signs_sl.cpp

Go to the documentation of this file.
00001 /* $Id: signs_sl.cpp 15299 2009-01-31 20:16:06Z smatz $ */
00002 
00005 #include "../stdafx.h"
00006 #include "../company_func.h"
00007 #include "../signs_base.h"
00008 
00009 #include "saveload.h"
00010 
00011 static const SaveLoad _sign_desc[] = {
00012   SLE_CONDVAR(Sign, name,  SLE_NAME,                   0, 83),
00013   SLE_CONDSTR(Sign, name,  SLE_STR, 0,                84, SL_MAX_VERSION),
00014   SLE_CONDVAR(Sign, x,     SLE_FILE_I16 | SLE_VAR_I32, 0, 4),
00015   SLE_CONDVAR(Sign, y,     SLE_FILE_I16 | SLE_VAR_I32, 0, 4),
00016   SLE_CONDVAR(Sign, x,     SLE_INT32,                  5, SL_MAX_VERSION),
00017   SLE_CONDVAR(Sign, y,     SLE_INT32,                  5, SL_MAX_VERSION),
00018   SLE_CONDVAR(Sign, owner, SLE_UINT8,                  6, SL_MAX_VERSION),
00019       SLE_VAR(Sign, z,     SLE_UINT8),
00020   SLE_END()
00021 };
00022 
00024 static void Save_SIGN()
00025 {
00026   Sign *si;
00027 
00028   FOR_ALL_SIGNS(si) {
00029     SlSetArrayIndex(si->index);
00030     SlObject(si, _sign_desc);
00031   }
00032 }
00033 
00035 static void Load_SIGN()
00036 {
00037   int index;
00038   while ((index = SlIterateArray()) != -1) {
00039     Sign *si = new (index) Sign();
00040     SlObject(si, _sign_desc);
00041     /* Before version 6.1, signs didn't have owner.
00042      * Before version 83, invalid signs were determined by si->str == 0.
00043      * Before version 103, owner could be a bankrupted company.
00044      *  - we can't use IsValidCompany() now, so this is fixed in AfterLoadGame()
00045      * All signs that were saved are valid (including those with just 'Sign' and INVALID_OWNER).
00046      *  - so set owner to OWNER_NONE if needed (signs from pre-version 6.1 would be lost) */
00047     if (CheckSavegameVersionOldStyle(6, 1) || (CheckSavegameVersion(83) && si->owner == INVALID_OWNER)) {
00048       si->owner = OWNER_NONE;
00049     }
00050   }
00051 }
00052 
00053 extern const ChunkHandler _sign_chunk_handlers[] = {
00054   { 'SIGN', Save_SIGN, Load_SIGN, CH_ARRAY | CH_LAST},
00055 };

Generated on Mon Mar 23 00:25:22 2009 for OpenTTD by  doxygen 1.5.6