forked from Mirrorlandia_minetest/minetest
Code modernization: src/m* (part 2)
* empty function * default constructor/destructor * remove unused Map::emergeSector(a,b) * for range-based loops * migrate a dirs[7] table to direction tables * remove various old unused function
This commit is contained in:
parent
e53d8a7536
commit
b5f7249a7e
148
src/map.cpp
148
src/map.cpp
@ -74,10 +74,8 @@ Map::~Map()
|
|||||||
/*
|
/*
|
||||||
Free all MapSectors
|
Free all MapSectors
|
||||||
*/
|
*/
|
||||||
for(std::map<v2s16, MapSector*>::iterator i = m_sectors.begin();
|
for (auto §or : m_sectors) {
|
||||||
i != m_sectors.end(); ++i)
|
delete sector.second;
|
||||||
{
|
|
||||||
delete i->second;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,11 +91,8 @@ void Map::removeEventReceiver(MapEventReceiver *event_receiver)
|
|||||||
|
|
||||||
void Map::dispatchEvent(MapEditEvent *event)
|
void Map::dispatchEvent(MapEditEvent *event)
|
||||||
{
|
{
|
||||||
for(std::set<MapEventReceiver*>::iterator
|
for (MapEventReceiver *event_receiver : m_event_receivers) {
|
||||||
i = m_event_receivers.begin();
|
event_receiver->onMapEditEvent(event);
|
||||||
i != m_event_receivers.end(); ++i)
|
|
||||||
{
|
|
||||||
(*i)->onMapEditEvent(event);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,7 +105,7 @@ MapSector * Map::getSectorNoGenerateNoExNoLock(v2s16 p)
|
|||||||
|
|
||||||
std::map<v2s16, MapSector*>::iterator n = m_sectors.find(p);
|
std::map<v2s16, MapSector*>::iterator n = m_sectors.find(p);
|
||||||
|
|
||||||
if(n == m_sectors.end())
|
if (n == m_sectors.end())
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
MapSector *sector = n->second;
|
MapSector *sector = n->second;
|
||||||
@ -182,7 +177,7 @@ MapNode Map::getNodeNoEx(v3s16 p, bool *is_valid_position)
|
|||||||
if (block == NULL) {
|
if (block == NULL) {
|
||||||
if (is_valid_position != NULL)
|
if (is_valid_position != NULL)
|
||||||
*is_valid_position = false;
|
*is_valid_position = false;
|
||||||
return MapNode(CONTENT_IGNORE);
|
return {CONTENT_IGNORE};
|
||||||
}
|
}
|
||||||
|
|
||||||
v3s16 relpos = p - blockpos*MAP_BLOCKSIZE;
|
v3s16 relpos = p - blockpos*MAP_BLOCKSIZE;
|
||||||
@ -254,14 +249,11 @@ void Map::addNodeAndUpdate(v3s16 p, MapNode n,
|
|||||||
|
|
||||||
// Update lighting
|
// Update lighting
|
||||||
std::vector<std::pair<v3s16, MapNode> > oldnodes;
|
std::vector<std::pair<v3s16, MapNode> > oldnodes;
|
||||||
oldnodes.push_back(std::pair<v3s16, MapNode>(p, oldnode));
|
oldnodes.emplace_back(p, oldnode);
|
||||||
voxalgo::update_lighting_nodes(this, oldnodes, modified_blocks);
|
voxalgo::update_lighting_nodes(this, oldnodes, modified_blocks);
|
||||||
|
|
||||||
for(std::map<v3s16, MapBlock*>::iterator
|
for (auto &modified_block : modified_blocks) {
|
||||||
i = modified_blocks.begin();
|
modified_block.second->expireDayNightDiff();
|
||||||
i != modified_blocks.end(); ++i)
|
|
||||||
{
|
|
||||||
i->second->expireDayNightDiff();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Report for rollback
|
// Report for rollback
|
||||||
@ -277,18 +269,9 @@ void Map::addNodeAndUpdate(v3s16 p, MapNode n,
|
|||||||
Add neighboring liquid nodes and this node to transform queue.
|
Add neighboring liquid nodes and this node to transform queue.
|
||||||
(it's vital for the node itself to get updated last, if it was removed.)
|
(it's vital for the node itself to get updated last, if it was removed.)
|
||||||
*/
|
*/
|
||||||
v3s16 dirs[7] = {
|
|
||||||
v3s16(0,0,1), // back
|
for (const v3s16 &dir : g_7dirs) {
|
||||||
v3s16(0,1,0), // top
|
v3s16 p2 = p + dir;
|
||||||
v3s16(1,0,0), // right
|
|
||||||
v3s16(0,0,-1), // front
|
|
||||||
v3s16(0,-1,0), // bottom
|
|
||||||
v3s16(-1,0,0), // left
|
|
||||||
v3s16(0,0,0), // self
|
|
||||||
};
|
|
||||||
for(u16 i=0; i<7; i++)
|
|
||||||
{
|
|
||||||
v3s16 p2 = p + dirs[i];
|
|
||||||
|
|
||||||
bool is_valid_position;
|
bool is_valid_position;
|
||||||
MapNode n2 = getNodeNoEx(p2, &is_valid_position);
|
MapNode n2 = getNodeNoEx(p2, &is_valid_position);
|
||||||
@ -318,11 +301,8 @@ bool Map::addNodeWithEvent(v3s16 p, MapNode n, bool remove_metadata)
|
|||||||
addNodeAndUpdate(p, n, modified_blocks, remove_metadata);
|
addNodeAndUpdate(p, n, modified_blocks, remove_metadata);
|
||||||
|
|
||||||
// Copy modified_blocks to event
|
// Copy modified_blocks to event
|
||||||
for(std::map<v3s16, MapBlock*>::iterator
|
for (auto &modified_block : modified_blocks) {
|
||||||
i = modified_blocks.begin();
|
event.modified_blocks.insert(modified_block.first);
|
||||||
i != modified_blocks.end(); ++i)
|
|
||||||
{
|
|
||||||
event.modified_blocks.insert(i->first);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(InvalidPositionException &e){
|
catch(InvalidPositionException &e){
|
||||||
@ -346,11 +326,8 @@ bool Map::removeNodeWithEvent(v3s16 p)
|
|||||||
removeNodeAndUpdate(p, modified_blocks);
|
removeNodeAndUpdate(p, modified_blocks);
|
||||||
|
|
||||||
// Copy modified_blocks to event
|
// Copy modified_blocks to event
|
||||||
for(std::map<v3s16, MapBlock*>::iterator
|
for (auto &modified_block : modified_blocks) {
|
||||||
i = modified_blocks.begin();
|
event.modified_blocks.insert(modified_block.first);
|
||||||
i != modified_blocks.end(); ++i)
|
|
||||||
{
|
|
||||||
event.modified_blocks.insert(i->first);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(InvalidPositionException &e){
|
catch(InvalidPositionException &e){
|
||||||
@ -397,19 +374,15 @@ void Map::timerUpdate(float dtime, float unload_timeout, u32 max_loaded_blocks,
|
|||||||
|
|
||||||
// If there is no practical limit, we spare creation of mapblock_queue
|
// If there is no practical limit, we spare creation of mapblock_queue
|
||||||
if (max_loaded_blocks == U32_MAX) {
|
if (max_loaded_blocks == U32_MAX) {
|
||||||
for (std::map<v2s16, MapSector*>::iterator si = m_sectors.begin();
|
for (auto §or_it : m_sectors) {
|
||||||
si != m_sectors.end(); ++si) {
|
MapSector *sector = sector_it.second;
|
||||||
MapSector *sector = si->second;
|
|
||||||
|
|
||||||
bool all_blocks_deleted = true;
|
bool all_blocks_deleted = true;
|
||||||
|
|
||||||
MapBlockVect blocks;
|
MapBlockVect blocks;
|
||||||
sector->getBlocks(blocks);
|
sector->getBlocks(blocks);
|
||||||
|
|
||||||
for (MapBlockVect::iterator i = blocks.begin();
|
for (MapBlock *block : blocks) {
|
||||||
i != blocks.end(); ++i) {
|
|
||||||
MapBlock *block = (*i);
|
|
||||||
|
|
||||||
block->incrementUsageTimer(dtime);
|
block->incrementUsageTimer(dtime);
|
||||||
|
|
||||||
if (block->refGet() == 0
|
if (block->refGet() == 0
|
||||||
@ -439,22 +412,18 @@ void Map::timerUpdate(float dtime, float unload_timeout, u32 max_loaded_blocks,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (all_blocks_deleted) {
|
if (all_blocks_deleted) {
|
||||||
sector_deletion_queue.push_back(si->first);
|
sector_deletion_queue.push_back(sector_it.first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
std::priority_queue<TimeOrderedMapBlock> mapblock_queue;
|
std::priority_queue<TimeOrderedMapBlock> mapblock_queue;
|
||||||
for (std::map<v2s16, MapSector*>::iterator si = m_sectors.begin();
|
for (auto §or_it : m_sectors) {
|
||||||
si != m_sectors.end(); ++si) {
|
MapSector *sector = sector_it.second;
|
||||||
MapSector *sector = si->second;
|
|
||||||
|
|
||||||
MapBlockVect blocks;
|
MapBlockVect blocks;
|
||||||
sector->getBlocks(blocks);
|
sector->getBlocks(blocks);
|
||||||
|
|
||||||
for(MapBlockVect::iterator i = blocks.begin();
|
for (MapBlock *block : blocks) {
|
||||||
i != blocks.end(); ++i) {
|
|
||||||
MapBlock *block = (*i);
|
|
||||||
|
|
||||||
block->incrementUsageTimer(dtime);
|
block->incrementUsageTimer(dtime);
|
||||||
mapblock_queue.push(TimeOrderedMapBlock(sector, block));
|
mapblock_queue.push(TimeOrderedMapBlock(sector, block));
|
||||||
}
|
}
|
||||||
@ -491,10 +460,9 @@ void Map::timerUpdate(float dtime, float unload_timeout, u32 max_loaded_blocks,
|
|||||||
block_count_all--;
|
block_count_all--;
|
||||||
}
|
}
|
||||||
// Delete empty sectors
|
// Delete empty sectors
|
||||||
for (std::map<v2s16, MapSector*>::iterator si = m_sectors.begin();
|
for (auto §or_it : m_sectors) {
|
||||||
si != m_sectors.end(); ++si) {
|
if (sector_it.second->empty()) {
|
||||||
if (si->second->empty()) {
|
sector_deletion_queue.push_back(sector_it.first);
|
||||||
sector_deletion_queue.push_back(si->first);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -876,7 +844,7 @@ void Map::transformLiquids(std::map<v3s16, MapBlock*> &modified_blocks,
|
|||||||
MapBlock *block = getBlockNoCreateNoEx(blockpos);
|
MapBlock *block = getBlockNoCreateNoEx(blockpos);
|
||||||
if (block != NULL) {
|
if (block != NULL) {
|
||||||
modified_blocks[blockpos] = block;
|
modified_blocks[blockpos] = block;
|
||||||
changed_nodes.push_back(std::pair<v3s16, MapNode>(p0, n00));
|
changed_nodes.emplace_back(p0, n00);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -902,8 +870,8 @@ void Map::transformLiquids(std::map<v3s16, MapBlock*> &modified_blocks,
|
|||||||
}
|
}
|
||||||
//infostream<<"Map::transformLiquids(): loopcount="<<loopcount<<std::endl;
|
//infostream<<"Map::transformLiquids(): loopcount="<<loopcount<<std::endl;
|
||||||
|
|
||||||
for (std::deque<v3s16>::iterator iter = must_reflow.begin(); iter != must_reflow.end(); ++iter)
|
for (auto &iter : must_reflow)
|
||||||
m_transforming_liquid.push_back(*iter);
|
m_transforming_liquid.push_back(iter);
|
||||||
|
|
||||||
voxalgo::update_lighting_nodes(this, changed_nodes, modified_blocks);
|
voxalgo::update_lighting_nodes(this, changed_nodes, modified_blocks);
|
||||||
|
|
||||||
@ -1205,14 +1173,11 @@ ServerMap::ServerMap(const std::string &savedir, IGameDef *gamedef,
|
|||||||
m_savedir = savedir;
|
m_savedir = savedir;
|
||||||
m_map_saving_enabled = false;
|
m_map_saving_enabled = false;
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
// If directory exists, check contents and load if possible
|
// If directory exists, check contents and load if possible
|
||||||
if(fs::PathExists(m_savedir))
|
if (fs::PathExists(m_savedir)) {
|
||||||
{
|
|
||||||
// If directory is empty, it is safe to save into it.
|
// If directory is empty, it is safe to save into it.
|
||||||
if(fs::GetDirListing(m_savedir).size() == 0)
|
if (fs::GetDirListing(m_savedir).empty()) {
|
||||||
{
|
|
||||||
infostream<<"ServerMap: Empty save directory is valid."
|
infostream<<"ServerMap: Empty save directory is valid."
|
||||||
<<std::endl;
|
<<std::endl;
|
||||||
m_map_saving_enabled = true;
|
m_map_saving_enabled = true;
|
||||||
@ -1442,10 +1407,8 @@ void ServerMap::finishBlockMake(BlockMakeData *data,
|
|||||||
data->transforming_liquid.pop_front();
|
data->transforming_liquid.pop_front();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (std::map<v3s16, MapBlock *>::iterator
|
for (auto &changed_block : *changed_blocks) {
|
||||||
it = changed_blocks->begin();
|
MapBlock *block = changed_block.second;
|
||||||
it != changed_blocks->end(); ++it) {
|
|
||||||
MapBlock *block = it->second;
|
|
||||||
if (!block)
|
if (!block)
|
||||||
continue;
|
continue;
|
||||||
/*
|
/*
|
||||||
@ -1975,10 +1938,7 @@ void ServerMap::save(ModifiedState save_level)
|
|||||||
MapBlockVect blocks;
|
MapBlockVect blocks;
|
||||||
sector->getBlocks(blocks);
|
sector->getBlocks(blocks);
|
||||||
|
|
||||||
for(MapBlockVect::iterator j = blocks.begin();
|
for (MapBlock *block : blocks) {
|
||||||
j != blocks.end(); ++j) {
|
|
||||||
MapBlock *block = *j;
|
|
||||||
|
|
||||||
block_count_all++;
|
block_count_all++;
|
||||||
|
|
||||||
if(block->getModified() >= (u32)save_level) {
|
if(block->getModified() >= (u32)save_level) {
|
||||||
@ -2032,17 +1992,14 @@ void ServerMap::listAllLoadableBlocks(std::vector<v3s16> &dst)
|
|||||||
|
|
||||||
void ServerMap::listAllLoadedBlocks(std::vector<v3s16> &dst)
|
void ServerMap::listAllLoadedBlocks(std::vector<v3s16> &dst)
|
||||||
{
|
{
|
||||||
for(std::map<v2s16, MapSector*>::iterator si = m_sectors.begin();
|
for (auto §or_it : m_sectors) {
|
||||||
si != m_sectors.end(); ++si)
|
MapSector *sector = sector_it.second;
|
||||||
{
|
|
||||||
MapSector *sector = si->second;
|
|
||||||
|
|
||||||
MapBlockVect blocks;
|
MapBlockVect blocks;
|
||||||
sector->getBlocks(blocks);
|
sector->getBlocks(blocks);
|
||||||
|
|
||||||
for(MapBlockVect::iterator i = blocks.begin();
|
for (MapBlock *block : blocks) {
|
||||||
i != blocks.end(); ++i) {
|
v3s16 p = block->getPos();
|
||||||
v3s16 p = (*i)->getPos();
|
|
||||||
dst.push_back(p);
|
dst.push_back(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2232,22 +2189,22 @@ MapDatabase *ServerMap::createDatabase(
|
|||||||
if (name == "dummy")
|
if (name == "dummy")
|
||||||
return new Database_Dummy();
|
return new Database_Dummy();
|
||||||
#if USE_LEVELDB
|
#if USE_LEVELDB
|
||||||
else if (name == "leveldb")
|
if (name == "leveldb")
|
||||||
return new Database_LevelDB(savedir);
|
return new Database_LevelDB(savedir);
|
||||||
#endif
|
#endif
|
||||||
#if USE_REDIS
|
#if USE_REDIS
|
||||||
else if (name == "redis")
|
if (name == "redis")
|
||||||
return new Database_Redis(conf);
|
return new Database_Redis(conf);
|
||||||
#endif
|
#endif
|
||||||
#if USE_POSTGRESQL
|
#if USE_POSTGRESQL
|
||||||
else if (name == "postgresql") {
|
if (name == "postgresql") {
|
||||||
std::string connect_string = "";
|
std::string connect_string;
|
||||||
conf.getNoEx("pgsql_connection", connect_string);
|
conf.getNoEx("pgsql_connection", connect_string);
|
||||||
return new MapDatabasePostgreSQL(connect_string);
|
return new MapDatabasePostgreSQL(connect_string);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else
|
|
||||||
throw BaseException(std::string("Database backend ") + name + " not supported.");
|
throw BaseException(std::string("Database backend ") + name + " not supported.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerMap::beginSave()
|
void ServerMap::beginSave()
|
||||||
@ -2448,7 +2405,7 @@ MapBlock* ServerMap::loadBlock(v3s16 blockpos)
|
|||||||
|
|
||||||
std::string ret;
|
std::string ret;
|
||||||
dbase->loadBlock(blockpos, &ret);
|
dbase->loadBlock(blockpos, &ret);
|
||||||
if (ret != "") {
|
if (!ret.empty()) {
|
||||||
loadBlock(&ret, blockpos, createSector(p2d), false);
|
loadBlock(&ret, blockpos, createSector(p2d), false);
|
||||||
} else {
|
} else {
|
||||||
// Not found in database, try the files
|
// Not found in database, try the files
|
||||||
@ -2556,10 +2513,6 @@ MMVManip::MMVManip(Map *map):
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
MMVManip::~MMVManip()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void MMVManip::initialEmerge(v3s16 blockpos_min, v3s16 blockpos_max,
|
void MMVManip::initialEmerge(v3s16 blockpos_min, v3s16 blockpos_max,
|
||||||
bool load_if_inexistent)
|
bool load_if_inexistent)
|
||||||
{
|
{
|
||||||
@ -2657,13 +2610,10 @@ void MMVManip::blitBackAll(std::map<v3s16, MapBlock*> *modified_blocks,
|
|||||||
/*
|
/*
|
||||||
Copy data of all blocks
|
Copy data of all blocks
|
||||||
*/
|
*/
|
||||||
for(std::map<v3s16, u8>::iterator
|
for (auto &loaded_block : m_loaded_blocks) {
|
||||||
i = m_loaded_blocks.begin();
|
v3s16 p = loaded_block.first;
|
||||||
i != m_loaded_blocks.end(); ++i)
|
|
||||||
{
|
|
||||||
v3s16 p = i->first;
|
|
||||||
MapBlock *block = m_map->getBlockNoCreateNoEx(p);
|
MapBlock *block = m_map->getBlockNoCreateNoEx(p);
|
||||||
bool existed = !(i->second & VMANIP_BLOCK_DATA_INEXIST);
|
bool existed = !(loaded_block.second & VMANIP_BLOCK_DATA_INEXIST);
|
||||||
if (!existed || (block == NULL) ||
|
if (!existed || (block == NULL) ||
|
||||||
(!overwrite_generated && block->isGenerated()))
|
(!overwrite_generated && block->isGenerated()))
|
||||||
continue;
|
continue;
|
||||||
|
@ -168,8 +168,6 @@ public:
|
|||||||
their differing fetch methods.
|
their differing fetch methods.
|
||||||
*/
|
*/
|
||||||
virtual MapSector * emergeSector(v2s16 p){ return NULL; }
|
virtual MapSector * emergeSector(v2s16 p){ return NULL; }
|
||||||
virtual MapSector * emergeSector(v2s16 p,
|
|
||||||
std::map<v3s16, MapBlock*> &changed_blocks){ return NULL; }
|
|
||||||
|
|
||||||
// Returns InvalidPositionException if not found
|
// Returns InvalidPositionException if not found
|
||||||
MapBlock * getBlockNoCreate(v3s16 p);
|
MapBlock * getBlockNoCreate(v3s16 p);
|
||||||
@ -496,7 +494,7 @@ class MMVManip : public VoxelManipulator
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MMVManip(Map *map);
|
MMVManip(Map *map);
|
||||||
virtual ~MMVManip();
|
virtual ~MMVManip() = default;
|
||||||
|
|
||||||
virtual void clear()
|
virtual void clear()
|
||||||
{
|
{
|
||||||
|
@ -250,9 +250,7 @@ bool MapBlock::propagateSunlight(std::set<v3s16> & light_sources,
|
|||||||
else if(current_light == LIGHT_SUN && nodemgr->get(n).sunlight_propagates)
|
else if(current_light == LIGHT_SUN && nodemgr->get(n).sunlight_propagates)
|
||||||
{
|
{
|
||||||
// Do nothing: Sunlight is continued
|
// Do nothing: Sunlight is continued
|
||||||
}
|
} else if (!nodemgr->get(n).light_propagates) {
|
||||||
else if(nodemgr->get(n).light_propagates == false)
|
|
||||||
{
|
|
||||||
// A solid object is on the way.
|
// A solid object is on the way.
|
||||||
stopped_to_solid_object = true;
|
stopped_to_solid_object = true;
|
||||||
|
|
||||||
@ -305,10 +303,10 @@ bool MapBlock::propagateSunlight(std::set<v3s16> & light_sources,
|
|||||||
if(nodemgr->get(n).light_propagates)
|
if(nodemgr->get(n).light_propagates)
|
||||||
{
|
{
|
||||||
if(n.getLight(LIGHTBANK_DAY, nodemgr) == LIGHT_SUN
|
if(n.getLight(LIGHTBANK_DAY, nodemgr) == LIGHT_SUN
|
||||||
&& sunlight_should_go_down == false)
|
&& !sunlight_should_go_down)
|
||||||
block_below_is_valid = false;
|
block_below_is_valid = false;
|
||||||
else if(n.getLight(LIGHTBANK_DAY, nodemgr) != LIGHT_SUN
|
else if(n.getLight(LIGHTBANK_DAY, nodemgr) != LIGHT_SUN
|
||||||
&& sunlight_should_go_down == true)
|
&& sunlight_should_go_down)
|
||||||
block_below_is_valid = false;
|
block_below_is_valid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -563,7 +561,7 @@ void MapBlock::serialize(std::ostream &os, u8 version, bool disk)
|
|||||||
flags |= 0x01;
|
flags |= 0x01;
|
||||||
if(getDayNightDiff())
|
if(getDayNightDiff())
|
||||||
flags |= 0x02;
|
flags |= 0x02;
|
||||||
if(m_generated == false)
|
if (!m_generated)
|
||||||
flags |= 0x08;
|
flags |= 0x08;
|
||||||
writeU8(os, flags);
|
writeU8(os, flags);
|
||||||
if (version >= 27) {
|
if (version >= 27) {
|
||||||
@ -659,13 +657,13 @@ void MapBlock::deSerialize(std::istream &is, u8 version, bool disk)
|
|||||||
}
|
}
|
||||||
|
|
||||||
u8 flags = readU8(is);
|
u8 flags = readU8(is);
|
||||||
is_underground = (flags & 0x01) ? true : false;
|
is_underground = (flags & 0x01) != 0;
|
||||||
m_day_night_differs = (flags & 0x02) ? true : false;
|
m_day_night_differs = (flags & 0x02) != 0;
|
||||||
if (version < 27)
|
if (version < 27)
|
||||||
m_lighting_complete = 0xFFFF;
|
m_lighting_complete = 0xFFFF;
|
||||||
else
|
else
|
||||||
m_lighting_complete = readU16(is);
|
m_lighting_complete = readU16(is);
|
||||||
m_generated = (flags & 0x08) ? false : true;
|
m_generated = (flags & 0x08) == 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Bulk node data
|
Bulk node data
|
||||||
@ -839,10 +837,10 @@ void MapBlock::deSerialize_pre22(std::istream &is, u8 version, bool disk)
|
|||||||
} else { // All other versions (10 to 21)
|
} else { // All other versions (10 to 21)
|
||||||
u8 flags;
|
u8 flags;
|
||||||
is.read((char*)&flags, 1);
|
is.read((char*)&flags, 1);
|
||||||
is_underground = (flags & 0x01) ? true : false;
|
is_underground = (flags & 0x01) != 0;
|
||||||
m_day_night_differs = (flags & 0x02) ? true : false;
|
m_day_night_differs = (flags & 0x02) != 0;
|
||||||
if(version >= 18)
|
if(version >= 18)
|
||||||
m_generated = (flags & 0x08) ? false : true;
|
m_generated = (flags & 0x08) == 0;
|
||||||
|
|
||||||
// Uncompress data
|
// Uncompress data
|
||||||
std::ostringstream os(std::ios_base::binary);
|
std::ostringstream os(std::ios_base::binary);
|
||||||
|
@ -255,7 +255,7 @@ public:
|
|||||||
*valid_position = isValidPosition(x, y, z);
|
*valid_position = isValidPosition(x, y, z);
|
||||||
|
|
||||||
if (!*valid_position)
|
if (!*valid_position)
|
||||||
return MapNode(CONTENT_IGNORE);
|
return {CONTENT_IGNORE};
|
||||||
|
|
||||||
return data[z * zstride + y * ystride + x];
|
return data[z * zstride + y * ystride + x];
|
||||||
}
|
}
|
||||||
@ -292,8 +292,8 @@ public:
|
|||||||
inline MapNode getNodeNoCheck(s16 x, s16 y, s16 z, bool *valid_position)
|
inline MapNode getNodeNoCheck(s16 x, s16 y, s16 z, bool *valid_position)
|
||||||
{
|
{
|
||||||
*valid_position = data != nullptr;
|
*valid_position = data != nullptr;
|
||||||
if (!valid_position)
|
if (!*valid_position)
|
||||||
return MapNode(CONTENT_IGNORE);
|
return {CONTENT_IGNORE};
|
||||||
|
|
||||||
return data[z * zstride + y * ystride + x];
|
return data[z * zstride + y * ystride + x];
|
||||||
}
|
}
|
||||||
@ -456,12 +456,12 @@ public:
|
|||||||
//// Node Timers
|
//// Node Timers
|
||||||
////
|
////
|
||||||
|
|
||||||
inline NodeTimer getNodeTimer(v3s16 p)
|
inline NodeTimer getNodeTimer(const v3s16 &p)
|
||||||
{
|
{
|
||||||
return m_node_timers.get(p);
|
return m_node_timers.get(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void removeNodeTimer(v3s16 p)
|
inline void removeNodeTimer(const v3s16 &p)
|
||||||
{
|
{
|
||||||
m_node_timers.remove(p);
|
m_node_timers.remove(p);
|
||||||
}
|
}
|
||||||
@ -640,31 +640,16 @@ inline bool blockpos_over_max_limit(v3s16 p)
|
|||||||
/*
|
/*
|
||||||
Returns the position of the block where the node is located
|
Returns the position of the block where the node is located
|
||||||
*/
|
*/
|
||||||
inline v3s16 getNodeBlockPos(v3s16 p)
|
inline v3s16 getNodeBlockPos(const v3s16 &p)
|
||||||
{
|
{
|
||||||
return getContainerPos(p, MAP_BLOCKSIZE);
|
return getContainerPos(p, MAP_BLOCKSIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline v2s16 getNodeSectorPos(v2s16 p)
|
|
||||||
{
|
|
||||||
return getContainerPos(p, MAP_BLOCKSIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline s16 getNodeBlockY(s16 y)
|
|
||||||
{
|
|
||||||
return getContainerPos(y, MAP_BLOCKSIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void getNodeBlockPosWithOffset(const v3s16 &p, v3s16 &block, v3s16 &offset)
|
inline void getNodeBlockPosWithOffset(const v3s16 &p, v3s16 &block, v3s16 &offset)
|
||||||
{
|
{
|
||||||
getContainerPosWithOffset(p, MAP_BLOCKSIZE, block, offset);
|
getContainerPosWithOffset(p, MAP_BLOCKSIZE, block, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void getNodeSectorPosWithOffset(const v2s16 &p, v2s16 &block, v2s16 &offset)
|
|
||||||
{
|
|
||||||
getContainerPosWithOffset(p, MAP_BLOCKSIZE, block, offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Get a quick string to describe what a block actually contains
|
Get a quick string to describe what a block actually contains
|
||||||
*/
|
*/
|
||||||
|
@ -71,8 +71,7 @@ void MeshMakeData::fill(MapBlock *block)
|
|||||||
// Get map for reading neigbhor blocks
|
// Get map for reading neigbhor blocks
|
||||||
Map *map = block->getParent();
|
Map *map = block->getParent();
|
||||||
|
|
||||||
for (u16 i=0; i<26; i++) {
|
for (const v3s16 &dir : g_26dirs) {
|
||||||
const v3s16 &dir = g_26dirs[i];
|
|
||||||
v3s16 bp = m_blockpos + dir;
|
v3s16 bp = m_blockpos + dir;
|
||||||
MapBlock *b = map->getBlockNoCreateNoEx(bp);
|
MapBlock *b = map->getBlockNoCreateNoEx(bp);
|
||||||
if(b)
|
if(b)
|
||||||
@ -220,9 +219,8 @@ static u16 getSmoothLightCombined(const v3s16 &p, MeshMakeData *data)
|
|||||||
u16 light_day = 0;
|
u16 light_day = 0;
|
||||||
u16 light_night = 0;
|
u16 light_night = 0;
|
||||||
|
|
||||||
for (u32 i = 0; i < 8; i++)
|
for (const v3s16 &dir : dirs8) {
|
||||||
{
|
MapNode n = data->m_vmanip.getNodeNoExNoEmerge(p - dir);
|
||||||
MapNode n = data->m_vmanip.getNodeNoExNoEmerge(p - dirs8[i]);
|
|
||||||
|
|
||||||
// if it's CONTENT_IGNORE we can't do any light calculations
|
// if it's CONTENT_IGNORE we can't do any light calculations
|
||||||
if (n.getContent() == CONTENT_IGNORE) {
|
if (n.getContent() == CONTENT_IGNORE) {
|
||||||
@ -426,7 +424,7 @@ struct FastFace
|
|||||||
};
|
};
|
||||||
|
|
||||||
static void makeFastFace(const TileSpec &tile, u16 li0, u16 li1, u16 li2, u16 li3,
|
static void makeFastFace(const TileSpec &tile, u16 li0, u16 li1, u16 li2, u16 li3,
|
||||||
v3f p, v3s16 dir, v3f scale, std::vector<FastFace> &dest)
|
const v3f &p, v3s16 dir, v3f scale, std::vector<FastFace> &dest)
|
||||||
{
|
{
|
||||||
// Position is at the center of the cube.
|
// Position is at the center of the cube.
|
||||||
v3f pos = p * BS;
|
v3f pos = p * BS;
|
||||||
@ -561,12 +559,11 @@ static void makeFastFace(const TileSpec &tile, u16 li0, u16 li1, u16 li2, u16 li
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(u16 i=0; i<4; i++)
|
for (v3f &vpos : vertex_pos) {
|
||||||
{
|
vpos.X *= scale.X;
|
||||||
vertex_pos[i].X *= scale.X;
|
vpos.Y *= scale.Y;
|
||||||
vertex_pos[i].Y *= scale.Y;
|
vpos.Z *= scale.Z;
|
||||||
vertex_pos[i].Z *= scale.Z;
|
vpos += pos;
|
||||||
vertex_pos[i] += pos;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
f32 abs_scale = 1.0;
|
f32 abs_scale = 1.0;
|
||||||
@ -656,7 +653,7 @@ static u8 face_contents(content_t m1, content_t m2, bool *equivalent,
|
|||||||
bool solidness_differs = (c1 != c2);
|
bool solidness_differs = (c1 != c2);
|
||||||
bool makes_face = contents_differ && solidness_differs;
|
bool makes_face = contents_differ && solidness_differs;
|
||||||
|
|
||||||
if(makes_face == false)
|
if (!makes_face)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if(c1 == 0)
|
if(c1 == 0)
|
||||||
@ -673,10 +670,10 @@ static u8 face_contents(content_t m1, content_t m2, bool *equivalent,
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(c1 > c2)
|
if (c1 > c2)
|
||||||
return 1;
|
return 1;
|
||||||
else
|
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -688,13 +685,12 @@ void getNodeTileN(MapNode mn, v3s16 p, u8 tileindex, MeshMakeData *data, TileSpe
|
|||||||
const ContentFeatures &f = ndef->get(mn);
|
const ContentFeatures &f = ndef->get(mn);
|
||||||
tile = f.tiles[tileindex];
|
tile = f.tiles[tileindex];
|
||||||
TileLayer *top_layer = NULL;
|
TileLayer *top_layer = NULL;
|
||||||
for (int layernum = 0; layernum < MAX_TILE_LAYERS; layernum++) {
|
for (TileLayer &layer : tile.layers) {
|
||||||
TileLayer *layer = &tile.layers[layernum];
|
if (layer.texture_id == 0)
|
||||||
if (layer->texture_id == 0)
|
|
||||||
continue;
|
continue;
|
||||||
top_layer = layer;
|
top_layer = &layer;
|
||||||
if (!layer->has_color)
|
if (!layer.has_color)
|
||||||
mn.getColor(f, &(layer->color));
|
mn.getColor(f, &(layer.color));
|
||||||
}
|
}
|
||||||
// Apply temporary crack
|
// Apply temporary crack
|
||||||
if (p == data->m_crack_pos_relative)
|
if (p == data->m_crack_pos_relative)
|
||||||
@ -826,9 +822,8 @@ static void getTileInfo(
|
|||||||
|
|
||||||
// eg. water and glass
|
// eg. water and glass
|
||||||
if (equivalent) {
|
if (equivalent) {
|
||||||
for (int layernum = 0; layernum < MAX_TILE_LAYERS; layernum++)
|
for (TileLayer &layer : tile.layers)
|
||||||
tile.layers[layernum].material_flags |=
|
layer.material_flags |= MATERIAL_FLAG_BACKFACE_CULLING;
|
||||||
MATERIAL_FLAG_BACKFACE_CULLING;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!data->m_smooth_lighting) {
|
if (!data->m_smooth_lighting) {
|
||||||
@ -1008,8 +1003,8 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset):
|
|||||||
m_last_crack(-1),
|
m_last_crack(-1),
|
||||||
m_last_daynight_ratio((u32) -1)
|
m_last_daynight_ratio((u32) -1)
|
||||||
{
|
{
|
||||||
for (int m = 0; m < MAX_TILE_LAYERS; m++)
|
for (auto &m : m_mesh)
|
||||||
m_mesh[m] = new scene::SMesh();
|
m = new scene::SMesh();
|
||||||
m_enable_shaders = data->m_use_shaders;
|
m_enable_shaders = data->m_use_shaders;
|
||||||
m_use_tangent_vertices = data->m_use_tangent_vertices;
|
m_use_tangent_vertices = data->m_use_tangent_vertices;
|
||||||
m_enable_vbo = g_settings->getBool("enable_vbo");
|
m_enable_vbo = g_settings->getBool("enable_vbo");
|
||||||
@ -1052,9 +1047,7 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset):
|
|||||||
// (NOTE: probably outdated)
|
// (NOTE: probably outdated)
|
||||||
//TimeTaker timer2("MeshCollector building");
|
//TimeTaker timer2("MeshCollector building");
|
||||||
|
|
||||||
for (u32 i = 0; i < fastfaces_new.size(); i++) {
|
for (const FastFace &f : fastfaces_new) {
|
||||||
FastFace &f = fastfaces_new[i];
|
|
||||||
|
|
||||||
const u16 indices[] = {0,1,2,2,3,0};
|
const u16 indices[] = {0,1,2,2,3,0};
|
||||||
const u16 indices_alternate[] = {0,1,3,2,3,1};
|
const u16 indices_alternate[] = {0,1,3,2,3,1};
|
||||||
|
|
||||||
@ -1240,14 +1233,14 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset):
|
|||||||
|
|
||||||
MapBlockMesh::~MapBlockMesh()
|
MapBlockMesh::~MapBlockMesh()
|
||||||
{
|
{
|
||||||
for (int m = 0; m < MAX_TILE_LAYERS; m++) {
|
for (scene::IMesh *m : m_mesh) {
|
||||||
if (m_enable_vbo && m_mesh[m])
|
if (m_enable_vbo && m)
|
||||||
for (u32 i = 0; i < m_mesh[m]->getMeshBufferCount(); i++) {
|
for (u32 i = 0; i < m->getMeshBufferCount(); i++) {
|
||||||
scene::IMeshBuffer *buf = m_mesh[m]->getMeshBuffer(i);
|
scene::IMeshBuffer *buf = m->getMeshBuffer(i);
|
||||||
RenderingEngine::get_video_driver()->removeHardwareBuffer(buf);
|
RenderingEngine::get_video_driver()->removeHardwareBuffer(buf);
|
||||||
}
|
}
|
||||||
m_mesh[m]->drop();
|
m->drop();
|
||||||
m_mesh[m] = NULL;
|
m = NULL;
|
||||||
}
|
}
|
||||||
delete m_minimap_mapblock;
|
delete m_minimap_mapblock;
|
||||||
}
|
}
|
||||||
@ -1263,13 +1256,11 @@ bool MapBlockMesh::animate(bool faraway, float time, int crack, u32 daynight_rat
|
|||||||
m_animation_force_timer = myrand_range(5, 100);
|
m_animation_force_timer = myrand_range(5, 100);
|
||||||
|
|
||||||
// Cracks
|
// Cracks
|
||||||
if(crack != m_last_crack)
|
if (crack != m_last_crack) {
|
||||||
{
|
for (auto &crack_material : m_crack_materials) {
|
||||||
for (std::map<std::pair<u8, u32>, std::string>::iterator i =
|
scene::IMeshBuffer *buf = m_mesh[crack_material.first.first]->
|
||||||
m_crack_materials.begin(); i != m_crack_materials.end(); ++i) {
|
getMeshBuffer(crack_material.first.second);
|
||||||
scene::IMeshBuffer *buf = m_mesh[i->first.first]->
|
std::string basename = crack_material.second;
|
||||||
getMeshBuffer(i->first.second);
|
|
||||||
std::string basename = i->second;
|
|
||||||
|
|
||||||
// Create new texture name from original
|
// Create new texture name from original
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
@ -1281,14 +1272,13 @@ bool MapBlockMesh::animate(bool faraway, float time, int crack, u32 daynight_rat
|
|||||||
|
|
||||||
// If the current material is also animated,
|
// If the current material is also animated,
|
||||||
// update animation info
|
// update animation info
|
||||||
std::map<std::pair<u8, u32>, TileLayer>::iterator anim_iter =
|
auto anim_iter = m_animation_tiles.find(crack_material.first);
|
||||||
m_animation_tiles.find(i->first);
|
|
||||||
if (anim_iter != m_animation_tiles.end()){
|
if (anim_iter != m_animation_tiles.end()){
|
||||||
TileLayer &tile = anim_iter->second;
|
TileLayer &tile = anim_iter->second;
|
||||||
tile.texture = new_texture;
|
tile.texture = new_texture;
|
||||||
tile.texture_id = new_texture_id;
|
tile.texture_id = new_texture_id;
|
||||||
// force animation update
|
// force animation update
|
||||||
m_animation_frames[i->first] = -1;
|
m_animation_frames[crack_material.first] = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1296,21 +1286,20 @@ bool MapBlockMesh::animate(bool faraway, float time, int crack, u32 daynight_rat
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Texture animation
|
// Texture animation
|
||||||
for (std::map<std::pair<u8, u32>, TileLayer>::iterator i =
|
for (auto &animation_tile : m_animation_tiles) {
|
||||||
m_animation_tiles.begin(); i != m_animation_tiles.end(); ++i) {
|
const TileLayer &tile = animation_tile.second;
|
||||||
const TileLayer &tile = i->second;
|
|
||||||
// Figure out current frame
|
// Figure out current frame
|
||||||
int frameoffset = m_animation_frame_offsets[i->first];
|
int frameoffset = m_animation_frame_offsets[animation_tile.first];
|
||||||
int frame = (int)(time * 1000 / tile.animation_frame_length_ms
|
int frame = (int)(time * 1000 / tile.animation_frame_length_ms
|
||||||
+ frameoffset) % tile.animation_frame_count;
|
+ frameoffset) % tile.animation_frame_count;
|
||||||
// If frame doesn't change, skip
|
// If frame doesn't change, skip
|
||||||
if(frame == m_animation_frames[i->first])
|
if(frame == m_animation_frames[animation_tile.first])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
m_animation_frames[i->first] = frame;
|
m_animation_frames[animation_tile.first] = frame;
|
||||||
|
|
||||||
scene::IMeshBuffer *buf = m_mesh[i->first.first]->
|
scene::IMeshBuffer *buf = m_mesh[animation_tile.first.first]->
|
||||||
getMeshBuffer(i->first.second);
|
getMeshBuffer(animation_tile.first.second);
|
||||||
|
|
||||||
const FrameSpec &animation_frame = (*tile.frames)[frame];
|
const FrameSpec &animation_frame = (*tile.frames)[frame];
|
||||||
buf->getMaterial().setTexture(0, animation_frame.texture);
|
buf->getMaterial().setTexture(0, animation_frame.texture);
|
||||||
@ -1327,20 +1316,17 @@ bool MapBlockMesh::animate(bool faraway, float time, int crack, u32 daynight_rat
|
|||||||
{
|
{
|
||||||
// Force reload mesh to VBO
|
// Force reload mesh to VBO
|
||||||
if (m_enable_vbo)
|
if (m_enable_vbo)
|
||||||
for (int m = 0; m < MAX_TILE_LAYERS; m++)
|
for (scene::IMesh *m : m_mesh)
|
||||||
m_mesh[m]->setDirty();
|
m->setDirty();
|
||||||
video::SColorf day_color;
|
video::SColorf day_color;
|
||||||
get_sunlight_color(&day_color, daynight_ratio);
|
get_sunlight_color(&day_color, daynight_ratio);
|
||||||
for(std::map<std::pair<u8, u32>, std::map<u32, video::SColor > >::iterator
|
|
||||||
i = m_daynight_diffs.begin();
|
for (auto &daynight_diff : m_daynight_diffs) {
|
||||||
i != m_daynight_diffs.end(); ++i)
|
scene::IMeshBuffer *buf = m_mesh[daynight_diff.first.first]->
|
||||||
{
|
getMeshBuffer(daynight_diff.first.second);
|
||||||
scene::IMeshBuffer *buf = m_mesh[i->first.first]->
|
|
||||||
getMeshBuffer(i->first.second);
|
|
||||||
video::S3DVertex *vertices = (video::S3DVertex *)buf->getVertices();
|
video::S3DVertex *vertices = (video::S3DVertex *)buf->getVertices();
|
||||||
for(std::map<u32, video::SColor >::iterator
|
for (auto j = daynight_diff.second.begin();
|
||||||
j = i->second.begin();
|
j != daynight_diff.second.end(); ++j)
|
||||||
j != i->second.end(); ++j)
|
|
||||||
{
|
{
|
||||||
final_color_blend(&(vertices[j->first].Color),
|
final_color_blend(&(vertices[j->first].Color),
|
||||||
j->second, day_color);
|
j->second, day_color);
|
||||||
@ -1355,11 +1341,11 @@ bool MapBlockMesh::animate(bool faraway, float time, int crack, u32 daynight_rat
|
|||||||
void MapBlockMesh::updateCameraOffset(v3s16 camera_offset)
|
void MapBlockMesh::updateCameraOffset(v3s16 camera_offset)
|
||||||
{
|
{
|
||||||
if (camera_offset != m_camera_offset) {
|
if (camera_offset != m_camera_offset) {
|
||||||
for (u8 layer = 0; layer < 2; layer++) {
|
for (scene::IMesh *layer : m_mesh) {
|
||||||
translateMesh(m_mesh[layer],
|
translateMesh(layer,
|
||||||
intToFloat(m_camera_offset - camera_offset, BS));
|
intToFloat(m_camera_offset - camera_offset, BS));
|
||||||
if (m_enable_vbo) {
|
if (m_enable_vbo) {
|
||||||
m_mesh[layer]->setDirty();
|
layer->setDirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_camera_offset = camera_offset;
|
m_camera_offset = camera_offset;
|
||||||
@ -1394,8 +1380,7 @@ void MeshCollector::append(const TileLayer &layer,
|
|||||||
std::vector<PreMeshBuffer> *buffers = &prebuffers[layernum];
|
std::vector<PreMeshBuffer> *buffers = &prebuffers[layernum];
|
||||||
|
|
||||||
PreMeshBuffer *p = NULL;
|
PreMeshBuffer *p = NULL;
|
||||||
for (u32 i = 0; i < buffers->size(); i++) {
|
for (PreMeshBuffer &pp : *buffers) {
|
||||||
PreMeshBuffer &pp = (*buffers)[i];
|
|
||||||
if (pp.layer != layer)
|
if (pp.layer != layer)
|
||||||
continue;
|
continue;
|
||||||
if (pp.indices.size() + numIndices > 65535)
|
if (pp.indices.size() + numIndices > 65535)
|
||||||
@ -1465,8 +1450,7 @@ void MeshCollector::append(const TileLayer &layer,
|
|||||||
std::vector<PreMeshBuffer> *buffers = &prebuffers[layernum];
|
std::vector<PreMeshBuffer> *buffers = &prebuffers[layernum];
|
||||||
|
|
||||||
PreMeshBuffer *p = NULL;
|
PreMeshBuffer *p = NULL;
|
||||||
for (u32 i = 0; i < buffers->size(); i++) {
|
for (PreMeshBuffer &pp : *buffers) {
|
||||||
PreMeshBuffer &pp = (*buffers)[i];
|
|
||||||
if(pp.layer != layer)
|
if(pp.layer != layer)
|
||||||
continue;
|
continue;
|
||||||
if(pp.indices.size() + numIndices > 65535)
|
if(pp.indices.size() + numIndices > 65535)
|
||||||
@ -1518,8 +1502,8 @@ void MeshCollector::append(const TileLayer &layer,
|
|||||||
void MeshCollector::applyTileColors()
|
void MeshCollector::applyTileColors()
|
||||||
{
|
{
|
||||||
if (m_use_tangent_vertices)
|
if (m_use_tangent_vertices)
|
||||||
for (int layer = 0; layer < MAX_TILE_LAYERS; layer++) {
|
for (auto &prebuffer : prebuffers) {
|
||||||
for (auto &pmb : prebuffers[layer]) {
|
for (PreMeshBuffer &pmb : prebuffer) {
|
||||||
video::SColor tc = pmb.layer.color;
|
video::SColor tc = pmb.layer.color;
|
||||||
if (tc == video::SColor(0xFFFFFFFF))
|
if (tc == video::SColor(0xFFFFFFFF))
|
||||||
continue;
|
continue;
|
||||||
@ -1532,8 +1516,8 @@ void MeshCollector::applyTileColors()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
for (int layer = 0; layer < MAX_TILE_LAYERS; layer++) {
|
for (auto &prebuffer : prebuffers) {
|
||||||
for (auto &pmb : prebuffers[layer]) {
|
for (PreMeshBuffer &pmb : prebuffer) {
|
||||||
video::SColor tc = pmb.layer.color;
|
video::SColor tc = pmb.layer.color;
|
||||||
if (tc == video::SColor(0xFFFFFFFF))
|
if (tc == video::SColor(0xFFFFFFFF))
|
||||||
continue;
|
continue;
|
||||||
|
@ -98,11 +98,6 @@ STATIC_ASSERT(
|
|||||||
//// Mapgen
|
//// Mapgen
|
||||||
////
|
////
|
||||||
|
|
||||||
Mapgen::Mapgen()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Mapgen::Mapgen(int mapgenid, MapgenParams *params, EmergeManager *emerge) :
|
Mapgen::Mapgen(int mapgenid, MapgenParams *params, EmergeManager *emerge) :
|
||||||
gennotify(emerge->gen_notify_on, &emerge->gen_notify_on_deco_ids)
|
gennotify(emerge->gen_notify_on, &emerge->gen_notify_on_deco_ids)
|
||||||
{
|
{
|
||||||
@ -131,11 +126,6 @@ Mapgen::Mapgen(int mapgenid, MapgenParams *params, EmergeManager *emerge) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Mapgen::~Mapgen()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
MapgenType Mapgen::getMapgenType(const std::string &mgname)
|
MapgenType Mapgen::getMapgenType(const std::string &mgname)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i != ARRLEN(g_reg_mapgens); i++) {
|
for (size_t i = 0; i != ARRLEN(g_reg_mapgens); i++) {
|
||||||
@ -283,7 +273,8 @@ s16 Mapgen::findLiquidSurface(v2s16 p2d, s16 ymin, s16 ymax)
|
|||||||
MapNode &n = vm->m_data[i];
|
MapNode &n = vm->m_data[i];
|
||||||
if (ndef->get(n).walkable)
|
if (ndef->get(n).walkable)
|
||||||
return -MAX_MAP_GENERATION_LIMIT;
|
return -MAX_MAP_GENERATION_LIMIT;
|
||||||
else if (ndef->get(n).isLiquid())
|
|
||||||
|
if (ndef->get(n).isLiquid())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
vm->m_area.add_y(em, i, -1);
|
vm->m_area.add_y(em, i, -1);
|
||||||
@ -939,11 +930,6 @@ void MapgenBasic::generateDungeons(s16 max_stone_y,
|
|||||||
//// GenerateNotifier
|
//// GenerateNotifier
|
||||||
////
|
////
|
||||||
|
|
||||||
GenerateNotifier::GenerateNotifier()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
GenerateNotifier::GenerateNotifier(u32 notify_on,
|
GenerateNotifier::GenerateNotifier(u32 notify_on,
|
||||||
std::set<u32> *notify_on_deco_ids)
|
std::set<u32> *notify_on_deco_ids)
|
||||||
{
|
{
|
||||||
|
@ -92,7 +92,7 @@ struct GenNotifyEvent {
|
|||||||
|
|
||||||
class GenerateNotifier {
|
class GenerateNotifier {
|
||||||
public:
|
public:
|
||||||
GenerateNotifier();
|
GenerateNotifier() = default;
|
||||||
GenerateNotifier(u32 notify_on, std::set<u32> *notify_on_deco_ids);
|
GenerateNotifier(u32 notify_on, std::set<u32> *notify_on_deco_ids);
|
||||||
|
|
||||||
void setNotifyOn(u32 notify_on);
|
void setNotifyOn(u32 notify_on);
|
||||||
@ -180,9 +180,9 @@ public:
|
|||||||
BiomeGen *biomegen = nullptr;
|
BiomeGen *biomegen = nullptr;
|
||||||
GenerateNotifier gennotify;
|
GenerateNotifier gennotify;
|
||||||
|
|
||||||
Mapgen();
|
Mapgen() = default;
|
||||||
Mapgen(int mapgenid, MapgenParams *params, EmergeManager *emerge);
|
Mapgen(int mapgenid, MapgenParams *params, EmergeManager *emerge);
|
||||||
virtual ~Mapgen();
|
virtual ~Mapgen() = default;
|
||||||
DISABLE_CLASS_COPY(Mapgen);
|
DISABLE_CLASS_COPY(Mapgen);
|
||||||
|
|
||||||
virtual MapgenType getType() const { return MAPGEN_INVALID; }
|
virtual MapgenType getType() const { return MAPGEN_INVALID; }
|
||||||
|
@ -300,8 +300,8 @@ int MapgenCarpathian::getSpawnLevelAtPoint(v2s16 p)
|
|||||||
s16 level_at_point = terrainLevelAtPoint(p.X, p.Y);
|
s16 level_at_point = terrainLevelAtPoint(p.X, p.Y);
|
||||||
if (level_at_point <= water_level || level_at_point > water_level + 32)
|
if (level_at_point <= water_level || level_at_point > water_level + 32)
|
||||||
return MAX_MAP_GENERATION_LIMIT; // Unsuitable spawn point
|
return MAX_MAP_GENERATION_LIMIT; // Unsuitable spawn point
|
||||||
else
|
|
||||||
return level_at_point;
|
return level_at_point;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ struct MapgenFlatParams : public MapgenParams
|
|||||||
NoiseParams np_cave2;
|
NoiseParams np_cave2;
|
||||||
|
|
||||||
MapgenFlatParams();
|
MapgenFlatParams();
|
||||||
~MapgenFlatParams() {}
|
~MapgenFlatParams() = default;
|
||||||
|
|
||||||
void readParams(const Settings *settings);
|
void readParams(const Settings *settings);
|
||||||
void writeParams(Settings *settings) const;
|
void writeParams(Settings *settings) const;
|
||||||
|
@ -48,7 +48,7 @@ struct MapgenV5Params : public MapgenParams
|
|||||||
NoiseParams np_cavern;
|
NoiseParams np_cavern;
|
||||||
|
|
||||||
MapgenV5Params();
|
MapgenV5Params();
|
||||||
~MapgenV5Params() {}
|
~MapgenV5Params() = default;
|
||||||
|
|
||||||
void readParams(const Settings *settings);
|
void readParams(const Settings *settings);
|
||||||
void writeParams(Settings *settings) const;
|
void writeParams(Settings *settings) const;
|
||||||
|
@ -454,20 +454,21 @@ BiomeV6Type MapgenV6::getBiome(int index, v2s16 p)
|
|||||||
return BT_TUNDRA;
|
return BT_TUNDRA;
|
||||||
}
|
}
|
||||||
|
|
||||||
return BT_NORMAL;
|
|
||||||
} else {
|
|
||||||
if (d > freq_desert)
|
|
||||||
return BT_DESERT;
|
|
||||||
|
|
||||||
if ((spflags & MGV6_BIOMEBLEND) && (d > freq_desert - 0.10) &&
|
|
||||||
((noise2d(p.X, p.Y, seed) + 1.0) > (freq_desert - d) * 20.0))
|
|
||||||
return BT_DESERT;
|
|
||||||
|
|
||||||
if ((spflags & MGV6_JUNGLES) && h > 0.75)
|
|
||||||
return BT_JUNGLE;
|
|
||||||
|
|
||||||
return BT_NORMAL;
|
return BT_NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (d > freq_desert)
|
||||||
|
return BT_DESERT;
|
||||||
|
|
||||||
|
if ((spflags & MGV6_BIOMEBLEND) && (d > freq_desert - 0.10) &&
|
||||||
|
((noise2d(p.X, p.Y, seed) + 1.0) > (freq_desert - d) * 20.0))
|
||||||
|
return BT_DESERT;
|
||||||
|
|
||||||
|
if ((spflags & MGV6_JUNGLES) && h > 0.75)
|
||||||
|
return BT_JUNGLE;
|
||||||
|
|
||||||
|
return BT_NORMAL;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,6 +30,17 @@ const v3s16 g_6dirs[6] =
|
|||||||
v3s16(-1, 0, 0) // left
|
v3s16(-1, 0, 0) // left
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const v3s16 g_7dirs[7] =
|
||||||
|
{
|
||||||
|
v3s16(0,0,1), // back
|
||||||
|
v3s16(0,1,0), // top
|
||||||
|
v3s16(1,0,0), // right
|
||||||
|
v3s16(0,0,-1), // front
|
||||||
|
v3s16(0,-1,0), // bottom
|
||||||
|
v3s16(-1,0,0), // left
|
||||||
|
v3s16(0,0,0), // self
|
||||||
|
};
|
||||||
|
|
||||||
const v3s16 g_26dirs[26] =
|
const v3s16 g_26dirs[26] =
|
||||||
{
|
{
|
||||||
// +right, +top, +back
|
// +right, +top, +back
|
||||||
|
@ -24,6 +24,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
|
|
||||||
extern const v3s16 g_6dirs[6];
|
extern const v3s16 g_6dirs[6];
|
||||||
|
|
||||||
|
extern const v3s16 g_7dirs[7];
|
||||||
|
|
||||||
extern const v3s16 g_26dirs[26];
|
extern const v3s16 g_26dirs[26];
|
||||||
|
|
||||||
// 26th is (0,0,0)
|
// 26th is (0,0,0)
|
||||||
|
Loading…
Reference in New Issue
Block a user