home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / compsrcs / misc / volume02 / travel.ler < prev    next >
Encoding:
Internet Message Format  |  1991-08-27  |  42.3 KB

  1. From mipos3!intelca!oliveb!ames!necntc!ncoast!allbery Fri Jan 29 08:03:47 PST 1988
  2. Article 267 of comp.sources.misc:
  3. Path: td2cad!mipos3!intelca!oliveb!ames!necntc!ncoast!allbery
  4. From: everson@compsci.bristol.ac.uk (Phill Everson)
  5. Newsgroups: comp.sources.misc
  6. Subject: v02i020: Traveller (FRP) programs
  7. Message-ID: <7131@ncoast.UUCP>
  8. Date: 26 Jan 88 04:10:58 GMT
  9. Sender: allbery@ncoast.UUCP
  10. Organization: Dept of Computer Science, University of Bristol, UK.
  11. Lines: 1888
  12. Approved: allbery@ncoast.UUCP
  13. X-Archive: comp.sources.misc/8801/20
  14. Comp.sources.misc: Volume 2, Issue 20
  15. Submitted-By: Phill Everson <everson@compsci.bristol.ac.uk>
  16. Archive-Name: traveller
  17.  
  18. Comp.sources.misc: Volume 2, Issue 20
  19. Submitted-By: Phill Everson <everson@compsci.bristol.ac.uk>
  20. Archive-Name: traveller
  21.  
  22. I don't know which newsgroup would be appropriate for the following,
  23. perhaps it should go in comp.sources.misc with some cross-postings?
  24. We are unable to post into rec.games.frp at present, so could you
  25. post it in the most suitable place please?  [Here.  Most non-source
  26. groups frown on sources the way source groups frown on binaries.  ++bsa]
  27.  
  28. # To unbundle, sh this file
  29.  echo README 1>&2
  30. cat >README<<'End of README'
  31. Usage of Traveller Programs
  32. ===========================
  33.  
  34. Create Two subdirectories sysgen & sysprint : Then unbundle the files.
  35. The directories will contain :
  36.  
  37. sysgen:
  38. Makefile const.h glob.c glob.h init.c main.c planets.c print.c rnd.c sats.c st.c
  39. stuff.h sub.c support.c system.c types.h
  40.  
  41. sysprint:
  42. Makefile mass stars.ps tr22 trconv trmult trmult.c ts
  43.  
  44. To generate complete listings of star systems (an allegedly complete
  45. implementation of Single-Star Systems according to the rules in Book 6)
  46. it is necessary to compile the files in sysgen (by typing make) and then
  47. running the program st. Be warned this produces voluminous output.
  48.  
  49. To generate a postscript file representing the star system, run st with
  50. the -m option. This produces a file which lists the major features in the
  51. system.
  52.  
  53. The command trconv file in the sysprint directory will then
  54. produce a postscript file. Trading routes can be added to the system
  55. description file by the DM as required.
  56.  
  57. Multiple systems can be printed using the trmult command. For example
  58.  
  59. trmult 2 2 stars.ps file1 file2 file3 file4
  60.  
  61. will place 4 systems on a piece of paper. But be warned: the order is not
  62. the most obvious imaginable.
  63.  
  64.  
  65. NOTE: the st command takes an argument which is an integer defining the
  66. system. This allows the st program to be run many times with predictable
  67. results.
  68.  
  69. tr22 & mass are historical examples of using trmult.
  70. End of README
  71.  echo sysgen/Makefile 1>&2
  72. cat >sysgen/Makefile <<'End of sysgen/Makefile'
  73. CFLAGS=
  74. PRFLAGS=-l60
  75. OBJS   =rnd.o init.o print.o glob.o st.o system.o support.o planets.o sats.o main.o sub.o
  76. SOURCES=rnd.c init.c print.c glob.c st.c system.c support.c planets.c sats.c main.c sub.c
  77. HDRS=const.h types.h glob.h
  78. PRG=st
  79. LIBS=-lm
  80.  
  81. $(PRG): $(OBJS)
  82.     cc $(CFLAGS) $(OBJS) $(LIBS) -o $(PRG)
  83.  
  84. $(OBJS) : stuff.h
  85.  
  86. stuff.h: $(HDRS)
  87.     @touch stuff.h
  88.  
  89. wc:
  90.     @wc $(SOURCES) $(HDRS)
  91.  
  92. lint:
  93.     @lint $(HDRS) $(SOURCES)
  94.  
  95. pr:
  96.     @pr $(PRFLAGS) $(HDRS) $(SOURCES)
  97.  
  98. objs:
  99.     @echo $(SOURCES)
  100.     @echo $(HDRS)
  101. End of sysgen/Makefile
  102.  echo sysgen/const.h 1>&2
  103. cat >sysgen/const.h <<'End of sysgen/const.h'
  104. #define DIE 6
  105. End of sysgen/const.h
  106.  echo sysgen/glob.c 1>&2
  107. cat >sysgen/glob.c <<'End of sysgen/glob.c'
  108. #include "stuff.h"
  109.  
  110. int orbits[]={ 0.2, 0.4, 0.7, 1.0, 1.6, 2.8, 5.2, 10.0, 19.6, 38.8,
  111.            77.2, 154.0, 307.6, 614.8, 1229.2, 2458.0, 4915.6, 9830.6,
  112.            19661.2, 39322.0 };
  113. char lt[]="aeioubcdfghjklmnpqrstvwxyz";
  114. int freq[]={ 82, 209, 278, 353, 380, 395, 422, 466, 488, 508, 569,
  115.              572, 580, 620, 644, 712, 731, 734, 792, 855, 947, 957,
  116.              980, 981, 1000, 1001 };
  117. int vowel=380;
  118. SYSDATA syst;
  119. char nature[]="SSSSSSSSBBBBTT";
  120. char ptypet[]="BBAMMMMMKGFFFF";
  121. int psizet[]={ 0, 1, 2, 3, 4, 5, 5,
  122.            5, 5, 5, 5, 6, 7, 7 };
  123. char ctypet[]="BBAFFGGKKMMMMM";
  124. int csizet[]={ 0, 1, 2, 3, 4, 7, 7,
  125.            5, 5, 6, 7, 7, 7, 7 };
  126. int natDM= -1;
  127. int typeDM=0;
  128. int sizeDM=0;
  129. char zones[][13][16]={ "--------IIIIIHO",
  130.                        "-------IIIIIHOO",
  131.                        "-------IIIIIHOO",
  132.                        "-------IIIIIHOO",
  133.                        "------IIIIIIHOO",
  134.                        "------IIIIIHOOO",
  135.                        "-------IIIIIHOO",
  136.                        "-------IIIIIHOO",
  137.                        "-------IIIIIHOO",
  138.                        "-------IIIIIHOO",
  139.                        "-------IIIIIHOO",
  140.                        "--------IIIIHOO",
  141.                        "--------IIIIHOO",
  142.  
  143.                        "--------IIIIIHO",
  144.                        "------IIIIIHOOO",
  145.                        "-----IIIIIIHOOO",
  146.                        "-----IIIIIHOOOO",
  147.                        "-----IIIIIHOOOO",
  148.                        "----IIIIIIHOOOO",
  149.                        "----IIIIIIHOOOO",
  150.                        "-----IIIIIHOOOO",
  151.                        "-----IIIIIHOOOO",
  152.                        "------IIIIIHOOO",
  153.                        "------IIIIIHOOO",
  154.                        "-------IIIIIHOO",
  155.                        "--------IIIIHOO",
  156.  
  157.                        "-------IIIIIHOO",
  158.                        "-----IIIIIIHOOO",
  159.                        "---IIIIIIHOOOOO",
  160.                        "--IIIIIIHOOOOOO",
  161.                        "--IIIIIIHOOOOOO",
  162.                        "--IIIIIIHOOOOOO",
  163.                        "--IIIIIIHOOOOOO",
  164.                        "--IIIIIIHOOOOOO",
  165.                        "--IIIIIIIHOOOOO",
  166.                        "---IIIIIIHOOOOO",
  167.                        "----IIIIIIHOOOO",
  168.                        "------IIIIIHOOO",
  169.                        "------IIIIIHOOO",
  170.  
  171.                        "-------IIIIIHOO",
  172.                        "-----IIIIIHOOOO",
  173.                        "-IIIIIIIHOOOOOO",
  174.                        "-IIIIIIHOOOOOOO",
  175.                        "-IIIIIHOOOOOOOO",
  176.                        "-IIIIIHOOOOOOOO",
  177.                        "-IIIIIHOOOOOOOO",
  178.                        "-IIIIIIHOOOOOOO",
  179.                        "-IIIIIIHOOOOOOO",
  180.                        "-IIIIIIIHOOOOOO",
  181.                        "--IIIIIIHOOOOOO",
  182.                        "----IIIIIHOOOOO",
  183.                        "-----IIIIHOOOOO",
  184.  
  185.                        "-------IIIIIHOO",
  186.                        "---IIIIIIHOOOOO",
  187.                        "-IIIIIIHOOOOOOO",
  188.                        "IIIIIIHOOOOOOOO",
  189.                        "IIIIIIHOOOOOOOO",
  190.                        "IIIIIHOOOOOOOOO",
  191.                        "IIIIIHOOOOOOOOO",
  192.                        "IIIIIHOOOOOOOOO",
  193.                        "IIIIHOOOOOOOOOO",
  194.                        "---------------",
  195.                        "---------------",
  196.                        "---------------",
  197.                        "---------------",
  198.  
  199.                        "------IIIIIIHOO",
  200.                        "---IIIIIIHOOOOO",
  201.                        "IIIIIIIHOOOOOOO",
  202.                        "IIIIIIHOOOOOOOO",
  203.                        "IIIIIHOOOOOOOOO",
  204.                        "IIIIHOOOOOOOOOO",
  205.                        "IIIHOOOOOOOOOOO",
  206.                        "IIHOOOOOOOOOOOO",
  207.                        "IIHOOOOOOOOOOOO",
  208.                        "HOOOOOOOOOOOOOO",
  209.                        "HOOOOOOOOOOOOOO",
  210.                        "OOOOOOOOOOOOOOO",
  211.                        "OOOOOOOOOOOOOOO",
  212.  
  213.                        "---------------",
  214.                        "---------------",
  215.                        "---------------",
  216.                        "---------------",
  217.                        "---------------",
  218.                        "IIIHOOOOOOOOOOO",
  219.                        "IIHOOOOOOOOOOOO",
  220.                        "IHOOOOOOOOOOOOO",
  221.                        "IHOOOOOOOOOOOOO",
  222.                        "OOOOOOOOOOOOOOO",
  223.                        "OOOOOOOOOOOOOOO",
  224.                        "OOOOOOOOOOOOOOO",
  225.                        "OOOOOOOOOOOOOOO",
  226.  
  227.                        "HOOOOOOOOOOOOOO",
  228.                        "HOOOOOOOOOOOOOO",
  229.                        "OOOOOOOOOOOOOOO",
  230.                        "OOOOOOOOOOOOOOO",
  231.                        "OOOOOOOOOOOOOOO",
  232.                        "OOOOOOOOOOOOOOO",
  233.                        "OOOOOOOOOOOOOOO",
  234.                        "OOOOOOOOOOOOOOO",
  235.                        "OOOOOOOOOOOOOOO",
  236.                        "OOOOOOOOOOOOOOO",
  237.                        "OOOOOOOOOOOOOOO",
  238.                        "OOOOOOOOOOOOOOO",
  239.                        "OOOOOOOOOOOOOOO" };
  240. int ggno[]={ 0, 1, 1, 1, 2, 2, 3,
  241.              3, 4, 4, 4, 5, 5, 5 };
  242. int plno[]={ 3, 2, 2, 2, 2, 2, 2,
  243.              1, 1, 1, 1, 1, 1, 1 };
  244. int ggDM, plDM;
  245. int ring[]={ 1, 1, 1, 1, 2, 2, 3 };
  246. int clos[]={ 1, 2, 3, 4, 5, 6, 7,
  247.               8, 9, 10, 11, 12, 13 };
  248. int far[]={ 5, 10, 15, 20, 25, 30, 35,
  249.            40, 45, 50, 55, 60, 65 };
  250. int extreme[]={ 75, 100, 125, 150, 175, 200,
  251.                225, 250, 275, 300, 325 };
  252. char starport[]="AAAAABBCCDEEX";
  253. char spaceport[]="YYYHGGF";
  254. int tech[][17]={0,0,0,0,0,0,0,0,0,0,6,4,2,0,0,0,-4,
  255.                 2,2,2,1,1,1,0,0,0,0,0,0,0,0,0,0,0,
  256.                 1,1,1,1,0,0,0,0,0,0,1,1,1,1,1,0,0,
  257.                 0,0,0,0,0,0,0,0,0,1,2,0,0,0,0,0,0,
  258.                 0,1,1,1,1,1,0,0,0,2,4,0,0,0,0,0,0,
  259.                 1,0,0,0,0,1,0,0,0,0,0,0,0,-2,0,0,0 };
  260. int mwatm,mwpop,mwgov,mwlaw,mwtech,mwind,mwpoor;
  261. int base;
  262. SUBDATA *subsect,*css;
  263. int grtab[]={ 0,0,0,0,5,5,10,10,
  264.               15,15,40,50,60,15,10,0 };
  265. int cloud[]={ 0,0,10,10,20,30,40,50,60,70,70 };
  266. double lumtab[][13]={ 560000,204000,107000,81000,61000,51000,67000,89000,
  267.                      97000,107000,117000,129000,141000,
  268.                   270000,46700,15000,11700,7400,5100,6100,8100,11700,
  269.                      20400,46000,89000,117000,
  270.                   170000,18600,2200,850,600,510,560,740,890,2450,4600,
  271.                      14900,16200,
  272.                   107000,6700,280,90,53,43,50,75,95,320,470,2280,2690,
  273.                   81000,2000,156,37,19,12,6.5,4.9,4.67,0,0,0,0,
  274.                   56000,1400,90,16,8.1,3.5,1.21,.67,.42,.08,.04,.007,.001,
  275.                   0,0,0,0,0,.977,.322,.186,.117,.025,.011,.002,.00006,
  276.                   .046,.01,.005,.0009,.0003,.00015,.00006,.00005,.00004,
  277.                      .00004,.00003,.00003,.00003 };
  278. double dtab[]={ .2,.4,.7,1,1.6,2.8,5.2,10,19.6,38.8,77.2,154,307.6,614.8,
  279.                      1229.2,2458,4915.6,9380.8,19661.2,39322 };
  280. char spa[50][50];
  281. int mapflag;
  282. End of sysgen/glob.c
  283.  echo sysgen/glob.h 1>&2
  284. cat >sysgen/glob.h <<'End of sysgen/glob.h'
  285. extern int orbits[];
  286. extern char lt[];
  287. extern int freq[];
  288. extern int vowel;
  289. extern SYSDATA syst;
  290. extern char nature[], ptypet[], ctypet[];
  291. extern int psizet[], csizet[], natDM, typeDM, sizeDM;
  292. extern char zones[][13][16];
  293. extern int ggno[], plno[];
  294. extern int ggDM, plDM;
  295. extern int ring[], clos[], far[], extreme[];
  296. extern char starport[],spaceport[];
  297. extern int tech[][17];
  298. extern int mwatm,mwpop,mwgov,mwlaw,mwtech,mwind,mwpoor;
  299. extern int base;
  300. extern SUBDATA *subsect,*css;
  301. extern int grtab[],cloud[];
  302. extern double lumtab[][13], dtab[];
  303. extern char spa[][50];
  304. extern int mapflag;
  305. End of sysgen/glob.h
  306.  echo sysgen/init.c 1>&2
  307. cat >sysgen/init.c <<'End of sysgen/init.c'
  308. #include "stuff.h"
  309.  
  310. init(argc,argv,maxx,maxy)
  311. char **argv;
  312. int *maxx,*maxy;
  313. {
  314.     subsect=(SUBDATA *)malloc(sizeof(SUBDATA));
  315.     subsect->next=NULL;
  316.     css=subsect;
  317.     if (argc>1 && argv[1][0]=='-')
  318.     {
  319.         if (argv[1][1]=='m')
  320.             mapflag=1;
  321.         argv++;
  322.         argc--;
  323.     }
  324.     switch(argc)
  325.     {
  326.     case 1:
  327.         iseed(42);
  328.         *maxx=8;
  329.         *maxy=10;
  330.         break;
  331.     case 2:
  332.         iseed(atoi(argv[1]));
  333.         *maxx=8;
  334.         *maxy=10;
  335.         break;
  336.     case 3:
  337.         iseed(atoi(argv[1]));
  338.         *maxx=8;
  339.         *maxy=atoi(argv[2]);
  340.         break;
  341.     case 4:
  342.         iseed(atoi(argv[1]));
  343.         *maxx=atoi(argv[3]);
  344.         *maxy=atoi(argv[2]);
  345.         break;
  346.     }
  347. }
  348. End of sysgen/init.c
  349.  echo sysgen/main.c 1>&2
  350. cat >sysgen/main.c <<'End of sysgen/main.c'
  351. #include "stuff.h"
  352.  
  353. mworld(s)
  354. SYSDATA *s;
  355. {
  356. int pop;
  357. PLANDATA *p,*mp;
  358. SATDATA *sat,*ms;
  359.  
  360.     pop=0;
  361.     mp=NULL;
  362.     for (p=s->orb0; p; p=p->next)
  363.     {
  364.         if (p->type=='P' || p->type=='W')
  365.         {
  366.             if (p->pop>pop || p->pop==pop && p->zone=='H')
  367.             {
  368.                 pop=p->pop;
  369.                 mp=p;
  370.                 ms=NULL;
  371.             }
  372.         }
  373.         for (sat=p->sats; sat; sat=sat->next)
  374.              if (sat->pop>pop || sat->pop==pop && p->zone=='H') 
  375.              {
  376.                  pop=sat->pop;
  377.                  mp=p;
  378.                  ms=sat;
  379.              }
  380.     }
  381.     if (mp==NULL)
  382.         return;
  383.     for (p=s->orb0; p && p!=mp; p=p->next)
  384.         ;
  385.     if (ms==NULL)
  386.     {
  387.         p->main=1;
  388.         p->gov=gov(p->pop);
  389.         p->law=law(p->gov);
  390.         if (p->pop>0) p->sport=starport[die(2)]; else p->sport='X';
  391.         p->tech=die(1)+tech[0][p->sport]+tech[1][p->size+1]+tech[2][p->atm]
  392.                        +tech[3][p->hyd]+tech[4][p->pop]+tech[5][p->gov];
  393.         if (p->tech<0) p->tech=0;
  394.         else if (p->tech>15) p->tech=15;
  395.         trade(&p->notes,p->size,p->atm,p->hyd,p->pop,p->gov,p->law,p->tech);
  396.         if (die(2)>7 && (p->sport=='A' || p->sport=='B'))
  397.             addstr(&p->notes,"Naval");
  398.         if (scb(p->sport)) addstr(&p->notes,"Scout");
  399.         mwatm=p->atm;
  400.         mwpop=p->pop;
  401.         mwgov=p->gov;
  402.         mwlaw=p->law;
  403.         mwtech=p->tech;
  404.         return;
  405.     }
  406.     for (sat=p->sats; sat && sat!=ms; sat=sat->next)
  407.         ;
  408.     sat->main=1;
  409.     sat->gov=gov(sat->pop);
  410.     sat->law=law(sat->gov);
  411.     sat->sport=starport[die(2)];
  412.     sat->tech=die(1)+tech[0][sat->size]+tech[1][sat->atm]+tech[2][sat->hyd]
  413.                    +tech[3][sat->pop]+tech[4][sat->gov];
  414.     if (sat->tech<0) sat->tech=0;
  415.     else if (sat->tech>15) sat->tech=15;
  416.     trade(&sat->notes,sat->size,sat->atm,sat->hyd,sat->pop,sat->gov,
  417.             sat->law,sat->tech);
  418.     if (die(2)>7 && (sat->sport=='A' || sat->sport=='B'))
  419.         addstr(&sat->notes,"Naval");
  420.     if (scb(sat->sport)) addstr(&sat->notes,"Scout");
  421.     mwgov=sat->gov;
  422.     mwlaw=sat->law;
  423.     mwtech=sat->tech;
  424. }
  425.  
  426. gov(pop)
  427. {
  428. int g;
  429.  
  430.     g=die(2)-7+pop;
  431.     if (g<0) return 0;
  432.     else if (g>15) return 15;
  433.     else return g;
  434. }
  435.  
  436. law(gov)
  437. {
  438. int l;
  439.  
  440.     l=die(2)-7+gov;
  441.     if (l<0) return 0;
  442.     else if (l>9) return 9;
  443.     else return l;
  444. }
  445.  
  446. scb(sp)
  447. char sp;
  448. {
  449. int DM;
  450.  
  451.    switch(sp)
  452.    {
  453.    case 'C':
  454.        DM= -1;
  455.        break;
  456.    case 'B':
  457.        DM= -2;
  458.        break;
  459.    case 'A':
  460.        DM= -3;
  461.        break;
  462.    }
  463.    if (sp!='E' && sp!='X')
  464.        return (die(2)+DM>6);
  465.    else
  466.        return 0;
  467. }
  468.  
  469. trade(notes,size,atm,hyd,pop,gov,law)
  470. char **notes;
  471. {
  472.     mwind=mwpoor=0;
  473.     if (atm>=4 && atm<=9 && hyd>=4 && hyd<=8 && pop>=5 && pop<=7)
  474.         addstr(notes,"Agr");
  475.     if (atm<=3 && hyd<=3 && pop>=6)
  476.         addstr(notes,"Non-Agr");
  477.     if ((atm>=0 && atm<=2 || atm==4 || atm==7 || atm==9) && pop>=9)
  478.     {
  479.         addstr(notes,"Ind");
  480.         mwind=1;
  481.     }
  482.     if (pop<=6)
  483.         addstr(notes,"Non-Ind");
  484.     if ((atm==6 || atm==9) && gov>=4 && gov<=9 && pop>=6 && pop<=8)
  485.         addstr(notes,"Rich");
  486.     if (atm>=2 && atm<=5 && hyd<=3)
  487.     {
  488.         addstr(notes,"Poor");
  489.         mwpoor=1;
  490.     }
  491.     if (hyd==10)
  492.         addstr(notes,"Water");
  493.     if (atm>=2 && hyd==0)
  494.         addstr(notes,"Desert");
  495.     if (atm==0)
  496.         addstr(notes,"Vacuum");
  497.     if (size==0)
  498.         addstr(notes,"Asteroid");
  499.     if (atm>=0 && atm<=1 && hyd>=1)
  500.         addstr(notes,"Ice-Capped");
  501. }
  502. End of sysgen/main.c
  503.  echo sysgen/planets.c 1>&2
  504. cat >sysgen/planets.c <<'End of sysgen/planets.c'
  505. #include "stuff.h"
  506.  
  507. new_planets(p,n,size,type,dec)
  508. PLANDATA **p;
  509. char type;
  510. {
  511. PLANDATA *q,*r;
  512. int z1,z2;
  513. char *name();
  514.  
  515.     switch(type)
  516.     {
  517.     case 'B':
  518.         z1=0;
  519.     case 'A':
  520.         z1=2;
  521.     case 'F':
  522.         z1=4;
  523.     case 'G':
  524.         z1=6;
  525.     case 'K':
  526.         z1=8;
  527.     case 'M':
  528.         z1=10;
  529.     }
  530.     if (dec>=5)
  531.         z1++;
  532.     if (type=='M' && dec==9)
  533.         z1++;
  534.     z2=size;
  535.     for (r=NULL,n--;n>=0;n--,r=q)
  536.     {
  537.         q=(PLANDATA *)malloc(sizeof(PLANDATA));
  538.         strcpy(q->name,name());
  539.         q->type=' ';
  540.         q->orbit=n;
  541.         q->zone=zones[z2][z1][(n<15)?n:14];
  542.         q->main=0;
  543.         q->sats=NULL;
  544.         q->notes=NULL;
  545.         q->next=r;
  546.     }
  547.     *p=r;
  548. }
  549.  
  550. empty(s)
  551. SYSDATA *s;
  552. {
  553. int n;
  554. PLANDATA *p;
  555.  
  556.     if (die(1)>=5)
  557.     {
  558.         n=die(1);
  559.         switch (n)
  560.         {
  561.         case 1:
  562.         case 2:
  563.             n=1;
  564.             break;
  565.         case 3:
  566.             n=2;
  567.             break;
  568.         default:
  569.             n=3;
  570.             break;
  571.         }
  572.         if (n>s->free)
  573.             n=s->free;
  574.         while (n>0)
  575.             for (p=s->orb0; p!=NULL && n>0; p=p->next)
  576.                 if (die(1)==6)
  577.                 {
  578.                     p->type='E';
  579.                     n--;
  580.                     s->free--;
  581.                 }
  582.     }
  583. }
  584.  
  585. capt(s)
  586. SYSDATA *s;
  587. {
  588. int n;
  589. PLANDATA *p;
  590.  
  591.     if (die(1)>=5)
  592.     {
  593.         n=(die(1)+1)/2;
  594.         if (n>s->orbits)
  595.             n=s->orbits;
  596.         while (n>0)
  597.             for (p=s->orb0; p!=NULL && n>0; p=p->next)
  598.                 if (die(1)==6)
  599.                 {
  600.                     p->capt=die(2)-7;
  601.                     n--;
  602.                 }
  603.     }
  604. }
  605.  
  606. gasgiants(s)
  607. SYSDATA *s;
  608. {
  609. int n;
  610. PLANDATA *p;
  611.  
  612.     if (die(2)<10)
  613.     {
  614.         n=ggno[die(2)+ggDM];
  615.         if (n>s->free)
  616.             n=s->free;
  617.         if (n==0)
  618.         {
  619.             n=1;
  620.             s->orbits++;
  621.             s->free++;
  622.             for (p=s->orb0; p->next; p=p->next)
  623.                 ;
  624.             p->next=(PLANDATA *)malloc(sizeof(PLANDATA));
  625.             if (p->zone=='I')
  626.                 p->next->zone='I';
  627.             else
  628.                 p->next->zone='O';
  629.             strcpy(p->next->name,name());
  630.             p->next->type=' ';
  631.             p->next->orbit=p->orbit+1;
  632.             p->next->main=0;
  633.             p->next->sats=NULL;
  634.             p->next->notes=NULL;
  635.             p->next->next=NULL;
  636.         }
  637.         s->gg=n;
  638.         while (n>0)
  639.             for (p=s->orb0; p && n>0;p=p->next)
  640.                 if (p->type==' ' && die(1)==6)
  641.                 {
  642.                     p->type=(die(1)<4)?'L':'S';
  643.                     n--;
  644.                     s->free--;
  645.                 }
  646.     }
  647.  
  648. planetoids(s)
  649. SYSDATA *s;
  650. {
  651. int n;
  652. PLANDATA *p;
  653.  
  654.     if (die(2)-s->gg<=6)
  655.     {
  656.         n=die(2)-s->gg;
  657.         n=plno[(n<0)?0:n];
  658.         if (n>s->free)
  659.             n=s->free;
  660.         if (n!=0)
  661.         {
  662.             for (p=s->orb0;p && n>0;p=p->next)
  663.                 if (p->type==' ' &&  p->next && (p->next->type=='S' || p->next->type=='L'))
  664.                 {
  665.                     p->type='P';
  666.                     n--;
  667.                     s->free--;
  668.                 }
  669.             while (n>0)
  670.                 for (p=s->orb0;p && n>0; p=p->next)
  671.                     if (p->type==' ' && die(1)==6)
  672.                     {
  673.                         p->type='P';
  674.                         n--;
  675.                         s->free--;
  676.                     }
  677.         }
  678.     }
  679. }
  680.  
  681. wsize(s)
  682. SYSDATA *s;
  683. {
  684. PLANDATA *p;
  685.  
  686.     for (p=s->orb0; p; p=p->next)
  687.     {
  688.         if (p->type=='P')
  689.             p->size=0;
  690.         if (p->type!=' ')
  691.             continue;
  692.         p->type='W';
  693.         p->size=die(2)-2;
  694.         if (p->orbit==0) p->size-=5;
  695.         if (p->orbit==1) p->size-=4;
  696.         if (p->orbit==2) p->size-=2;
  697.         if (s->ptype=='M') p->size-=2;
  698.         if (p->size<=0) p->size= -1;
  699.     }
  700. }
  701.  
  702. watm(s)
  703. SYSDATA *s;
  704. {
  705. PLANDATA *p;
  706.  
  707.     for (p=s->orb0; p; p=p->next)
  708.     {
  709.          if (p->type!='W' && p->type!='P')
  710.              continue;
  711.          p->atm=die(2)-7+p->size;
  712.          if (p->zone=='I') p->atm-=2;
  713.          if (p->zone=='O') p->atm-=4;
  714.          if (p->size==0) p->atm=0;
  715.          if (p->atm<0) p->atm=0;
  716.          if (p->atm>15) p->atm=15;
  717.     }
  718. }
  719.  
  720.  
  721. whyd(s)
  722. SYSDATA *s;
  723. {
  724. PLANDATA *p;
  725.  
  726.     for (p=s->orb0; p; p=p->next)
  727.     {
  728.          if (p->type!='W' && p->type!='P')
  729.              continue;
  730.          p->hyd=die(2)-7+p->size;
  731.          if (p->zone=='I') p->hyd=0;
  732.          if (p->zone=='O') p->hyd-=2;
  733.          if (p->size<2) p->hyd=0;
  734.          if (p->atm<2 || p->atm>9) p->hyd-=4;
  735.          if (p->hyd<0) p->hyd=0;
  736.          if (p->hyd>10) p->hyd=10;
  737.     }
  738. }
  739.  
  740. wpop(s)
  741. SYSDATA *s;
  742. {
  743. PLANDATA *p;
  744.  
  745.     for (p=s->orb0; p; p=p->next)
  746.     {
  747.          if (p->type!='W' && p->type!='P')
  748.              continue;
  749.          p->pop=die(2)-2;
  750.          if (p->zone=='I') p->pop-=5;
  751.          if (p->zone=='O') p->pop-=3;
  752.          if (p->atm!=0 && p->atm!=5 && p->atm!=6 && p->atm!=8) p->pop-=2;
  753.          if (p->pop<0) p->pop=0;
  754.     }
  755. }
  756. End of sysgen/planets.c
  757.  echo sysgen/print.c 1>&2
  758. cat >sysgen/print.c <<'End of sysgen/print.c'
  759. #include "stuff.h"
  760.  
  761. print(s)
  762. SYSDATA *s;
  763. {
  764. PLANDATA *p;
  765. SATDATA *sat;
  766. char *prss();
  767.  
  768.     if (mapflag) return;
  769.     printf("         %-15s   %c%d %-2s\n",s->name,s->ptype,
  770.                  s->pdec,prss(s->psize));
  771.     for (p=s->orb0; p; p=p->next)
  772.     {
  773.         putchar(' ');
  774.         if (p->zone=='H') putchar('*'); else putchar(' ');
  775.         printf(" %2d   ",p->orbit);
  776.         if (p->type=='L')
  777.             printf(" %-15s  Large GG\n",p->name);
  778.         else if (p->type=='S')
  779.             printf(" %-15s  Small GG\n",p->name);
  780.         else if (p->type!='E')
  781.             prpl(p,s);
  782.         else
  783.         {
  784.             printf("  Orbit Empty \n");
  785.             continue;
  786.         }
  787.         for (sat=p->sats; sat; sat=sat->next)
  788.         {
  789.             printf("     %3d", sat->orbit);
  790.             prsat(sat);
  791.         }
  792.     }
  793. }
  794.  
  795. prpl(p,s)
  796. PLANDATA *p;
  797. SYSDATA *s;
  798. {
  799. char hex(),pshex(),sshex();
  800.  
  801.     if (mapflag) return;
  802.     printf(" %-15s ",p->name);
  803.     printf(" %c",p->sport);
  804.     if (p->type=='P') putchar('0'); else putchar(pshex(p->size));
  805.     printf("%c%c%c%c%c  %c  ",hex(p->atm),hex(p->hyd),hex(p->pop),
  806.                 hex(p->gov),hex(p->law),hex(p->tech));
  807.     if (s!=0) plfacts(p,s);
  808.     if (p->notes)
  809.         printf(" %s",p->notes);
  810.     putchar('\n');
  811. }
  812.  
  813. prsat(p)
  814. SATDATA *p;
  815. {
  816. char hex(),pshex(),sshex();
  817.  
  818.     if (mapflag) return;
  819.     printf(" %-15s ",p->name);
  820.     printf(" %c",p->sport);
  821.     putchar(sshex(p->size));
  822.     printf("%c%c%c%c%c  %c  ",hex(p->atm),hex(p->hyd),hex(p->pop),
  823.                 hex(p->gov),hex(p->law),hex(p->tech));
  824.     if (p->notes)
  825.         printf(" %s",p->notes);
  826.     putchar('\n');
  827. }
  828.  
  829. char *prss(n)
  830. {
  831.     switch(n)
  832.     {
  833.     case 0:
  834.         return "Ia";
  835.         break;
  836.     case 1:
  837.         return "Ib";
  838.         break;
  839.     case 2:
  840.         return "II";
  841.         break;
  842.     case 3:
  843.         return "III";
  844.         break;
  845.     case 4:
  846.         return "IV";
  847.         break;
  848.     case 5:
  849.         return "V";
  850.         break;
  851.     case 6:
  852.         return "VI";
  853.         break;
  854.     case 7:
  855.         return "D";
  856.         break;
  857.     }
  858. }
  859.  
  860. char hex(n)
  861. {
  862.     if (n<0) return '0';
  863.     if (n<10) return '0'+n;
  864.     return n-10+'A';
  865. }
  866.  
  867. char pshex(n)
  868. {
  869.     if (n<=0) return 'S';
  870.     else return hex(n);
  871. }
  872.  
  873. char sshex(n)
  874. {
  875.     if (n<0) return 'S'; 
  876.     else if (n==0) return 'R';
  877.     else return hex(n);
  878. }
  879.  
  880. plfacts(p,s)
  881. PLANDATA *p;
  882. SYSDATA *s;
  883. {
  884. FACDATA f;
  885. int w,l,i,cl,z1;
  886. double lum,dist;
  887. double sqrt();
  888.  
  889.     f.green=grtab[p->atm];
  890.     f.cloud=cloud[p->hyd];
  891.     if (p->atm>=10) f.cloud+=4;
  892.     if (p->atm<=3) f.cloud-=2;
  893.     if (p->atm==14) f.cloud=(f.cloud-4)/2;
  894.     w=p->hyd*10;
  895.     l=100-p->hyd;
  896.     i=l/10;
  897.     l-=i/2;
  898.     w-=i/2;
  899.     f.land=l;
  900.     f.water=w;
  901.     f.ice=i;
  902.     cl=100-f.cloud;
  903.     l=l*cl/100;
  904.     w=w*cl/100;
  905.     i=i*cl/100;
  906.     f.albedo=l*15+w*2+f.cloud*60+i*55;
  907.     switch(s->ptype)
  908.     {
  909.     case 'B':
  910.         z1=0;
  911.     case 'A':
  912.         z1=2;
  913.     case 'F':
  914.         z1=4;
  915.     case 'G':
  916.         z1=6;
  917.     case 'K':
  918.         z1=8;
  919.     case 'M':
  920.         z1=10;
  921.     }
  922.     if (s->pdec>=5)
  923.         z1++;
  924.     if (s->ptype=='M' && s->pdec==9)
  925.         z1++;
  926.     lum=lumtab[s->psize][z1];
  927.     dist=dtab[p->orbit];
  928.     f.temp=374.025*f.green*(100-f.albedo)*sqrt(sqrt(lum))/sqrt(dist);
  929. }
  930. End of sysgen/print.c
  931.  echo sysgen/rnd.c 1>&2
  932. cat >sysgen/rnd.c <<'End of sysgen/rnd.c'
  933. #include "stuff.h"
  934.  
  935. static s;
  936.  
  937. rand(n)
  938. {
  939. double rnd();
  940.  
  941.     return (random()%n+1);
  942. }
  943.  
  944. iseed(q)
  945. int q;
  946. {
  947.     srandom(q);
  948. }
  949.  
  950. char *name()
  951. {
  952. static char st[20];
  953. int i,j,l;
  954.  
  955.     l=rand(7)+3;
  956.     st[l+1]='\0';
  957.     i=rand(1000);
  958.     for (j=0;freq[j]<i;j++)
  959.         ;
  960.     st[l--]=lt[j];
  961.     while (l>=0)
  962.     {
  963.         if (i<vowel)
  964.             i=rand(1000-vowel)+vowel;
  965.         else
  966.             i=rand(vowel);
  967.         for (j=0;freq[j]<i;j++)
  968.             ;
  969.         st[l--]=lt[j];
  970.     }
  971.     st[0]=toupper(st[0]);
  972.     return st;
  973. }
  974.  
  975. die(n)
  976. {
  977. int i,j;
  978.  
  979.     j=0;
  980.     for (i=0;i<n;i++)
  981.         j+=rand(DIE);
  982.     return j;
  983. }
  984. End of sysgen/rnd.c
  985.  echo sysgen/sats.c 1>&2
  986. cat >sysgen/sats.c <<'End of sysgen/sats.c'
  987. #include "stuff.h"
  988.  
  989. sats(s)
  990. SYSDATA *s;
  991. {
  992. PLANDATA *p;
  993.  
  994.     for (p=s->orb0; p; p=p->next)
  995.         switch(p->type)
  996.         {
  997.         case 'L':
  998.             new_sats(&p->sats,die(2));
  999.             break;
  1000.         case 'S':
  1001.             new_sats(&p->sats,die(2)-4);
  1002.             break;
  1003.         case 'W':
  1004.             new_sats(&p->sats,die(1)-3);
  1005.             break;
  1006.         default:
  1007.             p->sats=NULL;
  1008.         }
  1009. }
  1010.  
  1011. new_sats(p,n)
  1012. SATDATA **p;
  1013. {
  1014. SATDATA *r, *q;
  1015. char *name();
  1016.  
  1017.     if (n<=0)
  1018.         *p=NULL;
  1019.     else
  1020.     {
  1021.         for (r=NULL;n;r=q,n--)
  1022.         {
  1023.             q=(SATDATA *)malloc(sizeof(SATDATA));
  1024.             strcpy(q->name,name());
  1025.             q->main=0;
  1026.             q->notes=NULL;
  1027.             q->next=r;
  1028.         }
  1029.         *p=r;
  1030.     }
  1031. }
  1032.  
  1033. satwsize(s)
  1034. SYSDATA *s;
  1035. {
  1036. PLANDATA *p;
  1037.  
  1038.     for (p=s->orb0; p; p=p->next)
  1039.         satsize(p);
  1040. }
  1041.  
  1042. satsize(p)
  1043. PLANDATA *p;
  1044. {
  1045. SATDATA *s;
  1046.  
  1047.     for (s=p->sats; s; s=s->next)
  1048.     {
  1049.         switch(p->type)
  1050.         {
  1051.         case 'L':
  1052.             s->size=die(2)-4;
  1053.             break;
  1054.         case 'S':
  1055.             s->size=die(2)-6;
  1056.             break;
  1057.         case 'W':
  1058.             s->size=p->size-die(1);
  1059.             break;
  1060.         }
  1061.         if (s->size<0) s->size= -1; /*SMALL*/
  1062.         if (s->size>10) s->size= 10;
  1063.     }
  1064. }
  1065.  
  1066. satworbit(s)
  1067. SYSDATA *s;
  1068. {
  1069. PLANDATA *p;
  1070.  
  1071.     for (p=s->orb0; p; p=p->next)
  1072.         satorbit(p);
  1073. }
  1074.  
  1075. satorbit(p)
  1076. PLANDATA *p;
  1077. {
  1078. SATDATA *s,*r;
  1079. int otype,swap;
  1080. int DM;
  1081.  
  1082.     DM=0;
  1083.     for (s=p->sats; s; s=s->next,DM++)
  1084.     {
  1085.         otype=die(2)-DM;
  1086.         if (s->size==0) s->orbit=ring[die(1)];
  1087.         else if (otype<8) s->orbit=clos[die(2)];
  1088.         else if (otype==12 && (p->type=='L' || p->type=='S'))
  1089.             s->orbit=extreme[die(2)];
  1090.         else if (otype>7) s->orbit=far[die(2)];
  1091.     }
  1092.     swap=1;
  1093.     s=p->sats;
  1094.     while (s && s->next && swap)
  1095.     {
  1096.         s=p->sats;
  1097.         swap=0;
  1098.         if (s->orbit>s->next->orbit)
  1099.         {
  1100.             p->sats=s->next;
  1101.             s->next=p->sats->next;
  1102.             p->sats->next=s;
  1103.             swap=1;
  1104.         }
  1105.         for (s=p->sats; s->next->next; s=s->next)
  1106.         {
  1107.             r=s->next;
  1108.             if (r->orbit>r->next->orbit)
  1109.             {
  1110.                 s->next=r->next;
  1111.                 r->next=r->next->next;
  1112.                 s->next->next=r;
  1113.                 swap=1;
  1114.             }
  1115.         }
  1116.     }
  1117.     for (s=p->sats; s && s->next;)
  1118.         if (s->orbit==s->next->orbit)
  1119.         {
  1120.             r=s->next;
  1121.             s->next=r->next;
  1122.             free(r);
  1123.         }
  1124.         else
  1125.             s=s->next;
  1126. }
  1127.  
  1128. satwatm(s)
  1129. SYSDATA *s;
  1130. {
  1131. PLANDATA *p;
  1132.  
  1133.     for (p=s->orb0; p; p=p->next)
  1134.         satatm(p);
  1135. }
  1136.  
  1137. satatm(p)
  1138. PLANDATA *p;
  1139. {
  1140. SATDATA *s;
  1141.  
  1142.     for (s=p->sats; s; s=s->next)
  1143.     {
  1144.          s->atm=die(2)-7+s->size;
  1145.          if (p->zone=='I') s->atm-=4;
  1146.          if (p->zone=='O') s->atm-=4;
  1147.          if (s->size<2) s->atm=0;
  1148.          if (s->atm<0) s->atm=0;
  1149.          if (s->atm>15) s->atm=15;
  1150.     }
  1151. }
  1152.  
  1153. satwhyd(s)
  1154. SYSDATA *s;
  1155. {
  1156. PLANDATA *p;
  1157.  
  1158.     for (p=s->orb0; p; p=p->next)
  1159.         sathyd(p);
  1160. }
  1161.  
  1162. sathyd(p)
  1163. PLANDATA *p;
  1164. {
  1165. SATDATA *s;
  1166.  
  1167.     for (s=p->sats; s; s=s->next)
  1168.     {
  1169.         s->hyd=die(2)-7+s->size;
  1170.         if (p->zone=='I') s->hyd=0;
  1171.         if (p->zone=='O') s->hyd-=4;
  1172.         if (s->size<=0) s->hyd=0;
  1173.         if (s->atm<2 || s->atm>9) s->hyd-=4;
  1174.         if (s->hyd<0) s->hyd=0;
  1175.         if (s->hyd>10) s->hyd=10;
  1176.     }
  1177. }
  1178.  
  1179. satwpop(s)
  1180. SYSDATA *s;
  1181. {
  1182. PLANDATA *p;
  1183.  
  1184.     for (p=s->orb0; p; p=p->next)
  1185.         satpop(p);
  1186. }
  1187.  
  1188. satpop(p)
  1189. PLANDATA *p;
  1190. {
  1191. SATDATA *s;
  1192.  
  1193.     for (s=p->sats; s; s=s->next)
  1194.     {
  1195.         s->pop=die(2)-2;
  1196.         if (p->zone=='I') s->pop-=5;
  1197.         if (p->zone=='O') s->pop-=4;
  1198.         if (s->atm!=5 && s->atm!=6 && s->atm!=8) s->pop-=2;
  1199.         if (s->size<5) s->pop-=2;
  1200.         if (s->size==0) s->pop=0;
  1201.         if (s->pop<0) s->pop=0;
  1202.         if (s->pop>10) s->pop=10;
  1203.     }
  1204. }
  1205. End of sysgen/sats.c
  1206.  echo sysgen/st.c 1>&2
  1207. cat >sysgen/st.c <<'End of sysgen/st.c'
  1208. #include "stuff.h"
  1209.  
  1210. main(argc,argv)
  1211. char **argv;
  1212. {
  1213. int i,j,mxi,mxj;
  1214. char sysnat(), stype();
  1215.  
  1216.     init(argc,argv,&mxi,&mxj);
  1217.     for (i=1;i<=mxi;i++)
  1218.     {
  1219.         for (j=1;j<=mxj;j++)
  1220.         {
  1221.             spa[i][j]=' ';
  1222.             if (syspres(0))
  1223.             {
  1224.                 if (!mapflag) printf("\fSystem At (%02d%02d)\n\n",i,j);
  1225.                 strcpy(syst.name,name());
  1226.                 syst.nature=sysnat();
  1227.                 syst.ptype=stype(0);
  1228.                 syst.psize=ssize(0,syst.ptype);
  1229.                 syst.pdec=rand(10)-1;
  1230.                 if (syst.nature!='S')
  1231.                 {
  1232.                     syst.ctype=stype(1);
  1233.                     syst.csize=ssize(1,syst.ctype);
  1234.                     syst.cdec=rand(10)-1;
  1235.                 }
  1236.                 syst.orbits=nbrorbs(syst.psize,syst.ptype);
  1237.                 syst.free=syst.orbits;
  1238.                 new_planets(&syst.orb0,syst.orbits,syst.psize,syst.ptype,
  1239.                              syst.pdec);
  1240.                 syst.notes=NULL;
  1241.                 empty(&syst);
  1242.                 capt(&syst);
  1243.                 gasgiants(&syst);
  1244.                 planetoids(&syst);
  1245.                 wsize(&syst);
  1246.                 watm(&syst);
  1247.                 whyd(&syst);
  1248.                 wpop(&syst);
  1249.                 sats(&syst);
  1250.                 satwsize(&syst);
  1251.                 satworbit(&syst);
  1252.                 satwatm(&syst);
  1253.                 satwhyd(&syst);
  1254.                 satwpop(&syst);
  1255.                 mworld(&syst);
  1256.                 sub(&syst);
  1257.     
  1258.                 print(&syst);
  1259.                 css->x=i;
  1260.                 css->y=j;
  1261.                 spa[i][j]=freeup(&syst);
  1262.             }
  1263.         }
  1264.     }
  1265.     if (!mapflag)
  1266.     {
  1267.         putchar('\f');
  1268.         for (css=subsect; css->next; css=css->next)
  1269.         {
  1270.             printf("%02d%02d  ",css->x,css->y);
  1271.             if (!css->planet && !css->sat) printf(" %s system UNINHABITED\n",css->name);
  1272.             if (css->planet) prpl(css->planet,0);
  1273.             if (css->sat) prsat(css->sat,0);
  1274.         }
  1275.         printf("\f       ");
  1276.         for (i=1;i<=mxi;i++)
  1277.             printf("%02dxx ",i);
  1278.         putchar('\n');
  1279.         for (j=1;j<=mxj;j++)
  1280.         {
  1281.             printf(" xx%02d ",j);
  1282.             for (i=1;i<=mxi;i+=2)
  1283.                 printf("  %2c      ",spa[i][j]);
  1284.             printf("\n      ");
  1285.             for (i=2;i<=mxi;i+=2)
  1286.                 printf("       %2c ",spa[i][j]);
  1287.             putchar('\n');
  1288.         }
  1289.     }
  1290.     else
  1291.     {
  1292.         for (css=subsect;css->next;css=css->next)
  1293.         {
  1294.             printf("%d %d ",css->x-1,css->y-1);
  1295.             if (!css->planet && !css->sat) printf("%s %c\n",css->name,spa[css->x][css->y]);
  1296.             if (css->planet) printf("%s %c\n",css->planet->name,css->planet->sport);
  1297.             if (css->sat)  printf("%s %c\n",css->sat->name,css->sat->sport);
  1298.         }
  1299.         printf("99\n");
  1300.     }
  1301. }
  1302. End of sysgen/st.c
  1303.  echo sysgen/stuff.h 1>&2
  1304. cat >sysgen/stuff.h <<'End of sysgen/stuff.h'
  1305. #include <stdio.h>
  1306. #include <ctype.h>
  1307. #include "const.h"
  1308. #include "types.h"
  1309. #include "glob.h"
  1310. End of sysgen/stuff.h
  1311.  echo sysgen/sub.c 1>&2
  1312. cat >sysgen/sub.c <<'End of sysgen/sub.c'
  1313. #include "stuff.h"
  1314.  
  1315. sub(s)
  1316. SYSDATA *s;
  1317. {
  1318. PLANDATA *p;
  1319. SATDATA *sat;
  1320. int sp;
  1321.  
  1322.     for (p=s->orb0; p; p=p->next)
  1323.     {
  1324.         if (!p->main && p->type!='L' && p->type!='S')
  1325.         {
  1326.             p->gov=die(1);
  1327.             if (mwgov==6) p->gov=6;
  1328.             if (mwgov>=7) p->gov+=2;
  1329.             if (p->pop==0) p->gov=0;
  1330.             p->law=die(1)-3+mwlaw;
  1331.             if (p->gov==0) p->law=0;
  1332.             p->tech=mwtech-1+facility(&p->notes,p->zone,p->size,p->atm,p->hyd,
  1333.                       p->pop,p->gov,p->law);
  1334.             if (p->pop==0) p->tech=0;
  1335.             sp=die(1);
  1336.             if (p->pop>=6) sp+=2;
  1337.             if (p->pop<2) sp-=2;
  1338.             if (sp<1) sp=1;
  1339.             if (sp>6) sp=6;
  1340.             if (p->pop>0) p->sport=spaceport[sp]; else p->sport='Y';
  1341.         }
  1342.         for (sat=p->sats; sat; sat=sat->next)
  1343.         {
  1344.             if (!sat->main)
  1345.             {
  1346.                 sat->gov=die(1);
  1347.                 if (mwgov==6) sat->gov=6;
  1348.                 if (mwgov>=7) sat->gov+=2;
  1349.                 if (sat->pop==0) sat->gov=0;
  1350.                 sat->law=die(1)-3+mwlaw;
  1351.                 if (sat->gov==0) sat->law=0;
  1352.                 sat->tech=mwtech-1+facility(&sat->notes,p->zone,sat->size,
  1353.                            sat->atm,sat->hyd,sat->pop,sat->gov,sat->law);
  1354.                 if (sat->pop==0) sat->tech=0;
  1355.                 sp=die(1);
  1356.                 if (sat->pop>=6) sp+=2;
  1357.                 if (sat->pop<2) sp-=2;
  1358.                 if (sp<1) sp=1;
  1359.                 if (sp>6) sp=6;
  1360.                 if (sat->pop>0) sat->sport=spaceport[sp]; else sat->sport='Y';
  1361.             }
  1362.         }
  1363.     }
  1364. }
  1365.  
  1366. facility(notes,zone,size,atm,hyd,pop,gov,law)
  1367. char **notes;
  1368. char zone;
  1369. {
  1370. int bonus; /* TL bonus for lab or base */
  1371.  
  1372.     bonus=0;
  1373.     if (zone=='H' && atm>=4 && atm<=9 && hyd>=4 && hyd<=8 && pop>=2)
  1374.         addstr(notes,"Farming");
  1375.     if (mwind && pop>=2)
  1376.         addstr(notes,"Mining");
  1377.     if (gov==6  && pop>=5)
  1378.         addstr(notes,"Colony");
  1379.     if ((die(2)+((mwtech>=10)?2:0)>=11) && mwtech>8 && pop>0)
  1380.     {
  1381.         addstr(notes,"Lab.");
  1382.         bonus=1;
  1383.     }
  1384.     if (die(2)+((mwpop>=8)?1:0)+((atm==mwatm)?2:0)+(base?1:0)>=12 && pop>0 &&
  1385.            !mwpoor)
  1386.     {
  1387.         addstr(notes,"Mil. Base");
  1388.         bonus=1;
  1389.     }
  1390.     return bonus;
  1391. }
  1392. End of sysgen/sub.c
  1393.  echo sysgen/support.c 1>&2
  1394. cat >sysgen/support.c <<'End of sysgen/support.c'
  1395. #include "stuff.h"
  1396. char *malloc(), *realloc(), *strcpy(), *strcat();
  1397.  
  1398. addstr(p,q)
  1399. char **p,*q;
  1400. {
  1401.     if (*p==NULL)
  1402.         *p=strcpy(malloc(strlen(q)+1),q);
  1403.     else
  1404.         *p=strcat(strcat(realloc(*p,strlen(*p)+strlen(q)+2)," "),q);
  1405. }
  1406.  
  1407. freeup(s)
  1408. SYSDATA *s;
  1409. {
  1410. PLANDATA *p;
  1411. SATDATA *sat;
  1412. char sp;
  1413.  
  1414.     sp='X';
  1415.     css->planet=NULL;
  1416.     css->sat=NULL;
  1417.     css->name=strcpy(malloc(strlen(s->name)+1),s->name);
  1418.     for (p=s->orb0; p; p=p->next)
  1419.     {
  1420.         for (sat=p->sats; sat; sat=sat->next)
  1421.             if (sat->main)
  1422.             {
  1423.                 css->sat=sat;
  1424.                 sp=sat->sport;
  1425.             }
  1426.             else
  1427.                 free(sat);
  1428.         if (p->main)
  1429.         {
  1430.             p->sats=NULL;
  1431.             css->planet=p;
  1432.             sp=p->sport;
  1433.         }
  1434.         else
  1435.             free(p);
  1436.     }
  1437.     css->next=(SUBDATA *)malloc(sizeof(SUBDATA));
  1438.     css=css->next;
  1439.     css->planet=NULL;
  1440.     css->sat=NULL;
  1441.     css->next=NULL;
  1442.     return sp;
  1443. }
  1444. End of sysgen/support.c
  1445.  echo sysgen/system.c 1>&2
  1446. cat >sysgen/system.c <<'End of sysgen/system.c'
  1447. #include "stuff.h"
  1448.  
  1449. syspres(fudge)
  1450. {
  1451.     if (die(1)+fudge>=4)
  1452.         return 1;
  1453.     else
  1454.         return 0;
  1455. }
  1456.  
  1457. char sysnat()
  1458. {
  1459.     return nature[die(2)+natDM];
  1460. }
  1461.  
  1462. char stype(f)
  1463. {
  1464.     if (f==0)
  1465.         return ptypet[die(2)+typeDM];
  1466.     else
  1467.         return ctypet[die(2)+typeDM];
  1468. }
  1469.  
  1470. ssize(f,t)
  1471. char t;
  1472. {
  1473. int s;
  1474.  
  1475.     if (f==0)
  1476.         s=psizet[die(2)+sizeDM];
  1477.     else
  1478.         s=csizet[die(2)+sizeDM];
  1479.     if (s==4 && (t=='K' || t=='M'))
  1480.         s=5;
  1481.     if (s==6 && (t=='B' || t=='A' || t=='F'))
  1482.         s=5;
  1483.     return s;
  1484. }
  1485.  
  1486. nbrorbs(s,t)
  1487. char t;
  1488. {
  1489. int o;
  1490.  
  1491.     o=die(2);
  1492.     if (s==3) o+=4;
  1493.     if (s<=2) o+=8;
  1494.     if (t=='M') o-=4;
  1495.     if (t=='K') o-=2;
  1496.     if (o<1) o=1;
  1497.     return o;
  1498. }
  1499. End of sysgen/system.c
  1500.  echo sysgen/types.h 1>&2
  1501. cat >sysgen/types.h <<'End of sysgen/types.h'
  1502. typedef struct factors {
  1503.     int cloud;
  1504.     int albedo;
  1505.     int green;
  1506.     int land;
  1507.     int water;
  1508.     int ice;
  1509.     int temp;
  1510.     int tilt;
  1511.     int ecc;
  1512. } FACDATA;
  1513.  
  1514. typedef struct subsector {
  1515.     int x;
  1516.     int y;
  1517.     struct planet *planet;
  1518.     struct sat *sat;
  1519.     char *name;
  1520.     struct subsector *next;
  1521. } SUBDATA;
  1522.  
  1523. typedef struct system {
  1524.     char name[20];
  1525.     char nature;
  1526.     char ptype;
  1527.     int pdec;
  1528.     int psize;
  1529.     char ctype;
  1530.     int cdec;
  1531.     int csize;
  1532.     int orbits;
  1533.     int free;
  1534.     int gg;
  1535.     char *notes;
  1536.     struct planet *orb0;
  1537. } SYSDATA;
  1538.  
  1539. typedef struct planet {
  1540.     char name[20];
  1541.     int orbit;
  1542.     char zone;
  1543.     char type;
  1544.     int capt;
  1545.     char sport;
  1546.     int size;
  1547.     int atm;
  1548.     int hyd;
  1549.     int pop;
  1550.     int gov;
  1551.     int law;
  1552.     int tech;
  1553.     int main;
  1554.     char *notes;
  1555.     struct sat *sats;
  1556.     struct planet *next;
  1557. } PLANDATA;
  1558.  
  1559. typedef struct sat {
  1560.     char name[20];
  1561.     int orbit;
  1562.     char sport;
  1563.     int size;
  1564.     int atm;
  1565.     int hyd;
  1566.     int pop;
  1567.     int gov;
  1568.     int law;
  1569.     int tech;
  1570.     int main;
  1571.     char *notes;
  1572.     struct sat *next;
  1573. } SATDATA;
  1574. End of sysgen/types.h
  1575.  echo sysprint/Makefile 1>&2
  1576. cat >sysprint/Makefile <<'End of sysprint/Makefile'
  1577. all: trmult
  1578.  
  1579. trmult: trmult.o
  1580.     cc -o trmult trmult.o
  1581. End of sysprint/Makefile
  1582.  echo sysprint/mass 1>&2
  1583. cat >sysprint/mass <<'End of sysprint/mass'
  1584. trmult 4 4 stars.ps m1[3456]00 m900 m1[012]00 m[5678]00 m[1234]00
  1585. End of sysprint/mass
  1586.  echo sysprint/stars.ps 1>&2
  1587. cat >sysprint/stars.ps <<'End of sysprint/stars.ps'
  1588. /incx { 126 } def
  1589. /incy {  72 } def
  1590. /offset { 15 } def
  1591. /coffset { 35 } def
  1592. /stdfont { /Times-Roman findfont } def
  1593. /add36 { 36 sub } def
  1594. /setgrey { setgray } def
  1595. /grey4 { 0.1 setgrey 6 setlinewidth} def
  1596. /black1 {0 setgrey 1 setlinewidth} def
  1597. /grid {            % - GRID -
  1598. -21  36 rmoveto
  1599. -21 -36 rlineto
  1600.  21 -36 rlineto
  1601.  42   0 rlineto
  1602.  21  36 rlineto
  1603. -21  36 rlineto
  1604.  21 -36 rmoveto
  1605.  42   0 rlineto
  1606. } def
  1607. /top {            % - TOP -
  1608. -21  36 rmoveto
  1609.  42   0 rlineto
  1610. } def
  1611. /right {        % - RIGHT -
  1612.  84   0 rmoveto
  1613.  21 -36 rlineto
  1614. -21 -36 rlineto
  1615. } def
  1616. /bottom {        % - BOTTOM -
  1617.  21 -36 rmoveto
  1618.  21 -36 rlineto
  1619.  42   0 rlineto
  1620.  21  36 rlineto
  1621. } def
  1622. /coords {        % string COORDS -
  1623.   0 24 rmoveto
  1624.   dup            % duplicate string
  1625.   stringwidth
  1626.   pop
  1627.   2 div neg
  1628.   0
  1629.   rmoveto
  1630.   show            % second copy of string
  1631. } def
  1632. /starport {        % string STARPORT -
  1633.   dup
  1634.   stringwidth
  1635.   offset add exch
  1636.   2 div neg exch
  1637.   rmoveto
  1638.   show
  1639. } def
  1640. /name {            % string NAME -
  1641.   dup
  1642.   stringwidth
  1643.   pop offset neg exch
  1644.   2 div neg exch
  1645.   rmoveto
  1646.   show
  1647. } def
  1648. /conv2 {            % x (0:7) y (0:9) CONV2 x (minx:maxx) y (miny:maxy)
  1649.   9 exch sub    % 9-y
  1650.   incy mul        % (9-y)*incy
  1651.   miny add        % (9-y)*incy+miny
  1652.   exch            % stack: y x
  1653.   dup            % dup to give us second value for test
  1654.   2 mod 0 ne    % test for even column
  1655.   exch            % stack: y bool x
  1656.   incx 2 div mul% x*incx
  1657.   minx add        % x*incx+minx
  1658.   3 1 roll        % stack: x y bool
  1659.   {add36} if    % make y correction
  1660. } def
  1661. /conv {                % x (0:7) y (0:9) CONV -
  1662.   conv2
  1663.   moveto
  1664. } def
  1665. /pname {        % string x y PNAME -
  1666.   conv
  1667.   name
  1668. } def
  1669. /pport {        % string x y PNAME -
  1670.   conv
  1671.   starport
  1672. } def
  1673. /ccord {        % string x y CCORD -
  1674.   conv
  1675.   coords
  1676. } def
  1677. /route {        % x y x y ROUTE -
  1678.   4 setlinewidth
  1679.   conv
  1680.   conv2
  1681.   lineto
  1682.   stroke
  1683. } def
  1684. /Nbord {        % 0 Nbord -
  1685.   pop
  1686.   -21 36 rmoveto
  1687.   42 0 rlineto
  1688.   grey4
  1689.   stroke
  1690.   black1
  1691. } def
  1692. /NEbord {        % - NEbord -
  1693.   21 36 rmoveto
  1694.   21 -36 rlineto
  1695.   grey4
  1696.   stroke
  1697.   black1
  1698. } def
  1699. /SEbord {        % - SEbord -
  1700.   42 0 rmoveto
  1701.   -21 -36 rlineto
  1702.   grey4
  1703.   stroke
  1704.   black1
  1705. } def
  1706. /NSEbord {        % side NSEBORD -
  1707.   1 eq {NEbord} {SEbord} ifelse
  1708. } def
  1709. /border {        % side x y BORDER -
  1710.   conv
  1711.   dup
  1712.   0 eq {Nbord} {NSEbord} ifelse
  1713. } def
  1714. /planet {        % x y PLANET -
  1715.   conv2
  1716.   2 copy
  1717.   moveto
  1718.   -6 -10 rmoveto
  1719.   stdfont 30 scalefont setfont
  1720.   1 setgray
  1721.   (\267) show
  1722.   moveto
  1723.   -4 -7 rmoveto
  1724.   stdfont 20 scalefont setfont
  1725.   0 setgray
  1726.   (\267) show
  1727.   stdfont 10 scalefont setfont
  1728. } def
  1729. /grid2 {        % horiz vert GRID2 horiz
  1730.   2 copy
  1731.   moveto
  1732.   grid
  1733.   pop
  1734. } def
  1735. /grid1 {        % horiz GRID1 -
  1736.   maxy incy neg miny {grid2} for
  1737.   dup
  1738.   maxy moveto top
  1739.   miny moveto bottom
  1740. } def
  1741. /dogrid {        % - DOGRID -
  1742.   minx incx maxx {grid1} for
  1743. } def
  1744. /right1 {        % horiz vert RIGHT1 horiz
  1745.   2 copy
  1746.   moveto
  1747.   right
  1748.   pop
  1749. } def
  1750. /doright {        % - DORIGHT -
  1751.   maxx
  1752.   maxy incy neg miny {right1} for
  1753.   pop
  1754. } def
  1755. End of sysprint/stars.ps
  1756.  echo sysprint/tr22 1>&2
  1757. cat >sysprint/tr22 <<'End of sysprint/tr22'
  1758. trmult 2 2 stars.ps m${1}00 m${2}00 m${3}00 m${4}00
  1759. End of sysprint/tr22
  1760.  echo sysprint/trconv 1>&2
  1761. cat >sysprint/trconv <<'End of sysprint/trconv'
  1762. trmult 1 1 stars.ps $*
  1763. End of sysprint/trconv
  1764.  echo sysprint/trmult.c 1>&2
  1765. cat >sysprint/trmult.c <<'End of sysprint/trmult.c'
  1766. #include <stdio.h>
  1767. #define MAX        80
  1768. #define MAXC    30
  1769.  
  1770. #define MAXX    396
  1771. #define MINX    18
  1772. #define MAXY    702
  1773. #define MINY    54
  1774. #define INCX    126
  1775. #define INCY    72
  1776.  
  1777. main(argc,argv)
  1778. char **argv;
  1779. {
  1780. char name[MAXC],sport[MAXC];
  1781. FILE *fp;
  1782. int c;
  1783. int x,y,dx,dy,xa[MAX],ya[MAX];
  1784. int i,k;
  1785. int xsiz,ysiz;
  1786. int xl,yl;
  1787.  
  1788.     if (argc<5)
  1789.     {
  1790.         fprintf(stderr,"Usage: %s x y psfile starsfile ...\n",argv[0]);
  1791.         exit(-1);
  1792.     }
  1793.     xsiz=atoi(argv[1]);
  1794.     ysiz=atoi(argv[2]);
  1795.     if (argc!=xsiz*ysiz+4)
  1796.     {
  1797.         fprintf(stderr,"You must specify %d stars files\n",xsiz*ysiz);
  1798.         exit(-1);
  1799.     }
  1800.     printf("36 36 translate\n");
  1801.     printf("1 %d div 1 %d div scale\n",xsiz,ysiz);
  1802.     printf("/maxx { %d } def\n",MAXX);
  1803.     printf("/minx { %d } def\n",MINX);
  1804.     printf("/maxy { %d } def\n",MAXY);
  1805.     printf("/miny { %d } def\n",MINY);
  1806.     if (!(fp=fopen(argv[3],"r")))
  1807.     {
  1808.         fprintf(stderr,"Could not open %s\n",argv[3]);
  1809.         exit(-1);
  1810.     }
  1811.     printf("36 36 translate\n");
  1812.     while ((c=getc(fp))!=EOF)
  1813.         putchar(c);
  1814.     fclose(fp);
  1815.     for (yl=0,argv+=4;yl<ysiz;yl++)
  1816.     {
  1817.         if (yl!=0) printf("%d %d translate\n",(1-xsiz)*(MAXX-MINX+INCX),MAXY-MINY+INCY);
  1818.         for (xl=0;xl<xsiz;xl++,argv++)
  1819.         {
  1820.             if (xl!=0) printf("%d 0 translate\n",MAXX-MINX+INCX);
  1821.             printf("stdfont 10 scalefont setfont\n");
  1822.             printf("dogrid\n");
  1823.             printf("doright\n");
  1824.             printf("1 setlinewidth\n");
  1825.             printf("stroke\n");
  1826.             if (!(fp=fopen(*argv,"r")))
  1827.             {
  1828.                 fprintf(stderr,"Could not open %s\n",*argv);
  1829.                 exit(-1);
  1830.             }
  1831.             for (i=0;;i++)
  1832.             {
  1833.                 if ((c=fscanf(fp,"%d",&x))!=1)
  1834.                 {
  1835.                     if (c==EOF)
  1836.                         break;
  1837.                     fprintf(stderr,"Data Format Error! File %s Line %d\n",*argv,i);
  1838.                     exit(-1);
  1839.                 }
  1840.                 if (x==99)
  1841.                     break;
  1842.                 if ((c=fscanf(fp,"%d %s %s",&y,name,sport))!=3)
  1843.                 {
  1844.                     fprintf(stderr,"Data Format Error! File %s Line %d\n",*argv,i);
  1845.                     exit(-1);
  1846.                 }
  1847.                 xa[i]=x;
  1848.                 ya[i]=y;
  1849.                 printf("(%s) %d %d pname\n",name,x,y);
  1850.                 printf("(%s) %d %d pport\n",sport,x,y);
  1851.             }
  1852.             for (k=i++;;i++)
  1853.             {
  1854.                 if ((c=fscanf(fp,"%d",&x))!=1)
  1855.                 {    
  1856.                     if (c==EOF)
  1857.                         break;
  1858.                     fprintf(stderr,"Border Format Error! Line %d\n",i);
  1859.                     exit(-1);
  1860.                 }
  1861.                 if (x==99)
  1862.                     break;
  1863.                 if ((c=fscanf(fp,"%d %d",&y,&dx))!=2)
  1864.                 {
  1865.                     fprintf(stderr,"Border Format Error! Line %d\n",i);
  1866.                     exit (-1);
  1867.                 }
  1868.                 printf("%d %d %d border\n",dx,x-1,y-1);
  1869.             }
  1870.             for (i++;;i++)
  1871.             {
  1872.                 if ((c=fscanf(fp,"%d",&x))!=1)
  1873.                 {
  1874.                     if (c==EOF)
  1875.                         break;
  1876.                     fprintf(stderr,"Route Format Error! Line %d\n",i);
  1877.                     exit(-1);
  1878.                 }
  1879.                 if (x==99)
  1880.                     break;
  1881.                 if ((c=fscanf(fp,"%d %d %d",&y,&dx,&dy))!=3)
  1882.                 {
  1883.                     fprintf(stderr,"Route Format Error! File %s Line %d\n",*argv,i);
  1884.                     exit(-1);
  1885.                 }
  1886.                 printf("%d %d %d %d route\n",x-1,y-1,dx-1,dy-1);
  1887.             }
  1888.             for (i=0;i<k;i++)
  1889.                 printf("%d %d planet\n",xa[i],ya[i]);
  1890.             for (k=0;k<10;k++)
  1891.                 for (i=0;i<8;i++)
  1892.                     printf("(%02d%02d) %d %d ccord\n",i+1,k+1,i,k);
  1893.         }
  1894.     }
  1895.     printf("showpage\n");
  1896. }
  1897. End of sysprint/trmult.c
  1898.  echo sysprint/ts 1>&2
  1899. cat >sysprint/ts <<'End of sysprint/ts'
  1900. #Csh
  1901. foreach i (`nbrs $1 $2 $3`)
  1902.     st -m $i >m$i
  1903. end
  1904. End of sysprint/ts
  1905.  
  1906.  
  1907.