- bugfix for playername index offset on client
This commit is contained in:
parent
54ce27d19c
commit
ae010f85ab
|
@ -1021,6 +1021,7 @@ void MenuStateConnectedGame::update() {
|
||||||
//needToSetChangedGameSettings = false;
|
//needToSetChangedGameSettings = false;
|
||||||
//lastSetChangedGameSettings = time(NULL);
|
//lastSetChangedGameSettings = time(NULL);
|
||||||
clientInterface->sendSwitchSetupRequest("",clientInterface->getPlayerIndex(),-1,-1,getHumanPlayerName(),switchSetupRequestFlagType);
|
clientInterface->sendSwitchSetupRequest("",clientInterface->getPlayerIndex(),-1,-1,getHumanPlayerName(),switchSetupRequestFlagType);
|
||||||
|
|
||||||
switchSetupRequestFlagType=ssrft_None;
|
switchSetupRequestFlagType=ssrft_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1262,7 +1263,7 @@ void MenuStateConnectedGame::keyUp(char key) {
|
||||||
|
|
||||||
void MenuStateConnectedGame::setActiveInputLabel(GraphicLabel *newLable) {
|
void MenuStateConnectedGame::setActiveInputLabel(GraphicLabel *newLable) {
|
||||||
|
|
||||||
/*
|
|
||||||
if(newLable != NULL) {
|
if(newLable != NULL) {
|
||||||
string text= newLable->getText();
|
string text= newLable->getText();
|
||||||
size_t found = text.find_last_of("_");
|
size_t found = text.find_last_of("_");
|
||||||
|
@ -1280,13 +1281,13 @@ void MenuStateConnectedGame::setActiveInputLabel(GraphicLabel *newLable) {
|
||||||
activeInputLabel->setText(text);
|
activeInputLabel->setText(text);
|
||||||
}
|
}
|
||||||
activeInputLabel = newLable;
|
activeInputLabel = newLable;
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
string MenuStateConnectedGame::getHumanPlayerName() {
|
string MenuStateConnectedGame::getHumanPlayerName() {
|
||||||
string result = defaultPlayerName;
|
string result = defaultPlayerName;
|
||||||
|
|
||||||
/*
|
|
||||||
NetworkManager &networkManager= NetworkManager::getInstance();
|
NetworkManager &networkManager= NetworkManager::getInstance();
|
||||||
ClientInterface* clientInterface= networkManager.getClientInterface();
|
ClientInterface* clientInterface= networkManager.getClientInterface();
|
||||||
for(int j=0; j<GameConstants::maxPlayers; ++j) {
|
for(int j=0; j<GameConstants::maxPlayers; ++j) {
|
||||||
|
@ -1305,7 +1306,7 @@ string MenuStateConnectedGame::getHumanPlayerName() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2406,7 +2406,7 @@ string MenuStateCustomGame::getCurrentMapFile(){
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuStateCustomGame::setActiveInputLabel(GraphicLabel *newLable) {
|
void MenuStateCustomGame::setActiveInputLabel(GraphicLabel *newLable) {
|
||||||
/*
|
|
||||||
if(newLable != NULL) {
|
if(newLable != NULL) {
|
||||||
string text= newLable->getText();
|
string text= newLable->getText();
|
||||||
size_t found = text.find_last_of("_");
|
size_t found = text.find_last_of("_");
|
||||||
|
@ -2424,7 +2424,7 @@ void MenuStateCustomGame::setActiveInputLabel(GraphicLabel *newLable) {
|
||||||
activeInputLabel->setText(text);
|
activeInputLabel->setText(text);
|
||||||
}
|
}
|
||||||
activeInputLabel = newLable;
|
activeInputLabel = newLable;
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
string MenuStateCustomGame::getHumanPlayerName(int index) {
|
string MenuStateCustomGame::getHumanPlayerName(int index) {
|
||||||
|
@ -2433,7 +2433,7 @@ string MenuStateCustomGame::getHumanPlayerName(int index) {
|
||||||
//printf("\nIn [%s::%s Line: %d] index = %d\n",__FILE__,__FUNCTION__,__LINE__,index);
|
//printf("\nIn [%s::%s Line: %d] index = %d\n",__FILE__,__FUNCTION__,__LINE__,index);
|
||||||
//fflush(stdout);
|
//fflush(stdout);
|
||||||
|
|
||||||
/*
|
|
||||||
if(index < 0) {
|
if(index < 0) {
|
||||||
for(int j = 0; j < GameConstants::maxPlayers; ++j) {
|
for(int j = 0; j < GameConstants::maxPlayers; ++j) {
|
||||||
if(listBoxControls[j].getSelectedItemIndex() >= 0) {
|
if(listBoxControls[j].getSelectedItemIndex() >= 0) {
|
||||||
|
@ -2461,7 +2461,7 @@ string MenuStateCustomGame::getHumanPlayerName(int index) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -181,7 +181,7 @@ void ClientInterface::updateLobby() {
|
||||||
playerIndex= networkMessageIntro.getPlayerIndex();
|
playerIndex= networkMessageIntro.getPlayerIndex();
|
||||||
serverName= networkMessageIntro.getName();
|
serverName= networkMessageIntro.getName();
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] got NetworkMessageIntro, networkMessageIntro.getGameState() = %d, versionString [%s], sessionKey = %d\n",__FILE__,__FUNCTION__,__LINE__,networkMessageIntro.getGameState(),versionString.c_str(),sessionKey);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] got NetworkMessageIntro, networkMessageIntro.getGameState() = %d, versionString [%s], sessionKey = %d, playerIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,networkMessageIntro.getGameState(),versionString.c_str(),sessionKey,playerIndex);
|
||||||
|
|
||||||
//check consistency
|
//check consistency
|
||||||
if(networkMessageIntro.getVersionString() != getNetworkVersionString()) {
|
if(networkMessageIntro.getVersionString() != getNetworkVersionString()) {
|
||||||
|
@ -471,7 +471,7 @@ void ClientInterface::updateLobby() {
|
||||||
//set the faction index
|
//set the faction index
|
||||||
if(gameSettings.getStartLocationIndex(i) == playerIndex) {
|
if(gameSettings.getStartLocationIndex(i) == playerIndex) {
|
||||||
gameSettings.setThisFactionIndex(i);
|
gameSettings.setThisFactionIndex(i);
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Lined: %d] gameSettings.getThisFactionIndex(i) = %d, playerIndex = %d, i = %d\n",__FILE__,__FUNCTION__,__LINE__,gameSettings.getThisFactionIndex(),playerIndex,i);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] gameSettings.getThisFactionIndex(i) = %d, playerIndex = %d, i = %d\n",__FILE__,__FUNCTION__,__LINE__,gameSettings.getThisFactionIndex(),playerIndex,i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -487,9 +487,10 @@ void ClientInterface::updateLobby() {
|
||||||
case nmtPlayerIndexMessage:
|
case nmtPlayerIndexMessage:
|
||||||
{
|
{
|
||||||
PlayerIndexMessage playerIndexMessage(-1);
|
PlayerIndexMessage playerIndexMessage(-1);
|
||||||
if(receiveMessage(&playerIndexMessage))
|
if(receiveMessage(&playerIndexMessage)) {
|
||||||
{
|
|
||||||
playerIndex= playerIndexMessage.getPlayerIndex();
|
playerIndex= playerIndexMessage.getPlayerIndex();
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] got nmtPlayerIndexMessage, playerIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,playerIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -791,7 +792,11 @@ void ClientInterface::waitUntilReady(Checksum* checksum) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientInterface::sendTextMessage(const string &text, int teamIndex, bool echoLocal){
|
void ClientInterface::sendTextMessage(const string &text, int teamIndex, bool echoLocal){
|
||||||
NetworkMessageText networkMessageText(text, getHumanPlayerName(), teamIndex);
|
|
||||||
|
string humanPlayerName = getHumanPlayerName();
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] humanPlayerName = [%s] playerIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,humanPlayerName.c_str(),playerIndex);
|
||||||
|
|
||||||
|
NetworkMessageText networkMessageText(text, humanPlayerName, teamIndex);
|
||||||
sendMessage(&networkMessageText);
|
sendMessage(&networkMessageText);
|
||||||
|
|
||||||
if(echoLocal == true) {
|
if(echoLocal == true) {
|
||||||
|
@ -1015,9 +1020,9 @@ bool ClientInterface::shouldDiscardNetworkMessage(NetworkMessageType networkMess
|
||||||
string ClientInterface::getHumanPlayerName(int index) {
|
string ClientInterface::getHumanPlayerName(int index) {
|
||||||
string result = Config::getInstance().getString("NetPlayerName",Socket::getHostName().c_str());
|
string result = Config::getInstance().getString("NetPlayerName",Socket::getHostName().c_str());
|
||||||
|
|
||||||
if(index >= 0 || playerIndex >= 0) {
|
if(index >= 0 || playerIndex > 0) {
|
||||||
if(index < 0) {
|
if(index < 0) {
|
||||||
index = playerIndex;
|
index = playerIndex-1;
|
||||||
}
|
}
|
||||||
if(gameSettings.getNetworkPlayerName(index) != "") {
|
if(gameSettings.getNetworkPlayerName(index) != "") {
|
||||||
result = gameSettings.getNetworkPlayerName(index);
|
result = gameSettings.getNetworkPlayerName(index);
|
||||||
|
|
Loading…
Reference in New Issue