예제 #1
0
void P_ReadACSDefereds (PNGHandle *png)
{
	BYTE namelen;
	char mapname[256];
	size_t chunklen;

	P_RemoveDefereds ();

	if ((chunklen = M_FindPNGChunk (png, ACSD_ID)) != 0)
	{
		FPNGChunkArchive arc (png->File->GetFile(), ACSD_ID, chunklen);

		arc << namelen;
		while (namelen)
		{
			arc.Read (mapname, namelen);
			mapname[namelen] = 0;
			level_info_t *i = FindLevelInfo (mapname);
			if (i == NULL)
			{
				I_Error ("Unknown map '%s' in savegame", mapname);
			}
			arc << i->defered;
			arc << namelen;
		}
	}
	png->File->ResetFilePtr();
}
예제 #2
0
FTexture *PNGTexture_CreateFromFile(PNGHandle *png, const FString &filename)
{
	uint32_t width, height;
	uint8_t bitdepth, colortype, compression, filter, interlace;

	if (M_FindPNGChunk(png, MAKE_ID('I','H','D','R')) == 0)
	{
		return NULL;
	}

	// Check the IHDR to make sure it's a type of PNG we support.
	png->File->Read(&width, 4);
	png->File->Read(&height, 4);
	(*png->File) >> bitdepth >> colortype >> compression >> filter >> interlace;

	if (compression != 0 || filter != 0 || interlace > 1)
	{
		return NULL;
	}
	if (!((1 << colortype) & 0x5D))
	{
		return NULL;
	}
	if (!((1 << bitdepth) & 0x116))
	{
		return NULL;
	}

	return new FPNGTexture (*png->File, -1, filename, BigLong((int)width), BigLong((int)height),
		bitdepth, colortype, interlace);
}
예제 #3
0
void STAT_Read(PNGHandle *png)
{
	DWORD chunkLen = (DWORD)M_FindPNGChunk (png, STAT_ID);
	if (chunkLen != 0)
	{
		FPNGChunkArchive arc (png->File->GetFile(), STAT_ID, chunkLen);
		SerializeStatistics(arc);
	}
}
예제 #4
0
void G_ReadHubInfo (PNGHandle *png)
{
	int chunklen;

	if ((chunklen = M_FindPNGChunk (png, HUBS_ID)) != 0)
	{
		FPNGChunkArchive arc (png->File->GetFile(), HUBS_ID, chunklen);
		G_SerializeHub(arc);
	}
}
예제 #5
0
void FRandom::StaticReadRNGState (PNGHandle *png)
{
	FRandom *rng;

	size_t len = M_FindPNGChunk (png, RAND_ID);

	if (len != 0)
	{
		const size_t sizeof_rng = sizeof(rng->NameCRC) + sizeof(rng->idx) + sizeof(rng->sfmt.u);
		const int rngcount = (int)((len-4) / sizeof_rng);
		int i;
		DWORD crc;

		FPNGChunkArchive arc (png->File->GetFile(), RAND_ID, len);

		arc << rngseed;
		FRandom::StaticClearRandom ();

		for (i = rngcount; i; --i)
		{
			arc << crc;
			for (rng = FRandom::RNGList; rng != NULL; rng = rng->Next)
			{
				if (rng->NameCRC == crc)
				{
					arc << rng->idx;
					for (int i = 0; i < SFMT::N32; ++i)
					{
						arc << rng->sfmt.u[i];
					}
					break;
				}
			}
			if (rng == NULL)
			{ // The RNG was removed. Skip it.
				int idx;
				DWORD sfmt;
				arc << idx;
				for (int i = 0; i < SFMT::N32; ++i)
				{
					arc << sfmt;
				}
			}
		}
		png->File->ResetFilePtr();
	}
}
예제 #6
0
void P_ReadACSDefereds (PNGHandle *png)
{
	BYTE namelen;
	char mapname[256];
	FString MapName;
	size_t chunklen;

	P_RemoveDefereds ();

	if ((chunklen = M_FindPNGChunk (png, ACSD_ID)) != 0)
	{
		FPNGChunkArchive arc (png->File->GetFile(), ACSD_ID, chunklen);

		if (SaveVersion < 4508)
		{
			arc << namelen;
			while (namelen != 0)
			{
				arc.Read(mapname, namelen);
				mapname[namelen] = 0;
				level_info_t *i = FindLevelInfo(mapname);
				if (i == NULL)
				{
					I_Error("Unknown map '%s' in savegame", mapname);
				}
				arc << i->defered;
				arc << namelen;
			}
		}
		else
		{
			while (arc << MapName, MapName.Len() > 0)
			{
				level_info_t *i = FindLevelInfo(MapName);
				if (i == NULL)
				{
					I_Error("Unknown map '%s' in savegame", MapName.GetChars());
				}
				arc << i->defered;
			}
		}
	}
	png->File->ResetFilePtr();
}
예제 #7
0
void P_ReadACSDefereds (PNGHandle *png)
{
	FString MapName;
	size_t chunklen;

	P_RemoveDefereds ();

	if ((chunklen = M_FindPNGChunk (png, ACSD_ID)) != 0)
	{
		FPNGChunkArchive arc (png->File->GetFile(), ACSD_ID, chunklen);

		while (arc << MapName, MapName.Len() > 0)
		{
			level_info_t *i = FindLevelInfo(MapName);
			if (i == NULL)
			{
				I_Error("Unknown map '%s' in savegame", MapName.GetChars());
			}
			arc << i->defered;
		}
	}
	png->File->ResetFilePtr();
}
예제 #8
0
void G_ReadSnapshots (PNGHandle *png)
{
	DWORD chunkLen;
	BYTE namelen;
	char mapname[256];
	level_info_t *i;

	G_ClearSnapshots ();

	chunkLen = (DWORD)M_FindPNGChunk (png, SNAP_ID);
	while (chunkLen != 0)
	{
		FPNGChunkArchive arc (png->File->GetFile(), SNAP_ID, chunkLen);
		DWORD snapver;

		arc << snapver;
		arc << namelen;
		arc.Read (mapname, namelen);
		mapname[namelen] = 0;
		i = FindLevelInfo (mapname);
		i->snapshotVer = snapver;
		i->snapshot = new FCompressedMemFile;
		i->snapshot->Serialize (arc);
		chunkLen = (DWORD)M_NextPNGChunk (png, SNAP_ID);
	}

	chunkLen = (DWORD)M_FindPNGChunk (png, DSNP_ID);
	if (chunkLen != 0)
	{
		FPNGChunkArchive arc (png->File->GetFile(), DSNP_ID, chunkLen);
		DWORD snapver;

		arc << snapver;
		arc << namelen;
		arc.Read (mapname, namelen);
		TheDefaultLevelInfo.snapshotVer = snapver;
		TheDefaultLevelInfo.snapshot = new FCompressedMemFile;
		TheDefaultLevelInfo.snapshot->Serialize (arc);
	}

	chunkLen = (DWORD)M_FindPNGChunk (png, VIST_ID);
	if (chunkLen != 0)
	{
		FPNGChunkArchive arc (png->File->GetFile(), VIST_ID, chunkLen);

		arc << namelen;
		while (namelen != 0)
		{
			arc.Read (mapname, namelen);
			mapname[namelen] = 0;
			i = FindLevelInfo (mapname);
			i->flags |= LEVEL_VISITED;
			arc << namelen;
		}
	}

	chunkLen = (DWORD)M_FindPNGChunk (png, RCLS_ID);
	if (chunkLen != 0)
	{
		FPNGChunkArchive arc (png->File->GetFile(), PCLS_ID, chunkLen);
		SBYTE cnum;

		for (DWORD j = 0; j < chunkLen; ++j)
		{
			arc << cnum;
			SinglePlayerClass[j] = cnum;
		}
	}

	chunkLen = (DWORD)M_FindPNGChunk (png, PCLS_ID);
	if (chunkLen != 0)
	{
		FPNGChunkArchive arc (png->File->GetFile(), RCLS_ID, chunkLen);
		BYTE pnum;

		arc << pnum;
		while (pnum != 255)
		{
			arc.UserReadClass (players[pnum].cls);
			arc << pnum;
		}
	}
	png->File->ResetFilePtr();
}