Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Server Code Submissions

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 10-04-2008, 04:35 PM
Rocker8956
Hill Giant
 
Join Date: Sep 2007
Posts: 117
Default Shutdown timer rule/zone basis

This code allows zone shutdown timers to be set on a per zone basis.
Should help some servers from booting up the same zone 30 times in 10 minutes
Should also help with zones that have graveyards in other zones (I am assuming the timer on corpses stops while a zone is shutdown)

Short explanation of how this works.
If you want to make blackburrow wait 10 minutes after it is empty to shutdown
Find blackburrow in the zone table and change its shutdowndelay to 600000

Let me know if I missed something.

Required SQL
Code:
ALTER TABLE `zone` ADD column `shutdowndelay` bigint (16) unsigned NOT NULL default '5000';
INSERT INTO rule_values VALUES (1,'Zone:AutoShutdownDelay', 5000);
zone\Zonedb.h
Near line 181 Insert
Code:
int		getZoneShutDownDelay(int32 zoneID);
zone\zonedb.cpp
At end insert
Code:
int ZoneDatabase::getZoneShutDownDelay(int32 zoneID)
{
	char errbuf[MYSQL_ERRMSG_SIZE];
    char *query = 0;
    MYSQL_RES *result;
    MYSQL_ROW row;
	
	if (RunQuery(query, MakeAnyLenString(&query, "SELECT shutdowndelay FROM zone WHERE zoneidnumber=%i", zoneID), errbuf, &result))
	{
		if (mysql_num_rows(result) == 1) {
			row = mysql_fetch_row(result);
			mysql_free_result(result);
			safe_delete_array(query);
			return (atoi(row[0]));
		}
		else {
			cerr << "Error in getZoneShutDownDelay (more than one result) query '" << query << "' " << errbuf << endl;
			mysql_free_result(result);
			safe_delete_array(query);
			return (RuleI(Zone, AutoShutdownDelay));
		}
	}
	else {
		cerr << "Error in getZoneShutDownDelay query '" << query << "' " << errbuf << endl;
		safe_delete_array(query);
		mysql_free_result(result);
	}
	return (RuleI(Zone, AutoShutdownDelay));
}
zone\zone.h
near line 128
CHANGE
Code:
void	StartShutdownTimer(int32 set_time = ZONE_AUTOSHUTDOWN_DELAY);
TO
Code:
void	StartShutdownTimer(int32 set_time = (RuleI(Zone, AutoShutdownDelay)));
zone\zone.h
near line 32 INSERT
Code:
#include "../common/rulesys.h"
zone\zone.cpp
Line 654
CHANGE
Code:
autoshutdown_timer(ZONE_AUTOSHUTDOWN_DELAY),
TO
Code:
autoshutdown_timer((RuleI(Zone, AutoShutdownDelay))),
zone\zone.cpp
FIND (was line 1113 on mine)
Code:
void Zone::StartShutdownTimer(int32 set_time) {
Replace entire function with
Code:
void Zone::StartShutdownTimer(int32 set_time) {
	MZoneLock.lock();
	if (set_time > autoshutdown_timer.GetRemainingTime()) {
		if (set_time == (RuleI(Zone, AutoShutdownDelay)))
		{
			set_time = database.getZoneShutDownDelay(GetZoneID());
		}
		autoshutdown_timer.Start(set_time, false);
	}
	MZoneLock.unlock();
}
common\ruletypes.h
Near line 91 INSERT
Code:
RULE_INT ( Zone, AutoShutdownDelay, 5000 ) //How long a dynamic zone stays loaded while empty
zone\Features.h
Find and DELETE (line 38 for me)
Code:
#define ZONE_AUTOSHUTDOWN_DELAY		5000
zone\zone.h line 21
Find and DELETE (line 21 for me)
Code:
//#define ZONE_AUTOSHUTDOWN_DELAY		5000
Reply With Quote
 


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:47 PM.


 

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