From 04e5cfd33863b42b699729070b022fb404a2e8e9 Mon Sep 17 00:00:00 2001 From: toaster Date: Fri, 16 Sep 2022 22:51:02 +0100 Subject: [PATCH] Fix cups. * Required an adjustment of everywhere using G_MapNumber to return the raw header number, instead of off-by-one ala gamemap. * Fixing gamemap is a viable improvement for a future commit, but this commit is already pretty big. * Remove SCANTHINGS, since it used G_MapNumber and didn't work with long map names OR virtres anyways. * Support freeing new information in CLEAR LEVELS maincfg event, since I tried to use that to test cups. * Make Patch_Free's usability match Z_Free -- passing NULL is permitted and a no-op. --- src/d_main.c | 2 +- src/deh_soc.c | 205 ++++++++++++++++++++++++++----------------------- src/f_finale.c | 2 +- src/g_game.c | 12 +-- src/p_setup.c | 91 ++-------------------- src/p_setup.h | 3 - src/r_patch.c | 2 +- src/w_wad.c | 19 ----- 8 files changed, 125 insertions(+), 211 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 6d9c84a43..d74f42378 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1709,7 +1709,7 @@ void D_SRB2Main(void) // rei/miru: bootmap (Idea: starts the game on a predefined map) if (bootmap && !(M_CheckParm("-warp") && M_IsNextParm())) { - const INT32 bootMapNum = G_MapNumber(bootmap); + const INT32 bootMapNum = G_MapNumber(bootmap)+1; if (mapheaderinfo[bootMapNum]) { diff --git a/src/deh_soc.c b/src/deh_soc.c index e574b0c5e..023a7648a 100644 --- a/src/deh_soc.c +++ b/src/deh_soc.c @@ -159,12 +159,22 @@ void clear_levels(void) P_DeleteFlickies(i); P_DeleteGrades(i); + Patch_Free(mapheaderinfo[i]->thumbnailPic); + Patch_Free(mapheaderinfo[i]->minimapPic); + Z_Free(mapheaderinfo[i]->nextlevel); + Z_Free(mapheaderinfo[i]->marathonnext); + + Z_Free(mapheaderinfo[i]->lumpname); + Z_Free(mapheaderinfo[i]); mapheaderinfo[i] = NULL; } - // Realloc the one for the current gamemap as a safeguard - P_AllocMapHeader(gamemap-1); + nummapheaders = 0; + + // Realloc the one for the current gamemap as a safeguard -- TODO: BAD + if (Playing()) + P_AllocMapHeader(gamemap-1); } // TODO: Figure out how to do undolines for this.... @@ -1090,23 +1100,23 @@ void readlevelheader(MYFILE *f, char * name) const INT32 num = G_MapNumber(name); - if (num > NUMMAPS) + if (num >= NUMMAPS) { I_Error("Too many maps!"); } - if (f->wad > mainwads && num <= nummapheaders) + if (f->wad > mainwads && num < nummapheaders) { // only mark as a major mod if it replaces an already-existing mapheaderinfo G_SetGameModified(multiplayer, true); } // Reset all previous map header information - P_AllocMapHeader((INT16)(num-1)); + P_AllocMapHeader((INT16)(num)); - if (mapheaderinfo[num-1]->lumpname == NULL) + if (mapheaderinfo[num]->lumpname == NULL) { - mapheaderinfo[num-1]->lumpname = Z_StrDup(name); + mapheaderinfo[num]->lumpname = Z_StrDup(name); } do @@ -1145,16 +1155,16 @@ void readlevelheader(MYFILE *f, char * name) if (fastcmp(word, "LEVELNAME")) { - deh_strlcpy(mapheaderinfo[num-1]->lvlttl, word2, - sizeof(mapheaderinfo[num-1]->lvlttl), va("Level header %d: levelname", num)); - strlcpy(mapheaderinfo[num-1]->selectheading, word2, sizeof(mapheaderinfo[num-1]->selectheading)); // not deh_ so only complains once + deh_strlcpy(mapheaderinfo[num]->lvlttl, word2, + sizeof(mapheaderinfo[num]->lvlttl), va("Level header %d: levelname", num)); + strlcpy(mapheaderinfo[num]->selectheading, word2, sizeof(mapheaderinfo[num]->selectheading)); // not deh_ so only complains once continue; } // CHEAP HACK: move this over here for lowercase subtitles if (fastcmp(word, "SUBTITLE")) { - deh_strlcpy(mapheaderinfo[num-1]->subttl, word2, - sizeof(mapheaderinfo[num-1]->subttl), va("Level header %d: subtitle", num)); + deh_strlcpy(mapheaderinfo[num]->subttl, word2, + sizeof(mapheaderinfo[num]->subttl), va("Level header %d: subtitle", num)); continue; } @@ -1176,19 +1186,19 @@ void readlevelheader(MYFILE *f, char * name) } // Sanity limit of 128 params - if (mapheaderinfo[num-1]->numCustomOptions == 128) + if (mapheaderinfo[num]->numCustomOptions == 128) { deh_warning("Level header %d: too many custom parameters", num); continue; } - j = mapheaderinfo[num-1]->numCustomOptions++; + j = mapheaderinfo[num]->numCustomOptions++; - mapheaderinfo[num-1]->customopts = - Z_Realloc(mapheaderinfo[num-1]->customopts, - sizeof(customoption_t) * mapheaderinfo[num-1]->numCustomOptions, PU_STATIC, NULL); + mapheaderinfo[num]->customopts = + Z_Realloc(mapheaderinfo[num]->customopts, + sizeof(customoption_t) * mapheaderinfo[num]->numCustomOptions, PU_STATIC, NULL); // Newly allocated - modoption = &mapheaderinfo[num-1]->customopts[j]; + modoption = &mapheaderinfo[num]->customopts[j]; strncpy(modoption->option, word, 31); modoption->option[31] = '\0'; @@ -1204,33 +1214,33 @@ void readlevelheader(MYFILE *f, char * name) if (fastcmp(word, "FLICKYLIST") || fastcmp(word, "ANIMALLIST")) { if (fastcmp(word2, "NONE")) - P_DeleteFlickies(num-1); + P_DeleteFlickies(num); else if (fastcmp(word2, "DEMO")) - P_SetDemoFlickies(num-1); + P_SetDemoFlickies(num); else if (fastcmp(word2, "ALL")) { mobjtype_t tmpflickies[MAXFLICKIES]; - for (mapheaderinfo[num-1]->numFlickies = 0; - ((mapheaderinfo[num-1]->numFlickies < MAXFLICKIES) && FLICKYTYPES[mapheaderinfo[num-1]->numFlickies].type); - mapheaderinfo[num-1]->numFlickies++) - tmpflickies[mapheaderinfo[num-1]->numFlickies] = FLICKYTYPES[mapheaderinfo[num-1]->numFlickies].type; + for (mapheaderinfo[num]->numFlickies = 0; + ((mapheaderinfo[num]->numFlickies < MAXFLICKIES) && FLICKYTYPES[mapheaderinfo[num]->numFlickies].type); + mapheaderinfo[num]->numFlickies++) + tmpflickies[mapheaderinfo[num]->numFlickies] = FLICKYTYPES[mapheaderinfo[num]->numFlickies].type; - if (mapheaderinfo[num-1]->numFlickies) // just in case... + if (mapheaderinfo[num]->numFlickies) // just in case... { - size_t newsize = sizeof(mobjtype_t) * mapheaderinfo[num-1]->numFlickies; - mapheaderinfo[num-1]->flickies = Z_Realloc(mapheaderinfo[num-1]->flickies, newsize, PU_STATIC, NULL); - M_Memcpy(mapheaderinfo[num-1]->flickies, tmpflickies, newsize); + size_t newsize = sizeof(mobjtype_t) * mapheaderinfo[num]->numFlickies; + mapheaderinfo[num]->flickies = Z_Realloc(mapheaderinfo[num]->flickies, newsize, PU_STATIC, NULL); + M_Memcpy(mapheaderinfo[num]->flickies, tmpflickies, newsize); } } else { mobjtype_t tmpflickies[MAXFLICKIES]; - mapheaderinfo[num-1]->numFlickies = 0; + mapheaderinfo[num]->numFlickies = 0; tmp = strtok(word2,","); // get up to the first MAXFLICKIES flickies do { - if (mapheaderinfo[num-1]->numFlickies == MAXFLICKIES) // never going to get above that number + if (mapheaderinfo[num]->numFlickies == MAXFLICKIES) // never going to get above that number { deh_warning("Level header %d: too many flickies\n", num); break; @@ -1244,7 +1254,7 @@ void readlevelheader(MYFILE *f, char * name) //deh_warning("Level header %d: unknown flicky mobj type %s\n", num, tmp); -- no need for this line as get_mobjtype complains too continue; } - tmpflickies[mapheaderinfo[num-1]->numFlickies] = i; + tmpflickies[mapheaderinfo[num]->numFlickies] = i; } else // ...or a quick, limited selection of default flickies! { @@ -1257,17 +1267,17 @@ void readlevelheader(MYFILE *f, char * name) deh_warning("Level header %d: unknown flicky selection %s\n", num, tmp); continue; } - tmpflickies[mapheaderinfo[num-1]->numFlickies] = FLICKYTYPES[i].type; + tmpflickies[mapheaderinfo[num]->numFlickies] = FLICKYTYPES[i].type; } - mapheaderinfo[num-1]->numFlickies++; + mapheaderinfo[num]->numFlickies++; } while ((tmp = strtok(NULL,",")) != NULL); - if (mapheaderinfo[num-1]->numFlickies) + if (mapheaderinfo[num]->numFlickies) { - size_t newsize = sizeof(mobjtype_t) * mapheaderinfo[num-1]->numFlickies; - mapheaderinfo[num-1]->flickies = Z_Realloc(mapheaderinfo[num-1]->flickies, newsize, PU_STATIC, NULL); + size_t newsize = sizeof(mobjtype_t) * mapheaderinfo[num]->numFlickies; + mapheaderinfo[num]->flickies = Z_Realloc(mapheaderinfo[num]->flickies, newsize, PU_STATIC, NULL); // now we add them to the list! - M_Memcpy(mapheaderinfo[num-1]->flickies, tmpflickies, newsize); + M_Memcpy(mapheaderinfo[num]->flickies, tmpflickies, newsize); } else deh_warning("Level header %d: no valid flicky types found\n", num); @@ -1277,38 +1287,38 @@ void readlevelheader(MYFILE *f, char * name) // Strings that can be truncated else if (fastcmp(word, "NEXTLEVEL")) { - mapheaderinfo[num-1]->nextlevel = Z_StrDup(word2); + mapheaderinfo[num]->nextlevel = Z_StrDup(word2); } else if (fastcmp(word, "MARATHONNEXT")) { - mapheaderinfo[num-1]->marathonnext = Z_StrDup(word2); + mapheaderinfo[num]->marathonnext = Z_StrDup(word2); } else if (fastcmp(word, "ZONETITLE")) { - deh_strlcpy(mapheaderinfo[num-1]->zonttl, word2, - sizeof(mapheaderinfo[num-1]->zonttl), va("Level header %d: zonetitle", num)); + deh_strlcpy(mapheaderinfo[num]->zonttl, word2, + sizeof(mapheaderinfo[num]->zonttl), va("Level header %d: zonetitle", num)); } else if (fastcmp(word, "SCRIPTNAME")) { - deh_strlcpy(mapheaderinfo[num-1]->scriptname, word2, - sizeof(mapheaderinfo[num-1]->scriptname), va("Level header %d: scriptname", num)); + deh_strlcpy(mapheaderinfo[num]->scriptname, word2, + sizeof(mapheaderinfo[num]->scriptname), va("Level header %d: scriptname", num)); } else if (fastcmp(word, "RUNSOC")) { - deh_strlcpy(mapheaderinfo[num-1]->runsoc, word2, - sizeof(mapheaderinfo[num-1]->runsoc), va("Level header %d: runsoc", num)); + deh_strlcpy(mapheaderinfo[num]->runsoc, word2, + sizeof(mapheaderinfo[num]->runsoc), va("Level header %d: runsoc", num)); } else if (fastcmp(word, "ACT")) { if (i >= 0 && i <= 99) // 0 for no act number - mapheaderinfo[num-1]->actnum = (UINT8)i; + mapheaderinfo[num]->actnum = (UINT8)i; else deh_warning("Level header %d: invalid act number %d", num, i); } else if (fastcmp(word, "TYPEOFLEVEL")) { if (i) // it's just a number - mapheaderinfo[num-1]->typeoflevel = (UINT32)i; + mapheaderinfo[num]->typeoflevel = (UINT32)i; else { UINT32 tol = 0; @@ -1321,152 +1331,152 @@ void readlevelheader(MYFILE *f, char * 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; + mapheaderinfo[num]->typeoflevel = tol; } } else if (fastcmp(word, "KEYWORDS")) { - deh_strlcpy(mapheaderinfo[num-1]->keywords, word2, - sizeof(mapheaderinfo[num-1]->keywords), va("Level header %d: keywords", num)); + deh_strlcpy(mapheaderinfo[num]->keywords, word2, + sizeof(mapheaderinfo[num]->keywords), va("Level header %d: keywords", num)); } else if (fastcmp(word, "MUSIC")) { if (fastcmp(word2, "NONE")) - mapheaderinfo[num-1]->musname[0] = 0; // becomes empty string + mapheaderinfo[num]->musname[0] = 0; // becomes empty string else { - deh_strlcpy(mapheaderinfo[num-1]->musname, word2, - sizeof(mapheaderinfo[num-1]->musname), va("Level header %d: music", num)); + deh_strlcpy(mapheaderinfo[num]->musname, word2, + sizeof(mapheaderinfo[num]->musname), va("Level header %d: music", num)); } } else if (fastcmp(word, "MUSICSLOT")) deh_warning("Level header %d: MusicSlot parameter is deprecated and will be removed.\nUse \"Music\" instead.", num); else if (fastcmp(word, "MUSICTRACK")) - mapheaderinfo[num-1]->mustrack = ((UINT16)i - 1); + mapheaderinfo[num]->mustrack = ((UINT16)i - 1); else if (fastcmp(word, "MUSICPOS")) - mapheaderinfo[num-1]->muspos = (UINT32)get_number(word2); + mapheaderinfo[num]->muspos = (UINT32)get_number(word2); else if (fastcmp(word, "FORCECHARACTER")) { - strlcpy(mapheaderinfo[num-1]->forcecharacter, word2, SKINNAMESIZE+1); - strlwr(mapheaderinfo[num-1]->forcecharacter); // skin names are lowercase + strlcpy(mapheaderinfo[num]->forcecharacter, word2, SKINNAMESIZE+1); + strlwr(mapheaderinfo[num]->forcecharacter); // skin names are lowercase } else if (fastcmp(word, "WEATHER")) - mapheaderinfo[num-1]->weather = get_precip(word2); + mapheaderinfo[num]->weather = get_precip(word2); else if (fastcmp(word, "SKYTEXTURE")) - deh_strlcpy(mapheaderinfo[num-1]->skytexture, word2, - sizeof(mapheaderinfo[num-1]->skytexture), va("Level header %d: sky texture", num)); + deh_strlcpy(mapheaderinfo[num]->skytexture, word2, + sizeof(mapheaderinfo[num]->skytexture), va("Level header %d: sky texture", num)); else if (fastcmp(word, "PRECUTSCENENUM")) - mapheaderinfo[num-1]->precutscenenum = (UINT8)i; + mapheaderinfo[num]->precutscenenum = (UINT8)i; else if (fastcmp(word, "CUTSCENENUM")) - mapheaderinfo[num-1]->cutscenenum = (UINT8)i; + mapheaderinfo[num]->cutscenenum = (UINT8)i; else if (fastcmp(word, "PALETTE")) - mapheaderinfo[num-1]->palette = (UINT16)i; + mapheaderinfo[num]->palette = (UINT16)i; else if (fastcmp(word, "ENCOREPAL")) - mapheaderinfo[num-1]->encorepal = (UINT16)i; + mapheaderinfo[num]->encorepal = (UINT16)i; else if (fastcmp(word, "NUMLAPS")) - mapheaderinfo[num-1]->numlaps = (UINT8)i; + mapheaderinfo[num]->numlaps = (UINT8)i; else if (fastcmp(word, "UNLOCKABLE")) { if (i >= 0 && i <= MAXUNLOCKABLES) // 0 for no unlock required, anything else requires something - mapheaderinfo[num-1]->unlockrequired = (SINT8)i - 1; + mapheaderinfo[num]->unlockrequired = (SINT8)i - 1; else deh_warning("Level header %d: invalid unlockable number %d", num, i); } else if (fastcmp(word, "SKYBOXSCALE")) - mapheaderinfo[num-1]->skybox_scalex = mapheaderinfo[num-1]->skybox_scaley = mapheaderinfo[num-1]->skybox_scalez = (INT16)i; + mapheaderinfo[num]->skybox_scalex = mapheaderinfo[num]->skybox_scaley = mapheaderinfo[num]->skybox_scalez = (INT16)i; else if (fastcmp(word, "SKYBOXSCALEX")) - mapheaderinfo[num-1]->skybox_scalex = (INT16)i; + mapheaderinfo[num]->skybox_scalex = (INT16)i; else if (fastcmp(word, "SKYBOXSCALEY")) - mapheaderinfo[num-1]->skybox_scaley = (INT16)i; + mapheaderinfo[num]->skybox_scaley = (INT16)i; else if (fastcmp(word, "SKYBOXSCALEZ")) - mapheaderinfo[num-1]->skybox_scalez = (INT16)i; + mapheaderinfo[num]->skybox_scalez = (INT16)i; else if (fastcmp(word, "LEVELFLAGS")) - mapheaderinfo[num-1]->levelflags = get_number(word2); + mapheaderinfo[num]->levelflags = get_number(word2); else if (fastcmp(word, "MENUFLAGS")) - mapheaderinfo[num-1]->menuflags = get_number(word2); + mapheaderinfo[num]->menuflags = get_number(word2); // SRB2Kart else if (fastcmp(word, "MOBJSCALE")) - mapheaderinfo[num-1]->mobj_scale = get_number(word2); + mapheaderinfo[num]->mobj_scale = get_number(word2); else if (fastcmp(word, "DEFAULTWAYPOINTRADIUS")) - mapheaderinfo[num-1]->default_waypoint_radius = get_number(word2); + mapheaderinfo[num]->default_waypoint_radius = get_number(word2); else if (fastcmp(word, "LIGHTCONTRAST")) { - mapheaderinfo[num-1]->light_contrast = (UINT8)i; + mapheaderinfo[num]->light_contrast = (UINT8)i; } else if (fastcmp(word, "LIGHTANGLE")) { if (fastcmp(word2, "EVEN")) { - mapheaderinfo[num-1]->use_light_angle = false; - mapheaderinfo[num-1]->light_angle = 0; + mapheaderinfo[num]->use_light_angle = false; + mapheaderinfo[num]->light_angle = 0; } else { - mapheaderinfo[num-1]->use_light_angle = true; - mapheaderinfo[num-1]->light_angle = FixedAngle(FloatToFixed(atof(word2))); + mapheaderinfo[num]->use_light_angle = true; + mapheaderinfo[num]->light_angle = FixedAngle(FloatToFixed(atof(word2))); } } // Individual triggers for level flags, for ease of use (and 2.0 compatibility) else if (fastcmp(word, "SCRIPTISFILE")) { if (i || word2[0] == 'T' || word2[0] == 'Y') - mapheaderinfo[num-1]->levelflags |= LF_SCRIPTISFILE; + mapheaderinfo[num]->levelflags |= LF_SCRIPTISFILE; else - mapheaderinfo[num-1]->levelflags &= ~LF_SCRIPTISFILE; + mapheaderinfo[num]->levelflags &= ~LF_SCRIPTISFILE; } else if (fastcmp(word, "NOZONE")) { if (i || word2[0] == 'T' || word2[0] == 'Y') - mapheaderinfo[num-1]->levelflags |= LF_NOZONE; + mapheaderinfo[num]->levelflags |= LF_NOZONE; else - mapheaderinfo[num-1]->levelflags &= ~LF_NOZONE; + mapheaderinfo[num]->levelflags &= ~LF_NOZONE; } else if (fastcmp(word, "SECTIONRACE")) { if (i || word2[0] == 'T' || word2[0] == 'Y') - mapheaderinfo[num-1]->levelflags |= LF_SECTIONRACE; + mapheaderinfo[num]->levelflags |= LF_SECTIONRACE; else - mapheaderinfo[num-1]->levelflags &= ~LF_SECTIONRACE; + mapheaderinfo[num]->levelflags &= ~LF_SECTIONRACE; } else if (fastcmp(word, "SUBTRACTNUM")) { if (i || word2[0] == 'T' || word2[0] == 'Y') - mapheaderinfo[num-1]->levelflags |= LF_SUBTRACTNUM; + mapheaderinfo[num]->levelflags |= LF_SUBTRACTNUM; else - mapheaderinfo[num-1]->levelflags &= ~LF_SUBTRACTNUM; + mapheaderinfo[num]->levelflags &= ~LF_SUBTRACTNUM; } // Individual triggers for menu flags else if (fastcmp(word, "HIDDEN")) { if (i || word2[0] == 'T' || word2[0] == 'Y') - mapheaderinfo[num-1]->menuflags |= LF2_HIDEINMENU; + mapheaderinfo[num]->menuflags |= LF2_HIDEINMENU; else - mapheaderinfo[num-1]->menuflags &= ~LF2_HIDEINMENU; + mapheaderinfo[num]->menuflags &= ~LF2_HIDEINMENU; } else if (fastcmp(word, "HIDEINSTATS")) { if (i || word2[0] == 'T' || word2[0] == 'Y') - mapheaderinfo[num-1]->menuflags |= LF2_HIDEINSTATS; + mapheaderinfo[num]->menuflags |= LF2_HIDEINSTATS; else - mapheaderinfo[num-1]->menuflags &= ~LF2_HIDEINSTATS; + mapheaderinfo[num]->menuflags &= ~LF2_HIDEINSTATS; } else if (fastcmp(word, "TIMEATTACK") || fastcmp(word, "RECORDATTACK")) { // RECORDATTACK is an accepted alias if (i || word2[0] == 'T' || word2[0] == 'Y') - mapheaderinfo[num-1]->menuflags &= ~LF2_NOTIMEATTACK; + mapheaderinfo[num]->menuflags &= ~LF2_NOTIMEATTACK; else - mapheaderinfo[num-1]->menuflags |= LF2_NOTIMEATTACK; + mapheaderinfo[num]->menuflags |= LF2_NOTIMEATTACK; } else if (fastcmp(word, "VISITNEEDED")) { if (i || word2[0] == 'T' || word2[0] == 'Y') - mapheaderinfo[num-1]->menuflags |= LF2_VISITNEEDED; + mapheaderinfo[num]->menuflags |= LF2_VISITNEEDED; else - mapheaderinfo[num-1]->menuflags &= ~LF2_VISITNEEDED; + mapheaderinfo[num]->menuflags &= ~LF2_VISITNEEDED; } else if (fastcmp(word, "GRAVITY")) - mapheaderinfo[num-1]->gravity = FLOAT_TO_FIXED(atof(word2)); + mapheaderinfo[num]->gravity = FLOAT_TO_FIXED(atof(word2)); else deh_warning("Level header %d: unknown word '%s'", num, word); } @@ -3319,8 +3329,9 @@ void readcupheader(MYFILE *f, cupheader_t *cup) break; } - cup->levellist[cup->numlevels] = Z_StrDup(word2); + cup->levellist[cup->numlevels] = Z_StrDup(tmp); cup->numlevels++; + CONS_Printf("tmp = %s\n", tmp); } while((tmp = strtok(NULL,",")) != NULL); } else if (fastcmp(word, "BONUSGAME")) diff --git a/src/f_finale.c b/src/f_finale.c index 877d1892b..ec70678b0 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -1851,7 +1851,7 @@ void F_StartTitleScreen(void) { mapthing_t *startpos; - const INT32 titleMapNum = G_MapNumber(titlemap); + const INT32 titleMapNum = G_MapNumber(titlemap)+1; gamestate_t prevwipegamestate = wipegamestate; titlemapinaction = TITLEMAP_LOADING; titlemapcameraref = NULL; diff --git a/src/g_game.c b/src/g_game.c index b020179fa..6333326c9 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -625,7 +625,7 @@ INT32 G_MapNumber(const char * name) } } - return map + 1; + return map; } /** Clips the console player's mouse aiming to the current view. @@ -3610,7 +3610,7 @@ static void G_DoCompleted(void) if (mapheaderinfo[mNextNum]) { - nextmap = (INT16)(mNextNum-1); + nextmap = (INT16)mNextNum; } } else if (grandprixinfo.gp == true) @@ -3645,7 +3645,7 @@ static void G_DoCompleted(void) if (mapheaderinfo[nextNum]) { - nextmap = (INT16)(nextNum-1); + nextmap = (INT16)nextNum; if (marathonmode && nextmap == spmarathon_start-1) nextmap = 1100-1; // No infinite loop for you } @@ -3681,7 +3681,7 @@ static void G_DoCompleted(void) if (!mapheaderinfo[mNextNum]) cm = -1; // guarantee error execution else - cm = (INT16)(mNextNum-1); + cm = (INT16)mNextNum; } else { @@ -3690,7 +3690,7 @@ static void G_DoCompleted(void) if (!mapheaderinfo[nextNum]) cm = -1; // guarantee error execution else - cm = (INT16)(nextNum-1); + cm = (INT16)nextNum; } if (cm >= NUMMAPS || cm < 0) // out of range (either 1100ish or error) @@ -4892,7 +4892,7 @@ INT32 G_FindMapByNameOrCode(const char *mapname, char **realmapnamep) } else { - newmapnum = G_MapNumber(mapname); + newmapnum = G_MapNumber(mapname)+1; if (newmapnum > nummapheaders) return G_FindMap(mapname, realmapnamep, NULL, NULL); diff --git a/src/p_setup.c b/src/p_setup.c index 958e1c638..5aa38aa99 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -363,29 +363,17 @@ static void P_ClearSingleMapHeaderInfo(INT16 i) { const INT16 num = (INT16)(i-1); - if (mapheaderinfo[num]->thumbnailPic) - { - Patch_Free(mapheaderinfo[num]->thumbnailPic); - mapheaderinfo[num]->thumbnailPic = NULL; - } + Patch_Free(mapheaderinfo[num]->thumbnailPic); + mapheaderinfo[num]->thumbnailPic = NULL; - if (mapheaderinfo[num]->minimapPic) - { - Patch_Free(mapheaderinfo[num]->minimapPic); - mapheaderinfo[num]->minimapPic = NULL; - } + Patch_Free(mapheaderinfo[num]->minimapPic); + mapheaderinfo[num]->minimapPic = NULL; - if (mapheaderinfo[num]->nextlevel) - { - Z_Free(mapheaderinfo[num]->nextlevel); - mapheaderinfo[num]->nextlevel = NULL; - } + Z_Free(mapheaderinfo[num]->nextlevel); + mapheaderinfo[num]->nextlevel = NULL; - if (mapheaderinfo[num]->marathonnext) - { - Z_Free(mapheaderinfo[num]->marathonnext); - mapheaderinfo[num]->marathonnext = NULL; - } + Z_Free(mapheaderinfo[num]->marathonnext); + mapheaderinfo[num]->marathonnext = NULL; mapheaderinfo[num]->lvlttl[0] = '\0'; mapheaderinfo[num]->selectheading[0] = '\0'; @@ -762,69 +750,6 @@ void P_ReloadRings(void) } } -#ifdef SCANTHINGS -void P_ScanThings(INT16 mapnum, INT16 wadnum, INT16 lumpnum) -{ - size_t i, n; - UINT8 *data, *datastart; - UINT16 type, maprings; - INT16 tol; - UINT32 flags; - - tol = mapheaderinfo[mapnum-1]->typeoflevel; - flags = mapheaderinfo[mapnum-1]->levelflags; - - n = W_LumpLengthPwad(wadnum, lumpnum) / (5 * sizeof (INT16)); - //CONS_Printf("%u map things found!\n", n); - - maprings = 0; - data = datastart = W_CacheLumpNumPwad(wadnum, lumpnum, PU_STATIC); - for (i = 0; i < n; i++) - { - data += 3 * sizeof (INT16); // skip x y position, angle - type = READUINT16(data) & 4095; - data += sizeof (INT16); // skip options - - if (mt->type == mobjinfo[MT_RANDOMITEM].doomednum) - { - nummapboxes++; - } - else if (mt->type == mobjinfo[MT_BATTLECAPSULE].doomednum) - { - maptargets++; - } - else if (mt->type == mobjinfo[MT_RING].doomednum) - { - maprings++; - } - else - { - switch (type) - { - case 603: // 10 diagonal rings - maprings += 10; - break; - case 600: // 5 vertical rings - case 601: // 5 vertical rings - case 602: // 5 diagonal rings - maprings += 5; - break; - case 604: // 8 circle rings - maprings += 8; - break; - case 605: // 16 circle rings - maprings += 16; - break; - } - } - } - Z_Free(datastart); - - if (maprings) - CONS_Printf("%s has %u rings\n", G_BuildMapName(mapnum), maprings); -} -#endif - static void P_SpawnMapThings(boolean spawnemblems) { size_t i; diff --git a/src/p_setup.h b/src/p_setup.h index b36451dfb..4eaf46105 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -99,9 +99,6 @@ extern mapthing_t *mapthings; extern UINT16 p_adding_file; void P_SetupLevelSky(const char *skytexname, boolean global); -#ifdef SCANTHINGS -void P_ScanThings(INT16 mapnum, INT16 wadnum, INT16 lumpnum); -#endif void P_RespawnThings(void); boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate); #ifdef HWRENDER diff --git a/src/r_patch.c b/src/r_patch.c index 544c15ae8..8cf89fa3d 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -101,7 +101,7 @@ static void Patch_FreeData(patch_t *patch) void Patch_Free(patch_t *patch) { - if (patch == missingpat) + if (!patch || patch == missingpat) return; Patch_FreeData(patch); Z_Free(patch); diff --git a/src/w_wad.c b/src/w_wad.c index 490954dd4..3c739493c 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -64,9 +64,6 @@ #include "i_system.h" #include "md5.h" #include "lua_script.h" -#ifdef SCANTHINGS -#include "p_setup.h" // P_ScanThings -#endif #include "g_game.h" // G_SetGameModified #include "k_terrain.h" @@ -274,22 +271,6 @@ static inline void W_LoadDehackedLumps(UINT16 wadnum, boolean mainfile) DEH_LoadDehackedLumpPwad(wadnum, lump, mainfile); } } - -#ifdef SCANTHINGS - // Scan maps for emblems 'n shit - { - lumpinfo_t *lump_p = wadfiles[wadnum]->lumpinfo; - for (lump = 0; lump < wadfiles[wadnum]->numlumps; lump++, lump_p++) - { - const char *name = lump_p->name; - if (name[0] == 'M' && name[1] == 'A' && name[2] == 'P' && name[5]=='\0') - { - INT16 mapnum = (INT16)G_MapNumber(name); - P_ScanThings(mapnum, wadnum, lump + ML_THINGS); - } - } - } -#endif } /** Compute MD5 message digest for bytes read from STREAM of this filname.