src/town_cmd.cpp
branchnoai
changeset 11126 72d4c9314c72
parent 11044 097ea3e7ec56
equal deleted inserted replaced
11111:1b984dab8cec 11126:72d4c9314c72
    45 #include "station_func.h"
    45 #include "station_func.h"
    46 #include "cheat_func.h"
    46 #include "cheat_func.h"
    47 #include "functions.h"
    47 #include "functions.h"
    48 #include "animated_tile_func.h"
    48 #include "animated_tile_func.h"
    49 #include "date_func.h"
    49 #include "date_func.h"
       
    50 #include <map>
    50 
    51 
    51 #include "table/strings.h"
    52 #include "table/strings.h"
    52 #include "table/sprites.h"
    53 #include "table/sprites.h"
    53 #include "table/town_land.h"
    54 #include "table/town_land.h"
    54 
    55 
  2008  * The given ID is set to the ID of the north tile and the TileDiff to the north tile is returned.
  2009  * The given ID is set to the ID of the north tile and the TileDiff to the north tile is returned.
  2009  *
  2010  *
  2010  * @param house Is changed to the HouseID of the north tile of the same house
  2011  * @param house Is changed to the HouseID of the north tile of the same house
  2011  * @return TileDiff from the tile of the given HouseID to the north tile
  2012  * @return TileDiff from the tile of the given HouseID to the north tile
  2012  */
  2013  */
  2013 static TileIndex GetHouseNorthPart(HouseID &house)
  2014 TileIndex GetHouseNorthPart(HouseID &house)
  2014 {
  2015 {
  2015 	if (house >= 3) { // house id 0,1,2 MUST be single tile houses, or this code breaks.
  2016 	if (house >= 3) { // house id 0,1,2 MUST be single tile houses, or this code breaks.
  2016 		if (GetHouseSpecs(house - 1)->building_flags & TILE_SIZE_2x1) {
  2017 		if (GetHouseSpecs(house - 1)->building_flags & TILE_SIZE_2x1) {
  2017 			house--;
  2018 			house--;
  2018 			return TileDiffXY(-1, 0);
  2019 			return TileDiffXY(-1, 0);
  2179 }
  2180 }
  2180 
  2181 
  2181 /**
  2182 /**
  2182  * Search callback function for TownActionBuildStatue
  2183  * Search callback function for TownActionBuildStatue
  2183  * @param tile on which to perform the search
  2184  * @param tile on which to perform the search
  2184  * @param town_id The town_id for which we want a statue
  2185  * @param user_data The town_id for which we want a statue
  2185  * @return the result of the test
  2186  * @return the result of the test
  2186  */
  2187  */
  2187 static bool SearchTileForStatue(TileIndex tile, uint32 town_id)
  2188 static bool SearchTileForStatue(TileIndex tile, void *user_data)
  2188 {
  2189 {
  2189 	return DoBuildStatueOfCompany(tile, town_id);
  2190 	TownID *town_id = (TownID *)user_data;
       
  2191 	return DoBuildStatueOfCompany(tile, *town_id);
  2190 }
  2192 }
  2191 
  2193 
  2192 /**
  2194 /**
  2193  * Perform a 9x9 tiles circular search from the center of the town
  2195  * Perform a 9x9 tiles circular search from the center of the town
  2194  * in order to find a free tile to place a statue
  2196  * in order to find a free tile to place a statue
  2196  */
  2198  */
  2197 static void TownActionBuildStatue(Town *t)
  2199 static void TownActionBuildStatue(Town *t)
  2198 {
  2200 {
  2199 	TileIndex tile = t->xy;
  2201 	TileIndex tile = t->xy;
  2200 
  2202 
  2201 	if (CircularTileSearch(&tile, 9, SearchTileForStatue, t->index)) {
  2203 	if (CircularTileSearch(&tile, 9, SearchTileForStatue, &t->index)) {
  2202 		SetBit(t->statues, _current_player); // Once found and built, "inform" the Town
  2204 		SetBit(t->statues, _current_player); // Once found and built, "inform" the Town
  2203 	}
  2205 	}
  2204 }
  2206 }
  2205 
  2207 
  2206 static void TownActionFundBuildings(Town *t)
  2208 static void TownActionFundBuildings(Town *t)