PDA

View Full Version : How soon do rules apply


mixxit
07-04-2009, 07:41 PM
If i apply a rule - when will it apply? Instantly?

Cheers guys!

Zeice
07-04-2009, 08:51 PM
I believe you have reboot the server.

Kobaz
07-04-2009, 08:58 PM
I've been using #rules setdb in game and the change works instantly.

Zeice
07-04-2009, 09:41 PM
I didn't even know that command existed. -_-

Well learn something new everyday.

mixxit
07-05-2009, 02:21 AM
thanks for the info

Shendare
07-05-2009, 02:46 AM
The downside to #rules setdb is that it appears to wipe out the Notes field.

Kobaz
07-05-2009, 04:02 AM
I can see how to fix that algorithmically, but my C++ isn't up to it.

---
In memory, add a 1 byte field to the rule struct, called hasNote, default value false

When loading rules from DB, set hasNote to true if note field is non empty

In _SaveRule use an UPDATE instead of REPLACE if hasNote is true.
---

If rule isn't in DB then hasNote is false and the current REPLACE query is run.

Cost is slightly longer load time at server startup, and less than a kb of memory (assuming that there are less than a k of rules!).

I'll learn C++ by breaking my server trying to implement this.... it'll take me a while.

gaeorn
07-05-2009, 12:19 PM
should be able to use INSERT ... ON DUPLICATE KEY UPDATE ... ; syntax and not need to track if the notes field exists.

AndMetal
07-05-2009, 12:51 PM
Here's the function from common/rulesys.cpp (http://code.google.com/p/projecteqemu/source/browse/trunk/EQEmuServer/common/rulesys.cpp?r=744#282):


void RuleManager::_SaveRule(Database *db, RuleType type, uint16 index) {
char vstr[100];

switch(type) {
case IntRule:
sprintf(vstr, "%d", m_RuleIntValues[index]);
break;
case RealRule:
sprintf(vstr, "%.13f", m_RuleRealValues[index]);
break;
case BoolRule:
sprintf(vstr, "%s", m_RuleBoolValues[index]?"true":"false");
break;
}

char errbuf[MYSQL_ERRMSG_SIZE];
char* query = 0;
if (!db->RunQuery(query, MakeAnyLenString(&query,
"REPLACE INTO rule_values (ruleset_id, rule_name, rule_value) "
" VALUES(%d, '%s', '%s')",
m_activeRuleset, _GetRuleName(type, index), vstr),errbuf))
{
_log(RULES__ERROR, "Fauled to set rule in the database: %s: %s", query,errbuf);
}
safe_delete_array(query);
}


I'd commit the change real quick, but I don't really have enough time to test it out. If someone else ends up committing this, please change that typo :)

Kobaz
07-05-2009, 04:39 PM
That change works.

trevius
07-06-2009, 05:43 PM
You can also do "#rules reload" but it only reloads them for the current zone you are in.