ソースを参照

Merge pull request #4995 from IvanSavenko/local_state_fix

Fix serialization of selected spellbook page
Ivan Savenko 10 ヶ月 前
コミット
d4b2ec5b0b
1 ファイル変更8 行追加5 行削除
  1. 8 5
      client/PlayerLocalState.cpp

+ 8 - 5
client/PlayerLocalState.cpp

@@ -396,16 +396,19 @@ void PlayerLocalState::deserialize(const JsonNode & source)
 		}
 	}
 
-	spellbookSettings.spellbookLastPageBattle = source["spellbook"]["pageBattle"].Integer();
-	spellbookSettings.spellbookLastPageAdvmap = source["spellbook"]["pageAdvmap"].Integer();
-	spellbookSettings.spellbookLastTabBattle = source["spellbook"]["tabBattle"].Integer();
-	spellbookSettings.spellbookLastTabAdvmap = source["spellbook"]["tabAdvmap"].Integer();
+	if (!source["spellbook"].isNull())
+	{
+		spellbookSettings.spellbookLastPageBattle = source["spellbook"]["pageBattle"].Integer();
+		spellbookSettings.spellbookLastPageAdvmap = source["spellbook"]["pageAdvmap"].Integer();
+		spellbookSettings.spellbookLastTabBattle = source["spellbook"]["tabBattle"].Integer();
+		spellbookSettings.spellbookLastTabAdvmap = source["spellbook"]["tabAdvmap"].Integer();
+	}
 
 	// append any owned heroes / towns that were not present in loaded state
 	wanderingHeroes.insert(wanderingHeroes.end(), oldHeroes.begin(), oldHeroes.end());
 	ownedTowns.insert(ownedTowns.end(), oldTowns.begin(), oldTowns.end());
 
-//FIXME: broken, anything that is selected in here will be overwritten on NewTurn pack
+//FIXME: broken, anything that is selected in here will be overwritten on PlayerStartsTurn pack
 //	ObjectInstanceID selectedObjectID(source["currentSelection"].Integer());
 //	const CGObjectInstance * objectPtr = owner.cb->getObjInstance(selectedObjectID);
 //	const CArmedInstance * armyPtr = dynamic_cast<const CArmedInstance*>(objectPtr);