diff --git a/src/deh_soc.c b/src/deh_soc.c index f4f61c9b8..0fb112eb7 100644 --- a/src/deh_soc.c +++ b/src/deh_soc.c @@ -1200,7 +1200,7 @@ void readlevelheader(MYFILE *f, INT32 num) if (fastncmp(tmp, "MT_", 3)) // support for specified mobjtypes... { i = get_mobjtype(tmp); - if (!i) + if (i == -1) { //deh_warning("Level header %d: unknown flicky mobj type %s\n", num, tmp); -- no need for this line as get_mobjtype complains too continue; @@ -2322,7 +2322,8 @@ void readframe(MYFILE *f, INT32 num) } else if (fastcmp(word1, "NEXT")) { - states[num].nextstate = get_state(word2); + statenum_t state = get_state(word2); + states[num].nextstate = state == -1 ? S_NULL : state; } else if (fastcmp(word1, "VAR1")) { @@ -3750,7 +3751,10 @@ void readfollower(MYFILE *f) else if (fastcmp(word2, "OPPOSITE")) followers[numfollowers].defaultcolor = FOLLOWERCOLOR_OPPOSITE; else - followers[numfollowers].defaultcolor = get_skincolor(word2); + { + skincolornum_t color = get_skincolor(word2); + followers[numfollowers].defaultcolor = color == -1 ? SKINCOLOR_GREEN : color; + } } else if (fastcmp(word, "SCALE")) { @@ -3982,7 +3986,8 @@ void readweather(MYFILE *f, INT32 num) if (fastcmp(word, "TYPE")) { - precipprops[num].type = get_mobjtype(word2); + mobjtype_t mt = get_mobjtype(word2); + precipprops[num].type = mt == -1 ? MT_NULL : mt; } else if (fastcmp(word, "EFFECTS")) { @@ -4017,7 +4022,7 @@ mobjtype_t get_mobjtype(const char *word) if (fastcmp(word, MOBJTYPE_LIST[i]+3)) return i; deh_warning("Couldn't find mobjtype named 'MT_%s'",word); - return MT_NULL; + return -1; } statenum_t get_state(const char *word) @@ -4037,7 +4042,7 @@ statenum_t get_state(const char *word) if (fastcmp(word, STATE_LIST[i]+2)) return i; deh_warning("Couldn't find state named 'S_%s'",word); - return S_NULL; + return -1; } skincolornum_t get_skincolor(const char *word) @@ -4057,7 +4062,7 @@ skincolornum_t get_skincolor(const char *word) if (fastcmp(word, COLOR_ENUMS[i])) return i; deh_warning("Couldn't find skincolor named 'SKINCOLOR_%s'",word); - return SKINCOLOR_GREEN; + return -1; } spritenum_t get_sprite(const char *word) @@ -4101,7 +4106,7 @@ sfxenum_t get_sfx(const char *word) if (S_sfx[i].name && fasticmp(word, S_sfx[i].name)) return i; deh_warning("Couldn't find sfx named 'SFX_%s'",word); - return sfx_None; + return -1; } menutype_t get_menutype(const char *word) diff --git a/src/dehacked.c b/src/dehacked.c index c83586553..53fc2beba 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -314,7 +314,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, boolean mainfile) { if (i == 0 && word2[0] != '0') // If word2 isn't a number i = get_mobjtype(word2); // find a thing by name - if (i < NUMMOBJTYPES && i > 0) + if (i < NUMMOBJTYPES && i >= 0) { if (i < (MT_FIRSTFREESLOT+freeslotusage[1][1])) { @@ -325,7 +325,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, boolean mainfile) } else { - deh_warning("Thing %d out of range (1 - %d)", i, NUMMOBJTYPES-1); + deh_warning("Thing %d out of range (0 - %d)", i, NUMMOBJTYPES-1); ignorelines(f); } } @@ -333,11 +333,11 @@ static void DEH_LoadDehackedFile(MYFILE *f, boolean mainfile) { if (i == 0 && word2[0] != '0') // If word2 isn't a number i = get_skincolor(word2); // find a skincolor by name - if (i && i < numskincolors) + if (i < numskincolors && i >= 0) readskincolor(f, i); else { - deh_warning("Skincolor %d out of range (1 - %d)", i, numskincolors-1); + deh_warning("Skincolor %d out of range (0 - %d)", i, numskincolors-1); ignorelines(f); } } @@ -463,11 +463,11 @@ static void DEH_LoadDehackedFile(MYFILE *f, boolean mainfile) { if (i == 0 && word2[0] != '0') // If word2 isn't a number i = get_sfx(word2); // find a sound by name - if (i < NUMSFX && i > 0) + if (i < NUMSFX && i >= 0) readsound(f, i); else { - deh_warning("Sound %d out of range (1 - %d)", i, NUMSFX-1); + deh_warning("Sound %d out of range (0 - %d)", i, NUMSFX-1); ignorelines(f); } } diff --git a/src/info.c b/src/info.c index 33f98047f..a9f8ec64e 100644 --- a/src/info.c +++ b/src/info.c @@ -82,42 +82,11 @@ playersprite_t spr2defaults[NUMPLAYERSPRITES] = { }; // Doesn't work with g++, needs actionf_p1 (don't modify this comment) -state_t states[NUMSTATES] = { - {SPR_NULL, 0, 1, {NULL}, 0, 0, S_NULL} -}; +state_t states[NUMSTATES] = {}; -mobjinfo_t mobjinfo[NUMMOBJTYPES] = { - { - -1, // doomednum - S_NULL, // spawnstate - 0, // spawnhealth - S_NULL, // seestate - sfx_None, // seesound - 0, // reactiontime - sfx_None, // attacksound - S_NULL, // painstate - 0, // painchance - sfx_None, // painsound - S_NULL, // meleestate - S_NULL, // missilestate - S_NULL, // deathstate - S_NULL, // xdeathstate - sfx_None, // deathsound - 0, // speed - 0, // radius - 0, // height - 0, // display offset - 0, // mass - 0, // damage - sfx_None, // activesound - MF_NOBLOCKMAP|MF_NOSECTOR|MF_NOCLIP|MF_NOCLIPHEIGHT|MF_NOGRAVITY|MF_SCENERY|MF_DONTENCOREMAP, // flags - S_NULL // raisestate - } -}; +mobjinfo_t mobjinfo[NUMMOBJTYPES] = {}; -skincolor_t skincolors[MAXSKINCOLORS] = { - {"None", {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, SKINCOLOR_NONE, 0, 0, false}, -}; +skincolor_t skincolors[MAXSKINCOLORS] = {}; /** Patches the mobjinfo, state, and skincolor tables. * Free slots are emptied out and set to initial values.