Skip to content

Commit

Permalink
libcommon: Translate MAPINFO, episode 'startMap' numbers to URIs
Browse files Browse the repository at this point in the history
Once all the definitions have been read, translate any Hexen warp
trans numbers used when referencing the starting map of an episode.
  • Loading branch information
danij-deng committed Jul 26, 2014
1 parent c9099bb commit 7b5c79f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion doomsday/plugins/common/include/mapinfo.h
Expand Up @@ -103,7 +103,7 @@ struct HexDefs

/**
* To be called once all definitions have been parsed to translate Hexen's
* map "warp numbers" to URIs where they used as map definition references.
* map "warp numbers" to URIs where used as map definition references.
*/
void translateMapWarpNumbers();

Expand Down
11 changes: 10 additions & 1 deletion doomsday/plugins/common/src/mapinfo.cpp
Expand Up @@ -1133,6 +1133,15 @@ de::Uri HexDefs::translateMapWarpNumber(uint map)

void HexDefs::translateMapWarpNumbers()
{
for(HexDefs::EpisodeInfos::iterator i = hexDefs.episodeInfos.begin(); i != hexDefs.episodeInfos.end(); ++i)
{
EpisodeInfo &info = i->second;
de::Uri startMap(info.gets("startMap", ""), RC_NULL);
if(!startMap.scheme().compareWithoutCase("@wt"))
{
info.set("startMap", translateMapWarpNumber(startMap.path().toStringRef().toInt()).compose());
}
}
for(HexDefs::MapInfos::iterator i = hexDefs.mapInfos.begin(); i != hexDefs.mapInfos.end(); ++i)
{
MapInfo &info = i->second;
Expand All @@ -1151,7 +1160,7 @@ EpisodeInfo *P_EpisodeInfo(String id)

EpisodeInfo *P_CurrentEpisodeInfo()
{
return hexDefs.getEpisodeInfo(String::number(::gameEpisode));
return hexDefs.getEpisodeInfo(String::number(::gameEpisode + 1));
}

MapInfo *P_MapInfo(de::Uri const &mapUri)
Expand Down
8 changes: 6 additions & 2 deletions doomsday/plugins/common/src/p_start.cpp
Expand Up @@ -261,7 +261,7 @@ static void readMapInfoDefinitions()
// MAPINFO in the Hexen IWAD contains a bunch of broken definitions.
// As later map definitions now replace earlier ones, these broken defs
// override the earlier "good" defs. For now we'll kludge around this
// issue by patching the effected defs with the expected values.
// issue by patching the affected defs with the expected values.
if(!sourceIsCustom && (gameModeBits & (GM_HEXEN|GM_HEXEN_V10)))
{
MapInfo *info = hexDefs.getMapInfo(de::Uri("Maps:MAP07", RC_NULL));
Expand Down Expand Up @@ -384,10 +384,14 @@ static void readMapInfoDefinitions()
info.set("menuHelpInfo", composeNotDesignedForMessage(GET_TXT(TXT_SINGLEPLAYER)));
}
}
#else // __JHEXEN__ || __JDOOM64__
#elif __JDOOM64__
// A single implicit episode.
EpisodeInfo &info = hexDefs.episodeInfos["1"];
info.set("startMap", "Maps:MAP01");
#elif __JHEXEN__
// A single implicit episode.
EpisodeInfo &info = hexDefs.episodeInfos["1"];
info.set("startMap", "@wt:0");
#endif

// Translate internal "warp trans" numbers to URIs.
Expand Down

0 comments on commit 7b5c79f

Please sign in to comment.