newgrf_sl.cpp
Go to the documentation of this file.00001
00002
00005 #include "../stdafx.h"
00006 #include "../newgrf_config.h"
00007 #include "../core/bitmath_func.hpp"
00008 #include "../core/alloc_func.hpp"
00009 #include "../gfx_func.h"
00010
00011 #include "saveload.h"
00012
00013 static const SaveLoad _grfconfig_desc[] = {
00014 SLE_STR(GRFConfig, filename, SLE_STR, 0x40),
00015 SLE_VAR(GRFConfig, grfid, SLE_UINT32),
00016 SLE_ARR(GRFConfig, md5sum, SLE_UINT8, 16),
00017 SLE_ARR(GRFConfig, param, SLE_UINT32, 0x80),
00018 SLE_VAR(GRFConfig, num_params, SLE_UINT8),
00019 SLE_CONDVAR(GRFConfig, windows_paletted, SLE_BOOL, 101, SL_MAX_VERSION),
00020 SLE_END()
00021 };
00022
00023
00024 static void Save_NGRF()
00025 {
00026 int index = 0;
00027
00028 for (GRFConfig *c = _grfconfig; c != NULL; c = c->next) {
00029 if (HasBit(c->flags, GCF_STATIC)) continue;
00030 SlSetArrayIndex(index++);
00031 SlObject(c, _grfconfig_desc);
00032 }
00033 }
00034
00035
00036 static void Load_NGRF()
00037 {
00038 ClearGRFConfigList(&_grfconfig);
00039 while (SlIterateArray() != -1) {
00040 GRFConfig *c = CallocT<GRFConfig>(1);
00041 SlObject(c, _grfconfig_desc);
00042 if (CheckSavegameVersion(101)) c->windows_paletted = (_use_palette == PAL_WINDOWS);
00043 AppendToGRFConfigList(&_grfconfig, c);
00044 }
00045
00046
00047 AppendStaticGRFConfigs(&_grfconfig);
00048 }
00049
00050 extern const ChunkHandler _newgrf_chunk_handlers[] = {
00051 { 'NGRF', Save_NGRF, Load_NGRF, CH_ARRAY | CH_LAST }
00052 };