forked from hyperyoda/netrek-client-brmh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
war.c
100 lines (90 loc) · 2.31 KB
/
war.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
* war.c
*/
#include "copyright.h"
#include <stdio.h>
#include <math.h>
#include <signal.h>
#include "netrek.h"
static int newhostile;
/* Set up the war window and map it */
static char *feds = "FED - ";
static char *roms = "ROM - ";
static char *klis = "KLI - ";
static char *oris = "ORI - ";
static char *gos = " Re-program";
static char *exs = " Exit - no change";
static char *peaces = "Peace";
static char *hostiles = "Hostile";
static char *wars = "War";
void
warwindow()
{
W_MapWindow(war);
newhostile = me->p_hostile;
warrefresh();
}
void
warrefresh()
{
fillwin(0, feds, newhostile, me->p_swar, FED);
fillwin(1, roms, newhostile, me->p_swar, ROM);
fillwin(2, klis, newhostile, me->p_swar, KLI);
fillwin(3, oris, newhostile, me->p_swar, ORI);
W_WriteText(war, 0, 4, textColor, gos, strlen(gos), 0);
W_WriteText(war, 0, 5, textColor, exs, strlen(exs), 0);
}
void
fillwin(menunum, string, hostile, warbits, team)
int menunum;
char *string;
int hostile, warbits;
int team;
{
char buf[80];
if (team & warbits) {
(void) sprintf(buf, " %s%s", string, wars);
W_WriteText(war, 0, menunum, rColor, buf, strlen(buf), 0);
} else if (team & hostile) {
(void) sprintf(buf, " %s%s", string, hostiles);
W_WriteText(war, 0, menunum, yColor, buf, strlen(buf), 0);
} else {
(void) sprintf(buf, " %s%s", string, peaces);
W_WriteText(war, 0, menunum, gColor, buf, strlen(buf), 0);
}
}
void
waraction(data)
W_Event *data;
{
int enemyteam = 0;
if (data->y == 4) {
W_UnmapWindow(war);
sendWarReq(newhostile);
redrawall = 1; /* jch -- redraw planet names in diff font */
return;
}
if (data->y == 5) {
W_UnmapWindow(war);
return;
}
if (data->y == 0)
enemyteam = FED;
if (data->y == 1)
enemyteam = ROM;
if (data->y == 2)
enemyteam = KLI;
if (data->y == 3)
enemyteam = ORI;
if (me->p_swar & enemyteam) {
warning("You are already at war!");
W_Beep();
} else {
if (me->p_team == enemyteam) {
warning("It would never work ... your crew would have you in the brig in no time.");
} else {
newhostile ^= enemyteam;
}
}
warrefresh();
}