aboutsummaryrefslogtreecommitdiff
path: root/src/voxel.h
Commit message (Expand)AuthorAge
* VoxelArea: add_{x,y,z,p} must be staticLoic Blot2018-03-09
* Node definition manager refactor (#7016)Dániel Juhász2018-02-10
* Remove unused light updating codeDániel Juhász2018-02-04
* Modernize source code: last part (#6285)Loïc Blot2017-08-20
* Optimize headers (part 2) (#6272)Loïc Blot2017-08-18
* C++ modernize: Pragma once (#6264)Loïc Blot2017-08-17
* VoxelManip cleanups (const ref, const move) + function removal (#6169)Loïc Blot2017-07-26
* Cpp11 initializers: last src root changeset (#6022)Loïc Blot2017-06-21
* Time: Change old `u32` timestamps to 64-bit (#5818)SmallJoker2017-05-26
* For usages of assert() that are meant to persist in Release builds (when NDEB...Craig Robbins2015-03-07
* Optimise MapBlockMesh related functionsgregorycu2015-02-23
* Add VoxelArea::hasEmptyExtentunknown2015-01-13
* Optimise functions from CNodeDefManager and VoxelManipulatorCraig Robbins2014-11-21
* Remove emerge and speedup addArea by using memcopy instead of one by one assi...sapier2014-06-23
* Omnicleanup: header cleanup, add ModApiUtil shared between game and mainmenuKahrl2013-08-14
* Migrate to STL containers/algorithms.Ilya Zhuravlev2013-03-11
* Update Copyright YearsSfan52013-02-24
* Change Minetest-c55 to MinetestPilzAdam2013-02-24
* The new mapgen, noise functions, et al.kwolekr2013-01-21
* Optimize headersPerttu Ahola2012-06-17
* Switch the license to be LGPLv2/later, with small parts still remaining as GP...Perttu Ahola2012-06-05
* Implement propagateSunlight for VoxelManipulatorPerttu Ahola2012-03-27
* Clean unit test outputPerttu Ahola2012-03-10
* GameDef compilesPerttu Ahola2011-11-29
* Always return from non-void functionsGiuseppe Bilotta2011-08-08
* New map generator added (and SQLite, messed up the commits at that time...) (...Perttu Ahola2011-06-25
* fixed warnings reported by cppcheckPerttu Ahola2011-04-11
* Modified block mesh generation to have clearer input and output. Instead of b...Perttu Ahola2011-04-03
* added sneaking/crouching and changelogPerttu Ahola2011-02-14
* fully working i guessPerttu Ahola2011-02-11
* some generation-time mud flow tweakingPerttu Ahola2011-02-03
* partly working chunk-based map generator (doesn't save properly, spawn is pre...Perttu Ahola2011-02-01
* Reworked texture, material, mineral and whatever handlingPerttu Ahola2011-01-26
* Faster lighting at map generation timePerttu Ahola2011-01-24
* commented out old water stuffPerttu Ahola2011-01-24
* old water removed, some fixes here and therePerttu Ahola2011-01-17
* commit before content-tile separationPerttu Ahola2010-12-13
* fixes for vc++Perttu Ahola2010-12-13
* working nicelyPerttu Ahola2010-12-13
* starting to separate "material" to "content" and "tile"Perttu Ahola2010-12-12
* commit before some radicallish changes to water behaviorPerttu Ahola2010-12-11
* some work-in-progress water stuffPerttu Ahola2010-12-01
* license stuffPerttu Ahola2010-11-29
* vokselijuttu lisättyPerttu Ahola2010-11-29
class="hl opt">() == false; i++) { delete i.getNode()->getValue(); } // Clear container m_blocks.clear(); } MapBlock * MapSector::getBlockBuffered(s16 y) { MapBlock *block; if(m_block_cache != NULL && y == m_block_cache_y){ return m_block_cache; } // If block doesn't exist, return NULL core::map<s16, MapBlock*>::Node *n = m_blocks.find(y); if(n == NULL) { block = NULL; } // If block exists, return it else{ block = n->getValue(); } // Cache the last result m_block_cache_y = y; m_block_cache = block; return block; } MapBlock * MapSector::getBlockNoCreateNoEx(s16 y) { return getBlockBuffered(y); } MapBlock * MapSector::createBlankBlockNoInsert(s16 y) { assert(getBlockBuffered(y) == NULL); v3s16 blockpos_map(m_pos.X, y, m_pos.Y); MapBlock *block = new MapBlock(m_parent, blockpos_map, m_gamedef); return block; } MapBlock * MapSector::createBlankBlock(s16 y) { MapBlock *block = createBlankBlockNoInsert(y); m_blocks.insert(y, block); return block; } void MapSector::insertBlock(MapBlock *block) { s16 block_y = block->getPos().Y; MapBlock *block2 = getBlockBuffered(block_y); if(block2 != NULL){ throw AlreadyExistsException("Block already exists"); } v2s16 p2d(block->getPos().X, block->getPos().Z); assert(p2d == m_pos); // Insert into container m_blocks.insert(block_y, block); } void MapSector::deleteBlock(MapBlock *block) { s16 block_y = block->getPos().Y; // Clear from cache m_block_cache = NULL; // Remove from container m_blocks.remove(block_y); // Delete delete block; } void MapSector::getBlocks(core::list<MapBlock*> &dest) { core::list<MapBlock*> ref_list; core::map<s16, MapBlock*>::Iterator bi; bi = m_blocks.getIterator(); for(; bi.atEnd() == false; bi++) { MapBlock *b = bi.getNode()->getValue(); dest.push_back(b); } } /* ServerMapSector */ ServerMapSector::ServerMapSector(Map *parent, v2s16 pos, IGameDef *gamedef): MapSector(parent, pos, gamedef) { } ServerMapSector::~ServerMapSector() { } void ServerMapSector::serialize(std::ostream &os, u8 version) { if(!ser_ver_supported(version)) throw VersionMismatchException("ERROR: MapSector format not supported"); /* [0] u8 serialization version + heightmap data */ // Server has both of these, no need to support not having them. //assert(m_objects != NULL); // Write version os.write((char*)&version, 1); /* Add stuff here, if needed */ } ServerMapSector* ServerMapSector::deSerialize( std::istream &is, Map *parent, v2s16 p2d, core::map<v2s16, MapSector*> & sectors, IGameDef *gamedef ) { /* [0] u8 serialization version + heightmap data */ /* Read stuff */ // Read version u8 version = SER_FMT_VER_INVALID; is.read((char*)&version, 1); if(!ser_ver_supported(version)) throw VersionMismatchException("ERROR: MapSector format not supported"); /* Add necessary reading stuff here */ /* Get or create sector */ ServerMapSector *sector = NULL; core::map<v2s16, MapSector*>::Node *n = sectors.find(p2d); if(n != NULL) { dstream<<"WARNING: deSerializing existent sectors not supported " "at the moment, because code hasn't been tested." <<std::endl; MapSector *sector = n->getValue(); assert(sector->getId() == MAPSECTOR_SERVER); return (ServerMapSector*)sector; } else { sector = new ServerMapSector(parent, p2d, gamedef); sectors.insert(p2d, sector); } /* Set stuff in sector */ // Nothing here return sector; } #ifndef SERVER /* ClientMapSector */ ClientMapSector::ClientMapSector(Map *parent, v2s16 pos, IGameDef *gamedef): MapSector(parent, pos, gamedef) { } ClientMapSector::~ClientMapSector() { } #endif // !SERVER //END