Skip to content

Change: rearrange definitions of tree info to remove hardcoded values - #14

Open
PeterN wants to merge 48 commits into
masterfrom
working-tree
Open

Change: rearrange definitions of tree info to remove hardcoded values#14
PeterN wants to merge 48 commits into
masterfrom
working-tree

Conversation

@PeterN

@PeterN PeterN commented Apr 8, 2026

Copy link
Copy Markdown
Owner

Motivation / Problem

Trees are full of magic. Magic sprite numbers, magic climate-based value and magic tropic-zone values.

De-magic them.

Description

Rearrange definitions of tree info to remove hardcoded values
Tree availability is now defined with climates and tropical zone.

Limitations

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 touches english.txt or translations? Check the guidelines
  • This PR affects the GS/AI API? (label 'needs review: Script API')
    • ai_changelog.hpp, game_changelog.hpp need updating.
    • The compatibility wrappers (compat_*.nut) need updating.
  • This PR affects the NewGRF API? (label 'needs review: NewGRF')

Comment thread src/widget.cpp
@@ -1674,6 +1678,12 @@
child_wid->current_y = ComputeMaxSize(child_wid->smallest_y, given_height - child_wid->padding.Vertical(), vert_step);
}

for (const auto &child_wid : this->children) {
auto [pref_x, _] = child_wid->GetPreferredSizeForSize(child_wid->current_x, child_wid->current_y);
Comment thread src/widget.cpp
@@ -1848,6 +1858,12 @@
child_wid->current_x = ComputeMaxSize(child_wid->smallest_x, given_width - child_wid->padding.Horizontal(), hor_step);
}

for (const auto &child_wid : this->children) {
auto [_, pref_y] = child_wid->GetPreferredSizeForSize(child_wid->current_x, child_wid->current_y);
Comment thread src/newgrf/newgrf_act0_trees.cpp Fixed
Comment thread src/newgrf/newgrf_act0_trees.cpp Fixed
Comment thread src/newgrf_trees.cpp Outdated
Comment on lines +110 to +111
// assert(industry != nullptr && IsValidTile(tile));
// assert(industry->index == IndustryID::Invalid() || IsTileType(tile, TileType::Industry));
Comment thread src/newgrf_trees.h Outdated
uint16_t GetTreeTileCallback(CallbackID callback, uint32_t param1, uint32_t param2, TreeType treetype, TileIndex tile, std::span<int32_t> regs100 = {});
PalSpriteID GetCustomTreeSprite(TileIndex tile, TreeType treetype);
bool GetNewTreeList(const TileInfo *ti, TreeType treetype, uint trees, std::array<TreeListEnt, 4> &te);
// bool DrawNewTrees(const TileInfo *ti, TreeType treetype);
@@ -104,7 +104,7 @@
if (!ScriptEngine::IsBuildable(engine_id)) return -1;
if (!ScriptCargo::IsValidCargo(cargo)) return -1;

auto [res, veh_id, refit_capacity, refit_mail, cargo_capacities] = ::Command<Commands::BuildVehicle>::Do(DoCommandFlag::QueryCost, depot, engine_id, true, cargo, INVALID_CLIENT_ID);
auto [res, veh_id, refit_capacity, refit_mail, cargo_capacities] = ::Command<Commands::BuildVehicle>::Do(DoCommandFlag::QueryCost, depot, engine_id, true, cargo, ClientID::Invalid);
@@ -104,7 +104,7 @@
if (!ScriptEngine::IsBuildable(engine_id)) return -1;
if (!ScriptCargo::IsValidCargo(cargo)) return -1;

auto [res, veh_id, refit_capacity, refit_mail, cargo_capacities] = ::Command<Commands::BuildVehicle>::Do(DoCommandFlag::QueryCost, depot, engine_id, true, cargo, INVALID_CLIENT_ID);
auto [res, veh_id, refit_capacity, refit_mail, cargo_capacities] = ::Command<Commands::BuildVehicle>::Do(DoCommandFlag::QueryCost, depot, engine_id, true, cargo, ClientID::Invalid);
@@ -104,7 +104,7 @@
if (!ScriptEngine::IsBuildable(engine_id)) return -1;
if (!ScriptCargo::IsValidCargo(cargo)) return -1;

auto [res, veh_id, refit_capacity, refit_mail, cargo_capacities] = ::Command<Commands::BuildVehicle>::Do(DoCommandFlag::QueryCost, depot, engine_id, true, cargo, INVALID_CLIENT_ID);
auto [res, veh_id, refit_capacity, refit_mail, cargo_capacities] = ::Command<Commands::BuildVehicle>::Do(DoCommandFlag::QueryCost, depot, engine_id, true, cargo, ClientID::Invalid);
Comment thread src/newgrf/newgrf_act0_trees.cpp Outdated
if (treespec == nullptr) {
treespec = std::make_unique<TreeTileInfo>(GetOriginalTreeTileInfo()[subs_id]);

// treespec->enabled = true;
Comment thread src/newgrf/newgrf_act0_trees.cpp Outdated
Comment on lines +60 to +61
// treespec->anim_production = INDUSTRYTILE_NOANIM;
// treespec->anim_next = INDUSTRYTILE_NOANIM;
@PeterN
PeterN force-pushed the working-tree branch 3 times, most recently from 3fd1f5b to 31caaad Compare July 28, 2026 22:58
rubidium42 and others added 21 commits July 29, 2026 10:39
chinese (traditional): 1 change by KogentaSan
chinese (simplified): 154 changes by wensimehrp
catalan: 1 change by J0anJosep
chinese (simplified): 98 changes by wensimehrp
korean: 1 change by telk5093
afrikaans: 2 changes by chuckarrow
Allows getting a random value with less visible casting.
chinese (simplified): 160 changes by wensimehrp
turkish: 6 changes by efemert124570
Bumps the actions group with 2 updates: [github/codeql-action](https://github.com/github/codeql-action) and [microsoft/microsoft-store-apppublisher](https://github.com/microsoft/microsoft-store-apppublisher).


Updates `github/codeql-action` from 4 to 4.37.3
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](github/codeql-action@v4...v4.37.3)

Updates `microsoft/microsoft-store-apppublisher` from 1.3 to 1.4
- [Release notes](https://github.com/microsoft/microsoft-store-apppublisher/releases)
- [Commits](microsoft/microsoft-store-apppublisher@v1.3...v1.4)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 4.37.3
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: actions
- dependency-name: microsoft/microsoft-store-apppublisher
  dependency-version: '1.4'
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
chinese (simplified): 1 change by wensimehrp
norwegian (bokmal): 31 changes by eriksorngard
indonesian: 23 changes by q1t0
…in is driving backwards (OpenTTD#15485)

Co-authored-by: Tyler Trahan <tyler@tylertrahan.com>
This adds a simplistic "Screensaver Mode" under the about menu
which randomly picks between all vehicles on the map to follow, with a
bias towards moving vehicles.
swedish: 1 change by joeax910
If not present the existing but bad quality linear conversion can still be used.
… regression

Uses AIAccounting instead of AICompany::GetBankBalance.
PeterN and others added 5 commits August 7, 2026 07:40
indonesian: 72 changes by q1t0
norwegian (bokmal): 10 changes by eriksorngard
indonesian: 275 changes by q1t0
maori (new zealand): 25 changes by Kyle-McDangersword
esperanto: 20 changes by slashdevslashurandom
polish: 1 change by pAter-exe
@PeterN
PeterN force-pushed the working-tree branch 2 times, most recently from 77f7401 to bccf688 Compare August 11, 2026 07:25
translators and others added 18 commits August 12, 2026 06:01
swedish: 36 changes by Brickblock1
…ting (OpenTTD#15907)

Remove code that doubles the shown capacity of dual-headed engines when sorting the purchase list, as the given capacity is already doubled
chinese (traditional): 4 changes by KogentaSan
czech: 486 changes by adamek0202
…d save (OpenTTD#14481)

Previous to this change, railways got automatically converted to
electric railway if there was any electric locomotive, as electric
railways could not be disabled until version 38
The industry tile limit was set based on the premise that action 3 ids might later be extended. They have since been extended.

Limit is now the total number of industry tiles that can be used.
belarusian: 34 changes by GooseOb
Tree availability is now defined by climates, tropiczones and probabilities

Tree placer GUI is modified to list currently active tree tile types.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.