pre alloc MapName on mapload and unarchive
This commit is contained in:
1 parent
06bcd3ffca
commit
1b027e169a
14 files changed
+47
-33
No files matched your search
+2
-2
@@ -1454,7 +1454,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, globalmapname, 7);
|
||||
|
||||
M_Memcpy(netbuffer->u.serverinfo.mapmd5, mapmd5, 16);
|
||||
|
||||
@@ -1839,7 +1839,7 @@ static void CL_LoadReceivedSavegame(boolean reloading)
|
||||
{
|
||||
if (!reloading)
|
||||
{
|
||||
CON_LogMessage(va(M_GetText("Map is now \"%s"), G_BuildMapName(gamemap)));
|
||||
CON_LogMessage(va(M_GetText("Map is now \"%s"), globalmapname));
|
||||
if (strlen(mapheaderinfo[gamemap-1]->lvlttl) > 0)
|
||||
{
|
||||
CON_LogMessage(va(": %s", mapheaderinfo[gamemap-1]->lvlttl));
|
||||
|
||||
+5
-5
@@ -5010,16 +5010,16 @@ static void Command_Showmap_f(void)
|
||||
if (mapheaderinfo[gamemap-1]->zonttl[0] && !(mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE))
|
||||
{
|
||||
if (mapheaderinfo[gamemap-1]->actnum[0])
|
||||
CONS_Printf("%s (%d): %s %s %s\n", G_BuildMapName(gamemap), gamemap, mapheaderinfo[gamemap-1]->lvlttl, mapheaderinfo[gamemap-1]->zonttl, mapheaderinfo[gamemap-1]->actnum);
|
||||
CONS_Printf("%s (%d): %s %s %s\n", globalmapname, gamemap, mapheaderinfo[gamemap-1]->lvlttl, mapheaderinfo[gamemap-1]->zonttl, mapheaderinfo[gamemap-1]->actnum);
|
||||
else
|
||||
CONS_Printf("%s (%d): %s %s\n", G_BuildMapName(gamemap), gamemap, mapheaderinfo[gamemap-1]->lvlttl, mapheaderinfo[gamemap-1]->zonttl);
|
||||
CONS_Printf("%s (%d): %s %s\n", globalmapname, gamemap, mapheaderinfo[gamemap-1]->lvlttl, mapheaderinfo[gamemap-1]->zonttl);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mapheaderinfo[gamemap-1]->actnum[0])
|
||||
CONS_Printf("%s (%d): %s %s\n", G_BuildMapName(gamemap), gamemap, mapheaderinfo[gamemap-1]->lvlttl, mapheaderinfo[gamemap-1]->actnum);
|
||||
CONS_Printf("%s (%d): %s %s\n", globalmapname, gamemap, mapheaderinfo[gamemap-1]->lvlttl, mapheaderinfo[gamemap-1]->actnum);
|
||||
else
|
||||
CONS_Printf("%s (%d): %s\n", G_BuildMapName(gamemap), gamemap, mapheaderinfo[gamemap-1]->lvlttl);
|
||||
CONS_Printf("%s (%d): %s\n", globalmapname, gamemap, mapheaderinfo[gamemap-1]->lvlttl);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -5034,7 +5034,7 @@ static void Command_Mapmd5_f(void)
|
||||
char md5tmp[33];
|
||||
for (i = 0; i < 16; ++i)
|
||||
sprintf(&md5tmp[i*2], "%02x", mapmd5[i]);
|
||||
CONS_Printf("%s: %s\n", G_BuildMapName(gamemap), md5tmp);
|
||||
CONS_Printf("%s: %s\n", globalmapname, md5tmp);
|
||||
}
|
||||
else
|
||||
CONS_Printf(M_GetText("You must be in a level to use this.\n"));
|
||||
|
||||
+1
-1
@@ -547,7 +547,7 @@ 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));
|
||||
snprintf(mapimg, 8, "%s", globalmapname);
|
||||
strlwr(mapimg);
|
||||
discordPresence.largeImageKey = mapimg; // Map image
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
// Selected by user.
|
||||
extern INT16 gamemap;
|
||||
extern char *maptitle;
|
||||
extern const char *globalmapname;
|
||||
extern char mapmusname[7];
|
||||
extern UINT16 mapmusflags;
|
||||
extern UINT32 mapmusposition;
|
||||
|
||||
+14
-7
@@ -92,6 +92,7 @@ UINT32 mapmusresume;
|
||||
|
||||
INT16 gamemap = 1;
|
||||
char *maptitle = NULL;
|
||||
const char *globalmapname = NULL;
|
||||
INT16 maptol;
|
||||
UINT8 globalweather = 0;
|
||||
INT32 curWeather = PRECIP_NONE;
|
||||
@@ -570,6 +571,14 @@ INT16 rw_maximums[NUM_WEAPONS] =
|
||||
50 // MAX_RAIL
|
||||
};
|
||||
|
||||
void G_AllocMapTitles(INT16 map)
|
||||
{
|
||||
if (maptitle)
|
||||
Z_Free(maptitle);
|
||||
maptitle = G_BuildMapTitle(map);
|
||||
globalmapname = G_BuildMapName(map);
|
||||
}
|
||||
|
||||
// Allocation for time and nights data
|
||||
void G_AllocMainRecordData(INT16 i)
|
||||
{
|
||||
@@ -4249,9 +4258,7 @@ void G_InitNew(UINT8 pencoremode, const char *mapname, boolean resetplayer, bool
|
||||
|
||||
gamemap = (INT16)M_MapNumber(mapname[3], mapname[4]); // get xx out of MAPxx
|
||||
|
||||
if (maptitle)
|
||||
Z_Free(maptitle);
|
||||
maptitle = G_BuildMapTitle(gamemap);
|
||||
G_AllocMapTitles(gamemap);
|
||||
|
||||
// gamemap changed; we assume that its map header is always valid,
|
||||
// so make it so
|
||||
@@ -4278,7 +4285,7 @@ void G_InitNew(UINT8 pencoremode, const char *mapname, boolean resetplayer, bool
|
||||
|
||||
if (netgame)
|
||||
{
|
||||
CON_LogMessage(va(M_GetText("Map is now \"%s"), G_BuildMapName(gamemap)));
|
||||
CON_LogMessage(va(M_GetText("Map is now \"%s"), globalmapname));
|
||||
if (maptitle)
|
||||
CON_LogMessage(va(": %s", maptitle));
|
||||
CON_LogMessage("\"\n");
|
||||
@@ -7954,7 +7961,7 @@ void G_DoPlayMetal(void)
|
||||
thinker_t *th;
|
||||
|
||||
// it's an internal demo
|
||||
if ((l = W_CheckNumForName(va("%sMS",G_BuildMapName(gamemap)))) == LUMPERROR)
|
||||
if ((l = W_CheckNumForName(va("%sMS", globalmapname))) == LUMPERROR)
|
||||
{
|
||||
CONS_Alert(CONS_WARNING, M_GetText("No bot recording for this map.\n"));
|
||||
return;
|
||||
@@ -8059,13 +8066,13 @@ ATTRNORETURN void FUNCNORETURN G_StopMetalRecording(void)
|
||||
WRITEUINT8(demobuf.p, DEMOMARKER); // add the demo end marker
|
||||
md5_buffer((char *)p+16, demobuf.p - (p+16), (void *)p); // make a checksum of everything after the checksum in the file.
|
||||
#endif
|
||||
saved = FIL_WriteFile(va("%sMS.LMP", G_BuildMapName(gamemap)), demobuf.buffer, demobuf.p - demobuf.buffer); // finally output the file.
|
||||
saved = FIL_WriteFile(va("%sMS.LMP", globalmapname), demobuf.buffer, demobuf.p - demobuf.buffer); // finally output the file.
|
||||
}
|
||||
free(demobuf.buffer);
|
||||
demobuf.buffer = NULL;
|
||||
metalrecording = false;
|
||||
if (saved)
|
||||
I_Error("Saved to %sMS.LMP", G_BuildMapName(gamemap));
|
||||
I_Error("Saved to %sMS.LMP", globalmapname);
|
||||
I_Error("Failed to save demo!");
|
||||
}
|
||||
|
||||
|
||||
@@ -337,6 +337,8 @@ void G_WriteMetalTic(mobj_t *metal);
|
||||
void G_SaveMetal(UINT8 **buffer);
|
||||
void G_LoadMetal(UINT8 **buffer);
|
||||
|
||||
void G_AllocMapTitles(INT16 map);
|
||||
|
||||
// Your naming conventions are stupid and useless.
|
||||
// There is no conflict here.
|
||||
typedef struct demoghost {
|
||||
|
||||
+3
-3
@@ -679,10 +679,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_CheckNumForName(va("%sR", globalmapname));
|
||||
|
||||
if (lumpnum != -1)
|
||||
AutomapPic = W_CachePatchName(va("%sR", G_BuildMapName(gamemap)), PU_HUDGFX);
|
||||
AutomapPic = W_CachePatchName(va("%sR", globalmapname), PU_HUDGFX);
|
||||
else
|
||||
return 0; // no pic, just get outta here
|
||||
|
||||
@@ -1612,4 +1612,4 @@ void LUAh_VoteHUD(huddrawlist_h list)
|
||||
|
||||
lua_pushlightuserdata(gL, NULL);
|
||||
lua_setfield(gL, LUA_REGISTRYINDEX, "HUD_DRAW_LIST");
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1226,7 +1226,7 @@ void Command_Writethings_f(void)
|
||||
REQUIRE_SINGLEPLAYER;
|
||||
REQUIRE_OBJECTPLACE;
|
||||
|
||||
P_WriteThings(W_GetNumForName(G_BuildMapName(gamemap)) + ML_THINGS);
|
||||
P_WriteThings(W_GetNumForName(globalmapname) + ML_THINGS);
|
||||
}
|
||||
|
||||
void Command_ObjectPlace_f(void)
|
||||
|
||||
+3
-3
@@ -793,7 +793,7 @@ static void M_PNGText(png_structp png_ptr, png_infop png_info_ptr, PNG_CONST png
|
||||
}
|
||||
|
||||
if (gamestate == GS_LEVEL)
|
||||
snprintf(maptext, 8, "%s", G_BuildMapName(gamemap));
|
||||
snprintf(maptext, 8, "%s", globalmapname);
|
||||
else
|
||||
snprintf(maptext, 8, "Unknown");
|
||||
|
||||
@@ -1616,11 +1616,11 @@ void M_MinimapGenerate(void)
|
||||
return;
|
||||
}
|
||||
|
||||
filepath = va("%s" PATHSEP "%s-MINIMAP-%d.png", srb2home, G_BuildMapName(gamemap), mul);
|
||||
filepath = va("%s" PATHSEP "%s-MINIMAP-%d.png", srb2home, globalmapname, mul);
|
||||
}
|
||||
else
|
||||
{
|
||||
filepath = va("%s" PATHSEP "%s-MINIMAP.png", srb2home, G_BuildMapName(gamemap));
|
||||
filepath = va("%s" PATHSEP "%s-MINIMAP.png", srb2home, globalmapname);
|
||||
}
|
||||
|
||||
minigen = AM_MinimapGenerate(mul);
|
||||
|
||||
+5
-1
@@ -3186,6 +3186,8 @@ static inline void P_UnArchiveSPGame(savebuffer_t *save, INT16 mapoverride)
|
||||
else
|
||||
gamecomplete = false;
|
||||
|
||||
G_AllocMapTitles(gamemap);
|
||||
|
||||
// gamemap changed; we assume that its map header is always valid,
|
||||
// so make it so
|
||||
if(!mapheaderinfo[gamemap-1])
|
||||
@@ -3330,6 +3332,8 @@ FUNCINLINE static ATTRINLINE boolean P_NetUnArchiveMisc(savebuffer_t *save, bool
|
||||
|
||||
gamemap = READINT16(save->p);
|
||||
|
||||
G_AllocMapTitles(gamemap);
|
||||
|
||||
// gamemap changed; we assume that its map header is always valid,
|
||||
// so make it so
|
||||
if(!mapheaderinfo[gamemap-1])
|
||||
@@ -3503,7 +3507,7 @@ boolean P_LoadGame(savebuffer_t *save, INT16 mapoverride)
|
||||
}
|
||||
|
||||
// Only do this after confirming savegame is ok
|
||||
G_DeferedInitNew(false, G_BuildMapName(gamemap), savedata.skin, 0, true);
|
||||
G_DeferedInitNew(false, globalmapname, savedata.skin, 0, true);
|
||||
COM_BufAddText("dummyconsvar 1\n"); // G_DeferedInitNew doesn't do this
|
||||
|
||||
return true;
|
||||
|
||||
+7
-7
@@ -2315,7 +2315,7 @@ static void P_LoadRecordGhosts(void)
|
||||
if (!gpath)
|
||||
return;
|
||||
|
||||
sprintf(gpath,"%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s", srb2home, timeattackfolder, G_BuildMapName(gamemap));
|
||||
sprintf(gpath,"%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s", srb2home, timeattackfolder, globalmapname);
|
||||
|
||||
// Best Time ghost
|
||||
if (cv_ghost_besttime.value)
|
||||
@@ -2365,9 +2365,9 @@ 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_CheckNumForName(va("%sS%02u", globalmapname, j))) != LUMPERROR)
|
||||
{
|
||||
G_AddGhost(va("%sS%02u",G_BuildMapName(gamemap),j));
|
||||
G_AddGhost(va("%sS%02u", globalmapname, j));
|
||||
j++;
|
||||
}
|
||||
}
|
||||
@@ -2450,10 +2450,10 @@ static void P_InitMinimapInfo(void)
|
||||
fixed_t a;
|
||||
fixed_t b;
|
||||
node_t *bsp = &nodes[numnodes-1];
|
||||
lumpnum = W_CheckNumForName(va("%sR", G_BuildMapName(gamemap)));
|
||||
lumpnum = W_CheckNumForName(va("%sR", globalmapname));
|
||||
|
||||
if (lumpnum != -1)
|
||||
minimapinfo.minimap_pic = W_CachePatchName(va("%sR", G_BuildMapName(gamemap)), PU_HUDGFX);
|
||||
minimapinfo.minimap_pic = W_CachePatchName(va("%sR", globalmapname), PU_HUDGFX);
|
||||
|
||||
minimapinfo.mapthingcount = 0;
|
||||
// TODO iterate over mapthings to look for possible user-defined bounds
|
||||
@@ -2714,7 +2714,7 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate)
|
||||
}
|
||||
|
||||
// internal game map
|
||||
maplumpname = G_BuildMapName(gamemap);
|
||||
maplumpname = globalmapname;
|
||||
lastloadedmaplumpnum = W_CheckNumForName(maplumpname);
|
||||
if (lastloadedmaplumpnum == INT16_MAX)
|
||||
I_Error("Map %s not found.\n", maplumpname);
|
||||
@@ -2823,7 +2823,7 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate)
|
||||
//Ensure dedis only record a replay if there is a player at the start of the map, otherwise we get invalid replays!
|
||||
if (!demo.playback && multiplayer && D_NumPlayers()) {
|
||||
static char buf[256];
|
||||
sprintf(buf, "replay"PATHSEP"online"PATHSEP"%d-%s", (int) (time(NULL)), G_BuildMapName(gamemap));
|
||||
sprintf(buf, "replay"PATHSEP"online"PATHSEP"%d-%s", (int) (time(NULL)), globalmapname);
|
||||
|
||||
I_mkdir(va("%s"PATHSEP"replay", srb2home), 0755);
|
||||
I_mkdir(va("%s"PATHSEP"replay"PATHSEP"online", srb2home), 0755);
|
||||
|
||||
+1
-1
@@ -2308,7 +2308,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
|
||||
lumpnum_t lumpnum;
|
||||
char newname[9];
|
||||
|
||||
strcpy(newname, G_BuildMapName(gamemap));
|
||||
strcpy(newname, globalmapname);
|
||||
newname[0] = 'S';
|
||||
newname[1] = 'C';
|
||||
newname[2] = 'R';
|
||||
|
||||
+1
-1
@@ -351,7 +351,7 @@ static void write_backtrace(bt_crash_reason_t reason)
|
||||
fprintf(out, "Compiled: %s %s, commit %s, branch %s\n", compdate, comptime, comprevision, compbranch);
|
||||
|
||||
if (gamestate == GS_LEVEL)
|
||||
fprintf(out, "Game map: %s\n", G_BuildMapName(gamemap));
|
||||
fprintf(out, "Game map: %s\n", globalmapname);
|
||||
|
||||
fprintf(out, "Time of crash: %s\n", asctime(timeinfo));
|
||||
|
||||
|
||||
+1
-1
@@ -728,7 +728,7 @@ static void Y_UpdateRecordReplays(void)
|
||||
if ((gpath = malloc(glen)) == NULL)
|
||||
I_Error("Out of memory for replay filepath\n");
|
||||
|
||||
sprintf(gpath,"%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s", srb2home, timeattackfolder, G_BuildMapName(gamemap));
|
||||
sprintf(gpath,"%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s", srb2home, timeattackfolder, globalmapname);
|
||||
snprintf(lastdemo, 255, "%s-%s-last.lmp", gpath, cv_chooseskin.string);
|
||||
|
||||
if (FIL_FileExists(lastdemo))
|
||||
|
||||
Reference in new issue
Block a user