fixed bomb defuse check doesn't verify pressing IN_USE button of client
fixed potential crash bug in IsPointOccupied processing global refactoring
This commit is contained in:
parent
f8344a464e
commit
d5a8b3642b
18 changed files with 717 additions and 739 deletions
155
include/core.h
155
include/core.h
|
|
@ -361,6 +361,15 @@ enum LiftState
|
|||
LIFT_LEAVING
|
||||
};
|
||||
|
||||
// wayponit auto-downloader
|
||||
enum WaypointDownloadError
|
||||
{
|
||||
WDE_SOCKET_ERROR,
|
||||
WDE_CONNECT_ERROR,
|
||||
WDE_NOTFOUND_ERROR,
|
||||
WDE_NOERROR
|
||||
};
|
||||
|
||||
// game start messages for counter-strike...
|
||||
enum GameStartMessage
|
||||
{
|
||||
|
|
@ -376,6 +385,7 @@ enum GameStartMessage
|
|||
// netmessage functions
|
||||
enum NetworkMessage
|
||||
{
|
||||
NETMSG_UNDEFINED = 0,
|
||||
NETMSG_VGUI = 1,
|
||||
NETMSG_SHOWMENU = 2,
|
||||
NETMSG_WEAPONLIST = 3,
|
||||
|
|
@ -395,7 +405,7 @@ enum NetworkMessage
|
|||
NETMSG_SAYTEXT = 18,
|
||||
NETMSG_BOTVOICE = 19,
|
||||
NETMSG_RESETHUD = 20,
|
||||
NETMSG_UNDEFINED = 0
|
||||
NETMSG_NUM = 21
|
||||
};
|
||||
|
||||
// sensing states
|
||||
|
|
@ -1226,7 +1236,7 @@ public:
|
|||
};
|
||||
|
||||
// manager class
|
||||
class BotManager : public Singleton <BotManager>
|
||||
class BotManager
|
||||
{
|
||||
private:
|
||||
Array <CreateQueue> m_creationTab; // bot creation tab
|
||||
|
|
@ -1322,7 +1332,7 @@ public:
|
|||
};
|
||||
|
||||
// texts localizer
|
||||
class Localizer : public Singleton <Localizer>
|
||||
class Localizer
|
||||
{
|
||||
public:
|
||||
Array <LanguageItem> m_langTab;
|
||||
|
|
@ -1336,13 +1346,13 @@ public:
|
|||
};
|
||||
|
||||
// netmessage handler class
|
||||
class NetworkMsg : public Singleton <NetworkMsg>
|
||||
class NetworkMsg
|
||||
{
|
||||
private:
|
||||
Bot *m_bot;
|
||||
int m_state;
|
||||
int m_message;
|
||||
int m_registerdMessages[NETMSG_RESETHUD + 1];
|
||||
int m_registerdMessages[NETMSG_NUM];
|
||||
|
||||
public:
|
||||
NetworkMsg (void);
|
||||
|
|
@ -1360,7 +1370,7 @@ public:
|
|||
};
|
||||
|
||||
// waypoint operation class
|
||||
class Waypoint : public Singleton <Waypoint>
|
||||
class Waypoint
|
||||
{
|
||||
friend class Bot;
|
||||
|
||||
|
|
@ -1468,6 +1478,7 @@ public:
|
|||
{
|
||||
return m_foundBombOrigin;
|
||||
}
|
||||
const char *GetDataDir (void);
|
||||
|
||||
void SetBombPosition (bool shouldReset = false);
|
||||
String CheckSubfolderFile (void);
|
||||
|
|
@ -1482,141 +1493,41 @@ public:
|
|||
|
||||
return GetPath (index);
|
||||
}
|
||||
};
|
||||
|
||||
// wayponit auto-downloader
|
||||
enum WaypointDownloadError
|
||||
{
|
||||
WDE_SOCKET_ERROR,
|
||||
WDE_CONNECT_ERROR,
|
||||
WDE_NOTFOUND_ERROR,
|
||||
WDE_NOERROR
|
||||
};
|
||||
|
||||
class WaypointDownloader
|
||||
{
|
||||
public:
|
||||
|
||||
// free's socket handle
|
||||
void FreeSocket (int sock);
|
||||
void CloseSocketHandle (int sock);
|
||||
|
||||
// do actually downloading of waypoint file
|
||||
WaypointDownloadError DoDownload (void);
|
||||
WaypointDownloadError RequestWaypoint (void);
|
||||
};
|
||||
|
||||
enum VarType
|
||||
{
|
||||
VT_NORMAL = 0,
|
||||
VT_READONLY,
|
||||
VT_PASSWORD,
|
||||
VT_NOSERVER,
|
||||
VT_NOREGISTER
|
||||
};
|
||||
#include <engine.h>
|
||||
|
||||
class ConVarWrapper : public Singleton <ConVarWrapper>
|
||||
{
|
||||
private:
|
||||
struct VarPair
|
||||
{
|
||||
VarType type;
|
||||
cvar_t reg;
|
||||
class ConVar *self;
|
||||
};
|
||||
Array <VarPair> m_regs;
|
||||
|
||||
public:
|
||||
void RegisterVariable (const char *variable, const char *value, VarType varType, ConVar *self);
|
||||
void PushRegisteredConVarsToEngine (bool gameVars = false);
|
||||
};
|
||||
|
||||
|
||||
// expose bot globals
|
||||
#define netmsg NetworkMsg::GetReference ()
|
||||
#define locale Localizer::GetReference ()
|
||||
#define convars ConVarWrapper::GetReference ()
|
||||
#define waypoints Waypoint::GetReference ()
|
||||
#define bots BotManager::GetReference ()
|
||||
|
||||
// simplify access for console variables
|
||||
class ConVar
|
||||
{
|
||||
public:
|
||||
cvar_t *m_eptr;
|
||||
|
||||
public:
|
||||
ConVar (const char *name, const char *initval, VarType type = VT_NOSERVER)
|
||||
{
|
||||
m_eptr = NULL;
|
||||
|
||||
convars.RegisterVariable (name, initval, type, this);
|
||||
}
|
||||
|
||||
inline bool GetBool(void)
|
||||
{
|
||||
return m_eptr->value > 0.0f;
|
||||
}
|
||||
|
||||
inline int GetInt (void)
|
||||
{
|
||||
return static_cast <int> (m_eptr->value);
|
||||
}
|
||||
|
||||
inline int GetFlags (void)
|
||||
{
|
||||
return m_eptr->flags;
|
||||
}
|
||||
|
||||
inline float GetFloat (void)
|
||||
{
|
||||
return m_eptr->value;
|
||||
}
|
||||
|
||||
inline const char *GetString (void)
|
||||
{
|
||||
return m_eptr->string;
|
||||
}
|
||||
|
||||
inline const char *GetName (void)
|
||||
{
|
||||
return m_eptr->name;
|
||||
}
|
||||
|
||||
inline void SetFloat (float val)
|
||||
{
|
||||
g_engfuncs.pfnCVarSetFloat (m_eptr->name, val);
|
||||
}
|
||||
|
||||
inline void SetInt (int val)
|
||||
{
|
||||
SetFloat (static_cast <float> (val));
|
||||
}
|
||||
|
||||
inline void SetString (const char *val)
|
||||
{
|
||||
g_engfuncs.pfnCVarSetString (m_eptr->name, val);
|
||||
}
|
||||
};
|
||||
// expose bot super-globals
|
||||
extern NetworkMsg netmsg;
|
||||
extern Localizer locale;
|
||||
extern Waypoint waypoints;
|
||||
extern BotManager bots;
|
||||
extern Engine engine;
|
||||
|
||||
// prototypes of bot functions...
|
||||
extern int GetWeaponReturn (bool isString, const char *weaponAlias, int weaponIndex = -1);
|
||||
extern int GetWeaponPenetrationPower (int id);
|
||||
extern int GenerateBuildNumber (void);
|
||||
extern float GetShootingConeDeviation (edict_t *ent, Vector *position);
|
||||
|
||||
extern bool IsVisible (const Vector &origin, edict_t *ent);
|
||||
extern bool IsAlive (edict_t *ent);
|
||||
extern bool IsInViewCone (const Vector &origin, edict_t *ent);
|
||||
extern int GetWeaponPenetrationPower (int id);
|
||||
|
||||
extern bool IsValidBot (edict_t *ent);
|
||||
extern bool IsValidPlayer (edict_t *ent);
|
||||
extern bool IsPlayerVIP (edict_t *ent);
|
||||
extern bool OpenConfig (const char *fileName, const char *errorIfNotExists, File *outFile, bool languageDependant = false);
|
||||
extern bool FindNearestPlayer (void **holder, edict_t *to, float searchDistance = 4096.0, bool sameTeam = false, bool needBot = false, bool needAlive = false, bool needDrawn = false);
|
||||
extern const char *GetField (const char *string, int fieldId, bool endLine = false);
|
||||
extern const char *FormatBuffer (const char *format, ...);
|
||||
extern uint16 GenerateBuildNumber (void);
|
||||
|
||||
extern void FreeLibraryMemory (void);
|
||||
extern void RoundInit (void);
|
||||
extern void FakeClientCommand (edict_t *fakeClient, const char *format, ...);
|
||||
extern void strtrim (char *string);
|
||||
extern void CreatePath (char *path);
|
||||
extern void CheckWelcomeMessage (void);
|
||||
extern void DetectCSVersion (void);
|
||||
extern void AddLogEntry (bool outputToConsole, int logLevel, const char *format, ...);
|
||||
|
|
@ -1624,7 +1535,8 @@ extern void DisplayMenuToClient (edict_t *ent, MenuText *menu);
|
|||
extern void DecalTrace (entvars_t *pev, TraceResult *trace, int logotypeIndex);
|
||||
extern void SoundAttachToClients (edict_t *ent, const char *sample, float volume);
|
||||
extern void SoundSimulateUpdate (int playerIndex);
|
||||
extern const char *GetWaypointDir (void);
|
||||
|
||||
extern const char *FormatBuffer (const char *format, ...);
|
||||
|
||||
// very global convars
|
||||
extern ConVar yb_jasonmode;
|
||||
|
|
@ -1632,7 +1544,6 @@ extern ConVar yb_communication_type;
|
|||
extern ConVar yb_csdm_mode;
|
||||
extern ConVar yb_ignore_enemies;
|
||||
|
||||
#include <engine.h>
|
||||
#include <globals.h>
|
||||
#include <compress.h>
|
||||
#include <resource.h>
|
||||
|
|
|
|||
|
|
@ -21,6 +21,10 @@
|
|||
#include <math.h>
|
||||
#include <assert.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <direct.h>
|
||||
#endif
|
||||
|
||||
//
|
||||
// Title: Utility Classes Header
|
||||
//
|
||||
|
|
@ -3296,6 +3300,56 @@ public:
|
|||
|
||||
return Split (sep);
|
||||
}
|
||||
|
||||
public:
|
||||
//
|
||||
// Function: TrimExternalBuffer
|
||||
// Trims string from both sides.
|
||||
//
|
||||
// Returns:
|
||||
// None
|
||||
//
|
||||
static inline void TrimExternalBuffer (char *string)
|
||||
{
|
||||
char *ptr = string;
|
||||
|
||||
int length = 0, toggleFlag = 0, increment = 0;
|
||||
int i = 0;
|
||||
|
||||
while (*ptr++)
|
||||
length++;
|
||||
|
||||
for (i = length - 1; i >= 0; i--)
|
||||
{
|
||||
if (!isspace (string[i]))
|
||||
break;
|
||||
else
|
||||
{
|
||||
string[i] = 0;
|
||||
length--;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < length; i++)
|
||||
{
|
||||
if (isspace (string[i]) && !toggleFlag)
|
||||
{
|
||||
increment++;
|
||||
|
||||
if (increment + i < length)
|
||||
string[i] = string[increment + i];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!toggleFlag)
|
||||
toggleFlag = 1;
|
||||
|
||||
if (increment)
|
||||
string[i] = string[increment + i];
|
||||
}
|
||||
}
|
||||
string[length] = 0;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
|
|
@ -3615,6 +3669,29 @@ public:
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline void CreatePath (char *path)
|
||||
{
|
||||
for (char *ofs = path + 1; *ofs; ofs++)
|
||||
{
|
||||
if (*ofs == '/')
|
||||
{
|
||||
// create the directory
|
||||
*ofs = 0;
|
||||
#ifdef _WIN32
|
||||
_mkdir (path);
|
||||
#else
|
||||
mkdir (path, 0777);
|
||||
#endif
|
||||
*ofs = '/';
|
||||
}
|
||||
}
|
||||
#ifdef _WIN32
|
||||
_mkdir (path);
|
||||
#else
|
||||
mkdir (path, 0777);
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
|
|
|
|||
|
|
@ -28,12 +28,44 @@ enum TraceIgnore
|
|||
TRACE_IGNORE_EVERYTHING = TRACE_IGNORE_GLASS | TRACE_IGNORE_MONSTERS
|
||||
};
|
||||
|
||||
// variable type
|
||||
enum VarType
|
||||
{
|
||||
VT_NORMAL = 0,
|
||||
VT_READONLY,
|
||||
VT_PASSWORD,
|
||||
VT_NOSERVER,
|
||||
VT_NOREGISTER
|
||||
};
|
||||
|
||||
// need since we don't want to use Singleton on engine class
|
||||
class ConVarWrapper : public Singleton <ConVarWrapper>
|
||||
{
|
||||
private:
|
||||
struct VarPair
|
||||
{
|
||||
VarType type;
|
||||
cvar_t reg;
|
||||
class ConVar *self;
|
||||
};
|
||||
Array <VarPair> m_regs;
|
||||
|
||||
public:
|
||||
void RegisterVariable (const char *variable, const char *value, VarType varType, ConVar *self);
|
||||
void PushRegisteredConVarsToEngine (bool gameVars = false);
|
||||
};
|
||||
|
||||
// provides utility functions to not call original engine (less call-cost)
|
||||
class Engine
|
||||
{
|
||||
private:
|
||||
short m_drawModels[DRAW_NUM];
|
||||
|
||||
// bot client command
|
||||
bool m_isBotCommand;
|
||||
char m_arguments[256];
|
||||
int m_argumentCount;
|
||||
|
||||
// public functions
|
||||
public:
|
||||
|
||||
|
|
@ -85,21 +117,72 @@ public:
|
|||
// play's sound to client
|
||||
void EmitSound (edict_t *ent, const char *sound);
|
||||
|
||||
// sends bot command
|
||||
void IssueBotCommand (edict_t *ent, const char *fmt, ...);
|
||||
|
||||
// public inlines
|
||||
public:
|
||||
|
||||
// get the current time on server
|
||||
static inline float Time (void)
|
||||
inline float Time (void)
|
||||
{
|
||||
return g_pGlobals->time;
|
||||
}
|
||||
|
||||
// get "maxplayers" limit on server
|
||||
static inline int MaxClients (void)
|
||||
inline int MaxClients (void)
|
||||
{
|
||||
return g_pGlobals->maxClients;
|
||||
}
|
||||
|
||||
// get the fakeclient command interface
|
||||
inline bool IsBotCommand (void)
|
||||
{
|
||||
return m_isBotCommand;
|
||||
}
|
||||
|
||||
// gets custom engine args for client command
|
||||
inline const char *GetOverrideArgs (void)
|
||||
{
|
||||
if (strncmp ("say ", m_arguments, 4) == 0)
|
||||
return &m_arguments[4];
|
||||
else if (strncmp ("say_team ", m_arguments, 9) == 0)
|
||||
return &m_arguments[9];
|
||||
|
||||
return m_arguments;
|
||||
}
|
||||
|
||||
// gets custom engine argv for client command
|
||||
inline const char *GetOverrideArgv (int num)
|
||||
{
|
||||
return ExtractSingleField (m_arguments, num, false);
|
||||
}
|
||||
|
||||
// gets custom engine argc for client command
|
||||
inline int GetOverrideArgc (void)
|
||||
{
|
||||
return m_argumentCount;
|
||||
}
|
||||
|
||||
// static utility functions
|
||||
public:
|
||||
static const char *ExtractSingleField (const char *string, int id, bool terminate);
|
||||
};
|
||||
|
||||
// provides quick access to engine instance
|
||||
extern Engine engine;
|
||||
// simplify access for console variables
|
||||
class ConVar
|
||||
{
|
||||
public:
|
||||
cvar_t *m_eptr;
|
||||
|
||||
public:
|
||||
ConVar (const char *name, const char *initval, VarType type = VT_NOSERVER);
|
||||
|
||||
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.pfnCVarSetString (m_eptr->name, val); }
|
||||
};
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ extern bool g_autoWaypoint;
|
|||
extern bool g_botsCanPause;
|
||||
extern bool g_editNoclip;
|
||||
extern bool g_isMetamod;
|
||||
extern bool g_isFakeCommand;
|
||||
extern bool g_sendAudioFinished;
|
||||
extern bool g_isCommencing;
|
||||
extern bool g_leaderChoosen[2];
|
||||
|
|
@ -39,7 +38,6 @@ extern float g_lastRadioTime[2];
|
|||
extern int g_mapType;
|
||||
extern int g_numWaypoints;
|
||||
extern int g_gameFlags;
|
||||
extern int g_fakeArgc;
|
||||
|
||||
extern int g_highestDamageCT;
|
||||
extern int g_highestDamageT;
|
||||
|
|
@ -55,8 +53,6 @@ extern int g_lastRadio[2];
|
|||
extern int g_storeAddbotVars[4];
|
||||
extern int *g_weaponPrefs[];
|
||||
|
||||
extern char g_fakeArgv[256];
|
||||
|
||||
extern Array <Array <String> > g_chatFactory;
|
||||
extern Array <Array <ChatterItem> > g_chatterFactory;
|
||||
extern Array <BotName> g_botNames;
|
||||
|
|
@ -105,7 +101,7 @@ static inline int EntOffsetOfEntity(const edict_t *ent)
|
|||
return (char *) ent - (char *) g_worldEntity;
|
||||
}
|
||||
|
||||
static inline bool IsEntityNull (const edict_t *ent)
|
||||
static inline bool IsNullEntity (const edict_t *ent)
|
||||
{
|
||||
return !ent || !EntOffsetOfEntity (ent);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue