From c7f6b7a8c28b62b2bfcdee4a777f872f24d80328 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 29 Oct 2021 23:41:33 +0200 Subject: [PATCH] - DoFall + DoBeginFall. --- source/games/sw/src/actor.cpp | 42 +++++++-------------------------- source/games/sw/src/coolg.cpp | 4 ++-- source/games/sw/src/eel.cpp | 4 ++-- source/games/sw/src/hornet.cpp | 4 ++-- source/games/sw/src/misc.h | 4 ++-- source/games/sw/src/player.cpp | 2 +- source/games/sw/src/ripper.cpp | 6 ++--- source/games/sw/src/ripper2.cpp | 6 ++--- source/games/sw/src/skull.cpp | 4 ++-- source/games/sw/src/weapon.cpp | 10 ++++---- 10 files changed, 30 insertions(+), 56 deletions(-) diff --git a/source/games/sw/src/actor.cpp b/source/games/sw/src/actor.cpp index c11f8e3a5..5e49714ac 100644 --- a/source/games/sw/src/actor.cpp +++ b/source/games/sw/src/actor.cpp @@ -895,7 +895,7 @@ int DoJump(DSWActor* actor) if ((u->jump_speed += jump_adj) > 0) { // Start falling - DoBeginFall(SpriteNum); + DoBeginFall(actor); return 0; } @@ -912,56 +912,31 @@ int DoJump(DSWActor* actor) u->jump_speed = -u->jump_speed; // Change sprites state to falling - DoBeginFall(SpriteNum); + DoBeginFall(actor); } return 0; } -int -DoBeginFall(short SpriteNum) +int DoBeginFall(DSWActor* actor) { - USERp u = User[SpriteNum].Data(); + USERp u = actor->u(); SET(u->Flags, SPR_FALLING); RESET(u->Flags, SPR_JUMPING); u->jump_grav = ACTOR_GRAVITY; - DoFall(SpriteNum); + DoFall(actor); return 0; } -#if 0 -int -DoFall(short SpriteNum) +int DoFall(DSWActor* actor) { - USERp u = User[SpriteNum].Data(); - SPRITEp sp = User[SpriteNum]->SpriteP; - - // adjust jump speed by gravity - u->jump_speed += u->jump_grav * ACTORMOVETICS; - - // adjust player height by jump speed - sp->z += u->jump_speed * ACTORMOVETICS; - - // Stick like glue when you hit the ground - if (sp->z > u->loz) - { - sp->z = u->loz; - RESET(u->Flags, SPR_FALLING); - } - - return 0; -} -#else -int -DoFall(short SpriteNum) -{ - USERp u = User[SpriteNum].Data(); - SPRITEp sp = User[SpriteNum]->SpriteP; + USERp u = actor->u(); + SPRITEp sp = &actor->s(); // adjust jump speed by gravity u->jump_speed += u->jump_grav * ACTORMOVETICS; @@ -978,7 +953,6 @@ DoFall(short SpriteNum) return 0; } -#endif #include "saveable.h" diff --git a/source/games/sw/src/coolg.cpp b/source/games/sw/src/coolg.cpp index 8b9c36d84..c82b218cd 100644 --- a/source/games/sw/src/coolg.cpp +++ b/source/games/sw/src/coolg.cpp @@ -801,13 +801,13 @@ DoCoolgDeath(DSWActor* actor) if (TEST(u->Flags, SPR_FALLING)) { - DoFall(SpriteNum); + DoFall(actor); } else { DoFindGroundPoint(SpriteNum); u->floor_dist = 0; - DoBeginFall(SpriteNum); + DoBeginFall(actor); } if (TEST(u->Flags, SPR_SLIDING)) diff --git a/source/games/sw/src/eel.cpp b/source/games/sw/src/eel.cpp index 5f6d73e03..54943c2f9 100644 --- a/source/games/sw/src/eel.cpp +++ b/source/games/sw/src/eel.cpp @@ -537,13 +537,13 @@ DoEelDeath(DSWActor* actor) int nx, ny; if (TEST(u->Flags, SPR_FALLING)) { - DoFall(SpriteNum); + DoFall(actor); } else { DoFindGroundPoint(SpriteNum); u->floor_dist = 0; - DoBeginFall(SpriteNum); + DoBeginFall(actor); } if (TEST(u->Flags, SPR_SLIDING)) diff --git a/source/games/sw/src/hornet.cpp b/source/games/sw/src/hornet.cpp index 69bca3a19..1935734c7 100644 --- a/source/games/sw/src/hornet.cpp +++ b/source/games/sw/src/hornet.cpp @@ -519,14 +519,14 @@ DoHornetDeath(DSWActor* actor) if (TEST(u->Flags, SPR_FALLING)) { u->loz = u->zclip; - DoFall(SpriteNum); + DoFall(actor); } else { RESET(sp->cstat, CSTAT_SPRITE_YCENTER); u->jump_speed = 0; u->floor_dist = 0; - DoBeginFall(SpriteNum); + DoBeginFall(actor); DoFindGroundPoint(SpriteNum); u->zclip = u->loz; } diff --git a/source/games/sw/src/misc.h b/source/games/sw/src/misc.h index fec6ca243..fdbb1880f 100644 --- a/source/games/sw/src/misc.h +++ b/source/games/sw/src/misc.h @@ -82,8 +82,8 @@ void DoSlidorInterp(short, INTERP_FUNC); int DoBeginJump(DSWActor* actor); int DoJump(DSWActor* actor); -int DoBeginFall(short SpriteNum); -int DoFall(short SpriteNum); +int DoBeginFall(DSWActor* actor); +int DoFall(DSWActor* actor); void KeepActorOnFloor(DSWActor* actor); int DoActorSlide(DSWActor* actor); int DoActorSectorDamage(DSWActor* actor); diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index d2089b4d4..c5a6154f2 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -6406,7 +6406,7 @@ void DoPlayerDeathFlip(PLAYERp pp) DoPlayerDeathFall(pp); DoPlayerDeathHoriz(pp, PLAYER_DEATH_HORIZ_UP_VALUE, 4); if (MoveSkip2 == 0) - DoFall(pp->PlayerSprite); + DoFall(pp->Actor()); } } else diff --git a/source/games/sw/src/ripper.cpp b/source/games/sw/src/ripper.cpp index e3b371c3a..83757e4ac 100644 --- a/source/games/sw/src/ripper.cpp +++ b/source/games/sw/src/ripper.cpp @@ -1065,7 +1065,7 @@ DoRipperHangJF(DSWActor* actor) if (TEST(u->Flags, SPR_JUMPING)) DoJump(actor); else - DoFall(SpriteNum); + DoFall(actor); } if (!TEST(u->Flags, SPR_JUMPING | SPR_FALLING)) @@ -1133,7 +1133,7 @@ DoRipperMoveJump(DSWActor* actor) if (TEST(u->Flags, SPR_JUMPING)) DoJump(actor); else - DoFall(SpriteNum); + DoFall(actor); } if (!TEST(u->Flags, SPR_JUMPING | SPR_FALLING)) @@ -1305,7 +1305,7 @@ DoRipperMove(DSWActor* actor) if (TEST(u->Flags, SPR_JUMPING)) DoJump(actor); else - DoFall(SpriteNum); + DoFall(actor); } // if on a player/enemy sprite jump quickly diff --git a/source/games/sw/src/ripper2.cpp b/source/games/sw/src/ripper2.cpp index 000e43564..3f6e30586 100644 --- a/source/games/sw/src/ripper2.cpp +++ b/source/games/sw/src/ripper2.cpp @@ -1070,7 +1070,7 @@ DoRipper2HangJF(DSWActor* actor) if (TEST(u->Flags, SPR_JUMPING)) DoJump(actor); else - DoFall(SpriteNum); + DoFall(actor); } if (!TEST(u->Flags, SPR_JUMPING | SPR_FALLING)) @@ -1145,7 +1145,7 @@ DoRipper2MoveJump(DSWActor* actor) if (TEST(u->Flags, SPR_JUMPING)) DoJump(actor); else - DoFall(SpriteNum); + DoFall(actor); } if (!TEST(u->Flags, SPR_JUMPING | SPR_FALLING)) @@ -1323,7 +1323,7 @@ DoRipper2Move(DSWActor* actor) if (TEST(u->Flags, SPR_JUMPING)) DoJump(actor); else - DoFall(SpriteNum); + DoFall(actor); } // if on a player/enemy sprite jump quickly diff --git a/source/games/sw/src/skull.cpp b/source/games/sw/src/skull.cpp index 505ac5615..1183afd23 100644 --- a/source/games/sw/src/skull.cpp +++ b/source/games/sw/src/skull.cpp @@ -385,7 +385,7 @@ int DoSkullJump(DSWActor* actor) } else if (TEST(u->Flags,SPR_FALLING)) { - DoFall(SpriteNum); + DoFall(actor); // jump/fall type if (sp->xvel) @@ -804,7 +804,7 @@ int DoBettyJump(DSWActor* actor) } else if (TEST(u->Flags,SPR_FALLING)) { - DoFall(SpriteNum); + DoFall(actor); // jump/fall type if (sp->xvel) diff --git a/source/games/sw/src/weapon.cpp b/source/games/sw/src/weapon.cpp index 648d82f86..43f4c7732 100644 --- a/source/games/sw/src/weapon.cpp +++ b/source/games/sw/src/weapon.cpp @@ -3901,8 +3901,8 @@ DoVomit(DSWActor* actor) } else if (TEST(u->Flags, SPR_FALLING)) { - DoFall(SpriteNum); - DoFall(SpriteNum); + DoFall(actor); + DoFall(actor); DoShrapMove(SpriteNum); } else @@ -4035,7 +4035,7 @@ DoShrapDamage(DSWActor* actor) } else if (TEST(u->Flags, SPR_FALLING)) { - DoFall(SpriteNum); + DoFall(actor); DoShrapMove(SpriteNum); } else @@ -4756,7 +4756,7 @@ DoFireballFlames(DSWActor* actor) } else if (TEST(u->Flags, SPR_FALLING)) { - DoFall(SpriteNum); + DoFall(actor); jumping = true; //u->ret = move_missile(SpriteNum, dax, day, daz, Z(16), Z(16), CLIPMASK_MISSILE, MISSILEMOVETICS); } @@ -4831,7 +4831,7 @@ DoBreakFlames(DSWActor* actor) } else if (TEST(u->Flags, SPR_FALLING)) { - DoFall(SpriteNum); + DoFall(actor); jumping = true; } else