Luanti 5.10.0-dev
 
Loading...
Searching...
No Matches
ServerEnvironment Class Referencefinal

#include <serverenvironment.h>

+ Inheritance diagram for ServerEnvironment:
+ Collaboration diagram for ServerEnvironment:

Public Types

enum  BlockStatus { BS_UNKNOWN , BS_EMERGING , BS_LOADED , BS_ACTIVE }
 

Public Member Functions

 ServerEnvironment (std::unique_ptr< ServerMap > map, Server *server, MetricsBackend *mb)
 
 ~ServerEnvironment ()
 
void init ()
 
MapgetMap ()
 
ServerMapgetServerMap ()
 
ServerScriptinggetScriptIface ()
 
ServergetGameDef ()
 
float getSendRecommendedInterval ()
 
void saveLoadedPlayers (bool force=false)
 
void savePlayer (RemotePlayer *player)
 
PlayerSAOloadPlayer (RemotePlayer *player, bool *new_player, session_t peer_id, bool is_singleplayer)
 
void addPlayer (RemotePlayer *player)
 
void removePlayer (RemotePlayer *player)
 
bool removePlayerFromDatabase (const std::string &name)
 
void saveMeta ()
 
void loadMeta ()
 
u32 addParticleSpawner (float exptime)
 
u32 addParticleSpawner (float exptime, u16 attached_id)
 
void deleteParticleSpawner (u32 id, bool remove_from_object=true)
 
ServerActiveObjectgetActiveObject (u16 id)
 
u16 addActiveObject (std::unique_ptr< ServerActiveObject > object)
 
void invalidateActiveObjectObserverCaches ()
 
void getAddedActiveObjects (PlayerSAO *playersao, s16 radius, s16 player_radius, const std::set< u16 > &current_objects, std::vector< u16 > &added_objects)
 
void getRemovedActiveObjects (PlayerSAO *playersao, s16 radius, s16 player_radius, const std::set< u16 > &current_objects, std::vector< std::pair< bool, u16 > > &removed_objects)
 
bool getActiveObjectMessage (ActiveObjectMessage *dest)
 
virtual void getSelectedActiveObjects (const core::line3d< f32 > &shootline_on_map, std::vector< PointedThing > &objects, const std::optional< Pointabilities > &pointabilities)
 
void activateBlock (MapBlock *block, u32 additional_dtime=0)
 
void addActiveBlockModifier (ActiveBlockModifier *abm)
 
void addLoadingBlockModifierDef (LoadingBlockModifierDef *lbm)
 
bool setNode (v3s16 p, const MapNode &n)
 
bool removeNode (v3s16 p)
 
bool swapNode (v3s16 p, const MapNode &n)
 
u8 findSunlight (v3s16 pos) const
 
void getObjectsInsideRadius (std::vector< ServerActiveObject * > &objects, const v3f &pos, float radius, std::function< bool(ServerActiveObject *obj)> include_obj_cb)
 
void getObjectsInArea (std::vector< ServerActiveObject * > &objects, const aabb3f &box, std::function< bool(ServerActiveObject *obj)> include_obj_cb)
 
void clearObjects (ClearObjectsMode mode)
 
void deactivateBlocksAndObjects ()
 
void step (f32 dtime)
 
u32 getGameTime () const
 
void reportMaxLagEstimate (float f)
 
float getMaxLagEstimate () const
 
std::set< v3s16 > * getForceloadedBlocks ()
 
BlockStatus getBlockStatus (v3s16 blockpos)
 
void setStaticForActiveObjectsInBlock (v3s16 blockpos, bool static_exists, v3s16 static_block=v3s16(0, 0, 0))
 
RemotePlayergetPlayer (const session_t peer_id)
 
RemotePlayergetPlayer (const std::string &name, bool match_invalid_peer=false)
 
const std::vector< RemotePlayer * > getPlayers () const
 
u32 getPlayerCount () const
 
AuthDatabasegetAuthDatabase ()
 
- Public Member Functions inherited from Environment
 Environment (IGameDef *gamedef)
 
virtual ~Environment ()=default
 
 DISABLE_CLASS_COPY (Environment)
 
u32 getDayNightRatio ()
 
virtual void setTimeOfDay (u32 time)
 
u32 getTimeOfDay ()
 
float getTimeOfDayF ()
 
void stepTimeOfDay (float dtime)
 
void setTimeOfDaySpeed (float speed)
 
void setDayNightRatioOverride (bool enable, u32 value)
 
u32 getDayCount ()
 
bool line_of_sight (v3f pos1, v3f pos2, v3s16 *p=nullptr)
 
void continueRaycast (RaycastState *state, PointedThing *result)
 
IGameDefgetGameDef ()
 

Static Public Member Functions

static bool migratePlayersDatabase (const GameParams &game_params, const Settings &cmd_args)
 
static bool migrateAuthDatabase (const GameParams &game_params, const Settings &cmd_args)
 

Private Member Functions

void loadDefaultMeta ()
 called if env_meta.txt doesn't exist (e.g.
 
u16 addActiveObjectRaw (std::unique_ptr< ServerActiveObject > object, const StaticObject *from_static, u32 dtime_s)
 
void removeRemovedObjects ()
 
void activateObjects (MapBlock *block, u32 dtime_s)
 
void deactivateFarObjects (bool force_delete)
 
void deleteStaticFromBlock (ServerActiveObject *obj, u16 id, u32 mod_reason, bool no_emerge)
 
bool saveStaticToBlock (v3s16 blockpos, u16 store_id, ServerActiveObject *obj, const StaticObject &s_obj, u32 mod_reason)
 
void processActiveObjectRemove (ServerActiveObject *obj)
 
std::unique_ptr< ServerActiveObjectcreateSAO (ActiveObjectType type, v3f pos, const std::string &data)
 

Static Private Member Functions

static PlayerDatabaseopenPlayerDatabase (const std::string &name, const std::string &savedir, const Settings &conf)
 
static AuthDatabaseopenAuthDatabase (const std::string &name, const std::string &savedir, const Settings &conf)
 

Private Attributes

std::unique_ptr< ServerMapm_map
 
ServerScriptingm_script
 
Serverm_server
 
server::ActiveObjectMgr m_ao_manager
 
OnMapblocksChangedReceiver m_on_mapblocks_changed_receiver
 
std::queue< ActiveObjectMessagem_active_object_messages
 
float m_send_recommended_timer = 0.0f
 
IntervalLimiter m_object_management_interval
 
ActiveBlockList m_active_blocks
 
int m_fast_active_block_divider = 1
 
IntervalLimiter m_active_blocks_mgmt_interval
 
IntervalLimiter m_active_block_modifier_interval
 
IntervalLimiter m_active_blocks_nodemetadata_interval
 
bool m_meta_loaded = false
 
u32 m_game_time = 0
 
float m_game_time_fraction_counter = 0.0f
 
u32 m_last_clear_objects_time = 0
 
std::vector< ABMWithStatem_abms
 
LBMManager m_lbm_mgr
 
float m_recommended_send_interval = 0.1f
 
float m_max_lag_estimate = 0.1f
 
std::vector< RemotePlayer * > m_players
 
PlayerDatabasem_player_database = nullptr
 
AuthDatabasem_auth_database = nullptr
 
IntervalLimiter m_particle_management_interval
 
std::unordered_map< u32, float > m_particle_spawners
 
u32 m_particle_spawners_id_last_used = 0
 
std::unordered_map< u32, u16 > m_particle_spawner_attachments
 
MetricCounterPtr m_step_time_counter
 
MetricGaugePtr m_active_block_gauge
 
MetricGaugePtr m_active_object_gauge
 

Additional Inherited Members

- Public Attributes inherited from Environment
u32 m_added_objects
 
- Protected Attributes inherited from Environment
std::atomic< float > m_time_of_day_speed
 
u32 m_time_of_day
 
float m_time_of_day_f
 
float m_time_conversion_skew = 0.0f
 
bool m_enable_day_night_ratio_override = false
 
u32 m_day_night_ratio_override = 0.0f
 
std::atomic< u32 > m_day_count
 
bool m_cache_enable_shaders
 
float m_cache_active_block_mgmt_interval
 
float m_cache_abm_interval
 
float m_cache_nodetimer_interval
 
float m_cache_abm_time_budget
 
IGameDefm_gamedef
 

Member Enumeration Documentation

◆ BlockStatus

Enumerator
BS_UNKNOWN 
BS_EMERGING 
BS_LOADED 
BS_ACTIVE 

Constructor & Destructor Documentation

◆ ServerEnvironment()

ServerEnvironment::ServerEnvironment ( std::unique_ptr< ServerMap > map,
Server * server,
MetricsBackend * mb )

References MetricsBackend::addCounter(), MetricsBackend::addGauge(), m_active_block_gauge, m_active_object_gauge, and m_step_time_counter.

+ Here is the call graph for this function:

◆ ~ServerEnvironment()

ServerEnvironment::~ServerEnvironment ( )

References m_abms, m_active_blocks, m_auth_database, m_map, m_player_database, m_players, and ActiveBlockList::size().

+ Here is the call graph for this function:

Member Function Documentation

◆ activateBlock()

void ServerEnvironment::activateBlock ( MapBlock * block,
u32 additional_dtime = 0 )

References activateObjects(), LBMManager::applyLBMs(), BLOCK_TIMESTAMP_UNDEFINED, StaticObjectList::clearStored(), MapBlock::getTimestamp(), MapBlock::isOrphan(), m_game_time, m_last_clear_objects_time, m_lbm_mgr, m_script, MapBlock::m_static_objects, ScriptApiNode::node_on_timer(), p(), MapBlock::resetUsageTimer(), MapBlock::setTimestampNoChangedFlag(), and MapBlock::step().

Referenced by EmergeThread::finishGen(), step(), TestSAO::testActivate(), and TestSAO::testStaticToFalse().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ activateObjects()

void ServerEnvironment::activateObjects ( MapBlock * block,
u32 dtime_s )
private

References addActiveObjectRaw(), BS, StaticObjectList::clearStored(), createSAO(), errorstream, StaticObjectList::getAllStored(), MapBlock::getPos(), MapBlock::isOrphan(), MapBlock::m_static_objects, MapBlock::onObjectsActivation(), print_hexdump(), StaticObjectList::pushStored(), and verbosestream.

Referenced by activateBlock().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addActiveBlockModifier()

void ServerEnvironment::addActiveBlockModifier ( ActiveBlockModifier * abm)

References m_abms.

◆ addActiveObject()

u16 ServerEnvironment::addActiveObject ( std::unique_ptr< ServerActiveObject > object)

References addActiveObjectRaw(), and Environment::m_added_objects.

Referenced by add_entity(), and loadPlayer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addActiveObjectRaw()

u16 ServerEnvironment::addActiveObjectRaw ( std::unique_ptr< ServerActiveObject > object,
const StaticObject * from_static,
u32 dtime_s )
private

References ScriptApiBase::addObjectReference(), BS, ServerMap::emergeBlock(), errorstream, floatToInt(), getNodeBlockPos(), m_ao_manager, m_map, m_script, MapBlock::m_static_objects, MOD_REASON_ADD_ACTIVE_OBJECT_RAW, MOD_STATE_WRITE_NEEDED, p(), processActiveObjectRemove(), MapBlock::raiseModified(), server::ActiveObjectMgr::registerObject(), server::ActiveObjectMgr::removeObject(), sanity_check, StaticObjectList::setActive(), and warningstream.

Referenced by activateObjects(), and addActiveObject().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addLoadingBlockModifierDef()

void ServerEnvironment::addLoadingBlockModifierDef ( LoadingBlockModifierDef * lbm)

References LBMManager::addLBMDef(), and m_lbm_mgr.

+ Here is the call graph for this function:

◆ addParticleSpawner() [1/2]

u32 ServerEnvironment::addParticleSpawner ( float exptime)

References m_particle_spawners, m_particle_spawners_id_last_used, and PARTICLE_SPAWNER_NO_EXPIRY.

Referenced by Server::addParticleSpawner(), and addParticleSpawner().

+ Here is the caller graph for this function:

◆ addParticleSpawner() [2/2]

u32 ServerEnvironment::addParticleSpawner ( float exptime,
u16 attached_id )

References addParticleSpawner(), getActiveObject(), and m_particle_spawner_attachments.

+ Here is the call graph for this function:

◆ addPlayer()

void ServerEnvironment::addPlayer ( RemotePlayer * player)

References FATAL_ERROR_IF, Player::getName(), RemotePlayer::getPeerId(), getPlayer(), m_players, and PEER_ID_INEXISTENT.

Referenced by loadPlayer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clearObjects()

◆ createSAO()

std::unique_ptr< ServerActiveObject > ServerEnvironment::createSAO ( ActiveObjectType type,
v3f pos,
const std::string & data )
private

References ACTIVEOBJECT_TYPE_LUAENTITY, and warningstream.

Referenced by activateObjects().

+ Here is the caller graph for this function:

◆ deactivateBlocksAndObjects()

void ServerEnvironment::deactivateBlocksAndObjects ( )

References ActiveBlockList::clear(), deactivateFarObjects(), and m_active_blocks.

Referenced by Server::~Server(), and TestSAO::runTests().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deactivateFarObjects()

◆ deleteParticleSpawner()

void ServerEnvironment::deleteParticleSpawner ( u32 id,
bool remove_from_object = true )

References ServerActiveObject::detachParticleSpawner(), getActiveObject(), m_particle_spawner_attachments, and m_particle_spawners.

Referenced by LuaEntitySAO::~LuaEntitySAO(), Server::deleteParticleSpawner(), and PlayerSAO::removingFromEnvironment().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteStaticFromBlock()

void ServerEnvironment::deleteStaticFromBlock ( ServerActiveObject * obj,
u16 id,
u32 mod_reason,
bool no_emerge )
private

References ServerMap::emergeBlock(), errorstream, Map::getBlockNoCreateNoEx(), m_map, ServerActiveObject::m_static_block, ServerActiveObject::m_static_exists, MapBlock::m_static_objects, MOD_REASON_UNKNOWN, MOD_STATE_WRITE_NEEDED, MapBlock::raiseModified(), and StaticObjectList::remove().

Referenced by clearObjects(), deactivateFarObjects(), and removeRemovedObjects().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ findSunlight()

u8 ServerEnvironment::findSunlight ( v3s16 pos) const

References ServerMap::emergeBlock(), NodeDefManager::get(), MapDatabase::getBlockAsInteger(), Map::getNode(), m_map, m_server, IGameDef::ndef(), MapNode::param1, and ContentFeatures::sunlight_propagates.

+ Here is the call graph for this function:

◆ getActiveObject()

ServerActiveObject * ServerEnvironment::getActiveObject ( u16 id)
inline

◆ getActiveObjectMessage()

bool ServerEnvironment::getActiveObjectMessage ( ActiveObjectMessage * dest)

References m_active_object_messages.

Referenced by Server::AsyncRunStep().

+ Here is the caller graph for this function:

◆ getAddedActiveObjects()

void ServerEnvironment::getAddedActiveObjects ( PlayerSAO * playersao,
s16 radius,
s16 player_radius,
const std::set< u16 > & current_objects,
std::vector< u16 > & added_objects )

References BS, server::ActiveObjectMgr::getAddedActiveObjectsAroundPos(), ServerActiveObject::getBasePosition(), Player::getName(), PlayerSAO::getPlayer(), ServerActiveObject::isEffectivelyObservedBy(), and m_ao_manager.

Referenced by Server::SendActiveObjectRemoveAdd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAuthDatabase()

AuthDatabase * ServerEnvironment::getAuthDatabase ( )
inline

References m_auth_database.

Referenced by ModApiAuth::getAuthDb().

+ Here is the caller graph for this function:

◆ getBlockStatus()

ServerEnvironment::BlockStatus ServerEnvironment::getBlockStatus ( v3s16 blockpos)

References BS_ACTIVE, BS_EMERGING, BS_LOADED, BS_UNKNOWN, ActiveBlockList::contains(), Map::getBlockNoCreateNoEx(), ServerMap::isBlockInQueue(), m_active_blocks, and m_map.

+ Here is the call graph for this function:

◆ getForceloadedBlocks()

std::set< v3s16 > * ServerEnvironment::getForceloadedBlocks ( )
inline

◆ getGameDef()

◆ getGameTime()

u32 ServerEnvironment::getGameTime ( ) const
inline

References m_game_time.

Referenced by Server::AsyncRunStep().

+ Here is the caller graph for this function:

◆ getMap()

◆ getMaxLagEstimate()

float ServerEnvironment::getMaxLagEstimate ( ) const
inline

References m_max_lag_estimate.

Referenced by Server::AsyncRunStep(), PlayerSAO::checkMovementCheat(), Server::getStatusString(), and PlayerSAO::step().

+ Here is the caller graph for this function:

◆ getObjectsInArea()

void ServerEnvironment::getObjectsInArea ( std::vector< ServerActiveObject * > & objects,
const aabb3f & box,
std::function< bool(ServerActiveObject *obj)> include_obj_cb )
inline

References server::ActiveObjectMgr::getObjectsInArea(), and m_ao_manager.

+ Here is the call graph for this function:

◆ getObjectsInsideRadius()

void ServerEnvironment::getObjectsInsideRadius ( std::vector< ServerActiveObject * > & objects,
const v3f & pos,
float radius,
std::function< bool(ServerActiveObject *obj)> include_obj_cb )
inline

References server::ActiveObjectMgr::getObjectsInsideRadius(), and m_ao_manager.

Referenced by add_object_boxes(), and getSelectedActiveObjects().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPlayer() [1/2]

RemotePlayer * ServerEnvironment::getPlayer ( const session_t peer_id)

References m_players.

Referenced by Server::addParticleSpawner(), addPlayer(), Server::AsyncRunStep(), ServerInventoryManager::createDetachedInventory(), Server::DeleteClient(), Server::deleteParticleSpawner(), Server::dynamicAddMedia(), Server::emergePlayer(), ServerInventoryManager::getInventory(), PlayerMetaRef::getmeta(), RemoteClient::GetNextBlocks(), Server::getPlayerName(), Server::getPlayerSAO(), Server::handleCommand_ChatMessage(), Server::handleCommand_Damage(), Server::handleCommand_HaveMedia(), Server::handleCommand_Init(), Server::handleCommand_Interact(), Server::handleCommand_InventoryAction(), Server::handleCommand_InventoryFields(), Server::handleCommand_NodeMetaFields(), Server::handleCommand_PlayerItem(), Server::handleCommand_PlayerPos(), ModApiServer::l_remove_player(), Server::notifyPlayer(), Server::playSound(), ServerInventoryManager::removeDetachedInventory(), Server::reportFormspecPrependModified(), Server::reportInventoryFormspecModified(), Server::reportPrivsModified(), Server::SendAddParticleSpawner(), Server::SendChatMessage(), Server::SendMinimapModes(), Server::sendNodeChangePkt(), Server::SendPlayerFormspecPrepend(), Server::SendPlayerFov(), Server::SendPlayerInventoryFormspec(), Server::SendPlayerPrivileges(), Server::SendSpawnParticle(), ServerInventoryManager::setInventoryModified(), Server::showFormspec(), Server::spawnParticle(), Server::StageTwoClientInit(), and ClientInterface::UpdatePlayerList().

+ Here is the caller graph for this function:

◆ getPlayer() [2/2]

RemotePlayer * ServerEnvironment::getPlayer ( const std::string & name,
bool match_invalid_peer = false )

References m_players, and PEER_ID_INEXISTENT.

◆ getPlayerCount()

u32 ServerEnvironment::getPlayerCount ( ) const
inline

References m_players.

Referenced by ModApiEnv::l_get_connected_players(), and Server::SendBlocks().

+ Here is the caller graph for this function:

◆ getPlayers()

const std::vector< RemotePlayer * > ServerEnvironment::getPlayers ( ) const
inline

References m_players.

Referenced by ModApiEnv::l_get_connected_players().

+ Here is the caller graph for this function:

◆ getRemovedActiveObjects()

void ServerEnvironment::getRemovedActiveObjects ( PlayerSAO * playersao,
s16 radius,
s16 player_radius,
const std::set< u16 > & current_objects,
std::vector< std::pair< bool, u16 > > & removed_objects )

References ACTIVEOBJECT_TYPE_PLAYER, BS, FUNCTION_NAME, getActiveObject(), ServerActiveObject::getBasePosition(), Player::getName(), PlayerSAO::getPlayer(), ServerActiveObject::isEffectivelyObservedBy(), ServerActiveObject::isGone(), and warningstream.

Referenced by Server::SendActiveObjectRemoveAdd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getScriptIface()

◆ getSelectedActiveObjects()

void ServerEnvironment::getSelectedActiveObjects ( const core::line3d< f32 > & shootline_on_map,
std::vector< PointedThing > & objects,
const std::optional< Pointabilities > & pointabilities )
virtual

Gets the objects pointed by the shootline as pointed things. If this is a client environment, the local player won't be returned.

Parameters
[in]shootline_on_mapthe shootline for the test in world coordinates
[out]objectsfound objects

Implements Environment.

References boxLineCollision(), BS, UnitSAO::getArmorGroups(), getObjectsInsideRadius(), UnitSAO::getTotalRotation(), ObjectProperties::pointable, POINTABLE_NOT, and ObjectProperties::rotate_selectionbox.

+ Here is the call graph for this function:

◆ getSendRecommendedInterval()

float ServerEnvironment::getSendRecommendedInterval ( )
inline

References m_recommended_send_interval.

Referenced by LuaEntitySAO::sendPosition(), PlayerSAO::step(), and step().

+ Here is the caller graph for this function:

◆ getServerMap()

ServerMap & ServerEnvironment::getServerMap ( )

References m_map.

Referenced by Server::acceptAuth(), ABMHandler::apply(), Server::AsyncRunStep(), Server::findSpawnPos(), Server::init(), Server::rollbackRevertActions(), and EmergeThread::run().

+ Here is the caller graph for this function:

◆ init()

void ServerEnvironment::init ( )

References Map::addEventReceiver(), DIR_DELIM, errorstream, Settings::exists(), Settings::getNoEx(), Settings::getU16NoEx(), Server::getWorldPath(), ScriptApiEnv::has_on_mapblocks_changed(), m_auth_database, m_map, m_on_mapblocks_changed_receiver, m_player_database, m_script, m_server, MAP_BLOCKSIZE, openAuthDatabase(), openPlayerDatabase(), Settings::readConfigFile(), OnMapblocksChangedReceiver::receiving, Settings::set(), Settings::updateConfigFile(), and warningstream.

Referenced by Server::init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ invalidateActiveObjectObserverCaches()

void ServerEnvironment::invalidateActiveObjectObserverCaches ( )

References server::ActiveObjectMgr::invalidateActiveObjectObserverCaches(), and m_ao_manager.

Referenced by Server::AsyncRunStep().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadDefaultMeta()

void ServerEnvironment::loadDefaultMeta ( )
private

called if env_meta.txt doesn't exist (e.g.

new world)

References LBMManager::loadIntroductionTimes(), m_game_time, m_lbm_mgr, and m_server.

Referenced by loadMeta().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadMeta()

void ServerEnvironment::loadMeta ( )

References DIR_DELIM, Settings::exists(), Settings::get(), Settings::getU32(), Settings::getU64(), Server::getWorldPath(), infostream, loadDefaultMeta(), LBMManager::loadIntroductionTimes(), Environment::m_day_count, m_game_time, m_last_clear_objects_time, m_lbm_mgr, m_meta_loaded, m_server, Settings::parseConfigLines(), fs::PathExists(), SANITY_CHECK, and Environment::setTimeOfDay().

Referenced by Server::init(), and TestSAO::runTests().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadPlayer()

PlayerSAO * ServerEnvironment::loadPlayer ( RemotePlayer * player,
bool * new_player,
session_t peer_id,
bool is_singleplayer )

References actionstream, addActiveObject(), addPlayer(), Player::clearHud(), Server::findSpawnPos(), Player::getName(), infostream, PlayerDatabase::loadPlayer(), m_fast_active_block_divider, m_player_database, m_server, objectpos_over_limit(), and RemotePlayer::setModified().

Referenced by Server::emergePlayer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ migrateAuthDatabase()

bool ServerEnvironment::migrateAuthDatabase ( const GameParams & game_params,
const Settings & cmd_args )
static

References actionstream, DIR_DELIM, errorstream, Settings::exists(), Settings::get(), openAuthDatabase(), fs::PathExists(), Settings::readConfigFile(), fs::Rename(), Settings::set(), Settings::updateConfigFile(), warningstream, BaseException::what(), and GameParams::world_path.

Referenced by run_dedicated_server().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ migratePlayersDatabase()

bool ServerEnvironment::migratePlayersDatabase ( const GameParams & game_params,
const Settings & cmd_args )
static

References actionstream, fs::CreateDir(), fs::DeleteSingleFileOrEmptyDirectory(), DIR_DELIM, errorstream, Settings::exists(), PlayerSAO::finalize(), Settings::get(), PlayerDatabase::listPlayers(), PlayerDatabase::loadPlayer(), openPlayerDatabase(), Settings::readConfigFile(), fs::Rename(), PlayerDatabase::savePlayer(), Settings::set(), RemotePlayer::setPlayerSAO(), Settings::updateConfigFile(), BaseException::what(), and GameParams::world_path.

Referenced by run_dedicated_server().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ openAuthDatabase()

AuthDatabase * ServerEnvironment::openAuthDatabase ( const std::string & name,
const std::string & savedir,
const Settings & conf )
staticprivate

References Settings::getNoEx().

Referenced by init(), and migrateAuthDatabase().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ openPlayerDatabase()

PlayerDatabase * ServerEnvironment::openPlayerDatabase ( const std::string & name,
const std::string & savedir,
const Settings & conf )
staticprivate

References DIR_DELIM, and Settings::getNoEx().

Referenced by init(), and migratePlayersDatabase().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ processActiveObjectRemove()

void ServerEnvironment::processActiveObjectRemove ( ServerActiveObject * obj)
private

References ServerActiveObject::isGone(), m_script, ScriptApiBase::removeObjectReference(), and ServerActiveObject::removingFromEnvironment().

Referenced by addActiveObjectRaw(), clearObjects(), deactivateFarObjects(), and removeRemovedObjects().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeNode()

bool ServerEnvironment::removeNode ( v3s16 p)

References NodeDefManager::get(), Map::getNode(), ContentFeatures::has_after_destruct, ContentFeatures::has_on_destruct, m_map, m_script, m_server, IGameDef::ndef(), ScriptApiNode::node_after_destruct(), ScriptApiNode::node_on_destruct(), p(), Map::removeNodeWithEvent(), and ServerMap::updateVManip().

+ Here is the call graph for this function:

◆ removePlayer()

void ServerEnvironment::removePlayer ( RemotePlayer * player)

References m_players.

Referenced by PlayerSAO::unlinkPlayerSessionAndSave().

+ Here is the caller graph for this function:

◆ removePlayerFromDatabase()

bool ServerEnvironment::removePlayerFromDatabase ( const std::string & name)

References m_player_database, and PlayerDatabase::removePlayer().

Referenced by ModApiServer::l_remove_player().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeRemovedObjects()

void ServerEnvironment::removeRemovedObjects ( )
private

References server::ActiveObjectMgr::clearIf(), deleteStaticFromBlock(), ServerMap::emergeBlock(), g_profiler, infostream, ServerActiveObject::isGone(), ServerActiveObject::isPendingRemoval(), m_ao_manager, ServerActiveObject::m_known_by_count, m_map, ServerActiveObject::m_static_block, ServerActiveObject::m_static_exists, MOD_REASON_REMOVE_OBJECTS_REMOVE, processActiveObjectRemove(), SPT_AVG, and warningstream.

Referenced by step().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reportMaxLagEstimate()

void ServerEnvironment::reportMaxLagEstimate ( float f)
inline

References m_max_lag_estimate.

Referenced by Server::AsyncRunStep().

+ Here is the caller graph for this function:

◆ saveLoadedPlayers()

void ServerEnvironment::saveLoadedPlayers ( bool force = false)

References errorstream, m_player_database, m_players, PlayerDatabase::savePlayer(), and BaseException::what().

Referenced by Server::~Server(), and Server::AsyncRunStep().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveMeta()

void ServerEnvironment::saveMeta ( )

References LBMManager::createIntroductionTimesString(), DIR_DELIM, Environment::getTimeOfDay(), Server::getWorldPath(), infostream, Environment::m_day_count, m_game_time, m_last_clear_objects_time, m_lbm_mgr, m_meta_loaded, m_server, fs::safeWriteToFile(), Settings::set(), Settings::setU64(), and Settings::writeLines().

Referenced by Server::~Server(), and Server::AsyncRunStep().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ savePlayer()

void ServerEnvironment::savePlayer ( RemotePlayer * player)

References errorstream, Player::getName(), m_player_database, PlayerDatabase::savePlayer(), and BaseException::what().

Referenced by PlayerSAO::unlinkPlayerSessionAndSave().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveStaticToBlock()

bool ServerEnvironment::saveStaticToBlock ( v3s16 blockpos,
u16 store_id,
ServerActiveObject * obj,
const StaticObject & s_obj,
u32 mod_reason )
private

References ServerMap::emergeBlock(), errorstream, m_map, ServerActiveObject::m_static_block, ServerActiveObject::m_static_exists, and MapBlock::saveStaticObject().

Referenced by deactivateFarObjects().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setNode()

bool ServerEnvironment::setNode ( v3s16 p,
const MapNode & n )

◆ setStaticForActiveObjectsInBlock()

void ServerEnvironment::setStaticForActiveObjectsInBlock ( v3s16 blockpos,
bool static_exists,
v3s16 static_block = v3s16(0,0,0) )

References errorstream, ActiveObjectMgr< T >::getActiveObject(), StaticObjectList::getAllActives(), Map::getBlockNoCreateNoEx(), m_ao_manager, m_map, ServerActiveObject::m_static_block, ServerActiveObject::m_static_exists, and MapBlock::m_static_objects.

+ Here is the call graph for this function:

◆ step()

void ServerEnvironment::step ( f32 dtime)
virtual

Implements Environment.

References activateBlock(), ABMHandler::apply(), Profiler::avg(), BS, deactivateFarObjects(), ScriptApiEnv::environment_Step(), g_profiler, g_settings, Map::getBlockNoCreateNoEx(), ServerMap::getBlockOrEmerge(), MapBlock::getDiskTimestamp(), Settings::getFloat(), Settings::getS16(), getSendRecommendedInterval(), TimeTaker::getTimerTime(), MapBlock::getTimestamp(), porting::getTimeUs(), MetricCounter::increment(), ActiveBlockList::m_abm_list, m_abms, m_active_block_gauge, m_active_block_modifier_interval, m_active_blocks, m_active_blocks_mgmt_interval, m_active_blocks_nodemetadata_interval, m_active_object_gauge, m_active_object_messages, m_ao_manager, Environment::m_cache_abm_interval, Environment::m_cache_abm_time_budget, Environment::m_cache_active_block_mgmt_interval, Environment::m_cache_nodetimer_interval, m_fast_active_block_divider, m_game_time, m_game_time_fraction_counter, ActiveBlockList::m_list, m_map, m_object_management_interval, m_on_mapblocks_changed_receiver, m_particle_management_interval, m_particle_spawners, m_players, m_recommended_send_interval, m_script, m_send_recommended_timer, m_server, m_step_time_counter, MOD_REASON_BLOCK_EXPIRED, MOD_STATE_WRITE_AT_UNLOAD, OnMapblocksChangedReceiver::modified_blocks, ScriptApiNode::node_on_timer(), ScriptApiEnv::on_mapblocks_changed(), p(), PARTICLE_SPAWNER_NO_EXPIRY, PEER_ID_INEXISTENT, MapBlock::raiseModified(), OnMapblocksChangedReceiver::receiving, ActiveBlockList::remove(), removeRemovedObjects(), MapBlock::resetUsageTimer(), Server::sendDetachedInventories(), Server::SendInventory(), MetricGauge::set(), MapBlock::setTimestamp(), MapBlock::setTimestampNoChangedFlag(), ActiveBlockList::size(), SPT_AVG, IntervalLimiter::step(), MapBlock::step(), server::ActiveObjectMgr::step(), ServerScripting::stepAsync(), Environment::stepTimeOfDay(), TimeTaker::stop(), ActiveBlockList::update(), and warningstream.

Referenced by Server::AsyncRunStep(), TestSAO::testActivate(), TestSAO::testNotSaved(), TestSAO::testStaticSave(), TestSAO::testStaticToFalse(), and TestSAO::testStaticToTrue().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ swapNode()

bool ServerEnvironment::swapNode ( v3s16 p,
const MapNode & n )

References Map::addNodeWithEvent(), m_map, p(), and ServerMap::updateVManip().

+ Here is the call graph for this function:

Member Data Documentation

◆ m_abms

std::vector<ABMWithState> ServerEnvironment::m_abms
private

◆ m_active_block_gauge

MetricGaugePtr ServerEnvironment::m_active_block_gauge
private

Referenced by ServerEnvironment(), and step().

◆ m_active_block_modifier_interval

IntervalLimiter ServerEnvironment::m_active_block_modifier_interval
private

Referenced by step().

◆ m_active_blocks

◆ m_active_blocks_mgmt_interval

IntervalLimiter ServerEnvironment::m_active_blocks_mgmt_interval
private

Referenced by step().

◆ m_active_blocks_nodemetadata_interval

IntervalLimiter ServerEnvironment::m_active_blocks_nodemetadata_interval
private

Referenced by step().

◆ m_active_object_gauge

MetricGaugePtr ServerEnvironment::m_active_object_gauge
private

Referenced by ServerEnvironment(), and step().

◆ m_active_object_messages

std::queue<ActiveObjectMessage> ServerEnvironment::m_active_object_messages
private

Referenced by getActiveObjectMessage(), and step().

◆ m_ao_manager

◆ m_auth_database

AuthDatabase* ServerEnvironment::m_auth_database = nullptr
private

◆ m_fast_active_block_divider

int ServerEnvironment::m_fast_active_block_divider = 1
private

Referenced by loadPlayer(), and step().

◆ m_game_time

u32 ServerEnvironment::m_game_time = 0
private

◆ m_game_time_fraction_counter

float ServerEnvironment::m_game_time_fraction_counter = 0.0f
private

Referenced by step().

◆ m_last_clear_objects_time

u32 ServerEnvironment::m_last_clear_objects_time = 0
private

◆ m_lbm_mgr

LBMManager ServerEnvironment::m_lbm_mgr
private

◆ m_map

◆ m_max_lag_estimate

float ServerEnvironment::m_max_lag_estimate = 0.1f
private

◆ m_meta_loaded

bool ServerEnvironment::m_meta_loaded = false
private

Referenced by loadMeta(), and saveMeta().

◆ m_object_management_interval

IntervalLimiter ServerEnvironment::m_object_management_interval
private

Referenced by step().

◆ m_on_mapblocks_changed_receiver

OnMapblocksChangedReceiver ServerEnvironment::m_on_mapblocks_changed_receiver
private

Referenced by init(), and step().

◆ m_particle_management_interval

IntervalLimiter ServerEnvironment::m_particle_management_interval
private

Referenced by step().

◆ m_particle_spawner_attachments

std::unordered_map<u32, u16> ServerEnvironment::m_particle_spawner_attachments
private

◆ m_particle_spawners

std::unordered_map<u32, float> ServerEnvironment::m_particle_spawners
private

◆ m_particle_spawners_id_last_used

u32 ServerEnvironment::m_particle_spawners_id_last_used = 0
private

Referenced by addParticleSpawner().

◆ m_player_database

PlayerDatabase* ServerEnvironment::m_player_database = nullptr
private

◆ m_players

std::vector<RemotePlayer*> ServerEnvironment::m_players
private

◆ m_recommended_send_interval

float ServerEnvironment::m_recommended_send_interval = 0.1f
private

Referenced by getSendRecommendedInterval(), and step().

◆ m_script

◆ m_send_recommended_timer

float ServerEnvironment::m_send_recommended_timer = 0.0f
private

Referenced by step().

◆ m_server

Server* ServerEnvironment::m_server
private

◆ m_step_time_counter

MetricCounterPtr ServerEnvironment::m_step_time_counter
private

Referenced by ServerEnvironment(), and step().


The documentation for this class was generated from the following files: