annotate hockey.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: hockey.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 #ifdef HOCKEY
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
4 /* code for hockey lines [BDyess] 9/14/94 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
5
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
6 #include <stdio.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
7 #include "Wlib.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
8 #include "defs.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
9 #include "struct.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
10 #include "data.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
11 #include "proto.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
12 #include "gameconf.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
13 #include "packets.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
14
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
15 void dump_hockey_points();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
16 /*void init_puck(); /* getship.c */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
17
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
18 struct player *puck;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
19
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
20 /* check to see if on a hockey server and do initialization [BDyess] */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
21 void hockeyInit() {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
22 int i,j;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
23 struct planet *l, *last;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
24 int rightmost = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
25 int leftmost = blk_gwidth;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
26 int nplan = paradise ? nplanets : 40; /* shouldn't be Paradise... */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
27 int middle = blk_gwidth / 2;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
28 int top = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
29 int bottom = blk_gwidth;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
30 int line = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
31 struct point { int x,y; } boxpoints[4];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
32 /* top-topleft, top-bottomright, bottom-topright,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
33 bottom-bottomright, {x,y} for each [BDyess] */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
34 W_Color topcolor,bottomcolor;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
35
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
36 topcolor = bottomcolor = W_Grey;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
37
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
38 /* we're playing hockey if a player named "Puck" exists in the 'g'
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
39 slot, is independant, is in a scout, and has the login name
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
40 'Robot'. [BDyess] */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
41 puck = &players['g'-'a'+10];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
42 if(!hockey) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
43 if(0 == strcmp(puck->p_name,"Puck") &&
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
44 0 == strcmp(puck->p_login,"Robot") &&
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
45 puck->p_teami < 0 &&
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
46 SCOUT == puck->p_ship->s_type) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
47
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
48 printf("Hi Puck!\n");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
49 hockey = 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
50 /*init_puck();*/
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
51 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
52 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
53 if(!hockey) /* not a hockey server, nothing more to do */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
54 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
55
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
56 if(puck->p_ship->s_type != PUCK) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
57 puck->p_ship = getship(PUCK);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
58 redrawPlayer[puck->p_no];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
59 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
60 if(tacticalHockeyLines) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
61 last = &planets[nplan];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
62 /* guess where the lines are supposed to go based on planet
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
63 location. Always draws straight lines, ie. if the border
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
64 bows out, tough - the furthest out planet will have a vertical
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
65 line through it. [BDyess] */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
66
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
67 /* first the left and rightmost lines [BDyess] */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
68 for(l = &planets[0];l < last;l++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
69 if(l->pl_x < leftmost) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
70 leftmost = l->pl_x;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
71 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
72 if(l->pl_x > rightmost) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
73 rightmost = l->pl_x;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
74 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
75 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
76 hlines[line].vertical = 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
77 hlines[line].pos = leftmost;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
78 hlines[line].end1 = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
79 hlines[line].end2 = blk_gwidth;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
80 hlines[line].color = W_Grey;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
81 line++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
82 hlines[line].vertical = 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
83 hlines[line].pos = rightmost;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
84 hlines[line].end1 = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
85 hlines[line].end2 = blk_gwidth;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
86 hlines[line].color = W_Grey;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
87 line++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
88 /* now guess the middle planet. Pick the planet closest to the
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
89 middle of the screen. [BDyess] */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
90 hlines[line].pos = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
91 for(l = &planets[0];l < last;l++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
92 if(ABS(l->pl_y - middle) < ABS(hlines[line].pos - middle))
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
93 hlines[line].pos = l->pl_y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
94 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
95 middle = hlines[line].pos;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
96 hlines[line].end1 = leftmost;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
97 hlines[line].end2 = rightmost;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
98 hlines[line].vertical = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
99 hlines[line].color = W_Red;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
100 line++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
101 /* now find the upper and lower middle lines by picking the planets
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
102 closest to the center yet still above/below the middle and inside
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
103 the left and rightmost [BDyess] */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
104 for(l = &planets[0];l < last;l++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
105 if(NOBODY == l->pl_owner) continue;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
106 if(l->pl_y > top && l->pl_y < middle &&
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
107 l->pl_x < rightmost && l->pl_x > leftmost) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
108 top = l->pl_y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
109 topcolor = planetColor(l);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
110 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
111 if(l->pl_y < bottom && l->pl_y > middle &&
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
112 l->pl_x < rightmost && l->pl_x > leftmost) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
113 bottom = l->pl_y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
114 bottomcolor = planetColor(l);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
115 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
116 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
117 hlines[line].pos = top;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
118 hlines[line].end1 = leftmost;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
119 hlines[line].end2 = rightmost;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
120 hlines[line].vertical = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
121 hlines[line].color = teamColorHockeyLines ? topcolor : W_Cyan;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
122 line++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
123 hlines[line].pos = bottom;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
124 hlines[line].end1 = leftmost;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
125 hlines[line].end2 = rightmost;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
126 hlines[line].vertical = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
127 hlines[line].color = teamColorHockeyLines ? bottomcolor : W_Cyan;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
128 line++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
129 /* last, try to find the goal box. Search for the planets that
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
130 are inside the left and right, above/below the upper/lower middle,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
131 and are not neutral. Of those planets, take the top left and
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
132 bottom right points [BDyess] */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
133 /* toplefts */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
134 boxpoints[0].x = boxpoints[0].y = boxpoints[2].x = boxpoints[2].y =
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
135 blk_gwidth;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
136 /* bottomrights */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
137 boxpoints[1].x = boxpoints[1].y = boxpoints[3].x = boxpoints[3].y = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
138 for(l = &planets[0];l < last;l++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
139 /* don't want nobody's planets */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
140 if(l->pl_owner == NOBODY) continue;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
141 /* check for out-of-bounds */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
142 if((l->pl_y >= top && l->pl_y <= bottom) ||
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
143 l->pl_x >= rightmost || l->pl_x <= leftmost) continue;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
144 /* top or bottom? */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
145 if(l->pl_y < middle) i = 0; /* top */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
146 else i = 2; /* bottom */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
147 if(l->pl_x <= boxpoints[i].x &&
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
148 l->pl_y <= boxpoints[i].y) { /* new topleft */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
149 boxpoints[i].x = l->pl_x;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
150 boxpoints[i].y = l->pl_y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
151 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
152 if(l->pl_x >= boxpoints[i+1].x &&
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
153 l->pl_y >= boxpoints[i+1].y) { /* new bottomright */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
154 boxpoints[i+1].x = l->pl_x;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
155 boxpoints[i+1].y = l->pl_y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
156 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
157 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
158 if(! teamColorHockeyLines) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
159 topcolor = bottomcolor = W_Grey;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
160 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
161 hlines[line].vertical = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
162 hlines[line].pos = boxpoints[0].y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
163 hlines[line].end1 = boxpoints[0].x;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
164 hlines[line].end2 = boxpoints[1].x;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
165 hlines[line].color = topcolor;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
166 line++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
167 hlines[line].vertical = 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
168 hlines[line].pos = boxpoints[0].x;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
169 hlines[line].end1 = boxpoints[0].y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
170 hlines[line].end2 = boxpoints[1].y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
171 hlines[line].color = topcolor;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
172 line++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
173 hlines[line].vertical = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
174 hlines[line].pos = boxpoints[1].y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
175 hlines[line].end1 = boxpoints[0].x;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
176 hlines[line].end2 = boxpoints[1].x;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
177 hlines[line].color = W_Red;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
178 line++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
179 hlines[line].vertical = 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
180 hlines[line].pos = boxpoints[1].x;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
181 hlines[line].end1 = boxpoints[0].y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
182 hlines[line].end2 = boxpoints[1].y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
183 hlines[line].color = topcolor;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
184 line++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
185
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
186 hlines[line].vertical = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
187 hlines[line].pos = boxpoints[2].y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
188 hlines[line].end1 = boxpoints[2].x;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
189 hlines[line].end2 = boxpoints[3].x;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
190 hlines[line].color = W_Red;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
191 line++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
192 hlines[line].vertical = 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
193 hlines[line].pos = boxpoints[2].x;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
194 hlines[line].end1 = boxpoints[2].y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
195 hlines[line].end2 = boxpoints[3].y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
196 hlines[line].color = bottomcolor;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
197 line++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
198 hlines[line].vertical = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
199 hlines[line].pos = boxpoints[3].y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
200 hlines[line].end1 = boxpoints[2].x;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
201 hlines[line].end2 = boxpoints[3].x;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
202 hlines[line].color = bottomcolor;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
203 line++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
204 hlines[line].vertical = 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
205 hlines[line].pos = boxpoints[3].x;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
206 hlines[line].end1 = boxpoints[2].y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
207 hlines[line].end2 = boxpoints[3].y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
208 hlines[line].color = bottomcolor;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
209 line++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
210 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
211 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
212
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
213 /* draw the tactical hockey lines [BDyess] */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
214 void tactical_hockey() {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
215 int i;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
216 struct hockeyLine *l = &hlines[0];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
217 int dx,dx1,dx2,dy,dy1,dy2;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
218 int view = SCALE * WINSIDE / 2;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
219 static int old_tacticalHockeyLines, old_galacticHockeyLines,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
220 old_cleanHockeyGalactic, old_teamColorHockeyLines;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
221
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
222 if(!hockey)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
223 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
224
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
225 if(puck->p_ship->s_type != PUCK) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
226 puck->p_ship = getship(PUCK);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
227 redrawPlayer[puck->p_no];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
228 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
229 if(tacticalHockeyLines != old_tacticalHockeyLines) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
230 redrawall = 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
231 old_tacticalHockeyLines = tacticalHockeyLines;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
232 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
233 if(galacticHockeyLines != old_galacticHockeyLines) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
234 redrawall = 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
235 old_galacticHockeyLines = galacticHockeyLines;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
236 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
237 if(cleanHockeyGalactic != old_cleanHockeyGalactic) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
238 redrawall = 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
239 old_cleanHockeyGalactic = cleanHockeyGalactic;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
240 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
241 if(teamColorHockeyLines != old_teamColorHockeyLines) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
242 old_teamColorHockeyLines = teamColorHockeyLines;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
243 hockeyInit();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
244 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
245 /* draw whatever hockey lines are visible [BDyess] */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
246 if(hockey && tacticalHockeyLines) { /* if it should be drawn */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
247 for(i = 0, l = &hlines[0]; i < NUM_HOCKEY_LINES; i++, l++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
248 if(l->vertical) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
249 dx = l->pos - me->p_x;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
250 dy1 = l->end1 - me->p_y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
251 dy2 = l->end2 - me->p_y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
252 /* is it in view? [BDyess] */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
253 if(ABS(dx) <= view &&
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
254 (ABS(dy1) <= view || ABS(dy2) <= view ||
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
255 (l->end1 <= me->p_y && l->end2 >= me->p_y))) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
256 dx = dx / SCALE + WINSIDE / 2;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
257 dy1 = dy1 / SCALE + WINSIDE / 2;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
258 dy2 = dy2 / SCALE + WINSIDE / 2;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
259 W_CacheLine(w, dx, dy1, dx, dy2, l->color);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
260 clearline[0][clearlcount] = dx;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
261 clearline[1][clearlcount] = dy1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
262 clearline[2][clearlcount] = dx;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
263 clearline[3][clearlcount] = dy2;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
264 clearlcount++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
265 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
266 } else { /* horizontal */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
267 dy = l->pos - me->p_y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
268 dx1 = l->end1 - me->p_x;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
269 dx2 = l->end2 - me->p_x;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
270 /* is it in view? [BDyess] */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
271 if(ABS(dy) <= view &&
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
272 (ABS(dx1) <= view || ABS(dx2) <= view ||
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
273 (l->end1 <= me->p_x && l->end2 >= me->p_x))) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
274 dy = dy / SCALE + WINSIDE / 2;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
275 dx1 = dx1 / SCALE + WINSIDE / 2;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
276 dx2 = dx2 / SCALE + WINSIDE / 2;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
277 W_CacheLine(w, dx1, dy, dx2, dy, l->color);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
278 clearline[0][clearlcount] = dx1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
279 clearline[1][clearlcount] = dy;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
280 clearline[2][clearlcount] = dx2;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
281 clearline[3][clearlcount] = dy;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
282 clearlcount++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
283 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
284 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
285 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
286 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
287 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
288
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
289 /* draw the tactical hockey lines [BDyess] */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
290 void galactic_hockey() {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
291 int i;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
292 struct hockeyLine *l;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
293 int dx,dx1,dx2,dy,dy1,dy2;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
294 int gwidth, offsetx, offsety;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
295
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
296 if(hockey && galacticHockeyLines) { /* if it should be drawn */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
297 if(blk_zoom) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
298 gwidth = blk_gwidth / 2;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
299 offsetx = zoom_offset(me->p_x);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
300 offsety = zoom_offset(me->p_y);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
301 /* keep last offset? */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
302 } else {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
303 gwidth = blk_gwidth;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
304 offsetx = offsety = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
305 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
306 for(i = 0, l = &hlines[0]; i < NUM_HOCKEY_LINES; i++, l++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
307 if(l->vertical) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
308 dx = (l->pos - offsetx) * WINSIDE / gwidth;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
309 dy1 = (l->end1 - offsety) * WINSIDE / gwidth;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
310 dy2 = (l->end2 - offsety) * WINSIDE / gwidth;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
311 W_MakeLine(mapw, dx, dy1, dx, dy2, l->color);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
312 } else {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
313 dy = (l->pos - offsety) * WINSIDE / gwidth;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
314 dx1 = (l->end1 - offsetx) * WINSIDE / gwidth;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
315 dx2 = (l->end2 - offsetx) * WINSIDE / gwidth;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
316 W_MakeLine(mapw, dx1, dy, dx2, dy, l->color);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
317 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
318 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
319 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
320 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
321
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
322 void dump_hockey_points() {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
323 int i;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
324 struct hockeyLine *l;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
325
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
326 printf("Hockey points dump:\n");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
327 for (i = 0, l = &hlines[0]; i < NUM_HOCKEY_LINES; i++, l++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
328 if(l->vertical) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
329 printf("%d: %d,%d %d,%d\n",i,l->pos,l->end1,l->pos,l->end2);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
330 } else {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
331 printf("%d: %d,%d %d,%d\n",i,l->end1,l->pos,l->end2,l->pos);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
332 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
333 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
334 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
335 #endif /*HOCKEY*/