diff --git a/src/g_game.c b/src/g_game.c index 85a73e045..ecacc269b 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -246,11 +246,11 @@ INT32 gameovertics = 15*TICRATE; UINT8 ammoremovaltics = 2*TICRATE; // SRB2kart -tic_t introtime = 0; -tic_t starttime = 0; +tic_t introtime = 3; +tic_t starttime = 3; const tic_t bulbtime = TICRATE/2; -UINT8 numbulbs = 0; +UINT8 numbulbs = 1; tic_t raceexittime = 5*TICRATE + (2*TICRATE/3); tic_t battleexittime = 8*TICRATE; diff --git a/src/k_kart.c b/src/k_kart.c index 94b2b1237..0f97aa9d6 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -43,6 +43,63 @@ // indirectitemcooldown is timer before anyone's allowed another Shrink/SPB // mapreset is set when enough players fill an empty server +void K_TimerReset(void) +{ + starttime = introtime = 3; + numbulbs = 1; +} + +void K_TimerInit(void) +{ + UINT8 i; + UINT8 numPlayers = 0; + + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i]) + { + continue; + } + + if (players[i].spectator == true) + { + continue; + } + + numPlayers++; + } + + if (numPlayers >= 2) + { + rainbowstartavailable = true; + } + else + { + rainbowstartavailable = false; + } + + if (numPlayers <= 2) + { + introtime = 0; // No intro in Record Attack / 1v1 + } + else + { + introtime = (108) + 5; // 108 for rotation, + 5 for white fade + } + + numbulbs = 5; + + if (numPlayers > 2) + { + numbulbs += (numPlayers-2); + } + + starttime = (introtime + (3*TICRATE)) + ((2*TICRATE) + (numbulbs * bulbtime)); // Start countdown time, + buffer time + + // NOW you can try to spawn in the Battle capsules, if there's not enough players for a match + K_SpawnBattleCapsules(); +} + UINT16 K_GetPlayerDontDrawFlag(player_t *player) { UINT16 flag = 0; diff --git a/src/k_kart.h b/src/k_kart.h index 9b92fff7c..0e3aa0ff4 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -17,6 +17,8 @@ angle_t K_ReflectAngle(angle_t angle, angle_t against, fixed_t maxspeed, fixed_t void K_RegisterKartStuff(void); +void K_TimerReset(void); +void K_TimerInit(void); UINT16 K_GetPlayerDontDrawFlag(player_t *player); boolean K_IsPlayerLosing(player_t *player); fixed_t K_GetKartGameSpeedScalar(SINT8 value); diff --git a/src/p_saveg.c b/src/p_saveg.c index e24e3d2f7..6ed11bb3b 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -4180,6 +4180,7 @@ static void P_NetArchiveMisc(void) WRITEUINT32(save_p, introtime); WRITEUINT32(save_p, starttime); + WRITEUINT8(save_p, numbulbs); // Is it paused? if (paused) @@ -4314,6 +4315,7 @@ static inline boolean P_NetUnArchiveMisc(void) introtime = READUINT32(save_p); starttime = READUINT32(save_p); + numbulbs = READUINT8(save_p); // Is it paused? if (READUINT8(save_p) == 0x2f) diff --git a/src/p_setup.c b/src/p_setup.c index ba46c60e5..ac002b0d3 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3427,29 +3427,6 @@ static void P_InitLevelSettings(void) players[i].follower = NULL; } - rainbowstartavailable = false; - - if (p >= 2) - rainbowstartavailable = true; - - if (p <= 2) - { - introtime = 0; // No intro in Record Attack / 1v1 - } - else - { - introtime = (108) + 5; // 108 for rotation, + 5 for white fade - } - - numbulbs = 5; - - if (p > 2) - { - numbulbs += (p-2); - } - - starttime = (introtime + (3*TICRATE)) + ((2*TICRATE) + (numbulbs * bulbtime)); // Start countdown time, + buffer time - // SRB2Kart: map load variables if (grandprixinfo.gp == true) { @@ -4149,21 +4126,6 @@ boolean P_LoadLevel(boolean fromnetsave) lastmaploaded = gamemap; // HAS to be set after saving!! } - if (!fromnetsave) // uglier hack - { // to make a newly loaded level start on the second frame. - INT32 buf = gametic % TICQUEUE; - for (i = 0; i < MAXPLAYERS; i++) - { - if (playeringame[i]) - G_CopyTiccmd(&players[i].cmd, &netcmds[buf][i], 1); - } - P_PreTicker(2); - LUAh_MapLoad(); - } - - // NOW you can try to spawn in the Battle capsules, if there's not enough players for a match - K_SpawnBattleCapsules(); - if (grandprixinfo.gp == true) { if (grandprixinfo.initalize == true) @@ -4183,6 +4145,20 @@ boolean P_LoadLevel(boolean fromnetsave) K_UpdateMatchRaceBots(); } + if (!fromnetsave) // uglier hack + { // to make a newly loaded level start on the second frame. + INT32 buf = gametic % TICQUEUE; + for (i = 0; i < MAXPLAYERS; i++) + { + if (playeringame[i]) + G_CopyTiccmd(&players[i].cmd, &netcmds[buf][i], 1); + } + P_PreTicker(2); + LUAh_MapLoad(); + } + + K_TimerReset(); + // No render mode, stop here. if (rendermode == render_none) return true; diff --git a/src/p_tick.c b/src/p_tick.c index 71ded772c..85ee844dd 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -705,6 +705,13 @@ void P_Ticker(boolean run) if (demo.playback) G_StoreRewindInfo(); + if (leveltime == 2) + { + // The values needed to set this properly are not correct at map load, + // so we have to do it at the second tick instead... + K_TimerInit(); + } + // Z_CheckMemCleanup(); }