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