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

This commit is contained in:
zicodxx 2009-03-20 12:10:38 +00:00
parent 0fc0fff7f1
commit 0c36fecb42
25 changed files with 851 additions and 1746 deletions

View file

@ -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

View file

@ -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',

View file

@ -16,7 +16,7 @@
#include <netinet/in.h>
#include <unistd.h>
#include <errno.h>
#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,

View file

@ -2,7 +2,7 @@
#include <stdio.h>
#include <string.h>
#include <netinet/in.h> /* 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,

View file

@ -4,7 +4,7 @@
#include <stdlib.h>
#include <winsock.h>
#include <wsipx.h>
#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,

View file

@ -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[];

View file

@ -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"

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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();

View file

@ -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 <stdlib.h>
#include <stdio.h>
#include <string.h>
@ -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;
}

View file

@ -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)

View file

@ -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)

View file

@ -21,6 +21,36 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#ifndef _MULTI_H
#define _MULTI_H
#ifdef NETWORK
#ifdef _WIN32
#include <winsock.h>
#include <io.h>
#else
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <sys/time.h>
#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

View file

@ -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" };

View file

@ -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

File diff suppressed because it is too large Load diff

View file

@ -25,21 +25,6 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#include "multi.h"
#include "newmenu.h"
#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
#define MAX_ACTIVE_NETGAMES 12
typedef struct sequence_packet {
@ -86,21 +71,42 @@ typedef struct frame_info {
} __pack__ frame_info;
#endif
// short_frame_info is not aligned -- 01/18/96 -- MWA
// won't align because of shortpos. Shortpos needs
// to stay in current form.
typedef struct IPX_netplayer_info {
char callsign[CALLSIGN_LEN+1];
ubyte server[4];
ubyte node[6];
ushort socket;
sbyte connected;
} __pack__ IPX_netplayer_info;
typedef struct short_frame_info {
ubyte type; // What type of packet
ubyte pad[3]; // Pad out length of frame_info packet
int numpackets;
shortpos thepos;
ushort data_size; // Size of data appended to the net packet
ubyte playernum;
ubyte obj_render_type;
ubyte level_num;
char data[NET_XDATA_SIZE]; // extra data to be tacked on the end
} __pack__ short_frame_info;
typedef struct IPX_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;
IPX_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];
} __pack__ IPX_netgame_info;
void network_start_game();
void network_join_game();
@ -120,17 +126,11 @@ int network_whois_master();
extern int Network_send_objects;
extern int Network_send_objnum;
extern int PacketUrgent;
extern int Network_rejoined;
extern int Network_new_game;
extern int Network_status;
extern int restrict_mode;
extern fix LastPacketTime[MAX_PLAYERS];
extern ushort my_segments_checksum;
//extern int Network_allow_socket_changes;
//added on 8/4/98 by Matt Mueller for global short packets declaration
@ -176,7 +176,7 @@ extern int IPX_Socket;
void network_send_objects(void);
void network_dump_player(ubyte * server, ubyte *node, int why);
void network_send_game_info(sequence_packet *their, int light);
void network_send_game_info(sequence_packet *their);
//end this section change - VR
#ifdef SHAREWARE
@ -203,19 +203,8 @@ void network_send_game_info(sequence_packet *their, int light);
#define PID_GAME_INFO 37
#endif
#define PID_D1X_GAME_INFO_REQ 65
#define PID_D1X_GAME_INFO 66
#define PID_D1X_GAME_LITE_REQ 67
#define PID_D1X_GAME_LITE 68
#define PID_D1X_SYNC 69
#define PID_D1X_REQUEST 71
//added 03/04/99 Matt Mueller - send multi data, without extra baggage
#define PID_DIRECTDATA 72
//end addition -MM
#define PID_PING_SEND 73
#define PID_PING_RETURN 74
#define PID_PDATA_NOLOSS 75 // Same as PID_PDATA, but client should ACK it!
#define PID_PDATA_ACK 76 // ACK message for PID_PDATA_NOLOSS packet
#define NETGAME_ANARCHY 0
#define NETGAME_TEAM_ANARCHY 1

View file

@ -1,786 +0,0 @@
/*
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
*/
// Network packet conversions
// Based on macnet.c from MAC version of Descent 1
#ifdef NETWORK
#include <string.h>
#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;i<MAX_SUBMODELS;i++) {
obj->rtype.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

View file

@ -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

View file

@ -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"

View file

@ -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

View file

@ -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

View file

@ -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;