Skip to content

Commit

Permalink
Fixed dpDehRead: "Compatible Dehacked file not loading" (see here htt…
Browse files Browse the repository at this point in the history
…p://sourceforge.net/tracker/?func=detail&aid=2802979&group_id=74815&atid=542099).

Fixed dpDehRead: If multiple Text definitions with the same id are found (i.e., "patched" by a later definition), patching via a DEH patch did not work as expected (should take precedence).
  • Loading branch information
danij committed Jul 1, 2009
1 parent 752bcb4 commit 8a6efec
Show file tree
Hide file tree
Showing 3 changed files with 1,294 additions and 289 deletions.
2 changes: 1 addition & 1 deletion doomsday/engine/api/doomsday.h
Expand Up @@ -81,7 +81,7 @@ extern "C" {

// Base: Definitions.
int Def_Get(int type, const char* id, void* out);
int Def_Set(int type, int index, int value, void* ptr);
int Def_Set(int type, int index, int value, const void* ptr);
int Def_EvalFlags(char* flags);

// Base: Input.
Expand Down
32 changes: 24 additions & 8 deletions doomsday/engine/portable/src/def_main.c
Expand Up @@ -1550,13 +1550,20 @@ int Def_Get(int type, const char* id, void* out)
break;

case DD_DEF_TEXT:
for(i = 0; i < defs.count.text.num; ++i)
if(!stricmp(defs.text[i].id, id))
{
if(out)
*(char **) out = defs.text[i].text;
return i;
}
if(id && id[0])
{
int i;

// Read backwards to allow patching.
for(i = defs.count.text.num - 1; i >= 0; i--)
if(!stricmp(defs.text[i].id, id))
{
// \fixme: should be returning an immutable ptr.
if(out)
*(char **) out = defs.text[i].text;
return i;
}
}
return -1;

case DD_DEF_VALUE:
Expand Down Expand Up @@ -1644,13 +1651,22 @@ int Def_Get(int type, const char* id, void* out)
* This is supposed to be the main interface for outside parties to
* modify definitions (unless they want to do it manually with dedfile.h).
*/
int Def_Set(int type, int index, int value, void* ptr)
int Def_Set(int type, int index, int value, const void* ptr)
{
int i;
ded_music_t* musdef = 0;

switch(type)
{
case DD_DEF_TEXT:
if(index < 0 || index >= defs.count.text.num)
Con_Error("Def_Set: Text index %i is invalid.\n", index);

defs.text[index].text = M_Realloc(defs.text[index].text,
strlen((char*)ptr) + 1);
strcpy(defs.text[index].text, ptr);
break;

case DD_DEF_SOUND:
if(index < 0 || index >= countSounds.num)
Con_Error("Def_Set: Sound index %i is invalid.\n", index);
Expand Down

0 comments on commit 8a6efec

Please sign in to comment.