Added instructions to deal with situations where the game has crashed but we've noticed it

This commit is contained in:
Yair Morgenstern
2018-08-10 11:35:56 +03:00
parent e51ac717d7
commit 3515b0f6bd
4 changed files with 28 additions and 4 deletions

View File

@ -258,6 +258,16 @@
]
]
GameCrashed: [
[
"Oh no! It looks like something went DISASTROUSLY wrong!",
"This is ABSOLUTELY not supposed to happen!",
"Please send me (yairm210@hotmail.com) an email with the game information",
" (menu -> save game -> copy game info -> paste into email)",
" and I'll try to fix it as fast as I can!"
]
]
}

View File

@ -8,6 +8,7 @@ class GameSettings {
var language: String = "English"
var resolution: String = "1050x700"
var tutorialsShown = ArrayList<String>()
var hasCrashedRecently = false
fun save(){
GameSaver().setGeneralSettings(this)

View File

@ -107,11 +107,12 @@ class UnitAutomation{
// The >0.1 (instead of >0) solves a bug where you've moved 2/3 road tiles,
// you come to move a third (distance is less that remaining movements),
// and then later we round it off to a whole.
// So the poor unit thought it could attack from the tile, but when it comes to do so it has no moveement points!
// So the poor unit thought it could attack from the tile, but when it comes to do so it has no movement points!
// Silly floats, basically
val tilesToAttackFrom = distanceToTiles.filter { unit.currentMovement - it.value > 0.1 }
.map { it.key }
.filter { unit.canMoveTo(it) || it==unit.getTile() }
for(reachableTile in tilesToAttackFrom){ // tiles we'll still have energy after we reach there
val tilesInAttackRange = if (unit.hasUnique("Indirect fire")) reachableTile.getTilesInDistance(rangeOfAttack)
else reachableTile.getViewableTiles(rangeOfAttack)

View File

@ -85,6 +85,13 @@ class WorldScreen : CameraStageBaseScreen() {
fun update() {
kotlin.concurrent.thread { civInfo.happiness = civInfo.getHappinessForNextTurn().values.sum().toInt() }
if(UnCivGame.Current.settings.hasCrashedRecently){
displayTutorials("GameCrashed")
UnCivGame.Current.settings.tutorialsShown.remove("GameCrashed")
UnCivGame.Current.settings.hasCrashedRecently=false
UnCivGame.Current.settings.save()
}
if (UnCivGame.Current.settings.tutorialsShown.contains("CityEntered")) {
displayTutorials("AfterCityEntered")
}
@ -169,8 +176,14 @@ class WorldScreen : CameraStageBaseScreen() {
nextTurnButton.setText("Working...".tr())
kotlin.concurrent.thread {
game.gameInfo.nextTurn()
GameSaver().saveGame(game.gameInfo, "Autosave")
try {
game.gameInfo.nextTurn()
GameSaver().saveGame(game.gameInfo, "Autosave")
}
catch (ex:Exception){
UnCivGame.Current.settings.hasCrashedRecently=true
UnCivGame.Current.settings.save()
}
// If we put this BEFORE the save game, then we try to save the game...
// but the main thread does other stuff, including showing tutorials which guess what? Changes the game data
@ -202,7 +215,6 @@ class WorldScreen : CameraStageBaseScreen() {
// otherwise images will not load properly!
update()
displayTutorials("NextTurn")
if("BarbarianEncountered" !in UnCivGame.Current.settings.tutorialsShown
&& civInfo.getViewableTiles().any { it.getUnits().any { unit -> unit.civInfo.isBarbarianCivilization() } })