Esempio n. 1
0
int FTextureManager::ReadTexture (FArchive &arc)
{
	int usetype;
	const char *name;

	name = arc.ReadName ();
	if (name != NULL)
	{
		usetype = arc.ReadCount ();
		return GetTexture (name, usetype).GetIndex();
	}
	else return -1;
}
Esempio n. 2
0
static void SerializeStatistics(FArchive &arc)
{
	FString startlevel;
	int i = LevelData.Size();

	arc << i;

	if (arc.IsLoading()) 
	{
		arc << 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;
	}
	for(int j = 0; j < i; j++)
	{
		OneLevel &l = LevelData[j];

		arc << l.totalkills 
			<< l.killcount  
			<< l.totalsecrets
			<< l.secretcount
			<< l.leveltime;

		if (arc.IsStoring()) arc.WriteName(l.levelname);
		else strcpy(l.levelname, arc.ReadName());
	}
}
Esempio n. 3
0
void G_SerializeLevel (FArchive &arc, bool hubLoad)
{
	int i = level.totaltime;
	
	Renderer->StartSerialize(arc);

	arc << level.flags
		<< level.flags2
		<< level.fadeto
		<< level.found_secrets
		<< level.found_items
		<< level.killed_monsters
		<< level.gravity
		<< level.aircontrol
		<< level.teamdamage
		<< level.maptime
		<< i;

	if (SaveVersion >= 3313)
	{
		arc << level.nextmusic;
	}

	// Hub transitions must keep the current total time
	if (!hubLoad)
		level.totaltime = i;

	if (SaveVersion >= 4507)
	{
		arc << level.skytexture1 << level.skytexture2;
	}
	else
	{
		level.skytexture1 = TexMan.GetTexture(arc.ReadName(), FTexture::TEX_Wall, FTextureManager::TEXMAN_Overridable | FTextureManager::TEXMAN_ReturnFirst);
		level.skytexture2 = TexMan.GetTexture(arc.ReadName(), FTexture::TEX_Wall, FTextureManager::TEXMAN_Overridable | FTextureManager::TEXMAN_ReturnFirst);
	}
	if (arc.IsLoading())
	{
		sky1texture = level.skytexture1;
		sky2texture = level.skytexture2;
		R_InitSkyMap();
	}

	G_AirControlChanged ();

	BYTE t;

	// Does this level have scrollers?
	if (arc.IsStoring ())
	{
		t = level.Scrolls ? 1 : 0;
		arc << t;
	}
	else
	{
		arc << t;
		if (level.Scrolls)
		{
			delete[] level.Scrolls;
			level.Scrolls = NULL;
		}
		if (t)
		{
			level.Scrolls = new FSectorScrollValues[numsectors];
			memset (level.Scrolls, 0, sizeof(level.Scrolls)*numsectors);
		}
	}

	FBehavior::StaticSerializeModuleStates (arc);
	if (arc.IsLoading()) interpolator.ClearInterpolations();
	P_SerializeThinkers (arc, hubLoad);
	P_SerializeWorld (arc);
	P_SerializePolyobjs (arc);
	P_SerializeSubsectors(arc);
	StatusBar->Serialize (arc);

	if (SaveVersion >= 4222)
	{ // This must be done *after* thinkers are serialized.
		arc << level.DefaultSkybox;
	}

	arc << level.total_monsters << level.total_items << level.total_secrets;

	// Does this level have custom translations?
	FRemapTable *trans;
	WORD w;
	if (arc.IsStoring ())
	{
		for (unsigned int i = 0; i < translationtables[TRANSLATION_LevelScripted].Size(); ++i)
		{
			trans = translationtables[TRANSLATION_LevelScripted][i];
			if (trans != NULL && !trans->IsIdentity())
			{
				w = WORD(i);
				arc << w;
				trans->Serialize(arc);
			}
		}
		w = 0xffff;
		arc << w;
	}
	else
	{
		while (arc << w, w != 0xffff)
		{
			trans = translationtables[TRANSLATION_LevelScripted].GetVal(w);
			if (trans == NULL)
			{
				trans = new FRemapTable;
				translationtables[TRANSLATION_LevelScripted].SetVal(w, trans);
			}
			trans->Serialize(arc);
		}
	}

	// This must be saved, too, of course!
	FCanvasTextureInfo::Serialize (arc);
	AM_SerializeMarkers(arc);

	P_SerializePlayers (arc, hubLoad);
	P_SerializeSounds (arc);
	if (arc.IsLoading())
	{
		for (i = 0; i < numsectors; i++)
		{
			P_Recalculate3DFloors(&sectors[i]);
		}
		for (i = 0; i < MAXPLAYERS; ++i)
		{
			if (playeringame[i] && players[i].mo != NULL)
			{
				players[i].mo->SetupWeaponSlots();
			}
		}
	}
	Renderer->EndSerialize(arc);
}