Skip to content

Commit

Permalink
[Commands] Add #find ldon_theme Subcommand (#4564)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kinglykrab authored Dec 12, 2024
1 parent 0f164c4 commit 3f3c0f2
Show file tree
Hide file tree
Showing 12 changed files with 194 additions and 125 deletions.
38 changes: 15 additions & 23 deletions common/emu_constants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,29 +140,6 @@ std::string EQ::constants::GetLanguageName(uint8 language_id)
return EQ::constants::GetLanguageMap().find(language_id)->second;
}

const std::map<uint32, std::string>& EQ::constants::GetLDoNThemeMap()
{
static const std::map<uint32, std::string> 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<int8, std::string>& EQ::constants::GetFlyModeMap()
{
static const std::map<int8, std::string> flymode_map = {
Expand Down Expand Up @@ -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();
}
32 changes: 29 additions & 3 deletions common/emu_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,6 @@ namespace EQ
extern const std::map<uint8, std::string>& GetLanguageMap();
std::string GetLanguageName(uint8 language_id);

extern const std::map<uint32, std::string>& GetLDoNThemeMap();
std::string GetLDoNThemeName(uint32 theme_id);

extern const std::map<int8, std::string>& GetFlyModeMap();
std::string GetFlyModeName(int8 flymode_id);

Expand Down Expand Up @@ -751,6 +748,35 @@ static std::map<uint32, std::string> 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<uint32, std::pair<std::string, uint32>> 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;
Expand Down
18 changes: 0 additions & 18 deletions common/eq_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions common/repositories/adventure_stats_repository.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,23 @@ class AdventureStatsRepository: public BaseAdventureStatsRepository {
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;
}
Expand Down
68 changes: 34 additions & 34 deletions zone/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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 {
Expand Down Expand Up @@ -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;
}
Expand Down
Loading

0 comments on commit 3f3c0f2

Please sign in to comment.