diff --git a/src/Impostor.Api/Innersloth/Customization/HatType.cs b/src/Impostor.Api/Innersloth/Customization/HatType.cs
index 5e0a3efe0..c4af44c98 100644
--- a/src/Impostor.Api/Innersloth/Customization/HatType.cs
+++ b/src/Impostor.Api/Innersloth/Customization/HatType.cs
@@ -1,6 +1,6 @@
namespace Impostor.Api.Innersloth.Customization
{
- public enum HatType
+ public enum HatType : uint
{
NoHat = 0,
Astronaut = 1,
@@ -45,8 +45,8 @@ public enum HatType
ThirdEyeHat = 40,
ToiletPaperHat = 41,
Toppat = 42,
- Fedora = 43,
- Goggles2 = 44,
+ BlackFedora = 43,
+ SkiGoggles = 44,
Headphones = 45,
MaskHat = 46,
PaperMask = 47,
@@ -58,7 +58,7 @@ public enum HatType
Cheese = 53,
Cherry = 54,
Egg = 55,
- Fedora2 = 56,
+ GreenFedora = 56,
Flamingo = 57,
FlowerPin = 58,
Helmet = 59,
@@ -95,6 +95,7 @@ public enum HatType
MiniCrewmate = 90,
NinjaMask = 91,
RamHorns = 92,
- Snowman2 = 93,
+ SnowCrewmate = 93,
+ GeoffHat = 94,
}
}
diff --git a/src/Impostor.Api/Innersloth/Customization/PetType.cs b/src/Impostor.Api/Innersloth/Customization/PetType.cs
index 456e3274f..f8753f273 100644
--- a/src/Impostor.Api/Innersloth/Customization/PetType.cs
+++ b/src/Impostor.Api/Innersloth/Customization/PetType.cs
@@ -1,6 +1,6 @@
namespace Impostor.Api.Innersloth.Customization
{
- public enum PetType
+ public enum PetType : uint
{
NoPet = 0,
Alien = 1,
diff --git a/src/Impostor.Api/Innersloth/Customization/SkinType.cs b/src/Impostor.Api/Innersloth/Customization/SkinType.cs
index 35da31209..9f0aa2297 100644
--- a/src/Impostor.Api/Innersloth/Customization/SkinType.cs
+++ b/src/Impostor.Api/Innersloth/Customization/SkinType.cs
@@ -1,6 +1,6 @@
namespace Impostor.Api.Innersloth.Customization
{
- public enum SkinType : byte
+ public enum SkinType : uint
{
None = 0,
Astro = 1,
diff --git a/src/Impostor.Api/Net/Inner/Objects/IInnerPlayerControl.cs b/src/Impostor.Api/Net/Inner/Objects/IInnerPlayerControl.cs
index 8185e5859..c0ecf855d 100644
--- a/src/Impostor.Api/Net/Inner/Objects/IInnerPlayerControl.cs
+++ b/src/Impostor.Api/Net/Inner/Objects/IInnerPlayerControl.cs
@@ -41,48 +41,32 @@ public interface IInnerPlayerControl : IInnerNetObject
/// Sets the color of the current .
/// Visible to all players.
///
- /// A color for the player.
- /// Task that must be awaited.
- ValueTask SetColorAsync(byte colorId);
-
/// A color for the player.
- ///
+ /// Task that must be awaited.
ValueTask SetColorAsync(ColorType colorType);
///
/// Sets the hat of the current .
/// Visible to all players.
///
- /// An hat for the player.
- /// Task that must be awaited.
- ValueTask SetHatAsync(uint hatId);
-
/// An hat for the player.
- ///
+ /// Task that must be awaited.
ValueTask SetHatAsync(HatType hatType);
///
/// Sets the pet of the current .
/// Visible to all players.
///
- /// A pet for the player.
- /// Task that must be awaited.
- ValueTask SetPetAsync(uint petId);
-
/// A pet for the player.
- ///
+ /// Task that must be awaited.
ValueTask SetPetAsync(PetType petType);
///
/// Sets the skin of the current .
/// Visible to all players.
///
- /// A skin for the player.
- /// Task that must be awaited.
- ValueTask SetSkinAsync(uint skinId);
-
/// A skin for the player.
- ///
+ /// Task that must be awaited.
ValueTask SetSkinAsync(SkinType skinType);
///
diff --git a/src/Impostor.Api/Net/Inner/Objects/IInnerPlayerInfo.cs b/src/Impostor.Api/Net/Inner/Objects/IInnerPlayerInfo.cs
index 6cb33024a..310755ed2 100644
--- a/src/Impostor.Api/Net/Inner/Objects/IInnerPlayerInfo.cs
+++ b/src/Impostor.Api/Net/Inner/Objects/IInnerPlayerInfo.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using Impostor.Api.Innersloth;
+using Impostor.Api.Innersloth.Customization;
namespace Impostor.Api.Net.Inner.Objects
{
@@ -14,22 +15,22 @@ public interface IInnerPlayerInfo
///
/// Gets the color of the player.
///
- byte ColorId { get; }
+ ColorType Color { get; }
///
/// Gets the hat of the player.
///
- uint HatId { get; }
+ HatType Hat { get; }
///
/// Gets the pet of the player.
///
- uint PetId { get; }
+ PetType Pet { get; }
///
/// Gets the skin of the player.
///
- uint SkinId { get; }
+ SkinType Skin { get; }
///
/// Gets a value indicating whether the player is an impostor.
diff --git a/src/Impostor.Server/Net/Inner/Objects/InnerPlayerControl.Api.cs b/src/Impostor.Server/Net/Inner/Objects/InnerPlayerControl.Api.cs
index 23202e070..07c21267c 100644
--- a/src/Impostor.Server/Net/Inner/Objects/InnerPlayerControl.Api.cs
+++ b/src/Impostor.Server/Net/Inner/Objects/InnerPlayerControl.Api.cs
@@ -26,62 +26,42 @@ public async ValueTask SetNameAsync(string name)
await _game.FinishRpcAsync(writer);
}
- public async ValueTask SetColorAsync(byte colorId)
+ public async ValueTask SetColorAsync(ColorType color)
{
- PlayerInfo.ColorId = colorId;
+ PlayerInfo.Color = color;
using var writer = _game.StartRpc(NetId, RpcCalls.SetColor);
- writer.Write(colorId);
+ Rpc08SetColor.Serialize(writer, color);
await _game.FinishRpcAsync(writer);
}
- public ValueTask SetColorAsync(ColorType colorType)
+ public async ValueTask SetHatAsync(HatType hat)
{
- return SetColorAsync((byte)colorType);
- }
-
- public async ValueTask SetHatAsync(uint hatId)
- {
- PlayerInfo.HatId = hatId;
+ PlayerInfo.Hat = hat;
using var writer = _game.StartRpc(NetId, RpcCalls.SetHat);
- writer.WritePacked(hatId);
+ Rpc09SetHat.Serialize(writer, hat);
await _game.FinishRpcAsync(writer);
}
- public ValueTask SetHatAsync(HatType hatType)
- {
- return SetHatAsync((uint)hatType);
- }
-
- public async ValueTask SetPetAsync(uint petId)
+ public async ValueTask SetPetAsync(PetType pet)
{
- PlayerInfo.PetId = petId;
+ PlayerInfo.Pet = pet;
using var writer = _game.StartRpc(NetId, RpcCalls.SetPet);
- writer.WritePacked(petId);
+ Rpc17SetPet.Serialize(writer, pet);
await _game.FinishRpcAsync(writer);
}
- public ValueTask SetPetAsync(PetType petType)
+ public async ValueTask SetSkinAsync(SkinType skin)
{
- return SetPetAsync((uint)petType);
- }
-
- public async ValueTask SetSkinAsync(uint skinId)
- {
- PlayerInfo.SkinId = skinId;
+ PlayerInfo.Skin = skin;
using var writer = _game.StartRpc(NetId, RpcCalls.SetSkin);
- writer.WritePacked(skinId);
+ Rpc10SetSkin.Serialize(writer, skin);
await _game.FinishRpcAsync(writer);
}
- public ValueTask SetSkinAsync(SkinType skinType)
- {
- return SetSkinAsync((uint)skinType);
- }
-
public async ValueTask SendChatAsync(string text)
{
using var writer = _game.StartRpc(NetId, RpcCalls.SendChat);
diff --git a/src/Impostor.Server/Net/Inner/Objects/InnerPlayerControl.cs b/src/Impostor.Server/Net/Inner/Objects/InnerPlayerControl.cs
index 36097d300..b755a6651 100644
--- a/src/Impostor.Server/Net/Inner/Objects/InnerPlayerControl.cs
+++ b/src/Impostor.Server/Net/Inner/Objects/InnerPlayerControl.cs
@@ -388,9 +388,11 @@ private async ValueTask HandleSetName(ClientPlayer sender, string name)
return true;
}
+ private static readonly byte ColorsCount = (byte)Enum.GetValues().Length;
+
private async ValueTask HandleCheckColor(ClientPlayer sender, ColorType color)
{
- if (color > (ColorType)Enum.GetValues().Length)
+ if ((byte)color > ColorsCount)
{
if (await sender.Client.ReportCheatAsync(RpcCalls.CheckColor, "Client sent invalid color"))
{
@@ -415,7 +417,7 @@ private async ValueTask HandleSetColor(ClientPlayer sender, ColorType colo
if (sender.IsOwner(this))
{
- if (_game.Players.Any(x => x.Character != null && x.Character != this && x.Character.PlayerInfo.ColorId == (byte)color))
+ if (_game.Players.Any(x => x.Character != null && x.Character != this && x.Character.PlayerInfo.Color == color))
{
if (await sender.Client.ReportCheatAsync(RpcCalls.SetColor, "Client sent a color that is already used"))
{
@@ -433,9 +435,9 @@ private async ValueTask HandleSetColor(ClientPlayer sender, ColorType colo
var expected = RequestedColorId.Dequeue();
- while (_game.Players.Any(x => x.Character != null && x.Character != this && (ColorType)x.Character.PlayerInfo.ColorId == expected))
+ while (_game.Players.Any(x => x.Character != null && x.Character != this && x.Character.PlayerInfo.Color == expected))
{
- expected = (ColorType)(((byte)expected + 1) % Enum.GetValues().Length);
+ expected = (ColorType)(((byte)expected + 1) % ColorsCount);
}
if (color != expected)
@@ -446,7 +448,7 @@ private async ValueTask HandleSetColor(ClientPlayer sender, ColorType colo
}
}
- PlayerInfo.ColorId = (byte)color;
+ PlayerInfo.Color = color;
return true;
}
@@ -458,7 +460,7 @@ private async ValueTask HandleSetHat(ClientPlayer sender, HatType hat)
return false;
}
- PlayerInfo.HatId = (byte)hat;
+ PlayerInfo.Hat = hat;
return true;
}
@@ -470,7 +472,7 @@ private async ValueTask HandleSetSkin(ClientPlayer sender, SkinType skin)
return false;
}
- PlayerInfo.SkinId = (byte)skin;
+ PlayerInfo.Skin = skin;
return true;
}
@@ -533,7 +535,7 @@ private async ValueTask HandleSetPet(ClientPlayer sender, PetType pet)
return false;
}
- PlayerInfo.PetId = (byte)pet;
+ PlayerInfo.Pet = pet;
return true;
}
diff --git a/src/Impostor.Server/Net/Inner/Objects/InnerPlayerInfo.cs b/src/Impostor.Server/Net/Inner/Objects/InnerPlayerInfo.cs
index f248994ee..410b4af61 100644
--- a/src/Impostor.Server/Net/Inner/Objects/InnerPlayerInfo.cs
+++ b/src/Impostor.Server/Net/Inner/Objects/InnerPlayerInfo.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using Impostor.Api.Games;
using Impostor.Api.Innersloth;
+using Impostor.Api.Innersloth.Customization;
using Impostor.Api.Net.Messages;
namespace Impostor.Server.Net.Inner.Objects
@@ -19,13 +20,13 @@ public InnerPlayerInfo(byte playerId)
public string PlayerName { get; internal set; }
- public byte ColorId { get; internal set; }
+ public ColorType Color { get; internal set; }
- public uint HatId { get; internal set; }
+ public HatType Hat { get; internal set; }
- public uint PetId { get; internal set; }
+ public PetType Pet { get; internal set; }
- public uint SkinId { get; internal set; }
+ public SkinType Skin { get; internal set; }
public bool Disconnected { get; internal set; }
@@ -57,10 +58,10 @@ public void Serialize(IMessageWriter writer)
public void Deserialize(IMessageReader reader)
{
PlayerName = reader.ReadString();
- ColorId = reader.ReadByte();
- HatId = reader.ReadPackedUInt32();
- PetId = reader.ReadPackedUInt32();
- SkinId = reader.ReadPackedUInt32();
+ Color = (ColorType)reader.ReadByte();
+ Hat = (HatType)reader.ReadPackedUInt32();
+ Pet = (PetType)reader.ReadPackedUInt32();
+ Skin = (SkinType)reader.ReadPackedUInt32();
var flag = reader.ReadByte();
Disconnected = (flag & 1) > 0;
IsImpostor = (flag & 2) > 0;