Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Deh Reader: Added support for [MUSIC] and [SOUNDS] patches
  • Loading branch information
danij-deng committed Aug 22, 2012
1 parent 1fbfaa4 commit a1a7e80
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 9 deletions.
60 changes: 52 additions & 8 deletions doomsday/plugins/dehread/src/dehreader.cpp
Expand Up @@ -424,17 +424,13 @@ class DehReader
}
else if(line.beginsWith("[SOUNDS]", Qt::CaseInsensitive)) // .bex
{
// Not yet supported.
//skipToNextLine();
skipToNextLine();
parseSoundsBex();
skipToNextSection();
}
else if(line.beginsWith("[MUSIC]", Qt::CaseInsensitive)) // .bex
{
// Not yet supported.
//skipToNextLine();
skipToNextLine();
parseMusicBex();
skipToNextSection();
}
else
{
Expand Down Expand Up @@ -1370,13 +1366,61 @@ class DehReader
void parseSoundsBex()
{
LOG_AS("parseSoundsBex");
LOG_WARNING("[SOUNDS] patches are not supported.");
// .bex doesn't follow the same rules as .deh
for(; !line.trimmed().isEmpty(); readLine())
{
// Skip comment lines.
if(line.at(0) == '#') continue;

try
{
String var, expr;
parseAssignmentStatement(line, var, expr);
if(!patchSoundLumpNames(var, expr))
{
LOG_WARNING("Failed to locate sound \"%s\" for patching.") << var;
}
}
catch(const SyntaxError& er)
{
LOG_WARNING("%s, ignoring.") << er.asText();
}
}

if(line.trimmed().isEmpty())
{
skipToNextSection();
}
}

void parseMusicBex()
{
LOG_AS("parseMusicBex");
LOG_WARNING("[MUSIC] patches are not supported.");
// .bex doesn't follow the same rules as .deh
for(; !line.trimmed().isEmpty(); readLine())
{
// Skip comment lines.
if(line.at(0) == '#') continue;

try
{
String var, expr;
parseAssignmentStatement(line, var, expr);
if(!patchMusicLumpNames(var, expr))
{
LOG_WARNING("Failed to locate music \"%s\" for patching.") << var;
}
}
catch(const SyntaxError& er)
{
LOG_WARNING("%s, ignoring.") << er.asText();
}
}

if(line.trimmed().isEmpty())
{
skipToNextSection();
}
}

void parsePointerBex()
Expand Down
14 changes: 13 additions & 1 deletion doomsday/plugins/dehread/src/info.cpp
Expand Up @@ -352,7 +352,7 @@ int findSpriteNameInMap(const QString& name)
return -1; // Not found.
}

static const char* SoundMap[] = {
static const QString SoundMap[] = {
"None",
"pistol",
"shotgn",
Expand Down Expand Up @@ -465,6 +465,18 @@ static const char* SoundMap[] = {
NULL
};

int findSoundLumpNameInMap(const QString& name)
{
/// @todo Optimize - replace linear search.
if(!name.isEmpty())
for(int i = 0; !SoundMap[i].isEmpty(); ++i)
{
if(!SoundMap[i].compare(name, Qt::CaseInsensitive))
return i;
}
return -1; // Not found.
}

static SoundMapping soundMappings[] = {
{ "Alert", SDN_SEE, "See" },
{ "Attack", SDN_ATTACK, "Attack" },
Expand Down

0 comments on commit a1a7e80

Please sign in to comment.