* first steps for gcc/mingw support, thx shlainn
* output & log platform+compiler+version on startup * added early version of a movement mgr, its is not used yet and does NOT work yet!
This commit is contained in:
parent
16cf12da7c
commit
46a855278e
@ -7,6 +7,8 @@
|
|||||||
template <class T> class TypeStorage
|
template <class T> class TypeStorage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
typedef typename std::map<std::string,T*> _TypeMap;
|
||||||
|
typedef typename _TypeMap::iterator _TypeIter;
|
||||||
TypeStorage() { _keep = false; }
|
TypeStorage() { _keep = false; }
|
||||||
~TypeStorage();
|
~TypeStorage();
|
||||||
bool Exists(std::string);
|
bool Exists(std::string);
|
||||||
@ -25,7 +27,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
T *_Create(std::string);
|
T *_Create(std::string);
|
||||||
std::map<std::string,T*> _storage;
|
_TypeMap _storage;
|
||||||
bool _keep;
|
bool _keep;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -46,7 +48,7 @@ template<class T> T *TypeStorage<T>::_Create(std::string s)
|
|||||||
// delete object with that name, if present
|
// delete object with that name, if present
|
||||||
template<class T> void TypeStorage<T>::Delete(std::string s)
|
template<class T> void TypeStorage<T>::Delete(std::string s)
|
||||||
{
|
{
|
||||||
std::map<std::string,T*>::iterator it = _storage.find(s);
|
_TypeIter it = _storage.find(s);
|
||||||
if(it != _storage.end())
|
if(it != _storage.end())
|
||||||
{
|
{
|
||||||
delete it->second;
|
delete it->second;
|
||||||
@ -57,7 +59,7 @@ template<class T> void TypeStorage<T>::Delete(std::string s)
|
|||||||
// delete object with that ptr, if present
|
// delete object with that ptr, if present
|
||||||
template<class T> void TypeStorage<T>::DeleteByPtr(T *ptr)
|
template<class T> void TypeStorage<T>::DeleteByPtr(T *ptr)
|
||||||
{
|
{
|
||||||
for(std::map<std::string,T*>::iterator it = _storage.begin(); it != _storage.end(); it++)
|
for(_TypeIter it = _storage.begin(); it != _storage.end(); it++)
|
||||||
{
|
{
|
||||||
if(it->second == ptr)
|
if(it->second == ptr)
|
||||||
{
|
{
|
||||||
@ -71,7 +73,7 @@ template<class T> void TypeStorage<T>::DeleteByPtr(T *ptr)
|
|||||||
// return the the object with that name. return NULL if not found
|
// return the the object with that name. return NULL if not found
|
||||||
template <class T> T *TypeStorage<T>::GetNoCreate(std::string s)
|
template <class T> T *TypeStorage<T>::GetNoCreate(std::string s)
|
||||||
{
|
{
|
||||||
std::map<std::string,T*>::iterator it = _storage.find(s);
|
_TypeIter it = _storage.find(s);
|
||||||
if(it != _storage.end())
|
if(it != _storage.end())
|
||||||
return it->second;
|
return it->second;
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -97,7 +99,7 @@ template<class T> void TypeStorage<T>::Clear(bool keep)
|
|||||||
_storage.clear();
|
_storage.clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for(std::map<std::string,T*>::iterator it = _storage.begin(); it != _storage.end();)
|
for(_TypeIter it = _storage.begin(); it != _storage.end();)
|
||||||
{
|
{
|
||||||
delete it->second;
|
delete it->second;
|
||||||
_storage.erase(it++);
|
_storage.erase(it++);
|
||||||
@ -121,7 +123,7 @@ template<class T> void TypeStorage<T>::Unlink(std::string s)
|
|||||||
// removes the pointer from the storage without deleting it, if name is unknown
|
// removes the pointer from the storage without deleting it, if name is unknown
|
||||||
template<class T> void TypeStorage<T>::UnlinkByPtr(T *ptr)
|
template<class T> void TypeStorage<T>::UnlinkByPtr(T *ptr)
|
||||||
{
|
{
|
||||||
for(std::map<std::string,T*>::iterator it = _storage.begin(); it != _storage.end();)
|
for(_TypeIter it = _storage.begin(); it != _storage.end();)
|
||||||
{
|
{
|
||||||
if(it->second == ptr)
|
if(it->second == ptr)
|
||||||
{
|
{
|
||||||
@ -133,7 +135,7 @@ template<class T> void TypeStorage<T>::UnlinkByPtr(T *ptr)
|
|||||||
|
|
||||||
template<class T> std::string TypeStorage<T>::GetNameByPtr(T *ptr)
|
template<class T> std::string TypeStorage<T>::GetNameByPtr(T *ptr)
|
||||||
{
|
{
|
||||||
for(std::map<std::string,T*>::iterator it = _storage.begin(); it != _storage.end();)
|
for(_TypeIter it = _storage.begin(); it != _storage.end();)
|
||||||
{
|
{
|
||||||
if(it->second == ptr)
|
if(it->second == ptr)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -89,12 +89,10 @@ PseuInstance::~PseuInstance()
|
|||||||
delete _conf;
|
delete _conf;
|
||||||
|
|
||||||
log("--- Instance shut down ---");
|
log("--- Instance shut down ---");
|
||||||
log_close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PseuInstance::Init(void)
|
bool PseuInstance::Init(void)
|
||||||
{
|
{
|
||||||
log_prepare("logfile.txt","a");
|
|
||||||
log_setloglevel(0);
|
log_setloglevel(0);
|
||||||
log("");
|
log("");
|
||||||
log("--- Initializing Instance ---");
|
log("--- Initializing Instance ---");
|
||||||
|
|||||||
@ -495,7 +495,7 @@ void RealmSession::_HandleLogonChallenge(ByteBuffer& pkt)
|
|||||||
|
|
||||||
void RealmSession::_HandleLogonProof(ByteBuffer& pkt)
|
void RealmSession::_HandleLogonProof(ByteBuffer& pkt)
|
||||||
{
|
{
|
||||||
logdebug("RealmSocket: Got AUTH_LOGON_PROOF [%u of %u bytes]\n",pkt.size(),26);
|
logdebug("RealmSocket: Got AUTH_LOGON_PROOF [%u of %u bytes]",pkt.size(),26);
|
||||||
if(pkt.size() < 2)
|
if(pkt.size() < 2)
|
||||||
{
|
{
|
||||||
logerror("AUTH_LOGON_PROOF: Recieved incorrect/unknown packet. Hexdump:");
|
logerror("AUTH_LOGON_PROOF: Recieved incorrect/unknown packet. Hexdump:");
|
||||||
|
|||||||
171
src/Client/World/MovementMgr.cpp
Normal file
171
src/Client/World/MovementMgr.cpp
Normal file
@ -0,0 +1,171 @@
|
|||||||
|
#include "PseuWoW.h"
|
||||||
|
#include "WorldSession.h"
|
||||||
|
#include "World.h"
|
||||||
|
#include "MovementMgr.h"
|
||||||
|
#include "Player.h"
|
||||||
|
|
||||||
|
MovementMgr::MovementMgr()
|
||||||
|
{
|
||||||
|
_moveFlags = 0;
|
||||||
|
_instance = NULL;
|
||||||
|
_optime = 0;
|
||||||
|
_updatetime = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
MovementMgr::~MovementMgr()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void MovementMgr::SetInstance(PseuInstance *inst)
|
||||||
|
{
|
||||||
|
_movemode = MOVEMODE_MANUAL;
|
||||||
|
_instance = inst;
|
||||||
|
_mychar = inst->GetWSession()->GetMyChar();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MovementMgr::_BuildPacket(uint16 opcode)
|
||||||
|
{
|
||||||
|
WorldPacket wp(opcode,4+1+4+12); // it can be larger, if we are juming, on transport or swimming
|
||||||
|
wp << _moveFlags;
|
||||||
|
wp << (uint8)0; // unk
|
||||||
|
wp << getMSTime();
|
||||||
|
wp << _mychar->GetPosition();
|
||||||
|
// TODO: transport not yet handled/done
|
||||||
|
if(_moveFlags & MOVEMENTFLAG_ONTRANSPORT)
|
||||||
|
{
|
||||||
|
wp << (uint64)0; // transport guid
|
||||||
|
wp << WorldPosition(); // transport position
|
||||||
|
wp << getMSTime(); // transport time (??)
|
||||||
|
}
|
||||||
|
// TODO: swimming not yet done
|
||||||
|
if(_moveFlags & MOVEMENTFLAG_SWIMMING)
|
||||||
|
{
|
||||||
|
wp << (float)0; // angle; 1.55=looking up, -1.55=looking down, 0=looking forward
|
||||||
|
}
|
||||||
|
wp << (uint32)0; // last fall time (also used when jumping)
|
||||||
|
// TODO: jumping not yet done
|
||||||
|
// TODO: spline not yet done
|
||||||
|
|
||||||
|
|
||||||
|
_optime = getMSTime();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void MovementMgr::Update(bool calcpos)
|
||||||
|
{
|
||||||
|
uint32 curtime = getMSTime();
|
||||||
|
uint32 timediff = curtime - _updatetime;
|
||||||
|
_updatetime = curtime;
|
||||||
|
|
||||||
|
if(_movemode == MOVEMODE_AUTO)
|
||||||
|
{
|
||||||
|
WorldPosition& pos = _mychar->GetPosition();
|
||||||
|
float turnspeed = _mychar->GetSpeed(MOVE_TURN) / 1000.0f * timediff;
|
||||||
|
float runspeed = _mychar->GetSpeed(MOVE_RUN) / 1000.0f * timediff;
|
||||||
|
float movespeed = runspeed; // or use walkspeed, depending on setting. for now use only runspeed
|
||||||
|
// TODO: calc other speeds as soon as implemented
|
||||||
|
|
||||||
|
/*
|
||||||
|
if(_moveFlags & MOVEMENTFLAG_FORWARD)
|
||||||
|
{
|
||||||
|
pos.x += movespeed * sin(pos.o);
|
||||||
|
pos.y += movespeed * cos(pos.o);
|
||||||
|
}
|
||||||
|
// ...
|
||||||
|
if(_moveFlags & MOVEMENTFLAG_LEFT)
|
||||||
|
{
|
||||||
|
pos.o -= turnspeed;
|
||||||
|
}
|
||||||
|
if(_moveFlags & MOVEMENTFLAG_RIGHT)
|
||||||
|
{
|
||||||
|
pos.o += turnspeed;
|
||||||
|
}
|
||||||
|
if(pos.o < 0)
|
||||||
|
pos.o += 2 * M_PI;
|
||||||
|
else if(pos.o > 2 * M_PI)
|
||||||
|
pos.o -= 2 * M_PI;
|
||||||
|
|
||||||
|
pos.z = _instance->GetWSession()->GetWorld()->GetPosZ(pos.x,pos.y);
|
||||||
|
*/
|
||||||
|
// ^ It should look like this later on, but its not finished, and formulas are not tested.
|
||||||
|
// see it as some future plans that need a lot of finetuning ;)
|
||||||
|
}
|
||||||
|
|
||||||
|
// if we are moving, and 500ms have passed, send an heartbeat packet
|
||||||
|
if( (_moveFlags & MOVEMENTFLAG_ANY_MOVE) && _optime + MOVE_HEARTBEAT_DELAY < getMSTime())
|
||||||
|
{
|
||||||
|
_BuildPacket(MSG_MOVE_HEARTBEAT);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: apply gravity, handle falling, swimming, etc.
|
||||||
|
}
|
||||||
|
|
||||||
|
void MovementMgr::MoveStop(void)
|
||||||
|
{
|
||||||
|
_moveFlags &= ~(MOVEMENTFLAG_ANY_MOVE);
|
||||||
|
Update(false);
|
||||||
|
_BuildPacket(MSG_MOVE_STOP);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MovementMgr::MoveStartForward(void)
|
||||||
|
{
|
||||||
|
_moveFlags |= MOVEMENTFLAG_FORWARD;
|
||||||
|
_moveFlags &= ~MOVEMENTFLAG_BACKWARD;
|
||||||
|
Update(false);
|
||||||
|
_BuildPacket(MSG_MOVE_START_FORWARD);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MovementMgr::MoveStartBackward(void)
|
||||||
|
{
|
||||||
|
_moveFlags |= MOVEMENTFLAG_BACKWARD;
|
||||||
|
_moveFlags &= ~MOVEMENTFLAG_FORWARD;
|
||||||
|
Update(false);
|
||||||
|
_BuildPacket(MSG_MOVE_START_BACKWARD);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MovementMgr::MoveStartStrafeLeft(void)
|
||||||
|
{
|
||||||
|
_moveFlags |= MOVEMENTFLAG_STRAFE_LEFT;
|
||||||
|
_moveFlags &= ~MOVEMENTFLAG_STRAFE_RIGHT;
|
||||||
|
Update(false);
|
||||||
|
_BuildPacket(MSG_MOVE_START_STRAFE_LEFT);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MovementMgr::MoveStartStrafeRight(void)
|
||||||
|
{
|
||||||
|
_moveFlags |= MOVEMENTFLAG_STRAFE_RIGHT;
|
||||||
|
_moveFlags &= ~MOVEMENTFLAG_STRAFE_LEFT;
|
||||||
|
Update(false);
|
||||||
|
_BuildPacket(MSG_MOVE_START_STRAFE_RIGHT);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MovementMgr::MoveStartTurnLeft(void)
|
||||||
|
{
|
||||||
|
_moveFlags |= MOVEMENTFLAG_LEFT;
|
||||||
|
_moveFlags &= ~MOVEMENTFLAG_RIGHT;
|
||||||
|
Update(false);
|
||||||
|
_BuildPacket(MSG_MOVE_START_TURN_LEFT);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MovementMgr::MoveStartTurnRight(void)
|
||||||
|
{
|
||||||
|
_moveFlags |= MOVEMENTFLAG_RIGHT;
|
||||||
|
_moveFlags &= ~MOVEMENTFLAG_LEFT;
|
||||||
|
Update(false);
|
||||||
|
_BuildPacket(MSG_MOVE_START_TURN_RIGHT);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MovementMgr::MoveStopTurn(void)
|
||||||
|
{
|
||||||
|
_moveFlags &= ~(MOVEMENTFLAG_LEFT | MOVEMENTFLAG_RIGHT);
|
||||||
|
Update(false);
|
||||||
|
_BuildPacket(MSG_MOVE_STOP_TURN);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MovementMgr::MoveSetFacing(float o)
|
||||||
|
{
|
||||||
|
_mychar->SetPosition(_mychar->GetX(), _mychar->GetY(), _mychar->GetZ(), o);
|
||||||
|
Update(true);
|
||||||
|
_BuildPacket(MSG_MOVE_SET_FACING);
|
||||||
|
}
|
||||||
|
|
||||||
85
src/Client/World/MovementMgr.h
Normal file
85
src/Client/World/MovementMgr.h
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
#ifndef MOVEMENTMGR_H
|
||||||
|
#define MOVEMENTMGR_H
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
|
#define MOVE_HEARTBEAT_DELAY 500
|
||||||
|
|
||||||
|
enum MovementFlags
|
||||||
|
{
|
||||||
|
MOVEMENTFLAG_NONE = 0x00000000,
|
||||||
|
MOVEMENTFLAG_FORWARD = 0x00000001,
|
||||||
|
MOVEMENTFLAG_BACKWARD = 0x00000002,
|
||||||
|
MOVEMENTFLAG_STRAFE_LEFT = 0x00000004,
|
||||||
|
MOVEMENTFLAG_STRAFE_RIGHT = 0x00000008,
|
||||||
|
MOVEMENTFLAG_LEFT = 0x00000010,
|
||||||
|
MOVEMENTFLAG_RIGHT = 0x00000020,
|
||||||
|
MOVEMENTFLAG_PITCH_UP = 0x00000040,
|
||||||
|
MOVEMENTFLAG_PITCH_DOWN = 0x00000080,
|
||||||
|
MOVEMENTFLAG_WALK = 0x00000100,
|
||||||
|
MOVEMENTFLAG_ONTRANSPORT = 0x00000200,
|
||||||
|
MOVEMENTFLAG_UNK1 = 0x00000400,
|
||||||
|
MOVEMENTFLAG_FLY_UNK1 = 0x00000800,
|
||||||
|
MOVEMENTFLAG_JUMPING = 0x00001000,
|
||||||
|
MOVEMENTFLAG_UNK4 = 0x00002000,
|
||||||
|
MOVEMENTFLAG_FALLING = 0x00004000,
|
||||||
|
// 0x8000, 0x10000, 0x20000, 0x40000, 0x80000, 0x100000
|
||||||
|
MOVEMENTFLAG_SWIMMING = 0x00200000, // appears with fly flag also
|
||||||
|
MOVEMENTFLAG_FLY_UP = 0x00400000,
|
||||||
|
MOVEMENTFLAG_CAN_FLY = 0x00800000,
|
||||||
|
MOVEMENTFLAG_FLYING = 0x01000000,
|
||||||
|
MOVEMENTFLAG_UNK5 = 0x02000000,
|
||||||
|
MOVEMENTFLAG_SPLINE = 0x04000000, // probably wrong name
|
||||||
|
MOVEMENTFLAG_SPLINE2 = 0x08000000,
|
||||||
|
MOVEMENTFLAG_WATERWALKING = 0x10000000,
|
||||||
|
MOVEMENTFLAG_SAFE_FALL = 0x20000000, // active rogue safe fall spell (passive)
|
||||||
|
MOVEMENTFLAG_UNK3 = 0x40000000,
|
||||||
|
|
||||||
|
// custom flags
|
||||||
|
MOVEMENTFLAG_ANY_MOVE = (MOVEMENTFLAG_BACKWARD | MOVEMENTFLAG_FORWARD | MOVEMENTFLAG_STRAFE_LEFT | MOVEMENTFLAG_STRAFE_RIGHT
|
||||||
|
| MOVEMENTFLAG_LEFT | MOVEMENTFLAG_RIGHT)
|
||||||
|
};
|
||||||
|
|
||||||
|
enum MoveModes
|
||||||
|
{
|
||||||
|
MOVEMODE_AUTO, // CPU controlling movement, MyCharacter must be updated
|
||||||
|
MOVEMODE_MANUAL, // user controlling movement, MyCharacter is updated by the GUI already
|
||||||
|
};
|
||||||
|
|
||||||
|
class PseuInstance;
|
||||||
|
class MyCharacter;
|
||||||
|
|
||||||
|
|
||||||
|
class MovementMgr
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MovementMgr();
|
||||||
|
~MovementMgr();
|
||||||
|
void SetInstance(PseuInstance*);
|
||||||
|
inline void SetMoveMode(uint8 mode) { _movemode = mode; }
|
||||||
|
void Update(bool);
|
||||||
|
void MoveStartForward(void);
|
||||||
|
void MoveStartBackward(void);
|
||||||
|
void MoveStop(void);
|
||||||
|
void MoveStartStrafeLeft(void);
|
||||||
|
void MoveStartStrafeRight(void);
|
||||||
|
void MoveStartTurnLeft(void);
|
||||||
|
void MoveStartTurnRight(void);
|
||||||
|
void MoveStopTurn(void);
|
||||||
|
void MoveFallLand(void);
|
||||||
|
void MoveSetFacing(float);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void _BuildPacket(uint16);
|
||||||
|
PseuInstance *_instance;
|
||||||
|
MyCharacter *_mychar;
|
||||||
|
uint32 _moveFlags; // server relevant flags (move forward/backward/swim/fly/jump/etc)
|
||||||
|
uint32 _updatetime; // timeMS of last update cycle
|
||||||
|
uint32 _optime; // timeMS when last opcode was sent
|
||||||
|
uint8 _movemode; // automatic or manual
|
||||||
|
UnitMoveType _movetype; // index used for speed selection
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -13,6 +13,17 @@ struct WorldPosition
|
|||||||
float x,y,z,o;
|
float x,y,z,o;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline ByteBuffer& operator<<(ByteBuffer& bb, WorldPosition& p)
|
||||||
|
{
|
||||||
|
bb << p.x << p.y << p.z << p.o;
|
||||||
|
return bb;
|
||||||
|
}
|
||||||
|
inline ByteBuffer& operator>>(ByteBuffer& bb, WorldPosition& p)
|
||||||
|
{
|
||||||
|
bb >> p.x >> p.y >> p.z >> p.o;
|
||||||
|
return bb;
|
||||||
|
}
|
||||||
|
|
||||||
// used as interface for movement, map data,
|
// used as interface for movement, map data,
|
||||||
class World
|
class World
|
||||||
{
|
{
|
||||||
|
|||||||
@ -459,7 +459,7 @@ void WorldSession::_HandleCharEnumOpcode(WorldPacket& recvPacket)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
logdetail("Chars in list: %u\n",num);
|
logdetail("Chars in list: %u",num);
|
||||||
_LoadCache(); // we are about to login, so we need cache data
|
_LoadCache(); // we are about to login, so we need cache data
|
||||||
for(unsigned int i=0;i<num;i++)
|
for(unsigned int i=0;i<num;i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -81,12 +81,14 @@ int main(int argc, char* argv[]) {
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
set_new_handler(_new_handler);
|
set_new_handler(_new_handler);
|
||||||
_log_setcolor(true,LGREEN);
|
log_prepare("logfile.txt","a");
|
||||||
printf("+----------------------------------+\n"
|
logcustom(0,LGREEN,"+----------------------------------+");
|
||||||
"| (C) 2006,2007 Snowstorm Software |\n"
|
logcustom(0,LGREEN,"| (C) 2006-2008 Snowstorm Software |");
|
||||||
"| http://www.mangosclient.org |\n"
|
logcustom(0,LGREEN,"| http://www.mangosclient.org |");
|
||||||
"+----------------------------------+\n");
|
logcustom(0,LGREEN,"+----------------------------------+");
|
||||||
_log_resetcolor(true);
|
logcustom(0,GREEN,"Platform: %s",PLATFORM_NAME);
|
||||||
|
logcustom(0,GREEN,"Compiler: %s ("COMPILER_VERSION_OUT")",COMPILER_NAME,COMPILER_VERSION);
|
||||||
|
logcustom(0,GREEN,"Compiled: %s %s",__DATE__,__TIME__);
|
||||||
|
|
||||||
_HookSignals();
|
_HookSignals();
|
||||||
|
|
||||||
@ -98,6 +100,7 @@ int main(int argc, char* argv[]) {
|
|||||||
//...
|
//...
|
||||||
t.wait();
|
t.wait();
|
||||||
//...
|
//...
|
||||||
|
log_close();
|
||||||
_UnhookSignals();
|
_UnhookSignals();
|
||||||
raise(SIGABRT); // this way to terminate is not nice but the only way to quit the CLI thread
|
raise(SIGABRT); // this way to terminate is not nice but the only way to quit the CLI thread
|
||||||
raise(SIGQUIT);
|
raise(SIGQUIT);
|
||||||
|
|||||||
@ -309,6 +309,12 @@
|
|||||||
<File
|
<File
|
||||||
RelativePath=".\Client\World\Item.h">
|
RelativePath=".\Client\World\Item.h">
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\Client\World\MovementMgr.cpp">
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\Client\World\MovementMgr.h">
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\Client\World\Object.cpp">
|
RelativePath=".\Client\World\Object.cpp">
|
||||||
</File>
|
</File>
|
||||||
|
|||||||
@ -417,6 +417,14 @@
|
|||||||
RelativePath=".\Client\World\Item.h"
|
RelativePath=".\Client\World\Item.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\Client\World\MovementMgr.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\Client\World\MovementMgr.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\Client\World\Object.cpp"
|
RelativePath=".\Client\World\Object.cpp"
|
||||||
>
|
>
|
||||||
|
|||||||
@ -153,6 +153,9 @@
|
|||||||
<File
|
<File
|
||||||
RelativePath=".\shared\tools.h">
|
RelativePath=".\shared\tools.h">
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\shared\Widen.h">
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\shared\ZCompressor.cpp">
|
RelativePath=".\shared\ZCompressor.cpp">
|
||||||
</File>
|
</File>
|
||||||
|
|||||||
@ -22,6 +22,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
class ByteBufferException
|
class ByteBufferException
|
||||||
{
|
{
|
||||||
|
|||||||
@ -71,21 +71,70 @@
|
|||||||
#define I64FMT "%016llX"
|
#define I64FMT "%016llX"
|
||||||
#define I64FMTD "%llu"
|
#define I64FMTD "%llu"
|
||||||
#define SI64FMTD "%lld"
|
#define SI64FMTD "%lld"
|
||||||
typedef __int64_t int64;
|
# if PLATFORM == PLATFORM_UNIX
|
||||||
typedef __int32_t int32;
|
typedef __int64_t int64;
|
||||||
typedef __int16_t int16;
|
typedef __int32_t int32;
|
||||||
typedef __int8_t int8;
|
typedef __int16_t int16;
|
||||||
typedef __uint64_t uint64;
|
typedef __int8_t int8;
|
||||||
typedef __uint32_t uint32;
|
typedef __uint64_t uint64;
|
||||||
typedef __uint16_t uint16;
|
typedef __uint32_t uint32;
|
||||||
typedef __uint8_t uint8;
|
typedef __uint16_t uint16;
|
||||||
typedef uint16 WORD;
|
typedef __uint8_t uint8;
|
||||||
typedef uint32 DWORD;
|
typedef uint16 WORD;
|
||||||
|
typedef uint32 DWORD;
|
||||||
|
# else
|
||||||
|
typedef long long int64;
|
||||||
|
typedef long int32;
|
||||||
|
typedef short int16;
|
||||||
|
typedef char int8;
|
||||||
|
typedef unsigned long long uint64;
|
||||||
|
typedef unsigned long uint32;
|
||||||
|
typedef unsigned short uint16;
|
||||||
|
typedef unsigned char uint8;
|
||||||
|
typedef unsigned short WORD;
|
||||||
|
typedef uint32 DWORD;
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SIGQUIT
|
#ifndef SIGQUIT
|
||||||
#define SIGQUIT 3
|
#define SIGQUIT 3
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if COMPILER == COMPILER_MICROSOFT
|
||||||
|
# if _MSC_VER >= 1500
|
||||||
|
# define COMPILER_NAME "VC90"
|
||||||
|
# elif _MSC_VER >= 1400
|
||||||
|
# define COMPILER_NAME "VC80"
|
||||||
|
# elif _MSC_VER >= 1310
|
||||||
|
# define COMPILER_NAME "VC71"
|
||||||
|
# endif
|
||||||
|
# define COMPILER_VERSION _MSC_VER
|
||||||
|
# define COMPILER_VERSION_OUT "%u"
|
||||||
|
#elif COMPILER == COMPILER_GNU
|
||||||
|
# define COMPILER_NAME "GCC"
|
||||||
|
# ifdef __GNUC_PATCHLEVEL__
|
||||||
|
# define COMPILER_VERSION STRINGIZE(__GNUC__) "." STRINGIZE(__GNUC_MINOR__) "." STRINGIZE(__GNUC_PATCHLEVEL__)
|
||||||
|
# else
|
||||||
|
# define COMPILER_VERSION STRINGIZE(__GNUC__) "." STRINGIZE(__GNUC_MINOR__)
|
||||||
|
# endif
|
||||||
|
# define COMPILER_VERSION_OUT "%s"
|
||||||
|
// TODO: add more compilers here when necessary
|
||||||
|
#else
|
||||||
|
# define COMPILER_NAME "unknown"
|
||||||
|
# define COMPILER_VERSION "unk"
|
||||||
|
# define COMPILER_VERSION_OUT "%s"
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#if PLATFORM == PLATFORM_UNIX
|
||||||
|
# define PLATFORM_NAME "Unix"
|
||||||
|
#elif PLATFORM == PLATFORM_WIN32
|
||||||
|
# define PLATFORM_NAME "Win32"
|
||||||
|
#elif PLATFORM == PLATFORM_APPLE
|
||||||
|
# define PLATFORM_NAME "Apple"
|
||||||
|
// TODO: add more platforms here when necessary
|
||||||
|
#else
|
||||||
|
# define PLATFORM_NAME "unknown"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
45
src/shared/Widen.h
Normal file
45
src/shared/Widen.h
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
#ifndef _WIDEN_H
|
||||||
|
#define _WIDEN_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <locale>
|
||||||
|
#include <functional>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
// Put this class in your personal toolbox...
|
||||||
|
template<class E,
|
||||||
|
class T = std::char_traits<E>,
|
||||||
|
class A = std::allocator<E> >
|
||||||
|
|
||||||
|
class Widen : public std::unary_function<
|
||||||
|
const std::string&, std::basic_string<E, T, A> >
|
||||||
|
{
|
||||||
|
std::locale loc_;
|
||||||
|
const std::ctype<E>* pCType_;
|
||||||
|
|
||||||
|
// No copy-constructor, no assignment operator...
|
||||||
|
Widen(const Widen&);
|
||||||
|
Widen& operator= (const Widen&);
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Constructor...
|
||||||
|
Widen(const std::locale& loc = std::locale()) : loc_(loc)
|
||||||
|
{
|
||||||
|
pCType_ = &std::use_facet<std::ctype<E> >(loc);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Conversion...
|
||||||
|
std::basic_string<E, T, A> operator() (const std::string& str) const
|
||||||
|
{
|
||||||
|
typename std::basic_string<E, T, A>::size_type srcLen =
|
||||||
|
str.length();
|
||||||
|
const char* pSrcBeg = str.c_str();
|
||||||
|
std::vector<E> tmp(srcLen);
|
||||||
|
|
||||||
|
pCType_->widen(pSrcBeg, pSrcBeg + srcLen, &tmp[0]);
|
||||||
|
return std::basic_string<E, T, A>(&tmp[0], srcLen);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -23,8 +23,11 @@
|
|||||||
# include "zthread/Thread.h"
|
# include "zthread/Thread.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define STRINGIZE(a) #a
|
||||||
|
|
||||||
#include "SysDefs.h"
|
#include "SysDefs.h"
|
||||||
#include "DebugStuff.h"
|
#include "DebugStuff.h"
|
||||||
|
#include "Widen.h"
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
|
|||||||
@ -14,6 +14,11 @@ void log_prepare(char *fn, char *mode = NULL)
|
|||||||
{
|
{
|
||||||
if(!mode)
|
if(!mode)
|
||||||
mode = "a";
|
mode = "a";
|
||||||
|
if(logfile)
|
||||||
|
{
|
||||||
|
fflush(logfile);
|
||||||
|
fclose(logfile);
|
||||||
|
}
|
||||||
logfile = fopen(fn,mode);
|
logfile = fopen(fn,mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user