mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-18 03:01:29 +00:00
[Commands] Cleanup #who Command. (#1924)
* [Commands] Cleanup #who Command. - Cleanup messages and logic. - Add GetAccountStatusMap() and GetAccountStatusName() helpers for account status stuff. - Use Chat::Who instead of Chat::Magenta so you can more easily see saylinks. - Add a summon saylink to the list of saylinks so you can summon the player. * New line.
This commit is contained in:
parent
59c373bcff
commit
f3002d9656
@ -299,3 +299,41 @@ std::string EQ::constants::GetBodyTypeName(bodyType bodytype_id)
|
|||||||
}
|
}
|
||||||
return std::string();
|
return std::string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::map<uint8, std::string>& EQ::constants::GetAccountStatusMap()
|
||||||
|
{
|
||||||
|
static const std::map<uint8, std::string> account_status_map = {
|
||||||
|
{ AccountStatus::Player, "Player" },
|
||||||
|
{ AccountStatus::Steward, "Steward" },
|
||||||
|
{ AccountStatus::ApprenticeGuide, "Apprentice Guide" },
|
||||||
|
{ AccountStatus::Guide, "Guide" },
|
||||||
|
{ AccountStatus::QuestTroupe, "Quest Troupe" },
|
||||||
|
{ AccountStatus::SeniorGuide, "Senior Guide" },
|
||||||
|
{ AccountStatus::GMTester, "GM Tester" },
|
||||||
|
{ AccountStatus::EQSupport, "EQ Support" },
|
||||||
|
{ AccountStatus::GMStaff, "GM Staff" },
|
||||||
|
{ AccountStatus::GMAdmin, "GM Admin" },
|
||||||
|
{ AccountStatus::GMLeadAdmin, "GM Lead Admin" },
|
||||||
|
{ AccountStatus::QuestMaster, "Quest Master" },
|
||||||
|
{ AccountStatus::GMAreas, "GM Areas" },
|
||||||
|
{ AccountStatus::GMCoder, "GM Coder" },
|
||||||
|
{ AccountStatus::GMMgmt, "GM Mgmt" },
|
||||||
|
{ AccountStatus::GMImpossible, "GM Impossible" },
|
||||||
|
{ AccountStatus::Max, "GM Max" }
|
||||||
|
};
|
||||||
|
return account_status_map;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string EQ::constants::GetAccountStatusName(uint8 account_status)
|
||||||
|
{
|
||||||
|
auto account_statuses = EQ::constants::GetAccountStatusMap();
|
||||||
|
std::string status_name;
|
||||||
|
for (auto status_level = account_statuses.rbegin(); status_level != account_statuses.rend(); ++status_level) {
|
||||||
|
if (account_status >= status_level->first) {
|
||||||
|
status_name = status_level->second;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return status_name;
|
||||||
|
}
|
||||||
|
|||||||
@ -245,6 +245,9 @@ namespace EQ
|
|||||||
extern const std::map<bodyType, std::string>& GetBodyTypeMap();
|
extern const std::map<bodyType, std::string>& GetBodyTypeMap();
|
||||||
std::string GetBodyTypeName(bodyType bodytype_id);
|
std::string GetBodyTypeName(bodyType bodytype_id);
|
||||||
|
|
||||||
|
extern const std::map<uint8, std::string>& GetAccountStatusMap();
|
||||||
|
std::string GetAccountStatusName(uint8 account_status);
|
||||||
|
|
||||||
const int STANCE_TYPE_FIRST = stancePassive;
|
const int STANCE_TYPE_FIRST = stancePassive;
|
||||||
const int STANCE_TYPE_LAST = stanceBurnAE;
|
const int STANCE_TYPE_LAST = stanceBurnAE;
|
||||||
const int STANCE_TYPE_COUNT = stanceBurnAE;
|
const int STANCE_TYPE_COUNT = stanceBurnAE;
|
||||||
|
|||||||
@ -2,8 +2,7 @@
|
|||||||
|
|
||||||
void command_who(Client *c, const Seperator *sep)
|
void command_who(Client *c, const Seperator *sep)
|
||||||
{
|
{
|
||||||
std::string query =
|
std::string query = SQL(
|
||||||
SQL (
|
|
||||||
SELECT
|
SELECT
|
||||||
character_data.account_id,
|
character_data.account_id,
|
||||||
character_data.name,
|
character_data.name,
|
||||||
@ -11,67 +10,35 @@ void command_who(Client *c, const Seperator *sep)
|
|||||||
character_data.zone_instance,
|
character_data.zone_instance,
|
||||||
COALESCE(
|
COALESCE(
|
||||||
(
|
(
|
||||||
select
|
SELECT guilds.name FROM guilds WHERE id = (
|
||||||
guilds.name
|
|
||||||
from
|
|
||||||
guilds
|
|
||||||
where
|
|
||||||
id = (
|
|
||||||
(
|
(
|
||||||
select
|
SELECT guild_id FROM guild_members WHERE char_id = character_data.id
|
||||||
guild_id
|
|
||||||
from
|
|
||||||
guild_members
|
|
||||||
where
|
|
||||||
char_id = character_data.id
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
""
|
""
|
||||||
) as guild_name,
|
) AS guild_name,
|
||||||
character_data.level,
|
character_data.level,
|
||||||
character_data.race,
|
character_data.race,
|
||||||
character_data.class,
|
character_data.class,
|
||||||
COALESCE(
|
COALESCE(
|
||||||
(
|
(
|
||||||
select
|
SELECT account.status FROM account WHERE account.id = character_data.account_id LIMIT 1
|
||||||
account.status
|
|
||||||
from
|
|
||||||
account
|
|
||||||
where
|
|
||||||
account.id = character_data.account_id
|
|
||||||
LIMIT
|
|
||||||
1
|
|
||||||
), 0
|
|
||||||
) as account_status,
|
|
||||||
COALESCE(
|
|
||||||
(
|
|
||||||
select
|
|
||||||
account.name
|
|
||||||
from
|
|
||||||
account
|
|
||||||
where
|
|
||||||
account.id = character_data.account_id
|
|
||||||
LIMIT
|
|
||||||
1
|
|
||||||
),
|
),
|
||||||
0
|
0
|
||||||
) as account_name,
|
) AS account_status,
|
||||||
COALESCE(
|
COALESCE(
|
||||||
(
|
(
|
||||||
select
|
SELECT account.name FROM account WHERE account.id = character_data.account_id LIMIT 1
|
||||||
account_ip.ip
|
),
|
||||||
from
|
0
|
||||||
account_ip
|
) AS account_name,
|
||||||
where
|
COALESCE(
|
||||||
account_ip.accid = character_data.account_id
|
(
|
||||||
ORDER BY
|
SELECT account_ip.ip FROM account_ip WHERE account_ip.accid = character_data.account_id ORDER BY account_ip.lastused DESC LIMIT 1
|
||||||
account_ip.lastused DESC
|
|
||||||
LIMIT
|
|
||||||
1
|
|
||||||
),
|
),
|
||||||
""
|
""
|
||||||
) as account_ip
|
) AS account_ip
|
||||||
FROM
|
FROM
|
||||||
character_data
|
character_data
|
||||||
WHERE
|
WHERE
|
||||||
@ -81,12 +48,7 @@ void command_who(Client *c, const Seperator *sep)
|
|||||||
);
|
);
|
||||||
|
|
||||||
auto results = database.QueryDatabase(query);
|
auto results = database.QueryDatabase(query);
|
||||||
if (!results.Success()) {
|
if (!results.Success() || !results.RowCount()) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (results.RowCount() == 0) {
|
|
||||||
c->Message(Chat::Yellow, "No results found");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,28 +60,28 @@ void command_who(Client *c, const Seperator *sep)
|
|||||||
|
|
||||||
int found_count = 0;
|
int found_count = 0;
|
||||||
|
|
||||||
c->Message(Chat::Magenta, "Players in EverQuest");
|
c->Message(Chat::Who, "Players in EverQuest:");
|
||||||
c->Message(Chat::Magenta, "--------------------");
|
c->Message(Chat::Who, "------------------------------");
|
||||||
|
|
||||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
for (auto row : results) {
|
||||||
auto account_id = static_cast<uint32>(atoi(row[0]));
|
auto account_id = std::stoul(row[0]);
|
||||||
std::string player_name = row[1];
|
std::string player_name = row[1];
|
||||||
auto zone_id = static_cast<uint32>(atoi(row[2]));
|
auto zone_id = std::stoul(row[2]);
|
||||||
std::string zone_short_name = ZoneName(zone_id);
|
std::string zone_short_name = ZoneName(zone_id);
|
||||||
auto zone_instance = static_cast<uint32>(atoi(row[3]));
|
std::string zone_long_name = ZoneLongName(zone_id);
|
||||||
|
auto zone_instance = std::stoul(row[3]);
|
||||||
std::string guild_name = row[4];
|
std::string guild_name = row[4];
|
||||||
auto player_level = static_cast<uint32>(atoi(row[5]));
|
auto player_level = std::stoul(row[5]);
|
||||||
auto player_race = static_cast<uint32>(atoi(row[6]));
|
auto player_race = std::stoul(row[6]);
|
||||||
auto player_class = static_cast<uint32>(atoi(row[7]));
|
auto player_class = std::stoul(row[7]);
|
||||||
auto account_status = static_cast<uint32>(atoi(row[8]));
|
auto account_status = std::stoul(row[8]);
|
||||||
std::string account_name = row[9];
|
std::string account_name = row[9];
|
||||||
std::string account_ip = row[10];
|
std::string account_ip = row[10];
|
||||||
std::string base_class_name = GetClassIDName(static_cast<uint8>(player_class), 1);
|
std::string base_class_name = GetClassIDName(static_cast<uint8>(player_class));
|
||||||
std::string displayed_race_name = GetRaceIDName(static_cast<uint16>(player_race));
|
std::string displayed_race_name = GetRaceIDName(static_cast<uint16>(player_race));
|
||||||
|
|
||||||
if (search_string.length() > 0) {
|
if (search_string.length()) {
|
||||||
bool found_search_term =
|
bool found_search_term = (
|
||||||
(
|
|
||||||
str_tolower(player_name).find(search_string) != std::string::npos ||
|
str_tolower(player_name).find(search_string) != std::string::npos ||
|
||||||
str_tolower(zone_short_name).find(search_string) != std::string::npos ||
|
str_tolower(zone_short_name).find(search_string) != std::string::npos ||
|
||||||
str_tolower(displayed_race_name).find(search_string) != std::string::npos ||
|
str_tolower(displayed_race_name).find(search_string) != std::string::npos ||
|
||||||
@ -135,68 +97,145 @@ void command_who(Client *c, const Seperator *sep)
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string displayed_guild_name;
|
std::string displayed_guild_name;
|
||||||
if (guild_name.length() > 0) {
|
if (guild_name.length()) {
|
||||||
displayed_guild_name = EQ::SayLinkEngine::GenerateQuestSaylink(
|
displayed_guild_name = EQ::SayLinkEngine::GenerateQuestSaylink(
|
||||||
StringFormat(
|
fmt::format(
|
||||||
"#who \"%s\"",
|
"#who \"{}\"",
|
||||||
guild_name.c_str()),
|
guild_name
|
||||||
|
),
|
||||||
false,
|
false,
|
||||||
StringFormat("<%s>", guild_name.c_str())
|
fmt::format(
|
||||||
|
"<{}>",
|
||||||
|
guild_name
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string goto_saylink = EQ::SayLinkEngine::GenerateQuestSaylink(
|
auto goto_saylink = EQ::SayLinkEngine::GenerateQuestSaylink(
|
||||||
StringFormat("#goto %s", player_name.c_str()), false, "Goto"
|
fmt::format(
|
||||||
|
"#goto {}",
|
||||||
|
player_name
|
||||||
|
),
|
||||||
|
false,
|
||||||
|
"Goto"
|
||||||
|
);
|
||||||
|
|
||||||
|
auto summon_saylink = EQ::SayLinkEngine::GenerateQuestSaylink(
|
||||||
|
fmt::format(
|
||||||
|
"#summon {}",
|
||||||
|
player_name
|
||||||
|
),
|
||||||
|
false,
|
||||||
|
"Summon"
|
||||||
);
|
);
|
||||||
|
|
||||||
std::string display_class_name = GetClassIDName(
|
std::string display_class_name = GetClassIDName(
|
||||||
static_cast<uint8>(player_class),
|
static_cast<uint8>(player_class),
|
||||||
static_cast<uint8>(player_level));
|
static_cast<uint8>(player_level)
|
||||||
|
);
|
||||||
|
|
||||||
c->Message(
|
auto class_saylink = EQ::SayLinkEngine::GenerateQuestSaylink(
|
||||||
5, "%s[%u %s] %s (%s) %s ZONE: %s (%u) (%s) (%s) (%s)",
|
fmt::format(
|
||||||
(account_status > 0 ? "* GM * " : ""),
|
"#who {}",
|
||||||
player_level,
|
base_class_name
|
||||||
EQ::SayLinkEngine::GenerateQuestSaylink(
|
),
|
||||||
StringFormat("#who %s", base_class_name.c_str()),
|
|
||||||
false,
|
false,
|
||||||
display_class_name
|
display_class_name
|
||||||
).c_str(),
|
);
|
||||||
player_name.c_str(),
|
|
||||||
EQ::SayLinkEngine::GenerateQuestSaylink(
|
auto race_saylink = EQ::SayLinkEngine::GenerateQuestSaylink(
|
||||||
StringFormat("#who %s", displayed_race_name.c_str()),
|
fmt::format(
|
||||||
|
"#who %s",
|
||||||
|
displayed_race_name
|
||||||
|
),
|
||||||
false,
|
false,
|
||||||
displayed_race_name
|
displayed_race_name
|
||||||
).c_str(),
|
);
|
||||||
displayed_guild_name.c_str(),
|
|
||||||
EQ::SayLinkEngine::GenerateQuestSaylink(
|
auto zone_saylink = EQ::SayLinkEngine::GenerateQuestSaylink(
|
||||||
StringFormat("#who %s", zone_short_name.c_str()),
|
fmt::format(
|
||||||
false,
|
"#who {}",
|
||||||
zone_short_name
|
zone_short_name
|
||||||
).c_str(),
|
),
|
||||||
zone_instance,
|
false,
|
||||||
goto_saylink.c_str(),
|
zone_long_name
|
||||||
EQ::SayLinkEngine::GenerateQuestSaylink(
|
);
|
||||||
StringFormat("#who %s", account_name.c_str()),
|
|
||||||
|
auto account_saylink = EQ::SayLinkEngine::GenerateQuestSaylink(
|
||||||
|
fmt::format(
|
||||||
|
"#who {}",
|
||||||
|
account_name
|
||||||
|
),
|
||||||
false,
|
false,
|
||||||
account_name
|
account_name
|
||||||
).c_str(),
|
);
|
||||||
EQ::SayLinkEngine::GenerateQuestSaylink(
|
|
||||||
StringFormat("#who %s", account_ip.c_str()),
|
auto account_ip_saylink = EQ::SayLinkEngine::GenerateQuestSaylink(
|
||||||
|
fmt::format(
|
||||||
|
"#who {}",
|
||||||
|
account_ip
|
||||||
|
),
|
||||||
false,
|
false,
|
||||||
account_ip
|
account_ip
|
||||||
|
);
|
||||||
|
|
||||||
|
auto status_level = (
|
||||||
|
account_status ?
|
||||||
|
fmt::format(
|
||||||
|
"* {} * ",
|
||||||
|
EQ::constants::GetAccountStatusName(account_status)
|
||||||
|
) :
|
||||||
|
""
|
||||||
|
);
|
||||||
|
|
||||||
|
auto version_string = (
|
||||||
|
zone_instance ?
|
||||||
|
fmt::format(
|
||||||
|
" ({})",
|
||||||
|
zone_instance
|
||||||
|
) :
|
||||||
|
""
|
||||||
|
);
|
||||||
|
|
||||||
|
c->Message(
|
||||||
|
Chat::Who,
|
||||||
|
fmt::format(
|
||||||
|
"{}[{} {} ({})] {} ({}) ({}) ({}) {} ZONE: {}{} ({} | {})",
|
||||||
|
status_level,
|
||||||
|
player_level,
|
||||||
|
class_saylink,
|
||||||
|
base_class_name,
|
||||||
|
player_name,
|
||||||
|
race_saylink,
|
||||||
|
account_saylink,
|
||||||
|
account_ip_saylink,
|
||||||
|
displayed_guild_name,
|
||||||
|
zone_saylink,
|
||||||
|
version_string,
|
||||||
|
goto_saylink,
|
||||||
|
summon_saylink
|
||||||
).c_str()
|
).c_str()
|
||||||
);
|
);
|
||||||
|
|
||||||
found_count++;
|
found_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string count_string = found_count == 1 ? "is" : "are";
|
||||||
|
|
||||||
std::string message = (
|
std::string message = (
|
||||||
found_count > 0 ?
|
found_count ?
|
||||||
StringFormat("There is %i player(s) in EverQuest", found_count).c_str() :
|
fmt::format(
|
||||||
"There are no players in EverQuest that match those who filters."
|
"There {} {} player{} in EverQuest.",
|
||||||
|
count_string,
|
||||||
|
found_count,
|
||||||
|
found_count > 1 ? "s" : ""
|
||||||
|
) :
|
||||||
|
"There are no players in EverQuest that match those filters."
|
||||||
);
|
);
|
||||||
|
|
||||||
c->Message(Chat::Magenta, message.c_str());
|
c->Message(
|
||||||
|
Chat::Who,
|
||||||
|
message.c_str()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user