From 03053b9f9feae9ef86f0c9a3a43f653fc992006e Mon Sep 17 00:00:00 2001 From: rlcevg <514675+rlcevg@users.noreply.github.com> Date: Sat, 20 Mar 2021 14:26:44 +0200 Subject: [PATCH] On load: don't clear staticVars, don't add windgen duplicates --- rts/Sim/Units/Scripts/CobInstance.cpp | 23 ++++++++++++++--------- rts/Sim/Units/Scripts/CobInstance.h | 1 + rts/Sim/Units/Unit.cpp | 3 --- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/rts/Sim/Units/Scripts/CobInstance.cpp b/rts/Sim/Units/Scripts/CobInstance.cpp index f5cc6d04b8..f5bfae0148 100644 --- a/rts/Sim/Units/Scripts/CobInstance.cpp +++ b/rts/Sim/Units/Scripts/CobInstance.cpp @@ -61,17 +61,10 @@ inline bool CCobInstance::HasFunction(int id) const void CCobInstance::Init() { - assert(cobFile != nullptr); + InitCommon(); staticVars.clear(); staticVars.resize(cobFile->numStaticVars, 0); - - MapScriptToModelPieces(&unit->localModel); - - hasSetSFXOccupy = HasFunction(COBFN_SetSFXOccupy); - hasRockUnit = HasFunction(COBFN_RockUnit); - hasStartBuilding = HasFunction(COBFN_StartBuilding); - } void CCobInstance::PostLoad() @@ -88,7 +81,7 @@ void CCobInstance::PostLoad() t->cobFile = cobFile; } - Init(); + InitCommon(); } @@ -111,6 +104,18 @@ CCobInstance::~CCobInstance() } +void CCobInstance::InitCommon() +{ + assert(cobFile != nullptr); + + MapScriptToModelPieces(&unit->localModel); + + hasSetSFXOccupy = HasFunction(COBFN_SetSFXOccupy); + hasRockUnit = HasFunction(COBFN_RockUnit); + hasStartBuilding = HasFunction(COBFN_StartBuilding); +} + + void CCobInstance::MapScriptToModelPieces(LocalModel* lmodel) { std::vector& pieceNames = cobFile->pieceNames; // already in lowercase! diff --git a/rts/Sim/Units/Scripts/CobInstance.h b/rts/Sim/Units/Scripts/CobInstance.h index 5edebe135b..aa0569c8e1 100644 --- a/rts/Sim/Units/Scripts/CobInstance.h +++ b/rts/Sim/Units/Scripts/CobInstance.h @@ -37,6 +37,7 @@ class CCobInstance : public CUnitScript enum ThreadCallbackType { CBNone, CBKilled, CBAimWeapon, CBAimShield }; protected: + void InitCommon(); void MapScriptToModelPieces(LocalModel* lmodel); int RealCall(int functionId, std::array& args, ThreadCallbackType cb, int cbParam, int* retCode); diff --git a/rts/Sim/Units/Unit.cpp b/rts/Sim/Units/Unit.cpp index 0bef838658..f9536e446d 100644 --- a/rts/Sim/Units/Unit.cpp +++ b/rts/Sim/Units/Unit.cpp @@ -398,9 +398,6 @@ void CUnit::PostInit(const CUnit* builder) void CUnit::PostLoad() { - if (unitDef->windGenerator > 0.0f) - envResHandler.AddGenerator(this); - eventHandler.RenderUnitCreated(this, isCloaked); }