From 926a7566c8089644118d5ca31aca05499ce32569 Mon Sep 17 00:00:00 2001 From: bluma4862 Date: Sun, 11 May 2008 13:36:24 +0000 Subject: [PATCH] * fixed crashes without SCP databases * minor fixes --- src/Client/GUI/DrawObject.cpp | 5 ++--- src/Client/GUI/PseuGUI.h | 2 +- src/Client/GUI/SImage.cpp | 2 ++ src/Client/GUI/SceneWorld.cpp | 15 +++++++++++++-- src/Client/World/WorldSession.cpp | 1 + src/shared/MapTile.cpp | 6 +++--- 6 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/Client/GUI/DrawObject.cpp b/src/Client/GUI/DrawObject.cpp index 6d0feff..9e95aee 100644 --- a/src/Client/GUI/DrawObject.cpp +++ b/src/Client/GUI/DrawObject.cpp @@ -56,7 +56,7 @@ void DrawObject::_Init(void) SCPDatabase *cdi = _instance->dbmgr.GetDB("creaturedisplayinfo"); SCPDatabase *cmd = _instance->dbmgr.GetDB("creaturemodeldata"); uint32 modelid = cdi && displayid ? cdi->GetUint32(displayid,"model") : 0; - modelfile = std::string("data/model/") + cmd->GetString(modelid,"file"); + modelfile = std::string("data/model/") + (cmd ? cmd->GetString(modelid,"file") : ""); opacity = cdi && displayid ? cdi->GetUint32(displayid,"opacity") : 255; } else if (_obj->IsGameObject()) @@ -80,8 +80,7 @@ void DrawObject::_Init(void) SCPDatabase *gdi = _instance->dbmgr.GetDB("gameobjectdisplayinfo"); if (gdi && displayid) modelfile = std::string("data/model/") + gdi->GetString(displayid,"model"); - std::string test = gdi->GetString(displayid,"model"); - DEBUG(logdebug("GAMEOBJECT: %u - %u - %s", _obj->GetEntry(), displayid, test.c_str())); + DEBUG(logdebug("GAMEOBJECT: %u - %u", _obj->GetEntry(), displayid)); } else { DEBUG(logdebug("GAMEOBJECT UNKNOWN: %u", _obj->GetEntry())); } diff --git a/src/Client/GUI/PseuGUI.h b/src/Client/GUI/PseuGUI.h index 55806cc..cea3f86 100644 --- a/src/Client/GUI/PseuGUI.h +++ b/src/Client/GUI/PseuGUI.h @@ -49,7 +49,7 @@ inline irr::core::vector3df WPToIrr(WorldPosition wp) inline WorldPosition IrrToWP(irr::core::vector3df v, float o_rad) { - return WorldPosition(-v.X, v.Z, -v.Y, RAD_FIX(IRR_TO_O(o_rad))); // rotate by 90° and fix value + return WorldPosition(-v.X, -v.Z, v.Y, IRR_TO_O(o_rad)); // rotate by 90° and fix value } diff --git a/src/Client/GUI/SImage.cpp b/src/Client/GUI/SImage.cpp index f79935f..a789b11 100644 --- a/src/Client/GUI/SImage.cpp +++ b/src/Client/GUI/SImage.cpp @@ -43,6 +43,8 @@ u32 SImage::getBitsPerPixelFromFormat(ECOLOR_FORMAT format) } SImage::~SImage() { + if (Data) + delete Data; } diff --git a/src/Client/GUI/SceneWorld.cpp b/src/Client/GUI/SceneWorld.cpp index d37ad27..44121b0 100644 --- a/src/Client/GUI/SceneWorld.cpp +++ b/src/Client/GUI/SceneWorld.cpp @@ -369,7 +369,7 @@ void SceneWorld::UpdateTerrain(void) { logdebug("SceneWorld: Using alternative coords due to missing MapTile"); tpos.X = -(maptile->GetBaseX() + TILESIZE); - tpos.Y = -(maptile->GetBaseY() + TILESIZE); + tpos.Z = -(maptile->GetBaseY() + TILESIZE); } logdebug("SceneWorld: Setting position of terrain (x:%.2f y:%.2f z:%.2f)", tpos.X, tpos.Y, tpos.Z); terrain->setPosition(tpos); @@ -421,8 +421,19 @@ void SceneWorld::UpdateTerrain(void) // this is causing the framerate to drop to ~1. better leave it disabled for now :/ //doodad->addShadowVolumeSceneNode(); doodad->setPosition(core::vector3df(-d->x, d->z, -d->y)); - doodad->setRotation(core::vector3df(-d->ox, -d->oy-90, -d->oz)); + + // Rotation problems + // MapTile.cpp - changed to + // d.ox = mddf.c; d.oy = mddf.b; d.oz = mddf.a; + // its nonsense to do d.oy = mddf.b-90; and rotation with -d->oy-90 = -(mddf.b-90)-90 = -mddf.b + // here: + // doodad->setRotation(core::vector3df(-d->ox,0,-d->oz)); // rotated axes looks good + // doodad->setRotation(core::vector3df(0,-d->oy,0)); // same here + doodad->setRotation(core::vector3df(-d->ox,-d->oy,-d->oz)); // very ugly with some rotations, |ang|>360? + doodad->setScale(core::vector3df(d->scale, d->scale, d->scale)); + + // smgr->addTextSceneNode(this->device->getGUIEnvironment()->getBuiltInFont(), (irr::core::stringw(L"")+(float)d->uniqueid).c_str() , irr::video::SColor(255,255,255,255),doodad, irr::core::vector3df(0,5,0)); SceneNodeWithGridPos gp; gp.gx = mapmgr->GetGridX() + tilex - 1; gp.gy = mapmgr->GetGridY() + tiley - 1; diff --git a/src/Client/World/WorldSession.cpp b/src/Client/World/WorldSession.cpp index dc8d947..750171a 100644 --- a/src/Client/World/WorldSession.cpp +++ b/src/Client/World/WorldSession.cpp @@ -585,6 +585,7 @@ void WorldSession::_HandleCharEnumOpcode(WorldPacket& recvPacket) *mapdb = GetDBMgr().GetDB("map"), *classdb = GetDBMgr().GetDB("class"); char *zonename, *racename, *mapname, *classname; + zonename = racename = mapname = classname = NULL; for(unsigned int i=0;i_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])); + _chunks[ch].texlayer.push_back(std::string("data/texture/") + NormalizeFilename(std::string(adt->_textures[texoffs])).c_str()); } // 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 @@ -80,8 +80,8 @@ void MapTile::ImportFromADT(ADTFile *adt) d.z = mddf.y; d.x = -(mddf.z - ZEROPOINT); d.ox = mddf.c; - d.oy = mddf.b - 90.0f; // wowdev states Y=B-90, but this doesnt really look as expected... - d.oz = -mddf.a; + d.oy = mddf.b; + d.oz = mddf.a; d.flags = mddf.flags; d.uniqueid = mddf.uniqueid; d.model = std::string("./data/model/") + NormalizeFilename(_PathToFileName(adt->_models[mddf.id]));