mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-17 01:32:21 +02:00
* added missing movement arrows (advmap interface)
* corrected centering on hero's position * merged terrainRect and terrainRectSmooth
This commit is contained in:
@ -622,133 +622,165 @@ void CTerrainRect::showPath(const SDL_Rect * extRect)
|
||||
}
|
||||
else if (cv[i+1].coord.x == cv[i].coord.x+1 && cv[i+1].coord.y == cv[i].coord.y-1) //35x
|
||||
{
|
||||
if(cv[i-1].coord.x == cv[i].coord.x && cv[i-1].coord.y == cv[i].coord.y+1)
|
||||
if(cv[i-1].coord.x == cv[i].coord.x && cv[i-1].coord.y == cv[i].coord.y+1) //358
|
||||
{
|
||||
pn = 5;
|
||||
}
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y+1)
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y+1) //357
|
||||
{
|
||||
pn = 14;
|
||||
}
|
||||
else if(cv[i-1].coord.x+1 == cv[i].coord.x && cv[i-1].coord.y == cv[i].coord.y)
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y) //354
|
||||
{
|
||||
pn = 23;
|
||||
}
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y-1)
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y-1) //351
|
||||
{
|
||||
pn = 24;
|
||||
}
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y+1)
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y+1) //359
|
||||
{
|
||||
pn = 4;
|
||||
}
|
||||
}
|
||||
else if (cv[i+1].coord.x == cv[i].coord.x+1 && cv[i+1].coord.y == cv[i].coord.y) //65x
|
||||
{
|
||||
if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y+1)
|
||||
if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y+1) //657
|
||||
{
|
||||
pn = 6;
|
||||
}
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y)
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y) //654
|
||||
{
|
||||
pn = 15;
|
||||
}
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y-1)
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y-1) //651
|
||||
{
|
||||
pn = 24;
|
||||
}
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x && cv[i-1].coord.y == cv[i].coord.y-1) //652
|
||||
{
|
||||
pn = 17;
|
||||
}
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x && cv[i-1].coord.y == cv[i].coord.y+1) //658
|
||||
{
|
||||
pn = 5;
|
||||
}
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y-1) //653
|
||||
{
|
||||
pn = 18;
|
||||
}
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y+1) //659
|
||||
{
|
||||
pn = 4;
|
||||
}
|
||||
}
|
||||
else if (cv[i+1].coord.x == cv[i].coord.x+1 && cv[i+1].coord.y == cv[i].coord.y+1) //95x
|
||||
{
|
||||
if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y)
|
||||
if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y) //954
|
||||
{
|
||||
pn = 7;
|
||||
}
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y-1)
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y-1) //951
|
||||
{
|
||||
pn = 16;
|
||||
}
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x && cv[i-1].coord.y == cv[i].coord.y-1)
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x && cv[i-1].coord.y == cv[i].coord.y-1) //952
|
||||
{
|
||||
pn = 17;
|
||||
}
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y+1)
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y+1) //957
|
||||
{
|
||||
pn = 6;
|
||||
}
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y-1)
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y-1) //953
|
||||
{
|
||||
pn = 18;
|
||||
}
|
||||
}
|
||||
else if (cv[i+1].coord.x == cv[i].coord.x && cv[i+1].coord.y == cv[i].coord.y+1) //85x
|
||||
{
|
||||
if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y+1)
|
||||
if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y+1) //857
|
||||
{
|
||||
pn = 6;
|
||||
}
|
||||
if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y)
|
||||
if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y) //854
|
||||
{
|
||||
pn = 7;
|
||||
}
|
||||
if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y-1)
|
||||
if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y-1) //851
|
||||
{
|
||||
pn = 8;
|
||||
}
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x && cv[i-1].coord.y == cv[i].coord.y-1)
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x && cv[i-1].coord.y == cv[i].coord.y-1) //852
|
||||
{
|
||||
pn = 9;
|
||||
}
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y-1)
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y-1) //853
|
||||
{
|
||||
pn = 18;
|
||||
}
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y)
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y) //856
|
||||
{
|
||||
pn = 19;
|
||||
}
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y+1)
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y+1) //859
|
||||
{
|
||||
pn = 20;
|
||||
}
|
||||
}
|
||||
else if (cv[i+1].coord.x == cv[i].coord.x-1 && cv[i+1].coord.y == cv[i].coord.y+1) //75x
|
||||
{
|
||||
if(cv[i-1].coord.x == cv[i].coord.x && cv[i-1].coord.y == cv[i].coord.y-1)
|
||||
if(cv[i-1].coord.x == cv[i].coord.x && cv[i-1].coord.y == cv[i].coord.y-1) //752
|
||||
{
|
||||
pn = 1;
|
||||
}
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y-1)
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y-1) //753
|
||||
{
|
||||
pn = 10;
|
||||
}
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y)
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y) //756
|
||||
{
|
||||
pn = 19;
|
||||
}
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y-1)
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y-1) //751
|
||||
{
|
||||
pn = 8;
|
||||
}
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y+1)
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y+1) //759
|
||||
{
|
||||
pn = 20;
|
||||
}
|
||||
}
|
||||
else if (cv[i+1].coord.x == cv[i].coord.x-1 && cv[i+1].coord.y == cv[i].coord.y) //45x
|
||||
{
|
||||
if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y-1)
|
||||
if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y-1) //453
|
||||
{
|
||||
pn = 2;
|
||||
}
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y)
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y) //456
|
||||
{
|
||||
pn = 11;
|
||||
}
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y+1)
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x+1 && cv[i-1].coord.y == cv[i].coord.y+1) //459
|
||||
{
|
||||
pn = 20;
|
||||
}
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x && cv[i-1].coord.y == cv[i].coord.y-1) //452
|
||||
{
|
||||
pn = 1;
|
||||
}
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x && cv[i-1].coord.y == cv[i].coord.y+1) //456
|
||||
{
|
||||
pn = 21;
|
||||
}
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y-1) //451
|
||||
{
|
||||
pn = 8;
|
||||
}
|
||||
else if(cv[i-1].coord.x == cv[i].coord.x-1 && cv[i-1].coord.y == cv[i].coord.y+1) //457
|
||||
{
|
||||
pn = 22;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -823,25 +855,14 @@ void CTerrainRect::showPath(const SDL_Rect * extRect)
|
||||
} //for (int i=0;i<currentPath->nodes.size()-1;i++)
|
||||
}
|
||||
void CTerrainRect::show()
|
||||
{
|
||||
if(ADVOPT.smoothMove && (moveX != 0 || moveY != 0))
|
||||
{
|
||||
CGI->mh->terrainRectSmooth
|
||||
(LOCPLINT->adventureInt->position.x,LOCPLINT->adventureInt->position.y,
|
||||
tilesw,tilesh,LOCPLINT->adventureInt->position.z,LOCPLINT->adventureInt->anim,
|
||||
&LOCPLINT->cb->getVisibilityMap(), true, LOCPLINT->adventureInt->heroAnim,
|
||||
screen, &genRect(pos.h, pos.w, pos.x, pos.y), moveX, moveY
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
CGI->mh->terrainRect
|
||||
(LOCPLINT->adventureInt->position.x,LOCPLINT->adventureInt->position.y,
|
||||
tilesw,tilesh,LOCPLINT->adventureInt->position.z,LOCPLINT->adventureInt->anim,
|
||||
&LOCPLINT->cb->getVisibilityMap(), true, LOCPLINT->adventureInt->heroAnim,
|
||||
screen, &genRect(pos.h, pos.w, pos.x, pos.y)
|
||||
screen, &genRect(pos.h, pos.w, pos.x, pos.y), moveX, moveY, ADVOPT.smoothMove && (moveX != 0 || moveY != 0)
|
||||
);
|
||||
}
|
||||
|
||||
//SDL_BlitSurface(teren,&genRect(pos.h,pos.w,0,0),screen,&genRect(547,594,7,6));
|
||||
//SDL_FreeSurface(teren);
|
||||
if (currentPath && LOCPLINT->adventureInt->position.z==currentPath->startPos().z) //drawing path
|
||||
@ -1357,7 +1378,7 @@ void CAdvMapInt::update()
|
||||
}
|
||||
if(scrollingRight)
|
||||
{
|
||||
if(position.x < CGI->mh->map->width - terrain.tilesw + 4 )
|
||||
if(position.x < CGI->mh->map->width - terrain.tilesw + Woff )
|
||||
{
|
||||
position.x++;
|
||||
updateScreen = true;
|
||||
@ -1375,7 +1396,7 @@ void CAdvMapInt::update()
|
||||
}
|
||||
if(scrollingDown)
|
||||
{
|
||||
if(position.y < CGI->mh->map->height - terrain.tilesh + 4)
|
||||
if(position.y < CGI->mh->map->height - terrain.tilesh + Hoff)
|
||||
{
|
||||
position.y++;
|
||||
updateScreen = true;
|
||||
@ -1407,15 +1428,7 @@ void CAdvMapInt::centerOn(int3 on)
|
||||
on.x -= (LOCPLINT->adventureInt->terrain.tilesw/2);
|
||||
on.y -= (LOCPLINT->adventureInt->terrain.tilesh/2);
|
||||
|
||||
if (on.x<0)
|
||||
on.x=-(Woff/2);
|
||||
else if((on.x+LOCPLINT->adventureInt->terrain.tilesw) > (CGI->mh->sizes.x))
|
||||
on.x=CGI->mh->sizes.x-LOCPLINT->adventureInt->terrain.tilesw+(Woff/2);
|
||||
|
||||
if (on.y<0)
|
||||
on.y = -(Hoff/2);
|
||||
else if((on.y+LOCPLINT->adventureInt->terrain.tilesh) > (CGI->mh->sizes.y))
|
||||
on.y = CGI->mh->sizes.y-LOCPLINT->adventureInt->terrain.tilesh+(Hoff/2);
|
||||
on = LOCPLINT->repairScreenPos(on);
|
||||
|
||||
LOCPLINT->adventureInt->position.x=on.x;
|
||||
LOCPLINT->adventureInt->position.y=on.y;
|
||||
|
@ -1197,14 +1197,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
|
||||
{
|
||||
boost::unique_lock<boost::recursive_mutex> un(*pim);
|
||||
|
||||
int3 buff = details.ho->pos;
|
||||
buff.x-=11;
|
||||
buff.y-=9;
|
||||
buff = repairScreenPos(buff);
|
||||
LOCPLINT->adventureInt->position = buff; //actualizing screen pos
|
||||
|
||||
if(adventureInt == curint)
|
||||
adventureInt->minimap.draw();
|
||||
adventureInt->centerOn(details.ho->pos); //centering screen on hero
|
||||
|
||||
if(details.style>0)
|
||||
return;
|
||||
|
391
mapHandler.cpp
391
mapHandler.cpp
@ -508,7 +508,7 @@ void CMapHandler::init()
|
||||
tlog0<<"\tMaking object rects: "<<th.getDif()<<std::endl;
|
||||
}
|
||||
|
||||
SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level, unsigned char anim, std::vector< std::vector< std::vector<unsigned char> > > * visibilityMap, bool otherHeroAnim, unsigned char heroAnim, SDL_Surface * extSurf, SDL_Rect * extRect)
|
||||
SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level, unsigned char anim, std::vector< std::vector< std::vector<unsigned char> > > * visibilityMap, bool otherHeroAnim, unsigned char heroAnim, SDL_Surface * extSurf, SDL_Rect * extRect, int moveX, int moveY, bool smooth)
|
||||
{
|
||||
if(!otherHeroAnim)
|
||||
heroAnim = anim; //the same, as it should be
|
||||
@ -522,7 +522,6 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
|
||||
{
|
||||
su = CSDL_Ext::newSurface(dx*32, dy*32, CSDL_Ext::std32bppSurface);
|
||||
}
|
||||
|
||||
SDL_Rect prevClip;
|
||||
SDL_GetClipRect(su, &prevClip);
|
||||
if(extRect) SDL_SetClipRect(su, extRect); //preventing blitting outside of that rect
|
||||
@ -530,21 +529,54 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
|
||||
if (((dx+x)>((map->width+Woff)) || (dy+y)>((map->height+Hoff))) || ((x<-Woff)||(y<-Hoff) ) )
|
||||
throw std::string("terrainRect: out of range");
|
||||
////printing terrain
|
||||
for (int bx=0; bx<dx; bx++)
|
||||
for (int bx= (moveX <= 0 ? 0 : -1); bx<dx+(smooth?1:0); bx++)
|
||||
{
|
||||
for (int by=0; by<dy; by++)
|
||||
for (int by=(moveY <= 0 ? 0 : -1); by<dy+(smooth?1:0); by++)
|
||||
{
|
||||
const TerrainTile2 & tile = ttiles[x+bx][y+by][level];
|
||||
SDL_Rect sr;
|
||||
if(smooth)
|
||||
{
|
||||
sr.y=by*32 + moveY + extRect->y;
|
||||
sr.x=bx*32 + moveX + extRect->x;
|
||||
sr.h=sr.w=32;
|
||||
}
|
||||
else
|
||||
{
|
||||
sr.y=by*32;
|
||||
sr.x=bx*32;
|
||||
sr.h=sr.w=32;
|
||||
validateRectTerr(&sr, extRect);
|
||||
}
|
||||
if(tile.terbitmap)
|
||||
{
|
||||
SDL_BlitSurface(ttiles[x+bx][y+by][level].terbitmap, &genRect(sr.h, sr.w, 0, 0), su, &sr);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(smooth)
|
||||
{
|
||||
switch(tile.tileInfo->siodmyTajemniczyBajt%4)
|
||||
{
|
||||
case 0:
|
||||
SDL_BlitSurface(terrainGraphics[tile.tileInfo->tertype][tile.tileInfo->terview],
|
||||
&genRect(sr.h, sr.w, 0, 0),su,&sr);
|
||||
break;
|
||||
case 1:
|
||||
CSDL_Ext::blitWithRotate1clip(terrainGraphics[tile.tileInfo->tertype][tile.tileInfo->terview],
|
||||
&genRect(sr.h, sr.w, 0, 0),su,&sr);
|
||||
break;
|
||||
case 2:
|
||||
CSDL_Ext::blitWithRotate2clip(terrainGraphics[tile.tileInfo->tertype][tile.tileInfo->terview],
|
||||
&genRect(sr.h, sr.w, 0, 0),su,&sr);
|
||||
break;
|
||||
default:
|
||||
CSDL_Ext::blitWithRotate3clip(terrainGraphics[tile.tileInfo->tertype][tile.tileInfo->terview],
|
||||
&genRect(sr.h, sr.w, 0, 0),su,&sr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(tile.tileInfo->siodmyTajemniczyBajt%4)
|
||||
{
|
||||
@ -568,17 +600,27 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
////terrain printed
|
||||
////printing rivers
|
||||
for (int bx=0; bx<dx; bx++)
|
||||
for (int bx= (moveX <= 0 ? 0 : -1); bx<dx+(smooth?1:0); bx++)
|
||||
{
|
||||
for (int by=0; by<dy; by++)
|
||||
for (int by=(moveY <= 0 ? 0 : -1); by<dy+(smooth?1:0); by++)
|
||||
{
|
||||
SDL_Rect sr;
|
||||
if(smooth)
|
||||
{
|
||||
sr.y=by*32 + moveY + extRect->y;
|
||||
sr.x=bx*32 + moveX + extRect->x;
|
||||
sr.h=sr.w=32;
|
||||
}
|
||||
else
|
||||
{
|
||||
sr.y=by*32;
|
||||
sr.x=bx*32;
|
||||
sr.h=sr.w=32;
|
||||
validateRectTerr(&sr, extRect);
|
||||
}
|
||||
if(ttiles[x+bx][y+by][level].rivbitmap.size())
|
||||
{
|
||||
CSDL_Ext::blit8bppAlphaTo24bpp(ttiles[x+bx][y+by][level].rivbitmap[anim%ttiles[x+bx][y+by][level].rivbitmap.size()],&genRect(sr.h, sr.w, 0, 0),su,&sr);
|
||||
@ -587,17 +629,26 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
|
||||
}
|
||||
////rivers printed
|
||||
////printing roads
|
||||
for (int bx=0; bx<dx; bx++)
|
||||
for (int bx= (moveX <= 0 ? 0 : -1); bx<dx+(smooth?1:0); bx++)
|
||||
{
|
||||
for (int by=-1; by<dy; by++)
|
||||
for (int by=(moveY <= 0 ? 0 : -1) - 1; by<dy+(smooth?1:0); by++)
|
||||
{
|
||||
if(y+by<=-4)
|
||||
continue;
|
||||
SDL_Rect sr;
|
||||
if(smooth)
|
||||
{
|
||||
sr.y=by*32+16 + moveY + extRect->y;
|
||||
sr.x=bx*32 + moveX + extRect->x;
|
||||
sr.h=sr.w=32;
|
||||
}
|
||||
else
|
||||
{
|
||||
sr.y=by*32+16;
|
||||
sr.x=bx*32;
|
||||
sr.h=sr.w=32;
|
||||
validateRectTerr(&sr, extRect);
|
||||
}
|
||||
if(ttiles[x+bx][y+by][level].roadbitmap.size())
|
||||
{
|
||||
CSDL_Ext::blit8bppAlphaTo24bpp(ttiles[x+bx][y+by][level].roadbitmap[anim%ttiles[x+bx][y+by][level].roadbitmap.size()], &genRect(sr.h, sr.w, 0, (by==-1 ? 16 : 0)),su,&sr);
|
||||
@ -607,18 +658,28 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
|
||||
////roads printed
|
||||
////printing objects
|
||||
|
||||
for (int bx=0; bx<dx; bx++)
|
||||
for (int bx= (moveX <= 0 ? 0 : -1); bx<dx+(smooth?1:0); bx++)
|
||||
{
|
||||
for (int by=0; by<dy; by++)
|
||||
for (int by=(moveY <= 0 ? 0 : -1); by<dy+(smooth?1:0); by++)
|
||||
{
|
||||
for(int h=0; h < ttiles[x+bx][y+by][level].objects.size(); ++h)
|
||||
{
|
||||
SDL_Rect sr;
|
||||
if(smooth)
|
||||
{
|
||||
sr.w = 32;
|
||||
sr.h = 32;
|
||||
sr.x = (bx)*32 + moveX + extRect->x;
|
||||
sr.y = (by)*32 + moveY + extRect->y;
|
||||
}
|
||||
else
|
||||
{
|
||||
sr.w = 32;
|
||||
sr.h = 32;
|
||||
sr.x = (bx)*32;
|
||||
sr.y = (by)*32;
|
||||
validateRectTerr(&sr, extRect);
|
||||
}
|
||||
|
||||
SDL_Rect pp = ttiles[x+bx][y+by][level].objects[h].second;
|
||||
pp.h = sr.h;
|
||||
@ -694,15 +755,24 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
|
||||
}
|
||||
|
||||
////objects printed, printing shadow
|
||||
for (int bx=0; bx<dx; bx++)
|
||||
for (int bx= (moveX <= 0 ? 0 : -1); bx<dx+(smooth?1:0); bx++)
|
||||
{
|
||||
for (int by=0; by<dy; by++)
|
||||
for (int by=(moveY <= 0 ? 0 : -1); by<dy+(smooth?1:0); by++)
|
||||
{
|
||||
SDL_Rect sr;
|
||||
if(smooth)
|
||||
{
|
||||
sr.y=by*32 + moveY + extRect->y;
|
||||
sr.x=bx*32 + moveX + extRect->x;
|
||||
sr.h=sr.w=32;
|
||||
}
|
||||
else
|
||||
{
|
||||
sr.y=by*32;
|
||||
sr.x=bx*32;
|
||||
sr.h=sr.w=32;
|
||||
validateRectTerr(&sr, extRect);
|
||||
}
|
||||
|
||||
if(bx+x>=0 && by+y>=0 && bx+x<CGI->mh->map->width && by+y<CGI->mh->map->height && !(*visibilityMap)[bx+x][by+y][level])
|
||||
{
|
||||
@ -713,17 +783,26 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
|
||||
}
|
||||
////shadow printed
|
||||
//printing borders
|
||||
for (int bx=0; bx<dx; bx++)
|
||||
for (int bx= (moveX <= 0 ? 0 : -1); bx<dx+(smooth?1:0); bx++)
|
||||
{
|
||||
for (int by=0; by<dy; by++)
|
||||
for (int by=(moveY <= 0 ? 0 : -1); by<dy+(smooth?1:0); by++)
|
||||
{
|
||||
if(bx+x<0 || by+y<0 || bx+x>map->width+(-1) || by+y>map->height+(-1))
|
||||
{
|
||||
SDL_Rect sr;
|
||||
if(smooth)
|
||||
{
|
||||
sr.y=by*32 + moveY + extRect->y;
|
||||
sr.x=bx*32 + moveX + extRect->x;
|
||||
sr.h=sr.w=32;
|
||||
}
|
||||
else
|
||||
{
|
||||
sr.y=by*32;
|
||||
sr.x=bx*32;
|
||||
sr.h=sr.w=32;
|
||||
validateRectTerr(&sr, extRect);
|
||||
}
|
||||
SDL_BlitSurface(ttiles[x+bx][y+by][level].terbitmap,&genRect(sr.h, sr.w, 0, 0),su,&sr);
|
||||
}
|
||||
else
|
||||
@ -732,10 +811,19 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
|
||||
if(ttiles[x+bx][y+by][level].tileInfo->blocked) //temporary hiding blocked positions
|
||||
{
|
||||
SDL_Rect sr;
|
||||
if(smooth)
|
||||
{
|
||||
sr.y=by*32 + moveY;
|
||||
sr.x=bx*32 + moveX;
|
||||
sr.h=sr.w=32;
|
||||
}
|
||||
else
|
||||
{
|
||||
sr.y=by*32;
|
||||
sr.x=bx*32;
|
||||
sr.h=sr.w=32;
|
||||
validateRectTerr(&sr, extRect);
|
||||
}
|
||||
|
||||
SDL_Surface * ns = CSDL_Ext::newSurface(32, 32, CSDL_Ext::std32bppSurface);
|
||||
for(int f=0; f<ns->w*ns->h*4; ++f)
|
||||
@ -752,10 +840,19 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
|
||||
if(ttiles[x+bx][y+by][level].tileInfo->visitable) //temporary hiding visitable positions
|
||||
{
|
||||
SDL_Rect sr;
|
||||
if(smooth)
|
||||
{
|
||||
sr.y=by*32 + moveY;
|
||||
sr.x=bx*32 + moveX;
|
||||
sr.h=sr.w=32;
|
||||
}
|
||||
else
|
||||
{
|
||||
sr.y=by*32;
|
||||
sr.x=bx*32;
|
||||
sr.h=sr.w=32;
|
||||
validateRectTerr(&sr, extRect);
|
||||
}
|
||||
|
||||
SDL_Surface * ns = CSDL_Ext::newSurface(32, 32, CSDL_Ext::std32bppSurface);
|
||||
for(int f=0; f<ns->w*ns->h*4; ++f)
|
||||
@ -776,272 +873,6 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
|
||||
return su;
|
||||
}
|
||||
|
||||
SDL_Surface * CMapHandler::terrainRectSmooth(int x, int y, int dx, int dy, int level, unsigned char anim, std::vector< std::vector< std::vector<unsigned char> > > * visibilityMap, bool otherHeroAnim, unsigned char heroAnim, SDL_Surface * extSurf, SDL_Rect * extRect, int moveX, int moveY)
|
||||
{
|
||||
if(!otherHeroAnim)
|
||||
heroAnim = anim; //the same, as it should be
|
||||
//setting surface to blit at
|
||||
SDL_Surface * su = NULL; //blitting surface CSDL_Ext::newSurface(dx*32, dy*32, CSDL_Ext::std32bppSurface);
|
||||
if(extSurf)
|
||||
{
|
||||
su = extSurf;
|
||||
}
|
||||
else
|
||||
{
|
||||
su = CSDL_Ext::newSurface(dx*32, dy*32, CSDL_Ext::std32bppSurface);
|
||||
}
|
||||
SDL_Rect prevClip;
|
||||
SDL_GetClipRect(su, &prevClip);
|
||||
if(extRect) SDL_SetClipRect(su, extRect); //preventing blitting outside of that rect
|
||||
|
||||
if (((dx+x)>((map->width+Woff)) || (dy+y)>((map->height+Hoff))) || ((x<-Woff)||(y<-Hoff) ) )
|
||||
throw std::string("terrainRect: out of range");
|
||||
////printing terrain
|
||||
for (int bx= (moveX <= 0 ? 0 : -1); bx<dx+1; bx++)
|
||||
{
|
||||
for (int by=(moveY <= 0 ? 0 : -1); by<dy+1; by++)
|
||||
{
|
||||
const TerrainTile2 & tile = ttiles[x+bx][y+by][level];
|
||||
SDL_Rect sr;
|
||||
sr.y=by*32 + moveY + extRect->y;
|
||||
sr.x=bx*32 + moveX + extRect->x;
|
||||
sr.h=sr.w=32;
|
||||
//validateRectTerr(&sr, extRect);
|
||||
if(tile.terbitmap)
|
||||
{
|
||||
SDL_BlitSurface(ttiles[x+bx][y+by][level].terbitmap, &genRect(sr.h, sr.w, 0, 0), su, &sr);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(tile.tileInfo->siodmyTajemniczyBajt%4)
|
||||
{
|
||||
case 0:
|
||||
SDL_BlitSurface(terrainGraphics[tile.tileInfo->tertype][tile.tileInfo->terview],
|
||||
&genRect(sr.h, sr.w, 0, 0),su,&sr);
|
||||
break;
|
||||
case 1:
|
||||
CSDL_Ext::blitWithRotate1clip(terrainGraphics[tile.tileInfo->tertype][tile.tileInfo->terview],
|
||||
&genRect(sr.h, sr.w, 0, 0),su,&sr);
|
||||
break;
|
||||
case 2:
|
||||
CSDL_Ext::blitWithRotate2clip(terrainGraphics[tile.tileInfo->tertype][tile.tileInfo->terview],
|
||||
&genRect(sr.h, sr.w, 0, 0),su,&sr);
|
||||
break;
|
||||
default:
|
||||
CSDL_Ext::blitWithRotate3clip(terrainGraphics[tile.tileInfo->tertype][tile.tileInfo->terview],
|
||||
&genRect(sr.h, sr.w, 0, 0),su,&sr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
////terrain printed
|
||||
////printing rivers
|
||||
for (int bx=(moveX <= 0 ? 0 : -1); bx<dx+1; bx++)
|
||||
{
|
||||
for (int by=(moveY <= 0 ? 0 : -1); by<dy+1; by++)
|
||||
{
|
||||
SDL_Rect sr;
|
||||
sr.y=by*32 + moveY + extRect->y;
|
||||
sr.x=bx*32 + moveX + extRect->x;
|
||||
sr.h=sr.w=32;
|
||||
//validateRectTerr(&sr, extRect);
|
||||
if(ttiles[x+bx][y+by][level].rivbitmap.size())
|
||||
{
|
||||
CSDL_Ext::blit8bppAlphaTo24bpp(ttiles[x+bx][y+by][level].rivbitmap[anim%ttiles[x+bx][y+by][level].rivbitmap.size()],&genRect(sr.h, sr.w, 0, 0),su,&sr);
|
||||
}
|
||||
}
|
||||
}
|
||||
////rivers printed
|
||||
////printing roads
|
||||
for (int bx=(moveX <= 0 ? 0 : -1); bx<dx+1; bx++)
|
||||
{
|
||||
for (int by=(moveY <= 0 ? 0 : -1) - 1; by<dy+1; by++)
|
||||
{
|
||||
if(y+by<=-4)
|
||||
continue;
|
||||
SDL_Rect sr;
|
||||
sr.y=by*32+16 + moveY + extRect->y;
|
||||
sr.x=bx*32 + moveX + extRect->x;
|
||||
sr.h=sr.w=32;
|
||||
//validateRectTerr(&sr, extRect);
|
||||
if(ttiles[x+bx][y+by][level].roadbitmap.size())
|
||||
{
|
||||
CSDL_Ext::blit8bppAlphaTo24bpp(ttiles[x+bx][y+by][level].roadbitmap[anim%ttiles[x+bx][y+by][level].roadbitmap.size()], &genRect(sr.h, sr.w, 0, (by==-1 ? 16 : 0)),su,&sr);
|
||||
}
|
||||
}
|
||||
}
|
||||
////roads printed
|
||||
////printing objects
|
||||
|
||||
for (int bx=(moveX <= 0 ? 0 : -1); bx<dx+1; bx++)
|
||||
{
|
||||
for (int by=(moveY <= 0 ? 0 : -1); by<dy+1; by++)
|
||||
{
|
||||
for(int h=0; h < ttiles[x+bx][y+by][level].objects.size(); ++h)
|
||||
{
|
||||
SDL_Rect sr;
|
||||
sr.w = 32;
|
||||
sr.h = 32;
|
||||
sr.x = (bx)*32 + moveX + extRect->x;
|
||||
sr.y = (by)*32 + moveY + extRect->y;
|
||||
//validateRectTerr(&sr, extRect);
|
||||
|
||||
SDL_Rect pp = ttiles[x+bx][y+by][level].objects[h].second;
|
||||
pp.h = sr.h;
|
||||
pp.w = sr.w;
|
||||
const CGHeroInstance * themp = (dynamic_cast<const CGHeroInstance*>(ttiles[x+bx][y+by][level].objects[h].first));
|
||||
|
||||
if(themp && themp->moveDir && !themp->isStanding && themp->ID!=62) //last condition - this is not prison
|
||||
{
|
||||
int imgVal = 8;
|
||||
SDL_Surface * tb;
|
||||
|
||||
if(themp->type==NULL)
|
||||
continue;
|
||||
std::vector<Cimage> & iv = graphics->heroAnims[themp->type->heroType]->ourImages;
|
||||
|
||||
size_t gg;
|
||||
for(gg=0; gg<iv.size(); ++gg)
|
||||
{
|
||||
if(iv[gg].groupNumber==getHeroFrameNum(themp->moveDir, !themp->isStanding))
|
||||
{
|
||||
tb = iv[gg+heroAnim%imgVal].bitmap;
|
||||
break;
|
||||
}
|
||||
}
|
||||
CSDL_Ext::blit8bppAlphaTo24bpp(tb,&pp,su,&sr);
|
||||
pp.y+=imgVal*2-32;
|
||||
sr.y-=16;
|
||||
SDL_BlitSurface(graphics->flags4[themp->getOwner()]->ourImages[gg+heroAnim%imgVal+35].bitmap, &pp, su, &sr);
|
||||
}
|
||||
else if(themp && themp->moveDir && themp->isStanding && themp->ID!=62) //last condition - this is not prison)
|
||||
{
|
||||
int imgVal = 8;
|
||||
SDL_Surface * tb;
|
||||
|
||||
if(themp->type==NULL)
|
||||
continue;
|
||||
std::vector<Cimage> & iv = graphics->heroAnims[themp->type->heroType]->ourImages;
|
||||
|
||||
size_t gg;
|
||||
for(gg=0; gg < iv.size(); ++gg)
|
||||
{
|
||||
if(iv[gg].groupNumber==getHeroFrameNum(themp->moveDir, !themp->isStanding))
|
||||
{
|
||||
tb = iv[gg].bitmap;
|
||||
break;
|
||||
}
|
||||
}
|
||||
CSDL_Ext::blit8bppAlphaTo24bpp(tb,&pp,su,&sr);
|
||||
if(themp->pos.x==x+bx && themp->pos.y==y+by)
|
||||
{
|
||||
SDL_Rect bufr = sr;
|
||||
bufr.x-=2*32;
|
||||
bufr.y-=1*32;
|
||||
bufr.h = 64;
|
||||
bufr.w = 96;
|
||||
if(bufr.x-extRect->x>-64)
|
||||
SDL_BlitSurface(graphics->flags4[themp->getOwner()]->ourImages[ getHeroFrameNum(themp->moveDir, !themp->isStanding) *8+(heroAnim/4)%imgVal].bitmap, NULL, su, &bufr);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int imgVal = ttiles[x+bx][y+by][level].objects[h].first->defInfo->handler->ourImages.size();
|
||||
int phaseShift = ttiles[x+bx][y+by][level].objects[h].first->animPhaseShift;
|
||||
|
||||
//setting appropriate flag color
|
||||
if((ttiles[x+bx][y+by][level].objects[h].first->tempOwner>=0 && ttiles[x+bx][y+by][level].objects[h].first->tempOwner<8) || ttiles[x+bx][y+by][level].objects[h].first->tempOwner==255)
|
||||
CSDL_Ext::setPlayerColor(ttiles[x+bx][y+by][level].objects[h].first->defInfo->handler->ourImages[(anim+phaseShift)%imgVal].bitmap, ttiles[x+bx][y+by][level].objects[h].first->tempOwner);
|
||||
|
||||
CSDL_Ext::blit8bppAlphaTo24bpp(ttiles[x+bx][y+by][level].objects[h].first->defInfo->handler->ourImages[(anim+phaseShift)%imgVal].bitmap,&pp,su,&sr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////objects printed, printing shadow
|
||||
for (int bx=(moveX <= 0 ? 0 : -1); bx<dx+1; bx++)
|
||||
{
|
||||
for (int by=(moveY <= 0 ? 0 : -1); by<dy+1; by++)
|
||||
{
|
||||
SDL_Rect sr;
|
||||
sr.y=by*32 + moveY + extRect->y;
|
||||
sr.x=bx*32 + moveX + extRect->x;
|
||||
sr.h=sr.w=32;
|
||||
//validateRectTerr(&sr, extRect);
|
||||
|
||||
if(bx+x>=0 && by+y>=0 && bx+x<CGI->mh->map->width && by+y<CGI->mh->map->height && !(*visibilityMap)[bx+x][by+y][level])
|
||||
{
|
||||
SDL_Surface * hide = getVisBitmap(bx+x, by+y, *visibilityMap, level);
|
||||
CSDL_Ext::blit8bppAlphaTo24bpp(hide, &genRect(sr.h, sr.w, 0, 0), su, &sr);
|
||||
}
|
||||
}
|
||||
}
|
||||
////shadow printed
|
||||
//printing borders
|
||||
for (int bx=(moveX <= 0 ? 0 : -1); bx<dx+1; bx++)
|
||||
{
|
||||
for (int by=(moveY <= 0 ? 0 : -1); by<dy+1; by++)
|
||||
{
|
||||
if(bx+x<0 || by+y<0 || bx+x>map->width+(-1) || by+y>map->height+(-1))
|
||||
{
|
||||
SDL_Rect sr;
|
||||
sr.y=by*32 + moveY + extRect->y;
|
||||
sr.x=bx*32 + moveX + extRect->x;
|
||||
sr.h=sr.w=32;
|
||||
//validateRectTerr(&sr, extRect);
|
||||
SDL_BlitSurface(ttiles[x+bx][y+by][level].terbitmap,&genRect(sr.h, sr.w, 0, 0),su,&sr);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef MARK_BLOCKED_POSITIONS
|
||||
if(ttiles[x+bx][y+by][level].tileInfo->blocked) //temporary hiding blocked positions
|
||||
{
|
||||
SDL_Rect sr;
|
||||
sr.y=by*32 + moveY;
|
||||
sr.x=bx*32 + moveX;
|
||||
sr.h=sr.w=32;
|
||||
//validateRectTerr(&sr, extRect);
|
||||
|
||||
SDL_Surface * ns = CSDL_Ext::newSurface(32, 32, CSDL_Ext::std32bppSurface);
|
||||
for(int f=0; f<ns->w*ns->h*4; ++f)
|
||||
{
|
||||
*((unsigned char*)(ns->pixels) + f) = 128;
|
||||
}
|
||||
|
||||
SDL_BlitSurface(ns,&genRect(sr.h, sr.w, 0, 0),su,&sr);
|
||||
|
||||
SDL_FreeSurface(ns);
|
||||
}
|
||||
#endif
|
||||
#ifdef MARK_VISITABLE_POSITIONS
|
||||
if(ttiles[x+bx][y+by][level].tileInfo->visitable) //temporary hiding visitable positions
|
||||
{
|
||||
SDL_Rect sr;
|
||||
sr.y=by*32 + moveY;
|
||||
sr.x=bx*32 + moveX;
|
||||
sr.h=sr.w=32;
|
||||
//validateRectTerr(&sr, extRect);
|
||||
|
||||
SDL_Surface * ns = CSDL_Ext::newSurface(32, 32, CSDL_Ext::std32bppSurface);
|
||||
for(int f=0; f<ns->w*ns->h*4; ++f)
|
||||
{
|
||||
*((unsigned char*)(ns->pixels) + f) = 128;
|
||||
}
|
||||
|
||||
SDL_BlitSurface(ns,&genRect(sr.h, sr.w, 0, 0),su,&sr);
|
||||
|
||||
SDL_FreeSurface(ns);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
//borders printed
|
||||
SDL_SetClipRect(su, &prevClip); //restoring clip_rect
|
||||
return su;
|
||||
}
|
||||
SDL_Surface * CMapHandler::getVisBitmap(int x, int y, const std::vector< std::vector< std::vector<unsigned char> > > & visibilityMap, int lvl)
|
||||
{
|
||||
int size = visibilityMap.size()-1; //is tile visible. arrangement: (like num keyboard)
|
||||
|
@ -3,8 +3,8 @@
|
||||
#include "global.h"
|
||||
#include <list>
|
||||
#include <set>
|
||||
const int Woff = 12; //width of map's frame
|
||||
const int Hoff = 8;
|
||||
const int Woff = 13; //width of map's frame
|
||||
const int Hoff = 10;
|
||||
|
||||
class CGObjectInstance;
|
||||
class CGHeroInstance;
|
||||
@ -107,8 +107,7 @@ public:
|
||||
void roadsRiverTerrainInit();
|
||||
void prepareFOWDefs();
|
||||
|
||||
SDL_Surface * terrainRect(int x, int y, int dx, int dy, int level, unsigned char anim, std::vector< std::vector< std::vector<unsigned char> > > * visibilityMap, bool otherHeroAnim, unsigned char heroAnim, SDL_Surface * extSurf, SDL_Rect * extRect);
|
||||
SDL_Surface * terrainRectSmooth(int x, int y, int dx, int dy, int level=0, unsigned char anim=0, std::vector< std::vector< std::vector<unsigned char> > > * visibilityMap = NULL, bool otherHeroAnim = false, unsigned char heroAnim = 0, SDL_Surface * extSurf = NULL, SDL_Rect * extRect = NULL, int moveX = 0, int moveY = 0); //if extSurf is specified, blit to it
|
||||
SDL_Surface * terrainRect(int x, int y, int dx, int dy, int level, unsigned char anim, std::vector< std::vector< std::vector<unsigned char> > > * visibilityMap, bool otherHeroAnim, unsigned char heroAnim, SDL_Surface * extSurf, SDL_Rect * extRect, int moveX, int moveY, bool smooth);
|
||||
void updateWater();
|
||||
unsigned char getHeroFrameNum(const unsigned char & dir, const bool & isMoving) const; //terrainRect helper function
|
||||
void validateRectTerr(SDL_Rect * val, const SDL_Rect * ext); //terrainRect helper
|
||||
|
Reference in New Issue
Block a user