2007-06-06 19:12:12 +03:00
|
|
|
#include "stdafx.h"
|
|
|
|
#include "mapHandler.h"
|
|
|
|
#include "CSemiDefHandler.h"
|
|
|
|
#include "SDL_rotozoom.h"
|
2007-06-07 04:46:25 +03:00
|
|
|
#include "SDL_Extensions.h"
|
2007-06-22 19:36:05 +03:00
|
|
|
#include "CGameInfo.h"
|
2007-06-25 17:55:45 +03:00
|
|
|
#include "stdlib.h"
|
2007-06-22 19:36:05 +03:00
|
|
|
|
2007-06-06 19:12:12 +03:00
|
|
|
extern SDL_Surface * ekran;
|
2007-06-25 17:55:45 +03:00
|
|
|
void CMapHandler::init()
|
2007-06-06 19:12:12 +03:00
|
|
|
{
|
2007-06-25 17:55:45 +03:00
|
|
|
fullHide = CGameInfo::mainObj->sspriteh->giveDef("TSHRC.DEF", 2);
|
|
|
|
partialHide = CGameInfo::mainObj->sspriteh->giveDef("TSHRE.DEF", 2);
|
|
|
|
|
|
|
|
for(int i=0; i<partialHide->ourImages.size(); ++i)
|
|
|
|
{
|
2007-06-26 15:38:58 +03:00
|
|
|
CSDL_Ext::alphaTransform(partialHide->ourImages[i].bitmap);
|
2007-06-25 17:55:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
visibility.resize(reader->map.width+8);
|
|
|
|
for(int gg=0; gg<reader->map.width+8; ++gg)
|
|
|
|
{
|
|
|
|
visibility[gg].resize(reader->map.height+8);
|
|
|
|
for(int jj=0; jj<reader->map.height+8; ++jj)
|
|
|
|
visibility[gg][jj] = true;
|
|
|
|
}
|
|
|
|
undVisibility.resize(reader->map.width+8);
|
|
|
|
for(int gg=0; gg<reader->map.width+8; ++gg)
|
|
|
|
{
|
|
|
|
undVisibility[gg].resize(reader->map.height+8);
|
|
|
|
for(int jj=0; jj<reader->map.height+8; ++jj)
|
|
|
|
undVisibility[gg][jj] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
visibility[6][7] = false;
|
|
|
|
undVisibility[5][7] = false;
|
|
|
|
visibility[7][7] = false;
|
|
|
|
visibility[6][8] = false;
|
|
|
|
visibility[6][6] = false;
|
|
|
|
//visibility[5][6] = false;
|
|
|
|
//visibility[7][8] = false;
|
|
|
|
visibility[5][8] = false;
|
|
|
|
visibility[7][6] = false;
|
|
|
|
visibility[6][9] = false;
|
|
|
|
|
2007-06-22 19:36:05 +03:00
|
|
|
terrainBitmap = new SDL_Surface **[reader->map.width+8];
|
|
|
|
for (int ii=0;ii<reader->map.width+8;ii++)
|
|
|
|
terrainBitmap[ii] = new SDL_Surface*[reader->map.height+8]; // allocate memory
|
|
|
|
CSemiDefHandler * bord = CGameInfo::mainObj->sspriteh->giveDef("EDG.DEF");
|
|
|
|
for (int i=0; i<reader->map.width+8; i++) //jest po szeroko�ci
|
2007-06-06 19:12:12 +03:00
|
|
|
{
|
2007-06-22 19:36:05 +03:00
|
|
|
for (int j=0; j<reader->map.height+8;j++) //po wysoko�ci
|
2007-06-06 19:12:12 +03:00
|
|
|
{
|
2007-06-22 19:36:05 +03:00
|
|
|
if(i < 4 || i > (reader->map.width+3) || j < 4 || j > (reader->map.height+3))
|
|
|
|
{
|
|
|
|
if(i==3 && j==3)
|
|
|
|
{
|
|
|
|
terrainBitmap[i][j] = bord->ourImages[16].bitmap;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if(i==3 && j==(reader->map.height+4))
|
|
|
|
{
|
|
|
|
terrainBitmap[i][j] = bord->ourImages[19].bitmap;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if(i==(reader->map.width+4) && j==3)
|
|
|
|
{
|
|
|
|
terrainBitmap[i][j] = bord->ourImages[17].bitmap;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if(i==(reader->map.width+4) && j==(reader->map.height+4))
|
|
|
|
{
|
|
|
|
terrainBitmap[i][j] = bord->ourImages[18].bitmap;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if(j == 3 && i > 3 && i < reader->map.height+4)
|
|
|
|
{
|
|
|
|
terrainBitmap[i][j] = bord->ourImages[22+rand()%2].bitmap;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if(i == 3 && j > 3 && j < reader->map.height+4)
|
|
|
|
{
|
|
|
|
terrainBitmap[i][j] = bord->ourImages[33+rand()%2].bitmap;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if(j == reader->map.height+4 && i > 3 && i < reader->map.width+4)
|
|
|
|
{
|
|
|
|
terrainBitmap[i][j] = bord->ourImages[29+rand()%2].bitmap;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if(i == reader->map.width+4 && j > 3 && j < reader->map.height+4)
|
|
|
|
{
|
|
|
|
terrainBitmap[i][j] = bord->ourImages[25+rand()%2].bitmap;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
terrainBitmap[i][j] = bord->ourImages[rand()%16].bitmap;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
TerrainTile zz = reader->map.terrain[i-4][j-4];
|
|
|
|
std::string name = CSemiDefHandler::nameFromType(reader->map.terrain[i-4][j-4].tertype);
|
2007-06-12 21:17:33 +03:00
|
|
|
for (unsigned int k=0; k<reader->defs.size(); k++)
|
2007-06-06 19:12:12 +03:00
|
|
|
{
|
2007-06-07 19:16:38 +03:00
|
|
|
try
|
2007-06-06 19:12:12 +03:00
|
|
|
{
|
2007-06-07 19:16:38 +03:00
|
|
|
if (reader->defs[k]->defName != name)
|
|
|
|
continue;
|
|
|
|
else
|
2007-06-07 04:46:25 +03:00
|
|
|
{
|
2007-06-07 19:16:38 +03:00
|
|
|
SDL_Surface * n;
|
2007-06-22 19:36:05 +03:00
|
|
|
int ktora = reader->map.terrain[i-4][j-4].terview;
|
2007-06-07 19:16:38 +03:00
|
|
|
terrainBitmap[i][j] = reader->defs[k]->ourImages[ktora].bitmap;
|
|
|
|
//TODO: odwracanie
|
2007-06-22 19:36:05 +03:00
|
|
|
switch ((reader->map.terrain[i-4][j-4].siodmyTajemniczyBajt)%4)
|
2007-06-07 04:46:25 +03:00
|
|
|
{
|
2007-06-07 19:16:38 +03:00
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
terrainBitmap[i][j] = CSDL_Ext::rotate01(terrainBitmap[i][j]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
terrainBitmap[i][j] = CSDL_Ext::hFlip(terrainBitmap[i][j]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 3:
|
|
|
|
{
|
|
|
|
terrainBitmap[i][j] = CSDL_Ext::rotate03(terrainBitmap[i][j]);
|
|
|
|
break;
|
|
|
|
}
|
2007-06-07 04:46:25 +03:00
|
|
|
}
|
2007-06-07 19:16:38 +03:00
|
|
|
//SDL_BlitSurface(terrainBitmap[i][j],NULL,ekran,NULL); SDL_Flip(ekran);SDL_Delay(50);
|
2007-06-06 19:12:12 +03:00
|
|
|
|
2007-06-07 19:16:38 +03:00
|
|
|
break;
|
|
|
|
}
|
2007-06-06 19:12:12 +03:00
|
|
|
}
|
2007-06-07 19:16:38 +03:00
|
|
|
catch (...)
|
|
|
|
{ continue; }
|
2007-06-06 19:12:12 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-06-09 05:32:43 +03:00
|
|
|
if (reader->map.twoLevel)
|
|
|
|
{
|
2007-06-22 19:36:05 +03:00
|
|
|
undTerrainBitmap = new SDL_Surface **[reader->map.width+8];
|
|
|
|
for (int ii=0;ii<reader->map.width+8;ii++)
|
|
|
|
undTerrainBitmap[ii] = new SDL_Surface*[reader->map.height+8]; // allocate memory
|
|
|
|
for (int i=0; i<reader->map.width+8; i++)
|
2007-06-09 05:32:43 +03:00
|
|
|
{
|
2007-06-22 19:36:05 +03:00
|
|
|
for (int j=0; j<reader->map.height+8;j++)
|
2007-06-09 05:32:43 +03:00
|
|
|
{
|
2007-06-22 19:36:05 +03:00
|
|
|
if(i < 4 || i > (reader->map.width+3) || j < 4 || j > (reader->map.height+3))
|
|
|
|
{
|
|
|
|
if(i==3 && j==3)
|
|
|
|
{
|
|
|
|
undTerrainBitmap[i][j] = bord->ourImages[16].bitmap;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if(i==3 && j==(reader->map.height+4))
|
|
|
|
{
|
|
|
|
undTerrainBitmap[i][j] = bord->ourImages[19].bitmap;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if(i==(reader->map.width+4) && j==3)
|
|
|
|
{
|
|
|
|
undTerrainBitmap[i][j] = bord->ourImages[17].bitmap;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if(i==(reader->map.width+4) && j==(reader->map.height+4))
|
|
|
|
{
|
|
|
|
undTerrainBitmap[i][j] = bord->ourImages[18].bitmap;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if(j == 3 && i > 3 && i < reader->map.height+4)
|
|
|
|
{
|
|
|
|
undTerrainBitmap[i][j] = bord->ourImages[22+rand()%2].bitmap;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if(i == 3 && j > 3 && j < reader->map.height+4)
|
|
|
|
{
|
|
|
|
undTerrainBitmap[i][j] = bord->ourImages[33+rand()%2].bitmap;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if(j == reader->map.height+4 && i > 3 && i < reader->map.width+4)
|
|
|
|
{
|
|
|
|
undTerrainBitmap[i][j] = bord->ourImages[29+rand()%2].bitmap;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if(i == reader->map.width+4 && j > 3 && j < reader->map.height+4)
|
|
|
|
{
|
|
|
|
undTerrainBitmap[i][j] = bord->ourImages[25+rand()%2].bitmap;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
undTerrainBitmap[i][j] = bord->ourImages[rand()%16].bitmap;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
TerrainTile zz = reader->map.undergroungTerrain[i-4][j-4];
|
|
|
|
std::string name = CSemiDefHandler::nameFromType(reader->map.undergroungTerrain[i-4][j-4].tertype);
|
2007-06-12 21:17:33 +03:00
|
|
|
for (unsigned int k=0; k<reader->defs.size(); k++)
|
2007-06-09 05:32:43 +03:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
if (reader->defs[k]->defName != name)
|
|
|
|
continue;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SDL_Surface * n;
|
2007-06-22 19:36:05 +03:00
|
|
|
int ktora = reader->map.undergroungTerrain[i-4][j-4].terview;
|
2007-06-09 05:32:43 +03:00
|
|
|
undTerrainBitmap[i][j] = reader->defs[k]->ourImages[ktora].bitmap;
|
|
|
|
//TODO: odwracanie
|
2007-06-22 19:36:05 +03:00
|
|
|
switch ((reader->map.undergroungTerrain[i-4][j-4].siodmyTajemniczyBajt)%4)
|
2007-06-09 05:32:43 +03:00
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
undTerrainBitmap[i][j] = CSDL_Ext::rotate01(undTerrainBitmap[i][j]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
undTerrainBitmap[i][j] = CSDL_Ext::hFlip(undTerrainBitmap[i][j]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 3:
|
|
|
|
{
|
|
|
|
undTerrainBitmap[i][j] = CSDL_Ext::rotate03(undTerrainBitmap[i][j]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//SDL_BlitSurface(undTerrainBitmap[i][j],NULL,ekran,NULL); SDL_Flip(ekran);SDL_Delay(50);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{ continue; }
|
|
|
|
}
|
2007-06-25 17:55:45 +03:00
|
|
|
} //end of internal for
|
|
|
|
} //end of external for
|
|
|
|
} //end of if
|
2007-06-06 19:12:12 +03:00
|
|
|
}
|
2007-06-25 17:55:45 +03:00
|
|
|
|
|
|
|
SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level)
|
2007-06-06 19:12:12 +03:00
|
|
|
{
|
|
|
|
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
|
|
|
int rmask = 0xff000000;
|
|
|
|
int gmask = 0x00ff0000;
|
|
|
|
int bmask = 0x0000ff00;
|
|
|
|
int amask = 0x000000ff;
|
|
|
|
#else
|
|
|
|
int rmask = 0x000000ff;
|
|
|
|
int gmask = 0x0000ff00;
|
|
|
|
int bmask = 0x00ff0000;
|
|
|
|
int amask = 0xff000000;
|
|
|
|
#endif
|
2007-06-25 17:55:45 +03:00
|
|
|
|
2007-06-06 19:12:12 +03:00
|
|
|
SDL_Surface * su = SDL_CreateRGBSurface(SDL_SWSURFACE, dx*32, dy*32, 32,
|
|
|
|
rmask, gmask, bmask, amask);
|
2007-06-22 19:36:05 +03:00
|
|
|
if (((dx+x)>((reader->map.width+8)) || (dy+y)>((reader->map.height+8))) || ((x<0)||(y<0) ) )
|
2007-06-07 19:16:38 +03:00
|
|
|
throw new std::string("Poza zakresem");
|
2007-06-06 19:12:12 +03:00
|
|
|
for (int bx=0; bx<dx; bx++)
|
|
|
|
{
|
|
|
|
for (int by=0; by<dy; by++)
|
|
|
|
{
|
|
|
|
SDL_Rect * sr = new SDL_Rect;
|
|
|
|
sr->y=by*32;
|
|
|
|
sr->x=bx*32;
|
|
|
|
sr->h=sr->w=32;
|
2007-06-09 05:32:43 +03:00
|
|
|
if (!level)
|
2007-06-25 17:55:45 +03:00
|
|
|
{
|
2007-06-09 05:32:43 +03:00
|
|
|
SDL_BlitSurface(terrainBitmap[bx+x][by+y],NULL,su,sr);
|
2007-06-25 17:55:45 +03:00
|
|
|
if( bx+x>3 && by+y>3 && bx+x<visibility.size()-3 && by+y<visibility[0].size()-3 && !visibility[bx+x][by+y])
|
|
|
|
{
|
2007-06-26 15:38:58 +03:00
|
|
|
SDL_Surface * hide = getVisBitmap(bx+x, by+y, visibility);
|
2007-06-25 17:55:45 +03:00
|
|
|
Uint32 pompom[32][32];
|
|
|
|
for(int i=0; i<hide->w; ++i)
|
|
|
|
{
|
|
|
|
for(int j=0; j<hide->h; ++j)
|
|
|
|
{
|
|
|
|
pompom[i][j] = 0xffffffff - (CSDL_Ext::SDL_GetPixel(hide, i, j, true) & 0xff000000);
|
|
|
|
}
|
|
|
|
}
|
2007-06-26 15:38:58 +03:00
|
|
|
SDL_Surface * hide2 = SDL_ConvertSurface(hide, su->format, SDL_SWSURFACE);
|
|
|
|
for(int i=0; i<hide2->w; ++i)
|
2007-06-25 17:55:45 +03:00
|
|
|
{
|
2007-06-26 15:38:58 +03:00
|
|
|
for(int j=0; j<hide2->h; ++j)
|
2007-06-25 17:55:45 +03:00
|
|
|
{
|
2007-06-26 15:38:58 +03:00
|
|
|
Uint32 * place = (Uint32*)( (Uint8*)hide2->pixels + j * hide2->pitch + i * hide2->format->BytesPerPixel);
|
2007-06-25 17:55:45 +03:00
|
|
|
(*place)&=pompom[i][j];
|
|
|
|
}
|
|
|
|
}
|
2007-06-26 15:38:58 +03:00
|
|
|
SDL_BlitSurface(hide2, NULL, su, sr);
|
|
|
|
SDL_FreeSurface(hide2);
|
2007-06-25 17:55:45 +03:00
|
|
|
}
|
|
|
|
}
|
2007-06-09 05:32:43 +03:00
|
|
|
else
|
2007-06-25 17:55:45 +03:00
|
|
|
{
|
2007-06-09 05:32:43 +03:00
|
|
|
SDL_BlitSurface(undTerrainBitmap[bx+x][by+y],NULL,su,sr);
|
2007-06-25 17:55:45 +03:00
|
|
|
if( bx+x>3 && by+y>3 && bx+x<undVisibility.size()-3 && by+y<undVisibility[0].size()-3 && !undVisibility[bx+x][by+y])
|
|
|
|
{
|
2007-06-26 15:38:58 +03:00
|
|
|
SDL_Surface * hide = getVisBitmap(bx+x, by+y, undVisibility);
|
2007-06-25 17:55:45 +03:00
|
|
|
Uint32 pompom[32][32];
|
|
|
|
for(int i=0; i<hide->w; ++i)
|
|
|
|
{
|
|
|
|
for(int j=0; j<hide->h; ++j)
|
|
|
|
{
|
|
|
|
pompom[i][j] = 0xffffffff - (CSDL_Ext::SDL_GetPixel(hide, i, j, true) & 0xff000000);
|
|
|
|
}
|
|
|
|
}
|
2007-06-26 15:38:58 +03:00
|
|
|
SDL_Surface * hide2 = SDL_ConvertSurface(hide, su->format, SDL_SWSURFACE);
|
|
|
|
for(int i=0; i<hide2->w; ++i)
|
2007-06-25 17:55:45 +03:00
|
|
|
{
|
2007-06-26 15:38:58 +03:00
|
|
|
for(int j=0; j<hide2->h; ++j)
|
2007-06-25 17:55:45 +03:00
|
|
|
{
|
2007-06-26 15:38:58 +03:00
|
|
|
Uint32 * place = (Uint32*)( (Uint8*)hide2->pixels + j * hide2->pitch + i * hide2->format->BytesPerPixel);
|
2007-06-25 17:55:45 +03:00
|
|
|
(*place)&=pompom[i][j];
|
|
|
|
}
|
|
|
|
}
|
2007-06-26 15:38:58 +03:00
|
|
|
SDL_BlitSurface(hide2, NULL, su, sr);
|
|
|
|
SDL_FreeSurface(hide2);
|
2007-06-25 17:55:45 +03:00
|
|
|
}
|
|
|
|
}
|
2007-06-08 17:58:04 +03:00
|
|
|
delete sr;
|
2007-06-06 19:12:12 +03:00
|
|
|
//SDL_BlitSurface(su,NULL,ekran,NULL);SDL_Flip(ekran);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return su;
|
|
|
|
}
|
2007-06-25 17:55:45 +03:00
|
|
|
|
|
|
|
SDL_Surface * CMapHandler::terrBitmap(int x, int y)
|
|
|
|
{
|
|
|
|
return terrainBitmap[x+4][y+4];
|
|
|
|
}
|
|
|
|
|
|
|
|
SDL_Surface * CMapHandler::undTerrBitmap(int x, int y)
|
|
|
|
{
|
|
|
|
return undTerrainBitmap[x+4][y+4];
|
|
|
|
}
|
|
|
|
|
2007-06-26 15:38:58 +03:00
|
|
|
SDL_Surface * CMapHandler::getVisBitmap(int x, int y, std::vector< std::vector<char> > & visibility)
|
2007-06-25 17:55:45 +03:00
|
|
|
{
|
|
|
|
if(!visibility[x][y+1] && !visibility[x+1][y] && !visibility[x-1][y] && !visibility[x][y-1] && !visibility[x-1][y-1] && !visibility[x+1][y+1] && !visibility[x+1][y-1] && !visibility[x-1][y+1])
|
|
|
|
{
|
|
|
|
return fullHide->ourImages[rand()%fullHide->ourImages.size()].bitmap; //fully hidden
|
|
|
|
}
|
|
|
|
else if(!visibility[x][y+1] && !visibility[x+1][y] && !visibility[x-1][y] && !visibility[x][y-1] && !visibility[x-1][y-1] && visibility[x+1][y+1] && !visibility[x+1][y-1] && !visibility[x-1][y+1])
|
|
|
|
{
|
|
|
|
return partialHide->ourImages[22].bitmap; //visible right bottom corner
|
|
|
|
}
|
|
|
|
else if(!visibility[x][y+1] && !visibility[x+1][y] && !visibility[x-1][y] && !visibility[x][y-1] && !visibility[x-1][y-1] && !visibility[x+1][y+1] && visibility[x+1][y-1] && !visibility[x-1][y+1])
|
|
|
|
{
|
|
|
|
return partialHide->ourImages[15].bitmap; //visible right top corner
|
|
|
|
}
|
|
|
|
else if(!visibility[x][y+1] && !visibility[x+1][y] && !visibility[x-1][y] && !visibility[x][y-1] && !visibility[x-1][y-1] && !visibility[x+1][y+1] && !visibility[x+1][y-1] && visibility[x-1][y+1])
|
|
|
|
{
|
|
|
|
return CSDL_Ext::rotate01(partialHide->ourImages[22].bitmap); //visible left bottom corner
|
|
|
|
}
|
|
|
|
else if(!visibility[x][y+1] && !visibility[x+1][y] && !visibility[x-1][y] && !visibility[x][y-1] && visibility[x-1][y-1] && !visibility[x+1][y+1] && !visibility[x+1][y-1] && !visibility[x-1][y+1])
|
|
|
|
{
|
|
|
|
return CSDL_Ext::rotate01(partialHide->ourImages[15].bitmap); //visible left top corner
|
|
|
|
}
|
|
|
|
else if(!visibility[x][y+1] && !visibility[x+1][y] && !visibility[x-1][y] && visibility[x][y-1] && visibility[x-1][y-1] && !visibility[x+1][y+1] && visibility[x+1][y-1] && !visibility[x-1][y+1])
|
|
|
|
{
|
|
|
|
return partialHide->ourImages[rand()%2].bitmap; //visible top
|
|
|
|
}
|
|
|
|
else if(visibility[x][y+1] && !visibility[x+1][y] && !visibility[x-1][y] && !visibility[x][y-1] && !visibility[x-1][y-1] && visibility[x+1][y+1] && !visibility[x+1][y-1] && visibility[x-1][y+1])
|
|
|
|
{
|
|
|
|
return partialHide->ourImages[4+rand()%2].bitmap; //visble bottom
|
|
|
|
}
|
|
|
|
else if(!visibility[x][y+1] && !visibility[x+1][y] && visibility[x-1][y] && !visibility[x][y-1] && visibility[x-1][y-1] && !visibility[x+1][y+1] && !visibility[x+1][y-1] && visibility[x-1][y+1])
|
|
|
|
{
|
|
|
|
return CSDL_Ext::rotate01(partialHide->ourImages[2+rand()%2].bitmap); //visible left
|
|
|
|
}
|
|
|
|
else if(!visibility[x][y+1] && visibility[x+1][y] && !visibility[x-1][y] && !visibility[x][y-1] && !visibility[x-1][y-1] && visibility[x+1][y+1] && visibility[x+1][y-1] && !visibility[x-1][y+1])
|
|
|
|
{
|
|
|
|
return partialHide->ourImages[2+rand()%2].bitmap; //visible right
|
|
|
|
}
|
|
|
|
else if(visibility[x][y+1] && visibility[x+1][y] && !visibility[x-1][y] && !visibility[x][y-1] && !visibility[x-1][y-1])
|
|
|
|
{
|
|
|
|
return partialHide->ourImages[12+2*(rand()%2)].bitmap; //visible bottom, right - bottom, right; left top corner hidden
|
|
|
|
}
|
|
|
|
else if(!visibility[x][y+1] && visibility[x+1][y] && !visibility[x-1][y] && visibility[x][y-1] && !visibility[x-1][y+1])
|
|
|
|
{
|
|
|
|
return partialHide->ourImages[13].bitmap; //visible right, right - top; left bottom corner hidden
|
|
|
|
}
|
|
|
|
else if(!visibility[x][y+1] && !visibility[x+1][y] && visibility[x-1][y] && visibility[x][y-1] && !visibility[x+1][y+1])
|
|
|
|
{
|
|
|
|
return CSDL_Ext::rotate01(partialHide->ourImages[13].bitmap); //visible top, top - left, left; right bottom corner hidden
|
|
|
|
}
|
|
|
|
else if(visibility[x][y+1] && !visibility[x+1][y] && visibility[x-1][y] && !visibility[x][y-1] && !visibility[x+1][y-1])
|
|
|
|
{
|
|
|
|
return CSDL_Ext::rotate01(partialHide->ourImages[12+2*(rand()%2)].bitmap); //visible left, left - bottom, bottom; right top corner hidden
|
|
|
|
}
|
|
|
|
else if(visibility[x][y+1] && visibility[x+1][y] && visibility[x-1][y] && visibility[x][y-1] && visibility[x-1][y-1] && visibility[x+1][y+1] && visibility[x+1][y-1] && visibility[x-1][y+1])
|
|
|
|
{
|
|
|
|
return partialHide->ourImages[10].bitmap; //visible left, right, bottom and top
|
|
|
|
}
|
|
|
|
if(!visibility[x][y+1] && !visibility[x+1][y] && !visibility[x-1][y] && !visibility[x][y-1] && !visibility[x-1][y-1] && visibility[x+1][y+1] && visibility[x+1][y-1] && !visibility[x-1][y+1])
|
|
|
|
{
|
|
|
|
return partialHide->ourImages[16].bitmap; //visible right corners
|
|
|
|
}
|
|
|
|
if(!visibility[x][y+1] && !visibility[x+1][y] && !visibility[x-1][y] && !visibility[x][y-1] && visibility[x-1][y-1] && !visibility[x+1][y+1] && visibility[x+1][y-1] && !visibility[x-1][y+1])
|
|
|
|
{
|
|
|
|
return partialHide->ourImages[18].bitmap; //visible top corners
|
|
|
|
}
|
|
|
|
if(!visibility[x][y+1] && !visibility[x+1][y] && !visibility[x-1][y] && !visibility[x][y-1] && visibility[x-1][y-1] && !visibility[x+1][y+1] && !visibility[x+1][y-1] && visibility[x-1][y+1])
|
|
|
|
{
|
|
|
|
return CSDL_Ext::rotate01(partialHide->ourImages[16].bitmap); //visible left corners
|
|
|
|
}
|
|
|
|
if(!visibility[x][y+1] && !visibility[x+1][y] && !visibility[x-1][y] && !visibility[x][y-1] && !visibility[x-1][y-1] && visibility[x+1][y+1] && !visibility[x+1][y-1] && visibility[x-1][y+1])
|
|
|
|
{
|
|
|
|
return CSDL_Ext::hFlip(partialHide->ourImages[18].bitmap); //visible bottom corners
|
|
|
|
}
|
|
|
|
if(!visibility[x][y+1] && !visibility[x+1][y] && !visibility[x-1][y] && !visibility[x][y-1] && !visibility[x-1][y-1] && !visibility[x+1][y+1] && visibility[x+1][y-1] && visibility[x-1][y+1])
|
|
|
|
{
|
|
|
|
return partialHide->ourImages[17].bitmap; //visible right - top and bottom - left corners
|
|
|
|
}
|
|
|
|
if(!visibility[x][y+1] && !visibility[x+1][y] && !visibility[x-1][y] && !visibility[x][y-1] && visibility[x-1][y-1] && visibility[x+1][y+1] && !visibility[x+1][y-1] && !visibility[x-1][y+1])
|
|
|
|
{
|
|
|
|
return CSDL_Ext::hFlip(partialHide->ourImages[17].bitmap); //visible top - left and bottom - right corners
|
|
|
|
}
|
|
|
|
if(!visibility[x][y+1] && !visibility[x+1][y] && !visibility[x-1][y] && !visibility[x][y-1] && !visibility[x-1][y-1] && visibility[x+1][y+1] && visibility[x+1][y-1] && visibility[x-1][y+1])
|
|
|
|
{
|
|
|
|
return partialHide->ourImages[19].bitmap; //visible corners without left top
|
|
|
|
}
|
|
|
|
if(!visibility[x][y+1] && !visibility[x+1][y] && !visibility[x-1][y] && !visibility[x][y-1] && visibility[x-1][y-1] && visibility[x+1][y+1] && visibility[x+1][y-1] && !visibility[x-1][y+1])
|
|
|
|
{
|
|
|
|
return partialHide->ourImages[20].bitmap; //visible corners without left bottom
|
|
|
|
}
|
|
|
|
if(!visibility[x][y+1] && !visibility[x+1][y] && !visibility[x-1][y] && !visibility[x][y-1] && visibility[x-1][y-1] && !visibility[x+1][y+1] && visibility[x+1][y-1] && visibility[x-1][y+1])
|
|
|
|
{
|
|
|
|
return CSDL_Ext::rotate01(partialHide->ourImages[20].bitmap); //visible corners without right bottom
|
|
|
|
}
|
|
|
|
if(!visibility[x][y+1] && !visibility[x+1][y] && !visibility[x-1][y] && !visibility[x][y-1] && visibility[x-1][y-1] && visibility[x+1][y+1] && !visibility[x+1][y-1] && visibility[x-1][y+1])
|
|
|
|
{
|
|
|
|
return CSDL_Ext::rotate01(partialHide->ourImages[19].bitmap); //visible corners without right top
|
|
|
|
}
|
|
|
|
if(!visibility[x][y+1] && !visibility[x+1][y] && !visibility[x-1][y] && !visibility[x][y-1] && visibility[x-1][y-1] && visibility[x+1][y+1] && visibility[x+1][y-1] && visibility[x-1][y+1])
|
|
|
|
{
|
|
|
|
return partialHide->ourImages[21].bitmap; //visible all corners only
|
|
|
|
}
|
|
|
|
if(visibility[x][y+1] && visibility[x+1][y] && visibility[x-1][y] && !visibility[x][y-1])
|
|
|
|
{
|
|
|
|
return partialHide->ourImages[6].bitmap; //hidden top
|
|
|
|
}
|
|
|
|
if(visibility[x][y+1] && !visibility[x+1][y] && visibility[x-1][y] && visibility[x][y-1])
|
|
|
|
{
|
|
|
|
return partialHide->ourImages[7].bitmap; //hidden right
|
|
|
|
}
|
|
|
|
if(!visibility[x][y+1] && visibility[x+1][y] && visibility[x-1][y] && visibility[x][y-1])
|
|
|
|
{
|
|
|
|
return partialHide->ourImages[8].bitmap; //hidden bottom
|
|
|
|
}
|
|
|
|
if(visibility[x][y+1] && visibility[x+1][y] && !visibility[x-1][y] && visibility[x][y-1])
|
|
|
|
{
|
|
|
|
return CSDL_Ext::rotate01(partialHide->ourImages[6].bitmap); //hidden left
|
|
|
|
}
|
|
|
|
if(!visibility[x][y+1] && visibility[x+1][y] && visibility[x-1][y] && visibility[x][y-1])
|
|
|
|
{
|
|
|
|
return partialHide->ourImages[9].bitmap; //hidden top and bottom
|
|
|
|
}
|
|
|
|
if(visibility[x][y+1] && visibility[x+1][y] && !visibility[x-1][y] && visibility[x][y-1])
|
|
|
|
{
|
|
|
|
return partialHide->ourImages[29].bitmap; //hidden left and right
|
|
|
|
}
|
|
|
|
if(!visibility[x][y+1] && !visibility[x+1][y] && !visibility[x-1][y] && visibility[x][y-1] && visibility[x+1][y+1] && !visibility[x-1][y+1])
|
|
|
|
{
|
|
|
|
return partialHide->ourImages[24].bitmap; //visible top and right bottom corner
|
|
|
|
}
|
|
|
|
if(!visibility[x][y+1] && !visibility[x+1][y] && !visibility[x-1][y] && visibility[x][y-1] && !visibility[x+1][y+1] && visibility[x-1][y+1])
|
|
|
|
{
|
|
|
|
return CSDL_Ext::rotate01(partialHide->ourImages[24].bitmap); //visible top and left bottom corner
|
|
|
|
}
|
|
|
|
if(!visibility[x][y+1] && !visibility[x+1][y] && !visibility[x-1][y] && visibility[x][y-1] && visibility[x+1][y+1] && visibility[x-1][y+1])
|
|
|
|
{
|
|
|
|
return partialHide->ourImages[33].bitmap; //visible top and bottom corners
|
|
|
|
}
|
|
|
|
if(!visibility[x][y+1] && !visibility[x+1][y] && visibility[x-1][y] && !visibility[x][y-1] && !visibility[x+1][y+1] && visibility[x+1][y-1])
|
|
|
|
{
|
|
|
|
return CSDL_Ext::rotate01(partialHide->ourImages[26].bitmap); //visible left and right top corner
|
|
|
|
}
|
|
|
|
if(!visibility[x][y+1] && !visibility[x+1][y] && visibility[x-1][y] && !visibility[x][y-1] && visibility[x+1][y+1] && !visibility[x+1][y-1])
|
|
|
|
{
|
|
|
|
return CSDL_Ext::rotate01(partialHide->ourImages[25].bitmap); //visible left and right bottom corner
|
|
|
|
}
|
|
|
|
if(!visibility[x][y+1] && !visibility[x+1][y] && visibility[x-1][y] && !visibility[x][y-1] && visibility[x+1][y+1] && visibility[x+1][y-1])
|
|
|
|
{
|
|
|
|
return partialHide->ourImages[32].bitmap; //visible left and right corners
|
|
|
|
}
|
|
|
|
if(visibility[x][y+1] && !visibility[x+1][y] && !visibility[x-1][y] && !visibility[x][y-1] && visibility[x-1][y-1] && !visibility[x+1][y-1])
|
|
|
|
{
|
|
|
|
return CSDL_Ext::rotate01(partialHide->ourImages[30].bitmap); //visible bottom and left top corner
|
|
|
|
}
|
|
|
|
if(visibility[x][y+1] && !visibility[x+1][y] && !visibility[x-1][y] && !visibility[x][y-1] && !visibility[x-1][y-1] && visibility[x+1][y-1])
|
|
|
|
{
|
|
|
|
return partialHide->ourImages[30].bitmap; //visible bottom and right top corner
|
|
|
|
}
|
|
|
|
if(visibility[x][y+1] && !visibility[x+1][y] && !visibility[x-1][y] && !visibility[x][y-1] && visibility[x-1][y-1] && visibility[x+1][y-1])
|
|
|
|
{
|
|
|
|
return partialHide->ourImages[31].bitmap; //visible bottom and top corners
|
|
|
|
}
|
|
|
|
if(!visibility[x][y+1] && visibility[x+1][y] && !visibility[x-1][y] && !visibility[x][y-1] && !visibility[x-1][y-1] && visibility[x-1][y+1])
|
|
|
|
{
|
|
|
|
return partialHide->ourImages[25].bitmap; //visible right and left bottom corner
|
|
|
|
}
|
|
|
|
if(!visibility[x][y+1] && visibility[x+1][y] && !visibility[x-1][y] && !visibility[x][y-1] && visibility[x-1][y-1] && !visibility[x-1][y+1])
|
|
|
|
{
|
|
|
|
return partialHide->ourImages[26].bitmap; //visible right and left top corner
|
|
|
|
}
|
|
|
|
if(!visibility[x][y+1] && visibility[x+1][y] && !visibility[x-1][y] && !visibility[x][y-1] && visibility[x-1][y-1] && visibility[x-1][y+1])
|
|
|
|
{
|
|
|
|
return CSDL_Ext::rotate01(partialHide->ourImages[32].bitmap); //visible right and left cornres
|
|
|
|
}
|
|
|
|
if(visibility[x][y+1] && visibility[x+1][y] && !visibility[x-1][y] && !visibility[x][y-1] && visibility[x-1][y-1])
|
|
|
|
{
|
|
|
|
return partialHide->ourImages[28].bitmap; //visible bottom, right - bottom, right; left top corner visible
|
|
|
|
}
|
|
|
|
else if(!visibility[x][y+1] && visibility[x+1][y] && !visibility[x-1][y] && visibility[x][y-1] && visibility[x-1][y+1])
|
|
|
|
{
|
|
|
|
return partialHide->ourImages[27].bitmap; //visible right, right - top; left bottom corner visible
|
|
|
|
}
|
|
|
|
else if(!visibility[x][y+1] && !visibility[x+1][y] && visibility[x-1][y] && visibility[x][y-1] && visibility[x+1][y+1])
|
|
|
|
{
|
|
|
|
return CSDL_Ext::rotate01(partialHide->ourImages[27].bitmap); //visible top, top - left, left; right bottom corner visible
|
|
|
|
}
|
|
|
|
else if(visibility[x][y+1] && !visibility[x+1][y] && visibility[x-1][y] && !visibility[x][y-1] && visibility[x+1][y-1])
|
|
|
|
{
|
|
|
|
return CSDL_Ext::rotate01(partialHide->ourImages[28].bitmap); //visible left, left - bottom, bottom; right top corner visible
|
|
|
|
}
|
|
|
|
return fullHide->ourImages[0].bitmap; //this case should never happen, but it is better to hide too much than reveal it....
|
|
|
|
}
|
2007-06-26 15:38:58 +03:00
|
|
|
|
|
|
|
char & CMapHandler::visAccess(int x, int y)
|
|
|
|
{
|
|
|
|
return visibility[x+4][y+4];
|
|
|
|
}
|
|
|
|
|
|
|
|
char & CMapHandler::undVisAccess(int x, int y)
|
|
|
|
{
|
|
|
|
return undVisibility[x+4][y+4];
|
|
|
|
}
|