summaryrefslogtreecommitdiff
path: root/src/map/unit.c
diff options
context:
space:
mode:
authorai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec>2010-11-23 11:13:49 +0000
committerai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec>2010-11-23 11:13:49 +0000
commit959fcb568df0534989eba2f23870a12aaecb91a2 (patch)
tree430cee6221fbfd1b09a8ae5a16ac8c21284e7f42 /src/map/unit.c
parent7d7f935061145b4f387ce904ec3d1c44612341bb (diff)
downloadhercules-959fcb568df0534989eba2f23870a12aaecb91a2.tar.gz
hercules-959fcb568df0534989eba2f23870a12aaecb91a2.tar.bz2
hercules-959fcb568df0534989eba2f23870a12aaecb91a2.tar.xz
hercules-959fcb568df0534989eba2f23870a12aaecb91a2.zip
* Various small cleanups.
- Fixed truncation warnings in @statuspoint, @skillpoint and @str/@agi/@vit/@int/@dex/@luk (since r14436). - Fixed data type inconsistency in @statuspoint and @skillpoint (since r5762, related r13541). - Silenced truncation warnings in CR_ACIDDEMONSTRATION damage calculation and cardfix application (since r13700). - Reformatted unit_blown to make it look cleaner (follow up to r14492). git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/renewal@14493 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/unit.c')
-rw-r--r--src/map/unit.c82
1 files changed, 53 insertions, 29 deletions
diff --git a/src/map/unit.c b/src/map/unit.c
index f2dcdc921..05c0bcb16 100644
--- a/src/map/unit.c
+++ b/src/map/unit.c
@@ -572,46 +572,70 @@ uint8 unit_getdir(struct block_list *bl)
// &1 Do not send position update packets.
int unit_blown(struct block_list* bl, int dx, int dy, int count, int flag)
{
- int nx, ny, ret;
- struct skill_unit* su = BL_CAST(BL_SKILL, bl);
+ int nx, ny, result;
+ struct map_session_data* sd;
+ struct skill_unit* su = NULL;
- ret=path_blownpos(bl->m,bl->x,bl->y,dx,dy,count);
- nx = ret>>16;
- ny = ret&0xffff;
+ if(count)
+ {
+ sd = BL_CAST(BL_PC, bl);
+ su = BL_CAST(BL_SKILL, bl);
- if (!su)
- unit_stop_walking(bl,0);
+ result = path_blownpos(bl->m, bl->x, bl->y, dx, dy, count);
- dx = nx - bl->x;
- dy = ny - bl->y;
+ nx = result>>16;
+ ny = result&0xffff;
- if (!dx && !dy) //Could not knockback.
- return 0;
+ if(!su)
+ {
+ unit_stop_walking(bl, 0);
+ }
- map_foreachinmovearea(clif_outsight, bl, AREA_SIZE, dx, dy, bl->type == BL_PC ? BL_ALL : BL_PC, bl);
+ dx = nx-bl->x;
+ dy = ny-bl->y;
- if(su)
- skill_unit_move_unit_group(su->group,bl->m,dx,dy);
- else
- map_moveblock(bl, nx, ny, gettick());
+ if(dx || dy)
+ {
+ map_foreachinmovearea(clif_outsight, bl, AREA_SIZE, dx, dy, bl->type == BL_PC ? BL_ALL : BL_PC, bl);
- map_foreachinmovearea(clif_insight, bl, AREA_SIZE, -dx, -dy, bl->type == BL_PC ? BL_ALL : BL_PC, bl);
+ if(su)
+ {
+ skill_unit_move_unit_group(su->group, bl->m, dx, dy);
+ }
+ else
+ {
+ map_moveblock(bl, nx, ny, gettick());
+ }
- if(!(flag&0x1))
- clif_blown(bl);
+ map_foreachinmovearea(clif_insight, bl, AREA_SIZE, -dx, -dy, bl->type == BL_PC ? BL_ALL : BL_PC, bl);
- if( bl->type == BL_PC )
- {
- TBL_PC *sd = (TBL_PC*)bl;
- if( sd->touching_id )
- npc_touchnext_areanpc(sd,false);
- if( map_getcell(bl->m,bl->x,bl->y,CELL_CHKNPC) )
- npc_touch_areanpc(sd,bl->m,bl->x,bl->y);
+ if(!(flag&1))
+ {
+ clif_blown(bl);
+ }
+
+ if(sd)
+ {
+ if(sd->touching_id)
+ {
+ npc_touchnext_areanpc(sd, false);
+ }
+ if(map_getcell(bl->m, bl->x, bl->y, CELL_CHKNPC))
+ {
+ npc_touch_areanpc(sd, bl->m, bl->x, bl->y);
+ }
+ else
+ {
+ sd->areanpc_id = 0;
+ }
+ }
+ }
else
- sd->areanpc_id=0;
+ {// could not knockback
+ count = 0;
+ }
}
-
- return count; //Return amount of knocked back cells.
+ return count; // return amount of knocked back cells
}
//Warps a unit/ud to a given map/position.