1 /*
2  * XPilot NG XP-MapEdit, a map editor for xp maps.  Copyright (C) 1993 by
3  *
4  *      Aaron Averill           <averila@oes.orst.edu>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  *
20  * Modifications:
21  * 1996:
22  *      Robert Templeman        <mbcaprt@mphhpd.ph.man.ac.uk>
23  * 1997:
24  *      William Docter          <wad2@lehigh.edu>
25  */
26 
27 #include "xpmapedit.h"
28 
29 static char *display_name = NULL;
30 char *progname;
31 
32 Window mapwin, prefwin;
33 
34 Window mapinfo, robots, visibility, cannons, rounds;
35 Window inititems, maxitems, probs, scoring;
36 
37 Pixmap smlmap_pixmap;
38 int mapwin_width, mapwin_height;
39 int geometry_width, geometry_height;
40 
41 GC Wall_GC, Decor_GC, Treasure_GC, Target_GC;
42 GC Item_Conc_GC, Fuel_GC, Gravity_GC, Current_GC;
43 GC Wormhole_GC, Base_GC, Cannon_GC, Friction_GC;
44 GC White_GC, Black_GC, xorgc;
45 char *fontname = "*-times-bold-r-*-*-14-*-*-*-*-*-*-*";
46 
47 int drawicon, drawmode;
48 int prefssheet;
49 map_data_t clipdata;
50 xpmap_t map;
51 
52 int num_default_settings = 259;
53 charlie default_settings[259] = {
54     {"gravity", "-0.14"},
55     {"shipmass", "20.0"},
56     {"ballmass", "50.0"},
57     {"shotmass", "0.1"},
58     {"shotspeed", "21.0"},
59     {"shotlife", "60"},
60     {"firerepeatrate", "2"},
61     {"maxrobots", "4"},
62     {"minrobots", "-1"},
63     {"robotstalk", "no"},
64     {"robotsleave", "yes"},
65     {"robotleavelife", "50"},
66     {"robotleavescore", "-90"},
67     {"robotleaveratio", "-5"},
68     {"robotteam", "0"},
69     {"restrictrobots", "yes"},
70     {"reserverobotteam", "yes"},
71     {"robotrealname", "robot"},
72     {"robothostname", "xpilot.org"},
73     {"tankrealname", "tank"},
74     {"tankhostname", "tanks.org"},
75     {"tankscoredecrement", "500"},
76     {"turnthrust", "no"},
77     {"selfimmunity", "no"},
78     {"defaultshipshape",
79      "(NM:Default)(AU:Unknown)(SH: 15,0 -9,8 -9,-8)(MG: 15,0)(LG: 15,0)(RG: 15,0)(EN: -9,0)(LR: -9,8)(RR: -9,-8)(LL: -9,8)(RL: -9,-8)(MR: 15,0)"},
80     {"tankshipshape",
81      "(NM:fueltank)(AU:John E. Norlin)(SH: 15,0 14,-5 9,-8 -5,-8 -3,-8 -3,0 2,0 2,2 -3,2 -3,6 5,6 5,8 -5,8 -5,-8 -9,-8 -14,-5 -15,0 -14,5 -9,8 9,8 14,5)(EN: -15,0)(MG: 15,0)"},
82     {"maxplayershots", "256"},
83     {"shotsgravity", "yes"},
84     {"mapwidth", "100"},
85     {"mapheight", "100"},
86     {"mapname", "<New Map>"},
87     {"mapauthor", "<Your Name>"},
88     {"allowplayercrashes", "yes"},
89     {"allowplayerbounces", "yes"},
90     {"allowplayerkilling", "yes"},
91     {"allowshields", "yes"},
92     {"playerstartsshielded", "yes"},
93     {"shotswallbounce", "no"},
94     {"ballswallbounce", "yes"},
95     {"ballcollisions", "no"},
96     {"ballsparkcollisions", "yes"},
97     {"mineswallbounce", "no"},
98     {"itemswallbounce", "yes"},
99     {"missileswallbounce", "no"},
100     {"sparkswallbounce", "no"},
101     {"debriswallbounce", "no"},
102     {"asteroidswallbounce", "yes"},
103     {"cloakedexhaust", "yes"},
104     {"cloakedshield", "yes"},
105     {"maxobjectwallbouncespeed", "40"},
106     {"maxshieldedwallbouncespeed", "50"},
107     {"maxunshieldedwallbouncespeed", "20"},
108     {"maxshieldedplayerwallbounceangle", "90"},
109     {"maxunshieldedplayerwallbounceangle", "30"},
110     {"playerwallbouncebrakefactor", "0.89"},
111     {"objectwallbouncebrakefactor", "0.95"},
112     {"objectwallbouncelifefactor", "0.80"},
113     {"wallbouncefueldrainmult", "1.0"},
114     {"wallbouncedestroyitemprob", "0.0"},
115     {"limitedvisibility", "no"},
116     {"minvisibilitydistance", "0.0"},
117     {"maxvisibilitydistance", "0.0"},
118     {"limitedlives", "no"},
119     {"worldlives", "0"},
120     {"reset", "yes"},
121     {"resetonhuman", "0"},
122     {"allowalliances", "yes"},
123     {"announcealliances", "no"},
124     {"teamplay", "no"},
125     {"teamcannons", "no"},
126     {"teamfuel", "no"},
127     {"cannonsmartness", "1"},
128     {"cannonsuseitems", "no"},
129     {"cannonsdefend", "yes"},
130     {"cannonflak", "yes"},
131     {"cannondeadtime", "72"},
132     {"keepshots", "no"},
133     {"teamassign", "yes"},
134     {"teamimmunity", "yes"},
135     {"teamsharescore", "no"},
136     {"ecmsreprogrammines", "yes"},
137     {"ecmsreprogramrobots", "yes"},
138     {"targetkillteam", "no"},
139     {"targetteamcollision", "yes"},
140     {"targetsync", "no"},
141     {"targetdeadtime", "60"},
142     {"treasurekillteam", "no"},
143     {"capturetheflag", "no"},
144     {"treasurecollisiondestroys", "yes"},
145     {"ballconnectorspringconstant", "1500.0"},
146     {"ballconnectordamping", "2.0"},
147     {"maxballconnectorratio", "0.30"},
148     {"ballconnectorlength", "120"},
149     {"connectorisstring", "no"},
150     {"treasurecollisionmaykill", "no"},
151     {"wreckagecollisionmaykill", "no"},
152     {"asteroidcollisionmaykill", "yes"},
153     {"timing", "no"},
154     {"ballrace", "no"},
155     {"ballraceconnected", "no"},
156     {"edgewrap", "no"},
157     {"edgebounce", "yes"},
158     {"extraborder", "no"},
159     {"gravitypoint", "0,0"},
160     {"gravityangle", "90"},
161     {"gravitypointsource", "no"},
162     {"gravityclockwise", "no"},
163     {"gravityanticlockwise", "no"},
164     {"gravityvisible", "yes"},
165     {"wormholevisible", "yes"},
166     {"itemconcentratorvisible", "yes"},
167     {"asteroidconcentratorvisible", "yes"},
168     {"wormtime", "0"},
169     {"framespersecond", "14"},
170     {"allowsmartmissiles", "yes"},
171     {"allowheatseekers", "yes"},
172     {"allowtorpedoes", "yes"},
173     {"allownukes", "no"},
174     {"allowclusters", "no"},
175     {"allowmodifiers", "no"},
176     {"allowlasermodifiers", "no"},
177     {"allowshipshapes", "yes"},
178     {"playersonradar", "yes"},
179     {"missilesonradar", "yes"},
180     {"minesonradar", "no"},
181     {"nukesonradar", "yes"},
182     {"treasuresonradar", "no"},
183     {"asteroidsonradar", "no"},
184     {"distinguishmissiles", "yes"},
185     {"maxmissilesperpack", "4"},
186     {"maxminesperpack", "2"},
187     {"identifymines", "yes"},
188     {"shieldeditempickup", "no"},
189     {"shieldedmining", "no"},
190     {"laserisstungun", "no"},
191     {"nukeminsmarts", "7"},
192     {"nukeminmines", "4"},
193     {"nukeclusterdamage", "1.0"},
194     {"minefusetime", "0.0"},
195     {"minelife", "0"},
196     {"minminespeed", "0"},
197     {"missilelife", "0"},
198     {"baseminerange", "0"},
199     {"mineshotdetonatedistance", "0"},
200     {"shotkillscoremult", "1.0"},
201     {"torpedokillscoremult", "1.0"},
202     {"smartkillscoremult", "1.0"},
203     {"heatkillscoremult", "1.0"},
204     {"clusterkillscoremult", "1.0"},
205     {"laserkillscoremult", "1.0"},
206     {"tankkillscoremult", "0.44"},
207     {"runoverkillscoremult", "0.33"},
208     {"ballkillscoremult", "1.0"},
209     {"explosionkillscoremult", "0.33"},
210     {"shovekillscoremult", "0.5"},
211     {"crashscoremult", "0.33"},
212     {"minescoremult", "0.17"},
213     {"asteroidpoints", "1.0"},
214     {"cannonpoints", "1.0"},
215     {"asteroidmaxscore", "100.0"},
216     {"cannonmaxscore", "100.0"},
217     {"movingitemprob", "0.2"},
218     {"dropitemonkillprob", "0.5"},
219     {"randomitemprob", "0.0"},
220     {"detonateitemonkillprob", "0.5"},
221     {"destroyitemincollisionprob", "0.0"},
222     {"asteroiditemprob", "0.0"},
223     {"asteroidmaxitems", "0"},
224     {"itemprobmult", "1.0"},
225     {"cannonitemprobmult", "1.0"},
226     {"maxitemdensity", "0.00012"},
227     {"asteroidprob", "5e-7"},
228     {"maxasteroiddensity", "0"},
229     {"itemconcentratorradius", "10"},
230     {"itemconcentratorprob", "1.0"},
231     {"asteroidconcentratorradius", "10"},
232     {"asteroidconcentratorprob", "1.0"},
233     {"rogueheatprob", "1.0"},
234     {"roguemineprob", "1.0"},
235     {"itemenergypackprob", "1e-9"},
236     {"itemtankprob", "1e-9"},
237     {"itemecmprob", "1e-9"},
238     {"itemarmorprob", "1e-9"},
239     {"itemmineprob", "1e-9"},
240     {"itemmissileprob", "1e-9"},
241     {"itemcloakprob", "1e-9"},
242     {"itemsensorprob", "1e-9"},
243     {"itemwideangleprob", "1e-9"},
244     {"itemrearshotprob", "1e-9"},
245     {"itemafterburnerprob", "1e-9"},
246     {"itemtransporterprob", "1e-9"},
247     {"itemmirrorprob", "1e-9"},
248     {"itemdeflectorprob", "1e-9"},
249     {"itemhyperjumpprob", "1e-9"},
250     {"itemphasingprob", "1e-9"},
251     {"itemlaserprob", "1e-9"},
252     {"itememergencythrustprob", "1e-9"},
253     {"itemtractorbeamprob", "1e-9"},
254     {"itemautopilotprob", "1e-9"},
255     {"itememergencyshieldprob", "1e-9"},
256     {"initialfuel", "1000"},
257     {"initialtanks", "0"},
258     {"initialarmor", "0"},
259     {"initialecms", "0"},
260     {"initialmines", "0"},
261     {"initialmissiles", "0"},
262     {"initialcloaks", "0"},
263     {"initialsensors", "0"},
264     {"initialwideangles", "0"},
265     {"initialrearshots", "0"},
266     {"initialafterburners", "0"},
267     {"initialtransporters", "0"},
268     {"initialmirrors", "0"},
269     {"maxarmor", "10"},
270     {"initialdeflectors", "0"},
271     {"initialhyperjumps", "0"},
272     {"initialphasings", "0"},
273     {"initiallasers", "0"},
274     {"initialemergencythrusts", "0"},
275     {"initialtractorbeams", "0"},
276     {"initialautopilots", "0"},
277     {"initialemergencyshields", "0"},
278     {"maxfuel", "10000"},
279     {"maxtanks", "8"},
280     {"maxecms", "10"},
281     {"maxmines", "10"},
282     {"maxmissiles", "10"},
283     {"maxcloaks", "10"},
284     {"maxsensors", "10"},
285     {"maxwideangles", "10"},
286     {"maxrearshots", "10"},
287     {"maxafterburners", "10"},
288     {"maxtransporters", "10"},
289     {"maxdeflectors", "10"},
290     {"maxphasings", "10"},
291     {"maxhyperjumps", "10"},
292     {"maxemergencythrusts", "10"},
293     {"maxlasers", "5"},
294     {"maxtractorbeams", "4"},
295     {"maxautopilots", "10"},
296     {"maxemergencyshields", "10"},
297     {"maxmirrors", "10"},
298     {"gameduration", "0.0"},
299     {"allowviewing", "no"},
300     {"friction", "0.0"},
301     {"blockfriction", "0.0"},
302     {"blockfrictionvisible", "true"},
303     {"coriolis", "0"},
304     {"checkpointradius", "6.0"},
305     {"racelaps", "3"},
306     {"lockotherteam", "yes"},
307     {"loseitemdestroys", "no"},
308     {"usewreckage", "yes"},
309     {"maxoffensiveitems", "100"},
310     {"maxdefensiveitems", "100"},
311     {"rounddelay", "0"},
312     {"maxroundtime", "0"},
313     {"roundstoplay", "0"},
314     {"maxpausetime", "3600"}
315 };
316 
317 /* JLM Reorganized for new options */
318 int numprefs = 260;
319 prefs_t prefs[260] = {
320     {"mapwidth", "", "Width:", 3, MAPWIDTH, map.width_str, 0, 0, 0, 0, 0},
321     {"mapheight", "", "Height:", 3, MAPHEIGHT, map.height_str, 0, 1, 0, 0,
322      0},
323     {"mapname", "", "Name:", 255, STRING, map.mapName, 0, 2, 0, 0, 0},
324     {"mapauthor", "", "Author:", 255, STRING, map.mapAuthor, 0, 3, 0, 0,
325      0},
326     {"limitedlives", "", "Limited Lives?", 0, YESNO, 0, &map.limitedLives,
327      8, 0, 0, 0},
328     {"worldlives", "lives", "Lives:", 3, POSINT, map.worldLives, 0, 9, 0,
329      0, 0},
330     {"selfimmunity", "", "Self Immunity?", 0, YESNO, 0, &map.selfImmunity,
331      10, 0, 0, 0},
332     {"gravity", "", "Gravity:", 6, FLOAT, map.gravity, 0, 0, 1, 0, 0},
333     {"gravityangle", "", "Gravity Angle:", 3, POSINT, map.gravityAngle, 0,
334      1, 1, 0, 0},
335     {"gravitypoint", "", "Gravity Point:", 7, COORD, map.gravityPoint, 0,
336      2, 1, 0, 0},
337     {"gravitypointsource", "", "Point Source?", 0, YESNO, 0,
338      &map.gravityPointSource, 3, 1, 0, 0},
339     {"gravityclockwise", "", "Clockwise?", 0, YESNO, 0,
340      &map.gravityClockwise, 4, 1, 0, 0},
341     {"gravityanticlockwise", "", "Anti-Clockwise?", 0, YESNO, 0,
342      &map.gravityAnticlockwise, 5, 1, 0, 0},
343     {"shotsgravity", "", "Shots Gravity?", 0, YESNO, 0, &map.shotsGravity,
344      6, 1, 0, 0},
345     {"gravityvisible", "", "Gravity Visible?", 6, YESNO, 0,
346      &map.gravityVisible, 7, 1, 0, 0},
347     {"coriolis", "", "Coriolis:", 6, INT, map.coriolis, 0, 8, 1, 0, 0},
348     {"friction", "", "Friction:", 19, POSFLOAT, map.friction, 0, 10, 1, 0,
349      0},
350     {"blockfriction", "", "Block Friction:", 19, POSFLOAT,
351      map.blockFriction, 0, 11, 1, 0, 0},
352     {"defaultshipshape", "", "DefaultShipShape:", 255, STRING,
353      map.defaultShipShape, 0, 13, 1, 0, 0},
354     {"tankshipshape", "", "TankShipShape:", 255, STRING, map.tankShipShape,
355      0, 14, 1, 0, 0},
356     {"shipmass", "", "Ship Mass:", 6, POSFLOAT, map.shipMass, 0, 0, 2, 0,
357      0},
358     {"shotmass", "", "Shot Mass:", 6, POSFLOAT, map.shotMass, 0, 2, 2, 0,
359      0},
360     {"shotspeed", "", "Shot Speed:", 6, FLOAT, map.shotSpeed, 0, 3, 2, 0,
361      0},
362     {"shotlife", "", "Shot Life:", 3, POSINT, map.shotLife, 0, 4, 2, 0, 0},
363     {"maxplayershots", "shots", "Max. Shots:", 3, POSINT,
364      map.maxPlayerShots, 0, 5, 2, 0, 0},
365     {"firerepeatrate", "firerepeat", "Fire Repeat Rate:", 19, POSINT,
366      map.fireRepeatRate, 0, 6, 2, 0, 0},
367     {"keepshots", "", "KeepShots", 0, YESNO, 0, &map.keepShots, 7, 2, 0,
368      0},
369     {"edgebounce", "", "Edge Bounce?", 0, YESNO, 0, &map.edgeBounce, 9, 2,
370      0, 0},
371     {"edgewrap", "", "Edge Wrap?", 0, YESNO, 0, &map.edgeWrap, 10, 2, 0,
372      0},
373     {"extraborder", "", "Extra Border?", 0, YESNO, 0, &map.extraBorder, 11,
374      2, 0, 0},
375     {"turnthrust", "turnfuel", "TurnThrust?", 0, YESNO, 0, &map.turnThrust,
376      13, 2, 0, 0},
377 
378     {"robotstalk", "", "Robots Talk?", 0, YESNO, 0, &map.robotsTalk, 0, 0,
379      1, 0},
380     {"robotsleave", "", "Robots Leave?", 0, YESNO, 0, &map.robotsLeave, 1,
381      0, 1, 0},
382     {"robotleavelife", "", "Robot Leave Life:", 19, POSINT,
383      map.robotLeaveLife, 0, 2, 0, 1, 0},
384     {"robotleavescore", "", "Robot Leave Score:", 19, INT,
385      map.robotLeaveScore, 0, 3, 0, 1, 0},
386     {"robotleaveratio", "", "Robot Leave Ratio:", 19, POSFLOAT,
387      map.robotLeaveRatio, 0, 4, 0, 1, 0},
388     {"robotteam", "", "Robot Team:", 2, POSINT, map.robotTeam, 0, 5, 0, 1,
389      0},
390     {"restrictrobots", "", "Restrict Robots?", 0, YESNO, 0,
391      &map.restrictRobots, 6, 0, 1, 0},
392     {"reserverobotteam", "", "Resrve Rob Team?", 0, YESNO, 0,
393      &map.reserveRobotTeam, 7, 0, 1, 0},
394     {"minrobots", "", "Min. Robots", 19, FLOAT, map.minRobots, 0, 8, 0, 1,
395      0},
396     {"maxrobots", "robots", "Max. Robots:", 2, POSINT, map.maxRobots, 0, 9,
397      0, 1, 0},
398     {"robotrealname", "", "RobotRealName:", 255, STRING, map.robotRealName,
399      0, 11, 0, 1, 0},
400     {"robothostname", "", "RobotHostName:", 255, STRING, map.robotHostName,
401      0, 12, 0, 1, 0},
402     {"shotswallbounce", "", "Shots Bounce?", 0, YESNO, 0,
403      &map.shotsWallBounce, 0, 1, 1, 0},
404     {"ballswallbounce", "", "Balls Bounce?", 0, YESNO, 0,
405      &map.ballsWallBounce, 1, 1, 1, 0},
406     {"mineswallbounce", "", "Mines Bounce?", 0, YESNO, 0,
407      &map.minesWallBounce, 2, 1, 1, 0},
408     {"itemswallbounce", "", "Items Bounce?", 0, YESNO, 0,
409      &map.itemsWallBounce, 3, 1, 1, 0},
410     {"missileswallbounce", "", "Missiles Bounce?", 0, YESNO, 0,
411      &map.missilesWallBounce, 4, 1, 1, 0},
412     {"sparkswallbounce", "", "Sparks Bounce?", 0, YESNO, 0,
413      &map.sparksWallBounce, 5, 1, 1, 0},
414     {"debriswallbounce", "", "Debris Bounce?", 0, YESNO, 0,
415      &map.debrisWallBounce, 6, 1, 1, 0},
416     {"asteroidswallbounce", "", "Asteroids Bounce?", 0, YESNO, 0,
417      &map.asteroidsWallBounce, 7, 1, 1, 0},
418     {"wreckagecollisionmaykill", "wreckageunshieldedcollisionkills",
419      "Wreck Col Kills?", 0, YESNO, 0, &map.wreckageCollisionMayKill, 9, 1,
420      1, 0},
421     {"tankrealname", "", "TankRealName:", 255, STRING, map.tankRealName, 0,
422      10, 1, 1, 0},
423     {"tankhostname", "", "TankHostName:", 255, STRING, map.tankHostName, 0,
424      11, 1, 1, 0},
425     {"maxobjectwallbouncespeed", "maxobjectbouncespeed", "MxObjBnceSpd:",
426      19, POSFLOAT, map.maxObjectWallBounceSpeed, 0, 0, 2, 1, 0},
427     {"maxshieldedwallbouncespeed", "maxshieldedbouncespeed",
428      "MxShldBnceSpd:", 19, POSFLOAT, map.maxShieldedWallBounceSpeed, 0, 1,
429      2, 1, 0},
430     {"maxunshieldedwallbouncespeed", "maxunshieldedbouncespeed",
431      "MxUnshBnceSpd:", 19, POSFLOAT, map.maxUnshieldedWallBounceSpeed, 0,
432      2, 2, 1, 0},
433     {"maxshieldedplayerwallbounceangle", "maxshieldedbounceangle",
434      "MxShldBnceAng:", 19, POSFLOAT, map.maxShieldedPlayerWallBounceAngle,
435      0, 3, 2, 1, 0},
436     {"maxunshieldedplayerwallbounceangle", "maxunshieldedbounceangle",
437      "MxUnshBnceAng:", 19, POSFLOAT,
438      map.maxUnshieldedPlayerWallBounceAngle, 0, 4, 2, 1, 0},
439     {"playerwallbouncebrakefactor", "playerwallbrake", "Plyr Brake Fact:",
440      19, POSFLOAT, map.playerWallBounceBrakeFactor, 0, 5, 2, 1, 0},
441     {"objectwallbouncebrakefactor", "objectwallbrake", "Obj Brake Fact:",
442      19, POSFLOAT, map.objectWallBounceBrakeFactor, 0, 6, 2, 1, 0},
443     {"objectwallbouncelifefactor", "", "Obj Life Fact:", 19, POSFLOAT,
444      map.objectWallBounceLifeFactor, 0, 7, 2, 1, 0},
445     {"wallbouncefueldrainmult", "wallbouncedrail", "Fuel Drain Mult:", 19,
446      POSFLOAT, map.wallBounceFuelDrainMult, 0, 8, 2, 1, 0},
447     {"wallbouncedestroyitemprob", "", "BnceDestItmProb:", 19, POSFLOAT,
448      map.wallBounceDestroyItemProb, 0, 9, 2, 1, 0},
449     {"loseitemdestroys", "", "Lose Item Dests?", 0, YESNO, 0,
450      &map.loseItemDestroys, 11, 2, 1, 0},
451 
452     {"limitedvisibility", "", "Limited Visibility?", 0, YESNO, 0,
453      &map.limitedVisibility, 0, 0, 2, 0},
454     {"minvisibilitydistance", "minvisibility", "Min Visibility Dist:", 19,
455      POSFLOAT, map.minVisibilityDistance, 0, 1, 0, 2, 0},
456     {"maxvisibilitydistance", "maxvisibility", "Max Visibility Dist:", 19,
457      POSFLOAT, map.maxVisibilityDistance, 0, 2, 0, 2, 0},
458     {"wormholevisible", "", "Wormhole Visible?", 6, YESNO, 0,
459      &map.wormholeVisible, 3, 0, 2, 0},
460     {"itemconcentratorvisible", "", "Item Conc Vis?", 6, YESNO, 0,
461      &map.itemConcentratorVisible, 4, 0, 2, 0},
462     {"blockfrictionvisible", "", "BlockFriction Vis?", 6, YESNO, 0,
463      &map.blockFrictionVisible, 5, 0, 2, 0},
464     {"wormtime", "", "Wormhole Time:", 19, POSINT, map.wormTime, 0, 7, 0,
465      2, 0},
466     {"playerstartsshielded", "playerstartshielded", "Start Shielded?", 0,
467      YESNO, 0, &map.playerStartsShielded, 9, 0, 2, 0},
468     {"shieldeditempickup", "shielditem", "Shielded Pickup?", 0, YESNO, 0,
469      &map.shieldedItemPickup, 10, 0, 2, 0},
470     {"shieldedmining", "shieldmine", "Shielded Mining?", 0, YESNO, 0,
471      &map.shieldedMining, 11, 0, 2, 0},
472     {"allowalliances", "alliances", "AllowAlliances?", 0, YESNO, 0,
473      &map.allowAlliances, 13, 0, 2, 0},
474     {"announcealliances", "", "AnnounceAlliances?", 0, YESNO, 0,
475      &map.announceAlliances, 14, 0, 2, 0},
476     {"targetkillteam", "", "Target Kill Team?", 0, YESNO, 0,
477      &map.targetKillTeam, 0, 1, 2, 0},
478     {"targetteamcollision", "targetcollision", "Target Collision?", 0,
479      YESNO, 0, &map.targetTeamCollision, 1, 1, 2, 0},
480     {"targetsync", "", "Target Sync?", 0, YESNO, 0, &map.targetSync, 2, 1,
481      2, 0},
482     {"targetdeadtime", "", "Target Dead Time:", 19, POSINT,
483      map.targetDeadTime, 0, 3, 1, 2, 0},
484     {"treasurekillteam", "", "Treas. Kill Team?", 0, YESNO, 0,
485      &map.treasureKillTeam, 5, 1, 2, 0},
486     {"treasurecollisiondestroys", "treasurecollisiondestroy",
487      "Tres Col Dests?", 0, YESNO, 0, &map.treasureCollisionDestroys, 6, 1,
488      2, 0},
489     {"treasurecollisionmaykill", "treasureunshieldedcollisionkills",
490      "Tres Col Kills?", 0, YESNO, 0, &map.treasureCollisionMayKill, 7, 1,
491      2, 0},
492     {"ballconnectorlength", "", "BallCnctrLngth:", 19, POSFLOAT,
493      map.ballConnectorLength, 0, 8, 1, 2, 0},
494     {"maxballconnectorratio", "", "MxBallCnctrRatio:", 19, POSFLOAT,
495      map.maxBallConnectorRatio, 0, 9, 1, 2, 0},
496     {"ballconnectordamping", "", "BallCnctrDmping:", 19, POSFLOAT,
497      map.ballConnectorDamping, 0, 10, 1, 2, 0},
498     {"ballconnectorspringconstant", "", "BallCtrSprngCnst:", 19, POSFLOAT,
499      map.ballConnectorSpringConstant, 0, 11, 1, 2, 0},
500     {"connectorisstring", "", "Cnctr Is String?", 0, YESNO, 0,
501      &map.connectorIsString, 12, 1, 2, 0},
502     {"ballcollisions", "", "Ball Collisions?", 0, YESNO, 0,
503      &map.ballCollisions, 13, 1, 2, 0},
504     {"ballsparkcollisions", "", "Ball Spark Collisions?", 0, YESNO, 0,
505      &map.ballSparkCollisions, 14, 1, 2, 0},
506     {"ballmass", "", "BallMass:", 19, POSFLOAT, map.ballMass, 0, 15, 1, 2,
507      0},
508     {"playersonradar", "playersradar", "Players on Radar?", 0, YESNO, 0,
509      &map.playersOnRadar, 0, 2, 2, 0},
510     {"missilesonradar", "missilesradar", "Missles on Radar?", 0, YESNO, 0,
511      &map.missilesOnRadar, 1, 2, 2, 0},
512     {"minesonradar", "minesradar", "Mines on Radar?", 0, YESNO, 0,
513      &map.minesOnRadar, 2, 2, 2, 0},
514     {"nukesonradar", "nukesradar", "Nukes on Radar?", 0, YESNO, 0,
515      &map.nukesOnRadar, 3, 2, 2, 0},
516     {"treasuresonradar", "treasuresradar", "Treas. on Radar?", 0, YESNO, 0,
517      &map.treasuresOnRadar, 4, 2, 2, 0},
518     {"teamplay", "teams", "Team Play?", 0, YESNO, 0, &map.teamPlay, 6, 2,
519      2, 0},
520     {"teamassign", "", "Team Assign?", 0, YESNO, 0, &map.teamAssign, 7, 2,
521      2, 0},
522     {"teamimmunity", "", "Team Immunity?", 0, YESNO, 0, &map.teamImmunity,
523      8, 2, 2, 0},
524     {"teamcannons", "", "Team Cannons?", 0, YESNO, 0, &map.teamCannons, 9,
525      2, 2, 0},
526     {"teamfuel", "", "Team Fuel?", 0, YESNO, 0, &map.teamFuel, 10, 2, 2,
527      0},
528     {"capturetheflag", "ctf", "Capture The Flag?", 0, YESNO, 0,
529      &map.captureTheFlag, 11, 2, 2, 0},
530     {"cloakedexhaust", "", "Cloaked Exhaust?", 6, YESNO, 0,
531      &map.cloakedExhaust, 13, 2, 2, 0},
532     {"cloakedshield", "", "Cloaked Shield?", 6, YESNO, 0,
533      &map.cloakedShield, 14, 2, 2, 0},
534 
535     {"cannonsuseitems", "cannonspickupitems", "Cannons Use Items?", 0,
536      YESNO, 0, &map.cannonsUseItems, 0, 0, 3, 0},
537     {"cannonsdefend", "", "Cannons Defend?", 0, YESNO, 0,
538      &map.cannonsDefend, 1, 0, 3, 0},
539     {"cannonsmartness", "", "CannonSmartness:", 19, POSINT,
540      map.cannonSmartness, 0, 2, 0, 3, 0},
541     {"cannondeadtime", "", "CannonDeadTime:", 19, POSINT,
542      map.cannonDeadTime, 0, 3, 0, 3, 0},
543     {"cannonflak", "cannonaaa", "Cannon Flak?", 0, YESNO, 0,
544      &map.cannonFlak, 4, 0, 3, 0},
545     {"identifymines", "", "Identify Mines?", 0, YESNO, 0,
546      &map.identifyMines, 5, 0, 3, 0},
547     {"maxminesperpack", "", "Mines/Pac", 19, POSINT, map.maxMinesPerPack,
548      0, 6, 0, 3, 0},
549     {"minelife", "", "Mine Life", 19, POSFLOAT, map.mineLife, 0, 7, 0, 3,
550      0},
551     {"minefusetime", "", "Mine Fuse Time:", 19, POSINT, map.mineFuseTime,
552      0, 8, 0, 3, 0},
553     {"baseminerange", "", "Base Mine Range:", 19, POSINT,
554      map.baseMineRange, 0, 9, 0, 3, 0},
555     {"mineshotdetonatedistance", "", "MineShotDetDist:", 19, POSINT,
556      map.mineShotDetonateDistance, 0, 10, 0, 3, 0},
557     {"roguemineprob", "", "Rogue Mine Prob:", 19, POSFLOAT,
558      map.rogueMineProb, 0, 11, 0, 3, 0},
559     {"nukeminmines", "", "Min Nuke Mines:", 6, POSINT, map.nukeMinMines, 0,
560      12, 0, 3, 0},
561     {"minminespeed", "", "Min Mine Speed:", 19, POSFLOAT, map.minMineSpeed,
562      0, 13, 0, 3, 0},
563     {"nukeclusterdamage", "", "Nuke Clust Dam:", 19, POSFLOAT,
564      map.nukeClusterDamage, 0, 14, 0, 3, 0},
565     {"ecmsreprogramrobots", "", "EcmsReprgmRbts?", 6, YESNO, 0,
566      &map.ecmsReprogramRobots, 0, 1, 3, 0},
567     {"ecmsreprogrammines", "", "EcmsRprgMines?", 0, YESNO, 0,
568      &map.ecmsReprogramMines, 1, 1, 3, 0},
569     {"distinguishmissiles", "", "Distng Missiles?", 0, YESNO, 0,
570      &map.distinguishMissiles, 3, 1, 3, 0},
571     {"maxmissilesperpack", "", "Missiles/Pack:", 6, INT,
572      map.maxMissilesPerPack, 0, 4, 1, 3, 0},
573     {"missilelife", "", "Missile Life", 19, POSFLOAT, map.missileLife, 0,
574      5, 1, 3, 0},
575     {"rogueheatprob", "", "Rogue Heat Prob:", 19, POSFLOAT,
576      map.rogueHeatProb, 0, 6, 1, 3, 0},
577     {"nukeminsmarts", "", "Min Nuke Miss:", 6, POSINT, map.nukeMinSmarts,
578      0, 7, 1, 3, 0},
579     {"asteroidcollisionmaykill", "asteroidunshieldedcollisionkills",
580      "Asteroid Col Kills?", 0, YESNO, 0, &map.asteroidCollisionMayKill, 9,
581      1, 3, 0},
582     {"asteroidsonradar", "asteroidsradar", "Asteroids on Radar?", 0, YESNO,
583      0, &map.asteroidsOnRadar, 10, 1, 3, 0},
584     {"maxasteroiddensity", "", "MaxAsteroidDnsty:", 19, POSFLOAT,
585      map.maxAsteroidDensity, 0, 11, 1, 3, 0},
586     {"asteroidconcentratorvisible", "", "AsteroidConcVis?", 0, YESNO, 0,
587      &map.asteroidConcentratorVisible, 12, 1, 3, 0},
588     {"asteroidconcentratorradius", "asteroidconcentratorrange",
589      "AstrdConcRadius:", 19, POSINT, map.asteroidConcentratorRadius, 0, 13,
590      1, 3, 0},
591     {"asteroidmaxitems", "", "AstrdMaxItems:", 19, POSINT,
592      map.asteroidMaxItems, 0, 14, 1, 3, 0},
593 
594     {"allowshipshapes", "shipshapes", "Ship Shapes?", 0, YESNO, 0,
595      &map.allowShipShapes, 0, 2, 3, 0},
596     {"allowsmartmissiles", "allowsmarts", "Allow Smarts?", 6, YESNO, 0,
597      &map.allowSmartMissiles, 1, 2, 3, 0},
598     {"allowheatseekers", "allowheats", "Allow Heats?", 6, YESNO, 0,
599      &map.allowHeatSeekers, 2, 2, 3, 0},
600     {"allowtorpedoes", "allowtorps", "Allow Torps?", 6, YESNO, 0,
601      &map.allowTorpedoes, 3, 2, 3, 0},
602     {"allowplayercrashes", "", "Allow Crashes?", 0, YESNO, 0,
603      &map.allowPlayerCrashes, 4, 2, 3, 0},
604     {"allowplayerbounces", "", "Allow Bounces?", 0, YESNO, 0,
605      &map.allowPlayerBounces, 5, 2, 3, 0},
606     {"allowplayerkilling", "killings", "Allow Killing?", 0, YESNO, 0,
607      &map.allowPlayerKilling, 6, 2, 3, 0},
608     {"allowshields", "shields", "Allow Shields?", 0, YESNO, 0,
609      &map.allowShields, 7, 2, 3, 0},
610     {"allownukes", "nukes", "Allow Nukes?", 0, YESNO, 0, &map.allowNukes,
611      8, 2, 3, 0},
612     {"allowclusters", "clusters", "Allow Clusters?", 0, YESNO, 0,
613      &map.allowClusters, 9, 2, 3, 0},
614     {"allowmodifiers", "", "Allow Mods?", 0, YESNO, 0, &map.allowModifiers,
615      10, 2, 3, 0},
616     {"allowlasermodifiers", "lasermodifiers", "Laser Mods?", 0, YESNO, 0,
617      &map.allowLaserModifiers, 11, 2, 3, 0},
618     {"laserisstungun", "stungun", "Laser Stun Gun?", 0, YESNO, 0,
619      &map.laserIsStunGun, 13, 2, 3, 0},
620 
621     {"maxroundtime", "", "MaxRoundTime:", 19, POSINT, map.maxRoundTime, 0,
622      0, 0, 4, 0},
623     {"gameduration", "", "Game Duration:", 19, POSFLOAT, map.gameDuration,
624      0, 1, 0, 4, 0},
625     {"rounddelay", "", "Round Delay:", 19, POSINT, map.roundDelay, 0, 2, 0,
626      4, 0},
627     {"roundstoplay", "", "Rounds2Play:", 19, POSINT, map.roundsToPlay, 0,
628      3, 0, 4, 0},
629     {"reset", "", "World Reset?", 0, YESNO, 0, &map.reset, 5, 0, 4, 0},
630     {"resetonhuman", "humanreset", "ResetOnHuman:", 6, POSINT,
631      map.resetOnHuman, 0, 6, 0, 4, 0},
632     {"maxpausetime", "", "MaxPauseTime:", 19, POSINT, map.maxPauseTime, 0,
633      7, 0, 4, 0},
634     {"timing", "race", "Race-Timing?", 0, YESNO, 0, &map.timing, 0, 1, 4,
635      0},
636     {"checkpointradius", "", "Checkpoint Rad:", 19, POSFLOAT,
637      map.checkpointRadius, 0, 1, 1, 4, 0},
638     {"racelaps", "", "Race Laps:", 6, POSINT, map.raceLaps, 0, 2, 1, 4, 0},
639     {"ballrace", "", "BallRace?", 0, YESNO, 0, &map.ballrace, 3, 1, 4, 0},
640     {"ballraceconnected", "", "BallRaceCnctd?", 0, YESNO, 0,
641      &map.ballraceConnected, 4, 1, 4, 0},
642     {"itemconcentratorradius", "itemconcentratorrange", "Item Con Radius:",
643      19, POSFLOAT, map.itemConcentratorRadius, 0, 6, 1, 4, 0},
644     {"usewreckage", "", "Use Wreckage?", 6, YESNO, 0, &map.useWreckage, 2,
645      2, 4, 0},
646     {"lockotherteam", "", "Lock Other Team?", 0, YESNO, 0,
647      &map.lockOtherTeam, 3, 2, 4, 0},
648     {"allowviewing", "", "Allow Viewing?", 0, YESNO, 0, &map.allowViewing,
649      4, 2, 4, 0},
650     {"framespersecond", "FPS", "Frames/Second:", 6, POSINT,
651      map.framesPerSecond, 0, 6, 2, 4, 0},
652 
653     {"initialfuel", "", "Initial Fuel:", 19, POSFLOAT, map.initialFuel, 0,
654      0, 0, 5, 0},
655     {"initialtanks", "", "Initial Tanks:", 19, POSFLOAT, map.initialTanks,
656      0, 1, 0, 5, 0},
657     {"initialecms", "", "Initial ECMs:", 19, POSFLOAT, map.initialECMs, 0,
658      2, 0, 5, 0},
659     {"initialmines", "", "Initial Mines:", 19, POSFLOAT, map.initialMines,
660      0, 3, 0, 5, 0},
661     {"initialmissiles", "", "Initial Missiles:", 19, POSFLOAT,
662      map.initialMissiles, 0, 4, 0, 5, 0},
663     {"initialcloaks", "", "Initial Cloaks:", 19, POSFLOAT,
664      map.initialCloaks, 0, 5, 0, 5, 0},
665     {"initialsensors", "", "Initial Sensors:", 19, POSFLOAT,
666      map.initialSensors, 0, 6, 0, 5, 0},
667     {"initialwideangles", "", "Initial Wideangles:", 19, POSFLOAT,
668      map.initialWideangles, 0, 7, 0, 5, 0},
669     {"initialrearshots", "", "Initial Rearshots:", 19, POSFLOAT,
670      map.initialRearshots, 0, 8, 0, 5, 0},
671     {"initialafterburners", "", "Initial Aftrbrnrs:", 19, POSFLOAT,
672      map.initialAfterburners, 0, 9, 0, 5, 0},
673     {"initialtransporters", "", "Initial Trnsprtrs:", 19, POSFLOAT,
674      map.initialTransporters, 0, 0, 1, 5, 0},
675     {"initialdeflectors", "", "Initial Deflectors:", 19, POSINT,
676      map.initialDeflectors, 0, 1, 1, 5, 0},
677     {"initialphasings", "", "Initial Phasings:", 19, POSINT,
678      map.initialPhasings, 0, 2, 1, 5, 0},
679     {"initialhyperjumps", "", "Init. HyperJumps:", 19, POSINT,
680      map.initialHyperJumps, 0, 3, 1, 5, 0},
681     {"initialemergencythrusts", "", "Init. EmerThrust:", 19, POSFLOAT,
682      map.initialEmergencyThrusts, 0, 4, 1, 5, 0},
683     {"initiallasers", "", "Initial Lasers:", 19, POSFLOAT,
684      map.initialLasers, 0, 5, 1, 5, 0},
685     {"initialtractorbeams", "", "Initial TractorBms:", 19, POSFLOAT,
686      map.initialTractorBeams, 0, 6, 1, 5, 0},
687     {"initialautopilots", "", "Initial Autopilot:", 19, POSFLOAT,
688      map.initialAutopilots, 0, 7, 1, 5, 0},
689     {"initialemergencyshields", "", "Init. EmerShields:", 19, POSFLOAT,
690      map.initialEmergencyShields, 0, 8, 1, 5, 0},
691     {"initialmirrors", "", "Initial Mirrors:", 19, POSINT,
692      map.initialMirrors, 0, 9, 1, 5, 0},
693     {"initialarmor", "initialarmors", "Initial Armor:", 19, POSINT,
694      map.initialArmor, 0, 0, 2, 5, 0},
695 
696     {"maxfuel", "", "Max Fuel:", 19, POSINT, map.maxFuel, 0, 0, 0, 6, 0},
697     {"maxtanks", "", "Max Tanks:", 19, POSINT, map.maxTanks, 0, 1, 0, 6,
698      0},
699     {"maxecms", "", "Max ECMS:", 19, POSINT, map.maxECMs, 0, 2, 0, 6, 0},
700     {"maxmines", "", "Max Mines:", 19, POSINT, map.maxMines, 0, 3, 0, 6,
701      0},
702     {"maxmissiles", "", "Max Missiles:", 19, POSINT, map.maxMissiles, 0, 4,
703      0, 6, 0},
704     {"maxcloaks", "", "Max Cloaks:", 19, POSINT, map.maxCloaks, 0, 5, 0, 6,
705      0},
706     {"maxsensors", "", "Max Sensors:", 19, POSINT, map.maxSensors, 0, 6, 0,
707      6, 0},
708     {"maxwideangles", "", "Max Widesangles:", 19, POSINT,
709      map.maxWideangles, 0, 7, 0, 6, 0},
710     {"maxrearshots", "", "Max Rearshots:", 19, POSINT, map.maxRearshots, 0,
711      8, 0, 6, 0},
712     {"maxafterburners", "", "Max Afterburners:", 19, POSINT,
713      map.maxAfterburners, 0, 9, 0, 6, 0},
714     {"maxtransporters", "", "Max Transporters:", 19, POSINT,
715      map.maxTransporters, 0, 0, 1, 6, 0},
716     {"maxdeflectors", "", "Max Deflectors:", 19, POSINT, map.maxDeflectors,
717      0, 1, 1, 6, 0},
718     {"maxphasings", "", "Max Phasings:", 19, POSINT, map.maxPhasings, 0, 2,
719      1, 6, 0},
720     {"maxhyperjumps", "", "Max HyperJumps:", 19, POSINT, map.maxDeflectors,
721      0, 3, 1, 6, 0},
722     {"maxemergencythrusts", "", "Max Emrg.Thrsts:", 19, POSINT,
723      map.maxEmergencyThrusts, 0, 4, 1, 6, 0},
724     {"maxlasers", "", "Max Lasers:", 19, POSINT, map.maxLasers, 0, 5, 1, 6,
725      0},
726     {"maxtractorbeams", "", "Max TractorBms:", 19, POSINT,
727      map.maxTractorBeams, 0, 6, 1, 6, 0},
728     {"maxautopilots", "", "Max AutoPilots:", 19, POSINT, map.maxAutopilots,
729      0, 7, 1, 6, 0},
730     {"maxemergencyshields", "", "Max Emrg.Shields:", 19, POSINT,
731      map.maxEmergencyShields, 0, 8, 1, 6, 0},
732     {"maxmirrors", "", "Max Mirrors:", 19, POSINT, map.maxMirrors, 0, 9, 1,
733      6, 0},
734     {"maxarmor", "maxarmors", "Max Armor:", 19, POSINT, map.maxArmor, 0, 0,
735      2, 6, 0},
736     {"maxoffensiveitems", "", "MaxOffenseItems:", 6, POSINT,
737      map.maxOffensiveItems, 0, 1, 2, 6, 0},
738     {"maxdefensiveitems", "", "MaxDefenseItems:", 6, POSINT,
739      map.maxDefensiveItems, 0, 2, 2, 6, 0},
740     {"maxitemdensity", "", "MaxItemDensity:", 19, POSFLOAT,
741      map.maxItemDensity, 0, 4, 2, 6, 0},
742 
743 
744     {"itemenergypackprob", "", "Fuel Pack Prob:", 19, POSFLOAT,
745      map.itemEnergyPackProb, 0, 0, 0, 7, 0},
746     {"itemtankprob", "", "Tank Prob:", 19, POSFLOAT, map.itemTankProb, 0,
747      1, 0, 7, 0},
748     {"itemecmprob", "", "ECM Prob:", 19, POSFLOAT, map.itemECMProb, 0, 2,
749      0, 7, 0},
750     {"itemmineprob", "", "Mine Prob:", 19, POSFLOAT, map.itemMineProb, 0,
751      3, 0, 7, 0},
752     {"itemmissileprob", "", "Missile Prob:", 19, POSFLOAT,
753      map.itemMissileProb, 0, 4, 0, 7, 0},
754     {"itemcloakprob", "", "Cloak Prob:", 19, POSFLOAT, map.itemCloakProb,
755      0, 5, 0, 7, 0},
756     {"itemsensorprob", "", "Sensor Prob:", 19, POSFLOAT,
757      map.itemSensorProb, 0, 6, 0, 7, 0},
758     {"itemwideangleprob", "", "Wideangle Prob:", 19, POSFLOAT,
759      map.itemWideangleProb, 0, 7, 0, 7, 0},
760     {"itemrearshotprob", "", "Rearshot Prob:", 19, POSFLOAT,
761      map.itemRearshotProb, 0, 8, 0, 7, 0},
762     {"itemafterburnerprob", "", "Afterburner Prob:", 19, POSFLOAT,
763      map.itemAfterburnerProb, 0, 9, 0, 7, 0},
764     {"itemtransporterprob", "", "Transporter Prob:", 19, POSFLOAT,
765      map.itemTransporterProb, 0, 0, 1, 7, 0},
766     {"itemlaserprob", "", "Laser Prob:", 19, POSFLOAT, map.itemLaserProb,
767      0, 1, 1, 7, 0},
768     {"itememergencythrustprob", "", "EmerThrst Prob:", 19, POSFLOAT,
769      map.itemEmergencyThrustProb, 0, 2, 1, 7, 0},
770     {"itemtractorbeamprob", "", "Tractor Prob:", 19, POSFLOAT,
771      map.itemTractorBeamProb, 0, 3, 1, 7, 0},
772     {"itemautopilotprob", "", "Autopilot Prob:", 19, POSFLOAT,
773      map.itemAutopilotProb, 0, 4, 1, 7, 0},
774     {"itememergencyshieldprob", "", "EmerShield Prob:", 19, POSFLOAT,
775      map.itemEmergencyShieldProb, 0, 5, 1, 7, 0},
776     {"itemdeflectorprob", "", "Deflector Prob:", 19, POSFLOAT,
777      map.itemDeflectorProb, 0, 6, 1, 7, 0},
778     {"itemhyperjumpprob", "", "HyperJump Prob:", 19, POSFLOAT,
779      map.itemHyperJumpProb, 0, 7, 1, 7, 0},
780     {"itemphasingprob", "", "Phasing Prob:", 19, POSFLOAT,
781      map.itemPhasingProb, 0, 8, 1, 7, 0},
782     {"itemmirrorprob", "", "Mirror Prob:", 19, POSFLOAT,
783      map.itemMirrorProb, 0, 9, 1, 7, 0},
784     {"itemarmorprob", "", "Armor Prob:", 19, POSFLOAT, map.itemArmorProb,
785      0, 0, 2, 7, 0},
786     {"movingitemprob", "", "Moving Item Prob:", 19, POSFLOAT,
787      map.movingItemProb, 0, 1, 2, 7, 0},
788     {"dropitemonkillprob", "", "DropItemKillProb:", 19, POSFLOAT,
789      map.dropItemOnKillProb, 0, 2, 2, 7, 0},
790     {"detonateitemonkillprob", "", "DestItemKillProb:", 19, POSFLOAT,
791      map.detonateItemOnKillProb, 0, 3, 2, 7, 0},
792     {"destroyitemincollisionprob", "", "DestItemCollProb:", 19, POSFLOAT,
793      map.destroyItemInCollisionProb, 0, 4, 2, 7, 0},
794     {"itemconcentratorprob", "", "Item Conc. Prob:", 19, POSFLOAT,
795      map.itemConcentratorProb, 0, 5, 2, 7, 0},
796     {"itemprobmult", "itemprobfact", "Item Prob Mult:", 19, POSFLOAT,
797      map.itemProbMult, 0, 7, 2, 7, 0},
798     {"cannonitemprobmult", "", "Can.ItemProbMlt:", 19, POSFLOAT,
799      map.cannonItemProbMult, 0, 8, 2, 7, 0},
800     {"randomitemprob", "", "RandomItemProb:", 19, POSFLOAT,
801      map.randomItemProb, 0, 10, 2, 7, 0},
802     {"asteroidprob", "", "AsteroidProb:", 19, POSFLOAT, map.asteroidProb,
803      0, 12, 2, 7, 0},
804     {"asteroidconcentratorprob", "", "AstrdConcProb:", 19, POSFLOAT,
805      map.asteroidConcentratorProb, 0, 13, 2, 7, 0},
806     {"asteroiditemprob", "", "AstrdItemProb:", 19, POSFLOAT,
807      map.asteroidItemProb, 0, 14, 2, 7, 0},
808 
809     {"shotkillscoremult", "", "ShotKillScoreMlt:", 19, POSFLOAT,
810      map.shotKillScoreMult, 0, 0, 0, 8, 0},
811     {"torpedokillscoremult", "", "TorpKillScoreMlt:", 19, POSFLOAT,
812      map.torpedoKillScoreMult, 0, 1, 0, 8, 0},
813     {"smartkillscoremult", "", "SmrtKillScoroMlt:", 19, POSFLOAT,
814      map.smartKillScoreMult, 0, 2, 0, 8, 0},
815     {"heatkillscoremult", "", "HeatKillScoreMlt:", 19, POSFLOAT,
816      map.heatKillScoreMult, 0, 3, 0, 8, 0},
817     {"clusterkillscoremult", "", "ClstrKillScoreMlt:", 19, POSFLOAT,
818      map.clusterKillScoreMult, 0, 4, 0, 8, 0},
819     {"laserkillscoremult", "", "LasrKillScoreMlt:", 19, POSFLOAT,
820      map.laserKillScoreMult, 0, 5, 0, 8, 0},
821     {"tankkillscoremult", "", "TankKillScoreMlt:", 19, POSFLOAT,
822      map.tankKillScoreMult, 0, 6, 0, 8, 0},
823     {"runoverkillscoremult", "", "RnvrKillScoreMlt:", 19, POSFLOAT,
824      map.runoverKillScoreMult, 0, 7, 0, 8, 0},
825     {"ballkillscoremult", "", "BallKillScoreMlt:", 19, POSFLOAT,
826      map.ballKillScoreMult, 0, 8, 0, 8, 0},
827     {"explosionkillscoremult", "", "ExplKillScoreMlt:", 19, POSFLOAT,
828      map.explosionKillScoreMult, 0, 9, 0, 8, 0},
829     {"shovekillscoremult", "", "ShveKillScoreMlt:", 19, POSFLOAT,
830      map.shoveKillScoreMult, 0, 10, 0, 8, 0},
831     {"crashscoremult", "", "CrashScoreMlt:", 19, POSFLOAT,
832      map.crashScoreMult, 0, 11, 0, 8, 0},
833     {"minescoremult", "", "MineScoreMlt:", 19, POSFLOAT, map.mineScoreMult,
834      0, 12, 0, 8, 0},
835     {"tankscoredecrement", "", "Tank Decrement:", 6, INT,
836      map.tankScoreDecrement, 0, 0, 1, 8, 0},
837     {"asteroidpoints", "", "Asteroid Pts:", 19, FLOAT, map.asteroidPoints,
838      0, 1, 1, 8, 0},
839     {"asteroidmaxscore", "", "AsteroidMaxScore:", 19, FLOAT,
840      map.asteroidMaxScore, 0, 2, 1, 8, 0},
841     {"cannonpoints", "", "Cannon Pts:", 19, FLOAT, map.cannonPoints, 0, 3,
842      1, 8, 0},
843     {"cannonmaxscore", "", "CannonMaxScore:", 19, FLOAT,
844      map.cannonMaxScore, 0, 4, 1, 8, 0},
845     {"teamsharescore", "", "TeamShareScore?", 0, YESNO, 0,
846      &map.teamShareScore, 6, 1, 8, 0},
847 
848     {"mapdata", "", NULL, 0, MAPDATA, NULL, 0, 0, 0, 0, 0}
849 };
850 
851 /***************************************************************************/
852 /* int main                                                                */
853 /* Arguments :                                                             */
854 /*   argc                                                                  */
855 /*   argv                                                                  */
856 /* Purpose :                                                               */
857 /***************************************************************************/
858 
main(int argc,char * argv[])859 int main(int argc, char *argv[])
860 {
861     SetDefaults(argc, argv);
862 
863     Setup_default_server_options();
864 
865     T_ConnectToServer(display_name);
866 
867     LoadMap(map.mapFileName);
868 
869     SizeMapwin();
870 
871     T_SetToolkitFont(fontname);
872 
873     T_GetGC(&White_GC, "white");
874     T_GetGC(&Black_GC, "black");
875     T_GetGC(&xorgc, "white");
876     XSetFunction(display, xorgc, GXxor);
877     T_GetGC(&Wall_GC, COLOR_WALL);
878     T_GetGC(&Decor_GC, COLOR_DECOR);
879     T_GetGC(&Fuel_GC, COLOR_FUEL);
880     T_GetGC(&Treasure_GC, COLOR_TREASURE);
881     T_GetGC(&Target_GC, COLOR_TARGET);
882     T_GetGC(&Item_Conc_GC, COLOR_ITEM_CONC);
883     T_GetGC(&Gravity_GC, COLOR_GRAVITY);
884     T_GetGC(&Current_GC, COLOR_CURRENT);
885     T_GetGC(&Wormhole_GC, COLOR_WORMHOLE);
886     T_GetGC(&Base_GC, COLOR_BASE);
887     T_GetGC(&Cannon_GC, COLOR_CANNON);
888     T_GetGC(&Friction_GC, COLOR_FRICTION);
889 
890     mapwin = T_MakeWindow(50, (int) ((root_height - mapwin_height) / 2),
891 			  mapwin_width, mapwin_height, "white", "black");
892     T_SetWindowName(mapwin,
893 		    PACKAGE_NAME " XP-MapEdit",
894 		    PACKAGE_NAME " XP-MapEdit");
895     XSelectInput(display, mapwin, ExposureMask | ButtonPressMask |
896 		 KeyPressMask | StructureNotifyMask | ButtonReleaseMask |
897 		 PointerMotionMask);
898     BuildMapwinForm();
899 
900     smlmap_pixmap = XCreatePixmap(display, mapwin, TOOLSWIDTH, TOOLSWIDTH,
901 				  DefaultDepth(display, screennum));
902 
903     prefwin = T_PopupCreate(PREF_X, PREF_Y, PREFSEL_WIDTH, PREFSEL_HEIGHT,
904 			    "Preferences");
905     BuildPrefsForm();
906 
907     helpwin =
908 	T_PopupCreate(HELP_X, HELP_Y, HELP_WIDTH, HELP_HEIGHT, "Help");
909 
910     ResetMap();
911 
912     XMapWindow(display, mapwin);
913 
914     MainEventLoop();
915 
916     return 0;
917 }
918 
919 
920 
921 
922 /* RTT allow setting of server options from the default_settings array above */
Setup_default_server_options(void)923 void Setup_default_server_options(void)
924 {
925     int i;
926 
927     for (i = 0; i < num_default_settings; i++)
928 	AddOption(default_settings[i].name, default_settings[i].value);
929     return;
930 }
931 
932 
933 
934 
935 /***************************************************************************/
936 /* SetDefaults                                                             */
937 /* Arguments :                                                             */
938 /*   argc                                                                  */
939 /*   argv                                                                  */
940 /* Purpose :                                                               */
941 /***************************************************************************/
SetDefaults(int argc,char * argv[])942 void SetDefaults(int argc, char *argv[])
943 {
944     int i, j;
945 
946     /* Set "hardcoded" defaults from defaults file */
947     progname = argv[0];
948     drawicon = 3;
949     drawmode = 1;
950     geometry_width = 800;
951     geometry_height = 600;
952 
953     if (map.comments)
954 	free(map.comments);
955     map.comments = (char *) NULL;
956     map.mapName[0] = map.mapFileName[0] = '\0';
957     /*   strcpy(map.author,"Captain America (mbcaprt@mphhpd.ph.man.ac.uk)\0"); */
958     map.width = DEFAULT_WIDTH;
959     sprintf(map.width_str, "%d", map.width);
960     map.height = DEFAULT_HEIGHT;
961     sprintf(map.height_str, "%d", map.height);
962     for (i = 0; i < MAX_MAP_SIZE; i++)
963 	for (j = 0; j < MAX_MAP_SIZE; j++) {
964 	    map.data[i][j] = ' ';
965 	    clipdata[i][j] = ' ';
966 	}
967     map.view_x = map.view_y = 0;
968     map.view_zoom = DEFAULT_MAP_ZOOM;
969     map.changed = 0;
970     ParseArgs(argc, argv);
971 }
972 
973 /***************************************************************************/
974 /* ParseArgs                                                               */
975 /* Arguments :                                                             */
976 /*   argc                                                                  */
977 /*   argv                                                                  */
978 /* Purpose :                                                               */
979 /***************************************************************************/
ParseArgs(int argc,char * argv[])980 void ParseArgs(int argc, char *argv[])
981 {
982     static char *options[] = {
983 	"-font",
984 	"-display",
985 	"-help",
986 	"--help",
987 	"--version"
988     };
989     int NUMOPTIONS = 5;
990     int index, option;
991 
992     for (index = 1; index < argc; index++) {
993 	for (option = 0; option < NUMOPTIONS; option++)
994 	    if (!strcmp(argv[index], options[option]))
995 		break;
996 
997 	switch (option) {
998 
999 	case 0:
1000 	    free(fontname);
1001 	    fontname = (char *) malloc(strlen(argv[++index]) + 1);
1002 	    strcpy(fontname, argv[index]);
1003 	    break;
1004 
1005 	case 1:
1006 	    free(display_name);
1007 	    display_name = malloc(strlen(argv[++index]) + 1);
1008 	    strcpy(display_name, argv[index]);
1009 	    break;
1010 
1011 	case 2:
1012 	case 3:
1013 
1014 	    fprintf(stdout,
1015 		    "Usage :\n\n	%s [options] [mapfile]\n\n",
1016 		    argv[0]);
1017 	    fprintf(stdout,
1018 		    "[mapfile] is the map you wish to edit. Leaving it blank will start a new map\n");
1019 	    fprintf(stdout, "[options] can be\n\n");
1020 	    fprintf(stdout, "  -font <string>\n");
1021 	    fprintf(stdout,
1022 		    "    Use this font instead of the default\n\n");
1023 	    fprintf(stdout, "  -display <string>\n");
1024 	    fprintf(stdout,
1025 		    "    Display mapeditor on this display instead of the current\n\n");
1026 	    fprintf(stdout, "  -help\n");
1027 	    fprintf(stdout, "    Output this help\n\n");
1028 	    fprintf(stdout, "  --help\n");
1029 	    fprintf(stdout, "    Output this help\n\n");
1030 	    fprintf(stdout, "  --version\n");
1031 	    fprintf(stdout, "    Output version\n\n");
1032 	    exit(0);
1033 
1034 	case 4:
1035 	    fprintf(stdout, "xpilot-ng-xp-mapedit " VERSION "\n");
1036 	    exit(0);
1037 
1038 	default:
1039 	    if (argv[index][0] != '-')
1040 		strcpy(map.mapFileName, argv[index]);
1041 	    else
1042 		fprintf(stderr, "%s illegal option, ignoring.\n",
1043 			argv[index]);
1044 	    break;
1045 
1046 	}
1047     }
1048 }
1049 
1050 /***************************************************************************/
1051 /* ResetMap                                                                */
1052 /* Arguments :                                                             */
1053 /* Purpose :                                                               */
1054 /***************************************************************************/
ResetMap(void)1055 void ResetMap(void)
1056 {
1057     map.view_x = map.view_y = 0;
1058     while (((mapwin_width - TOOLSWIDTH) > (map.width * map.view_zoom)) ||
1059 	   (mapwin_height > (map.height * map.view_zoom)))
1060 	map.view_zoom++;
1061     T_SetWindowSizeLimits(mapwin, TOOLSWIDTH + 50, TOOLSHEIGHT,
1062 			  TOOLSWIDTH + map.width * map.view_zoom,
1063 			  map.height * map.view_zoom, 0, 0);
1064     SizeSmallMap();
1065     DrawTools();
1066     XFillRectangle(display, mapwin, Black_GC, TOOLSWIDTH, 0,
1067 		   mapwin_width - TOOLSWIDTH, mapwin_height);
1068     DrawMap(TOOLSWIDTH, 0, mapwin_width - TOOLSWIDTH, mapwin_height);
1069     T_FormScrollArea(mapwin, "draw_map_icon", T_SCROLL_UNBOUND, TOOLSWIDTH,
1070 		     0, mapwin_width - TOOLSWIDTH, mapwin_height,
1071 		     DrawMapIcon);
1072 }
1073 
1074 /***************************************************************************/
1075 /* SizeMapwin                                                              */
1076 /* Arguments :                                                             */
1077 /* Purpose :                                                               */
1078 /***************************************************************************/
SizeMapwin(void)1079 void SizeMapwin(void)
1080 {
1081     /* try for geometry settings */
1082     mapwin_width = geometry_width;
1083     mapwin_height = geometry_height;
1084     /* increase to size of tools if it's too small */
1085     if (mapwin_width < (TOOLSWIDTH + map.view_zoom))
1086 	mapwin_width = TOOLSWIDTH + map.view_zoom;
1087     if (mapwin_height < TOOLSHEIGHT)
1088 	mapwin_height = TOOLSHEIGHT;
1089     /* if it's too big for map, zoom in */
1090     while (((mapwin_width - TOOLSWIDTH) > (map.width * map.view_zoom)) ||
1091 	   (mapwin_height > (map.height * map.view_zoom)))
1092 	map.view_zoom++;
1093 }
1094 
1095 /***************************************************************************/
1096 /* SizeSmallMap                                                            */
1097 /* Arguments :                                                             */
1098 /* Purpose :                                                               */
1099 /***************************************************************************/
SizeSmallMap(void)1100 void SizeSmallMap(void)
1101 {
1102     smlmap_width = smlmap_height = TOOLSWIDTH - 20;
1103     smlmap_xscale = (float) (map.width) / (float) (smlmap_width);
1104     smlmap_yscale = (float) (map.height) / (float) (smlmap_height);
1105     if (map.width > map.height) {
1106 	smlmap_height = (int) (map.height / smlmap_xscale);
1107 	smlmap_yscale = (float) (map.height) / (float) (smlmap_height);
1108     } else if (map.height > map.width) {
1109 	smlmap_width = (int) (map.width / smlmap_yscale);
1110 	smlmap_xscale = (float) (map.width) / (float) (smlmap_width);
1111     }
1112     smlmap_x = TOOLSWIDTH / 2 - smlmap_width / 2;
1113     smlmap_y = TOOLSWIDTH / 2 - smlmap_height / 2;
1114     T_FormScrollArea(mapwin, "move_view", T_SCROLL_UNBOUND, smlmap_x,
1115 		     smlmap_y + TOOLSHEIGHT - TOOLSWIDTH, smlmap_width,
1116 		     smlmap_height, MoveMapView);
1117 }
1118