script_town.hpp

Go to the documentation of this file.
00001 /* $Id: script_town.hpp 23636 2011-12-19 21:06:06Z truebrain $ */
00002 
00003 /*
00004  * This file is part of OpenTTD.
00005  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
00006  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00007  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
00008  */
00009 
00012 #ifndef SCRIPT_TOWN_HPP
00013 #define SCRIPT_TOWN_HPP
00014 
00015 #include "script_cargo.hpp"
00016 #include "script_company.hpp"
00017 #include "script_text.hpp"
00018 #include "../../town_type.h"
00019 
00024 class ScriptTown : public ScriptObject {
00025 public:
00029   enum TownAction {
00030     /* Note: these values represent part of the in-game order of the _town_action_proc array */
00031 
00037     TOWN_ACTION_ADVERTISE_SMALL  = 0,
00038 
00044     TOWN_ACTION_ADVERTISE_MEDIUM = 1,
00045 
00051     TOWN_ACTION_ADVERTISE_LARGE  = 2,
00052 
00056     TOWN_ACTION_ROAD_REBUILD     = 3,
00057 
00061     TOWN_ACTION_BUILD_STATUE     = 4,
00062 
00066     TOWN_ACTION_FUND_BUILDINGS   = 5,
00067 
00071     TOWN_ACTION_BUY_RIGHTS       = 6,
00072 
00076     TOWN_ACTION_BRIBE            = 7,
00077   };
00078 
00082   enum TownRating {
00083     TOWN_RATING_NONE,         
00084     TOWN_RATING_APPALLING,    
00085     TOWN_RATING_VERY_POOR,    
00086     TOWN_RATING_POOR,         
00087     TOWN_RATING_MEDIOCRE,     
00088     TOWN_RATING_GOOD,         
00089     TOWN_RATING_VERY_GOOD,    
00090     TOWN_RATING_EXCELLENT,    
00091     TOWN_RATING_OUTSTANDING,  
00092     TOWN_RATING_INVALID = -1, 
00093   };
00094 
00098   enum RoadLayout {
00099     /* Note: these values represent part of the in-game TownLayout enum */
00100     ROAD_LAYOUT_ORIGINAL      = ::TL_ORIGINAL,     
00101     ROAD_LAYOUT_BETTER_ROADS  = ::TL_BETTER_ROADS, 
00102     ROAD_LAYOUT_2x2           = ::TL_2X2_GRID,     
00103     ROAD_LAYOUT_3x3           = ::TL_3X3_GRID,     
00104 
00105     /* Custom added value, only valid for this API */
00106     ROAD_LAYOUT_INVALID       = -1,                
00107   };
00108 
00113   static int32 GetTownCount();
00114 
00120   static bool IsValidTown(TownID town_id);
00121 
00128   static char *GetName(TownID town_id);
00129 
00138   static bool SetText(TownID town_id, Text *text);
00139 
00146   static int32 GetPopulation(TownID town_id);
00147 
00154   static int32 GetHouseCount(TownID town_id);
00155 
00162   static TileIndex GetLocation(TownID town_id);
00163 
00172   static int32 GetLastMonthProduction(TownID town_id, CargoID cargo_id);
00173 
00182   static int32 GetLastMonthSupplied(TownID town_id, CargoID cargo_id);
00183 
00192   static int32 GetLastMonthTransportedPercentage(TownID town_id, CargoID cargo_id);
00193 
00202   static int32 GetLastMonthReceived(TownID town_id, ScriptCargo::TownEffect towneffect_id);
00203 
00214   static bool SetCargoGoal(TownID town_id, ScriptCargo::TownEffect towneffect_id, uint32 goal);
00215 
00227   static uint32 GetCargoGoal(TownID town_id, ScriptCargo::TownEffect towneffect_id);
00228 
00238   static bool SetGrowthRate(TownID town_id, uint16 days_between_town_growth);
00239 
00247   static int32 GetGrowthRate(TownID town_id);
00248 
00257   static int32 GetDistanceManhattanToTile(TownID town_id, TileIndex tile);
00258 
00267   static int32 GetDistanceSquareToTile(TownID town_id, TileIndex tile);
00268 
00278   static bool IsWithinTownInfluence(TownID town_id, TileIndex tile);
00279 
00287   static bool HasStatue(TownID town_id);
00288 
00295   static bool IsCity(TownID town_id);
00296 
00304   static int GetRoadReworkDuration(TownID town_id);
00305 
00315   static ScriptCompany::CompanyID GetExclusiveRightsCompany(TownID town_id);
00316 
00325   static int32 GetExclusiveRightsDuration(TownID town_id);
00326 
00335   static bool IsActionAvailable(TownID town_id, TownAction town_action);
00336 
00346   static bool PerformTownAction(TownID town_id, TownAction town_action);
00347 
00357   static bool ExpandTown(TownID town_id, int houses);
00358 
00367   static TownRating GetRating(TownID town_id, ScriptCompany::CompanyID company_id);
00368 
00375   static int GetAllowedNoise(TownID town_id);
00376 
00382   static RoadLayout GetRoadLayout(TownID town_id);
00383 };
00384 
00385 #endif /* SCRIPT_TOWN_HPP */