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