Merge pull request #494 from akowald/gamerules-edictstate
Always send changes when using the GameRules_SetProp* natives.
This commit is contained in:
commit
c536a43914
@ -229,14 +229,10 @@ static cell_t GameRules_SetProp(IPluginContext *pContext, const cell_t *params)
|
|||||||
int offset;
|
int offset;
|
||||||
int bit_count;
|
int bit_count;
|
||||||
|
|
||||||
bool sendChange = true;
|
|
||||||
if (params[5] == 0)
|
|
||||||
sendChange = false;
|
|
||||||
|
|
||||||
void *pGameRules = GameRules();
|
void *pGameRules = GameRules();
|
||||||
|
|
||||||
CBaseEntity *pProxy = NULL;
|
CBaseEntity *pProxy = NULL;
|
||||||
if (sendChange && ((pProxy = GetGameRulesProxyEnt()) == NULL))
|
if ((pProxy = GetGameRulesProxyEnt()) == NULL)
|
||||||
return pContext->ThrowNativeError("Couldn't find gamerules proxy entity");
|
return pContext->ThrowNativeError("Couldn't find gamerules proxy entity");
|
||||||
|
|
||||||
if (!pGameRules || !g_szGameRulesProxy || !strcmp(g_szGameRulesProxy, ""))
|
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)
|
if (bit_count >= 17)
|
||||||
{
|
{
|
||||||
*(int32_t *)((intptr_t)pGameRules + offset) = params[2];
|
*(int32_t *)((intptr_t)pGameRules + offset) = params[2];
|
||||||
if (sendChange)
|
|
||||||
{
|
|
||||||
gamehelpers->SetEdictStateChanged(gamehelpers->EdictOfIndex(gamehelpers->EntityToBCompatRef(pProxy)), offset);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (bit_count >= 9)
|
else if (bit_count >= 9)
|
||||||
{
|
{
|
||||||
*(int16_t *)((intptr_t)pGameRules + offset) = (int16_t)params[2];
|
*(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)
|
else if (bit_count >= 2)
|
||||||
{
|
{
|
||||||
*(int8_t *)((intptr_t)pGameRules + offset) = (int8_t)params[2];
|
*(int8_t *)((intptr_t)pGameRules + offset) = (int8_t)params[2];
|
||||||
if (sendChange)
|
|
||||||
{
|
|
||||||
gamehelpers->SetEdictStateChanged(gamehelpers->EdictOfIndex(gamehelpers->EntityToBCompatRef(pProxy)), offset);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*(bool *)((intptr_t)pGameRules + offset) = (params[2] == 0) ? false : true;
|
*(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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,14 +307,10 @@ static cell_t GameRules_SetPropFloat(IPluginContext *pContext, const cell_t *par
|
|||||||
int offset;
|
int offset;
|
||||||
int bit_count;
|
int bit_count;
|
||||||
|
|
||||||
bool sendChange = true;
|
|
||||||
if (params[4] == 0)
|
|
||||||
sendChange = false;
|
|
||||||
|
|
||||||
void *pGameRules = GameRules();
|
void *pGameRules = GameRules();
|
||||||
|
|
||||||
CBaseEntity *pProxy = NULL;
|
CBaseEntity *pProxy = NULL;
|
||||||
if (sendChange && ((pProxy = GetGameRulesProxyEnt()) == NULL))
|
if ((pProxy = GetGameRulesProxyEnt()) == NULL)
|
||||||
return pContext->ThrowNativeError("Couldn't find gamerules proxy entity.");
|
return pContext->ThrowNativeError("Couldn't find gamerules proxy entity.");
|
||||||
|
|
||||||
if (!pGameRules || !g_szGameRulesProxy || !strcmp(g_szGameRulesProxy, ""))
|
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;
|
*(float *)((intptr_t)pGameRules + offset) = newVal;
|
||||||
|
|
||||||
if (sendChange)
|
edict_t *proxyEdict = gamehelpers->EdictOfIndex(gamehelpers->EntityToBCompatRef(pProxy));
|
||||||
{
|
if (proxyEdict != NULL)
|
||||||
gamehelpers->SetEdictStateChanged(gamehelpers->EdictOfIndex(gamehelpers->EntityToBCompatRef(pProxy)), offset);
|
gamehelpers->SetEdictStateChanged(proxyEdict, offset);
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -386,14 +365,10 @@ static cell_t GameRules_SetPropEnt(IPluginContext *pContext, const cell_t *param
|
|||||||
int offset;
|
int offset;
|
||||||
int bit_count;
|
int bit_count;
|
||||||
|
|
||||||
bool sendChange = true;
|
|
||||||
if (params[4] == 0)
|
|
||||||
sendChange = false;
|
|
||||||
|
|
||||||
void *pGameRules = GameRules();
|
void *pGameRules = GameRules();
|
||||||
|
|
||||||
CBaseEntity *pProxy = NULL;
|
CBaseEntity *pProxy = NULL;
|
||||||
if (sendChange && ((pProxy = GetGameRulesProxyEnt()) == NULL))
|
if ((pProxy = GetGameRulesProxyEnt()) == NULL)
|
||||||
return pContext->ThrowNativeError("Couldn't find gamerules proxy entity.");
|
return pContext->ThrowNativeError("Couldn't find gamerules proxy entity.");
|
||||||
|
|
||||||
if (!pGameRules || !g_szGameRulesProxy || !strcmp(g_szGameRulesProxy, ""))
|
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);
|
hndl.Set(pHandleEnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sendChange)
|
edict_t *proxyEdict = gamehelpers->EdictOfIndex(gamehelpers->EntityToBCompatRef(pProxy));
|
||||||
{
|
if (proxyEdict != NULL)
|
||||||
gamehelpers->SetEdictStateChanged(gamehelpers->EdictOfIndex(gamehelpers->EntityToBCompatRef(pProxy)), offset);
|
gamehelpers->SetEdictStateChanged(proxyEdict, offset);
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -466,14 +440,10 @@ static cell_t GameRules_SetPropVector(IPluginContext *pContext, const cell_t *pa
|
|||||||
int offset;
|
int offset;
|
||||||
int bit_count;
|
int bit_count;
|
||||||
|
|
||||||
bool sendChange = true;
|
|
||||||
if (params[4] == 0)
|
|
||||||
sendChange = false;
|
|
||||||
|
|
||||||
void *pGameRules = GameRules();
|
void *pGameRules = GameRules();
|
||||||
|
|
||||||
CBaseEntity *pProxy = NULL;
|
CBaseEntity *pProxy = NULL;
|
||||||
if (sendChange && ((pProxy = GetGameRulesProxyEnt()) == NULL))
|
if ((pProxy = GetGameRulesProxyEnt()) == NULL)
|
||||||
return pContext->ThrowNativeError("Couldn't find gamerules proxy entity.");
|
return pContext->ThrowNativeError("Couldn't find gamerules proxy entity.");
|
||||||
|
|
||||||
if (!pGameRules || !g_szGameRulesProxy || !strcmp(g_szGameRulesProxy, ""))
|
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->y = sp_ctof(vec[1]);
|
||||||
v->z = sp_ctof(vec[2]);
|
v->z = sp_ctof(vec[2]);
|
||||||
|
|
||||||
if (sendChange)
|
edict_t *proxyEdict = gamehelpers->EdictOfIndex(gamehelpers->EntityToBCompatRef(pProxy));
|
||||||
{
|
if (proxyEdict != NULL)
|
||||||
gamehelpers->SetEdictStateChanged(gamehelpers->EdictOfIndex(gamehelpers->EntityToBCompatRef(pProxy)), offset);
|
gamehelpers->SetEdictStateChanged(proxyEdict, offset);
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -563,14 +532,10 @@ static cell_t GameRules_SetPropString(IPluginContext *pContext, const cell_t *pa
|
|||||||
int offset;
|
int offset;
|
||||||
int maxlen;
|
int maxlen;
|
||||||
|
|
||||||
bool sendChange = true;
|
|
||||||
if (params[3] == 0)
|
|
||||||
sendChange = false;
|
|
||||||
|
|
||||||
void *pGameRules = GameRules();
|
void *pGameRules = GameRules();
|
||||||
|
|
||||||
CBaseEntity *pProxy = NULL;
|
CBaseEntity *pProxy = NULL;
|
||||||
if (sendChange && ((pProxy = GetGameRulesProxyEnt()) == NULL))
|
if ((pProxy = GetGameRulesProxyEnt()) == NULL)
|
||||||
return pContext->ThrowNativeError("Couldn't find gamerules proxy entity.");
|
return pContext->ThrowNativeError("Couldn't find gamerules proxy entity.");
|
||||||
|
|
||||||
if (!pGameRules || !g_szGameRulesProxy || !strcmp(g_szGameRulesProxy, ""))
|
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);
|
pContext->LocalToString(params[2], &src);
|
||||||
size_t len = strncopy(dest, src, maxlen);
|
size_t len = strncopy(dest, src, maxlen);
|
||||||
|
|
||||||
if (sendChange)
|
edict_t *proxyEdict = gamehelpers->EdictOfIndex(gamehelpers->EntityToBCompatRef(pProxy));
|
||||||
{
|
if (proxyEdict != NULL)
|
||||||
gamehelpers->SetEdictStateChanged(gamehelpers->EdictOfIndex(gamehelpers->EntityToBCompatRef(pProxy)), offset);
|
gamehelpers->SetEdictStateChanged(proxyEdict, offset);
|
||||||
}
|
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ native GameRules_GetProp(const String:prop[], size=4, element=0);
|
|||||||
* This value is auto-detected, and the size parameter is
|
* This value is auto-detected, and the size parameter is
|
||||||
* only used as a fallback in case detection fails.
|
* only used as a fallback in case detection fails.
|
||||||
* @param element Element # (starting from 0) if property is an array.
|
* @param element Element # (starting from 0) if property is an array.
|
||||||
* @param changeState If true, change will be sent over the network.
|
* @param changeState This parameter is ignored.
|
||||||
* @error Not supported.
|
* @error Not supported.
|
||||||
* @noreturn
|
* @noreturn
|
||||||
*/
|
*/
|
||||||
@ -115,7 +115,7 @@ native Float:GameRules_GetPropFloat(const String:prop[], element=0);
|
|||||||
* @param prop Property name.
|
* @param prop Property name.
|
||||||
* @param value Value to set.
|
* @param value Value to set.
|
||||||
* @param element Element # (starting from 0) if property is an array.
|
* @param element Element # (starting from 0) if property is an array.
|
||||||
* @param changeState If true, change will be sent over the network.
|
* @param changeState This parameter is ignored.
|
||||||
* @noreturn
|
* @noreturn
|
||||||
* @error Not supported.
|
* @error Not supported.
|
||||||
*/
|
*/
|
||||||
@ -139,7 +139,7 @@ native GameRules_GetPropEnt(const String:prop[], element=0);
|
|||||||
* @param prop Property name.
|
* @param prop Property name.
|
||||||
* @param other Entity index to set, or -1 to unset.
|
* @param other Entity index to set, or -1 to unset.
|
||||||
* @param element Element # (starting from 0) if property is an array.
|
* @param element Element # (starting from 0) if property is an array.
|
||||||
* @param changeState If true, change will be sent over the network.
|
* @param changeState This parameter is ignored.
|
||||||
* @noreturn
|
* @noreturn
|
||||||
* @error Not supported.
|
* @error Not supported.
|
||||||
*/
|
*/
|
||||||
@ -162,7 +162,7 @@ native GameRules_GetPropVector(const String:prop[], Float:vec[3], element=0);
|
|||||||
* @param prop Property name.
|
* @param prop Property name.
|
||||||
* @param vec Vector to set.
|
* @param vec Vector to set.
|
||||||
* @param element Element # (starting from 0) if property is an array.
|
* @param element Element # (starting from 0) if property is an array.
|
||||||
* @param changeState If true, change will be sent over the network.
|
* @param changeState This parameter is ignored.
|
||||||
* @noreturn
|
* @noreturn
|
||||||
* @error Not supported.
|
* @error Not supported.
|
||||||
*/
|
*/
|
||||||
@ -184,7 +184,7 @@ native GameRules_GetPropString(const String:prop[], String:buffer[], maxlen);
|
|||||||
*
|
*
|
||||||
* @param prop Property to use.
|
* @param prop Property to use.
|
||||||
* @param buffer String to set.
|
* @param buffer String to set.
|
||||||
* @param changeState If true, change will be sent over the network.
|
* @param changeState This parameter is ignored.
|
||||||
* @return Number of non-null bytes written.
|
* @return Number of non-null bytes written.
|
||||||
* @error Not supported.
|
* @error Not supported.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user