public Ping(Player player, PingType pingType, bool notify) { PlayerUUID = PingsPlayer.GetUUIDFromPlayer(player); PingType = pingType; DecayTimer = DecayDuration = 60 * ServerConfig.Instance.PingDuration; //TODO config Notify = notify; TileSize = new Point16(1, 1); Text = string.Empty; }
public static void CalculateUUIDForLocalPlayer(bool shortHash = true) { PingsPlayer pingsPlayer = Main.LocalPlayer.GetModPlayer <PingsPlayer>(); if (pingsPlayer.UUID == string.Empty) { int hash = Math.Abs(Main.ActivePlayerFileData.Path.GetHashCode() ^ Main.ActivePlayerFileData.IsCloudSave.GetHashCode()); string uuid = Main.clientUUID + "_" + hash; int n = 4; if (shortHash && uuid.Length > n * 2) { var firstN = new string(uuid.Take(n).ToArray()); var lastN = new string(uuid.Reverse().Take(n).Reverse().ToArray()); uuid = string.Concat(firstN, lastN); } pingsPlayer.UUID = uuid; } }
private void PlayerFileData_SetAsActive(On.Terraria.IO.PlayerFileData.orig_SetAsActive orig, Terraria.IO.PlayerFileData self) { orig(self); PingsPlayer.CalculateUUIDForLocalPlayer(); }
public Ping(string uuid, PingType pingType, bool notify) : this(PingsPlayer.GetPlayerFromUUID(uuid), pingType, notify) { //This gets called on netreceive //Joining client actually receives pings before he receives info from other players about their UUIDs //Bandaid fix is simply requesting world info again once the player actually fully gets ingame }