#include "database.h"
#include "database-dummy.h"
#include "database-sqlite3.h"
+#include "script/scripting_server.h"
#include <deque>
#include <queue>
#if USE_LEVELDB
Map::Map(std::ostream &dout, IGameDef *gamedef):
m_dout(dout),
m_gamedef(gamedef),
- m_sector_cache(NULL),
- m_nodedef(gamedef->ndef()),
- m_transforming_liquid_loop_count_multiplier(1.0f),
- m_unprocessed_count(0),
- m_inc_trending_up_start_time(0),
- m_queue_size_timer_started(false)
+ m_nodedef(gamedef->ndef())
{
}
return succeeded;
}
-bool Map::getDayNightDiff(v3s16 blockpos)
-{
- try{
- v3s16 p = blockpos + v3s16(0,0,0);
- MapBlock *b = getBlockNoCreate(p);
- if(b->getDayNightDiff())
- return true;
- }
- catch(InvalidPositionException &e){}
- // Leading edges
- try{
- v3s16 p = blockpos + v3s16(-1,0,0);
- MapBlock *b = getBlockNoCreate(p);
- if(b->getDayNightDiff())
- return true;
- }
- catch(InvalidPositionException &e){}
- try{
- v3s16 p = blockpos + v3s16(0,-1,0);
- MapBlock *b = getBlockNoCreate(p);
- if(b->getDayNightDiff())
- return true;
- }
- catch(InvalidPositionException &e){}
- try{
- v3s16 p = blockpos + v3s16(0,0,-1);
- MapBlock *b = getBlockNoCreate(p);
- if(b->getDayNightDiff())
- return true;
- }
- catch(InvalidPositionException &e){}
- // Trailing edges
- try{
- v3s16 p = blockpos + v3s16(1,0,0);
- MapBlock *b = getBlockNoCreate(p);
- if(b->getDayNightDiff())
- return true;
- }
- catch(InvalidPositionException &e){}
- try{
- v3s16 p = blockpos + v3s16(0,1,0);
- MapBlock *b = getBlockNoCreate(p);
- if(b->getDayNightDiff())
- return true;
- }
- catch(InvalidPositionException &e){}
- try{
- v3s16 p = blockpos + v3s16(0,0,1);
- MapBlock *b = getBlockNoCreate(p);
- if(b->getDayNightDiff())
- return true;
- }
- catch(InvalidPositionException &e){}
-
- return false;
-}
-
struct TimeOrderedMapBlock {
MapSector *sect;
MapBlock *block;
return m_transforming_liquid.size();
}
-void Map::transformLiquids(std::map<v3s16, MapBlock*> &modified_blocks)
+void Map::transformLiquids(std::map<v3s16, MapBlock*> &modified_blocks,
+ ServerEnvironment *env)
{
DSTACK(FUNCTION_NAME);
//TimeTaker timer("transformLiquids()");
// set the liquid level and flow bit to 0
n0.param2 = ~(LIQUID_LEVEL_MASK | LIQUID_FLOW_DOWN_MASK);
}
+
+ // change the node.
n0.setContent(new_node_content);
+ // on_flood() the node
+ if (floodable_node != CONTENT_AIR) {
+ if (env->getScriptIface()->node_on_flood(p0, n00, n0))
+ continue;
+ }
+
// Ignore light (because calling voxalgo::update_lighting_nodes)
n0.setLight(LIGHTBANK_DAY, 0, m_nodedef);
n0.setLight(LIGHTBANK_NIGHT, 0, m_nodedef);
time_until_purge *= 1000; // seconds -> milliseconds
- u32 curr_time = getTime(PRECISION_MILLI);
+ u64 curr_time = porting::getTimeMs();
u32 prev_unprocessed = m_unprocessed_count;
m_unprocessed_count = m_transforming_liquid.size();
EmergeManager *emerge):
Map(dout_server, gamedef),
settings_mgr(g_settings, savedir + DIR_DELIM + "map_meta.txt"),
- m_emerge(emerge),
- m_map_metadata_changed(true)
+ m_emerge(emerge)
{
verbosestream<<FUNCTION_NAME<<std::endl;
return getMapgenParams()->water_level;
}
+bool ServerMap::saoPositionOverLimit(const v3f &p)
+{
+ return getMapgenParams()->saoPosOverLimit(p);
+}
+
bool ServerMap::blockpos_over_mapgen_limit(v3s16 p)
{
const s16 mapgen_limit_bp = rangelim(
return block;
}
-void ServerMap::prepareBlock(MapBlock *block) {
-}
-
// N.B. This requires no synchronization, since data will not be modified unless
// the VoxelManipulator being updated belongs to the same thread.
void ServerMap::updateVManip(v3s16 pos)
}
#endif
-Database *ServerMap::createDatabase(
+MapDatabase *ServerMap::createDatabase(
const std::string &name,
const std::string &savedir,
Settings &conf)
{
if (name == "sqlite3")
- return new Database_SQLite3(savedir);
+ return new MapDatabaseSQLite3(savedir);
if (name == "dummy")
return new Database_Dummy();
#if USE_LEVELDB
return new Database_Redis(conf);
#endif
#if USE_POSTGRESQL
- else if (name == "postgresql")
- return new Database_PostgreSQL(conf);
+ else if (name == "postgresql") {
+ std::string connect_string = "";
+ conf.getNoEx("pgsql_connection", connect_string);
+ return new MapDatabasePostgreSQL(connect_string);
+ }
#endif
else
throw BaseException(std::string("Database backend ") + name + " not supported.");
return saveBlock(block, dbase);
}
-bool ServerMap::saveBlock(MapBlock *block, Database *db)
+bool ServerMap::saveBlock(MapBlock *block, MapDatabase *db)
{
v3s16 p3d = block->getPos();
out<<"ServerMap: ";
}
+bool ServerMap::repairBlockLight(v3s16 blockpos,
+ std::map<v3s16, MapBlock *> *modified_blocks)
+{
+ MapBlock *block = emergeBlock(blockpos, false);
+ if (!block || !block->isGenerated())
+ return false;
+ voxalgo::repair_block_light(this, block, modified_blocks);
+ return true;
+}
+
MMVManip::MMVManip(Map *map):
VoxelManipulator(),
- m_is_dirty(false),
- m_create_area(false),
m_map(map)
{
}