Mercurial > ~darius > hgwebdir.cgi > paradise_client
comparison war.c @ 3:5a977ccbc7a9 default tip
Empty changelog
author | darius |
---|---|
date | Sat, 06 Dec 1997 05:41:29 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
2:fba0b6e6cdc7 | 3:5a977ccbc7a9 |
---|---|
1 /* $Id: war.c,v 1.1.1.1 1997/12/06 05:41:31 darius Exp $ */ | |
2 | |
3 /* | |
4 * war.c | |
5 */ | |
6 #include "copyright.h" | |
7 | |
8 #include <stdio.h> | |
9 #include <math.h> | |
10 #include <signal.h> | |
11 #include "Wlib.h" | |
12 #include "defs.h" | |
13 #include "struct.h" | |
14 #include "data.h" | |
15 #include "packets.h" | |
16 #include "proto.h" | |
17 | |
18 static int newhostile; | |
19 | |
20 /* Set up the war window and map it */ | |
21 static char *feds = "FED - "; | |
22 static char *roms = "ROM - "; | |
23 static char *klis = "KLI - "; | |
24 static char *oris = "ORI - "; | |
25 static char *gos = " Re-program"; | |
26 static char *exs = " Exit - no change"; | |
27 static char *peaces = "Peace"; | |
28 static char *hostiles = "Hostile"; | |
29 static char *wars = "War"; | |
30 | |
31 /* Prototypes */ | |
32 static void fillwin P((int menunum, char *string, int hostile, int warbits, int team)); | |
33 static void warrefresh P((void)); | |
34 | |
35 void | |
36 warwindow() | |
37 { | |
38 W_MapWindow(war); | |
39 newhostile = me->p_hostile; | |
40 warrefresh(); | |
41 } | |
42 | |
43 static void | |
44 warrefresh() | |
45 { | |
46 fillwin(0, feds, newhostile, me->p_swar, FEDm); | |
47 fillwin(1, roms, newhostile, me->p_swar, ROMm); | |
48 fillwin(2, klis, newhostile, me->p_swar, KLIm); | |
49 fillwin(3, oris, newhostile, me->p_swar, ORIm); | |
50 W_WriteText(war, 0, 4, textColor, gos, strlen(gos), 0); | |
51 W_WriteText(war, 0, 5, textColor, exs, strlen(exs), 0); | |
52 } | |
53 | |
54 static void | |
55 fillwin(menunum, string, hostile, warbits, teammask) | |
56 int menunum; | |
57 char *string; | |
58 int hostile, warbits; | |
59 int teammask; | |
60 { | |
61 char buf[80]; | |
62 | |
63 if (teammask & warbits) { | |
64 (void) sprintf(buf, " %s%s", string, wars); | |
65 W_WriteText(war, 0, menunum, rColor, buf, strlen(buf), 0); | |
66 } else if (teammask & hostile) { | |
67 (void) sprintf(buf, " %s%s", string, hostiles); | |
68 W_WriteText(war, 0, menunum, yColor, buf, strlen(buf), 0); | |
69 } else { | |
70 (void) sprintf(buf, " %s%s", string, peaces); | |
71 W_WriteText(war, 0, menunum, gColor, buf, strlen(buf), 0); | |
72 } | |
73 } | |
74 | |
75 void | |
76 waraction(data) | |
77 W_Event *data; | |
78 { | |
79 int enemymask; | |
80 | |
81 if (data->y == 4) { | |
82 W_UnmapWindow(war); | |
83 sendWarReq(newhostile); | |
84 return; | |
85 } | |
86 if (data->y == 5) { | |
87 W_UnmapWindow(war); | |
88 return; | |
89 } | |
90 enemymask = 1 << data->y; | |
91 | |
92 if (me->p_swar & enemymask) { | |
93 warning("You are already at war!"); | |
94 W_Beep(); | |
95 } else { | |
96 if (idx_to_mask(me->p_teami) == enemymask) { | |
97 warning("It would never work ... your crew would have you in the brig in no time."); | |
98 } else { | |
99 newhostile ^= enemymask; | |
100 } | |
101 } | |
102 warrefresh(); | |
103 } |