diff options
-rw-r--r-- | industry_cmd.c | 38 | ||||
-rw-r--r-- | table/build_industry.h | 7 | ||||
-rw-r--r-- | town_cmd.c | 37 |
3 files changed, 48 insertions, 34 deletions
diff --git a/industry_cmd.c b/industry_cmd.c index bad47ae6d..4525f11ac 100644 --- a/industry_cmd.c +++ b/industry_cmd.c @@ -1006,12 +1006,12 @@ void OnTick_Industry(void) } -static bool CheckNewIndustry_NULL(TileIndex tile, IndustryType type) +static bool CheckNewIndustry_NULL(TileIndex tile) { return true; } -static bool CheckNewIndustry_Forest(TileIndex tile, IndustryType type) +static bool CheckNewIndustry_Forest(TileIndex tile) { if (_opt.landscape == LT_HILLY) { if (GetTileZ(tile) < _opt.snow_line + TILE_HEIGHT * 2U) { @@ -1022,21 +1022,28 @@ static bool CheckNewIndustry_Forest(TileIndex tile, IndustryType type) return true; } +static bool CheckNewIndustry_OilRefinery(TileIndex tile) +{ + if (_game_mode == GM_EDITOR) return true; + if (DistanceFromEdge(TILE_ADDXY(tile, 1, 1)) < 16) return true; + + _error_message = STR_483B_CAN_ONLY_BE_POSITIONED; + return false; +} + extern bool _ignore_restrictions; -/* Oil Rig and Oil Refinery */ -static bool CheckNewIndustry_Oil(TileIndex tile, IndustryType type) +static bool CheckNewIndustry_OilRig(TileIndex tile) { if (_game_mode == GM_EDITOR && _ignore_restrictions) return true; - if (_game_mode == GM_EDITOR && type != IT_OIL_RIG) return true; - if ((type != IT_OIL_RIG || TileHeight(tile) == 0) && + if (TileHeight(tile) == 0 && DistanceFromEdge(TILE_ADDXY(tile, 1, 1)) < 16) return true; _error_message = STR_483B_CAN_ONLY_BE_POSITIONED; return false; } -static bool CheckNewIndustry_Farm(TileIndex tile, IndustryType type) +static bool CheckNewIndustry_Farm(TileIndex tile) { if (_opt.landscape == LT_HILLY) { if (GetTileZ(tile) + TILE_HEIGHT * 2 >= _opt.snow_line) { @@ -1047,7 +1054,7 @@ static bool CheckNewIndustry_Farm(TileIndex tile, IndustryType type) return true; } -static bool CheckNewIndustry_Plantation(TileIndex tile, IndustryType type) +static bool CheckNewIndustry_Plantation(TileIndex tile) { if (GetTropicZone(tile) == TROPICZONE_DESERT) { _error_message = STR_0239_SITE_UNSUITABLE; @@ -1057,7 +1064,7 @@ static bool CheckNewIndustry_Plantation(TileIndex tile, IndustryType type) return true; } -static bool CheckNewIndustry_Water(TileIndex tile, IndustryType type) +static bool CheckNewIndustry_Water(TileIndex tile) { if (GetTropicZone(tile) != TROPICZONE_DESERT) { _error_message = STR_0318_CAN_ONLY_BE_BUILT_IN_DESERT; @@ -1067,7 +1074,7 @@ static bool CheckNewIndustry_Water(TileIndex tile, IndustryType type) return true; } -static bool CheckNewIndustry_Lumbermill(TileIndex tile, IndustryType type) +static bool CheckNewIndustry_Lumbermill(TileIndex tile) { if (GetTropicZone(tile) != TROPICZONE_RAINFOREST) { _error_message = STR_0317_CAN_ONLY_BE_BUILT_IN_RAINFOREST; @@ -1076,21 +1083,22 @@ static bool CheckNewIndustry_Lumbermill(TileIndex tile, IndustryType type) return true; } -static bool CheckNewIndustry_BubbleGen(TileIndex tile, IndustryType type) +static bool CheckNewIndustry_BubbleGen(TileIndex tile) { return GetTileZ(tile) <= TILE_HEIGHT * 4; } -typedef bool CheckNewIndustryProc(TileIndex tile, IndustryType type); +typedef bool CheckNewIndustryProc(TileIndex tile); static CheckNewIndustryProc * const _check_new_industry_procs[CHECK_END] = { CheckNewIndustry_NULL, CheckNewIndustry_Forest, - CheckNewIndustry_Oil, + CheckNewIndustry_OilRefinery, CheckNewIndustry_Farm, CheckNewIndustry_Plantation, CheckNewIndustry_Water, CheckNewIndustry_Lumbermill, CheckNewIndustry_BubbleGen, + CheckNewIndustry_OilRig }; static bool CheckSuitableIndustryPos(TileIndex tile) @@ -1409,7 +1417,7 @@ int32 CmdBuildIndustry(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) return CMD_ERROR; } - if (!_check_new_industry_procs[indspec->check_proc](tile, p1)) return CMD_ERROR; + if (!_check_new_industry_procs[indspec->check_proc](tile)) return CMD_ERROR; t = CheckMultipleIndustryInTown(tile, p1); if (t == NULL) return CMD_ERROR; @@ -1445,7 +1453,7 @@ Industry *CreateNewIndustry(TileIndex tile, IndustryType type) indspec = GetIndustrySpec(type); - if (!_check_new_industry_procs[indspec->check_proc](tile, type)) return NULL; + if (!_check_new_industry_procs[indspec->check_proc](tile)) return NULL; t = CheckMultipleIndustryInTown(tile, type); if (t == NULL) return NULL; diff --git a/table/build_industry.h b/table/build_industry.h index 9bfdcba5d..b30f5da1e 100644 --- a/table/build_industry.h +++ b/table/build_industry.h @@ -1070,12 +1070,13 @@ static const IndustryTileTable * const _tile_table_sugar_mine[] = { typedef enum CheckProcs { CHECK_NOTHING = 0, CHECK_FOREST = 1, - CHECK_OIL = 2, + CHECK_REFINERY = 2, CHECK_FARM = 3, CHECK_PLANTATION = 4, CHECK_WATER = 5, CHECK_LUMBERMILL = 6, CHECK_BUBBLEGEN = 7, + CHECK_OIL_RIG = 8, CHECK_END, } CheckProc; @@ -1115,13 +1116,13 @@ static const IndustrySpec _industry_specs[] = { STR_4832_ANNOUNCES_IMMINENT_CLOSURE, STR_4835_INCREASES_PRODUCTION, STR_483A_INSECT_INFESTATION_CAUSES), MK(_tile_table_oil_refinery, 31, - IT_OIL_RIG, IT_INVALID, IT_INVALID, CHECK_OIL, + IT_OIL_RIG, IT_INVALID, IT_INVALID, CHECK_REFINERY, CT_GOODS, 0, CT_INVALID, 0, 5, CT_OIL, CT_INVALID, CT_INVALID, STR_4833_SUPPLY_PROBLEMS_CAUSE_TO, STR_4835_INCREASES_PRODUCTION, STR_4839_PRODUCTION_DOWN_BY_50), MK(_tile_table_oil_rig, 240, - IT_OIL_REFINERY, IT_INVALID, IT_INVALID, CHECK_OIL, + IT_OIL_REFINERY, IT_INVALID, IT_INVALID, CHECK_OIL_RIG, CT_OIL, 15, CT_PASSENGERS, 2, 5, CT_INVALID, CT_INVALID, CT_INVALID, STR_4832_ANNOUNCES_IMMINENT_CLOSURE, STR_4837_NEW_OIL_RESERVES_FOUND, STR_4839_PRODUCTION_DOWN_BY_50), diff --git a/town_cmd.c b/town_cmd.c index 766789054..2c7a8653c 100644 --- a/town_cmd.c +++ b/town_cmd.c @@ -1442,18 +1442,22 @@ const byte _town_action_costs[8] = { 2, 4, 9, 35, 48, 53, 117, 175 }; -typedef void TownActionProc(Town *t, int action); +static void TownActionAdvertiseSmall(Town* t) +{ + ModifyStationRatingAround(t->xy, _current_player, 0x40, 10); +} + +static void TownActionAdvertiseMedium(Town* t) +{ + ModifyStationRatingAround(t->xy, _current_player, 0x70, 15); +} -static void TownActionAdvertise(Town *t, int action) +static void TownActionAdvertiseLarge(Town* t) { - static const byte _advertising_amount[3] = {0x40, 0x70, 0xA0}; - static const byte _advertising_radius[3] = {10, 15, 20}; - ModifyStationRatingAround(t->xy, _current_player, - _advertising_amount[action], - _advertising_radius[action]); + ModifyStationRatingAround(t->xy, _current_player, 0xA0, 20); } -static void TownActionRoadRebuild(Town *t, int action) +static void TownActionRoadRebuild(Town* t) { const Player* p; @@ -1495,7 +1499,7 @@ static bool DoBuildStatueOfCompany(TileIndex tile) return true; } -static void TownActionBuildStatue(Town *t, int action) +static void TownActionBuildStatue(Town* t) { // Layouted as an outward spiral static const TileIndexDiffC _statue_tiles[] = { @@ -1529,7 +1533,7 @@ static void TownActionBuildStatue(Town *t, int action) } } -static void TownActionFundBuildings(Town *t, int action) +static void TownActionFundBuildings(Town* t) { // Build next tick t->grow_counter = 1; @@ -1539,7 +1543,7 @@ static void TownActionFundBuildings(Town *t, int action) t->fund_buildings_months = 3; } -static void TownActionBuyRights(Town *t, int action) +static void TownActionBuyRights(Town* t) { t->exclusive_counter = 12; t->exclusivity = _current_player; @@ -1547,7 +1551,7 @@ static void TownActionBuyRights(Town *t, int action) ModifyStationRatingAround(t->xy, _current_player, 130, 17); } -static void TownActionBribe(Town *t, int action) +static void TownActionBribe(Town* t) { if (!RandomRange(15)) { Station *st; @@ -1580,10 +1584,11 @@ static void TownActionBribe(Town *t, int action) } } +typedef void TownActionProc(Town* t); static TownActionProc * const _town_action_proc[] = { - TownActionAdvertise, - TownActionAdvertise, - TownActionAdvertise, + TownActionAdvertiseSmall, + TownActionAdvertiseMedium, + TownActionAdvertiseLarge, TownActionRoadRebuild, TownActionBuildStatue, TownActionFundBuildings, @@ -1616,7 +1621,7 @@ int32 CmdDoTownAction(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) cost = (_price.build_industry >> 8) * _town_action_costs[p2]; if (flags & DC_EXEC) { - _town_action_proc[p2](t, p2); + _town_action_proc[p2](t); InvalidateWindow(WC_TOWN_AUTHORITY, p1); } |