Przeglądaj źródła

* pressing enter or escape close spellbook
* spellbook shows adventure spells when opened on adventure map
* removed redundant quotation marks from skills description
* erasing path after picking objects with last movement point

Michał W. Urbańczyk 16 lat temu
rodzic
commit
2f73b6cd1e

+ 1 - 1
AI/GeniusAI/CGeniusAI.cpp

@@ -56,7 +56,7 @@ void CGeniusAI::heroCreated(const CGHeroInstance *)
 {
 }
 
-void CGeniusAI::heroMoved(const HeroMoveDetails &)
+void CGeniusAI::heroMoved(const TryMoveHero &)
 {
 }
 

+ 1 - 1
AI/GeniusAI/CGeniusAI.h

@@ -21,7 +21,7 @@ public:
 	virtual void yourTurn();
 	virtual void heroKilled(const CGHeroInstance *);
 	virtual void heroCreated(const CGHeroInstance *);
-	virtual void heroMoved(const HeroMoveDetails &);
+	virtual void heroMoved(const TryMoveHero &);
 	virtual void heroPrimarySkillChanged(const CGHeroInstance * hero, int which, int val) {};
 	virtual void showSelDialog(std::string text, std::vector<CSelectableComponent*> & components, int askID){};
 	virtual void showBlockingDialog(const std::string &text, const std::vector<Component> &components, ui32 askID, const int soundID, bool selection, bool cancel); //Show a dialog, player must take decision. If selection then he has to choose between one of given components, if cancel he is allowed to not choose. After making choice, CCallback::selectionMade should be called with number of selected component (1 - n) or 0 for cancel (if allowed) and askID.

+ 2 - 2
CGameInterface.h

@@ -24,7 +24,7 @@ class CGlobalAI;
 class CGHeroInstance;
 class Component;
 class CSelectableComponent;
-struct HeroMoveDetails;
+struct TryMoveHero;
 class CGHeroInstance;
 class CGTownInstance;
 class CGObjectInstance;
@@ -73,7 +73,7 @@ public:
 	virtual void heroGotLevel(const CGHeroInstance *hero, int pskill, std::vector<ui16> &skills, boost::function<void(ui32)> &callback)=0; //pskill is gained primary skill, interface has to choose one of given skills and call callback with selection id
 	virtual void heroInGarrisonChange(const CGTownInstance *town){};
 	virtual void heroKilled(const CGHeroInstance*){};
-	virtual void heroMoved(const HeroMoveDetails & details){};
+	virtual void heroMoved(const TryMoveHero & details){};
 	virtual void heroPrimarySkillChanged(const CGHeroInstance * hero, int which, int val){};
 	virtual void heroManaPointsChanged(const CGHeroInstance * hero){} //not called at the beginning of turn and after spell casts
 	virtual void heroMovePointsChanged(const CGHeroInstance * hero){} //not called at the beginning of turn and after movement

+ 1 - 1
client/CAdvmapInterface.cpp

@@ -1326,7 +1326,7 @@ void CAdvMapInt::fshowSpellbok()
 		return;
 
 
-	CSpellWindow * spellWindow = new CSpellWindow(genRect(595, 620, (conf.cc.resx - 620)/2, (conf.cc.resy - 595)/2), (static_cast<const CGHeroInstance*>(LOCPLINT->adventureInt->selection)));
+	CSpellWindow * spellWindow = new CSpellWindow(genRect(595, 620, (conf.cc.resx - 620)/2, (conf.cc.resy - 595)/2), (static_cast<const CGHeroInstance*>(LOCPLINT->adventureInt->selection)), false);
 	LOCPLINT->pushInt(spellWindow);
 }
 

+ 8 - 5
client/CHeroWindow.cpp

@@ -212,15 +212,18 @@ void CHeroWindow::setHero(const CGHeroInstance *hero)
 	{
 		primSkillAreas[g]->bonus = hero->getPrimSkillLevel(g);
 	}
+
 	//secondary skills support
 	for(size_t g=0; g<hero->secSkills.size(); ++g)
 	{
-		secSkillAreas[g]->type = hero->secSkills[g].first;
-		secSkillAreas[g]->bonus = hero->secSkills[g].second;
-		std::string hlp = CGI->generaltexth->skillInfoTexts[ hero->secSkills[g].first ][hero->secSkills[g].second-1];
-		secSkillAreas[g]->text = hlp.substr(1, hlp.size()-2);
+		int skill = hero->secSkills[g].first, 
+			level = hero->secSkills[g].second;
+
+		secSkillAreas[g]->type = skill;
+		secSkillAreas[g]->bonus = level;
+		secSkillAreas[g]->text = CGI->generaltexth->skillInfoTexts[skill][level-1];
 
-		sprintf(bufor, CGI->generaltexth->heroscrn[21].c_str(), CGI->generaltexth->levels[hero->secSkills[g].second-1].c_str(), CGI->generaltexth->skillName[hero->secSkills[g].first].c_str());
+		sprintf(bufor, CGI->generaltexth->heroscrn[21].c_str(), CGI->generaltexth->levels[level-1].c_str(), CGI->generaltexth->skillName[skill].c_str());
 		secSkillAreas[g]->hoverText = std::string(bufor);
 	}
 

+ 46 - 47
client/CPlayerInterface.cpp

@@ -298,31 +298,30 @@ static int getDir(int3 src, int3 dst)
 	}
 	return ret;
 }
-void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
+void CPlayerInterface::heroMoved(const TryMoveHero & details)
 {
 	boost::unique_lock<boost::recursive_mutex> un(*pim);
+	const CGHeroInstance * ho = cb->getHeroInfo(details.id); //object representing this hero
 
-	adventureInt->centerOn(details.ho->pos); //actualizing screen pos
+	adventureInt->centerOn(ho->pos); //actualizing screen pos
 	adventureInt->minimap.draw(screen2);
 	adventureInt->heroList.draw(screen2);
 
-	if(details.style>0  ||  details.src == details.dst)
+	if(details.result == TryMoveHero::TELEPORTATION	||  details.start == details.end)
 		return;
 
 	//initializing objects and performing first step of move
-	const CGHeroInstance * ho = details.ho; //object representing this hero
-	int3 hp = details.src;
-	if (!details.successful) //hero failed to move
+	int3 hp = details.start;
+	if (details.result != TryMoveHero::SUCCESS) //hero failed to move
 	{
-		if(ho->movement > 50)
-			ho->moveDir = getDir(details.src,details.dst);
-		ho->isStanding = true;
-
-		if(ho->movement)
+		if(details.result == TryMoveHero::BLOCKING_VISIT)
 		{
+			ho->moveDir = getDir(details.start,details.end);
 			adventureInt->paths.erase(ho);
 			adventureInt->terrain.currentPath = NULL;
 		}
+
+		ho->isStanding = true;
 		stillMoveHero.setn(STOP_MOVE);
 		return;
 	}
@@ -339,7 +338,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
 	}
 
 
-	if(details.dst.x+1 == details.src.x && details.dst.y+1 == details.src.y) //tl
+	if(details.end.x+1 == details.start.x && details.end.y+1 == details.start.y) //tl
 	{
 		ho->moveDir = 1;
 		ho->isStanding = false;
@@ -367,7 +366,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
 
 		std::stable_sort(CGI->mh->ttiles[hp.x-3][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-3][hp.y][hp.z].objects.end(), ocmptwo_cgin);
 	}
-	else if(details.dst.x == details.src.x && details.dst.y+1 == details.src.y) //t
+	else if(details.end.x == details.start.x && details.end.y+1 == details.start.y) //t
 	{
 		ho->moveDir = 2;
 		ho->isStanding = false;
@@ -387,7 +386,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
 		std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y-2][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y-2][hp.z].objects.end(), ocmptwo_cgin);
 		std::stable_sort(CGI->mh->ttiles[hp.x][hp.y-2][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y-2][hp.z].objects.end(), ocmptwo_cgin);
 	}
-	else if(details.dst.x-1 == details.src.x && details.dst.y+1 == details.src.y) //tr
+	else if(details.end.x-1 == details.start.x && details.end.y+1 == details.start.y) //tr
 	{
 		ho->moveDir = 3;
 		ho->isStanding = false;
@@ -415,7 +414,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
 
 		std::stable_sort(CGI->mh->ttiles[hp.x+1][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x+1][hp.y][hp.z].objects.end(), ocmptwo_cgin);
 	}
-	else if(details.dst.x-1 == details.src.x && details.dst.y == details.src.y) //r
+	else if(details.end.x-1 == details.start.x && details.end.y == details.start.y) //r
 	{
 		ho->moveDir = 4;
 		ho->isStanding = false;
@@ -433,7 +432,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
 
 		std::stable_sort(CGI->mh->ttiles[hp.x+1][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x+1][hp.y][hp.z].objects.end(), ocmptwo_cgin);
 	}
-	else if(details.dst.x-1 == details.src.x && details.dst.y-1 == details.src.y) //br
+	else if(details.end.x-1 == details.start.x && details.end.y-1 == details.start.y) //br
 	{
 		ho->moveDir = 5;
 		ho->isStanding = false;
@@ -461,7 +460,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
 		std::stable_sort(CGI->mh->ttiles[hp.x][hp.y+1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y+1][hp.z].objects.end(), ocmptwo_cgin);
 		std::stable_sort(CGI->mh->ttiles[hp.x+1][hp.y+1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x+1][hp.y+1][hp.z].objects.end(), ocmptwo_cgin);
 	}
-	else if(details.dst.x == details.src.x && details.dst.y-1 == details.src.y) //b
+	else if(details.end.x == details.start.x && details.end.y-1 == details.start.y) //b
 	{
 		ho->moveDir = 6;
 		ho->isStanding = false;
@@ -481,7 +480,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
 		std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y+1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y+1][hp.z].objects.end(), ocmptwo_cgin);
 		std::stable_sort(CGI->mh->ttiles[hp.x][hp.y+1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y+1][hp.z].objects.end(), ocmptwo_cgin);
 	}
-	else if(details.dst.x+1 == details.src.x && details.dst.y-1 == details.src.y) //bl
+	else if(details.end.x+1 == details.start.x && details.end.y-1 == details.start.y) //bl
 	{
 		ho->moveDir = 7;
 		ho->isStanding = false;
@@ -509,7 +508,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
 		std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y+1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y+1][hp.z].objects.end(), ocmptwo_cgin);
 		std::stable_sort(CGI->mh->ttiles[hp.x][hp.y+1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y+1][hp.z].objects.end(), ocmptwo_cgin);
 	}
-	else if(details.dst.x+1 == details.src.x && details.dst.y == details.src.y) //l
+	else if(details.end.x+1 == details.start.x && details.end.y == details.start.y) //l
 	{
 		ho->moveDir = 8;
 		ho->isStanding = false;
@@ -532,7 +531,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
 	//main moving
 	for(int i=1; i<32; i+=2*heroMoveSpeed)
 	{
-		if(details.dst.x+1 == details.src.x && details.dst.y+1 == details.src.y) //tl
+		if(details.end.x+1 == details.start.x && details.end.y+1 == details.start.y) //tl
 		{
 			//setting advmap shift
 			adventureInt->terrain.moveX = i-32;
@@ -553,7 +552,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
 			subRect(hp.x-1, hp.y, hp.z, genRect(32, 32, 33+i, 33+i), ho->id);
 			subRect(hp.x, hp.y, hp.z, genRect(32, 32, 65+i, 33+i), ho->id);
 		}
-		else if(details.dst.x == details.src.x && details.dst.y+1 == details.src.y) //t
+		else if(details.end.x == details.start.x && details.end.y+1 == details.start.y) //t
 		{
 			//setting advmap shift
 			adventureInt->terrain.moveY = i-32;
@@ -570,7 +569,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
 			subRect(hp.x-1, hp.y, hp.z, genRect(32, 32, 32, 33+i), ho->id);
 			subRect(hp.x, hp.y, hp.z, genRect(32, 32, 64, 33+i), ho->id);
 		}
-		else if(details.dst.x-1 == details.src.x && details.dst.y+1 == details.src.y) //tr
+		else if(details.end.x-1 == details.start.x && details.end.y+1 == details.start.y) //tr
 		{
 			//setting advmap shift
 			adventureInt->terrain.moveX = -i+32;
@@ -591,7 +590,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
 			subRect(hp.x, hp.y, hp.z, genRect(32, 32, 63-i, 33+i), ho->id);
 			subRect(hp.x+1, hp.y, hp.z, genRect(32, 32, 95-i, 33+i), ho->id);
 		}
-		else if(details.dst.x-1 == details.src.x && details.dst.y == details.src.y) //r
+		else if(details.end.x-1 == details.start.x && details.end.y == details.start.y) //r
 		{
 			//setting advmap shift
 			adventureInt->terrain.moveX = -i+32;
@@ -606,7 +605,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
 			subRect(hp.x, hp.y, hp.z, genRect(32, 32, 63-i, 32), ho->id);
 			subRect(hp.x+1, hp.y, hp.z, genRect(32, 32, 95-i, 32), ho->id);
 		}
-		else if(details.dst.x-1 == details.src.x && details.dst.y-1 == details.src.y) //br
+		else if(details.end.x-1 == details.start.x && details.end.y-1 == details.start.y) //br
 		{
 			
 			//setting advmap shift
@@ -628,7 +627,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
 			subRect(hp.x, hp.y+1, hp.z, genRect(32, 32, 63-i, 63-i), ho->id);
 			subRect(hp.x+1, hp.y+1, hp.z, genRect(32, 32, 95-i, 63-i), ho->id);
 		}
-		else if(details.dst.x == details.src.x && details.dst.y-1 == details.src.y) //b
+		else if(details.end.x == details.start.x && details.end.y-1 == details.start.y) //b
 		{
 			//setting advmap shift
 			adventureInt->terrain.moveY = -i+32;
@@ -645,7 +644,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
 			subRect(hp.x-1, hp.y+1, hp.z, genRect(32, 32, 32, 63-i), ho->id);
 			subRect(hp.x, hp.y+1, hp.z, genRect(32, 32, 64, 63-i), ho->id);
 		}
-		else if(details.dst.x+1 == details.src.x && details.dst.y-1 == details.src.y) //bl
+		else if(details.end.x+1 == details.start.x && details.end.y-1 == details.start.y) //bl
 		{
 			//setting advmap shift
 			adventureInt->terrain.moveX = i-32;
@@ -666,7 +665,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
 			subRect(hp.x-1, hp.y+1, hp.z, genRect(32, 32, 33+i, 63-i), ho->id);
 			subRect(hp.x, hp.y+1, hp.z, genRect(32, 32, 65+i, 63-i), ho->id);
 		}
-		else if(details.dst.x+1 == details.src.x && details.dst.y == details.src.y) //l
+		else if(details.end.x+1 == details.start.x && details.end.y == details.start.y) //l
 		{
 			//setting advmap shift
 			adventureInt->terrain.moveX = i-32;
@@ -695,7 +694,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
 	//restoring adventureInt->terrain.move*
 	adventureInt->terrain.moveX = adventureInt->terrain.moveY = 0;
 
-	if(details.dst.x+1 == details.src.x && details.dst.y+1 == details.src.y) //tl
+	if(details.end.x+1 == details.start.x && details.end.y+1 == details.start.y) //tl
 	{
 		delObjRect(hp.x, hp.y-2, hp.z, ho->id);
 		delObjRect(hp.x, hp.y-1, hp.z, ho->id);
@@ -704,13 +703,13 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
 		delObjRect(hp.x-2, hp.y, hp.z, ho->id);
 		delObjRect(hp.x-3, hp.y, hp.z, ho->id);
 	}
-	else if(details.dst.x == details.src.x && details.dst.y+1 == details.src.y) //t
+	else if(details.end.x == details.start.x && details.end.y+1 == details.start.y) //t
 	{
 		delObjRect(hp.x, hp.y, hp.z, ho->id);
 		delObjRect(hp.x-1, hp.y, hp.z, ho->id);
 		delObjRect(hp.x-2, hp.y, hp.z, ho->id);
 	}
-	else if(details.dst.x-1 == details.src.x && details.dst.y+1 == details.src.y) //tr
+	else if(details.end.x-1 == details.start.x && details.end.y+1 == details.start.y) //tr
 	{
 		delObjRect(hp.x-2, hp.y-2, hp.z, ho->id);
 		delObjRect(hp.x-2, hp.y-1, hp.z, ho->id);
@@ -719,12 +718,12 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
 		delObjRect(hp.x-1, hp.y, hp.z, ho->id);
 		delObjRect(hp.x-2, hp.y, hp.z, ho->id);
 	}
-	else if(details.dst.x-1 == details.src.x && details.dst.y == details.src.y) //r
+	else if(details.end.x-1 == details.start.x && details.end.y == details.start.y) //r
 	{
 		delObjRect(hp.x-2, hp.y-1, hp.z, ho->id);
 		delObjRect(hp.x-2, hp.y, hp.z, ho->id);
 	}
-	else if(details.dst.x-1 == details.src.x && details.dst.y-1 == details.src.y) //br
+	else if(details.end.x-1 == details.start.x && details.end.y-1 == details.start.y) //br
 	{
 		delObjRect(hp.x-2, hp.y+1, hp.z, ho->id);
 		delObjRect(hp.x-2, hp.y, hp.z, ho->id);
@@ -733,13 +732,13 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
 		delObjRect(hp.x-1, hp.y-1, hp.z, ho->id);
 		delObjRect(hp.x-2, hp.y-1, hp.z, ho->id);
 	}
-	else if(details.dst.x == details.src.x && details.dst.y-1 == details.src.y) //b
+	else if(details.end.x == details.start.x && details.end.y-1 == details.start.y) //b
 	{
 		delObjRect(hp.x, hp.y-1, hp.z, ho->id);
 		delObjRect(hp.x-1, hp.y-1, hp.z, ho->id);
 		delObjRect(hp.x-2, hp.y-1, hp.z, ho->id);
 	}
-	else if(details.dst.x+1 == details.src.x && details.dst.y-1 == details.src.y) //bl
+	else if(details.end.x+1 == details.start.x && details.end.y-1 == details.start.y) //bl
 	{
 		delObjRect(hp.x, hp.y-1, hp.z, ho->id);
 		delObjRect(hp.x-1, hp.y-1, hp.z, ho->id);
@@ -748,29 +747,29 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
 		delObjRect(hp.x, hp.y, hp.z, ho->id);
 		delObjRect(hp.x, hp.y+1, hp.z, ho->id);
 	}
-	else if(details.dst.x+1 == details.src.x && details.dst.y == details.src.y) //l
+	else if(details.end.x+1 == details.start.x && details.end.y == details.start.y) //l
 	{
 		delObjRect(hp.x, hp.y-1, hp.z, ho->id);
 		delObjRect(hp.x, hp.y, hp.z, ho->id);
 	}
 
 	//restoring good rects
-	subRect(details.dst.x-2, details.dst.y-1, details.dst.z, genRect(32, 32, 0, 0), ho->id);
-	subRect(details.dst.x-1, details.dst.y-1, details.dst.z, genRect(32, 32, 32, 0), ho->id);
-	subRect(details.dst.x, details.dst.y-1, details.dst.z, genRect(32, 32, 64, 0), ho->id);
+	subRect(details.end.x-2, details.end.y-1, details.end.z, genRect(32, 32, 0, 0), ho->id);
+	subRect(details.end.x-1, details.end.y-1, details.end.z, genRect(32, 32, 32, 0), ho->id);
+	subRect(details.end.x, details.end.y-1, details.end.z, genRect(32, 32, 64, 0), ho->id);
 
-	subRect(details.dst.x-2, details.dst.y, details.dst.z, genRect(32, 32, 0, 32), ho->id);
-	subRect(details.dst.x-1, details.dst.y, details.dst.z, genRect(32, 32, 32, 32), ho->id);
-	subRect(details.dst.x, details.dst.y, details.dst.z, genRect(32, 32, 64, 32), ho->id);
+	subRect(details.end.x-2, details.end.y, details.end.z, genRect(32, 32, 0, 32), ho->id);
+	subRect(details.end.x-1, details.end.y, details.end.z, genRect(32, 32, 32, 32), ho->id);
+	subRect(details.end.x, details.end.y, details.end.z, genRect(32, 32, 64, 32), ho->id);
 
 	//restoring good order of objects
-	std::stable_sort(CGI->mh->ttiles[details.dst.x-2][details.dst.y-1][details.dst.z].objects.begin(), CGI->mh->ttiles[details.dst.x-2][details.dst.y-1][details.dst.z].objects.end(), ocmptwo_cgin);
-	std::stable_sort(CGI->mh->ttiles[details.dst.x-1][details.dst.y-1][details.dst.z].objects.begin(), CGI->mh->ttiles[details.dst.x-1][details.dst.y-1][details.dst.z].objects.end(), ocmptwo_cgin);
-	std::stable_sort(CGI->mh->ttiles[details.dst.x][details.dst.y-1][details.dst.z].objects.begin(), CGI->mh->ttiles[details.dst.x][details.dst.y-1][details.dst.z].objects.end(), ocmptwo_cgin);
+	std::stable_sort(CGI->mh->ttiles[details.end.x-2][details.end.y-1][details.end.z].objects.begin(), CGI->mh->ttiles[details.end.x-2][details.end.y-1][details.end.z].objects.end(), ocmptwo_cgin);
+	std::stable_sort(CGI->mh->ttiles[details.end.x-1][details.end.y-1][details.end.z].objects.begin(), CGI->mh->ttiles[details.end.x-1][details.end.y-1][details.end.z].objects.end(), ocmptwo_cgin);
+	std::stable_sort(CGI->mh->ttiles[details.end.x][details.end.y-1][details.end.z].objects.begin(), CGI->mh->ttiles[details.end.x][details.end.y-1][details.end.z].objects.end(), ocmptwo_cgin);
 
-	std::stable_sort(CGI->mh->ttiles[details.dst.x-2][details.dst.y][details.dst.z].objects.begin(), CGI->mh->ttiles[details.dst.x-2][details.dst.y][details.dst.z].objects.end(), ocmptwo_cgin);
-	std::stable_sort(CGI->mh->ttiles[details.dst.x-1][details.dst.y][details.dst.z].objects.begin(), CGI->mh->ttiles[details.dst.x-1][details.dst.y][details.dst.z].objects.end(), ocmptwo_cgin);
-	std::stable_sort(CGI->mh->ttiles[details.dst.x][details.dst.y][details.dst.z].objects.begin(), CGI->mh->ttiles[details.dst.x][details.dst.y][details.dst.z].objects.end(), ocmptwo_cgin);
+	std::stable_sort(CGI->mh->ttiles[details.end.x-2][details.end.y][details.end.z].objects.begin(), CGI->mh->ttiles[details.end.x-2][details.end.y][details.end.z].objects.end(), ocmptwo_cgin);
+	std::stable_sort(CGI->mh->ttiles[details.end.x-1][details.end.y][details.end.z].objects.begin(), CGI->mh->ttiles[details.end.x-1][details.end.y][details.end.z].objects.end(), ocmptwo_cgin);
+	std::stable_sort(CGI->mh->ttiles[details.end.x][details.end.y][details.end.z].objects.begin(), CGI->mh->ttiles[details.end.x][details.end.y][details.end.z].objects.end(), ocmptwo_cgin);
 
 	ho->isStanding = true;
 	//move finished

+ 2 - 2
client/CPlayerInterface.h

@@ -32,7 +32,7 @@ class CDefEssential;
 class AdventureMapButton;
 class CHighlightableButtonsGroup;
 class CDefHandler;
-struct HeroMoveDetails;
+struct TryMoveHero;
 class CDefEssential;
 class CGHeroInstance;
 class CAdvMapInt;
@@ -127,7 +127,7 @@ public:
 	void heroGotLevel(const CGHeroInstance *hero, int pskill, std::vector<ui16> &skills, boost::function<void(ui32)> &callback);
 	void heroInGarrisonChange(const CGTownInstance *town);
 	void heroKilled(const CGHeroInstance* hero);
-	void heroMoved(const HeroMoveDetails & details);
+	void heroMoved(const TryMoveHero & details);
 	void heroPrimarySkillChanged(const CGHeroInstance * hero, int which, int val);
 	void heroManaPointsChanged(const CGHeroInstance * hero);
 	void heroMovePointsChanged(const CGHeroInstance * hero);

+ 10 - 2
client/CSpellWindow.cpp

@@ -77,8 +77,8 @@ void SpellbookInteractiveArea::deactivate()
 	Hoverable::deactivate();
 }
 
-CSpellWindow::CSpellWindow(const SDL_Rect & myRect, const CGHeroInstance * myHero):
-	battleSpellsOnly(true),
+CSpellWindow::CSpellWindow(const SDL_Rect & myRect, const CGHeroInstance * myHero, bool openOnBattleSpells):
+	battleSpellsOnly(openOnBattleSpells),
 	selectedTab(4),
 	spellSite(0)
 {
@@ -594,6 +594,7 @@ void CSpellWindow::computeSpellsPerArea()
 
 void CSpellWindow::activate()
 {
+	KeyInterested::activate();
 	exitBtn->activate();
 	battleSpells->activate();
 	adventureSpells->activate();
@@ -616,6 +617,7 @@ void CSpellWindow::activate()
 
 void CSpellWindow::deactivate()
 {
+	KeyInterested::deactivate();
 	exitBtn->deactivate();
 	battleSpells->deactivate();
 	adventureSpells->deactivate();
@@ -646,6 +648,12 @@ void CSpellWindow::turnPageRight()
 	CGI->videoh->openAndPlayVideo("PGTRNRGH.SMK", pos.x+13, pos.y+15, screen);
 }
 
+void CSpellWindow::keyPressed(const SDL_KeyboardEvent & key)
+{
+	if(key.keysym.sym == SDLK_ESCAPE ||  key.keysym.sym == SDLK_RETURN)
+		fexitb();
+}
+
 CSpellWindow::SpellArea::SpellArea(SDL_Rect pos, CSpellWindow * owner)
 {
 	this->pos = pos;

+ 3 - 2
client/CSpellWindow.h

@@ -39,7 +39,7 @@ public:
 	SpellbookInteractiveArea(const SDL_Rect & myRect, boost::function<void()> funcL, const std::string & textR, boost::function<void()> funcHon, boost::function<void()> funcHoff);//c-tor
 };
 
-class CSpellWindow : public IShowActivable, public CIntObject
+class CSpellWindow : public IShowActivable, public KeyInterested
 {
 private:
 	class SpellArea : public ClickableL, public ClickableR, public Hoverable
@@ -83,7 +83,7 @@ private:
 	void turnPageRight();
 
 public:
-	CSpellWindow(const SDL_Rect & myRect, const CGHeroInstance * myHero); //c-tor
+	CSpellWindow(const SDL_Rect & myRect, const CGHeroInstance * myHero, bool openOnBattleSpells = true); //c-tor
 	~CSpellWindow(); //d-tor
 
 	void fexitb();
@@ -100,6 +100,7 @@ public:
 	void fLcornerb();
 	void fRcornerb();
 
+	void keyPressed(const SDL_KeyboardEvent & key);
 	void activate();
 	void deactivate();
 	void show(SDL_Surface * to);

+ 6 - 8
client/NetPacksClient.cpp

@@ -140,19 +140,17 @@ void RemoveObject::applyCl( CClient *cl )
 
 void TryMoveHero::applyFirstCl( CClient *cl )
 {
-	if(result>1)
+	if(result == TELEPORTATION)
 		CGI->mh->removeObject(GS(cl)->getHero(id));
 }
 
 void TryMoveHero::applyCl( CClient *cl )
 {
-	HeroMoveDetails hmd(start,end,GS(cl)->getHero(id));
-	hmd.style = result-1;
-	hmd.successful = result;
+	const CGHeroInstance *h = cl->getHero(id);
 
-	if(result>1)
-		CGI->mh->printObject(hmd.ho);
-	int player = hmd.ho->tempOwner;
+	if(result == TELEPORTATION)
+		CGI->mh->printObject(h);
+	int player = h->tempOwner;
 
 	if(vstd::contains(cl->playerint,player))
 	{
@@ -165,7 +163,7 @@ void TryMoveHero::applyCl( CClient *cl )
 		if(i->first >= PLAYER_LIMIT) continue;
 		if(GS(cl)->players[i->first].fogOfWarMap[start.x-1][start.y][start.z] || GS(cl)->players[i->first].fogOfWarMap[end.x-1][end.y][end.z])
 		{
-			i->second->heroMoved(hmd);
+			i->second->heroMoved(*this);
 		}
 	}
 }

+ 10 - 3
hch/CGeneralTextHandler.cpp

@@ -25,6 +25,13 @@ std::string readTo(std::string &in, int &it, char end)
 	it+=(1+last-it);
 	return in.substr(pom,last-pom);
 }
+
+void trimQuotation(std::string &op)
+{
+	if(op[0] == '\"' && op[op.size()-1] == '\"')
+		op = op.substr(1,op.size()-2);
+}
+
 void CGeneralTextHandler::load()
 {
 	std::string buf1 = bitmaph->getTextFile("ZELP.TXT");
@@ -47,9 +54,7 @@ void CGeneralTextHandler::load()
 				buf1.substr(pom+1,eol-pom-1)));
 			boost::algorithm::replace_all(zelp[zelp.size()-1].first,"\t","");
 			boost::algorithm::replace_all(zelp[zelp.size()-1].second,"\t","");
-			std::string &op = zelp.back().second;
-			if(op[0] == '\"' && op[op.size()-1] == '\"')
-				op =op.substr(1,op.size()-2);
+			trimQuotation(zelp.back().second);
 		}
 		itr=eol+2;
 	}
@@ -385,6 +390,8 @@ void CGeneralTextHandler::load()
 		loadToIt(skillInfoTexts[i][0],buf,it,4);
 		loadToIt(skillInfoTexts[i][1],buf,it,4);
 		loadToIt(skillInfoTexts[i][2],buf,it,3);
+		for(int j = 0; j < 3; j++)
+			trimQuotation(skillInfoTexts[i][j]);
 	}
 	buf = bitmaph->getTextFile("SKILLLEV.TXT");
 	it=0;

+ 6 - 1
lib/NetPacks.h

@@ -359,8 +359,13 @@ struct TryMoveHero : public CPackForClient //501
 	void applyCl(CClient *cl);
 	void applyGs(CGameState *gs);
 
+	enum EResult
+	{
+		FAILED, SUCCESS, TELEPORTATION, RESERVED___, BLOCKING_VISIT
+	};
+
 	ui32 id, movePoints;
-	ui8 result; //0 - failed; 1- succes -normal move; 2 - teleportation, 3 - instant jump
+	ui8 result; //uses EResult
 	int3 start, end;
 	std::set<int3> fowRevealed; //revealed tiles
 

+ 1 - 1
lib/NetPacksLib.cpp

@@ -241,7 +241,7 @@ void TryMoveHero::applyGs( CGameState *gs )
 {
 	CGHeroInstance *h = gs->getHero(id);
 	h->movement = movePoints;
-	if(start!=end && result)
+	if(start!=end && (result == SUCCESS || result == TELEPORTATION))
 	{
 		gs->map->removeBlockVisTiles(h);
 		h->pos = end;

+ 4 - 3
server/CGameHandler.cpp

@@ -1156,7 +1156,7 @@ bool CGameHandler::moveHero( si32 hid, int3 dst, ui8 instant, ui8 asker /*= 255*
 	tmh.id = hid;
 	tmh.start = h->pos;
 	tmh.end = dst;
-	tmh.result = 0;
+	tmh.result = TryMoveHero::FAILED;
 	tmh.movePoints = h->movement;
 
 	//check if destination tile is available
@@ -1196,6 +1196,7 @@ bool CGameHandler::moveHero( si32 hid, int3 dst, ui8 instant, ui8 asker /*= 255*
 		//we start moving
 		if(blockvis)//interaction with blocking object (like resources)
 		{
+			tmh.result = TryMoveHero::BLOCKING_VISIT;
 			sendAndApply(&tmh); 
 			//failed to move to that tile but we visit object
 			BOOST_FOREACH(CGObjectInstance *obj, t.visitableObjects)
@@ -1210,7 +1211,7 @@ bool CGameHandler::moveHero( si32 hid, int3 dst, ui8 instant, ui8 asker /*= 255*
 		}
 		else //normal move
 		{
-			tmh.result = 1;
+			tmh.result = TryMoveHero::SUCCESS;
 
 			BOOST_FOREACH(CGObjectInstance *obj, gs->map->terrain[h->pos.x-1][h->pos.y][h->pos.z].visitableObjects)
 			{
@@ -1243,7 +1244,7 @@ bool CGameHandler::moveHero( si32 hid, int3 dst, ui8 instant, ui8 asker /*= 255*
 				return true;
 			}
 		}
-		tmh.result = instant+1;
+		tmh.result = TryMoveHero::TELEPORTATION;
 		getTilesInRange(tmh.fowRevealed,h->getSightCenter()+(tmh.end-tmh.start),h->getSightRadious(),h->tempOwner,1);
 		sendAndApply(&tmh);
 		return true;