From 64ff789f2f779a538cbf58da77f37ddf50a2b5b0 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 30 Aug 2021 18:45:56 -0700 Subject: [PATCH 1/5] Add my full name --- src/f_finale.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/f_finale.c b/src/f_finale.c index ade26bbe..4c39ec9b 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -445,9 +445,9 @@ static const char *credits[] = { "", "\1Support Programming", "Colette \"fickleheart\" Bordelon", - "James R.", "\"Lat\'\"", "\"Monster Iestyn\"", + "James Robert Roman", "\"Shuffle\"", "\"SteelT\"", "", From f5bcfc6379383b7722468e7d5eb717eb2528ed03 Mon Sep 17 00:00:00 2001 From: Ashnal Date: Sat, 4 Sep 2021 22:46:30 -0400 Subject: [PATCH 2/5] Add I_Errors for when the game exhausts all freeslots of any type. --- src/dehacked.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 00f4fa96..0ce114d2 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -591,13 +591,13 @@ void DEH_UpdateMaxFreeslots(void) } // TODO: Figure out how to do undolines for this.... -// TODO: Warnings for running out of freeslots static void readfreeslots(MYFILE *f) { char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); char *word,*type; char *tmp; int i; + boolean allocated = false; do { @@ -625,10 +625,12 @@ static void readfreeslots(MYFILE *f) break; // TODO: Check for existing freeslot mobjs/states/etc. and make errors. - // TODO: Out-of-slots warnings/errors. // TODO: Name too long (truncated) warnings. if (fastcmp(type, "SFX")) + { + CONS_Printf("Sound sfx_%s allocated.\n",word); S_AddSoundFx(word, false, 0, false); + } else if (fastcmp(type, "SPR")) { for (i = SPR_FIRSTFREESLOT; i <= SPR_LASTFREESLOT; i++) @@ -642,29 +644,44 @@ static void readfreeslots(MYFILE *f) // Found a free slot! strncpy(sprnames[i],word,4); //sprnames[i][4] = 0; + CONS_Printf("Sprite SPR_%s allocated.\n",word); used_spr[(i-SPR_FIRSTFREESLOT)/8] |= 1<<(i%8); // Okay, this sprite slot has been named now. + allocated = true; break; } + + if (!allocated) + 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); FREE_STATES[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL); strcpy(FREE_STATES[i],word); freeslotusage[0][0]++; + allocated = true; break; } + + if (!allocated) + I_Error("Out of State Freeslots while allocating \"%s\"\nLoad less addons to fix this.", word); } else if (fastcmp(type, "MT")) { for (i = 0; i < NUMMOBJFREESLOTS; i++) if (!FREE_MOBJS[i]) { + CONS_Printf("MobjType MT_%s allocated.\n",word); FREE_MOBJS[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL); strcpy(FREE_MOBJS[i],word); freeslotusage[1][0]++; + allocated = true; break; } + + if (!allocated) + I_Error("Out of Mobj Freeslots while allocating \"%s\"\nLoad less addons to fix this.", word); } else deh_warning("Freeslots: unknown enum class '%s' for '%s_%s'", type, type, word); @@ -9215,7 +9232,7 @@ void DEH_Check(void) static inline int lib_freeslot(lua_State *L) { int n = lua_gettop(L); - int r = 0; // args returned + int r = 0; // args returned char *s, *type,*word; while (n-- > 0) @@ -9245,7 +9262,7 @@ static inline int lib_freeslot(lua_State *L) lua_pushinteger(L, sfx); r++; } else - return r; + return luaL_error(L, "Out of Sfx Freeslots while allocating \"%s\"\nLoad less addons to fix this.", word); } else if (fastcmp(type, "SPR")) { @@ -9272,7 +9289,7 @@ static inline int lib_freeslot(lua_State *L) break; } if (j > SPR_LASTFREESLOT) - return r; + I_Error("Out of Sprite Freeslots while allocating \"%s\"\nLoad less addons to fix this.", word); } else if (fastcmp(type, "S")) { @@ -9288,7 +9305,7 @@ static inline int lib_freeslot(lua_State *L) break; } if (i == NUMSTATEFREESLOTS) - return r; + I_Error("Out of State Freeslots while allocating \"%s\"\nLoad less addons to fix this.", word); } else if (fastcmp(type, "MT")) { @@ -9304,7 +9321,7 @@ static inline int lib_freeslot(lua_State *L) break; } if (i == NUMMOBJFREESLOTS) - return r; + I_Error("Out of Mobj Freeslots while allocating \"%s\"\nLoad less addons to fix this.", word); } Z_Free(s); lua_remove(L, 1); From 4b750e0504dd4b01f917894bcac5216a32306e7f Mon Sep 17 00:00:00 2001 From: Ashnal Date: Sat, 4 Sep 2021 22:47:13 -0400 Subject: [PATCH 3/5] Adjust S_AddSoundFx to also use I_Error when exhausting Freeslots --- src/sounds.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sounds.c b/src/sounds.c index 9285a2a8..75472bec 100644 --- a/src/sounds.c +++ b/src/sounds.c @@ -1034,7 +1034,7 @@ sfxenum_t S_AddSoundFx(const char *name, boolean singular, INT32 flags, boolean return i; } } - CONS_Alert(CONS_WARNING, M_GetText("No more free sound slots\n")); + I_Error("Out of Sound Freeslots while allocating \"%s\"\nLoad less addons to fix this.", name); return 0; } From 6e7bdc6031d6683527a56a31b5fd99b028346f8f Mon Sep 17 00:00:00 2001 From: Ashnal Date: Sun, 5 Sep 2021 19:21:02 -0400 Subject: [PATCH 4/5] Changed readfreeslots error checking to work like lib_freeslot Uses loop variable to determine error condition Also small change to lib_freeslot for SFX for consistent use of I_Error --- src/dehacked.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 0ce114d2..8f51df46 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -597,7 +597,6 @@ static void readfreeslots(MYFILE *f) char *word,*type; char *tmp; int i; - boolean allocated = false; do { @@ -646,11 +645,9 @@ static void readfreeslots(MYFILE *f) //sprnames[i][4] = 0; CONS_Printf("Sprite SPR_%s allocated.\n",word); used_spr[(i-SPR_FIRSTFREESLOT)/8] |= 1<<(i%8); // Okay, this sprite slot has been named now. - allocated = true; break; } - - if (!allocated) + 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")) @@ -661,11 +658,10 @@ static void readfreeslots(MYFILE *f) FREE_STATES[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL); strcpy(FREE_STATES[i],word); freeslotusage[0][0]++; - allocated = true; break; } - if (!allocated) + if (i == NUMSTATEFREESLOTS) I_Error("Out of State Freeslots while allocating \"%s\"\nLoad less addons to fix this.", word); } else if (fastcmp(type, "MT")) @@ -676,11 +672,10 @@ static void readfreeslots(MYFILE *f) FREE_MOBJS[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL); strcpy(FREE_MOBJS[i],word); freeslotusage[1][0]++; - allocated = true; break; } - if (!allocated) + if (i == NUMMOBJFREESLOTS) I_Error("Out of Mobj Freeslots while allocating \"%s\"\nLoad less addons to fix this.", word); } else @@ -9262,7 +9257,7 @@ static inline int lib_freeslot(lua_State *L) lua_pushinteger(L, sfx); r++; } else - return luaL_error(L, "Out of Sfx Freeslots while allocating \"%s\"\nLoad less addons to fix this.", word); + I_Error("Out of Sfx Freeslots while allocating \"%s\"\nLoad less addons to fix this.", word); //Should never get here since S_AddSoundFx was changed to throw I_Error when it can't allocate } else if (fastcmp(type, "SPR")) { From ab2bbf3b08657229f0ce88df6a0bedd557d0bae1 Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Tue, 7 Sep 2021 22:09:03 +0200 Subject: [PATCH 5/5] validation against mo (guards against delays) --- src/p_spec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 04d69c9b..671c49cf 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2879,7 +2879,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 432: // Enable 2D Mode (Disable if noclimb) - if (mo->player) + if (mo && mo->player) { if (line->flags & ML_NOCLIMB) mo->flags2 &= ~MF2_TWOD; @@ -2905,7 +2905,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 434: // Custom Power - if (mo->player) + if (mo && mo->player) { mobj_t *dummy = P_SpawnMobj(mo->x, mo->y, mo->z, MT_NULL); @@ -2985,7 +2985,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 437: // Disable Player Controls - if (mo->player) + if (mo && mo->player) { UINT16 fractime = (UINT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS); if (fractime < 1)