summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/map.cpp38
-rw-r--r--src/map.h3
2 files changed, 26 insertions, 15 deletions
diff --git a/src/map.cpp b/src/map.cpp
index 001ae1609..cf7dd6f9f 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -2596,7 +2596,7 @@ bool ServerMap::initBlockMake(BlockMakeData *data, v3s16 blockpos)
// Add the area
{
//TimeTaker timer("initBlockMake() initialEmerge");
- data->vmanip->initialEmerge(bigarea_blocks_min, bigarea_blocks_max);
+ data->vmanip->initialEmerge(bigarea_blocks_min, bigarea_blocks_max, false);
}
// Ensure none of the blocks to be generated were marked as containing CONTENT_IGNORE
@@ -4202,8 +4202,8 @@ void ManualMapVoxelManipulator::emerge(VoxelArea a, s32 caller_id)
VoxelManipulator::emerge(a, caller_id);
}
-void ManualMapVoxelManipulator::initialEmerge(
- v3s16 blockpos_min, v3s16 blockpos_max)
+void ManualMapVoxelManipulator::initialEmerge(v3s16 blockpos_min,
+ v3s16 blockpos_max, bool load_if_inexistent)
{
TimeTaker timer1("initialEmerge", &emerge_time);
@@ -4255,18 +4255,28 @@ void ManualMapVoxelManipulator::initialEmerge(
if(block_data_inexistent)
{
- flags |= VMANIP_BLOCK_DATA_INEXIST;
- /*
- Mark area inexistent
- */
- VoxelArea a(p*MAP_BLOCKSIZE, (p+1)*MAP_BLOCKSIZE-v3s16(1,1,1));
- // Fill with VOXELFLAG_INEXISTENT
- for(s32 z=a.MinEdge.Z; z<=a.MaxEdge.Z; z++)
- for(s32 y=a.MinEdge.Y; y<=a.MaxEdge.Y; y++)
- {
- s32 i = m_area.index(a.MinEdge.X,y,z);
- memset(&m_flags[i], VOXELFLAG_INEXISTENT, MAP_BLOCKSIZE);
+ if (load_if_inexistent) {
+ ServerMap *svrmap = (ServerMap *)m_map;
+ block = svrmap->emergeBlock(p, false);
+ if (block == NULL)
+ block = svrmap->createBlock(p);
+ else
+ block->copyTo(*this);
+ } else {
+ flags |= VMANIP_BLOCK_DATA_INEXIST;
+
+ /*
+ Mark area inexistent
+ */
+ VoxelArea a(p*MAP_BLOCKSIZE, (p+1)*MAP_BLOCKSIZE-v3s16(1,1,1));
+ // Fill with VOXELFLAG_INEXISTENT
+ for(s32 z=a.MinEdge.Z; z<=a.MaxEdge.Z; z++)
+ for(s32 y=a.MinEdge.Y; y<=a.MaxEdge.Y; y++)
+ {
+ s32 i = m_area.index(a.MinEdge.X,y,z);
+ memset(&m_flags[i], VOXELFLAG_INEXISTENT, MAP_BLOCKSIZE);
+ }
}
}
/*else if (block->getNode(0, 0, 0).getContent() == CONTENT_IGNORE)
diff --git a/src/map.h b/src/map.h
index 8326d3e58..bccadcec5 100644
--- a/src/map.h
+++ b/src/map.h
@@ -555,7 +555,8 @@ public:
virtual void emerge(VoxelArea a, s32 caller_id=-1);
- void initialEmerge(v3s16 blockpos_min, v3s16 blockpos_max);
+ void initialEmerge(v3s16 blockpos_min, v3s16 blockpos_max,
+ bool load_if_inexistent = true);
// This is much faster with big chunks of generated data
void blitBackAll(std::map<v3s16, MapBlock*> * modified_blocks);
n> DirListNode { std::string name; bool dir; }; std::vector<DirListNode> GetDirListing(const std::string &path); // Returns true if already exists bool CreateDir(const std::string &path); bool PathExists(const std::string &path); bool IsPathAbsolute(const std::string &path); bool IsDir(const std::string &path); bool IsDirDelimiter(char c); // Only pass full paths to this one. True on success. // NOTE: The WIN32 version returns always true. bool RecursiveDelete(const std::string &path); bool DeleteSingleFileOrEmptyDirectory(const std::string &path); // Returns path to temp directory, can return "" on error std::string TempPath(); /* Returns a list of subdirectories, including the path itself, but excluding hidden directories (whose names start with . or _) */ void GetRecursiveDirs(std::vector<std::string> &dirs, const std::string &dir); std::vector<std::string> GetRecursiveDirs(const std::string &dir); /* Multiplatform */ /* The path itself not included, returns a list of all subpaths. dst - vector that contains all the subpaths. list files - include files in the list of subpaths. ignore - paths that start with these charcters will not be listed. */ void GetRecursiveSubPaths(const std::string &path, std::vector<std::string> &dst, bool list_files, const std::set<char> &ignore = {}); // Tries to delete all, returns false if any failed bool DeletePaths(const std::vector<std::string> &paths); // Only pass full paths to this one. True on success. bool RecursiveDeleteContent(const std::string &path); // Create all directories on the given path that don't already exist. bool CreateAllDirs(const std::string &path); // Copy a regular file bool CopyFileContents(const std::string &source, const std::string &target); // Copy directory and all subdirectories // Omits files and subdirectories that start with a period bool CopyDir(const std::string &source, const std::string &target); // Check if one path is prefix of another // For example, "/tmp" is a prefix of "/tmp" and "/tmp/file" but not "/tmp2" // Ignores case differences and '/' vs. '\\' on Windows bool PathStartsWith(const std::string &path, const std::string &prefix); // Remove last path component and the dir delimiter before and/or after it, // returns "" if there is only one path component. // removed: If non-NULL, receives the removed component(s). // count: Number of components to remove std::string RemoveLastPathComponent(const std::string &path, std::string *removed = NULL, int count = 1); // Remove "." and ".." path components and for every ".." removed, remove // the last normal path component before it. Unlike AbsolutePath, // this does not resolve symlinks and check for existence of directories. std::string RemoveRelativePathComponents(std::string path); // Returns the absolute path for the passed path, with "." and ".." path // components and symlinks removed. Returns "" on error. std::string AbsolutePath(const std::string &path); // Returns the filename from a path or the entire path if no directory // delimiter is found. const char *GetFilenameFromPath(const char *path); bool safeWriteToFile(const std::string &path, const std::string &content); bool Rename(const std::string &from, const std::string &to); } // namespace fs