Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support NewGRF cargoes with default vehicles #9148

Merged
merged 3 commits into from
May 13, 2021

Conversation

frosch123
Copy link
Member

@frosch123 frosch123 commented Apr 30, 2021

Motivation / Problem

When players use a NewGRF industry set with new cargoes, but no vehicle NewGRF, there are some effects:

  • Many cargoes cannot be transported.
  • Train wagons, road vehicles and ships transport unsuitable cargoes by default, especially if not refittable.

This causes a lot of confusion amongst many new players, and a lot of annoyance for one NewGRF author.

Description

The PR detects whether default vehicles are used, or whether default vehicles are only trivially modified by NewGRF (stuff like names, but not cargoes or refittability).

If this is the case:

  • The default cargo type of vehicles is translated according to the original cargo tables. So a livestock wagon will transport livestock, no matter which cargo slot is used for livestock.
  • If vehicles only transport default cargoes, which are removed/replaced by the industry NewGRF, the vehicle become unavailable.
  • Refittabilty is defined by cargo classes and explicit lists for the default cargoes, just like NewGRF vehicles would do.

As a result:

  • All cargoes are transportable via train/road/ship.
  • Some cargoes are transportable via aircraft.

When a NewGRF defines the default cargo type and/or refittability of a vehicle, this PR changes nothing.

Limitations

This PR changes the refittability of vehicles in vanilla, also when using only default vehicles and default industries/cargoes.

  • This will break people's workflows.
  • This affects savegames:
    • Vehicles in savegames keep their cargo type, even if no longer a refit option.
    • The cargo types for newly purchased vehicles change.
    • Refit orders and auto-renew breaks.

Detail rules

  • Aircraft are refittable to all passenger/mail/express/armoured cargoes, except liquids.
  • Passenger ferries and busses are refittable to all passenger-like cargoes (e.g. also tourists).
  • Oil tankers are refittable to all liquid cargoes, including water and rubber.
  • Freight ships are refittable to all cargoes, except passengers or liquid.
  • In toyland there is no oil tanker, so the toyland cargo ship transports also liquids.
  • Train MUs are refittable to all cargoes. This allows to use these fast engines with all wagons, and still have a single-cargo consist. If the engines would not be refittable to everythnig, this makes stations accept unwanted cargoes.
  • Coal/copper/sugar trucks/wagons are refittable to all bulk cargoes, unless there is a specialised default vehicle, so not iron ore, etc.
  • Iron ore and grain trucks/wagons keep their specialised role, they are not refittable.
  • Oil/cola trucks/wagons are refittable to all liquid cargoes, unless there is a specialised default vehicle, so not water, etc.
  • Goods/candy trucks/wagons are refittable to all piece/express cargoes, except liquids and tourists.
    If arctic/tropic refrigerated cargoes are also excluded, they use the food wagon.
    Again, this catches only cargoes without specialised vehicles.
  • Food trucks/wagons are refittable to all refrigerated cargoes, including liquids.
  • Armoured trucks/wagons are refittable to all armoured cargoes. In toyland the mail truck/wagon takes over this role.

Scenario: FIRS 4 'Basic Temperate'

  • Milk is transportable by both oil and food trucks/wagons.
  • Andy knows why Kaolin is both bulk and liquid.
  • Ships
    • Oil tanker: Alcohol (default), Chemicals, Kaolin, Milk
    • Cargo ship: All but Passengers, Alcohol, Chemicals, Kaolin, Milk
    • Toyland cargo ship: All but Passengers
  • Aircraft: Passengers, Mail, Engineering Supplies, Farm Supplies, Fish, Food, Fruit, Goods
  • Temperate trains/road vehicles:
    • Coal trucks/wagons: Coal (default), Kaolin, Sand, Scrap Metal
    • Goods trucks/wagons: Engineering Supplies, Farm Supplies, Fish, Food, Fruit, Goods (default)
    • Oil trucks/wagons: Alcohol (default), Chemicals, Kaolin, Milk
    • Livestock trucks/wagons: Livestock only
    • Iron Ore trucks/wagons: Iron Ore only
    • Steel trucks/wagons: Steel only
    • Other trucks/wagons not available: Grain, Wood, Armoured
  • Arctic trains/road vehicles:
    • Coal trucks/wagons: Coal (default), Iron Ore, Kaolin, Sand, Scrap Metal
    • Goods trucks/wagons: Engineering Supplies, Farm Supplies, Goods (default), Steel
    • Food trucks/wagons: Fish, Food, Fruit, Milk
    • Oil trucks/wagons: Alcohol (default), Chemicals, Kaolin, Milk
    • Livestock trucks/wagons: Livestock only
    • Other trucks/wagons not available: Oil, Grain, Wood, Armoured, Paper
  • Tropic trains/road vehicles:
    • Copper Ore trucks/wagons: Coal (default), Iron Ore, Kaolin, Sand, Scrap Metal
    • Goods trucks/wagons: Engineering Supplies, Farm Supplies, Goods (default), Livestock, Steel
    • Food trucks/wagons: Fish, Food, Milk
    • Oil trucks/wagons: Alcohol (default), Chemicals, Kaolin, Milk
    • Fruit trucks/wagons: Fruit only
    • Other trucks/wagons not available: Grain, Wood, Armoured, Rubber, Water
  • Toyland trains/road vehicles:
    • Sugar trucks/wagons: Coal (default), Iron Ore, Kaolin, Sand, Scrap Metal
    • Sweet trucks/wagons: Engineering Supplies, Farm Supplies, Fish, Food, Fruit, Goods (default), Livestock, Steel
    • Cola trucks/wagons: Alcohol (default), Chemicals, Kaolin, Milk
    • No other trucks/wagons available.

Scenario: Vanilla, default vehicles, default cargoes

Engine OpenTTD 0.1 OpenTTD 1.11 this PR
Manley-Morel DMU and similar Only Passengers All but Oil Everything
SH '125' Only Mail All but Oil Everything
Aircraft All but Mail, Oil, Rubber, Tropic Food Passengers, Mail, Food, Fruit, Goods, Valuables, Gold, Diamonds, All Toyland Stuff Passengers, Mail, Food, Fruit, Goods, Valuables, Gold, Diamonds, Sweets
Oil Tanker Oil Oil Oil, Rubber, Water
Cargo Ship All (including water) but Passenger, Oil, Rubber, Tropic Food All but Passenger, Oil All but Passenger, Oil, Rubber, Water

So, wrt. savegames this affects:

  • Aircraft in toyland transporting non-passengers.
  • Ships in tropic transporting water or rubber.

Checklist for review

Some things are not automated, and forgotten often. This list is a reminder for the reviewers.

  • The bug fix is important enough to be backported? (label: 'backport requested')
  • This PR affects the save game format? (label 'savegame upgrade')
  • This PR affects the GS/AI API? (label 'needs review: Script API')
    • ai_changelog.hpp, gs_changelog.hpp need updating.
    • The compatibility wrappers (compat_*.nut) need updating.
  • This PR affects the NewGRF API? (label 'needs review: NewGRF')

@frosch123
Copy link
Member Author

@2TallTyler Andy said, you also had plans for this?

@2TallTyler
Copy link
Member

No plans, just ideas. I was thinking in NML terms of how to allow cargo labels while disallowing other vanilla cargos of the same class, for example the coal hopper would carry CC_BULK but be disallowed from carrying IORE and GRAI. But your solution is better.

Possibly out of scope, but since your solution is aware of if NewGRF cargos are loaded, it might be possible to change vehicle names in the same manner as OpenGFX+ Trains — the coal hopper becomes the Bulk Wagon, for example. Then we'd truly have full support for NewGRF cargos with default vehicles.

@frosch123
Copy link
Member Author

I have changed the refittability of train MUs again:

  • With original vehicles, it's common to use fast engines also for cargo trains.
  • When the engine is not refittable, it keeps transporting passengers/mail, which then results in stations accepting these cargoes.

For ships I stick with changing the tropic oil tanker to transport water and rubber. This looks way cooler than the generic cargo ship.

Toyland planes lose out though.

@frosch123
Copy link
Member Author

Possibly out of scope, but since your solution is aware of if NewGRF cargos are loaded, it might be possible to change vehicle names in the same manner as OpenGFX+ Trains — the coal hopper becomes the Bulk Wagon, for example. Then we'd truly have full support for NewGRF cargos with default vehicles.

Yes, that is possible, and can be added later.
For now I consider adding and swapping extra texts for all those Uhl/DW/MPS trucks and rail/monorail/maglev coal trucks too annoying :)

@frosch123 frosch123 added backport requested This PR should be backport to current release (RC / stable) needs review: NewGRF Review requested from a NewGRF expert labels May 1, 2021
Copy link
Member

@TrueBrain TrueBrain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some code-style questions, but functional I see no issues. In fact, I can follow most of the logic :D Tnx for the detailed description, that really helps :)

src/cargotype.cpp Show resolved Hide resolved
src/newgrf.cpp Outdated Show resolved Hide resolved
src/newgrf.cpp Show resolved Hide resolved
src/newgrf.cpp Show resolved Hide resolved
@TrueBrain
Copy link
Member

PS: I think Change is underselling this. As far as I am concerned, this can be a Feature. And yes, one I would fully agree should be backported :) Just my opinion on the matter :)

Default vehicles now behave as if they had a cargo translation table. This fixes default vehicles carrying seemingly random cargos, if NewGRF industry sets are present.
This behavior is disabled, when a NewGRF touches any of the cargo-type or refitting properties. In that case it's up to the NewGRF to define its own cargo translation table.
This ensures that default vehicles can transport any NewGRF defined cargos, albeit with weird graphics and vehicle names.
This also changes the refittability of default vehicles with default industries.
@frosch123 frosch123 removed the backport requested This PR should be backport to current release (RC / stable) label May 13, 2021
@frosch123
Copy link
Member Author

I removed the "backport request" label. I think this change is on the same "for new players" level as the STUN/TURN stuff.
So I vote for an out-of-the-line 1.12.

@frosch123 frosch123 merged commit 1da0ba9 into OpenTTD:master May 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs review: NewGRF Review requested from a NewGRF expert
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants