mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
bugfix and speedup
This commit is contained in:
parent
86b8c16f0a
commit
315f92ef14
@ -310,11 +310,11 @@ void CHeroWindow::quit()
|
|||||||
|
|
||||||
SDL_FreeSurface(curBack);
|
SDL_FreeSurface(curBack);
|
||||||
curBack = NULL;
|
curBack = NULL;
|
||||||
for(int v=0; v<LOCPLINT->lclickable.size(); ++v)
|
/*for(int v=0; v<LOCPLINT->lclickable.size(); ++v)
|
||||||
{
|
{
|
||||||
if(dynamic_cast<CArtPlace*>(LOCPLINT->lclickable[v]))
|
if(dynamic_cast<CArtPlace*>(LOCPLINT->lclickable[v]))
|
||||||
LOCPLINT->lclickable.erase(LOCPLINT->lclickable.begin()+v);
|
LOCPLINT->lclickable.erase(LOCPLINT->lclickable.begin()+v);
|
||||||
}
|
}*/
|
||||||
portraitArea->deactivate();
|
portraitArea->deactivate();
|
||||||
|
|
||||||
delete artFeet;
|
delete artFeet;
|
||||||
@ -673,17 +673,25 @@ void CHeroWindow::redrawCurBack()
|
|||||||
CSDL_Ext::printAt(manastr.str(), 212, 247, GEOR16, zwykly, curBack);
|
CSDL_Ext::printAt(manastr.str(), 212, 247, GEOR16, zwykly, curBack);
|
||||||
}
|
}
|
||||||
|
|
||||||
CArtPlace::CArtPlace(CArtifact *art): ourArt(art){}
|
CArtPlace::CArtPlace(CArtifact *art): ourArt(art), active(false){}
|
||||||
void CArtPlace::activate()
|
void CArtPlace::activate()
|
||||||
{
|
{
|
||||||
|
if(!active)
|
||||||
|
{
|
||||||
ClickableL::activate();
|
ClickableL::activate();
|
||||||
|
active = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void CArtPlace::clickLeft(boost::logic::tribool down)
|
void CArtPlace::clickLeft(boost::logic::tribool down)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
void CArtPlace::deactivate()
|
void CArtPlace::deactivate()
|
||||||
{
|
{
|
||||||
|
if(active)
|
||||||
|
{
|
||||||
|
active = false;
|
||||||
ClickableL::deactivate();
|
ClickableL::deactivate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void CArtPlace::show(SDL_Surface *to)
|
void CArtPlace::show(SDL_Surface *to)
|
||||||
{
|
{
|
||||||
@ -694,7 +702,7 @@ void CArtPlace::show(SDL_Surface *to)
|
|||||||
}
|
}
|
||||||
CArtPlace::~CArtPlace()
|
CArtPlace::~CArtPlace()
|
||||||
{
|
{
|
||||||
ClickableL::deactivate();
|
deactivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LClickableArea::activate()
|
void LClickableArea::activate()
|
||||||
|
@ -25,6 +25,8 @@ public:
|
|||||||
|
|
||||||
class CArtPlace: public ClickableL, public IShowable
|
class CArtPlace: public ClickableL, public IShowable
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
|
bool active;
|
||||||
public:
|
public:
|
||||||
const CArtifact * ourArt;
|
const CArtifact * ourArt;
|
||||||
CArtPlace(CArtifact * art);
|
CArtPlace(CArtifact * art);
|
||||||
|
@ -167,7 +167,6 @@ SDL_Surface * CPCXConv::getSurface()
|
|||||||
SDL_Surface * ret;
|
SDL_Surface * ret;
|
||||||
|
|
||||||
BMPHeader bh;
|
BMPHeader bh;
|
||||||
BMPPalette pal[256];
|
|
||||||
Epcxformat format;
|
Epcxformat format;
|
||||||
int fSize,i,y;
|
int fSize,i,y;
|
||||||
bool check1, check2;
|
bool check1, check2;
|
||||||
@ -209,23 +208,12 @@ SDL_Surface * CPCXConv::getSurface()
|
|||||||
{
|
{
|
||||||
it = pcxs-256*3;
|
it = pcxs-256*3;
|
||||||
for (int i=0;i<256;i++)
|
for (int i=0;i<256;i++)
|
||||||
{
|
|
||||||
pal[i].R=pcx[it++];
|
|
||||||
pal[i].G=pcx[it++];
|
|
||||||
pal[i].B=pcx[it++];
|
|
||||||
pal[i].F='\0';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (format==PCX8B)
|
|
||||||
{
|
|
||||||
|
|
||||||
for(int i=0; i<256; ++i)
|
|
||||||
{
|
{
|
||||||
SDL_Color tp;
|
SDL_Color tp;
|
||||||
tp.r = pal[i].R;
|
tp.r = pcx[it++];
|
||||||
tp.g = pal[i].G;
|
tp.g = pcx[it++];
|
||||||
tp.b = pal[i].B;
|
tp.b = pcx[it++];
|
||||||
tp.unused = pal[i].F;
|
tp.unused = 0;
|
||||||
*(ret->format->palette->colors+i) = tp;
|
*(ret->format->palette->colors+i) = tp;
|
||||||
}
|
}
|
||||||
for (y=bh.y;y>0;y--)
|
for (y=bh.y;y>0;y--)
|
||||||
@ -283,16 +271,16 @@ SDL_Surface * CLodHandler::loadBitmap(std::string fname)
|
|||||||
{
|
{
|
||||||
std::cout<<"File "<<fname<<" not found"<<std::endl;
|
std::cout<<"File "<<fname<<" not found"<<std::endl;
|
||||||
}
|
}
|
||||||
FLOD.seekg(entries[index].offset,std::ios_base::beg);
|
fseek(FLOD, entries[index].offset, 0);
|
||||||
if (entries[index].size==0) //file is not compressed
|
if (entries[index].size==0) //file is not compressed
|
||||||
{
|
{
|
||||||
pcx = new unsigned char[entries[index].realSize];
|
pcx = new unsigned char[entries[index].realSize];
|
||||||
FLOD.read((char*)pcx,entries[index].realSize);
|
fread((char*)pcx, 1, entries[index].realSize, FLOD);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
unsigned char * pcd = new unsigned char[entries[index].size];
|
unsigned char * pcd = new unsigned char[entries[index].size];
|
||||||
FLOD.read((char*)pcd,entries[index].size);
|
fread((char*)pcd, 1, entries[index].size, FLOD);
|
||||||
int res=infs2(pcd,entries[index].size,entries[index].realSize,pcx);
|
int res=infs2(pcd,entries[index].size,entries[index].realSize,pcx);
|
||||||
if(res!=0)
|
if(res!=0)
|
||||||
{
|
{
|
||||||
@ -389,12 +377,12 @@ CDefHandler * CLodHandler::giveDef(std::string defName)
|
|||||||
std::transform(defName.begin(), defName.end(), defName.begin(), (int(*)(int))toupper);
|
std::transform(defName.begin(), defName.end(), defName.begin(), (int(*)(int))toupper);
|
||||||
Entry * ourEntry = entries.znajdz(Entry(defName));
|
Entry * ourEntry = entries.znajdz(Entry(defName));
|
||||||
CDefHandler * ret;
|
CDefHandler * ret;
|
||||||
FLOD.seekg(ourEntry->offset,std::ios_base::beg);
|
fseek(FLOD, ourEntry->offset, 0);
|
||||||
unsigned char * outp;
|
unsigned char * outp;
|
||||||
if (ourEntry->size==0) //file is not compressed
|
if (ourEntry->size==0) //file is not compressed
|
||||||
{
|
{
|
||||||
outp = new unsigned char[ourEntry->realSize];
|
outp = new unsigned char[ourEntry->realSize];
|
||||||
FLOD.read((char*)outp, ourEntry->realSize);
|
fread((char*)outp, 1, ourEntry->realSize, FLOD);
|
||||||
CDefHandler * nh = new CDefHandler;
|
CDefHandler * nh = new CDefHandler;
|
||||||
nh->openFromMemory(outp, ourEntry->realSize, std::string((char*)ourEntry->name));
|
nh->openFromMemory(outp, ourEntry->realSize, std::string((char*)ourEntry->name));
|
||||||
nh->alphaTransformed = false;
|
nh->alphaTransformed = false;
|
||||||
@ -403,8 +391,8 @@ CDefHandler * CLodHandler::giveDef(std::string defName)
|
|||||||
else //we will decompress file
|
else //we will decompress file
|
||||||
{
|
{
|
||||||
outp = new unsigned char[ourEntry->size];
|
outp = new unsigned char[ourEntry->size];
|
||||||
FLOD.read((char*)outp, ourEntry->size);
|
fread((char*)outp, 1, ourEntry->size, FLOD);
|
||||||
FLOD.seekg(0, std::ios_base::beg);
|
fseek(FLOD, 0, 0);
|
||||||
unsigned char * decomp = NULL;
|
unsigned char * decomp = NULL;
|
||||||
int decRes = infs2(outp, ourEntry->size, ourEntry->realSize, decomp);
|
int decRes = infs2(outp, ourEntry->size, ourEntry->realSize, decomp);
|
||||||
CDefHandler * nh = new CDefHandler;
|
CDefHandler * nh = new CDefHandler;
|
||||||
@ -451,12 +439,12 @@ std::vector<CDefHandler *> CLodHandler::extractManyFiles(std::vector<std::string
|
|||||||
}
|
}
|
||||||
if(!exists)
|
if(!exists)
|
||||||
continue;
|
continue;
|
||||||
FLOD.seekg(entries[i].offset,std::ios_base::beg);
|
fseek(FLOD, entries[i].offset, 0);
|
||||||
unsigned char * outp;
|
unsigned char * outp;
|
||||||
if (entries[i].size==0) //file is not compressed
|
if (entries[i].size==0) //file is not compressed
|
||||||
{
|
{
|
||||||
outp = new unsigned char[entries[i].realSize];
|
outp = new unsigned char[entries[i].realSize];
|
||||||
FLOD.read((char*)outp, entries[i].realSize);
|
fread((char*)outp, 1, entries[i].realSize, FLOD);
|
||||||
CDefHandler * nh = new CDefHandler;
|
CDefHandler * nh = new CDefHandler;
|
||||||
nh->openFromMemory(outp, entries[i].realSize, std::string((char*)entries[i].name));
|
nh->openFromMemory(outp, entries[i].realSize, std::string((char*)entries[i].name));
|
||||||
nh->alphaTransformed = false;
|
nh->alphaTransformed = false;
|
||||||
@ -465,8 +453,8 @@ std::vector<CDefHandler *> CLodHandler::extractManyFiles(std::vector<std::string
|
|||||||
else //we will decompressing file
|
else //we will decompressing file
|
||||||
{
|
{
|
||||||
outp = new unsigned char[entries[i].size];
|
outp = new unsigned char[entries[i].size];
|
||||||
FLOD.read((char*)outp, entries[i].size);
|
fread((char*)outp, 1, entries[i].size, FLOD);
|
||||||
FLOD.seekg(0, std::ios_base::beg);
|
fseek(FLOD, 0, 0);
|
||||||
unsigned char * decomp = NULL;
|
unsigned char * decomp = NULL;
|
||||||
int decRes = infs2(outp, entries[i].size, entries[i].realSize, decomp);
|
int decRes = infs2(outp, entries[i].size, entries[i].realSize, decomp);
|
||||||
CDefHandler * nh = new CDefHandler;
|
CDefHandler * nh = new CDefHandler;
|
||||||
@ -661,13 +649,13 @@ void CLodHandler::extract(std::string FName)
|
|||||||
//std::cout<<" done\n";
|
//std::cout<<" done\n";
|
||||||
for (int i=0;i<totalFiles;i++)
|
for (int i=0;i<totalFiles;i++)
|
||||||
{
|
{
|
||||||
FLOD.seekg(entries[i].offset,std::ios_base::beg);
|
fseek(FLOD, entries[i].offset, 0);
|
||||||
std::string bufff = (FName.substr(0, FName.size()-4) + "\\" + (char*)entries[i].name);
|
std::string bufff = (FName.substr(0, FName.size()-4) + "\\" + (char*)entries[i].name);
|
||||||
unsigned char * outp;
|
unsigned char * outp;
|
||||||
if (entries[i].size==0) //file is not compressed
|
if (entries[i].size==0) //file is not compressed
|
||||||
{
|
{
|
||||||
outp = new unsigned char[entries[i].realSize];
|
outp = new unsigned char[entries[i].realSize];
|
||||||
FLOD.read((char*)outp, entries[i].realSize);
|
fread((char*)outp, 1, entries[i].realSize, FLOD);
|
||||||
std::ofstream out;
|
std::ofstream out;
|
||||||
out.open(bufff.c_str(), std::ios::binary);
|
out.open(bufff.c_str(), std::ios::binary);
|
||||||
if(!out.is_open())
|
if(!out.is_open())
|
||||||
@ -686,8 +674,8 @@ void CLodHandler::extract(std::string FName)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
outp = new unsigned char[entries[i].size];
|
outp = new unsigned char[entries[i].size];
|
||||||
FLOD.read((char*)outp, entries[i].size);
|
fread((char*)outp, 1, entries[i].size, FLOD);
|
||||||
FLOD.seekg(0, std::ios_base::beg);
|
fseek(FLOD, 0, 0);
|
||||||
std::ofstream destin;
|
std::ofstream destin;
|
||||||
destin.open(bufff.c_str(), std::ios::binary);
|
destin.open(bufff.c_str(), std::ios::binary);
|
||||||
//int decRes = decompress(outp, entries[i].size, entries[i].realSize, bufff);
|
//int decRes = decompress(outp, entries[i].size, entries[i].realSize, bufff);
|
||||||
@ -700,7 +688,7 @@ void CLodHandler::extract(std::string FName)
|
|||||||
}
|
}
|
||||||
delete[] outp;
|
delete[] outp;
|
||||||
}
|
}
|
||||||
FLOD.close();
|
fclose(FLOD);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLodHandler::extractFile(std::string FName, std::string name)
|
void CLodHandler::extractFile(std::string FName, std::string name)
|
||||||
@ -712,13 +700,13 @@ void CLodHandler::extractFile(std::string FName, std::string name)
|
|||||||
std::transform(buf1.begin(), buf1.end(), buf1.begin(), (int(*)(int))toupper);
|
std::transform(buf1.begin(), buf1.end(), buf1.begin(), (int(*)(int))toupper);
|
||||||
if(buf1!=name)
|
if(buf1!=name)
|
||||||
continue;
|
continue;
|
||||||
FLOD.seekg(entries[i].offset,std::ios_base::beg);
|
fseek(FLOD, entries[i].offset, 0);
|
||||||
std::string bufff = (FName.substr(0, FName.size()-4) + "\\" + (char*)entries[i].name);
|
std::string bufff = (FName.substr(0, FName.size()-4) + "\\" + (char*)entries[i].name);
|
||||||
unsigned char * outp;
|
unsigned char * outp;
|
||||||
if (entries[i].size==0) //file is not compressed
|
if (entries[i].size==0) //file is not compressed
|
||||||
{
|
{
|
||||||
outp = new unsigned char[entries[i].realSize];
|
outp = new unsigned char[entries[i].realSize];
|
||||||
FLOD.read((char*)outp, entries[i].realSize);
|
fread((char*)outp, 1, entries[i].realSize, FLOD);
|
||||||
std::ofstream out;
|
std::ofstream out;
|
||||||
out.open(bufff.c_str(), std::ios::binary);
|
out.open(bufff.c_str(), std::ios::binary);
|
||||||
if(!out.is_open())
|
if(!out.is_open())
|
||||||
@ -737,8 +725,8 @@ void CLodHandler::extractFile(std::string FName, std::string name)
|
|||||||
else //we will decompressing file
|
else //we will decompressing file
|
||||||
{
|
{
|
||||||
outp = new unsigned char[entries[i].size];
|
outp = new unsigned char[entries[i].size];
|
||||||
FLOD.read((char*)outp, entries[i].size);
|
fread((char*)outp, 1, entries[i].size, FLOD);
|
||||||
FLOD.seekg(0, std::ios_base::beg);
|
fseek(FLOD, 0, 0);
|
||||||
std::ofstream destin;
|
std::ofstream destin;
|
||||||
destin.open(bufff.c_str(), std::ios::binary);
|
destin.open(bufff.c_str(), std::ios::binary);
|
||||||
//int decRes = decompress(outp, entries[i].size, entries[i].realSize, bufff);
|
//int decRes = decompress(outp, entries[i].size, entries[i].realSize, bufff);
|
||||||
@ -751,7 +739,7 @@ void CLodHandler::extractFile(std::string FName, std::string name)
|
|||||||
}
|
}
|
||||||
delete[] outp;
|
delete[] outp;
|
||||||
}
|
}
|
||||||
FLOD.close();
|
fclose(FLOD);
|
||||||
}
|
}
|
||||||
|
|
||||||
int CLodHandler::readNormalNr (unsigned char* bufor, int bytCon, bool cyclic)
|
int CLodHandler::readNormalNr (unsigned char* bufor, int bytCon, bool cyclic)
|
||||||
@ -773,12 +761,12 @@ int CLodHandler::readNormalNr (unsigned char* bufor, int bytCon, bool cyclic)
|
|||||||
void CLodHandler::init(std::string lodFile)
|
void CLodHandler::init(std::string lodFile)
|
||||||
{
|
{
|
||||||
std::string Ts;
|
std::string Ts;
|
||||||
FLOD.open(lodFile.c_str(),std::ios::binary);
|
FLOD = fopen(lodFile.c_str(), "rb");
|
||||||
FLOD.seekg(8,std::ios_base::beg);
|
fseek(FLOD, 8, 0);
|
||||||
unsigned char temp[4];
|
unsigned char temp[4];
|
||||||
FLOD.read((char*)temp,4);
|
fread((char*)temp, 1, 4, FLOD);
|
||||||
totalFiles = readNormalNr(temp,4);
|
totalFiles = readNormalNr(temp,4);
|
||||||
FLOD.seekg(0x5c,std::ios_base::beg);
|
fseek(FLOD, 0x5c, 0);
|
||||||
for (int i=0; i<totalFiles; i++)
|
for (int i=0; i<totalFiles; i++)
|
||||||
{
|
{
|
||||||
Entry entry;
|
Entry entry;
|
||||||
@ -786,7 +774,8 @@ void CLodHandler::init(std::string lodFile)
|
|||||||
bool appending = true;
|
bool appending = true;
|
||||||
for(int kk=0; kk<12; ++kk)
|
for(int kk=0; kk<12; ++kk)
|
||||||
{
|
{
|
||||||
FLOD.read(bufc, 1);
|
//FLOD.read(bufc, 1);
|
||||||
|
fread(bufc, 1, 1, FLOD);
|
||||||
if(appending)
|
if(appending)
|
||||||
{
|
{
|
||||||
entry.name[kk] = toupper(*bufc);
|
entry.name[kk] = toupper(*bufc);
|
||||||
@ -798,13 +787,13 @@ void CLodHandler::init(std::string lodFile)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete bufc;
|
delete bufc;
|
||||||
FLOD.read((char*)entry.hlam_1,4);
|
fread((char*)entry.hlam_1, 1, 4, FLOD);
|
||||||
FLOD.read((char*)temp,4);
|
fread((char*)temp, 1, 4, FLOD);
|
||||||
entry.offset=readNormalNr(temp,4);
|
entry.offset=readNormalNr(temp,4);
|
||||||
FLOD.read((char*)temp,4);
|
fread((char*)temp, 1, 4, FLOD);
|
||||||
entry.realSize=readNormalNr(temp,4);
|
entry.realSize=readNormalNr(temp,4);
|
||||||
FLOD.read((char*)entry.hlam_2,4);
|
fread((char*)entry.hlam_2, 1, 4, FLOD);
|
||||||
FLOD.read((char*)temp,4);
|
fread((char*)temp, 1, 4, FLOD);
|
||||||
entry.size=readNormalNr(temp,4);
|
entry.size=readNormalNr(temp,4);
|
||||||
for (int z=0;z<12;z++)
|
for (int z=0;z<12;z++)
|
||||||
{
|
{
|
||||||
@ -828,12 +817,12 @@ std::string CLodHandler::getTextFile(std::string name)
|
|||||||
int curDef;
|
int curDef;
|
||||||
if(buf1!=name)
|
if(buf1!=name)
|
||||||
continue;
|
continue;
|
||||||
FLOD.seekg(entries[i].offset,std::ios_base::beg);
|
fseek(FLOD, entries[i].offset, 0);
|
||||||
unsigned char * outp;
|
unsigned char * outp;
|
||||||
if (entries[i].size==0) //file is not compressed
|
if (entries[i].size==0) //file is not compressed
|
||||||
{
|
{
|
||||||
outp = new unsigned char[entries[i].realSize];
|
outp = new unsigned char[entries[i].realSize];
|
||||||
FLOD.read((char*)outp, entries[i].realSize);
|
fread((char*)outp, 1, entries[i].realSize, FLOD);
|
||||||
std::string ret = std::string((char*)outp);
|
std::string ret = std::string((char*)outp);
|
||||||
delete[] outp;
|
delete[] outp;
|
||||||
return ret;
|
return ret;
|
||||||
@ -841,8 +830,8 @@ std::string CLodHandler::getTextFile(std::string name)
|
|||||||
else //we will decompressing file
|
else //we will decompressing file
|
||||||
{
|
{
|
||||||
outp = new unsigned char[entries[i].size];
|
outp = new unsigned char[entries[i].size];
|
||||||
FLOD.read((char*)outp, entries[i].size);
|
fread((char*)outp, 1, entries[i].size, FLOD);
|
||||||
FLOD.seekg(0, std::ios_base::beg);
|
fseek(FLOD, 0, 0);
|
||||||
unsigned char * decomp = NULL;
|
unsigned char * decomp = NULL;
|
||||||
int decRes = infs2(outp, entries[i].size, entries[i].realSize, decomp);
|
int decRes = infs2(outp, entries[i].size, entries[i].realSize, decomp);
|
||||||
std::string ret;
|
std::string ret;
|
||||||
|
@ -56,7 +56,7 @@ public:
|
|||||||
class CLodHandler
|
class CLodHandler
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
std::ifstream FLOD;
|
FILE* FLOD;
|
||||||
public:
|
public:
|
||||||
nodrze<Entry> entries;
|
nodrze<Entry> entries;
|
||||||
unsigned int totalFiles;
|
unsigned int totalFiles;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user