Skip to content

Commit

Permalink
Refactor|libcommon: Continued 'game' -> 'session' standardization
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Feb 23, 2014
1 parent 67e1de5 commit 182bb56
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 63 deletions.
2 changes: 1 addition & 1 deletion doomsday/plugins/common/include/g_common.h
Expand Up @@ -81,7 +81,7 @@ dd_bool G_QuitInProgress(void);
* @param mapEntrance Logical map entry point number.
* @param rules Game rules to apply.
*/
void G_NewGame(Uri const *mapUri, uint mapEntrance, GameRuleset const *rules);
void G_NewSession(Uri const *mapUri, uint mapEntrance, GameRuleset const *rules);
void G_DeferredNewGame(Uri const *mapUri, uint mapEntrance, GameRuleset const *rules);

/**
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/common/src/d_net.c
Expand Up @@ -161,7 +161,7 @@ int D_NetServerStarted(int before)

netRules.skill = cfg.netSkill;

G_NewGame(netMapUri, 0/*default*/, &netRules);
G_NewSession(netMapUri, 0/*default*/, &netRules);

/// @todo Necessary?
G_SetGameAction(GA_NONE);
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/common/src/d_netcl.c
Expand Up @@ -139,7 +139,7 @@ void NetCl_UpdateGameState(Reader* msg)
// Do we need to change the map?
if(gsFlags & GSF_CHANGE_MAP)
{
G_NewGame(mapUri, gameMapEntrance /*gsMapEntrance*/, &gsRules);
G_NewSession(mapUri, gameMapEntrance /*gsMapEntrance*/, &gsRules);

/// @todo Necessary?
G_SetGameAction(GA_NONE);
Expand Down
89 changes: 45 additions & 44 deletions doomsday/plugins/common/src/g_game.cpp
Expand Up @@ -133,8 +133,8 @@ struct loadmap_params_t
};
int G_DoLoadMap(loadmap_params_t *parm);

void G_DoLoadGame(de::String slotId);
void G_DoSaveGame(de::String slotId, de::String userDescription);
void G_DoLoadSession(de::String slotId);
void G_DoSaveSession(de::String slotId, de::String userDescription);
void G_DoPlayDemo();
void G_DoMapCompleted();
void G_DoEndDebriefing();
Expand All @@ -160,7 +160,7 @@ void R_LoadVectorGraphics();

int Hook_DemoStop(int hookType, int val, void *parm);

static void G_InitNewGame();
static void G_InitNewSession();

game_config_t cfg; // The global cfg.

Expand Down Expand Up @@ -201,10 +201,10 @@ wbstartstruct_t wmInfo; // Params for world map / intermission.
#endif

// Game Action Variables:
static de::String gaSaveGameSlot;
static bool gaSaveGameGenerateDescription = true;
static de::String gaSaveGameUserDescription;
static de::String gaLoadGameSlot;
static de::String gaSaveSessionSlot;
static bool gaSaveSessionGenerateDescription = true;
static de::String gaSaveSessionUserDescription;
static de::String gaLoadSessionSlot;

#if __JDOOM__ || __JDOOM64__
mobj_t *bodyQueue[BODYQUEUESIZE];
Expand Down Expand Up @@ -1665,19 +1665,19 @@ static void runGameAction()

switch(currentAction)
{
case GA_NEWGAME:
G_InitNewGame();
G_NewGame(dMapUri, dMapEntrance, &dRules);
case GA_NEWSESSION:
G_InitNewSession();
G_NewSession(dMapUri, dMapEntrance, &dRules);
G_SetGameAction(GA_NONE);
break;

case GA_LOADGAME:
G_DoLoadGame(gaLoadGameSlot);
case GA_LOADSESSION:
G_DoLoadSession(gaLoadSessionSlot);
G_SetGameAction(GA_NONE);
break;

case GA_SAVEGAME:
G_DoSaveGame(gaSaveGameSlot, gaSaveGameUserDescription);
case GA_SAVESESSION:
G_DoSaveSession(gaSaveSessionSlot, gaSaveSessionUserDescription);
G_SetGameAction(GA_NONE);
break;

Expand Down Expand Up @@ -2165,17 +2165,17 @@ static int rebornLoadConfirmResponse(msgresponse_t response, int /*userValue*/,
DENG2_ASSERT(slotId != 0);
if(response == MSG_YES)
{
gaLoadGameSlot = *slotId;
G_SetGameAction(GA_LOADGAME);
gaLoadSessionSlot = *slotId;
G_SetGameAction(GA_LOADSESSION);
}
else
{
#if __JHEXEN__
// Load the last autosave? (Not optional in Hexen).
if(G_SaveSlots()["auto"].isUsed())
{
gaLoadGameSlot = "auto";
G_SetGameAction(GA_LOADGAME);
gaLoadSessionSlot = "auto";
G_SetGameAction(GA_LOADSESSION);
}
else
#endif
Expand Down Expand Up @@ -2246,8 +2246,8 @@ void G_DoReborn(int plrNum)
#endif
if(!cfg.confirmRebornLoad)
{
gaLoadGameSlot = chosenSlot;
G_SetGameAction(GA_LOADGAME);
gaLoadSessionSlot = chosenSlot;
G_SetGameAction(GA_LOADSESSION);
}
else
{
Expand All @@ -2264,8 +2264,8 @@ void G_DoReborn(int plrNum)
#if __JHEXEN__
if(G_SaveSlots()["auto"].isUsed())
{
gaLoadGameSlot = "auto";
G_SetGameAction(GA_LOADGAME);
gaLoadSessionSlot = "auto";
G_SetGameAction(GA_LOADSESSION);
return;
}
#endif
Expand All @@ -2275,7 +2275,7 @@ void G_DoReborn(int plrNum)
G_SetGameAction(GA_RESTARTMAP);
}

static void G_InitNewGame()
static void G_InitNewSession()
{
#if __JHEXEN__
G_SaveSlots().clearSlot("base");
Expand Down Expand Up @@ -2911,7 +2911,7 @@ static int saveGameStateWorker(void *context)
// Slot already in use; reuse the existing description.
userDescription = saveInfo.userDescription();
}
else if(gaSaveGameGenerateDescription)
else if(gaSaveSessionGenerateDescription)
{
userDescription = Str_Text(G_GenerateUserSaveDescription());
}
Expand Down Expand Up @@ -3128,8 +3128,8 @@ void G_DoRestartMap()
briefDisabled = true;

// Restart the game session entirely.
G_InitNewGame();
G_NewGame(dMapUri, dMapEntrance, &dRules);
G_InitNewSession();
G_NewSession(dMapUri, dMapEntrance, &dRules);
#else
loadmap_params_t p;

Expand Down Expand Up @@ -3169,9 +3169,9 @@ bool G_LoadSession(de::String slotId)
{
if(!G_SessionLoadingPossible()) return false;

// Check whether this slot is in use. We do this here also because we
// need to provide our caller with instant feedback. Naturally this is
// no guarantee that the game-save will be accessible come load time.
// Check whether this slot is in use. We do this here also because we need to provide our
// caller with instant feedback. Naturally this is no guarantee that the game-save will
// be accessible come load time.

// First ensure we have up-to-date info.
G_SaveSlots().updateAll();
Expand All @@ -3181,12 +3181,13 @@ bool G_LoadSession(de::String slotId)
if(G_SaveSlots()[slotId].isUsed())
{
// Everything appears to be in order - schedule the game-save load!
gaLoadGameSlot = slotId;
G_SetGameAction(GA_LOADGAME);
gaLoadSessionSlot = slotId;
G_SetGameAction(GA_LOADSESSION);
return true;
}

App_Log(DE2_RES_ERROR, "Cannot load from save slot '%s': not in use", slotId.toLatin1().constData());
App_Log(DE2_RES_ERROR, "Cannot load from save slot '%s': not in use",
slotId.toLatin1().constData());
}
catch(SaveSlots::InvalidSlotError const &)
{}
Expand All @@ -3208,7 +3209,7 @@ static std::auto_ptr<IGameStateReader> gameStateReaderFor(SaveInfo &info)
/**
* Called by G_Ticker based on gameaction.
*/
void G_DoLoadGame(de::String slotId)
void G_DoLoadSession(de::String slotId)
{
#if __JHEXEN__
bool mustCopyBaseToAutoSlot = (slotId.compareWithoutCase("auto") && !IS_NETGAME);
Expand Down Expand Up @@ -3279,22 +3280,22 @@ bool G_SaveSession(de::String slotId, de::String *userDescription)
if(!G_SessionSavingPossible()) return false;
if(!G_SaveSlots().isKnownSlot(slotId)) return false;

gaSaveGameSlot = slotId;
gaSaveSessionSlot = slotId;

if(userDescription && !userDescription->isEmpty())
{
// A new description.
gaSaveGameGenerateDescription = false;
gaSaveGameUserDescription = *userDescription;
gaSaveSessionGenerateDescription = false;
gaSaveSessionUserDescription = *userDescription;
}
else
{
// Reusing the current name or generating a new one.
gaSaveGameGenerateDescription = (userDescription && userDescription->isEmpty());
gaSaveGameUserDescription.clear();
gaSaveSessionGenerateDescription = (userDescription && userDescription->isEmpty());
gaSaveSessionUserDescription.clear();
}

G_SetGameAction(GA_SAVEGAME);
G_SetGameAction(GA_SAVESESSION);
return true;
}

Expand Down Expand Up @@ -3335,7 +3336,7 @@ AutoStr *G_GenerateUserSaveDescription()
/**
* Called by G_Ticker based on gameaction.
*/
void G_DoSaveGame(de::String slotId, de::String userDescription)
void G_DoSaveSession(de::String slotId, de::String userDescription)
{
savegamestateworker_params_t p;
p.userDescription = userDescription;
Expand Down Expand Up @@ -3365,7 +3366,7 @@ void G_DeferredNewGame(Uri const *mapUri, uint mapEntrance, GameRuleset const *r
dMapEntrance = mapEntrance;
dRules = rules? *rules : gameRules; // make a copy.

G_SetGameAction(GA_NEWGAME);
G_SetGameAction(GA_NEWSESSION);
}

/// @todo Get this from MAPINFO
Expand Down Expand Up @@ -3416,7 +3417,7 @@ static uint mapNumberFor(Uri const *mapUri)
return 0;
}

void G_NewGame(Uri const *mapUri, uint mapEntrance, GameRuleset const *rules)
void G_NewSession(Uri const *mapUri, uint mapEntrance, GameRuleset const *rules)
{
DENG_ASSERT(mapUri != 0 && rules != 0);

Expand Down Expand Up @@ -4187,7 +4188,7 @@ D_CMD(LoadSession)
// A known used slot identifier.
if(confirmed || !cfg.confirmQuickGameSave)
{
// Try to schedule a GA_LOADGAME action.
// Try to schedule a GA_LOADSESSION action.
S_LocalSound(SFX_MENU_ACCEPT, NULL);
return G_LoadSession(slotId);
}
Expand Down Expand Up @@ -4304,7 +4305,7 @@ D_CMD(SaveSession)

if(!slotIsUsed || confirmed || !cfg.confirmQuickGameSave)
{
// Try to schedule a GA_SAVEGAME action.
// Try to schedule a GA_SAVESESSION action.
S_LocalSound(SFX_MENU_ACCEPT, NULL);
return G_SaveSession(slotId, &userDescription);
}
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/common/src/gamestatereader.cpp
Expand Up @@ -346,7 +346,7 @@ void GameStateReader::read(SaveInfo &info)
* Load the map and configure some game settings.
*/
briefDisabled = true;
G_NewGame(d->saveInfo->mapUri(), 0/*not saved??*/, &d->saveInfo->gameRules());
G_NewSession(d->saveInfo->mapUri(), 0/*not saved??*/, &d->saveInfo->gameRules());
G_SetGameAction(GA_NONE); /// @todo Necessary?

#if !__JHEXEN__
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/common/src/p_saveg.cpp
Expand Up @@ -876,7 +876,7 @@ void SV_LoadGameClient(uint sessionId)
// Do we need to change the map?
if(!Uri_Equality(gameMapUri, info->mapUri()))
{
G_NewGame(info->mapUri(), 0/*default*/, &info->gameRules());
G_NewSession(info->mapUri(), 0/*default*/, &info->gameRules());
G_SetGameAction(GA_NONE); /// @todo Necessary?
}
else
Expand Down
6 changes: 3 additions & 3 deletions doomsday/plugins/doom/include/d_event.h
Expand Up @@ -39,9 +39,9 @@
typedef enum {
GA_NONE,
GA_RESTARTMAP,
GA_NEWGAME,
GA_LOADGAME,
GA_SAVEGAME,
GA_NEWSESSION,
GA_LOADSESSION,
GA_SAVESESSION,
GA_MAPCOMPLETED,
GA_ENDDEBRIEFING,
GA_VICTORY,
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/doom/src/doomv9gamestatereader.cpp
Expand Up @@ -977,7 +977,7 @@ void DoomV9GameStateReader::read(SaveInfo &info)
* Load the map and configure some game settings.
*/
briefDisabled = true;
G_NewGame(info.mapUri(), 0/*not saved??*/, &info.gameRules());
G_NewSession(info.mapUri(), 0/*not saved??*/, &info.gameRules());
G_SetGameAction(GA_NONE); /// @todo Necessary?

// Recreate map state.
Expand Down
6 changes: 3 additions & 3 deletions doomsday/plugins/doom64/include/doomdef.h
Expand Up @@ -105,9 +105,9 @@ typedef enum gamestate_e {
typedef enum {
GA_NONE,
GA_RESTARTMAP,
GA_NEWGAME,
GA_LOADGAME,
GA_SAVEGAME,
GA_NEWSESSION,
GA_LOADSESSION,
GA_SAVESESSION,
GA_MAPCOMPLETED,
GA_ENDDEBRIEFING,
GA_VICTORY,
Expand Down
6 changes: 3 additions & 3 deletions doomsday/plugins/heretic/include/h_event.h
Expand Up @@ -38,9 +38,9 @@
typedef enum {
GA_NONE,
GA_RESTARTMAP,
GA_NEWGAME,
GA_LOADGAME,
GA_SAVEGAME,
GA_NEWSESSION,
GA_LOADSESSION,
GA_SAVESESSION,
GA_MAPCOMPLETED,
GA_ENDDEBRIEFING,
GA_VICTORY,
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/heretic/src/hereticv13gamestatereader.cpp
Expand Up @@ -991,7 +991,7 @@ void HereticV13GameStateReader::read(SaveInfo &info)
briefDisabled = true;

// Load a base map.
G_NewGame(info.mapUri(), 0/*not saved??*/, &info.gameRules());
G_NewSession(info.mapUri(), 0/*not saved??*/, &info.gameRules());
G_SetGameAction(GA_NONE); /// @todo Necessary?

// Recreate map state.
Expand Down
6 changes: 3 additions & 3 deletions doomsday/plugins/hexen/include/x_event.h
Expand Up @@ -37,9 +37,9 @@
typedef enum {
GA_NONE,
GA_RESTARTMAP,
GA_NEWGAME,
GA_LOADGAME,
GA_SAVEGAME,
GA_NEWSESSION,
GA_LOADSESSION,
GA_SAVESESSION,
GA_MAPCOMPLETED,
GA_ENDDEBRIEFING,
GA_LEAVEMAP,
Expand Down

0 comments on commit 182bb56

Please sign in to comment.