public byte[] Serialize() { List <byte> list = new List <byte>(); list.AddRange(ByteSerializer.SerializeString(this.username)); list.AddRange(ByteSerializer.SerializeVector3(this.position)); list.AddRange(ByteSerializer.SerializeInt((int)this.pointerMode)); list.AddRange(ByteSerializer.SerializeColor(this.pointerColor)); return(list.ToArray()); }
public byte[] Serialize() { List <byte> list = new List <byte>(); list.AddRange(ByteSerializer.SerializeInt((int)this.action)); list.AddRange(ByteSerializer.SerializeInt(this.userCap)); list.AddRange(ByteSerializer.SerializeBool(this.acceptingConnections)); list.AddRange(ByteSerializer.SerializeString(this.newPassword)); list.AddRange(ByteSerializer.SerializeInt((int)this.lobbyMode)); return(list.ToArray()); }
public byte[] Serialize() { List <byte> list = new List <byte>(); list.AddRange(ByteSerializer.SerializeInt((int)this.action)); list.AddRange(ByteSerializer.SerializeByteArray(this.content)); list.AddRange(ByteSerializer.SerializeString(this.username)); list.AddRange(ByteSerializer.SerializeString(this.metadata)); list.AddRange(ByteSerializer.SerializeBool(this.playSound)); return(list.ToArray()); }
public byte[] Serialize() { List <byte> list = new List <byte>(); list.AddRange(ByteSerializer.SerializeInt(this.userCount)); list.AddRange(ByteSerializer.SerializeInt(this.userCap)); list.AddRange(ByteSerializer.SerializeBool(this.acceptingConnections)); list.AddRange(ByteSerializer.SerializeInt((int)this.lobbyMode)); list.AddRange(ByteSerializer.SerializeBool(this.isFrozen)); list.AddRange(ByteSerializer.SerializeStrings(this.playerNames)); return(list.ToArray()); }
private static void patchSerializerTwo(SandboxLayoutData __instance, List <byte> bytes) { ptfInstance.ptfLogger.LogMessage($"Layout post version: {__instance.m_Version}"); // add number of mods stored //bytes.AddRange(ByteSerializer.SerializeInt(noncheatMods.Where(x => x.shouldSaveData).Count() + cheatMods.Where(x => x.shouldSaveData).Count())); // add mod data for each mod // make sure to be backwards compatible! List <string> modData = cheatMods.Where(x => x.isEnabled).Select(x => $"{x.Info.Metadata.Name}\u058D{x.Info.Metadata.Version}\u058D{x.getSettings()}").ToList(); modData.AddRange(noncheatMods.Where(x => x.shouldSaveData && x.isEnabled).Select(x => $"{x.Info.Metadata.Name}\u058D{x.Info.Metadata.Version}\u058D{x.getSettings()}").ToList()); string[] mods = modData.ToArray(); if (__instance.m_Version >= 0) { return; } bytes.AddRange(ByteSerializer.SerializeStrings(mods)); // add an int indicating the number of mods that will save binary data int modsSavingBinary = noncheatMods.Where(x => x.shouldSaveData).Count() + cheatMods.Where(x => x.shouldSaveData).Count(); bytes.AddRange(ByteSerializer.SerializeInt(modsSavingBinary)); foreach (var mod in noncheatMods) { if (mod.isEnabled && mod.shouldSaveData) { bytes.AddRange(ByteSerializer.SerializeString( $"{mod.Info.Metadata.Name}\u058D{mod.Info.Metadata.Version}" )); bytes.AddRange(ByteSerializer.SerializeByteArray( mod.saveData() )); } } foreach (var mod in cheatMods) { if (mod.isEnabled && mod.shouldSaveData) { bytes.AddRange(ByteSerializer.SerializeString( $"{mod.Info.Metadata.Name}\u058D{mod.Info.Metadata.Version}" )); bytes.AddRange(ByteSerializer.SerializeByteArray( mod.saveData() )); } } ptfInstance.ptfLogger.LogMessage($"Serialized {mods.Length.ToString()} Mod Names"); }
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}"); }