diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 062cfd535..87509a98d 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1554,7 +1554,7 @@ static void SV_SendServerInfo(INT32 node, tic_t servertime) CopyCaretColors(netbuffer->u.serverinfo.servername, cv_servername.string, MAXSERVERNAME); - strncpy(netbuffer->u.serverinfo.mapname, G_BuildMapName(gamemap), 7); + //strncpy(netbuffer->u.serverinfo.mapname, G_BuildMapName(gamemap), 7); M_Memcpy(netbuffer->u.serverinfo.mapmd5, mapmd5, 16); diff --git a/src/d_main.c b/src/d_main.c index e50a16c83..9c84f19db 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1752,14 +1752,11 @@ void D_SRB2Main(void) if (server && !M_CheckParm("+map")) { - // Prevent warping to nonexistent levels - if (W_CheckNumForName(G_BuildMapName(pstartmap)) == LUMPERROR) - I_Error("Could not warp to %s (map not found)\n", G_BuildMapName(pstartmap)); // Prevent warping to locked levels // ... unless you're in a dedicated server. Yes, technically this means you can view any level by // running a dedicated server and joining it yourself, but that's better than making dedicated server's // lives hell. - else if (!dedicated && M_MapLocked(pstartmap)) + if (!dedicated && M_MapLocked(pstartmap)) I_Error("You need to unlock this level before you can warp to it!\n"); else { diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 5c7705a42..6d0bd002b 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2347,7 +2347,7 @@ void D_MapChange(INT32 mapnum, INT32 newgametype, boolean pencoremode, boolean r if (delay != 2) { UINT8 flags = 0; - I_Assert(W_CheckNumForName(G_BuildMapName(mapnum)) != LUMPERROR); + //I_Assert(W_CheckNumForName(G_BuildMapName(mapnum)) != LUMPERROR); buf_p = buf; if (pencoremode) flags |= 1; diff --git a/src/discord.c b/src/discord.c index 42b4d91e4..9319095aa 100644 --- a/src/discord.c +++ b/src/discord.c @@ -576,7 +576,8 @@ void DRPC_UpdatePresence(void) if ((gamemap >= 1 && gamemap <= 60) // supported race maps || (gamemap >= 136 && gamemap <= 164)) // supported battle maps { - snprintf(mapimg, 8, "%s", G_BuildMapName(gamemap)); + //FIXME + //snprintf(mapimg, 8, "%s", G_BuildMapName(gamemap)); strlwr(mapimg); discordPresence.largeImageKey = mapimg; // Map image } diff --git a/src/f_finale.c b/src/f_finale.c index d127a2359..84afbdff4 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -2104,6 +2104,7 @@ void F_TitleScreenTicker(boolean run) //static boolean use_netreplay = false; char dname[9]; + char *dname2 = dname; lumpnum_t l; const char *mapname; UINT8 numstaff; @@ -2146,7 +2147,7 @@ void F_TitleScreenTicker(boolean run) mapname = G_BuildMapName(G_RandMap(TOL_RACE, -2, false, 0, false, NULL)+1); numstaff = 1; - while (numstaff < 99 && (l = W_CheckNumForName(va("%sS%02u",mapname,numstaff+1))) != LUMPERROR) + while (numstaff < 99 && (l = W_CheckNumForLongName(va("%sS%02u",mapname,numstaff+1))) != LUMPERROR) numstaff++; #if 0 // turns out this isn't how we're gonna organise 'em @@ -2167,7 +2168,7 @@ void F_TitleScreenTicker(boolean run) #endif // Setup demo name - snprintf(dname, 9, "%sS%02u", mapname, numstaff); + dname2 = Z_StrDup(va("%sS%02u", mapname, numstaff)); /*if ((l = W_CheckNumForName(dname)) == LUMPERROR) -- we KNOW it exists now { @@ -2180,7 +2181,12 @@ loadreplay: demo.title = demo.fromtitle = true; demo.ignorefiles = true; demo.loadfiles = false; - G_DoPlayDemo(dname); + G_DoPlayDemo(dname2); + + if (dname2 != dname) + { + Z_Free(dname2); + } } } diff --git a/src/g_game.c b/src/g_game.c index c4c00aee0..65b6f1176 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1201,7 +1201,8 @@ void G_DoLoadLevel(boolean resetplayer) // cleanup if (titlemapinaction == TITLEMAP_LOADING) { - if (W_CheckNumForName(G_BuildMapName(gamemap)) == LUMPERROR) + //if (W_CheckNumForName(G_BuildMapName(gamemap)) == LUMPERROR) + if (gamemap < 1 || gamemap > nummapheaders) { titlemap = 0; // let's not infinite recursion ok Command_ExitGame_f(); @@ -3262,7 +3263,7 @@ tryagain: if (pprevmap == -2) // title demo hack { lumpnum_t l; - if ((l = W_CheckNumForName(va("%sS01",G_BuildMapName(ix+1)))) == LUMPERROR) + if ((l = W_CheckNumForLongName(va("%sS01",G_BuildMapName(ix+1)))) == LUMPERROR) continue; } @@ -3513,7 +3514,7 @@ static void G_DoCompleted(void) cm = nextmap; //Start the loop again so that the error checking below is executed. //Make sure the map actually exists before you try to go to it! - if ((W_CheckNumForName(G_BuildMapName(cm + 1)) == LUMPERROR)) + if (cm < 0 || cm >= nummapheaders) { CONS_Alert(CONS_ERROR, M_GetText("Next map given (MAP %d) doesn't exist! Reverting to MAP01.\n"), cm+1); cm = 0; diff --git a/src/k_hud.c b/src/k_hud.c index 42c7fd7c2..fb89de464 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -2761,10 +2761,10 @@ static void K_drawKartMinimap(void) if (stplyr != &players[displayplayers[0]]) return; - lumpnum = W_CheckNumForName(va("%sR", G_BuildMapName(gamemap))); + lumpnum = W_CheckNumForLongName(va("%sR", G_BuildMapName(gamemap))); if (lumpnum != -1) - AutomapPic = W_CachePatchName(va("%sR", G_BuildMapName(gamemap)), PU_HUDGFX); + AutomapPic = W_CachePatchNum(lumpnum, PU_HUDGFX); else return; // no pic, just get outta here diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 2180012b0..a60215537 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -815,10 +815,10 @@ static int libd_drawOnMinimap(lua_State *L) if (stplyr != &players[displayplayers[0]]) return 0; - lumpnum = W_CheckNumForName(va("%sR", G_BuildMapName(gamemap))); + lumpnum = W_CheckNumForLongName(va("%sR", G_BuildMapName(gamemap))); if (lumpnum != -1) - AutomapPic = W_CachePatchName(va("%sR", G_BuildMapName(gamemap)), PU_HUDGFX); + AutomapPic = W_CachePatchNum(lumpnum, PU_HUDGFX); else return 0; // no pic, just get outta here diff --git a/src/m_cheat.c b/src/m_cheat.c index ff5f86968..e929ba3d5 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -1165,7 +1165,8 @@ void Command_Writethings_f(void) REQUIRE_SINGLEPLAYER; REQUIRE_OBJECTPLACE; - P_WriteThings(W_GetNumForName(G_BuildMapName(gamemap)) + ML_THINGS); + //FIXME? + //P_WriteThings(W_GetNumForName(G_BuildMapName(gamemap)) + ML_THINGS); } void Command_ObjectPlace_f(void) diff --git a/src/m_menu.c b/src/m_menu.c index 32d82f8f6..9d01961ed 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2218,7 +2218,7 @@ static void Dummystaff_OnChange(void) dummystaffname[0] = '\0'; - if ((l = W_CheckNumForName(va("%sS01",G_BuildMapName(cv_nextmap.value)))) == LUMPERROR) + if ((l = W_CheckNumForLongName(va("%sS01",G_BuildMapName(cv_nextmap.value)))) == LUMPERROR) { CV_StealthSetValue(&cv_dummystaff, 0); return; @@ -2227,7 +2227,7 @@ static void Dummystaff_OnChange(void) { char *temp = dummystaffname; UINT8 numstaff = 1; - while (numstaff < 99 && (l = W_CheckNumForName(va("%sS%02u",G_BuildMapName(cv_nextmap.value),numstaff+1))) != LUMPERROR) + while (numstaff < 99 && (l = W_CheckNumForLongName(va("%sS%02u",G_BuildMapName(cv_nextmap.value),numstaff+1))) != LUMPERROR) numstaff++; if (cv_dummystaff.value < 1) @@ -2235,7 +2235,7 @@ static void Dummystaff_OnChange(void) else if (cv_dummystaff.value > numstaff) CV_StealthSetValue(&cv_dummystaff, 1); - if ((l = W_CheckNumForName(va("%sS%02u",G_BuildMapName(cv_nextmap.value), cv_dummystaff.value))) == LUMPERROR) + if ((l = W_CheckNumForLongName(va("%sS%02u",G_BuildMapName(cv_nextmap.value), cv_dummystaff.value))) == LUMPERROR) return; // shouldn't happen but might as well check... G_UpdateStaffGhostName(l); @@ -5524,7 +5524,7 @@ static void DrawReplayHutReplayInfo(void) // A 160x100 image of the level as entry MAPxxP //CONS_Printf("%d %s\n", demolist[dir_on[menudepthleft]].map, G_BuildMapName(demolist[dir_on[menudepthleft]].map)); - lumpnum = W_CheckNumForName(va("%sP", G_BuildMapName(demolist[dir_on[menudepthleft]].map))); + lumpnum = W_CheckNumForLongName(va("%sP", G_BuildMapName(demolist[dir_on[menudepthleft]].map))); if (lumpnum != LUMPERROR) patch = W_CachePatchNum(lumpnum, PU_CACHE); else @@ -6187,15 +6187,10 @@ static boolean M_ExitPandorasBox(void) static void M_ChangeLevel(INT32 choice) { - char mapname[6]; (void)choice; - strlcpy(mapname, G_BuildMapName(cv_nextmap.value), sizeof (mapname)); - strlwr(mapname); - mapname[5] = '\0'; - M_ClearMenus(true); - COM_BufAddText(va("map %s -gametype \"%s\"\n", mapname, cv_newgametype.string)); + COM_BufAddText(va("map %d -gametype \"%s\"\n", cv_nextmap.value, cv_newgametype.string)); } static void M_ConfirmSpectate(INT32 choice) @@ -8878,7 +8873,7 @@ static void M_DrawLevelSelectOnly(boolean leftfade, boolean rightfade) // A 160x100 image of the level as entry MAPxxP if (cv_nextmap.value) { - lumpnum = W_CheckNumForName(va("%sP", G_BuildMapName(cv_nextmap.value))); + lumpnum = W_CheckNumForLongName(va("%sP", G_BuildMapName(cv_nextmap.value))); if (lumpnum != LUMPERROR) PictureOfLevel = W_CachePatchNum(lumpnum, PU_CACHE); else @@ -8944,7 +8939,7 @@ static void M_DrawLevelSelectOnly(boolean leftfade, boolean rightfade) // A 160x100 image of the level as entry MAPxxP if (i+1) { - lumpnum = W_CheckNumForName(va("%sP", G_BuildMapName(i+1))); + lumpnum = W_CheckNumForLongName(va("%sP", G_BuildMapName(i+1))); if (lumpnum != LUMPERROR) PictureOfLevel = W_CachePatchNum(lumpnum, PU_CACHE); else @@ -8982,7 +8977,7 @@ static void M_DrawLevelSelectOnly(boolean leftfade, boolean rightfade) // A 160x100 image of the level as entry MAPxxP if (i+1) { - lumpnum = W_CheckNumForName(va("%sP", G_BuildMapName(i+1))); + lumpnum = W_CheckNumForLongName(va("%sP", G_BuildMapName(i+1))); if (lumpnum != LUMPERROR) PictureOfLevel = W_CachePatchNum(lumpnum, PU_CACHE); else diff --git a/src/m_misc.c b/src/m_misc.c index cd8a35cba..177f2cd33 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -799,9 +799,11 @@ static void M_PNGText(png_structp png_ptr, png_infop png_info_ptr, PNG_CONST png break; } +#if 0 if (gamestate == GS_LEVEL) snprintf(maptext, 8, "%s", G_BuildMapName(gamemap)); else +#endif snprintf(maptext, 8, "Unknown"); if (gamestate == GS_LEVEL && mapheaderinfo[gamemap-1]->lvlttl[0] != '\0') @@ -2647,4 +2649,4 @@ const char * M_Ftrim (double f) dig[i + 1] = '\0'; return &dig[1];/* skip the 0 */ } -} \ No newline at end of file +} diff --git a/src/p_setup.c b/src/p_setup.c index d44b477bc..c0d7e4afa 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -367,7 +367,7 @@ static void P_ClearSingleMapHeaderInfo(INT16 i) mapheaderinfo[num]->ssspheres = 1; mapheaderinfo[num]->gravity = DEFAULT_GRAVITY; mapheaderinfo[num]->keywords[0] = '\0'; - snprintf(mapheaderinfo[num]->musname, 7, "%sM", G_BuildMapName(i)); + sprintf(mapheaderinfo[num]->musname, "%.5sM", G_BuildMapName(i)); mapheaderinfo[num]->musname[6] = 0; mapheaderinfo[num]->mustrack = 0; mapheaderinfo[num]->muspos = 0; @@ -3671,7 +3671,7 @@ static void P_LoadRecordGhosts(void) { lumpnum_t l; UINT8 j = 1; - while (j <= 99 && (l = W_CheckNumForName(va("%sS%02u",G_BuildMapName(gamemap),j))) != LUMPERROR) + while (j <= 99 && (l = W_CheckNumForLongName(va("%sS%02u",G_BuildMapName(gamemap),j))) != LUMPERROR) { G_AddGhost(va("%sS%02u",G_BuildMapName(gamemap),j)); j++; @@ -3774,7 +3774,7 @@ static void P_InitGametype(void) { static char buf[256]; char *path; - sprintf(buf, "media"PATHSEP"replay"PATHSEP"online"PATHSEP"%d-%s", (int) (time(NULL)), G_BuildMapName(gamemap)); + snprintf(buf, sizeof buf, "media"PATHSEP"replay"PATHSEP"online"PATHSEP"%d-%s", (int) (time(NULL)), G_BuildMapName(gamemap)); path = va("%s"PATHSEP"media"PATHSEP"replay"PATHSEP"online", srb2home); M_MkdirEach(path, M_PathParts(path) - 4, 0755); @@ -4004,12 +4004,12 @@ boolean P_LoadLevel(boolean fromnetsave) // internal game map maplumpname = G_BuildMapName(gamemap); - lastloadedmaplumpnum = W_CheckNumForName(maplumpname); + lastloadedmaplumpnum = W_CheckNumForMap(maplumpname); if (lastloadedmaplumpnum == LUMPERROR) I_Error("Map %s not found.\n", maplumpname); R_ReInitColormaps(mapheaderinfo[gamemap-1]->palette, - (encoremode ? W_CheckNumForName(va("%sE", maplumpname)) : LUMPERROR)); + (encoremode ? W_CheckNumForLongName(va("%sE", maplumpname)) : LUMPERROR)); CON_SetupBackColormap(); // SRB2 determines the sky texture to be used depending on the map header. diff --git a/src/p_spec.c b/src/p_spec.c index a86c54c07..b859d4588 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2571,6 +2571,8 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 415: // Run a script + // FIXME: cursed +#if 0 if (cv_runscripts.value) { INT32 scrnum; @@ -2605,6 +2607,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) else COM_BufInsertText(W_CacheLumpNum(lumpnum, PU_CACHE)); } +#endif break; case 416: // Spawn adjustable fire flicker diff --git a/src/s_sound.c b/src/s_sound.c index f17d5bdd2..79c301e70 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -2627,6 +2627,7 @@ void S_StartEx(boolean reset) music_stack_fadein = JINGLEPOSTFADE; } +// TODO: fix this function, needs better support for map names static void Command_Tunes_f(void) { const char *tunearg; diff --git a/src/y_inter.c b/src/y_inter.c index 5f5bb5f05..34b58c4a7 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -1813,9 +1813,9 @@ void Y_StartVote(void) levelinfo[i].gts = NULL; // set up the pic - lumpnum = W_CheckNumForName(va("%sP", G_BuildMapName(votelevels[i][0]+1))); + lumpnum = W_CheckNumForLongName(va("%sP", G_BuildMapName(votelevels[i][0]+1))); if (lumpnum != LUMPERROR) - levelinfo[i].pic = W_CachePatchName(va("%sP", G_BuildMapName(votelevels[i][0]+1)), PU_STATIC); + levelinfo[i].pic = W_CachePatchNum(lumpnum, PU_STATIC); else levelinfo[i].pic = W_CachePatchName("BLANKLVL", PU_STATIC); }