Page 1 of 1

possible bug when AI disconnects

Posted: Fri Dec 28, 2007 11:20 am
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

Re: possible bug when AI disconnects

Posted: Fri Dec 28, 2007 5:12 pm
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...

Re: possible bug when AI disconnects

Posted: Sun Jan 27, 2008 7:20 pm
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.

Re: possible bug when AI disconnects

Posted: Sun Feb 10, 2008 1:11 pm
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.

Re: possible bug when AI disconnects

Posted: Sat Feb 16, 2008 8:41 pm
by DoomWarrior
works fine :D