- bugfixes for network player disconnect feature
This commit is contained in:
parent
b7f72be930
commit
a4ad1f5aea
|
@ -485,7 +485,7 @@ void Commander::tryResumeGame() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Commander::tryNetworkPlayerDisconnected(int factionIndex) const {
|
void Commander::tryNetworkPlayerDisconnected(int factionIndex) const {
|
||||||
NetworkCommand command(this->world,nctPlayerStatusChange, factionIndex, 1);
|
NetworkCommand command(this->world,nctPlayerStatusChange, factionIndex, npst_Disconnected);
|
||||||
pushNetworkCommand(&command);
|
pushNetworkCommand(&command);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -882,9 +882,15 @@ void Commander::giveNetworkCommand(NetworkCommand* networkCommand) const {
|
||||||
int factionIndex = networkCommand->getUnitId();
|
int factionIndex = networkCommand->getUnitId();
|
||||||
int playerStatus = networkCommand->getCommandTypeId();
|
int playerStatus = networkCommand->getCommandTypeId();
|
||||||
|
|
||||||
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"nctPlayerStatusChange factionIndex = %d playerStatus = %d\n",factionIndex,playerStatus);
|
||||||
|
|
||||||
GameSettings *settings = world->getGameSettingsPtr();
|
GameSettings *settings = world->getGameSettingsPtr();
|
||||||
if(playerStatus == 1) {
|
if(playerStatus == npst_Disconnected) {
|
||||||
settings->setNetworkPlayerGameStatus(factionIndex,1);
|
settings->setNetworkPlayerStatuses(factionIndex,npst_Disconnected);
|
||||||
|
|
||||||
|
//printf("nctPlayerStatusChange -> faction->getPersonalityType() = %d index [%d] control [%d] networkstatus [%d]\n",
|
||||||
|
// world->getFaction(factionIndex)->getPersonalityType(),world->getFaction(factionIndex)->getIndex(),world->getFaction(factionIndex)->getControlType(),settings->getNetworkPlayerStatuses(factionIndex));
|
||||||
|
|
||||||
if(!world->getGame()->getGameOver()&& !this->world->getGame()->factionLostGame(factionIndex)){
|
if(!world->getGame()->getGameOver()&& !this->world->getGame()->factionLostGame(factionIndex)){
|
||||||
// use the fallback multiplier here
|
// use the fallback multiplier here
|
||||||
settings->setResourceMultiplierIndex(factionIndex,settings->getFallbackCpuMultiplier());
|
settings->setResourceMultiplierIndex(factionIndex,settings->getFallbackCpuMultiplier());
|
||||||
|
|
|
@ -2233,11 +2233,12 @@ void Game::mouseDownLeft(int x, int y) {
|
||||||
for(unsigned int i = 0; i < world.getFactionCount(); ++i) {
|
for(unsigned int i = 0; i < world.getFactionCount(); ++i) {
|
||||||
Faction *faction = world.getFaction(i);
|
Faction *faction = world.getFaction(i);
|
||||||
|
|
||||||
//printf("faction->getPersonalityType() = %d index [%d,%d] control [%d]\n",faction->getPersonalityType(),world.getThisFaction()->getIndex(),faction->getIndex(),faction->getControlType());
|
//printf("faction->getPersonalityType() = %d index [%d,%d] control [%d] networkstatus [%d]\n",faction->getPersonalityType(),world.getThisFaction()->getIndex(),faction->getIndex(),faction->getControlType(),this->gameSettings.getNetworkPlayerStatuses(i));
|
||||||
|
|
||||||
if(faction->getPersonalityType() != fpt_Observer &&
|
if(faction->getPersonalityType() != fpt_Observer &&
|
||||||
world.getThisFaction()->getIndex() != faction->getIndex() &&
|
world.getThisFaction()->getIndex() != faction->getIndex() &&
|
||||||
faction->getControlType() == ctNetwork) {
|
faction->getControlType() == ctNetwork &&
|
||||||
|
this->gameSettings.getNetworkPlayerStatuses(i) != npst_Disconnected) {
|
||||||
|
|
||||||
char szBuf[1024]="";
|
char szBuf[1024]="";
|
||||||
if(lang.hasString("DisconnectNetorkPlayerIndex") == true) {
|
if(lang.hasString("DisconnectNetorkPlayerIndex") == true) {
|
||||||
|
|
|
@ -41,6 +41,13 @@ enum FlagTypes1 {
|
||||||
//ft1_xx = 0x10,
|
//ft1_xx = 0x10,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum NetworkPlayerStatusType {
|
||||||
|
npst_None = 0,
|
||||||
|
npst_PickSettings = 1,
|
||||||
|
npst_BeRightBack = 2,
|
||||||
|
npst_Ready = 3,
|
||||||
|
npst_Disconnected = 4
|
||||||
|
};
|
||||||
|
|
||||||
class GameSettings {
|
class GameSettings {
|
||||||
private:
|
private:
|
||||||
|
@ -114,7 +121,7 @@ public:
|
||||||
for(int i = 0; i < GameConstants::maxPlayers; ++i) {
|
for(int i = 0; i < GameConstants::maxPlayers; ++i) {
|
||||||
factionTypeNames[i] = "";
|
factionTypeNames[i] = "";
|
||||||
networkPlayerNames[i] = "";
|
networkPlayerNames[i] = "";
|
||||||
networkPlayerStatuses[i] = 0;
|
networkPlayerStatuses[i] = npst_None;
|
||||||
networkPlayerLanguages[i] = DEFAULT_LANG;
|
networkPlayerLanguages[i] = DEFAULT_LANG;
|
||||||
factionControls[i] = ctClosed;
|
factionControls[i] = ctClosed;
|
||||||
resourceMultiplierIndex[i] = 1.0f;
|
resourceMultiplierIndex[i] = 1.0f;
|
||||||
|
@ -147,7 +154,7 @@ public:
|
||||||
const string &getFactionTypeName(int factionIndex) const {return factionTypeNames[factionIndex];}
|
const string &getFactionTypeName(int factionIndex) const {return factionTypeNames[factionIndex];}
|
||||||
string getNetworkPlayerName(int factionIndex) const {
|
string getNetworkPlayerName(int factionIndex) const {
|
||||||
string result = networkPlayerNames[factionIndex];
|
string result = networkPlayerNames[factionIndex];
|
||||||
if(networkPlayerGameStatus[factionIndex] == 1) {
|
if(networkPlayerStatuses[factionIndex] == npst_Disconnected) {
|
||||||
result = playerDisconnectedText + result;
|
result = playerDisconnectedText + result;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -4309,7 +4309,7 @@ int glestMain(int argc, char** argv) {
|
||||||
for(int i = 0; i < GameConstants::maxPlayers; ++i) {
|
for(int i = 0; i < GameConstants::maxPlayers; ++i) {
|
||||||
ControlType ct= ctClosed;
|
ControlType ct= ctClosed;
|
||||||
|
|
||||||
gameSettings->setNetworkPlayerStatuses(i, 0);
|
gameSettings->setNetworkPlayerStatuses(i, npst_None);
|
||||||
gameSettings->setFactionControl(i, ct);
|
gameSettings->setFactionControl(i, ct);
|
||||||
gameSettings->setStartLocationIndex(i, i);
|
gameSettings->setStartLocationIndex(i, i);
|
||||||
gameSettings->setResourceMultiplierIndex(i, 10);
|
gameSettings->setResourceMultiplierIndex(i, 10);
|
||||||
|
@ -4318,7 +4318,7 @@ int glestMain(int argc, char** argv) {
|
||||||
|
|
||||||
ControlType ct= ctHuman;
|
ControlType ct= ctHuman;
|
||||||
|
|
||||||
gameSettings->setNetworkPlayerStatuses(0, 0);
|
gameSettings->setNetworkPlayerStatuses(0, npst_None);
|
||||||
gameSettings->setFactionControl(0, ct);
|
gameSettings->setFactionControl(0, ct);
|
||||||
gameSettings->setFactionTypeName(0, formatString(GameConstants::OBSERVER_SLOTNAME));
|
gameSettings->setFactionTypeName(0, formatString(GameConstants::OBSERVER_SLOTNAME));
|
||||||
gameSettings->setTeam(0, GameConstants::maxPlayers + fpt_Observer - 1);
|
gameSettings->setTeam(0, GameConstants::maxPlayers + fpt_Observer - 1);
|
||||||
|
|
|
@ -1565,7 +1565,7 @@ void MenuStateConnectedGame::loadGameSettings(GameSettings *gameSettings) {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] i = %d, factionFiles[listBoxFactions[i].getSelectedItemIndex()] [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,i,factionFiles[listBoxFactions[i].getSelectedItemIndex()].c_str());
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] i = %d, factionFiles[listBoxFactions[i].getSelectedItemIndex()] [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,i,factionFiles[listBoxFactions[i].getSelectedItemIndex()].c_str());
|
||||||
|
|
||||||
gameSettings->setFactionTypeName(slotIndex, factionFiles[listBoxFactions[i].getSelectedItemIndex()]);
|
gameSettings->setFactionTypeName(slotIndex, factionFiles[listBoxFactions[i].getSelectedItemIndex()]);
|
||||||
gameSettings->setNetworkPlayerStatuses(slotIndex, 0);
|
gameSettings->setNetworkPlayerStatuses(slotIndex, npst_Disconnected);
|
||||||
gameSettings->setNetworkPlayerName(slotIndex, "Closed");
|
gameSettings->setNetworkPlayerName(slotIndex, "Closed");
|
||||||
|
|
||||||
closedCount++;
|
closedCount++;
|
||||||
|
@ -3709,6 +3709,10 @@ void MenuStateConnectedGame::setupUIFromGameSettings(GameSettings *gameSettings,
|
||||||
labelPlayerStatus[slot].setText(lang.get("PlayerStatusSetup"));
|
labelPlayerStatus[slot].setText(lang.get("PlayerStatusSetup"));
|
||||||
labelPlayerStatus[slot].setTextColor(Vec3f(1.f, 0.f, 0.f));
|
labelPlayerStatus[slot].setTextColor(Vec3f(1.f, 0.f, 0.f));
|
||||||
break;
|
break;
|
||||||
|
case npst_Disconnected:
|
||||||
|
labelPlayerStatus[slot].setText(lang.get("Closed"));
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
labelPlayerStatus[slot].setText("");
|
labelPlayerStatus[slot].setText("");
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -2305,6 +2305,10 @@ void MenuStateCustomGame::update() {
|
||||||
labelPlayerStatus[i].setText(lang.get("PlayerStatusSetup"));
|
labelPlayerStatus[i].setText(lang.get("PlayerStatusSetup"));
|
||||||
labelPlayerStatus[i].setTextColor(Vec3f(1.f, 0.f, 0.f));
|
labelPlayerStatus[i].setTextColor(Vec3f(1.f, 0.f, 0.f));
|
||||||
break;
|
break;
|
||||||
|
case npst_Disconnected:
|
||||||
|
labelPlayerStatus[i].setText(lang.get("Closed"));
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
labelPlayerStatus[i].setText("");
|
labelPlayerStatus[i].setText("");
|
||||||
break;
|
break;
|
||||||
|
@ -3220,7 +3224,7 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings,bool force
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//gameSettings->setNetworkPlayerName("");
|
//gameSettings->setNetworkPlayerName("");
|
||||||
gameSettings->setNetworkPlayerStatuses(factionCount, 0);
|
gameSettings->setNetworkPlayerStatuses(factionCount, npst_Disconnected);
|
||||||
labelPlayerNames[i].setText("");
|
labelPlayerNames[i].setText("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -250,7 +250,7 @@ ConnectionSlot::ConnectionSlot(ServerInterface* serverInterface, int playerIndex
|
||||||
this->sessionKey = 0;
|
this->sessionKey = 0;
|
||||||
this->serverInterface = serverInterface;
|
this->serverInterface = serverInterface;
|
||||||
this->playerIndex = playerIndex;
|
this->playerIndex = playerIndex;
|
||||||
this->playerStatus = 0;
|
this->playerStatus = npst_None;
|
||||||
this->playerLanguage = "";
|
this->playerLanguage = "";
|
||||||
this->currentFrameCount = 0;
|
this->currentFrameCount = 0;
|
||||||
this->currentLagCount = 0;
|
this->currentLagCount = 0;
|
||||||
|
|
|
@ -601,13 +601,6 @@ enum SwitchSetupRequestFlagType {
|
||||||
ssrft_PlayerStatus = 0x20
|
ssrft_PlayerStatus = 0x20
|
||||||
};
|
};
|
||||||
|
|
||||||
enum NetworkPlayerStatusType {
|
|
||||||
npst_None = 0x00,
|
|
||||||
npst_PickSettings = 0x01,
|
|
||||||
npst_BeRightBack = 0x02,
|
|
||||||
npst_Ready = 0x04
|
|
||||||
};
|
|
||||||
|
|
||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
class SwitchSetupRequest: public NetworkMessage{
|
class SwitchSetupRequest: public NetworkMessage{
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in New Issue