.com.unity Forums
  The Official e-Store of Shrapnel Games

This Month's Specials

BCT Commander- $6.00
winSPMBT: Main Battle Tank- Save $5.00

   







Go Back   .com.unity Forums > The Camo Workshop > WinSPWW2
Notices


Reply
 
Thread Tools Display Modes
  #21  
Old April 8th, 2019, 05:08 PM
ErikCumps's Avatar

ErikCumps ErikCumps is offline
Private
 
Join Date: Jan 2019
Location: Leuven, Belgium
Posts: 16
Thanks: 4
Thanked 8 Times in 4 Posts
ErikCumps is on a distinguished road
Post Re: OT: looking for zovs66

Hi Mark,

The savegame data is stored in multiple blocks, some compressed and some not.

This comment from my source code explains it quite well, I think:
Code:
/* This is the SPWaW/winSPWW2 savegame file format:
 *
 * A savegame is a contiguous set of several data blocks.
 *
 * The first data block is the game info section.
 * This is a fixed-size data block containing the savegame marker.
 * (which is currently "SPWAW_SAVE_V101"/"SPCTS_SAVE_V100" for SPWaW/winSPWW2)
 *
 * The other data blocks contain the savegame section data.
 *
 * Each data block consists of:
 *	 a data block header
 *	 the section data.
 *
 * The fixed-size data block header describes the section data that follows:
 *	the identification number of the section
 *	the size of the section data
 *	a flag indicating if the section data is compressed or not
 *
 * Uncompressed section data can be loaded as-is.
 *
 * Compressed section data must be decompressed after loading.
 * The actual size of the section data will be larger than the size of the section data in the file.
 */

/* This is the SPWaW/winSPWW2 section data compression format:
 *
 * Compressed section data is a contiguous set of run-length coded data blocks.
 *
 * There are two types of run-length coded data blocks:
 *	uncompressed run-length coded data (URLC)
 *	compressed run-length coded data (CRLC)
 *
 * Each run-length coded data block consists of:
 *	a run-length coding byte (RLB)
 *	one or more data bytes
 *
 * A compressed run-length coded data block is used to for sequences of identical data bytes:
 *	the RLB indicates the number of identical data bytes (N)
 *	the RLB is followed by a single data byte (B)
 *	the decompressed data is the sequence of N times the data byte B
 *
 * An uncompressed run-length coded data block is used for sequences of data bytes with mixed values:
 *	the RLB indicates the number of data bytes that follow (N)
 *	there is at least 1 and maximum 127 data bytes
 *	the N data bytes can be copied as-is
 */
The concrete block header layout for winSPWW2 is this:
Code:
#pragma pack(push, r1, 1)
typedef struct s_BLOCKHEAD_WINSPWW2 {
	unsigned int	section;
	unsigned int	size;
	unsigned char	flag;
} BLOCKHEAD_WINSPWW2;
#pragma pack(pop, r1)
If the 'flag' value is 0, the section data is NOT compressed.
If the 'flag' value is 1, the section data IS compressed.

Note: the two #pragma's you see are not part of the actual data layout, they are just hints to the compiler that it should respect the data layout as is and not insert additional padding between fields.

Hope this helps,
Erik
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 12:52 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright ©1999 - 2019, Shrapnel Games, Inc. - All Rights Reserved.