From 30a3bba6440f5134f655c3d9626759886a7b3f19 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 14 Sep 2022 20:44:10 +0200 Subject: [PATCH] - many CreateActor calls converted to true floats. --- source/games/duke/src/actors_r.cpp | 12 +++++----- source/games/duke/src/player_d.cpp | 34 +++++++++++++-------------- source/games/duke/src/player_r.cpp | 12 +++++----- source/games/duke/src/sectors_d.cpp | 29 +++++++++++++++++------ source/games/duke/src/sectors_r.cpp | 36 +++++++++++++++++++++++------ 5 files changed, 80 insertions(+), 43 deletions(-) diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index 3ab331963..9d4cbdfa7 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -474,15 +474,15 @@ void guts_r(DDukeActor* actor, int gtype, int n, int p) for (j = 0; j < n; j++) { // RANDCORRECT version from RR. - int a = krand() & 2047; - int r1 = krand(); - int r2 = krand(); + DAngle a = randomAngle(); + double zvel = -2 - krandf(8); + double vel = 3 + krandf(2); DVector3 offs; offs.Z = gutz - krandf(16); offs.Y = krandf(16) - 8; offs.X = krandf(16) - 8; // TRANSITIONAL: owned by a player??? - auto spawned = CreateActor(actor->sector(), offs + actor->spr.pos.XY(), gtype, -32, sx, sy, a, 48 + (r2 & 31), -512 - (r1 & 2047), ps[p].GetActor(), 5); + auto spawned = CreateActor(actor->sector(), offs + actor->spr.pos.XY(), gtype, -32, sx, sy, a, vel, zvel, ps[p].GetActor(), 5); if (spawned && pal != 0) spawned->spr.pal = pal; } @@ -1252,7 +1252,7 @@ static void weaponcommon_r(DDukeActor *proj) double zAdd = k * proj->vel.Z / 24; auto x = CreateActor(proj->sector(), proj->spr.pos.plusZ(zAdd) + proj->spr.angle.ToVector() * k * 2., FIRELASER, -40 + (k << 2), - proj->spr.xrepeat, proj->spr.yrepeat, 0, 0, 0, proj->GetOwner(), 5); + proj->spr.xrepeat, proj->spr.yrepeat, nullAngle, 0., 0., proj->GetOwner(), 5); if (x) { @@ -3135,7 +3135,7 @@ void handle_se06_r(DDukeActor *actor) } if (!hulkspawn) { - ns = CreateActor(actor->sector(), DVector3(actor->spr.pos.XY(), actor->sector()->ceilingz + 466.5), 3677, -8, 16, 16, 0, 0, 0, actor, 5); + ns = CreateActor(actor->sector(), DVector3(actor->spr.pos.XY(), actor->sector()->ceilingz + 466.5), 3677, -8, 16, 16, nullAngle, 0., 0., actor, 5); if (ns) { ns->spr.cstat = CSTAT_SPRITE_TRANS_FLIP | CSTAT_SPRITE_TRANSLUCENT; diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index 05651f9a6..d069acd30 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -126,7 +126,7 @@ static void shootfireball(DDukeActor *actor, int p, DVector3 pos, DAngle ang) sizy = 7; } - auto spawned = CreateActor(actor->sector(), pos, FIREBALL, -127, sizx, sizy, ang.Buildang(), int(vel * worldtoint), int(zvel * zworldtoint), actor, (short)4); + auto spawned = CreateActor(actor->sector(), pos, FIREBALL, -127, sizx, sizy, ang, vel, zvel, actor, (short)4); if (spawned) { spawned->spr.extra += (krand() & 7); @@ -263,7 +263,7 @@ static void shootknee(DDukeActor* actor, int p, DVector3 pos, DAngle ang) { if (hit.hitWall || hit.actor()) { - auto knee = CreateActor(hit.hitSector, hit.hitpos, KNEE, -15, 0, 0, ang.Buildang(), 32, 0, actor, 4); + auto knee = CreateActor(hit.hitSector, hit.hitpos, KNEE, -15, 0, 0, ang, 2., 0., actor, 4); if (knee) { knee->spr.extra += (krand() & 7); @@ -418,7 +418,7 @@ static void shootweapon(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int DDukeActor* spark; if (p >= 0) { - spark = CreateActor(hit.hitSector, hit.hitpos, SHOTSPARK1, -15, 10, 10, ang.Buildang(), 0, 0, actor, 4); + spark = CreateActor(hit.hitSector, hit.hitpos, SHOTSPARK1, -15, 10, 10, ang, 0., 0., actor, 4); if (!spark) return; spark->spr.extra = ScriptCode[gs.actorinfo[atwith].scriptaddress]; @@ -539,7 +539,7 @@ static void shootweapon(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int } else { - spark = CreateActor(hit.hitSector, hit.hitpos, SHOTSPARK1, -15, 24, 24, ang.Buildang(), 0, 0, actor, 4); + spark = CreateActor(hit.hitSector, hit.hitpos, SHOTSPARK1, -15, 24, 24, ang, 0., 0., actor, 4); if (spark) { spark->spr.extra = ScriptCode[gs.actorinfo[atwith].scriptaddress]; @@ -659,7 +659,7 @@ static void shootstuff(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int a while (scount > 0) { - auto spawned = CreateActor(sect, pos, atwith, -127, sizx, sizy, ang.Buildang(), int(vel * worldtoint), int(zvel * zworldtoint), actor, 4); + auto spawned = CreateActor(sect, pos, atwith, -127, sizx, sizy, ang, vel, zvel, actor, 4); if (!spawned) return; spawned->spr.extra += (krand() & 7); @@ -754,7 +754,7 @@ static void shootrpg(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int atw if (p < 0) aimed = nullptr; auto offset = (ang + DAngle1 * 61).ToVector() * (1024 / 448); - auto spawned = CreateActor(sect, pos.plusZ(-1) + offset, atwith, 0, 14, 14, ang.Buildang(), int(vel * worldtoint), int(zvel * zworldtoint), actor, 4); + auto spawned = CreateActor(sect, pos.plusZ(-1) + offset, atwith, 0, 14, 14, ang, vel, zvel, actor, 4); if (!spawned) return; @@ -884,7 +884,7 @@ static void shootlaser(DDukeActor* actor, int p, DVector3 pos, DAngle ang) if (j == 1) { - auto bomb = CreateActor(hit.hitSector, hit.hitpos, TRIPBOMB, -16, 4, 5, ang.Buildang(), 0, 0, actor, STAT_STANDABLE); + auto bomb = CreateActor(hit.hitSector, hit.hitpos, TRIPBOMB, -16, 4, 5, ang, 0., 0., actor, STAT_STANDABLE); if (!bomb) return; if (isWW2GI()) { @@ -984,7 +984,7 @@ static void shootgrowspark(DDukeActor* actor, int p, DVector3 pos, DAngle ang) actor->spr.cstat |= CSTAT_SPRITE_BLOCK_ALL; - auto spark = CreateActor(sect, hit.hitpos, GROWSPARK, -16, 28, 28, ang.Buildang(), 0, 0, actor, 1); + auto spark = CreateActor(sect, hit.hitpos, GROWSPARK, -16, 28, 28, ang, 0., 0., actor, 1); if (!spark) return; spark->spr.pal = 2; @@ -1027,7 +1027,7 @@ static void shootmortar(DDukeActor* actor, int p, const DVector3& pos, DAngle an zvel = -4; double vel = x / 16.; - CreateActor(sect, pos.plusZ(-6) + ang.ToVector() * 4, atwith, -64, 32, 32, ang.Buildang(), int(vel * worldtoint), int(zvel * zworldtoint), actor, 1); + CreateActor(sect, pos.plusZ(-6) + ang.ToVector() * 4, atwith, -64, 32, 32, ang, vel, zvel, actor, 1); } //--------------------------------------------------------------------------- @@ -1063,7 +1063,7 @@ static void shootshrinker(DDukeActor* actor, int p, const DVector3& pos, DAngle else zvel = 0; auto spawned = CreateActor(actor->sector(), - pos.plusZ(2) + ang.ToVector() * 0.25, SHRINKSPARK, -16, 28, 28, ang.Buildang(), 768, int(zvel * zworldtoint), actor, 4); + pos.plusZ(2) + ang.ToVector() * 0.25, SHRINKSPARK, -16, 28, 28, ang, 48., zvel, actor, 4); if (spawned) { @@ -2219,7 +2219,7 @@ static void operateweapon(int snum, ESyncBits actions) { auto p = &ps[snum]; auto pact = p->GetActor(); - int i, k; + int zvel, vel; // already firing... @@ -2238,24 +2238,24 @@ static void operateweapon(int snum, ESyncBits actions) if (p->on_ground && (actions & SB_CROUCH)) { - k = 15; - i = MulScale(p->horizon.sum().asq16(), 20, 16); + vel = 15/16.; + zvel = MulScale(p->horizon.sum().asq16(), 20, 16); } else { - k = 140; - i = -512 - MulScale(p->horizon.sum().asq16(), 20, 16); + vel = 140/16.; + zvel = -512 - MulScale(p->horizon.sum().asq16(), 20, 16); } auto spawned = CreateActor(p->cursector, p->pos + p->angle.ang.ToVector() * 16, HEAVYHBOMB, -16, 9, 9, - p->angle.ang.Buildang(), (k + (p->hbomb_hold_delay << 5)), i, pact, 1); + p->angle.ang.Buildang(), (vel + (p->hbomb_hold_delay << 5)), zvel, pact, 1); if (isNam()) { spawned->spr.extra = MulScale(krand(), NAM_GRENADE_LIFETIME_VAR, 14); } - if (k == 15) + if (vel == 15) { spawned->spr.yint = 3; spawned->spr.pos.Z += 8; diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 5f4823151..7da4515ce 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -139,13 +139,13 @@ static void shootmelee(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int a DDukeActor* wpn; if (isRRRA() && atwith == SLINGBLADE) { - wpn = CreateActor(hit.hitSector, hit.hitpos, SLINGBLADE, -15, 0, 0, ang.Buildang(), 32, 0, actor, 4); + wpn = CreateActor(hit.hitSector, hit.hitpos, SLINGBLADE, -15, 0, 0, ang, 32., 0., actor, 4); if (!wpn) return; wpn->spr.extra += 50; } else { - wpn = CreateActor(hit.hitSector, hit.hitpos, KNEE, -15, 0, 0, ang.Buildang(), 32, 0, actor, 4); + wpn = CreateActor(hit.hitSector, hit.hitpos, KNEE, -15, 0, 0, ang, 32., 0., actor, 4); if (!wpn) return; wpn->spr.extra += (krand() & 7); } @@ -301,7 +301,7 @@ static void shootweapon(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int DDukeActor* spark; if (p >= 0) { - spark = CreateActor(hit.hitSector, hit.hitpos, SHOTSPARK1, -15, 10, 10, ang.Buildang(), 0, 0, actor, 4); + spark = CreateActor(hit.hitSector, hit.hitpos, SHOTSPARK1, -15, 10, 10, ang, 0., 0., actor, 4); if (!spark) return; spark->spr.extra = ScriptCode[gs.actorinfo[atwith].scriptaddress]; spark->spr.extra += (krand() % 6); @@ -428,7 +428,7 @@ static void shootweapon(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int } else { - spark = CreateActor(hit.hitSector, hit.hitpos, SHOTSPARK1, -15, 24, 24, ang.Buildang(), 0, 0, actor, 4); + spark = CreateActor(hit.hitSector, hit.hitpos, SHOTSPARK1, -15, 24, 24, ang, 0., 0., actor, 4); if (!spark) return; spark->spr.extra = ScriptCode[gs.actorinfo[atwith].scriptaddress]; @@ -571,7 +571,7 @@ static void shootstuff(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int a while (scount > 0) { - auto spawned = CreateActor(sect, pos, atwith, -127, sizx, sizy, ang.Buildang(), int(vel * worldtoint), int(zvel * zworldtoint), actor, 4); + auto spawned = CreateActor(sect, pos, atwith, -127, sizx, sizy, ang, vel, zvel, actor, 4); if (!spawned) return; spawned->spr.extra += (krand() & 7); spawned->spr.cstat = CSTAT_SPRITE_YCENTER; @@ -671,7 +671,7 @@ static void shootrpg(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int atw } auto offset = (ang + DAngle1 * 61).ToVector() * (1024 / 448.); - auto spawned = CreateActor(sect, pos.plusZ(-1) + offset, atwith, 0, 14, 14, ang.Buildang(), int(vel * worldtoint), int(zvel * zworldtoint), actor, 4); + auto spawned = CreateActor(sect, pos.plusZ(-1) + offset, atwith, 0, 14, 14, ang, vel, zvel, actor, 4); if (!spawned) return; if (isRRRA()) diff --git a/source/games/duke/src/sectors_d.cpp b/source/games/duke/src/sectors_d.cpp index feba74004..ca70ab55a 100644 --- a/source/games/duke/src/sectors_d.cpp +++ b/source/games/duke/src/sectors_d.cpp @@ -669,12 +669,12 @@ void checkhitwall_d(DDukeActor* spr, walltype* wal, const DVector3& pos, int atw if (sptr == nullptr) return; DDukeActor* spawned; if (atwith == -1) - spawned = CreateActor(sptr, pos, FORCERIPPLE, -127, 8, 8, 0, 0, 0, spr, 5); + spawned = CreateActor(sptr, pos, FORCERIPPLE, -127, 8, 8, nullAngle, 0., 0., spr, 5); else { if (atwith == CHAINGUN) - spawned = CreateActor(sptr, pos, FORCERIPPLE, -127, 16 + spr->spr.xrepeat, 16 + spr->spr.yrepeat, 0, 0, 0, spr, 5); - else spawned = CreateActor(sptr, pos, FORCERIPPLE, -127, 32, 32, 0, 0, 0, spr, 5); + spawned = CreateActor(sptr, pos, FORCERIPPLE, -127, 16 + spr->spr.xrepeat, 16 + spr->spr.yrepeat, nullAngle, 0., 0., spr, 5); + else spawned = CreateActor(sptr, pos, FORCERIPPLE, -127, 32, 32, nullAngle, 0., 0., spr, 5); } if (spawned) { @@ -709,7 +709,7 @@ void checkhitwall_d(DDukeActor* spr, walltype* wal, const DVector3& pos, int atw if (wal->twoSided()) wal->nextWall()->cstat = 0; - auto spawned = CreateActor(sptr, pos, SECTOREFFECTOR, 0, 0, 0, ps[0].angle.ang.Buildang(), 0, 0, spr, 3); + auto spawned = CreateActor(sptr, pos, SECTOREFFECTOR, 0, 0, 0, ps[0].angle.ang, 0., 0., spr, 3); if (spawned) { spawned->spr.lotag = SE_128_GLASS_BREAKING; @@ -1078,7 +1078,11 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj) { for (k = 0; k < 64; k++) { - auto spawned = CreateActor(targ->sector(), targ->spr.pos.plusZ(-krandf(48)), SCRAP3 + (krand() & 3), -8, 48, 48, krand() & 2047, (krand() & 63) + 64, -(krand() & 4095) - (targ->int_zvel() >> 2), targ, 5); + auto a = randomAngle(); + auto vel = krandf(4) + 4; + auto zvel = -krandf(16) - targ->vel.Z * 0.25; + + auto spawned = CreateActor(targ->sector(), targ->spr.pos.plusZ(-48), SCRAP3 + (krand() & 3), -8, 48, 48, a, vel, zvel, targ, 5); spawned->spr.pal = 8; } @@ -1091,7 +1095,12 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj) case HANGLIGHT: case GENERICPOLE2: for (k = 0; k < 6; k++) - CreateActor(targ->sector(), targ->spr.pos.plusZ(-8), SCRAP1 + (krand() & 15), -8, 48, 48, krand() & 2047, (krand() & 63) + 64, -(krand() & 4095) - (targ->int_zvel() >> 2), targ, 5); + { + auto a = randomAngle(); + auto vel = krandf(4) + 4; + auto zvel = -krandf(16) - targ->vel.Z * 0.25; + CreateActor(targ->sector(), targ->spr.pos.plusZ(-8), SCRAP1 + (krand() & 15), -8, 48, 48, a, vel, zvel, targ, 5); + } S_PlayActorSound(GLASS_HEAVYBREAK, targ); deletesprite(targ); break; @@ -1121,8 +1130,14 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj) if (gs.actorinfo[SHOTSPARK1].scriptaddress && proj->spr.extra != ScriptCode[gs.actorinfo[SHOTSPARK1].scriptaddress]) { for (j = 0; j < 15; j++) + { + auto a = randomAngle(); + auto vel = krandf(8) + 4; + auto zvel = -krandf(2) - 1; + CreateActor(targ->sector(), DVector3(targ->spr.pos.XY(), targ->sector()->floorz - 12 - j * 2), SCRAP1 + (krand() & 15), -8, 64, 64, - krand() & 2047, (krand() & 127) + 64, -(krand() & 511) - 256, targ, 5); + a, vel, zvel, targ, 5); + } spawn(targ, EXPLOSION2); deletesprite(targ); } diff --git a/source/games/duke/src/sectors_r.cpp b/source/games/duke/src/sectors_r.cpp index 17674a8f3..ac43f976b 100644 --- a/source/games/duke/src/sectors_r.cpp +++ b/source/games/duke/src/sectors_r.cpp @@ -934,7 +934,10 @@ static void lotsofpopcorn(DDukeActor *actor, walltype* wal, int n) for (int j = n - 1; j >= 0; j--) { DAngle a = actor->spr.angle - DAngle45 + DAngle180 + randomAngle(90); - CreateActor(actor->sector(), actor->spr.pos, POPCORN, -32, 36, 36, a.Buildang(), 32 + (krand() & 63), 1024 - (krand() & 1023), actor, 5); + auto vel = krandf(4) + 2; + auto zvel = 4 - krandf(4); + + CreateActor(actor->sector(), actor->spr.pos, POPCORN, -32, 36, 36, a, vel, zvel, actor, 5); } return; } @@ -956,7 +959,10 @@ static void lotsofpopcorn(DDukeActor *actor, walltype* wal, int n) if (abs(z) > 32) z = actor->spr.pos.Z - 32 + krandf(64); DAngle a = actor->spr.angle - DAngle180; - CreateActor(actor->sector(), DVector3(pos, z), POPCORN, -32, 36, 36, a.Buildang(), 32 + (krand() & 63), -(krand() & 1023), actor, 5); + auto vel = krandf(4) + 2; + auto zvel = -krandf(4); + + CreateActor(actor->sector(), DVector3(pos, z), POPCORN, -32, 36, 36, a, vel, zvel, actor, 5); } } } @@ -1011,7 +1017,7 @@ void checkhitwall_r(DDukeActor* spr, walltype* wal, const DVector3& pos, int atw if (wal->twoSided()) wal->nextWall()->cstat = 0; - auto spawned = CreateActor(sptr, pos, SECTOREFFECTOR, 0, 0, 0, ps[0].angle.ang.Buildang(), 0, 0, spr, 3); + auto spawned = CreateActor(sptr, pos, SECTOREFFECTOR, 0, 0, 0, ps[0].angle.ang, 0., 0., spr, 3); if (spawned) { spawned->spr.lotag = SE_128_GLASS_BREAKING; @@ -1032,7 +1038,7 @@ void checkhitwall_r(DDukeActor* spr, walltype* wal, const DVector3& pos, int atw if (wal->twoSided()) wal->nextWall()->cstat = 0; - auto spawned = CreateActor(sptr, pos, SECTOREFFECTOR, 0, 0, 0, ps[0].angle.ang.Buildang(), 0, 0, spr, 3); + auto spawned = CreateActor(sptr, pos, SECTOREFFECTOR, 0, 0, 0, ps[0].angle.ang, 0., 0., spr, 3); if (spawned) { spawned->spr.lotag = SE_128_GLASS_BREAKING; @@ -2047,7 +2053,13 @@ void checkhitsprite_r(DDukeActor* targ, DDukeActor* proj) lotsofglass(targ, nullptr, 10); targ->spr.picnum++; for (k = 0; k < 6; k++) - CreateActor(targ->sector(), targ->spr.pos.plusZ(-8), SCRAP6 + (krand() & 15), -8, 48, 48, krand() & 2047, (krand() & 63) + 64, -(krand() & 4095) - (targ->int_zvel() >> 2), targ, 5); + { + auto a = randomAngle(); + auto vel = krandf(4) + 4; + auto zvel = -krandf(16) - targ->vel.Z * 0.25; + + CreateActor(targ->sector(), targ->spr.pos.plusZ(-8), SCRAP6 + (krand() & 15), -8, 48, 48, a, vel, zvel, targ, 5); + } break; case BOWLINGBALL: proj->vel.X = targ->vel.X * 0.75; @@ -2114,7 +2126,11 @@ void checkhitsprite_r(DDukeActor* targ, DDukeActor* proj) { for (k = 0; k < 64; k++) { - auto spawned = CreateActor(targ->sector(), targ->spr.pos.plusZ(-krandf(48)), SCRAP6 + (krand() & 3), -8, 48, 48, krand() & 2047, (krand() & 63) + 64, -(krand() & 4095) - (targ->int_zvel() >> 2), targ, 5); + auto a = randomAngle(); + auto vel = krandf(4) + 4; + auto zvel = -krandf(16) - targ->vel.Z * 0.25; + + auto spawned = CreateActor(targ->sector(), targ->spr.pos.plusZ(-krandf(48)), SCRAP6 + (krand() & 3), -8, 48, 48, a, vel, zvel, targ, 5); if (spawned) spawned->spr.pal = 8; } @@ -2146,8 +2162,14 @@ void checkhitsprite_r(DDukeActor* targ, DDukeActor* proj) if (gs.actorinfo[SHOTSPARK1].scriptaddress && proj->spr.extra != ScriptCode[gs.actorinfo[SHOTSPARK1].scriptaddress]) { for (j = 0; j < 15; j++) + { + auto a = randomAngle(); + auto vel = krandf(8) + 4; + auto zvel = -krandf(2) - 1; + CreateActor(targ->sector(), DVector3(targ->spr.pos.XY(), targ->sector()->floorz - 12 - j * 2), SCRAP1 + (krand() & 15), -8, 64, 64, - krand() & 2047, (krand() & 127) + 64, -(krand() & 511) - 256, targ, 5); + a, vel, zvel, targ, 5); + } spawn(targ, EXPLOSION2); deletesprite(targ); }