diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 492dd0ac4..8cb038251 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -841,11 +841,13 @@ static void resynch_write_ctf(resynchend_pak *rst) rst->flagplayer[i] = (SINT8)j; break; } + if (j == MAXPLAYERS) // fine, no I_Error { CONS_Alert(CONS_ERROR, "One of the flags has gone completely missing...\n"); rst->flagplayer[i] = -2; } + continue; } @@ -1135,6 +1137,7 @@ static void CV_SavePlayerNames(UINT8 **p) WRITEUINT8(*p, 0); continue; } + WRITESTRING(*p, player_names[i]); } } @@ -1148,10 +1151,13 @@ static void CV_LoadPlayerNames(UINT8 **p) for (; i < MAXPLAYERS; ++i) { READSTRING(*p, tmp_name); + if (tmp_name[0] == 0) continue; + if (tmp_name[MAXPLAYERNAME]) // overflow detected I_Error("Received bad server config packet when trying to join"); + memcpy(player_names[i], tmp_name, MAXPLAYERNAME+1); } } @@ -2029,6 +2035,7 @@ static void SV_SendSaveGame(INT32 node, boolean resending) P_SaveNetGame(&save, resending); length = save.p - save.buffer; + if (length > SAVEGAMESIZE) { Z_Free(save.buffer); @@ -5401,7 +5408,7 @@ static void PT_ServerCFG(SINT8 node) { maketic = gametic = neededtic = (tic_t)LONG(netbuffer->u.servercfg.gametic); if ((gametype = netbuffer->u.servercfg.gametype) >= NUMGAMETYPES) - I_Error("Bad gametype in cliserv!"); + I_Error("Bad gametype %d in cliserv!", gametype); modifiedgame = netbuffer->u.servercfg.modifiedgame; for (j = 0; j < MAXPLAYERS; j++) adminplayers[j] = netbuffer->u.servercfg.adminplayers[j]; diff --git a/src/doomdef.h b/src/doomdef.h index d4c9d63fa..b57ab0bfb 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -678,7 +678,6 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; #ifndef COMPAT_VANILLA #define SATURNJOIN #define SATURNPAK - #undef SEENAMES #endif #ifdef __cplusplus diff --git a/src/k_kart.c b/src/k_kart.c index e3306c629..eb58a7b62 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -5019,9 +5019,7 @@ static void K_MoveHeldObjects(player_t *player) mobj_t *cur = player->mo->hnext; mobj_t *targ = player->mo; - const boolean ponground = P_IsObjectOnGround(player->mo); - - if (ponground && player->speed > 0) + if (player->speed > 0 && P_IsObjectOnGround(player->mo)) player->kartstuff[k_bananadrag]++; while (!P_MobjWasRemoved(cur)) @@ -5070,7 +5068,8 @@ static void K_MoveHeldObjects(player_t *player) cur->angle = R_PointToAngle2(cur->x, cur->y, targx, targy); - /*if (P_IsObjectOnGround(player->mo) && player->speed > 0 && player->kartstuff[k_bananadrag] > TICRATE + /*if (player->speed > 0 && P_IsObjectOnGround(player->mo) + && player->kartstuff[k_bananadrag] > TICRATE && P_RandomChance(min(FRACUNIT/2, FixedDiv(player->speed, K_GetKartSpeed(player, false))/2))) { if (leveltime & 1) @@ -5079,8 +5078,9 @@ static void K_MoveHeldObjects(player_t *player) targz -= 8*(2*FRACUNIT)/7; }*/ - if (cv_bananajitter.value && ponground - && player->speed > 0 && player->kartstuff[k_bananadrag] > TICRATE) + // "jitter" dragged bananas around + if (cv_bananajitter.value && + player->speed > 0 && P_IsObjectOnGround(player->mo) && player->kartstuff[k_bananadrag] > TICRATE) { const fixed_t halfpspeed = FixedDiv(player->speed, K_GetKartSpeed(player, false))/2; @@ -5581,8 +5581,6 @@ FUNCINLINE static ATTRINLINE void K_SpawnNormalSpeedLines(player_t *player, bool */ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) { - const boolean onground = P_IsObjectOnGround(player->mo); - K_UpdateOffroad(player); K_UpdateEngineSounds(player, cmd); // Thanks, VAda! @@ -5699,7 +5697,7 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) if (player->kartstuff[k_spinouttimer]) { - if ((onground || ((player->kartstuff[k_spinouttype]+1)/2 == 1)) // spinouttype 1 and 2 - explosion and spb + if ((P_IsObjectOnGround(player->mo) || ((player->kartstuff[k_spinouttype]+1)/2 == 1)) // spinouttype 1 and 2 - explosion and spb && (player->kartstuff[k_sneakertimer] == 0)) { player->kartstuff[k_spinouttimer]--; @@ -5798,7 +5796,7 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) if (G_BattleGametype() && player->kartstuff[k_bumper] > 0) player->kartstuff[k_wanted]++; - if (onground) + if (P_IsObjectOnGround(player->mo)) player->kartstuff[k_waterskip] = 0; if (player->kartstuff[k_instashield]) @@ -5842,7 +5840,7 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) if (player->kartstuff[k_comebacktimer]) player->kartstuff[k_comebackmode] = 0; - if (onground && player->kartstuff[k_pogospring]) + if (player->kartstuff[k_pogospring] && P_IsObjectOnGround(player->mo)) { if (P_MobjFlip(player->mo)*player->mo->momz <= 0) player->kartstuff[k_pogospring] = 0; diff --git a/src/m_menu.c b/src/m_menu.c index dc4cbcc87..38b5e2875 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -212,18 +212,20 @@ static INT32 setupm_fakeskin; static INT32 setupm_fakecolor; static UINT8 setupm_pselect = 1; -//variables used for other skin select menus +// variables used for other skin select menus static UINT8 setupm_skinypos; static INT32 setupm_skinselect; static boolean setupm_skinlockedselect; -static UINT8 setupm_playernum; //brap +static UINT8 setupm_playernum; // brap // Addons Menu: Local mode static void M_LocalAddons(INT32 choice); -#define LOCALMODE_KEY (KEY_RALT) static boolean addons_localmode = false; +#define LOCALMODE_KEY (KEY_RALT) +#define AUTOLOAD_KEY (KEY_END) + // // PROTOTYPES // @@ -450,13 +452,13 @@ consvar_t cv_showallmaps = {"showallmaps", "No", CV_SAVE, CV_YesNo, NULL, 0, NUL consvar_t cv_showmusicfilename = {"showmusicfilename", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t serversort_cons_t[] = { - {0,"Ping"}, - {1,"Modified State"}, - {2,"Most Players"}, - {3,"Least Players"}, - {4,"Max Player Slots"}, - {5,"Gametype"}, - {0,NULL} + {0, "Ping"}, + {1, "Modified State"}, + {2, "Most Players"}, + {3, "Least Players"}, + {4, "Max Player Slots"}, + {5, "Gametype"}, + {0, NULL} }; consvar_t cv_serversort = {"serversort", "Ping", CV_CALL, serversort_cons_t, M_SortServerList, 0, NULL, NULL, 0, 0, NULL}; @@ -705,7 +707,7 @@ static void Dummystaff_OnChange(void) dummystaffname[0] = '\0'; - if ((l = W_CheckNumForName(va("%sS01",G_BuildMapName(cv_nextmap.value)))) == LUMPERROR) + if ((l = W_CheckNumForName(va("%sS01", G_BuildMapName(cv_nextmap.value)))) == LUMPERROR) { CV_StealthSetValue(&cv_dummystaff, 0); return; @@ -714,7 +716,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_CheckNumForName(va("%sS%02u", G_BuildMapName(cv_nextmap.value), numstaff+1))) != LUMPERROR) numstaff++; if (cv_dummystaff.value < 1) @@ -722,7 +724,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_CheckNumForName(va("%sS%02u", G_BuildMapName(cv_nextmap.value), cv_dummystaff.value))) == LUMPERROR) return; // shouldn't happen but might as well check... G_UpdateStaffGhostName(l); @@ -807,7 +809,8 @@ static void M_ChangeCvar(INT32 choice) CV_SetValue(cv,skins[skinno].prefcolor); return; } - CV_Set(cv,cv->defaultvalue); + + CV_Set(cv, cv->defaultvalue); return; } @@ -956,6 +959,7 @@ static void Command_Manual_f(void) { if (modeattacking) return; + M_StartControlPanel(); M_Manual(INT32_MAX); itemOn = 0; @@ -3671,10 +3675,10 @@ static void M_DrawAddons(void) //m = numwadfiles-(mainwads+2+1); //V_DrawCenteredString(BASEVIDWIDTH/2, y+24, (majormods ? highlightflags : V_TRANSLUCENT), va("%d ADD-ON%s LOADED", (int)m, (m == 1) ? "" : "S")); //+2 for music, sounds, +1 for main.kart - V_DrawThinString(0, BASEVIDHEIGHT-10, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_TRANSLUCENT|V_ALLOWLOWERCASE, ("END Key - Add addon to autoload")); + V_DrawThinString(0, BASEVIDHEIGHT-10, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_TRANSLUCENT|V_ALLOWLOWERCASE, va("%s Key - Add addon to autoload", G_KeynumToString(AUTOLOAD_KEY))); if (Playing() && (server || IsPlayerAdmin(consoleplayer))) - V_DrawThinString(0, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_TRANSLUCENT|V_ALLOWLOWERCASE, ("Right ALT Key - Switch to local addon mode")); + V_DrawThinString(0, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_TRANSLUCENT|V_ALLOWLOWERCASE, va("%s Key - Switch to local addon mode", G_KeynumToString(LOCALMODE_KEY))); } static void M_AddonExec(INT32 ch) @@ -3696,7 +3700,7 @@ static void M_AddonAutoLoad(INT32 ch) FILE *autoloadconfigfile; // check our controls // - if (ch != 'y' && ch != KEY_ENTER && ch != KEY_END) + if (ch != 'y' && ch != KEY_ENTER && ch != AUTOLOAD_KEY) { S_StartSound(NULL, sfx_s26d); return; @@ -3710,7 +3714,7 @@ static void M_AddonAutoLoad(INT32 ch) switch (dirmenu[dir_on[menudepthleft]][DIR_TYPE]) { case EXT_FOLDER: - M_StartMessage(va("%c%s\x80\nAutoloading folders is not supported as of yet. \n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), dirmenu[dir_on[menudepthleft]]+DIR_STRING),NULL,MM_NOTHING); + M_StartMessage(va("%c%s\x80\nAutoloading folders is not supported as of yet. \n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), dirmenu[dir_on[menudepthleft]]+DIR_STRING), NULL, MM_NOTHING); break; case EXT_TXT: case EXT_CFG: @@ -3897,7 +3901,7 @@ static void M_HandleAddons(INT32 choice) } break; - case KEY_END: + case AUTOLOAD_KEY: { boolean refresh = true; if (!dirmenu[dir_on[menudepthleft]]) diff --git a/src/p_map.c b/src/p_map.c index 06e666a28..ef4997293 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2428,7 +2428,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) if (thing->player) { - if (special == -1) + if (special == -1) // this should use the target coords not the ones were started with, but cant fix that for compat reasons! special = GETSECSPECIAL(R_PointInSubsector(x, y)->sector->special, 1); // If using type Section1:13, double the maxstep. @@ -2592,6 +2592,12 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) positives, so just ignore them entirely. */ if (stairjank && !oldslope && !thing->standingslope && thing->player && !thing->player->spectator) { + /* use a shorter sound if not two tics have passed + * since the last step */ + //S_ReducedVFXSound(thing, (thing->player->stairjank >= 16 ? sfx_s23b : sfx_s268), NULL); + //S_StartSound(thing, (thing->player->stairjank >= 16 ? sfx_s23b : sfx_s268)); + // sound does not work out all that well for kart maps + // TODO: maybe spawn smol dust effect similar to RR? /*if (!thing->player->stairjank) { diff --git a/src/p_mobj.c b/src/p_mobj.c index 12574c031..49916eb50 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -7068,7 +7068,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) } P_InstaThrust(mobj, mobj->angle, finalspeed); - + if (grounded) { sector_t *sec2 = P_ThingOnSpecial3DFloor(mobj); diff --git a/src/p_setup.c b/src/p_setup.c index 6d790262e..ec1320aa5 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2559,6 +2559,31 @@ static void P_LoadRecordGhosts(void) free(gpath); } +static void P_ResetSpawnpoints(void) +{ + UINT8 i; + + numdmstarts = numredctfstarts = numbluectfstarts = 0; + + // reset the player starts + for (i = 0; i < MAXPLAYERS; i++) + { + playerstarts[i] = NULL; + redctfstarts[i] = NULL; + bluectfstarts[i] = NULL; + } + + for (i = 0; i < MAX_DM_STARTS; i++) + { + deathmatchstarts[i] = NULL; + } + + for (i = 0; i < 2; i++) + { + skyboxmo[i] = NULL; + } +} + static void P_InitCamera(void) { INT32 i; @@ -2568,6 +2593,7 @@ static void P_InitCamera(void) for (i = 0; i <= splitscreen; i++) { + camera[i].postimg = 0; P_SetupCamera(&camera[i]); } @@ -2667,10 +2693,14 @@ static boolean P_RunSpecialWipe(boolean reloadinggamestate) { // Cancel all d_main.c fadeouts (keep fade in though). if (reloadinggamestate) + { wipegamestate = gamestate; // Don't fade if reloading the gamestate + return false; + } + // Encore mode fade to pink to white // This is handled BEFORE sounds are stopped. - else if (encoremode && !prevencoremode && !demo.rewinding) + if (encoremode && !prevencoremode && !demo.rewinding) { tic_t locstarttime, endtime, nowtime; @@ -2704,6 +2734,8 @@ static boolean P_RunSpecialWipe(boolean reloadinggamestate) // Hold on white for extra effect. while (nowtime < endtime) { + I_HandleInterrupt(); + // wait loop while (!((nowtime = I_GetTime()) - lastwipetic)) { @@ -2726,6 +2758,69 @@ static boolean P_RunSpecialWipe(boolean reloadinggamestate) return false; } +static void P_InitTagGametype(void) +{ + UINT8 i; + INT32 realnumplayers = 0; + INT32 playersactive[MAXPLAYERS]; + + //I just realized how problematic this code can be. + //D_NumPlayers() will not always cover the scope of the netgame. + //What if one player is node 0 and the other node 31? + //The solution? Make a temp array of all players that are currently playing and pick from them. + //Future todo? When a player leaves, shift all nodes down so D_NumPlayers() can be used as intended? + //Also, you'd never have to loop through all 32 players slots to find anything ever again. + for (i = 0; i < MAXPLAYERS; i++) + { + if (playeringame[i] && !players[i].spectator) + { + playersactive[realnumplayers] = i; //stores the player's node in the array. + realnumplayers++; + } + } + + if (!realnumplayers) // this should also fix the dedicated crash bug. You only pick a player if one exists to be picked. + { + CONS_Printf(M_GetText("No player currently available to become IT. Awaiting available players.\n")); + return; + } + + i = P_RandomKey(realnumplayers); + players[playersactive[i]].pflags |= PF_TAGIT; //choose our initial tagger before map starts. + + // Taken and modified from G_DoReborn() + // Remove the player so he can respawn elsewhere. + // first dissasociate the corpse + if (players[playersactive[i]].mo) + P_RemoveMobj(players[playersactive[i]].mo); + + G_SpawnPlayer(playersactive[i], false); //respawn the lucky player in his dedicated spawn location. +} + +static void P_InitGametype(void) +{ + if (modeattacking == ATTACKING_RECORD && !demo.playback) + P_LoadRecordGhosts(); + + if (G_RaceGametype() && server) + { + INT32 numLaps; + const mapheader_t *mapheader = mapheaderinfo[gamemap - 1]; + + if ((netgame || multiplayer) && cv_basenumlaps.value && + (!(mapheader->levelflags & LF_SECTIONRACE) || (mapheader->numlaps > cv_basenumlaps.value))) + numLaps = cv_basenumlaps.value; + else + numLaps = mapheader->numlaps; + + CV_StealthSetValue(&cv_numlaps, numLaps); + } + else if (G_TagGametype()) + { + P_InitTagGametype(); + } +} + static void P_SetupPlayer(void) { INT32 i; @@ -2752,63 +2847,14 @@ static void P_SetupPlayer(void) } } - if (modeattacking == ATTACKING_RECORD && !demo.playback) - P_LoadRecordGhosts(); - - if (G_TagGametype()) - { - INT32 realnumplayers = 0; - INT32 playersactive[MAXPLAYERS]; - - //I just realized how problematic this code can be. - //D_NumPlayers() will not always cover the scope of the netgame. - //What if one player is node 0 and the other node 31? - //The solution? Make a temp array of all players that are currently playing and pick from them. - //Future todo? When a player leaves, shift all nodes down so D_NumPlayers() can be used as intended? - //Also, you'd never have to loop through all 32 players slots to find anything ever again. - for (i = 0; i < MAXPLAYERS; i++) - { - if (playeringame[i] && !players[i].spectator) - { - playersactive[realnumplayers] = i; //stores the player's node in the array. - realnumplayers++; - } - } - - if (realnumplayers) // this should also fix the dedicated crash bug. You only pick a player if one exists to be picked. - { - i = P_RandomKey(realnumplayers); - players[playersactive[i]].pflags |= PF_TAGIT; //choose our initial tagger before map starts. - - // Taken and modified from G_DoReborn() - // Remove the player so he can respawn elsewhere. - // first dissasociate the corpse - if (players[playersactive[i]].mo) - P_RemoveMobj(players[playersactive[i]].mo); - - G_SpawnPlayer(playersactive[i], false); //respawn the lucky player in his dedicated spawn location. - } - else - CONS_Printf(M_GetText("No player currently available to become IT. Awaiting available players.\n")); - - } - else if (G_RaceGametype() && server) - { - INT32 numLaps = ((netgame || multiplayer) && cv_basenumlaps.value - && (!(mapheaderinfo[gamemap - 1]->levelflags & LF_SECTIONRACE) - || (mapheaderinfo[gamemap - 1]->numlaps > cv_basenumlaps.value))) - ? cv_basenumlaps.value - : mapheaderinfo[gamemap - 1]->numlaps; - - CV_StealthSetValue(&cv_numlaps, numLaps); - } + P_InitGametype(); // Start recording replay in multiplayer with a temp filename // 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)), G_BuildMapName(gamemap)); I_mkdir(va("%s"PATHSEP"replay", srb2home), 0755); I_mkdir(va("%s"PATHSEP"replay"PATHSEP"online", srb2home), 0755); @@ -2910,9 +2956,10 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) // 99% of the things already did, so. // Map header should always be in place at this point INT32 i; + UINT8 levelfadecol; boolean ranspecialwipe = false; lumpnum_t encoreLump = LUMPERROR; - UINT8 levelfadecol; + const mapheader_t *mapheader = mapheaderinfo[gamemap - 1]; midgamejoin = fromnetsave; // makes dynslopes run in P_Ticker to avoid synch issues and other stuff @@ -2920,7 +2967,7 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) levelloading = true; // This is needed. Don't touch. - maptol = mapheaderinfo[gamemap-1]->typeoflevel; + maptol = mapheader->typeoflevel; CON_Drawer(); // let the user know what we are going to do I_FinishUpdate(); // page flip or blit buffer @@ -2931,17 +2978,17 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) // Clear CECHO messages HU_ClearCEcho(); - if (mapheaderinfo[gamemap-1]->runsoc[0] != '#') - P_RunSOC(mapheaderinfo[gamemap-1]->runsoc); + if (mapheader->runsoc[0] != '#') + P_RunSOC(mapheader->runsoc); - if (cv_runscripts.value && mapheaderinfo[gamemap-1]->scriptname[0] != '#') - P_RunLevelScript(mapheaderinfo[gamemap-1]->scriptname); + if (cv_runscripts.value && mapheader->scriptname[0] != '#') + P_RunLevelScript(mapheader->scriptname); P_LevelInitStuff(reloadinggamestate); - if (mapheaderinfo[gamemap-1]->forcecharacter[0] != '\0' - && atoi(mapheaderinfo[gamemap-1]->forcecharacter) != 255) - P_ForceCharacter(mapheaderinfo[gamemap-1]->forcecharacter); + if (mapheader->forcecharacter[0] != '\0' + && atoi(mapheader->forcecharacter) != 255) + P_ForceCharacter(mapheader->forcecharacter); // Initial height of PointOfView // will be set by player think. @@ -2991,10 +3038,10 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) char tx[64]; V_DrawSmallString(1, 191, V_ALLOWLOWERCASE, M_GetText("Speeding off to...")); snprintf(tx, 63, "%s%s%s", - mapheaderinfo[gamemap-1]->lvlttl, - (strlen(mapheaderinfo[gamemap-1]->zonttl) > 0) ? va(" %s",mapheaderinfo[gamemap-1]->zonttl) : // SRB2kart - ((mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE) ? "" : " Zone"), - (strlen(mapheaderinfo[gamemap-1]->actnum) > 0) ? va(", Act %s",mapheaderinfo[gamemap-1]->actnum) : ""); + mapheader->lvlttl, + (strlen(mapheader->zonttl) > 0) ? va(" %s",mapheader->zonttl) : // SRB2kart + ((mapheader->levelflags & LF_NOZONE) ? "" : " Zone"), + (strlen(mapheader->actnum) > 0) ? va(", Act %s",mapheader->actnum) : ""); V_DrawSmallString(1, 195, V_ALLOWLOWERCASE, tx); I_UpdateNoVsync(); }*/ @@ -3013,20 +3060,16 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) curmapvirt = vres_GetMap(lastloadedmaplumpnum); encoreLump = W_CheckNumForName(va("%s%c", maplumpname, (encoremode ? 'E' : 'T'))); - R_ReInitColormaps(mapheaderinfo[gamemap-1]->palette, encoreLump); + R_ReInitColormaps(mapheader->palette, encoreLump); CON_SetupBackColormap(); // SRB2 determines the sky texture to be used depending on the map header. - P_SetupLevelSky(mapheaderinfo[gamemap-1]->skynum, true); + P_SetupLevelSky(mapheader->skynum, true); - numdmstarts = numredctfstarts = numbluectfstarts = 0; + P_ResetSpawnpoints(); - // reset the player starts - memset(playerstarts, 0, sizeof(playerstarts)); - memset(skyboxmo, 0, sizeof(skyboxmo)); - - P_MapStart(); + P_MapStart(); // tmthing can be used starting from this point P_LoadMapFromFile(); @@ -3046,7 +3089,7 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) if (!playerstarts[numcoopstarts]) break; - globalweather = mapheaderinfo[gamemap-1]->weather; + globalweather = mapheader->weather; // set up world state P_SpawnSpecials(fromnetsave, reloadinggamestate); @@ -3093,7 +3136,7 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) // clear special respawning que iquehead = iquetail = 0; - P_MapEnd(); + P_MapEnd(); // tmthing is no longer needed from this point onwards // Remove the loading shit from the screen if (rendermode != render_none && !reloadinggamestate) @@ -3124,9 +3167,15 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) savedata.lives = 0; } - // assume the skybox is visible on level load. - skyVisible = true; - memset(skyVisiblePerPlayer, true, sizeof(skyVisiblePerPlayer)); + if (!reloadinggamestate) + { + // assume the skybox is visible on level load. + skyVisible = true; + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) + { + skyVisiblePerPlayer[i] = true; + } + } if (!fromnetsave) // uglier hack { // to make a newly loaded level start on the second frame. @@ -3146,14 +3195,18 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) LUA_HookInt(gamemap, HOOK(MapLoad)); } - if (rendermode != render_none && !reloadinggamestate) + // reloading gamestate, stop here. + if (reloadinggamestate) + return true; + + G_AddMapToBuffer(gamemap-1); + + if (rendermode != render_none) { R_ResetViewInterpolation(0); R_UpdateMobjInterpolators(); } - G_AddMapToBuffer(gamemap-1); - G_ResetDeviceLED(); return true; diff --git a/src/p_spec.c b/src/p_spec.c index 1bcbebdf5..9aff26b3c 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -538,6 +538,7 @@ static sector_t *getNextSector(line_t *line, sector_t *sec) else return NULL; } + return line->frontsector; } @@ -568,6 +569,7 @@ fixed_t P_FindLowestFloorSurrounding(sector_t *sec) if (other->floorheight < floorh) floorh = other->floorheight; } + return floorh; } @@ -1180,7 +1182,7 @@ INT32 P_FindMinSurroundingLight(sector_t *sector, INT32 max) for (i = 0; i < sector->linecount; i++) { line = sector->lines[i]; - check = getNextSector(line,sector); + check = getNextSector(line, sector); if (!check) continue; @@ -2098,7 +2100,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) ffloor_t *rover; boolean foundit = false; - for(rover = mo->subsector->sector->ffloors; rover; rover = rover->next) + for (rover = mo->subsector->sector->ffloors; rover; rover = rover->next) { if (rover->master->frontsector->tag != line->tag) continue; @@ -2988,10 +2990,10 @@ sector_t *P_PlayerTouchingSectorSpecial(player_t *player, INT32 section, INT32 n { fixed_t topheight, bottomheight; - if (GETSECSPECIAL(rover->master->frontsector->special, section) != number) + if (!(rover->flags & FF_EXISTS)) continue; - if (!(rover->flags & FF_EXISTS)) + if (GETSECSPECIAL(rover->master->frontsector->special, section) != number) continue; topheight = P_GetSpecialTopZ(player->mo, sectors + rover->secnum, player->mo->subsector->sector);