* fixed GetZ() formulas.

* added ascii map dump. everytime pseuwow gets teleported to a new tile, "map_dump.txt" is created in pseuwow base dir.
This commit is contained in:
False.Genesis 2007-06-29 23:01:59 +00:00
parent 0165102288
commit 16be9c5bcc
4 changed files with 50 additions and 5 deletions

View File

@ -123,6 +123,10 @@ float MapMgr::GetZ(float x, float y)
MapTile *tile = _tiles->GetTile(xg,yg);
if(tile)
{
#ifndef _DEBUG
tile->DebugDumpToFile();
logdebug("DEBUG: tile dumped");
#endif
return tile->GetZ(x,y);
}

View File

@ -26,7 +26,7 @@ void World::Update(void)
}
// some debug code for testing...
if(_mapmgr && _x != _lastx && _y != _lasty)
if(_mapmgr && _x != _lastx || _y != _lasty)
{
logdetail("WORLD: relocation, to x=%f y=%f, calculated z=%f",_x,_y,this->GetPosZ(_x,_y));
_lastx = _x;

View File

@ -24,9 +24,9 @@ void MapTile::ImportFromADT(ADTFile *adt)
// import the height map
for(uint32 ch=0; ch<CHUNKS_PER_TILE; ch++)
{
_chunks[ch].basex = adt->_chunks[ch].hdr.zbase; // ADT files store (x/z) as ground coords and (y) as the height!
_chunks[ch].baseheight = adt->_chunks[ch].hdr.zbase; // ADT files store (x/z) as ground coords and (y) as the height!
_chunks[ch].basey = adt->_chunks[ch].hdr.xbase; // here converting it to (x/y) on ground and basehight as actual height.
_chunks[ch].baseheight = adt->_chunks[ch].hdr.ybase; // strange coords they use... :S
_chunks[ch].basex = adt->_chunks[ch].hdr.ybase; // strange coords they use... :S
uint32 fcnt=0, rcnt=0;
while(true) //9*9 + 8*8
{
@ -81,8 +81,8 @@ float MapTile::GetZ(float x, float y)
}
MapChunk& ch = _chunks[chy*16 + chx];
uint32 vx,vy; // get vertex position (0,0) ... (8,8);
vx = (uint32)floor(fabs(ch.basex - x / UNITSIZE) + 0.5f);
vy = (uint32)floor(fabs(ch.basey - x / UNITSIZE) + 0.5f);
vx = (uint32)floor((fabs(ch.basex - x) / UNITSIZE) + 0.5f);
vy = (uint32)floor((fabs(ch.basey - y) / UNITSIZE) + 0.5f);
if(vx > 8 || vy > 8)
{
logerror("MapTile::GetZ() wrong vertex indexes (%d, %d) for chunk (%d, %d) for (%f, %f)",vx,vy,chx,chy,x,y);
@ -93,3 +93,40 @@ float MapTile::GetZ(float x, float y)
return real_z;
}
#ifndef _DEBUG
void MapTile::DebugDumpToFile(void)
{
const char *f = "0123456789abcdefghijklmnopqrstuvwxyz";
float z;
uint32 p;
std::string out;
for(uint32 cy=0;cy<16;cy++)
{
for(uint32 vy=0;vy<9;vy++)
{
for(uint32 cx=0;cx<16;cx++)
{
for(uint32 vx=0;vx<9;vx++)
{
z = _chunks[cy*16 + cx].hmap_rough[vy*9 + vx] + _chunks[cy*16 + cx].baseheight;
p = (uint32)z;
uint32 pos = 17 + (p/10);
if(pos > strlen(f)-1)
pos=strlen(f)-1;
char c = f[pos];
out += c;
}
}
out += "\n";
}
}
FILE *fh;
fh = fopen("map_dump.txt","w");
fprintf(fh, out.c_str());
fclose(fh);
}
#endif

View File

@ -31,6 +31,10 @@ public:
void ImportFromADT(ADTFile*);
float GetZ(float,float);
#ifndef _DEBUG
void DebugDumpToFile(void);
#endif
private:
MapChunk _chunks[256]; // 16x16
std::vector<std::string> _textures;