-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1206 from tukasa0001/develop-4.0.0
Develop 4.0.0
- Loading branch information
Showing
87 changed files
with
5,269 additions
and
3,521 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
bin/ | ||
obj/ | ||
bin/ | ||
FodyWeavers.xsd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> | ||
<Costura> | ||
<IncludeAssemblies> | ||
Csv | ||
</IncludeAssemblies> | ||
</Costura> | ||
</Weavers> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
using System; | ||
using System.IO; | ||
using System.Text.RegularExpressions; | ||
using static TownOfHost.Translator; | ||
namespace TownOfHost | ||
{ | ||
public static class BanManager | ||
{ | ||
private static readonly string DENY_NAME_LIST_PATH = @"./TOH_DATA/DenyName.txt"; | ||
private static readonly string BAN_LIST_PATH = @"./TOH_DATA/BanList.txt"; | ||
|
||
public static void Init() | ||
{ | ||
Directory.CreateDirectory("TOH_DATA"); | ||
if (!File.Exists(DENY_NAME_LIST_PATH)) File.Create(DENY_NAME_LIST_PATH).Close(); | ||
if (!File.Exists(BAN_LIST_PATH)) File.Create(BAN_LIST_PATH).Close(); | ||
} | ||
public static void AddBanPlayer(InnerNet.ClientData player) | ||
{ | ||
if (!AmongUsClient.Instance.AmHost) return; | ||
if (!CheckBanList(player)) | ||
{ | ||
File.AppendAllText(BAN_LIST_PATH, $"{player.FriendCode},{player.PlayerName}\n"); | ||
} | ||
} | ||
public static void CheckDenyNamePlayer(InnerNet.ClientData player) | ||
{ | ||
if (!AmongUsClient.Instance.AmHost) return; | ||
try | ||
{ | ||
Directory.CreateDirectory("TOH_DATA"); | ||
if (!File.Exists(DENY_NAME_LIST_PATH)) File.Create(DENY_NAME_LIST_PATH).Close(); | ||
using StreamReader sr = new(DENY_NAME_LIST_PATH); | ||
string line; | ||
while ((line = sr.ReadLine()) != null) | ||
{ | ||
if (line == "") continue; | ||
if (Regex.IsMatch(player.PlayerName, line)) | ||
{ | ||
AmongUsClient.Instance.KickPlayer(player.Id, false); | ||
Logger.SendInGame(string.Format(GetString("Message.KickedByDenyName"), player.PlayerName, line)); | ||
Logger.Info($"{player.PlayerName}は名前が「{line}」に一致したためキックされました。", "Kick"); | ||
return; | ||
} | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
Logger.Exception(ex, "CheckDenyNamePlayer"); | ||
} | ||
} | ||
public static void CheckBanPlayer(InnerNet.ClientData player) | ||
{ | ||
if (!AmongUsClient.Instance.AmHost) return; | ||
if (CheckBanList(player)) | ||
{ | ||
AmongUsClient.Instance.KickPlayer(player.Id, true); | ||
Logger.SendInGame(string.Format(GetString("Message.BanedByBanList"), player.PlayerName)); | ||
Logger.Info($"{player.PlayerName}は過去にBAN済みのためBANされました。", "BAN"); | ||
return; | ||
} | ||
} | ||
public static bool CheckBanList(InnerNet.ClientData player) | ||
{ | ||
try | ||
{ | ||
Directory.CreateDirectory("TOH_DATA"); | ||
if (!File.Exists(BAN_LIST_PATH)) File.Create(BAN_LIST_PATH).Close(); | ||
using StreamReader sr = new(BAN_LIST_PATH); | ||
string line; | ||
while ((line = sr.ReadLine()) != null) | ||
{ | ||
if (line == "") continue; | ||
if (player.FriendCode == line.Split(",")[0]) return true; | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
Logger.Exception(ex, "CheckBanList"); | ||
} | ||
return false; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
using System.Collections.Generic; | ||
namespace TownOfHost | ||
{ | ||
public static class Camouflage | ||
{ | ||
public static Dictionary<byte, (int, string, string, string, string)> PlayerSkins = new(); | ||
public static void RpcSetSkin(PlayerControl target, bool ForceRevert = false) | ||
{ | ||
if (!(AmongUsClient.Instance.AmHost && Options.CommsCamouflage.GetBool())) return; | ||
if (target == null) return; | ||
var id = target.PlayerId; | ||
|
||
int colorId = 15; //グレー | ||
string hatId = ""; | ||
string skinId = ""; | ||
string visorId = ""; | ||
string petId = ""; | ||
if (Utils.IsActive(SystemTypes.Comms)) | ||
{ | ||
if (Main.PlayerStates[id].IsDead) return; | ||
} | ||
if (!Utils.IsActive(SystemTypes.Comms) || ForceRevert) | ||
{ | ||
var GetValue = Main.CheckShapeshift.TryGetValue(id, out var shapeshifting); | ||
if (!GetValue && Main.CheckShapeshift.ContainsKey(id)) return; | ||
|
||
var outfit = target.CurrentOutfit; | ||
var value = PlayerSkins[id]; | ||
|
||
if ( | ||
outfit.ColorId == value.Item1 && | ||
outfit.HatId == value.Item2 && | ||
outfit.SkinId == value.Item3 && | ||
outfit.VisorId == value.Item4 && | ||
outfit.PetId == value.Item5 | ||
) return; //姿が変わっていないなら処理しない | ||
|
||
colorId = shapeshifting ? outfit.ColorId : value.Item1; | ||
hatId = shapeshifting ? outfit.HatId : value.Item2; | ||
skinId = shapeshifting ? outfit.SkinId : value.Item3; | ||
visorId = shapeshifting ? outfit.VisorId : value.Item4; | ||
petId = shapeshifting ? outfit.PetId : value.Item5; | ||
} | ||
|
||
var sender = CustomRpcSender.Create(name: $"Camouflage.RpcSetSkin({target.Data.PlayerName})"); | ||
|
||
target.SetColor(colorId); | ||
sender.AutoStartRpc(target.NetId, (byte)RpcCalls.SetColor) | ||
.Write(colorId) | ||
.EndRpc(); | ||
|
||
target.SetHat(hatId, colorId); | ||
sender.AutoStartRpc(target.NetId, (byte)RpcCalls.SetHatStr) | ||
.Write(hatId) | ||
.EndRpc(); | ||
|
||
target.SetSkin(skinId, colorId); | ||
sender.AutoStartRpc(target.NetId, (byte)RpcCalls.SetSkinStr) | ||
.Write(skinId) | ||
.EndRpc(); | ||
|
||
target.SetVisor(visorId, colorId); | ||
sender.AutoStartRpc(target.NetId, (byte)RpcCalls.SetVisorStr) | ||
.Write(visorId) | ||
.EndRpc(); | ||
|
||
target.SetPet(petId); | ||
sender.AutoStartRpc(target.NetId, (byte)RpcCalls.SetPetStr) | ||
.Write(petId) | ||
.EndRpc(); | ||
|
||
sender.SendMessage(); | ||
} | ||
} | ||
} |
Oops, something went wrong.