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

Some error messages (including reaching game action and town noise limits) are not mapped to the Script API. #7801

Closed
James103 opened this issue Oct 25, 2019 · 2 comments

Comments

@James103
Copy link
Contributor

James103 commented Oct 25, 2019

Version of OpenTTD

As of 20191023-master-g0d1575b5c7

Expected result

The following error messages should be mapped to the corresponding values (subject to change):

  • "Tree planting limit reached" -> ERR_LIMIT_REACHED
  • "Tile clearing limit reached" -> ERR_LIMIT_REACHED
  • "Landscaping limit reached" -> ERR_LIMIT_REACHED
  • "Tree already here" -> ERR_ALREADY_BUILT
  • "{TOWN} local authority refuses permission for airport due to noise concerns" -> (see comment)

Edit: update mappings from @glx22's commit.

When these error messages occur, the suggested action is to wait and retry, for example ScriptController.Sleep(10); ScriptTile.PlantTree(tile).

Actual result

The above error messages are not mapped.

Steps to reproduce

  1. Lower the values of tree_per_64k_frames and tree_frame_burst below their defaults.
  2. Increase "Construction speed" for AIs to "Very Fast".
  3. Start an AI with the following code in Start() (see below).
  4. Unpause and fast-forward the game.
  5. After a while, you will initially see streaks of no trees at all, and then on top of that, the average number of new trees per tile will start to drop from 4. When this happens, the AI will output a bunch of ERR_UNKNOWN to the log instead of for example ERR_LIMIT_REACHED or ERR_ALREADY_BUILT.
local trees = 0;
local tile = 0;
local passes = 0;
while (true) {
	for (tile = 0; tile < AIMap.GetMapSize(); tile++) {
		if (AITile.PlantTree(tile)) trees++;
		if (AITile.PlantTree(tile)) trees++;
		if (AITile.PlantTree(tile)) trees++;
		if (AITile.PlantTree(tile)) trees++;
		AILog.Info("Pass "+passes+", Tile "+tile+" ("+AIMap.GetTileX(tile)+", "+AIMap.GetTileY(tile)+") - Trees: "+trees+" / 20000000 - Error: "+AIError.GetLastErrorString());
	}
	passes++;
}
glx22 added a commit to glx22/OpenTTD that referenced this issue Oct 25, 2019
@glx22
Copy link
Contributor

glx22 commented Oct 25, 2019

Maybe something like that

@James103
Copy link
Contributor Author

James103 commented Dec 8, 2019

The error message "{TOWN} local authority refuses permission for airport due to noise concerns" appears to not be mapped. Found by testing with AI Chopper (v10) in OpenTTD master version 2019-12-07.

The correct error mapping should be either:
a) ERR_LOCAL_AUTHORITY_REFUSES,
b) ERR_STATION_TOO_MANY_STATIONS_IN_TOWN,
c) ERR_NOISE_LIMIT_REACHED (new), or
d) ERR_LIMIT_REACHED.

@James103 James103 changed the title Error messages for reaching landscaping/tree planting/tile clearing limits are not mapped to the Script API. Some error messages (including reaching game action and town noise limits) are not mapped to the Script API. Dec 8, 2019
glx22 added a commit to glx22/OpenTTD that referenced this issue Dec 8, 2019
@LordAro LordAro closed this as completed Dec 17, 2019
douiwby pushed a commit to douiwby/OpenTTD that referenced this issue Apr 16, 2020
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

No branches or pull requests

3 participants