Skip to content

Commit

Permalink
Changed: Do not fatal error if an unknown Material name is encountere…
Browse files Browse the repository at this point in the history
…d in a

Material modification def. Instead we'll log the problem and continue to
parse the definition using a dummy ded_material_t struct.
  • Loading branch information
danij-deng committed Aug 5, 2011
1 parent 6f963c2 commit 96a80fe
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions doomsday/engine/portable/src/def_read.c
Expand Up @@ -1035,7 +1035,7 @@ static int DED_ReadData(ded_t* ded, const char* buffer, const char* _sourceFile)
if(ISTOKEN("Material"))
{
boolean bModify = false;
ded_material_t* mat;
ded_material_t* mat, dummyMat;
uint layer = 0;
int stage;

Expand All @@ -1056,17 +1056,23 @@ static int DED_ReadData(ded_t* ded, const char* buffer, const char* _sourceFile)
mat = Def_GetMaterial(otherMat);
if(NULL == mat)
{
ddstring_t* path = Uri_ToString(otherMat);
SetError2("Unknown Material.", Str_Text(path));
Str_Delete(path);

retVal = false;
goto ded_end_read;
VERBOSE(
ddstring_t* path = Uri_ToString(otherMat);
Con_Message("Warning: Unknown Material %s in %s on line #%i, will be ignored.\n",
Str_Text(path), source ? source->fileName : "?", source ? source->lineNumber : 0);
Str_Delete(path) )

// We'll read into a dummy definition.
idx = -1;
memset(&dummyMat, 0, sizeof(dummyMat));
mat = &dummyMat;
}
else
{
idx = mat - ded->materials;
bModify = true;
}

idx = mat - ded->materials;
Uri_Destruct(otherMat);
bModify = true;
}
else
{
Expand Down Expand Up @@ -1178,7 +1184,12 @@ static int DED_ReadData(ded_t* ded, const char* buffer, const char* _sourceFile)
else RV_END
CHECKSC;
}
prevMaterialDefIdx = idx;

// If we did not read into a dummy update the previous index.
if(idx > 0)
{
prevMaterialDefIdx = idx;
}
}

if(ISTOKEN("Model"))
Expand Down

0 comments on commit 96a80fe

Please sign in to comment.