mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-23 04:22:16 +00:00
- Duke: Clean up actor accesses in premap.cpp
.
This commit is contained in:
parent
89708731a3
commit
a2c8066f78
4 changed files with 43 additions and 50 deletions
|
@ -202,11 +202,11 @@ void initshell(DDukeActor* actj, DDukeActor* acti, bool isshell);
|
||||||
void spawneffector(DDukeActor* actor, TArray<DDukeActor*>* actors);
|
void spawneffector(DDukeActor* actor, TArray<DDukeActor*>* actors);
|
||||||
int startrts(int lumpNum, int localPlayer);
|
int startrts(int lumpNum, int localPlayer);
|
||||||
|
|
||||||
void pickrandomspot(int pn);
|
void pickrandomspot(DDukePlayer* const p);
|
||||||
void premapcontroller(DDukeActor* ac);
|
void premapcontroller(DDukeActor* ac);
|
||||||
void resetinventory(DDukePlayer* pn);
|
void resetinventory(DDukePlayer* pn);
|
||||||
void resetweapons(DDukePlayer* pn);
|
void resetweapons(DDukePlayer* pn);
|
||||||
void resetprestat(int snum, int g);
|
void resetprestat(DDukePlayer* const p, int g);
|
||||||
void prelevel_common(int g);
|
void prelevel_common(int g);
|
||||||
void cacheit();
|
void cacheit();
|
||||||
|
|
||||||
|
|
|
@ -1501,7 +1501,7 @@ void playerreset(DDukePlayer* p, DDukeActor* g_ac)
|
||||||
{
|
{
|
||||||
// I am not convinced this is even remotely smart to be executed from here..
|
// I am not convinced this is even remotely smart to be executed from here..
|
||||||
const auto pact = p->GetActor();
|
const auto pact = p->GetActor();
|
||||||
pickrandomspot(p->pnum);
|
pickrandomspot(p);
|
||||||
g_ac->spr.pos = pact->getPosWithOffsetZ();
|
g_ac->spr.pos = pact->getPosWithOffsetZ();
|
||||||
pact->backuppos();
|
pact->backuppos();
|
||||||
p->setbobpos();
|
p->setbobpos();
|
||||||
|
|
|
@ -51,16 +51,18 @@ short myangbak[MOVEFIFOSIZ];
|
||||||
|
|
||||||
void resetmys()
|
void resetmys()
|
||||||
{
|
{
|
||||||
mypos = omypos = getPlayer(myconnectindex)->GetActor()->getPosWithOffsetZ();
|
const auto p = getPlayer(myconnectindex);
|
||||||
|
const auto pact = p->GetActor();
|
||||||
|
mypos = omypos = pact->getPosWithOffsetZ();
|
||||||
myxvel = myyvel = myzvel = 0;
|
myxvel = myyvel = myzvel = 0;
|
||||||
myang = getPlayer(myconnectindex)->GetActor()->spr.Angles.Yaw;
|
myang = pact->spr.Angles.Yaw;
|
||||||
myhoriz = omyhoriz = getPlayer(myconnectindex)->GetActor()->spr.Angles.Pitch;
|
myhoriz = omyhoriz = pact->spr.Angles.Pitch;
|
||||||
myhorizoff = omyhorizoff = getPlayer(myconnectindex)->Angles.ViewAngles.Pitch;
|
myhorizoff = omyhorizoff = p->Angles.ViewAngles.Pitch;
|
||||||
mycursectnum = sectindex(getPlayer(myconnectindex)->cursector);
|
mycursectnum = sectindex(p->cursector);
|
||||||
myjumpingcounter = getPlayer(myconnectindex)->jumping_counter;
|
myjumpingcounter = p->jumping_counter;
|
||||||
myjumpingtoggle = getPlayer(myconnectindex)->jumping_toggle;
|
myjumpingtoggle = p->jumping_toggle;
|
||||||
myonground = getPlayer(myconnectindex)->on_ground;
|
myonground = p->on_ground;
|
||||||
myhardlanding = getPlayer(myconnectindex)->hard_landing;
|
myhardlanding = p->hard_landing;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0 // todo: fix this when networking works again
|
#if 0 // todo: fix this when networking works again
|
||||||
|
|
|
@ -58,21 +58,15 @@ void premapcontroller(DDukeActor* ac)
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
void pickrandomspot(int snum)
|
void pickrandomspot(DDukePlayer* const p)
|
||||||
{
|
{
|
||||||
DDukePlayer* p;
|
const auto pact = p->GetActor();
|
||||||
int i;
|
const int i = (ud.multimode > 1 && ud.coop != 1) ? (krand() % numplayersprites) : p->pnum;
|
||||||
|
|
||||||
p = getPlayer(snum);
|
pact->spr.pos = po[i].opos;
|
||||||
|
pact->backuppos();
|
||||||
if( ud.multimode > 1 && ud.coop != 1)
|
|
||||||
i = krand()%numplayersprites;
|
|
||||||
else i = snum;
|
|
||||||
|
|
||||||
p->GetActor()->spr.pos = po[i].opos;
|
|
||||||
p->GetActor()->backuppos();
|
|
||||||
p->setbobpos();
|
p->setbobpos();
|
||||||
p->GetActor()->PrevAngles.Yaw = p->GetActor()->spr.Angles.Yaw = po[i].oa;
|
pact->PrevAngles.Yaw = pact->spr.Angles.Yaw = po[i].oa;
|
||||||
p->setCursector(po[i].os);
|
p->setCursector(po[i].os);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -369,12 +363,8 @@ void resetinventory(DDukePlayer* p)
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
void resetprestat(int snum,int g)
|
void resetprestat(DDukePlayer* const p, int g)
|
||||||
{
|
{
|
||||||
DDukePlayer* p;
|
|
||||||
|
|
||||||
p = getPlayer(snum);
|
|
||||||
|
|
||||||
spriteqloc = 0;
|
spriteqloc = 0;
|
||||||
for(auto& p : spriteq) p = nullptr;
|
for(auto& p : spriteq) p = nullptr;
|
||||||
|
|
||||||
|
@ -651,7 +641,8 @@ void prelevel_common(int g)
|
||||||
// RRRA E2L1 fog handling.
|
// RRRA E2L1 fog handling.
|
||||||
ud.fogactive = 0;
|
ud.fogactive = 0;
|
||||||
|
|
||||||
resetprestat(0, g);
|
const auto firstp = getPlayer(0);
|
||||||
|
resetprestat(firstp, g);
|
||||||
numclouds = 0;
|
numclouds = 0;
|
||||||
|
|
||||||
memset(geosectorwarp, -1, sizeof(geosectorwarp));
|
memset(geosectorwarp, -1, sizeof(geosectorwarp));
|
||||||
|
@ -676,8 +667,8 @@ void prelevel_common(int g)
|
||||||
if (tilesurface(sectp->ceilingtexture) == TSURF_SCROLLSKY && numclouds < 127)
|
if (tilesurface(sectp->ceilingtexture) == TSURF_SCROLLSKY && numclouds < 127)
|
||||||
clouds[numclouds++] = sectp;
|
clouds[numclouds++] = sectp;
|
||||||
|
|
||||||
if (getPlayer(0)->one_parallax_sectnum == nullptr)
|
if (firstp->one_parallax_sectnum == nullptr)
|
||||||
getPlayer(0)->one_parallax_sectnum = sectp;
|
firstp->one_parallax_sectnum = sectp;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sectp->lotag == 32767) //Found a secret room
|
if (sectp->lotag == 32767) //Found a secret room
|
||||||
|
@ -688,7 +679,7 @@ void prelevel_common(int g)
|
||||||
|
|
||||||
if (sectp->lotag == -1)
|
if (sectp->lotag == -1)
|
||||||
{
|
{
|
||||||
getPlayer(0)->Exit = sectp->walls[0].pos;
|
firstp->Exit = sectp->walls[0].pos;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1117,8 +1108,9 @@ static void clearfrags(void)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < ud.multimode; i++)
|
for (int i = 0; i < ud.multimode; i++)
|
||||||
{
|
{
|
||||||
getPlayer(i)->frag = getPlayer(i)->fraggedself = 0;
|
const auto p = getPlayer(i);
|
||||||
memset(getPlayer(i)->frags, 0, sizeof(getPlayer(i)->frags));
|
p->frag = p->fraggedself = 0;
|
||||||
|
memset(p->frags, 0, sizeof(p->frags));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1147,9 +1139,7 @@ void enterlevel(MapRecord *mi, int gamemode)
|
||||||
FX_StopAllSounds();
|
FX_StopAllSounds();
|
||||||
S_SetReverb(0);
|
S_SetReverb(0);
|
||||||
|
|
||||||
auto p = getPlayer(0);
|
LoadTheMap(mi, getPlayer(0), gamemode);
|
||||||
|
|
||||||
LoadTheMap(mi, p, gamemode);
|
|
||||||
|
|
||||||
// Try this first so that it can disable the CD player if no tracks are found.
|
// Try this first so that it can disable the CD player if no tracks are found.
|
||||||
if (isRR())
|
if (isRR())
|
||||||
|
@ -1162,23 +1152,23 @@ void enterlevel(MapRecord *mi, int gamemode)
|
||||||
|
|
||||||
for (int i = connecthead; i >= 0; i = connectpoint2[i])
|
for (int i = connecthead; i >= 0; i = connectpoint2[i])
|
||||||
{
|
{
|
||||||
|
const auto p = getPlayer(i);
|
||||||
bool clearweapon = !!(currentLevel->flags & LEVEL_CLEARWEAPONS);
|
bool clearweapon = !!(currentLevel->flags & LEVEL_CLEARWEAPONS);
|
||||||
auto pn = getPlayer(i)->GetActor()->sector()->floortexture;
|
if (tileflags(p->GetActor()->sector()->floortexture) & TFLAG_CLEARINVENTORY)
|
||||||
if (tileflags(pn) & TFLAG_CLEARINVENTORY)
|
|
||||||
{
|
{
|
||||||
resetinventory(getPlayer(i));
|
resetinventory(p);
|
||||||
clearweapon = true;
|
clearweapon = true;
|
||||||
}
|
}
|
||||||
if (clearweapon)
|
if (clearweapon)
|
||||||
{
|
{
|
||||||
resetweapons(getPlayer(i));
|
resetweapons(p);
|
||||||
getPlayer(i)->gotweapon[PISTOL_WEAPON] = false;
|
p->gotweapon[PISTOL_WEAPON] = false;
|
||||||
getPlayer(i)->ammo_amount[PISTOL_WEAPON] = 0;
|
p->ammo_amount[PISTOL_WEAPON] = 0;
|
||||||
getPlayer(i)->curr_weapon = KNEE_WEAPON;
|
p->curr_weapon = KNEE_WEAPON;
|
||||||
getPlayer(i)->kickback_pic = 0;
|
p->kickback_pic = 0;
|
||||||
getPlayer(i)->okickback_pic = getPlayer(i)->kickback_pic = 0;
|
p->okickback_pic = p->kickback_pic = 0;
|
||||||
}
|
}
|
||||||
if (currentLevel->flags & LEVEL_CLEARINVENTORY) resetinventory(getPlayer(i));
|
if (currentLevel->flags & LEVEL_CLEARINVENTORY) resetinventory(p);
|
||||||
}
|
}
|
||||||
resetmys();
|
resetmys();
|
||||||
|
|
||||||
|
@ -1206,8 +1196,9 @@ void GameInterface::NewGame(MapRecord* map, int skill, bool)
|
||||||
{
|
{
|
||||||
for (int i = 0; i != -1; i = connectpoint2[i])
|
for (int i = 0; i != -1; i = connectpoint2[i])
|
||||||
{
|
{
|
||||||
resetweapons(getPlayer(i));
|
const auto p = getPlayer(i);
|
||||||
resetinventory(getPlayer(i));
|
resetweapons(p);
|
||||||
|
resetinventory(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
getPlayer(0)->last_extra = gs.max_player_health;
|
getPlayer(0)->last_extra = gs.max_player_health;
|
||||||
|
|
Loading…
Reference in a new issue