mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2025-12-18 18:50:58 +00:00
Chat strings are now sanitized.
* Only plain, printable ASCII is allowed for now. * Local chat is now printed to the server console, but group chat is still private * Added a helper function to print character names and IDs
This commit is contained in:
@@ -58,7 +58,7 @@ void PlayerManager::addPlayer(CNSocket* key, Player plr) {
|
||||
|
||||
key->plr = p;
|
||||
|
||||
std::cout << U16toU8(plr.PCStyle.szFirstName) << " " << U16toU8(plr.PCStyle.szLastName) << " has joined!" << std::endl;
|
||||
std::cout << getPlayerName(p) << " has joined!" << std::endl;
|
||||
std::cout << players.size() << " players" << std::endl;
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ void PlayerManager::removePlayer(CNSocket* key) {
|
||||
if (ChunkManager::chunks.find(view.chunkPos) != ChunkManager::chunks.end())
|
||||
ChunkManager::chunks[view.chunkPos]->players.erase(key);
|
||||
|
||||
std::cout << U16toU8(view.plr->PCStyle.szFirstName) << " " << U16toU8(view.plr->PCStyle.szLastName) << " (PlayerId = " << view.plr->iID << ") has left!" << std::endl;
|
||||
std::cout << getPlayerName(key->plr) << " has left!" << std::endl;
|
||||
|
||||
key->plr = nullptr;
|
||||
delete view.plr;
|
||||
@@ -945,6 +945,19 @@ Player *PlayerManager::getPlayer(CNSocket* key) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::string PlayerManager::getPlayerName(Player *plr, bool id) {
|
||||
// the print in CNShardServer can print packets from players that haven't yet joined
|
||||
if (plr == nullptr)
|
||||
return "NOT IN GAME";
|
||||
|
||||
std::string ret = U16toU8(plr->PCStyle.szFirstName) + " " + U16toU8(plr->PCStyle.szLastName);
|
||||
|
||||
if (id)
|
||||
ret += " [" + std::to_string(plr->iID) + "]";
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
WarpLocation PlayerManager::getRespawnPoint(Player *plr) {
|
||||
WarpLocation best;
|
||||
uint32_t curDist, bestDist = UINT32_MAX;
|
||||
|
||||
Reference in New Issue
Block a user