Minor performance improvement. server no longer wastes processing time creating the awfully long spawn packet when there is nobody in the map it is being spawned in (for mobs & npcs). this also makes server boot faster.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@15856 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
shennetsind 2012-04-11 11:21:48 +00:00
parent 6b4d673359
commit 8be0fbff1f
2 changed files with 23 additions and 16 deletions

View File

@ -915,6 +915,7 @@ int mob_spawn (struct mob_data *md)
md->sc.option = md->db->option; md->sc.option = md->db->option;
map_addblock(&md->bl); map_addblock(&md->bl);
if( map[md->bl.m].users )
clif_spawn(&md->bl); clif_spawn(&md->bl);
skill_unit_move(&md->bl,tick,1); skill_unit_move(&md->bl,tick,1);
mobskill_use(md, tick, MSC_SPAWN); mobskill_use(md, tick, MSC_SPAWN);

View File

@ -168,17 +168,14 @@ int npc_enable(const char* name, int flag)
return 0; return 0;
} }
if (flag&1) if (flag&1) {
{
nd->sc.option&=~OPTION_INVISIBLE; nd->sc.option&=~OPTION_INVISIBLE;
clif_spawn(&nd->bl); clif_spawn(&nd->bl);
} } else if (flag&2)
else if (flag&2)
nd->sc.option&=~OPTION_HIDE; nd->sc.option&=~OPTION_HIDE;
else if (flag&4) else if (flag&4)
nd->sc.option|= OPTION_HIDE; nd->sc.option|= OPTION_HIDE;
else //Can't change the view_data to invisible class because the view_data for all npcs is shared! [Skotlex] else { //Can't change the view_data to invisible class because the view_data for all npcs is shared! [Skotlex]
{
nd->sc.option|= OPTION_INVISIBLE; nd->sc.option|= OPTION_INVISIBLE;
clif_clearunit_area(&nd->bl,CLR_OUTSIGHT); // Hack to trick maya purple card [Xazax] clif_clearunit_area(&nd->bl,CLR_OUTSIGHT); // Hack to trick maya purple card [Xazax]
} }
@ -1964,6 +1961,7 @@ struct npc_data* npc_add_warp(short from_mapid, short from_x, short from_y, shor
status_set_viewdata(&nd->bl, nd->class_); status_set_viewdata(&nd->bl, nd->class_);
status_change_init(&nd->bl); status_change_init(&nd->bl);
unit_dataset(&nd->bl); unit_dataset(&nd->bl);
if( map[nd->bl.m].users )
clif_spawn(&nd->bl); clif_spawn(&nd->bl);
strdb_put(npcname_db, nd->exname, nd); strdb_put(npcname_db, nd->exname, nd);
@ -2024,6 +2022,7 @@ static const char* npc_parse_warp(char* w1, char* w2, char* w3, char* w4, const
status_set_viewdata(&nd->bl, nd->class_); status_set_viewdata(&nd->bl, nd->class_);
status_change_init(&nd->bl); status_change_init(&nd->bl);
unit_dataset(&nd->bl); unit_dataset(&nd->bl);
if( map[nd->bl.m].users )
clif_spawn(&nd->bl); clif_spawn(&nd->bl);
strdb_put(npcname_db, nd->exname, nd); strdb_put(npcname_db, nd->exname, nd);
@ -2131,6 +2130,7 @@ static const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const
status_change_init(&nd->bl); status_change_init(&nd->bl);
unit_dataset(&nd->bl); unit_dataset(&nd->bl);
nd->ud.dir = dir; nd->ud.dir = dir;
if( map[nd->bl.m].users )
clif_spawn(&nd->bl); clif_spawn(&nd->bl);
} else } else
{// 'floating' shop? {// 'floating' shop?
@ -2343,6 +2343,7 @@ static const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, cons
if( class_ >= 0 ) if( class_ >= 0 )
{ {
status_set_viewdata(&nd->bl, nd->class_); status_set_viewdata(&nd->bl, nd->class_);
if( map[nd->bl.m].users )
clif_spawn(&nd->bl); clif_spawn(&nd->bl);
} }
} }
@ -2489,6 +2490,7 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch
if( class_ >= 0 ) if( class_ >= 0 )
{ {
status_set_viewdata(&nd->bl, nd->class_); status_set_viewdata(&nd->bl, nd->class_);
if( map[nd->bl.m].users )
clif_spawn(&nd->bl); clif_spawn(&nd->bl);
} }
} }
@ -2567,6 +2569,7 @@ int npc_duplicate4instance(struct npc_data *snd, int m)
status_set_viewdata(&wnd->bl, wnd->class_); status_set_viewdata(&wnd->bl, wnd->class_);
status_change_init(&wnd->bl); status_change_init(&wnd->bl);
unit_dataset(&wnd->bl); unit_dataset(&wnd->bl);
if( map[wnd->bl.m].users )
clif_spawn(&wnd->bl); clif_spawn(&wnd->bl);
strdb_put(npcname_db, wnd->exname, wnd); strdb_put(npcname_db, wnd->exname, wnd);
} }
@ -2684,6 +2687,7 @@ void npc_setdisplayname(struct npc_data* nd, const char* newname)
nullpo_retv(nd); nullpo_retv(nd);
safestrncpy(nd->name, newname, sizeof(nd->name)); safestrncpy(nd->name, newname, sizeof(nd->name));
if( map[nd->bl.m].users )
clif_charnameack(0, &nd->bl); clif_charnameack(0, &nd->bl);
} }
@ -2698,9 +2702,11 @@ void npc_setclass(struct npc_data* nd, short class_)
if( nd->class_ == class_ ) if( nd->class_ == class_ )
return; return;
if( map[nd->bl.m].users )
clif_clearunit_area(&nd->bl, CLR_OUTSIGHT);// fade out clif_clearunit_area(&nd->bl, CLR_OUTSIGHT);// fade out
nd->class_ = class_; nd->class_ = class_;
status_set_viewdata(&nd->bl, class_); status_set_viewdata(&nd->bl, class_);
if( map[nd->bl.m].users )
clif_spawn(&nd->bl);// fade in clif_spawn(&nd->bl);// fade in
} }