Skip to content

Commit

Permalink
libcommon: Removed current episode ID from the map banner (log)
Browse files Browse the repository at this point in the history
On second thoughts, lets not include this info in the map banner so
as not to potentially confuse the user when manually warping.

Once a game session has begun, the episode is "locked in" at this
point. Any future map changes are interpreted as a continuation of
the current episode.

Consequently printing the current episode ID here is potentially
confusing, when switching to using map URIs.

For example, "warp 3 8" is interpreted as "Begin a new game on episode
3 and then warp to map-with-warp-number 8". Whereas "warp E3M8" is
interpreted as (simply) "warp to map-with-warp-number 8".

(Note that if both an episode ID and a map URI is specified, a new
game session will begin, as previously).
  • Loading branch information
danij-deng committed Feb 6, 2015
1 parent 09006e0 commit b2a4651
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 39 deletions.
11 changes: 11 additions & 0 deletions doomsday/plugins/common/include/g_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,17 @@ de::String G_MapTitle(de::Uri const &mapUri);
*/
de::Uri G_MapTitleImage(de::Uri const &mapUri);

/**
* Compose a textual, rich-formatted description of the the referenced map, containing
* pertinent information and/or metadata (such as the title and author).
*
* @param episodeId Unique episode identifier.
* @param mapUri Unique map identifier.
*
* @return Rich-formatted description of the map.
*/
de::String G_MapDescription(de::String episodeId, de::Uri const &mapUri);

/**
* Attempt to extract the logical map number encoded in the @a mapUri. Assumes the default
* form for the current game mode (i.e., MAPXX or EXMY).
Expand Down
81 changes: 42 additions & 39 deletions doomsday/plugins/common/src/g_game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1045,44 +1045,6 @@ void G_StartHelp()
LOG_SCR_WARNING("InFine script '%s' not defined") << scriptId;
}

/**
* Prints a banner to the console containing information pertinent to the referenced map
* (e.g., title, author...).
*/
static void printMapBanner(String episodeId, de::Uri const &mapUri)
{
LOG_MSG(DE2_ESC(R));

String const title = G_MapTitle(mapUri);
if(!title.isEmpty())
{
Record const *mgNodeDef = 0;
if(Record const *episode = Defs().episodes.tryFind("id", episodeId))
{
mgNodeDef = defn::Episode(*episode).tryFindMapGraphNode(mapUri.compose());
}

LOG_NOTE("Map: " DE2_ESC(i) DE2_ESC(b) "%s" DE2_ESC(.) " (%s%s)")
<< title << mapUri
<< (mgNodeDef? String(", warp: %1").arg(mgNodeDef->geti("warpNumber")) : "");
}

String const author = G_MapAuthor(mapUri, P_MapIsCustom(mapUri.compose().toUtf8().constData()));
if(!author.isEmpty())
{
LOG_NOTE("Author: " DE2_ESC(i)) << author;
}

String const episodeTitle = G_EpisodeTitle(episodeId);
if(!episodeTitle.isEmpty())
{
LOG_NOTE("Episode: " DE2_ESC(i) "%s (id: %s)")
<< episodeTitle << episodeId;
}

LOG_MSG(DE2_ESC(R));
}

void G_BeginMap()
{
G_ChangeGameState(GS_MAP);
Expand All @@ -1102,7 +1064,11 @@ void G_BeginMap()
// The music may have been paused for the briefing; unpause.
S_PauseMusic(false);

printMapBanner(COMMON_GAMESESSION->episodeId(), COMMON_GAMESESSION->mapUri());
// Print a map banner to the log.
LOG_MSG(DE2_ESC(R));
LOG_NOTE("%s") << G_MapDescription(COMMON_GAMESESSION->episodeId(),
COMMON_GAMESESSION->mapUri());
LOG_MSG(DE2_ESC(R));
}

int G_Responder(event_t *ev)
Expand Down Expand Up @@ -2157,6 +2123,43 @@ de::Uri G_MapTitleImage(de::Uri const &mapUri)
return de::Uri();
}

String G_MapDescription(String episodeId, de::Uri const &mapUri)
{
QByteArray mapUriUtf8 = mapUri.compose().toUtf8().constData();
if(!P_MapExists(mapUriUtf8.constData()))
{
return String("Unknown map (Episode: ") + episodeId + ", Uri: " + mapUri + ")";
}

String desc;
QTextStream os(&desc);

String const title = G_MapTitle(mapUri);
if(!title.isEmpty())
{
os << "Map: " DE2_ESC(i) DE2_ESC(b) << title << DE2_ESC(.)
<< " (Uri: " << mapUri;

if(Record const *rec = Defs().episodes.tryFind("id", episodeId))
{
if(Record const *mgNodeDef = defn::Episode(*rec).tryFindMapGraphNode(mapUri.compose()))
{
os << ", warp: " << String::number(mgNodeDef->geti("warpNumber"));
}
}

os << ")" << DE2_ESC(.);
}

String const author = G_MapAuthor(mapUri, P_MapIsCustom(mapUriUtf8.constData()));
if(!author.isEmpty())
{
os << "\nAuthor: " DE2_ESC(i) << author;
}

return desc;
}

/**
* Stops both playback and a recording. Called at critical points like
* starting a new game, or ending the game in the menu.
Expand Down

0 comments on commit b2a4651

Please sign in to comment.