Luanti 5.10.0-dev
 
Loading...
Searching...
No Matches
ClientEnvironment Class Reference

#include <clientenvironment.h>

+ Inheritance diagram for ClientEnvironment:
+ Collaboration diagram for ClientEnvironment:

Public Member Functions

 ClientEnvironment (irr_ptr< ClientMap > map, ITextureSource *texturesource, Client *client)
 
 ~ClientEnvironment ()
 
MapgetMap ()
 
ClientMapgetClientMap ()
 
ClientgetGameDef ()
 
void setScript (ClientScripting *script)
 
void step (f32 dtime)
 
virtual void setLocalPlayer (LocalPlayer *player)
 
LocalPlayergetLocalPlayer () const
 
void addSimpleObject (ClientSimpleObject *simple)
 
GenericCAOgetGenericCAO (u16 id)
 
ClientActiveObjectgetActiveObject (u16 id)
 
u16 addActiveObject (std::unique_ptr< ClientActiveObject > object)
 
void addActiveObject (u16 id, u8 type, const std::string &init_data)
 
void removeActiveObject (u16 id)
 
void processActiveObjectMessage (u16 id, const std::string &data)
 
void damageLocalPlayer (u16 damage, bool handle_hp=true)
 
void getActiveObjects (const v3f &origin, f32 max_d, std::vector< DistanceSortedActiveObject > &dest)
 
bool hasClientEnvEvents () const
 
ClientEnvEvent getClientEnvEvent ()
 
virtual void getSelectedActiveObjects (const core::line3d< f32 > &shootline_on_map, std::vector< PointedThing > &objects, const std::optional< Pointabilities > &pointabilities)
 
const std::set< std::string > & getPlayerNames ()
 
void addPlayerName (const std::string &name)
 
void removePlayerName (const std::string &name)
 
void updateCameraOffset (const v3s16 &camera_offset)
 
v3s16 getCameraOffset () const
 
void updateFrameTime (bool is_paused)
 
u64 getFrameTime () const
 
u64 getFrameTimeDelta () const
 
- 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 ()
 

Private Attributes

irr_ptr< ClientMapm_map
 
LocalPlayerm_local_player = nullptr
 
ITextureSourcem_texturesource
 
Clientm_client
 
ClientScriptingm_script = nullptr
 
client::ActiveObjectMgr m_ao_manager
 
std::vector< ClientSimpleObject * > m_simple_objects
 
std::queue< ClientEnvEventm_client_event_queue
 
IntervalLimiter m_active_object_light_update_interval
 
std::set< std::string > m_player_names
 
v3s16 m_camera_offset
 
u64 m_frame_time = 0
 
u64 m_frame_dtime = 0
 
u64 m_frame_time_pause_accumulator = 0
 

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
 

Constructor & Destructor Documentation

◆ ClientEnvironment()

ClientEnvironment::ClientEnvironment ( irr_ptr< ClientMap > map,
ITextureSource * texturesource,
Client * client )

◆ ~ClientEnvironment()

ClientEnvironment::~ClientEnvironment ( )

References ActiveObjectMgr< T >::clear(), m_ao_manager, m_local_player, m_map, and m_simple_objects.

+ Here is the call graph for this function:

Member Function Documentation

◆ addActiveObject() [1/2]

u16 ClientEnvironment::addActiveObject ( std::unique_ptr< ClientActiveObject > object)

References ClientActiveObject::addToScene(), Environment::getDayNightRatio(), Client::getSceneManager(), m_ao_manager, m_client, m_texturesource, and client::ActiveObjectMgr::registerObject().

Referenced by addActiveObject(), and Client::handleCommand_ActiveObjectRemoveAdd().

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

◆ addActiveObject() [2/2]

void ClientEnvironment::addActiveObject ( u16 id,
u8 type,
const std::string & init_data )

References addActiveObject(), ClientActiveObject::create(), errorstream, getActiveObject(), infostream, m_client, serializeJsonString(), and BaseException::what().

+ Here is the call graph for this function:

◆ addPlayerName()

void ClientEnvironment::addPlayerName ( const std::string & name)
inline

References m_player_names.

Referenced by Client::handleCommand_UpdatePlayerList().

+ Here is the caller graph for this function:

◆ addSimpleObject()

void ClientEnvironment::addSimpleObject ( ClientSimpleObject * simple)

References m_simple_objects.

Referenced by GenericCAO::directReportPunch(), and GenericCAO::processMessage().

+ Here is the caller graph for this function:

◆ damageLocalPlayer()

void ClientEnvironment::damageLocalPlayer ( u16 damage,
bool handle_hp = true )

References CEE_PLAYER_DAMAGE, getLocalPlayer(), LocalPlayer::hp, m_client_event_queue, and ClientEnvEvent::type.

Referenced by step().

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

◆ getActiveObject()

ClientActiveObject * ClientEnvironment::getActiveObject ( u16 id)
inline

References ActiveObjectMgr< T >::getActiveObject(), and m_ao_manager.

Referenced by addActiveObject(), GenericCAO::clearChildAttachments(), getGenericCAO(), GenericCAO::getParent(), Client::handleCommand_PlaySound(), processActiveObjectMessage(), removeActiveObject(), GenericCAO::setAttachment(), Client::step(), and GenericCAO::step().

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

◆ getActiveObjects()

void ClientEnvironment::getActiveObjects ( const v3f & origin,
f32 max_d,
std::vector< DistanceSortedActiveObject > & dest )
inline

References client::ActiveObjectMgr::getActiveObjects(), and m_ao_manager.

Referenced by add_object_boxes().

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

◆ getCameraOffset()

v3s16 ClientEnvironment::getCameraOffset ( ) const
inline

References m_camera_offset.

Referenced by GenericCAO::getPosition(), ParticleSpawner::spawnParticle(), GenericCAO::updateAttachments(), GenericCAO::updateNodePos(), and Particle::updateVertices().

+ Here is the caller graph for this function:

◆ getClientEnvEvent()

ClientEnvEvent ClientEnvironment::getClientEnvEvent ( )

References FATAL_ERROR_IF, and m_client_event_queue.

Referenced by Client::step().

+ Here is the caller graph for this function:

◆ getClientMap()

ClientMap & ClientEnvironment::getClientMap ( )

References m_map.

Referenced by Client::interact(), MapPostFxStep::run(), Client::sendPlayerPos(), Camera::update(), Particle::updateLight(), and Game::updatePointedThing().

+ Here is the caller graph for this function:

◆ getFrameTime()

u64 ClientEnvironment::getFrameTime ( ) const
inline

References m_frame_time.

Referenced by GameGlobalShaderConstantSetter::onSetConstants().

+ Here is the caller graph for this function:

◆ getFrameTimeDelta()

u64 ClientEnvironment::getFrameTimeDelta ( ) const
inline

References m_frame_dtime.

Referenced by GameGlobalShaderConstantSetter::onSetConstants().

+ Here is the caller graph for this function:

◆ getGameDef()

Client * ClientEnvironment::getGameDef ( )
inline

References m_client.

Referenced by SmokePuffCSO::SmokePuffCSO(), ParticleManager::handleParticleEvent(), ParticleSpawner::spawnParticle(), GenericCAO::step(), Particle::step(), and Particle::updateLight().

+ Here is the caller graph for this function:

◆ getGenericCAO()

GenericCAO * ClientEnvironment::getGenericCAO ( u16 id)

References ACTIVEOBJECT_TYPE_GENERIC, getActiveObject(), and ActiveObject::getType().

Referenced by GenericCAO::setChildrenVisible(), and ParticleSpawner::step().

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

◆ getLocalPlayer()

◆ getMap()

Map & ClientEnvironment::getMap ( )
virtual

◆ getPlayerNames()

const std::set< std::string > & ClientEnvironment::getPlayerNames ( )
inline

References m_player_names.

Referenced by Client::getConnectedPlayerNames().

+ Here is the caller graph for this function:

◆ getSelectedActiveObjects()

void ClientEnvironment::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(), client::ActiveObjectMgr::getActiveSelectableObjects(), GenericCAO::getGroups(), ActiveObject::getId(), GenericCAO::getName(), ClientActiveObject::getPosition(), GenericCAO::getProperties(), ClientActiveObject::getSceneNode(), GenericCAO::getSceneNode(), ClientActiveObject::getSelectionBox(), GenericCAO::isPlayer(), m_ao_manager, ObjectProperties::pointable, POINTABLE_NOT, and ObjectProperties::rotate_selectionbox.

+ Here is the call graph for this function:

◆ hasClientEnvEvents()

bool ClientEnvironment::hasClientEnvEvents ( ) const
inline

References m_client_event_queue.

Referenced by Client::step().

+ Here is the caller graph for this function:

◆ processActiveObjectMessage()

void ClientEnvironment::processActiveObjectMessage ( u16 id,
const std::string & data )

References errorstream, getActiveObject(), ActiveObject::getType(), infostream, ClientActiveObject::processMessage(), and BaseException::what().

Referenced by Client::handleCommand_ActiveObjectMessages().

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

◆ removeActiveObject()

void ClientEnvironment::removeActiveObject ( u16 id)

References getActiveObject(), m_ao_manager, and client::ActiveObjectMgr::removeObject().

Referenced by Client::handleCommand_ActiveObjectRemoveAdd().

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

◆ removePlayerName()

void ClientEnvironment::removePlayerName ( const std::string & name)
inline

References m_player_names.

Referenced by Client::handleCommand_UpdatePlayerList().

+ Here is the caller graph for this function:

◆ setLocalPlayer()

void ClientEnvironment::setLocalPlayer ( LocalPlayer * player)
virtual

References FATAL_ERROR_IF, and m_local_player.

Referenced by Client::Client().

+ Here is the caller graph for this function:

◆ setScript()

void ClientEnvironment::setScript ( ClientScripting * script)
inline

References m_script.

Referenced by Client::loadMods().

+ Here is the caller graph for this function:

◆ step()

void ClientEnvironment::step ( f32 dtime)
virtual

Implements Environment.

References LocalPlayer::applyControl(), Profiler::avg(), BS, Client::checkLocalPrivilege(), COLLISION_NODE, CONTENT_AIR, damageLocalPlayer(), encode_light(), ScriptApiClient::environment_step(), final_color_blend(), g_profiler, g_settings, Settings::getBool(), LocalPlayer::getCAO(), Environment::getDayNightRatio(), Client::getEventManager(), GenericCAO::getGroups(), getInteriorLight(), LocalPlayer::getLightPosition(), getLocalPlayer(), Player::getSpeed(), LocalPlayer::gravity, PlayerPhysicsOverride::gravity, ContentFeatures::groups, LocalPlayer::in_liquid, LocalPlayer::in_liquid_stable, LocalPlayer::is_climbing, GenericCAO::isImmortal(), itemgroup_get(), LocalPlayer::light_color, PlayerPhysicsOverride::liquid_fluidity, PlayerPhysicsOverride::liquid_fluidity_smooth, PlayerPhysicsOverride::liquid_sink, m_active_object_light_update_interval, m_ao_manager, m_client, m_map, m_script, m_simple_objects, ClientSimpleObject::m_to_be_removed, Client::modsLoaded(), LocalPlayer::move(), LocalPlayer::move_resistance, Player::movement_gravity, Player::movement_liquid_fluidity, Player::movement_liquid_fluidity_smooth, Player::movement_liquid_sink, MYMAX, MYMIN, IGameDef::ndef(), p(), Player::physics_override, MtEvent::PLAYER_FALLING_DAMAGE, MtEventManager::put(), Player::setSpeed(), client::ActiveObjectMgr::step(), ClientSimpleObject::step(), IntervalLimiter::step(), Environment::stepTimeOfDay(), LocalPlayer::swimming_pitch, LocalPlayer::swimming_vertical, and U16_MAX.

Referenced by Client::step().

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

◆ updateCameraOffset()

void ClientEnvironment::updateCameraOffset ( const v3s16 & camera_offset)
inline

References m_camera_offset.

◆ updateFrameTime()

void ClientEnvironment::updateFrameTime ( bool is_paused)

References porting::getTimeMs(), m_frame_dtime, m_frame_time, m_frame_time_pause_accumulator, and MYMAX.

+ Here is the call graph for this function:

Member Data Documentation

◆ m_active_object_light_update_interval

IntervalLimiter ClientEnvironment::m_active_object_light_update_interval
private

Referenced by step().

◆ m_ao_manager

◆ m_camera_offset

v3s16 ClientEnvironment::m_camera_offset
private

◆ m_client

Client* ClientEnvironment::m_client
private

◆ m_client_event_queue

std::queue<ClientEnvEvent> ClientEnvironment::m_client_event_queue
private

◆ m_frame_dtime

u64 ClientEnvironment::m_frame_dtime = 0
private

◆ m_frame_time

u64 ClientEnvironment::m_frame_time = 0
private

Referenced by getFrameTime(), and updateFrameTime().

◆ m_frame_time_pause_accumulator

u64 ClientEnvironment::m_frame_time_pause_accumulator = 0
private

Referenced by updateFrameTime().

◆ m_local_player

LocalPlayer* ClientEnvironment::m_local_player = nullptr
private

◆ m_map

irr_ptr<ClientMap> ClientEnvironment::m_map
private

◆ m_player_names

std::set<std::string> ClientEnvironment::m_player_names
private

◆ m_script

ClientScripting* ClientEnvironment::m_script = nullptr
private

Referenced by setScript(), and step().

◆ m_simple_objects

std::vector<ClientSimpleObject*> ClientEnvironment::m_simple_objects
private

◆ m_texturesource

ITextureSource* ClientEnvironment::m_texturesource
private

Referenced by addActiveObject().


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