diff --git a/CHANGELOG.txt b/CHANGELOG.txt index f4c1e65ab..97ba775bf 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,5 +1,9 @@ D2X-Rebirth Changelog +20091124 +-------- +include/args.h, INSTALL.txt, main/net_udp.c, main/net_udp.h, main/fireball.c, main/multi.c, main/multibot.c, main/multi.h, main/inferno.c, main/menu.c, main/object.c, main/kmatrix.c, main/kmatrix.h, main/newdemo.c, main/config.c, main/net_ipx.c, main/config.h, main/net_ipx.h, main/gamerend.c, main/gameseq.c, main/endlevel.c, main/vers_id.h, main/game.c, main/gauges.c, misc/args.c, SConstruct, d2x.ini, README.txt, arch/linux/ipx.c, arch/linux/ipx_kali.c, arch/win32/ipx.c: Abstracting networking protocols - Step 4: Implemented new UDP layer with Client/Server communication, Packet Loss Prevention and strict Version checking. Netgames list will follow later. + 20091117 -------- arch/ogl/gr.c, arch/sdl/gr.c, include/gr.h, main/menu.c, main/piggy.c: Only list resolutions that can actually be used, using new gr_check_mode diff --git a/INSTALL.txt b/INSTALL.txt index f06f0e1f1..3caa252df 100644 --- a/INSTALL.txt +++ b/INSTALL.txt @@ -26,19 +26,6 @@ For Mac OS X, an Xcode project is available (requires Xcode 2.1 or later). Xcode The SConstruct file provides various options to compile this program. To get a full list of all available commands, type scons -h within the Source directory. -Currently, the following variables are supported: - -'sharepath=DIR' (non-Mac OS *NIX only) use DIR for shared game data. (default: /usr/local/share/games/d2x-rebirth) -'sdl_only=1' don't include OpenGL, use SDL-only instead -'sdlmixer=1' use SDL_Mixer for sound (includes external music support) -'asm=1' use ASSEMBLER code (only with sdl_only=1, requires NASM and x86) -'debug=1' build DEBUG binary which includes asserts, debugging output, cheats and more output -'profiler=1' do profiler build -'editor=1' build editor !EXPERIMENTAL! -'arm=1' compile for ARM architecture - -‘editor’ is currently *not* supported and will not work. - To compile the source, type: scons diff --git a/README.txt b/README.txt index ff944d628..506e275cc 100644 --- a/README.txt +++ b/README.txt @@ -53,13 +53,10 @@ See INSTALL.txt. 3. Multiplayer -DXX-Rebirth supports Multiplayer over (obsoleted) IPX and UDP/IP. -Using UDP/IP works over LAN and Internet. Since the Networking code of the Descent Engine is Peer-to-Peer, it is necessary for -all players (Host and Clients) to open port UDP 31017. -Clients can put an offset to this port by using '-ip_baseport OFFSET'. -Hosts can also use option '-ip_relay' to route players with closed ports. Use this with caution. It will increase Lag and Ping drastically. -Also game summary will not refresh correctly for relay-players until Host has escaped the level as well. -UDP/IP also supports IPv6 by compiling the game with the designated flag. Please note IPv4- and IPv6-builds cannot play together. +D2X-Rebirth supports Multiplayer over (obsoleted) IPX and UDP/IP. +Please note that UDP/IP generally supports more features of D2X-Rebirth and uses Packet Loss Prevention while IPX is mainly meant to play together with non-D1X-Rebirth games. +Using UDP/IP works over LAN and Internet. By default, each game communicates over UDP-Port 42424. This can be changed via the menus while creating a game and manually join a game, command-line argument or D2X.INI. To successfully host a game online, make sure UDP-Port 42424 (or otherwise if specified correctly) is opened on your Router/Firewall. Clients do not need to open any ports. +The game also supports IPv6 if built in while compiling and should be backwards compatible to IPv4 builds as good as possible. 4. Legal stuff diff --git a/SConstruct b/SConstruct index 30283737c..e82a387c1 100644 --- a/SConstruct +++ b/SConstruct @@ -125,7 +125,6 @@ common_sources = [ 'main/hostage.c', 'main/hud.c', 'main/inferno.c', -'main/ipxdrv.c', 'main/kconfig.c', 'main/kmatrix.c', 'main/laser.c', @@ -138,6 +137,7 @@ common_sources = [ 'main/multi.c', 'main/multibot.c', 'main/net_ipx.c', +'main/net_udp.c', 'main/newdemo.c', 'main/newmenu.c', 'main/object.c', diff --git a/arch/linux/ipx.c b/arch/linux/ipx.c index 5e0e66502..4d7dcb29b 100644 --- a/arch/linux/ipx.c +++ b/arch/linux/ipx.c @@ -16,7 +16,7 @@ #include #include #include -#include "ipxdrv.h" +#include "net_ipx.h" #include "console.h" static int ipx_get_my_address( void ) diff --git a/arch/linux/ipx_kali.c b/arch/linux/ipx_kali.c index b894c41e4..c10076bb3 100644 --- a/arch/linux/ipx_kali.c +++ b/arch/linux/ipx_kali.c @@ -2,7 +2,7 @@ #include #include #include /* for htons & co. */ -#include "ipxdrv.h" +#include "net_ipx.h" #include "ukali.h" #include "console.h" diff --git a/arch/win32/ipx.c b/arch/win32/ipx.c index 42079b14d..35f767d5c 100644 --- a/arch/win32/ipx.c +++ b/arch/win32/ipx.c @@ -4,7 +4,7 @@ #include #include #include -#include "ipxdrv.h" +#include "net_ipx.h" #include "console.h" static int ipx_get_my_address( void ) diff --git a/d2x.ini b/d2x.ini index 4291dd53f..0192b8240 100644 --- a/d2x.ini +++ b/d2x.ini @@ -42,9 +42,9 @@ ;-norankings Disable multiplayer ranking system ;-playermessages View only messages from other players in multi - overrides -noredundancy ;-ipxnetwork Use IPX network number -;-ip_baseport Use

as offset from normal port -;-ip_relay Relay players with closed port over host (increases traffic and lag) -;-ip_hostaddr Use as host ip address +;-udp_hostaddr When manually joining a game use default IP Address to connect to +;-udp_hostport When manually joining a game use default UDP Port to connect to +;-udp_myport When hosting/joining a game use default UDP Port to send packets from Debug (use only if you know what you're doing): diff --git a/include/args.h b/include/args.h index f2880e95c..2b5e3f4cf 100644 --- a/include/args.h +++ b/include/args.h @@ -74,9 +74,9 @@ typedef struct Arg int MplNoRankings; int MplPlayerMessages; const char *MplIpxNetwork; - int MplIpBasePort; - int MplIpRelay; - char *MplIpHostAddr; + const char *MplUdpHostAddr; + int MplUdpHostPort; + int MplUdpMyPort; char *EdiAutoLoad; int EdiSaveHoardData; int EdiMacData; // also used for some read routines in non-editor build diff --git a/include/ipxdrv.h b/include/ipxdrv.h deleted file mode 100644 index 2d4738fb9..000000000 --- a/include/ipxdrv.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * - * IPX-based driver interface - * - */ - -#ifndef _NET_DRV_H -#define _NET_DRV_H - -#include "pstypes.h" - -#ifdef _WIN32 -#include -#else -#include /* for htons & co. */ -#endif - -#define MAX_PACKET_DATA 1500 -#define MAX_DATA_SIZE 542 -#define MAX_IPX_DATA 576 - -#define IPX_DEFAULT_SOCKET 0x5130 - -#define NETPROTO_IPX 1 -#define NETPROTO_KALINIX 2 - -typedef struct IPXAddressStruct { - ubyte Network[4]; - ubyte Node[6]; - ubyte Socket[2]; -} IPXAddress_t; - -typedef struct IPXPacketStructure { - ushort Checksum; - ushort Length; - ubyte TransportControl; - ubyte PacketType; - IPXAddress_t Destination; - IPXAddress_t Source; -} IPXPacket_t; - -typedef struct socket_struct { - ushort socket; - int fd; -} socket_t; - -struct recv_data { - /* all network order */ - ubyte src_network[4]; - ubyte src_node[6]; - ushort src_socket; - ushort dst_socket; - int pkt_type; -}; - -struct net_driver { - int (*open_socket)(socket_t *sk, int port); - void (*close_socket)(socket_t *mysock); - int (*send_packet)(socket_t *mysock, IPXPacket_t *IPXHeader, ubyte *data, int dataLen); - int (*receive_packet)(socket_t *s, char *buffer, int bufsize, struct recv_data *rec); - int (*packet_ready)(socket_t *s); - int usepacketnum;//we can save 4 bytes - int type; // type of driver (NETPROTO_*). Can be used to make driver-specific rules in other parts of the multiplayer code. -}; - -extern int ipxdrv_general_packet_ready(int fd); -extern void ipxdrv_get_local_target( ubyte * server, ubyte * node, ubyte * local_target ); -extern int ipxdrv_set(int arg); -extern int ipxdrv_change_default_socket( ushort socket_number ); -extern ubyte * ipxdrv_get_my_local_address(); -extern ubyte * ipxdrv_get_my_server_address(); -extern int ipxdrv_get_packet_data( ubyte * data ); -extern void ipxdrv_send_broadcast_packet_data( ubyte * data, int datasize ); -extern void ipxdrv_send_packet_data( ubyte * data, int datasize, ubyte *network, ubyte *address, ubyte *immediate_address ); -extern void ipxdrv_send_internetwork_packet_data( ubyte * data, int datasize, ubyte * server, ubyte *address ); -extern int ipxdrv_type(void); - -#ifndef __APPLE__ -extern struct net_driver ipxdrv_ipx; -#endif -#ifdef __LINUX__ -extern struct net_driver ipxdrv_kali; -#endif - -extern unsigned char MyAddress[10]; -extern ubyte broadcast_addr[]; -extern ubyte null_addr[]; -extern u_int32_t ipx_network; - -#endif /* _NET_DRV_H */ diff --git a/main/config.c b/main/config.c index 1b5dfdc76..e8c2e169d 100644 --- a/main/config.c +++ b/main/config.c @@ -58,7 +58,6 @@ static char *VSyncStr="VSync"; static char *MultisampleStr="Multisample"; static char *JukeboxOnStr="JukeboxOn"; static char *JukeboxPathStr="JukeboxPath"; -static char *IPHostAddrStr="IPHostAddr"; int ReadConfigFile() { @@ -92,7 +91,6 @@ int ReadConfigFile() #else strncpy(GameCfg.JukeboxPath, "::::Jukebox", PATH_MAX+1); #endif - memset(GameCfg.MplIpHostAddr, '\x0', sizeof(GameCfg.MplIpHostAddr)); infile = PHYSFSX_openReadBuffered("descent.cfg"); @@ -162,12 +160,6 @@ int ReadConfigFile() p = strchr( GameCfg.JukeboxPath, '\n'); if ( p ) *p = 0; } - else if (!strcmp(token, IPHostAddrStr)) { - char * p; - strncpy( GameCfg.MplIpHostAddr, value, 128 ); - p = strchr( GameCfg.MplIpHostAddr, '\n'); - if ( p ) *p = 0; - } } } @@ -214,7 +206,6 @@ int WriteConfigFile() PHYSFSX_printf(infile, "%s=%i\n", MultisampleStr, GameCfg.Multisample); PHYSFSX_printf(infile, "%s=%i\n", JukeboxOnStr, GameCfg.JukeboxOn); PHYSFSX_printf(infile, "%s=%s\n", JukeboxPathStr, GameCfg.JukeboxPath); - PHYSFSX_printf(infile, "%s=%s\n", IPHostAddrStr, GameCfg.MplIpHostAddr); PHYSFS_close(infile); diff --git a/main/config.h b/main/config.h index f04b6e2e4..efb3c9e95 100644 --- a/main/config.h +++ b/main/config.h @@ -44,7 +44,6 @@ typedef struct Cfg int Multisample; int JukeboxOn; char JukeboxPath[PATH_MAX+1]; - char MplIpHostAddr[128]; } __pack__ Cfg; extern struct Cfg GameCfg; diff --git a/main/endlevel.c b/main/endlevel.c index 4f599c995..7c8f9557f 100644 --- a/main/endlevel.c +++ b/main/endlevel.c @@ -231,13 +231,6 @@ int start_endlevel_movie() memcpy(gr_palette,save_pal,768); } -#ifdef NETWORK - if (r==MOVIE_NOT_PLAYED && (Game_mode & GM_MULTI)) - Kmatrix_nomovie_message=1; - else - Kmatrix_nomovie_message=0; -#endif - return (r); } diff --git a/main/fireball.c b/main/fireball.c index 7280775fb..8cba939d1 100644 --- a/main/fireball.c +++ b/main/fireball.c @@ -530,7 +530,7 @@ int choose_drop_segment() while ((segnum == -1) && (cur_drop_depth > BASE_NET_DROP_DEPTH/2)) { pnum = (d_rand() * N_players) >> 15; count = 0; - while ((count < N_players) && ((Players[pnum].connected == 0) || (pnum==Player_num) || ((Game_mode & (GM_TEAM|GM_CAPTURE)) && (get_team(pnum)==get_team(Player_num))))) { + while ((count < N_players) && ((Players[pnum].connected == CONNECT_DISCONNECTED) || (pnum==Player_num) || ((Game_mode & (GM_TEAM|GM_CAPTURE)) && (get_team(pnum)==get_team(Player_num))))) { pnum = (pnum+1)%N_players; count++; } diff --git a/main/game.c b/main/game.c index e303ab6e5..864bba6b5 100644 --- a/main/game.c +++ b/main/game.c @@ -1256,9 +1256,6 @@ int game_handler(window *wind, d_event *event, void *data) } if ( (Function_mode != FMODE_GAME ) && (Newdemo_state != ND_STATE_PLAYBACK ) && (Function_mode!=FMODE_EDITOR) -#ifdef NETWORK - && !IWasKicked -#endif ) { int choice, fmode; fmode = Function_mode; @@ -1274,9 +1271,6 @@ int game_handler(window *wind, d_event *event, void *data) Function_mode = FMODE_GAME; } -#ifdef NETWORK - IWasKicked=0; -#endif if (Function_mode != FMODE_GAME) { window_close(wind); diff --git a/main/gamerend.c b/main/gamerend.c index 7fb7668e2..9f70a0d2d 100644 --- a/main/gamerend.c +++ b/main/gamerend.c @@ -176,7 +176,7 @@ void show_netplayerinfo() // general game information y+=LINE_SPACING; - gr_printf(0x8000,y,"%s by %s",Netgame.game_name,Players[multi_who_is_master()].callsign); + gr_printf(0x8000,y,"%s",Netgame.game_name); y+=LINE_SPACING; gr_printf(0x8000,y,"%s - lvl: %i",Netgame.mission_title,Netgame.levelnum); @@ -206,8 +206,6 @@ void show_netplayerinfo() gr_printf(x+FSPACX(8)*18,y,"ping"); gr_printf(x+FSPACX(8)*23,y,"efficiency"); - multi_do_ping_frame(); - // process players table for (i=0; i %s\n", "Use IPX network number "); - printf( " -ip_baseport %s\n", "Use as offset from normal port (allows multiple instances of d1x to be run on a single computer)"); - printf( " -ip_relay %s\n", "Relay players with closed port over host (increases traffic and lag)"); - printf( " -ip_hostaddr %s\n", "Use as host ip address"); + printf( " -udp_hostaddr %s\n", "When manually joining a game use default IP Address to connect to"); + printf( " -udp_hostport %s\n", "When manually joining a game use default UDP Port to connect to"); + printf( " -udp_myport %s\n", "When hosting/joining a game use default UDP Port to send packets from"); #endif // NETWORK #ifdef EDITOR diff --git a/main/ipxdrv.c b/main/ipxdrv.c deleted file mode 100644 index e372c837b..000000000 --- a/main/ipxdrv.c +++ /dev/null @@ -1,360 +0,0 @@ -/* -THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX -SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO -END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A -ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS -IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS -SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE -FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE -CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS -AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. -COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. -*/ - -/* - * - * IPX-based driver interface - * This is the main interface to send packets via arch-dependend IPX-code layers. - * - */ - -#include -#include -#include -#include -#ifdef _MSC_VER -#include -#else -#include -#endif - -#include "config.h" -#include "args.h" -#include "text.h" -#include "net_ipx.h" -#include "console.h" -#include "ipxdrv.h" -#include "checker.h" - -ubyte broadcast_addr[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; -ubyte null_addr[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - -ubyte ipxdrv_installed=0; -u_int32_t ipx_network = 0; -ubyte MyAddress[10]; -int ipx_packetnum = 0; /* Sequence number */ - -/* User defined routing stuff */ -typedef struct user_address { - ubyte network[4]; - ubyte node[6]; - ubyte address[6]; -} user_address; - -socket_t socket_data; -#define MAX_USERS 64 -int Ipx_num_users = 0; -user_address Ipx_users[MAX_USERS]; -#define MAX_NETWORKS 64 -int Ipx_num_networks = 0; -uint Ipx_networks[MAX_NETWORKS]; - -int ipxdrv_general_packet_ready(int fd) -{ - fd_set set; - struct timeval tv; - - FD_ZERO(&set); - FD_SET(fd, &set); - tv.tv_sec = tv.tv_usec = 0; - if (select(fd + 1, &set, NULL, NULL, &tv) > 0) - return 1; - else - return 0; -} - -struct net_driver *driver = NULL; - -ubyte * ipxdrv_get_my_server_address() -{ - return (ubyte *)&ipx_network; -} - -ubyte * ipxdrv_get_my_local_address() -{ - return (ubyte *)(MyAddress + 4); -} - -void ipxdrv_close() -{ - if (ipxdrv_installed) - { -#ifdef _WIN32 - WSACleanup(); -#endif - driver->close_socket(&socket_data); - } - - ipxdrv_installed = 0; -} - -//--------------------------------------------------------------- -// Initializes all driver internals. -// If socket_number==0, then opens next available socket. -// Returns: 0 if successful. -// -1 if socket already open. -// -2 if socket table full. -// -3 if driver not installed. -// -4 if couldn't allocate low dos memory -// -5 if error with getting internetwork address -int ipxdrv_init( int socket_number ) -{ - static int cleanup = 0; -#ifdef _WIN32 - WORD wVersionRequested; - WSADATA wsaData; -#endif - - if (!driver) - return -1; - -#ifdef _WIN32 - wVersionRequested = MAKEWORD(2, 0); - if (WSAStartup( wVersionRequested, &wsaData)) - { - return -1; - } -#endif - memset(MyAddress,0,10); - - if (GameArg.MplIpxNetwork) - { - unsigned long n = strtol(GameArg.MplIpxNetwork, NULL, 16); - MyAddress[0] = n >> 24; MyAddress[1] = (n >> 16) & 255; - MyAddress[2] = (n >> 8) & 255; MyAddress[3] = n & 255; - con_printf(CON_DEBUG,"IPX: Using network %08x\n", (unsigned int)n); - } - - if (driver->open_socket(&socket_data, socket_number)) - { - return -3; - } - - memcpy(&ipx_network, MyAddress, 4); - Ipx_num_networks = 0; - memcpy( &Ipx_networks[Ipx_num_networks++], &ipx_network, 4 ); - - ipxdrv_installed = 1; - - if (!cleanup) - atexit(ipxdrv_close); - cleanup = 1; - - return 0; -} - -int ipxdrv_set(int arg) -{ - int ipxdrv_err; - - ipxdrv_close(); - - con_printf(CON_VERBOSE, "\n%s ", TXT_INITIALIZING_NETWORK); - - switch (arg) - { -#ifndef __APPLE__ - case NETPROTO_IPX: - driver = &ipxdrv_ipx; - break; -#endif -#ifdef __LINUX__ - case NETPROTO_KALINIX: - driver = &ipxdrv_kali; - break; -#endif - default: - driver = NULL; - break; - } - - if ((ipxdrv_err=ipxdrv_init(IPX_DEFAULT_SOCKET))==0) - { - con_printf(CON_VERBOSE, "%s %d.\n", TXT_IPX_CHANNEL, IPX_DEFAULT_SOCKET ); - Network_active = 1; - } - else - { - switch (ipxdrv_err) - { - case 3: - con_printf(CON_VERBOSE, "%s\n", TXT_NO_NETWORK); - break; - case -2: - con_printf(CON_VERBOSE, "%s 0x%x.\n", TXT_SOCKET_ERROR, IPX_DEFAULT_SOCKET); - break; - case -4: - con_printf(CON_VERBOSE, "%s\n", TXT_MEMORY_IPX ); - break; - default: - con_printf(CON_VERBOSE, "%s %d", TXT_ERROR_IPX, ipxdrv_err ); - break; - } - - con_printf(CON_VERBOSE, "%s\n",TXT_NETWORK_DISABLED); - Network_active = 0; // Assume no network - } - - return ipxdrv_installed?0:-1; -} - -int ipxdrv_get_packet_data( ubyte * data ) -{ - struct recv_data rd; - char *buf; - int size; - - if (driver->usepacketnum) - buf=alloca(MAX_IPX_DATA); - else - buf=(char *)data; - - memset(rd.src_network,1,4); - - while (driver->packet_ready(&socket_data)) - { - if ((size = driver->receive_packet(&socket_data, buf, MAX_IPX_DATA, &rd)) > 4) - { - if (!memcmp(rd.src_network, MyAddress, 10)) - { - continue; /* don't get own pkts */ - } - - if (driver->usepacketnum) - { - memcpy(data, buf + 4, size - 4); - return size-4; - } - else - { - return size; - } - } - } - return 0; -} - -void ipxdrv_send_packet_data( ubyte * data, int datasize, ubyte *network, ubyte *address, ubyte *immediate_address ) -{ - IPXPacket_t ipx_header; - - if (!ipxdrv_installed) - return; - - memcpy(ipx_header.Destination.Network, network, 4); - memcpy(ipx_header.Destination.Node, immediate_address, 6); - ipx_header.PacketType = 4; /* Packet Exchange */ - - if (driver->usepacketnum) - { - ubyte buf[MAX_IPX_DATA]; - *(uint *)buf = ipx_packetnum++; - - memcpy(buf + 4, data, datasize); - driver->send_packet(&socket_data, &ipx_header, buf, datasize + 4); - } - else - driver->send_packet(&socket_data, &ipx_header, data, datasize);//we can save 4 bytes -} - -void ipxdrv_get_local_target( ubyte * server, ubyte * node, ubyte * local_target ) -{ - memcpy( local_target, node, 6 ); -} - -void ipxdrv_send_broadcast_packet_data( ubyte * data, int datasize ) -{ - int i, j; - ubyte local_address[6]; - - if (!ipxdrv_installed) - return; - - // Set to all networks besides mine - for (i=0; iclose_socket(&socket_data); - - if (driver->open_socket(&socket_data, socket_number)) - { - return -3; - } - - return 0; -} - -// Return type of net_driver -int ipxdrv_type(void) -{ - return driver->type; -} - diff --git a/main/kmatrix.c b/main/kmatrix.c index 4e7844071..ba25ad041 100644 --- a/main/kmatrix.c +++ b/main/kmatrix.c @@ -14,6 +14,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. /* * * Kill matrix displayed at end of level. + * This source file contains code for both newer networking protocols and IPX. Pretty much redundant stuff but lets keep a clean cut until IPX dies completly. * */ @@ -54,20 +55,19 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #define CENTERING_OFFSET(x) ((300 - (70 + (x)*25 ))/2) #define CENTERSCREEN (SWIDTH/2) -int kmatrix_kills_changed = 0; +/* IPX CODE - START */ + +#define MAX_VIEW_TIME F1_0*15 +#define ENDLEVEL_IDLE_TIME F1_0*10 +fix StartAbortMenuTime; char ConditionLetters[]={' ','P','E','D','E','E','V','W'}; -char WaitingForOthers=0; - -int Kmatrix_nomovie_message=0; - -extern char MaxPowerupsAllowed[],PowerupsInMine[]; extern void newmenu_close(); -void kmatrix_reactor (char *message); -void kmatrix_phallic (); -void kmatrix_redraw_coop(); +void kmatrix_ipx_reactor (char *message); +void kmatrix_ipx_phallic (); +void kmatrix_ipx_redraw_coop(); -void kmatrix_draw_item( int i, int *sorted ) +void kmatrix_ipx_draw_item( int i, int *sorted ) { int j, x, y; char temp[10]; @@ -113,7 +113,7 @@ void kmatrix_draw_item( int i, int *sorted ) gr_printf( x ,y,"%4d/%s",Players[sorted[i]].net_kills_total,temp); } -void kmatrix_draw_coop_item( int i, int *sorted ) +void kmatrix_ipx_draw_coop_item( int i, int *sorted ) { int x, y; @@ -135,17 +135,10 @@ void kmatrix_draw_coop_item( int i, int *sorted ) gr_printf( x, y, "%d", Players[sorted[i]].net_killed_total); } - -void kmatrix_draw_names(int *sorted) +void kmatrix_ipx_draw_names(int *sorted) { int j, x, color; - if (Kmatrix_nomovie_message) - { - gr_set_fontcolor( BM_XRGB(63,0,0),-1 ); - gr_printf( CENTERSCREEN-FSPACX(40), FSPACY(20), "(Movie not played)"); - } - for (j=0; j Netgame.players[i].LastPacketTime+ENDLEVEL_IDLE_TIME) { - Players[i].connected = 0; - multi_send_endlevel_sub(i); + Players[i].connected = CONNECT_DISCONNECTED; } } - // Important: Make sure we keep connected state CONNECT_KMATRIX_WAITING even if player exits kmatrix loop which will change to CONNECT_WAITING! If we don't get all palyer packets in sync and order this condition is very handy to keep all connections alive! - if ((oldstates[i]==CONNECT_END_MENU || oldstates[i]==CONNECT_KMATRIX_WAITING) && (Players[i].connected!=0 || Players[i].connected!=CONNECT_END_MENU || Players[i].connected!=CONNECT_KMATRIX_WAITING)) - Players[i].connected=CONNECT_KMATRIX_WAITING; + // HACK: If a player legally exits kmatrix loop he will send the previous connect byte which can invalidate us from setting him to ready and let us stuck here forever... it's stupid to solve it this way, but for now I have no better idea. + if ((oldstates[i]==CONNECT_END_MENU || oldstates[i]==CONNECT_KMATRIX_WAITING) && // player was viewing scores before... + (Players[i].connected!=CONNECT_DISCONNECTED || Players[i].connected!=CONNECT_END_MENU || Players[i].connected!=CONNECT_KMATRIX_WAITING)) // ... but now he sends neither disconnect or further waiting signal - so he MUST be out of kmatrix already + Players[i].connected=CONNECT_KMATRIX_WAITING; if (Players[i].connected!=oldstates[i]) { if (ConditionLetters[Players[i].connected]!=ConditionLetters[oldstates[i]]) - kmatrix_kills_changed=1; oldstates[i]=Players[i].connected; multi_send_endlevel_packet(); } - if (Players[i].connected==0 || Players[i].connected==CONNECT_KMATRIX_WAITING) + if (Players[i].connected==CONNECT_DISCONNECTED || Players[i].connected==CONNECT_KMATRIX_WAITING) num_ready++; - if (Players[i].connected!=1) + if (Players[i].connected!=CONNECT_PLAYING) num_escaped++; } @@ -590,18 +494,6 @@ void kmatrix_view(int network) done=1; if (num_escaped>=N_players) Countdown_seconds_left=-1; - - if (previous_seconds_left != Countdown_seconds_left) - { - previous_seconds_left=Countdown_seconds_left; - kmatrix_kills_changed=1; - } - - if ( kmatrix_kills_changed ) - { - kmatrix_redraw(); - kmatrix_kills_changed=0; - } } gr_flip(); } @@ -613,7 +505,324 @@ void kmatrix_view(int network) game_flush_inputs(); - Kmatrix_nomovie_message=0; - newmenu_close(); } + +/* IPX CODE - END */ + +/* NEW CODE - START */ + +#define KMATRIX_VIEW_SEC 7 // Time after reactor explosion until new level - in seconds +void kmatrix_phallic (); +void kmatrix_redraw_coop(); + +void kmatrix_draw_item( int i, int *sorted ) +{ + int j, x, y; + char temp[10]; + + y = FSPACY(50+i*9); + gr_printf( FSPACX(CENTERING_OFFSET(N_players)), y, "%s", Players[sorted[i]].callsign ); + + for (j=0; jcv_font = GAME_FONT; + gr_set_fontcolor(gr_find_closest_color(63,63,63),-1); + gr_get_string_size(message, &sw, &sh, &aw); + gr_printf( CENTERSCREEN-(sw/2), FSPACY(55+72+3), message); +} + +void kmatrix_status_msg (fix time, int reactor) +{ + grd_curcanv->cv_font = GAME_FONT; + gr_set_fontcolor(gr_find_closest_color(255,255,255),-1); + + if (reactor) + gr_printf(0x8000, SHEIGHT-LINE_SPACING, "Waiting for players to finish level. Reactor time: T-%d", time); + else + gr_printf(0x8000, SHEIGHT-LINE_SPACING, "Level finished. Wait (%d) to proceed or ESC to Quit.", time); +} + +void kmatrix_redraw() +{ + int i, pcx_error, color; + int sorted[MAX_NUM_NET_PLAYERS]; + + pcx_error = pcx_read_fullscr(STARS_BACKGROUND, gr_palette); + Assert(pcx_error == PCX_ERROR_NONE); + + if (Game_mode & GM_MULTI_COOP) + { + kmatrix_redraw_coop(); + } + else + { + multi_sort_kill_list(); + gr_set_current_canvas(NULL); + grd_curcanv->cv_font = MEDIUM3_FONT; + + if (Game_mode & GM_CAPTURE) + gr_string( 0x8000, FSPACY(10), "CAPTURE THE FLAG SUMMARY"); + else if (Game_mode & GM_HOARD) + gr_string( 0x8000, FSPACY(10), "HOARD SUMMARY"); + else + gr_string( 0x8000, FSPACY(10), TXT_KILL_MATRIX_TITLE); + + grd_curcanv->cv_font = GAME_FONT; + multi_get_kill_list(sorted); + kmatrix_draw_names(sorted); + + for (i=0; icv_font = MEDIUM3_FONT; + gr_string( 0x8000, FSPACY(10), "COOPERATIVE SUMMARY"); + grd_curcanv->cv_font = GAME_FONT; + multi_get_kill_list(sorted); + kmatrix_draw_coop_names(sorted); + + for (i=0; i= end_time && end_time != -1) + done = 1; + + if (playing) + kmatrix_status_msg(Countdown_seconds_left, 1); + else + kmatrix_status_msg(f2i(time-end_time), 0); + + k = key_inkey(); + switch( k ) + { + case KEY_ESC: + if (network) + { + StartAbortMenuTime=timer_get_approx_seconds(); + choice=nm_messagebox1( NULL,multi_endlevel_poll2, 2, TXT_YES, TXT_NO, TXT_ABORT_GAME ); + } + else + choice=nm_messagebox( NULL, 2, TXT_YES, TXT_NO, TXT_ABORT_GAME ); + + if (choice==0) + { + Players[Player_num].connected=CONNECT_DISCONNECTED; + + if (network) + multi_send_endlevel_packet(); + + multi_leave_game(); + longjmp(LeaveGame, 0); + return; + } + break; + + case KEY_PRINT_SCREEN: + save_screen_shot(0); + break; + + default: + break; + } + + gr_flip(); + } + + if (network) + multi_send_endlevel_packet(); // make sure + + game_flush_inputs(); + newmenu_close(); + + if (is_D2_OEM) + { + if (Current_level_num==8) + { + Players[Player_num].connected=CONNECT_DISCONNECTED; + + if (network) + multi_send_endlevel_packet(); + + multi_leave_game(); + longjmp(LeaveGame, 0); + return; + } + } +} + +/* NEW CODE - END */ diff --git a/main/kmatrix.h b/main/kmatrix.h index b46dc5809..09863e56d 100644 --- a/main/kmatrix.h +++ b/main/kmatrix.h @@ -1,4 +1,3 @@ -/* $Id: kmatrix.h,v 1.1.1.1 2006/03/17 19:57:28 zicodxx Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -22,8 +21,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #ifndef _KMATRIX_H #define _KMATRIX_H -extern int kmatrix_kills_changed; - +void kmatrix_ipx_view(int network); void kmatrix_view(int network); #endif /* _KMATRIX_H */ diff --git a/main/menu.c b/main/menu.c index 8cba7b0f0..0119a53ad 100644 --- a/main/menu.c +++ b/main/menu.c @@ -45,11 +45,6 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "text.h" #include "gamefont.h" #include "newmenu.h" -#ifdef NETWORK -# include "net_ipx.h" -# include "ipxdrv.h" -# include "multi.h" -#endif #include "scores.h" #include "playsave.h" #include "kconfig.h" @@ -66,7 +61,11 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "gauges.h" #include "powerup.h" #include "strutil.h" - +#ifdef NETWORK +# include "net_ipx.h" +# include "net_udp.h" +# include "multi.h" +#endif #ifdef EDITOR #include "editor/editor.h" #endif @@ -84,8 +83,6 @@ enum MENUS MENU_SAVE_GAME, MENU_DEMO_PLAY, MENU_LOAD_LEVEL, - MENU_START_IPX_NETGAME, - MENU_JOIN_IPX_NETGAME, MENU_CONFIG, MENU_REJOIN_NETGAME, MENU_DIFFICULTY, @@ -103,12 +100,12 @@ enum MENUS // Only if networking is enabled... #ifdef NETWORK + MENU_START_UDP_NETGAME, + MENU_JOIN_MANUAL_UDP_NETGAME, + MENU_JOIN_LIST_UDP_NETGAME, MENU_START_IPX_NETGAME, MENU_JOIN_IPX_NETGAME, - MENU_BROWSE_UDP_NETGAME, // UDP/IP support - MENU_START_UDP_NETGAME, - MENU_JOIN_UDP_NETGAME, - MENU_START_KALI_NETGAME, // Kali support + MENU_START_KALI_NETGAME, // xKali support (not Windows Kali! Windows Kali is over IPX!) MENU_JOIN_KALI_NETGAME, #endif }; @@ -121,10 +118,7 @@ enum MENUS // Function Prototypes added after LINTING void do_option(int select); void do_new_game_menu(void); -#ifdef NETWORK -void do_multi_player_menu(void); -void do_ip_manual_join_menu(); -#endif //NETWORK +void do_multi_player_menu(); extern void newmenu_close(); extern void ReorderPrimary(); extern void ReorderSecondary(); @@ -337,6 +331,18 @@ void do_option ( int select) #ifdef NETWORK + case MENU_START_UDP_NETGAME: + multi_protocol = MULTI_PROTO_UDP; + net_udp_start_game(); + break; + case MENU_JOIN_MANUAL_UDP_NETGAME: + multi_protocol = MULTI_PROTO_UDP; + net_udp_manual_join_game(); + break; + case MENU_JOIN_LIST_UDP_NETGAME: + multi_protocol = MULTI_PROTO_UDP; + //net_udp_list_join_game(); + break; case MENU_START_IPX_NETGAME: multi_protocol = MULTI_PROTO_IPX; ipxdrv_set(NETPROTO_IPX); @@ -357,12 +363,6 @@ void do_option ( int select) ipxdrv_set(NETPROTO_KALINIX); net_ipx_join_game(); break; - case MENU_START_UDP_NETGAME: - // FIXME - break; - case MENU_JOIN_UDP_NETGAME: - // FIXME - break; case MENU_MULTIPLAYER: do_multi_player_menu(); break; @@ -813,8 +813,8 @@ void do_misc_menu() #ifdef NETWORK void do_multi_player_menu() { - int menu_choice[9]; - newmenu_item m[9]; + int menu_choice[12]; + newmenu_item m[12]; int choice = 0, num_options = 0; int old_game_mode; @@ -822,16 +822,24 @@ void do_multi_player_menu() old_game_mode = Game_mode; num_options = 0; -#ifdef NATIVE_IPX - ADD_ITEM("Start IPX Netgame", MENU_START_IPX_NETGAME, -1); - ADD_ITEM("Join IPX Netgame\n", MENU_JOIN_IPX_NETGAME, -1); -#endif //NATIVE_IPX - ADD_ITEM("Start UDP/IP Netgame", MENU_START_UDP_NETGAME, -1); - ADD_ITEM("Join UDP/IP Netgame\n", MENU_JOIN_UDP_NETGAME, -1); -#ifdef KALINIX - ADD_ITEM("Start Kali Netgame", MENU_START_KALI_NETGAME, -1); - ADD_ITEM("Join Kali Netgame", MENU_JOIN_KALI_NETGAME, -1); -#endif // KALINIX + m[num_options].type=NM_TYPE_TEXT; m[num_options].text="UDP:"; num_options++; + m[num_options].type=NM_TYPE_MENU; m[num_options].text="HOST GAME"; menu_choice[num_options]=MENU_START_UDP_NETGAME; num_options++; + m[num_options].type=NM_TYPE_MENU; m[num_options].text="FIND LAN GAMES"; menu_choice[num_options]=MENU_JOIN_LIST_UDP_NETGAME; num_options++; + //m[num_options].type=NM_TYPE_MENU; m[num_options].text="FIND LAN/ONLINE GAMES"; menu_choice[num_options]=MENU_JOIN_LIST_UDP_NETGAME; num_options++; + m[num_options].type=NM_TYPE_MENU; m[num_options].text="JOIN GAME MANUALLY"; menu_choice[num_options]=MENU_JOIN_MANUAL_UDP_NETGAME; num_options++; + +#ifdef HAVE_NETIPX_IPX_H + m[num_options].type=NM_TYPE_TEXT; m[num_options].text=""; num_options++; + m[num_options].type=NM_TYPE_TEXT; m[num_options].text="IPX:"; num_options++; + m[num_options].type=NM_TYPE_MENU; m[num_options].text="HOST GAME"; menu_choice[num_options]=MENU_START_IPX_NETGAME; num_options++; + m[num_options].type=NM_TYPE_MENU; m[num_options].text="JOIN GAME"; menu_choice[num_options]=MENU_JOIN_IPX_NETGAME; num_options++; +#endif //HAVE_NETIPX_IPX_H +#ifdef __LINUX__ + m[num_options].type=NM_TYPE_TEXT; m[num_options].text=""; num_options++; + m[num_options].type=NM_TYPE_TEXT; m[num_options].text="XKALI:"; num_options++; + m[num_options].type=NM_TYPE_MENU; m[num_options].text="HOST GAME"; menu_choice[num_options]=MENU_START_KALI_NETGAME; num_options++; + m[num_options].type=NM_TYPE_MENU; m[num_options].text="JOIN GAME"; menu_choice[num_options]=MENU_JOIN_KALI_NETGAME; num_options++; +#endif // __LINUX__ choice = newmenu_do1( NULL, TXT_MULTIPLAYER, num_options, m, NULL, choice ); @@ -843,57 +851,6 @@ void do_multi_player_menu() } while( choice > -1 ); } - -void do_ip_manual_join_menu() -{ - int menu_choice[3]; - newmenu_item m[3]; - int choice = 0, num_options = 0, j = 0; - int old_game_mode; - char buf[128]=""; - - if (*GameCfg.MplIpHostAddr) { - sprintf(buf,"%s",GameCfg.MplIpHostAddr); - - for (j=0; buf[j] != '\0'; j++) { - switch (buf[j]) { - case ' ': - buf[j] = '\0'; - } - } - } - - if (*GameArg.MplIpHostAddr) { - sprintf(buf,"%s",GameArg.MplIpHostAddr); - - for (j=0; buf[j] != '\0'; j++) { - switch (buf[j]) { - case ' ': - buf[j] = '\0'; - } - } - } - - do { - old_game_mode = Game_mode; - num_options = 0; - - m[num_options].type = NM_TYPE_INPUT; m[num_options].text=buf; m[num_options].text_len=128;menu_choice[num_options]=-1; num_options++; - - choice = newmenu_do1( NULL, "ENTER IP OR HOSTNAME", num_options, m, NULL, choice ); - - if ( choice > -1 ){ - strncpy(GameCfg.MplIpHostAddr, buf, 128); - // FIXME !! UDPConnectManual(buf); - } - - if (old_game_mode != Game_mode) - { - strncpy(GameCfg.MplIpHostAddr, buf, 128); - break; // leave menu - } - } while( choice > -1 ); -} #endif // NETWORK void do_options_menu() diff --git a/main/multi.c b/main/multi.c index 34b055503..728cf1e4e 100644 --- a/main/multi.c +++ b/main/multi.c @@ -27,6 +27,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "strutil.h" #include "game.h" #include "net_ipx.h" +#include "net_udp.h" #include "multi.h" #include "object.h" #include "laser.h" @@ -148,12 +149,16 @@ int multi_leave_menu = 0; int multi_quit_game = 0; int PacketUrgent = 0; -// For rejoin object syncing +// For rejoin object syncing (used here and all protocols - globally) int Network_send_objects = 0; // Are we in the process of sending objects to a player? +int Network_send_object_mode = 0; // What type of objects are we sending, static or dynamic? int Network_send_objnum = -1; // What object are we sending next? int Network_rejoined = 0; // Did WE rejoin this game? int Network_new_game = 0; // Is this the first level of a new game? +int Network_sending_extras=0; +int Player_joining_extras=-1; // This is so we know who to send 'latecomer' packets to. +int Network_player_added = 0; // Is this a new player or a returning player? ushort my_segments_checksum = 0; @@ -161,6 +166,10 @@ netgame_info Netgame; bitmap_index multi_player_textures[MAX_NUM_NET_PLAYERS][N_PLAYER_SHIP_TEXTURES]; +// Globals for protocol-bound Refuse-functions +char RefuseThisPlayer=0,WaitForRefuseAnswer=0,RefuseTeam,RefusePlayerName[12]; +fix RefuseTimeLimit=0; + typedef struct netplayer_stats { ubyte message_type; ubyte Player_num; // Who am i? @@ -192,7 +201,7 @@ typedef struct netplayer_stats { } netplayer_stats; int message_length[MULTI_MAX_TYPE+1] = { - 24, // POSITION + 25, // POSITION 3, // REAPPEAR 8, // FIRE 5, // KILL @@ -247,7 +256,7 @@ int message_length[MULTI_MAX_TYPE+1] = { 2, // MULTI_CAPTURE_BONUS 2, // MULTI_GOT_FLAG 12, // MULTI_DROP_FLAG - 142, // MULTI_ROBOT_CONTROLS + 1, // MULTI_ROBOT_CONTROLS - UNUSED 2, // MULTI_FINISH_GAME 3, // MULTI_RANK 1, // MULTI_MODEM_PING @@ -301,6 +310,13 @@ int GetMyNetRanking() return (rank+1); } +void ClipRank (ubyte *rank) +{ + // This function insures no crashes when dealing with D2 1.0 + if (*rank > 9) + *rank = 0; +} + // // Functions that replace what used to be macros // @@ -413,25 +429,15 @@ int multi_objnum_is_past(int objnum) case MULTI_PROTO_IPX: return net_ipx_objnum_is_past(objnum); break; + case MULTI_PROTO_UDP: + return net_udp_objnum_is_past(objnum); + break; default: Error("Protocol handling missing in multi_objnum_is_past\n"); break; } } -void multi_do_ping_frame() -{ - switch (multi_protocol) - { - case MULTI_PROTO_IPX: - return net_ipx_ping_all(); - break; - default: - Error("Protocol handling missing in multi_do_ping_frame\n"); - break; - } -} - // // Part 1 : functions whose main purpose in life is to divert the flow // of execution to either network specific code based @@ -450,19 +456,20 @@ multi_endlevel_score(void) if (Game_mode & GM_NETWORK) { old_connect = Players[Player_num].connected; - if (Players[Player_num].connected!=3) + if (Players[Player_num].connected!=CONNECT_DIED_IN_MINE) Players[Player_num].connected = CONNECT_END_MENU; Network_status = NETSTAT_ENDLEVEL; - } #endif - // Do the actual screen we wish to show Function_mode = FMODE_MENU; - kmatrix_view(Game_mode & GM_NETWORK); + if (multi_protocol == MULTI_PROTO_IPX) + kmatrix_ipx_view(Game_mode & GM_NETWORK); + else + kmatrix_view(Game_mode & GM_NETWORK); Function_mode = FMODE_GAME; @@ -473,19 +480,16 @@ multi_endlevel_score(void) Players[Player_num].connected = old_connect; } - -#ifndef SHAREWARE if (Game_mode & GM_MULTI_COOP) { for (i = 0; i < MaxNumNetPlayers; i++) // Reset keys Players[i].flags &= ~(PLAYER_FLAGS_BLUE_KEY | PLAYER_FLAGS_RED_KEY | PLAYER_FLAGS_GOLD_KEY); } + for (i = 0; i < MaxNumNetPlayers; i++) Players[i].flags &= ~(PLAYER_FLAGS_FLAG); // Clear capture flag -#endif - for (i=0;i= 0); - - if (Game_mode & GM_NETWORK) - Assert(buf[0] > 0); if (Game_mode & GM_NETWORK) { switch (multi_protocol) { case MULTI_PROTO_IPX: - net_ipx_send_data((unsigned char *)buf, len, repeat); + net_ipx_send_data((unsigned char *)buf, len, priority); + break; + case MULTI_PROTO_UDP: + net_udp_send_data((unsigned char *)buf, len, priority); break; default: Error("Protocol handling missing in multi_send_data_real\n"); @@ -973,10 +952,10 @@ multi_leave_game(void) if (Game_mode & GM_NETWORK) { Net_create_loc = 0; + multi_send_position(Players[Player_num].objnum); AdjustMineSpawn(); multi_cap_objects(); drop_player_eggs(ConsoleObject); - multi_send_position(Players[Player_num].objnum); multi_send_player_explode(MULTI_PLAYER_DROP); } @@ -989,6 +968,9 @@ multi_leave_game(void) case MULTI_PROTO_IPX: net_ipx_leave_game(); break; + case MULTI_PROTO_UDP: + net_udp_leave_game(); + break; default: Error("Protocol handling missing in multi_leave_game\n"); break; @@ -1024,6 +1006,9 @@ multi_endlevel(int *secret) case MULTI_PROTO_IPX: result = net_ipx_endlevel(secret); break; + case MULTI_PROTO_UDP: + result = net_udp_endlevel(secret); + break; default: Error("Protocol handling missing in multi_endlevel\n"); break; @@ -1032,12 +1017,31 @@ multi_endlevel(int *secret) return(result); } +void multi_endlevel_poll1( int nitems, struct newmenu_item * menus, int * key, int citem ) +{ + switch (multi_protocol) + { + case MULTI_PROTO_IPX: + net_ipx_kmatrix_poll1( nitems, menus, key, citem ); + break; + case MULTI_PROTO_UDP: + net_udp_kmatrix_poll1( nitems, menus, key, citem ); + break; + default: + Error("Protocol handling missing in multi_endlevel_poll1\n"); + break; + } +} + void multi_endlevel_poll2( int nitems, struct newmenu_item * menus, int * key, int citem ) { switch (multi_protocol) { case MULTI_PROTO_IPX: - net_ipx_endlevel_poll2( nitems, menus, key, citem ); + net_ipx_kmatrix_poll2( nitems, menus, key, citem ); + break; + case MULTI_PROTO_UDP: + net_udp_kmatrix_poll2( nitems, menus, key, citem ); break; default: Error("Protocol handling missing in multi_endlevel_poll2\n"); @@ -1045,19 +1049,6 @@ void multi_endlevel_poll2( int nitems, struct newmenu_item * menus, int * key, i } } -void multi_endlevel_poll3( int nitems, struct newmenu_item * menus, int * key, int citem ) -{ - switch (multi_protocol) - { - case MULTI_PROTO_IPX: - net_ipx_endlevel_poll3( nitems, menus, key, citem ); - break; - default: - Error("Protocol handling missing in multi_endlevel_poll3\n"); - break; - } -} - void multi_send_endlevel_packet() { switch (multi_protocol) @@ -1065,25 +1056,15 @@ void multi_send_endlevel_packet() case MULTI_PROTO_IPX: net_ipx_send_endlevel_packet(); break; + case MULTI_PROTO_UDP: + net_udp_send_endlevel_packet(); + break; default: Error("Protocol handling missing in multi_send_endlevel_packet\n"); break; } } -void multi_send_endlevel_sub(int player_num) -{ - switch (multi_protocol) - { - case MULTI_PROTO_IPX: - net_ipx_send_endlevel_sub(player_num); - break; - default: - Error("Protocol handling missing in multi_send_endlevel_sub\n"); - break; - } -} - // // Part 2 : functions that act on network messages and change the // the state of the game in some way. @@ -1114,7 +1095,7 @@ multi_menu_poll(void) // The following three [hackish] lines will go away eventually calc_frame_time(); memset(&Controls,0,sizeof(control_info)); // from game.c (was in below function) - GameProcessFrame(void); + GameProcessFrame(); multi_in_menu--; @@ -1346,6 +1327,9 @@ void multi_send_message_end() case MULTI_PROTO_IPX: net_ipx_send_netgame_update(); break; + case MULTI_PROTO_UDP: + net_udp_send_netgame_update(); + break; default: Error("Protocol handling missing in multi_send_message_end\n"); break; @@ -1417,7 +1401,10 @@ void multi_send_message_end() switch (multi_protocol) { case MULTI_PROTO_IPX: - net_ipx_dump_player(Netgame.players[i].protocol.ipx.server,Netgame.players[i].protocol.ipx.node, 7); + net_ipx_dump_player(Netgame.players[i].protocol.ipx.server,Netgame.players[i].protocol.ipx.node, DUMP_KICKED); + break; + case MULTI_PROTO_UDP: + net_udp_dump_player(Netgame.players[i].protocol.udp.addr, DUMP_KICKED); break; default: Error("Protocol handling missing in multi_send_message_end\n"); @@ -1686,28 +1673,22 @@ multi_do_message(char *buf) void multi_do_position(char *buf) { + ubyte pnum = 0; #ifdef WORDS_BIGENDIAN shortpos sp; #endif - // This routine does only player positions, mode game only - - int pnum = (Player_num+1)%2; - - Assert(&Objects[Players[pnum].objnum] != ConsoleObject); - - if (Game_mode & GM_NETWORK) - { - Int3(); // Get Jason, what the hell are we doing here? + // this is unused in IPX - position is forced within net_ipx_do_frame() + if (multi_protocol == MULTI_PROTO_IPX) return; - } + pnum = buf[1]; #ifndef WORDS_BIGENDIAN - extract_shortpos(&Objects[Players[pnum].objnum], (shortpos *)(buf+1),0); + extract_shortpos(&Objects[Players[pnum].objnum], (shortpos *)(buf + 2),0); #else - memcpy((ubyte *)(sp.bytemat), (ubyte *)(buf + 1), 9); - memcpy((ubyte *)&(sp.xo), (ubyte *)(buf + 10), 14); + memcpy((ubyte *)(sp.bytemat), (ubyte *)(buf + 2), 9); + memcpy((ubyte *)&(sp.xo), (ubyte *)(buf + 11), 14); extract_shortpos(&Objects[Players[pnum].objnum], &sp, 1); #endif @@ -1851,16 +1832,7 @@ multi_do_kill(char *buf) if (killer > 0) killer = objnum_remote_to_local(killer, (sbyte)buf[count+2]); -#ifdef SHAREWARE - if ((Objects[killed].type != OBJ_PLAYER) && (Objects[killed].type != OBJ_GHOST)) - { - Int3(); - return; - } -#endif - multi_compute_kill(killer, killed); - } @@ -1988,6 +1960,9 @@ multi_do_quit(char *buf) case MULTI_PROTO_IPX: net_ipx_disconnect_player(buf[1]); break; + case MULTI_PROTO_UDP: + net_udp_disconnect_player(buf[1]); + break; default: Error("Protocol handling missing in multi_do_quit\n"); break; @@ -2020,10 +1995,8 @@ multi_do_cloak(char *buf) Players[pnum].cloak_time = GameTime; ai_do_cloak_stuff(); -#ifndef SHAREWARE if (Game_mode & GM_MULTI_ROBOTS) multi_strip_robots(pnum); -#endif if (Newdemo_state == ND_STATE_RECORDING) newdemo_record_multi_cloak(pnum); @@ -2290,7 +2263,7 @@ void multi_do_req_player(char *buf) extract_netplayer_stats( &ps, &Players[Player_num] ); ps.Player_num = Player_num; ps.message_type = MULTI_SEND_PLAYER; // SET - multi_send_data((char*)&ps, sizeof(netplayer_stats), 0); + multi_send_data((char*)&ps, sizeof(netplayer_stats), 1); } } @@ -2461,7 +2434,7 @@ multi_send_destroy_controlcen(int objnum, int player) multibuf[0] = (char)MULTI_CONTROLCEN; PUT_INTEL_SHORT(multibuf+1, objnum); multibuf[3] = player; - multi_send_data(multibuf, 4, 2); + multi_send_data(multibuf, 4, 1); } void multi_send_drop_marker (int player,vms_vector position,char messagenum,char text[]) @@ -2497,12 +2470,15 @@ multi_send_endlevel_start(int secret) multi_send_data(multibuf, 3, 1); if (Game_mode & GM_NETWORK) { - Players[Player_num].connected = 5; + Players[Player_num].connected = CONNECT_ESCAPE_TUNNEL; switch (multi_protocol) { case MULTI_PROTO_IPX: net_ipx_send_endlevel_packet(); break; + case MULTI_PROTO_UDP: + net_udp_send_endlevel_packet(); + break; default: Error("Protocol handling missing in multi_send_endlevel_start\n"); break; @@ -2518,8 +2494,6 @@ multi_send_player_explode(char type) Assert( (type == MULTI_PLAYER_DROP) || (type == MULTI_PLAYER_EXPLODE) ); - multi_send_position(Players[Player_num].objnum); - if (Network_send_objects) { Network_send_objnum = -1; @@ -2580,7 +2554,7 @@ multi_send_player_explode(char type) Int3(); // See Rob } - multi_send_data(multibuf, message_length[MULTI_PLAYER_EXPLODE], 2); + multi_send_data(multibuf, message_length[MULTI_PLAYER_EXPLODE], 1); if (Players[Player_num].flags & PLAYER_FLAGS_CLOAKED) multi_send_decloak(); if (Game_mode & GM_MULTI_ROBOTS) @@ -2809,10 +2783,12 @@ multi_send_message(void) void multi_send_reappear() { + multi_send_position(Players[Player_num].objnum); + multibuf[0] = (char)MULTI_REAPPEAR; PUT_INTEL_SHORT(multibuf+1, Players[Player_num].objnum); - multi_send_data(multibuf, 3, 2); + multi_send_data(multibuf, 3, 1); PKilledFlags[Player_num]=0; } @@ -2824,11 +2800,12 @@ multi_send_position(int objnum) #endif int count=0; - if (Game_mode & GM_NETWORK) { + // this is unused in IPX - position is forced within net_ipx_do_frame() + if (multi_protocol == MULTI_PROTO_IPX) return; - } multibuf[count++] = (char)MULTI_POSITION; + multibuf[count++] = (char)Player_num; #ifndef WORDS_BIGENDIAN create_shortpos((shortpos *)(multibuf+count), Objects+objnum,0); count += sizeof(shortpos); @@ -2839,7 +2816,8 @@ multi_send_position(int objnum) memcpy(&(multibuf[count]), (ubyte *)&(sp.xo), 14); count += 14; #endif - + // send twice while first has priority so the next one will be attached to the next bigdata packet + multi_send_data(multibuf, count, 1); multi_send_data(multibuf, count, 0); } @@ -2872,10 +2850,8 @@ multi_send_kill(int objnum) count += 3; multi_send_data(multibuf, count, 1); -#ifndef SHAREWARE if (Game_mode & GM_MULTI_ROBOTS) multi_strip_robots(Player_num); -#endif } void @@ -2941,10 +2917,8 @@ multi_send_cloak(void) multi_send_data(multibuf, 2, 1); -#ifndef SHAREWARE if (Game_mode & GM_MULTI_ROBOTS) multi_strip_robots(Player_num); -#endif } void @@ -2968,13 +2942,12 @@ multi_send_door_open(int segnum, int side,ubyte flag) multibuf[3] = (sbyte)side; multibuf[4] = flag; - multi_send_data(multibuf, 5, 2); + multi_send_data(multibuf, 5, 1); } extern void net_ipx_send_naked_packet (char *,short,int); -void -multi_send_door_open_specific(int pnum,int segnum, int side,ubyte flag) +void multi_send_door_open_specific(int pnum,int segnum, int side,ubyte flag) { // For sending doors only to a specific person (usually when they're joining) @@ -2991,6 +2964,9 @@ multi_send_door_open_specific(int pnum,int segnum, int side,ubyte flag) case MULTI_PROTO_IPX: net_ipx_send_naked_packet(multibuf, 5, pnum); break; + case MULTI_PROTO_UDP: + net_udp_send_mdata_direct((ubyte *)multibuf, 5, pnum, 1); + break; default: Error("Protocol handling missing in multi_send_door_open_specific\n"); break; @@ -3054,6 +3030,8 @@ multi_send_create_powerup(int powerup_type, int segnum, int objnum, vms_vector * #endif int count = 0; + multi_send_position(Players[Player_num].objnum); + if (Game_mode & GM_NETWORK) PowerupsInMine[powerup_type]++; @@ -3072,7 +3050,7 @@ multi_send_create_powerup(int powerup_type, int segnum, int objnum, vms_vector * #endif // ----------- // Total = 19 - multi_send_data(multibuf, count, 2); + multi_send_data(multibuf, count, 1); if (Network_send_objects && multi_objnum_is_past(objnum)) { @@ -3156,7 +3134,6 @@ multi_send_trigger(int triggernum) multibuf[count] = (ubyte)triggernum; count += 1; multi_send_data(multibuf, count, 1); - //multi_send_data(multibuf, count, 1); // twice? } void @@ -3176,11 +3153,30 @@ multi_send_hostage_door_status(int wallnum) multi_send_data(multibuf, count, 0); } -extern int ConsistencyCount; extern int Drop_afterburner_blob_flag; int PhallicLimit=0; int PhallicMan=-1; +void multi_consistency_error(int reset) +{ + static int count = 0; + + if (reset) + count = 0; + + if (++count < 10) + return; + + Function_mode = FMODE_MENU; + nm_messagebox(NULL, 1, TXT_OK, TXT_CONSISTENCY_ERROR); + Function_mode = FMODE_GAME; + count = 0; + multi_quit_game = 1; + multi_leave_menu = 1; + multi_reset_stuff(); + Function_mode = FMODE_MENU; +} + void multi_prep_level(void) { // Do any special stuff to the level required for games @@ -3202,7 +3198,7 @@ void multi_prep_level(void) PhallicLimit=0; PhallicMan=-1; Drop_afterburner_blob_flag=0; - ConsistencyCount=0; + multi_consistency_error(1); for (i=0;ictype.powerup_info.count; @@ -3701,7 +3713,7 @@ void multi_send_drop_weapon (int objnum,int seed) if (Game_mode & GM_NETWORK) PowerupsInMine[objp->id]++; - multi_send_data(multibuf, 12, 2); + multi_send_data(multibuf, 12, 1); } void multi_do_drop_weapon (char *buf) @@ -3835,7 +3847,6 @@ void multi_send_wall_status (int wallnum,ubyte type,ubyte flags,ubyte state) multibuf[count]=flags; count++; multibuf[count]=state; count++; - multi_send_data(multibuf, count, 1); // twice, just to be sure multi_send_data(multibuf, count, 1); } @@ -3860,6 +3871,9 @@ void multi_send_wall_status_specific (int pnum,int wallnum,ubyte type,ubyte flag net_ipx_send_naked_packet(multibuf, count,pnum); // twice, just to be sure net_ipx_send_naked_packet(multibuf, count,pnum); break; + case MULTI_PROTO_UDP: + net_udp_send_mdata_direct((ubyte *)multibuf, count, pnum, 1); + break; default: Error("Protocol handling missing in multi_send_wall_status_specific\n"); break; @@ -4026,6 +4040,9 @@ void multi_send_light_specific (int pnum,int segnum,ubyte val) case MULTI_PROTO_IPX: net_ipx_send_naked_packet(multibuf, count, pnum); break; + case MULTI_PROTO_UDP: + net_udp_send_mdata_direct((ubyte *)multibuf, count, pnum, 1); + break; default: Error("Protocol handling missing in multi_send_light_specific\n"); break; @@ -4125,7 +4142,6 @@ void multi_send_active_door (int i) PUT_INTEL_SHORT(multibuf + count, ActiveDoors[i].back_wallnum[1]); count += 2; PUT_INTEL_INT(multibuf + count, ActiveDoors[i].time); count += 4; #endif - //multi_send_data (multibuf,sizeof(struct active_door)+3,1); multi_send_data (multibuf,count,1); } #endif // 0 (never used) @@ -4174,7 +4190,7 @@ void multi_do_sound_function (char *buf) char pnum,whichfunc; int sound; - if (Players[Player_num].connected!=1) + if (Players[Player_num].connected!=CONNECT_PLAYING) return; pnum=buf[1]; @@ -4216,8 +4232,6 @@ void multi_do_capture_bonus(char *buf) char pnum=buf[1]; int TheGoal; - kmatrix_kills_changed = 1; - if (pnum==Player_num) HUD_init_message("You have Scored!"); else @@ -4276,8 +4290,6 @@ void multi_do_orb_bonus(char *buf) int TheGoal; int bonus=GetOrbBonus (buf[2]); - kmatrix_kills_changed = 1; - if (pnum==Player_num) HUD_init_message("You have scored %d points!",bonus); else @@ -4490,7 +4502,7 @@ void multi_send_drop_flag (int objnum,int seed) if (Game_mode & GM_NETWORK) PowerupsInMine[objp->id]++; - multi_send_data(multibuf, 12, 2); + multi_send_data(multibuf, 12, 1); } void multi_do_drop_flag (char *buf) @@ -4532,63 +4544,6 @@ extern int robot_fired[MAX_ROBOTS_CONTROLLED]; extern sbyte robot_fire_buf[MAX_ROBOTS_CONTROLLED][18+3]; -void multi_send_robot_controls (char pnum) -{ - int count=2; - - multibuf[0]=MULTI_ROBOT_CONTROLS; - multibuf[1]=pnum; - memcpy (&(multibuf[count]),&robot_controlled,MAX_ROBOTS_CONTROLLED*4); - count+=(MAX_ROBOTS_CONTROLLED*4); - memcpy (&(multibuf[count]),&robot_agitation,MAX_ROBOTS_CONTROLLED*4); - count+=(MAX_ROBOTS_CONTROLLED*4); - memcpy (&(multibuf[count]),&robot_controlled_time,MAX_ROBOTS_CONTROLLED*4); - count+=(MAX_ROBOTS_CONTROLLED*4); - memcpy (&(multibuf[count]),&robot_last_send_time,MAX_ROBOTS_CONTROLLED*4); - count+=(MAX_ROBOTS_CONTROLLED*4); - memcpy (&(multibuf[count]),&robot_last_message_time,MAX_ROBOTS_CONTROLLED*4); - count+=(MAX_ROBOTS_CONTROLLED*4); - memcpy (&(multibuf[count]),&robot_send_pending,MAX_ROBOTS_CONTROLLED*4); - count+=(MAX_ROBOTS_CONTROLLED*4); - memcpy (&(multibuf[count]),&robot_fired,MAX_ROBOTS_CONTROLLED*4); - count+=(MAX_ROBOTS_CONTROLLED*4); - - switch (multi_protocol) - { - case MULTI_PROTO_IPX: - net_ipx_send_naked_packet (multibuf,142,pnum); - break; - default: - Error("Protocol handling missing in multi_send_robot_controls\n"); - break; - } -} -void multi_do_robot_controls(char *buf) -{ - int count=2; - - if (buf[1]!=Player_num) - { - Int3(); // Get Jason! Recieved a coop_sync that wasn't ours! - return; - } - - memcpy (&robot_controlled,&(buf[count]),MAX_ROBOTS_CONTROLLED*4); - count+=(MAX_ROBOTS_CONTROLLED*4); - memcpy (&robot_agitation,&(buf[count]),MAX_ROBOTS_CONTROLLED*4); - count+=(MAX_ROBOTS_CONTROLLED*4); - memcpy (&robot_controlled_time,&(buf[count]),MAX_ROBOTS_CONTROLLED*4); - count+=(MAX_ROBOTS_CONTROLLED*4); - memcpy (&robot_last_send_time,&(buf[count]),MAX_ROBOTS_CONTROLLED*4); - count+=(MAX_ROBOTS_CONTROLLED*4); - memcpy (&robot_last_message_time,&(buf[count]),MAX_ROBOTS_CONTROLLED*4); - count+=(MAX_ROBOTS_CONTROLLED*4); - memcpy (&robot_send_pending,&(buf[count]),MAX_ROBOTS_CONTROLLED*4); - count+=(MAX_ROBOTS_CONTROLLED*4); - memcpy (&robot_fired,&(buf[count]),MAX_ROBOTS_CONTROLLED*4); - count+=(MAX_ROBOTS_CONTROLLED*4); -} - #define POWERUPADJUSTS 5 int PowerupAdjustMapping[]={11,19,39,41,44}; @@ -4705,6 +4660,9 @@ void multi_send_trigger_specific (char pnum,char trig) case MULTI_PROTO_IPX: net_ipx_send_naked_packet(multibuf, 2, pnum); break; + case MULTI_PROTO_UDP: + net_udp_send_mdata_direct((ubyte *)multibuf, 2, pnum, 1); + break; default: Error("Protocol handling missing in multi_send_trigger_specific\n"); break; @@ -4724,7 +4682,7 @@ void multi_add_lifetime_kills () int oldrank; - if (!Game_mode & GM_NETWORK) + if (!(Game_mode & GM_NETWORK)) return; oldrank=GetMyNetRanking(); @@ -4751,7 +4709,7 @@ void multi_add_lifetime_killed () int oldrank; - if (!Game_mode & GM_NETWORK) + if (!(Game_mode & GM_NETWORK)) return; oldrank=GetMyNetRanking(); @@ -4856,6 +4814,19 @@ void multi_do_play_by_play (char *buf) /// CODE TO LOAD HOARD DATA /// +int HoardEquipped() +{ + static int checked=-1; + + if (checked==-1) + { + if (cfexist("hoard.ham") || cfexist("Data/hoard.ham")) + checked=1; + else + checked=0; + } + return (checked); +} void init_bitmap(grs_bitmap *bm,int w,int h,int flags,ubyte *data) { @@ -5179,11 +5150,10 @@ multi_process_data(char *buf, int len) if (!Endlevel_sequence) multi_do_play_by_play(buf); break; case MULTI_RANK: if (!Endlevel_sequence) multi_do_ranking (buf); break; -#ifndef SHAREWARE case MULTI_FINISH_GAME: multi_do_finish_game(buf); break; // do this one regardless of endsequence case MULTI_ROBOT_CONTROLS: - if (!Endlevel_sequence) multi_do_robot_controls(buf); break; + break; case MULTI_ROBOT_CLAIM: if (!Endlevel_sequence) multi_do_claim_robot(buf); break; case MULTI_ROBOT_POSITION: @@ -5194,7 +5164,6 @@ multi_process_data(char *buf, int len) if (!Endlevel_sequence) multi_do_release_robot(buf); break; case MULTI_ROBOT_FIRE: if (!Endlevel_sequence) multi_do_robot_fire(buf); break; -#endif case MULTI_SCORE: if (!Endlevel_sequence) multi_do_score(buf); break; case MULTI_CREATE_ROBOT: diff --git a/main/multi.h b/main/multi.h index 5842ff6d2..1dfbb423e 100644 --- a/main/multi.h +++ b/main/multi.h @@ -25,30 +25,28 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "piggy.h" #include "vers_id.h" #include "newmenu.h" - #ifdef _WIN32 - #include - #include +#include +#include #else - #include - #include - #include - #include - #include - #include +#include +#include +#include +#include +#include +#include #endif #ifdef IPv6 - #define _sockaddr sockaddr_in6 - #define _af AF_INET6 - #define _pf PF_INET6 +#define _sockaddr sockaddr_in6 +#define _af AF_INET6 +#define _pf PF_INET6 #else - #define _sockaddr sockaddr_in - #define _af AF_INET - #define _pf PF_INET +#define _sockaddr sockaddr_in +#define _af AF_INET +#define _pf PF_INET #endif - // PROTOCOL VARIABLES AND DEFINES extern int multi_protocol; // set and determinate used protocol #define MULTI_PROTO_IPX 1 // IPX-type protocol (IPX, KALI) @@ -126,7 +124,7 @@ extern int multi_protocol; // set and determinate used protocol #define MULTI_CAPTURE_BONUS 52 #define MULTI_GOT_FLAG 53 #define MULTI_DROP_FLAG 54 -#define MULTI_ROBOT_CONTROLS 55 +#define MULTI_ROBOT_CONTROLS 55 // unused! #define MULTI_FINISH_GAME 56 #define MULTI_RANK 57 #define MULTI_MODEM_PING 58 @@ -142,6 +140,14 @@ extern int multi_protocol; // set and determinate used protocol #define MAX_MULTI_MESSAGE_LEN 120 +#define NETGAME_ANARCHY 0 +#define NETGAME_TEAM_ANARCHY 1 +#define NETGAME_ROBOT_ANARCHY 2 +#define NETGAME_COOPERATIVE 3 +#define NETGAME_CAPTURE_FLAG 4 +#define NETGAME_HOARD 5 +#define NETGAME_TEAM_HOARD 6 + #define NETSTAT_MENU 0 #define NETSTAT_PLAYING 1 #define NETSTAT_BROWSING 2 @@ -158,6 +164,16 @@ extern int multi_protocol; // set and determinate used protocol #define CONNECT_END_MENU 6 #define CONNECT_KMATRIX_WAITING 7 // Like CONNECT_WAITING but used especially in kmatrix.c to seperate "escaped" and "waiting" +// reasons for a packet with type PID_DUMP +#define DUMP_CLOSED 0 // no new players allowed after game started +#define DUMP_FULL 1 // player cound maxed out +#define DUMP_ENDLEVEL 2 +#define DUMP_DORK 3 +#define DUMP_ABORTED 4 +#define DUMP_CONNECTED 5 // never used +#define DUMP_LEVEL 6 +#define DUMP_KICKED 7 + // Bitmask for netgame_info->AllowedItems to set allowed items in Netgame #define NETFLAG_DOLASER 1 #define NETFLAG_DOSUPERLASER 2 @@ -193,6 +209,7 @@ extern char *multi_allow_powerup_text[MULTI_ALLOW_POWERUP_MAX]; // Exported functions extern int GetMyNetRanking(); +extern void ClipRank (ubyte *rank); int objnum_remote_to_local(int remote_obj, int owner); int objnum_local_to_remote(int local_obj, sbyte *owner); void map_objnum_local_to_remote(int local, int remote, int owner); @@ -236,13 +253,13 @@ void multi_send_guided_info (object *miss,char); void multi_endlevel_score(void); +void multi_consistency_error(int reset); void multi_prep_level(void); int multi_level_sync(void); int multi_endlevel(int *secret); +void multi_endlevel_poll1(); void multi_endlevel_poll2( int nitems, struct newmenu_item * menus, int * key, int citem ); -void multi_endlevel_poll3( int nitems, struct newmenu_item * menus, int * key, int citem ); void multi_send_endlevel_packet(); -void multi_send_endlevel_sub(int player_num); int multi_menu_poll(void); void multi_leave_game(void); void multi_process_data(char *dat, int len); @@ -258,14 +275,13 @@ int multi_get_kill_list(int *plist); void multi_new_game(void); void multi_sort_kill_list(void); void multi_reset_stuff(void); -void multi_send_data(char *buf, int len, int repeat); +void multi_send_data(char *buf, int len, int priority); int get_team(int pnum); // Exported variables extern int PacketUrgent; -extern int Network_active; extern int Network_status; extern int Network_laser_gun; extern int Network_laser_fired; @@ -274,9 +290,13 @@ extern int Network_laser_flags; // IMPORTANT: These variables needed for player rejoining done by protocol-specific code extern int Network_send_objects; +extern int Network_send_object_mode; extern int Network_send_objnum; extern int Network_rejoined; extern int Network_new_game; +extern int Network_sending_extras; +extern int Player_joining_extras; +extern int Network_player_added; extern int message_length[MULTI_MAX_TYPE+1]; extern char multibuf[MAX_MULTI_MESSAGE_LEN+4]; @@ -329,6 +349,11 @@ extern bitmap_index multi_player_textures[MAX_NUM_NET_PLAYERS][N_PLAYER_SHIP_TEX extern char *RankStrings[]; +// Globals for protocol-bound Refuse-functions +extern char RefuseThisPlayer,WaitForRefuseAnswer,RefuseTeam,RefusePlayerName[12]; +extern fix RefuseTimeLimit; +#define REFUSE_INTERVAL (F1_0*8) + #define NETGAME_FLAG_CLOSED 1 #define NETGAME_FLAG_SHOW_ID 2 #define NETGAME_FLAG_SHOW_MAP 4 @@ -351,13 +376,11 @@ void change_playernum_to(int new_pnum); #define MISSILE_ADJUST 100 #define FLARE_ADJUST 127 +int HoardEquipped(); #ifdef EDITOR void save_hoard_data(void); #endif - -enum comp_type {DOS,WIN_32,WIN_95,MAC} __pack__ ; - /* * The Network Players structure * Contains both IPX- and UDP-specific data with designated prefixes and general player-related data. @@ -373,16 +396,12 @@ typedef struct netplayer_info ubyte server[4]; ubyte node[6]; ushort socket; - enum comp_type computer_type; + ubyte computer_type; // {DOS,WIN_32,WIN_95,MAC} } ipx; struct { struct _sockaddr addr; // IP address of this peer - int valid; // 1 = client connected / 2 = client ready for handshaking / 3 = client done with handshake and fully joined / 0 between clients = no connection -> relay - fix timestamp; // time of received packet - used for timeout - char hs_list[MAX_PLAYERS+4]; // list to store all handshake results for this player from already connected clients - int hstimeout; // counts the number of tries the client tried to connect - if reached 10, client put to relay if allowed - int relay; // relay packets by/to this clients over host + ubyte isyou; // This flag is set true while sending info to tell player his designated (re)join position } udp; } protocol; @@ -418,6 +437,7 @@ typedef struct netgame_info { struct _sockaddr addr; // IP address of this netgame's host int program_iver; // IVER of program for version checking + sbyte valid; // Status of Netgame info: -1 = Failed, Wrong version; 0 = No info, yet; 1 = Success } udp; } protocol; @@ -438,11 +458,11 @@ typedef struct netgame_info ubyte game_flags; ubyte team_vector; u_int32_t AllowedItems; - short Allow_marker_view:1; - short AlwaysLighting:1; - short ShowAllNames:1; - short BrightPlayers:1; - short InvulAppear:1; + short Allow_marker_view; + short AlwaysLighting; + short ShowAllNames; + short BrightPlayers; + short InvulAppear; char team_name[2][CALLSIGN_LEN+1]; int locations[MAX_PLAYERS]; short kills[MAX_PLAYERS][MAX_PLAYERS]; @@ -458,7 +478,7 @@ typedef struct netgame_info int player_score[MAX_PLAYERS]; ubyte player_flags[MAX_PLAYERS]; short PacketsPerSec; - ubyte PacketLossPrevention; + ubyte PacketLossPrevention; // FIXME: IMPLEMENT ME! } __pack__ netgame_info; diff --git a/main/multibot.c b/main/multibot.c index 8aff601bc..7c82863fa 100644 --- a/main/multibot.c +++ b/main/multibot.c @@ -338,10 +338,7 @@ multi_send_claim_robot(int objnum) s = objnum_local_to_remote(objnum, (sbyte *)&multibuf[4]); PUT_INTEL_SHORT(multibuf+2, s); - multi_send_data(multibuf, 5, 2); - multi_send_data(multibuf, 5, 2); - multi_send_data(multibuf, 5, 2); - + multi_send_data(multibuf, 5, 1); } void @@ -368,9 +365,7 @@ multi_send_release_robot(int objnum) s = objnum_local_to_remote(objnum, (sbyte *)&multibuf[4]); PUT_INTEL_SHORT(multibuf+2, s); - multi_send_data(multibuf, 5, 2); - multi_send_data(multibuf, 5, 2); - multi_send_data(multibuf, 5, 2); + multi_send_data(multibuf, 5, 1); } #define MIN_ROBOT_COM_GAP F1_0/12 @@ -518,7 +513,7 @@ multi_send_robot_fire(int objnum, int gun_num, vms_vector *fire) PacketUrgent = 1; } else - multi_send_data(multibuf, loc, 2); // Not our robot, send ASAP + multi_send_data(multibuf, loc, 1); // Not our robot, send ASAP } void @@ -559,7 +554,7 @@ multi_send_create_robot(int station, int objnum, int type) map_objnum_local_to_local((short)objnum); - multi_send_data(multibuf, loc, 2); + multi_send_data(multibuf, loc, 1); } void @@ -638,7 +633,7 @@ multi_send_create_robot_powerups(object *del_obj) Net_create_loc = 0; - multi_send_data(multibuf, 27, 2); + multi_send_data(multibuf, 27, 1); } void diff --git a/main/net_ipx.c b/main/net_ipx.c index b0039e4a7..b4cb02b9e 100644 --- a/main/net_ipx.c +++ b/main/net_ipx.c @@ -12,9 +12,9 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* - * - * Routines for managing network play. - * + * + * Routines for managing IPX-protocol network play. + * */ #ifdef HAVE_CONFIG_H @@ -67,54 +67,18 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "cfile.h" #include "gamefont.h" #include "rbaudio.h" -#include "ipxdrv.h" - -// MWA -- these structures are aligned -- please save me sanity and -// headaches by keeping alignment if these are changed!!!! Contact -// me for info. - -typedef struct endlevel_info { - ubyte type; - ubyte player_num; - sbyte connected; - ubyte seconds_left; - short kill_matrix[MAX_PLAYERS][MAX_PLAYERS]; - short kills; - short killed; -} endlevel_info; - -typedef struct endlevel_info_short { - ubyte type; - ubyte player_num; - sbyte connected; - ubyte seconds_left; -} endlevel_info_short; - -#define SEQUENCE_PACKET_SIZE (sizeof(sequence_packet)-sizeof(netplayer_info)+sizeof(IPX_netplayer_info)) -#define FRAME_INFO_SIZE sizeof(frame_info) -#define IPX_SHORT_INFO_SIZE sizeof(short_frame_info) - -netgame_info Active_games[MAX_ACTIVE_NETGAMES]; -netgame_info ActiveNetPlayers[MAX_ACTIVE_NETGAMES]; -netgame_info *TempPlayersInfo,TempPlayersBase; -int NamesInfoSecurity=-1; - -// MWAnetgame_info *TempNetInfo; -netgame_info TempNetInfo; +// Prototypes extern void multi_send_drop_marker (int player,vms_vector position,char messagenum,char text[]); extern void multi_send_kill_goal_counts(); - void net_ipx_process_naked_pdata (char *,int); -extern void multi_send_robot_controls(char); - void net_ipx_flush(); void net_ipx_listen(); void net_ipx_update_netgame(); void net_ipx_check_for_old_version(char pnum); void net_ipx_send_objects(); void net_ipx_send_rejoin_sync(int player_num); -void net_ipx_send_game_info(sequence_packet *their); +void net_ipx_send_game_info(IPX_sequence_packet *their); void net_ipx_send_endlevel_short_sub(int from_player_num, int to_player); void net_ipx_read_sync_packet(netgame_info * sp, int rsinit); int net_ipx_wait_for_playerinfo(); @@ -122,97 +86,401 @@ void net_ipx_process_pdata(char *data); void net_ipx_read_object_packet(ubyte *data ); void net_ipx_read_endlevel_packet(ubyte *data ); void net_ipx_read_endlevel_short_packet(ubyte *data ); +void net_ipx_ping_all(fix time); void net_ipx_ping(ubyte flat, int pnum); void net_ipx_handle_ping_return(ubyte pnum); void net_ipx_process_names_return(ubyte *data); -void net_ipx_send_player_names(sequence_packet *their); +void net_ipx_send_player_names(IPX_sequence_packet *their); void net_ipx_more_game_options(); void net_ipx_count_powerups_in_mine(); int net_ipx_wait_for_all_info(int choice); void net_ipx_do_big_wait(int choice); void net_ipx_send_extras(); -void net_ipx_read_pdata_packet(frame_info *pd); -void net_ipx_read_pdata_short_packet(short_frame_info *pd); - +void net_ipx_read_pdata_packet(IPX_frame_info *pd); +void net_ipx_read_pdata_short_packet(IPX_short_frame_info *pd); void ClipRank(ubyte *rank); -void DoRefuseStuff(sequence_packet *their); -int GetNewPlayerNumber(sequence_packet *their); -void SetAllAllowablesTo(int on); -int show_game_stats(int choice); - -int num_active_games = 0; -int PacketsPerSec=10; - -int Network_debug=0; -int Network_active=0; - -int Network_games_changed = 0; - -int Network_allow_socket_changes = 1; +void net_ipx_do_refuse_stuff(IPX_sequence_packet *their); +int net_ipx_get_new_player_num(IPX_sequence_packet *their); +int net_ipx_show_game_stats(int choice); +extern void multi_send_stolen_items(); +int net_ipx_wait_for_snyc(); +extern void multi_send_wall_status (int,ubyte,ubyte,ubyte); +extern void multi_send_wall_status_specific (int,int,ubyte,ubyte,ubyte); +extern void game_disable_cheats(); +// Variables +int num_active_ipx_games = 0; +int IPX_active=0; +int num_active_ipx_changed = 0; +int IPX_allow_socket_changes = 1; int NetSecurityFlag=NETSECURITY_OFF; int NetSecurityNum=0; -int Network_sending_extras=0; int VerifyPlayerJoined=-1; -int Player_joining_extras=-1; // This is so we know who to send 'latecomer' packets to. - // We could just send updates to everyone but that kills the sender! - -// For rejoin object syncing - -int Network_player_added = 0; // Is this a new player or a returning player? -int Network_send_object_mode = 0; // What type of objects are we sending, static or dynamic? -sequence_packet Network_player_rejoining; // Who is rejoining now? - -int NetGameType=0; -int TotalMissedPackets=0,TotalPacketsGot=0; - -frame_info MySyncPack,UrgentSyncPack; +IPX_sequence_packet IPX_sync_player; // Who is rejoining now? +int IPX_TotalMissedPackets=0,IPX_TotalPacketsGot=0; +IPX_frame_info MySyncPack,UrgentSyncPack; ubyte MySyncPackInitialized = 0; // Set to 1 if the MySyncPack is zeroed. - -sequence_packet My_Seq; +IPX_sequence_packet IPX_Seq; char WantPlayersInfo=0; char WaitingForPlayerInfo=0; - int IPX_Socket=0; - extern obj_position Player_init[MAX_PLAYERS]; - extern int force_cockpit_redraw; - -// reasons for a packet with type PID_DUMP -#define DUMP_CLOSED 0 // no new players allowed after game started -#define DUMP_FULL 1 // player cound maxed out -#define DUMP_ENDLEVEL 2 -#define DUMP_DORK 3 -#define DUMP_ABORTED 4 -#define DUMP_CONNECTED 5 // never used -#define DUMP_LEVEL 6 -#define DUMP_KICKED 7 // never used - extern ubyte Version_major,Version_minor; extern ubyte SurfingNet; extern char MaxPowerupsAllowed[MAX_POWERUP_TYPES]; extern char PowerupsInMine[MAX_POWERUP_TYPES]; +extern int Final_boss_is_dead; +typedef struct IPX_endlevel_info { + ubyte type; + ubyte player_num; + sbyte connected; + ubyte seconds_left; + short kill_matrix[MAX_PLAYERS][MAX_PLAYERS]; + short kills; + short killed; +} IPX_endlevel_info; -extern void multi_send_stolen_items(); +typedef struct IPX_endlevel_info_short { + ubyte type; + ubyte player_num; + sbyte connected; + ubyte seconds_left; +} IPX_endlevel_info_short; -int net_ipx_wait_for_snyc(); -extern void multi_send_wall_status (int,ubyte,ubyte,ubyte); -extern void multi_send_wall_status_specific (int,int,ubyte,ubyte,ubyte); +#define SEQUENCE_PACKET_SIZE (sizeof(IPX_sequence_packet)-sizeof(netplayer_info)+sizeof(IPX_netplayer_info)) +#define FRAME_INFO_SIZE sizeof(IPX_frame_info) +#define IPX_SHORT_INFO_SIZE sizeof(IPX_short_frame_info) -extern void game_disable_cheats(); +netgame_info Active_ipx_games[IPX_MAX_NETGAMES]; +netgame_info *TempPlayersInfo,TempPlayersBase; +int NamesInfoSecurity=-1; +netgame_info TempNetInfo; -char IWasKicked=0; -#ifdef NETPROFILING -FILE *SendLogFile,*RecieveLogFile; -int TTSent[100],TTRecv[100]; +/* General IPX functions - START */ +ubyte broadcast_addr[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; +ubyte null_addr[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +ubyte ipxdrv_installed=0; +u_int32_t ipx_network = 0; +ubyte MyAddress[10]; +int ipx_packetnum = 0; /* Sequence number */ + +/* User defined routing stuff */ +typedef struct user_address { + ubyte network[4]; + ubyte node[6]; + ubyte address[6]; +} user_address; + +socket_t socket_data; +#define MAX_USERS 64 +int Ipx_num_users = 0; +user_address Ipx_users[MAX_USERS]; +#define MAX_NETWORKS 64 +int Ipx_num_networks = 0; +uint Ipx_networks[MAX_NETWORKS]; + +int ipxdrv_general_packet_ready(int fd) +{ + fd_set set; + struct timeval tv; + + FD_ZERO(&set); + FD_SET(fd, &set); + tv.tv_sec = tv.tv_usec = 0; + if (select(fd + 1, &set, NULL, NULL, &tv) > 0) + return 1; + else + return 0; +} + +struct net_driver *driver = NULL; + +ubyte * ipxdrv_get_my_server_address() +{ + return (ubyte *)&ipx_network; +} + +ubyte * ipxdrv_get_my_local_address() +{ + return (ubyte *)(MyAddress + 4); +} + +void ipxdrv_close() +{ + if (ipxdrv_installed) + { +#ifdef _WIN32 + WSACleanup(); +#endif + driver->close_socket(&socket_data); + } + + ipxdrv_installed = 0; +} + +//--------------------------------------------------------------- +// Initializes all driver internals. +// If socket_number==0, then opens next available socket. +// Returns: 0 if successful. +// -1 if socket already open. +// -2 if socket table full. +// -3 if driver not installed. +// -4 if couldn't allocate low dos memory +// -5 if error with getting internetwork address +int ipxdrv_init( int socket_number ) +{ + static int cleanup = 0; +#ifdef _WIN32 + WORD wVersionRequested; + WSADATA wsaData; #endif -extern int Final_boss_is_dead; + if (!driver) + return -1; -#define NETWORK_OEM 0x10 +#ifdef _WIN32 + wVersionRequested = MAKEWORD(2, 0); + if (WSAStartup( wVersionRequested, &wsaData)) + { + return -1; + } +#endif + memset(MyAddress,0,10); -void send_sequence_packet(sequence_packet seq, ubyte *server, ubyte *node, ubyte *net_address) + if (GameArg.MplIpxNetwork) + { + unsigned long n = strtol(GameArg.MplIpxNetwork, NULL, 16); + MyAddress[0] = n >> 24; MyAddress[1] = (n >> 16) & 255; + MyAddress[2] = (n >> 8) & 255; MyAddress[3] = n & 255; + con_printf(CON_DEBUG,"IPX: Using network %08x\n", (unsigned int)n); + } + + if (driver->open_socket(&socket_data, socket_number)) + { + return -3; + } + + memcpy(&ipx_network, MyAddress, 4); + Ipx_num_networks = 0; + memcpy( &Ipx_networks[Ipx_num_networks++], &ipx_network, 4 ); + + ipxdrv_installed = 1; + + if (!cleanup) + atexit(ipxdrv_close); + cleanup = 1; + + return 0; +} + +int ipxdrv_set(int arg) +{ + int ipxdrv_err; + + ipxdrv_close(); + + con_printf(CON_VERBOSE, "\n%s ", TXT_INITIALIZING_NETWORK); + + switch (arg) + { +#ifndef __APPLE__ + case NETPROTO_IPX: + driver = &ipxdrv_ipx; + break; +#endif +#ifdef __LINUX__ + case NETPROTO_KALINIX: + driver = &ipxdrv_kali; + break; +#endif + default: + driver = NULL; + break; + } + + if ((ipxdrv_err=ipxdrv_init(IPX_DEFAULT_SOCKET))==0) + { + con_printf(CON_VERBOSE, "%s %d.\n", TXT_IPX_CHANNEL, IPX_DEFAULT_SOCKET ); + IPX_active = 1; + } + else + { + switch (ipxdrv_err) + { + case 3: + con_printf(CON_VERBOSE, "%s\n", TXT_NO_NETWORK); + break; + case -2: + con_printf(CON_VERBOSE, "%s 0x%x.\n", TXT_SOCKET_ERROR, IPX_DEFAULT_SOCKET); + break; + case -4: + con_printf(CON_VERBOSE, "%s\n", TXT_MEMORY_IPX ); + break; + default: + con_printf(CON_VERBOSE, "%s %d", TXT_ERROR_IPX, ipxdrv_err ); + break; + } + + con_printf(CON_VERBOSE, "%s\n",TXT_NETWORK_DISABLED); + IPX_active = 0; // Assume no network + } + + return ipxdrv_installed?0:-1; +} + +int ipxdrv_get_packet_data( ubyte * data ) +{ + struct recv_data rd; + char *buf; + int size; + + if (driver->usepacketnum) + buf=alloca(MAX_IPX_DATA); + else + buf=(char *)data; + + memset(rd.src_network,1,4); + + while (driver->packet_ready(&socket_data)) + { + if ((size = driver->receive_packet(&socket_data, buf, MAX_IPX_DATA, &rd)) > 4) + { + if (!memcmp(rd.src_network, MyAddress, 10)) + { + continue; /* don't get own pkts */ + } + + if (driver->usepacketnum) + { + memcpy(data, buf + 4, size - 4); + return size-4; + } + else + { + return size; + } + } + } + return 0; +} + +void ipxdrv_send_packet_data( ubyte * data, int datasize, ubyte *network, ubyte *address, ubyte *immediate_address ) +{ + IPXPacket_t ipx_header; + + if (!ipxdrv_installed) + return; + + memcpy(ipx_header.Destination.Network, network, 4); + memcpy(ipx_header.Destination.Node, immediate_address, 6); + ipx_header.PacketType = 4; /* Packet Exchange */ + + if (driver->usepacketnum) + { + ubyte buf[MAX_IPX_DATA]; + *(uint *)buf = ipx_packetnum++; + + memcpy(buf + 4, data, datasize); + driver->send_packet(&socket_data, &ipx_header, buf, datasize + 4); + } + else + driver->send_packet(&socket_data, &ipx_header, data, datasize);//we can save 4 bytes +} + +void ipxdrv_get_local_target( ubyte * server, ubyte * node, ubyte * local_target ) +{ + memcpy( local_target, node, 6 ); +} + +void ipxdrv_send_broadcast_packet_data( ubyte * data, int datasize ) +{ + int i, j; + ubyte local_address[6]; + + if (!ipxdrv_installed) + return; + + // Set to all networks besides mine + for (i=0; iclose_socket(&socket_data); + + if (driver->open_socket(&socket_data, socket_number)) + { + return -3; + } + + return 0; +} + +// Return type of net_driver +int ipxdrv_type(void) +{ + return driver->type; +} +/* General IPX functions - END */ + +void net_ipx_send_sequence_packet(IPX_sequence_packet seq, ubyte *server, ubyte *node, ubyte *net_address) { int loc, tmpi; short tmps; @@ -242,7 +510,7 @@ void send_sequence_packet(sequence_packet seq, ubyte *server, ubyte *node, ubyte ipxdrv_send_internetwork_packet_data(out_buffer, loc, server, node); } -void receive_sequence_packet(ubyte *data, sequence_packet *seq) +void net_ipx_receive_sequence_packet(ubyte *data, IPX_sequence_packet *seq) { int loc = 0; @@ -553,7 +821,6 @@ net_ipx_init(void) int save_pnum = Player_num; game_disable_cheats(); - IWasKicked=0; Final_boss_is_dead=0; NamesInfoSecurity=-1; @@ -569,20 +836,20 @@ net_ipx_init(void) PowerupsInMine[t]=0; } - TotalMissedPackets=0; TotalPacketsGot=0; + IPX_TotalMissedPackets=0; IPX_TotalPacketsGot=0; memset(&Netgame, 0, sizeof(netgame_info)); - memset(&My_Seq, 0, sizeof(sequence_packet)); - My_Seq.type = PID_REQUEST; - memcpy(My_Seq.player.callsign, Players[Player_num].callsign, CALLSIGN_LEN+1); + memset(&IPX_Seq, 0, sizeof(IPX_sequence_packet)); + IPX_Seq.type = PID_REQUEST; + memcpy(IPX_Seq.player.callsign, Players[Player_num].callsign, CALLSIGN_LEN+1); - My_Seq.player.version_major=Version_major; - My_Seq.player.version_minor=Version_minor; - My_Seq.player.rank=GetMyNetRanking(); + IPX_Seq.player.version_major=Version_major; + IPX_Seq.player.version_minor=Version_minor; + IPX_Seq.player.rank=GetMyNetRanking(); - memcpy(My_Seq.player.protocol.ipx.node, ipxdrv_get_my_local_address(), 6); - memcpy(My_Seq.player.protocol.ipx.server, ipxdrv_get_my_server_address(), 4 ); - My_Seq.player.protocol.ipx.computer_type = DOS; + memcpy(IPX_Seq.player.protocol.ipx.node, ipxdrv_get_my_local_address(), 6); + memcpy(IPX_Seq.player.protocol.ipx.server, ipxdrv_get_my_server_address(), 4 ); + IPX_Seq.player.protocol.ipx.computer_type = 1; for (Player_num = 0; Player_num < MAX_NUM_NET_PLAYERS; Player_num++) init_player_stats_game(); @@ -612,7 +879,7 @@ int net_ipx_how_many_connected() void -net_ipx_endlevel_poll2( int nitems, newmenu_item * menus, int * key, int citem ) +net_ipx_kmatrix_poll1( int nitems, newmenu_item * menus, int * key, int citem ) { // Polling loop for End-of-level menu @@ -621,11 +888,6 @@ net_ipx_endlevel_poll2( int nitems, newmenu_item * menus, int * key, int citem ) int num_ready = 0; int goto_secret = 0; - menus = menus; - citem = citem; - nitems = nitems; - key = key; - // Send our endlevel packet at regular intervals if (timer_get_approx_seconds() > (t1+ENDLEVEL_SEND_INTERVAL)) @@ -638,9 +900,9 @@ net_ipx_endlevel_poll2( int nitems, newmenu_item * menus, int * key, int citem ) for (i = 0; i < N_players; i++) { - if ((Players[i].connected != 1) && (Players[i].connected != 5) && (Players[i].connected != 6)) + if ((Players[i].connected != CONNECT_PLAYING) && (Players[i].connected != CONNECT_ESCAPE_TUNNEL) && (Players[i].connected != CONNECT_END_MENU)) num_ready++; - if (Players[i].connected == 4) + if (Players[i].connected == CONNECT_FOUND_SECRET) goto_secret = 1; } @@ -657,7 +919,7 @@ net_ipx_endlevel_poll2( int nitems, newmenu_item * menus, int * key, int citem ) extern fix StartAbortMenuTime; void -net_ipx_endlevel_poll3( int nitems, newmenu_item * menus, int * key, int citem ) +net_ipx_kmatrix_poll2( int nitems, newmenu_item * menus, int * key, int citem ) { // Polling loop for End-of-level menu @@ -676,7 +938,7 @@ net_ipx_endlevel_poll3( int nitems, newmenu_item * menus, int * key, int citem ) for (i = 0; i < N_players; i++) - if ((Players[i].connected != 1) && (Players[i].connected != 5) && (Players[i].connected != 6)) + if ((Players[i].connected != CONNECT_PLAYING) && (Players[i].connected != CONNECT_ESCAPE_TUNNEL) && (Players[i].connected != CONNECT_END_MENU)) num_ready++; if (num_ready == N_players) // All players have checked in or are disconnected @@ -717,7 +979,7 @@ net_ipx_endlevel(int *secret) } int -can_join_netgame(netgame_info *game) +net_ipx_can_join_netgame(netgame_info *game) { // Can this player rejoin a netgame in progress? @@ -765,8 +1027,8 @@ can_join_netgame(netgame_info *game) for (i = 0; i < num_players; i++) { if ( (!stricmp(Players[Player_num].callsign, game->players[i].callsign)) && - (!memcmp(My_Seq.player.protocol.ipx.node, game->players[i].protocol.ipx.node, 6)) && - (!memcmp(My_Seq.player.protocol.ipx.server, game->players[i].protocol.ipx.server, 4)) ) + (!memcmp(IPX_Seq.player.protocol.ipx.node, game->players[i].protocol.ipx.node, 6)) && + (!memcmp(IPX_Seq.player.protocol.ipx.server, game->players[i].protocol.ipx.server, 4)) ) break; } @@ -788,8 +1050,8 @@ net_ipx_disconnect_player(int playernum) return; } - Players[playernum].connected = 0; - Netgame.players[playernum].connected = 0; + Players[playernum].connected = CONNECT_DISCONNECTED; + Netgame.players[playernum].connected = CONNECT_DISCONNECTED; if (VerifyPlayerJoined==playernum) VerifyPlayerJoined=-1; @@ -803,7 +1065,7 @@ net_ipx_disconnect_player(int playernum) } void -net_ipx_new_player(sequence_packet *their) +net_ipx_new_player(IPX_sequence_packet *their) { int objnum; int pnum; @@ -844,7 +1106,7 @@ net_ipx_new_player(sequence_packet *their) memcpy(Netgame.players[pnum].protocol.ipx.server, their->player.protocol.ipx.server, 4); Players[pnum].n_packets_got = 0; - Players[pnum].connected = 1; + Players[pnum].connected = CONNECT_PLAYING; Players[pnum].net_kills_total = 0; Players[pnum].net_killed_total = 0; memset(kill_matrix[pnum], 0, MAX_PLAYERS*sizeof(short)); @@ -873,11 +1135,7 @@ net_ipx_new_player(sequence_packet *their) multi_sort_kill_list(); } -char RefuseThisPlayer=0,WaitForRefuseAnswer=0,RefuseTeam; -char RefusePlayerName[12]; -fix RefuseTimeLimit=0; - -void net_ipx_welcome_player(sequence_packet *their) +void net_ipx_welcome_player(IPX_sequence_packet *their) { // Add a player to a game already in progress ubyte local_address[6]; @@ -920,7 +1178,7 @@ void net_ipx_welcome_player(sequence_packet *their) } player_num = -1; - memset(&Network_player_rejoining, 0, sizeof(sequence_packet)); + memset(&IPX_sync_player, 0, sizeof(IPX_sequence_packet)); Network_player_added = 0; if ( (*(uint *)their->player.protocol.ipx.server) != 0 ) @@ -961,9 +1219,21 @@ void net_ipx_welcome_player(sequence_packet *their) int oldest_player = -1; fix oldest_time = timer_get_approx_seconds(); + int activeplayers = 0; Assert(N_players == MaxNumNetPlayers); + for (i = 0; i < Netgame.numplayers; i++) + if (Netgame.players[i].connected) + activeplayers++; + + if (activeplayers == Netgame.max_numplayers) + { + // Game is full. + net_ipx_dump_player(their->player.protocol.ipx.server, their->player.protocol.ipx.node, DUMP_FULL); + return; + } + for (i = 0; i < N_players; i++) { if ( (!Players[i].connected) && (Netgame.players[i].LastPacketTime < oldest_time)) @@ -1015,8 +1285,8 @@ void net_ipx_welcome_player(sequence_packet *their) // Send updated Objects data to the new/returning player - Network_player_rejoining = *their; - Network_player_rejoining.player.connected = player_num; + IPX_sync_player = *their; + IPX_sync_player.player.connected = player_num; Network_send_objects = 1; Network_send_objnum = -1; @@ -1028,7 +1298,7 @@ int net_ipx_objnum_is_past(int objnum) // determine whether or not a given object number has already been sent // to a re-joining player. - int player_num = Network_player_rejoining.player.connected; + int player_num = IPX_sync_player.player.connected; int obj_mode = !((object_owner[objnum] == -1) || (object_owner[objnum] == player_num)); if (!Network_send_objects) @@ -1044,7 +1314,7 @@ int net_ipx_objnum_is_past(int objnum) return 0; } -#define OBJ_PACKETS_PER_FRAME 1 +#define IPX_OBJ_PACKETS_PER_FRAME 1 extern void multi_send_active_door(char); extern void multi_send_door_open_specific(int,int,int,ubyte); @@ -1172,11 +1442,11 @@ int net_ipx_create_monitor_vector(void) return(vector); } -void net_ipx_stop_resync(sequence_packet *their) +void net_ipx_stop_resync(IPX_sequence_packet *their) { - if ( (!memcmp(Network_player_rejoining.player.protocol.ipx.node, their->player.protocol.ipx.node, 6)) && - (!memcmp(Network_player_rejoining.player.protocol.ipx.server, their->player.protocol.ipx.server, 4)) && - (!stricmp(Network_player_rejoining.player.callsign, their->player.callsign)) ) + if ( (!memcmp(IPX_sync_player.player.protocol.ipx.node, their->player.protocol.ipx.node, 6)) && + (!memcmp(IPX_sync_player.player.protocol.ipx.server, their->player.protocol.ipx.server, 4)) && + (!stricmp(IPX_sync_player.player.callsign, their->player.callsign)) ) { Network_send_objects = 0; Network_sending_extras=0; @@ -1186,7 +1456,7 @@ void net_ipx_stop_resync(sequence_packet *their) } } -void swap_object(object *obj) +void net_ipx_swap_object(object *obj) { // swap the short and int entries for this object obj->signature = INTEL_INT(obj->signature); @@ -1346,7 +1616,7 @@ void net_ipx_send_objects(void) static int frame_num = 0; int obj_count_frame = 0; - int player_num = Network_player_rejoining.player.connected; + int player_num = IPX_sync_player.player.connected; // Send clear objects array trigger and send player num @@ -1359,12 +1629,12 @@ void net_ipx_send_objects(void) // Endlevel started before we finished sending the goods, we'll // have to stop and try again after the level. - net_ipx_dump_player(Network_player_rejoining.player.protocol.ipx.server,Network_player_rejoining.player.protocol.ipx.node, DUMP_ENDLEVEL); + net_ipx_dump_player(IPX_sync_player.player.protocol.ipx.server,IPX_sync_player.player.protocol.ipx.node, DUMP_ENDLEVEL); Network_send_objects = 0; return; } - for (h = 0; h < OBJ_PACKETS_PER_FRAME; h++) // Do more than 1 per frame, try to speed it up without over-stressing the receiver. + for (h = 0; h < IPX_OBJ_PACKETS_PER_FRAME; h++) // Do more than 1 per frame, try to speed it up without over-stressing the receiver. { obj_count_frame = 0; memset(object_buffer, 0, MAX_DATA_SIZE); @@ -1408,7 +1678,7 @@ void net_ipx_send_objects(void) object_buffer[loc] = owner; loc += 1; *(short *)(object_buffer+loc) = INTEL_SHORT(remote_objnum); loc += 2; memcpy(&object_buffer[loc], &Objects[i], sizeof(object)); - swap_object((object *)&object_buffer[loc]); + net_ipx_swap_object((object *)&object_buffer[loc]); loc += sizeof(object); } @@ -1421,7 +1691,7 @@ void net_ipx_send_objects(void) Assert(loc <= MAX_DATA_SIZE); - ipxdrv_send_internetwork_packet_data( object_buffer, loc, Network_player_rejoining.player.protocol.ipx.server, Network_player_rejoining.player.protocol.ipx.node ); + ipxdrv_send_internetwork_packet_data( object_buffer, loc, IPX_sync_player.player.protocol.ipx.server, IPX_sync_player.player.protocol.ipx.node ); } if (i > Highest_object_index) @@ -1442,7 +1712,7 @@ void net_ipx_send_objects(void) object_buffer[2] = frame_num; *(short *)(object_buffer+3) = INTEL_SHORT(-2); *(short *)(object_buffer+6) = INTEL_SHORT(obj_count); - ipxdrv_send_internetwork_packet_data(object_buffer, 8, Network_player_rejoining.player.protocol.ipx.server, Network_player_rejoining.player.protocol.ipx.node); + ipxdrv_send_internetwork_packet_data(object_buffer, 8, IPX_sync_player.player.protocol.ipx.server, IPX_sync_player.player.protocol.ipx.node); // Send sync packet which tells the player who he is and to start! net_ipx_send_rejoin_sync(player_num); @@ -1471,7 +1741,7 @@ void net_ipx_send_rejoin_sync(int player_num) { int i, j; - Players[player_num].connected = 1; // connect the new guy + Players[player_num].connected = CONNECT_PLAYING; // connect the new guy Netgame.players[player_num].LastPacketTime = timer_get_approx_seconds(); if (Endlevel_sequence || Control_center_destroyed) @@ -1479,7 +1749,7 @@ void net_ipx_send_rejoin_sync(int player_num) // Endlevel started before we finished sending the goods, we'll // have to stop and try again after the level. - net_ipx_dump_player(Network_player_rejoining.player.protocol.ipx.server,Network_player_rejoining.player.protocol.ipx.node, DUMP_ENDLEVEL); + net_ipx_dump_player(IPX_sync_player.player.protocol.ipx.server,IPX_sync_player.player.protocol.ipx.node, DUMP_ENDLEVEL); Network_send_objects = 0; Network_sending_extras=0; @@ -1488,14 +1758,14 @@ void net_ipx_send_rejoin_sync(int player_num) if (Network_player_added) { - Network_player_rejoining.type = PID_ADDPLAYER; - Network_player_rejoining.player.connected = player_num; - net_ipx_new_player(&Network_player_rejoining); + IPX_sync_player.type = PID_ADDPLAYER; + IPX_sync_player.player.connected = player_num; + net_ipx_new_player(&IPX_sync_player); for (i = 0; i < N_players; i++) { if ((i != player_num) && (i != Player_num) && (Players[i].connected)) - send_sequence_packet( Network_player_rejoining, Netgame.players[i].protocol.ipx.server, Netgame.players[i].protocol.ipx.node, Players[i].net_address); + net_ipx_send_sequence_packet( IPX_sync_player, Netgame.players[i].protocol.ipx.server, Netgame.players[i].protocol.ipx.node, Players[i].net_address); } } @@ -1516,8 +1786,8 @@ void net_ipx_send_rejoin_sync(int player_num) Netgame.level_time = Players[Player_num].time_level; Netgame.monitor_vector = net_ipx_create_monitor_vector(); - send_netgame_packet(Network_player_rejoining.player.protocol.ipx.server, Network_player_rejoining.player.protocol.ipx.node, NULL, 0); - send_netplayers_packet(Network_player_rejoining.player.protocol.ipx.server, Network_player_rejoining.player.protocol.ipx.node); + send_netgame_packet(IPX_sync_player.player.protocol.ipx.server, IPX_sync_player.player.protocol.ipx.node, NULL, 0); + send_netplayers_packet(IPX_sync_player.player.protocol.ipx.server, IPX_sync_player.player.protocol.ipx.node); return; } @@ -1541,8 +1811,8 @@ void resend_sync_due_to_packet_loss_for_allender () Netgame.level_time = Players[Player_num].time_level; Netgame.monitor_vector = net_ipx_create_monitor_vector(); - send_netgame_packet(Network_player_rejoining.player.protocol.ipx.server, Network_player_rejoining.player.protocol.ipx.node, NULL, 0); - send_netplayers_packet(Network_player_rejoining.player.protocol.ipx.server, Network_player_rejoining.player.protocol.ipx.node); + send_netgame_packet(IPX_sync_player.player.protocol.ipx.server, IPX_sync_player.player.protocol.ipx.node, NULL, 0); + send_netplayers_packet(IPX_sync_player.player.protocol.ipx.server, IPX_sync_player.player.protocol.ipx.node); } char * net_ipx_get_player_name( int objnum ) @@ -1555,7 +1825,7 @@ char * net_ipx_get_player_name( int objnum ) return Players[Objects[objnum].id].callsign; } -void net_ipx_add_player(sequence_packet *p) +void net_ipx_add_player(IPX_sequence_packet *p) { int i; @@ -1573,11 +1843,11 @@ void net_ipx_add_player(sequence_packet *p) Netgame.players[N_players].version_major=p->player.version_major; Netgame.players[N_players].version_minor=p->player.version_minor; Netgame.players[N_players].rank=p->player.rank; - Netgame.players[N_players].connected = 1; + Netgame.players[N_players].connected = CONNECT_PLAYING; net_ipx_check_for_old_version (N_players); Players[N_players].KillGoalCount=0; - Players[N_players].connected = 1; + Players[N_players].connected = CONNECT_PLAYING; Netgame.players[N_players].LastPacketTime = timer_get_approx_seconds(); N_players++; Netgame.numplayers = N_players; @@ -1589,7 +1859,7 @@ void net_ipx_add_player(sequence_packet *p) // One of the players decided not to join the game -void net_ipx_remove_player(sequence_packet *p) +void net_ipx_remove_player(IPX_sequence_packet *p) { int i,pn; @@ -1629,13 +1899,13 @@ net_ipx_dump_player(ubyte * server, ubyte *node, int why) { // Inform player that he was not chosen for the netgame - sequence_packet temp; + IPX_sequence_packet temp; - memset(&temp, 0, sizeof(sequence_packet)); + memset(&temp, 0, sizeof(IPX_sequence_packet)); temp.type = PID_DUMP; memcpy(temp.player.callsign, Players[Player_num].callsign, CALLSIGN_LEN+1); temp.player.connected = why; - send_sequence_packet( temp, server, node, NULL); + net_ipx_send_sequence_packet( temp, server, node, NULL); } void @@ -1643,32 +1913,32 @@ net_ipx_send_game_list_request() { // Send a broadcast request for game info - sequence_packet me; + IPX_sequence_packet me; - memset(&me, 0, sizeof(sequence_packet)); + memset(&me, 0, sizeof(IPX_sequence_packet)); me.type = PID_GAME_LIST; memcpy( me.player.callsign, Players[Player_num].callsign, CALLSIGN_LEN+1 ); memcpy( me.player.protocol.ipx.node, ipxdrv_get_my_local_address(), 6 ); memcpy( me.player.protocol.ipx.server, ipxdrv_get_my_server_address(), 4 ); - send_sequence_packet( me, NULL, NULL, NULL); + net_ipx_send_sequence_packet( me, NULL, NULL, NULL); } void net_ipx_send_all_info_request(char type,int which_security) { // Send a broadcast request for game info - sequence_packet me; + IPX_sequence_packet me; - memset(&me, 0, sizeof(sequence_packet)); + memset(&me, 0, sizeof(IPX_sequence_packet)); me.Security=which_security; me.type = type; memcpy( me.player.callsign, Players[Player_num].callsign, CALLSIGN_LEN+1 ); memcpy( me.player.protocol.ipx.node, ipxdrv_get_my_local_address(), 6 ); memcpy( me.player.protocol.ipx.server, ipxdrv_get_my_server_address(), 4 ); - send_sequence_packet( me, NULL, NULL, NULL); + net_ipx_send_sequence_packet( me, NULL, NULL, NULL); } @@ -1728,14 +1998,14 @@ net_ipx_update_netgame(void) void net_ipx_send_endlevel_sub(int player_num) { - endlevel_info end; + IPX_endlevel_info end; int i; #ifdef WORDS_BIGENDIAN int j; #endif // Send an endlevel packet for a player - memset(&end,0,sizeof(endlevel_info)); + memset(&end,0,sizeof(IPX_endlevel_info)); end.type = PID_ENDLEVEL; end.player_num = player_num; end.connected = Players[player_num].connected; @@ -1748,7 +2018,7 @@ net_ipx_send_endlevel_sub(int player_num) end.kill_matrix[i][j] = INTEL_SHORT(end.kill_matrix[i][j]); #endif - if (Players[player_num].connected == 1) // Still playing + if (Players[player_num].connected == CONNECT_PLAYING) // Still playing { Assert(Control_center_destroyed); end.seconds_left = Countdown_seconds_left; @@ -1757,10 +2027,10 @@ net_ipx_send_endlevel_sub(int player_num) for (i = 0; i < N_players; i++) { if ((i != Player_num) && (i!=player_num) && (Players[i].connected)) { - if (Players[i].connected==1) { + if (Players[i].connected==CONNECT_PLAYING) { net_ipx_send_endlevel_short_sub(player_num,i); } else { - ipxdrv_send_packet_data((ubyte *)&end, sizeof(endlevel_info), Netgame.players[i].protocol.ipx.server, Netgame.players[i].protocol.ipx.node,Players[i].net_address); + ipxdrv_send_packet_data((ubyte *)&end, sizeof(IPX_endlevel_info), Netgame.players[i].protocol.ipx.server, Netgame.players[i].protocol.ipx.node,Players[i].net_address); } } } @@ -1778,7 +2048,7 @@ net_ipx_send_endlevel_packet(void) void net_ipx_send_endlevel_short_sub(int from_player_num,int to_player) { - endlevel_info_short end; + IPX_endlevel_info_short end; end.type = PID_ENDLEVEL_SHORT; end.player_num = from_player_num; @@ -1786,21 +2056,21 @@ net_ipx_send_endlevel_short_sub(int from_player_num,int to_player) end.seconds_left = Countdown_seconds_left; - if (Players[from_player_num].connected == 1) // Still playing + if (Players[from_player_num].connected == CONNECT_PLAYING) // Still playing { Assert(Control_center_destroyed); } if ((to_player != Player_num) && (to_player!=from_player_num) && (Players[to_player].connected)) { - ipxdrv_send_packet_data((ubyte *)&end, sizeof(endlevel_info_short), Netgame.players[to_player].protocol.ipx.server, Netgame.players[to_player].protocol.ipx.node,Players[to_player].net_address); + ipxdrv_send_packet_data((ubyte *)&end, sizeof(IPX_endlevel_info_short), Netgame.players[to_player].protocol.ipx.server, Netgame.players[to_player].protocol.ipx.node,Players[to_player].net_address); } } extern fix ThisLevelTime; void -net_ipx_send_game_info(sequence_packet *their) +net_ipx_send_game_info(IPX_sequence_packet *their) { // Send game info to someone who requested it @@ -1843,7 +2113,7 @@ net_ipx_send_game_info(sequence_packet *their) Netgame.game_status = old_status; } -void net_ipx_send_lite_info(sequence_packet *their) +void net_ipx_send_lite_info(IPX_sequence_packet *their) { // Send game info to someone who requested it @@ -1941,10 +2211,10 @@ int net_ipx_send_request(void) Assert(i < MAX_NUM_NET_PLAYERS); - My_Seq.type = PID_REQUEST; - My_Seq.player.connected = Current_level_num; + IPX_Seq.type = PID_REQUEST; + IPX_Seq.player.connected = Current_level_num; - send_sequence_packet(My_Seq, Netgame.players[i].protocol.ipx.server, Netgame.players[i].protocol.ipx.node, NULL); + net_ipx_send_sequence_packet(IPX_Seq, Netgame.players[i].protocol.ipx.server, Netgame.players[i].protocol.ipx.node, NULL); return i; } @@ -1968,39 +2238,39 @@ void net_ipx_process_gameinfo(ubyte *data) return; // If this first half doesn't go with the second half } - Network_games_changed = 1; + num_active_ipx_changed = 1; Assert (TempPlayersInfo!=NULL); - for (i = 0; i < num_active_games; i++) + for (i = 0; i < num_active_ipx_games; i++) { - if (!stricmp(Active_games[i].game_name, new->game_name) && Active_games[i].protocol.ipx.Game_Security==new->protocol.ipx.Game_Security) + if (!stricmp(Active_ipx_games[i].game_name, new->game_name) && Active_ipx_games[i].protocol.ipx.Game_Security==new->protocol.ipx.Game_Security) break; } - if (i == MAX_ACTIVE_NETGAMES) + if (i == IPX_MAX_NETGAMES) { return; } - memcpy(&Active_games[i], (ubyte *)new, sizeof(netgame_info)); - memcpy (&Active_games[i].players,TempPlayersInfo->players,sizeof(netplayer_info)*(MAX_PLAYERS+4)); + memcpy(&Active_ipx_games[i], (ubyte *)new, sizeof(netgame_info)); + memcpy (&Active_ipx_games[i].players,TempPlayersInfo->players,sizeof(netplayer_info)*(MAX_PLAYERS+4)); if (SecurityCheck) - if (Active_games[i].protocol.ipx.Game_Security==SecurityCheck) + if (Active_ipx_games[i].protocol.ipx.Game_Security==SecurityCheck) SecurityCheck=-1; - if (i == num_active_games) - num_active_games++; + if (i == num_active_ipx_games) + num_active_ipx_games++; - if (Active_games[i].numplayers == 0) + if (Active_ipx_games[i].numplayers == 0) { // Delete this game - for (j = i; j < num_active_games-1; j++) + for (j = i; j < num_active_ipx_games-1; j++) { - memcpy(&Active_games[j], &Active_games[j+1], sizeof(netgame_info)); + memcpy(&Active_ipx_games[j], &Active_ipx_games[j+1], sizeof(netgame_info)); } - num_active_games--; + num_active_ipx_games--; SecurityCheck=0; } } @@ -2014,61 +2284,61 @@ void net_ipx_process_lite_info(ubyte *data) receive_netgame_packet(data, (netgame_info *)&tmp_info, 1); new = &tmp_info; - Network_games_changed = 1; + num_active_ipx_changed = 1; - for (i = 0; i < num_active_games; i++) + for (i = 0; i < num_active_ipx_games; i++) { - if ((!stricmp(Active_games[i].game_name, new->game_name)) && Active_games[i].protocol.ipx.Game_Security==new->protocol.ipx.Game_Security) + if ((!stricmp(Active_ipx_games[i].game_name, new->game_name)) && Active_ipx_games[i].protocol.ipx.Game_Security==new->protocol.ipx.Game_Security) break; } - if (i == MAX_ACTIVE_NETGAMES) + if (i == IPX_MAX_NETGAMES) { return; } - memcpy(&Active_games[i], (ubyte *)new, sizeof(netgame_info)); + memcpy(&Active_ipx_games[i], (ubyte *)new, sizeof(netgame_info)); // See if this is really a Hoard game // If so, adjust all the data accordingly if (HoardEquipped()) { - if (Active_games[i].game_flags & NETGAME_FLAG_HOARD) + if (Active_ipx_games[i].game_flags & NETGAME_FLAG_HOARD) { - Active_games[i].gamemode=NETGAME_HOARD; - Active_games[i].game_status=NETSTAT_PLAYING; + Active_ipx_games[i].gamemode=NETGAME_HOARD; + Active_ipx_games[i].game_status=NETSTAT_PLAYING; - if (Active_games[i].game_flags & NETGAME_FLAG_TEAM_HOARD) - Active_games[i].gamemode=NETGAME_TEAM_HOARD; - if (Active_games[i].game_flags & NETGAME_FLAG_REALLY_ENDLEVEL) - Active_games[i].game_status=NETSTAT_ENDLEVEL; - if (Active_games[i].game_flags & NETGAME_FLAG_REALLY_FORMING) - Active_games[i].game_status=NETSTAT_STARTING; + if (Active_ipx_games[i].game_flags & NETGAME_FLAG_TEAM_HOARD) + Active_ipx_games[i].gamemode=NETGAME_TEAM_HOARD; + if (Active_ipx_games[i].game_flags & NETGAME_FLAG_REALLY_ENDLEVEL) + Active_ipx_games[i].game_status=NETSTAT_ENDLEVEL; + if (Active_ipx_games[i].game_flags & NETGAME_FLAG_REALLY_FORMING) + Active_ipx_games[i].game_status=NETSTAT_STARTING; } } - if (i == num_active_games) - num_active_games++; + if (i == num_active_ipx_games) + num_active_ipx_games++; - if (Active_games[i].numplayers == 0) + if (Active_ipx_games[i].numplayers == 0) { // Delete this game - for (j = i; j < num_active_games-1; j++) + for (j = i; j < num_active_ipx_games-1; j++) { - memcpy(&Active_games[j], &Active_games[j+1], sizeof(netgame_info)); + memcpy(&Active_ipx_games[j], &Active_ipx_games[j+1], sizeof(netgame_info)); } - num_active_games--; + num_active_ipx_games--; } } -void net_ipx_process_dump(sequence_packet *their) +void net_ipx_process_dump(IPX_sequence_packet *their) { // Our request for join was denied. Tell the user why. char temp[40]; int i; - if (their->player.connected!=7) + if (their->player.connected!=CONNECT_KMATRIX_WAITING) { nm_messagebox(NULL, 1, TXT_OK, NET_DUMP_STRINGS(their->player.connected)); Network_status = NETSTAT_MENU; @@ -2089,7 +2359,6 @@ void net_ipx_process_dump(sequence_packet *their) nm_messagebox(NULL, 1, TXT_OK, &temp); if (Network_status==NETSTAT_PLAYING) { - IWasKicked=1; multi_leave_game(); } else @@ -2101,30 +2370,29 @@ void net_ipx_process_dump(sequence_packet *their) } } } -void net_ipx_process_request(sequence_packet *their) +void net_ipx_process_request(IPX_sequence_packet *their) { // Player is ready to receieve a sync packet int i; for (i = 0; i < N_players; i++) { if (!memcmp(their->player.protocol.ipx.server, Netgame.players[i].protocol.ipx.server, 4) && !memcmp(their->player.protocol.ipx.node, Netgame.players[i].protocol.ipx.node, 6) && (!stricmp(their->player.callsign, Netgame.players[i].callsign))) { - Players[i].connected = 1; + Players[i].connected = CONNECT_PLAYING; break; } } } -#define REFUSE_INTERVAL F1_0 * 8 extern void multi_reset_object_texture (object *); void net_ipx_process_packet(ubyte *data, int length ) { - sequence_packet *their = (sequence_packet *)data; - sequence_packet tmp_packet; + IPX_sequence_packet *their = (IPX_sequence_packet *)data; + IPX_sequence_packet tmp_packet; - memset(&tmp_packet, 0, sizeof(sequence_packet)); + memset(&tmp_packet, 0, sizeof(IPX_sequence_packet)); - receive_sequence_packet(data, &tmp_packet); + net_ipx_receive_sequence_packet(data, &tmp_packet); their = &tmp_packet; // reassign their to point to correctly alinged structure length = length; @@ -2212,7 +2480,7 @@ void net_ipx_process_packet(ubyte *data, int length ) { // Someone wants to join a game in progress! if (Netgame.RefusePlayers) - DoRefuseStuff (their); + net_ipx_do_refuse_stuff (their); else net_ipx_welcome_player(their); } @@ -2373,7 +2641,7 @@ net_ipx_read_endlevel_packet( ubyte *data ) { // Special packet for end of level syncing int playernum; - endlevel_info *end = (endlevel_info *)data; + IPX_endlevel_info *end = (IPX_endlevel_info *)data; #ifdef WORDS_BIGENDIAN int i, j; @@ -2394,7 +2662,7 @@ net_ipx_read_endlevel_packet( ubyte *data ) return; // if it happens in a coop restore, don't worry about it } - if ((Network_status == NETSTAT_PLAYING) && (end->connected != 0)) + if ((Network_status == NETSTAT_PLAYING) && (end->connected != CONNECT_DISCONNECTED)) return; // Only accept disconnect packets if we're not out of the level yet Players[playernum].connected = end->connected; @@ -2402,7 +2670,7 @@ net_ipx_read_endlevel_packet( ubyte *data ) Players[playernum].net_kills_total = end->kills; Players[playernum].net_killed_total = end->killed; - if ((Players[playernum].connected == 1) && (end->seconds_left < Countdown_seconds_left)) + if ((Players[playernum].connected == CONNECT_PLAYING) && (end->seconds_left < Countdown_seconds_left)) Countdown_seconds_left = end->seconds_left; Netgame.players[playernum].LastPacketTime = timer_get_approx_seconds(); @@ -2414,9 +2682,9 @@ net_ipx_read_endlevel_short_packet( ubyte *data ) // Special packet for end of level syncing int playernum; - endlevel_info_short *end; + IPX_endlevel_info_short *end; - end = (endlevel_info_short *)data; + end = (IPX_endlevel_info_short *)data; playernum = end->player_num; @@ -2428,14 +2696,14 @@ net_ipx_read_endlevel_short_packet( ubyte *data ) return; // if it happens in a coop restore, don't worry about it } - if ((Network_status == NETSTAT_PLAYING) && (end->connected != 0)) + if ((Network_status == NETSTAT_PLAYING) && (end->connected != CONNECT_DISCONNECTED)) { return; // Only accept disconnect packets if we're not out of the level yet } Players[playernum].connected = end->connected; - if ((Players[playernum].connected == 1) && (end->seconds_left < Countdown_seconds_left)) + if ((Players[playernum].connected == CONNECT_PLAYING) && (end->seconds_left < Countdown_seconds_left)) Countdown_seconds_left = end->seconds_left; Netgame.players[playernum].LastPacketTime = timer_get_approx_seconds(); @@ -2566,7 +2834,7 @@ net_ipx_read_object_packet( ubyte *data ) Assert(obj->segnum == -1); Assert(objnum < MAX_OBJECTS); memcpy(obj, &data[loc], sizeof(object)); - swap_object(obj); + net_ipx_swap_object(obj); loc += sizeof(object); segnum = obj->segnum; obj->next = obj->prev = obj->segnum = -1; @@ -2700,9 +2968,13 @@ void net_ipx_start_poll( int nitems, newmenu_item * menus, int * key, int citem } } -int opt_cinvul, opt_team_anarchy, opt_coop, opt_show_on_map, opt_closed,opt_maxnet; -int last_cinvul=0,last_maxnet,opt_team_hoard; -int opt_refuse,opt_capture; +static fix LastPTA; +static int LastKillGoal; +static int opt_cinvul, opt_team_anarchy, opt_coop, opt_show_on_map, opt_closed,opt_maxnet; +static int last_cinvul=0,last_maxnet,opt_team_hoard; +static int opt_refuse,opt_capture; +static int opt_setpower,opt_playtime,opt_killgoal,opt_marker_view,opt_light; +static int opt_difficulty,opt_packets, opt_bright,opt_start_invul, opt_show_names, opt_short_packets, opt_socket; void net_ipx_game_param_poll( int nitems, newmenu_item * menus, int * key, int citem ) { @@ -2729,7 +3001,7 @@ void net_ipx_game_param_poll( int nitems, newmenu_item * menus, int * key, int c menus[opt_maxnet].max_value=2; } - if (!Netgame.game_flags & NETGAME_FLAG_SHOW_MAP) + if (!(Netgame.game_flags & NETGAME_FLAG_SHOW_MAP)) Netgame.game_flags |= NETGAME_FLAG_SHOW_MAP; if (Netgame.PlayTimeAllowed || Netgame.KillGoal) @@ -2765,7 +3037,6 @@ int net_ipx_get_game_params() char level_text[32]; char srmaxnet[50]; - SetAllAllowablesTo (1); NamesInfoSecurity=-1; for (i=0;iplayers[i].protocol.ipx.node, My_Seq.player.protocol.ipx.node, 6 )) && (!stricmp( TempPlayersInfo->players[i].callsign, temp_callsign)) ) { + if ( (!memcmp( TempPlayersInfo->players[i].protocol.ipx.node, IPX_Seq.player.protocol.ipx.node, 6 )) && (!stricmp( TempPlayersInfo->players[i].callsign, temp_callsign)) ) { if (Player_num!=-1) { Int3(); // Hey, we've found ourselves twice Network_status = NETSTAT_MENU; @@ -3074,8 +3334,8 @@ void net_ipx_read_sync_packet( netgame_info * sp, int rsinit) team_kills[0] = sp->team_kills[0]; team_kills[1] = sp->team_kills[1]; - Players[Player_num].connected = 1; - Netgame.players[Player_num].connected = 1; + Players[Player_num].connected = CONNECT_PLAYING; + Netgame.players[Player_num].connected = CONNECT_PLAYING; Netgame.players[Player_num].rank=GetMyNetRanking(); if (!Network_rejoined) @@ -3104,7 +3364,7 @@ net_ipx_send_sync(void) for (i=0; i=FSPACX(55)) @@ -3503,15 +3755,15 @@ void net_ipx_join_poll( int nitems, newmenu_item * menus, int * key, int citem ) break; } - MissName[k++]=Active_games[i].mission_title[j]; + MissName[k++]=Active_ipx_games[i].mission_title[j]; } MissName[k]=0; for (x=0,tx=0,k=0,j=0;j<15;j++) { - if (Active_games[i].game_name[j]=='\t') + if (Active_ipx_games[i].game_name[j]=='\t') continue; - thold[0]=Active_games[i].game_name[j]; + thold[0]=Active_ipx_games[i].game_name[j]; gr_get_string_size (thold,&tx,&ty,&ta); if ((x+=tx)>=FSPACX(55)) @@ -3520,56 +3772,56 @@ void net_ipx_join_poll( int nitems, newmenu_item * menus, int * key, int citem ) k+=3; break; } - GameName[k++]=Active_games[i].game_name[j]; + GameName[k++]=Active_ipx_games[i].game_name[j]; } GameName[k]=0; - nplayers=Active_games[i].numconnected; + nplayers=Active_ipx_games[i].numconnected; - if (Active_games[i].levelnum < 0) - sprintf(levelname, "S%d", -Active_games[i].levelnum); + if (Active_ipx_games[i].levelnum < 0) + sprintf(levelname, "S%d", -Active_ipx_games[i].levelnum); else - sprintf(levelname, "%d", Active_games[i].levelnum); + sprintf(levelname, "%d", Active_ipx_games[i].levelnum); if (game_status == NETSTAT_STARTING) { sprintf (menus[i+2].text,"%d.\t%s \t%s \t %d/%d \t%s \t %s \t%s", - i+1,GameName,ModeLetters[Active_games[i].gamemode],nplayers, - Active_games[i].max_numplayers,MissName,levelname,"Forming"); + i+1,GameName,ModeLetters[Active_ipx_games[i].gamemode],nplayers, + Active_ipx_games[i].max_numplayers,MissName,levelname,"Forming"); } else if (game_status == NETSTAT_PLAYING) { - join_status=can_join_netgame(&Active_games[i]); + join_status=net_ipx_can_join_netgame(&Active_ipx_games[i]); if (join_status==1) sprintf (menus[i+2].text,"%d.\t%s \t%s \t %d/%d \t%s \t %s \t%s", - i+1,GameName,ModeLetters[Active_games[i].gamemode],nplayers, - Active_games[i].max_numplayers,MissName,levelname,"Open"); + i+1,GameName,ModeLetters[Active_ipx_games[i].gamemode],nplayers, + Active_ipx_games[i].max_numplayers,MissName,levelname,"Open"); else if (join_status==2) sprintf (menus[i+2].text,"%d.\t%s \t%s \t %d/%d \t%s \t %s \t%s", - i+1,GameName,ModeLetters[Active_games[i].gamemode],nplayers, - Active_games[i].max_numplayers,MissName,levelname,"Full"); + i+1,GameName,ModeLetters[Active_ipx_games[i].gamemode],nplayers, + Active_ipx_games[i].max_numplayers,MissName,levelname,"Full"); else if (join_status==3) sprintf (menus[i+2].text,"%d.\t%s \t%s \t %d/%d \t%s \t %s \t%s", - i+1,GameName,ModeLetters[Active_games[i].gamemode],nplayers, - Active_games[i].max_numplayers,MissName,levelname,"Restrict"); + i+1,GameName,ModeLetters[Active_ipx_games[i].gamemode],nplayers, + Active_ipx_games[i].max_numplayers,MissName,levelname,"Restrict"); else sprintf (menus[i+2].text,"%d.\t%s \t%s \t %d/%d \t%s \t %s \t%s", - i+1,GameName,ModeLetters[Active_games[i].gamemode],nplayers, - Active_games[i].max_numplayers,MissName,levelname,"Closed"); + i+1,GameName,ModeLetters[Active_ipx_games[i].gamemode],nplayers, + Active_ipx_games[i].max_numplayers,MissName,levelname,"Closed"); } else sprintf (menus[i+2].text,"%d.\t%s \t%s \t %d/%d \t%s \t %s \t%s", - i+1,GameName,ModeLetters[Active_games[i].gamemode],nplayers, - Active_games[i].max_numplayers,MissName,levelname,"Between"); + i+1,GameName,ModeLetters[Active_ipx_games[i].gamemode],nplayers, + Active_ipx_games[i].max_numplayers,MissName,levelname,"Between"); Assert(strlen(menus[i+2].text) < 100); } - for (i = num_active_games; i < MAX_ACTIVE_NETGAMES; i++) + for (i = num_active_ipx_games; i < IPX_MAX_NETGAMES; i++) { sprintf(menus[i+2].text, "%d. ",i+1); } @@ -3599,14 +3851,14 @@ net_ipx_wait_for_sync(void) if (Network_status != NETSTAT_PLAYING) { - sequence_packet me; + IPX_sequence_packet me; - memset(&me, 0, sizeof(sequence_packet)); + memset(&me, 0, sizeof(IPX_sequence_packet)); me.type = PID_QUIT_JOINING; memcpy( me.player.callsign, Players[Player_num].callsign, CALLSIGN_LEN+1 ); memcpy( me.player.protocol.ipx.node, ipxdrv_get_my_local_address(), 6 ); memcpy( me.player.protocol.ipx.server, ipxdrv_get_my_server_address(), 4 ); - send_sequence_packet(me, Netgame.players[0].protocol.ipx.server, Netgame.players[0].protocol.ipx.node, NULL); + net_ipx_send_sequence_packet(me, Netgame.players[0].protocol.ipx.server, Netgame.players[0].protocol.ipx.node, NULL); N_players = 0; Function_mode = FMODE_MENU; Game_mode = GM_GAME_OVER; @@ -3640,7 +3892,7 @@ net_ipx_request_poll( int nitems, newmenu_item * menus, int * key, int citem ) for (i = 0; i < N_players; i++) { - if ((Players[i].connected == 1) || (Players[i].connected == 0)) + if ((Players[i].connected == CONNECT_PLAYING) || (Players[i].connected == CONNECT_DISCONNECTED)) num_ready++; } @@ -3665,7 +3917,7 @@ net_ipx_wait_for_requests(void) Network_status = NETSTAT_WAITING; net_ipx_flush(); - Players[Player_num].connected = 1; + Players[Player_num].connected = CONNECT_PLAYING; menu: choice = newmenu_do(NULL, TXT_WAIT, 1, m, net_ipx_request_poll); @@ -3684,7 +3936,7 @@ menu: // User confirmed abort for (i=0; i < N_players; i++) { - if ((Players[i].connected != 0) && (i != Player_num)) { + if ((Players[i].connected != CONNECT_DISCONNECTED) && (i != Player_num)) { net_ipx_dump_player(Netgame.players[i].protocol.ipx.server, Netgame.players[i].protocol.ipx.node, DUMP_ABORTED); } } @@ -3719,7 +3971,7 @@ net_ipx_level_sync(void) if (result) { - Players[Player_num].connected = 0; + Players[Player_num].connected = CONNECT_DISCONNECTED; net_ipx_send_endlevel_packet(); longjmp(LeaveGame, 0); } @@ -3747,20 +3999,20 @@ void net_ipx_count_powerups_in_mine(void) int net_ipx_do_join_game(int choice) { - if (Active_games[choice].protocol.ipx.protocol_version != MULTI_PROTO_VERSION) + if (Active_ipx_games[choice].protocol.ipx.protocol_version != MULTI_PROTO_VERSION) { nm_messagebox(TXT_SORRY, 1, TXT_OK, TXT_VERSION_MISMATCH); return 0; } - if (Active_games[choice].game_status == NETSTAT_ENDLEVEL) + if (Active_ipx_games[choice].game_status == NETSTAT_ENDLEVEL) { nm_messagebox(TXT_SORRY, 1, TXT_OK, TXT_NET_GAME_BETWEEN2); return 0; } // Check for valid mission name - if (!load_mission_by_name(Active_games[choice].mission_name)) + if (!load_mission_by_name(Active_ipx_games[choice].mission_name)) { nm_messagebox(NULL, 1, TXT_OK, TXT_MISSION_NOT_FOUND); return 0; @@ -3768,8 +4020,8 @@ int net_ipx_do_join_game(int choice) if (is_D2_OEM) { - My_Seq.player.version_minor|=NETWORK_OEM; - if (Active_games[choice].levelnum>8) + IPX_Seq.player.version_minor|=0x10; + if (Active_ipx_games[choice].levelnum>8) { nm_messagebox(NULL, 1, TXT_OK, "This OEM version only supports\nthe first 8 levels!"); return 0; @@ -3778,7 +4030,7 @@ int net_ipx_do_join_game(int choice) if (is_MAC_SHARE) { - if (Active_games[choice].levelnum > 4) + if (Active_ipx_games[choice].levelnum > 4) { nm_messagebox(NULL, 1, TXT_OK, "This SHAREWARE version only supports\nthe first 4 levels!"); return 0; @@ -3794,9 +4046,9 @@ int net_ipx_do_join_game(int choice) Network_status = NETSTAT_BROWSING; // We are looking at a game menu - if (!can_join_netgame(&Active_games[choice])) + if (!net_ipx_can_join_netgame(&Active_ipx_games[choice])) { - if (Active_games[0].numplayers == Active_games[0].max_numplayers) + if (Active_ipx_games[0].numplayers == Active_ipx_games[0].max_numplayers) nm_messagebox(TXT_SORRY, 1, TXT_OK, TXT_GAME_FULL); else nm_messagebox(TXT_SORRY, 1, TXT_OK, TXT_IN_PROGRESS); @@ -3804,7 +4056,7 @@ int net_ipx_do_join_game(int choice) } // Choice is valid, prepare to join in - memcpy (&Netgame, &Active_games[choice], sizeof(netgame_info)); + memcpy (&Netgame, &Active_ipx_games[choice], sizeof(netgame_info)); memcpy (&Netgame.players,TempPlayersInfo->players,sizeof(netplayer_info)*(MAX_PLAYERS+4)); Difficulty_level = Netgame.difficulty; @@ -3820,17 +4072,17 @@ int net_ipx_do_join_game(int choice) void nm_draw_background1(char * filename); -int show_game_stats(int choice); +int net_ipx_show_game_stats(int choice); int net_ipx_do_join_game(int choice); void net_ipx_join_game() { int choice, i; - char menu_text[MAX_ACTIVE_NETGAMES+2][200]; + char menu_text[IPX_MAX_NETGAMES+2][200]; - newmenu_item m[MAX_ACTIVE_NETGAMES+2]; + newmenu_item m[IPX_MAX_NETGAMES+2]; - if ( !Network_active ) + if ( !IPX_active ) { nm_messagebox(NULL, 1, TXT_OK, TXT_IPX_NOT_FOUND); return; @@ -3853,16 +4105,16 @@ void net_ipx_join_game() net_ipx_send_game_list_request(); // broadcast a request for lists - num_active_games = 0; + num_active_ipx_games = 0; - memset(m, 0, sizeof(newmenu_item)*MAX_ACTIVE_NETGAMES); - memset(Active_games, 0, sizeof(netgame_info)*MAX_ACTIVE_NETGAMES); + memset(m, 0, sizeof(newmenu_item)*IPX_MAX_NETGAMES); + memset(Active_ipx_games, 0, sizeof(netgame_info)*IPX_MAX_NETGAMES); gr_set_fontcolor(BM_XRGB(15,15,23),-1); m[0].text = menu_text[0]; m[0].type = NM_TYPE_TEXT; - if (Network_allow_socket_changes) + if (IPX_allow_socket_changes) sprintf( m[0].text, "\tCurrent IPX Socket is default %+d (PgUp/PgDn to change)", IPX_Socket ); else strcpy( m[0].text, "" ); //sprintf( m[0].text, "" ); @@ -3871,18 +4123,18 @@ void net_ipx_join_game() m[1].type=NM_TYPE_TEXT; sprintf (m[1].text,"\tGAME \tMODE \t#PLYRS \tMISSION \tLEV \tSTATUS"); - for (i = 0; i < MAX_ACTIVE_NETGAMES; i++) { + for (i = 0; i < IPX_MAX_NETGAMES; i++) { m[i+2].text = menu_text[i+2]; m[i+2].type = NM_TYPE_MENU; sprintf(m[i+2].text, "%d. ", i+1); } - Network_games_changed = 1; + num_active_ipx_changed = 1; remenu: SurfingNet=1; nm_draw_background1(Menu_pcx_name); //load this here so if we abort after loading level, we restore the palette gr_palette_load(gr_palette); - choice=newmenu_dotiny("NETGAMES", NULL,MAX_ACTIVE_NETGAMES+2, m, net_ipx_join_poll); + choice=newmenu_dotiny("NETGAMES", NULL,IPX_MAX_NETGAMES+2, m, net_ipx_join_poll); SurfingNet=0; if (choice==-1) { @@ -3891,13 +4143,13 @@ remenu: } choice-=2; - if (choice >=num_active_games) + if (choice >=num_active_ipx_games) { nm_messagebox(TXT_SORRY, 1, TXT_OK, TXT_INVALID_CHOICE); goto remenu; } - if (show_game_stats(choice)==0) + if (net_ipx_show_game_stats(choice)==0) goto remenu; // Choice has been made and looks legit @@ -3941,7 +4193,7 @@ int net_ipx_wait_for_all_info (int choice) WaitAllChoice=choice; StartWaitAllTime=timer_get_approx_seconds(); - SecurityCheck=Active_games[choice].protocol.ipx.Game_Security; + SecurityCheck=Active_ipx_games[choice].protocol.ipx.Game_Security; NetSecurityFlag=0; GetMenu: @@ -3988,8 +4240,8 @@ void net_ipx_do_big_wait(int choice) { if (TempPlayersInfo->protocol.ipx.Player_Security==SecurityCheck) { - memcpy (&Active_games[choice],(ubyte *)&TempNetInfo,sizeof(netgame_info)); - memcpy (&Active_games[choice].players, TempPlayersInfo->players, sizeof(netplayer_info)*(MAX_PLAYERS+4)); + memcpy (&Active_ipx_games[choice],(ubyte *)&TempNetInfo,sizeof(netgame_info)); + memcpy (&Active_ipx_games[choice].players, TempPlayersInfo->players, sizeof(netplayer_info)*(MAX_PLAYERS+4)); SecurityCheck=-1; } } @@ -4001,8 +4253,8 @@ void net_ipx_do_big_wait(int choice) if (net_ipx_wait_for_playerinfo()) { - memcpy (&Active_games[choice],(ubyte *)&TempNetInfo,sizeof(netgame_info)); - memcpy (&Active_games[choice].players, TempPlayersInfo->players, sizeof(netplayer_info)*(MAX_PLAYERS+4)); + memcpy (&Active_ipx_games[choice],(ubyte *)&TempNetInfo,sizeof(netgame_info)); + memcpy (&Active_ipx_games[choice].players, TempPlayersInfo->players, sizeof(netplayer_info)*(MAX_PLAYERS+4)); SecurityCheck=-1; } @@ -4052,7 +4304,7 @@ void net_ipx_leave_game() } - Players[Player_num].connected = 0; + Players[Player_num].connected = CONNECT_DISCONNECTED; net_ipx_send_endlevel_packet(); change_playernum_to(0); Game_mode = GM_GAME_OVER; @@ -4065,7 +4317,7 @@ void net_ipx_flush() { ubyte packet[MAX_DATA_SIZE]; - if (!Network_active) return; + if (!IPX_active) return; while (ipxdrv_get_packet_data(packet) > 0) ; } @@ -4081,7 +4333,7 @@ void net_ipx_listen() loopmax=N_players*Netgame.PacketsPerSec; } - if (!Network_active) return; + if (!IPX_active) return; WaitingForPlayerInfo=1; NetSecurityFlag=NETSECURITY_OFF; @@ -4105,7 +4357,7 @@ int net_ipx_wait_for_playerinfo() ubyte id; netgame_info info_struct; - if (!Network_active) return(0); + if (!IPX_active) return(0); if (Network_status==NETSTAT_PLAYING) { @@ -4172,7 +4424,7 @@ void net_ipx_send_data( ubyte * ptr, int len, int urgent ) if (!MySyncPackInitialized) { MySyncPackInitialized = 1; - memset( &MySyncPack, 0, sizeof(frame_info) ); + memset( &MySyncPack, 0, sizeof(IPX_frame_info) ); } if (urgent) @@ -4219,11 +4471,8 @@ void net_ipx_timeout_player(int playernum) } } -fix last_send_time = 0; -fix last_timeout_check = 0; - #ifdef WORDS_BIGENDIAN -void squish_short_frame_info(short_frame_info old_info, ubyte *data) +void squish_short_frame_info(IPX_short_frame_info old_info, ubyte *data) { int loc = 0; int tmpi; @@ -4267,11 +4516,14 @@ int NakedPacketDestPlayer=-1; void net_ipx_do_frame(int force, int listen) { int i; - short_frame_info ShortSyncPack; + IPX_short_frame_info ShortSyncPack; static fix LastEndlevel=0; + static fix last_send_time = 0, last_timeout_check = 0; if (!(Game_mode&GM_NETWORK)) return; + net_ipx_ping_all(timer_get_fixed_seconds()); + if ((Network_status != NETSTAT_PLAYING) || (Endlevel_sequence)) // Don't send postion during escape sequence... goto listen; @@ -4310,7 +4562,7 @@ void net_ipx_do_frame(int force, int listen) #endif int i; - memset(&ShortSyncPack,0,sizeof(short_frame_info)); + memset(&ShortSyncPack,0,sizeof(IPX_short_frame_info)); create_shortpos(&ShortSyncPack.thepos, Objects+objnum, 0); ShortSyncPack.type = PID_PDATA; ShortSyncPack.playernum = Player_num; @@ -4322,10 +4574,10 @@ void net_ipx_do_frame(int force, int listen) MySyncPack.numpackets = INTEL_INT(Players[0].n_packets_sent++); ShortSyncPack.numpackets = MySyncPack.numpackets; #ifndef WORDS_BIGENDIAN -// ipxdrvSendGamePacket((ubyte*)&ShortSyncPack, sizeof(short_frame_info) - MaxXDataSize + MySyncPack.data_size); +// ipxdrvSendGamePacket((ubyte*)&ShortSyncPack, sizeof(IPX_short_frame_info) - MaxXDataSize + MySyncPack.data_size); for(i=0; idata_size, Netgame.players[i].protocol.ipx.server, Netgame.players[i].protocol.ipx.node, Players[i].net_address); + ipxdrv_send_packet_data((ubyte *)&MySyncPack, sizeof(IPX_frame_info) - NET_XDATA_SIZE + (&MySyncPack)->data_size, Netgame.players[i].protocol.ipx.server, Netgame.players[i].protocol.ipx.node, Players[i].net_address); } } } @@ -4370,7 +4622,7 @@ void net_ipx_do_frame(int force, int listen) if (Control_center_destroyed) { if (Player_is_dead) - Players[Player_num].connected=3; + Players[Player_num].connected=CONNECT_DIED_IN_MINE; if (timer_get_approx_seconds() > (LastEndlevel+(F1_0/2))) { net_ipx_send_endlevel_packet(); @@ -4389,17 +4641,17 @@ void net_ipx_do_frame(int force, int listen) // Check for player timeouts for (i = 0; i < N_players; i++) { - if ((i != Player_num) && (Players[i].connected == 1)) + if ((i != Player_num) && (Players[i].connected == CONNECT_PLAYING)) { if ((Netgame.players[i].LastPacketTime == 0) || (Netgame.players[i].LastPacketTime > approx_time)) { Netgame.players[i].LastPacketTime = approx_time; continue; } - if ((approx_time - Netgame.players[i].LastPacketTime) > NETWORK_TIMEOUT) + if ((approx_time - Netgame.players[i].LastPacketTime) > IPX_TIMEOUT) net_ipx_timeout_player(i); } - if(Players[i].connected != 1 && Objects[Players[i].objnum].type != OBJ_GHOST) + if(Players[i].connected != CONNECT_PLAYING && Objects[Players[i].objnum].type != OBJ_GHOST) { HUD_init_message( "'%s' has left.", Players[i].callsign ); multi_make_player_ghost(i); @@ -4417,7 +4669,7 @@ listen: net_ipx_listen(); if (VerifyPlayerJoined!=-1 && !(FrameCount & 63)) - resend_sync_due_to_packet_loss_for_allender(); // This will resend to network_player_rejoining + resend_sync_due_to_packet_loss_for_allender(); // This will resend to IPX_sync_player if (Network_send_objects) net_ipx_send_objects(); @@ -4429,36 +4681,17 @@ listen: } } -int missed_packets = 0; - -int ConsistencyCount = 0; - -void net_ipx_consistency_error(void) -{ - if (++ConsistencyCount < 10) - return; - - Function_mode = FMODE_MENU; - nm_messagebox(NULL, 1, TXT_OK, TXT_CONSISTENCY_ERROR); - Function_mode = FMODE_GAME; - ConsistencyCount = 0; - multi_quit_game = 1; - multi_leave_menu = 1; - multi_reset_stuff(); - Function_mode = FMODE_MENU; -} - void net_ipx_process_pdata (char *data) { Assert (Game_mode & GM_NETWORK); if (Netgame.protocol.ipx.ShortPackets) - net_ipx_read_pdata_short_packet ((short_frame_info *)data); + net_ipx_read_pdata_short_packet ((IPX_short_frame_info *)data); else - net_ipx_read_pdata_packet ((frame_info *) data); + net_ipx_read_pdata_packet ((IPX_frame_info *) data); } -void net_ipx_read_pdata_packet(frame_info *pd) +void net_ipx_read_pdata_packet(IPX_frame_info *pd) { int TheirPlayernum; int TheirObjnum; @@ -4483,7 +4716,7 @@ void net_ipx_read_pdata_packet(frame_info *pd) if (Network_status!=NETSTAT_WAITING) { Int3(); // We missed an important packet! - net_ipx_consistency_error(); + multi_consistency_error(0); return; } else @@ -4511,15 +4744,12 @@ void net_ipx_read_pdata_packet(frame_info *pd) //------------- Keep track of missed packets ----------------- Players[TheirPlayernum].n_packets_got++; - TotalPacketsGot++; + IPX_TotalPacketsGot++; Netgame.players[TheirPlayernum].LastPacketTime = timer_get_approx_seconds(); if ( pd->numpackets != Players[TheirPlayernum].n_packets_got ) { - int missed_packets; - - missed_packets = pd->numpackets-Players[TheirPlayernum].n_packets_got; if ((pd->numpackets-Players[TheirPlayernum].n_packets_got)>0) - TotalMissedPackets += pd->numpackets-Players[TheirPlayernum].n_packets_got; + IPX_TotalMissedPackets += pd->numpackets-Players[TheirPlayernum].n_packets_got; Players[TheirPlayernum].n_packets_got = pd->numpackets; } @@ -4540,7 +4770,7 @@ void net_ipx_read_pdata_packet(frame_info *pd) //------------ Welcome them back if reconnecting -------------- if (!Players[TheirPlayernum].connected) { - Players[TheirPlayernum].connected = 1; + Players[TheirPlayernum].connected = CONNECT_PLAYING; if (Newdemo_state == ND_STATE_RECORDING) newdemo_record_multi_reconnect(TheirPlayernum); @@ -4571,7 +4801,7 @@ void net_ipx_read_pdata_packet(frame_info *pd) } -void net_ipx_read_pdata_short_packet(short_frame_info *pd) +void net_ipx_read_pdata_short_packet(IPX_short_frame_info *pd) { int TheirPlayernum; int TheirObjnum; @@ -4588,7 +4818,7 @@ void net_ipx_read_pdata_short_packet(short_frame_info *pd) if (Network_status!=NETSTAT_WAITING) { Int3(); // We missed an important packet! - net_ipx_consistency_error(); + multi_consistency_error(0); return; } else @@ -4621,15 +4851,12 @@ void net_ipx_read_pdata_short_packet(short_frame_info *pd) //------------- Keep track of missed packets ----------------- Players[TheirPlayernum].n_packets_got++; - TotalPacketsGot++; + IPX_TotalPacketsGot++; Netgame.players[TheirPlayernum].LastPacketTime = timer_get_approx_seconds(); if ( pd->numpackets != Players[TheirPlayernum].n_packets_got ) { - int missed_packets; - - missed_packets = pd->numpackets-Players[TheirPlayernum].n_packets_got; if ((pd->numpackets-Players[TheirPlayernum].n_packets_got)>0) - TotalMissedPackets += pd->numpackets-Players[TheirPlayernum].n_packets_got; + IPX_TotalMissedPackets += pd->numpackets-Players[TheirPlayernum].n_packets_got; Players[TheirPlayernum].n_packets_got = pd->numpackets; } @@ -4646,7 +4873,7 @@ void net_ipx_read_pdata_short_packet(short_frame_info *pd) //------------ Welcome them back if reconnecting -------------- if (!Players[TheirPlayernum].connected) { - Players[TheirPlayernum].connected = 1; + Players[TheirPlayernum].connected = CONNECT_PLAYING; if (Newdemo_state == ND_STATE_RECORDING) newdemo_record_multi_reconnect(TheirPlayernum); @@ -4764,36 +4991,6 @@ void net_ipx_set_power (void) } } -void SetAllAllowablesTo (int on) -{ - last_cinvul = 0; //default to zero -/* - Netgame.DoMegas=Netgame.DoSmarts=Netgame.DoFusions=Netgame.DoHelix=\ - Netgame.DoPhoenix=Netgame.DoCloak=Netgame.DoInvulnerability=\ - Netgame.DoAfterburner=Netgame.DoGauss=Netgame.DoVulcan=Netgame.DoPlasma=on; - - Netgame.DoOmega=Netgame.DoSuperLaser=Netgame.DoProximity=\ - Netgame.DoSpread=Netgame.DoMercury=Netgame.DoSmartMine=Netgame.DoFlash=\ - Netgame.DoGuided=Netgame.DoEarthShaker=on; - - Netgame.DoConverter=Netgame.DoAmmoRack=Netgame.DoHeadlight=on; - Netgame.DoHoming=Netgame.DoLaserUpgrade=Netgame.DoQuadLasers=on; - Netgame.BrightPlayers=Netgame.invul=on; - */ - Netgame.AllowedItems=0; - if (on) - Netgame.AllowedItems |= NETFLAG_DOPOWERUP; - Netgame.BrightPlayers=Netgame.InvulAppear=on; -} - -fix LastPTA; -int LastKillGoal; - -// Jeez -- mac compiler can't handle all of these on the same decl line. -int opt_setpower,opt_playtime,opt_killgoal,opt_socket,opt_marker_view,opt_light,opt_show_on_map; -int opt_difficulty,opt_packets,opt_short_packets, opt_bright,opt_start_invul; -int opt_show_names; - void net_ipx_more_options_poll( int nitems, newmenu_item * menus, int * key, int citem ); void net_ipx_more_game_options () @@ -5005,28 +5202,28 @@ void net_ipx_handle_ping_return (ubyte pnum) } // ping all connected players (except yourself) in 3sec interval and update ping_table -void net_ipx_ping_all() +void net_ipx_ping_all(fix time) { int i; static fix PingTime=0; Netgame.players[Player_num].ping = -1; // Set mine to fancy -1 because I am super fast! Weeee - if (PingTime+(F1_0*3) GameTime) + if (PingTime+(F1_0*3)