Update of /cvsroot/netrek/client/netrekxp/src In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv31222/src Modified Files: cowmain.c data.c defaults.c enter.c getname.c getship.c helpwin.c input.c newwin.c option.c playback.c socket.c Log Message: First pass at creating a dynamic rather than static shiplist. Struct shiplist is a linked list of ships that contains all the ship info (fuel, hull, etc). This shiplist is updated by shipcap packet. Replaced old static shipvals struct. Struct ship now has entries for keymaps and buttonmaps - this info has been moved out of the stats struct. This eliminates the need for struct shipdef, which was just a static struct that held ship name and keymap/buttonmap strings. Much of the keymap/buttonmap handling had to be redone, as well as initialization of ships and keymaps. Still some bugs to work out, keymaps are not working right. Going to remove the invidivual rcfile for each ship - this feature isn't very useful, as you can already define ship specific keymaps and buttonmaps in a single rc file. This patch removed the last ifdef PARADISE so that config value is now set to defined for posterity purposes, but it doesn't do anything. Index: getship.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/getship.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- getship.c 16 Apr 2008 00:08:13 -0000 1.6 +++ getship.c 18 Apr 2008 03:42:37 -0000 1.7 @@ -21,325 +21,408 @@ #include "data.h" #include "proto.h" -/* fill in ship characteristics */ - void -getshipdefaults () +initialize_shiptypes () { - shipvals[SCOUT].s_phaserdamage = 75; /* scout: was 75 */ - shipvals[SCOUT].s_torpspeed = 16; /* scout: was 16 */ - shipvals[SCOUT].s_maxspeed = 12; /* scout: */ - shipvals[SCOUT].s_maxfuel = 5000; /* scout: */ - shipvals[SCOUT].s_maxarmies = 2; /* scout: */ - shipvals[SCOUT].s_maxshield = 75; /* scout: was 75 */ - shipvals[SCOUT].s_maxdamage = 75; /* scout: */ - shipvals[SCOUT].s_maxwpntemp = 1000; /* scout: */ - shipvals[SCOUT].s_maxegntemp = 1000; /* scout: */ - shipvals[SCOUT].s_type = SCOUT; /* scout: */ - shipvals[SCOUT].s_width = 20; /* scout: */ - shipvals[SCOUT].s_height = 20; /* scout: */ - shipvals[SCOUT].s_phaserfuse = 10; /* scout: */ - shipvals[SCOUT].s_repair = 80; /* scout: */ - shipvals[SCOUT].s_letter = 's'; - shipvals[SCOUT].s_desig[0] = 'S'; - shipvals[SCOUT].s_desig[1] = 'C'; - shipvals[SCOUT].s_bitmap = SCOUT; - - shipvals[DESTROYER].s_phaserdamage = 85; /* destroyer: */ - shipvals[DESTROYER].s_torpspeed = 14; /* destroyer: */ - shipvals[DESTROYER].s_maxspeed = 10; /* destroyer: */ - shipvals[DESTROYER].s_maxfuel = 7000; /* destroyer: */ - shipvals[DESTROYER].s_maxarmies = 5; /* destroyer: */ - shipvals[DESTROYER].s_maxshield = 85; /* destroyer: */ - shipvals[DESTROYER].s_maxdamage = 85; /* destroyer: */ - shipvals[DESTROYER].s_maxwpntemp = 1000; /* destroyer: */ - shipvals[DESTROYER].s_maxegntemp = 1000; /* destroyer: */ - shipvals[DESTROYER].s_width = 20; /* destroyer: */ - shipvals[DESTROYER].s_height = 20; /* destroyer: */ - shipvals[DESTROYER].s_type = DESTROYER; /* destroyer: */ - shipvals[DESTROYER].s_phaserfuse = 10; /* destroyer: */ - shipvals[DESTROYER].s_repair = 100; /* destroyer: */ - shipvals[DESTROYER].s_letter = 'd'; - shipvals[DESTROYER].s_desig[0] = 'D'; - shipvals[DESTROYER].s_desig[1] = 'D'; - shipvals[DESTROYER].s_bitmap = DESTROYER; - - shipvals[BATTLESHIP].s_phaserdamage = 105; /* battleship: */ - shipvals[BATTLESHIP].s_torpspeed = 12; /* battleship: */ - shipvals[BATTLESHIP].s_maxspeed = 8; /* battleship: */ - shipvals[BATTLESHIP].s_maxfuel = 14000; /* battleship: */ - shipvals[BATTLESHIP].s_maxarmies = 6; /* battleship: */ - shipvals[BATTLESHIP].s_maxshield = 130; /* battleship: */ - shipvals[BATTLESHIP].s_maxdamage = 130; /* battleship: */ - shipvals[BATTLESHIP].s_maxwpntemp = 1000; /* battleship: */ - shipvals[BATTLESHIP].s_maxegntemp = 1000; /* battleship: */ - shipvals[BATTLESHIP].s_width = 20; /* battleship: */ - shipvals[BATTLESHIP].s_height = 20; /* battleship: */ - shipvals[BATTLESHIP].s_type = BATTLESHIP; /* battleship: */ - shipvals[BATTLESHIP].s_phaserfuse = 10; /* battleship: */ - shipvals[BATTLESHIP].s_repair = 125; /* battleship: */ - shipvals[BATTLESHIP].s_letter = 'b'; - shipvals[BATTLESHIP].s_desig[0] = 'B'; - shipvals[BATTLESHIP].s_desig[1] = 'B'; - shipvals[BATTLESHIP].s_bitmap = BATTLESHIP; - - shipvals[ASSAULT].s_phaserdamage = 80; /* assault */ - shipvals[ASSAULT].s_torpspeed = 16; /* assault */ - shipvals[ASSAULT].s_maxspeed = 8; /* assault */ - shipvals[ASSAULT].s_maxfuel = 6000; /* assault */ - shipvals[ASSAULT].s_maxarmies = 20; /* assault */ - shipvals[ASSAULT].s_maxshield = 80; /* assault */ - shipvals[ASSAULT].s_maxdamage = 200; /* assault */ - shipvals[ASSAULT].s_maxwpntemp = 1000; /* assault */ - shipvals[ASSAULT].s_maxegntemp = 1200; /* assault */ - shipvals[ASSAULT].s_width = 20; /* assault */ - shipvals[ASSAULT].s_height = 20; /* assault */ - shipvals[ASSAULT].s_type = ASSAULT; /* assault */ - shipvals[ASSAULT].s_phaserfuse = 10; /* assault */ - shipvals[ASSAULT].s_repair = 120; /* assault */ - shipvals[ASSAULT].s_letter = 'a'; - shipvals[ASSAULT].s_desig[0] = 'A'; - shipvals[ASSAULT].s_desig[1] = 'S'; - shipvals[ASSAULT].s_bitmap = ASSAULT; - - shipvals[STARBASE].s_phaserdamage = 120; /* starbase */ - shipvals[STARBASE].s_torpspeed = 14; /* starbase */ - shipvals[STARBASE].s_maxfuel = 60000; /* starbase */ - shipvals[STARBASE].s_maxarmies = 25; /* starbase */ - shipvals[STARBASE].s_maxshield = 500; /* starbase */ - shipvals[STARBASE].s_maxdamage = 600; /* starbase */ - shipvals[STARBASE].s_maxspeed = 2; /* starbase */ - shipvals[STARBASE].s_maxwpntemp = 1300; /* starbase */ - shipvals[STARBASE].s_maxegntemp = 1000; /* starbase */ - shipvals[STARBASE].s_width = 20; /* starbase */ - shipvals[STARBASE].s_height = 20; /* starbase */ - shipvals[STARBASE].s_type = STARBASE; /* starbase */ - shipvals[STARBASE].s_phaserfuse = 4; /* starbase */ - shipvals[STARBASE].s_repair = 140; /* starbase */ - shipvals[STARBASE].s_letter = 'o'; - shipvals[STARBASE].s_desig[0] = 'S'; - shipvals[STARBASE].s_desig[1] = 'B'; - shipvals[STARBASE].s_bitmap = STARBASE; - - shipvals[ATT].s_phaserdamage = 10000; /* att: */ - shipvals[ATT].s_torpspeed = 30; /* att: */ - shipvals[ATT].s_maxspeed = 60; /* att: */ - shipvals[ATT].s_maxfuel = 60000; /* att: */ - shipvals[ATT].s_maxarmies = 1000; /* att: */ - shipvals[ATT].s_maxshield = 30000; /* att: */ - shipvals[ATT].s_maxdamage = 30000; /* att: */ - shipvals[ATT].s_maxwpntemp = 10000; /* att: */ - shipvals[ATT].s_maxegntemp = 10000; /* att: */ - shipvals[ATT].s_width = 20; /* att: */ - shipvals[ATT].s_height = 20; /* att: */ - shipvals[ATT].s_type = ATT; /* att: */ - shipvals[ATT].s_phaserfuse = 2; /* att: */ - shipvals[ATT].s_repair = 30000; /* att: */ - shipvals[ATT].s_letter = 'X'; - shipvals[ATT].s_desig[0] = 'A'; - shipvals[ATT].s_desig[1] = 'T'; - shipvals[ATT].s_bitmap = ATT; - - shipvals[SGALAXY].s_phaserdamage = 100; /* galaxy: */ - shipvals[SGALAXY].s_torpspeed = 13; /* galaxy: */ - shipvals[SGALAXY].s_maxspeed = 9; /* galaxy: */ - shipvals[SGALAXY].s_maxfuel = 12000; /* galaxy: */ - shipvals[SGALAXY].s_maxarmies = 5; /* galaxy: */ - shipvals[SGALAXY].s_maxshield = 140; /* galaxy: */ - shipvals[SGALAXY].s_maxdamage = 120; /* galaxy: */ - shipvals[SGALAXY].s_maxwpntemp = 1000; /* galaxy: */ - shipvals[SGALAXY].s_maxegntemp = 1000; /* galaxy: */ - shipvals[SGALAXY].s_width = 20; /* galaxy: */ - shipvals[SGALAXY].s_height = 20; /* galaxy: */ - shipvals[SGALAXY].s_type = SGALAXY; /* galaxy: */ - shipvals[SGALAXY].s_phaserfuse = 10; /* galaxy: */ - shipvals[SGALAXY].s_repair = 112; /* galaxy: */ - shipvals[SGALAXY].s_letter = 'g'; - shipvals[SGALAXY].s_desig[0] = 'G'; - shipvals[SGALAXY].s_desig[1] = 'A'; - shipvals[SGALAXY].s_bitmap = SGALAXY; - - shipvals[CRUISER].s_phaserdamage = 100; /* cruiser: */ - shipvals[CRUISER].s_torpspeed = 12; /* cruiser: */ - shipvals[CRUISER].s_maxspeed = 9; /* cruiser: */ - shipvals[CRUISER].s_maxfuel = 10000; /* cruiser: */ - shipvals[CRUISER].s_maxarmies = 10; /* cruiser: */ - shipvals[CRUISER].s_maxshield = 100; /* cruiser: */ - shipvals[CRUISER].s_maxdamage = 100; /* cruiser: */ - shipvals[CRUISER].s_maxwpntemp = 1000; /* cruiser: */ - shipvals[CRUISER].s_maxegntemp = 1000; /* cruiser: */ - shipvals[CRUISER].s_width = 20; /* cruiser: */ - shipvals[CRUISER].s_height = 20; /* cruiser: */ - shipvals[CRUISER].s_type = CRUISER; /* cruiser: */ - shipvals[CRUISER].s_phaserfuse = 10; /* cruiser: */ - shipvals[CRUISER].s_repair = 110; /* cruiser: */ - shipvals[CRUISER].s_letter = 'c'; - shipvals[CRUISER].s_desig[0] = 'C'; - shipvals[CRUISER].s_desig[1] = 'A'; - shipvals[CRUISER].s_bitmap = CRUISER; - -#ifdef PARADISE - shipvals[JUMPSHIP].s_phaserdamage = 25; - shipvals[JUMPSHIP].s_torpspeed = 18; - shipvals[JUMPSHIP].s_maxspeed = 20; - shipvals[JUMPSHIP].s_maxfuel = 50000; - shipvals[JUMPSHIP].s_maxarmies = 0; - shipvals[JUMPSHIP].s_maxshield = 5; - shipvals[JUMPSHIP].s_maxdamage = 60; - shipvals[JUMPSHIP].s_maxwpntemp = 1300; - shipvals[JUMPSHIP].s_maxegntemp = 5000; - shipvals[JUMPSHIP].s_type = JUMPSHIP; - shipvals[JUMPSHIP].s_width = 20; - shipvals[JUMPSHIP].s_height = 20; - shipvals[JUMPSHIP].s_phaserfuse = 4; - shipvals[JUMPSHIP].s_repair = 200; - shipvals[JUMPSHIP].s_letter = 'j'; - shipvals[JUMPSHIP].s_desig[0] = 'J'; - shipvals[JUMPSHIP].s_desig[1] = 'S'; - shipvals[JUMPSHIP].s_bitmap = JUMPSHIP; - - shipvals[FLAGSHIP].s_phaserdamage = 102; - shipvals[FLAGSHIP].s_torpspeed = 12; - shipvals[FLAGSHIP].s_maxspeed = 9; - shipvals[FLAGSHIP].s_maxfuel = 12500; - shipvals[FLAGSHIP].s_maxarmies = 6; - shipvals[FLAGSHIP].s_maxshield = 115; - shipvals[FLAGSHIP].s_maxdamage = 115; - shipvals[FLAGSHIP].s_maxwpntemp = 1000; - shipvals[FLAGSHIP].s_maxegntemp = 1500; - shipvals[FLAGSHIP].s_type = FLAGSHIP; - shipvals[FLAGSHIP].s_width = 20; - shipvals[FLAGSHIP].s_height = 20; - shipvals[FLAGSHIP].s_phaserfuse = 10; - shipvals[FLAGSHIP].s_repair = 118; - shipvals[FLAGSHIP].s_letter = 'f'; - shipvals[FLAGSHIP].s_desig[0] = 'F'; - shipvals[FLAGSHIP].s_desig[1] = 'L'; - shipvals[FLAGSHIP].s_bitmap = FLAGSHIP; - - shipvals[WARBASE].s_phaserdamage = 125; - shipvals[WARBASE].s_torpspeed = 15; - shipvals[WARBASE].s_maxspeed = 3; - shipvals[WARBASE].s_maxfuel = 50000; - shipvals[WARBASE].s_maxarmies = 0; - shipvals[WARBASE].s_maxshield = 250; - shipvals[WARBASE].s_maxdamage = 500; - shipvals[WARBASE].s_maxwpntemp = 1500; - shipvals[WARBASE].s_maxegntemp = 1000; - shipvals[WARBASE].s_type = WARBASE; - shipvals[WARBASE].s_width = 20; - shipvals[WARBASE].s_height = 20; - shipvals[WARBASE].s_phaserfuse = 5; - shipvals[WARBASE].s_repair = 170; - shipvals[WARBASE].s_letter = 'w'; - shipvals[WARBASE].s_desig[0] = 'W'; - shipvals[WARBASE].s_desig[1] = 'B'; - shipvals[WARBASE].s_bitmap = WARBASE; - - shipvals[LIGHTCRUISER].s_phaserdamage = 90; - shipvals[LIGHTCRUISER].s_torpspeed = 13; - shipvals[LIGHTCRUISER].s_maxspeed = 10; - shipvals[LIGHTCRUISER].s_maxfuel = 8500; - shipvals[LIGHTCRUISER].s_maxarmies = 3; - shipvals[LIGHTCRUISER].s_maxshield = 95; - shipvals[LIGHTCRUISER].s_maxdamage = 90; - shipvals[LIGHTCRUISER].s_maxwpntemp = 1000; - shipvals[LIGHTCRUISER].s_maxegntemp = 1500; - shipvals[LIGHTCRUISER].s_type = LIGHTCRUISER; - shipvals[LIGHTCRUISER].s_width = 20; - shipvals[LIGHTCRUISER].s_height = 20; - shipvals[LIGHTCRUISER].s_phaserfuse = 10; - shipvals[LIGHTCRUISER].s_repair = 80; - shipvals[LIGHTCRUISER].s_letter = 'l'; - shipvals[LIGHTCRUISER].s_desig[0] = 'C'; - shipvals[LIGHTCRUISER].s_desig[1] = 'L'; - shipvals[LIGHTCRUISER].s_bitmap = LIGHTCRUISER; + int i; + struct shiplist *temp; - shipvals[CARRIER].s_phaserdamage = 95; - shipvals[CARRIER].s_torpspeed = 13; - shipvals[CARRIER].s_maxspeed = 9; - shipvals[CARRIER].s_maxfuel = 15000; - shipvals[CARRIER].s_maxarmies = 3; - shipvals[CARRIER].s_maxshield = 120; - shipvals[CARRIER].s_maxdamage = 150; - shipvals[CARRIER].s_maxwpntemp = 1000; - shipvals[CARRIER].s_maxegntemp = 1500; - shipvals[CARRIER].s_type = CARRIER; - shipvals[CARRIER].s_width = 20; - shipvals[CARRIER].s_height = 20; - shipvals[CARRIER].s_phaserfuse = 6; - shipvals[CARRIER].s_repair = 105; - shipvals[CARRIER].s_letter = 'v'; - shipvals[CARRIER].s_desig[0] = 'C'; - shipvals[CARRIER].s_desig[1] = 'V'; - shipvals[CARRIER].s_bitmap = CARRIER; + /* start at -1, the default shiptype */ + for (i = -1; i < nshiptypes; i++) { + temp = (struct shiplist *) malloc(sizeof(struct shiplist)); + temp->ship = (struct ship *) malloc(sizeof(struct ship)); + getshipdefaults(temp->ship, i); + temp->next = shiptypes; + if (temp->next) + temp->next->prev = temp; + temp->prev = NULL; + shiptypes = temp; + } +} - shipvals[UTILITY].s_phaserdamage = 80; - shipvals[UTILITY].s_torpspeed = 15; - shipvals[UTILITY].s_maxspeed = 7; - shipvals[UTILITY].s_maxfuel = 16000; - shipvals[UTILITY].s_maxarmies = 12; - shipvals[UTILITY].s_maxshield = 120; - shipvals[UTILITY].s_maxdamage = 220; - shipvals[UTILITY].s_maxwpntemp = 1000; - shipvals[UTILITY].s_maxegntemp = 1800; - shipvals[UTILITY].s_type = UTILITY; - shipvals[UTILITY].s_width = 20; - shipvals[UTILITY].s_height = 20; - shipvals[UTILITY].s_phaserfuse = 8; - shipvals[UTILITY].s_repair = 120; - shipvals[UTILITY].s_letter = 'u'; - shipvals[UTILITY].s_desig[0] = 'U'; - shipvals[UTILITY].s_desig[1] = 'T'; - shipvals[UTILITY].s_bitmap = UTILITY; +/* now returns a pointer to where the ship data is located. This way + if the data is later changed by the server everybody gets updated. + Plus as a bonus it's more efficient :) [Bill Dyess] */ +struct ship * +getship(int s_type) +{ + struct shiplist *temp, *new; - shipvals[PATROL].s_phaserdamage = 50; - shipvals[PATROL].s_torpspeed = 15; - shipvals[PATROL].s_maxspeed = 13; - shipvals[PATROL].s_maxfuel = 4000; - shipvals[PATROL].s_maxarmies = 1; - shipvals[PATROL].s_maxshield = 50; - shipvals[PATROL].s_maxdamage = 40; - shipvals[PATROL].s_maxwpntemp = 1000; - shipvals[PATROL].s_maxegntemp = 1500; - shipvals[PATROL].s_type = PATROL; - shipvals[PATROL].s_width = 20; - shipvals[PATROL].s_height = 20; - shipvals[PATROL].s_phaserfuse = 8; - shipvals[PATROL].s_repair = 50; - shipvals[PATROL].s_letter = 'p'; - shipvals[PATROL].s_desig[0] = 'P'; - shipvals[PATROL].s_desig[1] = 'T'; - shipvals[PATROL].s_bitmap = PATROL; + temp = shiptypes; + while (temp) { + if (temp->ship->s_type == s_type) { + return temp->ship; + } + temp = temp->next; + } + /* + ok, that shiptype is unheard of. Assume a new shiptype, and get the + values for CA. Also add the ship to the list so if it gets updated by + the server later everyone stays happy. [Bill Dyess] + */ + printf("Error: getship of unknown ship type %d, using CA defaults\n", s_type); + temp = shiptypes; + while (temp) { + if (temp->ship->s_type == DEFAULT) { + printf("Adding ship type %d\n", s_type); + /* now add the new ship to the list */ + new = (struct shiplist *) malloc(sizeof(struct shiplist)); + new->ship = (struct ship *) malloc(sizeof(struct ship)); + new->next = shiptypes; + new->prev = NULL; + if (shiptypes) + shiptypes->prev = new; + shiptypes = new; + memmove(new->ship, temp->ship, sizeof(struct ship)); + new->ship->s_type = s_type; + return new->ship; + } + temp = temp->next; + } + return temp->ship; - shipvals[PUCK].s_phaserdamage = 75; - shipvals[PUCK].s_torpspeed = 16; - shipvals[PUCK].s_maxspeed = 12; - shipvals[PUCK].s_maxfuel = 5000; - shipvals[PUCK].s_maxarmies = 2; - shipvals[PUCK].s_maxshield = 75; - shipvals[PUCK].s_maxdamage = 75; - shipvals[PUCK].s_maxwpntemp = 1000; - shipvals[PUCK].s_maxegntemp = 1000; - shipvals[PUCK].s_type = PUCK; - shipvals[PUCK].s_width = 20; - shipvals[PUCK].s_height = 20; - shipvals[PUCK].s_phaserfuse = 10; - shipvals[PUCK].s_repair = 80; - shipvals[PUCK].s_letter = 'k'; - shipvals[PUCK].s_desig[0] = 'P'; - shipvals[PUCK].s_desig[1] = 'U'; - shipvals[PUCK].s_bitmap = PUCK; -#endif } -/******************************************************************************/ -/*** getship() ***/ -/******************************************************************************/ +/* fill in ship characteristics */ void -getship (struct ship *shipp, - int s_type) +getshipdefaults (struct ship *shipp, int s_type) { - memcpy ((char *) shipp, (char *) &(shipvals[s_type]), - sizeof (struct ship)); + switch (s_type) { + case SCOUT: + case PUCK: + shipp->s_phaserdamage = 75; /* scout: was 75 */ + shipp->s_torpspeed = 16; /* scout: was 16 */ + shipp->s_maxspeed = 12; /* scout: */ + shipp->s_maxfuel = 5000; /* scout: */ + shipp->s_maxarmies = 2; /* scout: */ + shipp->s_maxshield = 75; /* scout: was 75 */ + shipp->s_maxdamage = 75; /* scout: */ + shipp->s_maxwpntemp = 1000; /* scout: */ + shipp->s_maxegntemp = 1000; /* scout: */ + shipp->s_type = SCOUT; /* scout: */ + shipp->s_width = 20; /* scout: */ + shipp->s_height = 20; /* scout: */ + shipp->s_phaserfuse = 10; /* scout: */ + shipp->s_repair = 80; /* scout: */ + if(s_type == PUCK) { + shipp->s_type = PUCK; + shipp->s_letter = 'k'; + shipp->s_desig[0] = 'P'; + shipp->s_desig[1] = 'U'; + shipp->s_bitmap = PUCK; + } else { + shipp->s_type = SCOUT; + shipp->s_letter = 's'; + shipp->s_desig[0] = 'S'; + shipp->s_desig[1] = 'C'; + shipp->s_bitmap = SCOUT; + } + break; + case DESTROYER: + shipp->s_phaserdamage = 85; /* destroyer: */ + shipp->s_torpspeed = 14; /* destroyer: */ + shipp->s_maxspeed = 10; /* destroyer: */ + shipp->s_maxfuel = 7000; /* destroyer: */ + shipp->s_maxarmies = 5; /* destroyer: */ + shipp->s_maxshield = 85; /* destroyer: */ + shipp->s_maxdamage = 85; /* destroyer: */ + shipp->s_maxwpntemp = 1000; /* destroyer: */ + shipp->s_maxegntemp = 1000; /* destroyer: */ + shipp->s_width = 20; /* destroyer: */ + shipp->s_height = 20; /* destroyer: */ + shipp->s_type = DESTROYER; /* destroyer: */ + shipp->s_phaserfuse = 10; /* destroyer: */ + shipp->s_repair = 100; /* destroyer: */ + shipp->s_letter = 'd'; + shipp->s_desig[0] = 'D'; + shipp->s_desig[1] = 'D'; + shipp->s_bitmap = DESTROYER; + break; + default: + case DEFAULT: + case CRUISER: + shipp->s_phaserdamage = 100; /* cruiser: */ + shipp->s_torpspeed = 12; /* cruiser: */ + shipp->s_maxspeed = 9; /* cruiser: */ + shipp->s_maxfuel = 10000; /* cruiser: */ + shipp->s_maxarmies = 10; /* cruiser: */ + shipp->s_maxshield = 100; /* cruiser: */ + shipp->s_maxdamage = 100; /* cruiser: */ + shipp->s_maxwpntemp = 1000; /* cruiser: */ + shipp->s_maxegntemp = 1000; /* cruiser: */ + shipp->s_width = 20; /* cruiser: */ + shipp->s_height = 20; /* cruiser: */ + shipp->s_type = s_type; /* cruiser OR default */ + shipp->s_phaserfuse = 10; /* cruiser: */ + shipp->s_repair = 110; /* cruiser: */ + shipp->s_letter = 'c'; + shipp->s_desig[0] = 'C'; + shipp->s_desig[1] = 'A'; + shipp->s_bitmap = CRUISER; + break; + case BATTLESHIP: + shipp->s_phaserdamage = 105; /* battleship: */ + shipp->s_torpspeed = 12; /* battleship: */ + shipp->s_maxspeed = 8; /* battleship: */ + shipp->s_maxfuel = 14000; /* battleship: */ + shipp->s_maxarmies = 6; /* battleship: */ + shipp->s_maxshield = 130; /* battleship: */ + shipp->s_maxdamage = 130; /* battleship: */ + shipp->s_maxwpntemp = 1000; /* battleship: */ + shipp->s_maxegntemp = 1000; /* battleship: */ + shipp->s_width = 20; /* battleship: */ + shipp->s_height = 20; /* battleship: */ + shipp->s_type = BATTLESHIP; /* battleship: */ + shipp->s_phaserfuse = 10; /* battleship: */ + shipp->s_repair = 125; /* battleship: */ + shipp->s_letter = 'b'; + shipp->s_desig[0] = 'B'; + shipp->s_desig[1] = 'B'; + shipp->s_bitmap = BATTLESHIP; + break; + case ASSAULT: + shipp->s_phaserdamage = 80; /* assault */ + shipp->s_torpspeed = 16; /* assault */ + shipp->s_maxspeed = 8; /* assault */ + shipp->s_maxfuel = 6000; /* assault */ + shipp->s_maxarmies = 20; /* assault */ + shipp->s_maxshield = 80; /* assault */ + shipp->s_maxdamage = 200; /* assault */ + shipp->s_maxwpntemp = 1000; /* assault */ + shipp->s_maxegntemp = 1200; /* assault */ + shipp->s_width = 20; /* assault */ + shipp->s_height = 20; /* assault */ + shipp->s_type = ASSAULT; /* assault */ + shipp->s_phaserfuse = 10; /* assault */ + shipp->s_repair = 120; /* assault */ + shipp->s_letter = 'a'; + shipp->s_desig[0] = 'A'; + shipp->s_desig[1] = 'S'; + shipp->s_bitmap = ASSAULT; + break; + case STARBASE: + shipp->s_phaserdamage = 120; /* starbase */ + shipp->s_torpspeed = 14; /* starbase */ + shipp->s_maxfuel = 60000; /* starbase */ + shipp->s_maxarmies = 25; /* starbase */ + shipp->s_maxshield = 500; /* starbase */ + shipp->s_maxdamage = 600; /* starbase */ + shipp->s_maxspeed = 2; /* starbase */ + shipp->s_maxwpntemp = 1300; /* starbase */ + shipp->s_maxegntemp = 1000; /* starbase */ + shipp->s_width = 20; /* starbase */ + shipp->s_height = 20; /* starbase */ + shipp->s_type = STARBASE; /* starbase */ + shipp->s_phaserfuse = 4; /* starbase */ + shipp->s_repair = 140; /* starbase */ + shipp->s_letter = 'o'; + shipp->s_desig[0] = 'S'; + shipp->s_desig[1] = 'B'; + shipp->s_bitmap = STARBASE; + break; + case ATT: /* or GALAXY */ + if (paradise) { + shipp->s_phaserdamage = 10000; /* att: */ + shipp->s_torpspeed = 30; /* att: */ + shipp->s_maxspeed = 60; /* att: */ + shipp->s_maxfuel = 60000; /* att: */ + shipp->s_maxarmies = 1000; /* att: */ + shipp->s_maxshield = 30000; /* att: */ + shipp->s_maxdamage = 30000; /* att: */ + shipp->s_maxwpntemp = 10000; /* att: */ + shipp->s_maxegntemp = 10000; /* att: */ + shipp->s_width = 20; /* att: */ + shipp->s_height = 20; /* att: */ + shipp->s_type = ATT; /* att: */ + shipp->s_phaserfuse = 2; /* att: */ + shipp->s_repair = 30000; /* att: */ + shipp->s_letter = 'X'; + shipp->s_desig[0] = 'A'; + shipp->s_desig[1] = 'T'; + shipp->s_bitmap = ATT; + } + else { + shipp->s_phaserdamage = 100; /* galaxy: */ + shipp->s_torpspeed = 13; /* galaxy: */ + shipp->s_maxspeed = 9; /* galaxy: */ + shipp->s_maxfuel = 12000; /* galaxy: */ + shipp->s_maxarmies = 5; /* galaxy: */ + shipp->s_maxshield = 140; /* galaxy: */ + shipp->s_maxdamage = 120; /* galaxy: */ + shipp->s_maxwpntemp = 1000; /* galaxy: */ + shipp->s_maxegntemp = 1000; /* galaxy: */ + shipp->s_width = 20; /* galaxy: */ + shipp->s_height = 20; /* galaxy: */ + shipp->s_type = SGALAXY; /* galaxy: */ + shipp->s_phaserfuse = 10; /* galaxy: */ + shipp->s_repair = 112; /* galaxy: */ + shipp->s_letter = 'g'; + shipp->s_desig[0] = 'G'; + shipp->s_desig[1] = 'A'; + shipp->s_bitmap = SGALAXY; + } + break; + case JUMPSHIP: /* or ATT */ + if (paradise) { + shipp->s_phaserdamage = 25; + shipp->s_torpspeed = 18; + shipp->s_maxspeed = 20; + shipp->s_maxfuel = 50000; + shipp->s_maxarmies = 0; + shipp->s_maxshield = 5; + shipp->s_maxdamage = 60; + shipp->s_maxwpntemp = 1300; + shipp->s_maxegntemp = 5000; + shipp->s_type = JUMPSHIP; + shipp->s_width = 20; + shipp->s_height = 20; + shipp->s_phaserfuse = 4; + shipp->s_repair = 200; + shipp->s_letter = 'j'; + shipp->s_desig[0] = 'J'; + shipp->s_desig[1] = 'S'; + shipp->s_bitmap = JUMPSHIP; + } + else { + shipp->s_phaserdamage = 10000; /* att: */ + shipp->s_torpspeed = 30; /* att: */ + shipp->s_maxspeed = 60; /* att: */ + shipp->s_maxfuel = 60000; /* att: */ + shipp->s_maxarmies = 1000; /* att: */ + shipp->s_maxshield = 30000; /* att: */ + shipp->s_maxdamage = 30000; /* att: */ + shipp->s_maxwpntemp = 10000; /* att: */ + shipp->s_maxegntemp = 10000; /* att: */ + shipp->s_width = 20; /* att: */ + shipp->s_height = 20; /* att: */ + shipp->s_type = ATT; /* att: */ + shipp->s_phaserfuse = 2; /* att: */ + shipp->s_repair = 30000; /* att: */ + shipp->s_letter = 'X'; + shipp->s_desig[0] = 'A'; + shipp->s_desig[1] = 'T'; + shipp->s_bitmap = ATT; + } + break; + case FLAGSHIP: + shipp->s_phaserdamage = 102; + shipp->s_torpspeed = 12; + shipp->s_maxspeed = 9; + shipp->s_maxfuel = 12500; + shipp->s_maxarmies = 6; + shipp->s_maxshield = 115; + shipp->s_maxdamage = 115; + shipp->s_maxwpntemp = 1000; + shipp->s_maxegntemp = 1500; + shipp->s_type = FLAGSHIP; + shipp->s_width = 20; + shipp->s_height = 20; + shipp->s_phaserfuse = 10; + shipp->s_repair = 118; + shipp->s_letter = 'f'; + shipp->s_desig[0] = 'F'; + shipp->s_desig[1] = 'L'; + shipp->s_bitmap = FLAGSHIP; + break; + case WARBASE: + shipp->s_phaserdamage = 125; + shipp->s_torpspeed = 15; + shipp->s_maxspeed = 3; + shipp->s_maxfuel = 50000; + shipp->s_maxarmies = 0; + shipp->s_maxshield = 250; + shipp->s_maxdamage = 500; + shipp->s_maxwpntemp = 1500; + shipp->s_maxegntemp = 1000; + shipp->s_type = WARBASE; + shipp->s_width = 20; + shipp->s_height = 20; + shipp->s_phaserfuse = 5; + shipp->s_repair = 170; + shipp->s_letter = 'w'; + shipp->s_desig[0] = 'W'; + shipp->s_desig[1] = 'B'; + shipp->s_bitmap = WARBASE; + break; + case LIGHTCRUISER: + shipp->s_phaserdamage = 90; + shipp->s_torpspeed = 13; + shipp->s_maxspeed = 10; + shipp->s_maxfuel = 8500; + shipp->s_maxarmies = 3; + shipp->s_maxshield = 95; + shipp->s_maxdamage = 90; + shipp->s_maxwpntemp = 1000; + shipp->s_maxegntemp = 1500; + shipp->s_type = LIGHTCRUISER; + shipp->s_width = 20; + shipp->s_height = 20; + shipp->s_phaserfuse = 10; + shipp->s_repair = 80; + shipp->s_letter = 'l'; + shipp->s_desig[0] = 'C'; + shipp->s_desig[1] = 'L'; + shipp->s_bitmap = LIGHTCRUISER; + break; + case CARRIER: + shipp->s_phaserdamage = 95; + shipp->s_torpspeed = 13; + shipp->s_maxspeed = 9; + shipp->s_maxfuel = 15000; + shipp->s_maxarmies = 3; + shipp->s_maxshield = 120; + shipp->s_maxdamage = 150; + shipp->s_maxwpntemp = 1000; + shipp->s_maxegntemp = 1500; + shipp->s_type = CARRIER; + shipp->s_width = 20; + shipp->s_height = 20; + shipp->s_phaserfuse = 6; + shipp->s_repair = 105; + shipp->s_letter = 'v'; + shipp->s_desig[0] = 'C'; + shipp->s_desig[1] = 'V'; + shipp->s_bitmap = CARRIER; + break; + case UTILITY: + shipp->s_phaserdamage = 80; + shipp->s_torpspeed = 15; + shipp->s_maxspeed = 7; + shipp->s_maxfuel = 16000; + shipp->s_maxarmies = 12; + shipp->s_maxshield = 120; + shipp->s_maxdamage = 220; + shipp->s_maxwpntemp = 1000; + shipp->s_maxegntemp = 1800; + shipp->s_type = UTILITY; + shipp->s_width = 20; + shipp->s_height = 20; + shipp->s_phaserfuse = 8; + shipp->s_repair = 120; + shipp->s_letter = 'u'; + shipp->s_desig[0] = 'U'; + shipp->s_desig[1] = 'T'; + shipp->s_bitmap = UTILITY; + break; + case PATROL: + shipp->s_phaserdamage = 50; + shipp->s_torpspeed = 15; + shipp->s_maxspeed = 13; + shipp->s_maxfuel = 4000; + shipp->s_maxarmies = 1; + shipp->s_maxshield = 50; + shipp->s_maxdamage = 40; + shipp->s_maxwpntemp = 1000; + shipp->s_maxegntemp = 1500; + shipp->s_type = PATROL; + shipp->s_width = 20; + shipp->s_height = 20; + shipp->s_phaserfuse = 8; + shipp->s_repair = 50; + shipp->s_letter = 'p'; + shipp->s_desig[0] = 'P'; + shipp->s_desig[1] = 'T'; + shipp->s_bitmap = PATROL; + break; + } } Index: newwin.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/newwin.c,v retrieving revision 1.73 retrieving revision 1.74 diff -u -d -r1.73 -r1.74 --- newwin.c 16 Apr 2008 02:57:09 -0000 1.73 +++ newwin.c 18 Apr 2008 03:42:37 -0000 1.74 @@ -916,7 +916,7 @@ { if (messageKeyOnly && messageon == 0) { - if (mystats->st_keymap[(event->key)-32] != 109) /* Not a message key (Key109)*/ + if (myship->s_keymap[(event->key)-32] != 109) /* Not a message key (Key109)*/ return; else /* It is a message key, allow them to start a message */ Key109(); @@ -1585,6 +1585,7 @@ entrywindow (int *team, int *s_type) { + struct shiplist *shipscan; int typeok = 0, i = 0; time_t startTime; W_Event event; @@ -1747,79 +1748,21 @@ if (!W_EventsPending ()) continue; W_NextEvent (&event); - typeok = 1; + typeok = 0; switch ((int) event.type) { case W_EV_KEY: - switch (event.key) + shipscan = shiptypes; + while (shipscan) { + if (shipscan->ship->s_letter == event.key) { + *s_type = shipscan->ship->s_type; + typeok = 1; + break; + } + shipscan = shipscan->next; + } + if (event.key == ' ') { - case 's': - *s_type = SCOUT; - break; - case 'd': - *s_type = DESTROYER; - break; - case 'c': - *s_type = CRUISER; - break; - case 'b': - *s_type = BATTLESHIP; - break; - case 'g': - *s_type = SGALAXY; - break; - case '*': - *s_type = ATT; - break; - case 'a': - *s_type = ASSAULT; - break; - case 'o': - *s_type = STARBASE; - break; - case 'j': - if (paradise) - *s_type = JUMPSHIP; - else - typeok = 0; - break; - case 'f': - if (paradise) - *s_type = FLAGSHIP; - else - typeok = 0; - break; - case 'w': - if (paradise) - *s_type = WARBASE; - else - typeok = 0; - break; - case 'l': - if (paradise) - *s_type = LIGHTCRUISER; - else - typeok = 0; - break; - case 'v': - if (paradise) - *s_type = CARRIER; - else - typeok = 0; - break; - case 'u': - if (paradise) - *s_type = UTILITY; - else - typeok = 0; - break; - case 'p': - if (paradise) - *s_type = PATROL; - else - typeok = 0; - break; - case ' ': switch (me->p_team) { case FED: @@ -1838,9 +1781,6 @@ break; } break; - default: - typeok = 0; - break; } if (event.Window == w) { Index: input.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/input.c,v retrieving revision 1.44 retrieving revision 1.45 diff -u -d -r1.44 -r1.45 --- input.c 16 Apr 2008 00:08:16 -0000 1.44 +++ input.c 18 Apr 2008 03:42:37 -0000 1.45 @@ -440,32 +440,18 @@ return (unsigned char) (c - 96); } - -/* Defined in defaults.c */ -extern struct shipdef *myshipdef; - /******************************************************************************/ -/*** initkeymap() ***/ +/*** initkeymap() - sets up default keymaps and buttonmaps, then builds the + ship specific versions ***/ /******************************************************************************/ void initkeymap (void) { + int j; unsigned char *str; - /* in the future let me strongly recommed we move keymap * completely - * outside of the stats structure. - jn */ - - if ((str = myshipdef->keymap) != NULL) - { - while (*str != '\0' && *(str + 1) != '\0') - { - if (*str >= 32 && *str < 128) - { - mystats->st_keymap[*str - 32] = *(str + 1); - } - str += 2; - } - } + if ((str = (unsigned char *) stringDefault ("keymap")) != NULL) + keymapAdd(str, default_keymap); /* See if we can get macroKey to work. What a hack -SAC */ if ((str = (unsigned char *) stringDefault ("macroKey")) != NULL) @@ -476,36 +462,22 @@ { /* This is a little pointless, but it'll preform as per * the documentation */ - mystats->st_keymap[*str - 32] = 'X'; + default_keymap[*str - 32] = 'X'; } else if (!strcmpi (str, "TAB")) { p = "^i"; - mystats->st_keymap[getctrlkey (&p) - 32] = 'X'; + default_keymap[getctrlkey (&p) - 32] = 'X'; } else if (!strcmpi (str, "ESC")) { p = "^["; - mystats->st_keymap[getctrlkey (&p) - 32] = 'X'; + default_keymap[getctrlkey (&p) - 32] = 'X'; } } - if ((str = myshipdef->ckeymap) != NULL) - { - unsigned char c1, c2; - - while (*str != '\0') - { - - if (*str >= 32 && *str < MAXASCII) - { - c1 = (unsigned char) (getctrlkey (&str) - 32); - c2 = getctrlkey (&str); - mystats->st_keymap[c1] = c2; - } - - } - } + if ((str = (unsigned char *) stringDefault ("ckeymap")) != NULL) + ckeymapAdd(str, default_keymap); #ifdef MOUSE_AS_SHIFT if ((str = (unsigned char *) stringDefault ("b1keymap")) != NULL) @@ -515,7 +487,7 @@ { if (*str >= 32 && *str < 176) { - mystats->st_keymap[*str - 32 + 192] = *(str + 1); + default_keymap[*str - 32 + 192] = *(str + 1); } str += 2; } @@ -528,7 +500,7 @@ { if (*str >= 32 && *str < 176) { - mystats->st_keymap[*str - 32 + 288] = *(str + 1); + default_keymap[*str - 32 + 288] = *(str + 1); } str += 2; } @@ -541,7 +513,7 @@ { if (*str >= 32 && *str < 176) { - mystats->st_keymap[*str - 32 + 384] = *(str + 1); + default_keymap[*str - 32 + 384] = *(str + 1); } str += 2; } @@ -554,7 +526,7 @@ { if (*str >= 32 && *str < 176) { - mystats->st_keymap[*str - 32 + 480] = *(str + 1); + default_keymap[*str - 32 + 480] = *(str + 1); } str += 2; } @@ -567,7 +539,7 @@ { if (*str >= 32 && *str < 176) { - mystats->st_keymap[*str - 32 + 576] = *(str + 1); + default_keymap[*str - 32 + 576] = *(str + 1); } str += 2; } @@ -576,93 +548,160 @@ #endif /* note: not stored on server */ - if ((str = myshipdef->buttonmap) != NULL) + if ((str = (unsigned char *) stringDefault ("buttonmap")) != NULL) + buttonmapAdd(str, default_buttonmap); + + /* Build ship specific keymaps */ + for (j = 0; j < nshiptypes; j++) + buildShipKeymap(getship(j)); +} + +void +keymapAdd(char *str, char *kmap) +{ + while (*str != '\0' && *(str + 1) != '\0') { - while (*str != '\0' && *(str + 1) != '\0') + if (*str >= 32 && *str < 128) + { + kmap[*str - 32] = *(str + 1); + } + str += 2; + } +} + +void +ckeymapAdd(char *cstr, char *kmap) +{ + unsigned char c1, c2; + + while (*cstr != '\0') + { + if (*cstr >= 32 && *cstr < MAXASCII) + { + c1 = (unsigned char) (getctrlkey (&cstr) - 32); + c2 = getctrlkey (&cstr); + kmap[c1] = c2; + } + } +} + +void +buttonmapAdd(char *str, char *bmap) +{ + while (*str != '\0' && *(str + 1) != '\0') + { + switch (*str++) { - switch (*str++) - { case '1': - buttonmap[1] = getctrlkey (&str); + bmap[1] = getctrlkey (&str); break; case '2': - buttonmap[2] = getctrlkey (&str); + bmap[2] = getctrlkey (&str); break; case '3': - buttonmap[3] = getctrlkey (&str); + bmap[3] = getctrlkey (&str); break; /* XButton 1 */ case '4': - buttonmap[4] = getctrlkey (&str); + bmap[4] = getctrlkey (&str); break; /* XButton 2 */ case '5': - buttonmap[5] = getctrlkey (&str); + bmap[5] = getctrlkey (&str); break; /* Wheel Up */ case '6': - buttonmap[6] = getctrlkey (&str); + bmap[6] = getctrlkey (&str); break; /* Wheel Down */ case '7': - buttonmap[7] = getctrlkey (&str); + bmap[7] = getctrlkey (&str); break; #ifdef SHIFTED_MOUSE case '8': - buttonmap[8] = getctrlkey (&str); + bmap[8] = getctrlkey (&str); break; case '9': - buttonmap[9] = getctrlkey (&str); + bmap[9] = getctrlkey (&str); break; case 'a': - buttonmap[10] = getctrlkey (&str); + bmap[10] = getctrlkey (&str); break; case 'b': - buttonmap[11] = getctrlkey (&str); + bmap[11] = getctrlkey (&str); break; case 'c': - buttonmap[12] = getctrlkey (&str); + bmap[12] = getctrlkey (&str); break; case 'd': - buttonmap[13] = getctrlkey (&str); + bmap[13] = getctrlkey (&str); break; case 'e': - buttonmap[14] = getctrlkey (&str); + bmap[14] = getctrlkey (&str); break; case 'f': - buttonmap[15] = getctrlkey (&str); + bmap[15] = getctrlkey (&str); break; case 'g': - buttonmap[16] = getctrlkey (&str); + bmap[16] = getctrlkey (&str); break; case 'h': - buttonmap[17] = getctrlkey (&str); + bmap[17] = getctrlkey (&str); break; case 'i': - buttonmap[18] = getctrlkey (&str); + bmap[18] = getctrlkey (&str); break; case 'j': - buttonmap[19] = getctrlkey (&str); + bmap[19] = getctrlkey (&str); break; case 'k': - buttonmap[20] = getctrlkey (&str); + bmap[20] = getctrlkey (&str); break; case 'l': - buttonmap[21] = getctrlkey (&str); + bmap[21] = getctrlkey (&str); break; case 'm': - buttonmap[22] = getctrlkey (&str); + bmap[22] = getctrlkey (&str); break; #endif /* SHIFTED_MOUSE */ default: LineToConsole ("%c ignored in buttonmap\n", *(str - 1)); break; - } } } +} + +/******************************************************************************/ +/*** buildShipKeymap() - initializes the ship specific keymaps and + buttonmaps, then searches defaults file for the ship specific entries */ +/******************************************************************************/ +void +buildShipKeymap(struct ship *shipp) +{ + char keybuf[40], ckeybuf[40], buttonbuf[40]; + char *pek; + +#ifdef MOUSE_AS_SHIFT + memcpy(shipp->s_keymap, default_keymap, 672); +#else + memcpy(shipp->s_keymap, default_keymap, 96); +#endif + memcpy(shipp->s_buttonmap, default_buttonmap, 23); + + sprintf(keybuf, "keymap-%c%c", shipp->s_desig[0], shipp->s_desig[1]); + sprintf(ckeybuf, "ckeymap-%c%c", shipp->s_desig[0], shipp->s_desig[1]); + sprintf(buttonbuf, "buttonmap-%c%c", shipp->s_desig[0], shipp->s_desig[1]); + + if (pek = stringDefault (keybuf)) + keymapAdd(pek, shipp->s_keymap); + if (pek = stringDefault (ckeybuf)) + ckeymapAdd(pek, shipp->s_keymap); + + if (pek = stringDefault (buttonbuf)) + buttonmapAdd(pek, shipp->s_buttonmap); } /******************************************************************************/ @@ -1245,105 +1284,25 @@ } } - - /* this may represent a considerable efficiency improvement */ - /* removes the need for an INDEX and a couple tests */ if (localflags & (PFREFIT)) { - switch (key) - { - case 'c': - sendRefitReq (CRUISER); - localflags &= ~(PFREFIT); - return; - break; - case 'o': - sendRefitReq (STARBASE); - localflags &= ~(PFREFIT); - return; - break; - case 'a': - sendRefitReq (ASSAULT); - localflags &= ~(PFREFIT); - return; - break; - case 'd': - sendRefitReq (DESTROYER); - localflags &= ~(PFREFIT); - return; - break; - case 'g': - sendRefitReq (SGALAXY); - localflags &= ~(PFREFIT); - return; - break; - case 'b': - sendRefitReq (BATTLESHIP); - localflags &= ~(PFREFIT); - return; - break; - case 's': - sendRefitReq (SCOUT); - localflags &= ~(PFREFIT); - return; - break; - case '*': - sendRefitReq (ATT); - localflags &= ~(PFREFIT); - return; - break; - case 'j': - if (paradise) - sendRefitReq (JUMPSHIP); - localflags &= ~(PFREFIT); - return; - break; - case 'f': - if (paradise) - sendRefitReq (FLAGSHIP); - localflags &= ~(PFREFIT); - return; - break; - case 'w': - if (paradise) - sendRefitReq (WARBASE); - localflags &= ~(PFREFIT); - return; - break; - case 'l': - if (paradise) - sendRefitReq (LIGHTCRUISER); - localflags &= ~(PFREFIT); - return; - break; - case 'v': - if (paradise) - sendRefitReq (CARRIER); - localflags &= ~(PFREFIT); - return; - break; - case 'u': - if (paradise) - sendRefitReq (UTILITY); - localflags &= ~(PFREFIT); - return; - break; - case 'p': - if (paradise) - sendRefitReq (PATROL); - localflags &= ~(PFREFIT); - return; - break; - default: - localflags &= ~(PFREFIT); - return; - break; + struct shiplist *temp; + temp = shiptypes; + while (temp) { + if (temp->ship->s_letter == key) { + sendRefitReq(temp->ship->s_type); + localflags &= ~(PFREFIT); + return; + } + temp = temp->next; } + localflags &= ~(PFREFIT); + return; } if (key >= 32 && key < MAXKEY) { - key = mystats->st_keymap[key - 32]; + key = myship->s_keymap[key - 32]; } else { @@ -1534,7 +1493,7 @@ break; } - key = mystats->st_keymap[key - 32 + offset]; + key = myship->s_keymap[key - 32 + offset]; } } @@ -1659,9 +1618,9 @@ if (data->key >= W_LBUTTON && data->key <= W_WHEELDOWN) #endif { - if (buttonmap[data->key] != '\0') + if (myship->s_buttonmap[data->key] != '\0') { - data->key = buttonmap[data->key]; + data->key = myship->s_buttonmap[data->key]; keyaction (data); return; } Index: enter.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/enter.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- enter.c 16 Apr 2008 00:08:11 -0000 1.16 +++ enter.c 18 Apr 2008 03:42:36 -0000 1.17 @@ -48,6 +48,7 @@ { /* Used to be struct memory universe, but leaving room for flexible struct sizes is better, and necessary for paradise - BB */ + initialize_shiptypes(); initialize_players(); initialize_torps(); initialize_plasmas(); Index: cowmain.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/cowmain.c,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- cowmain.c 16 Apr 2008 00:08:06 -0000 1.37 +++ cowmain.c 18 Apr 2008 03:42:36 -0000 1.38 @@ -1001,7 +1001,8 @@ #endif /* RWATCH */ sendVersion (); - getship (myship, myship->s_type); + myship = getship(myship->s_type); + currentship = myship->s_type; #ifdef BRMH redrawall = 2; Index: getname.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/getname.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- getname.c 6 Apr 2008 23:29:56 -0000 1.10 +++ getname.c 18 Apr 2008 03:42:37 -0000 1.11 @@ -420,18 +420,18 @@ // Reset the keymap for our player record for (j = 0; j < 95; j++) { - mystats->st_keymap[j] = (unsigned char) (j + 32); - mystats->st_keymap[j + 96] = (unsigned char) (j + 32 + 96); + myship->s_keymap[j] = (unsigned char) (j + 32); + myship->s_keymap[j + 96] = (unsigned char) (j + 32 + 96); #ifdef MOUSE_AS_SHIFT - mystats->st_keymap[j + 192] = (unsigned char) (j + 32); - mystats->st_keymap[j + 288] = (unsigned char) (j + 32); - mystats->st_keymap[j + 384] = (unsigned char) (j + 32); - mystats->st_keymap[j + 480] = (unsigned char) (j + 32); - mystats->st_keymap[j + 576] = (unsigned char) (j + 32); + myship->s_keymap[j + 192] = (unsigned char) (j + 32); + myship->s_keymap[j + 288] = (unsigned char) (j + 32); + myship->s_keymap[j + 384] = (unsigned char) (j + 32); + myship->s_keymap[j + 480] = (unsigned char) (j + 32); + myship->s_keymap[j + 576] = (unsigned char) (j + 32); #endif } - mystats->st_keymap[95] = 0; + myship->s_keymap[95] = 0; mystats->st_tticks = 1; mystats->st_flags = ST_MAPMODE + ST_NAMEMODE + ST_SHOWSHIELDS + ST_KEEPPEACE + ST_SHOWLOCAL * 2 + ST_SHOWGLOBAL * 2; Index: playback.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/playback.c,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- playback.c 16 Apr 2008 00:08:20 -0000 1.24 +++ playback.c 18 Apr 2008 03:42:37 -0000 1.25 @@ -221,7 +221,7 @@ mystats = &(me->p_stats); me->p_x = me->p_y = 50000; - getship (myship, CRUISER); + myship = getship(CRUISER); shipchange (CRUISER); displayme = me; packetsme = me; @@ -243,18 +243,18 @@ mystats->st_tticks = 1; for (i = 0; i < 95; i++) { - mystats->st_keymap[i] = (unsigned char) (i + 32); - mystats->st_keymap[i + 96] = (unsigned char) (i + 32 + 96); + myship->s_keymap[i] = (unsigned char) (i + 32); + myship->s_keymap[i + 96] = (unsigned char) (i + 32 + 96); #ifdef MOUSE_AS_SHIFT - mystats->st_keymap[i + 192] = (unsigned char) (i + 32); - mystats->st_keymap[i + 288] = (unsigned char) (i + 32); - mystats->st_keymap[i + 384] = (unsigned char) (i + 32); - mystats->st_keymap[i + 480] = (unsigned char) (i + 32); - mystats->st_keymap[i + 576] = (unsigned char) (i + 32); + myship->s_keymap[i + 192] = (unsigned char) (i + 32); + myship->s_keymap[i + 288] = (unsigned char) (i + 32); + myship->s_keymap[i + 384] = (unsigned char) (i + 32); + myship->s_keymap[i + 480] = (unsigned char) (i + 32); + myship->s_keymap[i + 576] = (unsigned char) (i + 32); #endif } - mystats->st_keymap[95] = 0; + myship->s_keymap[95] = 0; mystats->st_flags = ST_MAPMODE + ST_NAMEMODE + ST_SHOWSHIELDS + ST_KEEPPEACE + ST_SHOWLOCAL * 2 + ST_SHOWGLOBAL * 2; @@ -327,7 +327,7 @@ redrawall = 1; #endif - getship (myship, myship->s_type); + myship = getship (myship->s_type); shipchange (myship->s_type); enter (); calibrate_stats (); Index: socket.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/socket.c,v retrieving revision 1.42 retrieving revision 1.43 diff -u -d -r1.42 -r1.43 --- socket.c 16 Apr 2008 00:08:22 -0000 1.42 +++ socket.c 18 Apr 2008 03:42:37 -0000 1.43 @@ -2274,7 +2274,7 @@ ST_NAMEMODE * showPlanetNames + ST_SHOWSHIELDS + /* always on */ ST_KEEPPEACE * keepPeace + ST_SHOWLOCAL * 1 + /* This client no longer supports */ ST_SHOWGLOBAL * 1); /* showlocal and showgalactic, set to 1 */ - MCOPY (mystats->st_keymap, optPacket.keymap, 96); + MCOPY (myship->s_keymap, optPacket.keymap, 96); sendServerPacket ((struct player_spacket *) &optPacket); } @@ -2552,13 +2552,14 @@ redrawall = 1; /* Update the map if I * change teams */ } - - getship (&pl->p_ship, packet->shiptype); + pl->p_ship = *getship(packet->shiptype); pl->p_mapchars[1] = shipnos[pl->p_no]; + if (packet->pnum == me->p_no && currentship != packet->shiptype) + currentship = packet->shiptype; - - if (me == pl && lastship != me->p_ship.s_type) + if (me == pl && lastship != currentship) { + lastship = currentship; redrawTstats (); calibrate_stats (); redrawStats (); /* TSH */ @@ -2704,7 +2705,7 @@ shipvals[stype].s_desig[2] = packet->s_desig2; shipvals[stype].s_bitmap = ntohs (packet->s_bitmap); /* strncpy(shipvals[stype].s_name, packet->s_name, 16); */ - getship (myship, myship->s_type); + myship = getship (myship->s_type); redrawTstats (); /* Redraw dashboard */ calibrate_stats (); /* Redefine colored statwin sliders */ Index: data.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/data.c,v retrieving revision 1.107 retrieving revision 1.108 diff -u -d -r1.107 -r1.108 --- data.c 16 Apr 2008 02:57:08 -0000 1.107 +++ data.c 18 Apr 2008 03:42:36 -0000 1.108 @@ -28,6 +28,7 @@ struct thingy *thingies; struct t_unit *terrainInfo; struct ship *myship; +struct shiplist *shiptypes = NULL; struct stats *mystats; struct planet *planets; struct phaser *phasers; @@ -104,7 +105,13 @@ int tryUdp = 1; int tryUdp1 = 1; struct plupdate pl_update[MAXPLANETS]; -char buttonmap[23] = { '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0' }; +#ifdef MOUSE_AS_SHIFT +unsigned char default_keymap[672] = ""; +#else +unsigned char default_keymap[96] = ""; +#endif +unsigned char default_buttonmap[23] = ""; +int currentship; int lastm = 0; time_t delay = 0; /* time stamp for decaring war */ time_t rdelay = 0; /* time stamp for refitting */ Index: helpwin.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/helpwin.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- helpwin.c 16 Apr 2008 00:08:16 -0000 1.13 +++ helpwin.c 18 Apr 2008 03:42:37 -0000 1.14 @@ -288,7 +288,7 @@ if (message_number != -1) { /* And now we will remap the key in that message */ - mystats->st_keymap[(data->key) - 32] = help_message[message_number][0]; + myship->s_keymap[(data->key) - 32] = help_message[message_number][0]; /* Finally we want to update window */ fillhelp (); @@ -355,7 +355,7 @@ for (i = 0; i < 96; i++) { - if (mystats->st_keymap[i] != key) + if (myship->s_keymap[i] != key) continue; if (i + 32 == key) { Index: option.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/option.c,v retrieving revision 1.53 retrieving revision 1.54 diff -u -d -r1.53 -r1.54 --- option.c 16 Apr 2008 00:08:18 -0000 1.53 +++ option.c 18 Apr 2008 03:42:37 -0000 1.54 @@ -1041,7 +1041,7 @@ { if (*(str + 1) == '\0') break; - mystats->st_keymap[*str - 32] = *(str + 1); + myship->s_keymap[*str - 32] = *(str + 1); } if (*(str + 1) == '\0') break; @@ -1055,76 +1055,76 @@ switch (*str++) { case '1': - buttonmap[1] = getctrlkey (&str); + myship->s_buttonmap[1] = getctrlkey (&str); break; case '2': - buttonmap[2] = getctrlkey (&str); + myship->s_buttonmap[2] = getctrlkey (&str); break; case '3': - buttonmap[3] = getctrlkey (&str); + myship->s_buttonmap[3] = getctrlkey (&str); break; /* XButton 1 */ case '4': - buttonmap[4] = getctrlkey (&str); + myship->s_buttonmap[4] = getctrlkey (&str); break; /* XButton 2 */ case '5': - buttonmap[5] = getctrlkey (&str); + myship->s_buttonmap[5] = getctrlkey (&str); break; /* Wheel Up */ case '6': - buttonmap[6] = getctrlkey (&str); + myship->s_buttonmap[6] = getctrlkey (&str); break; /* Wheel Down */ case '7': - buttonmap[7] = getctrlkey (&str); + myship->s_buttonmap[7] = getctrlkey (&str); break; #ifdef SHIFTED_MOUSE case '8': - buttonmap[8] = getctrlkey (&str); + myship->s_buttonmap[8] = getctrlkey (&str); break; case '9': - buttonmap[9] = getctrlkey (&str); + myship->s_buttonmap[9] = getctrlkey (&str); break; case 'a': - buttonmap[10] = getctrlkey (&str); + myship->s_buttonmap[10] = getctrlkey (&str); break; case 'b': - buttonmap[11] = getctrlkey (&str); + myship->s_buttonmap[11] = getctrlkey (&str); break; case 'c': - buttonmap[12] = getctrlkey (&str); + myship->s_buttonmap[12] = getctrlkey (&str); break; case 'd': - buttonmap[13] = getctrlkey (&str); + myship->s_buttonmap[13] = getctrlkey (&str); break; case 'e': - buttonmap[14] = getctrlkey (&str); + myship->s_buttonmap[14] = getctrlkey (&str); break; case 'f': - buttonmap[15] = getctrlkey (&str); + myship->s_buttonmap[15] = getctrlkey (&str); break; case 'g': - buttonmap[16] = getctrlkey (&str); + myship->s_buttonmap[16] = getctrlkey (&str); break; case 'h': - buttonmap[17] = getctrlkey (&str); + myship->s_buttonmap[17] = getctrlkey (&str); break; case 'i': - buttonmap[18] = getctrlkey (&str); + myship->s_buttonmap[18] = getctrlkey (&str); break; case 'j': - buttonmap[19] = getctrlkey (&str); + myship->s_buttonmap[19] = getctrlkey (&str); break; case 'k': - buttonmap[20] = getctrlkey (&str); + myship->s_buttonmap[20] = getctrlkey (&str); break; case 'l': - buttonmap[21] = getctrlkey (&str); + myship->s_buttonmap[21] = getctrlkey (&str); break; case 'm': - buttonmap[22] = getctrlkey (&str); + myship->s_buttonmap[22] = getctrlkey (&str); break; #endif /* SHIFTED_MOUSE */ Index: defaults.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/defaults.c,v retrieving revision 1.90 retrieving revision 1.91 diff -u -d -r1.90 -r1.91 --- defaults.c 16 Apr 2008 02:57:08 -0000 1.90 +++ defaults.c 18 Apr 2008 03:42:36 -0000 1.91 @@ -21,44 +21,6 @@ #include "proto.h" #include "version.h" -#ifdef PARADISE -#define DEFAULTSHIP NUM_TYPES_PARADISE -struct shipdef shipdefaults[NUM_TYPES_PARADISE + 1] = { - {"sc", NULL, NULL, NULL, NULL}, - {"dd", NULL, NULL, NULL, NULL}, - {"ca", NULL, NULL, NULL, NULL}, - {"bb", NULL, NULL, NULL, NULL}, - {"as", NULL, NULL, NULL, NULL}, - {"sb", NULL, NULL, NULL, NULL}, - {"att", NULL, NULL, NULL, NULL}, - {"js", NULL, NULL, NULL, NULL}, - {"fl", NULL, NULL, NULL, NULL}, - {"wb", NULL, NULL, NULL, NULL}, - {"cl", NULL, NULL, NULL, NULL}, - {"cv", NULL, NULL, NULL, NULL}, - {"ut", NULL, NULL, NULL, NULL}, - {"pt", NULL, NULL, NULL, NULL}, - {"pu", NULL, NULL, NULL, NULL}, - {"default", NULL, NULL, NULL, NULL} -}; -#else -#define DEFAULTSHIP NUM_TYPES_BRONCO -struct shipdef shipdefaults[NUM_TYPES_BRONCO + 1] = { - {"sc", NULL, NULL, NULL, NULL}, - {"dd", NULL, NULL, NULL, NULL}, - {"ca", NULL, NULL, NULL, NULL}, - {"bb", NULL, NULL, NULL, NULL}, - {"as", NULL, NULL, NULL, NULL}, - {"sb", NULL, NULL, NULL, NULL}, - {"ga", NULL, NULL, NULL, NULL}, - {"att", NULL, NULL, NULL, NULL}, - {"default", NULL, NULL, NULL, NULL} -}; -#endif - -int myshiptype = DEFAULTSHIP; -struct shipdef *myshipdef = &shipdefaults[DEFAULTSHIP]; - struct save_options save_options[] = { {"agriCAPS", &agriCAPS, RC_BOOL, { @@ -1124,8 +1086,6 @@ /* sizeof doesn't work if it isn't in the same source file, shoot me */ MCOPY (dist_defaults, dist_prefered, sizedist); - getshipdefaults (); - if (!deffile) if (findDefaults (deffile, file)) deffile = file; @@ -1750,7 +1710,6 @@ { char *pek; char tmp[100]; - int i; if (strlen (pigcall) == 0) sprintf (pigcall, "Netrek XP 2009 (%s) - the smarter netrek eXPerience!", mvers); @@ -1988,42 +1947,6 @@ tts_ypos = intDefault("tts_ypos", TWINSIDE / 2 - 16); #endif /* BEEPLITE */ - shipdefaults[DEFAULTSHIP].keymap = (unsigned char *) stringDefault ("keymap"); - shipdefaults[DEFAULTSHIP].buttonmap = (unsigned char *) stringDefault ("buttonmap"); - shipdefaults[DEFAULTSHIP].ckeymap = (unsigned char *) stringDefault ("ckeymap"); - - for (i = DEFAULTSHIP; i >= 0; i--) - { - STRNCPY (tmp, "rcfile-", 8); - strcat (tmp, shipdefaults[i].name); - if (pek = stringDefault (tmp)) - shipdefaults[i].rcfile = pek; - else - shipdefaults[i].rcfile = shipdefaults[DEFAULTSHIP].rcfile; - - STRNCPY (tmp, "keymap-", 8); - strcat (tmp, shipdefaults[i].name); - if (pek = stringDefault (tmp)) - shipdefaults[i].keymap = (unsigned char *) pek; - else - shipdefaults[i].keymap = shipdefaults[DEFAULTSHIP].keymap; - - STRNCPY (tmp, "ckeymap-", 9); - strcat (tmp, shipdefaults[i].name); - if (pek = stringDefault (tmp)) - shipdefaults[i].ckeymap = (unsigned char *) pek; - else - shipdefaults[i].ckeymap = shipdefaults[DEFAULTSHIP].ckeymap; - - STRNCPY (tmp, "buttonmap-", 11); - strcat (tmp, shipdefaults[i].name); - if (pek = stringDefault (tmp)) - shipdefaults[i].buttonmap = (unsigned char *) pek; - else - shipdefaults[i].buttonmap = shipdefaults[DEFAULTSHIP].buttonmap; - } - myshipdef = &shipdefaults[myshiptype]; - /* Let's check whether windows settings had changed */ /* Read in defaults was moved before window generation, thus this code is obsolete and not worth fixing - BB 04/07 */ @@ -2078,7 +2001,7 @@ void shipchange (int type) { - if (type == myshiptype) +/* if (type == myshiptype) return; myshiptype = type; myshipdef = &shipdefaults[type]; @@ -2087,10 +2010,9 @@ initDefaults (shipdefaults[type].rcfile); resetdefaults (); } - initkeymap (); + initkeymap ();*/ } - - + /* Generally useful function that searches for a file in the current and home directories, also the executable directory on Win32 */ @@ -2270,13 +2192,13 @@ for (c = 1; c < 95; c++) { - if (c + 32 != mystats->st_keymap[c]) + if (c + 32 != default_keymap[c]) { - if (mystats->st_keymap[c] != 'X' && - (mystats->st_keymap[c] >= 32 && - mystats->st_keymap[c] < 127)) + if (default_keymap[c] != 'X' && + (default_keymap[c] >= 32 && + default_keymap[c] < 127)) { - sprintf (str1, "%c%c", c + 32, mystats->st_keymap[c]); + sprintf (str1, "%c%c", c + 32, default_keymap[c]); strcat (str, str1); } else @@ -2284,9 +2206,9 @@ } } // space time - if (mystats->st_keymap[0] != 32) + if (default_keymap[0] != 32) { - sprintf (str1, " %c", mystats->st_keymap[0]); + sprintf (str1, " %c", default_keymap[0]); strcat (str, str1); } if (saveBig && strlen (str) != 0) @@ -2331,13 +2253,13 @@ for (i = W_LBUTTON; i <= W_WHEELDOWN; i++) #endif { - if (buttonmap[i] != 0) + if (default_buttonmap[i] != 0) { - c = getkeyfromctrl (buttonmap[i]); + c = getkeyfromctrl (default_buttonmap[i]); if (c == '^') sprintf (str, "%c^^", getcharfromdec (i)); else - sprintf (str, "%c%c", getcharfromdec (i), getkeyfromctrl (buttonmap[i])); + sprintf (str, "%c%c", getcharfromdec (i), getkeyfromctrl (default_buttonmap[i])); strcat (str1, str); } } @@ -2368,11 +2290,11 @@ // macroKey if (strlen (macroKey) == 0) { - if (mystats->st_keymap[169] == 'X') + if (default_keymap[169] == 'X') strcpy (macroKey, "TAB"); - else if (mystats->st_keymap[155] == 'X') + else if (default_keymap[155] == 'X') strcpy (macroKey, "ESC"); - else if (mystats->st_keymap[56] == 'X') + else if (default_keymap[56] == 'X') strcpy (macroKey, "X"); } @@ -3435,10 +3357,12 @@ fputs ("# button keymaps (b1keymap through b5keymap)\n", fp); } // Individual ship type settings - for (j = (paradise ? NUM_TYPES_PARADISE : NUM_TYPES_BRONCO); j >= 0; j--) + for (j = 0; j < nshiptypes; j++) { - STRNCPY (str1, "rcfile-", 8); - strcat (str1, shipdefaults[j].name); + struct ship *shipp; + + shipp = getship(j); + sprintf(str1, "rcfile-%c%c", shipp->s_desig[0], shipp->s_desig[1]); adefault = stringDefault (str1); if (adefault != NULL) { @@ -3446,9 +3370,7 @@ fputs (str, fp); } - - STRNCPY (str1, "keymap-", 8); - strcat (str1, shipdefaults[j].name); + sprintf(str1, "keymap-%c%c", shipp->s_desig[0], shipp->s_desig[1]); adefault = stringDefault (str1); if (adefault != NULL) { @@ -3456,8 +3378,7 @@ fputs (str, fp); } - STRNCPY (str1, "ckeymap-", 9); - strcat (str1, shipdefaults[j].name); + sprintf(str1, "ckeymap-%c%c", shipp->s_desig[0], shipp->s_desig[1]); adefault = stringDefault (str1); if (adefault != NULL) { @@ -3465,8 +3386,7 @@ fputs (str, fp); } - STRNCPY (str1, "buttonmap-", 11); - strcat (str1, shipdefaults[j].name); + sprintf(str1, "buttonmap-%c%c", shipp->s_desig[0], shipp->s_desig[1]); adefault = stringDefault (str1); if (adefault != NULL) {