- replaced lo_sp with an actor pointer, both in USER and PLAYER.

This commit is contained in:
Christoph Oelckers 2021-10-31 00:29:54 +02:00
parent 64d77945f9
commit c0c27dfd1a
17 changed files with 80 additions and 74 deletions

View file

@ -130,7 +130,7 @@ int DoActorDie(DSWActor* actor, DSWActor* weapActor, int meansofdeath)
switch (wu->ID)
{
// Coolie actually explodes himself
// he is the Sprite AND Weapon
// he is the Sprite AND weapon
case COOLIE_RUN_R0:
ChangeState(actor, u->StateEnd);
u->RotNum = 0;
@ -422,7 +422,7 @@ int DoActorDebris(DSWActor* actor)
getzsofslope(sp->sectnum, sp->x, sp->y, &u->hiz, &u->loz);
u->lo_sectp = &sector[sp->sectnum];
u->hi_sectp = &sector[sp->sectnum];
u->lo_sp = nullptr;
u->lowActor = nullptr;
u->hi_sp = nullptr;
break;
}
@ -782,7 +782,7 @@ int DoActorStopFall(DSWActor* actor)
// don't stand on face or wall sprites - jump again
if (u->lo_sp && !TEST(u->lo_sp->cstat, CSTAT_SPRITE_ALIGNMENT_FLOOR))
if (u->lowActor && !TEST(u->lowActor->s().cstat, CSTAT_SPRITE_ALIGNMENT_FLOOR))
{
//sp->ang = NORM_ANGLE(sp->ang + (RANDOM_P2(64<<8)>>8) - 32);
sp->ang = NORM_ANGLE(sp->ang + 1024 + (RANDOM_P2(512<<8)>>8));

View file

@ -1619,7 +1619,8 @@ int move_scan(DSWActor* actor, short ang, int dist, int *stopx, int *stopy, int
short sang,ss;
int x, y, z, loz, hiz;
SPRITEp lo_sp, hi_sp;
SPRITEp hi_sp;
DSWActor *lowActor;
SECTORp lo_sectp, hi_sectp;
@ -1632,7 +1633,7 @@ int move_scan(DSWActor* actor, short ang, int dist, int *stopx, int *stopy, int
sang = sp->ang;
loz = u->loz;
hiz = u->hiz;
lo_sp = u->lo_sp;
lowActor = u->lowActor;
hi_sp = u->hi_sp;
lo_sectp = u->lo_sectp;
hi_sectp = u->hi_sectp;
@ -1661,7 +1662,7 @@ int move_scan(DSWActor* actor, short ang, int dist, int *stopx, int *stopy, int
sp->ang = sang;
u->loz = loz;
u->hiz = hiz;
u->lo_sp = lo_sp;
u->lowActor = lowActor;
u->hi_sp = hi_sp;
u->lo_sectp = lo_sectp;
u->hi_sectp = hi_sectp;

View file

@ -67,7 +67,7 @@ struct NODETREEstruct
typedef struct BOT_BRAIN
{
short tgt_inv; // Inventory item it wants to use
short tgt_weapon; // Weapon in wants to activate and use
short tgt_weapon; // weapon in wants to activate and use
short tgt_enemy; // Enemy it wants to kill
short tgt_sprite; // Sprite it wants to pickup or operate
short tgt_sector; // Sector it wants to get to

View file

@ -955,7 +955,7 @@ DoPickCloseBunny(USERp u)
{
near_dist = dist;
u->targetActor = itActor;
u->lo_sp = tsp;
u->lowActor = itActor;
//Bunny_Result = i;
return i;
}
@ -972,15 +972,14 @@ DoBunnyQuickJump(DSWActor* actor)
if (u->spal != PALETTE_PLAYER8) return false;
if (!u->lo_sp && u->spal == PALETTE_PLAYER8 && MoveSkip4)
if (!u->lowActor&& u->spal == PALETTE_PLAYER8 && MoveSkip4)
DoPickCloseBunny(u);
// Random Chance of like sexes fighting
if (u->lo_sp)
if (u->lowActor)
{
short hit_sprite = short(u->lo_sp - sprite);
auto hitActor = &swActors[hit_sprite];
SPRITEp tsp = u->lo_sp;
auto hitActor = u->lowActor;
SPRITEp tsp = &hitActor->s();
USERp tu = hitActor->u();
if (!tu || tu->ID != BUNNY_RUN_R0) return false;
@ -1001,7 +1000,7 @@ DoBunnyQuickJump(DSWActor* actor)
tu->Health = 0;
// Blood fountains
InitBloodSpray(hit_sprite,true,-1);
InitBloodSpray(hitActor->GetSpriteIndex(), true,-1);
if (SpawnShrap(hitActor, actor))
{
@ -1012,18 +1011,18 @@ DoBunnyQuickJump(DSWActor* actor)
Bunny_Count--; // Bunny died
u->lo_sp = nullptr;
u->lowActor = nullptr;
return true;
}
}
}
// Get layed!
if (u->lo_sp && u->spal == PALETTE_PLAYER8) // Only males check this
if (u->lowActor && u->spal == PALETTE_PLAYER8) // Only males check this
{
short hit_sprite = short(u->lo_sp - sprite);
SPRITEp tsp = u->lo_sp;
USERp tu = User[hit_sprite].Data();
auto hitActor = u->lowActor;
SPRITEp tsp = &hitActor->s();
USERp tu = hitActor->u();
if (!tu || tu->ID != BUNNY_RUN_R0) return false;
@ -1090,7 +1089,7 @@ DoBunnyQuickJump(DSWActor* actor)
tu->Vis = tsp->ang;
NewStateGroup(actor, sg_BunnyScrew);
NewStateGroup_(hit_sprite, sg_BunnyScrew);
NewStateGroup(hitActor, sg_BunnyScrew);
u->WaitTics = tu->WaitTics = SEC(10); // Mate for this long
return true;
}

View file

@ -660,7 +660,7 @@ int DoCoolgMatchPlayerZ(DSWActor* actor)
loz -= Z(FixedToInt(SectUser[u->lo_sectp - sector]->depth_fixed)) - Z(8);
// lower bound
if (u->lo_sp)
if (u->lowActor)
bound = loz - u->floor_dist;
else
bound = loz - u->floor_dist - COOLG_BOB_AMT;

View file

@ -308,9 +308,9 @@ DoShadows(spritetype* tsprite, int& spritesortcnt, tspriteptr_t tsp, int viewz,
SET(New->cstat, CSTAT_SPRITE_TRANSLUCENT);
loz = tu->loz;
if (tu->lo_sp)
if (tu->lowActor)
{
if (!TEST(tu->lo_sp->cstat, CSTAT_SPRITE_ALIGNMENT_WALL | CSTAT_SPRITE_ALIGNMENT_FLOOR))
if (!TEST(tu->lowActor->s().cstat, CSTAT_SPRITE_ALIGNMENT_WALL | CSTAT_SPRITE_ALIGNMENT_FLOOR))
{
loz = DoShadowFindGroundPoint(tsp);
}

View file

@ -480,9 +480,9 @@ int DoEelMatchPlayerZ(DSWActor* actor)
loz -= Z(FixedToInt(SectUser[u->lo_sectp - sector]->depth_fixed)) - Z(8);
// lower bound
if (u->lo_sp && u->tgt_sp() == u->hi_sp)
if (u->lowActor && u->tgt_sp() == u->hi_sp)
{
DISTANCE(sp->x, sp->y, u->lo_sp->x, u->lo_sp->y, dist, a, b, c);
DISTANCE(sp->x, sp->y, u->lowActor->s().x, u->lowActor->s().y, dist, a, b, c);
if (dist <= 300)
bound = u->sz;
else

View file

@ -775,7 +775,8 @@ struct PLAYERstruct
int hiz,loz;
int ceiling_dist,floor_dist;
SECTORp hi_sectp, lo_sectp;
SPRITEp hi_sp, lo_sp;
SPRITEp hi_sp;
DSWActor* lowActor;
SPRITEp last_camera_sp;
int circle_camera_dist;
@ -1131,7 +1132,8 @@ struct USER
int hiz,loz;
int zclip; // z height to move up for clipmove
SECTORp hi_sectp, lo_sectp;
SPRITEp hi_sp, lo_sp;
SPRITEp hi_sp;
DSWActor* lowActor;
int active_range;

View file

@ -386,7 +386,7 @@ int DoHornetMatchPlayerZ(short SpriteNum)
loz -= Z(FixedToInt(SectUser[u->lo_sectp - sector]->depth_fixed)) - Z(8);
// lower bound
if (u->lo_sp)
if (u->lowActor)
bound = loz - u->floor_dist;
else
bound = loz - u->floor_dist - HORNET_BOB_AMT;

View file

@ -1946,7 +1946,8 @@ DoPlayerZrange(PLAYERp pp)
// 49152+spritenum (sprite first touched)
pp->lo_sectp = pp->hi_sectp = nullptr;
pp->lo_sp = pp->hi_sp = nullptr;
pp->lowActor = nullptr;
pp->hi_sp = nullptr;
if (TEST(ceilhit, 0xc000) == 49152)
{
@ -1959,14 +1960,14 @@ DoPlayerZrange(PLAYERp pp)
if (TEST(florhit, 0xc000) == 49152)
{
pp->lo_sp = &sprite[florhit & 4095];
pp->lowActor = &swActors[florhit & 4095];
// prevent player from standing on Zombies
if (pp->lo_sp->statnum == STAT_ENEMY && User[pp->lo_sp - sprite]->ID == ZOMBIE_RUN_R0)
if (pp->lowActor->s().statnum == STAT_ENEMY && pp->lowActor->u()->ID == ZOMBIE_RUN_R0)
{
pp->lo_sectp = &sector[pp->lo_sp->sectnum];
pp->loz = pp->lo_sp->z;
pp->lo_sp = nullptr;
pp->lo_sectp = &sector[pp->lowActor->s().sectnum];
pp->loz = pp->lowActor->s().z;
pp->lowActor = nullptr;
}
}
else
@ -6082,7 +6083,7 @@ DoPlayerDeathZrange(PLAYERp pp)
// update player values with results from DoFindGround
// pp->hiz = u->hiz;
pp->loz = u->loz;
pp->lo_sp = u->lo_sp;
pp->lowActor = u->lowActor;
//pp->hi_sp = u->hi_sp;
pp->lo_sectp = u->lo_sectp;
//pp->hi_sectp = u->hi_sectp;

View file

@ -1161,9 +1161,9 @@ DoRipperQuickJump(DSWActor* actor)
// Tests to see if ripper is on top of a player/enemy and then immediatly
// does another jump
if (u->lo_sp)
if (u->lowActor)
{
SPRITEp tsp = u->lo_sp;
SPRITEp tsp = &u->lowActor->s();
if (TEST(tsp->extra, SPRX_PLAYER_OR_ENEMY))
{

View file

@ -1139,7 +1139,6 @@ int
DoRipper2MoveJump(DSWActor* actor)
{
USER* u = actor->u();
int SpriteNum = u->SpriteNum;
if (TEST(u->Flags, SPR_JUMPING | SPR_FALLING))
{
@ -1169,14 +1168,13 @@ int
DoRipper2QuickJump(DSWActor* actor)
{
USER* u = actor->u();
int SpriteNum = u->SpriteNum;
// Tests to see if ripper2 is on top of a player/enemy and then immediatly
// does another jump
if (u->lo_sp)
if (u->lowActor)
{
SPRITEp tsp = u->lo_sp;
SPRITEp tsp = &u->lowActor->s();
if (TEST(tsp->extra, SPRX_PLAYER_OR_ENEMY))
{

View file

@ -461,7 +461,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, PLAYERstruct& w, P
("hi_sectp", w.hi_sectp)
("lo_sectp", w.lo_sectp)
("hi_sp", w.hi_sp)
("lo_sp", w.lo_sp)
("lo_sp", w.lowActor)
("last_camera_sp", w.last_camera_sp)
("circle_camera_dist", w.circle_camera_dist)
("six", w.six)
@ -867,7 +867,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, USER& w, USER* def
("hi_sectp", w.hi_sectp, def->hi_sectp)
("lo_sectp", w.lo_sectp, def->lo_sectp)
("hi_sp", w.hi_sp, def->hi_sp)
("lo_sp", w.lo_sp, def->lo_sp)
("lo_sp", w.lowActor, def->lowActor)
("active_range", w.active_range, def->active_range)
("SpriteNum", w.SpriteNum, def->SpriteNum)
("Attach", w.Attach, def->Attach)

View file

@ -626,8 +626,9 @@ void KillActor(DSWActor* actor)
void KillSprite(int16_t SpriteNum)
{
SPRITEp sp = &sprite[SpriteNum];
USERp u = User[SpriteNum].Data();
auto actor = &swActors[SpriteNum];
SPRITEp sp = &actor->s();
USERp u = actor->u();
int i;
unsigned stat;
short statnum,sectnum;
@ -804,8 +805,8 @@ void KillSprite(int16_t SpriteNum)
if (u.Data())
{
if (u->hi_sp == sp) u->hi_sp = nullptr;
if (u->lo_sp == sp) u->lo_sp = nullptr;
if (u->tgt_sp() == sp) u->targetActor = nullptr;
if (u->lowActor == actor) u->lowActor = nullptr;
if (u->targetActor == actor) u->targetActor = nullptr;
}
}
}
@ -936,7 +937,7 @@ SpawnUser(short SpriteNum, short id, STATEp state)
#else
u->loz = sector[sp->sectnum].floorz;
u->hiz = sector[sp->sectnum].ceilingz;
u->lo_sp = nullptr;
u->lowActor = nullptr;
u->hi_sp = nullptr;
u->lo_sectp = &sector[sp->sectnum];
u->hi_sectp = &sector[sp->sectnum];
@ -4940,7 +4941,8 @@ DoActorZrange(short SpriteNum)
SET(sp->cstat, save_cstat);
u->lo_sectp = u->hi_sectp = nullptr;
u->lo_sp = u->hi_sp = nullptr;
u->hi_sp = nullptr;
u->lowActor = nullptr;
switch (TEST(ceilhit, HIT_MASK))
{
@ -4958,7 +4960,7 @@ DoActorZrange(short SpriteNum)
switch (TEST(florhit, HIT_MASK))
{
case HIT_SPRITE:
u->lo_sp = &sprite[NORM_SPRITE(florhit)];
u->lowActor = &swActors[NORM_SPRITE(florhit)];
break;
case HIT_SECTOR:
u->lo_sectp = &sector[NORM_SECTOR(florhit)];
@ -4981,7 +4983,8 @@ DoActorGlobZ(short SpriteNum)
u->hiz = globhiz;
u->lo_sectp = u->hi_sectp = nullptr;
u->lo_sp = u->hi_sp = nullptr;
u->hi_sp = nullptr;
u->lowActor = nullptr;
switch (TEST(globhihit, HIT_MASK))
{
@ -4996,7 +4999,7 @@ DoActorGlobZ(short SpriteNum)
switch (TEST(globlohit, HIT_MASK))
{
case HIT_SPRITE:
u->lo_sp = &sprite[globlohit & 4095];
u->lowActor = &swActors[globlohit & 4095];
break;
default:
u->lo_sectp = &sector[globlohit & 4095];
@ -5105,7 +5108,8 @@ int move_actor(DSWActor* actor, int xchange, int ychange, int zchange)
SPRITEp sp = &actor->s();
int x, y, z, loz, hiz;
SPRITEp lo_sp, hi_sp;
SPRITEp hi_sp;
DSWActor* lowActor;
SECTORp lo_sectp, hi_sectp;
short sectnum;
short dist;
@ -5125,7 +5129,7 @@ int move_actor(DSWActor* actor, int xchange, int ychange, int zchange)
z = sp->z;
loz = u->loz;
hiz = u->hiz;
lo_sp = u->lo_sp;
lowActor = u->lowActor;
hi_sp = u->hi_sp;
lo_sectp = u->lo_sectp;
hi_sectp = u->hi_sectp;
@ -5148,7 +5152,7 @@ int move_actor(DSWActor* actor, int xchange, int ychange, int zchange)
//sp->z = u->loz; // place on ground in case you are in the air
u->loz = loz;
u->hiz = hiz;
u->lo_sp = lo_sp;
u->lowActor = lowActor;
u->hi_sp = hi_sp;
u->lo_sectp = lo_sectp;
u->hi_sectp = hi_sectp;
@ -5167,7 +5171,7 @@ int move_actor(DSWActor* actor, int xchange, int ychange, int zchange)
//sp->z = u->loz; // place on ground in case you are in the air
u->loz = loz;
u->hiz = hiz;
u->lo_sp = lo_sp;
u->lowActor = lowActor;
u->hi_sp = hi_sp;
u->lo_sectp = lo_sectp;
u->hi_sectp = hi_sectp;
@ -7378,7 +7382,7 @@ move_ground_missile(short spritenum, int xchange, int ychange, int ceildist, int
getzsofslope(sp->sectnum, sp->x, sp->y, &u->hiz, &u->loz);
u->hi_sectp = u->lo_sectp = &sector[sp->sectnum];
u->hi_sp = u->lo_sp = nullptr;
u->hi_sp = u->lowActor = nullptr;
return retval;
}
else
@ -7405,7 +7409,7 @@ move_ground_missile(short spritenum, int xchange, int ychange, int ceildist, int
getzsofslope(sp->sectnum, sp->x, sp->y, &u->hiz, &u->loz);
u->hi_sectp = u->lo_sectp = &sector[sp->sectnum];
u->hi_sp = u->lo_sp = nullptr;
u->hi_sp = nullptr; u->lowActor = nullptr;
sp->z = u->loz - Z(8);
if (labs(u->hiz - u->loz) < Z(12))

View file

@ -1799,6 +1799,7 @@ PlayerPart:
{
sp = &sprite[sop->sp_num[i]];
u = User[sop->sp_num[i]].Data();
auto actor = &swActors[u->SpriteNum];
// if its a player sprite || NOT attached
if (!u || u->PlayerP || !TEST(u->Flags, SPR_SO_ATTACHED))
@ -1809,7 +1810,7 @@ PlayerPart:
{
pp = Player + pnum;
if (pp->lo_sp && pp->lo_sp == sp)
if (pp->lowActor && pp->lowActor == actor)
{
if (PlayerMove)
MovePlayer(pp, sop, nx, ny);

View file

@ -4460,15 +4460,13 @@ WeaponMoveHit(short SpriteNum)
if (sp->z > DIV2(u->hiz + u->loz))
{
// hit a floor sprite
if (u->lo_sp)
if (u->lowActor)
{
if (u->lo_sp->lotag == TAG_SPRITE_HIT_MATCH)
if (u->lowActor->s().lotag == TAG_SPRITE_HIT_MATCH)
{
if (MissileHitMatch(SpriteNum, -1, short(u->lo_sp - sprite)))
if (MissileHitMatch(SpriteNum, -1, u->lowActor->GetSpriteIndex()))
return true;
//DoMatchEverything(nullptr, u->lo_sp->hitag, -1);
//return(true);
}
return true;
@ -8053,8 +8051,8 @@ DoStar(DSWActor* actor)
}
}
if (u->lo_sp)
if (u->lo_sp->lotag == TAG_SPRITE_HIT_MATCH)
if (u->lowActor)
if (u->lowActor->s().lotag == TAG_SPRITE_HIT_MATCH)
break;
if (u->hi_sp)
if (u->hi_sp->lotag == TAG_SPRITE_HIT_MATCH)
@ -11980,12 +11978,13 @@ DoFindGround(int16_t SpriteNum)
{
case HIT_SPRITE:
{
hsp = &sprite[NORM_SPRITE(florhit)];
auto florActor = &swActors[NORM_SPRITE(florhit)];
hsp = &florActor->s();
if (TEST(hsp->cstat, CSTAT_SPRITE_ALIGNMENT_FLOOR))
{
// found a sprite floor
u->lo_sp = hsp;
u->lowActor = florActor;
u->lo_sectp = nullptr;
return true;
}
@ -12004,7 +12003,7 @@ DoFindGround(int16_t SpriteNum)
case HIT_SECTOR:
{
u->lo_sectp = &sector[NORM_SECTOR(florhit)];
u->lo_sp = nullptr;
u->lowActor = nullptr;
return true;
}
@ -12038,12 +12037,13 @@ int DoFindGroundPoint(DSWActor* actor)
{
case HIT_SPRITE:
{
hsp = &sprite[NORM_SPRITE(florhit)];
auto florActor = &swActors[NORM_SPRITE(florhit)];
hsp = &florActor->s();
if (TEST(hsp->cstat, CSTAT_SPRITE_ALIGNMENT_FLOOR))
{
// found a sprite floor
u->lo_sp = hsp;
u->lowActor = florActor;
u->lo_sectp = nullptr;
return true;
}
@ -12062,7 +12062,7 @@ int DoFindGroundPoint(DSWActor* actor)
case HIT_SECTOR:
{
u->lo_sectp = &sector[NORM_SECTOR(florhit)];
u->lo_sp = nullptr;
u->lowActor = nullptr;
return true;
}

View file

@ -703,7 +703,7 @@ int NullZilla(DSWActor* actor)
getzsofslope(sp->sectnum, sp->x, sp->y, &u->hiz, &u->loz);
u->lo_sectp = &sector[sp->sectnum];
u->hi_sectp = &sector[sp->sectnum];
u->lo_sp = nullptr;
u->lowActor = nullptr;
u->hi_sp = nullptr;
sp->z = u->loz;
@ -788,7 +788,7 @@ int DoZillaDeathMelt(DSWActor* actor)
getzsofslope(sp->sectnum, sp->x, sp->y, &u->hiz, &u->loz);
u->lo_sectp = &sector[sp->sectnum];
u->hi_sectp = &sector[sp->sectnum];
u->lo_sp = nullptr;
u->lowActor = nullptr;
u->hi_sp = nullptr;
sp->z = u->loz;