From 95d3095f8d7c670991f1f174a347a5a9d79c0988 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 3 Nov 2021 21:44:22 +0100 Subject: [PATCH] - DoItemFly --- source/games/sw/src/sprite.cpp | 2 +- source/games/sw/src/weapon.cpp | 26 +++++++++++--------------- source/games/sw/src/weapon.h | 2 +- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/source/games/sw/src/sprite.cpp b/source/games/sw/src/sprite.cpp index a9e7316e5..e527dd8ac 100644 --- a/source/games/sw/src/sprite.cpp +++ b/source/games/sw/src/sprite.cpp @@ -5490,7 +5490,7 @@ DoGet(DSWActor* actor) if (sp->xvel) { - if (!DoItemFly(SpriteNum)) + if (!DoItemFly(actor)) { sp->xvel = 0; change_actor_stat(actor, STAT_ITEM); diff --git a/source/games/sw/src/weapon.cpp b/source/games/sw/src/weapon.cpp index a3ebf1750..e79a8990f 100644 --- a/source/games/sw/src/weapon.cpp +++ b/source/games/sw/src/weapon.cpp @@ -21007,12 +21007,10 @@ bool CheckBreakToughness(BREAK_INFOp break_info, short ID) return true; // It wasn't tough, go ahead and break it } -int -DoItemFly(int16_t SpriteNum) +int DoItemFly(DSWActor* actor) { - auto actor = &swActors[SpriteNum]; - SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum].Data(); + SPRITEp sp = &actor->s(); + USERp u = actor->u(); if (TEST(u->Flags, SPR_UNDERWATER)) { @@ -21027,23 +21025,21 @@ DoItemFly(int16_t SpriteNum) u->zchange += u->Counter; } - SetCollision(u, move_missile(SpriteNum, u->xchange, u->ychange, u->zchange, + SetCollision(u, move_missile(actor->GetSpriteIndex(), u->xchange, u->ychange, u->zchange, u->ceiling_dist, u->floor_dist, CLIPMASK_MISSILE, MISSILEMOVETICS*2)); MissileHitDiveArea(actor); - if (u->ret) { - switch (TEST(u->ret, HIT_MASK)) + switch (u->coll.type) { - case HIT_SPRITE: + case kHitSprite: { short wall_ang; - short hit_sprite = -2; + auto hit_sprite = u->coll.actor; SPRITEp hsp; - hit_sprite = NORM_SPRITE(u->ret); - hsp = &sprite[hit_sprite]; + hsp = &hit_sprite->s(); if (TEST(hsp->cstat, CSTAT_SPRITE_ALIGNMENT_WALL)) { @@ -21060,12 +21056,12 @@ DoItemFly(int16_t SpriteNum) break; } - case HIT_WALL: + case kHitWall: { short hit_wall,nw,wall_ang; WALLp wph; - hit_wall = NORM_WALL(u->ret); + hit_wall = u->coll.index; wph = &wall[hit_wall]; nw = wall[hit_wall].point2; @@ -21076,7 +21072,7 @@ DoItemFly(int16_t SpriteNum) break; } - case HIT_SECTOR: + case kHitSector: { // hit floor if (sp->z > DIV2(u->hiz + u->loz)) diff --git a/source/games/sw/src/weapon.h b/source/games/sw/src/weapon.h index 61313229e..b6415c866 100644 --- a/source/games/sw/src/weapon.h +++ b/source/games/sw/src/weapon.h @@ -240,7 +240,7 @@ int SpawnBoltExp(int16_t Weapon); int SpawnTracerExp(int16_t Weapon); int SpawnGoroFireballExp(int16_t Weapon); bool MissileHitMatch(short Weapon,short WeaponNum,short hit_sprite); -int DoItemFly(int16_t SpriteNum); +int DoItemFly(DSWActor*); int SpawnVehicleSmoke(DSWActor* actor); short PrevWall(short wall_num); int DoDamage(short SpriteNum,short Weapon);