mirror of
https://github.com/DrBeef/Raze.git
synced 2025-03-30 20:51:22 +00:00
- use pointers for checkhitswitch and took separated clearcameras to a new functions to make this free of gotos.
This commit is contained in:
parent
9d8e7ea759
commit
e7369a2796
6 changed files with 72 additions and 65 deletions
|
@ -43,8 +43,8 @@ void operaterespawns_d(int low);
|
|||
void operaterespawns_r(int low);
|
||||
void operateforcefields_r(DDukeActor* act, int low);
|
||||
void operateforcefields_d(DDukeActor* act, int low);
|
||||
bool checkhitswitch_d(int snum, int w, DDukeActor *act);
|
||||
bool checkhitswitch_r(int snum, int w, DDukeActor* act);
|
||||
bool checkhitswitch_d(int snum, walltype* w, DDukeActor *act);
|
||||
bool checkhitswitch_r(int snum, walltype* w, DDukeActor* act);
|
||||
void activatebysector_d(int sect, DDukeActor* j);
|
||||
void activatebysector_r(int sect, DDukeActor* j);
|
||||
void checkhitwall_d(DDukeActor* spr, walltype* dawall, int x, int y, int z, int atwith);
|
||||
|
|
|
@ -82,7 +82,7 @@ struct Dispatcher
|
|||
void (*animatewalls)();
|
||||
void (*operaterespawns)(int low);
|
||||
void (*operateforcefields)(DDukeActor* act, int low);
|
||||
bool (*checkhitswitch)(int snum, int w, DDukeActor* act);
|
||||
bool (*checkhitswitch)(int snum, walltype* w, DDukeActor* act);
|
||||
void (*activatebysector)(int sect, DDukeActor* j);
|
||||
void (*checkhitwall)(DDukeActor* spr, walltype* dawall, int x, int y, int z, int atwith);
|
||||
bool (*checkhitceiling)(int sn);
|
||||
|
|
|
@ -278,7 +278,7 @@ static void shootknee(DDukeActor* actor, int p, int sx, int sy, int sz, int sa)
|
|||
if (hitsprt && hitsprt->s->picnum != ACCESSSWITCH && hitsprt->s->picnum != ACCESSSWITCH2)
|
||||
{
|
||||
fi.checkhitsprite(hitsprt, knee);
|
||||
if (p >= 0) fi.checkhitswitch(p, -1, hitsprt);
|
||||
if (p >= 0) fi.checkhitswitch(p, nullptr, hitsprt);
|
||||
}
|
||||
|
||||
else if (hitwallp)
|
||||
|
@ -292,7 +292,7 @@ static void shootknee(DDukeActor* actor, int p, int sx, int sy, int sz, int sa)
|
|||
if (wal->picnum != ACCESSSWITCH && wal->picnum != ACCESSSWITCH2)
|
||||
{
|
||||
fi.checkhitwall(knee, wal, hitx, hity, hitz, KNEE);
|
||||
if (p >= 0) fi.checkhitswitch(p, wallnum(wal), nullptr);
|
||||
if (p >= 0) fi.checkhitswitch(p, wal, nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -465,7 +465,7 @@ static void shootweapon(DDukeActor *actor, int p, int sx, int sy, int sz, int sa
|
|||
hitact->s->picnum == HANDSWITCH ||
|
||||
hitact->s->picnum == HANDSWITCH + 1))
|
||||
{
|
||||
fi.checkhitswitch(p, -1, hitact);
|
||||
fi.checkhitswitch(p, nullptr, hitact);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -486,7 +486,7 @@ static void shootweapon(DDukeActor *actor, int p, int sx, int sy, int sz, int sa
|
|||
wal->picnum == HANDSWITCH ||
|
||||
wal->picnum == HANDSWITCH + 1))
|
||||
{
|
||||
fi.checkhitswitch(p, wallnum(wal), nullptr);
|
||||
fi.checkhitswitch(p, wal, nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1547,7 +1547,7 @@ int doincrements_d(struct player_struct* p)
|
|||
{
|
||||
if (p->access_spritenum != nullptr)
|
||||
{
|
||||
fi.checkhitswitch(snum, -1, p->access_spritenum);
|
||||
fi.checkhitswitch(snum, nullptr, p->access_spritenum);
|
||||
switch (p->access_spritenum->s->pal)
|
||||
{
|
||||
case 0:p->got_access &= (0xffff - 0x1); break;
|
||||
|
@ -1558,7 +1558,7 @@ int doincrements_d(struct player_struct* p)
|
|||
}
|
||||
else
|
||||
{
|
||||
fi.checkhitswitch(snum, p->access_wallnum, nullptr);
|
||||
fi.checkhitswitch(snum, &wall[p->access_wallnum], nullptr);
|
||||
switch (wall[p->access_wallnum].pal)
|
||||
{
|
||||
case 0:p->got_access &= (0xffff - 0x1); break;
|
||||
|
|
|
@ -170,7 +170,7 @@ static void shootmelee(DDukeActor *actor, int p, int sx, int sy, int sz, int sa,
|
|||
if (hitsprt && hitsprt->s->picnum != ACCESSSWITCH && hitsprt->s->picnum != ACCESSSWITCH2)
|
||||
{
|
||||
fi.checkhitsprite(hitsprt, wpn);
|
||||
if (p >= 0) fi.checkhitswitch(p, -1, hitsprt);
|
||||
if (p >= 0) fi.checkhitswitch(p, nullptr, hitsprt);
|
||||
}
|
||||
else if (wal)
|
||||
{
|
||||
|
@ -182,7 +182,7 @@ static void shootmelee(DDukeActor *actor, int p, int sx, int sy, int sz, int sa,
|
|||
if (wal->picnum != ACCESSSWITCH && wal->picnum != ACCESSSWITCH2)
|
||||
{
|
||||
fi.checkhitwall(wpn, wal, hitx, hity, hitz, atwith);
|
||||
if (p >= 0) fi.checkhitswitch(p, wallnum(wal), nullptr);
|
||||
if (p >= 0) fi.checkhitswitch(p, wal, nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -359,7 +359,7 @@ static void shootweapon(DDukeActor* actor, int p, int sx, int sy, int sz, int sa
|
|||
hitsprt->s->picnum == HANDSWITCH ||
|
||||
hitsprt->s->picnum == HANDSWITCH + 1))
|
||||
{
|
||||
fi.checkhitswitch(p, -1, hitsprt);
|
||||
fi.checkhitswitch(p, nullptr, hitsprt);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -382,7 +382,7 @@ static void shootweapon(DDukeActor* actor, int p, int sx, int sy, int sz, int sa
|
|||
wal->picnum == HANDSWITCH ||
|
||||
wal->picnum == HANDSWITCH + 1))
|
||||
{
|
||||
fi.checkhitswitch(p, wallnum(wal), nullptr);
|
||||
fi.checkhitswitch(p, wal, nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1395,7 +1395,7 @@ int doincrements_r(struct player_struct* p)
|
|||
{
|
||||
if (p->access_spritenum != nullptr)
|
||||
{
|
||||
fi.checkhitswitch(snum, -1, p->access_spritenum);
|
||||
fi.checkhitswitch(snum, nullptr, p->access_spritenum);
|
||||
switch (p->access_spritenum->s->pal)
|
||||
{
|
||||
case 0:p->keys[1] = 1; break;
|
||||
|
@ -1406,7 +1406,7 @@ int doincrements_r(struct player_struct* p)
|
|||
}
|
||||
else
|
||||
{
|
||||
fi.checkhitswitch(snum, p->access_wallnum, nullptr);
|
||||
fi.checkhitswitch(snum, &wall[p->access_wallnum], nullptr);
|
||||
switch (wall[p->access_wallnum].pal)
|
||||
{
|
||||
case 0:p->keys[1] = 1; break;
|
||||
|
|
|
@ -222,14 +222,13 @@ void operateforcefields_d(DDukeActor* act, int low)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
bool checkhitswitch_d(int snum, int ww, DDukeActor *act)
|
||||
bool checkhitswitch_d(int snum, walltype* wwal, DDukeActor *act)
|
||||
{
|
||||
uint8_t switchpal;
|
||||
int lotag, hitag, picnum, correctdips, numdips;
|
||||
int sx, sy;
|
||||
walltype* wwal = nullptr;
|
||||
|
||||
if (ww < 0 && act == nullptr) return 0;
|
||||
if (wwal == nullptr && act == nullptr) return 0;
|
||||
correctdips = 1;
|
||||
numdips = 0;
|
||||
|
||||
|
@ -245,7 +244,6 @@ bool checkhitswitch_d(int snum, int ww, DDukeActor *act)
|
|||
}
|
||||
else
|
||||
{
|
||||
wwal = &wall[ww];
|
||||
lotag = wwal->lotag;
|
||||
if (lotag == 0) return 0;
|
||||
hitag = wwal->hitag;
|
||||
|
@ -308,7 +306,7 @@ bool checkhitswitch_d(int snum, int ww, DDukeActor *act)
|
|||
if (ps[snum].access_incs == 1)
|
||||
{
|
||||
if (!act)
|
||||
ps[snum].access_wallnum = ww;
|
||||
ps[snum].access_wallnum = wallnum(wwal);
|
||||
else
|
||||
ps[snum].access_spritenum = act;
|
||||
}
|
||||
|
@ -1486,6 +1484,33 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj)
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// taken out of checksectors to eliminate some gotos.
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void clearcameras(int i, player_struct* p)
|
||||
{
|
||||
if (i < 0)
|
||||
{
|
||||
p->pos.x = p->oposx;
|
||||
p->pos.y = p->oposy;
|
||||
p->pos.z = p->oposz;
|
||||
p->newOwner = nullptr;
|
||||
|
||||
updatesector(p->pos.x, p->pos.y, &p->cursectnum);
|
||||
|
||||
DukeStatIterator it(STAT_ACTOR);
|
||||
while (auto act = it.Next())
|
||||
{
|
||||
if (act->s->picnum == CAMERA1) act->s->yvel = 0;
|
||||
}
|
||||
}
|
||||
else if (p->newOwner != nullptr)
|
||||
p->newOwner = nullptr;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
|
@ -1498,9 +1523,9 @@ void checksectors_d(int snum)
|
|||
struct player_struct* p;
|
||||
int j;
|
||||
walltype* hitscanwall;
|
||||
int neartagsector, neartagwall;
|
||||
DDukeActor* neartagsprite;
|
||||
int neartaghitdist;
|
||||
int neartagsector = -1, neartagwall = -1;
|
||||
DDukeActor* neartagsprite = nullptr;
|
||||
int neartaghitdist = 0;
|
||||
|
||||
p = &ps[snum];
|
||||
auto pact = p->GetActor();
|
||||
|
@ -1545,8 +1570,8 @@ void checksectors_d(int snum)
|
|||
{
|
||||
if (abs(PlayerInputSideVel(snum)) > 768 || abs(PlayerInputForwardVel(snum)) > 768)
|
||||
{
|
||||
i = -1;
|
||||
goto CLEARCAMERAS;
|
||||
clearcameras(-1, p);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1560,8 +1585,7 @@ void checksectors_d(int snum)
|
|||
{
|
||||
if (p->newOwner != nullptr)
|
||||
{
|
||||
i = -1;
|
||||
goto CLEARCAMERAS;
|
||||
clearcameras(-1, p);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -1623,6 +1647,7 @@ void checksectors_d(int snum)
|
|||
neartagsector = -1;
|
||||
}
|
||||
}
|
||||
auto ntwall = neartagwall < 0? nullptr : &wall[neartagwall];
|
||||
|
||||
if (p->newOwner == nullptr && neartagsprite == nullptr && neartagsector == -1 && neartagwall == -1)
|
||||
if (isanunderoperator(p->GetActor()->getSector()->lotag))
|
||||
|
@ -1643,7 +1668,7 @@ void checksectors_d(int snum)
|
|||
|
||||
if (neartagsprite != nullptr)
|
||||
{
|
||||
if (fi.checkhitswitch(snum, -1, neartagsprite)) return;
|
||||
if (fi.checkhitswitch(snum, nullptr, neartagsprite)) return;
|
||||
|
||||
switch (neartagsprite->s->picnum)
|
||||
{
|
||||
|
@ -1735,32 +1760,17 @@ void checksectors_d(int snum)
|
|||
i = -1;
|
||||
}
|
||||
|
||||
CLEARCAMERAS:
|
||||
|
||||
if (i < 0)
|
||||
{
|
||||
p->pos.x = p->oposx;
|
||||
p->pos.y = p->oposy;
|
||||
p->pos.z = p->oposz;
|
||||
p->newOwner = nullptr;
|
||||
|
||||
updatesector(p->pos.x, p->pos.y, &p->cursectnum);
|
||||
|
||||
DukeStatIterator it(STAT_ACTOR);
|
||||
while (auto act = it.Next())
|
||||
{
|
||||
if (act->s->picnum == CAMERA1) act->s->yvel = 0;
|
||||
clearcameras(i, p);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (p->newOwner != nullptr)
|
||||
p->newOwner = nullptr;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!PlayerInput(snum, SB_OPEN)) return;
|
||||
else if (p->newOwner != nullptr) { i = -1; goto CLEARCAMERAS; }
|
||||
else if (p->newOwner != nullptr)
|
||||
{
|
||||
clearcameras(-1, p);
|
||||
return;
|
||||
}
|
||||
|
||||
if (neartagwall == -1 && neartagsector == -1 && neartagsprite == nullptr)
|
||||
if (abs(hits(p->GetActor())) < 512)
|
||||
|
@ -1773,17 +1783,16 @@ void checksectors_d(int snum)
|
|||
|
||||
if (neartagwall >= 0)
|
||||
{
|
||||
auto ntwall = &wall[neartagwall];
|
||||
if (ntwall->lotag > 0 && fi.isadoorwall(ntwall->picnum))
|
||||
{
|
||||
if (hitscanwall == ntwall || hitscanwall == nullptr)
|
||||
fi.checkhitswitch(snum, neartagwall, nullptr);
|
||||
fi.checkhitswitch(snum, ntwall, nullptr);
|
||||
return;
|
||||
}
|
||||
else if (p->newOwner != nullptr)
|
||||
{
|
||||
i = -1;
|
||||
goto CLEARCAMERAS;
|
||||
clearcameras(-1, p);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1808,7 +1817,7 @@ void checksectors_d(int snum)
|
|||
}
|
||||
operatesectors(p->GetActor()->s->sectnum, p->GetActor());
|
||||
}
|
||||
else fi.checkhitswitch(snum, neartagwall, nullptr);
|
||||
else fi.checkhitswitch(snum, ntwall, nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -344,14 +344,13 @@ void operateforcefields_r(DDukeActor* act, int low)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
bool checkhitswitch_r(int snum, int ww, DDukeActor* act)
|
||||
bool checkhitswitch_r(int snum, walltype* wwal, DDukeActor* act)
|
||||
{
|
||||
uint8_t switchpal;
|
||||
int lotag, hitag, picnum, correctdips, numdips;
|
||||
int sx, sy;
|
||||
walltype* wwal = nullptr;
|
||||
|
||||
if (ww < 0 && act == nullptr) return 0;
|
||||
if (wwal == nullptr && act == nullptr) return 0;
|
||||
correctdips = 1;
|
||||
numdips = 0;
|
||||
|
||||
|
@ -367,7 +366,6 @@ bool checkhitswitch_r(int snum, int ww, DDukeActor* act)
|
|||
}
|
||||
else
|
||||
{
|
||||
wwal = &wall[ww];
|
||||
lotag = wwal->lotag;
|
||||
if (lotag == 0) return 0;
|
||||
hitag = wwal->hitag;
|
||||
|
@ -426,7 +424,7 @@ bool checkhitswitch_r(int snum, int ww, DDukeActor* act)
|
|||
if (ps[snum].access_incs == 1)
|
||||
{
|
||||
if (!act)
|
||||
ps[snum].access_wallnum = ww;
|
||||
ps[snum].access_wallnum = wallnum(wwal);
|
||||
else
|
||||
ps[snum].access_spritenum = act;
|
||||
}
|
||||
|
@ -816,7 +814,7 @@ bool checkhitswitch_r(int snum, int ww, DDukeActor* act)
|
|||
switches[j]->s->picnum = MULTISWITCH2 + 3;
|
||||
else
|
||||
switches[j]->s->picnum = MULTISWITCH + 3;
|
||||
checkhitswitch_r(snum, -1, switches[j]);
|
||||
checkhitswitch_r(snum, nullptr, switches[j]);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
|
@ -2601,6 +2599,7 @@ void checksectors_r(int snum)
|
|||
neartagsector = -1;
|
||||
}
|
||||
}
|
||||
auto ntwall = neartagwall < 0? nullptr : &wall[neartagwall];
|
||||
|
||||
if (p->newOwner == nullptr && neartagsprite == nullptr && neartagsector == -1 && neartagwall == -1)
|
||||
if (isanunderoperator(p->GetActor()->getSector()->lotag))
|
||||
|
@ -2620,7 +2619,7 @@ void checksectors_r(int snum)
|
|||
|
||||
if (neartagsprite != nullptr)
|
||||
{
|
||||
if (fi.checkhitswitch(snum, -1,neartagsprite)) return;
|
||||
if (fi.checkhitswitch(snum, nullptr, neartagsprite)) return;
|
||||
|
||||
switch (neartagsprite->s->picnum)
|
||||
{
|
||||
|
@ -2735,11 +2734,10 @@ void checksectors_r(int snum)
|
|||
|
||||
if (neartagwall >= 0)
|
||||
{
|
||||
auto ntwall = &wall[neartagwall];
|
||||
if (ntwall->lotag > 0 && fi.isadoorwall(ntwall->picnum))
|
||||
{
|
||||
if (hitscanwall == ntwall || hitscanwall == nullptr)
|
||||
fi.checkhitswitch(snum, neartagwall, nullptr);
|
||||
fi.checkhitswitch(snum, ntwall, nullptr);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -2784,7 +2782,7 @@ void checksectors_r(int snum)
|
|||
FTA(41, p);
|
||||
}
|
||||
}
|
||||
else fi.checkhitswitch(snum, neartagwall, nullptr);
|
||||
else fi.checkhitswitch(snum, ntwall, nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue