From 0c36fecb4261ac7be1d24c648fc5ce647db0e44d Mon Sep 17 00:00:00 2001 From: zicodxx <> Date: Fri, 20 Mar 2009 12:10:38 +0000 Subject: [PATCH] Abstracting networking protocols - Step 2: Introducing new structure to hold protocol-dependend and -independend information about Netgame and it's Players; Further isolation of the IPX code and renaming the netdrv_* code to ipxdrv_* as this is now actually IPX-only; Next up: Renaming network_* functions to net_ipx_*, writing wrappers for protocol dependend functions in multi.c, Implementing protocol selection and Cleanup --- CHANGELOG.txt | 4 + SConstruct | 6 +- arch/linux/ipx.c | 6 +- arch/linux/ipx_kali.c | 6 +- arch/win32/ipx.c | 6 +- include/{netdrv.h => ipxdrv.h} | 28 +- main/automap.c | 1 - main/collide.c | 3 +- main/endlevel.c | 5 +- main/fireball.c | 1 - main/gameseq.c | 115 +++- main/{netdrv.c => ipxdrv.c} | 87 ++- main/menu.c | 21 +- main/multi.c | 35 +- main/multi.h | 223 +++++-- main/multipow.c | 20 - main/multipow.h | 24 - main/net_ipx.c | 1089 +++++++++++++------------------- main/net_ipx.h | 83 ++- main/netpkt.c | 786 ----------------------- main/netpkt.h | 34 - main/newdemo.c | 1 - main/powerup.c | 6 +- main/state.c | 4 +- main/switch.c | 3 +- 25 files changed, 851 insertions(+), 1746 deletions(-) rename include/{netdrv.h => ipxdrv.h} (70%) rename main/{netdrv.c => ipxdrv.c} (77%) delete mode 100644 main/multipow.c delete mode 100644 main/multipow.h delete mode 100644 main/netpkt.c delete mode 100644 main/netpkt.h diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 3a8abb7f9..64fea4ddd 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,5 +1,9 @@ D1X-Rebirth Changelog +20090320 +-------- +include/ipxdrv.h, main/ipxdrv.c, main/newmenu.c, main/fireball.c, main/multi.c, main/multi.h, main/menu.c, main/state.c, main/newdemo.c, main/net_ipx.c, main/net_ipx.h, main/gameseq.c, main/endlevel.c, main/game.c, main/gamecntl.c, SConstruct, arch/linux/ipx.c, arch/linux/ipx_kali.c, arch/win32/ipx.c: Abstracting networking protocols - Step 2: Introducing new structure to hold protocol-dependend and -independend information about Netgame and it's Players; Further isolation of the IPX code and renaming the netdrv_* code to ipxdrv_* as this is now actually IPX-only; Next up: Renaming network_* functions to net_ipx_*, writing wrappers for protocol dependend functions in multi.c, Implementing protocol selection and Cleanup + 20090304 -------- various: Abstracting networking protocols - Step 1: Renaming network-related files; Removing net_ipx.h (former network.h) includes from as much files as possible to make isolation of IPX-related functions easier in Step 2; Version defines Cleanup - needed later for good Version-Checking diff --git a/SConstruct b/SConstruct index ac9c4cb70..7d8fe89fc 100644 --- a/SConstruct +++ b/SConstruct @@ -116,6 +116,7 @@ common_sources = [ 'main/hostage.c', 'main/hud.c', 'main/inferno.c', +'main/ipxdrv.c', 'main/kconfig.c', 'main/kmatrix.c', 'main/laser.c', @@ -126,14 +127,9 @@ common_sources = [ 'main/morph.c', 'main/multi.c', 'main/multibot.c', -'main/multipow.c', 'main/net_ipx.c', -'main/netdrv.c', -'main/netdrv_udp.c', -'main/netpkt.c', 'main/newdemo.c', 'main/newmenu.c', -'main/noloss.c', 'main/object.c', 'main/paging.c', 'main/physics.c', diff --git a/arch/linux/ipx.c b/arch/linux/ipx.c index 0ebc33623..5e0e66502 100644 --- a/arch/linux/ipx.c +++ b/arch/linux/ipx.c @@ -16,7 +16,7 @@ #include #include #include -#include "netdrv.h" +#include "ipxdrv.h" #include "console.h" static int ipx_get_my_address( void ) @@ -171,10 +171,10 @@ static int ipx_receive_packet(socket_t *s, char *buffer, int bufsize, struct rec static int ipx_general_packet_ready(socket_t *s) { - return netdrv_general_packet_ready(s->fd); + return ipxdrv_general_packet_ready(s->fd); } -struct net_driver netdrv_ipx = { +struct net_driver ipxdrv_ipx = { ipx_open_socket, ipx_close_socket, ipx_send_packet, diff --git a/arch/linux/ipx_kali.c b/arch/linux/ipx_kali.c index 66809b7ba..b894c41e4 100644 --- a/arch/linux/ipx_kali.c +++ b/arch/linux/ipx_kali.c @@ -2,7 +2,7 @@ #include #include #include /* for htons & co. */ -#include "netdrv.h" +#include "ipxdrv.h" #include "ukali.h" #include "console.h" @@ -104,10 +104,10 @@ int kali_receive_packet(socket_t *s, char *outbuf, int outbufsize, struct recv_d static int kali_general_packet_ready(socket_t *s) { - return netdrv_general_packet_ready(s->fd); + return ipxdrv_general_packet_ready(s->fd); } -struct net_driver netdrv_kali = { +struct net_driver ipxdrv_kali = { kali_open_socket, kali_close_socket, kali_send_packet, diff --git a/arch/win32/ipx.c b/arch/win32/ipx.c index 8a95355b7..42079b14d 100644 --- a/arch/win32/ipx.c +++ b/arch/win32/ipx.c @@ -4,7 +4,7 @@ #include #include #include -#include "netdrv.h" +#include "ipxdrv.h" #include "console.h" static int ipx_get_my_address( void ) @@ -128,10 +128,10 @@ static int ipx_receive_packet(socket_t *s, char *buffer, int bufsize, struct rec static int ipx_general_packet_ready(socket_t *s) { - return netdrv_general_packet_ready(s->fd); + return ipxdrv_general_packet_ready(s->fd); } -struct net_driver netdrv_ipx = { +struct net_driver ipxdrv_ipx = { ipx_open_socket, ipx_close_socket, ipx_send_packet, diff --git a/include/netdrv.h b/include/ipxdrv.h similarity index 70% rename from include/netdrv.h rename to include/ipxdrv.h index 9b3dfb5f8..6598725c8 100644 --- a/include/netdrv.h +++ b/include/ipxdrv.h @@ -23,7 +23,6 @@ #define NETPROTO_IPX 1 #define NETPROTO_KALINIX 2 -#define NETPROTO_UDP 3 typedef struct IPXAddressStruct { ubyte Network[4]; @@ -64,25 +63,24 @@ struct net_driver { int type; // type of driver (NETPROTO_*). Can be used to make driver-specific rules in other parts of the multiplayer code. }; -extern int netdrv_general_packet_ready(int fd); -extern void netdrv_get_local_target( ubyte * server, ubyte * node, ubyte * local_target ); -extern int netdrv_set(int arg); -extern int netdrv_change_default_socket( ushort socket_number ); -extern ubyte * netdrv_get_my_local_address(); -extern ubyte * netdrv_get_my_server_address(); -extern int netdrv_get_packet_data( ubyte * data ); -extern void netdrv_send_broadcast_packet_data( ubyte * data, int datasize ); -extern void netdrv_send_packet_data( ubyte * data, int datasize, ubyte *network, ubyte *address, ubyte *immediate_address ); -extern void netdrv_send_internetwork_packet_data( ubyte * data, int datasize, ubyte * server, ubyte *address ); -extern int netdrv_type(void); +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 netdrv_ipx; +extern struct net_driver ipxdrv_ipx; #endif #ifdef __LINUX__ -extern struct net_driver netdrv_kali; +extern struct net_driver ipxdrv_kali; #endif -extern struct net_driver netdrv_udp; extern unsigned char MyAddress[10]; extern ubyte broadcast_addr[]; diff --git a/main/automap.c b/main/automap.c index df9200940..7535a9633 100644 --- a/main/automap.c +++ b/main/automap.c @@ -58,7 +58,6 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "fuelcen.h" #include "gameseq.h" #include "gamefont.h" -#include "net_ipx.h" #include "kconfig.h" #include "multi.h" #include "endlevel.h" diff --git a/main/collide.c b/main/collide.c index ede163f29..de40031c1 100644 --- a/main/collide.c +++ b/main/collide.c @@ -66,7 +66,6 @@ static char rcsid[] = "$Id: collide.c,v 1.1.1.1 2006/03/17 19:41:32 zicodxx Exp #include "piggy.h" #include "text.h" #include "maths.h" -#include "multipow.h" #ifdef EDITOR #include "editor/editor.h" @@ -1066,7 +1065,7 @@ void drop_pow_count(object *obj, int *pow_count) // limit powerups in D1X network games #ifdef NETWORK if ((Game_mode & GM_NETWORK) && - (Netgame.protocol_version == MULTI_PROTO_D1X_VER)) + (Netgame.protocol.ipx.protocol_version == MULTI_PROTO_D1X_VER)) { if (multi_allow_powerup_mask[i]) { // only check 'important' powerups (no shield,energy,conc) diff --git a/main/endlevel.c b/main/endlevel.c index ef249a7f0..f56507321 100644 --- a/main/endlevel.c +++ b/main/endlevel.c @@ -52,7 +52,6 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "multi.h" #include "vclip.h" #include "fireball.h" -#include "net_ipx.h" #include "text.h" #include "digi.h" #include "cfile.h" @@ -223,7 +222,7 @@ void start_endlevel_sequence() if (Game_mode & GM_MULTI) { multi_send_endlevel_start(0); #ifdef NETWORK - network_do_frame(1, 1); + multi_do_protocol_frame(1, 1); #endif } #endif @@ -279,7 +278,7 @@ void start_endlevel_sequence() #ifdef NETWORK if (Game_mode & GM_MULTI) { multi_send_endlevel_start(0); - network_do_frame(1, 1); + multi_do_protocol_frame(1, 1); } #endif diff --git a/main/fireball.c b/main/fireball.c index 6f2de1397..b20203def 100644 --- a/main/fireball.c +++ b/main/fireball.c @@ -49,7 +49,6 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "fuelcen.h" #include "gameseg.h" #include "fireball.h" -#include "multipow.h" #define EXPLOSION_SCALE fl2f(2.5) //explosion is the obj size times this diff --git a/main/gameseq.c b/main/gameseq.c index 8f92a8e16..59276989a 100644 --- a/main/gameseq.c +++ b/main/gameseq.c @@ -91,7 +91,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "state.h" #include "songs.h" #ifdef NETWORK -#include "netpkt.h" +#include "multi.h" #endif #include "strutil.h" @@ -656,6 +656,117 @@ char *get_level_file(int level_num) #endif } +//FIXME: Certain combinations of players having and not having the editor will cause the segment checksum code to fail. +#ifdef WORDS_BIGENDIAN + +#include "byteswap.h" +#include "segment.h" +#include "gameseg.h" + +// routine to calculate the checksum of the segments. We add these specialized routines +// since the current way is byte order dependent. + +void mac_do_checksum_calc(ubyte *b, int len, unsigned int *s1, unsigned int *s2) +{ + + while(len--) { + *s1 += *b++; + if (*s1 >= 255) *s1 -= 255; + *s2 += *s1; + } +} + +ushort mac_calc_segment_checksum() +{ + int i, j, k; + unsigned int sum1,sum2; + short s; + int t; + + sum1 = sum2 = 0; + for (i = 0; i < Highest_segment_index + 1; i++) { + for (j = 0; j < MAX_SIDES_PER_SEGMENT; j++) { + mac_do_checksum_calc((unsigned char *)&(Segments[i].sides[j].type), 1, &sum1, &sum2); + mac_do_checksum_calc(&(Segments[i].sides[j].pad), 1, &sum1, &sum2); + s = INTEL_SHORT(Segments[i].sides[j].wall_num); + mac_do_checksum_calc((ubyte *)&s, 2, &sum1, &sum2); + s = INTEL_SHORT(Segments[i].sides[j].tmap_num); + mac_do_checksum_calc((ubyte *)&s, 2, &sum1, &sum2); + s = INTEL_SHORT(Segments[i].sides[j].tmap_num2); + mac_do_checksum_calc((ubyte *)&s, 2, &sum1, &sum2); + for (k = 0; k < 4; k++) { + t = INTEL_INT(((int)Segments[i].sides[j].uvls[k].u)); + mac_do_checksum_calc((ubyte *)&t, 4, &sum1, &sum2); + t = INTEL_INT(((int)Segments[i].sides[j].uvls[k].v)); + mac_do_checksum_calc((ubyte *)&t, 4, &sum1, &sum2); + t = INTEL_INT(((int)Segments[i].sides[j].uvls[k].l)); + mac_do_checksum_calc((ubyte *)&t, 4, &sum1, &sum2); + } + for (k = 0; k < 2; k++) { + t = INTEL_INT(((int)Segments[i].sides[j].normals[k].x)); + mac_do_checksum_calc((ubyte *)&t, 4, &sum1, &sum2); + t = INTEL_INT(((int)Segments[i].sides[j].normals[k].y)); + mac_do_checksum_calc((ubyte *)&t, 4, &sum1, &sum2); + t = INTEL_INT(((int)Segments[i].sides[j].normals[k].z)); + mac_do_checksum_calc((ubyte *)&t, 4, &sum1, &sum2); + } + } + for (j = 0; j < MAX_SIDES_PER_SEGMENT; j++) { + s = INTEL_SHORT(Segments[i].children[j]); + mac_do_checksum_calc((ubyte *)&s, 2, &sum1, &sum2); + } + for (j = 0; j < MAX_VERTICES_PER_SEGMENT; j++) { + s = INTEL_SHORT(Segments[i].verts[j]); + mac_do_checksum_calc((ubyte *)&s, 2, &sum1, &sum2); + } + s = INTEL_SHORT(Segments[i].objects); + mac_do_checksum_calc((ubyte *)&s, 2, &sum1, &sum2); + mac_do_checksum_calc((unsigned char *)&(Segments[i].special), 1, &sum1, &sum2); + mac_do_checksum_calc((unsigned char *)&(Segments[i].matcen_num), 1, &sum1, &sum2); + s = INTEL_SHORT(Segments[i].value); + mac_do_checksum_calc((ubyte *)&s, 2, &sum1, &sum2); + t = INTEL_INT(((int)Segments[i].static_light)); + mac_do_checksum_calc((ubyte *)&t, 4, &sum1, &sum2); +#ifndef EDITOR + s = INTEL_SHORT(Segments[i].pad); // necessary? If this isn't set to 0 it won't work Intel-Intel anyway. + mac_do_checksum_calc((ubyte *)&s, 2, &sum1, &sum2); +#endif + } + sum2 %= 255; + return ((sum1<<8)+ sum2); +} + +// this routine totally and completely relies on the fact that the network +// checksum must be calculated on the segments!!!!! + +ushort netmisc_calc_checksum(void * vptr, int len) +{ + vptr = vptr; + len = len; + return mac_calc_segment_checksum(); +} +#else /* !WORDS_BIGENDIAN */ + +// Calculates the checksum of a block of memory. +ushort netmisc_calc_checksum(void * vptr, int len) +{ + ubyte *ptr = (ubyte *)vptr; + unsigned int sum1,sum2; + + sum1 = sum2 = 0; + + while(len--) { + sum1 += *ptr++; + if (sum1 >= 255) sum1 -= 255; + sum2 += sum1; + } + sum2 %= 255; + + return ((sum1<<8)+ sum2); +} + +#endif /* WORDS_BIGENDIAN */ + //load a level off disk. level numbers start at 1. Secret levels are -1,-2,-3 void LoadLevel(int level_num) { @@ -1357,7 +1468,7 @@ void StartLevel(int random) } if (Game_mode & GM_NETWORK) - network_do_frame(1, 1); + multi_do_protocol_frame(1, 1); #endif ai_reset_all_paths(); diff --git a/main/netdrv.c b/main/ipxdrv.c similarity index 77% rename from main/netdrv.c rename to main/ipxdrv.c index 88d80a1ec..e372c837b 100644 --- a/main/netdrv.c +++ b/main/ipxdrv.c @@ -14,16 +14,10 @@ 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. * */ -/* - * This is the main interface to send packets via different protocols - * It still uses IPX-style address information. - * Should insure maximum compability to old versions/games and isn't worse than any other way to store addresses in an *universal method*. - * Mapping actual addresses has to be done by the protocol code. - */ - #include #include #include @@ -39,13 +33,13 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "text.h" #include "net_ipx.h" #include "console.h" -#include "netdrv.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 netdrv_installed=0; +ubyte ipxdrv_installed=0; u_int32_t ipx_network = 0; ubyte MyAddress[10]; int ipx_packetnum = 0; /* Sequence number */ @@ -65,7 +59,7 @@ user_address Ipx_users[MAX_USERS]; int Ipx_num_networks = 0; uint Ipx_networks[MAX_NETWORKS]; -int netdrv_general_packet_ready(int fd) +int ipxdrv_general_packet_ready(int fd) { fd_set set; struct timeval tv; @@ -81,19 +75,19 @@ int netdrv_general_packet_ready(int fd) struct net_driver *driver = NULL; -ubyte * netdrv_get_my_server_address() +ubyte * ipxdrv_get_my_server_address() { return (ubyte *)&ipx_network; } -ubyte * netdrv_get_my_local_address() +ubyte * ipxdrv_get_my_local_address() { return (ubyte *)(MyAddress + 4); } -void netdrv_close() +void ipxdrv_close() { - if (netdrv_installed) + if (ipxdrv_installed) { #ifdef _WIN32 WSACleanup(); @@ -101,7 +95,7 @@ void netdrv_close() driver->close_socket(&socket_data); } - netdrv_installed = 0; + ipxdrv_installed = 0; } //--------------------------------------------------------------- @@ -113,7 +107,7 @@ void netdrv_close() // -3 if driver not installed. // -4 if couldn't allocate low dos memory // -5 if error with getting internetwork address -int netdrv_init( int socket_number ) +int ipxdrv_init( int socket_number ) { static int cleanup = 0; #ifdef _WIN32 @@ -150,20 +144,20 @@ int netdrv_init( int socket_number ) Ipx_num_networks = 0; memcpy( &Ipx_networks[Ipx_num_networks++], &ipx_network, 4 ); - netdrv_installed = 1; + ipxdrv_installed = 1; if (!cleanup) - atexit(netdrv_close); + atexit(ipxdrv_close); cleanup = 1; return 0; } -int netdrv_set(int arg) +int ipxdrv_set(int arg) { - int netdrv_err; + int ipxdrv_err; - netdrv_close(); + ipxdrv_close(); con_printf(CON_VERBOSE, "\n%s ", TXT_INITIALIZING_NETWORK); @@ -171,30 +165,27 @@ int netdrv_set(int arg) { #ifndef __APPLE__ case NETPROTO_IPX: - driver = &netdrv_ipx; + driver = &ipxdrv_ipx; break; #endif #ifdef __LINUX__ case NETPROTO_KALINIX: - driver = &netdrv_kali; + driver = &ipxdrv_kali; break; #endif - case NETPROTO_UDP: - driver = &netdrv_udp; - break; default: driver = NULL; break; } - if ((netdrv_err=netdrv_init(IPX_DEFAULT_SOCKET))==0) + 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 (netdrv_err) + switch (ipxdrv_err) { case 3: con_printf(CON_VERBOSE, "%s\n", TXT_NO_NETWORK); @@ -206,7 +197,7 @@ int netdrv_set(int arg) con_printf(CON_VERBOSE, "%s\n", TXT_MEMORY_IPX ); break; default: - con_printf(CON_VERBOSE, "%s %d", TXT_ERROR_IPX, netdrv_err ); + con_printf(CON_VERBOSE, "%s %d", TXT_ERROR_IPX, ipxdrv_err ); break; } @@ -214,10 +205,10 @@ int netdrv_set(int arg) Network_active = 0; // Assume no network } - return netdrv_installed?0:-1; + return ipxdrv_installed?0:-1; } -int netdrv_get_packet_data( ubyte * data ) +int ipxdrv_get_packet_data( ubyte * data ) { struct recv_data rd; char *buf; @@ -253,11 +244,11 @@ int netdrv_get_packet_data( ubyte * data ) return 0; } -void netdrv_send_packet_data( ubyte * data, int datasize, ubyte *network, ubyte *address, ubyte *immediate_address ) +void ipxdrv_send_packet_data( ubyte * data, int datasize, ubyte *network, ubyte *address, ubyte *immediate_address ) { IPXPacket_t ipx_header; - if (!netdrv_installed) + if (!ipxdrv_installed) return; memcpy(ipx_header.Destination.Network, network, 4); @@ -276,17 +267,17 @@ void netdrv_send_packet_data( ubyte * data, int datasize, ubyte *network, ubyte driver->send_packet(&socket_data, &ipx_header, data, datasize);//we can save 4 bytes } -void netdrv_get_local_target( ubyte * server, ubyte * node, ubyte * local_target ) +void ipxdrv_get_local_target( ubyte * server, ubyte * node, ubyte * local_target ) { memcpy( local_target, node, 6 ); } -void netdrv_send_broadcast_packet_data( ubyte * data, int datasize ) +void ipxdrv_send_broadcast_packet_data( ubyte * data, int datasize ) { int i, j; ubyte local_address[6]; - if (!netdrv_installed) + if (!ipxdrv_installed) return; // Set to all networks besides mine @@ -294,12 +285,12 @@ void netdrv_send_broadcast_packet_data( ubyte * data, int datasize ) { if ( memcmp( &Ipx_networks[i], &ipx_network, 4 ) ) { - netdrv_get_local_target( (ubyte *)&Ipx_networks[i], broadcast_addr, local_address ); - netdrv_send_packet_data( data, datasize, (ubyte *)&Ipx_networks[i], broadcast_addr, local_address ); + ipxdrv_get_local_target( (ubyte *)&Ipx_networks[i], broadcast_addr, local_address ); + ipxdrv_send_packet_data( data, datasize, (ubyte *)&Ipx_networks[i], broadcast_addr, local_address ); } else { - netdrv_send_packet_data( data, datasize, (ubyte *)&Ipx_networks[i], broadcast_addr, broadcast_addr ); + ipxdrv_send_packet_data( data, datasize, (ubyte *)&Ipx_networks[i], broadcast_addr, broadcast_addr ); } } @@ -314,7 +305,7 @@ void netdrv_send_broadcast_packet_data( ubyte * data, int datasize ) goto SkipUser; } - netdrv_send_packet_data( data, datasize, Ipx_users[i].network, Ipx_users[i].node, Ipx_users[i].address ); + ipxdrv_send_packet_data( data, datasize, Ipx_users[i].network, Ipx_users[i].node, Ipx_users[i].address ); SkipUser: j = 0; } @@ -322,11 +313,11 @@ SkipUser: } // Sends a non-localized packet... needs 4 byte server, 6 byte address -void netdrv_send_internetwork_packet_data( ubyte * data, int datasize, ubyte * server, ubyte *address ) +void ipxdrv_send_internetwork_packet_data( ubyte * data, int datasize, ubyte * server, ubyte *address ) { ubyte local_address[6]; - if (!netdrv_installed) + if (!ipxdrv_installed) return; #ifdef WORDS_NEED_ALIGNMENT @@ -336,19 +327,19 @@ void netdrv_send_internetwork_packet_data( ubyte * data, int datasize, ubyte * s if ((*(uint *)server) != 0) #endif // WORDS_NEED_ALIGNMENT { - netdrv_get_local_target( server, address, local_address ); - netdrv_send_packet_data( data, datasize, server, address, local_address ); + ipxdrv_get_local_target( server, address, local_address ); + ipxdrv_send_packet_data( data, datasize, server, address, local_address ); } else { // Old method, no server info. - netdrv_send_packet_data( data, datasize, server, address, address ); + ipxdrv_send_packet_data( data, datasize, server, address, address ); } } -int netdrv_change_default_socket( ushort socket_number ) +int ipxdrv_change_default_socket( ushort socket_number ) { - if ( !netdrv_installed ) + if ( !ipxdrv_installed ) return -3; driver->close_socket(&socket_data); @@ -362,7 +353,7 @@ int netdrv_change_default_socket( ushort socket_number ) } // Return type of net_driver -int netdrv_type(void) +int ipxdrv_type(void) { return driver->type; } diff --git a/main/menu.c b/main/menu.c index 398bf35d9..466c41db3 100644 --- a/main/menu.c +++ b/main/menu.c @@ -67,7 +67,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "gauges.h" #include "hudmsg.h" //for HUD_max_num_disp #ifdef NETWORK -#include "netdrv.h" +#include "ipxdrv.h" #include "tracker/tracker.h" #endif @@ -328,19 +328,19 @@ void do_option ( int select) #ifdef NETWORK case MENU_START_IPX_NETGAME: - netdrv_set(NETPROTO_IPX); + ipxdrv_set(NETPROTO_IPX); network_start_game(); break; case MENU_JOIN_IPX_NETGAME: - netdrv_set(NETPROTO_IPX); + ipxdrv_set(NETPROTO_IPX); network_join_game(); break; case MENU_START_KALI_NETGAME: - netdrv_set(NETPROTO_KALINIX); + ipxdrv_set(NETPROTO_KALINIX); network_start_game(); break; case MENU_JOIN_KALI_NETGAME: - netdrv_set(NETPROTO_KALINIX); + ipxdrv_set(NETPROTO_KALINIX); network_join_game(); break; #if 0 // Later... @@ -348,7 +348,7 @@ void do_option ( int select) case MENU_BROWSE_UDP_NETGAME: { // Initialize UDP/IP network subsystem for this platform... - netdrv_set(NETPROTO_UDP); + // FIXME // Invoke the browse UDP/IP network game GUI... TrackerBrowseMenu(); // Done... @@ -356,12 +356,10 @@ void do_option ( int select) } #endif case MENU_START_UDP_NETGAME: - netdrv_set(NETPROTO_UDP); - network_start_game(); + // FIXME break; case MENU_JOIN_UDP_NETGAME: - netdrv_set(NETPROTO_UDP); - do_ip_manual_join_menu(); + // FIXME break; case MENU_MULTIPLAYER: do_multi_player_menu(); @@ -839,7 +837,6 @@ void do_multi_player_menu() } while( choice > -1 ); } -int UDPConnectManual(char *addr); void do_ip_manual_join_menu() { int menu_choice[3]; @@ -880,7 +877,7 @@ void do_ip_manual_join_menu() if ( choice > -1 ){ strncpy(GameCfg.MplIpHostAddr, buf, 128); - UDPConnectManual(buf); + // FIXME !! UDPConnectManual(buf); } if (old_game_mode != Game_mode) diff --git a/main/multi.c b/main/multi.c index 79fa514e3..c085c453a 100644 --- a/main/multi.c +++ b/main/multi.c @@ -54,14 +54,13 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "gameseq.h" #include "physics.h" #include "config.h" -#include "multipow.h" #include "hudmsg.h" #include "ctype.h" // for isalpha #include "vers_id.h" #include "byteswap.h" #include "pstypes.h" #include "strutil.h" - +#include "u_mem.h" // // Local macros and prototypes @@ -101,6 +100,7 @@ sbyte object_owner[MAX_OBJECTS]; // Who created each object in my universe, - int Net_create_objnums[MAX_NET_CREATE_OBJECTS]; // For tracking object creation that will be sent to remote int Net_create_loc = 0; // pointer into previous array +int Network_status = 0; int Network_laser_fired = 0; // How many times we shot int Network_laser_gun; // Which gun number we shot int Network_laser_flags; // Special flags for the shot @@ -116,6 +116,11 @@ int multi_in_menu = 0; int multi_leave_menu = 0; int multi_quit_game = 0; +// For rejoin object syncing + +int Network_rejoined = 0; // Did WE rejoin this game? +int Network_new_game = 0; // Is this the first level of a new game? + //added 02/26/99 Matt Mueller - reactor kill stats short reactor_kills[MAX_NUM_NET_PLAYERS]; int reactor_kills_total; @@ -124,6 +129,8 @@ int reactor_kills_total; uint multi_allow_powerup; uint multi_got_pow_count; +ushort my_segments_checksum = 0; + netgame_info Netgame; bitmap_index multi_player_textures[MAX_NUM_NET_PLAYERS][N_PLAYER_SHIP_TEXTURES]; @@ -237,6 +244,17 @@ void multi_reset_player_object(object *objp); void multi_set_robot_ai(void); void extract_netplayer_stats( netplayer_stats *ps, player * pd ); +int multi_allow_powerup_mask[MAX_POWERUP_TYPES] = +{ NETFLAG_DOINVUL, 0, 0, NETFLAG_DOLASER, 0, 0, 0, 0, 0, 0, 0, 0, NETFLAG_DOQUAD, + NETFLAG_DOVULCAN, NETFLAG_DOSPREAD, NETFLAG_DOPLASMA, NETFLAG_DOFUSION, + NETFLAG_DOPROXIM, NETFLAG_DOHOMING, NETFLAG_DOHOMING, NETFLAG_DOSMART, + NETFLAG_DOMEGA, NETFLAG_DOVULCAN, NETFLAG_DOCLOAK, 0, NETFLAG_DOINVUL, 0, 0, 0 }; + +char *multi_allow_powerup_text[MULTI_ALLOW_POWERUP_MAX] = +{ "Laser upgrade", "Quad lasers", "Vulcan cannon", "Spreadfire cannon", "Plasma cannon", + "Fusion cannon", "Homing missiles", "Smart missiles", "Mega missiles", "Proximity bombs", + "Cloaking", "Invulnerability" }; + // // Functions that replace what used to be macros // @@ -698,6 +716,11 @@ void multi_compute_kill(int killer, int killed) multi_show_player_list(); } +void multi_do_protocol_frame(int force, int listen) +{ + network_do_frame(force, listen); +} + void multi_do_frame(void) { if (!(Game_mode & GM_MULTI) || Newdemo_state == ND_STATE_PLAYBACK) @@ -718,7 +741,7 @@ void multi_do_frame(void) } #endif - network_do_frame(0, 1); + multi_do_protocol_frame(0, 1); if (multi_quit_game && !multi_in_menu) { @@ -1053,7 +1076,7 @@ void multi_send_message_end() for (i = 0; i < N_players; i++) if ((!strnicmp(Players[i].callsign, &Network_message[name_index], strlen(Network_message)-name_index)) && (i != Player_num) && (Players[i].connected)) { kick_player:; - network_dump_player(Netgame.players[i].server,Netgame.players[i].node, 7); + network_dump_player(Netgame.players[i].protocol.ipx.server,Netgame.players[i].protocol.ipx.node, 7); HUD_init_message("Dumping %s...",Players[i].callsign); multi_message_index = 0; @@ -2751,7 +2774,7 @@ multi_prep_level(void) // send player powerups (assumes sync already send) if ((Game_mode & GM_NETWORK) && - Netgame.protocol_version == MULTI_PROTO_D1X_VER && + Netgame.protocol.ipx.protocol_version == MULTI_PROTO_D1X_VER && !Network_rejoined) multi_send_player_powerup_count(); @@ -2815,7 +2838,7 @@ network_i_am_master(void) return 0; return 1; } -#include "u_mem.h" + void change_playernum_to( int new_Player_num ) { // if (Player_num > -1) diff --git a/main/multi.h b/main/multi.h index ee5b5e99c..96c03efe2 100644 --- a/main/multi.h +++ b/main/multi.h @@ -21,6 +21,36 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #ifndef _MULTI_H #define _MULTI_H +#ifdef NETWORK + +#ifdef _WIN32 + #include + #include +#else + #include + #include + #include + #include + #include + #include +#endif + +#ifdef IPv6 + #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 +#endif + +// Defines +#include "gameseq.h" +#include "piggy.h" +#include "vers_id.h" +#include "powerup.h" + #ifdef SHAREWARE #define MAX_MESSAGE_LEN 25 #else @@ -28,17 +58,6 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #define SHAREWARE_MAX_MESSAGE_LEN 25 #endif -#ifdef NETWORK - -// Defines -#include "gameseq.h" -#include "piggy.h" -#include "vers_id.h" - -//added 03/05/99 Matt Mueller -#include "compare.h" -//end addition -MM - // What version of the multiplayer protocol is this? #ifdef SHAREWARE @@ -117,6 +136,40 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #define MISSILE_ADJUST 6 +#define NETSTAT_MENU 0 +#define NETSTAT_PLAYING 1 +#define NETSTAT_BROWSING 2 +#define NETSTAT_WAITING 3 +#define NETSTAT_STARTING 4 +#define NETSTAT_ENDLEVEL 5 + +#define CONNECT_DISCONNECTED 0 +#define CONNECT_PLAYING 1 +#define CONNECT_WAITING 2 +#define CONNECT_DIED_IN_MINE 3 +#define CONNECT_FOUND_SECRET 4 +#define CONNECT_ESCAPE_TUNNEL 5 +#define CONNECT_END_MENU 6 + +// Bitmask for netgame_info->AllowedItems to set allowed items in Netgame +#define NETFLAG_DOLASER 1 // 0x0000001 +#define NETFLAG_DOQUAD 2 // 0x0000002 +#define NETFLAG_DOVULCAN 4 // 0x0000004 +#define NETFLAG_DOSPREAD 8 // 0x0000008 +#define NETFLAG_DOPLASMA 16 // 0x0000010 +#define NETFLAG_DOFUSION 32 // 0x0000020 +#define NETFLAG_DOHOMING 64 // 0x0000040 +#define NETFLAG_DOSMART 128 // 0x0000080 +#define NETFLAG_DOMEGA 256 // 0x0000100 +#define NETFLAG_DOPROXIM 512 // 0x0000200 +#define NETFLAG_DOCLOAK 1024 // 0x0000400 +#define NETFLAG_DOINVUL 2048 // 0x0000800 +#define NETFLAG_DOPOWERUP 4095 // 0x0000fff mask for all powerup flags + +#define MULTI_ALLOW_POWERUP_MAX 12 +int multi_allow_powerup_mask[MAX_POWERUP_TYPES]; +extern char *multi_allow_powerup_text[MULTI_ALLOW_POWERUP_MAX]; + // Exported functions int objnum_remote_to_local(int remote_obj, int owner); @@ -126,6 +179,7 @@ void map_objnum_local_to_local(int objnum); void multi_init_objects(void); void multi_show_player_list(void); +void multi_do_protocol_frame(int force, int listen); void multi_do_frame(void); void multi_send_fire(int pl); @@ -187,10 +241,13 @@ int get_team(int pnum); // Exported variables extern int Network_active; +extern int Network_status; extern int Network_laser_gun; extern int Network_laser_fired; extern int Network_laser_level; extern int Network_laser_flags; +extern int Network_rejoined; +extern int Network_new_game; extern int message_length[MULTI_MAX_TYPE+1]; @@ -207,6 +264,8 @@ extern short team_kills[2]; extern int multi_goto_secret; +extern ushort my_segments_checksum; + //do we draw the kill list on the HUD? extern int Show_kill_list; extern int Show_reticle_name; @@ -248,54 +307,6 @@ extern bitmap_index multi_player_textures[MAX_NUM_NET_PLAYERS][N_PLAYER_SHIP_TEX #define NETPLAYER_ORIG_SIZE 22 #define NETPLAYER_D1X_SIZE 22 /* D1X version removes last char from callsign */ -typedef struct netplayer_info { - char callsign[CALLSIGN_LEN+1]; - ubyte server[4]; - ubyte node[6]; - ushort socket; - sbyte connected; -#ifndef SHAREWARE - /* following D1X only */ - ubyte sub_protocol; -#endif -} __pack__ netplayer_info; - -typedef struct netgame_info { - ubyte type; - char game_name[NETGAME_NAME_LEN+1]; - char team_name[2][CALLSIGN_LEN+1]; - ubyte gamemode; - ubyte difficulty; - ubyte game_status; - ubyte numplayers; - ubyte max_numplayers; - ubyte game_flags; - netplayer_info players[MAX_PLAYERS]; - int locations[MAX_PLAYERS]; - short kills[MAX_PLAYERS][MAX_PLAYERS]; - int levelnum; - ubyte protocol_version; - ubyte team_vector; - ushort segments_checksum; - short team_kills[2]; - short killed[MAX_PLAYERS]; - short player_kills[MAX_PLAYERS]; - fix level_time; - int control_invul_time; - int monitor_vector; - int player_score[MAX_PLAYERS]; - ubyte player_flags[MAX_PLAYERS]; - char mission_name[9]; - char mission_title[MISSION_NAME_LEN+1]; -// from protocol v 3.0 - ubyte packets_per_sec; - uint flags; - ubyte subprotocol; // constant for given version - ubyte required_subprotocol; // depends on game mode etc. -} __pack__ netgame_info; - -extern struct netgame_info Netgame; - int network_i_am_master(void); void change_playernum_to(int new_pnum); @@ -303,6 +314,100 @@ extern uint multi_allow_powerup; extern int HUD_init_message(char * format, ...); +extern struct netgame_info Netgame; + +/* + * The Network Players structure + * Contains both IPX- and UDP-specific data with designated prefixes and general player-related data. + * Note that not all of these infos will be sent to other users - some are used and/or set locally, only. + * Even if some variables are not UDP-specific, they might be used in IPX as well to maintain backwards compability. + */ +typedef struct netplayer_info +{ + union + { + struct + { + ubyte server[4]; + ubyte node[6]; + ushort socket; + } 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 + } udp; + } protocol; + + char callsign[CALLSIGN_LEN+1]; + sbyte connected; + int ping; +} __pack__ netplayer_info; + +/* + * The Network Game structure + * Contains both IPX- and UDP-specific data with designated prefixes and general game-related data. + * Note that not all of these infos will be sent to clients - some are used and/or set locally, only. + * Even if some variables are not UDP-specific, they might be used in IPX as well to maintain backwards compability. + */ +typedef struct netgame_info { + + union + { + struct + { + ubyte Game_pkt_type; + ubyte protocol_version; + } ipx; + struct + { + struct _sockaddr addr; // IP address of this netgame's host + int program_iver; // IVER of program for version checking + } udp; + } protocol; + + struct netplayer_info players[MAX_PLAYERS+4]; + char game_name[NETGAME_NAME_LEN+1]; + char mission_title[MISSION_NAME_LEN+1]; + char mission_name[9]; + int levelnum; + ubyte gamemode; + ubyte RefusePlayers; // FIXME!!! + ubyte difficulty; + ubyte game_status; + ubyte numplayers; + ubyte max_numplayers; + ubyte numconnected; // FIXME!!! + ubyte game_flags; + ubyte team_vector; + u_int32_t AllowedItems; + short Allow_marker_view:1; // FIXME!!! + short AlwaysLighting:1; // FIXME!!! + short ShowAllNames:1; // FIXME!!! + short BrightPlayers:1; // FIXME!!! + short InvulAppear:1; // FIXME!!! + char team_name[2][CALLSIGN_LEN+1]; + int locations[MAX_PLAYERS]; + short kills[MAX_PLAYERS][MAX_PLAYERS]; + ushort segments_checksum; + short team_kills[2]; + short killed[MAX_PLAYERS]; + short player_kills[MAX_PLAYERS]; + int KillGoal; // FIXME!!! + fix PlayTimeAllowed; // FIXME!!! + fix level_time; + int control_invul_time; + int monitor_vector; + int player_score[MAX_PLAYERS]; + ubyte player_flags[MAX_PLAYERS]; + short PacketsPerSec; + ubyte PacketLossPrevention; +} __pack__ netgame_info; + #endif #endif diff --git a/main/multipow.c b/main/multipow.c deleted file mode 100644 index 5969e15c6..000000000 --- a/main/multipow.c +++ /dev/null @@ -1,20 +0,0 @@ -#include "powerup.h" -#include "multipow.h" -#include "text.h" - -int multi_allow_powerup_mask[MAX_POWERUP_TYPES] = -{ NETFLAG_DOINVUL, 0, 0, NETFLAG_DOLASER, 0, 0, 0, 0, 0, 0, 0, 0, NETFLAG_DOQUAD, - NETFLAG_DOVULCAN, NETFLAG_DOSPREAD, NETFLAG_DOPLASMA, NETFLAG_DOFUSION, - NETFLAG_DOPROXIM, NETFLAG_DOHOMING, NETFLAG_DOHOMING, NETFLAG_DOSMART, - NETFLAG_DOMEGA, NETFLAG_DOVULCAN, NETFLAG_DOCLOAK, 0, NETFLAG_DOINVUL, 0, 0, 0 }; - -#if 0 -char *multi_allow_powerup_text[MULTI_ALLOW_POWERUP_MAX] = -{ "Laser upgrade", TXT_QUAD_LASERS, TXT_W_VULCAN, TXT_W_SPREADFIRE, TXT_W_PLASMA, - TXT_W_FUSION, TXT_W_H_MISSILE, TXT_W_S_MISSILE, TXT_W_M_MISSILE, TXT_W_P_BOMB, - "Cloaking", TXT_INVULNERABILITY }; -#endif -char *multi_allow_powerup_text[MULTI_ALLOW_POWERUP_MAX] = -{ "Laser upgrade", "Quad lasers", "Vulcan cannon", "Spreadfire cannon", "Plasma cannon", - "Fusion cannon", "Homing missiles", "Smart missiles", "Mega missiles", "Proximity bombs", - "Cloaking", "Invulnerability" }; diff --git a/main/multipow.h b/main/multipow.h deleted file mode 100644 index 6270985db..000000000 --- a/main/multipow.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef _MULTIPOW_H -#define _MULTIPOW_H -#include "powerup.h" - -#define NETFLAG_DOLASER 1 // 0x0000001 -#define NETFLAG_DOQUAD 2 // 0x0000002 -#define NETFLAG_DOVULCAN 4 // 0x0000004 -#define NETFLAG_DOSPREAD 8 // 0x0000008 -#define NETFLAG_DOPLASMA 16 // 0x0000010 -#define NETFLAG_DOFUSION 32 // 0x0000020 -#define NETFLAG_DOHOMING 64 // 0x0000040 -#define NETFLAG_DOSMART 128 // 0x0000080 -#define NETFLAG_DOMEGA 256 // 0x0000100 -#define NETFLAG_DOPROXIM 512 // 0x0000200 -#define NETFLAG_DOCLOAK 1024 // 0x0000400 -#define NETFLAG_DOINVUL 2048 // 0x0000800 -#define NETFLAG_DOPOWERUP 4095 // 0x0000fff mask for all powerup flags - -#define NETFLAG_SHORTPACKETS 0x1000000 - -#define MULTI_ALLOW_POWERUP_MAX 12 -int multi_allow_powerup_mask[MAX_POWERUP_TYPES]; -extern char *multi_allow_powerup_text[MULTI_ALLOW_POWERUP_MAX]; -#endif diff --git a/main/net_ipx.c b/main/net_ipx.c index a546f841d..fbf939d7c 100644 --- a/main/net_ipx.c +++ b/main/net_ipx.c @@ -31,7 +31,6 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "gauges.h" #include "object.h" #include "error.h" -#include "netpkt.h" #include "laser.h" #include "gamesave.h" #include "gamemine.h" @@ -54,13 +53,12 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "bm.h" #include "effects.h" #include "physics.h" -#include "netpkt.h" -#include "multipow.h" +#include "ipxdrv.h" #include "vers_id.h" #include "gamefont.h" #include "playsave.h" #include "rbaudio.h" -#include "noloss.h" +#include "byteswap.h" void network_send_rejoin_sync(int player_num); void network_update_netgame(void); @@ -68,13 +66,12 @@ void network_send_endlevel_sub(int player_num); void network_send_endlevel_packet(void); void network_read_endlevel_packet( ubyte *data ); void network_read_object_packet( ubyte *data ); -void network_read_sync_packet( ubyte * sp, int d1x ); +void network_read_sync_packet( ubyte * sp ); void network_flush(); void network_listen(); void network_ping(ubyte flag, int pnum); void network_process_pdata(char *data); -void network_read_pdata_packet(ubyte *data); -void network_read_pdata_short_packet(short_frame_info *pd); +void network_read_pdata_packet(frame_info *pd); int network_compare_players(netplayer_info *pl1, netplayer_info *pl2); void DoRefuseStuff(sequence_packet *their); int show_game_stats(int choice); @@ -85,19 +82,14 @@ int num_active_games = 0; int Network_debug=0; int Network_active=0; -int Network_status = 0; int Network_games_changed = 0; -int Network_short_packets = 0; - //added on 8/5/98 by Victor Rachels to make global pps setting int Network_pps = 10; //end edit - Victor Rachels // For rejoin object syncing -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_send_objects = 0; // Are we in the process of sending objects to a player? int Network_send_objnum = -1; // What object are we sending next? int Network_player_added = 0; // Is this a new player or a returning player? @@ -110,7 +102,6 @@ int PacketUrgent = 0; frame_info MySyncPack; ubyte MySyncPackInitialized = 0; // Set to 1 if the MySyncPack is zeroed. -ushort my_segments_checksum = 0; int restrict_mode = 0; @@ -132,6 +123,153 @@ extern ubyte SurfingNet; int network_wait_for_snyc(); + +void send_sequence_packet(sequence_packet seq, ubyte *server, ubyte *node, ubyte *net_address) +{ + short tmps; + int loc; + ubyte out_buffer[MAX_DATA_SIZE]; + + loc = 0; + memset(out_buffer, 0, sizeof(out_buffer)); + out_buffer[0] = seq.type; loc++; + memcpy(&(out_buffer[loc]), seq.player.callsign, CALLSIGN_LEN+1); loc += CALLSIGN_LEN+1; + memcpy(&(out_buffer[loc]), seq.player.protocol.ipx.server, 4); loc += 4; + memcpy(&(out_buffer[loc]), seq.player.protocol.ipx.node, 6); loc += 6; + tmps = INTEL_SHORT(seq.player.protocol.ipx.socket); + memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2; + out_buffer[loc] = seq.player.connected; loc++; + out_buffer[loc] = MULTI_PROTO_D1X_MINOR; loc++; + + if (net_address != NULL) + ipxdrv_send_packet_data( out_buffer, loc, server, node, net_address); + else if ((server == NULL) && (node == NULL)) + ipxdrv_send_broadcast_packet_data( out_buffer, loc ); + else + ipxdrv_send_internetwork_packet_data( out_buffer, loc, server, node); +} + +void receive_sequence_packet(ubyte *data, sequence_packet *seq) +{ + int loc = 0; + + seq->type = data[0]; loc++; + memcpy(seq->player.callsign, &(data[loc]), CALLSIGN_LEN+1); loc += CALLSIGN_LEN+1; + memcpy(&(seq->player.protocol.ipx.server), &(data[loc]), 4); loc += 4; + memcpy(&(seq->player.protocol.ipx.node), &(data[loc]), 6); loc += 6; + memcpy(&(seq->player.protocol.ipx.socket), &(data[loc]), 2); loc += 2; + seq->player.connected = data[loc]; loc++; +} + +void send_netgame_packet(ubyte *server, ubyte *node) +{ + IPX_netgame_info netpkt; + int i, j; + + netpkt.type = Netgame.protocol.ipx.Game_pkt_type; + memcpy(&netpkt.game_name, &Netgame.game_name, sizeof(char)*(NETGAME_NAME_LEN+1)); + memcpy(&netpkt.team_name, &Netgame.team_name, 2*(CALLSIGN_LEN+1)); + netpkt.gamemode = Netgame.gamemode; + netpkt.difficulty = Netgame.difficulty; + netpkt.game_status = Netgame.game_status; + netpkt.numplayers = Netgame.numplayers; + netpkt.max_numplayers = Netgame.max_numplayers; + netpkt.game_flags = Netgame.game_flags; + for (i = 0; i < MAX_PLAYERS; i++) + { + memcpy(&netpkt.players[i].callsign, &Netgame.players[i].callsign, CALLSIGN_LEN); + memcpy(&netpkt.players[i].server, &Netgame.players[i].protocol.ipx.server, 4); + memcpy(&netpkt.players[i].node, &Netgame.players[i].protocol.ipx.node, 6); + netpkt.players[i].socket = Netgame.players[i].protocol.ipx.socket; + netpkt.players[i].connected = Netgame.players[i].connected; + } + for (i = 0; i < MAX_PLAYERS; i++) + netpkt.locations[i] = Netgame.locations[i]; + for (i = 0; i < MAX_PLAYERS; i++) + for (j = 0; j < MAX_PLAYERS; j++) + netpkt.kills[i][j] = Netgame.kills[i][j]; + netpkt.levelnum = Netgame.levelnum; + netpkt.protocol_version = Netgame.protocol.ipx.protocol_version; + netpkt.team_vector = Netgame.team_vector; + netpkt.segments_checksum = Netgame.segments_checksum; + netpkt.team_kills[0] = Netgame.team_kills[0]; + netpkt.team_kills[1] = Netgame.team_kills[1]; + for (i = 0; i < MAX_PLAYERS; i++) + { + netpkt.killed[i] = Netgame.killed[i]; + netpkt.player_kills[i] = Netgame.player_kills[i]; + } + netpkt.level_time = Netgame.level_time; + netpkt.control_invul_time = Netgame.control_invul_time; + netpkt.monitor_vector = Netgame.monitor_vector; + for (i = 0; i < MAX_PLAYERS; i++) + { + netpkt.player_score[i] = Netgame.player_score[i]; + netpkt.player_flags[i] = Netgame.player_flags[i]; + } + memcpy(&netpkt.mission_name, &Netgame.mission_name, sizeof(char)*9); + memcpy(&netpkt.mission_title, &Netgame.mission_title, sizeof(char)*(MISSION_NAME_LEN+1)); + + if (server == NULL && node == NULL) + ipxdrv_send_broadcast_packet_data((ubyte *)&netpkt, sizeof(IPX_netgame_info)); + else + ipxdrv_send_internetwork_packet_data((ubyte *)&netpkt, sizeof(IPX_netgame_info), server, node); +} + +void receive_netgame_packet(ubyte *data, netgame_info *netgame) +{ + IPX_netgame_info netpkt; + int i, j; + + memcpy(&netpkt, data, sizeof(IPX_netgame_info)); + + netgame->protocol.ipx.Game_pkt_type = netpkt.type; + memcpy(netgame->game_name, &netpkt.game_name, sizeof(char)*(NETGAME_NAME_LEN+1)); + memcpy(netgame->team_name, &netpkt.team_name, 2*(CALLSIGN_LEN+1)); + netgame->gamemode = netpkt.gamemode; + netgame->difficulty = netpkt.difficulty; + netgame->game_status = netpkt.game_status; + netgame->numplayers = netpkt.numplayers; + netgame->max_numplayers = netpkt.max_numplayers; + netgame->game_flags = netpkt.game_flags; + for (i = 0; i < MAX_PLAYERS; i++) + { + memcpy(netgame->players[i].callsign, &netpkt.players[i].callsign, CALLSIGN_LEN); + memcpy(netgame->players[i].protocol.ipx.server, &netpkt.players[i].server, 4); + memcpy(netgame->players[i].protocol.ipx.node, &netpkt.players[i].node, 6); + netgame->players[i].protocol.ipx.socket = netpkt.players[i].socket; + netgame->players[i].connected = netpkt.players[i].connected; + } + for (i = 0; i < MAX_PLAYERS; i++) + netgame->locations[i] = netpkt.locations[i]; + for (i = 0; i < MAX_PLAYERS; i++) + for (j = 0; j < MAX_PLAYERS; j++) + netgame->kills[i][j] = netpkt.kills[i][j]; + netgame->levelnum = netpkt.levelnum; + netgame->protocol.ipx.protocol_version = netpkt.protocol_version; + netgame->team_vector = netpkt.team_vector; + netgame->segments_checksum = netpkt.segments_checksum; + netgame->team_kills[0] = netpkt.team_kills[0]; + netgame->team_kills[1] = netpkt.team_kills[1]; + for (i = 0; i < MAX_PLAYERS; i++) + { + netgame->killed[i] = netpkt.killed[i]; + netgame->player_kills[i] = netpkt.player_kills[i]; + } + netgame->level_time = netpkt.level_time; + netgame->control_invul_time = netpkt.control_invul_time; + netgame->monitor_vector = netpkt.monitor_vector; + for (i = 0; i < MAX_PLAYERS; i++) + { + netgame->player_score[i] = netpkt.player_score[i]; + netgame->player_flags[i] = netpkt.player_flags[i]; + } + memcpy(netgame->mission_name, &netpkt.mission_name, sizeof(char)*9); + memcpy(netgame->mission_title, &netpkt.mission_title, sizeof(char)*(MISSION_NAME_LEN+1)); +} + + + void network_init(void) { @@ -144,11 +282,8 @@ network_init(void) memset(&My_Seq, 0, sizeof(sequence_packet)); My_Seq.type = PID_REQUEST; memcpy(My_Seq.player.callsign, Players[Player_num].callsign, CALLSIGN_LEN+1); - memcpy(My_Seq.player.node, netdrv_get_my_local_address(), 6); - memcpy(My_Seq.player.server, netdrv_get_my_server_address(), 4 ); - #ifndef SHAREWARE - My_Seq.player.sub_protocol = MULTI_PROTO_D1X_MINOR; - #endif + 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 ); for (Player_num = 0; Player_num < MAX_NUM_NET_PLAYERS; Player_num++) init_player_stats_game(); @@ -159,7 +294,7 @@ network_init(void) Fuelcen_control_center_destroyed = 0; network_flush(); - Netgame.packets_per_sec = 10; + Netgame.PacketsPerSec = 10; } // Change socket to new_socket, returns 1 if really changed @@ -172,7 +307,7 @@ int network_change_socket(int new_socket) if (new_socket != IPX_Socket) { IPX_Socket = new_socket; network_listen(); - netdrv_change_default_socket( IPX_DEFAULT_SOCKET + IPX_Socket ); + ipxdrv_change_default_socket( IPX_DEFAULT_SOCKET + IPX_Socket ); return 1; } return 0; @@ -405,8 +540,8 @@ can_join_netgame(netgame_info *game) for (i = 0; i < num_players; i++) if ( (!strcasecmp(Players[Player_num].callsign, game->players[i].callsign)) && - (!memcmp(My_Seq.player.node, game->players[i].node, 6)) && - (!memcmp(My_Seq.player.server, game->players[i].server, 4)) ) + (!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)) ) break; if (i != num_players) @@ -442,8 +577,6 @@ network_disconnect_player(int playernum) Players[playernum].connected = 0; Netgame.players[playernum].connected = 0; - noloss_update_pdata_got(playernum); - // create_player_appearance_effect(&Objects[Players[playernum].objnum]); multi_make_player_ghost(playernum); @@ -454,16 +587,6 @@ network_disconnect_player(int playernum) multi_strip_robots(playernum); #endif - if (playernum==0 && netdrv_type() == NETPROTO_UDP) // Host has left - Quit game! - { - Function_mode = FMODE_MENU; - nm_messagebox(NULL, 1, TXT_OK, "Game was closed by host!"); - Function_mode = FMODE_GAME; - multi_quit_game = 1; - multi_leave_menu = 1; - multi_reset_stuff(); - Function_mode = FMODE_MENU; - } } void @@ -495,14 +618,14 @@ network_new_player(sequence_packet *their) memcpy(Netgame.players[pnum].callsign, their->player.callsign, CALLSIGN_LEN+1); #ifndef SHAREWARE - if ( (*(uint *)their->player.server) != 0 ) - netdrv_get_local_target( their->player.server, their->player.node, Players[pnum].net_address ); + if ( (*(uint *)their->player.protocol.ipx.server) != 0 ) + ipxdrv_get_local_target( their->player.protocol.ipx.server, their->player.protocol.ipx.node, Players[pnum].net_address ); else #endif - memcpy(Players[pnum].net_address, their->player.node, 6); + memcpy(Players[pnum].net_address, their->player.protocol.ipx.node, 6); - memcpy(Netgame.players[pnum].node, their->player.node, 6); - memcpy(Netgame.players[pnum].server, their->player.server, 4); + memcpy(Netgame.players[pnum].protocol.ipx.node, their->player.protocol.ipx.node, 6); + memcpy(Netgame.players[pnum].protocol.ipx.server, their->player.protocol.ipx.server, 4); Players[pnum].n_packets_got = 0; Players[pnum].connected = 1; @@ -545,7 +668,7 @@ void network_welcome_player(sequence_packet *their) if ((Endlevel_sequence) || (Fuelcen_control_center_destroyed)) { - network_dump_player(their->player.server,their->player.node, DUMP_ENDLEVEL); + network_dump_player(their->player.protocol.ipx.server,their->player.protocol.ipx.node, DUMP_ENDLEVEL); return; } @@ -559,7 +682,7 @@ void network_welcome_player(sequence_packet *their) if (their->player.connected != Current_level_num) { - network_dump_player(their->player.server, their->player.node, DUMP_LEVEL); + network_dump_player(their->player.protocol.ipx.server, their->player.protocol.ipx.node, DUMP_LEVEL); return; } @@ -568,11 +691,11 @@ void network_welcome_player(sequence_packet *their) Network_player_added = 0; #ifndef SHAREWARE - if ( (*(uint *)their->player.server) != 0 ) - netdrv_get_local_target( their->player.server, their->player.node, local_address ); + if ( (*(uint *)their->player.protocol.ipx.server) != 0 ) + ipxdrv_get_local_target( their->player.protocol.ipx.server, their->player.protocol.ipx.node, local_address ); else #endif - memcpy(local_address, their->player.node, 6); + memcpy(local_address, their->player.protocol.ipx.node, 6); for (i = 0; i < N_players; i++) { @@ -598,7 +721,7 @@ void network_welcome_player(sequence_packet *their) { // Slots are open but game is closed - network_dump_player(their->player.server, their->player.node, DUMP_CLOSED); + network_dump_player(their->player.protocol.ipx.server, their->player.protocol.ipx.node, DUMP_CLOSED); return; } else @@ -622,7 +745,7 @@ void network_welcome_player(sequence_packet *their) { // Game is full. - network_dump_player(their->player.server, their->player.node, DUMP_FULL); + network_dump_player(their->player.protocol.ipx.server, their->player.protocol.ipx.node, DUMP_FULL); return; } //End addition by GF @@ -641,7 +764,7 @@ void network_welcome_player(sequence_packet *their) { // Everyone is still connected - network_dump_player(their->player.server, their->player.node, DUMP_FULL); + network_dump_player(their->player.protocol.ipx.server, their->player.protocol.ipx.node, DUMP_FULL); return; } else @@ -812,8 +935,8 @@ int network_create_monitor_vector(void) void network_stop_resync(sequence_packet *their) { - if ( (!memcmp(Network_player_rejoining.player.node, their->player.node, 6)) && - (!memcmp(Network_player_rejoining.player.server, their->player.server, 4)) && + 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)) && (!strcasecmp(Network_player_rejoining.player.callsign, their->player.callsign)) ) { Network_send_objects = 0; @@ -821,6 +944,153 @@ void network_stop_resync(sequence_packet *their) } } +void swap_object(object *obj) +{ +// swap the short and int entries for this object + obj->signature = INTEL_INT(obj->signature); + obj->next = INTEL_SHORT(obj->next); + obj->prev = INTEL_SHORT(obj->prev); + obj->segnum = INTEL_SHORT(obj->segnum); + obj->attached_obj = INTEL_SHORT(obj->attached_obj); + obj->pos.x = INTEL_INT(obj->pos.x); + obj->pos.y = INTEL_INT(obj->pos.y); + obj->pos.z = INTEL_INT(obj->pos.z); + + obj->orient.rvec.x = INTEL_INT(obj->orient.rvec.x); + obj->orient.rvec.y = INTEL_INT(obj->orient.rvec.y); + obj->orient.rvec.z = INTEL_INT(obj->orient.rvec.z); + obj->orient.fvec.x = INTEL_INT(obj->orient.fvec.x); + obj->orient.fvec.y = INTEL_INT(obj->orient.fvec.y); + obj->orient.fvec.z = INTEL_INT(obj->orient.fvec.z); + obj->orient.uvec.x = INTEL_INT(obj->orient.uvec.x); + obj->orient.uvec.y = INTEL_INT(obj->orient.uvec.y); + obj->orient.uvec.z = INTEL_INT(obj->orient.uvec.z); + + obj->size = INTEL_INT(obj->size); + obj->shields = INTEL_INT(obj->shields); + + obj->last_pos.x = INTEL_INT(obj->last_pos.x); + obj->last_pos.y = INTEL_INT(obj->last_pos.y); + obj->last_pos.z = INTEL_INT(obj->last_pos.z); + + obj->lifeleft = INTEL_INT(obj->lifeleft); + + switch (obj->movement_type) { + + case MT_PHYSICS: + + obj->mtype.phys_info.velocity.x = INTEL_INT(obj->mtype.phys_info.velocity.x); + obj->mtype.phys_info.velocity.y = INTEL_INT(obj->mtype.phys_info.velocity.y); + obj->mtype.phys_info.velocity.z = INTEL_INT(obj->mtype.phys_info.velocity.z); + + obj->mtype.phys_info.thrust.x = INTEL_INT(obj->mtype.phys_info.thrust.x); + obj->mtype.phys_info.thrust.y = INTEL_INT(obj->mtype.phys_info.thrust.y); + obj->mtype.phys_info.thrust.z = INTEL_INT(obj->mtype.phys_info.thrust.z); + + obj->mtype.phys_info.mass = INTEL_INT(obj->mtype.phys_info.mass); + obj->mtype.phys_info.drag = INTEL_INT(obj->mtype.phys_info.drag); + obj->mtype.phys_info.brakes = INTEL_INT(obj->mtype.phys_info.brakes); + + obj->mtype.phys_info.rotvel.x = INTEL_INT(obj->mtype.phys_info.rotvel.x); + obj->mtype.phys_info.rotvel.y = INTEL_INT(obj->mtype.phys_info.rotvel.y); + obj->mtype.phys_info.rotvel.z = INTEL_INT(obj->mtype.phys_info.rotvel.z); + + obj->mtype.phys_info.rotthrust.x = INTEL_INT(obj->mtype.phys_info.rotthrust.x); + obj->mtype.phys_info.rotthrust.y = INTEL_INT(obj->mtype.phys_info.rotthrust.y); + obj->mtype.phys_info.rotthrust.z = INTEL_INT(obj->mtype.phys_info.rotthrust.z); + + obj->mtype.phys_info.turnroll = INTEL_INT(obj->mtype.phys_info.turnroll); + obj->mtype.phys_info.flags = INTEL_SHORT(obj->mtype.phys_info.flags); + + break; + + case MT_SPINNING: + + obj->mtype.spin_rate.x = INTEL_INT(obj->mtype.spin_rate.x); + obj->mtype.spin_rate.y = INTEL_INT(obj->mtype.spin_rate.y); + obj->mtype.spin_rate.z = INTEL_INT(obj->mtype.spin_rate.z); + break; + } + + switch (obj->control_type) { + + case CT_WEAPON: + obj->ctype.laser_info.parent_type = INTEL_SHORT(obj->ctype.laser_info.parent_type); + obj->ctype.laser_info.parent_num = INTEL_SHORT(obj->ctype.laser_info.parent_num); + obj->ctype.laser_info.parent_signature = INTEL_SHORT(obj->ctype.laser_info.parent_signature); + obj->ctype.laser_info.creation_time = INTEL_INT(obj->ctype.laser_info.creation_time); + obj->ctype.laser_info.last_hitobj = INTEL_INT(obj->ctype.laser_info.last_hitobj); + obj->ctype.laser_info.multiplier = INTEL_INT(obj->ctype.laser_info.multiplier); + break; + + case CT_EXPLOSION: + obj->ctype.expl_info.spawn_time = INTEL_INT(obj->ctype.expl_info.spawn_time); + obj->ctype.expl_info.delete_time = INTEL_INT(obj->ctype.expl_info.delete_time); + obj->ctype.expl_info.delete_objnum = INTEL_SHORT(obj->ctype.expl_info.delete_objnum); + obj->ctype.expl_info.attach_parent = INTEL_SHORT(obj->ctype.expl_info.attach_parent); + obj->ctype.expl_info.prev_attach = INTEL_SHORT(obj->ctype.expl_info.prev_attach); + obj->ctype.expl_info.next_attach = INTEL_SHORT(obj->ctype.expl_info.next_attach); + break; + + case CT_AI: + obj->ctype.ai_info.hide_segment = INTEL_SHORT(obj->ctype.ai_info.hide_segment); + obj->ctype.ai_info.hide_index = INTEL_SHORT(obj->ctype.ai_info.hide_index); + obj->ctype.ai_info.path_length = INTEL_SHORT(obj->ctype.ai_info.path_length); + obj->ctype.ai_info.cur_path_index = INTEL_SHORT(obj->ctype.ai_info.cur_path_index); + obj->ctype.ai_info.follow_path_start_seg = INTEL_SHORT(obj->ctype.ai_info.follow_path_start_seg); + obj->ctype.ai_info.follow_path_end_seg = INTEL_SHORT(obj->ctype.ai_info.follow_path_end_seg); + obj->ctype.ai_info.danger_laser_signature = INTEL_INT(obj->ctype.ai_info.danger_laser_signature); + obj->ctype.ai_info.danger_laser_num = INTEL_SHORT(obj->ctype.ai_info.danger_laser_num); + break; + + case CT_LIGHT: + obj->ctype.light_info.intensity = INTEL_INT(obj->ctype.light_info.intensity); + break; + + case CT_POWERUP: + obj->ctype.powerup_info.count = INTEL_INT(obj->ctype.powerup_info.count); + if (obj->id == POW_VULCAN_WEAPON) + obj->ctype.powerup_info.count = VULCAN_WEAPON_AMMO_AMOUNT; + break; + + } + + switch (obj->render_type) { + + case RT_MORPH: + case RT_POLYOBJ: { + int i; + + obj->rtype.pobj_info.model_num = INTEL_INT(obj->rtype.pobj_info.model_num); + + for (i=0;irtype.pobj_info.anim_angles[i].p = INTEL_INT(obj->rtype.pobj_info.anim_angles[i].p); + obj->rtype.pobj_info.anim_angles[i].b = INTEL_INT(obj->rtype.pobj_info.anim_angles[i].b); + obj->rtype.pobj_info.anim_angles[i].h = INTEL_INT(obj->rtype.pobj_info.anim_angles[i].h); + } + + obj->rtype.pobj_info.subobj_flags = INTEL_INT(obj->rtype.pobj_info.subobj_flags); + obj->rtype.pobj_info.tmap_override = INTEL_INT(obj->rtype.pobj_info.tmap_override); + obj->rtype.pobj_info.alt_textures = INTEL_INT(obj->rtype.pobj_info.alt_textures); + break; + } + + case RT_WEAPON_VCLIP: + case RT_HOSTAGE: + case RT_POWERUP: + case RT_FIREBALL: + obj->rtype.vclip_info.vclip_num = INTEL_INT(obj->rtype.vclip_info.vclip_num); + obj->rtype.vclip_info.frametime = INTEL_INT(obj->rtype.vclip_info.frametime); + break; + + case RT_LASER: + break; + + } +// END OF SWAPPING OBJECT STRUCTURE + +} + ubyte object_buffer[MAX_DATA_SIZE]; void network_send_objects(void) @@ -846,7 +1116,7 @@ void network_send_objects(void) // Endlevel started before we finished sending the goods, we'll // have to stop and try again after the level. - network_dump_player(Network_player_rejoining.player.server,Network_player_rejoining.player.node, DUMP_ENDLEVEL); + network_dump_player(Network_player_rejoining.player.protocol.ipx.server,Network_player_rejoining.player.protocol.ipx.node, DUMP_ENDLEVEL); Network_send_objects = 0; return; } @@ -908,8 +1178,8 @@ void network_send_objects(void) Assert(loc <= MAX_DATA_SIZE); - netdrv_send_internetwork_packet_data( object_buffer, loc, Network_player_rejoining.player.server, Network_player_rejoining.player.node ); - // OLD netdrv_send_packet_data(object_buffer, loc, &Network_player_rejoining.player.node); + ipxdrv_send_internetwork_packet_data( object_buffer, loc, Network_player_rejoining.player.protocol.ipx.server, Network_player_rejoining.player.protocol.ipx.node ); + // OLD ipxdrv_send_packet_data(object_buffer, loc, &Network_player_rejoining.player.protocol.ipx.node); } if (i > Highest_object_index) @@ -930,8 +1200,8 @@ void network_send_objects(void) object_buffer[2] = frame_num; *(short *)(object_buffer+3) = INTEL_SHORT(-2); *(short *)(object_buffer+6) = INTEL_SHORT(obj_count); - //OLD netdrv_send_packet_data(object_buffer, 8, &Network_player_rejoining.player.node); - netdrv_send_internetwork_packet_data(object_buffer, 8, Network_player_rejoining.player.server, Network_player_rejoining.player.node); + //OLD ipxdrv_send_packet_data(object_buffer, 8, &Network_player_rejoining.player.protocol.ipx.node); + ipxdrv_send_internetwork_packet_data(object_buffer, 8, Network_player_rejoining.player.protocol.ipx.server, Network_player_rejoining.player.protocol.ipx.node); // Send sync packet which tells the player who he is and to start! network_send_rejoin_sync(player_num); @@ -958,7 +1228,7 @@ void network_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. - network_dump_player(Network_player_rejoining.player.server,Network_player_rejoining.player.node, DUMP_ENDLEVEL); + network_dump_player(Network_player_rejoining.player.protocol.ipx.server,Network_player_rejoining.player.protocol.ipx.node, DUMP_ENDLEVEL); Network_send_objects = 0; return; } @@ -973,7 +1243,7 @@ void network_send_rejoin_sync(int player_num) { if ((i != player_num) && (i != Player_num) && (Players[i].connected)) { - send_sequence_packet( Network_player_rejoining, Netgame.players[i].server, Netgame.players[i].node, Players[i].net_address); + send_sequence_packet( Network_player_rejoining, Netgame.players[i].protocol.ipx.server, Netgame.players[i].protocol.ipx.node, Players[i].net_address); } } } @@ -999,15 +1269,13 @@ void network_send_rejoin_sync(int player_num) Netgame.monitor_vector = network_create_monitor_vector(); #endif - send_netgame_packet(Network_player_rejoining.player.server, Network_player_rejoining.player.node ); - send_netgame_packet(Network_player_rejoining.player.server, Network_player_rejoining.player.node ); - send_netgame_packet(Network_player_rejoining.player.server, Network_player_rejoining.player.node ); + send_netgame_packet(Network_player_rejoining.player.protocol.ipx.server, Network_player_rejoining.player.protocol.ipx.node ); + send_netgame_packet(Network_player_rejoining.player.protocol.ipx.server, Network_player_rejoining.player.protocol.ipx.node ); + send_netgame_packet(Network_player_rejoining.player.protocol.ipx.server, Network_player_rejoining.player.protocol.ipx.node ); #ifndef SHAREWARE network_send_door_updates(); #endif - if (Netgame.protocol_version == MULTI_PROTO_D1X_VER) - multi_send_start_powerup_count(); return; } @@ -1028,7 +1296,7 @@ void network_add_player(sequence_packet *p) int i; for (i=0; iplayer.node, 6) && !memcmp(Netgame.players[i].server, p->player.server, 4)){ + if ( !memcmp( Netgame.players[i].protocol.ipx.node, p->player.protocol.ipx.node, 6) && !memcmp(Netgame.players[i].protocol.ipx.server, p->player.protocol.ipx.server, 4)){ return; // already got them } } @@ -1038,12 +1306,9 @@ void network_add_player(sequence_packet *p) } memcpy( Netgame.players[N_players].callsign, p->player.callsign, CALLSIGN_LEN+1 ); - memcpy( Netgame.players[N_players].node, p->player.node, 6 ); - memcpy( Netgame.players[N_players].server, p->player.server, 4 ); + memcpy( Netgame.players[N_players].protocol.ipx.node, p->player.protocol.ipx.node, 6 ); + memcpy( Netgame.players[N_players].protocol.ipx.server, p->player.protocol.ipx.server, 4 ); Netgame.players[N_players].connected = 1; - #ifndef SHAREWARE - Netgame.players[N_players].sub_protocol = p->player.sub_protocol; - #endif Players[N_players].connected = 1; LastPacketTime[N_players] = timer_get_approx_seconds(); N_players++; @@ -1051,7 +1316,7 @@ void network_add_player(sequence_packet *p) // Broadcast updated info - network_send_game_info(NULL, 0); + network_send_game_info(NULL); } // One of the players decided not to join the game @@ -1062,7 +1327,7 @@ void network_remove_player(sequence_packet *p) pn = -1; for (i=0; iplayer.node, 6) && !memcmp(Netgame.players[i].server, p->player.server, 4)) { + if (!memcmp(Netgame.players[i].protocol.ipx.node, p->player.protocol.ipx.node, 6) && !memcmp(Netgame.players[i].protocol.ipx.server, p->player.protocol.ipx.server, 4)) { pn = i; break; } @@ -1072,8 +1337,8 @@ void network_remove_player(sequence_packet *p) for (i=pn; iplayer.server, their->player.node); + send_netgame_packet(their->player.protocol.ipx.server, their->player.protocol.ipx.node); - Netgame.type = old_type; + Netgame.protocol.ipx.Game_pkt_type = old_type; Netgame.game_status = old_status; } @@ -1236,32 +1499,29 @@ int network_send_request(void) Assert(i < MAX_NUM_NET_PLAYERS); - My_Seq.type = (Netgame.protocol_version == MULTI_PROTO_D1X_VER) - ? PID_D1X_REQUEST : PID_REQUEST; + My_Seq.type = PID_REQUEST; My_Seq.player.connected = Current_level_num; - send_sequence_packet(My_Seq, Netgame.players[i].server, Netgame.players[i].node, NULL); + send_sequence_packet(My_Seq, Netgame.players[i].protocol.ipx.server, Netgame.players[i].protocol.ipx.node, NULL); return i; } -void network_process_gameinfo(ubyte *data, int d1x) +void network_process_gameinfo(ubyte *data) { int i, j; netgame_info *new; netgame_info netgame; new = &netgame; - receive_netgame_packet(data, &netgame, d1x); + receive_netgame_packet(data, &netgame); Network_games_changed = 1; for (i = 0; i < num_active_games; i++) if (!strcasecmp(Active_games[i].game_name, new->game_name) && - (Active_games[i].type == PID_D1X_GAME_LITE || - new->type == PID_D1X_GAME_LITE || - (!memcmp(Active_games[i].players[0].node, new->players[0].node, 6) && - !memcmp(Active_games[i].players[0].server, new->players[0].server, 4)))) + (!memcmp(Active_games[i].players[0].protocol.ipx.node, new->players[0].protocol.ipx.node, 6) && + !memcmp(Active_games[i].players[0].protocol.ipx.server, new->players[0].protocol.ipx.server, 4))) break; if (i == MAX_ACTIVE_NETGAMES) @@ -1317,7 +1577,7 @@ void network_process_request(sequence_packet *their) int i; for (i = 0; i < N_players; i++) - if (!memcmp(their->player.server, Netgame.players[i].server, 4) && !memcmp(their->player.node, Netgame.players[i].node, 6) && (!strcasecmp(their->player.callsign, Netgame.players[i].callsign))) { + 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) && (!strcasecmp(their->player.callsign, Netgame.players[i].callsign))) { Players[i].connected = 1; break; } @@ -1326,32 +1586,28 @@ void network_process_request(sequence_packet *their) void network_process_packet(ubyte *data, int length ) { sequence_packet *their = (sequence_packet *)data; - -#ifdef WORDS_BIGENDIAN sequence_packet tmp_packet; memset(&tmp_packet, 0, sizeof(sequence_packet)); receive_sequence_packet(data, &tmp_packet); their = &tmp_packet; // reassign their to point to correctly alinged structure -#endif switch( their->type ) { case PID_GAME_INFO: if (Network_status == NETSTAT_BROWSING) - network_process_gameinfo(data, 0); + network_process_gameinfo(data); break; case PID_GAME_LIST: // Someone wants a list of games if ((Network_status == NETSTAT_PLAYING) || (Network_status == NETSTAT_STARTING) || (Network_status == NETSTAT_ENDLEVEL)) if (network_i_am_master()) - network_send_game_info(their, 1); + network_send_game_info(their); break; case PID_ADDPLAYER: network_new_player(their); break; - case PID_D1X_REQUEST: case PID_REQUEST: if (Network_status == NETSTAT_STARTING) { @@ -1385,18 +1641,13 @@ void network_process_packet(ubyte *data, int length ) break; case PID_SYNC: if (Network_status == NETSTAT_WAITING) - network_read_sync_packet(data, 0); + network_read_sync_packet(data); break; case PID_PDATA: - case PID_PDATA_NOLOSS: if ((Game_mode&GM_NETWORK) && ((Network_status == NETSTAT_PLAYING)||(Network_status == NETSTAT_ENDLEVEL) || Network_status==NETSTAT_WAITING)) { network_process_pdata((char *)data); } break; - case PID_PDATA_ACK: - if (Network_status == NETSTAT_PLAYING) - noloss_got_ack(data); - break; case PID_OBJECT_DATA: if (Network_status == NETSTAT_WAITING) network_read_object_packet(data); @@ -1405,37 +1656,6 @@ void network_process_packet(ubyte *data, int length ) if ((Network_status == NETSTAT_ENDLEVEL) || (Network_status == NETSTAT_PLAYING)) network_read_endlevel_packet(data); break; - // D1X packets - case PID_D1X_GAME_INFO_REQ: - // Someone wants full info of our D1X game - if ((Netgame.protocol_version == MULTI_PROTO_D1X_VER) && - ((Network_status == NETSTAT_PLAYING) || (Network_status == NETSTAT_STARTING) || (Network_status == NETSTAT_ENDLEVEL))) - if (network_i_am_master()) - network_send_game_info(their, 0); - break; - case PID_D1X_GAME_LITE_REQ: - // Someone wants a list of D1X games - if ((Netgame.protocol_version == MULTI_PROTO_D1X_VER) && - ((Network_status == NETSTAT_PLAYING) || (Network_status == NETSTAT_STARTING) || (Network_status == NETSTAT_ENDLEVEL))) - if (network_i_am_master()) - network_send_game_info(their, 1); - break; - case PID_D1X_GAME_INFO: - case PID_D1X_GAME_LITE: - if (Network_status == NETSTAT_BROWSING) - network_process_gameinfo(data, 1); - break; - case PID_D1X_SYNC: - if (Network_status == NETSTAT_WAITING) - network_read_sync_packet(data, 1); - break; -//added 03/04/99 Matt Mueller - new direct data packets.. - case PID_DIRECTDATA: - if ((Game_mode&GM_NETWORK) && ((Network_status == NETSTAT_PLAYING)||(Network_status == NETSTAT_ENDLEVEL) )) { - multi_process_bigdata( (char *)data+1, length-1); - } - break; -//end addition -MM case PID_PING_SEND: network_ping (PID_PING_RETURN,data[1]); break; @@ -1754,25 +1974,8 @@ void network_start_poll( int nitems, newmenu_item * menus, int * key, int citem } } -void network_set_power (void) -{ - newmenu_item m[MULTI_ALLOW_POWERUP_MAX]; - int i; - - for (i = 0; i < MULTI_ALLOW_POWERUP_MAX; i++) { - m[i].type = NM_TYPE_CHECK; m[i].text = multi_allow_powerup_text[i]; m[i].value = (Netgame.flags >> i) & 1; - } - i = newmenu_do1( NULL, "Objects to allow", MULTI_ALLOW_POWERUP_MAX, m, NULL, 0 ); - if (i > -1) { - Netgame.flags &= ~NETFLAG_DOPOWERUP; - for (i = 0; i < MULTI_ALLOW_POWERUP_MAX; i++) - if (m[i].value) - Netgame.flags |= (1 << i); - } -} - static int opt_cinvul, opt_team_anarchy, opt_coop, opt_show_on_map, opt_closed, opt_refuse, opt_maxnet; -static int opt_setpower,opt_show_on_map, opt_difficulty,opt_packets,opt_short_packets, opt_socket; +static int opt_show_on_map, opt_difficulty, opt_socket; static int last_maxnet, last_cinvul=0; void network_more_options_poll( int nitems, newmenu_item * menus, int * key, int citem ); @@ -1780,12 +1983,10 @@ void network_more_options_poll( int nitems, newmenu_item * menus, int * key, int void network_more_game_options () { int opt=0,i; - int opt_protover=-1; - char srinvul[50],packstring[5],socket_string[5]; + char srinvul[50],socket_string[5]; newmenu_item m[21]; sprintf (socket_string,"%d",IPX_Socket); - sprintf (packstring,"%d",Netgame.packets_per_sec); opt_difficulty = opt; m[opt].type = NM_TYPE_SLIDER; m[opt].value=Netgame.difficulty; m[opt].text=TXT_DIFFICULTY; m[opt].min_value=0; m[opt].max_value=(NDL-1); opt++; @@ -1797,74 +1998,20 @@ void network_more_game_options () opt_show_on_map=opt; m[opt].type = NM_TYPE_CHECK; m[opt].text = TXT_SHOW_ON_MAP; m[opt].value=(Netgame.game_flags & NETGAME_FLAG_SHOW_MAP); opt_show_on_map=opt; opt++; - m[opt].type = NM_TYPE_TEXT; m[opt].text = "Packets per second (2 - 20)"; opt++; - opt_packets=opt; - m[opt].type = NM_TYPE_INPUT; m[opt].text=packstring; m[opt].text_len=2; opt++; + m[opt].type = NM_TYPE_TEXT; m[opt].text = "Network socket"; opt++; + opt_socket = opt; + m[opt].type = NM_TYPE_INPUT; m[opt].text = socket_string; m[opt].text_len=4; opt++; - if (netdrv_type() != NETPROTO_UDP) - { - opt_protover=opt; - m[opt].type = NM_TYPE_CHECK; m[opt].text = "VERSION CHECK"; m[opt].value=(Netgame.protocol_version == MULTI_PROTO_D1X_VER); opt++; - m[opt].type = NM_TYPE_TEXT; m[opt].text = "Options below need version check"; opt++; - m[opt].type = NM_TYPE_TEXT; m[opt].text = "Network socket"; opt++; - opt_socket = opt; - m[opt].type = NM_TYPE_INPUT; m[opt].text = socket_string; m[opt].text_len=4; opt++; - } - opt_short_packets=opt; - m[opt].type = NM_TYPE_CHECK; m[opt].text = "Short packets"; m[opt].value=(Netgame.flags & NETFLAG_SHORTPACKETS); opt++; - opt_setpower = opt; - m[opt].type = NM_TYPE_MENU; m[opt].text = "Set objects allowed..."; opt++; - -menu: i = newmenu_do1( NULL, "Advanced netgame options", opt, m, network_more_options_poll, 0 ); Netgame.control_invul_time = m[opt_cinvul].value*5*F1_0*60; - if (i==opt_setpower) + if ((atoi(socket_string))!=IPX_Socket) { - network_set_power (); - goto menu; - } - - Netgame.packets_per_sec=atoi(packstring); - - if (Netgame.packets_per_sec>20) - { - Netgame.packets_per_sec=20; - nm_messagebox(TXT_ERROR, 1, TXT_OK, "Packet value out of range\nSetting value to 20"); - } - - if (Netgame.packets_per_sec<2) - { - nm_messagebox(TXT_ERROR, 1, TXT_OK, "Packet value out of range\nSetting value to 2"); - Netgame.packets_per_sec=2; - } - - if (netdrv_type() != NETPROTO_UDP) - { - if (m[opt_protover].value) - Netgame.protocol_version = MULTI_PROTO_D1X_VER; - else - Netgame.protocol_version = MULTI_PROTO_VERSION; - - if ((atoi(socket_string))!=IPX_Socket) - { - IPX_Socket=atoi(socket_string); - netdrv_change_default_socket( IPX_DEFAULT_SOCKET + IPX_Socket ); - } + IPX_Socket=atoi(socket_string); + ipxdrv_change_default_socket( IPX_DEFAULT_SOCKET + IPX_Socket ); } - if (m[opt_short_packets].value && Netgame.protocol_version == MULTI_PROTO_D1X_VER) - { - Network_short_packets = 1; - Netgame.flags |= NETFLAG_SHORTPACKETS; - } - else - { - Network_short_packets = 0; - Netgame.flags &= ~NETFLAG_SHORTPACKETS; - } - Netgame.difficulty=Difficulty_level = m[opt_difficulty].value; if (m[opt_show_on_map].value) Netgame.game_flags |= NETGAME_FLAG_SHOW_MAP; @@ -1949,25 +2096,8 @@ int network_get_game_params() sprintf( Netgame.game_name, "%s%s", Players[Player_num].callsign, TXT_S_GAME ); Netgame.difficulty=PlayerCfg.DefaultDifficulty; Netgame.max_numplayers=MaxNumNetPlayers; - Netgame.protocol_version = MULTI_PROTO_VERSION; - Netgame.flags = NETFLAG_DOPOWERUP; // enable all powerups - Netgame.protocol_version = MULTI_PROTO_D1X_VER; - - if (GameArg.MplGameProfile) - { - if (!nm_messagebox(NULL, 2, TXT_YES,TXT_NO, "do you want to load\na multiplayer profile?")) - { - char mprofile_file[13]=""; - if (newmenu_get_filename("Select profile\n to abort", ".mpx", mprofile_file, 1)) - { - PHYSFS_file *outfile; - - outfile = PHYSFSX_openReadBuffered(mprofile_file); - PHYSFS_read(outfile,&Netgame,sizeof(netgame_info),1); - PHYSFS_close(outfile); - } - } - } + Netgame.AllowedItems = NETFLAG_DOPOWERUP; // enable all powerups + Netgame.protocol.ipx.protocol_version = MULTI_PROTO_VERSION; #ifndef SHAREWARE if (!select_mission(1, TXT_MULTI_MISSION)) @@ -2137,7 +2267,7 @@ network_find_game(void) return 1; } -void network_read_sync_packet( ubyte * data, int d1x ) +void network_read_sync_packet( ubyte * data ) { int i, j; netgame_info *sp = &Netgame; @@ -2148,7 +2278,7 @@ void network_read_sync_packet( ubyte * data, int d1x ) if (data) { - receive_netgame_packet( data, &Netgame, d1x ); + receive_netgame_packet( data, &Netgame ); } N_players = sp->numplayers; @@ -2183,7 +2313,7 @@ void network_read_sync_packet( ubyte * data, int d1x ) for (i=0; iplayers[i].node, My_Seq.player.node, 6 )) && + if ((!memcmp( sp->players[i].protocol.ipx.node, My_Seq.player.protocol.ipx.node, 6 )) && (!strcasecmp( sp->players[i].callsign, temp_callsign)) ) { Assert(Player_num == -1); // Make sure we don't find ourselves twice! Looking for interplay reported bug @@ -2194,16 +2324,16 @@ void network_read_sync_packet( ubyte * data, int d1x ) #ifndef SHAREWARE #ifdef WORDS_NEED_ALIGNMENT uint server; - memcpy(&server, TempPlayersInfo->players[i].server, 4); + memcpy(&server, TempPlayersInfo->players[i].protocol.ipx.server, 4); if (server != 0) - netdrv_get_local_target((ubyte *)&server, sp->players[i].node, Players[i].net_address); + ipxdrv_get_local_target((ubyte *)&server, sp->players[i].protocol.ipx.node, Players[i].net_address); #else // WORDS_NEED_ALIGNMENT - if ( (*(uint *)sp->players[i].server) != 0 ) - netdrv_get_local_target( sp->players[i].server, sp->players[i].node, Players[i].net_address ); + if ( (*(uint *)sp->players[i].protocol.ipx.server) != 0 ) + ipxdrv_get_local_target( sp->players[i].protocol.ipx.server, sp->players[i].protocol.ipx.node, Players[i].net_address ); #endif // WORDS_NEED_ALIGNMENT else #endif - memcpy( Players[i].net_address, sp->players[i].node, 6 ); + memcpy( Players[i].net_address, sp->players[i].protocol.ipx.node, 6 ); Players[i].n_packets_got=0; // How many packets we got from them Players[i].n_packets_sent=0; // How many packets we sent to them @@ -2265,19 +2395,11 @@ void network_read_sync_packet( ubyte * data, int d1x ) Objects[Players[Player_num].objnum].type = OBJ_PLAYER; #ifndef SHAREWARE - // process D1X options - if (Netgame.protocol_version == MULTI_PROTO_D1X_VER) { - multi_allow_powerup = Netgame.flags & NETFLAG_DOPOWERUP; - Network_short_packets = (Netgame.flags & NETFLAG_SHORTPACKETS) ? 2 : 0; - Network_pps = Netgame.packets_per_sec; - } else { - if (data) { // adb: master does have this info - Network_short_packets = 0; - Network_pps = 10; - } - multi_allow_powerup = NETFLAG_DOPOWERUP; + if (data) { // adb: master does have this info + Network_pps = 10; } - #endif + multi_allow_powerup = NETFLAG_DOPOWERUP; +#endif Network_status = NETSTAT_PLAYING; Function_mode = FMODE_GAME; @@ -2290,10 +2412,10 @@ network_abort_game(void) { int i; for (i=1; i N_players) { memcpy(Netgame.players[N_players].callsign, Netgame.players[i].callsign, CALLSIGN_LEN+1); - memcpy(Netgame.players[N_players].node, Netgame.players[i].node, 6); - memcpy(Netgame.players[N_players].server, Netgame.players[i].server, 4); + memcpy(Netgame.players[N_players].protocol.ipx.node, Netgame.players[i].protocol.ipx.node, 6); + memcpy(Netgame.players[N_players].protocol.ipx.server, Netgame.players[i].protocol.ipx.server, 4); } Players[N_players].connected = 1; N_players++; } else { - network_dump_player(Netgame.players[i].server,Netgame.players[i].node, DUMP_DORK); + network_dump_player(Netgame.players[i].protocol.ipx.server,Netgame.players[i].protocol.ipx.node, DUMP_DORK); } } for (i = N_players; i < MAX_NUM_NET_PLAYERS; i++) { memset(Netgame.players[i].callsign, 0, CALLSIGN_LEN+1); - memset(Netgame.players[i].node, 0, 6); - memset(Netgame.players[i].server, 0, 4); + memset(Netgame.players[i].protocol.ipx.node, 0, 6); + memset(Netgame.players[i].protocol.ipx.server, 0, 4); } if (Netgame.gamemode == NETGAME_TEAM_ANARCHY) @@ -2584,7 +2706,7 @@ void network_start_game(void) if (i<0) return; if (IPX_Socket) { - netdrv_change_default_socket( IPX_DEFAULT_SOCKET + IPX_Socket ); + ipxdrv_change_default_socket( IPX_DEFAULT_SOCKET + IPX_Socket ); } N_players = 0; @@ -2593,32 +2715,10 @@ void network_start_game(void) Netgame.numplayers = 0; network_set_game_mode(Netgame.gamemode); MaxNumNetPlayers = Netgame.max_numplayers; - - if (GameArg.MplGameProfile) - { - char mprofile_file[13]=""; - newmenu_item m[1]; - m[0].type=NM_TYPE_INPUT; m[0].text_len = 8; m[0].text = mprofile_file; - if (!newmenu_do( NULL, "save profile as", 1, &(m[0]), NULL)) - { - PHYSFS_file *infile; - strcat(mprofile_file,".mpx"); - infile = PHYSFSX_openWriteBuffered(mprofile_file); - PHYSFS_write(infile,&Netgame,sizeof(netgame_info),1); - PHYSFS_close(infile); - } - } + Netgame.protocol.ipx.protocol_version = MULTI_PROTO_VERSION; Network_status = NETSTAT_STARTING; - //adb: the following will be overwritten for D1X only games -#ifndef SHAREWARE - Network_pps = Netgame.packets_per_sec; - Network_short_packets = (Netgame.flags & NETFLAG_SHORTPACKETS) ? 2 : 0; -#endif - - noloss_init_queue(); - if(network_select_players()) { StartNewLevel(Netgame.levelnum); @@ -2758,7 +2858,7 @@ void network_join_poll( int nitems, newmenu_item * menus, int * key, int citem ) if (IPX_Socket != osocket ) { sprintf( menus[0].text, "\t%s %+d (PgUp/PgDn to change)", TXT_CURRENT_IPX_SOCKET, IPX_Socket ); network_listen(); - netdrv_change_default_socket( IPX_DEFAULT_SOCKET + IPX_Socket ); + ipxdrv_change_default_socket( IPX_DEFAULT_SOCKET + IPX_Socket ); restart_net_searching(menus); network_send_game_list_request(); return; @@ -2911,9 +3011,9 @@ network_wait_for_sync(void) memset(&me, 0, sizeof(sequence_packet)); me.type = PID_QUIT_JOINING; memcpy( me.player.callsign, Players[Player_num].callsign, CALLSIGN_LEN+1 ); - memcpy( me.player.node, netdrv_get_my_local_address(), 6 ); - memcpy( me.player.server, netdrv_get_my_server_address(), 4 ); - send_sequence_packet( me, Netgame.players[0].server, Netgame.players[0].node, NULL ); + 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 ); N_players = 0; Function_mode = FMODE_MENU; Game_mode = GM_GAME_OVER; @@ -2989,7 +3089,7 @@ menu: for (i=0; i < N_players; i++) if ((Players[i].connected != 0) && (i != Player_num)) - network_dump_player(Netgame.players[i].server, Netgame.players[i].node, DUMP_ABORTED); + network_dump_player(Netgame.players[i].protocol.ipx.server, Netgame.players[i].protocol.ipx.node, DUMP_ABORTED); longjmp(LeaveGame, 1); } @@ -3009,7 +3109,6 @@ network_level_sync(void) // my_segments_checksum = netmisc_calc_checksum(Segments, sizeof(segment)*(Highest_segment_index+1)); network_flush(); // Flush any old packets - noloss_init_queue(); if (N_players == 0) result = network_wait_for_sync(); @@ -3042,21 +3141,13 @@ int network_do_join_game(int choice) return 0; } - if ((Active_games[choice].protocol_version != MULTI_PROTO_VERSION) && - (Active_games[choice].protocol_version != MULTI_PROTO_D1X_VER)) + if (Active_games[choice].protocol.ipx.protocol_version != MULTI_PROTO_VERSION) { - nm_messagebox(TXT_SORRY, 1, TXT_OK, TXT_VERSION_MISMATCH); + nm_messagebox(TXT_SORRY, 1, TXT_OK, TXT_VERSION_MISMATCH); return 0; } #ifndef SHAREWARE - if (Active_games[choice].protocol_version == MULTI_PROTO_D1X_VER && - Active_games[choice].required_subprotocol > MULTI_PROTO_D1X_MINOR) - { - nm_messagebox(TXT_SORRY, 1, TXT_OK, "This game uses features\nnot present in this version."); - return 0; - } - if (!load_mission_by_name(Active_games[choice].mission_name)) { nm_messagebox(NULL, 1, TXT_OK, TXT_MISSION_NOT_FOUND); @@ -3082,8 +3173,6 @@ int network_do_join_game(int choice) network_set_game_mode(Netgame.gamemode); - noloss_init_queue(); - StartNewLevel(Netgame.levelnum); return 1; // look ma, we're in a game!!! @@ -3180,7 +3269,7 @@ void network_leave_game() (Netgame.numplayers == 1 || Network_status == NETSTAT_STARTING)) { N_players = Netgame.numplayers = 0; - network_send_game_info(NULL, 1); + network_send_game_info(NULL); } Players[Player_num].connected = 0; @@ -3197,7 +3286,7 @@ void network_flush() if (!Network_active) return; - while (netdrv_get_packet_data(packet) > 0) + while (ipxdrv_get_packet_data(packet) > 0) ; } @@ -3208,10 +3297,10 @@ void network_listen() if (!Network_active) return; - size = netdrv_get_packet_data( packet ); + size = ipxdrv_get_packet_data( packet ); while ( size > 0 ) { network_process_packet( packet, size ); - size = netdrv_get_packet_data( packet ); + size = ipxdrv_get_packet_data( packet ); } } @@ -3279,7 +3368,6 @@ fix last_timeout_check = 0; void network_do_frame(int force, int listen) { int i; - short_frame_info ShortSyncPack; if (!(Game_mode&GM_NETWORK)) return; @@ -3295,7 +3383,6 @@ void network_do_frame(int force, int listen) // Send out packet 10 times per second maximum... unless they fire, then send more often... if ( (last_send_time > (F1_0 / Network_pps)) || (Network_laser_fired) || force || PacketUrgent ) { - int ack_pkt = (force || PacketUrgent); if ( Players[Player_num].connected ) { int objnum = Players[Player_num].objnum; @@ -3308,40 +3395,11 @@ void network_do_frame(int force, int listen) last_send_time = 0; - if (Netgame.flags & NETFLAG_SHORTPACKETS) - { - int i; - - memset(&ShortSyncPack,0,sizeof(short_frame_info)); - create_shortpos(&ShortSyncPack.thepos, Objects+objnum, 1); - if (Netgame.protocol_version == MULTI_PROTO_D1X_VER && ack_pkt) - ShortSyncPack.type = PID_PDATA_NOLOSS; - else - ShortSyncPack.type = PID_PDATA; - ShortSyncPack.playernum = Player_num; - ShortSyncPack.obj_render_type = Objects[objnum].render_type; - ShortSyncPack.level_num = Current_level_num; - ShortSyncPack.data_size = INTEL_SHORT(MySyncPack.data_size); - memcpy (&ShortSyncPack.data[0],&MySyncPack.data[0],MySyncPack.data_size); - - MySyncPack.numpackets = INTEL_INT(Players[0].n_packets_sent++); - ShortSyncPack.numpackets = MySyncPack.numpackets; -// NetDrvSendGamePacket((ubyte*)&ShortSyncPack, sizeof(short_frame_info) - NET_XDATA_SIZE + MySyncPack.data_size); - for(i=0; idata_size, Netgame.players[i].protocol.ipx.server, Netgame.players[i].protocol.ipx.node, Players[i].net_address); } } } - - noloss_process_queue(); // Check queued packets, remove or re-send if necessery - noloss_add_packet_to_queue(ack_pkt, MySyncPack.numpackets, MySyncPack.data, MySyncPack.data_size); // add the current packet to queue - PacketUrgent = 0; MySyncPack.data_size = 0; // Start data over at 0 length. @@ -3437,145 +3491,22 @@ void network_consistency_error(void) multi_reset_stuff(); } -#if 0 -void network_read_pdata_packet(ubyte *data, int short_packet) -{ - int TheirPlayernum; - int TheirObjnum; - object * TheirObj = NULL; - frame_info *pd; - - frame_info frame_data; - pd = &frame_data; - receive_frameinfo_packet(data, &frame_data, short_packet); - - if ((TheirPlayernum = pd->playernum) < 0) { - Int3(); // This packet is bogus!! - return; - } -#ifdef SHAREWARE - TheirObjnum = pd->objnum; -#else - TheirObjnum = Players[TheirPlayernum].objnum; -#endif - if (!multi_quit_game && (TheirPlayernum >= N_players)) { - Int3(); // We missed an important packet! - network_consistency_error(); - return; - } - if (Endlevel_sequence || (Network_status == NETSTAT_ENDLEVEL) ) { - int old_Endlevel_sequence = Endlevel_sequence; - Endlevel_sequence = 1; - if ( pd->data_size>0 ) { - // pass pd->data to some parser function.... - multi_process_bigdata( (char*)pd->data, pd->data_size ); - } - Endlevel_sequence = old_Endlevel_sequence; - return; - } - - if ((sbyte)pd->level_num != Current_level_num) - { - return; - } - - TheirObj = &Objects[TheirObjnum]; - - //------------- Keep track of missed packets ----------------- - Players[TheirPlayernum].n_packets_got++; - LastPacketTime[TheirPlayernum] = timer_get_approx_seconds(); -//edited 03/04/99 Matt Mueller - short_packet type 1 is the type without missed_packets - if ( short_packet != 1 && pd->numpackets != Players[TheirPlayernum].n_packets_got ) { -//end edit -MM - missed_packets += pd->numpackets-Players[TheirPlayernum].n_packets_got; - - Players[TheirPlayernum].n_packets_got = pd->numpackets; - } - - //------------ Read the player's ship's object info ---------------------- - if (short_packet == 1) { - extract_shortpos(TheirObj, (shortpos *)(data + 4),1); - } else if (short_packet == 2) { - extract_shortpos(TheirObj, (shortpos *)(data + 2),1); - } else { - TheirObj->pos = pd->obj_pos; - TheirObj->orient = pd->obj_orient; -#ifdef SHAREWARE - TheirObj->mtype.phys_info = pd->obj_phys_info; -#else - TheirObj->mtype.phys_info.velocity = pd->phys_velocity; - TheirObj->mtype.phys_info.rotvel = pd->phys_rotvel; -#endif -#if 0 // adb: why this? screws up ignore command - if ((TheirObj->render_type != pd->obj_render_type) && (pd->obj_render_type == RT_POLYOBJ)) - multi_make_ghost_player(TheirPlayernum); -#endif - - obj_relink(TheirObjnum,pd->obj_segnum); - - } - if (TheirObj->movement_type == MT_PHYSICS) - set_thrust_from_velocity(TheirObj); - - //------------ Welcome them back if reconnecting -------------- - if (!Players[TheirPlayernum].connected) { - Players[TheirPlayernum].connected = 1; - -#ifndef SHAREWARE - if (Newdemo_state == ND_STATE_RECORDING) - newdemo_record_multi_reconnect(TheirPlayernum); -#endif - - multi_make_ghost_player(TheirPlayernum); - - create_player_appearance_effect(&Objects[TheirObjnum]); - - digi_play_sample( SOUND_HUD_MESSAGE, F1_0); - hud_message( MSGC_MULTI_INFO, "'%s' %s",Players[TheirPlayernum].callsign, TXT_REJOIN ); - -#ifndef SHAREWARE - multi_send_score(); -#endif - } - - //------------ Parse the extra data at the end --------------- - - if ( pd->data_size>0 ) { - // pass pd->data to some parser function.... - multi_process_bigdata( (char*)pd->data, pd->data_size ); - } - -} -#endif - void network_process_pdata (char *data) { Assert (Game_mode & GM_NETWORK); - if (Netgame.flags & NETFLAG_SHORTPACKETS) - network_read_pdata_short_packet ((short_frame_info *)data); - else - network_read_pdata_packet ((ubyte *) data); + network_read_pdata_packet ((frame_info *) data); } -void network_read_pdata_packet(ubyte *data ) +void network_read_pdata_packet(frame_info *pd) { int TheirPlayernum; int TheirObjnum; object * TheirObj = NULL; - frame_info *pd; - frame_info frame_data; - - pd = &frame_data; - receive_frameinfo_packet(data, &frame_data); TheirPlayernum = pd->playernum; TheirObjnum = Players[pd->playernum].objnum; - if (pd->type == PID_PDATA_NOLOSS) - if (noloss_validate_pdata(pd->numpackets, pd->playernum) == 0) - return; // got that one already! - if (TheirPlayernum < 0) { Int3(); // This packet is bogus!! return; @@ -3662,142 +3593,6 @@ void network_read_pdata_packet(ubyte *data ) } -#ifdef WORDS_BIGENDIAN -void get_short_frame_info(ubyte *old_info, short_frame_info *new_info) -{ - int loc = 0; - - new_info->type = old_info[loc]; loc++; - /* skip three for pad byte */ loc += 3; - memcpy(&(new_info->numpackets), &(old_info[loc]), 4); loc += 4; - new_info->numpackets = INTEL_INT(new_info->numpackets); - memcpy(new_info->thepos.bytemat, &(old_info[loc]), 9); loc += 9; - memcpy(&(new_info->thepos.xo), &(old_info[loc]), 2); loc += 2; - memcpy(&(new_info->thepos.yo), &(old_info[loc]), 2); loc += 2; - memcpy(&(new_info->thepos.zo), &(old_info[loc]), 2); loc += 2; - memcpy(&(new_info->thepos.segment), &(old_info[loc]), 2); loc += 2; - memcpy(&(new_info->thepos.velx), &(old_info[loc]), 2); loc += 2; - memcpy(&(new_info->thepos.vely), &(old_info[loc]), 2); loc += 2; - memcpy(&(new_info->thepos.velz), &(old_info[loc]), 2); loc += 2; - new_info->thepos.xo = INTEL_SHORT(new_info->thepos.xo); - new_info->thepos.yo = INTEL_SHORT(new_info->thepos.yo); - new_info->thepos.zo = INTEL_SHORT(new_info->thepos.zo); - new_info->thepos.segment = INTEL_SHORT(new_info->thepos.segment); - new_info->thepos.velx = INTEL_SHORT(new_info->thepos.velx); - new_info->thepos.vely = INTEL_SHORT(new_info->thepos.vely); - new_info->thepos.velz = INTEL_SHORT(new_info->thepos.velz); - - memcpy(&(new_info->data_size), &(old_info[loc]), 2); loc += 2; - new_info->data_size = INTEL_SHORT(new_info->data_size); - new_info->playernum = old_info[loc]; loc++; - new_info->obj_render_type = old_info[loc]; loc++; - new_info->level_num = old_info[loc]; loc++; - memcpy(new_info->data, &(old_info[loc]), new_info->data_size); -} -#else -#define get_short_frame_info(old_info, new_info) \ - memcpy(new_info, old_info, sizeof(short_frame_info)) -#endif - -void network_read_pdata_short_packet(short_frame_info *pd ) -{ - int TheirPlayernum; - int TheirObjnum; - object * TheirObj = NULL; - short_frame_info new_pd; - -// short frame info is not aligned because of shortpos. The mac -// will call totally hacked and gross function to fix this up. - - get_short_frame_info((ubyte *)pd, &new_pd); - - TheirPlayernum = new_pd.playernum; - TheirObjnum = Players[new_pd.playernum].objnum; - - if (new_pd.type == PID_PDATA_NOLOSS) - if (noloss_validate_pdata(new_pd.numpackets, new_pd.playernum) == 0) - return; // got that one already! - - if (TheirPlayernum < 0) { - Int3(); // This packet is bogus!! - return; - } - if (!multi_quit_game && (TheirPlayernum >= N_players)) { - if (Network_status!=NETSTAT_WAITING) - { - Int3(); // We missed an important packet! - network_consistency_error(); - return; - } - else - return; - } - - if (Endlevel_sequence || (Network_status == NETSTAT_ENDLEVEL) ) { - int old_Endlevel_sequence = Endlevel_sequence; - Endlevel_sequence = 1; - if ( new_pd.data_size>0 ) { - // pass pd->data to some parser function.... - multi_process_bigdata( new_pd.data, new_pd.data_size ); - } - Endlevel_sequence = old_Endlevel_sequence; - return; - } - - if ((sbyte)new_pd.level_num != Current_level_num) - { - return; - } - - TheirObj = &Objects[TheirObjnum]; - - //------------- Keep track of missed packets ----------------- - Players[TheirPlayernum].n_packets_got++; - LastPacketTime[TheirPlayernum] = timer_get_approx_seconds(); - if ( pd->numpackets != Players[TheirPlayernum].n_packets_got ) { - missed_packets += pd->numpackets-Players[TheirPlayernum].n_packets_got; - - Players[TheirPlayernum].n_packets_got = pd->numpackets; - } - - //------------ Read the player's ship's object info ---------------------- - - extract_shortpos(TheirObj, &new_pd.thepos, 0); - - if ((TheirObj->render_type != new_pd.obj_render_type) && (new_pd.obj_render_type == RT_POLYOBJ)) - multi_make_ghost_player(TheirPlayernum); - - if (TheirObj->movement_type == MT_PHYSICS) - set_thrust_from_velocity(TheirObj); - - //------------ Welcome them back if reconnecting -------------- - if (!Players[TheirPlayernum].connected) { - Players[TheirPlayernum].connected = 1; - - if (Newdemo_state == ND_STATE_RECORDING) - newdemo_record_multi_reconnect(TheirPlayernum); - - multi_make_ghost_player(TheirPlayernum); - - create_player_appearance_effect(&Objects[TheirObjnum]); - - digi_play_sample( SOUND_HUD_MESSAGE, F1_0); - - HUD_init_message( "'%s' %s", Players[TheirPlayernum].callsign, TXT_REJOIN ); - - multi_send_score(); - } - - //------------ Parse the extra data at the end --------------- - - if ( new_pd.data_size>0 ) { - // pass pd->data to some parser function.... - multi_process_bigdata( new_pd.data, new_pd.data_size ); - } - -} - - int network_who_is_master(void) { // Who is the master of this game? @@ -3819,8 +3614,8 @@ void network_ping (ubyte flag,int pnum) mybuf[0]=flag; mybuf[1]=Player_num; - *(u_int32_t*)(multibuf+2)=INTEL_INT(timer_get_fixed_seconds()); - netdrv_send_packet_data( (ubyte *)mybuf, 7, Netgame.players[pnum].server, Netgame.players[pnum].node,Players[pnum].net_address ); + *(u_int32_t*)(multibuf+2)=INTEL_INT(GameTime); + ipxdrv_send_packet_data( (ubyte *)mybuf, 7, Netgame.players[pnum].protocol.ipx.server, Netgame.players[pnum].protocol.ipx.node,Players[pnum].net_address ); } static fix PingLaunchTime[MAX_PLAYERS],PingReturnTime[MAX_PLAYERS]; @@ -3833,7 +3628,7 @@ void network_handle_ping_return (ubyte pnum) return; } - PingReturnTime[pnum]=timer_get_fixed_seconds(); + PingReturnTime[pnum]=GameTime; PingTable[pnum]=f2i(fixmul(PingReturnTime[pnum]-PingLaunchTime[pnum],i2f(1000))); PingLaunchTime[pnum]=0; } @@ -3852,7 +3647,7 @@ void network_ping_all() { if (Players[i].connected && i != Player_num) { - PingLaunchTime[i]=timer_get_fixed_seconds(); + PingLaunchTime[i]=GameTime; network_ping (PID_PING_SEND,i); } } @@ -3923,40 +3718,13 @@ void DoRefuseStuff (sequence_packet *their) WaitForRefuseAnswer=0; if (!strcmp (their->player.callsign,RefusePlayerName)) { - network_dump_player(their->player.server,their->player.node, DUMP_DORK); + network_dump_player(their->player.protocol.ipx.server,their->player.protocol.ipx.node, DUMP_DORK); } return; } } } -// Send request for game information. Resend to keep connection alive. -// Function arguments not used, but needed to call while nm_messagebox1 -void network_info_req( int nitems, newmenu_item * menus, int * key, int citem ) -{ - sequence_packet me; - static fix nextsend, curtime; - ubyte null_addr[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - - menus = menus; - citem = citem; - nitems = nitems; - key = key; - curtime=timer_get_fixed_seconds(); - - if (nextsend - -#include "inferno.h" -#include "pstypes.h" -#include "netpkt.h" -#include "netdrv.h" - -//FIXME: Certain combinations of players having and not having the editor will cause the segment checksum code to fail. -#ifdef WORDS_BIGENDIAN - -#include "byteswap.h" -#include "segment.h" -#include "gameseg.h" - -// routine to calculate the checksum of the segments. We add these specialized routines -// since the current way is byte order dependent. - -void mac_do_checksum_calc(ubyte *b, int len, unsigned int *s1, unsigned int *s2) -{ - - while(len--) { - *s1 += *b++; - if (*s1 >= 255) *s1 -= 255; - *s2 += *s1; - } -} - -ushort mac_calc_segment_checksum() -{ - int i, j, k; - unsigned int sum1,sum2; - short s; - int t; - - sum1 = sum2 = 0; - for (i = 0; i < Highest_segment_index + 1; i++) { - for (j = 0; j < MAX_SIDES_PER_SEGMENT; j++) { - mac_do_checksum_calc((unsigned char *)&(Segments[i].sides[j].type), 1, &sum1, &sum2); - mac_do_checksum_calc(&(Segments[i].sides[j].pad), 1, &sum1, &sum2); - s = INTEL_SHORT(Segments[i].sides[j].wall_num); - mac_do_checksum_calc((ubyte *)&s, 2, &sum1, &sum2); - s = INTEL_SHORT(Segments[i].sides[j].tmap_num); - mac_do_checksum_calc((ubyte *)&s, 2, &sum1, &sum2); - s = INTEL_SHORT(Segments[i].sides[j].tmap_num2); - mac_do_checksum_calc((ubyte *)&s, 2, &sum1, &sum2); - for (k = 0; k < 4; k++) { - t = INTEL_INT(((int)Segments[i].sides[j].uvls[k].u)); - mac_do_checksum_calc((ubyte *)&t, 4, &sum1, &sum2); - t = INTEL_INT(((int)Segments[i].sides[j].uvls[k].v)); - mac_do_checksum_calc((ubyte *)&t, 4, &sum1, &sum2); - t = INTEL_INT(((int)Segments[i].sides[j].uvls[k].l)); - mac_do_checksum_calc((ubyte *)&t, 4, &sum1, &sum2); - } - for (k = 0; k < 2; k++) { - t = INTEL_INT(((int)Segments[i].sides[j].normals[k].x)); - mac_do_checksum_calc((ubyte *)&t, 4, &sum1, &sum2); - t = INTEL_INT(((int)Segments[i].sides[j].normals[k].y)); - mac_do_checksum_calc((ubyte *)&t, 4, &sum1, &sum2); - t = INTEL_INT(((int)Segments[i].sides[j].normals[k].z)); - mac_do_checksum_calc((ubyte *)&t, 4, &sum1, &sum2); - } - } - for (j = 0; j < MAX_SIDES_PER_SEGMENT; j++) { - s = INTEL_SHORT(Segments[i].children[j]); - mac_do_checksum_calc((ubyte *)&s, 2, &sum1, &sum2); - } - for (j = 0; j < MAX_VERTICES_PER_SEGMENT; j++) { - s = INTEL_SHORT(Segments[i].verts[j]); - mac_do_checksum_calc((ubyte *)&s, 2, &sum1, &sum2); - } - s = INTEL_SHORT(Segments[i].objects); - mac_do_checksum_calc((ubyte *)&s, 2, &sum1, &sum2); - mac_do_checksum_calc((unsigned char *)&(Segments[i].special), 1, &sum1, &sum2); - mac_do_checksum_calc((unsigned char *)&(Segments[i].matcen_num), 1, &sum1, &sum2); - s = INTEL_SHORT(Segments[i].value); - mac_do_checksum_calc((ubyte *)&s, 2, &sum1, &sum2); - t = INTEL_INT(((int)Segments[i].static_light)); - mac_do_checksum_calc((ubyte *)&t, 4, &sum1, &sum2); -#ifndef EDITOR - s = INTEL_SHORT(Segments[i].pad); // necessary? If this isn't set to 0 it won't work Intel-Intel anyway. - mac_do_checksum_calc((ubyte *)&s, 2, &sum1, &sum2); -#endif - } - sum2 %= 255; - return ((sum1<<8)+ sum2); -} - -// this routine totally and completely relies on the fact that the network -// checksum must be calculated on the segments!!!!! - -ushort netmisc_calc_checksum(void * vptr, int len) -{ - vptr = vptr; - len = len; - return mac_calc_segment_checksum(); -} -#endif - -// following are routine for macintosh only that will swap the elements of -// structures send through the networking code. The structures and -// this code must be kept in total sync - -#include "multi.h" -#ifdef NETWORK -#include "net_ipx.h" -#endif -#include "object.h" -#include "powerup.h" -#include "error.h" - -ubyte out_buffer[MAX_DATA_SIZE]; // used for tmp netgame packets as well as sending object data - -void put_netplayer_info(ubyte *data, netplayer_info *player, int d1x) -{ - memcpy(data, player->callsign, CALLSIGN_LEN); data += CALLSIGN_LEN; - if (!d1x) *(data++) = 0; - memcpy(data, player->server, 4); data += 4; - memcpy(data, player->node, 6); data += 6; - PUT_INTEL_SHORT(data, player->socket); data += 2; - *data = player->connected; data++; - if (d1x) { - *data = player->sub_protocol; data++; - } -} - -void get_netplayer_info(ubyte *data, netplayer_info *info, int d1x) -{ - int loc = 0; - - memcpy(info->callsign, &(data[loc]), CALLSIGN_LEN); loc += CALLSIGN_LEN; - info->callsign[CALLSIGN_LEN] = 0; - if (!d1x) loc++; - memcpy(&(info->server), &(data[loc]), 4); loc += 4; - memcpy(&(info->node), &(data[loc]), 6); loc += 6; - memcpy(&(info->socket), &(data[loc]), 2); loc += 2; -//MWA don't think we need to swap this because we need it in high order info->socket = INTEL_SHORT(info->socket); - info->connected = data[loc]; loc++; - //edited 03/04/99 Matt Mueller - sub_protocol was being set wrong in non-d1x games.. I still think its screwed somewhere else too though - if (d1x){ - info->sub_protocol = data[loc]; loc++; - }else - info->sub_protocol = 0; -//end edit -MM -} - -void send_sequence_packet(sequence_packet seq, ubyte *server, ubyte *node, ubyte *net_address) -{ - int loc; - - loc = 0; - memset(out_buffer, 0, sizeof(out_buffer)); - out_buffer[0] = seq.type; loc++; - put_netplayer_info(&(out_buffer[loc]), &seq.player, 0); loc += sizeof(netplayer_info); - out_buffer[loc] = MULTI_PROTO_D1X_MINOR; loc++; - - if (net_address != NULL) - netdrv_send_packet_data( out_buffer, loc, server, node, net_address); - else if ((server == NULL) && (node == NULL)) - netdrv_send_broadcast_packet_data( out_buffer, loc ); - else - netdrv_send_internetwork_packet_data( out_buffer, loc, server, node); -} - -void receive_sequence_packet(ubyte *data, sequence_packet *seq) -{ - int loc = 0; - - seq->type = data[0]; loc++; - get_netplayer_info(&(data[loc]), &(seq->player), 0); -} - -void send_netgame_packet(ubyte *server, ubyte *node) -{ - int i, j; - int loc = 0; - - if (Netgame.protocol_version == MULTI_PROTO_D1X_VER) { - send_d1x_netgame_packet(server, node); - return; - } - memset(out_buffer, 0, MAX_DATA_SIZE); - out_buffer[loc] = Netgame.type; loc++; - memcpy(&(out_buffer[loc]), Netgame.game_name, NETGAME_NAME_LEN+1); loc += (NETGAME_NAME_LEN+1); - memcpy(&(out_buffer[loc]), Netgame.team_name, 2*(CALLSIGN_LEN+1)); loc += 2*(CALLSIGN_LEN+1); - out_buffer[loc] = Netgame.gamemode; loc++; - out_buffer[loc] = Netgame.difficulty; loc++; - out_buffer[loc] = Netgame.game_status; loc++; - out_buffer[loc] = Netgame.numplayers; loc++; - out_buffer[loc] = Netgame.max_numplayers; loc++; - out_buffer[loc] = Netgame.game_flags; loc++; - for (i = 0; i < MAX_PLAYERS; i++) { - put_netplayer_info(&(out_buffer[loc]), &Netgame.players[i], 0); loc += sizeof(netplayer_info); - } - if (Netgame.protocol_version == MULTI_PROTO_D1X_VER) { - for (i = 0; i < MAX_PLAYERS; i++) { - out_buffer[loc] = Netgame.locations[i]; loc++; - } - } else { - for (i = 0; i < MAX_PLAYERS; i++) { - PUT_INTEL_INT(out_buffer + loc, Netgame.locations[i]); loc += 4; // SWAP HERE!!! - } - } - - for (i = 0; i < MAX_PLAYERS; i++) { - for (j = 0; j < MAX_PLAYERS; j++) { - PUT_INTEL_SHORT(out_buffer + loc, Netgame.kills[i][j]); loc += 2; // SWAP HERE!!! - } - } - - PUT_INTEL_INT(out_buffer + loc, Netgame.levelnum); loc += 4; // SWAP_HERE - out_buffer[loc] = Netgame.protocol_version; loc++; - out_buffer[loc] = Netgame.team_vector; loc++; - PUT_INTEL_SHORT(out_buffer + loc, Netgame.segments_checksum); loc += 2; // SWAP_HERE - PUT_INTEL_SHORT(out_buffer + loc, Netgame.team_kills[0]); loc += 2; // SWAP_HERE - PUT_INTEL_SHORT(out_buffer + loc, Netgame.team_kills[1]); loc += 2; // SWAP_HERE - for (i = 0; i < MAX_PLAYERS; i++) { - PUT_INTEL_SHORT(out_buffer + loc, Netgame.killed[i]); loc += 2; // SWAP HERE!!! - } - for (i = 0; i < MAX_PLAYERS; i++) { - PUT_INTEL_SHORT(out_buffer + loc, Netgame.player_kills[i]); loc += 2; // SWAP HERE!!! - } - - PUT_INTEL_INT(out_buffer + loc, Netgame.level_time); loc += 4; // SWAP_HERE - PUT_INTEL_INT(out_buffer + loc, Netgame.control_invul_time); loc += 4; // SWAP_HERE - PUT_INTEL_INT(out_buffer + loc, Netgame.monitor_vector); loc += 4; // SWAP_HERE - for (i = 0; i < 8; i++) { - PUT_INTEL_INT(out_buffer + loc, Netgame.player_score[i]); loc += 4; // SWAP_HERE - } - for (i = 0; i < 8; i++) { - out_buffer[loc] = Netgame.player_flags[i]; loc++; - } - memcpy(&(out_buffer[loc]), Netgame.mission_name, 9); loc += 9; - memcpy(&(out_buffer[loc]), Netgame.mission_title, MISSION_NAME_LEN+1); loc += (MISSION_NAME_LEN+1); - if (Netgame.protocol_version == MULTI_PROTO_D1X_VER) { - out_buffer[loc] = Netgame.packets_per_sec; loc++; - PUT_INTEL_INT(out_buffer + loc, Netgame.flags); loc += 4; - } - - if (server == NULL) - netdrv_send_broadcast_packet_data(out_buffer, loc); - else - netdrv_send_internetwork_packet_data( out_buffer, loc, server, node ); -} - -void receive_netgame_packet(ubyte *data, netgame_info *netgame, int d1x) -{ - int i, j; - int loc = 0; - if (d1x) { - receive_d1x_netgame_packet(data, netgame); - return; - } - - netgame->type = data[loc]; loc++; - memcpy(netgame->game_name, &(data[loc]), NETGAME_NAME_LEN+1); loc += (NETGAME_NAME_LEN+1); - memcpy(netgame->team_name, &(data[loc]), 2*(CALLSIGN_LEN+1)); loc += 2*(CALLSIGN_LEN+1); - netgame->gamemode = data[loc]; loc++; - netgame->difficulty = data[loc]; loc++; - netgame->game_status = data[loc]; loc++; - netgame->numplayers = data[loc]; loc++; - netgame->max_numplayers = data[loc]; loc++; - netgame->game_flags = data[loc]; loc++; - for (i = 0; i < MAX_PLAYERS; i++) { - get_netplayer_info(&(data[loc]), &(netgame->players[i]), 0); - loc += NETPLAYER_ORIG_SIZE; - } -#if 0 - if (d1x) { - for (i = 0; i < MAX_PLAYERS; i++) { - netgame->locations[i] = data[loc]; loc++; - } - } else -#endif - { - for (i = 0; i < MAX_PLAYERS; i++) { - memcpy(&(netgame->locations[i]), &(data[loc]), 4); loc += 4; // SWAP HERE!!! - netgame->locations[i] = INTEL_INT(netgame->locations[i]); - } - } - - for (i = 0; i < MAX_PLAYERS; i++) { - for (j = 0; j < MAX_PLAYERS; j++) { - memcpy(&(netgame->kills[i][j]), &(data[loc]), 2); loc += 2; // SWAP HERE!!! - netgame->kills[i][j] = INTEL_SHORT(netgame->kills[i][j]); - } - } - - memcpy(&(netgame->levelnum), &(data[loc]), 4); loc += 4; // SWAP_HERE - netgame->levelnum = INTEL_INT(netgame->levelnum); - netgame->protocol_version = data[loc]; loc++; - netgame->team_vector = data[loc]; loc++; - memcpy(&(netgame->segments_checksum), &(data[loc]), 2); loc += 2; // SWAP_HERE - netgame->segments_checksum = INTEL_SHORT(netgame->segments_checksum); - memcpy(&(netgame->team_kills[0]), &(data[loc]), 2); loc += 2; // SWAP_HERE - netgame->team_kills[0] = INTEL_SHORT(netgame->team_kills[0]); - memcpy(&(netgame->team_kills[1]), &(data[loc]), 2); loc += 2; // SWAP_HERE - netgame->team_kills[1] = INTEL_SHORT(netgame->team_kills[1]); - for (i = 0; i < MAX_PLAYERS; i++) { - memcpy(&(netgame->killed[i]), &(data[loc]), 2); loc += 2; // SWAP HERE!!! - netgame->killed[i] = INTEL_SHORT(netgame->killed[i]); - } - for (i = 0; i < MAX_PLAYERS; i++) { - memcpy(&(netgame->player_kills[i]), &(data[loc]), 2); loc += 2; // SWAP HERE!!! - netgame->player_kills[i] = INTEL_SHORT(netgame->player_kills[i]); - } - - memcpy(&(netgame->level_time), &(data[loc]), 4); loc += 4; // SWAP_HERE - netgame->level_time = INTEL_INT(netgame->level_time); - memcpy(&(netgame->control_invul_time), &(data[loc]), 4); loc += 4; // SWAP_HERE - netgame->control_invul_time = INTEL_INT(netgame->control_invul_time); - memcpy(&(netgame->monitor_vector), &(data[loc]), 4); loc += 4; // SWAP_HERE - netgame->monitor_vector = INTEL_INT(netgame->monitor_vector); - for (i = 0; i < 8; i++) { - memcpy(&(netgame->player_score[i]), &(data[loc]), 4); loc += 4; // SWAP_HERE - netgame->player_score[i] = INTEL_INT(netgame->player_score[i]); - } - memcpy(netgame->player_flags, &(data[loc]), 8); loc += 8; -#if 0 - for (i = 0; i < 8; i++) { - memcpy(&(netgame->player_flags[i]), &(data[loc]), 1); loc++; - } -#endif - - memcpy(netgame->mission_name, &(data[loc]), 9); loc += 9; - memcpy(netgame->mission_title, &(data[loc]), MISSION_NAME_LEN+1); loc += (MISSION_NAME_LEN+1); -#if 0 - if (d1x && netgame->protocol_version == MULTI_PROTO_D1X_VER) { - netgame->packets_per_sec = data[loc]; loc++; - memcpy(&netgame->flags, &data[loc], 4); loc += 4; - netgame->flags = INTEL_INT(netgame->flags); - } -#endif -} - -void send_d1x_netgame_packet(ubyte *server, ubyte *node) -{ - uint tmpi; - ushort tmps; - int i, j; - int loc = 0; - - memset(out_buffer, 0, MAX_DATA_SIZE); - out_buffer[loc] = Netgame.type; loc++; - out_buffer[loc] = MULTI_PROTO_D1X_VER; loc++; - out_buffer[loc] = Netgame.subprotocol; loc++; - out_buffer[loc] = Netgame.required_subprotocol; loc++; - memcpy(&(out_buffer[loc]), Netgame.game_name, NETGAME_NAME_LEN); loc += NETGAME_NAME_LEN; - memcpy(&(out_buffer[loc]), Netgame.mission_name, 8); loc += 8; - memcpy(&(out_buffer[loc]), Netgame.mission_title, MISSION_NAME_LEN); loc += MISSION_NAME_LEN; - out_buffer[loc] = Netgame.levelnum; loc++; - out_buffer[loc] = Netgame.gamemode; loc++; - out_buffer[loc] = Netgame.difficulty; loc++; - out_buffer[loc] = Netgame.game_status; loc++; - out_buffer[loc] = Netgame.game_flags; loc++; - out_buffer[loc] = Netgame.max_numplayers; loc++; - out_buffer[loc] = Netgame.team_vector; loc++; - if (Netgame.type == PID_D1X_GAME_LITE) { - int master = -1; - j = 0; - for (i = 0; i < Netgame.numplayers; i++) - if (Players[i].connected) { - if (master == -1) - master = i; - j++; - } - out_buffer[loc] = j; loc++; /* numconnected */ - if (master == -1) /* should not happen, but... */ - master = Player_num; - put_netplayer_info(&(out_buffer[loc]), &Netgame.players[master], 1); loc += NETPLAYER_D1X_SIZE; - //added 4/18/99 Matt Mueller - send .flags as well, so 'I' can show them - tmpi = INTEL_INT(Netgame.flags); - memcpy(&out_buffer[loc], &tmpi, 4); loc += 4; - //end addition -MM - } else { - out_buffer[loc] = Netgame.numplayers; loc++; - out_buffer[loc] = NETPLAYER_D1X_SIZE; loc++; // sizeof netplayer struct - for (i = 0; i < MAX_PLAYERS; i++) { - put_netplayer_info(&(out_buffer[loc]), &Netgame.players[i], 1); - loc += NETPLAYER_D1X_SIZE; - } - memcpy(&(out_buffer[loc]), Netgame.team_name[0], CALLSIGN_LEN); loc += CALLSIGN_LEN; - memcpy(&(out_buffer[loc]), Netgame.team_name[1], CALLSIGN_LEN); loc += CALLSIGN_LEN; - for (i = 0; i < MAX_PLAYERS; i++) { - out_buffer[loc] = Netgame.locations[i]; loc++; - } - for (i = 0; i < MAX_PLAYERS; i++) { - for (j = 0; j < MAX_PLAYERS; j++) { - tmps = INTEL_SHORT(Netgame.kills[i][j]); - memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2; // SWAP HERE!!! - } - } - tmps = INTEL_SHORT(Netgame.segments_checksum); - memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2; // SWAP_HERE - tmps = INTEL_SHORT(Netgame.team_kills[0]); - memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2; // SWAP_HERE - tmps = INTEL_SHORT(Netgame.team_kills[1]); - memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2; // SWAP_HERE - for (i = 0; i < MAX_PLAYERS; i++) { - tmps = INTEL_SHORT(Netgame.killed[i]); - memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2; // SWAP HERE!!! - } - for (i = 0; i < MAX_PLAYERS; i++) { - tmps = INTEL_SHORT(Netgame.player_kills[i]); - memcpy(&(out_buffer[loc]), &tmps, 2); loc += 2; // SWAP HERE!!! - } - tmpi = INTEL_INT(Netgame.level_time); - memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4; // SWAP_HERE - tmpi = INTEL_INT(Netgame.control_invul_time); - memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4; // SWAP_HERE - tmpi = INTEL_INT(Netgame.monitor_vector); - memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4; // SWAP_HERE - for (i = 0; i < 8; i++) { - tmpi = INTEL_INT(Netgame.player_score[i]); - memcpy(&(out_buffer[loc]), &tmpi, 4); loc += 4; // SWAP_HERE - } - memcpy(&(out_buffer[loc]), Netgame.player_flags, MAX_PLAYERS); loc += MAX_PLAYERS; - out_buffer[loc] = Netgame.packets_per_sec; loc++; - tmpi = INTEL_INT(Netgame.flags); - memcpy(&out_buffer[loc], &tmpi, 4); loc += 4; - } - - if (server == NULL) - netdrv_send_broadcast_packet_data(out_buffer, loc); - else - netdrv_send_internetwork_packet_data(out_buffer, loc, server, node); -} - -void receive_d1x_netgame_packet(ubyte *data, netgame_info *netgame) { - int i, j; - int loc = 0; - - netgame->type = data[loc]; loc++; - if (netgame->type == PID_D1X_GAME_LITE) { - memset(netgame, 0, sizeof(netgame_info)); - netgame->type = PID_D1X_GAME_LITE; - } - netgame->protocol_version = data[loc]; loc++; - netgame->subprotocol = data[loc]; loc++; - netgame->required_subprotocol = data[loc]; loc++; - memcpy(netgame->game_name, &(data[loc]), NETGAME_NAME_LEN); loc += NETGAME_NAME_LEN; - netgame->game_name[NETGAME_NAME_LEN] = 0; - memcpy(netgame->mission_name, &(data[loc]), 8); loc += 8; - netgame->mission_name[8] = 0; - memcpy(netgame->mission_title, &(data[loc]), MISSION_NAME_LEN); loc += MISSION_NAME_LEN; - netgame->mission_title[MISSION_NAME_LEN] = 0; - netgame->levelnum = ((signed char *)data)[loc]; loc++; - netgame->gamemode = data[loc]; loc++; - netgame->difficulty = data[loc]; loc++; - netgame->game_status = data[loc]; loc++; - netgame->game_flags = data[loc]; loc++; - netgame->max_numplayers = data[loc]; loc++; - netgame->team_vector = data[loc]; loc++; - if (netgame->type == PID_D1X_GAME_LITE) { - j = netgame->numplayers = data[loc]; loc++; - for (i = 0; i < j; i++) - netgame->players[i].connected = 1; - get_netplayer_info(&(data[loc]), &(netgame->players[0]), 1);loc += NETPLAYER_D1X_SIZE; - //added 4/18/99 Matt Mueller - send .flags as well, so 'I' can show them - if (netgame->subprotocol>=1){ - memcpy(&netgame->flags, &data[loc], 4); loc += 4; - netgame->flags = INTEL_INT(netgame->flags); - } - //end addition -MM - } else { - netgame->numplayers = data[loc]; loc++; - j = data[loc]; loc++; // sizeof netplayer struct - if (j > 29) { /* sanity: 304+29*8=536, just below IPX_MAX=542 */ - netgame->protocol_version = 0; return; - } - for (i = 0; i < MAX_PLAYERS; i++) { - get_netplayer_info(&(data[loc]), &(netgame->players[i]), 1); - loc += j; - } - memcpy(netgame->team_name[0], &(data[loc]), CALLSIGN_LEN); loc += CALLSIGN_LEN; - netgame->team_name[0][CALLSIGN_LEN] = 0; - memcpy(netgame->team_name[1], &(data[loc]), CALLSIGN_LEN); loc += CALLSIGN_LEN; - netgame->team_name[1][CALLSIGN_LEN] = 0; - for (i = 0; i < MAX_PLAYERS; i++) { - netgame->locations[i] = data[loc]; loc++; - } - for (i = 0; i < MAX_PLAYERS; i++) { - for (j = 0; j < MAX_PLAYERS; j++) { - memcpy(&(netgame->kills[i][j]), &(data[loc]), 2); loc += 2; // SWAP HERE!!! - netgame->kills[i][j] = INTEL_SHORT(netgame->kills[i][j]); - } - } - memcpy(&(netgame->segments_checksum), &(data[loc]), 2); loc += 2; // SWAP_HERE - netgame->segments_checksum = INTEL_SHORT(netgame->segments_checksum); - memcpy(&(netgame->team_kills[0]), &(data[loc]), 2); loc += 2; // SWAP_HERE - netgame->team_kills[0] = INTEL_SHORT(netgame->team_kills[0]); - memcpy(&(netgame->team_kills[1]), &(data[loc]), 2); loc += 2; // SWAP_HERE - netgame->team_kills[1] = INTEL_SHORT(netgame->team_kills[1]); - for (i = 0; i < MAX_PLAYERS; i++) { - memcpy(&(netgame->killed[i]), &(data[loc]), 2); loc += 2; // SWAP HERE!!! - netgame->killed[i] = INTEL_SHORT(netgame->killed[i]); - } - for (i = 0; i < MAX_PLAYERS; i++) { - memcpy(&(netgame->player_kills[i]), &(data[loc]), 2); loc += 2; // SWAP HERE!!! - netgame->player_kills[i] = INTEL_SHORT(netgame->player_kills[i]); - } - memcpy(&(netgame->level_time), &(data[loc]), 4); loc += 4; // SWAP_HERE - netgame->level_time = INTEL_INT(netgame->level_time); - memcpy(&(netgame->control_invul_time), &(data[loc]), 4); loc += 4; // SWAP_HERE - netgame->control_invul_time = INTEL_INT(netgame->control_invul_time); - memcpy(&(netgame->monitor_vector), &(data[loc]), 4); loc += 4; // SWAP_HERE - netgame->monitor_vector = INTEL_INT(netgame->monitor_vector); - for (i = 0; i < 8; i++) { - memcpy(&(netgame->player_score[i]), &(data[loc]), 4); loc += 4; // SWAP_HERE - netgame->player_score[i] = INTEL_INT(netgame->player_score[i]); - } - memcpy(netgame->player_flags, &(data[loc]), 8); loc += 8; - netgame->packets_per_sec = data[loc]; loc++; - memcpy(&netgame->flags, &data[loc], 4); loc += 4; - netgame->flags = INTEL_INT(netgame->flags); - } -} - -#ifdef WORDS_BIGENDIAN -void send_frameinfo_packet(frame_info *info, ubyte *server, ubyte *node, ubyte *net_address) -{ - int loc = 0; - - out_buffer[loc] = info->type; loc++; - /*3 bytes of padding */ loc += 3; - - PUT_INTEL_INT(&out_buffer[loc], info->numpackets); loc += 4; - PUT_INTEL_INT(&out_buffer[loc], (int)info->obj_pos.x); loc += 4; - PUT_INTEL_INT(&out_buffer[loc], (int)info->obj_pos.y); loc += 4; - PUT_INTEL_INT(&out_buffer[loc], (int)info->obj_pos.z); loc += 4; - - PUT_INTEL_INT(&out_buffer[loc], (int)info->obj_orient.rvec.x); loc += 4; - PUT_INTEL_INT(&out_buffer[loc], (int)info->obj_orient.rvec.y); loc += 4; - PUT_INTEL_INT(&out_buffer[loc], (int)info->obj_orient.rvec.z); loc += 4; - PUT_INTEL_INT(&out_buffer[loc], (int)info->obj_orient.uvec.x); loc += 4; - PUT_INTEL_INT(&out_buffer[loc], (int)info->obj_orient.uvec.y); loc += 4; - PUT_INTEL_INT(&out_buffer[loc], (int)info->obj_orient.uvec.z); loc += 4; - PUT_INTEL_INT(&out_buffer[loc], (int)info->obj_orient.fvec.x); loc += 4; - PUT_INTEL_INT(&out_buffer[loc], (int)info->obj_orient.fvec.y); loc += 4; - PUT_INTEL_INT(&out_buffer[loc], (int)info->obj_orient.fvec.z); loc += 4; - - PUT_INTEL_INT(&out_buffer[loc], (int)info->phys_velocity.x); loc += 4; - PUT_INTEL_INT(&out_buffer[loc], (int)info->phys_velocity.y); loc += 4; - PUT_INTEL_INT(&out_buffer[loc], (int)info->phys_velocity.z); loc += 4; - - PUT_INTEL_INT(&out_buffer[loc], (int)info->phys_rotvel.x); loc += 4; - PUT_INTEL_INT(&out_buffer[loc], (int)info->phys_rotvel.y); loc += 4; - PUT_INTEL_INT(&out_buffer[loc], (int)info->phys_rotvel.z); loc += 4; - - PUT_INTEL_SHORT(&out_buffer[loc], info->obj_segnum); loc += 2; - PUT_INTEL_SHORT(&out_buffer[loc], info->data_size); loc += 2; - out_buffer[loc] = info->playernum; loc++; - out_buffer[loc] = info->obj_render_type; loc++; - out_buffer[loc] = info->level_num; loc++; - memcpy(&out_buffer[loc], info->data, info->data_size); loc += info->data_size; - - // Always array passed - netdrv_send_packet_data(out_buffer, loc, server, node, net_address); -} - -void receive_frameinfo_packet(ubyte *data, frame_info *info) -{ - int loc = 0; - - info->type = data[loc]; loc++; - /*3 bytes of padding */ loc += 3; - - info->numpackets = GET_INTEL_INT(&data[loc]); loc += 4; - info->obj_pos.x = GET_INTEL_INT(&data[loc]); loc += 4; - info->obj_pos.y = GET_INTEL_INT(&data[loc]); loc += 4; - info->obj_pos.z = GET_INTEL_INT(&data[loc]); loc += 4; - - info->obj_orient.rvec.x = GET_INTEL_INT(&data[loc]); loc += 4; - info->obj_orient.rvec.y = GET_INTEL_INT(&data[loc]); loc += 4; - info->obj_orient.rvec.z = GET_INTEL_INT(&data[loc]); loc += 4; - info->obj_orient.uvec.x = GET_INTEL_INT(&data[loc]); loc += 4; - info->obj_orient.uvec.y = GET_INTEL_INT(&data[loc]); loc += 4; - info->obj_orient.uvec.z = GET_INTEL_INT(&data[loc]); loc += 4; - info->obj_orient.fvec.x = GET_INTEL_INT(&data[loc]); loc += 4; - info->obj_orient.fvec.y = GET_INTEL_INT(&data[loc]); loc += 4; - info->obj_orient.fvec.z = GET_INTEL_INT(&data[loc]); loc += 4; - - info->phys_velocity.x = GET_INTEL_INT(&data[loc]); loc += 4; - info->phys_velocity.y = GET_INTEL_INT(&data[loc]); loc += 4; - info->phys_velocity.z = GET_INTEL_INT(&data[loc]); loc += 4; - - info->phys_rotvel.x = GET_INTEL_INT(&data[loc]); loc += 4; - info->phys_rotvel.y = GET_INTEL_INT(&data[loc]); loc += 4; - info->phys_rotvel.z = GET_INTEL_INT(&data[loc]); loc += 4; - - info->obj_segnum = GET_INTEL_SHORT(&data[loc]); loc += 2; - info->data_size = GET_INTEL_SHORT(&data[loc]); loc += 2; - info->playernum = data[loc]; loc++; - info->obj_render_type = data[loc]; loc++; - info->level_num = data[loc]; loc++; - memcpy(info->data, &data[loc], info->data_size); loc += info->data_size; -} -#endif - -void swap_object(object *obj) -{ -// swap the short and int entries for this object - obj->signature = INTEL_INT(obj->signature); - obj->next = INTEL_SHORT(obj->next); - obj->prev = INTEL_SHORT(obj->prev); - obj->segnum = INTEL_SHORT(obj->segnum); - obj->attached_obj = INTEL_SHORT(obj->attached_obj); - obj->pos.x = INTEL_INT(obj->pos.x); - obj->pos.y = INTEL_INT(obj->pos.y); - obj->pos.z = INTEL_INT(obj->pos.z); - - obj->orient.rvec.x = INTEL_INT(obj->orient.rvec.x); - obj->orient.rvec.y = INTEL_INT(obj->orient.rvec.y); - obj->orient.rvec.z = INTEL_INT(obj->orient.rvec.z); - obj->orient.fvec.x = INTEL_INT(obj->orient.fvec.x); - obj->orient.fvec.y = INTEL_INT(obj->orient.fvec.y); - obj->orient.fvec.z = INTEL_INT(obj->orient.fvec.z); - obj->orient.uvec.x = INTEL_INT(obj->orient.uvec.x); - obj->orient.uvec.y = INTEL_INT(obj->orient.uvec.y); - obj->orient.uvec.z = INTEL_INT(obj->orient.uvec.z); - - obj->size = INTEL_INT(obj->size); - obj->shields = INTEL_INT(obj->shields); - - obj->last_pos.x = INTEL_INT(obj->last_pos.x); - obj->last_pos.y = INTEL_INT(obj->last_pos.y); - obj->last_pos.z = INTEL_INT(obj->last_pos.z); - - obj->lifeleft = INTEL_INT(obj->lifeleft); - - switch (obj->movement_type) { - - case MT_PHYSICS: - - obj->mtype.phys_info.velocity.x = INTEL_INT(obj->mtype.phys_info.velocity.x); - obj->mtype.phys_info.velocity.y = INTEL_INT(obj->mtype.phys_info.velocity.y); - obj->mtype.phys_info.velocity.z = INTEL_INT(obj->mtype.phys_info.velocity.z); - - obj->mtype.phys_info.thrust.x = INTEL_INT(obj->mtype.phys_info.thrust.x); - obj->mtype.phys_info.thrust.y = INTEL_INT(obj->mtype.phys_info.thrust.y); - obj->mtype.phys_info.thrust.z = INTEL_INT(obj->mtype.phys_info.thrust.z); - - obj->mtype.phys_info.mass = INTEL_INT(obj->mtype.phys_info.mass); - obj->mtype.phys_info.drag = INTEL_INT(obj->mtype.phys_info.drag); - obj->mtype.phys_info.brakes = INTEL_INT(obj->mtype.phys_info.brakes); - - obj->mtype.phys_info.rotvel.x = INTEL_INT(obj->mtype.phys_info.rotvel.x); - obj->mtype.phys_info.rotvel.y = INTEL_INT(obj->mtype.phys_info.rotvel.y); - obj->mtype.phys_info.rotvel.z = INTEL_INT(obj->mtype.phys_info.rotvel.z); - - obj->mtype.phys_info.rotthrust.x = INTEL_INT(obj->mtype.phys_info.rotthrust.x); - obj->mtype.phys_info.rotthrust.y = INTEL_INT(obj->mtype.phys_info.rotthrust.y); - obj->mtype.phys_info.rotthrust.z = INTEL_INT(obj->mtype.phys_info.rotthrust.z); - - obj->mtype.phys_info.turnroll = INTEL_INT(obj->mtype.phys_info.turnroll); - obj->mtype.phys_info.flags = INTEL_SHORT(obj->mtype.phys_info.flags); - - break; - - case MT_SPINNING: - - obj->mtype.spin_rate.x = INTEL_INT(obj->mtype.spin_rate.x); - obj->mtype.spin_rate.y = INTEL_INT(obj->mtype.spin_rate.y); - obj->mtype.spin_rate.z = INTEL_INT(obj->mtype.spin_rate.z); - break; - } - - switch (obj->control_type) { - - case CT_WEAPON: - obj->ctype.laser_info.parent_type = INTEL_SHORT(obj->ctype.laser_info.parent_type); - obj->ctype.laser_info.parent_num = INTEL_SHORT(obj->ctype.laser_info.parent_num); - obj->ctype.laser_info.parent_signature = INTEL_SHORT(obj->ctype.laser_info.parent_signature); - obj->ctype.laser_info.creation_time = INTEL_INT(obj->ctype.laser_info.creation_time); - obj->ctype.laser_info.last_hitobj = INTEL_INT(obj->ctype.laser_info.last_hitobj); - obj->ctype.laser_info.multiplier = INTEL_INT(obj->ctype.laser_info.multiplier); - break; - - case CT_EXPLOSION: - obj->ctype.expl_info.spawn_time = INTEL_INT(obj->ctype.expl_info.spawn_time); - obj->ctype.expl_info.delete_time = INTEL_INT(obj->ctype.expl_info.delete_time); - obj->ctype.expl_info.delete_objnum = INTEL_SHORT(obj->ctype.expl_info.delete_objnum); - obj->ctype.expl_info.attach_parent = INTEL_SHORT(obj->ctype.expl_info.attach_parent); - obj->ctype.expl_info.prev_attach = INTEL_SHORT(obj->ctype.expl_info.prev_attach); - obj->ctype.expl_info.next_attach = INTEL_SHORT(obj->ctype.expl_info.next_attach); - break; - - case CT_AI: - obj->ctype.ai_info.hide_segment = INTEL_SHORT(obj->ctype.ai_info.hide_segment); - obj->ctype.ai_info.hide_index = INTEL_SHORT(obj->ctype.ai_info.hide_index); - obj->ctype.ai_info.path_length = INTEL_SHORT(obj->ctype.ai_info.path_length); - obj->ctype.ai_info.cur_path_index = INTEL_SHORT(obj->ctype.ai_info.cur_path_index); - obj->ctype.ai_info.follow_path_start_seg = INTEL_SHORT(obj->ctype.ai_info.follow_path_start_seg); - obj->ctype.ai_info.follow_path_end_seg = INTEL_SHORT(obj->ctype.ai_info.follow_path_end_seg); - obj->ctype.ai_info.danger_laser_signature = INTEL_INT(obj->ctype.ai_info.danger_laser_signature); - obj->ctype.ai_info.danger_laser_num = INTEL_SHORT(obj->ctype.ai_info.danger_laser_num); - break; - - case CT_LIGHT: - obj->ctype.light_info.intensity = INTEL_INT(obj->ctype.light_info.intensity); - break; - - case CT_POWERUP: - obj->ctype.powerup_info.count = INTEL_INT(obj->ctype.powerup_info.count); - if (obj->id == POW_VULCAN_WEAPON) - obj->ctype.powerup_info.count = VULCAN_WEAPON_AMMO_AMOUNT; - break; - - } - - switch (obj->render_type) { - - case RT_MORPH: - case RT_POLYOBJ: { - int i; - - obj->rtype.pobj_info.model_num = INTEL_INT(obj->rtype.pobj_info.model_num); - - for (i=0;irtype.pobj_info.anim_angles[i].p = INTEL_INT(obj->rtype.pobj_info.anim_angles[i].p); - obj->rtype.pobj_info.anim_angles[i].b = INTEL_INT(obj->rtype.pobj_info.anim_angles[i].b); - obj->rtype.pobj_info.anim_angles[i].h = INTEL_INT(obj->rtype.pobj_info.anim_angles[i].h); - } - - obj->rtype.pobj_info.subobj_flags = INTEL_INT(obj->rtype.pobj_info.subobj_flags); - obj->rtype.pobj_info.tmap_override = INTEL_INT(obj->rtype.pobj_info.tmap_override); - obj->rtype.pobj_info.alt_textures = INTEL_INT(obj->rtype.pobj_info.alt_textures); - break; - } - - case RT_WEAPON_VCLIP: - case RT_HOSTAGE: - case RT_POWERUP: - case RT_FIREBALL: - obj->rtype.vclip_info.vclip_num = INTEL_INT(obj->rtype.vclip_info.vclip_num); - obj->rtype.vclip_info.frametime = INTEL_INT(obj->rtype.vclip_info.frametime); - break; - - case RT_LASER: - break; - - } -// END OF SWAPPING OBJECT STRUCTURE - -} - -#ifndef WORDS_BIGENDIAN - - -// Calculates the checksum of a block of memory. -ushort netmisc_calc_checksum(void * vptr, int len) -{ - ubyte *ptr = (ubyte *)vptr; - unsigned int sum1,sum2; - - sum1 = sum2 = 0; - - while(len--) { - sum1 += *ptr++; - if (sum1 >= 255) sum1 -= 255; - sum2 += sum1; - } - sum2 %= 255; - - return ((sum1<<8)+ sum2); -} - -#endif /* WORDS_BIGENDIAN */ - -#endif //ifdef NETWORK diff --git a/main/netpkt.h b/main/netpkt.h deleted file mode 100644 index c5bbcde1d..000000000 --- a/main/netpkt.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef _NETPKTOR_H -#define _NETPKTOR_H - -#include "byteswap.h" -#include "netdrv.h" -#include "net_ipx.h" - -//Returns a checksum of a block of memory. -extern ushort netmisc_calc_checksum( void * vptr, int len ); - -ubyte out_buffer[MAX_DATA_SIZE]; // used for tmp netgame packets as well as sending object data -extern frame_info MySyncPack; -void send_d1x_netgame_packet(ubyte *server, ubyte *node); -void receive_d1x_netgame_packet(ubyte *data, netgame_info *netgame); -//end change - -void send_sequence_packet(sequence_packet seq, ubyte *server, ubyte *node, ubyte *net_address); -void receive_sequence_packet(ubyte *data, sequence_packet *seq); -void send_netgame_packet(ubyte *server, ubyte *node); -void receive_netgame_packet(ubyte *data, netgame_info *netgame, int d1x); -void swap_object(object *obj); - -#ifdef WORDS_BIGENDIAN -void send_frameinfo_packet(frame_info *info, ubyte *server, ubyte *node, ubyte *net_address); -void receive_frameinfo_packet(ubyte *data, frame_info *info); -#else // !WORDS_BIGENDIAN -#define send_frameinfo_packet(info, server, node, net_address) \ - netdrv_send_packet_data((ubyte *)info, sizeof(frame_info) - NET_XDATA_SIZE + (info)->data_size, server, node, net_address) -#define receive_frameinfo_packet(data, info) \ - do { memcpy((ubyte *)(info), data, sizeof(frame_info) - NET_XDATA_SIZE); \ - memcpy((info)->data, &data[sizeof(frame_info) - NET_XDATA_SIZE], (info)->data_size); } while(0) -#endif // WORDS_BIGENDIAN - -#endif diff --git a/main/newdemo.c b/main/newdemo.c index fd44b3f50..e1a235438 100644 --- a/main/newdemo.c +++ b/main/newdemo.c @@ -58,7 +58,6 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "args.h" #include "palette.h" #include "multi.h" -#include "net_ipx.h" #include "text.h" #include "cntrlcen.h" #include "aistruct.h" diff --git a/main/powerup.c b/main/powerup.c index b4b10c836..edf255152 100644 --- a/main/powerup.c +++ b/main/powerup.c @@ -492,7 +492,7 @@ void pow_add_random(object *obj) { #ifndef NDEBUG #ifdef NETWORK if (!(Game_mode & GM_NETWORK) || - Netgame.protocol_version != MULTI_PROTO_D1X_VER) + Netgame.protocol.ipx.protocol_version != MULTI_PROTO_D1X_VER) return; #endif dump_pow_count("pow_add_random: now start level", powerup_start_level); @@ -507,7 +507,7 @@ void pow_add_level_pow_count(int *pow_count) { #ifndef NDEBUG #ifdef NETWORK if (!(Game_mode & GM_NETWORK) || - Netgame.protocol_version != MULTI_PROTO_D1X_VER) + Netgame.protocol.ipx.protocol_version != MULTI_PROTO_D1X_VER) return; #endif dump_pow_count("pow_add_level_pow_count: pow_count", pow_count); @@ -599,7 +599,7 @@ int may_create_powerup(int powerup) if (!(Game_mode & GM_NETWORK) #ifdef NETWORK - || Netgame.protocol_version != MULTI_PROTO_D1X_VER + || Netgame.protocol.ipx.protocol_version != MULTI_PROTO_D1X_VER #endif ) return -1; // say unknown if not in D1X network game diff --git a/main/state.c b/main/state.c index 451b61005..fcfde8487 100644 --- a/main/state.c +++ b/main/state.c @@ -60,9 +60,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "strutil.h" //end added #include "gamefont.h" -#ifdef NETWORK -#include "net_ipx.h" -#endif +#include "multi.h" #ifdef OGL #include "ogl_init.h" #endif diff --git a/main/switch.c b/main/switch.c index 2e5c6cf4b..e4dc57a84 100644 --- a/main/switch.c +++ b/main/switch.c @@ -41,7 +41,6 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "endlevel.h" #include "gameseq.h" #include "multi.h" -#include "net_ipx.h" #include "palette.h" trigger Triggers[MAX_TRIGGERS]; @@ -148,7 +147,7 @@ int check_trigger_sub(int trigger_num, int pnum) #endif #ifdef NETWORK if (Game_mode & GM_NETWORK) - network_do_frame(1, 1); + multi_do_protocol_frame(1, 1); #endif PlayerFinishedLevel(1); //1 means go to secret level return 1;