mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-05 06:50:04 +00:00
Add chat dump to monitor
This commit is contained in:
parent
792a317b48
commit
d03c4f109f
@ -14,6 +14,7 @@
|
||||
#include <math.h>
|
||||
|
||||
std::map<std::string, ChatCommand> ChatManager::commands;
|
||||
std::vector<std::string> ChatManager::dump;
|
||||
|
||||
std::vector<std::string> parseArgs(std::string full) {
|
||||
std::stringstream ss(full);
|
||||
@ -815,6 +816,7 @@ void ChatManager::chatHandler(CNSocket* sock, CNPacketData* data) {
|
||||
std::string fullChat = sanitizeText(U16toU8(chat->szFreeChat));
|
||||
|
||||
std::cout << "[FreeChat] " << PlayerManager::getPlayerName(plr, false) << ": " << fullChat << std::endl;
|
||||
dump.push_back(PlayerManager::getPlayerName(plr, true) + ": " + fullChat);
|
||||
|
||||
if (fullChat.length() > 1 && fullChat[0] == CMD_PREFIX) { // PREFIX
|
||||
runCmd(fullChat, sock);
|
||||
@ -844,6 +846,7 @@ void ChatManager::menuChatHandler(CNSocket* sock, CNPacketData* data) {
|
||||
std::string fullChat = sanitizeText(U16toU8(chat->szFreeChat));
|
||||
|
||||
std::cout << "[MenuChat] " << PlayerManager::getPlayerName(plr, false) << ": " << fullChat << std::endl;
|
||||
dump.push_back(PlayerManager::getPlayerName(plr, true) + ": " + fullChat);
|
||||
|
||||
// send to client
|
||||
INITSTRUCT(sP_FE2CL_REP_SEND_MENUCHAT_MESSAGE_SUCC, resp);
|
||||
@ -921,6 +924,7 @@ void ChatManager::announcementHandler(CNSocket* sock, CNPacketData* data) {
|
||||
}
|
||||
|
||||
std::cout << "[Bcast " << announcement->iAreaType << "] " << PlayerManager::getPlayerName(plr, false) << ": " << U16toU8(msg.szAnnounceMsg) << std::endl;
|
||||
dump.push_back("**" + PlayerManager::getPlayerName(plr, true) + ": " + U16toU8(msg.szAnnounceMsg) + "**");
|
||||
}
|
||||
|
||||
// we only allow plain ascii, at least for now
|
||||
|
@ -18,6 +18,7 @@ struct ChatCommand {
|
||||
|
||||
namespace ChatManager {
|
||||
extern std::map<std::string, ChatCommand> commands;
|
||||
extern std::vector<std::string> dump;
|
||||
void init();
|
||||
|
||||
void registerCommand(std::string cmd, int requiredLevel, CommandHandler handlr, std::string help = "");
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "CNShardServer.hpp"
|
||||
#include "PlayerManager.hpp"
|
||||
#include "ChatManager.hpp"
|
||||
#include "CNStructs.hpp"
|
||||
#include "Monitor.hpp"
|
||||
#include "settings.hpp"
|
||||
@ -102,6 +103,7 @@ outer:
|
||||
if (!transmit(it, (char*)"begin\n", 6))
|
||||
continue;
|
||||
|
||||
// player
|
||||
for (auto& pair : PlayerManager::players) {
|
||||
if (pair.second->hidden)
|
||||
continue;
|
||||
@ -114,11 +116,21 @@ outer:
|
||||
goto outer;
|
||||
}
|
||||
|
||||
// chat
|
||||
for (auto& str : ChatManager::dump) {
|
||||
n = std::snprintf(buff, sizeof(buff), "chat %s\n", str.c_str());
|
||||
|
||||
if (!transmit(it, buff, n))
|
||||
goto outer;
|
||||
}
|
||||
|
||||
if (!transmit(it, (char*)"end\n", 4))
|
||||
continue;
|
||||
|
||||
it++;
|
||||
}
|
||||
|
||||
ChatManager::dump.clear();
|
||||
}
|
||||
|
||||
bool Monitor::acceptConnection(SOCKET fd, uint16_t revents) {
|
||||
|
Loading…
Reference in New Issue
Block a user