Solved a crash situation when clicking on "Future Tech" when it has already been researched

This commit is contained in:
Yair Morgenstern 2019-03-28 23:51:39 +02:00
parent 0b47289c3d
commit 064488ca37
5 changed files with 7 additions and 18 deletions

View File

@ -15,7 +15,6 @@ import kotlin.math.min
class GameParameters{
var difficulty="Prince"
var nation="Babylon"
var mapRadius=20
var numberOfHumanPlayers=1
var humanNations=ArrayList<String>().apply { add("Babylon") }

View File

@ -12,7 +12,7 @@ import com.unciv.ui.utils.getRandom
class GameInfo {
var civilizations = mutableListOf<CivilizationInfo>()
var difficulty="Chieftain" // difficulty is game-wide, think what would happen if 2 human players could play on diffferent difficulties?
var difficulty="Chieftain" // difficulty is game-wide, think what would happen if 2 human players could play on different difficulties?
var tileMap: TileMap = TileMap()
var gameParameters=GameParameters()
var turns = 0

View File

@ -73,7 +73,10 @@ class TechManager {
while (!checkPrerequisites.isEmpty()) {
val techNameToCheck = checkPrerequisites.pop()
if (isResearched(techNameToCheck) || prerequisites.contains(techNameToCheck))
// future tech can have been researched even when we're researching it,
// so...if we skip it we'll end up with 0 techs in the "required techs", which will mean that we don't have annything to research. Yeah.
if (techNameToCheck!="Future Tech" &&
(isResearched(techNameToCheck) || prerequisites.contains(techNameToCheck)) )
continue //no need to add or check prerequisites
val techToCheck = GameBasics.Technologies[techNameToCheck]
for (str in techToCheck!!.prerequisites)

View File

@ -9,7 +9,6 @@ import com.unciv.models.gamebasics.GameBasics
import com.unciv.models.gamebasics.tech.Technology
import com.unciv.models.gamebasics.tr
import com.unciv.ui.utils.*
import com.unciv.ui.worldscreen.optionstable.PopupTable
import java.util.*
import kotlin.collections.HashSet
@ -69,18 +68,7 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo) : PickerScreen()
val techButton = TechButton(tech.name,civTech)
techNameToButton[tech.name] = techButton
techButton.onClick {
try {
selectTechnology(tech)
}catch (ex:Exception){
val popup = PopupTable(this)
popup.addGoodSizedLabel("You've encountered an error that I've been trying to pin down for a while.").row()
popup.addGoodSizedLabel("If you could copy your game data (menu-save game-copy to clipboard - paste into an email to yairm210@hotmail.com)").row()
popup.addGoodSizedLabel("That would be really helpful to me, thanks!").row()
popup.addGoodSizedLabel("If you also add what tech you clicked on to get this error that would be even better!").row()
popup.open()
}
}
techButton.onClick { selectTechnology(tech) }
topTable.add(techButton)
}
}

View File

@ -4,7 +4,6 @@ import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
import com.badlogic.gdx.utils.Json
import com.unciv.UnCivGame
import com.unciv.logic.GameInfo
import com.unciv.logic.GameSaver
@ -69,7 +68,7 @@ class LoadScreen : PickerScreen() {
try{
val clipboardContentsString = Gdx.app.clipboard.contents.trim()
val decoded = Gzip.unzip(clipboardContentsString)
val loadedGame = Json().fromJson(GameInfo::class.java, decoded)
val loadedGame = GameSaver().json().fromJson(GameInfo::class.java, decoded)
loadedGame.setTransients()
UnCivGame.Current.loadGame(loadedGame)
}catch (ex:Exception){