Lots of splitscreen fixes

LOTS of stuff I changed to use arrays instead of constantly duplicated code
This commit is contained in:
Sally Coolatta 2020-08-10 23:38:32 -04:00
parent 0ec506127e
commit a50a9a1843
18 changed files with 355 additions and 1199 deletions

View file

@ -1826,9 +1826,6 @@ void CV_AddValue(consvar_t *var, INT32 increment)
if (!increment)
return;
/*if (var == &cv_pointlimit && (gametype == GT_MATCH))
increment *= 50;*/
if (var == &cv_forceskin) // Special handling.
{
INT32 oldvalue = var->value;
@ -1914,13 +1911,8 @@ void CV_AddValue(consvar_t *var, INT32 increment)
if (newindice >= max || newindice <= MAXVAL)
{
/*if (var == &cv_pointlimit && (gametype == GT_MATCH) && increment > 0)
CV_SetValue(var, 50);
else*/
{
newvalue = var->PossibleValue[((increment > 0) ? MINVAL : MAXVAL)].value;
CV_SetValue(var, newvalue);
}
newvalue = var->PossibleValue[((increment > 0) ? MINVAL : MAXVAL)].value;
CV_SetValue(var, newvalue);
}
else
CV_Set(var, var->PossibleValue[newindice].strvalue);

View file

@ -52,7 +52,7 @@
#include "k_pwrlv.h"
#include "k_bot.h"
#if (defined(CLIENT_LOADINGSCREEN) && !defined(NONET))
#ifndef NONET
// cl loading screen
#include "v_video.h"
#include "f_finale.h"
@ -138,18 +138,12 @@ UINT8 adminpassmd5[16];
boolean adminpasswordset = false;
// Client specific
static ticcmd_t localcmds;
static ticcmd_t localcmds2;
static ticcmd_t localcmds3;
static ticcmd_t localcmds4;
static ticcmd_t localcmds[MAXSPLITSCREENPLAYERS];
static boolean cl_packetmissed;
// here it is for the secondary local player (splitscreen)
static UINT8 mynode; // my address pointofview server
static UINT8 localtextcmd[MAXTEXTCMD];
static UINT8 localtextcmd2[MAXTEXTCMD]; // splitscreen
static UINT8 localtextcmd3[MAXTEXTCMD]; // splitscreen == 2
static UINT8 localtextcmd4[MAXTEXTCMD]; // splitscreen == 3
static UINT8 localtextcmd[MAXSPLITSCREENPLAYERS][MAXTEXTCMD];
static tic_t neededtic;
SINT8 servernode = 0; // the number of the server node
char connectedservername[MAXSERVERNAME];
@ -258,76 +252,27 @@ void RegisterNetXCmd(netxcmd_t id, void (*cmd_f)(UINT8 **p, INT32 playernum))
listnetxcmd[id] = cmd_f;
}
void SendNetXCmd(netxcmd_t id, const void *param, size_t nparam)
void SendNetXCmdForPlayer(UINT8 playerid, netxcmd_t id, const void *param, size_t nparam)
{
if (localtextcmd[0]+2+nparam > MAXTEXTCMD)
if (localtextcmd[playerid][0]+2+nparam > MAXTEXTCMD)
{
// for future reference: if (cv_debug) != debug disabled.
CONS_Alert(CONS_ERROR, M_GetText("NetXCmd buffer full, cannot add netcmd %d! (size: %d, needed: %s)\n"), id, localtextcmd[0], sizeu1(nparam));
CONS_Alert(CONS_ERROR, M_GetText("NetXCmd buffer full, cannot add netcmd %d! (size: %d, needed: %s)\n"), id, localtextcmd[0][0], sizeu1(nparam));
return;
}
localtextcmd[0]++;
localtextcmd[localtextcmd[0]] = (UINT8)id;
localtextcmd[playerid][0]++;
localtextcmd[playerid][localtextcmd[playerid][0]] = (UINT8)id;
if (param && nparam)
{
M_Memcpy(&localtextcmd[localtextcmd[0]+1], param, nparam);
localtextcmd[0] = (UINT8)(localtextcmd[0] + (UINT8)nparam);
}
}
// splitscreen player
void SendNetXCmd2(netxcmd_t id, const void *param, size_t nparam)
{
if (localtextcmd2[0]+2+nparam > MAXTEXTCMD)
{
I_Error("No more place in the buffer for netcmd %d\n",id);
return;
}
localtextcmd2[0]++;
localtextcmd2[localtextcmd2[0]] = (UINT8)id;
if (param && nparam)
{
M_Memcpy(&localtextcmd2[localtextcmd2[0]+1], param, nparam);
localtextcmd2[0] = (UINT8)(localtextcmd2[0] + (UINT8)nparam);
}
}
void SendNetXCmd3(netxcmd_t id, const void *param, size_t nparam)
{
if (localtextcmd3[0]+2+nparam > MAXTEXTCMD)
{
I_Error("No more place in the buffer for netcmd %d\n",id);
return;
}
localtextcmd3[0]++;
localtextcmd3[localtextcmd3[0]] = (UINT8)id;
if (param && nparam)
{
M_Memcpy(&localtextcmd3[localtextcmd3[0]+1], param, nparam);
localtextcmd3[0] = (UINT8)(localtextcmd3[0] + (UINT8)nparam);
}
}
void SendNetXCmd4(netxcmd_t id, const void *param, size_t nparam)
{
if (localtextcmd4[0]+2+nparam > MAXTEXTCMD)
{
I_Error("No more place in the buffer for netcmd %d\n",id);
return;
}
localtextcmd4[0]++;
localtextcmd4[localtextcmd4[0]] = (UINT8)id;
if (param && nparam)
{
M_Memcpy(&localtextcmd4[localtextcmd4[0]+1], param, nparam);
localtextcmd4[0] = (UINT8)(localtextcmd4[0] + (UINT8)nparam);
M_Memcpy(&localtextcmd[playerid][localtextcmd[playerid][0]+1], param, nparam);
localtextcmd[playerid][0] = (UINT8)(localtextcmd[playerid][0] + (UINT8)nparam);
}
}
UINT8 GetFreeXCmdSize(void)
{
// -1 for the size and another -1 for the ID.
return (UINT8)(localtextcmd[0] - 2);
return (UINT8)(localtextcmd[0][0] - 2);
}
// Frees all textcmd memory for the specified tic
@ -488,10 +433,8 @@ void D_ResetTiccmds(void)
{
INT32 i;
memset(&localcmds, 0, sizeof(ticcmd_t));
memset(&localcmds2, 0, sizeof(ticcmd_t));
memset(&localcmds3, 0, sizeof(ticcmd_t));
memset(&localcmds4, 0, sizeof(ticcmd_t));
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
memset(&localcmds[i], 0, sizeof(ticcmd_t));
// Reset the net command list
for (i = 0; i < TEXTCMD_HASH_SIZE; i++)
@ -1197,7 +1140,7 @@ static void CV_LoadPlayerNames(UINT8 **p)
}
}
#if (defined(CLIENT_LOADINGSCREEN) && !defined(NONET))
#ifndef NONET
//
// CL_DrawConnectionStatus
@ -1344,6 +1287,8 @@ static boolean CL_AskFileList(INT32 firstfile)
static boolean CL_SendJoin(void)
{
UINT8 localplayers = 1;
UINT8 i;
if (netgame)
CONS_Printf(M_GetText("Sending join request...\n"));
netbuffer->packettype = PT_CLIENTJOIN;
@ -1359,12 +1304,11 @@ static boolean CL_SendJoin(void)
strncpy(netbuffer->u.clientcfg.application, SRB2APPLICATION,
sizeof netbuffer->u.clientcfg.application);
CleanupPlayerName(consoleplayer, cv_playername.zstring);
if (splitscreen)
CleanupPlayerName(1, cv_playername2.zstring);/* 1 is a HACK? oh no */
for (i = 0; i <= splitscreen; i++)
CleanupPlayerName(g_localplayers[i], cv_playername[i].zstring);
strncpy(netbuffer->u.clientcfg.names[0], cv_playername.zstring, MAXPLAYERNAME);
strncpy(netbuffer->u.clientcfg.names[1], cv_playername2.zstring, MAXPLAYERNAME);
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
strncpy(netbuffer->u.clientcfg.names[i], cv_playername[i].zstring, MAXPLAYERNAME);
return HSendPacket(servernode, false, 0, sizeof (clientconfig_pak));
}
@ -2808,7 +2752,7 @@ void CL_RemovePlayer(INT32 playernum, kickreason_t reason)
if (!playeringame[playernum])
return;
if (server && !demoplayback && playernode[playernum] != UINT8_MAX && !players[playernum].bot)
if (server && !demo.playback && playernode[playernum] != UINT8_MAX && !players[playernum].bot)
{
INT32 node = playernode[playernum];
//playerpernode[node] = 0; // It'd be better to remove them all at once, but ghosting happened, so continue to let CL_RemovePlayer do it one-by-one
@ -2832,12 +2776,12 @@ void CL_RemovePlayer(INT32 playernum, kickreason_t reason)
LUAh_PlayerQuit(&players[playernum], reason); // Lua hook for player quitting
// don't look through someone's view who isn't there
if (playernum == displayplayer)
if (playernum == displayplayers[0])
{
// Call ViewpointSwitch hooks here.
// The viewpoint was forcibly changed.
LUAh_ViewpointSwitch(&players[consoleplayer], &players[consoleplayer], true);
displayplayer = consoleplayer;
displayplayers[0] = consoleplayer;
}
G_RemovePartyMember(playernum);
@ -3724,7 +3668,7 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum)
{
if (newplayer->mo)
{
newplayer->viewheight = 41*newplayer->height/48;
newplayer->viewheight = P_GetPlayerViewHeight(newplayer);
if (newplayer->mo->eflags & MFE_VERTICALFLIP)
newplayer->viewz = newplayer->mo->z + newplayer->mo->height - newplayer->viewheight;
@ -3919,22 +3863,22 @@ static boolean SV_AddWaitingPlayers(const char *name, const char *name2, const c
if (playerpernode[node] < 1)
{
nodetoplayer[node] = newplayernum;
WRITESTRINGN(p, name, MAXPLAYERNAME);
WRITESTRINGN(buf_p, name, MAXPLAYERNAME);
}
else if (playerpernode[node] < 2)
{
nodetoplayer2[node] = newplayernum;
WRITESTRINGN(p, name2, MAXPLAYERNAME);
WRITESTRINGN(buf_p, name2, MAXPLAYERNAME);
}
else if (playerpernode[node] < 3)
{
nodetoplayer3[node] = newplayernum;
WRITESTRINGN(p, name3, MAXPLAYERNAME);
WRITESTRINGN(buf_p, name3, MAXPLAYERNAME);
}
else if (playerpernode[node] < 4)
{
nodetoplayer4[node] = newplayernum;
WRITESTRINGN(p, name4, MAXPLAYERNAME);
WRITESTRINGN(buf_p, name4, MAXPLAYERNAME);
}
WRITEUINT8(buf_p, nodetoplayer[node]); // consoleplayer
@ -4001,7 +3945,7 @@ boolean SV_SpawnServer(void)
else doomcom->numslots = 1;
}
return SV_AddWaitingPlayers(cv_playername.zstring, cv_playername2.zstring, cv_playername3.zstring, cv_playername4.zstring);
return SV_AddWaitingPlayers(cv_playername[0].zstring, cv_playername[1].zstring, cv_playername[2].zstring, cv_playername[3].zstring);
#endif
}
@ -4015,10 +3959,10 @@ void SV_StopServer(void)
Y_EndVote();
gamestate = wipegamestate = GS_NULL;
localtextcmd[0] = 0;
localtextcmd2[0] = 0;
localtextcmd3[0] = 0;
localtextcmd4[0] = 0;
localtextcmd[0][0] = 0;
localtextcmd[1][0] = 0;
localtextcmd[2][0] = 0;
localtextcmd[3][0] = 0;
for (i = firstticstosend; i < firstticstosend + TICQUEUE; i++)
D_Clearticcmd(i);
@ -4039,7 +3983,7 @@ void SV_StartSinglePlayerServer(void)
if (modeattacking == ATTACKING_CAPSULES)
{
G_SetGametype(GT_MATCH);
G_SetGametype(BT_BATTLE);
}
else
{
@ -4181,7 +4125,7 @@ static void HandleConnect(SINT8 node)
SV_SendSaveGame(node); // send a complete game state
DEBFILE("send savegame\n");
}
SV_AddWaitingPlayers(names[0], names[1]);
SV_AddWaitingPlayers(names[0], names[1], names[2], names[3]);
joindelay += cv_joindelay.value * TICRATE;
player_joining = true;
}
@ -5282,26 +5226,26 @@ static void CL_SendClientCmd(void)
else if (gamestate != GS_NULL && (addedtogame || dedicated))
{
packetsize = sizeof (clientcmd_pak);
G_MoveTiccmd(&netbuffer->u.clientpak.cmd, &localcmds, 1);
G_MoveTiccmd(&netbuffer->u.clientpak.cmd, &localcmds[0], 1);
netbuffer->u.clientpak.consistancy = SHORT(consistancy[gametic%TICQUEUE]);
if (splitscreen) // Send a special packet with 2 cmd for splitscreen
{
netbuffer->packettype = (mis ? PT_CLIENT2MIS : PT_CLIENT2CMD);
packetsize = sizeof (client2cmd_pak);
G_MoveTiccmd(&netbuffer->u.client2pak.cmd2, &localcmds2, 1);
G_MoveTiccmd(&netbuffer->u.client2pak.cmd2, &localcmds[1], 1);
if (splitscreen > 1)
{
netbuffer->packettype = (mis ? PT_CLIENT3MIS : PT_CLIENT3CMD);
packetsize = sizeof (client3cmd_pak);
G_MoveTiccmd(&netbuffer->u.client3pak.cmd3, &localcmds3, 1);
G_MoveTiccmd(&netbuffer->u.client3pak.cmd3, &localcmds[2], 1);
if (splitscreen > 2)
{
netbuffer->packettype = (mis ? PT_CLIENT4MIS : PT_CLIENT4CMD);
packetsize = sizeof (client4cmd_pak);
G_MoveTiccmd(&netbuffer->u.client4pak.cmd4, &localcmds4, 1);
G_MoveTiccmd(&netbuffer->u.client4pak.cmd4, &localcmds[3], 1);
}
}
}
@ -5312,43 +5256,43 @@ static void CL_SendClientCmd(void)
if (cl_mode == CL_CONNECTED || dedicated)
{
// Send extra data if needed
if (localtextcmd[0])
if (localtextcmd[0][0])
{
netbuffer->packettype = PT_TEXTCMD;
M_Memcpy(netbuffer->u.textcmd,localtextcmd, localtextcmd[0]+1);
M_Memcpy(netbuffer->u.textcmd,localtextcmd[0], localtextcmd[0][0]+1);
// All extra data have been sent
if (HSendPacket(servernode, true, 0, localtextcmd[0]+1)) // Send can fail...
localtextcmd[0] = 0;
if (HSendPacket(servernode, true, 0, localtextcmd[0][0]+1)) // Send can fail...
localtextcmd[0][0] = 0;
}
// Send extra data if needed for player 2 (splitscreen == 1)
if (localtextcmd2[0])
if (localtextcmd[1][0])
{
netbuffer->packettype = PT_TEXTCMD2;
M_Memcpy(netbuffer->u.textcmd, localtextcmd2, localtextcmd2[0]+1);
M_Memcpy(netbuffer->u.textcmd, localtextcmd[1], localtextcmd[1][0]+1);
// All extra data have been sent
if (HSendPacket(servernode, true, 0, localtextcmd2[0]+1)) // Send can fail...
localtextcmd2[0] = 0;
if (HSendPacket(servernode, true, 0, localtextcmd[1][0]+1)) // Send can fail...
localtextcmd[1][0] = 0;
}
// Send extra data if needed for player 3 (splitscreen == 2)
if (localtextcmd3[0])
if (localtextcmd[2][0])
{
netbuffer->packettype = PT_TEXTCMD3;
M_Memcpy(netbuffer->u.textcmd, localtextcmd3, localtextcmd3[0]+1);
M_Memcpy(netbuffer->u.textcmd, localtextcmd[2], localtextcmd[2][0]+1);
// All extra data have been sent
if (HSendPacket(servernode, true, 0, localtextcmd3[0]+1)) // Send can fail...
localtextcmd3[0] = 0;
if (HSendPacket(servernode, true, 0, localtextcmd[2][0]+1)) // Send can fail...
localtextcmd[2][0] = 0;
}
// Send extra data if needed for player 4 (splitscreen == 3)
if (localtextcmd4[0])
if (localtextcmd[3][0])
{
netbuffer->packettype = PT_TEXTCMD4;
M_Memcpy(netbuffer->u.textcmd, localtextcmd4, localtextcmd4[0]+1);
M_Memcpy(netbuffer->u.textcmd, localtextcmd[3], localtextcmd[3][0]+1);
// All extra data have been sent
if (HSendPacket(servernode, true, 0, localtextcmd4[0]+1)) // Send can fail...
localtextcmd4[0] = 0;
if (HSendPacket(servernode, true, 0, localtextcmd[3][0]+1)) // Send can fail...
localtextcmd[3][0] = 0;
}
}
}
@ -5485,23 +5429,23 @@ static void Local_Maketic(INT32 realtics)
if (!dedicated) rendergametic = gametic;
// translate inputs (keyboard/mouse/joystick) into game controls
G_BuildTiccmd(&localcmds, realtics, 1);
localcmds.angleturn |= TICCMD_RECEIVED;
G_BuildTiccmd(&localcmds[0], realtics, 1);
localcmds[0].angleturn |= TICCMD_RECEIVED;
if (splitscreen)
{
G_BuildTiccmd(&localcmds2, realtics, 2);
localcmds2.angleturn |= TICCMD_RECEIVED;
G_BuildTiccmd(&localcmds[1], realtics, 2);
localcmds[1].angleturn |= TICCMD_RECEIVED;
if (splitscreen > 1)
{
G_BuildTiccmd(&localcmds3, realtics, 3);
localcmds3.angleturn |= TICCMD_RECEIVED;
G_BuildTiccmd(&localcmds[2], realtics, 3);
localcmds[2].angleturn |= TICCMD_RECEIVED;
if (splitscreen > 2)
{
G_BuildTiccmd(&localcmds4, realtics, 4);
localcmds4.angleturn |= TICCMD_RECEIVED;
G_BuildTiccmd(&localcmds[3], realtics, 4);
localcmds[3].angleturn |= TICCMD_RECEIVED;
}
}
}

View file

@ -618,10 +618,8 @@ void D_ClientServerInit(void);
// Initialise the other field
void RegisterNetXCmd(netxcmd_t id, void (*cmd_f)(UINT8 **p, INT32 playernum));
void SendNetXCmd(netxcmd_t id, const void *param, size_t nparam);
void SendNetXCmd2(netxcmd_t id, const void *param, size_t nparam); // splitsreen player
void SendNetXCmd3(netxcmd_t id, const void *param, size_t nparam); // splitsreen3 player
void SendNetXCmd4(netxcmd_t id, const void *param, size_t nparam); // splitsreen4 player
void SendNetXCmdForPlayer(UINT8 playerid, netxcmd_t id, const void *param, size_t nparam);
#define SendNetXCmd(id, param, nparam) SendNetXCmdForPlayer(0, id, param, nparam) // Shortcut for P1
void SendKick(UINT8 playernum, UINT8 msg);
// Create any new ticcmds and broadcast to other players.
@ -636,7 +634,7 @@ void CL_AddSplitscreenPlayer(void);
void CL_RemoveSplitscreenPlayer(UINT8 p);
void CL_Reset(void);
void CL_ClearPlayer(INT32 playernum);
void CL_RemovePlayer(INT32 playernum, INT32 reason);
void CL_RemovePlayer(INT32 playernum, kickreason_t reason);
void CL_QueryServerList(msg_server_t *list);
void CL_UpdateServerList(boolean internetsearch, INT32 room);
// Is there a game running

File diff suppressed because it is too large Load diff

View file

@ -18,21 +18,9 @@
#include "command.h"
// console vars
extern consvar_t cv_playername;
extern consvar_t cv_playercolor;
extern consvar_t cv_skin;
// secondary splitscreen player
extern consvar_t cv_playername2;
extern consvar_t cv_playercolor2;
extern consvar_t cv_skin2;
// third splitscreen player
extern consvar_t cv_playername3;
extern consvar_t cv_playercolor3;
extern consvar_t cv_skin3;
// fourth splitscreen player
extern consvar_t cv_playername4;
extern consvar_t cv_playercolor4;
extern consvar_t cv_skin4;
extern consvar_t cv_playername[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_playercolor[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_skin[MAXSPLITSCREENPLAYERS];
// preferred number of players
extern consvar_t cv_splitplayers;

View file

@ -11269,7 +11269,7 @@ struct {
// Gametypes, for use with global var "gametype"
{"GT_RACE",GT_RACE},
{"GT_MATCH",GT_MATCH},
{"GT_BATTLE",GT_BATTLE},
// for P_DamageMobj
//// Damage types

View file

@ -1878,7 +1878,7 @@ void G_RecordDemo(const char *name)
demobuffer = malloc(maxsize);
demoend = demobuffer + maxsize;
demorecording = true;
demo.recording = true;
}
void G_RecordMetal(void)
@ -2712,8 +2712,8 @@ void G_DoPlayDemo(char *defdemoname)
M_StartMessage(msg, NULL, MM_NOTHING);
Z_Free(pdemoname);
Z_Free(demobuffer);
demoplayback = false;
titledemo = false;
demo.playback = false;
demo.title = false;
return;
}
demo_p += 12; // DEMOHEADER
@ -2732,8 +2732,8 @@ void G_DoPlayDemo(char *defdemoname)
M_StartMessage(msg, NULL, MM_NOTHING);
Z_Free(pdemoname);
Z_Free(demobuffer);
demoplayback = false;
titledemo = false;
demo.playback = false;
demo.title = false;
return;
}
@ -3530,7 +3530,7 @@ static void G_StopDemoRecording(void)
saved = FIL_WriteFile(va(pandf, srb2home, demoname), demobuffer, demo_p - demobuffer); // finally output the file.
}
free(demobuffer);
demorecording = false;
demo.recording = false;
if (modeattacking != ATTACKING_RECORD)
{

View file

@ -1543,7 +1543,7 @@ boolean G_Responder(event_t *ev)
|| ev->data1 == gamecontrol[0][gc_pause][1]
|| ev->data1 == KEY_PAUSE)
{
if (modeattacking && !demoplayback && (gamestate == GS_LEVEL))
if (modeattacking && !demo.playback && (gamestate == GS_LEVEL))
{
pausebreakkey = (ev->data1 == KEY_PAUSE);
if (menuactive || pausedelay < 0 || leveltime < 2)
@ -3028,60 +3028,20 @@ void G_SetGametypeDescription(INT16 gtype, char *descriptiontext, UINT8 leftcolo
// Gametype rankings
INT16 gametyperankings[NUMGAMETYPES] =
{
GT_COOP,
GT_COMPETITION,
GT_RACE,
GT_MATCH,
GT_TEAMMATCH,
GT_TAG,
GT_HIDEANDSEEK,
GT_CTF,
GT_BATTLE,
};
// Gametype to TOL (Type Of Level)
UINT32 gametypetol[NUMGAMETYPES] =
{
TOL_COOP, // Co-op
TOL_COMPETITION, // Competition
TOL_RACE, // Race
TOL_MATCH, // Match
TOL_MATCH, // Team Match
TOL_TAG, // Tag
TOL_TAG, // Hide and Seek
TOL_CTF, // CTF
TOL_BATTLE, // Battle
};
tolinfo_t TYPEOFLEVEL[NUMTOLNAMES] = {
{"SOLO",TOL_SP},
{"SP",TOL_SP},
{"SINGLEPLAYER",TOL_SP},
{"SINGLE",TOL_SP},
{"COOP",TOL_COOP},
{"CO-OP",TOL_COOP},
{"COMPETITION",TOL_COMPETITION},
{"RACE",TOL_RACE},
{"MATCH",TOL_MATCH},
{"TAG",TOL_TAG},
{"CTF",TOL_CTF},
{"2D",TOL_2D},
{"MARIO",TOL_MARIO},
{"NIGHTS",TOL_NIGHTS},
{"OLDBRAK",TOL_ERZ3},
{"XMAS",TOL_XMAS},
{"CHRISTMAS",TOL_XMAS},
{"WINTER",TOL_XMAS},
{"BATTLE",TOL_BATTLE},
{NULL, 0}
};
@ -3537,11 +3497,10 @@ void G_AddMapToBuffer(INT16 map)
//
static void G_UpdateVisited(void)
{
boolean spec = G_IsSpecialStage(gamemap);
// Update visitation flags?
if ((!modifiedgame || savemoddata) // Not modified
&& !multiplayer && !demoplayback && (gametype == GT_COOP) // SP/RA/NiGHTS mode
&& !multiplayer && !demo.playback && (gametype == GT_COOP) // SP/RA/NiGHTS mode
&& !(spec && stagefailed)) // Not failed the special stage
{
UINT8 earnedEmblems;
@ -3609,12 +3568,12 @@ static void G_HandleSaveLevel(void)
remove(liveeventbackup);
cursaveslot = 0;
}
else if ((!modifiedgame || savemoddata) && !(netgame || multiplayer || ultimatemode || demorecording || metalrecording || modeattacking))
else if ((!modifiedgame || savemoddata) && !(netgame || multiplayer || ultimatemode || demo.recording || metalrecording || modeattacking))
G_SaveGame((UINT32)cursaveslot, spstage_start);
}
}
// and doing THIS here means you don't lose your progress if you close the game mid-intermission
else if (!(ultimatemode || netgame || multiplayer || demoplayback || demorecording || metalrecording || modeattacking)
else if (!(ultimatemode || netgame || multiplayer || demo.playback || demo.recording || metalrecording || modeattacking)
&& (!modifiedgame || savemoddata) && cursaveslot > 0 && CanSaveLevel(lastmap+1))
G_SaveGame((UINT32)cursaveslot, lastmap+1); // not nextmap+1 to route around special stages
}
@ -3964,7 +3923,7 @@ static void G_DoContinued(void)
tokenlist = 0;
token = 0;
if (!(netgame || multiplayer || demoplayback || demorecording || metalrecording || modeattacking) && (!modifiedgame || savemoddata) && cursaveslot > 0)
if (!(netgame || multiplayer || demo.playback || demo.recording || metalrecording || modeattacking) && (!modifiedgame || savemoddata) && cursaveslot > 0)
G_SaveGameOver((UINT32)cursaveslot, true);
// Reset # of lives

View file

@ -157,23 +157,7 @@ void COM_Lua_f(void)
for (i = 0; i < argc; i++)
WRITESTRINGN(p, COM_Argv(i), 255);
switch (lpn)
{
case 3:
SendNetXCmd4(XD_LUACMD, buf, p-buf);
break;
case 2:
SendNetXCmd3(XD_LUACMD, buf, p-buf);
break;
case 1:
SendNetXCmd2(XD_LUACMD, buf, p-buf);
break;
default:
case 0:
SendNetXCmd(XD_LUACMD, buf, p-buf);
break;
}
SendNetXCmdForPlayer(lpn, XD_LUACMD, buf, p-buf);
free(buf);
return;
}

View file

@ -841,9 +841,9 @@ static menuitem_t SP_GrandPrixPlaceholderMenu[] =
// Single Player Time Attack
static menuitem_t SP_TimeAttackMenu[] =
{
{IT_STRING|IT_CVAR|IT_CV_STRING, NULL, "Name", &cv_playername, 0},
{IT_STRING|IT_CVAR|IT_CV_STRING, NULL, "Name", &cv_playername[0], 0},
{IT_STRING|IT_CVAR, NULL, "Character", &cv_chooseskin, 13},
{IT_STRING|IT_CVAR, NULL, "Color", &cv_playercolor, 26},
{IT_STRING|IT_CVAR, NULL, "Color", &cv_playercolor[0], 26},
{IT_STRING|IT_CVAR, NULL, "Level", &cv_nextmap, 78},
{IT_DISABLED, NULL, "Guest...", &SP_GuestReplayDef, 98},
@ -9815,14 +9815,14 @@ static void M_SetupMultiPlayer(INT32 choice)
multi_state = &states[mobjinfo[MT_PLAYER].seestate];
multi_tics = multi_state->tics;
strcpy(setupm_name, cv_playername.string);
strcpy(setupm_name, cv_playername[0].string);
// set for player 1
setupm_player = &players[consoleplayer];
setupm_cvskin = &cv_skin;
setupm_cvcolor = &cv_playercolor;
setupm_cvname = &cv_playername;
setupm_cvfollower = &cv_follower;
setupm_cvskin = &cv_skin[0];
setupm_cvcolor = &cv_playercolor[0];
setupm_cvname = &cv_playername[0];
setupm_cvfollower = &cv_follower[0];
setupm_fakefollower = atoi(setupm_cvfollower->string); // update fake follower value
@ -9855,14 +9855,14 @@ static void M_SetupMultiPlayer2(INT32 choice)
multi_state = &states[mobjinfo[MT_PLAYER].seestate];
multi_tics = multi_state->tics;
strcpy (setupm_name, cv_playername2.string);
strcpy (setupm_name, cv_playername[1].string);
// set for splitscreen secondary player
setupm_player = &players[g_localplayers[1]];
setupm_cvskin = &cv_skin2;
setupm_cvcolor = &cv_playercolor2;
setupm_cvname = &cv_playername2;
setupm_cvfollower = &cv_follower2;
setupm_cvskin = &cv_skin[1];
setupm_cvcolor = &cv_playercolor[1];
setupm_cvname = &cv_playername[1];
setupm_cvfollower = &cv_follower[1];
setupm_fakefollower = atoi(setupm_cvfollower->string); // update fake follower value
@ -9895,14 +9895,14 @@ static void M_SetupMultiPlayer3(INT32 choice)
multi_state = &states[mobjinfo[MT_PLAYER].seestate];
multi_tics = multi_state->tics;
strcpy(setupm_name, cv_playername3.string);
strcpy(setupm_name, cv_playername[2].string);
// set for splitscreen third player
setupm_player = &players[g_localplayers[2]];
setupm_cvskin = &cv_skin3;
setupm_cvcolor = &cv_playercolor3;
setupm_cvname = &cv_playername3;
setupm_cvfollower = &cv_follower3;
setupm_cvskin = &cv_skin[2];
setupm_cvcolor = &cv_playercolor[2];
setupm_cvname = &cv_playername[2];
setupm_cvfollower = &cv_follower[2];
setupm_fakefollower = atoi(setupm_cvfollower->string); // update fake follower value
@ -9935,14 +9935,14 @@ static void M_SetupMultiPlayer4(INT32 choice)
multi_state = &states[mobjinfo[MT_PLAYER].seestate];
multi_tics = multi_state->tics;
strcpy(setupm_name, cv_playername4.string);
strcpy(setupm_name, cv_playername[3].string);
// set for splitscreen fourth player
setupm_player = &players[g_localplayers[3]];
setupm_cvskin = &cv_skin4;
setupm_cvcolor = &cv_playercolor4;
setupm_cvname = &cv_playername4;
setupm_cvfollower = &cv_follower4;
setupm_cvskin = &cv_skin[3];
setupm_cvcolor = &cv_playercolor[3];
setupm_cvname = &cv_playername[3];
setupm_cvfollower = &cv_follower[3];
setupm_fakefollower = atoi(setupm_cvfollower->string); // update fake follower value

View file

@ -783,7 +783,7 @@ static void M_PNGText(png_structp png_ptr, png_infop png_info_ptr, PNG_CONST png
"Title", "Description", "Playername", "Mapnum", "Mapname",
"Location", "Interface", "Render Mode", "Revision", "Build Date", "Build Time"};
char titletxt[] = "SRB2Kart " VERSIONSTRING;
png_charp playertxt = cv_playername.zstring;
png_charp playertxt = cv_playername[0].zstring;
char desctxt[] = "SRB2Kart Screenshot";
char Movietxt[] = "SRB2Kart Movie";
size_t i;

View file

@ -1327,7 +1327,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget
S_ChangeMusicEx("_gover", 0, 0, 0, (2*MUSICRATE) - (MUSICRATE/25), 0); // 1.96 seconds
//P_PlayJingle(target->player, JT_GOVER); // can't be used because incompatible with track fadeout
if (!(netgame || multiplayer || demoplayback || demorecording || metalrecording || modeattacking) && numgameovers < maxgameovers)
if (!(netgame || multiplayer || demo.playback || demo.recording || metalrecording || modeattacking) && numgameovers < maxgameovers)
{
numgameovers++;
if ((!modifiedgame || savemoddata) && cursaveslot > 0)

View file

@ -61,6 +61,8 @@
#define mariomode (maptol & TOL_MARIO)
#define P_GetPlayerViewHeight(player) (41*player->mo->height/48)
typedef enum
{
THINK_POLYOBJ,

View file

@ -2624,7 +2624,7 @@ void P_PlayerZMovement(mobj_t *mo)
mo->player->viewheight -= mo->floorz - mo->z;
mo->player->deltaviewheight =
(FixedMul(41*mo->player->height/48, mo->scale) - mo->player->viewheight)>>3;
(P_GetPlayerViewHeight(mo->player) - mo->player->viewheight)>>3;
}
// adjust height
@ -13426,7 +13426,7 @@ void P_AfterPlayerSpawn(INT32 playernum)
P_SetPlayerAngle(p, mobj->angle);
p->viewheight = 41*p->height/48;
p->viewheight = P_GetPlayerViewHeight(p);
if (p->mo->eflags & MFE_VERTICALFLIP)
p->viewz = p->mo->z + p->mo->height - p->viewheight;

View file

@ -480,24 +480,10 @@ static void P_NetUnArchivePlayers(void)
players[i].botvars.itemdelay = READUINT32(save_p);
players[i].botvars.itemconfirm = READUINT32(save_p);
players[i].botvars.turnconfirm = READSINT8(save_p);
=======
players[i].thokitem = (mobjtype_t)READUINT32(save_p);
players[i].spinitem = (mobjtype_t)READUINT32(save_p);
players[i].revitem = (mobjtype_t)READUINT32(save_p);
players[i].followitem = (mobjtype_t)READUINT32(save_p);
players[i].actionspd = READFIXED(save_p);
players[i].mindash = READFIXED(save_p);
players[i].maxdash = READFIXED(save_p);
players[i].normalspeed = READFIXED(save_p);
players[i].runspeed = READFIXED(save_p);
players[i].thrustfactor = READUINT8(save_p);
players[i].accelstart = READUINT8(save_p);
players[i].acceleration = READUINT8(save_p);
players[i].jumpfactor = READFIXED(save_p);
players[i].height = READFIXED(save_p);
players[i].spinheight = READFIXED(save_p);
players[i].viewheight = 41*players[i].height/48; // scale cannot be factored in at this point
players[i].followitem = (mobjtype_t)READUINT32(save_p);
//players[i].viewheight = P_GetPlayerViewHeight(players[i]); // scale cannot be factored in at this point
}
}

View file

@ -3849,45 +3849,12 @@ static void P_InitCamera(void)
{
if (!dedicated)
{
UINT8 i;
P_SetupCamera();
// Salt: CV_ClearChangedFlags() messes with your settings :(
/*if (!cv_cam_height.changed)
CV_Set(&cv_cam_height, cv_cam_height.defaultvalue);
if (!cv_cam2_height.changed)
CV_Set(&cv_cam2_height, cv_cam2_height.defaultvalue);
if (!cv_cam_dist.changed)
CV_Set(&cv_cam_dist, cv_cam_dist.defaultvalue);
if (!cv_cam2_dist.changed)
CV_Set(&cv_cam2_dist, cv_cam2_dist.defaultvalue);*/
// Though, I don't think anyone would care about cam_rotate being reset back to the only value that makes sense :P
if (!cv_cam_rotate.changed)
CV_Set(&cv_cam_rotate, cv_cam_rotate.defaultvalue);
if (!cv_cam2_rotate.changed)
CV_Set(&cv_cam2_rotate, cv_cam2_rotate.defaultvalue);
if (!cv_analog[0].changed)
CV_SetValue(&cv_analog[0], 0);
if (!cv_analog[1].changed)
CV_SetValue(&cv_analog[1], 0);
displayplayer = consoleplayer; // Start with your OWN view, please!
}
if (twodlevel)
{
CV_SetValue(&cv_analog[0], false);
CV_SetValue(&cv_analog[1], false);
}
else
{
if (cv_useranalog[0].value)
CV_SetValue(&cv_analog[0], true);
if ((splitscreen && cv_useranalog[1].value) || botingame)
CV_SetValue(&cv_analog[1], true);
for (i = 0; i <= splitscreen; i++)
displayplayers[i] = g_localplayers[i]; // Start with your OWN view, please!
}
}
@ -4346,7 +4313,7 @@ boolean P_LoadLevel(boolean fromnetsave)
if (!lastmaploaded) // Start a new game?
{
// I'd love to do this in the menu code instead of here, but everything's a mess and I can't guarantee saving proper player struct info before the first act's started. You could probably refactor it, but it'd be a lot of effort. Easier to just work off known good code. ~toast 22/06/2020
if (!(ultimatemode || netgame || multiplayer || demoplayback || demorecording || metalrecording || modeattacking || marathonmode)
if (!(ultimatemode || netgame || multiplayer || demo.playback || demo.recording || metalrecording || modeattacking || marathonmode)
&& (!modifiedgame || savemoddata) && cursaveslot > 0)
G_SaveGame((UINT32)cursaveslot, gamemap);
// If you're looking for saving sp file progression (distinct from G_SaveGameOver), check G_DoCompleted.

View file

@ -248,7 +248,7 @@ void P_CalcHeight(player_t *player)
}
// move viewheight
pviewheight = FixedMul(41*player->height/48, mo->scale); // default eye view height
pviewheight = P_GetPlayerViewHeight(player); // default eye view height
if (player->mo->eflags & MFE_VERTICALFLIP)
player->viewz = mo->z + mo->height - player->viewheight - bob;
@ -3191,9 +3191,9 @@ void P_ResetCamera(player_t *player, camera_t *thiscam)
x = player->mo->x - P_ReturnThrustX(player->mo, thiscam->angle, player->mo->radius);
y = player->mo->y - P_ReturnThrustY(player->mo, thiscam->angle, player->mo->radius);
if (player->mo->eflags & MFE_VERTICALFLIP)
z = player->mo->z + player->mo->height - (41*player->height/48) - 16*FRACUNIT;
z = player->mo->z + player->mo->height - P_GetPlayerViewHeight(player) - 16*FRACUNIT;
else
z = player->mo->z + (41*player->height/48);
z = player->mo->z + P_GetPlayerViewHeight(player);
// set bits for the camera
thiscam->x = x;
@ -4683,7 +4683,7 @@ void P_PlayerAfterThink(player_t *player)
{
// defaults to make sure 1st person cam doesn't do anything weird on startup
player->deltaviewheight = 0;
player->viewheight = FixedMul(41*player->height/48, player->mo->scale);
player->viewheight = P_GetPlayerViewHeight(player);
if (player->mo->eflags & MFE_VERTICALFLIP)
player->viewz = player->mo->z + player->mo->height - player->viewheight;

View file

@ -1859,8 +1859,8 @@ void Y_StartVote(void)
I_Error("voteendtic is dirty");
#endif
widebgpatch = W_CachePatchName(((gametype == GT_MATCH) ? "BATTLSCW" : "INTERSCW"), PU_STATIC);
bgpatch = W_CachePatchName(((gametype == GT_MATCH) ? "BATTLSCR" : "INTERSCR"), PU_STATIC);
widebgpatch = W_CachePatchName(((gametype == GT_BATTLE) ? "BATTLSCW" : "INTERSCW"), PU_STATIC);
bgpatch = W_CachePatchName(((gametype == GT_BATTLE) ? "BATTLSCR" : "INTERSCR"), PU_STATIC);
cursor = W_CachePatchName("M_CURSOR", PU_STATIC);
cursor1 = W_CachePatchName("P1CURSOR", PU_STATIC);
cursor2 = W_CachePatchName("P2CURSOR", PU_STATIC);