Advertisement
Guest User

Untitled

a guest
May 19th, 2014
8
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 56.92 KB | None | 0 0
  1. /*
  2. * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
  3. * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License as published by the
  7. * Free Software Foundation; either version 2 of the License, or (at your
  8. * option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13. * more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along
  16. * with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18.  
  19. #ifndef _OBJECTMGR_H
  20. #define _OBJECTMGR_H
  21.  
  22. #include "Log.h"
  23. #include "Object.h"
  24. #include "Bag.h"
  25. #include "Creature.h"
  26. #include "DynamicObject.h"
  27. #include "GameObject.h"
  28. #include "TemporarySummon.h"
  29. #include "Corpse.h"
  30. #include "QuestDef.h"
  31. #include "ItemPrototype.h"
  32. #include "NPCHandler.h"
  33. #include "DatabaseEnv.h"
  34. #include "Mail.h"
  35. #include "Map.h"
  36. #include "ObjectAccessor.h"
  37. #include "ObjectDefines.h"
  38. #include <ace/Singleton.h>
  39. #include "VehicleDefines.h"
  40. #include <string>
  41. #include <map>
  42. #include <limits>
  43. #include "ConditionMgr.h"
  44. #include <functional>
  45.  
  46. class Item;
  47. struct AccessRequirement;
  48. struct PlayerClassInfo;
  49. struct PlayerClassLevelInfo;
  50. struct PlayerInfo;
  51. struct PlayerLevelInfo;
  52.  
  53. // GCC have alternative #pragma pack(N) syntax and old gcc version not support pack(push, N), also any gcc version not support it at some platform
  54. #if defined(__GNUC__)
  55. #pragma pack(1)
  56. #else
  57. #pragma pack(push, 1)
  58. #endif
  59.  
  60. struct PageText
  61. {
  62. std::string Text;
  63. uint16 NextPage;
  64. };
  65.  
  66. /// Key for storing temp summon data in TempSummonDataContainer
  67. struct TempSummonGroupKey
  68. {
  69. TempSummonGroupKey(uint32 summonerEntry, SummonerType summonerType, uint8 group)
  70. : _summonerEntry(summonerEntry), _summonerType(summonerType), _summonGroup(group)
  71. {
  72. }
  73.  
  74. bool operator<(TempSummonGroupKey const& rhs) const
  75. {
  76. // memcmp is only reliable if struct doesn't have any padding (packed)
  77. return memcmp(this, &rhs, sizeof(TempSummonGroupKey)) < 0;
  78. }
  79.  
  80. private:
  81. uint32 _summonerEntry; ///< Summoner's entry
  82. SummonerType _summonerType; ///< Summoner's type, see SummonerType for available types
  83. uint8 _summonGroup; ///< Summon's group id
  84. };
  85.  
  86. // GCC have alternative #pragma pack() syntax and old gcc version not support pack(pop), also any gcc version not support it at some platform
  87. #if defined(__GNUC__)
  88. #pragma pack()
  89. #else
  90. #pragma pack(pop)
  91. #endif
  92.  
  93. // DB scripting commands
  94. enum ScriptCommands
  95. {
  96. SCRIPT_COMMAND_TALK = 0, // source/target = Creature, target = any, datalong = talk type (0=say, 1=whisper, 2=yell, 3=emote text, 4=boss emote text), datalong2 & 1 = player talk (instead of creature), dataint = string_id
  97. SCRIPT_COMMAND_EMOTE = 1, // source/target = Creature, datalong = emote id, datalong2 = 0: set emote state; > 0: play emote state
  98. SCRIPT_COMMAND_FIELD_SET = 2, // source/target = Creature, datalong = field id, datalog2 = value
  99. SCRIPT_COMMAND_MOVE_TO = 3, // source/target = Creature, datalong2 = time to reach, x/y/z = destination
  100. SCRIPT_COMMAND_FLAG_SET = 4, // source/target = Creature, datalong = field id, datalog2 = bitmask
  101. SCRIPT_COMMAND_FLAG_REMOVE = 5, // source/target = Creature, datalong = field id, datalog2 = bitmask
  102. SCRIPT_COMMAND_TELEPORT_TO = 6, // source/target = Creature/Player (see datalong2), datalong = map_id, datalong2 = 0: Player; 1: Creature, x/y/z = destination, o = orientation
  103. SCRIPT_COMMAND_QUEST_EXPLORED = 7, // target/source = Player, target/source = GO/Creature, datalong = quest id, datalong2 = distance or 0
  104. SCRIPT_COMMAND_KILL_CREDIT = 8, // target/source = Player, datalong = creature entry, datalong2 = 0: personal credit, 1: group credit
  105. SCRIPT_COMMAND_RESPAWN_GAMEOBJECT = 9, // source = WorldObject (summoner), datalong = GO guid, datalong2 = despawn delay
  106. SCRIPT_COMMAND_TEMP_SUMMON_CREATURE = 10, // source = WorldObject (summoner), datalong = creature entry, datalong2 = despawn delay, x/y/z = summon position, o = orientation
  107. SCRIPT_COMMAND_OPEN_DOOR = 11, // source = Unit, datalong = GO guid, datalong2 = reset delay (min 15)
  108. SCRIPT_COMMAND_CLOSE_DOOR = 12, // source = Unit, datalong = GO guid, datalong2 = reset delay (min 15)
  109. SCRIPT_COMMAND_ACTIVATE_OBJECT = 13, // source = Unit, target = GO
  110. SCRIPT_COMMAND_REMOVE_AURA = 14, // source (datalong2 != 0) or target (datalong2 == 0) = Unit, datalong = spell id
  111. SCRIPT_COMMAND_CAST_SPELL = 15, // source and/or target = Unit, datalong2 = cast direction (0: s->t 1: s->s 2: t->t 3: t->s 4: s->creature with dataint entry), dataint & 1 = triggered flag
  112. SCRIPT_COMMAND_PLAY_SOUND = 16, // source = WorldObject, target = none/Player, datalong = sound id, datalong2 (bitmask: 0/1=anyone/player, 0/2=without/with distance dependency, so 1|2 = 3 is target with distance dependency)
  113. SCRIPT_COMMAND_CREATE_ITEM = 17, // target/source = Player, datalong = item entry, datalong2 = amount
  114. SCRIPT_COMMAND_DESPAWN_SELF = 18, // target/source = Creature, datalong = despawn delay
  115.  
  116. SCRIPT_COMMAND_LOAD_PATH = 20, // source = Unit, datalong = path id, datalong2 = is repeatable
  117. SCRIPT_COMMAND_CALLSCRIPT_TO_UNIT = 21, // source = WorldObject (if present used as a search center), datalong = script id, datalong2 = unit lowguid, dataint = script table to use (see ScriptsType)
  118. SCRIPT_COMMAND_KILL = 22, // source/target = Creature, dataint = remove corpse attribute
  119.  
  120. // TrinityCore only
  121. SCRIPT_COMMAND_ORIENTATION = 30, // source = Unit, target (datalong > 0) = Unit, datalong = > 0 turn source to face target, o = orientation
  122. SCRIPT_COMMAND_EQUIP = 31, // soucre = Creature, datalong = equipment id
  123. SCRIPT_COMMAND_MODEL = 32, // source = Creature, datalong = model id
  124. SCRIPT_COMMAND_CLOSE_GOSSIP = 33, // source = Player
  125. SCRIPT_COMMAND_PLAYMOVIE = 34 // source = Player, datalong = movie id
  126. };
  127.  
  128. // Benchmarked: Faster than std::unordered_map (insert/find)
  129. typedef std::map<uint32, PageText> PageTextContainer;
  130.  
  131. // Benchmarked: Faster than std::map (insert/find)
  132. typedef std::unordered_map<uint16, InstanceTemplate> InstanceTemplateContainer;
  133.  
  134. struct GameTele
  135. {
  136. float position_x;
  137. float position_y;
  138. float position_z;
  139. float orientation;
  140. uint32 mapId;
  141. std::string name;
  142. std::wstring wnameLow;
  143. };
  144.  
  145. typedef std::unordered_map<uint32, GameTele > GameTeleContainer;
  146.  
  147. enum ScriptsType
  148. {
  149. SCRIPTS_FIRST = 1,
  150.  
  151. SCRIPTS_SPELL = SCRIPTS_FIRST,
  152. SCRIPTS_EVENT,
  153. SCRIPTS_WAYPOINT,
  154.  
  155. SCRIPTS_LAST
  156. };
  157.  
  158. enum eScriptFlags
  159. {
  160. // Talk Flags
  161. SF_TALK_USE_PLAYER = 0x1,
  162.  
  163. // Emote flags
  164. SF_EMOTE_USE_STATE = 0x1,
  165.  
  166. // TeleportTo flags
  167. SF_TELEPORT_USE_CREATURE = 0x1,
  168.  
  169. // KillCredit flags
  170. SF_KILLCREDIT_REWARD_GROUP = 0x1,
  171.  
  172. // RemoveAura flags
  173. SF_REMOVEAURA_REVERSE = 0x1,
  174.  
  175. // CastSpell flags
  176. SF_CASTSPELL_SOURCE_TO_TARGET = 0,
  177. SF_CASTSPELL_SOURCE_TO_SOURCE = 1,
  178. SF_CASTSPELL_TARGET_TO_TARGET = 2,
  179. SF_CASTSPELL_TARGET_TO_SOURCE = 3,
  180. SF_CASTSPELL_SEARCH_CREATURE = 4,
  181. SF_CASTSPELL_TRIGGERED = 0x1,
  182.  
  183. // PlaySound flags
  184. SF_PLAYSOUND_TARGET_PLAYER = 0x1,
  185. SF_PLAYSOUND_DISTANCE_SOUND = 0x2,
  186.  
  187. // Orientation flags
  188. SF_ORIENTATION_FACE_TARGET = 0x1
  189. };
  190.  
  191. struct ScriptInfo
  192. {
  193. ScriptsType type;
  194. uint32 id;
  195. uint32 delay;
  196. ScriptCommands command;
  197.  
  198. union
  199. {
  200. struct
  201. {
  202. uint32 nData[3];
  203. float fData[4];
  204. } Raw;
  205.  
  206. struct // SCRIPT_COMMAND_TALK (0)
  207. {
  208. uint32 ChatType; // datalong
  209. uint32 Flags; // datalong2
  210. int32 TextID; // dataint
  211. } Talk;
  212.  
  213. struct // SCRIPT_COMMAND_EMOTE (1)
  214. {
  215. uint32 EmoteID; // datalong
  216. uint32 Flags; // datalong2
  217. } Emote;
  218.  
  219. struct // SCRIPT_COMMAND_FIELD_SET (2)
  220. {
  221. uint32 FieldID; // datalong
  222. uint32 FieldValue; // datalong2
  223. } FieldSet;
  224.  
  225. struct // SCRIPT_COMMAND_MOVE_TO (3)
  226. {
  227. uint32 Unused1; // datalong
  228. uint32 TravelTime; // datalong2
  229. int32 Unused2; // dataint
  230.  
  231. float DestX;
  232. float DestY;
  233. float DestZ;
  234. } MoveTo;
  235.  
  236. struct // SCRIPT_COMMAND_FLAG_SET (4)
  237. // SCRIPT_COMMAND_FLAG_REMOVE (5)
  238. {
  239. uint32 FieldID; // datalong
  240. uint32 FieldValue; // datalong2
  241. } FlagToggle;
  242.  
  243. struct // SCRIPT_COMMAND_TELEPORT_TO (6)
  244. {
  245. uint32 MapID; // datalong
  246. uint32 Flags; // datalong2
  247. int32 Unused1; // dataint
  248.  
  249. float DestX;
  250. float DestY;
  251. float DestZ;
  252. float Orientation;
  253. } TeleportTo;
  254.  
  255. struct // SCRIPT_COMMAND_QUEST_EXPLORED (7)
  256. {
  257. uint32 QuestID; // datalong
  258. uint32 Distance; // datalong2
  259. } QuestExplored;
  260.  
  261. struct // SCRIPT_COMMAND_KILL_CREDIT (8)
  262. {
  263. uint32 CreatureEntry; // datalong
  264. uint32 Flags; // datalong2
  265. } KillCredit;
  266.  
  267. struct // SCRIPT_COMMAND_RESPAWN_GAMEOBJECT (9)
  268. {
  269. uint32 GOGuid; // datalong
  270. uint32 DespawnDelay; // datalong2
  271. } RespawnGameobject;
  272.  
  273. struct // SCRIPT_COMMAND_TEMP_SUMMON_CREATURE (10)
  274. {
  275. uint32 CreatureEntry; // datalong
  276. uint32 DespawnDelay; // datalong2
  277. int32 Unused1; // dataint
  278.  
  279. float PosX;
  280. float PosY;
  281. float PosZ;
  282. float Orientation;
  283. } TempSummonCreature;
  284.  
  285. struct // SCRIPT_COMMAND_CLOSE_DOOR (12)
  286. // SCRIPT_COMMAND_OPEN_DOOR (11)
  287. {
  288. uint32 GOGuid; // datalong
  289. uint32 ResetDelay; // datalong2
  290. } ToggleDoor;
  291.  
  292. // SCRIPT_COMMAND_ACTIVATE_OBJECT (13)
  293.  
  294. struct // SCRIPT_COMMAND_REMOVE_AURA (14)
  295. {
  296. uint32 SpellID; // datalong
  297. uint32 Flags; // datalong2
  298. } RemoveAura;
  299.  
  300. struct // SCRIPT_COMMAND_CAST_SPELL (15)
  301. {
  302. uint32 SpellID; // datalong
  303. uint32 Flags; // datalong2
  304. int32 CreatureEntry; // dataint
  305.  
  306. float SearchRadius;
  307. } CastSpell;
  308.  
  309. struct // SCRIPT_COMMAND_PLAY_SOUND (16)
  310. {
  311. uint32 SoundID; // datalong
  312. uint32 Flags; // datalong2
  313. } PlaySound;
  314.  
  315. struct // SCRIPT_COMMAND_CREATE_ITEM (17)
  316. {
  317. uint32 ItemEntry; // datalong
  318. uint32 Amount; // datalong2
  319. } CreateItem;
  320.  
  321. struct // SCRIPT_COMMAND_DESPAWN_SELF (18)
  322. {
  323. uint32 DespawnDelay; // datalong
  324. } DespawnSelf;
  325.  
  326. struct // SCRIPT_COMMAND_LOAD_PATH (20)
  327. {
  328. uint32 PathID; // datalong
  329. uint32 IsRepeatable; // datalong2
  330. } LoadPath;
  331.  
  332. struct // SCRIPT_COMMAND_CALLSCRIPT_TO_UNIT (21)
  333. {
  334. uint32 CreatureEntry; // datalong
  335. uint32 ScriptID; // datalong2
  336. uint32 ScriptType; // dataint
  337. } CallScript;
  338.  
  339. struct // SCRIPT_COMMAND_KILL (22)
  340. {
  341. uint32 Unused1; // datalong
  342. uint32 Unused2; // datalong2
  343. int32 RemoveCorpse; // dataint
  344. } Kill;
  345.  
  346. struct // SCRIPT_COMMAND_ORIENTATION (30)
  347. {
  348. uint32 Flags; // datalong
  349. uint32 Unused1; // datalong2
  350. int32 Unused2; // dataint
  351.  
  352. float Unused3;
  353. float Unused4;
  354. float Unused5;
  355. float Orientation;
  356. } Orientation;
  357.  
  358. struct // SCRIPT_COMMAND_EQUIP (31)
  359. {
  360. uint32 EquipmentID; // datalong
  361. } Equip;
  362.  
  363. struct // SCRIPT_COMMAND_MODEL (32)
  364. {
  365. uint32 ModelID; // datalong
  366. } Model;
  367.  
  368. // SCRIPT_COMMAND_CLOSE_GOSSIP (33)
  369.  
  370. struct // SCRIPT_COMMAND_PLAYMOVIE (34)
  371. {
  372. uint32 MovieID; // datalong
  373. } PlayMovie;
  374. };
  375.  
  376. std::string GetDebugInfo() const;
  377. };
  378.  
  379. typedef std::multimap<uint32, ScriptInfo> ScriptMap;
  380. typedef std::map<uint32, ScriptMap > ScriptMapMap;
  381. typedef std::multimap<uint32, uint32> SpellScriptsContainer;
  382. typedef std::pair<SpellScriptsContainer::iterator, SpellScriptsContainer::iterator> SpellScriptsBounds;
  383. extern ScriptMapMap sSpellScripts;
  384. extern ScriptMapMap sEventScripts;
  385. extern ScriptMapMap sWaypointScripts;
  386.  
  387. std::string GetScriptsTableNameByType(ScriptsType type);
  388. ScriptMapMap* GetScriptsMapByType(ScriptsType type);
  389. std::string GetScriptCommandName(ScriptCommands command);
  390.  
  391. struct SpellClickInfo
  392. {
  393. uint32 spellId;
  394. uint8 castFlags;
  395. SpellClickUserTypes userType;
  396.  
  397. // helpers
  398. bool IsFitToRequirements(Unit const* clicker, Unit const* clickee) const;
  399. };
  400.  
  401. typedef std::multimap<uint32, SpellClickInfo> SpellClickInfoContainer;
  402. typedef std::pair<SpellClickInfoContainer::const_iterator, SpellClickInfoContainer::const_iterator> SpellClickInfoMapBounds;
  403.  
  404. struct AreaTrigger
  405. {
  406. uint32 target_mapId;
  407. float target_X;
  408. float target_Y;
  409. float target_Z;
  410. float target_Orientation;
  411. };
  412.  
  413. struct BroadcastText
  414. {
  415. BroadcastText() : Id(0), Language(0), EmoteId0(0), EmoteId1(0), EmoteId2(0),
  416. EmoteDelay0(0), EmoteDelay1(0), EmoteDelay2(0), SoundId(0), Unk1(0), Unk2(0)
  417. {
  418. MaleText.resize(DEFAULT_LOCALE + 1);
  419. FemaleText.resize(DEFAULT_LOCALE + 1);
  420. }
  421.  
  422. uint32 Id;
  423. uint32 Language;
  424. StringVector MaleText;
  425. StringVector FemaleText;
  426. uint32 EmoteId0;
  427. uint32 EmoteId1;
  428. uint32 EmoteId2;
  429. uint32 EmoteDelay0;
  430. uint32 EmoteDelay1;
  431. uint32 EmoteDelay2;
  432. uint32 SoundId;
  433. uint32 Unk1;
  434. uint32 Unk2;
  435. // uint32 VerifiedBuild;
  436.  
  437. std::string const& GetText(LocaleConstant locale = DEFAULT_LOCALE, uint8 gender = GENDER_MALE, bool forceGender = false) const
  438. {
  439. if (gender == GENDER_FEMALE && (forceGender || !FemaleText[DEFAULT_LOCALE].empty()))
  440. {
  441. if (FemaleText.size() > size_t(locale) && !FemaleText[locale].empty())
  442. return FemaleText[locale];
  443. return FemaleText[DEFAULT_LOCALE];
  444. }
  445. // else if (gender == GENDER_MALE)
  446. {
  447. if (MaleText.size() > size_t(locale) && !MaleText[locale].empty())
  448. return MaleText[locale];
  449. return MaleText[DEFAULT_LOCALE];
  450. }
  451. }
  452. };
  453.  
  454. typedef std::unordered_map<uint32, BroadcastText> BroadcastTextContainer;
  455.  
  456. typedef std::set<uint32> CellGuidSet;
  457. typedef std::map<uint32/*player guid*/, uint32/*instance*/> CellCorpseSet;
  458. struct CellObjectGuids
  459. {
  460. CellGuidSet creatures;
  461. CellGuidSet gameobjects;
  462. CellCorpseSet corpses;
  463. };
  464. typedef std::unordered_map<uint32/*cell_id*/, CellObjectGuids> CellObjectGuidsMap;
  465. typedef std::unordered_map<uint32/*(mapid, spawnMode) pair*/, CellObjectGuidsMap> MapObjectGuids;
  466.  
  467. // Trinity string ranges
  468. #define MIN_TRINITY_STRING_ID 1 // 'trinity_string'
  469. #define MAX_TRINITY_STRING_ID 2000000000
  470. #define MIN_DB_SCRIPT_STRING_ID MAX_TRINITY_STRING_ID // 'db_script_string'
  471. #define MAX_DB_SCRIPT_STRING_ID 2000010000
  472.  
  473. // Trinity Trainer Reference start range
  474. #define TRINITY_TRAINER_START_REF 200000
  475.  
  476. struct TrinityStringLocale
  477. {
  478. StringVector Content;
  479. };
  480.  
  481. typedef std::map<uint64, uint64> LinkedRespawnContainer;
  482. typedef std::unordered_map<uint32, CreatureData> CreatureDataContainer;
  483. typedef std::unordered_map<uint32, GameObjectData> GameObjectDataContainer;
  484. typedef std::map<TempSummonGroupKey, std::vector<TempSummonData> > TempSummonDataContainer;
  485. typedef std::unordered_map<uint32, CreatureLocale> CreatureLocaleContainer;
  486. typedef std::unordered_map<uint32, GameObjectLocale> GameObjectLocaleContainer;
  487. typedef std::unordered_map<uint32, ItemLocale> ItemLocaleContainer;
  488. typedef std::unordered_map<uint32, ItemSetNameLocale> ItemSetNameLocaleContainer;
  489. typedef std::unordered_map<uint32, QuestLocale> QuestLocaleContainer;
  490. typedef std::unordered_map<uint32, NpcTextLocale> NpcTextLocaleContainer;
  491. typedef std::unordered_map<uint32, PageTextLocale> PageTextLocaleContainer;
  492. typedef std::unordered_map<int32, TrinityStringLocale> TrinityStringLocaleContainer;
  493. typedef std::unordered_map<uint32, GossipMenuItemsLocale> GossipMenuItemsLocaleContainer;
  494. typedef std::unordered_map<uint32, PointOfInterestLocale> PointOfInterestLocaleContainer;
  495.  
  496. typedef std::multimap<uint32, uint32> QuestRelations;
  497. typedef std::pair<QuestRelations::const_iterator, QuestRelations::const_iterator> QuestRelationBounds;
  498.  
  499. struct PetLevelInfo
  500. {
  501. PetLevelInfo() : health(0), mana(0), armor(0) { for (uint8 i=0; i < MAX_STATS; ++i) stats[i] = 0; }
  502.  
  503. uint16 stats[MAX_STATS];
  504. uint16 health;
  505. uint16 mana;
  506. uint16 armor;
  507. };
  508.  
  509. struct MailLevelReward
  510. {
  511. MailLevelReward() : raceMask(0), mailTemplateId(0), senderEntry(0) { }
  512. MailLevelReward(uint32 _raceMask, uint32 _mailTemplateId, uint32 _senderEntry) : raceMask(_raceMask), mailTemplateId(_mailTemplateId), senderEntry(_senderEntry) { }
  513.  
  514. uint32 raceMask;
  515. uint32 mailTemplateId;
  516. uint32 senderEntry;
  517. };
  518.  
  519. typedef std::list<MailLevelReward> MailLevelRewardList;
  520. typedef std::unordered_map<uint8, MailLevelRewardList> MailLevelRewardContainer;
  521.  
  522. // We assume the rate is in general the same for all three types below, but chose to keep three for scalability and customization
  523. struct RepRewardRate
  524. {
  525. float questRate; // We allow rate = 0.0 in database. For this case, it means that
  526. float questDailyRate;
  527. float questWeeklyRate;
  528. float questMonthlyRate;
  529. float questRepeatableRate;
  530. float creatureRate; // no reputation are given at all for this faction/rate type.
  531. float spellRate;
  532. };
  533.  
  534. struct ReputationOnKillEntry
  535. {
  536. uint32 RepFaction1;
  537. uint32 RepFaction2;
  538. uint32 ReputationMaxCap1;
  539. int32 RepValue1;
  540. uint32 ReputationMaxCap2;
  541. int32 RepValue2;
  542. bool IsTeamAward1;
  543. bool IsTeamAward2;
  544. bool TeamDependent;
  545. };
  546.  
  547. struct RepSpilloverTemplate
  548. {
  549. uint32 faction[MAX_SPILLOVER_FACTIONS];
  550. float faction_rate[MAX_SPILLOVER_FACTIONS];
  551. uint32 faction_rank[MAX_SPILLOVER_FACTIONS];
  552. };
  553.  
  554. struct PointOfInterest
  555. {
  556. uint32 entry;
  557. float x;
  558. float y;
  559. uint32 icon;
  560. uint32 flags;
  561. uint32 data;
  562. std::string icon_name;
  563. };
  564.  
  565. struct GossipMenuItems
  566. {
  567. uint32 MenuId;
  568. uint32 OptionIndex;
  569. uint8 OptionIcon;
  570. std::string OptionText;
  571. uint32 OptionBroadcastTextId;
  572. uint32 OptionType;
  573. uint32 OptionNpcflag;
  574. uint32 ActionMenuId;
  575. uint32 ActionPoiId;
  576. bool BoxCoded;
  577. uint32 BoxMoney;
  578. std::string BoxText;
  579. uint32 BoxBroadcastTextId;
  580. ConditionList Conditions;
  581. };
  582.  
  583. struct GossipMenus
  584. {
  585. uint32 entry;
  586. uint32 text_id;
  587. ConditionList conditions;
  588. };
  589.  
  590. typedef std::multimap<uint32, GossipMenus> GossipMenusContainer;
  591. typedef std::pair<GossipMenusContainer::const_iterator, GossipMenusContainer::const_iterator> GossipMenusMapBounds;
  592. typedef std::pair<GossipMenusContainer::iterator, GossipMenusContainer::iterator> GossipMenusMapBoundsNonConst;
  593. typedef std::multimap<uint32, GossipMenuItems> GossipMenuItemsContainer;
  594. typedef std::pair<GossipMenuItemsContainer::const_iterator, GossipMenuItemsContainer::const_iterator> GossipMenuItemsMapBounds;
  595. typedef std::pair<GossipMenuItemsContainer::iterator, GossipMenuItemsContainer::iterator> GossipMenuItemsMapBoundsNonConst;
  596.  
  597. struct QuestPOIPoint
  598. {
  599. int32 x;
  600. int32 y;
  601.  
  602. QuestPOIPoint() : x(0), y(0) { }
  603. QuestPOIPoint(int32 _x, int32 _y) : x(_x), y(_y) { }
  604. };
  605.  
  606. struct QuestPOI
  607. {
  608. uint32 Id;
  609. int32 ObjectiveIndex;
  610. uint32 MapId;
  611. uint32 AreaId;
  612. uint32 FloorId;
  613. uint32 Unk3;
  614. uint32 Unk4;
  615. std::vector<QuestPOIPoint> points;
  616.  
  617. QuestPOI() : Id(0), ObjectiveIndex(0), MapId(0), AreaId(0), FloorId(0), Unk3(0), Unk4(0) { }
  618. QuestPOI(uint32 id, int32 objIndex, uint32 mapId, uint32 areaId, uint32 floorId, uint32 unk3, uint32 unk4) : Id(id), ObjectiveIndex(objIndex), MapId(mapId), AreaId(areaId), FloorId(floorId), Unk3(unk3), Unk4(unk4) { }
  619. };
  620.  
  621. typedef std::vector<QuestPOI> QuestPOIVector;
  622. typedef std::unordered_map<uint32, QuestPOIVector> QuestPOIContainer;
  623.  
  624. struct GraveYardData
  625. {
  626. uint32 safeLocId;
  627. uint32 team;
  628. };
  629.  
  630. typedef std::multimap<uint32, GraveYardData> GraveYardContainer;
  631. typedef std::pair<GraveYardContainer::const_iterator, GraveYardContainer::const_iterator> GraveYardMapBounds;
  632. typedef std::pair<GraveYardContainer::iterator, GraveYardContainer::iterator> GraveYardMapBoundsNonConst;
  633.  
  634. typedef std::unordered_map<uint32, VendorItemData> CacheVendorItemContainer;
  635. typedef std::unordered_map<uint32, TrainerSpellData> CacheTrainerSpellContainer;
  636.  
  637. enum SkillRangeType
  638. {
  639. SKILL_RANGE_LANGUAGE, // 300..300
  640. SKILL_RANGE_LEVEL, // 1..max skill for level
  641. SKILL_RANGE_MONO, // 1..1, grey monolite bar
  642. SKILL_RANGE_RANK, // 1..skill for known rank
  643. SKILL_RANGE_NONE // 0..0 always
  644. };
  645.  
  646. SkillRangeType GetSkillRangeType(SkillLineEntry const* pSkill, bool racial);
  647.  
  648. #define MAX_PLAYER_NAME 12 // max allowed by client name length
  649. #define MAX_INTERNAL_PLAYER_NAME 15 // max server internal player name length (> MAX_PLAYER_NAME for support declined names)
  650. #define MAX_PET_NAME 12 // max allowed by client name length
  651. #define MAX_CHARTER_NAME 24 // max allowed by client name length
  652.  
  653. bool normalizePlayerName(std::string& name);
  654.  
  655. struct LanguageDesc
  656. {
  657. Language lang_id;
  658. uint32 spell_id;
  659. uint32 skill_id;
  660. };
  661.  
  662. extern LanguageDesc lang_description[LANGUAGES_COUNT];
  663. LanguageDesc const* GetLanguageDescByID(uint32 lang);
  664.  
  665. enum EncounterCreditType
  666. {
  667. ENCOUNTER_CREDIT_KILL_CREATURE = 0,
  668. ENCOUNTER_CREDIT_CAST_SPELL = 1
  669. };
  670.  
  671. struct DungeonEncounter
  672. {
  673. DungeonEncounter(DungeonEncounterEntry const* _dbcEntry, EncounterCreditType _creditType, uint32 _creditEntry, uint32 _lastEncounterDungeon)
  674. : dbcEntry(_dbcEntry), creditType(_creditType), creditEntry(_creditEntry), lastEncounterDungeon(_lastEncounterDungeon) { }
  675.  
  676. DungeonEncounterEntry const* dbcEntry;
  677. EncounterCreditType creditType;
  678. uint32 creditEntry;
  679. uint32 lastEncounterDungeon;
  680. };
  681.  
  682. typedef std::list<DungeonEncounter const*> DungeonEncounterList;
  683. typedef std::unordered_map<uint32, DungeonEncounterList> DungeonEncounterContainer;
  684.  
  685. class PlayerDumpReader;
  686.  
  687. class ObjectMgr
  688. {
  689. friend class PlayerDumpReader;
  690. friend class ACE_Singleton<ObjectMgr, ACE_Null_Mutex>;
  691.  
  692. private:
  693. ObjectMgr();
  694. ~ObjectMgr();
  695.  
  696. public:
  697. typedef std::unordered_map<uint32, Item*> ItemMap;
  698.  
  699. typedef std::unordered_map<uint32, Quest*> QuestMap;
  700.  
  701. typedef std::unordered_map<uint32, AreaTrigger> AreaTriggerContainer;
  702.  
  703. typedef std::unordered_map<uint32, uint32> AreaTriggerScriptContainer;
  704.  
  705. typedef std::unordered_map<uint32, AccessRequirement*> AccessRequirementContainer;
  706.  
  707. typedef std::unordered_map<uint32, RepRewardRate > RepRewardRateContainer;
  708. typedef std::unordered_map<uint32, ReputationOnKillEntry> RepOnKillContainer;
  709. typedef std::unordered_map<uint32, RepSpilloverTemplate> RepSpilloverTemplateContainer;
  710.  
  711. typedef std::unordered_map<uint32, PointOfInterest> PointOfInterestContainer;
  712.  
  713. typedef std::vector<std::string> ScriptNameContainer;
  714.  
  715. typedef std::map<uint32, uint32> CharacterConversionMap;
  716.  
  717. Player* GetPlayerByLowGUID(uint32 lowguid) const;
  718.  
  719. GameObjectTemplate const* GetGameObjectTemplate(uint32 entry);
  720. GameObjectTemplateContainer const* GetGameObjectTemplates() const { return &_gameObjectTemplateStore; }
  721. int LoadReferenceVendor(int32 vendor, int32 item_id, std::set<uint32> *skip_vendors);
  722.  
  723. void LoadGameObjectTemplate();
  724. void AddGameobjectInfo(GameObjectTemplate* goinfo);
  725.  
  726. CreatureTemplate const* GetCreatureTemplate(uint32 entry);
  727. CreatureTemplateContainer const* GetCreatureTemplates() const { return &_creatureTemplateStore; }
  728. CreatureModelInfo const* GetCreatureModelInfo(uint32 modelId);
  729. CreatureModelInfo const* GetCreatureModelRandomGender(uint32* displayID);
  730. static uint32 ChooseDisplayId(CreatureTemplate const* cinfo, CreatureData const* data = NULL);
  731. static void ChooseCreatureFlags(CreatureTemplate const* cinfo, uint32& npcflag, uint32& unit_flags, uint32& dynamicflags, CreatureData const* data = NULL);
  732. EquipmentInfo const* GetEquipmentInfo(uint32 entry, int8& id);
  733. CreatureAddon const* GetCreatureAddon(uint32 lowguid);
  734. CreatureAddon const* GetCreatureTemplateAddon(uint32 entry);
  735. ItemTemplate const* GetItemTemplate(uint32 entry);
  736. ItemTemplateContainer; const* GetItemTemplateStore() const { return &_itemTemplateStore; }
  737.  
  738. ItemSetNameEntry const* GetItemSetNameEntry(uint32 itemId)
  739. {
  740. ItemSetNameContainer::iterator itr = _itemSetNameStore.find(itemId);
  741. if (itr != _itemSetNameStore.end())
  742. return &itr->second;
  743. return NULL;
  744. }
  745.  
  746. InstanceTemplate const* GetInstanceTemplate(uint32 mapId);
  747.  
  748. PetLevelInfo const* GetPetLevelInfo(uint32 creature_id, uint8 level) const;
  749.  
  750. PlayerClassInfo const* GetPlayerClassInfo(uint32 class_) const
  751. {
  752. if (class_ >= MAX_CLASSES)
  753. return NULL;
  754. return _playerClassInfo[class_];
  755. }
  756. void GetPlayerClassLevelInfo(uint32 class_, uint8 level, PlayerClassLevelInfo* info) const;
  757.  
  758. PlayerInfo const* GetPlayerInfo(uint32 race, uint32 class_) const;
  759.  
  760. void GetPlayerLevelInfo(uint32 race, uint32 class_, uint8 level, PlayerLevelInfo* info) const;
  761.  
  762. uint64 GetPlayerGUIDByName(std::string const& name) const;
  763.  
  764. /**
  765. * Retrieves the player name by guid.
  766. *
  767. * If the player is online, the name is retrieved immediately otherwise
  768. * a database query is done.
  769. *
  770. * @remark Use sWorld->GetCharacterNameData because it doesn't require a database query when player is offline
  771. *
  772. * @param guid player full guid
  773. * @param name returned name
  774. *
  775. * @return true if player was found, false otherwise
  776. */
  777. bool GetPlayerNameByGUID(uint64 guid, std::string& name) const;
  778. uint32 GetPlayerTeamByGUID(uint64 guid) const;
  779. uint32 GetPlayerAccountIdByGUID(uint64 guid) const;
  780. uint32 GetPlayerAccountIdByPlayerName(std::string const& name) const;
  781.  
  782. uint32 GetNearestTaxiNode(float x, float y, float z, uint32 mapid, uint32 team);
  783. void GetTaxiPath(uint32 source, uint32 destination, uint32 &path, uint32 &cost);
  784. uint32 GetTaxiMountDisplayId(uint32 id, uint32 team, bool allowed_alt_team = false);
  785.  
  786. Quest const* GetQuestTemplate(uint32 quest_id) const
  787. {
  788. QuestMap::const_iterator itr = _questTemplates.find(quest_id);
  789. return itr != _questTemplates.end() ? itr->second : NULL;
  790. }
  791.  
  792. QuestMap const& GetQuestTemplates() const { return _questTemplates; }
  793.  
  794. uint32 GetQuestForAreaTrigger(uint32 Trigger_ID) const
  795. {
  796. QuestAreaTriggerContainer::const_iterator itr = _questAreaTriggerStore.find(Trigger_ID);
  797. if (itr != _questAreaTriggerStore.end())
  798. return itr->second;
  799. return 0;
  800. }
  801.  
  802. bool IsTavernAreaTrigger(uint32 Trigger_ID) const
  803. {
  804. return _tavernAreaTriggerStore.find(Trigger_ID) != _tavernAreaTriggerStore.end();
  805. }
  806.  
  807. bool IsGameObjectForQuests(uint32 entry) const
  808. {
  809. return _gameObjectForQuestStore.find(entry) != _gameObjectForQuestStore.end();
  810. }
  811.  
  812. GossipText const* GetGossipText(uint32 Text_ID) const;
  813.  
  814. WorldSafeLocsEntry const* GetDefaultGraveYard(uint32 team);
  815. WorldSafeLocsEntry const* GetClosestGraveYard(float x, float y, float z, uint32 MapId, uint32 team);
  816. bool AddGraveYardLink(uint32 id, uint32 zoneId, uint32 team, bool persist = true);
  817. void RemoveGraveYardLink(uint32 id, uint32 zoneId, uint32 team, bool persist = false);
  818. void LoadGraveyardZones();
  819. GraveYardData const* FindGraveYardData(uint32 id, uint32 zone);
  820.  
  821. AreaTrigger const* GetAreaTrigger(uint32 trigger) const
  822. {
  823. AreaTriggerContainer::const_iterator itr = _areaTriggerStore.find(trigger);
  824. if (itr != _areaTriggerStore.end())
  825. return &itr->second;
  826. return NULL;
  827. }
  828.  
  829. AccessRequirement const* GetAccessRequirement(uint32 mapid, Difficulty difficulty) const
  830. {
  831. AccessRequirementContainer::const_iterator itr = _accessRequirementStore.find(MAKE_PAIR32(mapid, difficulty));
  832. if (itr != _accessRequirementStore.end())
  833. return itr->second;
  834. return NULL;
  835. }
  836.  
  837. AreaTrigger const* GetGoBackTrigger(uint32 Map) const;
  838. AreaTrigger const* GetMapEntranceTrigger(uint32 Map) const;
  839.  
  840. uint32 GetAreaTriggerScriptId(uint32 trigger_id);
  841. SpellScriptsBounds GetSpellScriptsBounds(uint32 spellId);
  842.  
  843. RepRewardRate const* GetRepRewardRate(uint32 factionId) const
  844. {
  845. RepRewardRateContainer::const_iterator itr = _repRewardRateStore.find(factionId);
  846. if (itr != _repRewardRateStore.end())
  847. return &itr->second;
  848.  
  849. return NULL;
  850. }
  851.  
  852. ReputationOnKillEntry const* GetReputationOnKilEntry(uint32 id) const
  853. {
  854. RepOnKillContainer::const_iterator itr = _repOnKillStore.find(id);
  855. if (itr != _repOnKillStore.end())
  856. return &itr->second;
  857. return NULL;
  858. }
  859.  
  860. int32 GetBaseReputationOf(FactionEntry const* factionEntry, uint8 race, uint8 playerClass);
  861.  
  862. RepSpilloverTemplate const* GetRepSpilloverTemplate(uint32 factionId) const
  863. {
  864. RepSpilloverTemplateContainer::const_iterator itr = _repSpilloverTemplateStore.find(factionId);
  865. if (itr != _repSpilloverTemplateStore.end())
  866. return &itr->second;
  867.  
  868. return NULL;
  869. }
  870.  
  871. PointOfInterest const* GetPointOfInterest(uint32 id) const
  872. {
  873. PointOfInterestContainer::const_iterator itr = _pointsOfInterestStore.find(id);
  874. if (itr != _pointsOfInterestStore.end())
  875. return &itr->second;
  876. return NULL;
  877. }
  878.  
  879. QuestPOIVector const* GetQuestPOIVector(uint32 questId)
  880. {
  881. QuestPOIContainer::const_iterator itr = _questPOIStore.find(questId);
  882. if (itr != _questPOIStore.end())
  883. return &itr->second;
  884. return NULL;
  885. }
  886.  
  887. VehicleAccessoryList const* GetVehicleAccessoryList(Vehicle* veh) const;
  888.  
  889. DungeonEncounterList const* GetDungeonEncounterList(uint32 mapId, Difficulty difficulty)
  890. {
  891. std::unordered_map<uint32, DungeonEncounterList>::const_iterator itr = _dungeonEncounterStore.find(MAKE_PAIR32(mapId, difficulty));
  892. if (itr != _dungeonEncounterStore.end())
  893. return &itr->second;
  894. return NULL;
  895. }
  896.  
  897. void LoadQuests();
  898. void LoadQuestStartersAndEnders()
  899. {
  900. TC_LOG_INFO("server.loading", "Loading GO Start Quest Data...");
  901. LoadGameobjectQuestStarters();
  902. TC_LOG_INFO("server.loading", "Loading GO End Quest Data...");
  903. LoadGameobjectQuestEnders();
  904. TC_LOG_INFO("server.loading", "Loading Creature Start Quest Data...");
  905. LoadCreatureQuestStarters();
  906. TC_LOG_INFO("server.loading", "Loading Creature End Quest Data...");
  907. LoadCreatureQuestEnders();
  908. }
  909. void LoadGameobjectQuestStarters();
  910. void LoadGameobjectQuestEnders();
  911. void LoadCreatureQuestStarters();
  912. void LoadCreatureQuestEnders();
  913.  
  914. QuestRelations* GetGOQuestRelationMap()
  915. {
  916. return &_goQuestRelations;
  917. }
  918.  
  919. QuestRelationBounds GetGOQuestRelationBounds(uint32 go_entry)
  920. {
  921. return _goQuestRelations.equal_range(go_entry);
  922. }
  923.  
  924. QuestRelationBounds GetGOQuestInvolvedRelationBounds(uint32 go_entry)
  925. {
  926. return _goQuestInvolvedRelations.equal_range(go_entry);
  927. }
  928.  
  929. QuestRelations* GetCreatureQuestRelationMap()
  930. {
  931. return &_creatureQuestRelations;
  932. }
  933.  
  934. QuestRelationBounds GetCreatureQuestRelationBounds(uint32 creature_entry)
  935. {
  936. return _creatureQuestRelations.equal_range(creature_entry);
  937. }
  938.  
  939. QuestRelationBounds GetCreatureQuestInvolvedRelationBounds(uint32 creature_entry)
  940. {
  941. return _creatureQuestInvolvedRelations.equal_range(creature_entry);
  942. }
  943.  
  944. void LoadEventScripts();
  945. void LoadSpellScripts();
  946. void LoadWaypointScripts();
  947.  
  948. void LoadSpellScriptNames();
  949. void ValidateSpellScripts();
  950.  
  951. void LoadBroadcastTexts();
  952. void LoadBroadcastTextLocales();
  953. bool LoadTrinityStrings(char const* table, int32 min_value, int32 max_value);
  954. bool LoadTrinityStrings() { return LoadTrinityStrings("trinity_string", MIN_TRINITY_STRING_ID, MAX_TRINITY_STRING_ID); }
  955. void LoadDbScriptStrings();
  956. void LoadCreatureClassLevelStats();
  957. void LoadCreatureLocales();
  958. void LoadCreatureTemplates();
  959. void LoadCreatureTemplateAddons();
  960. void CheckCreatureTemplate(CreatureTemplate const* cInfo);
  961. void LoadTempSummons();
  962. void LoadCreatures();
  963. void LoadLinkedRespawn();
  964. bool SetCreatureLinkedRespawn(uint32 guid, uint32 linkedGuid);
  965. void LoadCreatureAddons();
  966. void LoadCreatureModelInfo();
  967. void LoadEquipmentTemplates();
  968. void LoadGameObjectLocales();
  969. void LoadGameobjects();
  970. void LoadItemTemplates();
  971. void LoadItemLocales();
  972. void LoadItemSetNames();
  973. void LoadItemSetNameLocales();
  974. void LoadQuestLocales();
  975. void LoadNpcTextLocales();
  976. void LoadPageTextLocales();
  977. void LoadGossipMenuItemsLocales();
  978. void LoadPointOfInterestLocales();
  979. void LoadInstanceTemplate();
  980. void LoadInstanceEncounters();
  981. void LoadMailLevelRewards();
  982. void LoadVehicleTemplateAccessories();
  983. void LoadVehicleAccessories();
  984.  
  985. void LoadGossipText();
  986.  
  987. void LoadAreaTriggerTeleports();
  988. void LoadAccessRequirements();
  989. void LoadQuestAreaTriggers();
  990. void LoadAreaTriggerScripts();
  991. void LoadTavernAreaTriggers();
  992. void LoadGameObjectForQuests();
  993.  
  994. void LoadPageTexts();
  995. PageText const* GetPageText(uint32 pageEntry);
  996.  
  997. void LoadPlayerInfo();
  998. void LoadPetLevelInfo();
  999. void LoadExplorationBaseXP();
  1000. void LoadPetNames();
  1001. void LoadPetNumber();
  1002. void LoadCorpses();
  1003. void LoadFishingBaseSkillLevel();
  1004.  
  1005. void LoadReputationRewardRate();
  1006. void LoadReputationOnKill();
  1007. void LoadReputationSpilloverTemplate();
  1008.  
  1009. void LoadPointsOfInterest();
  1010. void LoadQuestPOI();
  1011.  
  1012. void LoadNPCSpellClickSpells();
  1013.  
  1014. void LoadGameTele();
  1015.  
  1016. void LoadGossipMenu();
  1017. void LoadGossipMenuItems();
  1018.  
  1019. void LoadVendors();
  1020. void LoadTrainerSpell();
  1021. void AddSpellToTrainer(uint32 entry, uint32 spell, uint32 spellCost, uint32 reqSkill, uint32 reqSkillValue, uint32 reqLevel);
  1022.  
  1023. std::string GeneratePetName(uint32 entry);
  1024. uint32 GetBaseXP(uint8 level);
  1025. uint32 GetXPForLevel(uint8 level) const;
  1026.  
  1027. int32 GetFishingBaseSkillLevel(uint32 entry) const
  1028. {
  1029. FishingBaseSkillContainer::const_iterator itr = _fishingBaseForAreaStore.find(entry);
  1030. return itr != _fishingBaseForAreaStore.end() ? itr->second : 0;
  1031. }
  1032.  
  1033. void ReturnOrDeleteOldMails(bool serverUp);
  1034.  
  1035. CreatureBaseStats const* GetCreatureBaseStats(uint8 level, uint8 unitClass);
  1036.  
  1037. void SetHighestGuids();
  1038. uint32 GenerateLowGuid(HighGuid guidhigh);
  1039. uint32 GenerateAuctionID();
  1040. uint64 GenerateEquipmentSetGuid();
  1041. uint32 GenerateMailID();
  1042. uint32 GeneratePetNumber();
  1043.  
  1044. typedef std::multimap<int32, uint32> ExclusiveQuestGroups;
  1045. typedef std::pair<ExclusiveQuestGroups::const_iterator, ExclusiveQuestGroups::const_iterator> ExclusiveQuestGroupsBounds;
  1046.  
  1047. ExclusiveQuestGroups mExclusiveQuestGroups;
  1048.  
  1049. MailLevelReward const* GetMailLevelReward(uint32 level, uint32 raceMask)
  1050. {
  1051. MailLevelRewardContainer::const_iterator map_itr = _mailLevelRewardStore.find(level);
  1052. if (map_itr == _mailLevelRewardStore.end())
  1053. return NULL;
  1054.  
  1055. for (MailLevelRewardList::const_iterator set_itr = map_itr->second.begin(); set_itr != map_itr->second.end(); ++set_itr)
  1056. if (set_itr->raceMask & raceMask)
  1057. return &*set_itr;
  1058.  
  1059. return NULL;
  1060. }
  1061.  
  1062. CellObjectGuids const& GetCellObjectGuids(uint16 mapid, uint8 spawnMode, uint32 cell_id)
  1063. {
  1064. return _mapObjectGuidsStore[MAKE_PAIR32(mapid, spawnMode)][cell_id];
  1065. }
  1066.  
  1067. CellObjectGuidsMap const& GetMapObjectGuids(uint16 mapid, uint8 spawnMode)
  1068. {
  1069. return _mapObjectGuidsStore[MAKE_PAIR32(mapid, spawnMode)];
  1070. }
  1071.  
  1072. /**
  1073. * Gets temp summon data for all creatures of specified group.
  1074. *
  1075. * @param summonerId Summoner's entry.
  1076. * @param summonerType Summoner's type, see SummonerType for available types.
  1077. * @param group Id of required group.
  1078. *
  1079. * @return null if group was not found, otherwise reference to the creature group data
  1080. */
  1081. std::vector<TempSummonData> const* GetSummonGroup(uint32 summonerId, SummonerType summonerType, uint8 group) const
  1082. {
  1083. TempSummonDataContainer::const_iterator itr = _tempSummonDataStore.find(TempSummonGroupKey(summonerId, summonerType, group));
  1084. if (itr != _tempSummonDataStore.end())
  1085. return &itr->second;
  1086.  
  1087. return NULL;
  1088. }
  1089.  
  1090. BroadcastText const* GetBroadcastText(uint32 id) const
  1091. {
  1092. BroadcastTextContainer::const_iterator itr = _broadcastTextStore.find(id);
  1093. if (itr != _broadcastTextStore.end())
  1094. return &itr->second;
  1095. return NULL;
  1096. }
  1097.  
  1098. CreatureData const* GetCreatureData(uint32 guid) const
  1099. {
  1100. CreatureDataContainer::const_iterator itr = _creatureDataStore.find(guid);
  1101. if (itr == _creatureDataStore.end()) return NULL;
  1102. return &itr->second;
  1103. }
  1104. CreatureData& NewOrExistCreatureData(uint32 guid) { return _creatureDataStore[guid]; }
  1105. void DeleteCreatureData(uint32 guid);
  1106. uint64 GetLinkedRespawnGuid(uint64 guid) const
  1107. {
  1108. LinkedRespawnContainer::const_iterator itr = _linkedRespawnStore.find(guid);
  1109. if (itr == _linkedRespawnStore.end()) return 0;
  1110. return itr->second;
  1111. }
  1112. CreatureLocale const* GetCreatureLocale(uint32 entry) const
  1113. {
  1114. CreatureLocaleContainer::const_iterator itr = _creatureLocaleStore.find(entry);
  1115. if (itr == _creatureLocaleStore.end()) return NULL;
  1116. return &itr->second;
  1117. }
  1118. GameObjectLocale const* GetGameObjectLocale(uint32 entry) const
  1119. {
  1120. GameObjectLocaleContainer::const_iterator itr = _gameObjectLocaleStore.find(entry);
  1121. if (itr == _gameObjectLocaleStore.end()) return NULL;
  1122. return &itr->second;
  1123. }
  1124. ItemLocale const* GetItemLocale(uint32 entry) const
  1125. {
  1126. ItemLocaleContainer::const_iterator itr = _itemLocaleStore.find(entry);
  1127. if (itr == _itemLocaleStore.end()) return NULL;
  1128. return &itr->second;
  1129. }
  1130. ItemSetNameLocale const* GetItemSetNameLocale(uint32 entry) const
  1131. {
  1132. ItemSetNameLocaleContainer::const_iterator itr = _itemSetNameLocaleStore.find(entry);
  1133. if (itr == _itemSetNameLocaleStore.end())return NULL;
  1134. return &itr->second;
  1135. }
  1136. QuestLocale const* GetQuestLocale(uint32 entry) const
  1137. {
  1138. QuestLocaleContainer::const_iterator itr = _questLocaleStore.find(entry);
  1139. if (itr == _questLocaleStore.end()) return NULL;
  1140. return &itr->second;
  1141. }
  1142. NpcTextLocale const* GetNpcTextLocale(uint32 entry) const
  1143. {
  1144. NpcTextLocaleContainer::const_iterator itr = _npcTextLocaleStore.find(entry);
  1145. void LoadFactionChangeSpells();
  1146. void LoadFactionChangeReputations();
  1147.  
  1148. ItemFakeStatContainer ;_ itemFakeStatStore; // custom
  1149.  
  1150. ; private:
  1151. // first free id for selected id type
  1152. uint32 _auctionId;
  1153. if (itr == _npcTextLocaleStore.end()) return NULL;
  1154. return &itr->second;
  1155. }
  1156. PageTextLocale const* GetPageTextLocale(uint32 entry) const
  1157. {
  1158. PageTextLocaleContainer::const_iterator itr = _pageTextLocaleStore.find(entry);
  1159. if (itr == _pageTextLocaleStore.end()) return NULL;
  1160. return &itr->second;
  1161. }
  1162. GossipMenuItemsLocale const* GetGossipMenuItemsLocale(uint32 entry) const
  1163. {
  1164. GossipMenuItemsLocaleContainer::const_iterator itr = _gossipMenuItemsLocaleStore.find(entry);
  1165. if (itr == _gossipMenuItemsLocaleStore.end()) return NULL;
  1166. return &itr->second;
  1167. }
  1168. PointOfInterestLocale const* GetPointOfInterestLocale(uint32 poi_id) const
  1169. {
  1170. PointOfInterestLocaleContainer::const_iterator itr = _pointOfInterestLocaleStore.find(poi_id);
  1171. if (itr == _pointOfInterestLocaleStore.end()) return NULL;
  1172. return &itr->second;
  1173. }
  1174.  
  1175. GameObjectData const* GetGOData(uint32 guid) const
  1176. {
  1177. GameObjectDataContainer::const_iterator itr = _gameObjectDataStore.find(guid);
  1178. if (itr == _gameObjectDataStore.end()) return NULL;
  1179. return &itr->second;
  1180. }
  1181. GameObjectData& NewGOData(uint32 guid) { return _gameObjectDataStore[guid]; }
  1182. void DeleteGOData(uint32 guid);
  1183.  
  1184. TrinityStringLocale const* GetTrinityStringLocale(int32 entry) const
  1185. {
  1186. TrinityStringLocaleContainer::const_iterator itr = _trinityStringLocaleStore.find(entry);
  1187. if (itr == _trinityStringLocaleStore.end()) return NULL;
  1188. return &itr->second;
  1189. }
  1190. const char *GetTrinityString(int32 entry, LocaleConstant locale_idx) const;
  1191. const char *GetTrinityStringForDBCLocale(int32 entry) const { return GetTrinityString(entry, DBCLocaleIndex); }
  1192. LocaleConstant GetDBCLocaleIndex() const { return DBCLocaleIndex; }
  1193. void SetDBCLocaleIndex(LocaleConstant locale) { DBCLocaleIndex = locale; }
  1194.  
  1195. void AddCorpseCellData(uint32 mapid, uint32 cellid, uint32 player_guid, uint32 instance);
  1196. void DeleteCorpseCellData(uint32 mapid, uint32 cellid, uint32 player_guid);
  1197.  
  1198. // grid objects
  1199. void AddCreatureToGrid(uint32 guid, CreatureData const* data);
  1200. void RemoveCreatureFromGrid(uint32 guid, CreatureData const* data);
  1201. void AddGameobjectToGrid(uint32 guid, GameObjectData const* data);
  1202. void RemoveGameobjectFromGrid(uint32 guid, GameObjectData const* data);
  1203. uint32 AddGOData(uint32 entry, uint32 map, float x, float y, float z, float o, uint32 spawntimedelay = 0, float rotation0 = 0, float rotation1 = 0, float rotation2 = 0, float rotation3 = 0);
  1204. uint32 AddCreData(uint32 entry, uint32 map, float x, float y, float z, float o, uint32 spawntimedelay = 0);
  1205. bool MoveCreData(uint32 guid, uint32 map, const Position& pos);
  1206.  
  1207. // reserved names
  1208. void LoadReservedPlayersNames();
  1209. bool IsReservedName(std::string const& name) const;
  1210.  
  1211. // name with valid structure and symbols
  1212. static uint8 CheckPlayerName(std::string const& name, bool create = false);
  1213. static PetNameInvalidReason CheckPetName(std::string const& name);
  1214. static bool IsValidCharterName(std::string const& name);
  1215.  
  1216. static bool CheckDeclinedNames(const std::wstring& w_ownname, DeclinedName const& names);
  1217.  
  1218. GameTele const* GetGameTele(uint32 id) const
  1219. {
  1220. GameTeleContainer::const_iterator itr = _gameTeleStore.find(id);
  1221. if (itr == _gameTeleStore.end()) return NULL;
  1222. return &itr->second;
  1223. }
  1224. GameTele const* GetGameTele(std::string const& name) const;
  1225. GameTele const* GetGameTeleExactName(std::string const& name) const;
  1226. GameTeleContainer const& GetGameTeleMap() const { return _gameTeleStore; }
  1227. bool AddGameTele(GameTele& data);
  1228. bool DeleteGameTele(std::string const& name);
  1229.  
  1230. TrainerSpellData const* GetNpcTrainerSpells(uint32 entry) const
  1231. {
  1232. CacheTrainerSpellContainer::const_iterator iter = _cacheTrainerSpellStore.find(entry);
  1233. if (iter == _cacheTrainerSpellStore.end())
  1234. return NULL;
  1235.  
  1236. return &iter->second;
  1237. }
  1238.  
  1239. VendorItemData const* GetNpcVendorItemList(uint32 entry) const
  1240. {
  1241. CacheVendorItemContainer::const_iterator iter = _cacheVendorItemStore.find(entry);
  1242. if (iter == _cacheVendorItemStore.end())
  1243. return NULL;
  1244.  
  1245. return &iter->second;
  1246. }
  1247. void AddVendorItem(uint32 entry, uint32 item, int32 maxcount, uint32 incrtime, uint32 extendedCost, bool persist = true); // for event
  1248. bool RemoveVendorItem(uint32 entry, uint32 item, bool persist = true); // for event
  1249. bool IsVendorItemValid(uint32 vendor_entry, uint32 item, int32 maxcount, uint32 ptime, uint32 ExtendedCost, Player* player = NULL, std::set<uint32>* skip_vendors = NULL, uint32 ORnpcflag = 0) const;
  1250.  
  1251. void LoadScriptNames();
  1252. ScriptNameContainer &GetScriptNames() { return _scriptNamesStore; }
  1253. const char * GetScriptName(uint32 id) const { return id < _scriptNamesStore.size() ? _scriptNamesStore[id].c_str() : ""; }
  1254. uint32 GetScriptId(const char *name);
  1255.  
  1256. SpellClickInfoMapBounds GetSpellClickInfoMapBounds(uint32 creature_id) const
  1257. {
  1258. return _spellClickInfoStore.equal_range(creature_id);
  1259. }
  1260.  
  1261. GossipMenusMapBounds GetGossipMenusMapBounds(uint32 uiMenuId) const
  1262. {
  1263. return _gossipMenusStore.equal_range(uiMenuId);
  1264. }
  1265.  
  1266. GossipMenusMapBoundsNonConst GetGossipMenusMapBoundsNonConst(uint32 uiMenuId)
  1267. {
  1268. return _gossipMenusStore.equal_range(uiMenuId);
  1269. }
  1270.  
  1271. GossipMenuItemsMapBounds GetGossipMenuItemsMapBounds(uint32 uiMenuId) const
  1272. {
  1273. return _gossipMenuItemsStore.equal_range(uiMenuId);
  1274. }
  1275. GossipMenuItemsMapBoundsNonConst GetGossipMenuItemsMapBoundsNonConst(uint32 uiMenuId)
  1276. {
  1277. return _gossipMenuItemsStore.equal_range(uiMenuId);
  1278. }
  1279.  
  1280. // for wintergrasp only
  1281. GraveYardContainer GraveYardStore;
  1282.  
  1283. static void AddLocaleString(std::string const& s, LocaleConstant locale, StringVector& data);
  1284. static inline void GetLocaleString(const StringVector& data, int loc_idx, std::string& value)
  1285. {
  1286. if (data.size() > size_t(loc_idx) && !data[loc_idx].empty())
  1287. value = data[loc_idx];
  1288. }
  1289.  
  1290. CharacterConversionMap FactionChangeAchievements;
  1291. CharacterConversionMap FactionChangeItems;
  1292. CharacterConversionMap FactionChangeQuests;
  1293. CharacterConversionMap FactionChangeReputation;
  1294. CharacterConversionMap FactionChangeSpells;
  1295. CharacterConversionMap FactionChangeTitles;
  1296.  
  1297. void LoadFactionChangeAchievements();
  1298. void LoadFactionChangeItems();
  1299. void LoadFactionChangeQuests();
  1300. void LoadFactionChangeReputations();
  1301. void LoadFactionChangeSpells();
  1302. void LoadFactionChangeTitles();
  1303.  
  1304. private:
  1305. // first free id for selected id type
  1306. uint32 _auctionId;
  1307. uint64 _equipmentSetGuid;
  1308. uint32 _itemTextId;
  1309. uint32 _mailId;
  1310. uint32 _hiPetNumber;
  1311.  
  1312. // first free low guid for selected guid type
  1313. uint32 _hiCharGuid;
  1314. uint32 _hiCreatureGuid;
  1315. uint32 _hiPetGuid;
  1316. uint32 _hiVehicleGuid;
  1317. uint32 _hiItemGuid;
  1318. uint32 _hiGoGuid;
  1319. uint32 _hiDoGuid;
  1320. uint32 _hiCorpseGuid;
  1321. uint32 _hiMoTransGuid;
  1322.  
  1323. QuestMap _questTemplates;
  1324.  
  1325. typedef std::unordered_map<uint32, GossipText> GossipTextContainer;
  1326. typedef std::unordered_map<uint32, uint32> QuestAreaTriggerContainer;
  1327. typedef std::set<uint32> TavernAreaTriggerContainer;
  1328. typedef std::set<uint32> GameObjectForQuestContainer;
  1329.  
  1330. QuestAreaTriggerContainer _questAreaTriggerStore;
  1331. TavernAreaTriggerContainer _tavernAreaTriggerStore;
  1332. GameObjectForQuestContainer _gameObjectForQuestStore;
  1333. GossipTextContainer _gossipTextStore;
  1334. AreaTriggerContainer _areaTriggerStore;
  1335. AreaTriggerScriptContainer _areaTriggerScriptStore;
  1336. AccessRequirementContainer _accessRequirementStore;
  1337. DungeonEncounterContainer _dungeonEncounterStore;
  1338.  
  1339. RepRewardRateContainer _repRewardRateStore;
  1340. RepOnKillContainer _repOnKillStore;
  1341. RepSpilloverTemplateContainer _repSpilloverTemplateStore;
  1342.  
  1343. GossipMenusContainer _gossipMenusStore;
  1344. GossipMenuItemsContainer _gossipMenuItemsStore;
  1345. PointOfInterestContainer _pointsOfInterestStore;
  1346.  
  1347. QuestPOIContainer _questPOIStore;
  1348.  
  1349. QuestRelations _goQuestRelations;
  1350. QuestRelations _goQuestInvolvedRelations;
  1351. QuestRelations _creatureQuestRelations;
  1352. QuestRelations _creatureQuestInvolvedRelations;
  1353.  
  1354. //character reserved names
  1355. typedef std::set<std::wstring> ReservedNamesContainer;
  1356. ReservedNamesContainer _reservedNamesStore;
  1357.  
  1358. GameTeleContainer _gameTeleStore;
  1359.  
  1360. ScriptNameContainer _scriptNamesStore;
  1361.  
  1362. SpellClickInfoContainer _spellClickInfoStore;
  1363.  
  1364. SpellScriptsContainer _spellScriptsStore;
  1365.  
  1366. VehicleAccessoryContainer _vehicleTemplateAccessoryStore;
  1367. VehicleAccessoryContainer _vehicleAccessoryStore;
  1368.  
  1369. LocaleConstant DBCLocaleIndex;
  1370.  
  1371. PageTextContainer _pageTextStore;
  1372. InstanceTemplateContainer _instanceTemplateStore;
  1373.  
  1374. private:
  1375. void LoadScripts(ScriptsType type);
  1376. void CheckScripts(ScriptsType type, std::set<int32>& ids);
  1377. void LoadQuestRelationsHelper(QuestRelations& map, std::string const& table, bool starter, bool go);
  1378. void PlayerCreateInfoAddItemHelper(uint32 race_, uint32 class_, uint32 itemId, int32 count);
  1379.  
  1380. MailLevelRewardContainer _mailLevelRewardStore;
  1381.  
  1382. CreatureBaseStatsContainer _creatureBaseStatsStore;
  1383.  
  1384. typedef std::map<uint32, PetLevelInfo*> PetLevelInfoContainer;
  1385. // PetLevelInfoContainer[creature_id][level]
  1386. PetLevelInfoContainer _petInfoStore; // [creature_id][level]
  1387.  
  1388. PlayerClassInfo* _playerClassInfo[MAX_CLASSES];
  1389.  
  1390. void BuildPlayerLevelInfo(uint8 race, uint8 class_, uint8 level, PlayerLevelInfo* plinfo) const;
  1391.  
  1392. PlayerInfo* _playerInfo[MAX_RACES][MAX_CLASSES];
  1393.  
  1394. typedef std::vector<uint32> PlayerXPperLevel; // [level]
  1395. PlayerXPperLevel _playerXPperLevel;
  1396.  
  1397. typedef std::map<uint32, uint32> BaseXPContainer; // [area level][base xp]
  1398. BaseXPContainer _baseXPTable;
  1399.  
  1400. typedef std::map<uint32, int32> FishingBaseSkillContainer; // [areaId][base skill level]
  1401. FishingBaseSkillContainer _fishingBaseForAreaStore;
  1402.  
  1403. typedef std::map<uint32, StringVector> HalfNameContainer;
  1404. HalfNameContainer _petHalfName0;
  1405. HalfNameContainer _petHalfName1;
  1406.  
  1407. typedef std::unordered_map<uint32, ItemSetNameEntry> ItemSetNameContainer;
  1408. ItemSetNameContainer _itemSetNameStore;
  1409.  
  1410. MapObjectGuids _mapObjectGuidsStore;
  1411. CreatureDataContainer _creatureDataStore;
  1412. CreatureTemplateContainer _creatureTemplateStore;
  1413. CreatureModelContainer _creatureModelStore;
  1414. CreatureAddonContainer _creatureAddonStore;
  1415. CreatureAddonContainer _creatureTemplateAddonStore;
  1416. EquipmentInfoContainer _equipmentInfoStore;
  1417. LinkedRespawnContainer _linkedRespawnStore;
  1418. CreatureLocaleContainer _creatureLocaleStore;
  1419. GameObjectDataContainer _gameObjectDataStore;
  1420. GameObjectLocaleContainer _gameObjectLocaleStore;
  1421. GameObjectTemplateContainer _gameObjectTemplateStore;
  1422. /// Stores temp summon data grouped by summoner's entry, summoner's type and group id
  1423. TempSummonDataContainer _tempSummonDataStore;
  1424.  
  1425. BroadcastTextContainer _broadcastTextStore;
  1426. ItemTemplateContainer ;_itemTemplateStore;
  1427. ItemLocaleContainer _itemLocaleStore;
  1428. ItemSetNameLocaleContainer _itemSetNameLocaleStore;
  1429. QuestLocaleContainer _questLocaleStore;
  1430. NpcTextLocaleContainer _npcTextLocaleStore;
  1431. PageTextLocaleContainer _pageTextLocaleStore;
  1432. TrinityStringLocaleContainer _trinityStringLocaleStore;
  1433. GossipMenuItemsLocaleContainer _gossipMenuItemsLocaleStore;
  1434. PointOfInterestLocaleContainer _pointOfInterestLocaleStore;
  1435.  
  1436. CacheVendorItemContainer _cacheVendorItemStore;
  1437. CacheTrainerSpellContainer _cacheTrainerSpellStore;
  1438.  
  1439. std::set<uint32> _difficultyEntries[MAX_DIFFICULTY - 1]; // already loaded difficulty 1 value in creatures, used in CheckCreatureTemplate
  1440. std::set<uint32> _hasDifficultyEntries[MAX_DIFFICULTY - 1]; // already loaded creatures with difficulty 1 values, used in CheckCreatureTemplate
  1441.  
  1442. enum CreatureLinkedRespawnType
  1443. {
  1444. CREATURE_TO_CREATURE,
  1445. CREATURE_TO_GO, // Creature is dependant on GO
  1446. GO_TO_GO,
  1447. GO_TO_CREATURE // GO is dependant on creature
  1448. };
  1449.  
  1450. std::set<uint32> _transportMaps; // Helper container storing map ids that are for transports only, loaded from gameobject_template
  1451. };
  1452.  
  1453. #define sObjectMgr ACE_Singleton<ObjectMgr, ACE_Null_Mutex>::instance()
  1454.  
  1455. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement