WorldDatabase.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  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. using namespace std;
  47. #define APPEARANCE_SOGA_HFHC 0
  48. #define APPEARANCE_SOGA_HTHC 1
  49. #define APPEARANCE_SOGA_HFC 2
  50. #define APPEARANCE_SOGA_HTC 3
  51. #define APPEARANCE_SOGA_HH 4
  52. #define APPEARANCE_SOGA_HC1 5
  53. #define APPEARANCE_SOGA_HC2 6
  54. #define APPEARANCE_SOGA_SC 7
  55. #define APPEARANCE_SOGA_EC 8
  56. #define APPEARANCE_HTHC 9
  57. #define APPEARANCE_HFHC 10
  58. #define APPEARANCE_HTC 11
  59. #define APPEARANCE_HFC 12
  60. #define APPEARANCE_HH 13
  61. #define APPEARANCE_HC1 14
  62. #define APPEARANCE_HC2 15
  63. #define APPEARANCE_WC1 16
  64. #define APPEARANCE_WC2 17
  65. #define APPEARANCE_SC 18
  66. #define APPEARANCE_EC 19
  67. #define APPEARANCE_SHIRT 20
  68. #define APPEARANCE_UCC 21
  69. #define APPEARANCE_PANTS 22
  70. #define APPEARANCE_ULC 23
  71. #define APPEARANCE_U9 24
  72. #define APPEARANCE_BODY_SIZE 25
  73. #define APPEARANCE_SOGA_WC1 26
  74. #define APPEARANCE_SOGA_WC2 27
  75. #define APPEARANCE_SOGA_SHIRT 28
  76. #define APPEARANCE_SOGA_UCC 29
  77. #define APPEARANCE_SOGA_PANTS 30
  78. #define APPEARANCE_SOGA_ULC 31
  79. #define APPEARANCE_SOGA_U13 32
  80. #define APPEARANCE_SOGA_EBT 33
  81. #define APPEARANCE_SOGA_CHEEKT 34
  82. #define APPEARANCE_SOGA_NT 35
  83. #define APPEARANCE_SOGA_CHINT 36
  84. #define APPEARANCE_SOGA_LT 37
  85. #define APPEARANCE_SOGA_EART 38
  86. #define APPEARANCE_SOGA_EYET 39
  87. #define APPEARANCE_EBT 40
  88. #define APPEARANCE_CHEEKT 41
  89. #define APPEARANCE_NT 42
  90. #define APPEARANCE_CHINT 43
  91. #define APPEARANCE_EART 44
  92. #define APPEARANCE_EYET 45
  93. #define APPEARANCE_LT 46
  94. #define APPEARANCE_BODY_AGE 47
  95. #define CHAR_PROPERTY_SPEED "modify_speed"
  96. #define CHAR_PROPERTY_FLYMODE "modify_flymode"
  97. #define CHAR_PROPERTY_INVUL "modify_invul"
  98. #define CHAR_PROPERTY_GMVISION "modify_gmvision"
  99. #define CHAR_PROPERTY_LUADEBUG "modify_luadebug"
  100. struct StartingItem{
  101. string type;
  102. int32 item_id;
  103. string creator;
  104. int8 condition;
  105. int8 attuned;
  106. int16 count;
  107. };
  108. class Bot;
  109. class WorldDatabase : public Database {
  110. public:
  111. WorldDatabase();
  112. ~WorldDatabase();
  113. bool ConnectNewDatabase();
  114. void PingNewDB();
  115. string* GetZoneName(int32 id);
  116. string GetZoneDescription(int32 id);
  117. int32 LoadCharacterSkills(int32 char_id, Player* player);
  118. void DeleteCharacterSkill(int32 char_id, Skill* skill);
  119. void DeleteCharacterSpell(int32 character_id, int32 spell_id);
  120. int32 LoadCharacterSpells(int32 char_id, Player* player);
  121. int32 LoadItemBlueStats();
  122. void SaveQuickBar(int32 char_id, vector<QuickBarItem*>* quickbar_items);
  123. void SavePlayerSpells(Client* client);
  124. int32 LoadSkills();
  125. void LoadCommandList();
  126. map<int8, vector<MacroData*> >* LoadCharacterMacros(int32 char_id);
  127. void UpdateCharacterMacro(int32 char_id, int8 number, const char* name, int16 icon, vector<string>* updates);
  128. void SaveWorldTime(WorldTime* time);
  129. bool SaveSpawnInfo(Spawn* spawn);
  130. int32 GetNextSpawnIDInZone(int32 zone_id);
  131. 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);
  132. float GetSpawnLocationPlacementOffsetX(int32 location_id);
  133. float GetSpawnLocationPlacementOffsetY(int32 location_id);
  134. float GetSpawnLocationPlacementOffsetZ(int32 location_id);
  135. int32 GetNextSpawnLocation();
  136. bool CreateNewSpawnLocation(int32 id, const char* name);
  137. bool RemoveSpawnFromSpawnLocation(Spawn* spawn);
  138. int32 GetSpawnLocationCount(int32 location, Spawn* spawn = 0);
  139. vector<string>* GetSpawnNameList(const char* in_name);
  140. void LoadSubCommandList();
  141. void LoadGlobalVariables();
  142. void UpdateVitality(int32 timestamp, float amount);
  143. void SaveVariable(const char* name, const char* value, const char* comment);
  144. void LoadVisualStates();
  145. void LoadAppearanceMasterList();
  146. void Save(Client* client);
  147. void SaveItems(Client* client);
  148. void SaveItem(int32 account_id, int32 char_id, Item* item, const char* type);
  149. void DeleteBuyBack(int32 char_id, int32 item_id, int16 quantity, int32 price);
  150. void LoadBuyBacks(Client* client);
  151. void SaveBuyBacks(Client* client);
  152. void SaveBuyBack(int32 char_id, int32 item_id, int16 quantity, int32 price);
  153. void DeleteItem(int32 char_id, Item* item, const char* type);
  154. void SaveCharacterColors(int32 char_id, const char* type, EQ2_Color color);
  155. void SaveCharacterFloats(int32 char_id, const char* type, float float1, float float2, float float3);
  156. int16 GetAppearanceID(string name);
  157. vector<int16>* GetAppearanceIDsLikeName(string name, bool filtered = true);
  158. string GetAppearanceName(int16 appearance_id);
  159. void UpdateRandomize(int32 spawn_id, sint32 value);
  160. int32 SaveCharacter(PacketStruct* create, int32 loginID);
  161. int32 LoadNPCAppearanceEquipmentData(ZoneServer* zone);
  162. 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);
  163. void LoadSpecialZones();
  164. void SaveCharacterSkills(Client* client);
  165. void SaveCharacterQuests(Client* client);
  166. void SaveCharacterQuestProgress(Client* client, Quest* quest);
  167. void DeleteCharacterQuest(int32 quest_id, int32 char_id, bool repeated_quest = false);
  168. void LoadCharacterQuests(Client* client);
  169. void LoadPlayerAA(Player *player);
  170. void LoadCharacterQuestProgress(Client* client);
  171. void LoadCharacterFriendsIgnoreList(Player* player);
  172. void LoadZoneInfo(ZoneServer* zone);
  173. void LoadZoneInfo(ZoneInfo* zone_info);
  174. int32 GetZoneID(const char* name);
  175. void SaveZoneInfo(int32 zone_id, const char* field, sint32 value);
  176. void SaveZoneInfo(int32 zone_id, const char* field, float value);
  177. void SaveZoneInfo(int32 zone_id, const char* field, const char* value);
  178. bool GetZoneRequirements(const char* zoneName,sint16* minStatus, int16* minLevel, int16* maxLevel, int16* minVersion);
  179. int16 GetMinimumClientVersion(int8 expansion_id);
  180. string GetExpansionIDByVersion(int16 version);
  181. int32 CheckTableVersions(char* tablename);
  182. bool RunDatabaseQueries(TableQuery* queries, bool output_result = true, bool data = false);
  183. void UpdateTableVersion(char* name, int32 version);
  184. void UpdateDataTableVersion(char* name, int32 version);
  185. void UpdateStartingFactions(int32 char_id, int8 choice);
  186. string GetStartingZoneName(int8 choice);
  187. void UpdateStartingZone(int32 char_id, int8 class_id, int8 race_id, int8 choice);
  188. void UpdateStartingItems(int32 char_id, int8 class_id, int8 race_id, bool base_class = false);
  189. void UpdateStartingSkills(int32 char_id, int8 class_id, int8 race_id);
  190. void UpdateStartingSpells(int32 char_id, int8 class_id, int8 race_id);
  191. void UpdateStartingSkillbar(int32 char_id, int8 class_id, int8 race_id);
  192. void UpdateStartingTitles(int32 char_id, int8 class_id, int8 race_id, int8 gender_id);
  193. bool UpdateSpawnLocationSpawns(Spawn* spawn);
  194. bool UpdateSpawnWidget(int32 widget_id, char* query);
  195. bool CheckVersionTable();
  196. void LoadFactionAlliances();
  197. void LoadFactionList();
  198. bool LoadPlayerFactions(Client* client);
  199. void SavePlayerFactions(Client* client);
  200. void LoadSpawnScriptData();
  201. void LoadZoneScriptData();
  202. int32 LoadSpellScriptData();
  203. bool UpdateSpawnScriptData(int32 spawn_id, int32 spawn_location_id, int32 spawnentry_id, const char* name);
  204. map<int32, string>* GetZoneList(const char* name, bool is_admin = false);
  205. bool VerifyZone(const char* name);
  206. int8 GetInstanceTypeByZoneID(int32 zoneID);
  207. /*void loadNPCAppearance(int32 appearance_id);
  208. void LoadNPCAppearances();*/
  209. void ResetDatabase();
  210. void EnableConstraints();
  211. void DisableConstraints();
  212. int32 SaveCombinedSpawnLocation(ZoneServer* zone, Spawn* spawn, const char* name);
  213. int32 ProcessSpawnLocations(ZoneServer* zone, const char* sql_query, int8 type);
  214. int32 LoadSpawnLocationGroupAssociations(ZoneServer* zone);
  215. int32 LoadSpawnLocationGroups(ZoneServer* zone);
  216. int32 LoadSpawnGroupChances(ZoneServer* zone);
  217. bool SpawnGroupAddAssociation(int32 group1, int32 group2);
  218. bool SpawnGroupRemoveAssociation(int32 group1, int32 group2);
  219. bool SpawnGroupAddSpawn(Spawn* spawn, int32 group_id);
  220. bool SpawnGroupRemoveSpawn(Spawn* spawn, int32 group_id);
  221. int32 CreateSpawnGroup(Spawn* spawn, string name);
  222. void DeleteSpawnGroup(int32 id);
  223. bool SetGroupSpawnChance(int32 id, float chance);
  224. void LoadGroundSpawnEntries(ZoneServer* zone);
  225. void LoadGroundSpawnItems(ZoneServer* zone);
  226. void LoadSpawns(ZoneServer* zone);
  227. int8 GetAppearanceType(string type);
  228. void LoadNPCs(ZoneServer* zone);
  229. int32 LoadAppearances(ZoneServer* zone, Client* client = 0);
  230. int32 LoadNPCSpells(ZoneServer* zone);
  231. int32 LoadNPCSkills(ZoneServer* zone);
  232. int32 LoadNPCEquipment(ZoneServer* zone);
  233. void LoadObjects(ZoneServer* zone);
  234. void LoadGroundSpawns(ZoneServer* zone);
  235. void LoadWidgets(ZoneServer* zone);
  236. void LoadSigns(ZoneServer* zone);
  237. void ReloadItemList();
  238. void LoadItemList();
  239. int32 LoadItemStats();
  240. int32 LoadItemAppearances();
  241. int32 LoadItemLevelOverride();
  242. int32 LoadItemEffects();
  243. int32 LoadBookPages();
  244. int32 LoadNextUniqueItemID();
  245. int32 LoadSkillItems();
  246. int32 LoadRangeWeapons();
  247. int32 LoadThrownWeapons();
  248. int32 LoadBaubles();
  249. int32 LoadBooks();
  250. int32 LoadItemsets();
  251. int32 LoadHouseItem();
  252. int32 LoadRecipeBookItems();
  253. int32 LoadArmor();
  254. int32 LoadAdornments();
  255. int32 LoadClassifications();
  256. int32 LoadShields();
  257. int32 LoadBags();
  258. int32 LoadFoods();
  259. int32 LoadWeapons();
  260. int32 LoadRanged();
  261. int32 LoadHouseContainers();
  262. map<int32, vector<LevelArray*> >* LoadSpellClasses();
  263. void LoadTransporters(ZoneServer* zone);
  264. void LoadTransportMaps(ZoneServer* zone);
  265. void LoadDataFromRow(MYSQL_ROW row, Item* item); // JA - eventually get rid of this function when all DB calls are converted
  266. void LoadDataFromRow(DatabaseResult *result, Item* item);
  267. void LoadCharacterItemList(int32 account_id, int32 char_id, Player* player, int16);
  268. bool loadCharacter(const char* name, int32 account_id, Client* client);
  269. bool LoadCharacterStats(int32 id, int32 account_id, Client* client);
  270. bool InsertCharacterStats(int32 character_id, int8 class_id, int8 race_id);
  271. bool UpdateCharacterTimeStamp(int32 account_id, int32 character_id, int32 timestamp);
  272. bool insertCharacterProperty(Client* client, char* propName, char* propValue);
  273. bool loadCharacterProperties(Client* client);
  274. string GetPlayerName(char* name);
  275. int32 GetCharacterTimeStamp(int32 character_id, int32 account_id,bool* char_exists);
  276. int32 GetCharacterTimeStamp(int32 character_id);
  277. sint32 GetLatestDataTableVersion(char* name);
  278. sint16 GetLowestCharacterAdminStatus(int32 account_id);
  279. sint16 GetHighestCharacterAdminStatus(int32 account_id);
  280. sint16 GetCharacterAdminStatus(char* character_name);
  281. sint16 GetCharacterAdminStatus(int32 account_id , int32 char_id);
  282. bool UpdateAdminStatus(char* character_name, sint16 flag);
  283. void LoadMerchantInformation();
  284. void LoadMerchantInventory();
  285. string GetMerchantDescription(int32 merchant_id);
  286. void LoadPlayerStatistics(Player* player, int32 char_id);
  287. void WritePlayerStatistic(Player* player, Statistic* stat);
  288. void LoadServerStatistics();
  289. void WriteServerStatistic(Statistic* stat);
  290. void WriteServerStatistic(int32 stat_id, sint32 stat_value);
  291. void WriteServerStatisticsNeededQueries();
  292. void SavePlayerMail(Mail* mail);
  293. void SavePlayerMail(Client* client);
  294. void LoadPlayerMail(Client* client, bool new_only = false);
  295. void DeletePlayerMail(Mail* mail);
  296. vector<int32>* GetAllPlayerIDs();
  297. void GetPetNames(ZoneServer* zone);
  298. //void LoadMerchantMultipliers();
  299. char* GetCharacterName(int32 character_id);
  300. int8 GetCharacterLevel(int32 character_id);
  301. int16 GetCharacterModelType(int32 character_id);
  302. int8 GetCharacterClass(int32 character_id);
  303. int8 GetCharacterGender(int32 character_id);
  304. int32 GetCharacterID(const char* name);
  305. int32 GetCharacterCurrentZoneID(int32 character_id);
  306. int32 GetCharacterAccountID(int32 character_id);
  307. void LoadEntityCommands(ZoneServer* zone);
  308. void LoadSpells();
  309. void LoadSpellEffects();
  310. void LoadSpellLuaData();
  311. void LoadTraits();
  312. int32 LoadPlayerSkillbar(Client* client);
  313. string GetColumnNames(char* name);
  314. string GetZoneName(char* zone_description);
  315. bool GetItemResultsToClient (Client* client, const char* varSearch, int maxResults=20);
  316. void LoadRevivePoints(vector<RevivePoint*>* revive_points, int32 zone_id);
  317. 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);
  318. void FixBugReport();
  319. int32 LoadQuests();
  320. void LoadQuestDetails(Quest* quest);
  321. bool DeleteCharacter(int32 account_id, int32 character_id);
  322. int32 GetMaxHotBarID();
  323. int8 CheckNameFilter(const char* name);
  324. static int32 NextUniqueHotbarID(){
  325. next_id++;
  326. return next_id;
  327. }
  328. void LoadFogInit(string zone, PacketStruct* packet);
  329. static int32 next_id;
  330. void ToggleCharacterOnline();
  331. void ToggleCharacterOnline(Client* client, int8 toggle);
  332. // Zone Instance DB Functions
  333. map<int32,int32>* GetInstanceRemovedSpawns(int32 instance_id, int8 type);
  334. int32 CreateNewInstance(int32 zone_id);
  335. //int32 AddCharacterInstance(int32 char_id, int32 instance_id, int32 grant_reenter_time_left=0, int32 grant_reset_time_left=0, int32 lockout_time=0);
  336. 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);
  337. bool UpdateCharacterInstanceTimers(int32 char_id, int32 instance_id, int32 lockout_time=0, int32 reset_time=0, int32 reenter_time=0 );
  338. bool UpdateCharacterInstance(int32 char_id, string zone_name, int32 instance_id, int8 type = 0, int32 timestamp = 0);
  339. bool VerifyInstanceID(int32 char_id, int32 instance_id);
  340. bool CheckVectorForValue(vector<int32>* vector, int32 value);
  341. int32 CheckSpawnRemoveInfo(map<int32,int32>* inmap, int32 spawn_location_entry_id);
  342. bool UpdateInstancedSpawnRemoved(int32 spawn_location_entry_id, int32 spawn_type, int32 respawn_time, int32 instance_id );
  343. int32 CreateInstanceSpawnRemoved(int32 spawn_location_entry_id, int32 spawn_type, int32 respawn_time, int32 instance_id );
  344. bool DeleteInstance(int32 instance_id);
  345. bool DeleteInstanceSpawnRemoved(int32 instance_id, int32 spawn_location_entry_id);
  346. bool DeleteCharacterFromInstance(int32 char_id, int32 instance_id);
  347. bool LoadCharacterInstances(Client* client);
  348. //
  349. MutexMap<int32, LoginEquipmentUpdate>* GetEquipmentUpdates();
  350. MutexMap<int32, LoginEquipmentUpdate>* GetEquipmentUpdates(int32 char_id);
  351. void UpdateLoginEquipment();
  352. MutexMap<int32, LoginZoneUpdate>* GetZoneUpdates();
  353. void UpdateLoginZones();
  354. void LoadLocationGrids(ZoneServer* zone);
  355. bool LoadLocationGridLocations(LocationGrid* grid);
  356. int32 CreateLocation(int32 zone_id, int32 grid_id, const char* name, bool include_y);
  357. bool AddLocationPoint(int32 location_id, float x, float y, float z);
  358. bool DeleteLocation(int32 location_id);
  359. bool DeleteLocationPoint(int32 location_point_id);
  360. void ListLocations(Client* client);
  361. void ListLocationPoints(Client* client, int32 location_id);
  362. bool LocationExists(int32 location_id);
  363. bool GetTableVersions(vector<TableVersion *> *table_versions);
  364. bool QueriesFromFile(const char *file);
  365. /* Achievements */
  366. void LoadAchievements();
  367. int32 LoadAchievementRequirements(Achievement *achievement);
  368. int32 LoadAchievementRewards(Achievement *achievement);
  369. void LoadPlayerAchievements(Player *player);
  370. int32 LoadPlayerAchievementsUpdates(Player *player);
  371. int32 LoadPlayerAchievementsUpdateItems(AchievementUpdate *update, int32 player_id);
  372. /* Alternate Advancement */
  373. void LoadAltAdvancements();
  374. void LoadTreeNodes();
  375. /* Collections */
  376. void LoadCollections();
  377. int32 LoadCollectionItems(Collection *collection);
  378. int32 LoadCollectionRewards(Collection *collection);
  379. void LoadPlayerCollections(Player *player);
  380. void LoadPlayerCollectionItems(Player *player, Collection *collection);
  381. void SavePlayerCollections(Client *client);
  382. void SavePlayerCollection(Client *client, Collection *collection);
  383. void SavePlayerCollectionItems(Client *client, Collection *collection);
  384. void SavePlayerCollectionItem(Client *client, Collection *collection, int32 item_id);
  385. /* Commands */
  386. map<int32, string>* GetSpawnTemplateListByName(const char* name);
  387. map<int32, string>* GetSpawnTemplateListByID(int32 location_id);
  388. int32 SaveSpawnTemplate(int32 placement_id, const char* template_name);
  389. bool RemoveSpawnTemplate(int32 template_id);
  390. int32 CreateSpawnFromTemplateByID(Client* client, int32 template_id);
  391. int32 CreateSpawnFromTemplateByName(Client* client, const char* template_name);
  392. bool SaveZoneSafeCoords(int32 zone_id, float x, float y, float z, float heading);
  393. bool SaveSignZoneToCoords(int32 spawn_id, float x, float y, float z, float heading);
  394. /* Guilds */
  395. void LoadGuilds();
  396. int32 LoadGuildMembers(Guild* guild);
  397. void LoadGuildEvents(Guild* guild);
  398. void LoadGuildRanks(Guild* guild);
  399. void LoadGuildEventFilters(Guild* guild);
  400. void LoadGuildPointsHistory(Guild* guild, GuildMember* guild_member);
  401. void LoadGuildRecruiting(Guild* guild);
  402. void SaveGuild(Guild* guild, bool new_guild = false);
  403. void SaveGuildMembers(Guild* guild);
  404. void SaveGuildEvents(Guild* guild);
  405. void SaveGuildRanks(Guild* guild);
  406. void SaveGuildEventFilters(Guild* guild);
  407. void SaveGuildPointsHistory(Guild* guild);
  408. void SaveGuildRecruiting(Guild* guild);
  409. void DeleteGuild(Guild* guild);
  410. void DeleteGuildMember(Guild* guild, int32 character_id);
  411. void DeleteGuildEvent(Guild* guild, int64 event_id);
  412. void DeleteGuildPointHistory(Guild* guild, int32 character_id, PointHistory* point_history);
  413. void ArchiveGuildEvent(Guild* guild, GuildEvent* guild_event);
  414. void SaveHiddenGuildEvent(Guild* guild, GuildEvent* guild_event);
  415. void LoadGuildDefaultRanks(Guild* guild);
  416. void LoadGuildDefaultEventFilters(Guild* guild);
  417. bool AddNewPlayerToServerGuild(int32 account_id, int32 char_id);
  418. int32 GetGuildIDByCharacterID(int32 char_id);
  419. /* Chat */
  420. void LoadChannels();
  421. /* Recipes */
  422. void LoadRecipes();
  423. void LoadRecipeBooks();
  424. void LoadPlayerRecipes(Player *player);
  425. int32 LoadPlayerRecipeBooks(int32 char_id, Player *player);
  426. void SavePlayerRecipeBook(Player* player, int32 recipebook_id);
  427. void LoadRecipeComponents();
  428. void LoadRecipeProducts();
  429. void UpdatePlayerRecipe(Player* player, int32 recipe_id, int8 highest_rank);
  430. void SavePlayerRecipe(Player* player, int32 recipe_id);
  431. /* Tradeskills */
  432. void LoadTradeskillEvents();
  433. /* Rules */
  434. void LoadGlobalRuleSet();
  435. void LoadRuleSets();
  436. void LoadRuleSetDetails(RuleSet *rule_set);
  437. /* Titles */
  438. void LoadTitles();
  439. int32 LoadCharacterTitles(int32 char_id, Player *player);
  440. sint16 GetCharPrefixIndex(int32 char_id, Player *player);
  441. sint16 GetCharSuffixIndex(int32 char_id, Player *player);
  442. void SaveCharPrefixIndex(sint16 index, int32 char_id, Client *client);
  443. void SaveCharSuffixIndex(sint16 index, int32 char_id, Client *client);
  444. /* Languages */
  445. void LoadLanguages();
  446. int32 LoadCharacterLanguages(int32 char_id, Player *player);
  447. int16 GetCharacterCurrentLang(int32 char_id, Player *player);
  448. void SaveCharacterCurrentLang(int32 id, int32 char_id, Client *client);
  449. /// <summary>Saves the given language for the given player</summary>
  450. /// <param name='char_id'>Character ID to save the language to</param>
  451. /// <param name='lang_id'>Language ID to save to the character</param>
  452. void SaveCharacterLang(int32 char_id, int32 lang_id);
  453. /* Tradeskills */
  454. /* Character History */
  455. void SaveCharacterHistory(Player* player, int8 type, int8 subtype, int32 value, int32 value2, char* location, int32 event_date);
  456. /* Housing */
  457. void LoadHouseZones();
  458. int64 AddPlayerHouse(int32 char_id, int32 house_id, int32 instance_id, int32 upkeep_due);
  459. void SetHouseUpkeepDue(int32 char_id, int32 house_id, int32 instance_id, int32 upkeep_due);
  460. void RemovePlayerHouse(int32 char_id, int32 house_id);
  461. void LoadPlayerHouses();
  462. /* World */
  463. bool CheckBannedIPs(const char* loginIP);
  464. /* Heroic OP */
  465. void LoadHOStarters();
  466. void LoadHOWheel();
  467. /* Race Types */
  468. void LoadRaceTypes();
  469. /* Loot */
  470. void LoadLoot(ZoneServer* zone);
  471. void LoadGlobalLoot(ZoneServer* zone);
  472. bool LoadSpawnLoot(ZoneServer* zone, Spawn* spawn);
  473. void AddLootTableToSpawn(Spawn* spawn, int32 loottable_id);
  474. bool RemoveSpawnLootTable(Spawn* spawn, int32 loottable_id);
  475. void LoadCharacterHistory(int32 char_id, Player *player);
  476. void LoadSpellErrors();
  477. /* Load single spawns */
  478. bool LoadSign(ZoneServer* zone, int32 spawn_id);
  479. bool LoadWidget(ZoneServer* zone, int32 spawn_id);
  480. bool LoadObject(ZoneServer* zone, int32 spawn_id);
  481. bool LoadGroundSpawn(ZoneServer* zone, int32 spawn_id);
  482. void LoadGroundSpawnEntry(ZoneServer* zone, int32 entry_id);
  483. void LoadGroundSpawnItems(ZoneServer* zone, int32 entry_id);
  484. bool LoadNPC(ZoneServer* zone, int32 spawn_id);
  485. void LoadAppearance(ZoneServer* zone, int32 spawn_id);
  486. void LoadNPCAppearanceEquipmentData(ZoneServer* zone, int32 spawn_id);
  487. /* Save character Pictures */
  488. /// <summary>Saves the pictures that clients send to the server</summary>
  489. /// <param name='characterID'>The ID of the character</param>
  490. /// <param name='type'>The type of image this is, 0 = paperdoll, 1 = headshot</param>
  491. /// <param name='picture'>The raw png data</param>
  492. void SaveCharacterPicture(int32 characterID, int8 type, uchar* picture, int32 picture_size);
  493. /* Quests */
  494. /// <summary>Updates the given date for the quest in the DB for a repeatable quest</summary>
  495. /// <param name='client'>Client to save the quest for</param>
  496. /// <param name='quest_id'>ID of the quest to save</param>
  497. /// <param name='quest_complete_count'>Number of times the quest has already been completed</param>
  498. void SaveCharRepeatableQuest(Client* client, int32 quest_id, int16 quest_complete_count);
  499. /* Zone Flight Paths */
  500. void LoadZoneFlightPaths(ZoneServer* zone);
  501. void LoadZoneFlightPathLocations(ZoneServer* zone);
  502. /* Character LUA History */
  503. void SaveCharacterLUAHistory(Player* player, int32 event_id, int32 value, int32 value2);
  504. void LoadCharacterLUAHistory(int32 char_id, Player* player);
  505. /* Bots - BotDB.cpp */
  506. int32 CreateNewBot(int32 char_id, string name, int8 race, int8 advClass, int8 gender, int16 model_id, int32& index);
  507. void SaveBotAppearance(Bot* bot);
  508. void SaveBotColors(int32 bot_id, const char* type, EQ2_Color color);
  509. void SaveBotFloats(int32 bot_id, const char* type, float float1, float float2, float float3);
  510. bool LoadBot(int32 char_id, int32 bot_index, Bot* bot);
  511. void LoadBotAppearance(Bot* bot);
  512. void SaveBotItem(int32 bot_id, int32 item_id, int8 slot);
  513. void LoadBotEquipment(Bot* bot);
  514. string GetBotList(int32 char_id);
  515. void DeleteBot(int32 char_id, int32 bot_index);
  516. void SetBotStartingItems(Bot* bot, int8 class_id, int8 race_id);
  517. void LoadTransmuting();
  518. void FindSpell(Client* client, char* findString);
  519. void LoadChestTraps();
  520. bool CheckExpansionFlags(ZoneServer* zone, int32 spawnXpackFlag);
  521. void GetHouseSpawnInstanceData(ZoneServer* zone, Spawn* spawn);
  522. int32 FindHouseInstanceSpawn(Spawn* spawn);
  523. private:
  524. DatabaseNew database_new;
  525. map<int32, string> zone_names;
  526. string skills;
  527. int32 max_zonename;
  528. char** zonename_array;
  529. };
  530. #endif