Browse Source

* VCMI won't try to calculate path when clicking terrain on the other map level then that of currently selected hero (caused hangs)
* Mines / Resource Silos won't give income in the first turn
* Double click on hero slot during stack splitting won't crash
* Fixed problems with updating buttons / minimap

Michał W. Urbańczyk 16 years ago
parent
commit
4581c30b20

+ 4 - 4
client/AdventureMapButton.cpp

@@ -68,7 +68,7 @@ void AdventureMapButton::clickLeft (boost::logic::tribool down)
 		state=1;
 		state=1;
 	else
 	else
 		state=0;
 		state=0;
-	show(screen2);
+	show(screenBuf);
 	if (actOnDown && down)
 	if (actOnDown && down)
 	{
 	{
 		pressedL=state;
 		pressedL=state;
@@ -198,7 +198,7 @@ void AdventureMapButton::block( ui8 on )
 	blocked = on;
 	blocked = on;
 	state = 0;
 	state = 0;
 	bitmapOffset = on ? 2 : 0;
 	bitmapOffset = on ? 2 : 0;
-	show(screen2);
+	show(screenBuf);
 }
 }
 
 
 void CHighlightableButton::select(bool on)
 void CHighlightableButton::select(bool on)
@@ -224,7 +224,7 @@ void CHighlightableButton::clickLeft( tribool down )
 		state=1;
 		state=1;
 	else
 	else
 		state = selected ? 3 : 0;
 		state = selected ? 3 : 0;
-	show(screen2);
+	show(screenBuf);
 	if (pressedL && (down==false))
 	if (pressedL && (down==false))
 	{
 	{
 		pressedL=state;
 		pressedL=state;
@@ -350,7 +350,7 @@ void CSlider::mouseMoved (const SDL_MouseMotionEvent & sEvent)
 
 
 void CSlider::redrawSlider()
 void CSlider::redrawSlider()
 {
 {
-	slider.show(screen2);
+	slider.show(screenBuf);
 }
 }
 
 
 void CSlider::moveLeft()
 void CSlider::moveLeft()

+ 5 - 4
client/CAdvmapInterface.cpp

@@ -481,7 +481,7 @@ void CTerrainRect::clickLeft(tribool down)
 			LOCPLINT->moveHero(currentHero,*currentPath);
 			LOCPLINT->moveHero(currentHero,*currentPath);
 			LOCPLINT->pim->lock();
 			LOCPLINT->pim->lock();
 		}
 		}
-		else //remove old path and find a new one
+		else if(mp.z == currentHero->pos.z) //remove old path and find a new one if we clicked on the map level on which hero is present
 		{
 		{
 			int3 bufpos = currentHero->getPosition(false);
 			int3 bufpos = currentHero->getPosition(false);
 			CPath *& pathForCurhero = LOCPLINT->adventureInt->heroList.items[LOCPLINT->adventureInt->heroList.selected].second;
 			CPath *& pathForCurhero = LOCPLINT->adventureInt->heroList.items[LOCPLINT->adventureInt->heroList.selected].second;
@@ -1282,16 +1282,16 @@ void CAdvMapInt::fswitchLevel()
 	{
 	{
 		position.z--;
 		position.z--;
 		underground.curimg=0;
 		underground.curimg=0;
-		underground.show(screen2);
+		underground.show(screenBuf);
 	}
 	}
 	else
 	else
 	{
 	{
 		underground.curimg=1;
 		underground.curimg=1;
 		position.z++;
 		position.z++;
-		underground.show(screen2);
+		underground.show(screenBuf);
 	}
 	}
 	updateScreen = true;
 	updateScreen = true;
-	minimap.draw(screen2);
+	minimap.draw(screenBuf);
 }
 }
 void CAdvMapInt::fshowQuestlog()
 void CAdvMapInt::fshowQuestlog()
 {
 {
@@ -1355,6 +1355,7 @@ void CAdvMapInt::activate()
 		active--;
 		active--;
 		return;
 		return;
 	}
 	}
+	screenBuf = screen;
 	LOCPLINT->statusbar = &statusbar;
 	LOCPLINT->statusbar = &statusbar;
 	kingOverview.activate();
 	kingOverview.activate();
 	underground.activate();
 	underground.activate();

+ 2 - 0
client/CCastleInterface.cpp

@@ -260,6 +260,8 @@ void CHeroGSlot::clickLeft(boost::logic::tribool down)
 	CHeroGSlot *other = upg  ?  &owner->hslotup :  &owner->hslotdown;
 	CHeroGSlot *other = upg  ?  &owner->hslotup :  &owner->hslotdown;
 	if(!down)
 	if(!down)
 	{
 	{
+		owner->garr->splitting = false;
+		owner->garr->highlighted = NULL;
 		if(hero && highlight)
 		if(hero && highlight)
 		{
 		{
 			highlight = false;
 			highlight = false;

+ 3 - 1
client/CMT.cpp

@@ -57,7 +57,9 @@
  */
  */
 
 
 std::string NAME = NAME_VER + std::string(" (client)"); //application name
 std::string NAME = NAME_VER + std::string(" (client)"); //application name
-SDL_Surface *screen = NULL, *screen2 = NULL; //main screen surface and hlp surface (used to store not-active interfaces layer)
+SDL_Surface *screen = NULL, //main screen surface 
+	*screen2 = NULL,//and hlp surface (used to store not-active interfaces layer) 
+	*screenBuf = screen; //points to screen (if only advmapint is present) or screen2 (else) - should be used when updating controls which are not regularly redrawed
 
 
 std::queue<SDL_Event*> events;
 std::queue<SDL_Event*> events;
 boost::mutex eventsM;
 boost::mutex eventsM;

+ 3 - 0
client/CPlayerInterface.cpp

@@ -1663,6 +1663,9 @@ void CPlayerInterface::popIntTotally( IShowActivable *top )
 
 
 void CPlayerInterface::pushInt( IShowActivable *newInt )
 void CPlayerInterface::pushInt( IShowActivable *newInt )
 {
 {
+	//a new interface will be present, we'll need to use buffer surface (unless it's advmapint that will alter screenBuf on activate anyway)
+	screenBuf = screen2; 
+
 	if(listInt.size())
 	if(listInt.size())
 		listInt.front()->deactivate();
 		listInt.front()->deactivate();
 	listInt.push_front(newInt);
 	listInt.push_front(newInt);

+ 7 - 8
client/GUIClasses.cpp

@@ -31,7 +31,7 @@
 #include <boost/assign/std/vector.hpp> 
 #include <boost/assign/std/vector.hpp> 
 #include <boost/assign/list_of.hpp>
 #include <boost/assign/list_of.hpp>
 #include <boost/date_time/posix_time/posix_time.hpp>
 #include <boost/date_time/posix_time/posix_time.hpp>
-#include <boost/thread.hpp>
+//#include <boost/thread.hpp>
 #include <cmath>
 #include <cmath>
 #include <queue>
 #include <queue>
 #include <sstream>
 #include <sstream>
@@ -1425,7 +1425,6 @@ void CTownList::mouseMoved (const SDL_MouseMotionEvent & sEvent)
 
 
 void CTownList::clickLeft(tribool down)
 void CTownList::clickLeft(tribool down)
 {
 {
-	SDL_Surface *dst = (LOCPLINT->topInt()==LOCPLINT->adventureInt ? screen : screen2);
 	if (down)
 	if (down)
 	{
 	{
 		/***************************ARROWS*****************************************/
 		/***************************ARROWS*****************************************/
@@ -1433,7 +1432,7 @@ void CTownList::clickLeft(tribool down)
 		{
 		{
 			if(from>0)
 			if(from>0)
 			{
 			{
-				blitAt(arrup->ourImages[1].bitmap,arrupp.x,arrupp.y,dst);
+				blitAt(arrup->ourImages[1].bitmap,arrupp.x,arrupp.y,screenBuf);
 				pressed = true;
 				pressed = true;
 			}
 			}
 			return;
 			return;
@@ -1442,7 +1441,7 @@ void CTownList::clickLeft(tribool down)
 		{
 		{
 			if(items.size()-from > SIZE)
 			if(items.size()-from > SIZE)
 			{
 			{
-				blitAt(arrdo->ourImages[1].bitmap,arrdop.x,arrdop.y,dst);
+				blitAt(arrdo->ourImages[1].bitmap,arrdop.x,arrdop.y,screenBuf);
 				pressed = false;
 				pressed = false;
 			}
 			}
 			return;
 			return;
@@ -1468,7 +1467,7 @@ void CTownList::clickLeft(tribool down)
 			return;
 			return;
 		if (pressed) //up
 		if (pressed) //up
 		{
 		{
-			blitAt(arrup->ourImages[0].bitmap,arrupp.x,arrupp.y,dst);
+			blitAt(arrup->ourImages[0].bitmap,arrupp.x,arrupp.y,screenBuf);
 			pressed = indeterminate;
 			pressed = indeterminate;
 			if (!down)
 			if (!down)
 			{
 			{
@@ -1476,12 +1475,12 @@ void CTownList::clickLeft(tribool down)
 				if (from<0)
 				if (from<0)
 					from=0;
 					from=0;
 
 
-				draw(dst);
+				draw(screenBuf);
 			}
 			}
 		}
 		}
 		else if (!pressed) //down
 		else if (!pressed) //down
 		{
 		{
-			blitAt(arrdo->ourImages[0].bitmap,arrdop.x,arrdop.y,dst);
+			blitAt(arrdo->ourImages[0].bitmap,arrdop.x,arrdop.y,screenBuf);
 			pressed = indeterminate;
 			pressed = indeterminate;
 			if (!down)
 			if (!down)
 			{
 			{
@@ -1489,7 +1488,7 @@ void CTownList::clickLeft(tribool down)
 				//if (from<items.size()-5)
 				//if (from<items.size()-5)
 				//	from=items.size()-5;
 				//	from=items.size()-5;
 
 
-				draw(dst);
+				draw(screenBuf);
 			}
 			}
 		}
 		}
 		else
 		else

+ 1 - 1
client/SDL_Extensions.h

@@ -16,7 +16,7 @@
  *
  *
  */
  */
 
 
-extern SDL_Surface * screen, *screen2;
+extern SDL_Surface * screen, *screen2, *screenBuf;
 extern SDL_Color tytulowy, tlo, zwykly ;
 extern SDL_Color tytulowy, tlo, zwykly ;
 extern TTF_Font * TNRB16, *TNR, *GEOR13, *GEORXX, *GEORM;
 extern TTF_Font * TNRB16, *TNR, *GEOR13, *GEORXX, *GEORM;
 void blitAtWR(SDL_Surface * src, int x, int y, SDL_Surface * dst=screen);
 void blitAtWR(SDL_Surface * src, int x, int y, SDL_Surface * dst=screen);

+ 3 - 0
hch/CObjectHandler.cpp

@@ -1664,6 +1664,9 @@ void CGMine::onHeroVisit( const CGHeroInstance * h ) const
 
 
 void CGMine::newTurn() const
 void CGMine::newTurn() const
 {
 {
+	if(cb->getDate() == 1)
+		return;
+
 	if (tempOwner == NEUTRAL_PLAYER)
 	if (tempOwner == NEUTRAL_PLAYER)
 		return;
 		return;
 	int vv = 1;
 	int vv = 1;

+ 1 - 1
lib/IGameCallback.h

@@ -41,7 +41,7 @@ public:
 
 
 	virtual int getOwner(int heroID);
 	virtual int getOwner(int heroID);
 	virtual int getResource(int player, int which);
 	virtual int getResource(int player, int which);
-	virtual int getDate(int mode=0);
+	virtual int getDate(int mode=0); ////mode=0 - total days in game, mode=1 - day of week, mode=2 - current week, mode=3 - current month
 	virtual const CGObjectInstance* getObj(int objid);
 	virtual const CGObjectInstance* getObj(int objid);
 	virtual const CGHeroInstance* getHero(int objid);
 	virtual const CGHeroInstance* getHero(int objid);
 	virtual const CGTownInstance* getTown(int objid);
 	virtual const CGTownInstance* getTown(int objid);

+ 8 - 8
lib/VCMI_lib.vcproj

@@ -282,6 +282,10 @@
 				RelativePath="..\hch\CDefObjInfoHandler.cpp"
 				RelativePath="..\hch\CDefObjInfoHandler.cpp"
 				>
 				>
 			</File>
 			</File>
+			<File
+				RelativePath=".\CGameState.cpp"
+				>
+			</File>
 			<File
 			<File
 				RelativePath="..\hch\CGeneralTextHandler.cpp"
 				RelativePath="..\hch\CGeneralTextHandler.cpp"
 				>
 				>
@@ -314,6 +318,10 @@
 				RelativePath=".\IGameCallback.cpp"
 				RelativePath=".\IGameCallback.cpp"
 				>
 				>
 			</File>
 			</File>
+			<File
+				RelativePath=".\map.cpp"
+				>
+			</File>
 			<File
 			<File
 				RelativePath=".\NetPacksLib.cpp"
 				RelativePath=".\NetPacksLib.cpp"
 				>
 				>
@@ -429,14 +437,6 @@
 				>
 				>
 			</File>
 			</File>
 		</Filter>
 		</Filter>
-		<File
-			RelativePath=".\CGameState.cpp"
-			>
-		</File>
-		<File
-			RelativePath=".\map.cpp"
-			>
-		</File>
 	</Files>
 	</Files>
 	<Globals>
 	<Globals>
 	</Globals>
 	</Globals>