- eliminated lots of direct tile references in spawn() calls.

This commit is contained in:
Christoph Oelckers 2022-12-29 00:51:26 +01:00
parent c1a9163f3c
commit 36d5ab74bb
9 changed files with 74 additions and 50 deletions

View file

@ -65,6 +65,30 @@ xx(DukeBloodSplat4)
xx(DukeBloodPool) xx(DukeBloodPool)
xx(DukeFirelaser) xx(DukeFirelaser)
xx(RedneckFirelaser) xx(RedneckFirelaser)
xx(DukeMeleeAttack)
xx(DukeFirstgunSprite)
xx(DukeShotgunSprite)
xx(DukeChaingunSprite)
xx(DukeRPGSprite)
xx(DukePipeBomb)
xx(DukeShrinkerSprite)
xx(DukeDevastatorSprite)
xx(DukeTripBombSprite)
xx(DukeFreezeSprite)
xx(DukeTransporterBeam)
xx(DukeWaterSplash)
xx(DukeShell)
xx(DukeShotgunShell)
xx(DukeRPG)
xx(RedneckDynamiteArrow)
xx(RedneckHulk)
xx(RedneckPig)
xx(RedneckMinion)
xx(RedneckVixen)
xx(RedneckRabbit)
xx(RedneckDoorkey)
xx(RedneckEmptyBike)
xx(RedneckEmptyBoat)
xx(spawnstate) xx(spawnstate)
xx(brokenstate) xx(brokenstate)

View file

@ -780,7 +780,7 @@ void detonate(DDukeActor *actor, PClassActor* explosion)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void gutsdir(DDukeActor* actor, int gtype, int n, int p) void gutsdir(DDukeActor* actor, PClassActor* gtype, int n, int p)
{ {
double scale; double scale;
@ -996,7 +996,7 @@ void handle_se01(DDukeActor *actor)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void handle_se14(DDukeActor* actor, bool checkstat, int RPG, int JIBS6) void handle_se14(DDukeActor* actor, bool checkstat, PClassActor* RPG)
{ {
auto sc = actor->sector(); auto sc = actor->sector();
int st = actor->spr.lotag; int st = actor->spr.lotag;
@ -1055,7 +1055,7 @@ void handle_se14(DDukeActor* actor, bool checkstat, int RPG, int JIBS6)
{ {
auto saved_angle = actor->spr.Angles.Yaw; auto saved_angle = actor->spr.Angles.Yaw;
actor->spr.Angles.Yaw = (actor->spr.pos.XY() - ps[p].GetActor()->spr.pos.XY()).Angle(); actor->spr.Angles.Yaw = (actor->spr.pos.XY() - ps[p].GetActor()->spr.pos.XY()).Angle();
shoot(actor, RPG, nullptr); shoot(actor, -1, RPG);
actor->spr.Angles.Yaw = saved_angle; actor->spr.Angles.Yaw = saved_angle;
} }
} }
@ -1173,7 +1173,7 @@ void handle_se14(DDukeActor* actor, bool checkstat, int RPG, int JIBS6)
updatesector(a2->spr.pos, &k); updatesector(a2->spr.pos, &k);
if (a2->spr.extra >= 0 && k == actor->sector()) if (a2->spr.extra >= 0 && k == actor->sector())
{ {
gutsdir(a2, JIBS6, 72, myconnectindex); gutsdir(a2, PClass::FindActor(NAME_DukeJibs6), 72, myconnectindex);
S_PlayActorSound(SQUISHED, actor); S_PlayActorSound(SQUISHED, actor);
a2->Destroy(); a2->Destroy();
} }
@ -1194,7 +1194,7 @@ void handle_se14(DDukeActor* actor, bool checkstat, int RPG, int JIBS6)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void handle_se30(DDukeActor *actor, int JIBS6) void handle_se30(DDukeActor *actor)
{ {
auto sc = actor->sector(); auto sc = actor->sector();
@ -1333,7 +1333,7 @@ void handle_se30(DDukeActor *actor, int JIBS6)
updatesector(a2->spr.pos, &k); updatesector(a2->spr.pos, &k);
if (a2->spr.extra >= 0 && k == actor->sector()) if (a2->spr.extra >= 0 && k == actor->sector())
{ {
gutsdir(a2, JIBS6, 24, myconnectindex); gutsdir(a2, PClass::FindActor(NAME_DukeJibs6), 24, myconnectindex);
S_PlayActorSound(SQUISHED, a2); S_PlayActorSound(SQUISHED, a2);
a2->Destroy(); a2->Destroy();
} }

View file

@ -557,7 +557,7 @@ void movetransports_d(void)
{ {
if (act->spr.pal == 0) if (act->spr.pal == 0)
{ {
spawn(act, DTILE_TRANSPORTERBEAM); spawn(act, PClass::FindActor(NAME_DukeTransporterBeam));
S_PlayActorSound(TELEPORTER, act); S_PlayActorSound(TELEPORTER, act);
} }
@ -586,7 +586,7 @@ void movetransports_d(void)
if (act->spr.pal == 0) if (act->spr.pal == 0)
{ {
auto k = spawn(Owner, DTILE_TRANSPORTERBEAM); auto k = spawn(Owner, PClass::FindActor(NAME_DukeTransporterBeam));
if (k) S_PlayActorSound(TELEPORTER, k); if (k) S_PlayActorSound(TELEPORTER, k);
} }
@ -667,12 +667,12 @@ void movetransports_d(void)
SetActor(act2, act2->spr.pos); SetActor(act2, act2->spr.pos);
if ((krand() & 255) < 32) if ((krand() & 255) < 32)
spawn(act2, DTILE_WATERSPLASH2); spawn(act2, PClass::FindActor(NAME_DukeWaterSplash));
if (sectlotag == 1) if (sectlotag == 1)
for (int l = 0; l < 9; l++) for (int l = 0; l < 9; l++)
{ {
auto q = spawn(ps[p].GetActor(), DTILE_WATERBUBBLE); auto q = spawn(ps[p].GetActor(), PClass::FindActor(NAME_DukeWaterBubble));
if (q) q->spr.pos.Z += krandf(64); if (q) q->spr.pos.Z += krandf(64);
} }
} }
@ -729,7 +729,7 @@ void movetransports_d(void)
if (sectlotag > 0) if (sectlotag > 0)
{ {
auto k = spawn(act2, DTILE_WATERSPLASH2); auto k = spawn(act2, PClass::FindActor(NAME_DukeWaterSplash));
if (k && sectlotag == 1 && act2->spr.statnum == 4) if (k && sectlotag == 1 && act2->spr.statnum == 4)
{ {
k->vel.X = act2->vel.X * 0.5; k->vel.X = act2->vel.X * 0.5;
@ -752,10 +752,10 @@ void movetransports_d(void)
if (act->spr.pal == 0) if (act->spr.pal == 0)
{ {
auto k = spawn(act, DTILE_TRANSPORTERBEAM); auto k = spawn(act, PClass::FindActor(NAME_DukeTransporterBeam));
if (k) S_PlayActorSound(TELEPORTER, k); if (k) S_PlayActorSound(TELEPORTER, k);
k = spawn(Owner, DTILE_TRANSPORTERBEAM); k = spawn(Owner, PClass::FindActor(NAME_DukeTransporterBeam));
if (k) S_PlayActorSound(TELEPORTER, k); if (k) S_PlayActorSound(TELEPORTER, k);
} }
@ -850,7 +850,7 @@ void handle_se06_d(DDukeActor* actor)
act2->temp_data[4] = actor->temp_data[4]; act2->temp_data[4] = actor->temp_data[4];
} }
} }
handle_se14(actor, true, DTILE_RPG, DTILE_JIBS6); handle_se14(actor, true, PClass::FindActor(NAME_DukeRPG));
} }
@ -970,11 +970,11 @@ void moveeffectors_d(void) //STATNUM 3
break; break;
case SE_14_SUBWAY_CAR: case SE_14_SUBWAY_CAR:
handle_se14(act, true, DTILE_RPG, DTILE_JIBS6); handle_se14(act, true, PClass::FindActor(NAME_DukeRPG));
break; break;
case SE_30_TWO_WAY_TRAIN: case SE_30_TWO_WAY_TRAIN:
handle_se30(act, DTILE_JIBS6); handle_se30(act);
break; break;
case SE_2_EARTHQUAKE: case SE_2_EARTHQUAKE:

View file

@ -484,7 +484,7 @@ void movetransports_r(void)
{ {
if (ps[p].on_ground && sectlotag == 0 && onfloorz && ps[p].jetpack_on == 0) if (ps[p].on_ground && sectlotag == 0 && onfloorz && ps[p].jetpack_on == 0)
{ {
spawn(act, RTILE_TRANSPORTERBEAM); spawn(act, PClass::FindActor(NAME_DukeTransporterBeam));
S_PlayActorSound(TELEPORTER, act); S_PlayActorSound(TELEPORTER, act);
for (k = connecthead; k >= 0; k = connectpoint2[k]) for (k = connecthead; k >= 0; k = connectpoint2[k])
@ -510,7 +510,7 @@ void movetransports_r(void)
ChangeActorSect(act2, Owner->sector()); ChangeActorSect(act2, Owner->sector());
ps[p].setCursector(act2->sector()); ps[p].setCursector(act2->sector());
auto beam = spawn(Owner, RTILE_TRANSPORTERBEAM); auto beam = spawn(Owner, PClass::FindActor(NAME_DukeTransporterBeam));
if (beam) S_PlayActorSound(TELEPORTER, beam); if (beam) S_PlayActorSound(TELEPORTER, beam);
break; break;
@ -598,7 +598,7 @@ void movetransports_r(void)
ChangeActorSect(act2, Owner->sector()); ChangeActorSect(act2, Owner->sector());
if ((krand() & 255) < 32) if ((krand() & 255) < 32)
spawn(ps[p].GetActor(), RTILE_WATERSPLASH2); spawn(ps[p].GetActor(), PClass::FindActor(NAME_DukeWaterSplash));
} }
else if (isRRRA() && k == 2) else if (isRRRA() && k == 2)
{ {
@ -694,7 +694,7 @@ void movetransports_r(void)
if (sectlotag > 0) if (sectlotag > 0)
{ {
auto spawned = spawn(act2, RTILE_WATERSPLASH2); auto spawned = spawn(act2, PClass::FindActor(NAME_DukeWaterSplash));
if (spawned && sectlotag == 1 && act2->spr.statnum == 4) if (spawned && sectlotag == 1 && act2->spr.statnum == 4)
{ {
spawned->vel.X = act2->vel.X * 0.5; spawned->vel.X = act2->vel.X * 0.5;
@ -715,10 +715,10 @@ void movetransports_r(void)
act2->backupang(); act2->backupang();
auto beam = spawn(act, RTILE_TRANSPORTERBEAM); auto beam = spawn(act, PClass::FindActor(NAME_DukeTransporterBeam));
if (beam) S_PlayActorSound(TELEPORTER, beam); if (beam) S_PlayActorSound(TELEPORTER, beam);
beam = spawn(Owner, RTILE_TRANSPORTERBEAM); beam = spawn(Owner, PClass::FindActor(NAME_DukeTransporterBeam));
if (beam) S_PlayActorSound(TELEPORTER, beam); if (beam) S_PlayActorSound(TELEPORTER, beam);
if (Owner->GetOwner() != Owner) if (Owner->GetOwner() != Owner)
@ -907,7 +907,7 @@ void handle_se06_r(DDukeActor *actor)
if ((!isRRRA() || lastlevel) && hulkspawn) if ((!isRRRA() || lastlevel) && hulkspawn)
{ {
hulkspawn--; hulkspawn--;
auto ns = spawn(actor, RTILE_HULK); auto ns = spawn(actor, PClass::FindActor(NAME_RedneckHulk));
if (ns) if (ns)
{ {
ns->spr.pos.Z = ns->sector()->ceilingz; ns->spr.pos.Z = ns->sector()->ceilingz;
@ -989,7 +989,7 @@ void handle_se06_r(DDukeActor *actor)
act2->temp_data[4] = actor->temp_data[4]; act2->temp_data[4] = actor->temp_data[4];
} }
} }
handle_se14(actor, false, RTILE_RPG, RTILE_JIBS6); handle_se14(actor, false, PClass::FindActor(NAME_RedneckDynamiteArrow));
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -1023,11 +1023,11 @@ void moveeffectors_r(void) //STATNUM 3
break; break;
case SE_14_SUBWAY_CAR: case SE_14_SUBWAY_CAR:
handle_se14(act, false, RTILE_RPG, RTILE_JIBS6); handle_se14(act, false, PClass::FindActor(NAME_RedneckDynamiteArrow));
break; break;
case SE_30_TWO_WAY_TRAIN: case SE_30_TWO_WAY_TRAIN:
handle_se30(act, RTILE_JIBS6); handle_se30(act);
break; break;
@ -1437,7 +1437,7 @@ void move_r(DDukeActor *actor, int pnum, int xvel)
} }
if (isRRRA()) if (isRRRA())
{ {
if (actor->sector()->lotag != 1) if (actor->sector()->lotag != ST_1_ABOVE_WATER)
{ {
switch (actor->spr.picnum) switch (actor->spr.picnum)
{ {
@ -1448,7 +1448,7 @@ void move_r(DDukeActor *actor, int pnum, int xvel)
break; break;
} }
} }
else if (actor->sector()->lotag == 1) else if (actor->sector()->lotag == ST_1_ABOVE_WATER)
{ {
switch (actor->spr.picnum) switch (actor->spr.picnum)
{ {
@ -1493,16 +1493,16 @@ void fakebubbaspawn(DDukeActor *actor, player_struct* p)
default: default:
break; break;
case 1: case 1:
spawn(actor, RTILE_PIG); spawn(actor, PClass::FindActor(NAME_RedneckPig));
break; break;
case 2: case 2:
spawn(actor, RTILE_MINION); spawn(actor, PClass::FindActor(NAME_RedneckMinion));
break; break;
case 3: case 3:
spawn(actor, RTILE_CHEER); spawn(actor, PClass::FindActor(NAME_RedneckCheerleader));
break; break;
case 4: case 4:
spawn(actor, RTILE_VIXEN); spawn(actor, PClass::FindActor(NAME_RedneckVixen));
operateactivators(666, p); operateactivators(666, p);
break; break;
} }
@ -1533,7 +1533,7 @@ static int fallspecial(DDukeActor *actor, int playernum)
{ {
if (!actor->isPlayer() && badguy(actor) && actor->spr.pos.Z == actor->floorz - FOURSLEIGHT_F) if (!actor->isPlayer() && badguy(actor) && actor->spr.pos.Z == actor->floorz - FOURSLEIGHT_F)
{ {
spawnguts(actor, PClass::FindActor("DukeJibs6"), 5); spawnguts(actor, PClass::FindActor(NAME_DukeJibs6), 5);
S_PlayActorSound(SQUISHED, actor); S_PlayActorSound(SQUISHED, actor);
addspritetodelete(); addspritetodelete();
} }
@ -1711,7 +1711,7 @@ void mamaspawn(DDukeActor *actor)
if (mamaspawn_count) if (mamaspawn_count)
{ {
mamaspawn_count--; mamaspawn_count--;
spawn(actor, RTILE_RABBIT); spawn(actor, PClass::FindActor(NAME_RedneckRabbit));
} }
} }

View file

@ -50,8 +50,8 @@ void spawnguts(DDukeActor* origin, PClass* type, int count);
void handle_se00(DDukeActor* i); void handle_se00(DDukeActor* i);
void handle_se01(DDukeActor* i); void handle_se01(DDukeActor* i);
void handle_se14(DDukeActor* i, bool checkstat, int RPG, int JIBS6); void handle_se14(DDukeActor* i, bool checkstat, PClassActor* RPG);
void handle_se30(DDukeActor* i, int JIBS6); void handle_se30(DDukeActor* i);
void handle_se02(DDukeActor* i); void handle_se02(DDukeActor* i);
void handle_se03(DDukeActor* i); void handle_se03(DDukeActor* i);
void handle_se04(DDukeActor* i); void handle_se04(DDukeActor* i);

View file

@ -539,9 +539,9 @@ int doincrements_d(player_struct* p)
void checkweapons_d(player_struct* p) void checkweapons_d(player_struct* p)
{ {
static const uint16_t weapon_sprites[MAX_WEAPONS] = { DTILE_KNEE, DTILE_FIRSTGUNSPRITE, DTILE_SHOTGUNSPRITE, static const FName weapon_sprites[MAX_WEAPONS] = { NAME_DukeMeleeAttack, NAME_DukeFirstgunSprite, NAME_DukeShotgunSprite,
DTILE_CHAINGUNSPRITE, DTILE_RPGSPRITE, DTILE_HEAVYHBOMB, DTILE_SHRINKERSPRITE, DTILE_DEVISTATORSPRITE, NAME_DukeChaingunSprite, NAME_DukeRPGSprite, NAME_DukePipeBomb, NAME_DukeShrinkerSprite, NAME_DukeDevastatorSprite,
DTILE_TRIPBOMBSPRITE, DTILE_FREEZESPRITE, DTILE_HEAVYHBOMB, DTILE_SHRINKERSPRITE }; NAME_DukeTripBombSprite, NAME_DukeFreezeSprite, NAME_DukePipeBomb, NAME_DukeShrinkerSprite };
int cw; int cw;
@ -559,7 +559,7 @@ void checkweapons_d(player_struct* p)
if (cw) if (cw)
{ {
if (krand() & 1) if (krand() & 1)
spawn(p->GetActor(), weapon_sprites[cw]); spawn(p->GetActor(), PClass::FindActor(weapon_sprites[cw]));
else switch (cw) else switch (cw)
{ {
case RPG_WEAPON: case RPG_WEAPON:
@ -892,7 +892,7 @@ static void underwater(int snum, ESyncBits actions, double floorz, double ceilin
if (p->scuba_on && (krand() & 255) < 8) if (p->scuba_on && (krand() & 255) < 8)
{ {
auto j = spawn(pact, DTILE_WATERBUBBLE); auto j = spawn(pact, PClass::FindActor(NAME_DukeWaterBubble));
if (j) if (j)
{ {
j->spr.pos += (p->GetActor()->spr.Angles.Yaw.ToVector() + DVector2(4 - (global_random & 8), 4 - (global_random & 8))) * 16; j->spr.pos += (p->GetActor()->spr.Angles.Yaw.ToVector() + DVector2(4 - (global_random & 8), 4 - (global_random & 8))) * 16;
@ -1185,7 +1185,7 @@ static void operateweapon(int snum, ESyncBits actions)
} }
else if (p->kickback_pic == 2) else if (p->kickback_pic == 2)
spawn(pact, DTILE_SHELL); spawn(pact, PClass::FindActor(NAME_DukeShell));
p->kickback_pic++; p->kickback_pic++;
@ -1253,7 +1253,7 @@ static void operateweapon(int snum, ESyncBits actions)
break; break;
case 24: case 24:
{ {
auto j = spawn(pact, DTILE_SHOTGUNSHELL); auto j = spawn(pact, PClass::FindActor(NAME_DukeShotgunShell));
if (j) if (j)
{ {
j->spr.Angles.Yaw += DAngle180; j->spr.Angles.Yaw += DAngle180;
@ -1287,7 +1287,7 @@ static void operateweapon(int snum, ESyncBits actions)
if ((p->kickback_pic % 3) == 0) if ((p->kickback_pic % 3) == 0)
{ {
auto j = spawn(pact, DTILE_SHELL); auto j = spawn(pact, PClass::FindActor(NAME_DukeShell));
if (j) if (j)
{ {
j->spr.Angles.Yaw += DAngle180; j->spr.Angles.Yaw += DAngle180;

View file

@ -666,7 +666,7 @@ void checkweapons_r(player_struct* p)
{ {
if (p->keys[i] == 1) if (p->keys[i] == 1)
{ {
auto j = spawn(p->GetActor(), RTILE_ACCESSCARD); auto j = spawn(p->GetActor(), PClass::FindActor(NAME_RedneckDoorkey));
if (j) switch (i) if (j) switch (i)
{ {
case 1: case 1:
@ -1385,7 +1385,7 @@ static void underwater(int snum, ESyncBits actions, double floorz, double ceilin
if (p->scuba_on && (krand() & 255) < 8) if (p->scuba_on && (krand() & 255) < 8)
{ {
auto j = spawn(pact, RTILE_WATERBUBBLE); auto j = spawn(pact, PClass::FindActor(NAME_DukeWaterBubble));
if (j) if (j)
{ {
j->spr.pos += (p->GetActor()->spr.Angles.Yaw.ToVector() + DVector2(12 - (global_random & 8), 12 - (global_random & 8))) * 16; j->spr.pos += (p->GetActor()->spr.Angles.Yaw.ToVector() + DVector2(12 - (global_random & 8), 12 - (global_random & 8))) * 16;
@ -3060,7 +3060,7 @@ void OffMotorcycle(player_struct *p)
p->TurbCount = 0; p->TurbCount = 0;
p->vel.XY() = p->GetActor()->spr.Angles.Yaw.ToVector() / 2048.; p->vel.XY() = p->GetActor()->spr.Angles.Yaw.ToVector() / 2048.;
p->moto_underwater = 0; p->moto_underwater = 0;
auto spawned = spawn(p->GetActor(), RTILE_EMPTYBIKE); auto spawned = spawn(p->GetActor(), PClass::FindActor(NAME_RedneckEmptyBike));
if (spawned) if (spawned)
{ {
spawned->spr.Angles.Yaw = p->GetActor()->spr.Angles.Yaw; spawned->spr.Angles.Yaw = p->GetActor()->spr.Angles.Yaw;
@ -3114,7 +3114,7 @@ void OffBoat(player_struct *p)
p->TurbCount = 0; p->TurbCount = 0;
p->vel.XY() = p->GetActor()->spr.Angles.Yaw.ToVector() / 2048.; p->vel.XY() = p->GetActor()->spr.Angles.Yaw.ToVector() / 2048.;
p->moto_underwater = 0; p->moto_underwater = 0;
auto spawned = spawn(p->GetActor(), RTILE_EMPTYBOAT); auto spawned = spawn(p->GetActor(), PClass::FindActor(NAME_RedneckEmptyBoat));
if (spawned) if (spawned)
{ {
spawned->spr.Angles.Yaw = p->GetActor()->spr.Angles.Yaw; spawned->spr.Angles.Yaw = p->GetActor()->spr.Angles.Yaw;

View file

@ -177,7 +177,7 @@ void checkhitdefault_d(DDukeActor* targ, DDukeActor* proj)
if (proj->spr.picnum != DTILE_FREEZEBLAST) if (proj->spr.picnum != DTILE_FREEZEBLAST)
//if (actortype[targ->spr.picnum] == 0) //TRANSITIONAL. //if (actortype[targ->spr.picnum] == 0) //TRANSITIONAL.
{ {
auto spawned = spawn(proj, DTILE_JIBS6); auto spawned = spawn(proj, PClass::FindActor(NAME_DukeJibs6));
if (spawned) if (spawned)
{ {
if (proj->spr.pal == 6) if (proj->spr.pal == 6)

View file

@ -175,7 +175,7 @@ void checkhitdefault_r(DDukeActor* targ, DDukeActor* proj)
if (proj->spr.picnum != RTILE_FREEZEBLAST) if (proj->spr.picnum != RTILE_FREEZEBLAST)
//if (actortype[targ->spr.picnum] == 0) //if (actortype[targ->spr.picnum] == 0)
{ {
auto spawned = spawn(proj, RTILE_JIBS6); auto spawned = spawn(proj, PClass::FindActor(NAME_DukeJibs6));
if (spawned) if (spawned)
{ {
if (proj->spr.pal == 6) if (proj->spr.pal == 6)