From a50a9a18436cd0ecc04b1eb8bf7296e2a8dce5e5 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Mon, 10 Aug 2020 23:38:32 -0400 Subject: [PATCH] Lots of splitscreen fixes LOTS of stuff I changed to use arrays instead of constantly duplicated code --- src/command.c | 12 +- src/d_clisrv.c | 182 +++---- src/d_clisrv.h | 8 +- src/d_netcmd.c | 1116 +++++++++--------------------------------- src/d_netcmd.h | 18 +- src/dehacked.c | 2 +- src/g_demo.c | 12 +- src/g_game.c | 57 +-- src/lua_consolelib.c | 18 +- src/m_menu.c | 44 +- src/m_misc.c | 2 +- src/p_inter.c | 2 +- src/p_local.h | 2 + src/p_mobj.c | 4 +- src/p_saveg.c | 20 +- src/p_setup.c | 43 +- src/p_user.c | 8 +- src/y_inter.c | 4 +- 18 files changed, 355 insertions(+), 1199 deletions(-) diff --git a/src/command.c b/src/command.c index f80dec82a..12387a392 100644 --- a/src/command.c +++ b/src/command.c @@ -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); diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 0d8086cbb..2b275d8bb 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -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; } } } diff --git a/src/d_clisrv.h b/src/d_clisrv.h index eb85568a0..9604deb7e 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -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 diff --git a/src/d_netcmd.c b/src/d_netcmd.c index f1ba30d79..c49e796c0 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -274,21 +274,27 @@ consvar_t cv_allowseenames = {"allowseenames", "No", CV_NETVAR, CV_YesNo, NULL, #endif // names -consvar_t cv_playername = {"name", "Sonic", CV_SAVE|CV_CALL|CV_NOINIT, NULL, Name_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_playername2 = {"name2", "Tails", CV_SAVE|CV_CALL|CV_NOINIT, NULL, Name2_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_playername3 = {"name3", "Knuckles", CV_SAVE|CV_CALL|CV_NOINIT, NULL, Name3_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_playername4 = {"name4", "Dr. Eggman", CV_SAVE|CV_CALL|CV_NOINIT, NULL, Name4_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_playername[MAXSPLITSCREENPLAYERS] = { + {"name", "Sonic", CV_SAVE|CV_CALL|CV_NOINIT, NULL, Name_OnChange, 0, NULL, NULL, 0, 0, NULL}, + {"name2", "Tails", CV_SAVE|CV_CALL|CV_NOINIT, NULL, Name2_OnChange, 0, NULL, NULL, 0, 0, NULL}, + {"name3", "Knuckles", CV_SAVE|CV_CALL|CV_NOINIT, NULL, Name3_OnChange, 0, NULL, NULL, 0, 0, NULL}, + {"name4", "Dr. Eggman", CV_SAVE|CV_CALL|CV_NOINIT, NULL, Name4_OnChange, 0, NULL, NULL, 0, 0, NULL} +}; // player colors -UINT16 lastgoodcolor = SKINCOLOR_BLUE, lastgoodcolor2 = SKINCOLOR_BLUE, lastgoodcolor3 = SKINCOLOR_BLUE, lastgoodcolor4 = SKINCOLOR_BLUE; -consvar_t cv_playercolor = {"color", "Blue", CV_SAVE|CV_CALL|CV_NOINIT, Color_cons_t, Color_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_playercolor2 = {"color2", "Orange", CV_SAVE|CV_CALL|CV_NOINIT, Color_cons_t, Color2_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_playercolor3 = {"color3", "Red", CV_SAVE|CV_CALL|CV_NOINIT, Color_cons_t, Color3_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_playercolor4 = {"color4", "Red", CV_SAVE|CV_CALL|CV_NOINIT, Color_cons_t, Color4_OnChange, 0, NULL, NULL, 0, 0, NULL}; +UINT16 lastgoodcolor[MAXSPLITSCREENPLAYERS] = {SKINCOLOR_BLUE, SKINCOLOR_BLUE, SKINCOLOR_BLUE, SKINCOLOR_BLUE}; +consvar_t cv_playercolor[MAXSPLITSCREENPLAYERS] = { + {"color", "Blue", CV_SAVE|CV_CALL|CV_NOINIT, Color_cons_t, Color_OnChange, 0, NULL, NULL, 0, 0, NULL}, + {"color2", "Orange", CV_SAVE|CV_CALL|CV_NOINIT, Color_cons_t, Color2_OnChange, 0, NULL, NULL, 0, 0, NULL}, + {"color3", "Red", CV_SAVE|CV_CALL|CV_NOINIT, Color_cons_t, Color3_OnChange, 0, NULL, NULL, 0, 0, NULL}, + {"color4", "Red", CV_SAVE|CV_CALL|CV_NOINIT, Color_cons_t, Color4_OnChange, 0, NULL, NULL, 0, 0, NULL} +}; // player's skin, saved for commodity, when using a favorite skins wad.. -consvar_t cv_skin = {"skin", DEFAULTSKIN, CV_SAVE|CV_CALL|CV_NOINIT, NULL, Skin_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_skin2 = {"skin2", DEFAULTSKIN2, CV_SAVE|CV_CALL|CV_NOINIT, NULL, Skin2_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_skin3 = {"skin3", DEFAULTSKIN3, CV_SAVE|CV_CALL|CV_NOINIT, NULL, Skin3_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_skin4 = {"skin4", DEFAULTSKIN4, CV_SAVE|CV_CALL|CV_NOINIT, NULL, Skin4_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_skin[MAXSPLITSCREENPLAYERS] = { + {"skin", DEFAULTSKIN, CV_SAVE|CV_CALL|CV_NOINIT, NULL, Skin_OnChange, 0, NULL, NULL, 0, 0, NULL}, + {"skin2", DEFAULTSKIN2, CV_SAVE|CV_CALL|CV_NOINIT, NULL, Skin2_OnChange, 0, NULL, NULL, 0, 0, NULL}, + {"skin3", DEFAULTSKIN3, CV_SAVE|CV_CALL|CV_NOINIT, NULL, Skin3_OnChange, 0, NULL, NULL, 0, 0, NULL}, + {"skin4", DEFAULTSKIN4, CV_SAVE|CV_CALL|CV_NOINIT, NULL, Skin4_OnChange, 0, NULL, NULL, 0, 0, NULL} +}; consvar_t cv_skipmapcheck = {"skipmapcheck", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -900,21 +906,13 @@ void D_RegisterClientCommands(void) #endif // register these so it is saved to config - CV_RegisterVar(&cv_playername); - CV_RegisterVar(&cv_playercolor); - CV_RegisterVar(&cv_skin); // r_things.c (skin NAME) - // secondary player (splitscreen) - CV_RegisterVar(&cv_playername2); - CV_RegisterVar(&cv_playercolor2); - CV_RegisterVar(&cv_skin2); - // third player - CV_RegisterVar(&cv_playername3); - CV_RegisterVar(&cv_playercolor3); - CV_RegisterVar(&cv_skin3); - // fourth player - CV_RegisterVar(&cv_playername4); - CV_RegisterVar(&cv_playercolor4); - CV_RegisterVar(&cv_skin4); + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) + { + CV_RegisterVar(&cv_playername[i]); + CV_RegisterVar(&cv_playercolor[i]); + CV_RegisterVar(&cv_skin[i]); + } + // preferred number of players CV_RegisterVar(&cv_splitplayers); @@ -1209,21 +1207,19 @@ boolean EnsurePlayerNameIsGood(char *name, INT32 playernum) /** Cleans up a local player's name before sending a name change. * Spaces at the beginning or end of the name are removed. Then if the new * name is identical to another player's name, ignoring case, the name change - * is canceled, and the name in cv_playername.value or cv_playername2.value + * is canceled, and the name in cv_playername[n].value * is restored to what it was before. * - * We assume that if playernum is ::consoleplayer or ::secondarydisplayplayer - * the console variable ::cv_playername or ::cv_playername2 respectively is + * We assume that if playernum is in ::g_localplayers + * the console variable ::cv_playername[n] is * already set to newname. However, the player name table is assumed to * contain the old name. * * \param playernum Player number who has requested a name change. - * Should be ::consoleplayer or ::secondarydisplayplayer. + * Should be in ::g_localplayers. * \param newname New name for that player; should already be in - * ::cv_playername or ::cv_playername2 if player is the - * console or secondary display player, respectively. - * \sa cv_playername, cv_playername2, SendNameAndColor, SendNameAndColor2, - * SetPlayerName + * ::cv_playername if player is a local player. + * \sa cv_playername, SendNameAndColor, SetPlayerName * \author Graue */ void CleanupPlayerName(INT32 playernum, const char *newname) @@ -1311,15 +1307,19 @@ void CleanupPlayerName(INT32 playernum, const char *newname) // set consvars whether namefailed or not, because even if it succeeded, // spaces may have been removed - if (playernum == consoleplayer) - CV_StealthSet(&cv_playername, tmpname); - else if (playernum == g_localplayers[1] || (!netgame && playernum == 1)) - CV_StealthSet(&cv_playername2, tmpname); - else if (playernum == g_localplayers[2] || (!netgame && playernum == 2)) - CV_StealthSet(&cv_playername3, tmpname); - else if (playernum == g_localplayers[3] || (!netgame && playernum == 3)) - CV_StealthSet(&cv_playername4, tmpname); - else I_Assert(((void)"CleanupPlayerName used on non-local player", 0)); + for (i = 0; i <= splitscreen; i++) + { + if (playernum == g_localplayers[i]) + { + CV_StealthSet(&cv_playername[i], tmpname); + break; + } + } + + if (i > splitscreen) + { + I_Assert(((void)"CleanupPlayerName used on non-local player", 0)); + } Z_Free(buf); } @@ -1463,48 +1463,49 @@ VaguePartyDescription (int playernum, int *party_sizes, int default_color) return party_description; } -static INT32 snacpending = 0, snac2pending = 0, snac3pending = 0, snac4pending = 0, chmappending = 0; +static INT32 snacpending[MAXSPLITSCREENPLAYERS] = {0,0,0,0}; +static INT32 chmappending = 0; // name, color, or skin has changed // -static void SendNameAndColor(void) +static void SendNameAndColor(UINT8 n) { - char buf[MAXPLAYERNAME+6]; + const INT32 playernum = g_localplayers[n]; + const player_t *player = &players[playernum]; + + XBOXSTATIC char buf[MAXPLAYERNAME+2]; char *p; - p = buf; + if (splitscreen < playernum) + return; // can happen if skin4/color4/name4 changed - // normal player colors - if (G_GametypeHasTeams()) - { - if (players[consoleplayer].ctfteam == 1 && cv_playercolor.value != skincolor_redteam) - CV_StealthSetValue(&cv_playercolor, skincolor_redteam); - else if (players[consoleplayer].ctfteam == 2 && cv_playercolor.value != skincolor_blueteam) - CV_StealthSetValue(&cv_playercolor, skincolor_blueteam); - } + if (playernum == -1) + return; + + p = buf; // don't allow inaccessible colors if (!skincolors[cv_playercolor.value].accessible) { - if (players[consoleplayer].skincolor && skincolors[players[consoleplayer].skincolor].accessible) - CV_StealthSetValue(&cv_playercolor, players[consoleplayer].skincolor); - else if (skincolors[atoi(cv_playercolor.defaultvalue)].accessible) - CV_StealthSet(&cv_playercolor, cv_playercolor.defaultvalue); - else if (skins[players[consoleplayer].skin].prefcolor && skincolors[skins[players[consoleplayer].skin].prefcolor].accessible) - CV_StealthSetValue(&cv_playercolor, skins[players[consoleplayer].skin].prefcolor); + if (player->skincolor && skincolors[player->skincolor].accessible) + CV_StealthSetValue(&cv_playercolor[n], player->skincolor); + else if (skins[player->skin].prefcolor && skincolors[player->skin].prefcolor].accessible) + CV_StealthSetValue(&cv_playercolor, skins[player->skin].prefcolor); + else if (skincolors[atoi(cv_playercolor[n].defaultvalue)].accessible) + CV_StealthSet(&cv_playercolor[n], cv_playercolor[n].defaultvalue); else { UINT16 i = 0; while (iskincolor + && !strcmp(cv_skin[n].string, skins[player->skin].name)) return; - players[consoleplayer].availabilities = R_GetSkinAvailabilities(); + player->availabilities = R_GetSkinAvailabilities(); // We'll handle it later if we're not playing. if (!Playing()) @@ -1515,408 +1516,63 @@ static void SendNameAndColor(void) { INT32 foundskin; - CleanupPlayerName(consoleplayer, cv_playername.zstring); - strcpy(player_names[consoleplayer], cv_playername.zstring); + CleanupPlayerName(playernum, cv_playername[n].zstring); + strcpy(player_names[playernum], cv_playername[n].zstring); - players[consoleplayer].skincolor = cv_playercolor.value; + player->skincolor = cv_playercolor[n].value; - if (players[consoleplayer].mo && !players[consoleplayer].powers[pw_dye]) - players[consoleplayer].mo->color = players[consoleplayer].skincolor; + if (player->mo && !player->powers[pw_dye]) + player->mo->color = player->skincolor; - if (metalrecording) + if (metalrecording && n == 0) { // Starring Metal Sonic as themselves, obviously. - SetPlayerSkinByNum(consoleplayer, 5); - CV_StealthSet(&cv_skin, skins[5].name); + SetPlayerSkinByNum(playernum, 5); + CV_StealthSet(&cv_skin[n], skins[5].name); } - else if ((foundskin = R_SkinAvailable(cv_skin.string)) != -1 && R_SkinUsable(consoleplayer, foundskin)) + else if ((foundskin = R_SkinAvailable(cv_skin[n].string)) != -1 && R_SkinUsable(playernum, foundskin)) { - cv_skin.value = foundskin; - SetPlayerSkin(consoleplayer, cv_skin.string); - CV_StealthSet(&cv_skin, skins[cv_skin.value].name); + cv_skin[n].value = foundskin; + SetPlayerSkin(playernum, cv_skin[n].string); + CV_StealthSet(&cv_skin[n], skins[cv_skin[n].value].name); } else { - cv_skin.value = players[consoleplayer].skin; - CV_StealthSet(&cv_skin, skins[players[consoleplayer].skin].name); + cv_skin[n].value = players[playernum].skin; + CV_StealthSet(&cv_skin[n], skins[player->skin].name); // will always be same as current - SetPlayerSkin(consoleplayer, cv_skin.string); + SetPlayerSkin(playernum, cv_skin[n].string); } return; } - snacpending++; + snacpending[n]++; // Don't change name if muted - if (cv_mute.value && !(server || IsPlayerAdmin(consoleplayer))) - CV_StealthSet(&cv_playername, player_names[consoleplayer]); + if (cv_mute.value && !(server || IsPlayerAdmin(playernum))) + CV_StealthSet(&cv_playername[n], player_names[playernum]); else // Cleanup name if changing it - CleanupPlayerName(consoleplayer, cv_playername.zstring); + CleanupPlayerName(playernum, cv_playername[n].zstring); // Don't change skin if the server doesn't want you to. - if (!CanChangeSkin(consoleplayer)) - CV_StealthSet(&cv_skin, skins[players[consoleplayer].skin].name); + if (!CanChangeSkin(playernum)) + CV_StealthSet(&cv_skin[n], skins[player->skin].name); // check if player has the skin loaded (cv_skin may have // the name of a skin that was available in the previous game) - cv_skin.value = R_SkinAvailable(cv_skin.string); - if ((cv_skin.value < 0) || !R_SkinUsable(consoleplayer, cv_skin.value)) + cv_skin[n].value = R_SkinAvailable(cv_skin.string); + if ((cv_skin[n].value < 0) || !R_SkinUsable(playernum, cv_skin[n].value)) { - CV_StealthSet(&cv_skin, DEFAULTSKIN); - cv_skin.value = 0; + CV_StealthSet(&cv_skin[n], DEFAULTSKIN); + cv_skin[n].value = 0; } // Finally write out the complete packet and send it off. - WRITESTRINGN(p, cv_playername.zstring, MAXPLAYERNAME); - WRITEUINT32(p, (UINT32)players[consoleplayer].availabilities); - WRITEUINT16(p, (UINT16)cv_playercolor.value); - WRITEUINT8(p, (UINT8)cv_skin.value); - SendNetXCmd(XD_NAMEANDCOLOR, buf, p - buf); -} - -// splitscreen -static void SendNameAndColor2(void) -{ - INT32 secondplaya = -1; - XBOXSTATIC char buf[MAXPLAYERNAME+2]; - char *p; - - if (splitscreen < 1) - return; // can happen if skin2/color2/name2 changed - - if (g_localplayers[1] != consoleplayer) - secondplaya = g_localplayers[1]; - else if (!netgame) // HACK - secondplaya = 1; - - if (secondplaya == -1) - return; - - p = buf; - - // normal player colors - if (G_GametypeHasTeams()) - { - if (players[secondplaya].ctfteam == 1 && cv_playercolor2.value != skincolor_redteam) - CV_StealthSetValue(&cv_playercolor2, skincolor_redteam); - else if (players[secondplaya].ctfteam == 2 && cv_playercolor2.value != skincolor_blueteam) - CV_StealthSetValue(&cv_playercolor2, skincolor_blueteam); - } - - // don't allow inaccessible colors - if (!skincolors[cv_playercolor2.value].accessible) - { - if (players[secondplaya].skincolor && skincolors[players[secondplaya].skincolor].accessible) - CV_StealthSetValue(&cv_playercolor2, players[secondplaya].skincolor); - else if (skincolors[atoi(cv_playercolor2.defaultvalue)].accessible) - CV_StealthSet(&cv_playercolor, cv_playercolor2.defaultvalue); - else if (skins[players[secondplaya].skin].prefcolor && skincolors[skins[players[secondplaya].skin].prefcolor].accessible) - CV_StealthSetValue(&cv_playercolor2, skins[players[secondplaya].skin].prefcolor); - else { - UINT16 i = 0; - while (icolor = players[secondplaya].skincolor; - - if (cv_forceskin.value >= 0 && (netgame || multiplayer)) // Server wants everyone to use the same player - { - const INT32 forcedskin = cv_forceskin.value; - - SetPlayerSkinByNum(secondplaya, forcedskin); - CV_StealthSet(&cv_skin2, skins[forcedskin].name); - } - else if ((foundskin = R_SkinAvailable(cv_skin2.string)) != -1 && R_SkinUsable(secondplaya, foundskin)) - { - cv_skin2.value = foundskin; - SetPlayerSkin(secondplaya, cv_skin2.string); - CV_StealthSet(&cv_skin2, skins[cv_skin2.value].name); - } - else - { - cv_skin2.value = players[secondplaya].skin; - CV_StealthSet(&cv_skin2, skins[players[secondplaya].skin].name); - // will always be same as current - SetPlayerSkin(secondplaya, cv_skin2.string); - } - return; - } - - snac2pending++; - - // Don't change name if muted - if (cv_mute.value && !(server || IsPlayerAdmin(g_localplayers[1]))) - CV_StealthSet(&cv_playername2, player_names[g_localplayers[1]]); - else // Cleanup name if changing it - CleanupPlayerName(g_localplayers[1], cv_playername2.zstring); - - // Don't change skin if the server doesn't want you to. - if (!CanChangeSkin(g_localplayers[1])) - CV_StealthSet(&cv_skin2, skins[players[g_localplayers[1]].skin].name); - - // check if player has the skin loaded (cv_skin2 may have - // the name of a skin that was available in the previous game) - cv_skin2.value = R_SkinAvailable(cv_skin2.string); - if (cv_skin2.value < 0) - { - CV_StealthSet(&cv_skin2, DEFAULTSKIN); - cv_skin2.value = 0; - } - - // Finally write out the complete packet and send it off. - WRITESTRINGN(p, cv_playername2.zstring, MAXPLAYERNAME); - WRITEUINT8(p, (UINT8)cv_playercolor2.value); - WRITEUINT8(p, (UINT8)cv_skin2.value); - SendNetXCmd2(XD_NAMEANDCOLOR, buf, p - buf); -} - -static void SendNameAndColor3(void) -{ - INT32 thirdplaya = -1; - XBOXSTATIC char buf[MAXPLAYERNAME+2]; - char *p; - - if (splitscreen < 2) - return; // can happen if skin3/color3/name3 changed - - if (g_localplayers[2] != consoleplayer) - thirdplaya = g_localplayers[2]; - else if (!netgame) // HACK - thirdplaya = 2; - - if (thirdplaya == -1) - return; - - p = buf; - - // normal player colors - if (G_GametypeHasTeams()) - { - if (players[thirdplaya].ctfteam == 1 && cv_playercolor3.value != skincolor_redteam) - CV_StealthSetValue(&cv_playercolor3, skincolor_redteam); - else if (players[thirdplaya].ctfteam == 2 && cv_playercolor3.value != skincolor_blueteam) - CV_StealthSetValue(&cv_playercolor3, skincolor_blueteam); - } - - // never allow the color "none" - if (!cv_playercolor3.value) - { - if (players[thirdplaya].skincolor) - CV_StealthSetValue(&cv_playercolor3, players[thirdplaya].skincolor); - else if (skins[players[thirdplaya].skin].prefcolor) - CV_StealthSetValue(&cv_playercolor3, skins[players[thirdplaya].skin].prefcolor); - else - CV_StealthSet(&cv_playercolor3, cv_playercolor3.defaultvalue); - } - - // We'll handle it later if we're not playing. - if (!Playing()) - return; - - // If you're not in a netgame, merely update the skin, color, and name. - if (!netgame) - { - INT32 foundskin; - - CleanupPlayerName(thirdplaya, cv_playername3.zstring); - strcpy(player_names[thirdplaya], cv_playername3.zstring); - - // don't use displayplayers[2]: the third player must be 2 - players[thirdplaya].skincolor = cv_playercolor3.value; - if (players[thirdplaya].mo) - players[thirdplaya].mo->color = players[thirdplaya].skincolor; - - if ((foundskin = R_SkinAvailable(cv_skin3.string)) != -1) - { - //boolean notsame; - - cv_skin3.value = foundskin; - - //notsame = (cv_skin3.value != players[thirdplaya].skin); - - SetPlayerSkin(thirdplaya, cv_skin3.string); - - // SRB2Kart - /*if (notsame) - { - CV_StealthSetValue(&cv_playercolor3, skins[players[thirdplaya].skin].prefcolor); - - players[thirdplaya].skincolor = (cv_playercolor3.value&0x3F) % MAXSKINCOLORS; - - if (players[thirdplaya].mo) - players[thirdplaya].mo->color = players[thirdplaya].skincolor; - }*/ - } - else - { - cv_skin3.value = players[thirdplaya].skin; - CV_StealthSet(&cv_skin3, skins[players[thirdplaya].skin].name); - // will always be same as current - SetPlayerSkin(thirdplaya, cv_skin3.string); - } - return; - } - - snac3pending++; - - // Don't change name if muted - if (cv_mute.value && !(server || IsPlayerAdmin(g_localplayers[2]))) - CV_StealthSet(&cv_playername3, player_names[g_localplayers[2]]); - else // Cleanup name if changing it - CleanupPlayerName(g_localplayers[2], cv_playername3.zstring); - - // Don't change skin if the server doesn't want you to. - if (!CanChangeSkin(g_localplayers[2])) - CV_StealthSet(&cv_skin3, skins[players[g_localplayers[2]].skin].name); - - // check if player has the skin loaded (cv_skin3 may have - // the name of a skin that was available in the previous game) - cv_skin3.value = R_SkinAvailable(cv_skin3.string); - if (cv_skin3.value < 0) - { - CV_StealthSet(&cv_skin3, DEFAULTSKIN); - cv_skin3.value = 0; - } - - // Finally write out the complete packet and send it off. - WRITESTRINGN(p, cv_playername3.zstring, MAXPLAYERNAME); - WRITEUINT8(p, (UINT8)cv_playercolor3.value); - WRITEUINT8(p, (UINT8)cv_skin3.value); - SendNetXCmd3(XD_NAMEANDCOLOR, buf, p - buf); -} - -static void SendNameAndColor4(void) -{ - INT32 fourthplaya = -1; - XBOXSTATIC char buf[MAXPLAYERNAME+2]; - char *p; - - if (splitscreen < 3) - return; // can happen if skin4/color4/name4 changed - - if (g_localplayers[3] != consoleplayer) - fourthplaya = g_localplayers[3]; - else if (!netgame) // HACK - fourthplaya = 3; - - if (fourthplaya == -1) - return; - - p = buf; - - // normal player colors - if (G_GametypeHasTeams()) - { - if (players[fourthplaya].ctfteam == 1 && cv_playercolor4.value != skincolor_redteam) - CV_StealthSetValue(&cv_playercolor4, skincolor_redteam); - else if (players[fourthplaya].ctfteam == 2 && cv_playercolor4.value != skincolor_blueteam) - CV_StealthSetValue(&cv_playercolor4, skincolor_blueteam); - } - - // never allow the color "none" - if (!cv_playercolor4.value) - { - if (players[fourthplaya].skincolor) - CV_StealthSetValue(&cv_playercolor4, players[fourthplaya].skincolor); - else if (skins[players[fourthplaya].skin].prefcolor) - CV_StealthSetValue(&cv_playercolor4, skins[players[fourthplaya].skin].prefcolor); - else - CV_StealthSet(&cv_playercolor4, cv_playercolor4.defaultvalue); - } - - // We'll handle it later if we're not playing. - if (!Playing()) - return; - - // If you're not in a netgame, merely update the skin, color, and name. - if (!netgame) - { - INT32 foundskin; - - CleanupPlayerName(fourthplaya, cv_playername4.zstring); - strcpy(player_names[fourthplaya], cv_playername4.zstring); - - // don't use displayplayers[3]: the second player must be 4 - players[fourthplaya].skincolor = cv_playercolor4.value; - if (players[fourthplaya].mo) - players[fourthplaya].mo->color = players[fourthplaya].skincolor; - - if ((foundskin = R_SkinAvailable(cv_skin4.string)) != -1) - { - //boolean notsame; - - cv_skin4.value = foundskin; - - //notsame = (cv_skin4.value != players[fourthplaya].skin); - - SetPlayerSkin(fourthplaya, cv_skin4.string); - - // SRB2Kart - /*if (notsame) - { - CV_StealthSetValue(&cv_playercolor4, skins[players[fourthplaya].skin].prefcolor); - - players[fourthplaya].skincolor = (cv_playercolor4.value&0x3F) % MAXSKINCOLORS; - - if (players[fourthplaya].mo) - players[fourthplaya].mo->color = players[fourthplaya].skincolor; - }*/ - } - else - { - cv_skin4.value = players[fourthplaya].skin; - CV_StealthSet(&cv_skin4, skins[players[fourthplaya].skin].name); - // will always be same as current - SetPlayerSkin(fourthplaya, cv_skin4.string); - } - return; - } - - snac4pending++; - - // Don't change name if muted - if (cv_mute.value && !(server || IsPlayerAdmin(g_localplayers[3]))) - CV_StealthSet(&cv_playername4, player_names[g_localplayers[3]]); - else // Cleanup name if changing it - CleanupPlayerName(g_localplayers[3], cv_playername4.zstring); - - // Don't change skin if the server doesn't want you to. - if (!CanChangeSkin(g_localplayers[3])) - CV_StealthSet(&cv_skin4, skins[players[g_localplayers[3]].skin].name); - - // check if player has the skin loaded (cv_skin4 may have - // the name of a skin that was available in the previous game) - cv_skin4.value = R_SkinAvailable(cv_skin4.string); - if (cv_skin4.value < 0) - { - CV_StealthSet(&cv_skin4, DEFAULTSKIN); - cv_skin4.value = 0; - } - - // Finally write out the complete packet and send it off. - WRITESTRINGN(p, cv_playername4.zstring, MAXPLAYERNAME); - WRITEUINT8(p, (UINT8)cv_playercolor4.value); - WRITEUINT8(p, (UINT8)cv_skin4.value); - SendNetXCmd4(XD_NAMEANDCOLOR, buf, p - buf); + WRITESTRINGN(p, cv_playername[n].zstring, MAXPLAYERNAME); + WRITEUINT32(p, (UINT32)player->availabilities); + WRITEUINT16(p, (UINT16)cv_playercolor[n].value); + WRITEUINT8(p, (UINT8)cv_skin[n].value); + SendNetXCmdForPlayer(n, XD_NAMEANDCOLOR, buf, p - buf); } static void Got_NameAndColor(UINT8 **cp, INT32 playernum) @@ -1925,26 +1581,29 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum) char name[MAXPLAYERNAME+1]; UINT16 color; UINT8 skin; + UINT8 i; #ifdef PARANOIA if (playernum < 0 || playernum > MAXPLAYERS) I_Error("There is no player %d!", playernum); #endif - if (playernum == consoleplayer) - snacpending--; // TODO: make snacpending an array instead of 4 separate vars? - else if (playernum == g_localplayers[1]) - snac2pending--; - else if (playernum == g_localplayers[2]) - snac3pending--; - else if (playernum == g_localplayers[3]) - snac4pending--; + for (i = 0; i <= splitscreen; i++) + { + if (playernum == g_localplayers[i]) + { + snacpending[i]--; #ifdef PARANOIA - if (snacpending < 0 || snac2pending < 0 || snac3pending < 0 || snac4pending < 0) - I_Error("snacpending negative!"); + if (snacpending[i] < 0) + I_Error("snacpending[%d] negative!", i); #endif + // i is now player screen id + break; + } + } + READSTRINGN(*cp, name, MAXPLAYERNAME); p->availabilities = READUINT32(*cp); color = READUINT16(*cp); @@ -1961,8 +1620,7 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum) demo_extradata[playernum] |= DXD_COLOR; // normal player colors - if (server && (p != &players[consoleplayer] && p != &players[g_localplayers[1]] - && p != &players[g_localplayers[2]] && p != &players[g_localplayers[3]])) + if (server && !P_IsLocalPlayer(p)) { boolean kick = false; INT32 s; @@ -2004,66 +1662,30 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum) const INT32 forcedskin = cv_forceskin.value; SetPlayerSkinByNum(playernum, forcedskin); - if (playernum == consoleplayer) - CV_StealthSet(&cv_skin, skins[forcedskin].name); - else if (playernum == g_localplayers[1]) - CV_StealthSet(&cv_skin2, skins[forcedskin].name); - else if (playernum == g_localplayers[2]) - CV_StealthSet(&cv_skin3, skins[forcedskin].name); - else if (playernum == g_localplayers[3]) - CV_StealthSet(&cv_skin4, skins[forcedskin].name); + if (playernum == g_localplayers[i]) + CV_StealthSet(&cv_skin[i], skins[forcedskin].name); } else SetPlayerSkinByNum(playernum, skin); } -void SendWeaponPref(void) +void SendWeaponPref(UINT8 n) { UINT8 buf[1]; buf[0] = 0; - if (cv_flipcam.value) - buf[0] |= 1; - SendNetXCmd(XD_WEAPONPREF, buf, 1); -} + // Player option cvars that need to be synched go HERE -void SendWeaponPref2(void) -{ - UINT8 buf[1]; - - buf[0] = 0; - if (cv_flipcam2.value) - buf[0] |= 1; - SendNetXCmd2(XD_WEAPONPREF, buf, 1); -} - -void SendWeaponPref3(void) -{ - XBOXSTATIC UINT8 buf[1]; - - buf[0] = 0; - if (cv_flipcam3.value) - buf[0] |= 1; - SendNetXCmd3(XD_WEAPONPREF, buf, 1); -} - -void SendWeaponPref4(void) -{ - XBOXSTATIC UINT8 buf[1]; - - buf[0] = 0; - if (cv_flipcam4.value) - buf[0] |= 1; - SendNetXCmd4(XD_WEAPONPREF, buf, 1); + SendNetXCmdForPlayer(n, XD_WEAPONPREF, buf, 1); + SendNetXCmd(); } static void Got_WeaponPref(UINT8 **cp,INT32 playernum) { UINT8 prefs = READUINT8(*cp); - players[playernum].pflags &= ~(PF_FLIPCAM); - if (prefs & 1) - players[playernum].pflags |= PF_FLIPCAM; + //players[playernum].pflags &= ~(PF_FLIPCAM); + // Player option cvars that need to be synched go HERE } static void Got_PowerLevel(UINT8 **cp,INT32 playernum) @@ -2266,44 +1888,30 @@ static void Got_LeaveParty(UINT8 **cp,INT32 playernum) void D_SendPlayerConfig(void) { - SendNameAndColor(); - if (splitscreen) - SendNameAndColor2(); - if (splitscreen > 1) - SendNameAndColor3(); - if (splitscreen > 2) - SendNameAndColor4(); - SendWeaponPref(); - if (splitscreen) - SendWeaponPref2(); - if (splitscreen > 1) - SendWeaponPref3(); - if (splitscreen > 2) - SendWeaponPref4(); + UINT8 i; + for (i = 0; i <= splitscreen; i++) { UINT8 buf[4]; UINT8 *buf_p = buf; - WRITEUINT16(buf_p, vspowerlevel[PWRLV_RACE]); - WRITEUINT16(buf_p, vspowerlevel[PWRLV_BATTLE]); + SendNameAndColor(i); + SendWeaponPref(i); - SendNetXCmd(XD_POWERLEVEL, buf, 4); - } + if (i > 0) + { + // Splitscreen players have invalid powerlevel + WRITEUINT16(buf_p, 0); + WRITEUINT16(buf_p, 0); + } + else + { + // Send it over + WRITEUINT16(buf_p, vspowerlevel[PWRLV_RACE]); + WRITEUINT16(buf_p, vspowerlevel[PWRLV_BATTLE]); + } - if (splitscreen) - { - UINT8 buf[4]; - UINT8 *buf_p = buf; - - WRITEUINT16(buf_p, 0); - WRITEUINT16(buf_p, 0); - - SendNetXCmd2(XD_POWERLEVEL, buf, 4); - if (splitscreen > 1) - SendNetXCmd3(XD_POWERLEVEL, buf, 4); - if (splitscreen > 2) - SendNetXCmd4(XD_POWERLEVEL, buf, 4); + SendNetXCmdForPlayer(i, XD_POWERLEVEL, buf, 4); } } @@ -3475,22 +3083,33 @@ static void Got_Clearscores(UINT8 **cp, INT32 playernum) } // Team changing functions -static void Command_Teamchange_f(void) +static void HandleTeamChangeCommand(UINT8 localplayer) { + const char *commandname = NULL; changeteam_union NetPacket; boolean error = false; UINT16 usvalue; NetPacket.value.l = NetPacket.value.b = 0; + switch (localplayer) + { + case 0: + commandname = "changeteam"; + break; + default: + commandname = va("changeteam%d", localplayer+1); + break; + } + // 0 1 // changeteam if (COM_Argc() <= 1) { if (G_GametypeHasTeams()) - CONS_Printf(M_GetText("changeteam : switch to a new team (%s)\n"), "red, blue or spectator"); + CONS_Printf(M_GetText("%s : switch to a new team (%s)\n"), commandname, "red, blue or spectator"); else if (G_GametypeHasSpectators()) - CONS_Printf(M_GetText("changeteam : switch to a new team (%s)\n"), "spectator or playing"); + CONS_Printf(M_GetText("%s : switch to a new team (%s)\n"), commandname, "spectator or playing"); else CONS_Alert(CONS_NOTICE, M_GetText("This command cannot be used in this gametype.\n")); return; @@ -3525,17 +3144,17 @@ static void Command_Teamchange_f(void) if (error) { if (G_GametypeHasTeams()) - CONS_Printf(M_GetText("changeteam : switch to a new team (%s)\n"), "red, blue or spectator"); + CONS_Printf(M_GetText("%s : switch to a new team (%s)\n"), commandname, "red, blue or spectator"); else if (G_GametypeHasSpectators()) - CONS_Printf(M_GetText("changeteam : switch to a new team (%s)\n"), "spectator or playing"); + CONS_Printf(M_GetText("%s : switch to a new team (%s)\n"), commandname, "spectator or playing"); return; } - if (players[consoleplayer].spectator) - error = !(NetPacket.packet.newteam || (players[consoleplayer].pflags & PF_WANTSTOJOIN)); // :lancer: + if (players[g_localplayers[localplayer]].spectator) + error = !(NetPacket.packet.newteam || (players[g_localplayers[localplayer]].pflags & PF_WANTSTOJOIN)); // :lancer: else if (G_GametypeHasTeams()) - error = (NetPacket.packet.newteam == (unsigned)players[consoleplayer].ctfteam); - else if (G_GametypeHasSpectators() && !players[consoleplayer].spectator) + error = (NetPacket.packet.newteam == (unsigned)players[g_localplayers[localplayer]].ctfteam); + else if (G_GametypeHasSpectators() && !players[g_localplayers[localplayer]].spectator) error = (NetPacket.packet.newteam == 3); #ifdef PARANOIA else @@ -3562,280 +3181,27 @@ static void Command_Teamchange_f(void) } usvalue = SHORT(NetPacket.value.l|NetPacket.value.b); - SendNetXCmd(XD_TEAMCHANGE, &usvalue, sizeof(usvalue)); + SendNetXCmdForPlayer(localplayer, XD_TEAMCHANGE, &usvalue, sizeof(usvalue)); +} + +static void Command_Teamchange_f(void) +{ + HandleTeamChangeCommand(0); } static void Command_Teamchange2_f(void) { - changeteam_union NetPacket; - boolean error = false; - UINT16 usvalue; - NetPacket.value.l = NetPacket.value.b = 0; - - // 0 1 - // changeteam2 - - if (COM_Argc() <= 1) - { - if (G_GametypeHasTeams()) - CONS_Printf(M_GetText("changeteam2 : switch to a new team (%s)\n"), "red, blue or spectator"); - else if (G_GametypeHasSpectators()) - CONS_Printf(M_GetText("changeteam2 : switch to a new team (%s)\n"), "spectator or playing"); - else - CONS_Alert(CONS_NOTICE, M_GetText("This command cannot be used in this gametype.\n")); - return; - } - - if (G_GametypeHasTeams()) - { - if (!strcasecmp(COM_Argv(1), "red") || !strcasecmp(COM_Argv(1), "1")) - NetPacket.packet.newteam = 1; - else if (!strcasecmp(COM_Argv(1), "blue") || !strcasecmp(COM_Argv(1), "2")) - NetPacket.packet.newteam = 2; - else if (!strcasecmp(COM_Argv(1), "spectator") || !strcasecmp(COM_Argv(1), "0")) - NetPacket.packet.newteam = 0; - else - error = true; - } - else if (G_GametypeHasSpectators()) - { - if (!strcasecmp(COM_Argv(1), "spectator") || !strcasecmp(COM_Argv(1), "0")) - NetPacket.packet.newteam = 0; - else if (!strcasecmp(COM_Argv(1), "playing") || !strcasecmp(COM_Argv(1), "1")) - NetPacket.packet.newteam = 3; - else - error = true; - } - - else - { - CONS_Alert(CONS_NOTICE, M_GetText("This command cannot be used in this gametype.\n")); - return; - } - - if (error) - { - if (G_GametypeHasTeams()) - CONS_Printf(M_GetText("changeteam2 : switch to a new team (%s)\n"), "red, blue or spectator"); - else if (G_GametypeHasSpectators()) - CONS_Printf(M_GetText("changeteam2 : switch to a new team (%s)\n"), "spectator or playing"); - return; - } - - if (players[g_localplayers[1]].spectator) - error = !(NetPacket.packet.newteam || (players[g_localplayers[1]].pflags & PF_WANTSTOJOIN)); - else if (G_GametypeHasTeams()) - error = (NetPacket.packet.newteam == (unsigned)players[g_localplayers[1]].ctfteam); - else if (G_GametypeHasSpectators() && !players[g_localplayers[1]].spectator) - error = (NetPacket.packet.newteam == 3); -#ifdef PARANOIA - else - I_Error("Invalid gametype after initial checks!"); -#endif - - if (error) - { - CONS_Alert(CONS_NOTICE, M_GetText("You're already on that team!\n")); - return; - } - - if (!cv_allowteamchange.value && NetPacket.packet.newteam) // allow swapping to spectator even in locked teams. - { - CONS_Alert(CONS_NOTICE, M_GetText("The server is not allowing team changes at the moment.\n")); - return; - } - - //additional check for hide and seek. Don't allow change of status after hidetime ends. - if ((gametyperules & GTR_HIDEFROZEN) && leveltime >= (hidetime * TICRATE)) - { - CONS_Alert(CONS_NOTICE, M_GetText("Hiding time expired; no Hide and Seek status changes allowed!\n")); - return; - } - - usvalue = SHORT(NetPacket.value.l|NetPacket.value.b); - SendNetXCmd2(XD_TEAMCHANGE, &usvalue, sizeof(usvalue)); + HandleTeamChangeCommand(1); } static void Command_Teamchange3_f(void) { - changeteam_union NetPacket; - boolean error = false; - UINT16 usvalue; - NetPacket.value.l = NetPacket.value.b = 0; - - // 0 1 - // changeteam3 - - if (COM_Argc() <= 1) - { - if (G_GametypeHasTeams()) - CONS_Printf(M_GetText("changeteam3 : switch to a new team (%s)\n"), "red, blue or spectator"); - else if (G_GametypeHasSpectators()) - CONS_Printf(M_GetText("changeteam3 : switch to a new team (%s)\n"), "spectator or playing"); - else - CONS_Alert(CONS_NOTICE, M_GetText("This command cannot be used in this gametype.\n")); - return; - } - - if (G_GametypeHasTeams()) - { - if (!strcasecmp(COM_Argv(1), "red") || !strcasecmp(COM_Argv(1), "1")) - NetPacket.packet.newteam = 1; - else if (!strcasecmp(COM_Argv(1), "blue") || !strcasecmp(COM_Argv(1), "2")) - NetPacket.packet.newteam = 2; - else if (!strcasecmp(COM_Argv(1), "spectator") || !strcasecmp(COM_Argv(1), "0")) - NetPacket.packet.newteam = 0; - else - error = true; - } - else if (G_GametypeHasSpectators()) - { - if (!strcasecmp(COM_Argv(1), "spectator") || !strcasecmp(COM_Argv(1), "0")) - NetPacket.packet.newteam = 0; - else if (!strcasecmp(COM_Argv(1), "playing") || !strcasecmp(COM_Argv(1), "1")) - NetPacket.packet.newteam = 3; - else - error = true; - } - - else - { - CONS_Alert(CONS_NOTICE, M_GetText("This command cannot be used in this gametype.\n")); - return; - } - - if (error) - { - if (G_GametypeHasTeams()) - CONS_Printf(M_GetText("changeteam3 : switch to a new team (%s)\n"), "red, blue or spectator"); - else if (G_GametypeHasSpectators()) - CONS_Printf(M_GetText("changeteam3 : switch to a new team (%s)\n"), "spectator or playing"); - return; - } - - if (players[g_localplayers[2]].spectator) - error = !(NetPacket.packet.newteam || (players[g_localplayers[2]].pflags & PF_WANTSTOJOIN)); - else if (G_GametypeHasTeams()) - error = (NetPacket.packet.newteam == (unsigned)players[g_localplayers[2]].ctfteam); - else if (G_GametypeHasSpectators() && !players[g_localplayers[2]].spectator) - error = (NetPacket.packet.newteam == 3); -#ifdef PARANOIA - else - I_Error("Invalid gametype after initial checks!"); -#endif - - if (error) - { - CONS_Alert(CONS_NOTICE, M_GetText("You're already on that team!\n")); - return; - } - - if (!cv_allowteamchange.value && NetPacket.packet.newteam) // allow swapping to spectator even in locked teams. - { - CONS_Alert(CONS_NOTICE, M_GetText("The server is not allowing team changes at the moment.\n")); - return; - } - - //additional check for hide and seek. Don't allow change of status after hidetime ends. - if (gametype == GT_HIDEANDSEEK && leveltime >= (hidetime * TICRATE)) - { - CONS_Alert(CONS_NOTICE, M_GetText("Hiding time expired; no Hide and Seek status changes allowed!\n")); - return; - } - - usvalue = SHORT(NetPacket.value.l|NetPacket.value.b); - SendNetXCmd3(XD_TEAMCHANGE, &usvalue, sizeof(usvalue)); + HandleTeamChangeCommand(2); } static void Command_Teamchange4_f(void) { - changeteam_union NetPacket; - boolean error = false; - UINT16 usvalue; - NetPacket.value.l = NetPacket.value.b = 0; - - // 0 1 - // changeteam4 - - if (COM_Argc() <= 1) - { - if (G_GametypeHasTeams()) - CONS_Printf(M_GetText("changeteam4 : switch to a new team (%s)\n"), "red, blue or spectator"); - else if (G_GametypeHasSpectators()) - CONS_Printf(M_GetText("changeteam4 : switch to a new team (%s)\n"), "spectator or playing"); - else - CONS_Alert(CONS_NOTICE, M_GetText("This command cannot be used in this gametype.\n")); - return; - } - - if (G_GametypeHasTeams()) - { - if (!strcasecmp(COM_Argv(1), "red") || !strcasecmp(COM_Argv(1), "1")) - NetPacket.packet.newteam = 1; - else if (!strcasecmp(COM_Argv(1), "blue") || !strcasecmp(COM_Argv(1), "2")) - NetPacket.packet.newteam = 2; - else if (!strcasecmp(COM_Argv(1), "spectator") || !strcasecmp(COM_Argv(1), "0")) - NetPacket.packet.newteam = 0; - else - error = true; - } - else if (G_GametypeHasSpectators()) - { - if (!strcasecmp(COM_Argv(1), "spectator") || !strcasecmp(COM_Argv(1), "0")) - NetPacket.packet.newteam = 0; - else if (!strcasecmp(COM_Argv(1), "playing") || !strcasecmp(COM_Argv(1), "1")) - NetPacket.packet.newteam = 3; - else - error = true; - } - - else - { - CONS_Alert(CONS_NOTICE, M_GetText("This command cannot be used in this gametype.\n")); - return; - } - - if (error) - { - if (G_GametypeHasTeams()) - CONS_Printf(M_GetText("changeteam4 : switch to a new team (%s)\n"), "red, blue or spectator"); - else if (G_GametypeHasSpectators()) - CONS_Printf(M_GetText("changeteam4 : switch to a new team (%s)\n"), "spectator or playing"); - return; - } - - if (players[g_localplayers[3]].spectator) - error = !(NetPacket.packet.newteam || (players[g_localplayers[3]].pflags & PF_WANTSTOJOIN)); - else if (G_GametypeHasTeams()) - error = (NetPacket.packet.newteam == (unsigned)players[g_localplayers[3]].ctfteam); - else if (G_GametypeHasSpectators() && !players[g_localplayers[3]].spectator) - error = (NetPacket.packet.newteam == 3); -#ifdef PARANOIA - else - I_Error("Invalid gametype after initial checks!"); -#endif - - if (error) - { - CONS_Alert(CONS_NOTICE, M_GetText("You're already on that team!\n")); - return; - } - - if (!cv_allowteamchange.value && NetPacket.packet.newteam) // allow swapping to spectator even in locked teams. - { - CONS_Alert(CONS_NOTICE, M_GetText("The server is not allowing team changes at the moment.\n")); - return; - } - - //additional check for hide and seek. Don't allow change of status after hidetime ends. - if ((gametyperules & GTR_HIDEFROZEN) && leveltime >= (hidetime * TICRATE)) - { - CONS_Alert(CONS_NOTICE, M_GetText("Hiding time expired; no Hide and Seek status changes allowed!\n")); - return; - } - - usvalue = SHORT(NetPacket.value.l|NetPacket.value.b); - SendNetXCmd4(XD_TEAMCHANGE, &usvalue, sizeof(usvalue)); + HandleTeamChangeCommand(3); } static void Command_ServerTeamChange_f(void) @@ -5215,12 +4581,7 @@ void D_GameTypeChanged(INT32 lastgametype) switch (gametype) { - case GT_COOP: - if (!cv_itemrespawntime.changed) - CV_Set(&cv_itemrespawntime, cv_itemrespawntime.defaultvalue); // respawn normally - break; - case GT_MATCH: - case GT_TEAMMATCH: + case GT_BATTLE: if (!cv_timelimit.changed && !cv_pointlimit.changed) // user hasn't changed limits { // default settings for match: 2 mins, no pointlimit @@ -5230,28 +4591,7 @@ void D_GameTypeChanged(INT32 lastgametype) if (!cv_itemrespawntime.changed) CV_Set(&cv_itemrespawntime, cv_itemrespawntime.defaultvalue); // respawn normally break; - case GT_TAG: - case GT_HIDEANDSEEK: - if (!cv_timelimit.changed && !cv_pointlimit.changed) // user hasn't changed limits - { - // default settings for tag: 5 mins, no pointlimit - // Note that tag mode also uses an alternate timing mechanism in tandem with timelimit. - CV_SetValue(&cv_timelimit, 5); - CV_SetValue(&cv_pointlimit, 0); - } - if (!cv_itemrespawntime.changed) - CV_Set(&cv_itemrespawntime, cv_itemrespawntime.defaultvalue); // respawn normally - break; - case GT_CTF: - if (!cv_timelimit.changed && !cv_pointlimit.changed) // user hasn't changed limits - { - // default settings for CTF: no timelimit, pointlimit 5 - CV_SetValue(&cv_timelimit, 0); - CV_SetValue(&cv_pointlimit, 5); - } - if (!cv_itemrespawntime.changed) - CV_Set(&cv_itemrespawntime, cv_itemrespawntime.defaultvalue); // respawn normally - break; + default: if (!cv_timelimit.changed && !cv_pointlimit.changed) // user hasn't changed limits { @@ -5986,10 +5326,10 @@ static void Name_OnChange(void) if (cv_mute.value && !(server || IsPlayerAdmin(consoleplayer))) { CONS_Alert(CONS_NOTICE, M_GetText("You may not change your name when chat is muted.\n")); - CV_StealthSet(&cv_playername, player_names[consoleplayer]); + CV_StealthSet(&cv_playername[0], player_names[consoleplayer]); } else - SendNameAndColor(); + SendNameAndColor(0); } @@ -5998,10 +5338,10 @@ static void Name2_OnChange(void) if (cv_mute.value) //Secondary player can't be admin. { CONS_Alert(CONS_NOTICE, M_GetText("You may not change your name when chat is muted.\n")); - CV_StealthSet(&cv_playername2, player_names[g_localplayers[1]]); + CV_StealthSet(&cv_playername[1], player_names[g_localplayers[1]]); } else - SendNameAndColor2(); + SendNameAndColor(1); } static void Name3_OnChange(void) @@ -6009,10 +5349,10 @@ static void Name3_OnChange(void) if (cv_mute.value) //Third player can't be admin. { CONS_Alert(CONS_NOTICE, M_GetText("You may not change your name when chat is muted.\n")); - CV_StealthSet(&cv_playername3, player_names[g_localplayers[2]]); + CV_StealthSet(&cv_playername[2], player_names[g_localplayers[2]]); } else - SendNameAndColor3(); + SendNameAndColor(2); } static void Name4_OnChange(void) @@ -6020,10 +5360,10 @@ static void Name4_OnChange(void) if (cv_mute.value) //Secondary player can't be admin. { CONS_Alert(CONS_NOTICE, M_GetText("You may not change your name when chat is muted.\n")); - CV_StealthSet(&cv_playername4, player_names[g_localplayers[3]]); + CV_StealthSet(&cv_playername[3], player_names[g_localplayers[3]]); } else - SendNameAndColor4(); + SendNameAndColor(3); } /** Sends a skin change for the console player, unless that player is moving. @@ -6038,16 +5378,16 @@ static void Skin_OnChange(void) if (!(cv_debug || devparm) && !(multiplayer || netgame) // In single player. && (gamestate != GS_WAITINGPLAYERS)) // allows command line -warp x +skin y { - CV_StealthSet(&cv_skin, skins[players[consoleplayer].skin].name); + CV_StealthSet(&cv_skin[0], skins[players[consoleplayer].skin].name); return; } if (CanChangeSkin(consoleplayer) && !P_PlayerMoving(consoleplayer)) - SendNameAndColor(); + SendNameAndColor(0); else { CONS_Alert(CONS_NOTICE, M_GetText("You can't change your skin at the moment.\n")); - CV_StealthSet(&cv_skin, skins[players[consoleplayer].skin].name); + CV_StealthSet(&cv_skin[0], skins[players[consoleplayer].skin].name); } } @@ -6062,11 +5402,11 @@ static void Skin2_OnChange(void) return; // do whatever you want if (CanChangeSkin(g_localplayers[1]) && !P_PlayerMoving(g_localplayers[1])) - SendNameAndColor2(); + SendNameAndColor(1); else { CONS_Alert(CONS_NOTICE, M_GetText("You can't change your skin at the moment.\n")); - CV_StealthSet(&cv_skin2, skins[players[g_localplayers[1]].skin].name); + CV_StealthSet(&cv_skin[1], skins[players[g_localplayers[1]].skin].name); } } @@ -6076,11 +5416,11 @@ static void Skin3_OnChange(void) return; // do whatever you want if (CanChangeSkin(g_localplayers[2]) && !P_PlayerMoving(g_localplayers[2])) - SendNameAndColor3(); + SendNameAndColor(2); else { CONS_Alert(CONS_NOTICE, M_GetText("You can't change your skin at the moment.\n")); - CV_StealthSet(&cv_skin3, skins[players[g_localplayers[2]].skin].name); + CV_StealthSet(&cv_skin[2], skins[players[g_localplayers[2]].skin].name); } } @@ -6090,11 +5430,11 @@ static void Skin4_OnChange(void) return; // do whatever you want if (CanChangeSkin(g_localplayers[3]) && !P_PlayerMoving(g_localplayers[3])) - SendNameAndColor4(); + SendNameAndColor(3); else { CONS_Alert(CONS_NOTICE, M_GetText("You can't change your skin at the moment.\n")); - CV_StealthSet(&cv_skin4, skins[players[g_localplayers[3]].skin].name); + CV_StealthSet(&cv_skin[3], skins[players[g_localplayers[3]].skin].name); } } @@ -6105,39 +5445,30 @@ static void Skin4_OnChange(void) static void Color_OnChange(void) { if (!Playing()) - return; // do whatever you want - - if (!(cv_debug || devparm) && !(multiplayer || netgame || modeattacking)) // In single player. { - CV_StealthSet(&cv_skin, skins[players[consoleplayer].skin].name); - return; - } - - if (!P_PlayerMoving(consoleplayer)) - { - // Color change menu scrolling fix is no longer necessary - SendNameAndColor(); + if (!cv_playercolor[0].value || !skincolors[cv_playercolor[0].value].accessible) + CV_StealthSetValue(&cv_playercolor[0], lastgoodcolor[0]); } else { if (!(cv_debug || devparm) && !(multiplayer || netgame)) // In single player. { - CV_StealthSet(&cv_skin, skins[players[consoleplayer].skin].name); + CV_StealthSet(&cv_skin[0], skins[players[consoleplayer].skin].name); return; } if (!P_PlayerMoving(consoleplayer) && skincolors[players[consoleplayer].skincolor].accessible == true) { // Color change menu scrolling fix is no longer necessary - SendNameAndColor(); + SendNameAndColor(0); } else { - CV_StealthSetValue(&cv_playercolor, + CV_StealthSetValue(&cv_playercolor[0], players[consoleplayer].skincolor); } } - lastgoodcolor = cv_playercolor.value; + lastgoodcolor[0] = cv_playercolor[0].value; } /** Sends a color change for the secondary splitscreen player, unless that @@ -6147,66 +5478,71 @@ static void Color_OnChange(void) */ static void Color2_OnChange(void) { - if (!Playing() || !splitscreen) - return; // do whatever you want - - if (!P_PlayerMoving(g_localplayers[1])) + if (!Playing() || splitscreen < 1) { - if (!cv_playercolor2.value || !skincolors[cv_playercolor2.value].accessible) - CV_StealthSetValue(&cv_playercolor2, lastgoodcolor2); + if (!cv_playercolor[1].value || !skincolors[cv_playercolor[1].value].accessible) + CV_StealthSetValue(&cv_playercolor[1], lastgoodcolor[1]); } else { - CV_StealthSetValue(&cv_playercolor2, - players[g_localplayers[1]].skincolor); + if (!P_PlayerMoving(g_localplayers[1]) && skincolors[players[g_localplayers[1]].skincolor].accessible == true) + { + // Color change menu scrolling fix is no longer necessary + SendNameAndColor(1); + } + else + { + CV_StealthSetValue(&cv_playercolor[1], + players[g_localplayers[1]].skincolor); + } } + lastgoodcolor[1] = cv_playercolor[1].value; } static void Color3_OnChange(void) { if (!Playing() || splitscreen < 2) - return; // do whatever you want - - if (!P_PlayerMoving(g_localplayers[2])) { - // Color change menu scrolling fix is no longer necessary - SendNameAndColor3(); + if (!cv_playercolor[2].value || !skincolors[cv_playercolor[2].value].accessible) + CV_StealthSetValue(&cv_playercolor[2], lastgoodcolor[2]); } else { - CV_StealthSetValue(&cv_playercolor3, - players[g_localplayers[2]].skincolor); + if (!P_PlayerMoving(g_localplayers[2]) && skincolors[players[g_localplayers[2]].skincolor].accessible == true) + { + // Color change menu scrolling fix is no longer necessary + SendNameAndColor(2); + } + else + { + CV_StealthSetValue(&cv_playercolor[2], + players[g_localplayers[2]].skincolor); + } } + lastgoodcolor[2] = cv_playercolor[2].value; } static void Color4_OnChange(void) { if (!Playing() || splitscreen < 3) - return; // do whatever you want - - if (!P_PlayerMoving(g_localplayers[3])) { - // Color change menu scrolling fix is no longer necessary - SendNameAndColor4(); + if (!cv_playercolor[3].value || !skincolors[cv_playercolor[3].value].accessible) + CV_StealthSetValue(&cv_playercolor[3], lastgoodcolor[3]); } else { - CV_StealthSetValue(&cv_playercolor4, - players[g_localplayers[3]].skincolor); -======= - if (!P_PlayerMoving(secondarydisplayplayer) && skincolors[players[secondarydisplayplayer].skincolor].accessible == true) + if (!P_PlayerMoving(g_localplayers[3]) && skincolors[players[g_localplayers[3]].skincolor].accessible == true) { // Color change menu scrolling fix is no longer necessary - SendNameAndColor2(); + SendNameAndColor(3); } else { - CV_StealthSetValue(&cv_playercolor2, - players[secondarydisplayplayer].skincolor); + CV_StealthSetValue(&cv_playercolor[3], + players[g_localplayers[3]].skincolor); } ->>>>>>> srb2/next } - lastgoodcolor2 = cv_playercolor2.value; + lastgoodcolor[3] = cv_playercolor[3].value; } /** Displays the result of the chat being muted or unmuted. diff --git a/src/d_netcmd.h b/src/d_netcmd.h index 514867e21..6fa09ee24 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -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; diff --git a/src/dehacked.c b/src/dehacked.c index e2bb92e10..8752bdac7 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -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 diff --git a/src/g_demo.c b/src/g_demo.c index f0da4f9ec..8c3eef08b 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -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) { diff --git a/src/g_game.c b/src/g_game.c index 417cdab67..7f1f4eb69 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -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 diff --git a/src/lua_consolelib.c b/src/lua_consolelib.c index 86ffdc85a..7fa652689 100644 --- a/src/lua_consolelib.c +++ b/src/lua_consolelib.c @@ -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; } diff --git a/src/m_menu.c b/src/m_menu.c index 5ff538570..02dff5cf3 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -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 diff --git a/src/m_misc.c b/src/m_misc.c index 162688b15..97c2e2f6b 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -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; diff --git a/src/p_inter.c b/src/p_inter.c index deb8eadfd..f6e4eb5c5 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -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) diff --git a/src/p_local.h b/src/p_local.h index 0178bfa6d..0eaa047b7 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -61,6 +61,8 @@ #define mariomode (maptol & TOL_MARIO) +#define P_GetPlayerViewHeight(player) (41*player->mo->height/48) + typedef enum { THINK_POLYOBJ, diff --git a/src/p_mobj.c b/src/p_mobj.c index c1180abec..33f6afda0 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -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; diff --git a/src/p_saveg.c b/src/p_saveg.c index 0012f0e38..3eada7453 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -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 } } diff --git a/src/p_setup.c b/src/p_setup.c index 4be2b8e41..e171c4d94 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -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. diff --git a/src/p_user.c b/src/p_user.c index 926a64548..b0fc976ab 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -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; diff --git a/src/y_inter.c b/src/y_inter.c index 169a4521a..8140e69a5 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -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);