mirror of
https://github.com/EQEmu/Server.git
synced 2026-01-04 03:13:52 +00:00
command_spawnfix converted to QueryDatabase
This commit is contained in:
parent
accedf7184
commit
d86fc1c141
@ -4511,33 +4511,31 @@ void command_npcspawn(Client *c, const Seperator *sep)
|
||||
}
|
||||
|
||||
void command_spawnfix(Client *c, const Seperator *sep) {
|
||||
Mob *t = c->GetTarget();
|
||||
if (!t || !t->IsNPC())
|
||||
Mob *targetMob = c->GetTarget();
|
||||
if (!targetMob || !targetMob->IsNPC()) {
|
||||
c->Message(0, "Error: #spawnfix: Need an NPC target.");
|
||||
else {
|
||||
Spawn2* s2 = t->CastToNPC()->respawn2;
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char *query = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
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->LogSQL(query);
|
||||
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);
|
||||
}
|
||||
}
|
||||
Spawn2* s2 = targetMob->CastToNPC()->respawn2;
|
||||
|
||||
if(!s2) {
|
||||
c->Message(0, "#spawnfix FAILED -- cannot determine which spawn entry in the database this mob came from.");
|
||||
return;
|
||||
}
|
||||
|
||||
std::string query = StringFormat("UPDATE spawn2 SET x = '%f', y = '%f', z = '%f', heading = '%f' WHERE id = '%i'",
|
||||
c->GetX(), c->GetY(), c->GetZ(), c->GetHeading(),s2->GetID());
|
||||
auto results = database.QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
c->Message(13, "Update failed! MySQL gave the following error:");
|
||||
c->Message(13, results.ErrorMessage().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
c->LogSQL(query.c_str());
|
||||
c->Message(0, "Updating coordinates successful.");
|
||||
targetMob->Depop(false);
|
||||
}
|
||||
|
||||
void command_loc(Client *c, const Seperator *sep)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user