mirror of
https://github.com/glest/glest-source.git
synced 2025-02-24 19:52:25 +01:00
- 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 {
|
||||
NetworkCommand command(this->world,nctPlayerStatusChange, factionIndex, 1);
|
||||
NetworkCommand command(this->world,nctPlayerStatusChange, factionIndex, npst_Disconnected);
|
||||
pushNetworkCommand(&command);
|
||||
}
|
||||
|
||||
@ -882,9 +882,15 @@ void Commander::giveNetworkCommand(NetworkCommand* networkCommand) const {
|
||||
int factionIndex = networkCommand->getUnitId();
|
||||
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();
|
||||
if(playerStatus == 1) {
|
||||
settings->setNetworkPlayerGameStatus(factionIndex,1);
|
||||
if(playerStatus == npst_Disconnected) {
|
||||
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)){
|
||||
// use the fallback multiplier here
|
||||
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) {
|
||||
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 &&
|
||||
world.getThisFaction()->getIndex() != faction->getIndex() &&
|
||||
faction->getControlType() == ctNetwork) {
|
||||
faction->getControlType() == ctNetwork &&
|
||||
this->gameSettings.getNetworkPlayerStatuses(i) != npst_Disconnected) {
|
||||
|
||||
char szBuf[1024]="";
|
||||
if(lang.hasString("DisconnectNetorkPlayerIndex") == true) {
|
||||
|
@ -41,6 +41,13 @@ enum FlagTypes1 {
|
||||
//ft1_xx = 0x10,
|
||||
};
|
||||
|
||||
enum NetworkPlayerStatusType {
|
||||
npst_None = 0,
|
||||
npst_PickSettings = 1,
|
||||
npst_BeRightBack = 2,
|
||||
npst_Ready = 3,
|
||||
npst_Disconnected = 4
|
||||
};
|
||||
|
||||
class GameSettings {
|
||||
private:
|
||||
@ -114,7 +121,7 @@ public:
|
||||
for(int i = 0; i < GameConstants::maxPlayers; ++i) {
|
||||
factionTypeNames[i] = "";
|
||||
networkPlayerNames[i] = "";
|
||||
networkPlayerStatuses[i] = 0;
|
||||
networkPlayerStatuses[i] = npst_None;
|
||||
networkPlayerLanguages[i] = DEFAULT_LANG;
|
||||
factionControls[i] = ctClosed;
|
||||
resourceMultiplierIndex[i] = 1.0f;
|
||||
@ -147,7 +154,7 @@ public:
|
||||
const string &getFactionTypeName(int factionIndex) const {return factionTypeNames[factionIndex];}
|
||||
string getNetworkPlayerName(int factionIndex) const {
|
||||
string result = networkPlayerNames[factionIndex];
|
||||
if(networkPlayerGameStatus[factionIndex] == 1) {
|
||||
if(networkPlayerStatuses[factionIndex] == npst_Disconnected) {
|
||||
result = playerDisconnectedText + result;
|
||||
}
|
||||
return result;
|
||||
|
@ -4309,7 +4309,7 @@ int glestMain(int argc, char** argv) {
|
||||
for(int i = 0; i < GameConstants::maxPlayers; ++i) {
|
||||
ControlType ct= ctClosed;
|
||||
|
||||
gameSettings->setNetworkPlayerStatuses(i, 0);
|
||||
gameSettings->setNetworkPlayerStatuses(i, npst_None);
|
||||
gameSettings->setFactionControl(i, ct);
|
||||
gameSettings->setStartLocationIndex(i, i);
|
||||
gameSettings->setResourceMultiplierIndex(i, 10);
|
||||
@ -4318,7 +4318,7 @@ int glestMain(int argc, char** argv) {
|
||||
|
||||
ControlType ct= ctHuman;
|
||||
|
||||
gameSettings->setNetworkPlayerStatuses(0, 0);
|
||||
gameSettings->setNetworkPlayerStatuses(0, npst_None);
|
||||
gameSettings->setFactionControl(0, ct);
|
||||
gameSettings->setFactionTypeName(0, formatString(GameConstants::OBSERVER_SLOTNAME));
|
||||
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());
|
||||
|
||||
gameSettings->setFactionTypeName(slotIndex, factionFiles[listBoxFactions[i].getSelectedItemIndex()]);
|
||||
gameSettings->setNetworkPlayerStatuses(slotIndex, 0);
|
||||
gameSettings->setNetworkPlayerStatuses(slotIndex, npst_Disconnected);
|
||||
gameSettings->setNetworkPlayerName(slotIndex, "Closed");
|
||||
|
||||
closedCount++;
|
||||
@ -3709,6 +3709,10 @@ void MenuStateConnectedGame::setupUIFromGameSettings(GameSettings *gameSettings,
|
||||
labelPlayerStatus[slot].setText(lang.get("PlayerStatusSetup"));
|
||||
labelPlayerStatus[slot].setTextColor(Vec3f(1.f, 0.f, 0.f));
|
||||
break;
|
||||
case npst_Disconnected:
|
||||
labelPlayerStatus[slot].setText(lang.get("Closed"));
|
||||
break;
|
||||
|
||||
default:
|
||||
labelPlayerStatus[slot].setText("");
|
||||
break;
|
||||
|
@ -2305,6 +2305,10 @@ void MenuStateCustomGame::update() {
|
||||
labelPlayerStatus[i].setText(lang.get("PlayerStatusSetup"));
|
||||
labelPlayerStatus[i].setTextColor(Vec3f(1.f, 0.f, 0.f));
|
||||
break;
|
||||
case npst_Disconnected:
|
||||
labelPlayerStatus[i].setText(lang.get("Closed"));
|
||||
break;
|
||||
|
||||
default:
|
||||
labelPlayerStatus[i].setText("");
|
||||
break;
|
||||
@ -3220,7 +3224,7 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings,bool force
|
||||
}
|
||||
else {
|
||||
//gameSettings->setNetworkPlayerName("");
|
||||
gameSettings->setNetworkPlayerStatuses(factionCount, 0);
|
||||
gameSettings->setNetworkPlayerStatuses(factionCount, npst_Disconnected);
|
||||
labelPlayerNames[i].setText("");
|
||||
}
|
||||
}
|
||||
|
@ -250,7 +250,7 @@ ConnectionSlot::ConnectionSlot(ServerInterface* serverInterface, int playerIndex
|
||||
this->sessionKey = 0;
|
||||
this->serverInterface = serverInterface;
|
||||
this->playerIndex = playerIndex;
|
||||
this->playerStatus = 0;
|
||||
this->playerStatus = npst_None;
|
||||
this->playerLanguage = "";
|
||||
this->currentFrameCount = 0;
|
||||
this->currentLagCount = 0;
|
||||
|
@ -601,13 +601,6 @@ enum SwitchSetupRequestFlagType {
|
||||
ssrft_PlayerStatus = 0x20
|
||||
};
|
||||
|
||||
enum NetworkPlayerStatusType {
|
||||
npst_None = 0x00,
|
||||
npst_PickSettings = 0x01,
|
||||
npst_BeRightBack = 0x02,
|
||||
npst_Ready = 0x04
|
||||
};
|
||||
|
||||
#pragma pack(push, 1)
|
||||
class SwitchSetupRequest: public NetworkMessage{
|
||||
private:
|
||||
|
Loading…
x
Reference in New Issue
Block a user