[Commands] Add #finddeity Command (#3435)

# Notes
- Add `#finddeity` command.
- Remove `ConvertDeityTypeBitToDeityType` as it's unused.
- Rename `ConvertDeityTypeToDeityTypeBit` to `GetDeityBitmask`.
This commit is contained in:
Alex King 2023-06-26 00:00:32 -04:00 committed by GitHub
parent ef7a3cae17
commit 8d986c95cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 171 additions and 144 deletions

View File

@ -11,7 +11,7 @@
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@ -19,131 +19,81 @@
#include "deity.h"
EQ::deity::DeityTypeBit EQ::deity::ConvertDeityTypeToDeityTypeBit(DeityType deity_type)
EQ::deity::DeityTypeBit EQ::deity::GetDeityBitmask(DeityType deity_type)
{
switch (deity_type) {
case DeityBertoxxulous:
return bit_DeityBertoxxulous;
case DeityBrellSirilis:
return bit_DeityBrellSirilis;
case DeityCazicThule:
return bit_DeityCazicThule;
case DeityErollisiMarr:
return bit_DeityErollisiMarr;
case DeityBristlebane:
return bit_DeityBristlebane;
case DeityInnoruuk:
return bit_DeityInnoruuk;
case DeityKarana:
return bit_DeityKarana;
case DeityMithanielMarr:
return bit_DeityMithanielMarr;
case DeityPrexus:
return bit_DeityPrexus;
case DeityQuellious:
return bit_DeityQuellious;
case DeityRallosZek:
return bit_DeityRallosZek;
case DeityRodcetNife:
return bit_DeityRodcetNife;
case DeitySolusekRo:
return bit_DeitySolusekRo;
case DeityTheTribunal:
return bit_DeityTheTribunal;
case DeityTunare:
return bit_DeityTunare;
case DeityVeeshan:
return bit_DeityVeeshan;
case DeityAgnostic_LB:
case DeityAgnostic:
return bit_DeityAgnostic;
default:
return bit_DeityAll;
};
case DeityBertoxxulous:
return bit_DeityBertoxxulous;
case DeityBrellSirilis:
return bit_DeityBrellSirilis;
case DeityCazicThule:
return bit_DeityCazicThule;
case DeityErollisiMarr:
return bit_DeityErollisiMarr;
case DeityBristlebane:
return bit_DeityBristlebane;
case DeityInnoruuk:
return bit_DeityInnoruuk;
case DeityKarana:
return bit_DeityKarana;
case DeityMithanielMarr:
return bit_DeityMithanielMarr;
case DeityPrexus:
return bit_DeityPrexus;
case DeityQuellious:
return bit_DeityQuellious;
case DeityRallosZek:
return bit_DeityRallosZek;
case DeityRodcetNife:
return bit_DeityRodcetNife;
case DeitySolusekRo:
return bit_DeitySolusekRo;
case DeityTheTribunal:
return bit_DeityTheTribunal;
case DeityTunare:
return bit_DeityTunare;
case DeityVeeshan:
return bit_DeityVeeshan;
case DeityAgnostic_LB:
case DeityAgnostic:
return bit_DeityAgnostic;
default:
return bit_DeityAll;
}
}
EQ::deity::DeityType EQ::deity::ConvertDeityTypeBitToDeityType(DeityTypeBit deity_type_bit)
const std::map<EQ::deity::DeityType, std::string>& EQ::deity::GetDeityMap()
{
switch (deity_type_bit) {
case bit_DeityAgnostic:
return DeityAgnostic;
case bit_DeityBertoxxulous:
return DeityBertoxxulous;
case bit_DeityBrellSirilis:
return DeityBrellSirilis;
case bit_DeityCazicThule:
return DeityCazicThule;
case bit_DeityErollisiMarr:
return DeityErollisiMarr;
case bit_DeityBristlebane:
return DeityBristlebane;
case bit_DeityInnoruuk:
return DeityInnoruuk;
case bit_DeityKarana:
return DeityKarana;
case bit_DeityMithanielMarr:
return DeityMithanielMarr;
case bit_DeityPrexus:
return DeityPrexus;
case bit_DeityQuellious:
return DeityQuellious;
case bit_DeityRallosZek:
return DeityRallosZek;
case bit_DeityRodcetNife:
return DeityRodcetNife;
case bit_DeitySolusekRo:
return DeitySolusekRo;
case bit_DeityTheTribunal:
return DeityTheTribunal;
case bit_DeityTunare:
return DeityTunare;
case bit_DeityVeeshan:
return DeityVeeshan;
default:
return DeityUnknown;
static const std::map<EQ::deity::DeityType, std::string> deity_map = {
{ DeityAgnostic, "Agnostic" },
{ DeityAgnostic_LB, "Agnostic" },
{ DeityBertoxxulous, "Bertoxxulous" },
{ DeityBrellSirilis, "Brell Serilis" },
{ DeityBristlebane, "Bristlebane" },
{ DeityCazicThule, "Cazic-Thule" },
{ DeityErollisiMarr, "Erollisi Marr" },
{ DeityInnoruuk, "Innoruuk" },
{ DeityKarana, "Karana" },
{ DeityMithanielMarr, "Mithaniel Marr" },
{ DeityPrexus, "Prexus" },
{ DeityQuellious, "Quellious" },
{ DeityRallosZek, "Rallos Zek" },
{ DeityRodcetNife, "Rodcet Nife" },
{ DeitySolusekRo, "Solusek Ro" },
{ DeityTheTribunal, "The Tribunal" },
{ DeityTunare, "Tunare" },
{ DeityVeeshan, "Veeshan" }
};
return deity_map;
}
const char* EQ::deity::DeityName(DeityType deity_type)
std::string EQ::deity::GetDeityName(DeityType deity_type)
{
switch (deity_type) {
case DeityBertoxxulous:
return "Bertoxxulous";
case DeityBrellSirilis:
return "Brell Serilis";
case DeityCazicThule:
return "Cazic-Thule";
case DeityErollisiMarr:
return "Erollisi Marr";
case DeityBristlebane:
return "Bristlebane";
case DeityInnoruuk:
return "Innoruuk";
case DeityKarana:
return "Karana";
case DeityMithanielMarr:
return "Mithaniel Marr";
case DeityPrexus:
return "Prexus";
case DeityQuellious:
return "Quellious";
case DeityRallosZek:
return "Rallos Zek";
case DeityRodcetNife:
return "Rodcet Nife";
case DeitySolusekRo:
return "Solusek Ro";
case DeityTheTribunal:
return "The Tribunal";
case DeityTunare:
return "Tunare";
case DeityVeeshan:
return "Veeshan";
case DeityAgnostic_LB:
case DeityAgnostic:
return "Agnostic";
default:
return "Unknown";
};
if (EQ::deity::GetDeityMap().find(deity_type) != EQ::deity::GetDeityMap().end()) {
return EQ::deity::GetDeityMap().find(deity_type)->second;
}
return std::string();
}

View File

@ -21,6 +21,8 @@
#define COMMON_DEITY_H
#include "types.h"
#include <map>
#include <string>
namespace EQ
@ -49,30 +51,29 @@ namespace EQ
};
enum DeityTypeBit : uint32 {
bit_DeityNone = 0x00000000,
bit_DeityAgnostic = 0x00000001,
bit_DeityBertoxxulous = 0x00000002,
bit_DeityBrellSirilis = 0x00000004,
bit_DeityCazicThule = 0x00000008,
bit_DeityErollisiMarr = 0x00000010,
bit_DeityBristlebane = 0x00000020,
bit_DeityInnoruuk = 0x00000040,
bit_DeityKarana = 0x00000080,
bit_DeityAgnostic = 0x00000001,
bit_DeityBertoxxulous = 0x00000002,
bit_DeityBrellSirilis = 0x00000004,
bit_DeityCazicThule = 0x00000008,
bit_DeityErollisiMarr = 0x00000010,
bit_DeityBristlebane = 0x00000020,
bit_DeityInnoruuk = 0x00000040,
bit_DeityKarana = 0x00000080,
bit_DeityMithanielMarr = 0x00000100,
bit_DeityPrexus = 0x00000200,
bit_DeityQuellious = 0x00000400,
bit_DeityRallosZek = 0x00000800,
bit_DeityRodcetNife = 0x00001000,
bit_DeitySolusekRo = 0x00002000,
bit_DeityTheTribunal = 0x00004000,
bit_DeityTunare = 0x00008000,
bit_DeityVeeshan = 0x00010000,
bit_DeityAll = 0xFFFFFFFF
bit_DeityPrexus = 0x00000200,
bit_DeityQuellious = 0x00000400,
bit_DeityRallosZek = 0x00000800,
bit_DeityRodcetNife = 0x00001000,
bit_DeitySolusekRo = 0x00002000,
bit_DeityTheTribunal = 0x00004000,
bit_DeityTunare = 0x00008000,
bit_DeityVeeshan = 0x00010000,
bit_DeityAll = UINT32_MAX
};
extern DeityTypeBit ConvertDeityTypeToDeityTypeBit(DeityType deity_type);
extern DeityType ConvertDeityTypeBitToDeityType(DeityTypeBit deity_type_bit);
extern const char* DeityName(DeityType deity_type);
extern DeityTypeBit GetDeityBitmask(DeityType deity_type);
extern std::string GetDeityName(DeityType deity_type);
extern const std::map<DeityType, std::string>& GetDeityMap();
} /*deity*/

View File

@ -353,7 +353,7 @@ bool EQ::InventoryProfile::SwapItem(
fail_state = swapRaceClass;
return false;
}
if (deity_id && source_item->Deity && !(deity::ConvertDeityTypeToDeityTypeBit((deity::DeityType)deity_id) & source_item->Deity)) {
if (deity_id && source_item->Deity && !(deity::GetDeityBitmask((deity::DeityType)deity_id) & source_item->Deity)) {
fail_state = swapDeity;
return false;
}
@ -379,7 +379,7 @@ bool EQ::InventoryProfile::SwapItem(
fail_state = swapRaceClass;
return false;
}
if (deity_id && destination_item->Deity && !(deity::ConvertDeityTypeToDeityTypeBit((deity::DeityType)deity_id) & destination_item->Deity)) {
if (deity_id && destination_item->Deity && !(deity::GetDeityBitmask((deity::DeityType)deity_id) & destination_item->Deity)) {
fail_state = swapDeity;
return false;
}

View File

@ -142,6 +142,7 @@ int command_init(void)
command_add("findcharacter", "[Search Criteria] - Search for a character", AccountStatus::Guide, command_findcharacter) ||
command_add("findclass", "[Search Criteria] - Search for a class", AccountStatus::Guide, command_findclass) ||
command_add("findcurrency", "[Search Criteria] - Search for an alternate currency", AccountStatus::Guide, command_findcurrency) ||
command_add("finddeity", "[Search Criteria] - Search for a deity", AccountStatus::Guide, command_finddeity) ||
command_add("findfaction", "[Search Criteria] - Search for a faction", AccountStatus::Guide, command_findfaction) ||
command_add("findlanguage", "[Search Criteria] - Search for a language", AccountStatus::Guide, command_findlanguage) ||
command_add("findnpctype", "[Search Criteria] - Search database NPC types", AccountStatus::GMAdmin, command_findnpctype) ||
@ -984,6 +985,7 @@ void command_bot(Client *c, const Seperator *sep)
#include "gm_commands/findcharacter.cpp"
#include "gm_commands/findclass.cpp"
#include "gm_commands/findcurrency.cpp"
#include "gm_commands/finddeity.cpp"
#include "gm_commands/findfaction.cpp"
#include "gm_commands/findlanguage.cpp"
#include "gm_commands/findnpctype.cpp"

View File

@ -92,6 +92,7 @@ void command_findaliases(Client *c, const Seperator *sep);
void command_findcharacter(Client *c, const Seperator *sep);
void command_findclass(Client *c, const Seperator *sep);
void command_findcurrency(Client *c, const Seperator *sep);
void command_finddeity(Client *c, const Seperator *sep);
void command_findfaction(Client *c, const Seperator *sep);
void command_findlanguage(Client *c, const Seperator *sep);
void command_findnpctype(Client *c, const Seperator *sep);

73
zone/gm_commands/finddeity.cpp Executable file
View File

@ -0,0 +1,73 @@
#include "../client.h"
void command_finddeity(Client *c, const Seperator *sep)
{
const auto arguments = sep->argnum;
if (!arguments) {
c->Message(Chat::White, "Usage: #finddeity [Search Criteria]");
return;
}
if (sep->IsNumber(1)) {
const auto deity_id = static_cast<EQ::deity::DeityType>(Strings::ToInt(sep->arg[1]));
const auto& deity_name = EQ::deity::GetDeityName(deity_id);
if (!deity_name.empty()) {
const auto deity_bit = EQ::deity::GetDeityBitmask(deity_id);
c->Message(
Chat::White,
fmt::format(
"Deity {} | {} ({})",
deity_id,
deity_name,
deity_bit
).c_str()
);
return;
}
c->Message(
Chat::White,
fmt::format(
"Deity ID {} was not found.",
deity_id
).c_str()
);
return;
}
const auto& search_criteria = Strings::ToLower(sep->argplus[1]);
if (!search_criteria.empty()) {
auto found_count = 0;
for (const auto& d : EQ::deity::GetDeityMap()) {
const auto& deity_name_lower = Strings::ToLower(d.second);
if (!Strings::Contains(deity_name_lower, search_criteria)) {
continue;
}
const auto deity_bit = EQ::deity::GetDeityBitmask(d.first);
c->Message(
Chat::White,
fmt::format(
"Deity {} | {} ({})",
d.first,
d.second,
deity_bit
).c_str()
);
found_count++;
}
c->Message(
Chat::White,
fmt::format(
"{} Deit{} found.",
found_count,
found_count != 1 ? "ies" : "y"
).c_str()
);
}
}

View File

@ -523,7 +523,7 @@ public:
virtual inline uint8 GetBaseGender() const { return base_gender; }
virtual uint16 GetFactionRace();
virtual inline uint16 GetDeity() const { return deity; }
virtual EQ::deity::DeityTypeBit GetDeityBit() { return EQ::deity::ConvertDeityTypeToDeityTypeBit((EQ::deity::DeityType)deity); }
virtual EQ::deity::DeityTypeBit GetDeityBit() { return EQ::deity::GetDeityBitmask((EQ::deity::DeityType)deity); }
inline uint16 GetRace() const { return race; }
inline uint16 GetModel() const { return (use_model == 0) ? race : use_model; }
inline uint8 GetGender() const { return gender; }

View File

@ -3881,7 +3881,7 @@ std::string QuestManager::getgendername(uint32 gender_id) {
}
std::string QuestManager::getdeityname(uint32 deity_id) {
return EQ::deity::DeityName(static_cast<EQ::deity::DeityType>(deity_id));
return EQ::deity::GetDeityName(static_cast<EQ::deity::DeityType>(deity_id));
}
std::string QuestManager::getinventoryslotname(int16 slot_id) {