void C4AulScriptEngine::CompileFunc(StdCompiler *pComp, bool fScenarioSection, C4ValueNumbers * numbers) { if (!fScenarioSection) { assert(UserFiles.empty()); // user files must not be kept open C4ValueMapData GlobalNamedDefault; GlobalNamedDefault.SetNameList(&GlobalNamedNames); pComp->Value(mkNamingAdapt(mkParAdapt(GlobalNamed, numbers), "StaticVariables", GlobalNamedDefault)); pComp->Value(mkNamingAdapt(mkParAdapt(*GameScript.ScenPropList._getPropList(), numbers), "Scenario")); } if (pComp->isDeserializer() && pGlobalEffects) { // loading scenario section or game re-init: Merge effects // Must keep old effects here even if they're dead, because the LoadScenarioSection call typically came from execution of a global effect // and otherwise dead pointers would remain on the stack GlobalEffectsMergeCompileFunc(pComp, pGlobalEffects, "Effects", this, numbers); GlobalEffectsMergeCompileFunc(pComp, GameScript.pScenarioEffects, "ScenarioEffects", GameScript.ScenPropList._getPropList(), numbers); } else { // Otherwise, just compile effects pComp->Value(mkParAdapt(mkNamingPtrAdapt(pGlobalEffects, "Effects"), this, numbers)); pComp->Value(mkParAdapt(mkNamingPtrAdapt(GameScript.pScenarioEffects, "ScenarioEffects"), GameScript.ScenPropList._getPropList(), numbers)); } pComp->Value(mkNamingAdapt(*numbers, "Values")); }
void C4AulScriptEngine::CompileFunc(StdCompiler *pComp, C4ValueNumbers * numbers) { assert(UserFiles.empty()); // user files must not be kept open C4ValueMapData GlobalNamedDefault; GlobalNamedDefault.SetNameList(&GlobalNamedNames); pComp->Value(mkNamingAdapt(mkParAdapt(GlobalNamed, numbers), "StaticVariables", GlobalNamedDefault)); pComp->Value(mkNamingAdapt(mkParAdapt(*GameScript.ScenPropList._getPropList(), numbers), "Scenario")); }
void C4ValueMapNames::ChangeNameList(const char **pnNames, int32_t *pnExtra, int32_t nSize) { // safe old name list char **pOldNames = pNames; int32_t *pOldExtra = pExtra; int32_t iOldSize = iSize; // create new lists pNames = new char *[nSize]; pExtra = new int32_t [nSize]; // copy names int32_t i; for(i = 0; i < nSize; i++) { pNames[i] = new char [SLen(pnNames[i]) + 1]; SCopy(pnNames[i], pNames[i], SLen(pnNames[i]) + 1); if(pnExtra) pExtra[i] = pnExtra[i]; } if(!pnExtra) ZeroMem(pExtra, sizeof (*pExtra) * nSize); // set new size iSize = nSize; // call OnNameListChanged list for all "child" lists C4ValueMapData *pAktData = pFirst; while(pAktData) { pAktData->OnNameListChanged(const_cast<const char **>(pOldNames), iOldSize); pAktData = pAktData->pNext; } // delete old list for(i = 0; i < iOldSize; i++) delete[] pOldNames[i]; delete[] pOldNames; delete[] pOldExtra; // ok. }