user Cvar_DirectSet for Convar::SetString
This commit is contained in:
parent
0fde82af4e
commit
cbac5da0b7
5 changed files with 18 additions and 18 deletions
|
|
@ -46,12 +46,13 @@ private:
|
|||
{
|
||||
VarType type;
|
||||
cvar_t reg;
|
||||
bool regMissing;
|
||||
class ConVar *self;
|
||||
};
|
||||
Array <VarPair> m_regs;
|
||||
|
||||
public:
|
||||
void RegisterVariable (const char *variable, const char *value, VarType varType, ConVar *self);
|
||||
void RegisterVariable (const char *variable, const char *value, VarType varType, bool regMissing, ConVar *self);
|
||||
void PushRegisteredConVarsToEngine (bool gameVars = false);
|
||||
};
|
||||
|
||||
|
|
@ -205,7 +206,7 @@ public:
|
|||
cvar_t *m_eptr;
|
||||
|
||||
public:
|
||||
ConVar (const char *name, const char *initval, VarType type = VT_NOSERVER);
|
||||
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); }
|
||||
|
|
@ -213,5 +214,5 @@ public:
|
|||
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); }
|
||||
inline void SetString (const char *val) { g_engfuncs.pfnCvar_DirectSet (m_eptr, const_cast <char *> (val)); }
|
||||
};
|
||||
|
|
|
|||
|
|
@ -246,7 +246,7 @@ typedef struct enginefuncs_s
|
|||
void (*pfnDeltaUnsetFieldByIndex) (struct delta_s *pFields, int fieldNumber);
|
||||
void (*pfnSetGroupMask) (int mask, int op);
|
||||
int (*pfnCreateInstancedBaseline) (int classname, struct entity_state_s *baseline);
|
||||
void (*pfnCvar_DirectSet) (struct cvar_s *var, char *value);
|
||||
void (*pfnCvar_DirectSet) (struct cvar_t *var, char *value);
|
||||
void (*pfnForceUnmodified) (FORCE_TYPE type, float *mins, float *maxs, const char *szFilename);
|
||||
void (*pfnGetPlayerStats) (const edict_t *client, int *ping, int *packet_loss);
|
||||
void (*pfnAddServerCommand) (char *cmd_name, void (*function) (void));
|
||||
|
|
|
|||
|
|
@ -2284,7 +2284,7 @@ bool Bot::LastEnemyShootable (void)
|
|||
|
||||
void Bot::CheckRadioCommands (void)
|
||||
{
|
||||
// this function handling radio and reactings to it
|
||||
// this function handling radio and reacting to it
|
||||
|
||||
float distance = (m_radioEntity->v.origin - pev->origin).GetLength ();
|
||||
|
||||
|
|
|
|||
|
|
@ -453,7 +453,7 @@ void Engine::IssueCmd (const char *fmt, ...)
|
|||
g_engfuncs.pfnServerCommand (string);
|
||||
}
|
||||
|
||||
void ConVarWrapper::RegisterVariable (const char *variable, const char *value, VarType varType, ConVar *self)
|
||||
void ConVarWrapper::RegisterVariable(const char *variable, const char *value, VarType varType, bool regMissing, ConVar *self)
|
||||
{
|
||||
// this function adds globally defined variable to registration stack
|
||||
|
||||
|
|
@ -462,6 +462,7 @@ void ConVarWrapper::RegisterVariable (const char *variable, const char *value, V
|
|||
|
||||
pair.reg.name = const_cast <char *> (variable);
|
||||
pair.reg.string = const_cast <char *> (value);
|
||||
pair.regMissing = regMissing;
|
||||
|
||||
int engineFlags = FCVAR_EXTDLL;
|
||||
|
||||
|
|
@ -501,13 +502,17 @@ void ConVarWrapper::PushRegisteredConVarsToEngine (bool gameVars)
|
|||
{
|
||||
ptr->self->m_eptr = g_engfuncs.pfnCVarGetPointer (ptr->reg.name);
|
||||
|
||||
// ensure game cvar exists
|
||||
InternalAssert (ptr->self->m_eptr != NULL);
|
||||
if (ptr->regMissing && ptr->self->m_eptr == NULL)
|
||||
{
|
||||
g_engfuncs.pfnCVarRegister (&ptr->reg);
|
||||
ptr->self->m_eptr = g_engfuncs.pfnCVarGetPointer (ptr->reg.name);
|
||||
}
|
||||
InternalAssert (ptr->self->m_eptr != NULL); // ensure game var exists
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ConVar::ConVar (const char *name, const char *initval, VarType type) : m_eptr (NULL)
|
||||
ConVar::ConVar (const char *name, const char *initval, VarType type, bool regMissing) : m_eptr (NULL)
|
||||
{
|
||||
ConVarWrapper::GetReference ().RegisterVariable (name, initval, type, this);
|
||||
ConVarWrapper::GetReference ().RegisterVariable (name, initval, type, regMissing, this);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,12 +12,7 @@
|
|||
ConVar yb_display_menu_text ("yb_display_menu_text", "1");
|
||||
|
||||
ConVar mp_roundtime ("mp_roundtime", NULL, VT_NOREGISTER);
|
||||
|
||||
#ifndef XASH_CSDM
|
||||
ConVar mp_freezetime ("mp_freezetime", NULL, VT_NOREGISTER);
|
||||
#else
|
||||
ConVar mp_freezetime ("mp_freezetime", "0", VT_NOSERVER);
|
||||
#endif
|
||||
ConVar mp_freezetime ("mp_freezetime", NULL, VT_NOREGISTER, true);
|
||||
|
||||
uint16 FixedUnsigned16 (float value, float scale)
|
||||
{
|
||||
|
|
@ -424,7 +419,6 @@ int GetWeaponPenetrationPower (int id)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
bool IsValidPlayer (edict_t *ent)
|
||||
{
|
||||
if (engine.IsNullEntity (ent))
|
||||
|
|
@ -716,7 +710,7 @@ bool FindNearestPlayer (void **pvHolder, edict_t *to, float searchDistance, bool
|
|||
// team, live status, search distance etc. if needBot is true, then pvHolder, will
|
||||
// be filled with bot pointer, else with edict pointer(!).
|
||||
|
||||
edict_t *survive = NULL; // pointer to temporaly & survive entity
|
||||
edict_t *survive = NULL; // pointer to temporally & survive entity
|
||||
float nearestPlayer = 4096.0f; // nearest player
|
||||
|
||||
int toTeam = engine.GetTeam (to);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue