# economy_sl.cpp

Go to the documentation of this file.

    00001 /* $Id: economy_sl.cpp 15027 2009-01-12 17:11:45Z truebrain $ */
    00002
    00005 #include "../stdafx.h"
    00006 #include "../economy_func.h"
    00007
    00008 #include "saveload.h"
    00009
    00011 static void SaveLoad_PRIC()
    00012 {
    00013   int vt = CheckSavegameVersion(65) ? (SLE_FILE_I32 | SLE_VAR_I64) : SLE_INT64;
    00014   SlArray(&_price,      NUM_PRICES, vt);
    00015   SlArray(&_price_frac, NUM_PRICES, SLE_UINT16);
    00016 }
    00017
    00019 static void SaveLoad_CAPR()
    00020 {
    00021   uint num_cargo = CheckSavegameVersion(55) ? 12 : NUM_CARGO;
    00022   int vt = CheckSavegameVersion(65) ? (SLE_FILE_I32 | SLE_VAR_I64) : SLE_INT64;
    00023   SlArray(&_cargo_payment_rates,      num_cargo, vt);
    00024   SlArray(&_cargo_payment_rates_frac, num_cargo, SLE_UINT16);
    00025 }
    00026
    00027 static const SaveLoad _economy_desc[] = {
    00028   SLE_CONDVAR(Economy, max_loan,                      SLE_FILE_I32 | SLE_VAR_I64,  0, 64),
    00029   SLE_CONDVAR(Economy, max_loan,                      SLE_INT64,                  65, SL_MAX_VERSION),
    00030   SLE_CONDVAR(Economy, max_loan_unround,              SLE_FILE_I32 | SLE_VAR_I64,  0, 64),
    00031   SLE_CONDVAR(Economy, max_loan_unround,              SLE_INT64,                  65, SL_MAX_VERSION),
    00032   SLE_CONDVAR(Economy, max_loan_unround_fract,        SLE_UINT16,                 70, SL_MAX_VERSION),
    00033       SLE_VAR(Economy, fluct,                         SLE_INT16),
    00034       SLE_VAR(Economy, interest_rate,                 SLE_UINT8),
    00035       SLE_VAR(Economy, infl_amount,                   SLE_UINT8),
    00036       SLE_VAR(Economy, infl_amount_pr,                SLE_UINT8),
    00037   SLE_CONDVAR(Economy, industry_daily_change_counter, SLE_UINT32,                102, SL_MAX_VERSION),
    00038       SLE_END()
    00039 };
    00040
    00042 static void Save_ECMY()
    00043 {
    00044   SlObject(&_economy, _economy_desc);
    00045 }
    00046
    00048 static void Load_ECMY()
    00049 {
    00050   SlObject(&_economy, _economy_desc);
    00051   StartupIndustryDailyChanges(CheckSavegameVersion(102));  // old savegames will need to be initialized
    00052 }
    00053
    00054 extern const ChunkHandler _economy_chunk_handlers[] = {
    00055   { 'PRIC', SaveLoad_PRIC, SaveLoad_PRIC, CH_RIFF | CH_AUTO_LENGTH},
    00056   { 'CAPR', SaveLoad_CAPR, SaveLoad_CAPR, CH_RIFF | CH_AUTO_LENGTH},
    00057   { 'ECMY', Save_ECMY,     Load_ECMY,     CH_RIFF | CH_LAST},
    00058 };