Browse Source

- Fixed mantis #1248
- Fixed spellbook page save positions for hotseat mode

beegee1 12 years ago
parent
commit
86b7feeab3
1 changed files with 9 additions and 6 deletions
  1. 9 6
      client/CSpellWindow.cpp

+ 9 - 6
client/CSpellWindow.cpp

@@ -208,9 +208,12 @@ CSpellWindow::CSpellWindow(const SDL_Rect &, const CGHeroInstance * _myHero, CPl
 		}
 		}
 	}
 	}
 
 
-	selectedTab = battleSpellsOnly ? LOCPLINT->spellbookSettings.spellbookLastTabBattle : LOCPLINT->spellbookSettings.spellbookLastTabAdvmap;
-	currentPage = battleSpellsOnly ? LOCPLINT->spellbookSettings.spellbookLastPageBattle : LOCPLINT->spellbookSettings.spellbokLastPageAdvmap;
-	vstd::abetween(currentPage, 0, pagesWithinCurrentTab());
+	selectedTab = battleSpellsOnly ? myInt->spellbookSettings.spellbookLastTabBattle : myInt->spellbookSettings.spellbookLastTabAdvmap;
+	currentPage = battleSpellsOnly ? myInt->spellbookSettings.spellbookLastPageBattle : myInt->spellbookSettings.spellbokLastPageAdvmap;
+
+	// spellbook last page battle index is not reset after battle, so this needs to stay here
+	vstd::abetween(currentPage, 0, pagesWithinCurrentTab() - 1);
+
 	computeSpellsPerArea();
 	computeSpellsPerArea();
 	addUsedEvents(KEYBOARD);
 	addUsedEvents(KEYBOARD);
 }
 }
@@ -248,8 +251,8 @@ CSpellWindow::~CSpellWindow()
 
 
 void CSpellWindow::fexitb()
 void CSpellWindow::fexitb()
 {
 {
-	(LOCPLINT->battleInt ? LOCPLINT->spellbookSettings.spellbookLastTabBattle : LOCPLINT->spellbookSettings.spellbookLastTabAdvmap) = selectedTab;
-	(LOCPLINT->battleInt ? LOCPLINT->spellbookSettings.spellbookLastPageBattle : LOCPLINT->spellbookSettings.spellbokLastPageAdvmap) = currentPage;
+	(LOCPLINT->battleInt ? myInt->spellbookSettings.spellbookLastTabBattle : myInt->spellbookSettings.spellbookLastTabAdvmap) = selectedTab;
+	(LOCPLINT->battleInt ? myInt->spellbookSettings.spellbookLastPageBattle : myInt->spellbookSettings.spellbokLastPageAdvmap) = currentPage;
 
 
 	GH.popIntTotally(this);
 	GH.popIntTotally(this);
 }
 }
@@ -868,4 +871,4 @@ void CSpellWindow::SpellArea::setSpell(SpellID spellID)
 	const CSpell * spell = CGI->spellh->spells[mySpell];
 	const CSpell * spell = CGI->spellh->spells[mySpell];
 	schoolLevel = owner->myHero->getSpellSchoolLevel(spell, &whichSchool);
 	schoolLevel = owner->myHero->getSpellSchoolLevel(spell, &whichSchool);
 	spellCost = owner->myInt->cb->getSpellCost(spell, owner->myHero);
 	spellCost = owner->myInt->cb->getSpellCost(spell, owner->myHero);
-}
+}