mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-05 18:24:12 +00:00
Efficiency and naming changes.
This commit is contained in:
@@ -288,7 +288,7 @@ void ClientPackets::HandleChatModerationRequest(const SystemAddress& sysAddr, Pa
|
||||
}
|
||||
|
||||
if (!receiver.empty()) {
|
||||
if (std::string(receiver.c_str(), 4) == "[GM]") {
|
||||
if (std::string(receiver.c_str(), 4) == "[GM]") { // Shift the string forward if we are speaking to a GM as the client appends "[GM]" if they are
|
||||
receiver = std::string(receiver.c_str() + 4, receiver.size() - 4);
|
||||
}
|
||||
}
|
||||
@@ -315,6 +315,9 @@ void ClientPackets::HandleChatModerationRequest(const SystemAddress& sysAddr, Pa
|
||||
if (res->next()) {
|
||||
idOfReceiver = res->getInt("id");
|
||||
}
|
||||
|
||||
delete stmt;
|
||||
delete res;
|
||||
}
|
||||
|
||||
if (user->GetIsBestFriendMap().find(receiver) == user->GetIsBestFriendMap().end() && idOfReceiver != LWOOBJID_EMPTY) {
|
||||
@@ -344,26 +347,14 @@ void ClientPackets::HandleChatModerationRequest(const SystemAddress& sysAddr, Pa
|
||||
}
|
||||
}
|
||||
|
||||
std::unordered_map<char, char> unacceptedItems;
|
||||
std::vector<std::string> segments = Game::chatFilter->IsSentenceOkay(message, entity->GetGMLevel(), !(isBestFriend && chatLevel == 1));
|
||||
std::vector<std::pair<uint8_t, uint8_t>> segments = Game::chatFilter->IsSentenceOkay(message, entity->GetGMLevel(), !(isBestFriend && chatLevel == 1));
|
||||
|
||||
bool bAllClean = segments.empty();
|
||||
|
||||
if (!bAllClean) {
|
||||
for (const auto& item : segments) {
|
||||
if (item == "") {
|
||||
unacceptedItems.insert({ (char)0, (char)message.length()});
|
||||
break;
|
||||
}
|
||||
|
||||
unacceptedItems.insert({ message.find(item), item.length() });
|
||||
}
|
||||
}
|
||||
|
||||
if (user->GetIsMuted()) {
|
||||
bAllClean = false;
|
||||
}
|
||||
|
||||
user->SetLastChatMessageApproved(bAllClean);
|
||||
WorldPackets::SendChatModerationResponse(sysAddr, bAllClean, requestID, receiver, unacceptedItems);
|
||||
WorldPackets::SendChatModerationResponse(sysAddr, bAllClean, requestID, receiver, segments);
|
||||
}
|
||||
|
@@ -188,28 +188,28 @@ void WorldPackets::SendCreateCharacter(const SystemAddress& sysAddr, Entity* ent
|
||||
Game::logger->Log("WorldPackets", "Sent CreateCharacter for ID: %llu\n", entity->GetObjectID());
|
||||
}
|
||||
|
||||
void WorldPackets::SendChatModerationResponse(const SystemAddress& sysAddr, bool requestAccepted, uint32_t requestID, const std::string& receiver, std::unordered_map<char, char> unacceptedItems) {
|
||||
CBITSTREAM
|
||||
PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_CHAT_MODERATION_STRING);
|
||||
void WorldPackets::SendChatModerationResponse(const SystemAddress& sysAddr, bool requestAccepted, uint32_t requestID, const std::string& receiver, std::vector<std::pair<uint8_t, uint8_t>> unacceptedItems) {
|
||||
CBITSTREAM
|
||||
PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_CHAT_MODERATION_STRING);
|
||||
|
||||
bitStream.Write<uint8_t>(unacceptedItems.empty()); // Is sentence ok?
|
||||
bitStream.Write<uint16_t>(0x16); // Source ID, unknown
|
||||
|
||||
bitStream.Write(static_cast<uint8_t>(requestID)); // request ID
|
||||
bitStream.Write(static_cast<char>(0)); // chat mode
|
||||
bitStream.Write(static_cast<char>(0)); // chat mode
|
||||
|
||||
PacketUtils::WritePacketWString(receiver, 42, &bitStream); // receiver name
|
||||
|
||||
for (auto it : unacceptedItems) {
|
||||
bitStream.Write<uint8_t>(it.first); // start index
|
||||
bitStream.Write<uint8_t>(it.second); // length
|
||||
}
|
||||
for (auto it : unacceptedItems) {
|
||||
bitStream.Write<uint8_t>(it.first); // start index
|
||||
bitStream.Write<uint8_t>(it.second); // length
|
||||
}
|
||||
|
||||
for (int i = unacceptedItems.size(); 64 > i; i++) {
|
||||
bitStream.Write<uint16_t>(0);
|
||||
}
|
||||
|
||||
SEND_PACKET
|
||||
SEND_PACKET
|
||||
}
|
||||
|
||||
void WorldPackets::SendGMLevelChange(const SystemAddress& sysAddr, bool success, uint8_t highestLevel, uint8_t prevLevel, uint8_t newLevel) {
|
||||
|
@@ -18,7 +18,7 @@ namespace WorldPackets {
|
||||
void SendTransferToWorld(const SystemAddress& sysAddr, const std::string& serverIP, uint32_t serverPort, bool mythranShift);
|
||||
void SendServerState(const SystemAddress& sysAddr);
|
||||
void SendCreateCharacter(const SystemAddress& sysAddr, Entity* entity, const std::string& xmlData, const std::u16string& username, int32_t gm);
|
||||
void SendChatModerationResponse(const SystemAddress& sysAddr, bool requestAccepted, uint32_t requestID, const std::string& receiver, std::unordered_map<char, char> unacceptedItems);
|
||||
void SendChatModerationResponse(const SystemAddress& sysAddr, bool requestAccepted, uint32_t requestID, const std::string& receiver, std::vector<std::pair<uint8_t, uint8_t>> unacceptedItems);
|
||||
void SendGMLevelChange(const SystemAddress& sysAddr, bool success, uint8_t highestLevel, uint8_t prevLevel, uint8_t newLevel);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user