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

* support for all SoD/WoG maps (to be tested)

* small improvements and bugfixes
This commit is contained in:
mateuszb 2007-08-25 17:51:32 +00:00
parent ab3a06bf69
commit 2541422e92
2 changed files with 61 additions and 32 deletions

View File

@ -324,19 +324,22 @@ void CAmbarCendamo::deh3m()
}
}
}
//allowed heroes have been read
switch(map.version)
if(map.version>=RoE)
i+=4;
unsigned char disp = 0;
if(map.version>=SoD)
{
case SoD: case WoG:
i+=36;
break;
case AB:
i+=35;
break;
case RoE:
i+=31;
break;
disp = bufor[i++];
for(int g=0; g<disp; ++g)
{
i+=2;
int lenbuf = readNormalNr(i); i+=4;
i+=lenbuf+1;
}
}
//allowed heroes have been read
unsigned char aaa1=bufor[i], aaa2=bufor[i+1], aaa3=bufor[i+2];
i+=31; //omitting 0s
//reading allowed artifacts //18 bytes
if(map.version!=RoE)
{
@ -412,7 +415,30 @@ void CAmbarCendamo::deh3m()
switch(map.version)
{
case WoG: case SoD: case AB:
i+=156;
if(bufor[i]=='\0') //omit 156 bytes of rubbish
{
i+=156;
break;
}
else //omit a lot of rubbish in a strage way
{
int lastFFpos=i;
while(i-lastFFpos<50) //i far in terrain bytes
{
++i;
if(bufor[i]==0xff)
{
lastFFpos=i;
}
}
i=lastFFpos;
while(bufor[i-1]!=0 || bufor[i]>8 || bufor[i+2]>4 || bufor[i+1]==0) //back to terrain bytes
{
i++;
}
}
break;
case RoE:
i+=0;
@ -887,6 +913,9 @@ void CAmbarCendamo::deh3m()
spec->missionType = bufor[i]; ++i;
switch(spec->missionType)
{
case 0:
i+=3;
continue;
case 1:
{
spec->m1level = readNormalNr(i); i+=4;
@ -2757,7 +2786,10 @@ void CAmbarCendamo::processMap(std::vector<std::string> & defsToUnpack)
}
}
}
int lvl = rand()%(((CCreGen2ObjInfo*)CGI->objh->objInstances[j]->info)->maxLevel - ((CCreGen2ObjInfo*)CGI->objh->objInstances[j]->info)->minLevel) + ((CCreGen2ObjInfo*)CGI->objh->objInstances[j]->info)->minLevel;
int lvl;
if((((CCreGen2ObjInfo*)CGI->objh->objInstances[j]->info)->maxLevel - ((CCreGen2ObjInfo*)CGI->objh->objInstances[j]->info)->minLevel)!=0)
lvl = rand()%(((CCreGen2ObjInfo*)CGI->objh->objInstances[j]->info)->maxLevel - ((CCreGen2ObjInfo*)CGI->objh->objInstances[j]->info)->minLevel) + ((CCreGen2ObjInfo*)CGI->objh->objInstances[j]->info)->minLevel;
else lvl = 0;
nxt.name = creGenNames[nxt.bytes[20]][lvl];
if(creGenNumbers[nxt.bytes[20]][lvl]!=-1)
{

View File

@ -369,7 +369,7 @@ void CMapHandler::init()
cr.x = fx*32;
cr.y = fy*32;
std::pair<CObjectInstance *, SDL_Rect> toAdd = std::make_pair(CGI->objh->objInstances[f], cr);
if((CGI->objh->objInstances[f]->pos.x + fx - curd->ourImages[0].bitmap->w/32)>=0 && (CGI->objh->objInstances[f]->pos.x + fx - curd->ourImages[0].bitmap->w/32)<=ttiles.size() && (CGI->objh->objInstances[f]->pos.y + fy - curd->ourImages[0].bitmap->h/32)>=0 && (CGI->objh->objInstances[f]->pos.y + fy - curd->ourImages[0].bitmap->h/32)<=ttiles[0].size())
if((CGI->objh->objInstances[f]->pos.x + fx - curd->ourImages[0].bitmap->w/32)>=0 && (CGI->objh->objInstances[f]->pos.x + fx - curd->ourImages[0].bitmap->w/32)<ttiles.size()-Woff && (CGI->objh->objInstances[f]->pos.y + fy - curd->ourImages[0].bitmap->h/32)>=0 && (CGI->objh->objInstances[f]->pos.y + fy - curd->ourImages[0].bitmap->h/32)<ttiles[0].size()-Hoff)
{
TerrainTile2 & curt =
ttiles
@ -488,26 +488,23 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
{
for (int by=0; by<dy; by++)
{
if(true)
for(int h=0; h<ttiles[x+bx][y+by][level].objects.size(); ++h)
{
for(int h=0; h<ttiles[x+bx][y+by][level].objects.size(); ++h)
{
SDL_Rect * sr = new SDL_Rect;
sr->w = 32;
sr->h = 32;
sr->x = (bx)*32;
sr->y = (by)*32;
SDL_Rect * sr = new SDL_Rect;
sr->w = 32;
sr->h = 32;
sr->x = (bx)*32;
sr->y = (by)*32;
SDL_Rect pp = ttiles[x+bx][y+by][level].objects[h].second;
int imgVal = CGI->ac->map.defy[
ttiles[x+bx][y+by][level].objects[h].first->defNumber]
.handler->ourImages.size();
SDL_Surface * tb = CGI->ac->map.defy[ttiles[x+bx][y+by][level].objects[h].first->defNumber].handler->ourImages[anim%imgVal].bitmap;
SDL_BlitSurface(
CGI->ac->map.defy[ttiles[x+bx][y+by][level].objects[h].first->defNumber].handler->ourImages[anim%imgVal].bitmap,
&pp,su,sr);
delete sr;
}
SDL_Rect pp = ttiles[x+bx][y+by][level].objects[h].second;
int imgVal = CGI->ac->map.defy[
ttiles[x+bx][y+by][level].objects[h].first->defNumber]
.handler->ourImages.size();
SDL_Surface * tb = CGI->ac->map.defy[ttiles[x+bx][y+by][level].objects[h].first->defNumber].handler->ourImages[anim%imgVal].bitmap;
SDL_BlitSurface(
CGI->ac->map.defy[ttiles[x+bx][y+by][level].objects[h].first->defNumber].handler->ourImages[anim%imgVal].bitmap,
&pp,su,sr);
delete sr;
}
}
}