Skip to content

Commit

Permalink
libcommon: Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Jul 13, 2012
1 parent c17c5ba commit 40b5f3f
Show file tree
Hide file tree
Showing 13 changed files with 63 additions and 48 deletions.
13 changes: 12 additions & 1 deletion doomsday/plugins/common/include/g_common.h
Expand Up @@ -71,7 +71,18 @@ boolean G_QuitInProgress(void);
* @param mapEntryPoint Logical map entry point number.
*/
void G_InitNew(skillmode_t skill, uint episode, uint map, uint mapEntryPoint);
void G_DeferedInitNew(skillmode_t skill, uint episode, uint map, uint mapEntryPoint);
void G_DeferedNewGame(skillmode_t skill, uint episode, uint map, uint mapEntryPoint);

#if __JHEXEN__
/**
* Same as @ref G_DeferedNewGame() except a GA_NEWGAME action is queued
* instead of GA_INITNEW.
*
* @todo Why the distinction, surely starting a new game requires the same
* logic regardless of where the action originated.
*/
void G_DeferedNewGameAlt(skillmode_t skill, uint episode, uint map, uint mapEntryPoint);
#endif

/**
* Leave the current map and start intermission routine.
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/common/src/d_net.c
Expand Up @@ -862,7 +862,7 @@ D_CMD(SetMap)
cfg.jumpEnabled = cfg.netJumping;

// Use the configured network skill level for the new map.
G_DeferedInitNew(cfg.netSkill, ep, map, 0/*default*/);
G_DeferedNewGame(cfg.netSkill, ep, map, 0/*default*/);
return true;
}

Expand Down
70 changes: 35 additions & 35 deletions doomsday/plugins/common/src/g_game.c
Expand Up @@ -144,7 +144,6 @@ D_CMD(SaveGame);
D_CMD(OpenSaveMenu);

void G_PlayerReborn(int player);
void G_DoInitNew(void);
void G_DoReborn(int playernum);

typedef struct {
Expand Down Expand Up @@ -1618,18 +1617,13 @@ static void runGameAction(void)
{
#if __JHEXEN__
case GA_INITNEW:
G_DoInitNew();
SV_HxInitBaseSlot();
G_InitNew(dSkill, dEpisode, dMap, dMapEntryPoint);
G_SetGameAction(GA_NONE);
break;
#endif

case GA_LEAVEMAP:
G_DoLeaveMap();
G_SetGameAction(GA_NONE);
break;

case GA_RESTARTMAP:
G_DoRestartMap();
case GA_NEWGAME:
G_DoNewGame();
G_SetGameAction(GA_NONE);
break;

Expand All @@ -1641,23 +1635,33 @@ static void runGameAction(void)
G_DoSaveGame();
break;

case GA_MAPCOMPLETED:
G_DoMapCompleted();
case GA_QUIT:
G_DoQuitGame();
// No further game state changes occur once we have begun to quit.
return;

case GA_SCREENSHOT:
G_DoScreenShot();
G_SetGameAction(GA_NONE);
break;

case GA_VICTORY:
case GA_LEAVEMAP:
G_DoLeaveMap();
G_SetGameAction(GA_NONE);
break;

case GA_SCREENSHOT:
G_DoScreenShot();
case GA_RESTARTMAP:
G_DoRestartMap();
G_SetGameAction(GA_NONE);
break;

case GA_QUIT:
G_DoQuitGame();
// No further game state changes occur once we have begun to quit.
return;
case GA_MAPCOMPLETED:
G_DoMapCompleted();
break;

case GA_VICTORY:
G_SetGameAction(GA_NONE);
break;

default: break;
}
Expand Down Expand Up @@ -2935,34 +2939,31 @@ void G_DoSaveGame(void)
G_SetGameAction(GA_NONE);
}

#if __JHEXEN__
void G_DeferredNewGame(skillmode_t skill)
void G_DeferedNewGame(skillmode_t skill, uint episode, uint map, uint mapEntryPoint)
{
dSkill = skill;
dMapEntryPoint = 0;
G_SetGameAction(GA_NEWGAME);
}
dEpisode = episode;
dMap = map;
dMapEntryPoint = mapEntryPoint;

void G_DoInitNew(void)
{
SV_HxInitBaseSlot();
G_InitNew(dSkill, dEpisode, dMap, dMapEntryPoint);
}
#if __JHEXEN__
G_SetGameAction(GA_INITNEW);
#else
G_SetGameAction(GA_NEWGAME);
#endif
}

void G_DeferedInitNew(skillmode_t skill, uint episode, uint map, uint mapEntryPoint)
#if __JHEXEN__
void G_DeferedNewGameAlt(skillmode_t skill, uint episode, uint map, uint mapEntryPoint)
{
dSkill = skill;
dEpisode = episode;
dMap = map;
dMapEntryPoint = mapEntryPoint;

#if __JHEXEN__
G_SetGameAction(GA_INITNEW);
#else
G_SetGameAction(GA_NEWGAME);
#endif
}
#endif

void G_DoNewGame(void)
{
Expand All @@ -2979,7 +2980,6 @@ void G_DoNewGame(void)
G_StartNewInit();
#endif
G_InitNew(dSkill, dEpisode, dMap, dMapEntryPoint);
G_SetGameAction(GA_NONE);
}

void G_InitNew(skillmode_t skill, uint episode, uint map, uint mapEntryPoint)
Expand Down
9 changes: 7 additions & 2 deletions doomsday/plugins/common/src/hu_menu.c
Expand Up @@ -6127,12 +6127,17 @@ void Hu_MenuInitNewGame(boolean confirmed)
return;
}
#endif

Hu_MenuCommand(chooseCloseMethod());

#if __JHEXEN__
cfg.playerClass[CONSOLEPLAYER] = mnPlrClass;
G_DeferredNewGame(mnSkillmode);
#endif

#if __JHEXEN__
G_DeferedNewGameAlt(mnSkillmode, mnEpisode, P_TranslateMap(0), 0/*default*/);
#else
G_DeferedInitNew(mnSkillmode, mnEpisode, 0, 0/*default*/);
G_DeferedNewGame(mnSkillmode, mnEpisode, 0, 0/*default*/);
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/jdoom/src/d_main.c
Expand Up @@ -577,7 +577,7 @@ void D_PostInit(void)

if(autoStart || IS_NETGAME)
{
G_DeferedInitNew(startSkill, startEpisode, startMap, 0/*default*/);
G_DeferedNewGame(startSkill, startEpisode, startMap, 0/*default*/);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/jdoom/src/m_cheat.c
Expand Up @@ -366,7 +366,7 @@ int Cht_WarpFunc(const int* args, int player)

// So be it.
briefDisabled = true;
G_DeferedInitNew(gameSkill, epsd, map, 0/*default*/);
G_DeferedNewGame(gameSkill, epsd, map, 0/*default*/);

return true;
}
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/jdoom64/src/d_main.c
Expand Up @@ -470,7 +470,7 @@ void D_PostInit(void)

if(autoStart || IS_NETGAME)
{
G_DeferedInitNew(startSkill, startEpisode, startMap, 0/*default*/);
G_DeferedNewGame(startSkill, startEpisode, startMap, 0/*default*/);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/jdoom64/src/m_cheat.c
Expand Up @@ -175,7 +175,7 @@ boolean Cht_WarpFunc(player_t* plr, cheatseq_t* cheat)

// So be it.
briefDisabled = true;
G_DeferedInitNew(gameSkill, epsd, map, 0/*default*/);
G_DeferedNewGame(gameSkill, epsd, map, 0/*default*/);

return true;
}
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/jheretic/src/h_main.c
Expand Up @@ -491,7 +491,7 @@ void H_PostInit(void)

if(autoStart || IS_NETGAME)
{
G_DeferedInitNew(startSkill, startEpisode, startMap, 0/*default*/);
G_DeferedNewGame(startSkill, startEpisode, startMap, 0/*default*/);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/jheretic/src/m_cheat.c
Expand Up @@ -336,7 +336,7 @@ int Cht_WarpFunc(const int* args, int player)

// So be it.
briefDisabled = true;
G_DeferedInitNew(gameSkill, epsd, map, 0/* default*/);
G_DeferedNewGame(gameSkill, epsd, map, 0/* default*/);

return true;
}
Expand Down
1 change: 0 additions & 1 deletion doomsday/plugins/jhexen/include/g_game.h
Expand Up @@ -119,7 +119,6 @@ void* G_GetVariable(int id);

void G_DeathMatchSpawnPlayer(int playernum);
uint G_GetMapNumber(uint episode, uint map);
void G_DeferredNewGame(skillmode_t skill);
void G_DeferedPlayDemo(char* demo);
void G_DoPlayDemo(void);

Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/jhexen/src/h2_main.c
Expand Up @@ -483,7 +483,7 @@ void X_PostInit(void)

if(autoStart || IS_NETGAME)
{
G_DeferedInitNew(startSkill, startEpisode, startMap, 0/* default */);
G_DeferedNewGame(startSkill, startEpisode, startMap, 0/* default */);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/jhexen/src/m_cheat.c
Expand Up @@ -605,7 +605,7 @@ int Cht_InitFunc(const int* args, int player)
if(plr->health <= 0)
return false; // Dead players can't cheat.

G_DeferedInitNew(gameSkill, gameEpisode, gameMap, gameMapEntryPoint);
G_DeferedNewGame(gameSkill, gameEpisode, gameMap, gameMapEntryPoint);
P_SetMessage(plr, TXT_CHEATWARP, false);
S_LocalSound(SFX_PLATFORM_STOP, NULL);
return true;
Expand Down

0 comments on commit 40b5f3f

Please sign in to comment.