コード例 #1
0
ファイル: C4Sector.cpp プロジェクト: Meowtimer/openclonk
void C4LSectors::Dump()
{
	C4ValueNumbers numbers;
	LogSilent(DecompileToBuf<StdCompilerINIWrite>(
	            mkNamingAdapt(
	              mkArrayAdaptMap(Sectors, Size, mkParAdaptMaker(&numbers)),
	              "Sector")).getData());
}
コード例 #2
0
ファイル: C4Scenario.cpp プロジェクト: lluchs/clonk-rage
void C4SWeather::CompileFunc(StdCompiler *pComp)
  {
  pComp->Value(mkNamingAdapt(Climate,                 "Climate",               C4SVal(50,10), true));
  pComp->Value(mkNamingAdapt(StartSeason,             "StartSeason",           C4SVal(50,50), true));
  pComp->Value(mkNamingAdapt(YearSpeed,               "YearSpeed",               C4SVal(50)));
  pComp->Value(mkNamingAdapt(Rain,                    "Rain",                  C4SVal()));
  pComp->Value(mkNamingAdapt(Wind,                    "Wind",                  C4SVal(0,70,-100,+100), true));
  pComp->Value(mkNamingAdapt(Lightning,               "Lightning",             C4SVal()));
  pComp->Value(mkNamingAdapt(mkStringAdaptMA(Precipitation),"Precipitation",   "Water"));
  pComp->Value(mkNamingAdapt(NoGamma,                 "NoGamma",               TRUE));
  }
コード例 #3
0
bool C4ObjectInfoCore::Compile(const char *szSource)
{
	bool ret = CompileFromBuf_LogWarn<StdCompilerINIRead>(
	             mkNamingAdapt(*this, "ObjectInfo"),
	             StdStrBuf(szSource),
	             "ObjectInfo");
	// DeathMessages are not allowed to stay forever
	if ('@' == DeathMessage[0]) DeathMessage[0] = ' ';
	return ret;
}
コード例 #4
0
ファイル: C4Scenario.cpp プロジェクト: Rocket-Fish/openclonk
void C4Scenario::CompileFunc(StdCompiler *pComp, bool fSection)
{
	pComp->Value(mkNamingAdapt(mkParAdapt(Head, fSection), "Head"));
	if (!fSection) pComp->Value(mkNamingAdapt(Definitions, "Definitions"));
	pComp->Value(mkNamingAdapt(mkParAdapt(Game, fSection), "Game"));
	for (int32_t i = 0; i < C4S_MaxPlayer; i++)
		pComp->Value(mkNamingAdapt(PlrStart[i], FormatString("Player%d", i+1).getData()));
	pComp->Value(mkNamingAdapt(Landscape, "Landscape"));
	pComp->Value(mkNamingAdapt(Animals, "Animals"));
	pComp->Value(mkNamingAdapt(Weather, "Weather"));
	pComp->Value(mkNamingAdapt(Environment, "Environment"));
}
コード例 #5
0
void C4Network2ResCore::CompileFunc(StdCompiler *pComp)
{
	pComp->Value(mkNamingAdapt(mkEnumAdaptT<uint8_t>(eType, C4Network2ResType_EnumMap), "Type", NRT_Null));
	pComp->Value(mkNamingAdapt(iID, "ID", -1));
	pComp->Value(mkNamingAdapt(iDerID, "DerID", -1));
	pComp->Value(mkNamingAdapt(fLoadable, "Loadable", true));
	if (fLoadable)
	{
		pComp->Value(mkNamingAdapt(iFileSize, "FileSize", 0U));
		pComp->Value(mkNamingAdapt(iFileCRC, "FileCRC", 0U));
		pComp->Value(mkNamingAdapt(iChunkSize, "ChunkSize", C4NetResChunkSize));
		if (!iChunkSize) pComp->excCorrupt("zero chunk size");
	}
	pComp->Value(mkNamingAdapt(iContentsCRC, "ContentsCRC", 0U));
	pComp->Value(mkNamingCountAdapt(fHasFileSHA, "FileSHA"));
	if (fHasFileSHA)
		pComp->Value(mkNamingAdapt(mkHexAdapt(FileSHA), "FileSHA"));
	pComp->Value(mkNamingAdapt(mkNetFilenameAdapt(FileName), "Filename", ""));
}
コード例 #6
0
ファイル: C4Update.cpp プロジェクト: ev1313/yaC
void C4UpdatePackageCore::CompileFunc(StdCompiler *pComp) {
    pComp->Value(mkNamingAdapt(toC4CArr(RequireVersion), "RequireVersion"));
    pComp->Value(mkNamingAdapt(toC4CStr(Name), "Name", ""));
    pComp->Value(mkNamingAdapt(toC4CStr(DestPath), "DestPath", ""));
    pComp->Value(mkNamingAdapt(GrpUpdate, "GrpUpdate", 0));
    pComp->Value(mkNamingAdapt(UpGrpCnt, "TargetCount", 0));
    pComp->Value(mkNamingAdapt(toC4CArrU(GrpChks1), "GrpChks1"));
    pComp->Value(mkNamingAdapt(GrpChks2, "GrpChks2", 0u));
}
コード例 #7
0
ファイル: C4Network2IO.cpp プロジェクト: 772/openclonk
void C4PacketPostMortem::CompileFunc(StdCompiler *pComp)
{
    bool fCompiler = pComp->isCompiler();

    // Connection ID, packet number and packet count
    pComp->Value(mkNamingAdapt(iConnID, "ConnID"));
    pComp->Value(mkNamingAdapt(iPacketCounter, "PacketCounter"));
    pComp->Value(mkNamingAdapt(iPacketCount, "PacketCount"));

    // Packets
    if (fCompiler)
    {
        // Read packets
        for (uint32_t i = 0; i < iPacketCount; i++)
        {
            // Create list entry
            PacketLink *pLink = new PacketLink();
            pLink->Next = pPackets;
            pPackets = pLink;
            // Compile data
            pComp->Value(mkNamingAdapt(pLink->Pkt, "PacketData"));
        }
        // Reverse order
        PacketLink *pPackets2 = pPackets;
        pPackets = NULL;
        while (pPackets2)
        {
            // Get link
            PacketLink *pLink = pPackets2;
            pPackets2 = pLink->Next;
            // Readd to list
            pLink->Next = pPackets;
            pPackets = pLink;
        }
    }
    else
    {
        // Write packets
        for (PacketLink *pLink = pPackets; pLink; pLink = pLink->Next)
            pComp->Value(mkNamingAdapt(pLink->Pkt, "PacketData"));
    }
}
コード例 #8
0
ファイル: C4ObjectList.cpp プロジェクト: 772/openclonk
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;
			}
		}
	}
}
コード例 #9
0
ファイル: C4Client.cpp プロジェクト: Meowtimer/openclonk
void C4ClientList::CompileFunc(StdCompiler *pComp)
{
	// Clear existing data
	bool fCompiler = pComp->isCompiler();
	if (fCompiler) Clear();
	// Client count
	uint32_t iClientCnt = getClientCnt();
	pComp->Value(mkNamingCountAdapt(iClientCnt, "Client"));
	// Compile all clients
	if (pComp->isCompiler())
		for (uint32_t i = 0; i < iClientCnt; i++)
		{
			C4Client *pClient = new C4Client();
			pComp->Value(mkNamingAdapt(*pClient, "Client"));
			Add(pClient);
		}
	else
		for (C4Client *pClient = pFirst; pClient; pClient = pClient->pNext)
			pComp->Value(mkNamingAdapt(*pClient, "Client"));
}
コード例 #10
0
ファイル: C4Client.cpp プロジェクト: Meowtimer/openclonk
void C4ClientCore::CompileFunc(StdCompiler *pComp)
{
	pComp->Value(mkNamingAdapt(iID, "ID", C4ClientIDUnknown));
	pComp->Value(mkNamingAdapt(fActivated, "Activated", false));
	pComp->Value(mkNamingAdapt(fObserver, "Observer", false));
	pComp->Value(mkNamingAdapt(Name, "Name", ""));
	pComp->Value(mkNamingAdapt(CUID, "CUID", ""));
	pComp->Value(mkNamingAdapt(Nick, "Nick", ""));
	pComp->Value(mkNamingAdapt(Revision, "Revision", ""));
}
コード例 #11
0
ファイル: C4Material.cpp プロジェクト: Rocket-Fish/openclonk
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             ));
}
コード例 #12
0
ファイル: C4Fonts.cpp プロジェクト: Marko10-000/clonk-rage
void C4FontDef::CompileFunc(StdCompiler * pComp)
	{
	pComp->Value(mkNamingAdapt(toC4CStrBuf(Name),        "Name",        ""));
	pComp->Value(mkNamingAdapt(iSize,                    "Size",         1));
	pComp->Value(mkNamingAdapt(toC4CStrBuf(LogFont),     "LogFont",     ""));
	pComp->Value(mkNamingAdapt(toC4CStrBuf(SmallFont),   "SmallFont",   ""));
	pComp->Value(mkNamingAdapt(toC4CStrBuf(Font),        "Font",        ""));
	pComp->Value(mkNamingAdapt(toC4CStrBuf(CaptionFont), "CaptionFont", ""));
	pComp->Value(mkNamingAdapt(toC4CStrBuf(TitleFont),   "TitleFont",   ""));		
	}
コード例 #13
0
void C4RoundResultsPlayer::CompileFunc(StdCompiler *pComp)
{
	// remember to adjust operator = and == when adding values here!
	pComp->Value(mkNamingAdapt(id,    "ID",   0));
	// pComp->Value(mkNamingAdapt(fctBigIcon,    "Icon",      C4TargetFacet())); - not possible
	pComp->Value(mkNamingAdapt(iTotalPlayingTime,  "TotalPlayingTime",    0u));
	pComp->Value(mkNamingAdapt(iScoreOld,  "SettlementScoreOld",    -1));
	pComp->Value(mkNamingAdapt(iScoreNew,  "SettlementScoreNew",    -1));
	pComp->Value(mkNamingAdapt(iLeagueScoreNew,  "Score",    -1));          // name used in league reply!
	pComp->Value(mkNamingAdapt(iLeagueScoreGain,  "GameScore",    -1));     // name used in league reply!
	pComp->Value(mkNamingAdapt(iLeagueRankNew,  "Rank",    0));             // name used in league reply!
	pComp->Value(mkNamingAdapt(iLeagueRankSymbolNew,  "RankSymbol",    0)); // name used in league reply!
	pComp->Value(mkNamingAdapt(sLeagueProgressData,  "LeagueProgressData",    StdCopyStrBuf()));
	StdEnumEntry<LeagueStatus> LeagueStatusEntries[] =
	{
		{ "",     RRPLS_Unknown },
		{ "Lost", RRPLS_Lost    },
		{ "Won",  RRPLS_Won     },
	};
	pComp->Value(mkNamingAdapt(mkEnumAdaptT<uint8_t>(eLeagueStatus, LeagueStatusEntries),  "Status",    RRPLS_Unknown));            // name used in league reply!
}
コード例 #14
0
bool C4RoundResults::Load(C4Group &hGroup, const char *szFilename)
{
	// clear previous
	Clear();
	// load file contents
	StdStrBuf Buf;
	if (!hGroup.LoadEntryString(szFilename, &Buf)) return false;
	// compile
	if (!CompileFromBuf_LogWarn<StdCompilerINIRead>(mkNamingAdapt(*this, "RoundResults"), Buf, szFilename)) return false;
	// done, success
	return true;
}
コード例 #15
0
ファイル: C4InfoCore.cpp プロジェクト: lluchs/clonk-rage
BOOL C4ObjectInfoCore::Compile(const char *szSource)
	{
	bool ret = CompileFromBuf_LogWarn<StdCompilerINIRead>(
								mkNamingAdapt(*this, "ObjectInfo"), 
								StdStrBuf(szSource),
								"ObjectInfo");
	// Do a promotion update to set physicals right
	Physical.PromotionUpdate(Rank);
	// DeathMessages are not allowed to stay forever
	if ('@' == DeathMessage[0]) DeathMessage[0] = ' ';
	return ret;
	}
コード例 #16
0
ファイル: C4Teams.cpp プロジェクト: sarah-russell12/openclonk
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));
}
コード例 #17
0
ファイル: C4Packet2.cpp プロジェクト: Rocket-Fish/openclonk
void C4PacketList::CompileFunc(StdCompiler *pComp)
{
	// unpack packets
	if (pComp->isCompiler())
	{
		// Read until no further sections available
		while (pComp->Name("IDPacket"))
		{
			// Read the packet
			C4IDPacket *pPkt = new C4IDPacket();
			try
			{
				pComp->Value(*pPkt);
				pComp->NameEnd();
			}
			catch (...)
			{
				delete pPkt;
				throw;
			}
			// Terminator?
			if (!pPkt->getPkt()) { delete pPkt; break; }
			// Add to list
			Add(pPkt);
		}
		pComp->NameEnd();
	}
	else
	{
		// Write all packets
		for (C4IDPacket *pPkt = pFirst; pPkt; pPkt = pPkt->pNext)
			pComp->Value(mkNamingAdapt(*pPkt, "IDPacket"));
		// Terminate, if no naming is available
		if (!pComp->hasNaming())
		{
			C4IDPacket Pkt;
			pComp->Value(mkNamingAdapt(Pkt, "IDPacket"));
		}
	}
}
コード例 #18
0
ファイル: C4Scoreboard.cpp プロジェクト: Fulgen301/openclonk
void C4Scoreboard::CompileFunc(StdCompiler *pComp)
{
	bool deserializing = pComp->isDeserializer();
	if (deserializing) Clear();
	pComp->Value(mkNamingAdapt(iRows,     "Rows",     0));
	pComp->Value(mkNamingAdapt(iCols,     "Cols",     0));
	pComp->Value(mkNamingAdapt(iDlgShow,  "DlgShow",  0));
	if (iRows * iCols)
	{
		if (deserializing) pEntries = new Entry[iRows * iCols];
		for (int32_t iRow = 0; iRow < iRows; ++iRow)
			for (int32_t iCol = 0; iCol < iCols; ++iCol)
			{
				Entry *pEnt = GetCell(iCol, iRow);
				pComp->Value(mkNamingAdapt(pEnt->Text, FormatString("Cell%i_%iString", iCol, iRow).getData()));
				pComp->Value(mkNamingAdapt(pEnt->iVal, FormatString("Cell%i_%iValue", iCol, iRow).getData()));
			}
		// recheck dlg show in read mode
		// will usually not do anything, because reading is done before enetering shared mode
		if (pComp->isDeserializer()) DoDlgShow(0, false);
	}
}
コード例 #19
0
ファイル: C4Update.cpp プロジェクト: ev1313/yaC
BOOL C4UpdatePackageCore::Load(C4Group &hGroup) {
    // Load from group
    StdStrBuf Source;
    if (!hGroup.LoadEntryString(C4CFN_UpdateCore, Source)) return FALSE;
    try {
        // Compile data
        CompileFromBuf<StdCompilerINIRead>(mkNamingAdapt(*this, "Update"), Source);
    } catch (StdCompiler::Exception *pExc) {
        delete pExc;
        return FALSE;
    }
    return TRUE;
}
コード例 #20
0
ファイル: C4Scenario.cpp プロジェクト: gitMarky/openclonk
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));
	pComp->Value(mkNamingAdapt(EvaluateOnAbort,                                   "EvaluateOnAbort", false));
}
コード例 #21
0
ファイル: C4Record.cpp プロジェクト: ev1313/clonk-rage
void C4RecordChunk::CompileFunc(StdCompiler *pComp) {
  pComp->Value(mkNamingAdapt(Frame, "Frame"));
  pComp->Value(mkNamingAdapt(mkIntAdapt(Type), "Type"));
  switch (Type) {
    case RCT_Ctrl:
      pComp->Value(mkPtrAdaptNoNull(pCtrl));
      break;
    case RCT_CtrlPkt:
      pComp->Value(mkPtrAdaptNoNull(pPkt));
      break;
    case RCT_End:
      break;
    case RCT_Frame:
      break;
    case RCT_File:
      pComp->Value(Filename);
      pComp->Value(mkPtrAdaptNoNull(pFileData));
      break;
    default:
      pComp->Value(mkPtrAdaptNoNull(pDbg));
      break;
  }
}
コード例 #22
0
ファイル: C4Update.cpp プロジェクト: ev1313/yaC
BOOL C4UpdatePackageCore::Save(C4Group &hGroup) {
    try {
        // decompile data
        StdStrBuf Core =
            DecompileToBuf<StdCompilerINIWrite>(mkNamingAdapt(*this, "Update"));
        char *stupid_buffer = new char[Core.getLength() + 1];
        memcpy(stupid_buffer, Core.getMData(), Core.getLength() + 1);
        // add to group
        return hGroup.Add(C4CFN_UpdateCore, stupid_buffer, Core.getLength(), FALSE,
                          TRUE);
    } catch (StdCompiler::Exception *pExc) {
        delete pExc;
        return FALSE;
    }
}
コード例 #23
0
ファイル: C4Update.cpp プロジェクト: ev1313/yaC
BOOL C4UpdatePackage::Load(C4Group *pGroup) {
    // read update core
    StdStrBuf Source;
    if (!pGroup->LoadEntryString(C4CFN_UpdateCore, Source)) return FALSE;
    try {
        // Compile data
        CompileFromBuf<StdCompilerINIRead>(mkNamingAdapt(*this, "Update"), Source);
    } catch (StdCompiler::Exception *pExc) {
        StdStrBuf Name = pGroup->GetFullName() + DirSep + C4CFN_UpdateCore;
        WriteLog("ERROR: %s (in %s)", pExc->Msg.getData(), Name.getData());
        delete pExc;
        return FALSE;
    }
    return TRUE;
}
コード例 #24
0
ファイル: C4Record.cpp プロジェクト: ev1313/clonk-rage
StdStrBuf C4Playback::ReWriteText() {
  // Would work, too, but is currently too slow due to bad buffering inside
  // StdCompilerINIWrite:
  // return
  // DecompileToBuf<StdCompilerINIWrite>(mkNamingAdapt(mkSTLContainerAdapt(chunks),
  // "Rec"));
  StdStrBuf Output;
  for (chunks_t::const_iterator i = chunks.begin(); i != chunks.end(); i++) {
    Output.Append(
        static_cast<const StdStrBuf &>(DecompileToBuf<StdCompilerINIWrite>(
            mkNamingAdapt(mkDecompileAdapt(*i), "Rec"))));
    Output.Append("\n\n");
  }
  return Output;
}
コード例 #25
0
bool C4ObjectInfoCore::Decompile(char **ppOutput, size_t *ipSize)
{
	StdStrBuf Buf;
	if (!DecompileToBuf_Log<StdCompilerINIWrite>(
	      mkNamingAdapt(*this, "ObjectInfo"),
	      &Buf,
	      "ObjectInfo"))
	{
		if (ppOutput) *ppOutput = NULL;
		if (ipSize) *ipSize = 0;
		return false;
	}
	if (ppOutput) *ppOutput = Buf.GrabPointer();
	if (ipSize) *ipSize = Buf.getSize();
	return true;
}
コード例 #26
0
ファイル: C4Teams.cpp プロジェクト: sarah-russell12/openclonk
bool C4TeamList::Save(C4Group &hGroup)
{
	// remove previous entry from group
	hGroup.DeleteEntry(C4CFN_Teams);
	// decompile
	try
	{
		StdStrBuf Buf = DecompileToBuf<StdCompilerINIWrite>(mkNamingAdapt(*this, "Teams"));
		// save it
		hGroup.Add(C4CFN_Teams, Buf, false, true);
	}
	catch (StdCompiler::Exception *)
		{ return false; }
	// done, success
	return true;
}
コード例 #27
0
void C4ScenarioParameterDef::CompileFunc(StdCompiler *pComp)
{
	if (!pComp->Name("ParameterDef")) { pComp->NameEnd(); pComp->excNotFound("ParameterDef"); }
	pComp->Value(mkNamingAdapt(mkParAdapt(Name, StdCompiler::RCT_All),          "Name",         StdCopyStrBuf()));
	pComp->Value(mkNamingAdapt(mkParAdapt(Description, StdCompiler::RCT_All),   "Description",  StdCopyStrBuf()));
	pComp->Value(mkNamingAdapt(mkParAdapt(ID, StdCompiler::RCT_Idtf),           "ID",           StdCopyStrBuf()));
	StdEnumEntry<ParameterType> ParTypeEntries[] =
	{
		{ "Enumeration", SPDT_Enum },
		{ nullptr, SPDT_Enum }
	};
	pComp->Value(mkNamingAdapt(mkEnumAdaptT<uint8_t>(Type, ParTypeEntries),         "Type",         SPDT_Enum));
	pComp->Value(mkNamingAdapt(Default,                                             "Default",      0));
	pComp->Value(mkNamingAdapt(LeagueValue,                                         "LeagueValue",  0));
	pComp->Value(mkNamingAdapt(mkParAdapt(Achievement, StdCompiler::RCT_Idtf),      "Achievement",  StdCopyStrBuf()));
	pComp->Value(mkNamingAdapt(mkSTLContainerAdapt(Options, StdCompiler::SEP_NONE), "Options"));
	pComp->NameEnd();
}
コード例 #28
0
bool C4RoundResults::Save(C4Group &hGroup, const char *szFilename)
{
	// remove previous entry from group
	hGroup.DeleteEntry(szFilename);
	// decompile
	try
	{
		StdStrBuf Buf = DecompileToBuf<StdCompilerINIWrite>(mkNamingAdapt(*this, "RoundResults"));
		// save it, if not empty
		if (Buf.getLength())
			if (!hGroup.Add(szFilename, Buf, false, true))
				return false;
	}
	catch (StdCompiler::Exception *)
		{ return false; }
	// done, success
	return true;
}
コード例 #29
0
void C4RoundResults::CompileFunc(StdCompiler *pComp)
{
	bool fCompiler = pComp->isCompiler();
	if (fCompiler) Clear();
	pComp->Value(mkNamingAdapt(Goals, "Goals", C4IDList()));
	pComp->Value(mkNamingAdapt(iPlayingTime, "PlayingTime", 0u));
	pComp->Value(mkNamingAdapt(fHideSettlementScore, "HideSettlementScore", Game.C4S.Game.IsMelee()));
	pComp->Value(mkNamingAdapt(sCustomEvaluationStrings, "CustomEvaluationStrings", StdCopyStrBuf()));
	pComp->Value(mkNamingAdapt(iLeaguePerformance, "LeaguePerformance", 0));
	pComp->Value(mkNamingAdapt(Players, "PlayerInfos", C4RoundResultsPlayers()));
	pComp->Value(mkNamingAdapt(sNetResult, "NetResult", StdCopyStrBuf()));
	StdEnumEntry<NetResult> NetResultEntries[] =
	{
		{ "",            NR_None       },
		{ "LeagueOK",    NR_LeagueOK   },
		{ "LeagueError", NR_LeagueError},
		{ "NetError",    NR_NetError   },
	};
	pComp->Value(mkNamingAdapt(mkEnumAdaptT<uint8_t>(eNetResult, NetResultEntries), "NetResult", NR_None));
}
コード例 #30
0
void C4RoundResultsPlayers::CompileFunc(StdCompiler *pComp)
{
	bool fCompiler = pComp->isCompiler();
	if (fCompiler) Clear();
	int32_t iTemp = iPlayerCount;
	pComp->Value(mkNamingCountAdapt<int32_t>(iTemp, "Player"));
	if (iTemp < 0 || iTemp > C4MaxPlayer)
		{ pComp->excCorrupt("player count out of range"); return; }
	// Grow list, if necessary
	if (fCompiler && iTemp > iPlayerCapacity)
	{
		GrowList(iTemp - iPlayerCapacity);
		iPlayerCount = iTemp;
		ZeroMem(ppPlayers, sizeof(*ppPlayers) * iPlayerCount);
	}
	// Compile
	pComp->Value(mkNamingAdapt(mkArrayAdaptMap(ppPlayers, iPlayerCount, mkPtrAdaptNoNull<C4RoundResultsPlayer>), "Player"));
	// Force specialization
	mkPtrAdaptNoNull<C4RoundResultsPlayer>(*ppPlayers);
}