mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-16 18:52:22 +00:00
Got rid of rules global (ugh) and gonna start work on items loading next
This commit is contained in:
@@ -72,7 +72,6 @@ bool LoadEMuShareMemDLL::Load() {
|
||||
Doors.GetDoor = (DLLFUNC_GetDoor) GetSym("GetDoor");
|
||||
Doors.cbAddDoor = (DLLFUNC_AddDoor) GetSym("AddDoor");
|
||||
Doors.DLLLoadDoors = (DLLFUNC_DLLLoadDoors) GetSym("DLLLoadDoors");
|
||||
Spells.DLLLoadSPDat = (DLLFUNC_DLLLoadSPDat) GetSym("DLLLoadSPDat");
|
||||
NPCFactionList.DLLLoadNPCFactionLists = (DLLFUNC_DLLLoadNPCFactionLists) GetSym("DLLLoadNPCFactionLists");
|
||||
NPCFactionList.GetNPCFactionList = (DLLFUNC_GetNPCFactionList) GetSym("GetNPCFactionList");
|
||||
NPCFactionList.cbAddNPCFactionList = (DLLFUNC_AddNPCFactionList) GetSym("AddNPCFactionList");
|
||||
@@ -82,16 +81,6 @@ bool LoadEMuShareMemDLL::Load() {
|
||||
Loot.cbAddLootDrop = (DLLFUNC_AddLootDrop) GetSym("AddLootDrop");
|
||||
Loot.GetLootTable = (DLLFUNC_GetLootTable) GetSym("GetLootTable");
|
||||
Loot.GetLootDrop = (DLLFUNC_GetLootDrop) GetSym("GetLootDrop");
|
||||
Opcodes.GetEQOpcode = (DLLFUNC_GetEQOpcode) GetSym("GetEQOpcode");
|
||||
Opcodes.GetEmuOpcode = (DLLFUNC_GetEmuOpcode) GetSym("GetEmuOpcode");
|
||||
Opcodes.SetOpcodePair = (DLLFUNC_SetOpcodePair) GetSym("SetOpcodePair");
|
||||
Opcodes.DLLLoadOpcodes = (DLLFUNC_DLLLoadOpcodes) GetSym("DLLLoadOpcodes");
|
||||
Opcodes.ClearEQOpcodes = (DLLFUNC_ClearEQOpcodes) GetSym("ClearEQOpcodes");
|
||||
SkillCaps.LoadSkillCaps = (DLLFUNC_DLLLoadSkillCaps) GetSym("LoadSkillCaps");
|
||||
SkillCaps.GetSkillCap = (DLLFUNC_GetSkillCap) GetSym("GetSkillCap");
|
||||
SkillCaps.SetSkillCap = (DLLFUNC_SetSkillCap) GetSym("SetSkillCap");
|
||||
SkillCaps.ClearSkillCaps = (DLLFUNC_ClearSkillCaps) GetSym("ClearSkillCaps");
|
||||
SkillCaps.GetTrainLevel = (DLLFUNC_GetTrainLevel) GetSym("GetTrainLevel");
|
||||
if(Items.GetItem == NULL) {
|
||||
Unload();
|
||||
LogFile->write(EQEMuLog::Error, "LoadEMuShareMemDLL::Load() failed to attach Items.GetItem");
|
||||
@@ -134,12 +123,6 @@ bool LoadEMuShareMemDLL::Load() {
|
||||
return(false);
|
||||
}
|
||||
|
||||
if(Spells.DLLLoadSPDat == NULL) {
|
||||
Unload();
|
||||
LogFile->write(EQEMuLog::Error, "LoadEMuShareMemDLL::Load() failed to attach Spells.DLLLoadSPDat");
|
||||
return(false);
|
||||
}
|
||||
|
||||
if(NPCFactionList.DLLLoadNPCFactionLists == NULL) {
|
||||
Unload();
|
||||
LogFile->write(EQEMuLog::Error, "LoadEMuShareMemDLL::Load() failed to attach NPCFactionList.DLLLoadNPCFactionLists");
|
||||
@@ -193,66 +176,6 @@ bool LoadEMuShareMemDLL::Load() {
|
||||
LogFile->write(EQEMuLog::Error, "LoadEMuShareMemDLL::Load() failed to attach Loot.GetLootDrop");
|
||||
return(false);
|
||||
}
|
||||
|
||||
if(Opcodes.GetEQOpcode == NULL) {
|
||||
Unload();
|
||||
LogFile->write(EQEMuLog::Error, "LoadEMuShareMemDLL::Load() failed to attach Opcodes.GetEQOpcode");
|
||||
return(false);
|
||||
}
|
||||
|
||||
if(Opcodes.GetEmuOpcode == NULL) {
|
||||
Unload();
|
||||
LogFile->write(EQEMuLog::Error, "LoadEMuShareMemDLL::Load() failed to attach Opcodes.GetEmuOpcode");
|
||||
return(false);
|
||||
}
|
||||
|
||||
if(Opcodes.SetOpcodePair == NULL) {
|
||||
Unload();
|
||||
LogFile->write(EQEMuLog::Error, "LoadEMuShareMemDLL::Load() failed to attach Opcodes.SetOpcodePair");
|
||||
return(false);
|
||||
}
|
||||
|
||||
if(Opcodes.DLLLoadOpcodes == NULL) {
|
||||
Unload();
|
||||
LogFile->write(EQEMuLog::Error, "LoadEMuShareMemDLL::Load() failed to attach Opcodes.DLLLoadOpcodes");
|
||||
return(false);
|
||||
}
|
||||
|
||||
if(Opcodes.ClearEQOpcodes == NULL) {
|
||||
Unload();
|
||||
LogFile->write(EQEMuLog::Error, "LoadEMuShareMemDLL::Load() failed to attach Opcodes.ClearEQOpcodes");
|
||||
return(false);
|
||||
}
|
||||
|
||||
if(SkillCaps.LoadSkillCaps == NULL) {
|
||||
Unload();
|
||||
LogFile->write(EQEMuLog::Error, "LoadEMuShareMemDLL::Load() failed to attach SkillCaps.LoadSkillCaps");
|
||||
return(false);
|
||||
}
|
||||
|
||||
if(SkillCaps.GetSkillCap == NULL) {
|
||||
Unload();
|
||||
LogFile->write(EQEMuLog::Error, "LoadEMuShareMemDLL::Load() failed to attach SkillCaps.GetSkillCap");
|
||||
return(false);
|
||||
}
|
||||
|
||||
if(SkillCaps.SetSkillCap == NULL) {
|
||||
Unload();
|
||||
LogFile->write(EQEMuLog::Error, "LoadEMuShareMemDLL::Load() failed to attach SkillCaps.SetSkillCap");
|
||||
return(false);
|
||||
}
|
||||
|
||||
if(SkillCaps.ClearSkillCaps == NULL) {
|
||||
Unload();
|
||||
LogFile->write(EQEMuLog::Error, "LoadEMuShareMemDLL::Load() failed to attach SkillCaps.ClearSkillCaps");
|
||||
return(false);
|
||||
}
|
||||
|
||||
if(SkillCaps.GetTrainLevel == NULL) {
|
||||
Unload();
|
||||
LogFile->write(EQEMuLog::Error, "LoadEMuShareMemDLL::Load() failed to attach SkillCaps.GetTrainLevel");
|
||||
return(false);
|
||||
}
|
||||
|
||||
LogFile->write(EQEMuLog::Status, "%s loaded", EmuLibName);
|
||||
loaded = true;
|
||||
@@ -286,15 +209,5 @@ void LoadEMuShareMemDLL::ClearFunc() {
|
||||
Loot.cbAddLootDrop = 0;
|
||||
Loot.GetLootTable = 0;
|
||||
Loot.GetLootDrop = 0;
|
||||
Opcodes.GetEQOpcode = NULL;
|
||||
Opcodes.GetEmuOpcode = NULL;
|
||||
Opcodes.SetOpcodePair = NULL;
|
||||
Opcodes.DLLLoadOpcodes = NULL;
|
||||
Opcodes.ClearEQOpcodes = NULL;
|
||||
SkillCaps.LoadSkillCaps = NULL;
|
||||
SkillCaps.GetSkillCap = NULL;
|
||||
SkillCaps.SetSkillCap = NULL;
|
||||
SkillCaps.ClearSkillCaps = NULL;
|
||||
SkillCaps.GetTrainLevel = NULL;
|
||||
loaded = false;
|
||||
}
|
||||
|
||||
@@ -43,19 +43,6 @@ struct ItemsDLLFunc_Struct {
|
||||
DLLFUNC_IterateItems IterateItems;
|
||||
DLLFUNC_AddItem cbAddItem;
|
||||
};
|
||||
/*
|
||||
typedef bool(*CALLBACK_DBLoadNPCTypes)(int32, uint32);
|
||||
|
||||
typedef bool(*DLLFUNC_DLLLoadNPCTypes)(const CALLBACK_DBLoadNPCTypes, uint32, int32*, uint32*);
|
||||
typedef const NPCType*(*DLLFUNC_GetNPCType)(uint32);
|
||||
typedef bool(*DLLFUNC_AddNPCType)(uint32, const NPCType*);
|
||||
struct NPCTypesDLLFunc_Struct {
|
||||
DLLFUNC_DLLLoadNPCTypes DLLLoadNPCTypes;
|
||||
DLLFUNC_GetNPCType GetNPCType;
|
||||
DLLFUNC_AddNPCType cbAddNPCType;
|
||||
};
|
||||
*/
|
||||
|
||||
|
||||
////////////
|
||||
// Doors ///
|
||||
@@ -71,16 +58,6 @@ struct DoorsDLLFunc_Struct {
|
||||
DLLFUNC_AddDoor cbAddDoor;
|
||||
};
|
||||
|
||||
////////////
|
||||
// Spells //
|
||||
////////////
|
||||
typedef bool(*CALLBACK_FileLoadSPDat)(void*, int32);
|
||||
|
||||
typedef bool(*DLLFUNC_DLLLoadSPDat)(const CALLBACK_FileLoadSPDat, const void**, int32*, uint32);
|
||||
struct SpellsDLLFunc_Struct {
|
||||
DLLFUNC_DLLLoadSPDat DLLLoadSPDat;
|
||||
};
|
||||
|
||||
//////////////
|
||||
// Factions //
|
||||
//////////////
|
||||
@@ -117,45 +94,6 @@ struct LootDLLFunc_Struct {
|
||||
DLLFUNC_GetLootDrop GetLootDrop;
|
||||
};
|
||||
|
||||
/////////////
|
||||
// Opcodes //
|
||||
/////////////
|
||||
|
||||
typedef bool(*CALLBACK_DBLoadOpcodes)(const char *filename);
|
||||
|
||||
typedef bool(*DLLFUNC_DLLLoadOpcodes)(const CALLBACK_DBLoadOpcodes, uint32 opsize, uint32 eq_count, uint32 emu_count, const char *filename);
|
||||
typedef uint16 (*DLLFUNC_GetEQOpcode)(uint16 emu_op);
|
||||
typedef uint16 (*DLLFUNC_GetEmuOpcode)(uint16 eq_op);
|
||||
typedef void (*DLLFUNC_ClearEQOpcodes)();
|
||||
typedef bool(*DLLFUNC_SetOpcodePair)(uint16 emu_op, uint16 eq_op);
|
||||
struct OpcodeDLLFunc_Struct {
|
||||
DLLFUNC_DLLLoadOpcodes DLLLoadOpcodes;
|
||||
DLLFUNC_GetEQOpcode GetEQOpcode;
|
||||
DLLFUNC_GetEmuOpcode GetEmuOpcode;
|
||||
DLLFUNC_SetOpcodePair SetOpcodePair;
|
||||
DLLFUNC_ClearEQOpcodes ClearEQOpcodes;
|
||||
};
|
||||
|
||||
////////////////
|
||||
// Skill Caps //
|
||||
////////////////
|
||||
|
||||
typedef bool(*CALLBACK_DBLoadSkillCaps)();
|
||||
|
||||
typedef bool(*DLLFUNC_DLLLoadSkillCaps)(const CALLBACK_DBLoadSkillCaps, uint32 opsize, uint8 ClassCount, uint8 SkillCount, uint8 LevelCount);
|
||||
typedef uint16 (*DLLFUNC_GetSkillCap)(uint8 Class_, uint8 Skill, uint8 Level);
|
||||
typedef void (*DLLFUNC_ClearSkillCaps)();
|
||||
typedef bool(*DLLFUNC_SetSkillCap)(uint8 Class_, uint8 Skill, uint8 Level, uint16 cap);
|
||||
typedef uint8 (*DLLFUNC_GetTrainLevel)(uint8 Class_, uint8 Skill, uint8 Level);
|
||||
struct SkillCapDLLFunc_Struct {
|
||||
DLLFUNC_DLLLoadSkillCaps LoadSkillCaps;
|
||||
DLLFUNC_GetSkillCap GetSkillCap;
|
||||
DLLFUNC_SetSkillCap SetSkillCap;
|
||||
DLLFUNC_ClearSkillCaps ClearSkillCaps;
|
||||
DLLFUNC_GetTrainLevel GetTrainLevel;
|
||||
};
|
||||
|
||||
|
||||
class LoadEMuShareMemDLL : public SharedLibrary {
|
||||
public:
|
||||
LoadEMuShareMemDLL();
|
||||
@@ -165,13 +103,9 @@ public:
|
||||
void Unload();
|
||||
|
||||
ItemsDLLFunc_Struct Items;
|
||||
//NPCTypesDLLFunc_Struct NPCTypes;
|
||||
DoorsDLLFunc_Struct Doors;
|
||||
SpellsDLLFunc_Struct Spells;
|
||||
NPCFactionListDLLFunc_Struct NPCFactionList;
|
||||
LootDLLFunc_Struct Loot;
|
||||
OpcodeDLLFunc_Struct Opcodes;
|
||||
SkillCapDLLFunc_Struct SkillCaps;
|
||||
private:
|
||||
void ClearFunc();
|
||||
|
||||
|
||||
+13
-11
@@ -30,11 +30,11 @@
|
||||
//which makes it a global for now, but with instancing we will do exactly
|
||||
//what we do with the zone global and just make it a member of core classes
|
||||
#define RuleI(cat, rule) \
|
||||
rules->GetIntRule( RuleManager::Int__##rule )
|
||||
RuleManager::Instance()->GetIntRule( RuleManager::Int__##rule )
|
||||
#define RuleR(cat, rule) \
|
||||
rules->GetRealRule( RuleManager::Real__##rule )
|
||||
RuleManager::Instance()->GetRealRule( RuleManager::Real__##rule )
|
||||
#define RuleB(cat, rule) \
|
||||
rules->GetBoolRule( RuleManager::Bool__##rule )
|
||||
RuleManager::Instance()->GetBoolRule( RuleManager::Bool__##rule )
|
||||
|
||||
|
||||
#include <vector>
|
||||
@@ -76,14 +76,17 @@ public:
|
||||
_CatCount
|
||||
} CategoryType;
|
||||
|
||||
static RuleManager* Instance() {
|
||||
static RuleManager rules;
|
||||
return &rules;
|
||||
}
|
||||
|
||||
static const IntType InvalidInt = _IntRuleCount;
|
||||
static const RealType InvalidReal = _RealRuleCount;
|
||||
static const BoolType InvalidBool = _BoolRuleCount;
|
||||
static const CategoryType InvalidCategory = _CatCount;
|
||||
|
||||
static const uint32 _RulesCount = _IntRuleCount+_RealRuleCount+_BoolRuleCount;
|
||||
|
||||
RuleManager();
|
||||
|
||||
//fetch routines, you should generally use the Rule* macros instead of this
|
||||
int32 GetIntRule (IntType t) const;
|
||||
@@ -111,9 +114,12 @@ public:
|
||||
bool LoadRules(Database *db, const char *ruleset = NULL);
|
||||
void SaveRules(Database *db, const char *ruleset = NULL);
|
||||
|
||||
protected:
|
||||
private:
|
||||
RuleManager();
|
||||
RuleManager(const RuleManager&);
|
||||
const RuleManager& operator=(const RuleManager&);
|
||||
|
||||
int m_activeRuleset;
|
||||
int m_activeRuleset;
|
||||
std::string m_activeName;
|
||||
#ifdef WIN64
|
||||
uint32 m_RuleIntValues [_IntRuleCount ];
|
||||
@@ -145,8 +151,4 @@ protected:
|
||||
|
||||
};
|
||||
|
||||
//this is not the right way to do this, but I
|
||||
//dont feel like solving it correctly right now:
|
||||
extern RuleManager *rules;
|
||||
|
||||
#endif /*RULESYS_H_*/
|
||||
|
||||
+4
-42
@@ -25,14 +25,14 @@ extern LoadEMuShareMemDLL EMuShareMemDLL;
|
||||
SharedDatabase *SharedDatabase::s_usedb = NULL;
|
||||
|
||||
SharedDatabase::SharedDatabase()
|
||||
: Database(), skill_caps_mmf(NULL)
|
||||
: Database(), skill_caps_mmf(NULL), items_mmf(NULL), items_hash(NULL)
|
||||
{
|
||||
SDBInitVars();
|
||||
s_usedb = this;
|
||||
}
|
||||
|
||||
SharedDatabase::SharedDatabase(const char* host, const char* user, const char* passwd, const char* database, uint32 port)
|
||||
: Database(host, user, passwd, database, port), skill_caps_mmf(NULL)
|
||||
: Database(host, user, passwd, database, port), skill_caps_mmf(NULL), items_mmf(NULL), items_hash(NULL)
|
||||
{
|
||||
SDBInitVars();
|
||||
s_usedb = this;
|
||||
@@ -50,6 +50,8 @@ void SharedDatabase::SDBInitVars() {
|
||||
|
||||
SharedDatabase::~SharedDatabase() {
|
||||
safe_delete(skill_caps_mmf);
|
||||
safe_delete(items_mmf);
|
||||
safe_delete(items_hash);
|
||||
}
|
||||
|
||||
bool SharedDatabase::SetHideMe(uint32 account_id, uint8 hideme)
|
||||
@@ -1518,10 +1520,6 @@ bool SharedDatabase::GetCommandSettings(map<string,uint8> &commands) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SharedDatabase::extDBLoadSkillCaps() {
|
||||
return s_usedb->DBLoadSkillCaps();
|
||||
}
|
||||
|
||||
bool SharedDatabase::LoadSkillCaps() {
|
||||
if(skill_caps_mmf)
|
||||
return true;
|
||||
@@ -1581,42 +1579,6 @@ void SharedDatabase::LoadSkillCaps(void *data) {
|
||||
}
|
||||
}
|
||||
|
||||
bool SharedDatabase::DBLoadSkillCaps() {
|
||||
LogFile->write(EQEMuLog::Status, "Loading skill caps from database...");
|
||||
|
||||
uint8 class_count = PLAYER_CLASS_COUNT;
|
||||
uint8 skill_count = HIGHEST_SKILL+1;
|
||||
uint8 level_count = HARD_LEVEL_CAP+1;
|
||||
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char *query = 0;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
if (RunQuery(query, MakeAnyLenString(&query,
|
||||
"SELECT skillID,class,level,cap FROM skill_caps ORDER BY skillID,class,level"),
|
||||
errbuf, &result)) {
|
||||
safe_delete_array(query);
|
||||
|
||||
while ((row = mysql_fetch_row(result))) {
|
||||
uint8 skillID = atoi(row[0]);
|
||||
uint8 class_ = atoi(row[1])-1; //classes are base 1...
|
||||
uint8 level = atoi(row[2]);
|
||||
uint16 cap = atoi(row[3]);
|
||||
if(skillID >= skill_count || class_ >= class_count || level >= level_count)
|
||||
continue;
|
||||
EMuShareMemDLL.SkillCaps.SetSkillCap(class_, skillID, level, cap);
|
||||
}
|
||||
mysql_free_result(result);
|
||||
}
|
||||
else {
|
||||
cerr << "Error in DBLoadSkillCaps (memshare) #2 query '" << query << "' " << errbuf << endl;
|
||||
safe_delete_array(query);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
uint16 SharedDatabase::GetSkillCap(uint8 Class_, SkillType Skill, uint8 Level) {
|
||||
if(!skill_caps_mmf) {
|
||||
return 0;
|
||||
|
||||
+3
-2
@@ -7,6 +7,7 @@
|
||||
#include "skills.h"
|
||||
#include "spdat.h"
|
||||
#include "Item.h"
|
||||
#include "fixed_memory_hash_set.h"
|
||||
|
||||
#include <list>
|
||||
|
||||
@@ -96,7 +97,6 @@ public:
|
||||
bool DBLoadNPCTypes(int32 iNPCTypeCount, uint32 iMaxNPCTypeID);
|
||||
bool DBLoadNPCFactionLists(int32 iNPCFactionListCount, uint32 iMaxNPCFactionListID);
|
||||
bool DBLoadLoot();
|
||||
bool DBLoadSkillCaps();
|
||||
|
||||
int GetMaxSpellID();
|
||||
void LoadSpells(void *data, int max_spells);
|
||||
@@ -117,7 +117,6 @@ protected:
|
||||
static bool extDBLoadItems(int32 iItemCount, uint32 iMaxItemID);
|
||||
static bool extDBLoadNPCFactionLists(int32 iNPCFactionListCount, uint32 iMaxNPCFactionListID);
|
||||
static bool extDBLoadLoot();
|
||||
static bool extDBLoadSkillCaps();
|
||||
|
||||
|
||||
uint32 max_item;
|
||||
@@ -129,6 +128,8 @@ protected:
|
||||
|
||||
uint32 npc_spells_maxid;
|
||||
|
||||
EQEmu::MemoryMappedFile *items_mmf;
|
||||
EQEmu::FixedMemoryHashSet<Item_Struct> *items_hash;
|
||||
EQEmu::MemoryMappedFile *skill_caps_mmf;
|
||||
private:
|
||||
static SharedDatabase *s_usedb;
|
||||
|
||||
Reference in New Issue
Block a user