From c654ad8fd9a1d14d1b21503eb197a2caf0e7cb12 Mon Sep 17 00:00:00 2001 From: Bradley Bell Date: Fri, 30 Aug 2002 08:02:25 +0000 Subject: [PATCH] networking works, finally --- NEWS | 2 +- arch/linux/Makefile.am | 8 +- arch/linux/include/ukali.h | 11 +- main/multi.h | 288 ++++++++++++++++++------------------- 4 files changed, 143 insertions(+), 166 deletions(-) diff --git a/NEWS b/NEWS index 5cecf773c..3d5b54acf 100644 --- a/NEWS +++ b/NEWS @@ -6,7 +6,7 @@ - Shareware data files support... Including the ability to play other missions if you have only the mac demo datafiles. - Descent 1 level support! thanks to Martin Schaffner -- Networking fuck-up fixed? +- Networking fuck-up fixed! --- Version 0.1.3 --- - deb and rpm support added diff --git a/arch/linux/Makefile.am b/arch/linux/Makefile.am index 578fd5685..fdb3437bc 100644 --- a/arch/linux/Makefile.am +++ b/arch/linux/Makefile.am @@ -4,7 +4,6 @@ noinst_LIBRARIES = libarch_linux.a INCLUDES = -I$(top_srcdir)/arch/include -I$(top_srcdir)/include -I$(top_srcdir)/main -I$(srcdir)/include - if USE_NETWORK NETWORK_SRCS = ipx_bsd.c ipx_kali.c ipx_lin.c ipx_udp.c linuxnet.c endif @@ -12,8 +11,9 @@ endif libarch_linux_a_SOURCES = ${NETWORK_SRCS} findfile.c init.c EXTRA_libarch_linux_a_SOURCES = \ -ipx_bsd.c ipx_kali.c ipx_lin.c joydefs.c joystick.c linuxnet.c ukali.c \ -arch_ip.cpp +ipx_bsd.c ipx_kali.c ipx_lin.c ipx_udp.c linuxnet.c EXTRA_DIST = ${EXTRA_SUBDIRS} \ -alsadigi.c hmistub.c hmiplay.c ipx_udp.c mono.c serial.c timer.c +alsadigi.c hmistub.c hmiplay.c mono.c serial.c timer.c \ +ukali.c \ +joydefs.c joystick.c diff --git a/arch/linux/include/ukali.h b/arch/linux/include/ukali.h index e132e187f..26d73ad45 100644 --- a/arch/linux/include/ukali.h +++ b/arch/linux/include/ukali.h @@ -1,16 +1,7 @@ /* - * $Source: /cvs/cvsroot/d2x/arch/linux/include/ukali.h,v $ - * $Revision: 1.3 $ - * $Author: bradleyb $ - * $Date: 2001-10-19 07:39:26 $ * * FIXME: add description * - * $Log: not supported by cvs2svn $ - * Revision 1.2 2001/10/19 07:29:37 bradleyb - * Brought linux networking in line with d1x, moved some arch/linux_* stuff to arch/linux/ - * - * */ #ifndef __UKALI_H__ @@ -65,7 +56,7 @@ typedef struct kaliaddr_ipx_tag { // Process name that shows up in /whois and /games list. // Maximum of 8 characters. //edited on 10/04/98 by Matt Mueller to show correct ver in kali -#define KALI_PROCESS_NAME "D2X" VERSION +#define KALI_PROCESS_NAME "D1X" D1XMAJOR D1XMINOR //end edit -MM #define MAX_PACKET_SIZE 1500 diff --git a/main/multi.h b/main/multi.h index d16ad49f9..a9ee02cb8 100644 --- a/main/multi.h +++ b/main/multi.h @@ -1,3 +1,4 @@ +/* $Id: multi.h,v 1.6 2002-08-30 08:02:25 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -7,29 +8,14 @@ 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. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* - * $Source: /cvs/cvsroot/d2x/main/multi.h,v $ - * $Revision: 1.5 $ - * $Author: bradleyb $ - * $Date: 2002-07-16 08:14:35 $ * * FIXME: put description here * - * $Log: not supported by cvs2svn $ - * Revision 1.4 2002/02/14 09:24:19 bradleyb - * d1x->d2x - * - * Revision 1.3 2002/02/13 10:39:21 bradleyb - * Lotsa networking stuff from d1x - * - * Revision 1.2 2001/10/25 02:15:56 bradleyb - * conditionalize including multi.h and network.h, fix backslashes - * - * */ #ifndef _MULTI_H @@ -44,9 +30,9 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. // What version of the multiplayer protocol is this? #ifdef SHAREWARE -#define MULTI_PROTO_VERSION 3 +#define MULTI_PROTO_VERSION 3 #else -#define MULTI_PROTO_VERSION 4 +#define MULTI_PROTO_VERSION 4 #endif // Protocol versions: @@ -61,80 +47,80 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. // How many simultaneous network players do we support? -#define MAX_NUM_NET_PLAYERS 8 +#define MAX_NUM_NET_PLAYERS 8 -#define MULTI_POSITION 0 -#define MULTI_REAPPEAR 1 -#define MULTI_FIRE 2 -#define MULTI_KILL 3 -#define MULTI_REMOVE_OBJECT 4 -#define MULTI_PLAYER_EXPLODE 5 -#define MULTI_MESSAGE 6 -#define MULTI_QUIT 7 -#define MULTI_PLAY_SOUND 8 -#define MULTI_BEGIN_SYNC 9 -#define MULTI_CONTROLCEN 10 -#define MULTI_ROBOT_CLAIM 11 -#define MULTI_END_SYNC 12 -#define MULTI_CLOAK 13 -#define MULTI_ENDLEVEL_START 14 -#define MULTI_DOOR_OPEN 15 -#define MULTI_CREATE_EXPLOSION 16 -#define MULTI_CONTROLCEN_FIRE 17 -#define MULTI_PLAYER_DROP 18 -#define MULTI_CREATE_POWERUP 19 -#define MULTI_CONSISTENCY 20 -#define MULTI_DECLOAK 21 -#define MULTI_MENU_CHOICE 22 -#define MULTI_ROBOT_POSITION 23 -#define MULTI_ROBOT_EXPLODE 24 -#define MULTI_ROBOT_RELEASE 25 -#define MULTI_ROBOT_FIRE 26 -#define MULTI_SCORE 27 -#define MULTI_CREATE_ROBOT 28 -#define MULTI_TRIGGER 29 -#define MULTI_BOSS_ACTIONS 30 -#define MULTI_CREATE_ROBOT_POWERUPS 31 -#define MULTI_HOSTAGE_DOOR 32 +#define MULTI_POSITION 0 +#define MULTI_REAPPEAR 1 +#define MULTI_FIRE 2 +#define MULTI_KILL 3 +#define MULTI_REMOVE_OBJECT 4 +#define MULTI_PLAYER_EXPLODE 5 +#define MULTI_MESSAGE 6 +#define MULTI_QUIT 7 +#define MULTI_PLAY_SOUND 8 +#define MULTI_BEGIN_SYNC 9 +#define MULTI_CONTROLCEN 10 +#define MULTI_ROBOT_CLAIM 11 +#define MULTI_END_SYNC 12 +#define MULTI_CLOAK 13 +#define MULTI_ENDLEVEL_START 14 +#define MULTI_DOOR_OPEN 15 +#define MULTI_CREATE_EXPLOSION 16 +#define MULTI_CONTROLCEN_FIRE 17 +#define MULTI_PLAYER_DROP 18 +#define MULTI_CREATE_POWERUP 19 +#define MULTI_CONSISTENCY 20 +#define MULTI_DECLOAK 21 +#define MULTI_MENU_CHOICE 22 +#define MULTI_ROBOT_POSITION 23 +#define MULTI_ROBOT_EXPLODE 24 +#define MULTI_ROBOT_RELEASE 25 +#define MULTI_ROBOT_FIRE 26 +#define MULTI_SCORE 27 +#define MULTI_CREATE_ROBOT 28 +#define MULTI_TRIGGER 29 +#define MULTI_BOSS_ACTIONS 30 +#define MULTI_CREATE_ROBOT_POWERUPS 31 +#define MULTI_HOSTAGE_DOOR 32 -#define MULTI_SAVE_GAME 33 -#define MULTI_RESTORE_GAME 34 +#define MULTI_SAVE_GAME 33 +#define MULTI_RESTORE_GAME 34 -#define MULTI_REQ_PLAYER 35 // Someone requests my player structure -#define MULTI_SEND_PLAYER 36 // Sending someone my player structure -#define MULTI_MARKER 37 -#define MULTI_DROP_WEAPON 38 -#define MULTI_GUIDED 39 -#define MULTI_STOLEN_ITEMS 40 -#define MULTI_WALL_STATUS 41 // send to new players -#define MULTI_HEARTBEAT 42 -#define MULTI_KILLGOALS 43 -#define MULTI_SEISMIC 44 -#define MULTI_LIGHT 45 -#define MULTI_START_TRIGGER 46 -#define MULTI_FLAGS 47 -#define MULTI_DROP_BLOB 48 -#define MULTI_POWERUP_UPDATE 49 -#define MULTI_ACTIVE_DOOR 50 -#define MULTI_SOUND_FUNCTION 51 -#define MULTI_CAPTURE_BONUS 52 -#define MULTI_GOT_FLAG 53 -#define MULTI_DROP_FLAG 54 -#define MULTI_ROBOT_CONTROLS 55 -#define MULTI_FINISH_GAME 56 -#define MULTI_RANK 57 -#define MULTI_MODEM_PING 58 -#define MULTI_MODEM_PING_RETURN 59 -#define MULTI_ORB_BONUS 60 -#define MULTI_GOT_ORB 61 -#define MULTI_DROP_ORB 62 -#define MULTI_PLAY_BY_PLAY 63 +#define MULTI_REQ_PLAYER 35 // Someone requests my player structure +#define MULTI_SEND_PLAYER 36 // Sending someone my player structure +#define MULTI_MARKER 37 +#define MULTI_DROP_WEAPON 38 +#define MULTI_GUIDED 39 +#define MULTI_STOLEN_ITEMS 40 +#define MULTI_WALL_STATUS 41 // send to new players +#define MULTI_HEARTBEAT 42 +#define MULTI_KILLGOALS 43 +#define MULTI_SEISMIC 44 +#define MULTI_LIGHT 45 +#define MULTI_START_TRIGGER 46 +#define MULTI_FLAGS 47 +#define MULTI_DROP_BLOB 48 +#define MULTI_POWERUP_UPDATE 49 +#define MULTI_ACTIVE_DOOR 50 +#define MULTI_SOUND_FUNCTION 51 +#define MULTI_CAPTURE_BONUS 52 +#define MULTI_GOT_FLAG 53 +#define MULTI_DROP_FLAG 54 +#define MULTI_ROBOT_CONTROLS 55 +#define MULTI_FINISH_GAME 56 +#define MULTI_RANK 57 +#define MULTI_MODEM_PING 58 +#define MULTI_MODEM_PING_RETURN 59 +#define MULTI_ORB_BONUS 60 +#define MULTI_GOT_ORB 61 +#define MULTI_DROP_ORB 62 +#define MULTI_PLAY_BY_PLAY 63 -#define MULTI_MAX_TYPE 63 +#define MULTI_MAX_TYPE 63 -#define MAX_NET_CREATE_OBJECTS 40 +#define MAX_NET_CREATE_OBJECTS 40 -#define MAX_MULTI_MESSAGE_LEN 120 +#define MAX_MULTI_MESSAGE_LEN 120 // Exported functions @@ -182,7 +168,7 @@ int multi_endlevel(int *secret); int multi_menu_poll(void); void multi_leave_game(void); void multi_process_data(char *dat, int len); -void multi_process_bigdata(char *buf, int len); +void multi_process_bigdata(char *buf, int len); void multi_do_death(int objnum); void multi_send_message_dialog(void); int multi_delete_extra_objects(void); @@ -231,7 +217,7 @@ extern fix Show_kill_list_timer; // Used to send network messages -extern char Network_message[MAX_MESSAGE_LEN]; +extern char Network_message[MAX_MESSAGE_LEN]; extern char Network_message_macro[4][MAX_MESSAGE_LEN]; extern int Network_message_reciever; @@ -261,15 +247,15 @@ extern int control_invul_time; extern bitmap_index multi_player_textures[MAX_NUM_NET_PLAYERS][N_PLAYER_SHIP_TEXTURES]; -#define NETGAME_FLAG_CLOSED 1 -#define NETGAME_FLAG_SHOW_ID 2 -#define NETGAME_FLAG_SHOW_MAP 4 -#define NETGAME_FLAG_HOARD 8 -#define NETGAME_FLAG_TEAM_HOARD 16 -#define NETGAME_FLAG_REALLY_ENDLEVEL 32 -#define NETGAME_FLAG_REALLY_FORMING 64 +#define NETGAME_FLAG_CLOSED 1 +#define NETGAME_FLAG_SHOW_ID 2 +#define NETGAME_FLAG_SHOW_MAP 4 +#define NETGAME_FLAG_HOARD 8 +#define NETGAME_FLAG_TEAM_HOARD 16 +#define NETGAME_FLAG_REALLY_ENDLEVEL 32 +#define NETGAME_FLAG_REALLY_FORMING 64 -#define NETGAME_NAME_LEN 15 +#define NETGAME_NAME_LEN 15 enum comp_type {DOS,WIN_32,WIN_95,MAC}; @@ -279,56 +265,56 @@ enum comp_type {DOS,WIN_32,WIN_95,MAC}; // members. typedef struct netplayer_info { - char callsign[CALLSIGN_LEN+1]; + char callsign[CALLSIGN_LEN+1]; union { struct { - ubyte server[4]; - ubyte node[6]; + ubyte server[4]; + ubyte node[6]; } ipx; struct { - ushort net; - ubyte node; - ubyte socket; + ushort net; + ubyte node; + ubyte socket; } appletalk; } network; - ubyte version_major; - ubyte version_minor; + ubyte version_major; + ubyte version_minor; enum comp_type computer_type; - byte connected; + byte connected; - ushort socket; + ushort socket; - ubyte rank; + ubyte rank; } netplayer_info; typedef struct AllNetPlayers_info - { - char type; - int Security; - struct netplayer_info players[MAX_PLAYERS+4]; - } AllNetPlayers_info; +{ + char type; + int Security; + struct netplayer_info players[MAX_PLAYERS+4]; +} AllNetPlayers_info; typedef struct netgame_info { - ubyte type; - int Security; - char game_name[NETGAME_NAME_LEN+1]; - char mission_title[MISSION_NAME_LEN+1]; - char mission_name[9]; - int levelnum; - ubyte gamemode; - ubyte RefusePlayers; - ubyte difficulty; - ubyte game_status; - ubyte numplayers; - ubyte max_numplayers; - ubyte numconnected; - ubyte game_flags; - ubyte protocol_version; - ubyte version_major; - ubyte version_minor; - ubyte team_vector; + ubyte type; + int Security; + char game_name[NETGAME_NAME_LEN+1]; + char mission_title[MISSION_NAME_LEN+1]; + char mission_name[9]; + int levelnum; + ubyte gamemode; + ubyte RefusePlayers; + ubyte difficulty; + ubyte game_status; + ubyte numplayers; + ubyte max_numplayers; + ubyte numconnected; + ubyte game_flags; + ubyte protocol_version; + ubyte version_major; + ubyte version_minor; + ubyte team_vector; // change the order of the bit fields for the mac compiler. // doing so will mean I don't have to do screwy things to @@ -356,7 +342,7 @@ typedef struct netgame_info { short DoEarthShaker:1; short DoMercury:1; short Allow_marker_view:1; - short AlwaysLighting:1; + short AlwaysLighting:1; short DoAmmoRack:1; short DoConverter:1; short DoHeadlight:1; @@ -394,7 +380,7 @@ typedef struct netgame_info { short DoHeadlight:1; short DoConverter:1; short DoAmmoRack:1; - short AlwaysLighting:1; + short AlwaysLighting:1; short Allow_marker_view:1; short DoMercury:1; short DoEarthShaker:1; @@ -402,24 +388,24 @@ typedef struct netgame_info { short DoFlash:1; #endif - 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; - fix PlayTimeAllowed; - fix level_time; - int control_invul_time; - int monitor_vector; - int player_score[MAX_PLAYERS]; - ubyte player_flags[MAX_PLAYERS]; - short PacketsPerSec; - ubyte ShortPackets; + 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; + fix PlayTimeAllowed; + fix level_time; + int control_invul_time; + int monitor_vector; + int player_score[MAX_PLAYERS]; + ubyte player_flags[MAX_PLAYERS]; + short PacketsPerSec; + ubyte ShortPackets; -} __pack__ netgame_info; +} netgame_info; extern struct netgame_info Netgame; extern struct AllNetPlayers_info NetPlayers; @@ -428,8 +414,8 @@ int network_i_am_master(void); void change_playernum_to(int new_pnum); //how to encode missiles & flares in weapon packets -#define MISSILE_ADJUST 100 -#define FLARE_ADJUST 127 +#define MISSILE_ADJUST 100 +#define FLARE_ADJUST 127 #endif