diff --git a/src/dehacked.c b/src/dehacked.c index 2f6fe9926..1858de421 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -3511,15 +3511,16 @@ static void DEH_LoadDehackedFile(MYFILE *f, boolean mainfile) continue; } word2 = strtok(NULL, " "); + if (word2) { + strupr(word2); + if (word2[strlen(word2) - 1] == '\n') + word2[strlen(word2) - 1] = '\0'; + i = atoi(word2); + } + else + i = 0; if (fastcmp(word, "CHARACTER")) { - if (word2) { - strupr(word2); - if (word2[strlen(word2)-1] == '\n') - word2[strlen(word2)-1] = '\0'; - i = atoi(word2); - } else - i = 0; if (i >= 0 && i < 32) readPlayer(f, i); else @@ -3529,13 +3530,58 @@ static void DEH_LoadDehackedFile(MYFILE *f, boolean mainfile) } continue; } + else if (fastcmp(word, "EMBLEM")) + { + if (!mainfile && !gamedataadded) + { + deh_warning("You must define a custom gamedata to use \"%s\"", word); + ignorelines(f); + } + else + { + if (!word2) + i = numemblems + 1; + + if (i > 0 && i <= MAXEMBLEMS) + { + if (numemblems < i) + numemblems = i; + reademblemdata(f, i); + } + else + { + deh_warning("Emblem number %d out of range (1 - %d)", i, MAXEMBLEMS); + ignorelines(f); + } + } + } + else if (fastcmp(word, "EXTRAEMBLEM")) + { + if (!mainfile && !gamedataadded) + { + deh_warning("You must define a custom gamedata to use \"%s\"", word); + ignorelines(f); + } + else + { + if (!word2) + i = numextraemblems + 1; + + if (i > 0 && i <= MAXEXTRAEMBLEMS) + { + if (numextraemblems < i) + numextraemblems = i; + readextraemblemdata(f, i); + } + else + { + deh_warning("Extra emblem number %d out of range (1 - %d)", i, MAXEXTRAEMBLEMS); + ignorelines(f); + } + } + } if (word2) { - strupr(word2); - if (word2[strlen(word2)-1] == '\n') - word2[strlen(word2)-1] = '\0'; - i = atoi(word2); - if (fastcmp(word, "THING") || fastcmp(word, "MOBJ") || fastcmp(word, "OBJECT")) { if (i == 0 && word2[0] != '0') // If word2 isn't a number @@ -3658,44 +3704,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, boolean mainfile) ignorelines(f); } } - else if (fastcmp(word, "EMBLEM")) - { - if (!mainfile && !gamedataadded) - { - deh_warning("You must define a custom gamedata to use \"%s\"", word); - ignorelines(f); - } - else if (i > 0 && i <= MAXEMBLEMS) - { - if (numemblems < i) - numemblems = i; - reademblemdata(f, i); - } - else - { - deh_warning("Emblem number %d out of range (1 - %d)", i, MAXEMBLEMS); - ignorelines(f); - } - } - else if (fastcmp(word, "EXTRAEMBLEM")) - { - if (!mainfile && !gamedataadded) - { - deh_warning("You must define a custom gamedata to use \"%s\"", word); - ignorelines(f); - } - else if (i > 0 && i <= MAXEXTRAEMBLEMS) - { - if (numextraemblems < i) - numextraemblems = i; - readextraemblemdata(f, i); - } - else - { - deh_warning("Extra emblem number %d out of range (1 - %d)", i, MAXEXTRAEMBLEMS); - ignorelines(f); - } - } else if (fastcmp(word, "UNLOCKABLE")) { if (!mainfile && !gamedataadded)