-
Notifications
You must be signed in to change notification settings - Fork 0
/
SeaTrade1.c
executable file
·3618 lines (3502 loc) · 111 KB
/
SeaTrade1.c
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
/* Project and source code (c) Copyright by Joona Palaste */
/* Licenced under GNU GPL 3.0 */
/*
* Source machine generated by GadToolsBox V2.0b
* which is (c) Copyright 1991-1993 Jaba Development
*
* GUI Designed by : JIPsoft (Joona I Palaste)
*/
#include <exec/types.h>
#include <exec/memory.h>
#include <intuition/intuition.h>
#include <intuition/classes.h>
#include <intuition/classusr.h>
#include <intuition/imageclass.h>
#include <intuition/gadgetclass.h>
#include <libraries/gadtools.h>
#include <libraries/asl.h>
#include <libraries/dos.h>
#include <graphics/displayinfo.h>
#include <graphics/gfxbase.h>
#include <clib/exec_protos.h>
#include <clib/intuition_protos.h>
#include <clib/gadtools_protos.h>
#include <clib/graphics_protos.h>
#include <clib/utility_protos.h>
#include <string.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include "SeaTrade.h"
extern UBYTE labels[15][32];
extern UBYTE *Sct;
extern struct Node List1Nodes[];
extern struct Node Cargo3Nodes[];
extern UBYTE InfoWdt[];
struct class class[57] = {
{"Spider", 200, 30, 1, 350, 0, 0, 20300},
{"Butterfly", 200, 50, 1, 250, 0, 0, 24500},
{"Scorpion", 250, 50, 1, 500, 0, 0, 26500},
{"Sparrow", 350, 40, 1, 1050, 0, 0, 28400},
{"Tarantula", 200, 70, 1, 150, 0, 0, 28700},
{"Hornet", 250, 70, 1, 400, 0, 0, 30700},
{"Dragonfly", 200, 90, 1, 50, 0, 0, 32900},
{"Kingfisher", 250, 90, 1, 300, 0, 0, 34900},
{"Raven", 350, 80, 1, 850, 0, 0, 36800},
{"Hawk", 350, 70, 2, 400, 0, 0, 40700},
{"Crow", 350, 100, 1, 750, 0, 0, 41000},
{"Hummingbird", 250, 120, 1, 150, 0, 0, 41200},
{"Eagle", 350, 80, 2, 350, 0, 0, 42800},
{"Falcon", 400, 100, 2, 500, 0, 0, 49000},
{"Viper", 600, 70, 2, 1650, 0, 0, 50700},
{"Boa", 600, 50, 3, 1250, 0, 0, 52500},
{"Albatross", 400, 150, 1, 750, 0, 0, 53500},
{"Cobra", 600, 120, 1, 1900, 0, 0, 55200},
{"Asp", 500, 100, 2, 1500, 0, 0, 57000},
{"Wolf", 650, 80, 3, 1350, 0, 0, 60800},
{"Dingo", 600, 120, 2, 1400, 0, 0, 61200},
{"Mamba", 600, 150, 1, 1750, 0, 0, 61500},
{"Cougar", 700, 90, 3, 1550, 0, 0, 64900},
{"Cheetah", 650, 150, 2, 1500, 0, 0, 69500},
{"Tiger", 1000, 120, 3, 2500, 1, 250, 96500},
{"Lion", 1100, 130, 3, 2950, 1, 250, 102600},
{"Lynx", 1100, 120, 3, 3000, 1, 300, 103000},
{"Basilisk", 1200, 150, 4, 2850, 1, 300, 119300},
{"Manticore", 1500, 100, 5, 4100, 1, 300, 126800},
{"Centaur", 1600, 90, 5, 4650, 1, 320, 129700},
{"Unicorn", 1600, 100, 5, 4600, 1, 300, 130800},
{"Griffin", 1600, 100, 5, 4500, 1, 320, 131800},
{"Sphinx", 1600, 120, 5, 4500, 1, 320, 136000},
{"Chimaera", 1700, 160, 5, 4800, 1, 320, 148400},
{"Wyvern", 2000, 160, 7, 5300, 1, 350, 173900},
{"Dragon", 2000, 200, 8, 4600, 1, 350, 188300},
{"Supporter", 2200, 200, 8, 5600, 1, 360, 196800},
{"Navigator", 2200, 220, 8, 5500, 1, 360, 201000},
{"Courier", 2500, 250, 8, 6450, 2, 250, 227100},
{"Clipper", 2500, 280, 8, 6300, 2, 250, 233400},
{"Expeditor", 2700, 250, 10, 6450, 2, 280, 250100},
{"Cruiser", 2700, 280, 10, 6300, 2, 280, 256400},
{"Trader", 3000, 250, 10, 7950, 2, 300, 264100},
{"Merchantman", 3200, 300, 10, 8700, 2, 320, 284600},
{"Carrier", 3300, 320, 12, 8100, 2, 320, 304800},
{"Voyager", 3400, 350, 10, 9450, 2, 360, 307100},
{"Enterprise", 3400, 320, 12, 8600, 2, 350, 311800},
{"Pluto", 4000, 300, 12, 11300, 3, 300, 342400},
{"Mercury", 4100, 320, 12, 11700, 3, 320, 353600},
{"Mars", 4100, 360, 12, 11500, 3, 320, 362000},
{"Venus", 4200, 360, 12, 12000, 3, 350, 370500},
{"Neptune", 4500, 320, 14, 12700, 3, 360, 387600},
{"Uranus", 4800, 320, 12, 15200, 3, 400, 393600},
{"Saturn", 4500, 360, 14, 12500, 3, 360, 396000},
{"Jupiter", 4800, 360, 12, 15000, 3, 400, 402000},
{"Solaris", 4800, 360, 14, 14000, 3, 400, 414000},
{"", 0, 0, 255, 65535, 0, 0, 0} /* Store - not a real ship class! */
};
struct city city[64] = {
{"Umacka", {0, 209, 160}, 0, {20, 16, 54, 67, 17, 37, 64, 66, 11, 14, 5, 20}, {5, 9, 14, 21, 22, 25, 28, 32, 36, 41, 42, 44, 46, 49}},
{"Serfrod", {3, 210, 108}, 0, {21, 16, 67, 64, 20, 34, 76, 57, 10, 13, 5, 20}, {1, 15, 19, 21, 31, 33, 35, 36, 43, 44, 46, 48, 49, 51}},
{"Ialer", {7, 152, 18}, 0, {21, 19, 55, 68, 19, 38, 63, 64, 9, 14, 5, 20}, {0, 10, 14, 16, 18, 20, 23, 27, 30, 36, 44, 46, 47, 48}},
{"Tornild", {8, 186, 203}, 3, {23, 24, 28, 101, 27, 35, 74, 37, 15, 15, 5, 20}, {0, 15, 22, 27, 30, 34, 37, 38, 42, 43, 47, 48, 49, 51}},
{"Undiq", {5, 245, 109}, 0, {19, 18, 65, 75, 18, 38, 64, 57, 10, 13, 5, 20}, {11, 12, 16, 17, 20, 21, 22, 26, 28, 30, 32, 34, 39, 40}},
{"Ineeng", {7, 99, 26}, 0, {19, 19, 61, 74, 17, 36, 72, 56, 10, 14, 5, 20}, {9, 15, 18, 19, 25, 30, 33, 35, 37, 38, 45, 46, 50, 53}},
{"Aldily", {7, 83, 151}, 0, {18, 19, 61, 68, 17, 37, 78, 68, 10, 14, 5, 20}, {2, 7, 12, 14, 15, 18, 20, 24, 27, 29, 40, 47, 48, 51}},
{"Aldtory", {9, 2, 216}, 3, {26, 24, 25, 101, 26, 40, 66, 33, 15, 13, 5, 20}, {3, 4, 5, 8, 10, 11, 18, 19, 22, 32, 39, 43, 46, 55}},
{"Ageold", {5, 164, 105}, 0, {18, 16, 59, 63, 17, 40, 75, 66, 9, 13, 5, 20}, {6, 11, 12, 13, 15, 18, 21, 23, 34, 35, 47, 49, 50, 55}},
{"Nyenn", {8, 224, 139}, 3, {27, 22, 26, 85, 28, 33, 68, 38, 15, 14, 5, 20}, {0, 5, 7, 18, 20, 26, 32, 33, 38, 41, 43, 45, 47, 54}},
{"Warem", {5, 183, 67}, 0, {19, 16, 60, 74, 20, 33, 75, 67, 9, 14, 5, 20}, {0, 2, 6, 7, 9, 17, 18, 21, 30, 31, 32, 38, 44, 47}},
{"Quanas", {9, 49, 233}, 3, {23, 24, 26, 97, 30, 34, 69, 33, 15, 14, 5, 20}, {12, 14, 15, 19, 22, 25, 26, 31, 33, 40, 42, 44, 50, 55}},
{"Ackunn", {8, 105, 248}, 3, {27, 25, 24, 95, 30, 37, 72, 33, 15, 14, 5, 20}, {1, 5, 7, 10, 14, 22, 23, 25, 43, 44, 46, 50, 51, 55}},
{"Esslet", {5, 58, 94}, 2, {19, 18, 43, 103, 43, 25, 47, 49, 10, 19, 5, 20}, {0, 6, 11, 13, 14, 15, 22, 23, 24, 33, 39, 46, 48, 49}},
{"Veslere", {8, 109, 43}, 3, {25, 25, 28, 84, 26, 35, 71, 37, 14, 15, 5, 20}, {6, 13, 16, 24, 25, 29, 37, 39, 40, 41, 43, 49, 53, 55}},
{"Schyim", {3, 29, 204}, 0, {19, 19, 55, 63, 18, 38, 65, 64, 10, 12, 5, 20}, {3, 5, 8, 21, 27, 29, 36, 38, 40, 46, 50, 52, 54, 55}},
{"Swolar", {5, 52, 65}, 2, {18, 18, 38, 94, 38, 24, 51, 47, 9, 16, 5, 20}, {0, 4, 6, 7, 10, 14, 22, 24, 29, 37, 41, 42, 48, 49}},
{"Aughpol", {7, 80, 225}, 3, {24, 26, 26, 95, 27, 35, 71, 33, 16, 14, 5, 20}, {0, 3, 4, 11, 12, 14, 25, 31, 32, 34, 37, 41, 45, 52}},
{"Essran", {3, 179, 232}, 0, {19, 18, 65, 66, 18, 40, 68, 58, 10, 14, 5, 20}, {3, 5, 6, 16, 18, 20, 30, 33, 35, 39, 41, 43, 49, 55}},
{"Ineray", {8, 37, 104}, 3, {25, 23, 28, 85, 29, 40, 71, 31, 14, 14, 5, 20}, {0, 4, 5, 16, 25, 35, 36, 38, 39, 41, 46, 49, 51, 52}},
{"Yaenth", {5, 17, 236}, 2, {19, 18, 38, 91, 39, 22, 55, 45, 9, 16, 5, 20}, {5, 8, 9, 11, 14, 17, 20, 21, 22, 28, 31, 37, 47, 50}},
{"Emano", {2, 182, 222}, 0, {18, 18, 54, 73, 19, 40, 73, 56, 9, 14, 5, 20}, {3, 5, 16, 18, 28, 29, 31, 35, 40, 41, 44, 52, 53, 54}},
{"Hatcdar", {2, 236, 0}, 0, {19, 18, 67, 74, 18, 35, 65, 64, 9, 15, 5, 20}, {0, 1, 2, 5, 6, 12, 22, 25, 27, 32, 39, 44, 52, 55}},
{"Raystai", {3, 123, 192}, 0, {21, 19, 61, 63, 20, 40, 74, 63, 9, 13, 5, 20}, {2, 3, 4, 10, 12, 13, 16, 19, 20, 21, 23, 24, 33, 51}},
{"Morhat", {5, 33, 161}, 2, {20, 18, 41, 92, 42, 24, 49, 43, 9, 19, 5, 20}, {1, 7, 9, 10, 29, 33, 34, 35, 37, 43, 44, 46, 47, 49}},
{"Etqua", {8, 50, 81}, 3, {26, 22, 25, 84, 29, 34, 63, 34, 16, 12, 5, 20}, {5, 7, 12, 18, 21, 31, 34, 36, 39, 40, 41, 42, 46, 53}},
{"Atque", {5, 112, 20}, 2, {22, 17, 37, 89, 43, 21, 48, 45, 10, 17, 5, 20}, {1, 7, 8, 9, 18, 19, 22, 27, 29, 31, 36, 39, 48, 49}},
{"Hatina", {6, 218, 156}, 2, {21, 18, 41, 102, 45, 21, 58, 50, 9, 18, 5, 20}, {3, 5, 11, 15, 16, 25, 29, 32, 35, 37, 38, 51, 53, 54}},
{"Queageo", {8, 75, 100}, 4, {18, 31, 43, 72, 43, 45, 47, 42, 10, 14, 5, 20}, {1, 2, 6, 9, 14, 16, 18, 24, 25, 34, 36, 38, 41, 44}},
{"Daruk", {9, 66, 73}, 3, {26, 24, 29, 88, 29, 38, 67, 31, 13, 14, 5, 20}, {2, 5, 11, 21, 22, 23, 25, 29, 30, 31, 40, 41, 46, 53}},
{"Ardale", {9, 119, 118}, 3, {24, 23, 28, 102, 31, 40, 68, 33, 13, 13, 5, 20}, {8, 11, 14, 15, 20, 23, 25, 30, 34, 35, 37, 39, 40, 53}},
{"Alehas", {8, 97, 87}, 4, {18, 31, 41, 77, 46, 50, 51, 43, 10, 14, 5, 20}, {0, 12, 18, 19, 21, 22, 34, 36, 39, 42, 46, 47, 50, 51}},
{"Tiagar", {5, 12, 56}, 2, {21, 16, 41, 90, 40, 26, 48, 45, 9, 19, 5, 20}, {0, 2, 5, 8, 10, 17, 18, 33, 35, 36, 39, 44, 46, 47}},
{"Nyray", {5, 193, 136}, 2, {20, 17, 41, 85, 43, 25, 47, 43, 10, 16, 5, 20}, {3, 8, 15, 18, 25, 26, 29, 32, 41, 45, 47, 48, 49, 50}},
{"Tusam", {1, 173, 209}, 0, {21, 19, 60, 69, 17, 34, 75, 60, 10, 15, 5, 20}, {3, 7, 8, 9, 11, 15, 19, 22, 29, 35, 40, 44, 45, 53}},
{"Shyaldy", {5, 21, 181}, 2, {20, 17, 43, 95, 44, 21, 56, 51, 9, 16, 5, 20}, {4, 5, 6, 10, 12, 13, 17, 20, 26, 32, 35, 37, 40, 48}},
{"Teaugh", {3, 252, 124}, 1, {15, 25, 37, 131, 26, 34, 85, 42, 5, 10, 5, 20}, {1, 2, 10, 14, 16, 17, 24, 29, 37, 40, 41, 42, 49, 53}},
{"Kellye", {1, 105, 31}, 0, {19, 19, 67, 68, 18, 38, 64, 63, 10, 13, 5, 20}, {2, 3, 4, 6, 8, 10, 15, 17, 20, 29, 33, 36, 42, 55}},
{"Urnaugh", {5, 106, 34}, 2, {20, 17, 37, 94, 44, 21, 49, 51, 9, 19, 5, 20}, {1, 10, 11, 12, 13, 15, 20, 25, 27, 33, 34, 41, 48, 52}},
{"Joer", {6, 87, 165}, 2, {19, 18, 36, 85, 42, 24, 47, 51, 11, 17, 5, 20}, {5, 12, 18, 25, 27, 28, 30, 31, 32, 36, 46, 49, 51, 55}},
{"Aughys", {4, 37, 38}, 1, {14, 26, 43, 149, 29, 35, 94, 48, 6, 9, 5, 20}, {4, 10, 18, 23, 27, 28, 32, 33, 35, 36, 37, 40, 49, 55}},
{"Nysback", {8, 100, 173}, 4, {18, 31, 37, 76, 44, 48, 51, 42, 9, 14, 5, 20}, {3, 9, 15, 16, 20, 22, 24, 27, 28, 43, 46, 51, 54, 55}},
{"Oughwar", {5, 15, 143}, 2, {20, 17, 43, 92, 41, 23, 55, 46, 10, 19, 5, 20}, {1, 3, 6, 10, 14, 16, 18, 22, 25, 30, 35, 37, 43, 47}},
{"Ildceri", {4, 49, 194}, 1, {15, 22, 38, 141, 31, 34, 103, 51, 5, 10, 5, 20}, {3, 4, 7, 11, 14, 18, 27, 29, 34, 39, 40, 42, 46, 53}},
{"Danech", {6, 72, 43}, 2, {20, 16, 45, 103, 38, 26, 50, 44, 9, 17, 5, 20}, {4, 5, 6, 7, 8, 9, 21, 23, 24, 33, 39, 41, 49, 50}},
{"Lorarr", {5, 37, 158}, 2, {20, 19, 37, 98, 46, 24, 50, 48, 9, 19, 5, 20}, {3, 7, 8, 10, 12, 16, 21, 22, 29, 31, 33, 42, 54, 55}},
{"Umelma", {4, 6, 59}, 1, {14, 22, 40, 142, 26, 35, 103, 48, 5, 10, 5, 20}, {2, 7, 12, 13, 14, 18, 27, 31, 35, 44, 45, 47, 48, 51}},
{"Essrald", {3, 90, 106}, 1, {15, 26, 44, 141, 26, 34, 87, 50, 5, 10, 5, 20}, {6, 7, 8, 11, 16, 18, 19, 24, 27, 29, 31, 42, 50, 52}},
{"Lyehler", {7, 50, 218}, 4, {21, 35, 42, 65, 45, 46, 47, 47, 10, 13, 5, 20}, {5, 14, 17, 18, 20, 23, 28, 33, 38, 39, 47, 49, 52, 53}},
{"Asrady", {6, 244, 93}, 4, {21, 32, 39, 65, 39, 48, 48, 49, 10, 13, 5, 20}, {0, 3, 6, 9, 12, 15, 16, 19, 20, 25, 33, 39, 49, 51}},
{"Tanceri", {6, 110, 9}, 4, {20, 30, 39, 73, 42, 47, 45, 49, 10, 12, 5, 20}, {3, 7, 8, 11, 13, 20, 21, 25, 31, 32, 34, 41, 42, 45}},
{"Nalart", {8, 207, 138}, 4, {19, 29, 40, 72, 38, 47, 51, 43, 9, 13, 5, 20}, {0, 4, 6, 9, 12, 13, 17, 18, 21, 24, 26, 45, 48, 50}},
{"Darak", {7, 213, 147}, 4, {21, 30, 40, 74, 38, 48, 42, 47, 10, 14, 5, 20}, {0, 3, 14, 17, 19, 22, 27, 28, 29, 31, 42, 44, 46, 48}},
{"Sulnala", {8, 35, 182}, 4, {21, 30, 38, 71, 42, 49, 46, 47, 10, 14, 5, 20}, {1, 6, 7, 10, 16, 20, 22, 29, 35, 38, 40, 47, 49, 50}},
{"Esthelm", {7, 157, 95}, 4, {21, 30, 39, 70, 41, 47, 47, 47, 10, 15, 5, 20}, {3, 4, 9, 13, 21, 25, 27, 29, 32, 38, 44, 49, 50, 51}},
{"Endryn", {7, 160, 144}, 4, {19, 35, 43, 65, 46, 47, 49, 42, 10, 13, 5, 20}, {3, 7, 11, 14, 19, 20, 29, 33, 34, 36, 37, 40, 51, 55}},
{"Turet", {1, 159, 32}, 1, {14, 24, 40, 136, 29, 35, 99, 43, 6, 9, 5, 20}, {0, 4, 9, 18, 20, 26, 31, 34, 36, 42, 43, 46, 49, 50}},
{"Worsaye", {7, 160, 162}, 4, {21, 35, 43, 74, 47, 46, 50, 45, 9, 14, 5, 20}, {3, 5, 6, 9, 11, 12, 13, 17, 28, 30, 35, 47, 52, 55}},
{"Beldhat", {4, 75, 134}, 1, {13, 26, 37, 135, 28, 35, 96, 43, 5, 9, 5, 20}, {3, 4, 10, 16, 21, 23, 27, 29, 33, 35, 37, 40, 48, 53}},
{"Ackvrod", {1, 206, 12}, 1, {16, 22, 38, 146, 30, 39, 92, 45, 5, 9, 5, 20}, {2, 7, 10, 12, 25, 27, 32, 36, 38, 39, 40, 48, 51, 53}},
{"Sulinau", {3, 112, 215}, 1, {14, 24, 42, 136, 31, 39, 100, 51, 5, 9, 5, 20}, {3, 8, 10, 11, 24, 28, 31, 34, 39, 41, 43, 47, 48, 55}},
{"Hinar", {7, 13, 220}, 4, {19, 35, 41, 63, 39, 47, 47, 45, 10, 13, 5, 20}, {2, 15, 16, 17, 22, 25, 29, 33, 35, 41, 45, 46, 47, 52}},
{"Muyer", {5, 144, 174}, 1, {15, 26, 43, 141, 26, 37, 102, 47, 5, 10, 5, 20}, {0, 1, 8, 11, 20, 21, 22, 27, 31, 37, 38, 41, 46, 48}},
{"Omtskel", {6, 4, 88}, 1, {15, 25, 40, 133, 31, 37, 90, 50, 5, 10, 5, 20}, {0, 3, 23, 25, 29, 30, 35, 36, 40, 42, 48, 49, 51, 52}}
};
STRPTR months[12]={
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov",
"Dec"
};
STRPTR firstnames[80]={
"Al", "Alice", "Andy", "Angus", "Anna", "Anni", "Betty", "Bill", "Bob",
"Bruce", "Carly", "Chloe", "Chuck", "Clara", "Cybil", "Dana", "David",
"Dora", "Ed", "Emma", "Ethan", "Fred", "Gary", "Greg", "Hanna", "Harry",
"Hugh", "Iggy", "Ike", "Jake", "James", "Jane", "Jason", "Jeff", "Jenny",
"Joe", "John", "Julia", "Kate", "Kim", "Lara", "Larry", "Lars", "Linda",
"Lisa", "Lois", "Louis", "Lucy", "Maria", "Marge", "Mary", "Mia", "Mike",
"Mona", "Nancy", "Neil", "Nick", "Nora", "Pat", "Paul", "Peter", "Phil",
"Pia", "Rob", "Roger", "Ron", "Ruth", "Sarah", "Selma", "Simon", "Spike",
"Steve", "Susan", "Tanya", "Tim", "Tom", "Vera", "Wendy", "Zack", "Zoe"
};
STRPTR lastnames[80]={
"Andrews", "Baker", "Barker", "Baube", "Bemis", "Blofeld", "Bond",
"Braben", "Brogden", "Bush", "Carter", "Clinton", "Cokes", "Cullen",
"Dalton", "Davies", "Delbo", "Drake", "Drougge", "Edwards", "Ferree",
"Fillis", "Flynt", "Ford", "Froholt", "Furman", "Galan", "Gates", "Gordon",
"Gore", "Grayson", "Green", "Guerra", "Haddock", "Hare", "Hefner",
"Hickman", "Hill", "Hunt", "Jameson", "Johnson", "Jung", "Jurasik", "Lane",
"Larsson", "Lennon", "Leno", "Lovejoy", "Loving", "Lowe", "Major", "Matz",
"Miner", "Monroe", "Moore", "Morency", "Mulder", "Nash", "Nixon", "Peake",
"Pilato", "Powers", "Quayle", "Ramshaw", "Reagan", "Rue", "Sawkins",
"Schwarz", "Scully", "Sellers", "Senior", "Sepelak", "Smith", "Stanz",
"Tennant", "Turner", "Venkman", "Wayne", "Welker", "Wildman"
};
STRPTR types[4]={"Crew", "Pass", "Pass", "Fail"};
STRPTR error="Error", proceed="Proceed", information="Information";
struct Image *image[407], *shipimage[8];
struct Image *panelimage, *citypanelimage, *shipviewimage, *classimage;
struct RastPort hidden_rp;
struct BitMap *hidden_bm=NULL;
struct Node *nodelist=NULL;
struct Node dockednodes[3];
struct Node freecabinsnode;
struct ship *shiplist, *ship, *currentship, *first, *second, *shipa, *shipb;
struct person *personlist, *person, *currentperson;
struct city *currentcity=NULL;
ULONG gametime, money, hour=1;
UWORD namesavailable[6400];
UWORD ships=0, howmuch, shipnum, selected, shipclass, namesleft=6400, persons=0;
WORD citydiff[64][12];
UBYTE text[4][36];
BYTE cargotype[5][12]={
{0, -1, 2, -1, -2, 0, 0, 1, 0, 0, 0, 0},
{-1, 0, 0, 2, 0, 0, 1, 0, -2, -1, 0, 0},
{0, -1, 0, 0, 2, -2, -1, 0, 0, 1, 0, 0},
{1, 0, -2, 0, 0, 0, 0, -1, 2, 0, 0, 0},
{0, 1, 0, -1, 2, 1, -2, 0, 0, 0, 0, 0}
};
UBYTE latitude[8], longitude[8], datestr[21], shipnums[256], dockstring[11],
freecabinstext[15];
UBYTE price[12] = {20, 25, 41, 94, 29, 37, 71, 47, 10, 14, 5, 20};
UBYTE *map;
WORD mapleft, maptop;
UBYTE autocenter=2, cargonum, transfermode=0, transfernum, peoplemode, textx,
texty, shippeople, cityn, shipturn=0, infomode=0, skipflag=TRUE;
BYTE currentdockedship;
double increment, slowest;
APTR logfile=NULL;
struct Image *readimage(BPTR, UWORD, UWORD, UBYTE);
void freeimage(struct Image *);
void cleanup();
void freeships();
UWORD weight(struct ship *);
void coordinatestrings(STRPTR, STRPTR, UWORD, UWORD);
void showcargostatus(UWORD, UWORD, UBYTE, UWORD, UWORD);
void moveship(BYTE, BYTE);
void setshipmoves(double);
void setshipfuel(UWORD);
void setshipfood(UWORD);
void makecargolist();
void showcargolist();
void showtransfervalues(UBYTE);
void hourly();
void cleartext();
void addtext(STRPTR);
void showtext();
void freepersons();
void datestring(STRPTR, ULONG);
void coordinatestrings(STRPTR, STRPTR, UWORD, UWORD);
void selectfirstperson();
void setmoney(ULONG);
UWORD getpay(struct ship *);
/* Loads the graphics in the accompanying data files into struct Images. */
int loadgraphics()
{
BPTR file;
UWORD i;
for (i=0; i<407; i++)
image[i]=NULL;
file=Open("SeaTrade.gfx", MODE_OLDFILE);
if (!file)
return NULL;
for (i=0; i<407; i++)
if (!(image[i]=readimage(file, 16, 16, 8)))
{
Close(file);
cleanup();
return NULL;
}
if (!(panelimage=readimage(file, 320, 256, 8)))
{
Close(file);
cleanup();
return NULL;
}
if (!(citypanelimage=readimage(file, 320, 256, 8)))
{
Close(file);
cleanup();
return NULL;
}
if (!(shipviewimage=readimage(file, 64, 64, 8)))
{
Close(file);
cleanup();
return NULL;
}
for (i=0; i<8; i++)
if (!(shipimage[i]=readimage(file, 32, 32, 8)))
{
Close(file);
cleanup();
return NULL;
}
if (!(classimage=readimage(file, 64, 112, 8)))
{
Close(file);
cleanup();
return NULL;
}
Close(file);
InitRastPort(&hidden_rp);
hidden_bm=AllocBitMap(320, 256, 8, BMF_CLEAR, NULL);
hidden_rp.BitMap=hidden_bm;
return TRUE;
}
/* Loads the palette in the accompanying data files into the screen's ViewPort.
*/
int loadpalette()
{
BPTR file;
UBYTE *data=NULL;
if (!(data=AllocVec(3080, MEMF_CLEAR)))
return NULL;
file=Open("SeaTrade.pal", MODE_OLDFILE);
if (!file)
{
FreeVec(data);
return NULL;
}
if (Read(file, data, 3080)<3080)
{
Close(file);
FreeVec(data);
return NULL;
}
LoadRGB32(&(Scr->ViewPort), data);
Close(file);
FreeVec(data);
return TRUE;
}
int allocstuff()
{
BPTR file;
map=NULL;
if (!(map=AllocVec(720000, MEMF_CLEAR)))
return FALSE;
if (!(file=Open("IslandMap.dat", MODE_OLDFILE)))
{
FreeVec(map); map=NULL;
return FALSE;
}
Read(file, map, 720000);
Close(file);
return TRUE;
}
void cleanup()
{
UWORD i;
for (i=0; i<407; i++)
freeimage(image[i]);
freeimage(panelimage);
freeimage(citypanelimage);
freeimage(shipviewimage);
for (i=0; i<8; i++)
freeimage(shipimage[i]);
freeimage(classimage);
if (map)
FreeVec(map);
freeships();
freepersons();
if (hidden_bm)
{
FreeBitMap(hidden_bm);
hidden_bm=NULL;
}
}
/* Reads a fully usable struct Image from the specified filehandle. Specify
image dimensions and depth. After use, first FreeVec(image->ImageData),
then FreeVec(image). */
struct Image *readimage(BPTR file, UWORD width, UWORD height, UBYTE depth)
{
struct Image *image;
UWORD *imagedata;
ULONG size;
if (!(image=AllocVec((ULONG)sizeof(struct Image), MEMF_CHIP)))
return NULL;
if ((width&15)==0)
size=width*height*depth/8;
else
size=((width&1008)+16)*height*depth/8;
if (!(imagedata=AllocVec(size, MEMF_CHIP)))
{
FreeVec(image);
return NULL;
}
if (!Read(file, imagedata, size))
{
FreeVec(image); FreeVec(imagedata);
return NULL;
}
image->LeftEdge=0; image->TopEdge=0; image->Width=width;
image->Height=height;
image->Depth=depth; image->ImageData=(UWORD *)imagedata;
image->PlanePick=(1<<depth)-1; image->PlaneOnOff=0; image->NextImage=NULL;
return image;
}
/* Safely frees the given struct Image. If called with a nonexistent image
(NULL pointer), does nothing. */
void freeimage(struct Image *image)
{
if (image)
{
FreeVec(image->ImageData); image->ImageData=NULL;
FreeVec(image);
}
}
/* Displays any given request with Intution EasyRequesters. */
UBYTE request(struct Window *window, STRPTR title, STRPTR text, STRPTR buttons,
APTR arg)
{
struct EasyStruct req;
req.es_StructSize=sizeof(struct EasyStruct);
req.es_Flags=0; req.es_Title=title;
req.es_TextFormat=text; req.es_GadgetFormat=buttons;
return EasyRequest(window, &req, NULL, arg);
}
/* Allocates and shows an ASL request, and allows the user to choose a file.
Returns the chosen filename in the UBYTE * buffer supplied in the second
parameter. */
int aslreq(UBYTE savemode, UBYTE *namebuffer)
{
STRPTR blurb, label;
UBYTE *p;
UBYTE result, c=0;
struct FileRequester *fr=NULL;
switch (savemode)
{
case FALSE:
blurb="Choose a file to save:"; label="Save";
break;
case TRUE:
blurb="Choose a file to load:"; label="Load";
break;
case 2:
blurb="Choose a log file:"; label="OK";
break;
}
if (fr=AllocAslRequestTags(ASL_FileRequest,
ASLFR_Window, SeaTradeWnd,
ASLFR_TitleText, blurb,
ASLFR_PositiveText, label,
ASLFR_NegativeText, (STRPTR)"Cancel",
ASLFR_InitialHeight, 224,
ASLFR_InitialWidth, 240,
ASLFR_InitialLeftEdge, 40,
ASLFR_InitialTopEdge, 20,
ASLFR_DoSaveMode, (BOOL)!!savemode,
TAG_DONE))
{
if (result=AslRequest(fr, NULL))
{
for (p=fr->rf_Dir; *p; p++);
if (p>fr->rf_Dir)
c=*(p-1);
if (c==':' || !c)
sprintf(namebuffer,"%s%s", fr->rf_Dir, fr->rf_File);
else
sprintf(namebuffer,"%s/%s", fr->rf_Dir, fr->rf_File);
}
FreeAslRequest(fr);
}
return result;
}
/* Finds out the size of the file associated with the given handle. Uses an
AmigaDOS FileInfoBlock as a measuring device. */
ULONG sizeoffile(BPTR file)
{
struct FileInfoBlock fib;
ULONG size=0L;
ExamineFH(file, &fib);
size=(ULONG)fib.fib_Size;
return size;
}
/* Changes the state of a menuitem. Supply the index numbers of the menu and the
item (NOT the actual pointers!) and a boolean state (disabled/enabled). */
void menuonoff(UBYTE menu, UBYTE item, UBYTE state)
{
if (state)
OnMenu(SeaTradeWnd, FULLMENUNUM(menu, item, NOSUB));
else
OffMenu(SeaTradeWnd,FULLMENUNUM(menu, item, NOSUB));
}
/* Changes the state of a submenuitem. Supply the index number of the menu, the
item and the subitem (NOT the actual pointers!) and a boolean state
(disabled/enabled). */
void submenuonoff(UBYTE menu, UBYTE item, UBYTE sub, UBYTE state)
{
if (state)
OnMenu(SeaTradeWnd, FULLMENUNUM(menu, item, sub));
else
OffMenu(SeaTradeWnd, FULLMENUNUM(menu, item, sub));
}
/* Returns a pseudo-random number from 0 to (maxvalue-1). */
long rnd(long maxvalue)
{
static int seed=0;
if (!seed)
{
seed=(int)time(NULL);
srand(seed);
}
return rand()%maxvalue;
}
UWORD getblocktype(UWORD x, UWORD y)
{
struct ship *ship;
ULONG lsb, msb;
UWORD result;
UBYTE bit;
for (ship=shiplist; ship; ship=ship->next);
lsb=x+800*y; msb=640000+x/8+100*y;
result=*(map+lsb);
bit=!!(*(map+msb) & 1<<(x&7));
result+=256*bit;
return result;
}
/* Draws the given Image to the given RastPort. Supply RastPort, index number of
Image, and block (not pixel) coordinates. */
void drawimage(struct RastPort *rp, UWORD num, UBYTE px, UBYTE py)
{
DrawImage(rp, image[num], 8+px*16, 8+py*16);
}
/* Superimposes the given Image onto the one currently ready to be copied at
hidden_rp. First ANDs the block with the given Image's "mask", then ORs the
block with the Image itself. */
void superimpose(struct RastPort *rp, UWORD num, UBYTE px, UBYTE py)
{
UWORD mask;
if (num>=375 && num<379) /* facing right, lights on */
mask=num+16;
if (num>=379 && num<387) /* facing right, lights off or facing left, lights
on */
mask=num+12;
if (num>=387 && num<395) /* facing left, lights off or facing right, lights
on, selected */
mask=num+8;
if (num>=395 && num<403) /* facing right, lights off, selected or facing
left, lights on, selected */
mask=num+4;
if (num>=403 && num<407) /* facing left, lights off, selected */
mask=num;
if (num>=391) /* if ship is selected, it uses same image as non-selected
ship */
num-=16;
drawimage(&hidden_rp, mask, 0, 11);
ClipBlit(&hidden_rp, 8, 184, rp, 8+px*16, 8+py*16, 16, 16, 0x80);
drawimage(&hidden_rp, num, 0, 11);
ClipBlit(&hidden_rp, 8, 184, rp, 8+px*16, 8+py*16, 16, 16, 0xE0);
}
void writelog(STRPTR text)
{
if (!logfile)
return;
Write(logfile, text, strlen(text));
}
void writelogdate()
{
UBYTE logdatestr[21];
datestring(logdatestr, gametime);
writelog(logdatestr);
}
void setshiplocation(struct ship *s, UWORD x, UWORD y)
{
ULONG loc;
loc=x+800*y;
s->location[0]=loc>>16;
s->location[1]=loc>>8&255;
s->location[2]=loc&255;
}
void getshiplocation(struct ship *s, UWORD *x, UWORD *y)
{
ULONG loc;
loc = (s->location[0]<<16) + (s->location[1]<<8) + s->location[2];
*x=loc%800; *y=loc/800;
}
void getcitylocation(struct city *s, UWORD *x, UWORD *y)
{
ULONG loc;
loc = (s->location[0]<<16) + (s->location[1]<<8) + s->location[2];
*x=loc%800; *y=loc/800;
}
/* Returns the image index (not the struct Image *) for a ship based on size
class and three flags. First flag is 0 for left-facing ships, 1 for right-
facing ships. Second flag is 0 for inactive ships, 1 for active ships. Third
flag is 0 for non-selected ships, 1 for selected ships. */
UWORD getshipimage(UBYTE size, UBYTE face, UBYTE active, UBYTE selected)
{
UWORD im;
im=375+size;
if (!face)
im+=8;
if (!active)
im+=4;
if (selected)
im+=16;
return im;
}
void drawmap(WORD left, WORD top)
{
UWORD sx, sy, currentx, currenty;
UBYTE x, y, direction, movesleft, iscurrent;
struct ship *s, *found;
if (left<0)
mapleft=left=0;
if (top<0)
maptop=top=0;
if (left>788)
mapleft=left=788;
if (top>788)
maptop=top=788;
getshiplocation(currentship, ¤tx, ¤ty);
for (x=0; x<11; x++)
for (y=0; y<11; y++)
{
drawimage(&hidden_rp, getblocktype(left+x, top+y), x, y);
found=NULL;
for (s=shiplist; s; s=s->next)
{
getshiplocation(s, &sx, &sy);
if (sx==left+x && sy==top+y)
{
direction=(s->flags&4)/4;
movesleft=s->moves>=1.0;
iscurrent=s==currentship;
found=s;
if (iscurrent || sx!=currentx || sy!=currenty)
break;
}
}
if (found)
superimpose(&hidden_rp, getshipimage(found->class/14, direction,
movesleft, iscurrent), x, y);
}
ClipBlit(&hidden_rp, 8, 8, SeaTradeWnd->RPort, 8, 8, 176, 176, 0xC0);
}
/* Adds a new ship to our list. The variable "ship" will point to the list's
tail. Returns a pointer to the new ship. Supplied parameters: ship name,
index number of ship class. */
struct ship *createship(STRPTR name, UBYTE class)
{
struct ship *newship;
if (!(newship=AllocVec(sizeof(struct ship), MEMF_CLEAR)))
return NULL;
CopyMem(name, newship->name, 13);
newship->class=class;
if (!shiplist)
shiplist=ship=newship;
else
{
ship->next=newship;
newship->prev=ship;
ship=newship;
}
/* detach list from ListView gadget to allow editing */
GT_SetGadgetAttrs(SeaTradeGadgets[11], SeaTradeWnd, NULL, GTLV_Labels,
(struct List *)~0, TAG_DONE);
AddTail(&Ships0List, &newship->node);
newship->node.ln_Name=newship->name;
/* reattach list to ListView gadget to update display */
GT_SetGadgetAttrs(SeaTradeGadgets[11], SeaTradeWnd, NULL, GTLV_Labels,
&Ships0List, TAG_DONE);
ships++;
return newship;
}
/* Renames the given ship. Since thisship->node->ln_Name already points to the
same memory location as thisship->name, all we need to update the ship
ListViewgadget is to detach and reattach the list. */
void renameship(struct ship *thisship, STRPTR name)
{
UBYTE message[80];
/* detach list from ListView gadget to allow editing */
GT_SetGadgetAttrs(SeaTradeGadgets[11], SeaTradeWnd, NULL, GTLV_Labels,
(struct List *)~0, TAG_DONE);
sprintf(message, ": The %s class ship \"%s\" was renamed \"%s\".\n",
class[thisship->class].name, thisship->name, name);
writelogdate();
writelog(message);
CopyMem(name, thisship->name, 13);
/* reattach list to ListView gadget to update display */
GT_SetGadgetAttrs(SeaTradeGadgets[11], SeaTradeWnd, NULL, GTLV_Labels,
&Ships0List, TAG_DONE);
}
/* Deletes the given ship from the list. */
void deleteship(struct ship *oldship)
{
if (!oldship)
return;
if (oldship->prev)
oldship->prev->next=oldship->next;
if (oldship->next)
oldship->next->prev=oldship->prev;
if (oldship==ship)
ship=oldship->prev;
if (oldship==shiplist)
shiplist=ship=NULL;
/* detach list from ListView gadget to allow editing */
GT_SetGadgetAttrs(SeaTradeGadgets[11], SeaTradeWnd, NULL, GTLV_Labels,
(struct List *)~0, TAG_DONE);
Remove(&oldship->node);
/* reattach list to ListView gadget to update display */
GT_SetGadgetAttrs(SeaTradeGadgets[11], SeaTradeWnd, NULL, GTLV_Labels,
&Ships0List, TAG_DONE);
FreeVec(oldship);
ships--;
}
/* Deletes all the ships from the list. */
void freeships()
{
struct ship *ship1, *ship2;
ship1=shiplist;
while (ship1)
{
ship2=ship1->next;
FreeVec(ship1);
ship1=ship2;
}
}
/* Creates a new person. Supplied parameters are: Person type and name (array
index), amount of pay person demands or offers, deadline before which person
must be handled, pointer to city where person appears, array index of city
where person wants to go. */
struct person *createperson(UWORD pay, ULONG deadline, struct city *location,
UBYTE destination)
{
struct person *newperson;
UWORD nameno, i;
if (namesleft)
{
nameno=rnd(namesleft);
if (nameno<namesleft-1)
for (i=nameno; i<namesleft-1; i++)
namesavailable[i]=namesavailable[i+1];
namesleft--;
}
else
{
namesleft=6400;
for (i=0; i<6400; i++)
namesavailable[i]=i;
nameno=rnd(namesleft);
}
if (!(newperson=AllocVec(sizeof(struct person), MEMF_CLEAR)))
return NULL;
sprintf(newperson->name, "%s %s", firstnames[namesavailable[nameno]%80],
lastnames[namesavailable[nameno]/80]);
newperson->node.ln_Name=newperson->name;
newperson->pay=pay; newperson->deadline=deadline;
newperson->location=location; newperson->destination=destination;
persons++;
return newperson;
}
void settype(struct person *p, UBYTE type)
{
p->flags=(p->flags & TYPEMASK) | ((type & 3) << 9);
}
UBYTE gettype(struct person *p)
{
return (p->flags >> 9) & 3;
}
void setloc(struct person *p, UWORD loc)
{
p->flags=(p->flags & LOCMASK) | (loc & 0x1FF);
}
UWORD getmark(struct person *p)
{
return p->flags & (CONTRACTMARK | FAILMARK);
}
void setmark(struct person *p, UWORD mark)
{
p->flags = (p->flags & MARKMASK) | mark;
}
UWORD getloc(struct person *p)
{
return p->flags & 0x1FF;
}
/* Adds the given person to the list. Persons are sorted in order of deadline,
earliest deadline first. */
void addperson(struct person *thisperson)
{
struct person *pointer;
if (!personlist)
personlist=person=thisperson;
else
{
pointer=person;
while (pointer && pointer->deadline > thisperson->deadline)
pointer=pointer->prev;
if (!pointer)
{
thisperson->next=personlist;
personlist->prev=thisperson;
personlist=thisperson;
}
else
{
thisperson->prev=pointer;
thisperson->next=pointer->next;
pointer->next->prev=thisperson;
pointer->next=thisperson;
if (pointer==person)
person=thisperson;
}
}
}
/* Creates a new passenger to one of the 64 cities. The passenger will have a
random destination, deadline, and payment offer. */
void createpassenger()
{
struct person *newperson;
LONG hurry;
WORD x1, y1, x2, y2, dx, dy;
UWORD pay;
UBYTE fromcity, tocity, attempts;
double d, dmodifier, hurrymodifier, rmodifier;
fromcity=rnd(64);
getcitylocation(&city[fromcity], &x1, &y1);
attempts=0;
do
{
tocity=rnd(64);
if (fromcity!=tocity)
{
getcitylocation(&city[tocity], &x2, &y2);
dx=x1-x2; dy=y1-y2;
d=sqrt(dx*dx + dy*dy);
}
else
d=0.0;
attempts++;
}
while ((d<60.0 || d>=240.0) && attempts<200);
if (attempts==200)
return; /* Give up after 200 attempts, to prevent infinite loops */
/* How much of a hurry the passenger is in? The times the passenger has to
travel range from 6 to 18 hours. A time of 6 hours will cause a
modifier of 1.25, a time of 18 hours a modifier of 0.75. */
hurry=rnd(43200);
hurrymodifier=1.0+(21600-hurry)/86400.0;
/* How far the passenger wants to go? The distances range from 60 to 240
squares. A distance of 60 squares will cause a modifier of 0.5, a
distance of 240 squares a modifier of 1.5. */
dmodifier=1.0+(d-150.0)/180.0;
/* And to spice it up, a random modifier from 0.9 to 1.1. */
rmodifier=1.0+(rnd(20)-10)/100.0;
pay=(400*dmodifier*hurrymodifier*rmodifier) + (fromcity<<10);
newperson=createperson(pay, gametime+21600+hurry, &city[fromcity], tocity);
if (newperson)
{
addperson(newperson);
settype(newperson, TOURIST);
setloc(newperson, fromcity);
}
}
/* Creates a new potential crew member (ie. a person looking for work) in one of
the 64 cities. The person will have a random deadline and salary demand. */
void createcrew()
{
struct person *newperson;
UBYTE incity;
incity=rnd(64);
newperson=createperson(rnd(20)+25, gametime+21600+rnd(43200), &city[incity],
0);
if (newperson)
{
addperson(newperson);
settype(newperson, CREW);
setloc(newperson, incity);
}
}
/* Deletes the given person from the list. */
void freeperson(struct person *oldperson)
{
if (oldperson==personlist)
personlist=oldperson->next;
else
oldperson->prev->next=oldperson->next;
if (oldperson==person)
person=oldperson->prev;
else
oldperson->next->prev=oldperson->prev;
FreeVec(oldperson);
persons--;
}
void freepersons()
{
struct person *p, *pp;
p=personlist;
while (p)
{
pp=p->next;
freeperson(p);
p=pp;
}
}
/* Makes a list of the persons in a given place (whether it's a city or a ship).
Since one person can be only in one place at a time, there's no need to store
the nodes in multiple lists, and the list can be cleared at the start of this
function. Supplied parameters: pointer to list to create, pointer to city or
ship where the persons are. */
void createpersonlist(struct MinList *list, void *location, UBYTE type)
{
struct person *p;
UBYTE flag;
NewList(list);
if (list!=&CityList8List)
shippeople=0;
for (p=personlist; p; p=p->next)
if (p->location == location)
{
flag=FALSE;
switch (type)
{
case CREW:
flag=(gettype(p)==CREW); break;
case (UBYTE)~0:
flag=TRUE; break;
default:
flag=(gettype(p)!=CREW); break;
}
if (flag)
{
if (list!=&List1List && list!=&Items2List)
AddTail(list, &p->node);
else
{
sprintf(labels[shippeople], "%13s (%s)", p->name,
types[gettype(p)]);
AddTail(list, &List1Nodes[shippeople]);
}
if (list!=&CityList8List)
shippeople++;
}
}
if (location!=¤tcity->store)
if (list!=&List1List && list!=&Items2List)
{
sprintf(freecabinstext, "%2d free cabins",
class[currentship->class].cabins - currentship->crew -
currentship->passengers);
freecabinsnode.ln_Name=freecabinstext;
if (list!=&CityList8List)
AddTail(list, &freecabinsnode);
}
else
{
sprintf(labels[shippeople], "Free cabins left: %2d",
class[currentship->class].cabins - currentship->crew -
currentship->passengers);
AddTail(list, &List1Nodes[shippeople]);
}
}
/* Returns the (index-1)th person whose location is the one specified. For
instance, use findperson(currentcity, 0) to find the first person in the
current city. */
struct person *findperson(void *location, LONG index, UBYTE type)
{
struct person *p;
LONG i=-1;
UBYTE flag;