Esempio n. 1
0
        private void SendMapsToWorld(IEnumerable <long> maps, MapReplaceOption option, bool local, string uuid)
        {
            var worldids  = WorldSide.GetTakenIDs();
            var writemaps = maps.ToList();

            // check for  conflicts
            foreach (var map in maps)
            {
                bool conflicted = worldids.Contains(map);
                if (conflicted)
                {
                    if (option == MapReplaceOption.ChangeExisting)
                    {
                        WorldSide.ChangeMapID(map, GetSafeID());
                    }
                    else if (option == MapReplaceOption.Skip)
                    {
                        writemaps.Remove(map);
                    }
                }
            }
            var import = ImportSide.GetMaps().Copy();

            ImportSide.RemoveMaps(writemaps);
            WorldSide.AddMaps(writemaps.ToDictionary(x => x, x => import[x]));
            AddChests(writemaps, local, uuid);
        }
Esempio n. 2
0
        // returns number of conflicts, does nothing if there is at least one
        public int SendMapsToWorld(IEnumerable <MapIDControl> maps, MapReplaceOption option, string playerid = NOBODY_IDENTIFIER)
        {
            var writemaps   = maps.ToList();
            var conflictids = new List <long>();

            // check for  conflicts
            foreach (var map in maps)
            {
                if (map.Conflicted)
                {
                    conflictids.Add(map.ID);
                    if (option == MapReplaceOption.Skip)
                    {
                        writemaps.Remove(map);
                    }
                }
            }
            if (option == MapReplaceOption.Info)
            {
                return(conflictids.Count);
            }
            if (option == MapReplaceOption.ChangeExisting)
            {
                foreach (var conflict in conflictids)
                {
                    var currentholder = GetMapByID(conflict, MapStatus.Existing);
                    currentholder.SetID(GetSafeID());
                    writemaps.Add(currentholder);
                }
            }
            SelectedWorld.AddMaps(writemaps.ToDictionary(x => x.ID, x => x.Map));
            var ids = writemaps.Select(x => x.ID);

            AddChests(ids, playerid);
            foreach (var box in writemaps.ToArray())
            {
                var exists = GetMapByID(box.ID, MapStatus.Existing);
                if (exists != null && exists != box)
                {
                    RemoveFromZone(exists, MapStatus.Existing);
                }
                SendToZone(box, MapStatus.Existing);
            }
            DetermineTransferConflicts();
            return(conflictids.Count);
        }
Esempio n. 3
0
        // returns number of conflicts
        public int ChangeMapIDs(IEnumerable <MapIDControl> boxes, long id, MapStatus area, MapReplaceOption option)
        {
            int conflicts = 0;
            var write     = new List <MapIDControl>();

            foreach (var box in boxes.ToArray())
            {
                bool shouldchange  = (option != MapReplaceOption.Info);
                var  currentholder = GetMapByID(id, area);
                if (currentholder != null && currentholder != box)
                {
                    if (option == MapReplaceOption.ChangeExisting)
                    {
                        currentholder.SetID(GetSafeID());
                        if (area == MapStatus.Existing)
                        {
                            write.Add(currentholder);
                        }
                    }
                    else if (option == MapReplaceOption.ReplaceExisting)
                    {
                        RemoveFromZone(currentholder, area);
                    }
                    else if (option == MapReplaceOption.Skip)
                    {
                        shouldchange = false;
                    }
                    conflicts++;
                }
                if (shouldchange)
                {
                    if (area == MapStatus.Existing)
                    {
                        SelectedWorld.RemoveMaps(new[] { box.ID });
                        write.Add(box);
                    }
                    box.SetID(id);
                }
                id++;
            }
            if (write.Any())
            {
                SendMapsToWorld(write, MapReplaceOption.ReplaceExisting);
            }
            DetermineTransferConflicts();
            return(conflicts);
        }
Esempio n. 4
0
 private void SkipButton_Click(object sender, EventArgs e)
 {
     SelectedOption = MapReplaceOption.Skip;
     this.Close();
 }
Esempio n. 5
0
 private void OverwriteButton_Click(object sender, EventArgs e)
 {
     SelectedOption = MapReplaceOption.ReplaceExisting;
     this.Close();
 }
Esempio n. 6
0
 private void AutoButton_Click(object sender, EventArgs e)
 {
     SelectedOption = MapReplaceOption.ChangeExisting;
     this.Close();
 }