From a82b8ffe7a4ddbcc423ceee60f32b52f8b857b8f Mon Sep 17 00:00:00 2001 From: Andrettin Date: Tue, 15 Dec 2015 23:58:13 +0100 Subject: [PATCH] Fixed a couple of saved game issues --- src/game/loadgame.cpp | 1 + src/unit/unit.cpp | 12 ++++++++---- src/unit/unit_save.cpp | 4 ++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/game/loadgame.cpp b/src/game/loadgame.cpp index 4e6a566e1..acfc5228c 100644 --- a/src/game/loadgame.cpp +++ b/src/game/loadgame.cpp @@ -227,6 +227,7 @@ void LoadGame(const std::string &filename) { //Wyrmgus start CleanPlayers(); //clean players, as they may not have been cleansed after a scenario + CurrentCustomHero = NULL; //otherwise the loaded game will have an extra hero for the current custom hero //Wyrmgus end // log will be enabled if found in the save game diff --git a/src/unit/unit.cpp b/src/unit/unit.cpp index ece7f79a5..3bfb921ae 100644 --- a/src/unit/unit.cpp +++ b/src/unit/unit.cpp @@ -921,12 +921,16 @@ void CUnit::EquipItem(CUnit &item, bool affect_character) Variable[HP_INDEX].Max += item.Variable[i].Max; Variable[HP_INDEX].Increase += item.Variable[i].Increase; } else if (i == SIGHTRANGE_INDEX) { - MapUnmarkUnitSight(*this); + if (!SaveGameLoading) { + MapUnmarkUnitSight(*this); + } Variable[i].Value += item.Variable[i].Value; Variable[i].Max += item.Variable[i].Max; - CurrentSightRange = Variable[i].Value; - UpdateUnitSightRange(*this); - MapMarkUnitSight(*this); + if (!SaveGameLoading) { + CurrentSightRange = Variable[i].Value; + UpdateUnitSightRange(*this); + MapMarkUnitSight(*this); + } } } } diff --git a/src/unit/unit_save.cpp b/src/unit/unit_save.cpp index 917b755be..650e6e638 100644 --- a/src/unit/unit_save.cpp +++ b/src/unit/unit_save.cpp @@ -360,9 +360,9 @@ void SaveUnit(const CUnit &unit, CFile &file) file.printf(",\n \"variation\", %d", unit.Variation); if (unit.Character != NULL) { if (!unit.Character->Custom) { - file.printf(",\n \"character\", %s", unit.Character->GetFullName().c_str()); + file.printf(",\n \"character\", \"%s\"", unit.Character->GetFullName().c_str()); } else { - file.printf(",\n \"custom-hero\", %s", unit.Character->GetFullName().c_str()); + file.printf(",\n \"custom-hero\", \"%s\"", unit.Character->GetFullName().c_str()); } } //Wyrmgus end