mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 12:41:30 +00:00
[Cleanup] Cleanup #show ip_lookup Message (#5005)
* [Cleanup] Cleanup #show ip_lookup Message * Test * Update clientlist.cpp
This commit is contained in:
parent
0c65a4febe
commit
822a5dcac4
@ -281,62 +281,107 @@ ClientListEntry* ClientList::FindCLEByCharacterID(uint32 iCharID) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ClientList::SendCLEList(const int16& admin, const char* to, WorldTCPConnection* connection, const char* iName) {
|
||||
void ClientList::SendCLEList(const int16& admin, const char* to, WorldTCPConnection* connection, const char* search_criteria)
|
||||
{
|
||||
LinkedListIterator<ClientListEntry*> iterator(clientlist);
|
||||
int x = 0, y = 0;
|
||||
int namestrlen = iName == 0 ? 0 : strlen(iName);
|
||||
bool addnewline = false;
|
||||
char newline[3];
|
||||
if (connection->IsConsole())
|
||||
strcpy(newline, "\r\n");
|
||||
else
|
||||
strcpy(newline, "^");
|
||||
|
||||
auto out = fmt::memory_buffer();
|
||||
int found_count = 0;
|
||||
int total_count = 0;
|
||||
int name_length = search_criteria ? strlen(search_criteria) : 0;
|
||||
|
||||
const char* new_line = connection->IsConsole() ? "\r\n" : "^";
|
||||
bool add_new_line = false;
|
||||
|
||||
std::string message;
|
||||
|
||||
iterator.Reset();
|
||||
while(iterator.MoreElements()) {
|
||||
|
||||
while (iterator.MoreElements()) {
|
||||
ClientListEntry* cle = iterator.GetData();
|
||||
if (admin >= cle->Admin() && (iName == 0 || namestrlen == 0 || strncasecmp(cle->name(), iName, namestrlen) == 0 || strncasecmp(cle->AccountName(), iName, namestrlen) == 0 || strncasecmp(cle->LSName(), iName, namestrlen) == 0)) {
|
||||
struct in_addr in;
|
||||
in.s_addr = cle->GetIP();
|
||||
if (addnewline) {
|
||||
fmt::format_to(std::back_inserter(out), fmt::runtime(newline));
|
||||
|
||||
struct in_addr in;
|
||||
in.s_addr = cle->GetIP();
|
||||
|
||||
if (
|
||||
admin >= cle->Admin() &&
|
||||
(
|
||||
!search_criteria ||
|
||||
Strings::Contains(std::string(inet_ntoa(in)), search_criteria) ||
|
||||
Strings::Contains(cle->name(), search_criteria) == 0 ||
|
||||
Strings::Contains(cle->AccountName(), search_criteria) == 0 ||
|
||||
Strings::Contains(cle->LSName(), search_criteria) == 0
|
||||
)
|
||||
) {
|
||||
if (add_new_line) {
|
||||
message += new_line;
|
||||
}
|
||||
fmt::format_to(std::back_inserter(out), "ID: {} Acc# {} AccName: {} IP: {}", cle->GetID(), cle->AccountID(), cle->AccountName(), inet_ntoa(in));
|
||||
fmt::format_to(std::back_inserter(out), "{} Stale: {} Online: {} Admin: {}", newline, cle->GetStaleCounter(), static_cast<int>(cle->Online()), cle->Admin());
|
||||
if (cle->LSID())
|
||||
fmt::format_to(std::back_inserter(out), "{} LSID: {} LSName: {} WorldAdmin: {}", newline, cle->LSID(), cle->LSName(), cle->WorldAdmin());
|
||||
if (cle->CharID())
|
||||
fmt::format_to(std::back_inserter(out), "{} CharID: {} CharName: {} Zone: {} ({})", newline, cle->CharID(), cle->name(), ZoneName(cle->zone()), cle->zone());
|
||||
if (out.size() >= 3072) {
|
||||
|
||||
message += fmt::format(
|
||||
"Account: {} ({}) | IP: {} | Admin: {}",
|
||||
cle->AccountName(),
|
||||
cle->AccountID(),
|
||||
inet_ntoa(in),
|
||||
cle->Admin()
|
||||
);
|
||||
|
||||
if (cle->CharID()) {
|
||||
message += fmt::format(
|
||||
"{}Character: {} ({}) | Zone: {} ({})",
|
||||
new_line,
|
||||
cle->name(),
|
||||
cle->CharID(),
|
||||
ZoneLongName(cle->zone()),
|
||||
cle->zone()
|
||||
);
|
||||
}
|
||||
|
||||
if (message.size() >= 3072) {
|
||||
connection->SendEmoteMessageRaw(
|
||||
to,
|
||||
0,
|
||||
AccountStatus::Player,
|
||||
Chat::NPCQuestSay,
|
||||
out.data()
|
||||
message.c_str()
|
||||
);
|
||||
addnewline = false;
|
||||
out.clear();
|
||||
message.clear();
|
||||
add_new_line = false;
|
||||
} else {
|
||||
addnewline = true;
|
||||
add_new_line = true;
|
||||
}
|
||||
y++;
|
||||
|
||||
found_count++;
|
||||
}
|
||||
|
||||
iterator.Advance();
|
||||
x++;
|
||||
total_count++;
|
||||
}
|
||||
fmt::format_to(std::back_inserter(out), "{}{} CLEs in memory. {} CLEs listed. numplayers = {}.", newline, x, y, numplayers);
|
||||
|
||||
message += fmt::format(
|
||||
"{}{}Player Count: {}",
|
||||
new_line,
|
||||
(
|
||||
found_count != total_count ?
|
||||
fmt::format(
|
||||
"Total: {} CLE{} | Found: {} CLE{} | ",
|
||||
total_count,
|
||||
(total_count != 1 ? "s" : ""),
|
||||
found_count,
|
||||
(found_count != 1 ? "s" : "")
|
||||
) :
|
||||
""
|
||||
),
|
||||
numplayers
|
||||
);
|
||||
|
||||
connection->SendEmoteMessageRaw(
|
||||
to,
|
||||
0,
|
||||
AccountStatus::Player,
|
||||
Chat::NPCQuestSay,
|
||||
out.data()
|
||||
message.c_str()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
void ClientList::CLEAdd(
|
||||
uint32 login_server_id,
|
||||
const char *login_server_name,
|
||||
|
||||
@ -45,7 +45,7 @@ public:
|
||||
void SendClientVersionSummary(const char *Name);
|
||||
void SendLFGMatches(ServerLFGMatchesRequest_Struct *LFGMatchesRequest);
|
||||
void ConsoleSendWhoAll(const char* to, int16 admin, Who_All_Struct* whom, WorldTCPConnection* connection);
|
||||
void SendCLEList(const int16& admin, const char* to, WorldTCPConnection* connection, const char* iName = 0);
|
||||
void SendCLEList(const int16& admin, const char* to, WorldTCPConnection* connection, const char* search_criteria = 0);
|
||||
|
||||
bool SendPacket(const char* to, ServerPacket* pack);
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ void ShowIPLookup(Client *c, const Seperator *sep)
|
||||
|
||||
auto pack = new ServerPacket(
|
||||
ServerOP_IPLookup,
|
||||
sizeof(ServerGenericWorldQuery_Struct) + ip_length + 1
|
||||
sizeof(ServerGenericWorldQuery_Struct) + ip_length
|
||||
);
|
||||
|
||||
auto s = (ServerGenericWorldQuery_Struct *) pack->pBuffer;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user