Преглед изворни кода

GCC/AmigaOS compatibility changes by Andrea Palmaté.

Michał W. Urbańczyk пре 17 година
родитељ
комит
6f7b29afcc
80 измењених фајлова са 1262 додато и 793 уклоњено
  1. 1 1
      AI_Base.h
  2. 6 6
      AdventureMapButton.cpp
  3. 26 26
      CAdvmapInterface.cpp
  4. 14 14
      CAdvmapInterface.h
  5. 12 12
      CBattleInterface.cpp
  6. 1 1
      CBattleInterface.h
  7. 46 38
      CCallback.cpp
  8. 17 8
      CCallback.h
  9. 44 32
      CCastleInterface.cpp
  10. 2 2
      CCastleInterface.h
  11. 14 4
      CConsoleHandler.cpp
  12. 5 1
      CConsoleHandler.h
  13. 1 1
      CCursorHandler.cpp
  14. 1 1
      CCursorHandler.h
  15. 1 1
      CGameInfo.cpp
  16. 2 1
      CGameInfo.h
  17. 9 1
      CGameInterface.cpp
  18. 13 13
      CGameInterface.h
  19. 17 5
      CGameState.h
  20. 26 10
      CHeroWindow.cpp
  21. 1 1
      CHeroWindow.h
  22. 53 21
      CLua.cpp
  23. 6 6
      CLua.h
  24. 9 5
      CLuaHandler.cpp
  25. 1 1
      CLuaHandler.h
  26. 60 48
      CMT.cpp
  27. 35 35
      CMessage.cpp
  28. 8 6
      CMessage.h
  29. 13 13
      CPathfinder.cpp
  30. 6 6
      CPathfinder.h
  31. 61 61
      CPlayerInterface.cpp
  32. 16 16
      CPlayerInterface.h
  33. BIN
      CPreGame.cpp
  34. 30 23
      CPreGame.h
  35. 2 2
      CScreenHandler.cpp
  36. 1 1
      CScreenHandler.h
  37. 45 26
      SDL_Extensions.cpp
  38. 1 1
      SDL_Extensions.h
  39. 7 3
      StartInfo.h
  40. 18 9
      global.h
  41. 1 1
      hch/CAbilityHandler.h
  42. 80 77
      hch/CAmbarCendamo.cpp
  43. 2 2
      hch/CAmbarCendamo.h
  44. 1 1
      hch/CArtHandler.h
  45. 10 6
      hch/CBuildingHandler.cpp
  46. 1 1
      hch/CBuildingHandler.h
  47. 2 2
      hch/CCastleHandler.h
  48. 19 15
      hch/CCreatureHandler.cpp
  49. 3 3
      hch/CCreatureHandler.h
  50. BIN
      hch/CDefHandler.cpp
  51. BIN
      hch/CDefHandler.h
  52. 3 3
      hch/CDefObjInfoHandler.h
  53. 2 1
      hch/CGeneralTextHandler.cpp
  54. 1 1
      hch/CGeneralTextHandler.h
  55. 1 1
      hch/CHeroHandler.h
  56. 17 17
      hch/CLodHandler.cpp
  57. 2 2
      hch/CLodHandler.h
  58. 48 48
      hch/CMusicHandler.cpp
  59. 1 1
      hch/CMusicHandler.h
  60. 6 6
      hch/CObjectHandler.cpp
  61. 8 8
      hch/CObjectHandler.h
  62. 1 1
      hch/CPreGameTextHandler.h
  63. 2 2
      hch/CSemiDefHandler.h
  64. 1 1
      hch/CSemiLodHandler.h
  65. 12 4
      hch/CSndHandler.cpp
  66. 1 1
      hch/CSndHandler.h
  67. 1 1
      hch/CSpellHandler.h
  68. 9 5
      hch/CTownHandler.cpp
  69. 1 1
      hch/CTownHandler.h
  70. 21 7
      hch/CVideoHandler.cpp
  71. 20 8
      hch/CVideoHandler.h
  72. 5 5
      int3.h
  73. 21 21
      map.cpp
  74. 18 18
      map.h
  75. 35 29
      mapHandler.cpp
  76. 6 6
      mapHandler.h
  77. 29 24
      nodrze.h
  78. 4 0
      stdafx.h
  79. 235 0
      tchar_amigaos4.h
  80. 1 1
      timeHandler.h

+ 1 - 1
AI_Base.h

@@ -13,4 +13,4 @@
 	#define VCMI_API __attribute__ ((visibility("default")))
 	#define VCMI_API __attribute__ ((visibility("default")))
 #else
 #else
 	#define VCMI_EXPORT extern "C"
 	#define VCMI_EXPORT extern "C"
-#endif
+#endif

+ 6 - 6
AdventureMapButton.cpp

@@ -1,9 +1,9 @@
 #include "CAdvmapInterface.h"
 #include "CAdvmapInterface.h"
 #include "SDL_Extensions.h"
 #include "SDL_Extensions.h"
-#include "hch\CDefHandler.h"
+#include "hch/CDefHandler.h"
 #include "CGameInfo.h"
 #include "CGameInfo.h"
-#include "hch\CLodHandler.h"
-#include "hch\CPreGameTextHandler.h"
+#include "hch/CLodHandler.h"
+#include "hch/CPreGameTextHandler.h"
 #include "hch/CTownHandler.h"
 #include "hch/CTownHandler.h"
 #include "CLua.h"
 #include "CLua.h"
 #include "CCallback.h"
 #include "CCallback.h"
@@ -31,7 +31,7 @@ AdventureMapButton::AdventureMapButton
 	helpBox=HelpBox;
 	helpBox=HelpBox;
 	colorChange = playerColoredButton;
 	colorChange = playerColoredButton;
 	int est = LOCPLINT->playerID;
 	int est = LOCPLINT->playerID;
-	CDefHandler * temp = CGI->spriteh->giveDef(defName); 
+	CDefHandler * temp = CGI->spriteh->giveDef(defName);
 	temp->notFreeImgs = true;
 	temp->notFreeImgs = true;
 	for (int i=0;i<temp->ourImages.size();i++)
 	for (int i=0;i<temp->ourImages.size();i++)
 	{
 	{
@@ -73,7 +73,7 @@ void AdventureMapButton::clickLeft (tribool down)
 	{
 	{
 		state=1;
 		state=1;
 	}
 	}
-	else 
+	else
 	{
 	{
 		state=0;
 		state=0;
 	}
 	}
@@ -263,4 +263,4 @@ CSlider::CSlider(int x, int y, int totalw, boost::function<void(int)> Moved, int
 	slider.actOnDown = true;
 	slider.actOnDown = true;
 
 
 	moveTo(value);
 	moveTo(value);
-}
+}

+ 26 - 26
CAdvmapInterface.cpp

@@ -1,10 +1,10 @@
 #include "stdafx.h"
 #include "stdafx.h"
 #include "CAdvmapInterface.h"
 #include "CAdvmapInterface.h"
-#include "hch\CLodHandler.h"
+#include "hch/CLodHandler.h"
 #include "CPlayerInterface.h"
 #include "CPlayerInterface.h"
-#include "hch\CPreGameTextHandler.h"
-#include "hch\CGeneralTextHandler.h"
-#include "hch\CTownHandler.h"
+#include "hch/CPreGameTextHandler.h"
+#include "hch/CGeneralTextHandler.h"
+#include "hch/CTownHandler.h"
 #include "CPathfinder.h"
 #include "CPathfinder.h"
 #include "CGameInfo.h"
 #include "CGameInfo.h"
 #include "SDL_Extensions.h"
 #include "SDL_Extensions.h"
@@ -19,7 +19,7 @@
 #include <sstream>
 #include <sstream>
 #include "AdventureMapButton.h"
 #include "AdventureMapButton.h"
 #include "CHeroWindow.h"
 #include "CHeroWindow.h"
-#pragma warning (disable : 4355) 
+#pragma warning (disable : 4355)
 extern TTF_Font * TNRB16, *TNR, *GEOR13, *GEORXX; //fonts
 extern TTF_Font * TNRB16, *TNR, *GEOR13, *GEORXX; //fonts
 
 
 using namespace boost::logic;
 using namespace boost::logic;
@@ -32,7 +32,7 @@ CAdvMapInt::~CAdvMapInt()
 }
 }
 CMinimap::CMinimap(bool draw)
 CMinimap::CMinimap(bool draw)
 {
 {
-	statusbarTxt = CGI->preth->zelp[291].first;  
+	statusbarTxt = CGI->preth->zelp[291].first;
 	rcText = CGI->preth->zelp[291].second;
 	rcText = CGI->preth->zelp[291].second;
 	pos.x=630;
 	pos.x=630;
 	pos.y=26;
 	pos.y=26;
@@ -60,7 +60,7 @@ CMinimap::CMinimap(bool draw)
 			SDL_PutPixel(radar,radar->w-1,i,255,75,125);
 			SDL_PutPixel(radar,radar->w-1,i,255,75,125);
 		}
 		}
 	}
 	}
-	SDL_SetColorKey(radar,SDL_SRCCOLORKEY,SDL_MapRGB(radar->format,0,255,255));	
+	SDL_SetColorKey(radar,SDL_SRCCOLORKEY,SDL_MapRGB(radar->format,0,255,255));
 
 
 	//radar = CGI->spriteh->giveDef("RADAR.DEF");
 	//radar = CGI->spriteh->giveDef("RADAR.DEF");
 	std::ifstream is("config/minimap.txt",std::ifstream::in);
 	std::ifstream is("config/minimap.txt",std::ifstream::in);
@@ -82,7 +82,7 @@ CMinimap::CMinimap(bool draw)
 		is >> pom;
 		is >> pom;
 		vinya2.second.g=pom;
 		vinya2.second.g=pom;
 		is >> pom;
 		is >> pom;
-		vinya2.second.b=pom;	
+		vinya2.second.b=pom;
 		vinya.second.unused=vinya2.second.unused=255;
 		vinya.second.unused=vinya2.second.unused=255;
 		colors.insert(vinya);
 		colors.insert(vinya);
 		colorsBlocked.insert(vinya2);
 		colorsBlocked.insert(vinya2);
@@ -117,9 +117,9 @@ void CMinimap::draw()
 		}
 		}
 	}
 	}
 	blitAt(FoW[LOCPLINT->adventureInt->position.z],0,0,temps);
 	blitAt(FoW[LOCPLINT->adventureInt->position.z],0,0,temps);
-	
+
 	//draw radar
 	//draw radar
-	int bx = (((float)LOCPLINT->adventureInt->position.x)/(((float)CGI->mh->sizes.x)))*pos.w, 
+	int bx = (((float)LOCPLINT->adventureInt->position.x)/(((float)CGI->mh->sizes.x)))*pos.w,
 		by = (((float)LOCPLINT->adventureInt->position.y)/(((float)CGI->mh->sizes.y)))*pos.h;
 		by = (((float)LOCPLINT->adventureInt->position.y)/(((float)CGI->mh->sizes.y)))*pos.h;
 	blitAt(radar,bx,by,temps);
 	blitAt(radar,bx,by,temps);
 	blitAt(temps,pos.x,pos.y);
 	blitAt(temps,pos.x,pos.y);
@@ -169,7 +169,7 @@ void CMinimap::clickLeft (tribool down)
 	ClickableL::clickLeft(down);
 	ClickableL::clickLeft(down);
 	if (!((bool)down))
 	if (!((bool)down))
 		return;
 		return;
-	
+
 	float dx=((float)(LOCPLINT->current->motion.x-pos.x))/((float)pos.w),
 	float dx=((float)(LOCPLINT->current->motion.x-pos.x))/((float)pos.w),
 		dy=((float)(LOCPLINT->current->motion.y-pos.y))/((float)pos.h);
 		dy=((float)(LOCPLINT->current->motion.y-pos.y))/((float)pos.h);
 
 
@@ -248,7 +248,7 @@ void CTerrainRect::activate()
 	Hoverable::activate();
 	Hoverable::activate();
 	KeyInterested::activate();
 	KeyInterested::activate();
 	MotionInterested::activate();
 	MotionInterested::activate();
-}; 
+};
 void CTerrainRect::deactivate()
 void CTerrainRect::deactivate()
 {
 {
 	ClickableL::deactivate();
 	ClickableL::deactivate();
@@ -256,7 +256,7 @@ void CTerrainRect::deactivate()
 	Hoverable::deactivate();
 	Hoverable::deactivate();
 	KeyInterested::deactivate();
 	KeyInterested::deactivate();
 	MotionInterested::deactivate();
 	MotionInterested::deactivate();
-}; 
+};
 void CTerrainRect::clickLeft(tribool down)
 void CTerrainRect::clickLeft(tribool down)
 {
 {
 	LOGE("Left mouse button down2");
 	LOGE("Left mouse button down2");
@@ -304,7 +304,7 @@ void CTerrainRect::clickLeft(tribool down)
 	}
 	}
 	const CGHeroInstance * currentHero = (LOCPLINT->adventureInt->heroList.items.size())?(LOCPLINT->adventureInt->heroList.items[LOCPLINT->adventureInt->heroList.selected].first):(NULL);
 	const CGHeroInstance * currentHero = (LOCPLINT->adventureInt->heroList.items.size())?(LOCPLINT->adventureInt->heroList.items[LOCPLINT->adventureInt->heroList.selected].first):(NULL);
 	if(!currentHero)
 	if(!currentHero)
-		return; 
+		return;
 	int3 bufpos = currentHero->getPosition(false);
 	int3 bufpos = currentHero->getPosition(false);
 	//bufpos.x-=1;
 	//bufpos.x-=1;
 	if (mres)
 	if (mres)
@@ -327,7 +327,7 @@ void CTerrainRect::mouseMoved (SDL_MouseMotionEvent & sEvent)
 	int3 pom=LOCPLINT->adventureInt->verifyPos(whichTileIsIt(sEvent.x,sEvent.y));
 	int3 pom=LOCPLINT->adventureInt->verifyPos(whichTileIsIt(sEvent.x,sEvent.y));
 	if (pom!=curHoveredTile)
 	if (pom!=curHoveredTile)
 		curHoveredTile=pom;
 		curHoveredTile=pom;
-	else 
+	else
 		return;
 		return;
 	std::vector<std::string> temp = LOCPLINT->cb->getObjDescriptions(pom);
 	std::vector<std::string> temp = LOCPLINT->cb->getObjDescriptions(pom);
 	if (temp.size())
 	if (temp.size())
@@ -619,13 +619,13 @@ void CResDataBar::draw()
 	char * buf = new char[15];
 	char * buf = new char[15];
 	for (int i=0;i<7;i++)
 	for (int i=0;i<7;i++)
 	{
 	{
-		itoa(LOCPLINT->cb->getResourceAmount(i),buf,10);
+		SDL_itoa(LOCPLINT->cb->getResourceAmount(i),buf,10);
 		printAt(buf,txtpos[i].first,txtpos[i].second,GEOR13,zwykly);
 		printAt(buf,txtpos[i].first,txtpos[i].second,GEOR13,zwykly);
 	}
 	}
 	std::vector<std::string> temp;
 	std::vector<std::string> temp;
-	itoa(LOCPLINT->cb->getDate(3),buf,10); temp+=std::string(buf);
-	itoa(LOCPLINT->cb->getDate(2),buf,10); temp+=std::string(buf);
-	itoa(LOCPLINT->cb->getDate(1),buf,10); temp+=std::string(buf);
+	SDL_itoa(LOCPLINT->cb->getDate(3),buf,10); temp+=std::string(buf);
+	SDL_itoa(LOCPLINT->cb->getDate(2),buf,10); temp+=std::string(buf);
+	SDL_itoa(LOCPLINT->cb->getDate(1),buf,10); temp+=std::string(buf);
 	printAt(processStr(datetext,temp),txtpos[7].first,txtpos[7].second,GEOR13,zwykly);
 	printAt(processStr(datetext,temp),txtpos[7].first,txtpos[7].second,GEOR13,zwykly);
 	temp.clear();
 	temp.clear();
 	//updateRect(&pos,screen);
 	//updateRect(&pos,screen);
@@ -672,7 +672,7 @@ void CInfoBar::draw(const CGObjectInstance * specific)
 		draw((const CGObjectInstance *)LOCPLINT->adventureInt->selection.selected);
 		draw((const CGObjectInstance *)LOCPLINT->adventureInt->selection.selected);
 	}
 	}
 	if (!specific)
 	if (!specific)
-		specific = (const CGObjectInstance *)LOCPLINT->adventureInt->selection.selected; 
+		specific = (const CGObjectInstance *)LOCPLINT->adventureInt->selection.selected;
 	//TODO: to rzutowanie wyglada groznie, ale dziala. Ale nie powinno wygladac groznie.
 	//TODO: to rzutowanie wyglada groznie, ale dziala. Ale nie powinno wygladac groznie.
 
 
 	if(!specific)
 	if(!specific)
@@ -745,7 +745,7 @@ void CInfoBar::newDay(int Day)
 	{
 	{
 		mode = 0; //showing day
 		mode = 0; //showing day
 	}
 	}
-	else 
+	else
 	{
 	{
 		switch(LOCPLINT->cb->getDate(2))
 		switch(LOCPLINT->cb->getDate(2))
 		{
 		{
@@ -867,7 +867,7 @@ townList(5,&genRect(192,48,747,196),747,196,747,372)
 	townList.genList();
 	townList.genList();
 
 
 	heroWindow = new CHeroWindow(this->player);
 	heroWindow = new CHeroWindow(this->player);
-	
+
 	gems.push_back(CGI->spriteh->giveDef("agemLL.def"));
 	gems.push_back(CGI->spriteh->giveDef("agemLL.def"));
 	gems.push_back(CGI->spriteh->giveDef("agemLR.def"));
 	gems.push_back(CGI->spriteh->giveDef("agemLR.def"));
 	gems.push_back(CGI->spriteh->giveDef("agemUL.def"));
 	gems.push_back(CGI->spriteh->giveDef("agemUL.def"));
@@ -887,7 +887,7 @@ void CAdvMapInt::fswitchLevel()
 		underground.curimg=0;
 		underground.curimg=0;
 		underground.show();
 		underground.show();
 	}
 	}
-	else 
+	else
 	{
 	{
 		underground.curimg=1;
 		underground.curimg=1;
 		position.z++;
 		position.z++;
@@ -931,7 +931,7 @@ void CAdvMapInt::fendTurn()
 void CAdvMapInt::activate()
 void CAdvMapInt::activate()
 {
 {
 	LOCPLINT->curint = this;
 	LOCPLINT->curint = this;
-	LOCPLINT->statusbar = &statusbar;	
+	LOCPLINT->statusbar = &statusbar;
 	kingOverview.activate();
 	kingOverview.activate();
 	underground.activate();
 	underground.activate();
 	questlog.activate();
 	questlog.activate();
@@ -1050,7 +1050,7 @@ CAdvMapInt::CurrentSelection::CurrentSelection()
 	selected=NULL;
 	selected=NULL;
 }
 }
 void CAdvMapInt::handleRightClick(std::string text, tribool down, CIntObject * client)
 void CAdvMapInt::handleRightClick(std::string text, tribool down, CIntObject * client)
-{	
+{
 	if (down)
 	if (down)
 	{
 	{
 		boost::algorithm::erase_all(text,"\"");
 		boost::algorithm::erase_all(text,"\"");
@@ -1091,4 +1091,4 @@ int3 CAdvMapInt::verifyPos(int3 ver)
 	if (ver.z>=CGI->mh->sizes.z)
 	if (ver.z>=CGI->mh->sizes.z)
 		ver.z=CGI->mh->sizes.z-1;
 		ver.z=CGI->mh->sizes.z-1;
 	return ver;
 	return ver;
-}
+}

+ 14 - 14
CAdvmapInterface.h

@@ -8,7 +8,7 @@
 #include "AdventureMapButton.h"
 #include "AdventureMapButton.h"
 class CDefHandler;
 class CDefHandler;
 class CCallback;
 class CCallback;
-struct CPath; 
+struct CPath;
 class CAdvMapInt;
 class CAdvMapInt;
 class CGHeroInstance;
 class CGHeroInstance;
 class CGTownInstance;
 class CGTownInstance;
@@ -18,7 +18,7 @@ class CMinimap
 	: public ClickableL, public ClickableR, public Hoverable, public MotionInterested, public virtual CIntObject
 	: public ClickableL, public ClickableR, public Hoverable, public MotionInterested, public virtual CIntObject
 {
 {
 public:
 public:
-	SDL_Surface * radar; 
+	SDL_Surface * radar;
 	SDL_Surface * temps;
 	SDL_Surface * temps;
 	std::map<int,SDL_Color> colors;
 	std::map<int,SDL_Color> colors;
 	std::map<int,SDL_Color> colorsBlocked;
 	std::map<int,SDL_Color> colorsBlocked;
@@ -26,7 +26,7 @@ public:
 	//TODO flagged buildings
 	//TODO flagged buildings
 	std::string statusbarTxt, rcText;
 	std::string statusbarTxt, rcText;
 
 
-	CMinimap(bool draw=true); 
+	CMinimap(bool draw=true);
 	void draw();
 	void draw();
 	void redraw(int level=-1);// (level==-1) => redraw all levels
 	void redraw(int level=-1);// (level==-1) => redraw all levels
 	void updateRadar();
 	void updateRadar();
@@ -51,7 +51,7 @@ public:
 	CDefHandler * arrows;
 	CDefHandler * arrows;
 	CTerrainRect();
 	CTerrainRect();
 	CPath * currentPath;
 	CPath * currentPath;
-	void activate(); 
+	void activate();
 	void deactivate();
 	void deactivate();
 	void clickLeft(tribool down);
 	void clickLeft(tribool down);
 	void clickRight(tribool down);
 	void clickRight(tribool down);
@@ -60,7 +60,7 @@ public:
 	void keyPressed (SDL_KeyboardEvent & key);
 	void keyPressed (SDL_KeyboardEvent & key);
 	void show();
 	void show();
 	void showPath();
 	void showPath();
-	int3 whichTileIsIt(int x, int y); //x,y are cursor position 
+	int3 whichTileIsIt(int x, int y); //x,y are cursor position
 	int3 whichTileIsIt(); //uses current cursor pos
 	int3 whichTileIsIt(); //uses current cursor pos
 };
 };
 class CResDataBar
 class CResDataBar
@@ -72,7 +72,7 @@ public:
 	std::string datetext;
 	std::string datetext;
 
 
 	void clickRight (tribool down);
 	void clickRight (tribool down);
-	void activate(); 
+	void activate();
 	void deactivate();
 	void deactivate();
 	CResDataBar();
 	CResDataBar();
 	~CResDataBar();
 	~CResDataBar();
@@ -108,7 +108,7 @@ public:
 	int player;
 	int player;
 
 
 	std::vector<CDefHandler *> gems;
 	std::vector<CDefHandler *> gems;
-	
+
 	bool scrollingLeft ;
 	bool scrollingLeft ;
 	bool scrollingRight ;
 	bool scrollingRight ;
 	bool scrollingUp ;
 	bool scrollingUp ;
@@ -128,7 +128,7 @@ public:
 		moveHero, //- move hero
 		moveHero, //- move hero
 		spellbook,//- spellbook
 		spellbook,//- spellbook
 		advOptions, //- adventure options
 		advOptions, //- adventure options
-		sysOptions,//- system options	
+		sysOptions,//- system options
 		nextHero, //- next hero
 		nextHero, //- next hero
 		endTurn;//- end turn
 		endTurn;//- end turn
 	//CHeroList herolist;
 	//CHeroList herolist;
@@ -137,13 +137,13 @@ public:
 
 
 	CStatusBar statusbar;
 	CStatusBar statusbar;
 	CResDataBar resdatabar;
 	CResDataBar resdatabar;
-	
+
 	CHeroList heroList;
 	CHeroList heroList;
-	CTownList townList;	
+	CTownList townList;
 	CInfoBar infoBar;
 	CInfoBar infoBar;
 
 
 	CHeroWindow * heroWindow;
 	CHeroWindow * heroWindow;
-	
+
 	struct CurrentSelection
 	struct CurrentSelection
 	{
 	{
 		int type; //0 - hero, 1 - town
 		int type; //0 - hero, 1 - town
@@ -153,8 +153,8 @@ public:
 
 
 	//fuctions binded to buttons
 	//fuctions binded to buttons
 	void fshowOverview();
 	void fshowOverview();
-	void fswitchLevel(); 
-	void fshowQuestlog(); 
+	void fswitchLevel();
+	void fshowQuestlog();
 	void fsleepWake();
 	void fsleepWake();
 	void fmoveHero();
 	void fmoveHero();
 	void fshowSpellbok();
 	void fshowSpellbok();
@@ -177,4 +177,4 @@ public:
 
 
 
 
 };
 };
-#endif //CADVENTUREMAPINTERFACE_H
+#endif //CADVENTUREMAPINTERFACE_H

+ 12 - 12
CBattleInterface.cpp

@@ -1,14 +1,14 @@
 #include "CBattleInterface.h"
 #include "CBattleInterface.h"
 #include "CGameInfo.h"
 #include "CGameInfo.h"
-#include "hch\CLodHandler.h"
+#include "hch/CLodHandler.h"
 #include "SDL_Extensions.h"
 #include "SDL_Extensions.h"
 #include "CAdvmapInterface.h"
 #include "CAdvmapInterface.h"
 #include "AdventureMapButton.h"
 #include "AdventureMapButton.h"
-#include "hch\CHeroHandler.h"
-#include "hch\CDefHandler.h"
+#include "hch/CHeroHandler.h"
+#include "hch/CDefHandler.h"
 #include "CCallback.h"
 #include "CCallback.h"
 #include "CGameState.h"
 #include "CGameState.h"
-#include "hch\CGeneralTextHandler.h"
+#include "hch/CGeneralTextHandler.h"
 #include <queue>
 #include <queue>
 #include <sstream>
 #include <sstream>
 
 
@@ -17,7 +17,7 @@ extern TTF_Font * GEOR13;
 extern SDL_Color zwykly;
 extern SDL_Color zwykly;
 SDL_Surface * CBattleInterface::cellBorder, * CBattleInterface::cellShade;
 SDL_Surface * CBattleInterface::cellBorder, * CBattleInterface::cellShade;
 
 
-CBattleInterface::CBattleInterface(CCreatureSet * army1, CCreatureSet * army2, CGHeroInstance *hero1, CGHeroInstance *hero2) 
+CBattleInterface::CBattleInterface(CCreatureSet * army1, CCreatureSet * army2, CGHeroInstance *hero1, CGHeroInstance *hero2)
 : printCellBorders(true), attackingHeroInstance(hero1), defendingHeroInstance(hero2), animCount(0), activeStack(-1), givenCommand(NULL), attackingInfo(NULL)
 : printCellBorders(true), attackingHeroInstance(hero1), defendingHeroInstance(hero2), animCount(0), activeStack(-1), givenCommand(NULL), attackingInfo(NULL)
 {
 {
 	//initializing armies
 	//initializing armies
@@ -58,7 +58,7 @@ CBattleInterface::CBattleInterface(CCreatureSet * army1, CCreatureSet * army2, C
 	blitAt(background, 0, 0);
 	blitAt(background, 0, 0);
 	blitAt(menu, 0, 556);
 	blitAt(menu, 0, 556);
 	CSDL_Ext::update();
 	CSDL_Ext::update();
-	
+
 	//preparing buttons and console
 	//preparing buttons and console
 	bOptions = new AdventureMapButton (std::string(), std::string(), boost::bind(&CBattleInterface::bOptionsf,this), 3, 561, "icm003.def", false, NULL, false);
 	bOptions = new AdventureMapButton (std::string(), std::string(), boost::bind(&CBattleInterface::bOptionsf,this), 3, 561, "icm003.def", false, NULL, false);
 	bSurrender = new AdventureMapButton (std::string(), std::string(), boost::bind(&CBattleInterface::bSurrenderf,this), 54, 561, "icm001.def", false, NULL, false);
 	bSurrender = new AdventureMapButton (std::string(), std::string(), boost::bind(&CBattleInterface::bSurrenderf,this), 54, 561, "icm001.def", false, NULL, false);
@@ -75,7 +75,7 @@ CBattleInterface::CBattleInterface(CCreatureSet * army1, CCreatureSet * army2, C
 	console->pos.y = 560;
 	console->pos.y = 560;
 	console->pos.w = 406;
 	console->pos.w = 406;
 	console->pos.h = 38;
 	console->pos.h = 38;
-	
+
 	//loading hero animations
 	//loading hero animations
 	if(hero1) // attacking hero
 	if(hero1) // attacking hero
 	{
 	{
@@ -104,7 +104,7 @@ CBattleInterface::CBattleInterface(CCreatureSet * army1, CCreatureSet * army2, C
 	for(int h=0; h<187; ++h)
 	for(int h=0; h<187; ++h)
 	{
 	{
 		bfield[h].myNumber = h;
 		bfield[h].myNumber = h;
-		
+
 		int x = 14 + ((h/17)%2==0 ? 22 : 0) + 44*(h%17);
 		int x = 14 + ((h/17)%2==0 ? 22 : 0) + 44*(h%17);
 		int y = 86 + 42 * (h/17);
 		int y = 86 + 42 * (h/17);
 		bfield[h].pos = genRect(cellShade->h, cellShade->w, x, y);
 		bfield[h].pos = genRect(cellShade->h, cellShade->w, x, y);
@@ -422,7 +422,7 @@ void CBattleInterface::stackKilled(int ID, int dmg, int killed, int IDby)
 		CSDL_Ext::update();
 		CSDL_Ext::update();
 		SDL_framerateDelay(LOCPLINT->mainFPSmng);
 		SDL_framerateDelay(LOCPLINT->mainFPSmng);
 	}
 	}
-	
+
 	printConsoleAttacked(ID, dmg, killed, IDby);
 	printConsoleAttacked(ID, dmg, killed, IDby);
 }
 }
 
 
@@ -451,7 +451,7 @@ void CBattleInterface::stackMoved(int number, int destHex, bool startMoving, boo
 
 
 	int mutPos = CBattleHex::mutualPosition(curStackPos, destHex);
 	int mutPos = CBattleHex::mutualPosition(curStackPos, destHex);
 
 
-	if(LOCPLINT->cb->battleGetCreature(number).isDoubleWide() && 
+	if(LOCPLINT->cb->battleGetCreature(number).isDoubleWide() &&
 		((creDir[number] && mutPos == 5) || (creDir[number] && mutPos == 0) || (creDir[number] && mutPos == 4))) //for special cases
 		((creDir[number] && mutPos == 5) || (creDir[number] && mutPos == 0) || (creDir[number] && mutPos == 4))) //for special cases
 	{
 	{
 		switch(CBattleHex::mutualPosition(curStackPos, destHex)) //reverse unit if necessary
 		switch(CBattleHex::mutualPosition(curStackPos, destHex)) //reverse unit if necessary
@@ -602,7 +602,7 @@ void CBattleInterface::stackMoved(int number, int destHex, bool startMoving, boo
 			reverseCreature(number, destHex);
 			reverseCreature(number, destHex);
 		//creDir[number] = (curs.owner == attackingHeroInstance->tempOwner);
 		//creDir[number] = (curs.owner == attackingHeroInstance->tempOwner);
 	}
 	}
-	
+
 	std::pair <int, int> coords = CBattleHex::getXYUnitAnim(destHex, creDir[number], curs.creature);
 	std::pair <int, int> coords = CBattleHex::getXYUnitAnim(destHex, creDir[number], curs.creature);
 	creAnims[number]->pos.x = coords.first;
 	creAnims[number]->pos.x = coords.first;
 	creAnims[number]->pos.y = coords.second;
 	creAnims[number]->pos.y = coords.second;
@@ -957,7 +957,7 @@ CBattleHero::CBattleHero(std::string defName, int phaseG, int imageG, bool flipG
 		if(flip)
 		if(flip)
 		{
 		{
 			SDL_Surface * hlp = CSDL_Ext::rotate01(dh->ourImages[i].bitmap);
 			SDL_Surface * hlp = CSDL_Ext::rotate01(dh->ourImages[i].bitmap);
-			SDL_FreeSurface(dh->ourImages[i].bitmap); 
+			SDL_FreeSurface(dh->ourImages[i].bitmap);
 			dh->ourImages[i].bitmap = hlp;
 			dh->ourImages[i].bitmap = hlp;
 		}
 		}
 		dh->ourImages[i].bitmap = CSDL_Ext::alphaTransform(dh->ourImages[i].bitmap);
 		dh->ourImages[i].bitmap = CSDL_Ext::alphaTransform(dh->ourImages[i].bitmap);

+ 1 - 1
CBattleInterface.h

@@ -148,5 +148,5 @@ public:
 	void newRound(int number); //caled when round is ended; number is the number of round
 	void newRound(int number); //caled when round is ended; number is the number of round
 	void hexLclicked(int whichOne); //hex only call-in
 	void hexLclicked(int whichOne); //hex only call-in
 
 
-	friend CBattleHex;
+	friend class CBattleHex;
 };
 };

+ 46 - 38
CCallback.cpp

@@ -1,10 +1,10 @@
 #include "stdafx.h"
 #include "stdafx.h"
 #include "CCallback.h"
 #include "CCallback.h"
 #include "CPathfinder.h"
 #include "CPathfinder.h"
-#include "hch\CHeroHandler.h"
-#include "hch\CTownHandler.h"
+#include "hch/CHeroHandler.h"
+#include "hch/CTownHandler.h"
 #include "CGameInfo.h"
 #include "CGameInfo.h"
-#include "hch\CAmbarCendamo.h"
+#include "hch/CAmbarCendamo.h"
 #include "mapHandler.h"
 #include "mapHandler.h"
 #include "CGameState.h"
 #include "CGameState.h"
 #include "CPlayerInterface.h"
 #include "CPlayerInterface.h"
@@ -13,12 +13,13 @@
 #include "CAdvmapInterface.h"
 #include "CAdvmapInterface.h"
 #include "CPlayerInterface.h"
 #include "CPlayerInterface.h"
 #include "hch/CBuildingHandler.h"
 #include "hch/CBuildingHandler.h"
+
 LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...);
 LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...);
 
 
 int CCallback::lowestSpeed(CGHeroInstance * chi)
 int CCallback::lowestSpeed(CGHeroInstance * chi)
 {
 {
 	int min = 150;
 	int min = 150;
-	for (  std::map<int,std::pair<CCreature*,int> >::iterator i = chi->army.slots.begin(); 
+	for (  std::map<int,std::pair<CCreature*,int> >::iterator i = chi->army.slots.begin();
 		   i!=chi->army.slots.end();		 i++													)
 		   i!=chi->army.slots.end();		 i++													)
 	{
 	{
 		if (min>(*i).second.first->speed)
 		if (min>(*i).second.first->speed)
@@ -29,9 +30,9 @@ int CCallback::lowestSpeed(CGHeroInstance * chi)
 int CCallback::valMovePoints(CGHeroInstance * chi)
 int CCallback::valMovePoints(CGHeroInstance * chi)
 {
 {
 	int ret = 1270+70*lowestSpeed(chi);
 	int ret = 1270+70*lowestSpeed(chi);
-	if (ret>2000) 
+	if (ret>2000)
 		ret=2000;
 		ret=2000;
-	
+
 	//TODO: additional bonuses (but they aren't currently stored in chi)
 	//TODO: additional bonuses (but they aren't currently stored in chi)
 
 
 	return ret;
 	return ret;
@@ -113,9 +114,12 @@ bool CCallback::moveHero(int ID, CPath * path, int idtype, int pathType)
 	if (pathType==0)
 	if (pathType==0)
 		CPathfinder::convertPath(path,pathType);
 		CPathfinder::convertPath(path,pathType);
 	if (pathType>1)
 	if (pathType>1)
+#ifndef __GNUC__
 		throw std::exception("Unknown path format");
 		throw std::exception("Unknown path format");
-
-	CPath * ourPath = path; 
+#else
+		throw std::exception();
+#endif
+	CPath * ourPath = path;
 	if(!ourPath)
 	if(!ourPath)
 		return false;
 		return false;
 	for(int i=ourPath->nodes.size()-1; i>0; i--)
 	for(int i=ourPath->nodes.size()-1; i>0; i--)
@@ -136,7 +140,7 @@ bool CCallback::moveHero(int ID, CPath * path, int idtype, int pathType)
 		{ //performing move
 		{ //performing move
 			hero->movement -= (ourPath->nodes.size()>=2 ?  (*(ourPath->nodes.end()-2)).dist : 0) - ourPath->nodes[i].dist;
 			hero->movement -= (ourPath->nodes.size()>=2 ?  (*(ourPath->nodes.end()-2)).dist : 0) - ourPath->nodes[i].dist;
 			ourPath->nodes.pop_back();
 			ourPath->nodes.pop_back();
-			
+
 			std::vector< CGObjectInstance * > vis = CGI->mh->getVisitableObjs(CGHeroInstance::convertPosition(curd.dst,false));
 			std::vector< CGObjectInstance * > vis = CGI->mh->getVisitableObjs(CGHeroInstance::convertPosition(curd.dst,false));
 			bool blockvis = false;
 			bool blockvis = false;
 			for (int pit = 0; pit<vis.size();pit++)
 			for (int pit = 0; pit<vis.size();pit++)
@@ -278,7 +282,7 @@ void CCallback::recruitCreatures(const CGObjectInstance *obj, int ID, int amount
 
 
 		//recruit
 		//recruit
 		int slot = -1; //slot ID
 		int slot = -1; //slot ID
-		std::pair<int,std::pair<CCreature*,int> > parb;	
+		std::pair<int,std::pair<CCreature*,int> > parb;
 
 
 		for(int i=0;i<7;i++) //TODO: if there is already stack of same creatures it should be used always
 		for(int i=0;i<7;i++) //TODO: if there is already stack of same creatures it should be used always
 		{
 		{
@@ -372,7 +376,7 @@ const CGTownInstance * CCallback::getTownInfo(int val, bool mode) //mode = 0 ->
 {
 {
 	if (!mode)
 	if (!mode)
 		return gs->players[gs->currentPlayer].towns[val];
 		return gs->players[gs->currentPlayer].towns[val];
-	else 
+	else
 	{
 	{
 		//TODO: add some smart ID to the CTownInstance
 		//TODO: add some smart ID to the CTownInstance
 
 
@@ -398,7 +402,7 @@ const CGHeroInstance * CCallback::getHeroInfo(int player, int val, bool mode) //
 		if(val<gs->players[player].heroes.size())
 		if(val<gs->players[player].heroes.size())
 			return gs->players[player].heroes[val];
 			return gs->players[player].heroes[val];
 		else return NULL;
 		else return NULL;
-	else 
+	else
 	{
 	{
 		for (int i=0; i<gs->players[player].heroes.size();i++)
 		for (int i=0; i<gs->players[player].heroes.size();i++)
 		{
 		{
@@ -435,7 +439,7 @@ int CCallback::getDate(int mode)
 		temp = ((gs->day-1)/7)+1;
 		temp = ((gs->day-1)/7)+1;
 		if (!(temp%4))
 		if (!(temp%4))
 			return 4;
 			return 4;
-		else 
+		else
 			return (temp%4);
 			return (temp%4);
 		break;
 		break;
 	case 3:
 	case 3:
@@ -448,7 +452,7 @@ bool CCallback::verifyPath(CPath * path, bool blockSea)
 {
 {
 	for (int i=0;i<path->nodes.size();i++)
 	for (int i=0;i<path->nodes.size();i++)
 	{
 	{
-		if ( CGI->mh->ttiles[path->nodes[i].coord.x][path->nodes[i].coord.y][path->nodes[i].coord.z].blocked 
+		if ( CGI->mh->ttiles[path->nodes[i].coord.x][path->nodes[i].coord.y][path->nodes[i].coord.z].blocked
 			&& (! (CGI->mh->ttiles[path->nodes[i].coord.x][path->nodes[i].coord.y][path->nodes[i].coord.z].visitable)))
 			&& (! (CGI->mh->ttiles[path->nodes[i].coord.x][path->nodes[i].coord.y][path->nodes[i].coord.z].visitable)))
 			return false; //path is wrong - one of the tiles is blocked
 			return false; //path is wrong - one of the tiles is blocked
 
 
@@ -458,16 +462,16 @@ bool CCallback::verifyPath(CPath * path, bool blockSea)
 				continue;
 				continue;
 
 
 			if (
 			if (
-					((CGI->mh->ttiles[path->nodes[i].coord.x][path->nodes[i].coord.y][path->nodes[i].coord.z].terType==EterrainType::water)
+					((CGI->mh->ttiles[path->nodes[i].coord.x][path->nodes[i].coord.y][path->nodes[i].coord.z].terType==water)
 					&&
 					&&
-					(CGI->mh->ttiles[path->nodes[i-1].coord.x][path->nodes[i-1].coord.y][path->nodes[i-1].coord.z].terType!=EterrainType::water))
+					(CGI->mh->ttiles[path->nodes[i-1].coord.x][path->nodes[i-1].coord.y][path->nodes[i-1].coord.z].terType!=water))
 				  ||
 				  ||
-					((CGI->mh->ttiles[path->nodes[i].coord.x][path->nodes[i].coord.y][path->nodes[i].coord.z].terType!=EterrainType::water)
+					((CGI->mh->ttiles[path->nodes[i].coord.x][path->nodes[i].coord.y][path->nodes[i].coord.z].terType!=water)
 					&&
 					&&
-					(CGI->mh->ttiles[path->nodes[i-1].coord.x][path->nodes[i-1].coord.y][path->nodes[i-1].coord.z].terType==EterrainType::water))
+					(CGI->mh->ttiles[path->nodes[i-1].coord.x][path->nodes[i-1].coord.y][path->nodes[i-1].coord.z].terType==water))
 				  ||
 				  ||
-				  (CGI->mh->ttiles[path->nodes[i-1].coord.x][path->nodes[i-1].coord.y][path->nodes[i-1].coord.z].terType==EterrainType::rock)
-					
+				  (CGI->mh->ttiles[path->nodes[i-1].coord.x][path->nodes[i-1].coord.y][path->nodes[i-1].coord.z].terType==rock)
+
 				)
 				)
 				return false;
 				return false;
 		}
 		}
@@ -558,7 +562,7 @@ const CCreatureSet* CCallback::getGarrison(const CGObjectInstance *obj)
 int CCallback::swapCreatures(const CGObjectInstance *s1, const CGObjectInstance *s2, int p1, int p2)
 int CCallback::swapCreatures(const CGObjectInstance *s1, const CGObjectInstance *s2, int p1, int p2)
 {
 {
 	CCreatureSet *S1 = const_cast<CCreatureSet*>(getGarrison(s1)), *S2 = const_cast<CCreatureSet*>(getGarrison(s2));
 	CCreatureSet *S1 = const_cast<CCreatureSet*>(getGarrison(s1)), *S2 = const_cast<CCreatureSet*>(getGarrison(s2));
-	if (((s1->ID == 34)&&(S1->slots.size()==1)&&(!S2->slots[p2].first)) || ((s2->ID == 34)&&(S2->slots.size()==1)&&(!S1->slots[p1].first)) || (0/*we are not allowed*/))
+	if (((s1->ID == 34)&&(S1->slots.size()==1)&&(!S2->slots[p2].first)) || ((s2->ID == 34)&&(S2->slots.size()==1)&&(!S1->slots[p1].first)) || (0/*we are not allowed*/)) 
 	{
 	{
 		//TODO: check if we are allowed to swap these creatures
 		//TODO: check if we are allowed to swap these creatures
 		return -1;
 		return -1;
@@ -602,7 +606,7 @@ int CCallback::swapCreatures(const CGObjectInstance *s1, const CGObjectInstance
 }
 }
 
 
 int CCallback::mergeStacks(const CGObjectInstance *s1, const CGObjectInstance *s2, int p1, int p2)
 int CCallback::mergeStacks(const CGObjectInstance *s1, const CGObjectInstance *s2, int p1, int p2)
-{	
+{
 	CCreatureSet *S1 = const_cast<CCreatureSet*>(getGarrison(s1)), *S2 = const_cast<CCreatureSet*>(getGarrison(s2));
 	CCreatureSet *S1 = const_cast<CCreatureSet*>(getGarrison(s1)), *S2 = const_cast<CCreatureSet*>(getGarrison(s2));
 	if ((S1->slots[p1].first != S2->slots[p2].first) && (true /*we are allowed to*/))
 	if ((S1->slots[p1].first != S2->slots[p2].first) && (true /*we are allowed to*/))
 	{
 	{
@@ -654,7 +658,7 @@ int CCallback::splitStack(const CGObjectInstance *s1, const CGObjectInstance *s2
 	S2->slots[p2].second = val;
 	S2->slots[p2].second = val;
 	S1->slots[p1].second -= val;
 	S1->slots[p1].second -= val;
 	if(!S1->slots[p1].second) //if we've moved all creatures
 	if(!S1->slots[p1].second) //if we've moved all creatures
-		S1->slots.erase(p1); 
+		S1->slots.erase(p1);
 
 
 
 
 	if(s1->tempOwner<PLAYER_LIMIT)
 	if(s1->tempOwner<PLAYER_LIMIT)
@@ -693,7 +697,7 @@ bool CCallback::dismissHero(const CGHeroInstance *hero)
 }
 }
 
 
 int CCallback::getMySerial()
 int CCallback::getMySerial()
-{	
+{
 	return gs->players[player].serial;
 	return gs->players[player].serial;
 }
 }
 
 
@@ -720,7 +724,7 @@ bool CCallback::swapArifacts(const CGHeroInstance * hero1, bool worn1, int pos1,
 	{
 	{
 		std::swap(Uhero1->artifacts[pos1], Uhero2->artifacts[pos2]);
 		std::swap(Uhero1->artifacts[pos1], Uhero2->artifacts[pos2]);
 	}
 	}
-	
+
 	return true;
 	return true;
 }
 }
 
 
@@ -757,7 +761,7 @@ int CCallback::battleGetBattlefieldType()
 	return CGI->mh->ttiles[CGI->state->curB->tile.x][CGI->state->curB->tile.y][CGI->state->curB->tile.z].terType;
 	return CGI->mh->ttiles[CGI->state->curB->tile.x][CGI->state->curB->tile.y][CGI->state->curB->tile.z].terType;
 }
 }
 
 
-int CCallback::battleGetObstaclesAtTile(int tile) //returns bitfield 
+int CCallback::battleGetObstaclesAtTile(int tile) //returns bitfield
 {
 {
 	//TODO - write
 	//TODO - write
 	return -1;
 	return -1;
@@ -767,10 +771,10 @@ int CCallback::battleGetStack(int pos)
 	for(int g=0; g<CGI->state->curB->stacks.size(); ++g)
 	for(int g=0; g<CGI->state->curB->stacks.size(); ++g)
 	{
 	{
 		if(CGI->state->curB->stacks[g]->position == pos ||
 		if(CGI->state->curB->stacks[g]->position == pos ||
-				( CGI->state->curB->stacks[g]->creature->isDoubleWide() && 
-					( (CGI->state->curB->stacks[g]->attackerOwned && CGI->state->curB->stacks[g]->position-1 == pos) || 
+				( CGI->state->curB->stacks[g]->creature->isDoubleWide() &&
+					( (CGI->state->curB->stacks[g]->attackerOwned && CGI->state->curB->stacks[g]->position-1 == pos) ||
 						(!CGI->state->curB->stacks[g]->attackerOwned && CGI->state->curB->stacks[g]->position+1 == pos)
 						(!CGI->state->curB->stacks[g]->attackerOwned && CGI->state->curB->stacks[g]->position+1 == pos)
-					) 
+					)
 				)
 				)
 			)
 			)
 			return CGI->state->curB->stacks[g]->ID;
 			return CGI->state->curB->stacks[g]->ID;
@@ -820,7 +824,11 @@ CCreature CCallback::battleGetCreature(int number)
 		if(CGI->state->curB->stacks[h]->ID == number) //creature found
 		if(CGI->state->curB->stacks[h]->ID == number) //creature found
 			return *(CGI->state->curB->stacks[h]->creature);
 			return *(CGI->state->curB->stacks[h]->creature);
 	}
 	}
+#ifndef __GNUC__
 	throw new std::exception("Cannot find the creature");
 	throw new std::exception("Cannot find the creature");
+#else
+	throw std::exception();
+#endif
 }
 }
 
 
 std::vector<int> CCallback::battleGetAvailableHexes(int ID)
 std::vector<int> CCallback::battleGetAvailableHexes(int ID)
@@ -852,7 +860,7 @@ int3 CScriptCallback::getPos(CGObjectInstance * ob)
 	return ob->pos;
 	return ob->pos;
 }
 }
 void CScriptCallback::changePrimSkill(int ID, int which, int val)
 void CScriptCallback::changePrimSkill(int ID, int which, int val)
-{	
+{
 	CGHeroInstance * hero = CGI->state->getHero(ID,0);
 	CGHeroInstance * hero = CGI->state->getHero(ID,0);
 	if (which<PRIMARY_SKILLS)
 	if (which<PRIMARY_SKILLS)
 	{
 	{
@@ -881,7 +889,7 @@ void CScriptCallback::changePrimSkill(int ID, int which, int val)
 				if(r<pom)
 				if(r<pom)
 					break;
 					break;
 			}
 			}
-			std::cout << "Bohater dostaje umiejetnosc pierwszorzedna " << x << " (wynik losowania "<<r<<")"<<std::endl; 
+			std::cout << "Bohater dostaje umiejetnosc pierwszorzedna " << x << " (wynik losowania "<<r<<")"<<std::endl;
 			hero->primSkills[x]++;
 			hero->primSkills[x]++;
 
 
 			//TODO: dac dwie umiejetnosci 2-rzedne to wyboru
 			//TODO: dac dwie umiejetnosci 2-rzedne to wyboru
@@ -924,11 +932,11 @@ void CScriptCallback::showSelDialog(int player, std::string text, std::vector<CS
 	return;
 	return;
 }
 }
 int CScriptCallback::getSelectedHero()
 int CScriptCallback::getSelectedHero()
-{	
+{
 	int ret;
 	int ret;
 	if (LOCPLINT->adventureInt->selection.type == HEROI_TYPE)
 	if (LOCPLINT->adventureInt->selection.type == HEROI_TYPE)
 		ret = ((CGHeroInstance*)(LOCPLINT->adventureInt->selection.selected))->subID;
 		ret = ((CGHeroInstance*)(LOCPLINT->adventureInt->selection.selected))->subID;
-	else 
+	else
 		ret = -1;;
 		ret = -1;;
 	return ret;
 	return ret;
 }
 }
@@ -950,7 +958,7 @@ int CScriptCallback::getDate(int mode)
 		temp = ((gs->day-1)/7)+1;
 		temp = ((gs->day-1)/7)+1;
 		if (!(temp%4))
 		if (!(temp%4))
 			return 4;
 			return 4;
-		else 
+		else
 			return (temp%4);
 			return (temp%4);
 		break;
 		break;
 	case 3:
 	case 3:
@@ -1059,13 +1067,13 @@ void CLuaCallback::registerFuncs(lua_State * L)
 	REGISTER_C_FUNC(getGnrlText);
 	REGISTER_C_FUNC(getGnrlText);
 	REGISTER_C_FUNC(changePrimSkill);
 	REGISTER_C_FUNC(changePrimSkill);
 	REGISTER_C_FUNC(getGnrlText);*/
 	REGISTER_C_FUNC(getGnrlText);*/
-	
+
 
 
 	lua_setglobal(L, "vcmi");
 	lua_setglobal(L, "vcmi");
 	#undef REGISTER_C_FUNC
 	#undef REGISTER_C_FUNC
 }
 }
 int CLuaCallback::getPos(lua_State * L)//(CGObjectInstance * object);
 int CLuaCallback::getPos(lua_State * L)//(CGObjectInstance * object);
-{	
+{
 	const int args = lua_gettop(L); // number of arguments
 	const int args = lua_gettop(L); // number of arguments
 	if ((args < 1) || !lua_isnumber(L, 1) )
 	if ((args < 1) || !lua_isnumber(L, 1) )
 		luaL_error(L,
 		luaL_error(L,
@@ -1077,7 +1085,7 @@ int CLuaCallback::getPos(lua_State * L)//(CGObjectInstance * object);
 	return 3;
 	return 3;
 }
 }
 int CLuaCallback::changePrimSkill(lua_State * L)//(int ID, int which, int val);
 int CLuaCallback::changePrimSkill(lua_State * L)//(int ID, int which, int val);
-{	
+{
 	const int args = lua_gettop(L); // number of arguments
 	const int args = lua_gettop(L); // number of arguments
 	if ((args < 1) || !lua_isnumber(L, 1) ||
 	if ((args < 1) || !lua_isnumber(L, 1) ||
 	    ((args >= 2) && !lua_isnumber(L, 2)) ||
 	    ((args >= 2) && !lua_isnumber(L, 2)) ||
@@ -1109,7 +1117,7 @@ int CLuaCallback::getSelectedHero(lua_State * L) //(),returns int (ID of hero, -
 	int ret;
 	int ret;
 	if (LOCPLINT->adventureInt->selection.type == HEROI_TYPE)
 	if (LOCPLINT->adventureInt->selection.type == HEROI_TYPE)
 		ret = ((CGHeroInstance*)(LOCPLINT->adventureInt->selection.selected))->subID;
 		ret = ((CGHeroInstance*)(LOCPLINT->adventureInt->selection.selected))->subID;
-	else 
+	else
 		ret = -1;
 		ret = -1;
 	lua_pushinteger(L,ret);
 	lua_pushinteger(L,ret);
 	return 1;
 	return 1;

+ 17 - 8
CCallback.h

@@ -2,7 +2,11 @@
 #define CCALLBACK_H
 #define CCALLBACK_H
 
 
 #include "mapHandler.h"
 #include "mapHandler.h"
+#ifdef _WIN32
 #include "tchar.h"
 #include "tchar.h"
+#else
+#include "tchar_amigaos4.h"
+#endif
 #include "CGameState.h"
 #include "CGameState.h"
 
 
 class CGameState;
 class CGameState;
@@ -24,9 +28,9 @@ struct UpgradeInfo
 };
 };
 
 
 class ICallback
 class ICallback
-{	
+{
 public:
 public:
-	virtual bool moveHero(int ID, CPath * path, int idtype, int pathType=0)=0;//idtype: 0 - position in vector of heroes (of that player); 1 - ID of hero 
+	virtual bool moveHero(int ID, CPath * path, int idtype, int pathType=0)=0;//idtype: 0 - position in vector of heroes (of that player); 1 - ID of hero
 															//pathType: 0 - nodes are manifestation pos, 1 - nodes are object pos
 															//pathType: 0 - nodes are manifestation pos, 1 - nodes are object pos
 	virtual int swapCreatures(const CGObjectInstance *s1, const CGObjectInstance *s2, int p1, int p2)=0;//swaps creatures between two posiibly different garrisons // TODO: AI-unsafe code - fix it!
 	virtual int swapCreatures(const CGObjectInstance *s1, const CGObjectInstance *s2, int p1, int p2)=0;//swaps creatures between two posiibly different garrisons // TODO: AI-unsafe code - fix it!
 	virtual int mergeStacks(const CGObjectInstance *s1, const CGObjectInstance *s2, int p1, int p2)=0;//joins first stack tothe second (creatures must be same type)
 	virtual int mergeStacks(const CGObjectInstance *s1, const CGObjectInstance *s2, int p1, int p2)=0;//joins first stack tothe second (creatures must be same type)
@@ -57,7 +61,7 @@ public:
 
 
 //battle
 //battle
 	virtual int battleGetBattlefieldType()=0; //   1. sand/shore   2. sand/mesas   3. dirt/birches   4. dirt/hills   5. dirt/pines   6. grass/hills   7. grass/pines   8. lava   9. magic plains   10. snow/mountains   11. snow/trees   12. subterranean   13. swamp/trees   14. fiery fields   15. rock lands   16. magic clouds   17. lucid pools   18. holy ground   19. clover field   20. evil fog   21. "favourable winds" text on magic plains background   22. cursed ground   23. rough   24. ship to ship   25. ship
 	virtual int battleGetBattlefieldType()=0; //   1. sand/shore   2. sand/mesas   3. dirt/birches   4. dirt/hills   5. dirt/pines   6. grass/hills   7. grass/pines   8. lava   9. magic plains   10. snow/mountains   11. snow/trees   12. subterranean   13. swamp/trees   14. fiery fields   15. rock lands   16. magic clouds   17. lucid pools   18. holy ground   19. clover field   20. evil fog   21. "favourable winds" text on magic plains background   22. cursed ground   23. rough   24. ship to ship   25. ship
-	virtual int battleGetObstaclesAtTile(int tile)=0; //returns bitfield 
+	virtual int battleGetObstaclesAtTile(int tile)=0; //returns bitfield
 	virtual int battleGetStack(int pos)=0; //returns ID of stack on the tile
 	virtual int battleGetStack(int pos)=0; //returns ID of stack on the tile
 	virtual CStack battleGetStackByID(int ID)=0; //returns stack info by given ID
 	virtual CStack battleGetStackByID(int ID)=0; //returns stack info by given ID
 	virtual CStack battleGetStackByPos(int pos)=0; //returns stack info by given pos
 	virtual CStack battleGetStackByPos(int pos)=0; //returns stack info by given pos
@@ -86,7 +90,7 @@ private:
 	CCallback(CGameState * GS, int Player):gs(GS),player(Player){};
 	CCallback(CGameState * GS, int Player):gs(GS),player(Player){};
 	CGameState * gs;
 	CGameState * gs;
 	int lowestSpeed(CGHeroInstance * chi); //speed of the slowest stack
 	int lowestSpeed(CGHeroInstance * chi); //speed of the slowest stack
-	int valMovePoints(CGHeroInstance * chi); 
+	int valMovePoints(CGHeroInstance * chi);
 	bool isVisible(int3 pos, int Player);
 	bool isVisible(int3 pos, int Player);
 
 
 protected:
 protected:
@@ -94,7 +98,7 @@ protected:
 
 
 public:
 public:
 //commands
 //commands
-	bool moveHero(int ID, CPath * path, int idtype, int pathType=0);//idtype: 0 - position in vector of heroes (of that player); 1 - ID of hero 
+	bool moveHero(int ID, CPath * path, int idtype, int pathType=0);//idtype: 0 - position in vector of heroes (of that player); 1 - ID of hero
 															//pathType: 0 - nodes are manifestation pos, 1 - nodes are object pos
 															//pathType: 0 - nodes are manifestation pos, 1 - nodes are object pos
 	void selectionMade(int selection, int asker);
 	void selectionMade(int selection, int asker);
 	int swapCreatures(const CGObjectInstance *s1, const CGObjectInstance *s2, int p1, int p2);
 	int swapCreatures(const CGObjectInstance *s1, const CGObjectInstance *s2, int p1, int p2);
@@ -130,7 +134,7 @@ public:
 
 
 	//battle
 	//battle
 	int battleGetBattlefieldType(); //   1. sand/shore   2. sand/mesas   3. dirt/birches   4. dirt/hills   5. dirt/pines   6. grass/hills   7. grass/pines   8. lava   9. magic plains   10. snow/mountains   11. snow/trees   12. subterranean   13. swamp/trees   14. fiery fields   15. rock lands   16. magic clouds   17. lucid pools   18. holy ground   19. clover field   20. evil fog   21. "favourable winds" text on magic plains background   22. cursed ground   23. rough   24. ship to ship   25. ship
 	int battleGetBattlefieldType(); //   1. sand/shore   2. sand/mesas   3. dirt/birches   4. dirt/hills   5. dirt/pines   6. grass/hills   7. grass/pines   8. lava   9. magic plains   10. snow/mountains   11. snow/trees   12. subterranean   13. swamp/trees   14. fiery fields   15. rock lands   16. magic clouds   17. lucid pools   18. holy ground   19. clover field   20. evil fog   21. "favourable winds" text on magic plains background   22. cursed ground   23. rough   24. ship to ship   25. ship
-	int battleGetObstaclesAtTile(int tile); //returns bitfield 
+	int battleGetObstaclesAtTile(int tile); //returns bitfield
 	int battleGetStack(int pos); //returns ID of stack on the tile
 	int battleGetStack(int pos); //returns ID of stack on the tile
 	CStack battleGetStackByID(int ID); //returns stack info by given ID
 	CStack battleGetStackByID(int ID); //returns stack info by given ID
 	CStack battleGetStackByPos(int pos); //returns stack info by given pos
 	CStack battleGetStackByPos(int pos); //returns stack info by given pos
@@ -142,10 +146,15 @@ public:
 	std::vector<int> battleGetAvailableHexes(int ID); //reutrns numbers of hexes reachable by creature with id ID
 	std::vector<int> battleGetAvailableHexes(int ID); //reutrns numbers of hexes reachable by creature with id ID
 	bool battleIsStackMine(int ID); //returns true if stack with id ID belongs to caller
 	bool battleIsStackMine(int ID); //returns true if stack with id ID belongs to caller
 	bool battleCanShoot(int ID, int dest); //returns true if unit with id ID can shoot to dest
 	bool battleCanShoot(int ID, int dest); //returns true if unit with id ID can shoot to dest
-	
+
+
 
 
 //friends
 //friends
+#ifndef __GNUC__
 	friend int _tmain(int argc, _TCHAR* argv[]);
 	friend int _tmain(int argc, _TCHAR* argv[]);
+#else
+	friend int main(int argc, _TCHAR* argv[]);
+#endif
 };
 };
 class CScriptCallback
 class CScriptCallback
 {
 {
@@ -185,4 +194,4 @@ private:
 
 
 	friend void initGameState(CGameInfo * cgi);
 	friend void initGameState(CGameInfo * cgi);
 };
 };
-#endif //CCALLBACK_H
+#endif //CCALLBACK_H

+ 44 - 32
CCastleInterface.cpp

@@ -15,7 +15,7 @@
 extern TTF_Font * GEOR16;
 extern TTF_Font * GEOR16;
 CBuildingRect::CBuildingRect(Structure *Str)
 CBuildingRect::CBuildingRect(Structure *Str)
 :str(Str), moi(false), offset(0)
 :str(Str), moi(false), offset(0)
-{	
+{
 	def = CGI->spriteh->giveDef(Str->defName);
 	def = CGI->spriteh->giveDef(Str->defName);
 	max = def->ourImages.size();
 	max = def->ourImages.size();
 
 
@@ -86,7 +86,7 @@ void CBuildingRect::hover(bool on)
 			MotionInterested::activate();
 			MotionInterested::activate();
 		moi = true;
 		moi = true;
 	}
 	}
-	else 
+	else
 	{
 	{
 		if(moi)
 		if(moi)
 			MotionInterested::deactivate();
 			MotionInterested::deactivate();
@@ -100,7 +100,7 @@ void CBuildingRect::hover(bool on)
 }
 }
 void CBuildingRect::clickLeft (tribool down)
 void CBuildingRect::clickLeft (tribool down)
 {
 {
-	
+
 	if(area && (LOCPLINT->castleInt->hBuild==this) && !(indeterminate(down)) && (CSDL_Ext::SDL_GetPixel(area,LOCPLINT->current->motion.x-pos.x,LOCPLINT->current->motion.y-pos.y) != 0)) //na polu
 	if(area && (LOCPLINT->castleInt->hBuild==this) && !(indeterminate(down)) && (CSDL_Ext::SDL_GetPixel(area,LOCPLINT->current->motion.x-pos.x,LOCPLINT->current->motion.y-pos.y) != 0)) //na polu
 	{
 	{
 		if(pressedL && !down)
 		if(pressedL && !down)
@@ -108,7 +108,7 @@ void CBuildingRect::clickLeft (tribool down)
 		ClickableL::clickLeft(down);
 		ClickableL::clickLeft(down);
 	}
 	}
 
 
-	
+
 	//todo - handle
 	//todo - handle
 }
 }
 void CBuildingRect::clickRight (tribool down)
 void CBuildingRect::clickRight (tribool down)
@@ -121,8 +121,8 @@ void CBuildingRect::clickRight (tribool down)
 		vinya->free = true;
 		vinya->free = true;
 		vinya->bitmap = CMessage::drawBoxTextBitmapSub
 		vinya->bitmap = CMessage::drawBoxTextBitmapSub
 			(LOCPLINT->playerID,
 			(LOCPLINT->playerID,
-			CGI->buildh->buildings[str->townID][str->ID]->description, 
-			LOCPLINT->castleInt->bicons->ourImages[str->ID].bitmap, 
+			CGI->buildh->buildings[str->townID][str->ID]->description,
+			LOCPLINT->castleInt->bicons->ourImages[str->ID].bitmap,
 			CGI->buildh->buildings[str->townID][str->ID]->name);
 			CGI->buildh->buildings[str->townID][str->ID]->name);
 		vinya->pos.x = screen->w/2 - vinya->bitmap->w/2;
 		vinya->pos.x = screen->w/2 - vinya->bitmap->w/2;
 		vinya->pos.y = screen->h/2 - vinya->bitmap->h/2;
 		vinya->pos.y = screen->h/2 - vinya->bitmap->h/2;
@@ -192,7 +192,11 @@ std::string getBgName(int type) //TODO - co z tym zrobi
 	case 8:
 	case 8:
 		return "TBELBACK.bmp";
 		return "TBELBACK.bmp";
 	default:
 	default:
+#ifndef __GNUC__
 		throw new std::exception("std::string getBgName(int type): invalid type");
 		throw new std::exception("std::string getBgName(int type): invalid type");
+#else
+		throw new std::exception();
+#endif
 	}
 	}
 }
 }
 class SORTHELP
 class SORTHELP
@@ -207,7 +211,7 @@ public:
 } srthlp ;
 } srthlp ;
 
 
 CCastleInterface::CCastleInterface(const CGTownInstance * Town, bool Activate)
 CCastleInterface::CCastleInterface(const CGTownInstance * Town, bool Activate)
-{	
+{
 	hall = NULL;
 	hall = NULL;
 	townInt = CGI->bitmaph->loadBitmap("TOWNSCRN.bmp");
 	townInt = CGI->bitmaph->loadBitmap("TOWNSCRN.bmp");
 	cityBg = CGI->bitmaph->loadBitmap(getBgName(Town->subID));
 	cityBg = CGI->bitmaph->loadBitmap(getBgName(Town->subID));
@@ -281,7 +285,11 @@ CCastleInterface::CCastleInterface(const CGTownInstance * Town, bool Activate)
 		defname = "HALLELEM.DEF";
 		defname = "HALLELEM.DEF";
 		break;
 		break;
 	default:
 	default:
+#ifndef __GNUC__
 		throw new std::exception("Bad town subID");
 		throw new std::exception("Bad town subID");
+#else
+		throw new std::exception();
+#endif
 	}
 	}
 	bicons = CGI->spriteh->giveDefEss(defname);
 	bicons = CGI->spriteh->giveDefEss(defname);
 	//blit buildings on bg
 	//blit buildings on bg
@@ -366,7 +374,7 @@ void CCastleInterface::enterHall()
 	hallInt->show();
 	hallInt->show();
 }
 }
 void CCastleInterface::showAll(SDL_Surface * to)
 void CCastleInterface::showAll(SDL_Surface * to)
-{	
+{
 	if (!to)
 	if (!to)
 		to=screen;
 		to=screen;
 	blitAt(cityBg,0,0,to);
 	blitAt(cityBg,0,0,to);
@@ -375,7 +383,7 @@ void CCastleInterface::showAll(SDL_Surface * to)
 	townlist->draw();
 	townlist->draw();
 	statusbar->show();
 	statusbar->show();
 
 
-	garr->show(); 
+	garr->show();
 	int pom;
 	int pom;
 
 
 	//draw fort icon
 	//draw fort icon
@@ -424,7 +432,7 @@ void CCastleInterface::showAll(SDL_Surface * to)
 	//print name and income
 	//print name and income
 	CSDL_Ext::printAt(town->name,85,389,GEOR13,zwykly,to);
 	CSDL_Ext::printAt(town->name,85,389,GEOR13,zwykly,to);
 	char temp[10];
 	char temp[10];
-	itoa(town->dailyIncome(),temp,10);
+	SDL_itoa(town->dailyIncome(),temp,10);
 	CSDL_Ext::printAtMiddle(temp,195,442,GEOR13,zwykly,to);
 	CSDL_Ext::printAtMiddle(temp,195,442,GEOR13,zwykly,to);
 
 
 	//blit town icon
 	//blit town icon
@@ -474,13 +482,13 @@ void CCastleInterface::show(SDL_Surface * to)
 			blitAt(buildings[i]->def->ourImages[0].bitmap,buildings[i]->pos.x,buildings[i]->pos.y,to);
 			blitAt(buildings[i]->def->ourImages[0].bitmap,buildings[i]->pos.x,buildings[i]->pos.y,to);
 			blitAt(buildings[i]->def->ourImages[frame].bitmap,buildings[i]->pos.x,buildings[i]->pos.y,to);
 			blitAt(buildings[i]->def->ourImages[frame].bitmap,buildings[i]->pos.x,buildings[i]->pos.y,to);
 		}
 		}
-		else 
+		else
 			blitAt(buildings[i]->def->ourImages[frame].bitmap,buildings[i]->pos.x,buildings[i]->pos.y,to);
 			blitAt(buildings[i]->def->ourImages[frame].bitmap,buildings[i]->pos.x,buildings[i]->pos.y,to);
 
 
 		if(hBuild==buildings[i] && hBuild->border) //if this this higlighted structure and has border we'll blit it
 		if(hBuild==buildings[i] && hBuild->border) //if this this higlighted structure and has border we'll blit it
 			blitAt(hBuild->border,hBuild->pos,to);
 			blitAt(hBuild->border,hBuild->pos,to);
 	}
 	}
-	
+
 }
 }
 void CCastleInterface::activate()
 void CCastleInterface::activate()
 {
 {
@@ -531,7 +539,7 @@ void CCastleInterface::recreateBuildings()
 	std::set< std::pair<int,int> > s; //group - id
 	std::set< std::pair<int,int> > s; //group - id
 
 
 
 
-		for (std::set<int>::const_iterator i=town->builtBuildings.begin();i!=town->builtBuildings.end();i++)
+	for (std::set<int>::const_iterator i=town->builtBuildings.begin();i!=town->builtBuildings.end();i++)
 	{
 	{
 		if(CGI->townh->structures.find(town->subID) != CGI->townh->structures.end()) //we have info about structures in this town
 		if(CGI->townh->structures.find(town->subID) != CGI->townh->structures.end()) //we have info about structures in this town
 		{
 		{
@@ -549,7 +557,7 @@ void CCastleInterface::recreateBuildings()
 					{
 					{
 						if(seti->first == st->group)
 						if(seti->first == st->group)
 						{
 						{
-							obecny = seti; 
+							obecny = seti;
 							break;
 							break;
 						}
 						}
 					}
 					}
@@ -563,7 +571,11 @@ void CCastleInterface::recreateBuildings()
 								{
 								{
 									delete buildings[itpb];
 									delete buildings[itpb];
 									buildings.erase(buildings.begin() + itpb);
 									buildings.erase(buildings.begin() + itpb);
+									#ifndef __GNUC__
 									obecny->second = st->ID;
 									obecny->second = st->ID;
+									#else
+									*(const_cast<int*>(&(obecny->second))) = st->ID;
+									#endif
 									buildings.push_back(new CBuildingRect(st));
 									buildings.push_back(new CBuildingRect(st));
 								}
 								}
 							}
 							}
@@ -584,7 +596,7 @@ void CCastleInterface::recreateBuildings()
 	std::sort(buildings.begin(),buildings.end(),srthlp);
 	std::sort(buildings.begin(),buildings.end(),srthlp);
 
 
 	//code for Mana Vortex (there are two sets of animation frames - one without mage guild and one with
 	//code for Mana Vortex (there are two sets of animation frames - one without mage guild and one with
-	if((town->subID == 5) && (town->builtBuildings.find(21)!=town->builtBuildings.end())) 
+	if((town->subID == 5) && (town->builtBuildings.find(21)!=town->builtBuildings.end()))
 	{
 	{
 		CBuildingRect *vortex = NULL;
 		CBuildingRect *vortex = NULL;
 		for(int i=0;i<buildings.size();i++)
 		for(int i=0;i<buildings.size();i++)
@@ -607,7 +619,7 @@ void CCastleInterface::recreateBuildings()
 		}
 		}
 	}
 	}
 	//code for the shipyard in the Castle
 	//code for the shipyard in the Castle
-	else if((town->subID == 0) && (town->builtBuildings.find(6)!=town->builtBuildings.end())) 
+	else if((town->subID == 0) && (town->builtBuildings.find(6)!=town->builtBuildings.end()))
 	{
 	{
 		CBuildingRect *shipyard = NULL;
 		CBuildingRect *shipyard = NULL;
 		for(int i=0;i<buildings.size();i++)
 		for(int i=0;i<buildings.size();i++)
@@ -636,19 +648,19 @@ void CHallInterface::CResDataBar::show(SDL_Surface * to)
 	char * buf = new char[15];
 	char * buf = new char[15];
 	for (int i=0;i<7;i++)
 	for (int i=0;i<7;i++)
 	{
 	{
-		itoa(LOCPLINT->cb->getResourceAmount(i),buf,10);
+		SDL_itoa(LOCPLINT->cb->getResourceAmount(i),buf,10);
 		CSDL_Ext::printAtMiddle(buf,pos.x + 50 + 76*i,pos.y+pos.h/2,GEOR13,zwykly);
 		CSDL_Ext::printAtMiddle(buf,pos.x + 50 + 76*i,pos.y+pos.h/2,GEOR13,zwykly);
 	}
 	}
 	std::vector<std::string> temp;
 	std::vector<std::string> temp;
-	itoa(LOCPLINT->cb->getDate(3),buf,10); temp.push_back(std::string(buf));
-	itoa(LOCPLINT->cb->getDate(2),buf,10); temp.push_back(buf);
-	itoa(LOCPLINT->cb->getDate(1),buf,10); temp.push_back(buf);
+	SDL_itoa(LOCPLINT->cb->getDate(3),buf,10); temp.push_back(std::string(buf));
+	SDL_itoa(LOCPLINT->cb->getDate(2),buf,10); temp.push_back(buf);
+	SDL_itoa(LOCPLINT->cb->getDate(1),buf,10); temp.push_back(buf);
 	CSDL_Ext::printAtMiddle(CSDL_Ext::processStr(
 	CSDL_Ext::printAtMiddle(CSDL_Ext::processStr(
 		CGI->generaltexth->allTexts[62]
 		CGI->generaltexth->allTexts[62]
-			+": %s, " 
-			+ CGI->generaltexth->allTexts[63] 
-			+ ": %s, " 
-			+	CGI->generaltexth->allTexts[64] 
+			+": %s, "
+			+ CGI->generaltexth->allTexts[63]
+			+ ": %s, "
+			+	CGI->generaltexth->allTexts[64]
 			+ ": %s",temp)
 			+ ": %s",temp)
 		,pos.x+545+(pos.w-545)/2,pos.y+pos.h/2,GEOR13,zwykly);
 		,pos.x+545+(pos.w-545)/2,pos.y+pos.h/2,GEOR13,zwykly);
 	temp.clear();
 	temp.clear();
@@ -711,7 +723,7 @@ void CHallInterface::CBuildingBox::show(SDL_Surface * to)
 	int pom, pom2=-1;
 	int pom, pom2=-1;
 	switch (state)
 	switch (state)
 	{
 	{
-	case 4: 
+	case 4:
 		pom = 0;
 		pom = 0;
 		pom2 = 0;
 		pom2 = 0;
 		break;
 		break;
@@ -786,7 +798,7 @@ CHallInterface::CHallInterface(CCastleInterface * owner)
 			{
 			{
 				if(
 				if(
 					(owner->town->builtBuildings.find(CGI->buildh->hall[owner->town->subID].second[i][j][k]))
 					(owner->town->builtBuildings.find(CGI->buildh->hall[owner->town->subID].second[i][j][k]))
-					== 
+					==
 					(owner->town->builtBuildings.end())						)
 					(owner->town->builtBuildings.end())						)
 				{
 				{
 					int x = 34 + 194*j,
 					int x = 34 + 194*j,
@@ -824,7 +836,7 @@ CHallInterface::CHallInterface(CCastleInterface * owner)
 					}
 					}
 
 
 					//TODO: check if capital is already built, check if there is water for shipyard
 					//TODO: check if capital is already built, check if there is water for shipyard
-					
+
 
 
 
 
 
 
@@ -963,9 +975,9 @@ std::string CHallInterface::CBuildWindow::getTextForState(int state)
 			std::set<int> used;
 			std::set<int> used;
 			used.insert(bid);
 			used.insert(bid);
 			std::set<int> reqs;
 			std::set<int> reqs;
-			
+
 			for(std::set<int>::iterator i=CGI->townh->requirements[tid][bid].begin();i!=CGI->townh->requirements[tid][bid].end();i++)
 			for(std::set<int>::iterator i=CGI->townh->requirements[tid][bid].begin();i!=CGI->townh->requirements[tid][bid].end();i++)
-				if (LOCPLINT->castleInt->town->builtBuildings.find(*i)   ==  LOCPLINT->castleInt->town->builtBuildings.end()) 
+				if (LOCPLINT->castleInt->town->builtBuildings.find(*i)   ==  LOCPLINT->castleInt->town->builtBuildings.end())
 					reqs.insert(*i);
 					reqs.insert(*i);
 			while(true)
 			while(true)
 			{
 			{
@@ -982,7 +994,7 @@ std::string CHallInterface::CBuildWindow::getTextForState(int state)
 								)
 								)
 						{
 						{
 							if(LOCPLINT->castleInt->town->builtBuildings.find(*j)   ==   //this building is not built
 							if(LOCPLINT->castleInt->town->builtBuildings.find(*j)   ==   //this building is not built
-													LOCPLINT->castleInt->town->builtBuildings.end()) 
+													LOCPLINT->castleInt->town->builtBuildings.end())
 							reqs.insert(*j);
 							reqs.insert(*j);
 						}
 						}
 					}
 					}
@@ -1029,7 +1041,7 @@ CHallInterface::CBuildWindow::CBuildWindow(int Tid, int Bid, int State, bool Mod
 	{
 	{
 		if(!CGI->buildh->buildings[tid][bid]->resources[cn])
 		if(!CGI->buildh->buildings[tid][bid]->resources[cn])
 			continue;
 			continue;
-		itoa(CGI->buildh->buildings[tid][bid]->resources[cn],buf,10);
+		SDL_itoa(CGI->buildh->buildings[tid][bid]->resources[cn],buf,10);
 		if(it<4)
 		if(it<4)
 		{
 		{
 			CSDL_Ext::printAtMiddle(buf,(bitmap->w/2-row1w/2)+77*it+16,ah+42,GEOR16,zwykly,bitmap);
 			CSDL_Ext::printAtMiddle(buf,(bitmap->w/2-row1w/2)+77*it+16,ah+42,GEOR16,zwykly,bitmap);
@@ -1062,4 +1074,4 @@ CHallInterface::CBuildWindow::~CBuildWindow()
 		delete buy;
 		delete buy;
 		delete cancel;
 		delete cancel;
 	}
 	}
-}
+}

+ 2 - 2
CCastleInterface.h

@@ -97,7 +97,7 @@ public:
 
 
 	class CBuildWindow: public IShowable, public ClickableR
 	class CBuildWindow: public IShowable, public ClickableR
 	{
 	{
-	public: 
+	public:
 		int tid, bid, state; //town id, building id, state
 		int tid, bid, state; //town id, building id, state
 		bool mode; // 0 - normal (with buttons), 1 - r-click popup
 		bool mode; // 0 - normal (with buttons), 1 - r-click popup
 		SDL_Surface * bitmap; //main window bitmap, with blitted res/text, without buttons/subtitle in "statusbar"
 		SDL_Surface * bitmap; //main window bitmap, with blitted res/text, without buttons/subtitle in "statusbar"
@@ -129,4 +129,4 @@ public:
 	void show(SDL_Surface * to=NULL);
 	void show(SDL_Surface * to=NULL);
 	void activate();
 	void activate();
 	void deactivate();
 	void deactivate();
-};
+};

+ 14 - 4
CConsoleHandler.cpp

@@ -53,7 +53,7 @@ int internalFunc(void * callback)
 				boost::filesystem::create_directory("Extracted_txts");
 				boost::filesystem::create_directory("Extracted_txts");
 				std::cout<<"Command accepted. Opening .lod file...\t";
 				std::cout<<"Command accepted. Opening .lod file...\t";
 				CLodHandler * txth = new CLodHandler;
 				CLodHandler * txth = new CLodHandler;
-				txth->init(std::string("Data\\H3bitmap.lod"));
+				txth->init(std::string(DATADIR "Data" PATHSEPARATOR "H3bitmap.lod"));
 				std::cout<<"done.\nScanning .lod file\n";
 				std::cout<<"done.\nScanning .lod file\n";
 				int curp=0;
 				int curp=0;
 				std::string pattern = ".TXT";
 				std::string pattern = ".TXT";
@@ -74,12 +74,15 @@ int internalFunc(void * callback)
 				std::cout<<"\rExtracting done :)\n";
 				std::cout<<"\rExtracting done :)\n";
 			}
 			}
 			vector<Coordinate>* p;
 			vector<Coordinate>* p;
+			int heroX;
+			int heroY;
+			int heroZ;
 			switch (*cn.c_str())
 			switch (*cn.c_str())
 			{
 			{
 			case 'P':
 			case 'P':
-				std::cout<<"Policzyc sciezke."<<std::endl;		
+				std::cout<<"Policzyc sciezke."<<std::endl;
 				readed>>src>>dst;
 				readed>>src>>dst;
-				
+
 				p = CGI->pathf->GetPath(Coordinate(src),Coordinate(dst),CGI->heroh->heroInstances[0]);
 				p = CGI->pathf->GetPath(Coordinate(src),Coordinate(dst),CGI->heroh->heroInstances[0]);
 				LOCPLINT->adventureInt->terrain.currentPath = CGI->pathf->ConvertToOldFormat(p);
 				LOCPLINT->adventureInt->terrain.currentPath = CGI->pathf->ConvertToOldFormat(p);
 				//LOCPLINT->adventureInt->terrain.currentPath = CGI->pathf->getPath(src,dst,CGI->heroh->heroInstances[0]);
 				//LOCPLINT->adventureInt->terrain.currentPath = CGI->pathf->getPath(src,dst,CGI->heroh->heroInstances[0]);
@@ -89,7 +92,14 @@ int internalFunc(void * callback)
 				break;
 				break;
 			case 'H': //position of hero
 			case 'H': //position of hero
 				readed>>heronum;
 				readed>>heronum;
+				#ifndef __GNUC__
 				std::cout<<"Position of hero "<<heronum<<": "<<CGI->heroh->heroInstances[heronum]->getPosition(false)<<std::endl;
 				std::cout<<"Position of hero "<<heronum<<": "<<CGI->heroh->heroInstances[heronum]->getPosition(false)<<std::endl;
+				#else
+				heroX = CGI->heroh->heroInstances[heronum]->getPosition(false).x;
+				heroY = CGI->heroh->heroInstances[heronum]->getPosition(false).y;
+				heroZ = CGI->heroh->heroInstances[heronum]->getPosition(false).z;
+				std::cout<<"Position of hero "<<heronum<<": x:"<<heroX<<"- y:"<<heroY<<"- z:"<<heroZ<<std::endl;
+				#endif
 				break;
 				break;
 			case 'M': //move heroa
 			case 'M': //move heroa
 				{
 				{
@@ -104,7 +114,7 @@ int internalFunc(void * callback)
 				readed>>src;
 				readed>>src;
 				CGI->mh->getObjDescriptions(src);
 				CGI->mh->getObjDescriptions(src);
 				break;
 				break;
-			case 'I': 
+			case 'I':
 				{
 				{
 					SDL_Surface * temp = LOCPLINT->infoWin(NULL);
 					SDL_Surface * temp = LOCPLINT->infoWin(NULL);
 					blitAtWR(temp,605,389);
 					blitAtWR(temp,605,389);

+ 5 - 1
CConsoleHandler.h

@@ -7,7 +7,11 @@ class CConsoleHandler
 public:
 public:
 	void runConsole();
 	void runConsole();
 
 
+#ifndef __GNUC__
 	friend int _tmain(int argc, _TCHAR* argv[]);
 	friend int _tmain(int argc, _TCHAR* argv[]);
+#else
+	friend int main(int argc, _TCHAR* argv[]);
+#endif
 };
 };
 
 
-#endif //CCONSOLEHANDLER_H
+#endif //CCONSOLEHANDLER_H

+ 1 - 1
CCursorHandler.cpp

@@ -4,7 +4,7 @@
 #include "SDL_thread.h"
 #include "SDL_thread.h"
 #include "CGameInfo.h"
 #include "CGameInfo.h"
 #include "SDL_framerate.h"
 #include "SDL_framerate.h"
-#include "hch\CLodHandler.h"
+#include "hch/CLodHandler.h"
 
 
 extern SDL_Surface * screen;
 extern SDL_Surface * screen;
 
 

+ 1 - 1
CCursorHandler.h

@@ -26,4 +26,4 @@ public:
 };
 };
 
 
 
 
-#endif //CCURSORHANDLER_H
+#endif //CCURSORHANDLER_H

+ 1 - 1
CGameInfo.cpp

@@ -1,4 +1,4 @@
 #include "stdafx.h"
 #include "stdafx.h"
 #include "CGameInfo.h"
 #include "CGameInfo.h"
 
 
-CGameInfo * CGameInfo::mainObj;
+CGameInfo * CGameInfo::mainObj;

+ 2 - 1
CGameInfo.h

@@ -3,6 +3,7 @@
 
 
 #include "StartInfo.h"
 #include "StartInfo.h"
 #include "SDL.h"
 #include "SDL.h"
+#include "CPregame.h"
 
 
 #include <vector>
 #include <vector>
 
 
@@ -70,4 +71,4 @@ public:
 	StartInfo scenarioOps;
 	StartInfo scenarioOps;
 };
 };
 
 
-#endif //CGAMEINFO_H
+#endif //CGAMEINFO_H

+ 9 - 1
CGameInterface.cpp

@@ -1,4 +1,4 @@
-#include "stdafx.h"
+	#include "stdafx.h"
 #include "CGameInterface.h"
 #include "CGameInterface.h"
 #include "CAdvMapInterface.h"
 #include "CAdvMapInterface.h"
 #include "CMessage.h"
 #include "CMessage.h"
@@ -14,6 +14,7 @@
 #include <sstream>
 #include <sstream>
 #include "hch/CHeroHandler.h"
 #include "hch/CHeroHandler.h"
 #include "SDL_framerate.h"
 #include "SDL_framerate.h"
+#include "AI/EmptyAI/CEmptyAI.h"
 
 
 #ifdef _WIN32
 #ifdef _WIN32
 	#include <windows.h> //for .dll libs
 	#include <windows.h> //for .dll libs
@@ -28,6 +29,7 @@ CGlobalAI * CAIHandler::getNewAI(CCallback * cb, std::string dllname)
 	CGlobalAI * ret=NULL;
 	CGlobalAI * ret=NULL;
 	CGlobalAI*(*getAI)();
 	CGlobalAI*(*getAI)();
 	void(*getName)(char*);
 	void(*getName)(char*);
+
 #ifdef _WIN32
 #ifdef _WIN32
 	HINSTANCE dll = LoadLibraryA(dllname.c_str());
 	HINSTANCE dll = LoadLibraryA(dllname.c_str());
 	if (!dll)
 	if (!dll)
@@ -42,11 +44,17 @@ CGlobalAI * CAIHandler::getNewAI(CCallback * cb, std::string dllname)
 	; //TODO: handle AI library on Linux
 	; //TODO: handle AI library on Linux
 #endif
 #endif
 	char * temp = new char[50];
 	char * temp = new char[50];
+#ifndef __amigaos4__
 	getName(temp);
 	getName(temp);
+#endif
 	std::cout << "Loaded .dll with AI named " << temp << std::endl;
 	std::cout << "Loaded .dll with AI named " << temp << std::endl;
 	delete temp;
 	delete temp;
+#ifndef __amigaos4__
 	ret = getAI();
 	ret = getAI();
 	ret->init(cb);
 	ret->init(cb);
+#else
+	//ret = new CEmptyAI();
+#endif
 	return ret;
 	return ret;
 }
 }
 //CGlobalAI::CGlobalAI()
 //CGlobalAI::CGlobalAI()

+ 13 - 13
CGameInterface.h

@@ -27,9 +27,9 @@ class CObstacle
 struct BattleAction
 struct BattleAction
 {
 {
 	bool side; //who made this action: false - left, true - right player
 	bool side; //who made this action: false - left, true - right player
-	int stackNumber;//stack ID, -1 left hero, -2 right hero, 
-	int actionType; //    0 = Cancel BattleAction   1 = Hero cast a spell   2 = Walk   3 = Defend   4 = Retreat from the battle   5 = Surrender   6 = Walk and Attack   7 = Shoot    8 = Wait   9 = Catapult 10 = Monster casts a spell (i.e. Faerie Dragons) 
-	int destinationTile; 
+	int stackNumber;//stack ID, -1 left hero, -2 right hero,
+	int actionType; //    0 = Cancel BattleAction   1 = Hero cast a spell   2 = Walk   3 = Defend   4 = Retreat from the battle   5 = Surrender   6 = Walk and Attack   7 = Shoot    8 = Wait   9 = Catapult 10 = Monster casts a spell (i.e. Faerie Dragons)
+	int destinationTile;
 	int additionalInfo; // e.g. spell number if type is 1 || 10
 	int additionalInfo; // e.g. spell number if type is 1 || 10
 };
 };
 
 
@@ -39,7 +39,7 @@ struct StackState
 	int attackBonus, defenseBonus, healthBonus, speedBonus;
 	int attackBonus, defenseBonus, healthBonus, speedBonus;
 	int currentHealth;
 	int currentHealth;
 	int shotsLeft;
 	int shotsLeft;
-	std::set<int> effects; 
+	std::set<int> effects;
 	int morale, luck;
 	int morale, luck;
 };
 };
 
 
@@ -49,20 +49,20 @@ public:
 	bool human;
 	bool human;
 	int playerID, serialID;
 	int playerID, serialID;
 
 
-	virtual void init(ICallback * CB)=0{};
-	virtual void yourTurn()=0{};
-	virtual void heroKilled(const CGHeroInstance*)=0{};
-	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 init(ICallback * CB){};
+	virtual void yourTurn(){};
+	virtual void heroKilled(const CGHeroInstance*){};
+	virtual void heroCreated(const CGHeroInstance*){};
+	virtual void heroPrimarySkillChanged(const CGHeroInstance * hero, int which, int val){};
+	virtual void heroMoved(const HeroMoveDetails & details){};
 	virtual void heroVisitsTown(const CGHeroInstance* hero, const CGTownInstance * town){};
 	virtual void heroVisitsTown(const CGHeroInstance* hero, const CGTownInstance * town){};
 	virtual void tileRevealed(int3 pos){};
 	virtual void tileRevealed(int3 pos){};
 	virtual void tileHidden(int3 pos){};
 	virtual void tileHidden(int3 pos){};
 	virtual void receivedResource(int type, int val){};
 	virtual void receivedResource(int type, int val){};
-	virtual void showSelDialog(std::string text, std::vector<CSelectableComponent*> & components, int askID)=0{};
+	virtual void showSelDialog(std::string text, std::vector<CSelectableComponent*> & components, int askID){};
 	virtual void garrisonChanged(const CGObjectInstance * obj){};
 	virtual void garrisonChanged(const CGObjectInstance * obj){};
 	virtual void buildChanged(const CGTownInstance *town, int buildingID, int what){}; //what: 1 - built, 2 - demolished
 	virtual void buildChanged(const CGTownInstance *town, int buildingID, int what){}; //what: 1 - built, 2 - demolished
-	//battle call-ins 
+	//battle call-ins
 	virtual void battleStart(CCreatureSet * army1, CCreatureSet * army2, int3 tile, CGHeroInstance *hero1, CGHeroInstance *hero2, bool side){}; //called by engine when battle starts; side=0 - left, side=1 - right
 	virtual void battleStart(CCreatureSet * army1, CCreatureSet * army2, int3 tile, CGHeroInstance *hero1, CGHeroInstance *hero2, bool side){}; //called by engine when battle starts; side=0 - left, side=1 - right
 	virtual void battlefieldPrepared(int battlefieldType, std::vector<CObstacle*> obstacles){}; //called when battlefield is prepared, prior the battle beginning
 	virtual void battlefieldPrepared(int battlefieldType, std::vector<CObstacle*> obstacles){}; //called when battlefield is prepared, prior the battle beginning
 	virtual void battleNewRound(int round){}; //called at the beggining of each turn, round=-1 is the tactic phase, round=0 is the first "normal" turn
 	virtual void battleNewRound(int round){}; //called at the beggining of each turn, round=-1 is the tactic phase, round=0 is the first "normal" turn
@@ -95,4 +95,4 @@ public:
 	virtual void battleStackKilled(int ID, int dmg, int killed, int IDby){};
 	virtual void battleStackKilled(int ID, int dmg, int killed, int IDby){};
 	virtual BattleAction activeStack(int stackID) {BattleAction ba; ba.actionType = 3; ba.stackNumber = stackID; return ba;};
 	virtual BattleAction activeStack(int stackID) {BattleAction ba; ba.actionType = 3; ba.stackNumber = stackID; return ba;};
 };
 };
-#endif //CGAMEINTERFACE_H
+#endif //CGAMEINTERFACE_H

+ 17 - 5
CGameState.h

@@ -3,7 +3,11 @@
 
 
 #include "mapHandler.h"
 #include "mapHandler.h"
 #include <set>
 #include <set>
+#ifdef _WIN32
 #include <tchar.h>
 #include <tchar.h>
+#else
+#include "tchar_amigaos4.h"
+#endif
 
 
 class CScriptCallback;
 class CScriptCallback;
 class CCallback;
 class CCallback;
@@ -62,7 +66,7 @@ private:
 	std::map<int,PlayerState> players; //color <-> playerstate
 	std::map<int,PlayerState> players; //color <-> playerstate
 	std::set<CCPPObjectScript *> cppscripts;
 	std::set<CCPPObjectScript *> cppscripts;
 	std::map<int, std::map<std::string, CObjectScript*> > objscr; //custom user scripts (as for now only Lua)
 	std::map<int, std::map<std::string, CObjectScript*> > objscr; //custom user scripts (as for now only Lua)
-	
+
 
 
 	bool checkFunc(int obid, std::string name)
 	bool checkFunc(int obid, std::string name)
 	{
 	{
@@ -78,7 +82,11 @@ private:
 	CGHeroInstance * getHero(int ID, int mode)
 	CGHeroInstance * getHero(int ID, int mode)
 	{
 	{
 		if (mode != 0)
 		if (mode != 0)
+#ifndef __GNUC__
 			throw new std::exception("gs->getHero: This mode is not supported!");
 			throw new std::exception("gs->getHero: This mode is not supported!");
+#else
+			throw new std::exception();
+#endif
 		for ( std::map<int, PlayerState>::iterator i=players.begin() ; i!=players.end();i++)
 		for ( std::map<int, PlayerState>::iterator i=players.begin() ; i!=players.end();i++)
 		{
 		{
 			for (int j=0;j<(*i).second.heroes.size();j++)
 			for (int j=0;j<(*i).second.heroes.size();j++)
@@ -94,12 +102,16 @@ private:
 	bool battleAttackCreatureStack(int ID, int dest);
 	bool battleAttackCreatureStack(int ID, int dest);
 	std::vector<int> battleGetRange(int ID); //called by std::vector<int> CCallback::battleGetAvailableHexes(int ID);
 	std::vector<int> battleGetRange(int ID); //called by std::vector<int> CCallback::battleGetAvailableHexes(int ID);
 public:
 public:
-	friend CCallback;
-	friend CPathfinder;;
-	friend CLuaCallback;
+	friend class CCallback;
+	friend class CPathfinder;;
+	friend class CLuaCallback;
+#ifndef __GNUC__
 	friend int _tmain(int argc, _TCHAR* argv[]);
 	friend int _tmain(int argc, _TCHAR* argv[]);
+#else
+	friend int main(int argc, _TCHAR* argv[]);
+#endif
 	friend void initGameState(CGameInfo * cgi);
 	friend void initGameState(CGameInfo * cgi);
-	friend CScriptCallback;
+	friend class CScriptCallback;
 	friend void handleCPPObjS(std::map<int,CCPPObjectScript*> * mapa, CCPPObjectScript * script);
 	friend void handleCPPObjS(std::map<int,CCPPObjectScript*> * mapa, CCPPObjectScript * script);
 	//CCallback * cb; //for communication between PlayerInterface/AI and GameState
 	//CCallback * cb; //for communication between PlayerInterface/AI and GameState
 
 

+ 26 - 10
CHeroWindow.cpp

@@ -2,14 +2,14 @@
 #include "global.h"
 #include "global.h"
 #include "CHeroWindow.h"
 #include "CHeroWindow.h"
 #include "CGameInfo.h"
 #include "CGameInfo.h"
-#include "hch\CHeroHandler.h"
-#include "hch\CGeneralTextHandler.h"
+#include "hch/CHeroHandler.h"
+#include "hch/CGeneralTextHandler.h"
 #include "SDL.h"
 #include "SDL.h"
 #include "SDL_Extensions.h"
 #include "SDL_Extensions.h"
 #include "CAdvmapInterface.h"
 #include "CAdvmapInterface.h"
-#include "hch\CLodHandler.h"
+#include "hch/CLodHandler.h"
 #include "AdventureMapButton.h"
 #include "AdventureMapButton.h"
-#include "hch\CObjectHandler.h"
+#include "hch/CObjectHandler.h"
 #include "CMessage.h"
 #include "CMessage.h"
 #include "CCallback.h"
 #include "CCallback.h"
 #include <sstream>
 #include <sstream>
@@ -185,7 +185,7 @@ void CHeroWindow::setHero(const CGHeroInstance *hero)
 {
 {
 	if(!hero) //something strange... no hero? it shouldn't happen
 	if(!hero) //something strange... no hero? it shouldn't happen
 	{
 	{
-		return; 
+		return;
 	}
 	}
 	curHero = hero;
 	curHero = hero;
 
 
@@ -230,7 +230,7 @@ void CHeroWindow::setHero(const CGHeroInstance *hero)
 			secSkillAreas[g]->text = hlp.substr(1, hlp.size()-2);
 			secSkillAreas[g]->text = hlp.substr(1, hlp.size()-2);
 			break;
 			break;
 		}
 		}
-		
+
 		char * hlpp = new char[200];
 		char * hlpp = new char[200];
 		sprintf(hlpp, CGI->generaltexth->heroscrn[21].c_str(), CGI->abilh->levels[hero->secSkills[g].second].c_str(), CGI->abilh->abilities[hero->secSkills[g].first]->name.c_str());
 		sprintf(hlpp, CGI->generaltexth->heroscrn[21].c_str(), CGI->abilh->levels[hero->secSkills[g].second].c_str(), CGI->abilh->abilities[hero->secSkills[g].first]->name.c_str());
 		secSkillAreas[g]->hoverText = std::string(hlpp);
 		secSkillAreas[g]->hoverText = std::string(hlpp);
@@ -626,12 +626,12 @@ void CHeroWindow::deactivate()
 	}
 	}
 
 
 	for(int f=0; f<artWorn.size(); ++f)
 	for(int f=0; f<artWorn.size(); ++f)
-	{		
+	{
 		if(artWorn[f])
 		if(artWorn[f])
 			artWorn[f]->deactivate();
 			artWorn[f]->deactivate();
 	}
 	}
 	for(int f=0; f<backpack.size(); ++f)
 	for(int f=0; f<backpack.size(); ++f)
-	{		
+	{
 		if(backpack[f])
 		if(backpack[f])
 			backpack[f]->deactivate();
 			backpack[f]->deactivate();
 	}
 	}
@@ -908,7 +908,7 @@ void CArtPlace::clickLeft(boost::logic::tribool down)
 			if(this->fitsHere(ourWindow->activeArtPlace->ourArt) && ourWindow->activeArtPlace->fitsHere(this->ourArt))
 			if(this->fitsHere(ourWindow->activeArtPlace->ourArt) && ourWindow->activeArtPlace->fitsHere(this->ourArt))
 			{
 			{
 				//swap artifacts
 				//swap artifacts
-				
+
 				LOCPLINT->cb->swapArifacts(
 				LOCPLINT->cb->swapArifacts(
 					ourWindow->curHero,
 					ourWindow->curHero,
 					this->myNumber>=0,
 					this->myNumber>=0,
@@ -930,7 +930,7 @@ void CArtPlace::clickLeft(boost::logic::tribool down)
 					text = ourArt->description;
 					text = ourArt->description;
 				else
 				else
 					text = std::string();
 					text = std::string();
-				
+
 				ourWindow->activeArtPlace->clicked = false;
 				ourWindow->activeArtPlace->clicked = false;
 				ourWindow->activeArtPlace = NULL;
 				ourWindow->activeArtPlace = NULL;
 			}
 			}
@@ -1030,7 +1030,11 @@ void LClickableArea::clickLeft(boost::logic::tribool down)
 {
 {
 	if(!down)
 	if(!down)
 	{
 	{
+		#ifndef __amigaos4__
 		LOCPLINT->showInfoDialog("TEST TEST AAA", std::vector<SComponent*>());
 		LOCPLINT->showInfoDialog("TEST TEST AAA", std::vector<SComponent*>());
+		#else
+		#warning error here!
+		#endif
 	}
 	}
 }
 }
 
 
@@ -1046,7 +1050,11 @@ void RClickableArea::clickRight(boost::logic::tribool down)
 {
 {
 	if(!down)
 	if(!down)
 	{
 	{
+		#ifndef __amigaos4__
 		LOCPLINT->showInfoDialog("TEST TEST AAA", std::vector<SComponent*>());
 		LOCPLINT->showInfoDialog("TEST TEST AAA", std::vector<SComponent*>());
+		#else
+		#warning error here!
+		#endif
 	}
 	}
 }
 }
 
 
@@ -1054,7 +1062,11 @@ void LRClickableAreaWText::clickLeft(boost::logic::tribool down)
 {
 {
 	if(!down)
 	if(!down)
 	{
 	{
+		#ifndef __amigaos4__
 		LOCPLINT->showInfoDialog(text, std::vector<SComponent*>());
 		LOCPLINT->showInfoDialog(text, std::vector<SComponent*>());
+		#else
+		#warning error here!
+		#endif
 	}
 	}
 }
 }
 void LRClickableAreaWText::clickRight(boost::logic::tribool down)
 void LRClickableAreaWText::clickRight(boost::logic::tribool down)
@@ -1098,7 +1110,11 @@ void LRClickableAreaWTextComp::clickLeft(boost::logic::tribool down)
 {
 {
 	if((!down) && pressedL)
 	if((!down) && pressedL)
 	{
 	{
+#ifndef __amigaos4__
 		LOCPLINT->showInfoDialog(text, std::vector<SComponent*>(1, new SComponent(SComponent::Etype(baseType), type, bonus)));
 		LOCPLINT->showInfoDialog(text, std::vector<SComponent*>(1, new SComponent(SComponent::Etype(baseType), type, bonus)));
+#else
+#warning error here!
+#endif
 	}
 	}
 	ClickableL::clickLeft(down);
 	ClickableL::clickLeft(down);
 }
 }

+ 1 - 1
CHeroWindow.h

@@ -135,5 +135,5 @@ public:
 
 
 	//friends
 	//friends
 	friend void CArtPlace::clickLeft(tribool down);
 	friend void CArtPlace::clickLeft(tribool down);
-	friend CPlayerInterface;
+	friend class CPlayerInterface;
 };
 };

+ 53 - 21
CLua.cpp

@@ -31,7 +31,7 @@ bool getGlobalFunc(lua_State * L, std::string fname)
 
 
 CObjectScript::CObjectScript()
 CObjectScript::CObjectScript()
 {
 {
-	language = ESLan::UNDEF;
+	language = UNDEF;
 	//std::cout << "Tworze obiekt objectscript "<<this<<std::endl;
 	//std::cout << "Tworze obiekt objectscript "<<this<<std::endl;
 }
 }
 
 
@@ -72,9 +72,13 @@ void CLua::open(std::string initpath)
 	}
 	}
 	else
 	else
 	{
 	{
+#ifndef __GNUC__
 		std::string temp = "Cannot open script ";
 		std::string temp = "Cannot open script ";
 		temp += initpath;
 		temp += initpath;
 		throw std::exception(temp.c_str());
 		throw std::exception(temp.c_str());
+#else
+		throw std::exception();
+#endif
 	}
 	}
 }
 }
 void CLua::registerCLuaCallback()
 void CLua::registerCLuaCallback()
@@ -98,22 +102,26 @@ void CLua::findF(std::string fname)
 void CLua::findF2(std::string fname)
 void CLua::findF2(std::string fname)
 {
 {
 	lua_pushstring (is, fname.c_str());
 	lua_pushstring (is, fname.c_str());
-	lua_gettable (is, LUA_GLOBALSINDEX); 
+	lua_gettable (is, LUA_GLOBALSINDEX);
 }
 }
 void CLua::findFS(std::string fname)
 void CLua::findFS(std::string fname)
 {
 {
 	lua_settop(is, 0);
 	lua_settop(is, 0);
-	if (!getGlobalFunc(is,fname)) 
+	if (!getGlobalFunc(is,fname))
 	{
 	{
 		lua_settop(is, 0);
 		lua_settop(is, 0);
+#ifndef __GNUC__
 		throw new std::exception((fname + ": function not defined").c_str()); // the call is not defined
 		throw new std::exception((fname + ": function not defined").c_str()); // the call is not defined
+#else
+		throw std::exception();
+#endif
 	}
 	}
 }
 }
 #undef LST
 #undef LST
 
 
 CLuaObjectScript::CLuaObjectScript(std::string filename)
 CLuaObjectScript::CLuaObjectScript(std::string filename)
 {
 {
-	language = ESLan::LUA;
+	language = LUA;
 	open(filename);
 	open(filename);
 	//binit = bnewobject = bonherovisit = brightext = false;
 	//binit = bnewobject = bonherovisit = brightext = false;
 	//std::cout << "Tworze obiekt CLuaObjectScript "<<this<<std::endl;
 	//std::cout << "Tworze obiekt CLuaObjectScript "<<this<<std::endl;
@@ -141,7 +149,11 @@ void CLuaObjectScript::newObject(CGObjectInstance *os)
 	if (lua_pcall (is, 1, 0, 0))
 	if (lua_pcall (is, 1, 0, 0))
 	{
 	{
 		lua_settop(is, 0);
 		lua_settop(is, 0);
+#ifndef __GNUC__
 		throw new  std::exception(("Failed to call "+genFN("newObject",os->ID)+" function in lua script.").c_str());
 		throw new  std::exception(("Failed to call "+genFN("newObject",os->ID)+" function in lua script.").c_str());
+#else
+		throw std::exception();
+#endif
 	}
 	}
 	lua_settop(is, 0);
 	lua_settop(is, 0);
 	return;
 	return;
@@ -154,7 +166,11 @@ void CLuaObjectScript::onHeroVisit(CGObjectInstance *os, int heroID)
 	if (lua_pcall (is, 2, 0, 0))
 	if (lua_pcall (is, 2, 0, 0))
 	{
 	{
 		lua_settop(is, 0);
 		lua_settop(is, 0);
+#ifndef __GNUC__
 		throw new  std::exception(("Failed to call "+genFN("heroVisit",os->ID)+" function in lua script.").c_str());
 		throw new  std::exception(("Failed to call "+genFN("heroVisit",os->ID)+" function in lua script.").c_str());
+#else
+		throw std::exception();
+#endif
 	}
 	}
 	lua_settop(is, 0);
 	lua_settop(is, 0);
 }
 }
@@ -165,7 +181,11 @@ std::string CLuaObjectScript::hoverText(CGObjectInstance *os)
 	if (lua_pcall (is, 1, 1, 0))
 	if (lua_pcall (is, 1, 1, 0))
 	{
 	{
 		lua_settop(is, 0);
 		lua_settop(is, 0);
+#ifndef __GNUC__
 		throw new  std::exception(("Failed to call "+genFN("hoverText",os->ID)+" function in lua script.").c_str());
 		throw new  std::exception(("Failed to call "+genFN("hoverText",os->ID)+" function in lua script.").c_str());
+#else
+		throw std::exception();
+#endif
 	}
 	}
 	std::string ret = lua_tostring(is,1);
 	std::string ret = lua_tostring(is,1);
 	lua_settop(is, 0);
 	lua_settop(is, 0);
@@ -199,7 +219,11 @@ void CVisitableOPH::onHeroVisit(CGObjectInstance *os, int heroID)
 	}
 	}
 	else
 	else
 	{
 	{
+#ifndef __GNUC__
 		throw new std::exception("Skrypt nie zainicjalizowal instancji tego obiektu. :(");
 		throw new std::exception("Skrypt nie zainicjalizowal instancji tego obiektu. :(");
+#else
+		throw std::exception();
+#endif
 	}
 	}
 };
 };
 void CVisitableOPH::onNAHeroVisit(CGObjectInstance *os, int heroID, bool alreadyVisited)
 void CVisitableOPH::onNAHeroVisit(CGObjectInstance *os, int heroID, bool alreadyVisited)
@@ -240,8 +264,8 @@ void CVisitableOPH::onNAHeroVisit(CGObjectInstance *os, int heroID, bool already
 			{
 			{
 				cb->changePrimSkill(heroID,w,vvv);
 				cb->changePrimSkill(heroID,w,vvv);
 				std::vector<SComponent*> weko;
 				std::vector<SComponent*> weko;
-				weko.push_back(new SComponent(SComponent::primskill,w,vvv)); 
-				cb->showInfoDialog(cb->getHeroOwner(heroID),CGI->objh->advobtxt[ot],&weko); 
+				weko.push_back(new SComponent(SComponent::primskill,w,vvv));
+				cb->showInfoDialog(cb->getHeroOwner(heroID),CGI->objh->advobtxt[ot],&weko);
 				//for (int ii=0; ii<weko.size();ii++)
 				//for (int ii=0; ii<weko.size();ii++)
 				//	delete weko[ii];
 				//	delete weko[ii];
 				break;
 				break;
@@ -250,8 +274,8 @@ void CVisitableOPH::onNAHeroVisit(CGObjectInstance *os, int heroID, bool already
 			{
 			{
 				cb->changePrimSkill(heroID,w,vvv);
 				cb->changePrimSkill(heroID,w,vvv);
 				std::vector<SComponent*> weko;
 				std::vector<SComponent*> weko;
-				weko.push_back(new SComponent(SComponent::experience,0,vvv)); 
-				cb->showInfoDialog(cb->getHeroOwner(heroID),CGI->objh->advobtxt[ot],&weko); 
+				weko.push_back(new SComponent(SComponent::experience,0,vvv));
+				cb->showInfoDialog(cb->getHeroOwner(heroID),CGI->objh->advobtxt[ot],&weko);
 				//for (int ii=0; ii<weko.size();ii++)
 				//for (int ii=0; ii<weko.size();ii++)
 				//	delete weko[ii];
 				//	delete weko[ii];
 				break;
 				break;
@@ -283,31 +307,35 @@ std::string CVisitableOPH::hoverText(CGObjectInstance *os)
 	switch(os->ID)
 	switch(os->ID)
 	{
 	{
 	case 51:
 	case 51:
-		pom = 8; 
+		pom = 8;
 		break;
 		break;
 	case 23:
 	case 23:
 		pom = 7;
 		pom = 7;
 		break;
 		break;
 	case 61:
 	case 61:
-		pom = 11; 
+		pom = 11;
 		break;
 		break;
 	case 32:
 	case 32:
-		pom = 4; 
+		pom = 4;
 		break;
 		break;
 	case 100:
 	case 100:
-		pom = 5; 
+		pom = 5;
 		break;
 		break;
 	default:
 	default:
+#ifndef __GNUC__
 		throw new std::exception("Unsupported ID in CVisitableOPH::hoverText");
 		throw new std::exception("Unsupported ID in CVisitableOPH::hoverText");
+#else
+		throw std::exception();
+#endif
 	}
 	}
 	add = " " + CGI->objh->xtrainfo[pom] + " ";
 	add = " " + CGI->objh->xtrainfo[pom] + " ";
 	int heroID = cb->getSelectedHero();
 	int heroID = cb->getSelectedHero();
 	if (heroID>=0)
 	if (heroID>=0)
 	{
 	{
-		add += ( (visitors[os].find(heroID) == visitors[os].end()) 
-				? 
+		add += ( (visitors[os].find(heroID) == visitors[os].end())
+				?
 			(CGI->generaltexth->allTexts[353])  //not visited
 			(CGI->generaltexth->allTexts[353])  //not visited
-				: 
+				:
 			( CGI->generaltexth->allTexts[352]) ); //visited
 			( CGI->generaltexth->allTexts[352]) ); //visited
 	}
 	}
 	return CGI->objh->objects[os->defInfo->id].name + add;
 	return CGI->objh->objects[os->defInfo->id].name + add;
@@ -332,7 +360,7 @@ void CVisitableOPW::onNAHeroVisit(CGObjectInstance *os, int heroID, bool already
 	{
 	{
 		if (os->ID!=112)
 		if (os->ID!=112)
 			mid++;
 			mid++;
-		else 
+		else
 			mid--;
 			mid--;
 		cb->showInfoDialog(cb->getHeroOwner(heroID),CGI->objh->advobtxt[mid],&std::vector<SComponent*>()); //TODO: maybe we have memory leak with these windows
 		cb->showInfoDialog(cb->getHeroOwner(heroID),CGI->objh->advobtxt[mid],&std::vector<SComponent*>()); //TODO: maybe we have memory leak with these windows
 	}
 	}
@@ -384,7 +412,7 @@ void CVisitableOPW::newTurn ()
 			(*i).second = false;
 			(*i).second = false;
 		}
 		}
 	}
 	}
-} 
+}
 void CVisitableOPW::newObject(CGObjectInstance *os)
 void CVisitableOPW::newObject(CGObjectInstance *os)
 {
 {
 	visited.insert(std::pair<CGObjectInstance*,bool>(os,false));
 	visited.insert(std::pair<CGObjectInstance*,bool>(os,false));
@@ -394,7 +422,7 @@ void CVisitableOPW::onHeroVisit(CGObjectInstance *os, int heroID)
 {
 {
 	if(visited[os])
 	if(visited[os])
 		onNAHeroVisit(os,heroID,true);
 		onNAHeroVisit(os,heroID,true);
-	else 
+	else
 		onNAHeroVisit(os,heroID,false);
 		onNAHeroVisit(os,heroID,false);
 }
 }
 
 
@@ -433,7 +461,7 @@ void CMines::onHeroVisit(CGObjectInstance *os, int heroID)
 		if (os->subID==7)
 		if (os->subID==7)
 			return; //TODO: support for abandoned mine
 			return; //TODO: support for abandoned mine
 		os->tempOwner = cb->getHeroOwner(heroID);
 		os->tempOwner = cb->getHeroOwner(heroID);
-		SComponent * com = new SComponent(SComponent::Etype::resource,os->subID,vv);
+		SComponent * com = new SComponent(SComponent::resource,os->subID,vv);
 		com->subtitle+=CGI->generaltexth->allTexts[3].substr(2,CGI->generaltexth->allTexts[3].length()-2);
 		com->subtitle+=CGI->generaltexth->allTexts[3].substr(2,CGI->generaltexth->allTexts[3].length()-2);
 		std::vector<SComponent*> weko;
 		std::vector<SComponent*> weko;
 		weko.push_back(com);
 		weko.push_back(com);
@@ -566,8 +594,12 @@ void CPickable::chosen(int which)
 		cb->changePrimSkill(tempStore[which]->ID,4,tempStore[which]->val);
 		cb->changePrimSkill(tempStore[which]->ID,4,tempStore[which]->val);
 		break;
 		break;
 	default:
 	default:
+#ifndef __GNUC__
 		throw new std::exception("Unhandled choice");
 		throw new std::exception("Unhandled choice");
-		
+#else
+		throw std::exception();
+#endif
+
 	}
 	}
 	for (int i=0;i<tempStore.size();i++)
 	for (int i=0;i<tempStore.size();i++)
 		delete tempStore[i];
 		delete tempStore[i];
@@ -735,4 +767,4 @@ std::vector<int> CCreatureGen::yourObjects() //returns IDs of objects which are
 	std::vector<int> ret(1);
 	std::vector<int> ret(1);
 	ret.push_back(17); //cregen1
 	ret.push_back(17); //cregen1
 	return ret;
 	return ret;
-}
+}

+ 6 - 6
CLua.h

@@ -29,7 +29,7 @@ public:
 	virtual void onHeroVisit(CGObjectInstance *os, int heroID){};
 	virtual void onHeroVisit(CGObjectInstance *os, int heroID){};
 	virtual void onHeroLeave(CGObjectInstance *os, int heroID){};
 	virtual void onHeroLeave(CGObjectInstance *os, int heroID){};
 	virtual std::string hoverText(CGObjectInstance *os){return "";};
 	virtual std::string hoverText(CGObjectInstance *os){return "";};
-	virtual void newTurn (){}; 
+	virtual void newTurn (){};
 
 
 
 
 	//TODO: implement functions below:
 	//TODO: implement functions below:
@@ -68,7 +68,7 @@ public:
 	void findF2(std::string fname);
 	void findF2(std::string fname);
 	void findFS(std::string fname);
 	void findFS(std::string fname);
 
 
-	
+
 	friend void initGameState(CGameInfo * cgi);
 	friend void initGameState(CGameInfo * cgi);
 };
 };
 
 
@@ -99,7 +99,7 @@ class CVisitableOPH : public CCPPObjectScript  //once per hero
 {
 {
 	CVisitableOPH(CScriptCallback * CB):CCPPObjectScript(CB){};
 	CVisitableOPH(CScriptCallback * CB):CCPPObjectScript(CB){};
 	std::map<CGObjectInstance*,std::set<int> > visitors;
 	std::map<CGObjectInstance*,std::set<int> > visitors;
-	
+
 	void onNAHeroVisit(CGObjectInstance *os, int heroID, bool alreadyVisited);
 	void onNAHeroVisit(CGObjectInstance *os, int heroID, bool alreadyVisited);
 	void newObject(CGObjectInstance *os);
 	void newObject(CGObjectInstance *os);
 	void onHeroVisit(CGObjectInstance *os, int heroID);
 	void onHeroVisit(CGObjectInstance *os, int heroID);
@@ -118,7 +118,7 @@ class CVisitableOPW : public CCPPObjectScript  //once per week
 	void onHeroVisit(CGObjectInstance *os, int heroID);
 	void onHeroVisit(CGObjectInstance *os, int heroID);
 	std::vector<int> yourObjects(); //returns IDs of objects which are handled by script
 	std::vector<int> yourObjects(); //returns IDs of objects which are handled by script
 	std::string hoverText(CGObjectInstance *os);
 	std::string hoverText(CGObjectInstance *os);
-	void newTurn (); 
+	void newTurn ();
 
 
 	friend void initGameState(CGameInfo * cgi);
 	friend void initGameState(CGameInfo * cgi);
 };
 };
@@ -133,7 +133,7 @@ class CMines : public CCPPObjectScript  //flaggable, and giving resource at each
 	void onHeroVisit(CGObjectInstance *os, int heroID);
 	void onHeroVisit(CGObjectInstance *os, int heroID);
 	std::vector<int> yourObjects(); //returns IDs of objects which are handled by script
 	std::vector<int> yourObjects(); //returns IDs of objects which are handled by script
 	std::string hoverText(CGObjectInstance *os);
 	std::string hoverText(CGObjectInstance *os);
-	void newTurn (); 
+	void newTurn ();
 
 
 	friend void initGameState(CGameInfo * cgi);
 	friend void initGameState(CGameInfo * cgi);
 };
 };
@@ -198,4 +198,4 @@ class CCreatureGen : public CCPPObjectScript
 	std::vector<int> yourObjects(); //returns IDs of objects which are handled by script
 	std::vector<int> yourObjects(); //returns IDs of objects which are handled by script
 
 
 	friend void initGameState(CGameInfo * cgi);
 	friend void initGameState(CGameInfo * cgi);
-};
+};

+ 9 - 5
CLuaHandler.cpp

@@ -48,16 +48,16 @@ void CLuaHandler::test()
 	{
 	{
 	   // Call main...
 	   // Call main...
 	   if ((iErr = lua_pcall (lua, 0, LUA_MULTRET, 0)) == 0)
 	   if ((iErr = lua_pcall (lua, 0, LUA_MULTRET, 0)) == 0)
-	   {    
+	   {
 
 
 			//int ret = luabind::call_function<int>(lua, "helloWorld2");
 			//int ret = luabind::call_function<int>(lua, "helloWorld2");
 			//lua_pushstring (lua, "helloWorld2");
 			//lua_pushstring (lua, "helloWorld2");
-			//lua_gettable (lua, LUA_GLOBALSINDEX);  
+			//lua_gettable (lua, LUA_GLOBALSINDEX);
 			//lua_pcall (lua, 0, 0, 0);
 			//lua_pcall (lua, 0, 0, 0);
 
 
 			// Push the function name onto the stack
 			// Push the function name onto the stack
 			lua_pushstring (lua, "rightText");
 			lua_pushstring (lua, "rightText");
-			lua_gettable (lua, LUA_GLOBALSINDEX);  
+			lua_gettable (lua, LUA_GLOBALSINDEX);
 			lua_pcall (lua, 0, 0, 0);
 			lua_pcall (lua, 0, 0, 0);
 		}
 		}
 	}
 	}
@@ -70,9 +70,13 @@ std::vector<std::string> * CLuaHandler::searchForScripts(std::string fol)
 	std::vector<std::string> * ret = new std::vector<std::string> ();
 	std::vector<std::string> * ret = new std::vector<std::string> ();
 	boost::filesystem::path folder(fol);
 	boost::filesystem::path folder(fol);
 	if (!boost::filesystem::exists(folder))
 	if (!boost::filesystem::exists(folder))
+#ifndef __GNUC__
 		throw new std::exception("No such folder!");
 		throw new std::exception("No such folder!");
+#else
+		throw std::exception();
+#endif
 	boost::filesystem::directory_iterator end_itr;
 	boost::filesystem::directory_iterator end_itr;
-	for 
+	for
 	  (
 	  (
 	  boost::filesystem::directory_iterator it(folder);
 	  boost::filesystem::directory_iterator it(folder);
 	  it!=end_itr;
 	  it!=end_itr;
@@ -113,4 +117,4 @@ std::vector<std::string> * CLuaHandler::functionList(std::string file)
 	}
 	}
 	is.close();
 	is.close();
 	return ret;
 	return ret;
-}
+}

+ 1 - 1
CLuaHandler.h

@@ -20,4 +20,4 @@ public:
 
 
 	void test();
 	void test();
 };
 };
-#endif //CLUAHANDLER_H
+#endif //CLUAHANDLER_H

+ 60 - 48
CMT.cpp

@@ -3,9 +3,9 @@
 #include "stdafx.h"
 #include "stdafx.h"
 #include "SDL.h"
 #include "SDL.h"
 #include "SDL_TTF.h"
 #include "SDL_TTF.h"
-#include "hch\CVideoHandler.h"
+#include "hch/CVideoHandler.h"
 #include "SDL_mixer.h"
 #include "SDL_mixer.h"
-#include "hch\CBuildingHandler.h"
+#include "hch/CBuildingHandler.h"
 #include "SDL_Extensions.h"
 #include "SDL_Extensions.h"
 #include "SDL_framerate.h"
 #include "SDL_framerate.h"
 #include <cmath>
 #include <cmath>
@@ -17,26 +17,26 @@
 #include "zlib.h"
 #include "zlib.h"
 #include <cmath>
 #include <cmath>
 #include <ctime>
 #include <ctime>
-#include "hch\CArtHandler.h"
-#include "hch\CHeroHandler.h"
-#include "hch\CCreatureHandler.h"
-#include "hch\CAbilityHandler.h"
-#include "hch\CSpellHandler.h"
-#include "hch\CBuildingHandler.h"
-#include "hch\CObjectHandler.h"
+#include "hch/CArtHandler.h"
+#include "hch/CHeroHandler.h"
+#include "hch/CCreatureHandler.h"
+#include "hch/CAbilityHandler.h"
+#include "hch/CSpellHandler.h"
+#include "hch/CBuildingHandler.h"
+#include "hch/CObjectHandler.h"
 #include "CGameInfo.h"
 #include "CGameInfo.h"
-#include "hch\CMusicHandler.h"
-#include "hch\CSemiLodHandler.h"
-#include "hch\CLodHandler.h"
-#include "hch\CDefHandler.h"
-#include "hch\CSndHandler.h"
-#include "hch\CTownHandler.h"
-#include "hch\CDefObjInfoHandler.h"
-#include "hch\CAmbarCendamo.h"
+#include "hch/CMusicHandler.h"
+#include "hch/CSemiLodHandler.h"
+#include "hch/CLodHandler.h"
+#include "hch/CDefHandler.h"
+#include "hch/CSndHandler.h"
+#include "hch/CTownHandler.h"
+#include "hch/CDefObjInfoHandler.h"
+#include "hch/CAmbarCendamo.h"
 #include "mapHandler.h"
 #include "mapHandler.h"
 #include "global.h"
 #include "global.h"
 #include "CPreGame.h"
 #include "CPreGame.h"
-#include "hch\CGeneralTextHandler.h"
+#include "hch/CGeneralTextHandler.h"
 #include "CConsoleHandler.h"
 #include "CConsoleHandler.h"
 #include "CCursorHandler.h"
 #include "CCursorHandler.h"
 #include "CScreenHandler.h"
 #include "CScreenHandler.h"
@@ -90,7 +90,7 @@ void initGameState(CGameInfo * cgi)
 		cgi->state->players.insert(ins);
 		cgi->state->players.insert(ins);
 	}
 	}
 	/******************RESOURCES****************************************************/
 	/******************RESOURCES****************************************************/
-	//TODO: zeby komputer dostawal inaczej niz gracz 
+	//TODO: zeby komputer dostawal inaczej niz gracz
 	std::vector<int> startres;
 	std::vector<int> startres;
 	std::ifstream tis("config/startres.txt");
 	std::ifstream tis("config/startres.txt");
 	int k;
 	int k;
@@ -176,7 +176,7 @@ void initGameState(CGameInfo * cgi)
 				vhi->army.slots[x-pom2].first = &(cgi->creh->creatures[pom]);
 				vhi->army.slots[x-pom2].first = &(cgi->creh->creatures[pom]);
 				if((pom = (vhi->type->highStack[x]-vhi->type->lowStack[x])) > 0)
 				if((pom = (vhi->type->highStack[x]-vhi->type->lowStack[x])) > 0)
 					vhi->army.slots[x-pom2].second = (rand()%pom)+vhi->type->lowStack[x];
 					vhi->army.slots[x-pom2].second = (rand()%pom)+vhi->type->lowStack[x];
-				else 
+				else
 					vhi->army.slots[x-pom2].second = +vhi->type->lowStack[x];
 					vhi->army.slots[x-pom2].second = +vhi->type->lowStack[x];
 			}
 			}
 		}
 		}
@@ -184,7 +184,7 @@ void initGameState(CGameInfo * cgi)
 		cgi->state->players[vhi->getOwner()].heroes.push_back(vhi);
 		cgi->state->players[vhi->getOwner()].heroes.push_back(vhi);
 
 
 	}
 	}
-	/*************************FOG**OF**WAR******************************************/		
+	/*************************FOG**OF**WAR******************************************/
 	for(std::map<int, PlayerState>::iterator k=cgi->state->players.begin(); k!=cgi->state->players.end(); ++k)
 	for(std::map<int, PlayerState>::iterator k=cgi->state->players.begin(); k!=cgi->state->players.end(); ++k)
 	{
 	{
 		k->second.fogOfWarMap.resize(cgi->ac->map.width, Woff);
 		k->second.fogOfWarMap.resize(cgi->ac->map.width, Woff);
@@ -223,7 +223,7 @@ void initGameState(CGameInfo * cgi)
 		//vti->creaturesLeft.resize(CREATURES_PER_TOWN);
 		//vti->creaturesLeft.resize(CREATURES_PER_TOWN);
 		if (vti->name.length()==0) // if town hasn't name we draw it
 		if (vti->name.length()==0) // if town hasn't name we draw it
 			vti->name=vti->town->names[rand()%vti->town->names.size()];
 			vti->name=vti->town->names[rand()%vti->town->names.size()];
-		
+
 		cgi->state->players[vti->getOwner()].towns.push_back(vti);
 		cgi->state->players[vti->getOwner()].towns.push_back(vti);
 	}
 	}
 
 
@@ -247,7 +247,7 @@ void initGameState(CGameInfo * cgi)
 
 
 		//init visiting heroes
 		//init visiting heroes
 		for(int l=0; l<k->second.heroes.size();l++)
 		for(int l=0; l<k->second.heroes.size();l++)
-		{ 
+		{
 			for(int m=0; m<k->second.towns.size();m++)
 			for(int m=0; m<k->second.towns.size();m++)
 			{
 			{
 				int3 vistile = k->second.towns[m]->pos; vistile.x--; //tile next to the entrance
 				int3 vistile = k->second.towns[m]->pos; vistile.x--; //tile next to the entrance
@@ -309,7 +309,7 @@ void initGameState(CGameInfo * cgi)
 			CGI->objh->objInstances[i]->state = scripts[CGI->objh->objInstances[i]->ID];
 			CGI->objh->objInstances[i]->state = scripts[CGI->objh->objInstances[i]->ID];
 			CGI->objh->objInstances[i]->state->newObject(CGI->objh->objInstances[i]);
 			CGI->objh->objInstances[i]->state->newObject(CGI->objh->objInstances[i]);
 		}
 		}
-		else 
+		else
 		{
 		{
 			CGI->objh->objInstances[i]->state = NULL;
 			CGI->objh->objInstances[i]->state = NULL;
 		}
 		}
@@ -322,12 +322,16 @@ void initGameState(CGameInfo * cgi)
 	delete lf;
 	delete lf;
 }
 }
 
 
+#ifndef __GNUC__
 int _tmain(int argc, _TCHAR* argv[])
 int _tmain(int argc, _TCHAR* argv[])
-{ 
+#else
+int main(int argc, _TCHAR* argv[])
+#endif
+{
 	//std::ios_base::sync_with_stdio(0);
 	//std::ios_base::sync_with_stdio(0);
 	//CLuaHandler luatest;
 	//CLuaHandler luatest;
-	//luatest.test(); 
-	
+	//luatest.test();
+
 		//CBIKHandler cb;
 		//CBIKHandler cb;
 		//cb.open("CSECRET.BIK");
 		//cb.open("CSECRET.BIK");
 	THC timeHandler tmh;
 	THC timeHandler tmh;
@@ -339,7 +343,7 @@ int _tmain(int argc, _TCHAR* argv[])
 	if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_AUDIO/*|SDL_INIT_EVENTTHREAD*/)==0)
 	if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_AUDIO/*|SDL_INIT_EVENTTHREAD*/)==0)
 	{
 	{
 		screen = SDL_SetVideoMode(800,600,24,SDL_SWSURFACE|SDL_DOUBLEBUF/*|SDL_FULLSCREEN*/);
 		screen = SDL_SetVideoMode(800,600,24,SDL_SWSURFACE|SDL_DOUBLEBUF/*|SDL_FULLSCREEN*/);
-		
+
 		//initializing important global surface
 		//initializing important global surface
 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
 		int rmask = 0xff000000;
 		int rmask = 0xff000000;
@@ -358,16 +362,18 @@ int _tmain(int argc, _TCHAR* argv[])
 		TTF_Init();
 		TTF_Init();
 		atexit(TTF_Quit);
 		atexit(TTF_Quit);
 		atexit(SDL_Quit);
 		atexit(SDL_Quit);
-		//TNRB = TTF_OpenFont("Fonts\\tnrb.ttf",16);
-		TNRB16 = TTF_OpenFont("Fonts\\tnrb.ttf",16);
-		//TNR = TTF_OpenFont("Fonts\\tnr.ttf",10);
-		GEOR13 = TTF_OpenFont("Fonts\\georgia.ttf",13);
-		GEOR16 = TTF_OpenFont("Fonts\\georgia.ttf",16);
-		GEORXX = TTF_OpenFont("Fonts\\tnrb.ttf",22);
-		GEORM = TTF_OpenFont("Fonts\\georgia.ttf",10);
+		//TNRB = TTF_OpenFont(DATADIR "Fonts" PATHSEPARATOR "tnrb.ttf",16);
+		TNRB16 = TTF_OpenFont(DATADIR "Fonts" PATHSEPARATOR "tnrb.ttf",16);
+		//TNR = TTF_OpenFont(DATADIR "Fonts" PATHSEPARATOR "tnr.ttf",10);
+		GEOR13 = TTF_OpenFont(DATADIR "Fonts" PATHSEPARATOR "georgia.ttf",13);
+		GEOR16 = TTF_OpenFont(DATADIR "Fonts" PATHSEPARATOR "georgia.ttf",16);
+		GEORXX = TTF_OpenFont(DATADIR "Fonts" PATHSEPARATOR "tnrb.ttf",22);
+		GEORM = TTF_OpenFont(DATADIR "Fonts" PATHSEPARATOR "georgia.ttf",10);
+
 		CMusicHandler * mush = new CMusicHandler;  //initializing audio
 		CMusicHandler * mush = new CMusicHandler;  //initializing audio
 		mush->initMusics();
 		mush->initMusics();
-		//audio initialized 
+
+		//audio initialized
 		/*if(Mix_PlayMusic(mush->mainMenuWoG, -1)==-1) //uncomment this fragment to have music
 		/*if(Mix_PlayMusic(mush->mainMenuWoG, -1)==-1) //uncomment this fragment to have music
 		{
 		{
 			printf("Mix_PlayMusic: %s\n", Mix_GetError());
 			printf("Mix_PlayMusic: %s\n", Mix_GetError());
@@ -379,19 +385,19 @@ int _tmain(int argc, _TCHAR* argv[])
 
 
 		SDL_WM_SetCaption(NAME,""); //set window title
 		SDL_WM_SetCaption(NAME,""); //set window title
 		CGameInfo * cgi = new CGameInfo; //contains all global informations about game (texts, lodHandlers, map handler itp.)
 		CGameInfo * cgi = new CGameInfo; //contains all global informations about game (texts, lodHandlers, map handler itp.)
-		CGameInfo::mainObj = cgi;		
+		CGameInfo::mainObj = cgi;
 		#ifdef _DEBUG
 		#ifdef _DEBUG
 		CGI = cgi;
 		CGI = cgi;
 		#endif
 		#endif
 		cgi->consoleh = new CConsoleHandler;
 		cgi->consoleh = new CConsoleHandler;
 		cgi->mush = mush;
 		cgi->mush = mush;
-		cgi->curh = new CCursorHandler; 
-		
+		cgi->curh = new CCursorHandler;
+
 		THC std::cout<<"Initializing screen, fonts and sound handling: "<<tmh.getDif()<<std::endl;
 		THC std::cout<<"Initializing screen, fonts and sound handling: "<<tmh.getDif()<<std::endl;
 		cgi->spriteh = new CLodHandler;
 		cgi->spriteh = new CLodHandler;
-		cgi->spriteh->init(std::string("Data\\H3sprite.lod"));
+		cgi->spriteh->init(std::string(DATADIR "Data" PATHSEPARATOR "H3sprite.lod"));
 		cgi->bitmaph = new CLodHandler;
 		cgi->bitmaph = new CLodHandler;
-		cgi->bitmaph->init(std::string("Data\\H3bitmap.lod"));
+		cgi->bitmaph->init(std::string(DATADIR "Data" PATHSEPARATOR "H3bitmap.lod"));
 		THC std::cout<<"Loading .lod files: "<<tmh.getDif()<<std::endl;
 		THC std::cout<<"Loading .lod files: "<<tmh.getDif()<<std::endl;
 
 
 		boost::filesystem::directory_iterator enddir;
 		boost::filesystem::directory_iterator enddir;
@@ -410,6 +416,7 @@ int _tmain(int argc, _TCHAR* argv[])
 				}
 				}
 			}
 			}
 		}
 		}
+
 		if(boost::filesystem::exists("Sprites"))
 		if(boost::filesystem::exists("Sprites"))
 		{
 		{
 			for (boost::filesystem::directory_iterator dir("Sprites");dir!=enddir;dir++)
 			for (boost::filesystem::directory_iterator dir("Sprites");dir!=enddir;dir++)
@@ -475,6 +482,7 @@ int _tmain(int argc, _TCHAR* argv[])
 		}
 		}
 		//palette initialized
 		//palette initialized
 		THC std::cout<<"Preparing players' colours: "<<tmh.getDif()<<std::endl;
 		THC std::cout<<"Preparing players' colours: "<<tmh.getDif()<<std::endl;
+
 		CMessage::init();
 		CMessage::init();
 		cgi->townh = new CTownHandler;
 		cgi->townh = new CTownHandler;
 		cgi->townh->loadNames();
 		cgi->townh->loadNames();
@@ -680,7 +688,6 @@ int _tmain(int argc, _TCHAR* argv[])
 		cgi->heroh->flags4.push_back(cgi->spriteh->giveDef("AF06.DEF")); //teal
 		cgi->heroh->flags4.push_back(cgi->spriteh->giveDef("AF06.DEF")); //teal
 		cgi->heroh->flags4.push_back(cgi->spriteh->giveDef("AF07.DEF")); //pink
 		cgi->heroh->flags4.push_back(cgi->spriteh->giveDef("AF07.DEF")); //pink
 
 
-
 		for(int q=0; q<8; ++q)
 		for(int q=0; q<8; ++q)
 		{
 		{
 			for(int o=0; o<cgi->heroh->flags4[q]->ourImages.size(); ++o)
 			for(int o=0; o<cgi->heroh->flags4[q]->ourImages.size(); ++o)
@@ -798,7 +805,7 @@ int _tmain(int argc, _TCHAR* argv[])
 
 
 		CSpellHandler * spellh = new CSpellHandler;
 		CSpellHandler * spellh = new CSpellHandler;
 		spellh->loadSpells();
 		spellh->loadSpells();
-		cgi->spellh = spellh;		
+		cgi->spellh = spellh;
 		THC std::cout<<"\tSpell handler: "<<pomtime.getDif()<<std::endl;
 		THC std::cout<<"\tSpell handler: "<<pomtime.getDif()<<std::endl;
 
 
 		CBuildingHandler * buildh = new CBuildingHandler;
 		CBuildingHandler * buildh = new CBuildingHandler;
@@ -827,9 +834,9 @@ int _tmain(int argc, _TCHAR* argv[])
 		THC std::cout<<"Handlers initailization (together): "<<tmh.getDif()<<std::endl;
 		THC std::cout<<"Handlers initailization (together): "<<tmh.getDif()<<std::endl;
 
 
 		std::string mapname;
 		std::string mapname;
-		//if(CPG->ourScenSel->mapsel.selected==0) 
+		//if(CPG->ourScenSel->mapsel.selected==0)
 		//	CPG->ourScenSel->mapsel.selected = 1; //only for tests
 		//	CPG->ourScenSel->mapsel.selected = 1; //only for tests
-		if (CPG) 
+		if (CPG)
 			mapname = CPG->ourScenSel->mapsel.ourMaps[CPG->ourScenSel->mapsel.selected].filename;
 			mapname = CPG->ourScenSel->mapsel.ourMaps[CPG->ourScenSel->mapsel.selected].filename;
 		else
 		else
 		{
 		{
@@ -872,11 +879,16 @@ int _tmain(int argc, _TCHAR* argv[])
 			cgi->playerint.push_back(NULL);
 			cgi->playerint.push_back(NULL);
 		}*/
 		}*/
 		for (int i=0; i<cgi->scenarioOps.playerInfos.size();i++) //initializing interfaces
 		for (int i=0; i<cgi->scenarioOps.playerInfos.size();i++) //initializing interfaces
-		{ 
-
+		{
 			if(!cgi->scenarioOps.playerInfos[i].human)
 			if(!cgi->scenarioOps.playerInfos[i].human)
+			{
+#ifdef _WIN32
 				cgi->playerint.push_back(static_cast<CGameInterface*>(CAIHandler::getNewAI(new CCallback(cgi->state,cgi->scenarioOps.playerInfos[i].color),"EmptyAI.dll")));
 				cgi->playerint.push_back(static_cast<CGameInterface*>(CAIHandler::getNewAI(new CCallback(cgi->state,cgi->scenarioOps.playerInfos[i].color),"EmptyAI.dll")));
-			else 
+#else
+				cgi->playerint.push_back(static_cast<CGameInterface*>(CAIHandler::getNewAI(new CCallback(cgi->state,cgi->scenarioOps.playerInfos[i].color),"libemptyai.so")));
+#endif
+			}
+			else
 			{
 			{
 				cgi->state->currentPlayer=cgi->scenarioOps.playerInfos[i].color;
 				cgi->state->currentPlayer=cgi->scenarioOps.playerInfos[i].color;
 				cgi->playerint.push_back(new CPlayerInterface(cgi->scenarioOps.playerInfos[i].color,i));
 				cgi->playerint.push_back(new CPlayerInterface(cgi->scenarioOps.playerInfos[i].color,i));

+ 35 - 35
CMessage.cpp

@@ -1,16 +1,16 @@
 #include "stdafx.h"
 #include "stdafx.h"
 #include "CMessage.h"
 #include "CMessage.h"
 #include "SDL_TTF.h"
 #include "SDL_TTF.h"
-#include "hch\CSemiDefHandler.h"
-#include "hch\CDefHandler.h"
+#include "hch/CSemiDefHandler.h"
+#include "hch/CDefHandler.h"
 #include "CGameInfo.h"
 #include "CGameInfo.h"
 #include "SDL_Extensions.h"
 #include "SDL_Extensions.h"
-#include "hch\CLodHandler.h"
+#include "hch/CLodHandler.h"
 #include <boost/algorithm/string.hpp>
 #include <boost/algorithm/string.hpp>
 #include <boost/algorithm/string/replace.hpp>
 #include <boost/algorithm/string/replace.hpp>
 #include "CPlayerInterface.h"
 #include "CPlayerInterface.h"
-#include "hch\CDefHandler.h"
-#include "hch\CSemiDefHandler.h"
+#include "hch/CDefHandler.h"
+#include "hch/CSemiDefHandler.h"
 #include "CGameInfo.h"
 #include "CGameInfo.h"
 #include "SDL_Extensions.h"
 #include "SDL_Extensions.h"
 #include <sstream>
 #include <sstream>
@@ -134,7 +134,7 @@ std::vector<std::string> * CMessage::breakText(std::string text, int line, bool
 	{
 	{
 		int whereCut = -1, braces=0;
 		int whereCut = -1, braces=0;
 		bool pom = true, opened=false;
 		bool pom = true, opened=false;
-		for (int i=0; i<line+braces; i++) 
+		for (int i=0; i<line+braces; i++)
 		{
 		{
 			if (text[i]==10) //end of line sign
 			if (text[i]==10) //end of line sign
 			{
 			{
@@ -146,7 +146,7 @@ std::vector<std::string> * CMessage::breakText(std::string text, int line, bool
 			{
 			{
 				if (text[i]=='{')
 				if (text[i]=='{')
 					opened=true;
 					opened=true;
-				else 
+				else
 					opened=false;
 					opened=false;
 				braces++;
 				braces++;
 			}
 			}
@@ -173,7 +173,7 @@ std::vector<std::string> * CMessage::breakText(std::string text, int line, bool
 		}
 		}
 	}
 	}
 	for (int i=0;i<text.length();i++)
 	for (int i=0;i<text.length();i++)
-	{		
+	{
 		if (text[i]==10) //end of line sign
 		if (text[i]==10) //end of line sign
 		{
 		{
 			ret->push_back(text.substr(0,i));
 			ret->push_back(text.substr(0,i));
@@ -212,7 +212,7 @@ std::pair<int, int> CMessage::getMaxSizes(std::vector< std::vector<CSelectableCo
 
 
 std::pair<int,int> CMessage::getMaxSizes(std::vector<std::vector<SDL_Surface*> > * txtg)
 std::pair<int,int> CMessage::getMaxSizes(std::vector<std::vector<SDL_Surface*> > * txtg)
 {
 {
-	std::pair<int,int> ret;		
+	std::pair<int,int> ret;
 	ret.first = -1;
 	ret.first = -1;
 	ret.second=0;
 	ret.second=0;
 	for (int i=0; i<txtg->size();i++) //szukamy najszerszej linii i lacznej wysokosci
 	for (int i=0; i<txtg->size();i++) //szukamy najszerszej linii i lacznej wysokosci
@@ -240,7 +240,7 @@ SDL_Surface * CMessage::blitTextOnSur(std::vector<std::vector<SDL_Surface*> > *
 
 
 		int tw = pw;
 		int tw = pw;
 		for (int j=0;j<(*txtg)[i].size();j++) //blit text
 		for (int j=0;j<(*txtg)[i].size();j++) //blit text
-		{	
+		{
 			blitAt((*txtg)[i][j],tw,curh+i*19,ret);
 			blitAt((*txtg)[i][j],tw,curh+i*19,ret);
 			tw+=(*txtg)[i][j]->w;
 			tw+=(*txtg)[i][j]->w;
 			SDL_FreeSurface((*txtg)[i][j]);
 			SDL_FreeSurface((*txtg)[i][j]);
@@ -254,7 +254,7 @@ SDL_Surface * CMessage::blitCompsOnSur(std::vector<SComponent*> & comps, int max
 	std::vector<std::string> * brdtext;
 	std::vector<std::string> * brdtext;
 	if (comps.size())
 	if (comps.size())
 		brdtext = breakText(comps[0]->subtitle,12,true,true);
 		brdtext = breakText(comps[0]->subtitle,12,true,true);
-	else 
+	else
 		brdtext = NULL;
 		brdtext = NULL;
 	curh += 30;
 	curh += 30;
 	comps[0]->pos.x = (ret->w/2) - ((comps[0]->getImg()->w)/2);
 	comps[0]->pos.x = (ret->w/2) - ((comps[0]->getImg()->w)/2);
@@ -270,7 +270,7 @@ SDL_Surface * CMessage::blitCompsOnSur(std::vector<SComponent*> & comps, int max
 	}
 	}
 	return ret;
 	return ret;
 }
 }
-SDL_Surface* CMessage::blitCompsOnSur(SDL_Surface * or, std::vector< std::vector<CSelectableComponent*> > *  komp, int inter, int &curh, SDL_Surface *ret)
+SDL_Surface* CMessage::blitCompsOnSur(SDL_Surface * _or, std::vector< std::vector<CSelectableComponent*> > *  komp, int inter, int &curh, SDL_Surface *ret)
 {
 {
 	for (int i=0;i<komp->size();i++)
 	for (int i=0;i<komp->size();i++)
 	{
 	{
@@ -281,7 +281,7 @@ SDL_Surface* CMessage::blitCompsOnSur(SDL_Surface * or, std::vector< std::vector
 			if(maxh<(*komp)[i][j]->getImg()->h)
 			if(maxh<(*komp)[i][j]->getImg()->h)
 				maxh=(*komp)[i][j]->getImg()->h;
 				maxh=(*komp)[i][j]->getImg()->h;
 		}
 		}
-		totalw += (inter*2+or->w) * ((*komp)[i].size() - 1);
+		totalw += (inter*2+_or->w) * ((*komp)[i].size() - 1);
 		curh+=maxh/2;
 		curh+=maxh/2;
 		int curw = (ret->w/2)-(totalw/2);
 		int curw = (ret->w/2)-(totalw/2);
 		for(int j=0;j<(*komp)[i].size();j++)
 		for(int j=0;j<(*komp)[i].size();j++)
@@ -294,8 +294,8 @@ SDL_Surface* CMessage::blitCompsOnSur(SDL_Surface * or, std::vector< std::vector
 			if(j<((*komp)[i].size()-1))
 			if(j<((*komp)[i].size()-1))
 			{
 			{
 				curw+=inter;
 				curw+=inter;
-				blitAt(or,curw,curh-(or->h/2),ret);
-				curw+=or->w;
+				blitAt(_or,curw,curh-(_or->h/2),ret);
+				curw+=_or->w;
 				curw+=inter;
 				curw+=inter;
 			}
 			}
 		}
 		}
@@ -337,7 +337,7 @@ std::vector<std::vector<SDL_Surface*> > * CMessage::drawText(std::vector<std::st
 			(*txtg)[i].push_back(TTF_RenderText_Blended(TNRB16,(*brtext)[i].substr(1,z-1).c_str(),tytulowy));
 			(*txtg)[i].push_back(TTF_RenderText_Blended(TNRB16,(*brtext)[i].substr(1,z-1).c_str(),tytulowy));
 			(*brtext)[i].erase(0,z+1); //z+1 bo dajemy zamykajaca klamre
 			(*brtext)[i].erase(0,z+1); //z+1 bo dajemy zamykajaca klamre
 		} //ends while((*brtext)[i].length())
 		} //ends while((*brtext)[i].length())
-	} //ends for(int i=0; i<brtext->size();i++) 
+	} //ends for(int i=0; i<brtext->size();i++)
 	return txtg;
 	return txtg;
 }
 }
 CSimpleWindow * CMessage::genWindow(std::string text, int player, int Lmar, int Rmar, int Tmar, int Bmar)
 CSimpleWindow * CMessage::genWindow(std::string text, int player, int Lmar, int Rmar, int Tmar, int Bmar)
@@ -346,7 +346,7 @@ CSimpleWindow * CMessage::genWindow(std::string text, int player, int Lmar, int
 	std::vector<std::string> * brtext = breakText(text,32,true,true);
 	std::vector<std::string> * brtext = breakText(text,32,true,true);
 	std::vector<std::vector<SDL_Surface*> > * txtg = drawText(brtext);
 	std::vector<std::vector<SDL_Surface*> > * txtg = drawText(brtext);
 	std::pair<int,int> txts = getMaxSizes(txtg);
 	std::pair<int,int> txts = getMaxSizes(txtg);
-	ret->bitmap = drawBox1(txts.first+Lmar+Rmar,txts.second+Tmar+Bmar,0); 
+	ret->bitmap = drawBox1(txts.first+Lmar+Rmar,txts.second+Tmar+Bmar,0);
 	ret->pos.h=ret->bitmap->h;
 	ret->pos.h=ret->bitmap->h;
 	ret->pos.w=ret->bitmap->w;
 	ret->pos.w=ret->bitmap->w;
 	for (int i=0; i<txtg->size();i++)
 	for (int i=0; i<txtg->size();i++)
@@ -365,7 +365,7 @@ CSimpleWindow * CMessage::genWindow(std::string text, int player, int Lmar, int
 				//std::stringstream n;
 				//std::stringstream n;
 				//n <<"temp_"<<i<<"__"<<j<<".bmp";
 				//n <<"temp_"<<i<<"__"<<j<<".bmp";
 			blitAt((*txtg)[i][j],tw,ph+i*19,ret->bitmap);
 			blitAt((*txtg)[i][j],tw,ph+i*19,ret->bitmap);
-				//SDL_SaveBMP(ret->bitmap,n.str().c_str());	
+				//SDL_SaveBMP(ret->bitmap,n.str().c_str());
 			tw+=(*txtg)[i][j]->w;
 			tw+=(*txtg)[i][j]->w;
 			SDL_FreeSurface((*txtg)[i][j]);
 			SDL_FreeSurface((*txtg)[i][j]);
 		}
 		}
@@ -391,7 +391,7 @@ CInfoWindow * CMessage::genIWindow(std::string text, int player, int charperline
 			+ comps[0]->getImg()->h
 			+ comps[0]->getImg()->h
 			+ 5 //img <-> subtitle
 			+ 5 //img <-> subtitle
 			+ 20; //subtitle //!!!!!!!!!!!!!!!!!!!!
 			+ 20; //subtitle //!!!!!!!!!!!!!!!!!!!!
-	ret->bitmap = drawBox1(txts.first+70,txts.second+70,0); 
+	ret->bitmap = drawBox1(txts.first+70,txts.second+70,0);
 	ret->pos.h=ret->bitmap->h;
 	ret->pos.h=ret->bitmap->h;
 	ret->pos.w=ret->bitmap->w;
 	ret->pos.w=ret->bitmap->w;
 	int curh = 30; //gorny margines
 	int curh = 30; //gorny margines
@@ -407,21 +407,21 @@ CInfoWindow * CMessage::genIWindow(std::string text, int player, int charperline
 	curh+=ret->okb.imgs[0][0]->h;
 	curh+=ret->okb.imgs[0][0]->h;
 	return ret;
 	return ret;
 }
 }
-std::vector< std::vector<CSelectableComponent*> > * CMessage::breakComps(std::vector<CSelectableComponent*> & comps,int maxw, SDL_Surface* or)
+std::vector< std::vector<CSelectableComponent*> > * CMessage::breakComps(std::vector<CSelectableComponent*> & comps,int maxw, SDL_Surface* _or)
 {
 {
 	std::vector< std::vector<CSelectableComponent*> > * ret = new std::vector< std::vector<CSelectableComponent*> >();
 	std::vector< std::vector<CSelectableComponent*> > * ret = new std::vector< std::vector<CSelectableComponent*> >();
 	ret->resize(1);
 	ret->resize(1);
 	bool wywalicOr=false;
 	bool wywalicOr=false;
-	if (!or)
+	if (!_or)
 	{
 	{
-		or = TTF_RenderText_Blended(GEOR13,CGI->generaltexth->allTexts[4].c_str(),zwykly);
+		_or = TTF_RenderText_Blended(GEOR13,CGI->generaltexth->allTexts[4].c_str(),zwykly);
 		wywalicOr=true;
 		wywalicOr=true;
 	}
 	}
 	int rvi = 0;
 	int rvi = 0;
 	int curw = 0;
 	int curw = 0;
 	for(int i=0;i<comps.size();i++)
 	for(int i=0;i<comps.size();i++)
 	{
 	{
-		curw += (comps[i]->getImg()->w + 12 + or->w);
+		curw += (comps[i]->getImg()->w + 12 + _or->w);
 		if (curw > maxw)
 		if (curw > maxw)
 		{
 		{
 			curw = 0;
 			curw = 0;
@@ -432,7 +432,7 @@ std::vector< std::vector<CSelectableComponent*> > * CMessage::breakComps(std::ve
 	}
 	}
 	if (wywalicOr)
 	if (wywalicOr)
 	{
 	{
-		SDL_FreeSurface(or);
+		SDL_FreeSurface(_or);
 	}
 	}
 	return ret;
 	return ret;
 }
 }
@@ -445,7 +445,7 @@ SDL_Surface * CMessage::drawBoxTextBitmapSub(int player, std::string text, SDL_S
 	std::pair<int,int> txts = getMaxSizes(txtg), boxs;
 	std::pair<int,int> txts = getMaxSizes(txtg), boxs;
 	boxs.first = std::max(txts.first,bitmap->w) // text/bitmap max width
 	boxs.first = std::max(txts.first,bitmap->w) // text/bitmap max width
 		+ 50; //side margins
 		+ 50; //side margins
-	boxs.second = 
+	boxs.second =
 		(curh=45) //top margin
 		(curh=45) //top margin
 		+ txts.second //text total height
 		+ txts.second //text total height
 		+ 55 //text <=> img
 		+ 55 //text <=> img
@@ -475,8 +475,8 @@ CSelWindow * CMessage::genSelWindow(std::string text, int player, int charperlin
 	std::pair<int,int> txts = getMaxSizes(txtg);
 	std::pair<int,int> txts = getMaxSizes(txtg);
 	txts.first+=45; //side margins
 	txts.first+=45; //side margins
 	int curh = 50; //top margin
 	int curh = 50; //top margin
-	SDL_Surface * or = TTF_RenderText_Blended(GEOR13,CGI->generaltexth->allTexts[4].c_str(),zwykly);
-	std::vector< std::vector<CSelectableComponent*> > * komp = breakComps(comps,500,or);
+	SDL_Surface * _or = TTF_RenderText_Blended(GEOR13,CGI->generaltexth->allTexts[4].c_str(),zwykly);
+	std::vector< std::vector<CSelectableComponent*> > * komp = breakComps(comps,500,_or);
 	std::pair<int,int> txts2 = getMaxSizes(komp);
 	std::pair<int,int> txts2 = getMaxSizes(komp);
 	ret->pos.h = txts.second //wys. tekstu
 	ret->pos.h = txts.second //wys. tekstu
 		+ txts2.second //wys komponentow
 		+ txts2.second //wys komponentow
@@ -490,13 +490,13 @@ CSelWindow * CMessage::genSelWindow(std::string text, int player, int charperlin
 	ret->bitmap = drawBox1(ret->pos.w,ret->pos.h,player);
 	ret->bitmap = drawBox1(ret->pos.w,ret->pos.h,player);
 	blitTextOnSur(txtg,curh,ret->bitmap);
 	blitTextOnSur(txtg,curh,ret->bitmap);
 	curh += 50;
 	curh += 50;
-	blitCompsOnSur(or,komp,10,curh,ret->bitmap);
+	blitCompsOnSur(_or,komp,10,curh,ret->bitmap);
 	curh += 30; //to buttton
 	curh += 30; //to buttton
 	ret->okb.posr.x = (ret->bitmap->w/2) - (ret->okb.imgs[0][0]->w/2);
 	ret->okb.posr.x = (ret->bitmap->w/2) - (ret->okb.imgs[0][0]->w/2);
 	ret->okb.posr.y = curh;
 	ret->okb.posr.y = curh;
 	ret->okb.show();
 	ret->okb.show();
 	curh+=ret->okb.imgs[0][0]->h;
 	curh+=ret->okb.imgs[0][0]->h;
-	SDL_FreeSurface(or);
+	SDL_FreeSurface(_or);
 	delete komp;
 	delete komp;
 	delete tekst;
 	delete tekst;
 	return ret;
 	return ret;
@@ -522,17 +522,17 @@ SDL_Surface * CMessage::genMessage
 	else hh=60+(21*tekst->size());
 	else hh=60+(21*tekst->size());
 	if (type==yesOrNO) //make place for buttons
 	if (type==yesOrNO) //make place for buttons
 	{
 	{
-		if (ww<200) ww=200; 
+		if (ww<200) ww=200;
 		hh+=70;
 		hh+=70;
 	}
 	}
 
 
 	SDL_Surface * ret = drawBox1(ww,hh,0);
 	SDL_Surface * ret = drawBox1(ww,hh,0);
 	//prepare title text
 	//prepare title text
-	
+
 	if (title.length())
 	if (title.length())
 	{
 	{
-		//SDL_Surface * titleText = TTF_RenderText_Shaded(TNRB16,title.c_str(),tytulowy,tlo);	
-		SDL_Surface * titleText = TTF_RenderText_Blended(TNRB16,title.c_str(),tytulowy);	
+		//SDL_Surface * titleText = TTF_RenderText_Shaded(TNRB16,title.c_str(),tytulowy,tlo);
+		SDL_Surface * titleText = TTF_RenderText_Blended(TNRB16,title.c_str(),tytulowy);
 
 
 		//draw title
 		//draw title
 		SDL_Rect tytul = genRect(titleText->h,titleText->w,((ret->w/2)-(titleText->w/2)),37);
 		SDL_Rect tytul = genRect(titleText->h,titleText->w,((ret->w/2)-(titleText->w/2)),37);
@@ -540,7 +540,7 @@ SDL_Surface * CMessage::genMessage
 		SDL_FreeSurface(titleText);
 		SDL_FreeSurface(titleText);
 	}
 	}
 	//draw text
 	//draw text
-	for (int i=0; i<tekst->size(); i++) 
+	for (int i=0; i<tekst->size(); i++)
 	{
 	{
 		int by = 37+i*21;
 		int by = 37+i*21;
 		if (title.length()) by+=40;
 		if (title.length()) by+=40;
@@ -566,4 +566,4 @@ SDL_Surface * CMessage::genMessage
 	}
 	}
 	delete tekst;
 	delete tekst;
 	return ret;
 	return ret;
-}
+}

+ 8 - 6
CMessage.h

@@ -4,6 +4,8 @@
 #include "global.h"
 #include "global.h"
 #include "SDL_TTF.h"
 #include "SDL_TTF.h"
 #include "SDL.h"
 #include "SDL.h"
+#include "CPreGame.h"
+
 enum EWindowType {infoOnly, infoOK, yesOrNO};
 enum EWindowType {infoOnly, infoOK, yesOrNO};
 class CPreGame;
 class CPreGame;
 class MapSel;
 class MapSel;
@@ -23,18 +25,18 @@ namespace NMessage
 class CMessage
 class CMessage
 {
 {
 public:
 public:
-	
+
 	static std::pair<int,int> getMaxSizes(std::vector<std::vector<SDL_Surface*> > * txtg);
 	static std::pair<int,int> getMaxSizes(std::vector<std::vector<SDL_Surface*> > * txtg);
 	static std::pair<int, int> getMaxSizes(std::vector< std::vector<CSelectableComponent*> > * komp);
 	static std::pair<int, int> getMaxSizes(std::vector< std::vector<CSelectableComponent*> > * komp);
 	static std::vector<std::vector<SDL_Surface*> > * drawText(std::vector<std::string> * brtext);
 	static std::vector<std::vector<SDL_Surface*> > * drawText(std::vector<std::string> * brtext);
 	static SDL_Surface * blitTextOnSur(std::vector<std::vector<SDL_Surface*> > * txtg, int & curh, SDL_Surface * ret);
 	static SDL_Surface * blitTextOnSur(std::vector<std::vector<SDL_Surface*> > * txtg, int & curh, SDL_Surface * ret);
 	static SDL_Surface * blitCompsOnSur(std::vector<SComponent*> & comps, int maxw, int inter, int & curh, SDL_Surface * ret);
 	static SDL_Surface * blitCompsOnSur(std::vector<SComponent*> & comps, int maxw, int inter, int & curh, SDL_Surface * ret);
-	static SDL_Surface* blitCompsOnSur(SDL_Surface * or, std::vector< std::vector<CSelectableComponent*> > *  komp, int inter, int &curh, SDL_Surface *ret);
-	static CInfoWindow * genIWindow(std::string text, int player, int charperline, std::vector<SComponent*> & comps);
-	static std::vector< std::vector<CSelectableComponent*> > * breakComps(std::vector<CSelectableComponent*> & comps,int maxw, SDL_Surface* or=NULL);
+	static SDL_Surface * blitCompsOnSur(SDL_Surface *_or, std::vector< std::vector<CSelectableComponent*> > *komp, int inter, int &curh, SDL_Surface *ret);
+	static CInfoWindow * genIWindow(std::string text, int player, int charperline, std::vector<SComponent*> &comps);
+	static std::vector< std::vector<CSelectableComponent*> > * breakComps(std::vector<CSelectableComponent*> &comps, int maxw, SDL_Surface* _or=NULL);
 	static CSelWindow * genSelWindow(std::string text, int player, int charperline, std::vector<CSelectableComponent*> & comps, int owner);
 	static CSelWindow * genSelWindow(std::string text, int player, int charperline, std::vector<CSelectableComponent*> & comps, int owner);
 	static CSimpleWindow * genWindow(std::string text, int player, int Lmar=35, int Rmar=35, int Tmar=35, int Bmar=35);//supports h3 text formatting; player sets color of window, Lmar/Rmar/Tmar/Bmar are Left/Right/Top/Bottom margins
 	static CSimpleWindow * genWindow(std::string text, int player, int Lmar=35, int Rmar=35, int Tmar=35, int Bmar=35);//supports h3 text formatting; player sets color of window, Lmar/Rmar/Tmar/Bmar are Left/Right/Top/Bottom margins
-	static SDL_Surface * genMessage(std::string title, std::string text, EWindowType type=infoOnly, 
+	static SDL_Surface * genMessage(std::string title, std::string text, EWindowType type=infoOnly,
 								std::vector<CDefHandler*> *addPics=NULL, void * cb=NULL);
 								std::vector<CDefHandler*> *addPics=NULL, void * cb=NULL);
 	static SDL_Surface * drawBox1(int w, int h, int playerColor=1);
 	static SDL_Surface * drawBox1(int w, int h, int playerColor=1);
 	static SDL_Surface * drawBoxTextBitmapSub(int player, std::string text, SDL_Surface* bitmap, std::string sub, int charperline=30);
 	static SDL_Surface * drawBoxTextBitmapSub(int player, std::string text, SDL_Surface* bitmap, std::string sub, int charperline=30);
@@ -46,4 +48,4 @@ public:
 //
 //
 
 
 
 
-#endif //CMESSAGE_H
+#endif //CMESSAGE_H

+ 13 - 13
CPathfinder.cpp

@@ -2,7 +2,7 @@
 #include "global.h"
 #include "global.h"
 #include "CPathfinder.h"
 #include "CPathfinder.h"
 #include "CGameInfo.h"
 #include "CGameInfo.h"
-#include "hch\CAmbarCendamo.h"
+#include "hch/CAmbarCendamo.h"
 #include "mapHandler.h"
 #include "mapHandler.h"
 #include "CGameState.h"
 #include "CGameState.h"
 
 
@@ -34,14 +34,14 @@ vector<Coordinate>* CPathfinder::GetPath(const CGHeroInstance* hero)
 	Hero = hero;
 	Hero = hero;
 
 
 	//Reset the queues
 	//Reset the queues
-	Open = priority_queue < vector<Coordinate>, vector<vector<Coordinate>>, Compare>();
+	Open = priority_queue < vector<Coordinate>, vector<vector<Coordinate> >, Compare>();
 	Closed.clear();
 	Closed.clear();
 
 
 	//Determine if the hero can move on water
 	//Determine if the hero can move on water
 	int3 hpos = Hero->getPosition(false);
 	int3 hpos = Hero->getPosition(false);
 	if (!Hero->canWalkOnSea())
 	if (!Hero->canWalkOnSea())
 	{
 	{
-		if (CGI->mh->ttiles[hpos.x][hpos.y][hpos.z].terType==EterrainType::water)
+		if (CGI->mh->ttiles[hpos.x][hpos.y][hpos.z].terType==water)
 			blockLandSea=false;
 			blockLandSea=false;
 		else
 		else
 			blockLandSea=true;
 			blockLandSea=true;
@@ -137,14 +137,14 @@ bool CPathfinder::ExistsInClosed(Coordinate node)
 }
 }
 
 
 /*
 /*
- * Adds the neighbors of the current node to the open cue so they can be considered in the 
+ * Adds the neighbors of the current node to the open cue so they can be considered in the
  * path creation.  If the node has a cost (f = g + h) less than zero, it isn't added to Open.
  * path creation.  If the node has a cost (f = g + h) less than zero, it isn't added to Open.
 */
 */
 void CPathfinder::AddNeighbors(vector<Coordinate>* branch)
 void CPathfinder::AddNeighbors(vector<Coordinate>* branch)
 {
 {
 	//8 possible Nodes to add
 	//8 possible Nodes to add
-	//   
-	//   1  2  3 
+	//
+	//   1  2  3
 	//   4  X  5
 	//   4  X  5
 	//   6  7  8
 	//   6  7  8
 
 
@@ -192,13 +192,13 @@ void CPathfinder::CalcH(Coordinate* node)
 	 *  => Impossible to move there.
 	 *  => Impossible to move there.
 	 */
 	 */
 	if( (CGI->mh->ttiles[node->x][node->y][node->z].blocked && !(node->x==End.x && node->y==End.y && CGI->mh->ttiles[node->x][node->y][node->z].visitable)) ||
 	if( (CGI->mh->ttiles[node->x][node->y][node->z].blocked && !(node->x==End.x && node->y==End.y && CGI->mh->ttiles[node->x][node->y][node->z].visitable)) ||
-		(CGI->mh->ttiles[node->x][node->y][node->z].terType==EterrainType::rock) ||
-		((blockLandSea) && (CGI->mh->ttiles[node->x][node->y][node->z].terType==EterrainType::water)) ||
+		(CGI->mh->ttiles[node->x][node->y][node->z].terType==rock) ||
+		((blockLandSea) && (CGI->mh->ttiles[node->x][node->y][node->z].terType==water)) ||
 		(!CGI->state->players[Hero->tempOwner].fogOfWarMap[node->x][node->y][node->z]) ||
 		(!CGI->state->players[Hero->tempOwner].fogOfWarMap[node->x][node->y][node->z]) ||
-		((!blockLandSea) && (CGI->mh->ttiles[node->x][node->y][node->z].terType!=EterrainType::water)))
+		((!blockLandSea) && (CGI->mh->ttiles[node->x][node->y][node->z].terType!=water)))
 	{
 	{
 		//Impossible.
 		//Impossible.
-	
+
 		node->h = -1;
 		node->h = -1;
 		return;
 		return;
 	}
 	}
@@ -213,7 +213,7 @@ void CPathfinder::CalcH(Coordinate* node)
 
 
 	//Get the movement cost.
 	//Get the movement cost.
 	ret = Hero->getTileCost(CGI->mh->ttiles[x][y][node->z].terType, CGI->mh->reader->map.terrain[x][y].malle,CGI->mh->reader->map.terrain[x][y].nuine);
 	ret = Hero->getTileCost(CGI->mh->ttiles[x][y][node->z].terType, CGI->mh->reader->map.terrain[x][y].malle,CGI->mh->reader->map.terrain[x][y].nuine);
-	
+
 	node->h = ret;
 	node->h = ret;
 }
 }
 
 
@@ -246,7 +246,7 @@ CPath* CPathfinder::ConvertToOldFormat(vector<Coordinate>* p)
 
 
 		//Set coord
 		//Set coord
 		temp.coord = int3(p->at(i).x,p->at(i).y,p->at(i).z);
 		temp.coord = int3(p->at(i).x,p->at(i).y,p->at(i).z);
-		
+
 		//Set accesible
 		//Set accesible
 		if(p->at(i).h == -1)
 		if(p->at(i).h == -1)
 		{
 		{
@@ -333,4 +333,4 @@ void Coordinate::operator =(const Coordinate &other)
 	this->z = other.z;
 	this->z = other.z;
 	this->g = other.g;
 	this->g = other.g;
 	this->h = other.h;
 	this->h = other.h;
-}
+}

+ 6 - 6
CPathfinder.h

@@ -6,7 +6,7 @@
 #include <math.h>
 #include <math.h>
 class CGHeroInstance;
 class CGHeroInstance;
 
 
-using namespace std; 
+using namespace std;
 
 
 class Coordinate
 class Coordinate
 {
 {
@@ -54,7 +54,7 @@ class CPathfinder
 {
 {
 private:
 private:
 	boost::logic::tribool blockLandSea; //true - blocks sea, false - blocks land, indeterminate - allows all
 	boost::logic::tribool blockLandSea; //true - blocks sea, false - blocks land, indeterminate - allows all
-	
+
 	/*
 	/*
 	 * Does the actual path calculation.  Don't call this directly, call GetPath instead.
 	 * Does the actual path calculation.  Don't call this directly, call GetPath instead.
 	 */
 	 */
@@ -67,7 +67,7 @@ private:
 	bool ExistsInClosed(Coordinate node);
 	bool ExistsInClosed(Coordinate node);
 
 
 	/*
 	/*
-	 * Adds the neighbors of the current node to the open cue so they can be considered in the 
+	 * Adds the neighbors of the current node to the open cue so they can be considered in the
 	 * path creation.  If the node has a cost (f = g + h) less than zero, it isn't added to Open.
 	 * path creation.  If the node has a cost (f = g + h) less than zero, it isn't added to Open.
 	 */
 	 */
 	void AddNeighbors(vector<Coordinate>* node);
 	void AddNeighbors(vector<Coordinate>* node);
@@ -84,7 +84,7 @@ private:
 
 
 public:
 public:
 	//Contains nodes to be searched
 	//Contains nodes to be searched
-	priority_queue < vector<Coordinate>, vector<vector<Coordinate>>, Compare> Open;
+	priority_queue < vector<Coordinate>, vector<vector<Coordinate> >, Compare > Open;
 
 
 	//History of nodes you have been to before
 	//History of nodes you have been to before
 	vector<Coordinate> Closed;
 	vector<Coordinate> Closed;
@@ -97,7 +97,7 @@ public:
 
 
 	//A reference to the Hero.
 	//A reference to the Hero.
 	const CGHeroInstance* Hero;
 	const CGHeroInstance* Hero;
-	
+
 	/*
 	/*
 	 * Does basic input checking and setup for the path calculation.
 	 * Does basic input checking and setup for the path calculation.
 	 */
 	 */
@@ -111,4 +111,4 @@ public:
 
 
 };
 };
 
 
-#endif //CPATHFINDER_H
+#endif //CPATHFINDER_H

+ 61 - 61
CPlayerInterface.cpp

@@ -21,7 +21,7 @@
 #include "timeHandler.h"
 #include "timeHandler.h"
 #include <boost/algorithm/string.hpp>
 #include <boost/algorithm/string.hpp>
 #include <boost/algorithm/string/replace.hpp>
 #include <boost/algorithm/string/replace.hpp>
-#include "hch\CPreGameTextHandler.h"
+#include "hch/CPreGameTextHandler.h"
 #include "CBattleInterface.h"
 #include "CBattleInterface.h"
 #include "CLua.h"
 #include "CLua.h"
 #include <cmath>
 #include <cmath>
@@ -227,7 +227,7 @@ void CGarrisonSlot::show()
 	if(creature)
 	if(creature)
 	{
 	{
 		char* buf = new char[15];
 		char* buf = new char[15];
-		itoa(count,buf,10);
+		SDL_itoa(count,buf,10);
 		blitAt(CGI->creh->bigImgs[creature->idNumber],pos);
 		blitAt(CGI->creh->bigImgs[creature->idNumber],pos);
 		printTo(buf,pos.x+56,pos.y+62,GEOR16,zwykly);
 		printTo(buf,pos.x+56,pos.y+62,GEOR16,zwykly);
 		if(owner->highlighted==this)
 		if(owner->highlighted==this)
@@ -332,7 +332,7 @@ void CGarrisonInt::createSlots()
 			(std::map<int,std::pair<CCreature*,int> >::const_iterator i=set1->slots.begin();
 			(std::map<int,std::pair<CCreature*,int> >::const_iterator i=set1->slots.begin();
 			i!=set1->slots.end(); i++)
 			i!=set1->slots.end(); i++)
 		{
 		{
-			(*sup)[i->first] = 
+			(*sup)[i->first] =
 				new CGarrisonSlot(this, pos.x + (i->first*(58+interx)), pos.y,i->first, 0, i->second.first,i->second.second);
 				new CGarrisonSlot(this, pos.x + (i->first*(58+interx)), pos.y,i->first, 0, i->second.first,i->second.second);
 		}
 		}
 		for(int i=0; i<sup->size(); i++)
 		for(int i=0; i<sup->size(); i++)
@@ -340,13 +340,13 @@ void CGarrisonInt::createSlots()
 				(*sup)[i] = new CGarrisonSlot(this, pos.x + (i*(58+interx)), pos.y,i,0,NULL, 0);
 				(*sup)[i] = new CGarrisonSlot(this, pos.x + (i*(58+interx)), pos.y,i,0,NULL, 0);
 	}
 	}
 	if(set2)
 	if(set2)
-	{	
+	{
 		sdown = new std::vector<CGarrisonSlot*>(7,(CGarrisonSlot *)(NULL));
 		sdown = new std::vector<CGarrisonSlot*>(7,(CGarrisonSlot *)(NULL));
 		for
 		for
 			(std::map<int,std::pair<CCreature*,int> >::const_iterator i=set2->slots.begin();
 			(std::map<int,std::pair<CCreature*,int> >::const_iterator i=set2->slots.begin();
 			i!=set2->slots.end(); i++)
 			i!=set2->slots.end(); i++)
 		{
 		{
-			(*sdown)[i->first] = 
+			(*sdown)[i->first] =
 				new CGarrisonSlot(this, pos.x + (i->first*(58+interx)), pos.y + 64 + intery,i->first,1, i->second.first,i->second.second);
 				new CGarrisonSlot(this, pos.x + (i->first*(58+interx)), pos.y + 64 + intery,i->first,1, i->second.first,i->second.second);
 		}
 		}
 		for(int i=0; i<sup->size(); i++)
 		for(int i=0; i<sup->size(); i++)
@@ -591,7 +591,7 @@ CSelectableComponent::CSelectableComponent(Etype Type, int Sub, int Val, CSelWin
 {
 {
 	SDL_Surface * symb = SComponent::getImg();
 	SDL_Surface * symb = SComponent::getImg();
 	myBitmap = CSDL_Ext::newSurface(symb->w+2,symb->h+2,screen);
 	myBitmap = CSDL_Ext::newSurface(symb->w+2,symb->h+2,screen);
-	SDL_SetColorKey(myBitmap,SDL_SRCCOLORKEY,SDL_MapRGB(myBitmap->format,0,255,255));	
+	SDL_SetColorKey(myBitmap,SDL_SRCCOLORKEY,SDL_MapRGB(myBitmap->format,0,255,255));
 	blitAt(symb,1,1,myBitmap);
 	blitAt(symb,1,1,myBitmap);
 	if (Border) //use custom border
 	if (Border) //use custom border
 	{
 	{
@@ -613,7 +613,7 @@ CSelectableComponent::CSelectableComponent(Etype Type, int Sub, int Val, CSelWin
 			SDL_PutPixel(border,0,i,239,215,123);
 			SDL_PutPixel(border,0,i,239,215,123);
 			SDL_PutPixel(border,(border->w)-1,i,239,215,123);
 			SDL_PutPixel(border,(border->w)-1,i,239,215,123);
 		}
 		}
-		SDL_SetColorKey(border,SDL_SRCCOLORKEY,SDL_MapRGB(border->format,0,255,255));	
+		SDL_SetColorKey(border,SDL_SRCCOLORKEY,SDL_MapRGB(border->format,0,255,255));
 	}
 	}
 	selected = false;
 	selected = false;
 }
 }
@@ -650,7 +650,7 @@ void CSelectableComponent::select(bool on)
 		selected = on;
 		selected = on;
 		return;
 		return;
 	}
 	}
-	else 
+	else
 	{
 	{
 		return;
 		return;
 	}
 	}
@@ -705,7 +705,7 @@ void CSelWindow::close()
 			ret = i;
 			ret = i;
 		}
 		}
 		components[i]->deactivate();
 		components[i]->deactivate();
-	}	
+	}
 	components.clear();
 	components.clear();
 	okb.deactivate();
 	okb.deactivate();
 	SDL_FreeSurface(bitmap);
 	SDL_FreeSurface(bitmap);
@@ -736,7 +736,7 @@ template <typename T> void CSCButton<T>::clickLeft (tribool down)
 	{
 	{
 		state=1;
 		state=1;
 	}
 	}
-	else 
+	else
 	{
 	{
 		state=0;
 		state=0;
 	}
 	}
@@ -745,16 +745,16 @@ template <typename T> void CSCButton<T>::clickLeft (tribool down)
 	if (delg)
 	if (delg)
 		(delg->*func)(down);
 		(delg->*func)(down);
 }
 }
-template <typename T> void CSCButton<typename T>::activate()
+template <typename T> void CSCButton<T>::activate()
 {
 {
 	ClickableL::activate();
 	ClickableL::activate();
 }
 }
-template <typename T> void CSCButton<typename T>::deactivate()
+template <typename T> void CSCButton<T>::deactivate()
 {
 {
 	ClickableL::deactivate();
 	ClickableL::deactivate();
 }
 }
 
 
-template <typename T> void CSCButton<typename T>::show(SDL_Surface * to)
+template <typename T> void CSCButton<T>::show(SDL_Surface * to)
 {
 {
 	if (delg) //we blit on our owner's bitmap
 	if (delg) //we blit on our owner's bitmap
 	{
 	{
@@ -792,7 +792,7 @@ void CButtonBase::show(SDL_Surface * to)
 	if (abs)
 	if (abs)
 	{
 	{
 		blitAt(imgs[curimg]
 		blitAt(imgs[curimg]
-			[( (state+bitmapOffset) < (imgs[curimg].size()) )	?	
+			[( (state+bitmapOffset) < (imgs[curimg].size()) )	?
 				(state+bitmapOffset)	:
 				(state+bitmapOffset)	:
 				(imgs[curimg].size()-1)			]
 				(imgs[curimg].size()-1)			]
 													,pos.x,pos.y,to);
 													,pos.x,pos.y,to);
@@ -801,11 +801,11 @@ void CButtonBase::show(SDL_Surface * to)
 	else
 	else
 	{
 	{
 		blitAt(imgs[curimg]
 		blitAt(imgs[curimg]
-			[( (state+bitmapOffset) < (imgs[curimg].size()) )	?	
+			[( (state+bitmapOffset) < (imgs[curimg].size()) )	?
 				(state+bitmapOffset)	:
 				(state+bitmapOffset)	:
 				(imgs[curimg].size()-1)			],pos.x+ourObj->pos.x,pos.y+ourObj->pos.y,to);
 				(imgs[curimg].size()-1)			],pos.x+ourObj->pos.x,pos.y+ourObj->pos.y,to);
 		//updateRect(&genRect(pos.h,pos.w,pos.x+ourObj->pos.x,pos.y+ourObj->pos.y),to);
 		//updateRect(&genRect(pos.h,pos.w,pos.x+ourObj->pos.x,pos.y+ourObj->pos.y),to);
-		
+
 	}
 	}
 }
 }
 ClickableL::ClickableL()
 ClickableL::ClickableL()
@@ -981,7 +981,7 @@ void CPlayerInterface::yourTurn()
 		//			CGI->mh->reader->defs[wnumber]->ourImages[g].bitmap->format->palette->colors[160 + i] = tab[i];
 		//			CGI->mh->reader->defs[wnumber]->ourImages[g].bitmap->format->palette->colors[160 + i] = tab[i];
 		//		}
 		//		}
 		//		//SDL_SaveBMP(CGI->mh->reader->defs[wnumber]->ourImages[g].bitmap,"t2.bmp");
 		//		//SDL_SaveBMP(CGI->mh->reader->defs[wnumber]->ourImages[g].bitmap,"t2.bmp");
-		//		CSDL_Ext::update(CGI->mh->reader->defs[wnumber]->ourImages[g].bitmap); 
+		//		CSDL_Ext::update(CGI->mh->reader->defs[wnumber]->ourImages[g].bitmap);
 		//	}
 		//	}
 		//}
 		//}
 		//water tiles updated
 		//water tiles updated
@@ -1067,7 +1067,7 @@ void CPlayerInterface::yourTurn()
 	adventureInt->hide();
 	adventureInt->hide();
 }
 }
 
 
-inline void subRect(const int & x, const int & y, const int & z, SDL_Rect & r, const int & hid)
+inline void subRect(const int & x, const int & y, const int & z, const SDL_Rect & r, const int & hid)
 {
 {
 	TerrainTile2 & hlp = CGI->mh->ttiles[x][y][z];
 	TerrainTile2 & hlp = CGI->mh->ttiles[x][y][z];
 	for(int h=0; h<hlp.objects.size(); ++h)
 	for(int h=0; h<hlp.objects.size(); ++h)
@@ -1089,7 +1089,7 @@ inline void delObjRect(const int & x, const int & y, const int & z, const int &
 		}
 		}
 }
 }
 int getDir(int3 src, int3 dst)
 int getDir(int3 src, int3 dst)
-{	
+{
 	int ret = -1;
 	int ret = -1;
 	if(dst.x+1 == src.x && dst.y+1 == src.y) //tl
 	if(dst.x+1 == src.x && dst.y+1 == src.y) //tl
 	{
 	{
@@ -1566,7 +1566,7 @@ SDL_Surface * CPlayerInterface::drawPrimarySkill(const CGHeroInstance *curh, SDL
 	char * buf = new char[10];
 	char * buf = new char[10];
 	for (int i=from;i<to;i++)
 	for (int i=from;i<to;i++)
 	{
 	{
-		itoa(curh->primSkills[i],buf,10);
+		SDL_itoa(curh->primSkills[i],buf,10);
 		printAtMiddle(buf,84+28*i,68,GEOR13,zwykly,ret);
 		printAtMiddle(buf,84+28*i,68,GEOR13,zwykly,ret);
 	}
 	}
 	delete[] buf;
 	delete[] buf;
@@ -1583,11 +1583,11 @@ SDL_Surface * CPlayerInterface::drawHeroInfoWin(const CGHeroInstance * curh)
 	for (std::map<int,std::pair<CCreature*,int> >::const_iterator i=curh->army.slots.begin(); i!=curh->army.slots.end();i++)
 	for (std::map<int,std::pair<CCreature*,int> >::const_iterator i=curh->army.slots.begin(); i!=curh->army.slots.end();i++)
 	{
 	{
 		blitAt(CGI->creh->smallImgs[(*i).second.first->idNumber],slotsPos[(*i).first].first+1,slotsPos[(*i).first].second+1,ret);
 		blitAt(CGI->creh->smallImgs[(*i).second.first->idNumber],slotsPos[(*i).first].first+1,slotsPos[(*i).first].second+1,ret);
-		itoa((*i).second.second,buf,10);
+		SDL_itoa((*i).second.second,buf,10);
 		printAtMiddle(buf,slotsPos[(*i).first].first+17,slotsPos[(*i).first].second+39,GEORM,zwykly,ret);
 		printAtMiddle(buf,slotsPos[(*i).first].first+17,slotsPos[(*i).first].second+39,GEORM,zwykly,ret);
 	}
 	}
 	blitAt(curh->type->portraitLarge,11,12,ret);
 	blitAt(curh->type->portraitLarge,11,12,ret);
-	itoa(curh->mana,buf,10);
+	SDL_itoa(curh->mana,buf,10);
 	printAtMiddle(buf,166,109,GEORM,zwykly,ret); //mana points
 	printAtMiddle(buf,166,109,GEORM,zwykly,ret); //mana points
 	delete[] buf;
 	delete[] buf;
 	blitAt(morale22->ourImages[curh->getCurrentMorale()+3].bitmap,14,84,ret);
 	blitAt(morale22->ourImages[curh->getCurrentMorale()+3].bitmap,14,84,ret);
@@ -1608,14 +1608,14 @@ SDL_Surface * CPlayerInterface::drawTownInfoWin(const CGTownInstance * curh)
 	blitAt(forts->ourImages[pom].bitmap,115,42,ret);
 	blitAt(forts->ourImages[pom].bitmap,115,42,ret);
 	if((pom=curh->hallLevel())>=0)
 	if((pom=curh->hallLevel())>=0)
 		blitAt(halls->ourImages[pom].bitmap,77,42,ret);
 		blitAt(halls->ourImages[pom].bitmap,77,42,ret);
-	itoa(curh->dailyIncome(),buf,10);
+	SDL_itoa(curh->dailyIncome(),buf,10);
 	printAtMiddle(buf,167,70,GEORM,zwykly,ret);
 	printAtMiddle(buf,167,70,GEORM,zwykly,ret);
 	for (std::map<int,std::pair<CCreature*,int> >::const_iterator i=curh->army.slots.begin(); i!=curh->army.slots.end();i++)
 	for (std::map<int,std::pair<CCreature*,int> >::const_iterator i=curh->army.slots.begin(); i!=curh->army.slots.end();i++)
 	{
 	{
 		if(!i->second.first)
 		if(!i->second.first)
 			continue;
 			continue;
 		blitAt(CGI->creh->smallImgs[(*i).second.first->idNumber],slotsPos[(*i).first].first+1,slotsPos[(*i).first].second+1,ret);
 		blitAt(CGI->creh->smallImgs[(*i).second.first->idNumber],slotsPos[(*i).first].first+1,slotsPos[(*i).first].second+1,ret);
-		itoa((*i).second.second,buf,10);
+		SDL_itoa((*i).second.second,buf,10);
 		printAtMiddle(buf,slotsPos[(*i).first].first+17,slotsPos[(*i).first].second+39,GEORM,zwykly,ret);
 		printAtMiddle(buf,slotsPos[(*i).first].first+17,slotsPos[(*i).first].second+39,GEORM,zwykly,ret);
 	}
 	}
 
 
@@ -1827,13 +1827,13 @@ void CPlayerInterface::handleEvent(SDL_Event *sEvent)
 		CGI->curh->cursorMove(sEvent->motion.x, sEvent->motion.y);
 		CGI->curh->cursorMove(sEvent->motion.x, sEvent->motion.y);
 	}
 	}
 
 
-	if(sEvent->type==SDL_QUIT) 
+	if(sEvent->type==SDL_QUIT)
 		exit(0);
 		exit(0);
 	else if (sEvent->type==SDL_KEYDOWN)
 	else if (sEvent->type==SDL_KEYDOWN)
 	{
 	{
 		handleKeyDown(sEvent);
 		handleKeyDown(sEvent);
 	} //keydown end
 	} //keydown end
-	else if(sEvent->type==SDL_KEYUP) 
+	else if(sEvent->type==SDL_KEYUP)
 	{
 	{
 		handleKeyUp(sEvent);
 		handleKeyUp(sEvent);
 	}//keyup end
 	}//keyup end
@@ -1956,12 +1956,12 @@ void CPlayerInterface::garrisonChanged(const CGObjectInstance * obj)
 			hw->garInt->recreateSlots();
 			hw->garInt->recreateSlots();
 			hw->garInt->show();
 			hw->garInt->show();
 		}
 		}
-		else if(castleInt == curint) //opened town window - redraw town garrsion slots (change is within hero garr) 
+		else if(castleInt == curint) //opened town window - redraw town garrsion slots (change is within hero garr)
 		{
 		{
 			castleInt->garr->highlighted = NULL;
 			castleInt->garr->highlighted = NULL;
 			castleInt->garr->recreateSlots();
 			castleInt->garr->recreateSlots();
 		}
 		}
-		
+
 	}
 	}
 	else if (obj->ID == 98) //town
 	else if (obj->ID == 98) //town
 	{
 	{
@@ -1971,7 +1971,7 @@ void CPlayerInterface::garrisonChanged(const CGObjectInstance * obj)
 			SDL_FreeSurface(townWins[tt->identifier]);
 			SDL_FreeSurface(townWins[tt->identifier]);
 			townWins[tt->identifier] = infoWin(tt);
 			townWins[tt->identifier] = infoWin(tt);
 		}
 		}
-		
+
 		const CCastleInterface *ci = dynamic_cast<CCastleInterface*>(curint);
 		const CCastleInterface *ci = dynamic_cast<CCastleInterface*>(curint);
 		if(ci)
 		if(ci)
 		{
 		{
@@ -2040,7 +2040,7 @@ BattleAction CPlayerInterface::activeStack(int stackID) //called when it's turn
 				objsToBlit[i]->show();
 				objsToBlit[i]->show();
 		//SDL_Flip(screen);
 		//SDL_Flip(screen);
 		CSDL_Ext::update(screen);
 		CSDL_Ext::update(screen);
-		
+
 		/*timeHandler th;
 		/*timeHandler th;
 		th.getDif();
 		th.getDif();
 		int tv = th.getDif();
 		int tv = th.getDif();
@@ -2181,7 +2181,7 @@ void CList::activate()
 	Hoverable::activate();
 	Hoverable::activate();
 	KeyInterested::activate();
 	KeyInterested::activate();
 	MotionInterested::activate();
 	MotionInterested::activate();
-}; 
+};
 void CList::deactivate()
 void CList::deactivate()
 {
 {
 	ClickableL::deactivate();
 	ClickableL::deactivate();
@@ -2189,7 +2189,7 @@ void CList::deactivate()
 	Hoverable::deactivate();
 	Hoverable::deactivate();
 	KeyInterested::deactivate();
 	KeyInterested::deactivate();
 	MotionInterested::deactivate();
 	MotionInterested::deactivate();
-}; 
+};
 void CList::clickLeft(tribool down)
 void CList::clickLeft(tribool down)
 {
 {
 };
 };
@@ -2201,7 +2201,7 @@ CHeroList::CHeroList(int Size)
 :CList(Size)
 :CList(Size)
 {
 {
 	pos = genRect(192,64,609,196);
 	pos = genRect(192,64,609,196);
-	
+
 	arrupp = genRect(16,64,609,196);
 	arrupp = genRect(16,64,609,196);
 	arrdop = genRect(16,64,609,372);
 	arrdop = genRect(16,64,609,372);
  //32px per hero
  //32px per hero
@@ -2211,7 +2211,7 @@ CHeroList::CHeroList(int Size)
 	pospory = 212;
 	pospory = 212;
 	posmanx = 666;
 	posmanx = 666;
 	posmany = 213;
 	posmany = 213;
-	
+
 	arrup = CGI->spriteh->giveDef("IAM012.DEF");
 	arrup = CGI->spriteh->giveDef("IAM012.DEF");
 	arrdo = CGI->spriteh->giveDef("IAM013.DEF");
 	arrdo = CGI->spriteh->giveDef("IAM013.DEF");
 	mobile = CGI->spriteh->giveDef("IMOBIL.DEF");
 	mobile = CGI->spriteh->giveDef("IMOBIL.DEF");
@@ -2245,7 +2245,7 @@ void CHeroList::select(int which)
 		draw();
 		draw();
 		LOCPLINT->adventureInt->infoBar.draw(NULL);
 		LOCPLINT->adventureInt->infoBar.draw(NULL);
 	}
 	}
-	if (which>=items.size()) 
+	if (which>=items.size())
 		return;
 		return;
 	selected = which;
 	selected = which;
 	LOCPLINT->adventureInt->centerOn(items[which].first->pos);
 	LOCPLINT->adventureInt->centerOn(items[which].first->pos);
@@ -2254,7 +2254,7 @@ void CHeroList::select(int which)
 	LOCPLINT->adventureInt->terrain.currentPath = items[which].second;
 	LOCPLINT->adventureInt->terrain.currentPath = items[which].second;
 	draw();
 	draw();
 	LOCPLINT->adventureInt->townList.draw();
 	LOCPLINT->adventureInt->townList.draw();
-	
+
 	LOCPLINT->adventureInt->infoBar.draw(NULL);
 	LOCPLINT->adventureInt->infoBar.draw(NULL);
 }
 }
 void CHeroList::clickLeft(tribool down)
 void CHeroList::clickLeft(tribool down)
@@ -2410,7 +2410,7 @@ void CHeroList::updateMove(const CGHeroInstance* which) //draws move points bar
 	blitAt(mobile->ourImages[pom].bitmap,posmobx,posmoby+ser*32); //move point
 	blitAt(mobile->ourImages[pom].bitmap,posmobx,posmoby+ser*32); //move point
 }
 }
 void CHeroList::draw()
 void CHeroList::draw()
-{	
+{
 	for (int iT=0+from;iT<5+from;iT++)
 	for (int iT=0+from;iT<5+from;iT++)
 	{
 	{
 		int i = iT-from;
 		int i = iT-from;
@@ -2477,7 +2477,7 @@ CTownList::CTownList(int Size, SDL_Rect * Pos, int arupx, int arupy, int ardox,
 	pressed = indeterminate;
 	pressed = indeterminate;
 
 
 	from = 0;
 	from = 0;
-	
+
 }
 }
 
 
 void CTownList::genList()
 void CTownList::genList()
@@ -2491,7 +2491,7 @@ void CTownList::genList()
 
 
 void CTownList::select(int which)
 void CTownList::select(int which)
 {
 {
-	if (which>=items.size()) 
+	if (which>=items.size())
 		return;
 		return;
 	selected = which;
 	selected = which;
 	if(!fun.empty())
 	if(!fun.empty())
@@ -2593,7 +2593,7 @@ void CTownList::clickLeft(tribool down)
 }
 }
 
 
 void CTownList::clickRight(tribool down)
 void CTownList::clickRight(tribool down)
-{	
+{
 	if (down)
 	if (down)
 	{
 	{
 		/***************************ARROWS*****************************************/
 		/***************************ARROWS*****************************************/
@@ -2635,7 +2635,7 @@ void CTownList::keyPressed (SDL_KeyboardEvent & key)
 }
 }
 
 
 void CTownList::draw()
 void CTownList::draw()
-{	
+{
 	for (int iT=0+from;iT<SIZE+from;iT++)
 	for (int iT=0+from;iT<SIZE+from;iT++)
 	{
 	{
 		int i = iT-from;
 		int i = iT-from;
@@ -2718,7 +2718,7 @@ void CRecrutationWindow::clickLeft(tribool down)
 	{
 	{
 		if(isItIn(&genRect(132,102,pos.x+curx,pos.y+64),LOCPLINT->current->motion.x,LOCPLINT->current->motion.y))
 		if(isItIn(&genRect(132,102,pos.x+curx,pos.y+64),LOCPLINT->current->motion.x,LOCPLINT->current->motion.y))
 		{
 		{
-			which = i;	
+			which = i;
 			int newAmount = std::min(amounts[i],creatures[i].amount);
 			int newAmount = std::min(amounts[i],creatures[i].amount);
 			slider->amount = newAmount;
 			slider->amount = newAmount;
 			if(slider->value > newAmount)
 			if(slider->value > newAmount)
@@ -2766,9 +2766,9 @@ void CRecrutationWindow::show(SDL_Surface * to)
 	cancel->show();
 	cancel->show();
 	slider->show();
 	slider->show();
 	char pom[15];
 	char pom[15];
-	itoa(creatures[which].amount,pom,10); //available
+	SDL_itoa(creatures[which].amount,pom,10); //available
 	printAtMiddle(pom,pos.x+205,pos.y+252,GEOR13,zwykly,screen);
 	printAtMiddle(pom,pos.x+205,pos.y+252,GEOR13,zwykly,screen);
-	itoa(slider->value,pom,10); //recruit
+	SDL_itoa(slider->value,pom,10); //recruit
 	printAtMiddle(pom,pos.x+279,pos.y+252,GEOR13,zwykly,screen);
 	printAtMiddle(pom,pos.x+279,pos.y+252,GEOR13,zwykly,screen);
 	printAtMiddle(CGI->generaltexth->allTexts[16] + " " + CGI->creh->creatures[creatures[which].ID].namePl,pos.x+243,pos.y+32,GEOR16,tytulowy,screen); //eg "Recruit Dragon flies"
 	printAtMiddle(CGI->generaltexth->allTexts[16] + " " + CGI->creh->creatures[creatures[which].ID].namePl,pos.x+243,pos.y+32,GEOR16,tytulowy,screen); //eg "Recruit Dragon flies"
 	int curx = pos.x+115-creatures[which].res.size()*16;
 	int curx = pos.x+115-creatures[which].res.size()*16;
@@ -2776,9 +2776,9 @@ void CRecrutationWindow::show(SDL_Surface * to)
 	{
 	{
 		blitAt(CGI->townh->resources->ourImages[creatures[which].res[i].first].bitmap,curx,pos.y+243,screen);
 		blitAt(CGI->townh->resources->ourImages[creatures[which].res[i].first].bitmap,curx,pos.y+243,screen);
 		blitAt(CGI->townh->resources->ourImages[creatures[which].res[i].first].bitmap,curx+258,pos.y+243,screen);
 		blitAt(CGI->townh->resources->ourImages[creatures[which].res[i].first].bitmap,curx+258,pos.y+243,screen);
-		itoa(creatures[which].res[i].second,pom,10);
+		SDL_itoa(creatures[which].res[i].second,pom,10);
 		printAtMiddle(pom,curx+12,pos.y+286,GEOR13,zwykly,screen);
 		printAtMiddle(pom,curx+12,pos.y+286,GEOR13,zwykly,screen);
-		itoa(creatures[which].res[i].second * slider->value,pom,10);
+		SDL_itoa(creatures[which].res[i].second * slider->value,pom,10);
 		printAtMiddle(pom,curx+12+258,pos.y+286,GEOR13,zwykly,screen);
 		printAtMiddle(pom,curx+12+258,pos.y+286,GEOR13,zwykly,screen);
 		curx+=32;
 		curx+=32;
 	}
 	}
@@ -2849,7 +2849,7 @@ CRecrutationWindow::CRecrutationWindow(const std::vector<std::pair<int,int> > &C
 	buy = new AdventureMapButton("","",boost::bind(&CRecrutationWindow::Buy,this),pos.x+212,pos.y+313,"IBY6432.DEF");
 	buy = new AdventureMapButton("","",boost::bind(&CRecrutationWindow::Buy,this),pos.x+212,pos.y+313,"IBY6432.DEF");
 	cancel = new AdventureMapButton("","",boost::bind(&CRecrutationWindow::Cancel,this),pos.x+290,pos.y+313,"ICN6432.DEF");
 	cancel = new AdventureMapButton("","",boost::bind(&CRecrutationWindow::Cancel,this),pos.x+290,pos.y+313,"ICN6432.DEF");
 	LOCPLINT->curint->deactivate();
 	LOCPLINT->curint->deactivate();
-	//AdventureMapButton( std::string Name, std::string HelpBox, void(T::*Function)(), 
+	//AdventureMapButton( std::string Name, std::string HelpBox, void(T::*Function)(),
 	//int x, int y, std::string defName, T* Owner, bool activ=false,  std::vector<std::string> * add = NULL, bool playerColoredButton = true );//c-tor
 	//int x, int y, std::string defName, T* Owner, bool activ=false,  std::vector<std::string> * add = NULL, bool playerColoredButton = true );//c-tor
 }//(int x, int y, int totalw, T*Owner,void(T::*Moved)(int to), int Capacity, int Amount, int Value, bool Horizontal)
 }//(int x, int y, int totalw, T*Owner,void(T::*Moved)(int to), int Capacity, int Amount, int Value, bool Horizontal)
 CRecrutationWindow::~CRecrutationWindow()
 CRecrutationWindow::~CRecrutationWindow()
@@ -2922,7 +2922,7 @@ void CSplitWindow::close()
 	deactivate();
 	deactivate();
 	delete this;
 	delete this;
 	LOCPLINT->curint->activate();
 	LOCPLINT->curint->activate();
-	
+
 	CCastleInterface *c = dynamic_cast<CCastleInterface*>(LOCPLINT->curint);
 	CCastleInterface *c = dynamic_cast<CCastleInterface*>(LOCPLINT->curint);
 	if(c) c->showAll();
 	if(c) c->showAll();
 }
 }
@@ -2939,16 +2939,16 @@ void CSplitWindow::show(SDL_Surface * to)
 	ok->show();
 	ok->show();
 	cancel->show();
 	cancel->show();
 	slider->show();
 	slider->show();
-	itoa(a1,pom,10);
+	SDL_itoa(a1,pom,10);
 	printAtMiddle(pom,pos.x+70,pos.y+237,GEOR16,zwykly,screen);
 	printAtMiddle(pom,pos.x+70,pos.y+237,GEOR16,zwykly,screen);
-	itoa(a2,pom,10);
+	SDL_itoa(a2,pom,10);
 	printAtMiddle(pom,pos.x+233,pos.y+237,GEOR16,zwykly,screen);
 	printAtMiddle(pom,pos.x+233,pos.y+237,GEOR16,zwykly,screen);
 	anim->blitPic(screen,pos.x+20,pos.y+54,false);
 	anim->blitPic(screen,pos.x+20,pos.y+54,false);
 	anim->blitPic(screen,pos.x+177,pos.y+54,false);
 	anim->blitPic(screen,pos.x+177,pos.y+54,false);
 }
 }
 void CSplitWindow::keyPressed (SDL_KeyboardEvent & key)
 void CSplitWindow::keyPressed (SDL_KeyboardEvent & key)
 {
 {
-	//TODO: make manual typing possible 
+	//TODO: make manual typing possible
 }
 }
 
 
 void CCreInfoWindow::show(SDL_Surface * to)
 void CCreInfoWindow::show(SDL_Surface * to)
@@ -2985,12 +2985,12 @@ CCreInfoWindow::CCreInfoWindow
 
 
 	//atttack
 	//atttack
 	printAt(CGI->preth->zelp[435].first,155,48,GEOR13,zwykly,bitmap);
 	printAt(CGI->preth->zelp[435].first,155,48,GEOR13,zwykly,bitmap);
-	itoa(c->attack,pom,10);
+	SDL_itoa(c->attack,pom,10);
 	if(State && State->attackBonus)
 	if(State && State->attackBonus)
 	{
 	{
 		int hlp = log10f(c->attack)+2;
 		int hlp = log10f(c->attack)+2;
 		pom[hlp-1] = ' '; pom[hlp] = '(';
 		pom[hlp-1] = ' '; pom[hlp] = '(';
-		itoa(c->attack+State->attackBonus,pom+hlp+1,10);
+		SDL_itoa(c->attack+State->attackBonus,pom+hlp+1,10);
 		hlp += 2+(int)log10f(State->attackBonus+c->attack);
 		hlp += 2+(int)log10f(State->attackBonus+c->attack);
 		pom[hlp] = ')'; pom[hlp+1] = '\0';
 		pom[hlp] = ')'; pom[hlp+1] = '\0';
 	}
 	}
@@ -2998,12 +2998,12 @@ CCreInfoWindow::CCreInfoWindow
 
 
 	//defense
 	//defense
 	printAt(CGI->preth->zelp[436].first,155,67,GEOR13,zwykly,bitmap);
 	printAt(CGI->preth->zelp[436].first,155,67,GEOR13,zwykly,bitmap);
-	itoa(c->defence,pom,10);
+	SDL_itoa(c->defence,pom,10);
 	if(State && State->defenseBonus)
 	if(State && State->defenseBonus)
 	{
 	{
 		int hlp = log10f(c->defence)+2;
 		int hlp = log10f(c->defence)+2;
 		pom[hlp-1] = ' '; pom[hlp] = '(';
 		pom[hlp-1] = ' '; pom[hlp] = '(';
-		itoa(c->defence+State->defenseBonus,pom+hlp+1,10);
+		SDL_itoa(c->defence+State->defenseBonus,pom+hlp+1,10);
 		pom[hlp+2+(int)log10f(State->defenseBonus+c->defence)] = ')';
 		pom[hlp+2+(int)log10f(State->defenseBonus+c->defence)] = ')';
 	}
 	}
 	printToWR(pom,276,80,GEOR13,zwykly,bitmap);
 	printToWR(pom,276,80,GEOR13,zwykly,bitmap);
@@ -3012,21 +3012,21 @@ CCreInfoWindow::CCreInfoWindow
 	if(c->shots)
 	if(c->shots)
 	{
 	{
 		printAt(CGI->generaltexth->allTexts[198],155,86,GEOR13,zwykly,bitmap);
 		printAt(CGI->generaltexth->allTexts[198],155,86,GEOR13,zwykly,bitmap);
-		itoa(c->shots,pom,10);
+		SDL_itoa(c->shots,pom,10);
 		printToWR(pom,276,99,GEOR13,zwykly,bitmap);
 		printToWR(pom,276,99,GEOR13,zwykly,bitmap);
 	}
 	}
 
 
 	//damage
 	//damage
 	printAt(CGI->generaltexth->allTexts[199],155,105,GEOR13,zwykly,bitmap);
 	printAt(CGI->generaltexth->allTexts[199],155,105,GEOR13,zwykly,bitmap);
-	itoa(c->damageMin,pom,10);
+	SDL_itoa(c->damageMin,pom,10);
 	hlp=log10f(c->damageMin)+2;
 	hlp=log10f(c->damageMin)+2;
 	pom[hlp-1]=' '; pom[hlp]='-'; pom[hlp+1]=' ';
 	pom[hlp-1]=' '; pom[hlp]='-'; pom[hlp+1]=' ';
-	itoa(c->damageMax,pom+hlp+2,10);
+	SDL_itoa(c->damageMax,pom+hlp+2,10);
 	printToWR(pom,276,118,GEOR13,zwykly,bitmap);
 	printToWR(pom,276,118,GEOR13,zwykly,bitmap);
 
 
 	//health
 	//health
 	printAt(CGI->preth->zelp[439].first,155,124,GEOR13,zwykly,bitmap);
 	printAt(CGI->preth->zelp[439].first,155,124,GEOR13,zwykly,bitmap);
-	itoa(c->hitPoints,pom,10);
+	SDL_itoa(c->hitPoints,pom,10);
 	printToWR(pom,276,137,GEOR13,zwykly,bitmap);
 	printToWR(pom,276,137,GEOR13,zwykly,bitmap);
 
 
 	//remaining health - TODO: show during the battles
 	//remaining health - TODO: show during the battles
@@ -3034,7 +3034,7 @@ CCreInfoWindow::CCreInfoWindow
 
 
 	//speed
 	//speed
 	printAt(CGI->preth->zelp[441].first,155,162,GEOR13,zwykly,bitmap);
 	printAt(CGI->preth->zelp[441].first,155,162,GEOR13,zwykly,bitmap);
-	itoa(c->speed,pom,10);
+	SDL_itoa(c->speed,pom,10);
 	printToWR(pom,276,175,GEOR13,zwykly,bitmap);
 	printToWR(pom,276,175,GEOR13,zwykly,bitmap);
 
 
 
 
@@ -3105,7 +3105,7 @@ void CCreInfoWindow::keyPressed (SDL_KeyboardEvent & key)
 void CCreInfoWindow::deactivate()
 void CCreInfoWindow::deactivate()
 {
 {
 	if(!type)
 	if(!type)
-		ClickableR::deactivate(); 
+		ClickableR::deactivate();
 	LOCPLINT->objsToBlit.erase(std::find(LOCPLINT->objsToBlit.begin(),LOCPLINT->objsToBlit.end(),this));
 	LOCPLINT->objsToBlit.erase(std::find(LOCPLINT->objsToBlit.begin(),LOCPLINT->objsToBlit.end(),this));
 	if(ok)
 	if(ok)
 		ok->deactivate();
 		ok->deactivate();

+ 16 - 16
CPlayerInterface.h

@@ -154,7 +154,7 @@ public:
 };
 };
 
 
 class CInfoWindow : public CSimpleWindow //text + comp. + ok button
 class CInfoWindow : public CSimpleWindow //text + comp. + ok button
-{ //okno usuwa swoje komponenty w chwili zamkniecia 
+{ //okno usuwa swoje komponenty w chwili zamkniecia
 public:
 public:
 	CSCButton<CInfoWindow> okb;
 	CSCButton<CInfoWindow> okb;
 	std::vector<SComponent*> components;
 	std::vector<SComponent*> components;
@@ -201,15 +201,15 @@ public:
 	{
 	{
 		primskill, secskill, resource, creature, artifact, experience
 		primskill, secskill, resource, creature, artifact, experience
 	} type;
 	} type;
-	int subtype; 
+	int subtype;
 	int val;
 	int val;
 
 
 	std::string description; //r-click
 	std::string description; //r-click
-	std::string subtitle; 
+	std::string subtitle;
 
 
 	SComponent(Etype Type, int Subtype, int Val);
 	SComponent(Etype Type, int Subtype, int Val);
 	//SComponent(const & SComponent r);
 	//SComponent(const & SComponent r);
-	
+
 	void clickRight (boost::logic::tribool down);
 	void clickRight (boost::logic::tribool down);
 	virtual SDL_Surface * getImg();
 	virtual SDL_Surface * getImg();
 	virtual void activate();
 	virtual void activate();
@@ -243,7 +243,7 @@ public:
 	int count;
 	int count;
 	int upg; //0 - up garrison, 1 - down garrison
 	int upg; //0 - up garrison, 1 - down garrison
 	bool active;
 	bool active;
-	
+
 	virtual void hover (bool on);
 	virtual void hover (bool on);
 	const CArmedInstance * getObj();
 	const CArmedInstance * getObj();
 	void clickRight (boost::logic::tribool down);
 	void clickRight (boost::logic::tribool down);
@@ -383,30 +383,30 @@ public:
 	std::string getCurrent();
 	std::string getCurrent();
 };
 };
 
 
-class CList 
+class CList
 	: public ClickableL, public ClickableR, public Hoverable, public KeyInterested, public virtual CIntObject, public MotionInterested
 	: public ClickableL, public ClickableR, public Hoverable, public KeyInterested, public virtual CIntObject, public MotionInterested
 {
 {
 public:
 public:
 	SDL_Surface * bg;
 	SDL_Surface * bg;
 	CDefHandler *arrup, *arrdo;
 	CDefHandler *arrup, *arrdo;
-	SDL_Surface *empty, *selection; 
+	SDL_Surface *empty, *selection;
 	SDL_Rect arrupp, arrdop; //positions of arrows
 	SDL_Rect arrupp, arrdop; //positions of arrows
 	int posw, posh; //position width/height
 	int posw, posh; //position width/height
 	int selected, //id of selected position, <0 if none
 	int selected, //id of selected position, <0 if none
-		from; 
+		from;
 	const int SIZE;
 	const int SIZE;
 	boost::logic::tribool pressed; //true=up; false=down; indeterminate=none
 	boost::logic::tribool pressed; //true=up; false=down; indeterminate=none
 
 
 	CList(int Size = 5);
 	CList(int Size = 5);
 	void clickLeft(boost::logic::tribool down);
 	void clickLeft(boost::logic::tribool down);
-	void activate(); 
+	void activate();
 	void deactivate();
 	void deactivate();
 	virtual void mouseMoved (SDL_MouseMotionEvent & sEvent)=0;
 	virtual void mouseMoved (SDL_MouseMotionEvent & sEvent)=0;
 	virtual void genList()=0;
 	virtual void genList()=0;
 	virtual void select(int which)=0;
 	virtual void select(int which)=0;
 	virtual void draw()=0;
 	virtual void draw()=0;
 };
 };
-class CHeroList 
+class CHeroList
 	: public CList
 	: public CList
 {
 {
 public:
 public:
@@ -429,10 +429,10 @@ public:
 	void init();
 	void init();
 };
 };
 
 
-class CTownList 
+class CTownList
 	: public CList
 	: public CList
 {
 {
-public: 
+public:
 	boost::function<void()> fun;
 	boost::function<void()> fun;
 	std::vector<const CGTownInstance*> items;
 	std::vector<const CGTownInstance*> items;
 	int posporx,pospory;
 	int posporx,pospory;
@@ -484,7 +484,7 @@ public:
 	void Cancel();
 	void Cancel();
 	void sliderMoved(int to);
 	void sliderMoved(int to);
 	void clickLeft(boost::logic::tribool down);
 	void clickLeft(boost::logic::tribool down);
-	void activate(); 
+	void activate();
 	void deactivate();
 	void deactivate();
 	void show(SDL_Surface * to = NULL);
 	void show(SDL_Surface * to = NULL);
 	CRecrutationWindow(const std::vector<std::pair<int,int> > & Creatures, const boost::function<void(int,int)> & Recruit); //creatures - pairs<creature_ID,amount>
 	CRecrutationWindow(const std::vector<std::pair<int,int> > & Creatures, const boost::function<void(int,int)> & Recruit); //creatures - pairs<creature_ID,amount>
@@ -504,7 +504,7 @@ public:
 
 
 	CSplitWindow(int cid, int max, CGarrisonInt *Owner);
 	CSplitWindow(int cid, int max, CGarrisonInt *Owner);
 	~CSplitWindow();
 	~CSplitWindow();
-	void activate(); 
+	void activate();
 	void split();
 	void split();
 	void close();
 	void close();
 	void deactivate();
 	void deactivate();
@@ -527,7 +527,7 @@ public:
 	AdventureMapButton *dismiss, *upgrade, *ok;
 	AdventureMapButton *dismiss, *upgrade, *ok;
 	CCreInfoWindow(int Cid, int Type, StackState *State, boost::function<void()> Upg, boost::function<void()> Dsm);
 	CCreInfoWindow(int Cid, int Type, StackState *State, boost::function<void()> Upg, boost::function<void()> Dsm);
 	~CCreInfoWindow();
 	~CCreInfoWindow();
-	void activate(); 
+	void activate();
 	void close();
 	void close();
 	void clickRight(boost::logic::tribool down);
 	void clickRight(boost::logic::tribool down);
 	void dismissF();
 	void dismissF();
@@ -536,4 +536,4 @@ public:
 	void show(SDL_Surface * to = NULL);
 	void show(SDL_Surface * to = NULL);
 };
 };
 
 
-#endif //CPLAYERINTERFACE_H
+#endif //CPLAYERINTERFACE_H


+ 30 - 23
CPreGame.h

@@ -4,14 +4,15 @@
 #include <set>
 #include <set>
 #include "SDL.h"
 #include "SDL.h"
 #include "StartInfo.h"
 #include "StartInfo.h"
-#include "hch\CSemiDefHandler.h"
-#include "hch\CSemiLodHandler.h"
-#include "hch\CPreGameTextHandler.h" 
+#include "hch/CSemiDefHandler.h"
+#include "hch/CSemiLodHandler.h"
+#include "hch/CPreGameTextHandler.h"
 #include "CMessage.h"
 #include "CMessage.h"
 #include "map.h"
 #include "map.h"
-#include "hch\CMusicHandler.h"
+#include "hch/CMusicHandler.h"
+
 class CPreGame;
 class CPreGame;
-extern CPreGame * CPG;
+extern class CPreGame *CPG;
 
 
 typedef void(CPreGame::*ttt)();
 typedef void(CPreGame::*ttt)();
 template <class T=ttt> class CGroup;
 template <class T=ttt> class CGroup;
@@ -44,12 +45,12 @@ template <class T=ttt> struct Button: public HighButton
 	T fun;
 	T fun;
 	virtual	void hover(bool on=true);
 	virtual	void hover(bool on=true);
 	virtual void select(bool on=true);
 	virtual void select(bool on=true);
-};	
+};
 template <class T=ttt> struct SetrButton: public Button<T>
 template <class T=ttt> struct SetrButton: public Button<T>
 {
 {
 	int key, * poin;
 	int key, * poin;
 	virtual void press(bool down=true);
 	virtual void press(bool down=true);
-	SetrButton(){type=1;selectable=selected=false;state=0;highlightable=false;}
+	SetrButton(){int type=1;bool selectable=false;bool selected=false;int state=0;bool highlightable=false;}
 };
 };
 template<class T=CPreGame>  class Slider
 template<class T=CPreGame>  class Slider
 { //
 { //
@@ -57,7 +58,7 @@ public:
 	bool vertical; // false means horizontal
 	bool vertical; // false means horizontal
 	SDL_Rect pos; // position
 	SDL_Rect pos; // position
 	Button<void(Slider::*)()> up, down, //or left/right
 	Button<void(Slider::*)()> up, down, //or left/right
-		slider; 
+		slider;
 	int positionsAmnt, capacity;// capacity - amount of positions dispplayed at once
 	int positionsAmnt, capacity;// capacity - amount of positions dispplayed at once
 	int whereAreWe; // first displayed thing
 	int whereAreWe; // first displayed thing
 	bool moving;
 	bool moving;
@@ -80,7 +81,7 @@ template<class T=ttt>  struct IntBut: public Button<T>
 public:
 public:
 	int key;
 	int key;
 	int * what;
 	int * what;
-	IntBut(){type=2;fun=NULL;highlightable=false;};
+	IntBut(){int type=2;int fun=NULL;bool highlightable=false;};
 	void set(){*what=key;};
 	void set(){*what=key;};
 };
 };
 template<class T=ttt>  struct IntSelBut: public Button<T>
 template<class T=ttt>  struct IntSelBut: public Button<T>
@@ -90,8 +91,14 @@ public:
 	int key;
 	int key;
 	IntSelBut(){};
 	IntSelBut(){};
 	IntSelBut( SDL_Rect Pos, T Fun,CDefHandler* Imgs, bool Sel=false, CPoinGroup<T>* gr=NULL, int My=-1)
 	IntSelBut( SDL_Rect Pos, T Fun,CDefHandler* Imgs, bool Sel=false, CPoinGroup<T>* gr=NULL, int My=-1)
-		: Button(Pos,Fun,Imgs,Sel,gr),key(My){ourPoinGroup=gr;};
-	void select(bool on=true) {(*this).Button::select(on);ourPoinGroup->setYour(this);CPG->printRating();}
+		: Button<T>(Pos,Fun,Imgs,Sel,gr),key(My){ourPoinGroup=gr;};
+	void select(bool on=true) {(*this).Button<T>::select(on);ourPoinGroup->setYour(this);
+		#ifndef __amigaos4__
+		CPG->printRating();
+		#else
+		#warning not compile here
+		#endif
+		}
 };
 };
 template <class T> class CPoinGroup :public CGroup<T>
 template <class T> class CPoinGroup :public CGroup<T>
 {
 {
@@ -183,7 +190,7 @@ public:
 	ESortBy sortBy;
 	ESortBy sortBy;
 	SDL_Surface * bg;
 	SDL_Surface * bg;
 	int selected; //selected map
 	int selected; //selected map
-	CDefHandler * Dtypes, * Dvic; 
+	CDefHandler * Dtypes, * Dvic;
 	CDefHandler *Dsizes, * Dloss,
 	CDefHandler *Dsizes, * Dloss,
 		* sFlags;
 		* sFlags;
 	std::vector<Mapa*> scenList;
 	std::vector<Mapa*> scenList;
@@ -229,7 +236,7 @@ public:
 } ;
 } ;
 class CPreGame
 class CPreGame
 {
 {
-public:	
+public:
 	std::string playerName;
 	std::string playerName;
 	int playerColor;
 	int playerColor;
 	HighButton * highlighted;
 	HighButton * highlighted;
@@ -241,13 +248,13 @@ public:
 	CMusicHandler * mush;
 	CMusicHandler * mush;
 	std::vector<HighButton *> btns;
 	std::vector<HighButton *> btns;
 	CPreGameTextHandler * preth ;
 	CPreGameTextHandler * preth ;
-	SDL_Rect * currentMessage;	
+	SDL_Rect * currentMessage;
 	SDL_Surface * behindCurMes;
 	SDL_Surface * behindCurMes;
 	CDefHandler *ok, *cancel;
 	CDefHandler *ok, *cancel;
 	enum EState { //where are we?
 	enum EState { //where are we?
 		mainMenu, newGame, loadGame, ScenarioList
 		mainMenu, newGame, loadGame, ScenarioList
 	} state;
 	} state;
-	struct menuItems { 
+	struct menuItems {
 		SDL_Surface * background, *bgAd;
 		SDL_Surface * background, *bgAd;
 		CDefHandler *newGame, *loadGame, *highScores,*credits, *quit;
 		CDefHandler *newGame, *loadGame, *highScores,*credits, *quit;
 		SDL_Rect lNewGame, lLoadGame, lHighScores, lCredits, lQuit;
 		SDL_Rect lNewGame, lLoadGame, lHighScores, lCredits, lQuit;
@@ -264,15 +271,15 @@ public:
 	void scenHandleEv(SDL_Event& sEvent);
 	void scenHandleEv(SDL_Event& sEvent);
 	void begin(){run=false;ret.difficulty=ourScenSel->selectedDiff;};
 	void begin(){run=false;ret.difficulty=ourScenSel->selectedDiff;};
 	void quitAskBox();
 	void quitAskBox();
-	void quit(){exit(0);};  
-	void initScenSel(); 
-	void showScenSel();  
-	void showScenList(); 
+	void quit(){exit(0);};
+	void initScenSel();
+	void showScenSel();
+	void showScenList();
 	void initOptions();
 	void initOptions();
-	void showOptions();  
-	void initNewMenu(); 
-	void showNewMenu();  
-	void showMainMenu();  
+	void showOptions();
+	void initNewMenu();
+	void showNewMenu();
+	void showMainMenu();
 	StartInfo runLoop(); // runs mainloop of PreGame
 	StartInfo runLoop(); // runs mainloop of PreGame
 	void initMainMenu(); //loads components for main menu
 	void initMainMenu(); //loads components for main menu
 	void highlightButton(int which, int on); //highlights one from 5 main menu buttons
 	void highlightButton(int which, int on); //highlights one from 5 main menu buttons

+ 2 - 2
CScreenHandler.cpp

@@ -6,7 +6,7 @@
 #include "SDL_Extensions.h"
 #include "SDL_Extensions.h"
 #include "CCursorHandler.h"
 #include "CCursorHandler.h"
 #include "CGameInfo.h"
 #include "CGameInfo.h"
-#include "hch\CDefHandler.h"
+#include "hch/CDefHandler.h"
 
 
 extern SDL_Surface * screen, * screen2;
 extern SDL_Surface * screen, * screen2;
 
 
@@ -42,4 +42,4 @@ void CScreenHandler::updateScreen()
 		}
 		}
 	}
 	}
 	CSDL_Ext::update(screen2);*/
 	CSDL_Ext::update(screen2);*/
-}
+}

+ 1 - 1
CScreenHandler.h

@@ -14,4 +14,4 @@ public:
 
 
 
 
 
 
-#endif //CSCREENHANDLER_H
+#endif //CSCREENHANDLER_H

+ 45 - 26
SDL_Extensions.cpp

@@ -7,7 +7,7 @@
 #include <algorithm>
 #include <algorithm>
 #include "CMessage.h"
 #include "CMessage.h"
 #include <boost/algorithm/string.hpp>
 #include <boost/algorithm/string.hpp>
-#include "hch\CDefHandler.h"
+#include "hch/CDefHandler.h"
 #include <map>
 #include <map>
 
 
 extern SDL_Color playerColorPalette[256];
 extern SDL_Color playerColorPalette[256];
@@ -235,34 +235,38 @@ void CSDL_Ext::printToWR(std::string text, int x, int y, TTF_Font * font, SDL_Co
 void CSDL_Ext::SDL_PutPixel(SDL_Surface *ekran, int x, int y, Uint8 R, Uint8 G, Uint8 B, int myC, Uint8 A)
 void CSDL_Ext::SDL_PutPixel(SDL_Surface *ekran, int x, int y, Uint8 R, Uint8 G, Uint8 B, int myC, Uint8 A)
 {
 {
 	Uint8 *p = (Uint8 *)ekran->pixels + y * ekran->pitch + x * ekran->format->BytesPerPixel-myC;
 	Uint8 *p = (Uint8 *)ekran->pixels + y * ekran->pitch + x * ekran->format->BytesPerPixel-myC;
+/*
 #if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
 #if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
 	p[0] = R;
 	p[0] = R;
 	p[1] = G;
 	p[1] = G;
 	p[2] = B;
 	p[2] = B;
 #else
 #else
+*/
 	p[0] = B;
 	p[0] = B;
 	p[1] = G;
 	p[1] = G;
 	p[2] = R;
 	p[2] = R;
 	if(ekran->format->BytesPerPixel==4)
 	if(ekran->format->BytesPerPixel==4)
 		p[3] = A;
 		p[3] = A;
-#endif
+//#endif
 	SDL_UpdateRect(ekran, x, y, 1, 1);
 	SDL_UpdateRect(ekran, x, y, 1, 1);
 }
 }
 
 
 void CSDL_Ext::SDL_PutPixelWithoutRefresh(SDL_Surface *ekran, int x, int y, Uint8 R, Uint8 G, Uint8 B, int myC, Uint8 A)
 void CSDL_Ext::SDL_PutPixelWithoutRefresh(SDL_Surface *ekran, int x, int y, Uint8 R, Uint8 G, Uint8 B, int myC, Uint8 A)
 {
 {
      Uint8 *p = (Uint8 *)ekran->pixels + y * ekran->pitch + x * ekran->format->BytesPerPixel-myC;
      Uint8 *p = (Uint8 *)ekran->pixels + y * ekran->pitch + x * ekran->format->BytesPerPixel-myC;
+/*
 #if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
 #if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
 	p[0] = B;
 	p[0] = B;
 	p[1] = G;
 	p[1] = G;
 	p[2] = R;
 	p[2] = R;
 #else
 #else
+*/
 	p[0] = R;
 	p[0] = R;
 	p[1] = G;
 	p[1] = G;
 	p[2] = B;
 	p[2] = B;
 	if(ekran->format->BytesPerPixel==4)
 	if(ekran->format->BytesPerPixel==4)
 		p[3] = A;
 		p[3] = A;
-#endif
+//#endif
 }
 }
 
 
 ///**************/
 ///**************/
@@ -280,11 +284,14 @@ SDL_Surface * CSDL_Ext::rotate01(SDL_Surface * toRot, int myC)
 			{
 			{
 				{
 				{
 					Uint8 *p = (Uint8 *)toRot->pixels + j * toRot->pitch + (ret->w - i - 1) * toRot->format->BytesPerPixel;
 					Uint8 *p = (Uint8 *)toRot->pixels + j * toRot->pitch + (ret->w - i - 1) * toRot->format->BytesPerPixel;
+/*
+
 #if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
 #if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
 						CSDL_Ext::SDL_PutPixel(ret, i, j, p[0], p[1], p[2], myC);
 						CSDL_Ext::SDL_PutPixel(ret, i, j, p[0], p[1], p[2], myC);
 #else
 #else
+*/
 						CSDL_Ext::SDL_PutPixel(ret, i, j, p[2], p[1], p[0], myC);
 						CSDL_Ext::SDL_PutPixel(ret, i, j, p[2], p[1], p[0], myC);
-#endif
+//#endif
 				}
 				}
 			}
 			}
 		}
 		}
@@ -317,11 +324,13 @@ SDL_Surface * CSDL_Ext::hFlip(SDL_Surface * toRot)
 				{
 				{
 					Uint8 *p = (Uint8 *)toRot->pixels + (ret->h - j -1) * toRot->pitch + i * toRot->format->BytesPerPixel;
 					Uint8 *p = (Uint8 *)toRot->pixels + (ret->h - j -1) * toRot->pitch + i * toRot->format->BytesPerPixel;
 					//int k=2;
 					//int k=2;
+/*
 #if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
 #if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
 						CSDL_Ext::SDL_PutPixel(ret, i, j, p[0], p[1], p[2]);
 						CSDL_Ext::SDL_PutPixel(ret, i, j, p[0], p[1], p[2]);
 #else
 #else
+*/
 						CSDL_Ext::SDL_PutPixel(ret, i, j, p[2], p[1], p[0]);
 						CSDL_Ext::SDL_PutPixel(ret, i, j, p[2], p[1], p[0]);
-#endif
+//#endif
 				}
 				}
 			}
 			}
 		}
 		}
@@ -355,11 +364,13 @@ SDL_Surface * CSDL_Ext::rotate02(SDL_Surface * toRot)
 		{
 		{
 			{
 			{
 				Uint8 *p = (Uint8 *)toRot->pixels + i * toRot->pitch + j * toRot->format->BytesPerPixel;
 				Uint8 *p = (Uint8 *)toRot->pixels + i * toRot->pitch + j * toRot->format->BytesPerPixel;
+/*
 #if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
 #if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
 					SDL_PutPixel(ret, i, j, p[0], p[1], p[2]);
 					SDL_PutPixel(ret, i, j, p[0], p[1], p[2]);
 #else
 #else
+*/
 					SDL_PutPixel(ret, i, j, p[2], p[1], p[0]);
 					SDL_PutPixel(ret, i, j, p[2], p[1], p[0]);
-#endif
+//#endif
 			}
 			}
 		}
 		}
 	}
 	}
@@ -381,11 +392,13 @@ SDL_Surface * CSDL_Ext::rotate03(SDL_Surface * toRot)
 			{
 			{
 				{
 				{
 					Uint8 *p = (Uint8 *)toRot->pixels + (ret->h - j - 1) * toRot->pitch + (ret->w - i - 1) * toRot->format->BytesPerPixel+2;
 					Uint8 *p = (Uint8 *)toRot->pixels + (ret->h - j - 1) * toRot->pitch + (ret->w - i - 1) * toRot->format->BytesPerPixel+2;
+/*
 #if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
 #if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
 						SDL_PutPixel(ret, i, j, p[0], p[1], p[2], 2);
 						SDL_PutPixel(ret, i, j, p[0], p[1], p[2], 2);
 #else
 #else
+*/
 						SDL_PutPixel(ret, i, j, p[2], p[1], p[0], 2);
 						SDL_PutPixel(ret, i, j, p[2], p[1], p[0], 2);
-#endif
+//#endif
 				}
 				}
 			}
 			}
 		}
 		}
@@ -461,11 +474,13 @@ Uint32 CSDL_Ext::SDL_GetPixel(SDL_Surface *surface, const int & x, const int & y
         return *(Uint16 *)p;
         return *(Uint16 *)p;
 
 
     case 3:
     case 3:
+/*
 #if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
 #if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
             return p[0] << 16 | p[1] << 8 | p[2];
             return p[0] << 16 | p[1] << 8 | p[2];
 #else
 #else
+*/
             return p[0] | p[1] << 8 | p[2] << 16;
             return p[0] | p[1] << 8 | p[2] << 16;
-#endif
+//#endif
 
 
     case 4:
     case 4:
         return *(Uint32 *)p;
         return *(Uint32 *)p;
@@ -480,11 +495,11 @@ SDL_Surface * CSDL_Ext::alphaTransform(SDL_Surface *src)
 	Uint32 trans = SDL_MapRGBA(src->format, 0, 255, 255, 255);
 	Uint32 trans = SDL_MapRGBA(src->format, 0, 255, 255, 255);
 	SDL_SetColorKey(src, 0, trans);
 	SDL_SetColorKey(src, 0, trans);
 	src->flags|=SDL_SRCALPHA;
 	src->flags|=SDL_SRCALPHA;
-	
+
 	SDL_Color transp;
 	SDL_Color transp;
 	transp.b = transp.g = transp.r = 0;
 	transp.b = transp.g = transp.r = 0;
 	transp.unused = 255;
 	transp.unused = 255;
-	
+
 	if(src->format->BitsPerPixel == 8)
 	if(src->format->BitsPerPixel == 8)
 	{
 	{
 		for(int yy=0; yy<src->format->palette->ncolors; ++yy)
 		for(int yy=0; yy<src->format->palette->ncolors; ++yy)
@@ -562,7 +577,7 @@ int CSDL_Ext::blit8bppAlphaTo24bpp(SDL_Surface * src, SDL_Rect * srcRect, SDL_Su
 		/* clip the source rectangle to the source surface */
 		/* clip the source rectangle to the source surface */
 		if(srcRect) {
 		if(srcRect) {
 				int maxw, maxh;
 				int maxw, maxh;
-		
+
 			srcx = srcRect->x;
 			srcx = srcRect->x;
 			w = srcRect->w;
 			w = srcRect->w;
 			if(srcx < 0) {
 			if(srcx < 0) {
@@ -584,7 +599,7 @@ int CSDL_Ext::blit8bppAlphaTo24bpp(SDL_Surface * src, SDL_Rect * srcRect, SDL_Su
 			maxh = src->h - srcy;
 			maxh = src->h - srcy;
 			if(maxh < h)
 			if(maxh < h)
 				h = maxh;
 				h = maxh;
-		    
+
 		} else {
 		} else {
 				srcx = srcy = 0;
 				srcx = srcy = 0;
 			w = src->w;
 			w = src->w;
@@ -634,11 +649,11 @@ int CSDL_Ext::blit8bppAlphaTo24bpp(SDL_Surface * src, SDL_Rect * srcRect, SDL_Su
 						SDL_Color tbc = src->format->palette->colors[*((Uint8*)src->pixels + (y+sr.y)*src->pitch + x + sr.x)]; //color to blit
 						SDL_Color tbc = src->format->palette->colors[*((Uint8*)src->pixels + (y+sr.y)*src->pitch + x + sr.x)]; //color to blit
 						Uint8 * p = (Uint8*)dst->pixels + (y+dstRect->y)*dst->pitch + (x+dstRect->x)*dst->format->BytesPerPixel; //place to blit at
 						Uint8 * p = (Uint8*)dst->pixels + (y+dstRect->y)*dst->pitch + (x+dstRect->x)*dst->format->BytesPerPixel; //place to blit at
 
 
-						// According analyze, the values of tbc.unused are fixed, 
+						// According analyze, the values of tbc.unused are fixed,
 						// and the approximate ratios are as following:
 						// and the approximate ratios are as following:
 						//
 						//
 						// tbc.unused	numbers
 						// tbc.unused	numbers
-						// 192			    2679					
+						// 192			    2679
 						// 164			  326907
 						// 164			  326907
 						// 82			  705590
 						// 82			  705590
 						// 214			 1292625
 						// 214			 1292625
@@ -648,7 +663,7 @@ int CSDL_Ext::blit8bppAlphaTo24bpp(SDL_Surface * src, SDL_Rect * srcRect, SDL_Su
 						//
 						//
 						// By making use of such characteristic, we may implement a
 						// By making use of such characteristic, we may implement a
 						// very fast algorithm for heroes3 without loose much quality.
 						// very fast algorithm for heroes3 without loose much quality.
-						switch ((Uint32)tbc.unused) 
+						switch ((Uint32)tbc.unused)
 						{
 						{
 							case 255:
 							case 255:
 								break;
 								break;
@@ -666,9 +681,9 @@ int CSDL_Ext::blit8bppAlphaTo24bpp(SDL_Surface * src, SDL_Rect * srcRect, SDL_Su
 								p[0] = ((((Uint32)p[0]-(Uint32)tbc.r)*(Uint32)tbc.unused) >> 8 + (Uint32)tbc.r) & 0xFF;
 								p[0] = ((((Uint32)p[0]-(Uint32)tbc.r)*(Uint32)tbc.unused) >> 8 + (Uint32)tbc.r) & 0xFF;
 								p[1] = ((((Uint32)p[1]-(Uint32)tbc.g)*(Uint32)tbc.unused) >> 8 + (Uint32)tbc.g) & 0xFF;
 								p[1] = ((((Uint32)p[1]-(Uint32)tbc.g)*(Uint32)tbc.unused) >> 8 + (Uint32)tbc.g) & 0xFF;
 								p[2] = ((((Uint32)p[2]-(Uint32)tbc.b)*(Uint32)tbc.unused) >> 8 + (Uint32)tbc.b) & 0xFF;
 								p[2] = ((((Uint32)p[2]-(Uint32)tbc.b)*(Uint32)tbc.unused) >> 8 + (Uint32)tbc.b) & 0xFF;
-								//p[0] = ((Uint32)tbc.unused*(Uint32)p[0] + (Uint32)tbc.r*(Uint32)(255-tbc.unused))>>8; //red 
-								//p[1] = ((Uint32)tbc.unused*(Uint32)p[1] + (Uint32)tbc.g*(Uint32)(255-tbc.unused))>>8; //green 
-								//p[2] = ((Uint32)tbc.unused*(Uint32)p[2] + (Uint32)tbc.b*(Uint32)(255-tbc.unused))>>8; //blue 
+								//p[0] = ((Uint32)tbc.unused*(Uint32)p[0] + (Uint32)tbc.r*(Uint32)(255-tbc.unused))>>8; //red
+								//p[1] = ((Uint32)tbc.unused*(Uint32)p[1] + (Uint32)tbc.g*(Uint32)(255-tbc.unused))>>8; //green
+								//p[2] = ((Uint32)tbc.unused*(Uint32)p[2] + (Uint32)tbc.b*(Uint32)(255-tbc.unused))>>8; //blue
 								break;
 								break;
 						}
 						}
 					}
 					}
@@ -682,8 +697,8 @@ int CSDL_Ext::blit8bppAlphaTo24bpp(SDL_Surface * src, SDL_Rect * srcRect, SDL_Su
 					{
 					{
 						SDL_Color tbc = src->format->palette->colors[*((Uint8*)src->pixels + (y+sr.y)*src->pitch + x + sr.x)]; //color to blit
 						SDL_Color tbc = src->format->palette->colors[*((Uint8*)src->pixels + (y+sr.y)*src->pitch + x + sr.x)]; //color to blit
 						Uint8 * p = (Uint8*)dst->pixels + (y+dstRect->y)*dst->pitch + (x+dstRect->x)*dst->format->BytesPerPixel; //place to blit at
 						Uint8 * p = (Uint8*)dst->pixels + (y+dstRect->y)*dst->pitch + (x+dstRect->x)*dst->format->BytesPerPixel; //place to blit at
-						
-						switch ((Uint32)tbc.unused) 
+
+						switch ((Uint32)tbc.unused)
 						{
 						{
 							case 255:
 							case 255:
 								break;
 								break;
@@ -701,9 +716,9 @@ int CSDL_Ext::blit8bppAlphaTo24bpp(SDL_Surface * src, SDL_Rect * srcRect, SDL_Su
 								p[2] = ((((Uint32)p[2]-(Uint32)tbc.r)*(Uint32)tbc.unused) >> 8 + (Uint32)tbc.r) & 0xFF;
 								p[2] = ((((Uint32)p[2]-(Uint32)tbc.r)*(Uint32)tbc.unused) >> 8 + (Uint32)tbc.r) & 0xFF;
 								p[1] = ((((Uint32)p[1]-(Uint32)tbc.g)*(Uint32)tbc.unused) >> 8 + (Uint32)tbc.g) & 0xFF;
 								p[1] = ((((Uint32)p[1]-(Uint32)tbc.g)*(Uint32)tbc.unused) >> 8 + (Uint32)tbc.g) & 0xFF;
 								p[0] = ((((Uint32)p[0]-(Uint32)tbc.b)*(Uint32)tbc.unused) >> 8 + (Uint32)tbc.b) & 0xFF;
 								p[0] = ((((Uint32)p[0]-(Uint32)tbc.b)*(Uint32)tbc.unused) >> 8 + (Uint32)tbc.b) & 0xFF;
-								//p[2] = ((Uint32)tbc.unused*(Uint32)p[2] + (Uint32)tbc.r*(Uint32)(255-tbc.unused))>>8; //red 
-								//p[1] = ((Uint32)tbc.unused*(Uint32)p[1] + (Uint32)tbc.g*(Uint32)(255-tbc.unused))>>8; //green 
-								//p[0] = ((Uint32)tbc.unused*(Uint32)p[0] + (Uint32)tbc.b*(Uint32)(255-tbc.unused))>>8; //blue 
+								//p[2] = ((Uint32)tbc.unused*(Uint32)p[2] + (Uint32)tbc.r*(Uint32)(255-tbc.unused))>>8; //red
+								//p[1] = ((Uint32)tbc.unused*(Uint32)p[1] + (Uint32)tbc.g*(Uint32)(255-tbc.unused))>>8; //green
+								//p[0] = ((Uint32)tbc.unused*(Uint32)p[0] + (Uint32)tbc.b*(Uint32)(255-tbc.unused))>>8; //blue
 								break;
 								break;
 						}
 						}
 					}
 					}
@@ -755,6 +770,7 @@ void CSDL_Ext::blueToPlayers(SDL_Surface * sur, int player)
 			for(int x=0; x<sur->w; ++x)
 			for(int x=0; x<sur->w; ++x)
 			{
 			{
 				Uint8* cp = (Uint8*)sur->pixels + y+sur->pitch + x*3;
 				Uint8* cp = (Uint8*)sur->pixels + y+sur->pitch + x*3;
+/*
 				if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
 				if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
 				{
 				{
 					if(cp[0]==0 && cp[1]==0 && cp[2]==255)
 					if(cp[0]==0 && cp[1]==0 && cp[2]==255)
@@ -766,14 +782,15 @@ void CSDL_Ext::blueToPlayers(SDL_Surface * sur, int player)
 				}
 				}
 				else
 				else
 				{
 				{
-					
+
+*/
 					if(cp[0]==255 && cp[1]==0 && cp[2]==0)
 					if(cp[0]==255 && cp[1]==0 && cp[2]==0)
 					{
 					{
 						cp[0] = CGameInfo::mainObj->playerColors[player].b;
 						cp[0] = CGameInfo::mainObj->playerColors[player].b;
 						cp[1] = CGameInfo::mainObj->playerColors[player].g;
 						cp[1] = CGameInfo::mainObj->playerColors[player].g;
 						cp[2] = CGameInfo::mainObj->playerColors[player].r;
 						cp[2] = CGameInfo::mainObj->playerColors[player].r;
 					}
 					}
-				}
+//				}
 			}
 			}
 		}
 		}
 	}
 	}
@@ -797,6 +814,7 @@ void CSDL_Ext::blueToPlayersAdv(SDL_Surface * sur, int player, int mode, void* a
 			for(int x=0; x<sur->w; ++x)
 			for(int x=0; x<sur->w; ++x)
 			{
 			{
 				Uint8* cp = (Uint8*)sur->pixels + y*sur->pitch + x*3;
 				Uint8* cp = (Uint8*)sur->pixels + y*sur->pitch + x*3;
+/*
 				if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
 				if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
 				{
 				{
 					if(cp[2]>cp[1] && cp[2]>cp[0])
 					if(cp[2]>cp[1] && cp[2]>cp[0])
@@ -823,6 +841,7 @@ void CSDL_Ext::blueToPlayersAdv(SDL_Surface * sur, int player, int mode, void* a
 					}
 					}
 				}
 				}
 				else
 				else
+*/
 				{
 				{
 					if(
 					if(
 						((mode==0) && (cp[0]>cp[1]) && (cp[0]>cp[2])) ||
 						((mode==0) && (cp[0]>cp[1]) && (cp[0]>cp[2])) ||
@@ -873,7 +892,7 @@ void CSDL_Ext::setPlayerColor(SDL_Surface * sur, unsigned char player)
 		return;
 		return;
 	if(sur->format->BitsPerPixel==8)
 	if(sur->format->BitsPerPixel==8)
 	{
 	{
-		if(player != 255) 
+		if(player != 255)
 			*(sur->format->palette->colors+5) = CGameInfo::mainObj->playerColors[player];
 			*(sur->format->palette->colors+5) = CGameInfo::mainObj->playerColors[player];
 		else
 		else
 			*(sur->format->palette->colors+5) = CGameInfo::mainObj->neutralColor;
 			*(sur->format->palette->colors+5) = CGameInfo::mainObj->neutralColor;

+ 1 - 1
SDL_Extensions.h

@@ -56,4 +56,4 @@ namespace CSDL_Ext
 	SDL_Surface * copySurface(SDL_Surface * mod); //returns copy of given surface
 	SDL_Surface * copySurface(SDL_Surface * mod); //returns copy of given surface
 };
 };
 
 
-#endif // SDL_EXTENSIONS_H
+#endif // SDL_EXTENSIONS_H

+ 7 - 3
StartInfo.h

@@ -13,8 +13,8 @@ struct StartInfo
 		int castle, hero,  //ID, if -1 then random, if -2 then none
 		int castle, hero,  //ID, if -1 then random, if -2 then none
 			heroPortrait; //-1 if default, else ID
 			heroPortrait; //-1 if default, else ID
 		std::string heroName;
 		std::string heroName;
-		Ebonus bonus; 
-		Ecolor color; //from 0 - 
+		Ebonus bonus;
+		Ecolor color; //from 0 -
 		int serial;
 		int serial;
 		int handicap;//0-no, 1-mild, 2-severe
 		int handicap;//0-no, 1-mild, 2-severe
 		std::string name;
 		std::string name;
@@ -28,8 +28,12 @@ struct StartInfo
 		for(int i=0; i<playerInfos.size(); ++i)
 		for(int i=0; i<playerInfos.size(); ++i)
 			if(playerInfos[i].color == no)
 			if(playerInfos[i].color == no)
 				return playerInfos[i];
 				return playerInfos[i];
+#ifndef __GNUC__
 		throw new std::exception("Cannot find info about player");
 		throw new std::exception("Cannot find info about player");
+#else
+		throw new std::exception();
+#endif
 	}
 	}
 };
 };
 
 
-#endif
+#endif

+ 18 - 9
global.h

@@ -7,19 +7,28 @@
 #include <iostream>
 #include <iostream>
 #include "int3.h"
 #include "int3.h"
 #define THC
 #define THC
-#else 
+#else
 #define THC //
 #define THC //
 #endif
 #endif
+
+#ifdef WIN32
+#define PATHSEPARATOR "\\"
+#define DATADIR ""
+#else
+#define PATHSEPARATOR "/"
+#define DATADIR "/progdir/"
+#endif
+
 enum Ecolor {RED, BLUE, TAN, GREEN, ORANGE, PURPLE, TEAL, PINK}; //player's colors
 enum Ecolor {RED, BLUE, TAN, GREEN, ORANGE, PURPLE, TEAL, PINK}; //player's colors
 enum EterrainType {border=-1, dirt, sand, grass, snow, swamp, rough, subterranean, lava, water, rock};
 enum EterrainType {border=-1, dirt, sand, grass, snow, swamp, rough, subterranean, lava, water, rock};
 enum Eriver {noRiver=0, clearRiver, icyRiver, muddyRiver, lavaRiver};
 enum Eriver {noRiver=0, clearRiver, icyRiver, muddyRiver, lavaRiver};
 enum Eroad {dirtRoad=1, grazvelRoad, cobblestoneRoad};
 enum Eroad {dirtRoad=1, grazvelRoad, cobblestoneRoad};
 enum Eformat { WoG=0x33, AB=0x15, RoE=0x0e,  SoD=0x1c};
 enum Eformat { WoG=0x33, AB=0x15, RoE=0x0e,  SoD=0x1c};
-enum EvictoryConditions {artifact, gatherTroop, gatherResource, buildCity, buildGrail, beatHero, 
+enum EvictoryConditions {artifact, gatherTroop, gatherResource, buildCity, buildGrail, beatHero,
 	captureCity, beatMonster, takeDwellings, takeMines, transportItem, winStandard=255};
 	captureCity, beatMonster, takeDwellings, takeMines, transportItem, winStandard=255};
 enum ElossCon {lossCastle, lossHero, timeExpires, lossStandard=255};
 enum ElossCon {lossCastle, lossHero, timeExpires, lossStandard=255};
-enum EHeroClasses {HERO_KNIGHT, HERO_CLERIC, HERO_RANGER, HERO_DRUID, HERO_ALCHEMIST, HERO_WIZARD, 
-	HERO_DEMONIAC, HERO_HERETIC, HERO_DEATHKNIGHT, HERO_NECROMANCER, HERO_WARLOCK, HERO_OVERLORD, 
+enum EHeroClasses {HERO_KNIGHT, HERO_CLERIC, HERO_RANGER, HERO_DRUID, HERO_ALCHEMIST, HERO_WIZARD,
+	HERO_DEMONIAC, HERO_HERETIC, HERO_DEATHKNIGHT, HERO_NECROMANCER, HERO_WARLOCK, HERO_OVERLORD,
 	HERO_BARBARIAN, HERO_BATTLEMAGE, HERO_BEASTMASTER, HERO_WITCH, HERO_PLANESWALKER, HERO_ELEMENTALIST};
 	HERO_BARBARIAN, HERO_BATTLEMAGE, HERO_BEASTMASTER, HERO_WITCH, HERO_PLANESWALKER, HERO_ELEMENTALIST};
 
 
 #ifdef _DEBUG
 #ifdef _DEBUG
@@ -28,9 +37,9 @@ extern CGameInfo* CGI;
 #else
 #else
 #define CGI (CGameInfo::mainObj)
 #define CGI (CGameInfo::mainObj)
 #endif
 #endif
-#define CURPLINT (((CPlayerInterface*)((CGameInfo::mainObj)->playerint[(CGameInfo::mainObj)->state->currentPlayer]))) 
-#define LOCPLINT (((CPlayerInterface*)((CGameInfo::mainObj)->playerint[(CGameInfo::mainObj)->localPlayer]))) 
-//CURPLINT gives pointer to the interface of human player which is currently making turn, 
+#define CURPLINT (((CPlayerInterface*)((CGameInfo::mainObj)->playerint[(CGameInfo::mainObj)->state->currentPlayer])))
+#define LOCPLINT (((CPlayerInterface*)((CGameInfo::mainObj)->playerint[(CGameInfo::mainObj)->localPlayer])))
+//CURPLINT gives pointer to the interface of human player which is currently making turn,
 //LOCPLINT gives pointer to the interface which is currently showed (on this machine)
 //LOCPLINT gives pointer to the interface which is currently showed (on this machine)
 
 
 #define HEROI_TYPE (0)
 #define HEROI_TYPE (0)
@@ -75,6 +84,6 @@ const int MAX_BUILDING_PER_TURN = 1;
 	{									\
 	{									\
 		std::cerr << e->what()<< std::endl;	\
 		std::cerr << e->what()<< std::endl;	\
 		delete e;						\
 		delete e;						\
-	}									
+	}
 
 
-#endif //GLOBAL_H
+#endif //GLOBAL_H

+ 1 - 1
hch/CAbilityHandler.h

@@ -26,4 +26,4 @@ public:
 	void loadAbilities();
 	void loadAbilities();
 };
 };
 
 
-#endif CABILITYHANDLER_H
+#endif //CABILITYHANDLER_H

+ 80 - 77
hch/CAmbarCendamo.cpp

@@ -56,15 +56,15 @@ CAmbarCendamo::CAmbarCendamo (const char * tie)
 	is->seekg(0,std::ios::end); // na koniec
 	is->seekg(0,std::ios::end); // na koniec
 	andame = is->tellg();  // read length
 	andame = is->tellg();  // read length
 	is->seekg(0,std::ios::beg); // wracamy na poczatek
 	is->seekg(0,std::ios::beg); // wracamy na poczatek
-	bufor = new unsigned char[andame]; // allocate memory 
+	bufor = new unsigned char[andame]; // allocate memory
 	is->read((char*)bufor, andame); // read map file to buffer
 	is->read((char*)bufor, andame); // read map file to buffer
 	is->close();
 	is->close();
 	delete is;
 	delete is;
 }
 }
-CAmbarCendamo::~CAmbarCendamo () 
+CAmbarCendamo::~CAmbarCendamo ()
 {// free memory
 {// free memory
 	for (int ii=0;ii<map.width;ii++)
 	for (int ii=0;ii<map.width;ii++)
-		delete map.terrain[ii] ; 
+		delete map.terrain[ii] ;
 	delete map.terrain;
 	delete map.terrain;
 	delete bufor;
 	delete bufor;
 }
 }
@@ -144,17 +144,17 @@ void CAmbarCendamo::deh3m()
 	map.areAnyPLayers = bufor[4]; //invalid on some maps
 	map.areAnyPLayers = bufor[4]; //invalid on some maps
 	map.height = map.width = bufor[5]; // wymiary mapy
 	map.height = map.width = bufor[5]; // wymiary mapy
 	map.twoLevel = bufor[9]; //czy sa lochy
 	map.twoLevel = bufor[9]; //czy sa lochy
-	map.terrain = new TerrainTile*[map.width]; // allocate memory 
+	map.terrain = new TerrainTile*[map.width]; // allocate memory
 	for (int ii=0;ii<map.width;ii++)
 	for (int ii=0;ii<map.width;ii++)
-		map.terrain[ii] = new TerrainTile[map.height]; // allocate memory 
+		map.terrain[ii] = new TerrainTile[map.height]; // allocate memory
 	if (map.twoLevel)
 	if (map.twoLevel)
 	{
 	{
-		map.undergroungTerrain = new TerrainTile*[map.width]; // allocate memory 
+		map.undergroungTerrain = new TerrainTile*[map.width]; // allocate memory
 		for (int ii=0;ii<map.width;ii++)
 		for (int ii=0;ii<map.width;ii++)
-			map.undergroungTerrain[ii] = new TerrainTile[map.height]; // allocate memory 
+			map.undergroungTerrain[ii] = new TerrainTile[map.height]; // allocate memory
 	}
 	}
 	int length = bufor[10]; //name length
 	int length = bufor[10]; //name length
-	int i=14, pom; 
+	int i=14, pom;
 	while (i-14<length)	//read name
 	while (i-14<length)	//read name
 		map.name+=bufor[i++];
 		map.name+=bufor[i++];
 	length = bufor[i] + bufor[i+1]*256; //description length
 	length = bufor[i] + bufor[i+1]*256; //description length
@@ -162,7 +162,7 @@ void CAmbarCendamo::deh3m()
 	for (pom=0;pom<length;pom++)
 	for (pom=0;pom<length;pom++)
 		map.description+=bufor[i++];
 		map.description+=bufor[i++];
 	map.difficulty = bufor[i++]; // reading map difficulty
 	map.difficulty = bufor[i++]; // reading map difficulty
-	if(map.version != Eformat::RoE)
+	if(map.version != RoE)
 	{
 	{
 		map.levelLimit = bufor[i++]; // hero level limit
 		map.levelLimit = bufor[i++]; // hero level limit
 	}
 	}
@@ -178,13 +178,13 @@ void CAmbarCendamo::deh3m()
 		{
 		{
 			switch(map.version)
 			switch(map.version)
 			{
 			{
-			case Eformat::SoD: case Eformat::WoG: 
+			case SoD: case WoG:
 				i+=13;
 				i+=13;
 				break;
 				break;
-			case Eformat::AB:
+			case AB:
 				i+=12;
 				i+=12;
 				break;
 				break;
-			case Eformat::RoE:
+			case RoE:
 				i+=6;
 				i+=6;
 				break;
 				break;
 			}
 			}
@@ -193,19 +193,19 @@ void CAmbarCendamo::deh3m()
 
 
 		map.players[pom].AITactic = bufor[i++];
 		map.players[pom].AITactic = bufor[i++];
 
 
-		if(map.version == Eformat::SoD || map.version == Eformat::WoG)
-			map.players[pom].p7= bufor[i++];	
+		if(map.version == SoD || map.version == WoG)
+			map.players[pom].p7= bufor[i++];
 
 
 		map.players[pom].allowedFactions = 0;
 		map.players[pom].allowedFactions = 0;
 		map.players[pom].allowedFactions += bufor[i++];
 		map.players[pom].allowedFactions += bufor[i++];
-		if(map.version != Eformat::RoE)
+		if(map.version != RoE)
 			map.players[pom].allowedFactions += (bufor[i++])*256;
 			map.players[pom].allowedFactions += (bufor[i++])*256;
 
 
 		map.players[pom].isFactionRandom = bufor[i++];
 		map.players[pom].isFactionRandom = bufor[i++];
 		map.players[pom].hasMainTown = bufor[i++];
 		map.players[pom].hasMainTown = bufor[i++];
 		if (map.players[pom].hasMainTown)
 		if (map.players[pom].hasMainTown)
 		{
 		{
-			if(map.version != Eformat::RoE)
+			if(map.version != RoE)
 			{
 			{
 				map.players[pom].generateHeroAtMainTown = bufor[i++];
 				map.players[pom].generateHeroAtMainTown = bufor[i++];
 				map.players[pom].generateHero = bufor[i++];
 				map.players[pom].generateHero = bufor[i++];
@@ -220,20 +220,20 @@ void CAmbarCendamo::deh3m()
 			map.players[pom].posOfMainTown.y = bufor[i++];
 			map.players[pom].posOfMainTown.y = bufor[i++];
 			map.players[pom].posOfMainTown.z = bufor[i++];
 			map.players[pom].posOfMainTown.z = bufor[i++];
 
 
-			
+
 		}
 		}
 		map.players[pom].p8= bufor[i++];
 		map.players[pom].p8= bufor[i++];
-		map.players[pom].p9= bufor[i++];		
+		map.players[pom].p9= bufor[i++];
 		if(map.players[pom].p9!=0xff)
 		if(map.players[pom].p9!=0xff)
 		{
 		{
 			map.players[pom].mainHeroPortrait = bufor[i++];
 			map.players[pom].mainHeroPortrait = bufor[i++];
 			int nameLength = bufor[i++];
 			int nameLength = bufor[i++];
-			i+=3; 
+			i+=3;
 			for (int pp=0;pp<nameLength;pp++)
 			for (int pp=0;pp<nameLength;pp++)
 				map.players[pom].mainHeroName+=bufor[i++];
 				map.players[pom].mainHeroName+=bufor[i++];
 		}
 		}
 
 
-		if(map.version != Eformat::RoE)
+		if(map.version != RoE)
 		{
 		{
 			i++; ////unknown byte
 			i++; ////unknown byte
 			int heroCount = bufor[i++];
 			int heroCount = bufor[i++];
@@ -313,7 +313,7 @@ void CAmbarCendamo::deh3m()
 				map.vicConDetails = new VicCon5();
 				map.vicConDetails = new VicCon5();
 				((VicCon5*)map.vicConDetails)->locationOfHero.x = bufor[i+2];
 				((VicCon5*)map.vicConDetails)->locationOfHero.x = bufor[i+2];
 				((VicCon5*)map.vicConDetails)->locationOfHero.y = bufor[i+3];
 				((VicCon5*)map.vicConDetails)->locationOfHero.y = bufor[i+3];
-				((VicCon5*)map.vicConDetails)->locationOfHero.z = bufor[i+4];				
+				((VicCon5*)map.vicConDetails)->locationOfHero.z = bufor[i+4];
 				nr=3;
 				nr=3;
 				break;
 				break;
 			}
 			}
@@ -322,7 +322,7 @@ void CAmbarCendamo::deh3m()
 				map.vicConDetails = new VicCon6();
 				map.vicConDetails = new VicCon6();
 				((VicCon6*)map.vicConDetails)->locationOfTown.x = bufor[i+2];
 				((VicCon6*)map.vicConDetails)->locationOfTown.x = bufor[i+2];
 				((VicCon6*)map.vicConDetails)->locationOfTown.y = bufor[i+3];
 				((VicCon6*)map.vicConDetails)->locationOfTown.y = bufor[i+3];
-				((VicCon6*)map.vicConDetails)->locationOfTown.z = bufor[i+4];				
+				((VicCon6*)map.vicConDetails)->locationOfTown.z = bufor[i+4];
 				nr=3;
 				nr=3;
 				break;
 				break;
 			}
 			}
@@ -331,19 +331,19 @@ void CAmbarCendamo::deh3m()
 				map.vicConDetails = new VicCon7();
 				map.vicConDetails = new VicCon7();
 				((VicCon7*)map.vicConDetails)->locationOfMonster.x = bufor[i+2];
 				((VicCon7*)map.vicConDetails)->locationOfMonster.x = bufor[i+2];
 				((VicCon7*)map.vicConDetails)->locationOfMonster.y = bufor[i+3];
 				((VicCon7*)map.vicConDetails)->locationOfMonster.y = bufor[i+3];
-				((VicCon7*)map.vicConDetails)->locationOfMonster.z = bufor[i+4];				
+				((VicCon7*)map.vicConDetails)->locationOfMonster.z = bufor[i+4];
 				nr=3;
 				nr=3;
 				break;
 				break;
 			}
 			}
 		case takeDwellings:
 		case takeDwellings:
-			{		
+			{
 				map.vicConDetails = new CspecificVictoryConidtions();
 				map.vicConDetails = new CspecificVictoryConidtions();
 				nr=0;
 				nr=0;
 				break;
 				break;
 			}
 			}
 		case takeMines:
 		case takeMines:
-			{	
-				map.vicConDetails = new CspecificVictoryConidtions();	
+			{
+				map.vicConDetails = new CspecificVictoryConidtions();
 				nr=0;
 				nr=0;
 				break;
 				break;
 			}
 			}
@@ -353,7 +353,7 @@ void CAmbarCendamo::deh3m()
 				((VicCona*)map.vicConDetails)->artifactID =  bufor[i+2];
 				((VicCona*)map.vicConDetails)->artifactID =  bufor[i+2];
 				((VicCona*)map.vicConDetails)->destinationPlace.x = bufor[i+3];
 				((VicCona*)map.vicConDetails)->destinationPlace.x = bufor[i+3];
 				((VicCona*)map.vicConDetails)->destinationPlace.y = bufor[i+4];
 				((VicCona*)map.vicConDetails)->destinationPlace.y = bufor[i+4];
-				((VicCona*)map.vicConDetails)->destinationPlace.z = bufor[i+5];				
+				((VicCona*)map.vicConDetails)->destinationPlace.z = bufor[i+5];
 				nr=4;
 				nr=4;
 				break;
 				break;
 			}
 			}
@@ -398,7 +398,7 @@ void CAmbarCendamo::deh3m()
 	int ist;
 	int ist;
 
 
 	ist=i; //starting i for loop
 	ist=i; //starting i for loop
-	for(i; i<ist+ (map.version == Eformat::RoE ? 16 : 20) ; ++i)
+	for(i; i<ist+ (map.version == RoE ? 16 : 20) ; ++i)
 	{
 	{
 		unsigned char c = bufor[i];
 		unsigned char c = bufor[i];
 		for(int yy=0; yy<8; ++yy)
 		for(int yy=0; yy<8; ++yy)
@@ -432,7 +432,7 @@ void CAmbarCendamo::deh3m()
 				int por = (1<<zz);
 				int por = (1<<zz);
 				if(players & por)
 				if(players & por)
 					map.disposedHeroes[g].players[zz] = true;
 					map.disposedHeroes[g].players[zz] = true;
-				else 
+				else
 					map.disposedHeroes[g].players[zz] = false;
 					map.disposedHeroes[g].players[zz] = false;
 			}
 			}
 		}
 		}
@@ -864,7 +864,7 @@ void CAmbarCendamo::deh3m()
 		int p = 99;
 		int p = 99;
 		switch(uu)
 		switch(uu)
 		{
 		{
-		case EDefType::EVENTOBJ_DEF: //for event - objects
+		case EVENTOBJ_DEF: //for event - objects
 			{
 			{
 				CEventObjInfo * spec = new CEventObjInfo;
 				CEventObjInfo * spec = new CEventObjInfo;
 				bool guardMess;
 				bool guardMess;
@@ -938,7 +938,7 @@ void CAmbarCendamo::deh3m()
 				nobj->info = spec;
 				nobj->info = spec;
 				break;
 				break;
 			}
 			}
-		case EDefType::HERO_DEF:
+		case HERO_DEF:
 			{
 			{
 				CHeroObjInfo * spec = new CHeroObjInfo;
 				CHeroObjInfo * spec = new CHeroObjInfo;
 				if(map.version>RoE)
 				if(map.version>RoE)
@@ -1354,7 +1354,7 @@ void CAmbarCendamo::deh3m()
 				nobj->info = spec;
 				nobj->info = spec;
 				break;
 				break;
 			}
 			}
-		case EDefType::SIGN_DEF:
+		case SIGN_DEF:
 			{
 			{
 				CSignObjInfo * spec = new CSignObjInfo;
 				CSignObjInfo * spec = new CSignObjInfo;
 				int length = readNormalNr(i); i+=4;
 				int length = readNormalNr(i); i+=4;
@@ -1366,7 +1366,7 @@ void CAmbarCendamo::deh3m()
 				nobj->info = spec;
 				nobj->info = spec;
 				break;
 				break;
 			}
 			}
-		case EDefType::SEERHUT_DEF:
+		case SEERHUT_DEF:
 			{
 			{
 				CSeerHutObjInfo * spec = new CSeerHutObjInfo;
 				CSeerHutObjInfo * spec = new CSeerHutObjInfo;
 				if(map.version>RoE)
 				if(map.version>RoE)
@@ -1668,7 +1668,7 @@ void CAmbarCendamo::deh3m()
 				nobj->info = spec;
 				nobj->info = spec;
 				break;
 				break;
 			}
 			}
-		case EDefType::WITCHHUT_DEF:
+		case WITCHHUT_DEF:
 			{
 			{
 				CWitchHutObjInfo * spec = new CWitchHutObjInfo;
 				CWitchHutObjInfo * spec = new CWitchHutObjInfo;
 				if(map.version>RoE) //in reo we cannot specify it - all are allowed (I hope)
 				if(map.version>RoE) //in reo we cannot specify it - all are allowed (I hope)
@@ -1694,11 +1694,11 @@ void CAmbarCendamo::deh3m()
 						spec->allowedAbilities.push_back(CGameInfo::mainObj->abilh->abilities[gg]);
 						spec->allowedAbilities.push_back(CGameInfo::mainObj->abilh->abilities[gg]);
 					}
 					}
 				}
 				}
-				
+
 				nobj->info = spec;
 				nobj->info = spec;
 				break;
 				break;
 			}
 			}
-		case EDefType::SCHOLAR_DEF:
+		case SCHOLAR_DEF:
 			{
 			{
 				CScholarObjInfo * spec = new CScholarObjInfo;
 				CScholarObjInfo * spec = new CScholarObjInfo;
 				spec->bonusType = bufor[i]; ++i;
 				spec->bonusType = bufor[i]; ++i;
@@ -1721,7 +1721,7 @@ void CAmbarCendamo::deh3m()
 				nobj->info = spec;
 				nobj->info = spec;
 				break;
 				break;
 			}
 			}
-		case EDefType::GARRISON_DEF:
+		case GARRISON_DEF:
 			{
 			{
 				CGarrisonObjInfo * spec = new CGarrisonObjInfo;
 				CGarrisonObjInfo * spec = new CGarrisonObjInfo;
 				spec->player = bufor[i]; ++i;
 				spec->player = bufor[i]; ++i;
@@ -1738,7 +1738,7 @@ void CAmbarCendamo::deh3m()
 				nobj->info = spec;
 				nobj->info = spec;
 				break;
 				break;
 			}
 			}
-		case EDefType::ARTIFACT_DEF:
+		case ARTIFACT_DEF:
 			{
 			{
 				CArtifactObjInfo * spec = new CArtifactObjInfo;
 				CArtifactObjInfo * spec = new CArtifactObjInfo;
 				bool areSettings = bufor[i]; ++i;
 				bool areSettings = bufor[i]; ++i;
@@ -1762,7 +1762,7 @@ void CAmbarCendamo::deh3m()
 				nobj->info = spec;
 				nobj->info = spec;
 				break;
 				break;
 			}
 			}
-		case EDefType::RESOURCE_DEF:
+		case RESOURCE_DEF:
 			{
 			{
 				CResourceObjInfo * spec = new CResourceObjInfo;
 				CResourceObjInfo * spec = new CResourceObjInfo;
 				bool isMessGuard = bufor[i]; ++i;
 				bool isMessGuard = bufor[i]; ++i;
@@ -1789,7 +1789,7 @@ void CAmbarCendamo::deh3m()
 				nobj->info = spec;
 				nobj->info = spec;
 				break;
 				break;
 			}
 			}
-		case EDefType::TOWN_DEF:
+		case TOWN_DEF:
 			{
 			{
 				CCastleObjInfo * spec = new CCastleObjInfo;
 				CCastleObjInfo * spec = new CCastleObjInfo;
 				if(map.version!=RoE)
 				if(map.version!=RoE)
@@ -1991,7 +1991,7 @@ void CAmbarCendamo::deh3m()
 				CGI->townh->townInstances.push_back(nt);
 				CGI->townh->townInstances.push_back(nt);
 				break;
 				break;
 			}
 			}
-		case EDefType::PLAYERONLY_DEF:
+		case PLAYERONLY_DEF:
 			{
 			{
 				CPlayerOnlyObjInfo * spec = new CPlayerOnlyObjInfo;
 				CPlayerOnlyObjInfo * spec = new CPlayerOnlyObjInfo;
 				spec->player = bufor[i]; ++i;
 				spec->player = bufor[i]; ++i;
@@ -2000,14 +2000,14 @@ void CAmbarCendamo::deh3m()
 				nobj->info = spec;
 				nobj->info = spec;
 				break;
 				break;
 			}
 			}
-		case EDefType::SHRINE_DEF:
+		case SHRINE_DEF:
 			{
 			{
 				CShrineObjInfo * spec = new CShrineObjInfo;
 				CShrineObjInfo * spec = new CShrineObjInfo;
 				spec->spell = bufor[i]; i+=4;
 				spec->spell = bufor[i]; i+=4;
 				nobj->info = spec;
 				nobj->info = spec;
 				break;
 				break;
 			}
 			}
-		case EDefType::SPELLSCROLL_DEF:
+		case SPELLSCROLL_DEF:
 			{
 			{
 				CSpellScrollObjinfo * spec = new CSpellScrollObjinfo;
 				CSpellScrollObjinfo * spec = new CSpellScrollObjinfo;
 				bool messg = bufor[i]; ++i;
 				bool messg = bufor[i]; ++i;
@@ -2030,7 +2030,7 @@ void CAmbarCendamo::deh3m()
 				nobj->info = spec;
 				nobj->info = spec;
 				break;
 				break;
 			}
 			}
-		case EDefType::PANDORA_DEF:
+		case PANDORA_DEF:
 			{
 			{
 				CPandorasBoxObjInfo * spec = new CPandorasBoxObjInfo;
 				CPandorasBoxObjInfo * spec = new CPandorasBoxObjInfo;
 				bool messg = bufor[i]; ++i;
 				bool messg = bufor[i]; ++i;
@@ -2097,14 +2097,14 @@ void CAmbarCendamo::deh3m()
 				///////end of copied fragment
 				///////end of copied fragment
 				break;
 				break;
 			}
 			}
-		case EDefType::GRAIL_DEF:
+		case GRAIL_DEF:
 			{
 			{
 				CGrailObjInfo * spec = new CGrailObjInfo;
 				CGrailObjInfo * spec = new CGrailObjInfo;
 				spec->radius = readNormalNr(i); i+=4;
 				spec->radius = readNormalNr(i); i+=4;
 				nobj->info = spec;
 				nobj->info = spec;
 				break;
 				break;
 			}
 			}
-		case EDefType::CREGEN_DEF:
+		case CREGEN_DEF:
 			{
 			{
 				CCreGenObjInfo * spec = new CCreGenObjInfo;
 				CCreGenObjInfo * spec = new CCreGenObjInfo;
 				spec->player = readNormalNr(i); i+=4;
 				spec->player = readNormalNr(i); i+=4;
@@ -2123,7 +2123,7 @@ void CAmbarCendamo::deh3m()
 				nobj->info = spec;
 				nobj->info = spec;
 				break;
 				break;
 			}
 			}
-		case EDefType::CREGEN2_DEF:
+		case CREGEN2_DEF:
 			{
 			{
 				CCreGen2ObjInfo * spec = new CCreGen2ObjInfo;
 				CCreGen2ObjInfo * spec = new CCreGen2ObjInfo;
 				spec->player = readNormalNr(i); i+=4;
 				spec->player = readNormalNr(i); i+=4;
@@ -2148,7 +2148,7 @@ void CAmbarCendamo::deh3m()
 				nobj->info = spec;
 				nobj->info = spec;
 				break;
 				break;
 			}
 			}
-		case EDefType::CREGEN3_DEF:
+		case CREGEN3_DEF:
 			{
 			{
 				CCreGen3ObjInfo * spec = new CCreGen3ObjInfo;
 				CCreGen3ObjInfo * spec = new CCreGen3ObjInfo;
 				spec->player = bufor[i]; ++i;
 				spec->player = bufor[i]; ++i;
@@ -2163,7 +2163,7 @@ void CAmbarCendamo::deh3m()
 				nobj->info = spec;
 				nobj->info = spec;
 				break;
 				break;
 			}
 			}
-		case EDefType::BORDERGUARD_DEF:
+		case BORDERGUARD_DEF:
 			{
 			{
 				CBorderGuardObjInfo * spec = new CBorderGuardObjInfo;
 				CBorderGuardObjInfo * spec = new CBorderGuardObjInfo;
 				spec->missionType = bufor[i]; ++i;
 				spec->missionType = bufor[i]; ++i;
@@ -2348,19 +2348,22 @@ void CAmbarCendamo::deh3m()
 					}
 					}
 				}//internal switch end (seer huts)
 				}//internal switch end (seer huts)
 
 
-				int len1 = readNormalNr(i); i+=4;
+				int len1;
+				len1 = readNormalNr(i); i+=4;
 				for(int ee=0; ee<len1; ++ee)
 				for(int ee=0; ee<len1; ++ee)
 				{
 				{
 					spec->firstVisitText += bufor[i]; ++i;
 					spec->firstVisitText += bufor[i]; ++i;
 				}
 				}
 
 
-				int len2 = readNormalNr(i); i+=4;
+				int len2;
+				len2 = readNormalNr(i); i+=4;
 				for(int ee=0; ee<len2; ++ee)
 				for(int ee=0; ee<len2; ++ee)
 				{
 				{
 					spec->nextVisitText += bufor[i]; ++i;
 					spec->nextVisitText += bufor[i]; ++i;
 				}
 				}
 
 
-				int len3 = readNormalNr(i); i+=4;
+				int len3;
+				len3 = readNormalNr(i); i+=4;
 				for(int ee=0; ee<len3; ++ee)
 				for(int ee=0; ee<len3; ++ee)
 				{
 				{
 					spec->completedText += bufor[i]; ++i;
 					spec->completedText += bufor[i]; ++i;
@@ -2369,7 +2372,7 @@ void CAmbarCendamo::deh3m()
 borderguardend:
 borderguardend:
 				break;
 				break;
 			}
 			}
-		case EDefType::HEROPLACEHOLDER_DEF:
+		case HEROPLACEHOLDER_DEF:
 			{
 			{
 				i+=3; //TODO: handle it more properly
 				i+=3; //TODO: handle it more properly
 				break;
 				break;
@@ -2383,7 +2386,7 @@ borderguardend:
 	THC std::cout<<"\tReading objects: "<<th.getDif()<<std::endl;
 	THC std::cout<<"\tReading objects: "<<th.getDif()<<std::endl;
 	//processMap(defsToUnpack);
 	//processMap(defsToUnpack);
 	std::vector<CDefHandler *> dhandlers = CGameInfo::mainObj->spriteh->extractManyFiles(defsToUnpack);
 	std::vector<CDefHandler *> dhandlers = CGameInfo::mainObj->spriteh->extractManyFiles(defsToUnpack);
-	
+
 	THC std::cout<<"\tUnpacking defs: "<<th.getDif()<<std::endl;
 	THC std::cout<<"\tUnpacking defs: "<<th.getDif()<<std::endl;
 	for (int i=0;i<dhandlers.size();i++)
 	for (int i=0;i<dhandlers.size();i++)
 	{
 	{
@@ -2492,55 +2495,55 @@ EDefType CAmbarCendamo::getDefType(CGDefInfo * a)
 	switch(a->id)
 	switch(a->id)
 	{
 	{
 	case 5: case 65: case 66: case 67: case 68: case 69:
 	case 5: case 65: case 66: case 67: case 68: case 69:
-		return EDefType::ARTIFACT_DEF; //handled
+		return ARTIFACT_DEF; //handled
 	case 6:
 	case 6:
-		return EDefType::PANDORA_DEF; //hanled
+		return PANDORA_DEF; //hanled
 	case 26:
 	case 26:
-		return EDefType::EVENTOBJ_DEF; //handled
+		return EVENTOBJ_DEF; //handled
 	case 33:
 	case 33:
-		return EDefType::GARRISON_DEF; //handled
+		return GARRISON_DEF; //handled
 	case 34: case 70: case 62: //70 - random hero //62 - prison
 	case 34: case 70: case 62: //70 - random hero //62 - prison
-		return EDefType::HERO_DEF; //handled
+		return HERO_DEF; //handled
 	case 36:
 	case 36:
-		return EDefType::GRAIL_DEF; //hanled
+		return GRAIL_DEF; //hanled
 	case 53: case 17: case 18: case 19: case 20: case 42: case 87: case 220://cases 17 - 20 and 42 - tests
 	case 53: case 17: case 18: case 19: case 20: case 42: case 87: case 220://cases 17 - 20 and 42 - tests
-		return EDefType::PLAYERONLY_DEF; //handled
+		return PLAYERONLY_DEF; //handled
 	case 54: case 71: case 72: case 73: case 74: case 75: case 162: case 163: case 164:
 	case 54: case 71: case 72: case 73: case 74: case 75: case 162: case 163: case 164:
-		return EDefType::CREATURES_DEF; //handled
+		return CREATURES_DEF; //handled
 	case 59:
 	case 59:
-		return EDefType::SIGN_DEF; //handled
+		return SIGN_DEF; //handled
 	case 77:
 	case 77:
-		return EDefType::TOWN_DEF; //can be problematic, but handled
+		return TOWN_DEF; //can be problematic, but handled
 	case 79: case 76:
 	case 79: case 76:
-		return EDefType::RESOURCE_DEF; //handled
+		return RESOURCE_DEF; //handled
 	case 81:
 	case 81:
-		return EDefType::SCHOLAR_DEF; //handled
+		return SCHOLAR_DEF; //handled
 	case 83:
 	case 83:
-		return EDefType::SEERHUT_DEF; //handled
+		return SEERHUT_DEF; //handled
 	case 91:
 	case 91:
-		return EDefType::SIGN_DEF; //handled
+		return SIGN_DEF; //handled
 	case 88: case 89: case 90:
 	case 88: case 89: case 90:
 		return SHRINE_DEF; //handled
 		return SHRINE_DEF; //handled
 	case 93:
 	case 93:
 		return SPELLSCROLL_DEF; //handled
 		return SPELLSCROLL_DEF; //handled
 	case 98:
 	case 98:
-		return EDefType::TOWN_DEF; //handled
+		return TOWN_DEF; //handled
 	case 113:
 	case 113:
-		return EDefType::WITCHHUT_DEF; //handled
+		return WITCHHUT_DEF; //handled
 	case 214:
 	case 214:
-		return EDefType::HEROPLACEHOLDER_DEF; //partially handled
+		return HEROPLACEHOLDER_DEF; //partially handled
 	case 215:
 	case 215:
-		return EDefType::BORDERGUARD_DEF; //handled by analogy to seer huts ;]
+		return BORDERGUARD_DEF; //handled by analogy to seer huts ;]
 	case 216:
 	case 216:
-		return EDefType::CREGEN2_DEF; //handled
+		return CREGEN2_DEF; //handled
 	case 217:
 	case 217:
-		return EDefType::CREGEN_DEF; //handled
+		return CREGEN_DEF; //handled
 	case 218:
 	case 218:
-		return EDefType::CREGEN3_DEF; //handled
+		return CREGEN3_DEF; //handled
 	case 219:
 	case 219:
-		return EDefType::GARRISON_DEF; //handled
+		return GARRISON_DEF; //handled
 	default:
 	default:
-		return EDefType::TERRAINOBJ_DEF; // nothing to be handled
+		return TERRAINOBJ_DEF; // nothing to be handled
 	}
 	}
 }
 }
 
 

+ 2 - 2
hch/CAmbarCendamo.h

@@ -13,7 +13,7 @@
 
 
 enum EDefType {TOWN_DEF, HERO_DEF, CREATURES_DEF, SEERHUT_DEF, RESOURCE_DEF, TERRAINOBJ_DEF, EVENTOBJ_DEF, SIGN_DEF, GARRISON_DEF, ARTIFACT_DEF, WITCHHUT_DEF, SCHOLAR_DEF, PLAYERONLY_DEF, SHRINE_DEF, SPELLSCROLL_DEF, PANDORA_DEF, GRAIL_DEF, CREGEN_DEF, CREGEN2_DEF, CREGEN3_DEF, BORDERGUARD_DEF, HEROPLACEHOLDER_DEF};
 enum EDefType {TOWN_DEF, HERO_DEF, CREATURES_DEF, SEERHUT_DEF, RESOURCE_DEF, TERRAINOBJ_DEF, EVENTOBJ_DEF, SIGN_DEF, GARRISON_DEF, ARTIFACT_DEF, WITCHHUT_DEF, SCHOLAR_DEF, PLAYERONLY_DEF, SHRINE_DEF, SPELLSCROLL_DEF, PANDORA_DEF, GRAIL_DEF, CREGEN_DEF, CREGEN2_DEF, CREGEN3_DEF, BORDERGUARD_DEF, HEROPLACEHOLDER_DEF};
 
 
-class CAmbarCendamo 
+class CAmbarCendamo
 {
 {
 public:
 public:
 /////////////////member variables
 /////////////////member variables
@@ -37,4 +37,4 @@ public:
 	EDefType getDefType(CGDefInfo * a); //returns type of object in def
 	EDefType getDefType(CGDefInfo * a); //returns type of object in def
 	CCreatureSet readCreatureSet(int pos, int number = 7); //reads creature set in most recently encountered format; reades number units (default is 7)
 	CCreatureSet readCreatureSet(int pos, int number = 7); //reads creature set in most recently encountered format; reades number units (default is 7)
 };
 };
-#endif //CAMBARCENDAMO_H
+#endif //CAMBARCENDAMO_H

+ 1 - 1
hch/CArtHandler.h

@@ -31,4 +31,4 @@ public:
 	bool loadArtEvents();
 	bool loadArtEvents();
 };
 };
 
 
-#endif // CARTHANDLER_H
+#endif // CARTHANDLER_H

+ 10 - 6
hch/CBuildingHandler.cpp

@@ -18,7 +18,11 @@ unsigned int readNr(std::string &in, unsigned int &it)
 		if(in[last]=='\t' || in[last]=='\n' || in[last]==' ' || in[last]=='\r' || in[last]=='\n')
 		if(in[last]=='\t' || in[last]=='\n' || in[last]==' ' || in[last]=='\r' || in[last]=='\n')
 			break;
 			break;
 	if(last==in.size())
 	if(last==in.size())
+#ifndef __GNUC__
 		throw new std::exception("Cannot read number...");
 		throw new std::exception("Cannot read number...");
+#else
+		throw new std::exception();
+#endif
 	std::stringstream ss(in.substr(it,last-it));
 	std::stringstream ss(in.substr(it,last-it));
 	it+=(1+last-it);
 	it+=(1+last-it);
 	ss >> last;
 	ss >> last;
@@ -61,7 +65,7 @@ void CBuildingHandler::loadBuildings()
 		delete nb;
 		delete nb;
 	}
 	}
 
 
-	//reading 14 per faction dwellings 
+	//reading 14 per faction dwellings
 	temp = readTo(buf,it,'\n');temp = readTo(buf,it,'\n');//dwellings - skip 2 lines
 	temp = readTo(buf,it,'\n');temp = readTo(buf,it,'\n');//dwellings - skip 2 lines
 	for(int i=0;i<F_NUMBER;i++)
 	for(int i=0;i<F_NUMBER;i++)
 	{
 	{
@@ -104,7 +108,7 @@ void CBuildingHandler::loadBuildings()
 		buildings[fi][16]->description = readTo(buf,it,'\n');
 		buildings[fi][16]->description = readTo(buf,it,'\n');
 	}
 	}
 	/////done reading "BLDGNEUT.TXT"******************************
 	/////done reading "BLDGNEUT.TXT"******************************
-	
+
 	buf = CGameInfo::mainObj->bitmaph->getTextFile("BLDGSPEC.TXT");
 	buf = CGameInfo::mainObj->bitmaph->getTextFile("BLDGSPEC.TXT");
 	andame = buf.size(), it=0;
 	andame = buf.size(), it=0;
 	for(int f=0;f<F_NUMBER;f++)
 	for(int f=0;f<F_NUMBER;f++)
@@ -133,7 +137,7 @@ void CBuildingHandler::loadBuildings()
 		}
 		}
 	}
 	}
 
 
-	char line[100]; //bufor 
+	char line[100]; //bufor
 	std::ifstream ofs("config/hall.txt");
 	std::ifstream ofs("config/hall.txt");
 	int castles;
 	int castles;
 	ofs>>castles;
 	ofs>>castles;
@@ -168,12 +172,12 @@ void CBuildingHandler::loadBuildings()
 					(hall[tid].second)[j][box].push_back(last);
 					(hall[tid].second)[j][box].push_back(last);
 					areboxes = it; //wyzeruje jak nie znajdzie kolejnej spacji = koniec linii
 					areboxes = it; //wyzeruje jak nie znajdzie kolejnej spacji = koniec linii
 					if(!it)
 					if(!it)
-						it = seppos+1; 
+						it = seppos+1;
 				}
 				}
 				box++;
 				box++;
 				it+=2;
 				it+=2;
 			}
 			}
 		}
 		}
 	}
 	}
-	
-}
+
+}

+ 1 - 1
hch/CBuildingHandler.h

@@ -22,4 +22,4 @@ public:
 	void loadBuildings(); //main loader
 	void loadBuildings(); //main loader
 };
 };
 
 
-#endif //CBUILDINGHANDLER_H
+#endif //CBUILDINGHANDLER_H

+ 2 - 2
hch/CCastleHandler.h

@@ -42,10 +42,10 @@ public:
 	std::vector<CSpell *> possibleSpells;
 	std::vector<CSpell *> possibleSpells;
 	std::vector<CSpell *> obligatorySpells;
 	std::vector<CSpell *> obligatorySpells;
 	std::vector<CSpell *> availableSpells;
 	std::vector<CSpell *> availableSpells;
-	
+
 	std::vector<CCastleEvent> events;
 	std::vector<CCastleEvent> events;
 
 
 	unsigned char alignment; //255 - same as owner/random, 0 - same as red, 1 - same as blue, etc
 	unsigned char alignment; //255 - same as owner/random, 0 - same as red, 1 - same as blue, etc
 };
 };
 
 
-#endif //CCASTLEHANDLER_H
+#endif //CCASTLEHANDLER_H

+ 19 - 15
hch/CCreatureHandler.cpp

@@ -321,7 +321,7 @@ void CCreatureHandler::loadCreatures()
 	}
 	}
 
 
 	//loading reference names
 	//loading reference names
-	std::ifstream ifs("config/crerefnam.txt"); 
+	std::ifstream ifs("config/crerefnam.txt");
 	int tempi;
 	int tempi;
 	std::string temps;
 	std::string temps;
 	for (;;)
 	for (;;)
@@ -336,7 +336,7 @@ void CCreatureHandler::loadCreatures()
 	ifs.clear();
 	ifs.clear();
 	for(int i=1;i<=10;i++)
 	for(int i=1;i<=10;i++)
 		levelCreatures.insert(std::pair<int,std::vector<CCreature*> >(i,std::vector<CCreature*>()));
 		levelCreatures.insert(std::pair<int,std::vector<CCreature*> >(i,std::vector<CCreature*>()));
-	ifs.open("config/monsters.txt"); 
+	ifs.open("config/monsters.txt");
 	{
 	{
 		while(!ifs.eof())
 		while(!ifs.eof())
 		{
 		{
@@ -353,7 +353,7 @@ void CCreatureHandler::loadCreatures()
 	ifs.clear();
 	ifs.clear();
 
 
 
 
-	ifs.open("config/cr_bgs.txt"); 
+	ifs.open("config/cr_bgs.txt");
 	while(!ifs.eof())
 	while(!ifs.eof())
 	{
 	{
 		int id;
 		int id;
@@ -365,7 +365,7 @@ void CCreatureHandler::loadCreatures()
 	ifs.clear();
 	ifs.clear();
 
 
 
 
-	ifs.open("config/cr_factions.txt"); 
+	ifs.open("config/cr_factions.txt");
 	while(!ifs.eof())
 	while(!ifs.eof())
 	{
 	{
 		int id, fact;
 		int id, fact;
@@ -375,7 +375,7 @@ void CCreatureHandler::loadCreatures()
 	ifs.close();
 	ifs.close();
 	ifs.clear();
 	ifs.clear();
 
 
-	ifs.open("config/cr_upgrade_list.txt"); 
+	ifs.open("config/cr_upgrade_list.txt");
 	while(!ifs.eof())
 	while(!ifs.eof())
 	{
 	{
 		int id, up;
 		int id, up;
@@ -401,17 +401,21 @@ void CCreatureHandler::loadCreatures()
 	}
 	}
 	delete smi;
 	delete smi;
 	//
 	//
-	
+
 	//loading unit animation def names
 	//loading unit animation def names
 	std::ifstream inp("config/CREDEFS.TXT", std::ios::in | std::ios::binary); //this file is not in lod
 	std::ifstream inp("config/CREDEFS.TXT", std::ios::in | std::ios::binary); //this file is not in lod
 	inp.seekg(0,std::ios::end); // na koniec
 	inp.seekg(0,std::ios::end); // na koniec
 	int andame2 = inp.tellg();  // read length
 	int andame2 = inp.tellg();  // read length
 	inp.seekg(0,std::ios::beg); // wracamy na poczatek
 	inp.seekg(0,std::ios::beg); // wracamy na poczatek
-	char * bufor = new char[andame2]; // allocate memory 
+	char * bufor = new char[andame2]; // allocate memory
 	inp.read((char*)bufor, andame2); // read map file to buffer
 	inp.read((char*)bufor, andame2); // read map file to buffer
 	inp.close();
 	inp.close();
 	buf = std::string(bufor);
 	buf = std::string(bufor);
+#ifndef __GNUC__
 	delete [andame2] bufor;
 	delete [andame2] bufor;
+#else
+	delete [] bufor;
+#endif
 
 
 	i = 0; //buf iterator
 	i = 0; //buf iterator
 	hmcr = 0;
 	hmcr = 0;
@@ -645,7 +649,7 @@ void CCreatureHandler::loadUnitAnimations()
 	//inp.seekg(0,std::ios::end); // na koniec
 	//inp.seekg(0,std::ios::end); // na koniec
 	//int andame = inp.tellg();  // read length
 	//int andame = inp.tellg();  // read length
 	//inp.seekg(0,std::ios::beg); // wracamy na poczatek
 	//inp.seekg(0,std::ios::beg); // wracamy na poczatek
-	//char * bufor = new char[andame]; // allocate memory 
+	//char * bufor = new char[andame]; // allocate memory
 	//inp.read((char*)bufor, andame); // read map file to buffer
 	//inp.read((char*)bufor, andame); // read map file to buffer
 	//inp.close();
 	//inp.close();
 	//std::string buf = std::string(bufor);
 	//std::string buf = std::string(bufor);
@@ -763,12 +767,12 @@ CCreatureAnimation::CCreatureAnimation(std::string name) : RLEntries(NULL), RWEn
 		int unknown3 = readNormalNr(i,4); i+=4;
 		int unknown3 = readNormalNr(i,4); i+=4;
 		for (j=0; j<totalInBlock; j++)
 		for (j=0; j<totalInBlock; j++)
 		{
 		{
-			for (int k=0;k<13;k++) Buffer[k]=FDef[i+k]; 
+			for (int k=0;k<13;k++) Buffer[k]=FDef[i+k];
 			i+=13;
 			i+=13;
 			SEntries[totalEntries+j].name=Buffer;
 			SEntries[totalEntries+j].name=Buffer;
 		}
 		}
 		for (j=0; j<totalInBlock; j++)
 		for (j=0; j<totalInBlock; j++)
-		{ 
+		{
 			SEntries[totalEntries+j].offset = readNormalNr(i,4);
 			SEntries[totalEntries+j].offset = readNormalNr(i,4);
 			int unknown4 = readNormalNr(i,4); i+=4;
 			int unknown4 = readNormalNr(i,4); i+=4;
 		}
 		}
@@ -813,7 +817,7 @@ int CCreatureAnimation::readNormalNr (int pos, int bytCon, unsigned char * str,
 			amp*=256;
 			amp*=256;
 		}
 		}
 	}
 	}
-	else 
+	else
 	{
 	{
 		for (int i=0; i<bytCon; i++)
 		for (int i=0; i<bytCon; i++)
 		{
 		{
@@ -870,14 +874,14 @@ int CCreatureAnimation::nextFrame(SDL_Surface *dest, int x, int y, bool attacker
 	}
 	}
 	//frame number increased
 	//frame number increased
 
 
-	long BaseOffset, 
+	long BaseOffset,
 		SpriteWidth, SpriteHeight, //sprite format
 		SpriteWidth, SpriteHeight, //sprite format
 		LeftMargin, RightMargin, TopMargin,BottomMargin,
 		LeftMargin, RightMargin, TopMargin,BottomMargin,
 		i, add, FullHeight,FullWidth,
 		i, add, FullHeight,FullWidth,
 		TotalRowLength, // length of read segment
 		TotalRowLength, // length of read segment
 		RowAdd;
 		RowAdd;
 	unsigned char SegmentType, SegmentLength;
 	unsigned char SegmentType, SegmentLength;
-	
+
 	i=BaseOffset=SEntries[SIndex].offset;
 	i=BaseOffset=SEntries[SIndex].offset;
 	int prSize=readNormalNr(i,4,FDef);i+=4;
 	int prSize=readNormalNr(i,4,FDef);i+=4;
 	int defType2 = readNormalNr(i,4,FDef);i+=4;
 	int defType2 = readNormalNr(i,4,FDef);i+=4;
@@ -889,7 +893,7 @@ int CCreatureAnimation::nextFrame(SDL_Surface *dest, int x, int y, bool attacker
 	TopMargin = readNormalNr(i,4,FDef);i+=4;
 	TopMargin = readNormalNr(i,4,FDef);i+=4;
 	RightMargin = FullWidth - SpriteWidth - LeftMargin;
 	RightMargin = FullWidth - SpriteWidth - LeftMargin;
 	BottomMargin = FullHeight - SpriteHeight - TopMargin;
 	BottomMargin = FullHeight - SpriteHeight - TopMargin;
-	
+
 	add = 4 - FullWidth%4;
 	add = 4 - FullWidth%4;
 
 
 	int BaseOffsetor = BaseOffset = i;
 	int BaseOffsetor = BaseOffset = i;
@@ -1023,7 +1027,7 @@ void CCreatureAnimation::putPixel(SDL_Surface * dest, const int & ftcp, const BM
 			p[2] = color.R;
 			p[2] = color.R;
 		}
 		}
 		else if(palc < 5) //shadow
 		else if(palc < 5) //shadow
-		{ 
+		{
 			Uint16 alpha;
 			Uint16 alpha;
 			switch(color.G)
 			switch(color.G)
 			{
 			{

+ 3 - 3
hch/CCreatureHandler.h

@@ -109,10 +109,10 @@ public:
 	void setType(int type); //sets type of animation and cleares framecount
 	void setType(int type); //sets type of animation and cleares framecount
 	int getType() const; //returns type of animation
 	int getType() const; //returns type of animation
 
 
-	int nextFrame(SDL_Surface * dest, int x, int y, bool attacker, bool incrementFrame = true, bool yellowBorder = false, SDL_Rect * destRect = NULL); //0 - success, any other - error //print next 
-	int nextFrameMiddle(SDL_Surface * dest, int x, int y, bool attacker, bool incrementFrame = true, bool yellowBorder = false, SDL_Rect * destRect = NULL); //0 - success, any other - error //print next 
+	int nextFrame(SDL_Surface * dest, int x, int y, bool attacker, bool incrementFrame = true, bool yellowBorder = false, SDL_Rect * destRect = NULL); //0 - success, any other - error //print next
+	int nextFrameMiddle(SDL_Surface * dest, int x, int y, bool attacker, bool incrementFrame = true, bool yellowBorder = false, SDL_Rect * destRect = NULL); //0 - success, any other - error //print next
 
 
 	int framesInGroup(int group) const; //retirns number of fromes in given group
 	int framesInGroup(int group) const; //retirns number of fromes in given group
 };
 };
 
 
-#endif //CCREATUREHANDLER_H
+#endif //CCREATUREHANDLER_H

BIN
hch/CDefHandler.cpp


BIN
hch/CDefHandler.h


+ 3 - 3
hch/CDefObjInfoHandler.h

@@ -6,7 +6,7 @@ class CDefHandler;
 class CGDefInfo
 class CGDefInfo
 {
 {
 public:
 public:
-	std::string name; 
+	std::string name;
 
 
 	unsigned char visitMap[6];
 	unsigned char visitMap[6];
 	unsigned char blockMap[6];
 	unsigned char blockMap[6];
@@ -14,7 +14,7 @@ public:
 	int id, subid; //of object described by this defInfo
 	int id, subid; //of object described by this defInfo
 	int terrainAllowed, //on which terrain it is possible to place object
 	int terrainAllowed, //on which terrain it is possible to place object
 		 terrainMenu; //in which menus in map editor object will be showed
 		 terrainMenu; //in which menus in map editor object will be showed
-	int type; //(0- ground, 1- towns, 2-creatures, 3- heroes, 4-artifacts, 5- resources)   
+	int type; //(0- ground, 1- towns, 2-creatures, 3- heroes, 4-artifacts, 5- resources)
 	CDefHandler * handler;
 	CDefHandler * handler;
 	int printPriority;
 	int printPriority;
 	bool isVisitable();
 	bool isVisitable();
@@ -48,4 +48,4 @@ public:
 	void load();
 	void load();
 };
 };
 
 
-#endif //COBJINFOECTHANDLER_H
+#endif //COBJINFOECTHANDLER_H

+ 2 - 1
hch/CGeneralTextHandler.cpp

@@ -14,6 +14,7 @@ void CGeneralTextHandler::load()
 		if(buf[i]=='\r')
 		if(buf[i]=='\r')
 			break;
 			break;
 	}
 	}
+
 	i+=2;
 	i+=2;
 	for(int jj=0; jj<764; ++jj)
 	for(int jj=0; jj<764; ++jj)
 	{
 	{
@@ -22,8 +23,8 @@ void CGeneralTextHandler::load()
 		allTexts.push_back(buflet);
 		allTexts.push_back(buflet);
 	}
 	}
 
 
-
 	std::string  strs = CGI->bitmaph->getTextFile("ARRAYTXT.TXT");
 	std::string  strs = CGI->bitmaph->getTextFile("ARRAYTXT.TXT");
+
 	int itr=0;
 	int itr=0;
 	while(itr<strs.length()-1)
 	while(itr<strs.length()-1)
 	{
 	{

+ 1 - 1
hch/CGeneralTextHandler.h

@@ -32,4 +32,4 @@ public:
 };
 };
 
 
 
 
-#endif //CGENERALTEXTHANDLER_H
+#endif //CGENERALTEXTHANDLER_H

+ 1 - 1
hch/CHeroHandler.h

@@ -73,4 +73,4 @@ public:
 };
 };
 
 
 
 
-#endif //CHEROHANDLER_H
+#endif //CHEROHANDLER_H

+ 17 - 17
hch/CLodHandler.cpp

@@ -38,7 +38,7 @@ void CPCXConv::fromFile(std::string path)
 	is->seekg(0,std::ios::end); // to the end
 	is->seekg(0,std::ios::end); // to the end
 	pcxs = is->tellg();  // read length
 	pcxs = is->tellg();  // read length
 	is->seekg(0,std::ios::beg); // wracamy na poczatek
 	is->seekg(0,std::ios::beg); // wracamy na poczatek
-	pcx = new unsigned char[pcxs]; // allocate memory 
+	pcx = new unsigned char[pcxs]; // allocate memory
 	is->read((char*)pcx, pcxs); // read map file to buffer
 	is->read((char*)pcx, pcxs); // read map file to buffer
 	is->close();
 	is->close();
 	delete is;
 	delete is;
@@ -67,17 +67,17 @@ void CPCXConv::convert()
 	bh.y = readNormalNr(it,4,pcx);it+=4;
 	bh.y = readNormalNr(it,4,pcx);it+=4;
 	if (fSize==bh.x*bh.y*3)
 	if (fSize==bh.x*bh.y*3)
 		check1=true;
 		check1=true;
-	else 
+	else
 		check1=false;
 		check1=false;
 	if (fSize==bh.x*bh.y)
 	if (fSize==bh.x*bh.y)
 		check2=true;
 		check2=true;
-	else 
+	else
 		check2=false;
 		check2=false;
 	if (check1)
 	if (check1)
 		format=PCX24B;
 		format=PCX24B;
 	else if (check2)
 	else if (check2)
 		format=PCX8B;
 		format=PCX8B;
-	else 
+	else
 		return;
 		return;
 	add = 4 - bh.x%4;
 	add = 4 - bh.x%4;
 	if (add==4)
 	if (add==4)
@@ -179,17 +179,17 @@ SDL_Surface * CPCXConv::getSurface()
 	bh.y = readNormalNr(it,4,pcx);it+=4;
 	bh.y = readNormalNr(it,4,pcx);it+=4;
 	if (fSize==bh.x*bh.y*3)
 	if (fSize==bh.x*bh.y*3)
 		check1=true;
 		check1=true;
-	else 
+	else
 		check1=false;
 		check1=false;
 	if (fSize==bh.x*bh.y)
 	if (fSize==bh.x*bh.y)
 		check2=true;
 		check2=true;
-	else 
+	else
 		check2=false;
 		check2=false;
 	if (check1)
 	if (check1)
 		format=PCX24B;
 		format=PCX24B;
 	else if (check2)
 	else if (check2)
 		format=PCX8B;
 		format=PCX8B;
-	else 
+	else
 		return NULL;
 		return NULL;
 	add = 4 - bh.x%4;
 	add = 4 - bh.x%4;
 	if (add==4)
 	if (add==4)
@@ -283,7 +283,7 @@ SDL_Surface * CLodHandler::loadBitmap(std::string fname)
 			fname.replace(fname.find_first_of('.'),fname.find_first_of('.')+4,".PCX");
 			fname.replace(fname.find_first_of('.'),fname.find_first_of('.')+4,".PCX");
 			f = fopen(fname.c_str(),"r");
 			f = fopen(fname.c_str(),"r");
 			if(!f)
 			if(!f)
-				return NULL; 
+				return NULL;
 			fread(sign,1,3,f);
 			fread(sign,1,3,f);
 			if(sign[0]=='B' && sign[1]=='M') //BMP named as PCX - people (eg. Kulex) sometimes use such files
 			if(sign[0]=='B' && sign[1]=='M') //BMP named as PCX - people (eg. Kulex) sometimes use such files
 			{
 			{
@@ -316,7 +316,7 @@ SDL_Surface * CLodHandler::loadBitmap(std::string fname)
 		pcx = new unsigned char[e->realSize];
 		pcx = new unsigned char[e->realSize];
 		fread((char*)pcx, 1, e->realSize, FLOD);
 		fread((char*)pcx, 1, e->realSize, FLOD);
 	}
 	}
-	else 
+	else
 	{
 	{
 		unsigned char * pcd = new unsigned char[e->size];
 		unsigned char * pcd = new unsigned char[e->size];
 		fread((char*)pcd, 1, e->size, FLOD);
 		fread((char*)pcd, 1, e->size, FLOD);
@@ -335,21 +335,21 @@ SDL_Surface * CLodHandler::loadBitmap(std::string fname)
 int CLodHandler::decompress (unsigned char * source, int size, int realSize, std::string & dest)
 int CLodHandler::decompress (unsigned char * source, int size, int realSize, std::string & dest)
 {
 {
 	std::ofstream lb;
 	std::ofstream lb;
-	lb.open("lodbuf\\buf.gz", std::ios::out|std::ios::binary);
+	lb.open(DATADIR "lodbuf" PATHSEPARATOR "buf.gz", std::ios::out|std::ios::binary);
 	for(int i=0; i<size; ++i)
 	for(int i=0; i<size; ++i)
 	{
 	{
 		lb<<source[i];
 		lb<<source[i];
 	}
 	}
 	lb.close();
 	lb.close();
 
 
-	FILE * inputf = fopen("lodbuf\\buf.gz", "rb+");
+	FILE * inputf = fopen(DATADIR "lodbuf" PATHSEPARATOR "buf.gz", "rb+");
 	FILE * outputf = fopen(dest.c_str(), "wb+");
 	FILE * outputf = fopen(dest.c_str(), "wb+");
 
 
 	int ret = infm(inputf, outputf);
 	int ret = infm(inputf, outputf);
 	fclose(inputf);
 	fclose(inputf);
 	fclose(outputf);
 	fclose(outputf);
 	return ret;
 	return ret;
-} 
+}
 
 
 int CLodHandler::infm(FILE *source, FILE *dest, int wBits)
 int CLodHandler::infm(FILE *source, FILE *dest, int wBits)
 {
 {
@@ -412,7 +412,7 @@ int CLodHandler::infm(FILE *source, FILE *dest, int wBits)
 	(void)inflateEnd(&strm);
 	(void)inflateEnd(&strm);
 	return ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR;
 	return ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR;
 }
 }
-CDefHandler * CLodHandler::giveDef(std::string defName) 
+CDefHandler * CLodHandler::giveDef(std::string defName)
 {
 {
 	std::transform(defName.begin(), defName.end(), defName.begin(), (int(*)(int))toupper);
 	std::transform(defName.begin(), defName.end(), defName.begin(), (int(*)(int))toupper);
 	Entry * ourEntry = entries.znajdz(Entry(defName));
 	Entry * ourEntry = entries.znajdz(Entry(defName));
@@ -475,7 +475,7 @@ CDefEssential * CLodHandler::giveDefEss(std::string defName)
 }
 }
 std::vector<CDefHandler *> CLodHandler::extractManyFiles(std::vector<std::string> defNamesIn)
 std::vector<CDefHandler *> CLodHandler::extractManyFiles(std::vector<std::string> defNamesIn)
 {
 {
-	std::vector<CDefHandler *> ret(defNamesIn.size()); 
+	std::vector<CDefHandler *> ret(defNamesIn.size());
 	for(int hh=0; hh<defNamesIn.size(); ++hh)
 	for(int hh=0; hh<defNamesIn.size(); ++hh)
 	{
 	{
 		//std::transform(defNamesIn[hh].begin(), defNamesIn[hh].end(), defNamesIn[hh].begin(), (int(*)(int))toupper);
 		//std::transform(defNamesIn[hh].begin(), defNamesIn[hh].end(), defNamesIn[hh].begin(), (int(*)(int))toupper);
@@ -672,7 +672,7 @@ int CLodHandler::infs2(unsigned char * in, int size, int realSize, unsigned char
 
 
 void CLodHandler::extract(std::string FName)
 void CLodHandler::extract(std::string FName)
 {
 {
-	
+
 	std::ofstream FOut;
 	std::ofstream FOut;
 	int i;
 	int i;
 
 
@@ -680,7 +680,7 @@ void CLodHandler::extract(std::string FName)
 	for (int i=0;i<totalFiles;i++)
 	for (int i=0;i<totalFiles;i++)
 	{
 	{
 		fseek(FLOD, entries[i].offset, 0);
 		fseek(FLOD, entries[i].offset, 0);
-		std::string bufff = (FName.substr(0, FName.size()-4) + "\\" + (char*)entries[i].name);
+		std::string bufff = (/*DATADIR  + */FName.substr(0, FName.size()-4) + PATHSEPARATOR + (char*)entries[i].name);
 		unsigned char * outp;
 		unsigned char * outp;
 		if (entries[i].size==0) //file is not compressed
 		if (entries[i].size==0) //file is not compressed
 		{
 		{
@@ -701,7 +701,7 @@ void CLodHandler::extract(std::string FName)
 				out.close();
 				out.close();
 			}
 			}
 		}
 		}
-		else 
+		else
 		{
 		{
 			outp = new unsigned char[entries[i].size];
 			outp = new unsigned char[entries[i].size];
 			fread((char*)outp, 1, entries[i].size, FLOD);
 			fread((char*)outp, 1, entries[i].size, FLOD);

+ 2 - 2
hch/CLodHandler.h

@@ -44,7 +44,7 @@ struct Entry
 	Entry(){};
 	Entry(){};
 };
 };
 class CPCXConv
 class CPCXConv
-{	
+{
 public:
 public:
 	unsigned char * pcx, *bmp;
 	unsigned char * pcx, *bmp;
 	int pcxs, bmps;
 	int pcxs, bmps;
@@ -82,4 +82,4 @@ public:
 	SDL_Surface * loadBitmap(std::string fname);
 	SDL_Surface * loadBitmap(std::string fname);
 };
 };
 
 
-#endif //CLODHANDLER_H
+#endif //CLODHANDLER_H

+ 48 - 48
hch/CMusicHandler.cpp

@@ -12,53 +12,53 @@ void CMusicHandler::initMusics()
 	}
 	}
 	atexit(Mix_CloseAudio);
 	atexit(Mix_CloseAudio);
 
 
-	AITheme0 = Mix_LoadMUS("MP3\\AITheme0.mp3");
-	AITheme1 = Mix_LoadMUS("MP3\\AITHEME1.mp3");
-	AITheme2 = Mix_LoadMUS("MP3\\AITHEME2.mp3");
-	buildTown = Mix_LoadWAV("MP3\\BUILDTWN.wav");
-	combat1 = Mix_LoadMUS("MP3\\COMBAT01.mp3");
-	combat2 = Mix_LoadMUS("MP3\\COMBAT02.mp3");
-	combat3 = Mix_LoadMUS("MP3\\COMBAT03.mp3");
-	combat4 = Mix_LoadMUS("MP3\\COMBAT04.mp3");
-	castleTown = Mix_LoadMUS("MP3\\CstleTown.mp3");
-	defendCastle = Mix_LoadMUS("MP3\\Defend Castle.mp3");
-	dirt = Mix_LoadMUS("MP3\\DIRT.mp3");
-	dungeon = Mix_LoadMUS("MP3\\DUNGEON.mp3");
-	elemTown = Mix_LoadMUS("MP3\\ElemTown.mp3");
-	evilTheme = Mix_LoadMUS("MP3\\EvilTheme.mp3");
-	fortressTown = Mix_LoadMUS("MP3\\FortressTown.mp3");
-	goodTheme = Mix_LoadMUS("MP3\\GoodTheme.mp3");
-	grass = Mix_LoadMUS("MP3\\GRASS.mp3");
-	infernoTown = Mix_LoadMUS("MP3\\InfernoTown.mp3");
-	lava = Mix_LoadMUS("MP3\\LAVA.mp3");
-	loopLepr = Mix_LoadMUS("MP3\\LoopLepr.mp3");
-	loseCampain = Mix_LoadMUS("MP3\\Lose Campain.mp3");
-	loseCastle = Mix_LoadMUS("MP3\\LoseCastle.mp3");
-	loseCombat = Mix_LoadMUS("MP3\\LoseCombat.mp3");
-	mainMenu = Mix_LoadMUS("MP3\\MAINMENU.mp3");
-	mainMenuWoG = Mix_LoadMUS("MP3\\MainMenuWoG.mp3");
-	necroTown = Mix_LoadMUS("MP3\\necroTown.mp3");
-	neutralTheme = Mix_LoadMUS("MP3\\NeutralTheme.mp3");
-	rampart = Mix_LoadMUS("MP3\\RAMPART.mp3");
-	retreatBattle = Mix_LoadMUS("MP3\\Retreat Battle.mp3");
-	rough = Mix_LoadMUS("MP3\\ROUGH.mp3");
-	sand = Mix_LoadMUS("MP3\\SAND.mp3");
-	secretTheme = Mix_LoadMUS("MP3\\SecretTheme.mp3");
-	snow = Mix_LoadMUS("MP3\\SNOW.mp3");
-	stronghold = Mix_LoadMUS("MP3\\StrongHold.mp3");
-	surrenderBattle = Mix_LoadMUS("MP3\\Surrender Battle.mp3");
-	swamp = Mix_LoadMUS("MP3\\SWAMP.mp3");
-	towerTown = Mix_LoadMUS("MP3\\TowerTown.mp3");
-	ultimateLose = Mix_LoadMUS("MP3\\UltimateLose.mp3");
-	underground = Mix_LoadMUS("MP3\\Underground.mp3");
-	water = Mix_LoadMUS("MP3\\WATER.mp3");
-	winBattle = Mix_LoadMUS("MP3\\Win Battle.mp3");
-	winScenario = Mix_LoadMUS("MP3\\Win Scenario.mp3");
-	
-	click = Mix_LoadWAV("MP3\\snd1.wav");
+	AITheme0 = Mix_LoadMUS(DATADIR "MP3" PATHSEPARATOR "AITheme0.mp3");
+	AITheme1 = Mix_LoadMUS(DATADIR "MP3" PATHSEPARATOR "AITHEME1.mp3");
+	AITheme2 = Mix_LoadMUS(DATADIR "MP3" PATHSEPARATOR "AITHEME2.mp3");
+	buildTown = Mix_LoadWAV("MP3" PATHSEPARATOR "BUILDTWN.wav");
+	combat1 = Mix_LoadMUS(DATADIR "MP3" PATHSEPARATOR "COMBAT01.mp3");
+	combat2 = Mix_LoadMUS(DATADIR "MP3" PATHSEPARATOR "COMBAT02.mp3");
+	combat3 = Mix_LoadMUS(DATADIR "MP3" PATHSEPARATOR "COMBAT03.mp3");
+	combat4 = Mix_LoadMUS(DATADIR "MP3" PATHSEPARATOR "COMBAT04.mp3");
+	castleTown = Mix_LoadMUS(DATADIR "MP3" PATHSEPARATOR "CstleTown.mp3");
+	defendCastle = Mix_LoadMUS(DATADIR "MP3" PATHSEPARATOR "Defend Castle.mp3");
+	dirt = Mix_LoadMUS(DATADIR "MP3" PATHSEPARATOR "DIRT.mp3");
+	dungeon = Mix_LoadMUS(DATADIR "MP3" PATHSEPARATOR "DUNGEON.mp3");
+	elemTown = Mix_LoadMUS(DATADIR "MP3" PATHSEPARATOR "ElemTown.mp3");
+	evilTheme = Mix_LoadMUS(DATADIR "MP3" PATHSEPARATOR "EvilTheme.mp3");
+	fortressTown = Mix_LoadMUS(DATADIR "MP3" PATHSEPARATOR "FortressTown.mp3");
+	goodTheme = Mix_LoadMUS(DATADIR "MP3" PATHSEPARATOR "GoodTheme.mp3");
+	grass = Mix_LoadMUS(DATADIR "MP3" PATHSEPARATOR "GRASS.mp3");
+	infernoTown = Mix_LoadMUS(DATADIR "MP3" PATHSEPARATOR "InfernoTown.mp3");
+	lava = Mix_LoadMUS(DATADIR "MP3" PATHSEPARATOR "LAVA.mp3");
+	loopLepr = Mix_LoadMUS(DATADIR "MP3" PATHSEPARATOR "LoopLepr.mp3");
+	loseCampain = Mix_LoadMUS(DATADIR "MP3" PATHSEPARATOR "Lose Campain.mp3");
+	loseCastle = Mix_LoadMUS(DATADIR "MP3" PATHSEPARATOR "LoseCastle.mp3");
+	loseCombat = Mix_LoadMUS(DATADIR "MP3" PATHSEPARATOR "LoseCombat.mp3");
+	mainMenu = Mix_LoadMUS(DATADIR "MP3" PATHSEPARATOR "MAINMENU.mp3");
+	mainMenuWoG = Mix_LoadMUS(DATADIR "MP3" PATHSEPARATOR "MainMenuWoG.mp3");
+	necroTown = Mix_LoadMUS(DATADIR "MP3" PATHSEPARATOR "necroTown.mp3");
+	neutralTheme = Mix_LoadMUS(DATADIR "MP3" PATHSEPARATOR "NeutralTheme.mp3");
+	rampart = Mix_LoadMUS(DATADIR "MP3" PATHSEPARATOR "RAMPART.mp3");
+	retreatBattle = Mix_LoadMUS(DATADIR "MP3" PATHSEPARATOR "Retreat Battle.mp3");
+	rough = Mix_LoadMUS(DATADIR "MP3" PATHSEPARATOR "ROUGH.mp3");
+	sand = Mix_LoadMUS(DATADIR "MP3" PATHSEPARATOR "SAND.mp3");
+	secretTheme = Mix_LoadMUS(DATADIR "MP3" PATHSEPARATOR "SecretTheme.mp3");
+	snow = Mix_LoadMUS(DATADIR "MP3" PATHSEPARATOR "SNOW.mp3");
+	stronghold = Mix_LoadMUS(DATADIR "MP3" PATHSEPARATOR "StrongHold.mp3");
+	surrenderBattle = Mix_LoadMUS(DATADIR "MP3" PATHSEPARATOR "Surrender Battle.mp3");
+	swamp = Mix_LoadMUS(DATADIR "MP3" PATHSEPARATOR "SWAMP.mp3");
+	towerTown = Mix_LoadMUS(DATADIR "MP3" PATHSEPARATOR "TowerTown.mp3");
+	ultimateLose = Mix_LoadMUS(DATADIR "MP3" PATHSEPARATOR "UltimateLose.mp3");
+	underground = Mix_LoadMUS(DATADIR "MP3" PATHSEPARATOR "Underground.mp3");
+	water = Mix_LoadMUS(DATADIR "MP3" PATHSEPARATOR "WATER.mp3");
+	winBattle = Mix_LoadMUS(DATADIR "MP3" PATHSEPARATOR "Win Battle.mp3");
+	winScenario = Mix_LoadMUS(DATADIR "MP3" PATHSEPARATOR "Win Scenario.mp3");
+
+	click = Mix_LoadWAV(DATADIR "MP3" PATHSEPARATOR "snd1.wav");
 	click->volume = 30;
 	click->volume = 30;
 
 
-	this->sndh = new CSndHandler(std::string("Data\\Heroes3.snd"));
+	this->sndh = new CSndHandler(std::string(DATADIR "Data" PATHSEPARATOR "Heroes3.snd"));
 }
 }
 
 
 void CMusicHandler::playClick()
 void CMusicHandler::playClick()
@@ -86,12 +86,12 @@ void CMusicHandler::playLodSnd(std::string sndname)
 
 
 	ops = SDL_RWFromConstMem(data, size);
 	ops = SDL_RWFromConstMem(data, size);
 	chunk = Mix_LoadWAV_RW(ops, 1);
 	chunk = Mix_LoadWAV_RW(ops, 1);
-	
+
 	channel = Mix_PlayChannel(-1, chunk, 0);
 	channel = Mix_PlayChannel(-1, chunk, 0);
 	if(channel == -1)
 	if(channel == -1)
 	{
 	{
-		fprintf(stderr, "Unable to play WAV file(Data\\Heroes3.wav::%s): %s\n",
+		fprintf(stderr, "Unable to play WAV file("DATADIR "Data" PATHSEPARATOR "Heroes3.wav::%s): %s\n",
 			sndname.c_str(),Mix_GetError());
 			sndname.c_str(),Mix_GetError());
 	}
 	}
 	ops->close(ops);
 	ops->close(ops);
-}
+}

+ 1 - 1
hch/CMusicHandler.h

@@ -17,4 +17,4 @@ public:
 };
 };
 
 
 
 
-#endif //CMUSICHANDLER_H
+#endif //CMUSICHANDLER_H

+ 6 - 6
hch/CObjectHandler.cpp

@@ -100,7 +100,7 @@ int CGObjectInstance::getOwner() const
 {
 {
 	//if (state)
 	//if (state)
 	//	return state->owner;
 	//	return state->owner;
-	//else 
+	//else
 		return tempOwner; //won't have owner
 		return tempOwner; //won't have owner
 }
 }
 
 
@@ -154,7 +154,7 @@ bool CGObjectInstance::operator<(const CGObjectInstance & cmp) const  //screen p
 	return false;
 	return false;
 }
 }
 
 
-	
+
 bool CGHeroInstance::isHero() const
 bool CGHeroInstance::isHero() const
 {
 {
 	return true;
 	return true;
@@ -164,13 +164,13 @@ unsigned int CGHeroInstance::getTileCost(const EterrainType & ttype, const Eroad
 	unsigned int ret = type->heroClass->terrCosts[ttype];
 	unsigned int ret = type->heroClass->terrCosts[ttype];
 	switch(rdtype)
 	switch(rdtype)
 	{
 	{
-	case Eroad::dirtRoad:
+	case dirtRoad:
 		ret*=0.75;
 		ret*=0.75;
 		break;
 		break;
-	case Eroad::grazvelRoad:
+	case grazvelRoad:
 		ret*=0.667;
 		ret*=0.667;
 		break;
 		break;
-	case Eroad::cobblestoneRoad:
+	case cobblestoneRoad:
 		ret*=0.5;
 		ret*=0.5;
 		break;
 		break;
 	}
 	}
@@ -387,4 +387,4 @@ CGObjectInstance& CGObjectInstance::operator=(const CGObjectInstance & right)
 	//*state = *right.state;
 	//*state = *right.state;
 	tempOwner = right.tempOwner;
 	tempOwner = right.tempOwner;
 	return *this;
 	return *this;
-}
+}

+ 8 - 8
hch/CObjectHandler.h

@@ -305,7 +305,7 @@ class CGObjectInstance
 public:
 public:
 	int3 pos; //h3m pos
 	int3 pos; //h3m pos
 	int ID, subID; //normal ID (this one from OH3 maps ;]) - eg. town=98; hero=34
 	int ID, subID; //normal ID (this one from OH3 maps ;]) - eg. town=98; hero=34
-	int id;//number of object in CObjectHandler's vector		
+	int id;//number of object in CObjectHandler's vector
 	CGDefInfo * defInfo;
 	CGDefInfo * defInfo;
 	CCPPObjectScript * state;
 	CCPPObjectScript * state;
 	CSpecObjInfo * info;
 	CSpecObjInfo * info;
@@ -313,10 +313,10 @@ public:
 
 
 	int tempOwner; //uzywane dla szybkosci, skrypt ma obowiazek aktualizowac te zmienna
 	int tempOwner; //uzywane dla szybkosci, skrypt ma obowiazek aktualizowac te zmienna
 	bool blockVisit;
 	bool blockVisit;
-	
+
 	virtual bool isHero() const;
 	virtual bool isHero() const;
-	int getOwner() const; 
-	void setOwner(int ow); 
+	int getOwner() const;
+	void setOwner(int ow);
 	int getWidth() const; //returns width of object graphic in tiles
 	int getWidth() const; //returns width of object graphic in tiles
 	int getHeight() const; //returns height of object graphic in tiles
 	int getHeight() const; //returns height of object graphic in tiles
 	bool visitableAt(int x, int y) const; //returns true if ibject is visitable at location (x, y) form left top tile of image (x, y in tiles)
 	bool visitableAt(int x, int y) const; //returns true if ibject is visitable at location (x, y) form left top tile of image (x, y in tiles)
@@ -352,7 +352,7 @@ public:
 	std::vector<std::pair<int,int> > secSkills; //first - ID of skill, second - level of skill (0 - basic, 1 - adv., 2 - expert)
 	std::vector<std::pair<int,int> > secSkills; //first - ID of skill, second - level of skill (0 - basic, 1 - adv., 2 - expert)
 	int movement; //remaining movement points
 	int movement; //remaining movement points
 
 
-	bool inTownGarrison; // if hero is in town garrison 
+	bool inTownGarrison; // if hero is in town garrison
 	CGTownInstance * visitedTown; //set if hero is visiting town or in the town garrison
 	CGTownInstance * visitedTown; //set if hero is visiting town or in the town garrison
 
 
 	std::vector<CArtifact *> artifacts; //hero's artifacts from bag
 	std::vector<CArtifact *> artifacts; //hero's artifacts from bag
@@ -383,7 +383,7 @@ public:
 	std::string name; // name of town
 	std::string name; // name of town
 	int builded; //how many buildings has been built this turn
 	int builded; //how many buildings has been built this turn
 	int destroyed; //how many buildings has been destroyed this turn
 	int destroyed; //how many buildings has been destroyed this turn
-	int identifier; 
+	int identifier;
 
 
 	int income;
 	int income;
 
 
@@ -392,7 +392,7 @@ public:
 	public:
 	public:
 		std::map<int,int> creatures; //level - available amount
 		std::map<int,int> creatures; //level - available amount
 	} strInfo;
 	} strInfo;
-	
+
 	std::set<int> forbiddenBuildings, builtBuildings, h3mbuildings;
 	std::set<int> forbiddenBuildings, builtBuildings, h3mbuildings;
 
 
 	const CGHeroInstance * garrisonHero, *visitingHero;
 	const CGHeroInstance * garrisonHero, *visitingHero;
@@ -431,4 +431,4 @@ public:
 };
 };
 
 
 
 
-#endif //COBJECTHANDLER_H
+#endif //COBJECTHANDLER_H

+ 1 - 1
hch/CPreGameTextHandler.h

@@ -18,4 +18,4 @@ public:
 };
 };
 
 
 
 
-#endif //CPREGAMETEXTHANDLER_H
+#endif //CPREGAMETEXTHANDLER_H

+ 2 - 2
hch/CSemiDefHandler.h

@@ -15,7 +15,7 @@ struct Cimage
 class CSemiDefHandler
 class CSemiDefHandler
 {
 {
 public:
 public:
-	int howManyImgs;	
+	int howManyImgs;
 	std::string defName;
 	std::string defName;
 	std::vector<Cimage> ourImages;
 	std::vector<Cimage> ourImages;
 	std::vector<std::string> namesOfImgs;
 	std::vector<std::string> namesOfImgs;
@@ -28,4 +28,4 @@ public:
 	void loadImages(std::string path);
 	void loadImages(std::string path);
 	~CSemiDefHandler();
 	~CSemiDefHandler();
 };
 };
-#endif // SEMIDEF_H
+#endif // SEMIDEF_H

+ 1 - 1
hch/CSemiLodHandler.h

@@ -10,4 +10,4 @@ public:
 	CSemiDefHandler * giveDef(std::string name, int dist=1); //loads def from our lod
 	CSemiDefHandler * giveDef(std::string name, int dist=1); //loads def from our lod
 };
 };
 
 
-#endif //CSEMILODHANDLER_H
+#endif //CSEMILODHANDLER_H

+ 12 - 4
hch/CSndHandler.cpp

@@ -12,7 +12,11 @@ CSndHandler::CSndHandler(std::string fname):CHUNK(65535)
 {
 {
 	file.open(fname.c_str(),std::ios::binary);
 	file.open(fname.c_str(),std::ios::binary);
 	if (!file.is_open())
 	if (!file.is_open())
+#ifndef __GNUC__
 		throw new std::exception((std::string("Cannot open ")+fname).c_str());
 		throw new std::exception((std::string("Cannot open ")+fname).c_str());
+#else
+		throw new std::exception();
+#endif
 	int nr = readNormalNr(0,4);
 	int nr = readNormalNr(0,4);
 	char tempc;
 	char tempc;
 	for (int i=0;i<nr;i++)
 	for (int i=0;i<nr;i++)
@@ -98,7 +102,7 @@ void CSndHandler::extract(std::string srcfile, std::string dstfile, bool caseSen
 }
 }
 MemberFile CSndHandler::getFile(std::string name)
 MemberFile CSndHandler::getFile(std::string name)
 {
 {
-	MemberFile ret;	
+	MemberFile ret;
 	std::transform(name.begin(),name.end(),name.begin(),tolower);
 	std::transform(name.begin(),name.end(),name.begin(),tolower);
 	for (int i=0;i<entries.size();i++)
 	for (int i=0;i<entries.size();i++)
 	{
 	{
@@ -149,7 +153,11 @@ CVidHandler::CVidHandler(std::string fname):CHUNK(65535)
 {
 {
 	file.open(fname.c_str(),std::ios::binary);
 	file.open(fname.c_str(),std::ios::binary);
 	if (!file.is_open())
 	if (!file.is_open())
+#ifndef __GNUC__
 		throw new std::exception((std::string("Cannot open ")+fname).c_str());
 		throw new std::exception((std::string("Cannot open ")+fname).c_str());
+#else
+		throw new std::exception();
+#endif
 	int nr = readNormalNr(0,4);
 	int nr = readNormalNr(0,4);
 	char tempc;
 	char tempc;
 	for (int i=0;i<nr;i++)
 	for (int i=0;i<nr;i++)
@@ -169,9 +177,9 @@ CVidHandler::CVidHandler(std::string fname):CHUNK(65535)
 			entries[i-1].size=entry.offset-entries[i-1].offset;
 			entries[i-1].size=entry.offset-entries[i-1].offset;
 		if (i==nr-1)
 		if (i==nr-1)
 		{
 		{
-			file.seekg(0,std::ios::end); 
+			file.seekg(0,std::ios::end);
 			entry.size = ((int)file.tellg())-entry.offset;
 			entry.size = ((int)file.tellg())-entry.offset;
-			file.seekg(0,std::ios::beg); 
+			file.seekg(0,std::ios::beg);
 		}
 		}
 		entries.push_back(entry);
 		entries.push_back(entry);
 	}
 	}
@@ -234,7 +242,7 @@ void CVidHandler::extract(std::string srcfile, std::string dstfile, bool caseSen
 }
 }
 MemberFile CVidHandler::getFile(std::string name)
 MemberFile CVidHandler::getFile(std::string name)
 {
 {
-	MemberFile ret;	
+	MemberFile ret;
 	std::transform(name.begin(),name.end(),name.begin(),tolower);
 	std::transform(name.begin(),name.end(),name.begin(),tolower);
 	for (int i=0;i<entries.size();i++)
 	for (int i=0;i<entries.size();i++)
 	{
 	{

+ 1 - 1
hch/CSndHandler.h

@@ -56,4 +56,4 @@ public:
 };
 };
 
 
 
 
-#endif //CSNDHANDLER_H
+#endif //CSNDHANDLER_H

+ 1 - 1
hch/CSpellHandler.h

@@ -38,4 +38,4 @@ public:
 	void loadSpells();
 	void loadSpells();
 };
 };
 
 
-#endif //CSPELLHANDLER_H
+#endif //CSPELLHANDLER_H

+ 9 - 5
hch/CTownHandler.cpp

@@ -2,7 +2,7 @@
 #include "CTownHandler.h"
 #include "CTownHandler.h"
 #include "../CGameInfo.h"
 #include "../CGameInfo.h"
 #include "CLodHandler.h"
 #include "CLodHandler.h"
-#include <sstream> 
+#include <sstream>
 #include "CGeneralTextHandler.h"
 #include "CGeneralTextHandler.h"
 CTownHandler::CTownHandler()
 CTownHandler::CTownHandler()
 {
 {
@@ -35,7 +35,7 @@ void CTownHandler::loadNames()
 		}
 		}
 		town.typeID=si++;
 		town.typeID=si++;
 		town.bonus=towns.size();
 		town.bonus=towns.size();
-		if (town.bonus==8) town.bonus=3; 
+		if (town.bonus==8) town.bonus=3;
 		if (town.name.length())
 		if (town.name.length())
 			towns.push_back(town);
 			towns.push_back(town);
 	}
 	}
@@ -124,7 +124,7 @@ void CTownHandler::loadNames()
 			{
 			{
 				i2->second->borderName = border;
 				i2->second->borderName = border;
 				i2->second->areaName = area;
 				i2->second->areaName = area;
-			}		
+			}
 			else
 			else
 				std::cout << "Warning2: No building "<<id<<" in the castle "<<town<<std::endl;
 				std::cout << "Warning2: No building "<<id<<" in the castle "<<town<<std::endl;
 		else
 		else
@@ -190,7 +190,7 @@ void CTownHandler::loadNames()
 						{
 						{
 							for(i=structures.begin();i!=structures.end();i++)
 							for(i=structures.begin();i!=structures.end();i++)
 							{
 							{
-								for(i2=i->second.begin(); i2!=i->second.end(); i2++) 
+								for(i2=i->second.begin(); i2!=i->second.end(); i2++)
 								{
 								{
 									if(i2->first == buildingID)
 									if(i2->first == buildingID)
 									{
 									{
@@ -249,7 +249,7 @@ void CTownHandler::loadNames()
 		}
 		}
 		of.close();
 		of.close();
 		of.clear();
 		of.clear();
-		
+
 		of.open("config/requirements.txt");
 		of.open("config/requirements.txt");
 		while(!of.eof())
 		while(!of.eof())
 		{
 		{
@@ -286,7 +286,11 @@ SDL_Surface * CTownHandler::getPic(int ID, bool fort, bool builded)
 	else if (ID==-3)
 	else if (ID==-3)
 		return smallIcons->ourImages[2+F_NUMBER*4].bitmap;
 		return smallIcons->ourImages[2+F_NUMBER*4].bitmap;
 	else if (ID>F_NUMBER || ID<-3)
 	else if (ID>F_NUMBER || ID<-3)
+#ifndef __GNUC__
 		throw new std::exception("Invalid ID");
 		throw new std::exception("Invalid ID");
+#else
+		throw new std::exception();
+#endif
 	else
 	else
 	{
 	{
 		int pom = 3;
 		int pom = 3;

+ 1 - 1
hch/CTownHandler.h

@@ -58,4 +58,4 @@ public:
 
 
 };
 };
 
 
-#endif //CTOWNHANDLER_H
+#endif //CTOWNHANDLER_H

+ 21 - 7
hch/CVideoHandler.cpp

@@ -2,9 +2,14 @@
 #include <iostream>
 #include <iostream>
 #include "CVideoHandler.h"
 #include "CVideoHandler.h"
 #include "SDL.h"
 #include "SDL.h"
+
 void DLLHandler::Instantiate(const char *filename)
 void DLLHandler::Instantiate(const char *filename)
 {
 {
+#ifdef WIN32
 	dll = LoadLibraryA(filename);
 	dll = LoadLibraryA(filename);
+#else
+	dll = dlopen(filename,RTLD_LOCAL | RTLD_LAZY);
+#endif
 }
 }
 const char *DLLHandler::GetLibExtension()
 const char *DLLHandler::GetLibExtension()
 {
 {
@@ -21,14 +26,22 @@ const char *DLLHandler::GetLibExtension()
 
 
 void *DLLHandler::FindAddress234(const char *symbol)
 void *DLLHandler::FindAddress234(const char *symbol)
 {
 {
+#ifdef WIN32
 	if ((int)symbol == 0x00001758)
 	if ((int)symbol == 0x00001758)
 		return NULL;
 		return NULL;
 	std::cout<<"co ja tu robie"<<std::endl;
 	std::cout<<"co ja tu robie"<<std::endl;
 	return (void*) GetProcAddress(dll,symbol);
 	return (void*) GetProcAddress(dll,symbol);
+#else
+	return (void *)dlsym(dll, symbol);
+#endif
 }
 }
 DLLHandler::~DLLHandler()
 DLLHandler::~DLLHandler()
 {
 {
+#ifdef WIN32
 	FreeLibrary(dll);
 	FreeLibrary(dll);
+#else
+	dlclose(dll);
+#endif
 }
 }
 
 
 
 
@@ -53,13 +66,15 @@ int readNormalNr2 (unsigned char* bufor, int &iter, int bytCon)
 }
 }
 void RaiseLastOSErrorAt(char * offset)
 void RaiseLastOSErrorAt(char * offset)
 {
 {
+#ifdef WIN32
 	int * lastError = new int;
 	int * lastError = new int;
 	std::exception * error;
 	std::exception * error;
 	*lastError = GetLastError();
 	*lastError = GetLastError();
 	if (*lastError)
 	if (*lastError)
 		throw lastError;
 		throw lastError;
-
-
+#else
+	throw new std::exception();
+#endif
 }
 }
 //var
 //var
 //  LastError: Integer;
 //  LastError: Integer;
@@ -93,10 +108,7 @@ void RaiseLastOSErrorAt(char * offset)
 //}
 //}
 void CBIKHandler::open(std::string name)
 void CBIKHandler::open(std::string name)
 {
 {
-
-
-
-
+#ifdef WIN32
 	hBinkFile = CreateFile
 	hBinkFile = CreateFile
 	(
 	(
 		L"CSECRET.BIK",				// file name
 		L"CSECRET.BIK",				// file name
@@ -135,7 +147,7 @@ void CBIKHandler::open(std::string name)
 		gg.bmPlanes=1;
 		gg.bmPlanes=1;
 		gg.bmWidthBytes=3*width;
 		gg.bmWidthBytes=3*width;
 		gg.bmBits = new unsigned char[width*height*(gg.bmBitsPixel/8)];
 		gg.bmBits = new unsigned char[width*height*(gg.bmBitsPixel/8)];
-		
+
 		//HBITMAP bitmapa = CreateBitmap(width, height,1,24,NULL);
 		//HBITMAP bitmapa = CreateBitmap(width, height,1,24,NULL);
 		std::cout<<"przeszlo!"<<std::endl;
 		std::cout<<"przeszlo!"<<std::endl;
 	}
 	}
@@ -143,7 +155,9 @@ void CBIKHandler::open(std::string name)
 	{
 	{
 		printf("cos nie tak");
 		printf("cos nie tak");
 	}
 	}
+#endif
 }
 }
+
 //void CBIKHandler::close()
 //void CBIKHandler::close()
 //{
 //{
 //	void *binkClose;
 //	void *binkClose;

+ 20 - 8
hch/CVideoHandler.h

@@ -2,7 +2,12 @@
 #define CVIDEOHANDLEER_H
 #define CVIDEOHANDLEER_H
 
 
 #include <stdio.h>
 #include <stdio.h>
+#ifdef WIN32
 #include <windows.h>
 #include <windows.h>
+#else
+#include <dlfcn.h>
+#endif
+
 //
 //
 #define BINKNOTHREADEDIO 0x00800000
 #define BINKNOTHREADEDIO 0x00800000
 //
 //
@@ -75,14 +80,14 @@
   //end;
   //end;
 typedef struct
 typedef struct
 {
 {
-	int width;			
-	int height;		
-	int frameCount;	
-	int currentFrame;		
+	int width;
+	int height;
+	int frameCount;
+	int currentFrame;
 	int lastFrame;
 	int lastFrame;
-	int FPSMul;	
+	int FPSMul;
 	int FPSDiv;
 	int FPSDiv;
-	int unknown0;	
+	int unknown0;
 	unsigned char flags;
 	unsigned char flags;
 	unsigned char unknown1[260];
 	unsigned char unknown1[260];
 	int CurPlane;		// current plane
 	int CurPlane;		// current plane
@@ -109,8 +114,11 @@ struct SMKStruct
 class DLLHandler
 class DLLHandler
 {
 {
 public:
 public:
+#ifndef __amigaos4__
 	HINSTANCE dll;
 	HINSTANCE dll;
-
+#else
+	void *dll;
+#endif
 	void Instantiate(const char *filename);
 	void Instantiate(const char *filename);
 	const char *GetLibExtension();
 	const char *GetLibExtension();
 	void *FindAddress234(const char *symbol);
 	void *FindAddress234(const char *symbol);
@@ -123,7 +131,11 @@ class CBIKHandler
 public:
 public:
 	DLLHandler ourLib;
 	DLLHandler ourLib;
 	int newmode;
 	int newmode;
+#ifndef __amigaos4__
 	HANDLE hBinkFile;
 	HANDLE hBinkFile;
+#else
+	void *hBinkFile;
+#endif
 	HBINK hBink;
 	HBINK hBink;
 	BINK_STRUCT data;
 	BINK_STRUCT data;
 	unsigned char * buffer;
 	unsigned char * buffer;
@@ -135,4 +147,4 @@ public:
 	void open(std::string name);
 	void open(std::string name);
 	void close();
 	void close();
 };
 };
-#endif //CVIDEOHANDLEER_H
+#endif //CVIDEOHANDLEER_H

+ 5 - 5
int3.h

@@ -23,7 +23,7 @@ public:
 		x+=i.x;
 		x+=i.x;
 		y+=i.y;
 		y+=i.y;
 		z+=i.z;
 		z+=i.z;
-	}	
+	}
 	inline void operator+=(const int & i)
 	inline void operator+=(const int & i)
 	{
 	{
 		x+=i;
 		x+=i;
@@ -35,15 +35,15 @@ public:
 		x-=i.x;
 		x-=i.x;
 		y-=i.y;
 		y-=i.y;
 		z-=i.z;
 		z-=i.z;
-	}	
+	}
 	inline void operator-=(const int & i)
 	inline void operator-=(const int & i)
 	{
 	{
 		x+=i;
 		x+=i;
 		y+=i;
 		y+=i;
 		z+=i;
 		z+=i;
-	}	
+	}
 	inline bool operator==(const int3 & i) const
 	inline bool operator==(const int3 & i) const
-		{return (x==i.x) && (y==i.y) && (z==i.z);}	
+		{return (x==i.x) && (y==i.y) && (z==i.z);}
 	inline bool operator!=(const int3 & i) const
 	inline bool operator!=(const int3 & i) const
 		{return !(*this==i);}
 		{return !(*this==i);}
 	inline bool operator<(const int3 & i) const
 	inline bool operator<(const int3 & i) const
@@ -72,4 +72,4 @@ inline std::ostream & operator<<(std::ostream & str, int3 & sth)
 {
 {
 	return str<<sth.x<<' '<<sth.y<<' '<<sth.z;
 	return str<<sth.x<<' '<<sth.y<<' '<<sth.z;
 }
 }
-#endif //INT3_H
+#endif //INT3_H

+ 21 - 21
map.cpp

@@ -27,9 +27,9 @@ CMapHeader::CMapHeader(unsigned char *map)
 	this->areAnyPLayers = map[4]; //seems to be invalid
 	this->areAnyPLayers = map[4]; //seems to be invalid
 	this->height = this->width = map[5]; // wymiary mapy
 	this->height = this->width = map[5]; // wymiary mapy
 	this->twoLevel = map[9]; //czy sa lochy
 	this->twoLevel = map[9]; //czy sa lochy
-	
+
 	int length = map[10]; //name length
 	int length = map[10]; //name length
-	int i=14, pom; 
+	int i=14, pom;
 	while (i-14<length)	//read name
 	while (i-14<length)	//read name
 		this->name+=map[i++];
 		this->name+=map[i++];
 	length = map[i] + map[i+1]*256; //description length
 	length = map[i] + map[i+1]*256; //description length
@@ -37,7 +37,7 @@ CMapHeader::CMapHeader(unsigned char *map)
 	for (pom=0;pom<length;pom++)
 	for (pom=0;pom<length;pom++)
 		this->description+=map[i++];
 		this->description+=map[i++];
 	this->difficulty = map[i++]; // reading map difficulty
 	this->difficulty = map[i++]; // reading map difficulty
-	if(version!=Eformat::RoE)
+	if(version!=RoE)
 	{
 	{
 		this->levelLimit = map[i++]; // hero level limit
 		this->levelLimit = map[i++]; // hero level limit
 	}
 	}
@@ -53,13 +53,13 @@ CMapHeader::CMapHeader(unsigned char *map)
 		{
 		{
 			switch(version)
 			switch(version)
 			{
 			{
-			case Eformat::SoD: case Eformat::WoG: 
+			case SoD: case WoG:
 				i+=13;
 				i+=13;
 				break;
 				break;
-			case Eformat::AB:
+			case AB:
 				i+=12;
 				i+=12;
 				break;
 				break;
-			case Eformat::RoE:
+			case RoE:
 				i+=6;
 				i+=6;
 				break;
 				break;
 			}
 			}
@@ -68,39 +68,39 @@ CMapHeader::CMapHeader(unsigned char *map)
 
 
 		this->players[pom].AITactic = map[i++];
 		this->players[pom].AITactic = map[i++];
 
 
-		if(version == Eformat::SoD || version == Eformat::WoG)
+		if(version == SoD || version == WoG)
 			i++;
 			i++;
 
 
 		this->players[pom].allowedFactions = 0;
 		this->players[pom].allowedFactions = 0;
 		this->players[pom].allowedFactions += map[i++];
 		this->players[pom].allowedFactions += map[i++];
-		if(version != Eformat::RoE)
+		if(version != RoE)
 			this->players[pom].allowedFactions += (map[i++])*256;
 			this->players[pom].allowedFactions += (map[i++])*256;
 
 
 		this->players[pom].isFactionRandom = map[i++];
 		this->players[pom].isFactionRandom = map[i++];
 		this->players[pom].hasMainTown = map[i++];
 		this->players[pom].hasMainTown = map[i++];
 		if (this->players[pom].hasMainTown)
 		if (this->players[pom].hasMainTown)
 		{
 		{
-			if(version != Eformat::RoE)
+			if(version != RoE)
 			{
 			{
 				this->players[pom].generateHeroAtMainTown = map[i++];
 				this->players[pom].generateHeroAtMainTown = map[i++];
 				this->players[pom].generateHero = map[i++];
 				this->players[pom].generateHero = map[i++];
 			}
 			}
 			this->players[pom].posOfMainTown.x = map[i++];
 			this->players[pom].posOfMainTown.x = map[i++];
 			this->players[pom].posOfMainTown.y = map[i++];
 			this->players[pom].posOfMainTown.y = map[i++];
-			this->players[pom].posOfMainTown.z = map[i++];	
+			this->players[pom].posOfMainTown.z = map[i++];
 		}
 		}
 		players[pom].p8= map[i++];
 		players[pom].p8= map[i++];
-		players[pom].p9= map[i++];		
+		players[pom].p9= map[i++];
 		if(players[pom].p9!=0xff)
 		if(players[pom].p9!=0xff)
 		{
 		{
 			players[pom].mainHeroPortrait = map[i++];
 			players[pom].mainHeroPortrait = map[i++];
 			int nameLength = map[i++];
 			int nameLength = map[i++];
-			i+=3; 
+			i+=3;
 			for (int pp=0;pp<nameLength;pp++)
 			for (int pp=0;pp<nameLength;pp++)
 				players[pom].mainHeroName+=map[i++];
 				players[pom].mainHeroName+=map[i++];
 		}
 		}
 
 
-		if(version!=Eformat::RoE)
+		if(version!=RoE)
 		{
 		{
 			i++; ////heroes placeholders //domostwa
 			i++; ////heroes placeholders //domostwa
 			int heroCount = map[i++];
 			int heroCount = map[i++];
@@ -180,7 +180,7 @@ CMapHeader::CMapHeader(unsigned char *map)
 				this->vicConDetails = new VicCon5();
 				this->vicConDetails = new VicCon5();
 				((VicCon5*)this->vicConDetails)->locationOfHero.x = map[i+2];
 				((VicCon5*)this->vicConDetails)->locationOfHero.x = map[i+2];
 				((VicCon5*)this->vicConDetails)->locationOfHero.y = map[i+3];
 				((VicCon5*)this->vicConDetails)->locationOfHero.y = map[i+3];
-				((VicCon5*)this->vicConDetails)->locationOfHero.z = map[i+4];				
+				((VicCon5*)this->vicConDetails)->locationOfHero.z = map[i+4];
 				nr=3;
 				nr=3;
 				break;
 				break;
 			}
 			}
@@ -189,7 +189,7 @@ CMapHeader::CMapHeader(unsigned char *map)
 				this->vicConDetails = new VicCon6();
 				this->vicConDetails = new VicCon6();
 				((VicCon6*)this->vicConDetails)->locationOfTown.x = map[i+2];
 				((VicCon6*)this->vicConDetails)->locationOfTown.x = map[i+2];
 				((VicCon6*)this->vicConDetails)->locationOfTown.y = map[i+3];
 				((VicCon6*)this->vicConDetails)->locationOfTown.y = map[i+3];
-				((VicCon6*)this->vicConDetails)->locationOfTown.z = map[i+4];				
+				((VicCon6*)this->vicConDetails)->locationOfTown.z = map[i+4];
 				nr=3;
 				nr=3;
 				break;
 				break;
 			}
 			}
@@ -198,19 +198,19 @@ CMapHeader::CMapHeader(unsigned char *map)
 				this->vicConDetails = new VicCon7();
 				this->vicConDetails = new VicCon7();
 				((VicCon7*)this->vicConDetails)->locationOfMonster.x = map[i+2];
 				((VicCon7*)this->vicConDetails)->locationOfMonster.x = map[i+2];
 				((VicCon7*)this->vicConDetails)->locationOfMonster.y = map[i+3];
 				((VicCon7*)this->vicConDetails)->locationOfMonster.y = map[i+3];
-				((VicCon7*)this->vicConDetails)->locationOfMonster.z = map[i+4];				
+				((VicCon7*)this->vicConDetails)->locationOfMonster.z = map[i+4];
 				nr=3;
 				nr=3;
 				break;
 				break;
 			}
 			}
 		case takeDwellings:
 		case takeDwellings:
-			{		
+			{
 				this->vicConDetails = new CspecificVictoryConidtions();
 				this->vicConDetails = new CspecificVictoryConidtions();
 				nr=3;
 				nr=3;
 				break;
 				break;
 			}
 			}
 		case takeMines:
 		case takeMines:
-			{	
-				this->vicConDetails = new CspecificVictoryConidtions();	
+			{
+				this->vicConDetails = new CspecificVictoryConidtions();
 				nr=3;
 				nr=3;
 				break;
 				break;
 			}
 			}
@@ -220,7 +220,7 @@ CMapHeader::CMapHeader(unsigned char *map)
 				((VicCona*)this->vicConDetails)->artifactID =  map[i+2];
 				((VicCona*)this->vicConDetails)->artifactID =  map[i+2];
 				((VicCona*)this->vicConDetails)->destinationPlace.x = map[i+3];
 				((VicCona*)this->vicConDetails)->destinationPlace.x = map[i+3];
 				((VicCona*)this->vicConDetails)->destinationPlace.y = map[i+4];
 				((VicCona*)this->vicConDetails)->destinationPlace.y = map[i+4];
-				((VicCona*)this->vicConDetails)->destinationPlace.z = map[i+5];				
+				((VicCona*)this->vicConDetails)->destinationPlace.z = map[i+5];
 				nr=4;
 				nr=4;
 				break;
 				break;
 			}
 			}
@@ -258,4 +258,4 @@ CMapHeader::CMapHeader(unsigned char *map)
 			this->players[rr].team=map[i++];
 			this->players[rr].team=map[i++];
 		}
 		}
 	}
 	}
-}
+}

+ 18 - 18
map.h

@@ -1,14 +1,14 @@
 #ifndef MAPD_H
 #ifndef MAPD_H
 #define MAPD_H
 #define MAPD_H
-#pragma warning (disable : 4482) 
+#pragma warning (disable : 4482)
 #include <string>
 #include <string>
 #include <vector>
 #include <vector>
 #include "global.h"
 #include "global.h"
-#include "hch\CSemiDefHandler.h"
-#include "hch\CDefHandler.h"
+#include "hch/CSemiDefHandler.h"
+#include "hch/CDefHandler.h"
 class CGDefInfo;
 class CGDefInfo;
 class CHeroObjInfo;
 class CHeroObjInfo;
-enum ESortBy{name,playerAm,size,format, viccon,loscon};
+enum ESortBy{_name, _playerAm, _size, _format, _viccon, _loscon};
 struct Sresource
 struct Sresource
 {
 {
 	std::string resName; //name of this resource
 	std::string resName; //name of this resource
@@ -56,7 +56,7 @@ struct TerrainTile
 };
 };
 struct DefInfo //information from def declaration
 struct DefInfo //information from def declaration
 {
 {
-	std::string name; 
+	std::string name;
 	int bytes [42];
 	int bytes [42];
 	//CSemiDefHandler * handler;
 	//CSemiDefHandler * handler;
 	CDefHandler * handler;
 	CDefHandler * handler;
@@ -76,7 +76,7 @@ struct PlayerInfo
 	bool canComputerPlay;
 	bool canComputerPlay;
 	unsigned int AITactic; //(00 - random, 01 -  warrior, 02 - builder, 03 - explorer)
 	unsigned int AITactic; //(00 - random, 01 -  warrior, 02 - builder, 03 - explorer)
 	unsigned int allowedFactions; //(01 - castle; 02 - rampart; 04 - tower; 08 - inferno; 16 - necropolis; 32 - dungeon; 64 - stronghold; 128 - fortress; 256 - conflux);
 	unsigned int allowedFactions; //(01 - castle; 02 - rampart; 04 - tower; 08 - inferno; 16 - necropolis; 32 - dungeon; 64 - stronghold; 128 - fortress; 256 - conflux);
-	bool isFactionRandom; 
+	bool isFactionRandom;
 	unsigned int mainHeroPortrait; //it's ID of hero with choosen portrait; 255 if standard
 	unsigned int mainHeroPortrait; //it's ID of hero with choosen portrait; 255 if standard
 	std::string mainHeroName;
 	std::string mainHeroName;
 	std::vector<SheroName> heroesNames;
 	std::vector<SheroName> heroesNames;
@@ -180,15 +180,15 @@ struct Mapa
 	bool areAnyPLayers; // if there are any playable players on map
 	bool areAnyPLayers; // if there are any playable players on map
 	std::string name;  //name of map
 	std::string name;  //name of map
 	std::string description;  //and description
 	std::string description;  //and description
-	int height, width; 
-	TerrainTile** terrain; 
+	int height, width;
+	TerrainTile** terrain;
 	TerrainTile** undergroungTerrain; // used only if there is underground level
 	TerrainTile** undergroungTerrain; // used only if there is underground level
 	std::vector<Rumor> rumors;
 	std::vector<Rumor> rumors;
 	std::vector<DisposedHero> disposedHeroes;
 	std::vector<DisposedHero> disposedHeroes;
 	std::vector<CHeroObjInfo*> predefinedHeroes;
 	std::vector<CHeroObjInfo*> predefinedHeroes;
 	std::vector<CGDefInfo *> defy; // list of .def files
 	std::vector<CGDefInfo *> defy; // list of .def files
 	PlayerInfo players[8]; // info about players
 	PlayerInfo players[8]; // info about players
-	std::vector<int> teams;  // teams[i] = team of player no i 
+	std::vector<int> teams;  // teams[i] = team of player no i
 	LossCondition lossCondition;
 	LossCondition lossCondition;
 	EvictoryConditions victoryCondition; //victory conditions
 	EvictoryConditions victoryCondition; //victory conditions
 	CspecificVictoryConidtions * vicConDetails; // used only if vistory conditions aren't standard
 	CspecificVictoryConidtions * vicConDetails; // used only if vistory conditions aren't standard
@@ -200,7 +200,7 @@ class CMapHeader
 public:
 public:
 	Eformat version; // version of map Eformat
 	Eformat version; // version of map Eformat
 	bool areAnyPLayers; // if there are any playable players on map
 	bool areAnyPLayers; // if there are any playable players on map
-	int height, width; 
+	int height, width;
 	bool twoLevel; // if map has underground level
 	bool twoLevel; // if map has underground level
 	std::string name;  //name of map
 	std::string name;  //name of map
 	std::string description;  //and description
 	std::string description;  //and description
@@ -210,7 +210,7 @@ public:
 	EvictoryConditions victoryCondition; //victory conditions
 	EvictoryConditions victoryCondition; //victory conditions
 	CspecificVictoryConidtions * vicConDetails; // used only if vistory conditions aren't standard
 	CspecificVictoryConidtions * vicConDetails; // used only if vistory conditions aren't standard
 	PlayerInfo players[8]; // info about players
 	PlayerInfo players[8]; // info about players
-	std::vector<int> teams;  // teams[i] = team of player no i 
+	std::vector<int> teams;  // teams[i] = team of player no i
 	int howManyTeams;
 	int howManyTeams;
 	CMapHeader(unsigned char *map); //an argument is a reference to string described a map (unpacked)
 	CMapHeader(unsigned char *map); //an argument is a reference to string described a map (unpacked)
 };
 };
@@ -235,17 +235,17 @@ class mapSorter
 {
 {
 public:
 public:
 	ESortBy sortBy;
 	ESortBy sortBy;
-	bool operator()(CMapHeader & a, CMapHeader& b)
+	bool operator()(const CMapHeader & a, const CMapHeader& b)
 	{
 	{
 		switch (sortBy)
 		switch (sortBy)
 		{
 		{
-		case ESortBy::format:
+		case _format:
 			return (a.version<b.version);
 			return (a.version<b.version);
 			break;
 			break;
-		case ESortBy::loscon:
+		case _loscon:
 			return (a.lossCondition.typeOfLossCon<b.lossCondition.typeOfLossCon);
 			return (a.lossCondition.typeOfLossCon<b.lossCondition.typeOfLossCon);
 			break;
 			break;
-		case ESortBy::playerAm:
+		case _playerAm:
 			int playerAmntB,humenPlayersB,playerAmntA,humenPlayersA;
 			int playerAmntB,humenPlayersB,playerAmntA,humenPlayersA;
 			playerAmntB=humenPlayersB=playerAmntA=humenPlayersA=0;
 			playerAmntB=humenPlayersB=playerAmntA=humenPlayersA=0;
 			for (int i=0;i<8;i++)
 			for (int i=0;i<8;i++)
@@ -260,13 +260,13 @@ public:
 			else
 			else
 				return (humenPlayersA<humenPlayersB);
 				return (humenPlayersA<humenPlayersB);
 			break;
 			break;
-		case ESortBy::size:
+		case _size:
 			return (a.width<b.width);
 			return (a.width<b.width);
 			break;
 			break;
-		case ESortBy::viccon:
+		case _viccon:
 			return (a.victoryCondition<b.victoryCondition);
 			return (a.victoryCondition<b.victoryCondition);
 			break;
 			break;
-		case ESortBy::name:
+		case _name:
 			return (a.name<b.name);
 			return (a.name<b.name);
 			break;
 			break;
 		default:
 		default:

+ 35 - 29
mapHandler.cpp

@@ -1,18 +1,18 @@
 #include "stdafx.h"
 #include "stdafx.h"
 #include "mapHandler.h"
 #include "mapHandler.h"
-#include "hch\CSemiDefHandler.h"
+#include "hch/CSemiDefHandler.h"
 #include "SDL_rotozoom.h"
 #include "SDL_rotozoom.h"
 #include "SDL_Extensions.h"
 #include "SDL_Extensions.h"
 #include "CGameInfo.h"
 #include "CGameInfo.h"
 #include "stdlib.h"
 #include "stdlib.h"
-#include "hch\CLodHandler.h"
-#include "hch\CDefObjInfoHandler.h"
+#include "hch/CLodHandler.h"
+#include "hch/CDefObjInfoHandler.h"
 #include <algorithm>
 #include <algorithm>
 #include "CGameState.h"
 #include "CGameState.h"
 #include "CLua.h"
 #include "CLua.h"
-#include "hch\CCastleHandler.h"
-#include "hch\CHeroHandler.h"
-#include "hch\CTownHandler.h"
+#include "hch/CCastleHandler.h"
+#include "hch/CHeroHandler.h"
+#include "hch/CTownHandler.h"
 #include <iomanip>
 #include <iomanip>
 #include <sstream>
 #include <sstream>
 extern SDL_Surface * screen;
 extern SDL_Surface * screen;
@@ -26,7 +26,7 @@ public:
 	}
 	}
 } ocmptwo ;
 } ocmptwo ;
 void alphaTransformDef(CGDefInfo * defInfo)
 void alphaTransformDef(CGDefInfo * defInfo)
-{	
+{
 	SDL_Surface * alphaTransSurf = SDL_CreateRGBSurface(SDL_SWSURFACE, 12, 12, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000);
 	SDL_Surface * alphaTransSurf = SDL_CreateRGBSurface(SDL_SWSURFACE, 12, 12, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000);
 	for(int yy=0;yy<defInfo->handler->ourImages.size();yy++)
 	for(int yy=0;yy<defInfo->handler->ourImages.size();yy++)
 	{
 	{
@@ -81,9 +81,9 @@ std::pair<int,int> CMapHandler::pickObject(CGObjectInstance *obj)
 			return std::pair<int,int>(34,pickHero(obj->tempOwner));
 			return std::pair<int,int>(34,pickHero(obj->tempOwner));
 		}
 		}
 	case 71: //random monster
 	case 71: //random monster
-		return std::pair<int,int>(54,rand()%(CGI->creh->creatures.size())); 
+		return std::pair<int,int>(54,rand()%(CGI->creh->creatures.size()));
 	case 72: //random monster lvl1
 	case 72: //random monster lvl1
-		return std::pair<int,int>(54,CGI->creh->levelCreatures[1][rand()%CGI->creh->levelCreatures[1].size()]->idNumber); 
+		return std::pair<int,int>(54,CGI->creh->levelCreatures[1][rand()%CGI->creh->levelCreatures[1].size()]->idNumber);
 	case 73: //random monster lvl2
 	case 73: //random monster lvl2
 		return std::pair<int,int>(54,CGI->creh->levelCreatures[2][rand()%CGI->creh->levelCreatures[2].size()]->idNumber);
 		return std::pair<int,int>(54,CGI->creh->levelCreatures[2][rand()%CGI->creh->levelCreatures[2].size()]->idNumber);
 	case 74: //random monster lvl3
 	case 74: //random monster lvl3
@@ -91,7 +91,7 @@ std::pair<int,int> CMapHandler::pickObject(CGObjectInstance *obj)
 	case 75: //random monster lvl4
 	case 75: //random monster lvl4
 		return std::pair<int,int>(54,CGI->creh->levelCreatures[4][rand()%CGI->creh->levelCreatures[4].size()]->idNumber);
 		return std::pair<int,int>(54,CGI->creh->levelCreatures[4][rand()%CGI->creh->levelCreatures[4].size()]->idNumber);
 	case 76: //random resource
 	case 76: //random resource
-		return std::pair<int,int>(79,rand()%7); //now it's OH3 style, use %8 for mithril 
+		return std::pair<int,int>(79,rand()%7); //now it's OH3 style, use %8 for mithril
 	case 77: //random town
 	case 77: //random town
 		{
 		{
 			int align = ((CCastleObjInfo*)obj->info)->alignment,
 			int align = ((CCastleObjInfo*)obj->info)->alignment,
@@ -108,14 +108,14 @@ std::pair<int,int> CMapHandler::pickObject(CGObjectInstance *obj)
 				f = CGI->scenarioOps.getIthPlayersSettings(align).castle;
 				f = CGI->scenarioOps.getIthPlayersSettings(align).castle;
 			}
 			}
 			if(f<0) f = rand()%CGI->townh->towns.size();
 			if(f<0) f = rand()%CGI->townh->towns.size();
-			return std::pair<int,int>(98,f); 
+			return std::pair<int,int>(98,f);
 		}
 		}
 	case 162: //random monster lvl5
 	case 162: //random monster lvl5
 		return std::pair<int,int>(54,CGI->creh->levelCreatures[5][rand()%CGI->creh->levelCreatures[5].size()]->idNumber);
 		return std::pair<int,int>(54,CGI->creh->levelCreatures[5][rand()%CGI->creh->levelCreatures[5].size()]->idNumber);
 	case 163: //random monster lvl6
 	case 163: //random monster lvl6
 		return std::pair<int,int>(54,CGI->creh->levelCreatures[6][rand()%CGI->creh->levelCreatures[6].size()]->idNumber);
 		return std::pair<int,int>(54,CGI->creh->levelCreatures[6][rand()%CGI->creh->levelCreatures[6].size()]->idNumber);
 	case 164: //random monster lvl7
 	case 164: //random monster lvl7
-		return std::pair<int,int>(54,CGI->creh->levelCreatures[7][rand()%CGI->creh->levelCreatures[7].size()]->idNumber); 
+		return std::pair<int,int>(54,CGI->creh->levelCreatures[7][rand()%CGI->creh->levelCreatures[7].size()]->idNumber);
 	case 216: //random dwelling
 	case 216: //random dwelling
 		{
 		{
 			int faction = rand()%F_NUMBER;
 			int faction = rand()%F_NUMBER;
@@ -150,9 +150,9 @@ std::pair<int,int> CMapHandler::pickObject(CGObjectInstance *obj)
 			int cid = CGI->townh->towns[faction].basicCreatures[level];
 			int cid = CGI->townh->towns[faction].basicCreatures[level];
 			for(int i=0;i<CGI->objh->cregens.size();i++)
 			for(int i=0;i<CGI->objh->cregens.size();i++)
 				if(CGI->objh->cregens[i]==cid)
 				if(CGI->objh->cregens[i]==cid)
-					return std::pair<int,int>(17,i); 
+					return std::pair<int,int>(17,i);
 			std::cout << "Cannot find a dwelling for creature "<<cid <<std::endl;
 			std::cout << "Cannot find a dwelling for creature "<<cid <<std::endl;
-			return std::pair<int,int>(17,0); 
+			return std::pair<int,int>(17,0);
 		}
 		}
 	case 217:
 	case 217:
 		{
 		{
@@ -187,9 +187,9 @@ std::pair<int,int> CMapHandler::pickObject(CGObjectInstance *obj)
 			int cid = CGI->townh->towns[faction].basicCreatures[obj->subID];
 			int cid = CGI->townh->towns[faction].basicCreatures[obj->subID];
 			for(int i=0;i<CGI->objh->cregens.size();i++)
 			for(int i=0;i<CGI->objh->cregens.size();i++)
 				if(CGI->objh->cregens[i]==cid)
 				if(CGI->objh->cregens[i]==cid)
-					return std::pair<int,int>(17,i); 
+					return std::pair<int,int>(17,i);
 			std::cout << "Cannot find a dwelling for creature "<<cid <<std::endl;
 			std::cout << "Cannot find a dwelling for creature "<<cid <<std::endl;
-			return std::pair<int,int>(17,0); 
+			return std::pair<int,int>(17,0);
 		}
 		}
 	case 218:
 	case 218:
 		{
 		{
@@ -198,15 +198,15 @@ std::pair<int,int> CMapHandler::pickObject(CGObjectInstance *obj)
 			int cid = CGI->townh->towns[obj->subID].basicCreatures[level];
 			int cid = CGI->townh->towns[obj->subID].basicCreatures[level];
 			for(int i=0;i<CGI->objh->cregens.size();i++)
 			for(int i=0;i<CGI->objh->cregens.size();i++)
 				if(CGI->objh->cregens[i]==cid)
 				if(CGI->objh->cregens[i]==cid)
-					return std::pair<int,int>(17,i); 
+					return std::pair<int,int>(17,i);
 			std::cout << "Cannot find a dwelling for creature "<<cid <<std::endl;
 			std::cout << "Cannot find a dwelling for creature "<<cid <<std::endl;
-			return std::pair<int,int>(17,0); 
+			return std::pair<int,int>(17,0);
 		}
 		}
 	}
 	}
 	return std::pair<int,int>(-1,-1);
 	return std::pair<int,int>(-1,-1);
 }
 }
 void CMapHandler::randomizeObject(CGObjectInstance *cur)
 void CMapHandler::randomizeObject(CGObjectInstance *cur)
-{		
+{
 	std::pair<int,int> ran = pickObject(cur);
 	std::pair<int,int> ran = pickObject(cur);
 	if(ran.first<0 || ran.second<0) //this is not a random object, or we couldn't find anything
 	if(ran.first<0 || ran.second<0) //this is not a random object, or we couldn't find anything
 	{
 	{
@@ -218,7 +218,7 @@ void CMapHandler::randomizeObject(CGObjectInstance *cur)
 			else if(t->hasFort())
 			else if(t->hasFort())
 				t->defInfo = CGI->dobjinfo->castles[t->subID];
 				t->defInfo = CGI->dobjinfo->castles[t->subID];
 			else
 			else
-				t->defInfo = villages[t->subID]; 
+				t->defInfo = villages[t->subID];
 			if(!t->defInfo->handler)
 			if(!t->defInfo->handler)
 			{
 			{
 				t->defInfo->handler = CGI->spriteh->giveDef(t->defInfo->name);
 				t->defInfo->handler = CGI->spriteh->giveDef(t->defInfo->name);
@@ -250,7 +250,7 @@ void CMapHandler::randomizeObject(CGObjectInstance *cur)
 		else if(t->hasFort())
 		else if(t->hasFort())
 			t->defInfo = CGI->dobjinfo->castles[t->subID];
 			t->defInfo = CGI->dobjinfo->castles[t->subID];
 		else
 		else
-			t->defInfo = villages[t->subID]; 
+			t->defInfo = villages[t->subID];
 		if(!t->defInfo->handler)
 		if(!t->defInfo->handler)
 		{
 		{
 			t->defInfo->handler = CGI->spriteh->giveDef(t->defInfo->name);
 			t->defInfo->handler = CGI->spriteh->giveDef(t->defInfo->name);
@@ -694,7 +694,7 @@ void CMapHandler::initObjectRects()
 					cr.x = fx<<5; //fx*32
 					cr.x = fx<<5; //fx*32
 					cr.y = fy<<5; //fy*32
 					cr.y = fy<<5; //fy*32
 					std::pair<CGObjectInstance*,SDL_Rect> toAdd = std::make_pair(CGI->objh->objInstances[f],cr);
 					std::pair<CGObjectInstance*,SDL_Rect> toAdd = std::make_pair(CGI->objh->objInstances[f],cr);
-					
+
 					if((CGI->objh->objInstances[f]->pos.x + fx - curd->ourImages[0].bitmap->w/32+1)>=0 && (CGI->objh->objInstances[f]->pos.x + fx - curd->ourImages[0].bitmap->w/32+1)<ttiles.size()-Woff && (CGI->objh->objInstances[f]->pos.y + fy - curd->ourImages[0].bitmap->h/32+1)>=0 && (CGI->objh->objInstances[f]->pos.y + fy - curd->ourImages[0].bitmap->h/32+1)<ttiles[0].size()-Hoff)
 					if((CGI->objh->objInstances[f]->pos.x + fx - curd->ourImages[0].bitmap->w/32+1)>=0 && (CGI->objh->objInstances[f]->pos.x + fx - curd->ourImages[0].bitmap->w/32+1)<ttiles.size()-Woff && (CGI->objh->objInstances[f]->pos.y + fy - curd->ourImages[0].bitmap->h/32+1)>=0 && (CGI->objh->objInstances[f]->pos.y + fy - curd->ourImages[0].bitmap->h/32+1)<ttiles[0].size()-Hoff)
 					{
 					{
 						//TerrainTile2 & curt =
 						//TerrainTile2 & curt =
@@ -762,7 +762,7 @@ void CMapHandler::init()
 		else
 		else
 			capitols[i%ccc]=n;
 			capitols[i%ccc]=n;
 		alphaTransformDef(n);
 		alphaTransformDef(n);
-	} 
+	}
 
 
 	for(int i=0;i<CGI->scenarioOps.playerInfos.size();i++)
 	for(int i=0;i<CGI->scenarioOps.playerInfos.size();i++)
 	{
 	{
@@ -1007,7 +1007,7 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
 					//setting appropriate flag color
 					//setting appropriate flag color
 					if((ttiles[x+bx][y+by][level].objects[h].first->tempOwner>=0 && ttiles[x+bx][y+by][level].objects[h].first->tempOwner<8) || ttiles[x+bx][y+by][level].objects[h].first->tempOwner==255)
 					if((ttiles[x+bx][y+by][level].objects[h].first->tempOwner>=0 && ttiles[x+bx][y+by][level].objects[h].first->tempOwner<8) || ttiles[x+bx][y+by][level].objects[h].first->tempOwner==255)
 						CSDL_Ext::setPlayerColor(ttiles[x+bx][y+by][level].objects[h].first->defInfo->handler->ourImages[(anim+phaseShift)%imgVal].bitmap, ttiles[x+bx][y+by][level].objects[h].first->tempOwner);
 						CSDL_Ext::setPlayerColor(ttiles[x+bx][y+by][level].objects[h].first->defInfo->handler->ourImages[(anim+phaseShift)%imgVal].bitmap, ttiles[x+bx][y+by][level].objects[h].first->tempOwner);
-					
+
 					CSDL_Ext::blit8bppAlphaTo24bpp(ttiles[x+bx][y+by][level].objects[h].first->defInfo->handler->ourImages[(anim+phaseShift)%imgVal].bitmap,&pp,su,&sr);
 					CSDL_Ext::blit8bppAlphaTo24bpp(ttiles[x+bx][y+by][level].objects[h].first->defInfo->handler->ourImages[(anim+phaseShift)%imgVal].bitmap,&pp,su,&sr);
 				}
 				}
 			}
 			}
@@ -1024,7 +1024,7 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
 			sr.x=bx*32;
 			sr.x=bx*32;
 			sr.h=sr.w=32;
 			sr.h=sr.w=32;
 			validateRectTerr(&sr, extRect);
 			validateRectTerr(&sr, extRect);
-			
+
 			if(bx+x>=0 && by+y>=0 && bx+x<CGI->mh->reader->map.width && by+y<CGI->mh->reader->map.height && !visibilityMap[bx+x][by+y][level])
 			if(bx+x>=0 && by+y>=0 && bx+x<CGI->mh->reader->map.width && by+y<CGI->mh->reader->map.height && !visibilityMap[bx+x][by+y][level])
 			{
 			{
 				SDL_Surface * hide = getVisBitmap(bx+x, by+y, visibilityMap, level);
 				SDL_Surface * hide = getVisBitmap(bx+x, by+y, visibilityMap, level);
@@ -1048,7 +1048,7 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
 
 
 				SDL_BlitSurface(ttiles[x+bx][y+by][level].terbitmap[anim%ttiles[x+bx][y+by][level].terbitmap.size()],&genRect(sr.h, sr.w, 0, 0),su,&sr);
 				SDL_BlitSurface(ttiles[x+bx][y+by][level].terbitmap[anim%ttiles[x+bx][y+by][level].terbitmap.size()],&genRect(sr.h, sr.w, 0, 0),su,&sr);
 			}
 			}
-			else 
+			else
 			{
 			{
 				if(MARK_BLOCKED_POSITIONS &&  ttiles[x+bx][y+by][level].blocked) //temporary hiding blocked positions
 				if(MARK_BLOCKED_POSITIONS &&  ttiles[x+bx][y+by][level].blocked) //temporary hiding blocked positions
 				{
 				{
@@ -1473,7 +1473,11 @@ std::string CMapHandler::getDefName(int id, int subid)
 	CGDefInfo* temp = CGI->dobjinfo->gobjs[id][subid];
 	CGDefInfo* temp = CGI->dobjinfo->gobjs[id][subid];
 	if(temp)
 	if(temp)
 		return temp->name;
 		return temp->name;
+#ifndef __GNUC__
 	throw new std::exception("Def not found.");
 	throw new std::exception("Def not found.");
+#else
+	throw new std::exception();
+#endif
 }
 }
 
 
 bool CMapHandler::printObject(CGObjectInstance *obj)
 bool CMapHandler::printObject(CGObjectInstance *obj)
@@ -1491,7 +1495,7 @@ bool CMapHandler::printObject(CGObjectInstance *obj)
 			std::pair<CGObjectInstance*,SDL_Rect> toAdd = std::make_pair(obj, cr);
 			std::pair<CGObjectInstance*,SDL_Rect> toAdd = std::make_pair(obj, cr);
 			if((obj->pos.x + fx - curd->ourImages[0].bitmap->w/32+1)>=0 && (obj->pos.x + fx - curd->ourImages[0].bitmap->w/32+1)<ttiles.size()-Woff && (obj->pos.y + fy - curd->ourImages[0].bitmap->h/32+1)>=0 && (obj->pos.y + fy - curd->ourImages[0].bitmap->h/32+1)<ttiles[0].size()-Hoff)
 			if((obj->pos.x + fx - curd->ourImages[0].bitmap->w/32+1)>=0 && (obj->pos.x + fx - curd->ourImages[0].bitmap->w/32+1)<ttiles.size()-Woff && (obj->pos.y + fy - curd->ourImages[0].bitmap->h/32+1)>=0 && (obj->pos.y + fy - curd->ourImages[0].bitmap->h/32+1)<ttiles[0].size()-Hoff)
 			{
 			{
-				TerrainTile2 & curt = 
+				TerrainTile2 & curt =
 					ttiles
 					ttiles
 					  [obj->pos.x + fx - curd->ourImages[0].bitmap->w/32]
 					  [obj->pos.x + fx - curd->ourImages[0].bitmap->w/32]
 				      [obj->pos.y + fy - curd->ourImages[0].bitmap->h/32]
 				      [obj->pos.y + fy - curd->ourImages[0].bitmap->h/32]
@@ -1581,7 +1585,8 @@ bool CMapHandler::recalculateHideVisPosUnderObj(CGObjectInstance *obj, bool with
 			{
 			{
 				if((obj->pos.x + fx - obj->defInfo->handler->ourImages[0].bitmap->w/32+1)>=0 && (obj->pos.x + fx - obj->defInfo->handler->ourImages[0].bitmap->w/32+1)<ttiles.size()-Woff && (obj->pos.y + fy - obj->defInfo->handler->ourImages[0].bitmap->h/32+1)>=0 && (obj->pos.y + fy - obj->defInfo->handler->ourImages[0].bitmap->h/32+1)<ttiles[0].size()-Hoff)
 				if((obj->pos.x + fx - obj->defInfo->handler->ourImages[0].bitmap->w/32+1)>=0 && (obj->pos.x + fx - obj->defInfo->handler->ourImages[0].bitmap->w/32+1)<ttiles.size()-Woff && (obj->pos.y + fy - obj->defInfo->handler->ourImages[0].bitmap->h/32+1)>=0 && (obj->pos.y + fy - obj->defInfo->handler->ourImages[0].bitmap->h/32+1)<ttiles[0].size()-Hoff)
 				{
 				{
-					recalculateHideVisPos(int3(obj->pos.x + fx - obj->defInfo->handler->ourImages[0].bitmap->w/32 +1, obj->pos.y + fy - obj->defInfo->handler->ourImages[0].bitmap->h/32 + 1, obj->pos.z));
+					int3 tempPos = int3(obj->pos.x + fx - obj->defInfo->handler->ourImages[0].bitmap->w/32 +1, obj->pos.y + fy - obj->defInfo->handler->ourImages[0].bitmap->h/32 + 1, obj->pos.z);
+					recalculateHideVisPos(tempPos);
 				}
 				}
 			}
 			}
 		}
 		}
@@ -1594,7 +1599,8 @@ bool CMapHandler::recalculateHideVisPosUnderObj(CGObjectInstance *obj, bool with
 			{
 			{
 				if((obj->pos.x + fx - obj->defInfo->handler->ourImages[0].bitmap->w/32+1)>=0 && (obj->pos.x + fx - obj->defInfo->handler->ourImages[0].bitmap->w/32+1)<ttiles.size()-Woff && (obj->pos.y + fy - obj->defInfo->handler->ourImages[0].bitmap->h/32+1)>=0 && (obj->pos.y + fy - obj->defInfo->handler->ourImages[0].bitmap->h/32+1)<ttiles[0].size()-Hoff)
 				if((obj->pos.x + fx - obj->defInfo->handler->ourImages[0].bitmap->w/32+1)>=0 && (obj->pos.x + fx - obj->defInfo->handler->ourImages[0].bitmap->w/32+1)<ttiles.size()-Woff && (obj->pos.y + fy - obj->defInfo->handler->ourImages[0].bitmap->h/32+1)>=0 && (obj->pos.y + fy - obj->defInfo->handler->ourImages[0].bitmap->h/32+1)<ttiles[0].size()-Hoff)
 				{
 				{
-					recalculateHideVisPos(int3(obj->pos.x + fx - obj->defInfo->handler->ourImages[0].bitmap->w/32 +1, obj->pos.y + fy - obj->defInfo->handler->ourImages[0].bitmap->h/32 + 1, obj->pos.z));
+					int3 tempPos = int3(obj->pos.x + fx - obj->defInfo->handler->ourImages[0].bitmap->w/32 +1, obj->pos.y + fy - obj->defInfo->handler->ourImages[0].bitmap->h/32 + 1, obj->pos.z);
+					recalculateHideVisPos(tempPos);
 				}
 				}
 			}
 			}
 		}
 		}

+ 6 - 6
mapHandler.h

@@ -1,15 +1,15 @@
 #ifndef MAPHANDLER_H
 #ifndef MAPHANDLER_H
 #define MAPHANDLER_H
 #define MAPHANDLER_H
 
 
-#include "hch\CAmbarCendamo.h"
-#include "hch\CSemiDefHandler.h"
+#include "hch/CAmbarCendamo.h"
+#include "hch/CSemiDefHandler.h"
 #include "CGameInfo.h"
 #include "CGameInfo.h"
-#include "hch\CDefHandler.h"
+#include "hch/CDefHandler.h"
 #include <boost/logic/tribool.hpp>
 #include <boost/logic/tribool.hpp>
-#include "hch\CObjectHandler.h"
+#include "hch/CObjectHandler.h"
 #include <list>
 #include <list>
 const int Woff = 12; //width of map's frame
 const int Woff = 12; //width of map's frame
-const int Hoff = 8; 
+const int Hoff = 8;
 
 
 struct TerrainTile2
 struct TerrainTile2
 {
 {
@@ -114,4 +114,4 @@ public:
 
 
 };
 };
 
 
-#endif //MAPHANDLER_H
+#endif //MAPHANDLER_H

+ 29 - 24
nodrze.h

@@ -6,9 +6,12 @@
 //ignore comment above, it is simply TowDragon's envy. Everything (without removing) is working fine
 //ignore comment above, it is simply TowDragon's envy. Everything (without removing) is working fine
 
 
 #include <iostream>
 #include <iostream>
+#include <fstream>
 #include <string>
 #include <string>
 #include <vector>
 #include <vector>
 
 
+#define CLOG(x)
+
 const bool CZERWONY=true, CZARNY=false;
 const bool CZERWONY=true, CZARNY=false;
 template <typename T>  class wezel
 template <typename T>  class wezel
 {
 {
@@ -82,7 +85,7 @@ public:
 		ktory=0;
 		ktory=0;
 	};
 	};
 	T * begin () {return minimumimum();}; //first element (=minimum)
 	T * begin () {return minimumimum();}; //first element (=minimum)
-	T * end () {return NIL;}; // 
+	T * end () {return NIL;}; //
 	void clear(); // czysci az do korzenia wlacznie
 	void clear(); // czysci az do korzenia wlacznie
 				// removes all elements, including root
 				// removes all elements, including root
 	void usun (T co); // usuwa element z drzewa
 	void usun (T co); // usuwa element z drzewa
@@ -140,7 +143,7 @@ template <typename T> void nodrze<T>::wypisuj(wezel<T> * w, std::ostream & strum
 	if (w==NIL) return;
 	if (w==NIL) return;
 	wypisuj(w->lewy, strum);
 	wypisuj(w->lewy, strum);
 
 
-	strum << "Informacje o wezle: "<<flush<<w<<flush;
+	strum << "Informacje o wezle: "<<std::flush<<w<<std::flush;
 	if (w->ojciec!=NIL)
 	if (w->ojciec!=NIL)
 		strum <<"\n\tOjciec: "<<(w->ojciec)<<" - "<<*(w->ojciec->zawart);
 		strum <<"\n\tOjciec: "<<(w->ojciec)<<" - "<<*(w->ojciec->zawart);
 	else strum <<"\n\tOjciec: NIL";
 	else strum <<"\n\tOjciec: NIL";
@@ -159,7 +162,7 @@ template <typename T> void nodrze<T>::wypisujPre(wezel<T> * w, std::ostream & st
 {
 {
 	if (w==NIL) return;
 	if (w==NIL) return;
 
 
-	strum << "Informacje o wezle: "<<flush<<w<<flush;
+	strum << "Informacje o wezle: "<<std::flush<<w<<std::flush;
 	if (w->ojciec!=NIL)
 	if (w->ojciec!=NIL)
 		strum <<"\n\tOjciec: "<<(w->ojciec)<<" - "<<*(w->ojciec->zawart);
 		strum <<"\n\tOjciec: "<<(w->ojciec)<<" - "<<*(w->ojciec->zawart);
 	else strum <<"\n\tOjciec: NIL";
 	else strum <<"\n\tOjciec: NIL";
@@ -179,14 +182,16 @@ template <typename T> void nodrze<T>::wypiszObficie(std::ostream & strum)
 {
 {
 	strum << "Nodrze " <<this<<" ma " << ile << " elementów."<<std::endl;
 	strum << "Nodrze " <<this<<" ma " << ile << " elementów."<<std::endl;
 	strum << "NIL to " << NIL <<std::endl;
 	strum << "NIL to " << NIL <<std::endl;
-	strum << "Ostatnio bralismy "<<ktory<<flush<<" element, czyli "<<" ("<<ostatnio<<")"<<flush<<*ostatnio<<flush<<std::endl;
+	strum << "Ostatnio bralismy "<<ktory<<std::flush<<" element, czyli "<<" ("<<ostatnio<<")"<<std::flush<<*ostatnio<<std::flush<<std::endl;
 	strum << "Nasze wezly in-order"<<std::endl;
 	strum << "Nasze wezly in-order"<<std::endl;
 	wypisujPre(korzen,strum);
 	wypisujPre(korzen,strum);
 };
 };
 template <typename T, class X> T* operator%(nodrze<T> & drzewko, X co)
 template <typename T, class X> T* operator%(nodrze<T> & drzewko, X co)
 {
 {
 	CLOG ("Szukam " <<co <<std::endl);
 	CLOG ("Szukam " <<co <<std::endl);
+#ifndef __amigaos4__
 	drzewko.wypiszObficie(*C->gl->loguj);
 	drzewko.wypiszObficie(*C->gl->loguj);
+#endif
 	wezel<T> * w = drzewko.korzen;
 	wezel<T> * w = drzewko.korzen;
 	while (w!=drzewko.NIL && (*w->zawart)!=co)
 	while (w!=drzewko.NIL && (*w->zawart)!=co)
 	{
 	{
@@ -494,10 +499,10 @@ template <typename T> void nodrze<T>::naprawUsun (wezel<T> * x)
 	wezel<T> *w;
 	wezel<T> *w;
 	while ( (x != korzen)  &&  (x->kolor == CZARNY) )
 	while ( (x != korzen)  &&  (x->kolor == CZARNY) )
 	{
 	{
-		CLOG("6... "<<flush);
+		CLOG("6... "<<std::flush);
 		if (x == x->ojciec->lewy)
 		if (x == x->ojciec->lewy)
 		{
 		{
-			CLOG("7... "<<flush);
+			CLOG("7... "<<std::flush);
 			w = x->ojciec->prawy;
 			w = x->ojciec->prawy;
 			if (w->kolor == CZERWONY)
 			if (w->kolor == CZERWONY)
 			{
 			{
@@ -506,38 +511,38 @@ template <typename T> void nodrze<T>::naprawUsun (wezel<T> * x)
 				rotacjaLewa(x->ojciec);
 				rotacjaLewa(x->ojciec);
 				w = x->ojciec->prawy;
 				w = x->ojciec->prawy;
 			}
 			}
-			CLOG("8... "<<flush);
+			CLOG("8... "<<std::flush);
 			if ( (w->lewy->kolor == CZARNY)  &&  (w->prawy->kolor == CZARNY) )
 			if ( (w->lewy->kolor == CZARNY)  &&  (w->prawy->kolor == CZARNY) )
 			{
 			{
-				CLOG("8,1... "<<flush);
+				CLOG("8,1... "<<std::flush);
 				w->kolor = CZERWONY;
 				w->kolor = CZERWONY;
 				x = x->ojciec;
 				x = x->ojciec;
 			}
 			}
 			else
 			else
 			{
 			{
-				CLOG("9... "<<flush);
+				CLOG("9... "<<std::flush);
 				if (w->prawy->kolor == CZARNY)
 				if (w->prawy->kolor == CZARNY)
 				{
 				{
-					CLOG("9,1... "<<flush);
+					CLOG("9,1... "<<std::flush);
 					w->lewy->kolor = CZARNY;
 					w->lewy->kolor = CZARNY;
 					w->kolor = CZERWONY;
 					w->kolor = CZERWONY;
 					rotacjaPrawa(w);
 					rotacjaPrawa(w);
 					w = x->ojciec->prawy;
 					w = x->ojciec->prawy;
-					CLOG("9,2... "<<flush);
+					CLOG("9,2... "<<std::flush);
 				}
 				}
-				CLOG("9,3... "<<flush);
+				CLOG("9,3... "<<std::flush);
 				w->kolor = x->ojciec->kolor;
 				w->kolor = x->ojciec->kolor;
 				x->ojciec->kolor = CZARNY;
 				x->ojciec->kolor = CZARNY;
 				w->prawy->kolor = CZARNY;
 				w->prawy->kolor = CZARNY;
 				rotacjaLewa(x->ojciec);
 				rotacjaLewa(x->ojciec);
 				x=korzen;
 				x=korzen;
-				CLOG("9,4... "<<flush);
-				
+				CLOG("9,4... "<<std::flush);
+
 			}
 			}
 		}
 		}
 		else
 		else
 		{
 		{
-			CLOG("10... "<<flush);
+			CLOG("10... "<<std::flush);
 			w = x->ojciec->lewy;
 			w = x->ojciec->lewy;
 			if (w->kolor == CZERWONY)
 			if (w->kolor == CZERWONY)
 			{
 			{
@@ -546,7 +551,7 @@ template <typename T> void nodrze<T>::naprawUsun (wezel<T> * x)
 				rotacjaPrawa(x->ojciec);
 				rotacjaPrawa(x->ojciec);
 				w = x->ojciec->lewy;
 				w = x->ojciec->lewy;
 			}
 			}
-			CLOG("11... "<<flush);
+			CLOG("11... "<<std::flush);
 			if ( (w->lewy->kolor == CZARNY)  &&  (w->prawy->kolor == CZARNY) )
 			if ( (w->lewy->kolor == CZARNY)  &&  (w->prawy->kolor == CZARNY) )
 			{
 			{
 				w->kolor = CZERWONY;
 				w->kolor = CZERWONY;
@@ -566,12 +571,12 @@ template <typename T> void nodrze<T>::naprawUsun (wezel<T> * x)
 				w->lewy->kolor = CZARNY;
 				w->lewy->kolor = CZARNY;
 				rotacjaPrawa(x->ojciec);
 				rotacjaPrawa(x->ojciec);
 				x=korzen;
 				x=korzen;
-				CLOG("12... "<<flush);
+				CLOG("12... "<<std::flush);
 			}
 			}
 		}
 		}
 	}
 	}
 	x->kolor = CZARNY;
 	x->kolor = CZARNY;
-	CLOG("13... "<<flush);
+	CLOG("13... "<<std::flush);
 };
 };
 template <typename T> wezel<T> * nodrze<T>::usunRBT (wezel<T> * nowy)
 template <typename T> wezel<T> * nodrze<T>::usunRBT (wezel<T> * nowy)
 {
 {
@@ -597,27 +602,27 @@ template <typename T> wezel<T> * nodrze<T>::usunRBT (wezel<T> * nowy)
 		}
 		}
 		CLOG(*ostatnio->zawart<<std::endl);
 		CLOG(*ostatnio->zawart<<std::endl);
 	}
 	}
-	CLOG("1... "<<flush);
+	CLOG("1... "<<std::flush);
 	wezel<T> *y, *x;
 	wezel<T> *y, *x;
 	if ( (nowy->lewy == NIL)  ||  (nowy->prawy == NIL) )
 	if ( (nowy->lewy == NIL)  ||  (nowy->prawy == NIL) )
 		y=nowy;
 		y=nowy;
 	else y = nastepnik(nowy);
 	else y = nastepnik(nowy);
-	CLOG("2... "<<flush);
+	CLOG("2... "<<std::flush);
 	if (y->lewy != NIL)
 	if (y->lewy != NIL)
 		x = y->lewy;
 		x = y->lewy;
 	else x = y->prawy;
 	else x = y->prawy;
 	x->ojciec = y->ojciec;
 	x->ojciec = y->ojciec;
-	CLOG("3... "<<flush);
+	CLOG("3... "<<std::flush);
 	if (y->ojciec == NIL)
 	if (y->ojciec == NIL)
 		korzen = x;
 		korzen = x;
 	else if (y == y->ojciec->lewy)
 	else if (y == y->ojciec->lewy)
 		y->ojciec->lewy = x;
 		y->ojciec->lewy = x;
 	else
 	else
 		y->ojciec->prawy = x;
 		y->ojciec->prawy = x;
-	CLOG("4... "<<flush);
+	CLOG("4... "<<std::flush);
 	if (y != nowy)
 	if (y != nowy)
 		(*nowy) = (*y); // skopiowanie
 		(*nowy) = (*y); // skopiowanie
-	CLOG("5... "<<flush);
+	CLOG("5... "<<std::flush);
 	if (y->kolor == CZARNY)
 	if (y->kolor == CZARNY)
 		naprawUsun(x);
 		naprawUsun(x);
 	CLOG ("koniec usuwania"<<std::endl);
 	CLOG ("koniec usuwania"<<std::endl);
@@ -904,4 +909,4 @@ template <typename T> void nodrze<T>::pre(std::ostream & strum, wezel<T> * wsk)
 	if (wsk->prawy != NIL)
 	if (wsk->prawy != NIL)
 		pre(strum,wsk->prawy);
 		pre(strum,wsk->prawy);
 };
 };
-#endif //_NODRZE_H
+#endif //_NODRZE_H

+ 4 - 0
stdafx.h

@@ -7,7 +7,11 @@
 
 
 #define WIN32_LEAN_AND_MEAN		// Exclude rarely-used stuff from Windows headers
 #define WIN32_LEAN_AND_MEAN		// Exclude rarely-used stuff from Windows headers
 #include <cstdio>
 #include <cstdio>
+#ifdef _WIN32
 #include <tchar.h>
 #include <tchar.h>
+#else
+#include "tchar_amigaos4.h"
+#endif
 #include <string>
 #include <string>
 #include <vector>
 #include <vector>
 #include <algorithm>
 #include <algorithm>

+ 235 - 0
tchar_amigaos4.h

@@ -0,0 +1,235 @@
+/*
+ * tchar.h
+ *
+ * Unicode mapping layer for the standard C library. By including this
+ * file and using the 't' names for string functions
+ * (eg. _tprintf) you can make code which can be easily adapted to both
+ * Unicode and non-unicode environments. In a unicode enabled compile define
+ * _UNICODE before including tchar.h, otherwise the standard non-unicode
+ * library functions will be used.
+ *
+ * Note that you still need to include string.h or stdlib.h etc. to define
+ * the appropriate functions. Also note that there are several defines
+ * included for non-ANSI functions which are commonly available (but using
+ * the convention of prepending an underscore to non-ANSI library function
+ * names).
+ *
+ * This file is part of the Mingw32 package.
+ *
+ * Contributors:
+ *  Created by Colin Peters <[email protected]>
+ *
+ *  THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ *  This source code is offered for use in the public domain. You may
+ *  use, modify or distribute it freely.
+ *
+ *  This code is distributed in the hope that it will be useful but
+ *  WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ *  DISCLAMED. This includes but is not limited to warranties of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * $Revision: 1.1.1.1 $
+ * $Author: brandon6684 $
+ * $Date: 2001/12/18 22:54:08 $
+ *
+ */
+
+#ifndef	_TCHAR_H_
+#define _TCHAR_H_
+
+/*
+ * NOTE: This tests _UNICODE, which is different from the UNICODE define
+ *       used to differentiate Win32 API calls.
+ */
+#ifdef	_UNICODE
+
+
+/*
+ * Use TCHAR instead of char or wchar_t. It will be appropriately translated
+ * if _UNICODE is correctly defined (or not).
+ */
+#ifndef _TCHAR_DEFINED
+#ifndef RC_INVOKED
+typedef	wchar_t	TCHAR;
+#endif	/* Not RC_INVOKED */
+#define _TCHAR_DEFINED
+#endif
+
+
+/*
+ * Enclose constant strings and literal characters in the _TEXT and _T macro to make
+ * them unicode constant strings when _UNICODE is defined.
+ */
+#define	_TEXT(x)	L ## x
+#define	_T(x)		L ## x
+
+/*
+ * Unicode functions
+ */
+
+#define	_tprintf		wprintf
+#define	_ftprintf		fwprintf
+#define	_stprintf		swprintf
+#define	_sntprintf	_snwprintf
+#define	_vtprintf		vwprintf
+#define	_vftprintf	vfwprintf
+#define	_vstprintf	vswprintf
+#define	_vsntprintf	_vsnwprintf
+#define	_tscanf		wscanf
+#define	_ftscanf		fwscanf
+#define	_stscanf		swscanf
+#define	_fgettc		fgetwc
+#define	_fgettchar	_fgetwchar
+#define	_fgetts		fgetws
+#define	_fputtc		fputwc
+#define	_fputtchar	_fputwchar
+#define	_fputts		fputws
+#define	_gettc		getwc
+#define	_getts		getws
+#define	_puttc		putwc
+#define	_putts		putws
+#define	_ungettc	ungetwc
+#define	_tcstod		wcstod
+#define	_tcstol		wcstol
+#define	_tcstoul		wcstoul
+#define	_tcscat		wcscat
+#define	_tcschr		wcschr
+#define	_tcscmp		wcscmp
+#define	_tcscpy		wcscpy
+#define	_tcscspn	wcscspn
+#define	_tcslen		wcslen
+#define	_tcsncat		wcsncat
+#define	_tcsncmp	wcsncmp
+#define	_tcsncpy	wcsncpy
+#define	_tcspbrk		wcspbrk
+#define	_tcsrchr		wcsrchr
+#define	_tcsspn		wcsspn
+#define	_tcsstr		wcsstr
+#define	_tcstok		wcstok
+#define	_tcsdup		_wcsdup
+#define	_tcsicmp	_wcsicmp
+#define	_tcsnicmp	_wcsnicmp
+#define	_tcsnset		_wcsnset
+#define	_tcsrev		_wcsrev
+#define	_tcsset		_wcsset
+#define	_tcslwr		_wcslwr
+#define	_tcsupr		_wcsupr
+#define	_tcsxfrm		wcsxfrm
+#define	_tcscoll		wcscoll
+#define	_tcsicoll		_wcsicoll
+#define	_istalpha	iswalpha
+#define	_istupper	iswupper
+#define	_istlower	iswlower
+#define	_istdigit		iswdigit
+#define	_istxdigit	iswxdigit
+#define	_istspace	iswspace
+#define	_istpunct	iswpunct
+#define	_istalnum	iswalnum
+#define	_istprint		iswprint
+#define	_istgraph	iswgraph
+#define	_istcntrl		iswcntrl
+#define	_istascii		iswascii
+#define	_totupper	towupper
+#define	_totlower	towlower
+#define	_ttoi		_wtoi
+#define	_tcsftime	wcsftime
+
+#else	/* Not _UNICODE */
+
+/*
+ * TCHAR, the type you should use instead of char.
+ */
+#ifndef _TCHAR_DEFINED
+#ifndef RC_INVOKED
+typedef char	TCHAR;
+#endif
+#define _TCHAR_DEFINED
+#endif
+
+/*
+ * Enclose constant strings and characters in the _TEXT and _T macro.
+ */
+#define	_TEXT(x)	x
+#define	_T(x)		x
+
+
+/*
+ * Non-unicode (standard) functions
+ */
+
+#define	_tprintf	printf
+#define _ftprintf	fprintf
+#define	_stprintf	sprintf
+#define	_sntprintf	_snprintf
+#define	_vtprintf	vprintf
+#define	_vftprintf	vfprintf
+#define _vstprintf	vsprintf
+#define	_vsntprintf	_vsnprintf
+#define	_tscanf		scanf
+#define	_ftscanf	fscanf
+#define	_stscanf	sscanf
+#define	_fgettc		fgetc
+#define	_fgettchar	_fgetchar
+#define	_fgetts		fgets
+#define	_fputtc		fputc
+#define	_fputtchar	_fputchar
+#define	_fputts		fputs
+#define	_gettc		getc
+#define	_getts		gets
+#define	_puttc		putc
+#define	_putts		puts
+#define	_ungettc	ungetc
+#define	_tcstod		strtod
+#define	_tcstol		strtol
+#define _tcstoul	strtoul
+#define	_tcscat		strcat
+#define _tcschr		strchr
+#define _tcscmp		strcmp
+#define _tcscpy		strcpy
+#define _tcscspn	strcspn
+#define	_tcslen		strlen
+#define	_tcsncat	strncat
+#define	_tcsncmp	strncmp
+#define	_tcsncpy	strncpy
+#define	_tcspbrk	strpbrk
+#define	_tcsrchr	strrchr
+#define _tcsspn		strspn
+#define	_tcsstr		strstr
+#define _tcstok		strtok
+#define	_tcsdup		_strdup
+#define	_tcsicmp	_stricmp
+#define	_tcsnicmp	_strnicmp
+#define	_tcsnset	_strnset
+#define	_tcsrev		_strrev
+#define _tcsset		_strset
+#define	_tcslwr		_strlwr
+#define	_tcsupr		_strupr
+#define	_tcsxfrm	strxfrm
+#define	_tcscoll	strcoll
+#define	_tcsicoll	_stricoll
+#define	_istalpha	isalpha
+#define	_istupper	isupper
+#define	_istlower	islower
+#define	_istdigit	isdigit
+#define	_istxdigit	isxdigit
+#define	_istspace	isspace
+#define	_istpunct	ispunct
+#define	_istalnum	isalnum
+#define	_istprint	isprint
+#define	_istgraph	isgraph
+#define	_istcntrl	iscntrl
+#define	_istascii	isascii
+#define _totupper	toupper
+#define	_totlower	tolower
+#define	_ttoi		atoi
+#define _tcsftime	strftime
+
+#ifdef __amigaos4__
+#define _TCHAR wchar_t
+#endif
+
+#endif	/* Not _UNICODE */
+
+#endif	/* Not _TCHAR_H_ */
+

+ 1 - 1
timeHandler.h

@@ -13,4 +13,4 @@ public:
 	long memDif(){return mem-clock();};
 	long memDif(){return mem-clock();};
 };
 };
 
 
-#endif //TIMEHANDLER_H
+#endif //TIMEHANDLER_H