* fixed server crash when pseuwow was teleported around
* added now required 'winmm.lib' to shared.vcproj * fixed memory leak with multiply created objects, where already existing objects didnt get deleted. * forgot to autodelete RealmSession on socket fail
This commit is contained in:
parent
cd99d323e9
commit
ec812a9b0f
@ -137,9 +137,14 @@ void RealmSession::Update(void)
|
||||
ByteBuffer *pkt;
|
||||
uint8 cmd;
|
||||
|
||||
if( _sh.GetCount() )
|
||||
{
|
||||
if( _sh.GetCount() ) // the socket will remove itself from the handler if it got closed
|
||||
_sh.Select(0,0);
|
||||
else // so we just need to check if the socket doesnt exist or if it exists but isnt valid anymore.
|
||||
{ // if thats the case, we dont need the session anymore either
|
||||
if(!_socket || (_socket && !_socket->IsOk()))
|
||||
{
|
||||
SetMustDie();
|
||||
}
|
||||
}
|
||||
|
||||
while(pktQueue.size())
|
||||
|
||||
@ -204,6 +204,7 @@ public:
|
||||
void SetActionButtons(WorldPacket &data);
|
||||
void AddSpell(uint32 spellid, uint16 spellslot);
|
||||
void RemoveSpell(uint32 spellid);
|
||||
void ClearSpells(void) { _spells.clear(); }
|
||||
uint64 GetTarget(void) { return _target; }
|
||||
void SetTarget(uint64 guid) { _target = guid; } // should only be called by WorldSession::SendSetSelection() !!
|
||||
bool HasSpell(uint32 spellid) { return GetSpellSlot(spellid) != 0; }
|
||||
|
||||
@ -71,6 +71,13 @@ void WorldSession::_HandleUpdateObjectOpcode(WorldPacket& recvPacket)
|
||||
uint8 objtypeid;
|
||||
recvPacket >> objtypeid;
|
||||
logdebug("Create Object type %u with guid "I64FMT,objtypeid,uguid);
|
||||
// dont create objects if already present in memory.
|
||||
// recreate every object except ourself!
|
||||
if( uguid != GetGuid() && objmgr.GetObj(uguid))
|
||||
{
|
||||
logdev("- already exists, deleting old , creating new object");
|
||||
objmgr.Remove(uguid);
|
||||
}
|
||||
|
||||
switch(objtypeid)
|
||||
{
|
||||
|
||||
@ -93,12 +93,15 @@ void WorldSession::SendWorldPacket(WorldPacket &pkt)
|
||||
|
||||
void WorldSession::Update(void)
|
||||
{
|
||||
if( _sh.GetCount() ) // the socketwil remove itself from the handler if it got closed
|
||||
if( _sh.GetCount() ) // the socket will remove itself from the handler if it got closed
|
||||
_sh.Select(0,0);
|
||||
else // so we just need to check if the socket doesnt exist or if it exists but isnt valid anymore.
|
||||
{ // if thats the case, we dont need the session anymore either
|
||||
if(!_socket || (_socket && !_socket->IsOk()))
|
||||
{
|
||||
_OnLeaveWorld();
|
||||
SetMustDie();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -202,6 +205,7 @@ OpcodeHandler *WorldSession::_GetOpcodeHandlerTable() const
|
||||
{SMSG_CHANNEL_LIST, &WorldSession::_HandleChannelListOpcode},
|
||||
{SMSG_EMOTE, &WorldSession::_HandleEmoteOpcode},
|
||||
{SMSG_TEXT_EMOTE, &WorldSession::_HandleTextEmoteOpcode},
|
||||
{SMSG_NEW_WORLD, &WorldSession::_HandleNewWorldOpcode},
|
||||
|
||||
// table termination
|
||||
{ 0, NULL }
|
||||
@ -624,23 +628,36 @@ void WorldSession::_HandleMovementOpcode(WorldPacket& recvPacket)
|
||||
|
||||
void WorldSession::_HandleTelePortAckOpcode(WorldPacket& recvPacket)
|
||||
{
|
||||
uint8 unk;
|
||||
uint16 unk1, unk2;
|
||||
uint32 unk3, unk4;
|
||||
uint32 unk32,time;
|
||||
uint64 guid;
|
||||
|
||||
float x, y, z, o, ang;
|
||||
float x, y, z, o;
|
||||
|
||||
recvPacket >> unk >> guid >> unk3 >> unk1 >> unk2 >> o >> x >> y >> z >> ang >> unk4;
|
||||
guid = recvPacket.GetPackedGuid();
|
||||
recvPacket >> unk32 >> unk32 >> time >> x >> y >> z >> o >> unk32;
|
||||
|
||||
logdetail("Got teleported, data: x: %f, y: %f, z: %f, o: %f, guid: "I64FMT, x, y, z, o, guid);
|
||||
|
||||
// TODO: put this into a capsule class later, that autodetects movement flags etc.
|
||||
WorldPacket response;
|
||||
response.SetOpcode(MSG_MOVE_FALL_LAND);
|
||||
response << uint32(0) << uint32(0) << x << y << z << o << uint32(0);
|
||||
response << uint32(0) << (uint32)getMSTime(); // no flags; time correct?
|
||||
response << x << y << z << o << uint32(0);
|
||||
SendWorldPacket(response);
|
||||
}
|
||||
|
||||
void WorldSession::_HandleNewWorldOpcode(WorldPacket& recvPacket)
|
||||
{
|
||||
uint32 mapid;
|
||||
float x,y,z,o;
|
||||
// we assume we are NOT on a transport!
|
||||
// else we had to do the following before:
|
||||
// recvPacket >> tmapid >> tx >> ty >> tz >> to;
|
||||
recvPacket >> mapid >> x >> y >> z >> o;
|
||||
GetMyChar()->ClearSpells(); // will be resent by server
|
||||
// clear action buttons
|
||||
}
|
||||
|
||||
void WorldSession::_HandleChannelNotifyOpcode(WorldPacket& recvPacket)
|
||||
{
|
||||
_channels->HandleNotifyOpcode(recvPacket);
|
||||
|
||||
@ -87,6 +87,7 @@ private:
|
||||
void _HandleChannelListOpcode(WorldPacket& recvPacket);
|
||||
void _HandleEmoteOpcode(WorldPacket& recvPacket);
|
||||
void _HandleTextEmoteOpcode(WorldPacket& recvPacket);
|
||||
void _HandleNewWorldOpcode(WorldPacket& recvPacket);
|
||||
|
||||
void _MovementUpdate(uint8 objtypeid, uint64 guid, WorldPacket& recvPacket); // Helper for _HandleUpdateObjectOpcode
|
||||
void _ValuesUpdate(uint64 uguid, WorldPacket& recvPacket); // ...
|
||||
|
||||
@ -38,7 +38,8 @@
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"/>
|
||||
Name="VCLibrarianTool"
|
||||
AdditionalDependencies="winmm.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Debug/PseuWoW_Controller.tlb"
|
||||
|
||||
@ -2,18 +2,25 @@
|
||||
#include <cctype>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <time.h>
|
||||
#include <fstream>
|
||||
#include <errno.h>
|
||||
#include "tools.h"
|
||||
|
||||
#ifndef _WIN32
|
||||
# include <sys/dir.h>
|
||||
# include <errno.h>
|
||||
#else
|
||||
#if PLATFORM == PLATFORM_WIN32
|
||||
# include <windows.h>
|
||||
# include <mmsystem.h>
|
||||
# include <time.h>
|
||||
#else
|
||||
# include <sys/dir.h>
|
||||
# if defined(__FreeBSD__) || defined(__APPLE_CC__)
|
||||
# include <time.h>
|
||||
# endif
|
||||
# include <sys/timeb.h>
|
||||
#endif
|
||||
|
||||
void printchex(std::string in, bool spaces=true){
|
||||
|
||||
void printchex(std::string in, bool spaces=true)
|
||||
{
|
||||
unsigned int len=0,i;
|
||||
len=in.length();
|
||||
printf("[");
|
||||
@ -24,7 +31,8 @@ void printchex(std::string in, bool spaces=true){
|
||||
printf("]\n");
|
||||
}
|
||||
|
||||
void printchex(char *in, uint32 len, bool spaces=true){
|
||||
void printchex(char *in, uint32 len, bool spaces=true)
|
||||
{
|
||||
unsigned int i;
|
||||
printf("[");
|
||||
if(spaces)
|
||||
@ -147,6 +155,7 @@ bool FileExists(std::string fn)
|
||||
return false;
|
||||
}
|
||||
|
||||
// must return true if creating the directory was successful
|
||||
bool CreateDir(const char *dir)
|
||||
{
|
||||
bool result;
|
||||
@ -160,4 +169,20 @@ bool CreateDir(const char *dir)
|
||||
return result;
|
||||
}
|
||||
|
||||
// current system time in ms
|
||||
uint32 getMSTime(void)
|
||||
{
|
||||
uint32 time_in_ms = 0;
|
||||
#if PLATFORM == PLATFORM_WIN32
|
||||
time_in_ms = timeGetTime();
|
||||
#else
|
||||
struct timeb tp;
|
||||
ftime(&tp);
|
||||
|
||||
time_in_ms = tp.time * 1000 + tp.millitm;
|
||||
#endif
|
||||
|
||||
return time_in_ms;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -18,5 +18,6 @@ std::string toHexDump(uint8* array,uint32 size,bool spaces=true);
|
||||
std::deque<std::string> GetFileList(std::string);
|
||||
bool FileExists(std::string);
|
||||
bool CreateDir(const char*);
|
||||
uint32 getMSTime(void);
|
||||
|
||||
#endif
|
||||
Loading…
x
Reference in New Issue
Block a user