Rocker8956
10-04-2008, 04:35 PM
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
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
int getZoneShutDownDelay(int32 zoneID);
zone\zonedb.cpp
At end insert
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
void StartShutdownTimer(int32 set_time = ZONE_AUTOSHUTDOWN_DELAY);
TO
void StartShutdownTimer(int32 set_time = (RuleI(Zone, AutoShutdownDelay)));
zone\zone.h
near line 32 INSERT
#include "../common/rulesys.h"
zone\zone.cpp
Line 654
CHANGE
autoshutdown_timer(ZONE_AUTOSHUTDOWN_DELAY),
TO
autoshutdown_timer((RuleI(Zone, AutoShutdownDelay))),
zone\zone.cpp
FIND (was line 1113 on mine)
void Zone::StartShutdownTimer(int32 set_time) {
Replace entire function with
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
RULE_INT ( Zone, AutoShutdownDelay, 5000 ) //How long a dynamic zone stays loaded while empty
zone\Features.h
Find and DELETE (line 38 for me)
#define ZONE_AUTOSHUTDOWN_DELAY 5000
zone\zone.h line 21
Find and DELETE (line 21 for me)
//#define ZONE_AUTOSHUTDOWN_DELAY 5000
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
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
int getZoneShutDownDelay(int32 zoneID);
zone\zonedb.cpp
At end insert
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
void StartShutdownTimer(int32 set_time = ZONE_AUTOSHUTDOWN_DELAY);
TO
void StartShutdownTimer(int32 set_time = (RuleI(Zone, AutoShutdownDelay)));
zone\zone.h
near line 32 INSERT
#include "../common/rulesys.h"
zone\zone.cpp
Line 654
CHANGE
autoshutdown_timer(ZONE_AUTOSHUTDOWN_DELAY),
TO
autoshutdown_timer((RuleI(Zone, AutoShutdownDelay))),
zone\zone.cpp
FIND (was line 1113 on mine)
void Zone::StartShutdownTimer(int32 set_time) {
Replace entire function with
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
RULE_INT ( Zone, AutoShutdownDelay, 5000 ) //How long a dynamic zone stays loaded while empty
zone\Features.h
Find and DELETE (line 38 for me)
#define ZONE_AUTOSHUTDOWN_DELAY 5000
zone\zone.h line 21
Find and DELETE (line 21 for me)
//#define ZONE_AUTOSHUTDOWN_DELAY 5000