invertika_game.Game.GameHandler.addPendingCharacter C# (CSharp) Method

addPendingCharacter() public method

public addPendingCharacter ( string token, Character ch ) : void
token string
ch Character
return void
        public void addPendingCharacter(string token, Character ch)
        {
            /* First, check if the character is already on the map. This may happen if
               a client just lost its connection, and logged to the account server
               again, yet the game server has not yet detected the lost connection. */

            int id=ch.getDatabaseID();

            foreach(NetComputer client in clients)
            {
                GameClient c=(GameClient)client;

                Character old_ch=c.character;
                if(old_ch!=null&&old_ch.getDatabaseID()==id)
                {
                    if(c.status!=(int)AccountClientStatus.CLIENT_CONNECTED)
                    {
                        /* Either the server is confused, or the client is up to no
                           good. So ignore the request, and wait for the connections
                           to properly time out. */
                        return;
                    }

                    /* As the connection was not properly closed, the account server
                       has not yet updated its data, so ignore them. Instead, take the
                       already present character, kill its current connection, and make
                       it available for a new connection. */

                    //delete ch;
                    GameState.remove(old_ch);
                    kill(old_ch);
                    ch=old_ch;
                    break;
                }
            }

            // Mark the character as pending a connection.
            mTokenCollector.addPendingConnect(token, ch);
        }