Bladeren bron

faster FoW in minimap, does not work, compiler errors

mateuszb 18 jaren geleden
bovenliggende
commit
58f1a2169f
13 gewijzigde bestanden met toevoegingen van 204 en 394 verwijderingen
  1. 2 0
      AI/EmptyAI/CEmptyAI.h
  2. 0 266
      AI/EmptyAI/Z_EmptyAI.vcproj
  3. 29 26
      CAdvmapInterface.cpp
  4. 3 1
      CAdvmapInterface.h
  5. 3 3
      CCallback.cpp
  6. 1 1
      CCallback.h
  7. 34 34
      CCursorHandler.cpp
  8. 2 0
      CGameInterface.h
  9. 58 3
      CMT.cpp
  10. 65 57
      CPlayerInterface.cpp
  11. 2 0
      CPlayerInterface.h
  12. 2 2
      CScreenHandler.cpp
  13. 3 1
      SDL_Extensions.cpp

+ 2 - 0
AI/EmptyAI/CEmptyAI.h

@@ -10,6 +10,8 @@ public:
 	void heroCreated(const CHeroInstance *);
 	void heroMoved(const HeroMoveDetails &);
 	void heroPrimarySkillChanged(const CGHeroInstance * hero, int which, int val) {};
+	void tileRevealed(int3 pos){};
+	void tileHidden(int3 pos){};
 };
 
 #define NAME "EmptyAI 0.1"

+ 0 - 266
AI/EmptyAI/Z_EmptyAI.vcproj

@@ -1,266 +0,0 @@
-<?xml version="1.0" encoding="windows-1250"?>
-<VisualStudioProject
-	ProjectType="Visual C++"
-	Version="9,00"
-	Name="Z_EmptyAI"
-	ProjectGUID="{954A9AEC-B3D0-46FA-9969-D44F069EAA23}"
-	TargetFrameworkVersion="131072"
-	>
-	<Platforms>
-		<Platform
-			Name="Win32"
-		/>
-	</Platforms>
-	<ToolFiles>
-	</ToolFiles>
-	<Configurations>
-		<Configuration
-			Name="Debug|Win32"
-			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
-			IntermediateDirectory="$(ConfigurationName)"
-			ConfigurationType="2"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="0"
-				AdditionalIncludeDirectories="G:\tp\SDL\include;&quot;E:\Program Files\Microsoft Visual Studio 8\VC\include&quot;"
-				DebugInformationFormat="3"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				OutputFile="../EmptyAI.dll"
-				Version="0.1"
-				GenerateDebugInformation="true"
-				GenerateMapFile="true"
-				MapFileName="mapfile.map"
-				MapExports="true"
-				RandomizedBaseAddress="1"
-				DataExecutionPrevention="0"
-				Profile="true"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-		<Configuration
-			Name="Release|Win32"
-			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
-			IntermediateDirectory="$(ConfigurationName)"
-			ConfigurationType="2"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="3"
-				InlineFunctionExpansion="2"
-				EnableIntrinsicFunctions="true"
-				FavorSizeOrSpeed="1"
-				OmitFramePointers="true"
-				EnableFiberSafeOptimizations="true"
-				WholeProgramOptimization="true"
-				AdditionalIncludeDirectories="G:\tp\SDL\include;&quot;E:\Program Files\Microsoft Visual Studio 8\VC\include&quot;"
-				StringPooling="true"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				OutputFile="../EmptyAI.dll"
-				LinkTimeCodeGeneration="1"
-				RandomizedBaseAddress="1"
-				DataExecutionPrevention="0"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-		<Configuration
-			Name="RD|Win32"
-			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
-			IntermediateDirectory="$(ConfigurationName)"
-			ConfigurationType="2"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="3"
-				InlineFunctionExpansion="2"
-				EnableIntrinsicFunctions="true"
-				FavorSizeOrSpeed="1"
-				OmitFramePointers="true"
-				EnableFiberSafeOptimizations="true"
-				WholeProgramOptimization="true"
-				AdditionalIncludeDirectories="G:\tp\SDL\include;&quot;E:\Program Files\Microsoft Visual Studio 8\VC\include&quot;"
-				StringPooling="true"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				OutputFile="../EmptyAI.dll"
-				LinkTimeCodeGeneration="1"
-				RandomizedBaseAddress="1"
-				DataExecutionPrevention="0"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-	</Configurations>
-	<References>
-	</References>
-	<Files>
-		<Filter
-			Name="Source Files"
-			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
-			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
-			>
-			<File
-				RelativePath=".\CEmptyAI.cpp"
-				>
-			</File>
-			<File
-				RelativePath=".\exp_funcs.cpp"
-				>
-			</File>
-		</Filter>
-		<Filter
-			Name="Header Files"
-			Filter="h;hpp;hxx;hm;inl;inc;xsd"
-			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
-			>
-			<File
-				RelativePath=".\CEmptyAI.h"
-				>
-			</File>
-		</Filter>
-		<Filter
-			Name="Resource Files"
-			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
-			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
-			>
-		</Filter>
-	</Files>
-	<Globals>
-	</Globals>
-</VisualStudioProject>

+ 29 - 26
CAdvmapInterface.cpp

@@ -636,47 +636,49 @@ void CMinimap::draw()
 	blitAt(map[LOCPLINT->adventureInt->position.z],0,0,temps);
 
 	//draw heroes
-	std::vector <const CGHeroInstance *> * hh = LOCPLINT->cb->getHeroesInfo(false);
+	std::vector <const CGHeroInstance *> hh = LOCPLINT->cb->getHeroesInfo(false);
 	int mw = map[0]->w, mh = map[0]->h,
 		wo = mw/CGI->mh->sizes.x, ho = mh/CGI->mh->sizes.y;
-	for (int i=0; i<hh->size();i++)
+
+	for (int i=0; i<hh.size();i++)
 	{
-		int3 hpos = (*hh)[i]->getPosition(false);
+		int3 hpos = hh[i]->getPosition(false);
 		float zawx = ((float)hpos.x/CGI->mh->sizes.x), zawy = ((float)hpos.y/CGI->mh->sizes.y);
 		int3 maplgp ( zawx*mw, zawy*mh, hpos.z );
 		for (int ii=0; ii<wo; ii++)
 		{
 			for (int jj=0; jj<ho; jj++)
 			{
-				SDL_PutPixel(temps,maplgp.x+ii,maplgp.y+jj,CGI->playerColors[(*hh)[i]->getOwner()].r,CGI->playerColors[(*hh)[i]->getOwner()].g,CGI->playerColors[(*hh)[i]->getOwner()].b);
+				SDL_PutPixel(temps,maplgp.x+ii,maplgp.y+jj,CGI->playerColors[hh[i]->getOwner()].r,CGI->playerColors[hh[i]->getOwner()].g,CGI->playerColors[hh[i]->getOwner()].b);
 			}
 		}
 	}
 	SDL_UpdateRect(ekran,pos.x,pos.y,pos.w,pos.h);
-	delete hh;
 
 	//draw FoW
-	for (int i=0; i<mw; i++)
-	{
-		for (int j=0; j<mh; j++)
-		{
-			int3 pp;
-			pp.x = (((float)i/mw)*CGI->mh->sizes.x);
-			pp.y = (((float)j/mh)*CGI->mh->sizes.y);
-			pp.z = LOCPLINT->adventureInt->position.z;
-			if ( !LOCPLINT->cb->isVisible(pp) )
-			{
-				for (int ii=0; ii<wo; ii++)
-				{
-					for (int jj=0; jj<ho; jj++)
-					{
-						if ((i+ii<pos.w-1) && (j+jj<pos.h-1))
-							SDL_PutPixel(temps,i+ii,j+jj,0,0,0);
-					}
-				}
-			}
-		}
-	}
+	//for (int i=0; i<mw; i++)
+	//{
+	//	for (int j=0; j<mh; j++)
+	//	{
+	//		int3 pp((((float)i/mw)*CGI->mh->sizes.x), (((float)j/mh)*CGI->mh->sizes.y), LOCPLINT->adventureInt->position.z);
+	//		/*pp.x = (((float)i/mw)*CGI->mh->sizes.x);
+	//		pp.y = (((float)j/mh)*CGI->mh->sizes.y);
+	//		pp.z = LOCPLINT->adventureInt->position.z;*/
+	//		if ( !LOCPLINT->cb->isVisible(pp) )
+	//		{
+	//			for (int ii=0; ii<wo; ii++)
+	//			{
+	//				for (int jj=0; jj<ho; jj++)
+	//				{
+	//					if ((i+ii<pos.w-1) && (j+jj<pos.h-1))
+	//						SDL_PutPixelWithoutRefresh(temps,i+ii,j+jj,0,0,0);
+	//				}
+	//			}
+	//		}
+	//	}
+	//}
+	//update(temps);
+	blitAt(FoW[LOCPLINT->adventureInt->position.z],0,0,temps);
 	
 	//draw radar
 	int bx = (((float)LOCPLINT->adventureInt->position.x)/(((float)CGI->mh->sizes.x)))*pos.w, 
@@ -707,6 +709,7 @@ void CMinimap::redraw(int level)// (level==-1) => redraw all levels
 			}
 		}
 		map.push_back(pom);
+
 	}
 }
 void CMinimap::updateRadar()

+ 3 - 1
CAdvmapInterface.h

@@ -128,7 +128,7 @@ public:
 	SDL_Surface * temps;
 	std::map<int,SDL_Color> colors;
 	std::map<int,SDL_Color> colorsBlocked;
-	std::vector<SDL_Surface *> map; //one bitmap for each level
+	std::vector<SDL_Surface *> map, FoW; //one bitmap for each level (terrain, Fog of War)
 	//TODO flagged buildings
 	std::string statusbarTxt, rcText;
 
@@ -143,6 +143,8 @@ public:
 	void mouseMoved (SDL_MouseMotionEvent & sEvent);
 	void activate(); // makes button active
 	void deactivate(); // makes button inactive (but don't deletes)
+	void hideTile(int3 pos); //puts FoW
+	void showTile(int3 pos); //removes FoW
 };
 class CTerrainRect
 	:  public ClickableL, public ClickableR, public Hoverable, public virtual CIntObject, public KeyInterested,

+ 3 - 3
CCallback.cpp

@@ -325,16 +325,16 @@ bool CCallback::isVisible(int3 pos, int Player)
 	return gs->players[Player].fogOfWarMap[pos.x][pos.y][pos.z];
 }
 
-std::vector < const CGHeroInstance *> * CCallback::getHeroesInfo(bool onlyOur)
+std::vector < const CGHeroInstance *> CCallback::getHeroesInfo(bool onlyOur)
 {
-	std::vector < const CGHeroInstance *> * ret = new std::vector < const CGHeroInstance *>();
+	std::vector < const CGHeroInstance *> ret = std::vector < const CGHeroInstance *>();
 	for ( std::map<int, PlayerState>::iterator i=gs->players.begin() ; i!=gs->players.end();i++)
 	{
 		for (int j=0;j<(*i).second.heroes.size();j++)
 		{
 			if ( ( isVisible((*i).second.heroes[j]->getPosition(false),player) ) || (*i).first==player)
 			{
-				ret->push_back((*i).second.heroes[j]);
+				ret.push_back((*i).second.heroes[j]);
 			}
 		}
 	} //	for ( std::map<int, PlayerState>::iterator i=gs->players.begin() ; i!=gs->players.end();i++)

+ 1 - 1
CCallback.h

@@ -69,7 +69,7 @@ public:
 	const CGTownInstance * getTownInfo(int val, bool mode); //mode = 0 -> val = serial; mode = 1 -> val = ID
 	int howManyTowns();
 	std::vector < std::string > getObjDescriptions(int3 pos); //returns descriptions of objects at pos in order from the lowest to the highest
-	std::vector < const CGHeroInstance *> * getHeroesInfo(bool onlyOur=true);
+	std::vector < const CGHeroInstance *> getHeroesInfo(bool onlyOur=true);
 	bool isVisible(int3 pos);
 	int getMyColor();
 	int getMySerial();

+ 34 - 34
CCursorHandler.cpp

@@ -180,58 +180,58 @@ static SDL_Cursor *init_system_cursor(const char *image[])
 
 void CCursorHandler::initCursor()
 {
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
-    int rmask = 0xff000000;
-    int gmask = 0x00ff0000;
-    int bmask = 0x0000ff00;
-    int amask = 0x000000ff;
-#else
-    int rmask = 0x000000ff;
-    int gmask = 0x0000ff00;
-    int bmask = 0x00ff0000;
-    int amask = 0xff000000;
-#endif
-	curVisible = true;
-	xpos = ypos = 0;
-	behindCur = SDL_CreateRGBSurface(SDL_SWSURFACE, 32, 32, 32, rmask, gmask, bmask, amask);
-	xbef = ybef = 0;
-	adventure = CGI->spriteh->giveDef("CRADVNTR.DEF");
-	combat = CGI->spriteh->giveDef("CRCOMBAT.DEF");
-	deflt = CGI->spriteh->giveDef("CRDEFLT.DEF");
-	spell = CGI->spriteh->giveDef("CRSPELL.DEF");
-	//SDL_SetCursor(init_system_cursor(arrow));
-	//SDL_Thread * myth = SDL_CreateThread(&cursorHandlerFunc, this);
+//#if SDL_BYTEORDER == SDL_BIG_ENDIAN
+//    int rmask = 0xff000000;
+//    int gmask = 0x00ff0000;
+//    int bmask = 0x0000ff00;
+//    int amask = 0x000000ff;
+//#else
+//    int rmask = 0x000000ff;
+//    int gmask = 0x0000ff00;
+//    int bmask = 0x00ff0000;
+//    int amask = 0xff000000;
+//#endif
+//	curVisible = true;
+//	xpos = ypos = 0;
+//	behindCur = SDL_CreateRGBSurface(SDL_SWSURFACE, 32, 32, 32, rmask, gmask, bmask, amask);
+//	xbef = ybef = 0;
+//	adventure = CGI->spriteh->giveDef("CRADVNTR.DEF");
+//	combat = CGI->spriteh->giveDef("CRCOMBAT.DEF");
+//	deflt = CGI->spriteh->giveDef("CRDEFLT.DEF");
+//	spell = CGI->spriteh->giveDef("CRSPELL.DEF");
+//	//SDL_SetCursor(init_system_cursor(arrow));
+//	//SDL_Thread * myth = SDL_CreateThread(&cursorHandlerFunc, this);
 }
 
 void CCursorHandler::changeGraphic(int type, int no)
 {
-	mode = type;
-	number = no;
+	//mode = type;
+	//number = no;
 }
 
 void CCursorHandler::cursorMove(int x, int y)
 {
-	xbef = xpos;
-	ybef = ypos;
-	xpos = x;
-	ypos = y;
+	//xbef = xpos;
+	//ybef = ypos;
+	//xpos = x;
+	//ypos = y;
 }
 
 void CCursorHandler::hardwareCursor()
 {
-	curVisible = false;
-	SDL_SetCursor(init_system_cursor(arrow2));
+	//curVisible = false;
+	//SDL_SetCursor(init_system_cursor(arrow2));
 }
 
 void CCursorHandler::hideCursor()
 {
-	curVisible = false;
-	SDL_SetCursor(init_system_cursor(arrow));
+	//curVisible = false;
+	//SDL_SetCursor(init_system_cursor(arrow));
 }
 
 void CCursorHandler::showGraphicCursor()
 {
-	curVisible = true;
-	SDL_SetCursor(init_system_cursor(arrow));
-	changeGraphic(0, 0);
+	//curVisible = true;
+	//SDL_SetCursor(init_system_cursor(arrow));
+	//changeGraphic(0, 0);
 }

+ 2 - 0
CGameInterface.h

@@ -21,6 +21,8 @@ public:
 	virtual void heroCreated(const CGHeroInstance*)=0{};
 	virtual void heroPrimarySkillChanged(const CGHeroInstance * hero, int which, int val)=0{};
 	virtual void heroMoved(const HeroMoveDetails & details)=0{};
+	virtual void tileRevealed(int3 pos)=0{};
+	virtual void tileHidden(int3 pos)=0{};
 	virtual void receivedResource(int type, int val){};
 };
 class CAIHandler

+ 58 - 3
CMT.cpp

@@ -46,6 +46,7 @@
 #include "CPlayerInterface.h"
 #include "CLuaHandler.h"
 #include "CLua.h"
+#include "CAdvmapInterface.h"
 #if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__)
 #  include <fcntl.h>
 #  include <io.h>
@@ -213,7 +214,6 @@ void initGameState(CGameInfo * cgi)
 			}
 		}
 	}
-
 	/****************************SCRIPTS************************************************/
 	std::map<int, std::map<std::string, CObjectScript*> > * skrypty = &cgi->state->objscr; //alias for easier access
 	/****************************C++ OBJECT SCRIPTS************************************************/
@@ -309,8 +309,9 @@ int _tmain(int argc, _TCHAR* argv[])
 			// well, there's no music, but most games don't break without music...
 		}*/
 
-		screen2 = SDL_SetVideoMode(800,600,24,SDL_SWSURFACE|SDL_DOUBLEBUF/*|SDL_FULLSCREEN*/);
-		screen = SDL_ConvertSurface(screen2, screen2->format, SDL_SWSURFACE);
+		//screen2 = SDL_SetVideoMode(800,600,24,SDL_SWSURFACE|SDL_DOUBLEBUF/*|SDL_FULLSCREEN*/);
+		screen = SDL_SetVideoMode(800,600,24,SDL_SWSURFACE|SDL_DOUBLEBUF/*|SDL_FULLSCREEN*/);
+		//screen = SDL_ConvertSurface(screen2, screen2->format, SDL_SWSURFACE);
 		ekran = screen;
 
 		SDL_WM_SetCaption(NAME,""); //set window title
@@ -736,6 +737,60 @@ int _tmain(int argc, _TCHAR* argv[])
 				((CPlayerInterface*)(cgi->playerint[i]))->init(new CCallback(cgi->state,cgi->scenarioOps.playerInfos[i].color));
 			}
 		}
+		///claculating FoWs for minimap
+		/****************************Minimaps' FoW******************************************/
+		for(int g=0; g<cgi->playerint.size(); ++g)
+		{
+			if(!cgi->playerint[g]->human)
+				continue;
+			CMinimap & mm = ((CPlayerInterface*)cgi->playerint[g])->adventureInt->minimap;
+
+			int mw = mm.map[0]->w, mh = mm.map[0]->h,
+				wo = mw/CGI->mh->sizes.x, ho = mh/CGI->mh->sizes.y;
+
+
+			for(int d=0; d<cgi->mh->reader->map.twoLevel+1; ++d)
+			{
+#if SDL_BYTEORDER == SDL_BIG_ENDIAN
+    int rmask = 0xff000000;
+    int gmask = 0x00ff0000;
+    int bmask = 0x0000ff00;
+    int amask = 0x000000ff;
+#else
+    int rmask = 0x000000ff;
+    int gmask = 0x0000ff00;
+    int bmask = 0x00ff0000;
+    int amask = 0xff000000;
+#endif
+				SDL_Surface * pt = SDL_CreateRGBSurface(SDL_SWSURFACE, mm.pos.w, mm.pos.h, 32, rmask, gmask, bmask, amask);
+
+				for (int i=0; i<mw; i++)
+				{
+					for (int j=0; j<mh; j++)
+					{
+						int3 pp((((float)i/mw)*CGI->mh->sizes.x), (((float)j/mh)*CGI->mh->sizes.y), d);
+						/*pp.x = (((float)i/mw)*CGI->mh->sizes.x);
+						pp.y = (((float)j/mh)*CGI->mh->sizes.y);
+						pp.z = LOCPLINT->adventureInt->position.z;*/
+						if ( !((CPlayerInterface*)cgi->playerint[g])->cb->isVisible(pp) )
+						{
+							for (int ii=0; ii<wo; ii++)
+							{
+								for (int jj=0; jj<ho; jj++)
+								{
+									if ((i+ii<mm.pos.w-1) && (j+jj<mm.pos.h-1))
+										CSDL_Ext::SDL_PutPixelWithoutRefresh(pt,i+ii,j+jj,0,0,0);
+
+								}
+							}
+						}
+					}
+				}
+				CSDL_Ext::update(pt);
+				mm.FoW.push_back(pt);
+			}
+
+		}
 
 		while(1) //main game loop, one execution per turn
 		{

+ 65 - 57
CPlayerInterface.cpp

@@ -379,21 +379,23 @@ void CPlayerInterface::yourTurn()
 
 inline void subRect(const int & x, const int & y, const int & z, SDL_Rect & r, const int & hid)
 {
-	for(int h=0; h<CGI->mh->ttiles[x][y][z].objects.size(); ++h)
-		if(CGI->mh->ttiles[x][y][z].objects[h].first->id==hid)
+	TerrainTile2 & hlp = CGI->mh->ttiles[x][y][z];
+	for(int h=0; h<hlp.objects.size(); ++h)
+		if(hlp.objects[h].first->id==hid)
 		{
-			CGI->mh->ttiles[x][y][z].objects[h].second.first = r;
-			break;
+			hlp.objects[h].second.first = r;
+			return;
 		}
 }
 
 inline void delObjRect(const int & x, const int & y, const int & z, const int & hid)
 {
-	for(int h=0; h<CGI->mh->ttiles[x][y][z].objects.size(); ++h)
-		if(CGI->mh->ttiles[x][y][z].objects[h].first->id==hid)
+	TerrainTile2 & hlp = CGI->mh->ttiles[x][y][z];
+	for(int h=0; h<hlp.objects.size(); ++h)
+		if(hlp.objects[h].first->id==hid)
 		{
-			CGI->mh->ttiles[x][y][z].objects.erase(CGI->mh->ttiles[x][y][z].objects.begin()+h);
-			break;
+			hlp.objects.erase(hlp.objects.begin()+h);
+			return;
 		}
 }
 int getDir(int3 src, int3 dst)
@@ -487,14 +489,14 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
 		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);
 
 		std::stable_sort(CGI->mh->ttiles[hp.x-3][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-3][hp.y-1][hp.z].objects.end(), ocmptwo_cgin);
-		std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][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);
-		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-2][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][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);
+		//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-3][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-3][hp.y][hp.z].objects.end(), ocmptwo_cgin);
-		std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.end(), ocmptwo_cgin);
-		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);
-		std::stable_sort(CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.end(), ocmptwo_cgin);
+		//std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.end(), ocmptwo_cgin);
+		//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);
+		//std::stable_sort(CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.end(), ocmptwo_cgin);
 	}
 	else if(details.dst.x == details.src.x && details.dst.y+1 == details.src.y) //t
 	{
@@ -516,13 +518,13 @@ 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);
 
-		std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][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);
-		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-2][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][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);
+		//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-2][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.end(), ocmptwo_cgin);
-		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);
-		std::stable_sort(CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.end(), ocmptwo_cgin);
+		//std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.end(), ocmptwo_cgin);
+		//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);
+		//std::stable_sort(CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.end(), ocmptwo_cgin);
 	}
 	else if(details.dst.x-1 == details.src.x && details.dst.y+1 == details.src.y) //tr
 	{
@@ -548,14 +550,14 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
 		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);
 		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-2][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][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);
-		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-2][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][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);
+		//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);
 
-		std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.end(), ocmptwo_cgin);
-		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);
-		std::stable_sort(CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.end(), ocmptwo_cgin);
+		//std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.end(), ocmptwo_cgin);
+		//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);
+		//std::stable_sort(CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.end(), ocmptwo_cgin);
 		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
@@ -572,14 +574,14 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
 		subRect(hp.x, hp.y, hp.z, genRect(32, 32, 63, 32), ho->id);
 		CGI->mh->ttiles[hp.x+1][hp.y][hp.z].objects.push_back(std::make_pair(ho, std::make_pair(genRect(32, 32, 95, 32), std::vector<std::list<int3>>())));
 
-		std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][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);
-		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-2][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][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);
+		//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);
 
-		std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.end(), ocmptwo_cgin);
-		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);
-		std::stable_sort(CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.end(), ocmptwo_cgin);
+		//std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.end(), ocmptwo_cgin);
+		//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);
+		//std::stable_sort(CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.end(), ocmptwo_cgin);
 		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
@@ -601,14 +603,14 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
 		CGI->mh->ttiles[hp.x][hp.y+1][hp.z].objects.push_back(std::make_pair(ho, std::make_pair(genRect(32, 32, 63, 63), std::vector<std::list<int3>>())));
 		CGI->mh->ttiles[hp.x+1][hp.y+1][hp.z].objects.push_back(std::make_pair(ho, std::make_pair(genRect(32, 32, 95, 63), std::vector<std::list<int3>>())));
 
-		std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][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);
-		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-2][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][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);
+		//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);
 
-		std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.end(), ocmptwo_cgin);
-		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);
-		std::stable_sort(CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.end(), ocmptwo_cgin);
+		//std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.end(), ocmptwo_cgin);
+		//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);
+		//std::stable_sort(CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.end(), ocmptwo_cgin);
 		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);
 
 		std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y+1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y+1][hp.z].objects.end(), ocmptwo_cgin);
@@ -632,13 +634,13 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
 		CGI->mh->ttiles[hp.x-1][hp.y+1][hp.z].objects.push_back(std::make_pair(ho, std::make_pair(genRect(32, 32, 32, 63), std::vector<std::list<int3>>())));
 		CGI->mh->ttiles[hp.x][hp.y+1][hp.z].objects.push_back(std::make_pair(ho, std::make_pair(genRect(32, 32, 64, 63), std::vector<std::list<int3>>())));
 
-		std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][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);
-		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-2][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][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);
+		//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-2][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.end(), ocmptwo_cgin);
-		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);
-		std::stable_sort(CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.end(), ocmptwo_cgin);
+		//std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.end(), ocmptwo_cgin);
+		//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);
+		//std::stable_sort(CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.end(), ocmptwo_cgin);
 
 		std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y+1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][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);
@@ -664,14 +666,14 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
 		CGI->mh->ttiles[hp.x][hp.y+1][hp.z].objects.push_back(std::make_pair(ho, std::make_pair(genRect(32, 32, 65, 63), std::vector<std::list<int3>>())));
 
 		std::stable_sort(CGI->mh->ttiles[hp.x-3][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-3][hp.y-1][hp.z].objects.end(), ocmptwo_cgin);
-		std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][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);
-		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-2][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][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);
+		//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-3][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-3][hp.y][hp.z].objects.end(), ocmptwo_cgin);
-		std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.end(), ocmptwo_cgin);
-		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);
-		std::stable_sort(CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.end(), ocmptwo_cgin);
+		//std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.end(), ocmptwo_cgin);
+		//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);
+		//std::stable_sort(CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.end(), ocmptwo_cgin);
 
 		std::stable_sort(CGI->mh->ttiles[hp.x-3][hp.y+1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-3][hp.y+1][hp.z].objects.end(), ocmptwo_cgin);
 		std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y+1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y+1][hp.z].objects.end(), ocmptwo_cgin);
@@ -693,14 +695,14 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
 		subRect(hp.x, hp.y, hp.z, genRect(32, 32, 65, 32), ho->id);
 
 		std::stable_sort(CGI->mh->ttiles[hp.x-3][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-3][hp.y-1][hp.z].objects.end(), ocmptwo_cgin);
-		std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][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);
-		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-2][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][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);
+		//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-3][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-3][hp.y][hp.z].objects.end(), ocmptwo_cgin);
-		std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.end(), ocmptwo_cgin);
-		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);
-		std::stable_sort(CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.end(), ocmptwo_cgin);
+		//std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.end(), ocmptwo_cgin);
+		//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);
+		//std::stable_sort(CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.end(), ocmptwo_cgin);
 	}
 	//first initializing done
 	SDL_framerateDelay(mainFPSmng); // after first move
@@ -1282,4 +1284,10 @@ void CPlayerInterface::removeObjToBlit(IShowable* obj)
 	objsToBlit.erase
 		(std::find(objsToBlit.begin(),objsToBlit.end(),obj));
 	//delete obj;
-}
+}
+void CPlayerInterface::tileRevealed(int3 pos)
+{
+}
+void CPlayerInterface::tileHidden(int3 pos)
+{
+}

+ 2 - 0
CPlayerInterface.h

@@ -171,6 +171,8 @@ public:
 	//overloaded funcs from Interface
 	void yourTurn();
 	void heroMoved(const HeroMoveDetails & details);
+	void tileRevealed(int3 pos);
+	void tileHidden(int3 pos);
 	void heroKilled(const CGHeroInstance*);
 	void heroCreated(const CGHeroInstance*);
 	void heroPrimarySkillChanged(const CGHeroInstance * hero, int which, int val);

+ 2 - 2
CScreenHandler.cpp

@@ -17,7 +17,7 @@ void CScreenHandler::initScreen()
 
 void CScreenHandler::updateScreen()
 {
-	blitAt(screen, 0, 0, screen2);
+	/*blitAt(screen, 0, 0, screen2);
 	switch(CGI->curh->mode)
 	{
 	case 0:
@@ -41,5 +41,5 @@ void CScreenHandler::updateScreen()
 			break;
 		}
 	}
-	CSDL_Ext::update(screen2);
+	CSDL_Ext::update(screen2);*/
 }

+ 3 - 1
SDL_Extensions.cpp

@@ -23,7 +23,7 @@ bool isItIn(const SDL_Rect * rect, int x, int y)
 		return true;
 	else return false;
 }
-SDL_Rect genRect(int hh, int ww, int xx, int yy)
+inline SDL_Rect genRect(int hh, int ww, int xx, int yy)
 {
 	SDL_Rect ret;
 	ret.h=hh;
@@ -167,6 +167,8 @@ void CSDL_Ext::SDL_PutPixelWithoutRefresh(SDL_Surface *ekran, int x, int y, Uint
 	p[0] = R;
 	p[1] = G;
 	p[2] = B;
+	if(ekran->format->BytesPerPixel==4)
+		p[3] = A;
 #endif
 }