1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-25 21:38:59 +02:00

some minor impovements

This commit is contained in:
mateuszb 2007-07-12 18:04:02 +00:00
parent 217e98e345
commit eb688cf1d3
5 changed files with 51 additions and 42 deletions

View File

@ -482,8 +482,8 @@ void CAmbarCendamo::deh3m()
nobj.z = bufor[i++];
nobj.defNumber = readNormalNr(i, 4); i+=4;
if (((nobj.x==0)&&(nobj.y==0)) || nobj.x>map.width || nobj.y>map.height || nobj.z>1 || nobj.defNumber>map.defy.size())
std::cout << "Alarm!!! Obiekt "<<ww<<" jest kopniety (lub wystaje poza mape)\n";
//if (((nobj.x==0)&&(nobj.y==0)) || nobj.x>map.width || nobj.y>map.height || nobj.z>1 || nobj.defNumber>map.defy.size())
// std::cout << "Alarm!!! Obiekt "<<ww<<" jest kopniety (lub wystaje poza mape)\n";
i+=5;
unsigned char buff [30];
@ -1831,7 +1831,10 @@ CCreatureSet CAmbarCendamo::readCreatureSet(int pos, int number)
CCreatureSet ret;
if(number>0 && readNormalNr(pos, 2)!=0xffff)
{
ret.slot1 = &(CGameInfo::mainObj->creh->creatures[readNormalNr(pos, 2)]);
int rettt = readNormalNr(pos, 2);
if(rettt>32768)
rettt = 65536-rettt+CGameInfo::mainObj->creh->creatures.size()-16;
ret.slot1 = &(CGameInfo::mainObj->creh->creatures[rettt]);
ret.s1 = readNormalNr(pos+2, 2);
}
else
@ -1841,7 +1844,10 @@ CCreatureSet CAmbarCendamo::readCreatureSet(int pos, int number)
}
if(number>1 && readNormalNr(pos+4, 2)!=0xffff)
{
ret.slot2 = &(CGameInfo::mainObj->creh->creatures[readNormalNr(pos+4, 2)]);
int rettt = readNormalNr(pos+4, 2);
if(rettt>32768)
rettt = 65536-rettt+CGameInfo::mainObj->creh->creatures.size()-16;
ret.slot2 = &(CGameInfo::mainObj->creh->creatures[rettt]);
ret.s2 = readNormalNr(pos+6, 2);
}
else
@ -1851,7 +1857,10 @@ CCreatureSet CAmbarCendamo::readCreatureSet(int pos, int number)
}
if(number>2 && readNormalNr(pos+8, 2)!=0xffff)
{
ret.slot3 = &(CGameInfo::mainObj->creh->creatures[readNormalNr(pos+8, 2)]);
int rettt = readNormalNr(pos+8, 2);
if(rettt>32768)
rettt = 65536-rettt+CGameInfo::mainObj->creh->creatures.size()-16;
ret.slot3 = &(CGameInfo::mainObj->creh->creatures[rettt]);
ret.s3 = readNormalNr(pos+10, 2);
}
else
@ -1861,7 +1870,10 @@ CCreatureSet CAmbarCendamo::readCreatureSet(int pos, int number)
}
if(number>3 && readNormalNr(pos+12, 2)!=0xffff)
{
ret.slot4 = &(CGameInfo::mainObj->creh->creatures[readNormalNr(pos+12, 2)]);
int rettt = readNormalNr(pos+12, 2);
if(rettt>32768)
rettt = 65536-rettt+CGameInfo::mainObj->creh->creatures.size()-16;
ret.slot4 = &(CGameInfo::mainObj->creh->creatures[rettt]);
ret.s4 = readNormalNr(pos+14, 2);
}
else
@ -1871,7 +1883,10 @@ CCreatureSet CAmbarCendamo::readCreatureSet(int pos, int number)
}
if(number>4 && readNormalNr(pos+16, 2)!=0xffff)
{
ret.slot5 = &(CGameInfo::mainObj->creh->creatures[readNormalNr(pos+16, 2)]);
int rettt = readNormalNr(pos+16, 2);
if(rettt>32768)
rettt = 65536-rettt+CGameInfo::mainObj->creh->creatures.size()-16;
ret.slot5 = &(CGameInfo::mainObj->creh->creatures[rettt]);
ret.s5 = readNormalNr(pos+18, 2);
}
else
@ -1881,7 +1896,10 @@ CCreatureSet CAmbarCendamo::readCreatureSet(int pos, int number)
}
if(number>5 && readNormalNr(pos+20, 2)!=0xffff)
{
ret.slot6 = &(CGameInfo::mainObj->creh->creatures[readNormalNr(pos+20, 2)]);
int rettt = readNormalNr(pos+20, 2);
if(rettt>32768)
rettt = 65536-rettt+CGameInfo::mainObj->creh->creatures.size()-16;
ret.slot6 = &(CGameInfo::mainObj->creh->creatures[rettt]);
ret.s6 = readNormalNr(pos+22, 2);
}
else
@ -1891,7 +1909,10 @@ CCreatureSet CAmbarCendamo::readCreatureSet(int pos, int number)
}
if(number>6 && readNormalNr(pos+24, 2)!=0xffff)
{
ret.slot7 = &(CGameInfo::mainObj->creh->creatures[readNormalNr(pos+24, 2)]);
int rettt = readNormalNr(pos+24, 2);
if(rettt>32768)
rettt = 65536-rettt+CGameInfo::mainObj->creh->creatures.size()-16;
ret.slot7 = &(CGameInfo::mainObj->creh->creatures[rettt]);
ret.s7 = readNormalNr(pos+26, 2);
}
else

View File

@ -259,9 +259,20 @@ void CCreatureHandler::loadCreatures()
if(ncre.nameSing!=std::string("") && ncre.namePl!=std::string(""))
{
ncre.idNumber = creatures.size();
ncre.isDefinite = true;
creatures.push_back(ncre);
}
}
for(int bb=1; bb<8; ++bb)
{
CCreature ncre;
ncre.isDefinite = false;
ncre.indefLevel = bb;
ncre.indefUpgraded = false;
creatures.push_back(ncre);
ncre.indefUpgraded = true;
creatures.push_back(ncre);
}
}
void CCreatureHandler::loadAnimationInfo()

View File

@ -21,6 +21,11 @@ public:
int troopCountLocationOffset, attackClimaxFrame;
///end of anim info
//for some types of towns
bool isDefinite; //if the creature type is wotn dependent, it should be true
int indefLevel; //only if indefinite
bool indefUpgraded; //onlu if inddefinite
//end
//TODO - zdolności - na typie wyliczeniowym czy czymś
};

View File

@ -192,21 +192,9 @@ SDL_Surface * CPCXConv::getSurface()
add = 4 - bh.x%4;
if (add==4)
add=0;
bh._h3=bh.x*bh.y;
if (format==Epcxformat::PCX8B)
{
int bmask = 0x0000ff;
int gmask = 0x00ff00;
int rmask = 0xff0000;
ret = SDL_CreateRGBSurface(SDL_SWSURFACE, bh.x+add, bh.y, 8, 0, 0, 0, 0);
bh._c1=0x436;
bh._c2=0x28;
bh._c3=1;
bh._c4=8;
//bh.dataSize2=bh.dataSize1=maxx*maxy;
bh.dataSize1=bh.x;
bh.dataSize2=bh.y;
bh.fullSize = bh.dataSize1+436;
}
else
{
@ -214,15 +202,6 @@ SDL_Surface * CPCXConv::getSurface()
int gmask = 0x00ff00;
int rmask = 0xff0000;
ret = SDL_CreateRGBSurface(SDL_SWSURFACE, bh.x+add, bh.y, 24, rmask, gmask, bmask, 0);
bh._c1=0x36;
bh._c2=0x28;
bh._c3=1;
bh._c4=0x18;
//bh.dataSize2=bh.dataSize1=0xB12;
bh.dataSize1=bh.x;
bh.dataSize2=bh.y;
bh.fullSize=(bh.x+add)*bh.y*3+36+18;
bh._h3*=3;
}
if (format==Epcxformat::PCX8B)
{
@ -252,14 +231,12 @@ SDL_Surface * CPCXConv::getSurface()
it=0xC+(y-1)*bh.x;
for (int j=0;j<bh.x;j++)
{
//out<<pcx[it+j];
*((char*)ret->pixels + ret->pitch * (y-1) + ret->format->BytesPerPixel * j) = pcx[it+j];
}
if (add>0)
{
for (int j=0;j<add;j++)
{
//out<<'\0'; //bylo z buforu, ale onnie byl incjalizowany (?!)
*((char*)ret->pixels + ret->pitch * (y-1) + ret->format->BytesPerPixel * (j+bh.x)) = 0;
}
}
@ -272,14 +249,12 @@ SDL_Surface * CPCXConv::getSurface()
it=0xC+(y-1)*bh.x*3;
for (int j=0;j<bh.x*3;j++)
{
//out<<pcx[it+j];
*((char*)ret->pixels + ret->pitch * (y-1) + j) = pcx[it+j];
}
if (add>0)
{
for (int j=0;j<add*3;j++)
{
//out<<'\0'; //bylo z buforu, ale onnie byl incjalizowany (?!)
*((char*)ret->pixels + ret->pitch * (y-1) + (j+bh.x*3)) = 0;
}
}
@ -296,13 +271,16 @@ SDL_Surface * CLodHandler::loadBitmap(std::string fname)
for (int i=0;i<entries.size();i++)
{
std::string buf1 = std::string((char*)entries[i].name);
//std::transform(buf1.begin(), buf1.end(), buf1.begin(), (int(*)(int))toupper);
if(buf1==fname)
{
index=i;
break;
}
}
if(index==-1)
{
std::cout<<"File "<<fname<<" did't found"<<std::endl;
}
FLOD.seekg(entries[index].offset,std::ios_base::beg);
if (entries[index].size==0) //file is not compressed
{
@ -321,13 +299,7 @@ SDL_Surface * CLodHandler::loadBitmap(std::string fname)
}
CPCXConv cp;
cp.openPCX((char*)pcx,entries[index].realSize);
//cp.convert();
//cp.saveBMP("vctemp.bmp");
//SDL_Surface * ret = SDL_LoadBMP("vctemp.bmp");
//boost::filesystem::path p("vctemp.bmp");
//boost::filesystem::remove(p);
return cp.getSurface();
//return ret;
}
int CLodHandler::decompress (unsigned char * source, int size, int realSize, std::string & dest)

View File

@ -331,7 +331,7 @@ int _tmain(int argc, _TCHAR* argv[])
{
initTable[ss] = mapstr[ss];
}
//#define CHOOSE
#define CHOOSE
#ifdef CHOOSE
CAmbarCendamo * ac = new CAmbarCendamo(initTable); //4gryf
#else