Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fixed exhausts on predefined actors. #3205

Merged
merged 4 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions source/main/physics/Actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3289,6 +3289,7 @@ void Actor::AddInterActorBeam(beam_t* beam, ActorPtr other, ActorLinkingRequestT
void Actor::RemoveInterActorBeam(beam_t* beam, ActorLinkingRequestType type)
{
ROR_ASSERT(beam->bm_locked_actor);
ROR_ASSERT(beam->bm_locked_actor->ar_state != ActorState::DISPOSED);
ActorPtr other = beam->bm_locked_actor;
beam->bm_locked_actor = nullptr;

Expand All @@ -3315,17 +3316,22 @@ void Actor::RemoveInterActorBeam(beam_t* beam, ActorLinkingRequestType type)
for (ActorPtr& actor : this->ar_linked_actors)
actor->DetermineLinkedActors();

other->DetermineLinkedActors();
for (ActorPtr& actor : other->ar_linked_actors)
actor->DetermineLinkedActors();

// Reset toggled states.
other->ar_physics_paused = false;
other->GetGfxActor()->SetDebugView(DebugViewType::DEBUGVIEW_NONE);
for (ActorPtr& actor : other->ar_linked_actors)
// This should never fail (a disposing actor should disconnect everything first)
// but there seems to be a bug at the moment.
if (other->ar_state != ActorState::DISPOSED)
{
actor->ar_physics_paused = false;
actor->GetGfxActor()->SetDebugView(DebugViewType::DEBUGVIEW_NONE);
other->DetermineLinkedActors();
for (ActorPtr& actor : other->ar_linked_actors)
actor->DetermineLinkedActors();

// Reset toggled states.
other->ar_physics_paused = false;
other->GetGfxActor()->SetDebugView(DebugViewType::DEBUGVIEW_NONE);
for (ActorPtr& actor : other->ar_linked_actors)
{
actor->ar_physics_paused = false;
actor->GetGfxActor()->SetDebugView(DebugViewType::DEBUGVIEW_NONE);
}
}

// Let scripts know.
Expand Down
13 changes: 7 additions & 6 deletions source/main/physics/ActorSpawner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2913,12 +2913,6 @@ void ActorSpawner::ProcessParticle(RigDef::Particle & def)
particle.snode->attachObject(particle.psys);
particle.snode->setPosition(m_actor->ar_nodes[particle.emitterNode].AbsPosition);

/* Shut down the emitters */
for (unsigned int i = 0; i < particle.psys->getNumEmitters(); i++)
{
particle.psys->getEmitter(i)->setEnabled(false);
}

m_actor->m_gfx_actor->m_cparticles.push_back(particle);
}

Expand Down Expand Up @@ -7277,6 +7271,13 @@ Ogre::ParticleSystem* ActorSpawner::CreateParticleSystem(std::string const & nam
name, Ogre::ParticleSystemFactory::FACTORY_TYPE_NAME, &params);
Ogre::ParticleSystem* psys = static_cast<Ogre::ParticleSystem*>(obj);
psys->setVisibilityFlags(DEPTHMAP_DISABLED); // disable particles in depthmap

// Shut down the emitters
for (size_t i = 0; i < psys->getNumEmitters(); i++)
{
psys->getEmitter(i)->setEnabled(false);
}

return psys;
}

Expand Down
26 changes: 14 additions & 12 deletions source/main/physics/Savegame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "SkyManager.h"
#include "Terrain.h"
#include "TuneupFileFormat.h"
#include "Utils.h"

#include <rapidjson/rapidjson.h>
#include <fstream>
Expand Down Expand Up @@ -304,8 +305,11 @@ bool ActorManager::LoadScene(Ogre::String save_filename)
for (rapidjson::Value& j_entry: j_doc["actors"].GetArray())
{
// NOTE: The filename is by default in "Bundle-qualified" format, i.e. "mybundle.zip:myactor.truck"
String rigdef_filename = j_entry["filename"].GetString();
CacheEntryPtr actor_entry = App::GetCacheSystem()->FindEntryByFilename(LT_AllBeam, /*partial:*/false, rigdef_filename);
String rigdef_filename_maybe_bundle_qualified = j_entry["filename"].GetString();
std::string filename;
std::string bundlename;
SplitBundleQualifiedFilename(rigdef_filename_maybe_bundle_qualified, bundlename, filename);
CacheEntryPtr actor_entry = App::GetCacheSystem()->FindEntryByFilename(LT_AllBeam, /*partial:*/false, rigdef_filename_maybe_bundle_qualified);

CacheEntryPtr skin = nullptr;
if (j_entry.HasMember("skin"))
Expand All @@ -330,9 +334,9 @@ bool ActorManager::LoadScene(Ogre::String save_filename)
int index = static_cast<int>(actors.size());
if (index < x_actors.size())
{
if (j_entry["filename"].GetString() != x_actors[index]->ar_filename ||
(skin != nullptr && skin->dname != x_actors[index]->m_used_skin_entry->dname) ||
section_config != x_actors[index]->getSectionConfig())
if (filename != x_actors[index]->ar_filename ||
(skin != nullptr && skin->dname != x_actors[index]->m_used_skin_entry->dname) ||
section_config != x_actors[index]->getSectionConfig())
{
if (x_actors[index] == player_actor)
{
Expand All @@ -352,21 +356,19 @@ bool ActorManager::LoadScene(Ogre::String save_filename)
}
}

if (actor == nullptr)
// If a 'preloaded' actor isn't loaded at this point, it means it's not installed.
if (actor == nullptr && !j_entry["preloaded_with_terrain"].GetBool())
{
bool preloaded = j_entry["preloaded_with_terrain"].GetBool();

ActorSpawnRequest* rq = new ActorSpawnRequest;
rq->asr_filename = rigdef_filename;
rq->asr_filename = rigdef_filename_maybe_bundle_qualified;
rq->asr_position.x = j_entry["position"][0].GetFloat();
rq->asr_position.y = preloaded ? j_entry["position"][1].GetFloat() : j_entry["min_height"].GetFloat();
rq->asr_position.y = j_entry["min_height"].GetFloat();
rq->asr_position.z = j_entry["position"][2].GetFloat();
rq->asr_rotation = Quaternion(Degree(270) - Radian(j_entry["rotation"].GetFloat()), Vector3::UNIT_Y);
rq->asr_skin_entry = skin;
rq->asr_working_tuneup = working_tuneup;
rq->asr_config = section_config;
rq->asr_origin = preloaded ? ActorSpawnRequest::Origin::TERRN_DEF : ActorSpawnRequest::Origin::SAVEGAME;
rq->asr_free_position = preloaded;
rq->asr_origin = ActorSpawnRequest::Origin::SAVEGAME;
// Copy saved state
rq->asr_saved_state = std::shared_ptr<rapidjson::Document>(new rapidjson::Document());
rq->asr_saved_state->CopyFrom(j_entry, rq->asr_saved_state->GetAllocator());
Expand Down
Loading