Skip to content

Commit

Permalink
Fixed cyclic dependency on "hu_stuff.h".
Browse files Browse the repository at this point in the history
Moved all menu patch registration to Hu_MenuLoadResources()
Only register the episode name patches with the gamemodes of __JDOOM__ that require them.
Fixed compile warning in gcc about struct mn_object_s being used before its defined.
  • Loading branch information
danij-deng committed May 8, 2011
1 parent 5737537 commit dba96aa
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 55 deletions.
12 changes: 1 addition & 11 deletions doomsday/plugins/common/include/hu_stuff.h
Expand Up @@ -27,11 +27,6 @@
#define LIBCOMMON_HU_STUFF_H

#include "gl_drawpatch.h"
#if __JHEXEN__
# include "h2def.h"
#else
# include "doomdef.h"
#endif

// The fonts.
typedef enum {
Expand Down Expand Up @@ -74,12 +69,7 @@ enum {
extern fontid_t fonts[NUM_GAME_FONTS];

extern patchid_t* pMapNames; // Name graphics of each map.
#if __JDOOM__ || __JDOOM64__
extern patchid_t pSkillModeNames[NUM_SKILL_MODES]; // Name graphics of each skill mode.
#endif
#if __JDOOM__
extern patchid_t* pEpisodeNames; // Name graphics of each episode.
#endif

#if __JHERETIC__ || __JHEXEN__
extern patchid_t pInvItemBox;
extern patchid_t pInvSelectBox;
Expand Down
3 changes: 2 additions & 1 deletion doomsday/plugins/common/include/m_defs.h
Expand Up @@ -29,9 +29,10 @@
#ifndef LIBCOMMON_M_DEFS_H
#define LIBCOMMON_M_DEFS_H

#include "r_common.h"
#include "hu_stuff.h"

struct mn_object_s;

typedef enum menucommand_e {
MCMD_OPEN, // Open the menu.
MCMD_CLOSE, // Close the menu.
Expand Down
28 changes: 28 additions & 0 deletions doomsday/plugins/common/src/hu_menu.c
Expand Up @@ -335,6 +335,11 @@ static patchid_t pSaveGame;
static patchid_t pReadThis;
static patchid_t pQuitGame;
static patchid_t pOptionsTitle;

static patchid_t pSkillModeNames[NUM_SKILL_MODES];
#endif
#if __JDOOM__
static patchid_t pEpisodeNames[4];
#endif

#if __JHEXEN__
Expand Down Expand Up @@ -1361,6 +1366,29 @@ void Hu_MenuLoadResources(void)
pOptionsTitle = R_PrecachePatch("M_OPTTTL", NULL);
#endif

#if __JDOOM__ || __JDOOM64__
pSkillModeNames[SM_BABY] = R_PrecachePatch("M_JKILL", NULL);
pSkillModeNames[SM_EASY] = R_PrecachePatch("M_ROUGH", NULL);
pSkillModeNames[SM_MEDIUM] = R_PrecachePatch("M_HURT", NULL);
pSkillModeNames[SM_HARD] = R_PrecachePatch("M_ULTRA", NULL);
# if __JDOOM__
pSkillModeNames[SM_NIGHTMARE] = R_PrecachePatch("M_NMARE", NULL);
# endif
#endif

#if __JDOOM__
if(gameModeBits & (GM_DOOM_SHAREWARE|GM_DOOM|GM_DOOM_ULTIMATE))
{
pEpisodeNames[0] = R_PrecachePatch("M_EPI1", NULL);
pEpisodeNames[1] = R_PrecachePatch("M_EPI2", NULL);
pEpisodeNames[2] = R_PrecachePatch("M_EPI3", NULL);
}
if(gameModeBits & GM_DOOM_ULTIMATE)
{
pEpisodeNames[3] = R_PrecachePatch("M_EPI4", NULL);
}
#endif

#if __JHERETIC__
{ int i;
for(i = 0; i < 18; ++i)
Expand Down
44 changes: 1 addition & 43 deletions doomsday/plugins/common/src/hu_stuff.c
Expand Up @@ -55,6 +55,7 @@
#include "p_tick.h"
#include "am_map.h"
#include "fi_lib.h"
#include "r_common.h"

// MACROS ------------------------------------------------------------------

Expand Down Expand Up @@ -106,13 +107,6 @@ fontid_t fonts[NUM_GAME_FONTS];
#if __JDOOM__ || __JDOOM64__
// Name graphics of each map.
patchid_t* pMapNames = NULL;
// Name graphics of each skill mode.
patchid_t pSkillModeNames[NUM_SKILL_MODES];
#endif

#if __JDOOM__
// Name graphics of each episode.
patchid_t* pEpisodeNames = NULL;
#endif

#if __JDOOM__ || __JDOOM64__
Expand Down Expand Up @@ -205,27 +199,6 @@ static short translatePatchToTextDrawFlags(short in)
*/
void Hu_LoadData(void)
{
#if __JDOOM__ || __JDOOM64__
static const char* skillModePatchNames[] =
{
"M_JKILL",
"M_ROUGH",
"M_HURT",
"M_ULTRA",
# if __JDOOM__
"M_NMARE"
# endif
};
#endif
#if __JDOOM__
static const char* episodePatchNames[] =
{
"M_EPI1",
"M_EPI2",
"M_EPI3",
"M_EPI4"
};
#endif
#if __JDOOM__ || __JDOOM64__
char name[9];
#endif
Expand Down Expand Up @@ -272,11 +245,6 @@ void Hu_LoadData(void)
#endif

#if __JDOOM__ || __JDOOM64__
for(i = 0; i < NUM_SKILL_MODES; ++i)
{
pSkillModeNames[i] = R_PrecachePatch(skillModePatchNames[i], NULL);
}

// Load the map name patches.
# if __JDOOM64__
{
Expand Down Expand Up @@ -314,10 +282,6 @@ void Hu_LoadData(void)
pMapNames[(i* 9) + j] = R_PrecachePatch(name, NULL);
}
}

pEpisodeNames = Z_Malloc(sizeof(patchid_t) * 4, PU_GAMESTATIC, 0);
for(i = 0; i < 4; ++i)
pEpisodeNames[i] = R_PrecachePatch(episodePatchNames[i], NULL);
}
# endif
#endif
Expand Down Expand Up @@ -353,12 +317,6 @@ void Hu_UnloadData(void)
pMapNames = 0;
#endif

#if __JDOOM__
if(pEpisodeNames)
Z_Free(pEpisodeNames);
pEpisodeNames = 0;
#endif

if(!Get(DD_NOVIDEO))
{
if(fogEffectData.texture)
Expand Down

0 comments on commit dba96aa

Please sign in to comment.