diff --git a/bin/stuffextract_svn.exe b/bin/stuffextract_svn.exe new file mode 100644 index 0000000..b74b765 Binary files /dev/null and b/bin/stuffextract_svn.exe differ diff --git a/src/dep/src/irrlicht/Irrlicht7.1.vcproj b/src/dep/src/irrlicht/Irrlicht7.1.vcproj index 3e7ea2f..24e0ed9 100644 --- a/src/dep/src/irrlicht/Irrlicht7.1.vcproj +++ b/src/dep/src/irrlicht/Irrlicht7.1.vcproj @@ -83,7 +83,7 @@ Optimization="2" InlineFunctionExpansion="1" EnableIntrinsicFunctions="FALSE" - AdditionalIncludeDirectories="..\..\include\irrlicht;zlib" + AdditionalIncludeDirectories="..\..\include\irrlicht;..\..\include\DXSDK\include;zlib" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;IRRLICHT_EXPORTS;_CRT_SECURE_NO_DEPRECATE" StringPooling="TRUE" ExceptionHandling="FALSE" @@ -147,7 +147,7 @@ EnableIntrinsicFunctions="TRUE" FavorSizeOrSpeed="0" OmitFramePointers="TRUE" - AdditionalIncludeDirectories="..\..\include\irrlicht;zlib" + AdditionalIncludeDirectories="..\..\include\irrlicht;..\..\include\DXSDK\include;zlib" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;IRRLICHT_EXPORTS;_CRT_SECURE_NO_DEPRECATE" StringPooling="TRUE" ExceptionHandling="FALSE" diff --git a/src/shared/ADTFile.cpp b/src/shared/ADTFile.cpp index 18b4f89..1694722 100644 --- a/src/shared/ADTFile.cpp +++ b/src/shared/ADTFile.cpp @@ -210,6 +210,7 @@ bool ADTFile::LoadMem(ByteBuffer& buf) } else if(!strcmp((char*)mfcc,"MCAL")) { + // we can NOT use _chunks[mcnkid].hdr.nLayers here... so we use: (full block size - header size) / single block size for(uint32 i = 0; i < (_chunks[mcnkid].hdr.sizeAlpha - 8) / 2048; i++) { buf.read((uint8*)(_chunks[mcnkid].alphamap[i]),2048); diff --git a/src/shared/ADTFileStructs.h b/src/shared/ADTFileStructs.h index 8299013..8a5ff14 100644 --- a/src/shared/ADTFileStructs.h +++ b/src/shared/ADTFileStructs.h @@ -7,6 +7,8 @@ #define OFFSET_MODELS 8 #define OFFSET_WMOS 10 +#define ADT_MAXLAYERS 4 + struct MHDR_chunk { uint32 pad; @@ -195,10 +197,10 @@ struct ADTMapChunk ADTMapChunkHeader hdr; float vertices[145]; NormalVector normalvecs[145]; - MCLY_chunk layer[4]; // can be less + MCLY_chunk layer[ADT_MAXLAYERS]; // can be less uint32 nTextures; uint8 shadowmap[512]; // 1 bit 64x64 - uint8 alphamap[4][2048]; // 4 bits, 64x64. max 4, 1 per layer + uint8 alphamap[ADT_MAXLAYERS][2048]; // 4 bits, 64x64. max 4, 1 per layer bool haswater; float waterlevel; LiquidVertex lqvertex[81]; diff --git a/src/shared/MapTile.cpp b/src/shared/MapTile.cpp index 53d2c8f..aa4e9eb 100644 --- a/src/shared/MapTile.cpp +++ b/src/shared/MapTile.cpp @@ -27,6 +27,7 @@ void MapTile::ImportFromADT(ADTFile *adt) _chunks[ch].basex = adt->_chunks[ch].hdr.xbase; // here converting it to (x/y) on ground and basehight as actual height. _chunks[ch].basey = adt->_chunks[ch].hdr.ybase; // strange coords they use... :S _chunks[ch].lqheight = adt->_chunks[ch].waterlevel; + // extract heightmap uint32 fcnt=0, rcnt=0; while(true) //9*9 + 8*8 { @@ -43,14 +44,34 @@ void MapTile::ImportFromADT(ADTFile *adt) fcnt++; } } + // extract water heightmap for(uint32 i = 0; i < 81; i++) { _chunks[ch].hmap_lq[i] = adt->_chunks[ch].lqvertex[i].h; } + // extract map layers with texture filenames + for(uint32 ly = 0; ly < adt->_chunks[ch].hdr.nLayers; ly++) + { + uint32 texoffs = adt->_chunks[ch].layer[ly].textureId; + _chunks[ch].texlayer.push_back(std::string("data/texture/") + _PathToFileName(adt->_textures[texoffs])); + } + // extract alpha maps. in adt they are stored in 4-bit encoding, which makes 4096 entries in 64x32 values + for(uint32 al = 0; al < (adt->_chunks[ch].hdr.sizeAlpha - 8) / 2048; al++) // see comment in ADTFile.cpp when loading MCAL chunk for explanation + { + for(uint32 aly = 0; aly < 64; aly++) + { + for(uint32 alx = 0; alx < 32; alx++) + { + _chunks[ch].alphamap[al][aly*64 + (alx*2)] = adt->_chunks[ch].alphamap[al][aly*64 + alx] & 0xF0; // first 4 bits + _chunks[ch].alphamap[al][aly*64 + (alx*2)+1] = adt->_chunks[ch].alphamap[al][aly*64 + alx] & 0x0F; // second + } + } + } } _xbase = _chunks[0].basex; _ybase = _chunks[0].basey; _hbase = _chunks[0].baseheight; + DEBUG(logdebug("MapTile first chunk base: h=%f x=%f y=%f",_hbase,_xbase,_ybase)); } diff --git a/src/shared/MapTile.h b/src/shared/MapTile.h index 421f6af..a19b524 100644 --- a/src/shared/MapTile.h +++ b/src/shared/MapTile.h @@ -20,6 +20,8 @@ public: float hmap[17*17]; // combined rough and fine hmap float basex,basey,baseheight,lqheight; float hmap_lq[9*9]; // liquid (water, lava) height map + std::vector texlayer; + uint8 alphamap[ADT_MAXLAYERS][64*64]; // TODO: make this a vector also //... TODO: implement the rest of this };