- added player color coding in lobbies as well as chat console
This commit is contained in:
parent
b869552cad
commit
8ab3366c66
|
@ -32,7 +32,7 @@ namespace Glest{ namespace Game{
|
||||||
|
|
||||||
const int ChatManager::maxTextLenght= 64;
|
const int ChatManager::maxTextLenght= 64;
|
||||||
|
|
||||||
ChatManager::ChatManager(){
|
ChatManager::ChatManager() {
|
||||||
console= NULL;
|
console= NULL;
|
||||||
editEnabled= false;
|
editEnabled= false;
|
||||||
teamMode= false;
|
teamMode= false;
|
||||||
|
@ -40,21 +40,21 @@ ChatManager::ChatManager(){
|
||||||
disableTeamMode = false;
|
disableTeamMode = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatManager::init(Console* console, int thisTeamIndex, const bool inMenu){
|
void ChatManager::init(Console* console, int thisTeamIndex, const bool inMenu) {
|
||||||
this->console= console;
|
this->console= console;
|
||||||
this->thisTeamIndex= thisTeamIndex;
|
this->thisTeamIndex= thisTeamIndex;
|
||||||
this->disableTeamMode= false;
|
this->disableTeamMode= false;
|
||||||
this->inMenu=inMenu;
|
this->inMenu=inMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatManager::keyUp(char key){
|
void ChatManager::keyUp(char key) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if(editEnabled){
|
if(editEnabled) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c] [%d]\n",__FILE__,__FUNCTION__,__LINE__,key,key);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c] [%d]\n",__FILE__,__FUNCTION__,__LINE__,key,key);
|
||||||
|
|
||||||
if(key==vkEscape)
|
if(key == vkEscape)
|
||||||
{
|
{
|
||||||
text.clear();
|
text.clear();
|
||||||
editEnabled= false;
|
editEnabled= false;
|
||||||
|
@ -78,7 +78,7 @@ void ChatManager::setDisableTeamMode(bool value) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatManager::keyDown(char key){
|
void ChatManager::keyDown(char key) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c] [%d]\n",__FILE__,__FUNCTION__,__LINE__,key,key);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c] [%d]\n",__FILE__,__FUNCTION__,__LINE__,key,key);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -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);
|
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);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c] [%d]\n",__FILE__,__FUNCTION__,__LINE__,key,key);
|
||||||
|
|
||||||
GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface();
|
GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface();
|
||||||
if(!text.empty()) {
|
if(text.empty() == false) {
|
||||||
string playerName = gameNetworkInterface->getHumanPlayerName();
|
string playerName = gameNetworkInterface->getHumanPlayerName();
|
||||||
|
int playerIndex = gameNetworkInterface->getHumanPlayerIndex();
|
||||||
|
console->addLine(playerName + ": " + text,false,playerIndex);
|
||||||
|
|
||||||
console->addLine(playerName + ": " + text);
|
|
||||||
gameNetworkInterface->sendTextMessage(text, teamMode? thisTeamIndex: -1);
|
gameNetworkInterface->sendTextMessage(text, teamMode? thisTeamIndex: -1);
|
||||||
if(!inMenu) editEnabled= false;
|
if(inMenu == false) {
|
||||||
|
editEnabled= false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
editEnabled= false;
|
editEnabled= false;
|
||||||
}
|
}
|
||||||
text.clear();
|
text.clear();
|
||||||
|
@ -184,9 +186,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);
|
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){
|
if(teamIndex == -1 || teamIndex == thisTeamIndex) {
|
||||||
//console->addLine(msg.chatText, true);
|
console->addLine(msg.chatSender + ": " + msg.chatText, true, msg.chatPlayerIndex);
|
||||||
console->addLine(msg.chatSender + ": " + msg.chatText, true);
|
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Added text to console\n",__FILE__,__FUNCTION__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Added text to console\n",__FILE__,__FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,31 +28,29 @@ namespace Glest{ namespace Game{
|
||||||
// class Console
|
// class Console
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
||||||
Console::Console(){
|
Console::Console() {
|
||||||
//config
|
//config
|
||||||
maxLines= Config::getInstance().getInt("ConsoleMaxLines");
|
maxLines = Config::getInstance().getInt("ConsoleMaxLines");
|
||||||
maxStoredLines= Config::getInstance().getInt("ConsoleMaxLinesStored");
|
maxStoredLines = Config::getInstance().getInt("ConsoleMaxLinesStored");
|
||||||
timeout= Config::getInstance().getInt("ConsoleTimeout");
|
timeout = Config::getInstance().getInt("ConsoleTimeout");
|
||||||
|
timeElapsed = 0.0f;
|
||||||
timeElapsed= 0.0f;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Console::addStdMessage(const string &s){
|
void Console::addStdMessage(const string &s) {
|
||||||
addLine(Lang::getInstance().get(s));
|
addLine(Lang::getInstance().get(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Console::addLine(string line, bool playSound){
|
void Console::addLine(string line, bool playSound, int playerIndex) {
|
||||||
try
|
try {
|
||||||
{
|
if(playSound == true) {
|
||||||
if(playSound){
|
|
||||||
SoundRenderer::getInstance().playFx(CoreData::getInstance().getClickSoundA());
|
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){
|
if(lines.size() > maxLines) {
|
||||||
lines.pop_back();
|
lines.pop_back();
|
||||||
}
|
}
|
||||||
storedLines.insert(storedLines.begin(), StringTimePair(line, timeElapsed));
|
storedLines.insert(storedLines.begin(), StringTimePair(line, StringTimePairData(timeElapsed,playerIndex)));
|
||||||
if(storedLines.size()>maxStoredLines){
|
if(storedLines.size() > maxStoredLines) {
|
||||||
storedLines.pop_back();
|
storedLines.pop_back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,23 +62,23 @@ void Console::addLine(string line, bool playSound){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Console::clearStoredLines(){
|
void Console::clearStoredLines() {
|
||||||
while(!storedLines.empty()){
|
while(storedLines.empty() == false) {
|
||||||
storedLines.pop_back();
|
storedLines.pop_back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Console::update(){
|
void Console::update() {
|
||||||
timeElapsed+= 1.f/GameConstants::updateFps;
|
timeElapsed += 1.f / GameConstants::updateFps;
|
||||||
|
|
||||||
if(!lines.empty()){
|
if(lines.empty() == false) {
|
||||||
if(lines.back().second<timeElapsed-timeout){
|
if(lines.back().second.first < (timeElapsed - timeout)) {
|
||||||
lines.pop_back();
|
lines.pop_back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Console::isEmpty(){
|
bool Console::isEmpty() {
|
||||||
return lines.empty();
|
return lines.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,9 @@ private:
|
||||||
static const int consoleLines= 5;
|
static const int consoleLines= 5;
|
||||||
|
|
||||||
public:
|
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 vector<StringTimePair> Lines;
|
||||||
typedef Lines::const_iterator LineIterator;
|
typedef Lines::const_iterator LineIterator;
|
||||||
|
|
||||||
|
@ -45,9 +47,6 @@ private:
|
||||||
Lines lines;
|
Lines lines;
|
||||||
Lines storedLines;
|
Lines storedLines;
|
||||||
|
|
||||||
//this should be deleted from here someday
|
|
||||||
bool won, lost;
|
|
||||||
|
|
||||||
//config
|
//config
|
||||||
int maxLines;
|
int maxLines;
|
||||||
int maxStoredLines;
|
int maxStoredLines;
|
||||||
|
@ -57,13 +56,16 @@ public:
|
||||||
Console();
|
Console();
|
||||||
|
|
||||||
int getStoredLineCount() const {return storedLines.size();}
|
int getStoredLineCount() const {return storedLines.size();}
|
||||||
int getLineCount() const {return lines.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 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;}
|
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 clearStoredLines();
|
||||||
void addStdMessage(const string &s);
|
void addStdMessage(const string &s);
|
||||||
void addLine(string line, bool playSound= false);
|
void addLine(string line, bool playSound= false,int playerIndex=-1);
|
||||||
void update();
|
void update();
|
||||||
bool isEmpty();
|
bool isEmpty();
|
||||||
};
|
};
|
||||||
|
|
|
@ -92,6 +92,8 @@ public:
|
||||||
|
|
||||||
static const char *OBSERVER_SLOTNAME;
|
static const char *OBSERVER_SLOTNAME;
|
||||||
static const char *RANDOMFACTION_SLOTNAME;
|
static const char *RANDOMFACTION_SLOTNAME;
|
||||||
|
|
||||||
|
static const char *playerTextureCacheLookupKey;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum PathType {
|
enum PathType {
|
||||||
|
|
|
@ -45,6 +45,8 @@ const char *GameConstants::folder_path_screenshots = "screens/";
|
||||||
const char *GameConstants::OBSERVER_SLOTNAME = "*Observer*";
|
const char *GameConstants::OBSERVER_SLOTNAME = "*Observer*";
|
||||||
const char *GameConstants::RANDOMFACTION_SLOTNAME = "*Random*";
|
const char *GameConstants::RANDOMFACTION_SLOTNAME = "*Random*";
|
||||||
|
|
||||||
|
const char *GameConstants::playerTextureCacheLookupKey = "playerTextureCache";
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
// class Config
|
// class Config
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#include "factory_repository.h"
|
#include "factory_repository.h"
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include "cache_manager.h"
|
||||||
#include "leak_dumper.h"
|
#include "leak_dumper.h"
|
||||||
|
|
||||||
using namespace Shared::Graphics;
|
using namespace Shared::Graphics;
|
||||||
|
@ -762,7 +762,7 @@ void Renderer::renderBackground(const Texture2D *texture) {
|
||||||
assertGl();
|
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();
|
assertGl();
|
||||||
|
|
||||||
glPushAttrib(GL_ENABLE_BIT);
|
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_TEXTURE_2D);
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
|
|
||||||
glColor4f(1.f, 1.f, 1.f, alpha);
|
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);
|
renderQuad(x, y, w, h, texture);
|
||||||
|
|
||||||
glPopAttrib();
|
glPopAttrib();
|
||||||
|
@ -789,15 +796,31 @@ void Renderer::renderConsole(const Console *console,const bool showFullConsole,c
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
Vec4f fontColor;
|
Vec4f fontColor;
|
||||||
|
|
||||||
if(game!=NULL){
|
if(game != NULL) {
|
||||||
fontColor=game->getGui()->getDisplay()->getColor();
|
fontColor = game->getGui()->getDisplay()->getColor();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// white shadowed is default ( in the menu for example )
|
// white shadowed is default ( in the menu for example )
|
||||||
fontColor=Vec4f(1.f, 1.f, 1.f, 0.0f);
|
fontColor=Vec4f(1.f, 1.f, 1.f, 0.0f);
|
||||||
}
|
}
|
||||||
if(showFullConsole){
|
|
||||||
for(int i=0; i<console->getStoredLineCount(); ++i){
|
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(
|
renderTextShadow(
|
||||||
console->getStoredLine(i),
|
console->getStoredLine(i),
|
||||||
CoreData::getInstance().getConsoleFont(),
|
CoreData::getInstance().getConsoleFont(),
|
||||||
|
@ -806,7 +829,20 @@ void Renderer::renderConsole(const Console *console,const bool showFullConsole,c
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(showMenuConsole) {
|
else if(showMenuConsole) {
|
||||||
for(int i=0; i<console->getStoredLineCount() && i<maxConsoleLines; ++i){
|
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(
|
renderTextShadow(
|
||||||
console->getStoredLine(i),
|
console->getStoredLine(i),
|
||||||
CoreData::getInstance().getConsoleFont(),
|
CoreData::getInstance().getConsoleFont(),
|
||||||
|
@ -815,7 +851,20 @@ void Renderer::renderConsole(const Console *console,const bool showFullConsole,c
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for(int i=0; i<console->getLineCount(); ++i) {
|
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(
|
renderTextShadow(
|
||||||
console->getLine(i),
|
console->getLine(i),
|
||||||
CoreData::getInstance().getConsoleFont(),
|
CoreData::getInstance().getConsoleFont(),
|
||||||
|
@ -826,24 +875,23 @@ void Renderer::renderConsole(const Console *console,const bool showFullConsole,c
|
||||||
glPopAttrib();
|
glPopAttrib();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::renderChatManager(const ChatManager *chatManager){
|
void Renderer::renderChatManager(const ChatManager *chatManager) {
|
||||||
Vec4f fontColor;
|
Vec4f fontColor;
|
||||||
Lang &lang= Lang::getInstance();
|
Lang &lang= Lang::getInstance();
|
||||||
|
|
||||||
if(chatManager->getEditEnabled()){
|
if(chatManager->getEditEnabled()) {
|
||||||
string text;
|
string text="";
|
||||||
|
|
||||||
if(chatManager->getTeamMode()){
|
if(chatManager->getTeamMode()) {
|
||||||
text+= lang.get("Team");
|
text += lang.get("Team");
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
text += lang.get("All");
|
||||||
text+= lang.get("All");
|
|
||||||
}
|
}
|
||||||
text+= ": " + chatManager->getText() + "_";
|
text += ": " + chatManager->getText() + "_";
|
||||||
|
|
||||||
if(game!=NULL){
|
if(game != NULL) {
|
||||||
fontColor=game->getGui()->getDisplay()->getColor();
|
fontColor = game->getGui()->getDisplay()->getColor();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// white shadowed is default ( in the menu for example )
|
// white shadowed is default ( in the menu for example )
|
||||||
|
@ -1032,6 +1080,23 @@ void Renderer::renderTextShadow(const string &text, const Font2D *font,const Vec
|
||||||
// ============= COMPONENTS =============================
|
// ============= COMPONENTS =============================
|
||||||
|
|
||||||
void Renderer::renderLabel(const GraphicLabel *label) {
|
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) {
|
if(label->getVisible() == false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1051,7 +1116,12 @@ void Renderer::renderLabel(const GraphicLabel *label) {
|
||||||
textPos= Vec2i(x, y+h/4);
|
textPos= Vec2i(x, y+h/4);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderText(label->getText(), label->getFont(), GraphicComponent::getFade(), textPos.x, textPos.y, label->getCentered());
|
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();
|
glPopAttrib();
|
||||||
}
|
}
|
||||||
|
|
|
@ -304,7 +304,7 @@ public:
|
||||||
void renderMouse2d(int mouseX, int mouseY, int anim, float fade= 0.f);
|
void renderMouse2d(int mouseX, int mouseY, int anim, float fade= 0.f);
|
||||||
void renderMouse3d();
|
void renderMouse3d();
|
||||||
void renderBackground(const Texture2D *texture);
|
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 renderConsole(const Console *console, const bool showAll=false, const bool showMenuConsole=false);
|
||||||
void renderChatManager(const ChatManager *chatManager);
|
void renderChatManager(const ChatManager *chatManager);
|
||||||
void renderResourceStatus();
|
void renderResourceStatus();
|
||||||
|
@ -316,6 +316,8 @@ public:
|
||||||
|
|
||||||
//components
|
//components
|
||||||
void renderLabel(const GraphicLabel *label);
|
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 renderButton(const GraphicButton *button);
|
||||||
void renderListBox(const GraphicListBox *listBox);
|
void renderListBox(const GraphicListBox *listBox);
|
||||||
void renderMessageBox(const GraphicMessageBox *listBox);
|
void renderMessageBox(const GraphicMessageBox *listBox);
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include "sound_renderer.h"
|
#include "sound_renderer.h"
|
||||||
#include "font_gl.h"
|
#include "font_gl.h"
|
||||||
|
#include "cache_manager.h"
|
||||||
#include "leak_dumper.h"
|
#include "leak_dumper.h"
|
||||||
|
|
||||||
#ifndef WIN32
|
#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());
|
//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) {
|
if(config.getBool("AllowGameDataSynchCheck","false") == true) {
|
||||||
vector<string> techDataPaths = config.getPathListForType(ptTechs);
|
vector<string> techDataPaths = config.getPathListForType(ptTechs);
|
||||||
preCacheThread.reset(new FileCRCPreCacheThread());
|
preCacheThread.reset(new FileCRCPreCacheThread());
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#include "game.h"
|
#include "game.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include "cache_manager.h"
|
||||||
#include "leak_dumper.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__);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
int i;
|
|
||||||
|
|
||||||
renderer.renderButton(&buttonDisconnect);
|
renderer.renderButton(&buttonDisconnect);
|
||||||
//renderer.renderButton(&buttonPlayNow);
|
//renderer.renderButton(&buttonPlayNow);
|
||||||
|
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
//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
|
||||||
renderer.renderLabel(&labelPlayers[i]);
|
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]);
|
renderer.renderListBox(&listBoxControls[i]);
|
||||||
if(listBoxControls[i].getSelectedItemIndex()!=ctClosed){
|
if(listBoxControls[i].getSelectedItemIndex()!=ctClosed){
|
||||||
renderer.renderListBox(&listBoxFactions[i]);
|
renderer.renderListBox(&listBoxFactions[i]);
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
|
#include "cache_manager.h"
|
||||||
#include "leak_dumper.h"
|
#include "leak_dumper.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -1038,13 +1038,30 @@ void MenuStateCustomGame::render() {
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
renderer.renderButton(&buttonReturn);
|
renderer.renderButton(&buttonReturn);
|
||||||
renderer.renderButton(&buttonPlayNow);
|
renderer.renderButton(&buttonPlayNow);
|
||||||
renderer.renderButton(&buttonRestoreLastSettings);
|
renderer.renderButton(&buttonRestoreLastSettings);
|
||||||
|
|
||||||
for(i=0; i<GameConstants::maxPlayers; ++i){
|
// Get a reference to the player texture cache
|
||||||
renderer.renderLabel(&labelPlayers[i]);
|
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.renderLabel(&labelPlayerNames[i]);
|
||||||
|
|
||||||
renderer.renderListBox(&listBoxControls[i]);
|
renderer.renderListBox(&listBoxControls[i]);
|
||||||
|
|
|
@ -435,7 +435,7 @@ void ClientInterface::updateLobby() {
|
||||||
{
|
{
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] got nmtText\n",__FILE__,__FUNCTION__);
|
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);
|
this->addChatInfo(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -622,7 +622,7 @@ void ClientInterface::updateKeyframe(int frameCount)
|
||||||
sleep(0);
|
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);
|
this->addChatInfo(msg);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -793,16 +793,16 @@ void ClientInterface::waitUntilReady(Checksum* checksum) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] END\n",__FILE__,__FUNCTION__);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] END\n",__FILE__,__FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientInterface::sendTextMessage(const string &text, int teamIndex, bool echoLocal){
|
void ClientInterface::sendTextMessage(const string &text, int teamIndex, bool echoLocal) {
|
||||||
|
|
||||||
string humanPlayerName = getHumanPlayerName();
|
string humanPlayerName = getHumanPlayerName();
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] humanPlayerName = [%s] playerIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,humanPlayerName.c_str(),playerIndex);
|
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);
|
sendMessage(&networkMessageText);
|
||||||
|
|
||||||
if(echoLocal == true) {
|
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);
|
this->addChatInfo(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -960,7 +960,7 @@ bool ClientInterface::shouldDiscardNetworkMessage(NetworkMessageType networkMess
|
||||||
NetworkMessageText netMsg = NetworkMessageText();
|
NetworkMessageText netMsg = NetworkMessageText();
|
||||||
this->receiveMessage(&netMsg);
|
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);
|
this->addChatInfo(msg);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -103,6 +103,7 @@ public:
|
||||||
|
|
||||||
const string &getVersionString() const {return versionString;}
|
const string &getVersionString() const {return versionString;}
|
||||||
virtual string getHumanPlayerName(int index=-1);
|
virtual string getHumanPlayerName(int index=-1);
|
||||||
|
virtual int getHumanPlayerIndex() const {return playerIndex;}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
|
@ -311,7 +311,7 @@ void ConnectionSlot::update(bool checkForNewClients) {
|
||||||
if(gotIntro == true) {
|
if(gotIntro == true) {
|
||||||
NetworkMessageText networkMessageText;
|
NetworkMessageText networkMessageText;
|
||||||
if(receiveMessage(&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);
|
this->addChatInfo(msg);
|
||||||
gotTextMsg = true;
|
gotTextMsg = true;
|
||||||
|
|
||||||
|
|
|
@ -162,6 +162,7 @@ public:
|
||||||
|
|
||||||
void validateConnection();
|
void validateConnection();
|
||||||
virtual string getHumanPlayerName(int index=-1);
|
virtual string getHumanPlayerName(int index=-1);
|
||||||
|
virtual int getHumanPlayerIndex() const {return playerIndex;}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
|
@ -45,21 +45,24 @@ class ChatMsgInfo {
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void copyAll(const ChatMsgInfo &obj) {
|
void copyAll(const ChatMsgInfo &obj) {
|
||||||
this->chatText = obj.chatText.c_str();
|
this->chatText = obj.chatText.c_str();
|
||||||
this->chatSender = obj.chatSender.c_str();
|
this->chatSender = obj.chatSender.c_str();
|
||||||
this->chatTeamIndex = obj.chatTeamIndex;
|
this->chatTeamIndex = obj.chatTeamIndex;
|
||||||
|
this->chatPlayerIndex = obj.chatPlayerIndex;
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ChatMsgInfo() {
|
ChatMsgInfo() {
|
||||||
this->chatText = "";
|
this->chatText = "";
|
||||||
this->chatSender = "";
|
this->chatSender = "";
|
||||||
this->chatTeamIndex = -1;
|
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->chatText = chatText;
|
||||||
this->chatSender = chatSender;
|
this->chatSender = chatSender;
|
||||||
this->chatTeamIndex = chatTeamIndex;
|
this->chatTeamIndex = chatTeamIndex;
|
||||||
|
this->chatPlayerIndex = chatPlayerIndex;
|
||||||
}
|
}
|
||||||
ChatMsgInfo(const ChatMsgInfo& obj) {
|
ChatMsgInfo(const ChatMsgInfo& obj) {
|
||||||
copyAll(obj);
|
copyAll(obj);
|
||||||
|
@ -72,6 +75,7 @@ public:
|
||||||
string chatText;
|
string chatText;
|
||||||
string chatSender;
|
string chatSender;
|
||||||
int chatTeamIndex;
|
int chatTeamIndex;
|
||||||
|
int chatPlayerIndex;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -107,6 +111,7 @@ public:
|
||||||
virtual const Socket* getSocket() const= 0;
|
virtual const Socket* getSocket() const= 0;
|
||||||
virtual void close()= 0;
|
virtual void close()= 0;
|
||||||
virtual string getHumanPlayerName(int index=-1) = 0;
|
virtual string getHumanPlayerName(int index=-1) = 0;
|
||||||
|
virtual int getHumanPlayerIndex() const = 0;
|
||||||
|
|
||||||
static void setDisplayMessageFunction(DisplayMessageFunction pDisplayMessage) { pCB_DisplayMessage = pDisplayMessage; }
|
static void setDisplayMessageFunction(DisplayMessageFunction pDisplayMessage) { pCB_DisplayMessage = pDisplayMessage; }
|
||||||
static DisplayMessageFunction getDisplayMessageFunction() { return pCB_DisplayMessage; }
|
static DisplayMessageFunction getDisplayMessageFunction() { return pCB_DisplayMessage; }
|
||||||
|
|
|
@ -393,7 +393,7 @@ void NetworkMessageCommandList::send(Socket* socket) const{
|
||||||
// class NetworkMessageText
|
// 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) {
|
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);
|
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);
|
||||||
|
@ -404,10 +404,11 @@ NetworkMessageText::NetworkMessageText(const string &text, const string &sender,
|
||||||
//throw runtime_error("NetworkMessageText - sender.length() >= maxSenderStringSize");
|
//throw runtime_error("NetworkMessageText - sender.length() >= maxSenderStringSize");
|
||||||
}
|
}
|
||||||
|
|
||||||
data.messageType= nmtText;
|
data.messageType = nmtText;
|
||||||
data.text= text;
|
data.text = text;
|
||||||
data.sender= sender;
|
data.sender = sender;
|
||||||
data.teamIndex= teamIndex;
|
data.teamIndex = teamIndex;
|
||||||
|
data.playerIndex = playerIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NetworkMessageText::receive(Socket* socket){
|
bool NetworkMessageText::receive(Socket* socket){
|
||||||
|
|
|
@ -282,7 +282,7 @@ public:
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
class NetworkMessageText: public NetworkMessage{
|
class NetworkMessageText: public NetworkMessage {
|
||||||
private:
|
private:
|
||||||
static const int maxTextStringSize= 340;
|
static const int maxTextStringSize= 340;
|
||||||
static const int maxSenderStringSize= 60;
|
static const int maxSenderStringSize= 60;
|
||||||
|
@ -293,6 +293,7 @@ private:
|
||||||
NetworkString<maxTextStringSize> text;
|
NetworkString<maxTextStringSize> text;
|
||||||
NetworkString<maxSenderStringSize> sender;
|
NetworkString<maxSenderStringSize> sender;
|
||||||
int8 teamIndex;
|
int8 teamIndex;
|
||||||
|
int8 playerIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -300,11 +301,12 @@ private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
NetworkMessageText(){}
|
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 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 getTeamIndex() const {return data.teamIndex;}
|
||||||
|
int getPlayerIndex() const {return data.playerIndex;}
|
||||||
|
|
||||||
virtual bool receive(Socket* socket);
|
virtual bool receive(Socket* socket);
|
||||||
virtual void send(Socket* socket) const;
|
virtual void send(Socket* socket) const;
|
||||||
|
|
|
@ -679,10 +679,11 @@ void ServerInterface::update() {
|
||||||
string newChatText = msg.chatText.c_str();
|
string newChatText = msg.chatText.c_str();
|
||||||
string newChatSender = msg.chatSender.c_str();
|
string newChatSender = msg.chatSender.c_str();
|
||||||
int newChatTeamIndex = msg.chatTeamIndex;
|
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());
|
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] 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();
|
NetworkMessageText netMsg = NetworkMessageText();
|
||||||
connectionSlot->receiveMessage(&netMsg);
|
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);
|
this->addChatInfo(msg);
|
||||||
|
|
||||||
string newChatText = msg.chatText.c_str();
|
string newChatText = msg.chatText.c_str();
|
||||||
string newChatSender = msg.chatSender.c_str();
|
string newChatSender = msg.chatSender.c_str();
|
||||||
int newChatTeamIndex = msg.chatTeamIndex;
|
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());
|
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] 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) {
|
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);
|
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);
|
broadcastMessage(&networkMessageText);
|
||||||
|
|
||||||
if(echoLocal == true) {
|
if(echoLocal == true) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
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);
|
this->addChatInfo(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1370,4 +1372,8 @@ string ServerInterface::getHumanPlayerName(int index) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ServerInterface::getHumanPlayerIndex() const {
|
||||||
|
return gameSettings.getThisFactionIndex();
|
||||||
|
}
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
|
|
@ -97,6 +97,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual string getHumanPlayerName(int index=-1);
|
virtual string getHumanPlayerName(int index=-1);
|
||||||
|
virtual int getHumanPlayerIndex() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user