From 7b848065882f6b3ce42535842f76a66d89893e9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20W=2E=20Urba=C5=84czyk?= Date: Sat, 9 Jun 2007 02:32:43 +0000 Subject: [PATCH] =?UTF-8?q?*=20poprawna=20obs=C5=82uga=20podziemi,=20prze?= =?UTF-8?q?=C5=82=C4=85czanie=20widoku=20przez=20"u"=20*=20naprawione=20na?= =?UTF-8?q?g=C5=82=C3=B3wki=20*=20okno=20ma=20tytu=C5=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CAbilityHandler.cpp | 2 +- CAmbarCendamo.cpp | 26 +++++++++++-------- CArtHandler.cpp | 2 +- CCreatureHandler.cpp | 2 +- CHeroHandler.cpp | 2 +- CMT.cpp | 13 ++++++++-- mapHandler.cpp | 60 +++++++++++++++++++++++++++++++++++++++++--- mapHandler.h | 2 +- stdafx.h | 2 +- 9 files changed, 90 insertions(+), 21 deletions(-) diff --git a/CAbilityHandler.cpp b/CAbilityHandler.cpp index 7b9dacc28..629559c59 100644 --- a/CAbilityHandler.cpp +++ b/CAbilityHandler.cpp @@ -1,5 +1,5 @@ +#include "stdafx.h" #include "CAbilityHandler.h" -#include void CAbilityHandler::loadAbilities() { diff --git a/CAmbarCendamo.cpp b/CAmbarCendamo.cpp index 9bc172bf9..b8d35a59b 100644 --- a/CAmbarCendamo.cpp +++ b/CAmbarCendamo.cpp @@ -1,7 +1,6 @@ #include "stdafx.h" #include "CAmbarCendamo.h" #include "CSemiDefHandler.h" -#include #include CAmbarCendamo::CAmbarCendamo (const char * tie) { @@ -290,9 +289,9 @@ void CAmbarCendamo::deh3m() } if (map.twoLevel) // read underground terrain { - for (int z=0; zopenDef(("H3sprite.lod\\"+sdh->nameFromType(map.terrain[i][j].tertype)).c_str()); - loadedTypes.insert(map.terrain[i][j].tertype); - defs.push_back(sdh); - } + if (loadedTypes.find(map.terrain[i][j].tertype)==loadedTypes.end()) + { + CSemiDefHandler *sdh = new CSemiDefHandler(); + sdh->openDef(("H3sprite.lod\\"+sdh->nameFromType(map.terrain[i][j].tertype)).c_str()); + loadedTypes.insert(map.terrain[i][j].tertype); + defs.push_back(sdh); + } + if (loadedTypes.find(map.undergroungTerrain[i][j].tertype)==loadedTypes.end()) + { + CSemiDefHandler *sdh = new CSemiDefHandler(); + sdh->openDef(("H3sprite.lod\\"+sdh->nameFromType(map.undergroungTerrain[i][j].tertype)).c_str()); + loadedTypes.insert(map.undergroungTerrain[i][j].tertype); + defs.push_back(sdh); + } } } }; \ No newline at end of file diff --git a/CArtHandler.cpp b/CArtHandler.cpp index 1b62ab4b5..cd3e270c2 100644 --- a/CArtHandler.cpp +++ b/CArtHandler.cpp @@ -1,5 +1,5 @@ +#include "stdafx.h" #include "CArtHandler.h" -#include void CArtHandler::loadArtifacts() { diff --git a/CCreatureHandler.cpp b/CCreatureHandler.cpp index 12f8dac48..a6675983e 100644 --- a/CCreatureHandler.cpp +++ b/CCreatureHandler.cpp @@ -1,5 +1,5 @@ +#include "stdafx.h" #include "CCreatureHandler.h" -#include void CCreatureHandler::loadCreatures() { diff --git a/CHeroHandler.cpp b/CHeroHandler.cpp index 86b2e2c19..2aa054ded 100644 --- a/CHeroHandler.cpp +++ b/CHeroHandler.cpp @@ -1,4 +1,4 @@ -#include +#include "stdafx.h" #include "CHeroHandler.h" void CHeroHandler::loadHeroes() diff --git a/CMT.cpp b/CMT.cpp index d4598c8e0..4f59f972f 100644 --- a/CMT.cpp +++ b/CMT.cpp @@ -24,6 +24,7 @@ #endif #define CHUNK 16384 #define pi 3.14159 +const char * NAME = "VCMI 0.1"; #include "CAmbarCendamo.h" @@ -196,7 +197,7 @@ void SDL_PutPixel(SDL_Surface *ekran, int x, int y, Uint8 R, Uint8 G, Uint8 B) } int _tmain(int argc, _TCHAR* argv[]) { - int xx=0, yy=0; + int xx=0, yy=0, zz=0; SDL_Event sEvent; srand ( time(NULL) ); SDL_Surface *screen, *temp; @@ -223,6 +224,7 @@ int _tmain(int argc, _TCHAR* argv[]) // def(zr,ko,i); // fclose(ko);fclose(zr); //} + SDL_WM_SetCaption(NAME,""); THC timeHandler tmh; CArtHandler * arth = new CArtHandler; arth->loadArtifacts(); @@ -295,9 +297,16 @@ int _tmain(int argc, _TCHAR* argv[]) return 0; break; } + case (SDLK_u): + { + if (zz) + zz--; + else zz++; + break; + } } SDL_FillRect(ekran, NULL, SDL_MapRGB(ekran->format, 0, 0, 0)); - SDL_Surface * help = mh->terrainRect(xx,yy,32,24); + SDL_Surface * help = mh->terrainRect(xx,yy,32,24,zz); SDL_BlitSurface(help,NULL,ekran,NULL); SDL_FreeSurface(help); SDL_Flip(ekran); diff --git a/mapHandler.cpp b/mapHandler.cpp index 4552c11ea..fe9a12a36 100644 --- a/mapHandler.cpp +++ b/mapHandler.cpp @@ -55,8 +55,60 @@ void mapHandler::init() } } } + if (reader->map.twoLevel) + { + undTerrainBitmap = new SDL_Surface **[reader->map.width]; + for (int ii=0;iimap.width;ii++) + undTerrainBitmap[ii] = new SDL_Surface*[reader->map.height]; // allocate memory + for (int i=0; imap.width; i++) + { + for (int j=0; jmap.height;j++) + { + TerrainTile zz = reader->map.undergroungTerrain[i][j]; + std::string name = CSemiDefHandler::nameFromType(reader->map.undergroungTerrain[i][j].tertype); + for (int k=0; kdefs.size(); k++) + { + try + { + if (reader->defs[k]->defName != name) + continue; + else + { + SDL_Surface * n; + int ktora = reader->map.undergroungTerrain[i][j].terview; + undTerrainBitmap[i][j] = reader->defs[k]->ourImages[ktora].bitmap; + //TODO: odwracanie + switch ((reader->map.undergroungTerrain[i][j].siodmyTajemniczyBajt)%4) + { + 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; } + } + } + } + } } -SDL_Surface * mapHandler::terrainRect(int x, int y, int dx, int dy) +SDL_Surface * mapHandler::terrainRect(int x, int y, int dx, int dy, int level) { #if SDL_BYTEORDER == SDL_BIG_ENDIAN int rmask = 0xff000000; @@ -81,8 +133,10 @@ SDL_Surface * mapHandler::terrainRect(int x, int y, int dx, int dy) sr->y=by*32; sr->x=bx*32; sr->h=sr->w=32; - - SDL_BlitSurface(terrainBitmap[bx+x][by+y],NULL,su,sr); + if (!level) + SDL_BlitSurface(terrainBitmap[bx+x][by+y],NULL,su,sr); + else + SDL_BlitSurface(undTerrainBitmap[bx+x][by+y],NULL,su,sr); delete sr; //SDL_BlitSurface(su,NULL,ekran,NULL);SDL_Flip(ekran); } diff --git a/mapHandler.h b/mapHandler.h index cc40b1011..2d0433d0c 100644 --- a/mapHandler.h +++ b/mapHandler.h @@ -5,7 +5,7 @@ public: CAmbarCendamo * reader; SDL_Surface *** terrainBitmap; SDL_Surface *** undTerrainBitmap; // used only if there is underground level - SDL_Surface * terrainRect(int x, int y, int dx, int dy); + SDL_Surface * terrainRect(int x, int y, int dx, int dy, int level=0); SDL_Surface mirrorImage(SDL_Surface *src); void init(); }; \ No newline at end of file diff --git a/stdafx.h b/stdafx.h index ad4ed34d3..1fb46e025 100644 --- a/stdafx.h +++ b/stdafx.h @@ -11,6 +11,6 @@ #include #include #include - +#include // TODO: reference additional headers your program requires here