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