fixed stack corruption in sound code
This commit is contained in:
parent
9e820b0a34
commit
a27d39a394
13 changed files with 155 additions and 143 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -58,3 +58,4 @@ project/yapb.vcxproj.user
|
|||
*.opendb
|
||||
*.aps
|
||||
*.db
|
||||
*.enc
|
||||
|
|
|
|||
|
|
@ -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 <entity_t> m_activeGrenades; // holds currently active grenades in the map
|
||||
Array <entity_t> m_trackedPlayers; // holds array of connected players, and waits the player joins team
|
||||
Array <edict_t *> m_activeGrenades; // holds currently active grenades in the map
|
||||
Array <edict_t *> 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 <entity_t> &GetActiveGrenades (void);
|
||||
const Array <edict_t *> &GetActiveGrenades (void);
|
||||
|
||||
inline bool HasActiveGrenades (void)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3965,8 +3965,7 @@ public:
|
|||
//
|
||||
static FORCEINLINE T *GetObject (void)
|
||||
{
|
||||
static T reference;
|
||||
return &reference;
|
||||
return &GetReference ();
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
|||
|
|
@ -63,35 +63,34 @@ enum NetMsgId
|
|||
NETMSG_NUM = 21
|
||||
};
|
||||
|
||||
// provides utility functions to not call original engine (less call-cost)
|
||||
class Engine : public Singleton <Engine>
|
||||
// variable reg pair
|
||||
struct VarPair
|
||||
{
|
||||
public:
|
||||
// variable reg pair
|
||||
struct VarPair
|
||||
{
|
||||
VarType type;
|
||||
cvar_t reg;
|
||||
bool regMissing;
|
||||
class ConVar *self;
|
||||
};
|
||||
};
|
||||
|
||||
// translation pair
|
||||
struct TranslatorPair
|
||||
{
|
||||
// translation pair
|
||||
struct TranslatorPair
|
||||
{
|
||||
const char *original;
|
||||
const char *translated;
|
||||
};
|
||||
};
|
||||
|
||||
// network message block
|
||||
struct MessageBlock
|
||||
{
|
||||
// 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 <Engine>
|
||||
{
|
||||
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 <edict_t *> (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 <int> (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 <int> (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 <float> (val)); }
|
||||
inline void SetString (const char *val) { g_engfuncs.pfnCvar_DirectSet (m_eptr, const_cast <char *> (val)); }
|
||||
FORCEINLINE bool GetBool (void) { return m_eptr->value > 0.0f; }
|
||||
FORCEINLINE int GetInt (void) { return static_cast <int> (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 <float> (val)); }
|
||||
FORCEINLINE void SetString (const char *val) { g_engfuncs.pfnCvar_DirectSet (m_eptr, const_cast <char *> (val)); }
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -137,18 +137,18 @@ public:
|
|||
return m_ptr;
|
||||
}
|
||||
|
||||
template <typename R> R GetFuncAddr (const char *function)
|
||||
inline void *GetFuncAddr (const char *function)
|
||||
{
|
||||
#ifdef PLATFORM_WIN32
|
||||
return reinterpret_cast <R> (GetProcAddress (GetHandle <HMODULE> (), function));
|
||||
return reinterpret_cast <void *> (GetProcAddress (static_cast <HMODULE> (m_ptr), function));
|
||||
#else
|
||||
return reinterpret_cast <R> (dlsym (m_ptr, function));
|
||||
return reinterpret_cast <void *> (dlsym (m_ptr, function));
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename R> R GetHandle (void)
|
||||
inline void *GetHandle (void)
|
||||
{
|
||||
return (R) m_ptr;
|
||||
return m_ptr;
|
||||
}
|
||||
|
||||
inline bool IsLoaded (void) const
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@
|
|||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<PlatformToolset>v120_xp</PlatformToolset>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
|
|
@ -131,6 +132,8 @@
|
|||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<FloatingPointModel>Strict</FloatingPointModel>
|
||||
<StringPooling>true</StringPooling>
|
||||
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
|
|
@ -178,13 +181,13 @@
|
|||
</Midl>
|
||||
<ClCompile>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<IntrinsicFunctions>false</IntrinsicFunctions>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<EnableFiberSafeOptimizations>false</EnableFiberSafeOptimizations>
|
||||
<AdditionalIncludeDirectories>..\mmgr;..\include\engine;..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>NDEBUG;WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ExceptionHandling>false</ExceptionHandling>
|
||||
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
|
||||
<EnableEnhancedInstructionSet>AdvancedVectorExtensions</EnableEnhancedInstructionSet>
|
||||
<PrecompiledHeaderFile>
|
||||
</PrecompiledHeaderFile>
|
||||
<PrecompiledHeaderOutputFile>.\release\inf\yapb.pch</PrecompiledHeaderOutputFile>
|
||||
|
|
@ -207,6 +210,7 @@
|
|||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<StringPooling>true</StringPooling>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
|
|
|
|||
|
|
@ -291,7 +291,7 @@ void Bot::AvoidGrenades (void)
|
|||
m_avoidGrenade = NULL;
|
||||
m_needAvoidGrenade = 0;
|
||||
}
|
||||
Array <entity_t> activeGrenades = bots.GetActiveGrenades ();
|
||||
Array <edict_t *> 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 <entity_t> activeGrenades = bots.GetActiveGrenades ();
|
||||
Array <edict_t *> 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++)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -850,7 +850,7 @@ void InitConfig (void)
|
|||
enum Lang { Lang_Original, Lang_Translate } langState = static_cast <Lang> (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 <char *> (yb_password_key.GetString ()))))
|
||||
client.flags &= ~CF_ADMIN;
|
||||
else if (strcmp (yb_password.GetString (), INFOKEY_VALUE (GET_INFOKEYBUFFER (client.ent), const_cast <char *> (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 <char *> (yb_password_key.GetString ()))) == 0)
|
||||
if (strcmp (yb_password.GetString (), INFOKEY_VALUE (GET_INFOKEYBUFFER (client.ent), const_cast <char *> (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
|
||||
|
|
@ -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 <FuncPointers_t> ("GiveFnptrsToDll");
|
||||
g_entityAPI = g_gameLib->GetFuncAddr <EntityAPI_t> ("GetEntityAPI");
|
||||
g_getNewEntityAPI = g_gameLib->GetFuncAddr <NewEntityAPI_t> ("GetNewDLLFunctions");
|
||||
g_serverBlendingAPI = g_gameLib->GetFuncAddr <BlendAPI_t> ("Server_GetBlendingInterface");
|
||||
g_funcPointers = static_cast <FuncPointers_t> (g_gameLib->GetFuncAddr ("GiveFnptrsToDll"));
|
||||
g_entityAPI = static_cast <EntityAPI_t> (g_gameLib->GetFuncAddr ("GetEntityAPI"));
|
||||
g_getNewEntityAPI = static_cast <NewEntityAPI_t> (g_gameLib->GetFuncAddr ("GetNewDLLFunctions"));
|
||||
g_serverBlendingAPI = static_cast <BlendAPI_t> (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 <EntityPtr_t > (name);
|
||||
if (*addr == NULL)
|
||||
*addr = static_cast <EntityPtr_t> (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...
|
||||
|
|
|
|||
|
|
@ -1488,7 +1488,7 @@ void BotManager::UpdateActiveGrenades (void)
|
|||
}
|
||||
}
|
||||
|
||||
const Array <entity_t> &BotManager::GetActiveGrenades (void)
|
||||
const Array <edict_t *> &BotManager::GetActiveGrenades (void)
|
||||
{
|
||||
return m_activeGrenades;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2428,7 +2428,6 @@ void Waypoint::SetBombPosition (bool shouldReset)
|
|||
|
||||
return;
|
||||
}
|
||||
|
||||
edict_t *ent = NULL;
|
||||
|
||||
while (!engine.IsNullEntity (ent = FIND_ENTITY_BY_CLASSNAME (ent, "grenade")))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue