From 2d5e8b6e1a67df8c0719e744211a188f9c855445 Mon Sep 17 00:00:00 2001 From: skotlex Date: Mon, 4 Sep 2006 14:10:14 +0000 Subject: - Some cleanup of how mobcount works. - status_calc_misc will now be invoked in status_calc_bl even on the first call, since status could have gone up due to skill bonuses. - Moved max HP/SP calculations to before invoking status_calc_misc - Simplified distance and check_distance to use "aegis" methods (greater of dx/dy = distance), there's a new define in map.h called CIRCULAR_AREA, when set, the previous method is used, and map for each in range calls will also check for distances, making most ground skills and battle system use real circles instead of squares. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@8609 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/map.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'src/map/map.c') diff --git a/src/map/map.c b/src/map/map.c index 87300b2e4..c25c61e79 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -220,14 +220,20 @@ int map_getusers(void) { return map_users; } - //Distance functions, taken from http://www.flipcode.com/articles/article_fastdistance.shtml int check_distance(int dx, int dy, int distance) { +#ifdef CIRCULAR_AREA //In this case, we just do a square comparison. Add 1 tile grace for diagonal range checks. return (dx*dx + dy*dy <= distance*distance + (dx&&dy?1:0)); +#else + if (dx < 0) dx = -dx; + if (dy < 0) dy = -dy; + return ((dx> 8 ); +#else + if (dx < 0) dx = -dx; + if (dy < 0) dy = -dy; + return (dxnext){ if(bl && bl->type&type && bl->x>=x0 && bl->x<=x1 && bl->y>=y0 && bl->y<=y1 - //For speed purposes, it does not checks actual range by default. - //Feel free to uncomment if you want a more "exact" approach. -// && check_distance_bl(center, bl, range) +#ifdef CIRCULAR_AREA + && check_distance_bl(center, bl, range) +#endif && bl_list_countnext){ if(bl && bl->x>=x0 && bl->x<=x1 && bl->y>=y0 && bl->y<=y1 -// && check_distance_bl(center, bl, range) +#ifdef CIRCULAR_AREA + && check_distance_bl(center, bl, range) +#endif && bl_list_countnext){ if(bl && bl->type&type && bl->x>=x0 && bl->x<=x1 && bl->y>=y0 && bl->y<=y1 +#ifdef CIRCULAR_AREA + && check_distance_bl(center, bl, range) +#endif && path_search_long(NULL,center->m,center->x,center->y,bl->x,bl->y) && bl_list_countnext){ if(bl && bl->x>=x0 && bl->x<=x1 && bl->y>=y0 && bl->y<=y1 +#ifdef CIRCULAR_AREA + && check_distance_bl(center, bl, range) +#endif && path_search_long(NULL,center->m,center->x,center->y,bl->x,bl->y) && bl_list_count