- made player.actorsqu a pointer and added the needed infrastructure for that.

This commit is contained in:
Christoph Oelckers 2020-10-17 10:30:11 +02:00
parent 39c154dc15
commit 7c88de0b42
9 changed files with 47 additions and 28 deletions

View file

@ -447,7 +447,7 @@ void moveplayers(void) //Players
{ {
p->knee_incs = 1; p->knee_incs = 1;
p->weapon_pos = -1; p->weapon_pos = -1;
p->actorsqu = ps[otherp].i; p->actorsqu = ps[otherp].GetActor();
} }
} }
} }
@ -460,9 +460,9 @@ void moveplayers(void) //Players
p->jetpack_amount = 1599; p->jetpack_amount = 1599;
} }
if (p->actorsqu >= 0) if (p->actorsqu != nullptr)
{ {
p->angle.addadjustment(FixedToFloat(getincangleq16(p->angle.ang.asq16(), gethiq16angle(sprite[p->actorsqu].x - p->posx, sprite[p->actorsqu].y - p->posy)) >> 2)); p->angle.addadjustment(FixedToFloat(getincangleq16(p->angle.ang.asq16(), gethiq16angle(p->actorsqu->s.x - p->posx, p->actorsqu->s.y - p->posy)) >> 2));
} }
if (s->extra > 0) if (s->extra > 0)

View file

@ -4283,12 +4283,12 @@ void move_d(int g_i, int g_p, int g_x)
{ {
if (hittype[g_i].bposz != g_sp->z || (ud.multimode < 2 && ud.player_skill < 2)) if (hittype[g_i].bposz != g_sp->z || (ud.multimode < 2 && ud.player_skill < 2))
{ {
if ((g_t[0] & 1) || ps[g_p].actorsqu == g_i) return; if ((g_t[0] & 1) || ps[g_p].actorsqu == &hittype[g_i]) return;
else daxvel <<= 1; else daxvel <<= 1;
} }
else else
{ {
if ((g_t[0] & 3) || ps[g_p].actorsqu == g_i) return; if ((g_t[0] & 3) || ps[g_p].actorsqu == &hittype[g_i]) return;
else daxvel <<= 2; else daxvel <<= 2;
} }
} }

View file

@ -4238,12 +4238,12 @@ void move_r(int g_i, int g_p, int g_x)
{ {
if (hittype[g_i].bposz != g_sp->z || (ud.multimode < 2 && ud.player_skill < 2)) if (hittype[g_i].bposz != g_sp->z || (ud.multimode < 2 && ud.player_skill < 2))
{ {
if ((g_t[0] & 1) || ps[g_p].actorsqu == g_i) return; if ((g_t[0] & 1) || ps[g_p].actorsqu == &hittype[g_i]) return;
else daxvel <<= 1; else daxvel <<= 1;
} }
else else
{ {
if ((g_t[0] & 3) || ps[g_p].actorsqu == g_i) return; if ((g_t[0] & 3) || ps[g_p].actorsqu == &hittype[g_i]) return;
else daxvel <<= 2; else daxvel <<= 2;
} }
} }

View file

@ -160,7 +160,8 @@ inline int ActorToScriptIndex(DDukeActor* a)
inline DDukeActor* ScriptIndexToActor(int index) inline DDukeActor* ScriptIndexToActor(int index)
{ {
if (index == -1) return nullptr; // only allow valid actors to get through here. Everything else gets null'ed.
if (index < 0 || index >= MAXSPRITES || hittype[index].s.statnum == MAXSTATUS) return nullptr;
return &hittype[index]; return &hittype[index];
} }

View file

@ -39,6 +39,7 @@ source as it is released.
#include "gamestate.h" #include "gamestate.h"
#include "conlabel.h" #include "conlabel.h"
#include "automap.h" #include "automap.h"
#include "dukeactor.h"
BEGIN_DUKE_NS BEGIN_DUKE_NS
@ -666,8 +667,8 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, int sActor, int sPl
break; break;
case PLAYER_ACTORSQU: case PLAYER_ACTORSQU:
if (bSet) ps[iPlayer].actorsqu = lValue; if (bSet) ps[iPlayer].actorsqu = ScriptIndexToActor(lValue);
else SetGameVarID((int)lVar2, ps[iPlayer].actorsqu, sActor, sPlayer); else SetGameVarID((int)lVar2, ActorToScriptIndex(ps[iPlayer].actorsqu), sActor, sPlayer);
break; break;
case PLAYER_TIMEBEFOREEXIT: case PLAYER_TIMEBEFOREEXIT:
@ -2786,7 +2787,7 @@ int ParseState::parse(void)
ps[g_p].knee_incs = 1; ps[g_p].knee_incs = 1;
if(ps[g_p].weapon_pos == 0) if(ps[g_p].weapon_pos == 0)
ps[g_p].weapon_pos = -1; ps[g_p].weapon_pos = -1;
ps[g_p].actorsqu = g_i; ps[g_p].actorsqu = &hittype[g_i];
} }
break; break;
case concmd_ifawayfromwall: case concmd_ifawayfromwall:
@ -3693,8 +3694,8 @@ void LoadActor(int i, int p, int x)
// if player was set to squish, first stop that... // if player was set to squish, first stop that...
if (p >= 0) if (p >= 0)
{ {
if (ps[p].actorsqu == i) if (ps[p].actorsqu == &hittype[i])
ps[p].actorsqu = -1; ps[p].actorsqu = nullptr;
} }
deletesprite(i); deletesprite(i);
} }
@ -3804,8 +3805,8 @@ void execute(int i,int p,int x)
if(s.killit_flag == 1) if(s.killit_flag == 1)
{ {
// if player was set to squish, first stop that... // if player was set to squish, first stop that...
if(ps[p].actorsqu == i) if(ps[p].actorsqu == &hittype[i])
ps[p].actorsqu = -1; ps[p].actorsqu = nullptr;
killthesprite = true; killthesprite = true;
} }
else else

View file

@ -36,6 +36,7 @@ source as it is released.
#include "ns.h" #include "ns.h"
#include "global.h" #include "global.h"
#include "mapinfo.h" #include "mapinfo.h"
#include "dukeactor.h"
BEGIN_DUKE_NS BEGIN_DUKE_NS
@ -417,30 +418,30 @@ void dokneeattack(int snum, int pi, const std::initializer_list<int> & respawnli
p->holster_weapon = 0; p->holster_weapon = 0;
if (p->weapon_pos < 0) if (p->weapon_pos < 0)
p->weapon_pos = -p->weapon_pos; p->weapon_pos = -p->weapon_pos;
if (p->actorsqu >= 0 && dist(&sprite[pi], &sprite[p->actorsqu]) < 1400) if (p->actorsqu != nullptr && dist(&sprite[pi], &p->actorsqu->s) < 1400)
{ {
fi.guts(&sprite[p->actorsqu], TILE_JIBS6, 7, myconnectindex); fi.guts(&p->actorsqu->s, TILE_JIBS6, 7, myconnectindex);
fi.spawn(p->actorsqu, TILE_BLOODPOOL); fi.spawn(p->actorsqu->GetIndex(), TILE_BLOODPOOL);
S_PlayActorSound(SQUISHED, p->actorsqu); S_PlayActorSound(SQUISHED, p->actorsqu);
if (isIn(sprite[p->actorsqu].picnum, respawnlist)) if (isIn(p->actorsqu->s.picnum, respawnlist))
{ {
if (sprite[p->actorsqu].yvel) if (p->actorsqu->s.yvel)
fi.operaterespawns(sprite[p->actorsqu].yvel); fi.operaterespawns(p->actorsqu->s.yvel);
} }
if (sprite[p->actorsqu].picnum == TILE_APLAYER) if (p->actorsqu->s.picnum == TILE_APLAYER)
{ {
quickkill(&ps[sprite[p->actorsqu].yvel]); quickkill(&ps[p->actorsqu->s.yvel]);
ps[sprite[p->actorsqu].yvel].frag_ps = snum; ps[p->actorsqu->s.yvel].frag_ps = snum;
} }
else if (badguy(&sprite[p->actorsqu])) else if (badguy(&p->actorsqu->s))
{ {
deletesprite(p->actorsqu); deletesprite(p->actorsqu);
p->actors_killed++; p->actors_killed++;
} }
else deletesprite(p->actorsqu); else deletesprite(p->actorsqu);
} }
p->actorsqu = -1; p->actorsqu = nullptr;
} }
} }

View file

@ -86,7 +86,7 @@ void resetplayerstats(int snum)
p->ftq = 0; p->ftq = 0;
p->tipincs = 0; p->tipincs = 0;
p->buttonpalette = 0; p->buttonpalette = 0;
p->actorsqu =-1; p->actorsqu =nullptr;
p->invdisptime = 0; p->invdisptime = 0;
p->refresh_inventory= 0; p->refresh_inventory= 0;
p->last_pissed_time = 0; p->last_pissed_time = 0;

View file

@ -34,6 +34,21 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
extern FixedBitArray<MAXSPRITES> activeSprites; extern FixedBitArray<MAXSPRITES> activeSprites;
//==========================================================================
//
//
//
//==========================================================================
template<> FSerializer& Serialize(FSerializer& arc, const char* key, Duke3d::weaponhit*& ht, Duke3d::weaponhit** def)
{
size_t index = ht - Duke3d::hittype;
assert(index < MAXSPRITES);
Serialize(arc, key, index, nullptr);
ht = &Duke3d::hittype[index];
return arc;
}
BEGIN_DUKE_NS BEGIN_DUKE_NS
void SerializeActorGlobals(FSerializer& arc); void SerializeActorGlobals(FSerializer& arc);

View file

@ -207,7 +207,8 @@ struct player_struct
short over_shoulder_on, fist_incs; short over_shoulder_on, fist_incs;
short cheat_phase; short cheat_phase;
short dummyplayersprite, extra_extra8, quick_kick, last_quick_kick; short dummyplayersprite, extra_extra8, quick_kick, last_quick_kick;
short heat_amount, actorsqu, timebeforeexit, customexitsound; short heat_amount, timebeforeexit, customexitsound;
DDukeActor* actorsqu;//, *wackedbyactor, *on_crane, *holoduke_on, *somethingonplayer;
short weaprecs[256], weapreccnt; short weaprecs[256], weapreccnt;
unsigned int interface_toggle_flag; unsigned int interface_toggle_flag;