public void Deserialize(byte[] bytes, ref int offset) { this.username = ByteSerializer.DeserializeString(bytes, ref offset); this.position = ByteSerializer.DeserializeVector3(bytes, ref offset); this.pointerMode = (PointerMode)ByteSerializer.DeserializeInt(bytes, ref offset); this.pointerColor = ByteSerializer.DeserializeColor(bytes, ref offset); }
public void Deserialize(byte[] bytes, ref int offset) { this.action = (ConfigAction)ByteSerializer.DeserializeInt(bytes, ref offset); this.userCap = ByteSerializer.DeserializeInt(bytes, ref offset); this.acceptingConnections = ByteSerializer.DeserializeBool(bytes, ref offset); this.newPassword = ByteSerializer.DeserializeString(bytes, ref offset); this.lobbyMode = (LobbyMode)ByteSerializer.DeserializeInt(bytes, ref offset); }
public void Deserialize(byte[] bytes, ref int offset) { this.action = (actionType)ByteSerializer.DeserializeInt(bytes, ref offset); this.content = ByteSerializer.DeserializeByteArray(bytes, ref offset); this.username = ByteSerializer.DeserializeString(bytes, ref offset); this.metadata = ByteSerializer.DeserializeString(bytes, ref offset); this.playSound = ByteSerializer.DeserializeBool(bytes, ref offset); }
public void Deserialize(byte[] bytes, ref int offset) { this.userCount = ByteSerializer.DeserializeInt(bytes, ref offset); this.userCap = ByteSerializer.DeserializeInt(bytes, ref offset); this.acceptingConnections = ByteSerializer.DeserializeBool(bytes, ref offset); this.lobbyMode = (LobbyMode)ByteSerializer.DeserializeInt(bytes, ref offset); this.isFrozen = ByteSerializer.DeserializeBool(bytes, ref offset); this.playerNames = ByteSerializer.DeserializeStrings(bytes, ref offset); }
public static void patchDeserializerPrefix(SandboxLayoutData __instance, byte[] bytes, ref int offset, ref bool __state) { __state = false; var startOffset = offset; __instance.m_Version = ByteSerializer.DeserializeInt(bytes, ref offset); offset = startOffset; //ptfInstance.ptfLogger.LogMessage($"Layout version pre-modcheck: {__instance.m_Version}"); if (__instance.m_Version > 0) { return; } __instance.m_Version *= -1; __state = true; byte[] new_ver = ByteSerializer.SerializeInt(__instance.m_Version); for (int i = 0; i < new_ver.Length; i++) { bytes[i] = new_ver[i]; } //ptfInstance.ptfLogger.LogMessage($"Layout version post-modcheck: {__instance.m_Version}"); }
public static void patchDeserializerPostfix(SandboxLayoutData __instance, byte[] bytes, ref int offset, bool __state) { //ptfInstance.ptfLogger.LogMessage($"Layout version pre-load: {__instance.m_Version}"); if (!__state) { return; } string[] strings = ByteSerializer.DeserializeStrings(bytes, ref offset); ptfInstance.ptfLogger.LogInfo($"Layout created with mod{(strings.Length > 1 ? "s" : "")}: "); foreach (string str in strings) { string[] partsOfMod = str.Split('\u058D'); string name = partsOfMod.Length >= 1 ? partsOfMod[0] : null; string version = partsOfMod.Length >= 2 ? partsOfMod[1] : null; string settings = partsOfMod.Length >= 3 ? partsOfMod[2] : null; ptfInstance.ptfLogger.LogInfo($" -- {str.Replace("\u058D", " - v")}"); var currMod = cheatMods.Where(p => p.Info.Metadata.Name == name).FirstOrDefault(); if (currMod == null) { currMod = noncheatMods.Where(p => p.Info.Metadata.Name == name).FirstOrDefault(); } ptfInstance.checkMods(0, name, version, settings, currMod); } if (offset == bytes.Length) { return; } int extraSaveDataCount = ByteSerializer.DeserializeInt(bytes, ref offset); if (extraSaveDataCount == 0) { return; } ptfInstance.Logger.LogInfo($"Layout created with custom data from mods: "); for (int i = 0; i < extraSaveDataCount; i++) { string modIdentifier = ByteSerializer.DeserializeString(bytes, ref offset); byte[] customModSaveData = ByteSerializer.DeserializeByteArray(bytes, ref offset); string[] partsOfMod = modIdentifier.Split('\u058D'); string name = partsOfMod.Length >= 1 ? partsOfMod[0] : null; string version = partsOfMod.Length >= 2 ? partsOfMod[1] : null; ptfInstance.Logger.LogInfo($" -- {name} - v{version}"); var currMod = cheatMods.Where(p => p.Info.Metadata.Name == name).FirstOrDefault(); if (currMod == null) { currMod = noncheatMods.Where(p => p.Info.Metadata.Name == name).FirstOrDefault(); } if (currMod == null) { return; } if (currMod.Info.Metadata.Version.ToString() != version) { return; } currMod.loadData(customModSaveData); } }
public static SandboxLayoutData DeserializeLayoutBytes(byte[] bytes, ref int offset) { SandboxLayoutData layoutData = new SandboxLayoutData(); layoutData.m_Version = ByteSerializer.DeserializeInt(bytes, ref offset); if (layoutData.m_Version < 0) { layoutData.m_Version *= -1; } layoutData.m_ThemeStubKey = ByteSerializer.DeserializeString(bytes, ref offset); if (layoutData.m_Version >= 19) { int num1 = ByteSerializer.DeserializeInt(bytes, ref offset); for (int i = 0; i < num1; i++) { layoutData.m_Anchors.Add(new BridgeJointProxy(layoutData.m_Version, bytes, ref offset)); } } if (layoutData.m_Version >= 5) { int num2 = ByteSerializer.DeserializeInt(bytes, ref offset); for (int i = 0; i < num2; i++) { layoutData.m_HydraulicsPhases.Add(new HydraulicsPhaseProxy(bytes, ref offset)); } } if (layoutData.m_Version > 4) { layoutData.m_Bridge.DeserializeBinary(bytes, ref offset); goto LABEL; } int num3 = ByteSerializer.DeserializeInt(bytes, ref offset); for (int i = 0; i < num3; i++) { layoutData.m_BridgeJoints.Add(new BridgeJointProxy(1, bytes, ref offset)); } int num4 = ByteSerializer.DeserializeInt(bytes, ref offset); for (int i = 0; i < num4; i++) { layoutData.m_BridgeEdges.Add(new BridgeEdgeProxy(bytes, ref offset)); } int num5 = ByteSerializer.DeserializeInt(bytes, ref offset); for (int i = 0; i < num5; i++) { layoutData.m_Pistons.Add(new PistonProxy(layoutData.m_Version, bytes, ref offset)); } LABEL: if (layoutData.m_Version >= 7) { int num6 = ByteSerializer.DeserializeInt(bytes, ref offset); for (int i = 0; i < num6; i++) { layoutData.m_ZedAxisVehicles.Add(new ZedAxisVehicleProxy(layoutData.m_Version, bytes, ref offset)); } } int num7 = ByteSerializer.DeserializeInt(bytes, ref offset); for (int i = 0; i < num7; i++) { layoutData.m_Vehicles.Add(new VehicleProxy(bytes, ref offset)); } int num8 = ByteSerializer.DeserializeInt(bytes, ref offset); for (int i = 0; i < num8; i++) { layoutData.m_VehicleStopTriggers.Add(new VehicleStopTriggerProxy(bytes, ref offset)); } if (layoutData.m_Version < 20) { int num9 = ByteSerializer.DeserializeInt(bytes, ref offset); for (int i = 0; i < num9; i++) { ByteSerializer.DeserializeVector2(bytes, ref offset); ByteSerializer.DeserializeString(bytes, ref offset); ByteSerializer.DeserializeBool(bytes, ref offset); } } int num10 = ByteSerializer.DeserializeInt(bytes, ref offset); for (int i = 0; i < num10; i++) { layoutData.m_EventTimelines.Add(new EventTimelineProxy(layoutData.m_Version, bytes, ref offset)); } int num11 = ByteSerializer.DeserializeInt(bytes, ref offset); for (int i = 0; i < num11; i++) { layoutData.m_Checkpoints.Add(new CheckpointProxy(bytes, ref offset)); } int num12 = ByteSerializer.DeserializeInt(bytes, ref offset); for (int i = 0; i < num12; i++) { layoutData.m_TerrainStretches.Add(new TerrainIslandProxy(layoutData.m_Version, bytes, ref offset)); } int num13 = ByteSerializer.DeserializeInt(bytes, ref offset); for (int i = 0; i < num13; i++) { layoutData.m_Platforms.Add(new PlatformProxy(layoutData.m_Version, bytes, ref offset)); } int num14 = ByteSerializer.DeserializeInt(bytes, ref offset); for (int i = 0; i < num14; i++) { layoutData.m_Ramps.Add(new RampProxy(layoutData.m_Version, bytes, ref offset)); } if (layoutData.m_Version < 5) { int num15 = ByteSerializer.DeserializeInt(bytes, ref offset); for (int i = 0; i < num15; i++) { layoutData.m_HydraulicsPhases.Add(new HydraulicsPhaseProxy(bytes, ref offset)); } } int num16 = ByteSerializer.DeserializeInt(bytes, ref offset); for (int i = 0; i < num16; i++) { layoutData.m_VehicleRestartPhases.Add(new VehicleRestartPhaseProxy(bytes, ref offset)); } int num17 = ByteSerializer.DeserializeInt(bytes, ref offset); for (int i = 0; i < num17; i++) { layoutData.m_FlyingObjects.Add(new FlyingObjectProxy(bytes, ref offset)); } int num18 = ByteSerializer.DeserializeInt(bytes, ref offset); for (int i = 0; i < num18; i++) { layoutData.m_Rocks.Add(new RockProxy(bytes, ref offset)); } int num19 = ByteSerializer.DeserializeInt(bytes, ref offset); for (int i = 0; i < num19; i++) { layoutData.m_WaterBlocks.Add(new WaterBlockProxy(layoutData.m_Version, bytes, ref offset)); } if (layoutData.m_Version < 5) { int num20 = ByteSerializer.DeserializeInt(bytes, ref offset); for (int i = 0; i < num20; i++) { ByteSerializer.DeserializeString(bytes, ref offset); int num21 = ByteSerializer.DeserializeInt(bytes, ref offset); for (int j = 0; j < num21; j++) { ByteSerializer.DeserializeString(bytes, ref offset); } } } layoutData.m_Budget.DeserializeBinary(bytes, ref offset); layoutData.m_Settings.DeserializeBinary(bytes, ref offset); if (layoutData.m_Version >= 9) { int num22 = ByteSerializer.DeserializeInt(bytes, ref offset); for (int i = 0; i < num22; i++) { layoutData.m_CustomShapes.Add(new CustomShapeProxy(layoutData.m_Version, bytes, ref offset)); } } if (layoutData.m_Version >= 15) { layoutData.m_Workshop.DeserializeBinary(layoutData.m_Version, bytes, ref offset); } if (layoutData.m_Version >= 17) { int num23 = ByteSerializer.DeserializeInt(bytes, ref offset); for (int i = 0; i < num23; i++) { layoutData.m_SupportPillars.Add(new SupportPillarProxy(bytes, ref offset)); } } if (layoutData.m_Version >= 18) { int num24 = ByteSerializer.DeserializeInt(bytes, ref offset); for (int i = 0; i < num24; i++) { layoutData.m_Pillars.Add(new PillarProxy(bytes, ref offset)); } } return(layoutData); }