Skip to content

Commit

Permalink
Hexen|SndInfoParser: Fix patching of MAPINFO (lump) definitions with …
Browse files Browse the repository at this point in the history
…SNDINFO-read values

(The only time a mapinfo_t is modified outside of MapInfoParser).
  • Loading branch information
danij-deng committed Jan 25, 2014
1 parent 479ce9b commit 933c905
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 20 deletions.
1 change: 0 additions & 1 deletion doomsday/plugins/common/include/hexlex.h
Expand Up @@ -78,7 +78,6 @@ class HexLex
int readNumber();

int readSoundIndex();
uint readMapNumber();
Uri *readUri(char const *defaultScheme = "");

/**
Expand Down
3 changes: 3 additions & 0 deletions doomsday/plugins/common/include/p_sound.h
Expand Up @@ -63,6 +63,9 @@ int S_GetSoundID(char const *name);

/**
* Attempt to parse the script on the identified @a path as "sound definition" data.
*
* Important: This should never be called @em before MapInfoParser, as this may need
* to patch those definitions...
*/
void SndInfoParser(Str const *path);
#endif
Expand Down
4 changes: 2 additions & 2 deletions doomsday/plugins/common/src/g_game.c
Expand Up @@ -1157,7 +1157,7 @@ static void printMapBanner(void)
{
char buf[64];
#if __JHEXEN__
mapinfo_t *mapInfo = P_MapInfo(mapUri);
mapinfo_t const *mapInfo = P_MapInfo(mapUri);
int warpNum = (mapInfo? mapInfo->warpTrans : -1);
dd_snprintf(buf, 64, "Map %u (%u): " DE2_ESC(b) "%s", warpNum + 1, gameMap + 1, title);
#else
Expand Down Expand Up @@ -1265,7 +1265,7 @@ static void initFogForMap(ddmapinfo_t *mapInfo)
#if __JHEXEN__
{
Uri *mapUri = G_ComposeMapUri(gameEpisode, gameMap);
mapinfo_t *mapInfo = P_MapInfo(mapUri);
mapinfo_t const *mapInfo = P_MapInfo(mapUri);
if(mapInfo)
{
int fadeTable = mapInfo->fadeTable;
Expand Down
6 changes: 0 additions & 6 deletions doomsday/plugins/common/src/hexlex.cpp
Expand Up @@ -222,12 +222,6 @@ Uri *HexLex::readUri(char const *defaultScheme)
return uri;
}

uint HexLex::readMapNumber()
{
uint num = readNumber();
return num > 0? num - 1 : num;
}

int HexLex::readSoundIndex()
{
return Def_Get(DD_DEF_SOUND_BY_NAME, Str_Text(readString()), 0);
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/common/src/p_mapsetup.cpp
Expand Up @@ -1060,7 +1060,7 @@ char const *P_MapTitle(uint episode, uint map)
// In Hexen we can also look in MAPINFO for the map title.
if(!title)
{
if(mapinfo_t *mapInfo = P_MapInfo(mapUri))
if(mapinfo_t const *mapInfo = P_MapInfo(mapUri))
{
title = mapInfo->title;
}
Expand Down
14 changes: 9 additions & 5 deletions doomsday/plugins/common/src/p_sound.cpp
Expand Up @@ -26,6 +26,7 @@
#include "dmu_lib.h"
#include "hexlex.h"
#ifdef __JHEXEN__
# include "g_common.h"
# include "p_mapinfo.h"
#endif

Expand Down Expand Up @@ -121,15 +122,18 @@ void SndInfoParser(Str const *path)
{
// $map int(map-number) string(lump-name)
// Associate a music lump to a map.
Uri *mapUri = lexer.readUri();
int mapNumber = lexer.readNumber();
Str const *lumpName = lexer.readString();

if(mapinfo_t *mapInfo = P_MapInfo(mapUri))
if(mapNumber > 0)
{
strncpy(mapInfo->songLump, Str_Text(lumpName), sizeof(mapInfo->songLump));
Uri *mapUri = G_ComposeMapUri(0, mapNumber - 1);
if(mapinfo_t *mapInfo = P_MapInfo(mapUri))
{
strncpy(mapInfo->songLump, Str_Text(lumpName), sizeof(mapInfo->songLump));
}
Uri_Delete(mapUri);
}

Uri_Delete(mapUri);
continue;
}
if(!Str_CompareIgnoreCase(lexer.token(), "$registered")) // Unused.
Expand Down
4 changes: 2 additions & 2 deletions doomsday/plugins/hexen/include/p_mapinfo.h
Expand Up @@ -30,10 +30,10 @@

typedef struct mapinfo_s {
uint map; ///< Logical map number.
short cluster;
int cluster;
uint warpTrans;
uint nextMap;
short cdTrack;
int cdTrack;
char title[32];
materialid_t sky1Material;
materialid_t sky2Material;
Expand Down
3 changes: 1 addition & 2 deletions doomsday/plugins/hexen/src/p_mapinfo.cpp
Expand Up @@ -139,7 +139,7 @@ void MapInfoParser(Str const *path)
}
Uri_Delete(mapUri);

// Map name must follow the number.
// Map title must follow the number.
strcpy(info->title, Str_Text(lexer.readString()));

// Process optional tokens.
Expand Down Expand Up @@ -198,7 +198,6 @@ void MapInfoParser(Str const *path)
Con_Error("MapInfoParser: Invalid map warp-number '%s' in \"%s\" on line #%i",
lexer.token(), F_PrettyPath(Str_Text(path)), lexer.lineNumber());
}

info->warpTrans = (unsigned) mapWarpNum - 1;
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/hexen/src/p_spec.c
Expand Up @@ -1006,7 +1006,7 @@ void P_InitLightning(void)
{
int i, secCount;
Uri *mapUri = G_ComposeMapUri(gameEpisode, gameMap);
mapinfo_t *mapInfo = P_MapInfo(mapUri);
mapinfo_t const *mapInfo = P_MapInfo(mapUri);
Uri_Delete(mapUri);

if(!mapInfo || !mapInfo->lightning)
Expand Down

0 comments on commit 933c905

Please sign in to comment.