[Cleanup] Cleanup Object Type Code (#4375)

* [Cleanup] Cleanup Object Type Code

* Move to object.cpp/object.h
This commit is contained in:
Alex King 2024-06-14 12:58:59 -04:00 committed by GitHub
parent 9cebba5911
commit 0b2493beb8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 211 additions and 147 deletions

View File

@ -296,84 +296,6 @@ std::string EQ::constants::GetSpawnAnimationName(uint8 animation_id)
return EQ::constants::GetSpawnAnimationMap().find(animation_id)->second; return EQ::constants::GetSpawnAnimationMap().find(animation_id)->second;
} }
const std::map<int, std::string>& EQ::constants::GetObjectTypeMap()
{
static const std::map<int, std::string> object_type_map = {
{ ObjectTypes::SmallBag, "Small Bag" },
{ ObjectTypes::LargeBag, "Large Bag" },
{ ObjectTypes::Quiver, "Quiver" },
{ ObjectTypes::BeltPouch, "Belt Pouch" },
{ ObjectTypes::WristPouch, "Wrist Pouch" },
{ ObjectTypes::Backpack, "Backpack" },
{ ObjectTypes::SmallChest, "Small Chest" },
{ ObjectTypes::LargeChest, "Large Chest" },
{ ObjectTypes::Bandolier, "Bandolier" },
{ ObjectTypes::Medicine, "Medicine" },
{ ObjectTypes::Tinkering, "Tinkering" },
{ ObjectTypes::Lexicon, "Lexicon" },
{ ObjectTypes::PoisonMaking, "Mortar and Pestle" },
{ ObjectTypes::Quest, "Quest" },
{ ObjectTypes::MixingBowl, "Mixing Bowl" },
{ ObjectTypes::Baking, "Baking" },
{ ObjectTypes::Tailoring, "Tailoring" },
{ ObjectTypes::Blacksmithing, "Blacksmithing" },
{ ObjectTypes::Fletching, "Fletching" },
{ ObjectTypes::Brewing, "Brewing" },
{ ObjectTypes::JewelryMaking, "Jewelry Making" },
{ ObjectTypes::Pottery, "Pottery" },
{ ObjectTypes::Kiln, "Kiln" },
{ ObjectTypes::KeyMaker, "Key Maker" },
{ ObjectTypes::ResearchWIZ, "Lexicon" },
{ ObjectTypes::ResearchMAG, "Lexicon" },
{ ObjectTypes::ResearchNEC, "Lexicon" },
{ ObjectTypes::ResearchENC, "Lexicon" },
{ ObjectTypes::Unknown, "Unknown" },
{ ObjectTypes::ResearchPractice, "Lexicon" },
{ ObjectTypes::Alchemy, "Alchemy" },
{ ObjectTypes::HighElfForge, "High Elf Forge" },
{ ObjectTypes::DarkElfForge, "Dark Elf Forge" },
{ ObjectTypes::OgreForge, "Ogre Forge" },
{ ObjectTypes::DwarfForge, "Dwarf Forge" },
{ ObjectTypes::GnomeForge, "Gnome Forge" },
{ ObjectTypes::BarbarianForge, "Barbarian Forge" },
{ ObjectTypes::IksarForge, "Iksar Forge" },
{ ObjectTypes::HumanForgeOne, "Human Forge" },
{ ObjectTypes::HumanForgeTwo, "Human Forge" },
{ ObjectTypes::HalflingTailoringOne, "Halfling Tailoring" },
{ ObjectTypes::HalflingTailoringTwo, "Halfling Tailoring" },
{ ObjectTypes::EruditeTailoring, "Erudite Tailoring" },
{ ObjectTypes::WoodElfTailoring, "Wood Elf Tailoring" },
{ ObjectTypes::WoodElfFletching, "Wood Elf Fletching" },
{ ObjectTypes::IksarPottery, "Iksar Pottery" },
{ ObjectTypes::Fishing, "Fishing" },
{ ObjectTypes::TrollForge, "Troll Forge" },
{ ObjectTypes::WoodElfForge, "Wood Elf Forge" },
{ ObjectTypes::HalflingForge, "Halfling Forge" },
{ ObjectTypes::EruditeForge, "Erudite Forge" },
{ ObjectTypes::Merchant, "Merchant" },
{ ObjectTypes::FroglokForge, "Froglok Forge" },
{ ObjectTypes::Augmenter, "Augmenter" },
{ ObjectTypes::Churn, "Churn" },
{ ObjectTypes::TransformationMold, "Transformation Mold" },
{ ObjectTypes::DetransformationMold, "Detransformation Mold" },
{ ObjectTypes::Unattuner, "Unattuner" },
{ ObjectTypes::TradeskillBag, "Tradeskill Bag" },
{ ObjectTypes::CollectibleBag, "Collectible Bag" },
{ ObjectTypes::NoDeposit, "No Deposit" }
};
return object_type_map;
}
std::string EQ::constants::GetObjectTypeName(int object_type)
{
if (!EQ::ValueWithin(object_type, ObjectTypes::SmallBag, ObjectTypes::NoDeposit)) {
return std::string();
}
return EQ::constants::GetObjectTypeMap().find(object_type)->second;
}
const std::map<uint8, std::string> &EQ::constants::GetWeatherTypeMap() const std::map<uint8, std::string> &EQ::constants::GetWeatherTypeMap()
{ {
static const std::map<uint8, std::string> weather_type_map = { static const std::map<uint8, std::string> weather_type_map = {

View File

@ -337,70 +337,6 @@ namespace EQ
Looting Looting
}; };
enum ObjectTypes : int {
SmallBag,
LargeBag,
Quiver,
BeltPouch,
WristPouch,
Backpack,
SmallChest,
LargeChest,
Bandolier,
Medicine,
Tinkering,
Lexicon,
PoisonMaking,
Quest,
MixingBowl,
Baking,
Tailoring,
Blacksmithing,
Fletching,
Brewing,
JewelryMaking,
Pottery,
Kiln,
KeyMaker,
ResearchWIZ,
ResearchMAG,
ResearchNEC,
ResearchENC,
Unknown,
ResearchPractice,
Alchemy,
HighElfForge,
DarkElfForge,
OgreForge,
DwarfForge,
GnomeForge,
BarbarianForge,
IksarForge,
HumanForgeOne,
HumanForgeTwo,
HalflingTailoringOne,
HalflingTailoringTwo,
EruditeTailoring,
WoodElfTailoring,
WoodElfFletching,
IksarPottery,
Fishing,
TrollForge,
WoodElfForge,
HalflingForge,
EruditeForge,
Merchant,
FroglokForge,
Augmenter,
Churn,
TransformationMold,
DetransformationMold,
Unattuner,
TradeskillBag,
CollectibleBag,
NoDeposit
};
enum WeatherTypes : uint8 { enum WeatherTypes : uint8 {
None, None,
Raining, Raining,
@ -453,9 +389,6 @@ namespace EQ
extern const std::map<uint8, std::string>& GetSpawnAnimationMap(); extern const std::map<uint8, std::string>& GetSpawnAnimationMap();
std::string GetSpawnAnimationName(uint8 animation_id); std::string GetSpawnAnimationName(uint8 animation_id);
extern const std::map<int, std::string>& GetObjectTypeMap();
std::string GetObjectTypeName(int object_type);
extern const std::map<uint8, std::string>& GetWeatherTypeMap(); extern const std::map<uint8, std::string>& GetWeatherTypeMap();
std::string GetWeatherTypeName(uint8 weather_type); std::string GetWeatherTypeName(uint8 weather_type);

View File

@ -61,6 +61,7 @@ public:
{.parent_command = "find", .sub_command = "item", .access_level = AccountStatus::QuestTroupe, .top_level_aliases = "fi|finditem|itemsearch"}, {.parent_command = "find", .sub_command = "item", .access_level = AccountStatus::QuestTroupe, .top_level_aliases = "fi|finditem|itemsearch"},
{.parent_command = "find", .sub_command = "language", .access_level = AccountStatus::QuestTroupe, .top_level_aliases = "findlanguage"}, {.parent_command = "find", .sub_command = "language", .access_level = AccountStatus::QuestTroupe, .top_level_aliases = "findlanguage"},
{.parent_command = "find", .sub_command = "npc_type", .access_level = AccountStatus::QuestTroupe, .top_level_aliases = "fn|findnpc|findnpctype"}, {.parent_command = "find", .sub_command = "npc_type", .access_level = AccountStatus::QuestTroupe, .top_level_aliases = "fn|findnpc|findnpctype"},
{.parent_command = "find", .sub_command = "object_type", .access_level = AccountStatus::QuestTroupe, .top_level_aliases = "findobjecttype"},
{.parent_command = "find", .sub_command = "race", .access_level = AccountStatus::QuestTroupe, .top_level_aliases = "findrace"}, {.parent_command = "find", .sub_command = "race", .access_level = AccountStatus::QuestTroupe, .top_level_aliases = "findrace"},
{.parent_command = "find", .sub_command = "recipe", .access_level = AccountStatus::QuestTroupe, .top_level_aliases = "findrecipe"}, {.parent_command = "find", .sub_command = "recipe", .access_level = AccountStatus::QuestTroupe, .top_level_aliases = "findrecipe"},
{.parent_command = "find", .sub_command = "skill", .access_level = AccountStatus::QuestTroupe, .top_level_aliases = "findskill"}, {.parent_command = "find", .sub_command = "skill", .access_level = AccountStatus::QuestTroupe, .top_level_aliases = "findskill"},

View File

@ -12,6 +12,7 @@
#include "find/item.cpp" #include "find/item.cpp"
#include "find/language.cpp" #include "find/language.cpp"
#include "find/npctype.cpp" #include "find/npctype.cpp"
#include "find/object_type.cpp"
#include "find/race.cpp" #include "find/race.cpp"
#include "find/recipe.cpp" #include "find/recipe.cpp"
#include "find/skill.cpp" #include "find/skill.cpp"
@ -52,6 +53,7 @@ void command_find(Client *c, const Seperator *sep)
"#findnpctype" "#findnpctype"
} }
}, },
Cmd{.cmd = "object_type", .u = "object_type [Search Criteria]", .fn = FindObjectType, .a = {"#findobjecttype"}},
Cmd{.cmd = "race", .u = "race [Search Criteria]", .fn = FindRace, .a = {"#findrace"}}, Cmd{.cmd = "race", .u = "race [Search Criteria]", .fn = FindRace, .a = {"#findrace"}},
Cmd{.cmd = "recipe", .u = "recipe [Search Criteria]", .fn = FindRecipe, .a = {"#findrecipe"}}, Cmd{.cmd = "recipe", .u = "recipe [Search Criteria]", .fn = FindRecipe, .a = {"#findrecipe"}},
Cmd{.cmd = "skill", .u = "skill [Search Criteria]", .fn = FindSkill, .a = {"#findskill"}}, Cmd{.cmd = "skill", .u = "skill [Search Criteria]", .fn = FindSkill, .a = {"#findskill"}},

View File

@ -0,0 +1,65 @@
#include "../../client.h"
void FindObjectType(Client *c, const Seperator *sep)
{
if (sep->IsNumber(2)) {
const uint32 object_type = Strings::ToUnsignedInt(sep->arg[2]);
const std::string& object_type_name = ObjectType::GetName(object_type);
if (Strings::EqualFold(object_type_name, "UNKNOWN OBJECT TYPE")) {
c->Message(
Chat::White,
fmt::format(
"Object Type {} does not exist.",
object_type
).c_str()
);
return;
}
c->Message(
Chat::White,
fmt::format(
"Object Type {} | {}",
object_type,
ObjectType::GetName(object_type)
).c_str()
);
return;
}
const std::string& search_criteria = Strings::ToLower(sep->argplus[2]);
uint32 found_count = 0;
for (const auto& e : object_types) {
const std::string& object_type_name_lower = Strings::ToLower(e.second);
if (!Strings::Contains(object_type_name_lower, search_criteria)) {
continue;
}
c->Message(
Chat::White,
fmt::format(
"Object Type {} | {}",
e.first,
e.second
).c_str()
);
found_count++;
}
c->Message(
Chat::White,
fmt::format(
"{} Object Type{} found matching '{}'.",
found_count,
found_count != 1 ? "s" : "",
sep->argplus[2]
).c_str()
);
}

View File

@ -54,8 +54,8 @@ void ShowRecipe(Client *c, const Seperator *sep)
e.iscontainer > 0 ? " (Container)" : "", e.iscontainer > 0 ? " (Container)" : "",
( (
e.item_id > 1000 ? e.item_id > 1000 ?
database.CreateItemLink(e.item_id) : database.CreateItemLink(static_cast<uint32>(e.item_id)) :
EQ::constants::GetObjectTypeName(e.item_id) ObjectType::GetName(static_cast<uint32>(e.item_id))
), ),
( (
can_summon_items && e.item_id > 1000 ? can_summon_items && e.item_id > 1000 ?

View File

@ -1293,3 +1293,13 @@ void Object::FixZ()
} }
} }
} }
std::string ObjectType::GetName(uint32 object_type)
{
return IsValid(object_type) ? object_types[object_type] : "UNKNOWN OBJECT TYPE";
}
bool ObjectType::IsValid(uint32 object_type)
{
return object_types.find(object_type) != object_types.end();
}

View File

@ -250,4 +250,135 @@ protected:
void FixZ(); void FixZ();
}; };
namespace ObjectType {
constexpr uint32 SmallBag = 0;
constexpr uint32 LargeBag = 1;
constexpr uint32 Quiver = 2;
constexpr uint32 BeltPouch = 3;
constexpr uint32 WristPouch = 4;
constexpr uint32 Backpack = 5;
constexpr uint32 SmallChest = 6;
constexpr uint32 LargeChest = 7;
constexpr uint32 Bandolier = 8;
constexpr uint32 Medicine = 9;
constexpr uint32 Tinkering = 10;
constexpr uint32 Lexicon = 11;
constexpr uint32 PoisonMaking = 12;
constexpr uint32 Quest = 13;
constexpr uint32 MixingBowl = 14;
constexpr uint32 Baking = 15;
constexpr uint32 Tailoring = 16;
constexpr uint32 Blacksmithing = 17;
constexpr uint32 Fletching = 18;
constexpr uint32 Brewing = 19;
constexpr uint32 JewelryMaking = 20;
constexpr uint32 Pottery = 21;
constexpr uint32 Kiln = 22;
constexpr uint32 KeyMaker = 23;
constexpr uint32 ResearchWIZ = 24;
constexpr uint32 ResearchMAG = 25;
constexpr uint32 ResearchNEC = 26;
constexpr uint32 ResearchENC = 27;
constexpr uint32 Unknown = 28;
constexpr uint32 ResearchPractice = 29;
constexpr uint32 Alchemy = 30;
constexpr uint32 HighElfForge = 31;
constexpr uint32 DarkElfForge = 32;
constexpr uint32 OgreForge = 33;
constexpr uint32 DwarfForge = 34;
constexpr uint32 GnomeForge = 35;
constexpr uint32 BarbarianForge = 36;
constexpr uint32 IksarForge = 37;
constexpr uint32 HumanForgeOne = 38;
constexpr uint32 HumanForgeTwo = 39;
constexpr uint32 HalflingTailoringOne = 40;
constexpr uint32 HalflingTailoringTwo = 41;
constexpr uint32 EruditeTailoring = 42;
constexpr uint32 WoodElfTailoring = 43;
constexpr uint32 WoodElfFletching = 44;
constexpr uint32 IksarPottery = 45;
constexpr uint32 Fishing = 46;
constexpr uint32 TrollForge = 47;
constexpr uint32 WoodElfForge = 48;
constexpr uint32 HalflingForge = 49;
constexpr uint32 EruditeForge = 50;
constexpr uint32 Merchant = 51;
constexpr uint32 FroglokForge = 52;
constexpr uint32 Augmenter = 53;
constexpr uint32 Churn = 54;
constexpr uint32 TransformationMold = 55;
constexpr uint32 DetransformationMold = 56;
constexpr uint32 Unattuner = 57;
constexpr uint32 TradeskillBag = 58;
constexpr uint32 CollectibleBag = 59;
constexpr uint32 NoDeposit = 60;
std::string GetName(uint32 object_type);
bool IsValid(uint32 object_type);
}
static std::map<uint32, std::string> object_types = {
{ ObjectType::SmallBag, "Small Bag" },
{ ObjectType::LargeBag, "Large Bag" },
{ ObjectType::Quiver, "Quiver" },
{ ObjectType::BeltPouch, "Belt Pouch" },
{ ObjectType::WristPouch, "Wrist Pouch" },
{ ObjectType::Backpack, "Backpack" },
{ ObjectType::SmallChest, "Small Chest" },
{ ObjectType::LargeChest, "Large Chest" },
{ ObjectType::Bandolier, "Bandolier" },
{ ObjectType::Medicine, "Medicine" },
{ ObjectType::Tinkering, "Tinkering" },
{ ObjectType::Lexicon, "Lexicon" },
{ ObjectType::PoisonMaking, "Mortar and Pestle" },
{ ObjectType::Quest, "Quest" },
{ ObjectType::MixingBowl, "Mixing Bowl" },
{ ObjectType::Baking, "Baking" },
{ ObjectType::Tailoring, "Tailoring" },
{ ObjectType::Blacksmithing, "Blacksmithing" },
{ ObjectType::Fletching, "Fletching" },
{ ObjectType::Brewing, "Brewing" },
{ ObjectType::JewelryMaking, "Jewelry Making" },
{ ObjectType::Pottery, "Pottery" },
{ ObjectType::Kiln, "Kiln" },
{ ObjectType::KeyMaker, "Key Maker" },
{ ObjectType::ResearchWIZ, "Lexicon" },
{ ObjectType::ResearchMAG, "Lexicon" },
{ ObjectType::ResearchNEC, "Lexicon" },
{ ObjectType::ResearchENC, "Lexicon" },
{ ObjectType::Unknown, "Unknown" },
{ ObjectType::ResearchPractice, "Lexicon" },
{ ObjectType::Alchemy, "Alchemy" },
{ ObjectType::HighElfForge, "High Elf Forge" },
{ ObjectType::DarkElfForge, "Dark Elf Forge" },
{ ObjectType::OgreForge, "Ogre Forge" },
{ ObjectType::DwarfForge, "Dwarf Forge" },
{ ObjectType::GnomeForge, "Gnome Forge" },
{ ObjectType::BarbarianForge, "Barbarian Forge" },
{ ObjectType::IksarForge, "Iksar Forge" },
{ ObjectType::HumanForgeOne, "Human Forge" },
{ ObjectType::HumanForgeTwo, "Human Forge" },
{ ObjectType::HalflingTailoringOne, "Halfling Tailoring" },
{ ObjectType::HalflingTailoringTwo, "Halfling Tailoring" },
{ ObjectType::EruditeTailoring, "Erudite Tailoring" },
{ ObjectType::WoodElfTailoring, "Wood Elf Tailoring" },
{ ObjectType::WoodElfFletching, "Wood Elf Fletching" },
{ ObjectType::IksarPottery, "Iksar Pottery" },
{ ObjectType::Fishing, "Fishing" },
{ ObjectType::TrollForge, "Troll Forge" },
{ ObjectType::WoodElfForge, "Wood Elf Forge" },
{ ObjectType::HalflingForge, "Halfling Forge" },
{ ObjectType::EruditeForge, "Erudite Forge" },
{ ObjectType::Merchant, "Merchant" },
{ ObjectType::FroglokForge, "Froglok Forge" },
{ ObjectType::Augmenter, "Augmenter" },
{ ObjectType::Churn, "Churn" },
{ ObjectType::TransformationMold, "Transformation Mold" },
{ ObjectType::DetransformationMold, "Detransformation Mold" },
{ ObjectType::Unattuner, "Unattuner" },
{ ObjectType::TradeskillBag, "Tradeskill Bag" },
{ ObjectType::CollectibleBag, "Collectible Bag" },
{ ObjectType::NoDeposit, "No Deposit" }
};
#endif #endif