For the short attention span crowd, YES it is broken.
Wolfman, it's mostly hitting the same npc twice.
Current implementation in my local tree,
fixes a memleak, target errors, checks for dupes, and despawns the npc.
The big problem comes from us altering the spawn2 and not reloading it into the zones cache. Once all the npc's are gone or in thier correct position you need to #shutdown(static) or leave(dynamic) the zone, I'll look into spliting the cacheing out into a seperate function we can call from zone->Repop().
Code:
#if 0
// Corrupts zone data
// test with a #repop after a #spawnfix
else if (strcasecmp(sep->arg[0], "#spawnfix") == 0) {
if (!target||!target->IsNPC()) {
Message(0, "Error: #spawnfix: No Target.");
}
else {
int32 tmp = 0;
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
MYSQL_RES *result;
MYSQL_ROW row;
if (database.RunQuery(query, MakeAnyLenString(&query, "SELECT id from spawn2 where zone='%s' AND x='%f' AND y='%f' AND heading='%f'", zone->GetShortName(), target->GetX(), target->GetY(), target->GetHeading()), errbuf, &result)) {
if (mysql_num_rows(result) == 1) {
row = mysql_fetch_row(result);
delete[] query;
mysql_free_result(result);
tmp = atoi(row[0]);
if(database.RunQuery(query, MakeAnyLenString(&query, "UPDATE spawn2 SET x='%f', y='%f', z='%f', heading='%f' WHERE id='%i'",this->GetX(), this->GetY(), this->GetZ(), this->GetHeading(),tmp), errbuf, 0)){
Message(0, "Updating coordinates successful.");
delete[] query;
target->Depop(false);
}
else {
Message(0, "Update failed, UPDATE command error!");
delete[] query;
mysql_free_result(result);
}
}
else {
delete[] query;
mysql_free_result(result);
Message(0, "Update failed, duplicate spawns detected!");
}
}
else {
delete[] query;
mysql_free_result(result);
Message(0, "Update failed, SELECT command error!");
}
}
}
#endif