tweaked a little weapon firing code

fixed chatter icon not disappearing
set bots correct walk speeds
implemented some sse2 stuff
update linux & android makefiles
This commit is contained in:
jeefo 2016-09-16 16:10:22 +03:00
commit c07065ca9d
15 changed files with 268 additions and 221 deletions

7
.gitignore vendored
View file

@ -17,7 +17,6 @@ $RECYCLE.BIN/
# =========================
# Operating System Files
# =========================
# OSX
# =========================
@ -35,6 +34,7 @@ Icon
# Files that might appear on external disk
.Spotlight-V100
.Trashes
/project/#Verone
*.pdb
*.asm
@ -53,14 +53,15 @@ Icon
*.suo
*.idb
*.vspx
project/yapb.vcxproj.user
*.user
*.psess
*.opendb
*.aps
*.db
*.enc
*.xml
/project/#Verone/incremental_index
*.vsp
*.lastcodeanalysissucceeded
*.json
*.html
*.settings

View file

@ -17,16 +17,12 @@
using namespace Math;
#include "platform.h"
#include <assert.h>
#include <ctype.h>
#include <limits.h>
#include <float.h>
#include <time.h>
#include <corelib.h>
// defines bots tasks
enum TaskID
{
@ -71,7 +67,7 @@ enum GameFlags
// bot menu ids
enum MenuId
{
BOT_MENU_IVALID = -1,
BOT_MENU_INVALID = 0,
BOT_MENU_MAIN,
BOT_MENU_FEATURES,
BOT_MENU_CONTROL,
@ -655,8 +651,6 @@ struct Client
int iconFlags[MAX_ENGINE_PLAYERS]; // flag holding chatter icons
float iconTimestamp[MAX_ENGINE_PLAYERS]; // timers for chatter icons
Client (void) : menu (BOT_MENU_IVALID) { }
};
// experience data hold in memory while playing
@ -1076,7 +1070,7 @@ private:
float GetBombTimeleft (void);
float GetEstimatedReachTime (void);
int GetAimingWaypoint (void);
int GetCampAimingWaypoint (void);
int GetAimingWaypoint (const Vector &to);
void FindShortestPath (int srcIndex, int destIndex);
@ -1214,6 +1208,9 @@ public:
/// the things that can be executed while skipping frames
void ThinkFrame (void);
void GotBlind (int alpha);
void GetDamage (edict_t *inflictor, int damage, int armor, int bits);
void DisplayDebugOverlay (void);
void NewRound (void);
void EquipInBuyzone (int buyState);
@ -1226,19 +1223,16 @@ public:
void DeleteSearchNodes (void);
void VerifyBreakable (edict_t *touch);
void RemoveCertainTask (TaskID id);
void PushTask (TaskID id, float desire, int data, float time, bool canContinue);
void RemoveCertainTask (TaskID id);
void ApplyTaskFilters (void);
void ResetTasks (void);
TaskItem *GetTask (void);
inline TaskID GetTaskId (void) { return GetTask ()->id; };
void TakeDamage (edict_t *inflictor, int damage, int armor, int bits);
void TakeBlinded (int r, int g, int b, int alpha);
void DiscardWeaponForUser (edict_t *user, bool discardC4);
void ReleaseUsedName (void);
void SayText (const char *text);
void TeamSayText (const char *text);
@ -1266,8 +1260,6 @@ public:
bool HasSecondaryWeapon(void);
bool HasShield (void);
bool IsShieldDrawn (void);
void ReleaseUsedName (void);
};
// manager class

View file

@ -21,12 +21,19 @@
#include <math.h>
#include <assert.h>
#ifdef _WIN32
#include <platform.h>
#ifdef PLATFORM_WIN32
#include <direct.h>
#else
#include <sys/stat.h>
#endif
#ifdef ENABLE_SSE_INTRINSICS
#include <xmmintrin.h>
#include <emmintrin.h>
#endif
//
// Basic Types
//
@ -69,7 +76,7 @@ static inline char *A_strdup (const char *str)
// From metamod-p
static inline bool A_IsValidCodePointer (const void *ptr)
{
#ifdef _WIN32
#ifdef PLATFORM_WIN32
if (IsBadCodePtr (reinterpret_cast <FARPROC> (ptr)))
return false;
#endif
@ -80,6 +87,11 @@ static inline bool A_IsValidCodePointer (const void *ptr)
return true;
}
#ifndef PLATFORM_WIN32
#define _unlink(p) unlink (p)
#define _mkdir(p) mkdir (p, 0777)
#endif
//
// Title: Utility Classes Header
//
@ -135,6 +147,106 @@ namespace Math
const float MATH_D2R = MATH_PI / 180.0f;
const float MATH_R2D = 180.0f / MATH_PI;
#ifdef ENABLE_SSE_INTRINSICS
//
// Function: mm_abs
//
// mm version if abs
//
static inline __m128 mm_abs (__m128 val)
{
return _mm_andnot_ps (_mm_castsi128_ps (_mm_set1_epi32 (0x80000000)), val);
};
//
// Function: mm_sine
//
// mm version if sine
//
static inline __m128 mm_sine (__m128 inp)
{
__m128 pi2 = _mm_set1_ps (MATH_PI * 2);
__m128 val = _mm_cmpnlt_ps (inp, _mm_set1_ps (MATH_PI));
val = _mm_and_ps (val, pi2);
inp = _mm_sub_ps (inp, val);
val = _mm_cmpngt_ps (inp, _mm_set1_ps (-MATH_PI));
val = _mm_and_ps (val, pi2);
inp = _mm_add_ps (inp, val);
val = _mm_mul_ps (mm_abs (inp), _mm_set1_ps (-4.0f / (MATH_PI * MATH_PI)));
val = _mm_add_ps (val, _mm_set1_ps (4.0f / MATH_PI));
__m128 res = _mm_mul_ps (val, inp);
val = _mm_mul_ps (mm_abs (res), res);
val = _mm_sub_ps (val, res);
val = _mm_mul_ps (val, _mm_set1_ps (0.225f));
res = _mm_add_ps (val, res);
return res;
}
#endif
//
// Function: A_sqrtf
//
// SIMD version of sqrtf.
//
static inline float A_sqrtf (float value)
{
#ifdef ENABLE_SSE_INTRINSICS
return _mm_cvtss_f32 (_mm_sqrt_ss (_mm_load_ss (&value)));
#else
return sqrtf (value);
#endif
}
//
// Function: A_sinf
//
// SIMD version of sinf.
//
static inline float A_sinf (float value)
{
#ifdef ENABLE_SSE_INTRINSICS
return _mm_cvtss_f32 (mm_sine (_mm_set1_ps (value)));
#else
return sinf (value);
#endif
}
//
// Function: A_cosf
//
// SIMD version of cosf.
//
static inline float A_cosf (float value)
{
#ifdef ENABLE_SSE_INTRINSICS
return _mm_cvtss_f32 (mm_sine (_mm_set1_ps (value + MATH_PI / 2.0f)));
#else
return cosf (value);
#endif
}
//
// Function: A_sincosf
//
// SIMD version of sincosf.
//
static inline void A_sincosf (float rad, float *sine, float *cosine)
{
#ifdef ENABLE_SSE_INTRINSICS
__m128 m_sincos = mm_sine (_mm_set_ps (0.0f, 0.0f, rad + MATH_PI / 2.f, rad));
__m128 m_cos = _mm_shuffle_ps (m_sincos, m_sincos, _MM_SHUFFLE (0, 0, 0, 1));
*sine = _mm_cvtss_f32 (m_sincos);
*cosine = _mm_cvtss_f32 (m_cos);
#else
*sine = sinf (rad);
*cosine = cosf (rad);
#endif
}
//
// Function: FltZero
//
@ -262,28 +374,11 @@ namespace Math
//
static inline void SineCosine (float rad, float *sine, float *cosine)
{
#if defined (_WIN32) && defined (_MSC_VER) && !defined (__clang__)
__asm
{
fld dword ptr[rad]
fsincos
mov ebx, [cosine]
fstp dword ptr[ebx]
mov ebx, [sine]
fstp dword ptr[ebx]
}
#elif defined (__ANDROID__)
#if defined (__ANDROID__)
*sine = sinf (rad);
*cosine = cosf (rad);
#elif defined (__linux__) || defined (GCC) || defined (__APPLE__)
double _cos, _sin;
__asm __volatile__ ("fsincos" : "=t" (_cos), "=u" (_sin) : "0" (rad));
*cosine = _cos;
*sine = _sin;
#else
*sine = sinf (rad);
*cosine = cosf (rad);
A_sincosf (rad, sine, cosine);
#endif
}
@ -294,7 +389,7 @@ namespace Math
template <typename Type> Type Clamp (Type x, Type a, Type b)
{
return x < a ? a : (x > b ? b : x);
return (x < a) ? a : ((x > b) ? b : x);
}
}
@ -549,7 +644,7 @@ public:
//
inline float GetLength (void) const
{
return sqrtf (x * x + y * y + z * z);
return Math::A_sqrtf (x * x + y * y + z * z);
}
//
@ -565,7 +660,7 @@ public:
//
inline float GetLength2D (void) const
{
return sqrtf (x * x + y * y);
return Math::A_sqrtf (x * x + y * y);
}
//
@ -3693,19 +3788,11 @@ public:
{
// create the directory
*ofs = 0;
#ifdef _WIN32
_mkdir (path);
#else
mkdir (path, 0777);
#endif
*ofs = '/';
}
}
#ifdef _WIN32
_mkdir (path);
#else
mkdir (path, 0777);
#endif
}
};

View file

@ -8,21 +8,13 @@
#ifndef META_API_H
#define META_API_H
typedef int (*GameAPI_t) (gamefuncs_t *, int);
typedef int (*GameAPI2_t) (gamefuncs_t *, int *);
typedef int (*NewAPI2_t) (gamefuncs_t *, int *);
typedef int (*EngineAPI_t) (enginefuncs_t *, int *);
typedef int (*GETENTITYAPI_FN) (gamefuncs_t *pFunctionTable, int interfaceVersion);
typedef int (*GETENTITYAPI2_FN) (gamefuncs_t *pFunctionTable, int *interfaceVersion);
typedef int (*GETNEWDLLFUNCTIONS_FN) (newgamefuncs_t *pFunctionTable, int *interfaceVersion);
typedef int (*GET_ENGINE_FUNCTIONS_FN) (enginefuncs_t *pengfuncsFromEngine, int *interfaceVersion);
#define META_INTERFACE_VERSION "5:13"
typedef enum
{
PT_NEVER = 0,
@ -107,7 +99,6 @@ typedef struct
#include "util.h"
// max buffer size for printed messages
#define MAX_LOGMSG_LEN 1024
@ -157,7 +148,6 @@ extern mutil_funcs_t *gpMetaUtilFuncs;
extern meta_globals_t *gpMetaGlobals;
extern metamod_funcs_t gMetaFunctionTable;
#define MDLL_FUNC gpGamedllFuncs->dllapi_table
#define MDLL_GameDLLInit MDLL_FUNC->pfnGameInit
@ -238,6 +228,5 @@ extern metamod_funcs_t gMetaFunctionTable;
#define IS_QUERYING_CLIENT_CVAR (*gpMetaUtilFuncs->pfnIsQueryingClienCVar_t)
#define MAKE_REQUESTID (*gpMetaUtilFuncs->pfnMakeRequestID)
#define GET_HOOK_TABLES (*gpMetaUtilFuncs->pfnGetHookTables)
uint16 FixedUnsigned16 (float fValue, float fScale);
short FixedSigned16 (float fValue, float fScale);
#endif

View file

@ -34,20 +34,25 @@
#error "Can't configure export macros. Compiler unrecognized."
#endif
// enable sse intrinsics
#define ENABLE_SSE_INTRINSICS 1
// operating system specific macros, functions and typedefs
#ifdef PLATFORM_WIN32
#include <direct.h>
#include <string.h>
#define DLL_ENTRYPOINT int __stdcall DllMain (HINSTANCE, DWORD dwReason, LPVOID)
#define STD_CALL __stdcall
#define DLL_ENTRYPOINT int STD_CALL DllMain (HINSTANCE, DWORD dwReason, LPVOID)
#define DLL_DETACHING (dwReason == DLL_PROCESS_DETACH)
#define DLL_RETENTRY return TRUE
#if defined (COMPILER_VISUALC)
#define DLL_GIVEFNPTRSTODLL extern "C" void __stdcall
#define DLL_GIVEFNPTRSTODLL extern "C" void STD_CALL
#elif defined (COMPILER_MINGW32)
#define DLL_GIVEFNPTRSTODLL SHARED_LIBRARAY_EXPORT void __stdcall
#define DLL_GIVEFNPTRSTODLL SHARED_LIBRARAY_EXPORT void STD_CALL
#endif
// specify export parameter
@ -56,12 +61,6 @@
#pragma comment (linker, "/SECTION:.data,RW")
#endif
typedef int (*GetEntityApi2_FN) (gamefuncs_t *, int);
typedef int (*GetNewEntityApi_FN) (newgamefuncs_t *, int *);
typedef int (*GetBlendingInterface_FN) (int, void **, void *, float (*)[3][4], float (*)[128][3][4]);
typedef void (*Entity_FN) (entvars_t *);
typedef void (__stdcall *GiveFnptrsToDll_FN) (enginefuncs_t *, globalvars_t *);
#elif defined (PLATFORM_LINUX) || defined (PLATFORM_OSX)
#include <unistd.h>
@ -81,18 +80,12 @@
#define DLL_RETENTRY return
#define DLL_GIVEFNPTRSTODLL extern "C" void __attribute__((visibility("default")))
#define STD_CALL /* */
#if defined (__ANDROID__)
#define PLATFORM_ANDROID 1
#undef ENABLE_SSE_INTRINSICS
#endif
typedef int (*GetEntityApi2_FN) (gamefuncs_t *, int);
typedef int (*GetNewEntityApi_FN) (newgamefuncs_t *, int *);
typedef int (*GetBlendingInterface_FN) (int, void **, void *, float (*)[3][4], float (*)[128][3][4]);
typedef void (*Entity_FN) (entvars_t *);
typedef void (*GiveFnptrsToDll_FN) (enginefuncs_t *, globalvars_t *);
// posix compatibility
#define _unlink unlink
#else
#error "Platform unrecognized."
#endif

View file

@ -22,7 +22,7 @@ OBJECTS = $(SRC_DIR)/basecode.cpp \
$(SRC_DIR)/support.cpp \
$(SRC_DIR)/waypoint.cpp \
C_OPT_FLAGS = -O2 -DNDEBUG -pipe -fno-strict-aliasing -mtune=generic
C_OPT_FLAGS = -Ofast -DNDEBUG -pipe -flto -fno-strict-aliasing -mtune=generic
C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3
C_GCC_FLAGS = -fvisibility=hidden
@ -49,10 +49,10 @@ ifeq "$(OS)" "Darwin"
else
LIB_EXT = so
CFLAGS += -DLINUX -D_LINUX -DPOSIX
LINK += -shared -lsupc++
LINK += -shared
endif
LINK += -m32 -lm -ldl
LINK += -m32 -lm -ldl -flto
CFLAGS += -msse2 -std=c++11 -m32 -Wall -Werror -Wextra
CPPFLAGS += -fno-exceptions -fno-rtti

View file

@ -10,7 +10,6 @@ ifeq ($(TARGET_ARCH_ABI),armeabi-v7a-hard)
LOCAL_MODULE_FILENAME = libyapb_hardfp
endif
LOCAL_CONLYFLAGS += -std=c99
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include \
$(LOCAL_PATH)/../include/engine
@ -28,7 +27,8 @@ LOCAL_SRC_FILES := \
support.cpp \
waypoint.cpp \
LOCAL_CFLAGS += -O2 -DLINUX -D_LINUX -DPOSIX -DHAVE_STDINT_H -D__extern_always_inline=inline -D_strdup=strdup -Dstricmp=strcasecmp -Dstrcmpi=strcasecmp -fno-strict-aliasing -Wall -Werror
LOCAL_CPPFLAGS += -w -fno-exceptions -fno-rtti
LOCAL_CFLAGS += -Ofast -std=c++11 -DLINUX -D_LINUX -DPOSIX -pipe -flto -fno-strict-aliasing -Wall -Werror
LOCAL_CPPFLAGS += -fno-exceptions -fno-rtti
LOCAL_LDFLAGS += -flto
include $(BUILD_SHARED_LIBRARY)

View file

@ -1007,9 +1007,6 @@ void Bot::InstantChatterMessage (int type)
if (!(g_gameFlags & GAME_SUPPORT_BOT_VOICE) || yb_communication_type.GetInt () != 2 || g_chatterFactory[type].IsEmpty ())
return;
if (m_notKilled)
EnableChatterIcon (true);
// delay only report team
if (type == Radio_ReportTeam)
{
@ -1019,9 +1016,10 @@ void Bot::InstantChatterMessage (int type)
m_timeRepotingInDelay = engine.Time () + Random.Float (30.0f, 60.0f);
}
auto playbackSound = g_chatterFactory[type].GetRandomElement ();
auto painSound = g_chatterFactory[Chatter_DiePain].GetRandomElement ();
const String &defaultSound = playbackSound.name;
const String &painSound = g_chatterFactory[Chatter_DiePain].GetRandomElement ().name;
if (m_notKilled)
EnableChatterIcon (true);
for (int i = 0; i < engine.MaxClients (); i++)
{
@ -1034,14 +1032,18 @@ void Bot::InstantChatterMessage (int type)
WRITE_BYTE (GetIndex ());
if (pev->deadflag & DEAD_DYING)
WRITE_STRING (FormatBuffer ("%s/%s.wav", yb_chatter_path.GetString (), painSound.GetBuffer ()));
{
client.iconTimestamp[GetIndex ()] = engine.Time () + painSound.duration;
WRITE_STRING (FormatBuffer ("%s/%s.wav", yb_chatter_path.GetString (), painSound.name.GetBuffer ()));
}
else if (!(pev->deadflag & DEAD_DEAD))
WRITE_STRING (FormatBuffer ("%s/%s.wav", yb_chatter_path.GetString (), defaultSound.GetBuffer ()));
{
client.iconTimestamp[GetIndex ()] = engine.Time () + playbackSound.duration;
WRITE_STRING (FormatBuffer ("%s/%s.wav", yb_chatter_path.GetString (), playbackSound.name.GetBuffer ()));
}
WRITE_SHORT (m_voicePitch);
MESSAGE_END ();
client.iconTimestamp[GetIndex ()] = engine.Time () + playbackSound.duration;
client.iconFlags[GetIndex ()] |= CF_ICON;
}
}
@ -2828,11 +2830,8 @@ void Bot::ChooseAimDirection (void)
{
bool changePredictedEnemy = true;
if (m_trackingEdict == m_lastEnemy)
{
if (m_timeNextTracking < engine.Time ())
if (m_trackingEdict == m_lastEnemy && m_timeNextTracking < engine.Time ())
changePredictedEnemy = false;
}
if (changePredictedEnemy)
{
@ -3605,10 +3604,10 @@ void Bot::RunTask_Camp (void)
if (--numFoundPoints >= 0)
m_camp = waypoints.GetPath (foundPoints[Random.Int (0, numFoundPoints)])->origin;
else
m_camp = waypoints.GetPath (GetAimingWaypoint ())->origin;
m_camp = waypoints.GetPath (GetCampAimingWaypoint ())->origin;
}
else
m_camp = waypoints.GetPath (GetAimingWaypoint ())->origin;
m_camp = waypoints.GetPath (GetCampAimingWaypoint ())->origin;
}
// press remembered crouch button
pev->button |= m_campButtons;
@ -5230,7 +5229,7 @@ int Bot::GetAmmo (void)
return m_ammo[g_weaponDefs[m_currentWeapon].ammo1];
}
void Bot::TakeDamage (edict_t *inflictor, int damage, int armor, int bits)
void Bot::GetDamage (edict_t *inflictor, int damage, int armor, int bits)
{
// this function gets called from the network message handler, when bot's gets hurt from any
// other player.
@ -5283,7 +5282,7 @@ void Bot::TakeDamage (edict_t *inflictor, int damage, int armor, int bits)
m_seeEnemyTime = engine.Time ();
}
if (yb_csdm_mode.GetInt () == 0)
if (!yb_csdm_mode.GetBool ())
CollectExperienceData (inflictor, armor + damage);
}
}
@ -5298,19 +5297,19 @@ void Bot::TakeDamage (edict_t *inflictor, int damage, int armor, int bits)
}
}
void Bot::TakeBlinded (int r, int g, int b, int alpha)
void Bot::GotBlind (int alpha)
{
// this function gets called by network message handler, when screenfade message get's send
// it's used to make bot blind from the grenade.
if (r != 255 || g != 255 || b != 255 || alpha <= 170)
m_maxViewDistance = Random.Float (10.0f, 20.0f);
m_blindTime = engine.Time () + static_cast <float> (alpha - 200) / 16.0f;
if (m_blindTime < engine.Time ())
return;
m_enemy = nullptr;
m_maxViewDistance = Random.Float (10.0f, 20.0f);
m_blindTime = engine.Time () + static_cast <float> (alpha - 200) / 16.0f;
if (m_difficulty <= 2)
{
m_blindMoveSpeed = 0.0f;
@ -5323,22 +5322,20 @@ void Bot::TakeBlinded (int r, int g, int b, int alpha)
m_blindMoveSpeed = -pev->maxspeed;
m_blindSidemoveSpeed = 0.0f;
float walkSpeed = GetWalkSpeed ();
if (Random.Int (0, 100) > 50)
m_blindSidemoveSpeed = walkSpeed;
m_blindSidemoveSpeed = pev->maxspeed;
else
m_blindSidemoveSpeed = -walkSpeed;
m_blindSidemoveSpeed = -pev->maxspeed;
if (pev->health < 85.0f)
m_blindMoveSpeed = -walkSpeed;
m_blindMoveSpeed = -pev->maxspeed;
else if (m_personality == PERSONALITY_CAREFUL)
{
m_blindMoveSpeed = 0.0f;
m_blindButton = IN_DUCK;
}
else
m_blindMoveSpeed = walkSpeed;
m_blindMoveSpeed = pev->maxspeed;
}
void Bot::CollectGoalExperience (int damage, int team)
@ -5456,7 +5453,7 @@ void Bot::HandleChatterMessage (const char *tempMessage)
{
// this function is added to prevent engine crashes with: 'Message XX started, before message XX ended', or something.
if (FStrEq (tempMessage, "#CTs_Win") && m_team == CT)
if ((m_team == CT && strcmp (tempMessage, "#CTs_Win") == 0) || (m_team == TERRORIST && strcmp (tempMessage, "#Terrorists_Win") == 0))
{
if (g_timeRoundMid > engine.Time ())
ChatterMessage (Chatter_QuicklyWonTheRound);
@ -5464,21 +5461,13 @@ void Bot::HandleChatterMessage (const char *tempMessage)
ChatterMessage (Chatter_WonTheRound);
}
if (FStrEq (tempMessage, "#Terrorists_Win") && m_team == TERRORIST)
{
if (g_timeRoundMid > engine.Time ())
ChatterMessage (Chatter_QuicklyWonTheRound);
else
ChatterMessage (Chatter_WonTheRound);
}
if (FStrEq (tempMessage, "#Bot_TeamAttack"))
else if (strcmp (tempMessage, "#Bot_TeamAttack") == 0)
ChatterMessage (Chatter_FriendlyFire);
if (FStrEq (tempMessage, "#Bot_NiceShotCommander"))
else if (strcmp (tempMessage, "#Bot_NiceShotCommander") == 0)
ChatterMessage (Chatter_NiceshotCommander);
if (FStrEq (tempMessage, "#Bot_NiceShotPall"))
else if (strcmp (tempMessage, "#Bot_NiceShotPall") == 0)
ChatterMessage (Chatter_NiceshotPall);
}
@ -5605,8 +5594,8 @@ Vector Bot::CheckToss(const Vector &start, const Vector &stop)
if ((midPoint.z < start.z) || (midPoint.z < end.z))
return Vector::GetZero ();
float timeOne = sqrtf ((midPoint.z - start.z) / (0.5f * gravity));
float timeTwo = sqrtf ((midPoint.z - end.z) / (0.5f * gravity));
float timeOne = A_sqrtf ((midPoint.z - start.z) / (0.5f * gravity));
float timeTwo = A_sqrtf ((midPoint.z - end.z) / (0.5f * gravity));
if (timeOne < 0.1f)
return Vector::GetZero ();
@ -6050,8 +6039,8 @@ bool Bot::IsBombDefusing (const Vector &bombOrigin)
float Bot::GetWalkSpeed (void)
{
if ((GetTaskId () == TASK_SEEKCOVER) || (pev->flags & FL_DUCKING) || (pev->button & IN_DUCK) || (pev->oldbuttons & IN_DUCK) || (m_currentTravelFlags & PATHFLAG_JUMP) || (m_currentPath != nullptr && m_currentPath->flags & FLAG_LADDER) || IsOnLadder () || IsInWater ())
if (GetTaskId () == TASK_SEEKCOVER || (pev->flags & FL_DUCKING) || (pev->button & IN_DUCK) || (pev->oldbuttons & IN_DUCK) || (m_currentTravelFlags & PATHFLAG_JUMP) || (m_currentPath != nullptr && m_currentPath->flags & FLAG_LADDER) || IsOnLadder () || IsInWater ())
return pev->maxspeed;
return static_cast <float> ((static_cast <int> (pev->maxspeed) * 0.5f) + (static_cast <int> (pev->maxspeed) / 50.0f)) - 18.0f;
return static_cast <float> (pev->maxspeed * 0.4f);
}

View file

@ -588,7 +588,7 @@ bool Bot::IsFriendInLineOfFire (float distance)
edict_t *ent = client.ent;
float friendDistance = (ent->v.origin - pev->origin).GetLength ();
float squareDistance = sqrtf (1089.0f + (friendDistance * friendDistance));
float squareDistance = A_sqrtf (1089.0f + (friendDistance * friendDistance));
if (GetShootingConeDeviation (GetEntity (), &ent->v.origin) > (friendDistance * friendDistance) / (squareDistance * squareDistance) && friendDistance <= distance)
return true;
@ -705,11 +705,11 @@ bool Bot::DoFirePause (float distance)
}
float offset = 0.0f;
const float BurstDistance = 300.0f;
const float SprayDistance = 200.0f;
if (distance < BurstDistance)
if (distance < SprayDistance)
return false;
else if (distance < 2 * BurstDistance)
else if (distance < 2 * SprayDistance)
offset = 10.0f;
else
offset = 5.0f;
@ -717,11 +717,16 @@ bool Bot::DoFirePause (float distance)
const float xPunch = DegreeToRadian (pev->punchangle.x);
const float yPunch = DegreeToRadian (pev->punchangle.y);
float interval = m_thinkInterval;
if ((g_gameFlags & GAME_LEGACY) && Math::FltZero (interval))
interval = (1.0f / 30.0f) * Random.Float (0.95f, 1.05f);
// check if we need to compensate recoil
if (tanf (sqrtf (fabsf (xPunch * xPunch) + fabsf (yPunch * yPunch))) * distance > offset + 30.0f + ((100 - (m_difficulty * 25)) / 100.f))
if (tanf (A_sqrtf (fabsf (xPunch * xPunch) + fabsf (yPunch * yPunch))) * distance > offset + 30.0f + ((100 - (m_difficulty * 25)) / 100.f))
{
if (m_firePause < engine.Time () - 0.4f)
m_firePause = engine.Time () + Random.Float (0.4f, 0.4f + 0.3f * ((100 - (m_difficulty * 25)) / 100.f));
if (m_firePause < engine.Time () - interval)
m_firePause = engine.Time () + Random.Float (0.5f, 0.5f + 0.3f * ((100.0f - (m_difficulty * 25)) / 100.f));
return true;
}

View file

@ -783,7 +783,7 @@ void Engine::ProcessMessageCapture (void *ptr)
damageBits = intVal;
if (bot != nullptr && (damageArmor > 0 || damageTaken > 0))
bot->TakeDamage (bot->pev->dmg_inflictor, damageTaken, damageArmor, damageBits);
bot->GetDamage (bot->pev->dmg_inflictor, damageTaken, damageArmor, damageBits);
break;
}
break;
@ -916,7 +916,8 @@ void Engine::ProcessMessageCapture (void *ptr)
break;
case 6:
bot->TakeBlinded (r, g, b, byteVal);
if (bot != nullptr && r >= 255 && g >= 255 && b >= 255 && byteVal > 170)
bot->GotBlind (byteVal);
break;
}
break;

View file

@ -197,7 +197,7 @@ int BotCommandHandler (edict_t *ent, const char *arg0, const char *arg1, const c
DisplayMenuToClient (ent, BOT_MENU_COMMANDS);
else
{
DisplayMenuToClient (ent, BOT_MENU_IVALID); // reset menu display
DisplayMenuToClient (ent, BOT_MENU_INVALID); // reset menu display
engine.CenterPrintf ("You're dead, and have no access to this menu");
}
}
@ -1217,14 +1217,14 @@ void ClientCommand (edict_t *ent)
return;
}
else if (A_stricmp (command, "menuselect") == 0 && !IsNullString (arg1) && g_clients[issuerPlayerIndex].menu != BOT_MENU_IVALID)
else if (A_stricmp (command, "menuselect") == 0 && !IsNullString (arg1) && g_clients[issuerPlayerIndex].menu != BOT_MENU_INVALID)
{
Client *client = &g_clients[issuerPlayerIndex];
int selection = atoi (arg1);
if (client->menu == BOT_MENU_WAYPOINT_TYPE)
{
DisplayMenuToClient (ent, BOT_MENU_IVALID); // reset menu display
DisplayMenuToClient (ent, BOT_MENU_INVALID); // reset menu display
switch (selection)
{
@ -1247,7 +1247,7 @@ void ClientCommand (edict_t *ent)
break;
case 10:
DisplayMenuToClient (ent, BOT_MENU_IVALID);
DisplayMenuToClient (ent, BOT_MENU_INVALID);
break;
}
if (g_gameFlags & GAME_METAMOD)
@ -1257,7 +1257,7 @@ void ClientCommand (edict_t *ent)
}
else if (client->menu == BOT_MENU_WAYPOINT_FLAG)
{
DisplayMenuToClient (ent, BOT_MENU_IVALID); // reset menu display
DisplayMenuToClient (ent, BOT_MENU_INVALID); // reset menu display
switch (selection)
{
@ -1288,7 +1288,7 @@ void ClientCommand (edict_t *ent)
}
else if (client->menu == BOT_MENU_WAYPOINT_MAIN_PAGE1)
{
DisplayMenuToClient (ent, BOT_MENU_IVALID); // reset menu display
DisplayMenuToClient (ent, BOT_MENU_INVALID); // reset menu display
switch (selection)
{
@ -1339,7 +1339,7 @@ void ClientCommand (edict_t *ent)
break;
case 10:
DisplayMenuToClient (ent, BOT_MENU_IVALID);
DisplayMenuToClient (ent, BOT_MENU_INVALID);
break;
}
if (g_gameFlags & GAME_METAMOD)
@ -1349,7 +1349,7 @@ void ClientCommand (edict_t *ent)
}
else if (client->menu == BOT_MENU_WAYPOINT_MAIN_PAGE2)
{
DisplayMenuToClient (ent, BOT_MENU_IVALID); // reset menu display
DisplayMenuToClient (ent, BOT_MENU_INVALID); // reset menu display
switch (selection)
{
@ -1445,7 +1445,7 @@ void ClientCommand (edict_t *ent)
}
else if (client->menu == BOT_MENU_WAYPOINT_RADIUS)
{
DisplayMenuToClient (ent, BOT_MENU_IVALID); // reset menu display
DisplayMenuToClient (ent, BOT_MENU_INVALID); // reset menu display
g_waypointOn = true; // turn waypoints on in case
@ -1461,7 +1461,7 @@ void ClientCommand (edict_t *ent)
}
else if (client->menu == BOT_MENU_MAIN)
{
DisplayMenuToClient (ent, BOT_MENU_IVALID); // reset menu display
DisplayMenuToClient (ent, BOT_MENU_INVALID); // reset menu display
switch (selection)
{
@ -1484,7 +1484,7 @@ void ClientCommand (edict_t *ent)
break;
case 10:
DisplayMenuToClient (ent, BOT_MENU_IVALID);
DisplayMenuToClient (ent, BOT_MENU_INVALID);
break;
}
@ -1495,7 +1495,7 @@ void ClientCommand (edict_t *ent)
}
else if (client->menu == BOT_MENU_CONTROL)
{
DisplayMenuToClient (ent, BOT_MENU_IVALID); // reset menu display
DisplayMenuToClient (ent, BOT_MENU_INVALID); // reset menu display
switch (selection)
{
@ -1520,7 +1520,7 @@ void ClientCommand (edict_t *ent)
break;
case 10:
DisplayMenuToClient (ent, BOT_MENU_IVALID);
DisplayMenuToClient (ent, BOT_MENU_INVALID);
break;
}
if (g_gameFlags & GAME_METAMOD)
@ -1530,7 +1530,7 @@ void ClientCommand (edict_t *ent)
}
else if (client->menu == BOT_MENU_FEATURES)
{
DisplayMenuToClient (ent, BOT_MENU_IVALID); // reset menu display
DisplayMenuToClient (ent, BOT_MENU_INVALID); // reset menu display
switch (selection)
{
@ -1557,13 +1557,13 @@ void ClientCommand (edict_t *ent)
DisplayMenuToClient (ent, BOT_MENU_COMMANDS);
else
{
DisplayMenuToClient (ent, BOT_MENU_IVALID); // reset menu display
DisplayMenuToClient (ent, BOT_MENU_INVALID); // reset menu display
engine.CenterPrintf ("You're dead, and have no access to this menu");
}
break;
case 10:
DisplayMenuToClient (ent, BOT_MENU_IVALID);
DisplayMenuToClient (ent, BOT_MENU_INVALID);
break;
}
if (g_gameFlags & GAME_METAMOD)
@ -1573,7 +1573,7 @@ void ClientCommand (edict_t *ent)
}
else if (client->menu == BOT_MENU_COMMANDS)
{
DisplayMenuToClient (ent, BOT_MENU_IVALID); // reset menu display
DisplayMenuToClient (ent, BOT_MENU_INVALID); // reset menu display
Bot *bot = nullptr;
switch (selection)
@ -1609,7 +1609,7 @@ void ClientCommand (edict_t *ent)
break;
case 10:
DisplayMenuToClient (ent, BOT_MENU_IVALID);
DisplayMenuToClient (ent, BOT_MENU_INVALID);
break;
}
@ -1620,7 +1620,7 @@ void ClientCommand (edict_t *ent)
}
else if (client->menu ==BOT_MENU_WAYPOINT_AUTOPATH)
{
DisplayMenuToClient (ent, BOT_MENU_IVALID); // reset menu display
DisplayMenuToClient (ent, BOT_MENU_INVALID); // reset menu display
const float autoDistanceValue[] = {0.0f, 100.0f, 130.0f, 160.0f, 190.0f, 220.0f, 250.0f };
@ -1639,7 +1639,7 @@ void ClientCommand (edict_t *ent)
}
else if (client->menu == BOT_MENU_WAYPOINT_PATH)
{
DisplayMenuToClient (ent, BOT_MENU_IVALID); // reset menu display
DisplayMenuToClient (ent, BOT_MENU_INVALID); // reset menu display
switch (selection)
{
@ -1656,7 +1656,7 @@ void ClientCommand (edict_t *ent)
break;
case 10:
DisplayMenuToClient (ent, BOT_MENU_IVALID);
DisplayMenuToClient (ent, BOT_MENU_INVALID);
break;
}
@ -1667,7 +1667,7 @@ void ClientCommand (edict_t *ent)
}
else if (client->menu == BOT_MENU_DIFFICULTY)
{
DisplayMenuToClient (ent, BOT_MENU_IVALID); // reset menu display
DisplayMenuToClient (ent, BOT_MENU_INVALID); // reset menu display
client->menu = BOT_MENU_PERSONALITY;
@ -1694,7 +1694,7 @@ void ClientCommand (edict_t *ent)
break;
case 10:
DisplayMenuToClient (ent, BOT_MENU_IVALID);
DisplayMenuToClient (ent, BOT_MENU_INVALID);
break;
}
@ -1708,7 +1708,7 @@ void ClientCommand (edict_t *ent)
}
else if (client->menu == BOT_MENU_TEAM_SELECT && fillCommand)
{
DisplayMenuToClient (ent, BOT_MENU_IVALID); // reset menu display
DisplayMenuToClient (ent, BOT_MENU_INVALID); // reset menu display
switch (selection)
{
@ -1724,7 +1724,7 @@ void ClientCommand (edict_t *ent)
break;
case 10:
DisplayMenuToClient (ent, BOT_MENU_IVALID);
DisplayMenuToClient (ent, BOT_MENU_INVALID);
break;
}
if (g_gameFlags & GAME_METAMOD)
@ -1734,7 +1734,7 @@ void ClientCommand (edict_t *ent)
}
else if (client->menu == BOT_MENU_PERSONALITY && fillCommand)
{
DisplayMenuToClient (ent, BOT_MENU_IVALID); // reset menu display
DisplayMenuToClient (ent, BOT_MENU_INVALID); // reset menu display
switch (selection)
{
@ -1745,7 +1745,7 @@ void ClientCommand (edict_t *ent)
bots.FillServer (fillServerTeam, selection - 2, g_storeAddbotVars[0]);
case 10:
DisplayMenuToClient (ent, BOT_MENU_IVALID);
DisplayMenuToClient (ent, BOT_MENU_INVALID);
break;
}
if (g_gameFlags & GAME_METAMOD)
@ -1755,7 +1755,7 @@ void ClientCommand (edict_t *ent)
}
else if (client->menu == BOT_MENU_TEAM_SELECT)
{
DisplayMenuToClient (ent, BOT_MENU_IVALID); // reset menu display
DisplayMenuToClient (ent, BOT_MENU_INVALID); // reset menu display
switch (selection)
{
@ -1778,7 +1778,7 @@ void ClientCommand (edict_t *ent)
break;
case 10:
DisplayMenuToClient (ent, BOT_MENU_IVALID);
DisplayMenuToClient (ent, BOT_MENU_INVALID);
break;
}
if (g_gameFlags & GAME_METAMOD)
@ -1788,7 +1788,7 @@ void ClientCommand (edict_t *ent)
}
else if (client->menu == BOT_MENU_PERSONALITY)
{
DisplayMenuToClient (ent, BOT_MENU_IVALID); // reset menu display
DisplayMenuToClient (ent, BOT_MENU_INVALID); // reset menu display
switch (selection)
{
@ -1801,7 +1801,7 @@ void ClientCommand (edict_t *ent)
break;
case 10:
DisplayMenuToClient (ent, BOT_MENU_IVALID);
DisplayMenuToClient (ent, BOT_MENU_INVALID);
break;
}
if (g_gameFlags & GAME_METAMOD)
@ -1811,7 +1811,7 @@ void ClientCommand (edict_t *ent)
}
else if (client->menu == BOT_MENU_TERRORIST_SELECT || client->menu == BOT_MENU_CT_SELECT)
{
DisplayMenuToClient (ent, BOT_MENU_IVALID); // reset menu display
DisplayMenuToClient (ent, BOT_MENU_INVALID); // reset menu display
switch (selection)
{
@ -1825,7 +1825,7 @@ void ClientCommand (edict_t *ent)
break;
case 10:
DisplayMenuToClient (ent, BOT_MENU_IVALID);
DisplayMenuToClient (ent, BOT_MENU_INVALID);
break;
}
if (g_gameFlags & GAME_METAMOD)
@ -1835,7 +1835,7 @@ void ClientCommand (edict_t *ent)
}
else if (client->menu == BOT_MENU_WEAPON_MODE)
{
DisplayMenuToClient (ent, BOT_MENU_IVALID); // reset menu display
DisplayMenuToClient (ent, BOT_MENU_INVALID); // reset menu display
switch (selection)
{
@ -1850,7 +1850,7 @@ void ClientCommand (edict_t *ent)
break;
case 10:
DisplayMenuToClient (ent, BOT_MENU_IVALID);
DisplayMenuToClient (ent, BOT_MENU_INVALID);
break;
}
if (g_gameFlags & GAME_METAMOD)
@ -1860,7 +1860,7 @@ void ClientCommand (edict_t *ent)
}
else if (client->menu == BOT_MENU_KICK_PAGE_1)
{
DisplayMenuToClient (ent, BOT_MENU_IVALID); // reset menu display
DisplayMenuToClient (ent, BOT_MENU_INVALID); // reset menu display
switch (selection)
{
@ -1890,7 +1890,7 @@ void ClientCommand (edict_t *ent)
}
else if (client->menu == BOT_MENU_KICK_PAGE_2)
{
DisplayMenuToClient (ent, BOT_MENU_IVALID); // reset menu display
DisplayMenuToClient (ent, BOT_MENU_INVALID); // reset menu display
switch (selection)
{
@ -1920,7 +1920,7 @@ void ClientCommand (edict_t *ent)
}
else if (client->menu == BOT_MENU_KICK_PAGE_3)
{
DisplayMenuToClient (ent, BOT_MENU_IVALID); // reset menu display
DisplayMenuToClient (ent, BOT_MENU_INVALID); // reset menu display
switch (selection)
{
@ -1950,7 +1950,7 @@ void ClientCommand (edict_t *ent)
}
else if (client->menu == BOT_MENU_KICK_PAGE_4)
{
DisplayMenuToClient (ent, BOT_MENU_IVALID); // reset menu display
DisplayMenuToClient (ent, BOT_MENU_INVALID); // reset menu display
switch (selection)
{
@ -2367,8 +2367,7 @@ void pfnClientCommand (edict_t *ent, char const *format, ...)
_vsnprintf (buffer, SIZEOF_CHAR (buffer), format, ap);
va_end (ap);
// is the target entity an official bot, or a third party bot ?
if (IsValidBot (ent))
if (bots.GetBot (ent))
{
engine.IssueBotCommand (ent, buffer);
@ -2771,6 +2770,7 @@ void pfnAlertMessage (ALERT_TYPE alertType, char *format, ...)
(*g_engfuncs.pfnAlertMessage) (alertType, buffer);
}
typedef void (*entity_func_t) (entvars_t *);
gamedll_funcs_t gameDLLFunc;
SHARED_LIBRARAY_EXPORT int GetEntityAPI2 (gamefuncs_t *functionTable, int *)
@ -2789,7 +2789,7 @@ SHARED_LIBRARAY_EXPORT int GetEntityAPI2 (gamefuncs_t *functionTable, int *)
if (!(g_gameFlags & GAME_METAMOD))
{
auto api_GetEntityAPI = g_gameLib->GetFuncAddr <GetEntityApi2_FN> ("GetEntityAPI");
auto api_GetEntityAPI = g_gameLib->GetFuncAddr <int (*) (gamefuncs_t *, int)> ("GetEntityAPI");
// pass other DLLs engine callbacks to function table...
if (api_GetEntityAPI (&g_functionTable, INTERFACE_VERSION) == 0)
@ -2848,7 +2848,7 @@ SHARED_LIBRARAY_EXPORT int GetNewDLLFunctions (newgamefuncs_t *functionTable, in
// pass them too, else the DLL interfacing wouldn't be complete and the game possibly wouldn't
// run properly.
auto api_GetNewDLLFunctions = g_gameLib->GetFuncAddr <GetNewEntityApi_FN> ("GetNewDLLFunctions");
auto api_GetNewDLLFunctions = g_gameLib->GetFuncAddr <int (*) (newgamefuncs_t *, int *)> ("GetNewDLLFunctions");
if (api_GetNewDLLFunctions == nullptr)
return FALSE;
@ -2908,7 +2908,7 @@ SHARED_LIBRARAY_EXPORT int Server_GetBlendingInterface (int version, void **ppin
// of the body move, which bones, which hitboxes and how) between the server and the game DLL.
// some MODs can be using a different hitbox scheme than the standard one.
auto api_GetBlendingInterface = g_gameLib->GetFuncAddr <GetBlendingInterface_FN> ("Server_GetBlendingInterface");
auto api_GetBlendingInterface = g_gameLib->GetFuncAddr <int (*) (int, void **, void *, float (*)[3][4], float (*)[128][3][4])> ("Server_GetBlendingInterface");
if (api_GetBlendingInterface == nullptr)
return FALSE;
@ -3021,7 +3021,7 @@ Library *LoadCSBinary (void)
return nullptr;
}
// detect if we're running modern game
Entity_FN entity = game->GetFuncAddr <Entity_FN> ("weapon_famas");
auto entity = game->GetFuncAddr <entity_func_t> ("weapon_famas");
// detect xash engine
if (g_engfuncs.pfnCVarGetPointer ("build") != nullptr)
@ -3147,7 +3147,7 @@ DLL_GIVEFNPTRSTODLL GiveFnptrsToDll (enginefuncs_t *functionTable, globalvars_t
}
#endif
auto api_GiveFnptrsToDll = g_gameLib->GetFuncAddr <GiveFnptrsToDll_FN> ("GiveFnptrsToDll");
auto api_GiveFnptrsToDll = g_gameLib->GetFuncAddr <void (STD_CALL *) (enginefuncs_t *, globalvars_t *)> ("GiveFnptrsToDll");
if (!api_GiveFnptrsToDll)
TerminateOnMalloc ();
@ -3173,10 +3173,10 @@ DLL_ENTRYPOINT
DLL_RETENTRY; // the return data type is OS specific too
}
void LinkEntity_Helper (Entity_FN &addr, const char *name, entvars_t *pev)
void LinkEntity_Helper (entity_func_t &addr, const char *name, entvars_t *pev)
{
if (addr == nullptr)
addr = g_gameLib->GetFuncAddr <Entity_FN > (name);
addr = g_gameLib->GetFuncAddr <entity_func_t> (name);
if (addr == nullptr)
return;
@ -3187,7 +3187,7 @@ void LinkEntity_Helper (Entity_FN &addr, const char *name, entvars_t *pev)
#define LINK_ENTITY(entityName) \
SHARED_LIBRARAY_EXPORT void entityName (entvars_t *pev) \
{ \
static Entity_FN addr; \
static entity_func_t addr; \
LinkEntity_Helper (addr, #entityName, pev); \
} \

View file

@ -171,12 +171,12 @@ BotCreationResult BotManager::CreateBot (const String &name, int difficulty, int
if (botName == nullptr)
continue;
if (botName->usedBy != 0)
if (botName->name.GetLength () < 3 || botName->usedBy != 0)
continue;
nameFound = true;
strncpy (outputName, botName->name, SIZEOF_CHAR (outputName));
strncpy (outputName, botName->name.GetBuffer (), SIZEOF_CHAR (outputName));
steamId = botName->steamId;
}
}
@ -191,11 +191,11 @@ BotCreationResult BotManager::CreateBot (const String &name, int difficulty, int
char prefixedName[33]; // temp buffer for storing modified name
if (!IsNullString (yb_name_prefix.GetString ()))
sprintf (prefixedName, "%s %s", yb_name_prefix.GetString (), outputName);
snprintf (prefixedName, SIZEOF_CHAR (prefixedName), "%s %s", yb_name_prefix.GetString (), outputName);
// buffer has been modified, copy to real name
if (!IsNullString (prefixedName))
strcpy (outputName, prefixedName);
strncpy (outputName, prefixedName, SIZEOF_CHAR (outputName));
}
bot = g_engfuncs.pfnCreateFakeClient (outputName);

View file

@ -3095,7 +3095,7 @@ void Bot::ChangeYaw (float speed)
#endif
int Bot::GetAimingWaypoint (void)
int Bot::GetCampAimingWaypoint (void)
{
// find a good waypoint to look at when camping

View file

@ -79,7 +79,7 @@ bool IsInViewCone (const Vector &origin, edict_t *ent)
{
MakeVectors (ent->v.v_angle);
if (((origin - (ent->v.origin + ent->v.view_ofs)).Normalize () | g_pGlobals->v_forward) >= cosf (((ent->v.fov > 0 ? ent->v.fov : 90.0f) * 0.5f) * MATH_D2R))
if (((origin - (ent->v.origin + ent->v.view_ofs)).Normalize () | g_pGlobals->v_forward) >= A_cosf (((ent->v.fov > 0 ? ent->v.fov : 90.0f) * 0.5f) * MATH_D2R))
return true;
return false;
@ -129,7 +129,7 @@ void DisplayMenuToClient (edict_t *ent, MenuId menu)
Client &client = g_clients[engine.IndexOfEntity (ent) - 1];
if (menu == BOT_MENU_IVALID)
if (menu == BOT_MENU_INVALID)
{
MESSAGE_BEGIN (MSG_ONE_UNRELIABLE, engine.FindMessageId (NETMSG_SHOWMENU), nullptr, ent);
WRITE_SHORT (0);
@ -138,33 +138,23 @@ void DisplayMenuToClient (edict_t *ent, MenuId menu)
WRITE_STRING ("");
MESSAGE_END ();
client.menu = BOT_MENU_IVALID;
client.menu = BOT_MENU_INVALID;
return;
}
int menuIndex = 0;
MenuText *menuPtr = nullptr;
for (int i = 0; i < ARRAYSIZE_HLSDK (g_menus); i++)
for (; menuIndex < ARRAYSIZE_HLSDK (g_menus); menuIndex++)
{
if (g_menus[i].id == menu)
{
menuPtr = &g_menus[i];
if (g_menus[menuIndex].id == menu)
break;
}
}
// worst case
if (!menuPtr)
{
client.menu = BOT_MENU_IVALID;
return;
}
const char *displayText = ((g_gameFlags & (GAME_XASH_ENGINE | GAME_MOBILITY)) && !yb_display_menu_text.GetBool ()) ? " " : menuPtr->text.GetBuffer ();
const auto &menuRef = g_menus[menuIndex];
const char *displayText = ((g_gameFlags & (GAME_XASH_ENGINE | GAME_MOBILITY)) && !yb_display_menu_text.GetBool ()) ? " " : menuRef.text.GetBuffer ();
while (strlen (displayText) >= 64)
{
MESSAGE_BEGIN (MSG_ONE_UNRELIABLE, engine.FindMessageId (NETMSG_SHOWMENU), nullptr, ent);
WRITE_SHORT (menuPtr->slots);
WRITE_SHORT (menuRef.slots);
WRITE_CHAR (-1);
WRITE_BYTE (1);
@ -176,7 +166,7 @@ void DisplayMenuToClient (edict_t *ent, MenuId menu)
}
MESSAGE_BEGIN (MSG_ONE_UNRELIABLE, engine.FindMessageId (NETMSG_SHOWMENU), nullptr, ent);
WRITE_SHORT (menuPtr->slots);
WRITE_SHORT (menuRef.slots);
WRITE_CHAR (-1);
WRITE_BYTE (0);
WRITE_STRING (displayText);
@ -756,7 +746,7 @@ void SoundAttachToClients (edict_t *ent, const char *sample, float volume)
// in case of worst case
if (index < 0 || index >= engine.MaxClients ())
index = 0;
return;
Client &client = g_clients[index];

View file

@ -1727,7 +1727,7 @@ void Waypoint::Think (void)
// if radius is nonzero, draw a full circle
if (path->radius > 0.0f)
{
float squareRoot = sqrtf (path->radius * path->radius * 0.5f);
float squareRoot = A_sqrtf (path->radius * path->radius * 0.5f);
engine.DrawLine (g_hostEntity, origin + Vector (path->radius, 0.0f, 0.0f), origin + Vector (squareRoot, -squareRoot, 0.0f), 5, 0, 0, 0, 255, 200, 0, 10);
engine.DrawLine (g_hostEntity, origin + Vector (squareRoot, -squareRoot, 0.0f), origin + Vector (0.0f, -path->radius, 0.0f), 5, 0, 0, 0, 255, 200, 0, 10);
@ -1743,7 +1743,7 @@ void Waypoint::Think (void)
}
else
{
float squareRoot = sqrtf (32.0f);
float squareRoot = A_sqrtf (32.0f);
engine.DrawLine (g_hostEntity, origin + Vector (squareRoot, -squareRoot, 0.0f), origin + Vector (-squareRoot, squareRoot, 0.0f), 5, 0, 255, 0, 0, 200, 0, 10);
engine.DrawLine (g_hostEntity, origin + Vector (-squareRoot, -squareRoot, 0.0f), origin + Vector (squareRoot, squareRoot, 0.0f), 5, 0, 255, 0, 0, 200, 0, 10);