1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-15 01:24:45 +02:00

* working pathfinder

* drawing paths
* new command "P X1 Y1 Z1 X2 Y2 Z2" - draws path between given points
* borders handling rewritten
* minor stuff
This commit is contained in:
Michał W. Urbańczyk
2007-08-17 17:42:21 +00:00
parent d708669a75
commit 7d704c7f02
18 changed files with 629 additions and 256 deletions

View File

@ -84,73 +84,70 @@ void CMapHandler::init()
//for (int ii=0;ii<reader->map.width+2*Woff;ii++)
// roadBitmaps[ii] = new SDL_Surface*[reader->map.height+2*Hoff]; // allocate memory
ttiles.resize(CGI->ac->map.width+2*Woff);
for (int i=0;i<ttiles.size();i++)
ttiles.resize(CGI->ac->map.width,Woff);
for (int i=0-Woff;i<ttiles.size()-Woff;i++)
{
ttiles[i].resize(CGI->ac->map.height+2*Hoff);
ttiles[i].resize(CGI->ac->map.height,Hoff);
}
for (int i=0;i<ttiles.size();i++)
for (int i=0-Woff;i<ttiles.size()-Woff;i++)
{
for (int j=0;j<CGI->ac->map.height+2*Hoff;j++)
ttiles[i][j].resize(CGI->ac->map.twoLevel+1);
for (int j=0-Hoff;j<CGI->ac->map.height+Hoff;j++)
ttiles[i][j].resize(CGI->ac->map.twoLevel+1,0);
}
for (int i=0; i<reader->map.width+2*Woff; i++) //jest po szeroko�ci
for (int i=0; i<reader->map.width; i++) //jest po szeroko�ci
{
for (int j=0; j<reader->map.height+2*Hoff;j++) //po wysoko�ci
for (int j=0; j<reader->map.height;j++) //po wysoko�ci
{
if(!(i<Woff || i>reader->map.width+Woff-1 || j<Woff || j>reader->map.height+Hoff-1))
for (int k=0; k<=reader->map.twoLevel; ++k)
{
for (int k=0; k<=reader->map.twoLevel; ++k)
TerrainTile** pomm = reader->map.terrain; ;
if (k==0)
pomm = reader->map.terrain;
else
pomm = reader->map.undergroungTerrain;
if(pomm[i][j].malle)
{
TerrainTile** pomm = reader->map.terrain; ;
if (k==0)
pomm = reader->map.terrain;
else
pomm = reader->map.undergroungTerrain;
if(pomm[i-Woff][j-Hoff].malle)
int cDir;
bool rotV, rotH;
if(k==0)
{
int cDir;
bool rotV, rotH;
if(k==0)
{
int roadpom = reader->map.terrain[i-Woff][j-Hoff].malle-1,
impom = reader->map.terrain[i-Woff][j-Hoff].roadDir;
SDL_Surface *pom1 = roadDefs[roadpom]->ourImages[impom].bitmap;
ttiles[i][j][k].roadbitmap.push_back(pom1);
cDir = reader->map.terrain[i-Woff][j-Hoff].roadDir;
rotH = (reader->map.terrain[i-Woff][j-Hoff].siodmyTajemniczyBajt >> 5) & 1;
rotV = (reader->map.terrain[i-Woff][j-Hoff].siodmyTajemniczyBajt >> 4) & 1;
}
else
{
int pom111 = reader->map.undergroungTerrain[i-Woff][j-Hoff].malle-1,
pom777 = reader->map.undergroungTerrain[i-Woff][j-Hoff].roadDir;
SDL_Surface *pom1 = roadDefs[pom111]->ourImages[pom777].bitmap;
ttiles[i][j][k].roadbitmap.push_back(pom1);
cDir = reader->map.undergroungTerrain[i-Woff][j-Hoff].roadDir;
int roadpom = reader->map.terrain[i][j].malle-1,
impom = reader->map.terrain[i][j].roadDir;
SDL_Surface *pom1 = roadDefs[roadpom]->ourImages[impom].bitmap;
ttiles[i][j][k].roadbitmap.push_back(pom1);
cDir = reader->map.terrain[i][j].roadDir;
rotH = (reader->map.terrain[i][j].siodmyTajemniczyBajt >> 5) & 1;
rotV = (reader->map.terrain[i][j].siodmyTajemniczyBajt >> 4) & 1;
}
else
{
int pom111 = reader->map.undergroungTerrain[i][j].malle-1,
pom777 = reader->map.undergroungTerrain[i][j].roadDir;
SDL_Surface *pom1 = roadDefs[pom111]->ourImages[pom777].bitmap;
ttiles[i][j][k].roadbitmap.push_back(pom1);
cDir = reader->map.undergroungTerrain[i][j].roadDir;
rotH = (reader->map.undergroungTerrain[i-Woff][j-Hoff].siodmyTajemniczyBajt >> 5) & 1;
rotV = (reader->map.undergroungTerrain[i-Woff][j-Hoff].siodmyTajemniczyBajt >> 4) & 1;
}
if(rotH)
{
ttiles[i][j][k].roadbitmap[0] = CSDL_Ext::hFlip(ttiles[i][j][k].roadbitmap[0]);
}
if(rotV)
{
ttiles[i][j][k].roadbitmap[0] = CSDL_Ext::rotate01(ttiles[i][j][k].roadbitmap[0]);
}
if(rotH || rotV)
{
ttiles[i][j][k].roadbitmap[0] = CSDL_Ext::alphaTransform(ttiles[i][j][k].roadbitmap[0]);
SDL_Surface * buf = CSDL_Ext::secondAlphaTransform(ttiles[i][j][k].roadbitmap[0], su);
SDL_FreeSurface(ttiles[i][j][k].roadbitmap[0]);
ttiles[i][j][k].roadbitmap[0] = buf;
}
rotH = (reader->map.undergroungTerrain[i][j].siodmyTajemniczyBajt >> 5) & 1;
rotV = (reader->map.undergroungTerrain[i][j].siodmyTajemniczyBajt >> 4) & 1;
}
if(rotH)
{
ttiles[i][j][k].roadbitmap[0] = CSDL_Ext::hFlip(ttiles[i][j][k].roadbitmap[0]);
}
if(rotV)
{
ttiles[i][j][k].roadbitmap[0] = CSDL_Ext::rotate01(ttiles[i][j][k].roadbitmap[0]);
}
if(rotH || rotV)
{
ttiles[i][j][k].roadbitmap[0] = CSDL_Ext::alphaTransform(ttiles[i][j][k].roadbitmap[0]);
SDL_Surface * buf = CSDL_Ext::secondAlphaTransform(ttiles[i][j][k].roadbitmap[0], su);
SDL_FreeSurface(ttiles[i][j][k].roadbitmap[0]);
ttiles[i][j][k].roadbitmap[0] = buf;
}
}
}
@ -158,39 +155,37 @@ void CMapHandler::init()
}
//initializing simple values
for (int i=0; i<ttiles.size(); i++) //jest po szeroko�ci
for (int i=0; i<CGI->ac->map.width; i++) //jest po szeroko�ci
{
for (int j=0; j<ttiles[0].size();j++) //po wysoko�ci
for (int j=0; j<CGI->ac->map.height;j++) //po wysoko�ci
{
for(int k=0; k<ttiles[0][0].size(); ++k)
{
ttiles[i][j][k].pos = int3(i, j, k);
ttiles[i][j][k].blocked = false;
ttiles[i][j][k].visitable = false;
if(i<Woff || j<Hoff || i>=CGI->ac->map.width+Woff || j>=CGI->ac->map.height+Hoff)
if(i<0 || j<0 || i>=CGI->ac->map.width || j>=CGI->ac->map.height)
{
ttiles[i][j][k].blocked = true;
continue;
}
ttiles[i][j][k].terType = (k==0 ? CGI->ac->map.terrain[i-Woff][j-Hoff].tertype : CGI->ac->map.undergroungTerrain[i-Woff][j-Hoff].tertype);
ttiles[i][j][k].malle = (k==0 ? CGI->ac->map.terrain[i-Woff][j-Hoff].malle : CGI->ac->map.undergroungTerrain[i-Woff][j-Hoff].malle);
ttiles[i][j][k].nuine = (k==0 ? CGI->ac->map.terrain[i-Woff][j-Hoff].nuine : CGI->ac->map.undergroungTerrain[i-Woff][j-Hoff].nuine);
ttiles[i][j][k].rivdir = (k==0 ? CGI->ac->map.terrain[i-Woff][j-Hoff].rivDir : CGI->ac->map.undergroungTerrain[i-Woff][j-Hoff].rivDir);
ttiles[i][j][k].roaddir = (k==0 ? CGI->ac->map.terrain[i-Woff][j-Hoff].roadDir : CGI->ac->map.undergroungTerrain[i-Woff][j-Hoff].roadDir);
ttiles[i][j][k].terType = (k==0 ? CGI->ac->map.terrain[i][j].tertype : CGI->ac->map.undergroungTerrain[i][j].tertype);
ttiles[i][j][k].malle = (k==0 ? CGI->ac->map.terrain[i][j].malle : CGI->ac->map.undergroungTerrain[i][j].malle);
ttiles[i][j][k].nuine = (k==0 ? CGI->ac->map.terrain[i][j].nuine : CGI->ac->map.undergroungTerrain[i][j].nuine);
ttiles[i][j][k].rivdir = (k==0 ? CGI->ac->map.terrain[i][j].rivDir : CGI->ac->map.undergroungTerrain[i][j].rivDir);
ttiles[i][j][k].roaddir = (k==0 ? CGI->ac->map.terrain[i][j].roadDir : CGI->ac->map.undergroungTerrain[i][j].roadDir);
}
}
}
//simple values initialized
for (int i=0; i<reader->map.width+Woff; i++) //jest po szeroko�ci
for (int i=0; i<reader->map.width; i++) //jest po szeroko�ci
{
for (int j=0; j<reader->map.height+Hoff;j++) //po wysoko�ci
for (int j=0; j<reader->map.height;j++) //po wysoko�ci
{
for(int k=0; k<=reader->map.twoLevel; ++k)
{
if(i<4 || j<4)
continue;
TerrainTile** pomm = reader->map.terrain;
if(k==0)
{
@ -200,23 +195,23 @@ void CMapHandler::init()
{
pomm = reader->map.undergroungTerrain;
}
if(pomm[i-Woff][j-Hoff].nuine)
if(pomm[i][j].nuine)
{
int cDir;
bool rotH, rotV;
if(k==0)
{
ttiles[i][j][k].rivbitmap.push_back(staticRiverDefs[reader->map.terrain[i-Woff][j-Hoff].nuine-1]->ourImages[reader->map.terrain[i-Woff][j-Hoff].rivDir].bitmap);
cDir = reader->map.terrain[i-Woff][j-Hoff].rivDir;
rotH = (reader->map.terrain[i-Woff][j-Hoff].siodmyTajemniczyBajt >> 3) & 1;
rotV = (reader->map.terrain[i-Woff][j-Hoff].siodmyTajemniczyBajt >> 2) & 1;
ttiles[i][j][k].rivbitmap.push_back(staticRiverDefs[reader->map.terrain[i][j].nuine-1]->ourImages[reader->map.terrain[i][j].rivDir].bitmap);
cDir = reader->map.terrain[i][j].rivDir;
rotH = (reader->map.terrain[i][j].siodmyTajemniczyBajt >> 3) & 1;
rotV = (reader->map.terrain[i][j].siodmyTajemniczyBajt >> 2) & 1;
}
else
{
ttiles[i][j][k].rivbitmap.push_back(staticRiverDefs[reader->map.undergroungTerrain[i-Woff][j-Hoff].nuine-1]->ourImages[reader->map.undergroungTerrain[i-Woff][j-Hoff].rivDir].bitmap);
cDir = reader->map.undergroungTerrain[i-Woff][j-Hoff].rivDir;
rotH = (reader->map.undergroungTerrain[i-Woff][j-Hoff].siodmyTajemniczyBajt >> 3) & 1;
rotV = (reader->map.undergroungTerrain[i-Woff][j-Hoff].siodmyTajemniczyBajt >> 2) & 1;
ttiles[i][j][k].rivbitmap.push_back(staticRiverDefs[reader->map.undergroungTerrain[i][j].nuine-1]->ourImages[reader->map.undergroungTerrain[i][j].rivDir].bitmap);
cDir = reader->map.undergroungTerrain[i][j].rivDir;
rotH = (reader->map.undergroungTerrain[i][j].siodmyTajemniczyBajt >> 3) & 1;
rotV = (reader->map.undergroungTerrain[i][j].siodmyTajemniczyBajt >> 2) & 1;
}
if(rotH)
{
@ -247,50 +242,50 @@ void CMapHandler::init()
// terrainBitmap[ii] = new SDL_Surface*[reader->map.height+2*Hoff]; // allocate memory
CDefHandler * bord = CGameInfo::mainObj->spriteh->giveDef("EDG.DEF");
for (int i=0; i<reader->map.width+2*Woff; i++) //jest po szeroko�ci
for (int i=0-Woff; i<reader->map.width+Woff; i++) //jest po szeroko�ci
{
for (int j=0; j<reader->map.height+2*Hoff;j++) //po wysoko�ci
for (int j=0-Hoff; j<reader->map.height+Hoff;j++) //po wysoko�ci
{
for(int k=0; k<=reader->map.twoLevel; ++k)
{
if(i < Woff || i > (reader->map.width+Woff-1) || j < Hoff || j > (reader->map.height+Hoff-1))
if(i < 0 || i > (reader->map.width-1) || j < 0 || j > (reader->map.height-1))
{
if(i==Woff-1 && j==Hoff-1)
if(i==-1 && j==-1)
{
ttiles[i][j][k].terbitmap.push_back(bord->ourImages[16].bitmap);
continue;
}
else if(i==Woff-1 && j==(reader->map.height+Hoff))
else if(i==-1 && j==(reader->map.height))
{
ttiles[i][j][k].terbitmap.push_back(bord->ourImages[19].bitmap);
continue;
}
else if(i==(reader->map.width+Woff) && j==Hoff-1)
else if(i==(reader->map.width) && j==-1)
{
ttiles[i][j][k].terbitmap.push_back(bord->ourImages[17].bitmap);
continue;
}
else if(i==(reader->map.width+Woff) && j==(reader->map.height+Hoff))
else if(i==(reader->map.width) && j==(reader->map.height))
{
ttiles[i][j][k].terbitmap.push_back(bord->ourImages[18].bitmap);
continue;
}
else if(j == Hoff-1 && i > Woff-1 && i < reader->map.height+Woff)
else if(j == -1 && i > -1 && i < reader->map.height)
{
ttiles[i][j][k].terbitmap.push_back(bord->ourImages[22+rand()%2].bitmap);
continue;
}
else if(i == Woff-1 && j > Hoff-1 && j < reader->map.height+Hoff)
else if(i == -1 && j > -1 && j < reader->map.height)
{
ttiles[i][j][k].terbitmap.push_back(bord->ourImages[33+rand()%2].bitmap);
continue;
}
else if(j == reader->map.height+Hoff && i > Woff-1 && i < reader->map.width+Woff)
else if(j == reader->map.height && i >-1 && i < reader->map.width)
{
ttiles[i][j][k].terbitmap.push_back(bord->ourImages[29+rand()%2].bitmap);
continue;
}
else if(i == reader->map.width+Woff && j > Hoff-1 && j < reader->map.height+Hoff)
else if(i == reader->map.width && j > -1 && j < reader->map.height)
{
ttiles[i][j][k].terbitmap.push_back(bord->ourImages[25+rand()%2].bitmap);
continue;
@ -304,9 +299,9 @@ void CMapHandler::init()
//TerrainTile zz = reader->map.terrain[i-Woff][j-Hoff];
std::string name;
if (k>0)
name = CSemiDefHandler::nameFromType(reader->map.undergroungTerrain[i-Woff][j-Hoff].tertype);
name = CSemiDefHandler::nameFromType(reader->map.undergroungTerrain[i][j].tertype);
else
name = CSemiDefHandler::nameFromType(reader->map.terrain[i-Woff][j-Hoff].tertype);
name = CSemiDefHandler::nameFromType(reader->map.terrain[i][j].tertype);
for (unsigned int m=0; m<reader->defs.size(); m++)
{
try
@ -317,15 +312,15 @@ void CMapHandler::init()
{
int ktora;
if (k==0)
ktora = reader->map.terrain[i-Woff][j-Hoff].terview;
ktora = reader->map.terrain[i][j].terview;
else
ktora = reader->map.undergroungTerrain[i-Woff][j-Hoff].terview;
ktora = reader->map.undergroungTerrain[i][j].terview;
ttiles[i][j][k].terbitmap.push_back(reader->defs[m]->ourImages[ktora].bitmap);
int zz;
if (k==0)
zz = (reader->map.terrain[i-Woff][j-Hoff].siodmyTajemniczyBajt)%4;
zz = (reader->map.terrain[i][j].siodmyTajemniczyBajt)%4;
else
zz = (reader->map.undergroungTerrain[i-Woff][j-Hoff].siodmyTajemniczyBajt)%4;
zz = (reader->map.undergroungTerrain[i][j].siodmyTajemniczyBajt)%4;
switch (zz)
{
case 1:
@ -359,6 +354,8 @@ void CMapHandler::init()
//initializing objects / rects
for(int f=0; f<CGI->objh->objInstances.size(); ++f)
{
CGI->objh->objInstances[f]->pos.x+=1;
CGI->objh->objInstances[f]->pos.y+=1;
CDefHandler * curd = CGI->ac->map.defy[CGI->objh->objInstances[f]->defNumber].handler;
for(int fx=0; fx<curd->ourImages[0].bitmap->w/32; ++fx)
{
@ -370,10 +367,16 @@ 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+Woff)>=0 && (CGI->objh->objInstances[f]->pos.x + fx - curd->ourImages[0].bitmap->w/32+Woff)<=ttiles.size() && (CGI->objh->objInstances[f]->pos.y + fy - curd->ourImages[0].bitmap->h/32+Hoff)>=0 && (CGI->objh->objInstances[f]->pos.y + fy - curd->ourImages[0].bitmap->h/32+Hoff)<=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() && (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())
{
TerrainTile2 & curt = ttiles[CGI->objh->objInstances[f]->pos.x + fx - curd->ourImages[0].bitmap->w/32+Woff][CGI->objh->objInstances[f]->pos.y + fy - curd->ourImages[0].bitmap->h/32+Hoff][CGI->objh->objInstances[f]->pos.z];
ttiles[CGI->objh->objInstances[f]->pos.x + fx - curd->ourImages[0].bitmap->w/32+Woff][CGI->objh->objInstances[f]->pos.y + fy - curd->ourImages[0].bitmap->h/32+Hoff][CGI->objh->objInstances[f]->pos.z].objects.push_back(toAdd);
TerrainTile2 & curt =
ttiles
[CGI->objh->objInstances[f]->pos.x + fx - curd->ourImages[0].bitmap->w/32]
[CGI->objh->objInstances[f]->pos.y + fy - curd->ourImages[0].bitmap->h/32]
[CGI->objh->objInstances[f]->pos.z];
ttiles[CGI->objh->objInstances[f]->pos.x + fx - curd->ourImages[0].bitmap->w/32][CGI->objh->objInstances[f]->pos.y + fy - curd->ourImages[0].bitmap->h/32][CGI->objh->objInstances[f]->pos.z].objects.push_back(toAdd);
}
} // for(int fy=0; fy<curd->ourImages[0].bitmap->h/32; ++fy)
@ -388,10 +391,10 @@ void CMapHandler::init()
{
for(int fy=0; fy<6; ++fy)
{
int xVal = CGI->objh->objInstances[f]->pos.x + Woff + fx - 7;
int yVal = CGI->objh->objInstances[f]->pos.y + Hoff + fy - 5;
int xVal = CGI->objh->objInstances[f]->pos.x + fx - 8;
int yVal = CGI->objh->objInstances[f]->pos.y + fy - 6;
int zVal = CGI->objh->objInstances[f]->pos.z;
if(xVal>=0 && xVal<ttiles.size() && yVal>=0 && yVal<ttiles[0].size())
if(xVal>=0 && xVal<ttiles.size()-Woff && yVal>=0 && yVal<ttiles[0].size()-Hoff)
{
TerrainTile2 & curt = ttiles[xVal][yVal][zVal];
if(((CGI->dobjinfo->objs[CGI->objh->objInstances[f]->defObjInfoNumber].visitMap[fy] >> (7 - fx)) & 1))
@ -402,9 +405,9 @@ void CMapHandler::init()
}
}
}
for(int ix=0; ix<ttiles.size(); ++ix)
for(int ix=0; ix<ttiles.size()-Woff; ++ix)
{
for(int iy=0; iy<ttiles[0].size(); ++iy)
for(int iy=0; iy<ttiles[0].size()-Hoff; ++iy)
{
for(int iz=0; iz<ttiles[0][0].size(); ++iz)
{
@ -430,7 +433,7 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
SDL_Surface * su = SDL_CreateRGBSurface(SDL_SWSURFACE, dx*32, dy*32, 32,
rmask, gmask, bmask, amask);
if (((dx+x)>((reader->map.width+8)) || (dy+y)>((reader->map.height+8))) || ((x<0)||(y<0) ) )
if (((dx+x)>((reader->map.width+Woff)) || (dy+y)>((reader->map.height+Hoff))) || ((x<-Woff)||(y<-Hoff) ) )
throw new std::string("terrainRect: out of range");
////printing terrain
for (int bx=0; bx<dx; bx++)
@ -478,9 +481,9 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
////roads printed
////printing objects
for (int bx=(x==0 ? 0 : -1); bx<dx; bx++)
for (int bx=0; bx<dx; bx++)
{
for (int by=( y==0 ? 0 : -1); by<dy; by++)
for (int by=0; by<dy; by++)
{
if(true)
{
@ -489,8 +492,8 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
SDL_Rect * sr = new SDL_Rect;
sr->w = 32;
sr->h = 32;
sr->x = (bx+1)*32;
sr->y = (by+1)*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[
@ -518,7 +521,7 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
if (!level)
{
if( bx+x>Woff-1 && by+y>Hoff-1 && bx+x<visibility.size()-(Woff-1) && by+y<visibility[0].size()-(Hoff-1) && !visibility[bx+x][by+y])
if( bx+x>-1 && by+y>-1 && bx+x<visibility.size()-(-1) && by+y<visibility[0].size()-(-1) && !visibility[bx+x][by+y])
{
SDL_Surface * hide = getVisBitmap(bx+x, by+y, visibility);
SDL_Surface * hide2 = CSDL_Ext::secondAlphaTransform(hide, su);
@ -528,7 +531,7 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
}
else
{
if( bx+x>Woff-1 && by+y>Hoff-1 && bx+x<undVisibility.size()-(Woff-1) && by+y<undVisibility[0].size()-(Hoff-1) && !undVisibility[bx+x][by+y])
if( bx+x>-1 && by+y>-1 && bx+x<undVisibility.size()-(-1) && by+y<undVisibility[0].size()-(-1) && !undVisibility[bx+x][by+y])
{
SDL_Surface * hide = getVisBitmap(bx+x, by+y, undVisibility);
SDL_Surface * hide2 = CSDL_Ext::secondAlphaTransform(hide, su);
@ -541,11 +544,11 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
}
////shadow printed
//printing borders
for (int bx=(x==0 ? 0 : -1); bx<dx; bx++)
for (int bx=0; bx<dx; bx++)
{
for (int by=(y==0 ? 0 : -1); by<dy; by++)
for (int by=0; by<dy; by++)
{
if(bx+x<Woff || by+y<Hoff || bx+x>reader->map.width+(Woff-1) || by+y>reader->map.height+(Hoff-1))
if(bx+x<0 || by+y<0 || bx+x>reader->map.width+(-1) || by+y>reader->map.height+(-1))
{
SDL_Rect * sr = new SDL_Rect;
sr->y=by*32;