- added player color coding in lobbies as well as chat console

This commit is contained in:
Mark Vejvoda 2010-10-22 07:28:55 +00:00
parent b869552cad
commit 8ab3366c66
19 changed files with 249 additions and 106 deletions

View File

@ -112,19 +112,21 @@ void ChatManager::keyDown(char key){
{
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c] [%d]\n",__FILE__,__FUNCTION__,__LINE__,key,key);
if(editEnabled){
if(editEnabled == true) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c] [%d]\n",__FILE__,__FUNCTION__,__LINE__,key,key);
GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface();
if(!text.empty()) {
if(text.empty() == false) {
string playerName = gameNetworkInterface->getHumanPlayerName();
int playerIndex = gameNetworkInterface->getHumanPlayerIndex();
console->addLine(playerName + ": " + text,false,playerIndex);
console->addLine(playerName + ": " + text);
gameNetworkInterface->sendTextMessage(text, teamMode? thisTeamIndex: -1);
if(!inMenu) editEnabled= false;
if(inMenu == false) {
editEnabled= false;
}
else
{
}
else {
editEnabled= false;
}
text.clear();
@ -185,8 +187,7 @@ 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.chatText, true);
console->addLine(msg.chatSender + ": " + msg.chatText, true);
console->addLine(msg.chatSender + ": " + msg.chatText, true, msg.chatPlayerIndex);
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Added text to console\n",__FILE__,__FUNCTION__);
}

View File

@ -33,7 +33,6 @@ Console::Console(){
maxLines = Config::getInstance().getInt("ConsoleMaxLines");
maxStoredLines = Config::getInstance().getInt("ConsoleMaxLinesStored");
timeout = Config::getInstance().getInt("ConsoleTimeout");
timeElapsed = 0.0f;
}
@ -41,17 +40,16 @@ void Console::addStdMessage(const string &s){
addLine(Lang::getInstance().get(s));
}
void Console::addLine(string line, bool playSound){
try
{
if(playSound){
void Console::addLine(string line, bool playSound, int playerIndex) {
try {
if(playSound == true) {
SoundRenderer::getInstance().playFx(CoreData::getInstance().getClickSoundA());
}
lines.insert(lines.begin(), StringTimePair(line, timeElapsed));
lines.insert(lines.begin(), StringTimePair(line, StringTimePairData(timeElapsed,playerIndex)));
if(lines.size() > maxLines) {
lines.pop_back();
}
storedLines.insert(storedLines.begin(), StringTimePair(line, timeElapsed));
storedLines.insert(storedLines.begin(), StringTimePair(line, StringTimePairData(timeElapsed,playerIndex)));
if(storedLines.size() > maxStoredLines) {
storedLines.pop_back();
}
@ -65,7 +63,7 @@ void Console::addLine(string line, bool playSound){
}
void Console::clearStoredLines() {
while(!storedLines.empty()){
while(storedLines.empty() == false) {
storedLines.pop_back();
}
}
@ -73,8 +71,8 @@ void Console::clearStoredLines(){
void Console::update() {
timeElapsed += 1.f / GameConstants::updateFps;
if(!lines.empty()){
if(lines.back().second<timeElapsed-timeout){
if(lines.empty() == false) {
if(lines.back().second.first < (timeElapsed - timeout)) {
lines.pop_back();
}
}

View File

@ -36,7 +36,9 @@ private:
static const int consoleLines= 5;
public:
typedef pair<string, float> StringTimePair;
// The float is elapsed time, the int is playerindex (-1 is no player)
typedef pair<float, int> StringTimePairData;
typedef pair<string, StringTimePairData > StringTimePair;
typedef vector<StringTimePair> Lines;
typedef Lines::const_iterator LineIterator;
@ -45,9 +47,6 @@ private:
Lines lines;
Lines storedLines;
//this should be deleted from here someday
bool won, lost;
//config
int maxLines;
int maxStoredLines;
@ -61,9 +60,12 @@ public:
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;}
void clearStoredLines();
void addStdMessage(const string &s);
void addLine(string line, bool playSound= false);
void addLine(string line, bool playSound= false,int playerIndex=-1);
void update();
bool isEmpty();
};

View File

@ -92,6 +92,8 @@ public:
static const char *OBSERVER_SLOTNAME;
static const char *RANDOMFACTION_SLOTNAME;
static const char *playerTextureCacheLookupKey;
};
enum PathType {

View File

@ -45,6 +45,8 @@ const char *GameConstants::folder_path_screenshots = "screens/";
const char *GameConstants::OBSERVER_SLOTNAME = "*Observer*";
const char *GameConstants::RANDOMFACTION_SLOTNAME = "*Random*";
const char *GameConstants::playerTextureCacheLookupKey = "playerTextureCache";
// =====================================================
// class Config
// =====================================================

View File

@ -25,7 +25,7 @@
#include "factory_repository.h"
#include <cstdlib>
#include <algorithm>
#include "cache_manager.h"
#include "leak_dumper.h"
using namespace Shared::Graphics;
@ -762,7 +762,7 @@ void Renderer::renderBackground(const Texture2D *texture) {
assertGl();
}
void Renderer::renderTextureQuad(int x, int y, int w, int h, const Texture2D *texture, float alpha){
void Renderer::renderTextureQuad(int x, int y, int w, int h, const Texture2D *texture, float alpha,const Vec3f *color){
assertGl();
glPushAttrib(GL_ENABLE_BIT);
@ -771,7 +771,14 @@ void Renderer::renderTextureQuad(int x, int y, int w, int h, const Texture2D *te
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
if(color != NULL) {
Vec4f newColor(*color);
newColor.w = alpha;
glColor4fv(newColor.ptr());
}
else {
glColor4f(1.f, 1.f, 1.f, alpha);
}
renderQuad(x, y, w, h, texture);
glPopAttrib();
@ -796,8 +803,24 @@ void Renderer::renderConsole(const Console *console,const bool showFullConsole,c
// white shadowed is default ( in the menu for example )
fontColor=Vec4f(1.f, 1.f, 1.f, 0.0f);
}
Vec4f defaultFontColor = fontColor;
if(showFullConsole) {
std::map<int,Texture2D *> &crcPlayerTextureCache = CacheManager::getCachedItem< std::map<int,Texture2D *> >(GameConstants::playerTextureCacheLookupKey);
for(int i = 0; i < console->getStoredLineCount(); ++i) {
int playerIndex = console->getStoredLinePlayerIndex(i);
if(playerIndex >= 0) {
Vec3f playerColor = crcPlayerTextureCache[playerIndex]->getPixmap()->getPixel3f(0, 0);
fontColor.x = playerColor.x;
fontColor.y = playerColor.y;
fontColor.z = playerColor.z;
}
else {
fontColor = defaultFontColor;
}
renderTextShadow(
console->getStoredLine(i),
CoreData::getInstance().getConsoleFont(),
@ -806,7 +829,20 @@ void Renderer::renderConsole(const Console *console,const bool showFullConsole,c
}
}
else if(showMenuConsole) {
std::map<int,Texture2D *> &crcPlayerTextureCache = CacheManager::getCachedItem< std::map<int,Texture2D *> >(GameConstants::playerTextureCacheLookupKey);
for(int i = 0; i < console->getStoredLineCount() && i < maxConsoleLines; ++i) {
int playerIndex = console->getStoredLinePlayerIndex(i);
if(playerIndex >= 0) {
Vec3f playerColor = crcPlayerTextureCache[playerIndex]->getPixmap()->getPixel3f(0, 0);
fontColor.x = playerColor.x;
fontColor.y = playerColor.y;
fontColor.z = playerColor.z;
}
else {
fontColor = defaultFontColor;
}
renderTextShadow(
console->getStoredLine(i),
CoreData::getInstance().getConsoleFont(),
@ -815,7 +851,20 @@ void Renderer::renderConsole(const Console *console,const bool showFullConsole,c
}
}
else {
std::map<int,Texture2D *> &crcPlayerTextureCache = CacheManager::getCachedItem< std::map<int,Texture2D *> >(GameConstants::playerTextureCacheLookupKey);
for(int i = 0; i < console->getLineCount(); ++i) {
int playerIndex = console->getLinePlayerIndex(i);
if(playerIndex >= 0) {
Vec3f playerColor = crcPlayerTextureCache[playerIndex]->getPixmap()->getPixel3f(0, 0);
fontColor.x = playerColor.x;
fontColor.y = playerColor.y;
fontColor.z = playerColor.z;
}
else {
fontColor = defaultFontColor;
}
renderTextShadow(
console->getLine(i),
CoreData::getInstance().getConsoleFont(),
@ -831,13 +880,12 @@ void Renderer::renderChatManager(const ChatManager *chatManager){
Lang &lang= Lang::getInstance();
if(chatManager->getEditEnabled()) {
string text;
string text="";
if(chatManager->getTeamMode()) {
text += lang.get("Team");
}
else
{
else {
text += lang.get("All");
}
text += ": " + chatManager->getText() + "_";
@ -1032,6 +1080,23 @@ void Renderer::renderTextShadow(const string &text, const Font2D *font,const Vec
// ============= COMPONENTS =============================
void Renderer::renderLabel(const GraphicLabel *label) {
Vec4f *colorWithAlpha = NULL;
renderLabel(label,colorWithAlpha);
}
void Renderer::renderLabel(const GraphicLabel *label,const Vec3f *color) {
if(color != NULL) {
Vec4f colorWithAlpha = Vec4f(*color);
colorWithAlpha.w = GraphicComponent::getFade();
renderLabel(label,&colorWithAlpha);
}
else {
Vec4f *colorWithAlpha = NULL;
renderLabel(label,colorWithAlpha);
}
}
void Renderer::renderLabel(const GraphicLabel *label,const Vec4f *color) {
if(label->getVisible() == false) {
return;
}
@ -1051,7 +1116,12 @@ void Renderer::renderLabel(const GraphicLabel *label) {
textPos= Vec2i(x, y+h/4);
}
if(color != NULL) {
renderText(label->getText(), label->getFont(), (*color), textPos.x, textPos.y, label->getCentered());
}
else {
renderText(label->getText(), label->getFont(), GraphicComponent::getFade(), textPos.x, textPos.y, label->getCentered());
}
glPopAttrib();
}

View File

@ -304,7 +304,7 @@ public:
void renderMouse2d(int mouseX, int mouseY, int anim, float fade= 0.f);
void renderMouse3d();
void renderBackground(const Texture2D *texture);
void renderTextureQuad(int x, int y, int w, int h, const Texture2D *texture, float alpha=1.f);
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 renderChatManager(const ChatManager *chatManager);
void renderResourceStatus();
@ -316,6 +316,8 @@ public:
//components
void renderLabel(const GraphicLabel *label);
void renderLabel(const GraphicLabel *label,const Vec3f *color);
void renderLabel(const GraphicLabel *label,const Vec4f *color);
void renderButton(const GraphicButton *button);
void renderListBox(const GraphicListBox *listBox);
void renderMessageBox(const GraphicMessageBox *listBox);

View File

@ -34,6 +34,7 @@
#include <algorithm>
#include "sound_renderer.h"
#include "font_gl.h"
#include "cache_manager.h"
#include "leak_dumper.h"
#ifndef WIN32
@ -934,6 +935,21 @@ int glestMain(int argc, char** argv){
//printf("In [%s::%s Line: %d] screenShotsPath [%s]\n",__FILE__,__FUNCTION__,__LINE__,screenShotsPath.c_str());
}
// Cache Player textures - START
std::map<int,Texture2D *> &crcPlayerTextureCache = CacheManager::getCachedItem< std::map<int,Texture2D *> >(GameConstants::playerTextureCacheLookupKey);
for(int index = 0; index < GameConstants::maxPlayers; ++index) {
string playerTexture = "data/core/faction_textures/faction" + intToStr(index) + ".tga";
if(fileExists(playerTexture) == true) {
Texture2D *texture = Renderer::getInstance().newTexture2D(rsGlobal);
texture->load(playerTexture);
crcPlayerTextureCache[index] = texture;
}
else {
crcPlayerTextureCache[index] = NULL;
}
}
// Cache Player textures - END
if(config.getBool("AllowGameDataSynchCheck","false") == true) {
vector<string> techDataPaths = config.getPathListForType(ptTechs);
preCacheThread.reset(new FileCRCPreCacheThread());

View File

@ -27,7 +27,7 @@
#include "game.h"
#include <algorithm>
#include <time.h>
#include "cache_manager.h"
#include "leak_dumper.h"
@ -532,15 +532,31 @@ void MenuStateConnectedGame::render() {
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
int i;
renderer.renderButton(&buttonDisconnect);
//renderer.renderButton(&buttonPlayNow);
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
for(i=0; i<GameConstants::maxPlayers; ++i){
// Get a reference to the player texture cache
std::map<int,Texture2D *> &crcPlayerTextureCache = CacheManager::getCachedItem< std::map<int,Texture2D *> >(GameConstants::playerTextureCacheLookupKey);
for(int i = 0; i < GameConstants::maxPlayers; ++i) {
if(crcPlayerTextureCache[i] != NULL) {
// Render the player # label the player's color
Vec3f playerColor = crcPlayerTextureCache[i]->getPixmap()->getPixel3f(0, 0);
renderer.renderLabel(&labelPlayers[i],&playerColor);
// Blend the color with white so make it more readable
Vec4f newColor(1.f, 1.f, 1.f, 0.57);
renderer.renderLabel(&labelPlayers[i],&newColor);
//int quadWidth = labelPlayerNames[i].getX() - labelPlayers[i].getX() - 5;
//renderer.renderTextureQuad(labelPlayers[i].getX(), labelPlayers[i].getY(), quadWidth, labelPlayers[i].getH(), crcPlayerTextureCache[i],1.0f,&playerColor);
}
else {
renderer.renderLabel(&labelPlayers[i]);
}
renderer.renderListBox(&listBoxControls[i]);
if(listBoxControls[i].getSelectedItemIndex()!=ctClosed){
renderer.renderListBox(&listBoxFactions[i]);

View File

@ -27,7 +27,7 @@
#include <algorithm>
#include <time.h>
#include <curl/curl.h>
#include "cache_manager.h"
#include "leak_dumper.h"
@ -1038,13 +1038,30 @@ void MenuStateCustomGame::render() {
}
else
{
int i;
renderer.renderButton(&buttonReturn);
renderer.renderButton(&buttonPlayNow);
renderer.renderButton(&buttonRestoreLastSettings);
for(i=0; i<GameConstants::maxPlayers; ++i){
// Get a reference to the player texture cache
std::map<int,Texture2D *> &crcPlayerTextureCache = CacheManager::getCachedItem< std::map<int,Texture2D *> >(GameConstants::playerTextureCacheLookupKey);
for(int i = 0; i < GameConstants::maxPlayers; ++i) {
if(crcPlayerTextureCache[i] != NULL) {
// Render the player # label the player's color
Vec3f playerColor = crcPlayerTextureCache[i]->getPixmap()->getPixel3f(0, 0);
renderer.renderLabel(&labelPlayers[i],&playerColor);
// Blend the color with white so make it more readable
Vec4f newColor(1.f, 1.f, 1.f, 0.57);
renderer.renderLabel(&labelPlayers[i],&newColor);
//int quadWidth = labelPlayerNames[i].getX() - labelPlayers[i].getX() - 5;
//renderer.renderTextureQuad(labelPlayers[i].getX(), labelPlayers[i].getY(), quadWidth, labelPlayers[i].getH(), crcPlayerTextureCache[i],1.0f,&playerColor);
}
else {
renderer.renderLabel(&labelPlayers[i]);
}
renderer.renderLabel(&labelPlayerNames[i]);
renderer.renderListBox(&listBoxControls[i]);

View File

@ -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());
ChatMsgInfo msg(networkMessageText.getText().c_str(),networkMessageText.getSender().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());
ChatMsgInfo msg(networkMessageText.getText().c_str(),networkMessageText.getSender().c_str(),networkMessageText.getTeamIndex(),networkMessageText.getPlayerIndex());
this->addChatInfo(msg);
}
break;
@ -798,11 +798,11 @@ 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);
NetworkMessageText networkMessageText(text, humanPlayerName, teamIndex,playerIndex);
sendMessage(&networkMessageText);
if(echoLocal == true) {
ChatMsgInfo msg(networkMessageText.getText().c_str(),networkMessageText.getSender().c_str(),networkMessageText.getTeamIndex());
ChatMsgInfo msg(networkMessageText.getText().c_str(),networkMessageText.getSender().c_str(),networkMessageText.getTeamIndex(),networkMessageText.getPlayerIndex());
this->addChatInfo(msg);
}
@ -960,7 +960,7 @@ bool ClientInterface::shouldDiscardNetworkMessage(NetworkMessageType networkMess
NetworkMessageText netMsg = NetworkMessageText();
this->receiveMessage(&netMsg);
ChatMsgInfo msg(netMsg.getText().c_str(),netMsg.getSender().c_str(),netMsg.getTeamIndex());
ChatMsgInfo msg(netMsg.getText().c_str(),netMsg.getSender().c_str(),netMsg.getTeamIndex(),netMsg.getPlayerIndex());
this->addChatInfo(msg);
}
break;

View File

@ -103,6 +103,7 @@ public:
const string &getVersionString() const {return versionString;}
virtual string getHumanPlayerName(int index=-1);
virtual int getHumanPlayerIndex() const {return playerIndex;}
protected:

View File

@ -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());
ChatMsgInfo msg(networkMessageText.getText().c_str(),networkMessageText.getSender().c_str(),networkMessageText.getTeamIndex(),networkMessageText.getPlayerIndex());
this->addChatInfo(msg);
gotTextMsg = true;

View File

@ -162,6 +162,7 @@ public:
void validateConnection();
virtual string getHumanPlayerName(int index=-1);
virtual int getHumanPlayerIndex() const {return playerIndex;}
protected:

View File

@ -48,6 +48,7 @@ protected:
this->chatText = obj.chatText.c_str();
this->chatSender = obj.chatSender.c_str();
this->chatTeamIndex = obj.chatTeamIndex;
this->chatPlayerIndex = obj.chatPlayerIndex;
}
public:
@ -55,11 +56,13 @@ public:
this->chatText = "";
this->chatSender = "";
this->chatTeamIndex = -1;
this->chatPlayerIndex = -1;
}
ChatMsgInfo(string chatText, string chatSender,int chatTeamIndex) {
ChatMsgInfo(string chatText, string chatSender,int chatTeamIndex, int chatPlayerIndex) {
this->chatText = chatText;
this->chatSender = chatSender;
this->chatTeamIndex = chatTeamIndex;
this->chatPlayerIndex = chatPlayerIndex;
}
ChatMsgInfo(const ChatMsgInfo& obj) {
copyAll(obj);
@ -72,6 +75,7 @@ public:
string chatText;
string chatSender;
int chatTeamIndex;
int chatPlayerIndex;
};
@ -107,6 +111,7 @@ public:
virtual const Socket* getSocket() const= 0;
virtual void close()= 0;
virtual string getHumanPlayerName(int index=-1) = 0;
virtual int getHumanPlayerIndex() const = 0;
static void setDisplayMessageFunction(DisplayMessageFunction pDisplayMessage) { pCB_DisplayMessage = pDisplayMessage; }
static DisplayMessageFunction getDisplayMessageFunction() { return pCB_DisplayMessage; }

View File

@ -393,7 +393,7 @@ void NetworkMessageCommandList::send(Socket* socket) const{
// class NetworkMessageText
// =====================================================
NetworkMessageText::NetworkMessageText(const string &text, const string &sender, int teamIndex){
NetworkMessageText::NetworkMessageText(const string &text, const string &sender, 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);
@ -408,6 +408,7 @@ NetworkMessageText::NetworkMessageText(const string &text, const string &sender,
data.text = text;
data.sender = sender;
data.teamIndex = teamIndex;
data.playerIndex = playerIndex;
}
bool NetworkMessageText::receive(Socket* socket){

View File

@ -293,6 +293,7 @@ private:
NetworkString<maxTextStringSize> text;
NetworkString<maxSenderStringSize> sender;
int8 teamIndex;
int8 playerIndex;
};
private:
@ -300,11 +301,12 @@ private:
public:
NetworkMessageText(){}
NetworkMessageText(const string &text, const string &sender, int teamIndex);
NetworkMessageText(const string &text, const string &sender, int teamIndex, int playerIndex);
string getText() const {return data.text.getString();}
string getSender() const {return data.sender.getString();}
int getTeamIndex() const {return data.teamIndex;}
int getPlayerIndex() const {return data.playerIndex;}
virtual bool receive(Socket* socket);
virtual void send(Socket* socket) const;

View File

@ -679,10 +679,11 @@ void ServerInterface::update() {
string newChatText = msg.chatText.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\n",__FILE__,__FUNCTION__,__LINE__,newChatText.c_str(),newChatSender.c_str(),newChatTeamIndex);
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);
NetworkMessageText networkMessageText(newChatText.c_str(),newChatSender.c_str(),newChatTeamIndex);
NetworkMessageText networkMessageText(newChatText.c_str(),newChatSender.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);
@ -805,16 +806,17 @@ bool ServerInterface::shouldDiscardNetworkMessage(NetworkMessageType networkMess
NetworkMessageText netMsg = NetworkMessageText();
connectionSlot->receiveMessage(&netMsg);
ChatMsgInfo msg(netMsg.getText().c_str(),netMsg.getSender().c_str(),netMsg.getTeamIndex());
ChatMsgInfo msg(netMsg.getText().c_str(),netMsg.getSender().c_str(),netMsg.getTeamIndex(),netMsg.getPlayerIndex());
this->addChatInfo(msg);
string newChatText = msg.chatText.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\n",__FILE__,__FUNCTION__,__LINE__,newChatText.c_str(),newChatSender.c_str(),newChatTeamIndex);
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);
NetworkMessageText networkMessageText(newChatText.c_str(),newChatSender.c_str(),newChatTeamIndex);
NetworkMessageText networkMessageText(newChatText.c_str(),newChatSender.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);
@ -972,13 +974,13 @@ 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);
NetworkMessageText networkMessageText(text, getHumanPlayerName().c_str(), teamIndex, gameSettings.getThisFactionIndex());
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);
ChatMsgInfo msg(text.c_str(),networkMessageText.getSender().c_str(),teamIndex,networkMessageText.getPlayerIndex());
this->addChatInfo(msg);
}
@ -1370,4 +1372,8 @@ string ServerInterface::getHumanPlayerName(int index) {
return result;
}
int ServerInterface::getHumanPlayerIndex() const {
return gameSettings.getThisFactionIndex();
}
}}//end namespace

View File

@ -97,6 +97,7 @@ public:
}
virtual string getHumanPlayerName(int index=-1);
virtual int getHumanPlayerIndex() const;
public: