src/oldloader.cpp
changeset 6574 e1d1a12faaf7
parent 6573 7624f942237f
child 6585 7da94b26498a
equal deleted inserted replaced
6573:7624f942237f 6574:e1d1a12faaf7
    25 	BUFFER_SIZE = 4096,
    25 	BUFFER_SIZE = 4096,
    26 
    26 
    27 	OLD_MAP_SIZE = 256 * 256
    27 	OLD_MAP_SIZE = 256 * 256
    28 };
    28 };
    29 
    29 
    30 typedef struct LoadgameState {
    30 struct LoadgameState {
    31 	FILE *file;
    31 	FILE *file;
    32 
    32 
    33 	uint chunk_size;
    33 	uint chunk_size;
    34 
    34 
    35 	bool decoding;
    35 	bool decoding;
    39 	uint buffer_cur;
    39 	uint buffer_cur;
    40 	byte buffer[BUFFER_SIZE];
    40 	byte buffer[BUFFER_SIZE];
    41 
    41 
    42 	uint total_read;
    42 	uint total_read;
    43 	bool failed;
    43 	bool failed;
    44 } LoadgameState;
    44 };
    45 
    45 
    46 /* OldChunk-Type */
    46 /* OldChunk-Type */
    47 typedef enum OldChunkTypes {
    47 enum OldChunkType {
    48 	OC_SIMPLE    = 0,
    48 	OC_SIMPLE    = 0,
    49 	OC_NULL      = 1,
    49 	OC_NULL      = 1,
    50 	OC_CHUNK     = 2,
    50 	OC_CHUNK     = 2,
    51 	OC_ASSERT    = 3,
    51 	OC_ASSERT    = 3,
    52 	/* 8 bytes allocated (256 max) */
    52 	/* 8 bytes allocated (256 max) */
    76 	OC_UINT32    = OC_VAR_U32  | OC_FILE_U32,
    76 	OC_UINT32    = OC_VAR_U32  | OC_FILE_U32,
    77 
    77 
    78 	OC_TILE      = OC_VAR_U32  | OC_FILE_U16,
    78 	OC_TILE      = OC_VAR_U32  | OC_FILE_U16,
    79 
    79 
    80 	OC_END       = 0 ///< End of the whole chunk, all 32bits set to zero
    80 	OC_END       = 0 ///< End of the whole chunk, all 32bits set to zero
    81 } OldChunkType;
    81 };
    82 
    82 
    83 DECLARE_ENUM_AS_BIT_SET(OldChunkType);
    83 DECLARE_ENUM_AS_BIT_SET(OldChunkType);
    84 
    84 
    85 typedef bool OldChunkProc(LoadgameState *ls, int num);
    85 typedef bool OldChunkProc(LoadgameState *ls, int num);
    86 
    86 
    87 typedef struct OldChunks {
    87 struct OldChunks {
    88 	OldChunkType type;   ///< Type of field
    88 	OldChunkType type;   ///< Type of field
    89 	uint32 amount;       ///< Amount of fields
    89 	uint32 amount;       ///< Amount of fields
    90 
    90 
    91 	void *ptr;           ///< Pointer where to save the data (may only be set if offset is 0)
    91 	void *ptr;           ///< Pointer where to save the data (may only be set if offset is 0)
    92 	uint offset;         ///< Offset from basepointer (may only be set if ptr is NULL)
    92 	uint offset;         ///< Offset from basepointer (may only be set if ptr is NULL)
    93 	OldChunkProc *proc;  ///< Pointer to function that is called with OC_CHUNK
    93 	OldChunkProc *proc;  ///< Pointer to function that is called with OC_CHUNK
    94 } OldChunks;
    94 };
    95 
    95 
    96 /* If it fails, check lines above.. */
    96 /* If it fails, check lines above.. */
    97 assert_compile(sizeof(TileIndex) == 4);
    97 assert_compile(sizeof(TileIndex) == 4);
    98 
    98 
    99 static uint32 _bump_assert_value;
    99 static uint32 _bump_assert_value;