Skip to content

Commit

Permalink
Refactor: Don't "zero-base shift" Hexen "warp numbers"
Browse files Browse the repository at this point in the history
It serves no useful purpose to shift the warp numbers so leave them
as they are.
  • Loading branch information
danij-deng committed Jul 29, 2014
1 parent 4c5d2e2 commit 447ed93
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 15 deletions.
9 changes: 5 additions & 4 deletions doomsday/plugins/common/src/g_game.cpp
Expand Up @@ -1196,7 +1196,7 @@ static void printMapBanner()
String text = String("Map: ") + gameMapUri.path().asText();
#if __JHEXEN__
Record const *mapInfo = COMMON_GAMESESSION->mapInfo();
text += String(" (%1)").arg(mapInfo? mapInfo->geti("warpTrans") + 1 : 0);
text += String(" (%1)").arg(mapInfo? mapInfo->geti("warpTrans") : 0);
#endif
text += String(" - " DE2_ESC(b)) + title;
App_Log(DE2_LOG_NOTE, "%s", text.toUtf8().constData());
Expand Down Expand Up @@ -3248,15 +3248,16 @@ D_CMD(WarpMap)
map = de::max(0, number % 10);
}
#endif
// Internally epsiode and map numbers are zero-based.
if(epsd != 0) epsd -= 1;
if(map != 0) map -= 1;

#if __JHEXEN__
// Hexen map numbers require translation.
/// @todo fixme: What about the episode?
newMapUri = P_TranslateMap(map);
#else
// Internally epsiode and map numbers are zero-based.
if(epsd != 0) epsd -= 1;
if(map != 0) map -= 1;

// Compose a map URI for the given episode and map pair using the default
// format specific to the game (and mode).
newMapUri = G_ComposeMapUri(epsd, map);
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/hexen/defs/hexen/episodes.ded
Expand Up @@ -5,5 +5,5 @@ Header { Version = 6; }

Episode {
Id = "1";
Start Map = "@wt:0";
Start Map = "@wt:1";
}
4 changes: 2 additions & 2 deletions doomsday/plugins/hexen/src/h2_main.cpp
Expand Up @@ -415,13 +415,13 @@ void X_PostInit()
}
else
{
startMapUri = P_TranslateMap(mapNumber - 1);
startMapUri = P_TranslateMap(mapNumber);
}
}

if(startMapUri.path().isEmpty())
{
startMapUri = P_TranslateMap(0);
startMapUri = P_TranslateMap(1);
}

// Are we autostarting?
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/idtech1converter/src/idtech1converter.cpp
Expand Up @@ -109,7 +109,7 @@ void ConvertMapInfo()
if(!sourceIsCustom && (gameModeBits & (GM_HEXEN|GM_HEXEN_V10)))
{
MapInfo *info = hexDefs.getMapInfo(de::Uri("Maps:MAP07", RC_NULL));
info->set("warpTrans", "@wt:6");
info->set("warpTrans", "@wt:7");
}
#endif
}
Expand Down
11 changes: 4 additions & 7 deletions doomsday/plugins/idtech1converter/src/mapinfotranslator.cpp
Expand Up @@ -397,11 +397,7 @@ DENG2_PIMPL(MapInfoParser)
}
else
{
if(mapNumber < 1)
{
throw ParseError(String("Invalid map number '%1' on line #%2").arg(mapNumber).arg(lexer.lineNumber()));
}
mapInfo.set((isSecret? "secretNextMap" : "nextMap"), String("@wt:%1").arg(mapNumber - 1));
mapInfo.set((isSecret? "secretNextMap" : "nextMap"), String("@wt:%1").arg(mapNumber));
}
}

Expand Down Expand Up @@ -449,7 +445,8 @@ DENG2_PIMPL(MapInfoParser)
info->set("map", mapUri.compose());

// Attempt to extract the "warp translation" number.
info->set("warpTrans", mapNumberFor(mapUri));
uint mapWarpNumber = mapNumberFor(mapUri);
info->set("warpTrans", mapWarpNumber != 0? mapWarpNumber + 1 : 0);
}

// Map title must follow the number.
Expand Down Expand Up @@ -870,7 +867,7 @@ DENG2_PIMPL(MapInfoParser)
{
throw ParseError(String("Invalid map warp-number '%1' on line #%2").arg(Str_Text(lexer.token())).arg(lexer.lineNumber()));
}
info->set("warpTrans", mapWarpNum - 1);
info->set("warpTrans", mapWarpNum);
continue;
}

Expand Down

0 comments on commit 447ed93

Please sign in to comment.