Kaynağa Gözat

Fixes for exchange window in non 800x600 res
Minor improvements and fixes.

Michał W. Urbańczyk 16 yıl önce
ebeveyn
işleme
25663d2605

+ 1 - 1
client/CPlayerInterface.cpp

@@ -1709,7 +1709,7 @@ void CPlayerInterface::requestRealized( PackageApplied *pa )
 
 void CPlayerInterface::heroExchangeStarted(si32 hero1, si32 hero2)
 {
-	pushInt(new CExchangeWindow(hero1, hero2));
+	pushInt(new CExchangeWindow(hero2, hero1));
 }
 
 void CPlayerInterface::recreateWanderingHeroes()

+ 13 - 8
client/GUIClasses.cpp

@@ -2536,6 +2536,7 @@ CMarketplaceWindow::CMarketplaceWindow(int Mode)
 	setMode(mode);
 	hLeft = hRight = NULL;
 	ok = new AdventureMapButton("","",boost::bind(&CPlayerInterface::popIntTotally,LOCPLINT,this),pos.x+516,pos.y+520,"IOK6432.DEF",SDLK_RETURN);
+	ok->assignedKeys.insert(SDLK_ESCAPE);
 	deal = new AdventureMapButton("","",boost::bind(&CMarketplaceWindow::makeDeal,this),pos.x+307,pos.y+520,"TPMRKB.DEF");
 	max = new AdventureMapButton("","",boost::bind(&CMarketplaceWindow::setMax,this),pos.x+229,pos.y+520,"IRCBTNS.DEF");
 
@@ -3304,7 +3305,7 @@ void CArtPlace::clickLeft(boost::logic::tribool down)
 {
 	//LRClickableAreaWTextComp::clickLeft(down);
 	
-	if(ourArt && !down) //we are spellbook
+	if(ourArt && !down && pressedL) //we are spellbook
 	{
 		if(ourArt->id == 0)
 		{
@@ -3849,7 +3850,7 @@ void CExchangeWindow::prepareBackground()
 		//printing secondary skills
 		for(int m=0; m<heroInst[b]->secSkills.size(); ++m)
 		{
-			blitAt(graphics->abils32->ourImages[heroInst[b]->secSkills[m].first * 3 + heroInst[b]->secSkills[m].second + 2].bitmap, genRect(32, 32, pos.x + 32 + 36 * m + 454 * b, pos.y + 88), bg);
+			blitAt(graphics->abils32->ourImages[heroInst[b]->secSkills[m].first * 3 + heroInst[b]->secSkills[m].second + 2].bitmap, genRect(32, 32, 32 + 36 * m + 454 * b, 88), bg);
 		}
 
 		//hero's specialty
@@ -3881,20 +3882,24 @@ void CExchangeWindow::prepareBackground()
 CExchangeWindow::CExchangeWindow(si32 hero1, si32 hero2) : bg(NULL)
 {
 	char bufor[400];
-
 	heroInst[0] = LOCPLINT->cb->getHeroInfo(hero1, 2);
 	heroInst[1] = LOCPLINT->cb->getHeroInfo(hero2, 2);
 
-	artifs[0] = new CArtifactsOfHero(genRect(600, 800, -334, 150));
+	prepareBackground();
+	pos.x = screen->w/2 - bg->w/2;
+	pos.y = screen->h/2 - bg->h/2;
+	pos.w = screen->w;
+	pos.h = screen->h;
+
+
+	artifs[0] = new CArtifactsOfHero(genRect(600, 800, pos.x + -334, pos.y + 150));
 	artifs[0]->commonInfo = new CArtifactsOfHero::SCommonPart;
 	artifs[0]->setHero(heroInst[0]);
 	artifs[0]->commonInfo->activeArtPlace = NULL;
-	artifs[1] = new CArtifactsOfHero(genRect(600, 800, 96, 150));
+	artifs[1] = new CArtifactsOfHero(genRect(600, 800, pos.x + 96, pos.y + 150));
 	artifs[1]->commonInfo = artifs[0]->commonInfo;
 	artifs[1]->setHero(heroInst[1]);
 
-	prepareBackground();
-
 
 	//primary skills
 	for(int g=0; g<4; ++g)
@@ -3967,7 +3972,7 @@ CExchangeWindow::CExchangeWindow(si32 hero1, si32 hero2) : bg(NULL)
 	ourBar = new CStatusBar(pos.x + 3, pos.y + 577, "TSTATBAR.bmp", 726);
 
 	//garrison interface
-	garr = new CGarrisonInt(pos.x + 69, pos.y + 131, 4, Point(418,0), bg, Point(0,0), heroInst[0],heroInst[1], true);
+	garr = new CGarrisonInt(pos.x + 69, pos.y + 131, 4, Point(418,0), bg, Point(69,131), heroInst[0],heroInst[1], true);
 }
 
 CExchangeWindow::~CExchangeWindow() //d-tor

+ 6 - 1
hch/CArtHandler.cpp

@@ -217,7 +217,12 @@ void CArtHandler::addBonuses()
 	ART_LUCK(46,+1); //Clover of Fortune
 	ART_LUCK(47,+1); //Cards of Prophecy
 	ART_LUCK(48,+1); //Ladybird of Luck
-	ART_MORALE(49,+1); //Badge of Courage
+	ART_MORALE(49,+1); //Badge of Courage -> +1 morale and immunity to hostile mind spells:
+	giveArtBonus(49,HeroBonus::SPELL_IMMUNITY,50);//sorrow
+	giveArtBonus(49,HeroBonus::SPELL_IMMUNITY,59);//berserk
+	giveArtBonus(49,HeroBonus::SPELL_IMMUNITY,60);//hypnotize
+	giveArtBonus(49,HeroBonus::SPELL_IMMUNITY,61);//forgetfulness
+	giveArtBonus(49,HeroBonus::SPELL_IMMUNITY,62);//forgetfulness
 	ART_MORALE(50,+1); //Crest of Valor
 	ART_MORALE(51,+1); //Glyph of Gallantry
 

+ 3 - 2
hch/CObjectHandler.cpp

@@ -447,7 +447,7 @@ int CGHeroInstance::maxMovePoints(bool onLand) const
 	else
 	{
 		//navigation:
-		switch(getSecSkillLevel(2))
+		switch(getSecSkillLevel(5))
 		{
 		case 1:
 			modifier = 0.5;
@@ -2495,7 +2495,8 @@ const std::string & CGWitchHut::getHoverText() const
 	{
 		hoverName += "\n" + VLC->generaltexth->allTexts[356]; // + (learn %s)
 		boost::algorithm::replace_first(hoverName,"%s",VLC->generaltexth->skillName[ability]);
-		if(cb->getSelectedHero(cb->getCurrentPlayer())->getSecSkillLevel(ability)) //hero knows that ability
+		const CGHeroInstance *h = cb->getSelectedHero(cb->getCurrentPlayer());
+		if(h && h->getSecSkillLevel(ability)) //hero knows that ability
 			hoverName += "\n\n" + VLC->generaltexth->allTexts[357]; // (Already learned)
 	}
 	return hoverName;

+ 1 - 1
hch/CVideoHandler.cpp

@@ -5,7 +5,7 @@
 #include <SDL.h>
 #include "../client/SDL_Extensions.h"
 
-//reads events and throws on key down
+//reads events and returns true on key down
 static bool keyDown()
 {
 	SDL_Event ev;

+ 1 - 1
lib/Connection.h

@@ -19,7 +19,7 @@
 #include <boost/mpl/identity.hpp>
 
 #include <boost/type_traits/is_array.hpp>
-const ui32 version = 707;
+const ui32 version = 708;
 class CConnection;
 namespace mpl = boost::mpl;
 

+ 3 - 0
lib/map.cpp

@@ -7,6 +7,7 @@
 #include <zlib.h>
 #include <boost/crc.hpp>
 #include "../hch/CLodHandler.h"
+#include <boost/bind.hpp>
 
 /*
  * map.cpp, part of VCMI engine
@@ -1906,6 +1907,8 @@ void Mapa::readObjects( unsigned char * bufor, int &i)
 		if(nobj->ID==HEROI_TYPE)
 			heroes.push_back(static_cast<CGHeroInstance*>(nobj));
 	}
+
+	std::sort(heroes.begin(), heroes.end(), boost::bind(&CGHeroInstance::subID, _1) < boost::bind(&CGHeroInstance::subID, _2));
 }
 
 void Mapa::readEvents( unsigned char * bufor, int &i )