Example #1
0
        // work in progress - not functional yet
        public static bool FullLoad( MapSenderParams param ) {
            try {
                //param.world.
                param.world.loadInProgress = false;
                param.world.loadSendingInProgress = true;
                return true;

            } catch( Exception ex ) {
                param.world.log.Log( "An error occured while trying to load a map: " + ex.Message, LogType.Error );
                param.world.loadInProgress = false;
                param.world.EndLockDown();
                return false;
            }
        }
Example #2
0
 // work in progress - not functional yet
 public static bool FullLoad(MapSenderParams param)
 {
     try {
         //param.world.
         param.world.loadInProgress        = false;
         param.world.loadSendingInProgress = true;
         return(true);
     } catch (Exception ex) {
         param.world.log.Log("An error occured while trying to load a map: " + ex.Message, LogType.Error);
         param.world.loadInProgress = false;
         param.world.EndLockDown();
         return(false);
     }
 }
Example #3
0
        public static bool StreamLoad( MapSenderParams param ) {
            try {
                param.world.completedBlockUpdates = 0;
                param.world.totalBlockUpdates = param.world.map.CompareAndUpdate( param.map );
                param.world.map.spawn = param.map.spawn;

                int ETA = param.world.totalBlockUpdates / param.world.server.CalculateMaxPacketsPerUpdate() / 10 + 1;
                param.world.SendToAll( Color.Red + "Reverting to a backup. ETA to completion: " + ETA + " seconds.", null );

                param.world.loadProgressReported = ETA < 10;

                param.world.loadInProgress = false;
                param.world.loadSendingInProgress = true;
                return true;

            } catch( Exception ex ) {
                param.world.log.Log( "An error occured while trying to load a map: " + ex.Message, LogType.Error );
                param.world.loadInProgress = false;
                param.world.EndLockDown();
                return false;
            }
        }
Example #4
0
        public static bool StreamLoad(MapSenderParams param)
        {
            try {
                param.world.completedBlockUpdates = 0;
                param.world.totalBlockUpdates     = param.world.map.CompareAndUpdate(param.map);
                param.world.map.spawn             = param.map.spawn;

                int ETA = param.world.totalBlockUpdates / param.world.server.CalculateMaxPacketsPerUpdate() / 10 + 1;
                param.world.SendToAll(Color.Red + "Reverting to a backup. ETA to completion: " + ETA + " seconds.", null);

                param.world.loadProgressReported = ETA < 10;

                param.world.loadInProgress        = false;
                param.world.loadSendingInProgress = true;
                return(true);
            } catch (Exception ex) {
                param.world.log.Log("An error occured while trying to load a map: " + ex.Message, LogType.Error);
                param.world.loadInProgress = false;
                param.world.EndLockDown();
                return(false);
            }
        }
Example #5
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 );
        }
Example #6
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);
        }