From cceecb4ab6cd919b358481409a23eeb0ce6a8570 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 29 Aug 2022 22:59:44 +0200 Subject: [PATCH] - use ToVector where appropriate --- source/games/blood/src/animatesprite.cpp | 3 +-- source/games/duke/src/actors.cpp | 5 ++--- source/games/duke/src/actors_d.cpp | 9 ++++----- source/games/duke/src/animatesprites_d.cpp | 6 ++---- source/games/duke/src/animatesprites_r.cpp | 6 ++---- source/games/duke/src/sectors_d.cpp | 4 ++-- source/games/duke/src/sectors_r.cpp | 2 +- source/games/duke/src/spawn.cpp | 2 +- source/games/sw/src/actor.cpp | 2 +- 9 files changed, 16 insertions(+), 23 deletions(-) diff --git a/source/games/blood/src/animatesprite.cpp b/source/games/blood/src/animatesprite.cpp index cb9810650..35d4dfbfe 100644 --- a/source/games/blood/src/animatesprite.cpp +++ b/source/games/blood/src/animatesprite.cpp @@ -103,8 +103,7 @@ tspritetype* viewInsertTSprite(tspriteArray& tsprites, sectortype* pSector, int pTSprite->ownerActor = parentTSprite->ownerActor; pTSprite->angle = parentTSprite->angle; } - pos.X += gCameraAng.Cos() * 2; - pos.Y += gCameraAng.Sin() * 2; + pos.XY() += gCameraAng.ToVector() * 2; pTSprite->pos = pos; return pTSprite; } diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 788e08ca1..1da2a65bf 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -790,8 +790,7 @@ void movecrane(DDukeActor *actor, int crane) { auto ang = ps[p].angle.ang; ps[p].backupxyz(); - ps[p].pos.X = actor->spr.pos.X - CRANE_STEP * ang.Cos(); - ps[p].pos.Y = actor->spr.pos.Y - CRANE_STEP * ang.Sin(); + ps[p].pos.XY() = actor->spr.pos.XY() - CRANE_STEP * ang.ToVector(); ps[p].pos.Z = actor->spr.pos.Z + 2; SetActor(ps[p].GetActor(), ps[p].pos); ps[p].setCursector(ps[p].GetActor()->sector()); @@ -4244,7 +4243,7 @@ void handle_se26(DDukeActor* actor) double zvel = actor->spr.zvel * zinttoworld; actor->spr.xvel = 32; - DVector2 vect = { 2 * actor->spr.angle.Cos(), 2 * actor->spr.angle.Sin() }; // was: (32 * bsin) >> 14 + DVector2 vect = 2 * actor->spr.angle.ToVector(); // was: (32 * bsin) >> 14 actor->spr.shade++; if (actor->spr.shade > 7) diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index 67bc288f8..df3a7f6dc 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -872,7 +872,7 @@ static void movetripbomb(DDukeActor *actor) actor->spr.angle = actor->temp_angle; actor->temp_data[3] = actor->int_pos().X; actor->temp_data[4] = actor->int_pos().Y; - actor->spr.pos += actor->temp_angle.ToVector(2); + actor->spr.pos += actor->temp_angle.ToVector() * 2; actor->spr.pos.Z -= 3; // Laser fix from EDuke32. @@ -908,7 +908,7 @@ static void movetripbomb(DDukeActor *actor) } x -= 1024; - actor->spr.pos += actor->temp_angle.ToVector(64); + actor->spr.pos += actor->temp_angle.ToVector() * 64; updatesectorneighbor(actor->spr.pos, &curSect, 128); if (curSect == nullptr) @@ -941,7 +941,7 @@ static void movetripbomb(DDukeActor *actor) actor->temp_data[3] = actor->int_pos().X; actor->temp_data[4] = actor->int_pos().Y; - actor->spr.pos += actor->temp_angle.ToVector(2); + actor->spr.pos += actor->temp_angle.ToVector() * 2; actor->spr.pos.Z -= 3; SetActor(actor, actor->spr.pos); @@ -2222,8 +2222,7 @@ static void greenslime(DDukeActor *actor) actor->spr.xrepeat = 20 + bsin(actor->temp_data[1], -13); actor->spr.yrepeat = 15 + bsin(actor->temp_data[1], -13); - actor->spr.pos.X = ps[p].pos.X + ps[p].angle.ang.Cos() * 8; - actor->spr.pos.Y = ps[p].pos.Y + ps[p].angle.ang.Sin() * 8; + actor->spr.pos.XY() = ps[p].pos.XY() + ps[p].angle.ang.ToVector() * 8; return; } diff --git a/source/games/duke/src/animatesprites_d.cpp b/source/games/duke/src/animatesprites_d.cpp index d75bdbe2d..a14184ed3 100644 --- a/source/games/duke/src/animatesprites_d.cpp +++ b/source/games/duke/src/animatesprites_d.cpp @@ -221,8 +221,7 @@ void animatesprites_d(tspriteArray& tsprites, int x, int y, int a, int smoothrat else { t->angle = VecToAngle(viewVec - t->pos.XY()); - t->pos.X = OwnerAc->spr.pos.X + t->angle.Cos(); - t->pos.Y = OwnerAc->spr.pos.Y + t->angle.Sin(); + t->pos.XY() = OwnerAc->spr.pos.XY() + t->angle.ToVector(); } } break; @@ -597,8 +596,7 @@ void animatesprites_d(tspriteArray& tsprites, int x, int y, int a, int smoothrat { // Alter the shadow's position so that it appears behind the sprite itself. auto look = VecToAngle(shadowspr->pos.XY() - ps[screenpeek].pos.XY()); - shadowspr->pos.X += look.Cos() * 2; - shadowspr->pos.Y += look.Sin() * 2; + shadowspr->pos.XY() += look.ToVector() * 2; } } } diff --git a/source/games/duke/src/animatesprites_r.cpp b/source/games/duke/src/animatesprites_r.cpp index 8b050c24d..cfa62cac4 100644 --- a/source/games/duke/src/animatesprites_r.cpp +++ b/source/games/duke/src/animatesprites_r.cpp @@ -215,8 +215,7 @@ void animatesprites_r(tspriteArray& tsprites, int x, int y, int a, int smoothrat else { t->angle = VecToAngle(viewVec - t->pos.XY()); - t->pos.X = OwnerAc->spr.pos.X + t->angle.Cos(); - t->pos.Y = OwnerAc->spr.pos.Y + t->angle.Sin(); + t->pos.XY() = OwnerAc->spr.pos.XY() + t->angle.ToVector(); } } break; @@ -752,8 +751,7 @@ void animatesprites_r(tspriteArray& tsprites, int x, int y, int a, int smoothrat { // Alter the shadow's position so that it appears behind the sprite itself. auto look = VecToAngle(shadowspr->pos.XY() - ps[screenpeek].pos.XY()); - shadowspr->pos.X += look.Cos() * 2; - shadowspr->pos.Y += look.Sin() * 2; + shadowspr->pos.XY() += look.ToVector() * 2; } } } diff --git a/source/games/duke/src/sectors_d.cpp b/source/games/duke/src/sectors_d.cpp index d25f74ad1..51c794b7b 100644 --- a/source/games/duke/src/sectors_d.cpp +++ b/source/games/duke/src/sectors_d.cpp @@ -921,12 +921,12 @@ void checkplayerhurt_d(player_struct* p, const Collision& coll) p->vel.Y = -p->angle.ang.Sin() * (1 << 22); S_PlayActorSound(DUKE_LONGTERM_PAIN, p->GetActor()); - fi.checkhitwall(p->GetActor(), wal, p->pos + DVector2(p->angle.ang.Cos() * 2, p->angle.ang.Sin() * 2), -1); + fi.checkhitwall(p->GetActor(), wal, p->pos + p->angle.ang.ToVector() * 2, -1); break; case BIGFORCE: p->hurt_delay = 26; - fi.checkhitwall(p->GetActor(), wal, p->pos + DVector2(p->angle.ang.Cos() * 2, p->angle.ang.Sin() * 2), -1); + fi.checkhitwall(p->GetActor(), wal, p->pos + p->angle.ang.ToVector() * 2, -1); break; } diff --git a/source/games/duke/src/sectors_r.cpp b/source/games/duke/src/sectors_r.cpp index 8d1763644..42cad6119 100644 --- a/source/games/duke/src/sectors_r.cpp +++ b/source/games/duke/src/sectors_r.cpp @@ -1412,7 +1412,7 @@ void checkplayerhurt_r(player_struct* p, const Collision &coll) { case BIGFORCE: p->hurt_delay = 26; - fi.checkhitwall(p->GetActor(), wal, p->pos + DVector2(p->angle.ang.Cos() * 2, p->angle.ang.Sin() * 2), -1); + fi.checkhitwall(p->GetActor(), wal, p->pos + p->angle.ang.ToVector() * 2, -1); break; } diff --git a/source/games/duke/src/spawn.cpp b/source/games/duke/src/spawn.cpp index 80baddae5..dec36d062 100644 --- a/source/games/duke/src/spawn.cpp +++ b/source/games/duke/src/spawn.cpp @@ -447,7 +447,7 @@ void initshell(DDukeActor* actj, DDukeActor* act, bool isshell) act->spr.pos.Z = actj->spr.pos.Z - gs.playerheight + 3; } - act->spr.pos.XY() = actj->spr.pos.XY() + ang.ToVector(8); + act->spr.pos.XY() = actj->spr.pos.XY() + ang.ToVector() * 8; act->spr.shade = -8; diff --git a/source/games/sw/src/actor.cpp b/source/games/sw/src/actor.cpp index 4951b35b8..b995c3262 100644 --- a/source/games/sw/src/actor.cpp +++ b/source/games/sw/src/actor.cpp @@ -413,7 +413,7 @@ int DoActorDebris(DSWActor* actor) else { // todo: check correctness - DVector2 nvec(ACTORMOVETICS * maptoworld * actor->spr.angle.Cos(), ACTORMOVETICS * maptoworld * actor->spr.angle.Sin()); + DVector2 nvec = ACTORMOVETICS * maptoworld * actor->spr.angle.ToVector(); if (!move_debris(actor, nvec)) {