Files
Impostor/src/Impostor.Server/Extensions/IGameOptionsExtensions.cs
T
miniduikbootandNiko233 28e933092a Stop hardcoding the GameOptions in GameListingV2
To prevent needing to pull in Impostor.Hazel, use an extension method
instead.

Thanks Niko for researching this part

Co-Authored-By: Niko233 <139348239+NikoCat233@users.noreply.github.com>
2025-03-30 20:35:03 +02:00

25 lines
693 B
C#

using System;
using Impostor.Api.Innersloth.GameOptions;
using Impostor.Hazel;
namespace Impostor.Server.Extensions;
public static class IGameOptionsExtensions
{
public static byte[] ToBytes(this IGameOptions gameOptions)
{
using var writer = MessageWriter.Get(MessageType.Unreliable);
writer.Write(gameOptions.Version);
writer.StartMessage(0);
writer.Write((byte)gameOptions.GameMode);
gameOptions.Serialize(writer);
writer.EndMessage();
return writer.ToByteArray(false);
}
public static string ToBase64String(this IGameOptions gameOptions)
{
return Convert.ToBase64String(gameOptions.ToBytes());
}
}