ACR_ServerCommunicator.GameWorldManager.ConsistencyCheck C# (CSharp) Method

ConsistencyCheck() private method

This debug routine verifies the consistency of the game world data model.
private ConsistencyCheck ( ) : void
return void
        private void ConsistencyCheck()
        {
            foreach (GameCharacter Character in OnlineCharacters)
            {
                GameServer Server = Character.Server;

                if (Character.Online == false)
                    throw new ApplicationException("Offline character " + Character.Name + " is in the global online list.");

                if (Server == null)
                    throw new ApplicationException("Character " + Character.CharacterName + " is online at no server.");

                var CharsInList = (from C in Server.Characters
                                   where C == Character
                                   select C);

                if (CharsInList.Count<GameCharacter>() != 1)
                {
                    throw new ApplicationException("Character " + Character.Name + " is in its parent servers character list an incorrect number of times: " + CharsInList.Count<GameCharacter>().ToString());
                }
            }

            foreach (GameServer Server in Servers)
            {
                foreach (GameCharacter Character in Server.Characters)
                {
                    if (Character.Online == false)
                        throw new ApplicationException("Offline character " + Character.Name + " is in server " + Server.Name + " online character list.");

                    if (Character.Server != Server)
                        throw new ApplicationException("Offline character " + Character.Name + " is in server " + Server.Name + " online character list, but claims to be in server " + (Character.Server == null ? "none" : Character.Server.Name) + " online list.");

                    var CharsInList = (from C in OnlineCharacters
                                       where C == Character
                                       select C);

                    if (CharsInList.Count<GameCharacter>() != 1)
                    {
                        throw new ApplicationException("GameServer " + Server.Name + " has online character " + Character.Name + " which is not in the global online list the correct number of times: " + CharsInList.Count<GameCharacter>().ToString());
                    }
                }
            }
        }
#endif