mirror of
https://github.com/EQEmu/Server.git
synced 2026-04-05 19:32:25 +00:00
- License was intended to be GPLv3 per earlier commit of GPLv3 LICENSE FILE - This is confirmed by the inclusion of libraries that are incompatible with GPLv2 - This is also confirmed by KLS and the agreement of KLS's predecessors - Added GPLv3 license headers to the compilable source files - Removed Folly licensing in strings.h since the string functions do not match the Folly functions and are standard functions - this must have been left over from previous implementations - Removed individual contributor license headers since the project has been under the "developer" mantle for many years - Removed comments on files that were previously automatically generated since they've been manually modified multiple times and there are no automatic scripts referencing them (removed in 2023)
208 lines
5.8 KiB
C++
208 lines
5.8 KiB
C++
/* EQEmu: EQEmulator
|
|
|
|
Copyright (C) 2001-2026 EQEmu Development Team
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
#include "zone/client.h"
|
|
|
|
void command_entityvariable(Client *c, const Seperator *sep)
|
|
{
|
|
const auto arguments = sep->argnum;
|
|
|
|
if (!arguments) {
|
|
c->Message(Chat::White, "Usage: #entityvariable clear - Clear all entity variables on yourself or your target");
|
|
c->Message(Chat::White, "Usage: #entityvariable delete [Variable Name] - Delete an entity variable from yourself or your target");
|
|
c->Message(Chat::White, "Usage: #entityvariable set [Variable Name] [Variable Value] - Set an entity variable for yourself or your target");
|
|
c->Message(Chat::White, "Usage: #entityvariable view [Variable Name] - View an entity variable on yourself or your target");
|
|
c->Message(Chat::White, "Note: You can have spaces in variable names and values by wrapping in double quotes like this");
|
|
c->Message(Chat::White, "Example: #entityvariable set \"Test Variable\" \"Test Value\"");
|
|
c->Message(Chat::White, "Note: Variable Value is optional and can be set to empty by not providing a value");
|
|
return;
|
|
}
|
|
|
|
const bool is_clear = !strcasecmp(sep->arg[1], "clear");
|
|
const bool is_delete = !strcasecmp(sep->arg[1], "delete");
|
|
const bool is_set = !strcasecmp(sep->arg[1], "set");
|
|
const bool is_view = !strcasecmp(sep->arg[1], "view");
|
|
|
|
if (
|
|
!is_clear &&
|
|
!is_delete &&
|
|
!is_set &&
|
|
!is_view
|
|
) {
|
|
c->Message(Chat::White, "Usage: #entityvariable clear - Clear all entity variables on yourself or your target");
|
|
c->Message(Chat::White, "Usage: #entityvariable delete [Variable Name] - Delete an entity variable from yourself or your target");
|
|
c->Message(Chat::White, "Usage: #entityvariable set [Variable Name] [Variable Value] - Set an entity variable for yourself or your target");
|
|
c->Message(Chat::White, "Usage: #entityvariable view [Variable Name] - View an entity variable on yourself or your target");
|
|
c->Message(Chat::White, "Note: You can have spaces in variable names and values by wrapping in double quotes like this");
|
|
c->Message(Chat::White, "Example: #entityvariable set \"Test Variable\" \"Test Value\"");
|
|
c->Message(Chat::White, "Note: Variable Value is optional and can be set to empty by not providing a value");
|
|
return;
|
|
}
|
|
|
|
Mob* t = c;
|
|
if (c->GetTarget()) {
|
|
t = c->GetTarget();
|
|
}
|
|
|
|
if (is_clear) {
|
|
const auto cleared = t->ClearEntityVariables();
|
|
|
|
if (!cleared) {
|
|
c->Message(
|
|
Chat::White,
|
|
fmt::format(
|
|
"{} {} not have any entity variables to clear.",
|
|
c->GetTargetDescription(t, TargetDescriptionType::UCYou),
|
|
c == t ? "do" : "does"
|
|
).c_str()
|
|
);
|
|
|
|
return;
|
|
}
|
|
|
|
c->Message(
|
|
Chat::White,
|
|
fmt::format(
|
|
"Cleared all entity variables for {}.",
|
|
c->GetTargetDescription(t)
|
|
).c_str()
|
|
);
|
|
} else if (is_delete) {
|
|
const std::string variable_name = sep->argplus[2];
|
|
|
|
if (!t->EntityVariableExists(variable_name)) {
|
|
c->Message(
|
|
Chat::White,
|
|
fmt::format(
|
|
"{} {} not have an entity variable named '{}'.",
|
|
c->GetTargetDescription(t, TargetDescriptionType::UCYou),
|
|
c == t ? "do" : "does",
|
|
variable_name
|
|
).c_str()
|
|
);
|
|
|
|
return;
|
|
}
|
|
|
|
t->DeleteEntityVariable(variable_name);
|
|
|
|
c->Message(
|
|
Chat::White,
|
|
fmt::format(
|
|
"Deleted an entity variable named '{}' from {}.",
|
|
variable_name,
|
|
c->GetTargetDescription(t)
|
|
).c_str()
|
|
);
|
|
|
|
return;
|
|
} else if (is_set) {
|
|
const std::string variable_name = sep->arg[2];
|
|
const std::string variable_value = sep->arg[3];
|
|
|
|
t->SetEntityVariable(variable_name, variable_value);
|
|
|
|
c->Message(
|
|
Chat::White,
|
|
fmt::format(
|
|
"Set an entity variable named '{}' to a value of '{}' for {}.",
|
|
variable_name,
|
|
variable_value,
|
|
c->GetTargetDescription(t)
|
|
).c_str()
|
|
);
|
|
} else if (is_view) {
|
|
const auto &l = t->GetEntityVariables();
|
|
|
|
uint32 variable_count = 0;
|
|
uint32 variable_number = 1;
|
|
const std::string search_criteria = arguments ? sep->argplus[2] : "";
|
|
|
|
for (const auto &e: l) {
|
|
if (
|
|
search_criteria.empty() ||
|
|
Strings::Contains(Strings::ToLower(e), Strings::ToLower(search_criteria))
|
|
) {
|
|
c->Message(
|
|
Chat::White,
|
|
fmt::format(
|
|
"Variable {} | Name: {} Value: {} | {}",
|
|
variable_number,
|
|
e,
|
|
t->GetEntityVariable(e),
|
|
Saylink::Silent(
|
|
fmt::format(
|
|
"#entityvariable delete {}",
|
|
e
|
|
),
|
|
"Delete"
|
|
)
|
|
).c_str()
|
|
);
|
|
|
|
variable_count++;
|
|
variable_number++;
|
|
}
|
|
}
|
|
|
|
if (!variable_count) {
|
|
c->Message(
|
|
Chat::White,
|
|
fmt::format(
|
|
"{} {} no entity variables{}.",
|
|
c->GetTargetDescription(t, TargetDescriptionType::UCYou),
|
|
c == t ? "have" : "has",
|
|
(
|
|
!search_criteria.empty() ?
|
|
fmt::format(
|
|
" matching '{}'",
|
|
search_criteria
|
|
) :
|
|
""
|
|
)
|
|
).c_str()
|
|
);
|
|
|
|
return;
|
|
}
|
|
|
|
c->Message(
|
|
Chat::White,
|
|
fmt::format(
|
|
"{} {} {} entity variable{}{}, would you like to {} all of {} entity variables?",
|
|
c->GetTargetDescription(t, TargetDescriptionType::UCYou),
|
|
c == t ? "have" : "has",
|
|
variable_count,
|
|
variable_count != 1 ? "s" : "",
|
|
(
|
|
!search_criteria.empty() ?
|
|
fmt::format(
|
|
" matching '{}'",
|
|
search_criteria
|
|
) :
|
|
""
|
|
),
|
|
Saylink::Silent(
|
|
"#entityvariable clear",
|
|
"clear"
|
|
),
|
|
c == t ? "your" : "their"
|
|
).c_str()
|
|
);
|
|
}
|
|
}
|