From e2610df50227a5f47ba5a4289f144c04268d6fb3 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Sat, 23 Oct 2010 04:00:39 +0000 Subject: [PATCH] - fixed chatting logic to now retain more info about the user that sent the text in the console manager. Colors now apply to the playername and changing playernames is ok in the lobby andf rendering accounts for this (as well as switching slots) --- source/glest_game/game/chat_manager.cpp | 5 +- source/glest_game/game/console.cpp | 49 +++++++++++++++++-- source/glest_game/game/console.h | 27 +++++----- source/glest_game/game/game_settings.h | 10 ++++ source/glest_game/graphics/renderer.cpp | 44 ++++++++--------- source/glest_game/graphics/renderer.h | 4 +- .../menu/menu_state_custom_game.cpp | 3 +- .../glest_game/network/client_interface.cpp | 12 +++-- source/glest_game/network/connection_slot.cpp | 2 +- source/glest_game/network/network_interface.h | 6 +-- source/glest_game/network/network_message.cpp | 14 +++--- source/glest_game/network/network_message.h | 9 ++-- .../glest_game/network/server_interface.cpp | 24 ++++----- 13 files changed, 132 insertions(+), 77 deletions(-) diff --git a/source/glest_game/game/chat_manager.cpp b/source/glest_game/game/chat_manager.cpp index 17998eff..1d00e640 100644 --- a/source/glest_game/game/chat_manager.cpp +++ b/source/glest_game/game/chat_manager.cpp @@ -119,7 +119,7 @@ void ChatManager::keyDown(char key) { if(text.empty() == false) { string playerName = gameNetworkInterface->getHumanPlayerName(); int playerIndex = gameNetworkInterface->getHumanPlayerIndex(); - console->addLine(playerName + ": " + text,false,playerIndex); + console->addLine(text,false,playerIndex); gameNetworkInterface->sendTextMessage(text, teamMode? thisTeamIndex: -1); if(inMenu == false) { @@ -187,7 +187,8 @@ void ChatManager::updateNetwork() { SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] got nmtText [%s] for team = %d\n",__FILE__,__FUNCTION__,msg.chatText.c_str(),teamIndex); if(teamIndex == -1 || teamIndex == thisTeamIndex) { - console->addLine(msg.chatSender + ": " + msg.chatText, true, msg.chatPlayerIndex); + //console->addLine(msg.chatSender + ": " + msg.chatText, true, msg.chatPlayerIndex); + console->addLine(msg.chatText, true, msg.chatPlayerIndex); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Added text to console\n",__FILE__,__FUNCTION__); } diff --git a/source/glest_game/game/console.cpp b/source/glest_game/game/console.cpp index ef619dfd..64291056 100644 --- a/source/glest_game/game/console.cpp +++ b/source/glest_game/game/console.cpp @@ -18,6 +18,7 @@ #include "sound_renderer.h" #include "core_data.h" #include +#include "network_manager.h" #include "leak_dumper.h" using namespace std; @@ -45,11 +46,27 @@ void Console::addLine(string line, bool playSound, int playerIndex) { if(playSound == true) { SoundRenderer::getInstance().playFx(CoreData::getInstance().getClickSoundA()); } - lines.insert(lines.begin(), StringTimePair(line, StringTimePairData(timeElapsed,playerIndex))); + ConsoleLineInfo info; + info.text = line; + info.timeStamp = timeElapsed; + info.PlayerIndex = playerIndex; + info.originalPlayerName = ""; + if(playerIndex >= 0) { + GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface(); + if(gameNetworkInterface != NULL) { + info.originalPlayerName = gameNetworkInterface->getGameSettings()->getNetworkPlayerNameByPlayerIndex(playerIndex); + //for(int i = 0; i < GameConstants::maxPlayers; ++i) { + // printf("i = %d, playerName = [%s]\n",i,gameNetworkInterface->getGameSettings()->getNetworkPlayerName(i).c_str()); + //} + } + } + //printf("info.PlayerIndex = %d, line [%s]\n",info.PlayerIndex,info.originalPlayerName.c_str()); + + lines.insert(lines.begin(), info); if(lines.size() > maxLines) { lines.pop_back(); } - storedLines.insert(storedLines.begin(), StringTimePair(line, StringTimePairData(timeElapsed,playerIndex))); + storedLines.insert(storedLines.begin(), info); if(storedLines.size() > maxStoredLines) { storedLines.pop_back(); } @@ -72,7 +89,7 @@ void Console::update() { timeElapsed += 1.f / GameConstants::updateFps; if(lines.empty() == false) { - if(lines.back().second.first < (timeElapsed - timeout)) { + if(lines.back().timeStamp < (timeElapsed - timeout)) { lines.pop_back(); } } @@ -81,6 +98,30 @@ void Console::update() { bool Console::isEmpty() { return lines.empty(); } - + +string Console::getLine(int i) const { + if(i < 0 || i >= lines.size()) + throw runtime_error("i >= Lines.size()"); + return lines[i].text; +} + +string Console::getStoredLine(int i) const { + if(i < 0 || i >= storedLines.size()) + throw runtime_error("i >= storedLines.size()"); + return storedLines[i].text; +} + +ConsoleLineInfo Console::getLineItem(int i) const { + if(i < 0 || i >= lines.size()) + throw runtime_error("i >= Lines.size()"); + return lines[i]; +} + +ConsoleLineInfo Console::getStoredLineItem(int i) const { + if(i < 0 || i >= storedLines.size()) + throw runtime_error("i >= storedLines.size()"); + return storedLines[i]; +} + }}//end namespace diff --git a/source/glest_game/game/console.h b/source/glest_game/game/console.h index eb962f5e..2a38fda4 100644 --- a/source/glest_game/game/console.h +++ b/source/glest_game/game/console.h @@ -23,7 +23,7 @@ using std::vector; using std::pair; using namespace std; -namespace Glest{ namespace Game{ +namespace Glest { namespace Game { // ===================================================== // class Console @@ -31,15 +31,21 @@ namespace Glest{ namespace Game{ // In-game console that shows various types of messages // ===================================================== -class Console{ +class ConsoleLineInfo { +public: + string text; + float timeStamp; + int PlayerIndex; + string originalPlayerName; +}; + +class Console { private: static const int consoleLines= 5; public: - // The float is elapsed time, the int is playerindex (-1 is no player) - typedef pair StringTimePairData; - typedef pair StringTimePair; - typedef vector Lines; + + typedef vector Lines; typedef Lines::const_iterator LineIterator; private: @@ -57,11 +63,10 @@ public: int getStoredLineCount() const {return storedLines.size();} int getLineCount() const {return lines.size();} - string getLine(int i) const { if(i < 0 || i >= lines.size()) throw runtime_error("i >= Lines.size()"); return lines[i].first;} - string getStoredLine(int i) const { if(i < 0 || i >= storedLines.size()) throw runtime_error("i >= storedLines.size()"); return storedLines[i].first;} - - int getLinePlayerIndex(int i) const { if(i < 0 || i >= lines.size()) throw runtime_error("i >= Lines.size()"); return lines[i].second.second;} - int getStoredLinePlayerIndex(int i) const { if(i < 0 || i >= storedLines.size()) throw runtime_error("i >= storedLines.size()"); return storedLines[i].second.second;} + string getLine(int i) const; + string getStoredLine(int i) const; + ConsoleLineInfo getLineItem(int i) const; + ConsoleLineInfo getStoredLineItem(int i) const; void clearStoredLines(); void addStdMessage(const string &s); diff --git a/source/glest_game/game/game_settings.h b/source/glest_game/game/game_settings.h index b1f4fef7..27c3838f 100644 --- a/source/glest_game/game/game_settings.h +++ b/source/glest_game/game/game_settings.h @@ -89,6 +89,16 @@ public: const string &getScenarioDir() const {return scenarioDir;} const string &getFactionTypeName(int factionIndex) const {return factionTypeNames[factionIndex];} const string &getNetworkPlayerName(int factionIndex) const {return networkPlayerNames[factionIndex];} + const string getNetworkPlayerNameByPlayerIndex(int playerIndex) const { + string result = ""; + for(int i = 0; i < GameConstants::maxPlayers; ++i) { + if(startLocationIndex[i] == playerIndex) { + result = networkPlayerNames[i]; + break; + } + } + return result; + } ControlType getFactionControl(int factionIndex) const {return factionControls[factionIndex];} bool isNetworkGame() const { diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index d5af3b44..4f8fe1b8 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -787,7 +787,7 @@ void Renderer::renderTextureQuad(int x, int y, int w, int h, const Texture2D *te assertGl(); } -void Renderer::RenderConsoleLine(int lineIndex, string line,int playerIndex,int xPosition) { +void Renderer::RenderConsoleLine(int lineIndex, int xPosition, const ConsoleLineInfo *lineInfo) { Vec4f fontColor; if(game != NULL) { fontColor = game->getGui()->getDisplay()->getColor(); @@ -799,9 +799,9 @@ void Renderer::RenderConsoleLine(int lineIndex, string line,int playerIndex,int Vec4f defaultFontColor = fontColor; - if(playerIndex >= 0) { + if(lineInfo->PlayerIndex >= 0) { std::map &crcPlayerTextureCache = CacheManager::getCachedItem< std::map >(GameConstants::playerTextureCacheLookupKey); - Vec3f playerColor = crcPlayerTextureCache[playerIndex]->getPixmap()->getPixel3f(0, 0); + Vec3f playerColor = crcPlayerTextureCache[lineInfo->PlayerIndex]->getPixmap()->getPixel3f(0, 0); fontColor.x = playerColor.x; fontColor.y = playerColor.y; fontColor.z = playerColor.z; @@ -809,20 +809,22 @@ void Renderer::RenderConsoleLine(int lineIndex, string line,int playerIndex,int GameNetworkInterface *gameNetInterface = NetworkManager::getInstance().getGameNetworkInterface(); if(gameNetInterface != NULL && gameNetInterface->getGameSettings() != NULL) { const GameSettings *gameSettings = gameNetInterface->getGameSettings(); - string playerName = gameSettings->getNetworkPlayerName(playerIndex); - if(StartsWith(line, playerName + ":") == true) { - line = line.erase(0,playerName.length()+1); - string headerLine = "*" + playerName + ":"; + string playerName = gameSettings->getNetworkPlayerNameByPlayerIndex(lineInfo->PlayerIndex); + if(playerName != lineInfo->originalPlayerName && lineInfo->originalPlayerName != "") { + playerName = lineInfo->originalPlayerName; + } + //printf("playerName [%s], line [%s]\n",playerName.c_str(),line.c_str()); - renderTextShadow( + string headerLine = "*" + playerName + ":"; + + renderTextShadow( headerLine, CoreData::getInstance().getConsoleFont(), fontColor, xPosition, lineIndex * 20 + 20); - fontColor = defaultFontColor; - xPosition += (7 * (playerName.length() + 2)); - } + fontColor = defaultFontColor; + xPosition += (7 * (playerName.length() + 2)); } } else { @@ -830,7 +832,7 @@ void Renderer::RenderConsoleLine(int lineIndex, string line,int playerIndex,int } renderTextShadow( - line, + lineInfo->text, CoreData::getInstance().getConsoleFont(), fontColor, xPosition, lineIndex * 20 + 20); @@ -847,29 +849,23 @@ void Renderer::renderConsole(const Console *console,const bool showFullConsole,c if(showFullConsole) { for(int i = 0; i < console->getStoredLineCount(); ++i) { - string line = console->getStoredLine(i); - int playerIndex = console->getStoredLinePlayerIndex(i); int xPosition = 20; - - RenderConsoleLine(i, line,playerIndex,xPosition); + const ConsoleLineInfo &lineInfo = console->getStoredLineItem(i); + RenderConsoleLine(i, xPosition, &lineInfo); } } else if(showMenuConsole) { for(int i = 0; i < console->getStoredLineCount() && i < maxConsoleLines; ++i) { - string line = console->getStoredLine(i); - int playerIndex = console->getStoredLinePlayerIndex(i); int xPosition = 20; - - RenderConsoleLine(i, line,playerIndex,xPosition); + const ConsoleLineInfo &lineInfo = console->getStoredLineItem(i); + RenderConsoleLine(i, xPosition, &lineInfo); } } else { for(int i = 0; i < console->getLineCount(); ++i) { - string line = console->getLine(i); - int playerIndex = console->getLinePlayerIndex(i); int xPosition = 20; - - RenderConsoleLine(i, line,playerIndex,xPosition); + const ConsoleLineInfo &lineInfo = console->getLineItem(i); + RenderConsoleLine(i, xPosition, &lineInfo); } } glPopAttrib(); diff --git a/source/glest_game/graphics/renderer.h b/source/glest_game/graphics/renderer.h index 387da588..8b162b1b 100644 --- a/source/glest_game/graphics/renderer.h +++ b/source/glest_game/graphics/renderer.h @@ -68,7 +68,7 @@ class Console; class MenuBackground; class ChatManager; class Object; - +class ConsoleLineInfo; // =========================================================== // class Renderer // @@ -306,7 +306,7 @@ public: void renderBackground(const Texture2D *texture); void renderTextureQuad(int x, int y, int w, int h, const Texture2D *texture, float alpha=1.f,const Vec3f *color=NULL); void renderConsole(const Console *console, const bool showAll=false, const bool showMenuConsole=false); - void RenderConsoleLine(int lineIndex, string line,int playerIndex,int xPosition); + void RenderConsoleLine(int lineIndex, int xPosition, const ConsoleLineInfo *lineInfo); void renderChatManager(const ChatManager *chatManager); void renderResourceStatus(); void renderSelectionQuad(); diff --git a/source/glest_game/menu/menu_state_custom_game.cpp b/source/glest_game/menu/menu_state_custom_game.cpp index 7033fef3..9f79c37e 100644 --- a/source/glest_game/menu/menu_state_custom_game.cpp +++ b/source/glest_game/menu/menu_state_custom_game.cpp @@ -1772,6 +1772,7 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings) { SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] i = %d, slotIndex = %d, getHumanPlayerName(i) [%s]\n",__FILE__,__FUNCTION__,__LINE__,i,slotIndex,getHumanPlayerName(i).c_str()); gameSettings->setThisFactionIndex(slotIndex); + //gameSettings->setNetworkPlayerName(slotIndex, getHumanPlayerName(i)); gameSettings->setNetworkPlayerName(slotIndex, getHumanPlayerName(i)); //labelPlayerNames[i].setText(getHumanPlayerName(i)); //SetActivePlayerNameEditor(); @@ -2269,7 +2270,7 @@ void MenuStateCustomGame::updateNetworkSlots() { try { ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface(); - for(int i= 0; igetSlot(i) == NULL && listBoxControls[i].getSelectedItemIndex() == ctNetwork) { try { diff --git a/source/glest_game/network/client_interface.cpp b/source/glest_game/network/client_interface.cpp index 84b7f7c5..6c15861f 100755 --- a/source/glest_game/network/client_interface.cpp +++ b/source/glest_game/network/client_interface.cpp @@ -435,7 +435,7 @@ void ClientInterface::updateLobby() { { SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] got nmtText\n",__FILE__,__FUNCTION__); - ChatMsgInfo msg(networkMessageText.getText().c_str(),networkMessageText.getSender().c_str(),networkMessageText.getTeamIndex(),networkMessageText.getPlayerIndex()); + ChatMsgInfo msg(networkMessageText.getText().c_str(),networkMessageText.getTeamIndex(),networkMessageText.getPlayerIndex()); this->addChatInfo(msg); } } @@ -622,7 +622,7 @@ void ClientInterface::updateKeyframe(int frameCount) sleep(0); } - ChatMsgInfo msg(networkMessageText.getText().c_str(),networkMessageText.getSender().c_str(),networkMessageText.getTeamIndex(),networkMessageText.getPlayerIndex()); + ChatMsgInfo msg(networkMessageText.getText().c_str(),networkMessageText.getTeamIndex(),networkMessageText.getPlayerIndex()); this->addChatInfo(msg); } break; @@ -798,11 +798,13 @@ void ClientInterface::sendTextMessage(const string &text, int teamIndex, bool ec string humanPlayerName = getHumanPlayerName(); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] humanPlayerName = [%s] playerIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,humanPlayerName.c_str(),playerIndex); - NetworkMessageText networkMessageText(text, humanPlayerName, teamIndex,playerIndex); + //NetworkMessageText networkMessageText(text, humanPlayerName, teamIndex,playerIndex); + NetworkMessageText networkMessageText(text, teamIndex,playerIndex); sendMessage(&networkMessageText); if(echoLocal == true) { - ChatMsgInfo msg(networkMessageText.getText().c_str(),networkMessageText.getSender().c_str(),networkMessageText.getTeamIndex(),networkMessageText.getPlayerIndex()); + //ChatMsgInfo msg(networkMessageText.getText().c_str(),networkMessageText.getSender().c_str(),networkMessageText.getTeamIndex(),networkMessageText.getPlayerIndex()); + ChatMsgInfo msg(networkMessageText.getText().c_str(),networkMessageText.getTeamIndex(),networkMessageText.getPlayerIndex()); this->addChatInfo(msg); } @@ -960,7 +962,7 @@ bool ClientInterface::shouldDiscardNetworkMessage(NetworkMessageType networkMess NetworkMessageText netMsg = NetworkMessageText(); this->receiveMessage(&netMsg); - ChatMsgInfo msg(netMsg.getText().c_str(),netMsg.getSender().c_str(),netMsg.getTeamIndex(),netMsg.getPlayerIndex()); + ChatMsgInfo msg(netMsg.getText().c_str(),netMsg.getTeamIndex(),netMsg.getPlayerIndex()); this->addChatInfo(msg); } break; diff --git a/source/glest_game/network/connection_slot.cpp b/source/glest_game/network/connection_slot.cpp index 158c94a3..79132f46 100644 --- a/source/glest_game/network/connection_slot.cpp +++ b/source/glest_game/network/connection_slot.cpp @@ -311,7 +311,7 @@ void ConnectionSlot::update(bool checkForNewClients) { if(gotIntro == true) { NetworkMessageText networkMessageText; if(receiveMessage(&networkMessageText)) { - ChatMsgInfo msg(networkMessageText.getText().c_str(),networkMessageText.getSender().c_str(),networkMessageText.getTeamIndex(),networkMessageText.getPlayerIndex()); + ChatMsgInfo msg(networkMessageText.getText().c_str(),networkMessageText.getTeamIndex(),networkMessageText.getPlayerIndex()); this->addChatInfo(msg); gotTextMsg = true; diff --git a/source/glest_game/network/network_interface.h b/source/glest_game/network/network_interface.h index 1e01c98f..0f87b8fb 100644 --- a/source/glest_game/network/network_interface.h +++ b/source/glest_game/network/network_interface.h @@ -46,7 +46,6 @@ protected: void copyAll(const ChatMsgInfo &obj) { this->chatText = obj.chatText.c_str(); - this->chatSender = obj.chatSender.c_str(); this->chatTeamIndex = obj.chatTeamIndex; this->chatPlayerIndex = obj.chatPlayerIndex; } @@ -54,13 +53,11 @@ public: ChatMsgInfo() { this->chatText = ""; - this->chatSender = ""; this->chatTeamIndex = -1; this->chatPlayerIndex = -1; } - ChatMsgInfo(string chatText, string chatSender,int chatTeamIndex, int chatPlayerIndex) { + ChatMsgInfo(string chatText, int chatTeamIndex, int chatPlayerIndex) { this->chatText = chatText; - this->chatSender = chatSender; this->chatTeamIndex = chatTeamIndex; this->chatPlayerIndex = chatPlayerIndex; } @@ -73,7 +70,6 @@ public: } string chatText; - string chatSender; int chatTeamIndex; int chatPlayerIndex; diff --git a/source/glest_game/network/network_message.cpp b/source/glest_game/network/network_message.cpp index 2af9a153..9b744425 100644 --- a/source/glest_game/network/network_message.cpp +++ b/source/glest_game/network/network_message.cpp @@ -393,20 +393,20 @@ void NetworkMessageCommandList::send(Socket* socket) const{ // class NetworkMessageText // ===================================================== -NetworkMessageText::NetworkMessageText(const string &text, const string &sender, int teamIndex, int playerIndex) { - +//NetworkMessageText::NetworkMessageText(const string &text, const string &sender, int teamIndex, int playerIndex) { +NetworkMessageText::NetworkMessageText(const string &text, int teamIndex, int playerIndex) { if(text.length() >= maxTextStringSize) { SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] WARNING / ERROR - text [%s] length = %d, max = %d\n",__FILE__,__FUNCTION__,__LINE__,text.c_str(),text.length(),maxTextStringSize); //throw runtime_error("NetworkMessageText - text.length() >= maxStringSize"); } - if(sender.length() >= maxSenderStringSize) { - SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] WARNING / ERROR - sender [%s] length = %d, max = %d\n",__FILE__,__FUNCTION__,__LINE__,sender.c_str(),sender.length(),maxSenderStringSize); + //if(sender.length() >= maxSenderStringSize) { + // SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] WARNING / ERROR - sender [%s] length = %d, max = %d\n",__FILE__,__FUNCTION__,__LINE__,sender.c_str(),sender.length(),maxSenderStringSize); //throw runtime_error("NetworkMessageText - sender.length() >= maxSenderStringSize"); - } + //} data.messageType = nmtText; data.text = text; - data.sender = sender; + //data.sender = sender; data.teamIndex = teamIndex; data.playerIndex = playerIndex; } @@ -415,7 +415,7 @@ bool NetworkMessageText::receive(Socket* socket){ bool result = NetworkMessage::receive(socket, &data, sizeof(data)); data.text.nullTerminate(); - data.sender.nullTerminate(); + //data.sender.nullTerminate(); return result; } diff --git a/source/glest_game/network/network_message.h b/source/glest_game/network/network_message.h index 0f4f2fa9..93025603 100644 --- a/source/glest_game/network/network_message.h +++ b/source/glest_game/network/network_message.h @@ -285,13 +285,13 @@ public: class NetworkMessageText: public NetworkMessage { private: static const int maxTextStringSize= 340; - static const int maxSenderStringSize= 60; + //static const int maxSenderStringSize= 60; private: struct Data{ int8 messageType; NetworkString text; - NetworkString sender; + //NetworkString sender; int8 teamIndex; int8 playerIndex; }; @@ -301,10 +301,11 @@ private: public: NetworkMessageText(){} - NetworkMessageText(const string &text, const string &sender, int teamIndex, int playerIndex); + //NetworkMessageText(const string &text, const string &sender, int teamIndex, int playerIndex); + NetworkMessageText(const string &text, int teamIndex, int playerIndex); string getText() const {return data.text.getString();} - string getSender() const {return data.sender.getString();} + //string getSender() const {return data.sender.getString();} int getTeamIndex() const {return data.teamIndex;} int getPlayerIndex() const {return data.playerIndex;} diff --git a/source/glest_game/network/server_interface.cpp b/source/glest_game/network/server_interface.cpp index e619a6d3..f9d544ed 100644 --- a/source/glest_game/network/server_interface.cpp +++ b/source/glest_game/network/server_interface.cpp @@ -677,16 +677,16 @@ void ServerInterface::update() { this->addChatInfo(msg); string newChatText = msg.chatText.c_str(); - string newChatSender = msg.chatSender.c_str(); + //string newChatSender = msg.chatSender.c_str(); int newChatTeamIndex = msg.chatTeamIndex; int newChatPlayerIndex = msg.chatPlayerIndex; - SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #1 about to broadcast nmtText chatText [%s] chatSender [%s] chatTeamIndex = %d, newChatPlayerIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,newChatText.c_str(),newChatSender.c_str(),newChatTeamIndex,newChatPlayerIndex); + SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #1 about to broadcast nmtText chatText [%s] chatTeamIndex = %d, newChatPlayerIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,newChatText.c_str(),newChatTeamIndex,newChatPlayerIndex); - NetworkMessageText networkMessageText(newChatText.c_str(),newChatSender.c_str(),newChatTeamIndex,newChatPlayerIndex); + NetworkMessageText networkMessageText(newChatText.c_str(),newChatTeamIndex,newChatPlayerIndex); broadcastMessage(&networkMessageText, connectionSlot->getPlayerIndex()); - SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] after broadcast nmtText chatText [%s] chatSender [%s] chatTeamIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,newChatText.c_str(),newChatSender.c_str(),newChatTeamIndex); + SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] after broadcast nmtText chatText [%s] chatTeamIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,newChatText.c_str(),newChatTeamIndex); } } @@ -806,20 +806,20 @@ bool ServerInterface::shouldDiscardNetworkMessage(NetworkMessageType networkMess NetworkMessageText netMsg = NetworkMessageText(); connectionSlot->receiveMessage(&netMsg); - ChatMsgInfo msg(netMsg.getText().c_str(),netMsg.getSender().c_str(),netMsg.getTeamIndex(),netMsg.getPlayerIndex()); + ChatMsgInfo msg(netMsg.getText().c_str(),netMsg.getTeamIndex(),netMsg.getPlayerIndex()); this->addChatInfo(msg); string newChatText = msg.chatText.c_str(); - string newChatSender = msg.chatSender.c_str(); + //string newChatSender = msg.chatSender.c_str(); int newChatTeamIndex = msg.chatTeamIndex; int newChatPlayerIndex = msg.chatPlayerIndex; - SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #1 about to broadcast nmtText chatText [%s] chatSender [%s] chatTeamIndex = %d, newChatPlayerIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,newChatText.c_str(),newChatSender.c_str(),newChatTeamIndex,newChatPlayerIndex); + SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #1 about to broadcast nmtText chatText [%s] chatTeamIndex = %d, newChatPlayerIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,newChatText.c_str(),newChatTeamIndex,newChatPlayerIndex); - NetworkMessageText networkMessageText(newChatText.c_str(),newChatSender.c_str(),newChatTeamIndex,newChatPlayerIndex); + NetworkMessageText networkMessageText(newChatText.c_str(),newChatTeamIndex,newChatPlayerIndex); broadcastMessage(&networkMessageText, connectionSlot->getPlayerIndex()); - SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] after broadcast nmtText chatText [%s] chatSender [%s] chatTeamIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,newChatText.c_str(),newChatSender.c_str(),newChatTeamIndex); + SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] after broadcast nmtText chatText [%s] chatTeamIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,newChatText.c_str(),newChatTeamIndex); } break; @@ -974,13 +974,15 @@ void ServerInterface::waitUntilReady(Checksum* checksum){ void ServerInterface::sendTextMessage(const string &text, int teamIndex, bool echoLocal) { SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] text [%s] teamIndex = %d, echoLocal = %d\n",__FILE__,__FUNCTION__,__LINE__,text.c_str(),teamIndex,echoLocal); - NetworkMessageText networkMessageText(text, getHumanPlayerName().c_str(), teamIndex, getHumanPlayerIndex()); + //NetworkMessageText networkMessageText(text, getHumanPlayerName().c_str(), teamIndex, getHumanPlayerIndex()); + NetworkMessageText networkMessageText(text, teamIndex, getHumanPlayerIndex()); broadcastMessage(&networkMessageText); if(echoLocal == true) { SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__); - ChatMsgInfo msg(text.c_str(),networkMessageText.getSender().c_str(),teamIndex,networkMessageText.getPlayerIndex()); + //ChatMsgInfo msg(text.c_str(),networkMessageText.getSender().c_str(),teamIndex,networkMessageText.getPlayerIndex()); + ChatMsgInfo msg(text.c_str(),teamIndex,networkMessageText.getPlayerIndex()); this->addChatInfo(msg); }