Crossfire Server, Trunk  R20513
los.c
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 1999-2014 Mark Wedel and the Crossfire Development Team
5  * Copyright (c) 1992 Frank Tore Johansen
6  *
7  * Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
8  * welcome to redistribute it under certain conditions. For details, please
9  * see COPYING and LICENSE.
10  *
11  * The authors can be reached via e-mail at <crossfire@metalforge.org>.
12  */
13 
19 #include "global.h"
20 
21 #include <math.h>
22 #include <stdlib.h>
23 #include <string.h>
24 
32 #define SPACE_BLOCK 0.5
33 
34 typedef struct blstr {
35  int x[4], y[4];
36  int index;
37 } blocks;
38 
40 
41 static void expand_lighted_sight(object *op);
42 
61 static void set_block(int x, int y, int bx, int by) {
62  int index = block[x][y].index, i;
63 
64  /* Due to flipping, we may get duplicates - better safe than sorry.
65  */
66  for (i = 0; i < index; i++) {
67  if (block[x][y].x[i] == bx
68  && block[x][y].y[i] == by)
69  return;
70  }
71 
72  block[x][y].x[index] = bx;
73  block[x][y].y[index] = by;
74  block[x][y].index++;
75 #ifdef LOS_DEBUG
76  LOG(llevDebug, "setblock: added %d %d -> %d %d (%d)\n", x, y, bx, by, block[x][y].index);
77 #endif
78 }
79 
88 void init_block(void) {
89  int x, y, dx, dy, i;
90  static const int block_x[3] = {
91  -1, -1, 0
92  }, block_y[3] = {
93  -1, 0, -1
94  };
95 
96  for (x = 0; x < MAP_CLIENT_X; x++)
97  for (y = 0; y < MAP_CLIENT_Y; y++) {
98  block[x][y].index = 0;
99  }
100 
101  /* The table should be symmetric, so only do the upper left
102  * quadrant - makes the processing easier.
103  */
104  for (x = 1; x <= MAP_CLIENT_X/2; x++) {
105  for (y = 1; y <= MAP_CLIENT_Y/2; y++) {
106  for (i = 0; i < 3; i++) {
107  dx = x+block_x[i];
108  dy = y+block_y[i];
109 
110  /* center space never blocks */
111  if (x == MAP_CLIENT_X/2 && y == MAP_CLIENT_Y/2)
112  continue;
113 
114  /* If its a straight line, its blocked */
115  if ((dx == x && x == MAP_CLIENT_X/2)
116  || (dy == y && y == MAP_CLIENT_Y/2)) {
117  /* For simplicity, we mirror the coordinates to block the other
118  * quadrants.
119  */
120  set_block(x, y, dx, dy);
121  if (x == MAP_CLIENT_X/2) {
122  set_block(x, MAP_CLIENT_Y-y-1, dx, MAP_CLIENT_Y-dy-1);
123  } else if (y == MAP_CLIENT_Y/2) {
124  set_block(MAP_CLIENT_X-x-1, y, MAP_CLIENT_X-dx-1, dy);
125  }
126  } else {
127  float d1, s, l;
128 
129  /* We use the algorihm that found out how close the point
130  * (x,y) is to the line from dx,dy to the center of the viewable
131  * area. l is the distance from x,y to the line.
132  * r is more a curiosity - it lets us know what direction (left/right)
133  * the line is off
134  */
135 
136  d1 = (float)(pow(MAP_CLIENT_X/2-dx, 2)+pow(MAP_CLIENT_Y/2-dy, 2));
137  s = (float)((dy-y)*(MAP_CLIENT_X/2-dx)-(dx-x)*(MAP_CLIENT_Y/2-dy))/d1;
138  l = FABS(sqrt(d1)*s);
139 
140  if (l <= SPACE_BLOCK) {
141  /* For simplicity, we mirror the coordinates to block the other
142  * quadrants.
143  */
144  set_block(x, y, dx, dy);
145  set_block(MAP_CLIENT_X-x-1, y, MAP_CLIENT_X-dx-1, dy);
146  set_block(x, MAP_CLIENT_Y-y-1, dx, MAP_CLIENT_Y-dy-1);
147  set_block(MAP_CLIENT_X-x-1, MAP_CLIENT_Y-y-1, MAP_CLIENT_X-dx-1, MAP_CLIENT_Y-dy-1);
148  }
149  }
150  }
151  }
152  }
153 }
154 
170 static void set_wall(object *op, int x, int y) {
171  int i;
172  // Get this outside the loop -- now we can recycle x and y in the loop
173  // Trying less dereferencing for better efficiency
174  // Equivalent to &(block[x][y]), but faster.
175  const blocks * const at = block[x] + y;
176  for (i = 0; i < at->index; i++) {
177  int dx = at->x[i], dy = at->y[i];
178 
179  /* x, y are the values as adjusted to be in the
180  * socket look structure. Since the values are copied,
181  * we can safely store this in the x and y passed to the function,
182  * since they were only needed to find the element of the blocks array.
183  */
184  x = dx-(MAP_CLIENT_X-op->contr->socket.mapx)/2;
185  y = dy-(MAP_CLIENT_Y-op->contr->socket.mapy)/2;
186 
187  if (x < 0 || x >= op->contr->socket.mapx
188  || y < 0 || y >= op->contr->socket.mapy)
189  continue;
190  /* we need to adjust to the fact that the socket
191  * code wants the los to start from the 0,0
192  * and not be relative to middle of los array.
193  */
194  op->contr->blocked_los[x][y] = 100;
195  set_wall(op, dx, dy);
196  }
197 }
198 
210 static void check_wall(object *op, int x, int y) {
211  int ax, ay;
212 
213  if (!block[x][y].index)
214  return;
215 
216  /* ax, ay are coordinates as indexed into the look window */
217  ax = x-(MAP_CLIENT_X-op->contr->socket.mapx)/2;
218  ay = y-(MAP_CLIENT_Y-op->contr->socket.mapy)/2;
219 
220  /* If the converted coordinates are outside the viewable
221  * area for the client, return now.
222  */
223  if (ax < 0 || ay < 0 || ax >= op->contr->socket.mapx || ay >= op->contr->socket.mapy)
224  return;
225 
226  /* If this space is already blocked, prune the processing - presumably
227  * whatever has set this space to be blocked has done the work and already
228  * done the dependency chain.
229  */
230  if (op->contr->blocked_los[ax][ay] == 100)
231  return;
232 
233 
234  if (get_map_flags(op->map, NULL, op->x+x-MAP_CLIENT_X/2, op->y+y-MAP_CLIENT_Y/2, NULL, NULL)&(P_BLOCKSVIEW|P_OUT_OF_MAP))
235  set_wall(op, x, y);
236 }
237 
248 void clear_los(object *op) {
249  /* This is safer than using the socket->mapx, mapy because
250  * we index the blocked_los as a 2 way array, so clearing
251  * the first z spaces may not not cover the spaces we are
252  * actually going to use
253  */
254  (void)memset((void *)op->contr->blocked_los, 0, MAP_CLIENT_X*MAP_CLIENT_Y);
255 }
256 
268 static void expand_sight(object *op) {
269  int i, x, y, dx, dy;
270 
271  for (x = 1; x < op->contr->socket.mapx-1; x++) /* loop over inner squares */
272  for (y = 1; y < op->contr->socket.mapy-1; y++) {
273  if (!op->contr->blocked_los[x][y]
274  && !(get_map_flags(op->map, NULL,
275  op->x-op->contr->socket.mapx/2+x,
276  op->y-op->contr->socket.mapy/2+y,
277  NULL, NULL)&(P_BLOCKSVIEW|P_OUT_OF_MAP))) {
278  for (i = 1; i <= 8; i += 1) { /* mark all directions */
279  dx = x+freearr_x[i];
280  dy = y+freearr_y[i];
281  if (op->contr->blocked_los[dx][dy] > 0) /* for any square blocked */
282  op->contr->blocked_los[dx][dy] = -1;
283  }
284  }
285  }
286 
287  if (MAP_DARKNESS(op->map) > 0) /* player is on a dark map */
289 
290 
291  /* clear mark squares */
292  for (x = 0; x < op->contr->socket.mapx; x++)
293  for (y = 0; y < op->contr->socket.mapy; y++)
294  if (op->contr->blocked_los[x][y] < 0)
295  op->contr->blocked_los[x][y] = 0;
296 }
297 
311 int has_carried_lights(const object *op) {
312  /* op may glow! */
313  if (op->glow_radius > 0)
314  return 1;
315 
316  return 0;
317 }
318 
325 static void expand_lighted_sight(object *op) {
326  int x, y, darklevel, ax, ay, basex, basey, mflags, light, x1, y1;
327  mapstruct *m = op->map;
328  int16_t nx, ny;
329 
330  darklevel = MAP_DARKNESS(m);
331 
332  /* If the player can see in the dark, lower the darklevel for him */
333  if (QUERY_FLAG(op, FLAG_SEE_IN_DARK))
334  darklevel -= 2;
335 
336  /* add light, by finding all (non-null) nearby light sources, then
337  * mark those squares specially. If the darklevel<1, there is no
338  * reason to do this, so we skip this function
339  */
340  if (darklevel < 1)
341  return;
342 
343  /* Do a sanity check. If not valid, some code below may do odd
344  * things.
345  */
346  if (darklevel > MAX_DARKNESS) {
347  LOG(llevError, "Map darkness for %s on %s is too high (%d)\n", op->name, op->map->path, darklevel);
348  darklevel = MAX_DARKNESS;
349  }
350 
351  /* First, limit player furthest (unlighted) vision */
352  for (x = 0; x < op->contr->socket.mapx; x++)
353  for (y = 0; y < op->contr->socket.mapy; y++)
354  if (op->contr->blocked_los[x][y] != 100)
356 
357  /* the spaces[] darkness value contains the information we need.
358  * Only process the area of interest.
359  * the basex, basey values represent the position in the op->contr->blocked_los
360  * array. Its easier to just increment them here (and start with the right
361  * value) than to recalculate them down below.
362  */
363  for (x = (op->x-op->contr->socket.mapx/2-MAX_LIGHT_RADII), basex = -MAX_LIGHT_RADII;
364  x <= (op->x+op->contr->socket.mapx/2+MAX_LIGHT_RADII); x++, basex++) {
365  for (y = (op->y-op->contr->socket.mapy/2-MAX_LIGHT_RADII), basey = -MAX_LIGHT_RADII;
366  y <= (op->y+op->contr->socket.mapy/2+MAX_LIGHT_RADII); y++, basey++) {
367  m = op->map;
368  nx = x;
369  ny = y;
370 
371  mflags = get_map_flags(m, &m, nx, ny, &nx, &ny);
372 
373  if (mflags&P_OUT_OF_MAP)
374  continue;
375 
376  /* This space is providing light, so we need to brighten up the
377  * spaces around here.
378  */
379  light = GET_MAP_LIGHT(m, nx, ny);
380  if (light != 0) {
381  for (ax = basex-light; ax <= basex+light; ax++) {
382  if (ax < 0 || ax >= op->contr->socket.mapx)
383  continue;
384  for (ay = basey-light; ay <= basey+light; ay++) {
385  if (ay < 0 || ay >= op->contr->socket.mapy)
386  continue;
387 
388  /* If the space is fully blocked, do nothing. Otherwise, we
389  * brighten the space. The further the light is away from the
390  * source (basex-x), the less effect it has. Though light used
391  * to dim in a square manner, it now dims in a circular manner
392  * using the the pythagorean theorem. glow_radius still
393  * represents the radius
394  */
395  if (op->contr->blocked_los[ax][ay] != 100) {
396  x1 = abs(basex-ax)*abs(basex-ax);
397  y1 = abs(basey-ay)*abs(basey-ay);
398  if (light > 0)
399  op->contr->blocked_los[ax][ay] -= MAX((light-isqrt(x1+y1)), 0);
400  if (light < 0)
401  op->contr->blocked_los[ax][ay] -= MIN((light+isqrt(x1+y1)), 0);
402  }
403  } /* for ay */
404  } /* for ax */
405  } /* if this space is providing light */
406  } /* for y */
407  } /* for x */
408 
409  /* Outdoor should never really be completely pitch black dark like
410  * a dungeon, so let the player at least see a little around themselves
411  */
412  if (op->map->outdoor && darklevel > (MAX_DARKNESS-3)) {
413  if (op->contr->blocked_los[op->contr->socket.mapx/2][op->contr->socket.mapy/2] > (MAX_DARKNESS-3))
414  op->contr->blocked_los[op->contr->socket.mapx/2][op->contr->socket.mapy/2] = MAX_DARKNESS-3;
415 
416  for (x = -1; x <= 1; x++)
417  for (y = -1; y <= 1; y++) {
418  if (op->contr->blocked_los[x+op->contr->socket.mapx/2][y+op->contr->socket.mapy/2] > (MAX_DARKNESS-2))
419  op->contr->blocked_los[x+op->contr->socket.mapx/2][y+op->contr->socket.mapy/2] = MAX_DARKNESS-2;
420  }
421  }
422  /* grant some vision to the player, based on the darklevel */
423  for (x = darklevel-MAX_DARKNESS; x < MAX_DARKNESS+1-darklevel; x++)
424  for (y = darklevel-MAX_DARKNESS; y < MAX_DARKNESS+1-darklevel; y++)
425  if (!(op->contr->blocked_los[x+op->contr->socket.mapx/2][y+op->contr->socket.mapy/2] == 100))
426  op->contr->blocked_los[x+op->contr->socket.mapx/2][y+op->contr->socket.mapy/2] -= MAX(0, 6-darklevel-MAX(abs(x), abs(y)));
427 }
428 
438 static void blinded_sight(object *op) {
439  int x, y;
440 
441  for (x = 0; x < op->contr->socket.mapx; x++)
442  for (y = 0; y < op->contr->socket.mapy; y++)
443  op->contr->blocked_los[x][y] = 100;
444 
445  op->contr->blocked_los[op->contr->socket.mapx/2][op->contr->socket.mapy/2] = 0;
446 }
447 
455 void update_los(object *op) {
456  int dx = op->contr->socket.mapx/2, dy = op->contr->socket.mapy/2, x, y;
457 
458  if (QUERY_FLAG(op, FLAG_REMOVED))
459  return;
460 
461  clear_los(op);
462  if (QUERY_FLAG(op, FLAG_WIZ) /* || XRAYS(op) */)
463  return;
464 
465  /* For larger maps, this is more efficient than the old way which
466  * used the chaining of the block array. Since many space views could
467  * be blocked by different spaces in front, this mean that a lot of spaces
468  * could be examined multile times, as each path would be looked at.
469  */
470  for (x = (MAP_CLIENT_X-op->contr->socket.mapx)/2+1; x < (MAP_CLIENT_X+op->contr->socket.mapx)/2-1; x++)
471  for (y = (MAP_CLIENT_Y-op->contr->socket.mapy)/2+1; y < (MAP_CLIENT_Y+op->contr->socket.mapy)/2-1; y++)
472  check_wall(op, x, y);
473 
474 
475  /* do the los of the player. 3 (potential) cases */
476  if (QUERY_FLAG(op, FLAG_BLIND)) /* player is blind */
477  blinded_sight(op);
478  else
479  expand_sight(op);
480 
481  if (QUERY_FLAG(op, FLAG_XRAYS)) {
482  int x, y;
483  for (x = -2; x <= 2; x++)
484  for (y = -2; y <= 2; y++)
485  op->contr->blocked_los[dx+x][dy+y] = 0;
486  }
487 }
488 
505  player *pl;
506 
507  for (pl = first_player; pl != NULL; pl = pl->next) {
508  if (pl->ob->map == map)
509  pl->do_los = 1;
510  }
511 }
512 
532 void update_all_los(const mapstruct *map, int x, int y) {
533  player *pl;
534 
535  for (pl = first_player; pl != NULL; pl = pl->next) {
536  /* Player should not have a null map, but do this
537  * check as a safety
538  */
539  if (!pl->ob->map)
540  continue;
541 
542  /* Same map is simple case - see if pl is close enough.
543  * Note in all cases, we did the check for same map first,
544  * and then see if the player is close enough and update
545  * los if that is the case. If the player is on the
546  * corresponding map, but not close enough, then the
547  * player can't be on another map that may be closer,
548  * so by setting it up this way, we trim processing
549  * some.
550  */
551  if (pl->ob->map == map) {
552  if ((abs(pl->ob->x-x) <= pl->socket.mapx/2)
553  && (abs(pl->ob->y-y) <= pl->socket.mapy/2))
554  pl->do_los = 1;
555  }
556  /* Now we check to see if player is on adjacent
557  * maps to the one that changed and also within
558  * view. The tile_maps[] could be null, but in that
559  * case it should never match the pl->ob->map, so
560  * we want ever try to dereference any of the data in it.
561  */
562 
563  /* The logic for 0 and 3 is to see how far the player is
564  * from the edge of the map (height/width) - pl->ob->(x,y)
565  * and to add current position on this map - that gives a
566  * distance.
567  * For 1 and 2, we check to see how far the given
568  * coordinate (x,y) is from the corresponding edge,
569  * and then add the players location, which gives
570  * a distance.
571  */
572  else if (pl->ob->map == map->tile_map[0]) {
573  if ((abs(pl->ob->x-x) <= pl->socket.mapx/2)
574  && (abs(y+MAP_HEIGHT(map->tile_map[0])-pl->ob->y) <= pl->socket.mapy/2))
575  pl->do_los = 1;
576  } else if (pl->ob->map == map->tile_map[2]) {
577  if ((abs(pl->ob->x-x) <= pl->socket.mapx/2)
578  && (abs(pl->ob->y+MAP_HEIGHT(map)-y) <= pl->socket.mapy/2))
579  pl->do_los = 1;
580  } else if (pl->ob->map == map->tile_map[1]) {
581  if ((abs(pl->ob->x+MAP_WIDTH(map)-x) <= pl->socket.mapx/2)
582  && (abs(pl->ob->y-y) <= pl->socket.mapy/2))
583  pl->do_los = 1;
584  } else if (pl->ob->map == map->tile_map[3]) {
585  if ((abs(x+MAP_WIDTH(map->tile_map[3])-pl->ob->x) <= pl->socket.mapx/2)
586  && (abs(pl->ob->y-y) <= pl->socket.mapy/2))
587  pl->do_los = 1;
588  }
589  }
590 }
591 
602 void print_los(object *op) {
603  int x, y;
604  char buf[MAP_CLIENT_X*2+20], buf2[10];
605 
606  snprintf(buf, sizeof(buf), "[fixed] ");
607  for (x = 0; x < op->contr->socket.mapx; x++) {
608  snprintf(buf2, sizeof(buf2), "%2d", x);
609  strncat(buf, buf2, sizeof(buf)-strlen(buf)-1);
610  }
612  for (y = 0; y < op->contr->socket.mapy; y++) {
613  snprintf(buf, sizeof(buf), "[fixed]%2d:", y);
614  for (x = 0; x < op->contr->socket.mapx; x++) {
615  snprintf(buf2, sizeof(buf2), " %1d", op->contr->blocked_los[x][y] == 100 ? 1 : 0);
616  strncat(buf, buf2, sizeof(buf)-strlen(buf)-1);
617  }
619  }
620 }
621 
632 void make_sure_seen(const object *op) {
633  player *pl;
634 
635  for (pl = first_player; pl; pl = pl->next)
636  if (pl->ob->map == op->map
637  && pl->ob->y-pl->socket.mapy/2 <= op->y
638  && pl->ob->y+pl->socket.mapy/2 >= op->y
639  && pl->ob->x-pl->socket.mapx/2 <= op->x
640  && pl->ob->x+pl->socket.mapx/2 >= op->x)
641  pl->blocked_los[pl->socket.mapx/2+op->x-pl->ob->x][pl->socket.mapy/2+op->y-pl->ob->y] = 0;
642 }
643 
655 void make_sure_not_seen(const object *op) {
656  player *pl;
657 
658  for (pl = first_player; pl; pl = pl->next)
659  if (pl->ob->map == op->map
660  && pl->ob->y-pl->socket.mapy/2 <= op->y
661  && pl->ob->y+pl->socket.mapy/2 >= op->y
662  && pl->ob->x-pl->socket.mapx/2 <= op->x
663  && pl->ob->x+pl->socket.mapx/2 >= op->x)
664  pl->do_los = 1;
665 }
Error, serious thing.
Definition: logger.h:11
char path[HUGE_BUF]
Filename of the map.
Definition: map.h:365
One player.
Definition: player.h:92
#define FLAG_SEE_IN_DARK
if set ob not effected by darkness
Definition: define.h:338
static void blinded_sight(object *op)
Sets all veiwable squares to blocked except for the one the central one that the player occupies...
Definition: los.c:438
void init_block(void)
initialises the array used by the LOS routines.
Definition: los.c:88
static void expand_lighted_sight(object *op)
Propagate the light information.
Definition: los.c:325
#define MAX_LIGHT_RADII
Max radii for &#39;light&#39; object, really large values allow objects that can slow down the game...
Definition: define.h:466
#define FABS(x)
Decstations have trouble with fabs()...
Definition: define.h:22
struct mapdef * tile_map[4]
Adjoining maps.
Definition: map.h:364
#define MAP_HEIGHT(m)
Map height.
Definition: map.h:80
socket_struct socket
Socket information for this player.
Definition: player.h:94
short freearr_x[SIZEOFFREE]
X offset when searching around a spot.
Definition: object.c:65
#define MAX_DARKNESS
Maximum map darkness, there is no practical reason to exceed this.
Definition: define.h:470
static void expand_sight(object *op)
Goes through the array of what the given player is able to see, and expands the visible area a bit...
Definition: los.c:268
int isqrt(int n)
Compute the square root.
Definition: utils.c:585
#define MAX(x, y)
Definition: compat.h:20
void make_sure_seen(const object *op)
The object is supposed to be visible through walls, thus check if any players are nearby...
Definition: los.c:632
static void check_wall(object *op, int x, int y)
Used to initialise the array used by the LOS routines.
Definition: los.c:210
Global type definitions and header inclusions.
void draw_ext_info(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *message)
Sends message to player(s).
Definition: main.c:310
#define MIN(x, y)
Definition: compat.h:17
#define FLAG_REMOVED
Object is not in any map or invenory.
Definition: define.h:232
short freearr_y[SIZEOFFREE]
Y offset when searching around a spot.
Definition: object.c:71
Definition: los.c:34
int16_t y
Position in the map for this object.
Definition: object.h:326
#define MSG_TYPE_COMMAND
Responses to commands, eg, who.
Definition: newclient.h:379
static blocks block[MAP_CLIENT_X][MAP_CLIENT_Y]
Definition: los.c:39
#define MAP_DARKNESS(m)
Map darkness used to enforce the MAX_DARKNESS value.
Definition: map.h:75
signed short int16_t
Definition: win32.h:160
void update_all_los(const mapstruct *map, int x, int y)
This function makes sure that update_los() will be called for all players on the given map within the...
Definition: los.c:532
struct mapdef * map
Pointer to the map in which this object is present.
Definition: object.h:297
#define snprintf
Definition: win32.h:46
static void set_wall(object *op, int x, int y)
This recursively sets the blocked line of sight view.
Definition: los.c:170
static void set_block(int x, int y, int bx, int by)
What this sets is that x,y blocks the view of bx,by This then sets up a relation - for example...
Definition: los.c:61
const char * name
The name of the object, obviously...
Definition: object.h:311
#define GET_MAP_LIGHT(M, X, Y)
Gets map light.
Definition: map.h:165
#define P_OUT_OF_MAP
This space is outside the map.
Definition: map.h:251
#define SPACE_BLOCK
Distance must be less than this for the object to be blocked.
Definition: los.c:32
struct pl * contr
Pointer to the player which control this object.
Definition: object.h:276
#define FLAG_XRAYS
X-ray vision.
Definition: define.h:301
int8_t blocked_los[MAP_CLIENT_X][MAP_CLIENT_Y]
Array showing what spaces the player can see.
Definition: player.h:159
#define QUERY_FLAG(xyz, p)
Definition: define.h:225
void clear_los(object *op)
Clears/initialises the los-array associated to the player controlling the object. ...
Definition: los.c:248
#define FLAG_WIZ
Object has special privilegies.
Definition: define.h:231
#define MSG_TYPE_COMMAND_DEBUG
Various debug type commands.
Definition: newclient.h:508
int16_t x
Definition: object.h:326
uint8_t mapx
Definition: newserver.h:128
#define MAP_CLIENT_X
This determines the maximum map size the client can request (and thus what the server will send to th...
Definition: config.h:236
int y[4]
Definition: los.c:35
int x[4]
Definition: los.c:35
object * ob
The object representing the player.
Definition: player.h:158
int has_carried_lights(const object *op)
Checks if op has a light source.
Definition: los.c:311
#define MAP_CLIENT_Y
Definition: config.h:237
uint32_t outdoor
True if an outdoor map.
Definition: map.h:340
#define FLAG_BLIND
If set, object cannot see (visually)
Definition: define.h:337
void print_los(object *op)
Debug-routine which dumps the array which specifies the visible area of a player. ...
Definition: los.c:602
void update_all_map_los(mapstruct *map)
update all_map_los is like update_all_los() below, but updates everyone on the map, no matter where they are.
Definition: los.c:504
#define MAP_WIDTH(m)
Map width.
Definition: map.h:78
Only for debugging purposes.
Definition: logger.h:13
int index
Definition: los.c:36
uint32_t do_los
If true, need to call update_los() in draw(), and clear.
Definition: player.h:126
void update_los(object *op)
Recalculates the array which specifies what is visible for the given player-object.
Definition: los.c:455
EXTERN player * first_player
First player.
Definition: global.h:117
struct pl * next
Pointer to next player, NULL if this is last.
Definition: player.h:93
int8_t glow_radius
indicates the glow radius of the object
Definition: object.h:364
int get_map_flags(mapstruct *oldmap, mapstruct **newmap, int16_t x, int16_t y, int16_t *nx, int16_t *ny)
This rolls up wall, blocks_magic, blocks_view, etc, all into one function that just returns a P_...
Definition: map.c:302
#define NDI_UNIQUE
Print immediately, don&#39;t buffer.
Definition: newclient.h:245
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
Definition: logger.c:51
#define P_BLOCKSVIEW
This spot blocks the player&#39;s view.
Definition: map.h:226
This is a game-map.
Definition: map.h:325
struct blstr blocks
void make_sure_not_seen(const object *op)
The object which is supposed to be visible through walls has just been removed from the map...
Definition: los.c:655
uint8_t mapy
How large a map the client wants.
Definition: newserver.h:128