cleanup localcmd stuff
This commit is contained in:
1 parent
f1c3b49933
commit
b995a764c4
5 files changed
+75
-147
No files matched your search
+59
-127
@@ -141,10 +141,7 @@ static UINT8 gamestate_resend_counter[MAXNETNODES];
|
||||
boolean hu_stopped = 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
|
||||
@@ -161,10 +158,7 @@ boolean is_client_saturn[MAXNETNODES];
|
||||
#define ISSATURN 69
|
||||
#endif
|
||||
|
||||
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+1];
|
||||
@@ -278,77 +272,30 @@ 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));
|
||||
// for future reference: if (cht_debug) != debug disabled.
|
||||
CONS_Alert(CONS_ERROR, M_GetText("NetXCmd buffer full, cannot add netcmd %d! (size: %d, needed: %s)\n"), id, localtextcmd[playerid][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);
|
||||
M_Memcpy(&localtextcmd[playerid][localtextcmd[playerid][0] + 1], param, nparam);
|
||||
localtextcmd[playerid][0] = (UINT8)(localtextcmd[playerid][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);
|
||||
}
|
||||
}
|
||||
|
||||
UINT8 GetFreeXCmdSize(void)
|
||||
/*UINT8 GetFreeXCmdSize(UINT8 playerid)
|
||||
{
|
||||
// -1 for the size and another -1 for the ID.
|
||||
return (UINT8)(localtextcmd[0] - 2);
|
||||
}
|
||||
return (UINT8)(localtextcmd[playerid][0] - 2);
|
||||
}*/
|
||||
|
||||
// Frees all textcmd memory for the specified tic
|
||||
static void D_FreeTextcmd(tic_t tic)
|
||||
@@ -512,10 +459,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++)
|
||||
@@ -4540,10 +4485,8 @@ void SV_StopServer(void)
|
||||
Y_EndVote();
|
||||
gamestate = wipegamestate = GS_NULL;
|
||||
|
||||
localtextcmd[0] = 0;
|
||||
localtextcmd2[0] = 0;
|
||||
localtextcmd3[0] = 0;
|
||||
localtextcmd4[0] = 0;
|
||||
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
||||
localtextcmd[i][0] = 0;
|
||||
|
||||
for (i = firstticstosend; i < firstticstosend + TICQUEUE; i++)
|
||||
D_Clearticcmd(i);
|
||||
@@ -5962,26 +5905,26 @@ static void CL_SendClientCmd(void)
|
||||
else if (gamestate != GS_NULL)
|
||||
{
|
||||
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 || botingame) // 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5991,44 +5934,33 @@ static void CL_SendClientCmd(void)
|
||||
|
||||
if (cl_mode == CL_CONNECTED || dedicated)
|
||||
{
|
||||
UINT8 i;
|
||||
// Send extra data if needed
|
||||
if (localtextcmd[0])
|
||||
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
||||
{
|
||||
netbuffer->packettype = PT_TEXTCMD;
|
||||
M_Memcpy(netbuffer->u.textcmd,localtextcmd, localtextcmd[0]+1);
|
||||
// All extra data have been sent
|
||||
if (HSendPacket(servernode, true, 0, localtextcmd[0]+1)) // Send can fail...
|
||||
localtextcmd[0] = 0;
|
||||
}
|
||||
if (localtextcmd[i][0])
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 3:
|
||||
netbuffer->packettype = PT_TEXTCMD4;
|
||||
break;
|
||||
case 2:
|
||||
netbuffer->packettype = PT_TEXTCMD3;
|
||||
break;
|
||||
case 1:
|
||||
netbuffer->packettype = PT_TEXTCMD2;
|
||||
break;
|
||||
default:
|
||||
netbuffer->packettype = PT_TEXTCMD;
|
||||
break;
|
||||
}
|
||||
|
||||
// Send extra data if needed for player 2 (splitscreen == 1)
|
||||
if (localtextcmd2[0])
|
||||
{
|
||||
netbuffer->packettype = PT_TEXTCMD2;
|
||||
M_Memcpy(netbuffer->u.textcmd, localtextcmd2, localtextcmd2[0]+1);
|
||||
// All extra data have been sent
|
||||
if (HSendPacket(servernode, true, 0, localtextcmd2[0]+1)) // Send can fail...
|
||||
localtextcmd2[0] = 0;
|
||||
}
|
||||
|
||||
// Send extra data if needed for player 3 (splitscreen == 2)
|
||||
if (localtextcmd3[0])
|
||||
{
|
||||
netbuffer->packettype = PT_TEXTCMD3;
|
||||
M_Memcpy(netbuffer->u.textcmd, localtextcmd3, localtextcmd3[0]+1);
|
||||
// All extra data have been sent
|
||||
if (HSendPacket(servernode, true, 0, localtextcmd3[0]+1)) // Send can fail...
|
||||
localtextcmd3[0] = 0;
|
||||
}
|
||||
|
||||
// Send extra data if needed for player 4 (splitscreen == 3)
|
||||
if (localtextcmd4[0])
|
||||
{
|
||||
netbuffer->packettype = PT_TEXTCMD4;
|
||||
M_Memcpy(netbuffer->u.textcmd, localtextcmd4, localtextcmd4[0]+1);
|
||||
// All extra data have been sent
|
||||
if (HSendPacket(servernode, true, 0, localtextcmd4[0]+1)) // Send can fail...
|
||||
localtextcmd4[0] = 0;
|
||||
M_Memcpy(netbuffer->u.textcmd, localtextcmd[i], localtextcmd[i][0]+1);
|
||||
// All extra data have been sent
|
||||
if (HSendPacket(servernode, true, 0, localtextcmd[i][0]+1)) // Send can fail...
|
||||
localtextcmd[i][0] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6155,27 +6087,27 @@ static void SV_SendTics(void)
|
||||
//
|
||||
// TryRunTics
|
||||
//
|
||||
static inline void CreateNewLocalCMD(UINT8 p, INT32 realtics)
|
||||
{
|
||||
G_BuildTiccmd(&localcmds[p], realtics, p+1);
|
||||
localcmds[p].angleturn |= TICCMD_RECEIVED;
|
||||
}
|
||||
|
||||
static void Local_Maketic(INT32 realtics)
|
||||
{
|
||||
INT32 i;
|
||||
|
||||
I_OsPolling(); // I_Getevent
|
||||
D_ProcessEvents(); // menu responder, cons responder,
|
||||
// game responder calls HU_Responder, AM_Responder, F_Responder,
|
||||
// and G_MapEventsToControls
|
||||
if (!dedicated) rendergametic = gametic;
|
||||
// translate inputs (keyboard/mouse/joystick) into game controls
|
||||
G_BuildTiccmd(&localcmds, realtics, 1);
|
||||
if (splitscreen || botingame)
|
||||
{
|
||||
G_BuildTiccmd(&localcmds2, realtics, 2);
|
||||
if (splitscreen > 1)
|
||||
{
|
||||
G_BuildTiccmd(&localcmds3, realtics, 3);
|
||||
if (splitscreen > 2)
|
||||
G_BuildTiccmd(&localcmds4, realtics, 4);
|
||||
}
|
||||
}
|
||||
|
||||
localcmds.angleturn |= TICCMD_RECEIVED;
|
||||
for (i = 0; i <= splitscreen; i++)
|
||||
{
|
||||
CreateNewLocalCMD(i, realtics);
|
||||
}
|
||||
}
|
||||
|
||||
void SV_SpawnPlayer(INT32 playernum, INT32 x, INT32 y, angle_t angle)
|
||||
|
||||
+3
-5
@@ -592,10 +592,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
|
||||
|
||||
// Create any new ticcmds and broadcast to other players.
|
||||
void NetKeepAlive(void);
|
||||
@@ -642,7 +640,7 @@ INT32 D_NumPlayers(void);
|
||||
void D_ResetTiccmds(void);
|
||||
|
||||
tic_t GetLag(INT32 node);
|
||||
UINT8 GetFreeXCmdSize(void);
|
||||
//UINT8 GetFreeXCmdSize(UINT8 playerid);
|
||||
|
||||
extern UINT8 hu_resynching;
|
||||
#ifdef SATURNSYNCH
|
||||
|
||||
+12
-12
@@ -1660,7 +1660,7 @@ static void SendNameAndColor(void)
|
||||
WRITESTRINGN(p, cv_playername.zstring, MAXPLAYERNAME);
|
||||
WRITEUINT8(p, (UINT8)cv_playercolor.value);
|
||||
WRITEUINT8(p, (UINT8)cv_skin.value);
|
||||
SendNetXCmd(XD_NAMEANDCOLOR, buf, p - buf);
|
||||
SendNetXCmdForPlayer(0, XD_NAMEANDCOLOR, buf, p - buf);
|
||||
}
|
||||
|
||||
// splitscreen
|
||||
@@ -1765,7 +1765,7 @@ static void SendNameAndColor2(void)
|
||||
WRITESTRINGN(p, cv_playername2.zstring, MAXPLAYERNAME);
|
||||
WRITEUINT8(p, (UINT8)cv_playercolor2.value);
|
||||
WRITEUINT8(p, (UINT8)cv_skin2.value);
|
||||
SendNetXCmd2(XD_NAMEANDCOLOR, buf, p - buf);
|
||||
SendNetXCmdForPlayer(1, XD_NAMEANDCOLOR, buf, p - buf);
|
||||
}
|
||||
|
||||
static void SendNameAndColor3(void)
|
||||
@@ -1877,7 +1877,7 @@ static void SendNameAndColor3(void)
|
||||
WRITESTRINGN(p, cv_playername3.zstring, MAXPLAYERNAME);
|
||||
WRITEUINT8(p, (UINT8)cv_playercolor3.value);
|
||||
WRITEUINT8(p, (UINT8)cv_skin3.value);
|
||||
SendNetXCmd3(XD_NAMEANDCOLOR, buf, p - buf);
|
||||
SendNetXCmdForPlayer(2, XD_NAMEANDCOLOR, buf, p - buf);
|
||||
}
|
||||
|
||||
static void SendNameAndColor4(void)
|
||||
@@ -1981,7 +1981,7 @@ static void SendNameAndColor4(void)
|
||||
WRITESTRINGN(p, cv_playername4.zstring, MAXPLAYERNAME);
|
||||
WRITEUINT8(p, (UINT8)cv_playercolor4.value);
|
||||
WRITEUINT8(p, (UINT8)cv_skin4.value);
|
||||
SendNetXCmd4(XD_NAMEANDCOLOR, buf, p - buf);
|
||||
SendNetXCmdForPlayer(3, XD_NAMEANDCOLOR, buf, p - buf);
|
||||
}
|
||||
|
||||
static void Got_NameAndColor(UINT8 **cp, INT32 playernum)
|
||||
@@ -2079,7 +2079,7 @@ void SendWeaponPref(void)
|
||||
buf[0] = 0;
|
||||
if (cv_flipcam[0].value)
|
||||
buf[0] |= 1;
|
||||
SendNetXCmd(XD_WEAPONPREF, buf, 1);
|
||||
SendNetXCmdForPlayer(0, XD_WEAPONPREF, buf, 1);
|
||||
}
|
||||
|
||||
void SendWeaponPref2(void)
|
||||
@@ -2089,7 +2089,7 @@ void SendWeaponPref2(void)
|
||||
buf[0] = 0;
|
||||
if (cv_flipcam[1].value)
|
||||
buf[0] |= 1;
|
||||
SendNetXCmd2(XD_WEAPONPREF, buf, 1);
|
||||
SendNetXCmdForPlayer(1, XD_WEAPONPREF, buf, 1);
|
||||
}
|
||||
|
||||
void SendWeaponPref3(void)
|
||||
@@ -2099,7 +2099,7 @@ void SendWeaponPref3(void)
|
||||
buf[0] = 0;
|
||||
if (cv_flipcam[2].value)
|
||||
buf[0] |= 1;
|
||||
SendNetXCmd3(XD_WEAPONPREF, buf, 1);
|
||||
SendNetXCmdForPlayer(2, XD_WEAPONPREF, buf, 1);
|
||||
}
|
||||
|
||||
void SendWeaponPref4(void)
|
||||
@@ -2109,7 +2109,7 @@ void SendWeaponPref4(void)
|
||||
buf[0] = 0;
|
||||
if (cv_flipcam[3].value)
|
||||
buf[0] |= 1;
|
||||
SendNetXCmd4(XD_WEAPONPREF, buf, 1);
|
||||
SendNetXCmdForPlayer(3, XD_WEAPONPREF, buf, 1);
|
||||
}
|
||||
|
||||
static void Got_WeaponPref(UINT8 **cp,INT32 playernum)
|
||||
@@ -3297,7 +3297,7 @@ static void Command_Teamchange_f(void)
|
||||
}
|
||||
|
||||
usvalue = SHORT(NetPacket.value.l|NetPacket.value.b);
|
||||
SendNetXCmd(XD_TEAMCHANGE, &usvalue, sizeof(usvalue));
|
||||
SendNetXCmdForPlayer(0, XD_TEAMCHANGE, &usvalue, sizeof(usvalue));
|
||||
}
|
||||
|
||||
static void Command_Teamchange2_f(void)
|
||||
@@ -3364,7 +3364,7 @@ static void Command_Teamchange2_f(void)
|
||||
}
|
||||
|
||||
usvalue = SHORT(NetPacket.value.l|NetPacket.value.b);
|
||||
SendNetXCmd2(XD_TEAMCHANGE, &usvalue, sizeof(usvalue));
|
||||
SendNetXCmdForPlayer(1, XD_TEAMCHANGE, &usvalue, sizeof(usvalue));
|
||||
}
|
||||
|
||||
static void Command_Teamchange3_f(void)
|
||||
@@ -3431,7 +3431,7 @@ static void Command_Teamchange3_f(void)
|
||||
}
|
||||
|
||||
usvalue = SHORT(NetPacket.value.l|NetPacket.value.b);
|
||||
SendNetXCmd3(XD_TEAMCHANGE, &usvalue, sizeof(usvalue));
|
||||
SendNetXCmdForPlayer(2, XD_TEAMCHANGE, &usvalue, sizeof(usvalue));
|
||||
}
|
||||
|
||||
static void Command_Teamchange4_f(void)
|
||||
@@ -3498,7 +3498,7 @@ static void Command_Teamchange4_f(void)
|
||||
}
|
||||
|
||||
usvalue = SHORT(NetPacket.value.l|NetPacket.value.b);
|
||||
SendNetXCmd4(XD_TEAMCHANGE, &usvalue, sizeof(usvalue));
|
||||
SendNetXCmdForPlayer(3, XD_TEAMCHANGE, &usvalue, sizeof(usvalue));
|
||||
}
|
||||
|
||||
static void Command_ServerTeamChange_f(void)
|
||||
|
||||
@@ -1357,9 +1357,7 @@ static void rendezvous(int size)
|
||||
|
||||
if (tic == refreshtic)
|
||||
{
|
||||
#ifdef HOLEPUNCH
|
||||
holepunchpacket->magic = hole_punch_magic;
|
||||
#endif
|
||||
sendto(mysockets[0], doomcom->data, size, 0, &rzv.any, sizeof rzv.ip4);
|
||||
}
|
||||
|
||||
|
||||
@@ -169,7 +169,7 @@ void COM_Lua_f(void)
|
||||
for (i = 0; i < argc; i++)
|
||||
WRITESTRINGN(p, COM_Argv(i), 255);
|
||||
if (flags & 2)
|
||||
SendNetXCmd2(XD_LUACMD, buf, p-buf);
|
||||
SendNetXCmdForPlayer(1, XD_LUACMD, buf, p-buf);
|
||||
else
|
||||
SendNetXCmd(XD_LUACMD, buf, p-buf);
|
||||
free(buf);
|
||||
|
||||
Reference in new issue
Block a user