summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbelugas <belugas@openttd.org>2009-08-03 20:02:25 +0000
committerbelugas <belugas@openttd.org>2009-08-03 20:02:25 +0000
commita2b996106ea25c97ece3e724c10d9d1b9e1d5aa2 (patch)
tree5cc371e6bbe7677dccd271c6c169145d51722d73
parent37d01c7758d018bfd2d29b623f83bde080598233 (diff)
downloadopenttd-a2b996106ea25c97ece3e724c10d9d1b9e1d5aa2.tar.xz
(svn r17058) -Codechange: magic numbers removal.
Two values used intead of just one, as it gives more possibilities to those who dare...
-rw-r--r--src/company_base.h2
-rw-r--r--src/company_type.h4
-rw-r--r--src/economy.cpp2
-rw-r--r--src/graph_gui.cpp3
4 files changed, 8 insertions, 3 deletions
diff --git a/src/company_base.h b/src/company_base.h
index 35a2e918c..481c1aa01 100644
--- a/src/company_base.h
+++ b/src/company_base.h
@@ -75,7 +75,7 @@ struct Company : CompanyPool::PoolItem<&_company_pool> {
Money yearly_expenses[3][EXPENSES_END];
CompanyEconomyEntry cur_economy;
- CompanyEconomyEntry old_economy[24];
+ CompanyEconomyEntry old_economy[MAX_HISTORY_MONTHS];
EngineRenewList engine_renew_list; ///< Defined later
CompanySettings settings; ///< settings specific for each company
uint16 *num_engines; ///< caches the number of engines of each type the company owns (no need to save this)
diff --git a/src/company_type.h b/src/company_type.h
index 997cc40a1..db190797b 100644
--- a/src/company_type.h
+++ b/src/company_type.h
@@ -37,6 +37,10 @@ enum {
MAX_LENGTH_COMPANY_NAME_PIXELS = 150, ///< The maximum length of a company name in pixels
};
+enum {
+ MAX_HISTORY_MONTHS = 24, ///< The maximum number of months kept as performance's history
+};
+
/** Define basic enum properties */
template <> struct EnumPropsT<Owner> : MakeEnumPropsT<Owner, byte, OWNER_BEGIN, OWNER_END, INVALID_OWNER> {};
typedef TinyEnumT<Owner> OwnerByte;
diff --git a/src/economy.cpp b/src/economy.cpp
index a3c880068..39c030ebd 100644
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -569,7 +569,7 @@ static void CompaniesGenStatistics()
c->old_economy[0] = c->cur_economy;
memset(&c->cur_economy, 0, sizeof(c->cur_economy));
- if (c->num_valid_stat_ent != 24) c->num_valid_stat_ent++;
+ if (c->num_valid_stat_ent != MAX_HISTORY_MONTHS) c->num_valid_stat_ent++;
UpdateCompanyRatingAndValue(c, true);
if (c->block_preview != 0) c->block_preview--;
diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp
index 4142d5556..77c86c1e6 100644
--- a/src/graph_gui.cpp
+++ b/src/graph_gui.cpp
@@ -160,6 +160,7 @@ protected:
enum {
GRAPH_MAX_DATASETS = 32,
GRAPH_AXIS_LINE_COLOUR = 215,
+ GRAPH_NUM_MONTHS = 24, ///< Number of months displayed in the graph.
GRAPH_X_POSITION_BEGINNING = 44, ///< Start the graph 44 pixels from gd_left
GRAPH_X_POSITION_SEPARATION = 22, ///< There are 22 pixels between each X value
@@ -190,7 +191,7 @@ protected:
Rect graph_location;
StringID format_str_y_axis;
byte colours[GRAPH_MAX_DATASETS];
- OverflowSafeInt64 cost[GRAPH_MAX_DATASETS][24]; ///< last 2 years
+ OverflowSafeInt64 cost[GRAPH_MAX_DATASETS][GRAPH_NUM_MONTHS]; ///< Stored costs for the last #GRAPH_NUM_MONTHS months
/**
* Actually draw the graph.