From 153b5b84f33f7e8dde9c0e2a14552fb663054db9 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 31 Aug 2022 00:44:27 +0200 Subject: [PATCH] - wrapped almost everything --- source/games/sw/src/game.h | 3 +++ source/games/sw/src/jweapon.cpp | 8 ++++---- source/games/sw/src/weapon.cpp | 30 +++++++++++++++--------------- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index ba79bbe32..aedfc5b0e 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -944,6 +944,9 @@ struct USER void set_int_change_x(int x) { change.X = x; } void set_int_change_y(int x) { change.Y = x; } void set_int_change_z(int x) { change.Z = x; } + void add_int_change_x(int x) { change.X += x; } + void add_int_change_y(int x) { change.Y += x; } + void add_int_change_z(int x) { change.Z += x; } // frequently repeated patterns void clearChange() { change.X = change.Y = change.Z = 0; } diff --git a/source/games/sw/src/jweapon.cpp b/source/games/sw/src/jweapon.cpp index 4fe796e99..7205c8e06 100644 --- a/source/games/sw/src/jweapon.cpp +++ b/source/games/sw/src/jweapon.cpp @@ -1275,8 +1275,8 @@ int PlayerInitChemBomb(PLAYER* pp) UpdateChange(actorNew, 0.5); // adjust xvel according to player velocity - actorNew->user.change.X += pp->vect.X >> 14; - actorNew->user.change.Y += pp->vect.Y >> 14; + actorNew->user.add_int_change_x(pp->vect.X >> 14); + actorNew->user.add_int_change_y(pp->vect.Y >> 14); // Smoke will come out for this many seconds actorNew->user.WaitTics = CHEMTICS; @@ -1626,8 +1626,8 @@ int PlayerInitCaltrops(PLAYER* pp) UpdateChange(actorNew, 0.5); // adjust xvel according to player velocity - actorNew->user.change.X += pp->vect.X >> 14; - actorNew->user.change.Y += pp->vect.Y >> 14; + actorNew->user.add_int_change_x(pp->vect.X >> 14); + actorNew->user.add_int_change_y(pp->vect.Y >> 14); SetupSpriteForBreak(actorNew); // Put Caltrops in the break queue return 0; diff --git a/source/games/sw/src/weapon.cpp b/source/games/sw/src/weapon.cpp index 1006408c6..c32cefa15 100644 --- a/source/games/sw/src/weapon.cpp +++ b/source/games/sw/src/weapon.cpp @@ -3862,7 +3862,7 @@ int DoFastShrapJumpFall(DSWActor* actor) int DoTracerShrap(DSWActor* actor) { - actor->add_int_pos({ actor->user.int_change().X, actor->user.int_change().Y, actor->user.change.Z }); + actor->add_int_pos({ actor->user.int_change().X, actor->user.int_change().Y, actor->user.int_change().Z }); actor->user.WaitTics -= MISSILEMOVETICS; if (actor->user.WaitTics <= 0) @@ -7850,9 +7850,9 @@ int VectorMissileSeek(DSWActor* actor, int16_t delay_tics, int16_t turn_speed, i // the large turn_speed is the slower the turn - actor->user.set_int_change_x((actor->user.change.X + ox*(turn_speed-1))/turn_speed); - actor->user.set_int_change_y((actor->user.change.Y + oy*(turn_speed-1))/turn_speed); - actor->user.set_int_change_z((actor->user.change.Z + oz*(turn_speed-1))/turn_speed); + actor->user.set_int_change_x((actor->user.int_change().X + ox*(turn_speed-1))/turn_speed); + actor->user.set_int_change_y((actor->user.int_change().Y + oy*(turn_speed-1))/turn_speed); + actor->user.set_int_change_z((actor->user.int_change().Z + oz*(turn_speed-1))/turn_speed); SetAngleFromChange(actor); } @@ -7906,9 +7906,9 @@ int VectorWormSeek(DSWActor* actor, int16_t delay_tics, int16_t aware_range1, in actor->user.set_int_change_y(Scale(actor->spr.xvel, goal->int_pos().Y - actor->int_pos().Y, dist)); actor->user.set_int_change_z(Scale(actor->spr.xvel, zh - actor->int_pos().Z, dist)); - actor->user.set_int_change_x((actor->user.change.X + ox*7)/8); - actor->user.set_int_change_y((actor->user.change.Y + oy*7)/8); - actor->user.set_int_change_z((actor->user.change.Z + oz*7)/8); + actor->user.set_int_change_x((actor->user.int_change().X + ox*7)/8); + actor->user.set_int_change_y((actor->user.int_change().Y + oy*7)/8); + actor->user.set_int_change_z((actor->user.int_change().Z + oz*7)/8); SetAngleFromChange(actor); } @@ -8191,9 +8191,9 @@ bool SlopeBounce(DSWActor* actor, bool *hit_wall) if ((abs(k)>>14) < l) { k = DivScale(k, l, 17); - actor->user.change.X -= MulScale(dax, k, 16); - actor->user.change.Y -= MulScale(day, k, 16); - actor->user.change.Z -= MulScale(daz, k, 12); + actor->user.add_int_change_x(-MulScale(dax, k, 16)); + actor->user.add_int_change_y(-MulScale(day, k, 16)); + actor->user.add_int_change_z(-MulScale(daz, k, 12)); SetAngleFromChange(actor); } @@ -8937,7 +8937,7 @@ int DoMine(DSWActor* actor) int DoPuff(DSWActor* actor) { - actor->add_int_pos({ actor->user.int_change().X, actor->user.int_change().Y, actor->user.change.Z }); + actor->add_int_pos({ actor->user.int_change().X, actor->user.int_change().Y, actor->user.int_change().Z }); return 0; } @@ -16154,8 +16154,8 @@ int InitGrenade(PLAYER* pp) if (!auto_aim) { // adjust xvel according to player velocity - actorNew->user.change.X += pp->vect.X>>14; - actorNew->user.change.Y += pp->vect.Y>>14; + actorNew->user.add_int_change_x(pp->vect.X>>14); + actorNew->user.add_int_change_y(pp->vect.Y>>14); } actorNew->user.Counter2 = true; // Phosphorus Grenade @@ -16262,8 +16262,8 @@ int InitMine(PLAYER* pp) if (labs(dot) > 10000) { // adjust xvel according to player velocity - actorNew->user.change.X += pp->vect.X>>13; - actorNew->user.change.Y += pp->vect.Y>>13; + actorNew->user.add_int_change_x(pp->vect.X>>13); + actorNew->user.add_int_change_y(pp->vect.Y>>13); } return 0;