From ae279c79c55d5e4efa0ef695a7053a552d1787f2 Mon Sep 17 00:00:00 2001
From: mateuszb <mateuszbaran89@gmail.com>
Date: Sat, 4 Aug 2007 19:01:22 +0000
Subject: [PATCH] * first version of player interface displaying * taking some
 txt files from lods * some minor changes

---
 CAbilityHandler.cpp     |  81 ++---------
 CAbilityHandler.h       |   6 +-
 CAdvmapInterface.cpp    |  55 ++++++-
 CAdvmapInterface.h      |  37 ++++-
 CAmbarCendamo.cpp       |   4 +-
 CArtHandler.cpp         | 308 ++++++++++++----------------------------
 CArtHandler.h           |   4 +-
 CDefObjInfoHandler.cpp  |   5 +-
 CGameInfo.h             |   8 +-
 CGameInterface.cpp      | 213 +++++++++++++++++++++++++--
 CGameInterface.h        |  22 ++-
 CGameState.h            |   5 +-
 CGeneralTextHandler.cpp |  12 ++
 CGeneralTextHandler.h   |   2 +-
 CHeroHandler.cpp        | 224 +++++++----------------------
 CMT.cpp                 |  48 +++----
 StartInfo.h             |   6 +
 global.h                |   6 +-
 18 files changed, 525 insertions(+), 521 deletions(-)

diff --git a/CAbilityHandler.cpp b/CAbilityHandler.cpp
index 76c188c8f..17864ea67 100644
--- a/CAbilityHandler.cpp
+++ b/CAbilityHandler.cpp
@@ -1,81 +1,24 @@
 #include "stdafx.h"
 #include "CAbilityHandler.h"
-
+#include "CGameInfo.h"
+#include "CGeneralTextHandler.h"
 void CAbilityHandler::loadAbilities()
 {
-	std::ifstream inp("H3bitmap.lod\\SSTRAITS.TXT", std::ios::in);
+	std::string buf = CGameInfo::mainObj->bitmaph->getTextFile("SSTRAITS.TXT");
+	int it=0;
 	std::string dump;
-	for(int i=0; i<5; ++i)
+	for(int i=0; i<2; ++i)
 	{
-		inp>>dump;
+		CGeneralTextHandler::loadToIt(dump,buf,it,3);
 	}
-	inp.ignore();
-	while(!inp.eof())
+	for (int i=0; i<SKILL_QUANTITY; i++)
 	{
-		CAbility * nab = new CAbility; //new creature, that will be read
-		std::string base;
-		char * tab = new char[500];
-		int iitBef = 0;
-		int iit = 0;
-		inp.getline(tab, 500);
-		base = std::string(tab);
-		if(base.size()<2) //ended, but some rubbish could still stay end we have something useless
-		{
-			inp.close();
-			return; //add counter
-		}
-		while(base[iit]!='\t')
-		{
-			++iit;
-		}
-		nab->name = base.substr(0, iit);
-		++iit;
-		iitBef=iit;
-
-		nab->basicText = base.substr(iitBef, base.size()-iitBef);
-
-		inp.getline(tab, 500);
-		inp.getline(tab, 500);
-		base = std::string(tab);
-
-		iitBef = 0;
-		iit = 0;
-
-		while(base[iit]!='\t')
-		{
-			++iit;
-		}
-		nab->basicText2 = base.substr(0, iit);
-		++iit;
-		iitBef=iit;
-
-		nab->advText = base.substr(iitBef, base.size()-iitBef);
-
-		inp.getline(tab, 500);
-		inp.getline(tab, 500);
-		base = std::string(tab);
-
-		iitBef = 0;
-		iit = 0;
-
-		while(base[iit]!='\t')
-		{
-			++iit;
-		}
-		nab->advText2 = base.substr(0, iit);
-		++iit;
-		iitBef=iit;
-
-		nab->expText = base.substr(iitBef, base.size()-iitBef);
-
-		inp.getline(tab, 500);
-		inp.getline(tab, 500);
-		base = std::string(tab);
-
-		nab->expText2 = base;
-
+		CAbility * nab = new CAbility; //new skill, that will be read
+		CGeneralTextHandler::loadToIt(nab->name,buf,it,4);
+		CGeneralTextHandler::loadToIt(nab->basicText,buf,it,4);
+		CGeneralTextHandler::loadToIt(nab->advText,buf,it,4);
+		CGeneralTextHandler::loadToIt(nab->expText,buf,it,3);
 		nab->idNumber = abilities.size();
 		abilities.push_back(nab);
-		delete [500] tab;
 	}
 }
\ No newline at end of file
diff --git a/CAbilityHandler.h b/CAbilityHandler.h
index f228bd514..78e0f240d 100644
--- a/CAbilityHandler.h
+++ b/CAbilityHandler.h
@@ -8,9 +8,9 @@ class CAbility
 {
 public:
 	std::string name;
-	std::string basicText, basicText2;
-	std::string advText, advText2;
-	std::string expText, expText2;
+	std::string basicText;
+	std::string advText;
+	std::string expText;
 	int idNumber;
 	bool isAllowed; //true if we can use this hero's ability (map information)
 };
diff --git a/CAdvmapInterface.cpp b/CAdvmapInterface.cpp
index f77afaf17..976282993 100644
--- a/CAdvmapInterface.cpp
+++ b/CAdvmapInterface.cpp
@@ -6,6 +6,18 @@ CAdvMapInt::CAdvMapInt(int Player)
 {
 	bg = CGI->bitmaph->loadBitmap("ADVMAP.bmp");
 	blueToPlayersAdv(bg,player);
+	scrollingLeft = false;
+	scrollingRight  = false;
+	scrollingUp = false ;
+	scrollingDown = false ;
+	updateScreen  = false;
+	anim=0;
+	animValHitCount=0; //animation frame
+	
+	gems.push_back(CGI->spriteh->giveDef("agemLL.def"));
+	gems.push_back(CGI->spriteh->giveDef("agemLR.def"));
+	gems.push_back(CGI->spriteh->giveDef("agemUL.def"));
+	gems.push_back(CGI->spriteh->giveDef("agemUR.def"));
 }
 CAdvMapInt::~CAdvMapInt()
 {
@@ -68,4 +80,45 @@ void CList::deactivate()
 }; 
 void CList::clickLeft(tribool down)
 {
-};
\ No newline at end of file
+};
+
+void CTerrainRect::activate()
+{
+	ClickableL::activate();
+	ClickableR::activate();
+	Hoverable::activate();
+	KeyInterested::activate();
+}; 
+void CTerrainRect::deactivate()
+{
+	ClickableL::deactivate();
+	ClickableR::deactivate();
+	Hoverable::deactivate();
+	KeyInterested::deactivate();
+}; 
+void CTerrainRect::clickLeft(tribool down){}
+void CTerrainRect::clickRight(tribool down){}
+void CTerrainRect::hover(bool on){}
+void CTerrainRect::keyPressed (SDL_KeyboardEvent & key){}
+void CTerrainRect::show()
+{
+	SDL_Surface * teren = CGI->mh->terrainRect
+		(CURPLINT->adventureInt->position.x,CURPLINT->adventureInt->position.y,
+		19,18,CURPLINT->adventureInt->position.z,CURPLINT->adventureInt->anim);
+	SDL_BlitSurface(teren,&genRect(547,594,0,0),ekran,&genRect(547,594,7,6));
+	SDL_FreeSurface(teren);
+}
+void CAdvMapInt::show()
+{
+	blitAt(bg,0,0);
+	SDL_Flip(ekran);
+}
+void CAdvMapInt::update()
+{
+	terrain.show();
+	blitAt(gems[2]->ourImages[CURPLINT->playerID].bitmap,6,6);
+	blitAt(gems[0]->ourImages[CURPLINT->playerID].bitmap,6,508);
+	blitAt(gems[1]->ourImages[CURPLINT->playerID].bitmap,556,508);
+	blitAt(gems[3]->ourImages[CURPLINT->playerID].bitmap,556,6);
+	updateRect(&genRect(550,600,6,6));
+}
\ No newline at end of file
diff --git a/CAdvmapInterface.h b/CAdvmapInterface.h
index d1c94a551..a8d31a772 100644
--- a/CAdvmapInterface.h
+++ b/CAdvmapInterface.h
@@ -71,7 +71,9 @@ class CDataBar
 	void refresh();
 };
 class CStatusBar
+	: public CIntObject
 {
+public:
 	SDL_Surface * bg;
 	std::string current;
 	void print(std::string text);
@@ -79,6 +81,7 @@ class CStatusBar
 class CMinimap
 	: public ClickableL, public ClickableR, public Hoverable, public CIntObject
 {
+public:
 	SDL_Surface * radar; //radar.def
 	SDL_Surface * terrainMap;
 	SDL_Surface * undTerrainMap; //underground
@@ -87,15 +90,41 @@ class CMinimap
 
 	bool underground; 
 
-	int3 position; //top left corner of visible map part
+};
+class CTerrainRect
+	:  public ClickableL, public ClickableR, public Hoverable, public CIntObject, public KeyInterested
+{
+public:
+	void activate(); 
+	void deactivate();
+	void clickLeft(tribool down);
+	void clickRight(tribool down);
+	void hover(bool on);
+	void keyPressed (SDL_KeyboardEvent & key);
+	void show();
 };
 /*****************************/
-class CAdvMapInt : public CGameInterface //adventure map interface
+class CAdvMapInt //adventure map interface
 {
+public:
 	CAdvMapInt(int Player);
 	~CAdvMapInt();
 
+	int3 position; //top left corner of visible map part
 	int player;
+
+	std::vector<CDefHandler *> gems;
+
+	
+	bool scrollingLeft ;
+	bool scrollingRight ;
+	bool scrollingUp ;
+	bool scrollingDown ;
+	bool updateScreen ;
+	unsigned char anim, animValHitCount; //animation frame
+
+
+
 	SDL_Surface * bg;
 	AdventureMapButton kingOverview,//- kingdom overview
 		undeground,//- underground switch
@@ -108,9 +137,13 @@ class CAdvMapInt : public CGameInterface //adventure map interface
 		nextHero, //- next hero
 		endTurn;//- end turn
 	//CHeroList herolist;
+
+	CTerrainRect terrain;
 	
 	void show();
 
+	void update();
+
 
 };
 #endif //CADVENTUREMAPINTERFACE_H
\ No newline at end of file
diff --git a/CAmbarCendamo.cpp b/CAmbarCendamo.cpp
index 643935873..681261f37 100644
--- a/CAmbarCendamo.cpp
+++ b/CAmbarCendamo.cpp
@@ -2499,9 +2499,9 @@ void CAmbarCendamo::processMap(std::vector<std::string> & defsToUnpack)
 					}
 					else
 					{
-						if(CGI->scenarioOps.playerInfos[((CCastleObjInfo*)CGI->objh->objInstances[j].info)->player].castle>-1)
+						if(CGI->scenarioOps.getIthPlayersSettings(((CCastleObjInfo*)CGI->objh->objInstances[j].info)->player).castle>-1)
 						{
-							nxt.bytes[20] = CGI->scenarioOps.playerInfos[((CCastleObjInfo*)CGI->objh->objInstances[j].info)->player].castle;
+							nxt.bytes[20] = CGI->scenarioOps.getIthPlayersSettings(((CCastleObjInfo*)CGI->objh->objInstances[j].info)->player).castle;
 						}
 						else
 						{
diff --git a/CArtHandler.cpp b/CArtHandler.cpp
index 8fdc4e6e4..31b3a4e02 100644
--- a/CArtHandler.cpp
+++ b/CArtHandler.cpp
@@ -1,233 +1,105 @@
 #include "stdafx.h"
 #include "CArtHandler.h"
+#include "CGameInfo.h"
+#include "CGeneralTextHandler.h"
 
 void CArtHandler::loadArtifacts()
 {
-	std::ifstream inp("H3bitmap.lod\\ARTRAITS.TXT", std::ios::in);
+	std::string buf = CGameInfo::mainObj->bitmaph->getTextFile("ARTRAITS.TXT");
+	int it=0;
 	std::string dump;
-	for(int i=0; i<44; ++i)
+	for(int i=0; i<2; ++i)
 	{
-		inp>>dump;
+		CGeneralTextHandler::loadToIt(dump,buf,it,3);
 	}
-	inp.ignore();
-	int numberlet = 0; //numer of artifact
-	while(!inp.eof())
+	for (int i=0; i<ARTIFACTS_QUANTITY; i++)
 	{
 		CArtifact nart;
-		nart.number = numberlet++;
-		char * read = new char[10000]; //here we'll have currently read character
-		inp.getline(read, 10000);
-		int eol=0; //end of looking
-		std::string ss = std::string(read);
-		if(ss==std::string("") && inp.eof())
-		{
-			delete [10000] read;
-			loadArtEvents();
-			return;
-		}
-		for(int i=0; i<200; ++i)
-		{
-			if(ss[i]=='\t')
-			{
-				nart.name = ss.substr(0, i);
-				eol=i+1;
-				break;
-			}
-		}
-		if(nart.name==std::string("-1") || nart.name==std::string("-2"))
-		{
-			artifacts.push_back(nart);
-			continue;
-		}
-		for(int i=eol; i<eol+200; ++i)
-		{
-			if(ss[i]=='\t')
-			{
-				nart.price = atoi(ss.substr(eol, i).c_str());
-				eol=i+1;
-				break;
-			}
-		}
-		if(ss[eol]=='x')
-			nart.spellBook = true;
-		else
-			nart.spellBook = false;
-		if(ss[eol++]!='\t')
-			eol++;
-		if(ss[eol]=='x')
-			nart.warMachine4 = true;
-		else
-			nart.warMachine4 = false;
-		if(ss[eol++]!='\t')
-			eol++;
-		if(ss[eol]=='x')
-			nart.warMachine3 = true;
-		else
-			nart.warMachine3 = false;
-		if(ss[eol++]!='\t')
-			eol++;
-		if(ss[eol]=='x')
-			nart.warMachine2 = true;
-		else
-			nart.warMachine2 = false;
-		if(ss[eol++]!='\t')
-			eol++;
-		if(ss[eol]=='x')
-			nart.warMachine1 = true;
-		else
-			nart.warMachine1 = false;
-		if(ss[eol++]!='\t')
-			eol++;
-		if(ss[eol]=='x')
-			nart.misc5 = true;
-		else
-			nart.misc5 = false;
-		if(ss[eol++]!='\t')
-			eol++;
-		if(ss[eol]=='x')
-			nart.misc4 = true;
-		else
-			nart.misc4 = false;
-		if(ss[eol++]!='\t')
-			eol++;
-		if(ss[eol]=='x')
-			nart.misc3 = true;
-		else
-			nart.misc3 = false;
-		if(ss[eol++]!='\t')
-			eol++;
-		if(ss[eol]=='x')
-			nart.misc2 = true;
-		else
-			nart.misc2 = false;
-		if(ss[eol++]!='\t')
-			eol++;
-		if(ss[eol]=='x')
-			nart.misc1 = true;
-		else
-			nart.misc1 = false;
-		if(ss[eol++]!='\t')
-			eol++;
-		if(ss[eol]=='x')
-			nart.feet = true;
-		else
-			nart.feet = false;
-		if(ss[eol++]!='\t')
-			eol++;
-		if(ss[eol]=='x')
-			nart.lRing = true;
-		else
-			nart.lRing = false;
-		if(ss[eol++]!='\t')
-			eol++;
-		if(ss[eol]=='x')
-			nart.rRing = true;
-		else
-			nart.rRing = false;
-		if(ss[eol++]!='\t')
-			eol++;
-		if(ss[eol]=='x')
-			nart.torso = true;
-		else
-			nart.torso = false;
-		if(ss[eol++]!='\t')
-			eol++;
-		if(ss[eol]=='x')
-			nart.lHand = true;
-		else
-			nart.lHand = false;
-		if(ss[eol++]!='\t')
-			eol++;
-		if(ss[eol]=='x')
-			nart.rHand = true;
-		else
-			nart.rHand = false;
-		if(ss[eol++]!='\t')
-			eol++;
-		if(ss[eol]=='x')
-			nart.neck = true;
-		else
-			nart.neck = false;
-		if(ss[eol++]!='\t')
-			eol++;
-		if(ss[eol]=='x')
-			nart.shoulders = true;
-		else
-			nart.shoulders = false;
-		if(ss[eol++]!='\t')
-			eol++;
-		if(ss[eol]=='x')
-			nart.head = true;
-		else
-			nart.head = false;
-		if(ss[eol++]!='\t')
-			eol++;
-		switch(ss[eol])
-		{
-		case 'J':
-			nart.aClass = EartClass::JartClass;
-			break;
-			
-		case 'N':
-			nart.aClass = EartClass::NartClass;
-			break;
-			
-		case 'R':
-			nart.aClass = EartClass::RartClass;
-			break;
-			
-		case 'S':
-			nart.aClass = EartClass::SartClass;
-			break;
-			
-		case 'T':
-			nart.aClass = EartClass::TartClass;
-			break;
-		}
-		if(ss[eol++]!='\t')
-			eol++;
-		nart.description = ss.substr(eol, ss.size());
-		inp.getline(read, 10000);
-		int bowCounter=0;
-		nart.desc2 = "";
-		do //do - while begin
-		{
-			++bowCounter;
-			inp.getline(read, 10000);
-			//inp.ignore();
-			ss = std::string(read);
-			nart.desc2 += ss;
-		}
-		while(nart.desc2[nart.desc2.size()-1]!='"' ||
-			( (nart.name==std::string("�uk Penetracji")||nart.name==std::string("Bow of Seeking")) && bowCounter<4) ); //do - while end
-		//if(nart.name!=std::string("-1") && nart.name!=std::string("-2"))
-		nart.description += "\n\n";
-		nart.description += nart.desc2;
-		this->artifacts.push_back(nart);
-		delete[10000] read;
-	}
-	loadArtEvents();
-}
+		std::string pom;
+		CGeneralTextHandler::loadToIt(nart.name,buf,it,4);
+		CGeneralTextHandler::loadToIt(pom,buf,it,4);
+		nart.price=atoi(pom.c_str());
 
-bool CArtHandler::loadArtEvents()
-{
-	std::ifstream inp("H3bitmap.lod\\ARTEVENT.TXT", std::ios::in);
-	if(!inp.is_open())
-	{
-		return false;
-	}
-	for(int i=0; i<this->artifacts.size(); ++i)
-	{
-		char * tab = new char[1000];
-		inp.getline(tab, 1000);
-		std::string spo = std::string("\42-1\42");
-		if(std::string(tab).substr(0, std::string(tab).size()-1)==std::string("\42-1\42")
-			|| std::string(tab).substr(0, std::string(tab).size()-1)==std::string("\"-2\""))
+		CGeneralTextHandler::loadToIt(pom,buf,it,4);
+		if (pom.length())
+			nart.spellBook=true;
+		CGeneralTextHandler::loadToIt(pom,buf,it,4);
+		if (pom.length())
+			nart.warMachine4=true;
+		CGeneralTextHandler::loadToIt(pom,buf,it,4);
+		if (pom.length())
+			nart.warMachine3=true;
+		CGeneralTextHandler::loadToIt(pom,buf,it,4);
+		if (pom.length())
+			nart.warMachine2=true;
+		CGeneralTextHandler::loadToIt(pom,buf,it,4);
+		if (pom.length())
+			nart.warMachine1=true;
+		CGeneralTextHandler::loadToIt(pom,buf,it,4);
+		if (pom.length())
+			nart.misc5=true;
+		CGeneralTextHandler::loadToIt(pom,buf,it,4);
+		if (pom.length())
+			nart.misc4=true;
+		CGeneralTextHandler::loadToIt(pom,buf,it,4);
+		if (pom.length())
+			nart.misc3=true;
+		CGeneralTextHandler::loadToIt(pom,buf,it,4);
+		if (pom.length())
+			nart.misc2=true;
+		CGeneralTextHandler::loadToIt(pom,buf,it,4);
+		if (pom.length())
+			nart.misc1=true;
+		CGeneralTextHandler::loadToIt(pom,buf,it,4);
+		if (pom.length())
+			nart.feet=true;
+		CGeneralTextHandler::loadToIt(pom,buf,it,4);
+		if (pom.length())
+			nart.lRing=true;
+		CGeneralTextHandler::loadToIt(pom,buf,it,4);
+		if (pom.length())
+			nart.rRing=true;
+		CGeneralTextHandler::loadToIt(pom,buf,it,4);
+		if (pom.length())
+			nart.torso=true;
+		CGeneralTextHandler::loadToIt(pom,buf,it,4);
+		if (pom.length())
+			nart.lHand=true;
+		CGeneralTextHandler::loadToIt(pom,buf,it,4);
+		if (pom.length())
+			nart.rHand=true;
+		CGeneralTextHandler::loadToIt(pom,buf,it,4);
+		if (pom.length())
+			nart.neck=true;
+		CGeneralTextHandler::loadToIt(pom,buf,it,4);
+		if (pom.length())
+			nart.shoulders=true;
+		CGeneralTextHandler::loadToIt(pom,buf,it,4);
+		if (pom.length())
+			nart.head=true;
+
+		CGeneralTextHandler::loadToIt(pom,buf,it,4);
+		switch (pom[0])
 		{
-			continue;
+		case 'S':
+			nart.aClass=EartClass::SartClass;
+			break;
+		case 'T':
+			nart.aClass=EartClass::TartClass;
+			break;
+		case 'N':
+			nart.aClass=EartClass::NartClass;
+			break;
+		case 'J':
+			nart.aClass=EartClass::JartClass;
+			break;
+		case 'R':
+			nart.aClass=EartClass::RartClass;
+			break;
 		}
-		artifacts[i].eventText = std::string(tab).substr(0, std::string(tab).size()-1);
-		delete[1000] tab;
+		CGeneralTextHandler::loadToIt(nart.description,buf,it,3);
+		nart.id=artifacts.size();
+
+		artifacts.push_back(nart);
 	}
-	return true;
 }
diff --git a/CArtHandler.h b/CArtHandler.h
index 6d8ec884f..17d56b4db 100644
--- a/CArtHandler.h
+++ b/CArtHandler.h
@@ -12,12 +12,12 @@ public:
 	bool isAllowed; //true if we can use this artifact (map information)
 	std::string name;
 	std::string description;
-	std::string desc2;
+	//std::string desc2;
 	std::string eventText;
 	unsigned int price;
 	bool spellBook, warMachine1, warMachine2, warMachine3, warMachine4, misc1, misc2, misc3, misc4, misc5, feet, lRing, rRing, torso, lHand, rHand, neck, shoulders, head;
 	EartClass aClass;
-	int number;
+	int id;
 };
 
 class CArtHandler //handles artifacts
diff --git a/CDefObjInfoHandler.cpp b/CDefObjInfoHandler.cpp
index deef79daf..d9a693b1a 100644
--- a/CDefObjInfoHandler.cpp
+++ b/CDefObjInfoHandler.cpp
@@ -1,5 +1,7 @@
 #include "stdafx.h"
 #include "CDefObjInfoHandler.h"
+#include "CGameInfo.h"
+#include <sstream>
 
 bool DefObjInfo::operator==(const std::string & por) const
 {
@@ -8,7 +10,7 @@ bool DefObjInfo::operator==(const std::string & por) const
 
 void CDefObjInfoHandler::load()
 {
-	std::ifstream inp("H3bitmap.lod\\ZOBJCTS.TXT", std::ios::in | std::ios::binary);
+	std::istringstream inp(CGameInfo::mainObj->bitmaph->getTextFile("ZOBJCTS.TXT"));
 	int objNumber;
 	inp>>objNumber;
 	for(int hh=0; hh<objNumber; ++hh)
@@ -24,5 +26,4 @@ void CDefObjInfoHandler::load()
 		inp>>nobj.priority;
 		objs.push_back(nobj);
 	}
-	inp.close();
 }
diff --git a/CGameInfo.h b/CGameInfo.h
index 50ef55fb1..45aa12b4e 100644
--- a/CGameInfo.h
+++ b/CGameInfo.h
@@ -18,6 +18,8 @@
 #include "CTownHandler.h"
 #include "CGeneralTextHandler.h"
 #include "CGameInterface.h"
+#include "CGameState.h"
+#include "mapHandler.h"
 #include "SDL.h"
 
 #include <vector>
@@ -25,15 +27,19 @@
 	CGameInfo class
 	for allowing different functions for modifying game informations
 */
+
+class CMapHandler;
 class CGameInfo
 {
 public:
 	static CGameInfo * mainObj; //pointer to main CGameInfo object
+	CGameState * state;
 	CArtHandler * arth;
 	CHeroHandler * heroh;
 	CCreatureHandler * creh;
 	CAbilityHandler * abilh;
 	CSpellHandler * spellh;
+	CMapHandler * mh;
 	CAmbarCendamo * ac;
 	CBuildingHandler * buildh;
 	CObjectHandler * objh;
@@ -44,7 +50,7 @@ public:
 	CLodHandler * spriteh;
 	CLodHandler * bitmaph;
 	CGeneralTextHandler * generaltexth;
-	CPlayerInterface * playerint;
+	std::vector<CGameInterface *> playerint;
 	std::vector<SDL_Color> playerColors;
 	SDL_Color neutralColor;
 	StartInfo scenarioOps;
diff --git a/CGameInterface.cpp b/CGameInterface.cpp
index fbb35fdc2..b6dc28fb1 100644
--- a/CGameInterface.cpp
+++ b/CGameInterface.cpp
@@ -1,11 +1,10 @@
 #include "stdafx.h"
 #include "CGameInterface.h"
+#include "CAdvMapInterface.h"
 #include "CMessage.h"
 #include "SDL_Extensions.h"
+#include "SDL_framerate.h"
 using namespace CSDL_Ext;
-
-
-
 CButtonBase::CButtonBase()
 {
 	type=-1;
@@ -30,34 +29,222 @@ void CButtonBase::show()
 }
 void ClickableL::activate()
 {
-	CGI->playerint->lclickable.push_back(this);
+	CURPLINT->lclickable.push_back(this);
 }
 void ClickableL::deactivate()
 {
-	CGI->playerint->lclickable.erase(std::find(CGI->playerint->lclickable.begin(),CGI->playerint->lclickable.end(),this));
+	CURPLINT->lclickable.erase
+		(std::find(CURPLINT->lclickable.begin(),CURPLINT->lclickable.end(),this));
 }
 void ClickableR::activate()
 {
-	CGI->playerint->rclickable.push_back(this);
+	CURPLINT->rclickable.push_back(this);
 }
 void ClickableR::deactivate()
 {
-	CGI->playerint->rclickable.erase(std::find(CGI->playerint->rclickable.begin(),CGI->playerint->rclickable.end(),this));
+	CURPLINT->rclickable.erase(std::find(CURPLINT->rclickable.begin(),CURPLINT->rclickable.end(),this));
 }
 void Hoverable::activate()
 {
-	CGI->playerint->hoverable.push_back(this);
+	CURPLINT->hoverable.push_back(this);
 }
 void Hoverable::deactivate()
 {
-	CGI->playerint->hoverable.erase(std::find(CGI->playerint->hoverable.begin(),CGI->playerint->hoverable.end(),this));
+	CURPLINT->hoverable.erase(std::find(CURPLINT->hoverable.begin(),CURPLINT->hoverable.end(),this));
 }
 void KeyInterested::activate()
 {
-	CGI->playerint->keyinterested.push_back(this);
+	CURPLINT->keyinterested.push_back(this);
 }
 void KeyInterested::deactivate()
 {
-	CGI->playerint->
-		keyinterested.erase(std::find(CGI->playerint->keyinterested.begin(),CGI->playerint->keyinterested.end(),this));
-}
\ No newline at end of file
+	CURPLINT->
+		keyinterested.erase(std::find(CURPLINT->keyinterested.begin(),CURPLINT->keyinterested.end(),this));
+}
+CPlayerInterface::CPlayerInterface(int Player)
+{
+	playerID=Player;
+	human=true;
+	adventureInt = new CAdvMapInt(Player);
+}
+void CPlayerInterface::yourTurn()
+{
+	unsigned char & animVal = CURPLINT->adventureInt->anim; //for animations handling
+	adventureInt->show();
+	//show rest of things
+
+	//initializing framerate keeper
+	FPSmanager * mainLoopFramerateKeeper = new FPSmanager;
+	SDL_initFramerate(mainLoopFramerateKeeper);
+	SDL_setFramerate(mainLoopFramerateKeeper, 30);
+	SDL_Event sEvent;
+	//framerate keeper initialized
+	for(;;) // main loop
+	{
+		
+		CURPLINT->adventureInt->updateScreen = false;
+		if(SDL_PollEvent(&sEvent))  //wait for event...
+		{
+			handleEvent(&sEvent);
+		}
+		++CURPLINT->adventureInt->animValHitCount; //for animations
+		if(CURPLINT->adventureInt->animValHitCount == 2)
+		{
+			CURPLINT->adventureInt->animValHitCount = 0;
+			++animVal;
+			CURPLINT->adventureInt->updateScreen = true;
+
+		}
+		if(CURPLINT->adventureInt->scrollingLeft)
+		{
+			if(CURPLINT->adventureInt->position.x>0)
+			{
+				CURPLINT->adventureInt->position.x--;
+				CURPLINT->adventureInt->updateScreen = true;
+			}
+		}
+		if(CURPLINT->adventureInt->scrollingRight)
+		{
+			if(CURPLINT->adventureInt->position.x<CGI->ac->map.width-19+8)
+			{
+				CURPLINT->adventureInt->position.x++;
+				CURPLINT->adventureInt->updateScreen = true;
+			}
+		}
+		if(CURPLINT->adventureInt->scrollingUp)
+		{
+			if(CURPLINT->adventureInt->position.y>0)
+			{
+				CURPLINT->adventureInt->position.y--;
+				CURPLINT->adventureInt->updateScreen = true;
+			}
+		}
+		if(CURPLINT->adventureInt->scrollingDown)
+		{
+			if(CURPLINT->adventureInt->position.y<CGI->ac->map.height-18+8)
+			{
+				CURPLINT->adventureInt->position.y++;
+				CURPLINT->adventureInt->updateScreen = true;
+			}
+		}
+		if(CURPLINT->adventureInt->updateScreen)
+		{
+			adventureInt->update();
+			CURPLINT->adventureInt->updateScreen=false;
+		}
+		SDL_Delay(5); //give time for other apps
+		SDL_framerateDelay(mainLoopFramerateKeeper);
+	}
+
+
+
+
+}
+
+void CPlayerInterface::handleEvent(SDL_Event *sEvent)
+{
+	if(sEvent->type==SDL_QUIT) 
+		exit(0);
+	else if (sEvent->type==SDL_KEYDOWN)
+	{
+		switch (sEvent->key.keysym.sym)
+		{
+		case SDLK_LEFT:
+			{
+				CURPLINT->adventureInt->scrollingLeft = true;
+				break;
+			}
+		case (SDLK_RIGHT):
+			{
+				CURPLINT->adventureInt->scrollingRight = true;
+				break;
+			}
+		case (SDLK_UP):
+			{
+				CURPLINT->adventureInt->scrollingUp = true;
+				break;
+			}
+		case (SDLK_DOWN):
+			{
+				CURPLINT->adventureInt->scrollingDown = true;
+				break;
+			}
+		case (SDLK_q):
+			{
+				exit(0);
+				break;
+			}
+		case (SDLK_u):
+			{
+				if(!CGI->ac->map.twoLevel)
+					break;
+				if (adventureInt->position.z)
+					adventureInt->position.z--;
+				else adventureInt->position.z++;
+				CURPLINT->adventureInt->updateScreen = true;
+				break;
+			}
+		}
+	} //keydown end
+	else if(sEvent->type==SDL_KEYUP) 
+	{
+		switch (sEvent->key.keysym.sym)
+		{
+		case SDLK_LEFT:
+			{
+				CURPLINT->adventureInt->scrollingLeft = false;
+				break;
+			}
+		case (SDLK_RIGHT):
+			{
+				CURPLINT->adventureInt->scrollingRight = false;
+				break;
+			}
+		case (SDLK_UP):
+			{
+				CURPLINT->adventureInt->scrollingUp = false;
+				break;
+			}
+		case (SDLK_DOWN):
+			{
+				CURPLINT->adventureInt->scrollingDown = false;
+				break;
+			}
+		}
+	}//keyup end
+	else if(sEvent->type==SDL_MOUSEMOTION)
+	{
+		if(sEvent->motion.x<15)
+		{
+			CURPLINT->adventureInt->scrollingLeft = true;
+		}
+		else
+		{
+			CURPLINT->adventureInt->scrollingLeft = false;
+		}
+		if(sEvent->motion.x>ekran->w-15)
+		{
+			CURPLINT->adventureInt->scrollingRight = true;
+		}
+		else
+		{
+			CURPLINT->adventureInt->scrollingRight = false;
+		}
+		if(sEvent->motion.y<15)
+		{
+			CURPLINT->adventureInt->scrollingUp = true;
+		}
+		else
+		{
+			CURPLINT->adventureInt->scrollingUp = false;
+		}
+		if(sEvent->motion.y>ekran->h-15)
+		{
+			CURPLINT->adventureInt->scrollingDown = true;
+		}
+		else
+		{
+			CURPLINT->adventureInt->scrollingDown = false;
+		}
+	}
+} //event end
\ No newline at end of file
diff --git a/CGameInterface.h b/CGameInterface.h
index 4b996661b..313d97f8b 100644
--- a/CGameInterface.h
+++ b/CGameInterface.h
@@ -62,21 +62,31 @@ public:
 };
 class CGameInterface
 {
-};
-class CAICallback : public CGameInterface // callback for AI
-{
-};
+public:
+	bool human;
+	int playerID;
 
-class CPlayerInterface
+	virtual void yourTurn()=0{};
+};
+class CGlobalAI : public CGameInterface // callback for AI
 {
 public:
-	static CAdvMapInt * adventureInt;
+	virtual void yourTurn(){};
+};
+class CPlayerInterface : public CGameInterface
+{
+public:
+	CAdvMapInt * adventureInt;
+	//TODO: town interace, battle interface, other interfaces
 
 	std::vector<ClickableL*> lclickable;
 	std::vector<ClickableR*> rclickable;
 	std::vector<Hoverable*> hoverable;
 	std::vector<KeyInterested*> keyinterested;
 
+	void yourTurn();
 	void handleEvent(SDL_Event * sEvent);
+
+	CPlayerInterface(int Player);
 };
 #endif //CGAMEINTERFACE_H
\ No newline at end of file
diff --git a/CGameState.h b/CGameState.h
index 7b4b9e789..de24ba28a 100644
--- a/CGameState.h
+++ b/CGameState.h
@@ -17,8 +17,9 @@
 
 struct PlayerState
 {
+public:
 	int color;
-	vector<vector<bool> > fogOfWarMap;
+	std::vector<std::vector<std::vector<bool> > >fogOfWarMap;
 	std::vector<int> resources;
 	std::vector<CHeroInstance> heroes;
 	std::vector<CTownInstance> towns;
@@ -26,6 +27,8 @@ struct PlayerState
 
 class CGameState
 {
+public:
+	int currentPlayer;
 	std::map<int,PlayerState> players; //color <-> playerstate
 };
 
diff --git a/CGeneralTextHandler.cpp b/CGeneralTextHandler.cpp
index 7c1e962db..f2972fa61 100644
--- a/CGeneralTextHandler.cpp
+++ b/CGeneralTextHandler.cpp
@@ -253,6 +253,18 @@ void CGeneralTextHandler::loadToIt(std::string &dest, std::string &src, int &ite
 			iter+=2;
 			break;
 		}
+	case 4:
+		{
+			int befi=iter;
+			for(iter; iter<src.size(); ++iter)
+			{
+				if(src[iter]=='\t')
+					break;
+			}
+			dest = src.substr(befi, iter-befi);
+			iter++;
+			break;
+		}
 	}
 }
 
diff --git a/CGeneralTextHandler.h b/CGeneralTextHandler.h
index 20f19c618..94254828b 100644
--- a/CGeneralTextHandler.h
+++ b/CGeneralTextHandler.h
@@ -22,7 +22,7 @@ public:
 	std::string somethingsRiseFromDeath, somethingRisesFormDeath, somethingDiesUnderGaze, somethingsDieUnderGaze, somethingTakesDefensiveStance, somethingsTakeDefensiveStance, somethingExp, nearestTownOccupied, noAvailableTown, heroTooTiredSpell, townGateCannotBeUsed, youHaveNoHeroes, heroHasCastSpell;
 	std::string doYouWishToSaveSomethingsArmy, problemsWithInputDevices, problemsWithSound, problemsWithMouse, problemsWithWindows, abandonedShipyard, spellFailed, somethingPauses, somethingsPause, somethingLevelSomething, somethingStudiedMagic, learnsSpeced, andSpaced, fromSomethingSpaced;*/
 
-	void loadToIt(std::string & dest, std::string & src, int & iter, int mode = 0); //mode 0 - dump to tab, dest to tab, dump to eol //mode 1 - dump to tab, src to eol //mode 2 - copy to tab, dump to eol //mode 3 - copy to eol
+	static void loadToIt(std::string & dest, std::string & src, int & iter, int mode = 0); //mode 0 - dump to tab, dest to tab, dump to eol //mode 1 - dump to tab, src to eol //mode 2 - copy to tab, dump to eol //mode 3 - copy to eol //mode 4 - copy to tab
 	void load();
 };
 
diff --git a/CHeroHandler.cpp b/CHeroHandler.cpp
index e1921b260..82a6a83f7 100644
--- a/CHeroHandler.cpp
+++ b/CHeroHandler.cpp
@@ -2,6 +2,9 @@
 #include "CHeroHandler.h"
 #include "CGameInfo.h"
 #include <sstream>
+#include "CGameInfo.h"
+#include "CGeneralTextHandler.h"
+
 #define CGI (CGameInfo::mainObj)
 
 CHeroHandler::~CHeroHandler()
@@ -31,13 +34,14 @@ void CHeroHandler::loadPortraits()
 void CHeroHandler::loadHeroes()
 {
 	int ID=0;
-	std::ifstream inp("H3bitmap.lod\\HOTRAITS.TXT", std::ios::in);
+	std::string buf = CGameInfo::mainObj->bitmaph->getTextFile("HOTRAITS.TXT");
+	int it=0;
 	std::string dump;
-	for(int i=0; i<25; ++i)
+	for(int i=0; i<2; ++i)
 	{
-		inp>>dump;
+		CGeneralTextHandler::loadToIt(dump,buf,it,3);
 	}
-	inp.ignore();
+
 	int numberOfCurrentClassHeroes = 0;
 	int currentClass = 0;
 	int additHero = 0;
@@ -55,7 +59,8 @@ void CHeroHandler::loadHeroes()
 	addTab[10] = HERO_BARBARIAN;
 	addTab[11] = HERO_DEMONIAC;
 
-	while(!inp.eof())
+	
+	for (int i=0; i<HEROES_QUANTITY; i++)
 	{
 		CHero * nher = new CHero;
 		if(currentClass<18)
@@ -72,196 +77,67 @@ void CHeroHandler::loadHeroes()
 		{
 			nher->heroType = addTab[additHero++];
 		}
-		std::string base;
-		char * tab = new char[500];
-		int iit = 0;
-		inp.getline(tab, 500);
-		base = std::string(tab);
-		if(base.size()<2) //ended, but some rubbish could still stay end we have something useless
-		{
-			loadSpecialAbilities();
-			loadBiographies();
-			loadHeroClasses();
-			initHeroClasses();
-			inp.close();
-			return;
-		}
-		while(base[iit]!='\t')
-		{
-			++iit;
-		}
-		nher->name = base.substr(0, iit);
-		++iit;
-		for(int i=iit; i<iit+100; ++i)
-		{
-			if(base[i]==(char)(10) || base[i]==(char)(9))
-			{
-				nher->low1stack = atoi(base.substr(iit, i).c_str());
-				iit=i+1;
-				break;
-			}
-		}
-		for(int i=iit; i<iit+100; ++i)
-		{
-			if(base[i]==(char)(10) || base[i]==(char)(9))
-			{
-				nher->high1stack = atoi(base.substr(iit, i).c_str());
-				iit=i+1;
-				break;
-			}
-		}
-		int ipom=iit;
-		while(base[ipom]!='\t')
-		{
-			++ipom;
-		}
-		nher->refType1stack = base.substr(iit, ipom-iit);
-		iit=ipom+1;
-		for(int i=iit; i<iit+100; ++i)
-		{
-			if(base[i]==(char)(10) || base[i]==(char)(9))
-			{
-				nher->low2stack = atoi(base.substr(iit, i-iit).c_str());
-				iit=i+1;
-				break;
-			}
-		}
-		for(int i=iit; i<iit+100; ++i)
-		{
-			if(base[i]==(char)(10) || base[i]==(char)(9))
-			{
-				nher->high2stack = atoi(base.substr(iit, i-iit).c_str());
-				iit=i+1;
-				break;
-			}
-		}
-		ipom=iit;
-		while(base[ipom]!='\t')
-		{
-			++ipom;
-		}
-		nher->refType2stack = base.substr(iit, ipom-iit);
-		iit=ipom+1;
-		for(int i=iit; i<iit+100; ++i)
-		{
-			if(base[i]==(char)(10) || base[i]==(char)(9))
-			{
-				nher->low3stack = atoi(base.substr(iit, i-iit).c_str());
-				iit=i+1;
-				break;
-			}
-		}
-		for(int i=iit; i<iit+100; ++i)
-		{
-			if(base[i]==(char)(10) || base[i]==(char)(9))
-			{
-				nher->high3stack = atoi(base.substr(iit, i-iit).c_str());
-				iit=i+1;
-				break;
-			}
-		}
-		nher->refType3stack = base.substr(iit, base.size()-iit);
-		nher->ID=ID++;
+
+		std::string pom ;
+		CGeneralTextHandler::loadToIt(nher->name,buf,it,4);
+
+		CGeneralTextHandler::loadToIt(pom,buf,it,4);
+		nher->low1stack = atoi(pom.c_str());
+		CGeneralTextHandler::loadToIt(pom,buf,it,4);
+		nher->high1stack = atoi(pom.c_str());
+		CGeneralTextHandler::loadToIt(nher->refType1stack,buf,it,4);
+
+		CGeneralTextHandler::loadToIt(pom,buf,it,4);
+		nher->low2stack = atoi(pom.c_str());
+		CGeneralTextHandler::loadToIt(pom,buf,it,4);
+		nher->high2stack = atoi(pom.c_str());
+		CGeneralTextHandler::loadToIt(nher->refType2stack,buf,it,4);
+
+		CGeneralTextHandler::loadToIt(pom,buf,it,4);
+		nher->low3stack = atoi(pom.c_str());
+		CGeneralTextHandler::loadToIt(pom,buf,it,4);
+		nher->high3stack = atoi(pom.c_str());
+		CGeneralTextHandler::loadToIt(nher->refType3stack,buf,it,3);
+	
+		nher->ID = heroes.size();
 		heroes.push_back(nher);
-		delete[500] tab;
 	}
 	loadSpecialAbilities();
+	loadBiographies();
+	loadHeroClasses();
+	initHeroClasses();
+	return;
 
 }
 void CHeroHandler::loadSpecialAbilities()
 {
-	std::ifstream inp("H3bitmap.lod\\HEROSPEC.txt", std::ios::in);
+	std::string buf = CGameInfo::mainObj->bitmaph->getTextFile("HEROSPEC.TXT");
+	int it=0;
 	std::string dump;
-	for(int i=0; i<7; ++i)
+	for(int i=0; i<2; ++i)
 	{
-		inp>>dump;
+		CGeneralTextHandler::loadToIt(dump,buf,it,3);
 	}
-	inp.ignore();
-	int whHero=0;
-	while(!inp.eof() && whHero<heroes.size())
+	for (int i=0;i<heroes.size();i++)
 	{
-		std::string base;
-		char * tab = new char[500];
-		int iitBef = 0;
-		int iit = 0;
-		inp.getline(tab, 500);
-		base = std::string(tab);
-		if(base.size()<2) //ended, but some rubbish could still stay end we have something useless
-		{
-			inp.close();
-			return; //add counter
-		}
-		while(base[iit]!='\t')
-		{
-			++iit;
-		}
-		heroes[whHero]->bonusName = base.substr(0, iit);
-		++iit;
-		iitBef=iit;
-
-		if(heroes[whHero]->bonusName == std::string("Ogry"))
-		{
-			char * tab2 = new char[500];
-			inp.getline(tab2, 500);
-			base += std::string(tab2);
-			delete [500] tab2;
-		}
-
-		while(base[iit]!='\t')
-		{
-			++iit;
-		}
-		heroes[whHero]->shortBonus = base.substr(iitBef, iit-iitBef);
-		++iit;
-		iitBef=iit;
-
-		while(base[iit]!='\t' && iit<base.size())
-		{
-			++iit;
-		}
-		heroes[whHero]->longBonus = base.substr(iitBef, iit-iitBef);
-		++whHero;
-		delete [500] tab;
+		CGeneralTextHandler::loadToIt(heroes[i]->bonusName,buf,it,4);
+		CGeneralTextHandler::loadToIt(heroes[i]->shortBonus,buf,it,4);
+		CGeneralTextHandler::loadToIt(heroes[i]->longBonus,buf,it,3);
 	}
-	inp.close();
 }
 
 void CHeroHandler::loadBiographies()
-{
-	std::ifstream inp("H3bitmap.lod\\HEROBIOS.TXT", std::ios::in | std::ios::binary);
-	inp.seekg(0,std::ios::end); // na koniec
-	int andame = inp.tellg();  // read length
-	inp.seekg(0,std::ios::beg); // wracamy na poczatek
-	char * bufor = new char[andame]; // allocate memory 
-	inp.read((char*)bufor, andame); // read map file to buffer
-	inp.close();
-	std::string buf = std::string(bufor);
-	delete [andame] bufor;
-	int i = 0; //buf iterator
-	for(int q=0; q<heroes.size(); ++q)
+{	
+	std::string buf = CGameInfo::mainObj->bitmaph->getTextFile("HEROBIOS.TXT");
+	int it=0;
+	for (int i=0;i<heroes.size();i++)
 	{
-		int befi=i;
-		for(i; i<andame; ++i)
-		{
-			if(buf[i]=='\r')
-				break;
-		}
-		heroes[q]->biography = buf.substr(befi, i-befi);
-		i+=2;
+		CGeneralTextHandler::loadToIt(heroes[i]->biography,buf,it,3);
 	}
 }
 
 void CHeroHandler::loadHeroClasses()
 {
-	//std::ifstream inp("H3bitmap.lod\\HCTRAITS.TXT", std::ios::in | std::ios::binary);
-	//inp.seekg(0,std::ios::end); // na koniec
-	//int andame = inp.tellg();  // read length
-	//inp.seekg(0,std::ios::beg); // wracamy na poczatek
-	//char * bufor = new char[andame]; // allocate memory 
-	//inp.read((char*)bufor, andame); // read map file to buffer
-	//inp.close();
-	//std::string buf = std::string(bufor);
-	//delete [andame] bufor;
 	std::string buf = CGameInfo::mainObj->bitmaph->getTextFile("HCTRAITS.TXT");
 	int andame = buf.size();
 	for(int y=0; y<andame; ++y)
diff --git a/CMT.cpp b/CMT.cpp
index e59888291..51fc5237c 100644
--- a/CMT.cpp
+++ b/CMT.cpp
@@ -288,30 +288,7 @@ int _tmain(int argc, _TCHAR* argv[])
 		cgi->scenarioOps = cpg->runLoop();
 		THC tmh.getDif();
 
-		//////////////////////////////////////////////////////////////////////////////// lod testing
 
-		//CLodHandler * clod = new CLodHandler;
-		//clod->loadLod("h3abp_bm.lod");
-
-		//CLodHandler * test = new CLodHandler;
-		//test->init(std::string("h3abp_bm.lod"));
-
-		//CDefHandler * tdef = new CDefHandler;
-		//tdef->openDef(std::string("newh3sprite\\AVLSPTR3.DEF"));
-		//tdef->getSprite(0);
-
-		//CLodHandler * bitmapLod = new CLodHandler;
-		//bitmapLod->init(std::string("newH3bitmap.lod"));
-
-		//CPCXConv * tconv = new CPCXConv;
-		//tconv->fromFile(std::string("newh3bitmap\\ADOPBPNL.PCX"));
-		//tconv->convert();
-		//tconv->saveBMP(std::string("tesciczekConva.bmp"));
-
-		//CSemiDefHandler * semek = new CSemiDefHandler;
-		//semek->openDef(std::string("EDG.DEF"), std::string("H3sprite.lod"));
-
-		//////////////////////////////////////////////////////////////////////////////// lod testing end
 
 		cgi->sspriteh = new CSemiLodHandler();
 		cgi->sspriteh->openLod("H3sprite.lod");
@@ -335,8 +312,11 @@ int _tmain(int argc, _TCHAR* argv[])
 		cgi->generaltexth->load();
 		cgi->dobjinfo = new CDefObjInfoHandler;
 		cgi->dobjinfo->load();
-
+		cgi->state = new CGameState();
 		THC std::cout<<"Handlers initailization: "<<tmh.getDif()<<std::endl;
+
+
+
 		std::string mapname;
 		if(CPG->ourScenSel->mapsel.selected==0) CPG->ourScenSel->mapsel.selected = 1; //only for tests
 		if (CPG) mapname = CPG->ourScenSel->mapsel.ourMaps[CPG->ourScenSel->mapsel.selected].filename;
@@ -366,6 +346,7 @@ int _tmain(int argc, _TCHAR* argv[])
 		ac->loadDefs();
 		THC std::cout<<"Reading terrain defs: "<<tmh.getDif()<<std::endl;
 		CMapHandler * mh = new CMapHandler();
+		cgi->mh = mh;
 		mh->reader = ac;
 		THC std::cout<<"Creating mapHandler: "<<tmh.getDif()<<std::endl;
 		mh->init();
@@ -378,6 +359,25 @@ int _tmain(int argc, _TCHAR* argv[])
 		SDL_UpdateRect(ekran, 0, 0, ekran->w, ekran->h);
 		THC std::cout<<"Displaying terrain: "<<tmh.getDif()<<std::endl;
 
+
+
+
+		for (int i=0; i<cgi->scenarioOps.playerInfos.size();i++)
+		{
+			if(cgi->scenarioOps.playerInfos[i].name=="AI")
+				cgi->playerint.push_back(new CGlobalAI());
+			else cgi->playerint.push_back(new CPlayerInterface(cgi->scenarioOps.playerInfos[i].color));
+		}
+
+
+		while(1)
+		{
+			for (int i=0;i<cgi->playerint.size();i++)
+			{
+				cgi->state->currentPlayer=cgi->playerint[i]->playerID;
+				cgi->playerint[i]->yourTurn();
+			}
+		}
 		//SDL_Surface * ss = ac->defs[0]->ourImages[0].bitmap;
 		//SDL_BlitSurface(ss, NULL, ekran, NULL);
 
diff --git a/StartInfo.h b/StartInfo.h
index e9fcc4cc8..ec1c8e333 100644
--- a/StartInfo.h
+++ b/StartInfo.h
@@ -19,6 +19,12 @@ struct StartInfo
 	};
 	std::vector<PlayerSettings> playerInfos;
 	int turnTime; //in minutes, 0=unlimited
+	PlayerSettings & getIthPlayersSettings(int no)
+	{
+		for(int i=0; i<playerInfos.size(); ++i)
+			if(playerInfos[i].color == no)
+				return playerInfos[i];
+	}
 };
 
 #endif
\ No newline at end of file
diff --git a/global.h b/global.h
index cb972a072..697d0b77a 100644
--- a/global.h
+++ b/global.h
@@ -19,11 +19,13 @@ enum ElossCon {lossCastle, lossHero, timeExpires, lossStandard=255};
 enum EHeroClasses {HERO_KNIGHT, HERO_CLERIC, HERO_RANGER, HERO_DRUID, HREO_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};
-
-
+#define CURPLINT (((CPlayerInterface*)(CGI->playerint[CGI->state->currentPlayer]))) //interface of current player (only human)
 const int F_NUMBER = 9; //factions quantity
 const int PLAYER_LIMIT = 8; //player limit per map
 const int HEROES_PER_TYPE=8; //amount of heroes of each type
+const int SKILL_QUANTITY=28;
+const int ARTIFACTS_QUANTITY=171;
+const int HEROES_QUANTITY=156;