Chris Miles 0550fcfd3f
[GM Commands] Split GM Commands Into Separate Files (#1766)
* Split GM commands into their own files

* Code cleanup
2021-11-14 22:48:47 -06:00

40 lines
997 B
C++
Executable File

#include "../client.h"
void command_spawnfix(Client *c, const Seperator *sep)
{
Mob *target_mob = c->GetTarget();
if (!target_mob || !target_mob->IsNPC()) {
c->Message(Chat::White, "Error: #spawnfix: Need an NPC target.");
return;
}
Spawn2 *s2 = target_mob->CastToNPC()->respawn2;
if (!s2) {
c->Message(
Chat::White,
"#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(),
target_mob->GetFixedZ(c->GetPosition()),
c->GetHeading(),
s2->GetID()
);
auto results = content_db.QueryDatabase(query);
if (!results.Success()) {
c->Message(Chat::Red, "Update failed! MySQL gave the following error:");
c->Message(Chat::Red, results.ErrorMessage().c_str());
return;
}
c->Message(Chat::White, "Updating coordinates successful.");
target_mob->Depop(false);
}