1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

kompleksowy błąd

This commit is contained in:
mateuszb 2007-07-07 11:09:25 +00:00
parent 9a58212847
commit 7b77d94f57
9 changed files with 475 additions and 24 deletions

View File

@ -5,6 +5,7 @@
#include "CObjectHandler.h"
#include "CCastleHandler.h"
#include "SDL_Extensions.h"
#include "boost\filesystem.hpp"
#include <set>
unsigned int intPow(unsigned int a, unsigned int b)
@ -404,8 +405,10 @@ void CAmbarCendamo::deh3m()
int samask = 0xff000000;
#endif
SDL_Surface * alphaTransSurf = SDL_CreateRGBSurface(SDL_SWSURFACE, 12, 12, 32, srmask, sgmask, sbmask, samask);
std::vector<std::string> defsToUnpack;
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;
DefInfo vinya; // info about new def
for (int cd=0;cd<nameLength;cd++)
@ -416,10 +419,22 @@ void CAmbarCendamo::deh3m()
{
vinya.bytes[v] = bufor[i++];
}
std::vector<DefObjInfo>::iterator pit = std::find(CGameInfo::mainObj->dobjinfo->objs.begin(), CGameInfo::mainObj->dobjinfo->objs.end(),
vinya.name);
if(pit == CGameInfo::mainObj->dobjinfo->objs.end())
{
vinya.isOnDefList = false;
}
else
{
vinya.printPriority = pit->priority;
vinya.isOnDefList = true;
}
map.defy.push_back(vinya); // add this def to the vector
defsToUnpack.push_back(vinya.name);
//testing - only fragment//////////////////////////////////////////////////////////////
map.defy[idd].handler = new CDefHandler();
/*map.defy[idd].handler = new CDefHandler();
CGameInfo::mainObj->lodh->extractFile(std::string("newH3sprite.lod"), map.defy[idd].name);
map.defy[idd].handler->openDef( std::string("newH3sprite\\")+map.defy[idd].name);
for(int ff=0; ff<map.defy[idd].handler->ourImages.size(); ++ff) //adding shadows and transparency
{
@ -428,10 +443,14 @@ void CAmbarCendamo::deh3m()
SDL_FreeSurface(map.defy[idd].handler->ourImages[ff].bitmap);
map.defy[idd].handler->ourImages[ff].bitmap = bufs;
}
boost::filesystem::remove(boost::filesystem::path(std::string("newH3sprite\\")+map.defy[idd].name));*/
//system((std::string("DEL newH3sprite\\")+map.defy[idd].name).c_str());
//end fo testing - only fragment///////////////////////////////////////////////////////
//teceDef();
}
std::vector<CDefHandler *> dhandlers = CGameInfo::mainObj->lodh->extractManyFiles(defsToUnpack, std::string("newh3sprite.lod"));
std::cout<<'\r'<<"Reading defs: 100% "<<std::endl;
SDL_FreeSurface(alphaTransSurf);
THC std::cout<<"Wczytywanie defow: "<<th.getDif()<<std::endl;
////loading objects

Binary file not shown.

Binary file not shown.

View File

@ -12,6 +12,7 @@
#include "CMusicHandler.h"
#include "CSemiLodHandler.h"
#include "CDefObjInfoHandler.h"
#include "CLodHandler.h"
/*
CGameInfo class
@ -32,6 +33,7 @@ public:
CMusicHandler * mush;
CSemiLodHandler * sspriteh;
CDefObjInfoHandler * dobjinfo;
CLodHandler * lodh;
};
#endif //CGAMEINFO_H

View File

@ -1,6 +1,8 @@
#include "stdafx.h"
#include "CLodHandler.h"
#include <sstream>
#include <algorithm>
#include <cstring>
int readNormalNr (int pos, int bytCon, unsigned char * str)
@ -165,7 +167,7 @@ void CPCXConv::convert()
// FTemp.Free;
// Result:=True;
//end;
int CLodHandler::decompress (unsigned char * source, int size, int realSize, std::ofstream & dest)
/*int CLodHandler::decompress (unsigned char * source, int size, int realSize, std::ofstream & dest)
{
std::ofstream lb;
lb.open("lodbuf\\buf.gz", std::ios::out|std::ios::binary);
@ -181,8 +183,12 @@ int CLodHandler::decompress (unsigned char * source, int size, int realSize, std
int ret = infm(inputf, outputf);
fclose(inputf);
fclose(outputf);
std::stringstream sin;
//for()
int ret = infs(sin, dest);
return ret;
}
} */
int CLodHandler::decompress (unsigned char * source, int size, int realSize, std::string & dest)
{
@ -265,6 +271,297 @@ int CLodHandler::infm(FILE *source, FILE *dest, int wBits)
return ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR;
}
std::vector<CDefHandler *> CLodHandler::extractManyFiles(std::vector<std::string> defNamesIn, std::string lodName)
{
std::vector<CDefHandler *> ret(defNamesIn.size());
for(int hh=0; hh<defNamesIn.size(); ++hh)
{
std::transform(defNamesIn[hh].begin(), defNamesIn[hh].end(), defNamesIn[hh].begin(), (int(*)(int))toupper);
}
std::ifstream FLOD;
std::ofstream FOut;
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::cout<<" done\n";
//std::transform(name.begin(), name.end(), name.begin(), (int(*)(int))toupper);
std::vector<char> found(defNamesIn.size(), 0);
for (int i=0;i<totalFiles;i++)
{
std::string buf1 = std::string((char*)entries[i].name);
std::transform(buf1.begin(), buf1.end(), buf1.begin(), (int(*)(int))toupper);
bool exists = false;
int curDef;
for(int hh=0; hh<defNamesIn.size(); ++hh)
{
if(buf1==defNamesIn[hh])
{
exists = true;
found[hh] = '\1';
curDef = hh;
break;
}
}
if(!exists)
continue;
FLOD.seekg(entries[i].offset,std::ios_base::beg);
std::string bufff = (lodName.substr(0, lodName.size()-4) + "\\" + (char*)entries[i].name);
unsigned char * outp;
if (entries[i].size==0) //file is not compressed
{
outp = new unsigned char[entries[i].realSize];
FLOD.read((char*)outp, entries[i].realSize);
/*std::ofstream out;
out.open(bufff.c_str(), std::ios::binary);
if(!out.is_open())
{
std::cout<<"Unable to create "<<bufff;
}
else
{
for(int hh=0; hh<entries[i].realSize; ++hh)
{
out<<*(outp+hh);
}
out.close();
}*/
CDefHandler * nh = new CDefHandler;
nh->openFromMemory(outp, entries[i].realSize, std::string((char*)entries[i].name));
ret[curDef] = nh;
}
else //we will decompressing file
{
outp = new unsigned char[entries[i].size];
FLOD.read((char*)outp, entries[i].size);
FLOD.seekg(0, std::ios_base::beg);
/*std::ofstream destin;
destin.open(bufff.c_str(), std::ios::binary);
//int decRes = decompress(outp, entries[i].size, entries[i].realSize, bufff);
int decRes = infs(outp, entries[i].size, entries[i].realSize, destin);
destin.close();
if(decRes!=0)
{
std::cout<<"LOD Extraction error"<<" "<<decRes<<" while extracting to "<<bufff<<std::endl;
}*/
unsigned char * decomp = NULL;
int decRes = infs2(outp, entries[i].size, entries[i].realSize, decomp);
CDefHandler * nh = new CDefHandler;
nh->openFromMemory(decomp, entries[i].realSize, std::string((char*)entries[i].name));
ret[curDef] = nh;
//delete decomp;
}
//for (int j=0; j<entries[i].size; j++)
// FOut << outp[j];
//FOut.flush();
delete outp;
//FOut.close();
//std::cout<<"*** done\n";
}
//TODO: przypisywanie defhandlerów powtarzaj¹cym siê defom
FLOD.close();
//std::cout<<"*** Archive: "+FName+" closed\n";
return ret;
}
int CLodHandler::infs(unsigned char * in, int size, int realSize, std::ofstream & out, int wBits)
{
int ret;
unsigned have;
z_stream strm;
unsigned char inx[NLoadHandlerHelp::fCHUNK];
unsigned char outx[NLoadHandlerHelp::fCHUNK];
/* 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;
int chunkNumber = 0;
do
{
int readBytes = 0;
for(int i=0; i<NLoadHandlerHelp::fCHUNK && (chunkNumber * NLoadHandlerHelp::fCHUNK + i)<size; ++i)
{
inx[i] = in[chunkNumber * NLoadHandlerHelp::fCHUNK + i];
++readBytes;
}
++chunkNumber;
strm.avail_in = readBytes;
//strm.avail_in = fread(inx, 1, NLoadHandlerHelp::fCHUNK, source);
/*if (in.bad())
{
(void)inflateEnd(&strm);
return Z_ERRNO;
}*/
if (strm.avail_in == 0)
break;
strm.next_in = inx;
/* run inflate() on input until output buffer not full */
do
{
strm.avail_out = NLoadHandlerHelp::fCHUNK;
strm.next_out = outx;
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 = NLoadHandlerHelp::fCHUNK - strm.avail_out;
/*if (fwrite(out, 1, have, dest) != have || ferror(dest))
{
(void)inflateEnd(&strm);
return Z_ERRNO;
}*/
out.write((char*)outx, have);
if(out.bad())
{
(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 CLodHandler::infs2(unsigned char * in, int size, int realSize, unsigned char *& out, int wBits)
{
int ret;
unsigned have;
z_stream strm;
unsigned char inx[NLoadHandlerHelp::fCHUNK];
unsigned char outx[NLoadHandlerHelp::fCHUNK];
out = new unsigned char [size];
int latPosOut = 0;
/* 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;
int chunkNumber = 0;
do
{
int readBytes = 0;
for(int i=0; i<NLoadHandlerHelp::fCHUNK && (chunkNumber * NLoadHandlerHelp::fCHUNK + i)<size; ++i)
{
inx[i] = in[chunkNumber * NLoadHandlerHelp::fCHUNK + i];
++readBytes;
}
++chunkNumber;
strm.avail_in = readBytes;
//strm.avail_in = fread(inx, 1, NLoadHandlerHelp::fCHUNK, source);
/*if (in.bad())
{
(void)inflateEnd(&strm);
return Z_ERRNO;
}*/
if (strm.avail_in == 0)
break;
strm.next_in = inx;
/* run inflate() on input until output buffer not full */
do
{
strm.avail_out = NLoadHandlerHelp::fCHUNK;
strm.next_out = outx;
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 = NLoadHandlerHelp::fCHUNK - strm.avail_out;
/*if (fwrite(out, 1, have, dest) != have || ferror(dest))
{
(void)inflateEnd(&strm);
return Z_ERRNO;
}*/
//out.write((char*)outx, have);
for(int oo=0; oo<have; ++oo)
{
out[latPosOut] = outx[oo];
++latPosOut;
}
/*if(out.bad())
{
(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;
}
void CLodHandler::extract(std::string FName)
{
std::ifstream FLOD;
@ -341,7 +638,113 @@ void CLodHandler::extract(std::string FName)
outp = new unsigned char[entries[i].size];
FLOD.read((char*)outp, entries[i].size);
FLOD.seekg(0, std::ios_base::beg);
int decRes = decompress(outp, entries[i].size, entries[i].realSize, bufff);
std::ofstream destin;
destin.open(bufff.c_str(), std::ios::binary);
//int decRes = decompress(outp, entries[i].size, entries[i].realSize, bufff);
int decRes = infs(outp, entries[i].size, entries[i].realSize, destin);
destin.close();
if(decRes!=0)
{
std::cout<<"LOD Extraction error"<<" "<<decRes<<" while extracting to "<<bufff<<std::endl;
}
}
//for (int j=0; j<entries[i].size; j++)
// FOut << outp[j];
//FOut.flush();
delete outp;
//FOut.close();
//std::cout<<"*** done\n";
}
FLOD.close();
//std::cout<<"*** Archive: "+FName+" closed\n";
}
void CLodHandler::extractFile(std::string FName, std::string name)
{
std::ifstream FLOD;
std::ofstream FOut;
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::transform(name.begin(), name.end(), name.begin(), (int(*)(int))toupper);
for (int i=0;i<totalFiles;i++)
{
std::string buf1 = std::string((char*)entries[i].name);
std::transform(buf1.begin(), buf1.end(), buf1.begin(), (int(*)(int))toupper);
if(buf1!=name)
continue;
FLOD.seekg(entries[i].offset,std::ios_base::beg);
std::string bufff = (FName.substr(0, FName.size()-4) + "\\" + (char*)entries[i].name);
unsigned char * outp;
if (entries[i].size==0) //file is not compressed
{
outp = new unsigned char[entries[i].realSize];
FLOD.read((char*)outp, entries[i].realSize);
std::ofstream out;
out.open(bufff.c_str(), std::ios::binary);
if(!out.is_open())
{
std::cout<<"Unable to create "<<bufff;
}
else
{
for(int hh=0; hh<entries[i].realSize; ++hh)
{
out<<*(outp+hh);
}
out.close();
}
}
else //we will decompressing file
{
outp = new unsigned char[entries[i].size];
FLOD.read((char*)outp, entries[i].size);
FLOD.seekg(0, std::ios_base::beg);
std::ofstream destin;
destin.open(bufff.c_str(), std::ios::binary);
//int decRes = decompress(outp, entries[i].size, entries[i].realSize, bufff);
int decRes = infs(outp, entries[i].size, entries[i].realSize, destin);
destin.close();
if(decRes!=0)
{
std::cout<<"LOD Extraction error"<<" "<<decRes<<" while extracting to "<<bufff<<std::endl;

View File

@ -22,9 +22,16 @@ struct Entry
unsigned char name[12], //filename
hlam_1[4], //
hlam_2[4]; //
std::string nameStr;
int offset, //from beginning
realSize, //size without compression
size; //and with
bool operator<(const Entry & comp) const
{
return this->nameStr<comp.nameStr;
}
Entry(std::string con): nameStr(con){};
Entry(){};
};
class CPCXConv
{
@ -49,7 +56,11 @@ public:
int decompress (unsigned char * source, int size, int realSize, std::ofstream & dest); //main decompression function
int decompress (unsigned char * source, int size, int realSize, std::string & dest); //main decompression function
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 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
void extract(std::string FName);
void extractFile(std::string FName, std::string name);
void init(std::string lodFile);
};

View File

@ -281,8 +281,8 @@ int _tmain(int argc, _TCHAR* argv[])
//CLodHandler * test = new CLodHandler;
//test->init(std::string("h3abp_bm.lod"));
CDefHandler * tdef = new CDefHandler;
tdef->openDef(std::string("newh3sprite\\AVLSPTR3.DEF"));
//CDefHandler * tdef = new CDefHandler;
//tdef->openDef(std::string("newh3sprite\\AVLSPTR3.DEF"));
//tdef->getSprite(0);
//CLodHandler * bitmapLod = new CLodHandler;
@ -293,8 +293,8 @@ int _tmain(int argc, _TCHAR* argv[])
//tconv->convert();
//tconv->saveBMP(std::string("tesciczekConva.bmp"));
CSemiDefHandler * semek = new CSemiDefHandler;
semek->openDef(std::string("EDG.DEF"), std::string("H3sprite.lod"));
//CSemiDefHandler * semek = new CSemiDefHandler;
//semek->openDef(std::string("EDG.DEF"), std::string("H3sprite.lod"));
//////////////////////////////////////////////////////////////////////////////// lod testing end
@ -323,6 +323,7 @@ int _tmain(int argc, _TCHAR* argv[])
cgi->objh = objh;
cgi->dobjinfo = new CDefObjInfoHandler;
cgi->dobjinfo->load();
cgi->lodh = new CLodHandler;
THC std::cout<<"Inicjalizacja wszelakich handlerow: "<<tmh.getDif()<<std::endl;
std::string mapname;

2
map.h
View File

@ -59,6 +59,8 @@ struct DefInfo //information from def declaration
int bytes [42];
//CSemiDefHandler * handler;
CDefHandler * handler;
int printPriority;
bool isOnDefList;
bool isVisitable();
};
struct Location

View File

@ -23,7 +23,7 @@ class poX
public:
bool operator()(const ObjSorter & por2, const ObjSorter & por) const
{
if(por2.xpos>=por.xpos)
if(por2.xpos<=por.xpos)
return false;
return true;
};
@ -319,9 +319,15 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
{
if(CGameInfo::mainObj->objh->objInstances[gg].x >= x-Woff-4 && CGameInfo::mainObj->objh->objInstances[gg].x < dx+x-Hoff+4 && CGameInfo::mainObj->objh->objInstances[gg].y >= y-Hoff-4 && CGameInfo::mainObj->objh->objInstances[gg].y < dy+y-Hoff+4 && CGameInfo::mainObj->objh->objInstances[gg].z == level)
{
std::vector<DefObjInfo>::iterator pit = std::find(CGameInfo::mainObj->dobjinfo->objs.begin(), CGameInfo::mainObj->dobjinfo->objs.end(),
CGameInfo::mainObj->ac->map.defy[CGameInfo::mainObj->objh->objInstances[gg].defNumber].name);
if(pit->priority==0)
if(!CGameInfo::mainObj->ac->map.defy[CGameInfo::mainObj->objh->objInstances[gg].defNumber].isOnDefList)
{
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.xpos = (CGameInfo::mainObj->objh->objInstances[gg].x-x+4)*32;
os.ypos = (CGameInfo::mainObj->objh->objInstances[gg].y-y+4)*32;
highPrObjsVis.push_back(os);
}
else if(CGameInfo::mainObj->ac->map.defy[CGameInfo::mainObj->objh->objInstances[gg].defNumber].printPriority==0)
{
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;
@ -342,11 +348,12 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
}
}
}
//std::stable_sort(lowPrObjs.begin(), lowPrObjs.end());
std::stable_sort(highPrObjs.begin(), highPrObjs.end(),pox);
std::stable_sort(highPrObjs.begin(), highPrObjs.end(),poy);
std::stable_sort(highPrObjsVis.begin(), highPrObjsVis.end(),pox);
std::stable_sort(highPrObjsVis.begin(), highPrObjsVis.end(),poy);
//std::stable_sort(lowPrObjs.begin(), lowPrObjs.end(), pox);
//std::stable_sort(lowPrObjs.begin(), lowPrObjs.end(), poy);
//std::stable_sort(highPrObjs.begin(), highPrObjs.end(),pox);
//std::stable_sort(highPrObjs.begin(), highPrObjs.end(),poy);
//std::stable_sort(highPrObjsVis.begin(), highPrObjsVis.end(),pox);
//std::stable_sort(highPrObjsVis.begin(), highPrObjsVis.end(),poy);
for(int yy=0; yy<lowPrObjs.size(); ++yy)
{
SDL_Rect * sr = new SDL_Rect;
@ -461,23 +468,28 @@ SDL_Surface * CMapHandler::getVisBitmap(int x, int y, std::vector< std::vector<c
}
else if(!visibility[x][y+1] && !visibility[x+1][y] && !visibility[x-1][y] && visibility[x][y-1] && visibility[x-1][y-1] && !visibility[x+1][y+1] && visibility[x+1][y-1] && !visibility[x-1][y+1])
{
return partialHide->ourImages[rand()%2].bitmap; //visible top
//return partialHide->ourImages[rand()%2].bitmap; //visible top
return partialHide->ourImages[0].bitmap; //visible top
}
else if(visibility[x][y+1] && !visibility[x+1][y] && !visibility[x-1][y] && !visibility[x][y-1] && !visibility[x-1][y-1] && visibility[x+1][y+1] && !visibility[x+1][y-1] && visibility[x-1][y+1])
{
return partialHide->ourImages[4+rand()%2].bitmap; //visble bottom
//return partialHide->ourImages[4+rand()%2].bitmap; //visble bottom
return partialHide->ourImages[4].bitmap; //visble bottom
}
else if(!visibility[x][y+1] && !visibility[x+1][y] && visibility[x-1][y] && !visibility[x][y-1] && visibility[x-1][y-1] && !visibility[x+1][y+1] && !visibility[x+1][y-1] && visibility[x-1][y+1])
{
return CSDL_Ext::rotate01(partialHide->ourImages[2+rand()%2].bitmap); //visible left
//return CSDL_Ext::rotate01(partialHide->ourImages[2+rand()%2].bitmap); //visible left
return CSDL_Ext::rotate01(partialHide->ourImages[2].bitmap); //visible left
}
else if(!visibility[x][y+1] && visibility[x+1][y] && !visibility[x-1][y] && !visibility[x][y-1] && !visibility[x-1][y-1] && visibility[x+1][y+1] && visibility[x+1][y-1] && !visibility[x-1][y+1])
{
return partialHide->ourImages[2+rand()%2].bitmap; //visible right
//return partialHide->ourImages[2+rand()%2].bitmap; //visible right
return partialHide->ourImages[2].bitmap; //visible right
}
else if(visibility[x][y+1] && visibility[x+1][y] && !visibility[x-1][y] && !visibility[x][y-1] && !visibility[x-1][y-1])
{
return partialHide->ourImages[12+2*(rand()%2)].bitmap; //visible bottom, right - bottom, right; left top corner hidden
//return partialHide->ourImages[12+2*(rand()%2)].bitmap; //visible bottom, right - bottom, right; left top corner hidden
return partialHide->ourImages[12].bitmap; //visible bottom, right - bottom, right; left top corner hidden
}
else if(!visibility[x][y+1] && visibility[x+1][y] && !visibility[x-1][y] && visibility[x][y-1] && !visibility[x-1][y+1])
{
@ -489,7 +501,8 @@ SDL_Surface * CMapHandler::getVisBitmap(int x, int y, std::vector< std::vector<c
}
else if(visibility[x][y+1] && !visibility[x+1][y] && visibility[x-1][y] && !visibility[x][y-1] && !visibility[x+1][y-1])
{
return CSDL_Ext::rotate01(partialHide->ourImages[12+2*(rand()%2)].bitmap); //visible left, left - bottom, bottom; right top corner hidden
//return CSDL_Ext::rotate01(partialHide->ourImages[12+2*(rand()%2)].bitmap); //visible left, left - bottom, bottom; right top corner hidden
return CSDL_Ext::rotate01(partialHide->ourImages[12].bitmap); //visible left, left - bottom, bottom; right top corner hidden
}
else if(visibility[x][y+1] && visibility[x+1][y] && visibility[x-1][y] && visibility[x][y-1] && visibility[x-1][y-1] && visibility[x+1][y+1] && visibility[x+1][y-1] && visibility[x-1][y+1])
{