mirror of https://github.com/OpenTTD/OpenTTD
(svn r20434) [1.0] -Backport from trunk:
- Fix: [NoAI] Clarify the documentation for AIBaseStation::GetLocation (r20238) - Fix: Do not spend cash when building a statue fails [FS#3985] (r20227) - Fix: [NewGRF] Vehicle var FE bit 6 did return incorrect values for new railtypes (r20175)release/1.0
parent
eaa79661cf
commit
133f5ba643
|
@ -64,7 +64,9 @@ public:
|
||||||
* Get the current location of a basestation.
|
* Get the current location of a basestation.
|
||||||
* @param station_id The basestation to get the location of.
|
* @param station_id The basestation to get the location of.
|
||||||
* @pre IsValidBaseStation(station_id).
|
* @pre IsValidBaseStation(station_id).
|
||||||
* @return The tile the basestation is currently on.
|
* @return The tile the basestation sign above it.
|
||||||
|
* @note The tile is not necessarily a station tile (and if it is, it could also belong to another station).
|
||||||
|
* @see AITileList_StationType.
|
||||||
*/
|
*/
|
||||||
static TileIndex GetLocation(StationID station_id);
|
static TileIndex GetLocation(StationID station_id);
|
||||||
|
|
||||||
|
|
|
@ -3399,6 +3399,7 @@ STR_ERROR_NO_SPACE_FOR_TOWN :{WHITE}... ther
|
||||||
STR_ERROR_TOWN_EXPAND_WARN_NO_ROADS :{WHITE}The town will not build roads. You can enable building of roads via Advanced Settings->Economy->Towns.
|
STR_ERROR_TOWN_EXPAND_WARN_NO_ROADS :{WHITE}The town will not build roads. You can enable building of roads via Advanced Settings->Economy->Towns.
|
||||||
STR_ERROR_ROAD_WORKS_IN_PROGRESS :{WHITE}Road works in progress
|
STR_ERROR_ROAD_WORKS_IN_PROGRESS :{WHITE}Road works in progress
|
||||||
STR_ERROR_TOWN_CAN_T_DELETE :{WHITE}Can't delete this town...{}A station or depot is referring to the town or a town owned tile can't be removed
|
STR_ERROR_TOWN_CAN_T_DELETE :{WHITE}Can't delete this town...{}A station or depot is referring to the town or a town owned tile can't be removed
|
||||||
|
STR_ERROR_STATUE_NO_SUITABLE_PLACE :{WHITE}... there is no suitable place for a statue in the center of this town
|
||||||
|
|
||||||
# Industry related errors
|
# Industry related errors
|
||||||
STR_ERROR_CAN_T_GENERATE_INDUSTRIES :{WHITE}Can't generate industries...
|
STR_ERROR_CAN_T_GENERATE_INDUSTRIES :{WHITE}Can't generate industries...
|
||||||
|
|
|
@ -694,11 +694,10 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
|
||||||
const Train *u = t->IsWagon() && HasBit(t->vehicle_flags, VRF_POWEREDWAGON) ? t->First() : t;
|
const Train *u = t->IsWagon() && HasBit(t->vehicle_flags, VRF_POWEREDWAGON) ? t->First() : t;
|
||||||
RailType railtype = GetRailType(v->tile);
|
RailType railtype = GetRailType(v->tile);
|
||||||
bool powered = t->IsEngine() || (t->IsWagon() && HasBit(t->vehicle_flags, VRF_POWEREDWAGON));
|
bool powered = t->IsEngine() || (t->IsWagon() && HasBit(t->vehicle_flags, VRF_POWEREDWAGON));
|
||||||
bool has_power = powered && HasPowerOnRail(u->railtype, railtype);
|
bool has_power = HasPowerOnRail(u->railtype, railtype);
|
||||||
bool is_electric = powered && u->railtype == RAILTYPE_ELECTRIC;
|
|
||||||
|
|
||||||
if (has_power) SetBit(modflags, 5);
|
if (powered && has_power) SetBit(modflags, 5);
|
||||||
if (is_electric && !has_power) SetBit(modflags, 6);
|
if (powered && !has_power) SetBit(modflags, 6);
|
||||||
if (HasBit(t->flags, VRF_TOGGLE_REVERSE)) SetBit(modflags, 8);
|
if (HasBit(t->flags, VRF_TOGGLE_REVERSE)) SetBit(modflags, 8);
|
||||||
}
|
}
|
||||||
if (HasBit(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE)) SetBit(modflags, 10);
|
if (HasBit(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE)) SetBit(modflags, 10);
|
||||||
|
|
|
@ -2335,23 +2335,33 @@ const byte _town_action_costs[TACT_COUNT] = {
|
||||||
2, 4, 9, 35, 48, 53, 117, 175
|
2, 4, 9, 35, 48, 53, 117, 175
|
||||||
};
|
};
|
||||||
|
|
||||||
static void TownActionAdvertiseSmall(Town *t)
|
static CommandCost TownActionAdvertiseSmall(Town *t, DoCommandFlag flags)
|
||||||
{
|
{
|
||||||
|
if (flags & DC_EXEC) {
|
||||||
ModifyStationRatingAround(t->xy, _current_company, 0x40, 10);
|
ModifyStationRatingAround(t->xy, _current_company, 0x40, 10);
|
||||||
|
}
|
||||||
|
return CommandCost();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void TownActionAdvertiseMedium(Town *t)
|
static CommandCost TownActionAdvertiseMedium(Town *t, DoCommandFlag flags)
|
||||||
{
|
{
|
||||||
|
if (flags & DC_EXEC) {
|
||||||
ModifyStationRatingAround(t->xy, _current_company, 0x70, 15);
|
ModifyStationRatingAround(t->xy, _current_company, 0x70, 15);
|
||||||
|
}
|
||||||
|
return CommandCost();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void TownActionAdvertiseLarge(Town *t)
|
static CommandCost TownActionAdvertiseLarge(Town *t, DoCommandFlag flags)
|
||||||
{
|
{
|
||||||
|
if (flags & DC_EXEC) {
|
||||||
ModifyStationRatingAround(t->xy, _current_company, 0xA0, 20);
|
ModifyStationRatingAround(t->xy, _current_company, 0xA0, 20);
|
||||||
|
}
|
||||||
|
return CommandCost();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void TownActionRoadRebuild(Town *t)
|
static CommandCost TownActionRoadRebuild(Town *t, DoCommandFlag flags)
|
||||||
{
|
{
|
||||||
|
if (flags & DC_EXEC) {
|
||||||
t->road_build_months = 6;
|
t->road_build_months = 6;
|
||||||
|
|
||||||
char company_name[MAX_LENGTH_COMPANY_NAME_BYTES];
|
char company_name[MAX_LENGTH_COMPANY_NAME_BYTES];
|
||||||
|
@ -2363,9 +2373,17 @@ static void TownActionRoadRebuild(Town *t)
|
||||||
SetDParamStr(1, cn);
|
SetDParamStr(1, cn);
|
||||||
|
|
||||||
AddNewsItem(STR_NEWS_ROAD_REBUILDING, NS_GENERAL, NR_TOWN, t->index, NR_NONE, UINT32_MAX, cn);
|
AddNewsItem(STR_NEWS_ROAD_REBUILDING, NS_GENERAL, NR_TOWN, t->index, NR_NONE, UINT32_MAX, cn);
|
||||||
|
}
|
||||||
|
return CommandCost();
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool DoBuildStatueOfCompany(TileIndex tile, TownID town_id)
|
/**
|
||||||
|
* Search callback function for TownActionBuildStatue.
|
||||||
|
* @param tile Tile on which to perform the search.
|
||||||
|
* @param user_data Unused.
|
||||||
|
* @return Result of the test.
|
||||||
|
*/
|
||||||
|
static bool SearchTileForStatue(TileIndex tile, void *user_data)
|
||||||
{
|
{
|
||||||
/* Statues can be build on slopes, just like houses. Only the steep slopes is a no go. */
|
/* Statues can be build on slopes, just like houses. Only the steep slopes is a no go. */
|
||||||
if (IsSteepSlope(GetTileSlope(tile, NULL))) return false;
|
if (IsSteepSlope(GetTileSlope(tile, NULL))) return false;
|
||||||
|
@ -2380,66 +2398,66 @@ static bool DoBuildStatueOfCompany(TileIndex tile, TownID town_id)
|
||||||
|
|
||||||
CompanyID old = _current_company;
|
CompanyID old = _current_company;
|
||||||
_current_company = OWNER_NONE;
|
_current_company = OWNER_NONE;
|
||||||
CommandCost r = DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
|
CommandCost r = DoCommand(tile, 0, 0, DC_NONE, CMD_LANDSCAPE_CLEAR);
|
||||||
_current_company = old;
|
_current_company = old;
|
||||||
|
|
||||||
if (r.Failed()) return false;
|
if (r.Failed()) return false;
|
||||||
|
|
||||||
MakeStatue(tile, _current_company, town_id);
|
|
||||||
MarkTileDirtyByTile(tile);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Search callback function for TownActionBuildStatue
|
|
||||||
* @param tile on which to perform the search
|
|
||||||
* @param user_data The town_id for which we want a statue
|
|
||||||
* @return the result of the test
|
|
||||||
*/
|
|
||||||
static bool SearchTileForStatue(TileIndex tile, void *user_data)
|
|
||||||
{
|
|
||||||
TownID *town_id = (TownID *)user_data;
|
|
||||||
return DoBuildStatueOfCompany(tile, *town_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform a 9x9 tiles circular search from the center of the town
|
* Perform a 9x9 tiles circular search from the center of the town
|
||||||
* in order to find a free tile to place a statue
|
* in order to find a free tile to place a statue
|
||||||
* @param t town to search in
|
* @param t town to search in
|
||||||
|
* @param flags Used to check if the statue must be built or not.
|
||||||
|
* @return Empty cost or an error.
|
||||||
*/
|
*/
|
||||||
static void TownActionBuildStatue(Town *t)
|
static CommandCost TownActionBuildStatue(Town *t, DoCommandFlag flags)
|
||||||
{
|
{
|
||||||
TileIndex tile = t->xy;
|
TileIndex tile = t->xy;
|
||||||
|
if (CircularTileSearch(&tile, 9, SearchTileForStatue, NULL)) {
|
||||||
if (CircularTileSearch(&tile, 9, SearchTileForStatue, &t->index)) {
|
if (flags & DC_EXEC) {
|
||||||
SetBit(t->statues, _current_company); // Once found and built, "inform" the Town
|
DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
|
||||||
|
MakeStatue(tile, _current_company, t->index);
|
||||||
|
SetBit(t->statues, _current_company); // Once found and built, "inform" the Town.
|
||||||
|
MarkTileDirtyByTile(tile);
|
||||||
}
|
}
|
||||||
|
return CommandCost();
|
||||||
|
}
|
||||||
|
return_cmd_error(STR_ERROR_STATUE_NO_SUITABLE_PLACE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void TownActionFundBuildings(Town *t)
|
static CommandCost TownActionFundBuildings(Town *t, DoCommandFlag flags)
|
||||||
{
|
{
|
||||||
|
if (flags & DC_EXEC) {
|
||||||
/* Build next tick */
|
/* Build next tick */
|
||||||
t->grow_counter = 1;
|
t->grow_counter = 1;
|
||||||
/* If we were not already growing */
|
/* If we were not already growing */
|
||||||
SetBit(t->flags, TOWN_IS_FUNDED);
|
SetBit(t->flags, TOWN_IS_FUNDED);
|
||||||
/* And grow for 3 months */
|
/* And grow for 3 months */
|
||||||
t->fund_buildings_months = 3;
|
t->fund_buildings_months = 3;
|
||||||
|
}
|
||||||
|
return CommandCost();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void TownActionBuyRights(Town *t)
|
static CommandCost TownActionBuyRights(Town *t, DoCommandFlag flags)
|
||||||
{
|
{
|
||||||
/* Check if it's allowed to by the rights */
|
/* Check if it's allowed to by the rights */
|
||||||
if (!_settings_game.economy.exclusive_rights) return;
|
if (!_settings_game.economy.exclusive_rights) return CMD_ERROR;
|
||||||
|
|
||||||
|
if (flags & DC_EXEC) {
|
||||||
t->exclusive_counter = 12;
|
t->exclusive_counter = 12;
|
||||||
t->exclusivity = _current_company;
|
t->exclusivity = _current_company;
|
||||||
|
|
||||||
ModifyStationRatingAround(t->xy, _current_company, 130, 17);
|
ModifyStationRatingAround(t->xy, _current_company, 130, 17);
|
||||||
|
}
|
||||||
|
return CommandCost();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void TownActionBribe(Town *t)
|
static CommandCost TownActionBribe(Town *t, DoCommandFlag flags)
|
||||||
{
|
{
|
||||||
|
if (flags & DC_EXEC) {
|
||||||
if (Chance16(1, 14)) {
|
if (Chance16(1, 14)) {
|
||||||
/* set as unwanted for 6 months */
|
/* set as unwanted for 6 months */
|
||||||
t->unwanted[_current_company] = 6;
|
t->unwanted[_current_company] = 6;
|
||||||
|
@ -2467,9 +2485,11 @@ static void TownActionBribe(Town *t)
|
||||||
} else {
|
} else {
|
||||||
ChangeTownRating(t, RATING_BRIBE_UP_STEP, RATING_BRIBE_MAXIMUM, DC_EXEC);
|
ChangeTownRating(t, RATING_BRIBE_UP_STEP, RATING_BRIBE_MAXIMUM, DC_EXEC);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return CommandCost();
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef void TownActionProc(Town *t);
|
typedef CommandCost TownActionProc(Town *t, DoCommandFlag flags);
|
||||||
static TownActionProc * const _town_action_proc[] = {
|
static TownActionProc * const _town_action_proc[] = {
|
||||||
TownActionAdvertiseSmall,
|
TownActionAdvertiseSmall,
|
||||||
TownActionAdvertiseMedium,
|
TownActionAdvertiseMedium,
|
||||||
|
@ -2545,8 +2565,10 @@ CommandCost CmdDoTownAction(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
|
||||||
|
|
||||||
CommandCost cost(EXPENSES_OTHER, _price[PR_TOWN_ACTION] * _town_action_costs[p2] >> 8);
|
CommandCost cost(EXPENSES_OTHER, _price[PR_TOWN_ACTION] * _town_action_costs[p2] >> 8);
|
||||||
|
|
||||||
|
CommandCost ret = _town_action_proc[p2](t, flags);
|
||||||
|
if (ret.Failed()) return ret;
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
_town_action_proc[p2](t);
|
|
||||||
SetWindowDirty(WC_TOWN_AUTHORITY, p1);
|
SetWindowDirty(WC_TOWN_AUTHORITY, p1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue