From 44cb574e327a5d73724e6e0e57cb32da5451f93b Mon Sep 17 00:00:00 2001 From: danij Date: Sat, 8 Feb 2014 23:24:12 +0000 Subject: [PATCH] Refactor|libcommon: Use a map URI with G_NewGame() and G_DeferredNewGame() At present the logical episode and map numbers are parsed from the map URI. In the future the episode should be specified in MAPINFO. --- doomsday/plugins/common/include/g_common.h | 17 +- doomsday/plugins/common/include/p_mapsetup.h | 13 +- doomsday/plugins/common/src/d_net.c | 24 +- doomsday/plugins/common/src/d_netcl.c | 22 +- doomsday/plugins/common/src/d_netsv.c | 12 +- doomsday/plugins/common/src/fi_lib.c | 10 +- doomsday/plugins/common/src/g_game.c | 234 +++++++++++-------- doomsday/plugins/common/src/g_update.c | 6 +- doomsday/plugins/common/src/hu_menu.c | 8 +- doomsday/plugins/common/src/hu_stuff.cpp | 12 +- doomsday/plugins/common/src/p_mapsetup.cpp | 27 +-- doomsday/plugins/common/src/p_saveg.cpp | 6 +- doomsday/plugins/common/src/p_sound.cpp | 2 +- doomsday/plugins/doom/include/g_game.h | 1 + doomsday/plugins/doom/src/d_main.c | 59 +++-- doomsday/plugins/doom/src/m_cheat.c | 37 +-- doomsday/plugins/doom/src/p_oldsvg.cpp | 2 +- doomsday/plugins/doom/src/wi_stuff.c | 2 +- doomsday/plugins/doom64/include/g_game.h | 1 + doomsday/plugins/doom64/src/d_main.c | 53 ++--- doomsday/plugins/doom64/src/m_cheat.c | 40 ++-- doomsday/plugins/doom64/src/wi_stuff.c | 2 +- doomsday/plugins/heretic/include/g_game.h | 1 + doomsday/plugins/heretic/src/h_main.c | 53 +++-- doomsday/plugins/heretic/src/m_cheat.c | 40 ++-- doomsday/plugins/heretic/src/p_oldsvg.cpp | 2 +- doomsday/plugins/hexen/include/g_game.h | 1 + doomsday/plugins/hexen/include/p_mapinfo.h | 5 + doomsday/plugins/hexen/src/acscript.cpp | 7 +- doomsday/plugins/hexen/src/h2_main.c | 57 ++--- doomsday/plugins/hexen/src/m_cheat.c | 39 ++-- doomsday/plugins/hexen/src/p_mapinfo.cpp | 5 + doomsday/plugins/hexen/src/p_spec.c | 4 +- 33 files changed, 404 insertions(+), 400 deletions(-) diff --git a/doomsday/plugins/common/include/g_common.h b/doomsday/plugins/common/include/g_common.h index 189d1cf6dc..d5347200fe 100644 --- a/doomsday/plugins/common/include/g_common.h +++ b/doomsday/plugins/common/include/g_common.h @@ -69,13 +69,12 @@ void G_EndGame(void); dd_bool G_QuitInProgress(void); /** - * @param episode Logical episode number. - * @param map Logical map number (i.e., not a warp/translated number). + * @param mapUri Map identifier. * @param mapEntrance Logical map entry point number. * @param rules Game rules to apply. */ -void G_NewGame(uint episode, uint map, uint mapEntrance, GameRuleset const *rules); -void G_DeferredNewGame(uint episode, uint map, uint mapEntrance, GameRuleset const *rules); +void G_NewGame(Uri const *mapUri, uint mapEntrance, GameRuleset const *rules); +void G_DeferredNewGame(Uri const *mapUri, uint mapEntrance, GameRuleset const *rules); /** * Signal that play on the current map may now begin. @@ -103,16 +102,6 @@ void G_LeaveMap(uint newMap, uint mapEntryPoint, dd_bool secretExit); */ Uri *G_ComposeMapUri(uint episode, uint map); -/** - * Compose the Uri for the @em current map. - * - * @note Some APIs are designed such that a NULL uri pointer means the "current map", - * so, calling this may be unnecessary. - * - * @return Resultant Uri. Must be destroyed with Uri_Delete() when no longer needed. - */ -Uri *G_CurrentMapUri(void); - /** * Determine if the specified @a episode and @a map value pair are valid and if not, * adjust their are values within the ranges defined by the current game type and mode. diff --git a/doomsday/plugins/common/include/p_mapsetup.h b/doomsday/plugins/common/include/p_mapsetup.h index fcfa23df70..056096b21d 100644 --- a/doomsday/plugins/common/include/p_mapsetup.h +++ b/doomsday/plugins/common/include/p_mapsetup.h @@ -46,12 +46,19 @@ void P_FinalizeMapChange(Uri const *uri); */ void P_SetupMap(Uri *uri); +/** + * @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). + */ char const *P_MapAuthor(Uri const *mapUri, dd_bool supressGameAuthor); + +/** + * @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). + */ char const *P_MapTitle(Uri const *mapUri); -patchid_t P_MapTitlePatch(uint episode, uint map); -char const *P_CurrentMapAuthor(dd_bool supressGameAuthor); -char const *P_CurrentMapTitle(void); +patchid_t P_MapTitlePatch(uint episode, uint map); #if __JDOOM__ || __JDOOM64__ || __JHERETIC__ void P_FindSecrets(void); diff --git a/doomsday/plugins/common/src/d_net.c b/doomsday/plugins/common/src/d_net.c index ab79f14af1..e41d06d29c 100644 --- a/doomsday/plugins/common/src/d_net.c +++ b/doomsday/plugins/common/src/d_net.c @@ -126,7 +126,7 @@ void NetSv_ApplyGameRulesFromConfig(void) */ int D_NetServerStarted(int before) { - uint netMap, netEpisode; + Uri *netMapUri = 0; GameRuleset netRules = gameRules; // Make a copy of the current rules. if(before) return true; @@ -144,26 +144,30 @@ int D_NetServerStarted(int before) // Set the game parameters. NetSv_ApplyGameRulesFromConfig(); - // Hexen has translated map numbers. -#if __JHEXEN__ - netMap = P_TranslateMap(cfg.netMap); + { +#if __JDOOM64__ + uint netEpisode = 0; #else - netMap = cfg.netMap; + uint netEpisode = cfg.netEpisode; #endif - -#if __JDOOM64__ - netEpisode = 0; +#if __JHEXEN__ // Map numbers need to be translated. + uint netMap = P_TranslateMap(cfg.netMap); #else - netEpisode = cfg.netEpisode; + uint netMap = cfg.netMap; #endif + netMapUri = G_ComposeMapUri(netEpisode, netMap); + } + netRules.skill = cfg.netSkill; - G_NewGame(netEpisode, netMap, 0/*default*/, &netRules); + G_NewGame(netMapUri, 0/*default*/, &netRules); /// @todo Necessary? G_SetGameAction(GA_NONE); + Uri_Delete(netMapUri); + return true; } diff --git a/doomsday/plugins/common/src/d_netcl.c b/doomsday/plugins/common/src/d_netcl.c index 818cfa4f5b..bc586a3b5e 100644 --- a/doomsday/plugins/common/src/d_netcl.c +++ b/doomsday/plugins/common/src/d_netcl.c @@ -42,10 +42,10 @@ void NetCl_UpdateGameState(Reader* msg) byte len; byte gsFlags = 0; char gsGameIdentity[256]; - Uri* mapUri; - byte gsEpisode = 0; - byte gsMap = 0; - byte gsMapEntrance = 0; + Uri *mapUri; + uint gsEpisode = 0; + uint gsMap = 0; + uint gsMapEntrance = 0; byte configFlags = 0; //byte gsDeathmatch = 0; //byte gsMonsters = 0; @@ -65,13 +65,12 @@ void NetCl_UpdateGameState(Reader* msg) gsGameIdentity[len] = 0; // Current map. - mapUri = Uri_FromReader(msg); - + mapUri = Uri_FromReader(msg); gsEpisode = Reader_ReadByte(msg); - gsMap = Reader_ReadByte(msg); + gsMap = Reader_ReadByte(msg); /// @todo Not communicated to clients?? - //gsMapEntryPoint = ??; + //gsMapEntrance = ??; configFlags = Reader_ReadByte(msg); gsRules.deathmatch = configFlags & 0x3; @@ -80,11 +79,13 @@ void NetCl_UpdateGameState(Reader* msg) gsRules.respawnMonsters = (configFlags & 0x8? true : false); #endif gsJumping = (configFlags & 0x10? true : false); - gsRules.skill = Reader_ReadByte(msg); + gsRules.skill = Reader_ReadByte(msg); // Interpret skill modes outside the normal range as "spawn no things". if(gsRules.skill < SM_BABY || gsRules.skill >= NUM_SKILL_MODES) + { gsRules.skill = SM_NOTHINGS; + } gsGravity = Reader_ReadFloat(msg); @@ -138,7 +139,7 @@ void NetCl_UpdateGameState(Reader* msg) // Do we need to change the map? if(gsFlags & GSF_CHANGE_MAP) { - G_NewGame(gsEpisode, gsMap, gameMapEntrance /*gsMapEntrance*/, &gsRules); + G_NewGame(mapUri, gameMapEntrance /*gsMapEntrance*/, &gsRules); /// @todo Necessary? G_SetGameAction(GA_NONE); @@ -147,6 +148,7 @@ void NetCl_UpdateGameState(Reader* msg) { gameEpisode = gsEpisode; gameMap = gsMap; + Uri_Copy(gameMapUri, mapUri); //gameMapEntrance = gsMapEntrance; /// @todo Not communicated to clients?? gameRules = gsRules; } diff --git a/doomsday/plugins/common/src/d_netsv.c b/doomsday/plugins/common/src/d_netsv.c index a655e16fc2..fc9ad03542 100644 --- a/doomsday/plugins/common/src/d_netsv.c +++ b/doomsday/plugins/common/src/d_netsv.c @@ -727,19 +727,17 @@ void NetSv_SendTotalCounts(int to) void NetSv_SendGameState(int flags, int to) { int i; - Writer* writer; + Writer *writer; GameInfo gameInfo; - Uri* mapUri; - AutoStr* str; + AutoStr *str; if(!IS_NETWORK_SERVER) return; DD_GameInfo(&gameInfo); - mapUri = G_CurrentMapUri(); // Print a short message that describes the game state. - str = Uri_Resolved(mapUri); + str = Uri_Resolved(gameMapUri); App_Log(DE2_NET_NOTE, "Sending game setup: %s %s %s", Str_Text(gameInfo.identityKey), Str_Text(str), gameConfigString); @@ -758,7 +756,7 @@ void NetSv_SendGameState(int flags, int to) Writer_Write(writer, Str_Text(gameInfo.identityKey), Str_Length(gameInfo.identityKey)); // The current map. - Uri_Write(mapUri, writer); + Uri_Write(gameMapUri, writer); // Also include the episode and map numbers. Writer_WriteByte(writer, gameEpisode); @@ -789,8 +787,6 @@ void NetSv_SendGameState(int flags, int to) // Send the packet. Net_SendPacket(i, GPT_GAME_STATE, Writer_Data(writer), Writer_Size(writer)); } - - Uri_Delete(mapUri); } /** diff --git a/doomsday/plugins/common/src/fi_lib.c b/doomsday/plugins/common/src/fi_lib.c index 8e6d1dbdc3..54d7a5d9f3 100644 --- a/doomsday/plugins/common/src/fi_lib.c +++ b/doomsday/plugins/common/src/fi_lib.c @@ -103,10 +103,9 @@ static void initStateConditions(fi_state_t *s) #if __JHEXEN__ // Leaving the current cluster? { - Uri *curMapUri = G_CurrentMapUri(); Uri *nextMapUri = G_ComposeMapUri(gameEpisode, nextMap); - mapinfo_t *curMapInfo = P_MapInfo(curMapUri); + mapinfo_t *curMapInfo = P_CurrentMapInfo(); mapinfo_t *nextMapInfo = P_MapInfo(nextMapUri); if(curMapInfo && nextMapInfo) { @@ -114,7 +113,6 @@ static void initStateConditions(fi_state_t *s) } Uri_Delete(nextMapUri); - Uri_Delete(curMapUri); } App_Log(DE2_DEV_SCR_VERBOSE, "Infine state condition: leave_hub=%i", s->conditions.leave_hub); #endif @@ -453,14 +451,10 @@ int Hook_FinaleScriptStop(int hookType, int finaleId, void* parameters) else if(mode == FIMODE_BEFORE) // A briefing has ended. { // Its time to start the map; que music and begin! - Uri *mapUri = G_CurrentMapUri(); - - S_MapMusic(mapUri); + S_MapMusic(0/*current map*/); HU_WakeWidgets(-1 /* all players */); G_BeginMap(); Pause_End(); // skip forced period - - Uri_Delete(mapUri); } return true; } diff --git a/doomsday/plugins/common/src/g_game.c b/doomsday/plugins/common/src/g_game.c index 4724cbf4ea..665b9667fb 100644 --- a/doomsday/plugins/common/src/g_game.c +++ b/doomsday/plugins/common/src/g_game.c @@ -165,6 +165,7 @@ dd_bool gameInProgress; uint gameEpisode; uint gameMap; uint gameMapEntrance; // Position indicator for reborn. +Uri *gameMapUri; GameRuleset gameRules; uint nextMap; @@ -208,9 +209,14 @@ int bodyQueueSlot; #endif // vars used with game status cvars +int gsvEpisode = 0; +int gsvMap = 0; +char *gsvMapAuthor = "Unknown"; +int gsvMapMusic = -1; +char *gsvMapTitle = "Unknown"; + int gsvInMap = 0; int gsvCurrentMusic = 0; -int gsvMapMusic = -1; int gsvArmor = 0; int gsvHealth = 0; @@ -226,9 +232,6 @@ int gsvWeapons[NUM_WEAPON_TYPES]; int gsvKeys[NUM_KEY_TYPES]; int gsvAmmo[NUM_AMMO_TYPES]; -char *gsvMapName = "Unknown"; -char *gsvMapAuthor = "Unknown"; - #if __JHERETIC__ || __JHEXEN__ || __JDOOM64__ int gsvInvItems[NUM_INVENTORYITEM_TYPES]; #endif @@ -252,13 +255,13 @@ cvartemplate_t gamestatusCVars[] = #endif {"map-author", READONLYCVAR, CVT_CHARPTR, &gsvMapAuthor, 0, 0}, - {"map-episode", READONLYCVAR, CVT_INT, &gameEpisode, 0, 0}, + {"map-episode", READONLYCVAR, CVT_INT, &gsvEpisode, 0, 0}, #if __JHEXEN__ {"map-hub", READONLYCVAR, CVT_INT, &mapHub, 0, 0}, #endif - {"map-id", READONLYCVAR, CVT_INT, &gameMap, 0, 0}, + {"map-id", READONLYCVAR, CVT_INT, &gsvMap, 0, 0}, {"map-music", READONLYCVAR, CVT_INT, &gsvMapMusic, 0, 0}, - {"map-name", READONLYCVAR, CVT_CHARPTR, &gsvMapName, 0, 0}, + {"map-name", READONLYCVAR, CVT_CHARPTR, &gsvMapTitle, 0, 0}, {"player-health", READONLYCVAR, CVT_INT, &gsvHealth, 0, 0}, {"player-armor", READONLYCVAR, CVT_INT, &gsvArmor, 0, 0}, @@ -402,9 +405,8 @@ ccmdtemplate_t gameCmds[] = { }; // Deferred new game arguments: -static uint dEpisode; -static uint dMap; static uint dMapEntrance; +static Uri *dMapUri; ///< @todo fixme: Never free'd static GameRuleset dRules; static gameaction_t gameAction; @@ -459,6 +461,8 @@ void G_CommonPreInit(void) { int i, j; + DENG_ASSERT(gameMapUri == 0); + gameMapUri = Uri_New(); quitInProgress = false; verbose = CommandLine_Exists("-verbose"); @@ -948,7 +952,7 @@ void G_CommonPostInit(void) /** * Common game shutdown routine. - * \note Game-specific actions should be placed in G_Shutdown rather than here. + * @note Game-specific actions should be placed in G_Shutdown rather than here. */ void G_CommonShutdown(void) { @@ -966,6 +970,8 @@ void G_CommonShutdown(void) Hu_MenuShutdown(); ST_Shutdown(); GUI_Shutdown(); + + Uri_Delete(gameMapUri); gameMapUri = 0; } /** @@ -1142,37 +1148,31 @@ void G_StartHelp(void) */ static void printMapBanner(void) { - Uri *mapUri = G_CurrentMapUri(); - char const *title = P_CurrentMapTitle(); + char const *title = P_MapTitle(0/*current map*/); App_Log(DE2_LOG_MAP, DE2_ESC(R)); if(title) { char buf[64]; #if __JHEXEN__ - mapinfo_t const *mapInfo = P_MapInfo(mapUri); + mapinfo_t const *mapInfo = P_CurrentMapInfo(); int warpNum = (mapInfo? mapInfo->warpTrans : -1); dd_snprintf(buf, 64, "Map %u (%u): " DE2_ESC(b) "%s", warpNum + 1, gameMap + 1, title); #else - dd_snprintf(buf, 64, "Map %u: " DE2_ESC(b) "%s", gameMap+1, title); + dd_snprintf(buf, 64, "Map %u: " DE2_ESC(b) "%s", gameMap + 1, title); #endif App_Log(DE2_MAP_NOTE, "%s", buf); } #if !__JHEXEN__ { - AutoStr *path = Uri_Compose(mapUri); - char const *author; - - author = P_CurrentMapAuthor(P_MapIsCustom(Str_Text(path))); + char const *author = P_MapAuthor(0/*current map*/, P_MapIsCustom(Str_Text(Uri_Compose(gameMapUri)))); if(!author) author = "Unknown"; App_Log(DE2_MAP_VERBOSE, "Author: %s", author); } #endif App_Log(DE2_LOG_MAP, ""); - - Uri_Delete(mapUri); } void G_BeginMap(void) @@ -1256,8 +1256,7 @@ static void initFogForMap(ddmapinfo_t *mapInfo) #if __JHEXEN__ { - Uri *mapUri = G_CurrentMapUri(); - mapinfo_t const *mapInfo = P_MapInfo(mapUri); + mapinfo_t const *mapInfo = P_CurrentMapInfo(); if(mapInfo) { int fadeTable = mapInfo->fadeTable; @@ -1276,7 +1275,6 @@ static void initFogForMap(ddmapinfo_t *mapInfo) } } } - Uri_Delete(mapUri); } #endif } @@ -1423,8 +1421,8 @@ void G_UpdateGSVarsForPlayer(player_t* pl) void G_UpdateGSVarsForMap(void) { - char const *mapAuthor = P_CurrentMapAuthor(false/*don't supress*/); - char const *mapTitle = P_CurrentMapTitle(); + char const *mapAuthor = P_MapAuthor(0/*current map*/, false/*don't supress*/); + char const *mapTitle = P_MapTitle(0/*current map*/); if(!mapAuthor) mapAuthor = "Unknown"; Con_SetString2("map-author", mapAuthor, SVF_WRITE_OVERRIDE); @@ -1511,7 +1509,7 @@ void G_DoQuitGame(void) void G_QueMapMusic(Uri const *mapUri) { - DENG_ASSERT(mapUri != 0); + if(!mapUri) mapUri = gameMapUri; #if __JHEXEN__ /** @@ -1548,7 +1546,7 @@ static void runGameAction(void) { case GA_NEWGAME: G_InitNewGame(); - G_NewGame(dEpisode, dMap, dMapEntrance, &dRules); + G_NewGame(dMapUri, dMapEntrance, &dRules); G_SetGameAction(GA_NONE); break; @@ -1766,13 +1764,11 @@ void G_PlayerLeaveMap(int player) #if __JHEXEN__ { - Uri *mapUri = G_CurrentMapUri(); Uri *nextMapUri = G_ComposeMapUri(gameEpisode, nextMap); - newCluster = (P_MapInfo(mapUri)->cluster != P_MapInfo(nextMapUri)->cluster); + newCluster = (P_CurrentMapInfo()->cluster != P_MapInfo(nextMapUri)->cluster); Uri_Delete(nextMapUri); - Uri_Delete(mapUri); } #endif @@ -2414,16 +2410,13 @@ void G_DoMapCompleted(void) // Go to an intermission? #if __JDOOM__ || __JHERETIC__ || __JDOOM64__ { - ddmapinfo_t minfo; - Uri* mapUri = G_CurrentMapUri(); - AutoStr* mapPath = Uri_Compose(mapUri); - if(Def_Get(DD_DEF_MAP_INFO, Str_Text(mapPath), &minfo) && (minfo.flags & MIF_NO_INTERMISSION)) - { - Uri_Delete(mapUri); - G_IntermissionDone(); - return; - } - Uri_Delete(mapUri); + ddmapinfo_t minfo; + if(Def_Get(DD_DEF_MAP_INFO, Str_Text(Uri_Compose(gameMapUri)), &minfo) && + (minfo.flags & MIF_NO_INTERMISSION)) + { + G_IntermissionDone(); + return; + } } #elif __JHEXEN__ @@ -2479,9 +2472,8 @@ void G_DoMapCompleted(void) #if __JDOOM__ || __JDOOM64__ void G_PrepareWIData(void) { - Uri* mapUri = G_CurrentMapUri(); - AutoStr* mapPath = Uri_Compose(mapUri); - wbstartstruct_t* info = &wmInfo; + AutoStr *mapPath = Uri_Compose(gameMapUri); + wbstartstruct_t *info = &wmInfo; ddmapinfo_t minfo; int i; @@ -2489,9 +2481,13 @@ void G_PrepareWIData(void) // See if there is a par time definition. if(Def_Get(DD_DEF_MAP_INFO, Str_Text(mapPath), &minfo) && minfo.parTime > 0) + { info->parTime = TICRATE * (int) minfo.parTime; + } else + { info->parTime = -1; // Unknown. + } info->pNum = CONSOLEPLAYER; for(i = 0; i < MAXPLAYERS; ++i) @@ -2506,8 +2502,6 @@ void G_PrepareWIData(void) pStats->time = mapTime; memcpy(pStats->frags, p->frags, sizeof(pStats->frags)); } - - Uri_Delete(mapUri); } #endif @@ -2517,17 +2511,10 @@ void G_PrepareWIData(void) */ dd_bool G_StartDebriefing() { - Uri *mapUri = G_CurrentMapUri(); ddfinale_t fin; - - if(G_DebriefingEnabled(mapUri, &fin) && - G_StartFinale(fin.script, 0, FIMODE_AFTER, 0)) - { - Uri_Delete(mapUri); - return true; - } - Uri_Delete(mapUri); - return false; + if(!G_DebriefingEnabled(gameMapUri, &fin)) return false; + + return G_StartFinale(fin.script, 0, FIMODE_AFTER, 0); } void G_IntermissionDone(void) @@ -2614,9 +2601,8 @@ void G_DoLeaveMap(void) // Same cluster? { - Uri *mapUri = G_CurrentMapUri(); Uri *nextMapUri = G_ComposeMapUri(gameEpisode, nextMap); - if(P_MapInfo(mapUri)->cluster == P_MapInfo(nextMapUri)->cluster) + if(P_CurrentMapInfo()->cluster == P_MapInfo(nextMapUri)->cluster) { if(!gameRules.deathmatch) { @@ -2633,7 +2619,6 @@ void G_DoLeaveMap(void) } Uri_Delete(nextMapUri); - Uri_Delete(mapUri); } // Take a copy of the player objects (they will be cleared in the process @@ -2747,7 +2732,7 @@ void G_DoRestartMap(void) // Restart the game session entirely. G_InitNewGame(); - G_NewGame(dEpisode, dMap, dMapEntrance, &dRules); + G_NewGame(dMapUri, dMapEntrance, &dRules); #else loadmap_params_t p; @@ -2759,7 +2744,7 @@ void G_DoRestartMap(void) // Delete raw images to conserve texture memory. DD_Executef(true, "texreset raw"); - p.mapUri = G_CurrentMapUri(); + p.mapUri = gameMapUri; p.revisit = false; // Don't reload save state. // This is a restart, so we won't brief again. @@ -2775,7 +2760,6 @@ void G_DoRestartMap(void) G_BeginMap(); Z_CheckHeap(); - Uri_Delete(p.mapUri); #endif } @@ -2877,15 +2861,13 @@ AutoStr *G_GenerateSaveGameName(void) char const *baseName, *mapTitle; char baseNameBuf[256]; AutoStr *mapPath; - Uri *mapUri; hours = time / 3600; time -= hours * 3600; minutes = time / 60; time -= minutes * 60; seconds = time; - mapUri = G_CurrentMapUri(); - mapPath = Uri_Compose(mapUri); - mapTitle = P_CurrentMapTitle(); + mapPath = Uri_Compose(gameMapUri); + mapTitle = P_MapTitle(0/*current map*/); // Still no map title? Use the identifier. // Some tricksy modders provide us with an empty title... @@ -2905,7 +2887,6 @@ AutoStr *G_GenerateSaveGameName(void) Str_Appendf(str, "%s%s%s %02i:%02i:%02i", (baseName? baseName : ""), (baseName? ":" : ""), mapTitle, hours, minutes, seconds); - Uri_Delete(mapUri); return str; } @@ -2958,23 +2939,72 @@ void G_DoSaveGame(void) G_SetGameAction(GA_NONE); } -void G_DeferredNewGame(uint episode, uint map, uint mapEntrance, GameRuleset const *rules) +void G_DeferredNewGame(Uri const *mapUri, uint mapEntrance, GameRuleset const *rules) { - DENG_ASSERT(rules != 0); - - dEpisode = episode; - dMap = map; + if(!dMapUri) + { + dMapUri = Uri_New(); + } + Uri_Copy(dMapUri, mapUri? mapUri : gameMapUri); dMapEntrance = mapEntrance; - dRules = *rules; // make a copy. + dRules = rules? *rules : gameRules; // make a copy. G_SetGameAction(GA_NEWGAME); } -void G_NewGame(uint episode, uint map, uint mapEntrance, GameRuleset const *rules) +/// @todo Get this from MAPINFO +static uint episodeNumberFor(Uri const *mapUri) +{ +#if __JDOOM__ || __JHERETIC__ + AutoStr *path = Uri_Resolved(mapUri); + if(!Str_IsEmpty(path)) + { +# if __JDOOM__ + if(gameModeBits & (GM_ANY_DOOM | ~GM_DOOM_CHEX)) +# endif + { + if(Str_At(path, 0) == 'E' && Str_At(path, 2) == 'M') + { + return atoi(Str_Text(path) + 1) - 1; + } + } + } +#else + DENG_UNUSED(mapUri); +#endif + return 0; +} + +/// @todo Get this from MAPINFO +static uint mapNumberFor(Uri const *mapUri) +{ + AutoStr *path = Uri_Resolved(mapUri); + if(!Str_IsEmpty(path)) + { +#if __JDOOM__ || __JHERETIC__ +# if __JDOOM__ + if(gameModeBits & (GM_ANY_DOOM | ~GM_DOOM_CHEX)) +# endif + { + if(Str_At(path, 0) == 'E' && Str_At(path, 2) == 'M') + { + return atoi(Str_Text(path) + 3) - 1; + } + } +#endif + if(Str_StartsWith(path, "MAP")) + { + return atoi(Str_Text(path) + 3) - 1; + } + } + return 0; +} + +void G_NewGame(Uri const *mapUri, uint mapEntrance, GameRuleset const *rules) { uint i; - DENG_ASSERT(rules != 0); + DENG_ASSERT(mapUri != 0 && rules != 0); G_StopDemo(); @@ -3016,14 +3046,24 @@ void G_NewGame(uint episode, uint map, uint mapEntrance, GameRuleset const *rule // Delete raw images to conserve texture memory. DD_Executef(true, "texreset raw"); - // Make sure that the episode and map numbers are good. - G_ValidateMap(&episode, &map); - - gameEpisode = episode; - gameMap = map; + gameEpisode = episodeNumberFor(mapUri); + gameMap = mapNumberFor(mapUri); + Uri_Copy(gameMapUri, mapUri); gameMapEntrance = mapEntrance; gameRules = *rules; + // Make sure that the episode and map numbers are good. + if(!G_ValidateMap(&gameEpisode, &gameMap)) + { + Uri *validMapUri = G_ComposeMapUri(gameEpisode, gameMap); + Uri_Copy(gameMapUri, validMapUri); + Uri_Delete(validMapUri); + } + + // Update game status cvars: + gsvMap = (unsigned)gameMap; + gsvEpisode = (unsigned)gameEpisode; + G_ApplyNewGameRules(); M_ResetRandom(); @@ -3035,7 +3075,7 @@ void G_NewGame(uint episode, uint map, uint mapEntrance, GameRuleset const *rule dd_bool showBrief; ddfinale_t fin; - p.mapUri = G_CurrentMapUri(); + p.mapUri = gameMapUri; p.revisit = false; showBrief = G_BriefingEnabled(p.mapUri, &fin); @@ -3059,10 +3099,9 @@ void G_NewGame(uint episode, uint map, uint mapEntrance, GameRuleset const *rule HU_WakeWidgets(-1 /* all players */); G_BeginMap(); } - - Z_CheckHeap(); - Uri_Delete(p.mapUri); } + + Z_CheckHeap(); } int G_QuitGameResponse(msgresponse_t response, int userValue, void* userPointer) @@ -3151,11 +3190,6 @@ Uri *G_ComposeMapUri(uint episode, uint map) return Uri_NewWithPath2(mapId, RC_NULL); } -Uri *G_CurrentMapUri(void) -{ - return G_ComposeMapUri(gameEpisode, gameMap); -} - dd_bool G_ValidateMap(uint *episode, uint *map) { dd_bool ok = true; @@ -3967,6 +4001,7 @@ D_CMD(WarpMap) // Hexen map numbers require translation. map = P_TranslateMapIfExists(map); #endif + if(!G_ValidateMap(&epsd, &map)) { char const *fmtString = argc == 3? "Unknown map \"%s, %s\"." : "Unknown map \"%s%s\"."; @@ -4001,19 +4036,24 @@ D_CMD(WarpMap) // So be it. briefDisabled = true; - if(!forceNewGameSession && gameInProgress) + { + Uri *newMapUri = G_ComposeMapUri(epsd, map); + if(!forceNewGameSession && gameInProgress) + { #if __JHEXEN__ - nextMap = map; - nextMapEntrance = 0; - G_SetGameAction(GA_LEAVEMAP); + nextMap = map; + nextMapEntrance = 0; + G_SetGameAction(GA_LEAVEMAP); #else - G_DeferredNewGame(epsd, map, 0/*default*/, &gameRules); + G_DeferredNewGame(newMapUri, 0/*default*/, &gameRules); #endif - } - else - { - G_DeferredNewGame(epsd, map, 0/*default*/, &gameRules); + } + else + { + G_DeferredNewGame(newMapUri, 0/*default*/, &gameRules); + } + Uri_Delete(newMapUri); } // If the command source was "us" the game library then it was probably in diff --git a/doomsday/plugins/common/src/g_update.c b/doomsday/plugins/common/src/g_update.c index 83bc4738b8..09555922de 100644 --- a/doomsday/plugins/common/src/g_update.c +++ b/doomsday/plugins/common/src/g_update.c @@ -132,11 +132,7 @@ void G_UpdateState(int step) #endif #if __JDOOM__ || __JHERETIC__ || __JDOOM64__ - { - Uri *mapUri = G_CurrentMapUri(); - S_MapMusic(mapUri); - Uri_Delete(mapUri); - } + S_MapMusic(0/*current map*/); #endif break; diff --git a/doomsday/plugins/common/src/hu_menu.c b/doomsday/plugins/common/src/hu_menu.c index 556687a0fe..cb0a9a45e2 100644 --- a/doomsday/plugins/common/src/hu_menu.c +++ b/doomsday/plugins/common/src/hu_menu.c @@ -6442,6 +6442,7 @@ int Hu_MenuConfirmInitNewGame(msgresponse_t response, int userValue, void* userP void Hu_MenuInitNewGame(dd_bool confirmed) { GameRuleset newRules = gameRules; + Uri *newMapUri = 0; #if __JDOOM__ if(!confirmed && SM_NIGHTMARE == mnSkillmode) @@ -6459,10 +6460,13 @@ void Hu_MenuInitNewGame(dd_bool confirmed) newRules.skill = mnSkillmode; #if __JHEXEN__ - G_DeferredNewGame(mnEpisode, P_TranslateMap(0), 0/*default*/, &newRules); + newMapUri = G_ComposeMapUri(mnEpisode, P_TranslateMap(0)); #else - G_DeferredNewGame(mnEpisode, 0, 0/*default*/, &newRules); + newMapUri = G_ComposeMapUri(mnEpisode, 0); #endif + + G_DeferredNewGame(newMapUri, 0/*default*/, &newRules); + Uri_Delete(newMapUri); } int Hu_MenuActionInitNewGame(mn_object_t* ob, mn_actionid_t action, void* parameters) diff --git a/doomsday/plugins/common/src/hu_stuff.cpp b/doomsday/plugins/common/src/hu_stuff.cpp index cc5908cdac..b932a4237a 100644 --- a/doomsday/plugins/common/src/hu_stuff.cpp +++ b/doomsday/plugins/common/src/hu_stuff.cpp @@ -751,7 +751,7 @@ static void drawMapMetaData(float x, float y, float alpha) { #define BORDER 2 - char const *title = P_CurrentMapTitle(); + char const *title = P_MapTitle(0/*current map*/); if(!title) title = "Unnamed"; char buf[256]; @@ -1482,7 +1482,7 @@ int Hu_MapTitleFirstLineHeight(void) dd_bool Hu_IsMapTitleAuthorVisible(void) { - char const *author = P_CurrentMapAuthor(cfg.hideIWADAuthor); + char const *author = P_MapAuthor(0/*current map*/, cfg.hideIWADAuthor); return author != 0 && (actualMapTime <= 6 * TICSPERSEC); } @@ -1501,8 +1501,8 @@ int Hu_MapTitleHeight(void) void Hu_DrawMapTitle(float alpha, dd_bool mapIdInsteadOfAuthor) { - char const *title = P_CurrentMapTitle(); - char const *author = P_CurrentMapAuthor(cfg.hideIWADAuthor); + char const *title = P_MapTitle(0/*current map*/); + char const *author = P_MapAuthor(0/*current map*/, cfg.hideIWADAuthor); float y = 0; @@ -1530,15 +1530,13 @@ void Hu_DrawMapTitle(float alpha, dd_bool mapIdInsteadOfAuthor) if(mapIdInsteadOfAuthor) { - Uri *mapUri = G_CurrentMapUri(); FR_SetFont(FID(GF_FONTA)); #if defined(__JHERETIC__) || defined(__JHEXEN__) FR_SetColorAndAlpha(.85f, .85f, .85f, alpha); #else FR_SetColorAndAlpha(.6f, .6f, .6f, alpha); #endif - FR_DrawTextXY3(Str_Text(Uri_ToString(mapUri)), 0, y, ALIGN_TOP, DTF_ONLY_SHADOW); - Uri_Delete(mapUri); + FR_DrawTextXY3(Str_Text(Uri_ToString(gameMapUri)), 0, y, ALIGN_TOP, DTF_ONLY_SHADOW); } else if(author) { diff --git a/doomsday/plugins/common/src/p_mapsetup.cpp b/doomsday/plugins/common/src/p_mapsetup.cpp index ac96d6b3b3..989f08b074 100644 --- a/doomsday/plugins/common/src/p_mapsetup.cpp +++ b/doomsday/plugins/common/src/p_mapsetup.cpp @@ -1044,7 +1044,8 @@ static void P_ResetWorldState() char const *P_MapTitle(Uri const *mapUri) { - DENG_ASSERT(mapUri != 0); + if(!mapUri) mapUri = gameMapUri; + char const *title = 0; // Perhaps a MapInfo definition exists for the map? @@ -1095,16 +1096,16 @@ char const *P_MapTitle(Uri const *mapUri) char const *P_MapAuthor(Uri const *mapUri, dd_bool supressGameAuthor) { - char const *author = 0; - - AutoStr *path = mapUri? Uri_Resolved(mapUri) : 0; + if(!mapUri) mapUri = gameMapUri; + AutoStr *path = Uri_Resolved(mapUri); if(!path || Str_IsEmpty(path)) return 0; // Perhaps a MapInfo definition exists for the map? ddmapinfo_t mapInfo; - if(Def_Get(DD_DEF_MAP_INFO, Str_Text(Uri_Compose(mapUri)), &mapInfo)) + char const *author = 0; + if(Def_Get(DD_DEF_MAP_INFO, Str_Text(path), &mapInfo)) { author = mapInfo.author; } @@ -1125,22 +1126,6 @@ char const *P_MapAuthor(Uri const *mapUri, dd_bool supressGameAuthor) return author; } -char const *P_CurrentMapTitle() -{ - Uri *mapUri = G_CurrentMapUri(); - char const *title = P_MapTitle(mapUri); - Uri_Delete(mapUri); - return title; -} - -char const *P_CurrentMapAuthor(dd_bool supressGameAuthor) -{ - Uri *mapUri = G_CurrentMapUri(); - char const *author = P_MapAuthor(mapUri, supressGameAuthor); - Uri_Delete(mapUri); - return author; -} - patchid_t P_MapTitlePatch(uint episode, uint map) { #if __JDOOM__ || __JDOOM64__ diff --git a/doomsday/plugins/common/src/p_saveg.cpp b/doomsday/plugins/common/src/p_saveg.cpp index a6f0fe2ff1..39c4f00f97 100644 --- a/doomsday/plugins/common/src/p_saveg.cpp +++ b/doomsday/plugins/common/src/p_saveg.cpp @@ -3689,7 +3689,7 @@ static int SV_LoadState(Str const *path, SaveInfo *info) * Load the map and configure some game settings. */ briefDisabled = true; - G_NewGame(info->episode(), info->map(), 0/*not saved??*/, &info->gameRules()); + G_NewGame(info->mapUri(), 0/*not saved??*/, &info->gameRules()); #if !__JHEXEN__ mapTime = info->mapTime(); @@ -4000,9 +4000,9 @@ void SV_LoadGameClient(uint gameId) } // Do we need to change the map? - if(gameMap != saveInfo->map() || gameEpisode != saveInfo->episode()) + if(!Uri_Equality(gameMapUri, saveInfo->mapUri())) { - G_NewGame(saveInfo->episode(), saveInfo->map(), 0/*default*/, &saveInfo->gameRules()); + G_NewGame(saveInfo->mapUri(), 0/*default*/, &saveInfo->gameRules()); /// @todo Necessary? G_SetGameAction(GA_NONE); } diff --git a/doomsday/plugins/common/src/p_sound.cpp b/doomsday/plugins/common/src/p_sound.cpp index eaff6e6ae0..3ea829702f 100644 --- a/doomsday/plugins/common/src/p_sound.cpp +++ b/doomsday/plugins/common/src/p_sound.cpp @@ -32,7 +32,7 @@ void S_MapMusic(Uri const *mapUri) { - DENG_ASSERT(mapUri != 0); + if(!mapUri) mapUri = gameMapUri; #ifdef __JHEXEN__ mapinfo_t const *mapInfo = P_MapInfo(mapUri); diff --git a/doomsday/plugins/doom/include/g_game.h b/doomsday/plugins/doom/include/g_game.h index 92aac3ac9c..acb8c5598f 100644 --- a/doomsday/plugins/doom/include/g_game.h +++ b/doomsday/plugins/doom/include/g_game.h @@ -51,6 +51,7 @@ extern player_t players[MAXPLAYERS]; extern dd_bool gameInProgress; extern uint gameEpisode; extern uint gameMap; +extern Uri *gameMapUri; extern uint gameMapEntrance; extern GameRuleset gameRules; diff --git a/doomsday/plugins/doom/src/d_main.c b/doomsday/plugins/doom/src/d_main.c index 10b3777c48..cc0292b384 100644 --- a/doomsday/plugins/doom/src/d_main.c +++ b/doomsday/plugins/doom/src/d_main.c @@ -63,10 +63,6 @@ char* borderGraphics[] = { "BRDR_BL" // Bottom left. }; -static uint startEpisode; -static uint startMap; -static dd_bool autoStart; - /** * Get a 32-bit integer value. */ @@ -408,8 +404,9 @@ void D_PreInit(void) */ void D_PostInit(void) { - AutoStr* path; - Uri* uri; + dd_bool autoStart = false; + Uri *startMapUri = 0; + AutoStr *path; int p; /// @todo Kludge: Border background is different in DOOM2. @@ -433,9 +430,6 @@ void D_PostInit(void) // Get skill / episode / map from parms. gameRules.skill = /*startSkill =*/ SM_MEDIUM; - startEpisode = 0; - startMap = 0; - autoStart = false; if(CommandLine_Check("-altdeath")) cfg.netDeathmatch = 2; @@ -487,15 +481,17 @@ void D_PostInit(void) p = CommandLine_Check("-skill"); if(p && p < myargc - 1) { - gameRules.skill = CommandLine_At(p + 1)[0] - '1'; + int skillNumber = atoi(CommandLine_At(p + 1)); + gameRules.skill = (skillmode_t)(skillNumber > 0? skillNumber - 1 : skillNumber); autoStart = true; } p = CommandLine_Check("-episode"); if(p && p < myargc - 1) { - startEpisode = CommandLine_At(p + 1)[0] - '1'; - startMap = 0; + int episodeNumber = atoi(CommandLine_At(p + 1)); + + startMapUri = G_ComposeMapUri(episodeNumber > 0? episodeNumber - 1 : episodeNumber, 0); autoStart = true; } @@ -504,44 +500,47 @@ void D_PostInit(void) { if(gameModeBits & (GM_ANY_DOOM2|GM_DOOM_CHEX)) { - startMap = atoi(CommandLine_At(p + 1)) - 1; + int mapNumber = atoi(CommandLine_At(p + 1)); + + startMapUri = G_ComposeMapUri(0, mapNumber > 0? mapNumber - 1 : mapNumber); autoStart = true; } else if(p < myargc - 2) { - startEpisode = CommandLine_At(p + 1)[0] - '1'; - startMap = CommandLine_At(p + 2)[0] - '1'; + int episodeNumber = atoi(CommandLine_At(p + 1)); + int mapNumber = atoi(CommandLine_At(p + 2)); + + startMapUri = G_ComposeMapUri(episodeNumber > 0? episodeNumber - 1 : episodeNumber, + mapNumber > 0? mapNumber - 1 : mapNumber); autoStart = true; } } - // Are we autostarting? - if(autoStart) + if(!startMapUri) { - if(gameModeBits & (GM_ANY_DOOM2|GM_DOOM_CHEX)) - App_Log(DE2_LOG_NOTE, "Autostart in Map %d, Skill %d", startMap+1, gameRules.skill); - else - App_Log(DE2_LOG_NOTE, "Autostart in Episode %d, Map %d, Skill %d", startEpisode+1, startMap+1, gameRules.skill); + startMapUri = G_ComposeMapUri(0, 0); } - // Validate episode and map. - uri = G_ComposeMapUri((gameModeBits & (GM_DOOM|GM_DOOM_SHAREWARE|GM_DOOM_ULTIMATE))? startEpisode : 0, startMap); - path = Uri_Compose(uri); - if((autoStart || IS_NETGAME) && !P_MapExists(Str_Text(path))) + // Are we autostarting? + if(autoStart) { - startEpisode = 0; - startMap = 0; + App_Log(DE2_LOG_NOTE, "Autostart in Map %s, Skill %d", + F_PrettyPath(Str_Text(Uri_ToString(startMapUri))), + gameRules.skill); } - Uri_Delete(uri); - if(autoStart || IS_NETGAME) + // Validate episode and map. + path = Uri_Compose(startMapUri); + if((autoStart || IS_NETGAME) && P_MapExists(Str_Text(path))) { - G_DeferredNewGame(startEpisode, startMap, 0/*default*/, &gameRules); + G_DeferredNewGame(startMapUri, 0/*default*/, &gameRules); } else { G_StartTitle(); // Start up intro loop. } + + Uri_Delete(startMapUri); } void D_Shutdown(void) diff --git a/doomsday/plugins/doom/src/m_cheat.c b/doomsday/plugins/doom/src/m_cheat.c index bd19ac7f80..53bd9e156d 100644 --- a/doomsday/plugins/doom/src/m_cheat.c +++ b/doomsday/plugins/doom/src/m_cheat.c @@ -669,36 +669,37 @@ D_CMD(CheatWhere) player_t *plr = &players[CONSOLEPLAYER]; char textBuffer[256]; Sector *sector; - AutoStr *path, *mapPath; - Uri *uri, *mapUri; + mobj_t *plrMo; + Uri *matUri; - if(G_GameState() != GS_MAP || !plr->plr->mo) + if(G_GameState() != GS_MAP) return true; - mapUri = G_CurrentMapUri(); - mapPath = Uri_ToString(mapUri); + plrMo = plr->plr->mo; + if(!plrMo) return true; + sprintf(textBuffer, "MAP [%s] X:%g Y:%g Z:%g", - Str_Text(mapPath), plr->plr->mo->origin[VX], plr->plr->mo->origin[VY], - plr->plr->mo->origin[VZ]); + Str_Text(Uri_ToString(gameMapUri)), + plrMo->origin[VX], plrMo->origin[VY], plrMo->origin[VZ]); P_SetMessage(plr, LMF_NO_HIDE, textBuffer); - Uri_Delete(mapUri); // Also print some information to the console. App_Log(DE2_MAP_NOTE, "%s", textBuffer); - sector = Mobj_Sector(plr->plr->mo); - uri = Materials_ComposeUri(P_GetIntp(sector, DMU_FLOOR_MATERIAL)); - path = Uri_ToString(uri); - App_Log(DE2_MAP_MSG, "FloorZ:%g Material:%s", P_GetDoublep(sector, DMU_FLOOR_HEIGHT), Str_Text(path)); - Uri_Delete(uri); + sector = Mobj_Sector(plrMo); + + matUri = Materials_ComposeUri(P_GetIntp(sector, DMU_FLOOR_MATERIAL)); + App_Log(DE2_MAP_MSG, "FloorZ:%g Material:%s", + P_GetDoublep(sector, DMU_FLOOR_HEIGHT), Str_Text(Uri_ToString(matUri))); + Uri_Delete(matUri); - uri = Materials_ComposeUri(P_GetIntp(sector, DMU_CEILING_MATERIAL)); - path = Uri_ToString(uri); - App_Log(DE2_MAP_MSG, "CeilingZ:%g Material:%s", P_GetDoublep(sector, DMU_CEILING_HEIGHT), Str_Text(path)); - Uri_Delete(uri); + matUri = Materials_ComposeUri(P_GetIntp(sector, DMU_CEILING_MATERIAL)); + App_Log(DE2_MAP_MSG, "CeilingZ:%g Material:%s", + P_GetDoublep(sector, DMU_CEILING_HEIGHT), Str_Text(Uri_ToString(matUri))); + Uri_Delete(matUri); App_Log(DE2_MAP_MSG, "Player height:%g Player radius:%g", - plr->plr->mo->height, plr->plr->mo->radius); + plrMo->height, plrMo->radius); return true; } diff --git a/doomsday/plugins/doom/src/p_oldsvg.cpp b/doomsday/plugins/doom/src/p_oldsvg.cpp index f929cc3bb3..ad947bd74e 100644 --- a/doomsday/plugins/doom/src/p_oldsvg.cpp +++ b/doomsday/plugins/doom/src/p_oldsvg.cpp @@ -846,7 +846,7 @@ int SV_LoadState_Dm_v19(Str const *path, SaveInfo *info) briefDisabled = true; // Load a base map. - G_NewGame(info->episode(), info->map(), 0/*not saved??*/, &info->gameRules()); + G_NewGame(info->mapUri(), 0/*not saved??*/, &info->gameRules()); // Recreate map state. mapTime = info->mapTime(); diff --git a/doomsday/plugins/doom/src/wi_stuff.c b/doomsday/plugins/doom/src/wi_stuff.c index 231ec33f51..aec68cdf7e 100644 --- a/doomsday/plugins/doom/src/wi_stuff.c +++ b/doomsday/plugins/doom/src/wi_stuff.c @@ -275,7 +275,7 @@ static void drawFinishedTitle(void) else mapNum = (wbs->episode * 9) + wbs->currentMap; - mapTitle = P_CurrentMapTitle(); + mapTitle = P_MapTitle(0/*current map*/); DGL_Enable(DGL_TEXTURE_2D); DGL_Color4f(1, 1, 1, 1); diff --git a/doomsday/plugins/doom64/include/g_game.h b/doomsday/plugins/doom64/include/g_game.h index 0979b986a1..40d083a731 100644 --- a/doomsday/plugins/doom64/include/g_game.h +++ b/doomsday/plugins/doom64/include/g_game.h @@ -52,6 +52,7 @@ extern uint nextMap; extern dd_bool gameInProgress; extern uint gameEpisode; extern uint gameMap; +extern Uri *gameMapUri; extern uint gameMapEntrance; extern GameRuleset gameRules; diff --git a/doomsday/plugins/doom64/src/d_main.c b/doomsday/plugins/doom64/src/d_main.c index 4b24c0461b..5c953df16d 100644 --- a/doomsday/plugins/doom64/src/d_main.c +++ b/doomsday/plugins/doom64/src/d_main.c @@ -35,14 +35,6 @@ #include "p_map.h" int verbose; - -//dd_bool devParm; // checkparm of -devparm -//dd_bool noMonstersParm; // checkparm of -nomonsters -//dd_bool respawnParm; // checkparm of -respawn -//dd_bool fastParm; // checkparm of -fast -//dd_bool turboParm; // checkparm of -turbo -//dd_bool randomClassParm; // checkparm of -randclass - float turboMul; // Multiplier for turbo. gamemode_t gameMode; @@ -54,7 +46,7 @@ float const defFontRGB2[] = { .85f, 0, 0 }; // The patches used in drawing the view border. // Percent-encoded. -char* borderGraphics[] = { +char *borderGraphics[] = { "Flats:FTILEABC", // Background. "BRDR_T", // Top. "BRDR_R", // Right. @@ -66,10 +58,6 @@ char* borderGraphics[] = { "BRDR_BL" // Bottom left. }; -static uint startEpisode; -static uint startMap; -static dd_bool autoStart; - /** * Get a 32-bit integer value. */ @@ -325,8 +313,9 @@ void D_PreInit(void) */ void D_PostInit(void) { + dd_bool autoStart = false; + Uri *startMapUri = 0; AutoStr *path; - Uri *uri; int p; // Common post init routine. @@ -343,9 +332,6 @@ void D_PostInit(void) // Get skill / episode / map from parms. gameRules.skill = /*startSkill =*/ SM_MEDIUM; - startEpisode = 0; - startMap = 0; - autoStart = false; // Game mode specific settings // None. @@ -400,42 +386,45 @@ void D_PostInit(void) p = CommandLine_Check("-skill"); if(p && p < myargc - 1) { - gameRules.skill = CommandLine_At(p + 1)[0] - '1'; + int skillNumber = atoi(CommandLine_At(p + 1)); + gameRules.skill = (skillmode_t)(skillNumber > 0? skillNumber - 1 : skillNumber); autoStart = true; } p = CommandLine_Check("-warp"); if(p && p < myargc - 1) { - startMap = atoi(CommandLine_At(p + 1)) - '1'; + int mapNumber = atoi(CommandLine_At(p + 1)); + + startMapUri = G_ComposeMapUri(0, mapNumber > 0? mapNumber - 1 : mapNumber); autoStart = true; } - // Are we autostarting? - if(autoStart) + if(!startMapUri) { - App_Log(DE2_LOG_NOTE, "Warp to Episode %d, Map %d, Skill %d", startEpisode+1, - startMap+1, gameRules.skill); + startMapUri = G_ComposeMapUri(0, 0); } - // Validate episode and map. - uri = G_ComposeMapUri(0, startMap); - path = Uri_Compose(uri); - if((autoStart || IS_NETGAME) && !P_MapExists(Str_Text(path))) + // Are we autostarting? + if(autoStart) { - startEpisode = 0; - startMap = 0; + App_Log(DE2_LOG_NOTE, "Autostart in Map %s, Skill %d", + F_PrettyPath(Str_Text(Uri_ToString(startMapUri))), + gameRules.skill); } - Uri_Delete(uri); - if(autoStart || IS_NETGAME) + // Validate episode and map. + path = Uri_Compose(startMapUri); + if((autoStart || IS_NETGAME) && P_MapExists(Str_Text(path))) { - G_DeferredNewGame(startEpisode, startMap, 0/*default*/, &gameRules); + G_DeferredNewGame(startMapUri, 0/*default*/, &gameRules); } else { G_StartTitle(); // Start up intro loop. } + + Uri_Delete(startMapUri); } void D_Shutdown(void) diff --git a/doomsday/plugins/doom64/src/m_cheat.c b/doomsday/plugins/doom64/src/m_cheat.c index 5b2f0bf95a..bf1b626637 100644 --- a/doomsday/plugins/doom64/src/m_cheat.c +++ b/doomsday/plugins/doom64/src/m_cheat.c @@ -185,35 +185,39 @@ void printDebugInfo(player_t *plr) { char textBuffer[256]; Sector *sector; - AutoStr *path, *mapPath; - Uri *uri, *mapUri; + mobj_t *plrMo; + Uri *matUri; - if(G_GameState() != GS_MAP || !plr->plr->mo) + DENG_ASSERT(plr != 0); + + if(G_GameState() != GS_MAP) return; - mapUri = G_CurrentMapUri(); - mapPath = Uri_ToString(mapUri); + plrMo = plr->plr->mo; + if(!plrMo) return; + sprintf(textBuffer, "MAP [%s] X:%g Y:%g Z:%g", - Str_Text(mapPath), plr->plr->mo->origin[VX], plr->plr->mo->origin[VY], - plr->plr->mo->origin[VZ]); + Str_Text(Uri_ToString(gameMapUri)), + plrMo->origin[VX], plrMo->origin[VY], plrMo->origin[VZ]); P_SetMessage(plr, LMF_NO_HIDE, textBuffer); - Uri_Delete(mapUri); // Also print some information to the console. App_Log(DE2_MAP_NOTE, "%s", textBuffer); - sector = Mobj_Sector(plr->plr->mo); - uri = Materials_ComposeUri(P_GetIntp(sector, DMU_FLOOR_MATERIAL)); - path = Uri_ToString(uri); - App_Log(DE2_MAP_MSG, "FloorZ:%g Material:%s", P_GetDoublep(sector, DMU_FLOOR_HEIGHT), Str_Text(path)); - Uri_Delete(uri); + sector = Mobj_Sector(plrMo); + + matUri = Materials_ComposeUri(P_GetIntp(sector, DMU_FLOOR_MATERIAL)); + App_Log(DE2_MAP_MSG, "FloorZ:%g Material:%s", + P_GetDoublep(sector, DMU_FLOOR_HEIGHT), Str_Text(Uri_ToString(matUri))); + Uri_Delete(matUri); - uri = Materials_ComposeUri(P_GetIntp(sector, DMU_CEILING_MATERIAL)); - path = Uri_ToString(uri); - App_Log(DE2_MAP_MSG, "CeilingZ:%g Material:%s", P_GetDoublep(sector, DMU_CEILING_HEIGHT), Str_Text(path)); - Uri_Delete(uri); + matUri = Materials_ComposeUri(P_GetIntp(sector, DMU_CEILING_MATERIAL)); + App_Log(DE2_MAP_MSG, "CeilingZ:%g Material:%s", + P_GetDoublep(sector, DMU_CEILING_HEIGHT), Str_Text(Uri_ToString(matUri))); + Uri_Delete(matUri); - App_Log(DE2_MAP_MSG, "Player height:%g Player radius:%g", plr->plr->mo->height, plr->plr->mo->radius); + App_Log(DE2_MAP_MSG, "Player height:%g Player radius:%g", + plrMo->height, plrMo->radius); } /** diff --git a/doomsday/plugins/doom64/src/wi_stuff.c b/doomsday/plugins/doom64/src/wi_stuff.c index 965037937a..baf7192b3c 100644 --- a/doomsday/plugins/doom64/src/wi_stuff.c +++ b/doomsday/plugins/doom64/src/wi_stuff.c @@ -122,7 +122,7 @@ static void drawFinishedTitle(void) { int x = SCREENWIDTH/2, y = WI_TITLEY; uint mapNum = wbs->currentMap; - char const *mapTitle = P_CurrentMapTitle(); + char const *mapTitle = P_MapTitle(0/*current map*/); patchid_t patchId; patchinfo_t info; diff --git a/doomsday/plugins/heretic/include/g_game.h b/doomsday/plugins/heretic/include/g_game.h index 6be1ac8f61..7c267e151b 100644 --- a/doomsday/plugins/heretic/include/g_game.h +++ b/doomsday/plugins/heretic/include/g_game.h @@ -51,6 +51,7 @@ extern player_t players[MAXPLAYERS]; extern dd_bool gameInProgress; extern uint gameEpisode; extern uint gameMap; +extern Uri *gameMapUri; extern uint gameMapEntrance; extern GameRuleset gameRules; diff --git a/doomsday/plugins/heretic/src/h_main.c b/doomsday/plugins/heretic/src/h_main.c index a26009b98a..a4aca3abe4 100644 --- a/doomsday/plugins/heretic/src/h_main.c +++ b/doomsday/plugins/heretic/src/h_main.c @@ -65,10 +65,6 @@ char* borderGraphics[] = { "BORDBL" // Bottom left. }; -static uint startEpisode; -static uint startMap; -static dd_bool autoStart; - /** * Get a 32-bit integer value. */ @@ -344,8 +340,9 @@ void H_PreInit(void) */ void H_PostInit(void) { - AutoStr* path; - Uri* uri; + dd_bool autoStart = false; + Uri *startMapUri = 0; + AutoStr *path; int p; /// @todo Kludge: Shareware WAD has different border background. @@ -366,9 +363,6 @@ void H_PostInit(void) // Defaults for skill, episode and map. gameRules.skill = /*startSkill =*/ SM_MEDIUM; - startEpisode = 0; - startMap = 0; - autoStart = false; // Game mode specific settings. /* None */ @@ -415,51 +409,56 @@ void H_PostInit(void) p = CommandLine_Check("-skill"); if(p && p < myargc - 1) { - gameRules.skill = CommandLine_At(p + 1)[0] - '1'; + int skillNumber = atoi(CommandLine_At(p + 1)); + gameRules.skill = (skillmode_t)(skillNumber > 0? skillNumber - 1 : skillNumber); autoStart = true; } p = CommandLine_Check("-episode"); if(p && p < myargc - 1) { - startEpisode = CommandLine_At(p + 1)[0] - '1'; - startMap = 0; + int episodeNumber = atoi(CommandLine_At(p + 1)); + + startMapUri = G_ComposeMapUri(episodeNumber > 0? episodeNumber - 1 : episodeNumber, 0); autoStart = true; } p = CommandLine_Check("-warp"); if(p && p < myargc - 2) { - startEpisode = CommandLine_At(p + 1)[0] - '1'; - startMap = CommandLine_At(p + 2)[0] - '1'; + int episodeNumber = atoi(CommandLine_At(p + 1)); + int mapNumber = atoi(CommandLine_At(p + 2)); + + startMapUri = G_ComposeMapUri(episodeNumber > 0? episodeNumber - 1 : episodeNumber, + mapNumber > 0? mapNumber - 1 : mapNumber); autoStart = true; } - // Are we autostarting? - if(autoStart) + if(!startMapUri) { - App_Log(DE2_LOG_NOTE, "Autostart in Episode %d, Map %d, Skill %d", - startEpisode + 1, startMap + 1, gameRules.skill + 1); + startMapUri = G_ComposeMapUri(0, 0); } - // Validate episode and map. - uri = G_ComposeMapUri(startEpisode, startMap); - path = Uri_Compose(uri); - if((autoStart || IS_NETGAME) && !P_MapExists(Str_Text(path))) + // Are we autostarting? + if(autoStart) { - startEpisode = 0; - startMap = 0; + App_Log(DE2_LOG_NOTE, "Autostart in Map %s, Skill %d", + F_PrettyPath(Str_Text(Uri_ToString(startMapUri))), + gameRules.skill); } - Uri_Delete(uri); - if(autoStart || IS_NETGAME) + // Validate episode and map. + path = Uri_Compose(startMapUri); + if((autoStart || IS_NETGAME) && P_MapExists(Str_Text(path))) { - G_DeferredNewGame(startEpisode, startMap, 0/*default*/, &gameRules); + G_DeferredNewGame(startMapUri, 0/*default*/, &gameRules); } else { G_StartTitle(); // Start up intro loop. } + + Uri_Delete(startMapUri); } void H_Shutdown(void) diff --git a/doomsday/plugins/heretic/src/m_cheat.c b/doomsday/plugins/heretic/src/m_cheat.c index 3c0f3f8f8d..5dadeccfb5 100644 --- a/doomsday/plugins/heretic/src/m_cheat.c +++ b/doomsday/plugins/heretic/src/m_cheat.c @@ -670,35 +670,37 @@ D_CMD(CheatWhere) player_t *plr = &players[CONSOLEPLAYER]; char textBuffer[256]; Sector *sector; - AutoStr *path, *mapPath; - Uri *uri, *mapUri; + mobj_t *plrMo; + Uri *matUri; - if(G_GameState() != GS_MAP || !plr->plr->mo) + if(G_GameState() != GS_MAP) return true; - mapUri = G_CurrentMapUri(); - mapPath = Uri_ToString(mapUri); + plrMo = plr->plr->mo; + if(!plrMo) return true; + sprintf(textBuffer, "MAP [%s] X:%g Y:%g Z:%g", - Str_Text(mapPath), plr->plr->mo->origin[VX], plr->plr->mo->origin[VY], - plr->plr->mo->origin[VZ]); + Str_Text(Uri_ToString(gameMapUri)), + plrMo->origin[VX], plrMo->origin[VY], plrMo->origin[VZ]); P_SetMessage(plr, LMF_NO_HIDE, textBuffer); - Uri_Delete(mapUri); - App_Log(DE2_MAP_NOTE, textBuffer); + // Also print some information to the console. + App_Log(DE2_MAP_NOTE, "%s", textBuffer); + + sector = Mobj_Sector(plrMo); - sector = Mobj_Sector(plr->plr->mo); - uri = Materials_ComposeUri(P_GetIntp(sector, DMU_FLOOR_MATERIAL)); - path = Uri_ToString(uri); - App_Log(DE2_MAP_MSG, "FloorZ:%g Material:%s", P_GetDoublep(sector, DMU_FLOOR_HEIGHT), Str_Text(path)); - Uri_Delete(uri); + matUri = Materials_ComposeUri(P_GetIntp(sector, DMU_FLOOR_MATERIAL)); + App_Log(DE2_MAP_MSG, "FloorZ:%g Material:%s", + P_GetDoublep(sector, DMU_FLOOR_HEIGHT), Str_Text(Uri_ToString(matUri))); + Uri_Delete(matUri); - uri = Materials_ComposeUri(P_GetIntp(sector, DMU_CEILING_MATERIAL)); - path = Uri_ToString(uri); - App_Log(DE2_MAP_MSG, "CeilingZ:%g Material:%s", P_GetDoublep(sector, DMU_CEILING_HEIGHT), Str_Text(path)); - Uri_Delete(uri); + matUri = Materials_ComposeUri(P_GetIntp(sector, DMU_CEILING_MATERIAL)); + App_Log(DE2_MAP_MSG, "CeilingZ:%g Material:%s", + P_GetDoublep(sector, DMU_CEILING_HEIGHT), Str_Text(Uri_ToString(matUri))); + Uri_Delete(matUri); App_Log(DE2_MAP_MSG, "Player height:%g Player radius:%g", - plr->plr->mo->height, plr->plr->mo->radius); + plrMo->height, plrMo->radius); return true; } diff --git a/doomsday/plugins/heretic/src/p_oldsvg.cpp b/doomsday/plugins/heretic/src/p_oldsvg.cpp index 64e0fa430f..01c2c7b9c4 100644 --- a/doomsday/plugins/heretic/src/p_oldsvg.cpp +++ b/doomsday/plugins/heretic/src/p_oldsvg.cpp @@ -866,7 +866,7 @@ int SV_LoadState_Hr_v13(Str const *path, SaveInfo *info) briefDisabled = true; // Load a base map. - G_NewGame(info->episode(), info->map(), 0/*not saved??*/, &info->gameRules()); + G_NewGame(info->mapUri(), 0/*not saved??*/, &info->gameRules()); // Recreate map state. mapTime = info->mapTime(); diff --git a/doomsday/plugins/hexen/include/g_game.h b/doomsday/plugins/hexen/include/g_game.h index 9917f93d2a..cd05d4a6ec 100644 --- a/doomsday/plugins/hexen/include/g_game.h +++ b/doomsday/plugins/hexen/include/g_game.h @@ -48,6 +48,7 @@ extern player_t players[MAXPLAYERS]; extern dd_bool gameInProgress; extern uint gameEpisode; extern uint gameMap; +extern Uri *gameMapUri; extern uint gameMapEntrance; extern GameRuleset gameRules; diff --git a/doomsday/plugins/hexen/include/p_mapinfo.h b/doomsday/plugins/hexen/include/p_mapinfo.h index c505df945c..5ac78a6fef 100644 --- a/doomsday/plugins/hexen/include/p_mapinfo.h +++ b/doomsday/plugins/hexen/include/p_mapinfo.h @@ -59,6 +59,11 @@ void MapInfoParser(Str const *path); */ mapinfo_t *P_MapInfo(Uri const *mapUri); +/** + * Returns MAPINFO data for the @em current map. + */ +mapinfo_t *P_CurrentMapInfo(void); + #define P_INVALID_LOGICAL_MAP 0xffffffff /** diff --git a/doomsday/plugins/hexen/src/acscript.cpp b/doomsday/plugins/hexen/src/acscript.cpp index d44e3322e2..9aca450da3 100644 --- a/doomsday/plugins/hexen/src/acscript.cpp +++ b/doomsday/plugins/hexen/src/acscript.cpp @@ -257,19 +257,16 @@ bool ACScriptInterpreter::startScript(int scriptNumber, Uri const *mapUri, byte const args[], mobj_t *activator, Line *line, int side) { DENG_ASSERT(!IS_CLIENT); + DENG_ASSERT(mapUri != 0); if(mapUri) { - Uri *currentMapUri = G_CurrentMapUri(); - if(!Uri_Equality(mapUri, currentMapUri)) + if(!Uri_Equality(gameMapUri, mapUri)) { - Uri_Delete(currentMapUri); - // Script is not for the current map. // Add it to the store to be started when that map is next entered. return newDeferredTask(mapUri, scriptNumber, args); } - Uri_Delete(currentMapUri); } if(BytecodeScriptInfo *info = scriptInfoPtr(scriptNumber)) diff --git a/doomsday/plugins/hexen/src/h2_main.c b/doomsday/plugins/hexen/src/h2_main.c index f7223ff917..5390ab3dfa 100644 --- a/doomsday/plugins/hexen/src/h2_main.c +++ b/doomsday/plugins/hexen/src/h2_main.c @@ -38,13 +38,6 @@ int verbose; -//dd_bool devParm; // checkparm of -devparm -//dd_bool noMonstersParm; // checkparm of -nomonsters -//dd_bool respawnParm; // checkparm of -respawn -//dd_bool fastParm; // checkparm of -fast -//dd_bool turboParm; // checkparm of -turbo -//dd_bool randomClassParm; // checkparm of -randclass - float turboMul; // Multiplier for turbo. gamemode_t gameMode; @@ -57,7 +50,7 @@ float const defFontRGB3[] = { .9f, .9f, .9f }; // The patches used in drawing the view border. // Percent-encoded. -char* borderGraphics[] = { +char *borderGraphics[] = { "Flats:F_022", // Background. "BORDT", // Top. "BORDR", // Right. @@ -69,11 +62,6 @@ char* borderGraphics[] = { "BORDBL" // Bottom left. }; -static dd_bool autoStart; -static uint startEpisode; -static uint startMap; -static playerclass_t startPlayerClass; - /** * Get a 32-bit integer value. */ @@ -318,9 +306,11 @@ void X_PreInit(void) */ void X_PostInit(void) { + dd_bool autoStart = false; + Uri *startMapUri = 0; + playerclass_t startPlayerClass = PCLASS_NONE; AutoStr *path; - int p, warpMap; - Uri *uri; + int p; // Do this early as other systems need to know. P_InitPlayerClassInfo(); @@ -336,10 +326,6 @@ void X_PostInit(void) // Defaults for skill, episode and map. gameRules.skill = /*startSkill =*/ SM_MEDIUM; - startEpisode = 0; - startMap = 0; - startPlayerClass = PCLASS_NONE; - autoStart = false; // Game mode specific settings. /* None */ @@ -395,7 +381,8 @@ void X_PostInit(void) if((p = CommandLine_CheckWith("-skill", 1)) != 0) { - gameRules.skill = (skillmode_t)(CommandLine_At(p + 1)[0] - '1'); + int skillNumber = atoi(CommandLine_At(p + 1)); + gameRules.skill = (skillmode_t)(skillNumber > 0? skillNumber - 1 : skillNumber); autoStart = true; } @@ -427,40 +414,38 @@ void X_PostInit(void) p = CommandLine_Check("-warp"); if(p && p < CommandLine_Count() - 1) { - warpMap = atoi(CommandLine_At(p + 1)) - 1; - startMap = P_TranslateMap(warpMap); + int warpMap = atoi(CommandLine_At(p + 1)); + + startMapUri = G_ComposeMapUri(0, P_TranslateMap(warpMap - 1)); autoStart = true; } - else + + if(!startMapUri) { - warpMap = 0; - startMap = P_TranslateMap(warpMap); + startMapUri = G_ComposeMapUri(0, P_TranslateMap(0)); } // Are we autostarting? if(autoStart) { - App_Log(DE2_LOG_NOTE, "Autostart in Map %d (%d), Skill %d", warpMap+1, startMap+1, gameRules.skill + 1); + App_Log(DE2_LOG_NOTE, "Autostart in Map %s, Skill %d", + F_PrettyPath(Str_Text(Uri_ToString(startMapUri))), + gameRules.skill); } // Validate episode and map. - uri = G_ComposeMapUri(0, startMap); - path = Uri_Compose(uri); - if((autoStart || IS_NETGAME) && !P_MapExists(Str_Text(path))) + path = Uri_Compose(startMapUri); + if((autoStart || IS_NETGAME) && P_MapExists(Str_Text(path))) { - startMap = 0; - } - Uri_Delete(uri); - - if(autoStart || IS_NETGAME) - { - G_DeferredNewGame(startEpisode, startMap, 0/*default*/, &gameRules); + G_DeferredNewGame(startMapUri, 0/*default*/, &gameRules); } else { // Start up intro loop. G_StartTitle(); } + + Uri_Delete(startMapUri); } void X_Shutdown(void) diff --git a/doomsday/plugins/hexen/src/m_cheat.c b/doomsday/plugins/hexen/src/m_cheat.c index 949fc16b35..076d5341fd 100644 --- a/doomsday/plugins/hexen/src/m_cheat.c +++ b/doomsday/plugins/hexen/src/m_cheat.c @@ -670,36 +670,37 @@ D_CMD(CheatWhere) player_t *plr = &players[CONSOLEPLAYER]; char textBuffer[256]; Sector *sector; - AutoStr *path, *mapPath; - Uri *uri, *mapUri; + mobj_t *plrMo; + Uri *matUri; - if(G_GameState() != GS_MAP || !plr->plr->mo) + if(G_GameState() != GS_MAP) return true; - mapUri = G_CurrentMapUri(); - mapPath = Uri_ToString(mapUri); - sprintf(textBuffer, "Map [%s] x:%g y:%g z:%g", - Str_Text(mapPath), plr->plr->mo->origin[VX], plr->plr->mo->origin[VY], - plr->plr->mo->origin[VZ]); + plrMo = plr->plr->mo; + if(!plrMo) return true; + + sprintf(textBuffer, "MAP [%s] X:%g Y:%g Z:%g", + Str_Text(Uri_ToString(gameMapUri)), + plrMo->origin[VX], plrMo->origin[VY], plrMo->origin[VZ]); P_SetMessage(plr, LMF_NO_HIDE, textBuffer); - Uri_Delete(mapUri); // Also print some information to the console. App_Log(DE2_MAP_NOTE, "%s", textBuffer); - sector = Mobj_Sector(plr->plr->mo); - uri = Materials_ComposeUri(P_GetIntp(sector, DMU_FLOOR_MATERIAL)); - path = Uri_ToString(uri); - App_Log(DE2_MAP_MSG, "FloorZ:%g Material:%s", P_GetDoublep(sector, DMU_FLOOR_HEIGHT), Str_Text(path)); - Uri_Delete(uri); + sector = Mobj_Sector(plrMo); + + matUri = Materials_ComposeUri(P_GetIntp(sector, DMU_FLOOR_MATERIAL)); + App_Log(DE2_MAP_MSG, "FloorZ:%g Material:%s", + P_GetDoublep(sector, DMU_FLOOR_HEIGHT), Str_Text(Uri_ToString(matUri))); + Uri_Delete(matUri); - uri = Materials_ComposeUri(P_GetIntp(sector, DMU_CEILING_MATERIAL)); - path = Uri_ToString(uri); - App_Log(DE2_MAP_MSG, "CeilingZ:%g Material:%s", P_GetDoublep(sector, DMU_CEILING_HEIGHT), Str_Text(path)); - Uri_Delete(uri); + matUri = Materials_ComposeUri(P_GetIntp(sector, DMU_CEILING_MATERIAL)); + App_Log(DE2_MAP_MSG, "CeilingZ:%g Material:%s", + P_GetDoublep(sector, DMU_CEILING_HEIGHT), Str_Text(Uri_ToString(matUri))); + Uri_Delete(matUri); App_Log(DE2_MAP_MSG, "Player height:%g Player radius:%g", - plr->plr->mo->height, plr->plr->mo->radius); + plrMo->height, plrMo->radius); return true; } diff --git a/doomsday/plugins/hexen/src/p_mapinfo.cpp b/doomsday/plugins/hexen/src/p_mapinfo.cpp index 0e3e9a2e2d..ba8e20b9ca 100644 --- a/doomsday/plugins/hexen/src/p_mapinfo.cpp +++ b/doomsday/plugins/hexen/src/p_mapinfo.cpp @@ -255,6 +255,11 @@ mapinfo_t *P_MapInfo(Uri const *mapUri) return 0; } +mapinfo_t *P_CurrentMapInfo() +{ + return P_MapInfo(gameMapUri); +} + uint P_TranslateMapIfExists(uint map) { uint matchedWithoutCluster = P_INVALID_LOGICAL_MAP; diff --git a/doomsday/plugins/hexen/src/p_spec.c b/doomsday/plugins/hexen/src/p_spec.c index f226490bf4..3acb99af12 100644 --- a/doomsday/plugins/hexen/src/p_spec.c +++ b/doomsday/plugins/hexen/src/p_spec.c @@ -1072,9 +1072,7 @@ void P_ForceLightning(void) void P_InitLightning(void) { int i, secCount; - Uri *mapUri = G_CurrentMapUri(); - mapinfo_t const *mapInfo = P_MapInfo(mapUri); - Uri_Delete(mapUri); + mapinfo_t const *mapInfo = P_CurrentMapInfo(); if(!mapInfo || !mapInfo->lightning) {