mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-18 19:59:47 +07:00
Retrieving the construction info in a different thread now works perfectly!
This commit is contained in:
@ -201,11 +201,14 @@ class CityConstructions {
|
|||||||
val cityStatsForConstruction: Stats
|
val cityStatsForConstruction: Stats
|
||||||
if (currentConstructionFromQueue == constructionName) cityStatsForConstruction = cityInfo.cityStats.currentCityStats
|
if (currentConstructionFromQueue == constructionName) cityStatsForConstruction = cityInfo.cityStats.currentCityStats
|
||||||
else {
|
else {
|
||||||
// The ol' Switcharoo - what would our stats be if that was our current construction?
|
/*
|
||||||
// Since this is only ever used for UI purposes, I feel fine with having it be a bit inefficient
|
The ol' Switcharoo - what would our stats be if that was our current construction?
|
||||||
// and recalculating the entire city stats
|
Since this is only ever used for UI purposes, I feel fine with having it be a bit inefficient
|
||||||
// We don't want to change our current construction queue - what if we have an empty queue, too many changes to check for -
|
and recalculating the entire city stats
|
||||||
// So we must clone it and see what would happen if that was our construction
|
We don't want to change our current construction queue - what if we have an empty queue,
|
||||||
|
this can affect the city if we run it on another thread like in ConstructionsTable -
|
||||||
|
So we run the numbers for the other construction
|
||||||
|
*/
|
||||||
|
|
||||||
val construction = cityInfo.cityConstructions.getConstruction(constructionName)
|
val construction = cityInfo.cityConstructions.getConstruction(constructionName)
|
||||||
cityInfo.cityStats.update(construction)
|
cityInfo.cityStats.update(construction)
|
||||||
|
@ -167,9 +167,9 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
|
|||||||
|
|
||||||
thread {
|
thread {
|
||||||
|
|
||||||
|
val constructionButtonDTOList = getConstructionButtonDTOs() // Since this can be a heavy operation and leads to many ANRs on older phones...
|
||||||
Gdx.app.postRunnable {
|
Gdx.app.postRunnable {
|
||||||
// For some bizarre reason, moving this to another thread messes up the entire construction list?! Haven't figured out why yet
|
// For some bizarre reason, moving this to another thread messes up the entire construction list?! Haven't figured out why yet
|
||||||
val constructionButtonDTOList = getConstructionButtonDTOs() // Since this can be a heavy operation and leads to many ANRs on older phones...
|
|
||||||
availableConstructionsTable.clear()
|
availableConstructionsTable.clear()
|
||||||
|
|
||||||
for (dto in constructionButtonDTOList) {
|
for (dto in constructionButtonDTOList) {
|
||||||
|
Reference in New Issue
Block a user