Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

[Bug]: GS has no autonomous way to remove industries #10390

Closed
andythenorth opened this issue Jan 22, 2023 · 0 comments
Closed

[Bug]: GS has no autonomous way to remove industries #10390

andythenorth opened this issue Jan 22, 2023 · 0 comments
Labels
component: AI/Game script (squirrel) This issue is related to Squirrel (Scripting language) enhancement Issue would be a good enhancement; we accept Pull Requests!

Comments

@andythenorth
Copy link
Contributor

andythenorth commented Jan 22, 2023

Version of OpenTTD

13-ish

Expected result

GS has one or more methods to remove an industry from the map, which are entirely within the control of the GS.

Actual result

There are multiple routes to remove industries, none are inherently reliable.

Use GSTile.DemolishTile()

See #10383 - this method can't remove industries currently, which is a bug. This issue might be resolve by resolving #10383.

DemolishTile() does work if the player has enabled magic bulldozer via the cheat menu. GS has no way to enable / disable cheats.

Side-channel signalling to grf industries

The GS can use GSIndustry.SetControlFlags() to signal intents to an industry. These can be interpreted by grf industries, and used to trigger the industry closure mechanism (via monthly industry callback 35).

Control flags are currently: enum | IndustryControlFlags {  INDCTL_NO_PRODUCTION_DECREASE,  INDCTL_NO_PRODUCTION_INCREASE,  INDCTL_NO_CL }

There is no appropriate flag for 'closure requested' or 'closure required'. However a GS and grf can collaborate to abuse one of the other flags.

We could add further flags.

Forced closure of an industry

This would be via monthly industry callback 35 (or the random equivalent). We delegated to grf the right to refuse closure, and I'm not proposing changing that.

Forced removal of all of a type from the map

This would primarily be of use when modifying the map at game start, but there might be other uses.

Assuming #10383 was resolved, industries could be removed by DemolishTile(). Mass removal could be done by creating a GSIndustryList() instance, and filtering for industry type, then valuating with the tile index for each industry instance. Then running a foreach loop and calling DemolishTile on each instance. This would consume a command for every instance, and commands are limited / expensive.

A method to mass-remove all of a type might be useful.

Steps to reproduce

I can provide a test GS, but it's not much use really except as evidence for the findings above.

If we have proposed solutions, I can write a GS to test them.

@2TallTyler 2TallTyler added component: AI/Game script (squirrel) This issue is related to Squirrel (Scripting language) enhancement Issue would be a good enhancement; we accept Pull Requests! labels Jan 22, 2023
@OpenTTD OpenTTD locked and limited conversation to collaborators Jan 7, 2024
@TrueBrain TrueBrain converted this issue into discussion #11705 Jan 7, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
component: AI/Game script (squirrel) This issue is related to Squirrel (Scripting language) enhancement Issue would be a good enhancement; we accept Pull Requests!
Projects
None yet
Development

No branches or pull requests

2 participants