3
|
1 /* $Id: shortcomm.c,v 1.1.1.1 1997/12/06 05:41:30 darius Exp $ */
|
|
2
|
|
3 /* This file implements all SHORT_PACKETS functions */
|
|
4 /* HW 19.07.93 */
|
|
5 #ifdef SHORT_PACKETS
|
|
6
|
|
7 #ifdef HPBSD
|
|
8 #include <machine/endian.h>
|
|
9 #endif
|
|
10
|
|
11 #include <stdio.h>
|
|
12 #include <sys/types.h>
|
|
13 #include <netinet/in.h>
|
|
14 #include <sys/socket.h>
|
|
15 #include <sys/time.h>
|
|
16 #ifdef RS6K
|
|
17 #include <sys/select.h>
|
|
18 #endif /* RS6K */
|
|
19 #include <netdb.h>
|
|
20 #include <math.h>
|
|
21 #include <errno.h>
|
|
22 #include "Wlib.h"
|
|
23 #include "defs.h"
|
|
24 #include "struct.h"
|
|
25 #include "data.h"
|
|
26 #include "packets.h"
|
|
27 #include "gameconf.h"
|
|
28 #ifdef SOUND
|
|
29 #include "Slib.h"
|
|
30 #endif
|
|
31 #include "sound.h"
|
|
32
|
|
33 #if 1
|
|
34
|
|
35 char *
|
|
36 ship_type(shp)
|
|
37 struct ship *shp;
|
|
38 {
|
|
39 static char ring[4][3];
|
|
40 static int ri;
|
|
41 char *rval;
|
|
42 ring[ri][0] = shp->s_desig[0];
|
|
43 ring[ri][1] = shp->s_desig[1];
|
|
44 ring[ri][2] = 0;
|
|
45 rval = ring[ri];
|
|
46 ri++;
|
|
47 if (ri >= sizeof(ring) / sizeof(*ring))
|
|
48 ri = 0;
|
|
49 return rval;
|
|
50 }
|
|
51 #define TEAM_LETTER(p) ( teaminfo[(p).p_teami].letter )
|
|
52 #define TEAM_SHORT(p) ( teaminfo[(p).p_teami].shortname )
|
|
53 #define TEAM_LETTERP(pl) ( teaminfo[mask_to_idx((pl).pl_owner)].letter )
|
|
54 #define TEAM_SHORTP(pl) ( teaminfo[mask_to_idx((pl).pl_owner)].shortname )
|
|
55 #define reviewWin messWin[WREVIEW].window
|
|
56 #define MAXTORP ntorps
|
|
57 #define MAXPLANETS nplanets
|
|
58 #define MAXPLASMA nplasmas
|
|
59
|
|
60 #else
|
|
61
|
|
62 #define ship_type(shp) shiptype[(shp).s_type]
|
|
63 #define TEAM_LETTER(p) ( teamlet[(p).p_team] )
|
|
64 #define TEAM_SHORT(p) ( teamshort[(p).p_team] )
|
|
65 #define TEAM_LETTERP(pl) ( teamlet[(pl).pl_owner] )
|
|
66 #define TEAM_SHORTP(pl) ( teamshort[(pl).pl_owner] )
|
|
67
|
|
68 #endif
|
|
69
|
|
70 /* from here on all SHORT_PACKETS */
|
|
71 #include "wtext.h" /* here are all warningdefines */
|
|
72
|
|
73 /* Here are all warnings that are send with SP_S_WARNING */
|
|
74 /* HW 93 */
|
|
75
|
|
76 /* DaemonMessages */
|
|
77 char *daemon_texts[] =
|
|
78 {
|
|
79 /* Game_Paused() */
|
|
80 "Game is paused. CONTINUE to continue.", /* 0 */
|
|
81 "Game is no-longer paused!",/* 1 */
|
|
82 "Game is paused. Captains CONTINUE to continue.", /* 2 */
|
|
83 "Game will continue in 10 seconds", /* 3 */
|
|
84 /* send_about_to_start() */
|
|
85 "Teams chosen. Game will start in 1 minute.", /* 4 */
|
|
86 "----------- Game will start in 1 minute -------------", /* 5 */
|
|
87 };
|
|
88
|
|
89 /* VARITEXTE = warnings with 1 or more arguments argument */
|
|
90 char *vari_texts[] =
|
|
91 {
|
|
92 /* redraw.c */
|
|
93 "Engineering: Energizing transporters in %d seconds", /* 0 */
|
|
94 "Stand By ... Self Destruct in %d seconds", /* 1 */
|
|
95 "Helmsman: Docking manuever completed Captain. All moorings secured at port %d.", /* 2 */
|
|
96 /* interface.c from INL server */
|
|
97 "Not constructed yet. %d minutes required for completion", /* 3 */
|
|
98
|
|
99 };
|
|
100
|
|
101
|
|
102
|
|
103 char *w_texts[] =
|
|
104 {
|
|
105 /* socket.c */
|
|
106 "Tractor beams haven't been invented yet.", /* 0 */
|
|
107 "Weapons's Officer: Cannot tractor while cloaked, sir!", /* 1 */
|
|
108 "Weapon's Officer: Vessel is out of range of our tractor beam.", /* 2 */
|
|
109
|
|
110 /* handleRepressReq */
|
|
111 /**************** coup.c ***********************/
|
|
112 /* coup() */
|
|
113 "You must have one kill to throw a coup", /* 3 */
|
|
114 "You must orbit your home planet to throw a coup", /* 4 */
|
|
115 "You already own a planet!!!", /* 5 */
|
|
116 "You must orbit your home planet to throw a coup", /* 6 */
|
|
117 "Too many armies on planet to throw a coup", /* 7 */
|
|
118 "Planet not yet ready for a coup", /* 8 */
|
|
119 /* getentry.c */
|
|
120 /* getentry() */
|
|
121 "I cannot allow that. Pick another team", /* 9 */
|
|
122 "Please confirm change of teams. Select the new team again.", /* 10 */
|
|
123 "That is an illegal ship type. Try again.", /* 11 */
|
|
124 "That ship hasn't beed designed yet. Try again.", /* 12 */
|
|
125 "Your new starbase is still under construction", /* 13 */
|
|
126 "Your team is not capable of defending such an expensive ship!", /* 14 */
|
|
127 "Your team's stuggling economy cannot support such an expenditure!", /* 15 */
|
|
128 "Your side already has a starbase!", /* 16 */
|
|
129 /* plasma.c */
|
|
130 /* nplasmatorp(course, type) */
|
|
131 "Plasmas haven't been invented yet.", /* 17 */
|
|
132 "Weapon's Officer: Captain, this ship is not armed with plasma torpedoes!", /* 18 */
|
|
133 "Plasma torpedo launch tube has exceeded the maximum safe temperature!", /* 19 */
|
|
134 "Our fire control system limits us to 1 live torpedo at a time captain!", /* 20 */
|
|
135 "Our fire control system limits us to 1 live torpedo at a time captain!", /* 21 */
|
|
136 "We don't have enough fuel to fire a plasma torpedo!", /* 22 */
|
|
137 "We cannot fire while our vessel is undergoing repairs.", /* 23 */
|
|
138 "We are unable to fire while in cloak, captain!", /* 24 */
|
|
139 /******** torp.c *********/
|
|
140 /* ntorp(course, type) */
|
|
141 "Torpedo launch tubes have exceeded maximum safe temperature!", /* 25 */
|
|
142 "Our computers limit us to having 8 live torpedos at a time captain!", /* 26 */
|
|
143 "We don't have enough fuel to fire photon torpedos!", /* 27 */
|
|
144 "We cannot fire while our vessel is in repair mode.", /* 28 */
|
|
145 "We are unable to fire while in cloak, captain!", /* 29 */
|
|
146 "We only have forward mounted cannons.", /* 30 */
|
|
147 /* phasers.c */
|
|
148 /* phaser(course) */
|
|
149 "Weapons Officer: This ship is not armed with phasers, captain!", /* 31 */
|
|
150 "Phasers have not recharged", /* 32 */
|
|
151 "Not enough fuel for phaser", /* 33 */
|
|
152 "Can't fire while repairing", /* 34 */
|
|
153 "Weapons overheated", /* 35 */
|
|
154 "Cannot fire while cloaked",/* 36 */
|
|
155 "Phaser missed!!!", /* 37 */
|
|
156 "You destroyed the plasma torpedo!", /* 38 */
|
|
157 /* interface.c */
|
|
158 /* bomb_planet() */
|
|
159 "Must be orbiting to bomb", /* 39 */
|
|
160 "Can't bomb your own armies. Have you been reading Catch-22 again?", /* 40 */
|
|
161 "Must declare war first (no Pearl Harbor syndrome allowed here).", /* 41 */
|
|
162 "Bomb out of T-mode? Please verify your order to bomb.", /* 42 */
|
|
163 "Hoser!", /* 43 */
|
|
164 /* beam_up() */
|
|
165 "Must be orbiting or docked to beam up.", /* 44 */
|
|
166 "Those aren't our men.", /* 45 */
|
|
167 "Comm Officer: We're not authorized to beam foriegn troops on board!", /* 46 */
|
|
168 /* beam_down() */
|
|
169 "Must be orbiting or docked to beam down.", /* 47 */
|
|
170 "Comm Officer: Starbase refuses permission to beam our troops over.", /* 48 */
|
|
171 /* declare_war(mask) */
|
|
172 "Pausing ten seconds to re-program battle computers.", /* 49 */
|
|
173 /* do_refit(type) */
|
|
174 "You must orbit your HOME planet to apply for command reassignment!", /* 50 */
|
|
175 "You must orbit your home planet to apply for command reassignment!", /* 51 */
|
|
176 "Can only refit to starbase on your home planet.", /* 52 */
|
|
177 "You must dock YOUR starbase to apply for command reassignment!", /* 53 */
|
|
178 "Must orbit home planet or dock your starbase to apply for command reassignment!", /* 54 */
|
|
179 "Central Command refuses to accept a ship in this condition!", /* 55 */
|
|
180 "You must beam your armies down before moving to your new ship", /* 56 */
|
|
181 "That ship hasn't been designed yet.", /* 57 */
|
|
182 "Your side already has a starbase!", /* 58 */
|
|
183 "Your team is not capable of defending such an expensive ship", /* 59 */
|
|
184 "Your new starbase is still under construction", /* 60 */
|
|
185 "Your team's stuggling economy cannot support such an expenditure!", /* 61 */
|
|
186 "You are being transported to your new vessel .... ", /* 62 */
|
|
187 /* redraw.c */
|
|
188 /* auto_features() */
|
|
189 "Engineering: Energize. [ SFX: chimes ]", /* 63 */
|
|
190 "Wait, you forgot your toothbrush!", /* 64 */
|
|
191 "Nothing like turning in a used ship for a new one.", /* 65 */
|
|
192 "First officer: Oh no, not you again... we're doomed!", /* 66 */
|
|
193 "First officer: Uh, I'd better run diagnostics on the escape pods.", /* 67 */
|
|
194 "Shipyard controller: This time, *please* be more careful, okay?", /* 68 */
|
|
195 "Weapons officer: Not again! This is absurd...", /* 69 */
|
|
196 "Weapons officer: ... the whole ship's computer is down?", /* 70 */
|
|
197 "Weapons officer: Just to twiddle a few bits of the ship's memory?", /* 71 */
|
|
198 "Weapons officer: Bah! [ bangs fist on inoperative console ]", /* 72 */
|
|
199 "First Officer: Easy, big guy... it's just one of those mysterious", /* 73 */
|
|
200 "First Officer: laws of the universe, like 'tires on the ether'.", /* 74 */
|
|
201 "First Officer: laws of the universe, like 'Klingon bitmaps are ugly'.", /* 75 */
|
|
202 "First Officer: laws of the universe, like 'all admirals have scummed'.", /* 76 */
|
|
203 "First Officer: laws of the universe, like 'Mucus Pig exists'.", /* 77 */
|
|
204 "First Officer: laws of the universe, like 'guests advance 5x faster'.", /* 78 */
|
|
205 /* orbit.c */
|
|
206 /*orbit() */
|
|
207 "Helmsman: Captain, the maximum safe speed for docking or orbiting is warp 2!", /* 79 */
|
|
208 "Central Command regulations prohibits you from orbiting foreign planets", /* 80 */
|
|
209 "Helmsman: Sensors read no valid targets in range to dock or orbit sir!", /* 81 */
|
|
210 /* redraw.c */
|
|
211 "No more room on board for armies", /* 82 */
|
|
212 "You notice everyone on the bridge is staring at you.", /* 83 */
|
|
213 /* startdaemon.c */
|
|
214 /* practice_robo() */
|
|
215 "Can't send in practice robot with other players in the game.", /* 84 */
|
|
216 /* socket.c */
|
|
217 /* doRead(asock) */
|
|
218 "Self Destruct has been canceled", /* 85 */
|
|
219 /* handleMessageReq(packet) */
|
|
220 "Be quiet", /* 86 */
|
|
221 "You are censured. Message was not sent.", /* 87 */
|
|
222 "You are ignoring that player. Message was not sent.", /* 88 */
|
|
223 "That player is censured. Message was not sent.", /* 89 */
|
|
224 /* handleQuitReq(packet) */
|
|
225 "Self destruct initiated", /* 90 */
|
|
226 /* handleScan(packet) */
|
|
227 "Scanners haven't been invented yet", /* 91 */
|
|
228 /* handleUdpReq(packet) */
|
|
229 "WARNING: BROKEN mode is enabled", /* 92 */
|
|
230 "Server can't do that UDP mode", /* 93 */
|
|
231 "Server will send with TCP only", /* 94 */
|
|
232 "Server will send with simple UDP", /* 95 */
|
|
233 "Request for fat UDP DENIED (set to simple)", /* 96 */
|
|
234 "Request for double UDP DENIED (set to simple)", /* 97 */
|
|
235 /* forceUpdate() */
|
|
236 "Update request DENIED (chill out!)", /* 98 */
|
|
237 /* INL redraw.c */
|
|
238 "Player lock lost while player dead.", /* 99 */
|
|
239 "Can only lock on own team.", /* 100 */
|
|
240 "You can only warp to your own team's planets!", /* 101 */
|
|
241 "Planet lock lost on change of ownership.", /* 102 */
|
|
242 " Weapons officer: Finally! systems are back online!", /* 103 */
|
|
243
|
|
244 };
|
|
245
|
|
246 #define NUMWTEXTS (sizeof w_texts / sizeof w_texts[0])
|
|
247 #define NUMVARITEXTS ( sizeof vari_texts / sizeof vari_texts[0])
|
|
248 #define NUMDAEMONTEXTS ( sizeof daemon_texts / sizeof daemon_texts[0])
|
|
249
|
|
250
|
|
251 void add_whydead();
|
|
252
|
|
253 extern int vtisize[];
|
|
254 extern unsigned char numofbits[];
|
|
255 #if 0
|
|
256 int Plx[MAX_PLAYER], Ply[MAX_PLAYER], Pgx[MAX_PLAYER], Pgy[MAX_PLAYER];
|
|
257 unsigned char Pdir[MAX_PLAYER];
|
|
258 #endif
|
|
259 int my_x, my_y; /* for rotation we need to keep track of our
|
|
260 real coordinates */
|
|
261 /* SP_S_WARNING vari texte */
|
|
262 char *s_texte[256]; /* Better with a malloc scheme */
|
|
263 char no_memory[] =
|
|
264 {"Not enough memory for warning string!"};
|
|
265
|
|
266 #if 0
|
|
267 /* For INL Server */
|
|
268 char *shiptype[NUM_TYPES] =
|
|
269 {"SC", "DD", "CA", "BB", "AS", "SB", "??"};
|
|
270 #endif
|
|
271 int spwinside = 500; /* WINSIDE from Server */
|
|
272 long spgwidth = 100000;
|
|
273
|
|
274
|
|
275 void
|
|
276 sendThreshold(v)
|
|
277 unsigned short v;
|
|
278 {
|
|
279 struct threshold_cpacket p;
|
|
280
|
|
281 p.type = CP_S_THRS;
|
|
282 p.thresh = v;
|
|
283 sendServerPacket((struct player_spacket *) & p);
|
|
284 }
|
|
285
|
|
286 void
|
|
287 handleVTorp(sbuf)
|
|
288 unsigned char *sbuf;
|
|
289 {
|
|
290 unsigned char *which, *data;
|
|
291 unsigned char bitset;
|
|
292 struct torp *thetorp;
|
|
293 int dx, dy;
|
|
294 int shiftvar;
|
|
295
|
|
296 int i;
|
|
297 register int shift = 0; /* How many torps are extracted (for shifting
|
|
298 ) */
|
|
299
|
|
300 /* now we must find the data ... :-) */
|
|
301 if (sbuf[0] == SP_S_8_TORP) { /* MAX packet */
|
|
302 bitset = 0xff;
|
|
303 which = &sbuf[1];
|
|
304 data = &sbuf[2];
|
|
305 } else { /* Normal Packet */
|
|
306 bitset = sbuf[1];
|
|
307 which = &sbuf[2];
|
|
308 data = &sbuf[3];
|
|
309 }
|
|
310
|
|
311 #ifdef CORRUPTED_PACKETS
|
|
312 /* we probably should do something clever here - jmn */
|
|
313 #endif
|
|
314
|
|
315 thetorp = &torps[((unsigned char) *which * 8)];
|
|
316 for (shift = 0, i = 0; i < 8;
|
|
317 #if defined(RS6K) || defined(__SABER__)
|
|
318 i++, thetorp++, bitset >>= 1) {
|
|
319 #else
|
|
320 i++, thetorp++, bitset = ((unsigned char)bitset) >> 1) {
|
|
321 #endif
|
|
322 if (bitset & 01) {
|
|
323 dx = (*data >> shift);
|
|
324 data++;
|
|
325 shiftvar = (unsigned char) *data; /* to silence gcc */
|
|
326 shiftvar <<= (8 - shift);
|
|
327 dx |= (shiftvar & 511);
|
|
328 shift++;
|
|
329 dy = (*data >> shift);
|
|
330 data++;
|
|
331 shiftvar = (unsigned char) *data; /* to silence gcc */
|
|
332 shiftvar <<= (8 - shift);
|
|
333 dy |= (shiftvar & 511);
|
|
334 shift++;
|
|
335 if (shift == 8) {
|
|
336 shift = 0;
|
|
337 data++;
|
|
338 }
|
|
339 /* This is necessary because TFREE/TMOVE is now encoded in the bitset */
|
|
340 if (thetorp->t_status == TFREE) {
|
|
341 thetorp->t_status = TMOVE; /* guess */
|
|
342 players[thetorp->t_owner].p_ntorp++;
|
|
343 #ifdef UNIX_SOUND
|
|
344 play_sound (SND_FIRETORP); /* Fire Torp */
|
|
345 #endif
|
|
346 } else if (thetorp->t_owner == me->p_no && thetorp->t_status == TEXPLODE) {
|
|
347 thetorp->t_status = TMOVE; /* guess */
|
|
348 }
|
|
349 /* Check if torp is visible */
|
|
350 if (dx > spwinside || dy > spwinside) {
|
|
351 thetorp->t_x = -100000; /* Not visible */
|
|
352 thetorp->t_y = -100000;
|
|
353 } else { /* visible */
|
|
354 /* thetorp->t_x = me->p_x + ((dx - spwinside / 2) * SCALE);
|
|
355 thetorp->t_y = me->p_y + ((dy - spwinside / 2) * SCALE); */
|
|
356 thetorp->t_x = my_x + ((dx - spwinside / 2) * SCALE);
|
|
357 thetorp->t_y = my_y + ((dy - spwinside / 2) * SCALE);
|
|
358 #ifdef ROTATERACE
|
|
359 if (rotate) {
|
|
360 rotate_coord(&thetorp->t_x, &thetorp->t_y, rotate_deg,
|
|
361 spgwidth / 2, spgwidth / 2);
|
|
362 }
|
|
363 #endif
|
|
364 }
|
|
365 }
|
|
366 /* if */
|
|
367 else { /* We got a TFREE */
|
|
368 if (thetorp->t_status && thetorp->t_status != TEXPLODE) {
|
|
369 players[thetorp->t_owner].p_ntorp--;
|
|
370 thetorp->t_status = TFREE; /* That's no guess */
|
|
371 }
|
|
372 }
|
|
373 } /* for */
|
|
374 }
|
|
375
|
|
376 void
|
|
377 handleSelfShort(packet)
|
|
378 struct youshort_spacket *packet;
|
|
379 {
|
|
380 me = (ghoststart ? &players[ghost_pno] : &players[packet->pnum]);
|
|
381 myship = me->p_ship;
|
|
382 mystats = &(me->p_stats);
|
|
383 me->p_hostile = packet->hostile;
|
|
384 me->p_swar = packet->swar;
|
|
385 me->p_armies = packet->armies;
|
|
386 me->p_flags = ntohl(packet->flags);
|
|
387 me->p_whydead = packet->whydead;
|
|
388 me->p_whodead = packet->whodead;
|
|
389 #ifdef SOUND
|
|
390 S_HandlePFlags();
|
|
391 #endif
|
|
392 }
|
|
393
|
|
394 void
|
|
395 handleSelfShip(packet)
|
|
396 struct youss_spacket *packet;
|
|
397 {
|
|
398 if (!me)
|
|
399 return; /* wait.. */
|
|
400
|
|
401 me->p_damage = ntohs(packet->damage);
|
|
402 me->p_shield = ntohs(packet->shield);
|
|
403 me->p_fuel = ntohs(packet->fuel);
|
|
404 me->p_etemp = ntohs(packet->etemp);
|
|
405 me->p_wtemp = ntohs(packet->wtemp);
|
|
406 #ifdef SOUND
|
|
407 S_HandlePFlags();
|
|
408 #endif
|
|
409 }
|
|
410
|
|
411 void
|
|
412 handleVPlayer(sbuf)
|
|
413 unsigned char *sbuf;
|
|
414 {
|
|
415 register int x, y, i, numofplayers, pl_no, save;
|
|
416 register struct player *pl;
|
|
417 unsigned char newdir; /* needed for uncloak kludge with ROTATERACE */
|
|
418 int offset;
|
|
419
|
|
420 numofplayers = (unsigned char) sbuf[1] & 0x3f;
|
|
421
|
|
422 if (sbuf[1] & (unsigned char) 128) { /* Short Header + Extended */
|
|
423 sbuf += 4;
|
|
424 offset = 32; /* more than 32 players? */
|
|
425 } else if (sbuf[1] & 64) { /* Short Header */
|
|
426 sbuf += 4;
|
|
427 offset = 0;
|
|
428 } else {
|
|
429 struct player_s_spacket *packet = (struct player_s_spacket *) sbuf;
|
|
430 pl = &players[me->p_no];
|
|
431 pl->p_dir = (unsigned char) packet->dir;
|
|
432 #if 0
|
|
433 Pdir[me->p_no] = (unsigned char) rosette(pl->p_dir, 16);
|
|
434 #endif
|
|
435 pl->p_speed = packet->speed;
|
|
436 #ifdef FEATURE
|
|
437 if (F_dead_warp && (pl->p_speed == 14)) {
|
|
438 if (pl->p_status == PALIVE) {
|
|
439 pl->p_status = PEXPLODE;
|
|
440 pl->p_explode = 0;
|
|
441 }
|
|
442 } else
|
|
443 #endif
|
|
444 {
|
|
445 pl->p_x = my_x = ntohl(packet->x);
|
|
446 pl->p_y = my_y = ntohl(packet->y);
|
|
447 #ifdef ROTATERACE
|
|
448 if (rotate) {
|
|
449 rotate_coord(&pl->p_x, &pl->p_y,
|
|
450 rotate_deg, spgwidth / 2, spgwidth / 2);
|
|
451 rotate_dir(&pl->p_dir, rotate_deg);
|
|
452 }
|
|
453 #endif
|
|
454 #if 0
|
|
455 Plx[me->p_no] = WINSIDE / 2;
|
|
456 Ply[me->p_no] = WINSIDE / 2;
|
|
457 Pgx[me->p_no] = pl->p_x * WINSIDE / spgwidth;
|
|
458 Pgy[me->p_no] = pl->p_y * WINSIDE / spgwidth;
|
|
459 #endif
|
|
460 }
|
|
461 redrawPlayer[me->p_no] = 1;
|
|
462 sbuf += 12; /* Now the small packets */
|
|
463 offset = 0;
|
|
464 }
|
|
465 for (i = 0; i < numofplayers; i++) {
|
|
466 pl_no = ((unsigned char) *sbuf & 0x1f) + offset;
|
|
467 if (pl_no >= nplayers)
|
|
468 continue;
|
|
469 save = (unsigned char) *sbuf;
|
|
470 sbuf++;
|
|
471 pl = &players[pl_no];
|
|
472 pl->p_speed = (unsigned char) *sbuf & 15; /* SPEED */
|
|
473 #if 0
|
|
474 Pdir[pl_no] = (unsigned char) *sbuf >> 4; /* DIR */
|
|
475 #endif
|
|
476 newdir = (unsigned char) *sbuf & 0xf0; /* realDIR */
|
|
477
|
|
478 #ifdef ROTATERACE
|
|
479 if (rotate)
|
|
480 rotate_dir(&newdir, rotate_deg);
|
|
481 #endif
|
|
482 #ifdef FEATURE
|
|
483 if (cloakerMaxWarp) {
|
|
484 if (pl->p_speed == 15)
|
|
485 pl->p_flags |= PFCLOAK;
|
|
486 else
|
|
487 pl->p_flags &= ~(PFCLOAK);
|
|
488 } else
|
|
489 #endif
|
|
490 {
|
|
491 #ifdef CHECK_DROPPED
|
|
492 /*
|
|
493 this is a mess. Too many exceptions. I don't use it any
|
|
494 more. cloakerMaxWarp is much much better, but requires server
|
|
495 support.
|
|
496 */
|
|
497 /*
|
|
498 Kludge to fix lost uncloak packets! [3/94] -JR may be a
|
|
499 problem with server sending directions after cloakphase is at
|
|
500 CLOAK_PHASES-1, since cloakphase is strictly a client variable
|
|
501 :(
|
|
502 */
|
|
503 if (pl->p_flags & PFCLOAK && pl->p_cloakphase >= (CLOAK_PHASES - 1) &&
|
|
504 (pl->p_dir & 0xf0 != newdir & 0xf0) && !(pl->p_flags & PFORBIT)) {
|
|
505 int i, plocked = 0;
|
|
506 for (i = 0; i < nplayers; i++) {
|
|
507 if ((phasers[i].ph_status & PHHIT) && (phasers[i].ph_target == pl_no)) {
|
|
508 plocked = 1;
|
|
509 break;
|
|
510 }
|
|
511 }
|
|
512 if (!plocked)
|
|
513 /*
|
|
514 if all of the above, the guy is *probably* uncloaked.
|
|
515 Ask the server.
|
|
516 */
|
|
517 sendShortReq(SPK_SALL);
|
|
518 }
|
|
519 #endif
|
|
520 }
|
|
521 pl->p_dir = newdir; /* realDIR */
|
|
522
|
|
523 sbuf++;
|
|
524 x = (unsigned char) *sbuf++;
|
|
525 y = (unsigned char) *sbuf++; /* The lower 8 Bits are saved */
|
|
526
|
|
527 /* Now we must preprocess the coordinates */
|
|
528 if ((unsigned char) save & 64)
|
|
529 x |= 256;
|
|
530 if ((unsigned char) save & 128)
|
|
531 y |= 256;
|
|
532 #ifdef FEATURE
|
|
533 /*
|
|
534 MAY CHANGE! dead_warp is still an experiment, some servers are
|
|
535 also sending illegal co-ords for dead players, so we'll just
|
|
536 ignore 'em for now if the guy's dead.
|
|
537 */
|
|
538 if (F_dead_warp && pl->p_speed == 14) {
|
|
539 if (pl->p_status == PALIVE) {
|
|
540 pl->p_status = PEXPLODE;
|
|
541 pl->p_explode = 0;
|
|
542 }
|
|
543 redrawPlayer[pl->p_no] = 1;
|
|
544 continue;
|
|
545 }
|
|
546 #endif
|
|
547 /* Now test if it's galactic or local coord */
|
|
548 if (save & 32) { /* It's galactic */
|
|
549 #if 0
|
|
550 if (x >= 501 || y >= 501) {
|
|
551 pl->p_x = -500 * spgwidth / spwinside;
|
|
552 pl->p_y = -500 * spgwidth / spwinside;
|
|
553 } else
|
|
554 #endif
|
|
555 {
|
|
556 pl->p_x = x * spgwidth / spwinside;
|
|
557 pl->p_y = y * spgwidth / spwinside;
|
|
558 }
|
|
559 #if 0
|
|
560 Pgx[pl_no] = x;
|
|
561 Pgy[pl_no] = y;
|
|
562 Plx[pl_no] = -1; /* Not visible */
|
|
563 Ply[pl_no] = -1;
|
|
564 #endif
|
|
565 } else { /* Local */
|
|
566 pl->p_x = my_x + ((x - spwinside / 2) * SCALE);
|
|
567 pl->p_y = my_y + ((y - spwinside / 2) * SCALE);
|
|
568 #if 0
|
|
569 Plx[pl_no] = x;
|
|
570 Ply[pl_no] = y;
|
|
571 Pgx[pl_no] = pl->p_x * spwinside / spgwidth;
|
|
572 Pgy[pl_no] = pl->p_y * spwinside / spgwidth;
|
|
573 #endif
|
|
574 }
|
|
575 redrawPlayer[pl->p_no] = 1;
|
|
576 #ifdef ROTATERACE
|
|
577 if (rotate) {
|
|
578 rotate_coord(&pl->p_x, &pl->p_y,
|
|
579 rotate_deg, spgwidth / 2, spgwidth / 2);
|
|
580 }
|
|
581 #endif
|
|
582 } /* for */
|
|
583 }
|
|
584
|
|
585 void
|
|
586 handleSMessage(packet)
|
|
587 struct mesg_s_spacket *packet;
|
|
588 {
|
|
589 char buf[100];
|
|
590 char addrbuf[9];
|
|
591
|
|
592 #if 0
|
|
593 if (debug)
|
|
594 printf("Length of Message is: %d total Size %d \n", strlen(&packet->mesg), (int) packet->length);
|
|
595 #endif
|
|
596 if (packet->m_from >= nplayers)
|
|
597 packet->m_from = 255;
|
|
598
|
|
599 if (packet->m_from == 255)
|
|
600 strcpy(addrbuf, "GOD->");
|
|
601 else {
|
|
602 sprintf(addrbuf, " %c%c->", TEAM_LETTER(players[packet->m_from]),
|
|
603 shipnos[players[packet->m_from].p_no]);
|
|
604 }
|
|
605
|
|
606 switch (packet->m_flags & (MTEAM | MINDIV | MALL)) {
|
|
607 case MALL:
|
|
608 sprintf(addrbuf + 5, "ALL");
|
|
609 break;
|
|
610 case MTEAM:
|
|
611 sprintf(addrbuf + 5, TEAM_SHORT(*me));
|
|
612 break;
|
|
613 case MINDIV:
|
|
614 /* I know that it's me -> xxx but i copied it straight ... */
|
|
615 sprintf(addrbuf + 5, "%c%c ", TEAM_LETTER(players[packet->m_recpt]),
|
|
616 shipnos[packet->m_recpt]);
|
|
617 break;
|
|
618 default:
|
|
619 sprintf(addrbuf + 5, "ALL");
|
|
620 break;
|
|
621 }
|
|
622 sprintf(buf, "%-9s%s", addrbuf, &packet->mesg);
|
|
623 dmessage(buf, packet->m_flags, packet->m_from, packet->m_recpt);
|
|
624 }
|
|
625
|
|
626 void
|
|
627 handleShortReply(packet)
|
|
628 struct shortreply_spacket *packet;
|
|
629 {
|
|
630 switch (packet->repl) {
|
|
631 case SPK_VOFF:
|
|
632 recv_short = 0;
|
|
633 sprefresh(SPK_VFIELD);
|
|
634 break;
|
|
635 case SPK_VON:
|
|
636 recv_short = 1;
|
|
637 sprefresh(SPK_VFIELD);
|
|
638
|
|
639 spwinside = (CARD16) ntohs(packet->winside);
|
|
640 /*
|
|
641 bug in server-side SP code, wrong-endian machines confuse a client
|
|
642 with normal byte order
|
|
643 */
|
|
644 if (spwinside == 0xf401)
|
|
645 spwinside = 0x01f4;
|
|
646
|
|
647 if (paradise) {
|
|
648 spgwidth = (INT32) ntohl(packet->gwidth);
|
|
649 blk_gwidth = spgwidth;
|
|
650 blk_windgwidth = (float)spwinside;
|
|
651 redrawall = 1;
|
|
652
|
|
653 /*
|
|
654 bug in server-side SP code, wrong-endian machines confuse a
|
|
655 client with normal byte order
|
|
656 */
|
|
657 if (spgwidth == 0xa0860100)
|
|
658 spgwidth = 0x000186a0;
|
|
659 if (spgwidth == 0x0100)
|
|
660 spgwidth = 0x000186a0;
|
|
661 }
|
|
662 break;
|
|
663 case SPK_MOFF:
|
|
664 recv_mesg = 0;
|
|
665 sprefresh(SPK_MFIELD);
|
|
666 W_SetSensitive(reviewWin, 0);
|
|
667 break;
|
|
668 case SPK_MON:
|
|
669 recv_mesg = 1;
|
|
670 sprefresh(SPK_MFIELD);
|
|
671 W_SetSensitive(reviewWin, 1);
|
|
672 break;
|
|
673 case SPK_M_KILLS:
|
|
674 recv_kmesg = 1;
|
|
675 sprefresh(SPK_KFIELD);
|
|
676 break;
|
|
677 case SPK_M_NOKILLS:
|
|
678 recv_kmesg = 0;
|
|
679 sprefresh(SPK_KFIELD);
|
|
680 break;
|
|
681 case SPK_M_WARN:
|
|
682 recv_warn = 1;
|
|
683 sprefresh(SPK_WFIELD);
|
|
684 break;
|
|
685 case SPK_M_NOWARN:
|
|
686 recv_warn = 0;
|
|
687 sprefresh(SPK_WFIELD);
|
|
688 break;
|
|
689
|
|
690 case SPK_THRESHOLD:
|
|
691 break;
|
|
692 default:
|
|
693 fprintf(stderr, "%s: unknown response packet value short-req: %d\n",
|
|
694 "netrek", packet->repl);
|
|
695 }
|
|
696 }
|
|
697
|
|
698 void
|
|
699 handleVTorpInfo(sbuf)
|
|
700 unsigned char *sbuf;
|
|
701 {
|
|
702 unsigned char *bitset, *which, *data, *infobitset, *infodata;
|
|
703 struct torp *thetorp;
|
|
704 int dx, dy;
|
|
705 int shiftvar;
|
|
706 char status, war;
|
|
707 register int i;
|
|
708 register int shift = 0; /* How many torps are extracted (for shifting
|
|
709 ) */
|
|
710
|
|
711 /* now we must find the data ... :-) */
|
|
712 bitset = &sbuf[1];
|
|
713 which = &sbuf[2];
|
|
714 infobitset = &sbuf[3];
|
|
715 /* Where is the data ? */
|
|
716 data = &sbuf[4];
|
|
717 infodata = &sbuf[vtisize[numofbits[(unsigned char) sbuf[1]]]];
|
|
718
|
|
719 thetorp = &torps[(unsigned char) (*which * 8)];
|
|
720
|
|
721 for (shift = 0, i = 0; i < 8;
|
|
722 #if defined(RS6K) || defined(__SABER__)
|
|
723 thetorp++, *bitset >>= 1, *infobitset >>= 1, i++) {
|
|
724 #else
|
|
725 thetorp++, *bitset = ((unsigned char)*bitset) >> 1, *infobitset = ((unsigned char) *infobitset) >> 1, i++) {
|
|
726 #endif
|
|
727
|
|
728 if (*bitset & 01) {
|
|
729 dx = (*data >> shift);
|
|
730 data++;
|
|
731 shiftvar = (unsigned char) *data; /* to silence gcc */
|
|
732 shiftvar <<= (8 - shift);
|
|
733 dx |= (shiftvar & 511);
|
|
734 shift++;
|
|
735 dy = (*data >> shift);
|
|
736 data++;
|
|
737 shiftvar = (unsigned char) *data; /* to silence gcc */
|
|
738 shiftvar <<= (8 - shift);
|
|
739 dy |= (shiftvar & 511);
|
|
740 shift++;
|
|
741 if (shift == 8) {
|
|
742 shift = 0;
|
|
743 data++;
|
|
744 }
|
|
745 /* Check for torp with no TorpInfo */
|
|
746 if (!(*infobitset & 01)) {
|
|
747 if (thetorp->t_status == TFREE) {
|
|
748 thetorp->t_status = TMOVE; /* guess */
|
|
749 players[thetorp->t_owner].p_ntorp++;
|
|
750 } else if (thetorp->t_owner == me->p_no &&
|
|
751 thetorp->t_status == TEXPLODE) { /* If TFREE got lost */
|
|
752 thetorp->t_status = TMOVE; /* guess */
|
|
753 }
|
|
754 }
|
|
755 /* Check if torp is visible */
|
|
756 if (dx > spwinside || dy > spwinside) {
|
|
757 thetorp->t_x = -100000; /* Not visible */
|
|
758 thetorp->t_y = -100000;
|
|
759 } else { /* visible */
|
|
760 /* thetorp->t_x = me->p_x + ((dx - spwinside / 2) * SCALE);
|
|
761 thetorp->t_y = me->p_y + ((dy - spwinside / 2) * SCALE);
|
|
762 */
|
|
763 thetorp->t_x = my_x + ((dx - spwinside / 2) *
|
|
764 SCALE);
|
|
765 thetorp->t_y = my_y + ((dy - spwinside / 2) *
|
|
766 SCALE);
|
|
767
|
|
768 #ifdef ROTATERACE
|
|
769 if (rotate) {
|
|
770 rotate_coord(&thetorp->t_x, &thetorp->t_y, rotate_deg,
|
|
771 spgwidth / 2, spgwidth / 2);
|
|
772 }
|
|
773 #endif
|
|
774 }
|
|
775 }
|
|
776 /* if */
|
|
777 else { /* Got a TFREE ? */
|
|
778 if (!(*infobitset & 01)) { /* No other TorpInfo for this Torp */
|
|
779 if (thetorp->t_status && thetorp->t_status != TEXPLODE) {
|
|
780 players[thetorp->t_owner].p_ntorp--;
|
|
781 thetorp->t_status = TFREE; /* That's no guess */
|
|
782 }
|
|
783 }
|
|
784 }
|
|
785 /* Now the TorpInfo */
|
|
786 if (*infobitset & 01) {
|
|
787 war = (unsigned char) *infodata & 15 /* 0x0f */ ;
|
|
788 status = ((unsigned char) *infodata & 0xf0) >> 4;
|
|
789 infodata++;
|
|
790 if (status == TEXPLODE && thetorp->t_status == TFREE) {
|
|
791 /* FAT: redundant explosion; don't update p_ntorp */
|
|
792 continue;
|
|
793 }
|
|
794 if (thetorp->t_status == TFREE && status) {
|
|
795 players[thetorp->t_owner].p_ntorp++;
|
|
796 #ifdef UNIX_SOUND
|
|
797 play_sound (SND_FIRETORP); /* Fire Torp */
|
|
798 #endif
|
|
799 }
|
|
800 if (thetorp->t_status && status == TFREE) {
|
|
801 players[thetorp->t_owner].p_ntorp--;
|
|
802 }
|
|
803 thetorp->t_war = war;
|
|
804 if (status != thetorp->t_status) {
|
|
805 /* FAT: prevent explosion reset */
|
|
806 thetorp->t_status = status;
|
|
807 if (thetorp->t_status == TEXPLODE) {
|
|
808 thetorp->t_fuse = NUMDETFRAMES;
|
|
809 }
|
|
810 }
|
|
811 } /* if */
|
|
812 } /* for */
|
|
813 }
|
|
814
|
|
815 void
|
|
816 handleVPlanet(sbuf)
|
|
817 unsigned char *sbuf;
|
|
818 {
|
|
819 register int i;
|
|
820 register int numofplanets; /* How many Planets are in the packet */
|
|
821 struct planet *plan;
|
|
822 struct planet_s_spacket *packet = (struct planet_s_spacket *) & sbuf[2];
|
|
823 /* FAT: prevent excessive redraw */
|
|
824 int redraw = 0;
|
|
825
|
|
826 numofplanets = (unsigned char) sbuf[1];
|
|
827
|
|
828 if (numofplanets > MAXPLANETS + 1)
|
|
829 return;
|
|
830
|
|
831 for (i = 0; i < numofplanets; i++, packet++) {
|
|
832 if (packet->pnum < 0 || packet->pnum >= MAXPLANETS)
|
|
833 continue;
|
|
834
|
|
835 plan = &planets[packet->pnum];
|
|
836 if (plan->pl_owner != packet->owner)
|
|
837 redraw = 1;
|
|
838 plan->pl_owner = packet->owner;
|
|
839
|
|
840 if (plan->pl_info != packet->info)
|
|
841 redraw = 1;
|
|
842
|
|
843 plan->pl_info = packet->info;
|
|
844 /* Redraw the planet because it was updated by server */
|
|
845
|
|
846 if (plan->pl_flags != (int) ntohs(packet->flags))
|
|
847 redraw = 1;
|
|
848 plan->pl_flags = (int) ntohs(packet->flags);
|
|
849
|
|
850 if (plan->pl_armies != (unsigned char) packet->armies) {
|
|
851 /*#ifdef EM*/
|
|
852 /*
|
|
853 don't redraw when armies change unless it crosses the '4' *
|
|
854 army limit. Keeps people from watching for planet 'flicker' *
|
|
855 when players are beaming
|
|
856 */
|
|
857 int planetarmies = (unsigned char) packet->armies;
|
|
858 if ((plan->pl_armies < 5 && planetarmies > 4) ||
|
|
859 (plan->pl_armies > 4 && planetarmies < 5))
|
|
860 /*#endif*/
|
|
861 redraw = 1;
|
|
862 }
|
|
863
|
|
864 plan->pl_armies = (unsigned char) packet->armies;
|
|
865 if (plan->pl_info == 0) {
|
|
866 plan->pl_owner = NOBODY;
|
|
867 }
|
|
868
|
|
869 if (redraw) {
|
|
870 plan->pl_flags |= PLREDRAW;
|
|
871 pl_update[packet->pnum].plu_update = 1;
|
|
872 pl_update[packet->pnum].plu_x = plan->pl_x;
|
|
873 pl_update[packet->pnum].plu_y = plan->pl_y;
|
|
874
|
|
875 }
|
|
876 } /* FOR */
|
|
877 }
|
|
878
|
|
879 void
|
|
880 sendShortReq(state)
|
|
881 char state;
|
|
882 {
|
|
883 struct shortreq_cpacket shortReq;
|
|
884
|
|
885 shortReq.type = CP_S_REQ;
|
|
886 shortReq.req = state;
|
|
887 shortReq.version = SHORTVERSION;
|
|
888 switch (state) {
|
|
889 case SPK_VON:
|
|
890 warning("Sending short packet request");
|
|
891 break;
|
|
892 case SPK_VOFF:
|
|
893 warning("Sending old packet request");
|
|
894 break;
|
|
895 default:
|
|
896 break;
|
|
897 }
|
|
898 if ((state == SPK_SALL || state == SPK_ALL) && recv_short) {
|
|
899 /* Let the client do the work, and not the network :-) */
|
|
900
|
|
901 register int i;
|
|
902 for (i = 0; i < nplayers * MAXTORP; i++)
|
|
903 torps[i].t_status = TFREE;
|
|
904
|
|
905 for (i = 0; i < nplayers * MAXPLASMA; i++)
|
|
906 plasmatorps[i].pt_status = PTFREE;
|
|
907
|
|
908 for (i = 0; i < nplayers; i++) {
|
|
909 players[i].p_ntorp = 0;
|
|
910 players[i].p_nplasmatorp = 0;
|
|
911 phasers[i].ph_status = PHFREE;
|
|
912 }
|
|
913 if (state == SPK_SALL)
|
|
914 warning("Sent request for small update (weapons+planets+kills)");
|
|
915 else if (state == SPK_ALL)
|
|
916 warning("Sent request for medium update (all except stats)");
|
|
917 else
|
|
918 warning("Sent some unknown request...");
|
|
919 }
|
|
920 sendServerPacket((struct shortreq_cpacket *) & shortReq);
|
|
921 }
|
|
922
|
|
923 char *whydeadmess[] =
|
|
924 {"", "[quit]", "[photon]", "[phaser]", "[planet]", "[explosion]",
|
|
925 "", "", "[ghostbust]", "[genocide]", "", "[plasma]", "[detted photon]", "[chain explosion]",
|
|
926 "[TEAM]", "", "[team det]", "[team explosion]"};
|
|
927
|
|
928
|
|
929 void
|
|
930 handleSWarning(packet)
|
|
931 struct warning_s_spacket *packet;
|
|
932 {
|
|
933 char buf[80];
|
|
934 register struct player *target;
|
|
935 register int damage;
|
|
936 static int arg3, arg4; /* Here are the arguments for warnings with
|
|
937 more than 2 arguments */
|
|
938 static int karg3, karg4, karg5 = 0;
|
|
939 char killmess[20];
|
|
940
|
|
941 switch (packet->whichmessage) {
|
|
942 case TEXTE: /* damage used as tmp var */
|
|
943 damage = (unsigned char) packet->argument;
|
|
944 damage |= (unsigned char) packet->argument2 << 8;
|
|
945 if (damage >= 0 && damage < NUMWTEXTS)
|
|
946 warning(w_texts[damage]);
|
|
947 break;
|
|
948 case PHASER_HIT_TEXT:
|
|
949 target = &players[(unsigned char) packet->argument & 0x3f];
|
|
950 damage = (unsigned char) packet->argument2;
|
|
951 if ((unsigned char) packet->argument & 64)
|
|
952 damage |= 256;
|
|
953 if ((unsigned char) packet->argument & 128)
|
|
954 damage |= 512;
|
|
955 (void) sprintf(buf, "Phaser burst hit %s for %d points", target->p_name, damage);
|
|
956 warning(buf);
|
|
957 break;
|
|
958 case BOMB_INEFFECTIVE:
|
|
959 sprintf(buf, "Weapons Officer: Bombing is ineffective. Only %d armies are defending.",
|
|
960 (int) packet->argument); /* nifty info feature 2/14/92
|
|
961 TMC */
|
|
962 warning(buf);
|
|
963 break;
|
|
964 case BOMB_TEXT:
|
|
965 sprintf(buf, "Weapons Officer: Bombarding %s... Sensors read %d armies left.",
|
|
966 planets[(unsigned char) packet->argument].pl_name,
|
|
967 (unsigned char) packet->argument2);
|
|
968 warning(buf);
|
|
969 break;
|
|
970 case BEAMUP_TEXT:
|
|
971 sprintf(buf, "%s: Too few armies to beam up",
|
|
972 planets[(unsigned char) packet->argument].pl_name);
|
|
973 warning(buf);
|
|
974 break;
|
|
975 case BEAMUP2_TEXT:
|
|
976 sprintf(buf, "Beaming up. (%d/%d)", (unsigned char) packet->argument, (unsigned char) packet->argument2);
|
|
977 warning(buf);
|
|
978 break;
|
|
979 case BEAMUPSTARBASE_TEXT:
|
|
980 sprintf(buf, "Starbase %s: Too few armies to beam up",
|
|
981 players[packet->argument].p_name);
|
|
982 warning(buf);
|
|
983 break;
|
|
984 case BEAMDOWNSTARBASE_TEXT:
|
|
985 sprintf(buf, "No more armies to beam down to Starbase %s.",
|
|
986 players[packet->argument].p_name);
|
|
987 warning(buf);
|
|
988
|
|
989 break;
|
|
990 case BEAMDOWNPLANET_TEXT:
|
|
991 sprintf(buf, "No more armies to beam down to %s.",
|
|
992 planets[(unsigned char) packet->argument].pl_name);
|
|
993 warning(buf);
|
|
994 break;
|
|
995 case SBREPORT:
|
|
996 sprintf(buf, "Transporter Room: Starbase %s reports all troop bunkers are full!",
|
|
997 players[packet->argument].p_name);
|
|
998 warning(buf);
|
|
999 break;
|
|
1000 case ONEARG_TEXT:
|
|
1001 if (packet->argument >= 0 && packet->argument < NUMVARITEXTS) {
|
|
1002 sprintf(buf, vari_texts[packet->argument], (unsigned char) packet->argument2);
|
|
1003 warning(buf);
|
|
1004 }
|
|
1005 break;
|
|
1006 case BEAM_D_PLANET_TEXT:
|
|
1007 sprintf(buf, "Beaming down. (%d/%d) %s has %d armies left",
|
|
1008 arg3,
|
|
1009 arg4,
|
|
1010 planets[(unsigned char) packet->argument].pl_name,
|
|
1011 packet->argument2);
|
|
1012 warning(buf);
|
|
1013 break;
|
|
1014 case ARGUMENTS:
|
|
1015 arg3 = (unsigned char) packet->argument;
|
|
1016 arg4 = (unsigned char) packet->argument2;
|
|
1017 break;
|
|
1018 case BEAM_U_TEXT:
|
|
1019 sprintf(buf, "Transfering ground units. (%d/%d) Starbase %s has %d armies left",
|
|
1020 (unsigned char) arg3, (unsigned char) arg4, players[packet->argument].p_name, (unsigned char) packet->argument2);
|
|
1021 warning(buf);
|
|
1022 break;
|
|
1023 case LOCKPLANET_TEXT:
|
|
1024 sprintf(buf, "Locking onto %s", planets[(unsigned char) packet->argument].pl_name);
|
|
1025 warning(buf);
|
|
1026 break;
|
|
1027 case SBRANK_TEXT:
|
|
1028 sprintf(buf, "You need a rank of %s or higher to command a starbase!", ranks[packet->argument].name);
|
|
1029 warning(buf);
|
|
1030 break;
|
|
1031 case SBDOCKREFUSE_TEXT:
|
|
1032 sprintf(buf, "Starbase %s refusing us docking permission captain.",
|
|
1033 players[packet->argument].p_name);
|
|
1034 warning(buf);
|
|
1035 break;
|
|
1036 case SBDOCKDENIED_TEXT:
|
|
1037 sprintf(buf, "Starbase %s: Permission to dock denied, all ports currently occupied.", players[packet->argument].p_name);
|
|
1038 warning(buf);
|
|
1039 break;
|
|
1040 case SBLOCKSTRANGER:
|
|
1041 sprintf(buf, "Locking onto %s (%c%c)",
|
|
1042 players[packet->argument].p_name,
|
|
1043 TEAM_LETTER(players[packet->argument]),
|
|
1044 shipnos[players[packet->argument].p_no]);
|
|
1045 warning(buf);
|
|
1046 break;
|
|
1047 case SBLOCKMYTEAM:
|
|
1048 sprintf(buf, "Locking onto %s (%c%c) (docking is %s)",
|
|
1049 players[packet->argument].p_name,
|
|
1050 TEAM_LETTER(players[packet->argument]),
|
|
1051 shipnos[players[packet->argument].p_no],
|
|
1052 (players[packet->argument].p_flags & PFDOCKOK) ? "enabled" : "disabled");
|
|
1053 warning(buf);
|
|
1054 break;
|
|
1055 case DMKILL:
|
|
1056 {
|
|
1057 struct mesg_spacket msg;
|
|
1058 int killer, victim, armies;
|
|
1059 float kills;
|
|
1060 victim = (unsigned char) packet->argument & 0x3f;
|
|
1061 killer = (unsigned char) packet->argument2 & 0x3f;
|
|
1062 /* that's only a temp */
|
|
1063 damage = (unsigned char) karg3;
|
|
1064 damage |= (karg4 & 127) << 8;
|
|
1065 kills = damage / 100.0;
|
|
1066 if (kills == 0.0)
|
|
1067 strcpy(killmess, "NO CREDIT");
|
|
1068 else
|
|
1069 sprintf(killmess, "%0.2f", kills);
|
|
1070 armies = (((unsigned char) packet->argument >> 6) | ((unsigned char) packet->argument2 & 192) >> 4);
|
|
1071 if (karg4 & 128)
|
|
1072 armies |= 16;
|
|
1073 if (armies == 0) {
|
|
1074 (void) sprintf(msg.mesg, "%s%s (%c%c) [%c%c] was kill %s for %s (%c%c) [%c%c]",
|
|
1075 (godToAllOnKills ? "GOD->ALL " : ""),
|
|
1076 players[victim].p_name,
|
|
1077 TEAM_LETTER(players[victim]),
|
|
1078 shipnos[victim],
|
|
1079 players[victim].p_ship->s_desig[0],
|
|
1080 players[victim].p_ship->s_desig[1],
|
|
1081 killmess,
|
|
1082 players[killer].p_name,
|
|
1083 TEAM_LETTER(players[killer]),
|
|
1084 shipnos[killer],
|
|
1085 players[killer].p_ship->s_desig[0],
|
|
1086 players[killer].p_ship->s_desig[1]);
|
|
1087 msg.m_flags = MALL | MVALID | MKILL;
|
|
1088 } else {
|
|
1089 #ifdef SOUND /* was feeling a little silly :-) */
|
|
1090 if (killer == me->p_no || alwaysSoundDoosh)
|
|
1091 S_PlaySound(S_DOOSH);
|
|
1092 #endif
|
|
1093 (void) sprintf(msg.mesg, "%s%s (%c%c+%d armies) [%c%c]: kill %s for %s (%c%c) [%c%c]",
|
|
1094 (godToAllOnKills ? "GOD->ALL " : ""),
|
|
1095 players[victim].p_name,
|
|
1096 TEAM_LETTER(players[victim]),
|
|
1097 shipnos[victim],
|
|
1098 armies,
|
|
1099 players[victim].p_ship->s_desig[0],
|
|
1100 players[victim].p_ship->s_desig[1],
|
|
1101 killmess,
|
|
1102 players[killer].p_name,
|
|
1103 TEAM_LETTER(players[killer]),
|
|
1104 shipnos[killer],
|
|
1105 players[killer].p_ship->s_desig[0],
|
|
1106 players[killer].p_ship->s_desig[1]);
|
|
1107 msg.m_flags = MALL | MVALID | MKILLA;
|
|
1108 }
|
|
1109 if (why_dead) {
|
|
1110 add_whydead(msg.mesg, karg5);
|
|
1111 karg5 = 0;
|
|
1112 }
|
|
1113 msg.type = SP_MESSAGE;
|
|
1114 msg.mesg[79] = '\0';
|
|
1115 msg.m_recpt = 0;
|
|
1116 msg.m_from = 255;
|
|
1117 handleMessage(&msg);
|
|
1118 }
|
|
1119 break;
|
|
1120 case KILLARGS:
|
|
1121 karg3 = (unsigned char) packet->argument;
|
|
1122 karg4 = (unsigned char) packet->argument2;
|
|
1123 break;
|
|
1124 case KILLARGS2:
|
|
1125 karg5 = (unsigned char) packet->argument;
|
|
1126 break;
|
|
1127 case DMKILLP:
|
|
1128 {
|
|
1129 struct mesg_spacket msg;
|
|
1130 (void) sprintf(msg.mesg, "%s%s (%c%c) [%c%c] killed by %s (%c)",
|
|
1131 (godToAllOnKills ? "GOD->ALL " : ""),
|
|
1132 players[packet->argument].p_name,
|
|
1133 TEAM_LETTER(players[packet->argument]),
|
|
1134 shipnos[packet->argument],
|
|
1135 players[packet->argument].p_ship->s_desig[0],
|
|
1136 players[packet->argument].p_ship->s_desig[1],
|
|
1137 planets[(unsigned char) packet->argument2].pl_name,
|
|
1138 TEAM_LETTERP(planets[(unsigned char) packet->argument2]));
|
|
1139 if (why_dead) {
|
|
1140 add_whydead(msg.mesg, karg5);
|
|
1141 karg5 = 0;
|
|
1142 }
|
|
1143 msg.type = SP_MESSAGE;
|
|
1144 msg.mesg[79] = '\0';
|
|
1145 msg.m_flags = MALL | MVALID | MKILLP;
|
|
1146 msg.m_recpt = 0;
|
|
1147 msg.m_from = 255;
|
|
1148 handleMessage(&msg);
|
|
1149 }
|
|
1150 break;
|
|
1151 case DMBOMB:
|
|
1152 {
|
|
1153 struct mesg_spacket msg;
|
|
1154 char buf1[80];
|
|
1155 (void) sprintf(buf, "%-3s->%-3s", planets[(unsigned char) packet->argument2].pl_name, TEAM_SHORTP(planets[(unsigned char) packet->argument2]));
|
|
1156 (void) sprintf(buf1, "We are being attacked by %s %c%c who is %d%% damaged.",
|
|
1157 players[packet->argument].p_name,
|
|
1158 TEAM_LETTER(players[packet->argument]),
|
|
1159 shipnos[packet->argument],
|
|
1160 arg3);
|
|
1161 (void) sprintf(msg.mesg, "%s %s", buf, buf1);
|
|
1162 msg.type = SP_MESSAGE;
|
|
1163 msg.mesg[79] = '\0';
|
|
1164 msg.m_flags = MTEAM | MBOMB | MVALID;
|
|
1165 msg.m_recpt = planets[(unsigned char) packet->argument2].pl_owner;
|
|
1166 msg.m_from = 255;
|
|
1167 handleMessage(&msg);
|
|
1168 }
|
|
1169 break;
|
|
1170 case DMDEST:
|
|
1171 {
|
|
1172 struct mesg_spacket msg;
|
|
1173 char buf1[80];
|
|
1174 (void) sprintf(buf, "%s destroyed by %s (%c%c)",
|
|
1175 planets[(unsigned char) packet->argument].pl_name,
|
|
1176 players[packet->argument2].p_name,
|
|
1177 TEAM_LETTER(players[packet->argument2]),
|
|
1178 shipnos[(unsigned char) packet->argument2]);
|
|
1179 (void) sprintf(buf1, "%-3s->%-3s",
|
|
1180 planets[(unsigned char) packet->argument].pl_name, TEAM_SHORTP(planets[(unsigned char) packet->argument]));
|
|
1181 (void) sprintf(msg.mesg, "%s %s", buf1, buf);
|
|
1182 msg.type = SP_MESSAGE;
|
|
1183 msg.mesg[79] = '\0';
|
|
1184 msg.m_flags = MTEAM | MDEST | MVALID;
|
|
1185 msg.m_recpt = planets[(unsigned char) packet->argument].pl_owner;
|
|
1186 msg.m_from = 255;
|
|
1187 handleMessage(&msg);
|
|
1188 }
|
|
1189 break;
|
|
1190 case DMTAKE:
|
|
1191 {
|
|
1192 struct mesg_spacket msg;
|
|
1193 char buf1[80];
|
|
1194 (void) sprintf(buf, "%s taken over by %s (%c%c)",
|
|
1195 planets[(unsigned char) packet->argument].pl_name,
|
|
1196 players[packet->argument2].p_name,
|
|
1197 TEAM_LETTER(players[packet->argument2]),
|
|
1198 shipnos[packet->argument2]);
|
|
1199 (void) sprintf(buf1, "%-3s->%-3s",
|
|
1200 planets[(unsigned char) packet->argument].pl_name, TEAM_SHORT(players[packet->argument2]));
|
|
1201 (void) sprintf(msg.mesg, "%s %s", buf1, buf);
|
|
1202 msg.type = SP_MESSAGE;
|
|
1203 msg.mesg[79] = '\0';
|
|
1204 msg.m_flags = MTEAM | MTAKE | MVALID;
|
|
1205 msg.m_recpt = idx_to_mask(players[packet->argument2].p_teami);
|
|
1206 msg.m_from = 255;
|
|
1207 handleMessage(&msg);
|
|
1208 }
|
|
1209 break;
|
|
1210 case DGHOSTKILL:
|
|
1211 {
|
|
1212 struct mesg_spacket msg;
|
|
1213 ushort damage;
|
|
1214 damage = (unsigned char) karg3;
|
|
1215 damage |= (unsigned char) (karg4 & 0xff) << 8;
|
|
1216 (void) sprintf(msg.mesg, "GOD->ALL %s (%c%c) was kill %0.2f for the GhostBusters",
|
|
1217 players[(unsigned char) packet->argument].p_name, TEAM_LETTER(players[(unsigned char) packet->argument]),
|
|
1218 shipnos[(unsigned char) packet->argument],
|
|
1219 (float) damage / 100.0);
|
|
1220 msg.type = SP_MESSAGE;
|
|
1221 msg.mesg[79] = '\0';
|
|
1222 msg.m_flags = MALL | MVALID;
|
|
1223 msg.m_recpt = 0;
|
|
1224 msg.m_from = 255;
|
|
1225 handleMessage(&msg);
|
|
1226 }
|
|
1227 break;
|
|
1228 /* INL Daemon Mesages */
|
|
1229 case INLDMKILLP:
|
|
1230 {
|
|
1231 struct mesg_spacket msg;
|
|
1232 *buf = 0;
|
|
1233 if (arg3) { /* Armies */
|
|
1234 sprintf(buf, "+%d", arg3);
|
|
1235 #ifdef SOUND
|
|
1236 if(alwaysSoundDoosh)
|
|
1237 S_PlaySound(S_DOOSH);
|
|
1238 #endif
|
|
1239 }
|
|
1240 (void) sprintf(msg.mesg, "%s%s[%s] (%c%c%s) killed by %s (%c)",
|
|
1241 (godToAllOnKills ? "GOD->ALL " : ""),
|
|
1242 players[(unsigned char) packet->argument].p_name,
|
|
1243 ship_type(players[(unsigned char) packet->argument].p_ship),
|
|
1244 TEAM_LETTER(players[(unsigned char) packet->argument]),
|
|
1245 shipnos[(unsigned char) packet->argument],
|
|
1246 buf,
|
|
1247 planets[(unsigned char) packet->argument2].pl_name,
|
|
1248 TEAM_LETTERP(planets[(unsigned char) packet->argument2]));
|
|
1249 if (why_dead) {
|
|
1250 add_whydead(msg.mesg, karg5);
|
|
1251 karg5 = 0;
|
|
1252 }
|
|
1253 msg.type = SP_MESSAGE;
|
|
1254 msg.mesg[79] = '\0';
|
|
1255 msg.m_flags = MALL | MVALID | MKILLP;
|
|
1256 msg.m_recpt = 0;
|
|
1257 msg.m_from = 255;
|
|
1258 handleMessage(&msg);
|
|
1259 }
|
|
1260 break;
|
|
1261 case INLDMKILL:
|
|
1262 {
|
|
1263 struct mesg_spacket msg;
|
|
1264 int killer, victim, armies;
|
|
1265 float kills;
|
|
1266 victim = (unsigned char) packet->argument & 0x3f;
|
|
1267 killer = (unsigned char) packet->argument2 & 0x3f;
|
|
1268 /* that's only a temp */
|
|
1269 damage = (unsigned char) karg3;
|
|
1270 damage |= (karg4 & 127) << 8;
|
|
1271 kills = damage / 100.0;
|
|
1272 armies = (((unsigned char) packet->argument >> 6) | ((unsigned char) packet->argument2 & 192) >> 4);
|
|
1273 if (karg4 & 128)
|
|
1274 armies |= 16;
|
|
1275 if (armies == 0) {
|
|
1276 (void) sprintf(msg.mesg, "%s%s[%s] (%c%c) was kill %0.2f for %s[%s] (%c%c)",
|
|
1277 (godToAllOnKills ? "GOD->ALL " : ""),
|
|
1278 players[victim].p_name,
|
|
1279 ship_type(players[victim].p_ship),
|
|
1280 TEAM_LETTER(players[victim]),
|
|
1281 shipnos[victim],
|
|
1282 kills,
|
|
1283 players[killer].p_name,
|
|
1284 ship_type(players[killer].p_ship),
|
|
1285 TEAM_LETTER(players[killer]),
|
|
1286 shipnos[killer]);
|
|
1287 msg.m_flags = MALL | MVALID | MKILL;
|
|
1288 } else {
|
|
1289 #ifdef SOUND
|
|
1290 if(killer == me->p_no || alwaysSoundDoosh)
|
|
1291 S_PlaySound(S_DOOSH);
|
|
1292 #endif
|
|
1293 (void) sprintf(msg.mesg, "%s%s[%s] (%c%c+%d armies) was kill %0.2f for %s[%s] (%c%c)",
|
|
1294 (godToAllOnKills ? "GOD->ALL " : ""),
|
|
1295 players[victim].p_name,
|
|
1296 ship_type(players[victim].p_ship),
|
|
1297 TEAM_LETTER(players[victim]),
|
|
1298 shipnos[victim],
|
|
1299 armies,
|
|
1300 kills,
|
|
1301 players[killer].p_name,
|
|
1302 ship_type(players[killer].p_ship),
|
|
1303 TEAM_LETTER(players[killer]),
|
|
1304 shipnos[killer]);
|
|
1305 msg.m_flags = MALL | MVALID | MKILLA;
|
|
1306 }
|
|
1307 if (why_dead) {
|
|
1308 add_whydead(msg.mesg, karg5);
|
|
1309 karg5 = 0;
|
|
1310 }
|
|
1311 msg.type = SP_MESSAGE;
|
|
1312 msg.mesg[79] = '\0';
|
|
1313 msg.m_recpt = 0;
|
|
1314 msg.m_from = 255;
|
|
1315 handleMessage(&msg);
|
|
1316 }
|
|
1317 break;
|
|
1318 case INLDRESUME:
|
|
1319 {
|
|
1320 struct mesg_spacket msg;
|
|
1321 sprintf(msg.mesg, " Game will resume in %d seconds", (unsigned char) packet->argument);
|
|
1322 msg.m_flags = MALL | MVALID;
|
|
1323 msg.type = SP_MESSAGE;
|
|
1324 msg.mesg[79] = '\0';
|
|
1325 msg.m_recpt = 0;
|
|
1326 msg.m_from = 255;
|
|
1327 handleMessage(&msg);
|
|
1328 }
|
|
1329 break;
|
|
1330 case INLDTEXTE:
|
|
1331 if (packet->argument >= 0 && (unsigned char) packet->argument < NUMDAEMONTEXTS) {
|
|
1332 struct mesg_spacket msg;
|
|
1333 strcpy(msg.mesg, daemon_texts[(unsigned char) packet->argument]);
|
|
1334 msg.m_flags = MALL | MVALID;
|
|
1335 msg.type = SP_MESSAGE;
|
|
1336 msg.mesg[79] = '\0';
|
|
1337 msg.m_recpt = 0;
|
|
1338 msg.m_from = 255;
|
|
1339 handleMessage(&msg);
|
|
1340 }
|
|
1341 break;
|
|
1342 case STEXTE:
|
|
1343 warning(s_texte[(unsigned char) packet->argument]);
|
|
1344 break;
|
|
1345 case SHORT_WARNING:
|
|
1346 {
|
|
1347 struct warning_spacket *warn = (struct warning_spacket *) packet;
|
|
1348 warning(warn->mesg);
|
|
1349 }
|
|
1350 break;
|
|
1351 case STEXTE_STRING:
|
|
1352 {
|
|
1353 struct warning_spacket *warn = (struct warning_spacket *) packet;
|
|
1354 warning(warn->mesg);
|
|
1355 s_texte[(unsigned char) warn->pad2] = (char *) malloc(warn->pad3 - 4);
|
|
1356 if (s_texte[(unsigned char) warn->pad2] == NULL) {
|
|
1357 s_texte[(unsigned char) warn->pad2] = no_memory;
|
|
1358 warning("Could not add warning! (No memory!)");
|
|
1359 } else
|
|
1360 strcpy(s_texte[(unsigned char) warn->pad2], warn->mesg);
|
|
1361 }
|
|
1362 break;
|
|
1363 default:
|
|
1364 warning("Unknown Short Warning!");
|
|
1365 break;
|
|
1366 }
|
|
1367 }
|
|
1368
|
|
1369 #define MY_SIZEOF(a) (sizeof(a) / sizeof(*(a)))
|
|
1370
|
|
1371 void
|
|
1372 add_whydead(s, m) /* 7/22/93 LAB */
|
|
1373 char *s;
|
|
1374 int m;
|
|
1375 {
|
|
1376 char b[256];
|
|
1377
|
|
1378 if (m < MY_SIZEOF(whydeadmess)) {
|
|
1379 sprintf(b, "%-50s %s", s, whydeadmess[m]);
|
|
1380 b[79] = '\0';
|
|
1381 strcpy(s, b);
|
|
1382 }
|
|
1383 }
|
|
1384
|
|
1385 #endif
|
|
1386
|
|
1387 /* END SHORT_PACKETS */
|