Retrieving the construction info in a different thread now works perfectly!

This commit is contained in:
Yair Morgenstern
2021-01-16 21:12:55 +02:00
parent 7e092fdf16
commit b27c744cd2
2 changed files with 9 additions and 6 deletions

View File

@ -201,11 +201,14 @@ class CityConstructions {
val cityStatsForConstruction: Stats
if (currentConstructionFromQueue == constructionName) cityStatsForConstruction = cityInfo.cityStats.currentCityStats
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
// and recalculating the entire city stats
// We don't want to change our current construction queue - what if we have an empty queue, too many changes to check for -
// So we must clone it and see what would happen if that was our construction
/*
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
and recalculating the entire city stats
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)
cityInfo.cityStats.update(construction)

View File

@ -167,9 +167,9 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
thread {
val constructionButtonDTOList = getConstructionButtonDTOs() // Since this can be a heavy operation and leads to many ANRs on older phones...
Gdx.app.postRunnable {
// 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()
for (dto in constructionButtonDTOList) {