mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Unify naming of NewGRF random trigger functions.
parent
368d131fb7
commit
39220a5feb
|
@ -1167,7 +1167,7 @@ static void TriggerIndustryProduction(Industry *i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TriggerIndustry(i, INDUSTRY_TRIGGER_RECEIVED_CARGO);
|
TriggerIndustryRandomisation(i, INDUSTRY_TRIGGER_RECEIVED_CARGO);
|
||||||
StartStopIndustryTileAnimation(i, IAT_INDUSTRY_RECEIVED_CARGO);
|
StartStopIndustryTileAnimation(i, IAT_INDUSTRY_RECEIVED_CARGO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1779,7 +1779,7 @@ static void LoadUnloadVehicle(Vehicle *front)
|
||||||
/* If there's goods waiting at the station, and the vehicle
|
/* If there's goods waiting at the station, and the vehicle
|
||||||
* has capacity for it, load it on the vehicle. */
|
* has capacity for it, load it on the vehicle. */
|
||||||
if ((v->cargo.ActionCount(VehicleCargoList::MTA_LOAD) > 0 || (ge->HasData() && ge->GetData().cargo.AvailableCount() > 0)) && MayLoadUnderExclusiveRights(st, v)) {
|
if ((v->cargo.ActionCount(VehicleCargoList::MTA_LOAD) > 0 || (ge->HasData() && ge->GetData().cargo.AvailableCount() > 0)) && MayLoadUnderExclusiveRights(st, v)) {
|
||||||
if (v->cargo.StoredCount() == 0) TriggerVehicle(v, VEHICLE_TRIGGER_NEW_CARGO);
|
if (v->cargo.StoredCount() == 0) TriggerVehicleRandomisation(v, VEHICLE_TRIGGER_NEW_CARGO);
|
||||||
if (_settings_game.order.gradual_loading) cap_left = std::min(cap_left, GetLoadAmount(v));
|
if (_settings_game.order.gradual_loading) cap_left = std::min(cap_left, GetLoadAmount(v));
|
||||||
|
|
||||||
uint loaded = ge->GetOrCreateData().cargo.Load(cap_left, &v->cargo, next_station, v->GetCargoTile());
|
uint loaded = ge->GetOrCreateData().cargo.Load(cap_left, &v->cargo, next_station, v->GetCargoTile());
|
||||||
|
@ -1910,7 +1910,7 @@ static void LoadUnloadVehicle(Vehicle *front)
|
||||||
/* Make sure the vehicle is marked dirty, since we need to update the NewGRF
|
/* Make sure the vehicle is marked dirty, since we need to update the NewGRF
|
||||||
* properties such as weight, power and TE whenever the trigger runs. */
|
* properties such as weight, power and TE whenever the trigger runs. */
|
||||||
dirty_vehicle = true;
|
dirty_vehicle = true;
|
||||||
TriggerVehicle(front, VEHICLE_TRIGGER_EMPTY);
|
TriggerVehicleRandomisation(front, VEHICLE_TRIGGER_EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dirty_vehicle) {
|
if (dirty_vehicle) {
|
||||||
|
|
|
@ -844,7 +844,7 @@ static void TileLoop_Industry(TileIndex tile)
|
||||||
* returning from TileLoop_Water. */
|
* returning from TileLoop_Water. */
|
||||||
if (!IsTileType(tile, MP_INDUSTRY)) return;
|
if (!IsTileType(tile, MP_INDUSTRY)) return;
|
||||||
|
|
||||||
TriggerIndustryTile(tile, INDTILE_TRIGGER_TILE_LOOP);
|
TriggerIndustryTileRandomisation(tile, INDTILE_TRIGGER_TILE_LOOP);
|
||||||
|
|
||||||
if (!IsIndustryCompleted(tile)) {
|
if (!IsIndustryCompleted(tile)) {
|
||||||
MakeIndustryTileBigger(tile);
|
MakeIndustryTileBigger(tile);
|
||||||
|
@ -1222,7 +1222,7 @@ static void ProduceIndustryGoods(Industry *i)
|
||||||
if (cut) ChopLumberMillTrees(i);
|
if (cut) ChopLumberMillTrees(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
TriggerIndustry(i, INDUSTRY_TRIGGER_INDUSTRY_TICK);
|
TriggerIndustryRandomisation(i, INDUSTRY_TRIGGER_INDUSTRY_TICK);
|
||||||
StartStopIndustryTileAnimation(i, IAT_INDUSTRY_TICK);
|
StartStopIndustryTileAnimation(i, IAT_INDUSTRY_TICK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1247,7 +1247,7 @@ bool TestVehicleBuildProbability(Vehicle *v, EngineID engine, BuildProbabilityTy
|
||||||
return p + RandomRange(PROBABILITY_RANGE) >= PROBABILITY_RANGE;
|
return p + RandomRange(PROBABILITY_RANGE) >= PROBABILITY_RANGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DoTriggerVehicle(Vehicle *v, VehicleTrigger trigger, uint16_t base_random_bits, bool first)
|
static void DoTriggerVehicleRandomisation(Vehicle *v, VehicleTrigger trigger, uint16_t base_random_bits, bool first)
|
||||||
{
|
{
|
||||||
/* We can't trigger a non-existent vehicle... */
|
/* We can't trigger a non-existent vehicle... */
|
||||||
assert(v != nullptr);
|
assert(v != nullptr);
|
||||||
|
@ -1278,14 +1278,14 @@ static void DoTriggerVehicle(Vehicle *v, VehicleTrigger trigger, uint16_t base_r
|
||||||
* i.e.), so we give them all the NEW_CARGO triggered
|
* i.e.), so we give them all the NEW_CARGO triggered
|
||||||
* vehicle's portion of random bits. */
|
* vehicle's portion of random bits. */
|
||||||
assert(first);
|
assert(first);
|
||||||
DoTriggerVehicle(v->First(), VEHICLE_TRIGGER_ANY_NEW_CARGO, new_random_bits, false);
|
DoTriggerVehicleRandomisation(v->First(), VEHICLE_TRIGGER_ANY_NEW_CARGO, new_random_bits, false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VEHICLE_TRIGGER_DEPOT:
|
case VEHICLE_TRIGGER_DEPOT:
|
||||||
/* We now trigger the next vehicle in chain recursively.
|
/* We now trigger the next vehicle in chain recursively.
|
||||||
* The random bits portions may be different for each
|
* The random bits portions may be different for each
|
||||||
* vehicle in chain. */
|
* vehicle in chain. */
|
||||||
if (v->Next() != nullptr) DoTriggerVehicle(v->Next(), trigger, 0, true);
|
if (v->Next() != nullptr) DoTriggerVehicleRandomisation(v->Next(), trigger, 0, true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VEHICLE_TRIGGER_EMPTY:
|
case VEHICLE_TRIGGER_EMPTY:
|
||||||
|
@ -1293,14 +1293,14 @@ static void DoTriggerVehicle(Vehicle *v, VehicleTrigger trigger, uint16_t base_r
|
||||||
* recursively. The random bits portions must be same
|
* recursively. The random bits portions must be same
|
||||||
* for each vehicle in chain, so we give them all
|
* for each vehicle in chain, so we give them all
|
||||||
* first chained vehicle's portion of random bits. */
|
* first chained vehicle's portion of random bits. */
|
||||||
if (v->Next() != nullptr) DoTriggerVehicle(v->Next(), trigger, first ? new_random_bits : base_random_bits, false);
|
if (v->Next() != nullptr) DoTriggerVehicleRandomisation(v->Next(), trigger, first ? new_random_bits : base_random_bits, false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VEHICLE_TRIGGER_ANY_NEW_CARGO:
|
case VEHICLE_TRIGGER_ANY_NEW_CARGO:
|
||||||
/* Now pass the trigger recursively to the next vehicle
|
/* Now pass the trigger recursively to the next vehicle
|
||||||
* in chain. */
|
* in chain. */
|
||||||
assert(!first);
|
assert(!first);
|
||||||
if (v->Next() != nullptr) DoTriggerVehicle(v->Next(), VEHICLE_TRIGGER_ANY_NEW_CARGO, base_random_bits, false);
|
if (v->Next() != nullptr) DoTriggerVehicleRandomisation(v->Next(), VEHICLE_TRIGGER_ANY_NEW_CARGO, base_random_bits, false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VEHICLE_TRIGGER_CALLBACK_32:
|
case VEHICLE_TRIGGER_CALLBACK_32:
|
||||||
|
@ -1309,10 +1309,10 @@ static void DoTriggerVehicle(Vehicle *v, VehicleTrigger trigger, uint16_t base_r
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerVehicle(Vehicle *v, VehicleTrigger trigger)
|
void TriggerVehicleRandomisation(Vehicle *v, VehicleTrigger trigger)
|
||||||
{
|
{
|
||||||
v->InvalidateNewGRFCacheOfChain();
|
v->InvalidateNewGRFCacheOfChain();
|
||||||
DoTriggerVehicle(v, trigger, 0, true);
|
DoTriggerVehicleRandomisation(v, trigger, 0, true);
|
||||||
v->InvalidateNewGRFCacheOfChain();
|
v->InvalidateNewGRFCacheOfChain();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -118,7 +118,7 @@ enum VehicleTrigger : uint8_t {
|
||||||
/* Externally triggered for each vehicle in chain */
|
/* Externally triggered for each vehicle in chain */
|
||||||
VEHICLE_TRIGGER_CALLBACK_32 = 0x10,
|
VEHICLE_TRIGGER_CALLBACK_32 = 0x10,
|
||||||
};
|
};
|
||||||
void TriggerVehicle(Vehicle *veh, VehicleTrigger trigger);
|
void TriggerVehicleRandomisation(Vehicle *veh, VehicleTrigger trigger);
|
||||||
|
|
||||||
void AlterVehicleListOrder(EngineID engine, uint16_t target);
|
void AlterVehicleListOrder(EngineID engine, uint16_t target);
|
||||||
void CommitVehicleListOrderChanges();
|
void CommitVehicleListOrderChanges();
|
||||||
|
|
|
@ -591,8 +591,8 @@ bool NewHouseTileLoop(TileIndex tile)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
TriggerHouse(tile, HOUSE_TRIGGER_TILE_LOOP);
|
TriggerHouseRandomisation(tile, HOUSE_TRIGGER_TILE_LOOP);
|
||||||
if (hs->building_flags.Any(BUILDING_HAS_1_TILE)) TriggerHouse(tile, HOUSE_TRIGGER_TILE_LOOP_TOP);
|
if (hs->building_flags.Any(BUILDING_HAS_1_TILE)) TriggerHouseRandomisation(tile, HOUSE_TRIGGER_TILE_LOOP_TOP);
|
||||||
|
|
||||||
/* Call the unsynchronized tile loop trigger */
|
/* Call the unsynchronized tile loop trigger */
|
||||||
AnimationControl(tile, false, 0);
|
AnimationControl(tile, false, 0);
|
||||||
|
@ -620,7 +620,7 @@ bool NewHouseTileLoop(TileIndex tile)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DoTriggerHouse(TileIndex tile, HouseTrigger trigger, uint8_t base_random, bool first)
|
static void DoTriggerHouseRandomisation(TileIndex tile, HouseTrigger trigger, uint8_t base_random, bool first)
|
||||||
{
|
{
|
||||||
/* We can't trigger a non-existent building... */
|
/* We can't trigger a non-existent building... */
|
||||||
assert(IsTileType(tile, MP_HOUSE));
|
assert(IsTileType(tile, MP_HOUSE));
|
||||||
|
@ -660,16 +660,16 @@ static void DoTriggerHouse(TileIndex tile, HouseTrigger trigger, uint8_t base_ra
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* Random value of first tile already set. */
|
/* Random value of first tile already set. */
|
||||||
if (hs->building_flags.Any(BUILDING_2_TILES_Y)) DoTriggerHouse(TileAddXY(tile, 0, 1), trigger, random_bits, false);
|
if (hs->building_flags.Any(BUILDING_2_TILES_Y)) DoTriggerHouseRandomisation(TileAddXY(tile, 0, 1), trigger, random_bits, false);
|
||||||
if (hs->building_flags.Any(BUILDING_2_TILES_X)) DoTriggerHouse(TileAddXY(tile, 1, 0), trigger, random_bits, false);
|
if (hs->building_flags.Any(BUILDING_2_TILES_X)) DoTriggerHouseRandomisation(TileAddXY(tile, 1, 0), trigger, random_bits, false);
|
||||||
if (hs->building_flags.Any(BUILDING_HAS_4_TILES)) DoTriggerHouse(TileAddXY(tile, 1, 1), trigger, random_bits, false);
|
if (hs->building_flags.Any(BUILDING_HAS_4_TILES)) DoTriggerHouseRandomisation(TileAddXY(tile, 1, 1), trigger, random_bits, false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerHouse(TileIndex t, HouseTrigger trigger)
|
void TriggerHouseRandomisation(TileIndex t, HouseTrigger trigger)
|
||||||
{
|
{
|
||||||
DoTriggerHouse(t, trigger, 0, true);
|
DoTriggerHouseRandomisation(t, trigger, 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -118,6 +118,6 @@ enum HouseTrigger : uint8_t {
|
||||||
*/
|
*/
|
||||||
HOUSE_TRIGGER_TILE_LOOP_TOP = 0x02,
|
HOUSE_TRIGGER_TILE_LOOP_TOP = 0x02,
|
||||||
};
|
};
|
||||||
void TriggerHouse(TileIndex t, HouseTrigger trigger);
|
void TriggerHouseRandomisation(TileIndex t, HouseTrigger trigger);
|
||||||
|
|
||||||
#endif /* NEWGRF_HOUSE_H */
|
#endif /* NEWGRF_HOUSE_H */
|
||||||
|
|
|
@ -310,7 +310,7 @@ bool StartStopIndustryTileAnimation(const Industry *ind, IndustryAnimationTrigge
|
||||||
* @param ind Industry of the tile.
|
* @param ind Industry of the tile.
|
||||||
* @param[in,out] reseed_industry Collects bits to reseed for the industry.
|
* @param[in,out] reseed_industry Collects bits to reseed for the industry.
|
||||||
*/
|
*/
|
||||||
static void DoTriggerIndustryTile(TileIndex tile, IndustryTileTrigger trigger, Industry *ind, uint32_t &reseed_industry)
|
static void DoTriggerIndustryTileRandomisation(TileIndex tile, IndustryTileTrigger trigger, Industry *ind, uint32_t &reseed_industry)
|
||||||
{
|
{
|
||||||
assert(IsValidTile(tile) && IsTileType(tile, MP_INDUSTRY));
|
assert(IsValidTile(tile) && IsTileType(tile, MP_INDUSTRY));
|
||||||
|
|
||||||
|
@ -359,11 +359,11 @@ static void DoReseedIndustry(Industry *ind, uint32_t reseed)
|
||||||
* @param tile Industry tile to trigger.
|
* @param tile Industry tile to trigger.
|
||||||
* @param trigger Trigger to trigger.
|
* @param trigger Trigger to trigger.
|
||||||
*/
|
*/
|
||||||
void TriggerIndustryTile(TileIndex tile, IndustryTileTrigger trigger)
|
void TriggerIndustryTileRandomisation(TileIndex tile, IndustryTileTrigger trigger)
|
||||||
{
|
{
|
||||||
uint32_t reseed_industry = 0;
|
uint32_t reseed_industry = 0;
|
||||||
Industry *ind = Industry::GetByTile(tile);
|
Industry *ind = Industry::GetByTile(tile);
|
||||||
DoTriggerIndustryTile(tile, trigger, ind, reseed_industry);
|
DoTriggerIndustryTileRandomisation(tile, trigger, ind, reseed_industry);
|
||||||
DoReseedIndustry(ind, reseed_industry);
|
DoReseedIndustry(ind, reseed_industry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -372,12 +372,12 @@ void TriggerIndustryTile(TileIndex tile, IndustryTileTrigger trigger)
|
||||||
* @param ind Industry to trigger.
|
* @param ind Industry to trigger.
|
||||||
* @param trigger Trigger to trigger.
|
* @param trigger Trigger to trigger.
|
||||||
*/
|
*/
|
||||||
void TriggerIndustry(Industry *ind, IndustryTileTrigger trigger)
|
void TriggerIndustryRandomisation(Industry *ind, IndustryTileTrigger trigger)
|
||||||
{
|
{
|
||||||
uint32_t reseed_industry = 0;
|
uint32_t reseed_industry = 0;
|
||||||
for (TileIndex tile : ind->location) {
|
for (TileIndex tile : ind->location) {
|
||||||
if (ind->TileBelongsToIndustry(tile)) {
|
if (ind->TileBelongsToIndustry(tile)) {
|
||||||
DoTriggerIndustryTile(tile, trigger, ind, reseed_industry);
|
DoTriggerIndustryTileRandomisation(tile, trigger, ind, reseed_industry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DoReseedIndustry(ind, reseed_industry);
|
DoReseedIndustry(ind, reseed_industry);
|
||||||
|
|
|
@ -72,7 +72,7 @@ enum IndustryTileTrigger : uint8_t {
|
||||||
INDUSTRY_TRIGGER_INDUSTRY_TICK = 0x02, ///< The industry has been triggered via its tick.
|
INDUSTRY_TRIGGER_INDUSTRY_TICK = 0x02, ///< The industry has been triggered via its tick.
|
||||||
INDUSTRY_TRIGGER_RECEIVED_CARGO = 0x04, ///< Cargo has been delivered.
|
INDUSTRY_TRIGGER_RECEIVED_CARGO = 0x04, ///< Cargo has been delivered.
|
||||||
};
|
};
|
||||||
void TriggerIndustryTile(TileIndex t, IndustryTileTrigger trigger);
|
void TriggerIndustryTileRandomisation(TileIndex t, IndustryTileTrigger trigger);
|
||||||
void TriggerIndustry(Industry *ind, IndustryTileTrigger trigger);
|
void TriggerIndustryRandomisation(Industry *ind, IndustryTileTrigger trigger);
|
||||||
|
|
||||||
#endif /* NEWGRF_INDUSTRYTILES_H */
|
#endif /* NEWGRF_INDUSTRYTILES_H */
|
||||||
|
|
|
@ -972,7 +972,7 @@ static void RunEconomyVehicleDayProc()
|
||||||
uint16_t callback = GetVehicleCallback(CBID_VEHICLE_32DAY_CALLBACK, 0, 0, v->engine_type, v);
|
uint16_t callback = GetVehicleCallback(CBID_VEHICLE_32DAY_CALLBACK, 0, 0, v->engine_type, v);
|
||||||
if (callback != CALLBACK_FAILED) {
|
if (callback != CALLBACK_FAILED) {
|
||||||
if (HasBit(callback, 0)) {
|
if (HasBit(callback, 0)) {
|
||||||
TriggerVehicle(v, VEHICLE_TRIGGER_CALLBACK_32); // Trigger vehicle trigger 10
|
TriggerVehicleRandomisation(v, VEHICLE_TRIGGER_CALLBACK_32); // Trigger vehicle trigger 10
|
||||||
}
|
}
|
||||||
|
|
||||||
/* After a vehicle trigger, the graphics and properties of the vehicle could change.
|
/* After a vehicle trigger, the graphics and properties of the vehicle could change.
|
||||||
|
@ -1614,7 +1614,7 @@ void VehicleEnterDepot(Vehicle *v)
|
||||||
VehicleEnteredDepotThisTick(v);
|
VehicleEnteredDepotThisTick(v);
|
||||||
|
|
||||||
/* After a vehicle trigger, the graphics and properties of the vehicle could change. */
|
/* After a vehicle trigger, the graphics and properties of the vehicle could change. */
|
||||||
TriggerVehicle(v, VEHICLE_TRIGGER_DEPOT);
|
TriggerVehicleRandomisation(v, VEHICLE_TRIGGER_DEPOT);
|
||||||
v->MarkDirty();
|
v->MarkDirty();
|
||||||
|
|
||||||
InvalidateWindowData(WC_VEHICLE_VIEW, v->index);
|
InvalidateWindowData(WC_VEHICLE_VIEW, v->index);
|
||||||
|
|
Loading…
Reference in New Issue