summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/map.c12
-rw-r--r--src/map/map.h3
-rw-r--r--src/map/mob.c1
-rw-r--r--src/map/npc.c15
-rw-r--r--src/map/npc.h2
-rw-r--r--src/map/unit.c2
6 files changed, 15 insertions, 20 deletions
diff --git a/src/map/map.c b/src/map/map.c
index 27eeab5d2..118e1b99a 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -2019,15 +2019,15 @@ int mob_cache_cleanup_sub(struct block_list *bl, va_list ap)
nullpo_retr(0, md);
//When not to remove:
- //Mob has the cached flag on 0
+ //Mob is not in cache
if (!md->special_state.cached)
return 0;
- if (!battle_config.mob_remove_damaged &&
- md->status.hp < md->status.max_hp)
+ //Mob is damaged and mob_remove_damaged is off
+ if (!battle_config.mob_remove_damaged && md->status.hp < md->status.max_hp)
{
- if (md->spawn && md->spawn_n >= 0) //Do not respawn mob later.
- map[md->spawn->m].moblist[md->spawn_n]->skip++;
- return 0; //Do not remove damaged mobs.
+ if( md->spawn ) //Do not respawn mob later.
+ md->spawn->skip++;
+ return 0;
}
unit_free(&md->bl,0);
diff --git a/src/map/map.h b/src/map/map.h
index 2a9666742..194a49304 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -37,7 +37,7 @@
#define MAX_SKILLUNITGROUP 25
#define MAX_SKILLUNITGROUPTICKSET 25
#define MAX_SKILLTIMERSKILL 15
-#define MAX_MOBSKILL 50
+#define MAX_MOBSKILL 40
#define MAX_MOB_LIST_PER_MAP 128
#define MAX_EVENTQUEUE 2
#define MAX_EVENTTIMER 32
@@ -913,7 +913,6 @@ struct mob_data {
} dmglog[DAMAGELOG_SIZE];
struct spawn_data *spawn; //Spawn data.
struct item *lootitem;
- short spawn_n; //Spawn data index on the map server.
short class_;
unsigned int tdmg; //Stores total damage given to the mob, for exp calculations. [Skotlex]
int level;
diff --git a/src/map/mob.c b/src/map/mob.c
index f52caa5c3..4a68d8c6f 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -225,7 +225,6 @@ struct mob_data* mob_spawn_dataset(struct spawn_data *data)
if(md->db->status.mode&MD_LOOTER)
md->lootitem = (struct item *)aCalloc(LOOTITEM_SIZE,sizeof(struct item));
- md->spawn_n = -1;
md->deletetimer = -1;
md->skillidx = -1;
status_set_viewdata(&md->bl, md->class_);
diff --git a/src/map/npc.c b/src/map/npc.c
index fa4f510d6..86b3c260a 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -2178,11 +2178,9 @@ static const char* npc_parse_function(char* w1, char* w2, char* w3, char* w4, co
* Parse Mob 1 - Parse mob list into each map
* Parse Mob 2 - Actually Spawns Mob
* [Wizputer]
- * If cached =1, it is a dynamic cached mob
- * index points to the index in the mob_list of the map_data cache.
- * -1 indicates that it is not stored on the map.
+ * If 'cached' is true, it is a dynamic cached mob
*------------------------------------------*/
-int npc_parse_mob2(struct spawn_data* mob, int index)
+int npc_parse_mob2(struct spawn_data* mob, bool cached)
{
int i;
struct mob_data *md;
@@ -2190,8 +2188,7 @@ int npc_parse_mob2(struct spawn_data* mob, int index)
for (i = mob->skip; i < mob->num; i++) {
md = mob_spawn_dataset(mob);
md->spawn = mob;
- md->spawn_n = index;
- md->special_state.cached = (index>=0); //If mob is cached on map, it is dynamically removed
+ md->special_state.cached = cached; //If mob is cached on map, it is dynamically removed
mob_spawn(md);
}
mob->skip = 0;
@@ -2340,7 +2337,7 @@ static const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const c
memcpy(data, &mob, sizeof(struct spawn_data));
if( !battle_config.dynamic_mobs || mob.delay1 || mob.delay2 ) {
- npc_parse_mob2(data,-1);
+ npc_parse_mob2(data,false);
npc_delay_mob += mob.num;
} else {
int index = map_addmobtolist(data->m, data);
@@ -2349,14 +2346,14 @@ static const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const c
// (usually shouldn't occur when map server is just starting,
// but not the case when we do @reloadscript
if (map[mob.m].users > 0)
- npc_parse_mob2(data,index);
+ npc_parse_mob2(data,true);
npc_cache_mob += mob.num;
} else {
// mobcache is full
// create them as delayed with one second
mob.delay1 = 1000;
mob.delay2 = 1000;
- npc_parse_mob2(data,-1);
+ npc_parse_mob2(data,false);
npc_delay_mob += mob.num;
}
}
diff --git a/src/map/npc.h b/src/map/npc.h
index 25487e7ff..f54f4d232 100644
--- a/src/map/npc.h
+++ b/src/map/npc.h
@@ -51,7 +51,7 @@ struct npc_data* npc_checknear(struct map_session_data* sd, struct block_list* b
int npc_buysellsel(struct map_session_data* sd, int id, int type);
int npc_buylist(struct map_session_data* sd,int n, unsigned short* item_list);
int npc_selllist(struct map_session_data* sd, int n, unsigned short* item_list);
-int npc_parse_mob2(struct spawn_data* mob, int index); // [Wizputer]
+int npc_parse_mob2(struct spawn_data* mob, bool cached); // [Wizputer]
struct npc_data* npc_add_warp(short from_mapid, short from_x, short from_y, short xs, short ys, unsigned short to_mapindex, short to_x, short to_y);
int npc_globalmessage(const char* name,const char* mes);
diff --git a/src/map/unit.c b/src/map/unit.c
index 98fdb350b..ed5980786 100644
--- a/src/map/unit.c
+++ b/src/map/unit.c
@@ -1890,7 +1890,7 @@ int unit_free(struct block_list *bl, int clrtype)
aFree(md->guardian_data);
md->guardian_data = NULL;
}
- if (md->spawn && md->spawn_n < 0 && --(md->spawn->num) == 0)
+ if (md->spawn && !md->special_state.cached && --(md->spawn->num) == 0)
{ //Spawning data is not attached to the map, so free it
//if this is the last mob who is pointing at it.
aFree(md->spawn);