WorldDatabase.h 26 KB

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