mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-26 06:45:37 +03:00
Fix some natives relying on a known engine bug related to last player's edict being invalid
This commit is contained in:
parent
fd0f6cc429
commit
9980b7ac62
@ -83,7 +83,7 @@ static cell AMX_NATIVE_CALL emit_sound(AMX *amx, cell *params) /* 7 param */
|
|||||||
EMIT_SOUND_DYN2(pPlayer->pEdict, channel, szSample, vol, att, flags, pitch);
|
EMIT_SOUND_DYN2(pPlayer->pEdict, channel, szSample, vol, att, flags, pitch);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
edict_t* pEdict = INDEXENT(params[1]);
|
edict_t* pEdict = GETEDICT(params[1]);
|
||||||
|
|
||||||
if (!FNullEnt(pEdict))
|
if (!FNullEnt(pEdict))
|
||||||
EMIT_SOUND_DYN2(pEdict, channel, szSample, vol, att, flags, pitch);
|
EMIT_SOUND_DYN2(pEdict, channel, szSample, vol, att, flags, pitch);
|
||||||
|
@ -145,6 +145,7 @@ void UTIL_TrimRight(char *buffer);
|
|||||||
#define GET_PLAYER_POINTER(e) (&g_players[ENTINDEX(e)])
|
#define GET_PLAYER_POINTER(e) (&g_players[ENTINDEX(e)])
|
||||||
//#define GET_PLAYER_POINTER(e) (&g_players[(((int)e-g_edict_point)/sizeof(edict_t))])
|
//#define GET_PLAYER_POINTER(e) (&g_players[(((int)e-g_edict_point)/sizeof(edict_t))])
|
||||||
#define GET_PLAYER_POINTER_I(i) (&g_players[i])
|
#define GET_PLAYER_POINTER_I(i) (&g_players[i])
|
||||||
|
#define GETEDICT(n) ((n >= 1 && n <= gpGlobals->maxClients) ? GET_PLAYER_POINTER_I(n)->pEdict : INDEXENT(n))
|
||||||
|
|
||||||
struct WeaponsVault
|
struct WeaponsVault
|
||||||
{
|
{
|
||||||
|
@ -423,7 +423,7 @@ static cell _message_begin(AMX *amx, cell *params, bool useFloat) /* 4 param */
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
MESSAGE_BEGIN(params[1], params[2], NULL, INDEXENT(params[4]));
|
MESSAGE_BEGIN(params[1], params[2], NULL, GETEDICT(params[4]));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -771,7 +771,7 @@ static cell _emessage_begin(AMX *amx, cell *params, bool useFloat)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_pEngTable->pfnMessageBegin(params[1], params[2], NULL, INDEXENT(params[4]));
|
g_pEngTable->pfnMessageBegin(params[1], params[2], NULL, GETEDICT(params[4]));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -662,7 +662,7 @@ static cell AMX_NATIVE_CALL objectives_reinit(AMX *amx, cell *params){ // index
|
|||||||
MF_LogError(amx, AMX_ERR_NATIVE, "Index out of range (%d)", player);
|
MF_LogError(amx, AMX_ERR_NATIVE, "Index out of range (%d)", player);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
mObjects.InitObj( player == 0 ? MSG_ALL:MSG_ONE, player == 0 ? NULL:INDEXENT(player) );
|
mObjects.InitObj( player == 0 ? MSG_ALL:MSG_ONE, player == 0 ? NULL: GETEDICT(player) );
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ void Client_InitObj(void* mValue){
|
|||||||
mObjects.Clear();
|
mObjects.Clear();
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
mObjects.obj[num].pEdict = INDEXENT(*(int*)mValue);
|
mObjects.obj[num].pEdict = GETEDICT(*(int*)mValue);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
mObjects.obj[num].index = *(int*)mValue;
|
mObjects.obj[num].index = *(int*)mValue;
|
||||||
|
@ -577,7 +577,7 @@ static cell AMX_NATIVE_CALL dod_weaponlist(AMX *amx, cell *params) // player
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
MESSAGE_BEGIN(MSG_ONE, GET_USER_MSG_ID(PLID, "WeaponList", NULL), NULL, INDEXENT(id));
|
MESSAGE_BEGIN(MSG_ONE, GET_USER_MSG_ID(PLID, "WeaponList", NULL), NULL, pPlayer->pEdict);
|
||||||
WRITE_BYTE(weaponlist[wpnID].grp);
|
WRITE_BYTE(weaponlist[wpnID].grp);
|
||||||
WRITE_BYTE(totalrds);
|
WRITE_BYTE(totalrds);
|
||||||
WRITE_BYTE(-1);
|
WRITE_BYTE(-1);
|
||||||
|
@ -85,7 +85,7 @@ static cell AMX_NATIVE_CALL set_tr(AMX *amx, cell *params)
|
|||||||
}
|
}
|
||||||
case TR_pHit:
|
case TR_pHit:
|
||||||
{
|
{
|
||||||
e = INDEXENT(*ptr);
|
e = INDEXENT2(*ptr);
|
||||||
if (!e || FNullEnt(e))
|
if (!e || FNullEnt(e))
|
||||||
return 0; //TODO: return error
|
return 0; //TODO: return error
|
||||||
gfm_tr->pHit = e;
|
gfm_tr->pHit = e;
|
||||||
|
@ -98,7 +98,7 @@ static cell AMX_NATIVE_CALL set_tr2(AMX *amx, cell *params)
|
|||||||
}
|
}
|
||||||
case TR_pHit:
|
case TR_pHit:
|
||||||
{
|
{
|
||||||
edict_t *e = INDEXENT(*ptr);
|
edict_t *e = INDEXENT2(*ptr);
|
||||||
if (!e || FNullEnt(e))
|
if (!e || FNullEnt(e))
|
||||||
return 0; //TODO: return error
|
return 0; //TODO: return error
|
||||||
tr->pHit = e;
|
tr->pHit = e;
|
||||||
|
@ -382,7 +382,7 @@ static cell AMX_NATIVE_CALL amx_set_pev(AMX *amx, cell *params)
|
|||||||
*(string_t *)EDICT_OFFS(v, offs) = value;
|
*(string_t *)EDICT_OFFS(v, offs) = value;
|
||||||
} else if ( (iSwitch > pev_edict_start && iSwitch < pev_edict_end)
|
} else if ( (iSwitch > pev_edict_start && iSwitch < pev_edict_end)
|
||||||
|| (iSwitch > pev_edict2_start && iSwitch < pev_absolute_end) ) {
|
|| (iSwitch > pev_edict2_start && iSwitch < pev_absolute_end) ) {
|
||||||
edict_t *e = INDEXENT((int)*blah);
|
edict_t *e = INDEXENT2((int)*blah);
|
||||||
*(edict_t **)EDICT_OFFS(v, offs) = e;
|
*(edict_t **)EDICT_OFFS(v, offs) = e;
|
||||||
} else if (iSwitch > pev_vecarray_start && iSwitch < pev_vecarray_end) {
|
} else if (iSwitch > pev_vecarray_start && iSwitch < pev_vecarray_end) {
|
||||||
vec3_t vec;
|
vec3_t vec;
|
||||||
@ -455,7 +455,7 @@ static cell AMX_NATIVE_CALL amx_pev_valid(AMX *amx, cell *params)
|
|||||||
{
|
{
|
||||||
int idx = static_cast<int>(params[1]);
|
int idx = static_cast<int>(params[1]);
|
||||||
|
|
||||||
edict_t *e = INDEXENT(idx);
|
edict_t *e = INDEXENT2(idx);
|
||||||
|
|
||||||
if (FNullEnt(e))
|
if (FNullEnt(e))
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -31,7 +31,7 @@ static cell AMX_NATIVE_CALL TFC_SetModel(AMX *amx, cell *params) {
|
|||||||
char *szModel = MF_GetAmxString(amx, params[2],0, &iLen);
|
char *szModel = MF_GetAmxString(amx, params[2],0, &iLen);
|
||||||
|
|
||||||
// Get Player's edict pointer
|
// Get Player's edict pointer
|
||||||
edict_t* pPlayer = INDEXENT(iIndex);
|
edict_t* pPlayer = MF_GetPlayerEdict(iIndex);
|
||||||
|
|
||||||
// Set key on client, replacement_model is for the model we want.
|
// Set key on client, replacement_model is for the model we want.
|
||||||
KeyValueData pkvd;
|
KeyValueData pkvd;
|
||||||
@ -62,7 +62,7 @@ static cell AMX_NATIVE_CALL TFC_ClearModel(AMX *amx, cell *params) {
|
|||||||
|
|
||||||
CHECK_PLAYER(iIndex)
|
CHECK_PLAYER(iIndex)
|
||||||
|
|
||||||
edict_t* pPlayer = INDEXENT(iIndex);
|
edict_t* pPlayer = MF_GetPlayerEdict(iIndex);
|
||||||
|
|
||||||
if (pPlayer->pvPrivateData == NULL)
|
if (pPlayer->pvPrivateData == NULL)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user