EQEmulator Forums

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

WildcardX 08-18-2006 02:35 PM

New Spawnstatus Command
 
I found the existing spawnstatus command to be limiting and have enhanced it to provide additional functionality that I think most server operators will applaud. Unfortunately, I don't have a diff file for this code so please accept what I can offer, the code snippets below...

Replace the existing "command_spawnstatus()" method with the following in the command.cpp file...

Code:

void command_spawnstatus(Client *c, const Seperator *sep)
{
        if((isalpha(sep->arg[1][0])) | (sep->arg[1][0] == 0))
        {
                if((sep->arg[1][0] == 'e') | (sep->arg[1][0] == 'E'))
                {
                        // show only enabled spawns
                        zone->ShowEnabledSpawnStatus(c);
                }
                else if((sep->arg[1][0] == 'd') | (sep->arg[1][0] == 'D'))
                {
                        // show only disabled spawns
                        zone->ShowDisabledSpawnStatus(c);
                }
                else if((sep->arg[1][0] == 'a') | (sep->arg[1][0] == 'A'))
                {
                        // show all spawn staus with no filters
                        zone->SpawnStatus(c);
                }
                else
                {
                        c->Message(0, "Usage: #spawnstatus <all | disabled | enabled | {Spawn2 ID}>");
                }
        }
        else
        {
                // show spawn status by spawn2 id
                zone->ShowSpawnStatusByID(c, atoi(sep->arg[1]));
        }
}

Add the following declarations in zone.h...

Code:

void        ShowEnabledSpawnStatus(Mob* client);
void    ShowDisabledSpawnStatus(Mob* client);
void    ShowSpawnStatusByID(Mob* client, uint32 spawnid);

Add the following methods to the zone.cpp file...

Code:

void Zone::ShowEnabledSpawnStatus(Mob* client)
{
        LinkedListIterator<Spawn2*> iterator(spawn2_list);
        int x = 0;
        int iEnabledCount = 0;

        iterator.Reset();

        while(iterator.MoreElements())
        {
                if (iterator.GetData()->timer.GetRemainingTime() != 0xFFFFFFFF)
                {
                        client->Message(0, "  %d:  %1.1f, %1.1f, %1.1f:  %1.2f", iterator.GetData()->GetID(), iterator.GetData()->GetX(), iterator.GetData()->GetY(), iterator.GetData()->GetZ(), (float)iterator.GetData()->timer.GetRemainingTime() / 1000);
                        iEnabledCount++;
                }

                x++;
                iterator.Advance();
        }

        client->Message(0, "%i of %i spawns listed.", iEnabledCount, x);
}

void Zone::ShowDisabledSpawnStatus(Mob* client)
{
        LinkedListIterator<Spawn2*> iterator(spawn2_list);
        int x = 0;
        int iDisabledCount = 0;

        iterator.Reset();

        while(iterator.MoreElements())
        {
                if (iterator.GetData()->timer.GetRemainingTime() == 0xFFFFFFFF)
                {
                        client->Message(0, "  %d:  %1.1f, %1.1f, %1.1f:  disabled", iterator.GetData()->GetID(), iterator.GetData()->GetX(), iterator.GetData()->GetY(), iterator.GetData()->GetZ());
                        iDisabledCount++;
                }

                x++;
                iterator.Advance();
        }

        client->Message(0, "%i of %i spawns listed.", iDisabledCount, x);
}

void Zone::ShowSpawnStatusByID(Mob* client, uint32 spawnid)
{
        LinkedListIterator<Spawn2*> iterator(spawn2_list);
        int x = 0;
        int iSpawnIDCount = 0;

        iterator.Reset();

        while(iterator.MoreElements())
        {
                if (iterator.GetData()->GetID() == spawnid)
                {
                        if (iterator.GetData()->timer.GetRemainingTime() == 0xFFFFFFFF)
                                client->Message(0, "  %d:  %1.1f, %1.1f, %1.1f:  disabled", iterator.GetData()->GetID(), iterator.GetData()->GetX(), iterator.GetData()->GetY(), iterator.GetData()->GetZ());
                        else
                                client->Message(0, "  %d:  %1.1f, %1.1f, %1.1f:  %1.2f", iterator.GetData()->GetID(), iterator.GetData()->GetX(), iterator.GetData()->GetY(), iterator.GetData()->GetZ(), (float)iterator.GetData()->timer.GetRemainingTime() / 1000);

                        iSpawnIDCount++;

                        break;
                }

                x++;
                iterator.Advance();
        }

        if(iSpawnIDCount > 0)
                client->Message(0, "%i of %i spawns listed.", iSpawnIDCount, x);
        else
                client->Message(0, "No matching spawn id was found in this zone.");
}

I have implemented and tested this code on EQEmu 0.7.0-843, enjoy.

WildcardX 09-21-2006 02:40 AM

Just wanted to bump this to get it into the next code release.

fathernitwit 10-02-2006 02:45 PM

I put in a slightly modified version for you.


All times are GMT -4. The time now is 04:35 PM.

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