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.67 by root, Sun Nov 29 17:41:07 2009 UTC vs.
Revision 1.73 by root, Mon Oct 29 23:55:52 2012 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,2012 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.
10 * 10 *
11 * This program is distributed in the hope that it will be useful, 11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the Affero GNU General Public License 16 * You should have received a copy of the Affero GNU General Public License
17 * and the GNU General Public License along with this program. If not, see 17 * and the GNU General Public License along with this program. If not, see
18 * <http://www.gnu.org/licenses/>. 18 * <http://www.gnu.org/licenses/>.
19 * 19 *
20 * The authors can be reached via e-mail to <support@deliantra.net> 20 * The authors can be reached via e-mail to <support@deliantra.net>
21 */ 21 */
22 22
23#include <global.h> 23#include <global.h>
24#include <cmath> 24#include <cmath>
128 // spiral path algorithm below, except when very little 128 // spiral path algorithm below, except when very little
129 // area is visible, in which case it is slower. which evens 129 // area is visible, in which case it is slower. which evens
130 // out los calculation times between large and small los maps. 130 // out los calculation times between large and small los maps.
131 // apply_lights also iterates over this area, maybe these 131 // apply_lights also iterates over this area, maybe these
132 // two passes could be combined somehow. 132 // two passes could be combined somehow.
133 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)
134 { 134 {
135 los_info &l = los [LOS_X0 + dx][LOS_Y0 + dy]; 135 los_info &l = los [LOS_X0 + dx][LOS_Y0 + dy];
136 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;
137 } 137 }
138 } 138 }
366 int half_y = pl->ns->mapy / 2; 366 int half_y = pl->ns->mapy / 2;
367 367
368 int pass2 = 0; // negative lights have an extra pass 368 int pass2 = 0; // negative lights have an extra pass
369 369
370 maprect *rects = pl->viewpoint->map->split_to_tiles ( 370 maprect *rects = pl->viewpoint->map->split_to_tiles (
371 mapwalk_buf,
371 pl->viewpoint->x - half_x - MAX_LIGHT_RADIUS, 372 pl->viewpoint->x - half_x - MAX_LIGHT_RADIUS,
372 pl->viewpoint->y - half_y - MAX_LIGHT_RADIUS, 373 pl->viewpoint->y - half_y - MAX_LIGHT_RADIUS,
373 pl->viewpoint->x + half_x + MAX_LIGHT_RADIUS + 1, 374 pl->viewpoint->x + half_x + MAX_LIGHT_RADIUS + 1,
374 pl->viewpoint->y + half_y + MAX_LIGHT_RADIUS + 1 375 pl->viewpoint->y + half_y + MAX_LIGHT_RADIUS + 1
375 ); 376 );
533 if (!pl->ob || !pl->ob->map || !pl->ns) 534 if (!pl->ob || !pl->ob->map || !pl->ns)
534 continue; 535 continue;
535 536
536 rv_vector rv; 537 rv_vector rv;
537 538
538 get_rangevector_from_mapcoord (map, x, y, pl->ob, &rv); 539 get_rangevector_from_mapcoord (pl->ob->map, x, y, pl->ob, &rv);
539 540
540 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))
541 pl->do_los = 1; 542 pl->do_los = 1;
542 } 543 }
543} 544}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines