mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 10:37:03 +00:00
Load npc_options at server startup, use cached data at creature gossip menu init.
Also new .reload table command added. Note: currently it will not affect creatures that have gossim memu created at command use moment.
This commit is contained in:
parent
e96fedc97c
commit
9e6390d88d
8 changed files with 77 additions and 31 deletions
|
|
@ -668,12 +668,9 @@ void Creature::prepareGossipMenu( Player *pPlayer,uint32 gossipid )
|
|||
// lazy loading single time at use
|
||||
LoadGossipOptions();
|
||||
|
||||
GossipOption* gso;
|
||||
GossipOption* ingso;
|
||||
|
||||
for( GossipOptionList::iterator i = m_goptions.begin( ); i != m_goptions.end( ); i++ )
|
||||
{
|
||||
gso=&*i;
|
||||
GossipOption* gso=&*i;
|
||||
if(gso->GossipId == gossipid)
|
||||
{
|
||||
bool cantalking=true;
|
||||
|
|
@ -746,11 +743,9 @@ void Creature::prepareGossipMenu( Player *pPlayer,uint32 gossipid )
|
|||
}
|
||||
}
|
||||
|
||||
if(!gso->Option.empty() && cantalking )
|
||||
{ //note for future dev: should have database fields for BoxMessage & BoxMoney
|
||||
pm->GetGossipMenu().AddMenuItem((uint8)gso->Icon,gso->Option, gossipid,gso->Action,"",0,false);
|
||||
ingso=gso;
|
||||
}
|
||||
//note for future dev: should have database fields for BoxMessage & BoxMoney
|
||||
if(!gso->OptionText.empty() && cantalking)
|
||||
pm->GetGossipMenu().AddMenuItem((uint8)gso->Icon,gso->OptionText, gossipid,gso->Action,"",0,false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -797,8 +792,8 @@ void Creature::OnGossipSelect(Player* player, uint32 option)
|
|||
uint32 action=gossipmenu.GetItem(option).m_gAction;
|
||||
uint32 zoneid=GetZoneId();
|
||||
uint64 guid=GetGUID();
|
||||
|
||||
GossipOption const *gossip=GetGossipOption( action );
|
||||
uint32 textid;
|
||||
if(!gossip)
|
||||
{
|
||||
zoneid=0;
|
||||
|
|
@ -806,7 +801,8 @@ void Creature::OnGossipSelect(Player* player, uint32 option)
|
|||
if(!gossip)
|
||||
return;
|
||||
}
|
||||
textid=GetGossipTextId( action, zoneid);
|
||||
|
||||
uint32 textid=GetGossipTextId( action, zoneid);
|
||||
if(textid==0)
|
||||
textid=GetNpcTextId();
|
||||
|
||||
|
|
@ -895,7 +891,7 @@ void Creature::OnPoiSelect(Player* player, GossipOption const *gossip)
|
|||
Map const* map=MapManager::Instance().GetBaseMap( mapid );
|
||||
uint16 areaflag=map->GetAreaFlag(GetPositionX(),GetPositionY());
|
||||
uint32 zoneid=Map::GetZoneId(areaflag,mapid);
|
||||
std::string areaname= gossip->Option;
|
||||
std::string areaname= gossip->OptionText;
|
||||
/*
|
||||
uint16 pflag;
|
||||
|
||||
|
|
@ -989,24 +985,10 @@ void Creature::LoadGossipOptions()
|
|||
|
||||
uint32 npcflags=GetUInt32Value(UNIT_NPC_FLAGS);
|
||||
|
||||
QueryResult *result = WorldDatabase.PQuery( "SELECT id,gossip_id,npcflag,icon,action,option_text FROM npc_option WHERE (npcflag & %u)<>0", npcflags );
|
||||
|
||||
if(!result)
|
||||
return;
|
||||
|
||||
GossipOption go;
|
||||
do
|
||||
{
|
||||
Field *fields = result->Fetch();
|
||||
go.Id= fields[0].GetUInt32();
|
||||
go.GossipId = fields[1].GetUInt32();
|
||||
go.NpcFlag=fields[2].GetUInt32();
|
||||
go.Icon=fields[3].GetUInt32();
|
||||
go.Action=fields[4].GetUInt32();
|
||||
go.Option=fields[5].GetCppString();
|
||||
addGossipOption(go);
|
||||
}while( result->NextRow() );
|
||||
delete result;
|
||||
CacheNpcOptionList const& noList = objmgr.GetNpcOptions ();
|
||||
for (CacheNpcOptionList::const_iterator i = noList.begin (); i != noList.end (); ++i)
|
||||
if(i->NpcFlag & npcflags)
|
||||
addGossipOption(*i);
|
||||
|
||||
m_gossipOptionLoaded = true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue