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

Reply
 
Thread Tools Display Modes
  #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
  #2  
Old 10-23-2008, 04:44 PM
cybernine186
Sarnak
 
Join Date: Feb 2008
Posts: 87
Default

It compiled good, I am putting this into action ASAP. We have had a lot of trouble with people that use the zone shutdown with 0 players as an exploit to get items that is rare.

Something like this is just what I was looking for.

Thanks a bunch
Reply With Quote
  #3  
Old 10-23-2008, 08:03 PM
cavedude's Avatar
cavedude
The PEQ Dude
 
Join Date: Apr 2003
Location: -
Posts: 1,988
Default

Might want to grab SVN, which has this already in it. It also has additional changes to this system that prevents a zone crash.
Reply With Quote
  #4  
Old 10-23-2008, 08:33 PM
cybernine186
Sarnak
 
Join Date: Feb 2008
Posts: 87
Default

The code above crashes the zone? We have special code that we choose to enter into our source code and do not always use the SVN, usually if I need changes I have to sort through the SVN code and determine what is what.
Reply With Quote
  #5  
Old 10-23-2008, 09:08 PM
Rocker8956
Hill Giant
 
Join Date: Sep 2007
Posts: 117
Default

If you replace the following functions with the code out of the SVN you should be good. I am fairly certain the two changes were made in these functions. I recall one of them dealing with the return value.

Zone\zonedb.cpp
int ZoneDatabase::getZoneShutDownDelay(int32 zoneID)

and

zone\zone.cpp
void Zone::StartShutdownTimer(int32 set_time)

If I get time I will try to pull them and repost here.
Reply With Quote
Reply

Thread Tools
Display Modes

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 07:56 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