2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
23 * related information and legal notices. It is expected that any future
24 * projects/authors will amend these files as needed.
28 * getbit.c: Replaces old bitmap code
30 * Known contributors to this file:
40 #include "prototypes.h"
43 #define GCFx(x) ((x + WORLD_X) % WORLD_X)
44 #define GCFy(y) ((y + WORLD_Y) % WORLD_Y)
47 emp_getbit(int x, int y, u_char *bitmap)
51 id = (GCFy(y)) * WORLD_X/2 + GCFx(x)/2;
52 return bitmap[id / 8] & bit(id & 07);
56 emp_setbit(int x, int y, u_char *bitmap)
60 id = (GCFy(y)) * WORLD_X/2 + GCFx(x)/2;
61 bitmap[id / 8] |= bit(id & 07);
65 emp_setbitmap(register int x, register int y, register u_char *bitmap, int *bitmaps)
71 for (mp = bitmaps; *mp != 9999; ) {
74 id = (GCFy(dy)) * WORLD_X/2 + GCFx(dx)/2;
75 bitmap[id / 8] |= bit(id & 07);
81 * if we're not player->god, we have to set up the bitmaps
82 * correctly for the owned sectors. If we are player->god,
83 * forego all this (expensive) nonsense!
86 emp_bitinit(struct nstr_sect *np, u_char *bitmap)
88 extern int *bitmaps[];
92 while (nxtsct(np, §)) {
95 eff = sect.sct_effic / 20;
98 emp_setbitmap(np->x, np->y, bitmap, bitmaps[eff]);
105 * the bit offsets for each bit pattern based on the efficiency of
115 #define bitoff(x, y) x, y
118 bitoff(-1,-1), bitoff(1,-1),
119 bitoff(-2,0), bitoff(0,0), bitoff(2,0),
120 bitoff(-1,1), bitoff(1,1),
126 bitoff(-3,-1), bitoff(-1,-1), bitoff(1,-1), bitoff(3,-1),
127 bitoff(-2,0), bitoff(0,0), bitoff(2,0),
128 bitoff(-3,1), bitoff(-1,1), bitoff(1,1), bitoff(3,1),
134 bitoff(-2,-2), bitoff(0,-2), bitoff(2,-2),
135 bitoff(-3,-1), bitoff(-1,-1), bitoff(1,-1), bitoff(3,-1),
136 bitoff(-4,0), bitoff(-2,0), bitoff(0,0), bitoff(2,0), bitoff(4,0),
137 bitoff(-3,1), bitoff(-1,1), bitoff(1,1), bitoff(3,1),
138 bitoff(-2,2), bitoff(0,2), bitoff(2,2),
143 bitoff(-1,-3), bitoff(1,-3),
144 bitoff(-4,-2), bitoff(-2,-2), bitoff(0,-2), bitoff(2,-2), bitoff(4,-2),
145 bitoff(-5,-1), bitoff(-3,-1), bitoff(-1,-1), bitoff(1,-1),
146 bitoff(3,-1), bitoff(5,-1),
147 bitoff(-4,0), bitoff(-2,0), bitoff(0,0), bitoff(2,0), bitoff(4,0),
148 bitoff(-5,1), bitoff(-3,1), bitoff(-1,1), bitoff(1,1),
149 bitoff(3,1), bitoff(5,1),
150 bitoff(-4,2), bitoff(-2,2), bitoff(0,2), bitoff(2,2), bitoff(4,2),
151 bitoff(-1,3), bitoff(1,3),
156 bitoff(-3,-3), bitoff(-1,-3), bitoff(1,-3), bitoff(3,-3),
157 bitoff(-4,-2), bitoff(-2,-2), bitoff(0,-2), bitoff(2,-2), bitoff(4,-2),
158 bitoff(-5,-1), bitoff(-3,-1), bitoff(-1,-1), bitoff(1,-1),
159 bitoff(3,-1), bitoff(5,-1),
160 bitoff(-6,0), bitoff(-4,0), bitoff(-2,0), bitoff(0,0), bitoff(2,0),
161 bitoff(4,0), bitoff(6,0),
162 bitoff(-5,1), bitoff(-3,1), bitoff(-1,1), bitoff(1,1),
163 bitoff(3,1), bitoff(5,1),
164 bitoff(-4,2), bitoff(-2,2), bitoff(0,2), bitoff(2,2), bitoff(4,2),
165 bitoff(-3,3), bitoff(-1,3), bitoff(1,3), bitoff(3, 3),