Skip to content

Commit

Permalink
- remove some old code no longer relevant for c/s
Browse files Browse the repository at this point in the history
  • Loading branch information
dpjudas committed Jul 15, 2019
1 parent 3420706 commit 7781725
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 91 deletions.
24 changes: 2 additions & 22 deletions src/g_game.cpp
Expand Up @@ -535,8 +535,6 @@ ticcmd_t G_BuildTiccmd ()

ticcmd_t cmd;

cmd.consistency = network->GetConsoleConsistency();

strafe = Button_Strafe.bDown;
speed = Button_Speed.bDown ^ (int)cl_run;

Expand All @@ -546,7 +544,7 @@ ticcmd_t G_BuildTiccmd ()
// and not the joystick, since we treat the joystick as
// the analog device it is.
if (Button_Left.bDown || Button_Right.bDown)
turnheld += network->ticdup;
turnheld++;
else
turnheld = 0;

Expand Down Expand Up @@ -1153,24 +1151,6 @@ void G_Ticker ()
{
Printf ("%s is turbo!\n", players[i].userinfo.GetName());
}

if (netgame && players[i].Bot == NULL && !demoplayback && (gametic%network->ticdup) == 0)
{
if (network->IsInconsistent(i, cmd->consistency))
{
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;
network->SetConsistency(i, sum);
}
else
{
network->SetConsistency(i, rngsum);
}
}
}
}

Expand Down Expand Up @@ -2380,7 +2360,7 @@ void G_WriteDemoTiccmd (ticcmd_t *cmd, int player)
}

// [RH] Write any special "ticcmds" for this player to the demo
demo_p += network->CopySpecData(player, demo_p, maxdemosize - (demo_p - demobuffer));
demo_p += CopySpecData(player, demo_p, maxdemosize - (demo_p - demobuffer));

// [RH] Now write out a "normal" ticcmd.
WriteUserCmdMessage (&cmd->ucmd, &players[player].cmd.ucmd, &demo_p);
Expand Down
5 changes: 2 additions & 3 deletions src/g_statusbar/shared_sbar.cpp
Expand Up @@ -1378,9 +1378,8 @@ void DBaseStatusBar::DrawConsistancy () const
firsttime = false;
if (debugfile)
{
fprintf (debugfile, "%s as of tic %d (%d)\n", conbuff,
players[1-consoleplayer].inconsistant,
players[1-consoleplayer].inconsistant/network->ticdup);
fprintf (debugfile, "%s as of tic %d\n", conbuff,
players[1-consoleplayer].inconsistant);
}
}
screen->DrawText (SmallFont, CR_GREEN,
Expand Down
2 changes: 2 additions & 0 deletions src/network/i_net.cpp
Expand Up @@ -98,6 +98,8 @@ const char *neterror (void);
#define neterror() strerror(errno)
#endif

#define NCMD_COMPRESSED 0x04 // remainder of packet is compressed

class DoomComImpl : public doomcom_t
{
public:
Expand Down
5 changes: 0 additions & 5 deletions src/network/net.cpp
Expand Up @@ -98,11 +98,6 @@ static TArray<PacketStore> InBuffer;
static TArray<PacketStore> OutBuffer;
#endif

int Network::GetHighPingThreshold() const
{
return ((BACKUPTICS / 2 - 1) * ticdup) * (1000 / TICRATE);
}

#if 0 // For reference. Remove when c/s migration is complete

void Network::ReadTicCmd(uint8_t **stream, int player, int tic)
Expand Down
57 changes: 1 addition & 56 deletions src/network/net.h
Expand Up @@ -60,7 +60,7 @@ class Network
// Statistics
virtual int GetPing(int player) const = 0;
virtual int GetServerPing() const = 0;
int GetHighPingThreshold() const;
int GetHighPingThreshold() const { return ((BACKUPTICS / 2 - 1)) * (1000 / TICRATE); }

// CCMDs
virtual void ListPingTimes() = 0;
Expand All @@ -74,62 +74,7 @@ class Network
void Startup() { }
void Net_ClearBuffers() { }
void D_QuitNetGame() { }

// Demo recording
size_t CopySpecData(int player, uint8_t *dest, size_t dest_size) { return 0; }

// Obsolete; only needed for p2p
bool IsInconsistent(int player, int16_t checkvalue) const { return false; }
void SetConsistency(int player, int16_t checkvalue) { }
int16_t GetConsoleConsistency() const { return 0; }

// Should probably be removed.
int ticdup = 1;
};

extern std::unique_ptr<Network> network;
extern std::unique_ptr<Network> netconnect;

// Old packet format. Kept for reference. Should be removed or updated once the c/s migration is complete.

// [RH]
// New generic packet structure:
//
// Header:
// One byte with following flags.
// One byte with starttic
// One byte with master's maketic (master -> slave only!)
// If NCMD_RETRANSMIT set, one byte with retransmitfrom
// If NCMD_XTICS set, one byte with number of tics (minus 3, so theoretically up to 258 tics in one packet)
// If NCMD_QUITTERS, one byte with number of players followed by one byte with each player's consolenum
// If NCMD_MULTI, one byte with number of players followed by one byte with each player's consolenum
// - The first player's consolenum is not included in this list, because it always matches the sender
//
// For each tic:
// Two bytes with consistency check, followed by tic data
//
// Setup packets are different, and are described just before D_ArbitrateNetStart().

#define NCMD_EXIT 0x80
#define NCMD_RETRANSMIT 0x40
#define NCMD_SETUP 0x20
#define NCMD_MULTI 0x10 // multiple players in this packet
#define NCMD_QUITTERS 0x08 // one or more players just quit (packet server only)
#define NCMD_COMPRESSED 0x04 // remainder of packet is compressed

#define NCMD_XTICS 0x03 // packet contains >2 tics
#define NCMD_2TICS 0x02 // packet contains 2 tics
#define NCMD_1TICS 0x01 // packet contains 1 tic
#define NCMD_0TICS 0x00 // packet contains 0 tics

enum
{
PRE_CONNECT, // Sent from guest to host for initial connection
PRE_KEEPALIVE,
PRE_DISCONNECT, // Sent from guest that aborts the game
PRE_ALLHERE, // Sent from host to guest when everybody has connected
PRE_CONACK, // Sent from host to guest to acknowledge PRE_CONNECT receipt
PRE_ALLFULL, // Sent from host to an unwanted guest
PRE_ALLHEREACK, // Sent from guest to host to acknowledge PRE_ALLHEREACK receipt
PRE_GO // Sent from host to guest to continue game startup
};
7 changes: 3 additions & 4 deletions src/playsim/bots/b_think.cpp
Expand Up @@ -76,13 +76,12 @@ void DBot::Think ()
ThinkForMove (&cmd);
TurnToAng ();

cmd.ucmd.yaw = (short)((actor->Angles.Yaw - oldyaw).Degrees * (65536 / 360.f)) / network->ticdup;
cmd.ucmd.yaw = (short)((actor->Angles.Yaw - oldyaw).Degrees * (65536 / 360.f));
cmd.ucmd.pitch = (short)((oldpitch - actor->Angles.Pitch).Degrees * (65536 / 360.f));
if (cmd.ucmd.pitch == -32768)
cmd.ucmd.pitch = -32767;
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));
actor->Angles.Yaw = oldyaw + DAngle(cmd.ucmd.yaw * (360 / 65536.f));
actor->Angles.Pitch = oldpitch - DAngle(cmd.ucmd.pitch * (360 / 65536.f));
}

if (t_active) t_active--;
Expand Down
3 changes: 3 additions & 0 deletions src/playsim/p_commands.h
Expand Up @@ -32,3 +32,6 @@ void CmdWriteWord(short it);
void CmdWriteLong(int it);
void CmdWriteFloat(float it);
void CmdWriteString(const char* it);

// Demo recording (To do: reimplement - it probably just copied the commands already written)
inline size_t CopySpecData(int player, uint8_t* dest, size_t dest_size) { return 0; }
2 changes: 1 addition & 1 deletion src/playsim/p_user.cpp
Expand Up @@ -1446,7 +1446,7 @@ 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) && (network->ticdup == 1)), DoLerp = false, NoInterpolateOld = R_GetViewInterpolationStatus();
bool CanLerp = (!(cl_predict_lerpscale < 0.01f)), DoLerp = false, NoInterpolateOld = R_GetViewInterpolationStatus();
for (int i = gametic; i < maxtic; ++i)
{
if (!NoInterpolateOld)
Expand Down

0 comments on commit 7781725

Please sign in to comment.