changeset 13082:9b6f556571eb draft

(svn r17582) -Codechange: Move TownActions and _town_action_costs[] to a header file to allow sharing.
author alberth <alberth@openttd.org>
date Sun, 20 Sep 2009 10:08:10 +0000
parents d9528b812fbf
children 1adece7fc42c
files src/town.h src/town_cmd.cpp src/town_gui.cpp
diffstat 3 files changed, 29 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/src/town.h
+++ b/src/town.h
@@ -215,6 +215,31 @@
 bool GenerateTowns(TownLayout layout);
 bool GenerateTownName(uint32 *townnameparts);
 
+
+/** Town actions of a company. */
+enum TownActions {
+	TACT_NONE             = 0x00, ///< Empty action set.
+
+	TACT_ADVERTISE_SMALL  = 0x01, ///< Small advertising campaign.
+	TACT_ADVERTISE_MEDIUM = 0x02, ///< Medium advertising campaign.
+	TACT_ADVERTISE_LARGE  = 0x04, ///< Large advertising campaign.
+	TACT_ROAD_REBUILD     = 0x08, ///< Rebuild the roads.
+	TACT_BUILD_STATUE     = 0x10, ///< Build a statue.
+	TACT_FOUND_BUILDINGS  = 0x20, ///< Found new buildings.
+	TACT_BUY_RIGHTS       = 0x40, ///< Buy exclusive transport rights.
+	TACT_BRIBE            = 0x80, ///< Try to bribe the counsil.
+
+	TACT_COUNT            = 8,    ///< Number of available town actions.
+
+	TACT_ADVERTISE        = TACT_ADVERTISE_SMALL | TACT_ADVERTISE_MEDIUM | TACT_ADVERTISE_LARGE, ///< All possible advertising actions.
+	TACT_CONSTRUCTION     = TACT_ROAD_REBUILD | TACT_BUILD_STATUE | TACT_FOUND_BUILDINGS,        ///< All possible construction actions.
+	TACT_FUNDS            = TACT_BUY_RIGHTS | TACT_BRIBE,                                        ///< All possible funding actions.
+	TACT_ALL              = TACT_ADVERTISE | TACT_CONSTRUCTION | TACT_FUNDS,                     ///< All possible actions.
+};
+DECLARE_ENUM_AS_BIT_SET(TownActions);
+
+extern const byte _town_action_costs[TACT_COUNT];
+
 /**
  * Calculate a hash value from a tile position
  *
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -2359,7 +2359,10 @@
 	UpdateTownMaxPass(t);
 }
 
-extern const byte _town_action_costs[8] = {
+/** Factor in the cost of each town action.
+ * @see TownActions
+ */
+const byte _town_action_costs[TACT_COUNT] = {
 	2, 4, 9, 35, 48, 53, 117, 175
 };
 
@@ -2509,26 +2512,6 @@
 	TownActionBribe
 };
 
-enum TownActions {
-	TACT_NONE             = 0x00,
-
-	TACT_ADVERTISE_SMALL  = 0x01,
-	TACT_ADVERTISE_MEDIUM = 0x02,
-	TACT_ADVERTISE_LARGE  = 0x04,
-	TACT_ROAD_REBUILD     = 0x08,
-	TACT_BUILD_STATUE     = 0x10,
-	TACT_FOUND_BUILDINGS  = 0x20,
-	TACT_BUY_RIGHTS       = 0x40,
-	TACT_BRIBE            = 0x80,
-
-	TACT_ADVERTISE        = TACT_ADVERTISE_SMALL | TACT_ADVERTISE_MEDIUM | TACT_ADVERTISE_LARGE,
-	TACT_CONSTRUCTION     = TACT_ROAD_REBUILD | TACT_BUILD_STATUE | TACT_FOUND_BUILDINGS,
-	TACT_FUNDS            = TACT_BUY_RIGHTS | TACT_BRIBE,
-	TACT_ALL              = TACT_ADVERTISE | TACT_CONSTRUCTION | TACT_FUNDS,
-};
-
-DECLARE_ENUM_AS_BIT_SET(TownActions);
-
 /** Get a list of available actions to do at a town.
  * @param nump if not NULL add put the number of available actions in it
  * @param cid the company that is querying the town
--- a/src/town_gui.cpp
+++ b/src/town_gui.cpp
@@ -76,8 +76,6 @@
 	NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, TWA_EXECUTE),  SetMinimalSize(317, 12), SetDataTip(STR_LOCAL_AUTHORITY_DO_IT_BUTTON, STR_LOCAL_AUTHORITY_DO_IT_TOOLTIP),
 };
 
-extern const byte _town_action_costs[8];
-
 struct TownAuthorityWindow : Window {
 private:
 	Town *town;