* some map loading formula (x/y) corrections
* first preparations to correctly position gui camera on real location, not just somewhere. formulas are still crap, need some help here. * fixed bug with IsFloatField(), thx bLuma! * misc code cleanups
This commit is contained in:
parent
5019a95392
commit
f879006477
@ -43,6 +43,7 @@ PseuGUI::PseuGUI()
|
|||||||
_guienv = NULL;
|
_guienv = NULL;
|
||||||
_scene = NULL;
|
_scene = NULL;
|
||||||
_passtime = _lastpasstime = _passtimediff = 0;
|
_passtime = _lastpasstime = _passtimediff = 0;
|
||||||
|
_updateWorldPos = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
PseuGUI::~PseuGUI()
|
PseuGUI::~PseuGUI()
|
||||||
@ -177,7 +178,11 @@ void PseuGUI::Run(void)
|
|||||||
_UpdateSceneState();
|
_UpdateSceneState();
|
||||||
|
|
||||||
if(_scene && _initialized)
|
if(_scene && _initialized)
|
||||||
|
{
|
||||||
|
if(_updateWorldPos)
|
||||||
|
SetWorldPosition(_worldpos_tmp);
|
||||||
_scene->OnUpdate(_passtimediff);
|
_scene->OnUpdate(_passtimediff);
|
||||||
|
}
|
||||||
|
|
||||||
_driver->beginScene(true, true, 0);
|
_driver->beginScene(true, true, 0);
|
||||||
|
|
||||||
@ -205,7 +210,6 @@ void PseuGUI::Run(void)
|
|||||||
_device->setWindowCaption(str.c_str());
|
_device->setWindowCaption(str.c_str());
|
||||||
|
|
||||||
lastFPS = fps;
|
lastFPS = fps;
|
||||||
DEBUG(logdebug("PseuGUI: Current FPS: %u",fps));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -258,6 +262,7 @@ void PseuGUI::_UpdateSceneState(void)
|
|||||||
case SCENESTATE_WORLD: _scene = new SceneWorld(this); break;
|
case SCENESTATE_WORLD: _scene = new SceneWorld(this); break;
|
||||||
default: _scene = new Scene(this); // will draw nothing, just yield the gui
|
default: _scene = new Scene(this); // will draw nothing, just yield the gui
|
||||||
}
|
}
|
||||||
|
_scene->SetState(_scenestate);
|
||||||
|
|
||||||
logdebug("PseuGUI: scene created.");
|
logdebug("PseuGUI: scene created.");
|
||||||
}
|
}
|
||||||
@ -269,6 +274,32 @@ void PseuGUI::DrawCurrentScene(void)
|
|||||||
_scene->OnDraw();
|
_scene->OnDraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// used to get our current WorldPosition
|
||||||
|
WorldPosition PseuGUI::GetWorldPosition(void)
|
||||||
|
{
|
||||||
|
if(_scene && _scene->GetState() == SCENESTATE_WORLD)
|
||||||
|
{
|
||||||
|
return ((SceneWorld*)_scene)->GetWorldPosition();
|
||||||
|
}
|
||||||
|
return WorldPosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
// used to notify the SceneWorld about a position change the server sent to us
|
||||||
|
void PseuGUI::SetWorldPosition(WorldPosition wp)
|
||||||
|
{
|
||||||
|
// buffer new position if the scene is not (yet) a world scene
|
||||||
|
_worldpos_tmp = wp;
|
||||||
|
if(_scene && _scene->GetState() == SCENESTATE_WORLD)
|
||||||
|
{
|
||||||
|
_updateWorldPos = false;
|
||||||
|
((SceneWorld*)_scene)->SetWorldPosition(wp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_updateWorldPos = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void PseuGUI::_HandleWindowResize(void)
|
void PseuGUI::_HandleWindowResize(void)
|
||||||
{
|
{
|
||||||
dimension2d<s32> scrn = _driver->getScreenSize();
|
dimension2d<s32> scrn = _driver->getScreenSize();
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "irrlicht/irrlicht.h"
|
#include "irrlicht/irrlicht.h"
|
||||||
#include "DrawObjMgr.h"
|
#include "DrawObjMgr.h"
|
||||||
|
#include "World.h"
|
||||||
|
|
||||||
class PseuGUI;
|
class PseuGUI;
|
||||||
class Object;
|
class Object;
|
||||||
@ -75,6 +76,10 @@ public:
|
|||||||
void DrawCurrentScene(void);
|
void DrawCurrentScene(void);
|
||||||
void SetSceneState(SceneState);
|
void SetSceneState(SceneState);
|
||||||
|
|
||||||
|
// helpers
|
||||||
|
WorldPosition GetWorldPosition(void);
|
||||||
|
void SetWorldPosition(WorldPosition);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _Init(void);
|
void _Init(void);
|
||||||
void _UpdateSceneState(void);
|
void _UpdateSceneState(void);
|
||||||
@ -94,6 +99,8 @@ private:
|
|||||||
irr::ITimer *_timer;
|
irr::ITimer *_timer;
|
||||||
uint32 _passtime, _lastpasstime, _passtimediff;
|
uint32 _passtime, _lastpasstime, _passtimediff;
|
||||||
irr::core::dimension2d<irr::s32> _screendimension;
|
irr::core::dimension2d<irr::s32> _screendimension;
|
||||||
|
WorldPosition _worldpos_tmp;
|
||||||
|
bool _updateWorldPos;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -19,6 +19,8 @@ class Scene
|
|||||||
public:
|
public:
|
||||||
Scene(PseuGUI *g);
|
Scene(PseuGUI *g);
|
||||||
~Scene();
|
~Scene();
|
||||||
|
inline void SetState(SceneState sc) { _scenestate = sc; }
|
||||||
|
inline SceneState GetState(void) { return _scenestate; }
|
||||||
virtual void OnUpdate(s32);
|
virtual void OnUpdate(s32);
|
||||||
virtual void OnDraw(void);
|
virtual void OnDraw(void);
|
||||||
virtual void OnDelete(void);
|
virtual void OnDelete(void);
|
||||||
@ -29,6 +31,7 @@ protected:
|
|||||||
irr::video::IVideoDriver* driver;
|
irr::video::IVideoDriver* driver;
|
||||||
irr::scene::ISceneManager* smgr;
|
irr::scene::ISceneManager* smgr;
|
||||||
irr::gui::IGUIEnvironment* guienv;
|
irr::gui::IGUIEnvironment* guienv;
|
||||||
|
SceneState _scenestate;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SceneGuiStart : public Scene
|
class SceneGuiStart : public Scene
|
||||||
@ -58,6 +61,10 @@ public:
|
|||||||
void OnUpdate(s32);
|
void OnUpdate(s32);
|
||||||
void UpdateTerrain(void);
|
void UpdateTerrain(void);
|
||||||
void InitTerrain(void);
|
void InitTerrain(void);
|
||||||
|
|
||||||
|
WorldPosition GetWorldPosition(void);
|
||||||
|
void SetWorldPosition(WorldPosition);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ShTlTerrainSceneNode *terrain;
|
ShTlTerrainSceneNode *terrain;
|
||||||
MCameraFPS *camera;
|
MCameraFPS *camera;
|
||||||
|
|||||||
@ -13,6 +13,9 @@
|
|||||||
#include "World.h"
|
#include "World.h"
|
||||||
|
|
||||||
#define MOUSE_SENSIVITY 0.5f
|
#define MOUSE_SENSIVITY 0.5f
|
||||||
|
#define ANGLE_STEP (M_PI/180)
|
||||||
|
#define DEG_TO_RAD(x) ((x)*ANGLE_STEP)
|
||||||
|
#define RAD_TO_DEG(x) ((x)/ANGLE_STEP)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -157,14 +160,19 @@ void SceneWorld::OnUpdate(s32 timediff)
|
|||||||
if (eventrecv->mouse.wheel < 10) eventrecv->mouse.wheel = 10;
|
if (eventrecv->mouse.wheel < 10) eventrecv->mouse.wheel = 10;
|
||||||
camera->setHeight( eventrecv->mouse.wheel + terrain->getHeight(camera->getPosition()) );
|
camera->setHeight( eventrecv->mouse.wheel + terrain->getHeight(camera->getPosition()) );
|
||||||
|
|
||||||
|
WorldPosition wp = GetWorldPosition();
|
||||||
core::stringw str = L"Camera: pitch:";
|
core::stringw str = L"Camera: pitch:";
|
||||||
str += camera->getPitch();
|
str += camera->getPitch();
|
||||||
str += L" dir:";
|
str += L" dir:";
|
||||||
str += camera->getDirection().X;
|
str += camera->getDirection().X;
|
||||||
str += L",";
|
str += L",";
|
||||||
str += camera->getDirection().Y;
|
str += camera->getDirection().Y;
|
||||||
|
str += L",";
|
||||||
|
str += camera->getDirection().Z;
|
||||||
|
str += " ## o: ";
|
||||||
|
str += DEG_TO_RAD(camera->getHeading());
|
||||||
str += L" Pos: ";
|
str += L" Pos: ";
|
||||||
str = (((((str + camera->getPosition().X) + L" | ") + camera->getPosition().Y) + L" | ") + camera->getPosition().Z);
|
str = ((((((str + wp.x) + L" | ") + wp.y) + L" | ") + wp.z) + L" | ") + wp.o;
|
||||||
str += L" -- Terrain: Sectors: ";
|
str += L" -- Terrain: Sectors: ";
|
||||||
str += (int)terrain->getSectorsRendered();
|
str += (int)terrain->getSectorsRendered();
|
||||||
str += L" / ";
|
str += L" / ";
|
||||||
@ -260,10 +268,10 @@ void SceneWorld::UpdateTerrain(void)
|
|||||||
{
|
{
|
||||||
for(uint32 hx = 0; hx < 9; hx++)
|
for(uint32 hx = 0; hx < 9; hx++)
|
||||||
{
|
{
|
||||||
f32 h = chunk->hmap_rough[hx * 9 + hy] + chunk->baseheight; // not sure if hx and hy are used correctly here
|
f32 h = chunk->hmap_rough[hy * 9 + hx] + chunk->baseheight; // not sure if hx and hy are used correctly here
|
||||||
u32 terrainx = (144 * tiley) + (9 * chx) + hx;
|
u32 terrainx = (144 * tilex) + (9 * chx) + hx;
|
||||||
u32 terrainy = (144 * tilex) + (9 * chy) + hy;
|
u32 terrainy = (144 * tiley) + (9 * chy) + hy;
|
||||||
terrain->setHeight(terrainx, terrainy, h);
|
terrain->setHeight(terrainy, terrainx, h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -289,7 +297,7 @@ void SceneWorld::UpdateTerrain(void)
|
|||||||
}
|
}
|
||||||
f32 heightdiff = highest - lowest;
|
f32 heightdiff = highest - lowest;
|
||||||
|
|
||||||
// randomize terrain color dependng on height
|
// randomize terrain color depending on height
|
||||||
for(s32 j=0; j<terrain->getSize().Height+1; j++)
|
for(s32 j=0; j<terrain->getSize().Height+1; j++)
|
||||||
for(s32 i=0; i<terrain->getSize().Width+1; i++)
|
for(s32 i=0; i<terrain->getSize().Width+1; i++)
|
||||||
{
|
{
|
||||||
@ -304,3 +312,47 @@ void SceneWorld::UpdateTerrain(void)
|
|||||||
logdebug("SceneWorld: Smoothing terrain normals...");
|
logdebug("SceneWorld: Smoothing terrain normals...");
|
||||||
terrain->smoothNormals();
|
terrain->smoothNormals();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WorldPosition SceneWorld::GetWorldPosition(void)
|
||||||
|
{
|
||||||
|
// TODO: later do not use CAMERA, but CHARACTER position, as soon as camera is changed from 1st to 3rd person view
|
||||||
|
// and floating around character in the middle
|
||||||
|
vector3df cam = camera->getPosition();
|
||||||
|
// TODO: need to correct camera values, the coords irrlicht returns are not suitable
|
||||||
|
|
||||||
|
// get the current maptile and use the coords of the top-left corner as relative positions
|
||||||
|
MapTile *tile = mapmgr->GetCurrentTile();
|
||||||
|
float mapx = tile->GetBaseX();
|
||||||
|
float mapy = tile->GetBaseY();
|
||||||
|
return WorldPosition(cam.X + mapx, cam.Z + mapy, cam.Y, DEG_TO_RAD(camera->getHeading()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void SceneWorld::SetWorldPosition(WorldPosition wp)
|
||||||
|
{
|
||||||
|
UpdateTerrain();
|
||||||
|
vector3df cam;
|
||||||
|
dimension2d<s32> tsize = terrain->getSize();
|
||||||
|
MapTile *tile = mapmgr->GetTile(MapMgr::GetGridCoord(wp.x), MapMgr::GetGridCoord(wp.y));
|
||||||
|
ASSERT(tile == mapmgr->GetCurrentTile()); // for debugging; we should already be located on the new tile
|
||||||
|
if(!tile)
|
||||||
|
{
|
||||||
|
logerror("SceneWorld::SetWorldPosition(): MapTile not loaded!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cam.X = tile->GetBaseX() - wp.x + (tsize.Width * UNITSIZE);
|
||||||
|
cam.Y = tile->GetBaseX() - wp.y + (tsize.Height * UNITSIZE);
|
||||||
|
float heading = RAD_TO_DEG(wp.o);
|
||||||
|
float heading_diff = camera->getHeading() - heading;
|
||||||
|
logdebug("Setting camera to x: %3f y: %3f z:%3f head: %3f", cam.X, cam.Y, cam.Z, heading);
|
||||||
|
|
||||||
|
// TODO:
|
||||||
|
// - correct the above formulas
|
||||||
|
// - find out terrain height where the camera should be set
|
||||||
|
// - set camera to correct position
|
||||||
|
// - correct camera turning
|
||||||
|
//camera->setPosition(cam);
|
||||||
|
//camera->turnRight(heading_diff);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -151,6 +151,7 @@ uint32 PlayerNameCache::GetSize(void)
|
|||||||
|
|
||||||
void ItemProtoCache_InsertDataToSession(WorldSession *session)
|
void ItemProtoCache_InsertDataToSession(WorldSession *session)
|
||||||
{
|
{
|
||||||
|
logdetail("ItemProtoCache: Loading...");
|
||||||
char* fn = "./cache/ItemPrototypes.cache";
|
char* fn = "./cache/ItemPrototypes.cache";
|
||||||
std::fstream fh;
|
std::fstream fh;
|
||||||
fh.open(fn, std::ios_base::in | std::ios_base::binary);
|
fh.open(fn, std::ios_base::in | std::ios_base::binary);
|
||||||
@ -176,6 +177,11 @@ void ItemProtoCache_InsertDataToSession(WorldSession *session)
|
|||||||
buf.clear();
|
buf.clear();
|
||||||
fh.read((char*)&datasize,sizeof(uint32));
|
fh.read((char*)&datasize,sizeof(uint32));
|
||||||
buf.resize(datasize);
|
buf.resize(datasize);
|
||||||
|
if(buf.size() < datasize)
|
||||||
|
{
|
||||||
|
logerror("ItemProtoCache: Failed to resize ByteBuffer!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
fh.read((char*)buf.contents(),datasize);
|
fh.read((char*)buf.contents(),datasize);
|
||||||
ItemProto *proto = new ItemProto;
|
ItemProto *proto = new ItemProto;
|
||||||
buf >> proto->Id;
|
buf >> proto->Id;
|
||||||
@ -274,7 +280,7 @@ void ItemProtoCache_InsertDataToSession(WorldSession *session)
|
|||||||
delete proto;
|
delete proto;
|
||||||
}
|
}
|
||||||
fh.close();
|
fh.close();
|
||||||
log("ItemProtoCache: Loaded %u Item Prototypes",counter);
|
logdetail("ItemProtoCache: Loaded %u Item Prototypes",counter);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemProtoCache_WriteDataToCache(WorldSession *session)
|
void ItemProtoCache_WriteDataToCache(WorldSession *session)
|
||||||
|
|||||||
@ -36,12 +36,11 @@ void MapMgr::Update(float x, float y, uint32 m)
|
|||||||
GridCoordPair gcoords = GetTransformGridCoordPair(x,y);
|
GridCoordPair gcoords = GetTransformGridCoordPair(x,y);
|
||||||
if(gcoords.x != _gridx || gcoords.y != _gridy)
|
if(gcoords.x != _gridx || gcoords.y != _gridy)
|
||||||
{
|
{
|
||||||
_LoadNearTiles(gcoords.x,gcoords.y,m);
|
|
||||||
_gridx = gcoords.x;
|
_gridx = gcoords.x;
|
||||||
_gridy = gcoords.y;
|
_gridy = gcoords.y;
|
||||||
|
_LoadNearTiles(_gridx,_gridy,m);
|
||||||
_UnloadOldTiles();
|
_UnloadOldTiles();
|
||||||
}
|
}
|
||||||
_mapid = m;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapMgr::Flush(void)
|
void MapMgr::Flush(void)
|
||||||
@ -99,10 +98,10 @@ void MapMgr::_LoadTile(uint32 gx, uint32 gy, uint32 m)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MapMgr::_UnloadOldTiles(void)
|
void MapMgr::_UnloadOldTiles(void)
|
||||||
{
|
|
||||||
for(uint32 gx=0; gx<64; gx++)
|
|
||||||
{
|
{
|
||||||
for(uint32 gy=0; gy<64; gy++)
|
for(uint32 gy=0; gy<64; gy++)
|
||||||
|
{
|
||||||
|
for(uint32 gx=0; gx<64; gx++)
|
||||||
{
|
{
|
||||||
if( (_gridx < gx-1 || _gridx > gx+1) && (_gridy < gy-1 || _gridy > gy+1) )
|
if( (_gridx < gx-1 || _gridx > gx+1) && (_gridy < gy-1 || _gridy > gy+1) )
|
||||||
{
|
{
|
||||||
@ -145,7 +144,7 @@ uint32 MapMgr::GetGridCoord(float f)
|
|||||||
|
|
||||||
GridCoordPair MapMgr::GetTransformGridCoordPair(float x, float y)
|
GridCoordPair MapMgr::GetTransformGridCoordPair(float x, float y)
|
||||||
{
|
{
|
||||||
return GridCoordPair(GetGridCoord(y), GetGridCoord(x)); // i have no idea why they are swapping x and y map coords in ADT files...
|
return GridCoordPair(GetGridCoord(x), GetGridCoord(y));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 MapMgr::GetLoadedMapsCount(void)
|
uint32 MapMgr::GetLoadedMapsCount(void)
|
||||||
|
|||||||
@ -44,6 +44,7 @@ public:
|
|||||||
inline uint16 GetValuesCount(void) { return _valuescount; }
|
inline uint16 GetValuesCount(void) { return _valuescount; }
|
||||||
|
|
||||||
inline const uint8 GetTypeId() { return _typeid; }
|
inline const uint8 GetTypeId() { return _typeid; }
|
||||||
|
inline const uint8 GetTypeMask() { return _type; }
|
||||||
inline bool isType(uint8 mask) { return (mask & _type) ? true : false; }
|
inline bool isType(uint8 mask) { return (mask & _type) ? true : false; }
|
||||||
inline const uint32 GetUInt32Value( uint16 index ) const
|
inline const uint32 GetUInt32Value( uint16 index ) const
|
||||||
{
|
{
|
||||||
|
|||||||
@ -60,7 +60,7 @@ void WorldSession::_HandleUpdateObjectOpcode(WorldPacket& recvPacket)
|
|||||||
if(obj)
|
if(obj)
|
||||||
this->_MovementUpdate(obj->GetTypeId(),uguid,recvPacket);
|
this->_MovementUpdate(obj->GetTypeId(),uguid,recvPacket);
|
||||||
else
|
else
|
||||||
logcustom(2,RED,"Got UpdateObject_Movement for unknown object "I64FMT,uguid);
|
logerror("Got UpdateObject_Movement for unknown object "I64FMT,uguid);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -332,7 +332,7 @@ void WorldSession::_ValuesUpdate(uint64 uguid, WorldPacket& recvPacket)
|
|||||||
{
|
{
|
||||||
if (umask.GetBit(i))
|
if (umask.GetBit(i))
|
||||||
{
|
{
|
||||||
if(IsFloatField(obj->GetTypeId(),i))
|
if(IsFloatField(obj->GetTypeMask(),i))
|
||||||
{
|
{
|
||||||
recvPacket >> fvalue;
|
recvPacket >> fvalue;
|
||||||
obj->SetFloatValue(i, fvalue);
|
obj->SetFloatValue(i, fvalue);
|
||||||
@ -389,16 +389,14 @@ void WorldSession::_QueryObjectInfo(uint64 guid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// helper to determine if an updatefield should store float or int values, depending on TypeId
|
// helper to determine if an updatefield should store float or int values, depending on TypeId
|
||||||
bool IsFloatField(uint8 tyid, uint32 f)
|
bool IsFloatField(uint8 ty, uint32 f)
|
||||||
{
|
{
|
||||||
static bool first_use = true;
|
|
||||||
static uint32 *ty[TYPEID_CORPSE+1];
|
|
||||||
|
|
||||||
static uint32 floats_object[] =
|
static uint32 floats_object[] =
|
||||||
{
|
{
|
||||||
(uint32)OBJECT_FIELD_SCALE_X,
|
(uint32)OBJECT_FIELD_SCALE_X,
|
||||||
(uint32)-1
|
(uint32)-1
|
||||||
};
|
};
|
||||||
|
/*
|
||||||
static uint32 floats_item[] =
|
static uint32 floats_item[] =
|
||||||
{
|
{
|
||||||
(uint32)-1
|
(uint32)-1
|
||||||
@ -407,6 +405,7 @@ bool IsFloatField(uint8 tyid, uint32 f)
|
|||||||
{
|
{
|
||||||
(uint32)-1
|
(uint32)-1
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
static uint32 floats_unit[] =
|
static uint32 floats_unit[] =
|
||||||
{
|
{
|
||||||
(uint32)UNIT_FIELD_BOUNDINGRADIUS,
|
(uint32)UNIT_FIELD_BOUNDINGRADIUS,
|
||||||
@ -467,21 +466,39 @@ bool IsFloatField(uint8 tyid, uint32 f)
|
|||||||
(uint32)-1
|
(uint32)-1
|
||||||
};
|
};
|
||||||
|
|
||||||
if(first_use)
|
if(ty & TYPE_OBJECT)
|
||||||
{
|
for(uint32 i = 0; floats_object[i] != (-1); i++)
|
||||||
first_use = true;
|
if(floats_object[i] == f)
|
||||||
ty[TYPEID_OBJECT] = &floats_object[0];
|
return true;
|
||||||
ty[TYPEID_ITEM] = &floats_item[0];
|
/*
|
||||||
ty[TYPEID_CONTAINER] = &floats_container[0];
|
if(ty & TYPE_ITEM)
|
||||||
ty[TYPEID_UNIT] = &floats_unit[0];
|
for(uint32 i = 0; floats_item[i] != (-1); i++)
|
||||||
ty[TYPEID_PLAYER] = &floats_player[0];
|
if(floats_object[i] == f)
|
||||||
ty[TYPEID_GAMEOBJECT] = &floats_gameobject[0];
|
return true;
|
||||||
ty[TYPEID_DYNAMICOBJECT] = &floats_dynobject[0];
|
if(ty & TYPE_CONTAINER)
|
||||||
ty[TYPEID_CORPSE] = &floats_corpse[0];
|
for(uint32 i = 0; floats_container[i] != (-1); i++)
|
||||||
}
|
if(floats_object[i] == f)
|
||||||
|
return true;
|
||||||
for(uint32 i = 0; ty[tyid][i] != (-1); i++)
|
*/
|
||||||
if(ty[tyid][i] == f)
|
if(ty & TYPE_UNIT)
|
||||||
|
for(uint32 i = 0; floats_unit[i] != (-1); i++)
|
||||||
|
if(floats_unit[i] == f)
|
||||||
|
return true;
|
||||||
|
if(ty & TYPE_PLAYER)
|
||||||
|
for(uint32 i = 0; floats_player[i] != (-1); i++)
|
||||||
|
if(floats_player[i] == f)
|
||||||
|
return true;
|
||||||
|
if(ty & TYPE_GAMEOBJECT)
|
||||||
|
for(uint32 i = 0; floats_gameobject[i] != (-1); i++)
|
||||||
|
if(floats_gameobject[i] == f)
|
||||||
|
return true;
|
||||||
|
if(ty & TYPE_DYNAMICOBJECT)
|
||||||
|
for(uint32 i = 0; floats_dynobject[i] != (-1); i++)
|
||||||
|
if(floats_dynobject[i] == f)
|
||||||
|
return true;
|
||||||
|
if(ty & TYPE_CORPSE)
|
||||||
|
for(uint32 i = 0; floats_corpse[i] != (-1); i++)
|
||||||
|
if(floats_corpse[i] == f)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -4,6 +4,15 @@
|
|||||||
class WorldSession;
|
class WorldSession;
|
||||||
class MapMgr;
|
class MapMgr;
|
||||||
|
|
||||||
|
struct WorldPosition
|
||||||
|
{
|
||||||
|
WorldPosition() : x(0.0f), y(0.0f), z(0.0f), o(0.0f) {};
|
||||||
|
WorldPosition(float px, float py) : x(px), y(py), z(0.0f), o(0.0f) {};
|
||||||
|
WorldPosition(float px, float py, float pz) : x(px), y(py), z(pz), o(0.0f) {};
|
||||||
|
WorldPosition(float px, float py, float pz, float po) : x(px), y(py), z(pz), o(po) {};
|
||||||
|
float x,y,z,o;
|
||||||
|
};
|
||||||
|
|
||||||
// used as interface for movement, map data,
|
// used as interface for movement, map data,
|
||||||
class World
|
class World
|
||||||
{
|
{
|
||||||
|
|||||||
@ -99,7 +99,7 @@ void WorldSession::AddToPktQueue(WorldPacket *pkt)
|
|||||||
void WorldSession::SendWorldPacket(WorldPacket &pkt)
|
void WorldSession::SendWorldPacket(WorldPacket &pkt)
|
||||||
{
|
{
|
||||||
if(GetInstance()->GetConf()->showmyopcodes)
|
if(GetInstance()->GetConf()->showmyopcodes)
|
||||||
logcustom(0,BROWN,"<< Opcode %u [%s]", pkt.GetOpcode(), GetOpcodeName(pkt.GetOpcode()));
|
logcustom(0,BROWN,"<< Opcode %u [%s] (%u bytes)", pkt.GetOpcode(), GetOpcodeName(pkt.GetOpcode()), pkt.size());
|
||||||
if(_socket && _socket->IsOk())
|
if(_socket && _socket->IsOk())
|
||||||
_socket->SendWorldPacket(pkt);
|
_socket->SendWorldPacket(pkt);
|
||||||
else
|
else
|
||||||
@ -637,7 +637,6 @@ void WorldSession::_HandleMessageChatOpcode(WorldPacket& recvPacket)
|
|||||||
// TODO: also _onwhisper must be replaced by this!
|
// TODO: also _onwhisper must be replaced by this!
|
||||||
if(!isCmd && GetInstance()->GetScripts()->GetScript("_onchatmessage"))
|
if(!isCmd && GetInstance()->GetScripts()->GetScript("_onchatmessage"))
|
||||||
{
|
{
|
||||||
DEBUG(logdebug("DefScript chat handler found, executing _onchatmessage"));
|
|
||||||
CmdSet Set;
|
CmdSet Set;
|
||||||
Set.arg[0] = toString(type);
|
Set.arg[0] = toString(type);
|
||||||
Set.arg[1] = toString(lang);
|
Set.arg[1] = toString(lang);
|
||||||
@ -795,9 +794,14 @@ void WorldSession::_HandleTelePortAckOpcode(WorldPacket& recvPacket)
|
|||||||
response << uint32(0) << (uint32)getMSTime(); // no flags; time correct?
|
response << uint32(0) << (uint32)getMSTime(); // no flags; time correct?
|
||||||
response << x << y << z << o << uint32(0);
|
response << x << y << z << o << uint32(0);
|
||||||
SendWorldPacket(response);
|
SendWorldPacket(response);
|
||||||
if(_world)
|
|
||||||
_world->UpdatePos(x,y);
|
_world->UpdatePos(x,y);
|
||||||
|
|
||||||
|
if(PseuGUI *gui = GetInstance()->GetGUI())
|
||||||
|
{
|
||||||
|
gui->SetWorldPosition(WorldPosition(x,y,z,o));
|
||||||
|
}
|
||||||
|
|
||||||
if(GetInstance()->GetScripts()->ScriptExists("_onteleport"))
|
if(GetInstance()->GetScripts()->ScriptExists("_onteleport"))
|
||||||
{
|
{
|
||||||
CmdSet Set;
|
CmdSet Set;
|
||||||
@ -824,6 +828,14 @@ void WorldSession::_HandleNewWorldOpcode(WorldPacket& recvPacket)
|
|||||||
_world->UpdatePos(x,y,mapid);
|
_world->UpdatePos(x,y,mapid);
|
||||||
_world->Update();
|
_world->Update();
|
||||||
|
|
||||||
|
// TODO: need to switch to SCENESTATE_LOGINSCREEN here, and after everything is loaded, back to SCENESTATE_WORLD
|
||||||
|
if(PseuGUI *gui = GetInstance()->GetGUI())
|
||||||
|
{
|
||||||
|
//gui->SetSceneState(SCENESTATE_WORLD);
|
||||||
|
// commented out, should be world scene anyway at this point...
|
||||||
|
gui->SetWorldPosition(WorldPosition(x,y,z,o));
|
||||||
|
}
|
||||||
|
|
||||||
if(GetInstance()->GetScripts()->ScriptExists("_onteleport"))
|
if(GetInstance()->GetScripts()->ScriptExists("_onteleport"))
|
||||||
{
|
{
|
||||||
CmdSet Set;
|
CmdSet Set;
|
||||||
@ -868,7 +880,6 @@ void WorldSession::_HandleInitialSpellsOpcode(WorldPacket& recvPacket)
|
|||||||
{
|
{
|
||||||
recvPacket >> spellid >> spellslot;
|
recvPacket >> spellid >> spellslot;
|
||||||
logdebug("Initial Spell: id=%u slot=%u",spellid,spellslot);
|
logdebug("Initial Spell: id=%u slot=%u",spellid,spellslot);
|
||||||
|
|
||||||
GetMyChar()->AddSpell(spellid, spellslot);
|
GetMyChar()->AddSpell(spellid, spellslot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1030,6 +1041,7 @@ void WorldSession::_HandleLoginVerifyWorldOpcode(WorldPacket& recvPacket)
|
|||||||
if(PseuGUI *gui = GetInstance()->GetGUI())
|
if(PseuGUI *gui = GetInstance()->GetGUI())
|
||||||
{
|
{
|
||||||
gui->SetSceneState(SCENESTATE_WORLD);
|
gui->SetSceneState(SCENESTATE_WORLD);
|
||||||
|
gui->SetWorldPosition(WorldPosition(x,y,z,o));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -37,7 +37,9 @@ bool ADTFile::LoadMem(ByteBuffer& buf)
|
|||||||
uint32 texturecnt=0,modelcnt=0,wmocnt=0;
|
uint32 texturecnt=0,modelcnt=0,wmocnt=0;
|
||||||
uint32 size; // used for every chunk
|
uint32 size; // used for every chunk
|
||||||
uint32 mcnkid=0;
|
uint32 mcnkid=0;
|
||||||
uint8 *fourcc = new uint8[5]; fourcc[4]=0;
|
uint8 _cc[5];
|
||||||
|
uint8 *fourcc = &_cc[0];
|
||||||
|
fourcc[4]=0;
|
||||||
|
|
||||||
while(buf.rpos() < buf.size())
|
while(buf.rpos() < buf.size())
|
||||||
{
|
{
|
||||||
@ -150,7 +152,9 @@ bool ADTFile::LoadMem(ByteBuffer& buf)
|
|||||||
else if(!strcmp((char*)fourcc,"MCNK"))
|
else if(!strcmp((char*)fourcc,"MCNK"))
|
||||||
{
|
{
|
||||||
_chunks[mcnkid].hdr = buf.read<ADTMapChunkHeader>();
|
_chunks[mcnkid].hdr = buf.read<ADTMapChunkHeader>();
|
||||||
uint8 *mfcc = new uint8[5]; mfcc[4]=0;
|
uint8 _cc2[5];
|
||||||
|
uint8 *mfcc = &_cc2[0];
|
||||||
|
mfcc[4]=0;
|
||||||
uint32 msize;
|
uint32 msize;
|
||||||
while(buf.rpos()<buf.size())
|
while(buf.rpos()<buf.size())
|
||||||
{
|
{
|
||||||
@ -204,7 +208,8 @@ bool ADTFile::LoadMem(ByteBuffer& buf)
|
|||||||
}
|
}
|
||||||
else if(!strcmp((char*)mfcc,"MCLQ"))
|
else if(!strcmp((char*)mfcc,"MCLQ"))
|
||||||
{
|
{
|
||||||
uint8 *fcc1 = new uint8[5];
|
uint8 _cc3[5];
|
||||||
|
uint8 *fcc1 = &_cc3[0];
|
||||||
buf.read(fcc1,4);
|
buf.read(fcc1,4);
|
||||||
flipcc(fcc1);
|
flipcc(fcc1);
|
||||||
fcc1[4]=0;
|
fcc1[4]=0;
|
||||||
@ -213,7 +218,6 @@ bool ADTFile::LoadMem(ByteBuffer& buf)
|
|||||||
_chunks[mcnkid].haswater = false;
|
_chunks[mcnkid].haswater = false;
|
||||||
//DEBUG(printf("ADT: MCNK: MCLQ not present\n"));
|
//DEBUG(printf("ADT: MCNK: MCLQ not present\n"));
|
||||||
buf.rpos(buf.rpos()-4);
|
buf.rpos(buf.rpos()-4);
|
||||||
delete [] fcc1;
|
|
||||||
continue; // next block read will be the MCSE block
|
continue; // next block read will be the MCSE block
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -248,7 +252,6 @@ bool ADTFile::LoadMem(ByteBuffer& buf)
|
|||||||
diffbytes = (msize-8) - rbytes; // dont forget to skip the 8 initial bytes
|
diffbytes = (msize-8) - rbytes; // dont forget to skip the 8 initial bytes
|
||||||
buf.rpos(buf.rpos()+diffbytes);
|
buf.rpos(buf.rpos()+diffbytes);
|
||||||
//DEBUG(printf("ADT: MCNK: MCLQ - %u junk bytes skipped\n",diffbytes));
|
//DEBUG(printf("ADT: MCNK: MCLQ - %u junk bytes skipped\n",diffbytes));
|
||||||
delete [] fcc1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(!strcmp((char*)mfcc,"MCSE"))
|
else if(!strcmp((char*)mfcc,"MCSE"))
|
||||||
@ -266,14 +269,13 @@ bool ADTFile::LoadMem(ByteBuffer& buf)
|
|||||||
if(!(isalnum(mfcc[0]) && isalnum(mfcc[1]) && isalnum(mfcc[2]) && isalnum(mfcc[3])))
|
if(!(isalnum(mfcc[0]) && isalnum(mfcc[1]) && isalnum(mfcc[2]) && isalnum(mfcc[3])))
|
||||||
{
|
{
|
||||||
printf("Error loading ADT file (chunk %u error).\n",mcnkid);
|
printf("Error loading ADT file (chunk %u error).\n",mcnkid);
|
||||||
return false; // dont care about those few mem leaks
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf.rpos(buf.rpos()+msize);
|
buf.rpos(buf.rpos()+msize);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
delete [] mfcc;
|
|
||||||
mcnkid++;
|
mcnkid++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -282,13 +284,12 @@ bool ADTFile::LoadMem(ByteBuffer& buf)
|
|||||||
if(!(isalnum(fourcc[0]) && isalnum(fourcc[1]) && isalnum(fourcc[2]) && isalnum(fourcc[3])))
|
if(!(isalnum(fourcc[0]) && isalnum(fourcc[1]) && isalnum(fourcc[2]) && isalnum(fourcc[3])))
|
||||||
{
|
{
|
||||||
printf("Error loading ADT file.\n");
|
printf("Error loading ADT file.\n");
|
||||||
return false; // dont care about those few mem leaks
|
return false;
|
||||||
}
|
}
|
||||||
buf.rpos(buf.rpos()+size);
|
buf.rpos(buf.rpos()+size);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
delete [] fourcc;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -43,7 +43,10 @@ void MapTile::ImportFromADT(ADTFile *adt)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DEBUG(logdebug("MapTile first chunk base: h=%f x=%f y=%f",_chunks[0].baseheight,_chunks[0].basex,_chunks[0].basey));
|
_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));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapTileStorage::_DebugDump(void)
|
void MapTileStorage::_DebugDump(void)
|
||||||
|
|||||||
@ -32,7 +32,10 @@ public:
|
|||||||
void ImportFromADT(ADTFile*);
|
void ImportFromADT(ADTFile*);
|
||||||
float GetZ(float,float);
|
float GetZ(float,float);
|
||||||
void DebugDumpToFile(void);
|
void DebugDumpToFile(void);
|
||||||
inline MapChunk *GetChunk(uint32 x, uint32 y) { return &_chunks[x * 16 + y]; }
|
inline MapChunk *GetChunk(uint32 x, uint32 y) { return &_chunks[y * 16 + x]; }
|
||||||
|
inline float GetBaseX(void) { return _xbase; }
|
||||||
|
inline float GetBaseY(void) { return _ybase; }
|
||||||
|
inline float GetBaseHeight(void) { return _hbase; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MapChunk _chunks[256]; // 16x16
|
MapChunk _chunks[256]; // 16x16
|
||||||
@ -40,7 +43,7 @@ private:
|
|||||||
std::vector<std::string> _wmos;
|
std::vector<std::string> _wmos;
|
||||||
std::vector<std::string> _models;
|
std::vector<std::string> _models;
|
||||||
|
|
||||||
float _xbase,_ybase;
|
float _xbase,_ybase,_hbase;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user