Makes sending the change the default behavior with the GameRules_Set* natives.
This commit is contained in:
@@ -229,14 +229,10 @@ static cell_t GameRules_SetProp(IPluginContext *pContext, const cell_t *params)
|
||||
int offset;
|
||||
int bit_count;
|
||||
|
||||
bool sendChange = true;
|
||||
if (params[5] == 0)
|
||||
sendChange = false;
|
||||
|
||||
void *pGameRules = GameRules();
|
||||
|
||||
CBaseEntity *pProxy = NULL;
|
||||
if (sendChange && ((pProxy = GetGameRulesProxyEnt()) == NULL))
|
||||
if ((pProxy = GetGameRulesProxyEnt()) == NULL)
|
||||
return pContext->ThrowNativeError("Couldn't find gamerules proxy entity");
|
||||
|
||||
if (!pGameRules || !g_szGameRulesProxy || !strcmp(g_szGameRulesProxy, ""))
|
||||
@@ -262,36 +258,24 @@ static cell_t GameRules_SetProp(IPluginContext *pContext, const cell_t *params)
|
||||
if (bit_count >= 17)
|
||||
{
|
||||
*(int32_t *)((intptr_t)pGameRules + offset) = params[2];
|
||||
if (sendChange)
|
||||
{
|
||||
gamehelpers->SetEdictStateChanged(gamehelpers->EdictOfIndex(gamehelpers->EntityToBCompatRef(pProxy)), offset);
|
||||
}
|
||||
}
|
||||
else if (bit_count >= 9)
|
||||
{
|
||||
*(int16_t *)((intptr_t)pGameRules + offset) = (int16_t)params[2];
|
||||
if (sendChange)
|
||||
{
|
||||
gamehelpers->SetEdictStateChanged(gamehelpers->EdictOfIndex(gamehelpers->EntityToBCompatRef(pProxy)), offset);
|
||||
}
|
||||
}
|
||||
else if (bit_count >= 2)
|
||||
{
|
||||
*(int8_t *)((intptr_t)pGameRules + offset) = (int8_t)params[2];
|
||||
if (sendChange)
|
||||
{
|
||||
gamehelpers->SetEdictStateChanged(gamehelpers->EdictOfIndex(gamehelpers->EntityToBCompatRef(pProxy)), offset);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*(bool *)((intptr_t)pGameRules + offset) = (params[2] == 0) ? false : true;
|
||||
if (sendChange)
|
||||
{
|
||||
gamehelpers->SetEdictStateChanged(gamehelpers->EdictOfIndex(gamehelpers->EntityToBCompatRef(pProxy)), offset);
|
||||
}
|
||||
}
|
||||
|
||||
edict_t *proxyEdict = gamehelpers->EdictOfIndex(gamehelpers->EntityToBCompatRef(pProxy));
|
||||
if (proxyEdict != NULL)
|
||||
gamehelpers->SetEdictStateChanged(proxyEdict, offset);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -323,14 +307,10 @@ static cell_t GameRules_SetPropFloat(IPluginContext *pContext, const cell_t *par
|
||||
int offset;
|
||||
int bit_count;
|
||||
|
||||
bool sendChange = true;
|
||||
if (params[4] == 0)
|
||||
sendChange = false;
|
||||
|
||||
void *pGameRules = GameRules();
|
||||
|
||||
CBaseEntity *pProxy = NULL;
|
||||
if (sendChange && ((pProxy = GetGameRulesProxyEnt()) == NULL))
|
||||
if ((pProxy = GetGameRulesProxyEnt()) == NULL)
|
||||
return pContext->ThrowNativeError("Couldn't find gamerules proxy entity.");
|
||||
|
||||
if (!pGameRules || !g_szGameRulesProxy || !strcmp(g_szGameRulesProxy, ""))
|
||||
@@ -344,10 +324,9 @@ static cell_t GameRules_SetPropFloat(IPluginContext *pContext, const cell_t *par
|
||||
|
||||
*(float *)((intptr_t)pGameRules + offset) = newVal;
|
||||
|
||||
if (sendChange)
|
||||
{
|
||||
gamehelpers->SetEdictStateChanged(gamehelpers->EdictOfIndex(gamehelpers->EntityToBCompatRef(pProxy)), offset);
|
||||
}
|
||||
edict_t *proxyEdict = gamehelpers->EdictOfIndex(gamehelpers->EntityToBCompatRef(pProxy));
|
||||
if (proxyEdict != NULL)
|
||||
gamehelpers->SetEdictStateChanged(proxyEdict, offset);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -386,14 +365,10 @@ static cell_t GameRules_SetPropEnt(IPluginContext *pContext, const cell_t *param
|
||||
int offset;
|
||||
int bit_count;
|
||||
|
||||
bool sendChange = true;
|
||||
if (params[4] == 0)
|
||||
sendChange = false;
|
||||
|
||||
void *pGameRules = GameRules();
|
||||
|
||||
CBaseEntity *pProxy = NULL;
|
||||
if (sendChange && ((pProxy = GetGameRulesProxyEnt()) == NULL))
|
||||
if ((pProxy = GetGameRulesProxyEnt()) == NULL)
|
||||
return pContext->ThrowNativeError("Couldn't find gamerules proxy entity.");
|
||||
|
||||
if (!pGameRules || !g_szGameRulesProxy || !strcmp(g_szGameRulesProxy, ""))
|
||||
@@ -423,10 +398,9 @@ static cell_t GameRules_SetPropEnt(IPluginContext *pContext, const cell_t *param
|
||||
hndl.Set(pHandleEnt);
|
||||
}
|
||||
|
||||
if (sendChange)
|
||||
{
|
||||
gamehelpers->SetEdictStateChanged(gamehelpers->EdictOfIndex(gamehelpers->EntityToBCompatRef(pProxy)), offset);
|
||||
}
|
||||
edict_t *proxyEdict = gamehelpers->EdictOfIndex(gamehelpers->EntityToBCompatRef(pProxy));
|
||||
if (proxyEdict != NULL)
|
||||
gamehelpers->SetEdictStateChanged(proxyEdict, offset);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -466,14 +440,10 @@ static cell_t GameRules_SetPropVector(IPluginContext *pContext, const cell_t *pa
|
||||
int offset;
|
||||
int bit_count;
|
||||
|
||||
bool sendChange = true;
|
||||
if (params[4] == 0)
|
||||
sendChange = false;
|
||||
|
||||
void *pGameRules = GameRules();
|
||||
|
||||
CBaseEntity *pProxy = NULL;
|
||||
if (sendChange && ((pProxy = GetGameRulesProxyEnt()) == NULL))
|
||||
if ((pProxy = GetGameRulesProxyEnt()) == NULL)
|
||||
return pContext->ThrowNativeError("Couldn't find gamerules proxy entity.");
|
||||
|
||||
if (!pGameRules || !g_szGameRulesProxy || !strcmp(g_szGameRulesProxy, ""))
|
||||
@@ -492,10 +462,9 @@ static cell_t GameRules_SetPropVector(IPluginContext *pContext, const cell_t *pa
|
||||
v->y = sp_ctof(vec[1]);
|
||||
v->z = sp_ctof(vec[2]);
|
||||
|
||||
if (sendChange)
|
||||
{
|
||||
gamehelpers->SetEdictStateChanged(gamehelpers->EdictOfIndex(gamehelpers->EntityToBCompatRef(pProxy)), offset);
|
||||
}
|
||||
edict_t *proxyEdict = gamehelpers->EdictOfIndex(gamehelpers->EntityToBCompatRef(pProxy));
|
||||
if (proxyEdict != NULL)
|
||||
gamehelpers->SetEdictStateChanged(proxyEdict, offset);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -563,14 +532,10 @@ static cell_t GameRules_SetPropString(IPluginContext *pContext, const cell_t *pa
|
||||
int offset;
|
||||
int maxlen;
|
||||
|
||||
bool sendChange = true;
|
||||
if (params[3] == 0)
|
||||
sendChange = false;
|
||||
|
||||
void *pGameRules = GameRules();
|
||||
|
||||
CBaseEntity *pProxy = NULL;
|
||||
if (sendChange && ((pProxy = GetGameRulesProxyEnt()) == NULL))
|
||||
if ((pProxy = GetGameRulesProxyEnt()) == NULL)
|
||||
return pContext->ThrowNativeError("Couldn't find gamerules proxy entity.");
|
||||
|
||||
if (!pGameRules || !g_szGameRulesProxy || !strcmp(g_szGameRulesProxy, ""))
|
||||
@@ -602,10 +567,9 @@ static cell_t GameRules_SetPropString(IPluginContext *pContext, const cell_t *pa
|
||||
pContext->LocalToString(params[2], &src);
|
||||
size_t len = strncopy(dest, src, maxlen);
|
||||
|
||||
if (sendChange)
|
||||
{
|
||||
gamehelpers->SetEdictStateChanged(gamehelpers->EdictOfIndex(gamehelpers->EntityToBCompatRef(pProxy)), offset);
|
||||
}
|
||||
edict_t *proxyEdict = gamehelpers->EdictOfIndex(gamehelpers->EntityToBCompatRef(pProxy));
|
||||
if (proxyEdict != NULL)
|
||||
gamehelpers->SetEdictStateChanged(proxyEdict, offset);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user