From e94fecf56d2e6b67aaddaa125628c9a73cf310ea Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 16 Jun 2026 19:07:54 +0200 Subject: [PATCH] cleanup even more style issues also should fix R_InitSprites printing the wrong spritename in some cases --- src/dehacked.c | 137 +++++++++++++++++++++++++-------------- src/g_demo.c | 20 +++--- src/hardware/hw_portal.c | 12 ++-- src/r_patch.cpp | 2 +- src/r_skins.c | 2 +- src/r_things.cpp | 64 ++++++++++-------- 6 files changed, 142 insertions(+), 95 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 323261243..cfac59656 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -337,12 +337,14 @@ static void readfreeslots(MYFILE *f) { if (used_spr[(i-SPR_FIRSTFREESLOT)/8] & (1<<(i%8))) { - if (!sprnames[i][4] && memcmp(sprnames[i],word,4)==0) + if (!sprnames[i][4] && memcmp(sprnames[i], word, 4) == 0) sprnames[i][4] = (char)f->wad; + continue; // Already allocated, next. } + // Found a free slot! - strncpy(sprnames[i],word,4); + strncpy(sprnames[i], word, 4); //sprnames[i][4] = 0; CONS_Printf("Sprite SPR_%s allocated.\n",word); @@ -351,22 +353,26 @@ static void readfreeslots(MYFILE *f) used_spr[(i-SPR_FIRSTFREESLOT)/8] |= 1<<(i%8); // Okay, this sprite slot has been named now. break; } + if (i > SPR_LASTFREESLOT) I_Error("Out of Sprite Freeslots while allocating \"%s\"\nLoad less addons to fix this.", word); } else if (fastcmp(type, "S")) { for (i = 0; i < NUMSTATEFREESLOTS; i++) - if (!FREE_STATES[i]) { - CONS_Printf("State S_%s allocated.\n",word); + { + if (!FREE_STATES[i]) + { + CONS_Printf("State S_%s allocated.\n", word); LUA_InvalidateMathlibCache(va("S_%s", word)); FREE_STATES[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL); - strcpy(FREE_STATES[i],word); + strcpy(FREE_STATES[i], word); freeslotusage[0][0]++; break; } + } if (i == NUMSTATEFREESLOTS) I_Error("Out of State Freeslots while allocating \"%s\"\nLoad less addons to fix this.", word); @@ -374,16 +380,19 @@ static void readfreeslots(MYFILE *f) else if (fastcmp(type, "MT")) { for (i = 0; i < NUMMOBJFREESLOTS; i++) - if (!FREE_MOBJS[i]) { - CONS_Printf("MobjType MT_%s allocated.\n",word); + { + if (!FREE_MOBJS[i]) + { + CONS_Printf("MobjType MT_%s allocated.\n", word); LUA_InvalidateMathlibCache(va("MT_%s", word)); FREE_MOBJS[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL); - strcpy(FREE_MOBJS[i],word); + strcpy(FREE_MOBJS[i], word); freeslotusage[1][0]++; break; } + } if (i == NUMMOBJFREESLOTS) I_Error("Out of Mobj Freeslots while allocating \"%s\"\nLoad less addons to fix this.", word); @@ -426,8 +435,11 @@ static void readthing(MYFILE *f, INT32 num) strupr(word2); else break; - if (word2[strlen(word2)-1] == '\n') - word2[strlen(word2)-1] = '\0'; + + const size_t word2len = strlen(word2); + + if (word2[word2len-1] == '\n') + word2[word2len-1] = '\0'; if (fastcmp(word, "MAPTHINGNUM") || fastcmp(word, "DOOMEDNUM")) { @@ -734,14 +746,20 @@ static void readlevelheader(MYFILE *f, INT32 num, INT32 wadnum) { UINT16 tol = 0; tmp = strtok(word2,","); + do { for (i = 0; TYPEOFLEVEL[i].name; i++) + { if (fastcmp(tmp, TYPEOFLEVEL[i].name)) break; + } + if (!TYPEOFLEVEL[i].name) deh_warning("Level header %d: unknown typeoflevel flag %s\n", num, tmp); + tol |= TYPEOFLEVEL[i].flag; } while((tmp = strtok(NULL,",")) != NULL); + mapheaderinfo[num-1]->typeoflevel = tol; } } @@ -1037,8 +1055,11 @@ static void readcutscenescene(MYFILE *f, INT32 num, INT32 scenenum) else break; - if (word2[strlen(word2)-1] == '\n') - word2[strlen(word2)-1] = '\0'; + const size_t word2len = strlen(word2); + + if (word2[word2len-1] == '\n') + word2[word2len-1] = '\0'; + i = atoi(word2); usi = (UINT16)i; @@ -1088,12 +1109,14 @@ static void readcutscenescene(MYFILE *f, INT32 num, INT32 scenenum) else if (fastcmp(word, "MUSICSLOT")) { i = get_mus(word2, true); + if (i && i <= 1035) snprintf(cutscenes[num]->scene[scenenum].musswitch, 7, "%sM", G_BuildMapName(i)); else if (i && i <= 1050) strncpy(cutscenes[num]->scene[scenenum].musswitch, compat_special_music_slots[i - 1036], 7); else cutscenes[num]->scene[scenenum].musswitch[0] = 0; // becomes empty string + cutscenes[num]->scene[scenenum].musswitch[6] = 0; } #endif @@ -1498,8 +1521,11 @@ static void readframe(MYFILE *f, INT32 num) strupr(word2); else break; - if (word2[strlen(word2)-1] == '\n') - word2[strlen(word2)-1] = '\0'; + + const size_t word2len = strlen(word2); + + if (word2[word2len-1] == '\n') + word2[word2len-1] = '\0'; if (fastcmp(word1, "SPRITENUMBER") || fastcmp(word1, "SPRITENAME")) { @@ -1828,13 +1854,19 @@ static void readextraemblemdata(MYFILE *f, INT32 num) value = atoi(word2); // used for numerical settings if (fastcmp(word, "NAME")) + { deh_strlcpy(extraemblems[num-1].name, word2, - sizeof (extraemblems[num-1].name), va("Extra emblem %d: name", num)); + sizeof (extraemblems[num-1].name), va("Extra emblem %d: name", num)); + } else if (fastcmp(word, "OBJECTIVE")) + { deh_strlcpy(extraemblems[num-1].description, word2, - sizeof (extraemblems[num-1].description), va("Extra emblem %d: objective", num)); + sizeof (extraemblems[num-1].description), va("Extra emblem %d: objective", num)); + } else if (fastcmp(word, "CONDITIONSET")) + { extraemblems[num-1].conditionset = (UINT8)value; + } else if (fastcmp(word, "SPRITE")) { if (word2[0] >= 'A' && word2[0] <= 'Z') @@ -1906,11 +1938,15 @@ static void readunlockable(MYFILE *f, INT32 num) i = atoi(word2); // used for numerical settings if (fastcmp(word, "NAME")) + { deh_strlcpy(unlockables[num].name, word2, - sizeof (unlockables[num].name), va("Unlockable %d: name", num)); + sizeof (unlockables[num].name), va("Unlockable %d: name", num)); + } else if (fastcmp(word, "OBJECTIVE")) + { deh_strlcpy(unlockables[num].objective, word2, - sizeof (unlockables[num].objective), va("Unlockable %d: objective", num)); + sizeof (unlockables[num].objective), va("Unlockable %d: objective", num)); + } else if (fastcmp(word, "SHOWCONDITIONSET")) unlockables[num].showconditionset = (UINT8)i; else if (fastcmp(word, "CONDITIONSET")) @@ -8102,7 +8138,7 @@ static mobjtype_t get_mobjtype(const char *word) if (*word >= '0' && *word <= '9') return atoi(word); - if (fastncmp("MT_",word,3)) + if (fastncmp("MT_", word, 3)) word += 3; // take off the MT_ for (i = 0; i < NUMMOBJFREESLOTS; i++) @@ -8128,7 +8164,7 @@ static statenum_t get_state(const char *word) if (*word >= '0' && *word <= '9') return atoi(word); - if (fastncmp("S_",word,2)) + if (fastncmp("S_", word, 2)) word += 2; // take off the S_ for (i = 0; i < NUMSTATEFREESLOTS; i++) @@ -8155,11 +8191,11 @@ static spritenum_t get_sprite(const char *word) if (*word >= '0' && *word <= '9') return atoi(word); - if (fastncmp("SPR_",word,4)) + if (fastncmp("SPR_", word, 4)) word += 4; // take off the SPR_ for (i = 0; i < NUMSPRITES; i++) - if (!sprnames[i][4] && memcmp(word,sprnames[i],4) == 0) + if (!sprnames[i][4] && memcmp(word, sprnames[i], 4) == 0) return i; deh_warning("Couldn't find sprite named 'SPR_%s'",word); @@ -8200,14 +8236,15 @@ static UINT16 get_mus(const char *word, UINT8 dehacked_mode) if (!word[2] && toupper(word[0]) >= 'A' && toupper(word[0]) <= 'Z') return (UINT16)M_MapNumber(word[0], word[1]); - if (fastncmp("MUS_",word,4)) + if (fastncmp("MUS_", word, 4)) word += 4; // take off the MUS_ - else if (fastncmp("O_",word,2) || fastncmp("D_",word,2)) + else if (fastncmp("O_", word, 2) || fastncmp("D_", word, 2)) word += 2; // take off the O_ or D_ strncpy(lumptmp, word, 4); lumptmp[3] = 0; - if (fasticmp("MAP",lumptmp)) + + if (fasticmp("MAP", lumptmp)) { word += 3; if (toupper(word[0]) >= 'A' && toupper(word[0]) <= 'Z') @@ -8320,7 +8357,7 @@ static inline int lib_freeslot(lua_State *L) { sfxenum_t sfx; strlwr(word); - CONS_Printf("Sound sfx_%s allocated.\n",word); + CONS_Printf("Sound sfx_%s allocated.\n", word); sfx = S_AddSoundFx(word, false, 0, false); if (sfx != sfx_None) @@ -8344,8 +8381,10 @@ static inline int lib_freeslot(lua_State *L) { if (!sprnames[j][4] && memcmp(sprnames[j], word, 4) == 0) sprnames[j][4] = wad; + continue; // Already allocated, next. } + // Found a free slot! CONS_Printf("Sprite SPR_%s allocated.\n",word); @@ -8353,7 +8392,7 @@ static inline int lib_freeslot(lua_State *L) lua_pushfstring(L, "SPR_%s", word); lua_call(L, 1, 0); - strncpy(sprnames[j],word,4); + strncpy(sprnames[j], word, 4); //sprnames[j][4] = 0; used_spr[(j-SPR_FIRSTFREESLOT)/8] |= 1<<(j%8); // Okay, this sprite slot has been named now. lua_pushinteger(L, j); @@ -8371,7 +8410,7 @@ static inline int lib_freeslot(lua_State *L) { if (!FREE_STATES[i]) { - CONS_Printf("State S_%s allocated.\n",word); + CONS_Printf("State S_%s allocated.\n", word); lua_pushcfunction(L, lua_glib_invalidate_cache); lua_pushfstring(L, "S_%s", word); @@ -8396,14 +8435,14 @@ static inline int lib_freeslot(lua_State *L) { if (!FREE_MOBJS[i]) { - CONS_Printf("MobjType MT_%s allocated.\n",word); + CONS_Printf("MobjType MT_%s allocated.\n", word); lua_pushcfunction(L, lua_glib_invalidate_cache); lua_pushfstring(L, "MT_%s", word); lua_call(L, 1, 0); FREE_MOBJS[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL); - strcpy(FREE_MOBJS[i],word); + strcpy(FREE_MOBJS[i], word); freeslotusage[1][0]++; lua_pushinteger(L, i); r++; @@ -8590,6 +8629,7 @@ static int lua_enumlib_mobjtype_get(lua_State *L) { if (!FREE_MOBJS[i]) break; + if (fastcmp(s+3, FREE_MOBJS[i])) { lua_pushinteger(L, MT_FIRSTFREESLOT+i); @@ -8678,30 +8718,29 @@ static int lua_enumlib_sfx_get_ds(lua_State *L) } #ifdef MUSICSLOT_COMPATIBILITY +static int lua_enumlib_mus_get(lua_State *L) +{ + const char *name = strchr(lua_tostring(L, 1), '_') + 1; + int mus = get_mus(name, false); - static int lua_enumlib_mus_get(lua_State *L) - { - const char *name = strchr(lua_tostring(L, 1), '_') + 1; - int mus = get_mus(name, false); + if (mus == 0) + return 0; - if (mus == 0) - return 0; + lua_pushinteger(L, mus); + return 1; +} - lua_pushinteger(L, mus); - return 1; - } +static int lua_enumlib_mus_get_mathlib(lua_State *L) +{ + const char *name = strchr(lua_tostring(L, 1), '_') + 1; + int mus = get_mus(name, false); - static int lua_enumlib_mus_get_mathlib(lua_State *L) - { - const char *name = strchr(lua_tostring(L, 1), '_') + 1; - int mus = get_mus(name, false); + if (mus == 0) + return luaL_error(L, "music '%s' could not be found.\n", lua_tostring(L, 1)); - if (mus == 0) - return luaL_error(L, "music '%s' could not be found.\n", lua_tostring(L, 1)); - - lua_pushinteger(L, mus); - return 1; - } + lua_pushinteger(L, mus); + return 1; +} #endif static int lua_enumlib_power_get(lua_State *L) diff --git a/src/g_demo.c b/src/g_demo.c index 850e08048..de6a1bb5d 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -515,49 +515,49 @@ void G_WriteDemoTiccmd(ticcmd_t *cmd, INT32 playernum) if (cmd->forwardmove != oldcmd[playernum].forwardmove) { - WRITEUINT8(demobuf.p,cmd->forwardmove); + WRITEUINT8(demobuf.p, cmd->forwardmove); oldcmd[playernum].forwardmove = cmd->forwardmove; ziptic |= ZT_FWD; } if (cmd->sidemove != oldcmd[playernum].sidemove) { - WRITEUINT8(demobuf.p,cmd->sidemove); + WRITEUINT8(demobuf.p, cmd->sidemove); oldcmd[playernum].sidemove = cmd->sidemove; ziptic |= ZT_SIDE; } if (cmd->angleturn != oldcmd[playernum].angleturn) { - WRITEINT16(demobuf.p,cmd->angleturn); + WRITEINT16(demobuf.p, cmd->angleturn); oldcmd[playernum].angleturn = cmd->angleturn; ziptic |= ZT_ANGLE; } if (cmd->buttons != oldcmd[playernum].buttons) { - WRITEUINT16(demobuf.p,cmd->buttons); + WRITEUINT16(demobuf.p, cmd->buttons); oldcmd[playernum].buttons = cmd->buttons; ziptic |= ZT_BUTTONS; } if (cmd->aiming != oldcmd[playernum].aiming) { - WRITEINT16(demobuf.p,cmd->aiming); + WRITEINT16(demobuf.p, cmd->aiming); oldcmd[playernum].aiming = cmd->aiming; ziptic |= ZT_AIMING; } if (cmd->driftturn != oldcmd[playernum].driftturn) { - WRITEINT16(demobuf.p,cmd->driftturn); + WRITEINT16(demobuf.p, cmd->driftturn); oldcmd[playernum].driftturn = cmd->driftturn; ziptic |= ZT_DRIFT; } if (cmd->latency != oldcmd[playernum].latency) { - WRITEUINT8(demobuf.p,cmd->latency); + WRITEUINT8(demobuf.p, cmd->latency); oldcmd[playernum].latency = cmd->latency; ziptic |= ZT_LATENCY; } @@ -726,8 +726,8 @@ void G_WriteGhostTic(mobj_t *ghost, INT32 playernum) // GZT_XYZ is only useful if you've moved 256 FRACUNITS or more in a single tic. if (abs(ghost->x-oldghost[playernum].x) > MAXMOM - || abs(ghost->y-oldghost[playernum].y) > MAXMOM - || abs(ghost->z-oldghost[playernum].z) > MAXMOM + || abs(ghost->y-oldghost[playernum].y) > MAXMOM + || abs(ghost->z-oldghost[playernum].z) > MAXMOM || ((UINT8)(leveltime & 255) > 0 && (UINT8)(leveltime & 255) <= (UINT8)cv_netdemosyncquality.value)) // Hack to enable slightly nicer resyncing { oldghost[playernum].x = ghost->x; @@ -1375,7 +1375,7 @@ fadeghost: UINT16 i, health; UINT16 count = READUINT16(g->p); //UINT32 type; - fixed_t x,y,z; + fixed_t x, y, z; angle_t angle; mobj_t *poof; diff --git a/src/hardware/hw_portal.c b/src/hardware/hw_portal.c index 117d59725..c64eedad0 100644 --- a/src/hardware/hw_portal.c +++ b/src/hardware/hw_portal.c @@ -80,8 +80,8 @@ void HWR_Portal_Add2Lines(const INT32 line1, const INT32 line2, seg_t *seg) gl_portal_t *portal = HWR_Portal_Add(seg); // Offset the portal view by the linedef centers - line_t* start = &lines[line1]; - line_t* dest = &lines[line2]; + line_t* start = &lines[line1]; + line_t* dest = &lines[line2]; angle_t dangle = R_PointToAngle2(0, 0, dest->dx, dest->dy) - R_PointToAngle2(start->dx, start->dy, 0, 0); @@ -99,7 +99,7 @@ void HWR_Portal_Add2Lines(const INT32 line1, const INT32 line2, seg_t *seg) dest_c.y = dest->v1->y/2 + dest->v2->y/2; disttopoint = R_PointToDist2(start_c.x, start_c.y, viewx, viewy); - angtopoint = R_PointToAngle2(start_c.x, start_c.y, viewx, viewy); + angtopoint = R_PointToAngle2(start_c.x, start_c.y, viewx, viewy); angtopoint += dangle; portal->viewx = dest_c.x + FixedMul(FINECOSINE(angtopoint>>ANGLETOFINESHIFT), disttopoint); @@ -220,9 +220,9 @@ boolean HWR_PortalCheckBBox(const fixed_t *bspcoord) if (!portalclipline) return true; - if (HWR_PortalCheckPointSide(bspcoord[BOXLEFT], bspcoord[BOXTOP]) || - HWR_PortalCheckPointSide(bspcoord[BOXLEFT], bspcoord[BOXBOTTOM]) || - HWR_PortalCheckPointSide(bspcoord[BOXRIGHT], bspcoord[BOXTOP]) || + if (HWR_PortalCheckPointSide(bspcoord[BOXLEFT], bspcoord[BOXTOP]) || + HWR_PortalCheckPointSide(bspcoord[BOXLEFT], bspcoord[BOXBOTTOM]) || + HWR_PortalCheckPointSide(bspcoord[BOXRIGHT], bspcoord[BOXTOP]) || HWR_PortalCheckPointSide(bspcoord[BOXRIGHT], bspcoord[BOXBOTTOM])) { return true; diff --git a/src/r_patch.cpp b/src/r_patch.cpp index f578a8f32..c7c49b827 100644 --- a/src/r_patch.cpp +++ b/src/r_patch.cpp @@ -289,7 +289,7 @@ void R_ParseSPRTINFOLump(UINT16 wadNum, UINT16 lumpNum) sprinfoLumpLength = W_LumpLengthPwad(wadNum, lumpNum); sprinfoText = (char *)Z_Malloc((sprinfoLumpLength+1)*sizeof(char),PU_STATIC,NULL); // Now move the contents of the lump into this new location. - memmove(sprinfoText,sprinfoLump,sprinfoLumpLength); + memmove(sprinfoText, sprinfoLump, sprinfoLumpLength); // Make damn well sure the last character in our new memory location is \0. sprinfoText[sprinfoLumpLength] = '\0'; // Finally, free up the memory from the first data load, because we really diff --git a/src/r_skins.c b/src/r_skins.c index 9ab6e0fbf..b45dd0d58 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -712,7 +712,7 @@ void R_AddSkins(UINT16 wadnum, boolean local) // skip to end of this skin's frames lastlump = lump; - while (W_CheckNameForNumPwad(wadnum, lastlump) && memcmp(W_CheckNameForNumPwad(wadnum, lastlump), csprname,4)==0) + while (W_CheckNameForNumPwad(wadnum, lastlump) && memcmp(W_CheckNameForNumPwad(wadnum, lastlump), csprname, 4) == 0) lastlump++; // allocate (or replace) sprite frames, and set spritedef diff --git a/src/r_things.cpp b/src/r_things.cpp index 875cb7290..b4707db6f 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -182,15 +182,14 @@ static void R_InstallSpriteLump(UINT16 wad, // graphics patch UINT8 rightfactor = ((rotation == ROT_R) ? 4 : 0); // the lump should be used for half of all rotations - if (sprtemp[frame].rotate == SRF_SINGLE) + if (sprtemp[frame].rotate == SRF_NONE) + sprtemp[frame].rotate = SRF_SINGLE; + else if (sprtemp[frame].rotate == SRF_SINGLE) CONS_Debug(DBG_SETUP, "R_InitSprites: Sprite %s frame %c has L/R rotations and a rot = 0 lump\n", spritename, cn); else if (sprtemp[frame].rotate == SRF_3D) CONS_Debug(DBG_SETUP, "R_InitSprites: Sprite %s frame %c has both L/R and 1-8 rotations\n", spritename, cn); // Let's not complain about multiple L/R rotations. It's not worth the effort. - if (sprtemp[frame].rotate == SRF_NONE) - sprtemp[frame].rotate = SRF_SINGLE; - sprtemp[frame].rotate |= ((rotation == ROT_R) ? SRF_RIGHT : SRF_LEFT); if (sprtemp[frame].rotate == (SRF_3D|SRF_2D)) @@ -233,6 +232,7 @@ static void R_InstallSpriteLump(UINT16 wad, // graphics patch // when using sprites in pwad : the lumppat points the new graphics sprtemp[frame].lumppat[rotation] = lumppat; sprtemp[frame].lumpid[rotation] = lumpid; + if (flipped) sprtemp[frame].flip |= (1<numframes) // (then spriteframes is not null) @@ -289,7 +291,7 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16 if (frame >= 64 || !(R_ValidSpriteAngle(rotation))) // Give an actual NAME error -_-... { - CONS_Alert(CONS_WARNING, M_GetText("Bad sprite name: %s\n"), W_CheckNameForNumPwad(wadnum,l)); + CONS_Alert(CONS_WARNING, M_GetText("Bad sprite name: %s\n"), W_CheckNameForNumPwad(wadnum, l)); continue; } @@ -315,6 +317,15 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16 { frame = R_Char2Frame(lumpinfo[l].name[6]); rotation = (UINT8)(lumpinfo[l].name[7] - '0'); + + /* + if (frame >= 64 || !(R_ValidSpriteAngle(rotation))) // Give an actual NAME error -_-... + { + CONS_Alert(CONS_WARNING, M_GetText("Bad sprite name: %s\n"), W_CheckNameForNumPwad(wadnum, l)); + continue; + } + */ + R_InstallSpriteLump(wadnum, l, numspritelumps, frame, rotation, 1); } @@ -363,30 +374,32 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16 switch (sprtemp[frame].rotate) { case SRF_NONE: - // no rotations were found for that frame at all - I_Error("R_AddSingleSpriteDef: No patches found for %.4s frame %c", sprname, R_Frame2Char(frame)); - break; + // no rotations were found for that frame at all + I_Error("R_AddSingleSpriteDef: No patches found for %.4s frame %c", sprname, R_Frame2Char(frame)); + break; case SRF_SINGLE: - // only the first rotation is needed - break; + // only the first rotation is needed + break; case SRF_2D: // both Left and Right rotations // we test to see whether the left and right slots are present if ((sprtemp[frame].lumppat[2] == LUMPERROR) || (sprtemp[frame].lumppat[6] == LUMPERROR)) I_Error("R_AddSingleSpriteDef: Sprite %s frame %c is missing rotations", sprname, R_Frame2Char(frame)); - break; + break; default: - // must have all 8 frames - for (rotation = 0; rotation < 8; rotation++) - // we test the patch lump, or the id lump whatever - // if it was not loaded the two are LUMPERROR - if (sprtemp[frame].lumppat[rotation] == LUMPERROR) - I_Error("R_AddSingleSpriteDef: Sprite %.4s frame %c is missing rotations", - sprname, R_Frame2Char(frame)); - break; + // must have all 8 frames + for (rotation = 0; rotation < 8; rotation++) + { + // we test the patch lump, or the id lump whatever + // if it was not loaded the two are LUMPERROR + if (sprtemp[frame].lumppat[rotation] == LUMPERROR) + I_Error("R_AddSingleSpriteDef: Sprite %.4s frame %c is missing rotations", + sprname, R_Frame2Char(frame)); + } + break; } } @@ -394,7 +407,6 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16 if (spritedef->numframes && // has been allocated spritedef->numframes < maxframe) // more frames are defined ? { - Z_Free(spritedef->spriteframes); spritedef->spriteframes = NULL; } @@ -451,12 +463,10 @@ void R_AddSpriteDefs(UINT16 wadnum) // for (i = 0; i < numsprites; i++) { - spritename = sprnames[i]; - - if (spritename[4] && wadnum >= (UINT16)spritename[4]) + if (sprnames[i][4] && wadnum >= (UINT16)sprnames[i][4]) continue; - if (R_AddSingleSpriteDef(spritename, &sprites[i], wadnum, start, end)) + if (R_AddSingleSpriteDef(sprnames[i], &sprites[i], wadnum, start, end)) { #ifdef HWRENDER if (rendermode == render_opengl) @@ -464,9 +474,7 @@ void R_AddSpriteDefs(UINT16 wadnum) #endif // if a new sprite was added (not just replaced) addsprites++; -#ifndef ZDEBUG - CONS_Debug(DBG_SETUP, "sprite %s set in pwad %d\n", spritename, wadnum); -#endif + CONS_Debug(DBG_SETUP, "sprite %s set in pwad %d\n", sprnames[i], wadnum); } }