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.50 by root, Tue Dec 23 22:04:17 2008 UTC vs.
Revision 1.51 by root, Wed Dec 24 01:37:23 2008 UTC

22 */ 22 */
23 23
24#include <global.h> 24#include <global.h>
25#include <cmath> 25#include <cmath>
26 26
27#define SEE_IN_DARK_RADIUS 3
28
27// los flags 29// los flags
28enum { 30enum {
29 FLG_XI = 0x01, // we have an x-parent 31 FLG_XI = 0x01, // we have an x-parent
30 FLG_YI = 0x02, // we have an y-parent 32 FLG_YI = 0x02, // we have an y-parent
31 FLG_BLOCKED = 0x04, // this space blocks the view 33 FLG_BLOCKED = 0x04, // this space blocks the view
280 return 0; 282 return 0;
281} 283}
282 284
283/* radius, distance => lightness adjust */ 285/* radius, distance => lightness adjust */
284static sint8 light_atten[MAX_LIGHT_RADIUS * 2 + 1][MAX_LIGHT_RADIUS * 3 / 2 + 1]; 286static sint8 light_atten[MAX_LIGHT_RADIUS * 2 + 1][MAX_LIGHT_RADIUS * 3 / 2 + 1];
285static sint8 vision_atten[MAX_DARKNESS + 1][MAX_DARKNESS * 3 / 2 + 1]; 287static sint8 vision_atten[MAX_DARKNESS + SEE_IN_DARK_RADIUS + 1][(MAX_DARKNESS + SEE_IN_DARK_RADIUS) * 3 / 2 + 1];
286 288
287static struct los_init 289static struct los_init
288{ 290{
289 los_init () 291 los_init ()
290 { 292 {
305 ? min (3, intensity) 307 ? min (3, intensity)
306 : LOS_MAX - intensity; 308 : LOS_MAX - intensity;
307 } 309 }
308 310
309 /* for general vision */ 311 /* for general vision */
310 for (int radius = 0; radius <= MAX_DARKNESS; ++radius) 312 for (int radius = 0; radius <= MAX_DARKNESS + SEE_IN_DARK_RADIUS; ++radius)
311 for (int distance = 0; distance <= MAX_DARKNESS * 3 / 2; ++distance) 313 for (int distance = 0; distance <= (MAX_DARKNESS + SEE_IN_DARK_RADIUS) * 3 / 2; ++distance)
312 {
313 vision_atten [radius][distance] = distance <= radius ? 3 : 4; 314 vision_atten [radius][distance] = distance <= radius ? 3 : 4;
314 }
315 } 315 }
316} los_init; 316} los_init;
317 317
318sint8 318sint8
319los_brighten (sint8 b, sint8 l) 319los_brighten (sint8 b, sint8 l)
355static void 355static void
356apply_lights (player *pl) 356apply_lights (player *pl)
357{ 357{
358 object *op = pl->observe; 358 object *op = pl->observe;
359 int darklevel = op->map->darklevel (); 359 int darklevel = op->map->darklevel ();
360
361 /* If the player can see in the dark, lower the darklevel for him */
362 if (op->flag [FLAG_SEE_IN_DARK])
363 darklevel = max (0, darklevel - 2);
364 360
365 int half_x = pl->ns->mapx / 2; 361 int half_x = pl->ns->mapx / 2;
366 int half_y = pl->ns->mapy / 2; 362 int half_y = pl->ns->mapy / 2;
367 363
368 int pass2 = 0; // negative lights have an extra pass 364 int pass2 = 0; // negative lights have an extra pass
398 rectangular_mapspace_iterate_end 394 rectangular_mapspace_iterate_end
399 395
400 /* grant some vision to the player, based on the darklevel */ 396 /* grant some vision to the player, based on the darklevel */
401 { 397 {
402 int light = clamp (MAX_DARKNESS - darklevel, 0, MAX_DARKNESS); 398 int light = clamp (MAX_DARKNESS - darklevel, 0, MAX_DARKNESS);
399
400 /* If the player can see in the dark, lower the darklevel for him */
401 if (op->flag [FLAG_SEE_IN_DARK])
402 light += SEE_IN_DARK_RADIUS;
403 403
404 apply_light<los_brighten> (pl, 0, 0, light, vision_atten [light]); 404 apply_light<los_brighten> (pl, 0, 0, light, vision_atten [light]);
405 } 405 }
406 } 406 }
407 407

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines