From e00cf92f47837d26d5b0fffb0668c5c717b3bacc Mon Sep 17 00:00:00 2001 From: smatz Date: Tue, 13 Jan 2009 22:58:03 +0000 Subject: (svn r15077) -Codechange: enumify DAYS_IN_YEAR and DAYS_IN_LEAP_YEAR -Change: when computing daily running cost, divide by 365 (instead of 364). Since r12134, the rounding errors don't need this correction anymore --- src/ai/ai.hpp | 7 ++++--- src/ai/ai_core.cpp | 2 +- src/ai/api/ai_engine.cpp | 2 +- src/ai/api/ai_engine.hpp | 2 +- src/ai/api/ai_event_types.hpp | 2 +- src/ai/api/ai_vehicle.hpp | 2 +- 6 files changed, 9 insertions(+), 8 deletions(-) (limited to 'src/ai') diff --git a/src/ai/ai.hpp b/src/ai/ai.hpp index 9af2e3cf1..71690bc05 100644 --- a/src/ai/ai.hpp +++ b/src/ai/ai.hpp @@ -6,6 +6,7 @@ #define AI_HPP #include "api/ai_event_types.hpp" +#include "../date_type.h" #ifndef AI_CONFIG_HPP struct ltstr { bool operator()(const char *s1, const char *s2) const { return strcmp(s1, s2) < 0; } }; @@ -21,9 +22,9 @@ public: * The default months AIs start after eachother. */ enum StartNext { - START_NEXT_EASY = 1461, - START_NEXT_MEDIUM = 730, - START_NEXT_HARD = 365, + START_NEXT_EASY = DAYS_IN_YEAR * 3 + DAYS_IN_LEAP_YEAR, + START_NEXT_MEDIUM = DAYS_IN_YEAR * 2, + START_NEXT_HARD = DAYS_IN_YEAR, START_NEXT_MIN = 1, START_NEXT_MAX = 3600, START_NEXT_DEVIATION = 60, diff --git a/src/ai/ai_core.cpp b/src/ai/ai_core.cpp index 3c5843ab6..ffb2ad04b 100644 --- a/src/ai/ai_core.cpp +++ b/src/ai/ai_core.cpp @@ -235,7 +235,7 @@ void CcAI(bool success, TileIndex tile, uint32 p1, uint32 p2) } /* Currently no AI can be started, check again in a year. */ - return 365; + return DAYS_IN_YEAR; } /* static */ char *AI::GetConsoleList(char *p, const char *last) diff --git a/src/ai/api/ai_engine.cpp b/src/ai/api/ai_engine.cpp index 5215c95f3..c3f3aed3e 100644 --- a/src/ai/api/ai_engine.cpp +++ b/src/ai/api/ai_engine.cpp @@ -186,7 +186,7 @@ { if (!IsValidEngine(engine_id)) return -1; - return ::GetEngine(engine_id)->lifelength * 366; + return ::GetEngine(engine_id)->lifelength * DAYS_IN_LEAP_YEAR; } /* static */ Money AIEngine::GetRunningCost(EngineID engine_id) diff --git a/src/ai/api/ai_engine.hpp b/src/ai/api/ai_engine.hpp index 67801107c..1dfe76e08 100644 --- a/src/ai/api/ai_engine.hpp +++ b/src/ai/api/ai_engine.hpp @@ -117,7 +117,7 @@ public: * @param engine_id The engine to get the running cost of. * @pre IsValidEngine(engine_id). * @return The running cost of a vehicle per year. - * @note Cost is per year; divide by 364 to get per day. + * @note Cost is per year; divide by 365 to get per day. */ static Money GetRunningCost(EngineID engine_id); diff --git a/src/ai/api/ai_event_types.hpp b/src/ai/api/ai_event_types.hpp index c64b2a367..13c004d97 100644 --- a/src/ai/api/ai_event_types.hpp +++ b/src/ai/api/ai_event_types.hpp @@ -286,7 +286,7 @@ public: /** * Get the running cost of the offered engine. * @return The running cost of the vehicle per year. - * @note Cost is per year; divide by 364 to get per day. + * @note Cost is per year; divide by 365 to get per day. */ Money GetRunningCost(); diff --git a/src/ai/api/ai_vehicle.hpp b/src/ai/api/ai_vehicle.hpp index 8120fe947..84ddb4734 100644 --- a/src/ai/api/ai_vehicle.hpp +++ b/src/ai/api/ai_vehicle.hpp @@ -218,7 +218,7 @@ public: * @param vehicle_id The vehicle to get the age of. * @pre IsValidVehicle(vehicle_id). * @return The running cost of the vehicle per year. - * @note Cost is per year; divide by 364 to get per day. + * @note Cost is per year; divide by 365 to get per day. * @note This is not equal to AIEngine::GetRunningCost for Trains, because * wagons and second engines can add up in the calculation too. */ -- cgit v1.2.3-54-g00ecf