Skip to content

Commit

Permalink
Fixed|libdoomsday|DED: Parsing Flags with an implicit zero value
Browse files Browse the repository at this point in the history
If no value is specified for a Flag then we should assume zero. This
fixes an XG regression where the value for ltc_none flag was being
registered with an uninitialized value.
  • Loading branch information
danij-deng committed Oct 5, 2014
1 parent ede7238 commit ead78ff
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
5 changes: 3 additions & 2 deletions doomsday/libdoomsday/include/doomsday/defs/ded.h
Expand Up @@ -22,8 +22,9 @@

#include <vector>
#include <de/libcore.h>
#include <de/Vector>
#include <de/Record>
#include <de/String>
#include <de/Vector>
#include "../uri.h"

#include "dedtypes.h"
Expand Down Expand Up @@ -131,7 +132,7 @@ struct LIBDOOMSDAY_PUBLIC ded_s

void clear();

int addFlag(char const *id, int value);
int addFlag(de::String const &id, int value);

int addModel();

Expand Down
2 changes: 1 addition & 1 deletion doomsday/libdoomsday/src/defs/ded.cpp
Expand Up @@ -67,7 +67,7 @@ void ded_s::clear()
modelOffset = 0;
}

int ded_s::addFlag(char const *id, int value)
int ded_s::addFlag(String const &id, int value)
{
Record &def = flags.append();
def.addText("id", id);
Expand Down
24 changes: 13 additions & 11 deletions doomsday/libdoomsday/src/defs/dedparser.cpp
Expand Up @@ -570,6 +570,8 @@ DENG2_PIMPL(DEDParser)

int ReadFlags(int *dest, char const *prefix)
{
DENG2_ASSERT(dest);

// By default, no flags are set.
*dest = 0;

Expand Down Expand Up @@ -599,14 +601,10 @@ DENG2_PIMPL(DEDParser)
{
*dest = ded->evalFlags2(flag.toUtf8().constData());
}
else
{
*dest = 0;
}
return true;
}

for(;;)
forever
{
// Read the flag.
ReadToken();
Expand Down Expand Up @@ -899,11 +897,13 @@ DENG2_PIMPL(DEDParser)
if(ISTOKEN("Flag"))
{
ded_stringid_t id;
int value;
int value = 0;
char dummyStr[2];

de::zap(id);

FINDBEGIN;
for(;;)
forever
{
READLABEL;
RV_STR("ID", id)
Expand All @@ -913,10 +913,12 @@ DENG2_PIMPL(DEDParser)
CHECKSC;
}

ded->addFlag(id, value);

// Sanity check.
DENG2_ASSERT(ded->flags.find("id", id).geti("value") == value);
if(qstrlen(id))
{
ded->addFlag(id, value);
// Sanity check.
DENG2_ASSERT(ded->flags.find("id", id).geti("value") == value);
}
}

if(ISTOKEN("Mobj") || ISTOKEN("Thing"))
Expand Down

0 comments on commit ead78ff

Please sign in to comment.