Removed one mob data variable related to dynamic mobs that I found to be redundant.

Changed MAX_MOBSKILL (max. amount of different skill entries per mob) from 50 to 40 to reduce memory consumption a bit more.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@12350 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
ultramage 2008-03-12 21:02:59 +00:00
parent 8d65f03635
commit 078d492412
6 changed files with 15 additions and 20 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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_);

View File

@ -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;
}
}

View File

@ -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);

View File

@ -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);