Browse Source

reload commands added

Fix #149 - /reload transporters
Fix #148 - /reload rules
Image 3 years ago
parent
commit
a7fe1df8f0

+ 2 - 0
DB/updates/reload_command_additions.sql

@@ -0,0 +1,2 @@
+insert into commands set type=1, command='reload',subcommand='rules',handler=519,required_status=100;
+insert into commands set type=1, command='reload',subcommand='transporters',handler=520,required_status=100;

+ 14 - 0
EQ2/source/WorldServer/Commands/Commands.cpp

@@ -1086,6 +1086,8 @@ void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* clie
 		client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload mail");
 		client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload guilds");
 		client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload locations");
+		client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload rules");
+		client->SimpleMessage(CHANNEL_COLOR_YELLOW, "/reload transporters");
 		break;
 	}
 	case COMMAND_RELOADSTRUCTS: {
@@ -1166,6 +1168,18 @@ void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* clie
 		client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
 		break;
 	}
+	case COMMAND_RELOAD_RULES: {
+		client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Rules...");
+		database.LoadRuleSets(true);
+		client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
+		break;
+	}
+	case COMMAND_RELOAD_TRANSPORTERS: {
+		client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Reloading Transporters in your current zone...");
+		database.LoadTransporters(client->GetCurrentZone());
+		client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Done!");
+		break;
+	}
 	case COMMAND_READ: {
 		if (sep && sep->arg[1][0] && sep->IsNumber(1)) {
 			if (strcmp(sep->arg[0], "read") == 0) {

+ 3 - 0
EQ2/source/WorldServer/Commands/Commands.h

@@ -885,6 +885,9 @@ private:
 #define COMMAND_PICKUP					517
 #define COMMAND_HOUSE_DEPOSIT			518
 
+#define COMMAND_RELOAD_RULES			519
+#define COMMAND_RELOAD_TRANSPORTERS		520
+
 #define GET_AA_XML						751
 #define ADD_AA							752
 #define COMMIT_AA_PROFILE				753				

+ 22 - 7
EQ2/source/WorldServer/Rules/Rules.cpp

@@ -170,7 +170,16 @@ RuleManager::RuleManager() {
 	m_global_rule_set.SetName("RuleManager::global_rule_set");
 	m_zone_rule_sets.SetName("RuleManager::zone_rule_sets");
 
-	#define RULE_INIT(category, type, value) rules[category][type] = new Rule(category, type, value, #category ":" #type)
+	Init();
+}
+
+RuleManager::~RuleManager() {
+	Flush();
+}
+
+void RuleManager::Init()
+{
+#define RULE_INIT(category, type, value) rules[category][type] = new Rule(category, type, value, #category ":" #type)
 
 	/* CLIENT */
 	RULE_INIT(R_Client, ShowWelcomeScreen, "0");
@@ -214,7 +223,7 @@ RuleManager::RuleManager() {
 	//RULE_INIT(R_Spawn, SpeedRatio, "0");		// was 1280/7.5 and 600/7.5 until it became 300.
 
 	/* TIMER */
-	
+
 	/* UI */
 	RULE_INIT(R_UI, MaxWhoResults, "20");
 	RULE_INIT(R_UI, MaxWhoOverrideStatus, "200");
@@ -261,7 +270,7 @@ RuleManager::RuleManager() {
 	RULE_INIT(R_World, SendPaperdollImagesToLogin, "1");			// default: true
 	RULE_INIT(R_World, TreasureChestDisabled, "0");					// default: false
 	//INSERT INTO `ruleset_details`(`id`, `ruleset_id`, `rule_category`, `rule_type`, `rule_value`, `description`) VALUES (NULL, '1', 'R_World', '', '', '')
-	
+
 	/* ZONE */
 	RULE_INIT(R_Zone, MaxPlayers, "100");
 	RULE_INIT(R_Zone, MinZoneLevelOverrideStatus, "1");
@@ -296,20 +305,26 @@ RuleManager::RuleManager() {
 	RULE_INIT(R_Expansion, GlobalHolidayFlag, "0");
 
 	RULE_INIT(R_World, DatabaseVersion, "0");
-	#undef RULE_INIT
+#undef RULE_INIT
 }
 
-RuleManager::~RuleManager() {
-	map<int32, map<int32, Rule *> >::iterator itr;
-	map<int32, Rule *>::iterator itr2;
+void RuleManager::Flush(bool reinit)
+{
+	map<int32, map<int32, Rule*> >::iterator itr;
+	map<int32, Rule*>::iterator itr2;
 
 	for (itr = rules.begin(); itr != rules.end(); itr++) {
 		for (itr2 = itr->second.begin(); itr2 != itr->second.end(); itr2++)
 			safe_delete(itr2->second);
 	}
 
+	rules.clear();
+
 	ClearRuleSets();
 	ClearZoneRuleSets();
+
+	if (reinit)
+		Init();
 }
 
 void RuleManager::LoadCodedDefaultsIntoRuleSet(RuleSet *rule_set) {

+ 3 - 0
EQ2/source/WorldServer/Rules/Rules.h

@@ -234,6 +234,9 @@ public:
 	RuleManager();
 	virtual ~RuleManager();
 
+	void Init();
+	void Flush(bool reinit=false);
+
 	void LoadCodedDefaultsIntoRuleSet(RuleSet *rule_set);
 
 	bool AddRuleSet(RuleSet *rule_set);

+ 4 - 1
EQ2/source/WorldServer/Rules/RulesDB.cpp

@@ -43,12 +43,15 @@ void WorldDatabase::LoadGlobalRuleSet() {
 		LogWrite(RULESYS__ERROR, 0, "Rules", "Error loading global rule set. A rule set with ID %u does not exist.", rule_set_id);
 }
 
-void WorldDatabase::LoadRuleSets() {
+void WorldDatabase::LoadRuleSets(bool reload) {
 	RuleSet *rule_set;
 	Query query;
 	MYSQL_ROW row;
 	MYSQL_RES *res;
 
+	if (reload)
+		rule_manager.Flush(true);
+
 	/* first load the coded defaults in */
 	rule_manager.LoadCodedDefaultsIntoRuleSet(rule_manager.GetGlobalRuleSet());
 

+ 1 - 1
EQ2/source/WorldServer/WorldDatabase.h

@@ -472,7 +472,7 @@ public:
 
 	/* Rules */
 	void LoadGlobalRuleSet();
-	void LoadRuleSets();
+	void LoadRuleSets(bool reload=false);
 	void LoadRuleSetDetails(RuleSet *rule_set);
 
 	/* Titles */