]> git.pond.sub.org Git - empserver/blob - scripts/bigstart
client: Make get_password() not echo with POSIX && !HAVE_GETPASS
[empserver] / scripts / bigstart
1 #!/bin/awk -f
2 #
3 #  IMPORTANT: You must change "height" and "width" by hand below.
4 #
5 #       A deity tool to parse a dump file and generate edit commands
6 #       to build larger start sanctuaries.
7 #               dump * | bigstart >bigstart.out
8 #               exec bigstart.out
9 #       -Drake (dld@chem.psu.edu)
10
11
12 function sanctuary(x,y,o,nsect)
13 {
14   if (x>=width/2) x -= width;
15   if (y>=height/2) y -= height;
16   if (x<-width/2) x += width;
17   if (y<-height/2) y+= height;
18
19   nsect = x "," y;
20   if ((nsect in newown) && !(nsect in own)) {
21     printf("des %s s\n",nsect);
22     printf("give civ %s 550\n",nsect);
23     printf("setsector oldowner %s %d\n",nsect,o);
24     printf("setsector owner %s %d\n",nsect,o);
25     printf("setsector work %s 100\n",nsect);
26     own[nsect]=o;
27     delete newown[nsect];
28     added++;
29   }
30 }
31
32
33 BEGIN {
34   SUBSEP=",";
35   sects=0;
36   begin=0;
37   width=64;
38   height=32;
39 }
40
41
42 {
43
44   if (begin==1) {
45     for (i=1;i<=NF;i++) header[i]=$i;
46     nheader=NF;
47     begin=2;
48     break;
49   }
50
51   if (NF != nheader) {
52     begin=0;
53   }
54
55   if (begin==2) {
56     for (i=1;i<=nheader;i++) {
57       val[header[i]] = $i;
58     }
59     if (val["own"]==0 && val["des"]=="-") {
60       newown[val["x"],val["y"]]=0;
61     }
62     if (val["own"]>0) {
63       own[val["x"],val["y"]]=val["own"];
64     }
65   }
66 }
67
68 / *DUMP SECTOR/ { begin=1; }
69
70 END {
71   do {
72     added=0;
73     for (sect in own) {
74       split(sect,a,",");
75       x=a[1];
76       y=a[2];
77       
78       sanctuary(x+2,y,own[sect]);
79       sanctuary(x-2,y,own[sect]);
80       sanctuary(x+1,y+1,own[sect]);
81       sanctuary(x+1,y-1,own[sect]);
82       sanctuary(x-1,y+1,own[sect]);
83       sanctuary(x-1,y-1,own[sect]);
84     }
85   } while (added);
86 }