public static void SetMapData(ZPackage mapData) { ServerPins.Clear(); var version = mapData.ReadInt(); var mapSize = mapData.ReadInt(); var explored = new bool[mapSize * mapSize]; for (var i = 0; i < mapSize * mapSize; i++) { explored[i] = mapData.ReadBool(); } var pinCount = mapData.ReadInt(); for (var i = 0; i < pinCount; i++) { var pin = new PinData { Name = mapData.ReadString(), Pos = mapData.ReadVector3(), Type = (Minimap.PinType)mapData.ReadInt(), Checked = mapData.ReadBool() }; ServerPins.Add(pin); } Explored = explored; }
// Token: 0x0600072F RID: 1839 RVA: 0x0003A2D0 File Offset: 0x000384D0 private void RPC_ServerList(ZRpc rpc, ZPackage pkg) { this.m_haveServerlist = true; this.m_serverListRevision++; pkg.ReadInt(); int num = pkg.ReadInt(); this.m_servers.Clear(); for (int i = 0; i < num; i++) { ServerData serverData = new ServerData(); serverData.m_name = pkg.ReadString(); serverData.m_host = pkg.ReadString(); serverData.m_port = pkg.ReadInt(); serverData.m_password = pkg.ReadBool(); serverData.m_upnp = pkg.ReadBool(); pkg.ReadLong(); serverData.m_version = pkg.ReadString(); serverData.m_players = pkg.ReadInt(); if (this.m_nameFilter.Length <= 0 || serverData.m_name.Contains(this.m_nameFilter)) { this.m_servers.Add(serverData); } } if (this.m_onServerList != null) { this.m_onServerList(this.m_servers); } }
// Token: 0x06000DBC RID: 3516 RVA: 0x00062418 File Offset: 0x00060618 public void Deserialize(ref ZPackage pkg) { this.m_damage.m_damage = pkg.ReadSingle(); this.m_damage.m_blunt = pkg.ReadSingle(); this.m_damage.m_slash = pkg.ReadSingle(); this.m_damage.m_pierce = pkg.ReadSingle(); this.m_damage.m_chop = pkg.ReadSingle(); this.m_damage.m_pickaxe = pkg.ReadSingle(); this.m_damage.m_fire = pkg.ReadSingle(); this.m_damage.m_frost = pkg.ReadSingle(); this.m_damage.m_lightning = pkg.ReadSingle(); this.m_damage.m_poison = pkg.ReadSingle(); this.m_damage.m_spirit = pkg.ReadSingle(); this.m_toolTier = pkg.ReadInt(); this.m_pushForce = pkg.ReadSingle(); this.m_backstabBonus = pkg.ReadSingle(); this.m_staggerMultiplier = pkg.ReadSingle(); this.m_dodgeable = pkg.ReadBool(); this.m_blockable = pkg.ReadBool(); this.m_point = pkg.ReadVector3(); this.m_dir = pkg.ReadVector3(); this.m_statusEffect = pkg.ReadString(); this.m_attacker = pkg.ReadZDOID(); this.m_skill = (Skills.SkillType)pkg.ReadInt(); }
public static void Deserialize(ZPackage package) { ZoneT.Clear(); int tnum = package.ReadInt(); for (int i = 0; i < tnum; i++) { ZoneT.Add(new ZoneTypes { Name = package.ReadString(), PVP = package.ReadBool(), PVPEnforce = package.ReadBool(), ShowPosition = package.ReadBool(), PositionEnforce = package.ReadBool(), Admins = package.ReadString(), Configurations = package.ReadString() }); } Zones.Clear(); int num = package.ReadInt(); for (int i = 0; i < num; i++) { Zones.Add(new Zone { ID = package.ReadInt(), Name = package.ReadString(), Type = package.ReadString(), Priority = package.ReadInt(), Shape = package.ReadString(), Position = new Vector2(package.ReadSingle(), package.ReadSingle()), Radius = package.ReadSingle(), }); } }
public static WorldPlayer Load(ZPackage pkg) { var worldPlayer = new WorldPlayer(); int num = pkg.ReadInt(); if (!ValheimVersion.IsPlayerVersionCompatible(num)) { return(null); } if (num >= 28) { worldPlayer.PlayerStats_kills = pkg.ReadInt(); worldPlayer.PlayerStats_deaths = pkg.ReadInt(); worldPlayer.PlayerStats_crafts = pkg.ReadInt(); worldPlayer.PlayerStats_builds = pkg.ReadInt(); } worldPlayer.WorldPlayerData.Clear(); int num2 = pkg.ReadInt(); for (int i = 0; i < num2; i++) { long key = pkg.ReadLong(); var worldPlayerData = new WorldPlayerData(); worldPlayerData.m_haveCustomSpawnPoint = pkg.ReadBool(); worldPlayerData.m_spawnPoint = pkg.ReadVector3(); worldPlayerData.m_haveLogoutPoint = pkg.ReadBool(); worldPlayerData.m_logoutPoint = pkg.ReadVector3(); if (num >= 30) { worldPlayerData.m_haveDeathPoint = pkg.ReadBool(); worldPlayerData.m_deathPoint = pkg.ReadVector3(); } worldPlayerData.m_homePoint = pkg.ReadVector3(); if (num >= 29 && pkg.ReadBool()) { worldPlayerData.m_mapData = pkg.ReadByteArray(); } worldPlayer.WorldPlayerData.Add(key, worldPlayerData); } worldPlayer.PlayerName = pkg.ReadString(); worldPlayer.PlayerId = pkg.ReadLong(); worldPlayer.StartSeed = pkg.ReadString(); if (pkg.ReadBool()) { var byteArray = pkg.ReadByteArray(); var playerPkg = new ZPackage(byteArray); worldPlayer.Player = PlayerReaderWriter.Load(playerPkg); } else { worldPlayer.Player = null; } return(worldPlayer); }
private bool LoadPlayerFromDisk() { try { ZPackage zpackage = this.LoadPlayerDataFromDisk(); if (zpackage == null) { ZLog.LogWarning((object)"No player data"); return(false); } int version = zpackage.ReadInt(); if (!Version.IsPlayerVersionCompatible(version)) { ZLog.Log((object)"Player data is not compatible, ignoring"); return(false); } if (version >= 28) { this.m_playerStats.m_kills = zpackage.ReadInt(); this.m_playerStats.m_deaths = zpackage.ReadInt(); this.m_playerStats.m_crafts = zpackage.ReadInt(); this.m_playerStats.m_builds = zpackage.ReadInt(); } this.m_worldData.Clear(); int num = zpackage.ReadInt(); for (int index = 0; index < num; ++index) { long key = zpackage.ReadLong(); PlayerProfile.WorldPlayerData worldPlayerData = new PlayerProfile.WorldPlayerData(); worldPlayerData.m_haveCustomSpawnPoint = zpackage.ReadBool(); worldPlayerData.m_spawnPoint = zpackage.ReadVector3(); worldPlayerData.m_haveLogoutPoint = zpackage.ReadBool(); worldPlayerData.m_logoutPoint = zpackage.ReadVector3(); if (version >= 30) { worldPlayerData.m_haveDeathPoint = zpackage.ReadBool(); worldPlayerData.m_deathPoint = zpackage.ReadVector3(); } worldPlayerData.m_homePoint = zpackage.ReadVector3(); if (version >= 29 && zpackage.ReadBool()) { worldPlayerData.m_mapData = zpackage.ReadByteArray(); } this.m_worldData.Add(key, worldPlayerData); } this.m_playerName = zpackage.ReadString(); this.m_playerID = zpackage.ReadLong(); this.m_startSeed = zpackage.ReadString(); this.m_playerData = !zpackage.ReadBool() ? (byte[])null : zpackage.ReadByteArray(); } catch (Exception ex) { ZLog.LogWarning((object)("Exception while loading player profile:" + this.m_filename + " , " + ex.ToString())); } return(true); }
public bool CreateMergedWorldWithPins(out string error) { try { error = string.Empty; foreach (var pp in _profiles) { ZPackage zPackage = new ZPackage(pp.m_worldData[_worldId].m_mapData); _mapData.m_mapVersion = zPackage.ReadInt(); int textureSize = zPackage.ReadInt(); if (_mapData.m_textureSize != textureSize) { return(false); } for (int i = 0; i < (_mapData.m_textureSize * _mapData.m_textureSize); i++) { _mapData.m_mergedWorld[i] = (byte)(_mapData.m_mergedWorld[i] | Convert.ToByte(zPackage.ReadBool())); } if (_mapData.m_mapVersion >= 2) { int pinCount = zPackage.ReadInt(); for (int j = 0; j < pinCount; j++) { string name = zPackage.ReadString(); Vector3 pos = zPackage.ReadVector3(); PinType type = (PinType)zPackage.ReadInt(); bool isChecked = _mapData.m_mapVersion >= 3 && zPackage.ReadBool(); _mapData.AddPin(name, pos, type, isChecked); _mapData.AddProfilePin(pp.GetPlayerId(), name, pos, type, isChecked); } } if (_mapData.m_mapVersion >= 4) { _mapData.m_isReferencePositionPublic = zPackage.ReadBool(); } } return(true); } catch (Exception ex) { error = ex.Message; return(false); } }
public static void OnServerCheckPin(ZRpc client, ZPackage data) { if (!Store.IsSharingPin()) { return; } data.SetPos(0); Utility.Log("Client checked pin by server"); var pin = ExplorationDatabase.UnpackPin(data); var state = data.ReadBool(); foreach (var clientPin in ExplorationDatabase.ClientPins.ToList()) { if (UtilityPin.ArePinsEqual(clientPin, pin)) { clientPin.Checked = state; var mapPin = UtilityPin.GetMapPin(clientPin); if (mapPin != null) { mapPin.m_checked = state; } } } }
// Token: 0x060004DD RID: 1245 RVA: 0x00028508 File Offset: 0x00026708 private void RPC_DamageText(long sender, ZPackage pkg) { Camera mainCamera = Utils.GetMainCamera(); if (!mainCamera) { return; } if (Hud.IsUserHidden()) { return; } DamageText.TextType type = (DamageText.TextType)pkg.ReadInt(); Vector3 vector = pkg.ReadVector3(); float dmg = pkg.ReadSingle(); bool flag = pkg.ReadBool(); float num = Vector3.Distance(mainCamera.transform.position, vector); if (num > this.m_maxTextDistance) { return; } bool mySelf = flag && sender == ZNet.instance.GetUID(); this.AddInworldText(type, vector, num, dmg, mySelf); }
private void syncPositionAndRotation(ZDO zdo, float dt) { if (zdo == null) { return; } var vr_data = zdo.GetByteArray("vr_data"); if (vr_data == null) { return; } ZPackage pkg = new ZPackage(vr_data); var currentDataRevision = zdo.m_dataRevision; if (currentDataRevision != lastDataRevision) { // New data revision since last sync so we reset our deltaT counter deltaTimeCounter = 0f; // Save the current data revision so we can detect the next new data package lastDataRevision = currentDataRevision; } deltaTimeCounter += dt; deltaTimeCounter = Mathf.Min(deltaTimeCounter, 2f); extractAndUpdate(pkg, ref camera, ref clientTempRelPosCamera, hasTempRelPos); extractAndUpdate(pkg, ref leftHand, ref clientTempRelPosLeft, hasTempRelPos); extractAndUpdate(pkg, ref rightHand, ref clientTempRelPosRight, hasTempRelPos); maybeAddVrik(); hasTempRelPos = true; readFingers(pkg); maybePullBow(pkg.ReadBool()); }
/// <summary> /// Sync Pin with clients via the server /// </summary> public static void RPC_VPlusMapPinSync(long sender, ZPackage mapPinPkg) { if (ZNet.m_isServer) //Server { if (sender == ZRoutedRpc.instance.GetServerPeerID()) { return; } if (mapPinPkg == null) { return; } foreach (ZNetPeer peer in ZRoutedRpc.instance.m_peers) { if (peer.m_uid != sender) { ZRoutedRpc.instance.InvokeRoutedRPC(peer.m_uid, "VPlusMapPinSync", new object[] { mapPinPkg }); } } ZLog.Log($"Sent map pin to all clients"); //VPlusAck.SendAck(sender); } else //Client { if (sender != ZRoutedRpc.instance.GetServerPeerID()) { return; //Only bother if it's from the server. } if (mapPinPkg == null) { ZLog.LogWarning("Warning: Got empty map pin package from server."); return; } long pinSender = mapPinPkg.ReadLong(); string senderName = mapPinPkg.ReadString(); if (senderName != Player.m_localPlayer.GetPlayerName() && pinSender != ZRoutedRpc.instance.m_id) { ZLog.Log("Checking sent pin"); Vector3 pinPos = mapPinPkg.ReadVector3(); int pinType = mapPinPkg.ReadInt(); string pinName = mapPinPkg.ReadString(); bool keepQuiet = mapPinPkg.ReadBool(); if (!Minimap.instance.HaveSimilarPin(pinPos, (Minimap.PinType)pinType, pinName, true)) { Minimap.PinData addedPin = Minimap.instance.AddPin(pinPos, (Minimap.PinType)pinType, pinName, true, false); if (!keepQuiet) { MessageHud.instance.ShowMessage(MessageHud.MessageType.Center, $"Received map pin {pinName} from {senderName}!", 0, Minimap.instance.GetSprite((Minimap.PinType)pinType)); } ZLog.Log($"I got pin named {pinName} from {senderName}!"); } } //Send Ack //VPlusAck.SendAck(sender); } }
public static BountyInfo FromPackage(ZPackage pkg) { var result = new BountyInfo(); var version = pkg.ReadInt(); result.Interval = pkg.ReadInt(); result.PlayerID = pkg.ReadLong(); result.Biome = (Heightmap.Biome)pkg.ReadInt(); result.State = (BountyState)pkg.ReadInt(); result.Target = BountyTargetInfo.FromPackage(pkg); result.TargetName = pkg.ReadString(); result.RewardIron = pkg.ReadInt(); result.RewardGold = pkg.ReadInt(); result.Position = SerializableVector3.FromPackage(pkg); result.MinimapCircleOffset = SerializableVector3.FromPackage(pkg); var addsCount = pkg.ReadInt(); result.Adds = new List <BountyTargetInfo>(); for (var index = 0; index < addsCount; index++) { result.Adds.Add(BountyTargetInfo.FromPackage(pkg)); } result.Slain = pkg.ReadBool(); return(result); }
// Extract the data from the zipped data public static void Deserialize(ZPackage data) { Client.EnforceZones = data.ReadBool(); Client.PVPEnforced = data.ReadBool(); Client.PVPMode = data.ReadBool(); Client.PositionEnforce = data.ReadBool(); Client.ShowPosition = data.ReadBool(); Client.Ward.Damage = data.ReadBool(); Client.Ward.Drop = data.ReadBool(); Client.Ward.Pickup = data.ReadBool(); Client.NoItemLoss = data.ReadBool(); Client.RespawnTimer = data.ReadSingle(); }
public static NoiseLayer Deserialize(ZPackage pkg) { // ReSharper disable once UseObjectOrCollectionInitializer var noiseLayer = new NoiseLayer(); noiseLayer.noiseSettings = NoiseSettings.Deserialize(pkg); if (pkg.ReadBool()) { noiseLayer.noiseWarpSettings = NoiseSettings.Deserialize(pkg); } if (pkg.ReadBool()) { noiseLayer.maskSettings = NoiseSettings.Deserialize(pkg); } if (pkg.ReadBool()) { noiseLayer.maskWarpSettings = NoiseSettings.Deserialize(pkg); } return(noiseLayer); }
public static PinData UnpackPin(ZPackage z) { var pin = new PinData { Name = z.ReadString(), Pos = z.ReadVector3(), Type = (Minimap.PinType)z.ReadInt(), Checked = z.ReadBool() }; return(pin); }
// Token: 0x0600090A RID: 2314 RVA: 0x000432B4 File Offset: 0x000414B4 private void ReceivePing(ZPackage package) { if (package.ReadBool()) { this.m_pkg.Clear(); this.m_pkg.Write(0); this.m_pkg.Write(false); this.SendPackage(this.m_pkg); return; } this.m_timeSinceLastPing = 0f; }
// Token: 0x060006B0 RID: 1712 RVA: 0x000377B4 File Offset: 0x000359B4 public static Inventory Load(ZPackage pkg) { var inventory = new Inventory(); int num = pkg.ReadInt(); int num2 = pkg.ReadInt(); inventory.m_inventory.Clear(); for (int i = 0; i < num2; i++) { string text = pkg.ReadString(); int stack = pkg.ReadInt(); float durability = pkg.ReadSingle(); Vector2i pos = pkg.ReadVector2i(); bool equiped = pkg.ReadBool(); int quality = 1; if (num >= 101) { quality = pkg.ReadInt(); } int variant = 0; if (num >= 102) { variant = pkg.ReadInt(); } long crafterID = 0L; string crafterName = ""; if (num >= 103) { crafterID = pkg.ReadLong(); crafterName = pkg.ReadString(); } if (text != "") { var item = new InventoryItem() { prefabName = text, m_stack = stack, m_durability = durability, m_gridPos = pos, m_equiped = equiped, m_quality = quality, m_variant = variant, m_crafterID = crafterID, m_crafterName = crafterName }; inventory.m_inventory.Add(item); } } return(inventory); }
public static void Deserialize(this PlayerProfile profile, ZPackage data) { Debug.Assert(data.ReadInt() <= Version.m_playerVersion); profile.m_playerStats.m_kills = data.ReadInt(); profile.m_playerStats.m_deaths = data.ReadInt(); profile.m_playerStats.m_crafts = data.ReadInt(); profile.m_playerStats.m_builds = data.ReadInt(); profile.m_worldData.Clear(); int num = data.ReadInt(); for (int i = 0; i < num; i++) { long key = data.ReadLong(); PlayerProfile.WorldPlayerData worldPlayerData = (PlayerProfile.WorldPlayerData)Activator.CreateInstance(typeof(PlayerProfile.WorldPlayerData), true); worldPlayerData.m_haveCustomSpawnPoint = data.ReadBool(); worldPlayerData.m_spawnPoint = data.ReadVector3(); worldPlayerData.m_haveLogoutPoint = data.ReadBool(); worldPlayerData.m_logoutPoint = data.ReadVector3(); worldPlayerData.m_haveDeathPoint = data.ReadBool(); worldPlayerData.m_deathPoint = data.ReadVector3(); worldPlayerData.m_homePoint = data.ReadVector3(); if (data.ReadBool()) { worldPlayerData.m_mapData = data.ReadByteArray(); } profile.m_worldData.Add(key, worldPlayerData); } profile.m_playerName = data.ReadString(); profile.m_playerID = data.ReadLong(); if (profile.m_playerID == 0L) { profile.m_playerID = Utils.GenerateUID(); } profile.m_startSeed = data.ReadString(); if (data.ReadBool()) { profile.m_playerData = data.ReadByteArray(); } }
public static object ReadVariable(this ZPackage zp, Type t) { if (t == typeof(int)) { return(zp.ReadInt()); } if (t == typeof(uint)) { return(zp.ReadUInt()); } if (t == typeof(bool)) { return(zp.ReadBool()); } if (t == typeof(char)) { return(zp.ReadChar()); } if (t == typeof(sbyte)) { return(zp.ReadSByte()); } if (t == typeof(long)) { return(zp.ReadLong()); } if (t == typeof(ulong)) { return(zp.ReadULong()); } if (t == typeof(float)) { return(zp.ReadSingle()); } if (t == typeof(double)) { return(zp.ReadDouble()); } if (t == typeof(string)) { return(zp.ReadString()); } return(null); }
public static NoiseSettings Deserialize(ZPackage pkg) { float?ReadOptionalSingle() { float v = pkg.ReadSingle(); return(float.IsNegativeInfinity(v) ? (float?)null : v); } // Don't use object initializer, although it executes in lexical order, it isn't explicit in the spec // ReSharper disable once UseObjectOrCollectionInitializer var settings = new NoiseSettings(); settings.NoiseType = (FastNoiseLite.NoiseType)pkg.ReadInt(); settings.Frequency = pkg.ReadSingle(); settings.FractalType = (FastNoiseLite.FractalType)pkg.ReadInt(); settings.FractalOctaves = pkg.ReadInt(); settings.FractalLacunarity = pkg.ReadSingle(); settings.FractalGain = pkg.ReadSingle(); settings.FractalWeightedStrength = pkg.ReadSingle(); settings.FractalPingPongStrength = pkg.ReadSingle(); settings.CellularDistanceFunction = (FastNoiseLite.CellularDistanceFunction)pkg.ReadInt(); settings.CellularReturnType = (FastNoiseLite.CellularReturnType)pkg.ReadInt(); settings.CellularJitter = pkg.ReadSingle(); settings.DomainWarpType = (FastNoiseLite.DomainWarpType)pkg.ReadInt(); settings.DomainWarpAmp = pkg.ReadSingle(); settings.Invert = pkg.ReadBool(); settings.SmoothThresholdStart = ReadOptionalSingle(); settings.SmoothThresholdEnd = ReadOptionalSingle(); settings.Threshold = ReadOptionalSingle(); settings.RangeStart = ReadOptionalSingle(); settings.RangeEnd = ReadOptionalSingle(); settings.Opacity = ReadOptionalSingle(); settings.BlendMode = (BlendOperations.BlendModeType)pkg.ReadInt(); return(settings); }
private IEnumerator AdminRPC_OnClientReceive(long sender, ZPackage package) { bool isAdmin = package.ReadBool(); Logger.LogInfo($"Received admin status from server: {(isAdmin ? "Admin" : "No Admin")}"); Instance.PlayerIsAdmin = isAdmin; InvokeOnAdminStatusChanged(); // If player is admin, unlock the configuration values if (isAdmin) { UnlockConfigurationEntries(); } else { LockConfigurationEntries(); } yield break; }
public static List <PinData> UnpackPins(ZPackage z) { var pins = new List <PinData>(); var pinCount = z.ReadInt(); for (var i = 0; i < pinCount; i++) { var pin = new PinData { Name = z.ReadString(), Pos = z.ReadVector3(), Type = (Minimap.PinType)z.ReadInt(), Checked = z.ReadBool() }; pins.Add(pin); } return(pins); }
public static void OnClientCheckPin(ZRpc client, ZPackage data) { if (!Store.IsSharingPin()) { return; } data.SetPos(0); Utility.Log("Server checked pin by client"); var pin = ExplorationDatabase.UnpackPin(data); var state = data.ReadBool(); ExplorationDatabase.SetPinState(pin, state); var znet = Traverse.Create(typeof(ZNet)).Field("m_instance").GetValue() as ZNet; var mPeers = Traverse.Create((znet)).Field("m_peers").GetValue() as List <ZNetPeer>; foreach (var peer in mPeers) { if (peer.IsReady()) { if (peer.m_rpc == client) { continue; } var z = ExplorationDatabase.PackPin(pin, true); z.Write(state); peer.m_rpc.Invoke("OnServerCheckPin", (object)z); } } if (client != null) { var z = ExplorationDatabase.PackPin(pin, true); z.Write(state); OnServerCheckPin(null, z); } }
// Token: 0x060006B8 RID: 1720 RVA: 0x00037B04 File Offset: 0x00035D04 public void Load(ZPackage pkg) { int num = pkg.ReadInt(); int num2 = pkg.ReadInt(); this.m_inventory.Clear(); for (int i = 0; i < num2; i++) { string text = pkg.ReadString(); int stack = pkg.ReadInt(); float durability = pkg.ReadSingle(); Vector2i pos = pkg.ReadVector2i(); bool equiped = pkg.ReadBool(); int quality = 1; if (num >= 101) { quality = pkg.ReadInt(); } int variant = 0; if (num >= 102) { variant = pkg.ReadInt(); } long crafterID = 0L; string crafterName = ""; if (num >= 103) { crafterID = pkg.ReadLong(); crafterName = pkg.ReadString(); } if (text != "") { this.AddItem(text, stack, durability, pos, equiped, quality, variant, crafterID, crafterName); } } this.Changed(); }
public static void RPC_RequestSetVisible(long sender, ZPackage pkg) { ZNetPeer peer = ZNet.instance.GetPeer(sender); // Get the Peer from the sender, to later check the SteamID against our Adminlist. if (peer != null) { // Confirm the peer exists string peerSteamID = ((ZSteamSocket)peer.m_socket).GetPeerID().m_SteamID.ToString(); // Get the SteamID from peer. if ( ZNet.instance.m_adminList != null && ZNet.instance.m_adminList.Contains(peerSteamID) ) { // Check that the SteamID is in our Admin List. // set server tod string name = pkg.ReadString(); bool vis = pkg.ReadBool(); if (!vis && !GamanMaker.invisible_players.Contains(name)) { GamanMaker.invisible_players.Add(name); } else if (vis && GamanMaker.invisible_players.Contains(name)) { GamanMaker.invisible_players.Remove(name); } pkg.SetPos(0); ZRoutedRpc.instance.InvokeRoutedRPC(0L, "EventSetVisible", new object[] { pkg }); } } else { ZPackage newPkg = new ZPackage(); // Create a new ZPackage. newPkg.Write("You aren't an Admin!"); // Tell them what's going on. ZRoutedRpc.instance.InvokeRoutedRPC(sender, "BadRequestMsg", new object[] { newPkg }); // Send the error message. } }
// Token: 0x06000918 RID: 2328 RVA: 0x0004377C File Offset: 0x0004197C public static void Deserialize(ParameterInfo[] paramInfo, ZPackage pkg, ref List <object> parameters) { for (int i = 1; i < paramInfo.Length; i++) { ParameterInfo parameterInfo = paramInfo[i]; if (parameterInfo.ParameterType == typeof(int)) { parameters.Add(pkg.ReadInt()); } else if (parameterInfo.ParameterType == typeof(uint)) { parameters.Add(pkg.ReadUInt()); } else if (parameterInfo.ParameterType == typeof(long)) { parameters.Add(pkg.ReadLong()); } else if (parameterInfo.ParameterType == typeof(float)) { parameters.Add(pkg.ReadSingle()); } else if (parameterInfo.ParameterType == typeof(double)) { parameters.Add(pkg.ReadDouble()); } else if (parameterInfo.ParameterType == typeof(bool)) { parameters.Add(pkg.ReadBool()); } else if (parameterInfo.ParameterType == typeof(string)) { parameters.Add(pkg.ReadString()); } else if (parameterInfo.ParameterType == typeof(ZPackage)) { parameters.Add(pkg.ReadPackage()); } else if (parameterInfo.ParameterType == typeof(List <string>)) { int num = pkg.ReadInt(); List <string> list = new List <string>(num); for (int j = 0; j < num; j++) { list.Add(pkg.ReadString()); } parameters.Add(list); } else if (parameterInfo.ParameterType == typeof(Vector3)) { Vector3 vector = new Vector3(pkg.ReadSingle(), pkg.ReadSingle(), pkg.ReadSingle()); parameters.Add(vector); } else if (parameterInfo.ParameterType == typeof(Quaternion)) { Quaternion quaternion = new Quaternion(pkg.ReadSingle(), pkg.ReadSingle(), pkg.ReadSingle(), pkg.ReadSingle()); parameters.Add(quaternion); } else if (parameterInfo.ParameterType == typeof(ZDOID)) { parameters.Add(pkg.ReadZDOID()); } else if (parameterInfo.ParameterType == typeof(HitData)) { HitData hitData = new HitData(); hitData.Deserialize(ref pkg); parameters.Add(hitData); } } }
public bool LoadPlayerFromDisk(out string error) { error = string.Empty; ZPackage zPackage = LoadPlayerDataFromDisk(); //backup DirectoryInfo dir = Directory.CreateDirectory("backup"); File.WriteAllBytes($"{dir.FullName}/{m_filename}", zPackage.GetArray()); if (zPackage == null) { error = "No player data"; return(false); } m_version = zPackage.ReadInt(); if (!VersionInfo.IsPlayerVersionCompatible(m_version)) { error = "Player data is not compatible, ignoring"; return(false); } if (m_version >= 28) { m_playerStats.m_kills = zPackage.ReadInt(); m_playerStats.m_deaths = zPackage.ReadInt(); m_playerStats.m_crafts = zPackage.ReadInt(); m_playerStats.m_builds = zPackage.ReadInt(); } int num2 = zPackage.ReadInt(); for (int i = 0; i < num2; i++) { long key = zPackage.ReadLong(); WorldPlayerData worldPlayerData = new WorldPlayerData(); worldPlayerData.m_haveCustomSpawnPoint = zPackage.ReadBool(); worldPlayerData.m_spawnPoint = zPackage.ReadVector3(); worldPlayerData.m_haveLogoutPoint = zPackage.ReadBool(); worldPlayerData.m_logoutPoint = zPackage.ReadVector3(); if (m_version >= 30) { worldPlayerData.m_haveDeathPoint = zPackage.ReadBool(); worldPlayerData.m_deathPoint = zPackage.ReadVector3(); } worldPlayerData.m_homePoint = zPackage.ReadVector3(); if (m_version >= 29 && zPackage.ReadBool()) { worldPlayerData.m_mapData = zPackage.ReadByteArray(); } m_worldData.Add(key, worldPlayerData); } m_playerName = zPackage.ReadString(); m_playerID = zPackage.ReadLong(); m_startSeed = zPackage.ReadString(); m_playerData = null; if (zPackage.ReadBool()) { m_playerData = zPackage.ReadByteArray(); } return(true); }
// Token: 0x06000793 RID: 1939 RVA: 0x0003BE94 File Offset: 0x0003A094 public void Load(ZPackage pkg, int version) { this.m_ownerRevision = pkg.ReadUInt(); this.m_dataRevision = pkg.ReadUInt(); this.m_persistent = pkg.ReadBool(); this.m_owner = pkg.ReadLong(); this.m_timeCreated = pkg.ReadLong(); this.m_pgwVersion = pkg.ReadInt(); if (version >= 16 && version < 24) { pkg.ReadInt(); } if (version >= 23) { this.m_type = (ZDO.ObjectType)pkg.ReadSByte(); } if (version >= 22) { this.m_distant = pkg.ReadBool(); } if (version < 13) { pkg.ReadChar(); pkg.ReadChar(); } if (version >= 17) { this.m_prefab = pkg.ReadInt(); } this.m_sector = pkg.ReadVector2i(); this.m_position = pkg.ReadVector3(); this.m_rotation = pkg.ReadQuaternion(); int num = (int)pkg.ReadChar(); if (num > 0) { this.InitFloats(); for (int i = 0; i < num; i++) { int key = pkg.ReadInt(); this.m_floats[key] = pkg.ReadSingle(); } } else { this.ReleaseFloats(); } int num2 = (int)pkg.ReadChar(); if (num2 > 0) { this.InitVec3(); for (int j = 0; j < num2; j++) { int key2 = pkg.ReadInt(); this.m_vec3[key2] = pkg.ReadVector3(); } } else { this.ReleaseVec3(); } int num3 = (int)pkg.ReadChar(); if (num3 > 0) { this.InitQuats(); for (int k = 0; k < num3; k++) { int key3 = pkg.ReadInt(); this.m_quats[key3] = pkg.ReadQuaternion(); } } else { this.ReleaseQuats(); } int num4 = (int)pkg.ReadChar(); if (num4 > 0) { this.InitInts(); for (int l = 0; l < num4; l++) { int key4 = pkg.ReadInt(); this.m_ints[key4] = pkg.ReadInt(); } } else { this.ReleaseInts(); } int num5 = (int)pkg.ReadChar(); if (num5 > 0) { this.InitLongs(); for (int m = 0; m < num5; m++) { int key5 = pkg.ReadInt(); this.m_longs[key5] = pkg.ReadLong(); } } else { this.ReleaseLongs(); } int num6 = (int)pkg.ReadChar(); if (num6 > 0) { this.InitStrings(); for (int n = 0; n < num6; n++) { int key6 = pkg.ReadInt(); this.m_strings[key6] = pkg.ReadString(); } } else { this.ReleaseStrings(); } if (version < 17) { this.m_prefab = this.GetInt("prefab", 0); } }
// Token: 0x06000791 RID: 1937 RVA: 0x0003B918 File Offset: 0x00039B18 public void Deserialize(ZPackage pkg) { this.m_persistent = pkg.ReadBool(); this.m_distant = pkg.ReadBool(); this.m_timeCreated = pkg.ReadLong(); this.m_pgwVersion = pkg.ReadInt(); this.m_type = (ZDO.ObjectType)pkg.ReadSByte(); this.m_prefab = pkg.ReadInt(); this.m_rotation = pkg.ReadQuaternion(); int num = pkg.ReadInt(); if ((num & 1) != 0) { this.InitFloats(); int num2 = (int)pkg.ReadByte(); for (int i = 0; i < num2; i++) { int key = pkg.ReadInt(); this.m_floats[key] = pkg.ReadSingle(); } } else { this.ReleaseFloats(); } if ((num & 2) != 0) { this.InitVec3(); int num3 = (int)pkg.ReadByte(); for (int j = 0; j < num3; j++) { int key2 = pkg.ReadInt(); this.m_vec3[key2] = pkg.ReadVector3(); } } else { this.ReleaseVec3(); } if ((num & 4) != 0) { this.InitQuats(); int num4 = (int)pkg.ReadByte(); for (int k = 0; k < num4; k++) { int key3 = pkg.ReadInt(); this.m_quats[key3] = pkg.ReadQuaternion(); } } else { this.ReleaseQuats(); } if ((num & 8) != 0) { this.InitInts(); int num5 = (int)pkg.ReadByte(); for (int l = 0; l < num5; l++) { int key4 = pkg.ReadInt(); this.m_ints[key4] = pkg.ReadInt(); } } else { this.ReleaseInts(); } if ((num & 64) != 0) { this.InitLongs(); int num6 = (int)pkg.ReadByte(); for (int m = 0; m < num6; m++) { int key5 = pkg.ReadInt(); this.m_longs[key5] = pkg.ReadLong(); } } else { this.ReleaseLongs(); } if ((num & 16) != 0) { this.InitStrings(); int num7 = (int)pkg.ReadByte(); for (int n = 0; n < num7; n++) { int key6 = pkg.ReadInt(); this.m_strings[key6] = pkg.ReadString(); } return; } this.ReleaseStrings(); }
// Token: 0x060001C5 RID: 453 RVA: 0x0000F2F0 File Offset: 0x0000D4F0 public static Player Load(ZPackage pkg) { var player = new Player(); int num = pkg.ReadInt(); if (num >= 7) { player.MaxHealth = pkg.ReadSingle(); } player.Health = pkg.ReadSingle(); if (num >= 10) { player.MaxStamina = pkg.ReadSingle(); } if (num >= 8) { player.FirstSpawn = pkg.ReadBool(); } if (num >= 20) { player.TimeSinceDeath = pkg.ReadSingle(); } if (num >= 23) { player.GuardianPower = pkg.ReadString(); } if (num >= 24) { player.GuardianPowerCooldown = pkg.ReadSingle(); } if (num == 2) { pkg.ReadZDOID(); } player.Inventory = InventoryReaderWriter.Load(pkg); int num3 = pkg.ReadInt(); for (int i = 0; i < num3; i++) { string item = pkg.ReadString(); player.m_knownRecipes.Add(item); } if (num < 15) { int num4 = pkg.ReadInt(); for (int j = 0; j < num4; j++) { pkg.ReadString(); } } else { int num5 = pkg.ReadInt(); for (int k = 0; k < num5; k++) { string key = pkg.ReadString(); int value = pkg.ReadInt(); player.m_knownStations.Add(key, value); } } int num6 = pkg.ReadInt(); for (int l = 0; l < num6; l++) { string item2 = pkg.ReadString(); player.m_knownMaterial.Add(item2); } if (num < 19 || num >= 21) { int num7 = pkg.ReadInt(); for (int m = 0; m < num7; m++) { string item3 = pkg.ReadString(); player.m_shownTutorials.Add(item3); } } if (num >= 6) { int num8 = pkg.ReadInt(); for (int n = 0; n < num8; n++) { string item4 = pkg.ReadString(); player.m_uniques.Add(item4); } } if (num >= 9) { int num9 = pkg.ReadInt(); for (int num10 = 0; num10 < num9; num10++) { string item5 = pkg.ReadString(); player.m_trophies.Add(item5); } } if (num >= 18) { int num11 = pkg.ReadInt(); for (int num12 = 0; num12 < num11; num12++) { Biome item6 = (Biome)pkg.ReadInt(); player.m_knownBiome.Add(item6); } } if (num >= 22) { int num13 = pkg.ReadInt(); for (int num14 = 0; num14 < num13; num14++) { string key2 = pkg.ReadString(); string value2 = pkg.ReadString(); player.m_knownTexts.Add(key2, value2); } } if (num >= 4) { string beard = pkg.ReadString(); string hair = pkg.ReadString(); player.Beard = beard; player.Hair = hair; } if (num >= 5) { Vector3 skinColor = pkg.ReadVector3(); Vector3 hairColor = pkg.ReadVector3(); player.SkinColor = skinColor; player.HairColor = hairColor; } if (num >= 11) { int playerModel = pkg.ReadInt(); player.PlayerModel = playerModel; } if (num >= 12) { player.m_foods.Clear(); int num15 = pkg.ReadInt(); for (int num16 = 0; num16 < num15; num16++) { if (num >= 14) { var food = new Food(); food.m_name = pkg.ReadString(); food.m_health = pkg.ReadSingle(); if (num >= 16) { food.m_stamina = pkg.ReadSingle(); } player.m_foods.Add(food); } else { pkg.ReadString(); pkg.ReadSingle(); pkg.ReadSingle(); pkg.ReadSingle(); pkg.ReadSingle(); pkg.ReadSingle(); pkg.ReadSingle(); if (num >= 13) { pkg.ReadSingle(); } } } } if (num >= 17) { player.Skills = SkillsReaderWriter.Load(pkg); } return(player); }