Pārlūkot izejas kodu

* poprawa wyświetlania obiektów
* upiększenie fragmentów kodu
* przesuwanie mapy przejechaniem kursora na skraj wyświetlanego obszaru
* ładne ramki przykrywające obiekty
* ulepszenie obsługi defów i lodów
* przyspieszenie przewijania map

mateuszb 18 gadi atpakaļ
vecāks
revīzija
051094abcc
14 mainītis faili ar 338 papildinājumiem un 259 dzēšanām
  1. 11 3
      CAmbarCendamo.cpp
  2. BIN
      CDefHandler.cpp
  3. BIN
      CDefHandler.h
  4. 2 1
      CGameInfo.h
  5. 139 125
      CLodHandler.cpp
  6. 4 2
      CLodHandler.h
  7. 105 84
      CMT.cpp
  8. 1 1
      CMessage.cpp
  9. BIN
      CPreGame.cpp
  10. 1 0
      CSemiDefHandler.h
  11. 5 0
      CSndHandler.h
  12. 1 3
      SDL_Extensions.cpp
  13. 5 0
      SDL_Extensions.h
  14. 64 40
      mapHandler.cpp

+ 11 - 3
CAmbarCendamo.cpp

@@ -408,7 +408,6 @@ void CAmbarCendamo::deh3m()
 	std::vector<std::string> defsToUnpack;
 	std::vector<std::string> defsToUnpack;
 	for (int idd = 0 ; idd<defAmount; idd++) // reading defs
 	for (int idd = 0 ; idd<defAmount; idd++) // reading defs
 	{
 	{
-		std::cout<<'\r'<<"Reading defs: "<<(100.0*idd)/((float)(defAmount))<<"%      ";
 		int nameLength = readNormalNr(i,4);i+=4;
 		int nameLength = readNormalNr(i,4);i+=4;
 		DefInfo vinya; // info about new def
 		DefInfo vinya; // info about new def
 		for (int cd=0;cd<nameLength;cd++)
 		for (int cd=0;cd<nameLength;cd++)
@@ -449,10 +448,19 @@ void CAmbarCendamo::deh3m()
 
 
 		//teceDef();
 		//teceDef();
 	}
 	}
-	std::vector<CDefHandler *> dhandlers = CGameInfo::mainObj->lodh->extractManyFiles(defsToUnpack, std::string("newh3sprite.lod"));
+	std::vector<CDefHandler *> dhandlers = CGameInfo::mainObj->spriteh->extractManyFiles(defsToUnpack, std::string("newh3sprite.lod"));
 	for (int i=0;i<dhandlers.size();i++)
 	for (int i=0;i<dhandlers.size();i++)
 		map.defy[i].handler=dhandlers[i];
 		map.defy[i].handler=dhandlers[i];
-	std::cout<<'\r'<<"Reading defs: 100%    "<<std::endl;
+	for(int vv=0; vv<map.defy.size(); ++vv)
+	{
+		for(int yy=0; yy<map.defy[vv].handler->ourImages.size(); ++yy)
+		{
+			map.defy[vv].handler->ourImages[yy].bitmap = CSDL_Ext::alphaTransform(map.defy[vv].handler->ourImages[yy].bitmap);
+			SDL_Surface * bufs = CSDL_Ext::secondAlphaTransform(map.defy[vv].handler->ourImages[yy].bitmap, alphaTransSurf);
+			SDL_FreeSurface(map.defy[vv].handler->ourImages[yy].bitmap);
+			map.defy[vv].handler->ourImages[yy].bitmap = bufs;
+		}
+	}
 	SDL_FreeSurface(alphaTransSurf);
 	SDL_FreeSurface(alphaTransSurf);
 	THC std::cout<<"Wczytywanie defow: "<<th.getDif()<<std::endl;
 	THC std::cout<<"Wczytywanie defow: "<<th.getDif()<<std::endl;
 	////loading objects
 	////loading objects

BIN
CDefHandler.cpp


BIN
CDefHandler.h


+ 2 - 1
CGameInfo.h

@@ -33,7 +33,8 @@ public:
 	CMusicHandler * mush;
 	CMusicHandler * mush;
 	CSemiLodHandler * sspriteh;
 	CSemiLodHandler * sspriteh;
 	CDefObjInfoHandler * dobjinfo;
 	CDefObjInfoHandler * dobjinfo;
-	CLodHandler * lodh;
+	CLodHandler * spriteh;
+	CLodHandler * bitmaph;
 };
 };
 
 
 #endif //CGAMEINFO_H
 #endif //CGAMEINFO_H

+ 139 - 125
CLodHandler.cpp

@@ -278,55 +278,56 @@ std::vector<CDefHandler *> CLodHandler::extractManyFiles(std::vector<std::string
 	{
 	{
 		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);
 	}
 	}
-	std::ifstream FLOD;
+	//std::ifstream FLOD;
 	std::ofstream FOut;
 	std::ofstream FOut;
 	int i;
 	int i;
 
 
-	std::string Ts;
-	//std::cout<<"*** Loading FAT ... \n";
-	FLOD.open(lodName.c_str(),std::ios::binary);
-	//std::cout<<"*** Archive: "+FName+" loaded\n";
-	FLOD.seekg(8,std::ios_base::beg);
-	unsigned char temp[4];
-	FLOD.read((char*)temp,4);
-	totalFiles = readNormalNr(temp,4);
-	FLOD.seekg(0x5c,std::ios_base::beg);
-	entries.reserve(totalFiles);
-	//std::cout<<"*** Loading FAT ...\n";
-	for (int i=0; i<totalFiles; i++)
-	{
-		entries.push_back(Entry());
-		//FLOD.read((char*)entries[i].name,12);
-		char * bufc = new char;
-		bool appending = true;
-		for(int kk=0; kk<12; ++kk)
-		{
-			FLOD.read(bufc, 1);
-			if(appending)
-			{
-				entries[i].name[kk] = *bufc;
-			}
-			else
-			{
-				entries[i].name[kk] = 0;
-				appending = false;
-			}
-		}
-		delete bufc;
-		FLOD.read((char*)entries[i].hlam_1,4);
-		FLOD.read((char*)temp,4);
-		entries[i].offset=readNormalNr(temp,4);
-		FLOD.read((char*)temp,4);
-		entries[i].realSize=readNormalNr(temp,4);
-		FLOD.read((char*)entries[i].hlam_2,4);
-		FLOD.read((char*)temp,4);
-		entries[i].size=readNormalNr(temp,4);
-	}
+	//std::string Ts;
+	////std::cout<<"*** Loading FAT ... \n";
+	//FLOD.open(lodName.c_str(),std::ios::binary);
+	////std::cout<<"*** Archive: "+FName+" loaded\n";
+	//FLOD.seekg(8,std::ios_base::beg);
+	//unsigned char temp[4];
+	//FLOD.read((char*)temp,4);
+	//totalFiles = readNormalNr(temp,4);
+	//FLOD.seekg(0x5c,std::ios_base::beg);
+	//entries.reserve(totalFiles);
+	////std::cout<<"*** Loading FAT ...\n";
+	//for (int i=0; i<totalFiles; i++)
+	//{
+	//	entries.push_back(Entry());
+	//	//FLOD.read((char*)entries[i].name,12);
+	//	char * bufc = new char;
+	//	bool appending = true;
+	//	for(int kk=0; kk<12; ++kk)
+	//	{
+	//		FLOD.read(bufc, 1);
+	//		if(appending)
+	//		{
+	//			entries[i].name[kk] = *bufc;
+	//		}
+	//		else
+	//		{
+	//			entries[i].name[kk] = 0;
+	//			appending = false;
+	//		}
+	//	}
+	//	delete bufc;
+	//	FLOD.read((char*)entries[i].hlam_1,4);
+	//	FLOD.read((char*)temp,4);
+	//	entries[i].offset=readNormalNr(temp,4);
+	//	FLOD.read((char*)temp,4);
+	//	entries[i].realSize=readNormalNr(temp,4);
+	//	FLOD.read((char*)entries[i].hlam_2,4);
+	//	FLOD.read((char*)temp,4);
+	//	entries[i].size=readNormalNr(temp,4);
+	//}
 	//std::cout<<" done\n";
 	//std::cout<<" done\n";
 	//std::transform(name.begin(), name.end(), name.begin(), (int(*)(int))toupper);
 	//std::transform(name.begin(), name.end(), name.begin(), (int(*)(int))toupper);
 	std::vector<char> found(defNamesIn.size(), 0);
 	std::vector<char> found(defNamesIn.size(), 0);
 	for (int i=0;i<totalFiles;i++)
 	for (int i=0;i<totalFiles;i++)
 	{
 	{
+		std::cout<<'\r'<<"Reading defs: "<<(100.0*i)/((float)(totalFiles))<<"%      ";
 		std::string buf1 = std::string((char*)entries[i].name);
 		std::string buf1 = std::string((char*)entries[i].name);
 		std::transform(buf1.begin(), buf1.end(), buf1.begin(), (int(*)(int))toupper);
 		std::transform(buf1.begin(), buf1.end(), buf1.begin(), (int(*)(int))toupper);
 		bool exists = false;
 		bool exists = false;
@@ -397,7 +398,20 @@ std::vector<CDefHandler *> CLodHandler::extractManyFiles(std::vector<std::string
 		//FOut.close();
 		//FOut.close();
 		//std::cout<<"*** done\n";
 		//std::cout<<"*** done\n";
 	}
 	}
-	//TODO: przypisywanie defhandlerów powtarzaj¹cym siê defom
+	std::cout<<'\r'<<"Reading defs: 100%    "<<std::endl;
+	for(int hh=0; hh<found.size(); ++hh)
+	{
+		if(!found[hh])
+		{
+			for(int ff=0; ff<hh; ++ff)
+			{
+				if(defNamesIn[ff]==defNamesIn[hh])
+				{
+					ret[hh]=ret[ff];
+				}
+			}
+		}
+	}
 	FLOD.close();
 	FLOD.close();
 	//std::cout<<"*** Archive: "+FName+" closed\n";
 	//std::cout<<"*** Archive: "+FName+" closed\n";
 	return ret;
 	return ret;
@@ -564,50 +578,10 @@ 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::ifstream FLOD;
+	
 	std::ofstream FOut;
 	std::ofstream FOut;
 	int i;
 	int i;
 
 
-	std::string Ts;
-	//std::cout<<"*** Loading FAT ... \n";
-	FLOD.open(FName.c_str(),std::ios::binary);
-	//std::cout<<"*** Archive: "+FName+" loaded\n";
-	FLOD.seekg(8,std::ios_base::beg);
-	unsigned char temp[4];
-	FLOD.read((char*)temp,4);
-	totalFiles = readNormalNr(temp,4);
-	FLOD.seekg(0x5c,std::ios_base::beg);
-	entries.reserve(totalFiles);
-	//std::cout<<"*** Loading FAT ...\n";
-	for (int i=0; i<totalFiles; i++)
-	{
-		entries.push_back(Entry());
-		//FLOD.read((char*)entries[i].name,12);
-		char * bufc = new char;
-		bool appending = true;
-		for(int kk=0; kk<12; ++kk)
-		{
-			FLOD.read(bufc, 1);
-			if(appending)
-			{
-				entries[i].name[kk] = *bufc;
-			}
-			else
-			{
-				entries[i].name[kk] = 0;
-				appending = false;
-			}
-		}
-		delete bufc;
-		FLOD.read((char*)entries[i].hlam_1,4);
-		FLOD.read((char*)temp,4);
-		entries[i].offset=readNormalNr(temp,4);
-		FLOD.read((char*)temp,4);
-		entries[i].realSize=readNormalNr(temp,4);
-		FLOD.read((char*)entries[i].hlam_2,4);
-		FLOD.read((char*)temp,4);
-		entries[i].size=readNormalNr(temp,4);
-	}
 	//std::cout<<" done\n";
 	//std::cout<<" done\n";
 	for (int i=0;i<totalFiles;i++)
 	for (int i=0;i<totalFiles;i++)
 	{
 	{
@@ -661,50 +635,50 @@ void CLodHandler::extract(std::string FName)
 
 
 void CLodHandler::extractFile(std::string FName, std::string name)
 void CLodHandler::extractFile(std::string FName, std::string name)
 {
 {
-	std::ifstream FLOD;
+	//std::ifstream FLOD;
 	std::ofstream FOut;
 	std::ofstream FOut;
 	int i;
 	int i;
 
 
-	std::string Ts;
-	//std::cout<<"*** Loading FAT ... \n";
-	FLOD.open(FName.c_str(),std::ios::binary);
-	//std::cout<<"*** Archive: "+FName+" loaded\n";
-	FLOD.seekg(8,std::ios_base::beg);
-	unsigned char temp[4];
-	FLOD.read((char*)temp,4);
-	totalFiles = readNormalNr(temp,4);
-	FLOD.seekg(0x5c,std::ios_base::beg);
-	entries.reserve(totalFiles);
-	//std::cout<<"*** Loading FAT ...\n";
-	for (int i=0; i<totalFiles; i++)
-	{
-		entries.push_back(Entry());
-		//FLOD.read((char*)entries[i].name,12);
-		char * bufc = new char;
-		bool appending = true;
-		for(int kk=0; kk<12; ++kk)
-		{
-			FLOD.read(bufc, 1);
-			if(appending)
-			{
-				entries[i].name[kk] = *bufc;
-			}
-			else
-			{
-				entries[i].name[kk] = 0;
-				appending = false;
-			}
-		}
-		delete bufc;
-		FLOD.read((char*)entries[i].hlam_1,4);
-		FLOD.read((char*)temp,4);
-		entries[i].offset=readNormalNr(temp,4);
-		FLOD.read((char*)temp,4);
-		entries[i].realSize=readNormalNr(temp,4);
-		FLOD.read((char*)entries[i].hlam_2,4);
-		FLOD.read((char*)temp,4);
-		entries[i].size=readNormalNr(temp,4);
-	}
+	//std::string Ts;
+	////std::cout<<"*** Loading FAT ... \n";
+	//FLOD.open(FName.c_str(),std::ios::binary);
+	////std::cout<<"*** Archive: "+FName+" loaded\n";
+	//FLOD.seekg(8,std::ios_base::beg);
+	//unsigned char temp[4];
+	//FLOD.read((char*)temp,4);
+	//totalFiles = readNormalNr(temp,4);
+	//FLOD.seekg(0x5c,std::ios_base::beg);
+	//entries.reserve(totalFiles);
+	////std::cout<<"*** Loading FAT ...\n";
+	//for (int i=0; i<totalFiles; i++)
+	//{
+	//	entries.push_back(Entry());
+	//	//FLOD.read((char*)entries[i].name,12);
+	//	char * bufc = new char;
+	//	bool appending = true;
+	//	for(int kk=0; kk<12; ++kk)
+	//	{
+	//		FLOD.read(bufc, 1);
+	//		if(appending)
+	//		{
+	//			entries[i].name[kk] = *bufc;
+	//		}
+	//		else
+	//		{
+	//			entries[i].name[kk] = 0;
+	//			appending = false;
+	//		}
+	//	}
+	//	delete bufc;
+	//	FLOD.read((char*)entries[i].hlam_1,4);
+	//	FLOD.read((char*)temp,4);
+	//	entries[i].offset=readNormalNr(temp,4);
+	//	FLOD.read((char*)temp,4);
+	//	entries[i].realSize=readNormalNr(temp,4);
+	//	FLOD.read((char*)entries[i].hlam_2,4);
+	//	FLOD.read((char*)temp,4);
+	//	entries[i].size=readNormalNr(temp,4);
+	//}
 	//std::cout<<" done\n";
 	//std::cout<<" done\n";
 	std::transform(name.begin(), name.end(), name.begin(), (int(*)(int))toupper);
 	std::transform(name.begin(), name.end(), name.begin(), (int(*)(int))toupper);
 	for (int i=0;i<totalFiles;i++)
 	for (int i=0;i<totalFiles;i++)
@@ -779,5 +753,45 @@ int CLodHandler::readNormalNr (unsigned char* bufor, int bytCon, bool cyclic)
 
 
 void CLodHandler::init(std::string lodFile)
 void CLodHandler::init(std::string lodFile)
 {
 {
-	extract(lodFile);
+	FLOD;
+	std::string Ts;
+	//std::cout<<"*** Loading FAT ... \n";
+	FLOD.open(lodFile.c_str(),std::ios::binary);
+	//std::cout<<"*** Archive: "+FName+" loaded\n";
+	FLOD.seekg(8,std::ios_base::beg);
+	unsigned char temp[4];
+	FLOD.read((char*)temp,4);
+	totalFiles = readNormalNr(temp,4);
+	FLOD.seekg(0x5c,std::ios_base::beg);
+	entries.reserve(totalFiles);
+	//std::cout<<"*** Loading FAT ...\n";
+	for (int i=0; i<totalFiles; i++)
+	{
+		entries.push_back(Entry());
+		//FLOD.read((char*)entries[i].name,12);
+		char * bufc = new char;
+		bool appending = true;
+		for(int kk=0; kk<12; ++kk)
+		{
+			FLOD.read(bufc, 1);
+			if(appending)
+			{
+				entries[i].name[kk] = *bufc;
+			}
+			else
+			{
+				entries[i].name[kk] = 0;
+				appending = false;
+			}
+		}
+		delete bufc;
+		FLOD.read((char*)entries[i].hlam_1,4);
+		FLOD.read((char*)temp,4);
+		entries[i].offset=readNormalNr(temp,4);
+		FLOD.read((char*)temp,4);
+		entries[i].realSize=readNormalNr(temp,4);
+		FLOD.read((char*)entries[i].hlam_2,4);
+		FLOD.read((char*)temp,4);
+		entries[i].size=readNormalNr(temp,4);
+	}
 }
 }

+ 4 - 2
CLodHandler.h

@@ -48,6 +48,8 @@ public:
 };
 };
 class CLodHandler
 class CLodHandler
 {
 {
+private:
+	std::ifstream FLOD;
 public:
 public:
 	std::vector<Entry> entries;
 	std::vector<Entry> entries;
 	unsigned int totalFiles;
 	unsigned int totalFiles;
@@ -58,9 +60,9 @@ public:
 	int infm(FILE *source, FILE *dest, int wBits = 15); //zlib handler
 	int infm(FILE *source, FILE *dest, int wBits = 15); //zlib handler
 	int infs(unsigned char * in, int size, int realSize, std::ofstream & out, int wBits=15); //zlib fast handler
 	int infs(unsigned char * in, int size, int realSize, std::ofstream & out, int wBits=15); //zlib fast handler
 	int infs2(unsigned char * in, int size, int realSize, unsigned char*& out, int wBits=15); //zlib fast handler
 	int infs2(unsigned char * in, int size, int realSize, unsigned char*& out, int wBits=15); //zlib fast handler
-	std::vector<CDefHandler *> extractManyFiles(std::vector<std::string> defNamesIn, std::string lodName); //extrats given files
+	std::vector<CDefHandler *> extractManyFiles(std::vector<std::string> defNamesIn, std::string lodName); //extrats given files (defs only)
 	void extract(std::string FName);
 	void extract(std::string FName);
-	void extractFile(std::string FName, std::string name);
+	void extractFile(std::string FName, std::string name); //extracts a specific file
 	void init(std::string lodFile);
 	void init(std::string lodFile);
 };
 };
 
 

+ 105 - 84
CMT.cpp

@@ -29,6 +29,11 @@
 #include "CDefHandler.h"
 #include "CDefHandler.h"
 #include "CSndHandler.h"
 #include "CSndHandler.h"
 #include "CDefObjInfoHandler.h"
 #include "CDefObjInfoHandler.h"
+#include "CAmbarCendamo.h"
+#include "mapHandler.h"
+#include "global.h"
+#include "CPreGame.h"
+
 #if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__)
 #if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__)
 #  include <fcntl.h>
 #  include <fcntl.h>
 #  include <io.h>
 #  include <io.h>
@@ -36,13 +41,10 @@
 #else
 #else
 #  define SET_BINARY_MODE(file)
 #  define SET_BINARY_MODE(file)
 #endif
 #endif
+
 #define CHUNK 16384
 #define CHUNK 16384
-#define pi 3.14159
 const char * NAME = "VCMI 0.2";
 const char * NAME = "VCMI 0.2";
-#include "CAmbarCendamo.h"
-#include "mapHandler.h"
-#include "global.h"
-#include "CPreGame.h"
+
 /* Compress from file source to file dest until EOF on source.
 /* Compress from file source to file dest until EOF on source.
    def() returns Z_OK on success, Z_MEM_ERROR if memory could not be
    def() returns Z_OK on success, Z_MEM_ERROR if memory could not be
    allocated for processing, Z_STREAM_ERROR if an invalid compression
    allocated for processing, Z_STREAM_ERROR if an invalid compression
@@ -107,63 +109,63 @@ int def(FILE *source, FILE *dest, int level, int winBits=15, int memLevel =8)
    invalid or incomplete, Z_VERSION_ERROR if the version of zlib.h and
    invalid or incomplete, Z_VERSION_ERROR if the version of zlib.h and
    the version of the library linked do not match, or Z_ERRNO if there
    the version of the library linked do not match, or Z_ERRNO if there
    is an error reading or writing the files. */
    is an error reading or writing the files. */
-int inf(FILE *source, FILE *dest, int wBits = 15)
-{
-	int ret;
-	unsigned have;
-	z_stream strm;
-	unsigned char in[CHUNK];
-	unsigned char out[CHUNK];
-
-	/* allocate inflate state */
-	strm.zalloc = Z_NULL;
-	strm.zfree = Z_NULL;
-	strm.opaque = Z_NULL;
-	strm.avail_in = 0;
-	strm.next_in = Z_NULL;
-	ret = inflateInit2(&strm, wBits);
-	if (ret != Z_OK)
-		return ret;
-
-	/* decompress until deflate stream ends or end of file */
-	do {
-		strm.avail_in = fread(in, 1, CHUNK, source);
-		if (ferror(source)) {
-			(void)inflateEnd(&strm);
-			return Z_ERRNO;
-		}
-		if (strm.avail_in == 0)
-			break;
-		strm.next_in = in;
-
-		/* run inflate() on input until output buffer not full */
-		do {
-			strm.avail_out = CHUNK;
-			strm.next_out = out;
-			ret = inflate(&strm, Z_NO_FLUSH);
-			assert(ret != Z_STREAM_ERROR);  /* state not clobbered */
-			switch (ret) {
-			case Z_NEED_DICT:
-				ret = Z_DATA_ERROR;	 /* and fall through */
-			case Z_DATA_ERROR:
-			case Z_MEM_ERROR:
-				(void)inflateEnd(&strm);
-				return ret;
-			}
-			have = CHUNK - strm.avail_out;
-			if (fwrite(out, 1, have, dest) != have || ferror(dest)) {
-				(void)inflateEnd(&strm);
-				return Z_ERRNO;
-			}
-		} while (strm.avail_out == 0);
-
-		/* done when inflate() says it's done */
-	} while (ret != Z_STREAM_END);
-
-	/* clean up and return */
-	(void)inflateEnd(&strm);
-	return ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR;
-}
+//int inf(FILE *source, FILE *dest, int wBits = 15)
+//{
+//	int ret;
+//	unsigned have;
+//	z_stream strm;
+//	unsigned char in[CHUNK];
+//	unsigned char out[CHUNK];
+//
+//	/* allocate inflate state */
+//	strm.zalloc = Z_NULL;
+//	strm.zfree = Z_NULL;
+//	strm.opaque = Z_NULL;
+//	strm.avail_in = 0;
+//	strm.next_in = Z_NULL;
+//	ret = inflateInit2(&strm, wBits);
+//	if (ret != Z_OK)
+//		return ret;
+//
+//	/* decompress until deflate stream ends or end of file */
+//	do {
+//		strm.avail_in = fread(in, 1, CHUNK, source);
+//		if (ferror(source)) {
+//			(void)inflateEnd(&strm);
+//			return Z_ERRNO;
+//		}
+//		if (strm.avail_in == 0)
+//			break;
+//		strm.next_in = in;
+//
+//		/* run inflate() on input until output buffer not full */
+//		do {
+//			strm.avail_out = CHUNK;
+//			strm.next_out = out;
+//			ret = inflate(&strm, Z_NO_FLUSH);
+//			assert(ret != Z_STREAM_ERROR);  /* state not clobbered */
+//			switch (ret) {
+//			case Z_NEED_DICT:
+//				ret = Z_DATA_ERROR;	 /* and fall through */
+//			case Z_DATA_ERROR:
+//			case Z_MEM_ERROR:
+//				(void)inflateEnd(&strm);
+//				return ret;
+//			}
+//			have = CHUNK - strm.avail_out;
+//			if (fwrite(out, 1, have, dest) != have || ferror(dest)) {
+//				(void)inflateEnd(&strm);
+//				return Z_ERRNO;
+//			}
+//		} while (strm.avail_out == 0);
+//
+//		/* done when inflate() says it's done */
+//	} while (ret != Z_STREAM_END);
+//
+//	/* clean up and return */
+//	(void)inflateEnd(&strm);
+//	return ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR;
+//}
 
 
 /* report a zlib or i/o error */
 /* report a zlib or i/o error */
 void zerr(int ret)
 void zerr(int ret)
@@ -190,25 +192,6 @@ void zerr(int ret)
 	}
 	}
 }
 }
 
 
-
-
-/*void SDL_PutPixel(SDL_Surface *ekran, int x, int y, Uint8 R, Uint8 G, Uint8 B)
-{
-	 Uint8 *p = (Uint8 *)ekran->pixels + y * ekran->pitch + x * ekran->format->BytesPerPixel;
-	 if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
-	 {
-		  p[0] = R;
-		  p[1] = G;
-		  p[2] = B;
-	 }
-	 else
-	 {
-		  p[0] = B;
-		  p[1] = G;
-		  p[2] = R;
-	 }
-	 SDL_UpdateRect(ekran, x, y, 1, 1);
-}*/
 int _tmain(int argc, _TCHAR* argv[])
 int _tmain(int argc, _TCHAR* argv[])
 { 
 { 
 	THC timeHandler tmh;
 	THC timeHandler tmh;
@@ -323,7 +306,10 @@ int _tmain(int argc, _TCHAR* argv[])
 		cgi->objh = objh;
 		cgi->objh = objh;
 		cgi->dobjinfo = new CDefObjInfoHandler;
 		cgi->dobjinfo = new CDefObjInfoHandler;
 		cgi->dobjinfo->load();
 		cgi->dobjinfo->load();
-		cgi->lodh = new CLodHandler;
+		cgi->spriteh = new CLodHandler;
+		cgi->spriteh->init(std::string("newH3sprite.lod"));
+		cgi->bitmaph = new CLodHandler;
+		cgi->bitmaph->init(std::string("newH3bitmap.lod"));
 
 
 		THC std::cout<<"Inicjalizacja wszelakich handlerow: "<<tmh.getDif()<<std::endl;
 		THC std::cout<<"Inicjalizacja wszelakich handlerow: "<<tmh.getDif()<<std::endl;
 		std::string mapname;
 		std::string mapname;
@@ -435,6 +421,41 @@ int _tmain(int argc, _TCHAR* argv[])
 							}
 							}
 						}
 						}
 					}//keyup end
 					}//keyup end
+					else if(sEvent.type==SDL_MOUSEMOTION)
+					{
+						if(sEvent.motion.x<5)
+						{
+							scrollingLeft = true;
+						}
+						else
+						{
+							scrollingLeft = false;
+						}
+						if(sEvent.motion.x>screen->w-5)
+						{
+							scrollingRight = true;
+						}
+						else
+						{
+							scrollingRight = false;
+						}
+						if(sEvent.motion.y<5)
+						{
+							scrollingUp = true;
+						}
+						else
+						{
+							scrollingUp = false;
+						}
+						if(sEvent.motion.y>screen->h-5)
+						{
+							scrollingDown = true;
+						}
+						else
+						{
+							scrollingDown = false;
+						}
+					}
 				} //event end
 				} //event end
 
 
 				/////////////// scrolling terrain
 				/////////////// scrolling terrain
@@ -464,7 +485,7 @@ int _tmain(int argc, _TCHAR* argv[])
 				}
 				}
 				if(scrollingDown)
 				if(scrollingDown)
 				{
 				{
-					if(yy<ac->map.height-18+8)
+					if(yy<ac->map.height-19+8)
 					{
 					{
 						yy++;
 						yy++;
 						updateScreen = true;
 						updateScreen = true;
@@ -493,7 +514,7 @@ int _tmain(int argc, _TCHAR* argv[])
 	}
 	}
 	else
 	else
 	{
 	{
-		printf("Coœ posz³o nie tak: %s/n",SDL_GetError());
+		printf("Coœ posz³o nie tak: %s/n", SDL_GetError());
 		return -1;
 		return -1;
 	}
 	}
 }
 }

+ 1 - 1
CMessage.cpp

@@ -10,7 +10,7 @@ extern SDL_Surface * ekran;
 extern TTF_Font * TNRB16, *TNR, *GEOR13;
 extern TTF_Font * TNRB16, *TNR, *GEOR13;
 SDL_Color genRGB(int r, int g, int b, int a=0);
 SDL_Color genRGB(int r, int g, int b, int a=0);
 void blitAt(SDL_Surface * src, int x, int y, SDL_Surface * dst=ekran);
 void blitAt(SDL_Surface * src, int x, int y, SDL_Surface * dst=ekran);
-void printAt(std::string text, int x, int y, TTF_Font * font, SDL_Color kolor=tytulowy, SDL_Surface * dst=ekran);
+//void printAt(std::string text, int x, int y, TTF_Font * font, SDL_Color kolor=tytulowy, SDL_Surface * dst=ekran, unsigned char quality = 2);
 extern CPreGame * CPG;
 extern CPreGame * CPG;
 void updateRect (SDL_Rect * rect, SDL_Surface * scr = ekran);
 void updateRect (SDL_Rect * rect, SDL_Surface * scr = ekran);
 bool isItIn(const SDL_Rect * rect, int x, int y);
 bool isItIn(const SDL_Rect * rect, int x, int y);

BIN
CPreGame.cpp


+ 1 - 0
CSemiDefHandler.h

@@ -8,6 +8,7 @@
 
 
 struct Cimage
 struct Cimage
 {
 {
+	int groupNumber;
 	std::string imName; //name without extension
 	std::string imName; //name without extension
 	SDL_Surface * bitmap;
 	SDL_Surface * bitmap;
 };
 };

+ 5 - 0
CSndHandler.h

@@ -1,3 +1,6 @@
+#ifndef CSNDHANDLER_H
+#define CSNDHANDLER_H
+
 #include <vector>
 #include <vector>
 #include <fstream>
 #include <fstream>
 class CSndHandler
 class CSndHandler
@@ -21,3 +24,5 @@ public:
 	void extract(int index, std::string dstfile); //saves selected file
 	void extract(int index, std::string dstfile); //saves selected file
 	unsigned char * extract (int index, int & size); //return selecte file - NIE TESTOWANE
 	unsigned char * extract (int index, int & size); //return selecte file - NIE TESTOWANE
 };
 };
+
+#endif //CSNDHANDLER_H

+ 1 - 3
SDL_Extensions.cpp

@@ -3,8 +3,6 @@
 #include "SDL_TTF.h"
 #include "SDL_TTF.h"
 #include <iostream>
 #include <iostream>
 
 
-extern SDL_Surface * ekran;
-extern SDL_Color tytulowy, tlo, zwykly ;
 bool isItIn(const SDL_Rect * rect, int x, int y)
 bool isItIn(const SDL_Rect * rect, int x, int y)
 {
 {
 	if ((x>rect->x && x<rect->x+rect->w) && (y>rect->y && y<rect->y+rect->h))
 	if ((x>rect->x && x<rect->x+rect->w) && (y>rect->y && y<rect->y+rect->h))
@@ -37,7 +35,7 @@ void updateRect (SDL_Rect * rect, SDL_Surface * scr = ekran)
 {
 {
 	SDL_UpdateRect(scr,rect->x,rect->y,rect->w,rect->h);
 	SDL_UpdateRect(scr,rect->x,rect->y,rect->w,rect->h);
 }
 }
-void printAt(std::string text, int x, int y, TTF_Font * font, SDL_Color kolor=tytulowy, SDL_Surface * dst=ekran)
+void CSDL_Ext::printAt(std::string text, int x, int y, TTF_Font * font, SDL_Color kolor, SDL_Surface * dst, unsigned char quality)
 {
 {
 	SDL_Surface * temp = TTF_RenderText_Blended(font,text.c_str(),kolor);
 	SDL_Surface * temp = TTF_RenderText_Blended(font,text.c_str(),kolor);
 	SDL_BlitSurface(temp,NULL,dst,&genRect(temp->h,temp->w,x,y));
 	SDL_BlitSurface(temp,NULL,dst,&genRect(temp->h,temp->w,x,y));

+ 5 - 0
SDL_Extensions.h

@@ -1,7 +1,11 @@
 #ifndef SDL_EXTENSIONS_H
 #ifndef SDL_EXTENSIONS_H
 #define SDL_EXTENSIONS_H
 #define SDL_EXTENSIONS_H
 #include "SDL.h"
 #include "SDL.h"
+#include "SDL_ttf.h"
 
 
+
+extern SDL_Surface * ekran;
+extern SDL_Color tytulowy, tlo, zwykly ;
 class CSDL_Ext
 class CSDL_Ext
 {
 {
 public:
 public:
@@ -16,6 +20,7 @@ public:
 	static SDL_Surface * alphaTransform(SDL_Surface * src); //adds transparency and shadows (partial handling only; see examples of using for details)
 	static SDL_Surface * alphaTransform(SDL_Surface * src); //adds transparency and shadows (partial handling only; see examples of using for details)
 	static SDL_Surface * secondAlphaTransform(SDL_Surface * src, SDL_Surface * alpha); //alpha is a surface we want to blit src to
 	static SDL_Surface * secondAlphaTransform(SDL_Surface * src, SDL_Surface * alpha); //alpha is a surface we want to blit src to
 	static Uint32 colorToUint32(const SDL_Color * color); //little endian only
 	static Uint32 colorToUint32(const SDL_Color * color); //little endian only
+	static void printAt(std::string text, int x, int y, TTF_Font * font, SDL_Color kolor=tytulowy, SDL_Surface * dst=ekran, unsigned char quality = 2); // quality: 0 - lowest, 1 - medium, 2 - highest
 };
 };
 
 
 #endif // SDL_EXTENSIONS_H
 #endif // SDL_EXTENSIONS_H

+ 64 - 40
mapHandler.cpp

@@ -79,48 +79,48 @@ void CMapHandler::init()
 	for (int ii=0;ii<reader->map.width+2*Woff;ii++)
 	for (int ii=0;ii<reader->map.width+2*Woff;ii++)
 		terrainBitmap[ii] = new SDL_Surface*[reader->map.height+2*Hoff]; // allocate memory 
 		terrainBitmap[ii] = new SDL_Surface*[reader->map.height+2*Hoff]; // allocate memory 
 	CSemiDefHandler * bord = CGameInfo::mainObj->sspriteh->giveDef("EDG.DEF");
 	CSemiDefHandler * bord = CGameInfo::mainObj->sspriteh->giveDef("EDG.DEF");
-	for (int i=0; i<reader->map.width+8; i++) //jest po szerokoœci
+	for (int i=0; i<reader->map.width+2*Woff; i++) //jest po szerokoœci
 	{
 	{
-		for (int j=0; j<reader->map.height+8;j++) //po wysokoœci
+		for (int j=0; j<reader->map.height+2*Hoff;j++) //po wysokoœci
 		{
 		{
-			if(i < 4 || i > (reader->map.width+3) || j < 4  || j > (reader->map.height+3))
+			if(i < Woff || i > (reader->map.width+Woff-1) || j < Hoff  || j > (reader->map.height+Hoff-1))
 			{
 			{
-				if(i==3 && j==3)
+				if(i==Woff-1 && j==Hoff-1)
 				{
 				{
 					terrainBitmap[i][j] = bord->ourImages[16].bitmap;
 					terrainBitmap[i][j] = bord->ourImages[16].bitmap;
 					continue;
 					continue;
 				}
 				}
-				else if(i==3 && j==(reader->map.height+4))
+				else if(i==Woff-1 && j==(reader->map.height+Hoff))
 				{
 				{
 					terrainBitmap[i][j] = bord->ourImages[19].bitmap;
 					terrainBitmap[i][j] = bord->ourImages[19].bitmap;
 					continue;
 					continue;
 				}
 				}
-				else if(i==(reader->map.width+4) && j==3)
+				else if(i==(reader->map.width+Woff) && j==Hoff-1)
 				{
 				{
 					terrainBitmap[i][j] = bord->ourImages[17].bitmap;
 					terrainBitmap[i][j] = bord->ourImages[17].bitmap;
 					continue;
 					continue;
 				}
 				}
-				else if(i==(reader->map.width+4) && j==(reader->map.height+4))
+				else if(i==(reader->map.width+Woff) && j==(reader->map.height+Hoff))
 				{
 				{
 					terrainBitmap[i][j] = bord->ourImages[18].bitmap;
 					terrainBitmap[i][j] = bord->ourImages[18].bitmap;
 					continue;
 					continue;
 				}
 				}
-				else if(j == 3 && i > 3 && i < reader->map.height+4)
+				else if(j == Hoff-1 && i > Woff-1 && i < reader->map.height+Woff)
 				{
 				{
 					terrainBitmap[i][j] = bord->ourImages[22+rand()%2].bitmap;
 					terrainBitmap[i][j] = bord->ourImages[22+rand()%2].bitmap;
 					continue;
 					continue;
 				}
 				}
-				else if(i == 3 && j > 3 && j < reader->map.height+4)
+				else if(i == Woff-1 && j > Hoff-1 && j < reader->map.height+Hoff)
 				{
 				{
 					terrainBitmap[i][j] = bord->ourImages[33+rand()%2].bitmap;
 					terrainBitmap[i][j] = bord->ourImages[33+rand()%2].bitmap;
 					continue;
 					continue;
 				}
 				}
-				else if(j == reader->map.height+4 && i > 3 && i < reader->map.width+4)
+				else if(j == reader->map.height+Hoff && i > Woff-1 && i < reader->map.width+Woff)
 				{
 				{
 					terrainBitmap[i][j] = bord->ourImages[29+rand()%2].bitmap;
 					terrainBitmap[i][j] = bord->ourImages[29+rand()%2].bitmap;
 					continue;
 					continue;
 				}
 				}
-				else if(i == reader->map.width+4 && j > 3 && j < reader->map.height+4)
+				else if(i == reader->map.width+Woff && j > Hoff-1 && j < reader->map.height+Hoff)
 				{
 				{
 					terrainBitmap[i][j] = bord->ourImages[25+rand()%2].bitmap;
 					terrainBitmap[i][j] = bord->ourImages[25+rand()%2].bitmap;
 					continue;
 					continue;
@@ -131,8 +131,8 @@ void CMapHandler::init()
 					continue;
 					continue;
 				}
 				}
 			}
 			}
-			TerrainTile zz = reader->map.terrain[i-4][j-4];
-			std::string name = CSemiDefHandler::nameFromType(reader->map.terrain[i-4][j-4].tertype);
+			TerrainTile zz = reader->map.terrain[i-Woff][j-Hoff];
+			std::string name = CSemiDefHandler::nameFromType(reader->map.terrain[i-Woff][j-Hoff].tertype);
 			for (unsigned int k=0; k<reader->defs.size(); k++)
 			for (unsigned int k=0; k<reader->defs.size(); k++)
 			{
 			{
 				try
 				try
@@ -141,10 +141,10 @@ void CMapHandler::init()
 						continue;
 						continue;
 					else
 					else
 					{
 					{
-						int ktora = reader->map.terrain[i-4][j-4].terview;
+						int ktora = reader->map.terrain[i-Woff][j-Hoff].terview;
 						terrainBitmap[i][j] = reader->defs[k]->ourImages[ktora].bitmap;
 						terrainBitmap[i][j] = reader->defs[k]->ourImages[ktora].bitmap;
 						//TODO: odwracanie	
 						//TODO: odwracanie	
-						switch ((reader->map.terrain[i-4][j-4].siodmyTajemniczyBajt)%4)
+						switch ((reader->map.terrain[i-Woff][j-Hoff].siodmyTajemniczyBajt)%4)
 						{
 						{
 						case 1:
 						case 1:
 							{
 							{
@@ -177,48 +177,48 @@ void CMapHandler::init()
 		undTerrainBitmap = new SDL_Surface **[reader->map.width+8];
 		undTerrainBitmap = new SDL_Surface **[reader->map.width+8];
 		for (int ii=0;ii<reader->map.width+8;ii++)
 		for (int ii=0;ii<reader->map.width+8;ii++)
 			undTerrainBitmap[ii] = new SDL_Surface*[reader->map.height+8]; // allocate memory 
 			undTerrainBitmap[ii] = new SDL_Surface*[reader->map.height+8]; // allocate memory 
-		for (int i=0; i<reader->map.width+8; i++)
+		for (int i=0; i<reader->map.width+2*Woff; i++)
 		{
 		{
-			for (int j=0; j<reader->map.height+8;j++)
+			for (int j=0; j<reader->map.height+2*Hoff;j++)
 			{
 			{
-				if(i < 4 || i > (reader->map.width+3) || j < 4  || j > (reader->map.height+3))
+				if(i < Woff || i > (reader->map.width+Woff-1) || j < Hoff  || j > (reader->map.height+Hoff-1))
 				{
 				{
-					if(i==3 && j==3)
+					if(i==Woff-1 && j==Hoff-1)
 					{
 					{
 						undTerrainBitmap[i][j] = bord->ourImages[16].bitmap;
 						undTerrainBitmap[i][j] = bord->ourImages[16].bitmap;
 						continue;
 						continue;
 					}
 					}
-					else if(i==3 && j==(reader->map.height+4))
+					else if(i==Woff-1 && j==(reader->map.height+Hoff))
 					{
 					{
 						undTerrainBitmap[i][j] = bord->ourImages[19].bitmap;
 						undTerrainBitmap[i][j] = bord->ourImages[19].bitmap;
 						continue;
 						continue;
 					}
 					}
-					else if(i==(reader->map.width+4) && j==3)
+					else if(i==(reader->map.width+Woff) && j==Hoff-1)
 					{
 					{
 						undTerrainBitmap[i][j] = bord->ourImages[17].bitmap;
 						undTerrainBitmap[i][j] = bord->ourImages[17].bitmap;
 						continue;
 						continue;
 					}
 					}
-					else if(i==(reader->map.width+4) && j==(reader->map.height+4))
+					else if(i==(reader->map.width+Woff) && j==(reader->map.height+Hoff))
 					{
 					{
 						undTerrainBitmap[i][j] = bord->ourImages[18].bitmap;
 						undTerrainBitmap[i][j] = bord->ourImages[18].bitmap;
 						continue;
 						continue;
 					}
 					}
-					else if(j == 3 && i > 3 && i < reader->map.height+4)
+					else if(j == Hoff-1 && i > Woff-1 && i < reader->map.width+Woff)
 					{
 					{
 						undTerrainBitmap[i][j] = bord->ourImages[22+rand()%2].bitmap;
 						undTerrainBitmap[i][j] = bord->ourImages[22+rand()%2].bitmap;
 						continue;
 						continue;
 					}
 					}
-					else if(i == 3 && j > 3 && j < reader->map.height+4)
+					else if(i == Woff-1 && j > Hoff-1 && j < reader->map.height+Hoff)
 					{
 					{
 						undTerrainBitmap[i][j] = bord->ourImages[33+rand()%2].bitmap;
 						undTerrainBitmap[i][j] = bord->ourImages[33+rand()%2].bitmap;
 						continue;
 						continue;
 					}
 					}
-					else if(j == reader->map.height+4 && i > 3 && i < reader->map.width+4)
+					else if(j == reader->map.height+Hoff && i > Woff-1 && i < reader->map.width+Woff)
 					{
 					{
 						undTerrainBitmap[i][j] = bord->ourImages[29+rand()%2].bitmap;
 						undTerrainBitmap[i][j] = bord->ourImages[29+rand()%2].bitmap;
 						continue;
 						continue;
 					}
 					}
-					else if(i == reader->map.width+4 && j > 3 && j < reader->map.height+4)
+					else if(i == reader->map.width+Woff && j > Hoff-1 && j < reader->map.height+Hoff)
 					{
 					{
 						undTerrainBitmap[i][j] = bord->ourImages[25+rand()%2].bitmap;
 						undTerrainBitmap[i][j] = bord->ourImages[25+rand()%2].bitmap;
 						continue;
 						continue;
@@ -229,8 +229,8 @@ void CMapHandler::init()
 						continue;
 						continue;
 					}
 					}
 				}
 				}
-				TerrainTile zz = reader->map.undergroungTerrain[i-4][j-4];
-				std::string name = CSemiDefHandler::nameFromType(reader->map.undergroungTerrain[i-4][j-4].tertype);
+				TerrainTile zz = reader->map.undergroungTerrain[i-Woff][j-Hoff];
+				std::string name = CSemiDefHandler::nameFromType(reader->map.undergroungTerrain[i-Woff][j-Hoff].tertype);
 				for (unsigned int k=0; k<reader->defs.size(); k++)
 				for (unsigned int k=0; k<reader->defs.size(); k++)
 				{
 				{
 					try
 					try
@@ -239,10 +239,10 @@ void CMapHandler::init()
 							continue;
 							continue;
 						else
 						else
 						{
 						{
-							int ktora = reader->map.undergroungTerrain[i-4][j-4].terview;
+							int ktora = reader->map.undergroungTerrain[i-Woff][j-Hoff].terview;
 							undTerrainBitmap[i][j] = reader->defs[k]->ourImages[ktora].bitmap;
 							undTerrainBitmap[i][j] = reader->defs[k]->ourImages[ktora].bitmap;
 							//TODO: odwracanie	
 							//TODO: odwracanie	
-							switch ((reader->map.undergroungTerrain[i-4][j-4].siodmyTajemniczyBajt)%4)
+							switch ((reader->map.undergroungTerrain[i-Woff][j-Hoff].siodmyTajemniczyBajt)%4)
 							{
 							{
 							case 1:
 							case 1:
 								{
 								{
@@ -323,8 +323,8 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
 			{
 			{
 				ObjSorter os;
 				ObjSorter os;
 				os.bitmap = CGameInfo::mainObj->ac->map.defy[CGameInfo::mainObj->objh->objInstances[gg].defNumber].handler->ourImages[anim%CGameInfo::mainObj->ac->map.defy[CGameInfo::mainObj->objh->objInstances[gg].defNumber].handler->ourImages.size()].bitmap;
 				os.bitmap = CGameInfo::mainObj->ac->map.defy[CGameInfo::mainObj->objh->objInstances[gg].defNumber].handler->ourImages[anim%CGameInfo::mainObj->ac->map.defy[CGameInfo::mainObj->objh->objInstances[gg].defNumber].handler->ourImages.size()].bitmap;
-				os.xpos = (CGameInfo::mainObj->objh->objInstances[gg].x-x+4)*32;
-				os.ypos = (CGameInfo::mainObj->objh->objInstances[gg].y-y+4)*32;
+				os.xpos = (CGameInfo::mainObj->objh->objInstances[gg].x-x+Woff)*32;
+				os.ypos = (CGameInfo::mainObj->objh->objInstances[gg].y-y+Hoff)*32;
 				highPrObjsVis.push_back(os);
 				highPrObjsVis.push_back(os);
 			}
 			}
 			else if(CGameInfo::mainObj->ac->map.defy[CGameInfo::mainObj->objh->objInstances[gg].defNumber].printPriority==0)
 			else if(CGameInfo::mainObj->ac->map.defy[CGameInfo::mainObj->objh->objInstances[gg].defNumber].printPriority==0)
@@ -336,8 +336,8 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
 
 
 				os.bitmap = CGameInfo::mainObj->ac->map.defy[defyod].handler->ourImages[ourimagesod].bitmap;
 				os.bitmap = CGameInfo::mainObj->ac->map.defy[defyod].handler->ourImages[ourimagesod].bitmap;
 
 
-				os.xpos = (CGameInfo::mainObj->objh->objInstances[gg].x-x+4)*32;
-				os.ypos = (CGameInfo::mainObj->objh->objInstances[gg].y-y+4)*32;
+				os.xpos = (CGameInfo::mainObj->objh->objInstances[gg].x-x+Woff)*32;
+				os.ypos = (CGameInfo::mainObj->objh->objInstances[gg].y-y+Hoff)*32;
 				if (CGameInfo::mainObj->ac->map.defy[CGameInfo::mainObj->objh->objInstances[gg].defNumber].isVisitable())
 				if (CGameInfo::mainObj->ac->map.defy[CGameInfo::mainObj->objh->objInstances[gg].defNumber].isVisitable())
 					highPrObjsVis.push_back(os);
 					highPrObjsVis.push_back(os);
 				else
 				else
@@ -347,8 +347,8 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
 			{
 			{
 				ObjSorter os;
 				ObjSorter os;
 				os.bitmap = CGameInfo::mainObj->ac->map.defy[CGameInfo::mainObj->objh->objInstances[gg].defNumber].handler->ourImages[anim%CGameInfo::mainObj->ac->map.defy[CGameInfo::mainObj->objh->objInstances[gg].defNumber].handler->ourImages.size()].bitmap;
 				os.bitmap = CGameInfo::mainObj->ac->map.defy[CGameInfo::mainObj->objh->objInstances[gg].defNumber].handler->ourImages[anim%CGameInfo::mainObj->ac->map.defy[CGameInfo::mainObj->objh->objInstances[gg].defNumber].handler->ourImages.size()].bitmap;
-				os.xpos = (CGameInfo::mainObj->objh->objInstances[gg].x-x+4)*32;
-				os.ypos = (CGameInfo::mainObj->objh->objInstances[gg].y-y+4)*32;
+				os.xpos = (CGameInfo::mainObj->objh->objInstances[gg].x-x+Woff)*32;
+				os.ypos = (CGameInfo::mainObj->objh->objInstances[gg].y-y+Hoff)*32;
 				lowPrObjs.push_back(os);
 				lowPrObjs.push_back(os);
 			}
 			}
 		}
 		}
@@ -414,7 +414,7 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
 			if (!level)
 			if (!level)
 			{
 			{
 				
 				
-				if( bx+x>3 && by+y>3 && bx+x<visibility.size()-3 && by+y<visibility[0].size()-3 && !visibility[bx+x][by+y])
+				if( bx+x>Woff-1 && by+y>Hoff-1 && bx+x<visibility.size()-(Woff-1) && by+y<visibility[0].size()-(Hoff-1) && !visibility[bx+x][by+y])
 				{
 				{
 					SDL_Surface * hide = getVisBitmap(bx+x, by+y, visibility);
 					SDL_Surface * hide = getVisBitmap(bx+x, by+y, visibility);
 					SDL_Surface * hide2 = CSDL_Ext::secondAlphaTransform(hide, su);
 					SDL_Surface * hide2 = CSDL_Ext::secondAlphaTransform(hide, su);
@@ -424,7 +424,7 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
 			}
 			}
 			else
 			else
 			{
 			{
-				if( bx+x>3 && by+y>3 && bx+x<undVisibility.size()-3 && by+y<undVisibility[0].size()-3 && !undVisibility[bx+x][by+y])
+				if( bx+x>Woff-1 && by+y>Hoff-1 && bx+x<undVisibility.size()-(Woff-1) && by+y<undVisibility[0].size()-(Hoff-1) && !undVisibility[bx+x][by+y])
 				{
 				{
 					SDL_Surface * hide = getVisBitmap(bx+x, by+y, undVisibility);
 					SDL_Surface * hide = getVisBitmap(bx+x, by+y, undVisibility);
 					SDL_Surface * hide2 = CSDL_Ext::secondAlphaTransform(hide, su);
 					SDL_Surface * hide2 = CSDL_Ext::secondAlphaTransform(hide, su);
@@ -436,6 +436,30 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
 		}
 		}
 	}
 	}
 	////shadow printed
 	////shadow printed
+	//printing borders
+	for (int bx=0; bx<dx; bx++)
+	{
+		for (int by=0; by<dy; by++)
+		{
+			if(bx+x<Woff || by+y<Hoff || bx+x>reader->map.width+(Woff-1) || by+y>reader->map.height+(Hoff-1))
+			{
+			SDL_Rect * sr = new SDL_Rect;
+			sr->y=by*32;
+			sr->x=bx*32;
+			sr->h=sr->w=32;
+			if (!level)
+			{
+				SDL_BlitSurface(terrainBitmap[bx+x][by+y],NULL,su,sr);
+			}
+			else 
+			{
+				SDL_BlitSurface(undTerrainBitmap[bx+x][by+y],NULL,su,sr);
+			}
+			delete sr;
+			}
+		}
+	}
+	//borders printed
 	return su;
 	return su;
 }
 }
 
 
@@ -650,10 +674,10 @@ SDL_Surface * CMapHandler::getVisBitmap(int x, int y, std::vector< std::vector<c
 
 
 char & CMapHandler::visAccess(int x, int y)
 char & CMapHandler::visAccess(int x, int y)
 {
 {
-	return visibility[x+4][y+4];
+	return visibility[x+Woff][y+Hoff];
 }
 }
 
 
 char & CMapHandler::undVisAccess(int x, int y)
 char & CMapHandler::undVisAccess(int x, int y)
 {
 {
-	return undVisibility[x+4][y+4];
+	return undVisibility[x+Woff][y+Hoff];
 }
 }