ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/los.C
(Generate patch)

Comparing deliantra/server/common/los.C (file contents):
Revision 1.46 by root, Tue Dec 23 00:39:48 2008 UTC vs.
Revision 1.47 by root, Tue Dec 23 01:51:27 2008 UTC

344{ 344{
345 int darklevel, mflags, light, x1, y1; 345 int darklevel, mflags, light, x1, y1;
346 maptile *m = op->map; 346 maptile *m = op->map;
347 sint16 nx, ny; 347 sint16 nx, ny;
348 348
349 darklevel = m->darkness; 349 darklevel = m->darklevel ();
350 350
351 /* If the player can see in the dark, lower the darklevel for him */ 351 /* If the player can see in the dark, lower the darklevel for him */
352 if (QUERY_FLAG (op, FLAG_SEE_IN_DARK)) 352 if (QUERY_FLAG (op, FLAG_SEE_IN_DARK))
353 darklevel -= LOS_MAX / 2; 353 darklevel -= 2;
354 354
355 /* Do a sanity check. If not valid, some code below may do odd 355 /* Do a sanity check. If not valid, some code below may do odd
356 * things. 356 * things.
357 */ 357 */
358 if (darklevel > MAX_DARKNESS) 358 if (darklevel > MAX_DARKNESS)
473 } 473 }
474 474
475 if (QUERY_FLAG (op, FLAG_XRAYS)) 475 if (QUERY_FLAG (op, FLAG_XRAYS))
476 for (int dx = -2; dx <= 2; dx++) 476 for (int dx = -2; dx <= 2; dx++)
477 for (int dy = -2; dy <= 2; dy++) 477 for (int dy = -2; dy <= 2; dy++)
478 op->contr->los[dx + LOS_X0][dy + LOS_X0] = 0; 478 min_it (op->contr->los[dx + LOS_X0][dy + LOS_X0], 1);
479} 479}
480 480
481/* update all_map_los is like update_all_los below, 481/* update all_map_los is like update_all_los below,
482 * but updates everyone on the map, no matter where they 482 * but updates everyone on the map, no matter where they
483 * are. This generally should not be used, as a per 483 * are. This generally should not be used, as a per
572 pl->do_los = 1; 572 pl->do_los = 1;
573 } 573 }
574 } 574 }
575} 575}
576 576
577static const int season_timechange[5][HOURS_PER_DAY] = {
578 /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4 5 6 7 8 9 10 11 12 13 */
579 { 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1},
580 { 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0},
581 { 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0},
582 { 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0},
583 { 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0}
584};
585
586void
587maptile::set_darkness_map ()
588{
589 timeofday_t tod;
590
591 if (!outdoor)
592 return;
593
594 get_tod (&tod);
595 darkness = 0;
596
597 for (int i = HOURS_PER_DAY / 2; i < HOURS_PER_DAY; i++)
598 change_map_light (season_timechange[tod.season][i]);
599
600 for (int i = 0; i <= tod.hour; i++)
601 change_map_light (season_timechange[tod.season][i]);
602}
603
604/*
605 * Compute the darkness level for all maps in the game. Requires the
606 * time of day as an argument.
607 */
608
609static void
610dawn_to_dusk (const timeofday_t * tod)
611{
612 /* If the light level isn't changing, no reason to do all
613 * the work below.
614 */
615 if (season_timechange[tod->season][tod->hour] == 0)
616 return;
617
618 maptile::change_all_map_light (season_timechange[tod->season][tod->hour]);
619}
620
621void
622adjust_daylight ()
623{
624 timeofday_t tod;
625
626 get_tod (&tod);
627 dawn_to_dusk (&tod);
628}
629
577/* 630/*
578 * make_sure_seen: The object is supposed to be visible through walls, thus 631 * make_sure_seen: The object is supposed to be visible through walls, thus
579 * check if any players are nearby, and edit their LOS array. 632 * check if any players are nearby, and edit their LOS array.
580 */ 633 */
581void 634void

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines