Speeded up item name lookup (#6161)

Partial takeover from #5997
Did some further cleanup and took it out of the pull request until secret has time to finish it.

All credits to @secretdataz

Co-authored-by: secretdataz <secretdataz@users.noreply.github.com>
This commit is contained in:
Lemongrass3110
2021-08-08 16:46:44 +02:00
committed by GitHub
parent 666311099e
commit 6b84115790
13 changed files with 253 additions and 169 deletions

View File

@@ -4218,7 +4218,7 @@ bool MobDatabase::parseDropNode(std::string nodeName, YAML::Node node, uint8 max
if (!this->asString(dropit, "Item", item_name))
return false;
item_data *item = itemdb_search_aegisname(item_name.c_str());
std::shared_ptr<item_data> item = item_db.search_aegisname( item_name.c_str() );
if (item == nullptr) {
this->invalidWarning(dropit["Item"], "Monster %s item %s does not exist, skipping.\n", nodeName.c_str(), item_name.c_str());
@@ -5296,7 +5296,7 @@ uint64 MobAvailDatabase::parseBodyNode(const YAML::Node &node) {
if (!this->asString(node, "Weapon", weapon))
return 0;
struct item_data *item = itemdb_search_aegisname(weapon.c_str());
std::shared_ptr<item_data> item = item_db.search_aegisname( weapon.c_str() );
if (item == nullptr) {
this->invalidWarning(node["Weapon"], "Weapon %s is not a valid item.\n", weapon.c_str());
@@ -5317,7 +5317,7 @@ uint64 MobAvailDatabase::parseBodyNode(const YAML::Node &node) {
if (!this->asString(node, "Shield", shield))
return 0;
struct item_data *item = itemdb_search_aegisname(shield.c_str());
std::shared_ptr<item_data> item = item_db.search_aegisname( shield.c_str() );
if (item == nullptr) {
this->invalidWarning(node["Shield"], "Shield %s is not a valid item.\n", shield.c_str());
@@ -5338,9 +5338,9 @@ uint64 MobAvailDatabase::parseBodyNode(const YAML::Node &node) {
if (!this->asString(node, "HeadTop", head))
return 0;
struct item_data *item;
std::shared_ptr<item_data> item = item_db.search_aegisname( head.c_str() );
if ((item = itemdb_search_aegisname(head.c_str())) == nullptr) {
if (item == nullptr) {
this->invalidWarning(node["HeadTop"], "HeadTop %s is not a valid item.\n", head.c_str());
return 0;
}
@@ -5359,7 +5359,7 @@ uint64 MobAvailDatabase::parseBodyNode(const YAML::Node &node) {
if (!this->asString(node, "HeadMid", head))
return 0;
struct item_data *item = itemdb_search_aegisname(head.c_str());
std::shared_ptr<item_data> item = item_db.search_aegisname( head.c_str() );
if (item == nullptr) {
this->invalidWarning(node["HeadMid"], "HeadMid %s is not a valid item.\n", head.c_str());
@@ -5380,7 +5380,7 @@ uint64 MobAvailDatabase::parseBodyNode(const YAML::Node &node) {
if (!this->asString(node, "HeadLow", head))
return 0;
struct item_data *item = itemdb_search_aegisname(head.c_str());
std::shared_ptr<item_data> item = item_db.search_aegisname( head.c_str() );
if (item == nullptr) {
this->invalidWarning(node["HeadLow"], "HeadLow %s is not a valid item.\n", head.c_str());
@@ -5403,7 +5403,7 @@ uint64 MobAvailDatabase::parseBodyNode(const YAML::Node &node) {
if (!this->asString(node, "PetEquip", equipment))
return 0;
struct item_data *item = itemdb_search_aegisname(equipment.c_str());
std::shared_ptr<item_data> item = item_db.search_aegisname( equipment.c_str() );
if (item == nullptr) {
this->invalidWarning(node["PetEquip"], "PetEquip %s is not a valid item.\n", equipment.c_str());