[GM Commands] Split GM Commands Into Separate Files (#1766)

* Split GM commands into their own files

* Code cleanup
This commit is contained in:
Chris Miles
2021-11-14 22:48:47 -06:00
committed by GitHub
parent 293361a1f7
commit 0550fcfd3f
291 changed files with 19224 additions and 15798 deletions
+39
View File
@@ -0,0 +1,39 @@
#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);
}