Page 3 of 3

Re: Implementing: Rules System

Posted: Thu Jul 28, 2011 8:11 am
by John Adams
Yep, sounds good. I've implemented maybe 20 or so rules in place of `variables`, but they can be easily changed when you poop me the new code.

Scatman wrote:Question 1:
I haven't done commands yet. Before I implement the in-game commands, I wanted to make sure you were happy with the rule system so if I do need to change something, I don't have to change a gazillion commands. But we'll definitely be able to do something like that.
I was not speaking of in-game commands, but the ConsoleCommands. I wanted to just view what is active, and needed to know how to access the rules via iterator or whatever to simply loop and printf() them to the console.

Nothing in-game, yet. Nor do I want to SET or SAVE rules yet. Just, view them without having to printf() every rule individually line by line (which I could have done, but figured there was a better way).

Re: Implementing: Rules System

Posted: Thu Jul 28, 2011 8:29 am
by Zcoretri
John Adams wrote: I was not speaking of in-game commands, but the ConsoleCommands. I wanted to just view what is active, and needed to know how to access the rules via iterator or whatever to simply loop and printf() them to the console.

Nothing in-game, yet. Nor do I want to SET or SAVE rules yet. Just, view them without having to printf() every rule individually line by line (which I could have done, but figured there was a better way).
Just want a clarification....what do you mean by Console Commands?

Re: Implementing: Rules System

Posted: Thu Jul 28, 2011 10:01 am
by John Adams
EQ2World.exe running on Windows, you can type stuff in the console box. I added that months ago (with Scat's help of course). But you never read posts from me, so I understand :( Not much works there yet, the system is in place for expanding.

World Startup says:

Code: Select all

12:34 D Thread: Starting console command thread...
12:34 I Console: Type 'help' or '?' and press enter for menu options.
ConsoleCommands.jpg

Re: Implementing: Rules System

Posted: Thu Jul 28, 2011 3:45 pm
by Zcoretri
I do read everything, I truly do :lol:

I just don't understand why, or what advantage the console commands give? Were those taken out from being commanded from in game?

Re: Implementing: Rules System

Posted: Thu Jul 28, 2011 3:48 pm
by John Adams
There's a bazillion reasons why one would want console-based commands. Why should I need to log into my server to do something, like broadcast the world is going down, or change the MOTD, or lookup a player/guild, or any in-game data? Not everyone is a wizard with MySQL.

I may want to lock the world, a zone, reset zone access timers, ban an IP, player, or bump someone's status to GM. A ba-ZILLION uses ;)

Re: Implementing: Rules System

Posted: Thu Jul 28, 2011 9:07 pm
by Sylva1n
Zcoretri wrote:I do read everything, I truly do :lol:
forum's link [mark all read] doesn't count ...

Re: Implementing: Rules System

Posted: Sat Jul 30, 2011 8:45 am
by John Adams
Scat, I just realized something (maybe) bad about ENUMs.

We're going to have, literally, hundreds of Rule Types by the time we're done implementing everything. I do not think it is practical to maintain a database column of enum('100s','of','rule',...'types'). Do you? Enum in the code seems fine, but can we make those fields simple varchar(64) and expect our server admins to not fat-finger a rule entry they want customized?

Thoughts?


Example:

Code: Select all

CREATE TABLE `ruleset_details` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `ruleset_id` int(10) unsigned NOT NULL,
  `rule_category` enum('R_Client','R_Guild','R_Player','R_UI','R_World','R_Zone') character set latin1 collate latin1_general_ci NOT NULL,
  `rule_type` enum('ShowWelcomeScreen','MaxLevel','MaxLevelOverrideStatus','MaxPlayers','MaxPlayersOverrideStatus','VitalityAmount','VitalityFrequency','MaxWhoResults','MaxWhoOverrideStatus','GamblingTokenItemID','GuildAutoJoin','GuildAutoJoinID','GuildAutoJoinDefaultRankID','ServerLocked','ServerLockedOverrideStatus','SyncZonesWithLogin','SyncEquipWithLogin','UseBannedIPsTable','MinZoneLevelOverrideStatus','MinZoneAccessOverrideStatus','XPMultiplier','TSXPMultiplier') character set latin1 collate latin1_general_ci NOT NULL,
  `rule_value` varchar(64) character set latin1 collate latin1_general_ci NOT NULL,
  `description` varchar(256) character set latin1 collate latin1_general_ci default NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `RuleCatTypeIDX` (`ruleset_id`,`rule_category`,`rule_type`),
  CONSTRAINT `FK_ruleset_details` FOREIGN KEY (`ruleset_id`) REFERENCES `rulesets` (`ruleset_id`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1

Re: Implementing: Rules System

Posted: Sat Jul 30, 2011 9:44 am
by John Adams
And naturally, I'm doing something wrong again. Rules Overrides are not working.

Log:
09:40 I World: Loading System Data...
09:41 D Rules: Loading Rule Sets...
09:41 T Rules: Loading rule set 'default_ruleset' (1)
09:41 T Rules: Setting rule category 'R_World', type 'MaxPlayers' to value: 1
09:41 D Rules: Loaded 1 Rule Sets
09:41 D Rules: Rule: R_World:ServerLockedOverrideStatus, Value: 10
09:41 D Rules: Rule: R_World:MaxPlayers, Value: -1
09:41 D Rules: Rule: R_World:MaxPlayersOverrideStatus, Value: 100
09:41 I World: Loaded System Data (took 9 seconds)
Here you see my override being loaded from the Database "Setting rule category 'R_World', type 'MaxPlayers' to value: 1"

And later when the rule is called to set MaxPlayers for the world during init, it says -1 (or, No MaxPlayers).

~big, huge FROWNY FACE~

I know you said you were revamping this, but as it is, this is not working and wanted you to know for said revamp ;)
Or, to tell me wtf I am doing wrong, again.

Re: Implementing: Rules System

Posted: Mon Aug 01, 2011 4:53 pm
by Scatman
Sure. I have no problem using VARCHARs instead, if we're going to have that many. It won't affect the code at all (enums and varchars are treated the same in the mysql api).

The bug if someone tries to use a rule that does not exist, won't return null anymore (and potentially crash world). It'll return a blank rule, so you can still use the getters on it, and it'll return a default value (0 for int, "" for string, etc).

From our conversations on IRC, overrides to appear to be working properly.

Re: Implementing: Rules System

Posted: Fri Sep 07, 2012 11:49 am
by John Adams
From IRC last night:
[22:06] <@Zcoretri> i keep getting these errors for rules that john added
[22:07] <@Jabantiz> did you connect to the patch server?
[22:07] <@Zcoretri> the data is the DB...but I have not updated my svn code that has his code changes
[22:08] <@Jabantiz> so you have the data but not the code?
[22:09] <@Zcoretri> yeah
[22:11] <@Jabantiz> not sure why that would give you errors
[22:11] <@Jabantiz> i would think the data would just be ignored since the server doesn't need it
The Rules Errors are only there to let you know that World pulled ruleset_details from the DB, but there is no defined rule in code to match it to. It will not hurt anything, only there as an information. The RULES__ERROR should probably be demoted to RULES__WARNING, because it is not a show stopper.

The rules are loaded from the DB according to what ruleset_id is assigned to the server (in `variables`). The code then loops through DB-provided Rules and matches them to Code. If there is a mismatch (like you're seeing), an error is displayed.

Pretty sure though, the World will run fine even if your Rules tables are empty, because the DB is merely an override to our default values in code (Rules.cpp, RuleManager::RuleManager() function)


Hope this explains it a little more. Any questions, please ask. I'd like all devs to fully understand Rules so we can start implementing more as we're going through code.