annotate gameconf.c @ 3:5a977ccbc7a9 default tip

Empty changelog
author darius
date Sat, 06 Dec 1997 05:41:29 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1 /* $Id: gameconf.c,v 1.1.1.1 1997/12/06 05:41:29 darius Exp $ */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
3 #include <stdio.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
4 #include <string.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
5 #include <sys/types.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
6 #include <netinet/in.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
7 #include <time.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
8 #ifndef hpux
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
9 #include <sys/time.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
10 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
11 #ifdef __STDC__
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
12 #include <stdlib.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
13 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
14
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
15 #include "gameconf.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
16 #include "defaultlogos.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
17 #include "data.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
18 #include "gppackets.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
19
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
20 int number_of_teams;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
21
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
22 struct teaminfo_s *teaminfo = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
23
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
24 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
25 load_default_teams()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
26 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
27 number_of_teams = 4;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
28
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
29 /* independent is teaminfo[-1], allteam is teaminfo[4] */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
30 teaminfo = 1 + (struct teaminfo_s *) malloc(sizeof(*teaminfo) * (number_of_teams + 2));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
31
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
32 strcpy(teaminfo[-1].name, "Independant");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
33 teaminfo[-1].letter = 'I';
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
34 strcpy(teaminfo[-1].shortname, "IND");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
35
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
36 strcpy(teaminfo[0].name, "Federation");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
37 teaminfo[0].letter = 'F';
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
38 strcpy(teaminfo[0].shortname, "FED");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
39
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
40
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
41 strcpy(teaminfo[1].name, "Romulan");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
42 teaminfo[1].letter = 'R';
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
43 strcpy(teaminfo[1].shortname, "ROM");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
44
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
45
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
46 strcpy(teaminfo[2].name, "Klingon");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
47 teaminfo[2].letter = 'K';
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
48 strcpy(teaminfo[2].shortname, "KLI");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
49
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
50
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
51 strcpy(teaminfo[3].name, "Orion");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
52 teaminfo[3].letter = 'O';
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
53 strcpy(teaminfo[3].shortname, "ORI");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
54
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
55 strcpy(teaminfo[4].name, "None");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
56 teaminfo[4].letter = '-';
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
57 strcpy(teaminfo[4].shortname, "NON");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
58 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
59
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
60 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
61 load_default_teamlogos()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
62 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
63 if (number_of_teams < 1)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
64 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
65 teaminfo[0].shield_logo = W_StoreBitmap(fedshield_width, fedshield_height,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
66 fedshield_bits, teamWin[0]);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
67 if (number_of_teams < 2)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
68 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
69 teaminfo[1].shield_logo = W_StoreBitmap(romshield_width, romshield_height,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
70 romshield_bits, teamWin[1]);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
71 if (number_of_teams < 3)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
72 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
73 teaminfo[2].shield_logo = W_StoreBitmap(klishield_width, klishield_height,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
74 klishield_bits, teamWin[2]);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
75 if (number_of_teams < 4)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
76 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
77 teaminfo[3].shield_logo = W_StoreBitmap(orishield_width, orishield_height,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
78 orishield_bits, teamWin[3]);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
79 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
80
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
81 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
82 load_generic_teams()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
83 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
84 /*
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
85 reserved letters: A G T
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
86 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
87 int i;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
88
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
89 /* independent is teaminfo[-1] */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
90 teaminfo = 1 + (struct teaminfo_s *) malloc(sizeof(*teaminfo) * (number_of_teams + 1));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
91
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
92 strcpy(teaminfo[-1].name, "Independant");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
93 teaminfo[-1].letter = 'I';
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
94 strcpy(teaminfo[-1].shortname, "IND");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
95
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
96 load_default_teamlogos(); /* loads the first 4 team logos */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
97
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
98 for (i = 0; i < number_of_teams; i++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
99 sprintf(teaminfo[i].name, "Team #%d", i);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
100 teaminfo[i].letter = 'J' + i; /* I, J through P */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
101 sprintf(teaminfo[i].shortname, "T%02d", i);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
102
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
103 #if 0
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
104 /* we should draw something nifty here */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
105 if (i >= 4) /* the first 4 have been loaded already. */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
106 teaminfo[i].shield_logo = W_StoreBitmap(1, 1, &i, teamWin[i]);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
107 /* XXX uh-oh if more than 4 teams */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
108
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
109 /* exactly. If there are more than 4 teams the above will SEGV because
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
110 of the &i (which should be a char * bitmap array).
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
111 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
112 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
113
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
114 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
115 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
116
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
117 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
118 initialize_thingies()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
119 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
120 int i;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
121 int n = (npthingies * nplayers + ngthingies);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
122 thingies = (struct thingy *) malloc(sizeof(*thingies) * n);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
123 for (i = 0; i < n; i++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
124 thingies[i].t_shape = SHP_BLANK;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
125 thingies[i].t_no = i;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
126 thingies[i].t_owner = (i >= npthingies * nplayers) ? -1 : (i / npthingies);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
127 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
128 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
129
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
130 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
131 initialize_players()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
132 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
133 int i;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
134
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
135 players = (struct player *) malloc(sizeof(*players) * nplayers);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
136
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
137 bzero(players, sizeof(struct player) * nplayers);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
138
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
139 for (i = 0; i < nplayers; i++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
140 players[i].p_status = PFREE;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
141 players[i].p_cloakphase = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
142 players[i].p_no = i;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
143 players[i].p_ntorp = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
144 players[i].p_ndrone = 0;/* TSH */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
145 players[i].p_explode = 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
146 players[i].p_stats.st_tticks = 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
147 players[i].p_ship = shiptypes->ship;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
148 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
149 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
150
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
151 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
152 initialize_torps()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
153 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
154 int i;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
155
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
156 torps = (struct torp *) malloc(sizeof(*torps) * nplayers * ntorps);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
157
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
158 for (i = 0; i < nplayers * ntorps; i++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
159 torps[i].t_status = TFREE;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
160 torps[i].t_no = i;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
161 torps[i].t_owner = (i / ntorps);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
162 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
163 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
164
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
165 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
166 initialize_plasmas()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
167 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
168 int i;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
169
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
170 plasmatorps = (struct plasmatorp *) malloc(sizeof(*plasmatorps) * nplayers * nplasmas);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
171
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
172 for (i = 0; i < nplayers * nplasmas; i++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
173 plasmatorps[i].pt_status = PTFREE;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
174 plasmatorps[i].pt_no = i;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
175 plasmatorps[i].pt_owner = (i / nplasmas);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
176 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
177 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
178
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
179 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
180 initialize_phasers()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
181 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
182 int i;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
183
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
184 phasers = (struct phaser *) malloc(sizeof(*phasers) * nplayers * nphasers);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
185
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
186 for (i = 0; i < nplayers * nphasers; i++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
187 phasers[i].ph_status = PHFREE;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
188 phasers[i].ph_fuse = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
189 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
190 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
191
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
192 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
193 initialize_planets()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
194 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
195 int i;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
196
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
197 planets = (struct planet *) malloc(sizeof(*planets) * nplanets);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
198
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
199 for (i = 0; i < nplanets; i++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
200 struct planet *curr = &planets[i];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
201 curr->pl_no = i;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
202 curr->pl_flags = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
203 curr->pl_owner = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
204 curr->pl_x = curr->pl_y = -10000;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
205 sprintf(curr->pl_name, "planet%d", i);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
206 curr->pl_namelen = strlen(curr->pl_name);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
207 curr->pl_armies = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
208 curr->pl_info = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
209 curr->pl_deadtime = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
210 curr->pl_couptime = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
211 curr->pl_timestamp = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
212
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
213 /* initialize planet redraw for moving planets */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
214 pl_update[i].plu_update = -1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
215 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
216 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
217
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
218 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
219 init_ranks()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
220 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
221 ranks2 = (struct rank2 *) malloc(sizeof(*ranks2) * nranks2);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
222 ranks2[0].genocides = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
223 ranks2[0].di = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
224 ranks2[0].battle = 0.0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
225 ranks2[0].strategy = 0.0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
226 ranks2[0].specship = 0.0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
227 ranks2[0].name = strdup("Recruit");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
228
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
229 ranks2[1].genocides = 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
230 ranks2[1].di = 10;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
231 ranks2[1].battle = 0.30;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
232 ranks2[1].strategy = 0.3;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
233 ranks2[1].specship = 0.0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
234 ranks2[1].name = strdup("Specialist");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
235
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
236 ranks2[2].genocides = 2;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
237 ranks2[2].di = 25;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
238 ranks2[2].battle = 0.40;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
239 ranks2[2].strategy = 0.6;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
240 ranks2[2].specship = 0.0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
241 ranks2[2].name = strdup("Cadet");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
242
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
243 ranks2[3].genocides = 3;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
244 ranks2[3].di = 45;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
245 ranks2[3].battle = 0.50;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
246 ranks2[3].strategy = 0.9;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
247 ranks2[3].specship = 0.0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
248 ranks2[3].name = strdup("Midshipman");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
249
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
250 ranks2[4].genocides = 4;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
251 ranks2[4].di = 70;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
252 ranks2[4].battle = 0.70;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
253 ranks2[4].strategy = 1.2;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
254 ranks2[4].specship = 0.0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
255 ranks2[4].name = strdup("Ensn. J.G.");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
256
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
257 ranks2[5].genocides = 5;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
258 ranks2[5].di = 100;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
259 ranks2[5].battle = 0.90;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
260 ranks2[5].strategy = 1.5;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
261 ranks2[5].specship = 0.0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
262 ranks2[5].name = strdup("Ensign");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
263
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
264 ranks2[6].genocides = 6;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
265 ranks2[6].di = 140;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
266 ranks2[6].battle = 1.10;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
267 ranks2[6].strategy = 2.0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
268 ranks2[6].specship = 0.0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
269 ranks2[6].name = strdup("Lt. J.G.");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
270
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
271 ranks2[7].genocides = 8;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
272 ranks2[7].di = 190;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
273 ranks2[7].battle = 1.30;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
274 ranks2[7].strategy = 2.5;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
275 ranks2[7].specship = 0.0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
276 ranks2[7].name = strdup("Lieutenant");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
277
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
278 ranks2[8].genocides = 10;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
279 ranks2[8].di = 250;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
280 ranks2[8].battle = 1.50;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
281 ranks2[8].strategy = 3.0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
282 ranks2[8].specship = 0.5;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
283 ranks2[8].name = strdup("Lt. Cmdr.");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
284
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
285 ranks2[9].genocides = 15;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
286 ranks2[9].di = 300;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
287 ranks2[9].battle = 1.80;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
288 ranks2[9].strategy = 3.5;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
289 ranks2[9].specship = 0.7;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
290 ranks2[9].name = strdup("Commander");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
291
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
292 ranks2[10].genocides = 18;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
293 ranks2[10].di = 350;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
294 ranks2[10].battle = 2.00;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
295 ranks2[10].strategy = 4.0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
296 ranks2[10].specship = 1.0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
297 ranks2[10].name = strdup("Captain");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
298
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
299 ranks2[11].genocides = 25;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
300 ranks2[11].di = 400;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
301 ranks2[11].battle = 2.10;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
302 ranks2[11].strategy = 4.3;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
303 ranks2[11].specship = 2.5;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
304 ranks2[11].name = strdup("Fleet Capt.");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
305
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
306 ranks2[12].genocides = 50;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
307 ranks2[12].di = 500;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
308 ranks2[12].battle = 2.15;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
309 ranks2[12].strategy = 4.8;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
310 ranks2[12].specship = 3.0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
311 ranks2[12].name = strdup("Commodore");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
312
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
313 ranks2[13].genocides = 75;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
314 ranks2[13].di = 700;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
315 ranks2[13].battle = 2.20;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
316 ranks2[13].strategy = 5.3;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
317 ranks2[13].specship = 3.3;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
318 ranks2[13].name = strdup("Moff");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
319
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
320 ranks2[14].genocides = 100;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
321 ranks2[14].di = 900;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
322 ranks2[14].battle = 2.25;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
323 ranks2[14].strategy = 5.7;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
324 ranks2[14].specship = 3.6;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
325 ranks2[14].name = strdup("Grand Moff");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
326
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
327 ranks2[15].genocides = 300;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
328 ranks2[15].di = 1200;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
329 ranks2[15].battle = 2.30;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
330 ranks2[15].strategy = 6.0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
331 ranks2[15].specship = 3.8;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
332 ranks2[15].name = strdup("Rear Adml.");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
333
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
334 ranks2[16].genocides = 700;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
335 ranks2[16].di = 1700;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
336 ranks2[16].battle = 2.35;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
337 ranks2[16].strategy = 6.1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
338 ranks2[16].specship = 4.0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
339 ranks2[16].name = strdup("Admiral");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
340
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
341 ranks2[17].genocides = 1000;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
342 ranks2[17].di = 2500;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
343 ranks2[17].battle = 2.40;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
344 ranks2[17].strategy = 6.2;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
345 ranks2[17].specship = 4.2;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
346 ranks2[17].name = strdup("Grand Adml.");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
347 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
348
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
349 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
350 init_royal()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
351 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
352 royal = (struct royalty *) malloc(sizeof(*royal) * nroyals);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
353
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
354 royal[0].name = strdup("none");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
355 royal[1].name = strdup("Wesley");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
356 royal[2].name = strdup("Centurion");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
357 royal[3].name = strdup("Praetor");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
358 royal[4].name = strdup("Emperor");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
359 #if 0
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
360 royal[5].name = strdup("Wizard");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
361 royal[6].name = strdup("Duke");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
362 royal[7].name = strdup("Count");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
363 royal[8].name = strdup("Baron");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
364 royal[9].name = strdup("Knight");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
365 royal[10].name = strdup("Dread");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
366 royal[11].name = strdup("Lord of Destruction");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
367 royal[12].name = strdup("BlitzMeister");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
368 royal[13].name = strdup("Hitler");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
369 royal[14].name = strdup("Terminator");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
370 royal[15].name = strdup("Kamikaze");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
371 royal[16].name = strdup("Speed Kamikaze");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
372 royal[17].name = strdup("Carpet Bomber");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
373 royal[18].name = strdup("NukeMeister");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
374 royal[19].name = strdup("Terrorist");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
375 royal[20].name = strdup("Democrat");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
376 royal[21].name = strdup("Executioner");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
377 royal[22].name = strdup("DooshMeister");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
378 royal[23].name = strdup("Diplomat");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
379 royal[24].name = strdup("speed Diplomat");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
380 royal[25].name = strdup("Addict");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
381 #endif /* 0 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
382 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
383
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
384 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
385 reinit_ranks()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
386 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
387 int i;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
388 ranks2 = (struct rank2 *) malloc(sizeof(*ranks2) * nranks2);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
389
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
390 for (i = 0; i < nranks2; i++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
391 ranks2[i].name = strdup("blank");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
392 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
393 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
394
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
395 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
396 reinit_royal()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
397 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
398 int i;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
399 royal = (struct royalty *) malloc(sizeof(*royal) * nroyals);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
400
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
401 for (i = 0; i < nroyals; i++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
402 royal[i].name = strdup("blank");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
403 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
404 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
405
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
406
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
407 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
408 resize_players()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
409 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
410 int me_no;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
411
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
412 if (me)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
413 me_no = me->p_no;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
414 players = (struct player *) realloc(players, sizeof(*players) * nplayers);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
415 if (me) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
416 me = &players[me_no];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
417 myship = me->p_ship;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
418 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
419 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
420
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
421 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
422 free_teams()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
423 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
424 int i;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
425 for (i = 0; i < number_of_teams; i++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
426 W_FreeBitmap(teaminfo[i].shield_logo);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
427 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
428 /* we offsetted by 1 to make room for IND */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
429 free(teaminfo - 1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
430 teaminfo = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
431 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
432
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
433 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
434 free_torps()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
435 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
436 free(torps);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
437 torps = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
438 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
439
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
440 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
441 free_phasers()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
442 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
443 free(phasers);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
444 phasers = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
445 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
446
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
447 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
448 free_plasmas()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
449 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
450 free(plasmatorps);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
451 plasmatorps = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
452 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
453
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
454 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
455 free_thingies()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
456 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
457 free(thingies);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
458 thingies = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
459 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
460
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
461 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
462 free_ranks()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
463 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
464 int i;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
465 for (i = 0; i < nranks2; i++)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
466 if (ranks2[i].name)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
467 free(ranks2[i].name);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
468 free(ranks2);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
469 ranks2 = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
470 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
471
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
472 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
473 free_royal()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
474 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
475 int i;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
476 for (i = 0; i < nroyals; i++)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
477 if (royal[i].name)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
478 free(royal[i].name);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
479
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
480 free(royal);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
481 royal = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
482 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
483
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
484 /*
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
485 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
486
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
487 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
488 build_default_configuration()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
489 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
490 load_default_teams();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
491 /* can't load logos until we have some windows */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
492
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
493 init_shiptypes();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
494 initialize_players();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
495 initialize_torps();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
496 initialize_thingies();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
497 initialize_plasmas();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
498 initialize_planets();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
499 initialize_phasers();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
500
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
501
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
502 init_ranks();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
503 init_royal();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
504 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
505
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
506 /*
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
507 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
508
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
509
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
510 int
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
511 compute_gameparam_size(buf)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
512 char *buf;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
513 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
514 struct gameparam_spacket *pkt = (struct gameparam_spacket *) buf;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
515
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
516 if (*buf != SP_GPARAM)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
517 return -1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
518
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
519 switch (pkt->subtype) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
520 case 0:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
521 return sizeof(struct gp_sizes_spacket);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
522 case 1:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
523 return sizeof(struct gp_team_spacket);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
524 case 2:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
525 return sizeof(struct gp_teamlogo_spacket);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
526 case 3:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
527 return sizeof(struct gp_shipshape_spacket);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
528 case 4:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
529 return sizeof(struct gp_shipbitmap_spacket);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
530 case 5:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
531 return sizeof(struct gp_rank_spacket);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
532 case 6:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
533 return sizeof(struct gp_royal_spacket);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
534 case 7:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
535 return sizeof(struct gp_teamplanet_spacket);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
536 default:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
537 return -1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
538 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
539 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
540
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
541 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
542 handleGPsizes(pkt)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
543 struct gp_sizes_spacket *pkt;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
544 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
545 free_ranks();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
546 free_royal();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
547
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
548 free_teams();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
549 free_torps();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
550 free_phasers();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
551 free_plasmas();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
552 free_thingies();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
553
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
554 free_shipshapes();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
555
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
556 nplayers = pkt->nplayers;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
557 number_of_teams = pkt->nteams;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
558 /* shiptypes */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
559 nranks2 = pkt->nranks;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
560 nroyals = pkt->nroyal;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
561 nphasers = pkt->nphasers;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
562 ntorps = pkt->ntorps;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
563 nplasmas = pkt->nplasmas;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
564 npthingies = pkt->nthingies;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
565 ngthingies = pkt->gthingies;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
566
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
567 /* gwidth */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
568 /* flags */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
569
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
570 load_generic_teams();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
571
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
572 reinit_ranks();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
573 reinit_royal();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
574
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
575 resize_players();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
576 initialize_torps();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
577 initialize_phasers();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
578 initialize_plasmas();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
579 initialize_thingies();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
580
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
581 slurp_ship_bitmaps();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
582 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
583
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
584 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
585 handleGPteam(pkt)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
586 struct gp_team_spacket *pkt;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
587 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
588 struct teaminfo_s *currteam;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
589
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
590 if ((int) pkt->index >= number_of_teams) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
591 fprintf(stderr, "Team #%d %s is out of range (0..%d)\n", pkt->index,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
592 pkt->teamname, number_of_teams);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
593 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
594 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
595 currteam = &teaminfo[pkt->index];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
596
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
597 currteam->letter = pkt->letter;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
598
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
599 strncpy(currteam->shortname, pkt->shortname, 3);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
600 currteam->shortname[3] = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
601
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
602 strncpy(currteam->name, pkt->teamname, sizeof(currteam->name) - 1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
603 currteam->name[sizeof(currteam->name) - 1] = 0;;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
604 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
605
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
606 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
607 handleGPteamlogo(pkt)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
608 struct gp_teamlogo_spacket *pkt;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
609 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
610 static char buf[13 * 99]; /* 99x99 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
611 static int curr_height = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
612 static int lwidth, lheight;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
613 static int teamindex;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
614 int pwidth;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
615
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
616 if ((unsigned) pkt->teamindex >= number_of_teams) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
617 fprintf(stderr, "Team #%d is out of range (0..%d)\n", pkt->teamindex,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
618 number_of_teams);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
619 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
620 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
621 if (pkt->y != curr_height) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
622 fprintf(stderr, "Bad gp_teamlogo packet sequence y(%d) != curr_height(%d)\n",
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
623 pkt->y, curr_height);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
624 curr_height = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
625 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
626 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
627 if (curr_height) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
628 if (lwidth != pkt->logowidth || lheight != pkt->logoheight ||
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
629 teamindex != pkt->teamindex) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
630 fprintf(stderr, "gp_teamlogo packet sequence error, %d!=%d || %d!=%d || %d!=%d\n",
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
631 lwidth, pkt->logowidth, lheight, pkt->logoheight,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
632 teamindex, pkt->teamindex);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
633 curr_height = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
634 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
635 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
636 } else {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
637 teamindex = pkt->teamindex;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
638 lwidth = pkt->logowidth;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
639 lheight = pkt->logoheight;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
640 if (lwidth > 99 || lheight > 99) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
641 fprintf(stderr, "logo too big (%dx%d), rejecting\n", lwidth, lheight);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
642 curr_height = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
643 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
644 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
645 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
646 pwidth = (lwidth - 1) / 8 + 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
647 memcpy(buf + pwidth * curr_height, pkt->data, pwidth * pkt->thisheight);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
648 curr_height += pkt->thisheight;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
649
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
650 if (curr_height >= lheight) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
651 W_FreeBitmap(teaminfo[teamindex].shield_logo);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
652 teaminfo[teamindex].shield_logo = W_StoreBitmap(lwidth, lheight, buf,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
653 teamWin[teamindex]);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
654 curr_height = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
655 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
656 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
657
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
658 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
659 handleGPshipshape(pkt)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
660 struct gp_shipshape_spacket *pkt;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
661 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
662 if (pkt->race < -1 || pkt->race >= number_of_teams) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
663 fprintf(stderr, "race #%d out of range (-1..%d)\n", pkt->race,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
664 number_of_teams - 1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
665 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
666 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
667 if ( /* pkt->shipno<0 || */ (int) pkt->shipno >= nshiptypes) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
668 fprintf(stderr, "ship class #%d out of range (0..%d)\n", pkt->shipno,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
669 nshiptypes - 1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
670 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
671 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
672 replace_shipshape(pkt->race, pkt->shipno, pkt->nviews,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
673 pkt->width, pkt->height);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
674 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
675
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
676 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
677 handleGPshipbitmap(pkt)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
678 struct gp_shipbitmap_spacket *pkt;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
679 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
680 if (pkt->race < -1 || pkt->race >= number_of_teams) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
681 fprintf(stderr, "race #%d out of range (-1..%d)\n", pkt->race,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
682 number_of_teams - 1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
683 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
684 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
685 if ( /* pkt->shipno<0 || */ (int) pkt->shipno >= nshiptypes) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
686 fprintf(stderr, "ship class #%d out of range (0..%d)\n", pkt->shipno,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
687 nshiptypes - 1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
688 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
689 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
690 replace_ship_bitmap(pkt->race, pkt->shipno, pkt->thisview, pkt->bitmapdata);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
691 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
692
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
693 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
694 handleGPrank(pkt)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
695 struct gp_rank_spacket *pkt;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
696 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
697 struct rank2 *curr;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
698 if (pkt->rankn >= nranks2) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
699 fprintf(stderr, "rank #%d %s out of range (0..%d)\n", pkt->rankn,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
700 pkt->name, nranks2 - 1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
701 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
702 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
703 curr = &ranks2[pkt->rankn];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
704 free(curr->name);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
705
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
706 curr->genocides = htonl(pkt->genocides);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
707 curr->di = htonl(pkt->milliDI) / 1000.0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
708 curr->battle = htonl(pkt->millibattle) / 1000.0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
709 curr->strategy = htonl(pkt->millistrat) / 1000.0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
710 curr->specship = htonl(pkt->millispec) / 1000.0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
711 curr->name = strdup(pkt->name);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
712 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
713
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
714 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
715 handleGProyal(pkt)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
716 struct gp_royal_spacket *pkt;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
717 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
718 if ((int) pkt->rankn >= nroyals) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
719 fprintf(stderr, "Royalty #%d %s out of range (0..%d)\n", pkt->rankn,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
720 pkt->name, nroyals - 1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
721 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
722 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
723 free(royal[pkt->rankn].name);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
724 royal[pkt->rankn].name = strdup(pkt->name);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
725 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
726
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
727 static unsigned char mplanet_bits[] = {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
728 0xe0, 0x03, 0x18, 0x0c, 0x04, 0x10, 0x02, 0x20, 0x02, 0x20, 0x01, 0x40,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
729 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x02, 0x20, 0x02, 0x20,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
730 0x04, 0x10, 0x18, 0x0c, 0xe0, 0x03, 0x00, 0x00};
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
731 static unsigned char planet_bits[] = {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
732 0x00, 0xf8, 0x03, 0x00, 0x00, 0x07, 0x1c, 0x00, 0xc0, 0x00, 0x60, 0x00,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
733 0x20, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0x02,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
734 0x04, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x04, 0x02, 0x00, 0x00, 0x08,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
735 0x02, 0x00, 0x00, 0x08, 0x02, 0x00, 0x00, 0x08, 0x01, 0x00, 0x00, 0x10,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
736 0x01, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00, 0x10,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
737 0x01, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00, 0x10,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
738 0x02, 0x00, 0x00, 0x08, 0x02, 0x00, 0x00, 0x08, 0x02, 0x00, 0x00, 0x08,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
739 0x04, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x04, 0x08, 0x00, 0x00, 0x02,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
740 0x10, 0x00, 0x00, 0x01, 0x20, 0x00, 0x80, 0x00, 0xc0, 0x00, 0x60, 0x00,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
741 0x00, 0x07, 0x1c, 0x00, 0x00, 0xf8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00};
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
742
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
743 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
744 handleGPteamplanet(pkt)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
745 struct gp_teamplanet_spacket *pkt;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
746 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
747 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
748 #define TACTICALSIZE sizeof(pkt->tactical)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
749 unsigned char tactical[TACTICALSIZE];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
750 int i;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
751 int race = pkt->teamn;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
752
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
753 if (race < -1 || race >= number_of_teams) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
754 fprintf(stderr, "race #%d out of range (-1..%d)\n", race,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
755 number_of_teams - 1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
756 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
757 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
758 for (i = 0; i < TACTICALSIZE; i++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
759 tactical[i] = (pkt->tactical[i] & pkt->tacticalM[i]) |
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
760 (planet_bits[i] & ~pkt->tacticalM[i]);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
761 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
762
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
763 W_FreeBitmap(bplanets[race + 1]);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
764 bplanets[race + 1] = W_StoreBitmap(30, 30, tactical, w);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
765
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
766 #undef TACTICALSIZE
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
767 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
768
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
769 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
770 #define GALACTICSIZE sizeof(pkt->galactic)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
771 unsigned char galactic[GALACTICSIZE];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
772 int i;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
773 int race = pkt->teamn;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
774
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
775 if (race < -1 || race >= number_of_teams) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
776 fprintf(stderr, "race #%d out of range (-1..%d)\n", race,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
777 number_of_teams - 1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
778 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
779 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
780 for (i = 0; i < GALACTICSIZE; i++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
781 galactic[i] = (pkt->galactic[i] & pkt->galacticM[i]) |
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
782 (mplanet_bits[i] & ~pkt->galacticM[i]);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
783 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
784
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
785 W_FreeBitmap(mbplanets[race + 1]);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
786 mbplanets[race + 1] = W_StoreBitmap(16, 16, galactic, mapw);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
787
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
788 #undef GALACTICSIZE
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
789 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
790 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
791
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
792 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
793 handleGameparams(pkt)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
794 struct gameparam_spacket *pkt;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
795 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
796 switch (pkt->subtype) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
797 case 0:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
798 handleGPsizes((struct gp_sizes_spacket *) pkt);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
799 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
800 case 1:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
801 handleGPteam((struct gp_team_spacket *) pkt);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
802 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
803 case 2:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
804 handleGPteamlogo((struct gp_teamlogo_spacket *) pkt);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
805 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
806 case 3:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
807 handleGPshipshape((struct gp_shipshape_spacket *) pkt);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
808 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
809 case 4:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
810 handleGPshipbitmap((struct gp_shipbitmap_spacket *) pkt);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
811 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
812 case 5:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
813 handleGPrank((struct gp_rank_spacket *) pkt);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
814 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
815 case 6:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
816 handleGProyal((struct gp_royal_spacket *) pkt);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
817 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
818 case 7:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
819 handleGPteamplanet((struct gp_teamplanet_spacket *) pkt);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
820 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
821 default:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
822 fprintf(stderr, "Gameparams packet subtype %d not yet implemented\n",
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
823 pkt->subtype);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
824 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
825 }