diff --git a/src/am_map.c b/src/am_map.c index 1478b37f9..70a78a1da 100644 --- a/src/am_map.c +++ b/src/am_map.c @@ -197,7 +197,7 @@ static fixed_t scale_mtof = (fixed_t)INITSCALEMTOF; // used by FTOM to scale from frame-buffer-to-map coords (=1/scale_mtof) static fixed_t scale_ftom; -static player_t *plr; // the player represented by an arrow +static player_t *plr = NULL; // the player represented by an arrow static boolean followplayer = true; // specifies whether to follow the player around @@ -237,7 +237,7 @@ static inline void AM_restoreScaleAndLoc(void) m_x = old_m_x; m_y = old_m_y; } - else + else if (plr && plr->mo) { m_x = (plr->mo->x >> FRACTOMAPBITS) - m_w/2; m_y = (plr->mo->y >> FRACTOMAPBITS) - m_h/2; @@ -319,7 +319,7 @@ static void AM_initVariables(void) plr = &players[pnum]; - if (plr != NULL && plr->mo != NULL) + if (plr && plr->mo) { m_x = (plr->mo->x >> FRACTOMAPBITS) - m_w/2; m_y = (plr->mo->y >> FRACTOMAPBITS) - m_h/2; @@ -599,6 +599,9 @@ static inline void AM_changeWindowScale(void) static inline void AM_doFollowPlayer(void) { + if (!plr || !plr->mo) + return; + if (f_oldloc.x != plr->mo->x || f_oldloc.y != plr->mo->y) { m_x = FTOM(MTOF(plr->mo->x >> FRACTOMAPBITS)) - m_w/2; diff --git a/src/command.c b/src/command.c index e7dd9cc01..4e43e2cb5 100644 --- a/src/command.c +++ b/src/command.c @@ -240,7 +240,6 @@ void COM_ImmedExecute(const char *ptext) while (i < strlen(ptext)) { - quotes = 0; for (j = 0; i < strlen(ptext); i++,j++) { diff --git a/src/d_netcmd.c b/src/d_netcmd.c index b4329a9b2..b55aac106 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2776,7 +2776,7 @@ static void Command_Map_f(void) // G_TOLFlag handles both multiplayer gametype and ignores it for !multiplayer else { - if (!mapheaderinfo[newmapnum-1] || mapheaderinfo[newmapnum-1] == NULL) + if (!mapheaderinfo[newmapnum-1]) { CONS_Alert(CONS_WARNING, M_GetText("Invalid mapheaderinfo for Course %s (%s)\n"), realmapname, G_BuildMapName(newmapnum)); Z_Free(realmapname); @@ -3030,9 +3030,14 @@ static void Command_ReplayMarker(void) adjustedleveltime = 0; char *title = G_BuildMapTitle(gamemap); - snprintf(demo.titlename, 64, "%s [%i:%02d/%.5s]", title, G_TicsToMinutes(adjustedleveltime, false), G_TicsToSeconds(adjustedleveltime), modeattacking ? "Record Attack" : connectedservername); + if (title) + { + snprintf(demo.titlename, 64, "%s [%i:%02d/%.5s]", title, G_TicsToMinutes(adjustedleveltime, false), G_TicsToSeconds(adjustedleveltime), modeattacking ? "Record Attack" : connectedservername); Z_Free(title); + } + else + snprintf(demo.titlename, 64, "[%i:%02d/%.5s]", G_TicsToMinutes(adjustedleveltime, false), G_TicsToSeconds(adjustedleveltime), modeattacking ? "Record Attack" : connectedservername); CONS_Printf("Replay will be saved!\n"); } diff --git a/src/discord.c b/src/discord.c index 158c79f7f..207a249a6 100644 --- a/src/discord.c +++ b/src/discord.c @@ -388,7 +388,7 @@ static void DRPC_GotServerIP(UINT32 address) --------------------------------------------------*/ static const char *DRPC_GetServerIP(void) { - const char *address; + const char *address; // If you're connected if (I_GetNodeAddress && (address = I_GetNodeAddress(servernode)) != NULL) @@ -571,9 +571,15 @@ void DRPC_UpdatePresence(void) { // Map name on tool tip char *title = G_BuildMapTitle(gamemap); - snprintf(mapname, 48, "Map: %s", title); + if (title) + { + snprintf(mapname, 48, "Map: %s", title); + Z_Free(title); + } + else + snprintf(mapname, 48, "Map: UNKNOWN"); + discordPresence.largeImageText = mapname; - Z_Free(title); } if (gamestate == GS_LEVEL && Playing()) diff --git a/src/g_game.c b/src/g_game.c index 9e991fff5..aec589e47 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3998,7 +3998,6 @@ void G_InitNew(UINT8 pencoremode, const char *mapname, boolean resetplayer, bool } } - char *G_BuildMapTitle(INT32 mapnum) { char *title = NULL; @@ -6068,15 +6067,19 @@ void G_BeginRecording(void) char *title = G_BuildMapTitle(gamemap); // Print to a separate temp buffer instead of demo.titlename, so we can use it in M_TextInputSetString - snprintf(demotitlename, 64, "%s - %s", title, modeattacking ? "Time Attack" : connectedservername); + if (title) + { + snprintf(demotitlename, 64, "%s - %s", title, modeattacking ? "Time Attack" : connectedservername); + Z_Free(title); + } + else + snprintf(demotitlename, 64, "%s", modeattacking ? "Time Attack" : connectedservername); // Init just in case it isn't initialized already M_TextInputInit(&demo.titlenameinput, demo.titlename, sizeof(demo.titlename)); // This will indirectly assign to demo.titlename too M_TextInputSetString(&demo.titlenameinput, demotitlename); - - Z_Free(title); } // demo checksum diff --git a/src/m_menu.c b/src/m_menu.c index 43a4a2f15..77930ccdf 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -7167,8 +7167,11 @@ static void DrawReplayHutReplayInfo(void) if (mapheaderinfo[demolist[dir_on[menudepthleft]].map-1]) { char *title = G_BuildMapTitle(demolist[dir_on[menudepthleft]].map); - V_DrawString(x, y, V_SNAPTOTOP|MENUCAPS, title); - Z_Free(title); + if (title) + { + V_DrawString(x, y, V_SNAPTOTOP|MENUCAPS, title); + Z_Free(title); + } } else V_DrawString(x, y, V_SNAPTOTOP|V_ALLOWLOWERCASE|V_TRANSLUCENT, "Level is not loaded."); @@ -8123,6 +8126,9 @@ UINT8 skyRoomMenuTranslations[MAXUNLOCKABLES]; static char *M_GetConditionString(condition_t cond) { + char *title = NULL; + char *response = NULL; + switch(cond.type) { case UC_PLAYTIME: @@ -8149,33 +8155,45 @@ static char *M_GetConditionString(condition_t cond) G_TicsToSeconds(cond.requirement)); case UC_MAPVISITED: { - char *title = G_BuildMapTitle(cond.requirement-1); - char *response = va("Visit %s", title); - Z_Free(title); + title = G_BuildMapTitle(cond.requirement-1); + if (title) + { + response = va("Visit %s", title); + Z_Free(title); + } return response; } case UC_MAPBEATEN: { - char *title = G_BuildMapTitle(cond.requirement-1); - char *response = va("Beat %s", title); - Z_Free(title); + title = G_BuildMapTitle(cond.requirement-1); + if (title) + { + response = va("Beat %s", title); + Z_Free(title); + } return response; } case UC_MAPALLEMERALDS: { - char *title = G_BuildMapTitle(cond.requirement-1); - char *response = va("Beat %s w/ all emeralds", title); - Z_Free(title); + title = G_BuildMapTitle(cond.requirement-1); + if (title) + { + response = va("Beat %s w/ all emeralds", title); + Z_Free(title); + } return response; } case UC_MAPTIME: { - char *title = G_BuildMapTitle(cond.extrainfo1-1); - char *response = va("Beat %s in %i:%02i.%02i", title, - G_TicsToMinutes(cond.requirement, true), - G_TicsToSeconds(cond.requirement), - G_TicsToCentiseconds(cond.requirement)); - Z_Free(title); + title = G_BuildMapTitle(cond.extrainfo1-1); + if (title) + { + response = va("Beat %s in %i:%02i.%02i", title, + G_TicsToMinutes(cond.requirement, true), + G_TicsToSeconds(cond.requirement), + G_TicsToCentiseconds(cond.requirement)); + Z_Free(title); + } return response; } case UC_TOTALEMBLEMS: diff --git a/src/p_setup.c b/src/p_setup.c index b34ed7ad2..5d242591d 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2808,6 +2808,10 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) CON_Drawer(); // let the user know what we are going to do I_FinishUpdate(); // page flip or blit buffer + // Reset the palette + if (rendermode != render_none) + V_SetPaletteLump("PLAYPAL"); + // Initialize sector node list. P_Initsecnode(); @@ -2869,20 +2873,14 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) F_WipeStartScreen(); V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, levelfadecol); F_WipeEndScreen(); - F_RunWipe(wipedefs[(encoremode ? wipe_level_final : wipe_level_toblack)], false); - } - else //dedicated servers - { - F_RunWipe(wipedefs[(encoremode ? wipe_level_final : wipe_level_toblack)], false); } + + F_RunWipe(wipedefs[(encoremode ? wipe_level_final : wipe_level_toblack)], false); } // Reset the palette now all fades have been done if (rendermode != render_none) - { - //V_ResetPaletteCVars(); // dont carry over changed palettes - V_SetPaletteLump(GetPalette()); // Set the level palette - } + V_ReloadPalette(); // Set the level palette // Print "SPEEDING OFF TO [ZONE] [ACT 1]..." /*if (rendermode != render_none) diff --git a/src/s_sound.c b/src/s_sound.c index 5bddcf1d8..1bad6fd88 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -2043,9 +2043,12 @@ static boolean S_SkipIntroMusic(void) char *maptitle = G_BuildMapTitle(gamemap); // Zzz... - // check if menu music is playing, otherwise it may continue playing - if (!stricmp(music.name, "titles") || (maptitle && (!stricmp(maptitle, "Wandering Falls")))) // wandering balls changes its song when the race starts Zzz... - skip = false; + if (maptitle) + { + // check if menu music is playing, otherwise it may continue playing + if (!stricmp(music.name, "titles") || (maptitle && (!stricmp(maptitle, "Wandering Falls")))) // wandering balls changes its song when the race starts Zzz... + skip = false; + } Z_Free(maptitle); diff --git a/src/v_video.c b/src/v_video.c index 0f3306696..7df5cacea 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -457,6 +457,9 @@ static void LoadPalette(const char *lumpname) #endif pLocalPalette[i].s.alpha = 0xFF; + if (!Cubeapply) + continue; + // lerp of colour cubing! if you want, make it smoother yourself V_CubeApply(&pLocalPalette[i].s.red, &pLocalPalette[i].s.green, &pLocalPalette[i].s.blue); }