EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Archive::Development (https://www.eqemulator.org/forums/forumdisplay.php?f=621)
-   -   #spawnfix -- fixed! (https://www.eqemulator.org/forums/showthread.php?t=15793)

RangerDown 09-11-2004 09:37 AM

#spawnfix -- fixed!
 
The #spawnfix command in its current implementation has some shortcomings. Main one being that it tries to search the spawn2 database based on the mob's current x,y,z,heading - which means that
(1) if the mob starts moving or turns to face another direction, you can't use #spawnfix after that
(2) because of imprecision in the way floats are saved to the database, you effectively get to use #spawnfix ONCE per mob, and after that it will give you the "duplicate spawns detected" if you ever try to fix that same mob spawn again.

This rewritten #spawnfix command gets rid of those limitations by using the mob's spawn ID number from the database, instead of trying to query based on the mob's current position.

In zone/command.cpp, seek to where the "command_spawnfix" function is defined. Remove it completely, and replace it with this function:

Code:

void command_spawnfix(Client *c, const Seperator *sep)
{
        Mob *t = c->GetTarget();
        if (!t || !t->IsNPC())
                c->Message(0, "Error: #spawnfix: Need an NPC target.");
        else {
                Spawn2* s2 = t->CastToNPC()->respawn2;
                char errbuf[MYSQL_ERRMSG_SIZE];
                char *query = 0;

                if(!s2)
                {  c->Message(0, "#spawnfix FAILED -- cannot determine which spawn entry in the database this mob came from.");
                }
                else
                {  if(database.RunQuery(query, MakeAnyLenString(&query, "UPDATE spawn2 SET x='%f', y='%f', z='%f', heading='%f' WHERE id='%i'",c->GetX(), c->GetY(), c->GetZ(), c->GetHeading(),s2->GetID()), errbuf))
                    {        c->Message(0, "Updating coordinates successful.");
                        t->Depop(false);
                    }
                    else
                    {        c->Message(13, "Update failed! MySQL gave the following error:");
                        c->Message(13, errbuf);
                    }
                    safe_delete_array(query);
                }
        }
}


eq_addict_08 09-11-2004 01:45 PM

sweet, I hated getting that "duplicate spawns" error...

relorm500 09-17-2004 10:42 AM

OMG you rule all, F what Melwin owns.





Just Kidding Melwin.
Melwin = King of all

Cisyouc 09-17-2004 11:31 AM

Quote:

Originally Posted by relorm500
OMG you rule all, F what Melwin owns.





Just Kidding Melwin.
Melwin = King of all

/sigh

Cripp 09-17-2004 11:33 AM

lol why are you so obsessed with melwin


All times are GMT -4. The time now is 11:36 AM.

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