Dedicated bcast monitor event

This commit is contained in:
Gent Semaj 2025-01-02 17:18:53 -05:00
parent 36e0667ed2
commit b4ed31d4fb
Signed by untrusted user: ycc
GPG Key ID: 2D76C57BF6BEADC4
3 changed files with 17 additions and 3 deletions

View File

@ -9,6 +9,7 @@
#include <assert.h>
std::vector<std::string> Chat::dump;
std::vector<std::string> Chat::bcasts;
using namespace Chat;
@ -120,9 +121,12 @@ static void announcementHandler(CNSocket* sock, CNPacketData* data) {
break;
}
std::string logLine = "[Bcast " + std::to_string(announcement->iAreaType) + "] " + PlayerManager::getPlayerName(plr, false) + ": " + AUTOU16TOU8(msg.szAnnounceMsg);
std::cout << logLine << std::endl;
dump.push_back("**" + logLine + "**");
std::string logLine = std::to_string(announcement->iAreaType) + " "
+ std::to_string(announcement->iAnnounceType) + " "
+ std::to_string(announcement->iDuringTime) + " "
+ PlayerManager::getPlayerName(plr, false) + ": " + AUTOU16TOU8(msg.szAnnounceMsg);
std::cout << "Broadcast " << logLine << std::endl;
bcasts.push_back(logLine);
}
// Buddy freechatting

View File

@ -9,6 +9,7 @@
namespace Chat {
extern std::vector<std::string> dump;
extern std::vector<std::string> bcasts;
void init();
void sendServerMessage(CNSocket* sock, std::string msg); // uses MOTD

View File

@ -106,6 +106,14 @@ outer:
goto outer;
}
// announcements
for (auto& str : Chat::bcasts) {
n = std::snprintf(buff, sizeof(buff), "bcast %s\n", str.c_str());
if (!transmit(it, buff, n))
goto outer;
}
// emails
for (auto& str : Email::dump) {
n = process_email(buff, str);
@ -124,6 +132,7 @@ outer:
}
Chat::dump.clear();
Chat::bcasts.clear();
Email::dump.clear();
}