Mercurial > ~darius > hgwebdir.cgi > paradise_server
comparison src/tool-xtk.c @ 8:0836fb919dfa
First entry of Paradise Server 2.9 patch 10 Beta
author | darius |
---|---|
date | Sat, 06 Dec 1997 04:37:05 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
7:814de70c9f67 | 8:0836fb919dfa |
---|---|
1 /*-------------------------------------------------------------------------- | |
2 NETREK II -- Paradise | |
3 | |
4 Permission to use, copy, modify, and distribute this software and its | |
5 documentation, or any derivative works thereof, for any NON-COMMERCIAL | |
6 purpose and without fee is hereby granted, provided that this copyright | |
7 notice appear in all copies. No representations are made about the | |
8 suitability of this software for any purpose. This software is provided | |
9 "as is" without express or implied warranty. | |
10 | |
11 Xtrek Copyright 1986 Chris Guthrie | |
12 Netrek (Xtrek II) Copyright 1989 Kevin P. Smith | |
13 Scott Silvey | |
14 Paradise II (Netrek II) Copyright 1993 Larry Denys | |
15 Kurt Olsen | |
16 Brandon Gillespie | |
17 --------------------------------------------------------------------------*/ | |
18 | |
19 #include "config.h" | |
20 | |
21 #include <stdio.h> | |
22 | |
23 #include "defs.h" | |
24 #include "data.h" | |
25 #include "shmem.h" | |
26 #include "getship.h" | |
27 #include "tool-util.h" | |
28 | |
29 char teamlet[] = {'I', 'F', 'R', 'X', 'K', 'X', 'X', 'X', 'O'}; | |
30 char *names[] = {"Neutral", "Fed", "Rom", "", "Kli", "", "", "", "Ori"}; | |
31 | |
32 void Usage(char *myname); | |
33 void pmessage(); | |
34 | |
35 int | |
36 main(argc, argv) | |
37 int argc; | |
38 char **argv; | |
39 { | |
40 int i; | |
41 int pno; | |
42 char buf[1000]; | |
43 char *myname; | |
44 int c; | |
45 struct player *victim; | |
46 | |
47 myname = *argv; | |
48 | |
49 if (argc < 2) | |
50 Usage(myname); | |
51 | |
52 if (argv[1][1] != 0) | |
53 Usage(myname); | |
54 pno = letter_to_pnum(argv[1][0]); | |
55 if (pno < 0 || pno >= MAXPLAYER) | |
56 { | |
57 fprintf(stderr, "player number out of bounds (%d, %d)\n", | |
58 pno, MAXPLAYER); | |
59 exit(1); | |
60 } | |
61 | |
62 openmem(0); | |
63 | |
64 victim = &players[pno]; | |
65 | |
66 if (victim->p_status != PALIVE) | |
67 { | |
68 if (argc > 2 && strcmp(argv[2], "F") == 0) | |
69 { | |
70 memset(victim, 0, sizeof(struct player)); | |
71 /* bzero(victim, sizeof(struct player)); /* confusion 8/5/91 TC */ | |
72 /* victim->p_status = PFREE; */ | |
73 exit(0); | |
74 } | |
75 printf("Slot is not alive.\n"); | |
76 exit(1); | |
77 } | |
78 if (argc <= 2) | |
79 { | |
80 sprintf(buf, "%s (%2s) was utterly obliterated.", | |
81 victim->p_name, twoletters(victim)); | |
82 /* victim->p_name, victim->p_mapchars); */ | |
83 victim->p_ship.s_type = STARBASE; | |
84 victim->p_whydead = KPROVIDENCE; | |
85 victim->p_explode = 10; | |
86 victim->p_status = 3; | |
87 victim->p_whodead = 0; | |
88 pmessage(buf, 0, MALL); | |
89 exit(0); | |
90 } | |
91 switch (*argv[2]) | |
92 { | |
93 case 'e': | |
94 sprintf(buf, "%s (%2s) has been ejected from the game.", | |
95 victim->p_name, twoletters(victim)); | |
96 victim->p_whydead = KQUIT; | |
97 victim->p_explode = 10; | |
98 victim->p_status = 3; | |
99 victim->p_whodead = 0; | |
100 pmessage(buf, 0, MALL); | |
101 break; | |
102 case 's': | |
103 { | |
104 int i; | |
105 for (i = 0; i < NUM_TYPES; i++) | |
106 { | |
107 if (argv[2][1] == shipvals[i].s_letter) | |
108 break; | |
109 } | |
110 if (i >= NUM_TYPES) | |
111 { | |
112 fprintf(stderr, "Unknown ship type %c.\n", argv[2][1]); | |
113 exit(1); | |
114 } | |
115 else | |
116 { | |
117 get_ship_for_player(victim, i); | |
118 } | |
119 } | |
120 | |
121 victim->p_damage = 0; | |
122 victim->p_shield = victim->p_ship.s_maxshield; | |
123 victim->p_wtemp = 0; | |
124 victim->p_etemp = 0; | |
125 victim->p_fuel = victim->p_ship.s_maxfuel; | |
126 break; | |
127 #if 0 | |
128 case 't': | |
129 switch (argv[2][1]) | |
130 { | |
131 case 'f': | |
132 victim->p_x = planets[0].pl_x; | |
133 victim->p_y = planets[0].pl_y; | |
134 break; | |
135 case 'r': | |
136 victim->p_x = planets[10].pl_x; | |
137 victim->p_y = planets[10].pl_y; | |
138 break; | |
139 case 'k': | |
140 victim->p_x = planets[20].pl_x; | |
141 victim->p_y = planets[20].pl_y; | |
142 break; | |
143 case 'o': | |
144 victim->p_x = planets[30].pl_x; | |
145 victim->p_y = planets[30].pl_y; | |
146 break; | |
147 case 'c': | |
148 victim->p_x = GWIDTH / 2; | |
149 victim->p_y = GWIDTH / 2; | |
150 break; | |
151 default: | |
152 printf("Valid teleports: frkoc.\n"); | |
153 exit(1); | |
154 } | |
155 break; | |
156 #endif | |
157 #if 0 | |
158 case 'S': /* super ship */ | |
159 victim->p_ship.s_maxshield = 750; | |
160 victim->p_shield = 750; | |
161 victim->p_ship.s_maxdamage = 750; | |
162 victim->p_ship.s_maxegntemp = 5000; | |
163 break; | |
164 #endif | |
165 case 'T': | |
166 { | |
167 int team; | |
168 team = letter_to_team(argv[2][1]); | |
169 if (team < 0) | |
170 { | |
171 fprintf(stderr, "Invalid team letter `%c', choose one of [frkoi]\n", argv[2][1]); | |
172 exit(1); | |
173 } | |
174 victim->p_team = team; | |
175 victim->p_hostile &= ~team; | |
176 victim->p_swar &= ~team; | |
177 sprintf(buf, "%2s has been changed to a %s.", | |
178 twoletters(victim), names[team]); | |
179 pmessage(buf, 0, MALL); | |
180 #if 0 | |
181 sprintf(buf, "%c%c", teamlet[victim->p_team], | |
182 shipnos[pno]); | |
183 strncpy(victim->p_mapchars, buf, 2); | |
184 #endif | |
185 } | |
186 break; | |
187 case 'D': /* demote */ | |
188 --victim->p_stats.st_rank; | |
189 sprintf(buf, "%2s was (temporarily) demoted for \ | |
190 rank normalization purposes.", twoletters(victim)); | |
191 pmessage(buf, 0, MALL); | |
192 break; | |
193 case 'P': | |
194 ++victim->p_stats.st_rank; | |
195 break; | |
196 case 'k': | |
197 victim->p_kills += 1.0; | |
198 break; | |
199 case 'h': | |
200 victim->p_shield = 0; | |
201 victim->p_damage = victim->p_ship.s_maxdamage / 2; | |
202 break; | |
203 case 'a': | |
204 victim->p_armies += 6; | |
205 break; | |
206 case 'C': | |
207 teams[victim->p_team].s_surrender = 6; | |
208 break; | |
209 case 'L': | |
210 victim->p_stats.st_sblosses--; | |
211 break; | |
212 case 'R': | |
213 if (victim->p_flags & PFROBOT) | |
214 { | |
215 victim->p_ship.s_type = STARBASE; | |
216 victim->p_whydead = KPROVIDENCE; | |
217 victim->p_explode = 10; | |
218 victim->p_status = 3; | |
219 victim->p_whodead = 0; | |
220 } | |
221 break; | |
222 #if 0 | |
223 case 'p': /* puck? */ | |
224 victim->p_ship.s_tractstr = 1; | |
225 victim->p_ship.s_torpdamage = -1; | |
226 victim->p_ship.s_plasmadamage = -1; | |
227 victim->p_ship.s_phaserdamage = -1; | |
228 victim->p_hostile = 0; | |
229 victim->p_swar = 0; | |
230 victim->p_team = 0; /* indep */ | |
231 victim->p_ship.s_type = STARBASE; | |
232 victim->p_ship.s_mass = 200; | |
233 victim->p_ship.s_repair = 30000; | |
234 | |
235 victim->p_ship.s_maxspeed = 0; | |
236 #endif | |
237 default: | |
238 Usage(myname); | |
239 } /* end switch */ | |
240 return 0; | |
241 } | |
242 | |
243 void | |
244 Usage(char *myname) | |
245 { | |
246 printf("-- NetrekII (Paradise), %s --\n", PARAVERS); | |
247 printf("\ | |
248 \n\t%'s [0-9a-j] <mode><mode option>'\n\ | |
249 \n\ | |
250 Where <mode> is one of :\n\ | |
251 e(ject from game) (simulates self-destruct)\n\ | |
252 s(hip class change)[abcdosA] (A = ATT)\n\ | |
253 T(eam change)[frko] (no team == independent)\n\ | |
254 D(emote) (-1 to rank)\n\ | |
255 P(romote) (+1 to rank)\n\ | |
256 F(ree slot) (bypasses 6 minute ghostbuster timeout)\n\ | |
257 k(ills increment) (+1 kill)\n\ | |
258 h(arm) (no shields, 50%% damage)\n\ | |
259 a(rmies increment) (+6 armies)\n\ | |
260 C(lock, surrender -- set it) (to 6 minutes (debugging aid))\n\ | |
261 L(oss adjust, SB (-1)) (in case you toast an SB accidentally)\n\ | |
262 R(obot obliterate) (like obliterate, but only for robots)\n\ | |
263 (no mode == obliterate)\n\ | |
264 ", myname); | |
265 exit(1); | |
266 } | |
267 | |
268 | |
269 #if 0 | |
270 /* stuff copied from other files: */ | |
271 | |
272 char * | |
273 twoletters(pl) | |
274 struct player *pl; | |
275 /* calculate the two letters that form the players designation (e.g. R4) */ | |
276 { | |
277 #define RINGSIZE MAXPLAYER+3 | |
278 static char buf[RINGSIZE][3]; /* ring of buffers so that this */ | |
279 static int idx; /* proc can be called several times before | |
280 * the results are used */ | |
281 if (idx >= RINGSIZE) | |
282 idx = 0; | |
283 buf[idx][0] = teams[pl->p_team].letter; | |
284 buf[idx][1] = shipnos[pl->p_no]; | |
285 buf[idx][2] = 0; | |
286 return buf[idx++]; | |
287 } | |
288 #endif | |
289 | |
290 | |
291 /*------------------------------PMESSAGE----------------------------------*/ | |
292 /* | |
293 * This function sens a message to the message board. It places the message | |
294 * in the next position of the array of messages. The message will ahve a | |
295 * header attached to the front of it. | |
296 */ | |
297 | |
298 void | |
299 pmessage(str, recip, group) | |
300 char *str; /* the message */ | |
301 int recip; /* who is the recipient */ | |
302 int group; /* group sent to and other flags */ | |
303 { | |
304 struct message *cur; /* to pnt to where to put message */ | |
305 int mesgnum; /* to hold index into array of messgs */ | |
306 | |
307 if ((mesgnum = ++(mctl->mc_current)) >= MAXMESSAGE) | |
308 { | |
309 mctl->mc_current = 0; /* move to next index in array and */ | |
310 mesgnum = 0; /* warp around if necessart */ | |
311 } | |
312 cur = &messages[mesgnum]; /* get addr of message struct */ | |
313 cur->m_no = mesgnum; /* set the message number */ | |
314 cur->m_flags = group; /* set the group and flags */ | |
315 cur->m_recpt = recip; /* set the recipient */ | |
316 cur->m_from = 255; /* message is from God */ | |
317 (void) sprintf(cur->m_data, "%s %s", "XTKILL:", str); | |
318 cur->m_flags |= MVALID; /* mark message as valid */ | |
319 } |