Răsfoiți Sursa

Moved objecthandler / minor

Michał W. Urbańczyk 17 ani în urmă
părinte
comite
d251597617

+ 2 - 11
CMT.cpp

@@ -48,17 +48,6 @@
 #include "CAdvmapInterface.h"
 #include "CCastleInterface.h"
 #include "client\Graphics.h"
-#include <boost/lambda/lambda.hpp>
-#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__)
-#  include <fcntl.h>
-#  include <io.h>
-#  define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY)
-#else
-#  define SET_BINARY_MODE(file)
-#endif
-#ifdef _DEBUG
-#endif
-#define CHUNK 16384
 const char * NAME = "VCMI \"Altanatse\" 0.7";
 DLL_EXPORT void initDLL(CLodHandler *b);
 SDL_Color playerColorPalette[256]; //palette to make interface colors good
@@ -214,6 +203,8 @@ void initGameState(Mapa * map, CGameInfo * cgi)
 	for (int i=0;i<map->towns.size();i++)
 	{
 		CGTownInstance * vti =(map->towns[i]);
+		if(!vti->town)
+			vti->town = &CGI->townh->towns[vti->subID];
 		if (vti->name.length()==0) // if town hasn't name we draw it
 			vti->name=vti->town->names[rand()%vti->town->names.size()];
 		if(vti->builtBuildings.find(-50)!=vti->builtBuildings.end()) //give standard set of buildings

+ 37 - 98
client/Graphics.cpp

@@ -171,6 +171,9 @@ void Graphics::loadHeroPortraits()
 }
 void Graphics::loadHeroAnim(std::vector<CDefHandler **> & anims)
 {
+	std::vector<std::pair<int,int> > rotations; //first - group number to be rotated1, second - group number after rotation1
+	rotations += std::make_pair(6,10), std::make_pair(7,11), std::make_pair(8,12), std::make_pair(1,13),
+		std::make_pair(2,14), std::make_pair(3,15);
 	for(int i=0; i<anims.size();i++)
 	{
 		std::stringstream nm;
@@ -181,77 +184,33 @@ void Graphics::loadHeroAnim(std::vector<CDefHandler **> & anims)
 		nm<<"_.DEF";
 		std::string name = nm.str();
 		(*anims[i]) = CDefHandler::giveDef(name);
-		//(CDefHandler*)(((void*)hc)+((void*)moveAnim)) = CDefHandler::giveDef(name);
-		for(int o=0; o<(*anims[i])->ourImages.size(); ++o)
+		int pom = 0; //how many groups has been rotated
+		for(int o=7; pom<6; ++o)
 		{
-			if((*anims[i])->ourImages[o].groupNumber==6)
+			for(int p=0;p<6;p++)
 			{
-				for(int e=0; e<8; ++e)
+				if((*anims[i])->ourImages[o].groupNumber==rotations[p].first)
 				{
-					Cimage nci;
-					nci.bitmap = CSDL_Ext::rotate01((*anims[i])->ourImages[o+e].bitmap);
-					nci.groupNumber = 10;
-					nci.imName = std::string();
-					(*anims[i])->ourImages.push_back(nci);
-				}
-				o+=8;
-			}
-			if((*anims[i])->ourImages[o].groupNumber==7)
-			{
-				for(int e=0; e<8; ++e)
-				{
-					Cimage nci;
-					nci.bitmap = CSDL_Ext::rotate01((*anims[i])->ourImages[o+e].bitmap);
-					nci.groupNumber = 11;
-					nci.imName = std::string();
-					(*anims[i])->ourImages.push_back(nci);
-				}
-				o+=8;
-			}
-			if((*anims[i])->ourImages[o].groupNumber==8)
-			{
-				for(int e=0; e<8; ++e)
-				{
-					Cimage nci;
-					nci.bitmap = CSDL_Ext::rotate01((*anims[i])->ourImages[o+e].bitmap);
-					nci.groupNumber = 12;
-					nci.imName = std::string();
-					(*anims[i])->ourImages.push_back(nci);
+					for(int e=0; e<8; ++e)
+					{
+						Cimage nci;
+						nci.bitmap = CSDL_Ext::rotate01((*anims[i])->ourImages[o+e].bitmap);
+						nci.groupNumber = rotations[p].second;
+						nci.imName = std::string();
+						(*anims[i])->ourImages.push_back(nci);
+						if(pom>2) //we need only one frame for groups 13/14/15
+							break;
+					}
+					if(pom<3) //there are eight frames of animtion of groups 6/7/8 so for speed we'll skip them
+						o+=8;
+					else //there is only one frame of 1/2/3
+						o+=1;
+					++pom;
+					if(p==2 && pom<4) //group1 starts at index 1
+						o = 1;
 				}
-				o+=8;
 			}
 		}
-		for(int o=0; o<(*anims[i])->ourImages.size(); ++o)
-		{
-			if((*anims[i])->ourImages[o].groupNumber==1)
-			{
-				Cimage nci;
-				nci.bitmap = CSDL_Ext::rotate01((*anims[i])->ourImages[o].bitmap);
-				nci.groupNumber = 13;
-				nci.imName = std::string();
-				(*anims[i])->ourImages.push_back(nci);
-				//o+=1;
-			}
-			if((*anims[i])->ourImages[o].groupNumber==2)
-			{
-				Cimage nci;
-				nci.bitmap = CSDL_Ext::rotate01((*anims[i])->ourImages[o].bitmap);
-				nci.groupNumber = 14;
-				nci.imName = std::string();
-				(*anims[i])->ourImages.push_back(nci);
-				//o+=1;
-			}
-			if((*anims[i])->ourImages[o].groupNumber==3)
-			{
-				Cimage nci;
-				nci.bitmap = CSDL_Ext::rotate01((*anims[i])->ourImages[o].bitmap);
-				nci.groupNumber = 15;
-				nci.imName = std::string();
-				(*anims[i])->ourImages.push_back(nci);
-				//o+=1;
-			}
-		}
-
 		for(int ff=0; ff<(*anims[i])->ourImages.size(); ++ff)
 		{
 			CSDL_Ext::alphaTransform((*anims[i])->ourImages[ff].bitmap);
@@ -264,46 +223,26 @@ void Graphics::loadHeroFlags(std::pair<std::vector<CDefHandler *> Graphics::*, s
 {
 	for(int i=0;i<8;i++)
 		(this->*pr.first).push_back(CDefHandler::giveDef(pr.second[i]));
-
+	std::vector<std::pair<int,int> > rotations; //first - group number to be rotated1, second - group number after rotation1
+	rotations += std::make_pair(6,10), std::make_pair(7,11), std::make_pair(8,12);
 	for(int q=0; q<8; ++q)
 	{
 		for(int o=0; o<(this->*pr.first)[q]->ourImages.size(); ++o)
 		{
-			if((this->*pr.first)[q]->ourImages[o].groupNumber==6)
-			{
-				for(int e=0; e<8; ++e)
-				{
-					Cimage nci;
-					nci.bitmap = CSDL_Ext::rotate01((this->*pr.first)[q]->ourImages[o+e].bitmap);
-					nci.groupNumber = 10;
-					nci.imName = std::string();
-					(this->*pr.first)[q]->ourImages.push_back(nci);
-				}
-				o+=8;
-			}
-			if((this->*pr.first)[q]->ourImages[o].groupNumber==7)
-			{
-				for(int e=0; e<8; ++e)
-				{
-					Cimage nci;
-					nci.bitmap = CSDL_Ext::rotate01((this->*pr.first)[q]->ourImages[o+e].bitmap);
-					nci.groupNumber = 11;
-					nci.imName = std::string();
-					(this->*pr.first)[q]->ourImages.push_back(nci);
-				}
-				o+=8;
-			}
-			if((this->*pr.first)[q]->ourImages[o].groupNumber==8)
+			for(int p=0;p<rotations.size();p++)
 			{
-				for(int e=0; e<8; ++e)
+				if((this->*pr.first)[q]->ourImages[o].groupNumber==rotations[p].first)
 				{
-					Cimage nci;
-					nci.bitmap = CSDL_Ext::rotate01((this->*pr.first)[q]->ourImages[o+e].bitmap);
-					nci.groupNumber = 12;
-					nci.imName = std::string();
-					(this->*pr.first)[q]->ourImages.push_back(nci);
+					for(int e=0; e<8; ++e)
+					{
+						Cimage nci;
+						nci.bitmap = CSDL_Ext::rotate01((this->*pr.first)[q]->ourImages[o+e].bitmap);
+						nci.groupNumber = rotations[p].second;
+						nci.imName = std::string();
+						(this->*pr.first)[q]->ourImages.push_back(nci);
+					}
+					o+=8;
 				}
-				o+=8;
 			}
 		}
 		if (mode)

+ 0 - 4
client/VCMI_client.vcproj

@@ -344,10 +344,6 @@
 				RelativePath="..\hch\CMusicHandler.cpp"
 				>
 			</File>
-			<File
-				RelativePath="..\hch\CObjectHandler.cpp"
-				>
-			</File>
 			<File
 				RelativePath="..\CPathfinder.cpp"
 				>

+ 0 - 3
hch/CAmbarCendamo.cpp

@@ -3,9 +3,6 @@
 #include "../CGameInfo.h"
 #include "CObjectHandler.h"
 #include "CDefObjInfoHandler.h"
-#include "../CGameState.h"
-#include "SDL.h"
-#include "CCreatureHandler.h"
 #include <set>
 #include <iomanip>
 #include <sstream>

+ 5 - 0
hch/CArtHandler.cpp

@@ -4,9 +4,14 @@
 #include "CLodHandler.h"
 #include <boost/assign/std/vector.hpp>
 #include <boost/assign/list_of.hpp>
+#include "../lib/VCMI_Lib.h"
 void loadToIt(std::string &dest, std::string &src, int &iter, int mode);
 extern CLodHandler *bitmaph;
 using namespace boost::assign;
+CArtHandler::CArtHandler()
+{
+	VLC->arth = this;
+}
 void CArtHandler::loadArtifacts()
 {
 	std::vector<bool CArtifact::*> slots;

+ 1 - 0
hch/CArtHandler.h

@@ -28,6 +28,7 @@ public:
 	std::vector<CArtifact> artifacts;
 	void loadArtifacts();
 	bool loadArtEvents();
+	CArtHandler();
 };
 
 #endif // CARTHANDLER_H

+ 5 - 0
hch/CCreatureHandler.cpp

@@ -7,7 +7,12 @@
 #include <boost/algorithm/string.hpp>
 #include <boost/algorithm/string/find.hpp>
 #include <boost/algorithm/string/replace.hpp>
+#include "../lib/VCMI_Lib.h"
 extern CLodHandler * bitmaph;
+CCreatureHandler::CCreatureHandler()
+{
+	VLC->creh = this;
+}
 int CCreature::getQuantityID(int quantity)
 {
 	if (quantity<5)

+ 1 - 1
hch/CCreatureHandler.h

@@ -61,6 +61,6 @@ public:
 	void loadCreatures();
 	void loadAnimationInfo();
 	void loadUnitAnimInfo(CCreature & unit, std::string & src, int & i);
-	CCreatureHandler(){};
+	CCreatureHandler();
 };
 #endif //CCREATUREHANDLER_H

+ 1 - 0
hch/CDefObjInfoHandler.h

@@ -16,6 +16,7 @@ public:
 	int id, subid; //of object described by this defInfo
 	int terrainAllowed, //on which terrain it is possible to place object
 		 terrainMenu; //in which menus in map editor object will be showed
+	int width, height; //tiles
 	int type; //(0- ground, 1- towns, 2-creatures, 3- heroes, 4-artifacts, 5- resources)   
 	CDefHandler * handler;
 	int printPriority;

+ 2 - 2
hch/CHeroHandler.h

@@ -8,7 +8,7 @@ class CHeroClass;
 class CDefHandler;
 class CGameInfo;
 class CGHeroInstance;
-class CHero
+class DLL_EXPORT CHero
 {
 public:
 	std::string name;
@@ -23,7 +23,7 @@ public:
 	//bool operator<(CHero& drugi){if (ID < drugi.ID) return true; else return false;}
 };
 
-class CHeroClass
+class DLL_EXPORT CHeroClass
 {
 public:
 	std::string name;

+ 42 - 42
hch/CMusicHandler.cpp

@@ -12,48 +12,48 @@ void CMusicHandler::initMusics()
 	}
 	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");
+	//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");
 	click->volume = 30;

+ 17 - 16
hch/CObjectHandler.cpp

@@ -1,19 +1,20 @@
+#define VCMI_DLL
 #include "../stdafx.h"
 #include "CObjectHandler.h"
 #include "CDefObjInfoHandler.h"
-#include "CDefHandler.h"
-#include "../CGameInfo.h"
 #include "CLodHandler.h"
 #include "CDefObjInfoHandler.h"
 #include "CHeroHandler.h"
 #include <boost/algorithm/string/replace.hpp>
 #include "CTownHandler.h"
 #include "CArtHandler.h"
+#include "../lib/VCMI_Lib.h"
 DLL_EXPORT void loadToIt(std::string &dest, std::string &src, int &iter, int mode);
+extern CLodHandler * bitmaph;
 void CObjectHandler::loadObjects()
 {
 	int ID=0;
-	std::string buf = CGI->bitmaph->getTextFile("OBJNAMES.TXT");
+	std::string buf = bitmaph->getTextFile("OBJNAMES.TXT");
 	int it=0;
 	while (it<buf.length()-1)
 	{
@@ -24,7 +25,7 @@ void CObjectHandler::loadObjects()
 		objects.push_back(nobj);
 	}
 
-	buf = CGI->bitmaph->getTextFile("ADVEVENT.TXT");
+	buf = bitmaph->getTextFile("ADVEVENT.TXT");
 	it=0;
 	std::string temp;
 	while (it<buf.length()-1)
@@ -36,7 +37,7 @@ void CObjectHandler::loadObjects()
 		advobtxt.push_back(temp);
 	}
 
-	buf = CGI->bitmaph->getTextFile("XTRAINFO.TXT");
+	buf = bitmaph->getTextFile("XTRAINFO.TXT");
 	it=0;
 	while (it<buf.length()-1)
 	{
@@ -44,7 +45,7 @@ void CObjectHandler::loadObjects()
 		xtrainfo.push_back(temp);
 	}
 
-	buf = CGI->bitmaph->getTextFile("MINENAME.TXT");
+	buf = bitmaph->getTextFile("MINENAME.TXT");
 	it=0;
 	while (it<buf.length()-1)
 	{
@@ -52,7 +53,7 @@ void CObjectHandler::loadObjects()
 		mines.push_back(std::pair<std::string,std::string>(temp,""));
 	}
 
-	buf = CGI->bitmaph->getTextFile("MINEEVNT.TXT");
+	buf = bitmaph->getTextFile("MINEEVNT.TXT");
 	it=0;
 	int i=0;
 	while (it<buf.length()-1)
@@ -62,7 +63,7 @@ void CObjectHandler::loadObjects()
 		mines[i++].second = temp;
 	}
 
-	buf = CGI->bitmaph->getTextFile("RESTYPES.TXT");
+	buf = bitmaph->getTextFile("RESTYPES.TXT");
 	it=0;
 	while (it<buf.length()-1)
 	{
@@ -82,7 +83,7 @@ void CObjectHandler::loadObjects()
 	}
 	ifs.close();
 	ifs.clear();
-	buf = CGI->bitmaph->getTextFile("ZCRGN1.TXT");
+	buf = bitmaph->getTextFile("ZCRGN1.TXT");
 	it=0;
 	while (it<buf.length()-1)
 	{
@@ -113,11 +114,11 @@ void CGObjectInstance::setOwner(int ow)
 }
 int CGObjectInstance::getWidth() const//returns width of object graphic in tiles
 {
-	return defInfo->handler->ourImages[0].bitmap->w/32;
+	return defInfo->width;
 }
 int CGObjectInstance::getHeight() const //returns height of object graphic in tiles
 {
-	return defInfo->handler->ourImages[0].bitmap->h/32;
+	return defInfo->width;
 }
 bool CGObjectInstance::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)
 {
@@ -238,7 +239,7 @@ int CGHeroInstance::getSecSkillLevel(const int & ID) const
 const CArtifact * CGHeroInstance::getArt(int pos)
 {
 	if(artifWorn.find(pos)!=artifWorn.end())
-		return &CGI->arth->artifacts[artifWorn[pos]];
+		return &VLC->arth->artifacts[artifWorn[pos]];
 	else 
 		return NULL;
 }
@@ -279,7 +280,7 @@ int CGTownInstance::getHordeLevel(const int & HID)  const//HID - 0 or 1; returns
 }
 int CGTownInstance::creatureGrowth(const int & level) const
 {
-	int ret = CGI->creh->creatures[town->basicCreatures[level]].growth;
+	int ret = VLC->creh->creatures[town->basicCreatures[level]].growth;
 	switch(fortLevel())
 	{
 	case 3:
@@ -288,13 +289,13 @@ int CGTownInstance::creatureGrowth(const int & level) const
 		ret*=(1.5); break;
 	}
 	if(builtBuildings.find(26)!=builtBuildings.end()) //grail
-		ret+=CGI->creh->creatures[town->basicCreatures[level]].growth;
+		ret+=VLC->creh->creatures[town->basicCreatures[level]].growth;
 	if(getHordeLevel(0)==level)
 		if((builtBuildings.find(18)!=builtBuildings.end()) || (builtBuildings.find(19)!=builtBuildings.end()))
-			ret+=CGI->creh->creatures[town->basicCreatures[level]].hordeGrowth;
+			ret+=VLC->creh->creatures[town->basicCreatures[level]].hordeGrowth;
 	if(getHordeLevel(1)==level)
 		if((builtBuildings.find(24)!=builtBuildings.end()) || (builtBuildings.find(25)!=builtBuildings.end()))
-			ret+=CGI->creh->creatures[town->basicCreatures[level]].hordeGrowth;
+			ret+=VLC->creh->creatures[town->basicCreatures[level]].hordeGrowth;
 	return ret;
 }
 int CGTownInstance::dailyIncome() const

+ 30 - 29
hch/CObjectHandler.h

@@ -1,11 +1,12 @@
 #ifndef COBJECTHANDLER_H
 #define COBJECTHANDLER_H
+#include "../global.h"
 #include <string>
 #include <vector>
 #include <set>
 #include <map>
 #include "CCreatureHandler.h"
-//#include "CHeroHandler.h"
+
 using boost::logic::tribool;
 class CCPPObjectScript;
 class CGObjectInstance;
@@ -18,11 +19,11 @@ class CBuilding;
 class CSpell;
 class CGTownInstance;
 class CArtifact;
-class CSpecObjInfo //class with object - specific info (eg. different information for creatures and heroes); use inheritance to make object - specific classes
+class DLL_EXPORT CSpecObjInfo //class with object - specific info (eg. different information for creatures and heroes); use inheritance to make object - specific classes
 {
 };
 
-class CEventObjInfo : public CSpecObjInfo
+class DLL_EXPORT CEventObjInfo : public CSpecObjInfo
 {
 public:
 	bool areGuarders; //true if there are
@@ -48,7 +49,7 @@ public:
 	bool humanActivate; //true if human player can activate this event
 };
 
-class CCastleEvent
+class DLL_EXPORT CCastleEvent
 {
 public:
 	std::string name, message;
@@ -68,7 +69,7 @@ public:
 	}
 };
 
-class CCreatureObjInfo : public CSpecObjInfo
+class DLL_EXPORT CCreatureObjInfo : public CSpecObjInfo
 {
 public:
 	unsigned char bytes[4]; //mysterious bytes identifying creature
@@ -81,13 +82,13 @@ public:
 	bool notGrowingTeam; //if true, number of units won't grow
 };
 
-class CSignObjInfo : public CSpecObjInfo
+class DLL_EXPORT CSignObjInfo : public CSpecObjInfo
 {
 public:
 	std::string message; //message
 };
 
-class CSeerHutObjInfo : public CSpecObjInfo
+class DLL_EXPORT CSeerHutObjInfo : public CSpecObjInfo
 {
 public:
 	unsigned char missionType; //type of mission: 0 - no mission; 1 - reach level; 2 - reach main statistics values; 3 - win with a certain hero; 4 - win with a certain creature; 5 - collect some atifacts; 6 - have certain troops in army; 7 - collect resources; 8 - be a certain hero; 9 - be a certain player
@@ -133,13 +134,13 @@ public:
 	int r10amount;
 };
 
-class CWitchHutObjInfo : public CSpecObjInfo
+class DLL_EXPORT CWitchHutObjInfo : public CSpecObjInfo
 {
 public:
 	std::vector<int> allowedAbilities;
 };
 
-class CScholarObjInfo : public CSpecObjInfo
+class DLL_EXPORT CScholarObjInfo : public CSpecObjInfo
 {
 public:
 	unsigned char bonusType; //255 - random, 0 - primary skill, 1 - secondary skill, 2 - spell
@@ -149,7 +150,7 @@ public:
 	int r2; //Spell ID
 };
 
-class CGarrisonObjInfo : public CSpecObjInfo
+class DLL_EXPORT CGarrisonObjInfo : public CSpecObjInfo
 {
 public:
 	unsigned char player; //255 - nobody; 0 - 7 - players
@@ -157,7 +158,7 @@ public:
 	bool movableUnits; //if true, units can be moved
 };
 
-class CArtifactObjInfo : public CSpecObjInfo
+class DLL_EXPORT CArtifactObjInfo : public CSpecObjInfo
 {
 public:
 	bool areGuards;
@@ -165,7 +166,7 @@ public:
 	CCreatureSet guards;
 };
 
-class CResourceObjInfo : public CSpecObjInfo
+class DLL_EXPORT CResourceObjInfo : public CSpecObjInfo
 {
 public:
 	bool randomAmount;
@@ -175,19 +176,19 @@ public:
 	std::string message;
 };
 
-class CPlayerOnlyObjInfo : public CSpecObjInfo
+class DLL_EXPORT CPlayerOnlyObjInfo : public CSpecObjInfo
 {
 public:
 	unsigned char player; //FF - nobody, 0 - 7
 };
 
-class CShrineObjInfo : public CSpecObjInfo
+class DLL_EXPORT CShrineObjInfo : public CSpecObjInfo
 {
 public:
 	unsigned char spell; //number of spell or 255
 };
 
-class CSpellScrollObjinfo : public CSpecObjInfo
+class DLL_EXPORT CSpellScrollObjinfo : public CSpecObjInfo
 {
 public:
 	std::string message;
@@ -196,7 +197,7 @@ public:
 	CCreatureSet guarders;
 };
 
-class CPandorasBoxObjInfo : public CSpecObjInfo
+class DLL_EXPORT CPandorasBoxObjInfo : public CSpecObjInfo
 {
 public:
 	std::string message;
@@ -217,13 +218,13 @@ public:
 	CCreatureSet creatures;
 };
 
-class CGrailObjInfo : public CSpecObjInfo
+class DLL_EXPORT CGrailObjInfo : public CSpecObjInfo
 {
 public:
 	int radius; //place grail at the distance lesser or equal radius from this place
 };
 
-class CCreGenObjInfo : public CSpecObjInfo
+class DLL_EXPORT CCreGenObjInfo : public CSpecObjInfo
 {
 public:
 	unsigned char player; //owner
@@ -232,7 +233,7 @@ public:
 	unsigned char castles[2]; //allowed castles
 };
 
-class CCreGen2ObjInfo : public CSpecObjInfo
+class DLL_EXPORT CCreGen2ObjInfo : public CSpecObjInfo
 {
 public:
 	unsigned char player; //owner
@@ -242,14 +243,14 @@ public:
 	unsigned char minLevel, maxLevel; //minimal and maximal level of creature in dwelling: <0, 6>
 };
 
-class CCreGen3ObjInfo : public CSpecObjInfo
+class DLL_EXPORT CCreGen3ObjInfo : public CSpecObjInfo
 {
 public:
 	unsigned char player; //owner
 	unsigned char minLevel, maxLevel; //minimal and maximal level of creature in dwelling: <0, 6>
 };
 
-class CBorderGuardObjInfo : public CSpecObjInfo //copied form seer huts, seems to be similar
+class DLL_EXPORT CBorderGuardObjInfo : public CSpecObjInfo //copied form seer huts, seems to be similar
 {
 public:
 	char missionType; //type of mission: 0 - no mission; 1 - reach level; 2 - reach main statistics values; 3 - win with a certain hero; 4 - win with a certain creature; 5 - collect some atifacts; 6 - have certain troops in army; 7 - collect resources; 8 - be a certain hero; 9 - be a certain player
@@ -278,15 +279,15 @@ public:
 	std::string firstVisitText, nextVisitText, completedText;
 };
 
-class CObject //typical object that can be encountered on a map
+class DLL_EXPORT CObject //typical object that can be encountered on a map
 {
 public:
 	std::string name; //object's name
 };
 
-class CGDefInfo;
+class DLL_EXPORT CGDefInfo;
 
-class CGObjectInstance
+class DLL_EXPORT CGObjectInstance
 {
 public:
 	int3 pos; //h3m pos
@@ -313,13 +314,13 @@ public:
 	CGObjectInstance& operator=(const CGObjectInstance & right);
 };
 
-class  CArmedInstance: public CGObjectInstance
+class  DLL_EXPORT CArmedInstance: public CGObjectInstance
 {
 public:
 	CCreatureSet army; //army
 };
 
-class CGHeroInstance : public CArmedInstance
+class DLL_EXPORT CGHeroInstance : public CArmedInstance
 {
 public:
 	int moveDir; //format:	123
@@ -340,7 +341,7 @@ public:
 	int identifier; //from the map file
 	bool sex;
 
-	struct Patrol
+	struct DLL_EXPORT Patrol
 	{
 		Patrol(){patrolling=false;patrolRadious=-1;};
 		bool patrolling;
@@ -374,7 +375,7 @@ public:
 	virtual ~CGHeroInstance();
 };
 
-class CGTownInstance : public CArmedInstance
+class DLL_EXPORT CGTownInstance : public CArmedInstance
 {
 public:
 	CTown * town;
@@ -408,7 +409,7 @@ public:
 	virtual ~CGTownInstance();
 };
 
-class CObjectHandler
+class DLL_EXPORT CObjectHandler
 {
 public:
 	std::vector<CObject> objects; //vector of objects; i-th object in vector has subnumber i

+ 1 - 1
hch/CTownHandler.h

@@ -6,7 +6,7 @@ class CBuilding;
 class CSpell;
 class CHero;
 class CGTownInstance;
-class CTown
+class DLL_EXPORT CTown
 {
 public:
 	std::string name; //name of type

+ 2 - 2
lib/VCMI_Lib.h

@@ -2,7 +2,7 @@
 
 
 //class CMapHandler;
-//class CArtHandler;
+class CArtHandler;
 //class CHeroHandler;
 class CCreatureHandler;
 //class CAbilityHandler;
@@ -30,7 +30,7 @@ class LibClasses
 {
 public:
 	//CGameState * state;
-	//CArtHandler * arth;
+	CArtHandler * arth;
 	//CHeroHandler * heroh;
 	CCreatureHandler * creh;
 	//CAbilityHandler * abilh;

+ 8 - 0
lib/VCMI_lib.vcproj

@@ -349,6 +349,10 @@
 				RelativePath="..\hch\CLodHandler.cpp"
 				>
 			</File>
+			<File
+				RelativePath="..\hch\CObjectHandler.cpp"
+				>
+			</File>
 			<File
 				RelativePath="..\hch\CTownHandler.cpp"
 				>
@@ -387,6 +391,10 @@
 				RelativePath="..\hch\CLodHandler.h"
 				>
 			</File>
+			<File
+				RelativePath="..\hch\CObjectHandler.h"
+				>
+			</File>
 			<File
 				RelativePath="..\hch\CTownHandler.h"
 				>

+ 21 - 0
mapHandler.cpp

@@ -278,6 +278,8 @@ void CMapHandler::randomizeObject(CGObjectInstance *cur)
 			if(!t->defInfo->handler)
 			{
 				t->defInfo->handler = CDefHandler::giveDef(t->defInfo->name);
+				t->defInfo->width = t->defInfo->handler->ourImages[0].bitmap->w/32;
+				t->defInfo->height = t->defInfo->handler->ourImages[0].bitmap->h/32;
 				alphaTransformDef(t->defInfo);
 			}
 		}
@@ -310,6 +312,8 @@ void CMapHandler::randomizeObject(CGObjectInstance *cur)
 		if(!t->defInfo->handler)
 		{
 			t->defInfo->handler = CDefHandler::giveDef(t->defInfo->name);
+			t->defInfo->width = t->defInfo->handler->ourImages[0].bitmap->w/32;
+			t->defInfo->height = t->defInfo->handler->ourImages[0].bitmap->h/32;
 			alphaTransformDef(t->defInfo);
 		}
 		//CGI->townh->townInstances.push_back(t);
@@ -323,6 +327,8 @@ void CMapHandler::randomizeObject(CGObjectInstance *cur)
 	if(!cur->defInfo->handler) //if we have to load def
 	{
 		cur->defInfo->handler = CDefHandler::giveDef(cur->defInfo->name);
+		cur->defInfo->width = cur->defInfo->handler->ourImages[0].bitmap->w/32;
+		cur->defInfo->height = cur->defInfo->handler->ourImages[0].bitmap->h/32;
 		alphaTransformDef(cur->defInfo);
 	}
 
@@ -810,9 +816,15 @@ void CMapHandler::init()
 	for (int ir=0;ir<map->defy.size();ir++)
 	{
 		map->defy[ir]->handler=CDefHandler::giveDef(map->defy[ir]->name);
+		map->defy[ir]->width = map->defy[ir]->handler->ourImages[0].bitmap->w/32;
+		map->defy[ir]->height = map->defy[ir]->handler->ourImages[0].bitmap->h/32;
 		CGDefInfo* pom = CGI->dobjinfo->gobjs[map->defy[ir]->id][map->defy[ir]->subid];
 		if(pom)
+		{
 			pom->handler=map->defy[ir]->handler;
+			pom->width = pom->handler->ourImages[0].bitmap->w/32;
+			pom->height = pom->handler->ourImages[0].bitmap->h/32;
+		}
 		else
 			std::cout << "Lacking def info for " << map->defy[ir]->id << " " << map->defy[ir]->subid <<" " << map->defy[ir]->name << std::endl;
 	}
@@ -838,6 +850,11 @@ void CMapHandler::init()
 		ifs >> n->name;
 		if (!(n->handler = CDefHandler::giveDef(n->name)))
 			std::cout << "Cannot open "<<n->name<<std::endl;
+		else
+		{
+			n->width = n->handler->ourImages[0].bitmap->w/32;
+			n->height = n->handler->ourImages[0].bitmap->h/32;
+		}
 		if(i<ccc)
 			villages[i]=n;
 		else
@@ -1543,7 +1560,11 @@ CGObjectInstance * CMapHandler::createObject(int id, int subid, int3 pos, int ow
 		return nobj;
 	nobj->defInfo = CGI->dobjinfo->gobjs[id][subid];
 	if(!nobj->defInfo->handler)
+	{
 		nobj->defInfo->handler = CDefHandler::giveDef(nobj->defInfo->name);
+		nobj->defInfo->width = nobj->defInfo->handler->ourImages[0].bitmap->w/32;
+		nobj->defInfo->height = nobj->defInfo->handler->ourImages[0].bitmap->h/32;
+	}
 	return nobj;
 }