void LoadMap(string path) { IMapFileFormat mapFile = null; if (path.EndsWith(".dat")) { mapFile = new MapDat(); } else if (path.EndsWith(".fcm")) { mapFile = new MapFcm3(); } else if (path.EndsWith(".cw")) { mapFile = new MapCw(); } try { using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read)) { int width, height, length; game.Map.Reset(); byte[] blocks = mapFile.Load(fs, game, out width, out height, out length); game.Map.SetData(blocks, width, height, length); game.MapEvents.RaiseOnNewMapLoaded(); LocalPlayer p = game.LocalPlayer; LocationUpdate update = LocationUpdate.MakePos(p.SpawnPoint, false); p.SetLocation(update, false); } } catch (Exception ex) { ErrorHandler.LogError("loading map", ex); game.Chat.Add("&e/client loadmap: Failed to load map \"" + path + "\""); } }
void LoadMap( string path ) { IMapFileFormat mapFile = null; if( path.EndsWith( ".dat" ) ) { mapFile = new MapDat(); } else if( path.EndsWith( ".fcm" ) ) { mapFile = new MapFcm3(); } else if( path.EndsWith( ".cw" ) ) { mapFile = new MapCw(); } try { using( FileStream fs = new FileStream( path, FileMode.Open, FileAccess.Read, FileShare.Read ) ) { int width, height, length; game.Map.Reset(); byte[] blocks = mapFile.Load( fs, game, out width, out height, out length ); game.Map.SetData( blocks, width, height, length ); game.Events.RaiseOnNewMapLoaded(); LocalPlayer p = game.LocalPlayer; LocationUpdate update = LocationUpdate.MakePos( p.SpawnPoint, false ); p.SetLocation( update, false ); } } catch( Exception ex ) { ErrorHandler.LogError( "loading map", ex ); game.Chat.Add( "&e/client loadmap: Failed to load map \"" + path + "\"" ); } }
void LoadMap(string path) { IMapFileFormat mapFile = null; if (path.EndsWith(".dat")) { mapFile = new MapDat(); } else if (path.EndsWith(".fcm")) { mapFile = new MapFcm3(); } else if (path.EndsWith(".cw")) { mapFile = new MapCw(); } try { using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read)) { int width, height, length; game.Map.Reset(); game.Map.TextureUrl = null; for (int tile = BlockInfo.CpeBlocksCount; tile < BlockInfo.BlocksCount; tile++) { game.BlockInfo.ResetBlockInfo((byte)tile, false); } game.BlockInfo.SetupCullingCache(); game.BlockInfo.InitLightOffsets(); byte[] blocks = mapFile.Load(fs, game, out width, out height, out length); game.Map.SetData(blocks, width, height, length); game.MapEvents.RaiseOnNewMapLoaded(); if (game.AllowServerTextures && game.Map.TextureUrl != null) { game.Network.RetrieveTexturePack(game.Map.TextureUrl); } LocalPlayer p = game.LocalPlayer; LocationUpdate update = LocationUpdate.MakePosAndOri(p.SpawnPoint, p.SpawnYaw, p.SpawnPitch, false); p.SetLocation(update, false); } } catch (Exception ex) { ErrorHandler.LogError("loading map", ex); game.Chat.Add("&e/client loadmap: Failed to load map \"" + path + "\""); } }
void SaveMap(string path) { try { if (File.Exists(path)) { File.Delete(path); } using (FileStream fs = new FileStream(path, FileMode.CreateNew, FileAccess.Write)) { IMapFileFormat map = new MapCw(); map.Save(fs, game); } } catch (Exception ex) { ErrorHandler.LogError("saving map", ex); MakeDescWidget("&cError while trying to save map"); return; } game.Chat.Add("&eSaved map to: " + Path.GetFileName(path)); game.SetNewScreen(new PauseScreen(game)); }
void SaveMap( string path ) { try { using( FileStream fs = new FileStream( path, FileMode.CreateNew, FileAccess.Write ) ) { IMapFile map = new MapCw(); map.Save( fs, game ); } } catch( Exception ex ) { Utils.LogError( "Error while trying to save map: {0}{1}", Environment.NewLine, ex ); MakeDescWidget( "&cFailed to save map" ); return; } game.SetNewScreen( new PauseScreen( game ) ); }
void SaveMap( string path ) { try { using( FileStream fs = new FileStream( path, FileMode.CreateNew, FileAccess.Write ) ) { IMapFileFormat map = new MapCw(); map.Save( fs, game ); } } catch( Exception ex ) { ErrorHandler.LogError( "saving map", ex ); MakeDescWidget( "&cError while trying to save map" ); return; } game.SetNewScreen( new PauseScreen( game ) ); }