From 38a8e15ff96342a967a31388c9758751bfc36dcf Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 12 Sep 2022 22:58:52 +0200 Subject: [PATCH] - floatified most of movetripbomb and ovel --- source/games/duke/src/actors.cpp | 7 +++---- source/games/duke/src/actors_d.cpp | 29 +++++++++++++++-------------- source/games/duke/src/gameexec.cpp | 22 +++++++++------------- source/games/duke/src/spawn.cpp | 6 ++---- source/games/duke/src/types.h | 2 +- 5 files changed, 30 insertions(+), 36 deletions(-) diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index d57b93e4b..62e78db2d 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -4945,7 +4945,7 @@ DAngle furthestangle(DDukeActor *actor, int angs) // //--------------------------------------------------------------------------- -int furthestcanseepoint(DDukeActor *actor, DDukeActor* tosee, int* dax, int* day) +int furthestcanseepoint(DDukeActor *actor, DDukeActor* tosee, DVector2& pos) { int j, angincs; HitInfo hit{}; @@ -4966,8 +4966,7 @@ int furthestcanseepoint(DDukeActor *actor, DDukeActor* tosee, int* dax, int* day if (d < da && hit.hitSector) if (cansee(hit.hitpos, hit.hitSector, actor->spr.pos.plusZ(-16), actor->sector())) { - *dax = hit.int_hitpos().X; - *day = hit.int_hitpos().Y; + pos = hit.hitpos.XY(); return 1; } } @@ -5012,7 +5011,7 @@ void alterang(int ang, DDukeActor* actor, int playernum) auto Owner = actor->GetOwner(); if (Owner->isPlayer()) - goalang = VecToAngle(actor->ovel.X - actor->int_pos().X, actor->ovel.Y - actor->int_pos().Y); + goalang = VecToAngle(actor->ovel - actor->spr.pos.XY()); else goalang = VecToAngle(Owner->spr.pos.XY() - actor->spr.pos.XY()); diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index f6b118eae..0591f8f73 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -802,7 +802,8 @@ void movefallers_d(void) static void movetripbomb(DDukeActor *actor) { - int j, x; + int j; + double x; int lTripBombControl = GetGameVar("TRIPBOMB_CONTROL", TRIPBOMB_TRIPWIRE, nullptr, -1).safeValue(); if (lTripBombControl & TRIPBOMB_TIMER) { @@ -824,14 +825,14 @@ static void movetripbomb(DDukeActor *actor) { S_PlayActorSound(LASERTRIP_EXPLODE, actor); for (j = 0; j < 5; j++) RANDOMSCRAP(actor); - x = actor->spr.extra; - fi.hitradius(actor, gs.tripbombblastradius, x >> 2, x >> 1, x - (x >> 2), x); + int ex = actor->spr.extra; + fi.hitradius(actor, gs.tripbombblastradius, ex >> 2, ex >> 1, ex - (ex >> 2), ex); auto spawned = spawn(actor, EXPLOSION2); if (spawned) { spawned->spr.angle = actor->spr.angle; - spawned->set_int_xvel(348); + spawned->vel.X = 348 / 16.; ssp(spawned, CLIPMASK0); } @@ -849,25 +850,25 @@ static void movetripbomb(DDukeActor *actor) { x = actor->spr.extra; actor->spr.extra = 1; - int16_t l = actor->int_ang(); + auto ang = actor->spr.angle; j = fi.ifhitbyweapon(actor); if (j >= 0) { actor->temp_data[2] = 16; } actor->spr.extra = x; - actor->set_int_ang(l); + actor->spr.angle = ang; } if (actor->temp_data[0] < 32) { findplayer(actor, &x); - if (x > 768) actor->temp_data[0]++; + if (x > 48) actor->temp_data[0]++; else if (actor->temp_data[0] > 16) actor->temp_data[0]++; } if (actor->temp_data[0] == 32) { - int16_t l = actor->int_ang(); + auto ang = actor->spr.angle; actor->spr.angle = actor->temp_angle; actor->temp_pos.XY() = actor->spr.pos.XY(); @@ -882,11 +883,11 @@ static void movetripbomb(DDukeActor *actor) ChangeActorSect(actor, curSect); DDukeActor* hit; - x = hitasprite(actor, &hit); + x = hitasprite(actor, &hit) * inttoworld; actor->ovel.X = x; - actor->set_int_ang(l); + actor->spr.angle = ang; if (lTripBombControl & TRIPBOMB_TRIPWIRE) { @@ -900,12 +901,12 @@ static void movetripbomb(DDukeActor *actor) spawned->spr.hitag = actor->spr.hitag; spawned->temp_data[1] = spawned->int_pos().Z; - if (x < 1024) + if (x < 64) { - spawned->spr.xrepeat = x >> 5; + spawned->spr.xrepeat = x / 2; break; } - x -= 1024; + x -= 64; actor->spr.pos += actor->temp_angle.ToVector() * 64; updatesectorneighbor(actor->spr.pos, &curSect, 128); @@ -943,7 +944,7 @@ static void movetripbomb(DDukeActor *actor) actor->spr.pos.Z -= 3; SetActor(actor, actor->spr.pos); - x = hitasprite(actor, nullptr); + x = hitasprite(actor, nullptr) * inttoworld; actor->spr.pos.XY() = actor->temp_pos.XY(); actor->spr.pos.Z += 3; diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index 9fd99c90b..3d1692962 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -80,7 +80,7 @@ struct ParseState void parseifelse(int condition); }; -int furthestcanseepoint(DDukeActor* i, DDukeActor* ts, int* dax, int* day); +int furthestcanseepoint(DDukeActor* i, DDukeActor* ts, DVector2& pos); bool ifsquished(DDukeActor* i, int p); void fakebubbaspawn(DDukeActor* actor, int g_p); void tearitup(sectortype* sect); @@ -1307,12 +1307,12 @@ void DoActor(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, else SetGameVarID(lVar2, act->ceilingz * (1/zmaptoworld), sActor, sPlayer); break; case ACTOR_HTLASTVX: - if (bSet) act->ovel.X = lValue; - else SetGameVarID(lVar2, act->ovel.X, sActor, sPlayer); + if (bSet) act->ovel.X = lValue * maptoworld; + else SetGameVarID(lVar2, act->ovel.X / maptoworld, sActor, sPlayer); break; case ACTOR_HTLASTVY: - if (bSet) act->ovel.Y = lValue; - else SetGameVarID(lVar2, act->ovel.Y, sActor, sPlayer); + if (bSet) act->ovel.Y = lValue * maptoworld; + else SetGameVarID(lVar2, act->ovel.Y / maptoworld, sActor, sPlayer); break; case ACTOR_HTG_T0: if (bSet) act->temp_data[0] = lValue; @@ -1475,14 +1475,13 @@ static bool ifcansee(DDukeActor* actor, int pnum) { // search around for target player // also modifies 'target' x&y if found. - j = furthestcanseepoint(actor, tosee, &actor->ovel.X, &actor->ovel.Y); + j = furthestcanseepoint(actor, tosee, actor->ovel); } else { // else, they did see it. // save where we were looking.. - actor->ovel.X = tosee->int_pos().X; - actor->ovel.Y = tosee->int_pos().Y; + actor->ovel = tosee->spr.pos; } if (j == 1 && (actor->spr.statnum == STAT_ACTOR || actor->spr.statnum == STAT_STANDABLE)) @@ -3120,14 +3119,11 @@ int ParseState::parse(void) } case concmd_getangletotarget: { - int i; - int ang; - insptr++; - i = *(insptr++); // ID of def + int i = *(insptr++); // ID of def // g_ac->lastvx and lastvy are last known location of target. - ang = getangle(g_ac->ovel.X - g_ac->int_pos().X, g_ac->ovel.Y - g_ac->int_pos().Y); + int ang = VecToAngle(g_ac->ovel - g_ac->spr.pos.XY()).Buildang(); SetGameVarID(i, ang, g_ac, g_p); break; } diff --git a/source/games/duke/src/spawn.cpp b/source/games/duke/src/spawn.cpp index b5730081c..cd1399d69 100644 --- a/source/games/duke/src/spawn.cpp +++ b/source/games/duke/src/spawn.cpp @@ -81,8 +81,7 @@ DDukeActor* CreateActor(sectortype* whatsectp, const DVector3& pos, int s_pn, in act->spr.lotag = 0; act->backuploc(); - act->ovel.X = 0; - act->ovel.Y = 0; + act->ovel.Zero(); act->timetosleep = 0; act->actorstayput = nullptr; @@ -154,8 +153,7 @@ bool initspriteforspawn(DDukeActor* act) act->floorz = act->sector()->floorz; act->ceilingz = act->sector()->ceilingz; - act->ovel.X = 0; - act->ovel.Y = 0; + act->ovel.Zero(); act->actorstayput = nullptr; act->temp_data[0] = act->temp_data[1] = act->temp_data[2] = act->temp_data[3] = act->temp_data[4] = act->temp_data[5] = 0; diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index 5c4708cca..1b733d8e7 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -49,7 +49,7 @@ public: short attackertype, hitextra, movflag; short tempang, dispicnum, basepicnum; short timetosleep; - vec2_t ovel; + DVector2 ovel; DAngle hitang; double floorz, ceilingz; union