Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Bug Reports

Development::Bug Reports Post detailed bug reports and what you would like to see next in the emu here.

Reply
 
Thread Tools Display Modes
  #1  
Old 08-12-2007, 06:30 AM
John Adams
Demi-God
 
Join Date: Jul 2006
Posts: 1,552
Default Crash on #rules reload

As usual, excuse my extremely novice coding knowledge... but I found a potentially evil bug in the #rules reload command. If you had not previously used #rules load, the zone (and in my case, the entire Linux server) will crash. I traced it using a breakpoint to the RulesManager::LoadRules(duh) routine... where *ruleset is expected. No check is being done if there is a valid ruleset set... The zone crash is happening inside GetRulesetID(), but can be fixed before going there by assuming "default" if a ruleset has not been loaded previously.

So I added a check. Please, if there is a better way of doing this, or if this is completely off-base, let me know. Still in learning mode here, but this fix does appear to work for me. If it's a legit bug, I will move the thread to Bugs.

Thanks!

In rulesys.cpp:
Code:
bool RuleManager::LoadRules(Database *db, const char *ruleset) {
	char errbuf[MYSQL_ERRMSG_SIZE];
	char *query = 0;
	MYSQL_RES *result;
	MYSQL_ROW row;

	if (!ruleset)				// getting a crazy server crash if you don't load a set before reloading =) jadams 8/12/07
		ruleset="default";		// let's try assuming ruleset='default' ?

	int rsid = GetRulesetID(db, ruleset);
	if(rsid < 0) {
		_log(RULES__ERROR, "Failed to find ruleset '%s' for load operation. Canceling.", ruleset);
		return(false);
	}

	_log(RULES__CHANGE, "Loading rule set '%s' (%d)", ruleset, rsid);

	m_activeRuleset = rsid;
	m_activeName = ruleset;
	
	if (db->RunQuery(query, MakeAnyLenString(&query, 
		"SELECT rule_name, rule_value"
		" FROM rule_values"
		" WHERE ruleset_id=%d", rsid), errbuf, &result))
	{
		safe_delete_array(query);
		while((row = mysql_fetch_row(result))) {
			if(!SetRule(row[0], row[1], false))
				_log(RULES__ERROR, "Unable to interpret rule record for %s", row[0]);
		}
		mysql_free_result(result);
	} else {
		safe_delete_array(query);
		LogFile->write(EQEMuLog::Error, "Error in LoadRules query %s: %s", query, errbuf);
		return(false);
	}

	return(true);
}
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 04:21 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3