Merge branch 'master' into 303

Conflicts:
	contrib/extractor/System.cpp
	contrib/extractor/ad.exe
	src/game/WorldSocket.cpp
This commit is contained in:
tomrus88 2008-11-06 15:50:47 +03:00
commit 78ec66babc
78 changed files with 510 additions and 752 deletions

View file

@ -81,7 +81,7 @@ m_Seed (static_cast<uint32> (rand32 ())),
m_OverSpeedPings (0),
m_LastPingTime (ACE_Time_Value::zero)
{
this->reference_counting_policy ().value (ACE_Event_Handler::Reference_Counting_Policy::ENABLED);
reference_counting_policy ().value (ACE_Event_Handler::Reference_Counting_Policy::ENABLED);
}
WorldSocket::~WorldSocket (void)
@ -92,9 +92,9 @@ WorldSocket::~WorldSocket (void)
if (m_OutBuffer)
m_OutBuffer->release ();
this->closing_ = true;
closing_ = true;
this->peer ().close ();
peer ().close ();
WorldPacket* pct;
while (m_PacketQueue.dequeue_head (pct) == 0)
@ -103,7 +103,7 @@ WorldSocket::~WorldSocket (void)
bool WorldSocket::IsClosed (void) const
{
return this->closing_;
return closing_;
}
void WorldSocket::CloseSocket (void)
@ -111,12 +111,12 @@ void WorldSocket::CloseSocket (void)
{
ACE_GUARD (LockType, Guard, m_OutBufferLock);
if (this->closing_)
if (closing_)
return;
this->closing_ = true;
closing_ = true;
this->peer ().close_writer ();
peer ().close_writer ();
}
{
@ -135,7 +135,7 @@ int WorldSocket::SendPacket (const WorldPacket& pct)
{
ACE_GUARD_RETURN (LockType, Guard, m_OutBufferLock, -1);
if (this->closing_)
if (closing_)
return -1;
// Dump outgoing packet.
@ -180,12 +180,12 @@ int WorldSocket::SendPacket (const WorldPacket& pct)
long WorldSocket::AddReference (void)
{
return static_cast<long> (this->add_reference ());
return static_cast<long> (add_reference ());
}
long WorldSocket::RemoveReference (void)
{
return static_cast<long> (this->remove_reference ());
return static_cast<long> (remove_reference ());
}
int WorldSocket::open (void *a)
@ -210,7 +210,7 @@ int WorldSocket::open (void *a)
// Store peer address.
ACE_INET_Addr remote_addr;
if (this->peer ().get_remote_addr (remote_addr) == -1)
if (peer ().get_remote_addr (remote_addr) == -1)
{
sLog.outError ("WorldSocket::open: peer ().get_remote_addr errno = %s", ACE_OS::strerror (errno));
return -1;
@ -226,42 +226,42 @@ int WorldSocket::open (void *a)
return -1;
// Register with ACE Reactor
if (this->reactor ()->register_handler(this, ACE_Event_Handler::READ_MASK | ACE_Event_Handler::WRITE_MASK) == -1)
if (reactor ()->register_handler(this, ACE_Event_Handler::READ_MASK | ACE_Event_Handler::WRITE_MASK) == -1)
{
sLog.outError ("WorldSocket::open: unable to register client handler errno = %s", ACE_OS::strerror (errno));
return -1;
}
// reactor takes care of the socket from now on
this->remove_reference ();
remove_reference ();
return 0;
}
int WorldSocket::close (int)
{
this->shutdown ();
shutdown ();
this->closing_ = true;
closing_ = true;
this->remove_reference ();
remove_reference ();
return 0;
}
int WorldSocket::handle_input (ACE_HANDLE)
{
if (this->closing_)
if (closing_)
return -1;
switch (this->handle_input_missing_data ())
switch (handle_input_missing_data ())
{
case -1 :
{
if ((errno == EWOULDBLOCK) ||
(errno == EAGAIN))
{
return this->Update (); // interesting line ,isnt it ?
return Update (); // interesting line ,isnt it ?
}
DEBUG_LOG ("WorldSocket::handle_input: Peer error closing connection errno = %s", ACE_OS::strerror (errno));
@ -279,7 +279,7 @@ int WorldSocket::handle_input (ACE_HANDLE)
case 1:
return 1;
default:
return this->Update (); // another interesting line ;)
return Update (); // another interesting line ;)
}
ACE_NOTREACHED(return -1);
@ -289,18 +289,18 @@ int WorldSocket::handle_output (ACE_HANDLE)
{
ACE_GUARD_RETURN (LockType, Guard, m_OutBufferLock, -1);
if (this->closing_)
if (closing_)
return -1;
const size_t send_len = m_OutBuffer->length ();
if (send_len == 0)
return this->cancel_wakeup_output (Guard);
return cancel_wakeup_output (Guard);
#ifdef MSG_NOSIGNAL
ssize_t n = this->peer ().send (m_OutBuffer->rd_ptr (), send_len, MSG_NOSIGNAL);
ssize_t n = peer ().send (m_OutBuffer->rd_ptr (), send_len, MSG_NOSIGNAL);
#else
ssize_t n = this->peer ().send (m_OutBuffer->rd_ptr (), send_len);
ssize_t n = peer ().send (m_OutBuffer->rd_ptr (), send_len);
#endif // MSG_NOSIGNAL
if (n == 0)
@ -308,7 +308,7 @@ int WorldSocket::handle_output (ACE_HANDLE)
else if (n == -1)
{
if (errno == EWOULDBLOCK || errno == EAGAIN)
return this->schedule_wakeup_output (Guard);
return schedule_wakeup_output (Guard);
return -1;
}
@ -319,16 +319,16 @@ int WorldSocket::handle_output (ACE_HANDLE)
// move the data to the base of the buffer
m_OutBuffer->crunch ();
return this->schedule_wakeup_output (Guard);
return schedule_wakeup_output (Guard);
}
else //now n == send_len
{
m_OutBuffer->reset ();
if (!iFlushPacketQueue ())
return this->cancel_wakeup_output (Guard);
return cancel_wakeup_output (Guard);
else
return this->schedule_wakeup_output (Guard);
return schedule_wakeup_output (Guard);
}
ACE_NOTREACHED (return 0);
@ -340,10 +340,10 @@ int WorldSocket::handle_close (ACE_HANDLE h, ACE_Reactor_Mask)
{
ACE_GUARD_RETURN (LockType, Guard, m_OutBufferLock, -1);
this->closing_ = true;
closing_ = true;
if (h == ACE_INVALID_HANDLE)
this->peer ().close_writer ();
peer ().close_writer ();
}
// Critical section
@ -358,13 +358,13 @@ int WorldSocket::handle_close (ACE_HANDLE h, ACE_Reactor_Mask)
int WorldSocket::Update (void)
{
if (this->closing_)
if (closing_)
return -1;
if (m_OutActive || m_OutBuffer->length () == 0)
return 0;
return this->handle_output (this->get_handle ());
return handle_output (get_handle ());
}
int WorldSocket::handle_input_header (void)
@ -416,7 +416,7 @@ int WorldSocket::handle_input_payload (void)
ACE_ASSERT (m_Header.space () == 0);
ACE_ASSERT (m_RecvWPct != NULL);
const int ret = this->ProcessIncoming (m_RecvWPct);
const int ret = ProcessIncoming (m_RecvWPct);
m_RecvPct.base (NULL, 0);
m_RecvPct.reset ();
@ -448,7 +448,7 @@ int WorldSocket::handle_input_missing_data (void)
const size_t recv_size = message_block.space ();
const ssize_t n = this->peer ().recv (message_block.wr_ptr (),
const ssize_t n = peer ().recv (message_block.wr_ptr (),
recv_size);
if (n <= 0)
@ -474,7 +474,7 @@ int WorldSocket::handle_input_missing_data (void)
}
//we just recieved nice new header
if (this->handle_input_header () == -1)
if (handle_input_header () == -1)
{
ACE_ASSERT ((errno != EWOULDBLOCK) && (errno != EAGAIN));
return -1;
@ -509,7 +509,7 @@ int WorldSocket::handle_input_missing_data (void)
}
//just recieved fresh new payload
if (this->handle_input_payload () == -1)
if (handle_input_payload () == -1)
{
ACE_ASSERT ((errno != EWOULDBLOCK) && (errno != EAGAIN));
return -1;
@ -528,7 +528,7 @@ int WorldSocket::cancel_wakeup_output (GuardType& g)
g.release ();
if (this->reactor ()->cancel_wakeup
if (reactor ()->cancel_wakeup
(this, ACE_Event_Handler::WRITE_MASK) == -1)
{
// would be good to store errno from reactor with errno guard
@ -548,7 +548,7 @@ int WorldSocket::schedule_wakeup_output (GuardType& g)
g.release ();
if (this->reactor ()->schedule_wakeup
if (reactor ()->schedule_wakeup
(this, ACE_Event_Handler::WRITE_MASK) == -1)
{
sLog.outError ("WorldSocket::schedule_wakeup_output");
@ -567,7 +567,7 @@ int WorldSocket::ProcessIncoming (WorldPacket* new_pct)
const ACE_UINT16 opcode = new_pct->GetOpcode ();
if (this->closing_)
if (closing_)
return -1;
// dump recieved packet
@ -854,7 +854,7 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
return -1;
}
std::string address = this->GetRemoteAddress ();
std::string address = GetRemoteAddress ();
DEBUG_LOG ("WorldSocket::HandleAuthSession: Client '%s' authenticated successfully from %s.",
account.c_str (),
@ -881,7 +881,7 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
// In case needed sometime the second arg is in microseconds 1 000 000 = 1 sec
ACE_OS::sleep (ACE_Time_Value (0, 10000));
sWorld.AddSession (this->m_Session);
sWorld.AddSession (m_Session);
// Create and send the Addon packet
if (sAddOnHandler.BuildAddonPacket (&recvPacket, &SendAddonPacked))
@ -949,14 +949,14 @@ int WorldSocket::HandlePing (WorldPacket& recvPacket)
sLog.outError ("WorldSocket::HandlePing: peer sent CMSG_PING, "
"but is not authenticated or got recently kicked,"
" address = %s",
this->GetRemoteAddress ().c_str ());
GetRemoteAddress ().c_str ());
return -1;
}
}
WorldPacket packet (SMSG_PONG, 4);
packet << ping;
return this->SendPacket (packet);
return SendPacket (packet);
}
int WorldSocket::iSendPacket (const WorldPacket& pct)