From 5ef78cbc16b795a90ce04fe032e2650af8d817f7 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 22 May 2022 21:41:40 -0400 Subject: [PATCH] EVEN MORE (also removed the define replacements since didn't work) --- src/objects/hyudoro.c | 69 +++++++++++++++++++------------------------ src/p_mobj.c | 2 ++ 2 files changed, 32 insertions(+), 39 deletions(-) diff --git a/src/objects/hyudoro.c b/src/objects/hyudoro.c index b5ece9157..d72a597c4 100644 --- a/src/objects/hyudoro.c +++ b/src/objects/hyudoro.c @@ -37,47 +37,15 @@ K_ChangePlayerItem #define hyudoro_itemtype(o) ((o)->movefactor) #define hyudoro_itemcount(o) ((o)->movecount) #define hyudoro_hover_stack(o) ((o)->threshold) - -static mobj_t * -hyudoro_next (mobj_t *o) -{ - I_Assert(o != NULL && P_MobjWasRemoved(o) == false); - I_Assert(o->tracer != NULL && P_MobjWasRemoved(o->tracer) == false); - - return o->tracer; -} - +#define hyudoro_next(o) ((o)->tracer) #define hyudoro_stackpos(o) ((o)->reactiontime) -// these next two functions cannot be combined -static mobj_t * -hyudoro_center (mobj_t *o) -{ - I_Assert(o != NULL && P_MobjWasRemoved(o) == false); - I_Assert(o->target != NULL && P_MobjWasRemoved(o->target) == false); - - return o->target; -} - -static mobj_t * -hyudoro_target (mobj_t *o) -{ - I_Assert(o != NULL && P_MobjWasRemoved(o) == false); - I_Assert(o->target != NULL && P_MobjWasRemoved(o->target) == false); - - return o->target; -} +// cannot be combined +#define hyudoro_center(o) ((o)->target) +#define hyudoro_target(o) ((o)->target) #define hyudoro_center_max_radius(o) ((o)->threshold) - -static mobj_t * -hyudoro_center_master (mobj_t *o) -{ - I_Assert(o != NULL && P_MobjWasRemoved(o) == false); - I_Assert(o->target != NULL && P_MobjWasRemoved(o->target) == false); - - return o->target; -} +#define hyudoro_center_master(o) ((o)->target) static angle_t trace_angle (mobj_t *hyu) @@ -126,6 +94,8 @@ get_hyudoro_target_player (mobj_t *hyu) { mobj_t *target = hyudoro_target(hyu); + I_Assert(target != NULL && P_MobjWasRemoved(target) == false); + return target ? target->player : NULL; } @@ -220,6 +190,8 @@ move_to_player (mobj_t *hyu) angle_t angle; + I_Assert(hyu != NULL && P_MobjWasRemoved(hyu) == false); + if (target == NULL || P_MobjWasRemoved(target) == true) return; @@ -239,6 +211,10 @@ deliver_item (mobj_t *hyu) mobj_t *target = hyudoro_target(hyu); player_t *player = target->player; + I_Assert(hyu != NULL && P_MobjWasRemoved(hyu) == false); + I_Assert(target != NULL && P_MobjWasRemoved(target) == false); + I_Assert(player != NULL); + P_SetTarget(&hyudoro_target(hyu), NULL); if (player) @@ -268,6 +244,8 @@ append_hyudoro { INT32 lastpos = 0; + I_Assert(hyu != NULL && P_MobjWasRemoved(hyu) == false); + while (is_hyudoro(*head)) { lastpos = hyudoro_stackpos(*head); @@ -314,7 +292,11 @@ hyudoro_patrol_hit_player mobj_t *center = hyudoro_center(hyu); - if (!player) + I_Assert(hyu != NULL && P_MobjWasRemoved(hyu) == false); + I_Assert(toucher != NULL && P_MobjWasRemoved(toucher) == false); + I_Assert(center != NULL && P_MobjWasRemoved(center) == false); + + if (player == NULL) return false; // Cannot hit its master @@ -356,6 +338,8 @@ award_immediately (mobj_t *hyu) { player_t *player = get_hyudoro_target_player(hyu); + I_Assert(hyu != NULL && P_MobjWasRemoved(hyu) == false); + if (player) { if (player->itemamount && @@ -380,6 +364,9 @@ hyudoro_return_hit_player ( mobj_t * hyu, mobj_t * toucher) { + I_Assert(hyu != NULL && P_MobjWasRemoved(hyu) == false); + I_Assert(toucher != NULL && P_MobjWasRemoved(toucher) == false); + if (toucher != hyudoro_target(hyu)) return false; @@ -399,7 +386,9 @@ hyudoro_hover_await_stack (mobj_t *hyu) { player_t *player = get_hyudoro_target_player(hyu); - if (!player) + I_Assert(hyu != NULL && P_MobjWasRemoved(hyu) == false); + + if (player == NULL) return false; // First in stack goes first @@ -453,6 +442,8 @@ Obj_HyudoroDeploy (mobj_t *master) void Obj_HyudoroThink (mobj_t *hyu) { + I_Assert(hyu != NULL && P_MobjWasRemoved(hyu) == false); + // Might get set from clipping slopes hyu->momz = 0; diff --git a/src/p_mobj.c b/src/p_mobj.c index 009241c62..64d0f616c 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -13464,6 +13464,8 @@ mobj_t *P_SpawnMobjFromMobj(mobj_t *mobj, fixed_t xofs, fixed_t yofs, fixed_t zo { mobj_t *newmobj; + I_Assert(mobj != NULL && P_MobjWasRemoved(mobj) == false); + xofs = FixedMul(xofs, mobj->scale); yofs = FixedMul(yofs, mobj->scale); zofs = FixedMul(zofs, mobj->scale);