mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-03-25 04:00:56 +00:00
Temporarily revert recent netcode changes
This commit is contained in:
parent
2ef231c073
commit
606797a5a4
16 changed files with 447 additions and 813 deletions
465
src/d_clisrv.c
465
src/d_clisrv.c
|
@ -1,7 +1,7 @@
|
|||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2023 by Sonic Team Junior.
|
||||
// Copyright (C) 1999-2022 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
@ -25,7 +25,8 @@
|
|||
#include "st_stuff.h"
|
||||
#include "hu_stuff.h"
|
||||
#include "keys.h"
|
||||
#include "g_input.h" // JOY1
|
||||
#include "g_input.h"
|
||||
#include "i_gamepad.h"
|
||||
#include "m_menu.h"
|
||||
#include "console.h"
|
||||
#include "d_netfil.h"
|
||||
|
@ -33,6 +34,7 @@
|
|||
#include "p_saveg.h"
|
||||
#include "z_zone.h"
|
||||
#include "p_local.h"
|
||||
#include "p_haptic.h"
|
||||
#include "m_misc.h"
|
||||
#include "am_map.h"
|
||||
#include "m_random.h"
|
||||
|
@ -49,7 +51,7 @@
|
|||
#include "m_perfstats.h"
|
||||
|
||||
// aaaaaa
|
||||
#include "i_joy.h"
|
||||
#include "i_gamepad.h"
|
||||
|
||||
#ifndef NONET
|
||||
// cl loading screen
|
||||
|
@ -120,8 +122,6 @@ UINT8 hu_redownloadinggamestate = 0;
|
|||
// true when a player is connecting or disconnecting so that the gameplay has stopped in its tracks
|
||||
boolean hu_stopped = false;
|
||||
|
||||
consvar_t cv_dedicatedidletime = CVAR_INIT ("dedicatedidletime", "10", CV_SAVE, CV_Unsigned, NULL);
|
||||
|
||||
UINT8 adminpassmd5[16];
|
||||
boolean adminpasswordset = false;
|
||||
|
||||
|
@ -655,22 +655,6 @@ static UINT8 Snake_GetOppositeDir(UINT8 dir)
|
|||
return 12 + 5 - dir;
|
||||
}
|
||||
|
||||
event_t *snakejoyevents[MAXEVENTS];
|
||||
UINT16 joyeventcount = 0;
|
||||
|
||||
// I'm screaming the hack is clean - ashi
|
||||
static boolean Snake_Joy_Grabber(event_t *ev)
|
||||
{
|
||||
if (ev->type == ev_joystick && ev->key == 0)
|
||||
{
|
||||
snakejoyevents[joyeventcount] = ev;
|
||||
joyeventcount++;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
static void Snake_FindFreeSlot(UINT8 *freex, UINT8 *freey, UINT8 headx, UINT8 heady)
|
||||
{
|
||||
UINT8 x, y;
|
||||
|
@ -697,19 +681,17 @@ static void Snake_Handle(void)
|
|||
UINT8 x, y;
|
||||
UINT8 oldx, oldy;
|
||||
UINT16 i;
|
||||
UINT16 j;
|
||||
UINT16 joystate = 0;
|
||||
static INT32 pjoyx = 0, pjoyy = 0;
|
||||
|
||||
// Handle retry
|
||||
if (snake->gameover && (PLAYER1INPUTDOWN(GC_JUMP) || gamekeydown[KEY_ENTER]))
|
||||
if (snake->gameover && (G_PlayerInputDown(0, GC_JUMP) || gamekeydown[KEY_ENTER]))
|
||||
{
|
||||
Snake_Initialise();
|
||||
snake->pausepressed = true; // Avoid accidental pause on respawn
|
||||
}
|
||||
|
||||
// Handle pause
|
||||
if (PLAYER1INPUTDOWN(GC_PAUSE) || gamekeydown[KEY_ENTER])
|
||||
if (G_PlayerInputDown(0, GC_PAUSE) || gamekeydown[KEY_ENTER])
|
||||
{
|
||||
if (!snake->pausepressed)
|
||||
snake->paused = !snake->paused;
|
||||
|
@ -728,58 +710,23 @@ static void Snake_Handle(void)
|
|||
oldx = snake->snakex[1];
|
||||
oldy = snake->snakey[1];
|
||||
|
||||
// process the input events in here dear lord
|
||||
for (j = 0; j < joyeventcount; j++)
|
||||
{
|
||||
event_t *ev = snakejoyevents[j];
|
||||
const INT32 jdeadzone = (JOYAXISRANGE * cv_digitaldeadzone.value) / FRACUNIT;
|
||||
if (ev->y != INT32_MAX)
|
||||
{
|
||||
if (Joystick.bGamepadStyle || abs(ev->y) > jdeadzone)
|
||||
{
|
||||
if (ev->y < 0 && pjoyy >= 0)
|
||||
joystate = 1;
|
||||
else if (ev->y > 0 && pjoyy <= 0)
|
||||
joystate = 2;
|
||||
pjoyy = ev->y;
|
||||
}
|
||||
else
|
||||
pjoyy = 0;
|
||||
}
|
||||
|
||||
if (ev->x != INT32_MAX)
|
||||
{
|
||||
if (Joystick.bGamepadStyle || abs(ev->x) > jdeadzone)
|
||||
{
|
||||
if (ev->x < 0 && pjoyx >= 0)
|
||||
joystate = 3;
|
||||
else if (ev->x > 0 && pjoyx <= 0)
|
||||
joystate = 4;
|
||||
pjoyx = ev->x;
|
||||
}
|
||||
else
|
||||
pjoyx = 0;
|
||||
}
|
||||
}
|
||||
joyeventcount = 0;
|
||||
|
||||
// Update direction
|
||||
if (PLAYER1INPUTDOWN(GC_STRAFELEFT) || gamekeydown[KEY_LEFTARROW] || joystate == 3)
|
||||
if (G_PlayerInputDown(0, GC_STRAFELEFT) || gamekeydown[KEY_LEFTARROW] || joystate == 3)
|
||||
{
|
||||
if (snake->snakelength < 2 || x <= oldx)
|
||||
snake->snakedir[0] = 1;
|
||||
}
|
||||
else if (PLAYER1INPUTDOWN(GC_STRAFERIGHT) || gamekeydown[KEY_RIGHTARROW] || joystate == 4)
|
||||
else if (G_PlayerInputDown(0, GC_STRAFERIGHT) || gamekeydown[KEY_RIGHTARROW] || joystate == 4)
|
||||
{
|
||||
if (snake->snakelength < 2 || x >= oldx)
|
||||
snake->snakedir[0] = 2;
|
||||
}
|
||||
else if (PLAYER1INPUTDOWN(GC_FORWARD) || gamekeydown[KEY_UPARROW] || joystate == 1)
|
||||
else if (G_PlayerInputDown(0, GC_FORWARD) || gamekeydown[KEY_UPARROW] || joystate == 1)
|
||||
{
|
||||
if (snake->snakelength < 2 || y <= oldy)
|
||||
snake->snakedir[0] = 3;
|
||||
}
|
||||
else if (PLAYER1INPUTDOWN(GC_BACKWARD) || gamekeydown[KEY_DOWNARROW] || joystate == 2)
|
||||
else if (G_PlayerInputDown(0, GC_BACKWARD) || gamekeydown[KEY_DOWNARROW] || joystate == 2)
|
||||
{
|
||||
if (snake->snakelength < 2 || y >= oldy)
|
||||
snake->snakedir[0] = 4;
|
||||
|
@ -1295,7 +1242,6 @@ static boolean CL_AskFileList(INT32 firstfile)
|
|||
static boolean CL_SendJoin(void)
|
||||
{
|
||||
UINT8 localplayers = 1;
|
||||
char const *player2name;
|
||||
if (netgame)
|
||||
CONS_Printf(M_GetText("Sending join request...\n"));
|
||||
netbuffer->packettype = PT_CLIENTJOIN;
|
||||
|
@ -1312,23 +1258,18 @@ static boolean CL_SendJoin(void)
|
|||
CleanupPlayerName(consoleplayer, cv_playername.zstring);
|
||||
if (splitscreen)
|
||||
CleanupPlayerName(1, cv_playername2.zstring);/* 1 is a HACK? oh no */
|
||||
// Avoid empty string on bots to avoid softlocking in singleplayer
|
||||
if (botingame)
|
||||
player2name = strcmp(cv_playername.zstring, "Tails") == 0 ? "Tail" : "Tails";
|
||||
else
|
||||
player2name = cv_playername2.zstring;
|
||||
|
||||
strncpy(netbuffer->u.clientcfg.names[0], cv_playername.zstring, MAXPLAYERNAME);
|
||||
strncpy(netbuffer->u.clientcfg.names[1], player2name, MAXPLAYERNAME);
|
||||
strncpy(netbuffer->u.clientcfg.names[1], cv_playername2.zstring, MAXPLAYERNAME);
|
||||
|
||||
return HSendPacket(servernode, true, 0, sizeof (clientconfig_pak));
|
||||
}
|
||||
|
||||
static INT32 FindRejoinerNum(SINT8 node)
|
||||
{
|
||||
char addressbuffer[64];
|
||||
char strippednodeaddress[64];
|
||||
const char *nodeaddress;
|
||||
const char *strippednodeaddress;
|
||||
char *port;
|
||||
INT32 i;
|
||||
|
||||
// Make sure there is no dead dress before proceeding to the stripping
|
||||
|
@ -1339,8 +1280,10 @@ static INT32 FindRejoinerNum(SINT8 node)
|
|||
return -1;
|
||||
|
||||
// Strip the address of its port
|
||||
strcpy(addressbuffer, nodeaddress);
|
||||
strippednodeaddress = I_NetSplitAddress(addressbuffer, NULL);
|
||||
strcpy(strippednodeaddress, nodeaddress);
|
||||
port = strchr(strippednodeaddress, ':');
|
||||
if (port)
|
||||
*port = '\0';
|
||||
|
||||
// Check if any player matches the stripped address
|
||||
for (i = 0; i < MAXPLAYERS; i++)
|
||||
|
@ -1383,9 +1326,8 @@ static void SV_SendServerInfo(INT32 node, tic_t servertime)
|
|||
netbuffer->u.serverinfo.time = (tic_t)LONG(servertime);
|
||||
netbuffer->u.serverinfo.leveltime = (tic_t)LONG(leveltime);
|
||||
|
||||
// Exclude bots from both counts
|
||||
netbuffer->u.serverinfo.numberofplayer = (UINT8)(D_NumPlayers() - D_NumBots());
|
||||
netbuffer->u.serverinfo.maxplayer = (UINT8)(cv_maxplayers.value - D_NumBots());
|
||||
netbuffer->u.serverinfo.numberofplayer = (UINT8)D_NumPlayers();
|
||||
netbuffer->u.serverinfo.maxplayer = (UINT8)cv_maxplayers.value;
|
||||
|
||||
netbuffer->u.serverinfo.refusereason = GetRefuseReason(node);
|
||||
|
||||
|
@ -1512,7 +1454,6 @@ static boolean SV_SendServerConfig(INT32 node)
|
|||
netbuffer->u.servercfg.gamestate = (UINT8)gamestate;
|
||||
netbuffer->u.servercfg.gametype = (UINT8)gametype;
|
||||
netbuffer->u.servercfg.modifiedgame = (UINT8)modifiedgame;
|
||||
netbuffer->u.servercfg.usedCheats = (UINT8)usedCheats;
|
||||
|
||||
memcpy(netbuffer->u.servercfg.server_context, server_context, 8);
|
||||
|
||||
|
@ -1711,6 +1652,8 @@ static void CL_LoadReceivedSavegame(boolean reloading)
|
|||
titledemo = false;
|
||||
automapactive = false;
|
||||
|
||||
P_StopRumble(NULL);
|
||||
|
||||
// load a base level
|
||||
if (P_LoadNetGame(reloading))
|
||||
{
|
||||
|
@ -1997,9 +1940,10 @@ void CL_UpdateServerList(boolean internetsearch, INT32 room)
|
|||
static void M_ConfirmConnect(event_t *ev)
|
||||
{
|
||||
#ifndef NONET
|
||||
if (ev->type == ev_keydown)
|
||||
|
||||
if (ev->type == ev_keydown || ev->type == ev_gamepad_down)
|
||||
{
|
||||
if (ev->key == ' ' || ev->key == 'y' || ev->key == KEY_ENTER || ev->key == KEY_JOY1)
|
||||
if ((ev->type == ev_keydown && (ev->key == ' ' || ev->key == 'y' || ev->key == KEY_ENTER)) || (ev->type == ev_gamepad_down && ev->which == 0 && ev->key == GAMEPAD_BUTTON_A))
|
||||
{
|
||||
if (totalfilesrequestednum > 0)
|
||||
{
|
||||
|
@ -2014,7 +1958,7 @@ static void M_ConfirmConnect(event_t *ev)
|
|||
|
||||
M_ClearMenus(true);
|
||||
}
|
||||
else if (ev->key == 'n' || ev->key == KEY_ESCAPE || ev->key == KEY_JOY1 + 3)
|
||||
else if ((ev->type == ev_keydown && (ev->key == 'n' || ev->key == KEY_ESCAPE)) || (ev->type == ev_gamepad_down && ev->which == 0 && ev->key == GAMEPAD_BUTTON_B))
|
||||
{
|
||||
cl_mode = CL_ABORTED;
|
||||
M_ClearMenus(true);
|
||||
|
@ -2448,14 +2392,11 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic
|
|||
// my hand has been forced and I am dearly sorry for this awful hack :vomit:
|
||||
for (; eventtail != eventhead; eventtail = (eventtail+1) & (MAXEVENTS-1))
|
||||
{
|
||||
#ifndef NONET
|
||||
if (!Snake_Joy_Grabber(&events[eventtail]))
|
||||
#endif
|
||||
G_MapEventsToControls(&events[eventtail]);
|
||||
G_MapEventsToControls(&events[eventtail]);
|
||||
}
|
||||
}
|
||||
|
||||
if (gamekeydown[KEY_ESCAPE] || gamekeydown[KEY_JOY1+1] || cl_mode == CL_ABORTED)
|
||||
if (gamekeydown[KEY_ESCAPE] || gamepads[0].buttons[GAMEPAD_BUTTON_B] || cl_mode == CL_ABORTED)
|
||||
{
|
||||
CONS_Printf(M_GetText("Network game synchronization aborted.\n"));
|
||||
M_StartMessage(M_GetText("Network game synchronization aborted.\n\nPress ESC\n"), NULL, MM_NOTHING);
|
||||
|
@ -2493,7 +2434,7 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic
|
|||
{
|
||||
if (!snake)
|
||||
{
|
||||
F_MenuPresTicker(); // title sky
|
||||
F_MenuPresTicker(true); // title sky
|
||||
F_TitleScreenTicker(true);
|
||||
F_TitleScreenDrawer();
|
||||
}
|
||||
|
@ -2608,8 +2549,6 @@ static void CL_ConnectToServer(void)
|
|||
}
|
||||
while (!(cl_mode == CL_CONNECTED && (client || (server && nodewaited <= pnumnodes))));
|
||||
|
||||
if (netgame)
|
||||
F_StartWaitingPlayers();
|
||||
DEBFILE(va("Synchronisation Finished\n"));
|
||||
|
||||
displayplayer = consoleplayer;
|
||||
|
@ -3516,10 +3455,10 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum)
|
|||
static CV_PossibleValue_t netticbuffer_cons_t[] = {{0, "MIN"}, {3, "MAX"}, {0, NULL}};
|
||||
consvar_t cv_netticbuffer = CVAR_INIT ("netticbuffer", "1", CV_SAVE, netticbuffer_cons_t, NULL);
|
||||
|
||||
consvar_t cv_allownewplayer = CVAR_INIT ("allowjoin", "On", CV_SAVE|CV_NETVAR|CV_ALLOWLUA, CV_OnOff, NULL);
|
||||
consvar_t cv_allownewplayer = CVAR_INIT ("allowjoin", "On", CV_SAVE|CV_NETVAR, CV_OnOff, NULL);
|
||||
consvar_t cv_joinnextround = CVAR_INIT ("joinnextround", "Off", CV_SAVE|CV_NETVAR, CV_OnOff, NULL); /// \todo not done
|
||||
static CV_PossibleValue_t maxplayers_cons_t[] = {{2, "MIN"}, {32, "MAX"}, {0, NULL}};
|
||||
consvar_t cv_maxplayers = CVAR_INIT ("maxplayers", "8", CV_SAVE|CV_NETVAR|CV_ALLOWLUA, maxplayers_cons_t, NULL);
|
||||
consvar_t cv_maxplayers = CVAR_INIT ("maxplayers", "8", CV_SAVE|CV_NETVAR, maxplayers_cons_t, NULL);
|
||||
static CV_PossibleValue_t joindelay_cons_t[] = {{1, "MIN"}, {3600, "MAX"}, {0, "Off"}, {0, NULL}};
|
||||
consvar_t cv_joindelay = CVAR_INIT ("joindelay", "10", CV_SAVE|CV_NETVAR, joindelay_cons_t, NULL);
|
||||
static CV_PossibleValue_t rejointimeout_cons_t[] = {{1, "MIN"}, {60 * FRACUNIT, "MAX"}, {0, "Off"}, {0, NULL}};
|
||||
|
@ -3547,22 +3486,22 @@ void D_ClientServerInit(void)
|
|||
VERSION/100, VERSION%100, SUBVERSION));
|
||||
|
||||
#ifndef NONET
|
||||
COM_AddCommand("getplayernum", Command_GetPlayerNum, COM_LUA);
|
||||
COM_AddCommand("kick", Command_Kick, COM_LUA);
|
||||
COM_AddCommand("ban", Command_Ban, COM_LUA);
|
||||
COM_AddCommand("banip", Command_BanIP, COM_LUA);
|
||||
COM_AddCommand("clearbans", Command_ClearBans, COM_LUA);
|
||||
COM_AddCommand("showbanlist", Command_ShowBan, COM_LUA);
|
||||
COM_AddCommand("reloadbans", Command_ReloadBan, COM_LUA);
|
||||
COM_AddCommand("connect", Command_connect, COM_LUA);
|
||||
COM_AddCommand("nodes", Command_Nodes, COM_LUA);
|
||||
COM_AddCommand("resendgamestate", Command_ResendGamestate, COM_LUA);
|
||||
COM_AddCommand("getplayernum", Command_GetPlayerNum);
|
||||
COM_AddCommand("kick", Command_Kick);
|
||||
COM_AddCommand("ban", Command_Ban);
|
||||
COM_AddCommand("banip", Command_BanIP);
|
||||
COM_AddCommand("clearbans", Command_ClearBans);
|
||||
COM_AddCommand("showbanlist", Command_ShowBan);
|
||||
COM_AddCommand("reloadbans", Command_ReloadBan);
|
||||
COM_AddCommand("connect", Command_connect);
|
||||
COM_AddCommand("nodes", Command_Nodes);
|
||||
COM_AddCommand("resendgamestate", Command_ResendGamestate);
|
||||
#ifdef PACKETDROP
|
||||
COM_AddCommand("drop", Command_Drop, COM_LUA);
|
||||
COM_AddCommand("droprate", Command_Droprate, COM_LUA);
|
||||
COM_AddCommand("drop", Command_Drop);
|
||||
COM_AddCommand("droprate", Command_Droprate);
|
||||
#endif
|
||||
#ifdef _DEBUG
|
||||
COM_AddCommand("numnodes", Command_Numnodes, COM_LUA);
|
||||
COM_AddCommand("numnodes", Command_Numnodes);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -3653,9 +3592,6 @@ void SV_ResetServer(void)
|
|||
|
||||
CV_RevertNetVars();
|
||||
|
||||
// Ensure synched when creating a new server
|
||||
M_CopyGameData(serverGamedata, clientGamedata);
|
||||
|
||||
DEBFILE("\n-=-=-=-=-=-=-= Server Reset =-=-=-=-=-=-=-\n\n");
|
||||
}
|
||||
|
||||
|
@ -3779,13 +3715,14 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum)
|
|||
|
||||
if (server && I_GetNodeAddress)
|
||||
{
|
||||
char addressbuffer[64];
|
||||
const char *address = I_GetNodeAddress(node);
|
||||
char *port = NULL;
|
||||
if (address) // MI: fix msvcrt.dll!_mbscat crash?
|
||||
{
|
||||
strcpy(addressbuffer, address);
|
||||
strcpy(playeraddress[newplayernum],
|
||||
I_NetSplitAddress(addressbuffer, NULL));
|
||||
strcpy(playeraddress[newplayernum], address);
|
||||
port = strchr(playeraddress[newplayernum], ':');
|
||||
if (port)
|
||||
*port = '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4089,7 +4026,7 @@ ConnectionRefused (SINT8 node, INT32 rejoinernum)
|
|||
{
|
||||
return va(
|
||||
"Maximum players reached: %d",
|
||||
cv_maxplayers.value - D_NumBots());
|
||||
cv_maxplayers.value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4417,8 +4354,6 @@ static void HandlePacketFromAwayNode(SINT8 node)
|
|||
maketic = gametic = neededtic = (tic_t)LONG(netbuffer->u.servercfg.gametic);
|
||||
G_SetGametype(netbuffer->u.servercfg.gametype);
|
||||
modifiedgame = netbuffer->u.servercfg.modifiedgame;
|
||||
if (netbuffer->u.servercfg.usedCheats)
|
||||
G_SetUsedCheats(true);
|
||||
memcpy(server_context, netbuffer->u.servercfg.server_context, 8);
|
||||
}
|
||||
|
||||
|
@ -4528,7 +4463,6 @@ static void HandlePacketFromPlayer(SINT8 node)
|
|||
netconsole = 0;
|
||||
else
|
||||
netconsole = nodetoplayer[node];
|
||||
|
||||
#ifdef PARANOIA
|
||||
if (netconsole >= MAXPLAYERS)
|
||||
I_Error("bad table nodetoplayer: node %d player %d", doomcom->remotenode, netconsole);
|
||||
|
@ -4567,32 +4501,21 @@ static void HandlePacketFromPlayer(SINT8 node)
|
|||
// Update the nettics
|
||||
nettics[node] = realend;
|
||||
|
||||
// This should probably still timeout though, as the node should always have a player 1 number
|
||||
if (netconsole == -1)
|
||||
// Don't do anything for packets of type NODEKEEPALIVE?
|
||||
if (netconsole == -1 || netbuffer->packettype == PT_NODEKEEPALIVE
|
||||
|| netbuffer->packettype == PT_NODEKEEPALIVEMIS)
|
||||
break;
|
||||
|
||||
// As long as clients send valid ticcmds, the server can keep running, so reset the timeout
|
||||
/// \todo Use a separate cvar for that kind of timeout?
|
||||
freezetimeout[node] = I_GetTime() + connectiontimeout;
|
||||
|
||||
// Don't do anything for packets of type NODEKEEPALIVE?
|
||||
// Sryder 2018/07/01: Update the freezetimeout still!
|
||||
if (netbuffer->packettype == PT_NODEKEEPALIVE
|
||||
|| netbuffer->packettype == PT_NODEKEEPALIVEMIS)
|
||||
break;
|
||||
|
||||
// If we've alredy received a ticcmd for this tic, just submit it for the next one.
|
||||
tic_t faketic = maketic;
|
||||
if ((!!(netcmds[maketic % BACKUPTICS][netconsole].angleturn & TICCMD_RECEIVED))
|
||||
&& (maketic - firstticstosend < BACKUPTICS))
|
||||
faketic++;
|
||||
|
||||
// Copy ticcmd
|
||||
G_MoveTiccmd(&netcmds[faketic%BACKUPTICS][netconsole], &netbuffer->u.clientpak.cmd, 1);
|
||||
G_MoveTiccmd(&netcmds[maketic%BACKUPTICS][netconsole], &netbuffer->u.clientpak.cmd, 1);
|
||||
|
||||
// Check ticcmd for "speed hacks"
|
||||
if (netcmds[faketic%BACKUPTICS][netconsole].forwardmove > MAXPLMOVE || netcmds[faketic%BACKUPTICS][netconsole].forwardmove < -MAXPLMOVE
|
||||
|| netcmds[faketic%BACKUPTICS][netconsole].sidemove > MAXPLMOVE || netcmds[faketic%BACKUPTICS][netconsole].sidemove < -MAXPLMOVE)
|
||||
if (netcmds[maketic%BACKUPTICS][netconsole].forwardmove > MAXPLMOVE || netcmds[maketic%BACKUPTICS][netconsole].forwardmove < -MAXPLMOVE
|
||||
|| netcmds[maketic%BACKUPTICS][netconsole].sidemove > MAXPLMOVE || netcmds[maketic%BACKUPTICS][netconsole].sidemove < -MAXPLMOVE)
|
||||
{
|
||||
CONS_Alert(CONS_WARNING, M_GetText("Illegal movement value received from node %d\n"), netconsole);
|
||||
//D_Clearticcmd(k);
|
||||
|
@ -4604,10 +4527,9 @@ static void HandlePacketFromPlayer(SINT8 node)
|
|||
// Splitscreen cmd
|
||||
if ((netbuffer->packettype == PT_CLIENT2CMD || netbuffer->packettype == PT_CLIENT2MIS)
|
||||
&& nodetoplayer2[node] >= 0)
|
||||
G_MoveTiccmd(&netcmds[faketic%BACKUPTICS][(UINT8)nodetoplayer2[node]],
|
||||
G_MoveTiccmd(&netcmds[maketic%BACKUPTICS][(UINT8)nodetoplayer2[node]],
|
||||
&netbuffer->u.client2pak.cmd2, 1);
|
||||
|
||||
|
||||
// Check player consistancy during the level
|
||||
if (realstart <= gametic && realstart + BACKUPTICS - 1 > gametic && gamestate == GS_LEVEL
|
||||
&& consistancy[realstart%BACKUPTICS] != SHORT(netbuffer->u.clientpak.consistancy)
|
||||
|
@ -4644,21 +4566,6 @@ static void HandlePacketFromPlayer(SINT8 node)
|
|||
}
|
||||
}
|
||||
break;
|
||||
case PT_BASICKEEPALIVE:
|
||||
if (client)
|
||||
break;
|
||||
|
||||
// This should probably still timeout though, as the node should always have a player 1 number
|
||||
if (netconsole == -1)
|
||||
break;
|
||||
|
||||
// If a client sends this it should mean they are done receiving the savegame
|
||||
sendingsavegame[node] = false;
|
||||
|
||||
// As long as clients send keep alives, the server can keep running, so reset the timeout
|
||||
/// \todo Use a separate cvar for that kind of timeout?
|
||||
freezetimeout[node] = I_GetTime() + connectiontimeout;
|
||||
break;
|
||||
case PT_TEXTCMD2: // splitscreen special
|
||||
netconsole = nodetoplayer2[node];
|
||||
/* FALLTHRU */
|
||||
|
@ -5085,66 +4992,39 @@ static INT16 Consistancy(void)
|
|||
return (INT16)(ret & 0xFFFF);
|
||||
}
|
||||
|
||||
// confusing, but this DOESN'T send PT_NODEKEEPALIVE, it sends PT_BASICKEEPALIVE
|
||||
// used during wipes to tell the server that a node is still connected
|
||||
static void CL_SendClientKeepAlive(void)
|
||||
{
|
||||
netbuffer->packettype = PT_BASICKEEPALIVE;
|
||||
|
||||
HSendPacket(servernode, false, 0, 0);
|
||||
}
|
||||
|
||||
static void SV_SendServerKeepAlive(void)
|
||||
{
|
||||
INT32 n;
|
||||
|
||||
for (n = 1; n < MAXNETNODES; n++)
|
||||
{
|
||||
if (nodeingame[n])
|
||||
{
|
||||
netbuffer->packettype = PT_BASICKEEPALIVE;
|
||||
HSendPacket(n, false, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// send the client packet to the server
|
||||
static void CL_SendClientCmd(void)
|
||||
{
|
||||
size_t packetsize = 0;
|
||||
boolean mis = false;
|
||||
|
||||
netbuffer->packettype = PT_CLIENTCMD;
|
||||
|
||||
if (cl_packetmissed)
|
||||
{
|
||||
netbuffer->packettype = PT_CLIENTMIS;
|
||||
mis = true;
|
||||
}
|
||||
|
||||
netbuffer->packettype++;
|
||||
netbuffer->u.clientpak.resendfrom = (UINT8)(neededtic & UINT8_MAX);
|
||||
netbuffer->u.clientpak.client_tic = (UINT8)(gametic & UINT8_MAX);
|
||||
|
||||
if (gamestate == GS_WAITINGPLAYERS)
|
||||
{
|
||||
// Send PT_NODEKEEPALIVE packet
|
||||
netbuffer->packettype = (mis ? PT_NODEKEEPALIVEMIS : PT_NODEKEEPALIVE);
|
||||
netbuffer->packettype += 4;
|
||||
packetsize = sizeof (clientcmd_pak) - sizeof (ticcmd_t) - sizeof (INT16);
|
||||
HSendPacket(servernode, false, 0, packetsize);
|
||||
}
|
||||
else if (gamestate != GS_NULL && (addedtogame || dedicated))
|
||||
{
|
||||
packetsize = sizeof (clientcmd_pak);
|
||||
G_MoveTiccmd(&netbuffer->u.clientpak.cmd, &localcmds, 1);
|
||||
netbuffer->u.clientpak.consistancy = SHORT(consistancy[gametic%BACKUPTICS]);
|
||||
|
||||
// Send a special packet with 2 cmd for splitscreen
|
||||
if (splitscreen || botingame)
|
||||
{
|
||||
netbuffer->packettype = (mis ? PT_CLIENT2MIS : PT_CLIENT2CMD);
|
||||
packetsize = sizeof (client2cmd_pak);
|
||||
netbuffer->packettype += 2;
|
||||
G_MoveTiccmd(&netbuffer->u.client2pak.cmd2, &localcmds2, 1);
|
||||
packetsize = sizeof (client2cmd_pak);
|
||||
}
|
||||
else
|
||||
packetsize = sizeof (clientcmd_pak);
|
||||
|
||||
HSendPacket(servernode, false, 0, packetsize);
|
||||
}
|
||||
|
@ -5155,7 +5035,7 @@ static void CL_SendClientCmd(void)
|
|||
if (localtextcmd[0])
|
||||
{
|
||||
netbuffer->packettype = PT_TEXTCMD;
|
||||
M_Memcpy(netbuffer->u.textcmd, localtextcmd, localtextcmd[0]+1);
|
||||
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;
|
||||
|
@ -5299,7 +5179,7 @@ static void Local_Maketic(INT32 realtics)
|
|||
// game responder calls HU_Responder, AM_Responder,
|
||||
// and G_MapEventsToControls
|
||||
if (!dedicated) rendergametic = gametic;
|
||||
// translate inputs (keyboard/mouse/joystick) into game controls
|
||||
// translate inputs (keyboard/mouse/gamepad) into game controls
|
||||
G_BuildTiccmd(&localcmds, realtics, 1);
|
||||
if (splitscreen || botingame)
|
||||
G_BuildTiccmd(&localcmds2, realtics, 2);
|
||||
|
@ -5535,11 +5415,28 @@ static inline void PingUpdate(void)
|
|||
pingmeasurecount = 1; //Reset count
|
||||
}
|
||||
|
||||
static tic_t gametime = 0;
|
||||
|
||||
static void UpdatePingTable(void)
|
||||
void NetUpdate(void)
|
||||
{
|
||||
static tic_t gametime = 0;
|
||||
static tic_t resptime = 0;
|
||||
tic_t nowtime;
|
||||
INT32 i;
|
||||
INT32 realtics;
|
||||
|
||||
nowtime = I_GetTime();
|
||||
realtics = nowtime - gametime;
|
||||
|
||||
if (realtics <= 0) // nothing new to update
|
||||
return;
|
||||
if (realtics > 5)
|
||||
{
|
||||
if (server)
|
||||
realtics = 1;
|
||||
else
|
||||
realtics = 5;
|
||||
}
|
||||
|
||||
gametime = nowtime;
|
||||
|
||||
if (server)
|
||||
{
|
||||
|
@ -5551,150 +5448,6 @@ static void UpdatePingTable(void)
|
|||
realpingtable[i] += G_TicsToMilliseconds(GetLag(playernode[i]));
|
||||
pingmeasurecount++;
|
||||
}
|
||||
}
|
||||
|
||||
// Handle timeouts to prevent definitive freezes from happenning
|
||||
static void HandleNodeTimeouts(void)
|
||||
{
|
||||
INT32 i;
|
||||
|
||||
if (server)
|
||||
{
|
||||
for (i = 1; i < MAXNETNODES; i++)
|
||||
if (nodeingame[i] && freezetimeout[i] < I_GetTime())
|
||||
Net_ConnectionTimeout(i);
|
||||
|
||||
// In case the cvar value was lowered
|
||||
if (joindelay)
|
||||
joindelay = min(joindelay - 1, 3 * (tic_t)cv_joindelay.value * TICRATE);
|
||||
}
|
||||
}
|
||||
|
||||
// Keep the network alive while not advancing tics!
|
||||
void NetKeepAlive(void)
|
||||
{
|
||||
tic_t nowtime;
|
||||
INT32 realtics;
|
||||
|
||||
nowtime = I_GetTime();
|
||||
realtics = nowtime - gametime;
|
||||
|
||||
// return if there's no time passed since the last call
|
||||
if (realtics <= 0) // nothing new to update
|
||||
return;
|
||||
|
||||
UpdatePingTable();
|
||||
|
||||
GetPackets();
|
||||
|
||||
#ifdef MASTERSERVER
|
||||
MasterClient_Ticker();
|
||||
#endif
|
||||
|
||||
if (client)
|
||||
{
|
||||
// send keep alive
|
||||
CL_SendClientKeepAlive();
|
||||
// No need to check for resynch because we aren't running any tics
|
||||
}
|
||||
else
|
||||
{
|
||||
SV_SendServerKeepAlive();
|
||||
}
|
||||
|
||||
// No else because no tics are being run and we can't resynch during this
|
||||
|
||||
Net_AckTicker();
|
||||
HandleNodeTimeouts();
|
||||
FileSendTicker();
|
||||
}
|
||||
|
||||
void NetUpdate(void)
|
||||
{
|
||||
static tic_t resptime = 0;
|
||||
tic_t nowtime;
|
||||
INT32 i;
|
||||
INT32 realtics;
|
||||
|
||||
nowtime = I_GetTime();
|
||||
realtics = nowtime - gametime;
|
||||
|
||||
if (realtics <= 0) // nothing new to update
|
||||
return;
|
||||
|
||||
if (realtics > 5)
|
||||
{
|
||||
if (server)
|
||||
realtics = 1;
|
||||
else
|
||||
realtics = 5;
|
||||
}
|
||||
|
||||
if (server && dedicated && gamestate == GS_LEVEL)
|
||||
{
|
||||
const tic_t dedicatedidletime = cv_dedicatedidletime.value * TICRATE;
|
||||
static tic_t dedicatedidletimeprev = 0;
|
||||
static tic_t dedicatedidle = 0;
|
||||
|
||||
if (dedicatedidletime > 0)
|
||||
{
|
||||
for (i = 1; i < MAXNETNODES; ++i)
|
||||
if (nodeingame[i])
|
||||
{
|
||||
if (dedicatedidle >= dedicatedidletime)
|
||||
{
|
||||
CONS_Printf("DEDICATED: Awakening from idle (Node %d detected...)\n", i);
|
||||
dedicatedidle = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == MAXNETNODES)
|
||||
{
|
||||
if (leveltime == 2)
|
||||
{
|
||||
// On next tick...
|
||||
dedicatedidle = dedicatedidletime-1;
|
||||
}
|
||||
else if (dedicatedidle >= dedicatedidletime)
|
||||
{
|
||||
if (D_GetExistingTextcmd(gametic, 0) || D_GetExistingTextcmd(gametic+1, 0))
|
||||
{
|
||||
CONS_Printf("DEDICATED: Awakening from idle (Netxcmd detected...)\n");
|
||||
dedicatedidle = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
realtics = 0;
|
||||
}
|
||||
}
|
||||
else if ((dedicatedidle += realtics) >= dedicatedidletime)
|
||||
{
|
||||
const char *idlereason = "at round start";
|
||||
if (leveltime > 3)
|
||||
idlereason = va("for %d seconds", dedicatedidle/TICRATE);
|
||||
|
||||
CONS_Printf("DEDICATED: No nodes %s, idling...\n", idlereason);
|
||||
realtics = 0;
|
||||
dedicatedidle = dedicatedidletime;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dedicatedidletimeprev > 0 && dedicatedidle >= dedicatedidletimeprev)
|
||||
{
|
||||
CONS_Printf("DEDICATED: Awakening from idle (Idle disabled...)\n");
|
||||
}
|
||||
dedicatedidle = 0;
|
||||
}
|
||||
|
||||
dedicatedidletimeprev = dedicatedidletime;
|
||||
}
|
||||
|
||||
gametime = nowtime;
|
||||
|
||||
UpdatePingTable();
|
||||
|
||||
if (client)
|
||||
maketic = neededtic;
|
||||
|
@ -5726,25 +5479,24 @@ void NetUpdate(void)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (!demoplayback && realtics > 0)
|
||||
if (!demoplayback)
|
||||
{
|
||||
INT32 counts;
|
||||
|
||||
hu_redownloadinggamestate = false;
|
||||
|
||||
// Don't erase tics not acknowledged
|
||||
counts = realtics;
|
||||
|
||||
firstticstosend = gametic;
|
||||
for (i = 0; i < MAXNETNODES; i++)
|
||||
{
|
||||
if (!nodeingame[i])
|
||||
continue;
|
||||
if (nettics[i] < firstticstosend)
|
||||
if (nodeingame[i] && nettics[i] < firstticstosend)
|
||||
{
|
||||
firstticstosend = nettics[i];
|
||||
if (maketic + counts >= nettics[i] + (BACKUPTICS - TICRATE))
|
||||
Net_ConnectionTimeout(i);
|
||||
}
|
||||
|
||||
if (maketic + 1 >= nettics[i] + BACKUPTICS)
|
||||
Net_ConnectionTimeout(i);
|
||||
}
|
||||
|
||||
// Don't erase tics not acknowledged
|
||||
counts = realtics;
|
||||
|
||||
if (maketic + counts >= firstticstosend + BACKUPTICS)
|
||||
counts = firstticstosend+BACKUPTICS-maketic-1;
|
||||
|
@ -5762,10 +5514,20 @@ void NetUpdate(void)
|
|||
}
|
||||
|
||||
Net_AckTicker();
|
||||
HandleNodeTimeouts();
|
||||
|
||||
// Handle timeouts to prevent definitive freezes from happenning
|
||||
if (server)
|
||||
{
|
||||
for (i = 1; i < MAXNETNODES; i++)
|
||||
if (nodeingame[i] && freezetimeout[i] < I_GetTime())
|
||||
Net_ConnectionTimeout(i);
|
||||
|
||||
// In case the cvar value was lowered
|
||||
if (joindelay)
|
||||
joindelay = min(joindelay - 1, 3 * (tic_t)cv_joindelay.value * TICRATE);
|
||||
}
|
||||
|
||||
nowtime /= NEWTICRATERATIO;
|
||||
|
||||
if (nowtime > resptime)
|
||||
{
|
||||
resptime = nowtime;
|
||||
|
@ -5796,19 +5558,6 @@ INT32 D_NumPlayers(void)
|
|||
return num;
|
||||
}
|
||||
|
||||
/** Similar to the above, but counts only bots.
|
||||
* Purpose is to remove bots from both the player count and the
|
||||
* max player count on the server view
|
||||
*/
|
||||
INT32 D_NumBots(void)
|
||||
{
|
||||
INT32 num = 0, ix;
|
||||
for (ix = 0; ix < MAXPLAYERS; ix++)
|
||||
if (playeringame[ix] && players[ix].bot)
|
||||
num++;
|
||||
return num;
|
||||
}
|
||||
|
||||
tic_t GetLag(INT32 node)
|
||||
{
|
||||
return gametic - nettics[node];
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2023 by Sonic Team Junior.
|
||||
// Copyright (C) 1999-2022 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
@ -77,8 +77,6 @@ typedef enum
|
|||
PT_ASKLUAFILE, // Client telling the server they don't have the file
|
||||
PT_HASLUAFILE, // Client telling the server they have the file
|
||||
|
||||
PT_BASICKEEPALIVE,// Keep the network alive during wipes, as tics aren't advanced and NetUpdate isn't called
|
||||
|
||||
// Add non-PT_CANFAIL packet types here to avoid breaking MS compatibility.
|
||||
|
||||
PT_CANFAIL, // This is kind of a priority. Anything bigger than CANFAIL
|
||||
|
@ -160,7 +158,6 @@ typedef struct
|
|||
|
||||
UINT8 gametype;
|
||||
UINT8 modifiedgame;
|
||||
UINT8 usedCheats;
|
||||
|
||||
char server_context[8]; // Unique context id, generated at server startup.
|
||||
} ATTRPACK serverconfig_pak;
|
||||
|
@ -400,7 +397,6 @@ extern tic_t servermaxping;
|
|||
extern consvar_t cv_netticbuffer, cv_allownewplayer, cv_joinnextround, cv_maxplayers, cv_joindelay, cv_rejointimeout;
|
||||
extern consvar_t cv_resynchattempts, cv_blamecfail;
|
||||
extern consvar_t cv_maxsend, cv_noticedownload, cv_downloadspeed;
|
||||
extern consvar_t cv_dedicatedidletime;
|
||||
|
||||
// Used in d_net, the only dependence
|
||||
tic_t ExpandTics(INT32 low, INT32 node);
|
||||
|
@ -415,9 +411,6 @@ void SendKick(UINT8 playernum, UINT8 msg);
|
|||
// Create any new ticcmds and broadcast to other players.
|
||||
void NetUpdate(void);
|
||||
|
||||
// Maintain connections to nodes without timing them all out.
|
||||
void NetKeepAlive(void);
|
||||
|
||||
void SV_StartSinglePlayerServer(void);
|
||||
boolean SV_SpawnServer(void);
|
||||
void SV_StopServer(void);
|
||||
|
@ -454,7 +447,6 @@ extern char motd[254], server_context[8];
|
|||
extern UINT8 playernode[MAXPLAYERS];
|
||||
|
||||
INT32 D_NumPlayers(void);
|
||||
INT32 D_NumBots(void);
|
||||
void D_ResetTiccmds(void);
|
||||
|
||||
tic_t GetLag(INT32 node);
|
||||
|
|
31
src/d_net.c
31
src/d_net.c
|
@ -2,7 +2,7 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2023 by Sonic Team Junior.
|
||||
// Copyright (C) 1999-2022 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
@ -869,9 +869,6 @@ static void DebugPrintpacket(const char *header)
|
|||
(UINT32)ExpandTics(netbuffer->u.clientpak.client_tic, doomcom->remotenode),
|
||||
(UINT32)ExpandTics (netbuffer->u.clientpak.resendfrom, doomcom->remotenode));
|
||||
break;
|
||||
case PT_BASICKEEPALIVE:
|
||||
fprintf(debugfile, " wipetime\n");
|
||||
break;
|
||||
case PT_TEXTCMD:
|
||||
case PT_TEXTCMD2:
|
||||
fprintf(debugfile, " length %d\n ", netbuffer->u.textcmd[0]);
|
||||
|
@ -1210,32 +1207,26 @@ static void Internal_FreeNodenum(INT32 nodenum)
|
|||
(void)nodenum;
|
||||
}
|
||||
|
||||
char *I_NetSplitAddress(char *host, char **port)
|
||||
{
|
||||
boolean v4 = (strchr(host, '.') != NULL);
|
||||
|
||||
host = strtok(host, v4 ? ":" : "[]");
|
||||
|
||||
if (port)
|
||||
*port = strtok(NULL, ":");
|
||||
|
||||
return host;
|
||||
}
|
||||
|
||||
SINT8 I_NetMakeNode(const char *hostname)
|
||||
{
|
||||
SINT8 newnode = -1;
|
||||
if (I_NetMakeNodewPort)
|
||||
{
|
||||
char *localhostname = strdup(hostname);
|
||||
char *port;
|
||||
char *t = localhostname;
|
||||
const char *port;
|
||||
if (!localhostname)
|
||||
return newnode;
|
||||
|
||||
// retrieve portnum from address!
|
||||
hostname = I_NetSplitAddress(localhostname, &port);
|
||||
strtok(localhostname, ":");
|
||||
port = strtok(NULL, ":");
|
||||
|
||||
newnode = I_NetMakeNodewPort(hostname, port);
|
||||
// remove the port in the hostname as we've it already
|
||||
while ((*t != ':') && (*t != '\0'))
|
||||
t++;
|
||||
*t = '\0';
|
||||
|
||||
newnode = I_NetMakeNodewPort(localhostname, port);
|
||||
free(localhostname);
|
||||
}
|
||||
return newnode;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2023 by Sonic Team Junior.
|
||||
// Copyright (C) 1999-2022 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
|
594
src/d_netcmd.c
594
src/d_netcmd.c
File diff suppressed because it is too large
Load diff
|
@ -1,7 +1,7 @@
|
|||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2023 by Sonic Team Junior.
|
||||
// Copyright (C) 1999-2022 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
@ -33,14 +33,10 @@ extern consvar_t cv_defaultskin2;
|
|||
|
||||
extern consvar_t cv_seenames, cv_allowseenames;
|
||||
extern consvar_t cv_usemouse;
|
||||
extern consvar_t cv_usejoystick;
|
||||
extern consvar_t cv_usejoystick2;
|
||||
#ifdef LJOYSTICK
|
||||
extern consvar_t cv_joyport;
|
||||
extern consvar_t cv_joyport2;
|
||||
#endif
|
||||
extern consvar_t cv_joyscale;
|
||||
extern consvar_t cv_joyscale2;
|
||||
extern consvar_t cv_usegamepad[2];
|
||||
extern consvar_t cv_gamepad_scale[2];
|
||||
extern consvar_t cv_gamepad_rumble[2];
|
||||
extern consvar_t cv_gamepad_autopause;
|
||||
|
||||
// splitscreen with second mouse
|
||||
extern consvar_t cv_mouse2port;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2023 by Sonic Team Junior.
|
||||
// Copyright (C) 1999-2022 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
@ -498,7 +498,7 @@ INT32 CL_CheckFiles(void)
|
|||
CONS_Debug(DBG_NETPLAY, "searching for '%s' ", fileneeded[i].filename);
|
||||
|
||||
// Check in already loaded files
|
||||
for (j = mainwads; j < numwadfiles; j++)
|
||||
for (j = mainwads; wadfiles[j]; j++)
|
||||
{
|
||||
nameonly(strcpy(wadfilename, wadfiles[j]->filename));
|
||||
if (!stricmp(wadfilename, fileneeded[i].filename) &&
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2023 by Sonic Team Junior.
|
||||
// Copyright (C) 1999-2022 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 2020-2023 by James R.
|
||||
// Copyright (C) 2020-2022 by James R.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
@ -65,8 +65,6 @@ static I_mutex hms_api_mutex;
|
|||
|
||||
static char *hms_server_token;
|
||||
|
||||
static char hms_useragent[512];
|
||||
|
||||
struct HMS_buffer
|
||||
{
|
||||
CURL *curl;
|
||||
|
@ -83,22 +81,6 @@ Contact_error (void)
|
|||
);
|
||||
}
|
||||
|
||||
static void
|
||||
get_user_agent(char *buf, size_t len)
|
||||
{
|
||||
if (snprintf(buf, len, "%s/%s (%s; %s; %i; %i) SRB2BASE/%i", SRB2APPLICATION, VERSIONSTRING, compbranch, comprevision, MODID, MODVERSION, CODEBASE) < 0)
|
||||
I_Error("http-mserv: get_user_agent failed");
|
||||
}
|
||||
|
||||
static void
|
||||
init_user_agent_once(void)
|
||||
{
|
||||
if (hms_useragent[0] != '\0')
|
||||
return;
|
||||
|
||||
get_user_agent(hms_useragent, 512);
|
||||
}
|
||||
|
||||
static size_t
|
||||
HMS_on_read (char *s, size_t _1, size_t n, void *userdata)
|
||||
{
|
||||
|
@ -174,8 +156,6 @@ HMS_connect (const char *format, ...)
|
|||
I_lock_mutex(&hms_api_mutex);
|
||||
#endif
|
||||
|
||||
init_user_agent_once();
|
||||
|
||||
seek = strlen(hms_api) + 1;/* + '/' */
|
||||
|
||||
va_start (ap, format);
|
||||
|
@ -216,18 +196,12 @@ HMS_connect (const char *format, ...)
|
|||
|
||||
curl_easy_setopt(curl, CURLOPT_URL, url);
|
||||
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
|
||||
|
||||
#ifndef NO_IPV6
|
||||
if (M_CheckParm("-noipv6"))
|
||||
#endif
|
||||
curl_easy_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
|
||||
curl_easy_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_TIMEOUT, cv_masterserver_timeout.value);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, HMS_on_read);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, buffer);
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_USERAGENT, hms_useragent);
|
||||
|
||||
curl_free(quack_token);
|
||||
free(url);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 2011-2023 by Sonic Team Junior.
|
||||
// Copyright (C) 2011-2022 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 2011-2023 by Sonic Team Junior.
|
||||
// Copyright (C) 2011-2022 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
|
13
src/i_net.h
13
src/i_net.h
|
@ -2,7 +2,7 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2023 by Sonic Team Junior.
|
||||
// Copyright (C) 1999-2022 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
@ -109,17 +109,6 @@ extern boolean (*I_NetCanSend)(void);
|
|||
*/
|
||||
extern void (*I_NetFreeNodenum)(INT32 nodenum);
|
||||
|
||||
/**
|
||||
\brief split a string into address and port
|
||||
|
||||
\param address string to split
|
||||
|
||||
\param port double pointer to hold port component (optional)
|
||||
|
||||
\return address component
|
||||
*/
|
||||
extern char *I_NetSplitAddress(char *address, char **port);
|
||||
|
||||
/** \brief open a connection with specified address
|
||||
|
||||
\param address address to connect to
|
||||
|
|
73
src/i_tcp.c
73
src/i_tcp.c
|
@ -1,7 +1,7 @@
|
|||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2023 by Sonic Team Junior.
|
||||
// Copyright (C) 1999-2022 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
@ -340,14 +340,8 @@ static inline void I_UPnP_rem(const char *port, const char * servicetype)
|
|||
|
||||
static const char *SOCK_AddrToStr(mysockaddr_t *sk)
|
||||
{
|
||||
static char s[64]; // 255.255.255.255:65535 or
|
||||
// [ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff]:65535
|
||||
static char s[64]; // 255.255.255.255:65535 or IPv6:65535
|
||||
#ifdef HAVE_NTOP
|
||||
#ifdef HAVE_IPV6
|
||||
int v6 = (sk->any.sa_family == AF_INET6);
|
||||
#else
|
||||
int v6 = 0;
|
||||
#endif
|
||||
void *addr;
|
||||
|
||||
if(sk->any.sa_family == AF_INET)
|
||||
|
@ -361,21 +355,14 @@ static const char *SOCK_AddrToStr(mysockaddr_t *sk)
|
|||
|
||||
if(addr == NULL)
|
||||
sprintf(s, "No address");
|
||||
else if(inet_ntop(sk->any.sa_family, addr, &s[v6], sizeof (s) - v6) == NULL)
|
||||
else if(inet_ntop(sk->any.sa_family, addr, s, sizeof (s)) == NULL)
|
||||
sprintf(s, "Unknown family type, error #%u", errno);
|
||||
#ifdef HAVE_IPV6
|
||||
else if(sk->any.sa_family == AF_INET6)
|
||||
{
|
||||
s[0] = '[';
|
||||
strcat(s, "]");
|
||||
|
||||
if (sk->ip6.sin6_port != 0)
|
||||
strcat(s, va(":%d", ntohs(sk->ip6.sin6_port)));
|
||||
}
|
||||
else if(sk->any.sa_family == AF_INET6 && sk->ip6.sin6_port != 0)
|
||||
strcat(s, va(":%d", ntohs(sk->ip6.sin6_port)));
|
||||
#endif
|
||||
else if(sk->any.sa_family == AF_INET && sk->ip4.sin_port != 0)
|
||||
strcat(s, va(":%d", ntohs(sk->ip4.sin_port)));
|
||||
|
||||
#else
|
||||
if (sk->any.sa_family == AF_INET)
|
||||
{
|
||||
|
@ -440,7 +427,7 @@ static boolean SOCK_cmpaddr(mysockaddr_t *a, mysockaddr_t *b, UINT8 mask)
|
|||
&& (b->ip4.sin_port == 0 || (a->ip4.sin_port == b->ip4.sin_port));
|
||||
#ifdef HAVE_IPV6
|
||||
else if (b->any.sa_family == AF_INET6)
|
||||
return !memcmp(&a->ip6.sin6_addr, &b->ip6.sin6_addr, sizeof(b->ip6.sin6_addr))
|
||||
return memcmp(&a->ip6.sin6_addr, &b->ip6.sin6_addr, sizeof(b->ip6.sin6_addr))
|
||||
&& (b->ip6.sin6_port == 0 || (a->ip6.sin6_port == b->ip6.sin6_port));
|
||||
#endif
|
||||
else
|
||||
|
@ -748,7 +735,8 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen
|
|||
unsigned long trueval = true;
|
||||
#endif
|
||||
mysockaddr_t straddr;
|
||||
socklen_t len = sizeof(straddr);
|
||||
struct sockaddr_in sin;
|
||||
socklen_t len = sizeof(sin);
|
||||
|
||||
if (s == (SOCKET_TYPE)ERRSOCKET)
|
||||
return (SOCKET_TYPE)ERRSOCKET;
|
||||
|
@ -766,12 +754,14 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen
|
|||
}
|
||||
#endif
|
||||
|
||||
memcpy(&straddr, addr, addrlen);
|
||||
straddr.any = *addr;
|
||||
I_OutputMsg("Binding to %s\n", SOCK_AddrToStr(&straddr));
|
||||
|
||||
if (family == AF_INET)
|
||||
{
|
||||
if (straddr.ip4.sin_addr.s_addr == htonl(INADDR_ANY))
|
||||
mysockaddr_t tmpaddr;
|
||||
tmpaddr.any = *addr ;
|
||||
if (tmpaddr.ip4.sin_addr.s_addr == htonl(INADDR_ANY))
|
||||
{
|
||||
opt = true;
|
||||
opts = (socklen_t)sizeof(opt);
|
||||
|
@ -788,7 +778,7 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen
|
|||
#ifdef HAVE_IPV6
|
||||
else if (family == AF_INET6)
|
||||
{
|
||||
if (memcmp(&straddr.ip6.sin6_addr, &in6addr_any, sizeof(in6addr_any)) == 0) //IN6_ARE_ADDR_EQUAL
|
||||
if (memcmp(addr, &in6addr_any, sizeof(in6addr_any)) == 0) //IN6_ARE_ADDR_EQUAL
|
||||
{
|
||||
opt = true;
|
||||
opts = (socklen_t)sizeof(opt);
|
||||
|
@ -798,7 +788,7 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen
|
|||
// make it IPv6 ony
|
||||
opt = true;
|
||||
opts = (socklen_t)sizeof(opt);
|
||||
if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, (char *)&opt, opts))
|
||||
if (setsockopt(s, SOL_SOCKET, IPV6_V6ONLY, (char *)&opt, opts))
|
||||
{
|
||||
CONS_Alert(CONS_WARNING, M_GetText("Could not limit IPv6 bind\n")); // I do not care anymore
|
||||
}
|
||||
|
@ -840,17 +830,10 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen
|
|||
CONS_Printf(M_GetText("Network system buffer set to: %dKb\n"), opt>>10);
|
||||
}
|
||||
|
||||
if (getsockname(s, &straddr.any, &len) == -1)
|
||||
if (getsockname(s, (struct sockaddr *)&sin, &len) == -1)
|
||||
CONS_Alert(CONS_WARNING, M_GetText("Failed to get port number\n"));
|
||||
else
|
||||
{
|
||||
if (family == AF_INET)
|
||||
current_port = (UINT16)ntohs(straddr.ip4.sin_port);
|
||||
#ifdef HAVE_IPV6
|
||||
else if (family == AF_INET6)
|
||||
current_port = (UINT16)ntohs(straddr.ip6.sin6_port);
|
||||
#endif
|
||||
}
|
||||
current_port = (UINT16)ntohs(sin.sin_port);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
@ -861,7 +844,7 @@ static boolean UDP_Socket(void)
|
|||
struct my_addrinfo *ai, *runp, hints;
|
||||
int gaie;
|
||||
#ifdef HAVE_IPV6
|
||||
const INT32 b_ipv6 = !M_CheckParm("-noipv6");
|
||||
const INT32 b_ipv6 = M_CheckParm("-ipv6");
|
||||
#endif
|
||||
const char *serv;
|
||||
|
||||
|
@ -1173,7 +1156,6 @@ static SINT8 SOCK_NetMakeNodewPort(const char *address, const char *port)
|
|||
SINT8 newnode = -1;
|
||||
struct my_addrinfo *ai = NULL, *runp, hints;
|
||||
int gaie;
|
||||
size_t i;
|
||||
|
||||
if (!port || !port[0])
|
||||
port = DEFAULTPORT;
|
||||
|
@ -1201,24 +1183,13 @@ static SINT8 SOCK_NetMakeNodewPort(const char *address, const char *port)
|
|||
|
||||
while (runp != NULL)
|
||||
{
|
||||
// test ip address of server
|
||||
for (i = 0; i < mysocketses; ++i)
|
||||
// find ip of the server
|
||||
if (sendto(mysockets[0], NULL, 0, 0, runp->ai_addr, runp->ai_addrlen) == 0)
|
||||
{
|
||||
/* sendto tests that there is a network to this
|
||||
address */
|
||||
if (runp->ai_addr->sa_family == myfamily[i] &&
|
||||
sendto(mysockets[i], NULL, 0, 0,
|
||||
runp->ai_addr, runp->ai_addrlen) == 0)
|
||||
{
|
||||
memcpy(&clientaddress[newnode], runp->ai_addr, runp->ai_addrlen);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i < mysocketses)
|
||||
runp = runp->ai_next;
|
||||
else
|
||||
memcpy(&clientaddress[newnode], runp->ai_addr, runp->ai_addrlen);
|
||||
break;
|
||||
}
|
||||
runp = runp->ai_next;
|
||||
}
|
||||
I_freeaddrinfo(ai);
|
||||
return newnode;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2023 by Sonic Team Junior.
|
||||
// Copyright (C) 1999-2022 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
|
10
src/mserv.c
10
src/mserv.c
|
@ -1,8 +1,8 @@
|
|||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2023 by Sonic Team Junior.
|
||||
// Copyright (C) 2020-2023 by James R.
|
||||
// Copyright (C) 1999-2022 by Sonic Team Junior.
|
||||
// Copyright (C) 2020-2022 by James R.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
@ -62,7 +62,7 @@ static CV_PossibleValue_t masterserver_update_rate_cons_t[] = {
|
|||
};
|
||||
|
||||
consvar_t cv_masterserver = CVAR_INIT ("masterserver", "https://mb.srb2.org/MS/0", CV_SAVE|CV_CALL, NULL, MasterServer_OnChange);
|
||||
consvar_t cv_servername = CVAR_INIT ("servername", "SRB2 server", CV_SAVE|CV_NETVAR|CV_CALL|CV_NOINIT|CV_ALLOWLUA, NULL, Update_parameters);
|
||||
consvar_t cv_servername = CVAR_INIT ("servername", "SRB2 server", CV_SAVE|CV_NETVAR|CV_CALL|CV_NOINIT, NULL, Update_parameters);
|
||||
|
||||
consvar_t cv_masterserver_update_rate = CVAR_INIT ("masterserver_update_rate", "15", CV_SAVE|CV_CALL|CV_NOINIT, masterserver_update_rate_cons_t, Update_parameters);
|
||||
|
||||
|
@ -97,8 +97,8 @@ void AddMServCommands(void)
|
|||
CV_RegisterVar(&cv_masterserver_token);
|
||||
CV_RegisterVar(&cv_servername);
|
||||
#ifdef MASTERSERVER
|
||||
COM_AddCommand("listserv", Command_Listserv_f, 0);
|
||||
COM_AddCommand("masterserver_update", Update_parameters, COM_LUA); // allows people to updates manually in case you were delisted by accident
|
||||
COM_AddCommand("listserv", Command_Listserv_f);
|
||||
COM_AddCommand("masterserver_update", Update_parameters); // allows people to updates manually in case you were delisted by accident
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2023 by Sonic Team Junior.
|
||||
// Copyright (C) 2020-2023 by James R.
|
||||
// Copyright (C) 1999-2022 by Sonic Team Junior.
|
||||
// Copyright (C) 2020-2022 by James R.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
@ -33,7 +33,7 @@ typedef union
|
|||
typedef struct
|
||||
{
|
||||
msg_header_t header;
|
||||
char ip[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"];
|
||||
char ip[16];
|
||||
char port[8];
|
||||
char name[32];
|
||||
INT32 room;
|
||||
|
|
Loading…
Reference in a new issue