-
Notifications
You must be signed in to change notification settings - Fork 0
/
CONQOPER.R
2371 lines (2127 loc) · 55.8 KB
/
CONQOPER.R
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
###############################################################################
#
# C O N Q O P E R
#
# Copyright (C)1983-1986 by Jef Poskanzer and Craig Leres
#
# Permission to use, copy, modify, and distribute this software and
# its documentation for any purpose and without fee is hereby granted,
# provided that this copyright notice appear in all copies and in all
# supporting documentation. Jef Poskanzer and Craig Leres make no
# representations about the suitability of this software for any
# purpose. It is provided "as is" without express or implied warranty.
#
###############################################################################
#
# Detailed revision history lives in "incl/conqdef"
#
###############################################################################
include "conqdef"
### conqoper - main program
#
DRIVER(conqoper)
NOIMPLICIT
integer cdcols, cdlins, strcmp, spawn, i
logical l, isagod, ioautobroad
character name(MAXUSERNAME)
string cpr COPYRIGHT
string vern VERSION_NUMBER
string verd VERSION_DATE
include "conqcom2"
call glname( name )
if ( ! isagod( name ) )
{
call putlin( "Poor cretins such as yourself lack the", ERROUT )
call error( " skills necessary to use this program." )
}
call rndini( 0, 0 ) # initialize random numbers
call cdinit # initialize display environment
l = ioautobroad( .false. ) # turn OFF automatic broadcasts
cunum = MSG_GOD # stow user number
cmaxlin = cdlins( 0 ) # number of lines
cmaxcol = cdcols( 0 ) # number of columns
call operate
call cdend
DRETURN
end
### bigbang - fire a torp from every ship
#
# SYNOPSIS
# call bigbang
#
subroutine bigbang
NOIMPLICIT
integer i, snum, cnt
real dir, mod360
logical launch
include "conqcom"
dir = 0.0
cnt = 0
for ( snum = 1; snum <= MAXSHIPS; snum = snum + 1 )
if ( sstatus(snum) == SS_LIVE )
for ( i = 1; i <= MAXTORPS; i = i + 1 )
if ( ! launch( snum, dir ) )
break
else
{
dir = mod360( dir + 40.0 )
cnt = cnt + 1
}
call cerror( MSG_GOD,
"bigbang: Fired %d torpedos, hoo hah won't they be surprised!", cnt )
return
end
### debugdisplay - verbose and ugly version of display
#
# SYNOPSIS
# integer snum
# call debugdisplay( snum )
#
subroutine debugdisplay( snum )
NOIMPLICIT
integer snum
# The following aren't displayed by this routine...
#
# logical ssrpwar(snum,NUMPLANETS) # self-ruled planets s/he is at war
# integer slastmsg(snum) # last message seen
# integer salastmsg(snum) # last message allowed to be seen
# logical smap(snum) # strategic map or not
# integer spfuse(snum) # tenths until phasers can be fired
# integer sscanned(snum,NUMTEAMS) # fuse for which ships have been
# logical stalert(snum) # torp alert!
# integer sctime(snum) # cpu hundreths at last check
# integer setime(snum) # elapsed hundreths at last check
# integer scacc(snum) # accumulated cpu time
# integer seacc(snum) # accumulated elapsed time
integer i, j, unum, lin, col, tcol, dcol
real x
character cupper, buf(MSGMAXLINE)
include "conqcom"
include "conqcom2"
call cdclrl( 1, MSG_LIN1 - 1 ) # don't clear the message lines
unum = suser(snum)
lin = 1
tcol = 1
dcol = tcol + 10
call cdputs( " ship:", lin, tcol )
buf(1) = EOS
call appship( snum, buf )
if ( srobot(snum) )
call appstr( " (ROBOT)", buf )
call cdputs( buf, lin, dcol )
lin = lin + 1
call cdputs( " sx:", lin, tcol )
call cdputr( oneplace(sx(snum)), 0, lin, dcol )
lin = lin + 1
call cdputs( " sy:", lin, tcol )
call cdputr( oneplace(sy(snum)), 0, lin, dcol )
lin = lin + 1
call cdputs( " sdx:", lin, tcol )
call cdputr( oneplace(sdx(snum)), 0, lin, dcol )
lin = lin + 1
call cdputs( " sdy:", lin, tcol )
call cdputr( oneplace(sdy(snum)), 0, lin, dcol )
lin = lin + 1
call cdputs( " skills:", lin, tcol )
call cdputr( oneplace(skills(snum)), 0, lin, dcol )
lin = lin + 1
call cdputs( " swarp:", lin, tcol )
x = oneplace(swarp(snum))
if ( x == ORBIT_CW )
call cdputs( "ORBIT_CW", lin, dcol )
else if ( x == ORBIT_CCW )
call cdputs( "ORBIT_CCW", lin, dcol )
else
call cdputr( x, 0, lin, dcol )
lin = lin + 1
call cdputs( " sdwarp:", lin, tcol )
call cdputr( oneplace(sdwarp(snum)), 0, lin, dcol )
lin = lin + 1
call cdputs( " shead:", lin, tcol )
call cdputn( round(shead(snum)), 0, lin, dcol )
lin = lin + 1
call cdputs( " sdhead:", lin, tcol )
call cdputn( round(sdhead(snum)), 0, lin, dcol )
lin = lin + 1
call cdputs( " sarmies:", lin, tcol )
call cdputn( sarmies(snum), 0, lin, dcol )
lin = 1
tcol = 23
dcol = tcol + 12
call cdputs( " name:", lin, tcol )
if ( spname(1,snum) != EOS )
call cdputs( spname(1,snum), lin, dcol )
lin = lin + 1
call cdputs( " username:", lin, tcol )
buf(1) = EOS
if ( unum >= 1 & unum <= MAXUSERS )
{
call strcpy( uname(1,unum), buf )
if ( buf(1) != EOS )
call appchr( ' ', buf )
}
call appchr( '(', buf )
call appint( unum, buf )
call appchr( ')', buf )
call cdputs( buf, lin, dcol )
lin = lin + 1
call cdputs( " slock:", lin, tcol )
call cdputs( " dtt:", lin + 1, tcol )
i = slock(snum)
if ( -i >= 1 & -i <= NUMPLANETS )
{
call cdputs( pname(1,-i), lin, dcol )
call cdputn( round( dist( sx(snum), sy(snum), px(-i), py(-i) ) ),
0, lin + 1, dcol )
}
else if ( i != 0 )
call cdputn( i, 0, lin, dcol )
lin = lin + 2
call cdputs( " sfuel:", lin, tcol )
call cdputn( round(sfuel(snum)), 0, lin, dcol )
lin = lin + 1
call cdputs( " w/e:", lin, tcol )
call prints( buf, "%d/%d", sweapons(snum), sengines(snum) )
if ( swfuse(snum) > 0 | sefuse(snum) > 0 )
{
call appstr( " (", buf )
call appint( swfuse(snum), buf )
call appchr( '/', buf )
call appint( sefuse(snum), buf )
call appchr( ')', buf )
}
call cdputs( buf, lin, dcol )
lin = lin + 1
call cdputs( " temp:", lin, tcol )
call prints( buf, "%d/%d", round(swtemp(snum)), round(setemp(snum)) )
call cdputs( buf, lin, dcol )
lin = lin + 1
call cdputs( " ssdfuse:", lin, tcol )
i = ssdfuse(snum)
buf(1) = EOS
if ( i != 0 )
{
call prints( buf, "%d ", i )
}
if ( scloaked(snum) )
call appstr( "(CLOAKED)", buf )
call cdputs( buf, lin, dcol )
lin = lin + 1
call cdputs( " spid:", lin, tcol )
i = spid(snum)
if ( i != 0 )
{
call prints( buf, "%08x", i )
call cdputs( buf, lin, dcol )
}
lin = lin + 1
call cdputs( "slastblast:", lin, tcol )
call cdputr( oneplace(slastblast(snum)), 0, lin, dcol )
lin = lin + 1
call cdputs( "slastphase:", lin, tcol )
call cdputr( oneplace(slastphase(snum)), 0, lin, dcol )
lin = 1
tcol = 57
dcol = tcol + 12
call cdputs( " sstatus:", lin, tcol )
buf(1) = EOS
call appsstatus( sstatus(snum), buf )
call cdputs( buf, lin, dcol )
lin = lin + 1
call cdputs( " skilledby:", lin, tcol )
i = skilledby(snum)
if ( i != 0 )
{
buf(1) = EOS
call appkb( skilledby(snum), buf )
call cdputs( buf, lin, dcol )
}
lin = lin + 1
call cdputs( " shields:", lin, tcol )
call cdputn( round(sshields(snum)), 0, lin, dcol )
if ( ! sshup(snum) )
call cdput( 'D', lin, dcol+5 )
lin = lin + 1
call cdputs( " sdamage:", lin, tcol )
call cdputn( round(sdamage(snum)), 0, lin, dcol )
if ( srmode(snum) )
call cdput( 'R', lin, dcol+5 )
lin = lin + 1
call cdputs( " stowedby:", lin, tcol )
i = stowedby(snum)
if ( i != 0 )
{
buf(1) = EOS
call appship( i, buf )
call cdputs( buf, lin, dcol )
}
lin = lin + 1
call cdputs( " stowing:", lin, tcol )
i = stowing(snum)
if ( i != 0 )
{
buf(1) = EOS
call appship( i, buf )
call cdputs( buf, lin, dcol )
}
lin = lin + 1
call cdputs( " swar:", lin, tcol )
buf(1) = '('
for ( i = 1; i <= NUMTEAMS; i = i + 1 )
if ( swar(snum,i) )
buf(i+1) = chrteams(i)
else
buf(i+1) = '-'
buf(NUMTEAMS+2) = ')'
buf(NUMTEAMS+3) = EOS
call fold( buf )
call cdputs( buf, lin, dcol )
lin = lin + 1
call cdputs( " srwar:", lin, tcol )
buf(1) = '('
for ( i = 1; i <= NUMTEAMS; i = i + 1 )
if ( srwar(snum,i) )
buf(i+1) = chrteams(i)
else
buf(i+1) = '-'
buf(NUMTEAMS+2) = ')'
buf(NUMTEAMS+3) = EOS
call cdputs( buf, lin, dcol )
lin = lin + 1
call cdputs( " soption:", lin, tcol )
call strcpy( "(gpainte)", buf )
for ( i = 1; i <= MAXOPTIONS; i = i + 1 )
if ( soption(snum,i) )
buf(i+1) = cupper(buf(i+1))
call cdputs( buf, lin, dcol )
lin = lin + 1
call cdputs( " uoption:", lin, tcol )
if ( unum >= 1 & unum <= MAXUSERS )
{
call strcpy( "(gpainte)", buf )
for ( i = 1; i <= MAXOPTIONS; i = i + 1 )
if ( uoption(unum,i) )
buf(i+1) = cupper(buf(i+1))
call cdputs( buf, lin, dcol )
}
lin = lin + 1
call cdputs( " saction:", lin, tcol )
i = saction(snum)
if ( i != 0 )
{
call robstr( i, buf )
call cdputs( buf, lin, dcol )
}
lin = cmaxlin - MAXTORPS - 2
call cdputs(
"tstatus tfuse tmult tx ty tdx tdy twar",
lin, 3 )
for ( i = 1; i <= MAXTORPS; i = i + 1 )
{
lin = lin + 1
call cdputn( tstatus(snum,i), 9, lin, 1 )
if ( tstatus(snum,i) != TS_OFF )
{
call cdputn( tfuse(snum,i), 9, lin, 10 )
call cdputr( oneplace(tmult(snum,i)), 9, lin, 19 )
call cdputr( oneplace(tx(snum,i)), 9, lin, 28 )
call cdputr( oneplace(ty(snum,i)), 9, lin, 37 )
call cdputr( oneplace(tdx(snum,i)), 9, lin, 46 )
call cdputr( oneplace(tdy(snum,i)), 9, lin, 55 )
buf(1) = '('
for ( j = 1; j <= NUMTEAMS; j = j + 1 )
if ( twar(snum,i,j) )
buf(j+1) = chrteams(j)
else
buf(j+1) = '-'
buf(NUMTEAMS+2) = ')'
buf(NUMTEAMS+3) = EOS
call cdputs( buf, lin, 67 )
}
}
call cdmove( 1, 1 )
call cdplay( .true. )
return
end
### debugplan - debugging planet list
#
# SYNOPSIS
# call debugplan
#
subroutine debugplan
NOIMPLICIT
integer i, j, lin, col, olin, sv(NUMPLANETS)
logical l, more, init
character buf(MSGMAXLINE), junk(10), uninhab(20)
include "conqcom"
string hd "planet C T arm uih scan planet C T arm uih scan"
data init / .false. /
if ( ! init )
{
for ( i = 1; i <= NUMPLANETS; i = i + 1 )
sv(i) = i
init = .true.
}
call sortplanets( sv )
call cdclear
call strcpy( hd, buf )
lin = 1
call cdputc( buf, lin )
for ( i = 1; buf(i) != EOS; i = i + 1 )
if ( buf(i) != ' ' )
buf(i) = '-'
lin = lin + 1
call cdputc( buf, lin )
lin = lin + 1
olin = lin
col = 6
for ( i = 1; i <= NUMPLANETS; i = i + 1 )
{
for ( j = 1; j <= NUMTEAMS; j = j + 1 )
if ( pscanned(sv(i),j) & j >= 1 & j <= NUMTEAMS )
junk(j) = chrteams(j)
else
junk(j) = '-'
junk(j+1) = EOS
j = puninhabtime(sv(i))
if ( j != 0 )
call prints( uninhab, "%d", j )
else
uninhab(1) = EOS
call prints( buf, "%-13s %c %c %3d %3s %4s",
pname(1,sv(i)), chrplanets(ptype(sv(i))), chrteams(pteam(sv(i))),
parmies(sv(i)), uninhab, junk )
call cdputs( buf, lin, col )
if ( ! preal(sv(i)) )
call cdput( '-', lin, col - 1 )
lin = lin + 1
if ( lin == MSG_LIN1 )
{
lin = olin
col = 44
}
}
l = more( "" )
return
end
### doomdisplay - watch the doomsday machine
#
# SYNOPSIS
# call doomdisplay
#
subroutine doomdisplay
NOIMPLICIT
integer i, lin, col, dcol
character buf(MSGMAXLINE)
include "conqcom"
call cdclear
lin = 1
col = 1
call strcpy( dname, buf )
if ( dtype != 0 )
{
call appchr( '(', buf )
call appint( dtype, buf )
call appchr( ')', buf )
}
call cdputc( buf, 1 )
lin = lin + 2
dcol = col + 11
call cdputs( " dstatus:", lin, col )
call cdputn( dstatus, 0, lin, dcol )
lin = lin + 1
call cdputs( " dx:", lin, col )
call cdputr( oneplace(dx), 0, lin, dcol )
lin = lin + 1
call cdputs( " dy:", lin, col )
call cdputr( oneplace(dy), 0, lin, dcol )
lin = lin + 1
call cdputs( " ddx:", lin, col )
call cdputr( oneplace(ddx), 0, lin, dcol )
lin = lin + 1
call cdputs( " ddy:", lin, col )
call cdputr( oneplace(ddy), 0, lin, dcol )
lin = lin + 1
call cdputs( " dhead:", lin, col )
call cdputn( round(dhead), 0, lin, dcol )
lin = lin + 1
call cdputs( " dlock:", lin, col )
call cdputs( " ddt:", lin+1, col )
i = dlock
if ( -i >= 1 & -i <= NUMPLANETS )
{
call cdputs( pname(1,-i), lin, dcol )
call cdputn( round( dist( dx, dy, px(-i), py(-i) ) ),
0, lin + 1, dcol )
}
else if ( i >= 1 & i <= MAXSHIPS )
{
buf(1) = EOS
call appship( i, buf )
call cdputs( buf, lin, dcol )
call cdputn( round( dist( dx, dy, sx(i), sy(i) ) ),
0, lin + 1, dcol )
}
else
call cdputn( i, 0, lin + 1, dcol )
lin = lin + 2
call cdmove( 1, 1 )
return
end
### gplanmatch - GOD's check if a string matches a planet name
#
# SYNOPSIS
# integer gplanmatch, pnum
# character str()
# logical status
# status = gplanmatch( str, pnum )
#
logical function gplanmatch( str, pnum )
NOIMPLICIT
character str(ARB)
integer pnum
integer i, alldig
logical planmatch, safectoi
if ( alldig( str ) == YES )
{
i = 1
if ( ! safectoi( pnum, str, i ) )
return ( .false. )
if ( pnum < 1 | pnum > NUMPLANETS )
return ( .false. )
}
else
return ( planmatch( str, pnum, .true. ) )
return ( .true. )
end
### kiss - give the kiss of death
#
# SYNOPSIS
# call kiss
#
subroutine kiss
NOIMPLICIT
integer i, snum, unum, alldig
character ch, cdgetx, buf(MSGMAXLINE)
logical l, didany, confirm, gunum, safectoi, stmatch
include "conqcom"
# Find out what to kill.
call cdclrl( MSG_LIN1, 2 )
ch = cdgetx( "Kill what (<cr> for driver)? ", MSG_LIN1, 1,
TERMS, buf, MSGMAXLINE )
if ( ch == TERM_ABORT )
{
call cdclrl( MSG_LIN1, 1 )
call cdmove( 1, 1 )
return
}
call delblanks( buf )
# Kill the driver?
if ( buf(1) == EOS )
{
if ( confirm( 0 ) )
if ( drivstat == DRS_RUNNING )
drivstat = DRS_KAMIKAZE
call cdclrl( MSG_LIN1, 2 )
call cdmove( 1, 1 )
return
}
# Kill a ship?
if ( alldig( buf ) == YES )
{
i = 1
l = safectoi( snum, buf, i ) # ignore status
if ( snum <= 0 | snum > MAXSHIPS )
call cdputs( "No such ship.", MSG_LIN2, 1 )
else if ( sstatus(snum) != SS_LIVE )
call cdputs( "You can't kill that ship.", MSG_LIN2, 1 )
else if ( confirm( 0 ) )
{
call kill( snum, KB_GOD )
call cdclrl( MSG_LIN1, 2 )
}
call cdmove( 1, 1 )
return
}
# Kill EVERYBODY?
if ( stmatch( buf, "all", .false. ) )
{
didany = .false.
for ( snum = 1; snum <= MAXSHIPS; snum = snum + 1 )
if ( sstatus(snum) == SS_LIVE )
{
didany = .true.
call cdclrl( MSG_LIN1, 1 )
call strcpy( "Kill ship ", buf )
call appship( snum, buf )
call cdputs( buf, MSG_LIN1, 1 )
if ( confirm( 0 ) )
call kill( snum, KB_GOD )
}
if ( didany )
call cdclrl( MSG_LIN1, 2 )
else
call cdputs( "Nobody here but us GODs.", MSG_LIN2, 1 )
call cdmove( 1, 1 )
return
}
# Kill a user?
if ( ! gunum( unum, buf ) )
{
call cdputs( "No such user.", MSG_LIN2, 1 )
call cdmove( 1, 1 )
return
}
# Yes.
didany = .false.
for ( snum = 1; snum <= MAXSHIPS; snum = snum + 1 )
if ( sstatus(snum) == SS_LIVE )
if ( suser(snum) == unum )
{
didany = .true.
call cdclrl( MSG_LIN1, 1 )
call strcpy( "Kill ship ", buf )
call appship( snum, buf )
call cdputs( buf, MSG_LIN1, 1 )
if ( confirm( 0 ) )
call kill( snum, KB_GOD )
}
if ( ! didany )
call cdputs( "That user isn't flying right now.", MSG_LIN2, 1 )
else
call cdclrl( MSG_LIN1, 2 )
return
end
### opback - put up the background for the operator program
#
# SYNOPSIS
# integer lastrev, savelin
# call opback( lastrev, savelin )
#
subroutine opback( lastrev, savelin )
NOIMPLICIT
integer lastrev, savelin
integer i, lin, col
include "conqcom2"
call cdclear
lin = 2
if ( lastrev == COMMONSTAMP )
call cdputc( "CONQUEST OPERATOR PROGRAM", lin )
else
{
call prints( cbuf, "CONQUEST COMMON BLOCK MISMATCH %d != %d",
lastrev, COMMONSTAMP )
call cdputc( cbuf, lin )
}
lin = lin + 2
savelin = lin
lin = lin + 3
call cdputc( "Options:", lin )
lin = lin + 2
i = lin
col = 5
call cdputs( "(f) - flip the open/closed flag", lin, col )
lin = lin + 1
call cdputs( "(d) - flip the doomsday machine!", lin, col )
lin = lin + 1
call cdputs( "(h) - hold the driver", lin, col )
lin = lin + 1
call cdputs( "(I) - initialize", lin, col )
lin = lin + 1
call cdputs( "(b) - big bang", lin, col )
lin = lin + 1
call cdputs( "(H) - user history", lin, col )
lin = lin + 1
call cdputs( "(/) - player list", lin, col )
lin = lin + 1
call cdputs( "(\) - full player list", lin, col )
lin = lin + 1
call cdputs( "(?) - planet list", lin, col )
lin = lin + 1
call cdputs( "($) - debugging planet list", lin, col )
lin = lin + 1
call cdputs( "(p) - edit a planet", lin, col )
lin = lin + 1
call cdputs( "(w) - watch a ship", lin, col )
lin = lin + 1
call cdputs( "(i) - info", lin, col )
lin = i
col = 45
call cdputs( "(r) - create a robot ship", lin, col )
lin = lin + 1
call cdputs( "(L) - review messages", lin, col )
lin = lin + 1
call cdputs( "(m) - message from GOD", lin, col )
lin = lin + 1
call cdputs( "(T) - team stats", lin, col )
lin = lin + 1
call cdputs( "(U) - user stats", lin, col )
lin = lin + 1
call cdputs( "(S) - more user stats", lin, col )
lin = lin + 1
call cdputs( "(s) - special stats page", lin, col )
lin = lin + 1
call cdputs( "(a) - add a user", lin, col )
lin = lin + 1
call cdputs( "(e) - edit a user", lin, col )
lin = lin + 1
call cdputs( "(R) - resign a user", lin, col )
lin = lin + 1
call cdputs( "(k) - kiss of death", lin, col )
lin = lin + 1
call cdputs( "(q) - exit", lin, col )
return
end
### operate - main part of the conquest operator program
#
# SYNOPSIS
# call operate
#
subroutine operate
NOIMPLICIT
integer i, lin, modp1, savelin, cntlockword, cntlockmesg
integer lastrev, msgrand, now, dgrand
character ch, buf(MSGMAXLINE), junk(MSGMAXLINE)
logical l, redraw, iochav, iogtimed, gunum, confirm
logical getamsg, readone, review
include "conqcom"
glastmsg = lastmsg
call glname( buf )
if ( gunum( i, buf ) )
uooption(i,MAXOOPTIONS) = .true.
cntlockword = 0
cntlockmesg = 0
lastrev = commonrev
call grand( msgrand )
redraw = .true.
repeat
{
if ( redraw | lastrev != commonrev )
{
lastrev = commonrev
call opback( lastrev, savelin )
redraw = .false.
}
# Line 1.
call strcpy( "game ", buf )
if ( closed )
call appstr( "CLOSED", buf )
else
call appstr( "open", buf )
call appstr( ", driver ", buf )
switch ( drivstat )
{
case DRS_OFF:
call appstr( "OFF", buf )
case DRS_RESTART:
call appstr( "RESTART", buf )
case DRS_STARTING:
call appstr( "STARTING", buf )
case DRS_HOLDING:
call appstr( "HOLDING", buf )
case DRS_RUNNING:
call appstr( "on", buf )
case DRS_KAMIKAZE:
call appstr( "KAMIKAZE", buf )
default:
call appstr( "???", buf )
}
call appstr( ", eater ", buf )
i = dstatus
if ( i == DS_OFF )
call appstr( "off", buf )
else if ( i == DS_LIVE )
{
call appstr( "ON (", buf )
i = dlock
if ( -i >= 1 & -i <= NUMPLANETS )
call appstr( pname(1,-i), buf )
else
call appship( i, buf ) # this will handle funny numbers
call appchr( ')', buf )
}
else
call appstr( "???", buf )
lin = savelin
call cdclrl( lin, 1 )
call cdputc( buf, lin )
# Line 2.
call strcpy( "lockword", buf )
if ( lockword == 0 )
cntlockword = 0
else if ( cntlockword < 5 )
cntlockword = cntlockword + 1
else
call upper( buf )
call strcpy( buf, junk )
call appstr( " = %d, ", junk )
call strcpy( "lockmesg", buf )
if ( lockmesg == 0 )
cntlockmesg = 0
else if ( cntlockmesg < 5 )
cntlockmesg = cntlockmesg + 1
else
call upper( buf )
call appstr( buf, junk )
call appstr( " = %d", junk )
call prints( buf, junk, lockword, lockmesg )
lin = lin + 1
call cdclrl( lin, 1 )
call cdputc( buf, lin )
# Display a new message, if any.
readone = .false.
if ( dgrand( msgrand, now ) >= NEWMSG_GRAND )
if ( getamsg( MSG_GOD, glastmsg ) )
{
call readmsg( MSG_GOD, glastmsg )
readone = .true.
msgrand = now
}
call cdmove( 1, 1 )
call cdplay( .true. )
# Un-read message, if there's a chance it got garbaged.
if ( readone )
if ( iochav( 0 ) )
glastmsg = modp1( glastmsg - 1, MAXMESSAGES )
# Get a character with timeout.
if ( ! iogtimed( ch, 1 ) )
next
switch ( ch )
{
case 'a':
call opuadd
redraw = .true.
case 'b':
if ( confirm( 0 ) )
call bigbang
case 'd':
if ( dstatus == DS_LIVE )
dstatus = DS_OFF
else
call doomsday
case 'e':
call opuedit
redraw = .true.
case 'f':
if ( closed )
{
closed = .false.
# Unlock the lockwords (just in case...)
PVUNLOCK(lockword)
PVUNLOCK(lockmesg)
drivstat = DRS_OFF
drivpid = 0
drivowner(1) = EOS
}
else if ( confirm( 0 ) )
closed = .true.
case 'h':
if ( drivstat == DRS_HOLDING )
drivstat = DRS_RUNNING
else
drivstat = DRS_HOLDING
case 'H':
call histlist( .true. )
redraw = .true.
case 'i':
call opinfo( MSG_GOD )
case 'I':
call opinit
redraw = .true.
case 'k':
call kiss
case 'L':
l = review( MSG_GOD, glastmsg )
case 'm':
call sendmsg( MSG_GOD, .true. )
case 'p':
call oppedit
redraw = .true.
case 'q', 'Q':
break
case 'r':
call oprobot
case 'R':
call opresign
redraw = .true.
case 's':
call opstats
redraw = .true.
case 'S':
call userstats( .true. )
redraw = .true.
case 'T':
call opteamlist
redraw = .true.
case 'U':
call userlist( .true. )
redraw = .true.
case 'w':
call watch
redraw = .true.
case '/':
call playlist( .true., .false. )
redraw = .true.
case '\':
call playlist( .true., .true. )
redraw = .true.
case '?':
call opplanlist
redraw = .true.
case '$':
call debugplan
redraw = .true.
case '@^L':
call cdredo
case ' ', TERM_NORMAL, EOS:
# do nothing
default:
call scbeep
}
# Disable messages for awhile.
call grand( msgrand )
}
return
end
### opinfo - do an operator info command
#
# SYNOPSIS
# integer snum
# call opinfo( snum )
#
subroutine opinfo( snum )
NOIMPLICIT
integer snum
integer i, j, now(7), alldig
character ch, cdgetx
logical l, extra, gplanmatch, safectoi, stmatch
string pmt "Information on: "
string huh "I don't understand."
string nf "Not found."
include "conqcom2"
call cdclrl( MSG_LIN1, 2 )