예제 #1
0
        private void onROAInfoUpdate(Dictionary <byte, object> parameters)
        {
            try
            {
                ROAInfoEventArgs args = new ROAInfoEventArgs();

                // If there's no destination key, ignore
                if (!parameters.ContainsKey(6) || parameters[6].ToString() == "")
                {
                    return;
                }

                // If there was a recent map change, ignore event
                // Todo: Remove this when I can handle fragmented packets
                if (!Settings.RecentlyJoinedNewMap())
                {
                    return;
                }



                args.sourceCluster            = PlayerState.currentMapID;
                args.sourceClusterDisplayName = WorldMap.GetMapDisplayName(args.sourceCluster);
                args.sourceClusterType        = WorldMap.GetClusterByID(args.sourceCluster).Type;

                args.targetCluster            = parameters[6].ToString();
                args.targetClusterDisplayName = WorldMap.GetMapDisplayName(args.targetCluster);
                args.targetClusterType        = WorldMap.GetClusterByID(args.targetCluster).Type;

                // Param is not present when remaining capacity is 0
                try
                {
                    args.remainingCapacity = parameters[9].ToString();
                }
                catch
                {
                    args.remainingCapacity = "0";
                }

                args.maxCapacity = parameters[10].ToString();

                var coordinates = (Single[])parameters[1];
                args.posX = coordinates[0].ToString();
                args.posY = coordinates[1].ToString();

                // Tunnel close time using server time
                long tunnelCloseTime = long.Parse(parameters[8].ToString());

                // Tunnel time remaining in milliseconds
                long timeRemaining = tunnelCloseTime - PlayerState.currentTime;

                // Get the epoch time in seconds when gate closes
                long endTime = (DateTimeOffset.Now.ToUnixTimeMilliseconds() + timeRemaining) / 1000;

                args.endTime = endTime.ToString();


                // Hack solution to get clientID in the POST. Needs a refactor.
                args.clientID = Settings.clientID;

                PacketHandlerEvents.InvokeNewROAUpdateEvent(args);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                DumpParameters(parameters);
            }
        }