private static void HandleWorldHash(NetworkMessage msg) { MsgWantWHash hash = msg as MsgWantWHash; WriteLine("Received" + (hash.IsRandomMap ? " Random " : " Normal ") + "WorldHash:" + hash.WorldHash); if (GetWorld) { WriteLine("Requesting World"); client.SendMessage(new MsgGetWorld(0)); } else { SendEnter(); } }
private void HandleWantWorldHash(ServerPlayer player, NetworkMessage msg) { Logger.Log4("Getting world hash for " + player.PlayerID.ToString()); MsgWantWHash hash = msg as MsgWantWHash; if (hash == null) { return; } if (URLCache != null && URLCache.URL != string.Empty) { player.SendMessage(URLCache); } player.SendMessage(HashCache); }
private void HandleWorldHash(NetworkMessage msg) { MsgWantWHash hash = msg as MsgWantWHash; WorldHash = hash.WorldHash; bool getWorld = true; if (Params.CacheFolder != null) { WorldCache = new BZWCache(Params.CacheFolder); if (WorldCache.CheckCacheForHash(hash.WorldHash)) { SetMap(WorldCache.ReadMapFromCache(hash.WorldHash)); if (Map != null) { getWorld = false; } } } if (getWorld && WorldURL != string.Empty) { if (WorldDownloadProgress != null) { WorldDownloadProgress.Invoke(this, new WorldDownloadProgressEventArgs(0)); } // try to download it from the interwebs WebClient worldWWW = new WebClient(); worldWWW.DownloadDataCompleted += worldWWW_DownloadDataCompleted; worldWWW.DownloadProgressChanged += worldWWW_DownloadProgressChanged; worldWWW.DownloadDataAsync(new Uri(WorldURL)); } if (getWorld) { SendGetWorld(); } else { SendEnter(); } }
public override void Setup() { SettingsCache = new MsgGameSettings(); byte[] worldBuffer = World.GetWorldData(); SettingsCache.WorldSize = worldBuffer.Length; SettingsCache.GameType = Config.GameData.GameType; SettingsCache.GameOptions = Config.GameData.GameOptions; SettingsCache.MaxPlayers = Config.GameData.MaxPlayers; SettingsCache.MaxShots = Config.GameData.MaxShots; SettingsCache.MaxFlags = FlagManager.MaxFlagID; SettingsCache.LinearAcceleration = Config.GameData.LinearAcceleration; SettingsCache.AngularAcceleration = Config.GameData.AngularAcceleration; HashCache = new MsgWantWHash(); HashCache.IsRandomMap = World.IsRandom; HashCache.WorldHash = BZFlag.Data.Utils.Cryptography.MD5Hash(worldBuffer); URLCache = new MsgCacheURL(); URLCache.URL = Config.GameData.MapURL; }