diff --git a/source/games/sw/src/actor.cpp b/source/games/sw/src/actor.cpp index a53ae005b..50c51ab4f 100644 --- a/source/games/sw/src/actor.cpp +++ b/source/games/sw/src/actor.cpp @@ -864,9 +864,9 @@ int DoActorDeathMove(DSWActor* actor) // !AIC - Jumping a falling for shrapnel and other stuff, not actors. -int DoBeginJump(short SpriteNum) +int DoBeginJump(DSWActor* actor) { - USERp u = User[SpriteNum].Data(); + USERp u = actor->u(); SET(u->Flags, SPR_JUMPING); RESET(u->Flags, SPR_FALLING); @@ -874,7 +874,7 @@ int DoBeginJump(short SpriteNum) // set up individual actor jump gravity u->jump_grav = ACTOR_GRAVITY; - DoJump(SpriteNum); + DoJump(u->SpriteNum); return 0; } diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index ee587a58d..bb02363db 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -744,6 +744,7 @@ typedef struct struct PLAYERstruct { + DSWActor* Actor(); // variable that fit in the sprite or user structure union { @@ -2226,5 +2227,11 @@ END_SW_NS #include "swactor.h" +BEGIN_SW_NS +DSWActor* PLAYERstruct::Actor() +{ + return &swActors[PlayerSprite]; +} +END_SW_NS #endif diff --git a/source/games/sw/src/jweapon.cpp b/source/games/sw/src/jweapon.cpp index f1b82f7d5..f61fa3c59 100644 --- a/source/games/sw/src/jweapon.cpp +++ b/source/games/sw/src/jweapon.cpp @@ -2464,6 +2464,7 @@ DoFlag(DSWActor* actor) int InitShell(int16_t SpriteNum, int16_t ShellNum) { + auto actor = &swActors[SpriteNum]; USERp u = User[SpriteNum].Data(); USERp wu; SPRITEp sp = &sprite[SpriteNum], wp; @@ -2571,7 +2572,7 @@ InitShell(int16_t SpriteNum, int16_t ShellNum) wu->jump_speed += RandomRange(400); wu->jump_speed = -wu->jump_speed; - DoBeginJump(w); + DoBeginJump(actor); wu->jump_grav = ACTOR_GRAVITY; return 0; diff --git a/source/games/sw/src/misc.h b/source/games/sw/src/misc.h index 6a07c5948..ab644aecc 100644 --- a/source/games/sw/src/misc.h +++ b/source/games/sw/src/misc.h @@ -80,7 +80,7 @@ using INTERP_FUNC = void(*)(int, int); void SetSlidorActive(short SpriteNum); void DoSlidorInterp(short, INTERP_FUNC); -int DoBeginJump(short SpriteNum); +int DoBeginJump(DSWActor* actor); int DoJump(short SpriteNum); int DoBeginFall(short SpriteNum); int DoFall(short SpriteNum); diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index 2d8b33a4a..2f2e59075 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -5955,7 +5955,7 @@ DoPlayerBeginDie(PLAYERp pp) pp->jump_speed = -200; NewStateGroup(pp->PlayerSprite, sg_PlayerDeath); DoFindGround(pp->PlayerSprite); - DoBeginJump(pp->PlayerSprite); + DoBeginJump(pp->Actor()); u->jump_speed = -300; break; } @@ -5975,7 +5975,7 @@ DoPlayerBeginDie(PLAYERp pp) u->ceiling_dist = Z(10); u->floor_dist = Z(0); DoFindGround(pp->PlayerSprite); - DoBeginJump(pp->PlayerSprite); + DoBeginJump(pp->Actor()); u->jump_speed = -400; break; case PLAYER_DEATH_CRUMBLE: diff --git a/source/games/sw/src/skull.cpp b/source/games/sw/src/skull.cpp index 98965fe15..0cf07e331 100644 --- a/source/games/sw/src/skull.cpp +++ b/source/games/sw/src/skull.cpp @@ -488,7 +488,7 @@ int DoSkullWait(DSWActor* actor) sp->xvel = 0; u->jump_speed = -600; NewStateGroup(SpriteNum, sg_SkullJump); - DoBeginJump(SpriteNum); + DoBeginJump(actor); } } else @@ -504,7 +504,7 @@ int DoSkullWait(DSWActor* actor) sp->xvel = 128 + (RANDOM_P2(256<<8)>>8); u->jump_speed = -700; NewStateGroup(SpriteNum, sg_SkullJump); - DoBeginJump(SpriteNum); + DoBeginJump(actor); } } @@ -902,7 +902,7 @@ int DoBettyWait(DSWActor* actor) sp->xvel = 0; u->jump_speed = -600; NewStateGroup(SpriteNum, sg_BettyJump); - DoBeginJump(SpriteNum); + DoBeginJump(actor); } } else @@ -918,7 +918,7 @@ int DoBettyWait(DSWActor* actor) sp->xvel = 128 + (RANDOM_P2(256<<8)>>8); u->jump_speed = -700; NewStateGroup(SpriteNum, sg_BettyJump); - DoBeginJump(SpriteNum); + DoBeginJump(actor); } } diff --git a/source/games/sw/src/weapon.cpp b/source/games/sw/src/weapon.cpp index c681538da..3cfac7eff 100644 --- a/source/games/sw/src/weapon.cpp +++ b/source/games/sw/src/weapon.cpp @@ -3759,8 +3759,9 @@ AutoShrap: SpriteNum = SpawnSprite(STAT_SKIP4, p->id, p->state, parent->sectnum, parent->x, parent->y, hz[p->zlevel], shrap_ang, 512); - sp = &sprite[SpriteNum]; - u = User[SpriteNum].Data(); + auto actor = &swActors[SpriteNum]; + sp = &actor->s(); + u = actor->u(); if (p->random_disperse) { @@ -3857,7 +3858,7 @@ AutoShrap: u->jump_speed += RandomRange(p->max_jspeed - p->min_jspeed); u->jump_speed = -u->jump_speed; - DoBeginJump(SpriteNum); + DoBeginJump(actor); u->jump_grav = jump_grav; u->xchange = MOVEx(sp->xvel, sp->ang); @@ -4044,7 +4045,7 @@ DoShrapDamage(DSWActor* actor) SET(u->Flags, SPR_BOUNCE); u->jump_speed = -300; sp->xvel >>= 2; - DoBeginJump(SpriteNum); + DoBeginJump(actor); return 0; } @@ -4244,8 +4245,9 @@ SpawnBlood(short SpriteNum, short Weapon, short hit_ang, int hit_x, int hit_y, i { New = SpawnSprite(STAT_SKIP4, p->id, p->state, sp->sectnum, hit_x, hit_y, hit_z, hit_ang, 0); - np = &sprite[New]; - nu = User[New].Data(); + auto actorNew = &swActors[New]; + np = &actorNew->s(); + nu = actorNew->u(); switch (nu->ID) { @@ -4311,7 +4313,7 @@ SpawnBlood(short SpriteNum, short Weapon, short hit_ang, int hit_x, int hit_y, i SET(u->Flags, SPR_BOUNCE); - DoBeginJump(New); + DoBeginJump(actorNew); } } @@ -10767,8 +10769,9 @@ SpawnFireballFlames(int16_t SpriteNum, int16_t enemy) New = SpawnSprite(STAT_MISSILE, FIREBALL_FLAMES, s_FireballFlames, sp->sectnum, sp->x, sp->y, sp->z, sp->ang, 0); - np = &sprite[New]; - nu = User[New].Data(); + auto actorNew = &swActors[New]; + np = &actorNew->s(); + nu = actorNew->u(); np->hitag = LUMINOUS; //Always full brightness @@ -10820,7 +10823,7 @@ SpawnFireballFlames(int16_t SpriteNum, int16_t enemy) DoFindGround(New); nu->jump_speed = 0; - DoBeginJump(New); + DoBeginJump(actorNew); } PlaySound(DIGI_FIRE1,np,v3df_dontpan|v3df_doppler); @@ -10841,8 +10844,9 @@ SpawnBreakFlames(int16_t SpriteNum) New = SpawnSprite(STAT_MISSILE, FIREBALL_FLAMES+1, s_BreakFlames, sp->sectnum, sp->x, sp->y, sp->z, sp->ang, 0); - np = &sprite[New]; - nu = User[New].Data(); + auto actorNew = &swActors[New]; + np = &actorNew->s(); + nu = actorNew->u(); np->hitag = LUMINOUS; //Always full brightness @@ -10863,7 +10867,7 @@ SpawnBreakFlames(int16_t SpriteNum) DoFindGround(New); nu->jump_speed = 0; - DoBeginJump(New); + DoBeginJump(actorNew); PlaySound(DIGI_FIRE1,np,v3df_dontpan|v3df_doppler); Set3DSoundOwner(New); @@ -10913,7 +10917,7 @@ SpawnBreakStaticFlames(int16_t SpriteNum) //DoFindGround(New); //nu->jump_speed = 0; - //DoBeginJump(New); + //DoBeginJump(actorNew); PlaySound(DIGI_FIRE1,np,v3df_dontpan|v3df_doppler); Set3DSoundOwner(New); @@ -12831,7 +12835,7 @@ DoSerpRing(DSWActor* actor) u->jump_speed = -800; change_sprite_stat(Weapon, STAT_ENEMY); NewStateGroup(Weapon, sg_SkullJump); - DoBeginJump(Weapon); + DoBeginJump(actor); // tell owner that one is gone // User[sp->owner]->Counter--; return 0;