@@ -205,7 +205,7 @@ int MovableObject::Create(const MovableObject &reference)
205
205
m_MissionCritical = reference.m_MissionCritical ;
206
206
m_CanBeSquished = reference.m_CanBeSquished ;
207
207
m_HUDVisible = reference.m_HUDVisible ;
208
- for (std::pair<std::string, bool > scriptEntry : reference.m_LoadedScripts ) {
208
+ for (const std::pair<std::string, bool > & scriptEntry : reference.m_LoadedScripts ) {
209
209
m_LoadedScripts.push_back ({scriptEntry.first , scriptEntry.second });
210
210
}
211
211
m_ScriptPresetName = reference.m_ScriptPresetName ;
@@ -329,9 +329,7 @@ int MovableObject::ReadProperty(std::string propName, Reader &reader)
329
329
else if (propName == " ScriptPath" )
330
330
{
331
331
std::string scriptPath = reader.ReadPropValue ();
332
- if (LoadScript (scriptPath) == -2 ) {
333
- reader.ReportError (" Duplicate script path " + scriptPath);
334
- }
332
+ if (LoadScript (scriptPath) == -2 ) { reader.ReportError (" Duplicate script path " + scriptPath); }
335
333
}
336
334
else if (propName == " ScreenEffect" )
337
335
{
@@ -495,7 +493,7 @@ int MovableObject::LoadScript(const std::string &scriptPath, bool loadAsEnabledS
495
493
m_LoadedScripts.push_back ({scriptPath, loadAsEnabledScript});
496
494
497
495
// Clear the temporary variable names that will hold the functions read in from the file
498
- for (std::string functionName : GetSupportedScriptFunctionNames ()) {
496
+ for (const std::string & functionName : GetSupportedScriptFunctionNames ()) {
499
497
if (g_LuaMan.RunScriptString (functionName + " = nil;" ) < 0 ) {
500
498
return -3 ;
501
499
}
@@ -551,7 +549,7 @@ int MovableObject::ReloadScripts() {
551
549
object->m_ScriptPresetName .clear ();
552
550
553
551
int status = 0 ;
554
- for (std::pair<std::string, bool > scriptEntry : loadedScriptsCopy) {
552
+ for (const std::pair<std::string, bool > & scriptEntry : loadedScriptsCopy) {
555
553
status = object->LoadScript (scriptEntry.first , scriptEntry.second );
556
554
if (status < 0 ) {
557
555
return status;
@@ -606,7 +604,7 @@ bool MovableObject::RemoveScript(const std::string &scriptPath) {
606
604
return false ;
607
605
}
608
606
609
- auto scriptEntryIterator = FindScript (scriptPath);
607
+ std::vector<std::pair<std::string, bool >>::const_iterator scriptEntryIterator = FindScript (scriptPath);
610
608
if (scriptEntryIterator != m_LoadedScripts.end ()) {
611
609
m_LoadedScripts.erase (scriptEntryIterator);
612
610
if (ObjectScriptsInitialized () && RunScriptedFunction (scriptPath, " OnScriptRemoveOrDisable" , {}, {" true" }) < 0 ) {
@@ -625,7 +623,7 @@ bool MovableObject::EnableScript(const std::string &scriptPath) {
625
623
return false ;
626
624
}
627
625
628
- auto scriptEntryIterator = FindScript (scriptPath);
626
+ std::vector<std::pair<std::string, bool >>::iterator scriptEntryIterator = FindScript (scriptPath);
629
627
if (scriptEntryIterator != m_LoadedScripts.end () && scriptEntryIterator->second == false ) {
630
628
if (ObjectScriptsInitialized () && RunScriptedFunction (scriptPath, " OnScriptEnable" ) < 0 ) {
631
629
return false ;
@@ -643,7 +641,7 @@ bool MovableObject::DisableScript(const std::string &scriptPath) {
643
641
return false ;
644
642
}
645
643
646
- auto scriptEntryIterator = FindScript (scriptPath);
644
+ std::vector<std::pair<std::string, bool >>::iterator scriptEntryIterator = FindScript (scriptPath);
647
645
if (scriptEntryIterator != m_LoadedScripts.end () && scriptEntryIterator->second == true ) {
648
646
if (ObjectScriptsInitialized () && RunScriptedFunction (scriptPath, " OnScriptRemoveOrDisable" , {}, {" false" }) < 0 ) {
649
647
return false ;
@@ -684,7 +682,7 @@ int MovableObject::RunScriptedFunctionInAppropriateScripts(const std::string &fu
684
682
}
685
683
686
684
int status = 0 ;
687
- for (std::pair<std::string, bool > scriptEntry : m_LoadedScripts) {
685
+ for (const std::pair<std::string, bool > & scriptEntry : m_LoadedScripts) {
688
686
if (runOnDisabledScripts || scriptEntry.second == true ) {
689
687
status = RunScriptedFunction (scriptEntry.first , functionName, functionEntityArguments, functionLiteralArguments);
690
688
if (status < 0 && stopOnError) {
0 commit comments