Update of /cvsroot/netrek/client/netrekxp/include In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv25812/include Modified Files: bitmaps.h data.h defs.h packets.h proto.h struct.h Log Message: This massive patch solves most of the issues that prevented the client from working on bronco and paradise servers simultaneously. The end goal is to remove all the #ifdef PARADISE defines and have a unified client. These patch notes will describe some of the obstacles, and what was done to work around them. Obstacles/Solutions: 1) One obstacle was the reliance on MAX* values in the client for things like MAXPLAYER, MAXTORP, and MAXPHASER. The solution was to copy the paradise client and define both a theoretical server maximum (i.e. MAXPLAYER) and then the actual value defined by the server (nplayers). Thus, many checks in the code were changed to use these new dynamic variables. MAXPLAYER is now 257 instead of 36. But the default value for nplayers is 36, and will only be changed if the client receives a paradise game parameters packet. So there is no impact on playing on bronco servers since the default value is always the same. Likewise, ntorps, nplasmas and nphasers are now dynamic, with the default values being the bronco defaults. 2) Another obstacle was conflicting defines for some server packets. Namely SP_GENERIC_32/SP_MOTD_PIC and SP_FLAGS_ALL/SP_STATS2. The solution was to treat these packets as having dynamic size, with the size being determined on whether the server is paradise or not. One complication was that a paradise server will send the client a SP_STATS2 packet before it even acknowledges the client is paradise comptable, thus corrupting the data stream! The solution is to treat all SP_FLAGS_ALL/SP_STATS2 packets as being SP_STATS2 if the login packet was not received yet (the login packet identifies whether the server is paradise or not). 3) Yet another obstacle was conflicting player flag states, namely PFOBSERV/PFWARP, and PFTWARP/PFSNAKE. The solution was to change all checks in the code involving observers and twarp and paradise warp to check if the server is paradise or not. 4) A minor obstacle was overlapping p_whydead states between bronco and paradise. Solved by a simple if (paradise) check. General Changes: 1) Most #ifdef PARADISE removed and replaced, where necessary, by if (paradise) checks. Some areas which required more work were the planet window, rank window, motd paging and layout, initializing and sorting the playerlist. 2) Load all paradise bitmaps upon startup. 3) Struct ship updated to include fields the server has been sending via ship cap packets but we have been ignoring. Will be necessary for future changes to how ship caps are handled. 4) Initialization of most data structs (players, torps, phasers, plasmas, teams) now moved into their own functions rather than all being done in openmem(). In paradise sometimes they need to be reinitialized, so this was necessary. 5) New funcion isMe() to check if a player X is me, or if I am an observer locked onto player X. 6) Metaserver now lists paradise servers. 7) Added afterburner/warpprep/impulse indicator to the plain text dashboard. 8) Added a bunch of safety checks for many of the packet types. 9) Added a bunch of the new packet types to the print_packet function. 10) Removed unused compute_extension1_size() 11) Added load_default_teams(). It sets up the classic bronco teams into a data structure called teaminfo. Index: bitmaps.h =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/include/bitmaps.h,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- bitmaps.h 12 Apr 2008 23:28:29 -0000 1.24 +++ bitmaps.h 16 Apr 2008 00:08:00 -0000 1.25 @@ -26,9 +26,7 @@ #define BMP_KLI_SHIP 3 #define BMP_ROM_SHIP 5 #define BMP_IND_SHIP 2 -#ifdef PARADISE #define BMP_PSHIP 6 -#endif // Weapons // ------- @@ -150,10 +148,8 @@ #define BMP_MPLANET_WIDTH 16 #define BMP_MPLANET_HEIGHT 16 -#ifdef PARADISE #define PARADISE_PLANET_VIEWS 13 #define PARADISE_MPLANET_VIEWS 13 -#endif #define PLANET_VIEWS 9 #define MPLANET_VIEWS 9 @@ -195,7 +191,6 @@ #define CPLANET_VIEWS 16 -#ifdef PARADISE #define BMP_DRONE 9 #define BMP_DRONEC 10 #define BMP_DRONE_WIDTH 6 @@ -231,4 +226,3 @@ #define BMP_MWORMHOLE_WIDTH 16 #define BMP_MWORMHOLE_HEIGHT 16 #define WORMHOLE_VIEWS 8 -#endif Index: defs.h =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/include/defs.h,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- defs.h 13 Apr 2008 13:50:19 -0000 1.31 +++ defs.h 16 Apr 2008 00:08:00 -0000 1.32 @@ -8,7 +8,7 @@ #include "copyright.h" -#ifdef PARADISE +/* Paradise stuff */ #define GRIDSIZE 33333 /* defs for updatePlayer [BDyess] */ @@ -25,7 +25,7 @@ #define GMAP_NEVER 0 #define GMAP_FREQUENT 1 #define GMAP_INFREQUENT 2 -#endif /* PARADISE */ +/* End paradise stuff */ /* Error handling */ #define RETURNBASE 10 @@ -37,11 +37,12 @@ #define MAX_MACRO 500 #endif -#ifdef PARADISE -#define MAXPLAYER 257 -#else -#define MAXPLAYER 36 -#endif +#define MAXPLAYER 257 /* Paradise can apparently go over 36 ... for + most purposes, the nplayers variable will be + used to track maximum players allowed by server. + This variable serves as a maximum possible value + for sizing arrays and structs. */ +//#define MAXPLAYER 36 #define TESTERS 4 /* Priveledged slots for * robots and game 'testers' */ @@ -49,6 +50,7 @@ #define MAXPLANETS 60 /* Maximum planets any server will send us. Bronco has 40, paradise can go up to 60 */ #define MAXTORP 8 +#define MAXPHASER 1 #define MAXPLASMA 1 #define PKEY 128 Index: packets.h =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/include/packets.h,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- packets.h 7 Jun 2007 04:43:37 -0000 1.11 +++ packets.h 16 Apr 2008 00:08:01 -0000 1.12 @@ -68,10 +68,8 @@ #define SP_RESERVED 25 /* for future use */ #define SP_PLANET_LOC 26 /* planet name, x, y */ -#ifdef PARADISE -#define SP_SCAN 27 /* ATM: results of player +#define SP_SCAN 27 /* paradise: results of player * scan */ -#endif #define SP_UDP_REPLY 28 /* notify client of UDP * status */ @@ -84,19 +82,16 @@ * verification */ #endif -#ifdef PARADISE -#define SP_MOTD_PIC 32 /* motd bitmap pictures */ -#define SP_STATS2 33 /* new stats packet */ -#define SP_STATUS2 34 /* new status packet */ -#define SP_PLANET2 35 /* new planet packet */ -#define SP_NEW_MOTD 36 /* New MOTD info notification uses */ -#define SP_THINGY 37 /* thingy location */ -#define SP_THINGY_INFO 38 /* thingy status */ -#else -#define SP_GENERIC_32 32 /* 32 byte generic, see struct */ -#define SP_FLAGS_ALL 33 /* abbreviated flags for all players */ -#endif - +// Note the conflicting defines for types 32 and 33 +#define SP_MOTD_PIC 32 /* paradise - motd bitmap pictures */ +#define SP_GENERIC_32 32 /* bronco - 32 byte generic, see struct */ +#define SP_STATS2 33 /* paradise - new stats packet */ +#define SP_FLAGS_ALL 33 /* bronco - abbreviated flags for all players */ +#define SP_STATUS2 34 /* paradise - new status packet */ +#define SP_PLANET2 35 /* paradise - new planet packet */ +#define SP_NEW_MOTD 36 /* paradise - New MOTD info notification uses */ +#define SP_THINGY 37 /* paradise - thingy location */ +#define SP_THINGY_INFO 38 /* paradise - thingy status */ #define SP_SHIP_CAP 39 /* Handles server ship mods */ #ifdef SHORT_PACKETS @@ -122,17 +117,15 @@ #define SP_S_8_TORP 49 /* optimized SP_S_TORP */ #define SP_S_PLANET 50 /* see SP_PLANET */ -#ifdef PARADISE -#define SP_GPARAM 51 /* game params packet */ +#define SP_GPARAM 51 /* paradise game params packet */ /* the following is a family of packets with the same type, but a discriminating subtype */ #define SP_PARADISE_EXT1 52 #define SP_PE1_MISSING_BITMAP 0 #define SP_PE1_NUM_MISSILES 1 /* end of packet 52 subtypes */ -#define SP_TERRAIN2 53 /* Terrain packets */ -#define SP_TERRAIN_INFO2 54 /* Terrain info */ -#endif +#define SP_TERRAIN2 53 /* paradise terrain packets */ +#define SP_TERRAIN_INFO2 54 /* paradise terrain info */ /* S_P2 */ #define SP_S_SEQUENCE 56 /* SP_SEQUENCE for @@ -199,11 +192,9 @@ * verification */ #endif -#ifdef PARADISE -/* the CP_ASK_MOTD packet is the same as temp_spacket */ -#define CP_ASK_MOTD 38 /* request MOTD */ -#endif -#define CP_PLANET 38 /* cross-check planet info */ +/* Note the conflicting defines for packet type 38*/ +#define CP_ASK_MOTD 38 /* paradise - request MOTD */ +#define CP_PLANET 38 /* bronco - cross-check planet info */ #define CP_PING_RESPONSE 42 /* client response */ @@ -905,7 +896,7 @@ unsigned short s_height; unsigned short s_maxarmies; char s_letter; - char pad2; + char s_armies; /* Paradise only */ char s_name[16]; char s_desig1; char s_desig2; @@ -1125,7 +1116,6 @@ #endif -#ifdef PARADISE /* Shapes of thingys. It would be best to add to the end of this list and try to coordinate your additions with other hackers. */ enum thingy_types { @@ -1447,4 +1437,4 @@ char galactic[32]; char galacticM[32]; }; -#endif + Index: struct.h =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/include/struct.h,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- struct.h 24 Feb 2008 00:33:55 -0000 1.24 +++ struct.h 16 Apr 2008 00:08:04 -0000 1.25 @@ -44,7 +44,6 @@ unsigned LONG timeprod; }; -#ifdef PARADISE struct thingy { int t_no; int t_shape; /* State information */ @@ -115,7 +114,6 @@ int page; }; -#endif enum dist_type { @@ -205,20 +203,15 @@ #define PFPRESS 0x800000 /* pressor beam activated */ #define PFDOCKOK 0x1000000 /* docking permission */ #define PFSEEN 0x2000000 /* seen by enemy on galactic map? */ -#ifdef PARADISE /* Note overlap with PFWARP/PFOBSERV and PFSNAKE/PFTWARP */ -#define PFWARPPREP (1<<26) /* in warp prep [BDyess] */ -#define PFWARP (1<<27) /* ship warping */ -#define PFAFTER (1<<28) /* after burners on */ -#define PFWPSUSPENDED (1<<29) /* warp prep suspended [BDyess] */ -#define PFSNAKE (1<<30) /* it's a space snake */ -#define PFBIRD (1<<31) /* it's a space bird */ -#define PFOBSERV (1<<31) /* set to something unused */ -#define PFTWARP (1<<31) /* set to something unused */ -#else +#define PFWARPPREP 0x4000000 /* in warp prep [BDyess] */ +#define PFWARP 0x8000000 /* ship warping */ #define PFOBSERV 0x8000000 /* for observers */ -#define PFTWARP 0x40000000 /* transwarping to base */ -#endif +#define PFAFTER 0x10000000 /* after burners on */ +#define PFWPSUSPENDED 0x20000000 /* warp prep suspended [BDyess] */ +#define PFSNAKE 0x40000000 /* it's a space snake */ +#define PFTWARP 0x40000000 /* transwarping to base */ +#define PFBIRD 0x80000000 /* it's a space bird */ #define KLOGIN 0x00 /* initial state */ #define KQUIT 0x01 /* Player quit */ @@ -236,28 +229,29 @@ #define KOVER 0x0d /* game over */ #define TOURNSTART 0x0e /* tournament game starting */ #define KBADBIN 0x0f /* bad binary */ -#ifdef PARADISE -#define KMISSILE 0x10 /* missile, note the overlap with KTORP2! */ -#define KASTEROID 0x11 /* asteroid, note the overlap with KSHIP2! */ -#else -#define KTORP2 0x10 /* killed by detted torps */ -#define KSHIP2 0x11 /* chain-reaction explosions */ -#endif +#define KTORP2 0x10 /* killed by detted torps, overloaded to paradise KMISSILE */ +#define KSHIP2 0x11 /* chain-reaction explosions, overloaded to paradise KASTEROID */ #define KPLASMA2 0x12 /* killed by zapped plasma */ -#ifdef PARADISE -#define NUM_TYPES 15 #define NUM_PSHIP_TYPES 7 #define PARADISE_SHIP_OFFSET 7 /* To make jumpship first entry in the paradise ship bitmap array */ +#ifdef PARADISE +#define NUM_TYPES 15 +#define ATT 6 +#define JUMPSHIP 7 +#define SGALAXY 8 /* Not sure where to put this .. */ +#else +#define NUM_TYPES 8 +#define SGALAXY 6 +#define ATT 7 +#define JUMPSHIP 8 +#endif #define SCOUT 0 #define DESTROYER 1 #define CRUISER 2 #define BATTLESHIP 3 #define ASSAULT 4 #define STARBASE 5 -#define ATT 6 -#define JUMPSHIP 7 -#define SGALAXY 8 /* Not sure where to put this .. */ #define FLAGSHIP 8 #define WARBASE 9 #define LIGHTCRUISER 10 @@ -265,17 +259,6 @@ #define UTILITY 12 #define PATROL 13 #define PUCK 14 -#else -#define NUM_TYPES 8 -#define SCOUT 0 -#define DESTROYER 1 -#define CRUISER 2 -#define BATTLESHIP 3 -#define ASSAULT 4 -#define STARBASE 5 -#define SGALAXY 6 -#define ATT 7 -#endif struct ship { @@ -293,6 +276,11 @@ int s_torpspeed; int s_phaserfuse; int s_repair; + char s_letter; + char s_armies; /* paradise - gets army carrying cap. from server */ + /* char s_name[16]; */ + char s_desig[2]; + short s_bitmap; }; struct stats @@ -326,7 +314,6 @@ int st_rank; /* Ranking of the player */ }; -#ifdef PARADISE struct stats2 { /* paradise stats */ int st_genocides; /* number of genocides participated in */ float st_tmaxkills; /* max kills ever */ @@ -355,7 +342,6 @@ int st_rank; /* Ranking of the player */ int st_royal; /* royaly, specialty, rank */ }; -#endif #define ST_MAPMODE 1 #define ST_NAMEMODE 2 @@ -420,11 +406,10 @@ short p_whydead; /* Tells you why you died */ short p_whodead; /* Tells you who killed you */ struct stats p_stats; /* player statistics */ -#ifdef PARADISE short p_ndrone; /* Number of drones .. why was this missing? */ short p_totmissiles; /* number of total missiles [Bill Dyess] */ struct stats2 p_stats2; /* Paradise stats */ -#endif + short p_genoplanets; /* planets taken since last * genocide */ short p_genoarmsbomb; /* armies bombed since last @@ -531,7 +516,6 @@ * are in a 'known' order. Ten planets per team, the first being the home * planet. */ -#ifdef PARADISE /* pl_flags is an int of 32 bits: @@ -575,10 +559,12 @@ #define PLREDRAW (1<<7) /* Player close for redraw */ -#define PLHOME (1<< 8) /* These 4 flags no longer are */ -#define PLCOUP (1<< 9) /* used in the server */ -#define PLCHEAP (1<<10) -#define PLCORE (1<<11) +#define PLHOME (1<< 8) /* home planet for a given + * team */ +#define PLCOUP (1<< 9) /* Coup has occured */ +#define PLCHEAP (1<<10) /* Planet was taken from + * undefended team */ +#define PLCORE (1<<11) /* A core world planet */ /* cosmic object types, bits 16 and 23, and 24 */ #define PLPLANET 0 /* object is a planet */ @@ -618,20 +604,6 @@ #define PLPARADISE (1<<22) /* Paradise server flag set to 1 for P server */ -#else -/* the lower bits represent the original owning team */ -#define PLREPAIR 0x010 -#define PLFUEL 0x020 -#define PLAGRI 0x040 -#define PLREDRAW 0x080 /* Player close for redraw */ -#define PLHOME 0x100 /* home planet for a given - * team */ -#define PLCOUP 0x200 /* Coup has occured */ -#define PLCHEAP 0x400 /* Planet was taken from - * undefended team */ -#define PLCORE 0x800 /* A core world planet */ - -#endif /* PARADISE */ struct planet { @@ -649,9 +621,7 @@ * support life */ int pl_couptime; /* Time before coup may take * place */ -#ifdef PARADISE int pl_timestamp; /* time the info was taken */ -#endif }; #define MVALID 0x01 @@ -760,7 +730,6 @@ char *name, *cname; }; -#ifdef PARADISE /* ratings struct */ struct ratings { float r_offrat; /* offense rating */ @@ -804,7 +773,6 @@ struct royalty { /* Paradise royalty ranks */ char *name; /* name of rank */ }; -#endif struct plupdate { Index: proto.h =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/include/proto.h,v retrieving revision 1.60 retrieving revision 1.61 diff -u -d -r1.60 -r1.61 --- proto.h 6 Apr 2008 22:41:43 -0000 1.60 +++ proto.h 16 Apr 2008 00:08:02 -0000 1.61 @@ -433,6 +433,7 @@ /******************************************************************************/ /*** local.c /******************************************************************************/ +int isMe (struct player *j); void initStars (void); static inline W_Icon planetBitmapC(register struct planet * p); static inline void planetResourcesC (register struct planet *p, int destwidth, @@ -825,9 +826,7 @@ struct list; void showValues (struct list *data); void newMotdLine (char *line); -#ifdef PARADISE void newMotdPic (int x, int y, int width, int height, char *bits, int page); -#endif void getResources (char *prog); void redrawTeam (W_Window win, int teamNo, @@ -1155,8 +1154,16 @@ void handleFlagsAll (struct flags_all_spacket *packet); struct rsa_key_spacket; void handleRSAKey (struct rsa_key_spacket *packet); -#ifdef PARADISE +void initialize_players (void); +void initialize_plasmas (void); +void initialize_torps (void); +void initialize_phasers (void); +// Paradise handlers void build_default_configuration (void); +void load_default_teams (void); +void initialize_thingies(void); +void handlePacket32 (unsigned char *sbuf); +void handlePacket33 (unsigned char *sbuf); void handleScan (struct scan_spacket *packet); void handleMotdPic (struct motd_pic_spacket * packet); void handleStats2 (struct stats_spacket2 * packet); @@ -1169,7 +1176,7 @@ void handleThingyInfo (struct thingy_info_spacket * packet); void handleExtension1 (struct paradiseext1_spacket * packet); void handleGameparams (struct gameparam_spacket * packet); -#endif +// end paradise handlers void sendUdpReq (int req); struct udp_reply_spacket; void handleUdpReply (struct udp_reply_spacket *packet); Index: data.h =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/include/data.h,v retrieving revision 1.96 retrieving revision 1.97 diff -u -d -r1.96 -r1.97 --- data.h 13 Apr 2008 02:48:54 -0000 1.96 +++ data.h 16 Apr 2008 00:08:00 -0000 1.97 @@ -37,11 +37,9 @@ extern struct torp *torps; extern struct plasmatorp *plasmatorps; extern struct status *status; -#ifdef PARADISE extern struct status2 *status2; extern struct thingy *thingies; extern struct t_unit *terrainInfo; -#endif extern struct ship *myship; extern struct stats *mystats; extern struct planet *planets; @@ -58,6 +56,10 @@ extern int GWINSIDE; extern int nplanets; +extern int nplayers; +extern int ntorps; +extern int nplasmas; +extern int nphasers; extern int gwidth; extern unsigned int oldalert; extern unsigned char oldtourn; @@ -282,7 +284,6 @@ extern double Sin[], Cos[]; -#ifdef PARADISE extern int paradise; extern int received_terrain_info; extern int terrain_x; @@ -290,13 +291,9 @@ extern int gwidth_zoom; /* galaxy width, adjusted for zoom, unused */ extern int offsetx; extern int offsety; /* offsets when zooming [BDyess] */ -extern int nplayers; extern int nshiptypes; -extern int ntorps; extern int npthingies; extern int ngthingies; -extern int nplasmas; -extern int nphasers; extern struct teaminfo_s *teaminfo; extern int number_of_teams; /* MOTD data */ @@ -304,7 +301,6 @@ extern struct page *pmotddata; extern char blk_refitstring[80]; extern int blk_friendlycloak; -#endif extern W_Icon fedteam, romteam, kliteam, oriteam; extern W_Icon stipple, clockpic, clockhandpic, genopic, genopic2; @@ -351,7 +347,6 @@ extern W_Icon tractbits, pressbits; //Paradise bitmaps -#ifdef PARADISE extern W_Icon drone_bitmap; extern W_Icon base_dronec_bitmap; extern W_Icon dronec_bitmap[NUM_CTORP_TYPES]; @@ -379,7 +374,6 @@ extern W_Icon paradise_cships_self[NUM_PSHIP_TYPES][NUMTEAMS]; extern W_Icon paradise_cship_bitmaps; extern W_Icon paradise_cships[NUM_PSHIP_TYPES][NUMTEAMS]; -#endif //Ships extern W_Icon ship_bitmaps[5]; @@ -431,12 +425,10 @@ extern W_Icon base_mplanets; extern W_Icon bplanets[PLANET_VIEWS]; extern W_Icon bmplanets[MPLANET_VIEWS]; -#ifdef PARADISE extern W_Icon paradise_base_planets; extern W_Icon paradise_base_mplanets; extern W_Icon paradise_bplanets[PARADISE_PLANET_VIEWS]; extern W_Icon paradise_bmplanets[PARADISE_PLANET_VIEWS]; -#endif extern W_Color borderColor, backColor, textColor, myColor, warningColor, shipCol[5], rColor, yColor, gColor, unColor, foreColor; extern char *colornames[COLORS]; @@ -452,12 +444,10 @@ extern char login[PSEUDOSIZE]; extern struct rank ranks[NUMRANKS]; -#ifdef PARADISE extern struct rank2 *ranks2; extern struct royalty *royal; extern int nranks2; extern int nroyals; -#endif extern W_Window messagew, w, mapw, statwin, baseWin, infow, tstatw, war, warnw, helpWin, teamWin[4], qwin, messwa, messwt, messwi,