9
3

WorldDatabase.h 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670
  1. /*
  2. EQ2Emulator: Everquest II Server Emulator
  3. Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
  4. This file is part of EQ2Emulator.
  5. EQ2Emulator is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. EQ2Emulator is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #ifndef EQ2WORLD_EMU_DATABASE_H
  17. #define EQ2WORLD_EMU_DATABASE_H
  18. #ifdef WIN32
  19. #include <WinSock2.h>
  20. #include <windows.h>
  21. #endif
  22. #include <mysql.h>
  23. #include <string>
  24. #include <vector>
  25. #include <map>
  26. #include <stdio.h>
  27. #include "../common/database.h"
  28. #include "../common/types.h"
  29. #include "../common/MiscFunctions.h"
  30. #include "../common/Mutex.h"
  31. #include "../common/DatabaseNew.h"
  32. #include "client.h"
  33. #include "Object.h"
  34. #include "Widget.h"
  35. #include "Sign.h"
  36. #include "NPC.h"
  37. #include "zoneserver.h"
  38. #include "Collections/Collections.h"
  39. #include "Achievements/Achievements.h"
  40. #include "Recipes/Recipe.h"
  41. #include "../common/PacketStruct.h"
  42. #include "Spells.h"
  43. #include "Titles.h"
  44. #include "Rules/Rules.h"
  45. #include "Languages.h"
  46. #include "World.h"
  47. using namespace std;
  48. #define APPEARANCE_SOGA_HFHC 0
  49. #define APPEARANCE_SOGA_HTHC 1
  50. #define APPEARANCE_SOGA_HFC 2
  51. #define APPEARANCE_SOGA_HTC 3
  52. #define APPEARANCE_SOGA_HH 4
  53. #define APPEARANCE_SOGA_HC1 5
  54. #define APPEARANCE_SOGA_HC2 6
  55. #define APPEARANCE_SOGA_SC 7
  56. #define APPEARANCE_SOGA_EC 8
  57. #define APPEARANCE_HTHC 9
  58. #define APPEARANCE_HFHC 10
  59. #define APPEARANCE_HTC 11
  60. #define APPEARANCE_HFC 12
  61. #define APPEARANCE_HH 13
  62. #define APPEARANCE_HC1 14
  63. #define APPEARANCE_HC2 15
  64. #define APPEARANCE_WC1 16
  65. #define APPEARANCE_WC2 17
  66. #define APPEARANCE_SC 18
  67. #define APPEARANCE_EC 19
  68. #define APPEARANCE_SHIRT 20
  69. #define APPEARANCE_UCC 21
  70. #define APPEARANCE_PANTS 22
  71. #define APPEARANCE_ULC 23
  72. #define APPEARANCE_U9 24
  73. #define APPEARANCE_BODY_SIZE 25
  74. #define APPEARANCE_SOGA_WC1 26
  75. #define APPEARANCE_SOGA_WC2 27
  76. #define APPEARANCE_SOGA_SHIRT 28
  77. #define APPEARANCE_SOGA_UCC 29
  78. #define APPEARANCE_SOGA_PANTS 30
  79. #define APPEARANCE_SOGA_ULC 31
  80. #define APPEARANCE_SOGA_U13 32
  81. #define APPEARANCE_SOGA_EBT 33
  82. #define APPEARANCE_SOGA_CHEEKT 34
  83. #define APPEARANCE_SOGA_NT 35
  84. #define APPEARANCE_SOGA_CHINT 36
  85. #define APPEARANCE_SOGA_LT 37
  86. #define APPEARANCE_SOGA_EART 38
  87. #define APPEARANCE_SOGA_EYET 39
  88. #define APPEARANCE_EBT 40
  89. #define APPEARANCE_CHEEKT 41
  90. #define APPEARANCE_NT 42
  91. #define APPEARANCE_CHINT 43
  92. #define APPEARANCE_EART 44
  93. #define APPEARANCE_EYET 45
  94. #define APPEARANCE_LT 46
  95. #define APPEARANCE_BODY_AGE 47
  96. #define APPEARANCE_MC 48
  97. #define APPEARANCE_SMC 49
  98. #define APPEARANCE_SBS 50
  99. #define APPEARANCE_SBA 51
  100. #define CHAR_PROPERTY_SPEED "modify_speed"
  101. #define CHAR_PROPERTY_FLYMODE "modify_flymode"
  102. #define CHAR_PROPERTY_INVUL "modify_invul"
  103. #define CHAR_PROPERTY_REGIONDEBUG "modify_regiondebug"
  104. #define CHAR_PROPERTY_GMVISION "modify_gmvision"
  105. #define CHAR_PROPERTY_LUADEBUG "modify_luadebug"
  106. #define CHAR_PROPERTY_GROUPLOOTMETHOD "group_loot_method"
  107. #define CHAR_PROPERTY_GROUPLOOTITEMRARITY "group_loot_item_rarity"
  108. #define CHAR_PROPERTY_GROUPAUTOSPLIT "group_auto_split"
  109. #define CHAR_PROPERTY_GROUPDEFAULTYELL "group_default_yell"
  110. #define CHAR_PROPERTY_GROUPAUTOLOCK "group_autolock"
  111. #define CHAR_PROPERTY_GROUPLOCKMETHOD "group_lock_method"
  112. #define CHAR_PROPERTY_GROUPSOLOAUTOLOCK "group_solo_autolock"
  113. #define CHAR_PROPERTY_AUTOLOOTMETHOD "group_auto_loot_method"
  114. #define CHAR_PROPERTY_ASSISTAUTOATTACK "assist_auto_attack"
  115. #define CHAR_PROPERTY_SETACTIVEFOOD "set_active_food"
  116. #define CHAR_PROPERTY_SETACTIVEDRINK "set_active_drink"
  117. #define DB_TYPE_SPELLEFFECTS 1
  118. #define DB_TYPE_MAINTAINEDEFFECTS 2
  119. struct StartingItem{
  120. string type;
  121. int32 item_id;
  122. string creator;
  123. int8 condition;
  124. int8 attuned;
  125. int16 count;
  126. };
  127. struct ClaimItems {
  128. int32 char_id;
  129. int32 item_id;
  130. int8 max_claim;
  131. int8 curr_claim;
  132. int8 one_per_char;
  133. int32 vet_reward_time;
  134. };
  135. class Bot;
  136. class WorldDatabase : public Database {
  137. public:
  138. WorldDatabase();
  139. ~WorldDatabase();
  140. bool ConnectNewDatabase();
  141. void PingNewDB();
  142. string GetZoneName(int32 id);
  143. string GetZoneDescription(int32 id);
  144. int32 LoadCharacterSkills(int32 char_id, Player* player);
  145. void DeleteCharacterSkill(int32 char_id, Skill* skill);
  146. void DeleteCharacterSpell(int32 character_id, int32 spell_id);
  147. int32 LoadCharacterSpells(int32 char_id, Player* player);
  148. int32 LoadItemBlueStats();
  149. void SaveQuickBar(int32 char_id, vector<QuickBarItem*>* quickbar_items);
  150. void SavePlayerSpells(Client* client);
  151. int32 LoadSkills();
  152. void LoadCommandList();
  153. map<int8, vector<MacroData*> >* LoadCharacterMacros(int32 char_id);
  154. void UpdateCharacterMacro(int32 char_id, int8 number, const char* name, int16 icon, vector<string>* updates);
  155. void SaveWorldTime(WorldTime* time);
  156. bool SaveSpawnInfo(Spawn* spawn);
  157. int32 GetNextSpawnIDInZone(int32 zone_id);
  158. bool SaveSpawnEntry(Spawn* spawn, const char* spawn_location_name, int8 percent, float x_offset, float y_offset, float z_offset, bool save_zonespawn = true, bool create_spawnlocation = true);
  159. float GetSpawnLocationPlacementOffsetX(int32 location_id);
  160. float GetSpawnLocationPlacementOffsetY(int32 location_id);
  161. float GetSpawnLocationPlacementOffsetZ(int32 location_id);
  162. int32 GetNextSpawnLocation();
  163. bool CreateNewSpawnLocation(int32 id, const char* name);
  164. bool RemoveSpawnFromSpawnLocation(Spawn* spawn);
  165. int32 GetSpawnLocationCount(int32 location, Spawn* spawn = 0);
  166. vector<string>* GetSpawnNameList(const char* in_name);
  167. void LoadSubCommandList();
  168. void LoadGlobalVariables();
  169. void UpdateVitality(int32 timestamp, float amount);
  170. void SaveVariable(const char* name, const char* value, const char* comment);
  171. void LoadVisualStates();
  172. void LoadAppearanceMasterList();
  173. void Save(Client* client);
  174. void SaveItems(Client* client);
  175. void SaveItem(int32 account_id, int32 char_id, Item* item, const char* type);
  176. void DeleteBuyBack(int32 char_id, int32 item_id, int16 quantity, int32 price);
  177. void LoadBuyBacks(Client* client);
  178. void SaveBuyBacks(Client* client);
  179. void SaveBuyBack(int32 char_id, int32 item_id, int16 quantity, int32 price);
  180. void DeleteItem(int32 char_id, Item* item, const char* type);
  181. void SaveCharacterColors(int32 char_id, const char* type, EQ2_Color color);
  182. void SaveCharacterFloats(int32 char_id, const char* type, float float1, float float2, float float3, float multiplier = 100.0f);
  183. int16 GetAppearanceID(string name);
  184. vector<int16>* GetAppearanceIDsLikeName(string name, bool filtered = true);
  185. string GetAppearanceName(int16 appearance_id);
  186. void UpdateRandomize(int32 spawn_id, sint32 value);
  187. int32 SaveCharacter(PacketStruct* create, int32 loginID);
  188. int32 LoadNPCAppearanceEquipmentData(ZoneServer* zone);
  189. void SaveNPCAppearanceEquipment(int32 spawn_id, int8 slot_id, int16 type, int8 red=0, int8 green=0, int8 blue=0, int8 hred=0, int8 hgreen=0, int8 hblue=0);
  190. void LoadSpecialZones();
  191. void SaveCharacterSkills(Client* client);
  192. void SaveCharacterQuests(Client* client);
  193. void SaveCharacterQuestProgress(Client* client, Quest* quest);
  194. void DeleteCharacterQuest(int32 quest_id, int32 char_id, bool repeated_quest = false);
  195. void LoadCharacterQuests(Client* client);
  196. void LoadPlayerAA(Player *player);
  197. void LoadCharacterQuestProgress(Client* client);
  198. void LoadCharacterFriendsIgnoreList(Player* player);
  199. void LoadZoneInfo(ZoneServer* zone);
  200. void LoadZoneInfo(ZoneInfo* zone_info);
  201. int32 GetZoneID(const char* name);
  202. void SaveZoneInfo(int32 zone_id, const char* field, sint32 value);
  203. void SaveZoneInfo(int32 zone_id, const char* field, float value);
  204. void SaveZoneInfo(int32 zone_id, const char* field, const char* value);
  205. bool GetZoneRequirements(const char* zoneName,sint16* minStatus, int16* minLevel, int16* maxLevel, int16* minVersion);
  206. int16 GetMinimumClientVersion(int8 expansion_id);
  207. string GetExpansionIDByVersion(int16 version);
  208. int32 CheckTableVersions(char* tablename);
  209. bool RunDatabaseQueries(TableQuery* queries, bool output_result = true, bool data = false);
  210. void UpdateTableVersion(char* name, int32 version);
  211. void UpdateDataTableVersion(char* name, int32 version);
  212. void UpdateStartingFactions(int32 char_id, int8 choice);
  213. string GetStartingZoneName(int8 choice);
  214. void UpdateStartingZone(int32 char_id, int8 class_id, int8 race_id, PacketStruct* create);
  215. void UpdateStartingItems(int32 char_id, int8 class_id, int8 race_id, bool base_class = false);
  216. void UpdateStartingSkills(int32 char_id, int8 class_id, int8 race_id);
  217. void UpdateStartingSpells(int32 char_id, int8 class_id, int8 race_id);
  218. void UpdateStartingSkillbar(int32 char_id, int8 class_id, int8 race_id);
  219. void UpdateStartingTitles(int32 char_id, int8 class_id, int8 race_id, int8 gender_id);
  220. bool UpdateSpawnLocationSpawns(Spawn* spawn);
  221. bool UpdateSpawnWidget(int32 widget_id, char* query);
  222. bool CheckVersionTable();
  223. void LoadFactionAlliances();
  224. void LoadFactionList();
  225. bool LoadPlayerFactions(Client* client);
  226. void SavePlayerFactions(Client* client);
  227. bool VerifyFactionID(int32 char_id, int32 faction_id);
  228. void LoadSpawnScriptData();
  229. void LoadZoneScriptData();
  230. int32 LoadSpellScriptData();
  231. bool UpdateSpawnScriptData(int32 spawn_id, int32 spawn_location_id, int32 spawnentry_id, const char* name);
  232. map<int32, string>* GetZoneList(const char* name, bool is_admin = false);
  233. bool VerifyZone(const char* name);
  234. int8 GetInstanceTypeByZoneID(int32 zoneID);
  235. /*void loadNPCAppearance(int32 appearance_id);
  236. void LoadNPCAppearances();*/
  237. void ResetDatabase();
  238. void EnableConstraints();
  239. void DisableConstraints();
  240. int32 SaveCombinedSpawnLocation(ZoneServer* zone, Spawn* spawn, const char* name);
  241. int32 ProcessSpawnLocations(ZoneServer* zone, const char* sql_query, int8 type);
  242. int32 LoadSpawnLocationGroupAssociations(ZoneServer* zone);
  243. int32 LoadSpawnLocationGroups(ZoneServer* zone);
  244. int32 LoadSpawnGroupChances(ZoneServer* zone);
  245. bool SpawnGroupAddAssociation(int32 group1, int32 group2);
  246. bool SpawnGroupRemoveAssociation(int32 group1, int32 group2);
  247. bool SpawnGroupAddSpawn(Spawn* spawn, int32 group_id);
  248. bool SpawnGroupRemoveSpawn(Spawn* spawn, int32 group_id);
  249. int32 CreateSpawnGroup(Spawn* spawn, string name);
  250. void DeleteSpawnGroup(int32 id);
  251. bool SetGroupSpawnChance(int32 id, float chance);
  252. void LoadGroundSpawnEntries(ZoneServer* zone);
  253. void LoadGroundSpawnItems(ZoneServer* zone);
  254. void LoadSpawns(ZoneServer* zone);
  255. int8 GetAppearanceType(string type);
  256. void LoadNPCs(ZoneServer* zone);
  257. void LoadSpiritShards(ZoneServer* zone);
  258. int32 LoadAppearances(ZoneServer* zone, Client* client = 0);
  259. int32 LoadNPCSpells();
  260. int32 LoadNPCSkills(ZoneServer* zone);
  261. int32 LoadNPCEquipment(ZoneServer* zone);
  262. void LoadObjects(ZoneServer* zone);
  263. void LoadGroundSpawns(ZoneServer* zone);
  264. void LoadWidgets(ZoneServer* zone);
  265. void LoadSigns(ZoneServer* zone);
  266. void ReloadItemList(int32 item_id = 0);
  267. void LoadItemList(int32 item_id = 0);
  268. int32 LoadItemStats(int32 item_id = 0);
  269. int32 LoadItemModStrings(int32 item_id = 0);
  270. int32 LoadItemAppearances(int32 item_id = 0);
  271. int32 LoadItemLevelOverride(int32 item_id = 0);
  272. int32 LoadItemEffects(int32 item_id = 0);
  273. int32 LoadBookPages(int32 item_id = 0);
  274. int32 LoadNextUniqueItemID();
  275. int32 LoadSkillItems(int32 item_id = 0);
  276. int32 LoadRangeWeapons(int32 item_id = 0);
  277. int32 LoadThrownWeapons(int32 item_id = 0);
  278. int32 LoadBaubles(int32 item_id = 0);
  279. int32 LoadBooks(int32 item_id = 0);
  280. int32 LoadItemsets(int32 item_id = 0);
  281. int32 LoadHouseItem(int32 item_id = 0);
  282. int32 LoadRecipeBookItems(int32 item_id = 0);
  283. int32 LoadArmor(int32 item_id = 0);
  284. int32 LoadAdornments(int32 item_id = 0);
  285. int32 LoadClassifications();
  286. int32 LoadShields(int32 item_id = 0);
  287. int32 LoadBags(int32 item_id = 0);
  288. int32 LoadFoods(int32 item_id = 0);
  289. int32 LoadWeapons(int32 item_id = 0);
  290. int32 LoadRanged();
  291. int32 LoadHouseContainers(int32 item_id = 0);
  292. void LoadBrokerItemStats();
  293. void SaveSignMark(int32 char_id, int32 sign_id, char* char_name, Client* client);
  294. string GetSignMark(int32 char_id, int32 sign_id, char* char_name); // returns the string containing the character name
  295. map<int32, vector<LevelArray*> >* LoadSpellClasses();
  296. void LoadTransporters(ZoneServer* zone);
  297. void LoadTransportMaps(ZoneServer* zone);
  298. void LoadDataFromRow(DatabaseResult *result, Item* item);
  299. void LoadCharacterItemList(int32 account_id, int32 char_id, Player* player, int16);
  300. bool loadCharacter(const char* name, int32 account_id, Client* client);
  301. std::string loadCharacterFromLogin(ZoneChangeDetails* details, int32 char_id, int32 account_id);
  302. bool LoadCharacterStats(int32 id, int32 account_id, Client* client);
  303. void LoadCharacterQuestRewards(Client* client);
  304. void LoadCharacterQuestTemporaryRewards(Client* client, int32 quest_id);
  305. bool InsertCharacterStats(int32 character_id, int8 class_id, int8 race_id);
  306. bool UpdateCharacterTimeStamp(int32 account_id, int32 character_id, int32 timestamp);
  307. bool insertCharacterProperty(Client* client, char* propName, char* propValue);
  308. bool loadCharacterProperties(Client* client);
  309. string GetPlayerName(char* name);
  310. int32 GetCharacterTimeStamp(int32 character_id, int32 account_id,bool* char_exists);
  311. int32 GetCharacterTimeStamp(int32 character_id);
  312. sint32 GetLatestDataTableVersion(char* name);
  313. sint16 GetLowestCharacterAdminStatus(int32 account_id);
  314. sint16 GetHighestCharacterAdminStatus(int32 account_id);
  315. sint16 GetCharacterAdminStatus(char* character_name);
  316. sint16 GetCharacterAdminStatus(int32 account_id , int32 char_id);
  317. bool UpdateAdminStatus(char* character_name, sint16 flag);
  318. void LoadMerchantInformation();
  319. void LoadMerchantInventory();
  320. string GetMerchantDescription(int32 merchant_id);
  321. void LoadPlayerStatistics(Player* player, int32 char_id);
  322. void WritePlayerStatistic(Player* player, Statistic* stat);
  323. void LoadServerStatistics();
  324. void WriteServerStatistic(Statistic* stat);
  325. void WriteServerStatistic(int32 stat_id, sint32 stat_value);
  326. void WriteServerStatisticsNeededQueries();
  327. void SavePlayerMail(Mail* mail);
  328. void SavePlayerMail(Client* client);
  329. void LoadPlayerMail(Client* client, bool new_only = false);
  330. void DeletePlayerMail(Mail* mail);
  331. vector<int32>* GetAllPlayerIDs();
  332. void GetPetNames(ZoneServer* zone);
  333. //void LoadMerchantMultipliers();
  334. char* GetCharacterName(int32 character_id);
  335. int8 GetCharacterLevel(int32 character_id);
  336. int16 GetCharacterModelType(int32 character_id);
  337. int8 GetCharacterClass(int32 character_id);
  338. int8 GetCharacterGender(int32 character_id);
  339. int32 GetCharacterID(const char* name);
  340. int32 GetCharacterCurrentZoneID(int32 character_id);
  341. int32 GetCharacterAccountID(int32 character_id);
  342. void LoadEntityCommands(ZoneServer* zone);
  343. void LoadSpells();
  344. void LoadSpellEffects();
  345. void LoadSpellLuaData();
  346. void LoadTraits();
  347. int32 LoadPlayerSkillbar(Client* client);
  348. string GetColumnNames(char* name);
  349. string GetZoneName(char* zone_description);
  350. bool GetItemResultsToClient (Client* client, const char* varSearch, int maxResults=20);
  351. void LoadRevivePoints(vector<RevivePoint*>* revive_points, int32 zone_id);
  352. void SaveBugReport(const char* category, const char* subcategory, const char* causes_crash, const char* reproducible, const char* summary, const char* description, const char* version, const char* player, int32 account_id, const char* spawn_name, int32 spawn_id, int32 zone_id);
  353. void FixBugReport();
  354. int32 LoadQuests();
  355. void LoadQuestDetails(Quest* quest);
  356. bool DeleteCharacter(int32 account_id, int32 character_id);
  357. int32 GetMaxHotBarID();
  358. int8 CheckNameFilter(const char* name, int8 min_length = 4, int8 max_length = 15);
  359. static int32 NextUniqueHotbarID(){
  360. next_id++;
  361. return next_id;
  362. }
  363. void LoadFogInit(string zone, PacketStruct* packet);
  364. static int32 next_id;
  365. void ToggleCharacterOnline();
  366. void ToggleCharacterOnline(Client* client, int8 toggle);
  367. // Zone Instance DB Functions
  368. map<int32,int32>* GetInstanceRemovedSpawns(int32 instance_id, int8 type);
  369. int32 CreateNewInstance(int32 zone_id);
  370. //int32 AddCharacterInstance(int32 char_id, int32 instance_id, int32 grant_reenter_time_left=0, int32 grant_reset_time_left=0, int32 lockout_time=0);
  371. int32 AddCharacterInstance(int32 char_id, int32 instance_id, string zone_name, int8 instance_type, int32 last_success, int32 last_failure, int32 success_lockout, int32 failure_lockout);
  372. bool UpdateCharacterInstanceTimers(int32 char_id, int32 instance_id, int32 lockout_time=0, int32 reset_time=0, int32 reenter_time=0 );
  373. bool UpdateCharacterInstance(int32 char_id, string zone_name, int32 instance_id, int8 type = 0, int32 timestamp = 0);
  374. bool VerifyInstanceID(int32 char_id, int32 instance_id);
  375. bool CheckVectorForValue(vector<int32>* vector, int32 value);
  376. int32 CheckSpawnRemoveInfo(map<int32,int32>* inmap, int32 spawn_location_entry_id);
  377. bool UpdateInstancedSpawnRemoved(int32 spawn_location_entry_id, int32 spawn_type, int32 respawn_time, int32 instance_id );
  378. int32 CreateInstanceSpawnRemoved(int32 spawn_location_entry_id, int32 spawn_type, int32 respawn_time, int32 instance_id );
  379. bool DeleteInstance(int32 instance_id);
  380. bool DeleteInstanceSpawnRemoved(int32 instance_id, int32 spawn_location_entry_id);
  381. bool DeleteCharacterFromInstance(int32 char_id, int32 instance_id);
  382. bool LoadCharacterInstances(Client* client);
  383. bool DeletePersistedRespawn(int32 zone_id, int32 spawn_location_entry_id);
  384. int32 CreatePersistedRespawn(int32 spawn_location_entry_id, int32 spawn_type, int32 respawn_time, int32 zone_id);
  385. map<int32,int32>* GetPersistedSpawns(int32 zone_id, int8 type);
  386. //
  387. MutexMap<int32, LoginEquipmentUpdate>* GetEquipmentUpdates();
  388. MutexMap<int32, LoginEquipmentUpdate>* GetEquipmentUpdates(int32 char_id);
  389. void UpdateLoginEquipment();
  390. MutexMap<int32, LoginZoneUpdate>* GetZoneUpdates();
  391. void UpdateLoginZones();
  392. void LoadLocationGrids(ZoneServer* zone);
  393. bool LoadLocationGridLocations(LocationGrid* grid);
  394. int32 CreateLocation(int32 zone_id, int32 grid_id, const char* name, bool include_y);
  395. bool AddLocationPoint(int32 location_id, float x, float y, float z);
  396. bool DeleteLocation(int32 location_id);
  397. bool DeleteLocationPoint(int32 location_point_id);
  398. void ListLocations(Client* client);
  399. void ListLocationPoints(Client* client, int32 location_id);
  400. bool LocationExists(int32 location_id);
  401. bool GetTableVersions(vector<TableVersion *> *table_versions);
  402. bool QueriesFromFile(const char *file);
  403. /* Achievements */
  404. void LoadAchievements();
  405. int32 LoadAchievementRequirements(Achievement *achievement);
  406. int32 LoadAchievementRewards(Achievement *achievement);
  407. void LoadPlayerAchievements(Player *player);
  408. int32 LoadPlayerAchievementsUpdates(Player *player);
  409. int32 LoadPlayerAchievementsUpdateItems(AchievementUpdate *update, int32 player_id);
  410. /* Alternate Advancement */
  411. void LoadAltAdvancements();
  412. void LoadTreeNodes();
  413. /* Collections */
  414. void LoadCollections();
  415. int32 LoadCollectionItems(Collection *collection);
  416. int32 LoadCollectionRewards(Collection *collection);
  417. void LoadPlayerCollections(Player *player);
  418. void LoadPlayerCollectionItems(Player *player, Collection *collection);
  419. void SavePlayerCollections(Client *client);
  420. void SavePlayerCollection(Client *client, Collection *collection);
  421. void SavePlayerCollectionItems(Client *client, Collection *collection);
  422. void SavePlayerCollectionItem(Client *client, Collection *collection, int32 item_id);
  423. /* Commands */
  424. map<int32, string>* GetSpawnTemplateListByName(const char* name);
  425. map<int32, string>* GetSpawnTemplateListByID(int32 location_id);
  426. int32 SaveSpawnTemplate(int32 placement_id, const char* template_name);
  427. bool RemoveSpawnTemplate(int32 template_id);
  428. int32 CreateSpawnFromTemplateByID(Client* client, int32 template_id);
  429. int32 CreateSpawnFromTemplateByName(Client* client, const char* template_name);
  430. bool SaveZoneSafeCoords(int32 zone_id, float x, float y, float z, float heading);
  431. bool SaveSignZoneToCoords(int32 spawn_id, float x, float y, float z, float heading);
  432. /* Guilds */
  433. void LoadGuilds();
  434. void LoadGuild(int32 guild_id);
  435. int32 LoadGuildMembers(Guild* guild);
  436. void LoadGuildEvents(Guild* guild);
  437. void LoadGuildRanks(Guild* guild);
  438. void LoadGuildEventFilters(Guild* guild);
  439. void LoadGuildPointsHistory(Guild* guild, GuildMember* guild_member);
  440. void LoadGuildRecruiting(Guild* guild);
  441. void SaveGuild(Guild* guild, bool new_guild = false);
  442. void SaveGuildMembers(Guild* guild);
  443. void SaveGuildEvents(Guild* guild);
  444. void SaveGuildRanks(Guild* guild);
  445. void SaveGuildEventFilters(Guild* guild);
  446. void SaveGuildPointsHistory(Guild* guild);
  447. void SaveGuildRecruiting(Guild* guild);
  448. void DeleteGuild(Guild* guild);
  449. void DeleteGuildMember(Guild* guild, int32 character_id);
  450. void DeleteGuildEvent(Guild* guild, int64 event_id);
  451. void DeleteGuildPointHistory(Guild* guild, int32 character_id, PointHistory* point_history);
  452. void ArchiveGuildEvent(Guild* guild, GuildEvent* guild_event);
  453. void SaveHiddenGuildEvent(Guild* guild, GuildEvent* guild_event);
  454. void LoadGuildDefaultRanks(Guild* guild);
  455. void LoadGuildDefaultEventFilters(Guild* guild);
  456. bool AddNewPlayerToServerGuild(int32 account_id, int32 char_id);
  457. int32 GetGuildIDByCharacterID(int32 char_id);
  458. /* Chat */
  459. void LoadChannels();
  460. /* Recipes */
  461. void LoadRecipes();
  462. void LoadRecipeBooks();
  463. void LoadPlayerRecipes(Player *player);
  464. int32 LoadPlayerRecipeBooks(int32 char_id, Player *player);
  465. void SavePlayerRecipeBook(Player* player, int32 recipebook_id);
  466. void LoadRecipeComponents();
  467. void UpdatePlayerRecipe(Player* player, int32 recipe_id, int8 highest_rank);
  468. void SavePlayerRecipe(Player* player, int32 recipe_id);
  469. /* Tradeskills */
  470. void LoadTradeskillEvents();
  471. /* Rules */
  472. void LoadGlobalRuleSet();
  473. void LoadRuleSets(bool reload=false);
  474. void LoadRuleSetDetails(RuleSet *rule_set);
  475. /* Titles */
  476. sint32 AddMasterTitle(const char* titleName, int8 isPrefix = 0);
  477. void LoadTitles();
  478. sint32 LoadCharacterTitles(int32 char_id, Player *player);
  479. sint32 GetCharPrefixIndex(int32 char_id, Player *player);
  480. sint32 GetCharSuffixIndex(int32 char_id, Player *player);
  481. void SaveCharPrefixIndex(sint32 index, int32 char_id);
  482. void SaveCharSuffixIndex(sint32 index, int32 char_id);
  483. sint32 AddCharacterTitle(sint32 index, int32 char_id, Spawn* player);
  484. /* Languages */
  485. void LoadLanguages();
  486. int32 LoadCharacterLanguages(int32 char_id, Player *player);
  487. int16 GetCharacterCurrentLang(int32 char_id, Player *player);
  488. void SaveCharacterCurrentLang(int32 id, int32 char_id, Client *client);
  489. void UpdateStartingLanguage(int32 char_id, uint8 race_id, int32 starting_city=0);
  490. /// <summary>Saves the given language for the given player</summary>
  491. /// <param name='char_id'>Character ID to save the language to</param>
  492. /// <param name='lang_id'>Language ID to save to the character</param>
  493. void SaveCharacterLang(int32 char_id, int32 lang_id);
  494. /* Tradeskills */
  495. /* Character History */
  496. void SaveCharacterHistory(Player* player, int8 type, int8 subtype, int32 value, int32 value2, char* location, int32 event_date);
  497. /* Housing */
  498. void LoadHouseZones();
  499. int64 AddPlayerHouse(int32 char_id, int32 house_id, int32 instance_id, int32 upkeep_due);
  500. void SetHouseUpkeepDue(int32 char_id, int32 house_id, int32 instance_id, int32 upkeep_due);
  501. void RemovePlayerHouse(int32 char_id, int32 house_id);
  502. void UpdateHouseEscrow(int32 house_id, int32 instance_id, int64 amount_coins, int32 amount_status);
  503. void LoadPlayerHouses();
  504. void LoadDeposits(PlayerHouse* house);
  505. void LoadHistory(PlayerHouse* house);
  506. void AddHistory(PlayerHouse* house, char* name, char* reason, int32 timestamp, int64 amount = 0, int32 status = 0, int8 pos_flag = 0);
  507. /* World */
  508. bool CheckBannedIPs(const char* loginIP);
  509. /* Heroic OP */
  510. void LoadHOStarters();
  511. void LoadHOWheel();
  512. /* Claim Items */
  513. void LoadClaimItems(int32 char_id);
  514. int16 CountCharClaimItems(int32 char_id);
  515. vector<ClaimItems> LoadCharacterClaimItems(int32 char_id);
  516. void ClaimItem(int32 char_id, int32 item_id, Client* client);
  517. int32 GetAccountAge(int32 account_id);
  518. /* Race Types */
  519. void LoadRaceTypes();
  520. /* Loot */
  521. void LoadLoot(ZoneServer* zone);
  522. void LoadGlobalLoot(ZoneServer* zone);
  523. bool LoadSpawnLoot(ZoneServer* zone, Spawn* spawn);
  524. void AddLootTableToSpawn(Spawn* spawn, int32 loottable_id);
  525. bool RemoveSpawnLootTable(Spawn* spawn, int32 loottable_id);
  526. void LoadCharacterHistory(int32 char_id, Player *player);
  527. void LoadSpellErrors();
  528. /* Load single spawns */
  529. bool LoadSign(ZoneServer* zone, int32 spawn_id);
  530. bool LoadWidget(ZoneServer* zone, int32 spawn_id);
  531. bool LoadObject(ZoneServer* zone, int32 spawn_id);
  532. bool LoadGroundSpawn(ZoneServer* zone, int32 spawn_id);
  533. void LoadGroundSpawnEntry(ZoneServer* zone, int32 entry_id);
  534. void LoadGroundSpawnItems(ZoneServer* zone, int32 entry_id);
  535. bool LoadNPC(ZoneServer* zone, int32 spawn_id);
  536. void LoadAppearance(ZoneServer* zone, int32 spawn_id);
  537. void LoadNPCAppearanceEquipmentData(ZoneServer* zone, int32 spawn_id);
  538. /* Save character Pictures */
  539. /// <summary>Saves the pictures that clients send to the server</summary>
  540. /// <param name='characterID'>The ID of the character</param>
  541. /// <param name='type'>The type of image this is, 0 = paperdoll, 1 = headshot</param>
  542. /// <param name='picture'>The raw png data</param>
  543. void SaveCharacterPicture(int32 characterID, int8 type, uchar* picture, int32 picture_size);
  544. /* Quests */
  545. /// <summary>Updates the given date for the quest in the DB for a repeatable quest</summary>
  546. /// <param name='client'>Client to save the quest for</param>
  547. /// <param name='quest_id'>ID of the quest to save</param>
  548. /// <param name='quest_complete_count'>Number of times the quest has already been completed</param>
  549. void SaveCharRepeatableQuest(Client* client, int32 quest_id, int16 quest_complete_count);
  550. /* Zone Flight Paths */
  551. void LoadZoneFlightPaths(ZoneServer* zone);
  552. void LoadZoneFlightPathLocations(ZoneServer* zone);
  553. /* Character LUA History */
  554. void SaveCharacterLUAHistory(Player* player, int32 event_id, int32 value, int32 value2);
  555. void LoadCharacterLUAHistory(int32 char_id, Player* player);
  556. /* Bots - BotDB.cpp */
  557. int32 CreateNewBot(int32 char_id, string name, int8 race, int8 advClass, int8 gender, int16 model_id, int32& index);
  558. void SaveBotAppearance(Bot* bot);
  559. void SaveBotColors(int32 bot_id, const char* type, EQ2_Color color);
  560. void SaveBotFloats(int32 bot_id, const char* type, float float1, float float2, float float3);
  561. bool LoadBot(int32 char_id, int32 bot_index, Bot* bot);
  562. void LoadBotAppearance(Bot* bot);
  563. void SaveBotItem(int32 bot_id, int32 item_id, int8 slot);
  564. void LoadBotEquipment(Bot* bot);
  565. string GetBotList(int32 char_id);
  566. void DeleteBot(int32 char_id, int32 bot_index);
  567. void SetBotStartingItems(Bot* bot, int8 class_id, int8 race_id);
  568. void LoadTransmuting();
  569. void FindSpell(Client* client, char* findString);
  570. void LoadChestTraps();
  571. bool CheckExpansionFlags(ZoneServer* zone, int32 spawnXpackFlag);
  572. bool CheckHolidayFlags(ZoneServer* zone, int32 spawnHolidayFlag);
  573. void GetHouseSpawnInstanceData(ZoneServer* zone, Spawn* spawn);
  574. int32 FindHouseInstanceSpawn(Spawn* spawn);
  575. /* Starting Character Abilities */
  576. void LoadStartingSkills(World* world);
  577. void LoadStartingSpells(World* world);
  578. void LoadVoiceOvers(World* world);
  579. int32 CreateSpiritShard(const char* name, int32 level, int8 race, int8 gender, int8 adventure_class,
  580. int16 model_type, int16 soga_model_type, int16 hair_type, int16 hair_face_type, int16 wing_type,
  581. int16 chest_type, int16 legs_type, int16 soga_hair_type, int16 soga_hair_face_type, int8 hide_hood,
  582. int16 size, int16 collision_radius, int16 action_state, int16 visual_state, int16 mood_state, int16 emote_state,
  583. int16 pos_state, int16 activity_status, char* sub_title, char* prefix_title, char* suffix_title, char* lastname,
  584. float x, float y, float z, float heading, int32 gridid, int32 charid, int32 zoneid, int32 instanceid);
  585. bool DeleteSpiritShard(int32 id);
  586. void LoadCharacterSpellEffects(int32 char_id, Client *client, int8 db_spell_type);
  587. int32 GetMysqlExpCurve(int level);
  588. private:
  589. DatabaseNew database_new;
  590. std::map<int32, string> zone_names;
  591. string skills;
  592. int32 max_zonename;
  593. char** zonename_array;
  594. std::map<int32, int8> zone_instance_types;
  595. };
  596. #endif