EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Development::Server Code Submissions (https://www.eqemulator.org/forums/forumdisplay.php?f=669)
-   -   Shutdown timer rule/zone basis (https://www.eqemulator.org/forums/showthread.php?t=26425)

Rocker8956 10-04-2008 04:35 PM

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

cybernine186 10-23-2008 04:44 PM

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

cavedude 10-23-2008 08:03 PM

Might want to grab SVN, which has this already in it. It also has additional changes to this system that prevents a zone crash.

cybernine186 10-23-2008 08:33 PM

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.

Rocker8956 10-23-2008 09:08 PM

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.


All times are GMT -4. The time now is 08:40 PM.

Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.