Merge branch 'splitplayers-mapcommand' into 'master'

Splitplayers Fixes

Closes #408

See merge request KartKrew/Kart!927
This commit is contained in:
Oni 2023-02-17 05:11:15 +00:00
commit e9668598d2
8 changed files with 103 additions and 61 deletions

View file

@ -2846,7 +2846,7 @@ static void Command_Map_f(void)
return; return;
} }
} }
else if (!Playing()) else if (!Playing() || (netgame == false && grandprixinfo.gp == true))
{ {
newresetplayers = true; newresetplayers = true;
if (mapheaderinfo[newmapnum-1]) if (mapheaderinfo[newmapnum-1])
@ -2970,8 +2970,21 @@ static void Command_Map_f(void)
if (!Playing()) if (!Playing())
{ {
UINT8 ssplayers = cv_splitplayers.value-1;
multiplayer = true; multiplayer = true;
restoreMenu = NULL; restoreMenu = NULL;
strncpy(connectedservername, cv_servername.string, MAXSERVERNAME);
if (cv_maxconnections.value < ssplayers+1)
CV_SetValue(&cv_maxconnections, ssplayers+1);
if (splitscreen != ssplayers)
{
splitscreen = ssplayers;
SplitScreen_OnChange();
}
} }
} }

View file

@ -17,6 +17,7 @@
#include "m_random.h" #include "m_random.h"
#include "r_sky.h" // skyflatnum #include "r_sky.h" // skyflatnum
#include "k_grandprix.h" // K_CanChangeRules #include "k_grandprix.h" // K_CanChangeRules
#include "k_boss.h" // bossinfo.valid
#include "p_spec.h" #include "p_spec.h"
#include "k_objects.h" #include "k_objects.h"
@ -92,7 +93,7 @@ void K_CheckBumpers(void)
UINT8 numingame = 0; UINT8 numingame = 0;
SINT8 winnernum = -1; SINT8 winnernum = -1;
UINT32 winnerscoreadd = 0, maxroundscore = 0; UINT32 winnerscoreadd = 0, maxroundscore = 0;
boolean nobumpers = false; UINT8 nobumpers = 0;
if (!(gametyperules & GTR_BUMPERS)) if (!(gametyperules & GTR_BUMPERS))
return; return;
@ -118,7 +119,7 @@ void K_CheckBumpers(void)
if (players[i].bumpers <= 0) // if you don't have any bumpers, you're probably not a winner if (players[i].bumpers <= 0) // if you don't have any bumpers, you're probably not a winner
{ {
nobumpers = true; nobumpers++;
continue; continue;
} }
else if (winnernum != -1) // TWO winners? that's dumb :V else if (winnernum != -1) // TWO winners? that's dumb :V
@ -128,9 +129,9 @@ void K_CheckBumpers(void)
winnerscoreadd -= players[i].roundscore; winnerscoreadd -= players[i].roundscore;
} }
if (K_CanChangeRules(true) == false) if (battlecapsules || bossinfo.valid)
{ {
if (nobumpers) if (nobumpers > 0 && nobumpers >= numingame)
{ {
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
{ {
@ -144,29 +145,15 @@ void K_CheckBumpers(void)
} }
return; return;
} }
else if (numingame <= 1)
if (numingame <= 1)
{ {
if ((gametyperules & GTR_CAPSULES) && !battlecapsules) if ((gametyperules & GTR_CAPSULES) && (K_CanChangeRules(true) == true))
{ {
// Reset map to turn on battle capsules // Reset map to turn on battle capsules
if (server) if (server)
D_MapChange(gamemap, gametype, encoremode, true, 0, false, false); D_MapChange(gamemap, gametype, encoremode, true, 0, false, false);
} }
else
{
if (nobumpers)
{
for (i = 0; i < MAXPLAYERS; i++)
{
if (!playeringame[i])
continue;
if (players[i].spectator)
continue;
players[i].pflags |= PF_NOCONTEST;
P_DoPlayerExit(&players[i]);
}
}
}
return; return;
} }

View file

@ -1466,7 +1466,7 @@ static void K_drawKartItem(void)
} }
} }
void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, UINT8 mode) void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT32 splitflags, UINT8 mode)
{ {
// TIME_X = BASEVIDWIDTH-124; // 196 // TIME_X = BASEVIDWIDTH-124; // 196
// TIME_Y = 6; // 6 // TIME_Y = 6; // 6
@ -1474,11 +1474,8 @@ void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, UINT8 mode)
tic_t worktime; tic_t worktime;
INT32 jitter = 0; INT32 jitter = 0;
INT32 splitflags = 0;
if (!mode) if (!mode)
{ {
splitflags = V_HUDTRANS|V_SLIDEIN|V_SNAPTOTOP|V_SNAPTORIGHT|V_SPLITSCREEN;
if (timelimitintics > 0) if (timelimitintics > 0)
{ {
if (drawtime >= timelimitintics) if (drawtime >= timelimitintics)
@ -4302,7 +4299,7 @@ static void K_drawKartStartCountdown(void)
break; break;
} }
if (numplayers == 2) if (inDuel == true)
{ {
pnum++; // DUEL pnum++; // DUEL
} }
@ -4971,17 +4968,15 @@ void K_drawKartHUD(void)
boolean battlefullscreen = false; boolean battlefullscreen = false;
boolean freecam = demo.freecam; //disable some hud elements w/ freecam boolean freecam = demo.freecam; //disable some hud elements w/ freecam
UINT8 i; UINT8 i;
UINT8 viewnum = R_GetViewNumber();
// Define the X and Y for each drawn object // Define the X and Y for each drawn object
// This is handled by console/menu values // This is handled by console/menu values
K_initKartHUD(); K_initKartHUD();
// Draw that fun first person HUD! Drawn ASAP so it looks more "real". // Draw that fun first person HUD! Drawn ASAP so it looks more "real".
for (i = 0; i <= r_splitscreen; i++) if (!camera[viewnum].chase && !freecam)
{
if (stplyr == &players[displayplayers[i]] && !camera[i].chase && !freecam)
K_drawKartFirstPerson(); K_drawKartFirstPerson();
}
// Draw full screen stuff that turns off the rest of the HUD // Draw full screen stuff that turns off the rest of the HUD
if (mapreset && stplyr == &players[displayplayers[0]]) if (mapreset && stplyr == &players[displayplayers[0]])
@ -5032,15 +5027,42 @@ void K_drawKartHUD(void)
if (LUA_HudEnabled(hud_item) && !freecam) if (LUA_HudEnabled(hud_item) && !freecam)
K_drawKartItem(); K_drawKartItem();
// If not splitscreen, draw... if (demo.title)
if (!r_splitscreen && !demo.title) ;
else if (!r_splitscreen)
{ {
// Draw the timestamp // Draw the timestamp
if (LUA_HudEnabled(hud_time)) if (LUA_HudEnabled(hud_time))
K_drawKartTimestamp(stplyr->realtime, TIME_X, TIME_Y, 0); K_drawKartTimestamp(stplyr->realtime,
TIME_X,
TIME_Y,
V_HUDTRANS|V_SLIDEIN|V_SNAPTOTOP|V_SNAPTORIGHT,
0);
islonesome = K_drawKartPositionFaces(); islonesome = K_drawKartPositionFaces();
} }
else if (viewnum == r_splitscreen
&& (gametyperules & GTR_TIMELIMIT)
&& timelimitintics > 0)
{
tic_t highestrealtime = players[displayplayers[1]].realtime;
// Uses the highest time across all players (handles paused timer on exiting)
for (i = 1; i <= r_splitscreen; i++)
{
if (players[displayplayers[i]].realtime <= highestrealtime)
continue;
highestrealtime = players[displayplayers[i]].realtime;
}
// Draw the timestamp (mostly) CENTERED
if (LUA_HudEnabled(hud_time))
K_drawKartTimestamp(highestrealtime,
(r_splitscreen == 1 ? TIME_X : ((BASEVIDWIDTH/2) - 69)),
TIME_Y,
V_HUDTRANS|V_SLIDEIN|V_SNAPTOTOP|(r_splitscreen == 1 ? V_SNAPTORIGHT : 0),
0);
}
if (!stplyr->spectator && !demo.freecam) // Bottom of the screen elements, don't need in spectate mode if (!stplyr->spectator && !demo.freecam) // Bottom of the screen elements, don't need in spectate mode
{ {

View file

@ -40,7 +40,7 @@ const char *K_GetItemPatch(UINT8 item, boolean tiny);
void K_LoadKartHUDGraphics(void); void K_LoadKartHUDGraphics(void);
void K_drawKartHUD(void); void K_drawKartHUD(void);
void K_drawKartFreePlay(void); void K_drawKartFreePlay(void);
void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, UINT8 mode); void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT32 splitflags, UINT8 mode);
void K_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, INT32 whiteplayer, INT32 hilicol); void K_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, INT32 whiteplayer, INT32 hilicol);
void K_DrawMapThumbnail(INT32 x, INT32 y, INT32 width, UINT32 flags, UINT16 map, UINT8 *colormap); void K_DrawMapThumbnail(INT32 x, INT32 y, INT32 width, UINT32 flags, UINT16 map, UINT8 *colormap);
void K_DrawLikeMapThumbnail(INT32 x, INT32 y, INT32 width, UINT32 flags, patch_t *patch, UINT8 *colormap); void K_DrawLikeMapThumbnail(INT32 x, INT32 y, INT32 width, UINT32 flags, patch_t *patch, UINT8 *colormap);

View file

@ -4192,9 +4192,10 @@ void K_HandleBumperChanges(player_t *player, UINT8 prevBumpers)
player->karmadelay = comebacktime; player->karmadelay = comebacktime;
if (gametyperules & GTR_BOSS) if (battlecapsules || bossinfo.valid)
{ {
P_DoTimeOver(player); player->pflags |= (PF_NOCONTEST|PF_ELIMINATED);
P_DamageMobj(player->mo, NULL, NULL, 1, DMG_TIMEOVER);
} }
else if (netgame) else if (netgame)
{ {

View file

@ -2266,7 +2266,7 @@ void M_DrawTimeAttack(void)
&& (mapheaderinfo[map]->numlaps != 1)) && (mapheaderinfo[map]->numlaps != 1))
{ {
V_DrawRightAlignedString(rightedge-12, timeheight, highlightflags, "BEST LAP:"); V_DrawRightAlignedString(rightedge-12, timeheight, highlightflags, "BEST LAP:");
K_drawKartTimestamp(laprec, 162+t, timeheight+6, 2); K_drawKartTimestamp(laprec, 162+t, timeheight+6, 0, 2);
timeheight += 30; timeheight += 30;
} }
else else
@ -2275,7 +2275,7 @@ void M_DrawTimeAttack(void)
} }
V_DrawRightAlignedString(rightedge-12, timeheight, highlightflags, "BEST TIME:"); V_DrawRightAlignedString(rightedge-12, timeheight, highlightflags, "BEST TIME:");
K_drawKartTimestamp(timerec, 162+t, timeheight+6, 1); K_drawKartTimestamp(timerec, 162+t, timeheight+6, 0, 1);
} }
else else
opty = 80; opty = 80;

View file

@ -102,7 +102,8 @@ static void K_MoveExitBeam(void)
if (player->distancetofinish > specialstageinfo.beamDist) if (player->distancetofinish > specialstageinfo.beamDist)
{ {
P_DoTimeOver(player); player->pflags |= PF_NOCONTEST;
P_DoPlayerExit(player);
} }
} }
} }

View file

@ -602,6 +602,8 @@ void V_AdjustXYWithSnap(INT32 *x, INT32 *y, UINT32 options, INT32 dupx, INT32 du
} }
if (timer < length) if (timer < length)
{
if ((options & (V_SNAPTORIGHT|V_SNAPTOLEFT|V_SPLITSCREEN)) != 0)
{ {
boolean slidefromright = false; boolean slidefromright = false;
@ -629,6 +631,22 @@ void V_AdjustXYWithSnap(INT32 *x, INT32 *y, UINT32 options, INT32 dupx, INT32 du
*x -= offset; *x -= offset;
} }
else
{
const INT32 offsetAmount = (screenheight * FRACUNIT/2) / length;
fixed_t offset = (screenheight * FRACUNIT/2) - (timer * offsetAmount);
offset += FixedMul(offsetAmount, renderdeltatics);
offset /= FRACUNIT;
if (options & V_SNAPTOBOTTOM)
{
offset = -offset;
}
*y -= offset;
}
}
} }
} }