diff --git a/src/servers/CNLoginServer.cpp b/src/servers/CNLoginServer.cpp index 6a26e81..028eaa2 100644 --- a/src/servers/CNLoginServer.cpp +++ b/src/servers/CNLoginServer.cpp @@ -1,4 +1,5 @@ #include "servers/CNLoginServer.hpp" +#include "servers/Monitor.hpp" #include "core/CNShared.hpp" #include "db/Database.hpp" @@ -312,6 +313,16 @@ void CNLoginServer::nameSave(CNSocket* sock, CNPacketData* data) { std::cout << "[WARN] Login Server: Database failed to create new character!" << std::endl; return invalidCharacter(sock); } + + Player plr; + Database::getPlayer(&plr, (int)resp.iPC_UID); + + // fire name check event if needed + if (plr.PCStyle.iNameCheck == 0) { + std::string namereq = std::to_string(resp.iPC_UID) + " " + AUTOU16TOU8(save->szFirstName) + " " + AUTOU16TOU8(save->szLastName); + Monitor::namereqs.push_back(namereq); + } + resp.iSlotNum = save->iSlotNum; resp.iGender = save->iGender; @@ -327,7 +338,9 @@ void CNLoginServer::nameSave(CNSocket* sock, CNPacketData* data) { DEBUGLOG( std::cout << "Login Server: new character created" << std::endl; std::cout << "\tSlot: " << (int)save->iSlotNum << std::endl; - std::cout << "\tName: " << AUTOU16TOU8(save->szFirstName) << " " << AUTOU16TOU8(save->szLastName) << std::endl; + std::cout << "\tName: " << AUTOU16TOU8(save->szFirstName) << " " << AUTOU16TOU8(save->szLastName); + if (plr.PCStyle.iNameCheck == 0) std::cout << " (pending approval)"; + std::cout << std::endl; ) } diff --git a/src/servers/Monitor.cpp b/src/servers/Monitor.cpp index 231b0c5..7a43480 100644 --- a/src/servers/Monitor.cpp +++ b/src/servers/Monitor.cpp @@ -17,6 +17,7 @@ static sockaddr_in address; std::vector Monitor::chats; std::vector Monitor::bcasts; std::vector Monitor::emails; +std::vector Monitor::namereqs; using namespace Monitor; @@ -131,6 +132,14 @@ outer: goto outer; } + // name requests + for (auto& str : namereqs) { + n = std::snprintf(buff, sizeof(buff), "namereq %s\n", str.c_str()); + + if (!transmit(it, buff, n)) + goto outer; + } + if (!transmit(it, (char*)"end\n", 4)) continue; @@ -140,6 +149,7 @@ outer: chats.clear(); bcasts.clear(); emails.clear(); + namereqs.clear(); } bool Monitor::acceptConnection(SOCKET fd, uint16_t revents) { diff --git a/src/servers/Monitor.hpp b/src/servers/Monitor.hpp index e905700..5ecab2b 100644 --- a/src/servers/Monitor.hpp +++ b/src/servers/Monitor.hpp @@ -6,6 +6,7 @@ namespace Monitor { extern std::vector chats; extern std::vector bcasts; extern std::vector emails; + extern std::vector namereqs; SOCKET init(); bool acceptConnection(SOCKET, uint16_t);