mirror of
https://github.com/ZDoom/Raze.git
synced 2025-04-04 23:12:15 +00:00
- Duke: Manual sweep for last replacements of player index for pointer.
This commit is contained in:
parent
0615eba516
commit
66a77ea860
10 changed files with 43 additions and 51 deletions
|
@ -50,18 +50,17 @@ This file is a combination of code from the following sources:
|
|||
BEGIN_DUKE_NS
|
||||
|
||||
|
||||
void moveactor(DDukeActor* actor, int p, double pdist, const int killit_flag)
|
||||
static void moveactor(DDukeActor* actor, DDukePlayer* const pp, double pdist, const int killit_flag)
|
||||
{
|
||||
if (killit_flag == 1)
|
||||
{
|
||||
// if player was set to squish, first stop that..
|
||||
const auto pp = getPlayer(p);
|
||||
if (pp->actorsqu == actor) pp->actorsqu = nullptr;
|
||||
actor->flags2 |= SFLAG2_DIENOW;
|
||||
}
|
||||
else
|
||||
{
|
||||
move(actor, p, pdist);
|
||||
move(actor, pp, pdist);
|
||||
|
||||
if (actor->spr.statnum == STAT_ACTOR)
|
||||
{
|
||||
|
@ -95,22 +94,23 @@ void TickActor(DDukeActor* self)
|
|||
if (self->spr.statnum == STAT_ACTOR || self->spr.statnum == STAT_PLAYER || (self->flags3 & SFLAG3_FORCERUNCON))
|
||||
{
|
||||
double pdist;
|
||||
int p;
|
||||
int pnum;
|
||||
|
||||
if (self->spr.statnum != STAT_PLAYER)
|
||||
{
|
||||
p = findplayer(self, &pdist);
|
||||
pnum = findplayer(self, &pdist);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ud.multimode > 1)
|
||||
p = findotherplayer(self->PlayerIndex(), &pdist);
|
||||
pnum = findotherplayer(self->PlayerIndex(), &pdist);
|
||||
else
|
||||
{
|
||||
p = self->PlayerIndex();
|
||||
pnum = self->PlayerIndex();
|
||||
pdist = 0;
|
||||
}
|
||||
}
|
||||
const auto p = getPlayer(pnum);
|
||||
|
||||
// Run sprite animations.
|
||||
if (self->curAction->name != NAME_None)
|
||||
|
@ -138,7 +138,7 @@ void TickActor(DDukeActor* self)
|
|||
self->flags4 |= SFLAG4_INRUNSTATE;
|
||||
IFVIRTUALPTR(self, DDukeActor, RunState)
|
||||
{
|
||||
VMValue val[] = { self, getPlayer(p), pdist};
|
||||
VMValue val[] = { self, p, pdist};
|
||||
try
|
||||
{
|
||||
VMCall(func, val, 3, nullptr, 0);
|
||||
|
@ -254,7 +254,7 @@ void checkavailinven(DDukePlayer* player)
|
|||
|
||||
void checkavailweapon(DDukePlayer* player)
|
||||
{
|
||||
int i, snum;
|
||||
int i;
|
||||
int weap;
|
||||
|
||||
if (player->wantweaponfire >= 0)
|
||||
|
@ -269,20 +269,18 @@ void checkavailweapon(DDukePlayer* player)
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
weap = player->curr_weapon;
|
||||
|
||||
if (player->gotweapon[weap])
|
||||
{
|
||||
if (player->ammo_amount[weap] > 0 || (WeaponSwitch(player->pnum) & 2) == 0)
|
||||
return;
|
||||
}
|
||||
|
||||
snum = player->GetPlayerNum();
|
||||
|
||||
int max = MAX_WEAPON;
|
||||
for (i = 0; i <= max; i++)
|
||||
{
|
||||
weap = ud.wchoice[snum][i];
|
||||
weap = ud.wchoice[player->pnum][i];
|
||||
if ((g_gameType & GAMEFLAG_SHAREWARE) && weap > 6) continue;
|
||||
|
||||
if (weap == 0) weap = max;
|
||||
|
@ -302,17 +300,17 @@ void checkavailweapon(DDukePlayer* player)
|
|||
if (isWW2GI())
|
||||
{
|
||||
const auto pact = player->GetActor();
|
||||
SetGameVarID(g_iWeaponVarID, player->curr_weapon, pact, snum); // snum is player index!
|
||||
SetGameVarID(g_iWeaponVarID, player->curr_weapon, pact, player->pnum); // snum is player index!
|
||||
|
||||
if (player->curr_weapon >= 0)
|
||||
{
|
||||
SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike(player->curr_weapon, player), pact, snum);
|
||||
SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike(player->curr_weapon, player), pact, player->pnum);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetGameVarID(g_iWorksLikeVarID, -1, pact, snum);
|
||||
SetGameVarID(g_iWorksLikeVarID, -1, pact, player->pnum);
|
||||
}
|
||||
OnEvent(EVENT_CHANGEWEAPON, snum, pact, -1);
|
||||
OnEvent(EVENT_CHANGEWEAPON, player->pnum, pact, -1);
|
||||
}
|
||||
|
||||
player->okickback_pic = player->kickback_pic = 0;
|
||||
|
@ -1286,7 +1284,7 @@ int movesprite_ex(DDukeActor* actor, const DVector3& change, unsigned int clipty
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void move(DDukeActor* actor, int pnum, double pdist)
|
||||
void move(DDukeActor* actor, DDukePlayer* const p, double pdist)
|
||||
{
|
||||
DAngle goalang, angdif;
|
||||
double daxvel;
|
||||
|
@ -1297,7 +1295,6 @@ void move(DDukeActor* actor, int pnum, double pdist)
|
|||
|
||||
actor->counter++;
|
||||
|
||||
const auto p = getPlayer(pnum);
|
||||
const auto pact = p->GetActor();
|
||||
|
||||
if (a & face_player)
|
||||
|
|
|
@ -103,7 +103,7 @@ void addweapon_d(DDukePlayer *p, int weapon, bool wswitch)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
int ifsquished(DDukeActor* actor, int p)
|
||||
int ifsquished(DDukeActor* actor, DDukePlayer* const p)
|
||||
{
|
||||
if (isRR()) return false; // this function is a no-op in RR's source.
|
||||
|
||||
|
@ -124,7 +124,7 @@ int ifsquished(DDukeActor* actor, int p)
|
|||
|
||||
if (squishme)
|
||||
{
|
||||
FTA(QUOTE_SQUISHED, getPlayer(p));
|
||||
FTA(QUOTE_SQUISHED, p);
|
||||
|
||||
if (badguy(actor))
|
||||
actor->vel.X = 0;
|
||||
|
@ -382,7 +382,7 @@ void movetransports_d(void)
|
|||
// if( onfloorz && sectlotag == 1 && ps[p].pos.z > (sectp->floorz-(6<<8)) )
|
||||
{
|
||||
k = 1;
|
||||
if (getPlayer(screenpeek) == p)
|
||||
if (screenpeek == p->pnum)
|
||||
{
|
||||
FX_StopAllSounds();
|
||||
}
|
||||
|
@ -401,7 +401,7 @@ void movetransports_d(void)
|
|||
{
|
||||
k = 1;
|
||||
// if( act2->spr.extra <= 0) break;
|
||||
if (getPlayer(screenpeek) == p)
|
||||
if (screenpeek == p->pnum)
|
||||
{
|
||||
FX_StopAllSounds();
|
||||
}
|
||||
|
|
|
@ -351,7 +351,7 @@ void movetransports_r(void)
|
|||
{
|
||||
if (p->OnBoat) break;
|
||||
k = 1;
|
||||
if (getPlayer(screenpeek) == p)
|
||||
if (screenpeek == p->pnum)
|
||||
{
|
||||
FX_StopAllSounds();
|
||||
}
|
||||
|
@ -366,7 +366,7 @@ void movetransports_r(void)
|
|||
{
|
||||
k = 1;
|
||||
if (act2->spr.extra <= 0) break;
|
||||
if (getPlayer(screenpeek) == p)
|
||||
if (screenpeek == p->pnum)
|
||||
{
|
||||
FX_StopAllSounds();
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ void RANDOMSCRAP(DDukeActor* i);
|
|||
void detonate(DDukeActor* i, PClassActor* explosion);
|
||||
void hitradius(DDukeActor* i, int r, int hp1, int hp2, int hp3, int hp4);
|
||||
int movesprite_ex(DDukeActor* actor, const DVector3& change, unsigned int cliptype, Collision& result);
|
||||
void move(DDukeActor* actor, int pnum, double xvel);
|
||||
void move(DDukeActor* actor, DDukePlayer* const p, double xvel);
|
||||
void lotsofstuff(DDukeActor* s, int n, PClassActor* spawntype);
|
||||
void watersplash2(DDukeActor* i);
|
||||
bool money(DDukeActor* i, int BLOODPOOL);
|
||||
|
@ -137,7 +137,7 @@ void wackplayer(DDukePlayer* p);
|
|||
void actoroperate(DDukeActor* g_ac);
|
||||
void playerkick(DDukePlayer* p, DDukeActor* g_ac);
|
||||
void garybanjo(DDukeActor* g_ac);
|
||||
int ifsquished(DDukeActor* i, int p);
|
||||
int ifsquished(DDukeActor* i, DDukePlayer* const p);
|
||||
void fakebubbaspawn(DDukeActor* actor, DDukePlayer* p);
|
||||
void tearitup(sectortype* sect);
|
||||
void destroyit(DDukeActor* actor);
|
||||
|
@ -175,7 +175,7 @@ DDukeActor* LocateTheLocator(int n, sectortype* sectnum);
|
|||
void clearcamera(DDukePlayer* ps);
|
||||
|
||||
void LoadActor(DDukeActor* i, int p, int x);
|
||||
bool execute(DDukeActor* s, int p, double d, int* killit_flag = nullptr);
|
||||
bool execute(DDukeActor* s, DDukePlayer* const p, double d, int* killit_flag = nullptr);
|
||||
void makeitfall(DDukeActor* s);
|
||||
DAngle furthestangle(DDukeActor* snum, int angDiv);
|
||||
void getglobalz(DDukeActor* s);
|
||||
|
|
|
@ -105,7 +105,7 @@ void FTA(int q, DDukePlayer* p)
|
|||
{
|
||||
p->ftq = q;
|
||||
auto qu = quoteMgr.GetQuote(q);
|
||||
if (p == getPlayer(screenpeek) && qu[0] != '\0')
|
||||
if (p->pnum == screenpeek && qu[0] != '\0')
|
||||
{
|
||||
#if 0
|
||||
if (q >= 70 && q <= 72)
|
||||
|
|
|
@ -1512,7 +1512,7 @@ int ParseState::parse(void)
|
|||
parseifelse(fi.ifhitbyweapon(g_ac) >= 0);
|
||||
break;
|
||||
case concmd_ifsquished:
|
||||
parseifelse(ifsquished(g_ac, g_p) == 1);
|
||||
parseifelse(ifsquished(g_ac, p) == 1);
|
||||
break;
|
||||
case concmd_ifdead:
|
||||
{
|
||||
|
@ -3211,7 +3211,7 @@ void LoadActor(DDukeActor *actor, int p, int x)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
bool execute(DDukeActor *actor,int p,double pdist, int* killit_flag)
|
||||
bool execute(DDukeActor *actor, DDukePlayer* const p, double pdist, int* killit_flag)
|
||||
{
|
||||
if (killit_flag) *killit_flag = 0;
|
||||
if ((actor->flags4 & SFLAG4_CONOVERRIDE) && overridecon) return false;
|
||||
|
@ -3221,7 +3221,7 @@ bool execute(DDukeActor *actor,int p,double pdist, int* killit_flag)
|
|||
return false;
|
||||
|
||||
ParseState s;
|
||||
s.g_p = p; // Player ID
|
||||
s.g_p = p->pnum; // Player ID
|
||||
s.g_x = int(pdist / maptoworld); // ??
|
||||
s.g_ac = actor;
|
||||
s.killit_flag = 0;
|
||||
|
|
|
@ -219,9 +219,8 @@ inline int monsterCheatCheck(DDukeActor* self)
|
|||
return false;
|
||||
}
|
||||
|
||||
inline void processinputvel(int snum)
|
||||
inline void processinputvel(DDukePlayer* const p)
|
||||
{
|
||||
const auto p = getPlayer(snum);
|
||||
p->cmd.ucmd.vel.XY() = p->cmd.ucmd.vel.XY().Rotated(p->GetActor()->spr.Angles.Yaw) + p->fric;
|
||||
}
|
||||
|
||||
|
|
|
@ -340,10 +340,7 @@ void selectweapon_d(DDukePlayer* const p, int weap) // playernum, weaponnum
|
|||
|
||||
int doincrements_d(DDukePlayer* p)
|
||||
{
|
||||
int snum;
|
||||
|
||||
auto pact = p->GetActor();
|
||||
snum = pact->PlayerIndex();
|
||||
|
||||
p->player_par++;
|
||||
|
||||
|
@ -363,7 +360,7 @@ int doincrements_d(DDukePlayer* p)
|
|||
if (p->last_pissed_time == (26 * 219))
|
||||
{
|
||||
S_PlayActorSound(FLUSH_TOILET, pact);
|
||||
if (snum == screenpeek || ud.coop == 1)
|
||||
if (p->pnum == screenpeek || ud.coop == 1)
|
||||
S_PlayActorSound(DUKE_PISSRELIEF, pact);
|
||||
}
|
||||
|
||||
|
@ -390,7 +387,7 @@ int doincrements_d(DDukePlayer* p)
|
|||
if (p->steroids_amount == 0)
|
||||
checkavailinven(p);
|
||||
if (!(p->steroids_amount & 7))
|
||||
if (snum == screenpeek || ud.coop == 1)
|
||||
if (p->pnum == screenpeek || ud.coop == 1)
|
||||
S_PlayActorSound(DUKE_HARTBEAT, pact);
|
||||
}
|
||||
|
||||
|
@ -514,7 +511,7 @@ int doincrements_d(DDukePlayer* p)
|
|||
if (p->knuckle_incs == 10 && !isWW2GI())
|
||||
{
|
||||
if (PlayClock > 1024)
|
||||
if (snum == screenpeek || ud.coop == 1)
|
||||
if (p->pnum == screenpeek || ud.coop == 1)
|
||||
{
|
||||
if (rand() & 1)
|
||||
S_PlayActorSound(DUKE_CRACK, pact);
|
||||
|
@ -1542,7 +1539,7 @@ void processinput_d(DDukePlayer* const p)
|
|||
const auto strafeVel = p->cmd.ucmd.vel.Y;
|
||||
constexpr auto maxVel = (117351124. / 10884538.);
|
||||
|
||||
processinputvel(p->pnum);
|
||||
processinputvel(p);
|
||||
|
||||
auto psectp = p->cursector;
|
||||
if (psectp == nullptr)
|
||||
|
|
|
@ -344,7 +344,6 @@ void selectweapon_r(DDukePlayer* const p, int weap)
|
|||
|
||||
int doincrements_r(DDukePlayer* p)
|
||||
{
|
||||
int snum;
|
||||
auto pact = p->GetActor();
|
||||
|
||||
if (isRRRA())
|
||||
|
@ -367,8 +366,6 @@ int doincrements_r(DDukePlayer* p)
|
|||
}
|
||||
}
|
||||
|
||||
snum = p->GetActor()->PlayerIndex();
|
||||
|
||||
p->player_par++;
|
||||
if (p->yehaa_timer)
|
||||
p->yehaa_timer--;
|
||||
|
@ -493,7 +490,7 @@ int doincrements_r(DDukePlayer* p)
|
|||
p->eatang = p->drunkang = 1647;
|
||||
}
|
||||
if (!(p->steroids_amount & 14))
|
||||
if (snum == screenpeek || ud.coop == 1)
|
||||
if (p->pnum == screenpeek || ud.coop == 1)
|
||||
S_PlayActorSound(DUKE_TAKEPILLS, pact);
|
||||
}
|
||||
|
||||
|
@ -578,7 +575,7 @@ int doincrements_r(DDukePlayer* p)
|
|||
S_PlayActorSound(snd, pact);
|
||||
}
|
||||
else if (PlayClock > 1024)
|
||||
if (snum == screenpeek || ud.coop == 1)
|
||||
if (p->pnum == screenpeek || ud.coop == 1)
|
||||
{
|
||||
if (rand() & 1)
|
||||
S_PlayActorSound(DUKE_CRACK, pact);
|
||||
|
@ -2278,7 +2275,7 @@ void processinput_r(DDukePlayer* const p)
|
|||
onBoat(p, actions);
|
||||
}
|
||||
|
||||
processinputvel(p->pnum);
|
||||
processinputvel(p);
|
||||
|
||||
if (psectp == nullptr)
|
||||
{
|
||||
|
|
|
@ -422,9 +422,11 @@ void GameInterface::UpdateSounds(void)
|
|||
|
||||
int S_PlaySound3D(FSoundID soundid, DDukeActor* actor, const DVector3& pos, int channel, EChanFlags flags)
|
||||
{
|
||||
auto const pl = getPlayer(myconnectindex);
|
||||
const auto mcip = getPlayer(myconnectindex);
|
||||
const auto spp = getPlayer(screenpeek);
|
||||
|
||||
if (!soundEngine->isValidSoundId(soundid) || !SoundEnabled() || actor == nullptr || !playrunning() ||
|
||||
(pl->timebeforeexit > 0 && pl->timebeforeexit <= REALGAMETICSPERSEC * 3)) return -1;
|
||||
(mcip->timebeforeexit > 0 && mcip->timebeforeexit <= REALGAMETICSPERSEC * 3)) return -1;
|
||||
|
||||
if (flags & CHANF_LOCAL && actor != getPlayer(screenpeek)->GetActor() && !ud.coop) return -1; // makes no sense...
|
||||
|
||||
|
@ -453,7 +455,7 @@ int S_PlaySound3D(FSoundID soundid, DDukeActor* actor, const DVector3& pos, int
|
|||
// Fixes a problem with quake06.voc in E3L4.
|
||||
if (ud.multimode == 1)
|
||||
{
|
||||
actor = pl->GetActor();
|
||||
actor = mcip->GetActor();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -470,7 +472,7 @@ int S_PlaySound3D(FSoundID soundid, DDukeActor* actor, const DVector3& pos, int
|
|||
bool explosion = ((userflags & (SF_GLOBAL | SF_DTAG)) == (SF_GLOBAL | SF_DTAG)) ||
|
||||
((sfx->ResourceId == PIPEBOMB_EXPLODE || sfx->ResourceId == LASERTRIP_EXPLODE || sfx->ResourceId == RPG_EXPLODE));
|
||||
|
||||
bool underwater = getPlayer(screenpeek)->insector() && getPlayer(screenpeek)->cursector->lotag == ST_2_UNDERWATER;
|
||||
bool underwater = spp->insector() && spp->cursector->lotag == ST_2_UNDERWATER;
|
||||
float pitch = 0;
|
||||
if (!explosion)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue