equal
deleted
inserted
replaced
117 } |
117 } |
118 |
118 |
119 /** |
119 /** |
120 * Obtains the costs that a certain user operation at a tile would generate. |
120 * Obtains the costs that a certain user operation at a tile would generate. |
121 * This function takes into account that cost that arise from obtaining ownership |
121 * This function takes into account that cost that arise from obtaining ownership |
122 * of the tile in question. |
122 * of the tile in question. Note that these costs are not accounted for in the |
|
123 * very simple difficulty levels. |
123 * @warning This function needs to be called BEFORE the tile actions |
124 * @warning This function needs to be called BEFORE the tile actions |
124 * are performed. Otherwise you'll get an assertion on the command |
125 * are performed. Otherwise you'll get an assertion on the command |
125 * because the computed prices for the test and the exec run are |
126 * because the computed prices for the test and the exec run are |
126 * different |
127 * different |
127 * @todo Implement inflation |
128 * @todo Implement inflation |
135 */ |
136 */ |
136 int32 CEconomy::GetPrice(Price operation, TileIndex tile, bool release) const |
137 int32 CEconomy::GetPrice(Price operation, TileIndex tile, bool release) const |
137 { |
138 { |
138 int32 cost = m_prices[operation]; |
139 int32 cost = m_prices[operation]; |
139 |
140 |
140 if (tile == INVALID_TILE) return cost; |
141 if (tile == INVALID_TILE || _opt.diff.economic_model == 0) return cost; |
141 if (release) cost -= Town::GetTilePrice(tile); |
142 if (release) cost -= Town::GetTilePrice(tile); |
142 else if (_current_player < MAX_PLAYERS && _current_player != GetTileOwner(tile)) cost += Town::GetTilePrice(tile); |
143 else if (_current_player < MAX_PLAYERS && _current_player != GetTileOwner(tile)) cost += Town::GetTilePrice(tile); |
143 |
144 |
144 return cost; |
145 return cost; |
145 } |
146 } |