- 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->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;
}
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)

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 ((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
{
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;
}
}

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 ((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
{
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;
}
}

View File

@ -160,7 +160,8 @@ inline int ActorToScriptIndex(DDukeActor* a)
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];
}

View File

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

View File

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

View File

@ -86,7 +86,7 @@ void resetplayerstats(int snum)
p->ftq = 0;
p->tipincs = 0;
p->buttonpalette = 0;
p->actorsqu =-1;
p->actorsqu =nullptr;
p->invdisptime = 0;
p->refresh_inventory= 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;
//==========================================================================
//
//
//
//==========================================================================
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
void SerializeActorGlobals(FSerializer& arc);

View File

@ -207,7 +207,8 @@ struct player_struct
short over_shoulder_on, fist_incs;
short cheat_phase;
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;
unsigned int interface_toggle_flag;