mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-01-30 20:41:00 +00:00
- Fixed the new network status display for the Linux terminal.
SVN r428 (trunk)
This commit is contained in:
parent
3eeef7af77
commit
4899fa91f1
8 changed files with 95 additions and 66 deletions
|
@ -1,3 +1,6 @@
|
||||||
|
December 28, 2006
|
||||||
|
- Fixed the new network status display for the Linux terminal.
|
||||||
|
|
||||||
December 25, 2006 (Changes by Graf Zahl)
|
December 25, 2006 (Changes by Graf Zahl)
|
||||||
- Converted the Communicator to DECORATE.
|
- Converted the Communicator to DECORATE.
|
||||||
- Renamed the new armor properties to use the same names as Skulltag to avoid
|
- Renamed the new armor properties to use the same names as Skulltag to avoid
|
||||||
|
|
|
@ -1356,7 +1356,7 @@ bool DoArbitrate (void *userdata)
|
||||||
|
|
||||||
D_ReadUserInfoStrings (netbuffer[1], &stream, false);
|
D_ReadUserInfoStrings (netbuffer[1], &stream, false);
|
||||||
|
|
||||||
Printf ("Found %s (node %d, player %d)\n",
|
ST_NetMessage ("Found %s (node %d, player %d)",
|
||||||
players[netbuffer[1]].userinfo.netname,
|
players[netbuffer[1]].userinfo.netname,
|
||||||
node, netbuffer[1]+1);
|
node, netbuffer[1]+1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,6 +70,8 @@
|
||||||
#define NOVTABLE
|
#define NOVTABLE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
typedef long long __int64;
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
typedef __int8 SBYTE;
|
typedef __int8 SBYTE;
|
||||||
typedef unsigned __int8 BYTE;
|
typedef unsigned __int8 BYTE;
|
||||||
|
|
|
@ -224,7 +224,7 @@ void PacketGet (void)
|
||||||
if (err == WSAECONNRESET)
|
if (err == WSAECONNRESET)
|
||||||
{ // The remote node aborted unexpectedly, so pretend it sent an exit packet
|
{ // The remote node aborted unexpectedly, so pretend it sent an exit packet
|
||||||
|
|
||||||
Printf (PRINT_BOLD, "The connection from %s was dropped\n",
|
ST_NetMessage ("The connection from %s was dropped.\n",
|
||||||
players[sendplayer[node]].userinfo.netname);
|
players[sendplayer[node]].userinfo.netname);
|
||||||
|
|
||||||
doomcom.data[0] = 0x80; // NCMD_EXIT
|
doomcom.data[0] = 0x80; // NCMD_EXIT
|
||||||
|
@ -309,7 +309,7 @@ void BuildAddress (sockaddr_in *address, char *name)
|
||||||
if (!isnamed)
|
if (!isnamed)
|
||||||
{
|
{
|
||||||
address->sin_addr.s_addr = inet_addr (name);
|
address->sin_addr.s_addr = inet_addr (name);
|
||||||
Printf ("Node number, %d address %s\n", doomcom.numnodes, name);
|
Printf ("Node number %d, address %s\n", doomcom.numnodes, name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -317,7 +317,7 @@ void BuildAddress (sockaddr_in *address, char *name)
|
||||||
if (!hostentry)
|
if (!hostentry)
|
||||||
I_FatalError ("gethostbyname: couldn't find %s\n%s", name, neterror());
|
I_FatalError ("gethostbyname: couldn't find %s\n%s", name, neterror());
|
||||||
address->sin_addr.s_addr = *(int *)hostentry->h_addr_list[0];
|
address->sin_addr.s_addr = *(int *)hostentry->h_addr_list[0];
|
||||||
Printf ("Node number %d hostname %s\n",
|
Printf ("Node number %d, hostname %s\n",
|
||||||
doomcom.numnodes, hostentry->h_name);
|
doomcom.numnodes, hostentry->h_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -425,11 +425,9 @@ bool Host_CheckForConnects (void *userdata)
|
||||||
{
|
{
|
||||||
if (node == -1)
|
if (node == -1)
|
||||||
{
|
{
|
||||||
Printf ("Got extra connect from %d.%d.%d.%d:%d\n",
|
const BYTE *s_addr_bytes = (const BYTE *)&from->sin_addr;
|
||||||
from->sin_addr.S_un.S_un_b.s_b1,
|
ST_NetMessage ("Got extra connect from %d.%d.%d.%d:%d",
|
||||||
from->sin_addr.S_un.S_un_b.s_b2,
|
s_addr_bytes[0], s_addr_bytes[1], s_addr_bytes[2], s_addr_bytes[3],
|
||||||
from->sin_addr.S_un.S_un_b.s_b3,
|
|
||||||
from->sin_addr.S_un.S_un_b.s_b4,
|
|
||||||
from->sin_port);
|
from->sin_port);
|
||||||
packet.Message = PRE_ALLFULL;
|
packet.Message = PRE_ALLFULL;
|
||||||
PreSend (&packet, 2, from);
|
PreSend (&packet, 2, from);
|
||||||
|
@ -441,8 +439,8 @@ bool Host_CheckForConnects (void *userdata)
|
||||||
{
|
{
|
||||||
node = doomcom.numnodes++;
|
node = doomcom.numnodes++;
|
||||||
sendaddress[node] = *from;
|
sendaddress[node] = *from;
|
||||||
|
ST_NetMessage ("Got connect from node %d.", node);
|
||||||
}
|
}
|
||||||
Printf ("Got connect from node %d\n", node);
|
|
||||||
|
|
||||||
// Let the new guest (and everyone else) know we got their message.
|
// Let the new guest (and everyone else) know we got their message.
|
||||||
SendConAck (doomcom.numnodes, numplayers);
|
SendConAck (doomcom.numnodes, numplayers);
|
||||||
|
@ -453,7 +451,7 @@ bool Host_CheckForConnects (void *userdata)
|
||||||
node = FindNode (from);
|
node = FindNode (from);
|
||||||
if (node >= 0)
|
if (node >= 0)
|
||||||
{
|
{
|
||||||
Printf ("Got disconnect from node %d\n", node);
|
ST_NetMessage ("Got disconnect from node %d.", node);
|
||||||
doomcom.numnodes--;
|
doomcom.numnodes--;
|
||||||
while (node < doomcom.numnodes)
|
while (node < doomcom.numnodes)
|
||||||
{
|
{
|
||||||
|
@ -589,7 +587,6 @@ void HostGame (int i)
|
||||||
Printf ("Console player number: %d\n", doomcom.consoleplayer);
|
Printf ("Console player number: %d\n", doomcom.consoleplayer);
|
||||||
|
|
||||||
doomcom.numnodes = 1;
|
doomcom.numnodes = 1;
|
||||||
Printf ("Waiting for players...\n");
|
|
||||||
|
|
||||||
atterm (SendAbort);
|
atterm (SendAbort);
|
||||||
|
|
||||||
|
@ -603,7 +600,7 @@ void HostGame (int i)
|
||||||
|
|
||||||
// Now inform everyone of all machines involved in the game
|
// Now inform everyone of all machines involved in the game
|
||||||
memset (gotack, 0, sizeof(gotack));
|
memset (gotack, 0, sizeof(gotack));
|
||||||
Printf ("Sending all here\n");
|
ST_NetMessage ("Sending all here.");
|
||||||
ST_NetInit ("Done waiting", 1);
|
ST_NetInit ("Done waiting", 1);
|
||||||
|
|
||||||
if (!ST_NetLoop (Host_SendAllHere, (void *)gotack))
|
if (!ST_NetLoop (Host_SendAllHere, (void *)gotack))
|
||||||
|
@ -614,7 +611,7 @@ void HostGame (int i)
|
||||||
popterm ();
|
popterm ();
|
||||||
|
|
||||||
// Now go
|
// Now go
|
||||||
Printf ("Go\n");
|
ST_NetMessage ("Go");
|
||||||
packet.Fake = PRE_FAKE;
|
packet.Fake = PRE_FAKE;
|
||||||
packet.Message = PRE_GO;
|
packet.Message = PRE_GO;
|
||||||
for (node = 1; node < doomcom.numnodes; node++)
|
for (node = 1; node < doomcom.numnodes; node++)
|
||||||
|
@ -627,7 +624,7 @@ void HostGame (int i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Printf ("Total players: %d\n", doomcom.numnodes);
|
ST_NetMessage ("Total players: %d", doomcom.numnodes);
|
||||||
|
|
||||||
doomcom.id = DOOMCOM_ID;
|
doomcom.id = DOOMCOM_ID;
|
||||||
doomcom.numplayers = doomcom.numnodes;
|
doomcom.numplayers = doomcom.numnodes;
|
||||||
|
@ -660,7 +657,7 @@ bool Guest_ContactHost (void *userdata)
|
||||||
{
|
{
|
||||||
if (packet.Message == PRE_CONACK)
|
if (packet.Message == PRE_CONACK)
|
||||||
{
|
{
|
||||||
Printf ("Total players: %d\n", packet.NumNodes);
|
ST_NetMessage ("Total players: %d", packet.NumNodes);
|
||||||
ST_NetInit ("Waiting for other players", packet.NumNodes);
|
ST_NetInit ("Waiting for other players", packet.NumNodes);
|
||||||
ST_NetProgress (packet.NumPresent);
|
ST_NetProgress (packet.NumPresent);
|
||||||
return true;
|
return true;
|
||||||
|
@ -670,7 +667,7 @@ bool Guest_ContactHost (void *userdata)
|
||||||
doomcom.numnodes = 0;
|
doomcom.numnodes = 0;
|
||||||
I_FatalError ("The host cancelled the game.");
|
I_FatalError ("The host cancelled the game.");
|
||||||
}
|
}
|
||||||
else if (packet.Message = PRE_ALLFULL)
|
else if (packet.Message == PRE_ALLFULL)
|
||||||
{
|
{
|
||||||
doomcom.numnodes = 0;
|
doomcom.numnodes = 0;
|
||||||
I_FatalError ("The game is full.");
|
I_FatalError ("The game is full.");
|
||||||
|
@ -710,7 +707,7 @@ bool Guest_WaitForOthers (void *userdata)
|
||||||
doomcom.numnodes = packet.NumNodes + 2;
|
doomcom.numnodes = packet.NumNodes + 2;
|
||||||
sendplayer[0] = packet.ConsoleNum; // My player number
|
sendplayer[0] = packet.ConsoleNum; // My player number
|
||||||
doomcom.consoleplayer = packet.ConsoleNum;
|
doomcom.consoleplayer = packet.ConsoleNum;
|
||||||
Printf ("Console player number: %d\n", doomcom.consoleplayer);
|
ST_NetMessage ("Console player number: %d", doomcom.consoleplayer);
|
||||||
for (node = 0; node < packet.NumNodes; node++)
|
for (node = 0; node < packet.NumNodes; node++)
|
||||||
{
|
{
|
||||||
sendaddress[node+2].sin_addr.s_addr = packet.machines[node].address;
|
sendaddress[node+2].sin_addr.s_addr = packet.machines[node].address;
|
||||||
|
@ -724,14 +721,14 @@ bool Guest_WaitForOthers (void *userdata)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Printf ("Received All Here, sending ACK\n");
|
ST_NetMessage ("Received All Here, sending ACK.");
|
||||||
packet.Fake = PRE_FAKE;
|
packet.Fake = PRE_FAKE;
|
||||||
packet.Message = PRE_ALLHEREACK;
|
packet.Message = PRE_ALLHEREACK;
|
||||||
PreSend (&packet, 2, &sendaddress[1]);
|
PreSend (&packet, 2, &sendaddress[1]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PRE_GO:
|
case PRE_GO:
|
||||||
Printf ("Go\n");
|
ST_NetMessage ("Received \"Go.\"");
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case PRE_DISCONNECT:
|
case PRE_DISCONNECT:
|
||||||
|
@ -775,7 +772,7 @@ void JoinGame (int i)
|
||||||
|
|
||||||
popterm ();
|
popterm ();
|
||||||
|
|
||||||
Printf ("Total players: %d\n", doomcom.numnodes);
|
ST_NetMessage ("Total players: %d", doomcom.numnodes);
|
||||||
|
|
||||||
doomcom.id = DOOMCOM_ID;
|
doomcom.id = DOOMCOM_ID;
|
||||||
doomcom.numplayers = doomcom.numnodes;
|
doomcom.numplayers = doomcom.numnodes;
|
||||||
|
|
|
@ -304,7 +304,7 @@ void FRandom::StaticPrintSeeds ()
|
||||||
|
|
||||||
while (rng != NULL)
|
while (rng != NULL)
|
||||||
{
|
{
|
||||||
Printf ("%s: %08lx\n", rng->Name, rng->Seed);
|
Printf ("%s: %08x\n", rng->Name, rng->Seed);
|
||||||
rng = rng->Next;
|
rng = rng->Next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ private:
|
||||||
|
|
||||||
SDLFB () {}
|
SDLFB () {}
|
||||||
};
|
};
|
||||||
IMPLEMENT_CLASS(SDLFB, DFrameBuffer)
|
IMPLEMENT_CLASS(SDLFB)
|
||||||
|
|
||||||
struct MiniModeInfo
|
struct MiniModeInfo
|
||||||
{
|
{
|
||||||
|
|
|
@ -39,11 +39,13 @@
|
||||||
|
|
||||||
#include "st_start.h"
|
#include "st_start.h"
|
||||||
#include "doomdef.h"
|
#include "doomdef.h"
|
||||||
|
#include "i_system.h"
|
||||||
|
|
||||||
termios OldTermIOS;
|
static termios OldTermIOS;
|
||||||
bool DidNetInit;
|
static bool DidNetInit;
|
||||||
int NetProgressMax, NetProgressTicker;
|
static int NetProgressMax, NetProgressTicker;
|
||||||
char SpinnyProgressChars[8] = { '|', '/', '-', '\\', '|', '/', '-', '\\' };
|
static const char *NetMessage;
|
||||||
|
static char SpinnyProgressChars[8] = { '|', '/', '-', '\\', '|', '/', '-', '\\' };
|
||||||
|
|
||||||
void ST_Init(int maxProgress)
|
void ST_Init(int maxProgress)
|
||||||
{
|
{
|
||||||
|
@ -59,39 +61,60 @@ void ST_Progress()
|
||||||
|
|
||||||
void ST_NetInit(const char *message, int numplayers)
|
void ST_NetInit(const char *message, int numplayers)
|
||||||
{
|
{
|
||||||
if (DidNetInit)
|
if (!DidNetInit)
|
||||||
{
|
|
||||||
if (numplayers == 1)
|
|
||||||
{
|
|
||||||
// Status message without any real progress info.
|
|
||||||
printf ("\n%s.", message);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf ("\n%s: ", message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
termios rawtermios;
|
termios rawtermios;
|
||||||
|
|
||||||
printf ("Press 'Q' to abort network game synchronization.\n%s: ", message);
|
fprintf (stderr, "Press 'Q' to abort network game synchronization.");
|
||||||
// Set stdin to raw mode so we can get keypresses in ST_CheckNetAbort()
|
// Set stdin to raw mode so we can get keypresses in ST_CheckNetAbort()
|
||||||
// immediately without waiting for an EOL.
|
// immediately without waiting for an EOL.
|
||||||
tcgetattr (STDIN_FILENO, &OldTermIOS);
|
tcgetattr (STDIN_FILENO, &OldTermIOS);
|
||||||
rawtermios = OldTermIOS;
|
rawtermios = OldTermIOS;
|
||||||
tcsetattr (STDIN_FILENO, &rawtermios);
|
rawtermios.c_lflag &= ~(ICANON | ECHO);
|
||||||
|
tcsetattr (STDIN_FILENO, TCSANOW, &rawtermios);
|
||||||
|
DidNetInit = true;
|
||||||
|
atterm (ST_NetDone);
|
||||||
}
|
}
|
||||||
|
if (numplayers == 1)
|
||||||
|
{
|
||||||
|
// Status message without any real progress info.
|
||||||
|
fprintf (stderr, "\n%s.", message);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf (stderr, "\n%s: ", message);
|
||||||
|
}
|
||||||
|
fflush (stderr);
|
||||||
|
NetMessage = message;
|
||||||
NetProgressMax = numplayers;
|
NetProgressMax = numplayers;
|
||||||
NetProgressTicker = 0;
|
NetProgressTicker = 0;
|
||||||
ST_NetProgress(); // You always know about yourself
|
ST_NetProgress(1); // You always know about yourself
|
||||||
}
|
}
|
||||||
|
|
||||||
void ST_NetDone()
|
void ST_NetDone()
|
||||||
{
|
{
|
||||||
// Restore stdin settings
|
// Restore stdin settings
|
||||||
tcsetattr (STDIN_FILENO, &OldTermIOS);
|
if (DidNetInit)
|
||||||
|
{
|
||||||
|
tcsetattr (STDIN_FILENO, TCSANOW, &OldTermIOS);
|
||||||
printf ("\n");
|
printf ("\n");
|
||||||
|
DidNetInit = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ST_NetMessage(const char *format, ...)
|
||||||
|
{
|
||||||
|
FString str;
|
||||||
|
va_list argptr;
|
||||||
|
|
||||||
|
va_start (argptr, format);
|
||||||
|
str.VFormat (format, argptr);
|
||||||
|
va_end (argptr);
|
||||||
|
fprintf (stderr, "\r%-40s\n", str.GetChars());
|
||||||
|
if (NetMessage == 0)
|
||||||
|
{
|
||||||
|
NetMessage = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ST_NetProgress(int count)
|
void ST_NetProgress(int count)
|
||||||
|
@ -102,24 +125,26 @@ void ST_NetProgress(int count)
|
||||||
{
|
{
|
||||||
NetProgressTicker++;
|
NetProgressTicker++;
|
||||||
}
|
}
|
||||||
else
|
else if (count > 0)
|
||||||
{
|
{
|
||||||
NetProgressTicker = count;
|
NetProgressTicker = count;
|
||||||
}
|
}
|
||||||
if (NetProgressMax == 0)
|
if (NetProgressMax == 0)
|
||||||
{
|
{
|
||||||
// Spinny-type progress meter, because we're a guest.
|
// Spinny-type progress meter, because we're a guest waiting for the host.
|
||||||
printf ("%c\b", SpinnyProgressChars[NetProgressTicker & 7]);
|
fprintf (stderr, "\r%s: %c", NetMessage, SpinnyProgressChars[NetProgressTicker & 7]);
|
||||||
|
fflush (stderr);
|
||||||
}
|
}
|
||||||
else if (NetProgressMax > 1)
|
else if (NetProgressMax > 1)
|
||||||
{
|
{
|
||||||
// Dotty-type progress meter, because we're a host.
|
// Dotty-type progress meter.
|
||||||
printf (".%*c[%2d/%2d]", MAXPLAYERS + 1 - NetProgressTicker, NetProgressMax);
|
fprintf (stderr, "\r%s: ", NetMessage);
|
||||||
printf ("\b\b\b\b\b\b\b");
|
for (i = 0; i < NetProgressTicker; ++i)
|
||||||
for (i = NetProgressTicker; i < MAXPLAYERS + 1; ++i)
|
|
||||||
{
|
{
|
||||||
printf ("\b");
|
fputc ('.', stderr);
|
||||||
}
|
}
|
||||||
|
fprintf (stderr, "%*c[%2d/%2d]", NetProgressMax + 1 - NetProgressTicker, ' ', NetProgressTicker, NetProgressMax);
|
||||||
|
fflush (stderr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,15 +155,15 @@ bool ST_NetLoop(bool (*timer_callback)(void *), void *userdata)
|
||||||
int retval;
|
int retval;
|
||||||
char k;
|
char k;
|
||||||
|
|
||||||
FD_ZERO (&rfds);
|
|
||||||
FD_SET (STDIN_FILENO, &rfds);
|
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
// Don't flood the network with packets on startup.
|
// Don't flood the network with packets on startup.
|
||||||
tv.tv_sec = 0;
|
tv.tv_sec = 0;
|
||||||
tv.tv_usec = 500000;
|
tv.tv_usec = 500000;
|
||||||
|
|
||||||
|
FD_ZERO (&rfds);
|
||||||
|
FD_SET (STDIN_FILENO, &rfds);
|
||||||
|
|
||||||
retval = select (1, &rfds, NULL, NULL, &tv);
|
retval = select (1, &rfds, NULL, NULL, &tv);
|
||||||
|
|
||||||
if (retval == -1)
|
if (retval == -1)
|
||||||
|
@ -149,6 +174,7 @@ bool ST_NetLoop(bool (*timer_callback)(void *), void *userdata)
|
||||||
{
|
{
|
||||||
if (timer_callback (userdata))
|
if (timer_callback (userdata))
|
||||||
{
|
{
|
||||||
|
fputc ('\n', stderr);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -157,7 +183,7 @@ bool ST_NetLoop(bool (*timer_callback)(void *), void *userdata)
|
||||||
// Check input on stdin
|
// Check input on stdin
|
||||||
if (k == 'q' || k == 'Q')
|
if (k == 'q' || k == 'Q')
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Network game synchronization aborted.");
|
fprintf (stderr, "\nNetwork game synchronization aborted.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,5 +39,6 @@ extern void ST_Done();
|
||||||
extern void ST_Progress();
|
extern void ST_Progress();
|
||||||
extern void ST_NetInit(const char *message, int numplayers);
|
extern void ST_NetInit(const char *message, int numplayers);
|
||||||
extern void ST_NetProgress(int count);
|
extern void ST_NetProgress(int count);
|
||||||
|
extern void ST_NetMessage(const char *format, ...); // cover for printf()
|
||||||
extern void ST_NetDone();
|
extern void ST_NetDone();
|
||||||
extern bool ST_NetLoop(bool (*timer_callback)(void *), void *userdata);
|
extern bool ST_NetLoop(bool (*timer_callback)(void *), void *userdata);
|
||||||
|
|
Loading…
Reference in a new issue