From ec431e54185f525e7006cae9f7e1a6fe9ced39b5 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 21 Feb 2015 19:19:15 +0300 Subject: Fix heavy CPU usage while walking. After this commit and some changes in configuration it allow spawn more than 7k mobs in small area with small CPU usage. --- src/map/init.c | 1 + src/map/unit.c | 11 +++++++++++ src/map/unit.h | 1 + 3 files changed, 13 insertions(+) (limited to 'src/map') diff --git a/src/map/init.c b/src/map/init.c index 810089d..3c736f9 100644 --- a/src/map/init.c +++ b/src/map/init.c @@ -133,6 +133,7 @@ HPExport void plugin_init (void) addHookPre("itemdb->is_item_usable", eitemdb_is_item_usable); addHookPre("itemdb->readdb_additional_fields", eitemdb_readdb_additional_fields); addHookPre("unit->can_move", eunit_can_move); + addHookPre("unit->walktoxy", eunit_walktoxy); addHookPost("clif->getareachar_unit", eclif_getareachar_unit_post); addHookPost("clif->authok", eclif_authok_post); diff --git a/src/map/unit.c b/src/map/unit.c index 2e6276e..0c6445b 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -145,3 +145,14 @@ int eunit_can_move(struct block_list *bl) hookStop(); return 1; } + +int eunit_walktoxy(struct block_list *bl __attribute__ ((unused)), + short *x __attribute__ ((unused)), + short *y __attribute__ ((unused)), + int *flagPtr) +{ + // reset flag "Search for an unoccupied cell and cancel if none available" + // this reduce CPU usage and allow mobs to walk on each other. + if ((*flagPtr)&8) + *flagPtr = ((*flagPtr) | 8) ^ 8; +} diff --git a/src/map/unit.h b/src/map/unit.h index 00fba4a..675bf0e 100644 --- a/src/map/unit.h +++ b/src/map/unit.h @@ -5,5 +5,6 @@ #define EVOL_MAP_UNIT int eunit_can_move(struct block_list *bl); +int eunit_walktoxy(struct block_list *bl, short *x, short *y, int *flagPtr); #endif // EVOL_MAP_UNIT -- cgit v1.2.3-60-g2f50