From 65d1e5cac9b726cc1db3a39fe9a2e0cdd7af19ce Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 20 Aug 2022 22:36:27 +0200 Subject: [PATCH] - wrapped user.z_tgt reads. --- source/games/sw/src/game.h | 1 + source/games/sw/src/spike.cpp | 40 +++++++++++++++++----------------- source/games/sw/src/sprite.cpp | 6 ++--- source/games/sw/src/vator.cpp | 40 +++++++++++++++++----------------- source/games/sw/src/weapon.cpp | 2 +- 5 files changed, 45 insertions(+), 44 deletions(-) diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 534f53fc6..df7258aea 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -933,6 +933,7 @@ struct USER int int_oz() const { return oz * zworldtoint; } int int_loz() const { return loz * zworldtoint; } int int_hiz() const { return hiz * zworldtoint; } + int int_z_tgt() const { return z_tgt * zworldtoint; } // // Variables that can be used by actors and Player diff --git a/source/games/sw/src/spike.cpp b/source/games/sw/src/spike.cpp index 4fa98625e..a01453e9b 100644 --- a/source/games/sw/src/spike.cpp +++ b/source/games/sw/src/spike.cpp @@ -49,16 +49,16 @@ void ReverseSpike(DSWActor* actor) } // moving toward to OFF pos - if (actor->user.z_tgt == actor->user.int_oz()) + if (actor->user.int_z_tgt() == actor->user.int_oz()) { - if (actor->int_pos().Z == actor->user.int_oz()) + if (actor->spr.pos.Z == actor->user.oz) actor->user.z_tgt = actor->user.pos.Z; else if (actor->user.pos.Z == actor->user.int_oz()) actor->user.z_tgt = actor->int_pos().Z; } - else if (actor->user.z_tgt == actor->user.pos.Z) + else if (actor->user.int_z_tgt() == actor->user.pos.Z) { - if (actor->int_pos().Z == actor->user.int_oz()) + if (actor->spr.pos.Z == actor->user.oz) actor->user.z_tgt = actor->int_pos().Z; else if (actor->user.pos.Z == actor->user.int_oz()) actor->user.z_tgt = actor->user.pos.Z; @@ -102,11 +102,11 @@ void SetSpikeActive(DSWActor* actor) actor->user.Tics = 0; // moving to the ON position - if (actor->user.z_tgt == actor->int_pos().Z) + if (actor->user.int_z_tgt() == actor->int_pos().Z) VatorSwitch(SP_TAG2(actor), true); else // moving to the OFF position - if (actor->user.z_tgt == actor->user.pos.Z) + if (actor->user.int_z_tgt() == actor->user.pos.Z) VatorSwitch(SP_TAG2(actor), false); } @@ -197,7 +197,7 @@ int DoSpikeMove(DSWActor* actor, int *lptr) zval = *lptr; // if LESS THAN goal - if (zval < actor->user.z_tgt) + if (zval < actor->user.int_z_tgt()) { // move it DOWN zval += (synctics * actor->user.jump_speed); @@ -205,20 +205,20 @@ int DoSpikeMove(DSWActor* actor, int *lptr) actor->user.jump_speed += actor->user.vel_rate * synctics; // if the other way make it equal - if (zval > actor->user.z_tgt) - zval = actor->user.z_tgt; + if (zval > actor->user.int_z_tgt()) + zval = actor->user.int_z_tgt(); } // if GREATER THAN goal - if (zval > actor->user.z_tgt) + if (zval > actor->user.int_z_tgt()) { // move it UP zval -= (synctics * actor->user.jump_speed); actor->user.jump_speed += actor->user.vel_rate * synctics; - if (zval < actor->user.z_tgt) - zval = actor->user.z_tgt; + if (zval < actor->user.int_z_tgt()) + zval = actor->user.int_z_tgt(); } *lptr = zval; @@ -279,10 +279,10 @@ int DoSpike(DSWActor* actor) SpikeAlign(actor); // EQUAL this entry has finished - if (*lptr == actor->user.z_tgt) + if (*lptr == actor->user.int_z_tgt()) { // in the ON position - if (actor->user.z_tgt == actor->int_pos().Z) + if (actor->user.int_z_tgt() == actor->int_pos().Z) { // change target actor->user.z_tgt = actor->user.pos.Z; @@ -295,7 +295,7 @@ int DoSpike(DSWActor* actor) } else // in the OFF position - if (actor->user.z_tgt == actor->user.pos.Z) + if (actor->user.int_z_tgt() == actor->user.pos.Z) { short match = SP_TAG2(actor); @@ -332,10 +332,10 @@ int DoSpike(DSWActor* actor) actor->user.Tics = actor->user.WaitTics; } } - else // if (*lptr == actor->user.z_tgt) + else // if (*lptr == actor->user.int_z_tgt()) { // if heading for the OFF (original) position and should NOT CRUSH - if (TEST_BOOL3(actor) && actor->user.z_tgt == actor->user.int_oz()) + if (TEST_BOOL3(actor) && actor->user.int_z_tgt() == actor->user.int_oz()) { bool found = false; @@ -384,10 +384,10 @@ int DoSpikeAuto(DSWActor* actor) SpikeAlign(actor); // EQUAL this entry has finished - if (*lptr == actor->user.z_tgt) + if (*lptr == actor->user.int_z_tgt()) { // in the UP position - if (actor->user.z_tgt == actor->int_pos().Z) + if (actor->user.int_z_tgt() == actor->int_pos().Z) { // change target actor->user.z_tgt = actor->user.pos.Z; @@ -399,7 +399,7 @@ int DoSpikeAuto(DSWActor* actor) } else // in the DOWN position - if (actor->user.z_tgt == actor->user.pos.Z) + if (actor->user.int_z_tgt() == actor->user.pos.Z) { // change target actor->user.jump_speed = actor->user.vel_tgt; diff --git a/source/games/sw/src/sprite.cpp b/source/games/sw/src/sprite.cpp index 68a0c7e83..82aae87eb 100644 --- a/source/games/sw/src/sprite.cpp +++ b/source/games/sw/src/sprite.cpp @@ -6549,11 +6549,11 @@ Collision move_ground_missile(DSWActor* actor, int xchange, int ychange, int cei daz = actor->int_pos().Z; // climbing a wall - if (actor->user.z_tgt) + if (actor->user.int_z_tgt()) { - if (labs(actor->user.z_tgt - actor->int_pos().Z) > Z(40)) + if (labs(actor->user.int_z_tgt() - actor->int_pos().Z) > Z(40)) { - if (actor->user.z_tgt > actor->int_pos().Z) + if (actor->user.int_z_tgt() > actor->int_pos().Z) { actor->spr.pos.Z += 30; return retval; diff --git a/source/games/sw/src/vator.cpp b/source/games/sw/src/vator.cpp index fe9c3c060..2398e19e8 100644 --- a/source/games/sw/src/vator.cpp +++ b/source/games/sw/src/vator.cpp @@ -54,16 +54,16 @@ void ReverseVator(DSWActor* actor) } // moving toward to OFF pos - if (actor->user.z_tgt == actor->user.int_oz()) + if (actor->user.int_z_tgt() == actor->user.int_oz()) { - if (actor->int_pos().Z == actor->user.int_oz()) + if (actor->spr.pos.Z == actor->user.oz) actor->user.z_tgt = actor->user.pos.Z; else if (actor->user.pos.Z == actor->user.int_oz()) actor->user.z_tgt = actor->int_pos().Z; } - else if (actor->user.z_tgt == actor->user.pos.Z) + else if (actor->user.int_z_tgt() == actor->user.pos.Z) { - if (actor->int_pos().Z == actor->user.int_oz()) + if (actor->spr.pos.Z == actor->user.oz) actor->user.z_tgt = actor->int_pos().Z; else if (actor->user.pos.Z == actor->user.int_oz()) actor->user.z_tgt = actor->user.pos.Z; @@ -107,11 +107,11 @@ void SetVatorActive(DSWActor* actor) actor->user.Tics = 0; // moving to the ON position - if (actor->user.z_tgt == actor->int_pos().Z) + if (actor->user.int_z_tgt() == actor->int_pos().Z) VatorSwitch(SP_TAG2(actor), true); else // moving to the OFF position - if (actor->user.z_tgt == actor->user.pos.Z) + if (actor->user.int_z_tgt() == actor->user.pos.Z) VatorSwitch(SP_TAG2(actor), false); } @@ -330,7 +330,7 @@ int DoVatorMove(DSWActor* actor, int *lptr) zval = *lptr; // if LESS THAN goal - if (zval < actor->user.z_tgt) + if (zval < actor->user.int_z_tgt()) { // move it DOWN zval += (synctics * actor->user.jump_speed); @@ -338,20 +338,20 @@ int DoVatorMove(DSWActor* actor, int *lptr) actor->user.jump_speed += actor->user.vel_rate * synctics; // if the other way make it equal - if (zval > actor->user.z_tgt) - zval = actor->user.z_tgt; + if (zval > actor->user.int_z_tgt()) + zval = actor->user.int_z_tgt(); } // if GREATER THAN goal - if (zval > actor->user.z_tgt) + if (zval > actor->user.int_z_tgt()) { // move it UP zval -= (synctics * actor->user.jump_speed); actor->user.jump_speed += actor->user.vel_rate * synctics; - if (zval < actor->user.z_tgt) - zval = actor->user.z_tgt; + if (zval < actor->user.int_z_tgt()) + zval = actor->user.int_z_tgt(); } move_amt = zval - *lptr; @@ -389,10 +389,10 @@ int DoVator(DSWActor* actor) } // EQUAL this entry has finished - if (zval == actor->user.z_tgt) + if (zval == actor->user.int_z_tgt()) { // in the ON position - if (actor->user.z_tgt == actor->int_pos().Z) + if (actor->user.int_z_tgt() == actor->int_pos().Z) { // change target actor->user.z_tgt = actor->user.pos.Z; @@ -406,7 +406,7 @@ int DoVator(DSWActor* actor) } else // in the OFF position - if (actor->user.z_tgt == actor->user.pos.Z) + if (actor->user.int_z_tgt() == actor->user.pos.Z) { short match = SP_TAG2(actor); @@ -444,10 +444,10 @@ int DoVator(DSWActor* actor) actor->user.Tics = actor->user.WaitTics; } } - else // if (*lptr == actor->user.z_tgt) + else // if (*lptr == actor->user.int_z_tgt()) { // if heading for the OFF (original) position and should NOT CRUSH - if (TEST_BOOL3(actor) && actor->user.z_tgt == actor->user.int_oz()) + if (TEST_BOOL3(actor) && actor->user.int_z_tgt() == actor->user.int_oz()) { int i; bool found = false; @@ -542,10 +542,10 @@ int DoVatorAuto(DSWActor* actor) } // EQUAL this entry has finished - if (zval == actor->user.z_tgt) + if (zval == actor->user.int_z_tgt()) { // in the UP position - if (actor->user.z_tgt == actor->int_pos().Z) + if (actor->user.int_z_tgt() == actor->int_pos().Z) { // change target actor->user.z_tgt = actor->user.pos.Z; @@ -557,7 +557,7 @@ int DoVatorAuto(DSWActor* actor) } else // in the DOWN position - if (actor->user.z_tgt == actor->user.pos.Z) + if (actor->user.int_z_tgt() == actor->user.pos.Z) { // change target actor->user.jump_speed = actor->user.vel_tgt; diff --git a/source/games/sw/src/weapon.cpp b/source/games/sw/src/weapon.cpp index f44ef2d9a..e4be657c6 100644 --- a/source/games/sw/src/weapon.cpp +++ b/source/games/sw/src/weapon.cpp @@ -10851,7 +10851,7 @@ int DoBloodWorm(DSWActor* actor) MissileHitDiveArea(actor); - if (!actor->user.z_tgt) + if (!actor->user.int_z_tgt()) { // stay alive for 10 seconds if (++actor->user.Counter3 > 3)