void C4PacketJoinData::CompileFunc(StdCompiler *pComp) { pComp->Value(mkNamingAdapt(mkIntPackAdapt(iClientID), "ClientID", C4ClientIDUnknown)); pComp->Value(mkNamingAdapt(mkIntPackAdapt(iStartCtrlTick), "CtrlTick", -1)); pComp->Value(mkNamingAdapt(mkParAdapt(GameStatus, true), "GameStatus")); pComp->Value(mkNamingAdapt(Dynamic, "Dynamic")); pComp->Value(mkNamingAdapt(ScenarioParameterDefs, "ParameterDefs")); pComp->Value(Parameters); }
void C4ObjectList::CompileFunc(StdCompiler *pComp, bool fSkipPlayerObjects, C4ValueNumbers * numbers) { // "Object" section count int32_t iObjCnt = ObjectCount(); pComp->Value(mkNamingCountAdapt(iObjCnt, "Object")); if (pComp->isDecompiler()) { // skipping player objects would screw object counting in non-naming compilers assert(!fSkipPlayerObjects || pComp->hasNaming()); // Decompile all objects in reverse order for (C4ObjectLink *pPos = Last; pPos; pPos = pPos->Prev) if (pPos->Obj->Status) if (!fSkipPlayerObjects || !pPos->Obj->IsUserPlayerObject()) pComp->Value(mkNamingAdapt(mkParAdapt(*pPos->Obj, numbers), "Object")); } else { // FIXME: Check that no PlayerObjects are loaded when fSkipPlayerObjects is true // i.e. that loading and saving was done with the same flag. // Remove previous data Clear(); // Load objects, add them to the list. for (int i = 0; i < iObjCnt; i++) { C4Object *pObj = NULL; try { pComp->Value(mkNamingAdapt(mkParAdapt(mkPtrAdaptNoNull(pObj), numbers), "Object")); Add(pObj, stReverse); } catch (StdCompiler::Exception *pExc) { // Failsafe object loading: If an error occurs during object loading, just skip that object and load the next one if (!pExc->Pos.getLength()) LogF("ERROR: Object loading: %s", pExc->Msg.getData()); else LogF("ERROR: Object loading(%s): %s", pExc->Pos.getData(), pExc->Msg.getData()); delete pExc; } } } }
void C4PropListStatic::RefCompileFunc(StdCompiler *pComp, C4ValueNumbers * numbers) const { assert(!pComp->isCompiler()); if (Parent) { Parent->RefCompileFunc(pComp, numbers); pComp->Separator(StdCompiler::SEP_PART); } if (!ParentKeyName) pComp->excCorrupt("C4PropListStatic::RefCompileFunc without ParentKeyName"); pComp->Value(mkParAdapt(ParentKeyName->GetData(), StdCompiler::RCT_ID)); }
void C4MaterialReaction::CompileFunc(StdCompiler *pComp) { if (pComp->isCompiler()) pScriptFunc = NULL; // compile reaction func ptr StdStrBuf sReactionFuncName; int32_t i=0; while (ReactionFuncMap[i].szRFName && (ReactionFuncMap[i].pFunc != pFunc)) ++i; sReactionFuncName = ReactionFuncMap[i].szRFName; pComp->Value(mkNamingAdapt(mkParAdapt(sReactionFuncName, StdCompiler::RCT_IdtfAllowEmpty), "Type", StdCopyStrBuf() )); i=0; while (ReactionFuncMap[i].szRFName && !SEqual(ReactionFuncMap[i].szRFName, sReactionFuncName.getData())) ++i; pFunc = ReactionFuncMap[i].pFunc; // compile the rest pComp->Value(mkNamingAdapt(mkParAdapt(TargetSpec, StdCompiler::RCT_All), "TargetSpec", StdCopyStrBuf() )); pComp->Value(mkNamingAdapt(mkParAdapt(ScriptFunc, StdCompiler::RCT_IdtfAllowEmpty), "ScriptFunc", StdCopyStrBuf() )); pComp->Value(mkNamingAdapt(iExecMask, "ExecMask", ~0u )); pComp->Value(mkNamingAdapt(fReverse, "Reverse", false )); pComp->Value(mkNamingAdapt(fInverseSpec, "InverseSpec", false )); pComp->Value(mkNamingAdapt(fInsertionCheck, "CheckSlide", true )); pComp->Value(mkNamingAdapt(iDepth, "Depth", 0 )); pComp->Value(mkNamingAdapt(mkParAdapt(sConvertMat, StdCompiler::RCT_IdtfAllowEmpty), "ConvertMat", StdCopyStrBuf() )); pComp->Value(mkNamingAdapt(iCorrosionRate, "CorrosionRate", 100 )); }
bool C4Scenario::Load(C4Group &hGroup, bool fLoadSection, bool suppress_errors) { StdStrBuf Buf; if (!hGroup.LoadEntryString(C4CFN_ScenarioCore,&Buf)) return false; if (!fLoadSection) Default(); if (suppress_errors) { if (!CompileFromBuf_Log<StdCompilerINIRead>(mkParAdapt(*this, fLoadSection), Buf, C4CFN_ScenarioCore)) { return false; } } else { if (!CompileFromBuf_LogWarn<StdCompilerINIRead>(mkParAdapt(*this, fLoadSection), Buf, C4CFN_ScenarioCore)) { return false; } } return true; }
bool C4Scenario::Save(C4Group &hGroup, bool fSaveSection) { StdStrBuf Buf; try { Buf.Take(DecompileToBuf<StdCompilerINIWrite>(mkParAdapt(*this, fSaveSection))); } catch (StdCompiler::Exception *) { return false; } if (!hGroup.Add(C4CFN_ScenarioCore,Buf,false,true)) { return false; } return true; }
void C4Team::CompileFunc(StdCompiler *pComp) { if (pComp->isCompiler()) Clear(); pComp->Value(mkNamingAdapt(iID, "id", 0)); pComp->Value(mkNamingAdapt(mkStringAdaptMA(Name), "Name", "")); pComp->Value(mkNamingAdapt(iPlrStartIndex, "PlrStartIndex", 0)); pComp->Value(mkNamingAdapt(iPlayerCount, "PlayerCount", 0)); if (pComp->isCompiler()) { delete [] piPlayers; piPlayers = new int32_t [iPlayerCapacity = iPlayerCount]; ZeroMem(piPlayers, sizeof(*piPlayers) * iPlayerCount); } pComp->Value(mkNamingAdapt(mkArrayAdapt(piPlayers, iPlayerCount, -1), "Players")); pComp->Value(mkNamingAdapt(dwClr, "Color", 0u)); pComp->Value(mkNamingAdapt(mkParAdapt(sIconSpec, StdCompiler::RCT_All), "IconSpec", StdCopyStrBuf())); pComp->Value(mkNamingAdapt(iMaxPlayer, "MaxPlayer", 0)); }
void C4SGame::CompileFunc(StdCompiler *pComp, bool fSection) { if (!fSection) { pComp->Value(mkNamingAdapt(Realism.ValueOverloads, "ValueOverloads", C4IDList())); } pComp->Value(mkNamingAdapt(mkRuntimeValueAdapt(Realism.LandscapePushPull), "LandscapePushPull", false)); pComp->Value(mkNamingAdapt(mkRuntimeValueAdapt(Realism.LandscapeInsertThrust), "LandscapeInsertThrust",true)); pComp->Value(mkNamingAdapt(mkParAdapt(Mode, StdCompiler::RCT_IdtfAllowEmpty), "Mode", StdCopyStrBuf())); pComp->Value(mkNamingAdapt(Goals, "Goals", C4IDList())); pComp->Value(mkNamingAdapt(Rules, "Rules", C4IDList())); pComp->Value(mkNamingAdapt(FoWEnabled, "FoWEnabled", true)); }
BOOL C4Scenario::Decompile(char **ppOutput, int32_t *ipSize, bool fSaveSection) { try { // Decompile StdStrBuf Buf = DecompileToBuf<StdCompilerINIWrite>(mkParAdapt(*this, fSaveSection)); // Return *ppOutput = Buf.GrabPointer(); *ipSize = Buf.getSize(); } catch(StdCompiler::Exception *) { return FALSE; } return TRUE; }
void C4Property::CompileFunc(StdCompiler *pComp, C4ValueNumbers * numbers) { StdStrBuf s; if (!pComp->isCompiler()) s = Key->GetData(); pComp->Value(s); if (pComp->isCompiler()) { if (Key) Key->DecRef(); Key = ::Strings.RegString(s); Key->IncRef(); } pComp->Separator(StdCompiler::SEP_SET); pComp->Value(mkParAdapt(Value, numbers)); }
void C4SHead::CompileFunc(StdCompiler *pComp, bool fSection) { if (!fSection) { pComp->Value(mkNamingAdapt(Icon, "Icon", 18)); pComp->Value( mkNamingAdapt(mkStringAdaptMA(Title), "Title", "Default Title")); pComp->Value(mkNamingAdapt(mkStringAdaptMA(Loader), "Loader", "")); pComp->Value(mkNamingAdapt(mkStringAdaptMA(Font), "Font", "")); pComp->Value(mkNamingAdapt(mkArrayAdaptDM(C4XVer, 0), "Version")); pComp->Value(mkNamingAdapt(Difficulty, "Difficulty", 0)); pComp->Value(mkNamingAdapt(EnableUnregisteredAccess, "Access", FALSE)); pComp->Value(mkNamingAdapt(MaxPlayer, "MaxPlayer", C4S_MaxPlayerDefault)); pComp->Value(mkNamingAdapt(MaxPlayerLeague, "MaxPlayerLeague", MaxPlayer)); pComp->Value(mkNamingAdapt(MinPlayer, "MinPlayer", 0)); pComp->Value(mkNamingAdapt(SaveGame, "SaveGame", FALSE)); pComp->Value(mkNamingAdapt(Replay, "Replay", FALSE)); pComp->Value(mkNamingAdapt(Film, "Film", FALSE)); pComp->Value(mkNamingAdapt(DisableMouse, "DisableMouse", FALSE)); pComp->Value(mkNamingAdapt(IgnoreSyncChecks, "IgnoreSyncChecks", FALSE)); } pComp->Value(mkNamingAdapt(NoInitialize, "NoInitialize", FALSE)); pComp->Value(mkNamingAdapt(RandomSeed, "RandomSeed", 0)); if (!fSection) { pComp->Value(mkNamingAdapt(mkStringAdaptMA(Engine), "Engine", "")); pComp->Value( mkNamingAdapt(mkStringAdaptMA(MissionAccess), "MissionAccess", "")); pComp->Value(mkNamingAdapt(NetworkGame, "NetworkGame", false)); pComp->Value( mkNamingAdapt(NetworkRuntimeJoin, "NetworkRuntimeJoin", false)); pComp->Value(mkNamingAdapt(ForcedGfxMode, "ForcedGfxMode", 0)); pComp->Value(mkNamingAdapt(ForcedFairCrew, "ForcedNoCrew", 0)); pComp->Value(mkNamingAdapt(FairCrewStrength, "DefCrewStrength", 0)); pComp->Value( mkNamingAdapt(ForcedAutoContextMenu, "ForcedAutoContextMenu", -1)); pComp->Value( mkNamingAdapt(ForcedControlStyle, "ForcedAutoStopControl", -1)); pComp->Value( mkNamingAdapt(mkStrValAdapt(mkParAdapt(Origin, StdCompiler::RCT_All), C4InVal::VAL_SubPathFilename), "Origin", StdCopyStrBuf())); // windows needs backslashes in Origin; other systems use forward slashes if (pComp->isCompiler()) Origin.ReplaceChar(AltDirectorySeparator, DirectorySeparator); } }
static void GlobalEffectsMergeCompileFunc(StdCompiler *pComp, C4Effect * & pEffects, const char * name, C4PropList * pForObj, C4ValueNumbers * numbers) { C4Effect *pOldEffect, *pNextOldEffect=pEffects; pEffects = nullptr; try { pComp->Value(mkParAdapt(mkNamingPtrAdapt(pEffects, name), pForObj, numbers)); } catch (...) { delete pNextOldEffect; throw; } while ((pOldEffect=pNextOldEffect)) { pNextOldEffect = pOldEffect->pNext; pOldEffect->Register(&pEffects, Abs(pOldEffect->iPriority)); } }
void C4PlayerInfoCore::CompileFunc(StdCompiler *pComp) { C4ValueNumbers numbers; pComp->Name("Player"); pComp->Value(mkNamingAdapt(toC4CStr(PrefName),"Name", "Neuling")); pComp->Value(mkNamingAdapt(toC4CStr(Comment), "Comment", "")); pComp->Value(mkNamingAdapt(Rank, "Rank", 0)); pComp->Value(mkNamingAdapt(toC4CStr(RankName),"RankName", LoadResStr("IDS_MSG_RANK"))); // TODO: check if this would be desirable pComp->Value(mkNamingAdapt(TotalScore, "Score", 0)); pComp->Value(mkNamingAdapt(Rounds, "Rounds", 0)); pComp->Value(mkNamingAdapt(RoundsWon, "RoundsWon", 0)); pComp->Value(mkNamingAdapt(RoundsLost, "RoundsLost", 0)); pComp->Value(mkNamingAdapt(TotalPlayingTime, "TotalPlayingTime", 0)); pComp->Value(mkNamingAdapt(mkParAdapt(ExtraData, &numbers), "ExtraData", C4ValueMapData())); pComp->Value(mkNamingAdapt(numbers, "ExtraDataValues")); if (pComp->isCompiler()) { numbers.Denumerate(); ExtraData.Denumerate(&numbers); } pComp->Value(mkNamingAdapt(toC4CStr(LeagueName),"LeagueName", "")); pComp->NameEnd(); pComp->Name("Preferences"); pComp->Value(mkNamingAdapt(PrefColor, "Color", 0)); pComp->Value(mkNamingAdapt(PrefColorDw, "ColorDw", 0xffu)); pComp->Value(mkNamingAdapt(PrefColor2Dw, "AlternateColorDw", 0u)); pComp->Value(mkNamingAdapt(PrefPosition, "Position", 0)); pComp->Value(mkNamingAdapt(PrefMouse, "Mouse", 1)); pComp->Value(mkNamingAdapt(OldPrefControl, "Control", 1)); pComp->Value(mkNamingAdapt(OldPrefControlStyle, "AutoStopControl", 0)); pComp->Value(mkNamingAdapt(OldPrefAutoContextMenu, "AutoContextMenu", -1)); // compiling default is -1 (if this is detected, AutoContextMenus will be defaulted by control style) pComp->Value(mkNamingAdapt(PrefControl, "ControlSet", StdStrBuf())); pComp->Value(mkNamingAdapt(PrefClonkSkin, "ClonkSkin", 0)); pComp->NameEnd(); pComp->Value(mkNamingAdapt(LastRound, "LastRound")); pComp->Value(mkNamingAdapt(Achievements, "Achievements")); }
void C4DefGraphicsAdapt::CompileFunc(StdCompiler *pComp) { bool fCompiler = pComp->isCompiler(); // nothing? if (!fCompiler && !pDefGraphics) return; // definition C4ID id; if (!fCompiler) id = pDefGraphics->pDef->id; pComp->Value(id); // go over two separators ("::"). Expect them if an id was found. if (!pComp->Separator(StdCompiler::SEP_PART2) || !pComp->Separator(StdCompiler::SEP_PART2)) pComp->excCorrupt("DefGraphics: expected \"::\""); // compile name StdStrBuf Name; if (!fCompiler) Name = pDefGraphics->GetName(); pComp->Value(mkDefaultAdapt(mkParAdapt(Name, StdCompiler::RCT_Idtf), "")); // reading: search def-graphics if (fCompiler) { // search definition, throw expection if not found C4Def *pDef = ::Definitions.ID2Def(id); // search def-graphics if (!pDef || !( pDefGraphics = pDef->Graphics.Get(Name.getData()) )) pComp->excCorrupt("DefGraphics: could not find graphics \"%s\" in %s(%s)!", Name.getData(), id.ToString(), pDef ? pDef->GetName() : "def not found"); } }
void C4Def::CompileFunc(StdCompiler *pComp) { pComp->Value(mkNamingAdapt(id, "id", C4ID::None )); pComp->Value(mkNamingAdapt(toC4CArr(rC4XVer), "Version" )); pComp->Value(mkNamingAdapt(mkParAdapt(RequireDef, false), "RequireDef", C4IDList() )); const StdBitfieldEntry<int32_t> Categories[] = { { "C4D_None", C4D_None }, { "C4D_StaticBack", C4D_StaticBack }, { "C4D_Structure", C4D_Structure }, { "C4D_Vehicle", C4D_Vehicle }, { "C4D_Living", C4D_Living }, { "C4D_Object", C4D_Object }, { "C4D_Goal", C4D_Goal }, { "C4D_Rule", C4D_Rule }, { "C4D_Environment", C4D_Environment }, { "C4D_Background", C4D_Background }, { "C4D_Parallax", C4D_Parallax }, { "C4D_MouseSelect", C4D_MouseSelect }, { "C4D_Foreground", C4D_Foreground }, { "C4D_MouseIgnore", C4D_MouseIgnore }, { "C4D_IgnoreFoW", C4D_IgnoreFoW }, { NULL, 0 } }; pComp->Value(mkNamingAdapt(mkBitfieldAdapt<int32_t>(Category, Categories), "Category", 0 )); pComp->Value(mkParAdapt(Shape, static_cast<C4Shape*>(NULL))); pComp->Value(mkNamingAdapt(Value, "Value", 0 )); pComp->Value(mkNamingAdapt(Mass, "Mass", 0 )); pComp->Value(mkNamingAdapt(SolidMask, "SolidMask", TargetRect0 )); pComp->Value(mkNamingAdapt(TopFace, "TopFace", TargetRect0 )); pComp->Value(mkNamingAdapt(PictureRect, "Picture", Rect0 )); pComp->Value(mkNamingAdapt(Entrance, "Entrance", Rect0 )); pComp->Value(mkNamingAdapt(Collection, "Collection", Rect0 )); pComp->Value(mkNamingAdapt(Exclusive, "Exclusive", 0 )); pComp->Value(mkNamingAdapt(Line, "Line", 0 )); // <Newton> undocumented, but obsolete? I don't understand the sense of this value. pComp->Value(mkNamingAdapt(LineIntersect, "LineIntersect", 0 )); pComp->Value(mkNamingAdapt(CrewMember, "CrewMember", 0 )); pComp->Value(mkNamingAdapt(NativeCrew, "NoStandardCrew", 0 )); pComp->Value(mkNamingAdapt(Constructable, "Construction", 0 )); const StdBitfieldEntry<int32_t> GrabPutGetTypes[] = { { "C4D_GrabGet" ,C4D_Grab_Get}, { "C4D_GrabPut" ,C4D_Grab_Put}, { NULL, 0} }; pComp->Value(mkNamingAdapt(mkBitfieldAdapt(GrabPutGet, GrabPutGetTypes), "GrabPutGet", 0 )); pComp->Value(mkNamingAdapt(Rotateable, "Rotate", 0 )); pComp->Value(mkNamingAdapt(RotatedEntrance, "RotatedEntrance", 0 )); pComp->Value(mkNamingAdapt(Float, "Float", 0 )); pComp->Value(mkNamingAdapt(ColorByOwner, "ColorByOwner", 0 )); pComp->Value(mkNamingAdapt(NoHorizontalMove, "HorizontalFix", 0 )); pComp->Value(mkNamingAdapt(LiftTop, "LiftTop", 0 )); pComp->Value(mkNamingAdapt(UprightAttach, "UprightAttach", 0 )); pComp->Value(mkNamingAdapt(GrowthType, "StretchGrowth", 0 )); pComp->Value(mkNamingAdapt(IncompleteActivity, "IncompleteActivity", 0 )); pComp->Value(mkNamingAdapt(AttractLightning, "AttractLightning", 0 )); pComp->Value(mkNamingAdapt(Oversize, "Oversize", 0 )); // <Newton> Fragile and Projectile are kinda obsolete. // Only used at one point in the command system. Should rather be solved with properties if at all pComp->Value(mkNamingAdapt(Fragile, "Fragile", 0 )); pComp->Value(mkNamingAdapt(Projectile, "Projectile", 0 )); pComp->Value(mkNamingAdapt(NoPushEnter, "NoPushEnter", 0 )); pComp->Value(mkNamingAdapt(VehicleControl, "VehicleControl", 0 )); pComp->Value(mkNamingAdapt(Pathfinder, "Pathfinder", 0 )); pComp->Value(mkNamingAdapt(MoveToRange, "MoveToRange", 0 )); pComp->Value(mkNamingAdapt(NoMassFromContents, "NoMassFromContents", 0 )); pComp->Value(mkNamingAdapt(NoStabilize, "NoStabilize", 0 )); pComp->Value(mkNamingAdapt(ClosedContainer, "ClosedContainer", 0 )); pComp->Value(mkNamingAdapt(SilentCommands, "SilentCommands", 0 )); pComp->Value(mkNamingAdapt(TemporaryCrew, "TemporaryCrew", 0 )); pComp->Value(mkNamingAdapt(BlitMode, "BlitMode", C4D_Blit_Normal )); pComp->Value(mkNamingAdapt(NoBreath, "NoBreath", 0 )); pComp->Value(mkNamingAdapt(ConSizeOff, "ConSizeOff", 0 )); pComp->Value(mkNamingAdapt(NoGet, "NoGet", 0 )); pComp->Value(mkNamingAdapt(NoTransferZones, "NoTransferZones", 0 )); const StdBitfieldEntry<int32_t> AllowPictureStackModes[] = { { "APS_Color", APS_Color }, { "APS_Graphics", APS_Graphics }, { "APS_Name", APS_Name }, { "APS_Overlay", APS_Overlay }, { NULL, 0 } }; pComp->Value(mkNamingAdapt(mkBitfieldAdapt<int32_t>(AllowPictureStack, AllowPictureStackModes), //undocumented "AllowPictureStack", 0 )); }
void C4MaterialCore::CompileFunc(StdCompiler *pComp) { assert(pComp->hasNaming()); if (pComp->isCompiler()) Clear(); pComp->Name("Material"); pComp->Value(mkNamingAdapt(toC4CStr(Name), "Name", "")); const StdEnumEntry<C4MaterialCoreShape> Shapes[] = { { "Flat", C4M_Flat }, { "TopFlat", C4M_TopFlat }, { "Smooth", C4M_Smooth }, { "Rough", C4M_Rough }, { "Octagon", C4M_Octagon }, { "Smoother", C4M_Smoother }, { NULL, C4M_Flat } }; pComp->Value(mkNamingAdapt(mkEnumAdaptT<uint8_t>(MapChunkType, Shapes), "Shape", C4M_Flat)); pComp->Value(mkNamingAdapt(Density, "Density", 0)); pComp->Value(mkNamingAdapt(Friction, "Friction", 0)); pComp->Value(mkNamingAdapt(DigFree, "DigFree", 0)); pComp->Value(mkNamingAdapt(BlastFree, "BlastFree", 0)); pComp->Value(mkNamingAdapt(Blast2Object, "Blast2Object", C4ID::None)); pComp->Value(mkNamingAdapt(Dig2Object, "Dig2Object", C4ID::None)); pComp->Value(mkNamingAdapt(Dig2ObjectRatio, "Dig2ObjectRatio", 0)); pComp->Value(mkNamingAdapt(Dig2ObjectCollect, "Dig2ObjectCollect", 0)); pComp->Value(mkNamingAdapt(Blast2ObjectRatio, "Blast2ObjectRatio", 0)); pComp->Value(mkNamingAdapt(Blast2PXSRatio, "Blast2PXSRatio", 0)); pComp->Value(mkNamingAdapt(Instable, "Instable", 0)); pComp->Value(mkNamingAdapt(MaxAirSpeed, "MaxAirSpeed", 0)); pComp->Value(mkNamingAdapt(MaxSlide, "MaxSlide", 0)); pComp->Value(mkNamingAdapt(WindDrift, "WindDrift", 0)); pComp->Value(mkNamingAdapt(Inflammable, "Inflammable", 0)); if (pComp->isCompiler()) { // The value used to have a wrong spelling ("Incindiary"). If there's // no "Incendiary" value, use the wrong spelling instead try { pComp->Value(mkNamingAdapt(Incendiary, "Incendiary")); } catch (StdCompiler::NotFoundException *ex) { delete ex; pComp->Value(mkNamingAdapt(Incendiary, "Incindiary", 0)); } } else { // When serializing, write both spellings because some script might be // calling GetMaterialVal with the wrong one pComp->Value(mkNamingAdapt(Incendiary, "Incendiary")); pComp->Value(mkNamingAdapt(Incendiary, "Incindiary")); } pComp->Value(mkNamingAdapt(Corrode, "Corrode", 0)); pComp->Value(mkNamingAdapt(Corrosive, "Corrosive", 0)); pComp->Value(mkNamingAdapt(Extinguisher, "Extinguisher", 0)); pComp->Value(mkNamingAdapt(Soil, "Soil", 0)); pComp->Value(mkNamingAdapt(Placement, "Placement", 0)); pComp->Value(mkNamingAdapt(Light, "Light", 0)); pComp->Value(mkNamingAdapt(mkParAdapt(sTextureOverlay, StdCompiler::RCT_IdtfAllowEmpty), "TextureOverlay", "")); pComp->Value(mkNamingAdapt(OverlayType, "OverlayType", 0)); pComp->Value(mkNamingAdapt(mkParAdapt(sPXSGfx, StdCompiler::RCT_IdtfAllowEmpty), "PXSGfx", "")); pComp->Value(mkNamingAdapt(PXSGfxRt, "PXSGfxRt", TargetRect0)); pComp->Value(mkNamingAdapt(PXSGfxSize, "PXSGfxSize", PXSGfxRt.Wdt)); pComp->Value(mkNamingAdapt(TempConvStrength, "TempConvStrength", 0)); pComp->Value(mkNamingAdapt(mkParAdapt(sBlastShiftTo, StdCompiler::RCT_IdtfAllowEmpty), "BlastShiftTo", "")); pComp->Value(mkNamingAdapt(mkParAdapt(sInMatConvert, StdCompiler::RCT_IdtfAllowEmpty), "InMatConvert", "")); pComp->Value(mkNamingAdapt(mkParAdapt(sInMatConvertTo, StdCompiler::RCT_IdtfAllowEmpty), "InMatConvertTo", "")); pComp->Value(mkNamingAdapt(InMatConvertDepth, "InMatConvertDepth", 0)); pComp->Value(mkNamingAdapt(AboveTempConvert, "AboveTempConvert", 0)); pComp->Value(mkNamingAdapt(AboveTempConvertDir, "AboveTempConvertDir", 0)); pComp->Value(mkNamingAdapt(mkParAdapt(sAboveTempConvertTo, StdCompiler::RCT_IdtfAllowEmpty), "AboveTempConvertTo", "")); pComp->Value(mkNamingAdapt(BelowTempConvert, "BelowTempConvert", 0)); pComp->Value(mkNamingAdapt(BelowTempConvertDir, "BelowTempConvertDir", 0)); pComp->Value(mkNamingAdapt(mkParAdapt(sBelowTempConvertTo, StdCompiler::RCT_IdtfAllowEmpty), "BelowTempConvertTo", "")); pComp->Value(mkNamingAdapt(MinHeightCount, "MinHeightCount", 0)); pComp->Value(mkNamingAdapt(SplashRate, "SplashRate", 10)); pComp->Value(mkNamingAdapt(KeepSinglePixels, "KeepSinglePixels", false)); pComp->Value(mkNamingAdapt(AnimationSpeed, "AnimationSpeed", 100)); pComp->Value(mkNamingAdapt(LightAngle, "LightAngle", 255)); pComp->Value(mkNamingAdapt(mkArrayAdaptDM(LightEmit, 0), "LightEmit")); pComp->Value(mkNamingAdapt(mkArrayAdaptDM(LightSpot, 16),"LightSpot")); pComp->Value(mkNamingAdapt(MinShapeOverlap, "MinShapeOverlap", 25)); pComp->NameEnd(); // material reactions pComp->Value(mkNamingAdapt(mkSTLContainerAdapt(CustomReactionList), "Reaction", std::vector<C4MaterialReaction>())); }
void CompileNewFunc(C4PropList *&pStruct, StdCompiler *pComp, C4ValueNumbers * const & rPar) { std::unique_ptr<C4PropList> temp(C4PropList::New()); // exception-safety pComp->Value(mkParAdapt(*temp, rPar)); pStruct = temp.release(); }
int C4GameObjects::Load(C4Group &hGroup, bool fKeepInactive) { Clear(!fKeepInactive); // Load data component StdStrBuf Source; if (!hGroup.LoadEntryString(C4CFN_ScenarioObjects, Source)) return 0; // Compile StdStrBuf Name = hGroup.GetFullName() + DirSep C4CFN_ScenarioObjects; if (!CompileFromBuf_LogWarn<StdCompilerINIRead>(mkParAdapt(*this, false), Source, Name.getData())) return 0; // Process objects C4ObjectLink *cLnk = nullptr; C4Object *pObj = nullptr; bool fObjectNumberCollision = false; int32_t iMaxObjectNumber = 0; for (cLnk = Last; cLnk; cLnk = cLnk->Prev) { C4Object *pObj = cLnk->Obj; // check object number collision with inactive list if (fKeepInactive) { for (C4ObjectLink *clnk = InactiveObjects.First; clnk; clnk = clnk->Next) if (clnk->Obj->Number == pObj->Number) fObjectNumberCollision = true; } // keep track of numbers iMaxObjectNumber = Max<long>(iMaxObjectNumber, pObj->Number); // add to list of backobjects if (pObj->Category & C4D_Background) Game.BackObjects.Add(pObj, C4ObjectList::stMain, this); // add to list of foreobjects if (pObj->Category & C4D_Foreground) Game.ForeObjects.Add(pObj, C4ObjectList::stMain, this); // Unterminate end } // Denumerate pointers // if object numbers collideded, numbers will be adjusted afterwards // so fake inactive object list empty meanwhile C4ObjectLink *pInFirst = nullptr; if (fObjectNumberCollision) { pInFirst = InactiveObjects.First; InactiveObjects.First = NULL; } // denumerate pointers Denumerate(); // update object enumeration index now, because calls like UpdateTransferZone // might create objects Game.ObjectEnumerationIndex = Max(Game.ObjectEnumerationIndex, iMaxObjectNumber); // end faking and adjust object numbers if (fObjectNumberCollision) { InactiveObjects.First = pInFirst; // simply renumber all inactive objects for (cLnk = InactiveObjects.First; cLnk; cLnk = cLnk->Next) if ((pObj = cLnk->Obj)->Status) pObj->Number = ++Game.ObjectEnumerationIndex; } // special checks: // -contained/contents-consistency // -StaticBack-objects zero speed for (cLnk = First; cLnk; cLnk = cLnk->Next) if ((pObj = cLnk->Obj)->Status) { // staticback must not have speed if (pObj->Category & C4D_StaticBack) { pObj->xdir = pObj->ydir = 0; } // contained must be in contents list if (pObj->Contained) if (!pObj->Contained->Contents.GetLink(pObj)) { DebugLogF( "Error in Objects.txt: Container of #%d is #%d, but not found in " "contents list!", pObj->Number, pObj->Contained->Number); pObj->Contained->Contents.Add(pObj, C4ObjectList::stContents); } // all contents must have contained set; otherwise, remove them! C4Object *pObj2; for (C4ObjectLink *cLnkCont = pObj->Contents.First; cLnkCont; cLnkCont = cLnkCont->Next) { // check double links if (pObj->Contents.GetLink(cLnkCont->Obj) != cLnkCont) { DebugLogF("Error in Objects.txt: Double containment of #%d by #%d!", cLnkCont->Obj->Number, pObj->Number); // this remove-call will only remove the previous (dobuled) link, so // cLnkCont should be save pObj->Contents.Remove(cLnkCont->Obj); // contents checked already continue; } // check contents/contained-relation if ((pObj2 = cLnkCont->Obj)->Status) if (pObj2->Contained != pObj) { DebugLogF( "Error in Objects.txt: Object #%d not in container #%d as " "referenced!", pObj2->Number, pObj->Number); pObj2->Contained = pObj; } } } // sort out inactive objects C4ObjectLink *cLnkNext; for (cLnk = First; cLnk; cLnk = cLnkNext) { cLnkNext = cLnk->Next; if (cLnk->Obj->Status == C4OS_INACTIVE) { if (cLnk->Prev) cLnk->Prev->Next = cLnkNext; else First = cLnkNext; if (cLnkNext) cLnkNext->Prev = cLnk->Prev; else Last = cLnk->Prev; if (cLnk->Prev = InactiveObjects.Last) InactiveObjects.Last->Next = cLnk; else InactiveObjects.First = cLnk; InactiveObjects.Last = cLnk; cLnk->Next = NULL; Mass -= pObj->Mass; } } { C4DebugRecOff DBGRECOFF; // - script callbacks that would kill // DebugRec-sync for runtime start // update graphics UpdateGraphics(false); // Update faces UpdateFaces(false); // Update ocf SetOCF(); } // make sure list is sorted by category - after sorting out inactives, because // inactives aren't sorted into the main list FixObjectOrder(); // Sectors.Dump(); // misc updates for (cLnk = First; cLnk; cLnk = cLnk->Next) if ((pObj = cLnk->Obj)->Status) { // add to plrview pObj->PlrFoWActualize(); // update flipdir (for old objects.txt with no flipdir defined) // assigns Action.DrawDir as well pObj->UpdateFlipDir(); } // Done return ObjectCount(); }
BOOL C4Scenario::Compile(const char *szSource, bool fLoadSection) { if (!fLoadSection) Default(); return CompileFromBuf_LogWarn<StdCompilerINIRead>(mkParAdapt(*this, fLoadSection), StdStrBuf(szSource), C4CFN_ScenarioCore); }
void C4KeyCodeEx::CompileFunc(StdCompiler *pComp, StdStrBuf *pOutBuf) { if (pComp->isCompiler()) { // reading from file StdStrBuf sCode; bool is_scan_code; // read shifts DWORD dwSetShift = 0; for (;;) { is_scan_code = pComp->Separator(StdCompiler::SEP_DOLLAR); if (!is_scan_code) pComp->NoSeparator(); pComp->Value(mkParAdapt(sCode, StdCompiler::RCT_Idtf)); if (is_scan_code) // scan codes start with $. Reassamble the two tokens that were split by StdCompiler { sCode.Take(FormatString("$%s", sCode.getData())); break; } if (!pComp->Separator(StdCompiler::SEP_PLUS)) break; // no more separator: Parse this as keyboard code // try to convert to shift state C4KeyShiftState eAddState = String2KeyShift(sCode); if (eAddState == KEYS_Undefined) pComp->excCorrupt("undefined key shift state: %s", sCode.getData()); dwSetShift |= eAddState; } // any code given? Otherwise, keep default if (sCode.getLength()) { // last section: convert to key code C4KeyCode eCode = String2KeyCode(sCode); if (eCode == KEY_Undefined) { if (pOutBuf) { // unknown key, but an output buffer for unknown keys was provided. No failure; caller might resolve key. eCode = KEY_Default; } else { pComp->excCorrupt("undefined key code: %s", sCode.getData()); } } dwShift = dwSetShift; Key = eCode; if (pOutBuf) pOutBuf->Take(std::move(sCode)); } } else { // write shift states for (DWORD dwShiftCheck = KEYS_First; dwShiftCheck <= KEYS_Max; dwShiftCheck <<= 1) if (dwShiftCheck & dwShift) { pComp->Value(mkDecompileAdapt(KeyShift2String((C4KeyShiftState) dwShiftCheck))); pComp->Separator(StdCompiler::SEP_PLUS); } // write key pComp->Value(mkDecompileAdapt(KeyCode2String(Key, false, false))); } }