version 1.2 | | version 1.3 |
---|
| | |
/* | | /* |
* static char *rcsid_socki0_c = | | * static char *rcsid_socki0_c = |
* "$Id: info.c,v 1.2 1999/07/13 06:03:06 cvs Exp $"; | | * "$Id: info.c,v 1.3 2001/06/04 06:41:02 mwedel Exp $"; |
*/ | | */ |
| | |
/* This file implements some of the simpler output functions to the | | /* This file implements some of the simpler output functions to the |
| | |
{ | | { |
int x, y; | | int x, y; |
int xmin = pl->x - strength + 1 < 0 ? 0 : pl->x - strength + 1; | | int xmin = pl->x - strength + 1 < 0 ? 0 : pl->x - strength + 1; |
int xmax = pl->x + strength - 1 > pl->map->mapx - 1 ? | | int xmax = pl->x + strength - 1 > pl->map->map_object->x - 1 ? |
pl->map->mapx - 1 : pl->x + strength - 1; | | pl->map->map_object->x - 1 : pl->x + strength - 1; |
int ymin = pl->y - strength + 1 < 0 ? 0 : pl->y - strength + 1; | | int ymin = pl->y - strength + 1 < 0 ? 0 : pl->y - strength + 1; |
int ymax = pl->y + strength - 1 > pl->map->mapy - 1 ? | | int ymax = pl->y + strength - 1 > pl->map->map_object->y - 1 ? |
pl->map->mapy - 1 : pl->y + strength - 1; | | pl->map->map_object->y - 1 : pl->y + strength - 1; |
| | |
for (x = xmin; x <= xmax; x++) { | | for (x = xmin; x <= xmax; x++) { |
for (y = ymin; y <= ymax; y++) { | | for (y = ymin; y <= ymax; y++) { |
if (wall(pl->map, x, y) || blocks_view(pl->map, x, y)) | | if (wall(pl->map, x, y) || blocks_view(pl->map, x, y)) |
map_mark[x + pl->map->mapx * y] = 2; | | map_mark[x + pl->map->map_object->x * y] = 2; |
else { | | else { |
map_mark[x + pl->map->mapx * y] = 1; | | map_mark[x + pl->map->map_object->x * y] = 1; |
magic_mapping_mark_recursive(pl, map_mark, x, y); | | magic_mapping_mark_recursive(pl, map_mark, x, y); |
} | | } |
} | | } |
| | |
for (dy = -1; dy <= 1; dy++) { | | for (dy = -1; dy <= 1; dy++) { |
x = px + dx; | | x = px + dx; |
y = py + dy; | | y = py + dy; |
if (x >= 0 && x < pl->map->mapx && y >= 0 && y < pl->map->mapy | | if (x >= 0 && x < pl->map->map_object->x && y >= 0 && y < pl->map->map_object->y |
&& (map_mark[x + pl->map->mapx * y] ==0) ) { | | && (map_mark[x + pl->map->map_object->x * y] ==0) ) { |
if (blocks_view(pl->map, x, y)) | | if (blocks_view(pl->map, x, y)) |
map_mark[x + pl->map->mapx * y] = 2; | | map_mark[x + pl->map->map_object->x * y] = 2; |
else { | | else { |
if (wall(pl->map, x, y)) | | if (wall(pl->map, x, y)) |
map_mark[x + pl->map->mapx * y] = 2; | | map_mark[x + pl->map->map_object->x * y] = 2; |
else | | else |
map_mark[x + pl->map->mapx * y] = 1; | | map_mark[x + pl->map->map_object->x * y] = 1; |
magic_mapping_mark_recursive(pl, map_mark, x, y); | | magic_mapping_mark_recursive(pl, map_mark, x, y); |
} | | } |
} | | } |
| | |
void draw_map(object *pl) | | void draw_map(object *pl) |
{ | | { |
int x,y; | | int x,y; |
char *map_mark = (char *) malloc(pl->map->mapx * pl->map->mapy); | | char *map_mark = (char *) malloc(pl->map->map_object->x * pl->map->map_object->y); |
int xmin = pl->map->mapx, xmax = 0, ymin = pl->map->mapy, ymax = 0; | | int xmin = pl->map->map_object->x, xmax = 0, ymin = pl->map->map_object->y, ymax = 0; |
SockList sl; | | SockList sl; |
| | |
if (pl->type!=PLAYER) { | | if (pl->type!=PLAYER) { |
| | |
return; | | return; |
} | | } |
/* First, we figure out what spaces are 'reachable' by the player */ | | /* First, we figure out what spaces are 'reachable' by the player */ |
memset(map_mark, 0, pl->map->mapx * pl->map->mapy); | | memset(map_mark, 0, pl->map->map_object->x * pl->map->map_object->y); |
magic_mapping_mark(pl, map_mark, 3); | | magic_mapping_mark(pl, map_mark, 3); |
for(x = 0; x < pl->map->mapx; x++) { | | for(x = 0; x < pl->map->map_object->x; x++) { |
for(y = 0; y < pl->map->mapy; y++) { | | for(y = 0; y < pl->map->map_object->y; y++) { |
if (map_mark[x + pl->map->mapx * y]==1) { | | if (map_mark[x + pl->map->map_object->x * y]==1) { |
xmin = x < xmin ? x : xmin; | | xmin = x < xmin ? x : xmin; |
xmax = x > xmax ? x : xmax; | | xmax = x > xmax ? x : xmax; |
ymin = y < ymin ? y : ymin; | | ymin = y < ymin ? y : ymin; |
| | |
xmin--; | | xmin--; |
xmin = xmin < 0 ? 0 : xmin; | | xmin = xmin < 0 ? 0 : xmin; |
xmax++; | | xmax++; |
xmax = xmax > pl->map->mapx - 1 ? pl->map->mapx - 1: xmax; | | xmax = xmax > pl->map->map_object->x - 1 ? pl->map->map_object->x - 1: xmax; |
ymin--; | | ymin--; |
ymin = ymin < 0 ? 0 : ymin; | | ymin = ymin < 0 ? 0 : ymin; |
ymax++; | | ymax++; |
ymax = ymax > pl->map->mapy - 1? pl->map->mapy - 1: ymax; | | ymax = ymax > pl->map->map_object->y - 1? pl->map->map_object->y - 1: ymax; |
| | |
| | |
sl.buf=malloc(MAXSOCKBUF); | | sl.buf=malloc(MAXSOCKBUF); |
| | |
for (x = xmin; x <= xmax; x++) { | | for (x = xmin; x <= xmax; x++) { |
int mark; | | int mark; |
| | |
if ((mark=map_mark[x+pl->map->mapx*y])==0) | | if ((mark=map_mark[x+pl->map->map_object->x*y])==0) |
sl.buf[sl.len++]=0; | | sl.buf[sl.len++]=0; |
else { | | else { |
New_Face *f = get_map(pl->map, x, y)->face; | | New_Face *f = get_map(pl->map, x, y)->face; |