// Token: 0x06000743 RID: 1859 RVA: 0x0003A8AC File Offset: 0x00038AAC public bool UpdateStatus(float dt, bool logErrors = false) { if (this.m_abort) { ZLog.Log("ZConnector - Abort"); return(true); } if (this.m_dnsError) { ZLog.Log("ZConnector - dns error"); return(true); } if (this.m_result != null && this.m_result.IsCompleted) { ZLog.Log("ZConnector - result completed"); return(true); } this.m_timer += dt; if (this.m_timer > ZConnector.m_timeout) { ZLog.Log("ZConnector - timeout"); this.Close(); return(true); } return(false); }
// Token: 0x06000BCF RID: 3023 RVA: 0x0005413C File Offset: 0x0005233C private void UpdateSpawnList(List <SpawnSystem.SpawnData> spawners, DateTime currentTime, bool eventSpawners) { string str = eventSpawners ? "e_" : "b_"; int num = 0; foreach (SpawnSystem.SpawnData spawnData in spawners) { num++; if (spawnData.m_enabled && this.m_heightmap.HaveBiome(spawnData.m_biome)) { int stableHashCode = (str + spawnData.m_prefab.name + num.ToString()).GetStableHashCode(); DateTime d = new DateTime(this.m_nview.GetZDO().GetLong(stableHashCode, 0L)); TimeSpan timeSpan = currentTime - d; int num2 = Mathf.Min(spawnData.m_maxSpawned, (int)(timeSpan.TotalSeconds / (double)spawnData.m_spawnInterval)); if (num2 > 0) { this.m_nview.GetZDO().Set(stableHashCode, currentTime.Ticks); } for (int i = 0; i < num2; i++) { if (UnityEngine.Random.Range(0f, 100f) <= spawnData.m_spawnChance) { if ((!string.IsNullOrEmpty(spawnData.m_requiredGlobalKey) && !ZoneSystem.instance.GetGlobalKey(spawnData.m_requiredGlobalKey)) || (spawnData.m_requiredEnvironments.Count > 0 && !EnvMan.instance.IsEnvironment(spawnData.m_requiredEnvironments)) || (!spawnData.m_spawnAtDay && EnvMan.instance.IsDay()) || (!spawnData.m_spawnAtNight && EnvMan.instance.IsNight()) || SpawnSystem.GetNrOfInstances(spawnData.m_prefab, Vector3.zero, 0f, eventSpawners, false) >= spawnData.m_maxSpawned) { break; } Vector3 vector; Player player; if (this.FindBaseSpawnPoint(spawnData, this.m_nearPlayers, out vector, out player) && (spawnData.m_spawnDistance <= 0f || !SpawnSystem.HaveInstanceInRange(spawnData.m_prefab, vector, spawnData.m_spawnDistance))) { int num3 = UnityEngine.Random.Range(spawnData.m_groupSizeMin, spawnData.m_groupSizeMax + 1); float d2 = (num3 > 1) ? spawnData.m_groupRadius : 0f; int num4 = 0; for (int j = 0; j < num3 * 2; j++) { Vector2 insideUnitCircle = UnityEngine.Random.insideUnitCircle; Vector3 a = vector + new Vector3(insideUnitCircle.x, 0f, insideUnitCircle.y) * d2; if (this.IsSpawnPointGood(spawnData, ref a)) { this.Spawn(spawnData, a + Vector3.up * spawnData.m_groundOffset, eventSpawners); num4++; if (num4 >= num3) { break; } } } ZLog.Log(string.Concat(new object[] { "Spawned ", spawnData.m_prefab.name, " x ", num4 })); } } } } } }
private IEnumerator rebindEquipment() { // wait 1 frame to start transition yield return(0); ZLog.Log("Rebinding equipment"); var inTransition = true; while (inTransition) { yield return(0); // check for transition next frame inTransition = false; for (var i = 0; i < standAnimator.layerCount; i++) { if (standAnimator.IsInTransition(i)) { inTransition = true; } } } ZLog.Log("Animation transition finished, rebinding"); foreach (var slot in equipmentSlotManager.slots.Values) { if (slot.isFilled()) { slot.bindSkeletonToStand(); } } }
// Token: 0x06000C64 RID: 3172 RVA: 0x00058FE8 File Offset: 0x000571E8 private bool CheckExposure(Player human) { float num; bool flag; Cover.GetCoverForPoint(this.GetSpawnPoint(), out num, out flag); if (!flag) { human.Message(MessageHud.MessageType.Center, "$msg_bedneedroof", 0, null); return(false); } if (num < 0.8f) { human.Message(MessageHud.MessageType.Center, "$msg_bedtooexposed", 0, null); return(false); } ZLog.Log(string.Concat(new object[] { "exporeusre check ", num, " ", flag.ToString() })); return(true); }
// Token: 0x0600064C RID: 1612 RVA: 0x000355D8 File Offset: 0x000337D8 public void ShowText(TextViewer.Style style, string topic, string text, bool autoHide) { if (Player.m_localPlayer == null) { return; } topic = Localization.instance.Localize(topic); text = Localization.instance.Localize(text); if (style == TextViewer.Style.Rune) { this.m_topic.text = topic; this.m_text.text = text; this.m_runeText.text = text; this.m_animator.SetBool(TextViewer.m_visibleID, true); } else if (style == TextViewer.Style.Intro) { this.m_introTopic.text = topic; this.m_introText.text = text; this.m_animatorIntro.SetTrigger("play"); ZLog.Log("Show intro " + Time.frameCount); } else if (style == TextViewer.Style.Raven) { this.m_ravenTopic.text = topic; this.m_ravenText.text = text; this.m_animatorRaven.SetBool(TextViewer.m_visibleID, true); } this.m_autoHide = autoHide; this.m_openPlayerPos = Player.m_localPlayer.transform.position; this.m_showTime = 0f; ZLog.Log("Show text " + topic + ":" + text); }
// Token: 0x06000F27 RID: 3879 RVA: 0x0006C3A0 File Offset: 0x0006A5A0 private bool OnAddOre(Switch sw, Humanoid user, ItemDrop.ItemData item) { if (item == null) { item = this.FindCookableItem(user.GetInventory()); if (item == null) { user.Message(MessageHud.MessageType.Center, "$msg_noprocessableitems", 0, null); return(false); } } if (!this.IsItemAllowed(item.m_dropPrefab.name)) { user.Message(MessageHud.MessageType.Center, "$msg_wontwork", 0, null); return(false); } ZLog.Log("trying to add " + item.m_shared.m_name); if (this.GetQueueSize() >= this.m_maxOre) { user.Message(MessageHud.MessageType.Center, "$msg_itsfull", 0, null); return(false); } user.Message(MessageHud.MessageType.Center, "$msg_added " + item.m_shared.m_name, 0, null); user.GetInventory().RemoveItem(item, 1); this.m_nview.InvokeRPC("AddOre", new object[] { item.m_dropPrefab.name }); return(true); }
private static void AddItemFromNearbyChests(Fermenter __instance) { if (!Configuration.Current.Fermenter.autoFuel || __instance.GetStatus() != Fermenter.Status.Empty || !__instance.m_nview.IsOwner()) { return; } Stopwatch delta = GameObjectAssistant.GetStopwatch(__instance.gameObject); if (!delta.IsRunning || delta.ElapsedMilliseconds > 1000) { List <Container> nearbyChests = InventoryAssistant.GetNearbyChests(__instance.gameObject, Configuration.Current.Fermenter.autoRange, !Configuration.Current.Fermenter.ignorePrivateAreaCheck); foreach (Container c in nearbyChests) { ItemDrop.ItemData item = __instance.FindCookableItem(c.GetInventory()); if (item != null) { if (InventoryAssistant.RemoveItemFromChest(c, item) == 0) { continue; } __instance.m_nview.InvokeRPC("AddItem", new object[] { item.m_dropPrefab.name }); ZLog.Log("Added " + item.m_shared.m_name + " to " + __instance.m_name); break; } } delta.Restart(); } }
static bool Save(ref Inventory __instance, ref ZPackage pkg) { pkg.Write(10000); pkg.Write(__instance.m_inventory.Count); foreach (ItemDrop.ItemData item in __instance.m_inventory) { if (item.m_dropPrefab == null) { ZLog.Log("Item missing prefab " + item.m_shared.m_name); pkg.Write(""); } else { pkg.Write(item.m_dropPrefab.name); } pkg.Write(item.m_stack); pkg.Write(item.m_durability); pkg.Write(item.m_gridPos); pkg.Write(item.m_equiped); pkg.Write(item.m_quality); pkg.Write(item.m_variant); pkg.Write(item.m_crafterID); pkg.Write(item.m_crafterName); if (item is TyrData) { var tyrData = (TyrData)item; tyrData.Save(pkg); } } return(false); }
IEnumerator LoadInspector(string scene, string flag, LoadSceneMode mode, bool autoAct) { ZLog.Log("SceneController...load scene!!!!from = " + currentScene + " to " + scene + " and flag = " + flag); if (currentScene == scene) { yield break; } ShowLoading = true; RenderSettings.skybox = null; yield return(new WaitForEndOfFrame()); asyncOperation = SceneManager.LoadSceneAsync(scene, mode); asyncOperation.allowSceneActivation = false; if (autoAct) { while (!asyncOperation.isDone) { if (asyncOperation.progress > 0.899f) { asyncOperation.allowSceneActivation = true; } yield return(null); } } else { yield return(asyncOperation); } ShowLoading = false; }
// Token: 0x0600108D RID: 4237 RVA: 0x00075570 File Offset: 0x00073770 private void Load() { if (this.m_nview == null) { return; } DateTime now = DateTime.Now; ZLog.Log("Loading dungeon"); ZDO zdo = this.m_nview.GetZDO(); int @int = zdo.GetInt("rooms", 0); for (int i = 0; i < @int; i++) { string text = "room" + i.ToString(); int int2 = zdo.GetInt(text, 0); Vector3 vec = zdo.GetVec3(text + "_pos", Vector3.zero); Quaternion quaternion = zdo.GetQuaternion(text + "_rot", Quaternion.identity); DungeonDB.RoomData room = DungeonDB.instance.GetRoom(int2); if (room == null) { ZLog.LogWarning("Missing room:" + int2); } else { this.PlaceRoom(room, vec, quaternion, null, ZoneSystem.SpawnMode.Client); } } ZLog.Log("Dungeon loaded " + @int); ZLog.Log("Dungeon load time " + (DateTime.Now - now).TotalMilliseconds + " ms"); }
// Token: 0x06001090 RID: 4240 RVA: 0x0007579C File Offset: 0x0007399C private void PlaceDoors(ZoneSystem.SpawnMode mode) { int num = 0; foreach (RoomConnection roomConnection in DungeonGenerator.m_doorConnections) { if (UnityEngine.Random.value <= this.m_doorChance) { DungeonGenerator.DoorDef doorDef = this.FindDoorType(roomConnection.m_type); if (doorDef == null) { ZLog.Log("No door type for connection:" + roomConnection.m_type); } else { GameObject obj = UnityEngine.Object.Instantiate <GameObject>(doorDef.m_prefab, roomConnection.transform.position, roomConnection.transform.rotation); if (mode == ZoneSystem.SpawnMode.Ghost) { UnityEngine.Object.Destroy(obj); } num++; } } } ZLog.Log("placed " + num + " doors"); }
// Token: 0x06000B77 RID: 2935 RVA: 0x00052888 File Offset: 0x00050A88 public static List <PlayerProfile> GetAllPlayerProfiles() { string[] array; try { array = Directory.GetFiles(Utils.GetSaveDataPath() + "/characters", "*.fch"); } catch { array = new string[0]; } List <PlayerProfile> list = new List <PlayerProfile>(); string[] array2 = array; for (int i = 0; i < array2.Length; i++) { string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(array2[i]); PlayerProfile playerProfile = new PlayerProfile(fileNameWithoutExtension); if (!playerProfile.Load()) { ZLog.Log("Failed to load " + fileNameWithoutExtension); } else { list.Add(playerProfile); } } return(list); }
// Token: 0x06000B64 RID: 2916 RVA: 0x0005260C File Offset: 0x0005080C private ZPackage LoadPlayerDataFromDisk() { string text = Utils.GetSaveDataPath() + "/characters/" + this.m_filename + ".fch"; FileStream fileStream; try { fileStream = File.OpenRead(text); } catch { ZLog.Log(" failed to load " + text); return(null); } byte[] data; try { BinaryReader binaryReader = new BinaryReader(fileStream); int count = binaryReader.ReadInt32(); data = binaryReader.ReadBytes(count); int count2 = binaryReader.ReadInt32(); binaryReader.ReadBytes(count2); } catch { ZLog.LogError(" error loading player.dat"); fileStream.Dispose(); return(null); } fileStream.Dispose(); return(new ZPackage(data)); }
private static void AddFuelFromNearbyChests(Fireplace __instance) { int toMaxFuel = (int)__instance.m_maxFuel - (int)Math.Ceiling(__instance.m_nview.GetZDO().GetFloat("fuel")); if (toMaxFuel > 0) { Stopwatch delta = GameObjectAssistant.GetStopwatch(__instance.gameObject); if (delta.IsRunning && delta.ElapsedMilliseconds < 1000) { return; } delta.Restart(); ItemDrop.ItemData fuelItemData = __instance.m_fuelItem.m_itemData; int addedFuel = InventoryAssistant.RemoveItemInAmountFromAllNearbyChests(__instance.gameObject, Helper.Clamp(Configuration.Current.FireSource.autoRange, 1, 50), fuelItemData, toMaxFuel, !Configuration.Current.FireSource.ignorePrivateAreaCheck); for (int i = 0; i < addedFuel; i++) { __instance.m_nview.InvokeRPC("AddFuel", new object[] { }); } if (addedFuel > 0) { ZLog.Log("Added " + addedFuel + " fuel(" + fuelItemData.m_shared.m_name + ") in " + __instance.m_name); } } }
// Token: 0x06000885 RID: 2181 RVA: 0x000417E8 File Offset: 0x0003F9E8 private void CreateDistantObjects(List <ZDO> objects, int maxCreatedPerFrame, ref int created) { if (created > maxCreatedPerFrame) { return; } int frameCount = Time.frameCount; foreach (ZDO zdo in objects) { if (zdo.m_tempCreateEarmark != frameCount) { if (this.CreateObject(zdo) != null) { created++; if (created > maxCreatedPerFrame) { break; } } else if (ZNet.instance.IsServer()) { zdo.SetOwner(ZDOMan.instance.GetMyID()); ZLog.Log(string.Concat(new object[] { "Destroyed invalid predab ZDO:", zdo.m_uid, " prefab hash:", zdo.GetPrefab() })); ZDOMan.instance.DestroyZDO(zdo); } } } }
private void SceneLoaded(Scene scene, LoadSceneMode mode) { ZLog.Log("SceneController...the scene had loaded that name = " + scene.name + ";mode = " + mode); currentScene = scene.name; AddOne(scene); NotifyManager.SendNotify(Enum.NotifyType.OnSceneLoaded, currentScene); }
// Token: 0x06000920 RID: 2336 RVA: 0x00043C04 File Offset: 0x00041E04 public bool Connect(string host, int port) { ZLog.Log(string.Concat(new object[] { "Connecting to ", host, " : ", port })); IPEndPoint endPoint = ZSocket.GetEndPoint(host, port); this.m_socket.BeginConnect(endPoint, null, null).AsyncWaitHandle.WaitOne(3000, true); if (!this.m_socket.Connected) { return(false); } try { this.m_endpoint = (this.m_socket.RemoteEndPoint as IPEndPoint); } catch { this.Close(); return(false); } this.BeginReceive(); ZLog.Log(" connected"); return(true); }
public static void SaveMapDataToDisk() { //TODO: Optimize / Improve on disk format for exploration data. (JSON?) if (ServerMapData == null) { return; } List <int> mapDataToDisk = new List <int>(); for (int y = 0; y < Minimap.instance.m_textureSize; ++y) { for (int x = 0; x < Minimap.instance.m_textureSize; ++x) { if (ServerMapData[y * Minimap.instance.m_textureSize + x]) { mapDataToDisk.Add(y * Minimap.instance.m_textureSize + x); } } } if (mapDataToDisk.Count > 0) { File.Delete(ValheimPlusPlugin.VPlusDataDirectoryPath + Path.DirectorySeparatorChar + ZNet.instance.GetWorldName() + "_mapSync.dat"); File.WriteAllText(ValheimPlusPlugin.VPlusDataDirectoryPath + Path.DirectorySeparatorChar + ZNet.instance.GetWorldName() + "_mapSync.dat", string.Join(",", mapDataToDisk)); ZLog.Log($"Saved {mapDataToDisk.Count} map points to disk."); } }
// Token: 0x06000F22 RID: 3874 RVA: 0x0006C154 File Offset: 0x0006A354 private void DropAllItems() { this.SpawnProcessed(); if (this.m_fuelItem != null) { float @float = this.m_nview.GetZDO().GetFloat("fuel", 0f); for (int i = 0; i < (int)@float; i++) { Vector3 position = base.transform.position + Vector3.up + UnityEngine.Random.insideUnitSphere * 0.3f; Quaternion rotation = Quaternion.Euler(0f, (float)UnityEngine.Random.Range(0, 360), 0f); UnityEngine.Object.Instantiate <GameObject>(this.m_fuelItem.gameObject, position, rotation); } } while (this.GetQueueSize() > 0) { string queuedOre = this.GetQueuedOre(); this.RemoveOneOre(); Smelter.ItemConversion itemConversion = this.GetItemConversion(queuedOre); if (itemConversion != null) { Vector3 position2 = base.transform.position + Vector3.up + UnityEngine.Random.insideUnitSphere * 0.3f; Quaternion rotation2 = Quaternion.Euler(0f, (float)UnityEngine.Random.Range(0, 360), 0f); UnityEngine.Object.Instantiate <GameObject>(itemConversion.m_from.gameObject, position2, rotation2); } else { ZLog.Log("Invalid ore in smelter " + queuedOre); } } }
// Token: 0x06000884 RID: 2180 RVA: 0x000416A4 File Offset: 0x0003F8A4 private void CreateObjectsSorted(List <ZDO> currentNearObjects, int maxCreatedPerFrame, ref int created) { this.m_tempCurrentObjects2.Clear(); int frameCount = Time.frameCount; foreach (ZDO zdo in currentNearObjects) { if (zdo.m_tempCreateEarmark != frameCount && (zdo.m_distant || ZoneSystem.instance.IsZoneLoaded(zdo.GetSector()))) { this.m_tempCurrentObjects2.Add(zdo); } } foreach (ZDO zdo2 in from item in this.m_tempCurrentObjects2 orderby item.m_type descending select item) { if (this.CreateObject(zdo2) != null) { created++; if (created > maxCreatedPerFrame) { break; } } else if (ZNet.instance.IsServer()) { zdo2.SetOwner(ZDOMan.instance.GetMyID()); ZLog.Log("Destroyed invalid predab ZDO:" + zdo2.m_uid); ZDOMan.instance.DestroyZDO(zdo2); } } }
private void UpdateAttach() { if (!this.m_nview.IsOwner()) { return; } this.CancelInvoke("UpdateAttach"); Player player = Player.m_localPlayer; if (equipmentSlotManager.hasQueuedItem() && player != null && (player.GetInventory().ContainsItem(equipmentSlotManager.queuedItem)) && this.CanAttach(equipmentSlotManager.queuedItem)) { // Users can queue one item at a time, but depending on its type is what slot it belongs to. If the slot is already filled it should // drop the item first. ItemDrop.ItemData itemData = equipmentSlotManager.queuedItem.Clone(); itemData.m_stack = 1; if (equipmentSlotManager.slots.ContainsKey(itemData.m_shared.m_itemType)) { EquippableSlot unfilledSlot = null; var slot = equipmentSlotManager.slots[itemData.m_shared.m_itemType]; if (slot.isFilled() || slot.exclusiveSlotFilled(equipmentSlotManager)) { foreach (var secondarySlot in slot.secondarySlots) { var fallbackSlot = equipmentSlotManager.slots[secondarySlot]; if (!fallbackSlot.isFilled() && !fallbackSlot.exclusiveSlotFilled(equipmentSlotManager)) { unfilledSlot = fallbackSlot; break; } } } else { unfilledSlot = slot; } if (unfilledSlot == null) { player.Message(MessageHud.MessageType.Center, "$ceko_piece_slot_filled", 0, null); } else { unfilledSlot.equip(itemData); player.UnequipItem(equipmentSlotManager.queuedItem, true); player.GetInventory().RemoveOneItem(equipmentSlotManager.queuedItem); this.m_nview.InvokeRPC(ZNetView.Everybody, "SetVisualItems"); this.m_effects.Create(this.GetAttach(equipmentSlotManager.queuedItem).transform.position, Quaternion.identity, null, 1f); } } else { ZLog.Log("Queued item didn't map to a slot."); } } equipmentSlotManager.queuedItem = null; }
// Token: 0x06000E26 RID: 3622 RVA: 0x0006500C File Offset: 0x0006320C private bool DamageArea(int hitAreaIndex, HitData hit) { ZLog.Log("hit mine rock " + hitAreaIndex); MineRock5.HitArea hitArea = this.GetHitArea(hitAreaIndex); if (hitArea == null) { ZLog.Log("Missing hit area " + hitAreaIndex); return(false); } this.LoadHealth(); if (hitArea.m_health <= 0f) { ZLog.Log("Already destroyed"); return(false); } HitData.DamageModifier type; hit.ApplyResistance(this.m_damageModifiers, out type); float totalDamage = hit.GetTotalDamage(); if (hit.m_toolTier < this.m_minToolTier) { DamageText.instance.ShowText(DamageText.TextType.TooHard, hit.m_point, 0f, false); return(false); } DamageText.instance.ShowText(type, hit.m_point, totalDamage, false); if (totalDamage <= 0f) { return(false); } hitArea.m_health -= totalDamage; this.SaveHealth(); this.m_hitEffect.Create(hit.m_point, Quaternion.identity, null, 1f); Player closestPlayer = Player.GetClosestPlayer(hit.m_point, 10f); if (closestPlayer) { closestPlayer.AddNoise(100f); } if (hitArea.m_health <= 0f) { this.m_nview.InvokeRPC(ZNetView.Everybody, "SetAreaHealth", new object[] { hitAreaIndex, hitArea.m_health }); this.m_destroyedEffect.Create(hit.m_point, Quaternion.identity, null, 1f); foreach (GameObject original in this.m_dropItems.GetDropList()) { Vector3 position = hit.m_point + UnityEngine.Random.insideUnitSphere * 0.3f; UnityEngine.Object.Instantiate <GameObject>(original, position, Quaternion.identity); } if (this.AllDestroyed()) { this.m_nview.Destroy(); } return(true); } return(false); }
// Token: 0x06000ED0 RID: 3792 RVA: 0x00069C40 File Offset: 0x00067E40 private void PrintStats() { if (this.m_players.Count == 0) { return; } ZLog.Log("Vel:" + this.m_body.velocity.magnitude.ToString("0.0")); }
private static void Postfix(ref ZNet __instance) { if (!ZNet.m_isServer) { ZLog.Log("-------------------- SENDING VPLUGCONFIGSYNC REQUEST"); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "VPlusConfigSync", new object[] { new ZPackage() }); } }
public void RemoveCertificate() { if (File.Exists(certificatePath)) { File.Delete(certificatePath); } ZLog.Log("RemoveCertificate...."); }
// Token: 0x0600097F RID: 2431 RVA: 0x00045AF0 File Offset: 0x00043CF0 public ZSteamSocket(CSteamID peerID) { ZSteamSocket.RegisterGlobalCallbacks(); this.m_peerID.SetSteamID(peerID); this.m_con = SteamNetworkingSockets.ConnectP2P(ref this.m_peerID, 0, 0, null); ZLog.Log("Connecting to " + this.m_peerID.GetSteamID().ToString()); ZSteamSocket.m_sockets.Add(this); }
public void Print() { for (int index = 0; index < this.m_inventory.Count; ++index) { ItemDrop.ItemData itemData = this.m_inventory[index]; ZLog.Log((object)(index.ToString() + ": " + itemData.m_shared.m_name + " " + (object)itemData.m_stack + " / " + (object)itemData.m_shared.m_maxStackSize)); } }
// Token: 0x06000878 RID: 2168 RVA: 0x00041314 File Offset: 0x0003F514 private void OnDestroy() { ZLog.Log("Net scene destroyed"); if (ZNetScene.m_instance == this) { ZNetScene.m_instance = null; } }
// Token: 0x06000C0A RID: 3082 RVA: 0x000559B8 File Offset: 0x00053BB8 public static World LoadWorld(string name) { FileStream fileStream = null; try { fileStream = File.OpenRead(World.GetMetaPath(name)); } catch { if (fileStream != null) { fileStream.Dispose(); } ZLog.Log(" failed to load " + name); return(new World(name, true, false)); } World result; try { BinaryReader binaryReader = new BinaryReader(fileStream); int count = binaryReader.ReadInt32(); ZPackage zpackage = new ZPackage(binaryReader.ReadBytes(count)); int num = zpackage.ReadInt(); if (!global::Version.IsWorldVersionCompatible(num)) { ZLog.Log("incompatible world version " + num); result = new World(name, false, true); } else { World world = new World(); world.m_name = zpackage.ReadString(); world.m_seedName = zpackage.ReadString(); world.m_seed = zpackage.ReadInt(); world.m_uid = zpackage.ReadLong(); if (num >= 26) { world.m_worldGenVersion = zpackage.ReadInt(); } result = world; } } catch { ZLog.LogWarning(" error loading world " + name); result = new World(name, true, false); } finally { if (fileStream != null) { fileStream.Dispose(); } } return(result); }
// Token: 0x060008C2 RID: 2242 RVA: 0x00042528 File Offset: 0x00040728 private bool GetNetworkTime(string ntpServer, out DateTime time) { byte[] array = new byte[48]; array[0] = 27; IPAddress[] addressList; try { addressList = Dns.GetHostEntry(ntpServer).AddressList; if (addressList.Length == 0) { ZLog.Log("Dns lookup failed"); time = DateTime.UtcNow; return(false); } } catch { ZLog.Log("Failed ntp dns lookup"); time = DateTime.UtcNow; return(false); } IPEndPoint remoteEP = new IPEndPoint(addressList[0], 123); Socket socket = null; try { socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); socket.ReceiveTimeout = 3000; socket.SendTimeout = 3000; socket.Connect(remoteEP); if (!socket.Connected) { ZLog.Log("Failed to connect to ntp"); time = DateTime.UtcNow; socket.Close(); return(false); } socket.Send(array); socket.Receive(array); socket.Shutdown(SocketShutdown.Both); socket.Close(); } catch { if (socket != null) { socket.Close(); } time = DateTime.UtcNow; return(false); } ulong num = (ulong)array[40] << 24 | (ulong)array[41] << 16 | (ulong)array[42] << 8 | (ulong)array[43]; ulong num2 = (ulong)array[44] << 24 | (ulong)array[45] << 16 | (ulong)array[46] << 8 | (ulong)array[47]; ulong num3 = num * 1000UL + num2 * 1000UL / 4294967296UL; time = new DateTime(1900, 1, 1).AddMilliseconds((double)num3); return(true); }