diff --git a/source/games/sw/src/draw.cpp b/source/games/sw/src/draw.cpp index 7d7fdf5375..435606f9a2 100644 --- a/source/games/sw/src/draw.cpp +++ b/source/games/sw/src/draw.cpp @@ -472,25 +472,14 @@ void WarpCopySprite(tspriteArray& tsprites) void DoStarView(tspritetype* tsp, DSWActor* tActor, double viewz) { - extern FState s_Star[], s_StarDown[]; - extern FState s_StarStuck[], s_StarDownStuck[]; double zdiff = viewz - tsp->pos.Z; if (abs(zdiff) > 24) { - if (tActor->user.__legacyState.StateStart == s_StarStuck) - tsp->setspritetexture(picFromState(&s_StarDownStuck[tActor->user.State - s_StarStuck])); - else - tsp->setspritetexture(picFromState(&s_StarDown[tActor->user.State - s_Star])); - - if (zdiff > 0) - tsp->cstat |= (CSTAT_SPRITE_YFLIP); - } - else - { - if (zdiff > 0) - tsp->cstat |= (CSTAT_SPRITE_YFLIP); + tsp->setspritetexture(GetTextureReplacement(tsp->spritetexture(), NAME_StarView)); } + if (zdiff > 0) + tsp->cstat |= (CSTAT_SPRITE_YFLIP); } //--------------------------------------------------------------------------- @@ -1061,7 +1050,6 @@ void PreDrawStackedWater(void) // analyzesprites() needs to draw the image actorNew->user.State = itActor2->user.State; actorNew->user.__legacyState.Rot = itActor2->user.__legacyState.Rot; - actorNew->user.__legacyState.StateStart = itActor2->user.__legacyState.StateStart; actorNew->user.__legacyState.StateEnd = itActor2->user.__legacyState.StateEnd; actorNew->user.Flags = itActor2->user.Flags; actorNew->user.Flags2 = itActor2->user.Flags2; diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 8f8cd0e03d..7b164acecd 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -711,7 +711,6 @@ struct USER struct LegacyState { FState* Rot; - FState* StateStart; FState* StateEnd; FState* StateFallOverride; // a bit kludgy - override std fall state ACTOR_ACTION_SET* ActorActionSet; diff --git a/source/games/sw/src/namelist.h b/source/games/sw/src/namelist.h index f3904b7204..42787d70b0 100644 --- a/source/games/sw/src/namelist.h +++ b/source/games/sw/src/namelist.h @@ -764,7 +764,7 @@ x(CARD_LOCKED, 1852) x(CARD_UNLOCKED, 1853) x(BREAK_LIGHT, 443) x(BREAK_MUSHROOM, 666) -x(STAR1, 2049) +x(STAR1, 2049) // this is not a texture - just a spawn ID! x(CRACK, 80) x(BLADE4, 5011) x(FFIRE1, 3143) diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index da0a006054..f1a21e460e 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -1119,7 +1119,6 @@ void UpdatePlayerUnderSprite(DSWPlayer* pp) act_under->user.State = act_over->user.State; act_under->user.__legacyState.Rot = act_over->user.__legacyState.Rot; - act_under->user.__legacyState.StateStart = act_over->user.__legacyState.StateStart; act_under->spr.setspritetexture(act_over->spr.spritetexture()); } diff --git a/source/games/sw/src/save.cpp b/source/games/sw/src/save.cpp index 3fe36c5d24..741aa11515 100644 --- a/source/games/sw/src/save.cpp +++ b/source/games/sw/src/save.cpp @@ -595,13 +595,11 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, USER& w, USER* def // The default serializer cannot handle the statically defined states so call these functons explicitly. _Serialize(arc, "State", w.State, &def->State); _Serialize(arc, "Rot", w.__legacyState.Rot, &def->__legacyState.Rot); - _Serialize(arc, "StateStart", w.__legacyState.StateStart, &def->__legacyState.StateStart); _Serialize(arc, "StateEnd", w.__legacyState.StateEnd, &def->__legacyState.StateEnd); _Serialize(arc, "StateFallOverride", w.__legacyState.StateFallOverride, &def->__legacyState.StateFallOverride); /* ("State", w.State, def->State) ("Rot", w.__legacyState.Rot, def->__legacyState.Rot) - ("StateStart", w.__legacyState.StateStart, def->__legacyState.StateStart) ("StateEnd", w.__legacyState.StateEnd, def->__legacyState.StateEnd) ("StateFallOverride", w.__legacyState.StateFallOverride, def->__legacyState.StateFallOverride) */ diff --git a/source/games/sw/src/sprite.cpp b/source/games/sw/src/sprite.cpp index 177534c793..e6f48ea8ec 100644 --- a/source/games/sw/src/sprite.cpp +++ b/source/games/sw/src/sprite.cpp @@ -690,7 +690,6 @@ void ChangeState(DSWActor* actor, FState* statep) return; actor->user.Tics = 0; - actor->user.State = actor->user.__legacyState.StateStart = statep; actor->spr.cstat2 |= CSTAT2_SPRITE_NOANIMATE; // just in case } @@ -761,8 +760,6 @@ void SpawnUser(DSWActor* actor, short id, FState* state) PRODUCTION_ASSERT(actor->hasU()); // be careful State can be nullptr - actor->user.State = actor->user.__legacyState.StateStart = state; - change_actor_stat(actor, actor->spr.statnum); actor->user.ID = id; @@ -4202,7 +4199,6 @@ int NewStateGroup(DSWActor* actor, FState* StateGroup) return 0; actor->user.__legacyState.Rot = StateGroup; - actor->user.State = actor->user.__legacyState.StateStart = StateGroup; actor->user.Tics = 0; @@ -4682,6 +4678,18 @@ int DoKey(DSWActor* actor) // //--------------------------------------------------------------------------- +static FState* LookForFrame(FState* start, int frame) +{ + auto state = start; + // try to do this as hack-free as possible, but make no assumptions about the state organization. + while (state && state->NextState == state + 1 && state->sprite == start->sprite) + { + if (state->Frame == frame) return state; + state++; + } + return start; +} + int DoCoin(DSWActor* actor) { int offset; @@ -4696,26 +4704,34 @@ int DoCoin(DSWActor* actor) if (actor->user.WaitTics < 10*120) { - if (actor->user.__legacyState.StateStart != s_GreenCoin) + if (actor->spr.inittype == 1) { - offset = int(actor->user.State - actor->user.__legacyState.StateStart); - ChangeState(actor, s_GreenCoin); - actor->user.State = actor->user.__legacyState.StateStart + offset; + actor->spr.inittype = 2; + ChangeState(actor, LookForFrame(s_GreenCoin, actor->user.State->Frame)); } } else if (actor->user.WaitTics < 20*120) { - if (actor->user.__legacyState.StateStart != s_YellowCoin) + if (actor->spr.inittype == 0) { - offset = int(actor->user.State - actor->user.__legacyState.StateStart); - ChangeState(actor, s_YellowCoin); - actor->user.State = actor->user.__legacyState.StateStart + offset; + actor->spr.inittype = 1; + ChangeState(actor, LookForFrame(s_YellowCoin, actor->user.State->Frame)); } } return 0; } + +void SpawnCoin(DSWActor* actor) +{ + auto actorNew = SpawnActor(STAT_ITEM, Red_COIN, s_RedCoin, actor->sector(), actor->spr.pos, nullAngle); + + actorNew->spr.inittype = 0; + actorNew->spr.shade = -20; + actorNew->user.WaitTics = actor->user.WaitTics - 12; + +} //--------------------------------------------------------------------------- // // @@ -4746,11 +4762,8 @@ int KillGet(DSWActor* actor) if (!gNet.SpawnMarkers || actor->spr.hitag == TAG_NORESPAWN_FLAG) // No coin if it's a special flag break; - auto actorNew = SpawnActor(STAT_ITEM, Red_COIN, s_RedCoin, actor->sector(), actor->spr.pos, nullAngle); - - actorNew->spr.shade = -20; - actorNew->user.WaitTics = actor->user.WaitTics - 12; + SpawnCoin(actor); break; } return 0; @@ -4794,11 +4807,7 @@ int KillGetAmmo(DSWActor* actor) if (!gNet.SpawnMarkers) break; - auto actorNew = SpawnActor(STAT_ITEM, Red_COIN, s_RedCoin, actor->sector(), actor->spr.pos, nullAngle); - - actorNew->spr.shade = -20; - actorNew->user.WaitTics = actor->user.WaitTics - 12; - + SpawnCoin(actor); break; } return 0; @@ -4850,11 +4859,7 @@ int KillGetWeapon(DSWActor* actor) if (!gNet.SpawnMarkers) break; - auto actorNew = SpawnActor(STAT_ITEM, Red_COIN, s_RedCoin, actor->sector(), actor->spr.pos, nullAngle); - - actorNew->spr.shade = -20; - actorNew->user.WaitTics = actor->user.WaitTics - 12; - + SpawnCoin(actor); break; } return 0; diff --git a/wadsrc/static/filter/shadowwarrior/rmapinfo.texflags b/wadsrc/static/filter/shadowwarrior/rmapinfo.texflags index c8445af15a..7100eca689 100644 --- a/wadsrc/static/filter/shadowwarrior/rmapinfo.texflags +++ b/wadsrc/static/filter/shadowwarrior/rmapinfo.texflags @@ -118,3 +118,11 @@ texturereplace shotgun2 SHOTGUN_RELOAD1 = SHOTGUN2_RELOAD1 SHOTGUN_RELOAD2 = SHOTGUN2_RELOAD2 } + +texturereplace StarView +{ + "STAR@A1" = "STAR_DOWN@A1" + "STAR@B1" = "STAR_DOWN@B1" + "STAR@C1" = "STAR_DOWN@C1" + "STAR@D1" = "STAR_DOWN@D1" +}