Caps the item and mob display name length (#6293)

* Resolves an issue of trying to create an item or mob whose name was over the cap limit.
* Display a warning now when the length is over the cap.
* Resized the item and monster database values that were over the cap.
Thanks to @Lemongrass3110, @secretdataz, and @Atemo
Co-authored-by: Lemongrass3110 <lemongrass@kstp.at>
This commit is contained in:
Aleos
2021-10-05 23:01:32 -04:00
committed by GitHub
parent e72997e0a6
commit 53e25aa462
7 changed files with 119 additions and 63 deletions

View File

@@ -4304,6 +4304,10 @@ uint64 MobDatabase::parseBodyNode(const YAML::Node &node) {
if (!this->asString(node, "AegisName", name))
return 0;
if (name.length() > NAME_LENGTH) {
this->invalidWarning(node["AegisName"], "AegisName \"%s\" exceeds maximum of %d characters, capping...\n", name.c_str(), NAME_LENGTH - 1);
}
name.resize(NAME_LENGTH);
mob->sprite = name;
}
@@ -4314,6 +4318,10 @@ uint64 MobDatabase::parseBodyNode(const YAML::Node &node) {
if (!this->asString(node, "Name", name))
return 0;
if (name.length() > NAME_LENGTH) {
this->invalidWarning(node["Name"], "Name \"%s\" exceeds maximum of %d characters, capping...\n", name.c_str(), NAME_LENGTH - 1);
}
name.resize(NAME_LENGTH);
mob->name = name;
}
@@ -4324,6 +4332,10 @@ uint64 MobDatabase::parseBodyNode(const YAML::Node &node) {
if (!this->asString(node, "JapaneseName", name))
return 0;
if (name.length() > NAME_LENGTH) {
this->invalidWarning(node["JapaneseName"], "JapaneseName \"%s\" exceeds maximum of %d characters, capping...\n", name.c_str(), NAME_LENGTH - 1);
}
name.resize(NAME_LENGTH);
mob->jname = name;
} else {