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.66 by root, Fri Nov 6 13:03:34 2009 UTC vs.
Revision 1.71 by root, Sat Apr 23 04:56:46 2011 UTC

1/* 1/*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2005,2006,2007,2008,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * 5 *
6 * Deliantra is free software: you can redistribute it and/or modify it under 6 * Deliantra is free software: you can redistribute it and/or modify it under
7 * the terms of the Affero GNU General Public License as published by the 7 * the terms of the Affero GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your 8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version. 9 * option) any later version.
32 FLG_YI = 0x02, // we have an y-parent 32 FLG_YI = 0x02, // we have an y-parent
33 FLG_BLOCKED = 0x04, // this space blocks the view 33 FLG_BLOCKED = 0x04, // this space blocks the view
34 FLG_QUEUED = 0x80 // already queued in queue, or border 34 FLG_QUEUED = 0x80 // already queued in queue, or border
35}; 35};
36 36
37// it is important for performance reasons that this structure
38// has a size easily computable by the cpu (*8 is perfect).
39// it is possible to move culled and visible into flags, at
40// some speed loss.
37struct los_info 41struct los_info
38{ 42{
39 uint8 flags; // FLG_xxx 43 uint8 flags; // FLG_xxx
40 uint8 culled; // culled from "tree" 44 uint8 culled; // culled from "tree"
41 uint8 visible; 45 uint8 visible;
81 85
82 los_info &l = los[x][y]; 86 los_info &l = los[x][y];
83 87
84 l.flags |= flags; 88 l.flags |= flags;
85 89
86 if (l.flags & FLG_QUEUED) 90 if (expect_false (l.flags & FLG_QUEUED))
87 return; 91 return;
88 92
89 l.flags |= FLG_QUEUED; 93 l.flags |= FLG_QUEUED;
90 94
91 queue[q1].x = dx; 95 queue[q1].x = dx;
124 // spiral path algorithm below, except when very little 128 // spiral path algorithm below, except when very little
125 // area is visible, in which case it is slower. which evens 129 // area is visible, in which case it is slower. which evens
126 // out los calculation times between large and small los maps. 130 // out los calculation times between large and small los maps.
127 // apply_lights also iterates over this area, maybe these 131 // apply_lights also iterates over this area, maybe these
128 // two passes could be combined somehow. 132 // two passes could be combined somehow.
129 unordered_mapwalk (pl->viewpoint, -half_x, -half_y, half_x, half_y) 133 unordered_mapwalk (mapwalk_buf, pl->viewpoint, -half_x, -half_y, half_x, half_y)
130 { 134 {
131 los_info &l = los [LOS_X0 + dx][LOS_Y0 + dy]; 135 los_info &l = los [LOS_X0 + dx][LOS_Y0 + dy];
132 l.flags = m->at (nx, ny).flags () & P_BLOCKSVIEW ? FLG_BLOCKED : 0; 136 l.flags = m->at (nx, ny).flags () & P_BLOCKSVIEW ? FLG_BLOCKED : 0;
133 } 137 }
134 } 138 }
362 int half_y = pl->ns->mapy / 2; 366 int half_y = pl->ns->mapy / 2;
363 367
364 int pass2 = 0; // negative lights have an extra pass 368 int pass2 = 0; // negative lights have an extra pass
365 369
366 maprect *rects = pl->viewpoint->map->split_to_tiles ( 370 maprect *rects = pl->viewpoint->map->split_to_tiles (
371 mapwalk_buf,
367 pl->viewpoint->x - half_x - MAX_LIGHT_RADIUS, 372 pl->viewpoint->x - half_x - MAX_LIGHT_RADIUS,
368 pl->viewpoint->y - half_y - MAX_LIGHT_RADIUS, 373 pl->viewpoint->y - half_y - MAX_LIGHT_RADIUS,
369 pl->viewpoint->x + half_x + MAX_LIGHT_RADIUS + 1, 374 pl->viewpoint->x + half_x + MAX_LIGHT_RADIUS + 1,
370 pl->viewpoint->y + half_y + MAX_LIGHT_RADIUS + 1 375 pl->viewpoint->y + half_y + MAX_LIGHT_RADIUS + 1
371 ); 376 );
529 if (!pl->ob || !pl->ob->map || !pl->ns) 534 if (!pl->ob || !pl->ob->map || !pl->ns)
530 continue; 535 continue;
531 536
532 rv_vector rv; 537 rv_vector rv;
533 538
534 get_rangevector_from_mapcoord (map, x, y, pl->ob, &rv); 539 get_rangevector_from_mapcoord (pl->ob->map, x, y, pl->ob, &rv);
535 540
536 if ((abs (rv.distance_x) <= pl->ns->mapx / 2) && (abs (rv.distance_y) <= pl->ns->mapy / 2)) 541 if ((abs (rv.distance_x) <= pl->ns->mapx / 2) && (abs (rv.distance_y) <= pl->ns->mapy / 2))
537 pl->do_los = 1; 542 pl->do_los = 1;
538 } 543 }
539} 544}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines