| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
#include "global.h" |
| 20 |
|
| 21 |
#include <math.h> |
| 22 |
#include <stdlib.h> |
| 23 |
#include <string.h> |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
#define SPACE_BLOCK 0.5 |
| 33 |
|
| 34 |
typedef struct blstr { |
| 35 |
int x[4], y[4]; |
| 36 |
int index; |
| 37 |
} blocks; |
| 38 |
|
| 39 |
static blocks block[MAP_CLIENT_X][MAP_CLIENT_Y]; |
| 40 |
|
| 41 |
static void expand_lighted_sight(object *op); |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
static void set_block(int x, int y, int bx, int by) { |
| 62 |
int index = block[x][y].index, i; |
| 63 |
|
| 64 |
|
| 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 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 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 |
|
| 102 |
|
| 103 |
|
| 104 |
for (x = 1; x <= MAP_CLIENT_X/2; x++) { |
| 105 |
for (y = 1; y <= MAP_CLIENT_Y/2; y++) { |
| 106 |
|
| 107 |
if (x == MAP_CLIENT_X/2 && y == MAP_CLIENT_Y/2) |
| 108 |
continue; |
| 109 |
|
| 110 |
for (i = 0; i < 3; i++) { |
| 111 |
dx = x+block_x[i]; |
| 112 |
dy = y+block_y[i]; |
| 113 |
|
| 114 |
|
| 115 |
if ((dx == x && x == MAP_CLIENT_X/2) |
| 116 |
|| (dy == y && y == MAP_CLIENT_Y/2)) { |
| 117 |
|
| 118 |
|
| 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 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 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 |
|
| 142 |
|
| 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 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
static void set_wall(player *pl, int x, int y) { |
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
const blocks * const at = block[x] + y; |
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
const int map_sock_x = (MAP_CLIENT_X-pl->socket.mapx)>>1, |
| 180 |
map_sock_y = (MAP_CLIENT_Y-pl->socket.mapy)>>1; |
| 181 |
for (int i = 0; i < at->index; i++) { |
| 182 |
int dx = at->x[i], dy = at->y[i]; |
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
x = dx-map_sock_x; |
| 190 |
y = dy-map_sock_y; |
| 191 |
|
| 192 |
if (x < 0 || x >= pl->socket.mapx |
| 193 |
|| y < 0 || y >= pl->socket.mapy |
| 194 |
|
| 195 |
|| pl->blocked_los[x][y] == 100) |
| 196 |
continue; |
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
pl->blocked_los[x][y] = 100; |
| 202 |
set_wall(pl, dx, dy); |
| 203 |
} |
| 204 |
} |
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
static void check_wall(object *op, int x, int y) { |
| 218 |
int ax, ay; |
| 219 |
|
| 220 |
if (!block[x][y].index) |
| 221 |
return; |
| 222 |
|
| 223 |
|
| 224 |
ax = x-(MAP_CLIENT_X-op->contr->socket.mapx)/2; |
| 225 |
ay = y-(MAP_CLIENT_Y-op->contr->socket.mapy)/2; |
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
if (ax < 0 || ay < 0 || ax >= op->contr->socket.mapx || ay >= op->contr->socket.mapy) |
| 231 |
return; |
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
if (op->contr->blocked_los[ax][ay] == 100) |
| 238 |
return; |
| 239 |
|
| 240 |
|
| 241 |
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)) |
| 242 |
set_wall(op->contr, x, y); |
| 243 |
} |
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
void clear_los(player *pl) { |
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
(void)memset((void *)pl->blocked_los, 0, MAP_CLIENT_X*MAP_CLIENT_Y); |
| 259 |
} |
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
static void expand_sight(object *op) { |
| 273 |
int i, x, y, dx, dy; |
| 274 |
|
| 275 |
for (x = 1; x < op->contr->socket.mapx-1; x++) |
| 276 |
for (y = 1; y < op->contr->socket.mapy-1; y++) { |
| 277 |
if (!op->contr->blocked_los[x][y] |
| 278 |
&& !(get_map_flags(op->map, NULL, |
| 279 |
op->x-op->contr->socket.mapx/2+x, |
| 280 |
op->y-op->contr->socket.mapy/2+y, |
| 281 |
NULL, NULL)&(P_BLOCKSVIEW|P_OUT_OF_MAP))) { |
| 282 |
for (i = 1; i <= 8; i += 1) { |
| 283 |
dx = x+freearr_x[i]; |
| 284 |
dy = y+freearr_y[i]; |
| 285 |
if (op->contr->blocked_los[dx][dy] > 0) |
| 286 |
op->contr->blocked_los[dx][dy] = -1; |
| 287 |
} |
| 288 |
} |
| 289 |
} |
| 290 |
|
| 291 |
if (MAP_DARKNESS(op->map) > 0) |
| 292 |
expand_lighted_sight(op); |
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
for (x = 0; x < op->contr->socket.mapx; x++) |
| 297 |
for (y = 0; y < op->contr->socket.mapy; y++) |
| 298 |
if (op->contr->blocked_los[x][y] < 0) |
| 299 |
op->contr->blocked_los[x][y] = 0; |
| 300 |
} |
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
|
| 309 |
|
| 310 |
|
| 311 |
|
| 312 |
|
| 313 |
|
| 314 |
|
| 315 |
int has_carried_lights(const object *op) { |
| 316 |
|
| 317 |
if (op->glow_radius > 0) |
| 318 |
return 1; |
| 319 |
|
| 320 |
return 0; |
| 321 |
} |
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
static void expand_lighted_sight(object *op) { |
| 330 |
int x, y, darklevel, ax, ay, basex, basey, mflags, light, x1, y1; |
| 331 |
mapstruct *m = op->map; |
| 332 |
int16_t nx, ny; |
| 333 |
|
| 334 |
darklevel = MAP_DARKNESS(m); |
| 335 |
|
| 336 |
|
| 337 |
if (QUERY_FLAG(op, FLAG_SEE_IN_DARK)) |
| 338 |
darklevel -= 2; |
| 339 |
|
| 340 |
|
| 341 |
|
| 342 |
|
| 343 |
|
| 344 |
if (darklevel < 1) |
| 345 |
return; |
| 346 |
|
| 347 |
|
| 348 |
|
| 349 |
|
| 350 |
if (darklevel > MAX_DARKNESS) { |
| 351 |
LOG(llevError, "Map darkness for %s on %s is too high (%d)\n", op->name, op->map->path, darklevel); |
| 352 |
darklevel = MAX_DARKNESS; |
| 353 |
} |
| 354 |
|
| 355 |
|
| 356 |
for (x = 0; x < op->contr->socket.mapx; x++) |
| 357 |
for (y = 0; y < op->contr->socket.mapy; y++) |
| 358 |
if (op->contr->blocked_los[x][y] != 100) |
| 359 |
op->contr->blocked_los[x][y] = MAX_LIGHT_RADII; |
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
for (x = (op->x-op->contr->socket.mapx/2-MAX_LIGHT_RADII), basex = -MAX_LIGHT_RADII; |
| 368 |
x <= (op->x+op->contr->socket.mapx/2+MAX_LIGHT_RADII); x++, basex++) { |
| 369 |
for (y = (op->y-op->contr->socket.mapy/2-MAX_LIGHT_RADII), basey = -MAX_LIGHT_RADII; |
| 370 |
y <= (op->y+op->contr->socket.mapy/2+MAX_LIGHT_RADII); y++, basey++) { |
| 371 |
m = op->map; |
| 372 |
nx = x; |
| 373 |
ny = y; |
| 374 |
|
| 375 |
mflags = get_map_flags(m, &m, nx, ny, &nx, &ny); |
| 376 |
|
| 377 |
if (mflags&P_OUT_OF_MAP) |
| 378 |
continue; |
| 379 |
|
| 380 |
|
| 381 |
|
| 382 |
|
| 383 |
light = GET_MAP_LIGHT(m, nx, ny); |
| 384 |
if (light != 0) { |
| 385 |
for (ax = basex-light; ax <= basex+light; ax++) { |
| 386 |
if (ax < 0 || ax >= op->contr->socket.mapx) |
| 387 |
continue; |
| 388 |
for (ay = basey-light; ay <= basey+light; ay++) { |
| 389 |
if (ay < 0 || ay >= op->contr->socket.mapy) |
| 390 |
continue; |
| 391 |
|
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
|
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
if (op->contr->blocked_los[ax][ay] != 100) { |
| 400 |
x1 = abs(basex-ax)*abs(basex-ax); |
| 401 |
y1 = abs(basey-ay)*abs(basey-ay); |
| 402 |
if (light > 0) |
| 403 |
op->contr->blocked_los[ax][ay] -= MAX((light-isqrt(x1+y1)), 0); |
| 404 |
if (light < 0) |
| 405 |
op->contr->blocked_los[ax][ay] -= MIN((light+isqrt(x1+y1)), 0); |
| 406 |
} |
| 407 |
} |
| 408 |
} |
| 409 |
} |
| 410 |
} |
| 411 |
} |
| 412 |
|
| 413 |
|
| 414 |
|
| 415 |
|
| 416 |
if (op->map->outdoor && darklevel > (MAX_DARKNESS-3)) { |
| 417 |
if (op->contr->blocked_los[op->contr->socket.mapx/2][op->contr->socket.mapy/2] > (MAX_DARKNESS-3)) |
| 418 |
op->contr->blocked_los[op->contr->socket.mapx/2][op->contr->socket.mapy/2] = MAX_DARKNESS-3; |
| 419 |
|
| 420 |
for (x = -1; x <= 1; x++) |
| 421 |
for (y = -1; y <= 1; y++) { |
| 422 |
if (op->contr->blocked_los[x+op->contr->socket.mapx/2][y+op->contr->socket.mapy/2] > (MAX_DARKNESS-2)) |
| 423 |
op->contr->blocked_los[x+op->contr->socket.mapx/2][y+op->contr->socket.mapy/2] = MAX_DARKNESS-2; |
| 424 |
} |
| 425 |
} |
| 426 |
|
| 427 |
for (x = darklevel-MAX_DARKNESS; x < MAX_DARKNESS+1-darklevel; x++) |
| 428 |
for (y = darklevel-MAX_DARKNESS; y < MAX_DARKNESS+1-darklevel; y++) |
| 429 |
if (!(op->contr->blocked_los[x+op->contr->socket.mapx/2][y+op->contr->socket.mapy/2] == 100)) |
| 430 |
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))); |
| 431 |
} |
| 432 |
|
| 433 |
|
| 434 |
|
| 435 |
|
| 436 |
|
| 437 |
|
| 438 |
|
| 439 |
|
| 440 |
|
| 441 |
|
| 442 |
static void blinded_sight(player *pl) { |
| 443 |
int x, y; |
| 444 |
|
| 445 |
for (x = 0; x < pl->socket.mapx; x++) |
| 446 |
for (y = 0; y < pl->socket.mapy; y++) |
| 447 |
pl->blocked_los[x][y] = 100; |
| 448 |
|
| 449 |
pl->blocked_los[pl->socket.mapx/2][pl->socket.mapy/2] = 0; |
| 450 |
} |
| 451 |
|
| 452 |
|
| 453 |
|
| 454 |
|
| 455 |
|
| 456 |
|
| 457 |
|
| 458 |
|
| 459 |
void update_los(object *op) { |
| 460 |
int dx = op->contr->socket.mapx/2, dy = op->contr->socket.mapy/2, x, y; |
| 461 |
|
| 462 |
if (QUERY_FLAG(op, FLAG_REMOVED)) |
| 463 |
return; |
| 464 |
|
| 465 |
clear_los(op->contr); |
| 466 |
if (QUERY_FLAG(op, FLAG_WIZ) ) |
| 467 |
return; |
| 468 |
|
| 469 |
|
| 470 |
|
| 471 |
|
| 472 |
|
| 473 |
|
| 474 |
for (x = (MAP_CLIENT_X-op->contr->socket.mapx)/2+1; x < (MAP_CLIENT_X+op->contr->socket.mapx)/2-1; x++) |
| 475 |
for (y = (MAP_CLIENT_Y-op->contr->socket.mapy)/2+1; y < (MAP_CLIENT_Y+op->contr->socket.mapy)/2-1; y++) |
| 476 |
check_wall(op, x, y); |
| 477 |
|
| 478 |
|
| 479 |
|
| 480 |
if (QUERY_FLAG(op, FLAG_BLIND)) |
| 481 |
blinded_sight(op->contr); |
| 482 |
else |
| 483 |
expand_sight(op); |
| 484 |
|
| 485 |
if (QUERY_FLAG(op, FLAG_XRAYS)) { |
| 486 |
int x, y; |
| 487 |
for (x = -2; x <= 2; x++) |
| 488 |
for (y = -2; y <= 2; y++) |
| 489 |
op->contr->blocked_los[dx+x][dy+y] = 0; |
| 490 |
} |
| 491 |
} |
| 492 |
|
| 493 |
|
| 494 |
|
| 495 |
|
| 496 |
|
| 497 |
|
| 498 |
|
| 499 |
|
| 500 |
|
| 501 |
|
| 502 |
|
| 503 |
|
| 504 |
|
| 505 |
|
| 506 |
|
| 507 |
|
| 508 |
void update_all_map_los(mapstruct *map) { |
| 509 |
player *pl; |
| 510 |
|
| 511 |
for (pl = first_player; pl != NULL; pl = pl->next) { |
| 512 |
if (pl->ob->map == map) |
| 513 |
pl->do_los = 1; |
| 514 |
} |
| 515 |
} |
| 516 |
|
| 517 |
|
| 518 |
|
| 519 |
|
| 520 |
|
| 521 |
|
| 522 |
|
| 523 |
|
| 524 |
|
| 525 |
|
| 526 |
|
| 527 |
|
| 528 |
|
| 529 |
|
| 530 |
|
| 531 |
|
| 532 |
|
| 533 |
|
| 534 |
|
| 535 |
|
| 536 |
void update_all_los(const mapstruct *map, int x, int y) { |
| 537 |
player *pl; |
| 538 |
|
| 539 |
for (pl = first_player; pl != NULL; pl = pl->next) { |
| 540 |
|
| 541 |
|
| 542 |
|
| 543 |
if (!pl->ob->map) |
| 544 |
continue; |
| 545 |
|
| 546 |
|
| 547 |
|
| 548 |
|
| 549 |
|
| 550 |
|
| 551 |
|
| 552 |
|
| 553 |
|
| 554 |
|
| 555 |
if (pl->ob->map == map) { |
| 556 |
if ((abs(pl->ob->x-x) <= pl->socket.mapx/2) |
| 557 |
&& (abs(pl->ob->y-y) <= pl->socket.mapy/2)) |
| 558 |
pl->do_los = 1; |
| 559 |
} |
| 560 |
|
| 561 |
|
| 562 |
|
| 563 |
|
| 564 |
|
| 565 |
|
| 566 |
|
| 567 |
|
| 568 |
|
| 569 |
|
| 570 |
|
| 571 |
|
| 572 |
|
| 573 |
|
| 574 |
|
| 575 |
|
| 576 |
else if (pl->ob->map == map->tile_map[0]) { |
| 577 |
if ((abs(pl->ob->x-x) <= pl->socket.mapx/2) |
| 578 |
&& (abs(y+MAP_HEIGHT(map->tile_map[0])-pl->ob->y) <= pl->socket.mapy/2)) |
| 579 |
pl->do_los = 1; |
| 580 |
} else if (pl->ob->map == map->tile_map[2]) { |
| 581 |
if ((abs(pl->ob->x-x) <= pl->socket.mapx/2) |
| 582 |
&& (abs(pl->ob->y+MAP_HEIGHT(map)-y) <= pl->socket.mapy/2)) |
| 583 |
pl->do_los = 1; |
| 584 |
} else if (pl->ob->map == map->tile_map[1]) { |
| 585 |
if ((abs(pl->ob->x+MAP_WIDTH(map)-x) <= pl->socket.mapx/2) |
| 586 |
&& (abs(pl->ob->y-y) <= pl->socket.mapy/2)) |
| 587 |
pl->do_los = 1; |
| 588 |
} else if (pl->ob->map == map->tile_map[3]) { |
| 589 |
if ((abs(x+MAP_WIDTH(map->tile_map[3])-pl->ob->x) <= pl->socket.mapx/2) |
| 590 |
&& (abs(pl->ob->y-y) <= pl->socket.mapy/2)) |
| 591 |
pl->do_los = 1; |
| 592 |
} |
| 593 |
} |
| 594 |
} |
| 595 |
|
| 596 |
|
| 597 |
|
| 598 |
|
| 599 |
|
| 600 |
|
| 601 |
|
| 602 |
|
| 603 |
|
| 604 |
|
| 605 |
|
| 606 |
void print_los(object *op) { |
| 607 |
int x, y; |
| 608 |
char buf[MAP_CLIENT_X*2+20], buf2[10]; |
| 609 |
|
| 610 |
snprintf(buf, sizeof(buf), "[fixed] "); |
| 611 |
for (x = 0; x < op->contr->socket.mapx; x++) { |
| 612 |
snprintf(buf2, sizeof(buf2), "%2d", x); |
| 613 |
strncat(buf, buf2, sizeof(buf)-strlen(buf)-1); |
| 614 |
} |
| 615 |
draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_DEBUG, buf); |
| 616 |
for (y = 0; y < op->contr->socket.mapy; y++) { |
| 617 |
snprintf(buf, sizeof(buf), "[fixed]%2d:", y); |
| 618 |
for (x = 0; x < op->contr->socket.mapx; x++) { |
| 619 |
snprintf(buf2, sizeof(buf2), " %1d", op->contr->blocked_los[x][y] == 100 ? 1 : 0); |
| 620 |
strncat(buf, buf2, sizeof(buf)-strlen(buf)-1); |
| 621 |
} |
| 622 |
draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_DEBUG, buf); |
| 623 |
} |
| 624 |
} |
| 625 |
|
| 626 |
|
| 627 |
|
| 628 |
|
| 629 |
|
| 630 |
|
| 631 |
|
| 632 |
|
| 633 |
|
| 634 |
|
| 635 |
|
| 636 |
void make_sure_seen(const object *op) { |
| 637 |
player *pl; |
| 638 |
|
| 639 |
for (pl = first_player; pl; pl = pl->next) |
| 640 |
if (pl->ob->map == op->map |
| 641 |
&& pl->ob->y-pl->socket.mapy/2 <= op->y |
| 642 |
&& pl->ob->y+pl->socket.mapy/2 >= op->y |
| 643 |
&& pl->ob->x-pl->socket.mapx/2 <= op->x |
| 644 |
&& pl->ob->x+pl->socket.mapx/2 >= op->x) |
| 645 |
pl->blocked_los[pl->socket.mapx/2+op->x-pl->ob->x][pl->socket.mapy/2+op->y-pl->ob->y] = 0; |
| 646 |
} |
| 647 |
|
| 648 |
|
| 649 |
|
| 650 |
|
| 651 |
|
| 652 |
|
| 653 |
|
| 654 |
|
| 655 |
|
| 656 |
|
| 657 |
|
| 658 |
|
| 659 |
void make_sure_not_seen(const object *op) { |
| 660 |
player *pl; |
| 661 |
|
| 662 |
for (pl = first_player; pl; pl = pl->next) |
| 663 |
if (pl->ob->map == op->map |
| 664 |
&& pl->ob->y-pl->socket.mapy/2 <= op->y |
| 665 |
&& pl->ob->y+pl->socket.mapy/2 >= op->y |
| 666 |
&& pl->ob->x-pl->socket.mapx/2 <= op->x |
| 667 |
&& pl->ob->x+pl->socket.mapx/2 >= op->x) |
| 668 |
pl->do_los = 1; |
| 669 |
} |