67 u32 active_object_count, u32 active_object_count_wider){};
93 const std::unordered_set<v3s16> &positions,
float dtime_s) {};
99 typedef std::vector<LoadingBlockModifierDef*>
lbm_vector;
100 typedef std::unordered_map<content_t, lbm_vector>
lbm_map;
134 u32 stamp,
float dtime_s);
146 std::unordered_map<std::string, LoadingBlockModifierDef *>
m_lbm_defs;
166 void update(std::vector<PlayerSAO*> &active_players,
167 s16 active_block_range,
168 s16 active_object_range,
169 std::set<v3s16> &blocks_removed,
170 std::set<v3s16> &blocks_added,
171 std::set<v3s16> &extra_blocks_added);
244 bool is_singleplayer);
287 const std::set<u16> ¤t_objects,
288 std::vector<u16> &added_objects);
296 const std::set<u16> ¤t_objects,
297 std::vector<std::pair<bool /* gone? */, u16>> &removed_objects);
306 const core::line3d<f32> &shootline_on_map,
307 std::vector<PointedThing> &objects,
308 const std::optional<Pointabilities> &pointabilities
359 void step(f32 dtime);
380 bool static_exists,
v3s16 static_block=
v3s16(0,0,0));
401 const std::string &savedir,
const Settings &conf);
403 const std::string &savedir,
const Settings &conf);
515 const std::string &data);
ActiveObjectType
Definition activeobject.h:14
Definition serverenvironment.h:164
void clear()
Definition serverenvironment.h:181
void remove(v3s16 p)
Definition serverenvironment.h:185
void update(std::vector< PlayerSAO * > &active_players, s16 active_block_range, s16 active_object_range, std::set< v3s16 > &blocks_removed, std::set< v3s16 > &blocks_added, std::set< v3s16 > &extra_blocks_added)
Definition serverenvironment.cpp:351
std::set< v3s16 > m_forceloaded_list
Definition serverenvironment.h:193
bool contains(v3s16 p) const
Definition serverenvironment.h:173
std::set< v3s16 > m_abm_list
Definition serverenvironment.h:191
std::set< v3s16 > m_list
Definition serverenvironment.h:190
auto size() const
Definition serverenvironment.h:177
Definition serverenvironment.h:41
virtual ~ActiveBlockModifier()=default
virtual void trigger(ServerEnvironment *env, v3s16 p, MapNode n, u32 active_object_count, u32 active_object_count_wider)
Definition serverenvironment.h:66
virtual const std::vector< std::string > & getRequiredNeighbors() const =0
virtual bool getSimpleCatchUp()=0
virtual const std::vector< std::string > & getTriggerContents() const =0
virtual void trigger(ServerEnvironment *env, v3s16 p, MapNode n)
Definition serverenvironment.h:65
ActiveBlockModifier()=default
virtual u32 getTriggerChance()=0
virtual const std::vector< std::string > & getWithoutNeighbors() const =0
virtual float getTriggerInterval()=0
T * getActiveObject(u16 id)
Definition activeobjectmgr.h:48
Definition environment.h:34
Definition serverenvironment.h:97
void addLBM(LoadingBlockModifierDef *lbm_def, IGameDef *gamedef)
Definition serverenvironment.cpp:72
lbm_vector lbm_list
Definition serverenvironment.h:113
const lbm_map::mapped_type * lookup(content_t c) const
Definition serverenvironment.cpp:104
DISABLE_CLASS_COPY(LBMContentMapping)
LBMContentMapping()=default
ALLOW_CLASS_MOVE(LBMContentMapping)
const lbm_vector & getList() const
Definition serverenvironment.h:105
~LBMContentMapping()
Definition serverenvironment.cpp:65
lbm_map map
Definition serverenvironment.h:114
std::unordered_map< content_t, lbm_vector > lbm_map
Definition serverenvironment.h:100
std::vector< LoadingBlockModifierDef * > lbm_vector
Definition serverenvironment.h:99
Definition serverenvironment.h:118
lbm_lookup_map m_lbm_lookup
Definition serverenvironment.h:150
void addLBMDef(LoadingBlockModifierDef *lbm_def)
Definition serverenvironment.cpp:124
void applyLBMs(ServerEnvironment *env, MapBlock *block, u32 stamp, float dtime_s)
Definition serverenvironment.cpp:238
std::string createIntroductionTimesString()
Definition serverenvironment.cpp:216
~LBMManager()
Definition serverenvironment.cpp:115
std::map< u32, LBMContentMapping > lbm_lookup_map
Definition serverenvironment.h:137
lbm_lookup_map::const_iterator getLBMsIntroducedAfter(u32 time)
Definition serverenvironment.h:155
bool m_query_mode
Definition serverenvironment.h:142
void loadIntroductionTimes(const std::string ×, IGameDef *gamedef, u32 now)
Definition serverenvironment.cpp:139
std::unordered_map< std::string, LoadingBlockModifierDef * > m_lbm_defs
Definition serverenvironment.h:146
Definition metricsbackend.h:39
Definition player_sao.h:56
Definition remoteplayer.h:26
Definition serveractiveobject.h:41
Definition serverenvironment.h:219
bool swapNode(v3s16 p, const MapNode &n)
Definition serverenvironment.cpp:1173
void removePlayer(RemotePlayer *player)
Definition serverenvironment.cpp:626
ServerScripting * getScriptIface()
Definition serverenvironment.h:231
IntervalLimiter m_object_management_interval
Definition serverenvironment.h:471
void getAddedActiveObjects(PlayerSAO *playersao, s16 radius, s16 player_radius, const std::set< u16 > ¤t_objects, std::vector< u16 > &added_objects)
Definition serverenvironment.cpp:1743
void init()
Definition serverenvironment.cpp:472
static bool migratePlayersDatabase(const GameParams &game_params, const Settings &cmd_args)
Definition serverenvironment.cpp:2379
void saveMeta()
Definition serverenvironment.cpp:711
IntervalLimiter m_particle_management_interval
Definition serverenvironment.h:504
IntervalLimiter m_active_blocks_mgmt_interval
Definition serverenvironment.h:475
void savePlayer(RemotePlayer *player)
Definition serverenvironment.cpp:659
MetricGaugePtr m_active_block_gauge
Definition serverenvironment.h:511
std::vector< RemotePlayer * > m_players
Definition serverenvironment.h:498
PlayerSAO * loadPlayer(RemotePlayer *player, bool *new_player, session_t peer_id, bool is_singleplayer)
Definition serverenvironment.cpp:670
virtual void getSelectedActiveObjects(const core::line3d< f32 > &shootline_on_map, std::vector< PointedThing > &objects, const std::optional< Pointabilities > &pointabilities)
Definition serverenvironment.cpp:1850
std::unique_ptr< ServerMap > m_map
Definition serverenvironment.h:458
MetricGaugePtr m_active_object_gauge
Definition serverenvironment.h:512
float m_recommended_send_interval
Definition serverenvironment.h:492
void processActiveObjectRemove(ServerActiveObject *obj)
Definition serverenvironment.cpp:2337
server::ActiveObjectMgr m_ao_manager
Definition serverenvironment.h:464
void saveLoadedPlayers(bool force=false)
Definition serverenvironment.cpp:643
OnMapblocksChangedReceiver m_on_mapblocks_changed_receiver
Definition serverenvironment.h:466
float m_max_lag_estimate
Definition serverenvironment.h:495
bool getActiveObjectMessage(ActiveObjectMessage *dest)
Definition serverenvironment.cpp:1840
bool m_meta_loaded
Definition serverenvironment.h:479
void setStaticForActiveObjectsInBlock(v3s16 blockpos, bool static_exists, v3s16 static_block=v3s16(0, 0, 0))
Definition serverenvironment.cpp:1817
u32 addParticleSpawner(float exptime)
Definition serverenvironment.cpp:1685
u32 m_game_time
Definition serverenvironment.h:482
std::queue< ActiveObjectMessage > m_active_object_messages
Definition serverenvironment.h:468
u8 findSunlight(v3s16 pos) const
Definition serverenvironment.cpp:1184
float getMaxLagEstimate() const
Definition serverenvironment.h:364
AuthDatabase * getAuthDatabase()
Definition serverenvironment.h:390
const std::vector< RemotePlayer * > getPlayers() const
Definition serverenvironment.h:384
Server * getGameDef()
Definition serverenvironment.h:234
static AuthDatabase * openAuthDatabase(const std::string &name, const std::string &savedir, const Settings &conf)
Definition serverenvironment.cpp:2466
void removeRemovedObjects()
Definition serverenvironment.cpp:1987
std::unordered_map< u32, float > m_particle_spawners
Definition serverenvironment.h:505
u16 addActiveObjectRaw(std::unique_ptr< ServerActiveObject > object, const StaticObject *from_static, u32 dtime_s)
Definition serverenvironment.cpp:1919
void activateBlock(MapBlock *block, u32 additional_dtime=0)
Definition serverenvironment.cpp:1056
BlockStatus getBlockStatus(v3s16 blockpos)
Definition serverenvironment.cpp:1670
float getSendRecommendedInterval()
Definition serverenvironment.h:237
Map & getMap()
Definition serverenvironment.cpp:578
void deactivateFarObjects(bool force_delete)
Definition serverenvironment.cpp:2154
RemotePlayer * getPlayer(const session_t peer_id)
Definition serverenvironment.cpp:588
void clearObjects(ClearObjectsMode mode)
Definition serverenvironment.cpp:1269
void reportMaxLagEstimate(float f)
Definition serverenvironment.h:363
Server * m_server
Definition serverenvironment.h:462
void deactivateBlocksAndObjects()
Definition serverenvironment.cpp:548
bool setNode(v3s16 p, const MapNode &n)
Definition serverenvironment.cpp:1115
MetricCounterPtr m_step_time_counter
Definition serverenvironment.h:510
void loadDefaultMeta()
called if env_meta.txt doesn't exist (e.g.
Definition serverenvironment.cpp:806
AuthDatabase * m_auth_database
Definition serverenvironment.h:501
bool removePlayerFromDatabase(const std::string &name)
Definition serverenvironment.cpp:638
std::set< v3s16 > * getForceloadedBlocks()
Definition serverenvironment.h:366
ServerActiveObject * getActiveObject(u16 id)
Definition serverenvironment.h:264
void addLoadingBlockModifierDef(LoadingBlockModifierDef *lbm)
Definition serverenvironment.cpp:1110
IntervalLimiter m_active_block_modifier_interval
Definition serverenvironment.h:476
void invalidateActiveObjectObserverCaches()
Definition serverenvironment.cpp:1734
u16 addActiveObject(std::unique_ptr< ServerActiveObject > object)
Definition serverenvironment.cpp:1726
bool removeNode(v3s16 p)
Definition serverenvironment.cpp:1148
LBMManager m_lbm_mgr
Definition serverenvironment.h:490
void getObjectsInsideRadius(std::vector< ServerActiveObject * > &objects, const v3f &pos, float radius, std::function< bool(ServerActiveObject *obj)> include_obj_cb)
Definition serverenvironment.h:339
u32 getPlayerCount() const
Definition serverenvironment.h:385
ActiveBlockList m_active_blocks
Definition serverenvironment.h:473
void loadMeta()
Definition serverenvironment.cpp:739
std::unique_ptr< ServerActiveObject > createSAO(ActiveObjectType type, v3f pos, const std::string &data)
Definition serverenvironment.cpp:2069
bool saveStaticToBlock(v3s16 blockpos, u16 store_id, ServerActiveObject *obj, const StaticObject &s_obj, u32 mod_reason)
Definition serverenvironment.cpp:2308
static PlayerDatabase * openPlayerDatabase(const std::string &name, const std::string &savedir, const Settings &conf)
Definition serverenvironment.cpp:2350
std::vector< ABMWithState > m_abms
Definition serverenvironment.h:489
int m_fast_active_block_divider
Definition serverenvironment.h:474
ServerScripting * m_script
Definition serverenvironment.h:460
u32 m_particle_spawners_id_last_used
Definition serverenvironment.h:506
u32 getGameTime() const
Definition serverenvironment.h:361
ServerEnvironment(std::unique_ptr< ServerMap > map, Server *server, MetricsBackend *mb)
Definition serverenvironment.cpp:455
std::unordered_map< u32, u16 > m_particle_spawner_attachments
Definition serverenvironment.h:507
~ServerEnvironment()
Definition serverenvironment.cpp:557
float m_game_time_fraction_counter
Definition serverenvironment.h:484
void addPlayer(RemotePlayer *player)
Definition serverenvironment.cpp:610
u32 m_last_clear_objects_time
Definition serverenvironment.h:487
void deleteStaticFromBlock(ServerActiveObject *obj, u16 id, u32 mod_reason, bool no_emerge)
Definition serverenvironment.cpp:2283
ServerMap & getServerMap()
Definition serverenvironment.cpp:583
void getObjectsInArea(std::vector< ServerActiveObject * > &objects, const aabb3f &box, std::function< bool(ServerActiveObject *obj)> include_obj_cb)
Definition serverenvironment.h:346
void getRemovedActiveObjects(PlayerSAO *playersao, s16 radius, s16 player_radius, const std::set< u16 > ¤t_objects, std::vector< std::pair< bool, u16 > > &removed_objects)
Definition serverenvironment.cpp:1767
static bool migrateAuthDatabase(const GameParams &game_params, const Settings &cmd_args)
Definition serverenvironment.cpp:2491
void activateObjects(MapBlock *block, u32 dtime_s)
Definition serverenvironment.cpp:2084
float m_send_recommended_timer
Definition serverenvironment.h:470
void deleteParticleSpawner(u32 id, bool remove_from_object=true)
Definition serverenvironment.cpp:1712
PlayerDatabase * m_player_database
Definition serverenvironment.h:500
void addActiveBlockModifier(ActiveBlockModifier *abm)
Definition serverenvironment.cpp:1105
BlockStatus
Definition serverenvironment.h:369
@ BS_EMERGING
Definition serverenvironment.h:371
@ BS_ACTIVE
Definition serverenvironment.h:373
@ BS_LOADED
Definition serverenvironment.h:372
@ BS_UNKNOWN
Definition serverenvironment.h:370
IntervalLimiter m_active_blocks_nodemetadata_interval
Definition serverenvironment.h:477
void step(f32 dtime)
Definition serverenvironment.cpp:1382
Definition servermap.h:44
Definition scripting_server.h:33
Definition settings.h:109
Definition activeobjectmgr.h:15
void getObjectsInArea(const aabb3f &box, std::vector< ServerActiveObject * > &result, std::function< bool(ServerActiveObject *obj)> include_obj_cb)
Definition activeobjectmgr.cpp:134
void getObjectsInsideRadius(const v3f &pos, float radius, std::vector< ServerActiveObject * > &result, std::function< bool(ServerActiveObject *obj)> include_obj_cb)
Definition activeobjectmgr.cpp:116
core::aabbox3d< f32 > aabb3f
Definition irr_aabb3d.h:11
core::vector3d< s16 > v3s16
Definition irr_v3d.h:13
core::vector3df v3f
Definition irr_v3d.h:11
u16 content_t
Definition mapnode.h:22
std::shared_ptr< MetricCounter > MetricCounterPtr
Definition metricsbackend.h:22
std::shared_ptr< MetricGauge > MetricGaugePtr
Definition metricsbackend.h:36
Definition activeobjectmgr.cpp:11
AccessDeniedCode
Definition networkprotocol.h:902
u16 session_t
Definition networkprotocol.h:22
ClearObjectsMode
Definition serverenvironment.h:209
@ CLEAR_OBJECTS_MODE_QUICK
Definition serverenvironment.h:215
@ CLEAR_OBJECTS_MODE_FULL
Definition serverenvironment.h:211
u16 session_t
Definition serverenvironment.h:31
Definition serverenvironment.h:71
ABMWithState(ActiveBlockModifier *abm_)
Definition serverenvironment.cpp:50
float timer
Definition serverenvironment.h:73
ActiveBlockModifier * abm
Definition serverenvironment.h:72
Definition activeobject.h:33
Definition gameparams.h:12
Definition serverenvironment.h:79
std::string name
Definition serverenvironment.h:82
bool run_at_every_load
Definition serverenvironment.h:83
virtual ~LoadingBlockModifierDef()=default
std::vector< std::string > trigger_contents
Definition serverenvironment.h:81
virtual void trigger(ServerEnvironment *env, MapBlock *block, const std::unordered_set< v3s16 > &positions, float dtime_s)
Called to invoke LBM.
Definition serverenvironment.h:92
Definition serverenvironment.h:199
std::unordered_set< v3s16 > modified_blocks
Definition serverenvironment.h:200
void onMapEditEvent(const MapEditEvent &event) override
Definition serverenvironment.cpp:443
bool receiving
Definition serverenvironment.h:201
Definition staticobject.h:17
static std::string p(std::string path)
Definition test_filesys.cpp:53