--- deliantra/server/common/los.C 2006/12/21 23:37:05 1.10 +++ deliantra/server/common/los.C 2006/12/25 14:54:44 1.14 @@ -295,7 +295,7 @@ } } - if (MAP_DARKNESS (op->map) > 0) /* player is on a dark map */ + if (op->map->darkness > 0) /* player is on a dark map */ expand_lighted_sight (op); @@ -332,7 +332,7 @@ maptile *m = op->map; sint16 nx, ny; - darklevel = MAP_DARKNESS (m); + darklevel = m->darkness; /* If the player can see in the dark, lower the darklevel for him */ if (QUERY_FLAG (op, FLAG_SEE_IN_DARK)) @@ -509,7 +509,7 @@ /* update all_map_los is like update_all_los below, * but updates everyone on the map, no matter where they - * are. This generally should not be used, as a per + * are. This generally should not be used, as a per * specific map change doesn't make much sense when tiling * is considered (lowering darkness would certainly be a * strange effect if done on a tile map, as it makes @@ -521,16 +521,11 @@ void update_all_map_los (maptile *map) { - player *pl; - - for (pl = first_player; pl != NULL; pl = pl->next) - { - if (pl->ob->map == map) - pl->do_los = 1; - } + for_all_players (pl) + if (pl->ob && pl->ob->map == map) + pl->do_los = 1; } - /* * This function makes sure that update_los() will be called for all * players on the given map within the next frame. @@ -543,18 +538,15 @@ * * map is the map that changed, x and y are the coordinates. */ - void update_all_los (const maptile *map, int x, int y) { - player *pl; - - for (pl = first_player; pl; pl = pl->next) + for_all_players (pl) { /* Player should not have a null map, but do this * check as a safety */ - if (!pl->ob->map) + if (!pl->ob || !pl->ob->map || !pl->ns) continue; /* Same map is simple case - see if pl is close enough. @@ -571,14 +563,14 @@ if ((abs (pl->ob->x - x) <= pl->ns->mapx / 2) && (abs (pl->ob->y - y) <= pl->ns->mapy / 2)) pl->do_los = 1; } + /* Now we check to see if player is on adjacent * maps to the one that changed and also within * view. The tile_maps[] could be null, but in that * case it should never match the pl->ob->map, so * we want ever try to dereference any of the data in it. - */ - - /* The logic for 0 and 3 is to see how far the player is + * + * The logic for 0 and 3 is to see how far the player is * from the edge of the map (height/width) - pl->ob->(x,y) * and to add current position on this map - that gives a * distance. @@ -589,22 +581,22 @@ */ else if (pl->ob->map == map->tile_map[0]) { - if ((abs (pl->ob->x - x) <= pl->ns->mapx / 2) && (abs (y + MAP_HEIGHT (map->tile_map[0]) - pl->ob->y) <= pl->ns->mapy / 2)) + if ((abs (pl->ob->x - x) <= pl->ns->mapx / 2) && (abs (y + map->tile_map[0]->height - pl->ob->y) <= pl->ns->mapy / 2)) pl->do_los = 1; } else if (pl->ob->map == map->tile_map[2]) { - if ((abs (pl->ob->x - x) <= pl->ns->mapx / 2) && (abs (pl->ob->y + MAP_HEIGHT (map) - y) <= pl->ns->mapy / 2)) + if ((abs (pl->ob->x - x) <= pl->ns->mapx / 2) && (abs (pl->ob->y + map->height - y) <= pl->ns->mapy / 2)) pl->do_los = 1; } else if (pl->ob->map == map->tile_map[1]) { - if ((abs (pl->ob->x + MAP_WIDTH (map) - x) <= pl->ns->mapx / 2) && (abs (pl->ob->y - y) <= pl->ns->mapy / 2)) + if ((abs (pl->ob->x + map->width - x) <= pl->ns->mapx / 2) && (abs (pl->ob->y - y) <= pl->ns->mapy / 2)) pl->do_los = 1; } else if (pl->ob->map == map->tile_map[3]) { - if ((abs (x + MAP_WIDTH (map->tile_map[3]) - pl->ob->x) <= pl->ns->mapx / 2) && (abs (pl->ob->y - y) <= pl->ns->mapy / 2)) + if ((abs (x + map->tile_map[3]->width - pl->ob->x) <= pl->ns->mapx / 2) && (abs (pl->ob->y - y) <= pl->ns->mapy / 2)) pl->do_los = 1; } } @@ -614,7 +606,6 @@ * Debug-routine which dumps the array which specifies the visible * area of a player. Triggered by the z key in DM mode. */ - void print_los (object *op) { @@ -622,20 +613,25 @@ char buf[50], buf2[10]; strcpy (buf, " "); + for (x = 0; x < op->contr->ns->mapx; x++) { sprintf (buf2, "%2d", x); strcat (buf, buf2); } + new_draw_info (NDI_UNIQUE, 0, op, buf); + for (y = 0; y < op->contr->ns->mapy; y++) { sprintf (buf, "%2d:", y); + for (x = 0; x < op->contr->ns->mapx; x++) { sprintf (buf2, " %1d", op->contr->blocked_los[x][y]); strcat (buf, buf2); } + new_draw_info (NDI_UNIQUE, 0, op, buf); } } @@ -648,9 +644,7 @@ void make_sure_seen (const object *op) { - player *pl; - - for (pl = first_player; pl; pl = pl->next) + for_all_players (pl) if (pl->ob->map == op->map && pl->ob->y - pl->ns->mapy / 2 <= op->y && pl->ob->y + pl->ns->mapy / 2 >= op->y && pl->ob->x - pl->ns->mapx / 2 <= op->x && pl->ob->x + pl->ns->mapx / 2 >= op->x) @@ -666,9 +660,7 @@ void make_sure_not_seen (const object *op) { - player *pl; - - for (pl = first_player; pl; pl = pl->next) + for_all_players (pl) if (pl->ob->map == op->map && pl->ob->y - pl->ns->mapy / 2 <= op->y && pl->ob->y + pl->ns->mapy / 2 >= op->y && pl->ob->x - pl->ns->mapx / 2 <= op->x && pl->ob->x + pl->ns->mapx / 2 >= op->x)