diff --git a/.gitignore b/.gitignore index 0f364ff..59e6f29 100644 --- a/.gitignore +++ b/.gitignore @@ -58,3 +58,4 @@ project/yapb.vcxproj.user *.opendb *.aps *.db +*.enc diff --git a/include/core.h b/include/core.h index ed8ec36..2ea6343 100644 --- a/include/core.h +++ b/include/core.h @@ -606,7 +606,7 @@ struct Client Vector soundPosition; // position sound was played int team; // bot team - int realTeam; // real bot team in free for all mode (csdm) + int team2; // real bot team in free for all mode (csdm) int flags; // client flags float hearingDistance; // distance this sound is heared @@ -1237,8 +1237,8 @@ private: bool m_economicsGood[2]; // is team able to buy anything bool m_deathMsgSent; // for fakeping - Array m_activeGrenades; // holds currently active grenades in the map - Array m_trackedPlayers; // holds array of connected players, and waits the player joins team + Array m_activeGrenades; // holds currently active grenades in the map + Array m_trackedPlayers; // holds array of connected players, and waits the player joins team edict_t *m_killerEntity; // killer entity for bots @@ -1304,7 +1304,7 @@ public: // grenades void UpdateActiveGrenades (void); - const Array &GetActiveGrenades (void); + const Array &GetActiveGrenades (void); inline bool HasActiveGrenades (void) { diff --git a/include/corelib.h b/include/corelib.h index 196f431..ac8d38e 100644 --- a/include/corelib.h +++ b/include/corelib.h @@ -704,10 +704,10 @@ public: // // Function: BuildVectors // - // Builds a 3D referential from a view angle, that is to say, the relative "forward", "right" and "upward" direction - // that a player would have if he were facing this view angle. World angles are stored in Vector structs too, the - // "x" component corresponding to the X angle (horizontal angle), and the "y" component corresponding to the Y angle - // (vertical angle). + // Builds a 3D referential from a view angle, that is to say, the relative "forward", "right" and "upward" direction + // that a player would have if he were facing this view angle. World angles are stored in Vector structs too, the + // "x" component corresponding to the X angle (horizontal angle), and the "y" component corresponding to the Y angle + // (vertical angle). // // Parameters: // forward - Forward referential vector. @@ -3965,8 +3965,7 @@ public: // static FORCEINLINE T *GetObject (void) { - static T reference; - return &reference; + return &GetReference (); } // diff --git a/include/engine.h b/include/engine.h index 7136fc4..f1be88b 100644 --- a/include/engine.h +++ b/include/engine.h @@ -63,35 +63,34 @@ enum NetMsgId NETMSG_NUM = 21 }; +// variable reg pair +struct VarPair +{ + VarType type; + cvar_t reg; + bool regMissing; + class ConVar *self; +}; + +// translation pair +struct TranslatorPair +{ + const char *original; + const char *translated; +}; + +// network message block +struct MessageBlock +{ + int bot; + int state; + int msg; + int regMsgs[NETMSG_NUM]; +}; + // provides utility functions to not call original engine (less call-cost) class Engine : public Singleton { -public: - // variable reg pair - struct VarPair - { - VarType type; - cvar_t reg; - bool regMissing; - class ConVar *self; - }; - - // translation pair - struct TranslatorPair - { - const char *original; - const char *translated; - }; - - // network message block - struct MessageBlock - { - int bot; - int state; - int msg; - int regMsgs[NETMSG_NUM]; - }; - private: short m_drawModels[DRAW_NUM]; @@ -186,13 +185,13 @@ public: public: // get the current time on server - inline float Time (void) + FORCEINLINE float Time (void) { return g_pGlobals->time; } // get "maxplayers" limit on server - inline int MaxClients (void) + FORCEINLINE int MaxClients (void) { return g_pGlobals->maxClients; } @@ -227,19 +226,19 @@ public: } // gets edict pointer out of entity index - inline edict_t *EntityOfIndex (const int index) + FORCEINLINE edict_t *EntityOfIndex (const int index) { return static_cast (m_startEntity + index); }; // gets edict index out of it's pointer - inline int IndexOfEntity (const edict_t *ent) + FORCEINLINE int IndexOfEntity (const edict_t *ent) { return static_cast (ent - m_startEntity); }; // verify entity isn't null - inline bool IsNullEntity (const edict_t *ent) + FORCEINLINE bool IsNullEntity (const edict_t *ent) { return !ent || !IndexOfEntity (ent); } @@ -295,7 +294,7 @@ public: } // tries to set needed message id - void TryCaptureMessage (int type, int msgId) + FORCEINLINE void TryCaptureMessage (int type, int msgId) { if (type == m_msgBlock.regMsgs[msgId]) SetOngoingMessageId (msgId); @@ -315,11 +314,11 @@ public: public: ConVar (const char *name, const char *initval, VarType type = VT_NOSERVER, bool regMissing = false); - inline bool GetBool (void) { return m_eptr->value > 0.0f; } - inline int GetInt (void) { return static_cast (m_eptr->value); } - inline float GetFloat (void) { return m_eptr->value; } - inline const char *GetString (void) { return m_eptr->string; } - inline void SetFloat (float val) { m_eptr->value = val; } - inline void SetInt (int val) { SetFloat (static_cast (val)); } - inline void SetString (const char *val) { g_engfuncs.pfnCvar_DirectSet (m_eptr, const_cast (val)); } + FORCEINLINE bool GetBool (void) { return m_eptr->value > 0.0f; } + FORCEINLINE int GetInt (void) { return static_cast (m_eptr->value); } + FORCEINLINE float GetFloat (void) { return m_eptr->value; } + FORCEINLINE const char *GetString (void) { return m_eptr->string; } + FORCEINLINE void SetFloat (float val) { m_eptr->value = val; } + FORCEINLINE void SetInt (int val) { SetFloat (static_cast (val)); } + FORCEINLINE void SetString (const char *val) { g_engfuncs.pfnCvar_DirectSet (m_eptr, const_cast (val)); } }; diff --git a/include/engine/eiface.h b/include/engine/eiface.h index 8c32968..a0632b0 100644 --- a/include/engine/eiface.h +++ b/include/engine/eiface.h @@ -100,8 +100,6 @@ typedef struct int iHitgroup; // 0 == generic, non zero is specific body part } TraceResult; -typedef edict_t *entity_t; - typedef uint32 CRC32_t; // Engine hands this to DLLs for functionality callbacks diff --git a/include/platform.h b/include/platform.h index bb46882..791985e 100644 --- a/include/platform.h +++ b/include/platform.h @@ -137,18 +137,18 @@ public: return m_ptr; } - template R GetFuncAddr (const char *function) + inline void *GetFuncAddr (const char *function) { #ifdef PLATFORM_WIN32 - return reinterpret_cast (GetProcAddress (GetHandle (), function)); + return reinterpret_cast (GetProcAddress (static_cast (m_ptr), function)); #else - return reinterpret_cast (dlsym (m_ptr, function)); + return reinterpret_cast (dlsym (m_ptr, function)); #endif } - template R GetHandle (void) + inline void *GetHandle (void) { - return (R) m_ptr; + return m_ptr; } inline bool IsLoaded (void) const diff --git a/project/yapb.vcxproj b/project/yapb.vcxproj index 38f0790..9f08cd2 100644 --- a/project/yapb.vcxproj +++ b/project/yapb.vcxproj @@ -57,6 +57,7 @@ DynamicLibrary v120_xp false + true DynamicLibrary @@ -131,6 +132,8 @@ false Strict true + Default + true NDEBUG;%(PreprocessorDefinitions) @@ -178,13 +181,13 @@ AnySuitable - false + true Speed false ..\mmgr;..\include\engine;..\include;%(AdditionalIncludeDirectories) NDEBUG;WIN32;%(PreprocessorDefinitions) false - StreamingSIMDExtensions2 + AdvancedVectorExtensions .\release\inf\yapb.pch @@ -207,6 +210,7 @@ true MultiThreaded true + true NDEBUG;%(PreprocessorDefinitions) diff --git a/source/basecode.cpp b/source/basecode.cpp index ec98202..81f6add 100644 --- a/source/basecode.cpp +++ b/source/basecode.cpp @@ -291,7 +291,7 @@ void Bot::AvoidGrenades (void) m_avoidGrenade = NULL; m_needAvoidGrenade = 0; } - Array activeGrenades = bots.GetActiveGrenades (); + Array activeGrenades = bots.GetActiveGrenades (); // find all grenades on the map FOR_EACH_AE (activeGrenades, it) @@ -354,7 +354,7 @@ bool Bot::IsBehindSmokeClouds (edict_t *ent) return false; const Vector &betweenUs = (ent->v.origin - pev->origin).Normalize (); - Array activeGrenades = bots.GetActiveGrenades (); + Array activeGrenades = bots.GetActiveGrenades (); // find all grenades on the map FOR_EACH_AE (activeGrenades, it) @@ -2861,7 +2861,7 @@ void Bot::ChooseAimDirection (void) if (m_trackingEdict == m_lastEnemy) { if (m_timeNextTracking < engine.Time ()) - changePredictedEnemy = IsAlive (m_lastEnemy); + changePredictedEnemy = false; } if (changePredictedEnemy) @@ -2869,7 +2869,7 @@ void Bot::ChooseAimDirection (void) m_lookAt = waypoints.GetPath (GetAimingWaypoint (m_lastEnemyOrigin))->origin; m_camp = m_lookAt; - m_timeNextTracking = engine.Time () + 2.0f; + m_timeNextTracking = engine.Time () + 1.25f; m_trackingEdict = m_lastEnemy; } else @@ -3005,7 +3005,7 @@ void Bot::ThinkFrame (void) CheckMessageQueue (); // check for pending messages // remove voice icon - if (g_lastRadioTime[g_clients[engine.IndexOfEntity (GetEntity ()) - 1].realTeam] + Random.Float (0.8f, 2.1f) < engine.Time ()) + if (g_lastRadioTime[g_clients[engine.IndexOfEntity (GetEntity ()) - 1].team2] + Random.Float (0.8f, 2.1f) < engine.Time ()) SwitchChatterIcon (false); // hide icon if (botMovement) @@ -6048,6 +6048,9 @@ bool Bot::IsBombDefusing (const Vector &bombOrigin) { // this function finds if somebody currently defusing the bomb. + if (!g_bombPlanted) + return false; + bool defusingInProgress = false; for (int i = 0; i < engine.MaxClients (); i++) diff --git a/source/engine.cpp b/source/engine.cpp index 950a746..dc24469 100644 --- a/source/engine.cpp +++ b/source/engine.cpp @@ -19,6 +19,13 @@ Engine::Engine (void) for (int i = 0; i < NETMSG_NUM; i++) m_msgBlock.regMsgs[i] = NETMSG_UNDEFINED; + + m_isBotCommand = false; + m_argumentCount = 0; + memset (m_arguments, 0, sizeof (m_arguments)); + + m_cvars.RemoveAll (); + m_language.RemoveAll (); } Engine::~Engine (void) @@ -37,10 +44,6 @@ void Engine::Precache (edict_t *startEntity) m_drawModels[DRAW_SIMPLE] = PRECACHE_MODEL (ENGINE_STR ("sprites/laserbeam.spr")); m_drawModels[DRAW_ARROW] = PRECACHE_MODEL (ENGINE_STR ("sprites/arrow1.spr")); - m_isBotCommand = false; - m_argumentCount = 0; - m_arguments[0] = 0x0; - m_localEntity = NULL; m_startEntity = startEntity; } @@ -254,7 +257,9 @@ float Engine::GetWaveLength (const char *fileName) bool Engine::IsDedicatedServer (void) { // return true if server is dedicated server, false otherwise - return g_engfuncs.pfnIsDedicatedServer () > 0; + static bool dedicated = g_engfuncs.pfnIsDedicatedServer () > 0; + + return dedicated; } const char *Engine::GetModName (void) @@ -980,8 +985,6 @@ void Engine::ProcessMesageCapture (void *ptr) } else if (!g_bombPlanted && FStrEq (strVal, "#Bomb_Planted")) { - waypoints.SetBombPosition (); - g_bombPlanted = g_bombSayString = true; g_timeBombPlanted = Time (); @@ -998,6 +1001,7 @@ void Engine::ProcessMesageCapture (void *ptr) bot->ChatterMessage (Chatter_WhereIsTheBomb); } } + waypoints.SetBombPosition (); } else if (bot != NULL && FStrEq (strVal, "#Switch_To_BurstFire")) bot->m_weaponBurstMode = BM_ON; @@ -1017,19 +1021,19 @@ void Engine::ProcessMesageCapture (void *ptr) if (playerIndex >= 0 && playerIndex <= MaxClients ()) { #ifndef XASH_CSDM - Client &cl = g_clients[playerIndex - 1]; + Client &client = g_clients[playerIndex - 1]; if (intVal == 1) - cl.realTeam = TERRORIST; + client.team2 = TERRORIST; else if (intVal == 2) - cl.realTeam = CT; + client.team2 = CT; else - cl.realTeam = SPECTATOR; + client.team2 = SPECTATOR; if (yb_csdm_mode.GetInt () == 2) - cl.team = playerIndex; + client.team = playerIndex; else - cl.team = cl.realTeam; + client.team = client.team2; #endif } break; diff --git a/source/interface.cpp b/source/interface.cpp index 56f4038..c8fdeaa 100644 --- a/source/interface.cpp +++ b/source/interface.cpp @@ -850,7 +850,7 @@ void InitConfig (void) enum Lang { Lang_Original, Lang_Translate } langState = static_cast (2); char buffer[1024]; - Engine::TranslatorPair temp = {"", ""}; + TranslatorPair temp = {"", ""}; while (fp.GetBuffer (line, 255)) { @@ -2217,21 +2217,23 @@ void StartFrame (void) // code below is executed only on dedicated server if (engine.IsDedicatedServer () && !engine.IsNullEntity (player) && (player->v.flags & FL_CLIENT) && !(player->v.flags & FL_FAKECLIENT)) { - if (g_clients[i].flags & CF_ADMIN) + Client &client = g_clients[i]; + + if (client.flags & CF_ADMIN) { if (IsNullString (yb_password_key.GetString ()) && IsNullString (yb_password.GetString ())) - g_clients[i].flags &= ~CF_ADMIN; - else if (strcmp (yb_password.GetString (), INFOKEY_VALUE (GET_INFOKEYBUFFER (g_clients[i].ent), const_cast (yb_password_key.GetString ())))) + client.flags &= ~CF_ADMIN; + else if (strcmp (yb_password.GetString (), INFOKEY_VALUE (GET_INFOKEYBUFFER (client.ent), const_cast (yb_password_key.GetString ())))) { - g_clients[i].flags &= ~CF_ADMIN; + client.flags &= ~CF_ADMIN; engine.Printf ("Player %s had lost remote access to yapb.", STRING (player->v.netname)); } } - else if (!(g_clients[i].flags & CF_ADMIN) && !IsNullString (yb_password_key.GetString ()) && !IsNullString (yb_password.GetString ())) + else if (!(client.flags & CF_ADMIN) && !IsNullString (yb_password_key.GetString ()) && !IsNullString (yb_password.GetString ())) { - if (strcmp (yb_password.GetString (), INFOKEY_VALUE (GET_INFOKEYBUFFER (g_clients[i].ent), const_cast (yb_password_key.GetString ()))) == 0) + if (strcmp (yb_password.GetString (), INFOKEY_VALUE (GET_INFOKEYBUFFER (client.ent), const_cast (yb_password_key.GetString ()))) == 0) { - g_clients[i].flags |= CF_ADMIN; + client.flags |= CF_ADMIN; engine.Printf ("Player %s had gained full remote access to yapb.", STRING (player->v.netname)); } } @@ -2386,14 +2388,14 @@ void pfnClientCommand (edict_t *ent, char const *format, ...) // case it's a bot asking for a client command, we handle it like we do for bot commands va_list ap; - char buffer[1024]; + char buffer[MAX_PRINT_BUFFER]; va_start (ap, format); - _vsnprintf (buffer, sizeof (buffer), format, ap); + _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) || (ent->v.flags & FL_DORMANT)) + if (ent->v.flags & FL_FAKECLIENT) { if (g_isMetamod) RETURN_META (MRES_SUPERCEDE); // prevent bots to be forced to issue client commands @@ -2887,7 +2889,7 @@ SHARED_LIBRARAY_EXPORT int GetEngineFunctions (enginefuncs_t *functionTable, int { if (g_isMetamod) memset (functionTable, 0, sizeof (enginefuncs_t)); - + functionTable->pfnChangeLevel = pfnChangeLevel; functionTable->pfnFindEntityByString = pfnFindEntityByString; functionTable->pfnEmitSound = pfnEmitSound; @@ -2909,7 +2911,7 @@ SHARED_LIBRARAY_EXPORT int GetEngineFunctions (enginefuncs_t *functionTable, int functionTable->pfnCmd_Argc = pfnCmd_Argc; functionTable->pfnSetClientMaxspeed = pfnSetClientMaxspeed; functionTable->pfnAlertMessage = pfnAlertMessage; - + return TRUE; } @@ -3095,10 +3097,10 @@ DLL_GIVEFNPTRSTODLL GiveFnptrsToDll (enginefuncs_t *functionTable, globalvars_t AddLogEntry (true, LL_FATAL | LL_IGNORE, "Mod that you has started, not supported by this bot (gamedir: %s)", engine.GetModName ()); #endif - g_funcPointers = g_gameLib->GetFuncAddr ("GiveFnptrsToDll"); - g_entityAPI = g_gameLib->GetFuncAddr ("GetEntityAPI"); - g_getNewEntityAPI = g_gameLib->GetFuncAddr ("GetNewDLLFunctions"); - g_serverBlendingAPI = g_gameLib->GetFuncAddr ("Server_GetBlendingInterface"); + g_funcPointers = static_cast (g_gameLib->GetFuncAddr ("GiveFnptrsToDll")); + g_entityAPI = static_cast (g_gameLib->GetFuncAddr ("GetEntityAPI")); + g_getNewEntityAPI = static_cast (g_gameLib->GetFuncAddr ("GetNewDLLFunctions")); + g_serverBlendingAPI = static_cast (g_gameLib->GetFuncAddr ("Server_GetBlendingInterface")); if (!g_funcPointers || !g_entityAPI) TerminateOnMalloc (); @@ -3119,29 +3121,27 @@ DLL_ENTRYPOINT if (DLL_DETACHING) { FreeLibraryMemory (); // free everything that's freeable - delete g_gameLib; // if dynamic link library of mod is load, free it } DLL_RETENTRY; // the return data type is OS specific too } -static void LinkEntity_Helper (EntityPtr_t &addr, const char *name, entvars_t *pev) +void LinkEntity_Helper (EntityPtr_t *addr, const char *name, entvars_t *pev) { - // here we're see an ugliest hack :) - //if (addr == NULL || (g_gameFlags & GAME_OFFICIAL_CSBOT)) - addr = g_gameLib->GetFuncAddr (name); + if (*addr == NULL) + *addr = static_cast (g_gameLib->GetFuncAddr (name)); - if (addr == NULL) + if (*addr == NULL) return; - addr (pev); + (*addr) (pev); } #define LINK_ENTITY(entityName) \ SHARED_LIBRARAY_EXPORT void entityName (entvars_t *pev) \ { \ - static EntityPtr_t addr = NULL; \ - LinkEntity_Helper (addr, #entityName, pev); \ + static EntityPtr_t addr; \ + LinkEntity_Helper (&addr, #entityName, pev); \ } \ // entities in counter-strike... diff --git a/source/manager.cpp b/source/manager.cpp index 4957f2a..131bcf9 100644 --- a/source/manager.cpp +++ b/source/manager.cpp @@ -1488,7 +1488,7 @@ void BotManager::UpdateActiveGrenades (void) } } -const Array &BotManager::GetActiveGrenades (void) +const Array &BotManager::GetActiveGrenades (void) { return m_activeGrenades; } diff --git a/source/support.cpp b/source/support.cpp index da4a59e..0115ee7 100644 --- a/source/support.cpp +++ b/source/support.cpp @@ -714,7 +714,7 @@ void SoundAttachToClients (edict_t *ent, const char *sample, float volume) // the array associated with the entity if (engine.IsNullEntity (ent) || IsNullString (sample)) - return; // reliability check + return; const Vector &origin = engine.GetAbsOrigin (ent); int index = engine.IndexOfEntity (ent) - 1; @@ -729,7 +729,7 @@ void SoundAttachToClients (edict_t *ent, const char *sample, float volume) if (!(g_clients[i].flags & CF_USED) || !(g_clients[i].flags & CF_ALIVE)) continue; - float distance = (g_clients[i].ent->v.origin - origin).GetLengthSquared (); + float distance = (g_clients[i].origin - origin).GetLength (); // now find nearest player if (distance < nearestDistance) @@ -739,56 +739,61 @@ void SoundAttachToClients (edict_t *ent, const char *sample, float volume) } } } - Client *client = &g_clients[index]; + + // in case of worst case + if (index < 0 || index >= engine.MaxClients ()) + index = 0; + + Client &client = g_clients[index]; if (strncmp ("player/bhit_flesh", sample, 17) == 0 || strncmp ("player/headshot", sample, 15) == 0) { // hit/fall sound? - client->hearingDistance = 768.0f * volume; - client->timeSoundLasting = engine.Time () + 0.5f; - client->soundPosition = origin; + client.hearingDistance = 768.0f * volume; + client.timeSoundLasting = engine.Time () + 0.5f; + client.soundPosition = origin; } else if (strncmp ("items/gunpickup", sample, 15) == 0) { // weapon pickup? - client->hearingDistance = 768.0f * volume; - client->timeSoundLasting = engine.Time () + 0.5f; - client->soundPosition = origin; + client.hearingDistance = 768.0f * volume; + client.timeSoundLasting = engine.Time () + 0.5f; + client.soundPosition = origin; } else if (strncmp ("weapons/zoom", sample, 12) == 0) { // sniper zooming? - client->hearingDistance = 512.0f * volume; - client->timeSoundLasting = engine.Time () + 0.1f; - client->soundPosition = origin; + client.hearingDistance = 512.0f * volume; + client.timeSoundLasting = engine.Time () + 0.1f; + client.soundPosition = origin; } else if (strncmp ("items/9mmclip", sample, 13) == 0) { // ammo pickup? - client->hearingDistance = 512.0f * volume; - client->timeSoundLasting = engine.Time () + 0.1f; - client->soundPosition = origin; + client.hearingDistance = 512.0f * volume; + client.timeSoundLasting = engine.Time () + 0.1f; + client.soundPosition = origin; } else if (strncmp ("hostage/hos", sample, 11) == 0) { // CT used hostage? - client->hearingDistance = 1024.0f * volume; - client->timeSoundLasting = engine.Time () + 5.0f; - client->soundPosition = origin; + client.hearingDistance = 1024.0f * volume; + client.timeSoundLasting = engine.Time () + 5.0f; + client.soundPosition = origin; } else if (strncmp ("debris/bustmetal", sample, 16) == 0 || strncmp ("debris/bustglass", sample, 16) == 0) { // broke something? - client->hearingDistance = 1024.0f * volume; - client->timeSoundLasting = engine.Time () + 2.0f; - client->soundPosition = origin; + client.hearingDistance = 1024.0f * volume; + client.timeSoundLasting = engine.Time () + 2.0f; + client.soundPosition = origin; } else if (strncmp ("doors/doormove", sample, 14) == 0) { // someone opened a door - client->hearingDistance = 1024.0f * volume; - client->timeSoundLasting = engine.Time () + 3.0f; - client->soundPosition = origin; + client.hearingDistance = 1024.0f * volume; + client.timeSoundLasting = engine.Time () + 3.0f; + client.soundPosition = origin; } } @@ -800,29 +805,29 @@ void SoundSimulateUpdate (int playerIndex) if (playerIndex < 0 || playerIndex >= engine.MaxClients ()) return; // reliability check - Client *client = &g_clients[playerIndex]; + Client &client = g_clients[playerIndex]; float hearDistance = 0.0f; float timeSound = 0.0f; - if (client->ent->v.oldbuttons & IN_ATTACK) // pressed attack button? + if (client.ent->v.oldbuttons & IN_ATTACK) // pressed attack button? { hearDistance = 2048.0f; timeSound = engine.Time () + 0.3f; } - else if (client->ent->v.oldbuttons & IN_USE) // pressed used button? + else if (client.ent->v.oldbuttons & IN_USE) // pressed used button? { hearDistance = 512.0f; timeSound = engine.Time () + 0.5f; } - else if (client->ent->v.oldbuttons & IN_RELOAD) // pressed reload button? + else if (client.ent->v.oldbuttons & IN_RELOAD) // pressed reload button? { hearDistance = 512.0f; timeSound = engine.Time () + 0.5f; } - else if (client->ent->v.movetype == MOVETYPE_FLY) // uses ladder? + else if (client.ent->v.movetype == MOVETYPE_FLY) // uses ladder? { - if (fabsf (client->ent->v.velocity.z) > 50.0f) + if (fabsf (client.ent->v.velocity.z) > 50.0f) { hearDistance = 1024.0f; timeSound = engine.Time () + 0.3f; @@ -835,7 +840,7 @@ void SoundSimulateUpdate (int playerIndex) if (mp_footsteps.GetBool ()) { // moves fast enough? - hearDistance = 1280.0f * (client->ent->v.velocity.GetLength2D () / 260.0f); + hearDistance = 1280.0f * (client.ent->v.velocity.GetLength2D () / 260.0f); timeSound = engine.Time () + 0.3f; } } @@ -844,22 +849,22 @@ void SoundSimulateUpdate (int playerIndex) return; // didn't issue sound? // some sound already associated - if (client->timeSoundLasting > engine.Time ()) + if (client.timeSoundLasting > engine.Time ()) { - if (client->hearingDistance <= hearDistance) + if (client.hearingDistance <= hearDistance) { // override it with new - client->hearingDistance = hearDistance; - client->timeSoundLasting = timeSound; - client->soundPosition = client->ent->v.origin; + client.hearingDistance = hearDistance; + client.timeSoundLasting = timeSound; + client.soundPosition = client.ent->v.origin; } } else { // just remember it - client->hearingDistance = hearDistance; - client->timeSoundLasting = timeSound; - client->soundPosition = client->ent->v.origin; + client.hearingDistance = hearDistance; + client.timeSoundLasting = timeSound; + client.soundPosition = client.ent->v.origin; } } diff --git a/source/waypoint.cpp b/source/waypoint.cpp index e8a0fc8..1f8040d 100644 --- a/source/waypoint.cpp +++ b/source/waypoint.cpp @@ -2428,7 +2428,6 @@ void Waypoint::SetBombPosition (bool shouldReset) return; } - edict_t *ent = NULL; while (!engine.IsNullEntity (ent = FIND_ENTITY_BY_CLASSNAME (ent, "grenade")))