-
Notifications
You must be signed in to change notification settings - Fork 0
/
SectorMaker.sh
1487 lines (1187 loc) · 46.8 KB
/
SectorMaker.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/sh
# SectorMaker.cgi
# by Micki Kaufman micki001@concentric.net
#
# I was looking at my LBB collection, and got an idea, so voila!
# Presenting the Traveller Sector Guidebook .cgi script. Creates and returns
# a high-resolution (vector-art) pdf containing the sector data and hexmaps,
# listed subsector by subsector.
#
# BASIC INSTRUCTIONS
# INSTALLATION
#
# # STEP ONE
# ## install Apple's "Xcode Tools" from http://developer.apple.com/macosx/
#
# # STEP TWO
# ## install the Mac OSX version of pdftk (used for splitting, joining, compressing and overlaying pdf pages) from http://www.pdfhacks.com/pdftk/
#
# # STEP THREE
# ## install pdf-API2 (a perl resource for handling pdfs and fonts) from http://search.cpan.org/~areibens/PDF-API2-0.55/lib/PDF/API2.pm
#
# # STEP FOUR
# ## unzip the SectorMaker archive from http://micki001.cnc.net/trav/SectorMakerScripts.zip and place all the files in the computer's cgi folder. Also, create the output folder.
# mkdir /sectors/autogen
# unzip SectorMakerScripts.zip -d /Library/WebServer/CGI-Executables/
#
# # STEP FIVE
# ## move to the install directory and set the script permissions properly.
# cd /Library/WebServer/CGI-Executables/install
# chmod ugo+x SectorMaker.cgi SectorMaker.sh BatchSectorMaker.sh
#
# # STEP SIX
# ## move the custom CoreFont main file into the newly-installed pdf-api2 CoreFont folder.
# cp pdf-api2/corefont.pm /Library/Perl/5.8.6/PDF/API2/Resource/Font/
#
# # STEP SEVEN
# ## install the custom CoreFont fonts into the newly-installed pdf-api2 CoreFont folder.
# cp pdf-api2/universbold.pm pdf-api2/univers.pm pdf-api2/optima.pm /Library/Perl/5.8.6/PDF/API2/Resource/Font/CoreFont/
#
# # STEP EIGHT
# ## install the required TrueType fonts (a few styles of Univers and Optima) into your computer's '/Library/Fonts/' folder.
# cp ttf/Univers_Bold_Italic.ttf ttf/Univers.ttf ttf/Univers_Bold.ttf ttf/Optima.ttf ttf/Univers_Italic.ttf /Library/Fonts/
#
# # STEP NINE
# ## install the custom SW4 Traveller binaries into your computer's '/usr/bin/' folder.
# cp bin/full-upp bin/mapsub3 bin/subsec2 bin/gensec3 /usr/bin/
#
# # STEP TEN
# ## install enscript files
# cp enscript/enscript.cfg enscript/travellerpagenums.hdr enscript/travellerpagenums2.hdr /usr/share/enscript/
#
#
# # USING THE SCRIPTS
#
# ## To use the script from the command line, navigate to the /Library/WebServer/CGI-Executables folder and use the following syntax:
# ./SectorMaker.sh {sectorname} {density} {tech} {desc} {{secfile}} {{regen}}
#
# ## To use the script from a web browser, use the following URL syntax (you must already have turned on 'Web Sharing', using the 'Sharing' Preference Pane of 'System Preferences'):
# http://[servername]/cgi-bin/SectorMaker.cgi?{sectorname}+{density}+{tech}+{desc}+{{secfile}}+{{regen}}
#
# ## To use the batch sector maker, navigate to the /Library/WebServer/CGI-Executables folder and use the following syntax:
# ./BatchSectorMaker.sh {number of sectors} {tech} {desc}
#
# ./SectorMaker.cgi parameters:
#
# {sectorname}
#
# {density|rift/sparse/scattered/dense or Xx}
#
# {tech|backwater,frontier,mature,cluster}
#
# {desc: Description|1=UPP and Animal,2=just UPP,3=none}
#
# {secfile: Pre-existing sector file name (used if an existing set of .sec, route and alliance
# files is available in trav/sectorfiles)}
#
# {regen: Pre-existing regeneration options|1=use existing file's pre-existing borders and routes,
# 2=only use pre-existing routes,3=only use pre-existing borders and routes}
#
# REQUIRES:
# - Apple's XCode Tools
# http://developer.apple.com/macosx/
# - pstopdf
# (built in on Mac OSX)
# - enscript
# (built in on Mac OSX)
# - pdftk
# http://www.pdfhacks.com/pdftk/
#
# Using sector tools, the sector data and individual subsector data is
# created, and the PostScript hexmap is generated. Using pstopdf, the PostScript
# hexmap is converted to a pdf. Using enscript, the text sector data is
# converted to a PostScript file. Still working on page size. using pdftk, the
# pdf's are overlaid and concatenated together. And then we serve it up!
#
# Far Future Enterprises Fair Use Notice:
# The Traveller game in all forms is owned by Far Future Enterprises. Copyright
# 1977 - 1998 Far Future Enterprises. Traveller is a registered trademark of Far
# Future Enterprises. Far Future permits web sites and fanzines for this game,
# provided it contains this notice, that Far Future is notified, and subject to
# a withdrawal of permission on 90 days notice. The contents of this site are
# for personal, non-commercial use only. Any use of Far Future EnterprisesÕs
# copyrighted material or trademarks anywhere on this web site and its files
# should not be viewed as a challenge to those copyrights or trademarks. In
# addition, any program/articles/file on this site cannot be republished or
# distributed without the consent of the author who contributed it.
#
#### First, here are the get_UPP, ?(random_Quote)? and parse_SectorDescription functions.
SCORING=1
### get_UPP (requires 'full-upp', installed in bin folder)
function get_UPP()
{
full-upp $2 > /tmp/$1uppo.txt
cat /tmp/$1uppo.txt /Library/WebServer/CGI-Executables/trav/ret.txt > /tmp/$1upp.txt
chmod ugo+w /tmp/$1upp.txt /tmp/$1uppo.txt
#echo "Content-Type: application/text"
#echo " Filename: "$1upp.txt
echo ""
echo $1
echo "Name: "$4 > /tmp/$1name1.txt
sed '/_/ s/_/ /g' /tmp/$1name1.txt > /tmp/$1name.txt
cat < /tmp/$1name.txt
sed -n '/ '$3' /p' /tmp/*_polities.txt > /tmp/$1polityinter.txt
cat /Library/WebServer/CGI-Executables/trav/Affiliation.txt /tmp/$1polityinter.txt > /tmp/$1polity.txt
cat < /tmp/$1polity.txt
#echo ""
echo "UPP: "$2
echo ""
cat < /tmp/$1upp.txt
rm -rf /tmp/$1upp.txt
rm -rf /tmp/$1polityinter.txt
rm -rf /tmp/$1polity.txt
rm -rf /tmp/*uppo.txt
rm -rf /tmp/$1name1.txt
rm -rf /tmp/$1name.txt
return
}
### get_More (grabs cargo and animal encounters)
function get_More()
{
cd /Library/WebServer/CGI-Executables/trav
perl shell.pl --tool=animal --extended --profile=$2 > /tmp/$1animo.txt
perl shell.pl --tool=bk7.trade.cargo --profile=$2 > /tmp/$1cargo.txt
cat /tmp/$1animo.txt /Library/WebServer/CGI-Executables/trav/ret.txt > /tmp/$1anim.txt
chmod ugo+w /tmp/$1anim.txt /tmp/$1animo.txt
#echo "Content-Type: application/text"
#echo " Filename: "$1anim.txt
#echo ""
echo "Generic Cargo:"
#echo ""
cat < /tmp/$1cargo.txt
#echo $1
echo ""
echo "Animal Encounters:"
#echo ""
cat < /tmp/$1anim.txt
rm -rf /tmp/$1anim.txt
rm -rf /tmp/$1animo.txt
cd /Library/WebServer/CGI-Executables/
return
}
### get_SectorDescriptions grabs each of the planet's descriptions (using the get_UPP function on each) and then serves the whole thing up as a text file and pdf.
function get_SectorDescriptions()
{
needforanim=2
## Main Loop
if [ "$needforanim" -lt "$desc" ]; then # -n tests to see if the argument is non empty
while read LINE
do
get_UPP $LINE $2 > /tmp/$1det$LINE-a.txt
# echo " . $1 World debug - UPP description render complete @" $SECONDS "seconds. "
done < /tmp/$1
else
while read LINE
do
get_UPP $LINE $2 > /tmp/$1det$LINE-a.txt
# echo " . $1 World debug - UPP description render complete @" $SECONDS "seconds. "
get_More $LINE > /tmp/$1det$LINE-banim.txt
# echo " . $1 World debug - cargo and animal encounters description render complete @" $SECONDS "seconds. "
done < /tmp/$1
fi
# Combine all the descriptions into one text file.
cat /Library/WebServer/CGI-Executables/trav/pageblanker.txt /tmp/$2title.txt /Library/WebServer/CGI-Executables/trav/descinfo.txt /Library/WebServer/CGI-Executables/trav/ret.txt /tmp/$1det*.txt > /tmp/$1finaldet.txt
wait
## Assemble the pages into a description section pdf
# Create .ps files from each datafile
enscript --word-wrap --margins=35:35:0:40 --fancy-header='travellerpagenums2' --header='|- $% -|' --header-font=Univers9 /tmp/$1finaldet.txt -f Courier6.5 --media=Traveller -q -p /tmp/$1out.ps
wait
# Create .pdf files from each datafile .ps
pstopdf /tmp/$1out.ps -o /tmp/$1piecetemp.pdf
wait
# Grab the pages, starting #36 (the prior 35 are blank to set up the numbering, since the pdftk program can't start the numbering at 36.
pdftk /tmp/$1piecetemp.pdf cat 38-end output /tmp/$1piecetempText.pdf
wait
# Grab the first page of the descriptions
pdftk /tmp/$1piecetempText.pdf cat 1-1 output /tmp/$1piecetempIntro.pdf
wait
# Place the 'World Descriptions' header on the first page, in keeping with the document's section headings.
pdftk /tmp/$1piecetempIntro.pdf background /Library/WebServer/CGI-Executables/trav/Desc_Background.pdf output /tmp/$1pieceDescIntroWithBack.pdf
wait
# Grab the rest of the descriptions
pdftk /tmp/$1piecetempText.pdf cat 2-end output /tmp/$1pieceEnd.pdf
wait
# Join the first page of descriptions (now with header) and the rest of the descriptions
pdftk /tmp/$1pieceDescIntroWithBack.pdf /tmp/$1pieceEnd.pdf cat output /tmp/$1piece.pdf
wait
return
}
### get_Sectormap makes a one-page sector map, including borders.
function get_Sectormap()
{
# Wipe pesky underscores
sed '/_/ s/_/ /g' /tmp/$1secdata > /tmp/$1secdataZ
ditto /tmp/$1secdataZ /tmp/$1_secdatapre
# Remove the first line so it doesn't get chunked
sed '1d' /tmp/$1_secdatapre > /tmp/$1_secdata
# Cut new chunks for sec2pdf-friendly format
cut -b20-23 /tmp/$1_secdata > /tmp/$1_secdataID
cut -b19-19 /tmp/$1_secdata > /tmp/$1_secdataSpace
cut -b1-14 /tmp/$1_secdata > /tmp/$1_secdataName
cut -b25-34 /tmp/$1_secdata > /tmp/$1_secdataUPP
cut -b35-52 /tmp/$1_secdata > /tmp/$1_secdataTrade
cut -b53-55 /tmp/$1_secdata > /tmp/$1_secdataPBG
cut -b56-58 /tmp/$1_secdata > /tmp/$1_secdataEmpire
cut -b60-60 /tmp/$1_secdata > /tmp/$1_secdataTAS
# Combine chunks in sec2pdf-friendly format, with new heading for sec2pdf
paste -d '\0' /tmp/$1_secdataName /tmp/$1_secdataID /tmp/$1_secdataSpace /tmp/$1_secdataUPP /tmp/$1_secdataSpace /tmp/$1_secdataTrade /tmp/$1_secdataTAS /tmp/$1_secdataSpace /tmp/$1_secdataSpace /tmp/$1_secdataPBG /tmp/$1_secdataEmpire /tmp/$1_secdataSpace > /tmp/$1_newsecdata1
cat trav/SectorTop.txt /tmp/$1_newsecdata1 > /tmp/$1_newsecdata
# Grab pre-existing alliances
if [ $2 > 0 ]; then # -n tests to see if the argument is non empty
perl allygen2.pl -f 2 -r -o /tmp/$1_automsec2 /tmp/$1_newsecdata
#echo " . $1 Sector debug - Allygen generation complete @" $SECONDS "seconds. "
# Strip various allygen items, based on param $6 ($3 here)
## Loop
if [ $3 = 3 ]; then
sed '/# Alliance:/d' /tmp/$1_automsec2.msec > /tmp/$1_automsec2a.msec
sed '/border/d' /tmp/$1_automsec2a.msec > /tmp/$1_automsec2b.msec
sed '/route/d' /tmp/$1_automsec2b.msec > /tmp/$1_automsec3.msec
cat /Library/WebServer/CGI-Executables/trav/sectorfiles/$1_route.txt /tmp/$1_automsec3.msec > /tmp/$1_automsec.msec
fi
if [ $3 = 2 ]; then
sed '/# Alliance:/d' /tmp/$1_automsec2.msec > /tmp/$1_automsec2a.msec
sed '/route/d' /tmp/$1_automsec2a.msec > /tmp/$1_automsec3.msec
cat /Library/WebServer/CGI-Executables/trav/sectorfiles/$1_route.txt /tmp/$1_automsec3.msec > /tmp/$1_automsec.msec
fi
if [ $3 = 1 ]; then
cat /Library/WebServer/CGI-Executables/trav/sectorfiles/$1_route.txt /tmp/$1_automsec2.msec > /tmp/$1_automsec.msec
fi
if [ $3 = 0 ]; then
cat /tmp/$1_automsec2.msec > /tmp/$1_automsec.msec
fi
# Generate Sector Map
perl sec2pdf.pl -s $1 -f 2 -b -a -h -B -pTraveller -t sector -m /tmp/$1_automsec.msec -d /tmp/$1_newsecdata -o /tmp/$1_sectormap1.pdf
#echo " . $1 Sector debug - Small Sectormap generation complete @" $SECONDS "seconds. "
# Generate Subsector Maps (borders, routes and regions)
perl sec2pdf_borders.pl -f 2 -s $1 -a -B -pTraveller -m /tmp/$1_automsec.msec -d /tmp/$1_newsecdata -o /tmp/$1_subsectorborders.pdf
#echo " . $1 Sector debug - Subsector routes generation complete @" $SECONDS "seconds. "
else
# Generate New Allegiances
perl allygen2.pl -f 2 -i -r -o /tmp/$1_automsec /tmp/$1_newsecdata
#echo " . $1 Sector debug - Allygen generation complete @" $SECONDS "seconds. "
# Generate Sector Map
perl sec2pdf.pl -s $1 -f 2 -b -a -B -h -pTraveller -t sector -m /tmp/$1_automsec.msec -d /tmp/$1_newsecdata -o /tmp/$1_sectormap1.pdf
#echo " . $1 Sector debug - Small Sectormap generation complete @" $SECONDS "seconds. "
# Generate Sector Map
perl sec2pdf_borders.pl -f 2 -s $1 -a -B -pTraveller -m /tmp/$1_automsec.msec -d /tmp/$1_newsecdata -o /tmp/$1_subsectorborders.pdf
#echo " . $1 Sector debug - Subsector routes generation complete @" $SECONDS "seconds. "
fi
# Combine the map with canon Classic Traveller background
pdftk /Library/WebServer/CGI-Executables/trav/backgrounds/SectorMap_Background.pdf background /tmp/$1_sectormap1.pdf output /tmp/$1_sectormap2.pdf compress
wait
return
}
### get_Polity randomly generates names for each of the polities generated by allygen.pl
function get_Polity {
case $((RANDOM%211+1)) in
1)echo $1 "Accomodation (" $2 ")"
;;
2)echo $1 "Accord (" $2 ")"
;;
3)echo $1 "Accordate (" $2 ")"
;;
4)echo $1 "Accordment (" $2 ")"
;;
5)echo $1 "Affiliation (" $2 ")"
;;
6)echo $1 "Affiliate (" $2 ")"
;;
7)echo $1 "Affinity (" $2 ")"
;;
8)echo $1 "Aggregate (" $2 ")"
;;
9)echo $1 "Alliance (" $2 ")"
;;
10)echo $1 "Amalgam (" $2 ")"
;;
11)echo $1 "Amalgamate (" $2 ")"
;;
12)echo $1 "Amalgamation (" $2 ")"
;;
13)echo $1 "Arbitration (" $2 ")"
;;
14)echo $1 "Ascendancy (" $2 ")"
;;
15)echo $1 "Assemblage (" $2 ")"
;;
16)echo $1 "Assembly (" $2 ")"
;;
17)echo $1 "Association (" $2 ")"
;;
18)echo $1 "Authority (" $2 ")"
;;
19)echo $1 "Autocracy (" $2 ")"
;;
20)echo $1 "Birthright (" $2 ")"
;;
21)echo $1 "Biumvirate (" $2 ")"
;;
22)echo $1 "Brotherhood (" $2 ")"
;;
23)echo $1 "Cabal (" $2 ")"
;;
24)echo $1 "Cartel (" $2 ")"
;;
25)echo $1 "Circle (" $2 ")"
;;
26)echo $1 "Circuit (" $2 ")"
;;
27)echo $1 "Clanholds (" $2 ")"
;;
28)echo $1 "Clanworlds (" $2 ")"
;;
29)echo $1 "Coalition (" $2 ")"
;;
30)echo $1 "Colonies (" $2 ")"
;;
31)echo $1 "Combine (" $2 ")"
;;
32)echo $1 "Command (" $2 ")"
;;
33)echo $1 "Commission (" $2 ")"
;;
34)echo $1 "Commonality (" $2 ")"
;;
35)echo $1 "Commonwealth (" $2 ")"
;;
36)echo $1 "Commune (" $2 ")"
;;
37)echo $1 "Communion (" $2 ")"
;;
38)echo $1 "Compact (" $2 ")"
;;
39)echo $1 "Compromise (" $2 ")"
;;
40)echo $1 "Concord (" $2 ")"
;;
41)echo $1 "Concordate (" $2 ")"
;;
42)echo $1 "Concourse (" $2 ")"
;;
43)echo $1 "Concurrence (" $2 ")"
;;
44)echo $1 "Confed (" $2 ")"
;;
45)echo $1 "Confederacy (" $2 ")"
;;
46)echo $1 "Confederation (" $2 ")"
;;
47)echo $1 "Confines (" $2 ")"
;;
48)echo $1 "Conglomerate (" $2 ")"
;;
49)echo $1 "Congress (" $2 ")"
;;
50)echo $1 "Congruity (" $2 ")"
;;
51)echo $1 "Conjunction (" $2 ")"
;;
52)echo $1 "Consanguinity (" $2 ")"
;;
53)echo $1 "Consolidation (" $2 ")"
;;
54)echo $1 "Consortium (" $2 ")"
;;
55)echo $1 "Conspiracy (" $2 ")"
;;
56)echo $1 "Constellation (" $2 ")"
;;
57)echo $1 "Consulate (" $2 ")"
;;
58)echo $1 "Control (" $2 ")"
;;
59)echo $1 "Cooperate (" $2 ")"
;;
60)echo $1 "Cooperative (" $2 ")"
;;
61)echo $1 "Coordinate (" $2 ")"
;;
62)echo $1 "Corporate (" $2 ")"
;;
63)echo $1 "Council (" $2 ")"
;;
64)echo $1 "County (" $2 ")"
;;
65)echo $1 "Covenant (" $2 ")"
;;
66)echo $1 "Crusade (" $2 ")"
;;
67)echo $1 "Delegation (" $2 ")"
;;
68)echo $1 "Democracy (" $2 ")"
;;
69)echo $1 "Demos (" $2 ")"
;;
70)echo $1 "Dependency (" $2 ")"
;;
71)echo $1 "Desmense (" $2 ")"
;;
72)echo $1 "Dictatorship (" $2 ")"
;;
73)echo $1 "Directorship (" $2 ")"
;;
74)echo $1 "Disjuncture (" $2 ")"
;;
75)echo $1 "District (" $2 ")"
;;
76)echo $1 "Domain (" $2 ")"
;;
77)echo $1 "Dominance (" $2 ")"
;;
78)echo $1 "Dominate (" $2 ")"
;;
79)echo $1 "Dominion (" $2 ")"
;;
80)echo $1 "Duchy (" $2 ")"
;;
81)echo $1 "Dynasty (" $2 ")"
;;
82)echo $1 "Ecclesiasty (" $2 ")"
;;
83)echo $1 "Empire (" $2 ")"
;;
84)echo $1 "Enclave (" $2 ")"
;;
85)echo $1 "Exchange (" $2 ")"
;;
86)echo $1 "Expanse (" $2 ")"
;;
87)echo $1 "Extent (" $2 ")"
;;
88)echo $1 "Faction (" $2 ")"
;;
89)echo $1 "Factors (" $2 ")"
;;
90)echo $1 "Federacy (" $2 ")"
;;
91)echo $1 "Federate (" $2 ")"
;;
92)echo $1 "Federation (" $2 ")"
;;
93)echo $1 "Fraternity (" $2 ")"
;;
94)echo $1 "Free Worlds (" $2 ")"
;;
95)echo $1 "Fusion (" $2 ")"
;;
96)echo $1 "Group (" $2 ")"
;;
97)echo $1 "Guild (" $2 ")"
;;
98)echo $1 "Harmony (" $2 ")"
;;
99)echo $1 "Hegemony (" $2 ")"
;;
100)echo $1 "Hierate (" $2 ")"
;;
101)echo $1 "Indentureship (" $2 ")"
;;
102)echo $1 "Integration (" $2 ")"
;;
103)echo $1 "Interacterate (" $2 ")"
;;
104)echo $1 "Inquisition (" $2 ")"
;;
105)echo $1 "Judicature (" $2 ")"
;;
106)echo $1 "Judiciary (" $2 ")"
;;
107)echo $1 "Judiciate (" $2 ")"
;;
108)echo $1 "Junction (" $2 ")"
;;
109)echo $1 "Juncture (" $2 ")"
;;
110)echo $1 "Jurisdiction (" $2 ")"
;;
111)echo $1 "Kinship (" $2 ")"
;;
112)echo $1 "Kinworlds (" $2 ")"
;;
113)echo $1 "Kithworlds (" $2 ")"
;;
114)echo $1 "League (" $2 ")"
;;
115)echo $1 "Legacy (" $2 ")"
;;
116)echo $1 "Legate (" $2 ")"
;;
117)echo $1 "Legion (" $2 ")"
;;
118)echo $1 "Magistracy (" $2 ")"
;;
119)echo $1 "Magistrate (" $2 ")"
;;
120)echo $1 "Mandate (" $2 ")"
;;
121)echo $1 "Manifest (" $2 ")"
;;
122)echo $1 "Merger (" $2 ")"
;;
123)echo $1 "Ministry (" $2 ")"
;;
124)echo $1 "Monarchy (" $2 ")"
;;
125)echo $1 "Monopoly (" $2 ")"
;;
126)echo $1 "Mutuality (" $2 ")"
;;
127)echo $1 "Network (" $2 ")"
;;
128)echo $1 "Occupation (" $2 ")"
;;
129)echo $1 "Order (" $2 ")"
;;
130)echo $1 "Organization (" $2 ")"
;;
131)echo $1 "Outlands (" $2 ")"
;;
132)echo $1 "Outworlds (" $2 ")"
;;
133)echo $1 "Pact (" $2 ")"
;;
134)echo $1 "Partnership (" $2 ")"
;;
135)echo $1 "Patronage (" $2 ")"
;;
136)echo $1 "Polity (" $2 ")"
;;
137)echo $1 "Possessions (" $2 ")"
;;
138)echo $1 "Power (" $2 ")"
;;
139)echo $1 "Predominance (" $2 ")"
;;
140)echo $1 "Preeminence (" $2 ")"
;;
141)echo $1 "Prepotency (" $2 ")"
;;
142)echo $1 "Prerogative (" $2 ")"
;;
143)echo $1 "Presidency (" $2 ")"
;;
144)echo $1 "Primacy (" $2 ")"
;;
145)echo $1 "Principality (" $2 ")"
;;
146)echo $1 "Proletariat (" $2 ")"
;;
147)echo $1 "Protectorate (" $2 ")"
;;
148)echo $1 "Province (" $2 ")"
;;
149)echo $1 "Radius (" $2 ")"
;;
150)echo $1 "Range (" $2 ")"
;;
151)echo $1 "Reaches (" $2 ")"
;;
152)echo $1 "Realm (" $2 ")"
;;
153)echo $1 "Reconciliation (" $2 ")"
;;
154)echo $1 "Regency (" $2 ")"
;;
155)echo $1 "Regime (" $2 ")"
;;
156)echo $1 "Region (" $2 ")"
;;
157)echo $1 "Regnum (" $2 ")"
;;
158)echo $1 "Reign (" $2 ")"
;;
159)echo $1 "Republic (" $2 ")"
;;
160)echo $1 "Rimworlds (" $2 ")"
;;
161)echo $1 "Ring (" $2 ")"
;;
162)echo $1 "Scope (" $2 ")"
;;
163)echo $1 "Settlements (" $2 ")"
;;
164)echo $1 "Signatorate (" $2 ")"
;;
165)echo $1 "Signatory (" $2 ")"
;;
166)echo $1 "Society (" $2 ")"
;;
167)echo $1 "Sodality (" $2 ")"
;;
168)echo $1 "Sovereignty (" $2 ")"
;;
169)echo $1 "Sphere (" $2 ")"
;;
170)echo $1 "States (" $2 ")"
;;
171)echo $1 "Stronghold (" $2 ")"
;;
172)echo $1 "Subjugacy (" $2 ")"
;;
173)echo $1 "Subjugate (" $2 ")"
;;
174)echo $1 "Superiority (" $2 ")"
;;
175)echo $1 "Supremacy (" $2 ")"
;;
176)echo $1 "Suzerainty (" $2 ")"
;;
177)echo $1 "Syndicate (" $2 ")"
;;
178)echo $1 "Synthesis (" $2 ")"
;;
179)echo $1 "Sweep (" $2 ")"
;;
180)echo $1 "Technocracy (" $2 ")"
;;
181)echo $1 "Territories (" $2 ")"
;;
182)echo $1 "Theocracy (" $2 ")"
;;
183)echo $1 "Throne Worlds (" $2 ")"
;;
184)echo $1 "Trade Association (" $2 ")"
;;
185)echo $1 "Trade Coalition (" $2 ")"
;;
186)echo $1 "Trade Confederation (" $2 ")"
;;
187)echo $1 "Trade Federation (" $2 ")"
;;
188)echo $1 "Trade Union (" $2 ")"
;;
189)echo $1 "Transcendancy (" $2 ")"
;;
190)echo $1 "Treaty (" $2 ")"
;;
191)echo $1 "Tripartite (" $2 ")"
;;
192)echo $1 "Triumvirate (" $2 ")"
;;
193)echo $1 "Trust (" $2 ")"
;;
194)echo $1 "Tyranny (" $2 ")"
;;
195)echo $1 "Unanimity (" $2 ")"
;;
196)echo $1 "Unification (" $2 ")"
;;
197)echo $1 "Union (" $2 ")"
;;
198)echo $1 "Unity (" $2 ")"
;;
199)echo $1 "Worlds (" $2 ")"
;;
200)echo $1 "Zone (" $2 ")"
;;
201)echo "Grand Duchy of "$1 "(" $2 ")"
;;
202)echo "Great "$1 "(" $2 ")"
;;
203)echo "League of "$1 "Worlds (" $2 ")"
;;
204)echo "Lords of "$1 "(" $2 ")"
;;
205)echo "New Worlds of "$1 "(" $2 ")"
;;
206)echo "Stellar Kingdom of "$1 "(" $2 ")"
;;
207)echo "Unified Systems of "$1 "(" $2 ")"
;;
208)echo "Concordance of "$1 "Worlds (" $2 ")"
;;
209)echo "League of "$1 "Worlds (" $2 ")"
;;
210)echo "Glory of "$1 "(" $2 ")"
;;
211)echo "Planetary Alliance of "$1 "(" $2 ")"
;;
212)echo "Entreaty of "$1 "(" $2 ")"
;;
*)echo $1
;;
esac
return
}
### get_Polities: Grabs each polity
function get_Polities {
while read LINE
do
get_Polity $LINE > /tmp/$1polity$LINE.txt
done < /tmp/$1
}
#### Now the main body of the script.
### 1. GENERATE THE COVERS
## Generate the custom cover
# Generate the text of the sector name
echo $1 > /tmp/$1seccoverA.txt
sed '/_/ s/_/ /g' /tmp/$1seccoverA.txt > /tmp/$1seccover.txt
# Add a line to the sectorname for processing
cat /Library/WebServer/CGI-Executables/trav/covercat.txt /tmp/$1seccover.txt > /tmp/$1seccover2.txt
# LBB cover
enscript --word-wrap /tmp/$1seccover2.txt -r --margins=266:-300:-400:407 -B -f OptimaItalic32 --media=Letter -q -p /tmp/$1seccover1.ps
# Turn the generated text white for the cover
sed '/5 578 M/ s/5 578 M/5 578 M 1 setgray/g' /tmp/$1seccover1.ps > /tmp/$1seccover.ps
# Make the generated text of the cover a pdf
pstopdf /tmp/$1seccover.ps -o /tmp/$1seccover1.pdf
# Combine the generated name and the background front cover pdf into the new sector front cover.
pdftk /tmp/$1seccover1.pdf background /Library/WebServer/CGI-Executables/trav/SectorData_Cover.pdf output /tmp/$1CoverInt.pdf
wait
#echo " . $1 Sector debug - cover complete @" $SECONDS "seconds. "
## Generate the back page
# Random Quote Grabber
./trav/randomquote.sh > /tmp/$1backquote.txt
# LBB Back
enscript /tmp/$1backquote.txt -r --word-wrap --margins=122:-100:364:40 -B -f OptimaItalic20 --media=Letter -q -p /tmp/$1Back1.ps
# Make the generated text of the back cover a pdf
sed '/5 567 M/ s/5 567 M/5 567 M 1 setgray/g' /tmp/$1Back1.ps > /tmp/$1CoverBack.ps
# Make the generated text of the back cover a pdf
pstopdf /tmp/$1CoverBack.ps -o /tmp/$1BackCovertemp.pdf
# Combine the generated text and the background back cover pdf into the new sector back cover.
pdftk /tmp/$1BackCovertemp.pdf background /tmp/$1CoverInt.pdf output /tmp/$1Cover.pdf
wait
#echo " . $1 Sector debug - back cover complete @" $SECONDS "seconds. "
### 2. GENERATE OR GRAB THE SECTOR'S DATA
## Generate the raw subsector data or import it
if [ $5 > 0 ]; then
cp /Library/WebServer/CGI-Executables/trav/sectorfiles/$5 /tmp/$1secdata
sed q /tmp/$1secdata > /tmp/$1secdataorighead
sed '1d' /tmp/$1secdata > /tmp/$1secdataorig
NUM_WORLDS=`wc -l /tmp/$1secdataorig | awk '{ print $1 }'`
else
gensec3 $2 $3 > /tmp/$1secdataorig2
# Save the first line of the sector file ('Version' tag)
sed q /tmp/$1secdataorig2 > /tmp/$1secdataorighead
# Remove the first line for the text processing
sed '1d' /tmp/$1secdataorig2 > /tmp/$1secdataorig
#echo " . $1 Sector debug - data generation complete @" $SECONDS "seconds. "
## Generate the sector's system names
# Count the number of worlds generated
NUM_WORLDS=`wc -l /tmp/$1secdataorig | awk '{ print $1 }'`
# Grab the generated datafile's contents preceding and following the name
cut -b20-80 /tmp/$1secdataorig > /tmp/$1secdataorigBack
# Run the random word generator
perl /Library/WebServer/CGI-Executables/trav/lc -$NUM_WORLDS /Library/WebServer/CGI-Executables/trav/namesmaster.txt > /tmp/$1namegrab1
# Grab the names from the file
sed -e :a -e 's/^.\{1,18\}$/& /;ta' /tmp/$1namegrab1 > /tmp/$1namegrab2
# Combine the three files into a new secdata file with the names inside
paste -d '\0' /tmp/$1namegrab2 /tmp/$1secdataorigBack > /tmp/$1secdatainterim
# paste the header back onto the sector data
cat /tmp/$1secdataorighead /tmp/$1secdatainterim > /tmp/$1secdata
fi
#echo " . $1 Sector debug - word generation complete @" $SECONDS "seconds. "
### 4. GENERATE THE SECTOR MAP
## If we're using a pre-existing sector file, don't change the alliances.
if [ $5 > 0 ]; then
# Run the map with old alliances retained
get_Sectormap $1 2 $6
wait
sed -n '/route/p' /tmp/$1_automsec.msec > /tmp/$1_route.txt
else
# Run the map with new alliances
get_Sectormap $1
wait
#echo " . $1 Sector debug - sector map generation complete @" $SECONDS "seconds. "
## If it's a fresh sector, go ahead and generate the names of the Alliances
# Grab a version of the msec file without 'border'
sed '/# Alliance: / s/# Alliance: / /g' /tmp/$1_automsec.msec > /tmp/$1_before.msec
#sed '/# Alliance: /d' /tmp/$1_automsec.msec > /tmp/$1_beforeZ.msec
sed '/border/d' /tmp/$1_automsec.msec > /tmp/$1_before1a.msec
sed -n '/route/p' /tmp/$1_before1a.msec > /tmp/$1_route.txt
sed '/route/d' /tmp/$1_before.msec > /tmp/$1_before1.msec
sed '/border/d' /tmp/$1_before1.msec > /tmp/$1_after1.msec
sed -n 'G; s/\n/&&/; /^\([ -~]*\n\).*\n\1/d; s/\n//; h; P' /tmp/$1_after1.msec > /tmp/$1_after.msec
# Count the alliances in the file
NUM_POLS=`wc -l /tmp/$1_after.msec | awk '{ print $1 }'`
# Generate the right number of random names
perl /Library/WebServer/CGI-Executables/trav/lc -$NUM_POLS /Library/WebServer/CGI-Executables/trav/namesmaster.txt > /tmp/politynames
# Put the codes with the random names and run the polity combiner
paste -d '\0' /tmp/politynames /tmp/$1_after.msec > /tmp/$1_combo1.msec
sed '/ / s/ / /g' /tmp/$1_combo1.msec > /tmp/$1_combo.msec
get_Polities $1_combo.msec
# Put all the polity names together as the final 'alliances' text
cat /tmp/$1_combo.msecpolity*.txt > /tmp/$1_polities.txt
ditto /tmp/$1_polities.txt /tmp/$1_alliances.txt
wait
#echo " . $1 Sector debug - alliance generation complete @" $SECONDS "seconds. "
fi
# NOTE: Need to add code to grab any spaces INSIDE the names and turn them into underscores. Right now it's manual.
## Grab the alliances (pre-existing or not) and parse them into the secdata file
# Save the first line of the sector file ('Version' tag)
sed q /tmp/$1secdata > /tmp/$1secdataorighead2
# Remove the first line for the text processing
if [ $5 > 0 ]; then
ditto /Library/WebServer/CGI-Executables/trav/sectorfiles/$1_alliances.txt /tmp/$1secdatadesc_alliances.txt
wait
ditto /Library/WebServer/CGI-Executables/trav/sectorfiles/$1_alliances.txt /tmp/$1_alliances.txt
wait
ditto /Library/WebServer/CGI-Executables/trav/sectorfiles/$1_alliances.txt /tmp/$1_polities.txt
wait
ditto /tmp/$1secdata /tmp/$1_automsec.sec
wait
else
sed '1,15d' /tmp/$1_automsec.sec > /tmp/$1_newsecdataProc
sed '1d' /tmp/$1secdata > /tmp/$1secdataProc
# Splice the new secdata file
cut -b1-56 /tmp/$1secdataProc > /tmp/$1_secdataEmpirePre
cut -b60-64 /tmp/$1secdataProc > /tmp/$1_secdataEmpirePost
cut -b56-58 /tmp/$1_newsecdataProc > /tmp/$1_secdataNewEmpire
# Put it all together
paste -d '\0' /tmp/$1_secdataEmpirePre /tmp/$1_secdataNewEmpire /tmp/$1_secdataEmpirePost > /tmp/$1secdatainterim2
cat /tmp/$1secdataorighead2 /tmp/$1secdatainterim2 > /tmp/$1secdata
# safety kludge for literal problem
ditto /tmp/$1_alliances.txt /tmp/$1secdatadesc_alliances.txt
wait
#echo " . $1 Sector debug - alliance parsing complete @" $SECONDS "seconds. "
fi
### GENERATE THE SUBSECTOR MAPS AND DATA PAGES
#Create Title Text for Listings and Descriptions
echo ""$1"""" > /tmp/$1titleA.txt
sed '/_/ s/_/ /g' /tmp/$1titleA.txt > /tmp/$1title.txt
# Create Title Text for Sector Map
echo "Contains" $NUM_WORLDS" systems." > /tmp/$1SectorMapsubtitle.txt
#echo ""$1""" Sector (containing" $NUM_WORLDS" systems)" > /tmp/$1SectorMaptitleA.txt
#sed '/_/ s/_/ /g' /tmp/$1SectorMaptitleA.txt > /tmp/$1SectorMaptitle.txt
#cat /tmp/$1title.txt /tmp/$1SectorMapsubtitle.txt > /tmp/$1SectorMaptitle.txt
cat /tmp/$1title.txt /Library/WebServer/CGI-Executables/trav/ret.txt /tmp/$1SectorMapsubtitle.txt > /tmp/$1SectorMaptitle.txt
## Big Per-Subsector Loop Starts
whichborderpage=0
for x in A B C D E F G H I J K L M N O P; do
let "whichborderpage = whichborderpage +1"
# Generate this subsector's data file
subsec2 S=$x < /tmp/$1secdata > /tmp/$1subsec1$x
NUM_SUBSECWORLDS=`wc -l /tmp/$1subsec1$x | awk '{ print $1 }'`
sed '/_/ s/_/ /g' /tmp/$1subsec1$x > /tmp/$1subsec$x
wait