mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-03-03 16:11:33 +00:00
- Create a Network class and a network global for d_net
- Remove old DOS stuff from doomcom_t and clarify the interface by adding a NetPacket class - Remove all calls to NetUpdate from the software renderers
This commit is contained in:
parent
836b09c933
commit
0df692bfec
44 changed files with 768 additions and 942 deletions
|
@ -213,7 +213,7 @@ CCMD (removebots)
|
|||
return;
|
||||
}
|
||||
|
||||
Net_WriteByte (DEM_KILLBOTS);
|
||||
network.Net_WriteByte (DEM_KILLBOTS);
|
||||
}
|
||||
|
||||
CCMD (freeze)
|
||||
|
@ -227,8 +227,8 @@ CCMD (freeze)
|
|||
return;
|
||||
}
|
||||
|
||||
Net_WriteByte (DEM_GENERICCHEAT);
|
||||
Net_WriteByte (CHT_FREEZE);
|
||||
network.Net_WriteByte (DEM_GENERICCHEAT);
|
||||
network.Net_WriteByte (CHT_FREEZE);
|
||||
}
|
||||
|
||||
CCMD (listbots)
|
||||
|
|
|
@ -319,8 +319,8 @@ bool FCajunMaster::SpawnBot (const char *name, int color)
|
|||
|
||||
thebot->inuse = BOTINUSE_Waiting;
|
||||
|
||||
Net_WriteByte (DEM_ADDBOT);
|
||||
Net_WriteByte (botshift);
|
||||
network.Net_WriteByte (DEM_ADDBOT);
|
||||
network.Net_WriteByte (botshift);
|
||||
{
|
||||
//Set color.
|
||||
char concat[512];
|
||||
|
@ -334,12 +334,12 @@ bool FCajunMaster::SpawnBot (const char *name, int color)
|
|||
mysnprintf (concat + strlen(concat), countof(concat) - strlen(concat),
|
||||
"\\team\\%d\n", thebot->lastteam);
|
||||
}
|
||||
Net_WriteString (concat);
|
||||
network.Net_WriteString (concat);
|
||||
}
|
||||
Net_WriteByte(thebot->skill.aiming);
|
||||
Net_WriteByte(thebot->skill.perfection);
|
||||
Net_WriteByte(thebot->skill.reaction);
|
||||
Net_WriteByte(thebot->skill.isp);
|
||||
network.Net_WriteByte(thebot->skill.aiming);
|
||||
network.Net_WriteByte(thebot->skill.perfection);
|
||||
network.Net_WriteByte(thebot->skill.reaction);
|
||||
network.Net_WriteByte(thebot->skill.isp);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ static FRandom pr_botmove ("BotMove");
|
|||
//so this is what the bot does.
|
||||
void DBot::Think ()
|
||||
{
|
||||
ticcmd_t *cmd = &netcmds[player - players][((gametic + 1)/ticdup)%BACKUPTICS];
|
||||
ticcmd_t *cmd = &network.netcmds[player - players][((gametic + 1)/ network.ticdup)%BACKUPTICS];
|
||||
|
||||
memset (cmd, 0, sizeof(*cmd));
|
||||
|
||||
|
@ -83,13 +83,13 @@ void DBot::Think ()
|
|||
ThinkForMove (cmd);
|
||||
TurnToAng ();
|
||||
|
||||
cmd->ucmd.yaw = (short)((actor->Angles.Yaw - oldyaw).Degrees * (65536 / 360.f)) / ticdup;
|
||||
cmd->ucmd.yaw = (short)((actor->Angles.Yaw - oldyaw).Degrees * (65536 / 360.f)) / network.ticdup;
|
||||
cmd->ucmd.pitch = (short)((oldpitch - actor->Angles.Pitch).Degrees * (65536 / 360.f));
|
||||
if (cmd->ucmd.pitch == -32768)
|
||||
cmd->ucmd.pitch = -32767;
|
||||
cmd->ucmd.pitch /= ticdup;
|
||||
actor->Angles.Yaw = oldyaw + DAngle(cmd->ucmd.yaw * ticdup * (360 / 65536.f));
|
||||
actor->Angles.Pitch = oldpitch - DAngle(cmd->ucmd.pitch * ticdup * (360 / 65536.f));
|
||||
cmd->ucmd.pitch /= network.ticdup;
|
||||
actor->Angles.Yaw = oldyaw + DAngle(cmd->ucmd.yaw * network.ticdup * (360 / 65536.f));
|
||||
actor->Angles.Pitch = oldpitch - DAngle(cmd->ucmd.pitch * network.ticdup * (360 / 65536.f));
|
||||
}
|
||||
|
||||
if (t_active) t_active--;
|
||||
|
|
136
src/c_cmds.cpp
136
src/c_cmds.cpp
|
@ -122,8 +122,8 @@ CCMD (god)
|
|||
if (CheckCheatmode ())
|
||||
return;
|
||||
|
||||
Net_WriteByte (DEM_GENERICCHEAT);
|
||||
Net_WriteByte (CHT_GOD);
|
||||
network.Net_WriteByte (DEM_GENERICCHEAT);
|
||||
network.Net_WriteByte (CHT_GOD);
|
||||
}
|
||||
|
||||
CCMD(god2)
|
||||
|
@ -131,8 +131,8 @@ CCMD(god2)
|
|||
if (CheckCheatmode())
|
||||
return;
|
||||
|
||||
Net_WriteByte(DEM_GENERICCHEAT);
|
||||
Net_WriteByte(CHT_GOD2);
|
||||
network.Net_WriteByte(DEM_GENERICCHEAT);
|
||||
network.Net_WriteByte(CHT_GOD2);
|
||||
}
|
||||
|
||||
CCMD (iddqd)
|
||||
|
@ -140,8 +140,8 @@ CCMD (iddqd)
|
|||
if (CheckCheatmode ())
|
||||
return;
|
||||
|
||||
Net_WriteByte (DEM_GENERICCHEAT);
|
||||
Net_WriteByte (CHT_IDDQD);
|
||||
network.Net_WriteByte (DEM_GENERICCHEAT);
|
||||
network.Net_WriteByte (CHT_IDDQD);
|
||||
}
|
||||
|
||||
CCMD (buddha)
|
||||
|
@ -149,8 +149,8 @@ CCMD (buddha)
|
|||
if (CheckCheatmode())
|
||||
return;
|
||||
|
||||
Net_WriteByte(DEM_GENERICCHEAT);
|
||||
Net_WriteByte(CHT_BUDDHA);
|
||||
network.Net_WriteByte(DEM_GENERICCHEAT);
|
||||
network.Net_WriteByte(CHT_BUDDHA);
|
||||
}
|
||||
|
||||
CCMD(buddha2)
|
||||
|
@ -158,8 +158,8 @@ CCMD(buddha2)
|
|||
if (CheckCheatmode())
|
||||
return;
|
||||
|
||||
Net_WriteByte(DEM_GENERICCHEAT);
|
||||
Net_WriteByte(CHT_BUDDHA2);
|
||||
network.Net_WriteByte(DEM_GENERICCHEAT);
|
||||
network.Net_WriteByte(CHT_BUDDHA2);
|
||||
}
|
||||
|
||||
CCMD (notarget)
|
||||
|
@ -167,8 +167,8 @@ CCMD (notarget)
|
|||
if (CheckCheatmode ())
|
||||
return;
|
||||
|
||||
Net_WriteByte (DEM_GENERICCHEAT);
|
||||
Net_WriteByte (CHT_NOTARGET);
|
||||
network.Net_WriteByte (DEM_GENERICCHEAT);
|
||||
network.Net_WriteByte (CHT_NOTARGET);
|
||||
}
|
||||
|
||||
CCMD (fly)
|
||||
|
@ -176,8 +176,8 @@ CCMD (fly)
|
|||
if (CheckCheatmode ())
|
||||
return;
|
||||
|
||||
Net_WriteByte (DEM_GENERICCHEAT);
|
||||
Net_WriteByte (CHT_FLY);
|
||||
network.Net_WriteByte (DEM_GENERICCHEAT);
|
||||
network.Net_WriteByte (CHT_FLY);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -192,8 +192,8 @@ CCMD (noclip)
|
|||
if (CheckCheatmode ())
|
||||
return;
|
||||
|
||||
Net_WriteByte (DEM_GENERICCHEAT);
|
||||
Net_WriteByte (CHT_NOCLIP);
|
||||
network.Net_WriteByte (DEM_GENERICCHEAT);
|
||||
network.Net_WriteByte (CHT_NOCLIP);
|
||||
}
|
||||
|
||||
CCMD (noclip2)
|
||||
|
@ -201,8 +201,8 @@ CCMD (noclip2)
|
|||
if (CheckCheatmode())
|
||||
return;
|
||||
|
||||
Net_WriteByte (DEM_GENERICCHEAT);
|
||||
Net_WriteByte (CHT_NOCLIP2);
|
||||
network.Net_WriteByte (DEM_GENERICCHEAT);
|
||||
network.Net_WriteByte (CHT_NOCLIP2);
|
||||
}
|
||||
|
||||
CCMD (powerup)
|
||||
|
@ -210,8 +210,8 @@ CCMD (powerup)
|
|||
if (CheckCheatmode ())
|
||||
return;
|
||||
|
||||
Net_WriteByte (DEM_GENERICCHEAT);
|
||||
Net_WriteByte (CHT_POWER);
|
||||
network.Net_WriteByte (DEM_GENERICCHEAT);
|
||||
network.Net_WriteByte (CHT_POWER);
|
||||
}
|
||||
|
||||
CCMD (morphme)
|
||||
|
@ -221,13 +221,13 @@ CCMD (morphme)
|
|||
|
||||
if (argv.argc() == 1)
|
||||
{
|
||||
Net_WriteByte (DEM_GENERICCHEAT);
|
||||
Net_WriteByte (CHT_MORPH);
|
||||
network.Net_WriteByte (DEM_GENERICCHEAT);
|
||||
network.Net_WriteByte (CHT_MORPH);
|
||||
}
|
||||
else
|
||||
{
|
||||
Net_WriteByte (DEM_MORPHEX);
|
||||
Net_WriteString (argv[1]);
|
||||
network.Net_WriteByte (DEM_MORPHEX);
|
||||
network.Net_WriteString (argv[1]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -236,8 +236,8 @@ CCMD (anubis)
|
|||
if (CheckCheatmode ())
|
||||
return;
|
||||
|
||||
Net_WriteByte (DEM_GENERICCHEAT);
|
||||
Net_WriteByte (CHT_ANUBIS);
|
||||
network.Net_WriteByte (DEM_GENERICCHEAT);
|
||||
network.Net_WriteByte (CHT_ANUBIS);
|
||||
}
|
||||
|
||||
// [GRB]
|
||||
|
@ -246,8 +246,8 @@ CCMD (resurrect)
|
|||
if (CheckCheatmode ())
|
||||
return;
|
||||
|
||||
Net_WriteByte (DEM_GENERICCHEAT);
|
||||
Net_WriteByte (CHT_RESSURECT);
|
||||
network.Net_WriteByte (DEM_GENERICCHEAT);
|
||||
network.Net_WriteByte (CHT_RESSURECT);
|
||||
}
|
||||
|
||||
EXTERN_CVAR (Bool, chasedemo)
|
||||
|
@ -278,8 +278,8 @@ CCMD (chase)
|
|||
if (gamestate != GS_LEVEL || (!(dmflags2 & DF2_CHASECAM) && deathmatch && CheckCheatmode ()))
|
||||
return;
|
||||
|
||||
Net_WriteByte (DEM_GENERICCHEAT);
|
||||
Net_WriteByte (CHT_CHASECAM);
|
||||
network.Net_WriteByte (DEM_GENERICCHEAT);
|
||||
network.Net_WriteByte (CHT_CHASECAM);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -377,14 +377,14 @@ CCMD (changemap)
|
|||
{
|
||||
if (argv.argc() > 2)
|
||||
{
|
||||
Net_WriteByte (DEM_CHANGEMAP2);
|
||||
Net_WriteByte (atoi(argv[2]));
|
||||
network.Net_WriteByte (DEM_CHANGEMAP2);
|
||||
network.Net_WriteByte (atoi(argv[2]));
|
||||
}
|
||||
else
|
||||
{
|
||||
Net_WriteByte (DEM_CHANGEMAP);
|
||||
network.Net_WriteByte (DEM_CHANGEMAP);
|
||||
}
|
||||
Net_WriteString (mapname);
|
||||
network.Net_WriteString (mapname);
|
||||
}
|
||||
}
|
||||
catch(CRecoverableError &error)
|
||||
|
@ -404,12 +404,12 @@ CCMD (give)
|
|||
if (CheckCheatmode () || argv.argc() < 2)
|
||||
return;
|
||||
|
||||
Net_WriteByte (DEM_GIVECHEAT);
|
||||
Net_WriteString (argv[1]);
|
||||
network.Net_WriteByte (DEM_GIVECHEAT);
|
||||
network.Net_WriteString (argv[1]);
|
||||
if (argv.argc() > 2)
|
||||
Net_WriteLong(atoi(argv[2]));
|
||||
network.Net_WriteLong(atoi(argv[2]));
|
||||
else
|
||||
Net_WriteLong(0);
|
||||
network.Net_WriteLong(0);
|
||||
}
|
||||
|
||||
CCMD (take)
|
||||
|
@ -417,12 +417,12 @@ CCMD (take)
|
|||
if (CheckCheatmode () || argv.argc() < 2)
|
||||
return;
|
||||
|
||||
Net_WriteByte (DEM_TAKECHEAT);
|
||||
Net_WriteString (argv[1]);
|
||||
network.Net_WriteByte (DEM_TAKECHEAT);
|
||||
network.Net_WriteString (argv[1]);
|
||||
if (argv.argc() > 2)
|
||||
Net_WriteLong(atoi (argv[2]));
|
||||
network.Net_WriteLong(atoi (argv[2]));
|
||||
else
|
||||
Net_WriteLong (0);
|
||||
network.Net_WriteLong (0);
|
||||
}
|
||||
|
||||
CCMD(setinv)
|
||||
|
@ -430,17 +430,17 @@ CCMD(setinv)
|
|||
if (CheckCheatmode() || argv.argc() < 2)
|
||||
return;
|
||||
|
||||
Net_WriteByte(DEM_SETINV);
|
||||
Net_WriteString(argv[1]);
|
||||
network.Net_WriteByte(DEM_SETINV);
|
||||
network.Net_WriteString(argv[1]);
|
||||
if (argv.argc() > 2)
|
||||
Net_WriteLong(atoi(argv[2]));
|
||||
network.Net_WriteLong(atoi(argv[2]));
|
||||
else
|
||||
Net_WriteLong(0);
|
||||
network.Net_WriteLong(0);
|
||||
|
||||
if (argv.argc() > 3)
|
||||
Net_WriteByte(!!atoi(argv[3]));
|
||||
network.Net_WriteByte(!!atoi(argv[3]));
|
||||
else
|
||||
Net_WriteByte(0);
|
||||
network.Net_WriteByte(0);
|
||||
|
||||
}
|
||||
|
||||
|
@ -538,18 +538,18 @@ CCMD (puke)
|
|||
|
||||
if (script > 0)
|
||||
{
|
||||
Net_WriteByte (DEM_RUNSCRIPT);
|
||||
Net_WriteWord (script);
|
||||
network.Net_WriteByte (DEM_RUNSCRIPT);
|
||||
network.Net_WriteWord (script);
|
||||
}
|
||||
else
|
||||
{
|
||||
Net_WriteByte (DEM_RUNSCRIPT2);
|
||||
Net_WriteWord (-script);
|
||||
network.Net_WriteByte (DEM_RUNSCRIPT2);
|
||||
network.Net_WriteWord (-script);
|
||||
}
|
||||
Net_WriteByte (argn);
|
||||
network.Net_WriteByte (argn);
|
||||
for (i = 0; i < argn; ++i)
|
||||
{
|
||||
Net_WriteLong (arg[i]);
|
||||
network.Net_WriteLong (arg[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -582,12 +582,12 @@ CCMD (pukename)
|
|||
arg[i] = atoi(argv[argstart + i]);
|
||||
}
|
||||
}
|
||||
Net_WriteByte(DEM_RUNNAMEDSCRIPT);
|
||||
Net_WriteString(argv[1]);
|
||||
Net_WriteByte(argn | (always << 7));
|
||||
network.Net_WriteByte(DEM_RUNNAMEDSCRIPT);
|
||||
network.Net_WriteString(argv[1]);
|
||||
network.Net_WriteByte(argn | (always << 7));
|
||||
for (i = 0; i < argn; ++i)
|
||||
{
|
||||
Net_WriteLong(arg[i]);
|
||||
network.Net_WriteLong(arg[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -628,12 +628,12 @@ CCMD (special)
|
|||
return;
|
||||
}
|
||||
}
|
||||
Net_WriteByte(DEM_RUNSPECIAL);
|
||||
Net_WriteWord(specnum);
|
||||
Net_WriteByte(argc - 2);
|
||||
network.Net_WriteByte(DEM_RUNSPECIAL);
|
||||
network.Net_WriteWord(specnum);
|
||||
network.Net_WriteByte(argc - 2);
|
||||
for (int i = 2; i < argc; ++i)
|
||||
{
|
||||
Net_WriteLong(atoi(argv[i]));
|
||||
network.Net_WriteLong(atoi(argv[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -779,10 +779,10 @@ CCMD (warp)
|
|||
}
|
||||
else
|
||||
{
|
||||
Net_WriteByte (DEM_WARPCHEAT);
|
||||
Net_WriteWord (atoi (argv[1]));
|
||||
Net_WriteWord (atoi (argv[2]));
|
||||
Net_WriteWord (argv.argc() == 3 ? ONFLOORZ/65536 : atoi (argv[3]));
|
||||
network.Net_WriteByte (DEM_WARPCHEAT);
|
||||
network.Net_WriteWord (atoi (argv[1]));
|
||||
network.Net_WriteWord (atoi (argv[2]));
|
||||
network.Net_WriteWord (argv.argc() == 3 ? ONFLOORZ/65536 : atoi (argv[3]));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1083,8 +1083,8 @@ CCMD(thaw)
|
|||
if (CheckCheatmode())
|
||||
return;
|
||||
|
||||
Net_WriteByte (DEM_GENERICCHEAT);
|
||||
Net_WriteByte (CHT_CLEARFROZENPROPS);
|
||||
network.Net_WriteByte (DEM_GENERICCHEAT);
|
||||
network.Net_WriteByte (CHT_CLEARFROZENPROPS);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
|
@ -1300,7 +1300,7 @@ void C_FullConsole ()
|
|||
{
|
||||
if (demoplayback)
|
||||
G_CheckDemoStatus ();
|
||||
D_QuitNetGame ();
|
||||
network.D_QuitNetGame ();
|
||||
advancedemo = false;
|
||||
ConsoleState = c_down;
|
||||
HistPos = NULL;
|
||||
|
|
|
@ -623,7 +623,7 @@ void C_DoCommand (const char *cmd, int keynum)
|
|||
button->ReleaseKey (keynum);
|
||||
if (button == &Button_Mlook && lookspring)
|
||||
{
|
||||
Net_WriteByte (DEM_CENTERVIEW);
|
||||
network.Net_WriteByte (DEM_CENTERVIEW);
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
|
|
@ -356,16 +356,16 @@ static void ShoveChatStr (const char *str, uint8_t who)
|
|||
who |= 2;
|
||||
}
|
||||
|
||||
Net_WriteByte (DEM_SAY);
|
||||
Net_WriteByte (who);
|
||||
network.Net_WriteByte (DEM_SAY);
|
||||
network.Net_WriteByte (who);
|
||||
|
||||
if (!chat_substitution || !DoSubstitution (substBuff, str))
|
||||
{
|
||||
Net_WriteString (str);
|
||||
network.Net_WriteString (str);
|
||||
}
|
||||
else
|
||||
{
|
||||
Net_WriteString (substBuff);
|
||||
network.Net_WriteString (substBuff);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -143,7 +143,6 @@ const FIWADInfo *D_FindIWAD(TArray<FString> &wadfiles, const char *iwad, const c
|
|||
|
||||
// PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
|
||||
|
||||
void D_CheckNetGame ();
|
||||
void D_ProcessEvents ();
|
||||
void G_BuildTiccmd (ticcmd_t* cmd);
|
||||
void D_DoAdvanceDemo ();
|
||||
|
@ -399,14 +398,14 @@ CUSTOM_CVAR (Int, dmflags, 0, CVAR_SERVERINFO)
|
|||
|
||||
if (self & DF_NO_FREELOOK)
|
||||
{
|
||||
Net_WriteByte (DEM_CENTERVIEW);
|
||||
network.Net_WriteByte (DEM_CENTERVIEW);
|
||||
}
|
||||
// If nofov is set, force everybody to the arbitrator's FOV.
|
||||
if ((self & DF_NO_FOV) && consoleplayer == Net_Arbitrator)
|
||||
{
|
||||
float fov;
|
||||
|
||||
Net_WriteByte (DEM_FOV);
|
||||
network.Net_WriteByte (DEM_FOV);
|
||||
|
||||
// If the game is started with DF_NO_FOV set, the arbitrator's
|
||||
// DesiredFOV will not be set when this callback is run, so
|
||||
|
@ -416,7 +415,7 @@ CUSTOM_CVAR (Int, dmflags, 0, CVAR_SERVERINFO)
|
|||
{
|
||||
fov = 90;
|
||||
}
|
||||
Net_WriteFloat (fov);
|
||||
network.Net_WriteFloat (fov);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -937,7 +936,7 @@ void D_Display ()
|
|||
|
||||
if (!wipe || NoWipe < 0)
|
||||
{
|
||||
NetUpdate (); // send out any new accumulation
|
||||
network.NetUpdate (); // send out any new accumulation
|
||||
// normal update
|
||||
// draw ZScript UI stuff
|
||||
C_DrawConsole (hw2d); // draw console
|
||||
|
@ -956,7 +955,7 @@ void D_Display ()
|
|||
screen->WipeEndScreen ();
|
||||
|
||||
wipestart = I_msTime();
|
||||
NetUpdate(); // send out any new accumulation
|
||||
network.NetUpdate(); // send out any new accumulation
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -971,7 +970,7 @@ void D_Display ()
|
|||
C_DrawConsole (hw2d); // console and
|
||||
M_Drawer (); // menu are drawn even on top of wipes
|
||||
screen->Update (); // page flip or blit buffer
|
||||
NetUpdate (); // [RH] not sure this is needed anymore
|
||||
network.NetUpdate (); // [RH] not sure this is needed anymore
|
||||
} while (!done);
|
||||
screen->WipeCleanup();
|
||||
I_FreezeTime(false);
|
||||
|
@ -994,10 +993,10 @@ void D_ErrorCleanup ()
|
|||
savegamerestore = false;
|
||||
screen->Unlock ();
|
||||
bglobal.RemoveAllBots (true);
|
||||
D_QuitNetGame ();
|
||||
network.D_QuitNetGame ();
|
||||
if (demorecording || demoplayback)
|
||||
G_CheckDemoStatus ();
|
||||
Net_ClearBuffers ();
|
||||
network.Net_ClearBuffers ();
|
||||
G_NewInit ();
|
||||
M_ClearMenus ();
|
||||
singletics = false;
|
||||
|
@ -1048,7 +1047,7 @@ void D_DoomLoop ()
|
|||
{
|
||||
I_StartTic ();
|
||||
D_ProcessEvents ();
|
||||
G_BuildTiccmd (&netcmds[consoleplayer][maketic%BACKUPTICS]);
|
||||
G_BuildTiccmd (&network.netcmds[consoleplayer][network.maketic%BACKUPTICS]);
|
||||
if (advancedemo)
|
||||
D_DoAdvanceDemo ();
|
||||
C_Ticker ();
|
||||
|
@ -1057,13 +1056,13 @@ void D_DoomLoop ()
|
|||
// [RH] Use the consoleplayer's camera to update sounds
|
||||
S_UpdateSounds (players[consoleplayer].camera); // move positional sounds
|
||||
gametic++;
|
||||
maketic++;
|
||||
network.maketic++;
|
||||
GC::CheckGC ();
|
||||
Net_NewMakeTic ();
|
||||
network.Net_NewMakeTic ();
|
||||
}
|
||||
else
|
||||
{
|
||||
TryRunTics (); // will run at least one tic
|
||||
network.TryRunTics (); // will run at least one tic
|
||||
}
|
||||
// Update display, next frame, with current state.
|
||||
I_StartTic ();
|
||||
|
@ -2635,7 +2634,7 @@ void D_DoomMain (void)
|
|||
{
|
||||
if (!batchrun) Printf ("D_CheckNetGame: Checking network game status.\n");
|
||||
StartScreen->LoadingStatus ("Checking network game status.", 0x3f);
|
||||
D_CheckNetGame ();
|
||||
network.D_CheckNetGame ();
|
||||
}
|
||||
|
||||
// [SP] Force vanilla transparency auto-detection to re-detect our game lumps now
|
||||
|
@ -2650,7 +2649,7 @@ void D_DoomMain (void)
|
|||
|
||||
// [RH] Run any saved commands from the command line or autoexec.cfg now.
|
||||
gamestate = GS_FULLCONSOLE;
|
||||
Net_NewMakeTic ();
|
||||
network.Net_NewMakeTic ();
|
||||
DThinker::RunThinkers ();
|
||||
gamestate = GS_STARTUP;
|
||||
|
||||
|
@ -2733,7 +2732,7 @@ void D_DoomMain (void)
|
|||
G_BeginRecording(NULL);
|
||||
}
|
||||
|
||||
atterm(D_QuitNetGame); // killough
|
||||
atterm([] { network.D_QuitNetGame(); }); // killough
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2903,7 +2902,7 @@ void FStartupScreen::NetInit(char const *,int) {}
|
|||
void FStartupScreen::NetProgress(int) {}
|
||||
void FStartupScreen::NetMessage(char const *,...) {}
|
||||
void FStartupScreen::NetDone(void) {}
|
||||
bool FStartupScreen::NetLoop(bool (*)(void *),void *) { return false; }
|
||||
bool FStartupScreen::NetLoop(std::function<bool()> callback) { return false; }
|
||||
|
||||
DEFINE_FIELD_X(InputEventData, event_t, type)
|
||||
DEFINE_FIELD_X(InputEventData, event_t, subtype)
|
||||
|
|
622
src/d_net.cpp
622
src/d_net.cpp
File diff suppressed because it is too large
Load diff
208
src/d_net.h
208
src/d_net.h
|
@ -17,21 +17,14 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see http://www.gnu.org/licenses/
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Networking stuff.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
#ifndef __D_NET__
|
||||
#define __D_NET__
|
||||
#pragma once
|
||||
|
||||
#include "doomtype.h"
|
||||
#include "doomdef.h"
|
||||
#include "d_protocol.h"
|
||||
|
||||
#include "i_net.h"
|
||||
#include <memory>
|
||||
|
||||
//
|
||||
// Network play related stuff.
|
||||
|
@ -41,58 +34,11 @@
|
|||
// be transmitted.
|
||||
//
|
||||
|
||||
#define DOOMCOM_ID 0x12345678l
|
||||
#define MAXNETNODES 8 // max computers in a game
|
||||
#define BACKUPTICS 36 // number of tics to remember
|
||||
#define MAXTICDUP 5
|
||||
#define LOCALCMDTICS (BACKUPTICS*MAXTICDUP)
|
||||
|
||||
|
||||
#ifdef DJGPP
|
||||
// The DOS drivers provide a pretty skimpy buffer.
|
||||
// Probably not enough.
|
||||
#define MAX_MSGLEN (BACKUPTICS*10)
|
||||
#else
|
||||
#define MAX_MSGLEN 14000
|
||||
#endif
|
||||
|
||||
#define CMD_SEND 1
|
||||
#define CMD_GET 2
|
||||
|
||||
//
|
||||
// Network packet data.
|
||||
//
|
||||
struct doomcom_t
|
||||
{
|
||||
uint32_t id; // should be DOOMCOM_ID
|
||||
int16_t intnum; // DOOM executes an int to execute commands
|
||||
|
||||
// communication between DOOM and the driver
|
||||
int16_t command; // CMD_SEND or CMD_GET
|
||||
int16_t remotenode; // dest for send, set by get (-1 = no packet).
|
||||
int16_t datalength; // bytes in doomdata to be sent
|
||||
|
||||
// info common to all nodes
|
||||
int16_t numnodes; // console is always node 0.
|
||||
int16_t ticdup; // 1 = no duplication, 2-5 = dup for slow nets
|
||||
#ifdef DJGPP
|
||||
int16_t pad[5]; // keep things aligned for DOS drivers
|
||||
#endif
|
||||
|
||||
// info specific to this node
|
||||
int16_t consoleplayer;
|
||||
int16_t numplayers;
|
||||
#ifdef DJGPP
|
||||
int16_t angleoffset; // does not work, but needed to preserve
|
||||
int16_t drone; // alignment for DOS drivers
|
||||
#endif
|
||||
|
||||
// packet data to be sent
|
||||
uint8_t data[MAX_MSGLEN];
|
||||
|
||||
};
|
||||
|
||||
|
||||
class FDynamicBuffer
|
||||
{
|
||||
public:
|
||||
|
@ -107,52 +53,124 @@ private:
|
|||
int m_Len, m_BufferLen;
|
||||
};
|
||||
|
||||
extern FDynamicBuffer NetSpecs[MAXPLAYERS][BACKUPTICS];
|
||||
struct TicSpecial
|
||||
{
|
||||
uint8_t *streams[BACKUPTICS];
|
||||
size_t used[BACKUPTICS];
|
||||
uint8_t *streamptr;
|
||||
size_t streamoffs;
|
||||
size_t specialsize;
|
||||
int lastmaketic;
|
||||
bool okay;
|
||||
|
||||
// Create any new ticcmds and broadcast to other players.
|
||||
void NetUpdate (void);
|
||||
TicSpecial();
|
||||
~TicSpecial();
|
||||
|
||||
// Broadcasts special packets to other players
|
||||
// to notify of game exit
|
||||
void D_QuitNetGame (void);
|
||||
void GetMoreSpace(size_t needed);
|
||||
void CheckSpace(size_t needed);
|
||||
void NewMakeTic();
|
||||
|
||||
//? how many ticks to run?
|
||||
void TryRunTics (void);
|
||||
TicSpecial &operator << (uint8_t it);
|
||||
TicSpecial &operator << (short it);
|
||||
TicSpecial &operator << (int it);
|
||||
TicSpecial &operator << (float it);
|
||||
TicSpecial &operator << (const char *it);
|
||||
};
|
||||
|
||||
//Use for checking to see if the netgame has stalled
|
||||
void Net_CheckLastReceived(int);
|
||||
struct ArbitrateData
|
||||
{
|
||||
uint32_t playersdetected[MAXNETNODES];
|
||||
uint8_t gotsetup[MAXNETNODES];
|
||||
};
|
||||
|
||||
// [RH] Functions for making and using special "ticcmds"
|
||||
void Net_NewMakeTic ();
|
||||
void Net_WriteByte (uint8_t);
|
||||
void Net_WriteWord (short);
|
||||
void Net_WriteLong (int);
|
||||
void Net_WriteFloat (float);
|
||||
void Net_WriteString (const char *);
|
||||
void Net_WriteBytes (const uint8_t *, int len);
|
||||
struct Network
|
||||
{
|
||||
public:
|
||||
void D_CheckNetGame();
|
||||
void ListPingTimes();
|
||||
void Network_Controller(int playernum, bool add);
|
||||
void Net_ClearBuffers();
|
||||
void NetUpdate();
|
||||
void D_QuitNetGame();
|
||||
void TryRunTics();
|
||||
void Net_NewMakeTic();
|
||||
|
||||
void Net_WriteByte(uint8_t it);
|
||||
void Net_WriteWord(short it);
|
||||
void Net_WriteLong(int it);
|
||||
void Net_WriteFloat(float it);
|
||||
void Net_WriteString(const char *it);
|
||||
void Net_WriteBytes(const uint8_t *block, int len);
|
||||
|
||||
short consistancy[MAXPLAYERS][BACKUPTICS];
|
||||
|
||||
FDynamicBuffer NetSpecs[MAXPLAYERS][BACKUPTICS];
|
||||
ticcmd_t netcmds[MAXPLAYERS][BACKUPTICS];
|
||||
ticcmd_t localcmds[LOCALCMDTICS];
|
||||
|
||||
int maketic;
|
||||
int ticdup; // 1 = no duplication, 2-5 = dup for slow nets
|
||||
|
||||
int nodeforplayer[MAXPLAYERS];
|
||||
int netdelay[MAXNETNODES][BACKUPTICS]; // Used for storing network delay times.
|
||||
|
||||
private:
|
||||
int NetbufferSize();
|
||||
int ExpandTics(int low);
|
||||
void HSendPacket(int node, int len);
|
||||
bool HGetPacket();
|
||||
void PlayerIsGone(int netnode, int netconsole);
|
||||
void GetPackets();
|
||||
bool DoArbitrate(ArbitrateData *data);
|
||||
void D_ArbitrateNetStart();
|
||||
void Net_CheckLastReceived(int counts);
|
||||
|
||||
void SendSetup(uint32_t playersdetected[MAXNETNODES], uint8_t gotsetup[MAXNETNODES], int len);
|
||||
|
||||
std::unique_ptr<doomcom_t> doomcom;
|
||||
NetPacket netbuffer;
|
||||
|
||||
int gametime;
|
||||
|
||||
enum { NET_PeerToPeer, NET_PacketServer };
|
||||
uint8_t NetMode = NET_PeerToPeer;
|
||||
|
||||
int nettics[MAXNETNODES];
|
||||
bool nodeingame[MAXNETNODES]; // set false as nodes leave game
|
||||
bool nodejustleft[MAXNETNODES]; // set when a node just left
|
||||
bool remoteresend[MAXNETNODES]; // set when local needs tics
|
||||
int resendto[MAXNETNODES]; // set when remote needs tics
|
||||
int resendcount[MAXNETNODES];
|
||||
|
||||
uint64_t lastrecvtime[MAXPLAYERS]; // [RH] Used for pings
|
||||
uint64_t currrecvtime[MAXPLAYERS];
|
||||
uint64_t lastglobalrecvtime; // Identify the last time a packet was received.
|
||||
bool hadlate;
|
||||
int lastaverage;
|
||||
|
||||
int playerfornode[MAXNETNODES];
|
||||
|
||||
int skiptics;
|
||||
|
||||
int reboundpacket;
|
||||
uint8_t reboundstore[MAX_MSGLEN];
|
||||
|
||||
int frameon;
|
||||
int frameskip[4];
|
||||
int oldnettics;
|
||||
int mastertics;
|
||||
|
||||
int entertic;
|
||||
int oldentertics;
|
||||
|
||||
TicSpecial specials;
|
||||
};
|
||||
|
||||
extern Network network;
|
||||
|
||||
void Net_DoCommand (int type, uint8_t **stream, int player);
|
||||
void Net_SkipCommand (int type, uint8_t **stream);
|
||||
|
||||
void Net_ClearBuffers ();
|
||||
|
||||
|
||||
// Netgame stuff (buffers and pointers, i.e. indices).
|
||||
|
||||
// This is the interface to the packet driver, a separate program
|
||||
// in DOS, but just an abstraction here.
|
||||
extern doomcom_t doomcom;
|
||||
|
||||
extern struct ticcmd_t localcmds[LOCALCMDTICS];
|
||||
|
||||
extern int maketic;
|
||||
extern int nettics[MAXNETNODES];
|
||||
extern int netdelay[MAXNETNODES][BACKUPTICS];
|
||||
extern int nodeforplayer[MAXPLAYERS];
|
||||
|
||||
extern ticcmd_t netcmds[MAXPLAYERS][BACKUPTICS];
|
||||
extern int ticdup;
|
||||
|
||||
// [RH]
|
||||
// New generic packet structure:
|
||||
//
|
||||
|
@ -182,5 +200,3 @@ extern int ticdup;
|
|||
#define NCMD_2TICS 0x02 // packet contains 2 tics
|
||||
#define NCMD_1TICS 0x01 // packet contains 1 tic
|
||||
#define NCMD_0TICS 0x00 // packet contains 0 tics
|
||||
|
||||
#endif
|
||||
|
|
|
@ -549,8 +549,8 @@ void D_UserInfoChanged (FBaseCVar *cvar)
|
|||
|
||||
mysnprintf (foo, countof(foo), "\\%s\\%s", cvar->GetName(), escaped_val.GetChars());
|
||||
|
||||
Net_WriteByte (DEM_UINFCHANGED);
|
||||
Net_WriteString (foo);
|
||||
network.Net_WriteByte (DEM_UINFCHANGED);
|
||||
network.Net_WriteString (foo);
|
||||
}
|
||||
|
||||
static const char *SetServerVar (char *name, ECVarType type, uint8_t **stream, bool singlebit)
|
||||
|
@ -633,15 +633,15 @@ void D_SendServerInfoChange (const FBaseCVar *cvar, UCVarValue value, ECVarType
|
|||
|
||||
namelen = strlen (cvar->GetName ());
|
||||
|
||||
Net_WriteByte (DEM_SINFCHANGED);
|
||||
Net_WriteByte ((uint8_t)(namelen | (type << 6)));
|
||||
Net_WriteBytes ((uint8_t *)cvar->GetName (), (int)namelen);
|
||||
network.Net_WriteByte (DEM_SINFCHANGED);
|
||||
network.Net_WriteByte ((uint8_t)(namelen | (type << 6)));
|
||||
network.Net_WriteBytes ((uint8_t *)cvar->GetName (), (int)namelen);
|
||||
switch (type)
|
||||
{
|
||||
case CVAR_Bool: Net_WriteByte (value.Bool); break;
|
||||
case CVAR_Int: Net_WriteLong (value.Int); break;
|
||||
case CVAR_Float: Net_WriteFloat (value.Float); break;
|
||||
case CVAR_String: Net_WriteString (value.String); break;
|
||||
case CVAR_Bool: network.Net_WriteByte (value.Bool); break;
|
||||
case CVAR_Int: network.Net_WriteLong (value.Int); break;
|
||||
case CVAR_Float: network.Net_WriteFloat (value.Float); break;
|
||||
case CVAR_String: network.Net_WriteString (value.String); break;
|
||||
default: break; // Silence GCC
|
||||
}
|
||||
}
|
||||
|
@ -652,10 +652,10 @@ void D_SendServerFlagChange (const FBaseCVar *cvar, int bitnum, bool set)
|
|||
|
||||
namelen = (int)strlen (cvar->GetName ());
|
||||
|
||||
Net_WriteByte (DEM_SINFCHANGEDXOR);
|
||||
Net_WriteByte ((uint8_t)namelen);
|
||||
Net_WriteBytes ((uint8_t *)cvar->GetName (), namelen);
|
||||
Net_WriteByte (uint8_t(bitnum | (set << 5)));
|
||||
network.Net_WriteByte (DEM_SINFCHANGEDXOR);
|
||||
network.Net_WriteByte ((uint8_t)namelen);
|
||||
network.Net_WriteBytes ((uint8_t *)cvar->GetName (), namelen);
|
||||
network.Net_WriteByte (uint8_t(bitnum | (set << 5)));
|
||||
}
|
||||
|
||||
void D_DoServerInfoChange (uint8_t **stream, bool singlebit)
|
||||
|
|
|
@ -409,7 +409,6 @@ int SkipTicCmd (uint8_t **stream, int count)
|
|||
}
|
||||
|
||||
#include <assert.h>
|
||||
extern short consistancy[MAXPLAYERS][BACKUPTICS];
|
||||
void ReadTicCmd (uint8_t **stream, int player, int tic)
|
||||
{
|
||||
int type;
|
||||
|
@ -418,7 +417,7 @@ void ReadTicCmd (uint8_t **stream, int player, int tic)
|
|||
|
||||
int ticmod = tic % BACKUPTICS;
|
||||
|
||||
tcmd = &netcmds[player][ticmod];
|
||||
tcmd = &network.netcmds[player][ticmod];
|
||||
tcmd->consistancy = ReadWord (stream);
|
||||
|
||||
start = *stream;
|
||||
|
@ -426,18 +425,18 @@ void ReadTicCmd (uint8_t **stream, int player, int tic)
|
|||
while ((type = ReadByte (stream)) != DEM_USERCMD && type != DEM_EMPTYUSERCMD)
|
||||
Net_SkipCommand (type, stream);
|
||||
|
||||
NetSpecs[player][ticmod].SetData (start, int(*stream - start - 1));
|
||||
network.NetSpecs[player][ticmod].SetData (start, int(*stream - start - 1));
|
||||
|
||||
if (type == DEM_USERCMD)
|
||||
{
|
||||
UnpackUserCmd (&tcmd->ucmd,
|
||||
tic ? &netcmds[player][(tic-1)%BACKUPTICS].ucmd : NULL, stream);
|
||||
tic ? &network.netcmds[player][(tic-1)%BACKUPTICS].ucmd : NULL, stream);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (tic)
|
||||
{
|
||||
memcpy (&tcmd->ucmd, &netcmds[player][(tic-1)%BACKUPTICS].ucmd, sizeof(tcmd->ucmd));
|
||||
memcpy (&tcmd->ucmd, &network.netcmds[player][(tic-1)%BACKUPTICS].ucmd, sizeof(tcmd->ucmd));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -446,7 +445,7 @@ void ReadTicCmd (uint8_t **stream, int player, int tic)
|
|||
}
|
||||
|
||||
if (player==consoleplayer&&tic>BACKUPTICS)
|
||||
assert(consistancy[player][ticmod] == tcmd->consistancy);
|
||||
assert(network.consistancy[player][ticmod] == tcmd->consistancy);
|
||||
}
|
||||
|
||||
void RunNetSpecs (int player, int buf)
|
||||
|
@ -454,9 +453,9 @@ void RunNetSpecs (int player, int buf)
|
|||
uint8_t *stream;
|
||||
int len;
|
||||
|
||||
if (gametic % ticdup == 0)
|
||||
if (gametic % network.ticdup == 0)
|
||||
{
|
||||
stream = NetSpecs[player][buf].GetData (&len);
|
||||
stream = network.NetSpecs[player][buf].GetData (&len);
|
||||
if (stream)
|
||||
{
|
||||
uint8_t *end = stream + len;
|
||||
|
@ -466,7 +465,7 @@ void RunNetSpecs (int player, int buf)
|
|||
Net_DoCommand (type, &stream, player);
|
||||
}
|
||||
if (!demorecording)
|
||||
NetSpecs[player][buf].SetData (NULL, 0);
|
||||
network.NetSpecs[player][buf].SetData (NULL, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -154,13 +154,13 @@ bool E_SendNetworkEvent(FString name, int arg1, int arg2, int arg3, bool manual)
|
|||
if (gamestate != GS_LEVEL)
|
||||
return false;
|
||||
|
||||
Net_WriteByte(DEM_NETEVENT);
|
||||
Net_WriteString(name);
|
||||
Net_WriteByte(3);
|
||||
Net_WriteLong(arg1);
|
||||
Net_WriteLong(arg2);
|
||||
Net_WriteLong(arg3);
|
||||
Net_WriteByte(manual);
|
||||
network.Net_WriteByte(DEM_NETEVENT);
|
||||
network.Net_WriteString(name);
|
||||
network.Net_WriteByte(3);
|
||||
network.Net_WriteLong(arg1);
|
||||
network.Net_WriteLong(arg2);
|
||||
network.Net_WriteLong(arg3);
|
||||
network.Net_WriteByte(manual);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -196,9 +196,6 @@ bool precache = true; // if true, load all graphics at start
|
|||
|
||||
wbstartstruct_t wminfo; // parms for world map / intermission
|
||||
|
||||
short consistancy[MAXPLAYERS][BACKUPTICS];
|
||||
|
||||
|
||||
#define MAXPLMOVE (forwardmove[1])
|
||||
|
||||
#define TURBOTHRESHOLD 12800
|
||||
|
@ -316,12 +313,12 @@ CCMD (slot)
|
|||
|
||||
CCMD (centerview)
|
||||
{
|
||||
Net_WriteByte (DEM_CENTERVIEW);
|
||||
network.Net_WriteByte (DEM_CENTERVIEW);
|
||||
}
|
||||
|
||||
CCMD(crouch)
|
||||
{
|
||||
Net_WriteByte(DEM_CROUCH);
|
||||
network.Net_WriteByte(DEM_CROUCH);
|
||||
}
|
||||
|
||||
CCMD (land)
|
||||
|
@ -577,7 +574,7 @@ void G_BuildTiccmd (ticcmd_t *cmd)
|
|||
base = I_BaseTiccmd (); // empty, or external driver
|
||||
*cmd = *base;
|
||||
|
||||
cmd->consistancy = consistancy[consoleplayer][(maketic/ticdup)%BACKUPTICS];
|
||||
cmd->consistancy = network.consistancy[consoleplayer][(network.maketic/network.ticdup)%BACKUPTICS];
|
||||
|
||||
strafe = Button_Strafe.bDown;
|
||||
speed = Button_Speed.bDown ^ (int)cl_run;
|
||||
|
@ -588,7 +585,7 @@ void G_BuildTiccmd (ticcmd_t *cmd)
|
|||
// and not the joystick, since we treat the joystick as
|
||||
// the analog device it is.
|
||||
if (Button_Left.bDown || Button_Right.bDown)
|
||||
turnheld += ticdup;
|
||||
turnheld += network.ticdup;
|
||||
else
|
||||
turnheld = 0;
|
||||
|
||||
|
@ -754,32 +751,32 @@ void G_BuildTiccmd (ticcmd_t *cmd)
|
|||
if (sendpause)
|
||||
{
|
||||
sendpause = false;
|
||||
Net_WriteByte (DEM_PAUSE);
|
||||
network.Net_WriteByte (DEM_PAUSE);
|
||||
}
|
||||
if (sendsave)
|
||||
{
|
||||
sendsave = false;
|
||||
Net_WriteByte (DEM_SAVEGAME);
|
||||
Net_WriteString (savegamefile);
|
||||
Net_WriteString (savedescription);
|
||||
network.Net_WriteByte (DEM_SAVEGAME);
|
||||
network.Net_WriteString (savegamefile);
|
||||
network.Net_WriteString (savedescription);
|
||||
savegamefile = "";
|
||||
}
|
||||
if (SendItemUse == (const AInventory *)1)
|
||||
{
|
||||
Net_WriteByte (DEM_INVUSEALL);
|
||||
network.Net_WriteByte (DEM_INVUSEALL);
|
||||
SendItemUse = NULL;
|
||||
}
|
||||
else if (SendItemUse != NULL)
|
||||
{
|
||||
Net_WriteByte (DEM_INVUSE);
|
||||
Net_WriteLong (SendItemUse->InventoryID);
|
||||
network.Net_WriteByte (DEM_INVUSE);
|
||||
network.Net_WriteLong (SendItemUse->InventoryID);
|
||||
SendItemUse = NULL;
|
||||
}
|
||||
if (SendItemDrop != NULL)
|
||||
{
|
||||
Net_WriteByte (DEM_INVDROP);
|
||||
Net_WriteLong (SendItemDrop->InventoryID);
|
||||
Net_WriteLong(SendItemDropAmount);
|
||||
network.Net_WriteByte (DEM_INVDROP);
|
||||
network.Net_WriteLong (SendItemDrop->InventoryID);
|
||||
network.Net_WriteLong(SendItemDropAmount);
|
||||
SendItemDrop = NULL;
|
||||
}
|
||||
|
||||
|
@ -883,7 +880,7 @@ static void ChangeSpy (int changespy)
|
|||
// has done this for you, since it could desync otherwise.
|
||||
if (!demoplayback)
|
||||
{
|
||||
Net_WriteByte(DEM_REVERTCAMERA);
|
||||
network.Net_WriteByte(DEM_REVERTCAMERA);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -1153,7 +1150,7 @@ void G_Ticker ()
|
|||
}
|
||||
|
||||
// get commands, check consistancy, and build new consistancy check
|
||||
int buf = (gametic/ticdup)%BACKUPTICS;
|
||||
int buf = (gametic/network.ticdup)%BACKUPTICS;
|
||||
|
||||
// [RH] Include some random seeds and player stuff in the consistancy
|
||||
// check, not just the player's x position like BOOM.
|
||||
|
@ -1167,9 +1164,9 @@ void G_Ticker ()
|
|||
if (playeringame[i])
|
||||
{
|
||||
ticcmd_t *cmd = &players[i].cmd;
|
||||
ticcmd_t *newcmd = &netcmds[i][buf];
|
||||
ticcmd_t *newcmd = &network.netcmds[i][buf];
|
||||
|
||||
if ((gametic % ticdup) == 0)
|
||||
if ((gametic % network.ticdup) == 0)
|
||||
{
|
||||
RunNetSpecs (i, buf);
|
||||
}
|
||||
|
@ -1197,22 +1194,22 @@ void G_Ticker ()
|
|||
Printf ("%s is turbo!\n", players[i].userinfo.GetName());
|
||||
}
|
||||
|
||||
if (netgame && players[i].Bot == NULL && !demoplayback && (gametic%ticdup) == 0)
|
||||
if (netgame && players[i].Bot == NULL && !demoplayback && (gametic%network.ticdup) == 0)
|
||||
{
|
||||
//players[i].inconsistant = 0;
|
||||
if (gametic > BACKUPTICS*ticdup && consistancy[i][buf] != cmd->consistancy)
|
||||
if (gametic > BACKUPTICS*network.ticdup && network.consistancy[i][buf] != cmd->consistancy)
|
||||
{
|
||||
players[i].inconsistant = gametic - BACKUPTICS*ticdup;
|
||||
players[i].inconsistant = gametic - BACKUPTICS*network.ticdup;
|
||||
}
|
||||
if (players[i].mo)
|
||||
{
|
||||
uint32_t sum = rngsum + int((players[i].mo->X() + players[i].mo->Y() + players[i].mo->Z())*257) + players[i].mo->Angles.Yaw.BAMs() + players[i].mo->Angles.Pitch.BAMs();
|
||||
sum ^= players[i].health;
|
||||
consistancy[i][buf] = sum;
|
||||
network.consistancy[i][buf] = sum;
|
||||
}
|
||||
else
|
||||
{
|
||||
consistancy[i][buf] = rngsum;
|
||||
network.consistancy[i][buf] = rngsum;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2472,11 +2469,11 @@ void G_WriteDemoTiccmd (ticcmd_t *cmd, int player, int buf)
|
|||
}
|
||||
|
||||
// [RH] Write any special "ticcmds" for this player to the demo
|
||||
if ((specdata = NetSpecs[player][buf].GetData (&speclen)) && gametic % ticdup == 0)
|
||||
if ((specdata = network.NetSpecs[player][buf].GetData (&speclen)) && gametic % network.ticdup == 0)
|
||||
{
|
||||
memcpy (demo_p, specdata, speclen);
|
||||
demo_p += speclen;
|
||||
NetSpecs[player][buf].SetData (NULL, 0);
|
||||
network.NetSpecs[player][buf].SetData (NULL, 0);
|
||||
}
|
||||
|
||||
// [RH] Now write out a "normal" ticcmd.
|
||||
|
|
|
@ -1110,15 +1110,15 @@ void FWeaponSlots::SendDifferences(int playernum, const FWeaponSlots &other)
|
|||
// The slots differ. Send mine.
|
||||
if (playernum == consoleplayer)
|
||||
{
|
||||
Net_WriteByte(DEM_SETSLOT);
|
||||
network.Net_WriteByte(DEM_SETSLOT);
|
||||
}
|
||||
else
|
||||
{
|
||||
Net_WriteByte(DEM_SETSLOTPNUM);
|
||||
Net_WriteByte(playernum);
|
||||
network.Net_WriteByte(DEM_SETSLOTPNUM);
|
||||
network.Net_WriteByte(playernum);
|
||||
}
|
||||
Net_WriteByte(i);
|
||||
Net_WriteByte(Slots[i].Size());
|
||||
network.Net_WriteByte(i);
|
||||
network.Net_WriteByte(Slots[i].Size());
|
||||
for (j = 0; j < Slots[i].Size(); ++j)
|
||||
{
|
||||
Net_WriteWeapon(Slots[i].GetWeapon(j));
|
||||
|
@ -1248,9 +1248,9 @@ CCMD (setslot)
|
|||
Printf ("Slot %d cleared\n", slot);
|
||||
}
|
||||
|
||||
Net_WriteByte(DEM_SETSLOT);
|
||||
Net_WriteByte(slot);
|
||||
Net_WriteByte(argv.argc()-2);
|
||||
network.Net_WriteByte(DEM_SETSLOT);
|
||||
network.Net_WriteByte(slot);
|
||||
network.Net_WriteByte(argv.argc()-2);
|
||||
for (int i = 2; i < argv.argc(); i++)
|
||||
{
|
||||
Net_WriteWeapon(PClass::FindActor(argv[i]));
|
||||
|
@ -1299,8 +1299,8 @@ CCMD (addslot)
|
|||
}
|
||||
else
|
||||
{
|
||||
Net_WriteByte(DEM_ADDSLOT);
|
||||
Net_WriteByte(slot);
|
||||
network.Net_WriteByte(DEM_ADDSLOT);
|
||||
network.Net_WriteByte(slot);
|
||||
Net_WriteWeapon(type);
|
||||
}
|
||||
}
|
||||
|
@ -1375,8 +1375,8 @@ CCMD (addslotdefault)
|
|||
}
|
||||
else
|
||||
{
|
||||
Net_WriteByte(DEM_ADDSLOTDEFAULT);
|
||||
Net_WriteByte(slot);
|
||||
network.Net_WriteByte(DEM_ADDSLOTDEFAULT);
|
||||
network.Net_WriteByte(slot);
|
||||
Net_WriteWeapon(type);
|
||||
}
|
||||
}
|
||||
|
@ -1541,12 +1541,12 @@ void Net_WriteWeapon(PClassActor *type)
|
|||
assert(index >= 0 && index <= 32767);
|
||||
if (index < 128)
|
||||
{
|
||||
Net_WriteByte(index);
|
||||
network.Net_WriteByte(index);
|
||||
}
|
||||
else
|
||||
{
|
||||
Net_WriteByte(0x80 | index);
|
||||
Net_WriteByte(index >> 7);
|
||||
network.Net_WriteByte(0x80 | index);
|
||||
network.Net_WriteByte(index >> 7);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -890,7 +890,7 @@ IMPLEMENT_CLASS(DAutosaver, false, false)
|
|||
|
||||
void DAutosaver::Tick ()
|
||||
{
|
||||
Net_WriteByte (DEM_CHECKAUTOSAVE);
|
||||
network.Net_WriteByte (DEM_CHECKAUTOSAVE);
|
||||
Destroy ();
|
||||
}
|
||||
|
||||
|
|
|
@ -700,8 +700,8 @@ CCMD (spray)
|
|||
return;
|
||||
}
|
||||
|
||||
Net_WriteByte (DEM_SPRAY);
|
||||
Net_WriteString (argv[1]);
|
||||
network.Net_WriteByte (DEM_SPRAY);
|
||||
network.Net_WriteString (argv[1]);
|
||||
}
|
||||
|
||||
void SprayDecal(AActor *shooter, const char *name, double distance)
|
||||
|
|
|
@ -1054,10 +1054,10 @@ static void DrawLatency()
|
|||
return;
|
||||
}
|
||||
int i, localdelay = 0, arbitratordelay = 0;
|
||||
for (i = 0; i < BACKUPTICS; i++) localdelay += netdelay[0][i];
|
||||
for (i = 0; i < BACKUPTICS; i++) arbitratordelay += netdelay[nodeforplayer[Net_Arbitrator]][i];
|
||||
localdelay = ((localdelay / BACKUPTICS) * ticdup) * (1000 / TICRATE);
|
||||
arbitratordelay = ((arbitratordelay / BACKUPTICS) * ticdup) * (1000 / TICRATE);
|
||||
for (i = 0; i < BACKUPTICS; i++) localdelay += network.netdelay[0][i];
|
||||
for (i = 0; i < BACKUPTICS; i++) arbitratordelay += network.netdelay[network.nodeforplayer[Net_Arbitrator]][i];
|
||||
localdelay = ((localdelay / BACKUPTICS) * network.ticdup) * (1000 / TICRATE);
|
||||
arbitratordelay = ((arbitratordelay / BACKUPTICS) * network.ticdup) * (1000 / TICRATE);
|
||||
int color = CR_GREEN;
|
||||
if (MAX(localdelay, arbitratordelay) > 200)
|
||||
{
|
||||
|
@ -1067,7 +1067,7 @@ static void DrawLatency()
|
|||
{
|
||||
color = CR_ORANGE;
|
||||
}
|
||||
if (MAX(localdelay, arbitratordelay) >= ((BACKUPTICS / 2 - 1) * ticdup) * (1000 / TICRATE))
|
||||
if (MAX(localdelay, arbitratordelay) >= ((BACKUPTICS / 2 - 1) * network.ticdup) * (1000 / TICRATE))
|
||||
{
|
||||
color = CR_RED;
|
||||
}
|
||||
|
|
|
@ -1255,7 +1255,7 @@ void DBaseStatusBar::DrawConsistancy () const
|
|||
{
|
||||
fprintf (debugfile, "%s as of tic %d (%d)\n", conbuff,
|
||||
players[1-consoleplayer].inconsistant,
|
||||
players[1-consoleplayer].inconsistant/ticdup);
|
||||
players[1-consoleplayer].inconsistant/network.ticdup);
|
||||
}
|
||||
}
|
||||
screen->DrawText (SmallFont, CR_GREEN,
|
||||
|
|
|
@ -437,11 +437,11 @@ static void HU_DrawPlayer (player_t *player, bool highlight, int col1, int col2,
|
|||
int avgdelay = 0;
|
||||
for (int i = 0; i < BACKUPTICS; i++)
|
||||
{
|
||||
avgdelay += netdelay[nodeforplayer[(int)(player - players)]][i];
|
||||
avgdelay += network.netdelay[network.nodeforplayer[(int)(player - players)]][i];
|
||||
}
|
||||
avgdelay /= BACKUPTICS;
|
||||
|
||||
mysnprintf(str, countof(str), "%d", (avgdelay * ticdup) * (1000 / TICRATE));
|
||||
mysnprintf(str, countof(str), "%d", (avgdelay * network.ticdup) * (1000 / TICRATE));
|
||||
|
||||
screen->DrawText(SmallFont, color, col5, y + ypadding, str,
|
||||
DTA_CleanNoMove, true, TAG_DONE);
|
||||
|
|
327
src/i_net.cpp
327
src/i_net.cpp
|
@ -95,15 +95,6 @@ typedef int SOCKET;
|
|||
typedef int socklen_t;
|
||||
#endif
|
||||
|
||||
//
|
||||
// NETWORKING
|
||||
//
|
||||
|
||||
static u_short DOOMPORT = (IPPORT_USERRESERVED + 29);
|
||||
static SOCKET mysocket = INVALID_SOCKET;
|
||||
static sockaddr_in sendaddress[MAXNETNODES];
|
||||
static uint8_t sendplayer[MAXNETNODES];
|
||||
|
||||
#ifdef __WIN32__
|
||||
const char *neterror (void);
|
||||
#else
|
||||
|
@ -145,12 +136,50 @@ struct PreGamePacket
|
|||
} machines[MAXNETNODES];
|
||||
};
|
||||
|
||||
uint8_t TransmitBuffer[TRANSMIT_SIZE];
|
||||
class DoomComImpl : public doomcom_t
|
||||
{
|
||||
public:
|
||||
DoomComImpl();
|
||||
~DoomComImpl() { CloseNetwork(); }
|
||||
|
||||
//
|
||||
// UDPsocket
|
||||
//
|
||||
SOCKET UDPsocket (void)
|
||||
void PacketSend(const NetPacket &packet) override;
|
||||
void PacketGet(NetPacket &packet) override;
|
||||
|
||||
private:
|
||||
u_short DOOMPORT = (IPPORT_USERRESERVED + 29);
|
||||
SOCKET mysocket = INVALID_SOCKET;
|
||||
sockaddr_in sendaddress[MAXNETNODES];
|
||||
uint8_t sendplayer[MAXNETNODES];
|
||||
|
||||
uint8_t TransmitBuffer[TRANSMIT_SIZE];
|
||||
|
||||
SOCKET UDPsocket();
|
||||
void BindToLocalPort(SOCKET s, u_short port);
|
||||
int FindNode(const sockaddr_in *address);
|
||||
sockaddr_in *PreGet(void *buffer, int bufferlen, bool noabort);
|
||||
void PreSend(const void *buffer, int bufferlen, const sockaddr_in *to);
|
||||
void BuildAddress(sockaddr_in *address, const char *name);
|
||||
void CloseNetwork();
|
||||
void StartNetwork(bool autoPort);
|
||||
void SendAbort();
|
||||
void SendConAck(int num_connected, int num_needed);
|
||||
bool Host_CheckForConnects();
|
||||
bool Host_SendAllHere(int *gotack);
|
||||
void HostGame(int i);
|
||||
bool Guest_ContactHost();
|
||||
bool Guest_WaitForOthers();
|
||||
void JoinGame(int i);
|
||||
|
||||
static int PrivateNetOf(in_addr in);
|
||||
bool NodesOnSameNetwork();
|
||||
};
|
||||
|
||||
std::unique_ptr<doomcom_t> I_InitNetwork()
|
||||
{
|
||||
return std::unique_ptr<doomcom_t>(new DoomComImpl());
|
||||
}
|
||||
|
||||
SOCKET DoomComImpl::UDPsocket()
|
||||
{
|
||||
SOCKET s;
|
||||
|
||||
|
@ -162,10 +191,7 @@ SOCKET UDPsocket (void)
|
|||
return s;
|
||||
}
|
||||
|
||||
//
|
||||
// BindToLocalPort
|
||||
//
|
||||
void BindToLocalPort (SOCKET s, u_short port)
|
||||
void DoomComImpl::BindToLocalPort(SOCKET s, u_short port)
|
||||
{
|
||||
int v;
|
||||
sockaddr_in address;
|
||||
|
@ -180,17 +206,17 @@ void BindToLocalPort (SOCKET s, u_short port)
|
|||
I_FatalError ("BindToPort: %s", neterror ());
|
||||
}
|
||||
|
||||
int FindNode (const sockaddr_in *address)
|
||||
int DoomComImpl::FindNode(const sockaddr_in *address)
|
||||
{
|
||||
int i;
|
||||
|
||||
// find remote node number
|
||||
for (i = 0; i<doomcom.numnodes; i++)
|
||||
for (i = 0; i<numnodes; i++)
|
||||
if (address->sin_addr.s_addr == sendaddress[i].sin_addr.s_addr
|
||||
&& address->sin_port == sendaddress[i].sin_port)
|
||||
break;
|
||||
|
||||
if (i == doomcom.numnodes)
|
||||
if (i == numnodes)
|
||||
{
|
||||
// packet is not from one of the players (new game broadcast?)
|
||||
i = -1;
|
||||
|
@ -198,63 +224,52 @@ int FindNode (const sockaddr_in *address)
|
|||
return i;
|
||||
}
|
||||
|
||||
//
|
||||
// PacketSend
|
||||
//
|
||||
void PacketSend (void)
|
||||
void DoomComImpl::PacketSend(const NetPacket &packet)
|
||||
{
|
||||
int c;
|
||||
|
||||
// FIXME: Catch this before we've overflown the buffer. With long chat
|
||||
// text and lots of backup tics, it could conceivably happen. (Though
|
||||
// apparently it hasn't yet, which is good.)
|
||||
if (doomcom.datalength > MAX_MSGLEN)
|
||||
if (packet.datalength > MAX_MSGLEN)
|
||||
{
|
||||
I_FatalError("Netbuffer overflow!");
|
||||
}
|
||||
assert(!(doomcom.data[0] & NCMD_COMPRESSED));
|
||||
assert(!(packet.data[0] & NCMD_COMPRESSED));
|
||||
|
||||
uLong size = TRANSMIT_SIZE - 1;
|
||||
if (doomcom.datalength >= 10)
|
||||
if (packet.datalength >= 10)
|
||||
{
|
||||
TransmitBuffer[0] = doomcom.data[0] | NCMD_COMPRESSED;
|
||||
c = compress2(TransmitBuffer + 1, &size, doomcom.data + 1, doomcom.datalength - 1, 9);
|
||||
TransmitBuffer[0] = packet.data[0] | NCMD_COMPRESSED;
|
||||
c = compress2(TransmitBuffer + 1, &size, packet.data + 1, packet.datalength - 1, 9);
|
||||
size += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
c = -1; // Just some random error code to avoid sending the compressed buffer.
|
||||
}
|
||||
if (c == Z_OK && size < (uLong)doomcom.datalength)
|
||||
if (c == Z_OK && size < (uLong)packet.datalength)
|
||||
{
|
||||
// Printf("send %lu/%d\n", size, doomcom.datalength);
|
||||
c = sendto(mysocket, (char *)TransmitBuffer, size,
|
||||
0, (sockaddr *)&sendaddress[doomcom.remotenode],
|
||||
sizeof(sendaddress[doomcom.remotenode]));
|
||||
// Printf("send %lu/%d\n", size, datalength);
|
||||
c = sendto(mysocket, (char *)TransmitBuffer, size, 0, (sockaddr *)&sendaddress[packet.remotenode], sizeof(sendaddress[packet.remotenode]));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (doomcom.datalength > TRANSMIT_SIZE)
|
||||
if (packet.datalength > TRANSMIT_SIZE)
|
||||
{
|
||||
I_Error("Net compression failed (zlib error %d)", c);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Printf("send %d\n", doomcom.datalength);
|
||||
c = sendto(mysocket, (char *)doomcom.data, doomcom.datalength,
|
||||
0, (sockaddr *)&sendaddress[doomcom.remotenode],
|
||||
sizeof(sendaddress[doomcom.remotenode]));
|
||||
// Printf("send %d\n", datalength);
|
||||
c = sendto(mysocket, (char *)packet.data, packet.datalength, 0, (sockaddr *)&sendaddress[packet.remotenode], sizeof(sendaddress[packet.remotenode]));
|
||||
}
|
||||
}
|
||||
// if (c == -1)
|
||||
// I_Error ("SendPacket error: %s",strerror(errno));
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// PacketGet
|
||||
//
|
||||
void PacketGet (void)
|
||||
void DoomComImpl::PacketGet(NetPacket &packet)
|
||||
{
|
||||
int c;
|
||||
socklen_t fromlen;
|
||||
|
@ -262,8 +277,7 @@ void PacketGet (void)
|
|||
int node;
|
||||
|
||||
fromlen = sizeof(fromaddress);
|
||||
c = recvfrom (mysocket, (char*)TransmitBuffer, TRANSMIT_SIZE, 0,
|
||||
(sockaddr *)&fromaddress, &fromlen);
|
||||
c = recvfrom (mysocket, (char*)TransmitBuffer, TRANSMIT_SIZE, 0, (sockaddr *)&fromaddress, &fromlen);
|
||||
node = FindNode (&fromaddress);
|
||||
|
||||
if (node >= 0 && c == SOCKET_ERROR)
|
||||
|
@ -284,7 +298,7 @@ void PacketGet (void)
|
|||
players[sendplayer[node]].userinfo.GetName());
|
||||
}
|
||||
|
||||
doomcom.data[0] = 0x80; // NCMD_EXIT
|
||||
packet.data[0] = 0x80; // NCMD_EXIT
|
||||
c = 1;
|
||||
}
|
||||
else if (err != WSAEWOULDBLOCK)
|
||||
|
@ -293,23 +307,23 @@ void PacketGet (void)
|
|||
}
|
||||
else
|
||||
{
|
||||
doomcom.remotenode = -1; // no packet
|
||||
packet.remotenode = -1; // no packet
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (node >= 0 && c > 0)
|
||||
{
|
||||
doomcom.data[0] = TransmitBuffer[0] & ~NCMD_COMPRESSED;
|
||||
packet.data[0] = TransmitBuffer[0] & ~NCMD_COMPRESSED;
|
||||
if (TransmitBuffer[0] & NCMD_COMPRESSED)
|
||||
{
|
||||
uLongf msgsize = MAX_MSGLEN - 1;
|
||||
int err = uncompress(doomcom.data + 1, &msgsize, TransmitBuffer + 1, c - 1);
|
||||
int err = uncompress(packet.data + 1, &msgsize, TransmitBuffer + 1, c - 1);
|
||||
// Printf("recv %d/%lu\n", c, msgsize + 1);
|
||||
if (err != Z_OK)
|
||||
{
|
||||
Printf("Net decompression failed (zlib error %s)\n", M_ZLibError(err).GetChars());
|
||||
// Pretend no packet
|
||||
doomcom.remotenode = -1;
|
||||
packet.remotenode = -1;
|
||||
return;
|
||||
}
|
||||
c = msgsize + 1;
|
||||
|
@ -317,7 +331,7 @@ void PacketGet (void)
|
|||
else
|
||||
{
|
||||
// Printf("recv %d\n", c);
|
||||
memcpy(doomcom.data + 1, TransmitBuffer + 1, c - 1);
|
||||
memcpy(packet.data + 1, TransmitBuffer + 1, c - 1);
|
||||
}
|
||||
}
|
||||
else if (c > 0)
|
||||
|
@ -327,23 +341,22 @@ void PacketGet (void)
|
|||
{
|
||||
DPrintf(DMSG_WARNING, "Dropped packet: Unknown host (%s:%d)\n", inet_ntoa(fromaddress.sin_addr), fromaddress.sin_port);
|
||||
}
|
||||
doomcom.remotenode = -1;
|
||||
packet.remotenode = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
doomcom.remotenode = node;
|
||||
doomcom.datalength = (short)c;
|
||||
packet.remotenode = node;
|
||||
packet.datalength = (short)c;
|
||||
}
|
||||
|
||||
sockaddr_in *PreGet (void *buffer, int bufferlen, bool noabort)
|
||||
sockaddr_in *DoomComImpl::PreGet(void *buffer, int bufferlen, bool noabort)
|
||||
{
|
||||
static sockaddr_in fromaddress;
|
||||
socklen_t fromlen;
|
||||
int c;
|
||||
|
||||
fromlen = sizeof(fromaddress);
|
||||
c = recvfrom (mysocket, (char *)buffer, bufferlen, 0,
|
||||
(sockaddr *)&fromaddress, &fromlen);
|
||||
c = recvfrom (mysocket, (char *)buffer, bufferlen, 0, (sockaddr *)&fromaddress, &fromlen);
|
||||
|
||||
if (c == SOCKET_ERROR)
|
||||
{
|
||||
|
@ -355,12 +368,12 @@ sockaddr_in *PreGet (void *buffer, int bufferlen, bool noabort)
|
|||
return &fromaddress;
|
||||
}
|
||||
|
||||
void PreSend (const void *buffer, int bufferlen, const sockaddr_in *to)
|
||||
void DoomComImpl::PreSend(const void *buffer, int bufferlen, const sockaddr_in *to)
|
||||
{
|
||||
sendto (mysocket, (const char *)buffer, bufferlen, 0, (const sockaddr *)to, sizeof(*to));
|
||||
}
|
||||
|
||||
void BuildAddress (sockaddr_in *address, const char *name)
|
||||
void DoomComImpl::BuildAddress(sockaddr_in *address, const char *name)
|
||||
{
|
||||
hostent *hostentry; // host information entry
|
||||
u_short port;
|
||||
|
@ -401,7 +414,7 @@ void BuildAddress (sockaddr_in *address, const char *name)
|
|||
if (!isnamed)
|
||||
{
|
||||
address->sin_addr.s_addr = inet_addr (target);
|
||||
Printf ("Node number %d, address %s\n", doomcom.numnodes, target.GetChars());
|
||||
Printf ("Node number %d, address %s\n", numnodes, target.GetChars());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -409,12 +422,11 @@ void BuildAddress (sockaddr_in *address, const char *name)
|
|||
if (!hostentry)
|
||||
I_FatalError ("gethostbyname: couldn't find %s\n%s", target.GetChars(), neterror());
|
||||
address->sin_addr.s_addr = *(int *)hostentry->h_addr_list[0];
|
||||
Printf ("Node number %d, hostname %s\n",
|
||||
doomcom.numnodes, hostentry->h_name);
|
||||
Printf ("Node number %d, hostname %s\n", numnodes, hostentry->h_name);
|
||||
}
|
||||
}
|
||||
|
||||
void CloseNetwork (void)
|
||||
void DoomComImpl::CloseNetwork()
|
||||
{
|
||||
if (mysocket != INVALID_SOCKET)
|
||||
{
|
||||
|
@ -426,7 +438,7 @@ void CloseNetwork (void)
|
|||
#endif
|
||||
}
|
||||
|
||||
void StartNetwork (bool autoPort)
|
||||
void DoomComImpl::StartNetwork(bool autoPort)
|
||||
{
|
||||
u_long trueval = 1;
|
||||
#ifdef __WIN32__
|
||||
|
@ -438,8 +450,6 @@ void StartNetwork (bool autoPort)
|
|||
}
|
||||
#endif
|
||||
|
||||
atterm (CloseNetwork);
|
||||
|
||||
netgame = true;
|
||||
multiplayer = true;
|
||||
|
||||
|
@ -453,17 +463,17 @@ void StartNetwork (bool autoPort)
|
|||
#endif
|
||||
}
|
||||
|
||||
void SendAbort (void)
|
||||
void DoomComImpl::SendAbort()
|
||||
{
|
||||
uint8_t dis[2] = { PRE_FAKE, PRE_DISCONNECT };
|
||||
int i, j;
|
||||
|
||||
if (doomcom.numnodes > 1)
|
||||
if (numnodes > 1)
|
||||
{
|
||||
if (consoleplayer == 0)
|
||||
{
|
||||
// The host needs to let everyone know
|
||||
for (i = 1; i < doomcom.numnodes; ++i)
|
||||
for (i = 1; i < numnodes; ++i)
|
||||
{
|
||||
for (j = 4; j > 0; --j)
|
||||
{
|
||||
|
@ -482,7 +492,7 @@ void SendAbort (void)
|
|||
}
|
||||
}
|
||||
|
||||
static void SendConAck (int num_connected, int num_needed)
|
||||
void DoomComImpl::SendConAck (int num_connected, int num_needed)
|
||||
{
|
||||
PreGamePacket packet;
|
||||
|
||||
|
@ -490,17 +500,16 @@ static void SendConAck (int num_connected, int num_needed)
|
|||
packet.Message = PRE_CONACK;
|
||||
packet.NumNodes = num_needed;
|
||||
packet.NumPresent = num_connected;
|
||||
for (int node = 1; node < doomcom.numnodes; ++node)
|
||||
for (int node = 1; node < numnodes; ++node)
|
||||
{
|
||||
PreSend (&packet, 4, &sendaddress[node]);
|
||||
}
|
||||
StartScreen->NetProgress (doomcom.numnodes);
|
||||
StartScreen->NetProgress (numnodes);
|
||||
}
|
||||
|
||||
bool Host_CheckForConnects (void *userdata)
|
||||
bool DoomComImpl::Host_CheckForConnects()
|
||||
{
|
||||
PreGamePacket packet;
|
||||
int numplayers = (int)(intptr_t)userdata;
|
||||
sockaddr_in *from;
|
||||
int node;
|
||||
|
||||
|
@ -514,7 +523,7 @@ bool Host_CheckForConnects (void *userdata)
|
|||
{
|
||||
case PRE_CONNECT:
|
||||
node = FindNode (from);
|
||||
if (doomcom.numnodes == numplayers)
|
||||
if (numnodes == numplayers)
|
||||
{
|
||||
if (node == -1)
|
||||
{
|
||||
|
@ -530,13 +539,13 @@ bool Host_CheckForConnects (void *userdata)
|
|||
{
|
||||
if (node == -1)
|
||||
{
|
||||
node = doomcom.numnodes++;
|
||||
node = numnodes++;
|
||||
sendaddress[node] = *from;
|
||||
StartScreen->NetMessage ("Got connect from node %d.", node);
|
||||
}
|
||||
|
||||
// Let the new guest (and everyone else) know we got their message.
|
||||
SendConAck (doomcom.numnodes, numplayers);
|
||||
SendConAck (numnodes, numplayers);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -545,15 +554,15 @@ bool Host_CheckForConnects (void *userdata)
|
|||
if (node >= 0)
|
||||
{
|
||||
StartScreen->NetMessage ("Got disconnect from node %d.", node);
|
||||
doomcom.numnodes--;
|
||||
while (node < doomcom.numnodes)
|
||||
numnodes--;
|
||||
while (node < numnodes)
|
||||
{
|
||||
sendaddress[node] = sendaddress[node+1];
|
||||
node++;
|
||||
}
|
||||
|
||||
// Let remaining guests know that somebody left.
|
||||
SendConAck (doomcom.numnodes, numplayers);
|
||||
SendConAck (numnodes, numplayers);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -561,10 +570,10 @@ bool Host_CheckForConnects (void *userdata)
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (doomcom.numnodes < numplayers)
|
||||
if (numnodes < numplayers)
|
||||
{
|
||||
// Send message to everyone as a keepalive
|
||||
SendConAck(doomcom.numnodes, numplayers);
|
||||
SendConAck(numnodes, numplayers);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -578,24 +587,23 @@ bool Host_CheckForConnects (void *userdata)
|
|||
node = FindNode (from);
|
||||
if (node >= 0)
|
||||
{
|
||||
doomcom.numnodes--;
|
||||
while (node < doomcom.numnodes)
|
||||
numnodes--;
|
||||
while (node < numnodes)
|
||||
{
|
||||
sendaddress[node] = sendaddress[node+1];
|
||||
node++;
|
||||
}
|
||||
// Let remaining guests know that somebody left.
|
||||
SendConAck (doomcom.numnodes, numplayers);
|
||||
SendConAck (numnodes, numplayers);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return doomcom.numnodes >= numplayers;
|
||||
return numnodes >= numplayers;
|
||||
}
|
||||
|
||||
bool Host_SendAllHere (void *userdata)
|
||||
bool DoomComImpl::Host_SendAllHere(int *gotack)
|
||||
{
|
||||
int *gotack = (int *)userdata; // ackcount is at gotack[MAXNETNODES]
|
||||
PreGamePacket packet;
|
||||
int node;
|
||||
sockaddr_in *from;
|
||||
|
@ -604,14 +612,14 @@ bool Host_SendAllHere (void *userdata)
|
|||
// acknowledged receipt effectively get just a heartbeat packet.
|
||||
packet.Fake = PRE_FAKE;
|
||||
packet.Message = PRE_ALLHERE;
|
||||
for (node = 1; node < doomcom.numnodes; node++)
|
||||
for (node = 1; node < numnodes; node++)
|
||||
{
|
||||
int machine, spot = 0;
|
||||
|
||||
packet.ConsoleNum = node;
|
||||
if (!gotack[node])
|
||||
{
|
||||
for (spot = 0, machine = 1; machine < doomcom.numnodes; machine++)
|
||||
for (spot = 0, machine = 1; machine < numnodes; machine++)
|
||||
{
|
||||
if (node != machine)
|
||||
{
|
||||
|
@ -624,7 +632,7 @@ bool Host_SendAllHere (void *userdata)
|
|||
// and storing in the packet the next address.
|
||||
}
|
||||
}
|
||||
packet.NumNodes = doomcom.numnodes - 2;
|
||||
packet.NumNodes = numnodes - 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -652,13 +660,12 @@ bool Host_SendAllHere (void *userdata)
|
|||
}
|
||||
|
||||
// If everybody has replied, then this loop can end.
|
||||
return gotack[MAXNETNODES] == doomcom.numnodes - 1;
|
||||
return gotack[MAXNETNODES] == numnodes - 1;
|
||||
}
|
||||
|
||||
void HostGame (int i)
|
||||
void DoomComImpl::HostGame(int i)
|
||||
{
|
||||
PreGamePacket packet;
|
||||
int numplayers;
|
||||
int node;
|
||||
int gotack[MAXNETNODES+1];
|
||||
|
||||
|
@ -677,9 +684,8 @@ void HostGame (int i)
|
|||
{ // Special case: Only 1 player, so don't bother starting the network
|
||||
netgame = false;
|
||||
multiplayer = true;
|
||||
doomcom.id = DOOMCOM_ID;
|
||||
doomcom.numplayers = doomcom.numnodes = 1;
|
||||
doomcom.consoleplayer = 0;
|
||||
numnodes = 1;
|
||||
consoleplayer = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -687,18 +693,17 @@ void HostGame (int i)
|
|||
|
||||
// [JC] - this computer is starting the game, therefore it should
|
||||
// be the Net Arbitrator.
|
||||
doomcom.consoleplayer = 0;
|
||||
Printf ("Console player number: %d\n", doomcom.consoleplayer);
|
||||
consoleplayer = 0;
|
||||
Printf ("Console player number: %d\n", consoleplayer);
|
||||
|
||||
doomcom.numnodes = 1;
|
||||
|
||||
atterm (SendAbort);
|
||||
numnodes = 1;
|
||||
|
||||
StartScreen->NetInit ("Waiting for players", numplayers);
|
||||
|
||||
// Wait for numplayers-1 different connections
|
||||
if (!StartScreen->NetLoop (Host_CheckForConnects, (void *)(intptr_t)numplayers))
|
||||
if (!StartScreen->NetLoop([&] { return Host_CheckForConnects(); }))
|
||||
{
|
||||
SendAbort();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
|
@ -707,18 +712,17 @@ void HostGame (int i)
|
|||
StartScreen->NetMessage ("Sending all here.");
|
||||
StartScreen->NetInit ("Done waiting", 1);
|
||||
|
||||
if (!StartScreen->NetLoop (Host_SendAllHere, (void *)gotack))
|
||||
if (!StartScreen->NetLoop([&] { return Host_SendAllHere(gotack); }))
|
||||
{
|
||||
SendAbort();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
popterm ();
|
||||
|
||||
// Now go
|
||||
StartScreen->NetMessage ("Go");
|
||||
packet.Fake = PRE_FAKE;
|
||||
packet.Message = PRE_GO;
|
||||
for (node = 1; node < doomcom.numnodes; node++)
|
||||
for (node = 1; node < numnodes; node++)
|
||||
{
|
||||
// If we send the packets eight times to each guest,
|
||||
// hopefully at least one of them will get through.
|
||||
|
@ -728,13 +732,12 @@ void HostGame (int i)
|
|||
}
|
||||
}
|
||||
|
||||
StartScreen->NetMessage ("Total players: %d", doomcom.numnodes);
|
||||
StartScreen->NetMessage ("Total players: %d", numnodes);
|
||||
|
||||
doomcom.id = DOOMCOM_ID;
|
||||
doomcom.numplayers = doomcom.numnodes;
|
||||
numplayers = numnodes;
|
||||
|
||||
// On the host, each player's number is the same as its node number
|
||||
for (i = 0; i < doomcom.numnodes; ++i)
|
||||
for (i = 0; i < numnodes; ++i)
|
||||
{
|
||||
sendplayer[i] = i;
|
||||
}
|
||||
|
@ -744,7 +747,7 @@ void HostGame (int i)
|
|||
// Once that host acknowledges receipt of the notification, this routine
|
||||
// is never called again.
|
||||
|
||||
bool Guest_ContactHost (void *userdata)
|
||||
bool DoomComImpl::Guest_ContactHost()
|
||||
{
|
||||
sockaddr_in *from;
|
||||
PreGamePacket packet;
|
||||
|
@ -768,12 +771,12 @@ bool Guest_ContactHost (void *userdata)
|
|||
}
|
||||
else if (packet.Message == PRE_DISCONNECT)
|
||||
{
|
||||
doomcom.numnodes = 0;
|
||||
numnodes = 0;
|
||||
I_FatalError ("The host cancelled the game.");
|
||||
}
|
||||
else if (packet.Message == PRE_ALLFULL)
|
||||
{
|
||||
doomcom.numnodes = 0;
|
||||
numnodes = 0;
|
||||
I_FatalError ("The game is full.");
|
||||
}
|
||||
}
|
||||
|
@ -785,7 +788,7 @@ bool Guest_ContactHost (void *userdata)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool Guest_WaitForOthers (void *userdata)
|
||||
bool DoomComImpl::Guest_WaitForOthers()
|
||||
{
|
||||
sockaddr_in *from;
|
||||
PreGamePacket packet;
|
||||
|
@ -803,14 +806,14 @@ bool Guest_WaitForOthers (void *userdata)
|
|||
break;
|
||||
|
||||
case PRE_ALLHERE:
|
||||
if (doomcom.numnodes == 2)
|
||||
if (numnodes == 2)
|
||||
{
|
||||
int node;
|
||||
|
||||
doomcom.numnodes = packet.NumNodes + 2;
|
||||
numnodes = packet.NumNodes + 2;
|
||||
sendplayer[0] = packet.ConsoleNum; // My player number
|
||||
doomcom.consoleplayer = packet.ConsoleNum;
|
||||
StartScreen->NetMessage ("Console player number: %d", doomcom.consoleplayer);
|
||||
consoleplayer = packet.ConsoleNum;
|
||||
StartScreen->NetMessage ("Console player number: %d", consoleplayer);
|
||||
for (node = 0; node < packet.NumNodes; node++)
|
||||
{
|
||||
sendaddress[node+2].sin_addr.s_addr = packet.machines[node].address;
|
||||
|
@ -847,7 +850,7 @@ bool Guest_WaitForOthers (void *userdata)
|
|||
return false;
|
||||
}
|
||||
|
||||
void JoinGame (int i)
|
||||
void DoomComImpl::JoinGame(int i)
|
||||
{
|
||||
if ((i == Args->NumArgs() - 1) ||
|
||||
(Args->GetArg(i+1)[0] == '-') ||
|
||||
|
@ -859,36 +862,33 @@ void JoinGame (int i)
|
|||
// Host is always node 1
|
||||
BuildAddress (&sendaddress[1], Args->GetArg(i+1));
|
||||
sendplayer[1] = 0;
|
||||
doomcom.numnodes = 2;
|
||||
|
||||
atterm (SendAbort);
|
||||
numnodes = 2;
|
||||
|
||||
// Let host know we are here
|
||||
StartScreen->NetInit ("Contacting host", 0);
|
||||
|
||||
if (!StartScreen->NetLoop (Guest_ContactHost, NULL))
|
||||
if (!StartScreen->NetLoop([&] { return Guest_ContactHost(); }))
|
||||
{
|
||||
SendAbort();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
// Wait for everyone else to connect
|
||||
if (!StartScreen->NetLoop (Guest_WaitForOthers, 0))
|
||||
if (!StartScreen->NetLoop([&] { return Guest_WaitForOthers(); }))
|
||||
{
|
||||
SendAbort();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
popterm ();
|
||||
StartScreen->NetMessage ("Total players: %d", numnodes);
|
||||
|
||||
StartScreen->NetMessage ("Total players: %d", doomcom.numnodes);
|
||||
|
||||
doomcom.id = DOOMCOM_ID;
|
||||
doomcom.numplayers = doomcom.numnodes;
|
||||
numplayers = numnodes;
|
||||
}
|
||||
|
||||
static int PrivateNetOf(in_addr in)
|
||||
int DoomComImpl::PrivateNetOf(in_addr in)
|
||||
{
|
||||
int addr = ntohl(in.s_addr);
|
||||
if ((addr & 0xFFFF0000) == 0xC0A80000) // 192.168.0.0
|
||||
if ((addr & 0xFFFF0000) == 0xC0A80000) // 192.168.0.0
|
||||
{
|
||||
return 0xC0A80000;
|
||||
}
|
||||
|
@ -908,14 +908,8 @@ static int PrivateNetOf(in_addr in)
|
|||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// NodesOnSameNetwork
|
||||
//
|
||||
// The best I can really do here is check if the others are on the same
|
||||
// private network, since that means we (probably) are too.
|
||||
//
|
||||
|
||||
static bool NodesOnSameNetwork()
|
||||
// The best I can really do here is check if the others are on the same private network, since that means we (probably) are too.
|
||||
bool DoomComImpl::NodesOnSameNetwork()
|
||||
{
|
||||
int net1;
|
||||
|
||||
|
@ -925,7 +919,7 @@ static bool NodesOnSameNetwork()
|
|||
{
|
||||
return false;
|
||||
}
|
||||
for (int i = 2; i < doomcom.numnodes; ++i)
|
||||
for (int i = 2; i < numnodes; ++i)
|
||||
{
|
||||
int net = PrivateNetOf(sendaddress[i].sin_addr);
|
||||
// Printf("Net[%d] = %08x\n", i, net);
|
||||
|
@ -937,29 +931,11 @@ static bool NodesOnSameNetwork()
|
|||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
// I_InitNetwork
|
||||
//
|
||||
// Returns true if packet server mode might be a good idea.
|
||||
//
|
||||
bool I_InitNetwork (void)
|
||||
DoomComImpl::DoomComImpl()
|
||||
{
|
||||
int i;
|
||||
const char *v;
|
||||
|
||||
memset (&doomcom, 0, sizeof(doomcom));
|
||||
|
||||
// set up for network
|
||||
v = Args->CheckValue ("-dup");
|
||||
if (v)
|
||||
{
|
||||
doomcom.ticdup = clamp (atoi (v), 1, MAXTICDUP);
|
||||
}
|
||||
else
|
||||
{
|
||||
doomcom.ticdup = 1;
|
||||
}
|
||||
|
||||
v = Args->CheckValue ("-port");
|
||||
if (v)
|
||||
{
|
||||
|
@ -983,32 +959,9 @@ bool I_InitNetwork (void)
|
|||
// single player game
|
||||
netgame = false;
|
||||
multiplayer = false;
|
||||
doomcom.id = DOOMCOM_ID;
|
||||
doomcom.numplayers = doomcom.numnodes = 1;
|
||||
doomcom.consoleplayer = 0;
|
||||
return false;
|
||||
numplayers = numnodes = 1;
|
||||
consoleplayer = 0;
|
||||
}
|
||||
if (doomcom.numnodes < 3)
|
||||
{ // Packet server mode with only two players is effectively the same as
|
||||
// peer-to-peer but with some slightly larger packets.
|
||||
return false;
|
||||
}
|
||||
return doomcom.numnodes > 3 || !NodesOnSameNetwork();
|
||||
}
|
||||
|
||||
|
||||
void I_NetCmd (void)
|
||||
{
|
||||
if (doomcom.command == CMD_SEND)
|
||||
{
|
||||
PacketSend ();
|
||||
}
|
||||
else if (doomcom.command == CMD_GET)
|
||||
{
|
||||
PacketGet ();
|
||||
}
|
||||
else
|
||||
I_Error ("Bad net cmd: %i\n",doomcom.command);
|
||||
}
|
||||
|
||||
#ifdef __WIN32__
|
||||
|
|
45
src/i_net.h
45
src/i_net.h
|
@ -1,8 +1,41 @@
|
|||
#ifndef __I_NET_H__
|
||||
#define __I_NET_H__
|
||||
|
||||
// Called by D_DoomMain.
|
||||
bool I_InitNetwork (void);
|
||||
void I_NetCmd (void);
|
||||
#pragma once
|
||||
|
||||
#endif
|
||||
#include <memory>
|
||||
|
||||
#define MAX_MSGLEN 14000
|
||||
|
||||
struct NetPacket
|
||||
{
|
||||
NetPacket() { memset(data, 0, sizeof(data)); }
|
||||
|
||||
// packet data to be sent
|
||||
uint8_t data[MAX_MSGLEN];
|
||||
|
||||
// bytes in data to be sent
|
||||
int16_t datalength = 0;
|
||||
|
||||
// dest for send, set by get (-1 = no packet).
|
||||
int16_t remotenode = 0;
|
||||
|
||||
uint8_t &operator[](int i) { return data[i]; }
|
||||
const uint8_t &operator[](int i) const { return data[i]; }
|
||||
};
|
||||
|
||||
// Network packet data.
|
||||
struct doomcom_t
|
||||
{
|
||||
virtual ~doomcom_t() { }
|
||||
|
||||
virtual void PacketSend(const NetPacket &packet) = 0;
|
||||
virtual void PacketGet(NetPacket &packet) = 0;
|
||||
|
||||
// info common to all nodes
|
||||
int16_t numnodes = 0; // console is always node 0.
|
||||
|
||||
// info specific to this node
|
||||
int16_t consoleplayer = 0;
|
||||
int16_t numplayers = 0;
|
||||
};
|
||||
|
||||
std::unique_ptr<doomcom_t> I_InitNetwork();
|
||||
|
|
12
src/info.cpp
12
src/info.cpp
|
@ -594,17 +594,17 @@ static void SummonActor (int command, int command2, FCommandLine argv)
|
|||
Printf ("Unknown actor '%s'\n", argv[1]);
|
||||
return;
|
||||
}
|
||||
Net_WriteByte (argv.argc() > 2 ? command2 : command);
|
||||
Net_WriteString (type->TypeName.GetChars());
|
||||
network.Net_WriteByte (argv.argc() > 2 ? command2 : command);
|
||||
network.Net_WriteString (type->TypeName.GetChars());
|
||||
|
||||
if (argv.argc () > 2)
|
||||
{
|
||||
Net_WriteWord (atoi (argv[2])); // angle
|
||||
Net_WriteWord ((argv.argc() > 3) ? atoi(argv[3]) : 0); // TID
|
||||
Net_WriteByte ((argv.argc() > 4) ? atoi(argv[4]) : 0); // special
|
||||
network.Net_WriteWord (atoi (argv[2])); // angle
|
||||
network.Net_WriteWord ((argv.argc() > 3) ? atoi(argv[3]) : 0); // TID
|
||||
network.Net_WriteByte ((argv.argc() > 4) ? atoi(argv[4]) : 0); // special
|
||||
for (int i = 5; i < 10; i++)
|
||||
{ // args[5]
|
||||
Net_WriteLong((i < argv.argc()) ? atoi(argv[i]) : 0);
|
||||
network.Net_WriteLong((i < argv.argc()) ? atoi(argv[i]) : 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -809,7 +809,7 @@ bool DIntermissionController::Responder (event_t *ev)
|
|||
int res = mScreen->Responder(ev);
|
||||
if (res == -1 && !mSentAdvance)
|
||||
{
|
||||
Net_WriteByte(DEM_ADVANCEINTER);
|
||||
network.Net_WriteByte(DEM_ADVANCEINTER);
|
||||
mSentAdvance = true;
|
||||
}
|
||||
return !!res;
|
||||
|
|
|
@ -701,6 +701,6 @@ CCMD (mdk)
|
|||
return;
|
||||
|
||||
const char *name = argv.argc() > 1 ? argv[1] : "";
|
||||
Net_WriteByte (DEM_MDK);
|
||||
Net_WriteString(name);
|
||||
network.Net_WriteByte (DEM_MDK);
|
||||
network.Net_WriteString(name);
|
||||
}
|
||||
|
|
|
@ -695,17 +695,17 @@ DEFINE_ACTION_FUNCTION(DConversationMenu, SendConversationReply)
|
|||
switch (node)
|
||||
{
|
||||
case -1:
|
||||
Net_WriteByte(DEM_CONVNULL);
|
||||
network.Net_WriteByte(DEM_CONVNULL);
|
||||
break;
|
||||
|
||||
case -2:
|
||||
Net_WriteByte(DEM_CONVCLOSE);
|
||||
network.Net_WriteByte(DEM_CONVCLOSE);
|
||||
break;
|
||||
|
||||
default:
|
||||
Net_WriteByte(DEM_CONVREPLY);
|
||||
Net_WriteWord(node);
|
||||
Net_WriteByte(reply);
|
||||
network.Net_WriteByte(DEM_CONVREPLY);
|
||||
network.Net_WriteWord(node);
|
||||
network.Net_WriteByte(reply);
|
||||
break;
|
||||
}
|
||||
StaticLastReply = reply;
|
||||
|
|
|
@ -1981,8 +1981,8 @@ CCMD (kill)
|
|||
if (CheckCheatmode ())
|
||||
return;
|
||||
|
||||
Net_WriteByte (DEM_GENERICCHEAT);
|
||||
Net_WriteByte (CHT_MASSACRE);
|
||||
network.Net_WriteByte (DEM_GENERICCHEAT);
|
||||
network.Net_WriteByte (CHT_MASSACRE);
|
||||
}
|
||||
else if (!stricmp (argv[1], "baddies"))
|
||||
{
|
||||
|
@ -1990,13 +1990,13 @@ CCMD (kill)
|
|||
if (CheckCheatmode ())
|
||||
return;
|
||||
|
||||
Net_WriteByte (DEM_GENERICCHEAT);
|
||||
Net_WriteByte (CHT_MASSACRE2);
|
||||
network.Net_WriteByte (DEM_GENERICCHEAT);
|
||||
network.Net_WriteByte (CHT_MASSACRE2);
|
||||
}
|
||||
else
|
||||
{
|
||||
Net_WriteByte (DEM_KILLCLASSCHEAT);
|
||||
Net_WriteString (argv[1]);
|
||||
network.Net_WriteByte (DEM_KILLCLASSCHEAT);
|
||||
network.Net_WriteString (argv[1]);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -2006,7 +2006,7 @@ CCMD (kill)
|
|||
return;
|
||||
|
||||
// Kill the player
|
||||
Net_WriteByte (DEM_SUICIDE);
|
||||
network.Net_WriteByte (DEM_SUICIDE);
|
||||
}
|
||||
C_HideConsole ();
|
||||
}
|
||||
|
@ -2018,8 +2018,8 @@ CCMD(remove)
|
|||
if (CheckCheatmode())
|
||||
return;
|
||||
|
||||
Net_WriteByte(DEM_REMOVE);
|
||||
Net_WriteString(argv[1]);
|
||||
network.Net_WriteByte(DEM_REMOVE);
|
||||
network.Net_WriteString(argv[1]);
|
||||
C_HideConsole();
|
||||
}
|
||||
else
|
||||
|
@ -2027,5 +2027,4 @@ CCMD(remove)
|
|||
Printf("Usage: remove <actor class name>\n");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3088,7 +3088,7 @@ FUNC(LS_Autosave)
|
|||
if (gameaction != ga_savegame)
|
||||
{
|
||||
level.flags2 &= ~LEVEL2_NOAUTOSAVEHINT;
|
||||
Net_WriteByte (DEM_CHECKAUTOSAVE);
|
||||
network.Net_WriteByte (DEM_CHECKAUTOSAVE);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -602,7 +602,7 @@ void player_t::SetFOV(float fov)
|
|||
{
|
||||
if (consoleplayer == Net_Arbitrator)
|
||||
{
|
||||
Net_WriteByte(DEM_MYFOV);
|
||||
network.Net_WriteByte(DEM_MYFOV);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -612,9 +612,9 @@ void player_t::SetFOV(float fov)
|
|||
}
|
||||
else
|
||||
{
|
||||
Net_WriteByte(DEM_MYFOV);
|
||||
network.Net_WriteByte(DEM_MYFOV);
|
||||
}
|
||||
Net_WriteFloat(clamp<float>(fov, 5.f, 179.f));
|
||||
network.Net_WriteFloat(clamp<float>(fov, 5.f, 179.f));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -734,9 +734,9 @@ void player_t::SendPitchLimits() const
|
|||
{
|
||||
if (this - players == consoleplayer)
|
||||
{
|
||||
Net_WriteByte(DEM_SETPITCHLIMIT);
|
||||
Net_WriteByte(Renderer->GetMaxViewPitch(false)); // up
|
||||
Net_WriteByte(Renderer->GetMaxViewPitch(true)); // down
|
||||
network.Net_WriteByte(DEM_SETPITCHLIMIT);
|
||||
network.Net_WriteByte(Renderer->GetMaxViewPitch(false)); // up
|
||||
network.Net_WriteByte(Renderer->GetMaxViewPitch(true)); // down
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2453,7 +2453,7 @@ void P_PredictPlayer (player_t *player)
|
|||
return;
|
||||
}
|
||||
|
||||
maxtic = maketic;
|
||||
maxtic = network.maketic;
|
||||
|
||||
if (gametic == maxtic)
|
||||
{
|
||||
|
@ -2504,13 +2504,13 @@ void P_PredictPlayer (player_t *player)
|
|||
act->BlockNode = NULL;
|
||||
|
||||
// Values too small to be usable for lerping can be considered "off".
|
||||
bool CanLerp = (!(cl_predict_lerpscale < 0.01f) && (ticdup == 1)), DoLerp = false, NoInterpolateOld = R_GetViewInterpolationStatus();
|
||||
bool CanLerp = (!(cl_predict_lerpscale < 0.01f) && (network.ticdup == 1)), DoLerp = false, NoInterpolateOld = R_GetViewInterpolationStatus();
|
||||
for (int i = gametic; i < maxtic; ++i)
|
||||
{
|
||||
if (!NoInterpolateOld)
|
||||
R_RebuildViewInterpolation(player);
|
||||
|
||||
player->cmd = localcmds[i % LOCALCMDTICS];
|
||||
player->cmd = network.localcmds[i % LOCALCMDTICS];
|
||||
P_PlayerThink (player);
|
||||
player->mo->Tick ();
|
||||
|
||||
|
|
|
@ -111,8 +111,6 @@ void PolyRenderer::RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, int
|
|||
|
||||
void PolyRenderer::RenderActorView(AActor *actor, bool dontmaplines)
|
||||
{
|
||||
NetUpdate();
|
||||
|
||||
DontMapLines = dontmaplines;
|
||||
|
||||
R_SetupFrame(Viewpoint, Viewwindow, actor);
|
||||
|
@ -147,8 +145,6 @@ void PolyRenderer::RenderActorView(AActor *actor, bool dontmaplines)
|
|||
|
||||
Viewpoint.camera->renderflags = savedflags;
|
||||
interpolator.RestoreInterpolations ();
|
||||
|
||||
NetUpdate();
|
||||
}
|
||||
|
||||
void PolyRenderer::RenderRemainingPlayerSprites()
|
||||
|
|
|
@ -72,7 +72,7 @@ public:
|
|||
virtual void NetProgress(int count);
|
||||
virtual void NetMessage(const char *format, ...);
|
||||
virtual void NetDone();
|
||||
virtual bool NetLoop(bool (*timerCallback)(void*), void* userData);
|
||||
virtual bool NetLoop(std::function<bool()> callback);
|
||||
};
|
||||
|
||||
|
||||
|
@ -154,11 +154,11 @@ void FBasicStartupScreen::NetDone()
|
|||
FConsoleWindow::GetInstance().NetDone();
|
||||
}
|
||||
|
||||
bool FBasicStartupScreen::NetLoop(bool (*timerCallback)(void*), void* const userData)
|
||||
bool FBasicStartupScreen::NetLoop(std::function<bool()> callback)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (timerCallback(userData))
|
||||
if (callback())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ class FTTYStartupScreen : public FStartupScreen
|
|||
void NetProgress(int count);
|
||||
void NetMessage(const char *format, ...); // cover for printf
|
||||
void NetDone();
|
||||
bool NetLoop(bool (*timer_callback)(void *), void *userdata);
|
||||
bool NetLoop(std::function<bool()> callback);
|
||||
protected:
|
||||
bool DidNetInit;
|
||||
int NetMaxPos, NetCurPos;
|
||||
|
@ -305,7 +305,7 @@ void FTTYStartupScreen::NetProgress(int count)
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
bool FTTYStartupScreen::NetLoop(bool (*timer_callback)(void *), void *userdata)
|
||||
bool FTTYStartupScreen::NetLoop(std::function<bool()> callback)
|
||||
{
|
||||
fd_set rfds;
|
||||
struct timeval tv;
|
||||
|
@ -329,7 +329,7 @@ bool FTTYStartupScreen::NetLoop(bool (*timer_callback)(void *), void *userdata)
|
|||
}
|
||||
else if (retval == 0)
|
||||
{
|
||||
if (timer_callback (userdata))
|
||||
if (callback())
|
||||
{
|
||||
fputc ('\n', stderr);
|
||||
return true;
|
||||
|
|
|
@ -35,6 +35,8 @@
|
|||
** Actual implementation is system-specific.
|
||||
*/
|
||||
|
||||
#include <functional>
|
||||
|
||||
class FStartupScreen
|
||||
{
|
||||
public:
|
||||
|
@ -51,7 +53,7 @@ public:
|
|||
virtual void NetProgress(int count);
|
||||
virtual void NetMessage(const char *format, ...); // cover for printf
|
||||
virtual void NetDone();
|
||||
virtual bool NetLoop(bool (*timer_callback)(void *), void *userdata);
|
||||
virtual bool NetLoop(std::function<bool()> callback);
|
||||
protected:
|
||||
int MaxPos, CurPos, NotchPos;
|
||||
};
|
||||
|
|
|
@ -433,8 +433,8 @@ static bool CheatAddKey (cheatseq_t *cheat, uint8_t key, bool *eat)
|
|||
|
||||
static bool Cht_Generic (cheatseq_t *cheat)
|
||||
{
|
||||
Net_WriteByte (DEM_GENERICCHEAT);
|
||||
Net_WriteByte (cheat->Args[0]);
|
||||
network.Net_WriteByte (DEM_GENERICCHEAT);
|
||||
network.Net_WriteByte (cheat->Args[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -599,7 +599,7 @@ CCMD(finishgame)
|
|||
return;
|
||||
}
|
||||
// This CCMD simulates an end-of-game action and exists to end mods that never exit their last level.
|
||||
Net_WriteByte(DEM_FINISHGAME);
|
||||
network.Net_WriteByte(DEM_FINISHGAME);
|
||||
}
|
||||
|
||||
ADD_STAT(statistics)
|
||||
|
|
|
@ -85,9 +85,6 @@ namespace swrenderer
|
|||
return;
|
||||
}
|
||||
|
||||
if (Thread->MainThread)
|
||||
NetUpdate();
|
||||
|
||||
frontsector = curline->frontsector;
|
||||
backsector = curline->backsector;
|
||||
|
||||
|
|
|
@ -373,9 +373,6 @@ namespace swrenderer
|
|||
WallSampler sampler(Thread->Viewport.get(), y1, texturemid, swal[x], yrepeat, lwal[x] + xoffset, xmagnitude, rw_pic);
|
||||
Draw1Column(x, y1, y2, sampler);
|
||||
}
|
||||
|
||||
if (Thread->MainThread)
|
||||
NetUpdate();
|
||||
}
|
||||
|
||||
void RenderWallPart::ProcessNormalWall(const short *uwal, const short *dwal, double texturemid, float *swal, fixed_t *lwal)
|
||||
|
|
|
@ -142,7 +142,5 @@ namespace swrenderer
|
|||
renderer.Render(this, xscale, yscale, alpha, additive, masked, colormap, tex);
|
||||
}
|
||||
}
|
||||
if (thread->MainThread)
|
||||
NetUpdate();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -451,14 +451,8 @@ namespace swrenderer
|
|||
int prevuniq2 = CurrentPortalUniq;
|
||||
CurrentPortalUniq = prevuniq;
|
||||
|
||||
if (Thread->MainThread)
|
||||
NetUpdate();
|
||||
|
||||
Thread->TranslucentPass->Render(); // this is required since with portals there often will be cases when more than 80% of the view is inside a portal.
|
||||
|
||||
if (Thread->MainThread)
|
||||
NetUpdate();
|
||||
|
||||
Thread->Clip3D->LeaveSkybox(); // pop 3D floor height map
|
||||
CurrentPortalUniq = prevuniq2;
|
||||
|
||||
|
|
|
@ -145,8 +145,6 @@ namespace swrenderer
|
|||
CameraLight::Instance()->SetCamera(MainThread()->Viewport->viewpoint, MainThread()->Viewport->RenderTarget, actor);
|
||||
MainThread()->Viewport->SetupFreelook();
|
||||
|
||||
NetUpdate();
|
||||
|
||||
this->dontmaplines = dontmaplines;
|
||||
|
||||
// [RH] Setup particles for this frame
|
||||
|
@ -277,9 +275,6 @@ namespace swrenderer
|
|||
thread->OpaquePass->RenderScene();
|
||||
thread->Clip3D->ResetClip(); // reset clips (floor/ceiling)
|
||||
|
||||
if (thread->MainThread)
|
||||
NetUpdate();
|
||||
|
||||
if (viewactive)
|
||||
{
|
||||
thread->PlaneList->Render();
|
||||
|
@ -287,13 +282,7 @@ namespace swrenderer
|
|||
thread->Portal->RenderPlanePortals();
|
||||
thread->Portal->RenderLinePortals();
|
||||
|
||||
if (thread->MainThread)
|
||||
NetUpdate();
|
||||
|
||||
thread->TranslucentPass->Render();
|
||||
|
||||
if (thread->MainThread)
|
||||
NetUpdate();
|
||||
}
|
||||
|
||||
DrawerThreads::Execute(thread->DrawQueue);
|
||||
|
|
|
@ -551,8 +551,5 @@ namespace swrenderer
|
|||
drawerargs.DrawMaskedColumn(thread, x, iscale, pic, frac + xiscale / 2, spryscale, sprtopscreen, sprflipvert, mfloorclip, mceilingclip, RenderStyle, false);
|
||||
frac += xiscale;
|
||||
}
|
||||
|
||||
if (thread->MainThread)
|
||||
NetUpdate();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -371,8 +371,5 @@ namespace swrenderer
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (thread->MainThread)
|
||||
NetUpdate();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -177,11 +177,6 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms)
|
|||
#ifndef NO_SWRENDER
|
||||
SWCanvas::DrawTexture(this, img, parms);
|
||||
#endif
|
||||
|
||||
if (ticdup != 0 && menuactive == MENU_Off)
|
||||
{
|
||||
NetUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
void DCanvas::SetClipRect(int x, int y, int w, int h)
|
||||
|
|
|
@ -124,7 +124,7 @@ public:
|
|||
void NetProgress(int count);
|
||||
void NetMessage(const char *format, ...); // cover for printf
|
||||
void NetDone();
|
||||
bool NetLoop(bool (*timer_callback)(void *), void *userdata);
|
||||
bool NetLoop(std::function<bool()> callback);
|
||||
protected:
|
||||
LRESULT NetMarqueeMode;
|
||||
int NetMaxPos, NetCurPos;
|
||||
|
@ -531,7 +531,7 @@ void FBasicStartupScreen :: NetProgress(int count)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
bool FBasicStartupScreen::NetLoop(bool (*timer_callback)(void *), void *userdata)
|
||||
bool FBasicStartupScreen::NetLoop(std::function<bool()> callback)
|
||||
{
|
||||
BOOL bRet;
|
||||
MSG msg;
|
||||
|
@ -552,7 +552,7 @@ bool FBasicStartupScreen::NetLoop(bool (*timer_callback)(void *), void *userdata
|
|||
{
|
||||
if (msg.message == WM_TIMER && msg.hwnd == Window && msg.wParam == 1337)
|
||||
{
|
||||
if (timer_callback (userdata))
|
||||
if (callback())
|
||||
{
|
||||
KillTimer (NetStartPane, 1);
|
||||
return true;
|
||||
|
|
Loading…
Reference in a new issue