Skip to content

Commit

Permalink
🔧 Restored custom light support in savegame
Browse files Browse the repository at this point in the history
  • Loading branch information
ohlidalp authored and Petr Ohlídal committed Apr 7, 2021
1 parent 9350f07 commit 48c0bf5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
17 changes: 10 additions & 7 deletions source/main/physics/Savegame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,12 +499,12 @@ bool ActorManager::SaveScene(Ogre::String filename)
j_entry.AddMember("custom_particles", actor->m_custom_particles_enabled, j_doc.GetAllocator());

// Flares
rapidjson::Value j_flares(rapidjson::kArrayType);
for (const auto& flare : actor->ar_flares)
rapidjson::Value j_custom_lights(rapidjson::kArrayType);
for (int i = 0; i < MAX_CLIGHTS; i++)
{
j_flares.PushBack(flare.controltoggle_status, j_doc.GetAllocator());
j_custom_lights.PushBack(actor->m_custom_lights[i], j_doc.GetAllocator());
}
j_entry.AddMember("flares", j_flares, j_doc.GetAllocator());
j_entry.AddMember("custom_lights", j_custom_lights, j_doc.GetAllocator());

if (actor->m_buoyance)
{
Expand Down Expand Up @@ -782,10 +782,13 @@ void ActorManager::RestoreSavedState(Actor* actor, rapidjson::Value const& j_ent
actor->ToggleCustomParticles();
}

auto flares = j_entry["flares"].GetArray();
for (int i = 0; i < static_cast<int>(actor->ar_flares.size()); i++)
if (j_entry.HasMember("custom_lights"))
{
actor->ar_flares[i].controltoggle_status = flares[i].GetBool();
auto flares = j_entry["custom_lights"].GetArray();
for (int i = 0; i < MAX_CLIGHTS; i++)
{
actor->m_custom_lights[i] = flares[i].GetBool();
}
}

if (actor->m_buoyance)
Expand Down
1 change: 0 additions & 1 deletion source/main/physics/SimData.h
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,6 @@ struct flare_t
Ogre::Light *light;
FlareType fl_type;
int controlnumber; //!< Only 'u' type flares, valid values 0-9, maps to EV_TRUCK_LIGHTTOGGLE01 to 10.
bool controltoggle_status; // UNUSED - TO BE REMOVED
float blinkdelay;
float blinkdelay_curr;
bool blinkdelay_state;
Expand Down

0 comments on commit 48c0bf5

Please # to comment.