- initial work to support multi-language text messages
This commit is contained in:
parent
4fb33d34ce
commit
4a27e75891
|
@ -133,7 +133,7 @@ void ChatManager::keyDown(char key) {
|
|||
console->addLine(text,false,playerIndex);
|
||||
}
|
||||
|
||||
gameNetworkInterface->sendTextMessage(text, teamMode? thisTeamIndex: -1);
|
||||
gameNetworkInterface->sendTextMessage(text, teamMode? thisTeamIndex: -1, false, "");
|
||||
if(inMenu == false) {
|
||||
editEnabled= false;
|
||||
}
|
||||
|
|
|
@ -451,7 +451,7 @@ CommandResult Commander::pushNetworkCommand(const NetworkCommand* networkCommand
|
|||
if(gameNetworkInterface != NULL) {
|
||||
char szMsg[1024]="";
|
||||
sprintf(szMsg,"Player detected an error: Command refers to non existent unit id = %d. Game out of synch.",networkCommand->getUnitId());
|
||||
gameNetworkInterface->sendTextMessage(szMsg,-1, true);
|
||||
gameNetworkInterface->sendTextMessage(szMsg,-1, true, "");
|
||||
}
|
||||
throw runtime_error(szBuf);
|
||||
}
|
||||
|
@ -655,7 +655,7 @@ Command* Commander::buildCommand(const NetworkCommand* networkCommand) const {
|
|||
if(gameNetworkInterface != NULL) {
|
||||
char szMsg[1024]="";
|
||||
sprintf(szMsg,"Player detected an error: Can not find unit with id: %d. Game out of synch.",networkCommand->getUnitId());
|
||||
gameNetworkInterface->sendTextMessage(szMsg,-1, true);
|
||||
gameNetworkInterface->sendTextMessage(szMsg,-1, true, "");
|
||||
}
|
||||
|
||||
throw runtime_error(szBuf);
|
||||
|
@ -676,17 +676,17 @@ Command* Commander::buildCommand(const NetworkCommand* networkCommand) const {
|
|||
if(gameNetworkInterface != NULL && gameNetworkInterface->isConnected() == true) {
|
||||
char szMsg[1024]="";
|
||||
sprintf(szMsg,"Player detected an error: Unit / Faction mismatch for unitId: %d",networkCommand->getUnitId());
|
||||
gameNetworkInterface->sendTextMessage(szMsg,-1, true);
|
||||
gameNetworkInterface->sendTextMessage(szMsg,-1, true, "");
|
||||
sprintf(szMsg,"Local faction index = %d, remote index = %d. Game out of synch.",unit->getFaction()->getIndex(),networkCommand->getUnitFactionIndex());
|
||||
gameNetworkInterface->sendTextMessage(szMsg,-1, true);
|
||||
gameNetworkInterface->sendTextMessage(szMsg,-1, true, "");
|
||||
|
||||
}
|
||||
else {
|
||||
char szMsg[1024]="";
|
||||
sprintf(szMsg,"Player detected an error: Connection lost, possible Unit / Faction mismatch for unitId: %d",networkCommand->getUnitId());
|
||||
gameNetworkInterface->sendTextMessage(szMsg,-1, true);
|
||||
gameNetworkInterface->sendTextMessage(szMsg,-1, true,"");
|
||||
sprintf(szMsg,"Local faction index = %d, remote index = %d. Game out of synch.",unit->getFaction()->getIndex(),networkCommand->getUnitFactionIndex());
|
||||
gameNetworkInterface->sendTextMessage(szMsg,-1, true);
|
||||
gameNetworkInterface->sendTextMessage(szMsg,-1, true,"");
|
||||
}
|
||||
|
||||
std::string sError = "Error [#1]: Game is out of sync (Unit / Faction mismatch)\nplease check log files for details.";
|
||||
|
@ -736,7 +736,7 @@ Command* Commander::buildCommand(const NetworkCommand* networkCommand) const {
|
|||
if(gameNetworkInterface != NULL) {
|
||||
char szMsg[1024]="";
|
||||
sprintf(szMsg,"Player detected an error: Can not find command type for unitId: %d. Game out of synch.",networkCommand->getUnitId());
|
||||
gameNetworkInterface->sendTextMessage(szMsg,-1, true);
|
||||
gameNetworkInterface->sendTextMessage(szMsg,-1, true, "");
|
||||
}
|
||||
|
||||
std::string sError = "Error [#3]: Game is out of sync, please check log files for details.";
|
||||
|
|
|
@ -958,7 +958,13 @@ void Game::ReplaceDisconnectedNetworkPlayersWithAI(bool isNetworkGame, NetworkRo
|
|||
}
|
||||
sprintf(szBuf,msg.c_str(),i+1,this->gameSettings.getNetworkPlayerName(i).c_str());
|
||||
}
|
||||
server->sendTextMessage(szBuf,-1,true);
|
||||
|
||||
Lang &lang= Lang::getInstance();
|
||||
const vector<string> languageList = this->gameSettings.getUniqueNetworkPlayerLanguages();
|
||||
for(unsigned int j = 0; j < languageList.size(); ++j) {
|
||||
bool localEcho = (languageList[j] == lang.getLanguage());
|
||||
server->sendTextMessage(szBuf,-1,localEcho,languageList[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "game_constants.h"
|
||||
#include "conversion.h"
|
||||
#include <algorithm>
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using namespace Shared::Util;
|
||||
|
@ -45,6 +46,7 @@ private:
|
|||
string factionTypeNames[GameConstants::maxPlayers]; //faction names
|
||||
string networkPlayerNames[GameConstants::maxPlayers];
|
||||
int networkPlayerStatuses[GameConstants::maxPlayers];
|
||||
string networkPlayerLanguages[GameConstants::maxPlayers];
|
||||
|
||||
ControlType factionControls[GameConstants::maxPlayers];
|
||||
int resourceMultiplierIndex[GameConstants::maxPlayers];
|
||||
|
@ -91,6 +93,7 @@ public:
|
|||
factionTypeNames[i] = "";
|
||||
networkPlayerNames[i] = "";
|
||||
networkPlayerStatuses[i] = 0;
|
||||
networkPlayerLanguages[i] = "english";
|
||||
factionControls[i] = ctClosed;
|
||||
resourceMultiplierIndex[i] = 1.0f;
|
||||
teams[i] = 0;
|
||||
|
@ -117,6 +120,22 @@ public:
|
|||
const string &getFactionTypeName(int factionIndex) const {return factionTypeNames[factionIndex];}
|
||||
const string &getNetworkPlayerName(int factionIndex) const {return networkPlayerNames[factionIndex];}
|
||||
const int getNetworkPlayerStatuses(int factionIndex) const { return networkPlayerStatuses[factionIndex];}
|
||||
const string getNetworkPlayerLanguages(int factionIndex) const { return networkPlayerLanguages[factionIndex];}
|
||||
|
||||
const vector<string> getUniqueNetworkPlayerLanguages() const {
|
||||
vector<string> languageList;
|
||||
for(int i = 0; i < GameConstants::maxPlayers; ++i) {
|
||||
if(networkPlayerLanguages[i] != "") {
|
||||
if(std::find(languageList.begin(),languageList.end(),networkPlayerLanguages[i]) == languageList.end()) {
|
||||
languageList.push_back(networkPlayerLanguages[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(languageList.size() == 0) {
|
||||
languageList.push_back("");
|
||||
}
|
||||
return languageList;
|
||||
}
|
||||
|
||||
const string getNetworkPlayerNameByPlayerIndex(int playerIndex) const {
|
||||
string result = "";
|
||||
|
@ -176,6 +195,8 @@ public:
|
|||
void setFactionTypeName(int factionIndex, const string& factionTypeName) {this->factionTypeNames[factionIndex]= factionTypeName;}
|
||||
void setNetworkPlayerName(int factionIndex,const string& playername) {this->networkPlayerNames[factionIndex]= playername;}
|
||||
void setNetworkPlayerStatuses(int factionIndex,int status) {this->networkPlayerStatuses[factionIndex]= status;}
|
||||
void setNetworkPlayerLanguages(int factionIndex, string language) {this->networkPlayerLanguages[factionIndex]=language;}
|
||||
|
||||
void setFactionControl(int factionIndex, ControlType controller) {this->factionControls[factionIndex]= controller;}
|
||||
void setResourceMultiplierIndex(int factionIndex, int multiplierIndex) {this->resourceMultiplierIndex[factionIndex]= multiplierIndex;}
|
||||
|
||||
|
@ -220,6 +241,7 @@ public:
|
|||
result += "player index = " + intToStr(idx) + "\n";
|
||||
result += "factionTypeName = " + factionTypeNames[idx] + "\n";
|
||||
result += "networkPlayerName = " + networkPlayerNames[idx] + "\n";
|
||||
result += "networkPlayerLanguage = " + networkPlayerLanguages[idx] + "\n";
|
||||
|
||||
result += "factionControl = " + intToStr(factionControls[idx]) + "\n";
|
||||
result += "resourceMultiplierIndex = " + intToStr(resourceMultiplierIndex[idx]) + "\n";
|
||||
|
|
|
@ -37,9 +37,17 @@ Lang &Lang::getInstance(){
|
|||
|
||||
void Lang::loadStrings(const string &language) {
|
||||
this->language= language;
|
||||
strings.clear();
|
||||
loadStrings(language, strings, true);
|
||||
}
|
||||
|
||||
void Lang::loadStrings(const string &language, Properties &properties, bool fileMustExist) {
|
||||
properties.clear();
|
||||
string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey);
|
||||
strings.load(data_path + "data/lang/"+language+".lng");
|
||||
string languageFile = data_path + "data/lang/" + language + ".lng";
|
||||
if(fileMustExist == false && fileExists(languageFile) == false) {
|
||||
return;
|
||||
}
|
||||
properties.load(languageFile);
|
||||
}
|
||||
|
||||
void Lang::loadScenarioStrings(const string &scenarioDir, const string &scenarioName){
|
||||
|
@ -75,12 +83,21 @@ void Lang::loadScenarioStrings(const string &scenarioDir, const string &scenario
|
|||
}
|
||||
}
|
||||
|
||||
bool Lang::hasString(const string &s) {
|
||||
bool Lang::hasString(const string &s, string language) {
|
||||
bool hasString = false;
|
||||
try {
|
||||
if(language != "") {
|
||||
if(otherLanguageStrings.find(language) == otherLanguageStrings.end()) {
|
||||
loadStrings(language, otherLanguageStrings[language], false);
|
||||
}
|
||||
string result = otherLanguageStrings[language].getString(s);
|
||||
hasString = true;
|
||||
}
|
||||
else {
|
||||
string result = strings.getString(s);
|
||||
hasString = true;
|
||||
}
|
||||
}
|
||||
catch(exception &ex) {
|
||||
if(strings.getpath() != "") {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||
|
@ -89,10 +106,24 @@ bool Lang::hasString(const string &s) {
|
|||
return hasString;
|
||||
}
|
||||
|
||||
string Lang::get(const string &s) {
|
||||
bool Lang::isLanguageLocal(string compareLanguage) const {
|
||||
return (compareLanguage == language);
|
||||
}
|
||||
|
||||
string Lang::get(const string &s, string language) {
|
||||
try {
|
||||
string result = strings.getString(s);
|
||||
string result = "";
|
||||
if(language != "") {
|
||||
if(otherLanguageStrings.find(language) == otherLanguageStrings.end()) {
|
||||
loadStrings(language, otherLanguageStrings[language], false);
|
||||
}
|
||||
result = otherLanguageStrings[language].getString(s);
|
||||
replaceAll(result, "\\n", "\n");
|
||||
}
|
||||
else {
|
||||
result = strings.getString(s);
|
||||
replaceAll(result, "\\n", "\n");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
catch(exception &ex) {
|
||||
|
|
|
@ -31,16 +31,21 @@ private:
|
|||
Properties strings;
|
||||
Properties scenarioStrings;
|
||||
|
||||
std::map<string,Properties> otherLanguageStrings;
|
||||
|
||||
private:
|
||||
Lang(){};
|
||||
void loadStrings(const string &language, Properties &properties, bool fileMustExist);
|
||||
|
||||
public:
|
||||
static Lang &getInstance();
|
||||
void loadStrings(const string &language);
|
||||
void loadScenarioStrings(const string &scenarioDir, const string &scenarioName);
|
||||
string get(const string &s);
|
||||
bool hasString(const string &s);
|
||||
string get(const string &s,string language="");
|
||||
bool hasString(const string &s, string language="");
|
||||
string getScenarioString(const string &s);
|
||||
string getLanguage() const { return language; }
|
||||
bool isLanguageLocal(string compareLanguage) const;
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
|
|
@ -502,14 +502,19 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){
|
|||
if(ftpMissingDataType == ftpmsg_MissingMap) {
|
||||
getMissingMapFromFTPServerInProgress = true;
|
||||
|
||||
Lang &lang= Lang::getInstance();
|
||||
const vector<string> languageList = clientInterface->getGameSettings()->getUniqueNetworkPlayerLanguages();
|
||||
for(unsigned int i = 0; i < languageList.size(); ++i) {
|
||||
char szMsg[1024]="";
|
||||
if(lang.hasString("DataMissingMapNowDownloading") == true) {
|
||||
sprintf(szMsg,lang.get("DataMissingMapNowDownloading").c_str(),getHumanPlayerName().c_str(),getMissingMapFromFTPServer.c_str());
|
||||
if(lang.hasString("DataMissingMapNowDownloading",languageList[i]) == true) {
|
||||
sprintf(szMsg,lang.get("DataMissingMapNowDownloading",languageList[i]).c_str(),getHumanPlayerName().c_str(),getMissingMapFromFTPServer.c_str());
|
||||
}
|
||||
else {
|
||||
sprintf(szMsg,"Player: %s is attempting to download the map: %s",getHumanPlayerName().c_str(),getMissingMapFromFTPServer.c_str());
|
||||
}
|
||||
clientInterface->sendTextMessage(szMsg,-1, true);
|
||||
bool localEcho = lang.isLanguageLocal(languageList[i]);
|
||||
clientInterface->sendTextMessage(szMsg,-1, localEcho,languageList[i]);
|
||||
}
|
||||
|
||||
if(ftpClientThread != NULL) {
|
||||
ftpClientThread->addMapToRequests(getMissingMapFromFTPServer);
|
||||
|
@ -521,14 +526,19 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){
|
|||
else if(ftpMissingDataType == ftpmsg_MissingTileset) {
|
||||
getMissingTilesetFromFTPServerInProgress = true;
|
||||
|
||||
Lang &lang= Lang::getInstance();
|
||||
const vector<string> languageList = clientInterface->getGameSettings()->getUniqueNetworkPlayerLanguages();
|
||||
for(unsigned int i = 0; i < languageList.size(); ++i) {
|
||||
char szMsg[1024]="";
|
||||
if(lang.hasString("DataMissingTilesetNowDownloading") == true) {
|
||||
sprintf(szMsg,lang.get("DataMissingTilesetNowDownloading").c_str(),getHumanPlayerName().c_str(),getMissingTilesetFromFTPServer.c_str());
|
||||
if(lang.hasString("DataMissingTilesetNowDownloading",languageList[i]) == true) {
|
||||
sprintf(szMsg,lang.get("DataMissingTilesetNowDownloading",languageList[i]).c_str(),getHumanPlayerName().c_str(),getMissingTilesetFromFTPServer.c_str());
|
||||
}
|
||||
else {
|
||||
sprintf(szMsg,"Player: %s is attempting to download the tileset: %s",getHumanPlayerName().c_str(),getMissingTilesetFromFTPServer.c_str());
|
||||
}
|
||||
clientInterface->sendTextMessage(szMsg,-1, true);
|
||||
bool localEcho = lang.isLanguageLocal(languageList[i]);
|
||||
clientInterface->sendTextMessage(szMsg,-1, localEcho,languageList[i]);
|
||||
}
|
||||
|
||||
if(ftpClientThread != NULL) {
|
||||
ftpClientThread->addTilesetToRequests(getMissingTilesetFromFTPServer);
|
||||
|
@ -540,14 +550,19 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){
|
|||
else if(ftpMissingDataType == ftpmsg_MissingTechtree) {
|
||||
getMissingTechtreeFromFTPServerInProgress = true;
|
||||
|
||||
Lang &lang= Lang::getInstance();
|
||||
const vector<string> languageList = clientInterface->getGameSettings()->getUniqueNetworkPlayerLanguages();
|
||||
for(unsigned int i = 0; i < languageList.size(); ++i) {
|
||||
char szMsg[1024]="";
|
||||
if(lang.hasString("DataMissingTechtreeNowDownloading") == true) {
|
||||
sprintf(szMsg,lang.get("DataMissingTechtreeNowDownloading").c_str(),getHumanPlayerName().c_str(),getMissingTechtreeFromFTPServer.c_str());
|
||||
if(lang.hasString("DataMissingTechtreeNowDownloading",languageList[i]) == true) {
|
||||
sprintf(szMsg,lang.get("DataMissingTechtreeNowDownloading",languageList[i]).c_str(),getHumanPlayerName().c_str(),getMissingTechtreeFromFTPServer.c_str());
|
||||
}
|
||||
else {
|
||||
sprintf(szMsg,"Player: %s is attempting to download the techtree: %s",getHumanPlayerName().c_str(),getMissingTechtreeFromFTPServer.c_str());
|
||||
}
|
||||
clientInterface->sendTextMessage(szMsg,-1, true);
|
||||
bool localEcho = lang.isLanguageLocal(languageList[i]);
|
||||
clientInterface->sendTextMessage(szMsg,-1, localEcho,languageList[i]);
|
||||
}
|
||||
|
||||
if(ftpClientThread != NULL) {
|
||||
ftpClientThread->addTechtreeToRequests(getMissingTechtreeFromFTPServer);
|
||||
|
@ -565,8 +580,12 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){
|
|||
soundRenderer.playFx(coreData.getClickSoundA());
|
||||
if(clientInterface->getSocket() != NULL) {
|
||||
if(clientInterface->isConnected() == true) {
|
||||
string sQuitText = lang.get("QuitGame");
|
||||
clientInterface->sendTextMessage(sQuitText,-1);
|
||||
Lang &lang= Lang::getInstance();
|
||||
const vector<string> languageList = clientInterface->getGameSettings()->getUniqueNetworkPlayerLanguages();
|
||||
for(unsigned int i = 0; i < languageList.size(); ++i) {
|
||||
string sQuitText = lang.get("QuitGame",languageList[i]);
|
||||
clientInterface->sendTextMessage(sQuitText,-1,false,languageList[i]);
|
||||
}
|
||||
sleep(1);
|
||||
}
|
||||
clientInterface->close();
|
||||
|
@ -604,7 +623,8 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){
|
|||
listBoxTeams[i].getSelectedItemIndex(),
|
||||
getHumanPlayerName(),
|
||||
getNetworkPlayerStatus(),
|
||||
switchSetupRequestFlagType);
|
||||
switchSetupRequestFlagType,
|
||||
lang.getLanguage());
|
||||
switchSetupRequestFlagType= ssrft_None;
|
||||
}
|
||||
break;
|
||||
|
@ -622,7 +642,8 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){
|
|||
listBoxTeams[i].getSelectedItemIndex(),
|
||||
getHumanPlayerName(),
|
||||
getNetworkPlayerStatus(),
|
||||
switchSetupRequestFlagType);
|
||||
switchSetupRequestFlagType,
|
||||
lang.getLanguage());
|
||||
switchSetupRequestFlagType= ssrft_None;
|
||||
}
|
||||
break;
|
||||
|
@ -645,7 +666,8 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){
|
|||
//labelPlayerNames[myCurrentIndex].getText(),
|
||||
getHumanPlayerName(),
|
||||
getNetworkPlayerStatus(),
|
||||
switchSetupRequestFlagType);
|
||||
switchSetupRequestFlagType,
|
||||
lang.getLanguage());
|
||||
labelPlayerNames[myCurrentIndex].setText("");
|
||||
labelPlayerNames[i].setText("");
|
||||
switchSetupRequestFlagType= ssrft_None;
|
||||
|
@ -674,7 +696,8 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){
|
|||
listBoxTeams[clientInterface->getPlayerIndex()].getSelectedItemIndex(),
|
||||
getHumanPlayerName(),
|
||||
getNetworkPlayerStatus(),
|
||||
switchSetupRequestFlagType);
|
||||
switchSetupRequestFlagType,
|
||||
lang.getLanguage());
|
||||
switchSetupRequestFlagType=ssrft_None;
|
||||
}
|
||||
}
|
||||
|
@ -949,10 +972,15 @@ void MenuStateConnectedGame::update() {
|
|||
pingCount >= 3 && clientInterface->getLastPingLag() >= (GameConstants::networkPingInterval * 3)) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
string playerNameStr = getHumanPlayerName();
|
||||
clientInterface->sendTextMessage(lang.get("ConnectionTimedOut"),-1);
|
||||
Lang &lang= Lang::getInstance();
|
||||
const vector<string> languageList = clientInterface->getGameSettings()->getUniqueNetworkPlayerLanguages();
|
||||
for(unsigned int i = 0; i < languageList.size(); ++i) {
|
||||
//string playerNameStr = getHumanPlayerName();
|
||||
clientInterface->sendTextMessage(lang.get("ConnectionTimedOut",languageList[i]),-1,false,languageList[i]);
|
||||
sleep(1);
|
||||
clientInterface->close();
|
||||
}
|
||||
}
|
||||
|
||||
pingCount++;
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
@ -1054,7 +1082,14 @@ void MenuStateConnectedGame::update() {
|
|||
if(updateDataSynchDetailText == true &&
|
||||
lastMapDataSynchError != lang.get("DataNotSynchedMap") + " " + listBoxMap.getSelectedItem()) {
|
||||
lastMapDataSynchError = lang.get("DataNotSynchedMap") + " " + listBoxMap.getSelectedItem();
|
||||
clientInterface->sendTextMessage(lastMapDataSynchError,-1,true);
|
||||
|
||||
Lang &lang= Lang::getInstance();
|
||||
const vector<string> languageList = clientInterface->getGameSettings()->getUniqueNetworkPlayerLanguages();
|
||||
for(unsigned int i = 0; i < languageList.size(); ++i) {
|
||||
string msg = lang.get("DataNotSynchedMap",languageList[i]) + " " + listBoxMap.getSelectedItem();
|
||||
bool localEcho = lang.isLanguageLocal(languageList[i]);
|
||||
clientInterface->sendTextMessage(msg,-1,localEcho,languageList[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1065,7 +1100,14 @@ void MenuStateConnectedGame::update() {
|
|||
if(updateDataSynchDetailText == true &&
|
||||
lastTileDataSynchError != lang.get("DataNotSynchedTileset") + " " + listBoxTileset.getSelectedItem()) {
|
||||
lastTileDataSynchError = lang.get("DataNotSynchedTileset") + " " + listBoxTileset.getSelectedItem();
|
||||
clientInterface->sendTextMessage(lastTileDataSynchError,-1,true);
|
||||
|
||||
Lang &lang= Lang::getInstance();
|
||||
const vector<string> languageList = clientInterface->getGameSettings()->getUniqueNetworkPlayerLanguages();
|
||||
for(unsigned int i = 0; i < languageList.size(); ++i) {
|
||||
string msg = lang.get("DataNotSynchedTileset",languageList[i]) + " " + listBoxTileset.getSelectedItem();
|
||||
bool localEcho = lang.isLanguageLocal(languageList[i]);
|
||||
clientInterface->sendTextMessage(msg,-1,localEcho,languageList[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1076,7 +1118,18 @@ void MenuStateConnectedGame::update() {
|
|||
if(updateDataSynchDetailText == true &&
|
||||
lastTechtreeDataSynchError != lang.get("DataNotSynchedTechtree") + " " + listBoxTechTree.getSelectedItem()) {
|
||||
lastTechtreeDataSynchError = lang.get("DataNotSynchedTechtree") + " " + listBoxTechTree.getSelectedItem();
|
||||
clientInterface->sendTextMessage(lastTechtreeDataSynchError,-1,true);
|
||||
|
||||
Lang &lang= Lang::getInstance();
|
||||
const vector<string> languageList = clientInterface->getGameSettings()->getUniqueNetworkPlayerLanguages();
|
||||
for(unsigned int i = 0; i < languageList.size(); ++i) {
|
||||
string msg = lang.get("DataNotSynchedTechtree",languageList[i]) + " " + listBoxTechTree.getSelectedItem();
|
||||
bool localEcho = lang.isLanguageLocal(languageList[i]);
|
||||
clientInterface->sendTextMessage(msg,-1,localEcho,languageList[i]);
|
||||
}
|
||||
|
||||
//const vector<string> languageList = clientInterface->getGameSettings()->getUniqueNetworkPlayerLanguages();
|
||||
for(unsigned int i = 0; i < languageList.size(); ++i) {
|
||||
bool localEcho = lang.isLanguageLocal(languageList[i]);
|
||||
|
||||
string mismatchedFactionText = "";
|
||||
vector<pair<string,int32> > serverFactionCRCList = gameSettings->getFactionCRCList();
|
||||
|
@ -1092,7 +1145,12 @@ void MenuStateConnectedGame::update() {
|
|||
foundFaction = true;
|
||||
if(serverFaction.second != clientFaction.second) {
|
||||
if(mismatchedFactionText == "") {
|
||||
mismatchedFactionText = "The following factions are mismatched: [" + intToStr(factionCRCList.size()) + "][" + intToStr(serverFactionCRCList.size()) + "] - ";
|
||||
mismatchedFactionText = "The following factions are mismatched: ";
|
||||
if(lang.hasString("MismatchedFactions",languageList[i]) == true) {
|
||||
mismatchedFactionText = lang.get("MismatchedFactions",languageList[i]);
|
||||
}
|
||||
|
||||
mismatchedFactionText += " ["+ intToStr(factionCRCList.size()) + "][" + intToStr(serverFactionCRCList.size()) + "] - ";
|
||||
}
|
||||
mismatchedFactionText += serverFaction.first + ", ";
|
||||
}
|
||||
|
@ -1102,11 +1160,21 @@ void MenuStateConnectedGame::update() {
|
|||
|
||||
if(foundFaction == false) {
|
||||
if(mismatchedFactionText == "") {
|
||||
mismatchedFactionText = "The following factions are mismatched: [" + intToStr(factionCRCList.size()) + "][" + intToStr(serverFactionCRCList.size()) + "] - ";
|
||||
mismatchedFactionText = "The following factions are mismatched: ";
|
||||
if(lang.hasString("MismatchedFactions",languageList[i]) == true) {
|
||||
mismatchedFactionText = lang.get("MismatchedFactions",languageList[i]);
|
||||
}
|
||||
|
||||
mismatchedFactionText += " ["+ intToStr(factionCRCList.size()) + "][" + intToStr(serverFactionCRCList.size()) + "] - ";
|
||||
}
|
||||
if(lang.hasString("MismatchedFactionsMissing",languageList[i]) == true) {
|
||||
mismatchedFactionText += serverFaction.first + " " + lang.get("MismatchedFactionsMissing",languageList[i]) + ", ";
|
||||
}
|
||||
else {
|
||||
mismatchedFactionText += serverFaction.first + " (missing), ";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(unsigned int clientFactionIdx = 0; clientFactionIdx < factionCRCList.size(); ++clientFactionIdx) {
|
||||
pair<string,int32> &clientFaction = factionCRCList[clientFactionIdx];
|
||||
|
@ -1123,14 +1191,25 @@ void MenuStateConnectedGame::update() {
|
|||
|
||||
if(foundFaction == false) {
|
||||
if(mismatchedFactionText == "") {
|
||||
mismatchedFactionText = "The following factions are mismatched: [" + intToStr(factionCRCList.size()) + "][" + intToStr(serverFactionCRCList.size()) + "] - ";
|
||||
mismatchedFactionText = "The following factions are mismatched: ";
|
||||
if(lang.hasString("MismatchedFactions",languageList[i]) == true) {
|
||||
mismatchedFactionText = lang.get("MismatchedFactions",languageList[i]);
|
||||
}
|
||||
|
||||
mismatchedFactionText += " ["+ intToStr(factionCRCList.size()) + "][" + intToStr(serverFactionCRCList.size()) + "] - ";
|
||||
}
|
||||
if(lang.hasString("MismatchedFactionsExtra",languageList[i]) == true) {
|
||||
mismatchedFactionText += clientFaction.first + " " + lang.get("MismatchedFactionsExtra",languageList[i]) + ", ";
|
||||
}
|
||||
else {
|
||||
mismatchedFactionText += clientFaction.first + " (extra), ";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(mismatchedFactionText != "") {
|
||||
clientInterface->sendTextMessage(mismatchedFactionText,-1,true);
|
||||
clientInterface->sendTextMessage(mismatchedFactionText,-1,localEcho,languageList[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1157,7 +1236,7 @@ void MenuStateConnectedGame::update() {
|
|||
clientInterface->getReceivedDataSynchCheck() &&
|
||||
lastMapDataSynchError != "map CRC mismatch, " + listBoxMap.getSelectedItem()) {
|
||||
lastMapDataSynchError = "map CRC mismatch, " + listBoxMap.getSelectedItem();
|
||||
clientInterface->sendTextMessage(lastMapDataSynchError,-1,true);
|
||||
clientInterface->sendTextMessage(lastMapDataSynchError,-1,true, "");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1167,7 +1246,7 @@ void MenuStateConnectedGame::update() {
|
|||
clientInterface->getReceivedDataSynchCheck() &&
|
||||
lastTileDataSynchError != "tile CRC mismatch, " + listBoxTileset.getSelectedItem()) {
|
||||
lastTileDataSynchError = "tile CRC mismatch, " + listBoxTileset.getSelectedItem();
|
||||
clientInterface->sendTextMessage(lastTileDataSynchError,-1,true);
|
||||
clientInterface->sendTextMessage(lastTileDataSynchError,-1,true,"");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1183,11 +1262,11 @@ void MenuStateConnectedGame::update() {
|
|||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] report: %s\n",__FILE__,__FUNCTION__,__LINE__,report.c_str());
|
||||
|
||||
clientInterface->sendTextMessage("techtree CRC mismatch",-1,true);
|
||||
clientInterface->sendTextMessage("techtree CRC mismatch",-1,true,"");
|
||||
vector<string> reportLineTokens;
|
||||
Tokenize(report,reportLineTokens,"\n");
|
||||
for(int reportLine = 0; reportLine < reportLineTokens.size(); ++reportLine) {
|
||||
clientInterface->sendTextMessage(reportLineTokens[reportLine],-1,true);
|
||||
clientInterface->sendTextMessage(reportLineTokens[reportLine],-1,true,"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1328,14 +1407,19 @@ void MenuStateConnectedGame::update() {
|
|||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
Lang &lang= Lang::getInstance();
|
||||
const vector<string> languageList = clientInterface->getGameSettings()->getUniqueNetworkPlayerLanguages();
|
||||
for(unsigned int i = 0; i < languageList.size(); ++i) {
|
||||
|
||||
char szMsg[1024]="";
|
||||
if(lang.hasString("DataMissingTileset") == true) {
|
||||
sprintf(szMsg,lang.get("DataMissingTileset").c_str(),getHumanPlayerName().c_str(),gameSettings->getTileset().c_str());
|
||||
if(lang.hasString("DataMissingTileset",languageList[i]) == true) {
|
||||
sprintf(szMsg,lang.get("DataMissingTileset",languageList[i]).c_str(),getHumanPlayerName().c_str(),gameSettings->getTileset().c_str());
|
||||
}
|
||||
else {
|
||||
sprintf(szMsg,"Player: %s is missing the tileset: %s",getHumanPlayerName().c_str(),gameSettings->getTileset().c_str());
|
||||
}
|
||||
clientInterface->sendTextMessage(szMsg,-1, true);
|
||||
clientInterface->sendTextMessage(szMsg,-1, lang.isLanguageLocal(languageList[i]),languageList[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
listBoxTileset.setItems(tilesets);
|
||||
|
@ -1375,14 +1459,19 @@ void MenuStateConnectedGame::update() {
|
|||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
Lang &lang= Lang::getInstance();
|
||||
const vector<string> languageList = clientInterface->getGameSettings()->getUniqueNetworkPlayerLanguages();
|
||||
for(unsigned int i = 0; i < languageList.size(); ++i) {
|
||||
|
||||
char szMsg[1024]="";
|
||||
if(lang.hasString("DataMissingTechtree") == true) {
|
||||
sprintf(szMsg,lang.get("DataMissingTechtree").c_str(),getHumanPlayerName().c_str(),gameSettings->getTech().c_str());
|
||||
if(lang.hasString("DataMissingTechtree",languageList[i]) == true) {
|
||||
sprintf(szMsg,lang.get("DataMissingTechtree",languageList[i]).c_str(),getHumanPlayerName().c_str(),gameSettings->getTech().c_str());
|
||||
}
|
||||
else {
|
||||
sprintf(szMsg,"Player: %s is missing the techtree: %s",getHumanPlayerName().c_str(),gameSettings->getTech().c_str());
|
||||
}
|
||||
clientInterface->sendTextMessage(szMsg,-1, true);
|
||||
clientInterface->sendTextMessage(szMsg,-1, lang.isLanguageLocal(languageList[i]),languageList[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
listBoxTechTree.setItems(techtree);
|
||||
|
@ -1616,7 +1705,8 @@ void MenuStateConnectedGame::update() {
|
|||
-1,
|
||||
getHumanPlayerName(),
|
||||
getNetworkPlayerStatus(),
|
||||
switchSetupRequestFlagType);
|
||||
switchSetupRequestFlagType,
|
||||
lang.getLanguage());
|
||||
|
||||
switchSetupRequestFlagType=ssrft_None;
|
||||
}
|
||||
|
@ -1717,14 +1807,19 @@ bool MenuStateConnectedGame::loadFactions(const GameSettings *gameSettings, bool
|
|||
gameSettings->getTech() != "") {
|
||||
lastMissingTechtree = gameSettings->getTech();
|
||||
|
||||
Lang &lang= Lang::getInstance();
|
||||
const vector<string> languageList = clientInterface->getGameSettings()->getUniqueNetworkPlayerLanguages();
|
||||
for(unsigned int i = 0; i < languageList.size(); ++i) {
|
||||
|
||||
char szMsg[1024]="";
|
||||
if(lang.hasString("DataMissingTechtree") == true) {
|
||||
sprintf(szMsg,lang.get("DataMissingTechtree").c_str(),getHumanPlayerName().c_str(),gameSettings->getTech().c_str());
|
||||
if(lang.hasString("DataMissingTechtree",languageList[i]) == true) {
|
||||
sprintf(szMsg,lang.get("DataMissingTechtree",languageList[i]).c_str(),getHumanPlayerName().c_str(),gameSettings->getTech().c_str());
|
||||
}
|
||||
else {
|
||||
sprintf(szMsg,"Player: %s is missing the techtree: %s",getHumanPlayerName().c_str(),gameSettings->getTech().c_str());
|
||||
}
|
||||
clientInterface->sendTextMessage(szMsg,-1, true);
|
||||
clientInterface->sendTextMessage(szMsg,-1, lang.isLanguageLocal(languageList[i]),languageList[i]);
|
||||
}
|
||||
}
|
||||
|
||||
foundFactions = false;
|
||||
|
@ -1991,14 +2086,19 @@ bool MenuStateConnectedGame::loadMapInfo(string file, MapInfo *mapInfo, bool loa
|
|||
|
||||
lastMissingMap = gameSettings->getMap();
|
||||
|
||||
Lang &lang= Lang::getInstance();
|
||||
const vector<string> languageList = clientInterface->getGameSettings()->getUniqueNetworkPlayerLanguages();
|
||||
for(unsigned int i = 0; i < languageList.size(); ++i) {
|
||||
|
||||
char szMsg[1024]="";
|
||||
if(lang.hasString("DataMissingMap") == true) {
|
||||
sprintf(szMsg,lang.get("DataMissingMap").c_str(),getHumanPlayerName().c_str(),gameSettings->getMap().c_str());
|
||||
if(lang.hasString("DataMissingMap",languageList[i]) == true) {
|
||||
sprintf(szMsg,lang.get("DataMissingMap",languageList[i]).c_str(),getHumanPlayerName().c_str(),gameSettings->getMap().c_str());
|
||||
}
|
||||
else {
|
||||
sprintf(szMsg,"Player: %s is missing the map: %s",getHumanPlayerName().c_str(),gameSettings->getMap().c_str());
|
||||
}
|
||||
clientInterface->sendTextMessage(szMsg,-1, true);
|
||||
clientInterface->sendTextMessage(szMsg,-1, lang.isLanguageLocal(languageList[i]),languageList[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2079,13 +2179,22 @@ void MenuStateConnectedGame::FTPClient_CallbackEvent(string itemName,
|
|||
safeMutexFTPProgress.ReleaseLock();
|
||||
|
||||
if(itemName != "" && (lastProgress.first / 25) < (fileProgress / 25)) {
|
||||
char szMsg[1024]="";
|
||||
sprintf(szMsg,"Player: %s download progress for [%s] is %d %%",getHumanPlayerName().c_str(),itemName.c_str(),fileProgress);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] szMsg [%s] lastProgress.first = %d, fileProgress = %d\n",__FILE__,__FUNCTION__,__LINE__,szMsg,lastProgress.first,fileProgress);
|
||||
|
||||
NetworkManager &networkManager= NetworkManager::getInstance();
|
||||
ClientInterface* clientInterface= networkManager.getClientInterface();
|
||||
clientInterface->sendTextMessage(szMsg,-1, true);
|
||||
|
||||
Lang &lang= Lang::getInstance();
|
||||
const vector<string> languageList = clientInterface->getGameSettings()->getUniqueNetworkPlayerLanguages();
|
||||
for(unsigned int i = 0; i < languageList.size(); ++i) {
|
||||
char szMsg[1024]="";
|
||||
if(lang.hasString("FileDownloadProgress",languageList[i]) == true) {
|
||||
sprintf(szMsg,lang.get("FileDownloadProgress",languageList[i]).c_str(),getHumanPlayerName().c_str(),itemName.c_str(),fileProgress);
|
||||
}
|
||||
else {
|
||||
sprintf(szMsg,"Player: %s download progress for [%s] is %d %%",getHumanPlayerName().c_str(),itemName.c_str(),fileProgress);
|
||||
}
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] szMsg [%s] lastProgress.first = %d, fileProgress = %d\n",__FILE__,__FUNCTION__,__LINE__,szMsg,lastProgress.first,fileProgress);
|
||||
clientInterface->sendTextMessage(szMsg,-1, lang.isLanguageLocal(languageList[i]),languageList[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2111,26 +2220,34 @@ void MenuStateConnectedGame::FTPClient_CallbackEvent(string itemName,
|
|||
checksum.addFile(file);
|
||||
lastCheckedCRCMapValue = checksum.getSum();
|
||||
|
||||
Lang &lang= Lang::getInstance();
|
||||
const vector<string> languageList = clientInterface->getGameSettings()->getUniqueNetworkPlayerLanguages();
|
||||
for(unsigned int i = 0; i < languageList.size(); ++i) {
|
||||
char szMsg[1024]="";
|
||||
if(lang.hasString("DataMissingMapSuccessDownload") == true) {
|
||||
sprintf(szMsg,lang.get("DataMissingMapSuccessDownload").c_str(),getHumanPlayerName().c_str(),itemName.c_str());
|
||||
if(lang.hasString("DataMissingMapSuccessDownload",languageList[i]) == true) {
|
||||
sprintf(szMsg,lang.get("DataMissingMapSuccessDownload",languageList[i]).c_str(),getHumanPlayerName().c_str(),itemName.c_str());
|
||||
}
|
||||
else {
|
||||
sprintf(szMsg,"Player: %s SUCCESSFULLY downloaded the map: %s",getHumanPlayerName().c_str(),itemName.c_str());
|
||||
}
|
||||
clientInterface->sendTextMessage(szMsg,-1, true);
|
||||
clientInterface->sendTextMessage(szMsg,-1, lang.isLanguageLocal(languageList[i]),languageList[i]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
curl_version_info_data *curlVersion= curl_version_info(CURLVERSION_NOW);
|
||||
|
||||
Lang &lang= Lang::getInstance();
|
||||
const vector<string> languageList = clientInterface->getGameSettings()->getUniqueNetworkPlayerLanguages();
|
||||
for(unsigned int i = 0; i < languageList.size(); ++i) {
|
||||
char szMsg[1024]="";
|
||||
if(lang.hasString("DataMissingMapFailDownload") == true) {
|
||||
sprintf(szMsg,lang.get("DataMissingMapFailDownload").c_str(),getHumanPlayerName().c_str(),itemName.c_str(),curlVersion->version);
|
||||
if(lang.hasString("DataMissingMapFailDownload",languageList[i]) == true) {
|
||||
sprintf(szMsg,lang.get("DataMissingMapFailDownload",languageList[i]).c_str(),getHumanPlayerName().c_str(),itemName.c_str(),curlVersion->version);
|
||||
}
|
||||
else {
|
||||
sprintf(szMsg,"Player: %s FAILED to download the map: [%s] using CURL version [%s]",getHumanPlayerName().c_str(),itemName.c_str(),curlVersion->version);
|
||||
}
|
||||
clientInterface->sendTextMessage(szMsg,-1, true);
|
||||
clientInterface->sendTextMessage(szMsg,-1, lang.isLanguageLocal(languageList[i]),languageList[i]);
|
||||
}
|
||||
|
||||
console.addLine(result.second,true);
|
||||
}
|
||||
|
@ -2148,14 +2265,19 @@ void MenuStateConnectedGame::FTPClient_CallbackEvent(string itemName,
|
|||
const GameSettings *gameSettings = clientInterface->getGameSettings();
|
||||
|
||||
if(result.first == ftp_crt_SUCCESS) {
|
||||
|
||||
Lang &lang= Lang::getInstance();
|
||||
const vector<string> languageList = clientInterface->getGameSettings()->getUniqueNetworkPlayerLanguages();
|
||||
for(unsigned int i = 0; i < languageList.size(); ++i) {
|
||||
char szMsg[1024]="";
|
||||
if(lang.hasString("DataMissingTilesetSuccessDownload") == true) {
|
||||
sprintf(szMsg,lang.get("DataMissingTilesetSuccessDownload").c_str(),getHumanPlayerName().c_str(),itemName.c_str());
|
||||
if(lang.hasString("DataMissingTilesetSuccessDownload",languageList[i]) == true) {
|
||||
sprintf(szMsg,lang.get("DataMissingTilesetSuccessDownload",languageList[i]).c_str(),getHumanPlayerName().c_str(),itemName.c_str());
|
||||
}
|
||||
else {
|
||||
sprintf(szMsg,"Player: %s SUCCESSFULLY downloaded the tileset: %s",getHumanPlayerName().c_str(),itemName.c_str());
|
||||
}
|
||||
clientInterface->sendTextMessage(szMsg,-1, true);
|
||||
clientInterface->sendTextMessage(szMsg,-1, lang.isLanguageLocal(languageList[i]),languageList[i]);
|
||||
}
|
||||
|
||||
// START
|
||||
// Clear the CRC Cache if it is populated
|
||||
|
@ -2183,14 +2305,19 @@ void MenuStateConnectedGame::FTPClient_CallbackEvent(string itemName,
|
|||
else {
|
||||
curl_version_info_data *curlVersion= curl_version_info(CURLVERSION_NOW);
|
||||
|
||||
Lang &lang= Lang::getInstance();
|
||||
const vector<string> languageList = clientInterface->getGameSettings()->getUniqueNetworkPlayerLanguages();
|
||||
for(unsigned int i = 0; i < languageList.size(); ++i) {
|
||||
char szMsg[1024]="";
|
||||
if(lang.hasString("DataMissingTilesetFailDownload") == true) {
|
||||
sprintf(szMsg,lang.get("DataMissingTilesetFailDownload").c_str(),getHumanPlayerName().c_str(),itemName.c_str(),curlVersion->version);
|
||||
if(lang.hasString("DataMissingTilesetFailDownload",languageList[i]) == true) {
|
||||
sprintf(szMsg,lang.get("DataMissingTilesetFailDownload",languageList[i]).c_str(),getHumanPlayerName().c_str(),itemName.c_str(),curlVersion->version);
|
||||
}
|
||||
else {
|
||||
sprintf(szMsg,"Player: %s FAILED to download the tileset: [%s] using CURL version [%s]",getHumanPlayerName().c_str(),itemName.c_str(),curlVersion->version);
|
||||
}
|
||||
clientInterface->sendTextMessage(szMsg,-1, true);
|
||||
clientInterface->sendTextMessage(szMsg,-1, lang.isLanguageLocal(languageList[i]),languageList[i]);
|
||||
}
|
||||
|
||||
console.addLine(result.second,true);
|
||||
}
|
||||
}
|
||||
|
@ -2207,14 +2334,19 @@ void MenuStateConnectedGame::FTPClient_CallbackEvent(string itemName,
|
|||
const GameSettings *gameSettings = clientInterface->getGameSettings();
|
||||
|
||||
if(result.first == ftp_crt_SUCCESS) {
|
||||
|
||||
Lang &lang= Lang::getInstance();
|
||||
const vector<string> languageList = clientInterface->getGameSettings()->getUniqueNetworkPlayerLanguages();
|
||||
for(unsigned int i = 0; i < languageList.size(); ++i) {
|
||||
char szMsg[1024]="";
|
||||
if(lang.hasString("DataMissingTechtreeSuccessDownload") == true) {
|
||||
sprintf(szMsg,lang.get("DataMissingTechtreeSuccessDownload").c_str(),getHumanPlayerName().c_str(),itemName.c_str());
|
||||
if(lang.hasString("DataMissingTechtreeSuccessDownload",languageList[i]) == true) {
|
||||
sprintf(szMsg,lang.get("DataMissingTechtreeSuccessDownload",languageList[i]).c_str(),getHumanPlayerName().c_str(),itemName.c_str());
|
||||
}
|
||||
else {
|
||||
sprintf(szMsg,"Player: %s SUCCESSFULLY downloaded the techtree: %s",getHumanPlayerName().c_str(),itemName.c_str());
|
||||
}
|
||||
clientInterface->sendTextMessage(szMsg,-1, true);
|
||||
clientInterface->sendTextMessage(szMsg,-1, lang.isLanguageLocal(languageList[i]),languageList[i]);
|
||||
}
|
||||
|
||||
// START
|
||||
// Clear the CRC Cache if it is populated
|
||||
|
@ -2242,14 +2374,19 @@ void MenuStateConnectedGame::FTPClient_CallbackEvent(string itemName,
|
|||
else {
|
||||
curl_version_info_data *curlVersion= curl_version_info(CURLVERSION_NOW);
|
||||
|
||||
Lang &lang= Lang::getInstance();
|
||||
const vector<string> languageList = clientInterface->getGameSettings()->getUniqueNetworkPlayerLanguages();
|
||||
for(unsigned int i = 0; i < languageList.size(); ++i) {
|
||||
char szMsg[1024]="";
|
||||
if(lang.hasString("DataMissingTechtreeFailDownload") == true) {
|
||||
sprintf(szMsg,lang.get("DataMissingTechtreeFailDownload").c_str(),getHumanPlayerName().c_str(),itemName.c_str(),curlVersion->version);
|
||||
if(lang.hasString("DataMissingTechtreeFailDownload",languageList[i]) == true) {
|
||||
sprintf(szMsg,lang.get("DataMissingTechtreeFailDownload",languageList[i]).c_str(),getHumanPlayerName().c_str(),itemName.c_str(),curlVersion->version);
|
||||
}
|
||||
else {
|
||||
sprintf(szMsg,"Player: %s FAILED to download the techtree: [%s] using CURL version [%s]",getHumanPlayerName().c_str(),itemName.c_str(),curlVersion->version);
|
||||
}
|
||||
clientInterface->sendTextMessage(szMsg,-1, true);
|
||||
clientInterface->sendTextMessage(szMsg,-1, lang.isLanguageLocal(languageList[i]),languageList[i]);
|
||||
}
|
||||
|
||||
console.addLine(result.second,true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1661,7 +1661,7 @@ void MenuStateCustomGame::update() {
|
|||
lastMapDataSynchError != "map CRC mismatch, " + listBoxMap.getSelectedItem()) {
|
||||
lastMapDataSynchError = "map CRC mismatch, " + listBoxMap.getSelectedItem();
|
||||
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
||||
serverInterface->sendTextMessage(lastMapDataSynchError,-1, true);
|
||||
serverInterface->sendTextMessage(lastMapDataSynchError,-1, true,"");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1673,7 +1673,7 @@ void MenuStateCustomGame::update() {
|
|||
lastTileDataSynchError != "tile CRC mismatch, " + listBoxTileset.getSelectedItem()) {
|
||||
lastTileDataSynchError = "tile CRC mismatch, " + listBoxTileset.getSelectedItem();
|
||||
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
||||
serverInterface->sendTextMessage(lastTileDataSynchError,-1,true);
|
||||
serverInterface->sendTextMessage(lastTileDataSynchError,-1,true,"");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1690,11 +1690,11 @@ void MenuStateCustomGame::update() {
|
|||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] report: %s\n",__FILE__,__FUNCTION__,__LINE__,report.c_str());
|
||||
|
||||
serverInterface->sendTextMessage("techtree CRC mismatch",-1,true);
|
||||
serverInterface->sendTextMessage("techtree CRC mismatch",-1,true,"");
|
||||
vector<string> reportLineTokens;
|
||||
Tokenize(report,reportLineTokens,"\n");
|
||||
for(int reportLine = 0; reportLine < reportLineTokens.size(); ++reportLine) {
|
||||
serverInterface->sendTextMessage(reportLineTokens[reportLine],-1,true);
|
||||
serverInterface->sendTextMessage(reportLineTokens[reportLine],-1,true,"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2142,6 +2142,8 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings) {
|
|||
gameSettings->setThisFactionIndex(slotIndex);
|
||||
gameSettings->setNetworkPlayerName(slotIndex, getHumanPlayerName(i));
|
||||
gameSettings->setNetworkPlayerStatuses(slotIndex, getNetworkPlayerStatus());
|
||||
Lang &lang= Lang::getInstance();
|
||||
gameSettings->setNetworkPlayerLanguages(slotIndex, lang.getLanguage());
|
||||
}
|
||||
gameSettings->setResourceMultiplierIndex(slotIndex, listBoxRMultiplier[i].getSelectedItemIndex());
|
||||
|
||||
|
|
|
@ -234,10 +234,10 @@ void MenuStateJoinGame::mouseClick(int x, int y, MouseButton mouseButton) {
|
|||
clientInterface->stopServerDiscovery();
|
||||
|
||||
if(clientInterface->getSocket() != NULL) {
|
||||
if(clientInterface->isConnected() == true) {
|
||||
string sQuitText = Config::getInstance().getString("NetPlayerName",Socket::getHostName().c_str()) + " has chosen to leave the game!";
|
||||
clientInterface->sendTextMessage(sQuitText,-1);
|
||||
}
|
||||
//if(clientInterface->isConnected() == true) {
|
||||
// string sQuitText = Config::getInstance().getString("NetPlayerName",Socket::getHostName().c_str()) + " has chosen to leave the game!";
|
||||
// clientInterface->sendTextMessage(sQuitText,-1);
|
||||
//}
|
||||
clientInterface->close();
|
||||
}
|
||||
abortAutoFind = true;
|
||||
|
|
|
@ -72,8 +72,15 @@ ClientInterface::~ClientInterface() {
|
|||
if(clientSocket != NULL && clientSocket->isConnected() == true) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
Lang &lang= Lang::getInstance();
|
||||
const vector<string> languageList = this->gameSettings.getUniqueNetworkPlayerLanguages();
|
||||
for(unsigned int i = 0; i < languageList.size(); ++i) {
|
||||
string sQuitText = "has chosen to leave the game!";
|
||||
sendTextMessage(sQuitText,-1);
|
||||
if(lang.hasString("PlayerLeftGame",languageList[i]) == true) {
|
||||
sQuitText = lang.get("PlayerLeftGame",languageList[i]);
|
||||
}
|
||||
sendTextMessage(sQuitText,-1,false,languageList[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
@ -105,8 +112,15 @@ void ClientInterface::connect(const Ip &ip, int port) {
|
|||
|
||||
void ClientInterface::reset() {
|
||||
if(getSocket() != NULL) {
|
||||
Lang &lang= Lang::getInstance();
|
||||
const vector<string> languageList = this->gameSettings.getUniqueNetworkPlayerLanguages();
|
||||
for(unsigned int i = 0; i < languageList.size(); ++i) {
|
||||
string sQuitText = "has chosen to leave the game!";
|
||||
sendTextMessage(sQuitText,-1);
|
||||
if(lang.hasString("PlayerLeftGame",languageList[i]) == true) {
|
||||
sQuitText = lang.get("PlayerLeftGame",languageList[i]);
|
||||
}
|
||||
sendTextMessage(sQuitText,-1,false,languageList[i]);
|
||||
}
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
@ -146,7 +160,7 @@ void ClientInterface::update() {
|
|||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] WARNING / ERROR, requestedCommands.size() = %d\n",__FILE__,__FUNCTION__,__LINE__,requestedCommands.size());
|
||||
|
||||
string sMsg = "may go out of synch: client requestedCommands.size() = " + intToStr(requestedCommands.size());
|
||||
sendTextMessage(sMsg,-1, true);
|
||||
sendTextMessage(sMsg,-1, true,"");
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took %lld msecs\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||
}
|
||||
|
@ -194,10 +208,10 @@ void ClientInterface::updateLobby() {
|
|||
"\nClient: " + getNetworkVersionString() + " player [" + playerNameStr + "]";
|
||||
printf("%s\n",sErr.c_str());
|
||||
|
||||
sendTextMessage("Server and client binary mismatch!!",-1, true);
|
||||
sendTextMessage(" Server:" + networkMessageIntro.getVersionString(),-1, true);
|
||||
sendTextMessage(" Client: "+ getNetworkVersionString(),-1, true);
|
||||
sendTextMessage(" Client player [" + playerNameStr + "]",-1, true);
|
||||
sendTextMessage("Server and client binary mismatch!!",-1, true,"");
|
||||
sendTextMessage(" Server:" + networkMessageIntro.getVersionString(),-1, true,"");
|
||||
sendTextMessage(" Client: "+ getNetworkVersionString(),-1, true,"");
|
||||
sendTextMessage(" Client player [" + playerNameStr + "]",-1, true,"");
|
||||
}
|
||||
else {
|
||||
versionMatched = true;
|
||||
|
@ -206,11 +220,6 @@ void ClientInterface::updateLobby() {
|
|||
sErr = "Warning, Server and client are using the same version but different platforms.\n\nServer: " + networkMessageIntro.getVersionString() +
|
||||
"\nClient: " + getNetworkVersionString() + " player [" + playerNameStr + "]";
|
||||
printf("%s\n",sErr.c_str());
|
||||
|
||||
//sendTextMessage("Server and client have different platform mismatch.",-1, true);
|
||||
//sendTextMessage(" Server:" + networkMessageIntro.getVersionString(),-1, true);
|
||||
//sendTextMessage(" Client: "+ getNetworkVersionString(),-1, true);
|
||||
//sendTextMessage(" Client player [" + playerNameStr + "]",-1, true);
|
||||
}
|
||||
|
||||
if(Config::getInstance().getBool("PlatformConsistencyChecks","true") &&
|
||||
|
@ -228,7 +237,8 @@ void ClientInterface::updateLobby() {
|
|||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
//send intro message
|
||||
NetworkMessageIntro sendNetworkMessageIntro(sessionKey,getNetworkVersionString(), getHumanPlayerName(), -1, nmgstOk, this->getSocket()->getConnectedIPAddress(),serverFTPPort);
|
||||
Lang &lang= Lang::getInstance();
|
||||
NetworkMessageIntro sendNetworkMessageIntro(sessionKey,getNetworkVersionString(), getHumanPlayerName(), -1, nmgstOk, this->getSocket()->getConnectedIPAddress(),serverFTPPort,lang.getLanguage());
|
||||
sendMessage(&sendNetworkMessageIntro);
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
@ -425,7 +435,7 @@ void ClientInterface::updateLobby() {
|
|||
{
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] got nmtText\n",__FILE__,__FUNCTION__);
|
||||
|
||||
ChatMsgInfo msg(networkMessageText.getText().c_str(),networkMessageText.getTeamIndex(),networkMessageText.getPlayerIndex());
|
||||
ChatMsgInfo msg(networkMessageText.getText().c_str(),networkMessageText.getTeamIndex(),networkMessageText.getPlayerIndex(),networkMessageText.getTargetLanguage());
|
||||
this->addChatInfo(msg);
|
||||
}
|
||||
}
|
||||
|
@ -490,7 +500,7 @@ void ClientInterface::updateLobby() {
|
|||
{
|
||||
string sErr = string(__FILE__) + "::" + string(__FUNCTION__) + " Unexpected network message: " + intToStr(networkMessageType);
|
||||
//throw runtime_error(string(__FILE__) + "::" + string(__FUNCTION__) + " Unexpected network message: " + intToStr(networkMessageType));
|
||||
sendTextMessage("Unexpected network message: " + intToStr(networkMessageType),-1, true);
|
||||
sendTextMessage("Unexpected network message: " + intToStr(networkMessageType),-1, true,"");
|
||||
DisplayErrorMessage(sErr);
|
||||
quit= true;
|
||||
close();
|
||||
|
@ -554,8 +564,7 @@ void ClientInterface::updateKeyframe(int frameCount) {
|
|||
" got a Network synchronization error, frame counts do not match, server frameCount = " +
|
||||
intToStr(networkMessageCommandList.getFrameCount()) + ", local frameCount = " +
|
||||
intToStr(frameCount);
|
||||
//throw runtime_error("Network synchronization error, frame counts do not match");
|
||||
sendTextMessage(sErr,-1, true);
|
||||
sendTextMessage(sErr,-1, true,"");
|
||||
DisplayErrorMessage(sErr);
|
||||
quit= true;
|
||||
close();
|
||||
|
@ -611,7 +620,7 @@ void ClientInterface::updateKeyframe(int frameCount) {
|
|||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took %lld msecs\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||
|
||||
ChatMsgInfo msg(networkMessageText.getText().c_str(),networkMessageText.getTeamIndex(),networkMessageText.getPlayerIndex());
|
||||
ChatMsgInfo msg(networkMessageText.getText().c_str(),networkMessageText.getTeamIndex(),networkMessageText.getPlayerIndex(),networkMessageText.getTargetLanguage());
|
||||
this->addChatInfo(msg);
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took %lld msecs\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||
|
@ -625,7 +634,7 @@ void ClientInterface::updateKeyframe(int frameCount) {
|
|||
|
||||
default:
|
||||
{
|
||||
sendTextMessage("Unexpected message in client interface: " + intToStr(networkMessageType),-1, true);
|
||||
sendTextMessage("Unexpected message in client interface: " + intToStr(networkMessageType),-1, true,"");
|
||||
DisplayErrorMessage(string(__FILE__) + "::" + string(__FUNCTION__) + " Unexpected message in client interface: " + intToStr(networkMessageType));
|
||||
quit= true;
|
||||
close();
|
||||
|
@ -716,12 +725,21 @@ void ClientInterface::waitUntilReady(Checksum* checksum) {
|
|||
else if(networkMessageType == nmtInvalid) {
|
||||
if(chrono.getMillis() > readyWaitTimeout) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
Lang &lang= Lang::getInstance();
|
||||
const vector<string> languageList = this->gameSettings.getUniqueNetworkPlayerLanguages();
|
||||
for(unsigned int i = 0; i < languageList.size(); ++i) {
|
||||
string sErr = "Timeout waiting for server";
|
||||
sendTextMessage(sErr,-1, true);
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(lang.hasString("TimeoutWaitingForServer",languageList[i]) == true) {
|
||||
sErr = lang.get("TimeoutWaitingForServer",languageList[i]);
|
||||
}
|
||||
bool echoLocal = lang.isLanguageLocal(lang.getLanguage());
|
||||
sendTextMessage(sErr,-1,echoLocal,languageList[i]);
|
||||
|
||||
if(echoLocal) {
|
||||
DisplayErrorMessage(sErr);
|
||||
}
|
||||
}
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
|
@ -822,7 +840,7 @@ void ClientInterface::waitUntilReady(Checksum* checksum) {
|
|||
}
|
||||
else {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
sendTextMessage("Unexpected network message: " + intToStr(networkMessageType),-1, true);
|
||||
sendTextMessage("Unexpected network message: " + intToStr(networkMessageType),-1, true,"");
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
|
@ -849,26 +867,69 @@ void ClientInterface::waitUntilReady(Checksum* checksum) {
|
|||
if(networkMessageReady.getChecksum() != checksum->getSum()) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
Lang &lang= Lang::getInstance();
|
||||
const vector<string> languageList = this->gameSettings.getUniqueNetworkPlayerLanguages();
|
||||
for(unsigned int i = 0; i < languageList.size(); ++i) {
|
||||
string sErr = "Checksum error, you don't have the same data as the server";
|
||||
sendTextMessage(sErr,-1, true);
|
||||
if(lang.hasString("CheckSumGameLoadError",languageList[i]) == true) {
|
||||
sErr = lang.get("CheckSumGameLoadError",languageList[i]);
|
||||
}
|
||||
bool echoLocal = lang.isLanguageLocal(lang.getLanguage());
|
||||
sendTextMessage(sErr,-1,echoLocal,languageList[i]);
|
||||
|
||||
string playerNameStr = "Player with error is [" + getHumanPlayerName() + "]";
|
||||
sendTextMessage(playerNameStr,-1, true);
|
||||
string playerNameStr = "Player with error is: " + getHumanPlayerName();
|
||||
if(lang.hasString("CheckSumGameLoadPlayer",languageList[i]) == true) {
|
||||
playerNameStr = lang.get("CheckSumGameLoadPlayer",languageList[i]) + " " + getHumanPlayerName();
|
||||
}
|
||||
sendTextMessage(playerNameStr,-1,echoLocal,languageList[i]);
|
||||
|
||||
string sErr1 = "Client Checksum: " + intToStr(checksum->getSum());
|
||||
sendTextMessage(sErr1,-1, true);
|
||||
if(lang.hasString("CheckSumGameLoadClient",languageList[i]) == true) {
|
||||
sErr1 = lang.get("CheckSumGameLoadClient",languageList[i]) + " " + intToStr(checksum->getSum());
|
||||
}
|
||||
|
||||
sendTextMessage(sErr1,-1,echoLocal,languageList[i]);
|
||||
|
||||
string sErr2 = "Server Checksum: " + intToStr(networkMessageReady.getChecksum());
|
||||
sendTextMessage(sErr2,-1, true);
|
||||
if(lang.hasString("CheckSumGameLoadServer",languageList[i]) == true) {
|
||||
sErr2 = lang.get("CheckSumGameLoadServer",languageList[i]) + " " + intToStr(networkMessageReady.getChecksum());
|
||||
}
|
||||
sendTextMessage(sErr2,-1,echoLocal,languageList[i]);
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d %s %s %s\n",__FILE__,__FUNCTION__,__LINE__,sErr.c_str(),sErr1.c_str(),sErr2.c_str());
|
||||
|
||||
if(echoLocal == true) {
|
||||
if(Config::getInstance().getBool("NetworkConsistencyChecks")) {
|
||||
// error message and disconnect only if checked
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
string niceError = sErr + string("\n") + sErr1 + string("\n") + sErr2;
|
||||
DisplayErrorMessage(niceError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// string sErr = "Checksum error, you don't have the same data as the server";
|
||||
// CheckSumGameLoadError
|
||||
// sendTextMessage(sErr,-1, true);
|
||||
//
|
||||
// string playerNameStr = "Player with error is [" + getHumanPlayerName() + "]";
|
||||
// sendTextMessage(playerNameStr,-1, true);
|
||||
//
|
||||
// string sErr1 = "Client Checksum: " + intToStr(checksum->getSum());
|
||||
// sendTextMessage(sErr1,-1, true);
|
||||
//
|
||||
// string sErr2 = "Server Checksum: " + intToStr(networkMessageReady.getChecksum());
|
||||
// sendTextMessage(sErr2,-1, true);
|
||||
|
||||
// if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d %s %s %s\n",__FILE__,__FUNCTION__,__LINE__,sErr.c_str(),sErr1.c_str(),sErr2.c_str());
|
||||
|
||||
if(Config::getInstance().getBool("NetworkConsistencyChecks")) {
|
||||
// error message and disconnect only if checked
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
//string niceError = sErr + string("\n") + sErr1 + string("\n") + sErr2;
|
||||
//DisplayErrorMessage(niceError);
|
||||
|
||||
quit= true;
|
||||
|
||||
|
@ -888,19 +949,19 @@ void ClientInterface::waitUntilReady(Checksum* checksum) {
|
|||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) 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 targetLanguage) {
|
||||
|
||||
string humanPlayerName = getHumanPlayerName();
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] humanPlayerName = [%s] playerIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,humanPlayerName.c_str(),playerIndex);
|
||||
|
||||
NetworkMessageText networkMessageText(text, teamIndex,playerIndex);
|
||||
NetworkMessageText networkMessageText(text, teamIndex,playerIndex,targetLanguage);
|
||||
sendMessage(&networkMessageText);
|
||||
|
||||
if(echoLocal == true) {
|
||||
ChatMsgInfo msg(networkMessageText.getText().c_str(),networkMessageText.getTeamIndex(),networkMessageText.getPlayerIndex());
|
||||
ChatMsgInfo msg(networkMessageText.getText().c_str(),networkMessageText.getTeamIndex(),networkMessageText.getPlayerIndex(),targetLanguage);
|
||||
this->addChatInfo(msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ClientInterface::sendPingMessage(int32 pingFrequency, int64 pingTime) {
|
||||
|
@ -954,8 +1015,19 @@ NetworkMessageType ClientInterface::waitForMessage()
|
|||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
sendTextMessage("Timeout waiting for message",-1, true);
|
||||
DisplayErrorMessage("Timeout waiting for message");
|
||||
Lang &lang= Lang::getInstance();
|
||||
const vector<string> languageList = this->gameSettings.getUniqueNetworkPlayerLanguages();
|
||||
for(unsigned int i = 0; i < languageList.size(); ++i) {
|
||||
string msg = "Timeout waiting for message.";
|
||||
if(lang.hasString("TimeoutWaitingForMessage",languageList[i]) == true) {
|
||||
msg = lang.get("TimeoutWaitingForMessage",languageList[i]);
|
||||
}
|
||||
|
||||
sendTextMessage(msg,-1, lang.isLanguageLocal(languageList[i]),languageList[i]);
|
||||
if(lang.isLanguageLocal(languageList[i]) == true) {
|
||||
DisplayErrorMessage(msg);
|
||||
}
|
||||
}
|
||||
quit= true;
|
||||
close();
|
||||
return msg;
|
||||
|
@ -982,8 +1054,18 @@ void ClientInterface::quitGame(bool userManuallyQuit)
|
|||
if(clientSocket != NULL && userManuallyQuit == true)
|
||||
{
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
string sQuitText = "has chosen to leave the game!";
|
||||
sendTextMessage(sQuitText,-1);
|
||||
|
||||
Lang &lang= Lang::getInstance();
|
||||
const vector<string> languageList = this->gameSettings.getUniqueNetworkPlayerLanguages();
|
||||
for(unsigned int i = 0; i < languageList.size(); ++i) {
|
||||
string msg = "has chosen to leave the game!";
|
||||
if(lang.hasString("PlayerLeftGame",languageList[i]) == true) {
|
||||
msg = lang.get("PlayerLeftGame",languageList[i]);
|
||||
}
|
||||
|
||||
sendTextMessage(msg,-1, lang.isLanguageLocal(languageList[i]),languageList[i]);
|
||||
}
|
||||
sleep(1);
|
||||
close();
|
||||
}
|
||||
|
||||
|
@ -1020,11 +1102,12 @@ void ClientInterface::stopServerDiscovery() {
|
|||
|
||||
void ClientInterface::sendSwitchSetupRequest(string selectedFactionName, int8 currentFactionIndex,
|
||||
int8 toFactionIndex,int8 toTeam, string networkPlayerName,
|
||||
int8 networkPlayerStatus, int8 flags) {
|
||||
int8 networkPlayerStatus, int8 flags,
|
||||
string language) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] networkPlayerName [%s] flags = %d\n",__FILE__,__FUNCTION__,__LINE__,networkPlayerName.c_str(),flags);
|
||||
SwitchSetupRequest message=SwitchSetupRequest(selectedFactionName,
|
||||
currentFactionIndex, toFactionIndex,toTeam,networkPlayerName,
|
||||
networkPlayerStatus, flags);
|
||||
networkPlayerStatus, flags,language);
|
||||
sendMessage(&message);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
@ -1062,7 +1145,7 @@ bool ClientInterface::shouldDiscardNetworkMessage(NetworkMessageType networkMess
|
|||
NetworkMessageText netMsg = NetworkMessageText();
|
||||
this->receiveMessage(&netMsg);
|
||||
|
||||
ChatMsgInfo msg(netMsg.getText().c_str(),netMsg.getTeamIndex(),netMsg.getPlayerIndex());
|
||||
ChatMsgInfo msg(netMsg.getText().c_str(),netMsg.getTeamIndex(),netMsg.getPlayerIndex(),netMsg.getTargetLanguage());
|
||||
this->addChatInfo(msg);
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -71,7 +71,8 @@ public:
|
|||
virtual void waitUntilReady(Checksum* checksum);
|
||||
|
||||
// message sending
|
||||
virtual void sendTextMessage(const string &text, int teamIndex, bool echoLocal=false);
|
||||
virtual void sendTextMessage(const string &text, int teamIndex, bool echoLocal,
|
||||
string targetLanguage);
|
||||
virtual void quitGame(bool userManuallyQuit);
|
||||
|
||||
//misc
|
||||
|
@ -94,7 +95,8 @@ public:
|
|||
|
||||
void sendSwitchSetupRequest(string selectedFactionName, int8 currentFactionIndex,
|
||||
int8 toFactionIndex, int8 toTeam,string networkPlayerName,
|
||||
int8 networkPlayerStatus, int8 flags);
|
||||
int8 networkPlayerStatus, int8 flags,
|
||||
string language);
|
||||
virtual bool getConnectHasHandshaked() const { return gotIntro; }
|
||||
std::string getServerIpAddress();
|
||||
|
||||
|
|
|
@ -228,6 +228,7 @@ ConnectionSlot::ConnectionSlot(ServerInterface* serverInterface, int playerIndex
|
|||
this->serverInterface = serverInterface;
|
||||
this->playerIndex = playerIndex;
|
||||
this->playerStatus = 0;
|
||||
this->playerLanguage = "";
|
||||
this->currentFrameCount = 0;
|
||||
this->currentLagCount = 0;
|
||||
this->gotLagCountWarning = false;
|
||||
|
@ -318,6 +319,7 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
|
|||
this->clearChatInfo();
|
||||
this->name = "";
|
||||
this->playerStatus = npst_PickSettings;
|
||||
this->playerLanguage = "";
|
||||
this->ready = false;
|
||||
this->vctFileList.clear();
|
||||
this->receivedNetworkGameStatus = false;
|
||||
|
@ -366,7 +368,7 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
|
|||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] !!!!!!!!WARNING - no open slots, disconnecting client\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
if(socket != NULL) {
|
||||
NetworkMessageIntro networkMessageIntro(sessionKey,getNetworkVersionString(), getHostName(), playerIndex, nmgstNoSlots, 0, ServerSocket::getFTPServerPort());
|
||||
NetworkMessageIntro networkMessageIntro(sessionKey,getNetworkVersionString(), getHostName(), playerIndex, nmgstNoSlots, 0, ServerSocket::getFTPServerPort(),"");
|
||||
sendMessage(&networkMessageIntro);
|
||||
}
|
||||
|
||||
|
@ -378,7 +380,7 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
|
|||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] client will be assigned to the next open slot\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
if(socket != NULL) {
|
||||
NetworkMessageIntro networkMessageIntro(sessionKey,getNetworkVersionString(), getHostName(), playerIndex, nmgstOk, 0, ServerSocket::getFTPServerPort());
|
||||
NetworkMessageIntro networkMessageIntro(sessionKey,getNetworkVersionString(), getHostName(), playerIndex, nmgstOk, 0, ServerSocket::getFTPServerPort(),"");
|
||||
sendMessage(&networkMessageIntro);
|
||||
|
||||
//if(chrono.getMillis() > 1) printf("In [%s::%s Line: %d] action running for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis());
|
||||
|
@ -438,7 +440,7 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
|
|||
if(gotIntro == true) {
|
||||
NetworkMessageText networkMessageText;
|
||||
if(receiveMessage(&networkMessageText)) {
|
||||
ChatMsgInfo msg(networkMessageText.getText().c_str(),networkMessageText.getTeamIndex(),networkMessageText.getPlayerIndex());
|
||||
ChatMsgInfo msg(networkMessageText.getText().c_str(),networkMessageText.getTeamIndex(),networkMessageText.getPlayerIndex(),networkMessageText.getTargetLanguage());
|
||||
this->addChatInfo(msg);
|
||||
gotTextMsg = true;
|
||||
}
|
||||
|
@ -479,9 +481,10 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
|
|||
NetworkMessageIntro networkMessageIntro;
|
||||
if(receiveMessage(&networkMessageIntro)) {
|
||||
int msgSessionId = networkMessageIntro.getSessionId();
|
||||
name= networkMessageIntro.getName();
|
||||
versionString = networkMessageIntro.getVersionString();
|
||||
this->name= networkMessageIntro.getName();
|
||||
this->versionString = networkMessageIntro.getVersionString();
|
||||
this->connectedRemoteIPAddress = networkMessageIntro.getExternalIp();
|
||||
this->playerLanguage = networkMessageIntro.getPlayerLanguage();
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] got name [%s] versionString [%s], msgSessionId = %d\n",__FILE__,__FUNCTION__,name.c_str(),versionString.c_str(),msgSessionId);
|
||||
|
||||
|
@ -510,10 +513,10 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
|
|||
"\nClient: " + networkMessageIntro.getVersionString() + " player [" + playerNameStr + "]";
|
||||
printf("%s\n",sErr.c_str());
|
||||
|
||||
serverInterface->sendTextMessage("Server and client binary mismatch!!",-1, true,lockedSlotIndex);
|
||||
serverInterface->sendTextMessage(" Server:" + getNetworkVersionString(),-1, true,lockedSlotIndex);
|
||||
serverInterface->sendTextMessage(" Client: "+ networkMessageIntro.getVersionString(),-1, true,lockedSlotIndex);
|
||||
serverInterface->sendTextMessage(" Client player [" + playerNameStr + "]",-1, true,lockedSlotIndex);
|
||||
serverInterface->sendTextMessage("Server and client binary mismatch!!",-1, true,"",lockedSlotIndex);
|
||||
serverInterface->sendTextMessage(" Server:" + getNetworkVersionString(),-1, true,"",lockedSlotIndex);
|
||||
serverInterface->sendTextMessage(" Client: "+ networkMessageIntro.getVersionString(),-1, true,"",lockedSlotIndex);
|
||||
serverInterface->sendTextMessage(" Client player [" + playerNameStr + "]",-1, true,"",lockedSlotIndex);
|
||||
}
|
||||
else {
|
||||
versionMatched = true;
|
||||
|
@ -718,6 +721,7 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
|
|||
|
||||
this->playerStatus = switchSetupRequest.getNetworkPlayerStatus();
|
||||
this->name = switchSetupRequest.getNetworkPlayerName();
|
||||
this->playerLanguage = switchSetupRequest.getNetworkPlayerLanguage();
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d] networkPlayerName [%s]\n",__FILE__,__FUNCTION__,__LINE__,serverInterface->getSwitchSetupRequests()[factionIdx]->getNetworkPlayerName().c_str());
|
||||
|
||||
|
|
|
@ -123,6 +123,7 @@ private:
|
|||
int sessionKey;
|
||||
uint32 connectedRemoteIPAddress;
|
||||
int playerStatus;
|
||||
string playerLanguage;
|
||||
|
||||
public:
|
||||
ConnectionSlot(ServerInterface* serverInterface, int playerIndex);
|
||||
|
@ -178,6 +179,8 @@ public:
|
|||
|
||||
int getNetworkPlayerStatus() const { return playerStatus;}
|
||||
|
||||
string getNetworkPlayerLanguage() const { return playerLanguage; }
|
||||
|
||||
protected:
|
||||
|
||||
Mutex * getServerSynchAccessor();
|
||||
|
|
|
@ -48,6 +48,7 @@ protected:
|
|||
this->chatText = obj.chatText.c_str();
|
||||
this->chatTeamIndex = obj.chatTeamIndex;
|
||||
this->chatPlayerIndex = obj.chatPlayerIndex;
|
||||
this->targetLanguage = obj.targetLanguage;
|
||||
}
|
||||
public:
|
||||
|
||||
|
@ -55,11 +56,14 @@ public:
|
|||
this->chatText = "";
|
||||
this->chatTeamIndex = -1;
|
||||
this->chatPlayerIndex = -1;
|
||||
this->targetLanguage = "";
|
||||
}
|
||||
ChatMsgInfo(string chatText, int chatTeamIndex, int chatPlayerIndex) {
|
||||
ChatMsgInfo(string chatText, int chatTeamIndex, int chatPlayerIndex,
|
||||
string targetLanguage) {
|
||||
this->chatText = chatText;
|
||||
this->chatTeamIndex = chatTeamIndex;
|
||||
this->chatPlayerIndex = chatPlayerIndex;
|
||||
this->targetLanguage = targetLanguage;
|
||||
}
|
||||
ChatMsgInfo(const ChatMsgInfo& obj) {
|
||||
copyAll(obj);
|
||||
|
@ -72,6 +76,7 @@ public:
|
|||
string chatText;
|
||||
int chatTeamIndex;
|
||||
int chatPlayerIndex;
|
||||
string targetLanguage;
|
||||
|
||||
};
|
||||
|
||||
|
@ -184,7 +189,8 @@ public:
|
|||
virtual void waitUntilReady(Checksum* checksum)= 0;
|
||||
|
||||
//message sending
|
||||
virtual void sendTextMessage(const string &text, int teamIndex,bool echoLocal=false)= 0;
|
||||
virtual void sendTextMessage(const string &text, int teamIndex,bool echoLocal,
|
||||
string targetLanguage)= 0;
|
||||
virtual void quitGame(bool userManuallyQuit)=0;
|
||||
|
||||
//misc
|
||||
|
|
|
@ -119,7 +119,8 @@ NetworkMessageIntro::NetworkMessageIntro(int32 sessionId,const string &versionSt
|
|||
const string &name, int playerIndex,
|
||||
NetworkGameStateType gameState,
|
||||
uint32 externalIp,
|
||||
uint32 ftpPort) {
|
||||
uint32 ftpPort,
|
||||
const string &playerLanguage) {
|
||||
data.messageType = nmtIntro;
|
||||
data.sessionId = sessionId;
|
||||
data.versionString = versionString;
|
||||
|
@ -128,12 +129,15 @@ NetworkMessageIntro::NetworkMessageIntro(int32 sessionId,const string &versionSt
|
|||
data.gameState = static_cast<int8>(gameState);
|
||||
data.externalIp = externalIp;
|
||||
data.ftpPort = ftpPort;
|
||||
data.language = playerLanguage;
|
||||
}
|
||||
|
||||
bool NetworkMessageIntro::receive(Socket* socket) {
|
||||
bool result = NetworkMessage::receive(socket, &data, sizeof(data));
|
||||
data.name.nullTerminate();
|
||||
data.versionString.nullTerminate();
|
||||
data.language.nullTerminate();
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] get nmtIntro, data.playerIndex = %d, data.sessionId = %d\n",__FILE__,__FUNCTION__,__LINE__,data.playerIndex,data.sessionId);
|
||||
return result;
|
||||
}
|
||||
|
@ -246,6 +250,7 @@ NetworkMessageLaunch::NetworkMessageLaunch(const GameSettings *gameSettings,int8
|
|||
data.factionTypeNames[i]= gameSettings->getFactionTypeName(i);
|
||||
data.networkPlayerNames[i]= gameSettings->getNetworkPlayerName(i);
|
||||
data.networkPlayerStatuses[i] = gameSettings->getNetworkPlayerStatuses(i);
|
||||
data.networkPlayerLanguages[i] = gameSettings->getNetworkPlayerLanguages(i);
|
||||
data.factionControls[i]= gameSettings->getFactionControl(i);
|
||||
data.resourceMultiplierIndex[i]= gameSettings->getResourceMultiplierIndex(i);
|
||||
data.teams[i]= gameSettings->getTeam(i);
|
||||
|
@ -289,6 +294,7 @@ void NetworkMessageLaunch::buildGameSettings(GameSettings *gameSettings) const {
|
|||
gameSettings->setFactionTypeName(i, data.factionTypeNames[i].getString());
|
||||
gameSettings->setNetworkPlayerName(i,data.networkPlayerNames[i].getString());
|
||||
gameSettings->setNetworkPlayerStatuses(i, data.networkPlayerStatuses[i]);
|
||||
gameSettings->setNetworkPlayerLanguages(i, data.networkPlayerLanguages[i].getString());
|
||||
gameSettings->setFactionControl(i, static_cast<ControlType>(data.factionControls[i]));
|
||||
gameSettings->setResourceMultiplierIndex(i,data.resourceMultiplierIndex[i]);
|
||||
gameSettings->setTeam(i, data.teams[i]);
|
||||
|
@ -316,6 +322,7 @@ bool NetworkMessageLaunch::receive(Socket* socket) {
|
|||
for(int i= 0; i < GameConstants::maxPlayers; ++i){
|
||||
data.factionTypeNames[i].nullTerminate();
|
||||
data.networkPlayerNames[i].nullTerminate();
|
||||
data.networkPlayerLanguages[i].nullTerminate();
|
||||
}
|
||||
for(unsigned int i = 0; i < maxFactionCRCCount; ++i) {
|
||||
data.factionNameList[i].nullTerminate();
|
||||
|
@ -439,17 +446,17 @@ 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, int teamIndex, int playerIndex) {
|
||||
NetworkMessageText::NetworkMessageText(const string &text, int teamIndex, int playerIndex,
|
||||
const string targetLanguage) {
|
||||
if(text.length() >= maxTextStringSize) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) 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);
|
||||
}
|
||||
|
||||
data.messageType = nmtText;
|
||||
data.text = text;
|
||||
//data.sender = sender;
|
||||
data.teamIndex = teamIndex;
|
||||
data.playerIndex = playerIndex;
|
||||
data.targetLanguage = targetLanguage;
|
||||
}
|
||||
|
||||
NetworkMessageText * NetworkMessageText::getCopy() const {
|
||||
|
@ -462,7 +469,7 @@ bool NetworkMessageText::receive(Socket* socket){
|
|||
bool result = NetworkMessage::receive(socket, &data, sizeof(data));
|
||||
|
||||
data.text.nullTerminate();
|
||||
//data.sender.nullTerminate();
|
||||
data.targetLanguage.nullTerminate();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -964,11 +971,13 @@ SwitchSetupRequest::SwitchSetupRequest() {
|
|||
data.networkPlayerName="";
|
||||
data.networkPlayerStatus = npst_None;
|
||||
data.switchFlags = ssrft_None;
|
||||
data.language = "";
|
||||
}
|
||||
|
||||
SwitchSetupRequest::SwitchSetupRequest(string selectedFactionName, int8 currentFactionIndex,
|
||||
int8 toFactionIndex,int8 toTeam,string networkPlayerName,
|
||||
int8 networkPlayerStatus, int8 flags) {
|
||||
int8 networkPlayerStatus, int8 flags,
|
||||
string language) {
|
||||
data.messageType= nmtSwitchSetupRequest;
|
||||
data.selectedFactionName=selectedFactionName;
|
||||
data.currentFactionIndex=currentFactionIndex;
|
||||
|
@ -977,6 +986,7 @@ SwitchSetupRequest::SwitchSetupRequest(string selectedFactionName, int8 currentF
|
|||
data.networkPlayerName=networkPlayerName;
|
||||
data.networkPlayerStatus=networkPlayerStatus;
|
||||
data.switchFlags = flags;
|
||||
data.language = language;
|
||||
}
|
||||
|
||||
bool SwitchSetupRequest::receive(Socket* socket) {
|
||||
|
@ -984,6 +994,7 @@ bool SwitchSetupRequest::receive(Socket* socket) {
|
|||
|
||||
data.selectedFactionName.nullTerminate();
|
||||
data.networkPlayerName.nullTerminate();
|
||||
data.language.nullTerminate();
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d] data.networkPlayerName [%s]\n",__FILE__,__FUNCTION__,__LINE__,data.networkPlayerName.getString().c_str());
|
||||
|
||||
|
|
|
@ -55,6 +55,8 @@ enum NetworkGameStateType {
|
|||
nmgstCount
|
||||
};
|
||||
|
||||
static const int maxLanguageStringSize= 60;
|
||||
|
||||
// =====================================================
|
||||
// class NetworkMessage
|
||||
// =====================================================
|
||||
|
@ -94,6 +96,7 @@ private:
|
|||
int8 gameState;
|
||||
uint32 externalIp;
|
||||
uint32 ftpPort;
|
||||
NetworkString<maxLanguageStringSize> language;
|
||||
};
|
||||
|
||||
private:
|
||||
|
@ -101,7 +104,9 @@ private:
|
|||
|
||||
public:
|
||||
NetworkMessageIntro();
|
||||
NetworkMessageIntro(int32 sessionId, const string &versionString, const string &name, int playerIndex, NetworkGameStateType gameState, uint32 externalIp, uint32 ftpPort);
|
||||
NetworkMessageIntro(int32 sessionId, const string &versionString,
|
||||
const string &name, int playerIndex, NetworkGameStateType gameState,
|
||||
uint32 externalIp, uint32 ftpPort, const string &playerLanguage);
|
||||
|
||||
int32 getSessionId() const { return data.sessionId;}
|
||||
string getVersionString() const { return data.versionString.getString(); }
|
||||
|
@ -110,6 +115,7 @@ public:
|
|||
NetworkGameStateType getGameState() const { return static_cast<NetworkGameStateType>(data.gameState); }
|
||||
uint32 getExternalIp() const { return data.externalIp;}
|
||||
uint32 getFtpPort() const { return data.ftpPort; }
|
||||
string getPlayerLanguage() const { return data.language.getString(); }
|
||||
|
||||
virtual bool receive(Socket* socket);
|
||||
virtual void send(Socket* socket) const;
|
||||
|
@ -200,6 +206,8 @@ private:
|
|||
NetworkString<maxSmallStringSize> factionTypeNames[GameConstants::maxPlayers]; //faction names
|
||||
NetworkString<maxSmallStringSize> networkPlayerNames[GameConstants::maxPlayers]; //networkPlayerNames
|
||||
int32 networkPlayerStatuses[GameConstants::maxPlayers]; //networkPlayerStatuses
|
||||
NetworkString<maxSmallStringSize> networkPlayerLanguages[GameConstants::maxPlayers];
|
||||
|
||||
int32 mapCRC;
|
||||
int32 tilesetCRC;
|
||||
int32 techCRC;
|
||||
|
@ -300,16 +308,15 @@ public:
|
|||
#pragma pack(push, 1)
|
||||
class NetworkMessageText: public NetworkMessage {
|
||||
private:
|
||||
static const int maxTextStringSize= 340;
|
||||
//static const int maxSenderStringSize= 60;
|
||||
static const int maxTextStringSize= 500;
|
||||
|
||||
private:
|
||||
struct Data{
|
||||
int8 messageType;
|
||||
NetworkString<maxTextStringSize> text;
|
||||
//NetworkString<maxSenderStringSize> sender;
|
||||
int8 teamIndex;
|
||||
int8 playerIndex;
|
||||
NetworkString<maxLanguageStringSize> targetLanguage;
|
||||
};
|
||||
|
||||
private:
|
||||
|
@ -317,13 +324,13 @@ private:
|
|||
|
||||
public:
|
||||
NetworkMessageText(){}
|
||||
//NetworkMessageText(const string &text, const string &sender, int teamIndex, int playerIndex);
|
||||
NetworkMessageText(const string &text, int teamIndex, int playerIndex);
|
||||
NetworkMessageText(const string &text, int teamIndex, int playerIndex,
|
||||
const string targetLanguage);
|
||||
|
||||
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;}
|
||||
string getTargetLanguage() const {return data.targetLanguage.getString();}
|
||||
|
||||
virtual bool receive(Socket* socket);
|
||||
virtual void send(Socket* socket) const;
|
||||
|
@ -334,7 +341,7 @@ public:
|
|||
// =====================================================
|
||||
// class NetworkMessageQuit
|
||||
//
|
||||
// Message sent at the beggining of the game
|
||||
// Message sent at the beginning of the game
|
||||
// =====================================================
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
@ -358,7 +365,7 @@ public:
|
|||
// =====================================================
|
||||
// class NetworkMessageSynchNetworkGameData
|
||||
//
|
||||
// Message sent at the beggining of a network game
|
||||
// Message sent at the beginning of a network game
|
||||
// =====================================================
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
@ -494,7 +501,7 @@ public:
|
|||
// =====================================================
|
||||
// class NetworkMessageSynchNetworkGameDataFileCRCCheck
|
||||
//
|
||||
// Message sent at the beggining of a network game
|
||||
// Message sent at the beginning of a network game
|
||||
// =====================================================
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
@ -534,7 +541,7 @@ public:
|
|||
// =====================================================
|
||||
// class NetworkMessageSynchNetworkGameDataFileGet
|
||||
//
|
||||
// Message sent at the beggining of a network game
|
||||
// Message sent at the beginning of a network game
|
||||
// =====================================================
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
@ -606,6 +613,7 @@ private:
|
|||
NetworkString<maxPlayernameStringSize> networkPlayerName;
|
||||
int8 networkPlayerStatus;
|
||||
int8 switchFlags;
|
||||
NetworkString<maxLanguageStringSize> language;
|
||||
};
|
||||
|
||||
private:
|
||||
|
@ -615,7 +623,8 @@ public:
|
|||
SwitchSetupRequest();
|
||||
SwitchSetupRequest( string selectedFactionName, int8 currentFactionIndex,
|
||||
int8 toFactionIndex,int8 toTeam,string networkPlayerName,
|
||||
int8 networkPlayerStatus, int8 flags);
|
||||
int8 networkPlayerStatus, int8 flags,
|
||||
string language);
|
||||
|
||||
string getSelectedFactionName() const {return data.selectedFactionName.getString();}
|
||||
int getCurrentFactionIndex() const {return data.currentFactionIndex;}
|
||||
|
@ -627,6 +636,7 @@ public:
|
|||
void clearSwitchFlag(SwitchSetupRequestFlagType flag) { data.switchFlags &= ~flag;}
|
||||
|
||||
int getNetworkPlayerStatus() { return data.networkPlayerStatus; }
|
||||
string getNetworkPlayerLanguage() const { return data.language.getString(); }
|
||||
|
||||
virtual bool receive(Socket* socket);
|
||||
virtual void send(Socket* socket) const;
|
||||
|
|
|
@ -245,6 +245,7 @@ bool ServerInterface::switchSlot(int fromPlayerIndex, int toPlayerIndex) {
|
|||
}
|
||||
|
||||
void ServerInterface::removeSlot(int playerIndex, int lockedSlotIndex) {
|
||||
Lang &lang= Lang::getInstance();
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] playerIndex = %d, lockedSlotIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,playerIndex,lockedSlotIndex);
|
||||
MutexSafeWrapper safeMutex(&serverSynchAccessor,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
MutexSafeWrapper safeMutexSlot(NULL,string(__FILE__) + "_" + intToStr(__LINE__) + "_" + intToStr(playerIndex));
|
||||
|
@ -254,19 +255,29 @@ void ServerInterface::removeSlot(int playerIndex, int lockedSlotIndex) {
|
|||
}
|
||||
ConnectionSlot *slot = slots[playerIndex];
|
||||
bool notifyDisconnect = false;
|
||||
char szBuf[4096] = "";
|
||||
vector<string> msgList;
|
||||
const vector<string> languageList = this->gameSettings.getUniqueNetworkPlayerLanguages();
|
||||
if(slot != NULL) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] playerIndex = %d, lockedSlotIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,playerIndex,lockedSlotIndex);
|
||||
|
||||
if(slot->getLastReceiveCommandListTime() > 0) {
|
||||
const char* msgTemplate = "Player %s, disconnected from the game.";
|
||||
char szBuf[4096] = "";
|
||||
|
||||
for(unsigned int i = 0; i < languageList.size(); ++i) {
|
||||
string msgTemplate = "Player %s, disconnected from the game.";
|
||||
if(lang.hasString("PlayerDisconnected",languageList[i]) == true) {
|
||||
msgTemplate = lang.get("PlayerDisconnected",languageList[i]);
|
||||
}
|
||||
#ifdef WIN32
|
||||
_snprintf(szBuf,4095,msgTemplate,slot->getName().c_str());
|
||||
_snprintf(szBuf,4095,msgTemplate.c_str(),slot->getName().c_str());
|
||||
#else
|
||||
snprintf(szBuf,4095,msgTemplate,slot->getName().c_str());
|
||||
snprintf(szBuf,4095,msgTemplate.c_str(),slot->getName().c_str());
|
||||
#endif
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] %s\n",__FILE__,__FUNCTION__,__LINE__,szBuf);
|
||||
|
||||
msgList.push_back(szBuf);
|
||||
}
|
||||
|
||||
notifyDisconnect = true;
|
||||
}
|
||||
}
|
||||
|
@ -282,9 +293,13 @@ void ServerInterface::removeSlot(int playerIndex, int lockedSlotIndex) {
|
|||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] playerIndex = %d, lockedSlotIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,playerIndex,lockedSlotIndex);
|
||||
if(notifyDisconnect == true) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] playerIndex = %d, lockedSlotIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,playerIndex,lockedSlotIndex);
|
||||
string sMsg = szBuf;
|
||||
//string sMsg = szBuf;
|
||||
//sendTextMessage(sMsg,-1, true, lockedSlotIndex);
|
||||
queueTextMessage(sMsg,-1, true);
|
||||
//const vector<string> languageList = this->gameSettings.getUniqueNetworkPlayerLanguages();
|
||||
for(unsigned int j = 0; j < languageList.size(); ++j) {
|
||||
bool localEcho = lang.isLanguageLocal(languageList[j]);
|
||||
queueTextMessage(msgList[j],-1, localEcho, languageList[j]);
|
||||
}
|
||||
}
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] playerIndex = %d, lockedSlotIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,playerIndex,lockedSlotIndex);
|
||||
}
|
||||
|
@ -443,17 +458,27 @@ std::pair<bool,bool> ServerInterface::clientLagCheck(ConnectionSlot *connectionS
|
|||
(maxClientLagTimeAllowed > 0 && clientLagTime > maxClientLagTimeAllowed) ||
|
||||
(maxFrameCountLagAllowedEver > 0 && clientLagCount > maxFrameCountLagAllowedEver)) {
|
||||
clientLagExceededOrWarned.first = true;
|
||||
|
||||
Lang &lang= Lang::getInstance();
|
||||
const vector<string> languageList = this->gameSettings.getUniqueNetworkPlayerLanguages();
|
||||
for(unsigned int i = 0; i < languageList.size(); ++i) {
|
||||
char szBuf[4096]="";
|
||||
|
||||
const char* msgTemplate = "DROPPING %s, exceeded max allowed LAG count of %f [time = %f], clientLag = %f [%f], disconnecting client.";
|
||||
string msgTemplate = "DROPPING %s, exceeded max allowed LAG count of %f [time = %f], clientLag = %f [%f], disconnecting client.";
|
||||
if(lang.hasString("ClientLagDropping") == true) {
|
||||
msgTemplate = lang.get("ClientLagDropping",languageList[i]);
|
||||
}
|
||||
if(gameSettings.getNetworkPauseGameForLaggedClients() == true &&
|
||||
(maxFrameCountLagAllowedEver <= 0 || clientLagCount <= maxFrameCountLagAllowedEver)) {
|
||||
msgTemplate = "PAUSING GAME TEMPORARILY for %s, exceeded max allowed LAG count of %f [time = %f], clientLag = %f [%f], waiting for client to catch up...";
|
||||
if(lang.hasString("ClientLagPausing") == true) {
|
||||
msgTemplate = lang.get("ClientLagPausing",languageList[i]);
|
||||
}
|
||||
}
|
||||
#ifdef WIN32
|
||||
_snprintf(szBuf,4095,msgTemplate,connectionSlot->getName().c_str() ,maxFrameCountLagAllowed,maxClientLagTimeAllowed,clientLagCount,clientLagTime);
|
||||
_snprintf(szBuf,4095,msgTemplate.c_str(),connectionSlot->getName().c_str() ,maxFrameCountLagAllowed,maxClientLagTimeAllowed,clientLagCount,clientLagTime);
|
||||
#else
|
||||
snprintf(szBuf,4095,msgTemplate,connectionSlot->getName().c_str(),maxFrameCountLagAllowed,maxClientLagTimeAllowed,clientLagCount,clientLagTime);
|
||||
snprintf(szBuf,4095,msgTemplate.c_str(),connectionSlot->getName().c_str(),maxFrameCountLagAllowed,maxClientLagTimeAllowed,clientLagCount,clientLagTime);
|
||||
#endif
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] %s\n",__FILE__,__FUNCTION__,__LINE__,szBuf);
|
||||
|
||||
|
@ -461,7 +486,9 @@ std::pair<bool,bool> ServerInterface::clientLagCheck(ConnectionSlot *connectionS
|
|||
|
||||
if(skipNetworkBroadCast == false) {
|
||||
string sMsg = szBuf;
|
||||
sendTextMessage(sMsg,-1, true, connectionSlot->getPlayerIndex());
|
||||
bool echoLocal = lang.isLanguageLocal(languageList[i]);
|
||||
sendTextMessage(sMsg,-1, echoLocal, languageList[i], connectionSlot->getPlayerIndex());
|
||||
}
|
||||
}
|
||||
|
||||
if(gameSettings.getNetworkPauseGameForLaggedClients() == false ||
|
||||
|
@ -481,13 +508,20 @@ std::pair<bool,bool> ServerInterface::clientLagCheck(ConnectionSlot *connectionS
|
|||
if(connectionSlot->getLagCountWarning() == false) {
|
||||
connectionSlot->setLagCountWarning(true);
|
||||
|
||||
Lang &lang= Lang::getInstance();
|
||||
const vector<string> languageList = this->gameSettings.getUniqueNetworkPlayerLanguages();
|
||||
for(unsigned int i = 0; i < languageList.size(); ++i) {
|
||||
char szBuf[4096]="";
|
||||
|
||||
const char* msgTemplate = "LAG WARNING for %s, may exceed max allowed LAG count of %f [time = %f], clientLag = %f [%f], WARNING...";
|
||||
string msgTemplate = "LAG WARNING for %s, may exceed max allowed LAG count of %f [time = %f], clientLag = %f [%f], WARNING...";
|
||||
if(lang.hasString("ClientLagWarning") == true) {
|
||||
msgTemplate = lang.get("ClientLagWarning",languageList[i]);
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
_snprintf(szBuf,4095,msgTemplate,connectionSlot->getName().c_str(),maxFrameCountLagAllowed,maxClientLagTimeAllowed,clientLagCount,clientLagTime);
|
||||
_snprintf(szBuf,4095,msgTemplate.c_str(),connectionSlot->getName().c_str(),maxFrameCountLagAllowed,maxClientLagTimeAllowed,clientLagCount,clientLagTime);
|
||||
#else
|
||||
snprintf(szBuf,4095,msgTemplate,connectionSlot->getName().c_str(),maxFrameCountLagAllowed,maxClientLagTimeAllowed,clientLagCount,clientLagTime);
|
||||
snprintf(szBuf,4095,msgTemplate.c_str(),connectionSlot->getName().c_str(),maxFrameCountLagAllowed,maxClientLagTimeAllowed,clientLagCount,clientLagTime);
|
||||
#endif
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] %s\n",__FILE__,__FUNCTION__,__LINE__,szBuf);
|
||||
|
||||
|
@ -495,7 +529,9 @@ std::pair<bool,bool> ServerInterface::clientLagCheck(ConnectionSlot *connectionS
|
|||
|
||||
if(skipNetworkBroadCast == false) {
|
||||
string sMsg = szBuf;
|
||||
sendTextMessage(sMsg,-1, true, connectionSlot->getPlayerIndex());
|
||||
bool echoLocal = lang.isLanguageLocal(languageList[i]);
|
||||
sendTextMessage(sMsg,-1, echoLocal, languageList[i], connectionSlot->getPlayerIndex());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -751,11 +787,14 @@ void ServerInterface::dispatchPendingChatMessages(std::vector <string> &errorMsg
|
|||
string newChatText = msg.chatText.c_str();
|
||||
int newChatTeamIndex = msg.chatTeamIndex;
|
||||
int newChatPlayerIndex = msg.chatPlayerIndex;
|
||||
string newChatLanguage = msg.targetLanguage;
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) 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(),newChatTeamIndex,newChatPlayerIndex);
|
||||
if(newChatLanguage == "" || newChatLanguage == connectionSlot->getNetworkPlayerLanguage()) {
|
||||
NetworkMessageText networkMessageText(newChatText.c_str(),newChatTeamIndex,newChatPlayerIndex,"");
|
||||
broadcastMessage(&networkMessageText, connectionSlot->getPlayerIndex(),i);
|
||||
}
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] after broadcast nmtText chatText [%s] chatTeamIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,newChatText.c_str(),newChatTeamIndex);
|
||||
}
|
||||
|
@ -887,7 +926,7 @@ void ServerInterface::updateKeyframe(int frameCount) {
|
|||
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] WARNING / ERROR, requestedCommands.size() = %d\n",__FILE__,__FUNCTION__,__LINE__,requestedCommands.size());
|
||||
|
||||
string sMsg = "may go out of synch: server requestedCommands.size() = " + intToStr(requestedCommands.size());
|
||||
sendTextMessage(sMsg,-1, true);
|
||||
sendTextMessage(sMsg,-1, true,"");
|
||||
}
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] build command list took %lld msecs, networkMessageCommandList.getCommandCount() = %d, frameCount = %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis(),networkMessageCommandList.getCommandCount(),frameCount);
|
||||
|
@ -936,17 +975,18 @@ bool ServerInterface::shouldDiscardNetworkMessage(NetworkMessageType networkMess
|
|||
NetworkMessageText netMsg = NetworkMessageText();
|
||||
connectionSlot->receiveMessage(&netMsg);
|
||||
|
||||
ChatMsgInfo msg(netMsg.getText().c_str(),netMsg.getTeamIndex(),netMsg.getPlayerIndex());
|
||||
ChatMsgInfo msg(netMsg.getText().c_str(),netMsg.getTeamIndex(),netMsg.getPlayerIndex(),netMsg.getTargetLanguage());
|
||||
this->addChatInfo(msg);
|
||||
|
||||
string newChatText = msg.chatText.c_str();
|
||||
//string newChatSender = msg.chatSender.c_str();
|
||||
int newChatTeamIndex = msg.chatTeamIndex;
|
||||
int newChatPlayerIndex = msg.chatPlayerIndex;
|
||||
string newChatLanguage = msg.targetLanguage.c_str();
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) 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(),newChatTeamIndex,newChatPlayerIndex);
|
||||
NetworkMessageText networkMessageText(newChatText.c_str(),newChatTeamIndex,newChatPlayerIndex,newChatLanguage);
|
||||
broadcastMessage(&networkMessageText, connectionSlot->getPlayerIndex());
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] after broadcast nmtText chatText [%s] chatTeamIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,newChatText.c_str(),newChatTeamIndex);
|
||||
|
@ -1036,7 +1076,7 @@ void ServerInterface::waitUntilReady(Checksum *checksum) {
|
|||
}
|
||||
else if(networkMessageType != nmtInvalid) {
|
||||
string sErr = "Unexpected network message: " + intToStr(networkMessageType);
|
||||
sendTextMessage(sErr,-1, true,i);
|
||||
sendTextMessage(sErr,-1, true,"",i);
|
||||
DisplayErrorMessage(sErr);
|
||||
logger.setCancelLoading(false);
|
||||
return;
|
||||
|
@ -1052,9 +1092,19 @@ void ServerInterface::waitUntilReady(Checksum *checksum) {
|
|||
//check for timeout
|
||||
if(allReady == false) {
|
||||
if(chrono.getMillis() > readyWaitTimeout) {
|
||||
Lang &lang= Lang::getInstance();
|
||||
const vector<string> languageList = this->gameSettings.getUniqueNetworkPlayerLanguages();
|
||||
for(unsigned int i = 0; i < languageList.size(); ++i) {
|
||||
string sErr = "Timeout waiting for clients.";
|
||||
sendTextMessage(sErr,-1, true);
|
||||
if(lang.hasString("TimeoutWaitingForClients") == true) {
|
||||
sErr = lang.get("TimeoutWaitingForClients",languageList[i]);
|
||||
}
|
||||
bool localEcho = lang.isLanguageLocal(languageList[i]);
|
||||
sendTextMessage(sErr,-1, localEcho, languageList[i]);
|
||||
if(localEcho == true) {
|
||||
DisplayErrorMessage(sErr);
|
||||
}
|
||||
}
|
||||
logger.setCancelLoading(false);
|
||||
return;
|
||||
}
|
||||
|
@ -1160,12 +1210,19 @@ void ServerInterface::waitUntilReady(Checksum *checksum) {
|
|||
}
|
||||
|
||||
if(logger.getCancelLoading() == true) {
|
||||
string sErr = lang.get("GameCancelledByUser");
|
||||
sendTextMessage(sErr,-1, true);
|
||||
|
||||
Lang &lang= Lang::getInstance();
|
||||
const vector<string> languageList = this->gameSettings.getUniqueNetworkPlayerLanguages();
|
||||
for(unsigned int i = 0; i < languageList.size(); ++i) {
|
||||
string sErr = lang.get("GameCancelledByUser",languageList[i]);
|
||||
bool localEcho = lang.isLanguageLocal(languageList[i]);
|
||||
sendTextMessage(sErr,-1, localEcho,languageList[i]);
|
||||
if(localEcho == true) {
|
||||
DisplayErrorMessage(sErr);
|
||||
}
|
||||
}
|
||||
quitGame(true);
|
||||
|
||||
DisplayErrorMessage(sErr);
|
||||
//DisplayErrorMessage(sErr);
|
||||
logger.setCancelLoading(false);
|
||||
return;
|
||||
}
|
||||
|
@ -1222,34 +1279,38 @@ void ServerInterface::processTextMessageQueue() {
|
|||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] textMessageQueue.size() = %d\n",__FILE__,__FUNCTION__,__LINE__,textMessageQueue.size());
|
||||
for(int i = 0; i < textMessageQueue.size(); ++i) {
|
||||
TextMessageQueue &item = textMessageQueue[i];
|
||||
sendTextMessage(item.text, item.teamIndex, item.echoLocal);
|
||||
sendTextMessage(item.text, item.teamIndex, item.echoLocal, item.targetLanguage);
|
||||
}
|
||||
textMessageQueue.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void ServerInterface::queueTextMessage(const string & text, int teamIndex, bool echoLocal) {
|
||||
void ServerInterface::queueTextMessage(const string & text, int teamIndex,
|
||||
bool echoLocal, string targetLanguage) {
|
||||
MutexSafeWrapper safeMutexSlot(&textMessageQueueThreadAccessor,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
TextMessageQueue item;
|
||||
item.text = text;
|
||||
item.teamIndex = teamIndex;
|
||||
item.echoLocal = echoLocal;
|
||||
item.targetLanguage = targetLanguage;
|
||||
textMessageQueue.push_back(item);
|
||||
}
|
||||
|
||||
void ServerInterface::sendTextMessage(const string & text, int teamIndex, bool echoLocal) {
|
||||
sendTextMessage(text, teamIndex, echoLocal, -1);
|
||||
void ServerInterface::sendTextMessage(const string & text, int teamIndex,
|
||||
bool echoLocal,string targetLanguage) {
|
||||
sendTextMessage(text, teamIndex, echoLocal, targetLanguage, -1);
|
||||
}
|
||||
|
||||
void ServerInterface::sendTextMessage(const string & text, int teamIndex, bool echoLocal, int lockedSlotIndex) {
|
||||
void ServerInterface::sendTextMessage(const string& text, int teamIndex, bool echoLocal,
|
||||
string targetLanguage, int lockedSlotIndex) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] text [%s] teamIndex = %d, echoLocal = %d, lockedSlotIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,text.c_str(),teamIndex,echoLocal,lockedSlotIndex);
|
||||
NetworkMessageText networkMessageText(text, teamIndex, getHumanPlayerIndex());
|
||||
NetworkMessageText networkMessageText(text, teamIndex, getHumanPlayerIndex(), targetLanguage);
|
||||
broadcastMessage(&networkMessageText, -1, lockedSlotIndex);
|
||||
if(echoLocal == true) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) 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(),teamIndex,networkMessageText.getPlayerIndex());
|
||||
ChatMsgInfo msg(text.c_str(),teamIndex,networkMessageText.getPlayerIndex(), targetLanguage);
|
||||
this->addChatInfo(msg);
|
||||
}
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
@ -1433,7 +1494,7 @@ void ServerInterface::broadcastMessage(const NetworkMessage *networkMessage, int
|
|||
safeMutexSlotBroadCastAccessor.ReleaseLock();
|
||||
|
||||
string sMsg = ex.what();
|
||||
sendTextMessage(sMsg,-1, true, lockedSlotIndex);
|
||||
sendTextMessage(sMsg,-1, true, "", lockedSlotIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,13 +33,17 @@ namespace Glest{ namespace Game{
|
|||
// class ServerInterface
|
||||
// =====================================================
|
||||
|
||||
class ServerInterface: public GameNetworkInterface, public ConnectionSlotCallbackInterface, public SimpleTaskCallbackInterface, public FTPClientValidationInterface {
|
||||
class ServerInterface: public GameNetworkInterface,
|
||||
public ConnectionSlotCallbackInterface,
|
||||
public SimpleTaskCallbackInterface,
|
||||
public FTPClientValidationInterface {
|
||||
|
||||
class TextMessageQueue {
|
||||
public:
|
||||
string text;
|
||||
int teamIndex;
|
||||
bool echoLocal;
|
||||
string targetLanguage;
|
||||
};
|
||||
|
||||
private:
|
||||
|
@ -89,9 +93,9 @@ public:
|
|||
virtual void updateLobby() { };
|
||||
virtual void updateKeyframe(int frameCount);
|
||||
virtual void waitUntilReady(Checksum *checksum);
|
||||
virtual void sendTextMessage(const string & text, int teamIndex, bool echoLocal = false);
|
||||
void sendTextMessage(const string & text, int teamIndex, bool echoLocal, int lockedSlotIndex);
|
||||
void queueTextMessage(const string & text, int teamIndex, bool echoLocal = false);
|
||||
virtual void sendTextMessage(const string & text, int teamIndex, bool echoLocal, string targetLanguage);
|
||||
void sendTextMessage(const string & text, int teamIndex, bool echoLocal, string targetLanguage, int lockedSlotIndex);
|
||||
void queueTextMessage(const string & text, int teamIndex, bool echoLocal, string targetLanguage);
|
||||
virtual void quitGame(bool userManuallyQuit);
|
||||
virtual string getNetworkStatus();
|
||||
ServerSocket *getServerSocket()
|
||||
|
|
Loading…
Reference in New Issue