Exemplo n.º 1
0
        public static void Postfix(WaypointMapLayer __instance, byte[] data)
        {
            string currentHash = FloatyWaypointManagement.GetWaypointsHash();

            if (currentHash != null)
            {
                var    incomingWaypoints = SerializerUtil.Deserialize <List <Waypoint> >(data);
                string str = "";

                for (int i = 0; i < incomingWaypoints.Count; i++)
                {
                    str += incomingWaypoints[i].Title;
                    str += i;
                }

                string incomingHash = ExtraMath.Sha512Hash(str);

                if (currentHash == incomingHash)
                {
                    return;
                }
            }

            FloatyWaypointManagement.TriggerRepopulation();
        }
Exemplo n.º 2
0
        public static string GetWaypointsHash()
        {
            lock (WaypointElements)
            {
                if (WaypointElements != null && WaypointElements.Count > 0)
                {
                    string str = "";
                    var    wps = new HudElementWaypoint[WaypointElements.Count];
                    WaypointElements.CopyTo(wps, 0);
                    Array.Sort(wps, delegate(HudElementWaypoint a, HudElementWaypoint b) {
                        var c = (a?.waypoint?.Index ?? 0).CompareTo(b?.waypoint?.Index ?? 0);
                        return(c);
                    });

                    foreach (var wp in wps)
                    {
                        str += wp?.waypoint?.Title ?? "";
                        str += wp?.waypoint?.Index ?? 00;
                    }
                    return(ExtraMath.Sha512Hash(str));
                }
                else
                {
                    return(null);
                }
            }
        }