当前位置: 首页>>代码示例>>C++>>正文


C++ FSerializer类代码示例

本文整理汇总了C++中FSerializer的典型用法代码示例。如果您正苦于以下问题:C++ FSerializer类的具体用法?C++ FSerializer怎么用?C++ FSerializer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了FSerializer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: STAT_Serialize

void STAT_Serialize(FSerializer &arc)
{
	FString startlevel;
	int i = LevelData.Size();

	if (arc.BeginObject("statistics"))
	{
		if (arc.isReading())
		{
			arc("startlevel", startlevel);
			StartEpisode = NULL;
			for (unsigned int j = 0; j < AllEpisodes.Size(); j++)
			{
				if (!AllEpisodes[j].mEpisodeMap.CompareNoCase(startlevel))
				{
					StartEpisode = &AllEpisodes[j];
					break;
				}
			}
			LevelData.Resize(i);
		}
		else
		{
			if (StartEpisode != NULL) startlevel = StartEpisode->mEpisodeMap;
			arc("startlevel", startlevel);
		}
		arc("levels", LevelData);
		arc.EndObject();
	}
}
开发者ID:Jayman2000,项目名称:zdoom-pull,代码行数:30,代码来源:statistics.cpp

示例2: P_WriteACSDefereds

void P_WriteACSDefereds (FSerializer &arc)
{
	bool found = false;

	// only write this stuff if needed
	for (auto &wi : wadlevelinfos)
	{
		if (wi.deferred.Size() > 0)
		{
			found = true;
			break;
		}
	}
	if (found && arc.BeginObject("deferred"))
	{
		for (auto &wi : wadlevelinfos)
		{
			if (wi.deferred.Size() > 0)
			{
				if (wi.deferred.Size() > 0)
				{
					arc(wi.MapName, wi.deferred);
				}
			}
		}
		arc.EndObject();
	}
}
开发者ID:floverdevel,项目名称:zdoom,代码行数:28,代码来源:g_level.cpp

示例3: RecurseWriteFields

static void RecurseWriteFields(const PClass *type, FSerializer &ar, const void *addr)
{
	if (type != nullptr)
	{
		RecurseWriteFields(type->ParentClass, ar, addr);
		// Don't write this part if it has no non-transient variables
		for (unsigned i = 0; i < type->Fields.Size(); ++i)
		{
			if (!(type->Fields[i]->Flags & (VARF_Transient|VARF_Meta)))
			{
				// Tag this section with the class it came from in case
				// a more-derived class has variables that shadow a less-
				// derived class. Whether or not that is a language feature
				// that will actually be allowed remains to be seen.
				FString key;
				key.Format("class:%s", type->TypeName.GetChars());
				if (ar.BeginObject(key.GetChars()))
				{
					type->VMType->Symbols.WriteFields(ar, addr);
					ar.EndObject();
				}
				break;
			}
		}
	}
}
开发者ID:ArcticPheenix,项目名称:gzdoom,代码行数:26,代码来源:dobjtype.cpp

示例4: StaticWriteRNGState

void FRandom::StaticWriteRNGState (FSerializer &arc)
{
	FRandom *rng;

	arc("rngseed", rngseed);

	if (arc.BeginArray("rngs"))
	{
		for (rng = FRandom::RNGList; rng != NULL; rng = rng->Next)
		{
			// Only write those RNGs that have names
			if (rng->NameCRC != 0)
			{
				if (arc.BeginObject(nullptr))
				{
					arc("crc", rng->NameCRC)
						("index", rng->idx)
						.Array("u", rng->sfmt.u, SFMT::N32)
						.EndObject();
				}
			}
		}
		arc.EndArray();
	}
}
开发者ID:Blzut3,项目名称:gzdoom,代码行数:25,代码来源:m_random.cpp

示例5: StaticReadRNGState

void FRandom::StaticReadRNGState(FSerializer &arc)
{
	FRandom *rng;

	arc("rngseed", rngseed);

	// Call StaticClearRandom in order to ensure that SFMT is initialized
	FRandom::StaticClearRandom ();

	if (arc.BeginArray("rngs"))
	{
		int count = arc.ArraySize();

		for (int i = 0; i < count; i++)
		{
			if (arc.BeginObject(nullptr))
			{
				uint32_t crc;
				arc("crc", crc);

				for (rng = FRandom::RNGList; rng != NULL; rng = rng->Next)
				{
					if (rng->NameCRC == crc)
					{
						arc("index", rng->idx)
							.Array("u", rng->sfmt.u, SFMT::N32);
						break;
					}
				}
				arc.EndObject();
			}
		}
		arc.EndArray();
	}
}
开发者ID:Blzut3,项目名称:gzdoom,代码行数:35,代码来源:m_random.cpp

示例6: G_UnSnapshotLevel

void G_UnSnapshotLevel (bool hubLoad)
{
	if (level.info->Snapshot.mBuffer == nullptr)
		return;

	if (level.info->isValid())
	{
		FSerializer arc;
		if (!arc.OpenReader(&level.info->Snapshot))
		{
			I_Error("Failed to load savegame");
			return;
		}

		G_SerializeLevel (arc, hubLoad);
		level.FromSnapshot = true;

		TThinkerIterator<APlayerPawn> it;
		APlayerPawn *pawn, *next;

		next = it.Next();
		while ((pawn = next) != 0)
		{
			next = it.Next();
			if (pawn->player == NULL || pawn->player->mo == NULL || !playeringame[pawn->player - players])
			{
				int i;

				// If this isn't the unmorphed original copy of a player, destroy it, because it's extra.
				for (i = 0; i < MAXPLAYERS; ++i)
				{
					if (playeringame[i] && players[i].morphTics && players[i].mo->tracer == pawn)
					{
						break;
					}
				}
				if (i == MAXPLAYERS)
				{
					pawn->Destroy ();
				}
			}
		}
	}
	// No reason to keep the snapshot around once the level's been entered.
	level.info->Snapshot.Clean();
	if (hubLoad)
	{
		// Unlock ACS global strings that were locked when the snapshot was made.
		FBehavior::StaticUnlockLevelVarStrings();
	}
}
开发者ID:floverdevel,项目名称:zdoom,代码行数:51,代码来源:g_level.cpp

示例7: ReadOnePlayer

static void ReadOnePlayer(FSerializer &arc, bool skipload)
{
	int i;
	const char *name = NULL;
	bool didIt = false;

	if (arc.BeginObject(nullptr))
	{
		arc.StringPtr("playername", name);

		for (i = 0; i < MAXPLAYERS; ++i)
		{
			if (playeringame[i])
			{
				if (!didIt)
				{
					didIt = true;
					player_t playerTemp;
					playerTemp.Serialize(arc);
					if (!skipload)
					{
						// This temp player has undefined pitch limits, so set them to something
						// that should leave the pitch stored in the savegame intact when
						// rendering. The real pitch limits will be set by P_SerializePlayers()
						// via a net command, but that won't be processed in time for a screen
						// wipe, so we need something here.
						playerTemp.MaxPitch = playerTemp.MinPitch = playerTemp.mo->Angles.Pitch;
						CopyPlayer(&players[i], &playerTemp, name);
					}
					else
					{
						// we need the player actor, so that G_FinishTravel can destroy it later.
						players[i].mo = playerTemp.mo;
					}
				}
				else
				{
					if (players[i].mo != NULL)
					{
						players[i].mo->Destroy();
						players[i].mo = NULL;
					}
				}
			}
		}
		arc.EndObject();
	}
}
开发者ID:XaserAcheron,项目名称:zdoom,代码行数:48,代码来源:p_saveg.cpp

示例8: G_SnapshotLevel

void G_SnapshotLevel ()
{
	level.info->Snapshot.Clean();

	if (level.info->isValid())
	{
		FSerializer arc;

		if (arc.OpenWriter(save_formatted))
		{
			SaveVersion = SAVEVER;
			G_SerializeLevel(arc, false);
			level.info->Snapshot = arc.GetCompressedOutput();
		}
	}
}
开发者ID:floverdevel,项目名称:zdoom,代码行数:16,代码来源:g_level.cpp

示例9: Serialize

void FRemapTable::Serialize(FSerializer &arc)
{
	int n = NumEntries;

	arc("numentries", NumEntries);
	if (arc.isReading())
	{
		if (n != NumEntries)
		{
			Free();
			Alloc(NumEntries);
		}
	}
	arc.Array("remap", Remap, NumEntries);
	arc.Array("palette", Palette, NumEntries);
}
开发者ID:emileb,项目名称:gzdoom,代码行数:16,代码来源:r_translate.cpp

示例10: ReadAllFields

bool PClass::ReadAllFields(FSerializer &ar, void *addr) const
{
	bool readsomething = false;
	bool foundsomething = false;
	const char *key;
	key = ar.GetKey();
	if (strcmp(key, "classtype"))
	{
		// this does not represent a DObject
		Printf(TEXTCOLOR_RED "trying to read user variables but got a non-object (first key is '%s')", key);
		ar.mErrors++;
		return false;
	}
	while ((key = ar.GetKey()))
	{
		if (strncmp(key, "class:", 6))
		{
			// We have read all user variable blocks.
			break;
		}
		foundsomething = true;
		PClass *type = PClass::FindClass(key + 6);
		if (type != nullptr)
		{
			// Only read it if the type is related to this one.
			if (IsDescendantOf(type))
			{
				if (ar.BeginObject(nullptr))
				{
					readsomething |= type->VMType->Symbols.ReadFields(ar, addr, type->TypeName.GetChars());
					ar.EndObject();
				}
			}
			else
			{
				DPrintf(DMSG_ERROR, "Unknown superclass %s of class %s\n",
					type->TypeName.GetChars(), TypeName.GetChars());
			}
		}
		else
		{
			DPrintf(DMSG_ERROR, "Unknown superclass %s of class %s\n",
				key+6, TypeName.GetChars());
		}
	}
	return readsomething || !foundsomething;
}
开发者ID:ArcticPheenix,项目名称:gzdoom,代码行数:47,代码来源:dobjtype.cpp

示例11: EndSerialize

void FGLInterface::EndSerialize(FSerializer &arc)
{
	if (arc.isReading())
	{
		gl_RecreateAllAttachedLights();
		gl_InitPortals();
	}
}
开发者ID:nashmuhandes,项目名称:GZDoom-GPL,代码行数:8,代码来源:gl_scene.cpp

示例12: StartSerialize

void FGLInterface::StartSerialize(FSerializer &arc)
{
	if (arc.BeginObject("glinfo"))
	{
		arc("fogdensity", fogdensity)
			("outsidefogdensity", outsidefogdensity)
			("skyfog", skyfog)
			.EndObject();
	}
}
开发者ID:nashmuhandes,项目名称:GZDoom-GPL,代码行数:10,代码来源:gl_scene.cpp

示例13: Serialize

void DElevator::Serialize(FSerializer &arc)
{
	Super::Serialize (arc);
	arc.Enum("type", m_Type)
		("direction", m_Direction)
		("floordestdist", m_FloorDestDist)
		("ceilingdestdist", m_CeilingDestDist)
		("speed", m_Speed)
		("interp_floor", m_Interp_Floor)
		("interp_ceiling", m_Interp_Ceiling);
}
开发者ID:ArcticPheenix,项目名称:gzdoom,代码行数:11,代码来源:p_floor.cpp

示例14: P_SerializeSounds

void P_SerializeSounds(FSerializer &arc)
{
	S_SerializeSounds(arc);
	DSeqNode::SerializeSequences (arc);
	const char *name = NULL;
	BYTE order;

	if (arc.isWriting())
	{
		order = S_GetMusic(&name);
	}
	arc.StringPtr("musicname", name)
		("musicorder", order);

	if (arc.isReading())
	{
		if (!S_ChangeMusic(name, order))
			if (level.cdtrack == 0 || !S_ChangeCDMusic(level.cdtrack, level.cdid))
				S_ChangeMusic(level.Music, level.musicorder);
	}
}
开发者ID:XaserAcheron,项目名称:zdoom,代码行数:21,代码来源:p_saveg.cpp

示例15: G_ReadVisited

void G_ReadVisited(FSerializer &arc)
{
	if (arc.BeginArray("visited"))
	{
		for (int s = arc.ArraySize(); s > 0; s--)
		{
			FString str;
			arc(nullptr, str);
			auto i = FindLevelInfo(str);
			if (i != nullptr) i->flags |= LEVEL_VISITED;
		}
		arc.EndArray();
	}

	arc.Array("randomclasses", SinglePlayerClass, MAXPLAYERS);

	if (arc.BeginObject("playerclasses"))
	{
		for (int i = 0; i < MAXPLAYERS; ++i)
		{
			FString key;
			key.Format("%d", i);
			arc(key, players[i].cls);
		}
		arc.EndObject();
	}
}
开发者ID:floverdevel,项目名称:zdoom,代码行数:27,代码来源:g_level.cpp


注:本文中的FSerializer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。