- use an actor pointer in Get/SetGameVarID's parameters to weed out the ordering screwups.

This commit is contained in:
Christoph Oelckers 2020-11-01 18:23:09 +01:00
parent de92287d0b
commit a514910aa4
12 changed files with 136 additions and 133 deletions

View file

@ -257,7 +257,7 @@ void addweapon_d(struct player_struct *p, int weapon)
}
SetGameVarID(g_iReturnVarID, 0, snum, -1);
OnEvent(EVENT_CHANGEWEAPON, snum, p->GetActor(), -1);
if (GetGameVarID(g_iReturnVarID, -1, snum) == 0)
if (GetGameVarID(g_iReturnVarID, nullptr, snum) == 0)
{
p->curr_weapon = weapon;
}
@ -1048,7 +1048,7 @@ static void movetripbomb(DDukeActor *actor)
{
auto s = &actor->s;
int j, x;
int lTripBombControl = GetGameVar("TRIPBOMB_CONTROL", TRIPBOMB_TRIPWIRE, -1, -1);
int lTripBombControl = GetGameVar("TRIPBOMB_CONTROL", TRIPBOMB_TRIPWIRE, nullptr, -1);
if (lTripBombControl & TRIPBOMB_TIMER)
{
// we're on a timer....

View file

@ -241,11 +241,11 @@ static bool cheatInventory(int player)
{
auto invGet = [=](int defvalue, int evtype, int16_t &dest)
{
SetGameVarID(g_iReturnVarID, defvalue, -1, player);
SetGameVarID(g_iReturnVarID, defvalue, nullptr, player);
OnEvent(evtype, player, nullptr, -1);
if (GetGameVarID(g_iReturnVarID, -1, player) >= 0)
if (GetGameVarID(g_iReturnVarID, nullptr, player) >= 0)
{
dest = GetGameVarID(g_iReturnVarID, -1, player);
dest = GetGameVarID(g_iReturnVarID, nullptr, player);
}
};

View file

@ -190,16 +190,6 @@ inline int bossguy(DDukeActor* pSprite)
return bossguypic(pSprite->s.picnum);
}
inline int GetGameVarID(int id, DDukeActor* sActor, int sPlayer)
{
return GetGameVarID(id, sActor->GetIndex(), sPlayer);
}
inline void SetGameVarID(int id, int lValue, DDukeActor* sActor, int sPlayer)
{
SetGameVarID(id, lValue, sActor->GetIndex(), sPlayer);
}
// old interface versions of already changed functions
inline void RANDOMSCRAP(spritetype* s, int i)

View file

@ -95,9 +95,10 @@ void addspritetodelete(int spnum)
killthesprite = true;
}
static void DoUserDef(bool bSet, int lVar1, int lLabelID, int lVar2, int sActor, int sPlayer, int lParm2)
static void DoUserDef(bool bSet, int lVar1, int lLabelID, int lVar2, int sActor_, int sPlayer, int lParm2)
{
int lValue;
auto sActor = &hittype[sActor_];
lValue = GetGameVarID((int)lVar2, sActor, sPlayer);
@ -262,12 +263,13 @@ static void DoUserDef(bool bSet, int lVar1, int lLabelID, int lVar2, int sActor,
}
///////////////////////////////////////////
void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, int sActor, int sPlayer, int lParm2)
void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, int sActor_, int sPlayer, int lParm2)
{
int iPlayer;
int lValue;
int lTemp;
auto sActor = &hittype[sActor_];
lValue = GetGameVarID((int)lVar2, sActor, sPlayer);
if (lVar1 == g_iThisActorID)
@ -931,11 +933,12 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, int sActor, int sPl
}
////////////////////
void DoWall(char bSet, int lVar1, int lLabelID, int lVar2, short sActor, short sPlayer, int lParm2)
void DoWall(char bSet, int lVar1, int lLabelID, int lVar2, short sActor_, short sPlayer, int lParm2)
{
int iWall;
int lValue;
auto sActor = &hittype[sActor_];
lValue = GetGameVarID((int)lVar2, sActor, sPlayer);
iWall = GetGameVarID((int)lVar1, sActor, sPlayer);
@ -1018,16 +1021,17 @@ void DoWall(char bSet, int lVar1, int lLabelID, int lVar2, short sActor, short s
return;
}
void DoSector(char bSet, int lVar1, int lLabelID, int lVar2, short sActor, short sPlayer, int lParm2)
void DoSector(char bSet, int lVar1, int lLabelID, int lVar2, short sActor_, short sPlayer, int lParm2)
{
int iSector;
int lValue;
auto sActor = &hittype[sActor_];
if (lVar1 == g_iThisActorID)
{
// if they've asked for 'this', then use 'this'...
iSector = sprite[sActor].sectnum;
iSector = sActor->s.sectnum;
}
else
{
@ -1133,17 +1137,18 @@ void DoSector(char bSet, int lVar1, int lLabelID, int lVar2, short sActor, short
}
return;
}
void DoActor(bool bSet, int lVar1, int lLabelID, int lVar2, int sActor, int sPlayer, int lParm2)
void DoActor(bool bSet, int lVar1, int lLabelID, int lVar2, int sActor_, int sPlayer, int lParm2)
{
int iActor;
int lValue;
auto sActor = &hittype[sActor_];
lValue = GetGameVarID((int)lVar2, sActor, sPlayer);
if (lVar1 == g_iThisActorID)
{
// if they've asked for 'this', then use 'this'...
iActor = sActor;
iActor = sActor_;
}
else
{
@ -2604,7 +2609,7 @@ int ParseState::parse(void)
{ int i;
insptr++;
i=*(insptr++); // ID of def
SetGameVarID(i, *insptr, g_ac->GetIndex(), g_p );
SetGameVarID(i, *insptr, g_ac, g_p );
insptr++;
break;
}
@ -2612,7 +2617,7 @@ int ParseState::parse(void)
{ int i;
insptr++;
i=*(insptr++); // ID of def
SetGameVarID(i, GetGameVarID(*insptr, g_ac, g_p), g_ac->GetIndex(), g_p );
SetGameVarID(i, GetGameVarID(*insptr, g_ac, g_p), g_ac, g_p );
// aGameVars[i].lValue = aGameVars[*insptr].lValue;
insptr++;
break;
@ -2623,7 +2628,7 @@ int ParseState::parse(void)
i=*(insptr++); // ID of def
//sprintf(g_szBuf,"AddVar %d to Var ID=%d, g_ac->GetIndex()=%d, g_p=%d\n",*insptr, i, g_ac, g_p);
//AddLog(g_szBuf);
SetGameVarID(i, GetGameVarID(i, g_ac, g_p) + *insptr, g_ac->GetIndex(), g_p );
SetGameVarID(i, GetGameVarID(i, g_ac, g_p) + *insptr, g_ac, g_p );
insptr++;
break;
}
@ -2632,7 +2637,7 @@ int ParseState::parse(void)
{ int i;
insptr++;
i=*(insptr++); // ID of def
SetGameVarID(i, GetGameVarID(i, g_ac, g_p) + GetGameVarID(*insptr, g_ac, g_p), g_ac->GetIndex(), g_p );
SetGameVarID(i, GetGameVarID(i, g_ac, g_p) + GetGameVarID(*insptr, g_ac, g_p), g_ac, g_p );
insptr++;
break;
}
@ -3058,7 +3063,7 @@ int ParseState::parse(void)
if (lSprite >= 0)
{
lTemp = GetGameVarID(lVar3, g_ac, g_p);
SetGameVarID(lVar2, lTemp, lSprite, g_p);
SetGameVarID(lVar2, lTemp, &hittype[lSprite], g_p);
}
break;
@ -3080,7 +3085,7 @@ int ParseState::parse(void)
lSprite = GetGameVarID(lVar1, g_ac, g_p);
if (lSprite >= 0)
{
lTemp = GetGameVarID(lVar2, lSprite, g_p);
lTemp = GetGameVarID(lVar2, &hittype[lSprite], g_p);
SetGameVarID(lVar3, lTemp, g_ac, g_p);
}

View file

@ -278,7 +278,7 @@ void ResetGameVars(void)
//
//---------------------------------------------------------------------------
int GetGameVarID(int id, int sActor, int sPlayer)
int GetGameVarID(int id, DDukeActor* sActor, int sPlayer)
{
if(id<0 || id >= iGameVarCount)
{
@ -287,7 +287,7 @@ int GetGameVarID(int id, int sActor, int sPlayer)
}
if (id == g_iThisActorID)
{
return sActor;
return sActor->GetIndex();
}
if( aGameVars[id].dwFlags & GAMEVAR_FLAG_PERPLAYER )
{
@ -304,9 +304,9 @@ int GetGameVarID(int id, int sActor, int sPlayer)
else if( aGameVars[id].dwFlags & GAMEVAR_FLAG_PERACTOR )
{
// for the current actor
if(sActor >= 0 && sActor <=MAXSPRITES)
if(sActor != nullptr)
{
return aGameVars[id].plArray[sActor];
return aGameVars[id].plArray[sActor->GetIndex()];
}
else
{
@ -344,7 +344,7 @@ int GetGameVarID(int id, int sActor, int sPlayer)
//
//---------------------------------------------------------------------------
void SetGameVarID(int id, int lValue, int sActor, int sPlayer)
void SetGameVarID(int id, int lValue, DDukeActor* sActor, int sPlayer)
{
if(id<0 || id >= iGameVarCount)
{
@ -360,7 +360,7 @@ void SetGameVarID(int id, int lValue, int sActor, int sPlayer)
else if( aGameVars[id].dwFlags & GAMEVAR_FLAG_PERACTOR )
{
// for the current actor
if (sActor >= 0) aGameVars[id].plArray[sActor]=lValue;
if (sActor != nullptr) aGameVars[id].plArray[sActor->GetIndex()]=lValue;
else for (auto& i : aGameVars[id].plArray) i = lValue; // -1 sets all actors - was undefined OOB access in WW2GI.
}
else if( aGameVars[id].dwFlags & GAMEVAR_FLAG_PLONG )
@ -381,7 +381,7 @@ void SetGameVarID(int id, int lValue, int sActor, int sPlayer)
//
//---------------------------------------------------------------------------
int GetGameVar(const char *szGameLabel, int lDefault, int sActor, int sPlayer)
int GetGameVar(const char *szGameLabel, int lDefault, DDukeActor* sActor, int sPlayer)
{
for (int i = 0; i < iGameVarCount; i++)
{
@ -1171,49 +1171,49 @@ void ResetSystemDefaults(void)
for(i=0;i<12/*MAX_WEAPONS*/;i++)
{
sprintf(aszBuf,"WEAPON%d_CLIP",i);
aplWeaponClip[i][j]=GetGameVar(aszBuf,0, -1, j);
aplWeaponClip[i][j]=GetGameVar(aszBuf,0, nullptr, j);
sprintf(aszBuf,"WEAPON%d_RELOAD",i);
aplWeaponReload[i][j]=GetGameVar(aszBuf,0, -1, j);
aplWeaponReload[i][j]=GetGameVar(aszBuf,0, nullptr, j);
sprintf(aszBuf,"WEAPON%d_FIREDELAY",i);
aplWeaponFireDelay[i][j]=GetGameVar(aszBuf,0, -1, j);
aplWeaponFireDelay[i][j]=GetGameVar(aszBuf,0, nullptr, j);
sprintf(aszBuf,"WEAPON%d_TOTALTIME",i);
aplWeaponTotalTime[i][j]=GetGameVar(aszBuf,0, -1, j);
aplWeaponTotalTime[i][j]=GetGameVar(aszBuf,0, nullptr, j);
sprintf(aszBuf,"WEAPON%d_HOLDDELAY",i);
aplWeaponHoldDelay[i][j]=GetGameVar(aszBuf,0, -1, j);
aplWeaponHoldDelay[i][j]=GetGameVar(aszBuf,0, nullptr, j);
sprintf(aszBuf,"WEAPON%d_FLAGS",i);
aplWeaponFlags[i][j]=GetGameVar(aszBuf,0, -1, j);
aplWeaponFlags[i][j]=GetGameVar(aszBuf,0, nullptr, j);
sprintf(aszBuf,"WEAPON%d_SHOOTS",i);
aplWeaponShoots[i][j]=GetGameVar(aszBuf,0, -1, j);
aplWeaponShoots[i][j]=GetGameVar(aszBuf,0, nullptr, j);
sprintf(aszBuf,"WEAPON%d_SPAWNTIME",i);
aplWeaponSpawnTime[i][j]=GetGameVar(aszBuf,0, -1, j);
aplWeaponSpawnTime[i][j]=GetGameVar(aszBuf,0, nullptr, j);
sprintf(aszBuf,"WEAPON%d_SPAWN",i);
aplWeaponSpawn[i][j]=GetGameVar(aszBuf,0, -1, j);
aplWeaponSpawn[i][j]=GetGameVar(aszBuf,0, nullptr, j);
sprintf(aszBuf,"WEAPON%d_SHOTSPERBURST",i);
aplWeaponShotsPerBurst[i][j]=GetGameVar(aszBuf,0, -1, j);
aplWeaponShotsPerBurst[i][j]=GetGameVar(aszBuf,0, nullptr, j);
sprintf(aszBuf,"WEAPON%d_WORKSLIKE",i);
aplWeaponWorksLike[i][j]=GetGameVar(aszBuf,0, -1, j);
aplWeaponWorksLike[i][j]=GetGameVar(aszBuf,0, nullptr, j);
sprintf(aszBuf,"WEAPON%d_INITIALSOUND",i);
aplWeaponInitialSound[i][j]=GetGameVar(aszBuf,0, -1, j);
aplWeaponInitialSound[i][j]=GetGameVar(aszBuf,0, nullptr, j);
sprintf(aszBuf,"WEAPON%d_FIRESOUND",i);
aplWeaponFireSound[i][j]=GetGameVar(aszBuf,0, -1, j);
aplWeaponFireSound[i][j]=GetGameVar(aszBuf,0, nullptr, j);
sprintf(aszBuf,"WEAPON%d_SOUND2TIME",i);
aplWeaponSound2Time[i][j]=GetGameVar(aszBuf,0, -1, j);
aplWeaponSound2Time[i][j]=GetGameVar(aszBuf,0, nullptr, j);
sprintf(aszBuf,"WEAPON%d_SOUND2SOUND",i);
aplWeaponSound2Sound[i][j]=GetGameVar(aszBuf,0, -1, j);
aplWeaponSound2Sound[i][j]=GetGameVar(aszBuf,0, nullptr, j);
}
}

View file

@ -124,9 +124,11 @@ int GetDefID(const char *szGameLabel);
void ClearGameVars(void);
void AddSystemVars();
void ResetGameVars(void);
int GetGameVarID(int id, int sActor, int sPlayer);
void SetGameVarID(int id, int lValue, int sActor, int sPlayer);
int GetGameVar(const char* szGameLabel, int lDefault, int sActor, int sPlayer);
struct weaponhit;
using DDukeActor = weaponhit;
int GetGameVarID(int id, DDukeActor* sActor, int sPlayer);
void SetGameVarID(int id, int lValue, DDukeActor* sActor, int sPlayer);
int GetGameVar(const char* szGameLabel, int lDefault, DDukeActor* sActor, int sPlayer);
void ClearGameEvents();
bool IsGameEvent(int i);

View file

@ -95,9 +95,9 @@ void hud_input(int plnum)
{
if (PlayerInput(plnum, SB_QUICK_KICK) && p->quick_kick == 0 && (p->curr_weapon != KNEE_WEAPON || p->kickback_pic == 0))
{
SetGameVarID(g_iReturnVarID, 0, -1, plnum);
SetGameVarID(g_iReturnVarID, 0, nullptr, plnum);
OnEvent(EVENT_QUICKKICK, plnum, nullptr, -1);
if (GetGameVarID(g_iReturnVarID, -1, plnum) == 0)
if (GetGameVarID(g_iReturnVarID, nullptr, plnum) == 0)
{
p->quick_kick = 14;
if (!p->quick_kick_msg && plnum == screenpeek) FTA(QUOTE_MIGHTY_FOOT, p);
@ -120,9 +120,9 @@ void hud_input(int plnum)
// Activate an inventory item. This just forwards to the other inventory bits. If the inventory selector was taken out of the playsim this could be removed.
if (PlayerInput(plnum, SB_INVUSE) && p->newowner == -1)
{
SetGameVarID(g_iReturnVarID, 0, -1, plnum);
SetGameVarID(g_iReturnVarID, 0, nullptr, plnum);
OnEvent(EVENT_INVENTORY, plnum, nullptr, -1);
if (GetGameVarID(g_iReturnVarID, -1, plnum) == 0)
if (GetGameVarID(g_iReturnVarID, nullptr, plnum) == 0)
{
if (p->inven_icon > ICON_NONE && p->inven_icon <= ICON_HEATS) PlayerSetItemUsed(plnum, p->inven_icon);
}
@ -130,9 +130,9 @@ void hud_input(int plnum)
if (!isRR() && PlayerUseItem(plnum, ICON_HEATS))
{
SetGameVarID(g_iReturnVarID, 0, -1, plnum);
SetGameVarID(g_iReturnVarID, 0, nullptr, plnum);
OnEvent(EVENT_USENIGHTVISION, plnum, nullptr, -1);
if (GetGameVarID(g_iReturnVarID, -1, plnum) == 0 && p->heat_amount > 0)
if (GetGameVarID(g_iReturnVarID, nullptr, plnum) == 0 && p->heat_amount > 0)
{
p->heat_on = !p->heat_on;
setpal(p);
@ -144,9 +144,9 @@ void hud_input(int plnum)
if (PlayerUseItem(plnum, ICON_STEROIDS))
{
SetGameVarID(g_iReturnVarID, 0, -1, plnum);
SetGameVarID(g_iReturnVarID, 0, nullptr, plnum);
OnEvent(EVENT_USESTEROIDS, plnum, nullptr, -1);
if (GetGameVarID(g_iReturnVarID, -1, plnum) == 0)
if (GetGameVarID(g_iReturnVarID, nullptr, plnum) == 0)
{
if (p->steroids_amount == 400)
{
@ -227,15 +227,15 @@ void hud_input(int plnum)
// These events force us to keep the inventory selector in the playsim as opposed to the UI where it really belongs.
if (PlayerInput(plnum, SB_INVPREV))
{
SetGameVarID(g_iReturnVarID, dainv, -1, plnum);
SetGameVarID(g_iReturnVarID, dainv, nullptr, plnum);
OnEvent(EVENT_INVENTORYLEFT, plnum, nullptr, -1);
dainv = GetGameVarID(g_iReturnVarID, -1, plnum);
dainv = GetGameVarID(g_iReturnVarID, nullptr, plnum);
}
if (PlayerInput(plnum, SB_INVNEXT))
{
SetGameVarID(g_iReturnVarID, dainv, -1, plnum);
SetGameVarID(g_iReturnVarID, dainv, nullptr, plnum);
OnEvent(EVENT_INVENTORYRIGHT, plnum, nullptr, -1);
dainv = GetGameVarID(g_iReturnVarID, -1, plnum);
dainv = GetGameVarID(g_iReturnVarID, nullptr, plnum);
}
p->inven_icon = dainv;
// Someone must have really hated constant data, doing this with a switch/case (and of course also with literal numbers...)
@ -271,9 +271,9 @@ void hud_input(int plnum)
if (PlayerUseItem(plnum, ICON_HOLODUKE) && (isRR() || p->newowner == -1))
{
SetGameVarID(g_iReturnVarID, 0, -1, plnum);
SetGameVarID(g_iReturnVarID, 0, nullptr, plnum);
OnEvent(EVENT_HOLODUKEON, plnum, nullptr, -1);
if (GetGameVarID(g_iReturnVarID, -1, plnum) == 0)
if (GetGameVarID(g_iReturnVarID, nullptr, plnum) == 0)
{
if (!isRR())
{
@ -328,9 +328,9 @@ void hud_input(int plnum)
if (isRR() && PlayerUseItem(plnum, ICON_HEATS) && p->newowner == -1)
{
SetGameVarID(g_iReturnVarID, 0, -1, plnum);
SetGameVarID(g_iReturnVarID, 0, nullptr, plnum);
OnEvent(EVENT_USENIGHTVISION, plnum, nullptr, -1);
if (GetGameVarID(g_iReturnVarID, -1, plnum) == 0)
if (GetGameVarID(g_iReturnVarID, nullptr, plnum) == 0)
{
if (p->yehaa_timer == 0)
{
@ -360,9 +360,9 @@ void hud_input(int plnum)
if (PlayerUseItem(plnum, ICON_FIRSTAID))
{
SetGameVarID(g_iReturnVarID, 0, -1, plnum);
SetGameVarID(g_iReturnVarID, 0, nullptr, plnum);
OnEvent(EVENT_USEMEDKIT, plnum, nullptr, -1);
if (GetGameVarID(g_iReturnVarID, -1, plnum) == 0)
if (GetGameVarID(g_iReturnVarID, nullptr, plnum) == 0)
{
if (p->firstaid_amount > 0 && p->GetActor()->s.extra < max_player_health)
{
@ -413,9 +413,9 @@ void hud_input(int plnum)
if (PlayerUseItem(plnum, ICON_JETPACK) && (isRR() || p->newowner == -1))
{
SetGameVarID(g_iReturnVarID, 0, -1, plnum);
SetGameVarID(g_iReturnVarID, 0, nullptr, plnum);
OnEvent(EVENT_USEJETPACK, plnum, nullptr, -1);
if (GetGameVarID(g_iReturnVarID, -1, plnum) == 0)
if (GetGameVarID(g_iReturnVarID, nullptr, plnum) == 0)
{
if (!isRR())
{
@ -481,9 +481,9 @@ void hud_input(int plnum)
if (PlayerInput(plnum, SB_TURNAROUND) && p->angle.spin.asbam() == 0 && p->on_crane == nullptr)
{
SetGameVarID(g_iReturnVarID, 0, -1, plnum);
SetGameVarID(g_iReturnVarID, 0, nullptr, plnum);
OnEvent(EVENT_TURNAROUND, plnum, nullptr, -1);
if (GetGameVarID(g_iReturnVarID, -1, plnum) != 0)
if (GetGameVarID(g_iReturnVarID, nullptr, plnum) != 0)
{
p->sync.actions &= ~SB_TURNAROUND;
}

View file

@ -741,9 +741,9 @@ void playerCrouch(int snum)
{
auto p = &ps[snum];
// crouching
SetGameVarID(g_iReturnVarID, 0, p->i, snum);
SetGameVarID(g_iReturnVarID, 0, p->GetActor(), snum);
OnEvent(EVENT_CROUCH, snum, p->GetActor(), -1);
if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0)
if (GetGameVarID(g_iReturnVarID, p->GetActor(), snum) == 0)
{
p->posz += (2048 + 768);
p->crack_time = CRACK_TIME;
@ -757,9 +757,9 @@ void playerJump(int snum, int fz, int cz)
{
if ((fz - cz) > (56 << 8))
{
SetGameVarID(g_iReturnVarID, 0, p->i, snum);
SetGameVarID(g_iReturnVarID, 0, p->GetActor(), snum);
OnEvent(EVENT_JUMP, snum, p->GetActor(), -1);
if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0)
if (GetGameVarID(g_iReturnVarID, p->GetActor(), snum) == 0)
{
p->jumping_counter = 1;
p->jumping_toggle = 1;
@ -904,9 +904,9 @@ void checklook(int snum, ESyncBits actions)
if ((actions & SB_LOOK_LEFT) && !p->OnMotorcycle)
{
SetGameVarID(g_iReturnVarID, 0, p->i, snum);
SetGameVarID(g_iReturnVarID, 0, p->GetActor(), snum);
OnEvent(EVENT_LOOKLEFT, snum, p->GetActor(), -1);
if (GetGameVarID(g_iReturnVarID, p->i, snum) != 0)
if (GetGameVarID(g_iReturnVarID, p->GetActor(), snum) != 0)
{
actions &= ~SB_LOOK_LEFT;
}
@ -914,9 +914,9 @@ void checklook(int snum, ESyncBits actions)
if ((actions & SB_LOOK_RIGHT) && !p->OnMotorcycle)
{
SetGameVarID(g_iReturnVarID, 0, p->i, snum);
SetGameVarID(g_iReturnVarID, 0, p->GetActor(), snum);
OnEvent(EVENT_LOOKRIGHT, snum, p->GetActor(), -1);
if (GetGameVarID(g_iReturnVarID, p->i, snum) != 0)
if (GetGameVarID(g_iReturnVarID, p->GetActor(), snum) != 0)
{
actions &= ~SB_LOOK_RIGHT;
}
@ -933,9 +933,9 @@ void checklook(int snum, ESyncBits actions)
void playerCenterView(int snum)
{
auto p = &ps[snum];
SetGameVarID(g_iReturnVarID, 0, p->i, snum);
SetGameVarID(g_iReturnVarID, 0, p->GetActor(), snum);
OnEvent(EVENT_RETURNTOCENTER, snum, p->GetActor(), -1);
if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0)
if (GetGameVarID(g_iReturnVarID, p->GetActor(), snum) == 0)
{
p->sync.actions |= SB_CENTERVIEW;
}
@ -948,9 +948,9 @@ void playerCenterView(int snum)
void playerLookUp(int snum, ESyncBits actions)
{
auto p = &ps[snum];
SetGameVarID(g_iReturnVarID, 0, p->i, snum);
SetGameVarID(g_iReturnVarID, 0, p->GetActor(), snum);
OnEvent(EVENT_LOOKUP, snum, p->GetActor(), -1);
if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0)
if (GetGameVarID(g_iReturnVarID, p->GetActor(), snum) == 0)
{
p->sync.actions |= SB_CENTERVIEW;
}
@ -963,9 +963,9 @@ void playerLookUp(int snum, ESyncBits actions)
void playerLookDown(int snum, ESyncBits actions)
{
auto p = &ps[snum];
SetGameVarID(g_iReturnVarID, 0, p->i, snum);
SetGameVarID(g_iReturnVarID, 0, p->GetActor(), snum);
OnEvent(EVENT_LOOKDOWN, snum, p->GetActor(), -1);
if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0)
if (GetGameVarID(g_iReturnVarID, p->GetActor(), snum) == 0)
{
p->sync.actions |= SB_CENTERVIEW;
}
@ -978,9 +978,9 @@ void playerLookDown(int snum, ESyncBits actions)
void playerAimUp(int snum, ESyncBits actions)
{
auto p = &ps[snum];
SetGameVarID(g_iReturnVarID, 0, p->i, snum);
SetGameVarID(g_iReturnVarID, 0, p->GetActor(), snum);
OnEvent(EVENT_AIMUP, snum, p->GetActor(), -1);
if (GetGameVarID(g_iReturnVarID, p->i, snum) != 0)
if (GetGameVarID(g_iReturnVarID, p->GetActor(), snum) != 0)
{
p->sync.actions &= ~SB_AIM_UP;
}
@ -989,9 +989,9 @@ void playerAimUp(int snum, ESyncBits actions)
void playerAimDown(int snum, ESyncBits actions)
{
auto p = &ps[snum];
SetGameVarID(g_iReturnVarID, 0, p->i, snum);
SetGameVarID(g_iReturnVarID, 0, p->GetActor(), snum);
OnEvent(EVENT_AIMDOWN, snum, p->GetActor(), -1);
if (GetGameVarID(g_iReturnVarID, p->i, snum) != 0)
if (GetGameVarID(g_iReturnVarID, p->GetActor(), snum) != 0)
{
p->sync.actions &= ~SB_AIM_DOWN;
}

View file

@ -316,7 +316,8 @@ static void shootknee(int i, int p, int sx, int sy, int sz, int sa)
static void shootweapon(int i, int p, int sx, int sy, int sz, int sa, int atwith)
{
spritetype* const s = &sprite[i];
auto actor = &hittype[i];
auto s = &actor->s;
int sect = s->sectnum;
int zvel;
short hitsect, hitspr, hitwall, l, j, k;
@ -326,12 +327,13 @@ static void shootweapon(int i, int p, int sx, int sy, int sz, int sa, int atwith
if (p >= 0)
{
SetGameVarID(g_iAimAngleVarID, AUTO_AIM_ANGLE, i, p);
SetGameVarID(g_iAimAngleVarID, AUTO_AIM_ANGLE, actor, p);
OnEvent(EVENT_GETAUTOAIMANGLE, p, ps[p].GetActor(), -1);
int varval = GetGameVarID(g_iAimAngleVarID, actor, p);
j = -1;
if (GetGameVarID(g_iAimAngleVarID, i, p) > 0)
if (varval > 0)
{
j = aim(s, GetGameVarID(g_iAimAngleVarID, i, p));
j = aim(s, varval);
}
if (j >= 0)
@ -359,11 +361,11 @@ static void shootweapon(int i, int p, int sx, int sy, int sz, int sa, int atwith
{
int angRange = 32;
int zRange = 256;
SetGameVarID(g_iAngRangeVarID, 32, i, p);
SetGameVarID(g_iZRangeVarID, 256, i, p);
SetGameVarID(g_iAngRangeVarID, 32, actor, p);
SetGameVarID(g_iZRangeVarID, 256, actor, p);
OnEvent(EVENT_GETSHOTRANGE, p, ps[p].GetActor(), -1);
angRange = GetGameVarID(g_iAngRangeVarID, i, p);
zRange = GetGameVarID(g_iZRangeVarID, i, p);
angRange = GetGameVarID(g_iAngRangeVarID, actor, p);
zRange = GetGameVarID(g_iZRangeVarID, actor, p);
sa += (angRange / 2) - (krand() & (angRange - 1));
if (j == -1)
@ -878,11 +880,11 @@ static void shootlaser(int i, int p, int sx, int sy, int sz, int sa)
k = EGS(hitsect, hitx, hity, hitz, TRIPBOMB, -16, 4, 5, sa, 0, 0, i, 6);
if (isWW2GI())
{
int lTripBombControl = GetGameVar("TRIPBOMB_CONTROL", TRIPBOMB_TRIPWIRE, -1, -1);
int lTripBombControl = GetGameVar("TRIPBOMB_CONTROL", TRIPBOMB_TRIPWIRE, nullptr, -1);
if (lTripBombControl & TRIPBOMB_TIMER)
{
int lLifetime = GetGameVar("STICKYBOMB_LIFETIME", NAM_GRENADE_LIFETIME, -1, p);
int lLifetimeVar = GetGameVar("STICKYBOMB_LIFETIME_VAR", NAM_GRENADE_LIFETIME_VAR, -1, p);
int lLifetime = GetGameVar("STICKYBOMB_LIFETIME", NAM_GRENADE_LIFETIME, nullptr, p);
int lLifetimeVar = GetGameVar("STICKYBOMB_LIFETIME_VAR", NAM_GRENADE_LIFETIME_VAR, nullptr, p);
// set timer. blows up when at zero....
sprite[k].extra = lLifetime
+ mulscale(krand(), lLifetimeVar, 14)
@ -998,7 +1000,9 @@ void shoot_d(int i, int atwith)
{
short sect, l, j, k;
int sx, sy, sz, sa, p, vel, zvel, x, dal;
spritetype* const s = &sprite[i];
auto actor = &hittype[i];
spritetype* const s = &actor->s;
auto atact = &hittype[atwith];
if (s->picnum == TILE_APLAYER)
{
p = s->yvel;
@ -1008,10 +1012,10 @@ void shoot_d(int i, int atwith)
p = -1;
}
SetGameVarID(g_iAtWithVarID, 0, p, atwith);
SetGameVarID(g_iReturnVarID, 0, p, i);
SetGameVarID(g_iAtWithVarID, 0, atact, p);
SetGameVarID(g_iReturnVarID, 0, actor, p);
OnEvent(EVENT_SHOOT, p, ps[p].GetActor(), -1);
if (GetGameVarID(g_iReturnVarID, p, i) != 0)
if (GetGameVarID(g_iReturnVarID, actor, p) != 0)
{
return;
}
@ -1673,9 +1677,9 @@ static void operateJetpack(int snum, ESyncBits actions, int psectlotag, int fz,
if (actions & SB_JUMP) //A (soar high)
{
// jump
SetGameVarID(g_iReturnVarID, 0, pi, snum);
SetGameVarID(g_iReturnVarID, 0, p->GetActor(), snum);
OnEvent(EVENT_SOARUP, snum, p->GetActor(), -1);
if (GetGameVarID(g_iReturnVarID, pi, snum) == 0)
if (GetGameVarID(g_iReturnVarID, p->GetActor(), snum) == 0)
{
p->posz -= j;
p->crack_time = CRACK_TIME;
@ -1685,9 +1689,9 @@ static void operateJetpack(int snum, ESyncBits actions, int psectlotag, int fz,
if (actions & SB_CROUCH) //Z (soar low)
{
// crouch
SetGameVarID(g_iReturnVarID, 0, pi, snum);
SetGameVarID(g_iReturnVarID, 0, p->GetActor(), snum);
OnEvent(EVENT_SOARDOWN, snum, p->GetActor(), -1);
if (GetGameVarID(g_iReturnVarID, pi, snum) == 0)
if (GetGameVarID(g_iReturnVarID, p->GetActor(), snum) == 0)
{
p->posz += j;
p->crack_time = CRACK_TIME;
@ -2639,11 +2643,11 @@ static void processweapon(int snum, ESyncBits actions, int psect)
{
if (isWW2GI())
{
SetGameVarID(g_iReturnVarID, 0, pi, snum);
SetGameVarID(g_iWeaponVarID, p->curr_weapon, pi, snum);
SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike[p->curr_weapon][snum], pi, snum);
SetGameVarID(g_iReturnVarID, 0, p->GetActor(), snum);
SetGameVarID(g_iWeaponVarID, p->curr_weapon, p->GetActor(), snum);
SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike[p->curr_weapon][snum], p->GetActor(), snum);
OnEvent(EVENT_HOLSTER, snum, p->GetActor(), -1);
if (GetGameVarID(g_iReturnVarID, pi, snum) == 0)
if (GetGameVarID(g_iReturnVarID, p->GetActor(), snum) == 0)
{
// now it uses the game definitions...
if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_HOLSTER_CLEARS_CLIP)

View file

@ -840,9 +840,11 @@ void shoot_r(int i, int atwith)
{
short sect, sa, p, j;
int sx, sy, sz, vel, zvel, x;
spritetype* s;
s = &sprite[i];
auto actor = &hittype[i];
spritetype* const s = &actor->s;
auto atact = &hittype[atwith];
sect = s->sectnum;
zvel = 0;
@ -872,10 +874,10 @@ void shoot_r(int i, int atwith)
}
}
SetGameVarID(g_iAtWithVarID, 0, p, atwith);
SetGameVarID(g_iReturnVarID, 0, p, i);
OnEvent(EVENT_SHOOT, p, &hittype[i], -1);
if (GetGameVarID(g_iReturnVarID, p, i) != 0)
SetGameVarID(g_iAtWithVarID, 0, atact, p);
SetGameVarID(g_iReturnVarID, 0, actor, p);
OnEvent(EVENT_SHOOT, p, ps[p].GetActor(), -1);
if (GetGameVarID(g_iReturnVarID, actor, p) != 0)
{
return;
}

View file

@ -63,8 +63,8 @@ void DoFire(struct player_struct *p, short snum)
S_PlayActorSound(aplWeaponFireSound[p->curr_weapon][snum],p->i);
}
SetGameVarID(g_iWeaponVarID,p->curr_weapon,p->i,snum);
SetGameVarID(g_iWorksLikeVarID,aplWeaponWorksLike[p->curr_weapon][snum], p->i, snum);
SetGameVarID(g_iWeaponVarID, p->curr_weapon, p->GetActor(), snum);
SetGameVarID(g_iWorksLikeVarID,aplWeaponWorksLike[p->curr_weapon][snum], p->GetActor(), snum);
fi.shoot(p->i,aplWeaponShoots[p->curr_weapon][snum]);
for(i=1;i<aplWeaponShotsPerBurst[p->curr_weapon][snum];i++)
{
@ -158,11 +158,11 @@ void fireweapon_ww(int snum)
}
else
{
SetGameVarID(g_iReturnVarID, 0, pi, snum);
SetGameVarID(g_iWeaponVarID, p->curr_weapon, pi, snum);
SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike[p->curr_weapon][snum], pi, snum);
SetGameVarID(g_iReturnVarID, 0, p->GetActor(), snum);
SetGameVarID(g_iWeaponVarID, p->curr_weapon, p->GetActor(), snum);
SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike[p->curr_weapon][snum], p->GetActor(), snum);
OnEvent(EVENT_FIRE, snum, p->GetActor(), -1);
if (GetGameVarID(g_iReturnVarID, pi, snum) == 0)
if (GetGameVarID(g_iReturnVarID, p->GetActor(), snum) == 0)
{
switch (aplWeaponWorksLike[p->curr_weapon][snum])
{
@ -349,8 +349,8 @@ void operateweapon_ww(int snum, ESyncBits actions, int psect)
p->angle.ang.asbuild(), (k + (p->hbomb_hold_delay << 5)), i, pi, 1);
{
int lGrenadeLifetime = GetGameVar("GRENADE_LIFETIME", NAM_GRENADE_LIFETIME, -1, snum);
int lGrenadeLifetimeVar = GetGameVar("GRENADE_LIFETIME_VAR", NAM_GRENADE_LIFETIME_VAR, -1, snum);
int lGrenadeLifetime = GetGameVar("GRENADE_LIFETIME", NAM_GRENADE_LIFETIME, nullptr, snum);
int lGrenadeLifetimeVar = GetGameVar("GRENADE_LIFETIME_VAR", NAM_GRENADE_LIFETIME_VAR, nullptr, snum);
// set timer. blows up when at zero....
sprite[j].extra = lGrenadeLifetime
+ mulscale(krand(), lGrenadeLifetimeVar, 14)
@ -404,8 +404,8 @@ void operateweapon_ww(int snum, ESyncBits actions, int psect)
lastvisinc = ud.levelclock + 32;
p->visibility = 0;
}
SetGameVarID(g_iWeaponVarID, p->curr_weapon, p->i, snum);
SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike[p->curr_weapon][snum], p->i, snum);
SetGameVarID(g_iWeaponVarID, p->curr_weapon, p->GetActor(), snum);
SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike[p->curr_weapon][snum], p->GetActor(), snum);
fi.shoot(pi, aplWeaponShoots[p->curr_weapon][snum]);
}
}

View file

@ -104,7 +104,7 @@ public:
int GetMoraleOrShield(struct player_struct *p, int snum)
{
// special handling for WW2GI
int lAmount = GetGameVar("PLR_MORALE", -1, p->i, snum);
int lAmount = GetGameVar("PLR_MORALE", -1, p->GetActor(), snum);
if (lAmount == -1) lAmount = p->shield_amount;
return lAmount;
}