re-added support for hl-1.1.0.4 & cs beta 6.6 minimum.
This commit is contained in:
parent
af82dbf1bb
commit
37a352ac54
7 changed files with 55 additions and 28 deletions
|
|
@ -66,6 +66,18 @@ static inline char *A_strdup (const char *str)
|
||||||
return strcpy (new char[strlen (str) + 1], str);
|
return strcpy (new char[strlen (str) + 1], str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// From metamod-p
|
||||||
|
static inline bool A_IsValidCodePointer (const void *ptr)
|
||||||
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
if (IsBadCodePtr (reinterpret_cast <FARPROC> (ptr)))
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// do not check on linux
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Title: Utility Classes Header
|
// Title: Utility Classes Header
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -68,8 +68,10 @@ struct VarPair
|
||||||
{
|
{
|
||||||
VarType type;
|
VarType type;
|
||||||
cvar_t reg;
|
cvar_t reg;
|
||||||
bool regMissing;
|
|
||||||
class ConVar *self;
|
class ConVar *self;
|
||||||
|
|
||||||
|
bool regMissing;
|
||||||
|
const char *regVal;
|
||||||
};
|
};
|
||||||
|
|
||||||
// translation pair
|
// translation pair
|
||||||
|
|
@ -167,7 +169,7 @@ public:
|
||||||
void IssueBotCommand (edict_t *ent, const char *fmt, ...);
|
void IssueBotCommand (edict_t *ent, const char *fmt, ...);
|
||||||
|
|
||||||
// adds cvar to registration stack
|
// adds cvar to registration stack
|
||||||
void PushVariableToStack (const char *variable, const char *value, VarType varType, bool regMissing, ConVar *self);
|
void PushVariableToStack (const char *variable, const char *value, VarType varType, bool regMissing, const char *regVal, ConVar *self);
|
||||||
|
|
||||||
// sends local registration stack for engine registration
|
// sends local registration stack for engine registration
|
||||||
void PushRegisteredConVarsToEngine (bool gameVars = false);
|
void PushRegisteredConVarsToEngine (bool gameVars = false);
|
||||||
|
|
@ -312,7 +314,7 @@ public:
|
||||||
cvar_t *m_eptr;
|
cvar_t *m_eptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ConVar (const char *name, const char *initval, VarType type = VT_NOSERVER, bool regMissing = false);
|
ConVar (const char *name, const char *initval, VarType type = VT_NOSERVER, bool regMissing = false, const char *regVal = nullptr);
|
||||||
|
|
||||||
FORCEINLINE bool GetBool (void) { return m_eptr->value > 0.0f; }
|
FORCEINLINE bool GetBool (void) { return m_eptr->value > 0.0f; }
|
||||||
FORCEINLINE int GetInt (void) { return static_cast <int> (m_eptr->value); }
|
FORCEINLINE int GetInt (void) { return static_cast <int> (m_eptr->value); }
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ ConVar yb_best_weapon_picker_type ("yb_best_weapon_picker_type", "2");
|
||||||
|
|
||||||
// game console variables
|
// game console variables
|
||||||
ConVar mp_c4timer ("mp_c4timer", nullptr, VT_NOREGISTER);
|
ConVar mp_c4timer ("mp_c4timer", nullptr, VT_NOREGISTER);
|
||||||
ConVar mp_buytime ("mp_buytime", nullptr, VT_NOREGISTER);
|
ConVar mp_buytime ("mp_buytime", nullptr, VT_NOREGISTER, true, "1");
|
||||||
ConVar mp_footsteps ("mp_footsteps", nullptr, VT_NOREGISTER);
|
ConVar mp_footsteps ("mp_footsteps", nullptr, VT_NOREGISTER);
|
||||||
ConVar sv_gravity ("sv_gravity", nullptr, VT_NOREGISTER);
|
ConVar sv_gravity ("sv_gravity", nullptr, VT_NOREGISTER);
|
||||||
|
|
||||||
|
|
@ -5995,13 +5995,8 @@ void Bot::EquipInBuyzone (int buyState)
|
||||||
{
|
{
|
||||||
// this function is gets called when bot enters a buyzone, to allow bot to buy some stuff
|
// this function is gets called when bot enters a buyzone, to allow bot to buy some stuff
|
||||||
|
|
||||||
bool checkBuyTime = false;
|
|
||||||
|
|
||||||
if (mp_buytime.m_eptr != nullptr)
|
|
||||||
checkBuyTime = (g_timeRoundStart + Random.Float (10.0f, 20.0f) + mp_buytime.GetFloat () < engine.Time ());
|
|
||||||
|
|
||||||
// if bot is in buy zone, try to buy ammo for this weapon...
|
// if bot is in buy zone, try to buy ammo for this weapon...
|
||||||
if (m_seeEnemyTime + 5.0f < engine.Time () && m_lastEquipTime + 15.0f < engine.Time () && m_inBuyZone && checkBuyTime && !g_bombPlanted && m_moneyAmount > g_botBuyEconomyTable[0])
|
if (m_seeEnemyTime + 5.0f < engine.Time () && m_lastEquipTime + 15.0f < engine.Time () && m_inBuyZone && (g_timeRoundStart + Random.Float (10.0f, 20.0f) + mp_buytime.GetFloat () < engine.Time ()) && !g_bombPlanted && m_moneyAmount > g_botBuyEconomyTable[0])
|
||||||
{
|
{
|
||||||
m_buyingFinished = false;
|
m_buyingFinished = false;
|
||||||
m_buyState = buyState;
|
m_buyState = buyState;
|
||||||
|
|
|
||||||
|
|
@ -321,6 +321,10 @@ void Engine::RegisterCmd (const char * command, void func (void))
|
||||||
// that for every "command_name" server command it receives, it should call the function
|
// that for every "command_name" server command it receives, it should call the function
|
||||||
// pointed to by "function" in order to handle it.
|
// pointed to by "function" in order to handle it.
|
||||||
|
|
||||||
|
// check for hl pre 1.1.0.4, as it's doesn't have pfnAddServerCommand
|
||||||
|
if (!A_IsValidCodePointer (g_engfuncs.pfnAddServerCommand))
|
||||||
|
AddLogEntry (true, LL_FATAL, "YaPB's minimum HL engine version is 1.1.0.4 and minimum Counter-Strike Beta 6.6. Please update your engine version.");
|
||||||
|
|
||||||
g_engfuncs.pfnAddServerCommand (const_cast <char *> (command), func);
|
g_engfuncs.pfnAddServerCommand (const_cast <char *> (command), func);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -479,7 +483,7 @@ void Engine::IssueCmd (const char *fmt, ...)
|
||||||
g_engfuncs.pfnServerCommand (string);
|
g_engfuncs.pfnServerCommand (string);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::PushVariableToStack (const char *variable, const char *value, VarType varType, bool regMissing, ConVar *self)
|
void Engine::PushVariableToStack (const char *variable, const char *value, VarType varType, bool regMissing, const char *regVal, ConVar *self)
|
||||||
{
|
{
|
||||||
// this function adds globally defined variable to registration stack
|
// this function adds globally defined variable to registration stack
|
||||||
|
|
||||||
|
|
@ -489,6 +493,7 @@ void Engine::PushVariableToStack (const char *variable, const char *value, VarTy
|
||||||
pair.reg.name = const_cast <char *> (variable);
|
pair.reg.name = const_cast <char *> (variable);
|
||||||
pair.reg.string = const_cast <char *> (value);
|
pair.reg.string = const_cast <char *> (value);
|
||||||
pair.regMissing = regMissing;
|
pair.regMissing = regMissing;
|
||||||
|
pair.regVal = regVal;
|
||||||
|
|
||||||
int engineFlags = FCVAR_EXTDLL;
|
int engineFlags = FCVAR_EXTDLL;
|
||||||
|
|
||||||
|
|
@ -530,10 +535,17 @@ void Engine::PushRegisteredConVarsToEngine (bool gameVars)
|
||||||
|
|
||||||
if (ptr->regMissing && ptr->self->m_eptr == nullptr)
|
if (ptr->regMissing && ptr->self->m_eptr == nullptr)
|
||||||
{
|
{
|
||||||
|
if (ptr->reg.string == nullptr && ptr->regVal != nullptr)
|
||||||
|
{
|
||||||
|
ptr->reg.string = const_cast <char *> (ptr->regVal);
|
||||||
|
ptr->reg.flags |= FCVAR_SERVER;
|
||||||
|
}
|
||||||
g_engfuncs.pfnCVarRegister (&ptr->reg);
|
g_engfuncs.pfnCVarRegister (&ptr->reg);
|
||||||
ptr->self->m_eptr = g_engfuncs.pfnCVarGetPointer (ptr->reg.name);
|
ptr->self->m_eptr = g_engfuncs.pfnCVarGetPointer (ptr->reg.name);
|
||||||
}
|
}
|
||||||
InternalAssert (ptr->self->m_eptr != nullptr); // ensure game var exists
|
|
||||||
|
if (!ptr->self->m_eptr)
|
||||||
|
engine.Printf ("Got nullptr on cvar %s!", ptr->reg.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1056,7 +1068,7 @@ void Engine::ProcessMessageCapture (void *ptr)
|
||||||
m_msgBlock.state++; // and finally update network message state
|
m_msgBlock.state++; // and finally update network message state
|
||||||
}
|
}
|
||||||
|
|
||||||
ConVar::ConVar (const char *name, const char *initval, VarType type, bool regMissing) : m_eptr (nullptr)
|
ConVar::ConVar (const char *name, const char *initval, VarType type, bool regMissing, const char *regVal) : m_eptr (nullptr)
|
||||||
{
|
{
|
||||||
engine.PushVariableToStack (name, initval, type, regMissing, this);
|
engine.PushVariableToStack (name, initval, type, regMissing, regVal, this);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ ConVar yb_password_key ("yb_password_key", "_ybpw");
|
||||||
ConVar yb_language ("yb_language", "en");
|
ConVar yb_language ("yb_language", "en");
|
||||||
ConVar yb_version ("yb_version", PRODUCT_VERSION, VT_READONLY);
|
ConVar yb_version ("yb_version", PRODUCT_VERSION, VT_READONLY);
|
||||||
|
|
||||||
ConVar mp_startmoney ("mp_startmoney", nullptr, VT_NOREGISTER);
|
ConVar mp_startmoney ("mp_startmoney", nullptr, VT_NOREGISTER, true, "800");
|
||||||
|
|
||||||
int BotCommandHandler (edict_t *ent, const char *arg0, const char *arg1, const char *arg2, const char *arg3, const char *arg4, const char *arg5, const char *self)
|
int BotCommandHandler (edict_t *ent, const char *arg0, const char *arg1, const char *arg2, const char *arg3, const char *arg4, const char *arg5, const char *self)
|
||||||
{
|
{
|
||||||
|
|
@ -2370,8 +2370,10 @@ void pfnClientCommand (edict_t *ent, char const *format, ...)
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
|
|
||||||
// is the target entity an official bot, or a third party bot ?
|
// is the target entity an official bot, or a third party bot ?
|
||||||
if (ent->v.flags & FL_FAKECLIENT)
|
if (IsValidBot (ent))
|
||||||
{
|
{
|
||||||
|
engine.IssueBotCommand (ent, buffer);
|
||||||
|
|
||||||
if (g_gameFlags & GAME_METAMOD)
|
if (g_gameFlags & GAME_METAMOD)
|
||||||
RETURN_META (MRES_SUPERCEDE); // prevent bots to be forced to issue client commands
|
RETURN_META (MRES_SUPERCEDE); // prevent bots to be forced to issue client commands
|
||||||
|
|
||||||
|
|
@ -2463,7 +2465,7 @@ void pfnMessageBegin (int msgDest, int msgType, const float *origin, edict_t *ed
|
||||||
if (g_gameFlags & GAME_METAMOD)
|
if (g_gameFlags & GAME_METAMOD)
|
||||||
RETURN_META (MRES_IGNORED);
|
RETURN_META (MRES_IGNORED);
|
||||||
|
|
||||||
MESSAGE_BEGIN (msgDest, msgType, origin, ed);
|
g_engfuncs.pfnMessageBegin (msgDest, msgType, origin, ed);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pfnMessageEnd (void)
|
void pfnMessageEnd (void)
|
||||||
|
|
@ -2473,7 +2475,7 @@ void pfnMessageEnd (void)
|
||||||
if (g_gameFlags & GAME_METAMOD)
|
if (g_gameFlags & GAME_METAMOD)
|
||||||
RETURN_META (MRES_IGNORED);
|
RETURN_META (MRES_IGNORED);
|
||||||
|
|
||||||
MESSAGE_END ();
|
g_engfuncs.pfnMessageEnd ();
|
||||||
|
|
||||||
// send latency fix
|
// send latency fix
|
||||||
bots.SendDeathMsgFix ();
|
bots.SendDeathMsgFix ();
|
||||||
|
|
@ -2495,7 +2497,7 @@ void pfnWriteByte (int value)
|
||||||
if (g_gameFlags & GAME_METAMOD)
|
if (g_gameFlags & GAME_METAMOD)
|
||||||
RETURN_META (MRES_IGNORED);
|
RETURN_META (MRES_IGNORED);
|
||||||
|
|
||||||
WRITE_BYTE (value);
|
g_engfuncs.pfnWriteByte (value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pfnWriteChar (int value)
|
void pfnWriteChar (int value)
|
||||||
|
|
@ -2506,7 +2508,7 @@ void pfnWriteChar (int value)
|
||||||
if (g_gameFlags & GAME_METAMOD)
|
if (g_gameFlags & GAME_METAMOD)
|
||||||
RETURN_META (MRES_IGNORED);
|
RETURN_META (MRES_IGNORED);
|
||||||
|
|
||||||
WRITE_CHAR (value);
|
g_engfuncs.pfnWriteChar (value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pfnWriteShort (int value)
|
void pfnWriteShort (int value)
|
||||||
|
|
@ -2517,7 +2519,7 @@ void pfnWriteShort (int value)
|
||||||
if (g_gameFlags & GAME_METAMOD)
|
if (g_gameFlags & GAME_METAMOD)
|
||||||
RETURN_META (MRES_IGNORED);
|
RETURN_META (MRES_IGNORED);
|
||||||
|
|
||||||
WRITE_SHORT (value);
|
g_engfuncs.pfnWriteShort (value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pfnWriteLong (int value)
|
void pfnWriteLong (int value)
|
||||||
|
|
@ -2528,7 +2530,7 @@ void pfnWriteLong (int value)
|
||||||
if (g_gameFlags & GAME_METAMOD)
|
if (g_gameFlags & GAME_METAMOD)
|
||||||
RETURN_META (MRES_IGNORED);
|
RETURN_META (MRES_IGNORED);
|
||||||
|
|
||||||
WRITE_LONG (value);
|
g_engfuncs.pfnWriteLong (value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pfnWriteAngle (float value)
|
void pfnWriteAngle (float value)
|
||||||
|
|
@ -2539,7 +2541,7 @@ void pfnWriteAngle (float value)
|
||||||
if (g_gameFlags & GAME_METAMOD)
|
if (g_gameFlags & GAME_METAMOD)
|
||||||
RETURN_META (MRES_IGNORED);
|
RETURN_META (MRES_IGNORED);
|
||||||
|
|
||||||
WRITE_ANGLE (value);
|
g_engfuncs.pfnWriteAngle (value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pfnWriteCoord (float value)
|
void pfnWriteCoord (float value)
|
||||||
|
|
@ -2550,7 +2552,7 @@ void pfnWriteCoord (float value)
|
||||||
if (g_gameFlags & GAME_METAMOD)
|
if (g_gameFlags & GAME_METAMOD)
|
||||||
RETURN_META (MRES_IGNORED);
|
RETURN_META (MRES_IGNORED);
|
||||||
|
|
||||||
WRITE_COORD (value);
|
g_engfuncs.pfnWriteCoord (value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pfnWriteString (const char *sz)
|
void pfnWriteString (const char *sz)
|
||||||
|
|
@ -2561,7 +2563,7 @@ void pfnWriteString (const char *sz)
|
||||||
if (g_gameFlags & GAME_METAMOD)
|
if (g_gameFlags & GAME_METAMOD)
|
||||||
RETURN_META (MRES_IGNORED);
|
RETURN_META (MRES_IGNORED);
|
||||||
|
|
||||||
WRITE_STRING (sz);
|
g_engfuncs.pfnWriteString (sz);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pfnWriteEntity (int value)
|
void pfnWriteEntity (int value)
|
||||||
|
|
@ -2572,7 +2574,7 @@ void pfnWriteEntity (int value)
|
||||||
if (g_gameFlags & GAME_METAMOD)
|
if (g_gameFlags & GAME_METAMOD)
|
||||||
RETURN_META (MRES_IGNORED);
|
RETURN_META (MRES_IGNORED);
|
||||||
|
|
||||||
WRITE_ENTITY (value);
|
g_engfuncs.pfnWriteEntity (value);
|
||||||
}
|
}
|
||||||
|
|
||||||
int pfnCmd_Argc (void)
|
int pfnCmd_Argc (void)
|
||||||
|
|
|
||||||
|
|
@ -1283,6 +1283,10 @@ void Bot::StartGame (void)
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// cs prior beta 7.0 uses hud-based motd, so press fire once
|
||||||
|
if (g_gameFlags & GAME_LEGACY)
|
||||||
|
pev->button |= IN_ATTACK;
|
||||||
|
|
||||||
// handle counter-strike stuff here...
|
// handle counter-strike stuff here...
|
||||||
if (m_startAction == GSM_TEAM_SELECT)
|
if (m_startAction == GSM_TEAM_SELECT)
|
||||||
{
|
{
|
||||||
|
|
@ -1321,7 +1325,7 @@ void Bot::StartGame (void)
|
||||||
|
|
||||||
// bot has now joined the game (doesn't need to be started)
|
// bot has now joined the game (doesn't need to be started)
|
||||||
m_notStarted = false;
|
m_notStarted = false;
|
||||||
|
|
||||||
// check for greeting other players, since we connected
|
// check for greeting other players, since we connected
|
||||||
if (Random.Int (0, 100) < 20)
|
if (Random.Int (0, 100) < 20)
|
||||||
ChatMessage (CHAT_WELCOME);
|
ChatMessage (CHAT_WELCOME);
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
ConVar yb_display_menu_text ("yb_display_menu_text", "1");
|
ConVar yb_display_menu_text ("yb_display_menu_text", "1");
|
||||||
|
|
||||||
ConVar mp_roundtime ("mp_roundtime", nullptr, VT_NOREGISTER);
|
ConVar mp_roundtime ("mp_roundtime", nullptr, VT_NOREGISTER);
|
||||||
ConVar mp_freezetime ("mp_freezetime", nullptr, VT_NOREGISTER, true);
|
ConVar mp_freezetime ("mp_freezetime", nullptr, VT_NOREGISTER, true, "0");
|
||||||
|
|
||||||
uint16 FixedUnsigned16 (float value, float scale)
|
uint16 FixedUnsigned16 (float value, float scale)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue