Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 3f28910

Browse files
committed
Fixed some attachable script screwup. Third time's the charm!
1 parent ef415d7 commit 3f28910

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

Entities/Attachable.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ void Attachable::Attach(MOSRotating *pParent)
274274
// Reset the attachables timers so things that have been sitting in inventory don't make backed up emissions
275275
ResetAllTimers();
276276

277-
if (m_pParent != NULL && m_pParent->ObjectScriptsInitialized()) {
277+
if (m_pParent != NULL && (!m_pParent->HasAnyScripts() || m_pParent->ObjectScriptsInitialized())) {
278278
RunScriptedFunctionInAppropriateScripts("OnAttach", false, false, {m_pParent});
279279
}
280280
}
@@ -306,7 +306,7 @@ void Attachable::Detach()
306306

307307
m_RestTimer.Reset();
308308

309-
if (temporaryParent != NULL && temporaryParent->ObjectScriptsInitialized()) {
309+
if (temporaryParent != NULL && (!temporaryParent->HasAnyScripts() || temporaryParent->ObjectScriptsInitialized())) {
310310
RunScriptedFunctionInAppropriateScripts("OnDetach", false, false, {temporaryParent});
311311
}
312312
}
@@ -554,7 +554,7 @@ void Attachable::Update()
554554
MOSRotating::Update();
555555

556556
// If we're attached to something, MoveableMan doesn't own us, and therefore isn't calling our ScriptUpdate (and our parent isn't calling it either), so we should here
557-
if (m_pParent != NULL && m_pParent->ObjectScriptsInitialized()) { UpdateScripts(); }
557+
if (m_pParent != NULL && (!m_pParent->HasAnyScripts() || m_pParent->ObjectScriptsInitialized())) { UpdateScripts(); }
558558
}
559559

560560

Entities/MovableObject.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,12 @@ ENTITYALLOCATION(MovableObject)
220220
/// <returns>The iterator pointing to the vector entry for the script or the end of the vector if the script was not found.</returns>
221221
virtual std::vector<std::pair<std::string, bool>>::const_iterator const FindScript(std::string const &scriptPath) const { return std::find_if(m_LoadedScripts.cbegin(), m_LoadedScripts.cend(), [&scriptPath](auto element) { return element.first == scriptPath; }); }
222222

223+
/// <summary>
224+
/// Checks if this MO has any scripts on it.
225+
/// </summary>
226+
/// <returns>Whether or not this MO has any scripts on it.</returns>
227+
virtual bool const HasAnyScripts() const { return !m_LoadedScripts.empty(); }
228+
223229
/// <summary>
224230
/// Checks if the script at the given path is one of the scripts on this MO.
225231
/// </summary>

0 commit comments

Comments
 (0)