[6828] Added script name indexing for creature, gameobject, item, areatrigger and instance scripts.

* loaded all distinct script names into one vector at server startup
* added custom loaders to convert the script names to indices
* converted all the script lookup functions to use the index instead of the name
This commit is contained in:
Wyk3d 2008-11-16 03:18:26 +02:00
parent 074bd3a08f
commit 766654c85d
16 changed files with 184 additions and 101 deletions

View file

@ -286,9 +286,10 @@ class ObjectMgr
typedef UNORDERED_MAP<uint32, Quest*> QuestMap;
typedef UNORDERED_MAP<uint32, AreaTrigger> AreaTriggerMap;
typedef UNORDERED_MAP<uint32, std::string> AreaTriggerScriptMap;
typedef UNORDERED_MAP<uint32, uint32> AreaTriggerScriptMap;
typedef UNORDERED_MAP<uint32, ReputationOnKillEntry> RepOnKillMap;
@ -296,6 +297,8 @@ class ObjectMgr
typedef UNORDERED_MAP<uint32, PetCreateSpellEntry> PetCreateSpellMap;
typedef std::vector<std::string> ScriptNameMap;
Player* GetPlayer(const char* name) const { return ObjectAccessor::Instance().FindPlayerByName(name);}
Player* GetPlayer(uint64 guid) const { return ObjectAccessor::FindPlayer(guid); }
@ -460,7 +463,7 @@ class ObjectMgr
AreaTrigger const* GetGoBackTrigger(uint32 Map) const;
const char* GetAreaTriggerScriptName(uint32 id);
uint32 GetAreaTriggerScriptId(uint32 trigger_id);
ReputationOnKillEntry const* GetReputationOnKilEntry(uint32 id) const
{
@ -764,6 +767,10 @@ class ObjectMgr
bool RemoveVendorItem(uint32 entry,uint32 item);
bool IsVendorItemValid( uint32 vendor_entry, uint32 item, uint32 maxcount, uint32 ptime, uint32 ExtendedCost, Player* pl = NULL, std::set<uint32>* skip_vendors = NULL ) const;
void LoadScriptNames();
ScriptNameMap &GetScriptNames() { return m_scriptNames; }
const char * GetScriptName(uint32 id) { return id < m_scriptNames.size() ? m_scriptNames[id].c_str() : ""; }
uint32 GetScriptId(const char *name);
protected:
uint32 m_auctionid;
uint32 m_mailid;
@ -781,7 +788,7 @@ class ObjectMgr
uint32 m_hiPetNumber;
QuestMap mQuestTemplates;
QuestMap mQuestTemplates;
typedef UNORDERED_MAP<uint32, GossipText*> GossipTextMap;
typedef UNORDERED_MAP<uint32, uint32> QuestAreaTriggerMap;
@ -825,6 +832,8 @@ class ObjectMgr
GameTeleMap m_GameTeleMap;
ScriptNameMap m_scriptNames;
typedef std::vector<LocaleConstant> LocalForIndex;
LocalForIndex m_LocalForIndex;
int GetOrNewIndexForLocale(LocaleConstant loc);
@ -885,7 +894,9 @@ class ObjectMgr
#define objmgr MaNGOS::Singleton<ObjectMgr>::Instance()
// scripting access functions
bool MANGOS_DLL_SPEC LoadMangosStrings(DatabaseType& db, char const* table,int32 start_value = -1, int32 end_value = std::numeric_limits<int32>::min());
MANGOS_DLL_SPEC const char* GetAreaTriggerScriptNameById(uint32 id);
MANGOS_DLL_SPEC bool LoadMangosStrings(DatabaseType& db, char const* table,int32 start_value = -1, int32 end_value = std::numeric_limits<int32>::min());
MANGOS_DLL_SPEC uint32 GetAreaTriggerScriptId(uint32 trigger_id);
MANGOS_DLL_SPEC uint32 GetScriptId(const char *name);
MANGOS_DLL_SPEC ObjectMgr::ScriptNameMap& GetScriptNames();
#endif