diff options
author | shennetsind <ind@henn.et> | 2013-10-18 16:00:35 -0300 |
---|---|---|
committer | shennetsind <ind@henn.et> | 2013-10-18 16:00:35 -0300 |
commit | 2c720d87c1cf208a4d561a2663f191965a8888b8 (patch) | |
tree | b8e9c7655b72bc3f54a13b0362e4de75ff566b9f /src/map/map.c | |
parent | 8e4bc1905c6a5f0e3c17b70c0b37b4d901363ed9 (diff) | |
download | hercules-2c720d87c1cf208a4d561a2663f191965a8888b8.tar.gz hercules-2c720d87c1cf208a4d561a2663f191965a8888b8.tar.bz2 hercules-2c720d87c1cf208a4d561a2663f191965a8888b8.tar.xz hercules-2c720d87c1cf208a4d561a2663f191965a8888b8.zip |
Item Drop (from any source) Processing Improvement
Signed-off-by: shennetsind <ind@henn.et>
Diffstat (limited to 'src/map/map.c')
-rw-r--r-- | src/map/map.c | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/src/map/map.c b/src/map/map.c index d920875ee..14a9b4908 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -88,8 +88,12 @@ int map_usercount(void) { *------------------------------------------*/ int map_freeblock (struct block_list *bl) { nullpo_retr(map->block_free_lock, bl); + if (map->block_free_lock == 0 || map->block_free_count >= block_free_max) { - aFree(bl); + if( bl->type == BL_ITEM ) + ers_free(map->flooritem_ers, bl); + else + aFree(bl); bl = NULL; if (map->block_free_count >= block_free_max) ShowWarning("map_freeblock: too many free block! %d %d\n", map->block_free_count, map->block_free_lock); @@ -109,11 +113,14 @@ int map_freeblock_lock (void) { * Remove the lock on map_bl *------------------------------------------*/ int map_freeblock_unlock (void) { + if ((--map->block_free_lock) == 0) { int i; - for (i = 0; i < map->block_free_count; i++) - { - aFree(map->block_free[i]); + for (i = 0; i < map->block_free_count; i++) { + if( map->block_free[i]->type == BL_ITEM ) + ers_free(map->flooritem_ers, map->block_free[i]); + else + aFree(map->block_free[i]); map->block_free[i] = NULL; } map->block_free_count = 0; @@ -1330,7 +1337,7 @@ int map_clearflooritem_timer(int tid, unsigned int tick, int id, intptr_t data) void map_clearflooritem(struct block_list *bl) { struct flooritem_data* fitem = (struct flooritem_data*)bl; - if( fitem->cleartimer ) + if( fitem->cleartimer != INVALID_TIMER ) timer->delete(fitem->cleartimer,map->clearflooritem_timer); clif->clearflooritem(fitem, 0); @@ -1470,15 +1477,16 @@ int map_addflooritem(struct item *item_data,int amount,int16 m,int16 x,int16 y,i return 0; r=rnd(); - CREATE(fitem, struct flooritem_data, 1); - fitem->bl.type=BL_ITEM; + fitem = ers_alloc(map->flooritem_ers, struct flooritem_data); + + fitem->bl.type = BL_ITEM; fitem->bl.prev = fitem->bl.next = NULL; - fitem->bl.m=m; - fitem->bl.x=x; - fitem->bl.y=y; + fitem->bl.m = m; + fitem->bl.x = x; + fitem->bl.y = y; fitem->bl.id = map->get_new_object_id(); if(fitem->bl.id==0){ - aFree(fitem); + ers_free(map->flooritem_ers, fitem); return 0; } @@ -5092,6 +5100,7 @@ void do_final(void) map->sql_close(); ers_destroy(map->iterator_ers); + ers_destroy(map->flooritem_ers); aFree(map->list); @@ -5470,7 +5479,10 @@ int do_init(int argc, char *argv[]) map->zone_db = strdb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, MAP_ZONE_NAME_LENGTH); map->iterator_ers = ers_new(sizeof(struct s_mapiterator),"map.c::map_iterator_ers",ERS_OPT_NONE); - + + map->flooritem_ers = ers_new(sizeof(struct flooritem_data),"map.c::map_flooritem_ers",ERS_OPT_NONE); + ers_chunk_size(map->flooritem_ers, 100); + map->sql_init(); if (logs->config.sql_logs) logs->sql_init(); @@ -5634,6 +5646,8 @@ void map_defaults(void) { map->iterator_ers = NULL; map->cache_buffer = NULL; + + map->flooritem_ers = NULL; /* funcs */ map->zone_init = map_zone_init; map->zone_remove = map_zone_remove; |