diff --git a/common/emu_constants.cpp b/common/emu_constants.cpp index fd4983216..670aeb981 100644 --- a/common/emu_constants.cpp +++ b/common/emu_constants.cpp @@ -140,29 +140,6 @@ std::string EQ::constants::GetLanguageName(uint8 language_id) return EQ::constants::GetLanguageMap().find(language_id)->second; } -const std::map& EQ::constants::GetLDoNThemeMap() -{ - static const std::map ldon_theme_map = { - { LDoNThemes::Unused, "Unused" }, - { LDoNThemes::GUK, "Deepest Guk" }, - { LDoNThemes::MIR, "Miragul's Menagerie" }, - { LDoNThemes::MMC, "Mistmoore Catacombs" }, - { LDoNThemes::RUJ, "Rujarkian Hills" }, - { LDoNThemes::TAK, "Takish-Hiz" }, - }; - - return ldon_theme_map; -} - -std::string EQ::constants::GetLDoNThemeName(uint32 theme_id) -{ - if (!EQ::ValueWithin(theme_id, LDoNThemes::Unused, LDoNThemes::TAK)) { - return std::string(); - } - - return EQ::constants::GetLDoNThemeMap().find(theme_id)->second; -} - const std::map& EQ::constants::GetFlyModeMap() { static const std::map flymode_map = { @@ -459,3 +436,18 @@ bool ComparisonType::IsValid(uint8 type) { return comparison_types.find(type) != comparison_types.end(); } + +uint32 LDoNTheme::GetBitmask(uint32 theme_id) +{ + return IsValid(theme_id) ? ldon_theme_names[theme_id].second : LDoNTheme::UnusedBit; +} + +std::string LDoNTheme::GetName(uint32 theme_id) +{ + return IsValid(theme_id) ? ldon_theme_names[theme_id].first : "UNKNOWN LDON THEME"; +} + +bool LDoNTheme::IsValid(uint32 theme_id) +{ + return ldon_theme_names.find(theme_id) != ldon_theme_names.end(); +} diff --git a/common/emu_constants.h b/common/emu_constants.h index 83056cfb2..7da8196d3 100644 --- a/common/emu_constants.h +++ b/common/emu_constants.h @@ -352,9 +352,6 @@ namespace EQ extern const std::map& GetLanguageMap(); std::string GetLanguageName(uint8 language_id); - extern const std::map& GetLDoNThemeMap(); - std::string GetLDoNThemeName(uint32 theme_id); - extern const std::map& GetFlyModeMap(); std::string GetFlyModeName(int8 flymode_id); @@ -751,6 +748,35 @@ static std::map stance_names = { { Stance::AEBurn, "AE Burn" } }; +namespace LDoNTheme { + constexpr uint32 Unused = 0; + constexpr uint32 GUK = 1; + constexpr uint32 MIR = 2; + constexpr uint32 MMC = 3; + constexpr uint32 RUJ = 4; + constexpr uint32 TAK = 5; + + constexpr uint32 UnusedBit = 0; + constexpr uint32 GUKBit = 1; + constexpr uint32 MIRBit = 2; + constexpr uint32 MMCBit = 4; + constexpr uint32 RUJBit = 8; + constexpr uint32 TAKBit = 16; + + uint32 GetBitmask(uint32 theme_id); + std::string GetName(uint32 theme_id); + bool IsValid(uint32 theme_id); +} + +static std::map> ldon_theme_names = { + { LDoNTheme::Unused, { "Unused", LDoNTheme::UnusedBit }, }, + { LDoNTheme::GUK, { "Deepest Guk", LDoNTheme::GUKBit }, }, + { LDoNTheme::MIR, { "Miragul's Menagerie", LDoNTheme::MIRBit }, }, + { LDoNTheme::MMC, { "Mistmoore Catacombs", LDoNTheme::MMCBit }, }, + { LDoNTheme::RUJ, { "Rujarkian Hills", LDoNTheme::RUJBit }, }, + { LDoNTheme::TAK, { "Takish-Hiz", LDoNTheme::TAKBit }, }, +}; + namespace PCNPCOnlyFlagType { constexpr int PC = 1; constexpr int NPC = 2; diff --git a/common/eq_constants.h b/common/eq_constants.h index 44beffd25..fd9cd346a 100644 --- a/common/eq_constants.h +++ b/common/eq_constants.h @@ -993,24 +993,6 @@ enum class DynamicZoneMemberStatus : uint8_t LinkDead }; -enum LDoNThemes { - Unused = 0, - GUK, - MIR, - MMC, - RUJ, - TAK -}; - -enum LDoNThemeBits { - UnusedBit = 0, - GUKBit = 1, - MIRBit = 2, - MMCBit = 4, - RUJBit = 8, - TAKBit = 16 -}; - enum StartZoneIndex { Odus = 0, Qeynos, diff --git a/common/repositories/adventure_stats_repository.h b/common/repositories/adventure_stats_repository.h index a4025ed2b..5b93a7fe1 100644 --- a/common/repositories/adventure_stats_repository.h +++ b/common/repositories/adventure_stats_repository.h @@ -49,23 +49,23 @@ public: std::string field; switch (theme_id) { - case LDoNThemes::GUK: { + case LDoNTheme::GUK: { field = "guk_"; break; } - case LDoNThemes::MIR: { + case LDoNTheme::MIR: { field = "mir_"; break; } - case LDoNThemes::MMC: { + case LDoNTheme::MMC: { field = "mmc_"; break; } - case LDoNThemes::RUJ: { + case LDoNTheme::RUJ: { field = "ruj_"; break; } - case LDoNThemes::TAK: { + case LDoNTheme::TAK: { field = "tak_"; break; } diff --git a/zone/client.cpp b/zone/client.cpp index d0a8d97b0..920553f5c 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -329,7 +329,7 @@ Client::Client(EQStreamInterface *ieqs) : Mob( adventure_stats_timer = nullptr; adventure_leaderboard_timer = nullptr; adv_data = nullptr; - adv_requested_theme = LDoNThemes::Unused; + adv_requested_theme = LDoNTheme::Unused; adv_requested_id = 0; adv_requested_member_count = 0; @@ -1469,7 +1469,7 @@ bool Client::UpdateLDoNPoints(uint32 theme_id, int points) bool is_loss = false; switch (theme_id) { - case LDoNThemes::Unused: { // No theme, so distribute evenly across all + case LDoNTheme::Unused: { // No theme, so distribute evenly across all int split_points = (points / 5); int guk_points = (split_points + (points % 5)); @@ -1522,12 +1522,12 @@ bool Client::UpdateLDoNPoints(uint32 theme_id, int points) points -= split_points; if (split_points != 0) { // if anything left, recursively loop thru again - UpdateLDoNPoints(LDoNThemes::Unused, split_points); + UpdateLDoNPoints(LDoNTheme::Unused, split_points); } break; } - case LDoNThemes::GUK: { + case LDoNTheme::GUK: { if (points < 0) { if (m_pp.ldon_points_guk < (0 - points)) { return false; @@ -1539,7 +1539,7 @@ bool Client::UpdateLDoNPoints(uint32 theme_id, int points) m_pp.ldon_points_guk += points; break; } - case LDoNThemes::MIR: { + case LDoNTheme::MIR: { if (points < 0) { if (m_pp.ldon_points_mir < (0 - points)) { return false; @@ -1551,7 +1551,7 @@ bool Client::UpdateLDoNPoints(uint32 theme_id, int points) m_pp.ldon_points_mir += points; break; } - case LDoNThemes::MMC: { + case LDoNTheme::MMC: { if (points < 0) { if (m_pp.ldon_points_mmc < (0 - points)) { return false; @@ -1563,7 +1563,7 @@ bool Client::UpdateLDoNPoints(uint32 theme_id, int points) m_pp.ldon_points_mmc += points; break; } - case LDoNThemes::RUJ: { + case LDoNTheme::RUJ: { if (points < 0) { if (m_pp.ldon_points_ruj < (0 - points)) { return false; @@ -1575,7 +1575,7 @@ bool Client::UpdateLDoNPoints(uint32 theme_id, int points) m_pp.ldon_points_ruj += points; break; } - case LDoNThemes::TAK: { + case LDoNTheme::TAK: { if (points < 0) { if (m_pp.ldon_points_tak < (0 - points)) { return false; @@ -1623,23 +1623,23 @@ bool Client::UpdateLDoNPoints(uint32 theme_id, int points) void Client::SetLDoNPoints(uint32 theme_id, uint32 points) { switch (theme_id) { - case LDoNThemes::GUK: { + case LDoNTheme::GUK: { m_pp.ldon_points_guk = points; break; } - case LDoNThemes::MIR: { + case LDoNTheme::MIR: { m_pp.ldon_points_mir = points; break; } - case LDoNThemes::MMC: { + case LDoNTheme::MMC: { m_pp.ldon_points_mmc = points; break; } - case LDoNThemes::RUJ: { + case LDoNTheme::RUJ: { m_pp.ldon_points_ruj = points; break; } - case LDoNThemes::TAK: { + case LDoNTheme::TAK: { m_pp.ldon_points_tak = points; break; } @@ -5676,15 +5676,15 @@ uint32 Client::GetLDoNPointsTheme(uint32 t) { switch(t) { - case LDoNThemes::GUK: + case LDoNTheme::GUK: return m_pp.ldon_points_guk; - case LDoNThemes::MIR: + case LDoNTheme::MIR: return m_pp.ldon_points_mir; - case LDoNThemes::MMC: + case LDoNTheme::MMC: return m_pp.ldon_points_mmc; - case LDoNThemes::RUJ: + case LDoNTheme::RUJ: return m_pp.ldon_points_ruj; - case LDoNThemes::TAK: + case LDoNTheme::TAK: return m_pp.ldon_points_tak; default: return 0; @@ -5695,15 +5695,15 @@ uint32 Client::GetLDoNWinsTheme(uint32 t) { switch(t) { - case LDoNThemes::GUK: + case LDoNTheme::GUK: return m_pp.ldon_wins_guk; - case LDoNThemes::MIR: + case LDoNTheme::MIR: return m_pp.ldon_wins_mir; - case LDoNThemes::MMC: + case LDoNTheme::MMC: return m_pp.ldon_wins_mmc; - case LDoNThemes::RUJ: + case LDoNTheme::RUJ: return m_pp.ldon_wins_ruj; - case LDoNThemes::TAK: + case LDoNTheme::TAK: return m_pp.ldon_wins_tak; default: return 0; @@ -5714,15 +5714,15 @@ uint32 Client::GetLDoNLossesTheme(uint32 t) { switch(t) { - case LDoNThemes::GUK: + case LDoNTheme::GUK: return m_pp.ldon_losses_guk; - case LDoNThemes::MIR: + case LDoNTheme::MIR: return m_pp.ldon_losses_mir; - case LDoNThemes::MMC: + case LDoNTheme::MMC: return m_pp.ldon_losses_mmc; - case LDoNThemes::RUJ: + case LDoNTheme::RUJ: return m_pp.ldon_losses_ruj; - case LDoNThemes::TAK: + case LDoNTheme::TAK: return m_pp.ldon_losses_tak; default: return 0; @@ -5731,35 +5731,35 @@ uint32 Client::GetLDoNLossesTheme(uint32 t) void Client::UpdateLDoNWinLoss(uint32 theme_id, bool win, bool remove) { switch (theme_id) { - case LDoNThemes::GUK: + case LDoNTheme::GUK: if (win) { m_pp.ldon_wins_guk += (remove ? -1 : 1); } else { m_pp.ldon_losses_guk += (remove ? -1 : 1); } break; - case LDoNThemes::MIR: + case LDoNTheme::MIR: if (win) { m_pp.ldon_wins_mir += (remove ? -1 : 1); } else { m_pp.ldon_losses_mir += (remove ? -1 : 1); } break; - case LDoNThemes::MMC: + case LDoNTheme::MMC: if (win) { m_pp.ldon_wins_mmc += (remove ? -1 : 1); } else { m_pp.ldon_losses_mmc += (remove ? -1 : 1); } break; - case LDoNThemes::RUJ: + case LDoNTheme::RUJ: if (win) { m_pp.ldon_wins_ruj += (remove ? -1 : 1); } else { m_pp.ldon_losses_ruj += (remove ? -1 : 1); } break; - case LDoNThemes::TAK: + case LDoNTheme::TAK: if (win) { m_pp.ldon_wins_tak += (remove ? -1 : 1); } else { @@ -6227,7 +6227,7 @@ void Client::NewAdventure(int id, int theme, const char *text, int member_count, void Client::ClearPendingAdventureData() { adv_requested_id = 0; - adv_requested_theme = LDoNThemes::Unused; + adv_requested_theme = LDoNTheme::Unused; safe_delete_array(adv_requested_data); adv_requested_member_count = 0; } diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 4236a4851..4afe67935 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -2019,38 +2019,38 @@ void Client::Handle_OP_AdventureMerchantPurchase(const EQApplicationPacket *app) return; } - if (item->LDoNTheme <= LDoNThemeBits::TAKBit) { + if (item->LDoNTheme <= LDoNTheme::TAKBit) { uint32 ldon_theme; - if (item->LDoNTheme & LDoNThemeBits::TAKBit) { + if (item->LDoNTheme & LDoNTheme::TAKBit) { if (m_pp.ldon_points_tak < item_cost) { cannot_afford = true; - ldon_theme = LDoNThemes::TAK; + ldon_theme = LDoNTheme::TAK; } - } else if (item->LDoNTheme & LDoNThemeBits::RUJBit) { + } else if (item->LDoNTheme & LDoNTheme::RUJBit) { if (m_pp.ldon_points_ruj < item_cost) { cannot_afford = true; - ldon_theme = LDoNThemes::RUJ; + ldon_theme = LDoNTheme::RUJ; } - } else if (item->LDoNTheme & LDoNThemeBits::MMCBit) { + } else if (item->LDoNTheme & LDoNTheme::MMCBit) { if (m_pp.ldon_points_mmc < item_cost) { cannot_afford = true; - ldon_theme = LDoNThemes::MMC; + ldon_theme = LDoNTheme::MMC; } - } else if (item->LDoNTheme & LDoNThemeBits::MIRBit) { + } else if (item->LDoNTheme & LDoNTheme::MIRBit) { if (m_pp.ldon_points_mir < item_cost) { cannot_afford = true; - ldon_theme = LDoNThemes::MIR; + ldon_theme = LDoNTheme::MIR; } - } else if (item->LDoNTheme & LDoNThemeBits::GUKBit) { + } else if (item->LDoNTheme & LDoNTheme::GUKBit) { if (m_pp.ldon_points_guk < item_cost) { cannot_afford = true; - ldon_theme = LDoNThemes::GUK; + ldon_theme = LDoNTheme::GUK; } } merchant_type = fmt::format( "{} Point{}", - EQ::constants::GetLDoNThemeName(ldon_theme), + LDoNTheme::GetName(ldon_theme), item_cost != 1 ? "s" : "" ); } @@ -2194,19 +2194,19 @@ void Client::Handle_OP_AdventureMerchantRequest(const EQApplicationPacket *app) item = database.GetItem(ml.item); if (item) { - uint32 theme = LDoNThemes::Unused; - if (item->LDoNTheme > LDoNThemeBits::TAKBit) { - theme = LDoNThemes::Unused; - } else if (item->LDoNTheme & LDoNThemeBits::TAKBit) { - theme = LDoNThemes::TAK; - } else if (item->LDoNTheme & LDoNThemeBits::RUJBit) { - theme = LDoNThemes::RUJ; - } else if (item->LDoNTheme & LDoNThemeBits::MMCBit) { - theme = LDoNThemes::MMC; - } else if (item->LDoNTheme & LDoNThemeBits::MIRBit) { - theme = LDoNThemes::MIR; - } else if (item->LDoNTheme & LDoNThemeBits::GUKBit) { - theme = LDoNThemes::GUK; + uint32 theme = LDoNTheme::Unused; + if (item->LDoNTheme > LDoNTheme::TAKBit) { + theme = LDoNTheme::Unused; + } else if (item->LDoNTheme & LDoNTheme::TAKBit) { + theme = LDoNTheme::TAK; + } else if (item->LDoNTheme & LDoNTheme::RUJBit) { + theme = LDoNTheme::RUJ; + } else if (item->LDoNTheme & LDoNTheme::MMCBit) { + theme = LDoNTheme::MMC; + } else if (item->LDoNTheme & LDoNTheme::MIRBit) { + theme = LDoNTheme::MIR; + } else if (item->LDoNTheme & LDoNTheme::GUKBit) { + theme = LDoNTheme::GUK; } ss << "^" << item->Name << "|"; ss << item->ID << "|"; diff --git a/zone/gm_commands/find.cpp b/zone/gm_commands/find.cpp index c2e1ee559..84f33ac0d 100644 --- a/zone/gm_commands/find.cpp +++ b/zone/gm_commands/find.cpp @@ -11,6 +11,7 @@ #include "find/faction.cpp" #include "find/item.cpp" #include "find/language.cpp" +#include "find/ldon_theme.cpp" #include "find/npctype.cpp" #include "find/object_type.cpp" #include "find/race.cpp" @@ -47,6 +48,7 @@ void command_find(Client *c, const Seperator *sep) Cmd{.cmd = "faction", .u = "faction [Search Criteria]", .fn = FindFaction, .a = {"#findfaction"}}, Cmd{.cmd = "item", .u = "item [Search Criteria]", .fn = FindItem, .a = {"#fi", "#finditem"}}, Cmd{.cmd = "language", .u = "language [Search Criteria]", .fn = FindLanguage, .a = {"#findlanguage"}}, + Cmd{.cmd = "ldon_theme", .u = "ldon_theme [Search Criteria]", .fn = FindLDoNTheme, .a = {"#findldontheme"}}, Cmd{ .cmd = "npctype", .u = "npctype [Search Criteria]", .fn = FindNPCType, .a = { "#fn", diff --git a/zone/gm_commands/find/class.cpp b/zone/gm_commands/find/class.cpp index 2ce3b1707..a89211e77 100644 --- a/zone/gm_commands/find/class.cpp +++ b/zone/gm_commands/find/class.cpp @@ -57,7 +57,7 @@ void FindClass(Client *c, const Seperator *sep) ( IsPlayerClass(class_id) ? fmt::format( - " | ({})", + " ({})", Strings::Commify(GetPlayerClassBit(class_id)) ) : "" diff --git a/zone/gm_commands/find/ldon_theme.cpp b/zone/gm_commands/find/ldon_theme.cpp new file mode 100644 index 000000000..aa7231297 --- /dev/null +++ b/zone/gm_commands/find/ldon_theme.cpp @@ -0,0 +1,65 @@ +#include "../../client.h" + +void FindLDoNTheme(Client *c, const Seperator *sep) +{ + if (sep->IsNumber(2)) { + const uint32 theme_id = Strings::ToUnsignedInt(sep->arg[2]); + if (LDoNTheme::IsValid(theme_id)) { + c->Message( + Chat::White, + fmt::format( + "Theme {} | {} ({})", + theme_id, + LDoNTheme::GetName(theme_id), + LDoNTheme::GetBitmask(theme_id) + ).c_str() + ); + + return; + } + + c->Message( + Chat::White, + fmt::format( + "Theme ID {} was not found.", + theme_id + ).c_str() + ); + + return; + } + + const std::string& search_criteria = Strings::ToLower(sep->argplus[2]); + + uint32 found_count = 0; + + for (const auto& l : ldon_theme_names) { + const std::string& ldon_theme_name_lower = Strings::ToLower(l.second.first); + if (!Strings::Contains(ldon_theme_name_lower, search_criteria)) { + continue; + } + + c->Message( + Chat::White, + fmt::format( + "Theme {} | {} ({})", + l.first, + l.second.first, + l.second.second + ).c_str() + ); + + found_count++; + } + + c->Message( + Chat::White, + fmt::format( + "{} Theme{} found matching '{}'.", + found_count, + found_count != 1 ? "s" : "", + sep->argplus[2] + ).c_str() + ); +} + diff --git a/zone/gm_commands/set/adventure_points.cpp b/zone/gm_commands/set/adventure_points.cpp index 3b49d06ec..55465039a 100755 --- a/zone/gm_commands/set/adventure_points.cpp +++ b/zone/gm_commands/set/adventure_points.cpp @@ -3,20 +3,21 @@ void SetAdventurePoints(Client *c, const Seperator *sep) { - const auto arguments = sep->argnum; + const uint16 arguments = sep->argnum; if (arguments < 3 || !sep->IsNumber(2) || !sep->IsNumber(3)) { c->Message(Chat::White, "Usage: #set adventure_points [Theme] [Points]"); c->Message(Chat::White, "Valid themes are as follows:"); - for (const auto& e : EQ::constants::GetLDoNThemeMap()) { - if (e.first != LDoNThemes::Unused) { + for (const auto& e : ldon_theme_names) { + if (e.first != LDoNTheme::Unused) { c->Message( Chat::White, fmt::format( - "Theme {} | {}", + "Theme {} | {} ({})", e.first, - e.second + e.second.first, + e.second.second ).c_str() ); } @@ -25,25 +26,26 @@ void SetAdventurePoints(Client *c, const Seperator *sep) return; } - auto t = c; + Client* t = c; if (c->GetTarget() && c->GetTarget()->IsClient()) { t = c->GetTarget()->CastToClient(); } const uint32 theme_id = Strings::ToUnsignedInt(sep->arg[2]); - const uint32 points = Strings::ToUnsignedInt(sep->arg[3]); + const uint32 points = Strings::ToUnsignedInt(sep->arg[3]); - if (!EQ::ValueWithin(theme_id, LDoNThemes::GUK, LDoNThemes::TAK)) { + if (!LDoNTheme::IsValid(theme_id)) { c->Message(Chat::White, "Valid themes are as follows:"); - for (const auto& e : EQ::constants::GetLDoNThemeMap()) { - if (e.first != LDoNThemes::Unused) { + for (const auto& e : ldon_theme_names) { + if (e.first != LDoNTheme::Unused) { c->Message( Chat::White, fmt::format( - "Theme {} | {}", + "Theme {} | {} ({})", e.first, - e.second + e.second.first, + e.second.second ).c_str() ); } @@ -56,7 +58,7 @@ void SetAdventurePoints(Client *c, const Seperator *sep) Chat::White, fmt::format( "Set {} Points to {} for {}.", - EQ::constants::GetLDoNThemeName(theme_id), + LDoNTheme::GetName(theme_id), Strings::Commify(points), c->GetTargetDescription(t) ).c_str() diff --git a/zone/gm_commands/show/currencies.cpp b/zone/gm_commands/show/currencies.cpp index d63395822..4f4d3cfda 100644 --- a/zone/gm_commands/show/currencies.cpp +++ b/zone/gm_commands/show/currencies.cpp @@ -89,11 +89,11 @@ void ShowCurrencies(Client *c, const Seperator *sep) } } - for (const auto& l : EQ::constants::GetLDoNThemeMap()) { + for (const auto& l : ldon_theme_names) { const uint32 ldon_currency_value = t->GetLDoNPointsTheme(l.first); if (ldon_currency_value) { currency_table += DialogueWindow::TableRow( - DialogueWindow::TableCell(l.second) + + DialogueWindow::TableCell(l.second.first) + DialogueWindow::TableCell(Strings::Commify(ldon_currency_value)) ); diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index e1a859add..ad29a76a9 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -1287,7 +1287,7 @@ std::string QuestManager::getskillname(int skill_id) { } std::string QuestManager::getldonthemename(uint32 theme_id) { - return EQ::constants::GetLDoNThemeName(theme_id); + return LDoNTheme::GetName(theme_id); } std::string QuestManager::getfactionname(int faction_id) {