From: <geo...@us...> - 2011-08-19 05:24:42
|
Revision: 4169 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=4169&view=rev Author: geoffthemedio Date: 2011-08-19 03:47:30 +0000 (Fri, 19 Aug 2011) Log Message: ----------- -Made planet shield, troop, and defense meters meter predictions show increases towards max meter values. -Made troop meters actually grow by +1 each turn. Modified Paths: -------------- trunk/FreeOrion/universe/Planet.cpp Modified: trunk/FreeOrion/universe/Planet.cpp =================================================================== --- trunk/FreeOrion/universe/Planet.cpp 2011-08-18 20:40:06 UTC (rev 4168) +++ trunk/FreeOrion/universe/Planet.cpp 2011-08-19 03:47:30 UTC (rev 4169) @@ -300,6 +300,7 @@ double Planet::NextTurnCurrentMeterValue(MeterType type) const { + MeterType max_meter_type = INVALID_METER_TYPE; switch (type) { case METER_TARGET_POPULATION: case METER_TARGET_HEALTH: @@ -322,9 +323,27 @@ case METER_CONSTRUCTION: return ResourceCenterNextTurnMeterValue(type); break; + case METER_SHIELD: max_meter_type = METER_MAX_SHIELD; break; + case METER_TROOPS: max_meter_type = METER_MAX_TROOPS; break; + case METER_DEFENSE: max_meter_type = METER_MAX_DEFENSE; break; default: return UniverseObject::NextTurnCurrentMeterValue(type); } + + const Meter* meter = GetMeter(type); + if (!meter) { + throw std::invalid_argument("Planet::NextTurnCurrentMeterValue passed meter type that the Planet does not have, but should."); + } + double current_meter_value = meter->Current(); + + const Meter* max_meter = GetMeter(max_meter_type); + if (!max_meter) { + throw std::runtime_error("Planet::NextTurnCurrentMeterValue dealing with invalid meter type"); + } + double max_meter_value = max_meter->Current(); + + // currently meter growth is one per turn. + return std::min(current_meter_value + 1.0, max_meter_value); } std::vector<std::string> Planet::AvailableFoci() const @@ -606,6 +625,7 @@ // not starving. grow meters GetMeter(METER_SHIELD)->AddToCurrent(1.0); GetMeter(METER_DEFENSE)->AddToCurrent(1.0); + GetMeter(METER_TROOPS)->AddToCurrent(1.0); } StateChangedSignal(); |