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);
}
}
}