fixed some crashes (with vc80)

This commit is contained in:
Necroalbert 2007-03-05 20:30:53 +00:00
parent 7aaac21eca
commit 10e6b70c4d
4 changed files with 161 additions and 161 deletions

View File

@ -30,7 +30,7 @@ class ByteBuffer
{
};
const static size_t DEFAULT_SIZE = 0x1000;
const static size_t DEFAULT_SIZE = 0xFF;
ByteBuffer(): _rpos(0), _wpos(0)
{

View File

@ -8,11 +8,11 @@
enum AuthCmd
{
AUTH_LOGON_CHALLENGE = 0x00,
AUTH_LOGON_PROOF = 0x01,
REALM_LIST = 0x10,
enum AuthCmd
{
AUTH_LOGON_CHALLENGE = 0x00,
AUTH_LOGON_PROOF = 0x01,
REALM_LIST = 0x10,
};
struct SRealmHeader
@ -41,26 +41,26 @@ struct AuthHandler
void (RealmSocket::*handler)(void);
};
struct sAuthLogonChallenge_S
{
uint8 cmd;
uint8 error;
uint8 unk2;
uint8 B[32];
uint8 g_len;
uint8 g[1];
uint8 N_len;
uint8 N[32];
uint8 salt[32];
uint8 unk3[16];
struct sAuthLogonChallenge_S
{
uint8 cmd;
uint8 error;
uint8 unk2;
uint8 B[32];
uint8 g_len;
uint8 g[1];
uint8 N_len;
uint8 N[32];
uint8 salt[32];
uint8 unk3[16];
};
struct sAuthLogonProof_S
{
uint8 cmd;
uint8 error;
uint8 M2[20];
uint32 unk2;
struct sAuthLogonProof_S
{
uint8 cmd;
uint8 error;
uint8 M2[20];
uint32 unk2;
};
const AuthHandler table[]=
@ -126,7 +126,7 @@ void RealmSocket::_HandleRealmList(void)
{
std::string realmAddr;
ByteBuffer realmbuf;
realmbuf.reserve(ibuf.GetLength());
realmbuf.resize(ibuf.GetLength());
ibuf.Read((char*)realmbuf.contents(), ibuf.GetLength());
uint32 unk;

View File

@ -33,10 +33,10 @@ WorldSession::~WorldSession()
{
WorldPacket *packet;
// clear the queue
while(!pktQueue.empty())
{
packet = pktQueue.next();
delete packet;
while(!pktQueue.empty())
{
packet = pktQueue.next();
delete packet;
}
_OnLeaveWorld();
@ -102,8 +102,8 @@ void WorldSession::Update(void)
{
WorldPacket *packet = pktQueue.next();
for (uint16 i = 0; table[i].handler != NULL; i++)
{
for (uint16 i = 0; table[i].handler != NULL; i++)
{
if (table[i].opcode == packet->GetOpcode())
{
try
@ -145,11 +145,11 @@ void WorldSession::Update(void)
}
OpcodeHandler *WorldSession::_GetOpcodeHandlerTable() const
{
static OpcodeHandler table[] =
{
{ SMSG_AUTH_CHALLENGE, &WorldSession::_HandleAuthChallengeOpcode },
OpcodeHandler *WorldSession::_GetOpcodeHandlerTable() const
{
static OpcodeHandler table[] =
{
{ SMSG_AUTH_CHALLENGE, &WorldSession::_HandleAuthChallengeOpcode },
{ SMSG_AUTH_RESPONSE, &WorldSession::_HandleAuthResponseOpcode },
{SMSG_CHAR_ENUM, &WorldSession::_HandleCharEnumOpcode},
{SMSG_SET_PROFICIENCY, &WorldSession::_HandleSetProficiencyOpcode},
@ -158,91 +158,91 @@ OpcodeHandler *WorldSession::_GetOpcodeHandlerTable() const
{SMSG_NAME_QUERY_RESPONSE, &WorldSession::_HandleNameQueryResponseOpcode},
{SMSG_PONG, &WorldSession::_HandlePongOpcode},
{SMSG_TRADE_STATUS, &WorldSession::_HandleTradeStatusOpcode},
{SMSG_GROUP_INVITE, &WorldSession::_HandleGroupInviteOpcode},
{SMSG_CHANNEL_NOTIFY, &WorldSession::_HandleChannelNotifyOpcode},
// movement opcodes
{MSG_MOVE_SET_FACING, &WorldSession::_HandleMovementOpcode},
{MSG_MOVE_START_FORWARD, &WorldSession::_HandleMovementOpcode},
{MSG_MOVE_START_BACKWARD, &WorldSession::_HandleMovementOpcode},
{MSG_MOVE_STOP, &WorldSession::_HandleMovementOpcode},
{MSG_MOVE_START_STRAFE_LEFT, &WorldSession::_HandleMovementOpcode},
{MSG_MOVE_START_STRAFE_RIGHT, &WorldSession::_HandleMovementOpcode},
{MSG_MOVE_STOP_STRAFE, &WorldSession::_HandleMovementOpcode},
{MSG_MOVE_JUMP, &WorldSession::_HandleMovementOpcode},
{MSG_MOVE_START_TURN_LEFT, &WorldSession::_HandleMovementOpcode},
{MSG_MOVE_START_TURN_RIGHT, &WorldSession::_HandleMovementOpcode},
{MSG_MOVE_STOP_TURN, &WorldSession::_HandleMovementOpcode},
{MSG_MOVE_START_SWIM, &WorldSession::_HandleMovementOpcode},
{MSG_MOVE_STOP_SWIM, &WorldSession::_HandleMovementOpcode},
{MSG_MOVE_HEARTBEAT, &WorldSession::_HandleMovementOpcode},
{MSG_MOVE_FALL_LAND, &WorldSession::_HandleMovementOpcode},
{MSG_MOVE_TELEPORT_ACK, &WorldSession::_HandleTelePortAckOpcode},
{SMSG_COMPRESSED_UPDATE_OBJECT, &WorldSession::_HandleCompressedUpdateObjectOpcode},
{SMSG_UPDATE_OBJECT, &WorldSession::_HandleUpdateObjectOpcode},
{SMSG_CAST_RESULT, &WorldSession::_HandleCastResultOpcode},
{SMSG_ITEM_QUERY_SINGLE_RESPONSE, &WorldSession::_HandleItemQuerySingleResponseOpcode},
{SMSG_DESTROY_OBJECT, &WorldSession::_HandleDestroyObjectOpcode},
{SMSG_INITIAL_SPELLS, &WorldSession::_HandleInitialSpellsOpcode},
// table termination
{ 0, NULL }
};
return table;
}
void WorldSession::SetTarget(uint64 guid)
{
_targetGUID=guid;
// TODO: update the UpdateFields once implemented
}
void WorldSession::SetFollowTarget(uint64 guid)
{
_followGUID=guid;
}
void WorldSession::_OnEnterWorld(void)
{
{SMSG_GROUP_INVITE, &WorldSession::_HandleGroupInviteOpcode},
{SMSG_CHANNEL_NOTIFY, &WorldSession::_HandleChannelNotifyOpcode},
// movement opcodes
{MSG_MOVE_SET_FACING, &WorldSession::_HandleMovementOpcode},
{MSG_MOVE_START_FORWARD, &WorldSession::_HandleMovementOpcode},
{MSG_MOVE_START_BACKWARD, &WorldSession::_HandleMovementOpcode},
{MSG_MOVE_STOP, &WorldSession::_HandleMovementOpcode},
{MSG_MOVE_START_STRAFE_LEFT, &WorldSession::_HandleMovementOpcode},
{MSG_MOVE_START_STRAFE_RIGHT, &WorldSession::_HandleMovementOpcode},
{MSG_MOVE_STOP_STRAFE, &WorldSession::_HandleMovementOpcode},
{MSG_MOVE_JUMP, &WorldSession::_HandleMovementOpcode},
{MSG_MOVE_START_TURN_LEFT, &WorldSession::_HandleMovementOpcode},
{MSG_MOVE_START_TURN_RIGHT, &WorldSession::_HandleMovementOpcode},
{MSG_MOVE_STOP_TURN, &WorldSession::_HandleMovementOpcode},
{MSG_MOVE_START_SWIM, &WorldSession::_HandleMovementOpcode},
{MSG_MOVE_STOP_SWIM, &WorldSession::_HandleMovementOpcode},
{MSG_MOVE_HEARTBEAT, &WorldSession::_HandleMovementOpcode},
{MSG_MOVE_FALL_LAND, &WorldSession::_HandleMovementOpcode},
{MSG_MOVE_TELEPORT_ACK, &WorldSession::_HandleTelePortAckOpcode},
{SMSG_COMPRESSED_UPDATE_OBJECT, &WorldSession::_HandleCompressedUpdateObjectOpcode},
{SMSG_UPDATE_OBJECT, &WorldSession::_HandleUpdateObjectOpcode},
{SMSG_CAST_RESULT, &WorldSession::_HandleCastResultOpcode},
{SMSG_ITEM_QUERY_SINGLE_RESPONSE, &WorldSession::_HandleItemQuerySingleResponseOpcode},
{SMSG_DESTROY_OBJECT, &WorldSession::_HandleDestroyObjectOpcode},
{SMSG_INITIAL_SPELLS, &WorldSession::_HandleInitialSpellsOpcode},
// table termination
{ 0, NULL }
};
return table;
}
void WorldSession::SetTarget(uint64 guid)
{
_targetGUID=guid;
// TODO: update the UpdateFields once implemented
}
void WorldSession::SetFollowTarget(uint64 guid)
{
_followGUID=guid;
}
void WorldSession::_OnEnterWorld(void)
{
if(!_logged)
{
_logged=true;
GetInstance()->GetScripts()->RunScript("_enterworld",NULL);
}
}
void WorldSession::_OnLeaveWorld(void)
{
if(_logged)
{
_logged=false;
GetInstance()->GetScripts()->RunScript("_leaveworld",NULL);
}
}
void WorldSession::_DoTimedActions(void)
{
static clock_t pingtime=0;
if(_logged)
{
if(pingtime < clock())
{
pingtime=clock() + 30*CLOCKS_PER_SEC;
SendPing(clock());
}
//...
}
}
///////////////////////////////////////////////////////////////
// Opcode Handlers
///////////////////////////////////////////////////////////////
}
}
void WorldSession::_OnLeaveWorld(void)
{
if(_logged)
{
_logged=false;
GetInstance()->GetScripts()->RunScript("_leaveworld",NULL);
}
}
void WorldSession::_DoTimedActions(void)
{
static clock_t pingtime=0;
if(_logged)
{
if(pingtime < clock())
{
pingtime=clock() + 30*CLOCKS_PER_SEC;
SendPing(clock());
}
//...
}
}
///////////////////////////////////////////////////////////////
// Opcode Handlers
///////////////////////////////////////////////////////////////
void WorldSession::_HandleAuthChallengeOpcode(WorldPacket& recvPacket)
{
std::string acc = stringToUpper(GetInstance()->GetConf()->accname);
@ -279,8 +279,8 @@ void WorldSession::_HandleAuthChallengeOpcode(WorldPacket& recvPacket)
}
void WorldSession::_HandleAuthResponseOpcode(WorldPacket& recvPacket)
{
void WorldSession::_HandleAuthResponseOpcode(WorldPacket& recvPacket)
{
uint8 errcode;
recvPacket >> errcode;
if(errcode==0xC){
@ -291,11 +291,11 @@ void WorldSession::_HandleAuthResponseOpcode(WorldPacket& recvPacket)
} else {
logcritical("World Authentication failed, errcode=0x%X",(unsigned char)errcode);
GetInstance()->SetError();
}
}
void WorldSession::_HandleCharEnumOpcode(WorldPacket& recvPacket)
{
}
}
void WorldSession::_HandleCharEnumOpcode(WorldPacket& recvPacket)
{
uint8 num;
PlayerEnum plr[10]; // max characters per realm is 10
uint8 dummy8;
@ -373,10 +373,10 @@ void WorldSession::_HandleCharEnumOpcode(WorldPacket& recvPacket)
pkt.SetOpcode(CMSG_PLAYER_LOGIN);
pkt << _myGUID;
SendWorldPacket(pkt);
}
}
}
}
void WorldSession::_HandleSetProficiencyOpcode(WorldPacket& recvPacket)
{
_OnEnterWorld();
@ -572,16 +572,16 @@ void WorldSession::_HandleTradeStatusOpcode(WorldPacket& recvPacket)
}
}
void WorldSession::_HandleGroupInviteOpcode(WorldPacket& recvPacket)
{
void WorldSession::_HandleGroupInviteOpcode(WorldPacket& recvPacket)
{
recvPacket.hexlike();
WorldPacket pkt;
pkt.SetOpcode(CMSG_GROUP_DECLINE);
SendWorldPacket(pkt);
}
void WorldSession::_HandleMovementOpcode(WorldPacket& recvPacket)
{
SendWorldPacket(pkt);
}
void WorldSession::_HandleMovementOpcode(WorldPacket& recvPacket)
{
uint32 flags, time;
float x, y, z, o;
uint64 guid;
@ -619,7 +619,7 @@ void WorldSession::_HandleTelePortAckOpcode(WorldPacket& recvPacket)
logdetail("Got teleported, data: x: %f, y: %f, z: %f, o: %f, guid: %d\n", x, y, z, o, guid);
WorldPacket response;
response.SetOpcode(MSG_MOVE_FALL_LAND);
response.SetOpcode(MSG_MOVE_FALL_LAND);
response << uint32(0) << uint32(0) << x << y << z << o << uint32(0);
SendWorldPacket(response);
}

View File

@ -10,33 +10,33 @@ WorldSocket::WorldSocket(SocketHandler &h, WorldSession *s) : TcpSocket(h)
}
void WorldSocket::OnConnect()
{
printf("Connected to world server.\r\n");
}
void WorldSocket::OnConnectFailed()
{
printf("WorldSocket::OnConnectFailed()\n");
}
void WorldSocket::OnDelete()
{
printf("Connection to world server has been closed.\n");
if(_session)
_session->SetSocket(NULL);
}
void WorldSocket::OnException()
{
this->SetCloseAndDelete();
}
void WorldSocket::OnRead()
{
void WorldSocket::OnConnect()
{
printf("Connected to world server.\r\n");
}
void WorldSocket::OnConnectFailed()
{
printf("WorldSocket::OnConnectFailed()\n");
}
void WorldSocket::OnDelete()
{
printf("Connection to world server has been closed.\n");
if(_session)
_session->SetSocket(NULL);
}
void WorldSocket::OnException()
{
this->SetCloseAndDelete();
}
void WorldSocket::OnRead()
{
TcpSocket::OnRead();
uint32 len = ibuf.GetLength();
//printf("WorldSocket::OnRead() %u bytes\n",len);
printf("WorldSocket::OnRead() %u bytes\n",len);
if(!len)
{
this->CloseAndDelete();
@ -116,7 +116,7 @@ void WorldSocket::SendWorldPacket(WorldPacket &pkt)
_crypt.EncryptSend((uint8*)&hdr, 6);
ByteBuffer final(pkt.size()+6);
final.append((uint8*)&hdr,sizeof(ClientPktHeader));
final.append(pkt.contents(),pkt.size());
final.append(pkt);
SendBuf((char*)final.contents(),final.size());
}