Skip to content

Commit

Permalink
Merge pull request #11 from rlcevg/fix_savegame
Browse files Browse the repository at this point in the history
On load: don't clear staticVars, don't add windgen duplicates
  • Loading branch information
lhog authored Mar 20, 2021
2 parents e9f42ac + 03053b9 commit 98185ca
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
23 changes: 14 additions & 9 deletions rts/Sim/Units/Scripts/CobInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -88,7 +81,7 @@ void CCobInstance::PostLoad()
t->cobFile = cobFile;
}

Init();
InitCommon();
}


Expand All @@ -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<std::string>& pieceNames = cobFile->pieceNames; // already in lowercase!
Expand Down
1 change: 1 addition & 0 deletions rts/Sim/Units/Scripts/CobInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<int, 1 + MAX_COB_ARGS>& args, ThreadCallbackType cb, int cbParam, int* retCode);
Expand Down
3 changes: 0 additions & 3 deletions rts/Sim/Units/Unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 98185ca

Please sign in to comment.