mirror of
https://github.com/vcmi/vcmi.git
synced 2025-09-16 09:26:28 +02:00
general code improvements
This commit is contained in:
30
CMT.cpp
30
CMT.cpp
@@ -63,6 +63,7 @@
|
||||
const char * NAME = "VCMI 0.52 \"Tirion\" Techdemo";
|
||||
|
||||
SDL_Surface * ekran, * screen, * screen2;
|
||||
extern SDL_Surface * CSDL_Ext::std32bppSurface;
|
||||
TTF_Font * TNRB16, *TNR, *GEOR13, *GEORXX, *GEORM, *GEOR16;
|
||||
void handleCPPObjS(std::map<int,CCPPObjectScript*> * mapa, CCPPObjectScript * script)
|
||||
{
|
||||
@@ -311,6 +312,21 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||
if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_AUDIO/*|SDL_INIT_EVENTTHREAD*/)==0)
|
||||
{
|
||||
screen = SDL_SetVideoMode(800,600,24,SDL_SWSURFACE|SDL_DOUBLEBUF/*|SDL_FULLSCREEN*/);
|
||||
|
||||
//initializing important global surface
|
||||
#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
|
||||
CSDL_Ext::std32bppSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, 1, 1, 32, rmask, gmask, bmask, amask);
|
||||
|
||||
CPG=NULL;
|
||||
TTF_Init();
|
||||
atexit(TTF_Quit);
|
||||
@@ -794,21 +810,9 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||
int mw = mm.map[0]->w, mh = mm.map[0]->h,
|
||||
wo = mw/CGI->mh->sizes.x, ho = mh/CGI->mh->sizes.y;
|
||||
|
||||
|
||||
for(int d=0; d<cgi->mh->reader->map.twoLevel+1; ++d)
|
||||
{
|
||||
#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
|
||||
SDL_Surface * pt = SDL_CreateRGBSurface(SDL_SWSURFACE, mm.pos.w, mm.pos.h, 32, rmask, gmask, bmask, amask);
|
||||
SDL_Surface * pt = CSDL_Ext::newSurface(mm.pos.w, mm.pos.h, CSDL_Ext::std32bppSurface);
|
||||
|
||||
for (int i=0; i<mw; i++)
|
||||
{
|
||||
|
@@ -216,8 +216,7 @@ void CSDL_Ext::SDL_PutPixelWithoutRefresh(SDL_Surface *ekran, int x, int y, Uint
|
||||
///**************/
|
||||
SDL_Surface * CSDL_Ext::rotate01(SDL_Surface * toRot, int myC)
|
||||
{
|
||||
SDL_Surface * first = SDL_CreateRGBSurface(toRot->flags, toRot->w, toRot->h, toRot->format->BitsPerPixel, toRot->format->Rmask, toRot->format->Gmask, toRot->format->Bmask, toRot->format->Amask);
|
||||
SDL_Surface * ret = SDL_ConvertSurface(first, toRot->format, toRot->flags);
|
||||
SDL_Surface * ret = SDL_ConvertSurface(toRot, toRot->format, toRot->flags);
|
||||
//SDL_SetColorKey(ret, SDL_SRCCOLORKEY, toRot->format->colorkey);
|
||||
if(toRot->format->BytesPerPixel!=1)
|
||||
{
|
||||
@@ -249,13 +248,11 @@ SDL_Surface * CSDL_Ext::rotate01(SDL_Surface * toRot, int myC)
|
||||
}
|
||||
}
|
||||
}
|
||||
SDL_FreeSurface(first);
|
||||
return ret;
|
||||
}
|
||||
SDL_Surface * CSDL_Ext::hFlip(SDL_Surface * toRot)
|
||||
{
|
||||
SDL_Surface * first = SDL_CreateRGBSurface(toRot->flags, toRot->w, toRot->h, toRot->format->BitsPerPixel, toRot->format->Rmask, toRot->format->Gmask, toRot->format->Bmask, toRot->format->Amask);
|
||||
SDL_Surface * ret = SDL_ConvertSurface(first, toRot->format, toRot->flags);
|
||||
SDL_Surface * ret = SDL_ConvertSurface(toRot, toRot->format, toRot->flags);
|
||||
//SDL_SetColorKey(ret, SDL_SRCCOLORKEY, toRot->format->colorkey);
|
||||
if(ret->format->BytesPerPixel!=1)
|
||||
{
|
||||
@@ -288,7 +285,6 @@ SDL_Surface * CSDL_Ext::hFlip(SDL_Surface * toRot)
|
||||
}
|
||||
}
|
||||
}
|
||||
SDL_FreeSurface(first);
|
||||
return ret;
|
||||
};
|
||||
|
||||
@@ -297,8 +293,7 @@ SDL_Surface * CSDL_Ext::hFlip(SDL_Surface * toRot)
|
||||
///**************/
|
||||
SDL_Surface * CSDL_Ext::rotate02(SDL_Surface * toRot)
|
||||
{
|
||||
SDL_Surface * first = SDL_CreateRGBSurface(toRot->flags, toRot->h, toRot->w, toRot->format->BitsPerPixel, toRot->format->Rmask, toRot->format->Gmask, toRot->format->Bmask, toRot->format->Amask);
|
||||
SDL_Surface * ret = SDL_ConvertSurface(first, toRot->format, toRot->flags);
|
||||
SDL_Surface * ret = SDL_ConvertSurface(toRot, toRot->format, toRot->flags);
|
||||
//SDL_SetColorKey(ret, SDL_SRCCOLORKEY, toRot->format->colorkey);
|
||||
for(int i=0; i<ret->w; ++i)
|
||||
{
|
||||
@@ -314,7 +309,6 @@ SDL_Surface * CSDL_Ext::rotate02(SDL_Surface * toRot)
|
||||
}
|
||||
}
|
||||
}
|
||||
SDL_FreeSurface(first);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -323,8 +317,7 @@ SDL_Surface * CSDL_Ext::rotate02(SDL_Surface * toRot)
|
||||
///*************/
|
||||
SDL_Surface * CSDL_Ext::rotate03(SDL_Surface * toRot)
|
||||
{
|
||||
SDL_Surface * first = SDL_CreateRGBSurface(toRot->flags, toRot->w, toRot->h, toRot->format->BitsPerPixel, toRot->format->Rmask, toRot->format->Gmask, toRot->format->Bmask, toRot->format->Amask);
|
||||
SDL_Surface * ret = SDL_ConvertSurface(first, toRot->format, toRot->flags);
|
||||
SDL_Surface * ret = SDL_ConvertSurface(toRot, toRot->format, toRot->flags);
|
||||
//SDL_SetColorKey(ret, SDL_SRCCOLORKEY, toRot->format->colorkey);
|
||||
if(ret->format->BytesPerPixel!=1)
|
||||
{
|
||||
@@ -354,7 +347,6 @@ SDL_Surface * CSDL_Ext::rotate03(SDL_Surface * toRot)
|
||||
}
|
||||
}
|
||||
}
|
||||
SDL_FreeSurface(first);
|
||||
return ret;
|
||||
}
|
||||
//converts surface to cursor
|
||||
@@ -396,7 +388,7 @@ SDL_Cursor * CSDL_Ext::SurfaceToCursor(SDL_Surface *image, int hx, int hy)
|
||||
return cursor;
|
||||
}
|
||||
|
||||
Uint32 CSDL_Ext::SDL_GetPixel(SDL_Surface *surface, int x, int y, bool colorByte)
|
||||
Uint32 CSDL_Ext::SDL_GetPixel(SDL_Surface *surface, const int & x, const int & y, bool colorByte)
|
||||
{
|
||||
int bpp = surface->format->BytesPerPixel;
|
||||
/* Here p is the address to the pixel we want to retrieve */
|
||||
@@ -484,22 +476,13 @@ SDL_Surface * CSDL_Ext::alphaTransform(SDL_Surface *src)
|
||||
|
||||
SDL_Surface * CSDL_Ext::secondAlphaTransform(SDL_Surface * src, SDL_Surface * alpha)
|
||||
{
|
||||
|
||||
Uint32 pompom[256][256];
|
||||
for(int i=0; i<src->w; ++i)
|
||||
{
|
||||
for(int j=0; j<src->h; ++j)
|
||||
{
|
||||
pompom[i][j] = 0xffffffff - (SDL_GetPixel(src, i, j, true) & 0xff000000);
|
||||
}
|
||||
}
|
||||
SDL_Surface * hide2 = SDL_ConvertSurface(src, alpha->format, SDL_SWSURFACE);
|
||||
for(int i=0; i<hide2->w; ++i)
|
||||
{
|
||||
for(int j=0; j<hide2->h; ++j)
|
||||
{
|
||||
Uint32 * place = (Uint32*)( (Uint8*)hide2->pixels + j * hide2->pitch + i * hide2->format->BytesPerPixel);
|
||||
(*place)&=pompom[i][j];
|
||||
(*place) &= 0xffffffff - (SDL_GetPixel(src, i, j, true) & 0xff000000);
|
||||
}
|
||||
}
|
||||
return hide2;
|
||||
@@ -742,23 +725,10 @@ int readNormalNr (std::istream &in, int bytCon)
|
||||
|
||||
void CSDL_Ext::fullAlphaTransform(SDL_Surface *& src)
|
||||
{
|
||||
#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
|
||||
src = alphaTransform(src);
|
||||
SDL_Surface * hlp1, * hlp2;
|
||||
hlp1 = SDL_CreateRGBSurface(SDL_SWSURFACE, src->w, src->h, 32, rmask, gmask, bmask, amask);
|
||||
hlp2 = secondAlphaTransform(src, hlp1);
|
||||
SDL_Surface * hlp2;
|
||||
hlp2 = secondAlphaTransform(src, std32bppSurface);
|
||||
SDL_FreeSurface(src);
|
||||
SDL_FreeSurface(hlp1);
|
||||
src = hlp2;
|
||||
}
|
||||
|
||||
@@ -770,3 +740,5 @@ std::string CSDL_Ext::processStr(std::string str, std::vector<std::string> & tor
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
SDL_Surface * CSDL_Ext::std32bppSurface = NULL;
|
||||
|
@@ -23,6 +23,7 @@ template <typename T> int getIndexOf(const std::vector<T> & v, const T & val)
|
||||
SDL_Rect genRect(int hh, int ww, int xx, int yy);
|
||||
namespace CSDL_Ext
|
||||
{
|
||||
extern SDL_Surface * std32bppSurface;
|
||||
void SDL_PutPixel(SDL_Surface *ekran, int x, int y, Uint8 R, Uint8 G, Uint8 B, int myC=0, Uint8 A = 255); //myC influences the start of reading pixels
|
||||
void SDL_PutPixelWithoutRefresh(SDL_Surface *ekran, int x, int y, Uint8 R, Uint8 G, Uint8 B, int myC=0, Uint8 A = 255); //myC influences the start of reading pixels ; without refreshing
|
||||
SDL_Surface * rotate01(SDL_Surface * toRot, int myC = 2); //vertical flip
|
||||
@@ -30,7 +31,7 @@ namespace CSDL_Ext
|
||||
SDL_Surface * rotate02(SDL_Surface * toRot); //rotate 90 degrees left
|
||||
SDL_Surface * rotate03(SDL_Surface * toRot); //rotate 180 degrees
|
||||
SDL_Cursor * SurfaceToCursor(SDL_Surface *image, int hx, int hy);
|
||||
Uint32 SDL_GetPixel(SDL_Surface *surface, int x, int y, bool colorByte = false);
|
||||
Uint32 SDL_GetPixel(SDL_Surface *surface, const int & x, const int & y, bool colorByte = false);
|
||||
SDL_Color SDL_GetPixelColor(SDL_Surface *surface, int x, int y);
|
||||
SDL_Surface * alphaTransform(SDL_Surface * src); //adds transparency and shadows (partial handling only; see examples of using for details)
|
||||
SDL_Surface * secondAlphaTransform(SDL_Surface * src, SDL_Surface * alpha); //alpha is a surface we want to blit src to
|
||||
|
@@ -561,18 +561,6 @@ void CAmbarCendamo::deh3m()
|
||||
defAmount = readNormalNr(i);
|
||||
i+=4;
|
||||
|
||||
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
||||
int srmask = 0xff000000;
|
||||
int sgmask = 0x00ff0000;
|
||||
int sbmask = 0x0000ff00;
|
||||
int samask = 0x000000ff;
|
||||
#else
|
||||
int srmask = 0x000000ff;
|
||||
int sgmask = 0x0000ff00;
|
||||
int sbmask = 0x00ff0000;
|
||||
int samask = 0xff000000;
|
||||
#endif
|
||||
SDL_Surface * alphaTransSurf = SDL_CreateRGBSurface(SDL_SWSURFACE, 12, 12, 32, srmask, sgmask, sbmask, samask);
|
||||
std::vector<std::string> defsToUnpack;
|
||||
for (int idd = 0 ; idd<defAmount; idd++) // reading defs
|
||||
{
|
||||
@@ -2146,15 +2134,13 @@ borderguardend:
|
||||
for(int yy=0; yy<map.defy[vv]->handler->ourImages.size(); ++yy)
|
||||
{
|
||||
map.defy[vv]->handler->ourImages[yy].bitmap = CSDL_Ext::alphaTransform(map.defy[vv]->handler->ourImages[yy].bitmap);
|
||||
SDL_Surface * bufs = CSDL_Ext::secondAlphaTransform(map.defy[vv]->handler->ourImages[yy].bitmap, alphaTransSurf);
|
||||
SDL_Surface * bufs = CSDL_Ext::secondAlphaTransform(map.defy[vv]->handler->ourImages[yy].bitmap, CSDL_Ext::std32bppSurface);
|
||||
SDL_FreeSurface(map.defy[vv]->handler->ourImages[yy].bitmap);
|
||||
map.defy[vv]->handler->ourImages[yy].bitmap = bufs;
|
||||
map.defy[vv]->handler->alphaTransformed = true;
|
||||
}
|
||||
}
|
||||
|
||||
SDL_FreeSurface(alphaTransSurf);
|
||||
|
||||
THC std::cout<<"\tHandling defs: "<<th.getDif()<<std::endl;
|
||||
|
||||
//loading events
|
||||
|
@@ -698,36 +698,11 @@ int CCreatureAnimation::nextFrame(SDL_Surface *dest, int x, int y)
|
||||
/*if (add==4)
|
||||
add=0;*/ //moved to defcompression dependent block
|
||||
|
||||
#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
|
||||
|
||||
//ret = SDL_CreateRGBSurface(SDL_SWSURFACE, FullWidth, FullHeight, 8, 0, 0, 0, 0);
|
||||
//int tempee2 = readNormalNr(0,4,((unsigned char *)tempee.c_str()));
|
||||
|
||||
int BaseOffsetor = BaseOffset = i;
|
||||
|
||||
/*for(int i=0; i<256; ++i)
|
||||
{
|
||||
SDL_Color pr;
|
||||
pr.r = palette[i].R;
|
||||
pr.g = palette[i].G;
|
||||
pr.b = palette[i].B;
|
||||
pr.unused = palette[i].F;
|
||||
(*(ret->format->palette->colors+i))=pr;
|
||||
}*/
|
||||
|
||||
for (int i=0;i<800;i++)
|
||||
fbuffer[i]=0;
|
||||
|
||||
if (defType2==1) //as it should be allways in creature animations
|
||||
{
|
||||
if (add==4)
|
||||
|
@@ -64,7 +64,6 @@ class CCreatureAnimation
|
||||
{
|
||||
private:
|
||||
int totalEntries, DEFType, totalBlocks, fullWidth, fullHeight;
|
||||
unsigned char fbuffer[800];
|
||||
bool allowRepaint;
|
||||
int length;
|
||||
BMPPalette palette[256];
|
||||
|
Binary file not shown.
@@ -319,21 +319,6 @@ void CMapHandler::roadsRiverTerrainInit()
|
||||
{
|
||||
//initializing road's and river's DefHandlers
|
||||
|
||||
#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
|
||||
|
||||
SDL_Surface * su = SDL_CreateRGBSurface(SDL_SWSURFACE, 32, 32, 32,
|
||||
rmask, gmask, bmask, amask);
|
||||
|
||||
roadDefs.push_back(CGameInfo::mainObj->spriteh->giveDef("dirtrd.def"));
|
||||
roadDefs.push_back(CGameInfo::mainObj->spriteh->giveDef("gravrd.def"));
|
||||
roadDefs.push_back(CGameInfo::mainObj->spriteh->giveDef("cobbrd.def"));
|
||||
@@ -409,7 +394,7 @@ void CMapHandler::roadsRiverTerrainInit()
|
||||
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_Surface * buf = CSDL_Ext::secondAlphaTransform(ttiles[i][j][k].roadbitmap[0], CSDL_Ext::std32bppSurface);
|
||||
SDL_FreeSurface(ttiles[i][j][k].roadbitmap[0]);
|
||||
ttiles[i][j][k].roadbitmap[0] = buf;
|
||||
}
|
||||
@@ -488,7 +473,7 @@ void CMapHandler::roadsRiverTerrainInit()
|
||||
if(rotH || rotV)
|
||||
{
|
||||
ttiles[i][j][k].rivbitmap[0] = CSDL_Ext::alphaTransform(ttiles[i][j][k].rivbitmap[0]);
|
||||
SDL_Surface * buf = CSDL_Ext::secondAlphaTransform(ttiles[i][j][k].rivbitmap[0], su);
|
||||
SDL_Surface * buf = CSDL_Ext::secondAlphaTransform(ttiles[i][j][k].rivbitmap[0], CSDL_Ext::std32bppSurface);
|
||||
SDL_FreeSurface(ttiles[i][j][k].rivbitmap[0]);
|
||||
ttiles[i][j][k].rivbitmap[0] = buf;
|
||||
}
|
||||
@@ -496,8 +481,6 @@ void CMapHandler::roadsRiverTerrainInit()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SDL_FreeSurface(su);
|
||||
}
|
||||
void CMapHandler::borderAndTerrainBitmapInit()
|
||||
{
|
||||
@@ -628,15 +611,15 @@ void CMapHandler::initObjectRects()
|
||||
continue;
|
||||
}
|
||||
CDefHandler * curd = CGI->objh->objInstances[f]->defInfo->handler;
|
||||
for(int fx=0; fx<curd->ourImages[0].bitmap->w/32; ++fx)
|
||||
for(int fx=0; fx<curd->ourImages[0].bitmap->w>>5; ++fx) //curd->ourImages[0].bitmap->w/32
|
||||
{
|
||||
for(int fy=0; fy<curd->ourImages[0].bitmap->h/32; ++fy)
|
||||
for(int fy=0; fy<curd->ourImages[0].bitmap->h>>5; ++fy) //curd->ourImages[0].bitmap->h/32
|
||||
{
|
||||
SDL_Rect cr;
|
||||
cr.w = 32;
|
||||
cr.h = 32;
|
||||
cr.x = fx*32;
|
||||
cr.y = fy*32;
|
||||
cr.x = fx<<5; //fx*32
|
||||
cr.y = fy<<5; //fy*32
|
||||
std::pair<CGObjectInstance*,std::pair<SDL_Rect, std::vector<std::list<int3>>>> toAdd = std::make_pair(CGI->objh->objInstances[f], std::make_pair(cr, std::vector<std::list<int3>>()));
|
||||
///initializing places that will be coloured by blitting (flag colour / player colour positions)
|
||||
if(toAdd.first->defInfo->isVisitable())
|
||||
@@ -666,13 +649,11 @@ void CMapHandler::initObjectRects()
|
||||
}
|
||||
if((CGI->objh->objInstances[f]->pos.x + fx - curd->ourImages[0].bitmap->w/32+1)>=0 && (CGI->objh->objInstances[f]->pos.x + fx - curd->ourImages[0].bitmap->w/32+1)<ttiles.size()-Woff && (CGI->objh->objInstances[f]->pos.y + fy - curd->ourImages[0].bitmap->h/32+1)>=0 && (CGI->objh->objInstances[f]->pos.y + fy - curd->ourImages[0].bitmap->h/32+1)<ttiles[0].size()-Hoff)
|
||||
{
|
||||
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];
|
||||
|
||||
|
||||
//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+1][CGI->objh->objInstances[f]->pos.y + fy - curd->ourImages[0].bitmap->h/32+1][CGI->objh->objInstances[f]->pos.z].objects.push_back(toAdd);
|
||||
}
|
||||
|
||||
@@ -763,19 +744,8 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
|
||||
{
|
||||
if(!otherHeroAnim)
|
||||
heroAnim = anim; //the same, as it should be
|
||||
#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
|
||||
SDL_Surface * su = SDL_CreateRGBSurface(SDL_SWSURFACE, dx*32, dy*32, 32,
|
||||
rmask, gmask, bmask, amask);
|
||||
|
||||
SDL_Surface * su = CSDL_Ext::newSurface(dx*32, dy*32, CSDL_Ext::std32bppSurface);
|
||||
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
|
||||
@@ -1274,8 +1244,7 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
|
||||
sr.x=bx*32;
|
||||
sr.h=sr.w=32;
|
||||
|
||||
SDL_Surface * ns = SDL_CreateRGBSurface(SDL_SWSURFACE, 32, 32, 32,
|
||||
rmask, gmask, bmask, amask);
|
||||
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;
|
||||
@@ -1292,8 +1261,7 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
|
||||
sr.x=bx*32;
|
||||
sr.h=sr.w=32;
|
||||
|
||||
SDL_Surface * ns = SDL_CreateRGBSurface(SDL_SWSURFACE, 32, 32, 32,
|
||||
rmask, gmask, bmask, amask);
|
||||
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;
|
||||
|
Reference in New Issue
Block a user