From 5be3b76e85f32f11cc5cd99abc255d8eec556e24 Mon Sep 17 00:00:00 2001 From: terminx Date: Tue, 11 Nov 2008 13:45:12 +0000 Subject: [PATCH] git-svn-id: https://svn.eduke32.com/eduke32@1125 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/mmulti.c | 93 ------------------ polymer/eduke32/build/src/mmulti_unstable.c | 30 ++++-- polymer/eduke32/source/game.c | 103 +++++++++++++++++++- 3 files changed, 122 insertions(+), 104 deletions(-) diff --git a/polymer/eduke32/build/src/mmulti.c b/polymer/eduke32/build/src/mmulti.c index 966ebee39..f81404871 100644 --- a/polymer/eduke32/build/src/mmulti.c +++ b/polymer/eduke32/build/src/mmulti.c @@ -914,96 +914,3 @@ int getexternaladdress(char *buffer, const char *host, int port) Bmemcpy(buffer,&ipaddr,j); return(1); } - -#ifdef _WIN32 -int getversionfromwebsite(char *buffer) // FIXME: this probably belongs in game land -{ - int bytes_sent, i=0, j=0; - struct sockaddr_in dest_addr; - struct hostent *h; - char *host = "eduke32.sourceforge.net"; - char *req = "GET http://eduke32.sourceforge.net/VERSION HTTP/1.0\r\n\r\n"; - char tempbuf[2048],otherbuf[16],ver[16]; - -#ifdef _WIN32 - if (wsainitialized == 0) - { - WSADATA ws; - - if (WSAStartup(0x101,&ws) == SOCKET_ERROR) - { - initprintf("update: Winsock error in getversionfromwebsite() (%d)\n",errno); - return(0); - } - wsainitialized = 1; - } -#endif - - if ((h=gethostbyname(host)) == NULL) - { - initprintf("update: gethostbyname() error in getversionfromwebsite() (%d)\n",h_errno); - return(0); - } - - dest_addr.sin_addr.s_addr = ((struct in_addr *)(h->h_addr))->s_addr; - dest_addr.sin_family = AF_INET; - dest_addr.sin_port = htons(80); - - memset(&(dest_addr.sin_zero), '\0', 8); - - - mysock = socket(PF_INET, SOCK_STREAM, 0); - - if (mysock == INVALID_SOCKET) - { - initprintf("update: socket() error in getversionfromwebsite() (%d)\n",errno); - return(0); - } - initprintf("Connecting to \"http://%s\"\n",host); - if (connect(mysock, (struct sockaddr *)&dest_addr, sizeof(struct sockaddr)) == SOCKET_ERROR) - { - initprintf("update: connect() error in getversionfromwebsite() (%d)\n",errno); - return(0); - } - - bytes_sent = send(mysock, req, strlen(req), 0); - if (bytes_sent == SOCKET_ERROR) - { - initprintf("update: send() error in getversionfromwebsite() (%d)\n",errno); - return(0); - } - - // initprintf("sent %d bytes\n",bytes_sent); - recv(mysock, (char *)&tempbuf, sizeof(tempbuf), 0); - closesocket(mysock); - - memcpy(&otherbuf,&tempbuf,sizeof(otherbuf)); - - strtok(otherbuf," "); - if (atol(strtok(NULL," ")) == 200) - { - for (i=0;(unsigned)i 4) - if (tempbuf[i-1] == '\n' && tempbuf[i-2] == '\r' && tempbuf[i-3] == '\n' && tempbuf[i-4] == '\r') - { - while (j < 9) - { - ver[j] = tempbuf[i]; - i++, j++; - } - ver[j] = '\0'; - break; - } - } - - if (j) - { - strcpy(buffer,ver); - return(1); - } - } - return(0); -} -#endif diff --git a/polymer/eduke32/build/src/mmulti_unstable.c b/polymer/eduke32/build/src/mmulti_unstable.c index 8b219df17..b1883d8e8 100644 --- a/polymer/eduke32/build/src/mmulti_unstable.c +++ b/polymer/eduke32/build/src/mmulti_unstable.c @@ -15,6 +15,7 @@ #include "mmulti_unstable.h" #include "enet/enet.h" #include "compat.h" +#include "baselayer.h" //STL @@ -169,6 +170,11 @@ void initmultiplayers(int argc, char **argv, char damultioption, char dacomrateo { long i; + UNREFERENCED_PARAMETER(argc); + UNREFERENCED_PARAMETER(damultioption); + UNREFERENCED_PARAMETER(dacomrateoption); + UNREFERENCED_PARAMETER(dapriority); + initcrc(); for(i=0;i -# define EAGAIN WSAEWOULDBLOCK # define EWOULDBLOCK WSAEWOULDBLOCK # define ECONNREFUSED WSAECONNRESET # define socklen_t size_t @@ -637,7 +645,6 @@ void deinit_network_transport(gcomtype *gcom) #include #include "cache1d.h" /* kopen4load for cfg file. */ -#include "baselayer.h" /* getticks */ #define IPSEG1(ip) ((((unsigned int) ip) & 0xFF000000) >> 24) #define IPSEG2(ip) ((((unsigned int) ip) & 0x00FF0000) >> 16) @@ -660,6 +667,7 @@ static struct { volatile int ctrlc_pressed = 0; static void siginthandler(int sigint) { + UNREFERENCED_PARAMETER(sigint); ctrlc_pressed = 1; } @@ -766,7 +774,7 @@ static int get_udp_packet(int *ip, short *_port, void *pkt, size_t pktsize) /* FIXME: Will this ever receive a partial packet? */ int rc = recvfrom(udpsocket, pkt, pktsize, 0, - (struct sockaddr *) &addr, (int *)&fromlen); + (struct sockaddr *) &addr, (unsigned int *)&fromlen); if (rc == -1) err = neterrno(); @@ -887,7 +895,7 @@ static char *read_whole_file(const char *cfgfile) if (cfgfile == NULL) return(NULL); - handle = kopen4load(cfgfile, 0); + handle = kopen4load((char *)cfgfile, 0); if (handle == -1) { initprintf("ERROR: Failed to open config file [%s].\n", cfgfile); @@ -951,7 +959,7 @@ static int set_socket_blockmode(int onOrOff) rc = (ioctlsocket(udpsocket, FIONBIO, &flags) == 0); #else flags = fcntl(udpsocket, F_GETFL, 0); - if (flags != -1) + if ((signed)flags != -1) { if (onOrOff) flags &= ~O_NONBLOCK; @@ -996,7 +1004,7 @@ static int open_udp_socket(int ip, int port) initprintf("Stun is currently %s\n", (natfree) ? "Enabled":"Disabled"); udpsocket = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); - if (udpsocket == -1) + if ((signed)udpsocket == -1) { initprintf("socket creation failed: %s\n", netstrerror()); return(0); @@ -1029,6 +1037,9 @@ static int open_udp_socket(int ip, int port) /* server init. */ static int wait_for_other_players(gcomtype *gcom, int myip) { + UNREFERENCED_PARAMETER(gcom); + UNREFERENCED_PARAMETER(myip); + initprintf("Server code NOT implemented!\n"); return(0); } @@ -1036,6 +1047,9 @@ static int wait_for_other_players(gcomtype *gcom, int myip) /* client init. */ static int connect_to_server(gcomtype *gcom, int myip) { + UNREFERENCED_PARAMETER(gcom); + UNREFERENCED_PARAMETER(myip); + initprintf("Client code NOT implemented!\n"); return(0); } @@ -1581,7 +1595,7 @@ void deinit_network_transport(gcomtype *gcom) free(gcom); } - if (udpsocket != -1) + if ((signed)udpsocket != -1) { initprintf(" ...closing socket...\n"); set_socket_blockmode(1); /* block while socket drains. */ @@ -1601,7 +1615,7 @@ void callcommit(void) int ip, i, rc; short port; - if (udpsocket == -1) + if ((signed)udpsocket == -1) return; process_udp_send_queue(); diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index b0f74b53d..71d0427e9 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -48,12 +48,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN #undef UNREFERENCED_PARAMETER -#ifndef ENET_NETWORKING #include #include +#include +#include extern int getversionfromwebsite(char *buffer); #define UPDATEINTERVAL 604800 // 1w -#endif #else static int usecwd = 0; #endif /* _WIN32 */ @@ -74,7 +74,9 @@ static int g_NoSound = 0; static int g_NoMusic = 0; static char *CommandMap = NULL; static char *CommandName = NULL; +#ifndef ENET_NETWORKING static char *CommandNet = NULL; +#endif static int g_KeepAddr = 0; int CommandWeaponChoice = 0; static struct strllist @@ -168,6 +170,101 @@ unsigned int g_FrameDelay = 0; extern char forcegl; #endif +#ifdef _WIN32 +int getversionfromwebsite(char *buffer) // FIXME: this probably belongs in game land +{ + int wsainitialized = 0; + int bytes_sent, i=0, j=0; + struct sockaddr_in dest_addr; + struct hostent *h; + char *host = "eduke32.sourceforge.net"; + char *req = "GET http://eduke32.sourceforge.net/VERSION HTTP/1.0\r\n\r\n"; + char tempbuf[2048],otherbuf[16],ver[16]; + SOCKET mysock; + +#ifdef _WIN32 + if (wsainitialized == 0) + { + WSADATA ws; + + if (WSAStartup(0x101,&ws) == SOCKET_ERROR) + { + initprintf("update: Winsock error in getversionfromwebsite() (%d)\n",errno); + return(0); + } + wsainitialized = 1; + } +#endif + + if ((h=gethostbyname(host)) == NULL) + { + initprintf("update: gethostbyname() error in getversionfromwebsite() (%d)\n",h_errno); + return(0); + } + + dest_addr.sin_addr.s_addr = ((struct in_addr *)(h->h_addr))->s_addr; + dest_addr.sin_family = AF_INET; + dest_addr.sin_port = htons(80); + + memset(&(dest_addr.sin_zero), '\0', 8); + + + mysock = socket(PF_INET, SOCK_STREAM, 0); + + if (mysock == INVALID_SOCKET) + { + initprintf("update: socket() error in getversionfromwebsite() (%d)\n",errno); + return(0); + } + initprintf("Connecting to \"http://%s\"\n",host); + if (connect(mysock, (struct sockaddr *)&dest_addr, sizeof(struct sockaddr)) == SOCKET_ERROR) + { + initprintf("update: connect() error in getversionfromwebsite() (%d)\n",errno); + return(0); + } + + bytes_sent = send(mysock, req, strlen(req), 0); + if (bytes_sent == SOCKET_ERROR) + { + initprintf("update: send() error in getversionfromwebsite() (%d)\n",errno); + return(0); + } + + // initprintf("sent %d bytes\n",bytes_sent); + recv(mysock, (char *)&tempbuf, sizeof(tempbuf), 0); + closesocket(mysock); + + memcpy(&otherbuf,&tempbuf,sizeof(otherbuf)); + + strtok(otherbuf," "); + if (atol(strtok(NULL," ")) == 200) + { + for (i=0;(unsigned)i 4) + if (tempbuf[i-1] == '\n' && tempbuf[i-2] == '\r' && tempbuf[i-3] == '\n' && tempbuf[i-4] == '\r') + { + while (j < 9) + { + ver[j] = tempbuf[i]; + i++, j++; + } + ver[j] = '\0'; + break; + } + } + + if (j) + { + strcpy(buffer,ver); + return(1); + } + } + return(0); +} +#endif + int kopen4loadfrommod(char *filename, char searchfirst) { static char fn[BMAX_PATH]; @@ -8831,6 +8928,7 @@ static void comlinehelp(void) #endif } +#ifndef ENET_NETWORKING static signed int rancid_players = 0; static char rancid_ip_strings[MAXPLAYERS][32], rancid_local_port_string[8]; @@ -8911,7 +9009,6 @@ static inline int stringsort(const char *p1, const char *p2) return Bstrcmp(&p1[0],&p2[0]); } -#ifndef ENET_NETWORKING // Not supported with the enet network backend currently static void setup_rancid_net(const char *fn) {