Browse Source

* third part of spellBook
* probably finished counterattacking

mateuszb 17 years ago
parent
commit
ae6e260107
8 changed files with 400 additions and 78 deletions
  1. 198 73
      CBattleInterface.cpp
  2. 1 0
      CBattleInterface.h
  3. 17 0
      CHeroWindow.cpp
  4. 2 2
      SDL_Extensions.cpp
  5. 159 3
      client/CSpellWindow.cpp
  6. 10 0
      client/CSpellWindow.h
  7. 12 0
      hch/CSpellHandler.cpp
  8. 1 0
      hch/CSpellHandler.h

+ 198 - 73
CBattleInterface.cpp

@@ -13,6 +13,7 @@
 #include "hch/CGeneralTextHandler.h"
 #include "client/CCreatureAnimation.h"
 #include "client/Graphics.h"
+#include "client/CSpellWindow.h"
 #include <queue>
 #include <sstream>
 #include "lib/CondSh.h"
@@ -495,6 +496,17 @@ void CBattleInterface::bAutofightf()
 
 void CBattleInterface::bSpellf()
 {
+	CGI->curh->changeGraphic(0,0);
+	LOCPLINT->curint->deactivate();
+
+	const CGHeroInstance * chi = NULL;
+	if(attackingHeroInstance->tempOwner == LOCPLINT->playerID)
+		chi = attackingHeroInstance;
+	else
+		chi = defendingHeroInstance;
+	CSpellWindow * spellWindow = new CSpellWindow(genRect(595, 620, 90, 2), chi);
+	spellWindow->activate();
+	LOCPLINT->objsToBlit.push_back(spellWindow);
 }
 
 void CBattleInterface::bWaitf()
@@ -700,9 +712,11 @@ void CBattleInterface::stackMoved(int number, int destHex, bool startMoving, boo
 
 void CBattleInterface::stackIsAttacked(int ID, int dmg, int killed, int IDby, bool byShooting)
 {
-	if(creAnims[ID]->getType() != 2)
+	while(creAnims[ID]->getType() != 2 || (attackingInfo && attackingInfo->IDby == IDby))
 	{
-		return; //something went wrong
+		show();
+		CSDL_Ext::update();
+		SDL_framerateDelay(LOCPLINT->mainFPSmng);
 	}
 	if(byShooting) //delay hit animation
 	{
@@ -744,51 +758,105 @@ void CBattleInterface::stackIsAttacked(int ID, int dmg, int killed, int IDby, bo
 
 void CBattleInterface::stackAttacking(int ID, int dest)
 {
-	if(attackingInfo != NULL)
+	while(attackingInfo != NULL)
 	{
-		return; //something went wrong
+		show();
+		CSDL_Ext::update();
+		SDL_framerateDelay(LOCPLINT->mainFPSmng);
 	}
 	CStack aStack = *LOCPLINT->cb->battleGetStackByID(ID); //attacking stack
-	if(aStack.creature->isDoubleWide())
+	if(aStack.attackerOwned)
 	{
-		switch(BattleInfo::mutualPosition(aStack.position, dest)) //attack direction
+		if(aStack.creature->isDoubleWide())
 		{
-			case 0:
-				//reverseCreature(ID, aStack.position, true);
-				break;
-			case 1:
-				break;
-			case 2:
-				break;
-			case 3:
-				break;
-			case 4:
-				//reverseCreature(ID, aStack.position, true);
-				break;
-			case 5:
-				reverseCreature(ID, aStack.position, true);
-				break;
+			switch(BattleInfo::mutualPosition(aStack.position, dest)) //attack direction
+			{
+				case 0:
+					//reverseCreature(ID, aStack.position, true);
+					break;
+				case 1:
+					break;
+				case 2:
+					break;
+				case 3:
+					break;
+				case 4:
+					//reverseCreature(ID, aStack.position, true);
+					break;
+				case 5:
+					reverseCreature(ID, aStack.position, true);
+					break;
+			}
+		}
+		else //else for if(aStack.creature->isDoubleWide())
+		{
+			switch(BattleInfo::mutualPosition(aStack.position, dest)) //attack direction
+			{
+				case 0:
+					reverseCreature(ID, aStack.position, true);
+					break;
+				case 1:
+					break;
+				case 2:
+					break;
+				case 3:
+					break;
+				case 4:
+					reverseCreature(ID, aStack.position, true);
+					break;
+				case 5:
+					reverseCreature(ID, aStack.position, true);
+					break;
+			}
 		}
 	}
-	else //else for if(aStack.creature->isDoubleWide())
+	else //if(aStack.attackerOwned)
 	{
-		switch(BattleInfo::mutualPosition(aStack.position, dest)) //attack direction
+		if(aStack.creature->isDoubleWide())
 		{
-			case 0:
-				reverseCreature(ID, aStack.position, true);
-				break;
-			case 1:
-				break;
-			case 2:
-				break;
-			case 3:
-				break;
-			case 4:
-				reverseCreature(ID, aStack.position, true);
-				break;
-			case 5:
-				reverseCreature(ID, aStack.position, true);
-				break;
+			switch(BattleInfo::mutualPosition(aStack.position, dest)) //attack direction
+			{
+				case 0:
+					//reverseCreature(ID, aStack.position, true);
+					break;
+				case 1:
+					break;
+				case 2:
+					reverseCreature(ID, aStack.position, true);
+					break;
+				case 3:
+					break;
+				case 4:
+					//reverseCreature(ID, aStack.position, true);
+					break;
+				case 5:
+					//reverseCreature(ID, aStack.position, true);
+					break;
+			}
+		}
+		else //else for if(aStack.creature->isDoubleWide())
+		{
+			switch(BattleInfo::mutualPosition(aStack.position, dest)) //attack direction
+			{
+				case 0:
+					//reverseCreature(ID, aStack.position, true);
+					break;
+				case 1:
+					reverseCreature(ID, aStack.position, true);
+					break;
+				case 2:
+					reverseCreature(ID, aStack.position, true);
+					break;
+				case 3:
+					reverseCreature(ID, aStack.position, true);
+					break;
+				case 4:
+					//reverseCreature(ID, aStack.position, true);
+					break;
+				case 5:
+					//reverseCreature(ID, aStack.position, true);
+					break;
+			}
 		}
 	}
 
@@ -796,6 +864,7 @@ void CBattleInterface::stackAttacking(int ID, int dest)
 	attackingInfo->dest = dest;
 	attackingInfo->frame = 0;
 	attackingInfo->ID = ID;
+	attackingInfo->IDby = LOCPLINT->cb->battleGetStackByPos(dest)->ID;
 	attackingInfo->reversing = false;
 	attackingInfo->shooting = false;
 
@@ -1031,47 +1100,103 @@ void CBattleInterface::attackingShowHelper()
 		else if(attackingInfo->frame == (attackingInfo->maxframe - 1))
 		{
 			attackingInfo->reversing = true;
-			CStack aStack = *LOCPLINT->cb->battleGetStackByID(attackingInfo->ID); //attacking stack
-			if(aStack.creature->isDoubleWide())
+
+			CStack* aStackp = LOCPLINT->cb->battleGetStackByID(attackingInfo->ID); //attacking stack
+			if(aStackp == NULL)
+				return;
+			CStack aStack = *aStackp;
+			if(aStack.attackerOwned)
 			{
-				switch(BattleInfo::mutualPosition(aStack.position, attackingInfo->dest)) //attack direction
+				if(aStack.creature->isDoubleWide())
 				{
-					case 0:
-						//reverseCreature(ID, aStack.position, true);
-						break;
-					case 1:
-						break;
-					case 2:
-						break;
-					case 3:
-						break;
-					case 4:
-						//reverseCreature(ID, aStack.position, true);
-						break;
-					case 5:
-						reverseCreature(attackingInfo->ID, aStack.position, true);
-						break;
+					switch(BattleInfo::mutualPosition(aStack.position, attackingInfo->dest)) //attack direction
+					{
+						case 0:
+							//reverseCreature(ID, aStack.position, true);
+							break;
+						case 1:
+							break;
+						case 2:
+							break;
+						case 3:
+							break;
+						case 4:
+							//reverseCreature(ID, aStack.position, true);
+							break;
+						case 5:
+							reverseCreature(attackingInfo->ID, aStack.position, true);
+							break;
+					}
+				}
+				else //else for if(aStack.creature->isDoubleWide())
+				{
+					switch(BattleInfo::mutualPosition(aStack.position, attackingInfo->dest)) //attack direction
+					{
+						case 0:
+							reverseCreature(attackingInfo->ID, aStack.position, true);
+							break;
+						case 1:
+							break;
+						case 2:
+							break;
+						case 3:
+							break;
+						case 4:
+							reverseCreature(attackingInfo->ID, aStack.position, true);
+							break;
+						case 5:
+							reverseCreature(attackingInfo->ID, aStack.position, true);
+							break;
+					}
 				}
 			}
-			else //else for if(aStack.creature->isDoubleWide())
+			else //if(aStack.attackerOwned)
 			{
-				switch(BattleInfo::mutualPosition(aStack.position, attackingInfo->dest)) //attack direction
+				if(aStack.creature->isDoubleWide())
 				{
-					case 0:
-						reverseCreature(attackingInfo->ID, aStack.position, true);
-						break;
-					case 1:
-						break;
-					case 2:
-						break;
-					case 3:
-						break;
-					case 4:
-						reverseCreature(attackingInfo->ID, aStack.position, true);
-						break;
-					case 5:
-						reverseCreature(attackingInfo->ID, aStack.position, true);
-						break;
+					switch(BattleInfo::mutualPosition(aStack.position, attackingInfo->dest)) //attack direction
+					{
+						case 0:
+							//reverseCreature(ID, aStack.position, true);
+							break;
+						case 1:
+							break;
+						case 2:
+							reverseCreature(attackingInfo->ID, aStack.position, true);
+							break;
+						case 3:
+							break;
+						case 4:
+							//reverseCreature(ID, aStack.position, true);
+							break;
+						case 5:
+							//reverseCreature(ID, aStack.position, true);
+							break;
+					}
+				}
+				else //else for if(aStack.creature->isDoubleWide())
+				{
+					switch(BattleInfo::mutualPosition(aStack.position, attackingInfo->dest)) //attack direction
+					{
+						case 0:
+							//reverseCreature(ID, aStack.position, true);
+							break;
+						case 1:
+							reverseCreature(attackingInfo->ID, aStack.position, true);
+							break;
+						case 2:
+							reverseCreature(attackingInfo->ID, aStack.position, true);
+							break;
+						case 3:
+							reverseCreature(attackingInfo->ID, aStack.position, true);
+							break;
+						case 4:
+							//reverseCreature(ID, aStack.position, true);
+							break;
+						case 5:
+							//reverseCreature(ID, aStack.position, true);
+							break;
+					}
 				}
 			}
 			attackingInfo->reversing = false;

+ 1 - 0
CBattleInterface.h

@@ -108,6 +108,7 @@ private:
 	{
 	public:
 		int ID; //attacking stack
+		int IDby; //attacked stack
 		int dest; //atacked hex
 		int frame, maxframe; //frame of animation, number of frames of animation
 		bool reversing;

+ 17 - 0
CHeroWindow.cpp

@@ -10,6 +10,7 @@
 #include "SDL_Extensions.h"
 #include "client/CBitmapHandler.h"
 #include "client/Graphics.h"
+#include "client/CSpellWindow.h"
 #include "global.h"
 #include "hch/CAbilityHandler.h"
 #include "hch/CArtHandler.h"
@@ -674,8 +675,22 @@ void CArtPlace::activate()
 void CArtPlace::clickLeft(boost::logic::tribool down)
 {
 	//LRClickableAreaWTextComp::clickLeft(down);
+	
+	if(ourArt && !down) //we are spellbook
+	{
+		if(ourArt->id == 0)
+		{
+			ourWindow->deactivate();
+
+			CSpellWindow * spellWindow = new CSpellWindow(genRect(595, 620, 90, 2), ourWindow->curHero);
+			spellWindow->activate();
+			LOCPLINT->objsToBlit.push_back(spellWindow);
+		}
+	}
 	if(!down && !clicked) //not clicked before
 	{
+		if(ourArt && ourArt->id == 0)
+			return; //this is handled separately
 		if(!ourWindow->activeArtPlace) //nothing has benn clicked
 		{
 			if(ourArt) //to prevent selecting empty slots (bugfix to what GrayFace reported)
@@ -730,6 +745,8 @@ void CArtPlace::clickLeft(boost::logic::tribool down)
 	}
 	else if(!down && clicked)
 	{
+		if(ourArt && ourArt->id == 0)
+			return; //this is handled separately
 		clicked = false;
 		ourWindow->activeArtPlace = NULL;
 	}

+ 2 - 2
SDL_Extensions.cpp

@@ -141,7 +141,7 @@ void CSDL_Ext::printAtMiddle(std::string text, int x, int y, TTF_Font * font, SD
 		break;
 	}
 	SDL_BlitSurface(temp,NULL,dst,&genRect(temp->h,temp->w,x-(temp->w/2),y-(temp->h/2)));
-	SDL_UpdateRect(dst,x-(temp->w/2),y-(temp->h/2),temp->w,temp->h);
+	//SDL_UpdateRect(dst,x-(temp->w/2),y-(temp->h/2),temp->w,temp->h);
 	SDL_FreeSurface(temp);
 }
 void CSDL_Ext::printAt(std::string text, int x, int y, TTF_Font * font, SDL_Color kolor, SDL_Surface * dst, unsigned char quality)
@@ -199,7 +199,7 @@ void CSDL_Ext::printTo(std::string text, int x, int y, TTF_Font * font, SDL_Colo
 		break;
 	}
 	SDL_BlitSurface(temp,NULL,dst,&genRect(temp->h,temp->w,x-temp->w,y-temp->h));
-	SDL_UpdateRect(dst,x-temp->w,y-temp->h,temp->w,temp->h);
+	//SDL_UpdateRect(dst,x-temp->w,y-temp->h,temp->w,temp->h);
 	SDL_FreeSurface(temp);
 }
 

+ 159 - 3
client/CSpellWindow.cpp

@@ -2,6 +2,7 @@
 #include "Graphics.h"
 #include "../hch/CDefHandler.h"
 #include "../hch/CObjectHandler.h"
+#include "../hch/CSpellHandler.h"
 #include "../hch/CPreGameTextHandler.h"
 #include "../CAdvmapInterface.h"
 #include "../CGameInfo.h"
@@ -53,6 +54,7 @@ void SpellbookInteractiveArea::activate()
 	ClickableL::activate();
 	ClickableR::activate();
 	Hoverable::activate();
+
 }
 void SpellbookInteractiveArea::deactivate()
 {
@@ -61,8 +63,115 @@ void SpellbookInteractiveArea::deactivate()
 	Hoverable::deactivate();
 }
 
-CSpellWindow::CSpellWindow(const SDL_Rect & myRect, const CGHeroInstance * myHero): selectedTab(4)
+CSpellWindow::CSpellWindow(const SDL_Rect & myRect, const CGHeroInstance * myHero): selectedTab(4), spellSite(0), battleSpellsOnly(true)
 {
+	//for testing only
+	for(ui32 v=0; v<CGI->spellh->spells.size(); ++v)
+	{
+		((CGHeroInstance*)(myHero))->spells.insert(v);
+	}
+
+	//initializing sizes of spellbook's parts
+	for(int b=0; b<5; ++b)
+		sitesPerTabAdv[b] = 0;
+	for(int b=0; b<5; ++b)
+		sitesPerTabBattle[b] = 0;
+	for(std::set<ui32>::const_iterator g = myHero->spells.begin(); g!=myHero->spells.end(); ++g)
+	{
+		if(CGI->spellh->spells[*g].creatureAbility)
+			continue; //currently we don't want tu put here creature abilities
+		if(CGI->spellh->spells[*g].air)
+		{
+			if(CGI->spellh->spells[*g].combatSpell)
+			{
+				++(sitesPerTabBattle[0]);
+				++(sitesPerTabBattle[4]);
+			}
+			else
+			{
+				++(sitesPerTabAdv[0]);
+				++(sitesPerTabAdv[4]);
+			}
+		}
+		if(CGI->spellh->spells[*g].fire)
+		{
+			if(CGI->spellh->spells[*g].combatSpell)
+			{
+				++(sitesPerTabBattle[1]);
+				++(sitesPerTabBattle[4]);
+			}
+			else
+			{
+				++(sitesPerTabAdv[1]);
+				++(sitesPerTabAdv[4]);
+			}
+		}
+		if(CGI->spellh->spells[*g].water)
+		{
+			if(CGI->spellh->spells[*g].combatSpell)
+			{
+				++(sitesPerTabBattle[2]);
+				++(sitesPerTabBattle[4]);
+			}
+			else
+			{
+				++(sitesPerTabAdv[2]);
+				++(sitesPerTabAdv[4]);
+			}
+		}
+		if(CGI->spellh->spells[*g].earth)
+		{
+			if(CGI->spellh->spells[*g].combatSpell)
+			{
+				++(sitesPerTabBattle[3]);
+				++(sitesPerTabBattle[4]);
+			}
+			else
+			{
+				++(sitesPerTabAdv[3]);
+				++(sitesPerTabAdv[4]);
+			}
+		}
+	}
+	if(sitesPerTabAdv[4] % 12 == 0)
+		sitesPerTabAdv[4]/=12;
+	else
+		sitesPerTabAdv[4] = sitesPerTabAdv[4]/12 + 1;
+
+	for(int v=0; v<4; ++v)
+	{
+		if(sitesPerTabAdv[v] <= 10)
+			sitesPerTabAdv[v] = 1;
+		else
+		{
+			if((sitesPerTabAdv[v] - 10) % 12 == 0)
+				sitesPerTabAdv[v] = (sitesPerTabAdv[v] - 10) / 12 + 1;
+			else
+				sitesPerTabAdv[v] = (sitesPerTabAdv[v] - 10) / 12 + 2;
+		}
+	}
+	
+	if(sitesPerTabBattle[4] % 12 == 0)
+		sitesPerTabBattle[4]/=12;
+	else
+		sitesPerTabBattle[4] = sitesPerTabBattle[4]/12 + 1;
+
+	for(int v=0; v<4; ++v)
+	{
+		if(sitesPerTabBattle[v] <= 10)
+			sitesPerTabBattle[v] = 1;
+		else
+		{
+			if((sitesPerTabBattle[v] - 10) % 12 == 0)
+				sitesPerTabBattle[v] = (sitesPerTabBattle[v] - 10) / 12 + 1;
+			else
+				sitesPerTabBattle[v] = (sitesPerTabBattle[v] - 10) / 12 + 2;
+		}
+	}
+
+
+	//numbers of spell pages computed
+
 	pos = myRect;
 	background = BitmapHandler::loadBitmap("SpelBack.bmp");
 	graphics->blueToPlayersAdv(background, myHero->tempOwner);
@@ -71,8 +180,8 @@ CSpellWindow::CSpellWindow(const SDL_Rect & myRect, const CGHeroInstance * myHer
 	mana<<myHero->mana;
 	CSDL_Ext::printAtMiddle(mana.str(), 434, 425, GEOR16, tytulowy, background);
 
-	leftCorner = BitmapHandler::loadBitmap("SpelTrnL.bmp");
-	rightCorner = BitmapHandler::loadBitmap("SpelTrnL.bmp");
+	leftCorner = BitmapHandler::loadBitmap("SpelTrnL.bmp", true);
+	rightCorner = BitmapHandler::loadBitmap("SpelTrnR.bmp", true);
 	spells = CDefHandler::giveDef("Spells.def");
 	spellTab = CDefHandler::giveDef("SpelTab.def");
 	schools = CDefHandler::giveDef("Schools.def");
@@ -103,6 +212,11 @@ CSpellWindow::CSpellWindow(const SDL_Rect & myRect, const CGHeroInstance * myHer
 	selectSpellsW = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::fspellsWb, this), CGI->preth->zelp[456].second, boost::bind(&CStatusBar::print, statusBar, (CGI->preth->zelp[456].first)), boost::bind(&CStatusBar::clear, statusBar));
 	temp_rect = genRect(36, 56, 639, 332);
 	selectSpellsAll = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::fspellsAllb, this), CGI->preth->zelp[458].second, boost::bind(&CStatusBar::print, statusBar, (CGI->preth->zelp[458].first)), boost::bind(&CStatusBar::clear, statusBar));
+
+	temp_rect = genRect(leftCorner->h, leftCorner->w, 187, 79);
+	lCorner = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::fLcornerb, this), CGI->preth->zelp[450].second, boost::bind(&CStatusBar::print, statusBar, (CGI->preth->zelp[450].first)), boost::bind(&CStatusBar::clear, statusBar));
+	temp_rect = genRect(rightCorner->h, rightCorner->w, 577, 76);
+	rCorner = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::fRcornerb, this), CGI->preth->zelp[451].second, boost::bind(&CStatusBar::print, statusBar, (CGI->preth->zelp[451].first)), boost::bind(&CStatusBar::clear, statusBar));
 }
 
 CSpellWindow::~CSpellWindow()
@@ -129,6 +243,9 @@ CSpellWindow::~CSpellWindow()
 	delete selectSpellsF;
 	delete selectSpellsW;
 	delete selectSpellsAll;
+
+	delete lCorner;
+	delete rCorner;
 }
 
 void CSpellWindow::fexitb()
@@ -150,10 +267,12 @@ void CSpellWindow::fexitb()
 
 void CSpellWindow::fadvSpellsb()
 {
+	battleSpellsOnly = false;
 }
 
 void CSpellWindow::fbattleSpellsb()
 {
+	battleSpellsOnly = true;
 }
 
 void CSpellWindow::fmanaPtsb()
@@ -163,26 +282,43 @@ void CSpellWindow::fmanaPtsb()
 void CSpellWindow::fspellsAb()
 {
 	selectedTab = 0;
+	spellSite = 0;
 }
 
 void CSpellWindow::fspellsEb()
 {
 	selectedTab = 3;
+	spellSite = 0;
 }
 
 void CSpellWindow::fspellsFb()
 {
 	selectedTab = 1;
+	spellSite = 0;
 }
 
 void CSpellWindow::fspellsWb()
 {
 	selectedTab = 2;
+	spellSite = 0;
 }
 
 void CSpellWindow::fspellsAllb()
 {
 	selectedTab = 4;
+	spellSite = 0;
+}
+
+void CSpellWindow::fLcornerb()
+{
+	if(spellSite>0)
+		--spellSite;
+}
+
+void CSpellWindow::fRcornerb()
+{
+	if((spellSite + 1) < (battleSpellsOnly ? sitesPerTabBattle[selectedTab] : sitesPerTabAdv[selectedTab]))
+		++spellSite;
 }
 
 void CSpellWindow::show(SDL_Surface *to)
@@ -194,6 +330,20 @@ void CSpellWindow::show(SDL_Surface *to)
 	blitAt(spellTab->ourImages[selectedTab].bitmap, 614, 96, to);
 	
 	statusBar->show();
+
+	if(selectedTab!=4 && spellSite == 0)
+	{
+		blitAt(schools->ourImages[selectedTab].bitmap, 207, 76, to);
+	}
+
+	if(spellSite!=0)
+	{
+		blitAt(leftCorner, lCorner->pos.x, lCorner->pos.y, to);
+	}
+	if((spellSite+1) != (battleSpellsOnly ? sitesPerTabBattle[selectedTab] : sitesPerTabAdv[selectedTab]) )
+	{
+		blitAt(rightCorner, rCorner->pos.x, rCorner->pos.y, to);
+	}
 }
 
 void CSpellWindow::activate()
@@ -208,6 +358,9 @@ void CSpellWindow::activate()
 	selectSpellsF->activate();
 	selectSpellsW->activate();
 	selectSpellsAll->activate();
+
+	lCorner->activate();
+	rCorner->activate();
 }
 
 void CSpellWindow::deactivate()
@@ -222,4 +375,7 @@ void CSpellWindow::deactivate()
 	selectSpellsF->deactivate();
 	selectSpellsW->deactivate();
 	selectSpellsAll->deactivate();
+	
+	lCorner->deactivate();
+	rCorner->deactivate();
 }

+ 10 - 0
client/CSpellWindow.h

@@ -35,8 +35,15 @@ private:
 
 	SpellbookInteractiveArea * exitBtn, * battleSpells, * adventureSpells, * manaPoints;
 	SpellbookInteractiveArea * selectSpellsA, * selectSpellsE, * selectSpellsF, * selectSpellsW, * selectSpellsAll;
+	SpellbookInteractiveArea * lCorner, * rCorner;
 	CStatusBar * statusBar;
+
+	Uint8 sitesPerTabAdv[5];
+	Uint8 sitesPerTabBattle[5];
+
+	bool battleSpellsOnly; //if true, only battle spells are displayed; if false, only adventure map spells are displayed
 	Uint8 selectedTab; // 0 - air magic, 1 - fire magic, 2 - water magic, 3 - earth magic, 4 - all schools
+	Uint8 spellSite; //changes when corners are clicked
 public:
 	CSpellWindow(const SDL_Rect & myRect, const CGHeroInstance * myHero); //c-tor
 	~CSpellWindow(); //d-tor
@@ -52,6 +59,9 @@ public:
 	void fspellsWb();
 	void fspellsAllb();
 
+	void fLcornerb();
+	void fRcornerb();
+
 	void activate();
 	void deactivate();
 	void show(SDL_Surface * to = NULL);

+ 12 - 0
hch/CSpellHandler.cpp

@@ -13,6 +13,8 @@ void CSpellHandler::loadSpells()
 		loadToIt(pom,buf,i,3);
 
 	bool combSpells=false; //true, if we are reading combat spells
+	bool creatureAbility=false; //if true, only creature can use this spell
+	int ifHit = 0;
 	while(i<andame)
 	{
 		if(spells.size()==81)
@@ -22,9 +24,18 @@ void CSpellHandler::loadSpells()
 		loadToIt(nsp.name,buf,i,4);
 		if(nsp.name == std::string(""))
 		{
+			if(ifHit == 0)
+			{
+				combSpells = true;
+			}
+			if(ifHit == 1)
+			{
+				creatureAbility = true;
+			}
 			for(int z=0; z<3; ++z)
 				loadToIt(pom,buf,i,3);
 			loadToIt(nsp.name,buf,i,4);
+			++ifHit;
 		}
 
 		loadToIt(nsp.abbName,buf,i,4);
@@ -65,6 +76,7 @@ void CSpellHandler::loadSpells()
 		loadToIt(nsp.attributes,buf,i,3);
 		nsp.id = spells.size();
 		nsp.combatSpell = combSpells;
+		nsp.creatureAbility = creatureAbility;
 		spells.push_back(nsp);
 	}
 }

+ 1 - 0
hch/CSpellHandler.h

@@ -23,6 +23,7 @@ public:
 	std::vector<std::string> descriptions; //descriptions of spell for skill levels: 0 - none, 1 - basic, etc
 	std::string attributes; //reference only attributes
 	bool combatSpell; //is this spell combat (true) or adventure (false)
+	bool creatureAbility; //if true, only creatures can use this spell
 };
 
 class DLL_EXPORT CSpellHandler