[Cleanup] Remove hard-coded Status Checks (#3727)

* [Cleanup] Remove hard-coded Status Checks

# Notes
- Removed the hard-coded GM status checks since if you have access to the command we can now limit access to subcommands if necessary.

* Update client_packet.cpp
This commit is contained in:
Alex King 2023-12-03 11:44:30 -05:00 committed by GitHub
parent 22994e3264
commit e719aa43cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 649 additions and 862 deletions

View File

@ -238,25 +238,6 @@ enum { //some random constants
// Timer to update aggrometer // Timer to update aggrometer
#define AGGRO_METER_UPDATE_MS 1000 #define AGGRO_METER_UPDATE_MS 1000
//Some hard coded statuses from commands and other places:
enum {
minStatusToBeGM = 40,
minStatusToUseGMCommands = 80,
minStatusToKick = 150,
minStatusToAvoidFalling = 100,
minStatusToIgnoreZoneFlags = 80,
minStatusToSeeOthersZoneFlags = 80,
minStatusToEditOtherGuilds = 80,
commandMovecharSelfOnly = 80, //below this == only self move allowed
commandMovecharToSpecials = 200, //ability to send people to cshom/load zones
commandCastSpecials = 100, //can cast special spells
commandDoAnimOthers = 100, //can #doanim on others
commandEditPlayerCorpses = 150, //can Edit Player Corpses
commandInterrogateInv = 100, //below this == only log on error state and self-only target dump
commandInvSnapshot = 150 //ability to clear/restore snapshots
};
// This is the item ID we use for say links, we use the max that fits in 5 ASCII chars // This is the item ID we use for say links, we use the max that fits in 5 ASCII chars
#define SAYLINK_ITEM_ID 0xFFFFF #define SAYLINK_ITEM_ID 0xFFFFF

View File

@ -1385,10 +1385,6 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
InitInnates(); InitInnates();
/* If GM not set in DB, and does not meet min status to be GM, reset */
if (m_pp.gm && admin < minStatusToBeGM)
m_pp.gm = 0;
/* Load Guild */ /* Load Guild */
if (!IsInAGuild()) { if (!IsInAGuild()) {
m_pp.guild_id = GUILD_NONE; m_pp.guild_id = GUILD_NONE;
@ -1702,8 +1698,9 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
this is not quite where live sends inventory, they do it after tribute this is not quite where live sends inventory, they do it after tribute
*/ */
if (loaditems) { /* Don't load if a length error occurs */ if (loaditems) { /* Don't load if a length error occurs */
if (admin >= minStatusToBeGM) if (m_pp.gm) {
m_inv.SetGMInventory(true); // set to true to allow expansion-restricted packets through m_inv.SetGMInventory(true); // set to true to allow expansion-restricted packets through
}
BulkSendInventoryItems(); BulkSendInventoryItems();
/* Send stuff on the cursor which isn't sent in bulk */ /* Send stuff on the cursor which isn't sent in bulk */
@ -6238,7 +6235,7 @@ void Client::Handle_OP_EnvDamage(const EQApplicationPacket *app)
damage = 31337; damage = 31337;
} }
if (admin >= minStatusToAvoidFalling && GetGM()) { if (GetGM()) {
Message( Message(
Chat::Red, Chat::Red,
fmt::format( fmt::format(
@ -6446,84 +6443,90 @@ void Client::Handle_OP_GetGuildsList(const EQApplicationPacket *app)
void Client::Handle_OP_GMBecomeNPC(const EQApplicationPacket *app) void Client::Handle_OP_GMBecomeNPC(const EQApplicationPacket *app)
{ {
if (Admin() < minStatusToUseGMCommands) { if (!GetGM()) {
Message(Chat::Red, "Your account has been reported for hacking."); Message(Chat::Red, "Your account has been reported for hacking.");
RecordPlayerEventLog(PlayerEvent::POSSIBLE_HACK, PlayerEvent::PossibleHackEvent{.message = "Used /becomenpc when they shouldn't be able to"}); RecordPlayerEventLog(PlayerEvent::POSSIBLE_HACK, PlayerEvent::PossibleHackEvent{.message = "Used /becomenpc when they shouldn't be able to"});
return; return;
} }
if (app->size != sizeof(BecomeNPC_Struct)) { if (app->size != sizeof(BecomeNPC_Struct)) {
LogError("Wrong size: OP_GMBecomeNPC, size=[{}], expected [{}]", app->size, sizeof(BecomeNPC_Struct)); LogError("Wrong size: OP_GMBecomeNPC, size=[{}], expected [{}]", app->size, sizeof(BecomeNPC_Struct));
return; return;
} }
//entity_list.QueueClients(this, app, false);
BecomeNPC_Struct* bnpc = (BecomeNPC_Struct*)app->pBuffer;
Mob* cli = (Mob*)entity_list.GetMob(bnpc->id); auto *b = (BecomeNPC_Struct *) app->pBuffer;
if (cli == nullptr) {
Mob *m = entity_list.GetMob(b->id);
if (!m) {
return; return;
} }
if (cli->IsClient()) { if (m->IsClient()) {
Client* target = cli->CastToClient(); Client *t = m->CastToClient();
target->QueuePacket(app); t->QueuePacket(app);
if(target->GetGM()) { if (t->GetGM()) {
target->SetInvul(false); t->SetInvul(false);
target->SetHideMe(false); t->SetHideMe(false);
target->SetGM(false); t->SetGM(false);
} }
cli->SendAppearancePacket(AT_NPCName, 1, true); m->SendAppearancePacket(AT_NPCName, 1, true);
target->SetBecomeNPC(true); t->SetBecomeNPC(true);
target->SetBecomeNPCLevel(bnpc->maxlevel); t->SetBecomeNPCLevel(b->maxlevel);
cli->MessageString(Chat::White, TOGGLE_OFF); m->MessageString(Chat::White, TOGGLE_OFF);
target->tellsoff = true; t->tellsoff = true;
target->UpdateWho(); t->UpdateWho();
} }
return;
} }
void Client::Handle_OP_GMDelCorpse(const EQApplicationPacket *app) void Client::Handle_OP_GMDelCorpse(const EQApplicationPacket *app)
{ {
if (app->size != sizeof(GMDelCorpse_Struct)) if (app->size != sizeof(GMDelCorpse_Struct)) {
return; return;
if (Admin() < commandEditPlayerCorpses) { }
if (!GetGM()) {
Message(Chat::Red, "Your account has been reported for hacking."); Message(Chat::Red, "Your account has been reported for hacking.");
RecordPlayerEventLog(PlayerEvent::POSSIBLE_HACK, PlayerEvent::PossibleHackEvent{.message = "Used /delcorpse"}); RecordPlayerEventLog(PlayerEvent::POSSIBLE_HACK, PlayerEvent::PossibleHackEvent{.message = "Used /delcorpse"});
return; return;
} }
GMDelCorpse_Struct* dc = (GMDelCorpse_Struct *)app->pBuffer;
Mob* corpse = entity_list.GetMob(dc->corpsename); auto *c = (GMDelCorpse_Struct *) app->pBuffer;
if (corpse == 0) { Mob *corpse = entity_list.GetMob(c->corpsename);
if (!c) {
return; return;
} }
if (corpse->IsCorpse() != true) {
if (!corpse->IsCorpse()) {
return; return;
} }
corpse->CastToCorpse()->Delete(); corpse->CastToCorpse()->Delete();
std::cout << name << " deleted corpse " << dc->corpsename << std::endl; Message(Chat::Red, fmt::format("Corpse {} deleted.", c->corpsename).c_str());
Message(Chat::Red, "Corpse %s deleted.", dc->corpsename);
return;
} }
void Client::Handle_OP_GMEmoteZone(const EQApplicationPacket *app) void Client::Handle_OP_GMEmoteZone(const EQApplicationPacket *app)
{ {
if (Admin() < minStatusToUseGMCommands) {
Message(Chat::Red, "Your account has been reported for hacking.");
return;
}
if (app->size != sizeof(GMEmoteZone_Struct)) { if (app->size != sizeof(GMEmoteZone_Struct)) {
LogError("Wrong size: OP_GMEmoteZone, size=[{}], expected [{}]", app->size, sizeof(GMEmoteZone_Struct)); LogError("Wrong size: OP_GMEmoteZone, size=[{}], expected [{}]", app->size, sizeof(GMEmoteZone_Struct));
return; return;
} }
GMEmoteZone_Struct* gmez = (GMEmoteZone_Struct*)app->pBuffer;
char* newmessage = nullptr; if (!GetGM()) {
if (strstr(gmez->text, "^") == 0) Message(Chat::Red, "Your account has been reported for hacking.");
entity_list.Message(Chat::White, 15, gmez->text); RecordPlayerEventLog(PlayerEvent::POSSIBLE_HACK, PlayerEvent::PossibleHackEvent{.message = "Used /emote"});
else { return;
for (newmessage = strtok((char*)gmez->text, "^"); newmessage != nullptr; newmessage = strtok(nullptr, "^")) }
entity_list.Message(Chat::White, 15, newmessage);
auto *gmez = (GMEmoteZone_Struct*)app->pBuffer;
char *newmessage = nullptr;
if (strstr(gmez->text, "^") == 0) {
entity_list.Message(0, Chat::White, gmez->text);
} else {
for (newmessage = strtok((char *) gmez->text, "^"); newmessage != nullptr; newmessage = strtok(nullptr, "^")) {
entity_list.Message(0, Chat::White, newmessage);
}
} }
return;
} }
void Client::Handle_OP_GMEndTraining(const EQApplicationPacket *app) void Client::Handle_OP_GMEndTraining(const EQApplicationPacket *app)
@ -6533,154 +6536,149 @@ void Client::Handle_OP_GMEndTraining(const EQApplicationPacket *app)
DumpPacket(app); DumpPacket(app);
return; return;
} }
OPGMEndTraining(app); OPGMEndTraining(app);
return;
} }
void Client::Handle_OP_GMFind(const EQApplicationPacket *app) void Client::Handle_OP_GMFind(const EQApplicationPacket *app)
{ {
if (Admin() < minStatusToUseGMCommands) {
Message(Chat::Red, "Your account has been reported for hacking.");
RecordPlayerEventLog(PlayerEvent::POSSIBLE_HACK, PlayerEvent::PossibleHackEvent{.message = "Used /find"});
return;
}
if (app->size != sizeof(GMFind_Struct)) { if (app->size != sizeof(GMFind_Struct)) {
LogError("Wrong size: OP_GMFind, size=[{}], expected [{}]", app->size, sizeof(GMFind_Struct)); LogError("Wrong size: OP_GMFind, size=[{}], expected [{}]", app->size, sizeof(GMFind_Struct));
return; return;
} }
//Break down incoming if (!GetGM()) {
auto* request = (GMFind_Struct*) app->pBuffer; Message(Chat::Red, "Your account has been reported for hacking.");
//Create a new outgoing RecordPlayerEventLog(PlayerEvent::POSSIBLE_HACK, PlayerEvent::PossibleHackEvent{.message = "Used /find"});
auto outapp = new EQApplicationPacket(OP_GMFind, sizeof(GMFind_Struct)); return;
auto* foundplayer = (GMFind_Struct*) outapp->pBuffer;
//Copy the constants
strcpy(foundplayer->charname, request->charname);
strcpy(foundplayer->gmname, request->gmname);
//Check if the NPC exits intrazone...
auto* gt = entity_list.GetMob(request->charname);
if (gt) {
foundplayer->success = 1;
foundplayer->x = gt->GetX();
foundplayer->y = gt->GetY();
foundplayer->z = gt->GetZ();
foundplayer->zoneID = zone->GetZoneID();
} }
//Send the packet...
auto *r = (GMFind_Struct *) app->pBuffer;
auto outapp = new EQApplicationPacket(OP_GMFind, sizeof(GMFind_Struct));
auto *f = (GMFind_Struct *) outapp->pBuffer;
strcpy(f->charname, r->charname);
strcpy(f->gmname, r->gmname);
auto* gt = entity_list.GetMob(r->charname);
if (gt) {
f->success = 1;
f->x = gt->GetX();
f->y = gt->GetY();
f->z = gt->GetZ();
f->zoneID = zone->GetZoneID();
}
FastQueuePacket(&outapp); FastQueuePacket(&outapp);
return;
} }
void Client::Handle_OP_GMGoto(const EQApplicationPacket *app) void Client::Handle_OP_GMGoto(const EQApplicationPacket *app)
{ {
if (app->size != sizeof(GMSummon_Struct)) { if (app->size != sizeof(GMSummon_Struct)) {
std::cout << "Wrong size on OP_GMGoto. Got: " << app->size << ", Expected: " << sizeof(GMSummon_Struct) << std::endl; LogError("Wrong size: OP_GMGoto, size=[{}], expected [{}]", app->size, sizeof(GMSummon_Struct));
return; return;
} }
if (Admin() < minStatusToUseGMCommands) {
if (!GetGM()) {
Message(Chat::Red, "Your account has been reported for hacking."); Message(Chat::Red, "Your account has been reported for hacking.");
RecordPlayerEventLog(PlayerEvent::POSSIBLE_HACK, PlayerEvent::PossibleHackEvent{.message = "Used /goto"}); RecordPlayerEventLog(PlayerEvent::POSSIBLE_HACK, PlayerEvent::PossibleHackEvent{.message = "Used /goto"});
return; return;
} }
GMSummon_Struct* gmg = (GMSummon_Struct*)app->pBuffer;
Mob* gt = entity_list.GetMob(gmg->charname); auto *gmg = (GMSummon_Struct *) app->pBuffer;
if (gt != nullptr) { Mob *gt = entity_list.GetMob(gmg->charname);
if (!gt) {
MovePC(zone->GetZoneID(), zone->GetInstanceID(), gt->GetX(), gt->GetY(), gt->GetZ(), gt->GetHeading()); MovePC(zone->GetZoneID(), zone->GetInstanceID(), gt->GetX(), gt->GetY(), gt->GetZ(), gt->GetHeading());
} } else if (!worldserver.Connected()) {
else if (!worldserver.Connected())
Message(Chat::Red, "Error: World server disconnected."); Message(Chat::Red, "Error: World server disconnected.");
else { } else {
auto pack = new ServerPacket(ServerOP_GMGoto, sizeof(ServerGMGoto_Struct)); auto pack = new ServerPacket(ServerOP_GMGoto, sizeof(ServerGMGoto_Struct));
memset(pack->pBuffer, 0, pack->size); memset(pack->pBuffer, 0, pack->size);
ServerGMGoto_Struct* wsgmg = (ServerGMGoto_Struct*)pack->pBuffer; ServerGMGoto_Struct *wsgmg = (ServerGMGoto_Struct *) pack->pBuffer;
strcpy(wsgmg->myname, GetName()); strcpy(wsgmg->myname, GetName());
strcpy(wsgmg->gotoname, gmg->charname); strcpy(wsgmg->gotoname, gmg->charname);
wsgmg->admin = admin; wsgmg->admin = admin;
worldserver.SendPacket(pack); worldserver.SendPacket(pack);
safe_delete(pack); safe_delete(pack);
} }
return;
} }
void Client::Handle_OP_GMHideMe(const EQApplicationPacket *app) void Client::Handle_OP_GMHideMe(const EQApplicationPacket *app)
{ {
if (Admin() < minStatusToUseGMCommands) {
Message(Chat::Red, "Your account has been reported for hacking.");
RecordPlayerEventLog(PlayerEvent::POSSIBLE_HACK, PlayerEvent::PossibleHackEvent{.message = "Used /hideme"});
return;
}
if (app->size != sizeof(SpawnAppearance_Struct)) { if (app->size != sizeof(SpawnAppearance_Struct)) {
LogError("Wrong size: OP_GMHideMe, size=[{}], expected [{}]", app->size, sizeof(SpawnAppearance_Struct)); LogError("Wrong size: OP_GMHideMe, size=[{}], expected [{}]", app->size, sizeof(SpawnAppearance_Struct));
return; return;
} }
SpawnAppearance_Struct* sa = (SpawnAppearance_Struct*)app->pBuffer;
Message(Chat::Red, "#: %i, %i", sa->type, sa->parameter);
SetHideMe(!sa->parameter);
return;
if (!GetGM()) {
Message(Chat::Red, "Your account has been reported for hacking.");
RecordPlayerEventLog(PlayerEvent::POSSIBLE_HACK, PlayerEvent::PossibleHackEvent{.message = "Used /hideme"});
return;
}
auto *sa = (SpawnAppearance_Struct *) app->pBuffer;
SetHideMe(!sa->parameter);
} }
void Client::Handle_OP_GMKick(const EQApplicationPacket *app) void Client::Handle_OP_GMKick(const EQApplicationPacket *app)
{ {
if (app->size != sizeof(GMKick_Struct)) if (app->size != sizeof(GMKick_Struct)) {
return; return;
if (Admin() < minStatusToKick) { }
if (!GetGM()) {
Message(Chat::Red, "Your account has been reported for hacking."); Message(Chat::Red, "Your account has been reported for hacking.");
RecordPlayerEventLog(PlayerEvent::POSSIBLE_HACK, PlayerEvent::PossibleHackEvent{.message = "Used /kick"}); RecordPlayerEventLog(PlayerEvent::POSSIBLE_HACK, PlayerEvent::PossibleHackEvent{.message = "Used /kick"});
return; return;
} }
GMKick_Struct* gmk = (GMKick_Struct *)app->pBuffer;
Client* client = entity_list.GetClientByName(gmk->name); auto *gmk = (GMKick_Struct *)app->pBuffer;
if (client == 0) { Client *c = entity_list.GetClientByName(gmk->name);
if (!worldserver.Connected()) if (!c) {
if (!worldserver.Connected()) {
Message(Chat::Red, "Error: World server disconnected"); Message(Chat::Red, "Error: World server disconnected");
else { } else {
auto pack = new ServerPacket(ServerOP_KickPlayer, sizeof(ServerKickPlayer_Struct)); auto pack = new ServerPacket(ServerOP_KickPlayer, sizeof(ServerKickPlayer_Struct));
ServerKickPlayer_Struct* skp = (ServerKickPlayer_Struct*)pack->pBuffer; auto *skp = (ServerKickPlayer_Struct *) pack->pBuffer;
strcpy(skp->adminname, gmk->gmname); strcpy(skp->adminname, gmk->gmname);
strcpy(skp->name, gmk->name); strcpy(skp->name, gmk->name);
skp->adminrank = Admin(); skp->adminrank = Admin();
worldserver.SendPacket(pack); worldserver.SendPacket(pack);
safe_delete(pack); safe_delete(pack);
} }
} } else {
else {
entity_list.QueueClients(this, app); entity_list.QueueClients(this, app);
//client->Kick();
} }
return;
} }
void Client::Handle_OP_GMKill(const EQApplicationPacket *app) void Client::Handle_OP_GMKill(const EQApplicationPacket *app)
{ {
if (Admin() < minStatusToUseGMCommands) {
Message(Chat::Red, "Your account has been reported for hacking.");
RecordPlayerEventLog(PlayerEvent::POSSIBLE_HACK, PlayerEvent::PossibleHackEvent{.message = "Used /kill"});
return;
}
if (app->size != sizeof(GMKill_Struct)) { if (app->size != sizeof(GMKill_Struct)) {
LogError("Wrong size: OP_GMKill, size=[{}], expected [{}]", app->size, sizeof(GMKill_Struct)); LogError("Wrong size: OP_GMKill, size=[{}], expected [{}]", app->size, sizeof(GMKill_Struct));
return; return;
} }
GMKill_Struct* gmk = (GMKill_Struct *)app->pBuffer;
Mob* obj = entity_list.GetMob(gmk->name); if (!GetGM()) {
Client* client = entity_list.GetClientByName(gmk->name); Message(Chat::Red, "Your account has been reported for hacking.");
if (obj != 0) { RecordPlayerEventLog(PlayerEvent::POSSIBLE_HACK, PlayerEvent::PossibleHackEvent{.message = "Used /kill"});
if (client != 0) { return;
}
auto *gmk = (GMKill_Struct *) app->pBuffer;
Mob *obj = entity_list.GetMob(gmk->name);
Client *c = entity_list.GetClientByName(gmk->name);
if (obj) {
if (c) {
entity_list.QueueClients(this, app); entity_list.QueueClients(this, app);
} } else {
else {
obj->Kill(); obj->Kill();
} }
} } else {
else { if (!worldserver.Connected()) {
if (!worldserver.Connected())
Message(Chat::Red, "Error: World server disconnected"); Message(Chat::Red, "Error: World server disconnected");
else { } else {
auto pack = new ServerPacket(ServerOP_KillPlayer, sizeof(ServerKillPlayer_Struct)); auto pack = new ServerPacket(ServerOP_KillPlayer, sizeof(ServerKillPlayer_Struct));
ServerKillPlayer_Struct* skp = (ServerKillPlayer_Struct*)pack->pBuffer; auto *skp = (ServerKillPlayer_Struct *) pack->pBuffer;
strcpy(skp->gmname, gmk->gmname); strcpy(skp->gmname, gmk->gmname);
strcpy(skp->target, gmk->name); strcpy(skp->target, gmk->name);
skp->admin = Admin(); skp->admin = Admin();
@ -6688,7 +6686,6 @@ void Client::Handle_OP_GMKill(const EQApplicationPacket *app)
safe_delete(pack); safe_delete(pack);
} }
} }
return;
} }
void Client::Handle_OP_GMLastName(const EQApplicationPacket *app) void Client::Handle_OP_GMLastName(const EQApplicationPacket *app)
@ -6697,32 +6694,30 @@ void Client::Handle_OP_GMLastName(const EQApplicationPacket *app)
std::cout << "Wrong size on OP_GMLastName. Got: " << app->size << ", Expected: " << sizeof(GMLastName_Struct) << std::endl; std::cout << "Wrong size on OP_GMLastName. Got: " << app->size << ", Expected: " << sizeof(GMLastName_Struct) << std::endl;
return; return;
} }
GMLastName_Struct* gmln = (GMLastName_Struct*)app->pBuffer;
if (strlen(gmln->lastname) >= 64) {
Message(Chat::Red, "/LastName: New last name too long. (max=63)");
}
else {
Client* client = entity_list.GetClientByName(gmln->name);
if (client == 0) {
Message(Chat::Red, "/LastName: %s not found", gmln->name);
}
else {
if (Admin() < minStatusToUseGMCommands) {
Message(Chat::Red, "Your account has been reported for hacking.");
RecordPlayerEventLog(PlayerEvent::POSSIBLE_HACK, PlayerEvent::PossibleHackEvent{.message = "Used /lastname"});
return;
}
else
client->ChangeLastName(gmln->lastname); if (!GetGM()) {
Message(Chat::Red, "Your account has been reported for hacking.");
RecordPlayerEventLog(PlayerEvent::POSSIBLE_HACK, PlayerEvent::PossibleHackEvent{.message = "Used /lastname"});
return;
}
auto *gmln = (GMLastName_Struct *) app->pBuffer;
if (strlen(gmln->lastname) >= 64) {
Message(Chat::Red, "/LastName: New last name too long. Max length is 63.");
} else {
Client *c = entity_list.GetClientByName(gmln->name);
if (!c) {
Message(Chat::Red, fmt::format("/LastName: {} not found", gmln->name).c_str());
} else {
c->ChangeLastName(gmln->lastname);
} }
gmln->unknown[0] = 1; gmln->unknown[0] = 1;
gmln->unknown[1] = 1; gmln->unknown[1] = 1;
gmln->unknown[2] = 1; gmln->unknown[2] = 1;
gmln->unknown[3] = 1; gmln->unknown[3] = 1;
entity_list.QueueClients(this, app, false); entity_list.QueueClients(this, app, false);
} }
return;
} }
void Client::Handle_OP_GMNameChange(const EQApplicationPacket *app) void Client::Handle_OP_GMNameChange(const EQApplicationPacket *app)
@ -6731,44 +6726,49 @@ void Client::Handle_OP_GMNameChange(const EQApplicationPacket *app)
LogError("Wrong size: OP_GMNameChange, size=[{}], expected [{}]", app->size, sizeof(GMName_Struct)); LogError("Wrong size: OP_GMNameChange, size=[{}], expected [{}]", app->size, sizeof(GMName_Struct));
return; return;
} }
const GMName_Struct* gmn = (const GMName_Struct *)app->pBuffer;
if (Admin() < minStatusToUseGMCommands) { auto *gmn = (GMName_Struct *) app->pBuffer;
if (!GetGM()) {
Message(Chat::Red, "Your account has been reported for hacking."); Message(Chat::Red, "Your account has been reported for hacking.");
RecordPlayerEventLog(PlayerEvent::POSSIBLE_HACK, PlayerEvent::PossibleHackEvent{.message = "Used /name"}); RecordPlayerEventLog(PlayerEvent::POSSIBLE_HACK, PlayerEvent::PossibleHackEvent{.message = "Used /name"});
return; return;
} }
Client* client = entity_list.GetClientByName(gmn->oldname);
LogInfo("GM([{}]) changeing players name. Old:[{}] New:[{}]", GetName(), gmn->oldname, gmn->newname);
bool usedname = database.CheckUsedName(gmn->newname);
if (client == 0) {
Message(Chat::Red, "%s not found for name change. Operation failed!", gmn->oldname);
return;
}
if ((strlen(gmn->newname) > 63) || (strlen(gmn->newname) == 0)) {
Message(Chat::Red, "Invalid number of characters in new name (%s).", gmn->newname);
return;
}
if (!usedname) {
Message(Chat::Red, "%s is already in use. Operation failed!", gmn->newname);
return;
Client *c = entity_list.GetClientByName(gmn->oldname);
LogInfo("GM([{}]) changeing players name. Old:[{}] New:[{}]", GetName(), gmn->oldname, gmn->newname);
const bool used_name = database.CheckUsedName(gmn->newname);
if (!c) {
Message(Chat::Red, fmt::format("{} not found for name change. Operation failed!", gmn->oldname).c_str());
return;
} }
if (strlen(gmn->newname) > 63 || strlen(gmn->newname) == 0) {
Message(Chat::Red, fmt::format("Invalid number of characters in new name '{}'.", gmn->newname).c_str());
return;
}
if (!used_name) {
Message(Chat::Red, fmt::format("{} is already in use. Operation failed!", gmn->newname).c_str());
return;
}
database.UpdateName(gmn->oldname, gmn->newname); database.UpdateName(gmn->oldname, gmn->newname);
strcpy(client->name, gmn->newname); strcpy(c->name, gmn->newname);
client->Save(); c->Save();
if (gmn->badname == 1) { if (gmn->badname == 1) {
database.AddToNameFilter(gmn->oldname); database.AddToNameFilter(gmn->oldname);
} }
EQApplicationPacket* outapp = app->Copy();
GMName_Struct* gmn2 = (GMName_Struct*)outapp->pBuffer; auto *outapp = app->Copy();
auto *gmn2 = (GMName_Struct *) outapp->pBuffer;
gmn2->unknown[0] = 1; gmn2->unknown[0] = 1;
gmn2->unknown[1] = 1; gmn2->unknown[1] = 1;
gmn2->unknown[2] = 1; gmn2->unknown[2] = 1;
entity_list.QueueClients(this, outapp, false); entity_list.QueueClients(this, outapp, false);
safe_delete(outapp); safe_delete(outapp);
UpdateWho(); UpdateWho();
return;
} }
void Client::Handle_OP_GMSearchCorpse(const EQApplicationPacket *app) void Client::Handle_OP_GMSearchCorpse(const EQApplicationPacket *app)
@ -6863,6 +6863,13 @@ void Client::Handle_OP_GMSummon(const EQApplicationPacket *app)
std::cout << "Wrong size on OP_GMSummon. Got: " << app->size << ", Expected: " << sizeof(GMSummon_Struct) << std::endl; std::cout << "Wrong size on OP_GMSummon. Got: " << app->size << ", Expected: " << sizeof(GMSummon_Struct) << std::endl;
return; return;
} }
if (!GetGM()) {
Message(Chat::Red, "Your account has been reported for hacking.");
RecordPlayerEventLog(PlayerEvent::POSSIBLE_HACK, PlayerEvent::PossibleHackEvent{.message = "Used /summon"});
return;
}
OPGMSummon(app); OPGMSummon(app);
return; return;
} }
@ -6873,12 +6880,14 @@ void Client::Handle_OP_GMToggle(const EQApplicationPacket *app)
std::cout << "Wrong size on OP_GMToggle. Got: " << app->size << ", Expected: " << sizeof(GMToggle_Struct) << std::endl; std::cout << "Wrong size on OP_GMToggle. Got: " << app->size << ", Expected: " << sizeof(GMToggle_Struct) << std::endl;
return; return;
} }
if (Admin() < minStatusToUseGMCommands) {
if (!GetGM()) {
Message(Chat::Red, "Your account has been reported for hacking."); Message(Chat::Red, "Your account has been reported for hacking.");
RecordPlayerEventLog(PlayerEvent::POSSIBLE_HACK, PlayerEvent::PossibleHackEvent{.message = "Used /toggle"}); RecordPlayerEventLog(PlayerEvent::POSSIBLE_HACK, PlayerEvent::PossibleHackEvent{.message = "Used /toggle"});
return; return;
} }
GMToggle_Struct *ts = (GMToggle_Struct *)app->pBuffer;
auto *ts = (GMToggle_Struct *)app->pBuffer;
if (ts->toggle == 0) { if (ts->toggle == 0) {
MessageString(Chat::White, TOGGLE_OFF); MessageString(Chat::White, TOGGLE_OFF);
tellsoff = true; tellsoff = true;
@ -6886,10 +6895,10 @@ void Client::Handle_OP_GMToggle(const EQApplicationPacket *app)
MessageString(Chat::White, TOGGLE_ON); MessageString(Chat::White, TOGGLE_ON);
tellsoff = false; tellsoff = false;
} else { } else {
Message(Chat::White, "Unkown value in /toggle packet"); Message(Chat::White, "Unknown value in /toggle packet.");
} }
UpdateWho(); UpdateWho();
return;
} }
void Client::Handle_OP_GMTraining(const EQApplicationPacket *app) void Client::Handle_OP_GMTraining(const EQApplicationPacket *app)
@ -6899,6 +6908,7 @@ void Client::Handle_OP_GMTraining(const EQApplicationPacket *app)
DumpPacket(app); DumpPacket(app);
return; return;
} }
OPGMTraining(app); OPGMTraining(app);
return; return;
} }
@ -6910,6 +6920,7 @@ void Client::Handle_OP_GMTrainSkill(const EQApplicationPacket *app)
DumpPacket(app); DumpPacket(app);
return; return;
} }
OPGMTrainSkill(app); OPGMTrainSkill(app);
return; return;
} }
@ -6920,27 +6931,30 @@ void Client::Handle_OP_GMZoneRequest(const EQApplicationPacket *app)
std::cout << "Wrong size on OP_GMZoneRequest. Got: " << app->size << ", Expected: " << sizeof(GMZoneRequest_Struct) << std::endl; std::cout << "Wrong size on OP_GMZoneRequest. Got: " << app->size << ", Expected: " << sizeof(GMZoneRequest_Struct) << std::endl;
return; return;
} }
if (Admin() < minStatusToBeGM) {
if (!GetGM()) {
Message(Chat::Red, "Your account has been reported for hacking."); Message(Chat::Red, "Your account has been reported for hacking.");
RecordPlayerEventLog(PlayerEvent::POSSIBLE_HACK, PlayerEvent::PossibleHackEvent{.message = "Used /zone"}); RecordPlayerEventLog(PlayerEvent::POSSIBLE_HACK, PlayerEvent::PossibleHackEvent{.message = "Used /zone"});
return; return;
} }
auto* gmzr = (GMZoneRequest_Struct*)app->pBuffer; auto *gmzr = (GMZoneRequest_Struct *) app->pBuffer;
float target_x = -1, target_y = -1, target_z = -1, target_heading; float target_x = -1, target_y = -1, target_z = -1, target_heading;
int16 min_status = AccountStatus::Player; int16 min_status = AccountStatus::Player;
uint8 min_level = 0; uint8 min_level = 0;
char target_zone[32]; char target_zone[32];
uint16 zone_id = gmzr->zone_id; uint16 zone_id = gmzr->zone_id;
if (gmzr->zone_id == 0) if (gmzr->zone_id == 0) {
zone_id = zonesummon_id; zone_id = zonesummon_id;
}
const char* zone_short_name = ZoneName(zone_id); const char *zone_short_name = ZoneName(zone_id);
if (zone_short_name == nullptr) if (zone_short_name == nullptr) {
target_zone[0] = 0; target_zone[0] = 0;
else } else {
strcpy(target_zone, zone_short_name); strcpy(target_zone, zone_short_name);
}
// this both loads the safe points and does a sanity check on zone name // this both loads the safe points and does a sanity check on zone name
auto z = GetZone(target_zone, 0); auto z = GetZone(target_zone, 0);
@ -6954,41 +6968,40 @@ void Client::Handle_OP_GMZoneRequest(const EQApplicationPacket *app)
} }
auto outapp = new EQApplicationPacket(OP_GMZoneRequest, sizeof(GMZoneRequest_Struct)); auto outapp = new EQApplicationPacket(OP_GMZoneRequest, sizeof(GMZoneRequest_Struct));
auto* gmzr2 = (GMZoneRequest_Struct*)outapp->pBuffer; auto *gmzr2 = (GMZoneRequest_Struct *) outapp->pBuffer;
strcpy(gmzr2->charname, GetName()); strcpy(gmzr2->charname, GetName());
gmzr2->zone_id = gmzr->zone_id; gmzr2->zone_id = gmzr->zone_id;
gmzr2->x = target_x; gmzr2->x = target_x;
gmzr2->y = target_y; gmzr2->y = target_y;
gmzr2->z = target_z; gmzr2->z = target_z;
gmzr2->heading = target_heading; gmzr2->heading = target_heading;
// Next line stolen from ZoneChange as well... - This gives us a nicer message than the normal "zone is down" message...
if (target_zone[0] != 0 && admin >= min_status && GetLevel() >= min_level) if (target_zone[0] != 0 && admin >= min_status && GetLevel() >= min_level) {
gmzr2->success = 1; gmzr2->success = 1;
else { } else {
std::cout << "GetZoneSafeCoords failed. zoneid = " << gmzr->zone_id << "; czone = " << zone->GetZoneID() << std::endl; LogError("GetZoneSafeCoords failed. Zone ID [{}] Current Zone [{}]", gmzr->zone_id, zone->GetZoneID());
gmzr2->success = 0; gmzr2->success = 0;
} }
QueuePacket(outapp); QueuePacket(outapp);
safe_delete(outapp); safe_delete(outapp);
return;
} }
void Client::Handle_OP_GMZoneRequest2(const EQApplicationPacket *app) void Client::Handle_OP_GMZoneRequest2(const EQApplicationPacket *app)
{ {
if (Admin() < minStatusToBeGM) {
Message(Chat::Red, "Your account has been reported for hacking.");
RecordPlayerEventLog(PlayerEvent::POSSIBLE_HACK, PlayerEvent::PossibleHackEvent{.message = "Used /zone"});
return;
}
if (app->size < sizeof(uint32)) { if (app->size < sizeof(uint32)) {
LogError("OP size error: OP_GMZoneRequest2 expected:[{}] got:[{}]", sizeof(uint32), app->size); LogError("OP size error: OP_GMZoneRequest2 expected:[{}] got:[{}]", sizeof(uint32), app->size);
return; return;
} }
if (!GetGM()) {
Message(Chat::Red, "Your account has been reported for hacking.");
RecordPlayerEventLog(PlayerEvent::POSSIBLE_HACK, PlayerEvent::PossibleHackEvent{.message = "Used /zone"});
return;
}
uint32 zonereq = *((uint32 *)app->pBuffer); uint32 zonereq = *((uint32 *)app->pBuffer);
GoToSafeCoords(zonereq, 0); GoToSafeCoords(zonereq, 0);
return;
} }
void Client::Handle_OP_GroupAcknowledge(const EQApplicationPacket *app) void Client::Handle_OP_GroupAcknowledge(const EQApplicationPacket *app)

View File

@ -277,7 +277,7 @@ void Doors::HandleClick(Client *sender, uint8 trigger)
// enforce flags before they hit zoning process // enforce flags before they hit zoning process
auto z = GetZone(m_destination_zone_name, 0); auto z = GetZone(m_destination_zone_name, 0);
if (z && !z->flag_needed.empty() && Strings::IsNumber(z->flag_needed) && Strings::ToInt(z->flag_needed) == 1) { if (z && !z->flag_needed.empty() && Strings::IsNumber(z->flag_needed) && Strings::ToInt(z->flag_needed) == 1) {
if (sender->Admin() < minStatusToIgnoreZoneFlags && !sender->HasZoneFlag(z->zoneidnumber)) { if (!sender->GetGM() && !sender->HasZoneFlag(z->zoneidnumber)) {
LogInfo( LogInfo(
"Character [{}] does not have the flag to be in this zone [{}]!", "Character [{}] does not have the flag to be in this zone [{}]!",
sender->GetCleanName(), sender->GetCleanName(),

View File

@ -23,10 +23,7 @@ void command_castspell(Client *c, const Seperator *sep)
const uint16 spell_id = Strings::ToUnsignedInt(sep->arg[1]); const uint16 spell_id = Strings::ToUnsignedInt(sep->arg[1]);
if (IsCastRestrictedSpell(spell_id) && c->Admin() < commandCastSpecials) { if (spell_id >= SPDAT_RECORDS) {
c->Message(Chat::White, "Unable to cast spell.");
return;
} else if (spell_id >= SPDAT_RECORDS) {
c->Message(Chat::White, "Invalid Spell ID."); c->Message(Chat::White, "Invalid Spell ID.");
return; return;
} }

View File

@ -9,18 +9,22 @@ void command_corpse(Client *c, const Seperator *sep)
c->Message(Chat::White, "Usage: #corpse deletenpccorpses - Deletes all NPC corpses"); c->Message(Chat::White, "Usage: #corpse deletenpccorpses - Deletes all NPC corpses");
c->Message(Chat::White, "Usage: #corpse inspectloot - Inspects the loot on a corpse"); c->Message(Chat::White, "Usage: #corpse inspectloot - Inspects the loot on a corpse");
c->Message(Chat::White, "Usage: #corpse listnpc - Lists all NPC corpses"); c->Message(Chat::White, "Usage: #corpse listnpc - Lists all NPC corpses");
c->Message(Chat::White, "Usage: #corpse lock - Locks the corpse, only GMs can loot the corpse when it is locked"); c->Message(
Chat::White,
"Usage: #corpse lock - Locks the corpse, only GMs can loot the corpse when it is locked"
);
c->Message(Chat::White, "Usage: #corpse removecash - Removes the cash from a corpse"); c->Message(Chat::White, "Usage: #corpse removecash - Removes the cash from a corpse");
c->Message(Chat::White, "Usage: #corpse unlock - Unlocks the corpses, allowing non-GMs to loot the corpse"); c->Message(Chat::White, "Usage: #corpse unlock - Unlocks the corpses, allowing non-GMs to loot the corpse");
if (c->Admin() >= commandEditPlayerCorpses) { c->Message(Chat::White, "Usage: #corpse charid [Character ID] - Change player corpse's owner");
c->Message(Chat::White, "Usage: #corpse charid [Character ID] - Change player corpse's owner"); c->Message(Chat::White, "Usage: #corpse deleteplayercorpses - Deletes all player corpses");
c->Message(Chat::White, "Usage: #corpse deleteplayercorpses - Deletes all player corpses"); c->Message(Chat::White, "Usage: #corpse depop [Bury] - Depops single target corpse.");
c->Message(Chat::White, "Usage: #corpse depop [Bury] - Depops single target corpse."); c->Message(Chat::White, "Usage: #corpse depopall [Bury] - Depops all target player's corpses.");
c->Message(Chat::White, "Usage: #corpse depopall [Bury] - Depops all target player's corpses."); c->Message(Chat::White, "Usage: #corpse listplayer - Lists all player corpses");
c->Message(Chat::White, "Usage: #corpse listplayer - Lists all player corpses"); c->Message(
c->Message(Chat::White, "Usage: #corpse moveallgraveyard - Moves all player corpses to the current zone's graveyard or non-instance"); Chat::White,
c->Message(Chat::White, "Note: Set bury to 0 to skip burying the corpses."); "Usage: #corpse moveallgraveyard - Moves all player corpses to the current zone's graveyard or non-instance"
} );
c->Message(Chat::White, "Note: Set bury to 0 to skip burying the corpses.");
return; return;
} }
@ -59,72 +63,57 @@ void command_corpse(Client *c, const Seperator *sep)
c->Message(Chat::White, "Usage: #corpse deletenpccorpses - Deletes all NPC corpses"); c->Message(Chat::White, "Usage: #corpse deletenpccorpses - Deletes all NPC corpses");
c->Message(Chat::White, "Usage: #corpse inspectloot - Inspects the loot on a corpse"); c->Message(Chat::White, "Usage: #corpse inspectloot - Inspects the loot on a corpse");
c->Message(Chat::White, "Usage: #corpse listnpc - Lists all NPC corpses"); c->Message(Chat::White, "Usage: #corpse listnpc - Lists all NPC corpses");
c->Message(Chat::White, "Usage: #corpse lock - Locks the corpse, only GMs can loot the corpse when it is locked"); c->Message(
Chat::White,
"Usage: #corpse lock - Locks the corpse, only GMs can loot the corpse when it is locked"
);
c->Message(Chat::White, "Usage: #corpse removecash - Removes the cash from a corpse"); c->Message(Chat::White, "Usage: #corpse removecash - Removes the cash from a corpse");
c->Message(Chat::White, "Usage: #corpse unlock - Unlocks the corpses, allowing non-GMs to loot the corpse"); c->Message(Chat::White, "Usage: #corpse unlock - Unlocks the corpses, allowing non-GMs to loot the corpse");
if (c->Admin() >= commandEditPlayerCorpses) { c->Message(Chat::White, "Usage: #corpse charid [Character ID] - Change player corpse's owner");
c->Message(Chat::White, "Usage: #corpse charid [Character ID] - Change player corpse's owner"); c->Message(Chat::White, "Usage: #corpse deleteplayercorpses - Deletes all player corpses");
c->Message(Chat::White, "Usage: #corpse deleteplayercorpses - Deletes all player corpses"); c->Message(Chat::White, "Usage: #corpse depop [Bury] - Depops single target corpse.");
c->Message(Chat::White, "Usage: #corpse depop [Bury] - Depops single target corpse."); c->Message(Chat::White, "Usage: #corpse depopall [Bury] - Depops all target player's corpses.");
c->Message(Chat::White, "Usage: #corpse depopall [Bury] - Depops all target player's corpses."); c->Message(Chat::White, "Usage: #corpse listplayer - Lists all player corpses");
c->Message(Chat::White, "Usage: #corpse listplayer - Lists all player corpses"); c->Message(
c->Message(Chat::White, "Usage: #corpse moveallgraveyard - Moves all player corpses to the current zone's graveyard or non-instance"); Chat::White,
c->Message(Chat::White, "Note: Set bury to 0 to skip burying the corpses."); "Usage: #corpse moveallgraveyard - Moves all player corpses to the current zone's graveyard or non-instance"
} );
c->Message(Chat::White, "Note: Set bury to 0 to skip burying the corpses.");
return; return;
} }
if (is_delete_player_corpses) { if (is_delete_player_corpses) {
if (c->Admin() >= commandEditPlayerCorpses) { auto corpses_deleted = entity_list.DeletePlayerCorpses();
auto corpses_deleted = entity_list.DeletePlayerCorpses(); auto deleted_string = (
auto deleted_string = ( corpses_deleted ?
corpses_deleted ? fmt::format(
fmt::format( "{} Player corpse{} deleted.",
"{} Player corpse{} deleted.", corpses_deleted,
corpses_deleted, corpses_deleted != 1 ? "s" : ""
corpses_deleted != 1 ? "s" : "" ) :
) : "There are no player corpses to delete."
"There are no player corpses to delete." );
); c->Message(Chat::White, deleted_string.c_str());
c->Message(Chat::White, deleted_string.c_str());
} else {
c->Message(Chat::White, "Your status is not high enough to delete player corpses.");
return;
}
} else if (is_delete) { } else if (is_delete) {
if (!target || !target->IsCorpse()) { if (!target || !target->IsCorpse()) {
c->Message(Chat::White, "You must target a corpse to use this command."); c->Message(Chat::White, "You must target a corpse to use this command.");
return; return;
} }
if (target->IsPlayerCorpse() && c->Admin() < commandEditPlayerCorpses) { c->Message(
c->Message(Chat::White, "Your status is not high enough to delete a player corpse."); Chat::White,
return; fmt::format(
} "Deleting {} corpse {}.",
target->IsNPCCorpse() ? "NPC" : "player",
c->GetTargetDescription(target)
).c_str()
);
if ( target->CastToCorpse()->Delete();
target->IsNPCCorpse() ||
c->Admin() >= commandEditPlayerCorpses
) {
c->Message(
Chat::White,
fmt::format(
"Deleting {} corpse {}.",
target->IsNPCCorpse() ? "NPC" : "player",
c->GetTargetDescription(target)
).c_str()
);
target->CastToCorpse()->Delete();
}
} else if (is_list_npc) { } else if (is_list_npc) {
entity_list.ListNPCCorpses(c); entity_list.ListNPCCorpses(c);
} else if (is_list_player) { } else if (is_list_player) {
if (c->Admin() < commandEditPlayerCorpses) {
c->Message(Chat::White, "Your status is not high enough to list player corpses.");
return;
}
entity_list.ListPlayerCorpses(c); entity_list.ListPlayerCorpses(c);
} else if (is_delete_npc_corpses) { } else if (is_delete_npc_corpses) {
auto corpses_deleted = entity_list.DeleteNPCCorpses(); auto corpses_deleted = entity_list.DeleteNPCCorpses();
@ -139,42 +128,32 @@ void command_corpse(Client *c, const Seperator *sep)
); );
c->Message(Chat::White, deleted_string.c_str()); c->Message(Chat::White, deleted_string.c_str());
} else if (is_character_id) { } else if (is_character_id) {
if (c->Admin() >= commandEditPlayerCorpses) { if (!target || !target->IsPlayerCorpse()) {
if (!target || !target->IsPlayerCorpse()) { c->Message(Chat::White, "You must target a player corpse to use this command.");
c->Message(Chat::White, "You must target a player corpse to use this command.");
return;
}
if (!sep->IsNumber(2)) {
c->Message(Chat::White, "Usage: #corpse charid [Character ID] - Change player corpse's owner");
return;
}
auto character_id = Strings::ToInt(sep->arg[2]);
c->Message(
Chat::White,
fmt::format(
"Setting the owner to {} ({}) for the player corpse {}.",
database.GetCharNameByID(character_id),
target->CastToCorpse()->SetCharID(character_id),
c->GetTargetDescription(target)
).c_str()
);
} else {
c->Message(Chat::White, "Your status is not high enough to modify a player corpse's owner.");
return; return;
} }
if (!sep->IsNumber(2)) {
c->Message(Chat::White, "Usage: #corpse charid [Character ID] - Change player corpse's owner");
return;
}
const uint32 character_id = Strings::ToUnsignedInt(sep->arg[2]);
c->Message(
Chat::White,
fmt::format(
"Setting the owner to {} ({}) for the player corpse {}.",
database.GetCharNameByID(character_id),
target->CastToCorpse()->SetCharID(character_id),
c->GetTargetDescription(target)
).c_str()
);
} else if (is_reset_looter) { } else if (is_reset_looter) {
if (!target || !target->IsCorpse()) { if (!target || !target->IsCorpse()) {
c->Message(Chat::White, "You must target a corpse to use this command."); c->Message(Chat::White, "You must target a corpse to use this command.");
return; return;
} }
if (target->IsPlayerCorpse() && c->Admin() < commandEditPlayerCorpses) {
c->Message(Chat::White, "Your status is not high enough to reset looter on a player corpse.");
return;
}
target->CastToCorpse()->ResetLooter(); target->CastToCorpse()->ResetLooter();
c->Message( c->Message(
Chat::White, Chat::White,
@ -190,36 +169,22 @@ void command_corpse(Client *c, const Seperator *sep)
return; return;
} }
if (target->IsPlayerCorpse() && c->Admin() < commandEditPlayerCorpses) { target->CastToCorpse()->RemoveCash();
c->Message(Chat::White, "Your status is not high enough to remove cash from a player corpse.");
return;
}
if ( c->Message(
target->IsNPCCorpse() || Chat::White,
c->Admin() >= commandEditPlayerCorpses fmt::format(
) { "Removed cash from {} corpse {}.",
target->CastToCorpse()->RemoveCash(); target->IsNPCCorpse() ? "NPC" : "player",
c->Message( c->GetTargetDescription(target)
Chat::White, ).c_str()
fmt::format( );
"Removed cash from {} corpse {}.",
target->IsNPCCorpse() ? "NPC" : "player",
c->GetTargetDescription(target)
).c_str()
);
}
} else if (is_inspect_loot) { } else if (is_inspect_loot) {
if (!target || !target->IsCorpse()) { if (!target || !target->IsCorpse()) {
c->Message(Chat::White, "You must target a corpse to use this command."); c->Message(Chat::White, "You must target a corpse to use this command.");
return; return;
} }
if (target->IsPlayerCorpse() && c->Admin() < commandEditPlayerCorpses) {
c->Message(Chat::White, "Your status is not high enough to inspect the loot of a player corpse.");
return;
}
target->CastToCorpse()->QueryLoot(c); target->CastToCorpse()->QueryLoot(c);
} else if (is_lock) { } else if (is_lock) {
if (!target || !target->IsCorpse()) { if (!target || !target->IsCorpse()) {
@ -227,11 +192,6 @@ void command_corpse(Client *c, const Seperator *sep)
return; return;
} }
if (target->IsPlayerCorpse() && c->Admin() < commandEditPlayerCorpses) {
c->Message(Chat::White, "Your status is not high enough to lock player corpses.");
return;
}
target->CastToCorpse()->Lock(); target->CastToCorpse()->Lock();
c->Message( c->Message(
Chat::White, Chat::White,
@ -247,11 +207,6 @@ void command_corpse(Client *c, const Seperator *sep)
return; return;
} }
if (target->IsPlayerCorpse() && c->Admin() < commandEditPlayerCorpses) {
c->Message(Chat::White, "Your status is not high enough to unlock player corpses.");
return;
}
target->CastToCorpse()->UnLock(); target->CastToCorpse()->UnLock();
c->Message( c->Message(
Chat::White, Chat::White,
@ -267,30 +222,20 @@ void command_corpse(Client *c, const Seperator *sep)
return; return;
} }
if (c->Admin() >= commandEditPlayerCorpses) { const bool bury_corpse = sep->IsNumber(2) ? Strings::ToBool(sep->arg[2]) : false;
bool bury_corpse = (
sep->IsNumber(2) ? c->Message(
( Chat::White,
Strings::ToInt(sep->arg[2]) != 0 ? fmt::format(
true : "Depopping player corpse {}.",
false c->GetTargetDescription(target)
) : ).c_str()
false );
);
c->Message( target->CastToCorpse()->DepopPlayerCorpse();
Chat::White,
fmt::format( if (bury_corpse) {
"Depopping player corpse {}.", target->CastToCorpse()->Bury();
c->GetTargetDescription(target)
).c_str()
);
target->CastToCorpse()->DepopPlayerCorpse();
if (bury_corpse) {
target->CastToCorpse()->Bury();
}
} else {
c->Message(Chat::White, "Your status is not high enough to depop a player corpse.");
return;
} }
} else if (is_depop_all) { } else if (is_depop_all) {
if (!target || !target->IsClient()) { if (!target || !target->IsClient()) {
@ -298,50 +243,36 @@ void command_corpse(Client *c, const Seperator *sep)
return; return;
} }
if (c->Admin() >= commandEditPlayerCorpses) { const bool bury_corpse = sep->IsNumber(2) ? Strings::ToBool(sep->arg[2]) : false;
bool bury_corpse = (
sep->IsNumber(2) ? c->Message(
( Chat::White,
Strings::ToInt(sep->arg[2]) != 0 ? fmt::format(
true : "Depopping all player corpses for {}.",
false c->GetTargetDescription(target)
) : ).c_str()
false );
);
target->CastToClient()->DepopAllCorpses();
if (bury_corpse) {
target->CastToClient()->BuryPlayerCorpses();
}
} else if (is_move_all_to_graveyard) {
const int moved_count = entity_list.MovePlayerCorpsesToGraveyard(true);
if (moved_count) {
c->Message( c->Message(
Chat::White, Chat::White,
fmt::format( fmt::format(
"Depopping all player corpses for {}.", "Moved {} player corpse{} to graveyard in {} ({}).",
c->GetTargetDescription(target) moved_count,
moved_count != 1 ? "s" : "",
ZoneLongName(zone->GetZoneID()),
ZoneName(zone->GetZoneID())
).c_str() ).c_str()
); );
target->CastToClient()->DepopAllCorpses();
if (bury_corpse) {
target->CastToClient()->BuryPlayerCorpses();
}
} else { } else {
c->Message(Chat::White, "Your status is not high enough to depop all of a player's corpses."); c->Message(Chat::White, "There are no player corpses to move to the graveyard.");
return;
}
} else if (is_move_all_to_graveyard) {
int moved_count = entity_list.MovePlayerCorpsesToGraveyard(true);
if (c->Admin() >= commandEditPlayerCorpses) {
if (moved_count) {
c->Message(
Chat::White,
fmt::format(
"Moved {} player corpse{} to graveyard in {} ({}).",
moved_count,
moved_count != 1 ? "s" : "",
ZoneLongName(zone->GetZoneID()),
ZoneName(zone->GetZoneID())
).c_str()
);
} else {
c->Message(Chat::White, "There are no player corpses to move to the graveyard.");
}
} else {
c->Message(Chat::White, "Your status is not high enough to move all player corpses to the graveyard.");
} }
} }
} }

View File

@ -10,7 +10,7 @@ void command_doanim(Client *c, const Seperator *sep)
} }
Mob* t = c; Mob* t = c;
if (c->GetTarget() && c->Admin() >= commandDoAnimOthers) { if (c->GetTarget()) {
t = c->GetTarget(); t = c->GetTarget();
} }

View File

@ -81,11 +81,6 @@ void command_guild(Client *c, const Seperator *sep)
).c_str() ).c_str()
); );
} else { } else {
if (c->Admin() < minStatusToEditOtherGuilds) {
c->Message(Chat::White, "You cannot edit other peoples' guilds.");
return;
}
auto guild_name = sep->argplus[3]; auto guild_name = sep->argplus[3];
auto guild_id = guild_mgr.CreateGuild(sep->argplus[3], leader_id); auto guild_id = guild_mgr.CreateGuild(sep->argplus[3], leader_id);
@ -144,16 +139,6 @@ void command_guild(Client *c, const Seperator *sep)
return; return;
} }
if (c->Admin() < minStatusToEditOtherGuilds) {
if (c->GuildID() != guild_id) {
c->Message(Chat::White, "You cannot edit other peoples' guilds.");
return;
} else if (!guild_mgr.CheckGMStatus(guild_id, c->Admin())) {
c->Message(Chat::White, "You cannot edit your current guild, your status is not high enough.");
return;
}
}
LogGuilds( LogGuilds(
"[{}]: Deleting guild [{}] ([{}]) with GM command", "[{}]: Deleting guild [{}] ([{}]) with GM command",
c->GetName(), c->GetName(),
@ -175,16 +160,10 @@ void command_guild(Client *c, const Seperator *sep)
SendGuildSubCommands(c); SendGuildSubCommands(c);
} else if (is_info) { } else if (is_info) {
if (arguments != 2 && c->IsInAGuild()) { if (arguments != 2 && c->IsInAGuild()) {
if (c->Admin() >= minStatusToEditOtherGuilds) { c->Message(Chat::White, "#guild info [Guild ID]");
c->Message(Chat::White, "#guild info [Guild ID]");
} else {
c->Message(Chat::White, "You cannot edit other peoples' guilds.");
}
} else { } else {
auto guild_id = GUILD_NONE; auto guild_id = GUILD_NONE;
if (arguments != 2 || !sep->IsNumber(2)) { if (sep->IsNumber(2)) {
guild_id = c->GuildID();
} else if (c->Admin() >= minStatusToEditOtherGuilds) {
guild_id = Strings::ToUnsignedInt(sep->arg[2]); guild_id = Strings::ToUnsignedInt(sep->arg[2]);
} }
@ -193,11 +172,6 @@ void command_guild(Client *c, const Seperator *sep)
} }
} }
} else if (is_list) { } else if (is_list) {
if (c->Admin() < minStatusToEditOtherGuilds) {
c->Message(Chat::White, "You cannot edit other peoples' guilds.");
return;
}
guild_mgr.ListGuilds(c, std::string()); guild_mgr.ListGuilds(c, std::string());
} else if (is_rename) { } else if (is_rename) {
if (!sep->IsNumber(2)) { if (!sep->IsNumber(2)) {
@ -215,16 +189,6 @@ void command_guild(Client *c, const Seperator *sep)
return; return;
} }
if (c->Admin() < minStatusToEditOtherGuilds) {
if (c->GuildID() != guild_id) {
c->Message(Chat::White, "You cannot edit other peoples' guilds.");
return;
} else if (!guild_mgr.CheckGMStatus(guild_id, c->Admin())) {
c->Message(Chat::White, "You cannot edit your current guild, your status is not high enough.");
return;
}
}
auto new_guild_name = sep->argplus[3]; auto new_guild_name = sep->argplus[3];
LogGuilds( LogGuilds(
"[{}]: Renaming guild [{}] ([{}]) to [{}] with GM command", "[{}]: Renaming guild [{}] ([{}]) to [{}] with GM command",
@ -293,11 +257,6 @@ void command_guild(Client *c, const Seperator *sep)
return; return;
} }
if (c->Admin() < minStatusToEditOtherGuilds && guild_id != c->GuildID()) {
c->Message(Chat::White, "You cannot edit other peoples' guilds.");
return;
}
if (!guild_id || guild_id == GUILD_NONE) { if (!guild_id || guild_id == GUILD_NONE) {
LogGuilds( LogGuilds(
"[{}]: Removing [{}] ([{}]) from guild with GM command", "[{}]: Removing [{}] ([{}]) from guild with GM command",
@ -390,16 +349,6 @@ void command_guild(Client *c, const Seperator *sep)
return; return;
} }
if (c->Admin() < minStatusToEditOtherGuilds) {
if (c->GuildID() != guild_id) {
c->Message(Chat::White, "You cannot edit other peoples' guilds.");
return;
} else if (!guild_mgr.CheckGMStatus(guild_id, c->Admin())) {
c->Message(Chat::White, "You cannot edit your current guild, your status is not high enough.");
return;
}
}
LogGuilds( LogGuilds(
"[{}]: Setting leader of guild [{}] ([{}]) to [{}] with GM command", "[{}]: Setting leader of guild [{}] ([{}]) to [{}] with GM command",
c->GetName(), c->GetName(),
@ -461,11 +410,6 @@ void command_guild(Client *c, const Seperator *sep)
return; return;
} }
if (c->Admin() < minStatusToEditOtherGuilds && character_id != c->CharacterID()) {
c->Message(Chat::White, "You cannot edit other peoples' guilds.");
return;
}
LogGuilds( LogGuilds(
"[{}]: Setting [{}] ([{}])'s guild rank to [{}] with GM command", "[{}]: Setting [{}] ([{}])'s guild rank to [{}] with GM command",
c->GetName(), c->GetName(),
@ -498,8 +442,6 @@ void command_guild(Client *c, const Seperator *sep)
); );
if (!client) { if (!client) {
c->Message(Chat::White, "You must target someone or specify a character name."); c->Message(Chat::White, "You must target someone or specify a character name.");
} else if (c->Admin() < minStatusToEditOtherGuilds && client->GuildID() != c->GuildID()) {
c->Message(Chat::White, "You cannot edit other peoples' guilds.");
} else { } else {
if (!client->IsInAGuild()) { if (!client->IsInAGuild()) {
c->Message( c->Message(

View File

@ -15,20 +15,13 @@ void command_interrogateinv(Client *c, const Seperator *sep)
// same or not. // same or not.
if (strcasecmp(sep->arg[1], "help") == 0) { if (strcasecmp(sep->arg[1], "help") == 0) {
if (c->Admin() < commandInterrogateInv) { c->Message(Chat::White, "Usage: #interrogateinv [log] [silent]");
c->Message(Chat::White, "Usage: #interrogateinv"); c->Message(
c->Message(Chat::White, " Displays your inventory's current in-memory nested storage references"); Chat::White,
} " Displays your or your Player target inventory's current in-memory nested storage references"
else { );
c->Message(Chat::White, "Usage: #interrogateinv [log] [silent]"); c->Message(Chat::White, " [log] - Logs interrogation to file");
c->Message( c->Message(Chat::White, " [silent] - Omits the in-game message portion of the interrogation");
Chat::White,
" Displays your or your Player target inventory's current in-memory nested storage references"
);
c->Message(Chat::White, " [log] - Logs interrogation to file");
c->Message(Chat::White, " [silent] - Omits the in-game message portion of the interrogation");
}
return;
} }
Client *target = nullptr; Client *target = nullptr;
@ -38,33 +31,20 @@ void command_interrogateinv(Client *c, const Seperator *sep)
bool error = false; bool error = false;
bool allowtrip = false; bool allowtrip = false;
if (c->Admin() < commandInterrogateInv) { if (c->GetTarget() == nullptr) {
if (c->GetInterrogateInvState()) { target = c;
c->Message(Chat::Red, "The last use of #interrogateinv on this inventory instance discovered an error..."); } else if (c->GetTarget()->IsClient()) {
c->Message(Chat::Red, "Logging out, zoning or re-arranging items at this point will result in item loss!"); target = c->GetTarget()->CastToClient();
return; } else {
} c->Message(Chat::Default, "Use of this command is limited to Client entities");
target = c; return;
allowtrip = true;
} }
else {
if (c->GetTarget() == nullptr) {
target = c;
}
else if (c->GetTarget()->IsClient()) {
target = c->GetTarget()->CastToClient();
}
else {
c->Message(Chat::Default, "Use of this command is limited to Client entities");
return;
}
if (strcasecmp(sep->arg[1], "log") == 0) { if (strcasecmp(sep->arg[1], "log") == 0) {
log = true; log = true;
} }
if (strcasecmp(sep->arg[2], "silent") == 0) { if (strcasecmp(sep->arg[2], "silent") == 0) {
silent = true; silent = true;
}
} }
bool success = target->InterrogateInventory(c, log, silent, allowtrip, error); bool success = target->InterrogateInventory(c, log, silent, allowtrip, error);

View File

@ -27,50 +27,48 @@ void command_invsnapshot(Client *c, const Seperator *sep)
"<td><c \"#AAAAAA\">takes snapshot of character inventory</td>" "<td><c \"#AAAAAA\">takes snapshot of character inventory</td>"
"</tr>"; "</tr>";
if (c->Admin() >= commandInvSnapshot) { window_text.append(
window_text.append( "<tr>"
"<tr>" "<td><c \"#00FF00\">gcount</td>"
"<td><c \"#00FF00\">gcount</td>" "<td></td>"
"<td></td>" "<td><c \"#AAAAAA\">returns global snapshot count</td>"
"<td><c \"#AAAAAA\">returns global snapshot count</td>" "</tr>"
"</tr>" "<tr>"
"<tr>" "<td><c \"#00FF00\">gclear</td>"
"<td><c \"#00FF00\">gclear</td>" "<td><c \"#FFFF00\"><br>now</td>"
"<td><c \"#FFFF00\"><br>now</td>" "<td><c \"#AAAAAA\">delete all snapshots - rule<br>delete all snapshots - now</td>"
"<td><c \"#AAAAAA\">delete all snapshots - rule<br>delete all snapshots - now</td>" "</tr>"
"</tr>" "<tr>"
"<tr>" "<td><c \"#00FF00\">count</td>"
"<td><c \"#00FF00\">count</td>" "<td></td>"
"<td></td>" "<td><c \"#AAAAAA\">returns character snapshot count</td>"
"<td><c \"#AAAAAA\">returns character snapshot count</td>" "</tr>"
"</tr>" "<tr>"
"<tr>" "<td><c \"#00FF00\">clear</td>"
"<td><c \"#00FF00\">clear</td>" "<td><c \"#FFFF00\"><br>now</td>"
"<td><c \"#FFFF00\"><br>now</td>" "<td><c \"#AAAAAA\">delete character snapshots - rule<br>delete character snapshots - now</td>"
"<td><c \"#AAAAAA\">delete character snapshots - rule<br>delete character snapshots - now</td>" "</tr>"
"</tr>" "<tr>"
"<tr>" "<td><c \"#00FF00\">list</td>"
"<td><c \"#00FF00\">list</td>" "<td><br><c \"#FFFF00\">count</td>"
"<td><br><c \"#FFFF00\">count</td>" "<td><c \"#AAAAAA\">lists entry ids for current character<br>limits to count</td>"
"<td><c \"#AAAAAA\">lists entry ids for current character<br>limits to count</td>" "</tr>"
"</tr>" "<tr>"
"<tr>" "<td><c \"#00FF00\">parse</td>"
"<td><c \"#00FF00\">parse</td>" "<td><c \"#00FF00\">tstmp</td>"
"<td><c \"#00FF00\">tstmp</td>" "<td><c \"#AAAAAA\">displays slots and items in snapshot</td>"
"<td><c \"#AAAAAA\">displays slots and items in snapshot</td>" "</tr>"
"</tr>" "<tr>"
"<tr>" "<td><c \"#00FF00\">compare</td>"
"<td><c \"#00FF00\">compare</td>" "<td><c \"#00FF00\">tstmp</td>"
"<td><c \"#00FF00\">tstmp</td>" "<td><c \"#AAAAAA\">compares inventory against snapshot</td>"
"<td><c \"#AAAAAA\">compares inventory against snapshot</td>" "</tr>"
"</tr>" "<tr>"
"<tr>" "<td><c \"#00FF00\">restore</td>"
"<td><c \"#00FF00\">restore</td>" "<td><c \"#00FF00\">tstmp</td>"
"<td><c \"#00FF00\">tstmp</td>" "<td><c \"#AAAAAA\">restores slots and items in snapshot</td>"
"<td><c \"#AAAAAA\">restores slots and items in snapshot</td>" "</tr>"
"</tr>" );
);
}
window_text.append( window_text.append(
"</table>" "</table>"
@ -81,34 +79,30 @@ void command_invsnapshot(Client *c, const Seperator *sep)
return; return;
} }
if (c->Admin() >= commandInvSnapshot) { // global arguments if (strcmp(sep->arg[1], "gcount") == 0) {
auto is_count = database.CountInvSnapshots();
c->Message(
Chat::White,
"There %s %i inventory snapshot%s.",
(is_count == 1 ? "is" : "are"),
is_count,
(is_count == 1 ? "" : "s"));
if (strcmp(sep->arg[1], "gcount") == 0) { return;
auto is_count = database.CountInvSnapshots(); }
if (strcmp(sep->arg[1], "gclear") == 0) {
if (strcmp(sep->arg[2], "now") == 0) {
database.ClearInvSnapshots(true);
c->Message(Chat::White, "Inventory snapshots cleared using current time.");
} else {
database.ClearInvSnapshots();
c->Message( c->Message(
Chat::White, Chat::White, "Inventory snapshots cleared using RuleI(Character, InvSnapshotHistoryD) (%i day%s).",
"There %s %i inventory snapshot%s.", RuleI(Character, InvSnapshotHistoryD), (RuleI(Character, InvSnapshotHistoryD) == 1 ? "" : "s"));
(is_count == 1 ? "is" : "are"),
is_count,
(is_count == 1 ? "" : "s"));
return;
} }
if (strcmp(sep->arg[1], "gclear") == 0) { return;
if (strcmp(sep->arg[2], "now") == 0) {
database.ClearInvSnapshots(true);
c->Message(Chat::White, "Inventory snapshots cleared using current time.");
}
else {
database.ClearInvSnapshots();
c->Message(
Chat::White, "Inventory snapshots cleared using RuleI(Character, InvSnapshotHistoryD) (%i day%s).",
RuleI(Character, InvSnapshotHistoryD), (RuleI(Character, InvSnapshotHistoryD) == 1 ? "" : "s"));
}
return;
}
} }
if (!c->GetTarget() || !c->GetTarget()->IsClient()) { if (!c->GetTarget() || !c->GetTarget()->IsClient()) {
@ -127,8 +121,7 @@ void command_invsnapshot(Client *c, const Seperator *sep)
tc->GetName(), tc->GetName(),
RuleI(Character, InvSnapshotMinIntervalM), RuleI(Character, InvSnapshotMinIntervalM),
(RuleI(Character, InvSnapshotMinIntervalM) == 1 ? "" : "s")); (RuleI(Character, InvSnapshotMinIntervalM) == 1 ? "" : "s"));
} } else {
else {
tc->SetNextInvSnapshot(RuleI(Character, InvSnapshotMinRetryM)); tc->SetNextInvSnapshot(RuleI(Character, InvSnapshotMinRetryM));
c->Message( c->Message(
Chat::White, Chat::White,
@ -141,278 +134,266 @@ void command_invsnapshot(Client *c, const Seperator *sep)
return; return;
} }
if (c->Admin() >= commandInvSnapshot) { if (strcmp(sep->arg[1], "count") == 0) {
if (strcmp(sep->arg[1], "count") == 0) { auto is_count = database.CountCharacterInvSnapshots(tc->CharacterID());
auto is_count = database.CountCharacterInvSnapshots(tc->CharacterID()); c->Message(
Chat::White,
"%s (id: %u) has %i inventory snapshot%s.",
tc->GetName(),
tc->CharacterID(),
is_count,
(is_count == 1 ? "" : "s"));
return;
}
if (strcmp(sep->arg[1], "clear") == 0) {
if (strcmp(sep->arg[2], "now") == 0) {
database.ClearCharacterInvSnapshots(tc->CharacterID(), true);
c->Message( c->Message(
Chat::White, Chat::White,
"%s (id: %u) has %i inventory snapshot%s.", "%s\'s (id: %u) inventory snapshots cleared using current time.",
tc->GetName(),
tc->CharacterID());
} else {
database.ClearCharacterInvSnapshots(tc->CharacterID());
c->Message(
Chat::White,
"%s\'s (id: %u) inventory snapshots cleared using RuleI(Character, InvSnapshotHistoryD) (%i day%s).",
tc->GetName(), tc->GetName(),
tc->CharacterID(), tc->CharacterID(),
is_count, RuleI(Character, InvSnapshotHistoryD),
(is_count == 1 ? "" : "s")); (RuleI(Character, InvSnapshotHistoryD) == 1 ? "" : "s"));
}
return;
}
if (strcmp(sep->arg[1], "list") == 0) {
std::list<std::pair<uint32, int>> is_list;
database.ListCharacterInvSnapshots(tc->CharacterID(), is_list);
if (is_list.empty()) {
c->Message(Chat::White, "No inventory snapshots for %s (id: %u)", tc->GetName(), tc->CharacterID());
return; return;
} }
if (strcmp(sep->arg[1], "clear") == 0) { auto list_count = 0;
if (strcmp(sep->arg[2], "now") == 0) { if (sep->IsNumber(2)) {
database.ClearCharacterInvSnapshots(tc->CharacterID(), true); list_count = Strings::ToInt(sep->arg[2]);
c->Message( }
Chat::White, if (list_count < 1 || list_count > is_list.size()) {
"%s\'s (id: %u) inventory snapshots cleared using current time.", list_count = is_list.size();
tc->GetName(),
tc->CharacterID());
}
else {
database.ClearCharacterInvSnapshots(tc->CharacterID());
c->Message(
Chat::White,
"%s\'s (id: %u) inventory snapshots cleared using RuleI(Character, InvSnapshotHistoryD) (%i day%s).",
tc->GetName(),
tc->CharacterID(),
RuleI(Character, InvSnapshotHistoryD),
(RuleI(Character, InvSnapshotHistoryD) == 1 ? "" : "s"));
}
return;
} }
if (strcmp(sep->arg[1], "list") == 0) { std::string window_title = StringFormat("Snapshots for %s", tc->GetName());
std::list<std::pair<uint32, int>> is_list;
database.ListCharacterInvSnapshots(tc->CharacterID(), is_list);
if (is_list.empty()) { std::string window_text =
c->Message(Chat::White, "No inventory snapshots for %s (id: %u)", tc->GetName(), tc->CharacterID()); "<table>"
return;
}
auto list_count = 0;
if (sep->IsNumber(2)) {
list_count = Strings::ToInt(sep->arg[2]);
}
if (list_count < 1 || list_count > is_list.size()) {
list_count = is_list.size();
}
std::string window_title = StringFormat("Snapshots for %s", tc->GetName());
std::string window_text =
"<table>"
"<tr>"
"<td>Timestamp</td>"
"<td>Entry Count</td>"
"</tr>";
for (auto iter : is_list) {
if (!list_count) {
break;
}
window_text.append(
StringFormat(
"<tr>" "<tr>"
"<td>%u</td>" "<td>Timestamp</td>"
"<td>%i</td>" "<td>Entry Count</td>"
"</tr>", "</tr>";
iter.first,
iter.second
));
--list_count; for (auto iter: is_list) {
if (!list_count) {
break;
} }
window_text.append( window_text.append(
"</table>" StringFormat(
); "<tr>"
"<td>%u</td>"
c->SendPopupToClient(window_title.c_str(), window_text.c_str()); "<td>%i</td>"
"</tr>",
return;
}
if (strcmp(sep->arg[1], "parse") == 0) {
if (!sep->IsNumber(2)) {
c->Message(Chat::White, "A timestamp is required to use this option.");
return;
}
uint32 timestamp = Strings::ToUnsignedInt(sep->arg[2]);
if (!database.ValidateCharacterInvSnapshotTimestamp(tc->CharacterID(), timestamp)) {
c->Message(
Chat::White,
"No inventory snapshots for %s (id: %u) exist at %u.",
tc->GetName(),
tc->CharacterID(),
timestamp
);
return;
}
std::list<std::pair<int16, uint32>> parse_list;
database.ParseCharacterInvSnapshot(tc->CharacterID(), timestamp, parse_list);
std::string window_title = StringFormat("Snapshot Parse for %s @ %u", tc->GetName(), timestamp);
std::string window_text = "Slot: ItemID - Description<br>";
for (auto iter : parse_list) {
auto item_data = database.GetItem(iter.second);
std::string window_line = StringFormat(
"%i: %u - %s<br>",
iter.first, iter.first,
iter.second, iter.second
(item_data ? item_data->Name : "[error]")); ));
if (window_text.length() + window_line.length() < 4095) { --list_count;
window_text.append(window_line); }
}
else {
c->Message(Chat::White, "Too many snapshot entries to list...");
break;
}
}
c->SendPopupToClient(window_title.c_str(), window_text.c_str()); window_text.append(
"</table>"
);
c->SendPopupToClient(window_title.c_str(), window_text.c_str());
return;
}
if (strcmp(sep->arg[1], "parse") == 0) {
if (!sep->IsNumber(2)) {
c->Message(Chat::White, "A timestamp is required to use this option.");
return; return;
} }
if (strcmp(sep->arg[1], "compare") == 0) { uint32 timestamp = Strings::ToUnsignedInt(sep->arg[2]);
if (!sep->IsNumber(2)) {
c->Message(Chat::White, "A timestamp is required to use this option."); if (!database.ValidateCharacterInvSnapshotTimestamp(tc->CharacterID(), timestamp)) {
return; c->Message(
Chat::White,
"No inventory snapshots for %s (id: %u) exist at %u.",
tc->GetName(),
tc->CharacterID(),
timestamp
);
return;
}
std::list<std::pair<int16, uint32>> parse_list;
database.ParseCharacterInvSnapshot(tc->CharacterID(), timestamp, parse_list);
std::string window_title = StringFormat("Snapshot Parse for %s @ %u", tc->GetName(), timestamp);
std::string window_text = "Slot: ItemID - Description<br>";
for (auto iter: parse_list) {
auto item_data = database.GetItem(iter.second);
std::string window_line = StringFormat(
"%i: %u - %s<br>",
iter.first,
iter.second,
(item_data ? item_data->Name : "[error]"));
if (window_text.length() + window_line.length() < 4095) {
window_text.append(window_line);
} else {
c->Message(Chat::White, "Too many snapshot entries to list...");
break;
} }
}
uint32 timestamp = Strings::ToUnsignedInt(sep->arg[2]); c->SendPopupToClient(window_title.c_str(), window_text.c_str());
if (!database.ValidateCharacterInvSnapshotTimestamp(tc->CharacterID(), timestamp)) { return;
c->Message( }
Chat::White,
"No inventory snapshots for %s (id: %u) exist at %u.",
tc->GetName(),
tc->CharacterID(),
timestamp
);
return;
}
std::list<std::pair<int16, uint32>> inv_compare_list; if (strcmp(sep->arg[1], "compare") == 0) {
database.DivergeCharacterInventoryFromInvSnapshot(tc->CharacterID(), timestamp, inv_compare_list); if (!sep->IsNumber(2)) {
c->Message(Chat::White, "A timestamp is required to use this option.");
return;
}
std::list<std::pair<int16, uint32>> iss_compare_list; uint32 timestamp = Strings::ToUnsignedInt(sep->arg[2]);
database.DivergeCharacterInvSnapshotFromInventory(tc->CharacterID(), timestamp, iss_compare_list);
std::string window_title = StringFormat("Snapshot Comparison for %s @ %u", tc->GetName(), timestamp); if (!database.ValidateCharacterInvSnapshotTimestamp(tc->CharacterID(), timestamp)) {
c->Message(
Chat::White,
"No inventory snapshots for %s (id: %u) exist at %u.",
tc->GetName(),
tc->CharacterID(),
timestamp
);
return;
}
std::string window_text = "Slot: (action) Snapshot -&gt; Inventory<br>"; std::list<std::pair<int16, uint32>> inv_compare_list;
database.DivergeCharacterInventoryFromInvSnapshot(tc->CharacterID(), timestamp, inv_compare_list);
auto inv_iter = inv_compare_list.begin(); std::list<std::pair<int16, uint32>> iss_compare_list;
auto iss_iter = iss_compare_list.begin(); database.DivergeCharacterInvSnapshotFromInventory(tc->CharacterID(), timestamp, iss_compare_list);
while (true) { std::string window_title = StringFormat("Snapshot Comparison for %s @ %u", tc->GetName(), timestamp);
std::string window_line;
if (inv_iter == inv_compare_list.end() && iss_iter == iss_compare_list.end()) { std::string window_text = "Slot: (action) Snapshot -&gt; Inventory<br>";
break;
} auto inv_iter = inv_compare_list.begin();
else if (inv_iter != inv_compare_list.end() && iss_iter == iss_compare_list.end()) { auto iss_iter = iss_compare_list.begin();
window_line = StringFormat("%i: (delete) [empty] -&gt; %u<br>", inv_iter->first, inv_iter->second);
while (true) {
std::string window_line;
if (inv_iter == inv_compare_list.end() && iss_iter == iss_compare_list.end()) {
break;
} else if (inv_iter != inv_compare_list.end() && iss_iter == iss_compare_list.end()) {
window_line = StringFormat("%i: (delete) [empty] -&gt; %u<br>", inv_iter->first, inv_iter->second);
++inv_iter;
} else if (inv_iter == inv_compare_list.end() && iss_iter != iss_compare_list.end()) {
window_line = StringFormat("%i: (insert) %u -&gt; [empty]<br>", iss_iter->first, iss_iter->second);
++iss_iter;
} else {
if (inv_iter->first < iss_iter->first) {
window_line = StringFormat(
"%i: (delete) [empty] -&gt; %u<br>",
inv_iter->first,
inv_iter->second
);
++inv_iter;
} else if (inv_iter->first > iss_iter->first) {
window_line = StringFormat(
"%i: (insert) %u -&gt; [empty]<br>",
iss_iter->first,
iss_iter->second
);
++iss_iter;
} else {
window_line = StringFormat(
"%i: (replace) %u -&gt; %u<br>",
iss_iter->first,
iss_iter->second,
inv_iter->second
);
++inv_iter; ++inv_iter;
}
else if (inv_iter == inv_compare_list.end() && iss_iter != iss_compare_list.end()) {
window_line = StringFormat("%i: (insert) %u -&gt; [empty]<br>", iss_iter->first, iss_iter->second);
++iss_iter; ++iss_iter;
} }
else {
if (inv_iter->first < iss_iter->first) {
window_line = StringFormat(
"%i: (delete) [empty] -&gt; %u<br>",
inv_iter->first,
inv_iter->second
);
++inv_iter;
}
else if (inv_iter->first > iss_iter->first) {
window_line = StringFormat(
"%i: (insert) %u -&gt; [empty]<br>",
iss_iter->first,
iss_iter->second
);
++iss_iter;
}
else {
window_line = StringFormat(
"%i: (replace) %u -&gt; %u<br>",
iss_iter->first,
iss_iter->second,
inv_iter->second
);
++inv_iter;
++iss_iter;
}
}
if (window_text.length() + window_line.length() < 4095) {
window_text.append(window_line);
}
else {
c->Message(Chat::White, "Too many comparison entries to list...");
break;
}
} }
c->SendPopupToClient(window_title.c_str(), window_text.c_str()); if (window_text.length() + window_line.length() < 4095) {
window_text.append(window_line);
} else {
c->Message(Chat::White, "Too many comparison entries to list...");
break;
}
}
c->SendPopupToClient(window_title.c_str(), window_text.c_str());
return;
}
if (strcmp(sep->arg[1], "restore") == 0) {
if (!sep->IsNumber(2)) {
c->Message(Chat::White, "A timestamp is required to use this option.");
return; return;
} }
if (strcmp(sep->arg[1], "restore") == 0) { uint32 timestamp = Strings::ToUnsignedInt(sep->arg[2]);
if (!sep->IsNumber(2)) {
c->Message(Chat::White, "A timestamp is required to use this option.");
return;
}
uint32 timestamp = Strings::ToUnsignedInt(sep->arg[2]);
if (!database.ValidateCharacterInvSnapshotTimestamp(tc->CharacterID(), timestamp)) {
c->Message(
Chat::White,
"No inventory snapshots for %s (id: %u) exist at %u.",
tc->GetName(),
tc->CharacterID(),
timestamp
);
return;
}
if (database.SaveCharacterInvSnapshot(tc->CharacterID())) {
tc->SetNextInvSnapshot(RuleI(Character, InvSnapshotMinIntervalM));
}
else {
c->Message(
Chat::Red, "Failed to take pre-restore inventory snapshot of %s (id: %u).",
tc->GetName(), tc->CharacterID());
return;
}
if (database.RestoreCharacterInvSnapshot(tc->CharacterID(), timestamp)) {
// cannot delete all valid item slots from client..so, we worldkick
tc->WorldKick(); // self restores update before the 'kick' is processed
c->Message(
Chat::White, "Successfully applied snapshot %u to %s's (id: %u) inventory.",
timestamp, tc->GetName(), tc->CharacterID());
}
else {
c->Message(
Chat::Red, "Failed to apply snapshot %u to %s's (id: %u) inventory.",
timestamp, tc->GetName(), tc->CharacterID());
}
if (!database.ValidateCharacterInvSnapshotTimestamp(tc->CharacterID(), timestamp)) {
c->Message(
Chat::White,
"No inventory snapshots for %s (id: %u) exist at %u.",
tc->GetName(),
tc->CharacterID(),
timestamp
);
return; return;
} }
if (database.SaveCharacterInvSnapshot(tc->CharacterID())) {
tc->SetNextInvSnapshot(RuleI(Character, InvSnapshotMinIntervalM));
} else {
c->Message(
Chat::Red, "Failed to take pre-restore inventory snapshot of %s (id: %u).",
tc->GetName(), tc->CharacterID());
return;
}
if (database.RestoreCharacterInvSnapshot(tc->CharacterID(), timestamp)) {
// cannot delete all valid item slots from client..so, we worldkick
tc->WorldKick(); // self restores update before the 'kick' is processed
c->Message(
Chat::White, "Successfully applied snapshot %u to %s's (id: %u) inventory.",
timestamp, tc->GetName(), tc->CharacterID());
} else {
c->Message(
Chat::Red, "Failed to apply snapshot %u to %s's (id: %u) inventory.",
timestamp, tc->GetName(), tc->CharacterID());
}
return;
} }
} }

View File

@ -2,18 +2,18 @@
void command_movechar(Client *c, const Seperator *sep) void command_movechar(Client *c, const Seperator *sep)
{ {
int arguments = sep->argnum; const int arguments = sep->argnum;
if (arguments < 2) { if (arguments < 2) {
c->Message(Chat::White, "Usage: #movechar [Character ID|Character Name] [Zone ID|Zone Short Name]"); c->Message(Chat::White, "Usage: #movechar [Character ID|Character Name] [Zone ID|Zone Short Name]");
return; return;
} }
std::string character_name = ( const std::string &character_name = (
sep->IsNumber(1) ? sep->IsNumber(1) ?
database.GetCharNameByID(Strings::ToUnsignedInt(sep->arg[1])) : database.GetCharNameByID(Strings::ToUnsignedInt(sep->arg[1])) :
sep->arg[1] sep->arg[1]
); );
auto character_id = database.GetCharacterID(character_name.c_str()); const uint32 character_id = database.GetCharacterID(character_name.c_str());
if (!character_id) { if (!character_id) {
c->Message( c->Message(
Chat::White, Chat::White,
@ -25,15 +25,15 @@ void command_movechar(Client *c, const Seperator *sep)
return; return;
} }
auto account_id = database.GetAccountIDByChar(character_name.c_str()); const uint32 account_id = database.GetAccountIDByChar(character_name.c_str());
std::string zone_short_name = Strings::ToLower( const std::string &zone_short_name = Strings::ToLower(
sep->IsNumber(2) ? sep->IsNumber(2) ?
ZoneName(Strings::ToUnsignedInt(sep->arg[2]), true) : ZoneName(Strings::ToUnsignedInt(sep->arg[2]), true) :
sep->arg[2] sep->arg[2]
); );
bool is_unknown_zone = zone_short_name.find("unknown") != std::string::npos; const bool is_unknown_zone = zone_short_name.find("unknown") != std::string::npos;
if (is_unknown_zone) { if (is_unknown_zone) {
c->Message( c->Message(
Chat::White, Chat::White,
@ -45,63 +45,34 @@ void command_movechar(Client *c, const Seperator *sep)
return; return;
} }
auto zone_id = ZoneID(zone_short_name); const uint32 zone_id = ZoneID(zone_short_name);
auto z = GetZone(zone_id); auto z = GetZone(zone_id);
if (!z) { if (!z) {
c->Message(Chat::Red, "Invalid zone."); c->Message(Chat::Red, "Invalid zone.");
return; return;
} }
bool is_special_zone = ( const bool moved = database.MoveCharacterToZone(character_name.c_str(), zone_id);
zone_short_name.find("cshome") != std::string::npos || std::string moved_string = moved ? "Succeeded" : "Failed";
zone_short_name.find("load") != std::string::npos || c->Message(
zone_short_name.find("load2") != std::string::npos Chat::White,
fmt::format(
"Character Move {} | Character: {} ({})",
moved_string,
character_name,
character_id
).c_str()
); );
if (c->Admin() < commandMovecharToSpecials && is_special_zone) { c->Message(
c->Message( Chat::White,
Chat::White, fmt::format(
fmt::format( "Character Move {} | Zone: {} ({}) ID: {}",
"{} ({}) is a special zone and you cannot move someone there.", moved_string,
z->long_name, z->long_name,
zone_short_name zone_short_name,
).c_str() zone_id
); ).c_str()
return; );
}
if (
c->Admin() >= commandMovecharSelfOnly ||
account_id == c->AccountID()
) {
bool moved = database.MoveCharacterToZone(character_name.c_str(), zone_id);
std::string moved_string = (
moved ?
"Succeeded" :
"Failed"
);
c->Message(
Chat::White,
fmt::format(
"Character Move {} | Character: {} ({})",
moved_string,
character_name,
character_id
).c_str()
);
c->Message(
Chat::White,
fmt::format(
"Character Move {} | Zone: {} ({}) ID: {}",
moved_string,
z->long_name,
zone_short_name,
zone_id
).c_str()
);
} else {
c->Message(Chat::White, "You cannot move characters that are not on your account.");
}
} }

View File

@ -2,13 +2,8 @@
void ShowFlags(Client *c, const Seperator *sep) void ShowFlags(Client *c, const Seperator *sep)
{ {
auto t = c; Client *t = c;
if (c->GetTarget() && c->GetTarget()->IsClient()) {
if (
c->GetTarget() &&
c->GetTarget()->IsClient() &&
c->Admin() >= minStatusToSeeOthersZoneFlags
) {
t = c->GetTarget()->CastToClient(); t = c->GetTarget()->CastToClient();
} }

View File

@ -2,12 +2,8 @@
void ShowPEQZoneFlags(Client *c, const Seperator *sep) void ShowPEQZoneFlags(Client *c, const Seperator *sep)
{ {
auto t = c; Client *t = c;
if ( if (c->GetTarget() && c->GetTarget()->IsClient()) {
c->GetTarget() &&
c->GetTarget()->IsClient() &&
c->Admin() >= minStatusToSeeOthersZoneFlags
) {
t = c->GetTarget()->CastToClient(); t = c->GetTarget()->CastToClient();
} }

View File

@ -1343,7 +1343,7 @@ bool Client::CanEnterZone(const std::string& zone_short_name, int16 instance_ver
} }
if (!z->flag_needed.empty() && Strings::IsNumber(z->flag_needed) && Strings::ToBool(z->flag_needed)) { if (!z->flag_needed.empty() && Strings::IsNumber(z->flag_needed) && Strings::ToBool(z->flag_needed)) {
if (Admin() < minStatusToIgnoreZoneFlags && !HasZoneFlag(z->zoneidnumber)) { if (!GetGM() && !HasZoneFlag(z->zoneidnumber)) {
LogInfo( LogInfo(
"Character [{}] does not have the flag to be in this zone [{}]!", "Character [{}] does not have the flag to be in this zone [{}]!",
GetCleanName(), GetCleanName(),