#include "../client.h"
void command_invsnapshot(Client *c, const Seperator *sep)
{
if (!c) {
return;
}
if (sep->argnum == 0 || strcmp(sep->arg[1], "help") == 0) {
std::string window_title = "Inventory Snapshot Argument Help Menu";
std::string window_text =
"
"
""
"| Usage: | "
" | "
"#invsnapshot arguments (required optional) | "
"
"
""
"| help | "
" | "
"this menu | "
"
"
""
"| capture | "
" | "
"takes snapshot of character inventory | "
"
";
window_text.append(
""
"| gcount | "
" | "
"returns global snapshot count | "
"
"
""
"| gclear | "
" now | "
"delete all snapshots - rule delete all snapshots - now | "
"
"
""
"| count | "
" | "
"returns character snapshot count | "
"
"
""
"| clear | "
" now | "
"delete character snapshots - rule delete character snapshots - now | "
"
"
""
"| list | "
" count | "
"lists entry ids for current character limits to count | "
"
"
""
"| parse | "
"tstmp | "
"displays slots and items in snapshot | "
"
"
""
"| compare | "
"tstmp | "
"compares inventory against snapshot | "
"
"
""
"| restore | "
"tstmp | "
"restores slots and items in snapshot | "
"
"
);
window_text.append(
"
"
);
c->SendPopupToClient(window_title.c_str(), window_text.c_str());
return;
}
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"));
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, "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()) {
c->Message(Chat::White, "Target must be a client.");
return;
}
auto tc = (Client *) c->GetTarget();
if (strcmp(sep->arg[1], "capture") == 0) {
if (database.SaveCharacterInvSnapshot(tc->CharacterID())) {
tc->SetNextInvSnapshot(RuleI(Character, InvSnapshotMinIntervalM));
c->Message(
Chat::White,
"Successful inventory snapshot taken of %s - setting next interval for %i minute%s.",
tc->GetName(),
RuleI(Character, InvSnapshotMinIntervalM),
(RuleI(Character, InvSnapshotMinIntervalM) == 1 ? "" : "s"));
} else {
tc->SetNextInvSnapshot(RuleI(Character, InvSnapshotMinRetryM));
c->Message(
Chat::White,
"Failed to take inventory snapshot of %s - retrying in %i minute%s.",
tc->GetName(),
RuleI(Character, InvSnapshotMinRetryM),
(RuleI(Character, InvSnapshotMinRetryM) == 1 ? "" : "s"));
}
return;
}
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\'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;
}
if (strcmp(sep->arg[1], "list") == 0) {
std::list