mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 00:42:08 +00:00
- Duke: Initial setup to convert PlayerArray
array to array of DukePlayer
pointers.
This commit is contained in:
parent
0aac044da6
commit
6d2124dd01
13 changed files with 41 additions and 33 deletions
|
@ -273,7 +273,7 @@ void checkavailweapon(DukePlayer* player)
|
|||
weap = player->curr_weapon;
|
||||
if (player->gotweapon[weap])
|
||||
{
|
||||
if (player->ammo_amount[weap] > 0 || (WeaponSwitch(player - PlayerArray) & 2) == 0)
|
||||
if (player->ammo_amount[weap] > 0 || (WeaponSwitch(player - *PlayerArray) & 2) == 0)
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
BEGIN_DUKE_NS
|
||||
|
||||
extern DukePlayer PlayerArray[MAXPLAYERS];
|
||||
extern DukePlayer* PlayerArray[MAXPLAYERS];
|
||||
|
||||
struct GameInterface : public ::GameInterface
|
||||
{
|
||||
|
@ -39,7 +39,7 @@ struct GameInterface : public ::GameInterface
|
|||
void SerializeGameState(FSerializer& arc) override;
|
||||
void ExitFromMenu() override;
|
||||
void DrawPlayerSprite(const DVector2& origin, bool onteam) override;
|
||||
void reapplyInputBits(InputPacket* const input) override { input->actions |= PlayerArray[myconnectindex].input.actions & SB_CENTERVIEW; }
|
||||
void reapplyInputBits(InputPacket* const input) override { input->actions |= PlayerArray[myconnectindex]->input.actions & SB_CENTERVIEW; }
|
||||
void doPlayerMovement(const float scaleAdjust) override;
|
||||
unsigned getCrouchState() override;
|
||||
void UpdateSounds() override;
|
||||
|
@ -53,7 +53,7 @@ struct GameInterface : public ::GameInterface
|
|||
void NewGame(MapRecord* map, int skill, bool) override;
|
||||
void LevelCompleted(MapRecord* map, int skill) override;
|
||||
bool DrawAutomapPlayer(const DVector2& mxy, const DVector2& cpos, const DAngle cang, const DVector2& xydim, const double czoom, double const interpfrac) override;
|
||||
DCoreActor* getConsoleActor() override { return PlayerArray[myconnectindex].GetActor(); }
|
||||
DCoreActor* getConsoleActor() override { return PlayerArray[myconnectindex]->GetActor(); }
|
||||
void ToggleThirdPerson() override;
|
||||
void SwitchCoopView() override;
|
||||
void ToggleShowWeapon() override;
|
||||
|
|
|
@ -83,18 +83,18 @@ static void markgcroots()
|
|||
GC::MarkArray(spriteq, 1024);
|
||||
GC::Mark(currentCommentarySprite);
|
||||
GC::Mark(ud.cameraactor);
|
||||
for (auto& pl : PlayerArray)
|
||||
for (auto pl : PlayerArray)
|
||||
{
|
||||
GC::Mark(pl.actor);
|
||||
GC::Mark(pl.actorsqu);
|
||||
GC::Mark(pl.wackedbyactor);
|
||||
GC::Mark(pl.on_crane);
|
||||
GC::Mark(pl.holoduke_on);
|
||||
GC::Mark(pl.somethingonplayer);
|
||||
GC::Mark(pl.access_spritenum);
|
||||
GC::Mark(pl.dummyplayersprite);
|
||||
GC::Mark(pl.newOwner);
|
||||
for (auto& var : pl.uservars)
|
||||
GC::Mark(pl->actor);
|
||||
GC::Mark(pl->actorsqu);
|
||||
GC::Mark(pl->wackedbyactor);
|
||||
GC::Mark(pl->on_crane);
|
||||
GC::Mark(pl->holoduke_on);
|
||||
GC::Mark(pl->somethingonplayer);
|
||||
GC::Mark(pl->access_spritenum);
|
||||
GC::Mark(pl->dummyplayersprite);
|
||||
GC::Mark(pl->newOwner);
|
||||
for (auto& var : pl->uservars)
|
||||
{
|
||||
var.Mark();
|
||||
}
|
||||
|
@ -386,6 +386,13 @@ void initactorflags()
|
|||
|
||||
void GameInterface::app_init()
|
||||
{
|
||||
// Initialise player array.
|
||||
for (unsigned i = 0; i < MAXPLAYERS; i++)
|
||||
{
|
||||
PlayerArray[i] = new DukePlayer;
|
||||
*PlayerArray[i] = {};
|
||||
}
|
||||
|
||||
RegisterClasses();
|
||||
GC::AddMarkerFunc(markgcroots);
|
||||
|
||||
|
|
|
@ -268,9 +268,9 @@ void ResetGameVars(void)
|
|||
{
|
||||
if (aGameVars[i].dwFlags & (GAMEVAR_FLAG_PERPLAYER))
|
||||
{
|
||||
for (auto &pl : PlayerArray)
|
||||
for (auto pl : PlayerArray)
|
||||
{
|
||||
pl.uservars[aGameVars[i].indexValue] = aGameVars[i].defaultValue;
|
||||
pl->uservars[aGameVars[i].indexValue] = aGameVars[i].defaultValue;
|
||||
}
|
||||
}
|
||||
else if (!(aGameVars[i].dwFlags & GAMEVAR_FLAG_PERACTOR))
|
||||
|
@ -1222,7 +1222,7 @@ void FinalizeGameVars(void)
|
|||
aGameVars[i].indexValue = actorNdx++;
|
||||
}
|
||||
}
|
||||
for (auto& pl : PlayerArray) pl.uservars.Resize(weapNdx);
|
||||
for (auto pl : PlayerArray) pl->uservars.Resize(weapNdx);
|
||||
ResetGameVars();
|
||||
|
||||
numActorVars = actorNdx;
|
||||
|
|
|
@ -46,7 +46,7 @@ DukeGameInfo gs;
|
|||
int screenpeek;
|
||||
|
||||
// serialized
|
||||
DukePlayer PlayerArray[MAXPLAYERS];
|
||||
DukePlayer* PlayerArray[MAXPLAYERS];
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
|
|
|
@ -70,7 +70,7 @@ extern int screenpeek;
|
|||
// Variables that must be saved
|
||||
extern int rtsplaying;
|
||||
|
||||
extern DukePlayer PlayerArray[MAXPLAYERS];
|
||||
extern DukePlayer* PlayerArray[MAXPLAYERS];
|
||||
extern int spriteqamount;
|
||||
extern int lastvisinc;
|
||||
extern animwalltype animwall[MAXANIMWALLS];
|
||||
|
|
|
@ -12,7 +12,7 @@ BEGIN_DUKE_NS
|
|||
|
||||
inline DukePlayer* getPlayer(int index)
|
||||
{
|
||||
return &PlayerArray[index];
|
||||
return PlayerArray[index];
|
||||
}
|
||||
|
||||
inline int rnd(int X)
|
||||
|
|
|
@ -1229,21 +1229,21 @@ int playeraddammo(DukePlayer* p, int weaponindex, int amount)
|
|||
}
|
||||
addammo(weaponindex, p, amount);
|
||||
if (p->curr_weapon == KNEE_WEAPON)
|
||||
if (p->gotweapon[weaponindex] && (WeaponSwitch(p - PlayerArray) & 1))
|
||||
if (p->gotweapon[weaponindex] && (WeaponSwitch(p - *PlayerArray) & 1))
|
||||
fi.addweapon(p, weaponindex, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
int playeraddweapon(DukePlayer* p, int weaponindex, int amount)
|
||||
{
|
||||
if (p->gotweapon[weaponindex] == 0) fi.addweapon(p, weaponindex, !!(WeaponSwitch(p- PlayerArray) & 1));
|
||||
if (p->gotweapon[weaponindex] == 0) fi.addweapon(p, weaponindex, !!(WeaponSwitch(p - *PlayerArray) & 1));
|
||||
else if (p->ammo_amount[weaponindex] >= gs.max_ammo_amount[weaponindex])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
addammo(weaponindex, p, amount);
|
||||
if (p->curr_weapon == KNEE_WEAPON)
|
||||
if (p->gotweapon[weaponindex] && (WeaponSwitch(p - PlayerArray) & 1))
|
||||
if (p->gotweapon[weaponindex] && (WeaponSwitch(p - *PlayerArray) & 1))
|
||||
fi.addweapon(p, weaponindex, true);
|
||||
|
||||
return true;
|
||||
|
@ -1327,7 +1327,7 @@ int checkp(DDukeActor* self, DukePlayer* p, int flags)
|
|||
bool j = 0;
|
||||
|
||||
double vel = self->vel.X;
|
||||
unsigned plindex = unsigned(p - PlayerArray);
|
||||
unsigned plindex = unsigned(p - *PlayerArray);
|
||||
|
||||
// sigh.. this was yet another place where number literals were used as bit masks for every single value, making the code totally unreadable.
|
||||
if ((flags & pducking) && p->on_ground && PlayerInput(plindex, SB_CROUCH))
|
||||
|
@ -1484,7 +1484,7 @@ void playerreset(DukePlayer* p, DDukeActor* g_ac)
|
|||
else
|
||||
{
|
||||
// I am not convinced this is even remotely smart to be executed from here..
|
||||
pickrandomspot(int(p - PlayerArray));
|
||||
pickrandomspot(int(p - *PlayerArray));
|
||||
g_ac->spr.pos = p->GetActor()->getPosWithOffsetZ();
|
||||
p->GetActor()->backuppos();
|
||||
p->setbobpos();
|
||||
|
@ -1504,7 +1504,7 @@ void playerreset(DukePlayer* p, DDukeActor* g_ac)
|
|||
p->wantweaponfire = -1;
|
||||
p->GetActor()->PrevAngles.Pitch = p->GetActor()->spr.Angles.Pitch = nullAngle;
|
||||
p->on_crane = nullptr;
|
||||
p->frag_ps = int(p - PlayerArray);
|
||||
p->frag_ps = int(p - *PlayerArray);
|
||||
p->Angles.PrevViewAngles.Pitch = p->Angles.ViewAngles.Pitch = nullAngle;
|
||||
p->opyoff = 0;
|
||||
p->wackedbyactor = nullptr;
|
||||
|
|
|
@ -1952,7 +1952,7 @@ HORIZONLY:
|
|||
if (p->show_empty_weapon > 0)
|
||||
{
|
||||
p->show_empty_weapon--;
|
||||
if (p->show_empty_weapon == 0 && (WeaponSwitch(p - PlayerArray) & 2))
|
||||
if (p->show_empty_weapon == 0 && (WeaponSwitch(p - *PlayerArray) & 2))
|
||||
{
|
||||
if (p->last_full_weapon == GROW_WEAPON)
|
||||
p->subweapon |= (1 << GROW_WEAPON);
|
||||
|
|
|
@ -2910,7 +2910,7 @@ HORIZONLY:
|
|||
{
|
||||
p->show_empty_weapon--;
|
||||
|
||||
if (p->show_empty_weapon == 0 && (WeaponSwitch(p - PlayerArray) & 2))
|
||||
if (p->show_empty_weapon == 0 && (WeaponSwitch(p - *PlayerArray) & 2))
|
||||
{
|
||||
fi.addweapon(p, p->last_full_weapon, true);
|
||||
return;
|
||||
|
|
|
@ -293,7 +293,7 @@ void resetweapons(DukePlayer* p)
|
|||
p->gotweapon[SLINGBLADE_WEAPON] = true;
|
||||
p->ammo_amount[SLINGBLADE_WEAPON] = 1;
|
||||
}
|
||||
OnEvent(EVENT_RESETWEAPONS, int(p - PlayerArray), nullptr, -1);
|
||||
OnEvent(EVENT_RESETWEAPONS, int(p - *PlayerArray), nullptr, -1);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -362,7 +362,7 @@ void resetinventory(DukePlayer* p)
|
|||
ufocnt = 0;
|
||||
hulkspawn = 2;
|
||||
}
|
||||
OnEvent(EVENT_RESETINVENTORY, int(p - PlayerArray), p->GetActor());
|
||||
OnEvent(EVENT_RESETINVENTORY, int(p - *PlayerArray), p->GetActor());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -415,7 +415,8 @@ void GameInterface::SerializeGameState(FSerializer& arc)
|
|||
("rtsplaying", rtsplaying)
|
||||
//("tempwallptr", tempwallptr)
|
||||
("joe9000", ud.joe9000)
|
||||
.Array("players", PlayerArray, ud.multimode)
|
||||
#pragma message("Duke: Fix saving!")
|
||||
//.Array("players", PlayerArray, ud.multimode)
|
||||
("spriteqamount", spriteqamount)
|
||||
("lastvisinc", lastvisinc)
|
||||
("numanimwalls", numanimwalls)
|
||||
|
|
|
@ -179,7 +179,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Duke, StopCommentary, StopCommentary)
|
|||
int getPlayerIndex(DukePlayer* p)
|
||||
{
|
||||
if (!p) return -1;
|
||||
return int(p - PlayerArray);
|
||||
return int(p - *PlayerArray);
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(_Duke, getPlayerIndex, getPlayerIndex)
|
||||
|
|
Loading…
Reference in a new issue