Skip to content

Commit

Permalink
SW: fixed some bad sprite definitions and cleaned out unused data
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed Nov 27, 2023
1 parent a67f251 commit d26dfa2
Show file tree
Hide file tree
Showing 14 changed files with 111 additions and 196 deletions.
16 changes: 16 additions & 0 deletions source/common/textures/texturemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1624,6 +1624,22 @@ void FTextureManager::Listaliases()
}
}

FString FTextureManager::Listaliases(FTextureID id)
{
decltype(aliases)::Iterator it(aliases);
decltype(aliases)::Pair* pair;

FString list;
while (it.NextPair(pair))
{
if (pair->Value != id.GetIndex()) continue;
auto tex = GetGameTexture(pair->Value);
if (list.IsNotEmpty()) list += ", ";
list += pair->Key.GetChars();
}
return list;
}

//==========================================================================
//
// link a texture with a given lump
Expand Down
1 change: 1 addition & 0 deletions source/common/textures/texturemanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class FTextureManager

void FlushAll();
void Listaliases();
FString Listaliases(FTextureID);
FTextureID GetFrontSkyLayer(FTextureID);
FTextureID GetRawTexture(FTextureID tex, bool dontlookup = false);
void SetRawTexture(FTextureID texid)
Expand Down
68 changes: 45 additions & 23 deletions source/core/mainloop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,13 +400,57 @@ void DrawOverlays()
DrawRateStuff();
}

static void doDrawTile(const char* texname)
{
auto tex = TexMan.CheckForTexture(texname, ETextureType::Any);
if (!tex.isValid()) tex = tileGetTextureID(atoi(texname));
if (tex.isValid())
{
auto tx = TexMan.GetGameTexture(tex, true);
if (tx)
{
int width = (int)tx->GetDisplayWidth();
int height = (int)tx->GetDisplayHeight();
int dwidth, dheight;
if (width > height)
{
dwidth = screen->GetWidth() / 4;
dheight = height * dwidth / width;
}
else
{
dheight = screen->GetHeight() / 4;
dwidth = width * dheight / height;
}
DrawText(twod, SmallFont, CR_CYAN, 0, 5, FStringf("Displaying %s %s", texname, TexMan.Listaliases(tex).GetChars()).GetChars(), DTA_KeepRatio, true, TAG_DONE);
DrawTexture(twod, tx, 0, 30, DTA_DestWidth, dwidth, DTA_DestHeight, dheight, TAG_DONE);
}
}

}
//==========================================================================
//
// Display
//
//==========================================================================
CVAR(String, drawtile, "", 0) // debug stuff. Draws the tile with the given number on top of thze HUD

CCMD(nexttile)
{
do
{
*(drawtile.get()) = FStringf("#%05d", atoi(*drawtile + 1) + 1).GetChars();
} while (TexMan.CheckForTexture(*drawtile, ETextureType::Any).isNull());
}

CCMD(prevtile)
{
do
{
*(drawtile.get()) = FStringf("#%05d", atoi(*drawtile + 1) - 1).GetChars();
} while (TexMan.CheckForTexture(*drawtile, ETextureType::Any).isNull());
}

void Display()
{
if (screen == nullptr || (!AppActive && (screen->IsFullscreen() || !vid_activeinbackground)))
Expand Down Expand Up @@ -466,29 +510,7 @@ void Display()
DrawOverlays();
if (drawtile[0])
{
auto tex = TexMan.CheckForTexture(drawtile, ETextureType::Any);
if (!tex.isValid()) tex = tileGetTextureID(atoi(drawtile));
if (tex.isValid())
{
auto tx = TexMan.GetGameTexture(tex, true);
if (tx)
{
int width = (int)tx->GetDisplayWidth();
int height = (int)tx->GetDisplayHeight();
int dwidth, dheight;
if (width > height)
{
dwidth = screen->GetWidth() / 4;
dheight = height * dwidth / width;
}
else
{
dheight = screen->GetHeight() / 4;
dwidth = width * dheight / height;
}
DrawTexture(twod, tx, 0, 0, DTA_DestWidth, dwidth, DTA_DestHeight, dheight, TAG_DONE);
}
}
doDrawTile(drawtile);
}
}
else
Expand Down
16 changes: 15 additions & 1 deletion source/core/textures/tilesetbuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,20 @@ static void GenerateRotations(int firsttileid, const char* basename, int tile, i
}
}
}
else if (order == -1)
{
for (int rotation = 0; rotation < numrotations; rotation++)
{
int oldtile = tile;
for (int frame = 0; frame < numframes; frame++)
{
FStringf str("%s@%c%x", basename, frame + 'A', rotation + 1);
TexMan.AddAlias(str.GetChars(), FSetTextureID(firsttileid + tile));
tile++;
}
tile -= 2 * numframes;
}
}
}

static void CompleteRotations(int firsttileid, const char* basename, const char* getname, int numframes, int numrotations)
Expand Down Expand Up @@ -317,7 +331,7 @@ void LoadAliases(int firsttileid, int maxarttile)
sc.ScriptMessage("%d: Bad number of rotations\n", numrotations);
continue;
}
if (order < 0)
if (order < -1)
{
sc.ScriptMessage("%d: Bad order\n", order);
continue;
Expand Down
20 changes: 0 additions & 20 deletions source/games/sw/src/coolg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,24 +140,6 @@ FState s_CoolgStand[] =
{SPR_COOLG_RUN, 'A', COOLG_RUN_RATE, &AF(DoCoolgMove), &s_CoolgStand[0]},
};

//////////////////////
//
// COOLG CLUB
//
//////////////////////

#define COOLG_RATE 16

FState s_CoolgClub[] =
{
{SPR_COOLG_CLUB, 'A', COOLG_RATE, &AF(NullCoolg), &s_CoolgClub[1]},
{SPR_COOLG_RUN, 'A', COOLG_RATE, &AF(NullCoolg), &s_CoolgClub[2]},
{SPR_COOLG_CLUB, 'B', 0|SF_QUICK_CALL, &AF(InitCoolgBash), &s_CoolgClub[3]},
{SPR_COOLG_CLUB, 'B', COOLG_RATE, &AF(NullCoolg), &s_CoolgClub[4]},
{SPR_COOLG_CLUB, 'B', 0|SF_QUICK_CALL, &AF(InitActorDecide), &s_CoolgClub[5]},
{SPR_COOLG_CLUB, 'B', COOLG_RATE, &AF(DoCoolgMove), &s_CoolgClub[5]}
};

//////////////////////
//
// COOLG FIRE
Expand Down Expand Up @@ -281,7 +263,6 @@ ACTOR_ACTION_SET CoolgActionSet =
s_CoolgDead,
nullptr,
nullptr,
// {s_CoolgClub},
{s_CoolgAttack},
{1024},
{s_CoolgAttack},
Expand Down Expand Up @@ -745,7 +726,6 @@ static saveable_data saveable_coolg_data[] =

SAVE_DATA(s_CoolgRun),
SAVE_DATA(s_CoolgStand),
SAVE_DATA(s_CoolgClub),
SAVE_DATA(s_CoolgAttack),
SAVE_DATA(s_CoolgPain),
SAVE_DATA(s_CoolgDie),
Expand Down
4 changes: 2 additions & 2 deletions source/games/sw/src/goro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ FState s_GoroSpell[] =

FState s_GoroStand[] =
{
{SPR_GORO_STAND, 'A', GORO_STAND_RATE, &AF(DoGoroMove), &s_GoroStand[0]},
{SPR_GORO_CHOP, 'A', GORO_STAND_RATE, &AF(DoGoroMove), &s_GoroStand[0]},
};


Expand All @@ -190,7 +190,7 @@ FState s_GoroStand[] =

FState s_GoroPain[] =
{
{SPR_GORO_STAND, 'A', GORO_PAIN_RATE, &AF(DoGoroPain), &s_GoroPain[0]},
{SPR_GORO_CHOP, 'A', GORO_PAIN_RATE, &AF(DoGoroPain), &s_GoroPain[0]},
};


Expand Down
23 changes: 1 addition & 22 deletions source/games/sw/src/namelist.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ x(MENU_CURSOR, 298)
x(DART1, 2000)
x(DART2, 2001)
x(DART3, 2002)
x(DART4, 2003)
x(DART, 2004)
x(FIRE1, 2005)
x(FIRE2, 2006)
Expand Down Expand Up @@ -47,10 +46,8 @@ x(LIGHT6, 2040)
x(ELECTRO1, 2041)
x(ELECTRO2, 2042)
x(ELECTRO3, 2043)
x(RIFLE1, 2044)
x(RIFLE2, 2045)
x(RIFLE3, 2046)
x(DONTUSE_EXTRA, 2047)
x(RIFLE4, 2048)
x(CARTRIGE3, 2053)
x(STATUE1, 2054)
Expand Down Expand Up @@ -102,8 +99,6 @@ x(ICON_CLOAK, 1804)
x(ICON_NIGHT_VISION, 3031)
x(ICON_NAPALM, 3046)
x(ICON_RING, 3050)
x(ICON_GOROAMMO, 3035)
x(ICON_HEARTAMMO, 1820)
x(ICON_RINGAMMO, 3054)
x(ICON_NAPALMAMMO, 3058)
x(ICON_GRENADE, 3059)
Expand All @@ -124,7 +119,6 @@ x(STARTALPHANUM, 4608)
x(ENDALPHANUM, 4701)
x(STATUS_BAR, 2434)
x(STATUS_KEYS, 2881)
x(STATUS_NUMBERS, 2887)
x(BORDER_TILE, 2604)
x(BLUE_KEY, 1766)
x(BLUE_KEY_STATUE, 1768)
Expand Down Expand Up @@ -764,7 +758,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)
Expand Down Expand Up @@ -826,18 +820,6 @@ x(BLOODYSWORD_SWING0, 4091)
x(BLOODYSWORD_SWING1, 4092)
x(BLOODYSWORD_SWING2, 4093)
x(FIST2_SWING_ALT, 4058)
x(FIST3_REST, 4060)
x(FIST3_SWING0, 4061)
x(FIST3_SWING1, 4062)
x(FIST3_SWING2, 4063)
x(BLOODYFIST3_REST, 4064)
x(BLOODYFIST3_SWING0, 4065)
x(BLOODYFIST3_SWING1, 4066)
x(BLOODYFIST3_SWING2, 4067)
x(KICK0, 4080)
x(KICK1, 4081)
x(BLOODYKICK0, 4082)
x(BLOODYKICK1, 4083)
x(STAR_REST, 2130)
x(STAR_DOWN0, 2131)
x(STAR_DOWN1, 2132)
Expand Down Expand Up @@ -894,7 +876,6 @@ x(RAIL_FIRE0, 2018)
x(RAIL_FIRE1, 2019)
x(HOTHEAD_REST, 2048)
x(HOTHEAD_ATTACK, 2049)
x(HOTHEAD_CENTER, 2327)
x(HOTHEAD_TURN0, 2314)
x(HOTHEAD_TURN1, 2315)
x(HOTHEAD_TURN2, 2316)
Expand Down Expand Up @@ -943,5 +924,3 @@ x(ChopsOpen, 2001)
x(ChopsClose, 2002)
x(FIST2_REST, 4050)
x(FIST2_SWING0, 4051)
x(FIST2_SWING1, 4052)
x(FIST2_SWING2, 4053)
58 changes: 2 additions & 56 deletions source/games/sw/src/panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6557,43 +6557,6 @@ PANEL_STATE ps_Fist2Swing[] =
{SPR_FIST2_SWING_ALT, 2, /* end slide */ &AF(pFistSlideDown), &ps_Fist2Swing[4], 0,0,0},
};

PANEL_STATE ps_Fist3Swing[] =
{
{SPR_FIST3_SWING0, FIST_PAUSE_TICS+25, nullptr, &ps_Fist3Swing[1], 0,0,0},
{SPR_FIST3_SWING1, 0, /* damage */ &AF(pFistAttack), &ps_Fist3Swing[2], psf_QuickCall, 0,0},
{SPR_FIST3_SWING2, FIST_PAUSE_TICS+10, nullptr, &ps_Fist3Swing[3], 0,0,0},
{SPR_FIST3_SWING2, FIST_MID_SLIDE_TICS+3, /* mid slide */ &AF(pFistSlideDown), &ps_Fist3Swing[4], 0,0,0},

{SPR_FIST3_SWING2, 8, /* end slide */ &AF(pFistSlideDown), &ps_Fist3Swing[4], 0,0,0},

{SPR_FIST3_SWING1, FIST_SLIDE_TICS+20, /* start slide */ &AF(pFistSlideR), &ps_Fist3Swing[6], psf_Xflip, 0,0},
{SPR_FIST3_SWING2, 0, /* damage */ &AF(pFistAttack), &ps_Fist3Swing[7], psf_QuickCall|psf_Xflip, 0,0},
{SPR_FIST3_SWING2, FIST_MID_SLIDE_TICS+3, /* mid slide */ &AF(pFistSlideDownR), &ps_Fist3Swing[8], psf_Xflip, 0,0},

{SPR_FIST3_SWING2, 8, /* end slide */ &AF(pFistSlideDownR), &ps_Fist3Swing[8], psf_Xflip, 0,0},
{SPR_FIST3_SWING2, 8, /* end slide */ nullptr, &ps_Fist3Swing[1], psf_Xflip, 0,0},
};

#define KICK_PAUSE_TICS 40
#define KICK_SLIDE_TICS 30
#define KICK_MID_SLIDE_TICS 20

PANEL_STATE ps_Kick[] =
{
{SPR_KICK0, KICK_PAUSE_TICS, nullptr, &ps_Kick[1], 0,0,0},
{SPR_KICK1, 0, /* damage */ &AF(pFistAttack), &ps_Kick[2], psf_QuickCall, 0,0},
{SPR_KICK1, KICK_SLIDE_TICS, /* start slide */ nullptr, &ps_Kick[3], 0,0,0},
{SPR_KICK1, KICK_MID_SLIDE_TICS, /* mid slide */ &AF(pFistSlideDown), &ps_Kick[4], 0,0,0},

{SPR_KICK1, 30, /* end slide */ &AF(pFistSlideDown), &ps_Kick[4], 0,0,0},

{SPR_KICK0, KICK_SLIDE_TICS, /* start slide */ nullptr, &ps_Kick[6], psf_Xflip, 0,0},
{SPR_KICK1, 0, /* damage */ &AF(pFistAttack), &ps_Kick[7], psf_QuickCall|psf_Xflip, 0,0},
{SPR_KICK1, KICK_MID_SLIDE_TICS,/* mid slide */ &AF(pFistSlideDownR), &ps_Kick[8], psf_Xflip, 0, 0},

{SPR_KICK1, 30, /* end slide */ &AF(pFistSlideDownR), &ps_Kick[8], psf_Xflip, 0,0},
{SPR_KICK1, 30, /* end slide */ nullptr, &ps_Kick[1], psf_Xflip, 0,0},
};

PANEL_STATE ps_RetractFist[] =
{
Expand Down Expand Up @@ -6746,7 +6709,7 @@ void pFistSlideDown(DPanelSprite* psp)

psp->backupcoords();

if (psp->ActionState == ps_Kick || psp->PlayerP->WpnKungFuMove == 3)
if (psp->PlayerP->WpnKungFuMove == 3)
{
psp->pos.Y -= pspSinVel(psp, ang);
}
Expand All @@ -6769,15 +6732,8 @@ void pFistSlideDown(DPanelSprite* psp)

if (RandomRange(1000) > 500)
{
//if(RandomRange(1000) > 300)
// {
psp->ActionState = ps_FistSwing;
psp->PlayerP->WpnKungFuMove = 0;
// } else
// {
// psp->ActionState = ps_Fist3Swing;
// psp->PlayerP->WpnKungFuMove = 1;
// }
pSetState(psp, psp->ActionState);

psp->opos.X = psp->pos.X = FIST_XOFF;
Expand Down Expand Up @@ -6849,7 +6805,7 @@ void pFistSlideDownR(DPanelSprite* psp)

psp->backupcoords();

if (psp->ActionState == ps_Kick || psp->PlayerP->WpnKungFuMove == 3)
if (psp->PlayerP->WpnKungFuMove == 3)
{
psp->pos.Y -= pspSinVel(psp, ang);
}
Expand Down Expand Up @@ -6973,9 +6929,6 @@ void pFistRest(DPanelSprite* psp)

force = !!(psp->flags & PANF_UNHIDE_SHOOT);

if (psp->ActionState == ps_Kick)
psp->ActionState = ps_FistSwing;

// Reset move to default
psp->PlayerP->WpnKungFuMove = 0;

Expand Down Expand Up @@ -7868,15 +7821,8 @@ static saveable_data saveable_panel_data[] =
SAVE_DATA(ps_PresentFist2),
SAVE_DATA(ps_Fist2Rest),
SAVE_DATA(ps_Fist2Hide),
/*
SAVE_DATA(ps_PresentFist3),
SAVE_DATA(ps_Fist3Rest),
SAVE_DATA(ps_Fist3Hide),
*/
SAVE_DATA(ps_FistSwing),
SAVE_DATA(ps_Fist2Swing),
SAVE_DATA(ps_Fist3Swing),
SAVE_DATA(ps_Kick),
SAVE_DATA(ps_RetractFist),

SAVE_DATA(ps_PanelEnvironSuit),
Expand Down
2 changes: 0 additions & 2 deletions source/games/sw/src/save.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ extern bool bosswasseen[3];

#define ANIM_SAVE 1

extern FState s_NotRestored[];




Expand Down
Loading

0 comments on commit d26dfa2

Please sign in to comment.