Exemple #1
0
        void Load(Player player, Command cmd)
        {
            lock ( loadLock ) {
                if (world.loadInProgress || world.loadSendingInProgress)
                {
                    player.Message("Loading already in progress, please wait.");
                    return;
                }
                world.loadInProgress = true;
            }

            if (!player.Can(Permissions.SaveAndLoad))
            {
                world.NoAccessMessage(player);
                world.loadInProgress = false;
                return;
            }

            string mapName = cmd.Next();

            if (mapName == null)
            {
                player.Message("Syntax: " + Color.Help + "/load mapName");
                world.loadInProgress = false;
                return;
            }

            string mapFileName = mapName + ".fcm";

            if (!File.Exists(mapFileName))
            {
                player.Message("No backup file \"" + mapName + "\" found.");
                world.loadInProgress = false;
                return;
            }

            Map newMap = Map.Load(world, mapFileName);

            if (newMap == null)
            {
                player.Message("Could not load \"" + mapFileName + "\". Check logfile for details.");
                world.loadInProgress = false;
                return;
            }

            if (newMap.widthX != world.map.widthX ||
                newMap.widthY != world.map.widthY ||
                newMap.height != world.map.height)
            {
                player.Message("Map sizes of \"" + mapName + "\" and the current map do not match.");
                world.loadInProgress = false;
                return;
            }

            world.log.Log("{0} is loading the map \"{1}\".", LogType.UserActivity, player.name, mapName);
            player.Message("Loading map \"" + mapName + "\"...");
            world.BeginLockDown();
            MapSenderParams param = new MapSenderParams()
            {
                map    = newMap,
                player = player,
                world  = world
            };

            world.tasks.Add(MapSender.StreamLoad, param, true);
        }