mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-31 04:56:20 +00:00
[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:
@@ -23,10 +23,7 @@ void command_castspell(Client *c, const Seperator *sep)
|
||||
|
||||
const uint16 spell_id = Strings::ToUnsignedInt(sep->arg[1]);
|
||||
|
||||
if (IsCastRestrictedSpell(spell_id) && c->Admin() < commandCastSpecials) {
|
||||
c->Message(Chat::White, "Unable to cast spell.");
|
||||
return;
|
||||
} else if (spell_id >= SPDAT_RECORDS) {
|
||||
if (spell_id >= SPDAT_RECORDS) {
|
||||
c->Message(Chat::White, "Invalid Spell ID.");
|
||||
return;
|
||||
}
|
||||
|
||||
+113
-182
@@ -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 inspectloot - Inspects the loot on a corpse");
|
||||
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 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 deleteplayercorpses - Deletes all player corpses");
|
||||
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 listplayer - Lists all player corpses");
|
||||
c->Message(Chat::White, "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.");
|
||||
}
|
||||
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 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 listplayer - Lists all player corpses");
|
||||
c->Message(
|
||||
Chat::White,
|
||||
"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;
|
||||
}
|
||||
|
||||
@@ -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 inspectloot - Inspects the loot on a corpse");
|
||||
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 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 deleteplayercorpses - Deletes all player corpses");
|
||||
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 listplayer - Lists all player corpses");
|
||||
c->Message(Chat::White, "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.");
|
||||
}
|
||||
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 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 listplayer - Lists all player corpses");
|
||||
c->Message(
|
||||
Chat::White,
|
||||
"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;
|
||||
}
|
||||
|
||||
|
||||
if (is_delete_player_corpses) {
|
||||
if (c->Admin() >= commandEditPlayerCorpses) {
|
||||
auto corpses_deleted = entity_list.DeletePlayerCorpses();
|
||||
auto deleted_string = (
|
||||
corpses_deleted ?
|
||||
fmt::format(
|
||||
"{} Player corpse{} deleted.",
|
||||
corpses_deleted,
|
||||
corpses_deleted != 1 ? "s" : ""
|
||||
) :
|
||||
"There are no player corpses to delete."
|
||||
);
|
||||
c->Message(Chat::White, deleted_string.c_str());
|
||||
} else {
|
||||
c->Message(Chat::White, "Your status is not high enough to delete player corpses.");
|
||||
return;
|
||||
}
|
||||
auto corpses_deleted = entity_list.DeletePlayerCorpses();
|
||||
auto deleted_string = (
|
||||
corpses_deleted ?
|
||||
fmt::format(
|
||||
"{} Player corpse{} deleted.",
|
||||
corpses_deleted,
|
||||
corpses_deleted != 1 ? "s" : ""
|
||||
) :
|
||||
"There are no player corpses to delete."
|
||||
);
|
||||
c->Message(Chat::White, deleted_string.c_str());
|
||||
} else if (is_delete) {
|
||||
if (!target || !target->IsCorpse()) {
|
||||
c->Message(Chat::White, "You must target a corpse to use this command.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (target->IsPlayerCorpse() && c->Admin() < commandEditPlayerCorpses) {
|
||||
c->Message(Chat::White, "Your status is not high enough to delete a player corpse.");
|
||||
return;
|
||||
}
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Deleting {} corpse {}.",
|
||||
target->IsNPCCorpse() ? "NPC" : "player",
|
||||
c->GetTargetDescription(target)
|
||||
).c_str()
|
||||
);
|
||||
|
||||
if (
|
||||
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();
|
||||
}
|
||||
target->CastToCorpse()->Delete();
|
||||
} else if (is_list_npc) {
|
||||
entity_list.ListNPCCorpses(c);
|
||||
} 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);
|
||||
} else if (is_delete_npc_corpses) {
|
||||
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());
|
||||
} else if (is_character_id) {
|
||||
if (c->Admin() >= commandEditPlayerCorpses) {
|
||||
if (!target || !target->IsPlayerCorpse()) {
|
||||
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.");
|
||||
if (!target || !target->IsPlayerCorpse()) {
|
||||
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;
|
||||
}
|
||||
|
||||
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) {
|
||||
if (!target || !target->IsCorpse()) {
|
||||
c->Message(Chat::White, "You must target a corpse to use this command.");
|
||||
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();
|
||||
c->Message(
|
||||
Chat::White,
|
||||
@@ -190,36 +169,22 @@ void command_corpse(Client *c, const Seperator *sep)
|
||||
return;
|
||||
}
|
||||
|
||||
if (target->IsPlayerCorpse() && c->Admin() < commandEditPlayerCorpses) {
|
||||
c->Message(Chat::White, "Your status is not high enough to remove cash from a player corpse.");
|
||||
return;
|
||||
}
|
||||
target->CastToCorpse()->RemoveCash();
|
||||
|
||||
if (
|
||||
target->IsNPCCorpse() ||
|
||||
c->Admin() >= commandEditPlayerCorpses
|
||||
) {
|
||||
target->CastToCorpse()->RemoveCash();
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Removed cash from {} corpse {}.",
|
||||
target->IsNPCCorpse() ? "NPC" : "player",
|
||||
c->GetTargetDescription(target)
|
||||
).c_str()
|
||||
);
|
||||
}
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Removed cash from {} corpse {}.",
|
||||
target->IsNPCCorpse() ? "NPC" : "player",
|
||||
c->GetTargetDescription(target)
|
||||
).c_str()
|
||||
);
|
||||
} else if (is_inspect_loot) {
|
||||
if (!target || !target->IsCorpse()) {
|
||||
c->Message(Chat::White, "You must target a corpse to use this command.");
|
||||
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);
|
||||
} else if (is_lock) {
|
||||
if (!target || !target->IsCorpse()) {
|
||||
@@ -227,11 +192,6 @@ void command_corpse(Client *c, const Seperator *sep)
|
||||
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();
|
||||
c->Message(
|
||||
Chat::White,
|
||||
@@ -247,11 +207,6 @@ void command_corpse(Client *c, const Seperator *sep)
|
||||
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();
|
||||
c->Message(
|
||||
Chat::White,
|
||||
@@ -267,30 +222,20 @@ void command_corpse(Client *c, const Seperator *sep)
|
||||
return;
|
||||
}
|
||||
|
||||
if (c->Admin() >= commandEditPlayerCorpses) {
|
||||
bool bury_corpse = (
|
||||
sep->IsNumber(2) ?
|
||||
(
|
||||
Strings::ToInt(sep->arg[2]) != 0 ?
|
||||
true :
|
||||
false
|
||||
) :
|
||||
false
|
||||
);
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Depopping player corpse {}.",
|
||||
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;
|
||||
const bool bury_corpse = sep->IsNumber(2) ? Strings::ToBool(sep->arg[2]) : false;
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Depopping player corpse {}.",
|
||||
c->GetTargetDescription(target)
|
||||
).c_str()
|
||||
);
|
||||
|
||||
target->CastToCorpse()->DepopPlayerCorpse();
|
||||
|
||||
if (bury_corpse) {
|
||||
target->CastToCorpse()->Bury();
|
||||
}
|
||||
} else if (is_depop_all) {
|
||||
if (!target || !target->IsClient()) {
|
||||
@@ -298,50 +243,36 @@ void command_corpse(Client *c, const Seperator *sep)
|
||||
return;
|
||||
}
|
||||
|
||||
if (c->Admin() >= commandEditPlayerCorpses) {
|
||||
bool bury_corpse = (
|
||||
sep->IsNumber(2) ?
|
||||
(
|
||||
Strings::ToInt(sep->arg[2]) != 0 ?
|
||||
true :
|
||||
false
|
||||
) :
|
||||
false
|
||||
);
|
||||
const bool bury_corpse = sep->IsNumber(2) ? Strings::ToBool(sep->arg[2]) : false;
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Depopping all player corpses for {}.",
|
||||
c->GetTargetDescription(target)
|
||||
).c_str()
|
||||
);
|
||||
|
||||
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(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Depopping all player corpses for {}.",
|
||||
c->GetTargetDescription(target)
|
||||
"Moved {} player corpse{} to graveyard in {} ({}).",
|
||||
moved_count,
|
||||
moved_count != 1 ? "s" : "",
|
||||
ZoneLongName(zone->GetZoneID()),
|
||||
ZoneName(zone->GetZoneID())
|
||||
).c_str()
|
||||
);
|
||||
target->CastToClient()->DepopAllCorpses();
|
||||
if (bury_corpse) {
|
||||
target->CastToClient()->BuryPlayerCorpses();
|
||||
}
|
||||
} else {
|
||||
c->Message(Chat::White, "Your status is not high enough to depop all of a player's corpses.");
|
||||
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.");
|
||||
c->Message(Chat::White, "There are no player corpses to move to the graveyard.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ void command_doanim(Client *c, const Seperator *sep)
|
||||
}
|
||||
|
||||
Mob* t = c;
|
||||
if (c->GetTarget() && c->Admin() >= commandDoAnimOthers) {
|
||||
if (c->GetTarget()) {
|
||||
t = c->GetTarget();
|
||||
}
|
||||
|
||||
|
||||
@@ -81,11 +81,6 @@ void command_guild(Client *c, const Seperator *sep)
|
||||
).c_str()
|
||||
);
|
||||
} else {
|
||||
if (c->Admin() < minStatusToEditOtherGuilds) {
|
||||
c->Message(Chat::White, "You cannot edit other peoples' guilds.");
|
||||
return;
|
||||
}
|
||||
|
||||
auto guild_name = sep->argplus[3];
|
||||
auto guild_id = guild_mgr.CreateGuild(sep->argplus[3], leader_id);
|
||||
|
||||
@@ -144,16 +139,6 @@ void command_guild(Client *c, const Seperator *sep)
|
||||
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(
|
||||
"[{}]: Deleting guild [{}] ([{}]) with GM command",
|
||||
c->GetName(),
|
||||
@@ -175,16 +160,10 @@ void command_guild(Client *c, const Seperator *sep)
|
||||
SendGuildSubCommands(c);
|
||||
} else if (is_info) {
|
||||
if (arguments != 2 && c->IsInAGuild()) {
|
||||
if (c->Admin() >= minStatusToEditOtherGuilds) {
|
||||
c->Message(Chat::White, "#guild info [Guild ID]");
|
||||
} else {
|
||||
c->Message(Chat::White, "You cannot edit other peoples' guilds.");
|
||||
}
|
||||
c->Message(Chat::White, "#guild info [Guild ID]");
|
||||
} else {
|
||||
auto guild_id = GUILD_NONE;
|
||||
if (arguments != 2 || !sep->IsNumber(2)) {
|
||||
guild_id = c->GuildID();
|
||||
} else if (c->Admin() >= minStatusToEditOtherGuilds) {
|
||||
if (sep->IsNumber(2)) {
|
||||
guild_id = Strings::ToUnsignedInt(sep->arg[2]);
|
||||
}
|
||||
|
||||
@@ -193,11 +172,6 @@ void command_guild(Client *c, const Seperator *sep)
|
||||
}
|
||||
}
|
||||
} 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());
|
||||
} else if (is_rename) {
|
||||
if (!sep->IsNumber(2)) {
|
||||
@@ -215,16 +189,6 @@ void command_guild(Client *c, const Seperator *sep)
|
||||
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];
|
||||
LogGuilds(
|
||||
"[{}]: Renaming guild [{}] ([{}]) to [{}] with GM command",
|
||||
@@ -293,11 +257,6 @@ void command_guild(Client *c, const Seperator *sep)
|
||||
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) {
|
||||
LogGuilds(
|
||||
"[{}]: Removing [{}] ([{}]) from guild with GM command",
|
||||
@@ -390,16 +349,6 @@ void command_guild(Client *c, const Seperator *sep)
|
||||
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(
|
||||
"[{}]: Setting leader of guild [{}] ([{}]) to [{}] with GM command",
|
||||
c->GetName(),
|
||||
@@ -461,11 +410,6 @@ void command_guild(Client *c, const Seperator *sep)
|
||||
return;
|
||||
}
|
||||
|
||||
if (c->Admin() < minStatusToEditOtherGuilds && character_id != c->CharacterID()) {
|
||||
c->Message(Chat::White, "You cannot edit other peoples' guilds.");
|
||||
return;
|
||||
}
|
||||
|
||||
LogGuilds(
|
||||
"[{}]: Setting [{}] ([{}])'s guild rank to [{}] with GM command",
|
||||
c->GetName(),
|
||||
@@ -498,8 +442,6 @@ void command_guild(Client *c, const Seperator *sep)
|
||||
);
|
||||
if (!client) {
|
||||
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 {
|
||||
if (!client->IsInAGuild()) {
|
||||
c->Message(
|
||||
|
||||
@@ -15,20 +15,13 @@ void command_interrogateinv(Client *c, const Seperator *sep)
|
||||
// same or not.
|
||||
|
||||
if (strcasecmp(sep->arg[1], "help") == 0) {
|
||||
if (c->Admin() < commandInterrogateInv) {
|
||||
c->Message(Chat::White, "Usage: #interrogateinv");
|
||||
c->Message(Chat::White, " Displays your inventory's current in-memory nested storage references");
|
||||
}
|
||||
else {
|
||||
c->Message(Chat::White, "Usage: #interrogateinv [log] [silent]");
|
||||
c->Message(
|
||||
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;
|
||||
c->Message(Chat::White, "Usage: #interrogateinv [log] [silent]");
|
||||
c->Message(
|
||||
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");
|
||||
}
|
||||
|
||||
Client *target = nullptr;
|
||||
@@ -38,33 +31,20 @@ void command_interrogateinv(Client *c, const Seperator *sep)
|
||||
bool error = false;
|
||||
bool allowtrip = false;
|
||||
|
||||
if (c->Admin() < commandInterrogateInv) {
|
||||
if (c->GetInterrogateInvState()) {
|
||||
c->Message(Chat::Red, "The last use of #interrogateinv on this inventory instance discovered an error...");
|
||||
c->Message(Chat::Red, "Logging out, zoning or re-arranging items at this point will result in item loss!");
|
||||
return;
|
||||
}
|
||||
target = c;
|
||||
allowtrip = true;
|
||||
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;
|
||||
}
|
||||
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) {
|
||||
log = true;
|
||||
}
|
||||
if (strcasecmp(sep->arg[2], "silent") == 0) {
|
||||
silent = true;
|
||||
}
|
||||
if (strcasecmp(sep->arg[1], "log") == 0) {
|
||||
log = true;
|
||||
}
|
||||
if (strcasecmp(sep->arg[2], "silent") == 0) {
|
||||
silent = true;
|
||||
}
|
||||
|
||||
bool success = target->InterrogateInventory(c, log, silent, allowtrip, error);
|
||||
|
||||
+278
-297
@@ -27,50 +27,48 @@ void command_invsnapshot(Client *c, const Seperator *sep)
|
||||
"<td><c \"#AAAAAA\">takes snapshot of character inventory</td>"
|
||||
"</tr>";
|
||||
|
||||
if (c->Admin() >= commandInvSnapshot) {
|
||||
window_text.append(
|
||||
"<tr>"
|
||||
"<td><c \"#00FF00\">gcount</td>"
|
||||
"<td></td>"
|
||||
"<td><c \"#AAAAAA\">returns global snapshot count</td>"
|
||||
"</tr>"
|
||||
"<tr>"
|
||||
"<td><c \"#00FF00\">gclear</td>"
|
||||
"<td><c \"#FFFF00\"><br>now</td>"
|
||||
"<td><c \"#AAAAAA\">delete all snapshots - rule<br>delete all snapshots - now</td>"
|
||||
"</tr>"
|
||||
"<tr>"
|
||||
"<td><c \"#00FF00\">count</td>"
|
||||
"<td></td>"
|
||||
"<td><c \"#AAAAAA\">returns character snapshot count</td>"
|
||||
"</tr>"
|
||||
"<tr>"
|
||||
"<td><c \"#00FF00\">clear</td>"
|
||||
"<td><c \"#FFFF00\"><br>now</td>"
|
||||
"<td><c \"#AAAAAA\">delete character snapshots - rule<br>delete character snapshots - now</td>"
|
||||
"</tr>"
|
||||
"<tr>"
|
||||
"<td><c \"#00FF00\">list</td>"
|
||||
"<td><br><c \"#FFFF00\">count</td>"
|
||||
"<td><c \"#AAAAAA\">lists entry ids for current character<br>limits to count</td>"
|
||||
"</tr>"
|
||||
"<tr>"
|
||||
"<td><c \"#00FF00\">parse</td>"
|
||||
"<td><c \"#00FF00\">tstmp</td>"
|
||||
"<td><c \"#AAAAAA\">displays slots and items in snapshot</td>"
|
||||
"</tr>"
|
||||
"<tr>"
|
||||
"<td><c \"#00FF00\">compare</td>"
|
||||
"<td><c \"#00FF00\">tstmp</td>"
|
||||
"<td><c \"#AAAAAA\">compares inventory against snapshot</td>"
|
||||
"</tr>"
|
||||
"<tr>"
|
||||
"<td><c \"#00FF00\">restore</td>"
|
||||
"<td><c \"#00FF00\">tstmp</td>"
|
||||
"<td><c \"#AAAAAA\">restores slots and items in snapshot</td>"
|
||||
"</tr>"
|
||||
);
|
||||
}
|
||||
window_text.append(
|
||||
"<tr>"
|
||||
"<td><c \"#00FF00\">gcount</td>"
|
||||
"<td></td>"
|
||||
"<td><c \"#AAAAAA\">returns global snapshot count</td>"
|
||||
"</tr>"
|
||||
"<tr>"
|
||||
"<td><c \"#00FF00\">gclear</td>"
|
||||
"<td><c \"#FFFF00\"><br>now</td>"
|
||||
"<td><c \"#AAAAAA\">delete all snapshots - rule<br>delete all snapshots - now</td>"
|
||||
"</tr>"
|
||||
"<tr>"
|
||||
"<td><c \"#00FF00\">count</td>"
|
||||
"<td></td>"
|
||||
"<td><c \"#AAAAAA\">returns character snapshot count</td>"
|
||||
"</tr>"
|
||||
"<tr>"
|
||||
"<td><c \"#00FF00\">clear</td>"
|
||||
"<td><c \"#FFFF00\"><br>now</td>"
|
||||
"<td><c \"#AAAAAA\">delete character snapshots - rule<br>delete character snapshots - now</td>"
|
||||
"</tr>"
|
||||
"<tr>"
|
||||
"<td><c \"#00FF00\">list</td>"
|
||||
"<td><br><c \"#FFFF00\">count</td>"
|
||||
"<td><c \"#AAAAAA\">lists entry ids for current character<br>limits to count</td>"
|
||||
"</tr>"
|
||||
"<tr>"
|
||||
"<td><c \"#00FF00\">parse</td>"
|
||||
"<td><c \"#00FF00\">tstmp</td>"
|
||||
"<td><c \"#AAAAAA\">displays slots and items in snapshot</td>"
|
||||
"</tr>"
|
||||
"<tr>"
|
||||
"<td><c \"#00FF00\">compare</td>"
|
||||
"<td><c \"#00FF00\">tstmp</td>"
|
||||
"<td><c \"#AAAAAA\">compares inventory against snapshot</td>"
|
||||
"</tr>"
|
||||
"<tr>"
|
||||
"<td><c \"#00FF00\">restore</td>"
|
||||
"<td><c \"#00FF00\">tstmp</td>"
|
||||
"<td><c \"#AAAAAA\">restores slots and items in snapshot</td>"
|
||||
"</tr>"
|
||||
);
|
||||
|
||||
window_text.append(
|
||||
"</table>"
|
||||
@@ -81,34 +79,30 @@ void command_invsnapshot(Client *c, const Seperator *sep)
|
||||
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) {
|
||||
auto is_count = database.CountInvSnapshots();
|
||||
return;
|
||||
}
|
||||
|
||||
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(
|
||||
Chat::White,
|
||||
"There %s %i inventory snapshot%s.",
|
||||
(is_count == 1 ? "is" : "are"),
|
||||
is_count,
|
||||
(is_count == 1 ? "" : "s"));
|
||||
|
||||
return;
|
||||
Chat::White, "Inventory snapshots cleared using RuleI(Character, InvSnapshotHistoryD) (%i day%s).",
|
||||
RuleI(Character, InvSnapshotHistoryD), (RuleI(Character, InvSnapshotHistoryD) == 1 ? "" : "s"));
|
||||
}
|
||||
|
||||
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(
|
||||
Chat::White, "Inventory snapshots cleared using RuleI(Character, InvSnapshotHistoryD) (%i day%s).",
|
||||
RuleI(Character, InvSnapshotHistoryD), (RuleI(Character, InvSnapshotHistoryD) == 1 ? "" : "s"));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!c->GetTarget() || !c->GetTarget()->IsClient()) {
|
||||
@@ -127,8 +121,7 @@ void command_invsnapshot(Client *c, const Seperator *sep)
|
||||
tc->GetName(),
|
||||
RuleI(Character, InvSnapshotMinIntervalM),
|
||||
(RuleI(Character, InvSnapshotMinIntervalM) == 1 ? "" : "s"));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
tc->SetNextInvSnapshot(RuleI(Character, InvSnapshotMinRetryM));
|
||||
c->Message(
|
||||
Chat::White,
|
||||
@@ -141,278 +134,266 @@ void command_invsnapshot(Client *c, const Seperator *sep)
|
||||
return;
|
||||
}
|
||||
|
||||
if (c->Admin() >= commandInvSnapshot) {
|
||||
if (strcmp(sep->arg[1], "count") == 0) {
|
||||
auto is_count = database.CountCharacterInvSnapshots(tc->CharacterID());
|
||||
if (strcmp(sep->arg[1], "count") == 0) {
|
||||
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(
|
||||
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->CharacterID(),
|
||||
is_count,
|
||||
(is_count == 1 ? "" : "s"));
|
||||
RuleI(Character, InvSnapshotHistoryD),
|
||||
(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;
|
||||
}
|
||||
|
||||
if (strcmp(sep->arg[1], "clear") == 0) {
|
||||
if (strcmp(sep->arg[2], "now") == 0) {
|
||||
database.ClearCharacterInvSnapshots(tc->CharacterID(), true);
|
||||
c->Message(
|
||||
Chat::White,
|
||||
"%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->CharacterID(),
|
||||
RuleI(Character, InvSnapshotHistoryD),
|
||||
(RuleI(Character, InvSnapshotHistoryD) == 1 ? "" : "s"));
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
if (strcmp(sep->arg[1], "list") == 0) {
|
||||
std::list<std::pair<uint32, int>> is_list;
|
||||
database.ListCharacterInvSnapshots(tc->CharacterID(), is_list);
|
||||
std::string window_title = StringFormat("Snapshots for %s", tc->GetName());
|
||||
|
||||
if (is_list.empty()) {
|
||||
c->Message(Chat::White, "No inventory snapshots for %s (id: %u)", tc->GetName(), tc->CharacterID());
|
||||
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(
|
||||
std::string window_text =
|
||||
"<table>"
|
||||
"<tr>"
|
||||
"<td>%u</td>"
|
||||
"<td>%i</td>"
|
||||
"</tr>",
|
||||
iter.first,
|
||||
iter.second
|
||||
));
|
||||
"<td>Timestamp</td>"
|
||||
"<td>Entry Count</td>"
|
||||
"</tr>";
|
||||
|
||||
--list_count;
|
||||
for (auto iter: is_list) {
|
||||
if (!list_count) {
|
||||
break;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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>",
|
||||
StringFormat(
|
||||
"<tr>"
|
||||
"<td>%u</td>"
|
||||
"<td>%i</td>"
|
||||
"</tr>",
|
||||
iter.first,
|
||||
iter.second,
|
||||
(item_data ? item_data->Name : "[error]"));
|
||||
iter.second
|
||||
));
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
--list_count;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
if (strcmp(sep->arg[1], "compare") == 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.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)) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
"No inventory snapshots for %s (id: %u) exist at %u.",
|
||||
tc->GetName(),
|
||||
tc->CharacterID(),
|
||||
timestamp
|
||||
);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
std::list<std::pair<int16, uint32>> inv_compare_list;
|
||||
database.DivergeCharacterInventoryFromInvSnapshot(tc->CharacterID(), timestamp, inv_compare_list);
|
||||
if (strcmp(sep->arg[1], "compare") == 0) {
|
||||
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;
|
||||
database.DivergeCharacterInvSnapshotFromInventory(tc->CharacterID(), timestamp, iss_compare_list);
|
||||
uint32 timestamp = Strings::ToUnsignedInt(sep->arg[2]);
|
||||
|
||||
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 -> 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();
|
||||
auto iss_iter = iss_compare_list.begin();
|
||||
std::list<std::pair<int16, uint32>> iss_compare_list;
|
||||
database.DivergeCharacterInvSnapshotFromInventory(tc->CharacterID(), timestamp, iss_compare_list);
|
||||
|
||||
while (true) {
|
||||
std::string window_line;
|
||||
std::string window_title = StringFormat("Snapshot Comparison for %s @ %u", tc->GetName(), timestamp);
|
||||
|
||||
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] -> %u<br>", inv_iter->first, inv_iter->second);
|
||||
std::string window_text = "Slot: (action) Snapshot -> Inventory<br>";
|
||||
|
||||
auto inv_iter = inv_compare_list.begin();
|
||||
auto iss_iter = iss_compare_list.begin();
|
||||
|
||||
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] -> %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 -> [empty]<br>", iss_iter->first, iss_iter->second);
|
||||
++iss_iter;
|
||||
} else {
|
||||
if (inv_iter->first < iss_iter->first) {
|
||||
window_line = StringFormat(
|
||||
"%i: (delete) [empty] -> %u<br>",
|
||||
inv_iter->first,
|
||||
inv_iter->second
|
||||
);
|
||||
++inv_iter;
|
||||
} else if (inv_iter->first > iss_iter->first) {
|
||||
window_line = StringFormat(
|
||||
"%i: (insert) %u -> [empty]<br>",
|
||||
iss_iter->first,
|
||||
iss_iter->second
|
||||
);
|
||||
++iss_iter;
|
||||
} else {
|
||||
window_line = StringFormat(
|
||||
"%i: (replace) %u -> %u<br>",
|
||||
iss_iter->first,
|
||||
iss_iter->second,
|
||||
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 -> [empty]<br>", iss_iter->first, iss_iter->second);
|
||||
++iss_iter;
|
||||
}
|
||||
else {
|
||||
if (inv_iter->first < iss_iter->first) {
|
||||
window_line = StringFormat(
|
||||
"%i: (delete) [empty] -> %u<br>",
|
||||
inv_iter->first,
|
||||
inv_iter->second
|
||||
);
|
||||
++inv_iter;
|
||||
}
|
||||
else if (inv_iter->first > iss_iter->first) {
|
||||
window_line = StringFormat(
|
||||
"%i: (insert) %u -> [empty]<br>",
|
||||
iss_iter->first,
|
||||
iss_iter->second
|
||||
);
|
||||
++iss_iter;
|
||||
}
|
||||
else {
|
||||
window_line = StringFormat(
|
||||
"%i: (replace) %u -> %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;
|
||||
}
|
||||
|
||||
if (strcmp(sep->arg[1], "restore") == 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;
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
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());
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,18 +2,18 @@
|
||||
|
||||
void command_movechar(Client *c, const Seperator *sep)
|
||||
{
|
||||
int arguments = sep->argnum;
|
||||
const int arguments = sep->argnum;
|
||||
if (arguments < 2) {
|
||||
c->Message(Chat::White, "Usage: #movechar [Character ID|Character Name] [Zone ID|Zone Short Name]");
|
||||
return;
|
||||
}
|
||||
|
||||
std::string character_name = (
|
||||
const std::string &character_name = (
|
||||
sep->IsNumber(1) ?
|
||||
database.GetCharNameByID(Strings::ToUnsignedInt(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) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
@@ -25,15 +25,15 @@ void command_movechar(Client *c, const Seperator *sep)
|
||||
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) ?
|
||||
ZoneName(Strings::ToUnsignedInt(sep->arg[2]), true) :
|
||||
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) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
@@ -45,63 +45,34 @@ void command_movechar(Client *c, const Seperator *sep)
|
||||
return;
|
||||
}
|
||||
|
||||
auto zone_id = ZoneID(zone_short_name);
|
||||
auto z = GetZone(zone_id);
|
||||
const uint32 zone_id = ZoneID(zone_short_name);
|
||||
auto z = GetZone(zone_id);
|
||||
|
||||
if (!z) {
|
||||
c->Message(Chat::Red, "Invalid zone.");
|
||||
return;
|
||||
}
|
||||
|
||||
bool is_special_zone = (
|
||||
zone_short_name.find("cshome") != std::string::npos ||
|
||||
zone_short_name.find("load") != std::string::npos ||
|
||||
zone_short_name.find("load2") != std::string::npos
|
||||
const 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()
|
||||
);
|
||||
|
||||
if (c->Admin() < commandMovecharToSpecials && is_special_zone) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"{} ({}) is a special zone and you cannot move someone there.",
|
||||
z->long_name,
|
||||
zone_short_name
|
||||
).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.");
|
||||
}
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Character Move {} | Zone: {} ({}) ID: {}",
|
||||
moved_string,
|
||||
z->long_name,
|
||||
zone_short_name,
|
||||
zone_id
|
||||
).c_str()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,13 +2,8 @@
|
||||
|
||||
void ShowFlags(Client *c, const Seperator *sep)
|
||||
{
|
||||
auto t = c;
|
||||
|
||||
if (
|
||||
c->GetTarget() &&
|
||||
c->GetTarget()->IsClient() &&
|
||||
c->Admin() >= minStatusToSeeOthersZoneFlags
|
||||
) {
|
||||
Client *t = c;
|
||||
if (c->GetTarget() && c->GetTarget()->IsClient()) {
|
||||
t = c->GetTarget()->CastToClient();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,12 +2,8 @@
|
||||
|
||||
void ShowPEQZoneFlags(Client *c, const Seperator *sep)
|
||||
{
|
||||
auto t = c;
|
||||
if (
|
||||
c->GetTarget() &&
|
||||
c->GetTarget()->IsClient() &&
|
||||
c->Admin() >= minStatusToSeeOthersZoneFlags
|
||||
) {
|
||||
Client *t = c;
|
||||
if (c->GetTarget() && c->GetTarget()->IsClient()) {
|
||||
t = c->GetTarget()->CastToClient();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user