diff --git a/doomsday/plugins/common/include/g_common.h b/doomsday/plugins/common/include/g_common.h index bf5f6798d2..50bdf522c4 100644 --- a/doomsday/plugins/common/include/g_common.h +++ b/doomsday/plugins/common/include/g_common.h @@ -105,29 +105,24 @@ bool G_SetGameActionLoadSession(de::String slotId); void G_SetGameActionMapCompleted(de::Uri const &nextMapUri, uint nextMapEntryPoint, dd_bool secretExit); /** - * @param episodeId Identifier of the episode to lookup the title of. Can be @c 0 in - * which case the title for the @em current episode will be returned - * (if set). + * @param episodeId Identifier of the episode to lookup the title of. */ -de::String G_EpisodeTitle(de::String const *episodeId = 0); +de::String G_EpisodeTitle(de::String episodeId); /** - * @param mapUri Identifier of the map to lookup the author of. Can be @c 0 in which - * case the author for the @em current map will be returned (if set). + * @param mapUri Identifier of the map to lookup the author of. */ -de::String G_MapAuthor(de::Uri const *mapUri = 0, bool supressGameAuthor = false); +de::String G_MapAuthor(de::Uri const &mapUri, bool supressGameAuthor = false); /** - * @param mapUri Identifier of the map to lookup the title of. Can be @c 0 in which - * case the title for the @em current map will be returned (if set). + * @param mapUri Identifier of the map to lookup the title of. */ -de::String G_MapTitle(de::Uri const *mapUri = 0); +de::String G_MapTitle(de::Uri const &mapUri); /** - * @param mapUri Identifier of the map to lookup the title of. Can be @c 0 in which - * case the title for the @em current map will be returned (if set). + * @param mapUri Identifier of the map to lookup the title of. */ -patchid_t G_MapTitlePatch(de::Uri const *mapUri = 0); +patchid_t G_MapTitlePatch(de::Uri const &mapUri); extern "C" { #endif @@ -201,7 +196,7 @@ de::Uri G_ComposeMapUri(uint episode, uint map); extern "C" { #endif -struct uri_s const *G_CurrentMapUri(void); +AutoStr *G_CurrentMapUriPath(void); int G_Ruleset_Skill(); #if !__JHEXEN__ diff --git a/doomsday/plugins/common/src/d_netcl.cpp b/doomsday/plugins/common/src/d_netcl.cpp index a1062d1633..6ca4fdd929 100644 --- a/doomsday/plugins/common/src/d_netcl.cpp +++ b/doomsday/plugins/common/src/d_netcl.cpp @@ -122,7 +122,7 @@ void NetCl_UpdateGameState(reader_s *msg) /// @todo Breaks session management logic; rules cannot change once the session has /// begun and setting the current map and/or entrance is illogical at this point. DENG2_ASSERT(!Str_Compare(gsEpisodeId, COMMON_GAMESESSION->episodeId().toLatin1().constData())); - DENG2_ASSERT(*reinterpret_cast(gsMapUri) == ::gameMapUri); + DENG2_ASSERT(*reinterpret_cast(gsMapUri) == COMMON_GAMESESSION->mapUri()); COMMON_GAMESESSION->applyNewRules(gsRules); //COMMON_GAMESESSION->setMap(*gsMapUri); diff --git a/doomsday/plugins/common/src/d_netsv.cpp b/doomsday/plugins/common/src/d_netsv.cpp index 02494501d1..18ef203412 100644 --- a/doomsday/plugins/common/src/d_netsv.cpp +++ b/doomsday/plugins/common/src/d_netsv.cpp @@ -662,12 +662,13 @@ void NetSv_SendGameState(int flags, int to) AutoStr *gameId = AutoStr_FromTextStd(COMMON_GAMESESSION->gameId().toLatin1().constData()); AutoStr *episodeId = AutoStr_FromTextStd(COMMON_GAMESESSION->episodeId().toLatin1().constData()); + de::Uri mapUri = COMMON_GAMESESSION->mapUri(); // Print a short message that describes the game state. LOG_NET_NOTE("Sending game setup: %s %s %s %s") << gameId << episodeId - << ::gameMapUri.resolved() + << mapUri.resolved() << gameConfigString; // Send an update to all the players in the game. @@ -683,7 +684,7 @@ void NetSv_SendGameState(int flags, int to) Str_Write(gameId, writer); // Current map. - Uri_Write(reinterpret_cast(&::gameMapUri), writer); + Uri_Write(reinterpret_cast(&mapUri), writer); // Current episode. Str_Write(episodeId, writer); diff --git a/doomsday/plugins/common/src/fi_lib.cpp b/doomsday/plugins/common/src/fi_lib.cpp index 3c772749e3..1748463780 100644 --- a/doomsday/plugins/common/src/fi_lib.cpp +++ b/doomsday/plugins/common/src/fi_lib.cpp @@ -92,7 +92,7 @@ static void initStateConditions(fi_state_t *s) if(Record const *episodeDef = COMMON_GAMESESSION->episodeDef()) { defn::Episode epsd(*episodeDef); - Record const *currentHub = epsd.tryFindHubByMapId(::gameMapUri.compose()); + Record const *currentHub = epsd.tryFindHubByMapId(COMMON_GAMESESSION->mapUri().compose()); s->conditions.leave_hub = (currentHub != epsd.tryFindHubByMapId(::nextMapUri.compose())); } App_Log(DE2_DEV_SCR_VERBOSE, "Infine state condition: leave_hub=%i", s->conditions.leave_hub); diff --git a/doomsday/plugins/common/src/g_game.cpp b/doomsday/plugins/common/src/g_game.cpp index b600bf5aa9..21c9315f5c 100644 --- a/doomsday/plugins/common/src/g_game.cpp +++ b/doomsday/plugins/common/src/g_game.cpp @@ -514,12 +514,12 @@ static void initSaveSlots() */ void G_CommonPreInit() { - // Apply the default game rules. - COMMON_GAMESESSION->applyNewRules(defaultGameRules = GameRuleset()); - - gameMapUri.clear(); quitInProgress = false; verbose = CommandLine_Exists("-verbose"); + ::gameMapUri.clear(); + + // Apply the default game rules. + COMMON_GAMESESSION->applyNewRules(defaultGameRules = GameRuleset()); // Register hooks. Plug_AddHook(HOOK_DEMO_STOP, Hook_DemoStop); @@ -1290,32 +1290,37 @@ void G_StartHelp() } /** - * Prints a banner to the console containing information pertinent to the current map - * (e.g., map title, author...). + * Prints a banner to the console containing information pertinent to the referenced map + * (e.g., title, author...). */ -static void printMapBanner() +static void printMapBanner(String episodeId, de::Uri const &mapUri) { App_Log(DE2_LOG_MESSAGE, DE2_ESC(R)); - String const title = G_MapTitle(); // current map + String const title = G_MapTitle(mapUri); if(!title.isEmpty()) { - Record const *mgNodeDef = COMMON_GAMESESSION->mapGraphNodeDef(); + Record const *mgNodeDef = 0; + if(Record const *episode = Defs().episodes.tryFind("id", episodeId)) + { + mgNodeDef = defn::Episode(*episode).tryFindMapGraphNode(mapUri.compose()); + } + String text = String("Map: " DE2_ESC(i) DE2_ESC(b) "%1" DE2_ESC(.) " (%2%3)") .arg(title) - .arg(gameMapUri.asText()) + .arg(mapUri.asText()) .arg(mgNodeDef? String(", warp: %1").arg(mgNodeDef->geti("warpNumber")) : ""); App_Log(DE2_LOG_NOTE, "%s", text.toUtf8().constData()); } - String const author = G_MapAuthor(0/*current map*/, P_MapIsCustom(gameMapUri.compose().toUtf8().constData())); + String const author = G_MapAuthor(mapUri, P_MapIsCustom(mapUri.compose().toUtf8().constData())); if(!author.isEmpty()) { String text = String("Author: " DE2_ESC(i)) + author; App_Log(DE2_LOG_NOTE, "%s", text.toUtf8().constData()); } - String const episodeTitle = G_EpisodeTitle(); + String const episodeTitle = G_EpisodeTitle(episodeId); if(!episodeTitle.isEmpty()) { String text = String("Episode: " DE2_ESC(i)) + episodeTitle; @@ -1337,19 +1342,22 @@ void G_BeginMap() G_ControlReset(-1); // Clear all controls for all local players. - // Update the game status cvars for the current map. - String mapAuthor = G_MapAuthor(); // current map + // Update the game status cvars for the current map: + String const episodeId = COMMON_GAMESESSION->episodeId(); + de::Uri const mapUri = COMMON_GAMESESSION->mapUri(); + + String mapAuthor = G_MapAuthor(mapUri); if(mapAuthor.isEmpty()) mapAuthor = "Unknown"; Con_SetString2("map-author", mapAuthor.toUtf8().constData(), SVF_WRITE_OVERRIDE); - String mapTitle = G_MapTitle(); // current map + String mapTitle = G_MapTitle(mapUri); if(mapTitle.isEmpty()) mapTitle = "Unknown"; Con_SetString2("map-name", mapTitle.toUtf8().constData(), SVF_WRITE_OVERRIDE); // Time can now progress in this map. mapTime = actualMapTime = 0; - printMapBanner(); + printMapBanner(episodeId, mapUri); // The music may have been paused for the briefing; unpause. S_PauseMusic(false); @@ -1654,15 +1662,18 @@ static void runGameAction() { #if __JDOOM__ // Has the secret map been completed? - if((gameModeBits & (GM_DOOM|GM_DOOM_SHAREWARE|GM_DOOM_ULTIMATE)) && - (::gameMapUri.path() == "E1M9" || - ::gameMapUri.path() == "E2M9" || - ::gameMapUri.path() == "E3M9" || - ::gameMapUri.path() == "E4M9")) + if(gameModeBits & (GM_DOOM | GM_DOOM_SHAREWARE | GM_DOOM_ULTIMATE)) { - for(int i = 0; i < MAXPLAYERS; ++i) + de::Uri const mapUri = COMMON_GAMESESSION->mapUri(); + if(mapUri.path() == "E1M9" || + mapUri.path() == "E2M9" || + mapUri.path() == "E3M9" || + mapUri.path() == "E4M9") { - players[i].didSecret = true; + for(int i = 0; i < MAXPLAYERS; ++i) + { + players[i].didSecret = true; + } } } #endif @@ -1915,7 +1926,7 @@ void G_PlayerLeaveMap(int player) if(Record const *episodeDef = COMMON_GAMESESSION->episodeDef()) { defn::Episode epsd(*episodeDef); - Record const *currentHub = epsd.tryFindHubByMapId(::gameMapUri.compose()); + Record const *currentHub = epsd.tryFindHubByMapId(COMMON_GAMESESSION->mapUri().compose()); newHub = (currentHub != epsd.tryFindHubByMapId(::nextMapUri.compose())); } #endif @@ -2143,12 +2154,13 @@ void G_PlayerReborn(int player) p->weapons[WT_SECOND].owned = true; p->ammo[AT_CRYSTAL].owned = 50; + de::Uri const mapUri = COMMON_GAMESESSION->mapUri(); if(secret || - (::gameMapUri.path() == "E1M9" || - ::gameMapUri.path() == "E2M9" || - ::gameMapUri.path() == "E3M9" || - ::gameMapUri.path() == "E4M9" || - ::gameMapUri.path() == "E5M9")) + (mapUri.path() == "E1M9" || + mapUri.path() == "E2M9" || + mapUri.path() == "E3M9" || + mapUri.path() == "E4M9" || + mapUri.path() == "E5M9")) { p->didSecret = true; } @@ -2248,37 +2260,39 @@ byte G_Ruleset_RespawnMonsters() */ dd_bool G_IfVictory() { + de::Uri const mapUri = COMMON_GAMESESSION->mapUri(); #if __JDOOM64__ - if(::gameMapUri.path() == "MAP28") + if(mapUri.path() == "MAP28") { return true; } #elif __JDOOM__ if(gameMode == doom_chex) { - if(::gameMapUri.path() == "MAP05") + if(mapUri.path() == "MAP05") { return true; } } else if((gameModeBits & GM_ANY_DOOM) && - (::gameMapUri.path() == "E1M8" || - ::gameMapUri.path() == "E2M8" || - ::gameMapUri.path() == "E3M8" || - ::gameMapUri.path() == "E4M8")) + (mapUri.path() == "E1M8" || + mapUri.path() == "E2M8" || + mapUri.path() == "E3M8" || + mapUri.path() == "E4M8")) { return true; } #elif __JHERETIC__ - if(::gameMapUri.path() == "E1M8" || - ::gameMapUri.path() == "E2M8" || - ::gameMapUri.path() == "E3M8" || - ::gameMapUri.path() == "E4M8" || - ::gameMapUri.path() == "E5M8") + if(mapUri.path() == "E1M8" || + mapUri.path() == "E2M8" || + mapUri.path() == "E3M8" || + mapUri.path() == "E4M8" || + mapUri.path() == "E5M8") { return true; } #elif __JHEXEN__ + DENG2_UNUSED(mapUri); if(nextMapUri.path().isEmpty()) { return true; @@ -2290,7 +2304,7 @@ dd_bool G_IfVictory() static int prepareIntermission(void * /*context*/) { #if __JDOOM__ || __JDOOM64__ || __JHERETIC__ - wmInfo.currentMap = gameMapUri; + wmInfo.currentMap = COMMON_GAMESESSION->mapUri(); wmInfo.nextMap = nextMapUri; wmInfo.didSecret = players[CONSOLEPLAYER].didSecret; @@ -2403,7 +2417,7 @@ static Record const *finaleDebriefing() if(cfg.overrideHubMsg && G_GameState() == GS_MAP) { defn::Episode epsd(*COMMON_GAMESESSION->episodeDef()); - Record const *currentHub = epsd.tryFindHubByMapId(::gameMapUri.compose()); + Record const *currentHub = epsd.tryFindHubByMapId(COMMON_GAMESESSION->mapUri().compose()); if(currentHub != epsd.tryFindHubByMapId(::nextMapUri.compose())) { return 0; @@ -2418,7 +2432,7 @@ static Record const *finaleDebriefing() if(G_GameState() == GS_INFINE) return 0; // Is there such a finale definition? - return Defs().finales.tryFind("after", ::gameMapUri.compose()); + return Defs().finales.tryFind("after", COMMON_GAMESESSION->mapUri().compose()); } /// @todo common::GameSession should handle this -ds @@ -2458,35 +2472,36 @@ void G_IntermissionDone() G_SetGameAction(GA_LEAVEMAP); } -de::String G_DefaultSavedSessionUserDescription(de::String const &saveName, bool autogenerate) +String G_DefaultSavedSessionUserDescription(String const &saveName, bool autogenerate) { // If the slot is already in use then choose existing description. if(!saveName.isEmpty()) { - de::String const existing = COMMON_GAMESESSION->savedUserDescription(saveName); + String const existing = COMMON_GAMESESSION->savedUserDescription(saveName); if(!existing.isEmpty()) return existing; } if(!autogenerate) return ""; // Autogenerate a suitable description. - de::String description; + String description; // Include the source file name, for custom maps. - de::String mapUriAsText = gameMapUri.compose(); + de::Uri const mapUri = COMMON_GAMESESSION->mapUri(); + String mapUriAsText = mapUri.compose(); if(P_MapIsCustom(mapUriAsText.toUtf8().constData())) { - de::String const mapSourcePath(Str_Text(P_MapSourceFile(mapUriAsText.toUtf8().constData()))); + String const mapSourcePath(Str_Text(P_MapSourceFile(mapUriAsText.toUtf8().constData()))); description += mapSourcePath.fileNameWithoutExtension() + ":"; } // Include the map title. - de::String mapTitle = G_MapTitle(); // current map + String mapTitle = G_MapTitle(mapUri); // No map title? Use the identifier. (Some tricksy modders provide us with an empty title). /// @todo Move this logic engine-side. if(mapTitle.isEmpty() || mapTitle.at(0) == ' ') { - mapTitle = gameMapUri.path(); + mapTitle = mapUri.path(); } description += mapTitle; @@ -2495,10 +2510,10 @@ de::String G_DefaultSavedSessionUserDescription(de::String const &saveName, bool int const hours = time / 3600; time -= hours * 3600; int const minutes = time / 60; time -= minutes * 60; int const seconds = time; - description += de::String(" %1:%2:%3") - .arg(hours, 2, 10, QChar('0')) - .arg(minutes, 2, 10, QChar('0')) - .arg(seconds, 2, 10, QChar('0')); + description += String(" %1:%2:%3") + .arg(hours, 2, 10, QChar('0')) + .arg(minutes, 2, 10, QChar('0')) + .arg(seconds, 2, 10, QChar('0')); return description; } @@ -2528,9 +2543,9 @@ uint G_MapNumberFor(de::Uri const &mapUri) return 0; } -uri_s const *G_CurrentMapUri() +AutoStr *G_CurrentMapUriPath() { - return reinterpret_cast(&::gameMapUri); + return AutoStr_FromTextStd(COMMON_GAMESESSION->mapUri().path().toStringRef().toUtf8().constData()); } de::Uri G_ComposeMapUri(uint episode, uint map) @@ -2553,21 +2568,10 @@ de::Uri G_ComposeMapUri(uint episode, uint map) return de::Uri("Maps", mapId); } -String G_EpisodeTitle(String const *episodeId) +String G_EpisodeTitle(String episodeId) { - Record const *episodeDef = 0; - if(!episodeId) - { - // The current episode. - episodeDef = COMMON_GAMESESSION->episodeDef(); - } - else - { - episodeDef = Defs().episodes.tryFind("id", *episodeId); - } - String title; - if(episodeDef) + if(Record const *episodeDef = Defs().episodes.tryFind("id", episodeId)) { title = episodeDef->gets("title"); // Perhaps the title string is a reference to a Text definition? @@ -2580,14 +2584,12 @@ String G_EpisodeTitle(String const *episodeId) return title; } -String G_MapTitle(de::Uri const *mapUri) +String G_MapTitle(de::Uri const &mapUri) { - if(!mapUri) mapUri = &::gameMapUri; - String title; // Perhaps a MapInfo definition exists for the map? - if(Record const *mapInfo = Defs().mapInfos.tryFind("id", mapUri->compose())) + if(Record const *mapInfo = Defs().mapInfos.tryFind("id", mapUri.compose())) { title = mapInfo->gets("title"); // Perhaps the title string is a reference to a Text definition? @@ -2611,14 +2613,12 @@ String G_MapTitle(de::Uri const *mapUri) return title; } -String G_MapAuthor(de::Uri const *mapUri, bool supressGameAuthor) +String G_MapAuthor(de::Uri const &mapUri, bool supressGameAuthor) { - if(!mapUri) mapUri = &gameMapUri; - String author; // Perhaps a MapInfo definition exists for the map? - String mapUriAsText = mapUri->compose(); + String mapUriAsText = mapUri.compose(); if(Record const *mapInfo = Defs().mapInfos.tryFind("id", mapUriAsText)) { author = mapInfo->gets("author"); @@ -2658,16 +2658,14 @@ static uint episodeNumberFor(de::Uri const &mapUri) } #endif // __JDOOM__ -patchid_t G_MapTitlePatch(de::Uri const *mapUri) +patchid_t G_MapTitlePatch(de::Uri const &mapUri) { - if(!mapUri) mapUri = &gameMapUri; - #if __JDOOM__ || __JDOOM64__ - uint map = G_MapNumberFor(*mapUri); + uint map = G_MapNumberFor(mapUri); # if __JDOOM__ if(!(gameModeBits & (GM_ANY_DOOM2|GM_DOOM_CHEX))) { - uint episode = episodeNumberFor(*mapUri); + uint episode = episodeNumberFor(mapUri); map = (episode * 9) + map; } # endif @@ -2678,7 +2676,6 @@ patchid_t G_MapTitlePatch(de::Uri const *mapUri) #else DENG2_UNUSED(mapUri); #endif - return 0; } @@ -3258,7 +3255,7 @@ D_CMD(WarpMap) #if __JHEXEN__ // Hexen does not allow warping to the current map. - if(!forceNewSession && COMMON_GAMESESSION->hasBegun() && ::gameMapUri == mapUri) + if(!forceNewSession && COMMON_GAMESESSION->mapUri() == mapUri) { P_SetMessage(players + CONSOLEPLAYER, LMF_NO_HIDE, "Cannot warp to the current map."); return false; diff --git a/doomsday/plugins/common/src/gamesession.cpp b/doomsday/plugins/common/src/gamesession.cpp index 304fc0f0c8..4a5abe85d1 100644 --- a/doomsday/plugins/common/src/gamesession.cpp +++ b/doomsday/plugins/common/src/gamesession.cpp @@ -208,7 +208,7 @@ DENG2_PIMPL(GameSession), public SavedSession::IMapStateReaderFactory Folder &mapsFolder = App::fileSystem().makeFolder(saved->path() / "maps"); DENG2_ASSERT(mapsFolder.mode().testFlag(File::Write)); - mapsFolder.replaceFile(gameMapUri.path() + "State") + mapsFolder.replaceFile(::gameMapUri.path() + "State") << serializeCurrentMapState(); saved->flush(); // No need to populate; FS2 Files already in sync with source data. @@ -559,11 +559,11 @@ DENG2_PIMPL(GameSession), public SavedSession::IMapStateReaderFactory //S_StartMusic("chess", true); // Waiting-for-map-load song #endif - S_MapMusic(&gameMapUri); + S_MapMusic(&::gameMapUri); S_PauseMusic(true); } - P_SetupMap(gameMapUri); + P_SetupMap(::gameMapUri); if(revisit) { @@ -1122,7 +1122,7 @@ void GameSession::leaveMap() #if __JHEXEN__ else { - File &outFile = mapsFolder.replaceFile(gameMapUri.path() + "State"); + File &outFile = mapsFolder.replaceFile(::gameMapUri.path() + "State"); outFile << serializeCurrentMapState(true /*exclude players*/); // We'll flush whole package soon. } @@ -1158,7 +1158,7 @@ void GameSession::leaveMap() ::gameMapEntrance = ::nextMapEntrance; // Are we revisiting a previous map? - bool const revisit = saved && saved->hasState(String("maps") / gameMapUri.path()); + bool const revisit = saved && saved->hasState(String("maps") / ::gameMapUri.path()); d->reloadMap(revisit); @@ -1183,7 +1183,7 @@ void GameSession::leaveMap() d->rules.randomClasses = oldRandomClassesRule; // Launch waiting scripts. - Game_ACScriptInterpreter().runDeferredTasks(gameMapUri); + Game_ACScriptInterpreter().runDeferredTasks(::gameMapUri); #endif if(saved) @@ -1206,7 +1206,7 @@ void GameSession::leaveMap() Folder &mapsFolder = saved->locate("maps"); DENG2_ASSERT(mapsFolder.mode().testFlag(File::Write)); - File &outFile = mapsFolder.replaceFile(gameMapUri.path() + "State"); + File &outFile = mapsFolder.replaceFile(::gameMapUri.path() + "State"); outFile << serializeCurrentMapState(); // Write all changes to the package. diff --git a/doomsday/plugins/common/src/hu_stuff.cpp b/doomsday/plugins/common/src/hu_stuff.cpp index 7ad1e9357d..94c779efae 100644 --- a/doomsday/plugins/common/src/hu_stuff.cpp +++ b/doomsday/plugins/common/src/hu_stuff.cpp @@ -756,7 +756,7 @@ static void drawMapMetaData(float x, float y, float alpha) { #define BORDER 2 - de::String title = G_MapTitle(); // current map + de::String title = G_MapTitle(COMMON_GAMESESSION->mapUri()); if(title.isEmpty()) title = "Unnamed"; char buf[256]; @@ -1441,7 +1441,7 @@ int Hu_MapTitleFirstLineHeight() { int y = 0; patchinfo_t patchInfo; - if(R_GetPatchInfo(G_MapTitlePatch()/*current map*/, &patchInfo)) + if(R_GetPatchInfo(G_MapTitlePatch(COMMON_GAMESESSION->mapUri()), &patchInfo)) { y = patchInfo.geometry.size.height + 2; } @@ -1451,7 +1451,7 @@ int Hu_MapTitleFirstLineHeight() dd_bool Hu_IsMapTitleAuthorVisible() { - de::String const author = G_MapAuthor(0/*current map*/, CPP_BOOL(cfg.hideIWADAuthor)); + de::String const author = G_MapAuthor(COMMON_GAMESESSION->mapUri(), CPP_BOOL(cfg.hideIWADAuthor)); return !author.isEmpty() && (actualMapTime <= 6 * TICSPERSEC); } @@ -1470,8 +1470,9 @@ int Hu_MapTitleHeight(void) void Hu_DrawMapTitle(float alpha, dd_bool mapIdInsteadOfAuthor) { - de::String const title = G_MapTitle(); // current map - de::String const author = G_MapAuthor(0/*current map*/, CPP_BOOL(cfg.hideIWADAuthor)); + de::Uri const mapUri = COMMON_GAMESESSION->mapUri(); + de::String const title = G_MapTitle(mapUri); + de::String const author = G_MapAuthor(mapUri, CPP_BOOL(cfg.hideIWADAuthor)); float y = 0; @@ -1483,7 +1484,7 @@ void Hu_DrawMapTitle(float alpha, dd_bool mapIdInsteadOfAuthor) FR_SetColorAndAlpha(defFontRGB[0], defFontRGB[1], defFontRGB[2], alpha); #if __JDOOM__ || __JDOOM64__ - patchid_t patchId = G_MapTitlePatch(); // current map + patchid_t patchId = G_MapTitlePatch(mapUri); WI_DrawPatch(patchId, Hu_ChoosePatchReplacement(PRM_ALLOW_TEXT, patchId, title.toUtf8().constData()), de::Vector2i(), ALIGN_TOP, 0, DTF_ONLY_SHADOW); @@ -1506,7 +1507,7 @@ void Hu_DrawMapTitle(float alpha, dd_bool mapIdInsteadOfAuthor) #else FR_SetColorAndAlpha(.6f, .6f, .6f, alpha); #endif - FR_DrawTextXY3(gameMapUri.path().toUtf8().constData(), 0, y, ALIGN_TOP, DTF_ONLY_SHADOW); + FR_DrawTextXY3(mapUri.path().toUtf8().constData(), 0, y, ALIGN_TOP, DTF_ONLY_SHADOW); } else if(!author.isEmpty()) { diff --git a/doomsday/plugins/common/src/p_map.cpp b/doomsday/plugins/common/src/p_map.cpp index b235eb99d9..d26cc18add 100644 --- a/doomsday/plugins/common/src/p_map.cpp +++ b/doomsday/plugins/common/src/p_map.cpp @@ -168,7 +168,7 @@ static int PIT_StompThing(mobj_t *mo, void *context) if(!Mobj_IsPlayer(parm.stompMobj)) return true; #elif __JDOOM__ // Monsters only stomp on a boss map. - if(!Mobj_IsPlayer(parm.stompMobj) && ::gameMapUri.path() != "MAP30") + if(!Mobj_IsPlayer(parm.stompMobj) && COMMON_GAMESESSION->mapUri().path() != "MAP30") return true; #endif } diff --git a/doomsday/plugins/common/src/p_saveg.cpp b/doomsday/plugins/common/src/p_saveg.cpp index fb38b33d42..07ff0c22a1 100644 --- a/doomsday/plugins/common/src/p_saveg.cpp +++ b/doomsday/plugins/common/src/p_saveg.cpp @@ -878,7 +878,7 @@ void SV_LoadGameClient(uint /*sessionId*/) } // Do we need to change the map? - if(gameMapUri != *reinterpret_cast(mapUri)) + if(COMMON_GAMESESSION->mapUri() != *reinterpret_cast(mapUri)) { COMMON_GAMESESSION->begin(*mapUri, 0/*default*/, *rules); } diff --git a/doomsday/plugins/doom/src/m_cheat.cpp b/doomsday/plugins/doom/src/m_cheat.cpp index 0bacc8106c..e23a3b1911 100644 --- a/doomsday/plugins/doom/src/m_cheat.cpp +++ b/doomsday/plugins/doom/src/m_cheat.cpp @@ -700,7 +700,7 @@ D_CMD(CheatWhere) if(!plrMo) return true; sprintf(textBuffer, "MAP [%s] X:%g Y:%g Z:%g", - gameMapUri.path().toUtf8().constData(), + COMMON_GAMESESSION->mapUri().path().toUtf8().constData(), plrMo->origin[VX], plrMo->origin[VY], plrMo->origin[VZ]); P_SetMessage(plr, LMF_NO_HIDE, textBuffer); diff --git a/doomsday/plugins/doom/src/p_enemy.c b/doomsday/plugins/doom/src/p_enemy.c index a34a5da2fb..c45c2ea0c9 100644 --- a/doomsday/plugins/doom/src/p_enemy.c +++ b/doomsday/plugins/doom/src/p_enemy.c @@ -1584,7 +1584,7 @@ void C_DECL A_BossDeath(mobj_t *mo) }; static int const numBossTriggers = sizeof(bossTriggers) / sizeof(bossTriggers[0]); - Str const *currentMapPath = Uri_Path(G_CurrentMapUri()); + AutoStr *currentMapPath = G_CurrentMapUriPath(); // Make sure there is a player alive. int i; @@ -1659,7 +1659,7 @@ void C_DECL A_Hoof(mobj_t *mo) * @todo Kludge: Only play very loud sounds in map 8. * \todo: Implement a MAPINFO option for this. */ - Str const *currentMapPath = Uri_Path(G_CurrentMapUri()); + AutoStr *currentMapPath = G_CurrentMapUriPath(); S_StartSound(SFX_HOOF | (!(gameModeBits & GM_ANY_DOOM2) && (!Str_CompareIgnoreCase(currentMapPath, "E1M8") || @@ -1675,7 +1675,7 @@ void C_DECL A_Metal(mobj_t *mo) * @todo Kludge: Only play very loud sounds in map 8. * \todo: Implement a MAPINFO option for this. */ - Str const *currentMapPath = Uri_Path(G_CurrentMapUri()); + AutoStr *currentMapPath = G_CurrentMapUriPath(); S_StartSound(SFX_METAL | (!(gameModeBits & GM_ANY_DOOM2) && (!Str_CompareIgnoreCase(currentMapPath, "E1M8") || diff --git a/doomsday/plugins/doom/src/wi_stuff.cpp b/doomsday/plugins/doom/src/wi_stuff.cpp index a2dc645586..12291e2454 100644 --- a/doomsday/plugins/doom/src/wi_stuff.cpp +++ b/doomsday/plugins/doom/src/wi_stuff.cpp @@ -272,8 +272,8 @@ static void drawFinishedTitle(Vector2i origin = Vector2i(SCREENWIDTH / 2, WI_TIT FR_SetColorAndAlpha(defFontRGB[CR], defFontRGB[CG], defFontRGB[CB], 1); // Draw - patchid_t const patchId = G_MapTitlePatch(&wbs->currentMap); - de::String const mapTitle = G_MapTitle(&wbs->currentMap); + patchid_t const patchId = G_MapTitlePatch(wbs->currentMap); + de::String const mapTitle = G_MapTitle(wbs->currentMap); WI_DrawPatch(patchId, patchReplacementText(patchId, mapTitle.toUtf8().constData()), origin, ALIGN_TOP, 0, DTF_NO_TYPEIN); patchinfo_t info; if(R_GetPatchInfo(patchId, &info)) @@ -297,7 +297,7 @@ static void drawEnteringTitle(Vector2i origin = Vector2i(SCREENWIDTH / 2, WI_TIT /// kludge end. // See if there is a map name... - String mapTitle = G_MapTitle(&wbs->nextMap); + String mapTitle = G_MapTitle(wbs->nextMap); DGL_Enable(DGL_TEXTURE_2D); DGL_Color4f(1, 1, 1, 1); @@ -310,7 +310,7 @@ static void drawEnteringTitle(Vector2i origin = Vector2i(SCREENWIDTH / 2, WI_TIT WI_DrawPatch(pEntering, patchReplacementText(pEntering), origin, ALIGN_TOP, 0, DTF_NO_TYPEIN); patchinfo_t info; - patchid_t const mapTitlePatch = G_MapTitlePatch(&wbs->nextMap); + patchid_t const mapTitlePatch = G_MapTitlePatch(wbs->nextMap); if(R_GetPatchInfo(mapTitlePatch, &info)) origin.y += (5 * info.geometry.size.height) / 4; diff --git a/doomsday/plugins/doom64/src/m_cheat.cpp b/doomsday/plugins/doom64/src/m_cheat.cpp index 549a685228..a7166eb73f 100644 --- a/doomsday/plugins/doom64/src/m_cheat.cpp +++ b/doomsday/plugins/doom64/src/m_cheat.cpp @@ -167,7 +167,7 @@ void printDebugInfo(player_t *plr) char textBuffer[256]; sprintf(textBuffer, "MAP [%s] X:%g Y:%g Z:%g", - gameMapUri.path().toUtf8().constData(), + COMMON_GAMESESSION->mapUri().path().toUtf8().constData(), plrMo->origin[VX], plrMo->origin[VY], plrMo->origin[VZ]); P_SetMessage(plr, LMF_NO_HIDE, textBuffer); diff --git a/doomsday/plugins/doom64/src/p_enemy.c b/doomsday/plugins/doom64/src/p_enemy.c index e58f886429..d353458c69 100644 --- a/doomsday/plugins/doom64/src/p_enemy.c +++ b/doomsday/plugins/doom64/src/p_enemy.c @@ -1948,7 +1948,7 @@ void C_DECL A_CyberDeath(mobj_t *mo) }; static int const numBossTriggers = sizeof(bossTriggers) / sizeof(bossTriggers[0]); - Str const *currentMapPath = Uri_Path(G_CurrentMapUri()); + AutoStr *currentMapPath = G_CurrentMapUriPath(); int i; // Cyber deaths cause a rather spectacular kaboom. @@ -2071,7 +2071,7 @@ void C_DECL A_BarrelExplode(mobj_t *actor) S_StartSound(actor->info->deathSound, actor); P_RadiusAttack(actor, actor->target, 128, 127); - if(Str_CompareIgnoreCase(Uri_Path(G_CurrentMapUri()), "MAP01")) + if(Str_CompareIgnoreCase(G_CurrentMapUriPath(), "MAP01")) return; if(actor->type != MT_BARREL) @@ -2117,7 +2117,7 @@ void C_DECL A_BossDeath(mobj_t *mo) if(mo->type != MT_BITCH) return; - if(Str_CompareIgnoreCase(Uri_Path(G_CurrentMapUri()), "MAP30")) + if(Str_CompareIgnoreCase(G_CurrentMapUriPath(), "MAP30")) return; // Make sure there is a player alive for victory. @@ -2148,7 +2148,7 @@ void C_DECL A_Hoof(mobj_t *mo) * @todo Kludge: Only play very loud sounds in map 8. * \todo: Implement a MAPINFO option for this. */ - S_StartSound(SFX_HOOF | (!Str_CompareIgnoreCase(Uri_Path(G_CurrentMapUri()), "MAP08")? DDSF_NO_ATTENUATION : 0), mo); + S_StartSound(SFX_HOOF | (!Str_CompareIgnoreCase(G_CurrentMapUriPath(), "MAP08")? DDSF_NO_ATTENUATION : 0), mo); A_Chase(mo); } @@ -2158,7 +2158,7 @@ void C_DECL A_Metal(mobj_t *mo) * @todo Kludge: Only play very loud sounds in map 8. * \todo: Implement a MAPINFO option for this. */ - S_StartSound(SFX_MEAL | (!Str_CompareIgnoreCase(Uri_Path(G_CurrentMapUri()), "MAP08")? DDSF_NO_ATTENUATION : 0), mo); + S_StartSound(SFX_MEAL | (!Str_CompareIgnoreCase(G_CurrentMapUriPath(), "MAP08")? DDSF_NO_ATTENUATION : 0), mo); A_Chase(mo); } diff --git a/doomsday/plugins/doom64/src/wi_stuff.cpp b/doomsday/plugins/doom64/src/wi_stuff.cpp index 884bb59f91..bf56ae32b1 100644 --- a/doomsday/plugins/doom64/src/wi_stuff.cpp +++ b/doomsday/plugins/doom64/src/wi_stuff.cpp @@ -124,20 +124,21 @@ static void drawBackground() static void drawFinishedTitle(Vector2i origin = Vector2i(SCREENWIDTH / 2, WI_TITLEY)) { - String const mapTitle = G_MapTitle(); // current map - DGL_Enable(DGL_TEXTURE_2D); DGL_Color4f(1, 1, 1, 1); FR_SetFont(FID(GF_FONTB)); FR_LoadDefaultAttrib(); // Draw - patchid_t const mapTitlePatch = G_MapTitlePatch(&wbs->currentMap); + String const mapTitle = G_MapTitle(wbs->currentMap); + patchid_t const mapTitlePatch = G_MapTitlePatch(wbs->currentMap); WI_DrawPatch(mapTitlePatch, patchReplacementText(mapTitlePatch, mapTitle.toUtf8().constData()), origin, ALIGN_TOP, 0, DTF_NO_TYPEIN); patchinfo_t info; if(R_GetPatchInfo(mapTitlePatch, &info)) + { origin.y += (5 * info.geometry.size.height) / 4; + } // Draw "Finished!" WI_DrawPatch(pFinished, patchReplacementText(pFinished), origin, ALIGN_TOP); @@ -148,7 +149,7 @@ static void drawFinishedTitle(Vector2i origin = Vector2i(SCREENWIDTH / 2, WI_TIT static void drawEnteringTitle(Vector2i origin = Vector2i(SCREENWIDTH / 2, WI_TITLEY)) { // See if there is a map name... - String mapTitle = G_MapTitle(&wbs->nextMap); + String mapTitle = G_MapTitle(wbs->nextMap); DGL_Enable(DGL_TEXTURE_2D); DGL_Color4f(1, 1, 1, 1); @@ -159,7 +160,7 @@ static void drawEnteringTitle(Vector2i origin = Vector2i(SCREENWIDTH / 2, WI_TIT WI_DrawPatch(pEntering, patchReplacementText(pEntering), origin, ALIGN_TOP); patchinfo_t info; - patchid_t const mapTitlePatch = G_MapTitlePatch(&wbs->nextMap); + patchid_t const mapTitlePatch = G_MapTitlePatch(wbs->nextMap); if(R_GetPatchInfo(mapTitlePatch, &info)) origin.y += (5 * info.geometry.size.height) / 4; diff --git a/doomsday/plugins/heretic/src/in_lude.cpp b/doomsday/plugins/heretic/src/in_lude.cpp index 84ddc6fb82..72077b3a47 100644 --- a/doomsday/plugins/heretic/src/in_lude.cpp +++ b/doomsday/plugins/heretic/src/in_lude.cpp @@ -658,7 +658,7 @@ void IN_DrawOldLevel() FR_LoadDefaultAttrib(); FR_SetColorAndAlpha(defFontRGB[0], defFontRGB[1], defFontRGB[2], 1); - FR_DrawTextXY3(G_MapTitle(&wbs->currentMap).toUtf8().constData(), 160, 3, ALIGN_TOP, DTF_ONLY_SHADOW); + FR_DrawTextXY3(G_MapTitle(wbs->currentMap).toUtf8().constData(), 160, 3, ALIGN_TOP, DTF_ONLY_SHADOW); FR_SetFont(FID(GF_FONTA)); FR_SetColor(defFontRGB3[0], defFontRGB3[1],defFontRGB3[2]); @@ -714,7 +714,7 @@ void IN_DrawYAH() FR_SetFont(FID(GF_FONTB)); FR_SetColor(defFontRGB[0], defFontRGB[1], defFontRGB[2]); - FR_DrawTextXY3(G_MapTitle(&wbs->nextMap).toUtf8().constData(), 160, 20, ALIGN_TOP, DTF_ONLY_SHADOW); + FR_DrawTextXY3(G_MapTitle(wbs->nextMap).toUtf8().constData(), 160, 20, ALIGN_TOP, DTF_ONLY_SHADOW); DGL_Color4f(1, 1, 1, 1); @@ -752,7 +752,7 @@ void IN_DrawSingleStats() FR_DrawTextXY3("KILLS", 50, 65, ALIGN_TOPLEFT, DTF_ONLY_SHADOW); FR_DrawTextXY3("ITEMS", 50, 90, ALIGN_TOPLEFT, DTF_ONLY_SHADOW); FR_DrawTextXY3("SECRETS", 50, 115, ALIGN_TOPLEFT, DTF_ONLY_SHADOW); - FR_DrawTextXY3(G_MapTitle(&wbs->currentMap).toUtf8().constData(), 160, 3, ALIGN_TOP, DTF_ONLY_SHADOW); + FR_DrawTextXY3(G_MapTitle(wbs->currentMap).toUtf8().constData(), 160, 3, ALIGN_TOP, DTF_ONLY_SHADOW); FR_SetFont(FID(GF_FONTA)); FR_SetColor(defFontRGB3[0], defFontRGB3[1], defFontRGB3[2]); @@ -865,7 +865,7 @@ void IN_DrawSingleStats() FR_SetFont(FID(GF_FONTB)); FR_SetColorAndAlpha(defFontRGB[0], defFontRGB[1], defFontRGB[2], 1); - FR_DrawTextXY3(G_MapTitle(&wbs->nextMap).toUtf8().constData(), 160, 170, ALIGN_TOP, DTF_ONLY_SHADOW); + FR_DrawTextXY3(G_MapTitle(wbs->nextMap).toUtf8().constData(), 160, 170, ALIGN_TOP, DTF_ONLY_SHADOW); DGL_Disable(DGL_TEXTURE_2D); @@ -890,7 +890,7 @@ void IN_DrawCoopStats() FR_DrawTextXY3("KILLS", 95, 35, ALIGN_TOPLEFT, DTF_ONLY_SHADOW); FR_DrawTextXY3("BONUS", 155, 35, ALIGN_TOPLEFT, DTF_ONLY_SHADOW); FR_DrawTextXY3("SECRET", 232, 35, ALIGN_TOPLEFT, DTF_ONLY_SHADOW); - FR_DrawTextXY3(G_MapTitle(&wbs->currentMap).toUtf8().constData(), SCREENWIDTH/2, 3, ALIGN_TOP, DTF_ONLY_SHADOW); + FR_DrawTextXY3(G_MapTitle(wbs->currentMap).toUtf8().constData(), SCREENWIDTH/2, 3, ALIGN_TOP, DTF_ONLY_SHADOW); FR_SetFont(FID(GF_FONTA)); FR_SetColor(defFontRGB3[0], defFontRGB3[1], defFontRGB3[2]); diff --git a/doomsday/plugins/heretic/src/m_cheat.cpp b/doomsday/plugins/heretic/src/m_cheat.cpp index 17594bb456..9d0c056d13 100644 --- a/doomsday/plugins/heretic/src/m_cheat.cpp +++ b/doomsday/plugins/heretic/src/m_cheat.cpp @@ -682,7 +682,7 @@ D_CMD(CheatWhere) if(!plrMo) return true; sprintf(textBuffer, "MAP [%s] X:%g Y:%g Z:%g", - gameMapUri.path().toUtf8().constData(), + COMMON_GAMESESSION->mapUri().path().toUtf8().constData(), plrMo->origin[VX], plrMo->origin[VY], plrMo->origin[VZ]); P_SetMessage(plr, LMF_NO_HIDE, textBuffer); diff --git a/doomsday/plugins/heretic/src/p_enemy.c b/doomsday/plugins/heretic/src/p_enemy.c index edc147f555..c116162938 100644 --- a/doomsday/plugins/heretic/src/p_enemy.c +++ b/doomsday/plugins/heretic/src/p_enemy.c @@ -2136,7 +2136,7 @@ void C_DECL A_BossDeath(mobj_t *actor) static int const numBossTriggers = sizeof(bossTriggers) / sizeof(bossTriggers[0]); int i; - Str const *currentMapPath = Uri_Path(G_CurrentMapUri()); + AutoStr *currentMapPath = G_CurrentMapUriPath(); for(i = 0; i < numBossTriggers; ++i) { BossTrigger const *trigger = &bossTriggers[i]; diff --git a/doomsday/plugins/hexen/src/acscript.cpp b/doomsday/plugins/hexen/src/acscript.cpp index 2228044785..e35cdf1962 100644 --- a/doomsday/plugins/hexen/src/acscript.cpp +++ b/doomsday/plugins/hexen/src/acscript.cpp @@ -276,7 +276,7 @@ bool ACScriptInterpreter::startScript(int scriptNumber, de::Uri const *mapUri, if(mapUri) { - if(gameMapUri != *mapUri) + if(COMMON_GAMESESSION->mapUri() != *mapUri) { // Script is not for the current map. // Add it to the store to be started when that map is next entered. diff --git a/doomsday/plugins/hexen/src/m_cheat.cpp b/doomsday/plugins/hexen/src/m_cheat.cpp index d701cf42b8..a72f72612c 100644 --- a/doomsday/plugins/hexen/src/m_cheat.cpp +++ b/doomsday/plugins/hexen/src/m_cheat.cpp @@ -26,6 +26,7 @@ #include "d_net.h" #include "g_common.h" +#include "gamesession.h" #include "player.h" #include "am_map.h" #include "hu_msg.h" @@ -660,7 +661,7 @@ D_CMD(CheatWhere) char textBuffer[256]; sprintf(textBuffer, "MAP [%s] X:%g Y:%g Z:%g", - gameMapUri.path().toUtf8().constData(), + COMMON_GAMESESSION->mapUri().path().toUtf8().constData(), plrMo->origin[VX], plrMo->origin[VY], plrMo->origin[VZ]); P_SetMessage(plr, LMF_NO_HIDE, textBuffer); diff --git a/doomsday/plugins/hexen/src/p_spec.cpp b/doomsday/plugins/hexen/src/p_spec.cpp index cd7940f9e9..cbbf9ecfd3 100644 --- a/doomsday/plugins/hexen/src/p_spec.cpp +++ b/doomsday/plugins/hexen/src/p_spec.cpp @@ -200,7 +200,13 @@ dd_bool EV_LineSearchForPuzzleItem(Line *line, byte * /*args*/, mobj_t *mo) static de::Uri getMapUriForWarpNumber(int warpNumber) { - if(!warpNumber) return gameMapUri; // current map. + if(!warpNumber) + { + /// @todo Surely this is never reached because warping to the current map is + /// usually impossible in Hexen. Does anything actually use this? -ds + DENG2_ASSERT(!"getMapUriForWarpNumber() called with warpNumber:0"); + return COMMON_GAMESESSION->mapUri(); // Current map URI. + } return TranslateMapWarpNumber(COMMON_GAMESESSION->episodeId(), warpNumber - 1); }