From 9b1004fe821a2a4b99de08754f1f7cb34baa2596 Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Fri, 10 Oct 2008 22:08:15 +0000 Subject: [PATCH] dynlight area cleanup git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@2892 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/worldlight.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/source/src/worldlight.cpp b/source/src/worldlight.cpp index 0bdaa06c..d899b43d 100644 --- a/source/src/worldlight.cpp +++ b/source/src/worldlight.cpp @@ -191,6 +191,11 @@ vector dlights; VAR(dynlight, 0, 1, 1); +static inline bool insidearea(const block &a, const block &b) +{ + return b.x >= a.x && b.y >= a.y && b.x+b.xs <= a.x+a.xs && b.y+b.ys <= a.y+a.ys; +} + void preparedynlight(dlight &d) { block area = { (int)d.o.x-d.reach, (int)d.o.y-d.reach, d.reach*2+1, d.reach*2+1 }; @@ -202,9 +207,7 @@ void preparedynlight(dlight &d) if(d.area) { - if(area.x >= d.area->x && area.y >= d.area->y && - area.x+area.xs <= d.area->x+d.area->xs && area.y+area.ys <= d.area->y+d.area->ys) - return; + if(insidearea(*d.area, area)) return; freeblock(d.area); } @@ -250,11 +253,6 @@ void removedynlights(physent *owner) } } -static inline bool insidearea(const block &a, const block &b) -{ - return b.x >= a.x && b.y >= a.y && b.x+b.xs <= a.x+a.xs && b.y+b.ys <= a.y+a.ys; -} - void dodynlights() { if(dlights.empty()) return;