Skip to content

Commit

Permalink
libcommon|HexLex: HexLex no longer accesses the DED definition database
Browse files Browse the repository at this point in the history
If DED definition lookup is necessary for translating a parsed value
then this should be implemented in the parser instead.
  • Loading branch information
danij-deng committed Jan 25, 2014
1 parent 933c905 commit 2c8a931
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 33 deletions.
4 changes: 1 addition & 3 deletions doomsday/plugins/common/include/hexlex.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,8 @@ class HexLex
*/
Str const *token();

Str const *readString();
int readNumber();

int readSoundIndex();
Str const *readString();
Uri *readUri(char const *defaultScheme = "");

/**
Expand Down
5 changes: 0 additions & 5 deletions doomsday/plugins/common/src/hexlex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,6 @@ Uri *HexLex::readUri(char const *defaultScheme)
return uri;
}

int HexLex::readSoundIndex()
{
return Def_Get(DD_DEF_SOUND_BY_NAME, Str_Text(readString()), 0);
}

void HexLex::unreadToken()
{
if(_readPos == 0)
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/common/src/p_sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void SndInfoParser(Str const *path)

// string(sound-id) string(lump-name | '?')
// A sound definition.
int const soundIndex = lexer.readSoundIndex();
int const soundIndex = Def_Get(DD_DEF_SOUND_BY_NAME, Str_Text(lexer.readString()), 0);
Str const *lumpName = lexer.readString();

if(soundIndex)
Expand Down
38 changes: 19 additions & 19 deletions doomsday/plugins/hexen/src/p_mapinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,32 +52,32 @@ static void setMusicCDTrack(char const *musicId, int track)
void MapInfoParser(Str const *path)
{
mapInfos.clear();
uint logicalMapIndex = 0;

// Prepare a default-configured definition, for one-shot initialization.
mapinfo_t defMapInfo;

defMapInfo.map = -1; // Unknown.
defMapInfo.cluster = 0;
defMapInfo.warpTrans = 0;
defMapInfo.nextMap = 0; // Always go to map 0 if not specified.
defMapInfo.cdTrack = 1;
defMapInfo.sky1Material = Materials_ResolveUriCString(gameMode == hexen_demo || gameMode == hexen_betademo? "Textures:SKY2" : "Textures:SKY1");
defMapInfo.sky2Material = defMapInfo.sky1Material;
defMapInfo.sky1ScrollDelta = 0;
defMapInfo.sky2ScrollDelta = 0;
defMapInfo.doubleSky = false;
defMapInfo.lightning = false;
defMapInfo.fadeTable = W_GetLumpNumForName("COLORMAP");
strcpy(defMapInfo.title, "DEVELOPMENT MAP"); // Unknown.
strcpy(defMapInfo.songLump, "DEFSONG"); // Unknown.

AutoStr *script = M_ReadFileIntoString(path, 0);

if(script && !Str_IsEmpty(script))
{
App_Log(DE2_RES_VERBOSE, "Parsing \"%s\"...", F_PrettyPath(Str_Text(path)));

// Prepare a default-configured definition, for one-shot initialization.
mapinfo_t defMapInfo;
defMapInfo.map = -1; // Unknown.
defMapInfo.cluster = 0;
defMapInfo.warpTrans = 0;
defMapInfo.nextMap = 0; // Always go to map 0 if not specified.
defMapInfo.cdTrack = 1;
defMapInfo.sky1Material = Materials_ResolveUriCString(gameMode == hexen_demo || gameMode == hexen_betademo? "Textures:SKY2" : "Textures:SKY1");
defMapInfo.sky2Material = defMapInfo.sky1Material;
defMapInfo.sky1ScrollDelta = 0;
defMapInfo.sky2ScrollDelta = 0;
defMapInfo.doubleSky = false;
defMapInfo.lightning = false;
defMapInfo.fadeTable = W_GetLumpNumForName("COLORMAP");
strcpy(defMapInfo.title, "DEVELOPMENT MAP"); // Unknown.
strcpy(defMapInfo.songLump, "DEFSONG"); // Unknown.

uint logicalMapIndex = 0;

HexLex lexer(script, path);

while(lexer.readToken())
Expand Down
11 changes: 6 additions & 5 deletions doomsday/plugins/hexen/src/sn_sonix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,15 @@ void SndSeqParser(Str const *path)
verifySequencePtr(tempDataStart, tempDataPtr);

*tempDataPtr++ = SS_CMD_PLAYREPEAT;
*tempDataPtr++ = lexer.readSoundIndex();
*tempDataPtr++ = Def_Get(DD_DEF_SOUND_BY_NAME, Str_Text(lexer.readString()), 0);
continue;
}
if(!Str_CompareIgnoreCase(lexer.token(), "playtime"))
{
verifySequencePtr(tempDataStart, tempDataPtr);

*tempDataPtr++ = SS_CMD_PLAY;
*tempDataPtr++ = lexer.readSoundIndex();
*tempDataPtr++ = Def_Get(DD_DEF_SOUND_BY_NAME, Str_Text(lexer.readString()), 0);
*tempDataPtr++ = SS_CMD_DELAY;
*tempDataPtr++ = lexer.readNumber();
continue;
Expand All @@ -210,7 +210,7 @@ void SndSeqParser(Str const *path)
verifySequencePtr(tempDataStart, tempDataPtr);

*tempDataPtr++ = SS_CMD_PLAY;
*tempDataPtr++ = lexer.readSoundIndex();
*tempDataPtr++ = Def_Get(DD_DEF_SOUND_BY_NAME, Str_Text(lexer.readString()), 0);
*tempDataPtr++ = SS_CMD_WAITUNTILDONE;
continue;
}
Expand All @@ -219,7 +219,7 @@ void SndSeqParser(Str const *path)
verifySequencePtr(tempDataStart, tempDataPtr);

*tempDataPtr++ = SS_CMD_PLAY;
*tempDataPtr++ = lexer.readSoundIndex();
*tempDataPtr++ = Def_Get(DD_DEF_SOUND_BY_NAME, Str_Text(lexer.readString()), 0);
continue;
}
if(!Str_CompareIgnoreCase(lexer.token(), "delayrand"))
Expand Down Expand Up @@ -249,7 +249,8 @@ void SndSeqParser(Str const *path)
}
if(!Str_CompareIgnoreCase(lexer.token(), "stopsound"))
{
SequenceTranslate[seqCommmandIndex].stopSound = lexer.readSoundIndex();
SequenceTranslate[seqCommmandIndex].stopSound =
Def_Get(DD_DEF_SOUND_BY_NAME, Str_Text(lexer.readString()), 0);
*tempDataPtr++ = SS_CMD_STOPSOUND;
continue;
}
Expand Down

0 comments on commit 2c8a931

Please sign in to comment.