possible bug when AI disconnects

Programmers discuss here anything related to FreeOrion programming. Primarily for the developers to discuss.

Moderator: Committer

Post Reply
Message
Author
quarl
Space Krill
Posts: 1
Joined: Fri Dec 28, 2007 10:51 am

possible bug when AI disconnects

#1 Post by quarl »

Hi,

I may have encountered a bug in ServerFSM::HandleNonLobbyDisconnection(). When an AI player is eliminated, the freeoriond process exits and the GUI client hangs at "downloading new state", after these console messages:

Code: Select all

  HumanClientApp::HandleMessage(TURN_PROGRESS)
  HumanClientApp::HandleMessage(PLAYER_ELIMINATED)
I suspect the culprit the following code; disabling it fixes the problem:

Code: Select all

void ServerFSM::HandleNonLobbyDisconnection(const Disconnection& d)
{
    //....
    //....

    if (m_server.m_networking.empty() || m_server.m_ai_clients.size() == m_server.m_networking.NumPlayers()) {
        Logger().debugStream() << "ServerFSM::HandleNonLobbyDisconnection : All human players disconnected; server terminating.";
        Sleep(2000); // HACK! Pause for a bit to let the player disconnected and end game messages propogate.
        m_server.Exit(1);
    }
}
With 1 human and 4 AI players (i.e. single-player), after player #4, an AI player, is eliminated, m_networking.NumPlayers() is 4 but m_ai_clients.size() is still 4, not 3. I don't see any items ever removed from m_ai_clients. So the problem may be an incorrect assumption by HandleNonLobbyDisconnection() regarding the contents of m_ai_clients, or m_ai_clients not being updated somewhere else.

A more robust check might be to count the number of non-AI players still connected (is that possible?). There's a similar check in MPLobby::react(). Also, a more visible error message would be nice for this exit condition (errorStream instead of debugStream?).

For now I just #ifdef-out the check above and the game runs fine.

Best, Karl

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: possible bug when AI disconnects

#2 Post by Geoff the Medio »

You've already posted a comment on this bug on sourceforge, so I don't need to point you to the tracker, but in case anyone else is wondering, this post should clarify things...

DoomWarrior
Krill Swarm
Posts: 13
Joined: Sat Jan 12, 2008 9:23 pm

Re: possible bug when AI disconnects

#3 Post by DoomWarrior »

is there any progress on solving this issue? The game is almost not playable :-(
It would be appricated if there is just a dirty hack as a work-around until this is fixed gracefully.

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: possible bug when AI disconnects

#4 Post by Geoff the Medio »

DoomWarrior wrote:is there any progress on solving this issue? The game is almost not playable :-(
It would be appricated if there is just a dirty hack as a work-around until this is fixed gracefully.
It has been fixed in SVN. Yay for tzlaine.

DoomWarrior
Krill Swarm
Posts: 13
Joined: Sat Jan 12, 2008 9:23 pm

Re: possible bug when AI disconnects

#5 Post by DoomWarrior »

works fine :D

Post Reply