Got rid of rules global (ugh) and gonna start work on items loading next

This commit is contained in:
KimLS 2013-02-20 15:35:46 -08:00
parent 8eb7d0aaa8
commit ef9498b03a
15 changed files with 67 additions and 284 deletions

View File

@ -8,9 +8,6 @@ SET(sharedmem_src
MMF.cpp
MMFMutex.cpp
NPCFactionLists.cpp
Opcodes.cpp
SkillCaps.cpp
Spells.cpp
)
SET(sharedmem_headers
@ -20,9 +17,6 @@ SET(sharedmem_headers
MMF.h
MMFMutex.h
NPCFactionLists.h
Opcodes.h
SkillCaps.h
Spells.h
)
SET(EQEMU_MAX_ITEMS 300000 CACHE STRING "Maxium number of items to load into memory. Make sure this is bigger than the total number of items in the server database")

View File

@ -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;
}

View File

@ -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();

View File

@ -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_*/

View File

@ -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;

View File

@ -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;

View File

@ -44,8 +44,6 @@ Database database;
LFGuildManager lfguildmanager;
string WorldShortName;
// RuleManager *rules = new RuleManager();
const queryservconfig *Config;
WorldServer *worldserver = 0;
@ -97,22 +95,6 @@ int main() {
return(1);
}
char tmp[64];
// Disable the Rule system, since we could be split brained from the main database
// if (database.GetVariable("RuleSet", tmp, sizeof(tmp)-1)) {
// _log(WORLD__INIT, "Loading rule set '%s'", tmp);
// if(!rules->LoadRules(&database, tmp)) {
// _log(QUERYSERV__ERROR, "Failed to load ruleset '%s', falling back to defaults.", tmp);
// }
// } else {
// if(!rules->LoadRules(&database, "default")) {
// _log(QUERYSERV__INIT, "No rule set configured, using default rules");
// } else {
// _log(QUERYSERV__INIT, "Loaded default rule set 'default'", tmp);
// }
// }
if (signal(SIGINT, CatchSignal) == SIG_ERR) {
_log(QUERYSERV__ERROR, "Could not set signal handler");
return 0;

View File

@ -27,9 +27,6 @@
#include "spells.h"
#include "skill_caps.h"
//blah global variables =(
RuleManager *rules = new RuleManager();
int main(int argc, char **argv) {
RegisterExecutablePlatform(ExePlatformSharedMemory);
set_exception_handler();
@ -55,19 +52,8 @@ int main(int argc, char **argv) {
}
bool load_all = true;
bool load_spells = true;
bool load_skill_caps = true;
if(load_all || load_spells) {
LogFile->write(EQEMuLog::Status, "Loading spells...");
try {
LoadSpells(&database);
} catch(std::exception &ex) {
LogFile->write(EQEMuLog::Error, "%s", ex.what());
return 0;
}
}
bool load_spells = true;
if(load_all || load_skill_caps) {
LogFile->write(EQEMuLog::Status, "Loading skill caps...");
try {
@ -78,5 +64,15 @@ int main(int argc, char **argv) {
}
}
if(load_all || load_spells) {
LogFile->write(EQEMuLog::Status, "Loading spells...");
try {
LoadSpells(&database);
} catch(std::exception &ex) {
LogFile->write(EQEMuLog::Error, "%s", ex.what());
return 0;
}
}
return 0;
}

View File

@ -49,8 +49,6 @@ Database database;
string WorldShortName;
RuleManager *rules = new RuleManager();
const ucsconfig *Config;
WorldServer *worldserver = 0;
@ -114,11 +112,11 @@ int main() {
if (database.GetVariable("RuleSet", tmp, sizeof(tmp)-1)) {
_log(WORLD__INIT, "Loading rule set '%s'", tmp);
if(!rules->LoadRules(&database, tmp)) {
if(!RuleManager::Instance()->LoadRules(&database, tmp)) {
_log(UCS__ERROR, "Failed to load ruleset '%s', falling back to defaults.", tmp);
}
} else {
if(!rules->LoadRules(&database, "default")) {
if(!RuleManager::Instance()->LoadRules(&database, "default")) {
_log(UCS__INIT, "No rule set configured, using default rules");
} else {
_log(UCS__INIT, "Loaded default rule set 'default'", tmp);

View File

@ -115,7 +115,6 @@ QueryServConnection QSLink;
LauncherList launcher_list;
AdventureManager adventure_manager;
DBAsync *dbasync = NULL;
RuleManager *rules = new RuleManager();
volatile bool RunLoops = true;
uint32 numclients = 0;
uint32 numzones = 0;
@ -302,11 +301,11 @@ int main(int argc, char** argv) {
char tmp[64];
if (database.GetVariable("RuleSet", tmp, sizeof(tmp)-1)) {
_log(WORLD__INIT, "Loading rule set '%s'", tmp);
if(!rules->LoadRules(&database, tmp)) {
if(!RuleManager::Instance()->LoadRules(&database, tmp)) {
_log(WORLD__INIT_ERR, "Failed to load ruleset '%s', falling back to defaults.", tmp);
}
} else {
if(!rules->LoadRules(&database, "default")) {
if(!RuleManager::Instance()->LoadRules(&database, "default")) {
_log(WORLD__INIT, "No rule set configured, using default rules");
} else {
_log(WORLD__INIT, "Loaded default rule set 'default'", tmp);

View File

@ -796,12 +796,12 @@ bool ZoneServer::Process() {
case ServerOP_ReloadRules:
{
zoneserver_list.SendPacket(pack);
rules->LoadRules(&database, "default");
RuleManager::Instance()->LoadRules(&database, "default");
break;
}
case ServerOP_ReloadRulesWorld:
{
rules->LoadRules(&database, "default");
RuleManager::Instance()->LoadRules(&database, "default");
break;
}
case ServerOP_CameraShake:

View File

@ -8551,10 +8551,11 @@ void command_rules(Client *c, const Seperator *sep) {
}
if(!strcasecmp(sep->arg[1], "current")) {
c->Message(0, "Currently running ruleset '%s' (%d)", rules->GetActiveRuleset(), rules->GetActiveRulesetID());
c->Message(0, "Currently running ruleset '%s' (%d)", RuleManager::Instance()->GetActiveRuleset(),
RuleManager::Instance()->GetActiveRulesetID());
} else if(!strcasecmp(sep->arg[1], "listsets")) {
std::map<int, std::string> sets;
if(!rules->ListRulesets(&database, sets)) {
if(!RuleManager::Instance()->ListRulesets(&database, sets)) {
c->Message(13, "Failed to list rule sets!");
return;
}
@ -8567,11 +8568,12 @@ void command_rules(Client *c, const Seperator *sep) {
c->Message(0, "(%d) %s", cur->first, cur->second.c_str());
}
} else if(!strcasecmp(sep->arg[1], "reload")) {
rules->LoadRules(&database, rules->GetActiveRuleset());
c->Message(0, "The active ruleset (%s (%d)) has been reloaded", rules->GetActiveRuleset(), rules->GetActiveRulesetID());
RuleManager::Instance()->LoadRules(&database, RuleManager::Instance()->GetActiveRuleset());
c->Message(0, "The active ruleset (%s (%d)) has been reloaded", RuleManager::Instance()->GetActiveRuleset(),
RuleManager::Instance()->GetActiveRulesetID());
} else if(!strcasecmp(sep->arg[1], "switch")) {
//make sure this is a valid rule set..
int rsid = rules->GetRulesetID(&database, sep->arg[2]);
int rsid = RuleManager::Instance()->GetRulesetID(&database, sep->arg[2]);
if(rsid < 0) {
c->Message(13, "Unknown rule set '%s'", sep->arg[2]);
return;
@ -8582,27 +8584,27 @@ void command_rules(Client *c, const Seperator *sep) {
}
//TODO: we likely want to reload this ruleset everywhere...
rules->LoadRules(&database, sep->arg[2]);
RuleManager::Instance()->LoadRules(&database, sep->arg[2]);
c->Message(0, "The selected ruleset has been changed to (%s (%d)) and reloaded locally", sep->arg[2], rsid);
} else if(!strcasecmp(sep->arg[1], "load")) {
//make sure this is a valid rule set..
int rsid = rules->GetRulesetID(&database, sep->arg[2]);
int rsid = RuleManager::Instance()->GetRulesetID(&database, sep->arg[2]);
if(rsid < 0) {
c->Message(13, "Unknown rule set '%s'", sep->arg[2]);
return;
}
rules->LoadRules(&database, sep->arg[2]);
RuleManager::Instance()->LoadRules(&database, sep->arg[2]);
c->Message(0, "Loaded ruleset '%s' (%d) locally", sep->arg[2], rsid);
} else if(!strcasecmp(sep->arg[1], "store")) {
if(sep->argnum == 1) {
//store current rule set.
rules->SaveRules(&database);
RuleManager::Instance()->SaveRules(&database);
c->Message(0, "Rules saved");
} else if(sep->argnum == 2) {
rules->SaveRules(&database, sep->arg[2]);
int prersid = rules->GetActiveRulesetID();
int rsid = rules->GetRulesetID(&database, sep->arg[2]);
RuleManager::Instance()->SaveRules(&database, sep->arg[2]);
int prersid = RuleManager::Instance()->GetActiveRulesetID();
int rsid = RuleManager::Instance()->GetRulesetID(&database, sep->arg[2]);
if(rsid < 0) {
c->Message(13, "Unable to query ruleset ID after store, it most likely failed.");
} else {
@ -8616,7 +8618,7 @@ void command_rules(Client *c, const Seperator *sep) {
return;
}
} else if(!strcasecmp(sep->arg[1], "reset")) {
rules->ResetRules();
RuleManager::Instance()->ResetRules();
c->Message(0, "The running ruleset has been set to defaults");
} else if(!strcasecmp(sep->arg[1], "get")) {
@ -8625,7 +8627,7 @@ void command_rules(Client *c, const Seperator *sep) {
return;
}
std::string value;
if(!rules->GetRule(sep->arg[2], value))
if(!RuleManager::Instance()->GetRule(sep->arg[2], value))
c->Message(13, "Unable to find rule %s", sep->arg[2]);
else
c->Message(0, "%s - %s", sep->arg[2], value.c_str());
@ -8635,7 +8637,7 @@ void command_rules(Client *c, const Seperator *sep) {
c->Message(13, "Invalid argument count, see help.");
return;
}
if(!rules->SetRule(sep->arg[2], sep->arg[3])) {
if(!RuleManager::Instance()->SetRule(sep->arg[2], sep->arg[3])) {
c->Message(13, "Failed to modify rule");
} else {
c->Message(0, "Rule modified locally.");
@ -8645,7 +8647,7 @@ void command_rules(Client *c, const Seperator *sep) {
c->Message(13, "Invalid argument count, see help.");
return;
}
if(!rules->SetRule(sep->arg[2], sep->arg[3], &database, true)) {
if(!RuleManager::Instance()->SetRule(sep->arg[2], sep->arg[3], &database, true)) {
c->Message(13, "Failed to modify rule");
} else {
c->Message(0, "Rule modified locally and in the database.");
@ -8653,7 +8655,7 @@ void command_rules(Client *c, const Seperator *sep) {
} else if(!strcasecmp(sep->arg[1], "list")) {
if(sep->argnum == 1) {
std::vector<const char *> rule_list;
if(!rules->ListCategories(rule_list)) {
if(!RuleManager::Instance()->ListCategories(rule_list)) {
c->Message(13, "Failed to list categories!");
return;
}
@ -8669,7 +8671,7 @@ void command_rules(Client *c, const Seperator *sep) {
if(std::string("all") != sep->arg[2])
catfilt = sep->arg[2];
std::vector<const char *> rule_list;
if(!rules->ListRules(catfilt, rule_list)) {
if(!RuleManager::Instance()->ListRules(catfilt, rule_list)) {
c->Message(13, "Failed to list rules!");
return;
}
@ -8692,7 +8694,7 @@ void command_rules(Client *c, const Seperator *sep) {
if(std::string("all") != sep->arg[2])
catfilt = sep->arg[2];
std::vector<const char *> rule_list;
if(!rules->ListRules(catfilt, rule_list)) {
if(!RuleManager::Instance()->ListRules(catfilt, rule_list)) {
c->Message(13, "Failed to list rules!");
return;
}
@ -8701,7 +8703,7 @@ void command_rules(Client *c, const Seperator *sep) {
cur = rule_list.begin();
end = rule_list.end();
for(std::string tmp_value; cur != end; cur++) {
if (rules->GetRule(*cur, tmp_value))
if (RuleManager::Instance()->GetRule(*cur, tmp_value))
c->Message(0, " %s - %s", *cur, tmp_value.c_str());
}
}

View File

@ -117,7 +117,6 @@ npcDecayTimes_Struct npcCorpseDecayTimes[100];
TitleManager title_manager;
DBAsyncFinishedQueue MTdbafq;
DBAsync *dbasync = NULL;
RuleManager *rules = new RuleManager();
TaskManager *taskmanager = 0;
QuestParserCollection *parse = 0;
@ -257,7 +256,8 @@ int main(int argc, char** argv) {
CheckEQEMuErrorAndPause();
return 0;
}
_log(ZONE__INIT, "Loading spells");
_log(ZONE__INIT, "Loading spells");
EQEmu::MemoryMappedFile *mmf = NULL;
LoadSpells(&mmf);
@ -285,11 +285,11 @@ int main(int argc, char** argv) {
char tmp[64];
if (database.GetVariable("RuleSet", tmp, sizeof(tmp)-1)) {
_log(ZONE__INIT, "Loading rule set '%s'", tmp);
if(!rules->LoadRules(&database, tmp)) {
if(!RuleManager::Instance()->LoadRules(&database, tmp)) {
_log(ZONE__INIT_ERR, "Failed to load ruleset '%s', falling back to defaults.", tmp);
}
} else {
if(!rules->LoadRules(&database, "default")) {
if(!RuleManager::Instance()->LoadRules(&database, "default")) {
_log(ZONE__INIT, "No rule set configured, using default rules");
} else {
_log(ZONE__INIT, "Loaded default rule set 'default'", tmp);

View File

@ -1753,7 +1753,7 @@ void WorldServer::Process() {
}
case ServerOP_ReloadRules:
{
rules->LoadRules(&database, rules->GetActiveRuleset());
RuleManager::Instance()->LoadRules(&database, RuleManager::Instance()->GetActiveRuleset());
break;
}
case ServerOP_CameraShake:

View File

@ -1144,12 +1144,12 @@ bool Zone::Init(bool iStaticZone) {
if (!LoadZoneCFG(zone->GetShortName(), zone->GetInstanceVersion(), true)) // try loading the zone name...
LoadZoneCFG(zone->GetFileName(), zone->GetInstanceVersion()); // if that fails, try the file name, then load defaults
if(rules->GetActiveRulesetID() != default_ruleset)
if(RuleManager::Instance()->GetActiveRulesetID() != default_ruleset)
{
string r_name = rules->GetRulesetName(&database, default_ruleset);
string r_name = RuleManager::Instance()->GetRulesetName(&database, default_ruleset);
if(r_name.size() > 0)
{
rules->LoadRules(&database, r_name.c_str());
RuleManager::Instance()->LoadRules(&database, r_name.c_str());
}
}