FAForever / FAForever/fa

Details for bug when `AI_Instabuild` is enabled, factory-produced units/upgrading structures are invisible

Open
#6,695 0 comments 0 reactions 0 assignees View on GitHub
area: sim type: bug
Dominant language
Lua
Stars
264
Forks
260
Avg merge
3d 2h
Merged PRs (30d)
21

Description

## Problematic code for units produced from a factory:

FactoryUnit.BuildingState.Main:
https://github.com/FAForever/fa/blob/78dfcbca8f86571c37d236fe0829c33c940e6580/lua/sim/units/FactoryUnit.lua#L399-L403

https://github.com/FAForever/fa/blob/a08c68e0504390a726cdacd5e1cc94ae0183b626/lua/sim/units/FactoryUnit.lua#L418-L421

Bone hiding then revealing after a delay is done within the `Main` thread of a State. The thread is killed when the State is changed, so the instant completion of the unit instantly switches it to the `RollingOffState`, not letting the unit get unhidden.

## Problematic code for upgrading structures:

StructureUnit.UpgradingState.Main:
https://github.com/FAForever/fa/blob/c490f7c9e5427f9d8d2cae7ded9a5bcf68e7a76d/lua/sim/units/StructureUnit.lua#L979

StructureUnit.UpgradingState.OnStopBuild:
https://github.com/FAForever/fa/blob/c490f7c9e5427f9d8d2cae7ded9a5bcf68e7a76d/lua/sim/units/StructureUnit.lua#L1000

The default upgrade effect is to hide the upgrading unit until it is done. The logging shows that the bone is being revealed and then hidden, so I think since `Main` is a thread, it is running after `OnStopBuild`, which is usually fine but not with instant building enabled.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.