yairm210/Unciv

Coders: deprecated getX helpers with forEachX replacements may break functionality if used blindly

Chiusa

#14.921 aperta il 24 mag 2026

 (0 commenti) (0 reazioni) (0 assegnatari)Kotlin (1903 fork)batch import
bughelp wanted

Metriche repository

Star
 (11.096 stelle)
Metriche merge PR
 (Merge medio 3g 6h) (80 PR mergiate in 30 g)

Descrizione

Game Version

5eecbdb

Describe the bug

@Ambeco - your newly introduced (#14724) forEach* functions have at last one pitfall. See Steps. I assume using the other overload would solve that, but haven't tested so far - it's still a pitfall because from the call site it looks entirely equivalent.

Steps to Reproduce

1: Replace: https://github.com/yairm210/Unciv/blob/93ac3d8ae984c53a52952e99e1a91b62cad14850/core/src/com/unciv/logic/city/managers/CityExpansionManager.kt#L133-L135 ...with:

        city.getCenterTile().forEachTileInDistance(1) { tile ->
            if (tile.getCity() == null)
                takeOwnership(tile)
        }

2: Run and found city 3: See it only owns its center tile - the first iteration somehow will abort the loop once it sees the first-checked tile is already owned...

Operating System

Linux

Additional Information

These ReplaceWith definitions are necessarily bad, since automatic application by the IDE will never result in working code. Can't be helped because the changes need to begin before the actual call. These things can be written with surprising intelligence to help that IDE auto-fix, but replacement will always begin with the function name and end with the closing ) of the parameter list. Can't change receiver or append lambdas.

Guida contributor