diff -r ed8f92929297 -r dc85aaa556ae src/economy_new.h --- a/src/economy_new.h Fri Mar 23 12:03:41 2007 +0000 +++ b/src/economy_new.h Sat Mar 31 12:34:36 2007 +0000 @@ -46,40 +46,81 @@ * Handles all the economic data and events */ class CEconomy : public EconomicObject { -private: - FixedT m_basic_growth; ///< Basic growth number, depends solely on difficulty setting - byte m_long_term_cycle; ///< The period of the long-term cycle suggested by Kondratiev - byte m_short_term_cycle; ///< The period of the short-term cycle (see Juglar, others) - FixedT m_long_term_ampl; ///< Amplitude of the long-term cycle - FixedT m_short_term_ampl; ///< Amplitude of the short-term cycle - public: /** - * Starts the economy. This sets the basic growth by the difficulty level and adjust the current - * EAL by the year of the game. We also set the economic cycles here. - * @warning This should be run once per game only + * Enumerator for the different costs for operations a player can perform. + * Should be used to access the array of prices. */ - CEconomy() { - /* Set basic growth */ - FixedT growth(_opt.diff.economic_growth, 2); - m_basic_growth = (growth + 1) / 100 + 1; - DEBUG(eco, 3, "Starting a new economy with a basic growth factor of %.3f in the year %d", (double)m_basic_growth, _cur_year); + enum Price { + STATION_VALUE, + PRICE_RAIL_BUILD, /**< Cost of placing a single piece of track (a vertical or horizontal one. + * @todo make sure the longer pieces of track cost a bit more + */ + BUILD_ROAD, + BUILD_SIGNALS, + BUILD_BRIDGE, + BUILD_TRAIN_DEPOT, + BUILD_ROAD_DEPOT, + BUILD_SHIP_DEPOT, + BUILD_TUNNEL, + TRAIN_STATION_TRACK, + TRAIN_STATION_LENGTH, + BUILD_AIRPORT, + BUILD_BUS_STATION, + BUILD_TRUCK_STATION, + BUILD_DOCK, + BUILD_RAILVEHICLE, + BUILD_RAILWAGON, + AIRCRAFT_BASE, + ROADVEH_BASE, + SHIP_BASE, + BUILD_TREES, + TERRAFORM, + CLEAR_1, + PURCHASE_LAND, + CLEAR_2, + CLEAR_3, + REMOVE_TREES, + PRICE_RAIL_REMOVE, /**< cost for removing a piece of track. Less than for building because one + * might be able to reuse stuff + */ + REMOVE_SIGNALS, + CLEAR_BRIDGE, + REMOVE_TRAIN_DEPOT, + REMOVE_ROAD_DEPOT, + REMOVE_SHIP_DEPOT, + CLEAR_TUNNEL, + CLEAR_WATER, + REMOVE_RAIL_STATION, + REMOVE_AIRPORT, + REMOVE_BUS_STATION, + REMOVE_TRUCK_STATION, + REMOVE_DOCK, + REMOVE_HOUSE, + REMOVE_ROAD, + RUNNING_RAIL0, + RUNNING_RAIL1, + RUNNING_RAIL2, + AIRCRAFT_RUNNING, + ROADVEH_RUNNING, + SHIP_RUNNING, + BUILD_INDUSTRY, - /* Set up the economic cycles */ - m_long_term_cycle = RandomRange(15) + 45; - m_short_term_cycle = RandomRange(4) + 6; - m_long_term_ampl = RandomRange(5) + 10; - m_short_term_ampl = RandomRange(10) + 15; - m_long_term_ampl /= 1000; - m_short_term_ampl /= 1000; - DEBUG(eco, 4, "Adjusting economic cycles to %d and %d years", m_long_term_cycle, m_short_term_cycle); - DEBUG(eco, 4, "Adjusting economic cycles to %f and %f (amplitude)", (double)m_long_term_ampl, (double)m_short_term_ampl); + MAX_PRICE ///< end marker; use with for loops and arrays for example + }; - m_activity_level = 1; - m_activity_level = pow(m_basic_growth, _cur_year - 1820); - DEBUG(eco, 4, "Adjusting basic EAL for current year (offset %d) to %.3f", _cur_year - 1820, (double)m_activity_level); - } +private: + FixedT m_basic_growth; ///< Basic growth number, depends solely on difficulty setting + byte m_long_term_cycle; ///< The period of the long-term cycle suggested by Kondratiev + byte m_short_term_cycle; ///< The period of the short-term cycle (see Juglar, others) + FixedT m_long_term_ampl; ///< Amplitude of the long-term cycle + FixedT m_short_term_ampl; ///< Amplitude of the short-term cycle + + FixedT m_prices[MAX_PRICE]; ///< Cost of operations for the player. Positive for cost, negative for income + +public: + CEconomy(); /** * Removes an economy. @@ -128,6 +169,30 @@ static const SaveLoad eco_desc[]; + /** + * Saves and Loads the prices from the savegame + */ + void SaveLoad_PRIC() + { + uint16 dummy[MAX_PRICE]; + SlArray(m_prices, MAX_PRICE, SLE_INT32); + SlArray(dummy, MAX_PRICE, SLE_UINT16); + } + + int32 GetPrice(Price operation, TileIndex tile = INVALID_TILE, bool release = false) const; + + /** + * Manually sets the price of an operation, used while loading games + * @param operation The operation which to set the price for + * @param value The new price of the operation + */ + void SetPrice(int operation, int32 value) + { + assert(operation < MAX_PRICE); + DEBUG(eco, 4, "Setting price of operation %d to %f", (int)operation, (double) value); + m_prices[operation] = value; + } + private: /** * Computes the modification of economic growth by cyclic events