git-svn-id: https://svn.eduke32.com/eduke32@1133 1a8010ca-5511-0410-912e-c29ae57300e0

This commit is contained in:
terminx 2008-11-14 11:04:22 +00:00
parent d79f544c22
commit 1636f68c0d
4 changed files with 25 additions and 31 deletions

View file

@ -62,10 +62,10 @@ GCC_MINOR := $(shell $(CC) -dumpversion 2>&1 | cut -d'.' -f2)
ifeq (4,$(GCC_MAJOR)) ifeq (4,$(GCC_MAJOR))
ifneq (0,$(GCC_MINOR)) ifneq (0,$(GCC_MINOR))
debug += -ftree-vectorize # debug += -ftree-vectorize
ifneq (1,$(GCC_MINOR)) ifneq (1,$(GCC_MINOR))
ifneq (2,$(GCC_MINOR)) ifneq (2,$(GCC_MINOR))
debug += -finline-small-functions -fpredictive-commoning # debug += -finline-small-functions -fpredictive-commoning
endif endif
endif endif
endif endif

View file

@ -79,12 +79,12 @@ GCC_MAJOR := $(shell $(CC) -dumpversion 2>&1 | cut -d'.' -f1)
GCC_MINOR := $(shell $(CC) -dumpversion 2>&1 | cut -d'.' -f2) GCC_MINOR := $(shell $(CC) -dumpversion 2>&1 | cut -d'.' -f2)
ifeq (4,$(GCC_MAJOR)) ifeq (4,$(GCC_MAJOR))
debug += -ftree-vectorize # debug += -ftree-vectorize
ifneq (0,$(GCC_MINOR)) ifneq (0,$(GCC_MINOR))
ifneq (1,$(GCC_MINOR)) ifneq (1,$(GCC_MINOR))
ifneq (2,$(GCC_MINOR)) ifneq (2,$(GCC_MINOR))
# this should only enable for 4.3.0 and later # this should only enable for 4.3.0 and later
debug += -finline-small-functions -fpredictive-commoning # debug += -finline-small-functions -fpredictive-commoning
endif endif
endif endif
endif endif

View file

@ -628,12 +628,12 @@ void genericmultifunction(int other, char *bufptr, int messleng, int command)
#define HEADER_PEER_GREETING 245 #define HEADER_PEER_GREETING 245
static sockettype udpsocket = -1; static sockettype udpsocket = -1;
static short udpport = BUILD_DEFAULT_UDP_PORT; static unsigned short udpport = BUILD_DEFAULT_UDP_PORT;
static struct static struct
{ {
int host; int host;
short port; unsigned short port;
} allowed_addresses[MAX_PLAYERS]; /* only respond to these IPs. */ } allowed_addresses[MAX_PLAYERS]; /* only respond to these IPs. */
#if PLATFORM_WIN32 #if PLATFORM_WIN32
@ -684,7 +684,7 @@ static char *static_ipstring(int ip)
} }
static int send_udp_packet(int ip, short port, void *pkt, size_t pktsize) static int send_udp_packet(int ip, unsigned short port, void *pkt, size_t pktsize)
{ {
/* !!! FIXME: See if this would ever block. */ /* !!! FIXME: See if this would ever block. */
/* !!! FIXME: See if this would send a partial packet. */ /* !!! FIXME: See if this would send a partial packet. */
@ -718,11 +718,11 @@ static void process_udp_send_queue(void)
} }
static int get_udp_packet(int *ip, short *_port, void *pkt, size_t pktsize) static int get_udp_packet(int *ip, unsigned short *_port, void *pkt, size_t pktsize)
{ {
int err = 0; int err = 0;
struct sockaddr_in addr; struct sockaddr_in addr;
short port; unsigned short port;
socklen_t fromlen = sizeof(addr); socklen_t fromlen = sizeof(addr);
int valid = 0; int valid = 0;
int i; int i;
@ -1007,7 +1007,7 @@ typedef struct
} PacketPeerGreeting; } PacketPeerGreeting;
static void send_peer_greeting(int ip, short port, short myid) static void send_peer_greeting(int ip, unsigned short port, short myid)
{ {
PacketPeerGreeting packet; PacketPeerGreeting packet;
memset(&packet, '\0', sizeof(packet)); memset(&packet, '\0', sizeof(packet));
@ -1024,7 +1024,7 @@ static int wait_for_other_players(gcomtype *gcom, int myip)
int i, j; int i, j;
int rc; int rc;
int ip; int ip;
short port; unsigned short port;
unsigned short heard_from[MAX_PLAYERS]; unsigned short heard_from[MAX_PLAYERS];
int max; int max;
int remaining; int remaining;
@ -1084,7 +1084,7 @@ static int wait_for_other_players(gcomtype *gcom, int myip)
remaining--; remaining--;
initprintf("%s:%i (id 0x%X) connected, %d player%s left.\n", initprintf("%s:%i (id 0x%X) connected, %d player%s left.\n",
ipstr, port ,(int) packet.id, ipstr, (unsigned)port ,(int) packet.id,
remaining, remaining == 1 ? "" : "s"); remaining, remaining == 1 ? "" : "s");
/* make sure they've heard from us at all... */ /* make sure they've heard from us at all... */
@ -1212,7 +1212,7 @@ static int connect_to_server(gcomtype *gcom, int myip)
int i; int i;
int rc; int rc;
int ip; int ip;
short port; unsigned short port;
int first_send = 1; int first_send = 1;
unsigned short heard_from[MAX_PLAYERS]; unsigned short heard_from[MAX_PLAYERS];
unsigned int resendat; unsigned int resendat;
@ -1305,7 +1305,7 @@ static int connect_to_server(gcomtype *gcom, int myip)
// allowed_addresses[i].port = port; // allowed_addresses[i].port = port;
initprintf("Connected to %s:%i\n", initprintf("Connected to %s:%i\n",
ipstr, port); ipstr, (unsigned)port);
initprintf("Waiting for server to launch game\n"); initprintf("Waiting for server to launch game\n");
} }
else else
@ -1414,7 +1414,7 @@ static int connect_to_everyone(gcomtype *gcom, int myip, int bcast)
int i; int i;
int rc; int rc;
int ip; int ip;
short port; unsigned short port;
int first_send = 1; int first_send = 1;
unsigned short heard_from[MAX_PLAYERS]; unsigned short heard_from[MAX_PLAYERS];
unsigned int resendat; unsigned int resendat;
@ -1583,7 +1583,7 @@ static int connect_to_everyone(gcomtype *gcom, int myip, int bcast)
allowed_addresses[i].port = port; allowed_addresses[i].port = port;
remaining--; remaining--;
initprintf("Connected to %s:%i (id 0x%X). %d player%s to go.\n", initprintf("Connected to %s:%i (id 0x%X). %d player%s left.\n",
ipstr, port ,(int) packet.id, ipstr, port ,(int) packet.id,
remaining, remaining == 1 ? "" : "s"); remaining, remaining == 1 ? "" : "s");
@ -1716,7 +1716,7 @@ static int parse_ip(const char *str, int *ip)
return(1); return(1);
} }
static int parse_interface(char *str, int *ip, short *udpport) static int parse_interface(char *str, int *ip, unsigned short *udpport)
{ {
char *ptr = strchr(str, ':'); char *ptr = strchr(str, ':');
if (ptr) /* portnum specified? */ if (ptr) /* portnum specified? */
@ -1857,8 +1857,7 @@ static int parse_udp_config(int argc, char **argv, gcomtype *gcom)
udpmode = udpmode_server; udpmode = udpmode_server;
gcom->numplayers = (argv[i][4]-'0'); gcom->numplayers = (argv[i][4]-'0');
if ((argv[i][5] >= '0') && (argv[i][5] <= '9')) gcom->numplayers = gcom->numplayers*10+(argv[i][5]-'0'); if ((argv[i][5] >= '0') && (argv[i][5] <= '9')) gcom->numplayers = gcom->numplayers*10+(argv[i][5]-'0');
gcom->numplayers--; initprintf("mmulti_unstable: %d-player game server\n", gcom->numplayers--);
initprintf("mmulti_unstable: %d-player game server\n", gcom->numplayers);
} }
initprintf("mmulti_unstable: Master-slave mode\n"); initprintf("mmulti_unstable: Master-slave mode\n");
} }
@ -1971,7 +1970,7 @@ static int parse_udp_config(int argc, char **argv, gcomtype *gcom)
else if (Bstrcasecmp(tok, "allow") == 0) else if (Bstrcasecmp(tok, "allow") == 0)
{ {
int host; int host;
short port=BUILD_DEFAULT_UDP_PORT; unsigned short port=BUILD_DEFAULT_UDP_PORT;
if ((tok = get_token(&ptr)) != NULL) if ((tok = get_token(&ptr)) != NULL)
{ {
if (gcom->numplayers >= MAX_PLAYERS - 1) if (gcom->numplayers >= MAX_PLAYERS - 1)
@ -2090,7 +2089,7 @@ void deinit_network_transport(gcomtype *gcom)
void callcommit(void) void callcommit(void)
{ {
int ip, i, rc; int ip, i, rc;
short port; unsigned short port;
if ((signed)udpsocket == -1) if ((signed)udpsocket == -1)
return; return;

View file

@ -1520,14 +1520,12 @@ void waitforeverybody()
while (1) while (1)
{ {
#ifdef _WIN32 idle();
Sleep(10); /*
#else
usleep(10);
#endif
sampletimer(); sampletimer();
handleevents(); handleevents();
AudioUpdate(); AudioUpdate();
*/
if (quitevent || keystatus[1]) gameexit(""); if (quitevent || keystatus[1]) gameexit("");
@ -1537,11 +1535,8 @@ void waitforeverybody()
{ {
if (g_player[i].playerreadyflag < g_player[myconnectindex].playerreadyflag) break; if (g_player[i].playerreadyflag < g_player[myconnectindex].playerreadyflag) break;
if ((!networkmode) && (myconnectindex != connecthead)) if ((!networkmode) && (myconnectindex != connecthead))
{ return;
i = -1; //slaves in M/S mode only wait for master
break;
} //slaves in M/S mode only wait for master
} }
if (i < 0) return; if (i < 0) return;
} }