Ejemplo n.º 1
0
        public void Disconnect(string title, string reason)
        {
            Gui.Reset(this);
            World.Reset();
            World.blocks = null;
            Drawer2D.InitColours();
            BlockInfo.Reset(this);

            TexturePackExtractor.ExtractDefault(this);
            Gui.SetNewScreen(new ErrorScreen(this, title, reason));
            GC.Collect();
        }
Ejemplo n.º 2
0
        void LoadMap(string path)
        {
            IMapFormatImporter importer = null;

            if (path.EndsWith(".dat"))
            {
                importer = new MapDatImporter();
            }
            else if (path.EndsWith(".fcm"))
            {
                importer = new MapFcm3Importer();
            }
            else if (path.EndsWith(".cw"))
            {
                importer = new MapCwImporter();
            }
            else if (path.EndsWith(".lvl"))
            {
                importer = new MapLvlImporter();
            }

            try {
                using (FileStream fs = File.OpenRead(path)) {
                    int width, height, length;
                    game.World.Reset();
                    if (game.World.TextureUrl != null)
                    {
                        TexturePackExtractor.ExtractDefault(game);
                        game.World.TextureUrl = null;
                    }
                    game.BlockInfo.Reset(game);

                    byte[] blocks = importer.Load(fs, game, out width, out height, out length);
                    game.World.SetNewMap(blocks, width, height, length);
                    game.WorldEvents.RaiseOnNewMapLoaded();
                    if (game.AllowServerTextures && game.World.TextureUrl != null)
                    {
                        game.Server.RetrieveTexturePack(game.World.TextureUrl);
                    }

                    LocalPlayer    p      = game.LocalPlayer;
                    LocationUpdate update = LocationUpdate.MakePosAndOri(p.Spawn, p.SpawnYaw, p.SpawnPitch, false);
                    p.SetLocation(update, false);
                }
            } catch (Exception ex) {
                ErrorHandler.LogError("loading map", ex);
                string file = Path.GetFileName(path);
                game.Chat.Add("&e/client loadmap: Failed to load map \"" + file + "\"");
            }
        }
Ejemplo n.º 3
0
        void HandleSetMapEnvUrl()
        {
            string url = reader.ReadAsciiString();

            if (!game.AllowServerTextures)
            {
                return;
            }

            if (url == "")
            {
                TexturePackExtractor.ExtractDefault(game);
            }
            else if (Utils.IsUrlPrefix(url, 0))
            {
                net.RetrieveTexturePack(url);
            }
            Utils.LogDebug("Image url: " + url);
        }