1
0
Fork 0

Codechange: Rename TownEffect to TownAcceptanceEffect.

This makes it clearer that TownEffect only affects acceptance behaviour.
pull/10538/head
Peter Nelson 2024-01-07 19:32:39 +00:00 committed by Peter Nelson
parent 782cbe95d6
commit 60dcf3b5e2
16 changed files with 114 additions and 114 deletions

View File

@ -21,16 +21,16 @@
typedef uint32_t CargoLabel; typedef uint32_t CargoLabel;
/** Town growth effect when delivering cargo. */ /** Town growth effect when delivering cargo. */
enum TownEffect : byte { enum TownAcceptanceEffect : byte {
TE_BEGIN = 0, TAE_BEGIN = 0,
TE_NONE = TE_BEGIN, ///< Cargo has no effect. TAE_NONE = TAE_BEGIN, ///< Cargo has no effect.
TE_PASSENGERS, ///< Cargo behaves passenger-like. TAE_PASSENGERS, ///< Cargo behaves passenger-like.
TE_MAIL, ///< Cargo behaves mail-like. TAE_MAIL, ///< Cargo behaves mail-like.
TE_GOODS, ///< Cargo behaves goods/candy-like. TAE_GOODS, ///< Cargo behaves goods/candy-like.
TE_WATER, ///< Cargo behaves water-like. TAE_WATER, ///< Cargo behaves water-like.
TE_FOOD, ///< Cargo behaves food/fizzy-drinks-like. TAE_FOOD, ///< Cargo behaves food/fizzy-drinks-like.
TE_END, ///< End of town effects. TAE_END, ///< End of town effects.
NUM_TE = TE_END, ///< Amount of town effects. NUM_TAE = TAE_END, ///< Amount of town effects.
}; };
/** Cargo classes. */ /** Cargo classes. */
@ -64,7 +64,7 @@ struct CargoSpec {
uint8_t transit_periods[2]; uint8_t transit_periods[2];
bool is_freight; ///< Cargo type is considered to be freight (affects train freight multiplier). bool is_freight; ///< Cargo type is considered to be freight (affects train freight multiplier).
TownEffect town_effect; ///< The effect that delivering this cargo type has on towns. Also affects destination of subsidies. TownAcceptanceEffect town_acceptance_effect; ///< The effect that delivering this cargo type has on towns. Also affects destination of subsidies.
uint8_t callback_mask; ///< Bitmask of cargo callbacks that have to be called uint8_t callback_mask; ///< Bitmask of cargo callbacks that have to be called
StringID name; ///< Name of this type of cargo. StringID name; ///< Name of this type of cargo.

View File

@ -1136,7 +1136,7 @@ static Money DeliverGoods(int num_pieces, CargoID cargo_type, StationID dest, ui
/* Increase town's counter for town effects */ /* Increase town's counter for town effects */
const CargoSpec *cs = CargoSpec::Get(cargo_type); const CargoSpec *cs = CargoSpec::Get(cargo_type);
st->town->received[cs->town_effect].new_act += accepted_total; st->town->received[cs->town_acceptance_effect].new_act += accepted_total;
/* Determine profit */ /* Determine profit */
Money profit = GetTransportedGoodsIncome(accepted_total, distance, periods_in_transit, cargo_type); Money profit = GetTransportedGoodsIncome(accepted_total, distance, periods_in_transit, cargo_type);

View File

@ -3066,15 +3066,15 @@ static ChangeInfoResult CargoChangeInfo(uint cid, int numinfo, int prop, ByteRea
uint8_t substitute_type = buf->ReadByte(); uint8_t substitute_type = buf->ReadByte();
switch (substitute_type) { switch (substitute_type) {
case 0x00: cs->town_effect = TE_PASSENGERS; break; case 0x00: cs->town_acceptance_effect = TAE_PASSENGERS; break;
case 0x02: cs->town_effect = TE_MAIL; break; case 0x02: cs->town_acceptance_effect = TAE_MAIL; break;
case 0x05: cs->town_effect = TE_GOODS; break; case 0x05: cs->town_acceptance_effect = TAE_GOODS; break;
case 0x09: cs->town_effect = TE_WATER; break; case 0x09: cs->town_acceptance_effect = TAE_WATER; break;
case 0x0B: cs->town_effect = TE_FOOD; break; case 0x0B: cs->town_acceptance_effect = TAE_FOOD; break;
default: default:
GrfMsg(1, "CargoChangeInfo: Unknown town growth substitute value {}, setting to none.", substitute_type); GrfMsg(1, "CargoChangeInfo: Unknown town growth substitute value {}, setting to none.", substitute_type);
FALLTHROUGH; FALLTHROUGH;
case 0xFF: cs->town_effect = TE_NONE; break; case 0xFF: cs->town_acceptance_effect = TAE_NONE; break;
} }
break; break;
} }

View File

@ -99,14 +99,14 @@
case 0xC9: return GB(ClampTo<uint16_t>(this->t->supplied[CT_MAIL].old_act), 8, 8); case 0xC9: return GB(ClampTo<uint16_t>(this->t->supplied[CT_MAIL].old_act), 8, 8);
case 0xCA: return this->t->GetPercentTransported(CT_PASSENGERS); case 0xCA: return this->t->GetPercentTransported(CT_PASSENGERS);
case 0xCB: return this->t->GetPercentTransported(CT_MAIL); case 0xCB: return this->t->GetPercentTransported(CT_MAIL);
case 0xCC: return this->t->received[TE_FOOD].new_act; case 0xCC: return this->t->received[TAE_FOOD].new_act;
case 0xCD: return GB(this->t->received[TE_FOOD].new_act, 8, 8); case 0xCD: return GB(this->t->received[TAE_FOOD].new_act, 8, 8);
case 0xCE: return this->t->received[TE_WATER].new_act; case 0xCE: return this->t->received[TAE_WATER].new_act;
case 0xCF: return GB(this->t->received[TE_WATER].new_act, 8, 8); case 0xCF: return GB(this->t->received[TAE_WATER].new_act, 8, 8);
case 0xD0: return this->t->received[TE_FOOD].old_act; case 0xD0: return this->t->received[TAE_FOOD].old_act;
case 0xD1: return GB(this->t->received[TE_FOOD].old_act, 8, 8); case 0xD1: return GB(this->t->received[TAE_FOOD].old_act, 8, 8);
case 0xD2: return this->t->received[TE_WATER].old_act; case 0xD2: return this->t->received[TAE_WATER].old_act;
case 0xD3: return GB(this->t->received[TE_WATER].old_act, 8, 8); case 0xD3: return GB(this->t->received[TAE_WATER].old_act, 8, 8);
case 0xD4: return this->t->road_build_months; case 0xD4: return this->t->road_build_months;
case 0xD5: return this->t->fund_buildings_months; case 0xD5: return this->t->fund_buildings_months;
} }

View File

@ -2225,15 +2225,15 @@ bool AfterLoadGame()
s->remaining = 12 - s->remaining; // convert "age" to "remaining" s->remaining = 12 - s->remaining; // convert "age" to "remaining"
s->awarded = INVALID_COMPANY; // not awarded to anyone s->awarded = INVALID_COMPANY; // not awarded to anyone
const CargoSpec *cs = CargoSpec::Get(s->cargo_type); const CargoSpec *cs = CargoSpec::Get(s->cargo_type);
switch (cs->town_effect) { switch (cs->town_acceptance_effect) {
case TE_PASSENGERS: case TAE_PASSENGERS:
case TE_MAIL: case TAE_MAIL:
/* Town -> Town */ /* Town -> Town */
s->src_type = s->dst_type = SourceType::Town; s->src_type = s->dst_type = SourceType::Town;
if (Town::IsValidID(s->src) && Town::IsValidID(s->dst)) continue; if (Town::IsValidID(s->src) && Town::IsValidID(s->dst)) continue;
break; break;
case TE_GOODS: case TAE_GOODS:
case TE_FOOD: case TAE_FOOD:
/* Industry -> Town */ /* Industry -> Town */
s->src_type = SourceType::Industry; s->src_type = SourceType::Industry;
s->dst_type = SourceType::Town; s->dst_type = SourceType::Town;
@ -2251,9 +2251,9 @@ bool AfterLoadGame()
* Town -> Town subsidies are converted using simple heuristic */ * Town -> Town subsidies are converted using simple heuristic */
s->remaining = 24 - s->remaining; // convert "age of awarded subsidy" to "remaining" s->remaining = 24 - s->remaining; // convert "age of awarded subsidy" to "remaining"
const CargoSpec *cs = CargoSpec::Get(s->cargo_type); const CargoSpec *cs = CargoSpec::Get(s->cargo_type);
switch (cs->town_effect) { switch (cs->town_acceptance_effect) {
case TE_PASSENGERS: case TAE_PASSENGERS:
case TE_MAIL: { case TAE_MAIL: {
/* Town -> Town */ /* Town -> Town */
const Station *ss = Station::GetIfValid(s->src); const Station *ss = Station::GetIfValid(s->src);
const Station *sd = Station::GetIfValid(s->dst); const Station *sd = Station::GetIfValid(s->dst);
@ -2813,12 +2813,12 @@ bool AfterLoadGame()
/* Set the default cargo requirement for town growth */ /* Set the default cargo requirement for town growth */
switch (_settings_game.game_creation.landscape) { switch (_settings_game.game_creation.landscape) {
case LT_ARCTIC: case LT_ARCTIC:
if (FindFirstCargoWithTownEffect(TE_FOOD) != nullptr) t->goal[TE_FOOD] = TOWN_GROWTH_WINTER; if (FindFirstCargoWithTownAcceptanceEffect(TAE_FOOD) != nullptr) t->goal[TAE_FOOD] = TOWN_GROWTH_WINTER;
break; break;
case LT_TROPIC: case LT_TROPIC:
if (FindFirstCargoWithTownEffect(TE_FOOD) != nullptr) t->goal[TE_FOOD] = TOWN_GROWTH_DESERT; if (FindFirstCargoWithTownAcceptanceEffect(TAE_FOOD) != nullptr) t->goal[TAE_FOOD] = TOWN_GROWTH_DESERT;
if (FindFirstCargoWithTownEffect(TE_WATER) != nullptr) t->goal[TE_WATER] = TOWN_GROWTH_DESERT; if (FindFirstCargoWithTownAcceptanceEffect(TAE_WATER) != nullptr) t->goal[TAE_WATER] = TOWN_GROWTH_DESERT;
break; break;
} }
} }

View File

@ -601,10 +601,10 @@ static const OldChunks town_chunk[] = {
OCL_NULL( 2 ), ///< pct_pass_transported / pct_mail_transported, now computed on the fly OCL_NULL( 2 ), ///< pct_pass_transported / pct_mail_transported, now computed on the fly
OCL_SVAR( OC_TTD | OC_UINT16, Town, received[TE_FOOD].new_act ), OCL_SVAR( OC_TTD | OC_UINT16, Town, received[TAE_FOOD].new_act ),
OCL_SVAR( OC_TTD | OC_UINT16, Town, received[TE_WATER].new_act ), OCL_SVAR( OC_TTD | OC_UINT16, Town, received[TAE_WATER].new_act ),
OCL_SVAR( OC_TTD | OC_UINT16, Town, received[TE_FOOD].old_act ), OCL_SVAR( OC_TTD | OC_UINT16, Town, received[TAE_FOOD].old_act ),
OCL_SVAR( OC_TTD | OC_UINT16, Town, received[TE_WATER].old_act ), OCL_SVAR( OC_TTD | OC_UINT16, Town, received[TAE_WATER].old_act ),
OCL_SVAR( OC_UINT8, Town, road_build_months ), OCL_SVAR( OC_UINT8, Town, road_build_months ),
OCL_SVAR( OC_UINT8, Town, fund_buildings_months ), OCL_SVAR( OC_UINT8, Town, fund_buildings_months ),

View File

@ -174,7 +174,7 @@ public:
void Load(Town *t) const override void Load(Town *t) const override
{ {
size_t length = IsSavegameVersionBefore(SLV_SAVELOAD_LIST_LENGTH) ? (size_t)TE_END : SlGetStructListLength(TE_END); size_t length = IsSavegameVersionBefore(SLV_SAVELOAD_LIST_LENGTH) ? (size_t)TAE_END : SlGetStructListLength(TAE_END);
for (size_t i = 0; i < length; i++) { for (size_t i = 0; i < length; i++) {
SlObject(&t->received[i], this->GetLoadDescription()); SlObject(&t->received[i], this->GetLoadDescription());
} }
@ -239,12 +239,12 @@ static const SaveLoad _town_desc[] = {
SLE_CONDVAR(Town, supplied[CT_MAIL].new_act, SLE_FILE_U16 | SLE_VAR_U32, SL_MIN_VERSION, SLV_9), SLE_CONDVAR(Town, supplied[CT_MAIL].new_act, SLE_FILE_U16 | SLE_VAR_U32, SL_MIN_VERSION, SLV_9),
SLE_CONDVAR(Town, supplied[CT_MAIL].new_act, SLE_UINT32, SLV_9, SLV_165), SLE_CONDVAR(Town, supplied[CT_MAIL].new_act, SLE_UINT32, SLV_9, SLV_165),
SLE_CONDVAR(Town, received[TE_FOOD].old_act, SLE_UINT16, SL_MIN_VERSION, SLV_165), SLE_CONDVARNAME(Town, received[TAE_FOOD].old_act, "received[TE_FOOD].old_act", SLE_UINT16, SL_MIN_VERSION, SLV_165),
SLE_CONDVAR(Town, received[TE_WATER].old_act, SLE_UINT16, SL_MIN_VERSION, SLV_165), SLE_CONDVARNAME(Town, received[TAE_WATER].old_act, "received[TE_WATER].old_act", SLE_UINT16, SL_MIN_VERSION, SLV_165),
SLE_CONDVAR(Town, received[TE_FOOD].new_act, SLE_UINT16, SL_MIN_VERSION, SLV_165), SLE_CONDVARNAME(Town, received[TAE_FOOD].new_act, "received[TE_FOOD].new_act", SLE_UINT16, SL_MIN_VERSION, SLV_165),
SLE_CONDVAR(Town, received[TE_WATER].new_act, SLE_UINT16, SL_MIN_VERSION, SLV_165), SLE_CONDVARNAME(Town, received[TAE_WATER].new_act, "received[TE_WATER].new_act", SLE_UINT16, SL_MIN_VERSION, SLV_165),
SLE_CONDARR(Town, goal, SLE_UINT32, NUM_TE, SLV_165, SL_MAX_VERSION), SLE_CONDARR(Town, goal, SLE_UINT32, NUM_TAE, SLV_165, SL_MAX_VERSION),
SLE_CONDSSTR(Town, text, SLE_STR | SLF_ALLOW_CONTROL, SLV_168, SL_MAX_VERSION), SLE_CONDSSTR(Town, text, SLE_STR | SLF_ALLOW_CONTROL, SLV_168, SL_MAX_VERSION),

View File

@ -25,7 +25,7 @@
/* static */ bool ScriptCargo::IsValidTownEffect(TownEffect towneffect_type) /* static */ bool ScriptCargo::IsValidTownEffect(TownEffect towneffect_type)
{ {
return (towneffect_type >= (TownEffect)TE_BEGIN && towneffect_type < (TownEffect)TE_END); return (towneffect_type >= (TownEffect)TAE_BEGIN && towneffect_type < (TownEffect)TAE_END);
} }
/* static */ std::optional<std::string> ScriptCargo::GetName(CargoID cargo_type) /* static */ std::optional<std::string> ScriptCargo::GetName(CargoID cargo_type)
@ -67,7 +67,7 @@
{ {
if (!IsValidCargo(cargo_type)) return TE_NONE; if (!IsValidCargo(cargo_type)) return TE_NONE;
return (ScriptCargo::TownEffect)::CargoSpec::Get(cargo_type)->town_effect; return (ScriptCargo::TownEffect)::CargoSpec::Get(cargo_type)->town_acceptance_effect;
} }
/* static */ Money ScriptCargo::GetCargoIncome(CargoID cargo_type, SQInteger distance, SQInteger days_in_transit) /* static */ Money ScriptCargo::GetCargoIncome(CargoID cargo_type, SQInteger distance, SQInteger days_in_transit)

View File

@ -42,12 +42,12 @@ public:
*/ */
enum TownEffect { enum TownEffect {
/* Note: these values represent part of the in-game TownEffect enum */ /* Note: these values represent part of the in-game TownEffect enum */
TE_NONE = ::TE_NONE, ///< This cargo has no effect on a town TE_NONE = ::TAE_NONE, ///< This cargo has no effect on a town
TE_PASSENGERS = ::TE_PASSENGERS, ///< This cargo supplies passengers to a town TE_PASSENGERS = ::TAE_PASSENGERS, ///< This cargo supplies passengers to a town
TE_MAIL = ::TE_MAIL, ///< This cargo supplies mail to a town TE_MAIL = ::TAE_MAIL, ///< This cargo supplies mail to a town
TE_GOODS = ::TE_GOODS, ///< This cargo supplies goods to a town TE_GOODS = ::TAE_GOODS, ///< This cargo supplies goods to a town
TE_WATER = ::TE_WATER, ///< This cargo supplies water to a town TE_WATER = ::TAE_WATER, ///< This cargo supplies water to a town
TE_FOOD = ::TE_FOOD, ///< This cargo supplies food to a town TE_FOOD = ::TAE_FOOD, ///< This cargo supplies food to a town
}; };
/** /**

View File

@ -133,7 +133,7 @@
goal = Clamp<SQInteger>(goal, 0, UINT32_MAX); goal = Clamp<SQInteger>(goal, 0, UINT32_MAX);
return ScriptObject::Command<CMD_TOWN_CARGO_GOAL>::Do(town_id, (::TownEffect)towneffect_id, goal); return ScriptObject::Command<CMD_TOWN_CARGO_GOAL>::Do(town_id, (::TownAcceptanceEffect)towneffect_id, goal);
} }
/* static */ SQInteger ScriptTown::GetCargoGoal(TownID town_id, ScriptCargo::TownEffect towneffect_id) /* static */ SQInteger ScriptTown::GetCargoGoal(TownID town_id, ScriptCargo::TownEffect towneffect_id)

View File

@ -20,7 +20,7 @@ ScriptTownList::ScriptTownList(HSQUIRRELVM vm)
ScriptTownEffectList::ScriptTownEffectList() ScriptTownEffectList::ScriptTownEffectList()
{ {
for (int i = TE_BEGIN; i < TE_END; i++) { for (int i = TAE_BEGIN; i < TAE_END; i++) {
this->AddItem(i); this->AddItem(i);
} }
} }

View File

@ -36,62 +36,62 @@
* @param td1 CargoSpec->transit_periods[0]. * @param td1 CargoSpec->transit_periods[0].
* @param td2 CargoSpec->transit_periods[1]. * @param td2 CargoSpec->transit_periods[1].
* @param freight Cargo type is considered to be freight (affects train freight multiplier). * @param freight Cargo type is considered to be freight (affects train freight multiplier).
* @param te The effect that delivering this cargo type has on towns. Also affects destination of subsidies. * @param tae The effect that delivering this cargo type has on towns.
* @param str_plural The name suffix used to populate CargoSpec->name, CargoSpec->quantifier, * @param str_plural The name suffix used to populate CargoSpec->name, CargoSpec->quantifier,
* CargoSpec->abbrev and CargoSpec->sprite. See above for more detailed information. * CargoSpec->abbrev and CargoSpec->sprite. See above for more detailed information.
* @param str_singular The name suffix used to populate CargoSpec->name_single. See above for more information. * @param str_singular The name suffix used to populate CargoSpec->name_single. See above for more information.
* @param str_volume Name of a single unit of cargo of this type. * @param str_volume Name of a single unit of cargo of this type.
* @param classes Classes of this cargo type. @see CargoClass * @param classes Classes of this cargo type. @see CargoClass
*/ */
#define MK(bt, label, colour, weight, mult, ip, td1, td2, freight, te, str_plural, str_singular, str_volume, classes) \ #define MK(bt, label, colour, weight, mult, ip, td1, td2, freight, tae, str_plural, str_singular, str_volume, classes) \
{label, bt, colour, colour, weight, mult, classes, ip, {td1, td2}, freight, te, 0, \ {label, bt, colour, colour, weight, mult, classes, ip, {td1, td2}, freight, tae, 0, \
MK_STR_CARGO_PLURAL(str_plural), MK_STR_CARGO_SINGULAR(str_singular), str_volume, MK_STR_QUANTITY(str_plural), MK_STR_ABBREV(str_plural), \ MK_STR_CARGO_PLURAL(str_plural), MK_STR_CARGO_SINGULAR(str_singular), str_volume, MK_STR_QUANTITY(str_plural), MK_STR_ABBREV(str_plural), \
MK_SPRITE(str_plural), nullptr, nullptr, 0} MK_SPRITE(str_plural), nullptr, nullptr, 0}
/** Cargo types available by default. */ /** Cargo types available by default. */
static const CargoSpec _default_cargo[] = { static const CargoSpec _default_cargo[] = {
MK( 0, 'PASS', 152, 1, 0x400, 3185, 0, 24, false, TE_PASSENGERS, PASSENGERS, PASSENGER, STR_PASSENGERS, CC_PASSENGERS), MK( 0, 'PASS', 152, 1, 0x400, 3185, 0, 24, false, TAE_PASSENGERS, PASSENGERS, PASSENGER, STR_PASSENGERS, CC_PASSENGERS),
MK( 1, 'COAL', 6, 16, 0x100, 5916, 7, 255, true, TE_NONE, COAL, COAL, STR_TONS, CC_BULK), MK( 1, 'COAL', 6, 16, 0x100, 5916, 7, 255, true, TAE_NONE, COAL, COAL, STR_TONS, CC_BULK),
MK( 2, 'MAIL', 15, 4, 0x200, 4550, 20, 90, false, TE_MAIL, MAIL, MAIL, STR_BAGS, CC_MAIL), MK( 2, 'MAIL', 15, 4, 0x200, 4550, 20, 90, false, TAE_MAIL, MAIL, MAIL, STR_BAGS, CC_MAIL),
/* Oil in temperate and arctic */ /* Oil in temperate and arctic */
MK( 3, 'OIL_', 174, 16, 0x100, 4437, 25, 255, true, TE_NONE, OIL, OIL, STR_LITERS, CC_LIQUID), MK( 3, 'OIL_', 174, 16, 0x100, 4437, 25, 255, true, TAE_NONE, OIL, OIL, STR_LITERS, CC_LIQUID),
/* Oil in subtropic */ /* Oil in subtropic */
MK( 3, 'OIL_', 174, 16, 0x100, 4892, 25, 255, true, TE_NONE, OIL, OIL, STR_LITERS, CC_LIQUID), MK( 3, 'OIL_', 174, 16, 0x100, 4892, 25, 255, true, TAE_NONE, OIL, OIL, STR_LITERS, CC_LIQUID),
MK( 4, 'LVST', 208, 3, 0x100, 4322, 4, 18, true, TE_NONE, LIVESTOCK, LIVESTOCK, STR_ITEMS, CC_PIECE_GOODS), MK( 4, 'LVST', 208, 3, 0x100, 4322, 4, 18, true, TAE_NONE, LIVESTOCK, LIVESTOCK, STR_ITEMS, CC_PIECE_GOODS),
MK( 5, 'GOOD', 194, 8, 0x200, 6144, 5, 28, true, TE_GOODS, GOODS, GOODS, STR_CRATES, CC_EXPRESS), MK( 5, 'GOOD', 194, 8, 0x200, 6144, 5, 28, true, TAE_GOODS, GOODS, GOODS, STR_CRATES, CC_EXPRESS),
MK( 6, 'GRAI', 191, 16, 0x100, 4778, 4, 40, true, TE_NONE, GRAIN, GRAIN, STR_TONS, CC_BULK), MK( 6, 'GRAI', 191, 16, 0x100, 4778, 4, 40, true, TAE_NONE, GRAIN, GRAIN, STR_TONS, CC_BULK),
MK( 6, 'WHEA', 191, 16, 0x100, 4778, 4, 40, true, TE_NONE, WHEAT, WHEAT, STR_TONS, CC_BULK), MK( 6, 'WHEA', 191, 16, 0x100, 4778, 4, 40, true, TAE_NONE, WHEAT, WHEAT, STR_TONS, CC_BULK),
MK( 6, 'MAIZ', 191, 16, 0x100, 4322, 4, 40, true, TE_NONE, MAIZE, MAIZE, STR_TONS, CC_BULK), MK( 6, 'MAIZ', 191, 16, 0x100, 4322, 4, 40, true, TAE_NONE, MAIZE, MAIZE, STR_TONS, CC_BULK),
/* Wood in temperate and arctic */ /* Wood in temperate and arctic */
MK( 7, 'WOOD', 84, 16, 0x100, 5005, 15, 255, true, TE_NONE, WOOD, WOOD, STR_TONS, CC_PIECE_GOODS), MK( 7, 'WOOD', 84, 16, 0x100, 5005, 15, 255, true, TAE_NONE, WOOD, WOOD, STR_TONS, CC_PIECE_GOODS),
/* Wood in subtropic */ /* Wood in subtropic */
MK( 7, 'WOOD', 84, 16, 0x100, 7964, 15, 255, true, TE_NONE, WOOD, WOOD, STR_TONS, CC_PIECE_GOODS), MK( 7, 'WOOD', 84, 16, 0x100, 7964, 15, 255, true, TAE_NONE, WOOD, WOOD, STR_TONS, CC_PIECE_GOODS),
MK( 8, 'IORE', 184, 16, 0x100, 5120, 9, 255, true, TE_NONE, IRON_ORE, IRON_ORE, STR_TONS, CC_BULK), MK( 8, 'IORE', 184, 16, 0x100, 5120, 9, 255, true, TAE_NONE, IRON_ORE, IRON_ORE, STR_TONS, CC_BULK),
MK( 9, 'STEL', 10, 16, 0x100, 5688, 7, 255, true, TE_NONE, STEEL, STEEL, STR_TONS, CC_PIECE_GOODS), MK( 9, 'STEL', 10, 16, 0x100, 5688, 7, 255, true, TAE_NONE, STEEL, STEEL, STR_TONS, CC_PIECE_GOODS),
MK( 10, 'VALU', 202, 2, 0x100, 7509, 1, 32, true, TE_NONE, VALUABLES, VALUABLES, STR_BAGS, CC_ARMOURED), MK( 10, 'VALU', 202, 2, 0x100, 7509, 1, 32, true, TAE_NONE, VALUABLES, VALUABLES, STR_BAGS, CC_ARMOURED),
MK( 10, 'GOLD', 202, 8, 0x100, 5802, 10, 40, true, TE_NONE, GOLD, GOLD, STR_BAGS, CC_ARMOURED), MK( 10, 'GOLD', 202, 8, 0x100, 5802, 10, 40, true, TAE_NONE, GOLD, GOLD, STR_BAGS, CC_ARMOURED),
MK( 10, 'DIAM', 202, 2, 0x100, 5802, 10, 255, true, TE_NONE, DIAMONDS, DIAMOND, STR_BAGS, CC_ARMOURED), MK( 10, 'DIAM', 202, 2, 0x100, 5802, 10, 255, true, TAE_NONE, DIAMONDS, DIAMOND, STR_BAGS, CC_ARMOURED),
MK( 11, 'PAPR', 10, 16, 0x100, 5461, 7, 60, true, TE_NONE, PAPER, PAPER, STR_TONS, CC_PIECE_GOODS), MK( 11, 'PAPR', 10, 16, 0x100, 5461, 7, 60, true, TAE_NONE, PAPER, PAPER, STR_TONS, CC_PIECE_GOODS),
MK( 12, 'FOOD', 48, 16, 0x100, 5688, 0, 30, true, TE_FOOD, FOOD, FOOD, STR_TONS, CC_EXPRESS | CC_REFRIGERATED), MK( 12, 'FOOD', 48, 16, 0x100, 5688, 0, 30, true, TAE_FOOD, FOOD, FOOD, STR_TONS, CC_EXPRESS | CC_REFRIGERATED),
MK( 13, 'FRUT', 208, 16, 0x100, 4209, 0, 15, true, TE_NONE, FRUIT, FRUIT, STR_TONS, CC_BULK | CC_REFRIGERATED), MK( 13, 'FRUT', 208, 16, 0x100, 4209, 0, 15, true, TAE_NONE, FRUIT, FRUIT, STR_TONS, CC_BULK | CC_REFRIGERATED),
MK( 14, 'CORE', 184, 16, 0x100, 4892, 12, 255, true, TE_NONE, COPPER_ORE, COPPER_ORE, STR_TONS, CC_BULK), MK( 14, 'CORE', 184, 16, 0x100, 4892, 12, 255, true, TAE_NONE, COPPER_ORE, COPPER_ORE, STR_TONS, CC_BULK),
MK( 15, 'WATR', 10, 16, 0x100, 4664, 20, 80, true, TE_WATER, WATER, WATER, STR_LITERS, CC_LIQUID), MK( 15, 'WATR', 10, 16, 0x100, 4664, 20, 80, true, TAE_WATER, WATER, WATER, STR_LITERS, CC_LIQUID),
MK( 16, 'RUBR', 6, 16, 0x100, 4437, 2, 20, true, TE_NONE, RUBBER, RUBBER, STR_LITERS, CC_LIQUID), MK( 16, 'RUBR', 6, 16, 0x100, 4437, 2, 20, true, TAE_NONE, RUBBER, RUBBER, STR_LITERS, CC_LIQUID),
MK( 17, 'SUGR', 6, 16, 0x100, 4437, 20, 255, true, TE_NONE, SUGAR, SUGAR, STR_TONS, CC_BULK), MK( 17, 'SUGR', 6, 16, 0x100, 4437, 20, 255, true, TAE_NONE, SUGAR, SUGAR, STR_TONS, CC_BULK),
MK( 18, 'TOYS', 174, 2, 0x100, 5574, 25, 255, true, TE_NONE, TOYS, TOY, STR_ITEMS, CC_PIECE_GOODS), MK( 18, 'TOYS', 174, 2, 0x100, 5574, 25, 255, true, TAE_NONE, TOYS, TOY, STR_ITEMS, CC_PIECE_GOODS),
MK( 19, 'BATT', 208, 4, 0x100, 4322, 2, 30, true, TE_NONE, BATTERIES, BATTERY, STR_ITEMS, CC_PIECE_GOODS), MK( 19, 'BATT', 208, 4, 0x100, 4322, 2, 30, true, TAE_NONE, BATTERIES, BATTERY, STR_ITEMS, CC_PIECE_GOODS),
MK( 20, 'SWET', 194, 5, 0x200, 6144, 8, 40, true, TE_GOODS, SWEETS, SWEETS, STR_BAGS, CC_EXPRESS), MK( 20, 'SWET', 194, 5, 0x200, 6144, 8, 40, true, TAE_GOODS, SWEETS, SWEETS, STR_BAGS, CC_EXPRESS),
MK( 21, 'TOFF', 191, 16, 0x100, 4778, 14, 60, true, TE_NONE, TOFFEE, TOFFEE, STR_TONS, CC_BULK), MK( 21, 'TOFF', 191, 16, 0x100, 4778, 14, 60, true, TAE_NONE, TOFFEE, TOFFEE, STR_TONS, CC_BULK),
MK( 22, 'COLA', 84, 16, 0x100, 4892, 5, 75, true, TE_NONE, COLA, COLA, STR_LITERS, CC_LIQUID), MK( 22, 'COLA', 84, 16, 0x100, 4892, 5, 75, true, TAE_NONE, COLA, COLA, STR_LITERS, CC_LIQUID),
MK( 23, 'CTCD', 184, 16, 0x100, 5005, 10, 25, true, TE_NONE, CANDYFLOSS, CANDYFLOSS, STR_TONS, CC_BULK), MK( 23, 'CTCD', 184, 16, 0x100, 5005, 10, 25, true, TAE_NONE, CANDYFLOSS, CANDYFLOSS, STR_TONS, CC_BULK),
MK( 24, 'BUBL', 10, 1, 0x100, 5077, 20, 80, true, TE_NONE, BUBBLES, BUBBLE, STR_ITEMS, CC_PIECE_GOODS), MK( 24, 'BUBL', 10, 1, 0x100, 5077, 20, 80, true, TAE_NONE, BUBBLES, BUBBLE, STR_ITEMS, CC_PIECE_GOODS),
MK( 25, 'PLST', 202, 16, 0x100, 4664, 30, 255, true, TE_NONE, PLASTIC, PLASTIC, STR_LITERS, CC_LIQUID), MK( 25, 'PLST', 202, 16, 0x100, 4664, 30, 255, true, TAE_NONE, PLASTIC, PLASTIC, STR_LITERS, CC_LIQUID),
MK( 26, 'FZDR', 48, 2, 0x100, 6250, 30, 50, true, TE_FOOD, FIZZY_DRINKS, FIZZY_DRINK, STR_ITEMS, CC_PIECE_GOODS), MK( 26, 'FZDR', 48, 2, 0x100, 6250, 30, 50, true, TAE_FOOD, FIZZY_DRINKS, FIZZY_DRINK, STR_ITEMS, CC_PIECE_GOODS),
/* Void slot in temperate */ /* Void slot in temperate */
MK(0xFF, 0, 1, 0, 0x100, 5688, 0, 30, true, TE_NONE, NOTHING, NOTHING, STR_TONS, CC_NOAVAILABLE), MK(0xFF, 0, 1, 0, 0x100, 5688, 0, 30, true, TAE_NONE, NOTHING, NOTHING, STR_TONS, CC_NOAVAILABLE),
/* Void slot in arctic */ /* Void slot in arctic */
MK(0xFF, 0, 184, 0, 0x100, 5120, 9, 255, true, TE_NONE, NOTHING, NOTHING, STR_TONS, CC_NOAVAILABLE), MK(0xFF, 0, 184, 0, 0x100, 5120, 9, 255, true, TAE_NONE, NOTHING, NOTHING, STR_TONS, CC_NOAVAILABLE),
}; };

View File

@ -73,8 +73,8 @@ struct Town : TownPool::PoolItem<&_town_pool> {
int16_t ratings[MAX_COMPANIES]; ///< ratings of each company for this town int16_t ratings[MAX_COMPANIES]; ///< ratings of each company for this town
TransportedCargoStat<uint32_t> supplied[NUM_CARGO]; ///< Cargo statistics about supplied cargo. TransportedCargoStat<uint32_t> supplied[NUM_CARGO]; ///< Cargo statistics about supplied cargo.
TransportedCargoStat<uint16_t> received[NUM_TE]; ///< Cargo statistics about received cargotypes. TransportedCargoStat<uint16_t> received[NUM_TAE]; ///< Cargo statistics about received cargotypes.
uint32_t goal[NUM_TE]; ///< Amount of cargo required for the town to grow. uint32_t goal[NUM_TAE]; ///< Amount of cargo required for the town to grow.
std::string text; ///< General text with additional information. std::string text; ///< General text with additional information.
@ -232,7 +232,7 @@ HouseZonesBits GetTownRadiusGroup(const Town *t, TileIndex tile);
void SetTownRatingTestMode(bool mode); void SetTownRatingTestMode(bool mode);
TownActions GetMaskOfTownActions(CompanyID cid, const Town *t); TownActions GetMaskOfTownActions(CompanyID cid, const Town *t);
bool GenerateTowns(TownLayout layout); bool GenerateTowns(TownLayout layout);
const CargoSpec *FindFirstCargoWithTownEffect(TownEffect effect); const CargoSpec *FindFirstCargoWithTownAcceptanceEffect(TownAcceptanceEffect effect);
extern const byte _town_action_costs[TACT_COUNT]; extern const byte _town_action_costs[TACT_COUNT];

View File

@ -1920,12 +1920,12 @@ static void DoCreateTown(Town *t, TileIndex tile, uint32_t townnameparts, TownSi
/* Set the default cargo requirement for town growth */ /* Set the default cargo requirement for town growth */
switch (_settings_game.game_creation.landscape) { switch (_settings_game.game_creation.landscape) {
case LT_ARCTIC: case LT_ARCTIC:
if (FindFirstCargoWithTownEffect(TE_FOOD) != nullptr) t->goal[TE_FOOD] = TOWN_GROWTH_WINTER; if (FindFirstCargoWithTownAcceptanceEffect(TAE_FOOD) != nullptr) t->goal[TAE_FOOD] = TOWN_GROWTH_WINTER;
break; break;
case LT_TROPIC: case LT_TROPIC:
if (FindFirstCargoWithTownEffect(TE_FOOD) != nullptr) t->goal[TE_FOOD] = TOWN_GROWTH_DESERT; if (FindFirstCargoWithTownAcceptanceEffect(TAE_FOOD) != nullptr) t->goal[TAE_FOOD] = TOWN_GROWTH_DESERT;
if (FindFirstCargoWithTownEffect(TE_WATER) != nullptr) t->goal[TE_WATER] = TOWN_GROWTH_DESERT; if (FindFirstCargoWithTownAcceptanceEffect(TAE_WATER) != nullptr) t->goal[TAE_WATER] = TOWN_GROWTH_DESERT;
break; break;
} }
@ -2874,10 +2874,10 @@ CommandCost CmdRenameTown(DoCommandFlag flags, TownID town_id, const std::string
* @param effect Town effect of interest * @param effect Town effect of interest
* @return first active cargo slot with that effect * @return first active cargo slot with that effect
*/ */
const CargoSpec *FindFirstCargoWithTownEffect(TownEffect effect) const CargoSpec *FindFirstCargoWithTownAcceptanceEffect(TownAcceptanceEffect effect)
{ {
for (const CargoSpec *cs : CargoSpec::Iterate()) { for (const CargoSpec *cs : CargoSpec::Iterate()) {
if (cs->town_effect == effect) return cs; if (cs->town_acceptance_effect == effect) return cs;
} }
return nullptr; return nullptr;
} }
@ -2886,25 +2886,25 @@ const CargoSpec *FindFirstCargoWithTownEffect(TownEffect effect)
* Change the cargo goal of a town. * Change the cargo goal of a town.
* @param flags Type of operation. * @param flags Type of operation.
* @param town_id Town ID to cargo game of. * @param town_id Town ID to cargo game of.
* @param te TownEffect to change the game of. * @param tae TownEffect to change the game of.
* @param goal The new goal value. * @param goal The new goal value.
* @return Empty cost or an error. * @return Empty cost or an error.
*/ */
CommandCost CmdTownCargoGoal(DoCommandFlag flags, TownID town_id, TownEffect te, uint32_t goal) CommandCost CmdTownCargoGoal(DoCommandFlag flags, TownID town_id, TownAcceptanceEffect tae, uint32_t goal)
{ {
if (_current_company != OWNER_DEITY) return CMD_ERROR; if (_current_company != OWNER_DEITY) return CMD_ERROR;
if (te < TE_BEGIN || te >= TE_END) return CMD_ERROR; if (tae < TAE_BEGIN || tae >= TAE_END) return CMD_ERROR;
Town *t = Town::GetIfValid(town_id); Town *t = Town::GetIfValid(town_id);
if (t == nullptr) return CMD_ERROR; if (t == nullptr) return CMD_ERROR;
/* Validate if there is a cargo which is the requested TownEffect */ /* Validate if there is a cargo which is the requested TownEffect */
const CargoSpec *cargo = FindFirstCargoWithTownEffect(te); const CargoSpec *cargo = FindFirstCargoWithTownAcceptanceEffect(tae);
if (cargo == nullptr) return CMD_ERROR; if (cargo == nullptr) return CMD_ERROR;
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
t->goal[te] = goal; t->goal[tae] = goal;
UpdateTownGrowth(t); UpdateTownGrowth(t);
InvalidateWindowData(WC_TOWN_VIEW, town_id); InvalidateWindowData(WC_TOWN_VIEW, town_id);
} }
@ -3634,7 +3634,7 @@ static void UpdateTownGrowth(Town *t)
if (t->fund_buildings_months == 0) { if (t->fund_buildings_months == 0) {
/* Check if all goals are reached for this town to grow (given we are not funding it) */ /* Check if all goals are reached for this town to grow (given we are not funding it) */
for (int i = TE_BEGIN; i < TE_END; i++) { for (int i = TAE_BEGIN; i < TAE_END; i++) {
switch (t->goal[i]) { switch (t->goal[i]) {
case TOWN_GROWTH_WINTER: case TOWN_GROWTH_WINTER:
if (TileHeight(t->xy) >= GetSnowLine() && t->received[i].old_act == 0 && t->cache.population > 90) return; if (TileHeight(t->xy) >= GetSnowLine() && t->received[i].old_act == 0 && t->cache.population > 90) return;

View File

@ -14,14 +14,14 @@
#include "company_type.h" #include "company_type.h"
#include "town_type.h" #include "town_type.h"
enum TownEffect : byte; enum TownAcceptanceEffect : byte;
std::tuple<CommandCost, Money, TownID> CmdFoundTown(DoCommandFlag flags, TileIndex tile, TownSize size, bool city, TownLayout layout, bool random_location, uint32_t townnameparts, const std::string &text); std::tuple<CommandCost, Money, TownID> CmdFoundTown(DoCommandFlag flags, TileIndex tile, TownSize size, bool city, TownLayout layout, bool random_location, uint32_t townnameparts, const std::string &text);
CommandCost CmdRenameTown(DoCommandFlag flags, TownID town_id, const std::string &text); CommandCost CmdRenameTown(DoCommandFlag flags, TownID town_id, const std::string &text);
CommandCost CmdDoTownAction(DoCommandFlag flags, TownID town_id, uint8_t action); CommandCost CmdDoTownAction(DoCommandFlag flags, TownID town_id, uint8_t action);
CommandCost CmdTownGrowthRate(DoCommandFlag flags, TownID town_id, uint16_t growth_rate); CommandCost CmdTownGrowthRate(DoCommandFlag flags, TownID town_id, uint16_t growth_rate);
CommandCost CmdTownRating(DoCommandFlag flags, TownID town_id, CompanyID company_id, int16_t rating); CommandCost CmdTownRating(DoCommandFlag flags, TownID town_id, CompanyID company_id, int16_t rating);
CommandCost CmdTownCargoGoal(DoCommandFlag flags, TownID town_id, TownEffect te, uint32_t goal); CommandCost CmdTownCargoGoal(DoCommandFlag flags, TownID town_id, TownAcceptanceEffect tae, uint32_t goal);
CommandCost CmdTownSetText(DoCommandFlag flags, TownID town_id, const std::string &text); CommandCost CmdTownSetText(DoCommandFlag flags, TownID town_id, const std::string &text);
CommandCost CmdExpandTown(DoCommandFlag flags, TownID town_id, uint32_t grow_amount); CommandCost CmdExpandTown(DoCommandFlag flags, TownID town_id, uint32_t grow_amount);
CommandCost CmdDeleteTown(DoCommandFlag flags, TownID town_id); CommandCost CmdDeleteTown(DoCommandFlag flags, TownID town_id);

View File

@ -421,7 +421,7 @@ public:
tr.top += GetCharacterHeight(FS_NORMAL); tr.top += GetCharacterHeight(FS_NORMAL);
bool first = true; bool first = true;
for (int i = TE_BEGIN; i < TE_END; i++) { for (int i = TAE_BEGIN; i < TAE_END; i++) {
if (this->town->goal[i] == 0) continue; if (this->town->goal[i] == 0) continue;
if (this->town->goal[i] == TOWN_GROWTH_WINTER && (TileHeight(this->town->xy) < LowestSnowLine() || this->town->cache.population <= 90)) continue; if (this->town->goal[i] == TOWN_GROWTH_WINTER && (TileHeight(this->town->xy) < LowestSnowLine() || this->town->cache.population <= 90)) continue;
if (this->town->goal[i] == TOWN_GROWTH_DESERT && (GetTropicZone(this->town->xy) != TROPICZONE_DESERT || this->town->cache.population <= 60)) continue; if (this->town->goal[i] == TOWN_GROWTH_DESERT && (GetTropicZone(this->town->xy) != TROPICZONE_DESERT || this->town->cache.population <= 60)) continue;
@ -434,7 +434,7 @@ public:
bool rtl = _current_text_dir == TD_RTL; bool rtl = _current_text_dir == TD_RTL;
const CargoSpec *cargo = FindFirstCargoWithTownEffect((TownEffect)i); const CargoSpec *cargo = FindFirstCargoWithTownAcceptanceEffect((TownAcceptanceEffect)i);
assert(cargo != nullptr); assert(cargo != nullptr);
StringID string; StringID string;
@ -542,7 +542,7 @@ public:
uint aimed_height = 3 * GetCharacterHeight(FS_NORMAL); uint aimed_height = 3 * GetCharacterHeight(FS_NORMAL);
bool first = true; bool first = true;
for (int i = TE_BEGIN; i < TE_END; i++) { for (int i = TAE_BEGIN; i < TAE_END; i++) {
if (this->town->goal[i] == 0) continue; if (this->town->goal[i] == 0) continue;
if (this->town->goal[i] == TOWN_GROWTH_WINTER && (TileHeight(this->town->xy) < LowestSnowLine() || this->town->cache.population <= 90)) continue; if (this->town->goal[i] == TOWN_GROWTH_WINTER && (TileHeight(this->town->xy) < LowestSnowLine() || this->town->cache.population <= 90)) continue;
if (this->town->goal[i] == TOWN_GROWTH_DESERT && (GetTropicZone(this->town->xy) != TROPICZONE_DESERT || this->town->cache.population <= 60)) continue; if (this->town->goal[i] == TOWN_GROWTH_DESERT && (GetTropicZone(this->town->xy) != TROPICZONE_DESERT || this->town->cache.population <= 60)) continue;