annotate src/tool-util.c @ 17:65de6eb6861a

Indenting...
author darius
date Wed, 24 Dec 1997 12:37:24 +0000
parents 0836fb919dfa
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1 #include "config.h"
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
2
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
3 #include "tool-util.h"
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
4 #include "shmem.h"
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
5 #include "data.h"
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
6
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
7 char
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
8 team_to_letter(t)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
9 int t;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
10 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
11 switch (t)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
12 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
13 case FED:
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
14 return 'F';
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
15 case ROM:
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
16 return 'R';
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
17 case KLI:
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
18 return 'K';
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
19 case ORI:
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
20 return 'O';
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
21 default:
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
22 return 'I';
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
23 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
24 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
25
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
26 int
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
27 letter_to_team(ch)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
28 char ch;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
29 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
30 switch (ch)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
31 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
32 case 'I':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
33 case 'i':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
34 return 0;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
35 case 'F':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
36 case 'f':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
37 return FED;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
38 case 'R':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
39 case 'r':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
40 return ROM;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
41 case 'K':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
42 case 'k':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
43 return KLI;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
44 case 'O':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
45 case 'o':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
46 return ORI;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
47 default:
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
48 return -1;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
49 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
50 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
51
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
52 int
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
53 letter_to_pnum(ch)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
54 char ch;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
55 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
56 switch (ch)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
57 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
58 case '0':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
59 case '1':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
60 case '2':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
61 case '3':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
62 case '4':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
63 case '5':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
64 case '6':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
65 case '7':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
66 case '8':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
67 case '9':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
68 return ch - '0';
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
69
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
70 case 'a':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
71 case 'b':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
72 case 'c':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
73 case 'd':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
74 case 'e':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
75 case 'f':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
76 case 'g':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
77 case 'h':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
78 case 'i':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
79 case 'j':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
80 case 'k':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
81 case 'l':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
82 case 'm':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
83 case 'n':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
84 case 'o':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
85 case 'p':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
86 case 'q':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
87 case 'r':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
88 case 's':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
89 case 't':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
90 case 'u':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
91 case 'v':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
92 case 'w':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
93 case 'x':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
94 case 'y':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
95 case 'z':
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
96 return ch - 'a' + 10;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
97 default:
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
98 return -1;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
99 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
100 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
101
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
102 char
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
103 pnum_to_letter(ch)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
104 int ch;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
105 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
106 switch (ch)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
107 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
108 case 0:
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
109 case 1:
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
110 case 2:
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
111 case 3:
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
112 case 4:
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
113 case 5:
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
114 case 6:
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
115 case 7:
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
116 case 8:
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
117 case 9:
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
118 return ch + '0';
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
119 default:
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
120 return ch - 10 + 'a';
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
121 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
122 }
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
123
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
124
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
125 char *
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
126 twoletters(pl)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
127 struct player *pl;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
128 /* calculate the two letters that form the players designation (e.g. R4) */
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
129 {
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
130 #define RINGSIZE MAXPLAYER+3
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
131 static char buf[RINGSIZE][3]; /* ring of buffers so that this */
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
132 static int idx; /* proc can be called several times before
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
133 * the results are used */
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
134 if (idx >= RINGSIZE)
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
135 idx = 0;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
136 buf[idx][0] = teams[pl->p_team].letter;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
137 buf[idx][1] = shipnos[pl->p_no];
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
138 buf[idx][2] = 0;
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
139 return buf[idx++];
0836fb919dfa First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
140 }