Fix some daylength issues, possible division by zero in main menu.
[openttd-joker.git] / src / saveload / storage_sl.cpp
blob30ce212be82040dc243a3e48f6f2b305d0efe921
1 /* $Id: storage_sl.cpp 26371 2014-02-23 22:03:08Z frosch $ */
3 /*
4 * This file is part of OpenTTD.
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 */
10 /** @file storage_sl.cpp Code handling saving and loading of persistent storages. */
12 #include "../stdafx.h"
13 #include "../newgrf_storage.h"
14 #include "saveload.h"
16 #include "../safeguards.h"
18 /** Description of the data to save and load in #PersistentStorage. */
19 static const SaveLoad _storage_desc[] = {
20 SLE_CONDVAR(PersistentStorage, grfid, SLE_UINT32, 6, SL_MAX_VERSION),
21 SLE_CONDARR(PersistentStorage, storage, SLE_UINT32, 16, 161, SL_MAX_VERSION),
22 SLE_END()
25 /** Load persistent storage data. */
26 static void Load_PSAC()
28 int index;
30 while ((index = SlIterateArray()) != -1) {
31 assert(PersistentStorage::CanAllocateItem());
32 PersistentStorage *ps = new (index) PersistentStorage(0, 0, 0);
33 SlObject(ps, _storage_desc);
37 /** Save persistent storage data. */
38 static void Save_PSAC()
40 PersistentStorage *ps;
42 /* Write the industries */
43 FOR_ALL_STORAGES(ps) {
44 ps->ClearChanges();
45 SlSetArrayIndex(ps->index);
46 SlObject(ps, _storage_desc);
50 /** Chunk handler for persistent storages. */
51 extern const ChunkHandler _persistent_storage_chunk_handlers[] = {
52 { 'PSAC', Save_PSAC, Load_PSAC, NULL, NULL, CH_ARRAY | CH_LAST},