--- deliantra/server/common/los.C 2009/11/06 13:03:34 1.66 +++ deliantra/server/common/los.C 2011/04/23 04:56:46 1.71 @@ -1,7 +1,7 @@ /* * This file is part of Deliantra, the Roguelike Realtime MMORPG. * - * Copyright (©) 2005,2006,2007,2008,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team + * Copyright (©) 2005,2006,2007,2008,2009,2010,2011 Marc Alexander Lehmann / Robin Redeker / the Deliantra team * * Deliantra is free software: you can redistribute it and/or modify it under * the terms of the Affero GNU General Public License as published by the @@ -34,6 +34,10 @@ FLG_QUEUED = 0x80 // already queued in queue, or border }; +// it is important for performance reasons that this structure +// has a size easily computable by the cpu (*8 is perfect). +// it is possible to move culled and visible into flags, at +// some speed loss. struct los_info { uint8 flags; // FLG_xxx @@ -83,7 +87,7 @@ l.flags |= flags; - if (l.flags & FLG_QUEUED) + if (expect_false (l.flags & FLG_QUEUED)) return; l.flags |= FLG_QUEUED; @@ -126,7 +130,7 @@ // out los calculation times between large and small los maps. // apply_lights also iterates over this area, maybe these // two passes could be combined somehow. - unordered_mapwalk (pl->viewpoint, -half_x, -half_y, half_x, half_y) + unordered_mapwalk (mapwalk_buf, pl->viewpoint, -half_x, -half_y, half_x, half_y) { los_info &l = los [LOS_X0 + dx][LOS_Y0 + dy]; l.flags = m->at (nx, ny).flags () & P_BLOCKSVIEW ? FLG_BLOCKED : 0; @@ -364,6 +368,7 @@ int pass2 = 0; // negative lights have an extra pass maprect *rects = pl->viewpoint->map->split_to_tiles ( + mapwalk_buf, pl->viewpoint->x - half_x - MAX_LIGHT_RADIUS, pl->viewpoint->y - half_y - MAX_LIGHT_RADIUS, pl->viewpoint->x + half_x + MAX_LIGHT_RADIUS + 1, @@ -531,7 +536,7 @@ rv_vector rv; - get_rangevector_from_mapcoord (map, x, y, pl->ob, &rv); + get_rangevector_from_mapcoord (pl->ob->map, x, y, pl->ob, &rv); if ((abs (rv.distance_x) <= pl->ns->mapx / 2) && (abs (rv.distance_y) <= pl->ns->mapy / 2)) pl->do_los = 1;