shareddb.cpp & .h header include cleanup

This commit is contained in:
Akkadius 2014-12-15 22:42:34 -06:00
parent 62d8fb538b
commit 689f95b430
2 changed files with 109 additions and 105 deletions

View File

@ -3,22 +3,20 @@
#include <cstdlib> #include <cstdlib>
#include <ctime> #include <ctime>
#include "shareddb.h"
#include "mysql.h"
#include "item.h"
#include "classes.h" #include "classes.h"
#include "rulesys.h"
#include "seperator.h"
#include "string_util.h"
#include "eq_packet_structs.h" #include "eq_packet_structs.h"
#include "guilds.h"
#include "extprofile.h"
#include "memory_mapped_file.h"
#include "ipc_mutex.h"
#include "eqemu_exception.h" #include "eqemu_exception.h"
#include "loottable.h"
#include "faction.h" #include "faction.h"
#include "features.h" #include "features.h"
#include "guilds.h"
#include "ipc_mutex.h"
#include "item.h"
#include "loottable.h"
#include "memory_mapped_file.h"
#include "mysql.h"
#include "rulesys.h"
#include "shareddb.h"
#include "string_util.h"
SharedDatabase::SharedDatabase() SharedDatabase::SharedDatabase()
: Database(), skill_caps_mmf(nullptr), items_mmf(nullptr), items_hash(nullptr), faction_mmf(nullptr), faction_hash(nullptr), : Database(), skill_caps_mmf(nullptr), items_mmf(nullptr), items_hash(nullptr), faction_mmf(nullptr), faction_hash(nullptr),

View File

@ -6,128 +6,134 @@
#include "database.h" #include "database.h"
#include "skills.h" #include "skills.h"
#include "spdat.h" #include "spdat.h"
#include "item.h"
#include "base_data.h" #include "base_data.h"
#include "fixed_memory_hash_set.h" #include "fixed_memory_hash_set.h"
#include "fixed_memory_variable_hash_set.h" #include "fixed_memory_variable_hash_set.h"
#include <list> #include <list>
class EvolveInfo;
class Inventory;
class ItemInst;
struct BaseDataStruct;
struct InspectMessage_Struct;
struct PlayerProfile_Struct;
struct SPDat_Spell_Struct;
struct Item_Struct; struct Item_Struct;
struct NPCFactionList; struct NPCFactionList;
struct Faction;
struct LootTable_Struct; struct LootTable_Struct;
struct LootDrop_Struct; struct LootDrop_Struct;
namespace EQEmu { namespace EQEmu
{
class MemoryMappedFile; class MemoryMappedFile;
} }
/* /*
* This object is inherited by world and zone's DB object, This object is inherited by world and zone's DB object,
* and is mainly here to facilitate shared memory, and other and is mainly here to facilitate shared memory, and other
* things which only world and zone need. things which only world and zone need.
*/ */
class SharedDatabase : public Database { class SharedDatabase : public Database
public: {
SharedDatabase(); public:
SharedDatabase(const char* host, const char* user, const char* passwd, const char* database,uint32 port); SharedDatabase();
virtual ~SharedDatabase(); SharedDatabase(const char* host, const char* user, const char* passwd, const char* database, uint32 port);
virtual ~SharedDatabase();
/* /*
* General Character Related Stuff General Character Related Stuff
*/ */
bool SetGMSpeed(uint32 account_id, uint8 gmspeed); bool SetGMSpeed(uint32 account_id, uint8 gmspeed);
uint8 GetGMSpeed(uint32 account_id); uint8 GetGMSpeed(uint32 account_id);
bool SetHideMe(uint32 account_id, uint8 hideme); bool SetHideMe(uint32 account_id, uint8 hideme);
int32 DeleteStalePlayerCorpses(); int32 DeleteStalePlayerCorpses();
void LoadCharacterInspectMessage(uint32 character_id, InspectMessage_Struct* message); void LoadCharacterInspectMessage(uint32 character_id, InspectMessage_Struct* message);
void SaveCharacterInspectMessage(uint32 character_id, const InspectMessage_Struct* message); void SaveCharacterInspectMessage(uint32 character_id, const InspectMessage_Struct* message);
void GetBotInspectMessage(uint32 botid, InspectMessage_Struct* message); void GetBotInspectMessage(uint32 botid, InspectMessage_Struct* message);
void SetBotInspectMessage(uint32 botid, const InspectMessage_Struct* message); void SetBotInspectMessage(uint32 botid, const InspectMessage_Struct* message);
bool GetCommandSettings(std::map<std::string,uint8> &commands); bool GetCommandSettings(std::map<std::string, uint8> &commands);
uint32 GetTotalTimeEntitledOnAccount(uint32 AccountID); uint32 GetTotalTimeEntitledOnAccount(uint32 AccountID);
/* /*
* Character Inventory Character Inventory
*/ */
bool SaveCursor(uint32 char_id, std::list<ItemInst*>::const_iterator &start, std::list<ItemInst*>::const_iterator &end); bool SaveCursor(uint32 char_id, std::list<ItemInst*>::const_iterator &start, std::list<ItemInst*>::const_iterator &end);
bool SaveInventory(uint32 char_id, const ItemInst* inst, int16 slot_id); bool SaveInventory(uint32 char_id, const ItemInst* inst, int16 slot_id);
bool DeleteSharedBankSlot(uint32 char_id, int16 slot_id); bool DeleteSharedBankSlot(uint32 char_id, int16 slot_id);
bool DeleteInventorySlot(uint32 char_id, int16 slot_id); bool DeleteInventorySlot(uint32 char_id, int16 slot_id);
bool UpdateInventorySlot(uint32 char_id, const ItemInst* inst, int16 slot_id); bool UpdateInventorySlot(uint32 char_id, const ItemInst* inst, int16 slot_id);
bool UpdateSharedBankSlot(uint32 char_id, const ItemInst* inst, int16 slot_id); bool UpdateSharedBankSlot(uint32 char_id, const ItemInst* inst, int16 slot_id);
bool VerifyInventory(uint32 account_id, int16 slot_id, const ItemInst* inst); bool VerifyInventory(uint32 account_id, int16 slot_id, const ItemInst* inst);
bool GetSharedBank(uint32 id, Inventory* inv, bool is_charid); bool GetSharedBank(uint32 id, Inventory* inv, bool is_charid);
int32 GetSharedPlatinum(uint32 account_id); int32 GetSharedPlatinum(uint32 account_id);
bool SetSharedPlatinum(uint32 account_id, int32 amount_to_add); bool SetSharedPlatinum(uint32 account_id, int32 amount_to_add);
bool GetInventory(uint32 char_id, Inventory* inv); bool GetInventory(uint32 char_id, Inventory* inv);
bool GetInventory(uint32 account_id, char* name, Inventory* inv); bool GetInventory(uint32 account_id, char* name, Inventory* inv);
bool SetStartingItems(PlayerProfile_Struct* pp, Inventory* inv, uint32 si_race, uint32 si_class, uint32 si_deity, uint32 si_current_zone, char* si_name, int admin); bool SetStartingItems(PlayerProfile_Struct* pp, Inventory* inv, uint32 si_race, uint32 si_class, uint32 si_deity, uint32 si_current_zone, char* si_name, int admin);
std::string GetBook(const char *txtfile); std::string GetBook(const char *txtfile);
/* /*
* Item Methods Item Methods
*/ */
ItemInst* CreateItem(uint32 item_id, int16 charges = 0, uint32 aug1 = 0, uint32 aug2 = 0, uint32 aug3 = 0, uint32 aug4 = 0, uint32 aug5 = 0, uint32 aug6 = 0, uint8 attuned = 0); ItemInst* CreateItem(uint32 item_id, int16 charges = 0, uint32 aug1 = 0, uint32 aug2 = 0, uint32 aug3 = 0, uint32 aug4 = 0, uint32 aug5 = 0, uint32 aug6 = 0, uint8 attuned = 0);
ItemInst* CreateItem(const Item_Struct* item, int16 charges = 0, uint32 aug1 = 0, uint32 aug2 = 0, uint32 aug3 = 0, uint32 aug4 = 0, uint32 aug5 = 0, uint32 aug6 = 0, uint8 attuned = 0); ItemInst* CreateItem(const Item_Struct* item, int16 charges = 0, uint32 aug1 = 0, uint32 aug2 = 0, uint32 aug3 = 0, uint32 aug4 = 0, uint32 aug5 = 0, uint32 aug6 = 0, uint8 attuned = 0);
ItemInst* CreateBaseItem(const Item_Struct* item, int16 charges=0); ItemInst* CreateBaseItem(const Item_Struct* item, int16 charges = 0);
/* /*
* Shared Memory crap Shared Memory crap
*/ */
//items //items
void GetItemsCount(int32 &item_count, uint32 &max_id); void GetItemsCount(int32 &item_count, uint32 &max_id);
void LoadItems(void *data, uint32 size, int32 items, uint32 max_item_id); void LoadItems(void *data, uint32 size, int32 items, uint32 max_item_id);
bool LoadItems(); bool LoadItems();
const Item_Struct* IterateItems(uint32* id); const Item_Struct* IterateItems(uint32* id);
const Item_Struct* GetItem(uint32 id); const Item_Struct* GetItem(uint32 id);
const EvolveInfo* GetEvolveInfo(uint32 loregroup); const EvolveInfo* GetEvolveInfo(uint32 loregroup);
//faction lists //faction lists
void GetFactionListInfo(uint32 &list_count, uint32 &max_lists); void GetFactionListInfo(uint32 &list_count, uint32 &max_lists);
const NPCFactionList* GetNPCFactionEntry(uint32 id); const NPCFactionList* GetNPCFactionEntry(uint32 id);
void LoadNPCFactionLists(void *data, uint32 size, uint32 list_count, uint32 max_lists); void LoadNPCFactionLists(void *data, uint32 size, uint32 list_count, uint32 max_lists);
bool LoadNPCFactionLists(); bool LoadNPCFactionLists();
//loot //loot
void GetLootTableInfo(uint32 &loot_table_count, uint32 &max_loot_table, uint32 &loot_table_entries); void GetLootTableInfo(uint32 &loot_table_count, uint32 &max_loot_table, uint32 &loot_table_entries);
void GetLootDropInfo(uint32 &loot_drop_count, uint32 &max_loot_drop, uint32 &loot_drop_entries); void GetLootDropInfo(uint32 &loot_drop_count, uint32 &max_loot_drop, uint32 &loot_drop_entries);
void LoadLootTables(void *data, uint32 size); void LoadLootTables(void *data, uint32 size);
void LoadLootDrops(void *data, uint32 size); void LoadLootDrops(void *data, uint32 size);
bool LoadLoot(); bool LoadLoot();
const LootTable_Struct* GetLootTable(uint32 loottable_id); const LootTable_Struct* GetLootTable(uint32 loottable_id);
const LootDrop_Struct* GetLootDrop(uint32 lootdrop_id); const LootDrop_Struct* GetLootDrop(uint32 lootdrop_id);
void LoadSkillCaps(void *data); void LoadSkillCaps(void *data);
bool LoadSkillCaps(); bool LoadSkillCaps();
uint16 GetSkillCap(uint8 Class_, SkillUseTypes Skill, uint8 Level); uint16 GetSkillCap(uint8 Class_, SkillUseTypes Skill, uint8 Level);
uint8 GetTrainLevel(uint8 Class_, SkillUseTypes Skill, uint8 Level); uint8 GetTrainLevel(uint8 Class_, SkillUseTypes Skill, uint8 Level);
int GetMaxSpellID(); int GetMaxSpellID();
void LoadSpells(void *data, int max_spells); void LoadSpells(void *data, int max_spells);
void LoadDamageShieldTypes(SPDat_Spell_Struct* sp, int32 iMaxSpellID); void LoadDamageShieldTypes(SPDat_Spell_Struct* sp, int32 iMaxSpellID);
int GetMaxBaseDataLevel(); int GetMaxBaseDataLevel();
bool LoadBaseData(); bool LoadBaseData();
void LoadBaseData(void *data, int max_level); void LoadBaseData(void *data, int max_level);
const BaseDataStruct* GetBaseData(int lvl, int cl); const BaseDataStruct* GetBaseData(int lvl, int cl);
protected: protected:
EQEmu::MemoryMappedFile *skill_caps_mmf; EQEmu::MemoryMappedFile *skill_caps_mmf;
EQEmu::MemoryMappedFile *items_mmf; EQEmu::MemoryMappedFile *items_mmf;
EQEmu::FixedMemoryHashSet<Item_Struct> *items_hash; EQEmu::FixedMemoryHashSet<Item_Struct> *items_hash;
EQEmu::MemoryMappedFile *faction_mmf; EQEmu::MemoryMappedFile *faction_mmf;
EQEmu::FixedMemoryHashSet<NPCFactionList> *faction_hash; EQEmu::FixedMemoryHashSet<NPCFactionList> *faction_hash;
EQEmu::MemoryMappedFile *loot_table_mmf; EQEmu::MemoryMappedFile *loot_table_mmf;
EQEmu::FixedMemoryVariableHashSet<LootTable_Struct> *loot_table_hash; EQEmu::FixedMemoryVariableHashSet<LootTable_Struct> *loot_table_hash;
EQEmu::MemoryMappedFile *loot_drop_mmf; EQEmu::MemoryMappedFile *loot_drop_mmf;
EQEmu::FixedMemoryVariableHashSet<LootDrop_Struct> *loot_drop_hash; EQEmu::FixedMemoryVariableHashSet<LootDrop_Struct> *loot_drop_hash;
EQEmu::MemoryMappedFile *base_data_mmf; EQEmu::MemoryMappedFile *base_data_mmf;
}; };
#endif /*SHAREDDB_H_*/ #endif /*SHAREDDB_H_*/