diff --git a/source/main/CMakeLists.txt b/source/main/CMakeLists.txt index df30391dda..dc1fc56c17 100644 --- a/source/main/CMakeLists.txt +++ b/source/main/CMakeLists.txt @@ -33,14 +33,14 @@ set(SOURCE_FILES gfx/DustPool.{h,cpp} gfx/EnvironmentMap.{h,cpp} gfx/GfxActor.{h,cpp} - gfx/GfxData.h + gfx/GfxData.{h,cpp} gfx/GfxScene.{h,cpp} gfx/HydraxWater.{h,cpp} gfx/IWater.h gfx/MovableText.{h,cpp} gfx/Renderdash.{h,cpp} gfx/ShadowManager.{h,cpp} - gfx/SimBuffers.h + gfx/SimBuffers.{h,cpp} gfx/Skidmark.{h,cpp} gfx/SkyManager.{h,cpp} gfx/SkyXManager.{h,cpp} @@ -156,7 +156,7 @@ set(SOURCE_FILES physics/Differentials.{h,cpp} physics/Savegame.cpp physics/SimConstants.h - physics/SimData.h + physics/SimData.{h,cpp} physics/SlideNode.{h,cpp} physics/air/AeroEngine.h physics/air/AirBrake.{h,cpp} diff --git a/source/main/ForwardDeclarations.h b/source/main/ForwardDeclarations.h index f3cdb5df2c..7dcd03cdf2 100644 --- a/source/main/ForwardDeclarations.h +++ b/source/main/ForwardDeclarations.h @@ -27,6 +27,9 @@ #include "RefCountingObjectPtr.h" +#include +#include + #pragma once namespace RoR @@ -177,6 +180,8 @@ namespace RoR typedef RefCountingObjectPtr TerrainPtr; typedef RefCountingObjectPtr VehicleAIPtr; + typedef std::vector ActorPtrVec; + namespace GUI { class ConsoleView; diff --git a/source/main/GameContext.cpp b/source/main/GameContext.cpp index 29d341a8a1..5f2ccf0e9d 100644 --- a/source/main/GameContext.cpp +++ b/source/main/GameContext.cpp @@ -49,6 +49,16 @@ using namespace RoR; +GameContext::GameContext() +{ + // Constructs `ActorPtr` - doesn't compile without `#include Actor.h` - not pretty if in header (even if auto-generated by C++). +} + +GameContext::~GameContext() +{ + // Destructs `ActorPtr` - doesn't compile without `#include Actor.h` - not pretty if in header (even if auto-generated by C++). +} + // -------------------------------- // Message queue @@ -766,6 +776,8 @@ void GameContext::OnLoaderGuiApply(LoaderType type, CacheEntryPtr entry, std::st } } +void GameContext::SetPrevPlayerActor(ActorPtr actor) { m_prev_player_actor = actor; } + // -------------------------------- // Characters diff --git a/source/main/GameContext.h b/source/main/GameContext.h index 603376468f..e991f255a7 100644 --- a/source/main/GameContext.h +++ b/source/main/GameContext.h @@ -25,7 +25,6 @@ #pragma once -#include "Actor.h" #include "ActorManager.h" #include "CacheSystem.h" #include "CharacterFactory.h" @@ -98,6 +97,9 @@ class GameContext friend class AppContext; public: + GameContext(); + ~GameContext(); + /// @name Message queue /// @{ @@ -132,7 +134,7 @@ class GameContext const ActorPtr& GetPlayerActor() { return m_player_actor; } const ActorPtr& GetPrevPlayerActor() { return m_prev_player_actor; } const ActorPtr& GetLastSpawnedActor() { return m_last_spawned_actor; } //!< Last actor spawned by user and still alive. - void SetPrevPlayerActor(ActorPtr actor) { m_prev_player_actor = actor; } + void SetPrevPlayerActor(ActorPtr actor); void ChangePlayerActor(ActorPtr actor); void ShowLoaderGUI(int type, const Ogre::String& instance, const Ogre::String& box); @@ -188,12 +190,12 @@ class GameContext // Actors (physics and netcode) ActorManager m_actor_manager; - ActorPtr m_player_actor = nullptr; //!< Actor (vehicle or machine) mounted and controlled by player - ActorPtr m_prev_player_actor = nullptr; //!< Previous actor (vehicle or machine) mounted and controlled by player - ActorPtr m_last_spawned_actor = nullptr; //!< Last actor spawned by user and still alive. + ActorPtr m_player_actor; //!< Actor (vehicle or machine) mounted and controlled by player + ActorPtr m_prev_player_actor; //!< Previous actor (vehicle or machine) mounted and controlled by player + ActorPtr m_last_spawned_actor; //!< Last actor spawned by user and still alive. - CacheEntryPtr m_last_cache_selection = nullptr; //!< Vehicle/load - CacheEntryPtr m_last_skin_selection = nullptr; + CacheEntryPtr m_last_cache_selection; //!< Vehicle/load + CacheEntryPtr m_last_skin_selection; Ogre::String m_last_section_config; ActorSpawnRequest m_current_selection; //!< Context of the loader UI CacheEntryPtr m_dummy_cache_selection; diff --git a/source/main/audio/SoundScriptManager.h b/source/main/audio/SoundScriptManager.h index c596ac37c2..fe557fe5ab 100644 --- a/source/main/audio/SoundScriptManager.h +++ b/source/main/audio/SoundScriptManager.h @@ -23,7 +23,6 @@ #pragma once -#include "Actor.h" #include "AngelScriptBindings.h" #include "Application.h" #include "RefCountingObjectPtr.h" diff --git a/source/main/gameplay/Character.cpp b/source/main/gameplay/Character.cpp index 166599230d..087dd6c61a 100644 --- a/source/main/gameplay/Character.cpp +++ b/source/main/gameplay/Character.cpp @@ -544,6 +544,8 @@ void Character::SetActorCoupling(bool enabled, ActorPtr actor) #endif // USE_SOCKETW } +ActorPtr Character::GetActorCoupling() { return m_actor_coupling; } + // -------------------------------- // GfxCharacter diff --git a/source/main/gameplay/Character.h b/source/main/gameplay/Character.h index 61873e1987..253c27cace 100644 --- a/source/main/gameplay/Character.h +++ b/source/main/gameplay/Character.h @@ -21,7 +21,6 @@ #pragma once -#include "Actor.h" #include "ForwardDeclarations.h" #include "SurveyMapEntity.h" @@ -53,7 +52,7 @@ class Character std::string const & GetAnimName() const { return m_anim_name; } float GetAnimTime() const { return m_anim_time; } Ogre::Radian getRotation() const { return m_character_rotation; } - ActorPtr GetActorCoupling() { return m_actor_coupling; } + ActorPtr GetActorCoupling(); void setColour(int color) { this->m_color_number = color; } Ogre::Vector3 getPosition(); void setPosition(Ogre::Vector3 position); diff --git a/source/main/gameplay/CharacterFactory.cpp b/source/main/gameplay/CharacterFactory.cpp index 78a2e60665..05c980685d 100644 --- a/source/main/gameplay/CharacterFactory.cpp +++ b/source/main/gameplay/CharacterFactory.cpp @@ -21,6 +21,7 @@ #include "CharacterFactory.h" +#include "Actor.h" #include "Application.h" #include "Character.h" #include "GfxScene.h" diff --git a/source/main/gameplay/EngineSim.h b/source/main/gameplay/EngineSim.h index aa5aee020d..2fe04c68e0 100644 --- a/source/main/gameplay/EngineSim.h +++ b/source/main/gameplay/EngineSim.h @@ -22,7 +22,6 @@ #pragma once #include "Application.h" -#include "Actor.h" namespace RoR { diff --git a/source/main/gameplay/RepairMode.cpp b/source/main/gameplay/RepairMode.cpp index 65b9f5882b..b7552fcad0 100644 --- a/source/main/gameplay/RepairMode.cpp +++ b/source/main/gameplay/RepairMode.cpp @@ -21,6 +21,7 @@ #include "RepairMode.h" +#include "Actor.h" #include "GameContext.h" #include "InputEngine.h" diff --git a/source/main/gameplay/SceneMouse.h b/source/main/gameplay/SceneMouse.h index cacdc95299..f246823c07 100644 --- a/source/main/gameplay/SceneMouse.h +++ b/source/main/gameplay/SceneMouse.h @@ -28,7 +28,6 @@ #include "Application.h" #include "SimData.h" -#include #include #include diff --git a/source/main/gfx/EnvironmentMap.h b/source/main/gfx/EnvironmentMap.h index 64e1122267..b9a3f8f7c3 100644 --- a/source/main/gfx/EnvironmentMap.h +++ b/source/main/gfx/EnvironmentMap.h @@ -44,8 +44,6 @@ class GfxEnvmap static const unsigned int NUM_FACES = 6; - void InitEnvMap(Ogre::Vector3 center); - Ogre::Camera* m_cameras[NUM_FACES]; Ogre::RenderTarget* m_render_targets[NUM_FACES]; Ogre::TexturePtr m_rtt_texture; diff --git a/source/main/gfx/GfxActor.cpp b/source/main/gfx/GfxActor.cpp index d9f3e5e329..e491dc7fbf 100644 --- a/source/main/gfx/GfxActor.cpp +++ b/source/main/gfx/GfxActor.cpp @@ -194,6 +194,11 @@ RoR::GfxActor::~GfxActor() } } +ActorPtr RoR::GfxActor::GetActor() +{ + return m_actor; +} + void RoR::GfxActor::SetMaterialFlareOn(int flare_index, bool state_on) { for (FlareMaterial& entry: m_flare_materials) diff --git a/source/main/gfx/GfxActor.h b/source/main/gfx/GfxActor.h index 734df462e1..b748f8bd25 100644 --- a/source/main/gfx/GfxActor.h +++ b/source/main/gfx/GfxActor.h @@ -26,7 +26,6 @@ #pragma once -#include "Actor.h" #include "AutoPilot.h" #include "Differentials.h" #include "ForwardDeclarations.h" @@ -138,7 +137,7 @@ class GfxActor VideoCamState GetVideoCamState() const { return m_vidcam_state; } DebugViewType GetDebugView() const { return m_debug_view; } Ogre::String GetResourceGroup() { return m_custom_resource_group; } - ActorPtr GetActor() { return m_actor; } // Watch out for multithreading with this! + ActorPtr GetActor(); // Watch out for multithreading with this! Ogre::TexturePtr GetHelpTex() { return m_help_tex; } Ogre::MaterialPtr GetHelpMat() { return m_help_mat; } int FetchNumBeams() const ; diff --git a/source/main/gfx/GfxData.cpp b/source/main/gfx/GfxData.cpp new file mode 100644 index 0000000000..12c9259fc8 --- /dev/null +++ b/source/main/gfx/GfxData.cpp @@ -0,0 +1,36 @@ +/* + This source file is part of Rigs of Rods + Copyright 2005-2012 Pierre-Michel Ricordel + Copyright 2007-2012 Thomas Fischer + Copyright 2013-2023 Petr Ohlidal + + For more information, see http://www.rigsofrods.org/ + + Rigs of Rods is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License version 3, as + published by the Free Software Foundation. + + Rigs of Rods is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Rigs of Rods. If not, see . +*/ + +#include "SimBuffers.h" + +#include "Actor.h" + +using namespace RoR; + +BeamGfx::BeamGfx() +{ + // Constructs `ActorPtr` - doesn't compile without `#include Actor.h` - not pretty if in header (even if auto-generated by C++). +} + +BeamGfx::~BeamGfx() +{ + // Destructs `ActorPtr` - doesn't compile without `#include Actor.h` - not pretty if in header (even if auto-generated by C++). +} diff --git a/source/main/gfx/GfxData.h b/source/main/gfx/GfxData.h index 0f3219d48c..3b9cedf443 100644 --- a/source/main/gfx/GfxData.h +++ b/source/main/gfx/GfxData.h @@ -265,6 +265,9 @@ struct NodeGfx /// Visuals of softbody beam (`beam_t` struct); Partially updated along with SimBuffer struct BeamGfx { + BeamGfx(); + ~BeamGfx(); + // We don't keep pointer to the Ogre::Entity - we rely on the SceneNode keeping it attached all the time. Ogre::SceneNode* rod_scenenode = nullptr; uint16_t rod_beam_index = 0; @@ -272,7 +275,7 @@ struct BeamGfx NodeNum_t rod_node1 = NODENUM_INVALID; //!< Node index - may change during simulation! NodeNum_t rod_node2 = NODENUM_INVALID; //!< Node index - may change during simulation! - ActorPtr rod_target_actor = nullptr; + ActorPtr rod_target_actor; bool rod_is_visible = false; }; diff --git a/source/main/gfx/SimBuffers.cpp b/source/main/gfx/SimBuffers.cpp new file mode 100644 index 0000000000..24dcef4fc9 --- /dev/null +++ b/source/main/gfx/SimBuffers.cpp @@ -0,0 +1,36 @@ +/* + This source file is part of Rigs of Rods + Copyright 2005-2012 Pierre-Michel Ricordel + Copyright 2007-2012 Thomas Fischer + Copyright 2013-2023 Petr Ohlidal + + For more information, see http://www.rigsofrods.org/ + + Rigs of Rods is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License version 3, as + published by the Free Software Foundation. + + Rigs of Rods is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Rigs of Rods. If not, see . +*/ + +#include "SimBuffers.h" + +#include "Actor.h" + +using namespace RoR; + +GameContextSB::GameContextSB() +{ + // Constructs `ActorPtr` - doesn't compile without `#include Actor.h` - not pretty if in header (even if auto-generated by C++). +} + +GameContextSB::~GameContextSB() +{ + // Destructs `ActorPtr` - doesn't compile without `#include Actor.h` - not pretty if in header (even if auto-generated by C++). +} diff --git a/source/main/gfx/SimBuffers.h b/source/main/gfx/SimBuffers.h index 2bd5fa46bb..8fa3b8383f 100644 --- a/source/main/gfx/SimBuffers.h +++ b/source/main/gfx/SimBuffers.h @@ -194,6 +194,9 @@ struct ActorSB struct GameContextSB { + GameContextSB(); + ~GameContextSB(); + ActorPtr simbuf_player_actor; Ogre::Vector3 simbuf_character_pos = Ogre::Vector3::ZERO; bool simbuf_sim_paused = false; diff --git a/source/main/gui/GUIManager.cpp b/source/main/gui/GUIManager.cpp index 4971b68dc5..91eaa59d56 100644 --- a/source/main/gui/GUIManager.cpp +++ b/source/main/gui/GUIManager.cpp @@ -24,11 +24,13 @@ #include "GUIManager.h" +#include "Actor.h" #include "AppContext.h" #include "ActorManager.h" #include "CameraManager.h" #include "ContentManager.h" #include "GameContext.h" +#include "GfxActor.h" #include "GfxScene.h" #include "GUIUtils.h" #include "InputEngine.h" diff --git a/source/main/gui/panels/GUI_FlexbodyDebug.cpp b/source/main/gui/panels/GUI_FlexbodyDebug.cpp index 2283708e31..8aa4898942 100644 --- a/source/main/gui/panels/GUI_FlexbodyDebug.cpp +++ b/source/main/gui/panels/GUI_FlexbodyDebug.cpp @@ -22,6 +22,7 @@ #include "GUI_FlexbodyDebug.h" +#include "Actor.h" #include "Application.h" #include "SimData.h" #include "Collisions.h" diff --git a/source/main/gui/panels/GUI_MainSelector.h b/source/main/gui/panels/GUI_MainSelector.h index 000e5f5f95..78cfdfb453 100644 --- a/source/main/gui/panels/GUI_MainSelector.h +++ b/source/main/gui/panels/GUI_MainSelector.h @@ -61,7 +61,7 @@ class MainSelector { DisplayEntry(CacheEntryPtr entry); - CacheEntryPtr sde_entry = nullptr; + CacheEntryPtr sde_entry; Str<50> sde_filetime_str; // pre-formatted Str<50> sde_addtime_str; // pre-formatted Str<50> sde_driveable_str; // pre-formatted diff --git a/source/main/physics/Actor.h b/source/main/physics/Actor.h index 99459d8fd9..ace59de8ff 100644 --- a/source/main/physics/Actor.h +++ b/source/main/physics/Actor.h @@ -42,8 +42,6 @@ namespace RoR { /// @addtogroup Physics /// @{ -typedef std::vector ActorPtrVec; - /// Softbody object; can be anything from soda can to a space shuttle /// Former name: `Beam` (that's why scripting uses `BeamClass`) class Actor : public RefCountingObject @@ -563,8 +561,8 @@ ActorPtrVec ar_linked_actors; //!< Sim state float m_load_mass = 0.f; //!< Physics attr; predefined load mass in Kg int m_masscount = 0; //!< Physics attr; Number of nodes loaded with l option float m_dry_mass = 0.f; //!< Physics attr; - std::unique_ptr m_buoyance; //!< Physics - CacheEntryPtr m_used_skin_entry = nullptr; //!< Graphics + std::unique_ptr m_buoyance; //!< Physics + CacheEntryPtr m_used_skin_entry; //!< Graphics Skidmark* m_skid_trails[MAX_WHEELS*2] = {}; bool m_antilockbrake = false; //!< GUI state bool m_tractioncontrol = false; //!< GUI state diff --git a/source/main/physics/ActorManager.h b/source/main/physics/ActorManager.h index c687af630b..d7913a47c3 100644 --- a/source/main/physics/ActorManager.h +++ b/source/main/physics/ActorManager.h @@ -24,7 +24,6 @@ #pragma once -#include "Actor.h" #include "Application.h" #include "SimData.h" #include "CmdKeyInertia.h" diff --git a/source/main/physics/SimData.cpp b/source/main/physics/SimData.cpp new file mode 100644 index 0000000000..4ab399eb24 --- /dev/null +++ b/source/main/physics/SimData.cpp @@ -0,0 +1,92 @@ +/* + This source file is part of Rigs of Rods + Copyright 2005-2012 Pierre-Michel Ricordel + Copyright 2007-2012 Thomas Fischer + Copyright 2013-2023 Petr Ohlidal + + For more information, see http://www.rigsofrods.org/ + + Rigs of Rods is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License version 3, as + published by the Free Software Foundation. + + Rigs of Rods is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Rigs of Rods. If not, see . +*/ + +#include "SimData.h" + +#include "Actor.h" +#include "CacheSystem.h" + +using namespace RoR; + +ActorSpawnRequest::ActorSpawnRequest() +{ + // Constructs `CacheEntryPtr` - doesn't compile without `#include CacheSystem.h` - not pretty if in header (even if auto-generated by C++). +} + +ActorSpawnRequest::~ActorSpawnRequest() +{ + // Destructs `CacheEntryPtr` - doesn't compile without `#include CacheSystem.h` - not pretty if in header (even if auto-generated by C++). +} + +beam_t::beam_t() +{ + // Constructs `ActorPtr` - doesn't compile without `#include Actor.h` - not pretty if in header (even if auto-generated by C++). +} + +beam_t::~beam_t() +{ + // Destructs `ActorPtr` - doesn't compile without `#include Actor.h` - not pretty if in header (even if auto-generated by C++). +} + +rope_t::rope_t() +{ + // Constructs `ActorPtr` - doesn't compile without `#include Actor.h` - not pretty if in header (even if auto-generated by C++). +} + +rope_t::~rope_t() +{ + // Destructs `ActorPtr` - doesn't compile without `#include Actor.h` - not pretty if in header (even if auto-generated by C++). +} + +tie_t::tie_t() +{ + // Constructs `ActorPtr` - doesn't compile without `#include Actor.h` - not pretty if in header (even if auto-generated by C++). + + // Bitfields cannot be initialized in-class (C++ limitation). + ti_no_self_lock = false; + ti_tied = false; + ti_tying = false; +} + +tie_t::~tie_t() +{ + // Destructs `ActorPtr` - doesn't compile without `#include Actor.h` - not pretty if in header (even if auto-generated by C++). +} + +hook_t::hook_t() +{ + // Constructs `ActorPtr` - doesn't compile without `#include Actor.h` - not pretty if in header (even if auto-generated by C++). +} + +hook_t::~hook_t() +{ + // Destructs `ActorPtr` - doesn't compile without `#include Actor.h` - not pretty if in header (even if auto-generated by C++). +} + +soundsource_t::soundsource_t() +{ + // Constructs `ActorPtr` - doesn't compile without `#include Actor.h` - not pretty if in header (even if auto-generated by C++). +} + +soundsource_t::~soundsource_t() +{ + // Destructs `ActorPtr` - doesn't compile without `#include Actor.h` - not pretty if in header (even if auto-generated by C++). +} diff --git a/source/main/physics/SimData.h b/source/main/physics/SimData.h index af4b2d6035..2e3adc7597 100644 --- a/source/main/physics/SimData.h +++ b/source/main/physics/SimData.h @@ -2,7 +2,7 @@ This source file is part of Rigs of Rods Copyright 2005-2012 Pierre-Michel Ricordel Copyright 2007-2012 Thomas Fischer - Copyright 2013-2020 Petr Ohlidal + Copyright 2013-2023 Petr Ohlidal For more information, see http://www.rigsofrods.org/ @@ -340,39 +340,40 @@ struct node_t /// Simulation: An edge in the softbody structure struct beam_t { - beam_t() { memset(this, 0, sizeof(beam_t)); } - - node_t* p1; - node_t* p2; - Ogre::Real k; //!< tensile spring - Ogre::Real d; //!< damping factor - Ogre::Real L; //!< length - Ogre::Real minmaxposnegstress; - Ogre::Real maxposstress; - Ogre::Real maxnegstress; - Ogre::Real strength; - Ogre::Real stress; - Ogre::Real plastic_coef; - int detacher_group; //!< Attribute: detacher group number (integer) - SpecialBeam bounded; - BeamType bm_type; - bool bm_inter_actor; //!< in case p2 is on another actor - ActorPtr bm_locked_actor; //!< in case p2 is on another actor - bool bm_disabled; - bool bm_broken; - - Ogre::Real shortbound; - Ogre::Real longbound; - Ogre::Real refL; //!< reference length - - shock_t* shock; - - Ogre::Real initial_beam_strength; //!< for reset - Ogre::Real default_beam_deform; //!< for reset - - Ogre::Real debug_k; //!< debug shock spring_rate - Ogre::Real debug_d; //!< debug shock damping - Ogre::Real debug_v; //!< debug shock velocity + beam_t(); + ~beam_t(); + + node_t* p1 = nullptr; + node_t* p2 = nullptr; + float k = 0.f; //!< tensile spring + float d = 0.f; //!< damping factor + float L = 0.f; //!< length + float minmaxposnegstress = 0.f; + float maxposstress = 0.f; + float maxnegstress = 0.f; + float strength = 0.f; + float stress = 0.f; + float plastic_coef = 0.f; + int detacher_group = DEFAULT_DETACHER_GROUP; //!< Attribute: detacher group number (integer) + SpecialBeam bounded = SpecialBeam::NOSHOCK; + BeamType bm_type = BeamType::BEAM_NORMAL; + bool bm_inter_actor = false; //!< in case p2 is on another actor + ActorPtr bm_locked_actor; //!< in case p2 is on another actor + bool bm_disabled = false; + bool bm_broken = false; + + float shortbound = 0.f; + float longbound = 0.f; + float refL = 0.f; //!< reference length + + shock_t* shock = nullptr; + + float initial_beam_strength = 0.f; //!< for reset + float default_beam_deform = 0.f; //!< for reset + + float debug_k = 0.f; //!< debug shock spring_rate + float debug_d = 0.f; //!< debug shock damping + float debug_v = 0.f; //!< debug shock velocity }; struct shock_t @@ -420,6 +421,9 @@ struct collcab_rate_t struct soundsource_t { + soundsource_t(); + ~soundsource_t(); + SoundScriptInstancePtr ssi; NodeNum_t nodenum; int type; @@ -480,22 +484,25 @@ struct wheeldetacher_t struct hook_t { - HookState hk_locked; - int hk_group; - int hk_lockgroup; - bool hk_selflock; - bool hk_autolock; - bool hk_nodisable; - float hk_maxforce; - float hk_lockrange; - float hk_lockspeed; - float hk_timer; - float hk_timer_preset; - float hk_min_length; //!< Absolute value in meters - node_t* hk_hook_node; - node_t* hk_lock_node; - beam_t* hk_beam; - ActorPtr hk_locked_actor; + hook_t(); + ~hook_t(); + + HookState hk_locked = HookState::UNLOCKED; + int hk_group = 0; + int hk_lockgroup = 0; + bool hk_selflock = false; + bool hk_autolock = false; + bool hk_nodisable = false; + float hk_maxforce = 0.f; + float hk_lockrange = 0.f; + float hk_lockspeed = 0.f; + float hk_timer = 0.f; + float hk_timer_preset = 0.f; + float hk_min_length = 0.f; //!< Absolute value in meters + node_t* hk_hook_node = nullptr; + node_t* hk_lock_node = nullptr; + beam_t* hk_beam = nullptr; + ActorPtr hk_locked_actor; }; struct ropable_t @@ -510,22 +517,28 @@ struct ropable_t struct rope_t { - int rp_locked; - int rp_group; - beam_t* rp_beam; - ropable_t* rp_locked_ropable; - ActorPtr rp_locked_actor; + rope_t(); + ~rope_t(); + + int rp_locked = 0; + int rp_group = 0; + beam_t* rp_beam = nullptr; + ropable_t* rp_locked_ropable = nullptr; + ActorPtr rp_locked_actor; }; struct tie_t { - ActorPtr ti_locked_actor; - beam_t* ti_beam; - ropable_t* ti_locked_ropable; - int ti_group; - float ti_contract_speed; - float ti_max_stress; - float ti_min_length; //!< Proportional to orig; length + tie_t(); + ~tie_t(); + + ActorPtr ti_locked_actor; + beam_t* ti_beam = nullptr; + ropable_t* ti_locked_ropable = nullptr; + int ti_group = 0; + float ti_contract_speed = 0.f; + float ti_max_stress = 0.f; + float ti_min_length = 0.f; //!< Proportional to orig; length bool ti_no_self_lock:1; //!< Attribute bool ti_tied:1; //!< State @@ -775,6 +788,9 @@ struct authorinfo_t struct ActorSpawnRequest { + ActorSpawnRequest(); + ~ActorSpawnRequest(); + enum class Origin //!< Enables special processing { UNKNOWN, @@ -786,13 +802,13 @@ struct ActorSpawnRequest AI //!< Script controlled }; - CacheEntryPtr asr_cache_entry = nullptr; //!< Optional, overrides 'asr_filename' and 'asr_cache_entry_num' + CacheEntryPtr asr_cache_entry; //!< Optional, overrides 'asr_filename' and 'asr_cache_entry_num' std::string asr_filename; Ogre::String asr_config; Ogre::Vector3 asr_position = Ogre::Vector3::ZERO; Ogre::Quaternion asr_rotation = Ogre::Quaternion::ZERO; collision_box_t* asr_spawnbox = nullptr; - CacheEntryPtr asr_skin_entry = nullptr; + CacheEntryPtr asr_skin_entry; Origin asr_origin = Origin::UNKNOWN; int asr_debugview = 0; //(int)DebugViewType::DEBUGVIEW_NONE; Ogre::UTFString asr_net_username; diff --git a/source/main/scripting/ScriptEngine.cpp b/source/main/scripting/ScriptEngine.cpp index 4c77af6509..cd4595f24a 100644 --- a/source/main/scripting/ScriptEngine.cpp +++ b/source/main/scripting/ScriptEngine.cpp @@ -74,6 +74,16 @@ const char* RoR::ScriptCategoryToString(ScriptCategory c) } } +ScriptUnit::ScriptUnit() +{ + // Constructs `ActorPtr` - doesn't compile without `#include Actor.h` - not pretty if in header (even if auto-generated by C++). +} + +ScriptUnit::~ScriptUnit() +{ + // Destructs `ActorPtr` - doesn't compile without `#include Actor.h` - not pretty if in header (even if auto-generated by C++). +} + // some hacky functions void logString(const std::string &str) diff --git a/source/main/scripting/ScriptEngine.h b/source/main/scripting/ScriptEngine.h index 690119e253..2fccca36d6 100644 --- a/source/main/scripting/ScriptEngine.h +++ b/source/main/scripting/ScriptEngine.h @@ -68,6 +68,9 @@ const char* ScriptCategoryToString(ScriptCategory c); /// Represents a loaded script and all associated resources/handles. struct ScriptUnit { + ScriptUnit(); + ~ScriptUnit(); + ScriptUnitId_t uniqueId = SCRIPTUNITID_INVALID; ScriptCategory scriptCategory = ScriptCategory::INVALID; unsigned int eventMask = 0; //!< filter mask for script events diff --git a/source/main/terrain/Terrain.cpp b/source/main/terrain/Terrain.cpp index 4d5e408eda..127d672046 100644 --- a/source/main/terrain/Terrain.cpp +++ b/source/main/terrain/Terrain.cpp @@ -21,6 +21,7 @@ #include "Terrain.h" +#include "Actor.h" #include "ActorManager.h" #include "CacheSystem.h" #include "Collisions.h"