summaryrefslogtreecommitdiff
path: root/src/map/skill.c
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2009-01-31 15:48:04 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2009-01-31 15:48:04 +0000
commit64b6e20b84aa3dca07228df923e73c0703b3d5af (patch)
tree013b60c9e17b9bf6819a0da06feda229adc78b3d /src/map/skill.c
parent4dbc7922cdb25fcedc9ca39fc72ddca926e61efe (diff)
downloadhercules-64b6e20b84aa3dca07228df923e73c0703b3d5af.tar.gz
hercules-64b6e20b84aa3dca07228df923e73c0703b3d5af.tar.bz2
hercules-64b6e20b84aa3dca07228df923e73c0703b3d5af.tar.xz
hercules-64b6e20b84aa3dca07228df923e73c0703b3d5af.zip
objects[] array removal (bugreport:2559)
- Removed the 2 MB wide static array in favor of a general-purpose DBMap (id_db for now). - Inlined functions map_addobject, map_delobject and map_delobjectnofree into their callers' code. - Replaced the free id lookup algorithm from ancient jathena with something more efficient. - Moved the algorithm to map_get_new_object_id() (similar idea as r13481). git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@13503 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/skill.c')
-rw-r--r--src/map/skill.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/map/skill.c b/src/map/skill.c
index 54968bf3d..7187cc37b 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -9504,7 +9504,7 @@ struct skill_unit *skill_initunit (struct skill_unit_group *group, int idx, int
if(!unit->alive)
group->alive_count++;
- unit->bl.id=map_addobject(&unit->bl);
+ unit->bl.id=map_get_new_object_id();
unit->bl.type=BL_SKILL;
unit->bl.m=group->map;
unit->bl.x=x;
@@ -9514,6 +9514,7 @@ struct skill_unit *skill_initunit (struct skill_unit_group *group, int idx, int
unit->val1=val1;
unit->val2=val2;
+ map_addiddb(&unit->bl);
map_addblock(&unit->bl);
// perform oninit actions
@@ -9583,7 +9584,7 @@ int skill_delunit (struct skill_unit* unit)
unit->group=NULL;
unit->alive=0;
- map_delobjectnofree(unit->bl.id);
+ map_delblock(&unit->bl); // don't free yet
if(--group->alive_count==0)
skill_delunitgroup(NULL, group);
@@ -9851,11 +9852,17 @@ int skill_unit_timer_sub_onplace (struct block_list* bl, va_list ap)
*------------------------------------------*/
int skill_unit_timer_sub (struct block_list* bl, va_list ap)
{
- struct skill_unit* unit = (struct skill_unit *)bl;
- struct skill_unit_group* group = unit->group;
unsigned int tick = va_arg(ap,unsigned int);
+ struct skill_unit* unit;
+ struct skill_unit_group* group;
bool dissonance;
+ if( bl->type != BL_SKILL )
+ return 0;
+
+ unit = (struct skill_unit *)bl;
+ group = unit->group;
+
if( !unit->alive )
return 0;
@@ -10011,7 +10018,7 @@ int skill_unit_timer(int tid, unsigned int tick, int id, intptr data)
{
map_freeblock_lock();
- map_foreachobject( skill_unit_timer_sub, BL_SKILL, tick );
+ map_foreachiddb( skill_unit_timer_sub, tick );
map_freeblock_unlock();