EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Development::Development (https://www.eqemulator.org/forums/forumdisplay.php?f=590)
-   -   New Quest Command quest::clearspawntimers() (https://www.eqemulator.org/forums/showthread.php?t=26295)

trevius 09-21-2008 11:10 PM

New Quest Command quest::clearspawntimers()
 
Discussion: http://eqemulator.net/forums/showthread.php?t=26295

This command should work similar to the "#repop force" command which will reset the spawn timers for the zone and repop everything including anything that was down due to having a timer left on it. I haven't tested this code yet, but I am going to test it tonight and verify it works. I basically just looked at the code for quest::repopzone() and for the command #repop and combined the 2, so I think it should work. I will report back later after I get the chance to test it.


questmgr.cpp
Code:

void QuestManager::clearspawntimers() {
        if(zone)  {
                char errbuf[MYSQL_ERRMSG_SIZE];
                char *query = 0;
                database.RunQuery(query, MakeAnyLenString(&query, "UPDATE spawn2 SET timeleft=0 WHERE zone='%s'",zone->GetShortName()), errbuf);
                safe_delete_array(query);
        }
}

questmgr.h
Code:

        void clearspawntimers();

perlparser.cpp
Code:

XS(XS__clearspawntimers);
XS(XS__clearspawntimers)
{
        dXSARGS;
        if (items != 0)
                Perl_croak(aTHX_ "Usage: clearspawntimers()");

        quest_manager.clearspawntimers();

        XSRETURN_EMPTY;
}

Code:

                newXS(strcpy(buf, "clearspawntimers"), XS__clearspawntimers, file);
If this doesn't work, I will keep messing with it until I can get it working unless someone else feels like making some suggestions.

trevius 09-21-2008 11:45 PM

Compiled so far without a problem. Now to test if after the reboot tonight on my server :P

MNWatchdog 09-21-2008 11:49 PM

Why post before testing?

renoofturks1 09-21-2008 11:56 PM

So others may see it and review his work. I prefer to have someone one over my cod before it goes live onto a server. Other people may be able to see things you never even thought of.

trevius 09-22-2008 12:11 AM

Quote:

Originally Posted by MNWatchdog (Post 156534)
Why post before testing?

Ya, mostly posting because I can write this while I am work, but I can't test it from work. I might as well note the code here even if it isn't fully tested yet IMO. This should be pretty simple code and even if it doesn't work, I am sure it will work after 1 or 2 small changes. This way people get a chance to review it and point out if there are any major mistakes before I test it out on my server potentially effecting 50 - 80 players while I try the code.

Normally I would just post new code ideas in the development section if I am not too sure that they will work. But in this case, just setting up a quest command by using code from a normal command should be pretty straight forward. I got the new traindiscs and new version of scribespells quest commands working that way easy enough. Plus, being a mod, I can always go back and edit my post at any time to make any corrections to the code if needed or even move the post to another section if it never gets finished :P

I don't have a clue of how to write code from scratch, but I work pretty well from example :)

trevius 09-22-2008 03:05 AM

Ok, I changed how this command works slightly after testing the code. I renamed the command to quest::clearspawntimers(), and now it is just used to clear the spawn timers. So, you have the option to do a quest::repopzone() after it, or just let it wait until the zone goes down and comes back up, or whatever.

The code I submitted above has been tested and is working fine on my server. If people think it would be better just to add in the actual repop to the command, I could do that instead, but I always like having open options :)

cavedude 09-22-2008 01:45 PM

This is a great command! There are plenty of times on PEQ when I'm fiddling with spawns, and when I am done and am about to go to do a /repop force I see people hunting in the zone. In order to not disturb them, I just set timeleft to 0 in the DB at a prompt and leave. This guy just made my life easier!

trevius 09-23-2008 06:40 AM

Well, this is a quest command, but I could certainly make a normal # command for it as well if you like. They are pretty simple with examples hehe.

cavedude 09-23-2008 09:48 AM

It's no real difference to me. I have a custom NPC in PEQ's template folder that I spawn whenever I need to test something or the like.


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

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