--- deliantra/server/common/los.C 2009/11/04 18:17:57 1.65 +++ deliantra/server/common/los.C 2010/02/07 04:22:32 1.68 @@ -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; @@ -303,26 +307,29 @@ } } los_init; -// brighten area, ignore los -sint8 -los_brighten_nolos (sint8 b, sint8 l) -{ - return min (b, l); -} +// the following functions cannot be static, due to c++ stupidity :/ +namespace { + // brighten area, ignore los + sint8 + los_brighten_nolos (sint8 b, sint8 l) + { + return min (b, l); + } -// brighten area, but respect los -sint8 -los_brighten (sint8 b, sint8 l) -{ - return b == LOS_BLOCKED ? b : min (b, l); -} + // brighten area, but respect los + sint8 + los_brighten (sint8 b, sint8 l) + { + return b == LOS_BLOCKED ? b : min (b, l); + } -// darken area, respect los -sint8 -los_darken (sint8 b, sint8 l) -{ - return max (b, l); -} + // darken area, respect los + sint8 + los_darken (sint8 b, sint8 l) + { + return max (b, l); + } +}; template static void @@ -361,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,