summaryrefslogtreecommitdiff
path: root/src/powder.c
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2011-10-10 22:41:19 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2011-10-10 22:41:19 (GMT)
commitbf8258ee306a9649e0cfbf5344f8a533907175d8 (patch)
treec6fc31a8f7719aa12176d8614fae8f93b93d032d /src/powder.c
parent9c9f6b2287b028f7d0367308c7669e0ba8960a36 (diff)
downloadpowder-bf8258ee306a9649e0cfbf5344f8a533907175d8.zip
powder-bf8258ee306a9649e0cfbf5344f8a533907175d8.tar.gz
Elements, LIGH, TESC, EMP and DEST thanks to MaksProg
Diffstat (limited to 'src/powder.c')
-rw-r--r--src/powder.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/powder.c b/src/powder.c
index 077a242..100ea96 100644
--- a/src/powder.c
+++ b/src/powder.c
@@ -1258,9 +1258,9 @@ inline int parts_avg(int ci, int ni,int t)
}
-int nearest_part(int ci, int t)
+int nearest_part(int ci, int t, int max_d)
{
- int distance = MAX_DISTANCE;
+ int distance = (max_d!=-1)?max_d:MAX_DISTANCE;
int ndistance = 0;
int id = -1;
int i = 0;
@@ -1268,7 +1268,7 @@ int nearest_part(int ci, int t)
int cy = (int)parts[ci].y;
for (i=0; i<=parts_lastActiveIndex; i++)
{
- if (parts[i].type==t&&!parts[i].life&&i!=ci)
+ if ((parts[i].type==t||t==-1)&&!parts[i].life&&i!=ci)
{
ndistance = abs(cx-parts[i].x)+abs(cy-parts[i].y);// Faster but less accurate Older: sqrt(pow(cx-parts[i].x, 2)+pow(cy-parts[i].y, 2));
if (ndistance<distance)