Show
Ignore:
Timestamp:
11/19/08 13:22:12 (17 years ago)
Author:
yumileroy
Message:

[svn] * Added ACE for Linux and Windows (Thanks Derex for Linux part and partial Windows part)
* Updated to 6721 and 676
* Fixed TrinityScript? logo
* Version updated to 0.2.6721.676

Original author: Neo2003
Date: 2008-10-04 06:17:19-05:00

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/game/WorldSession.cpp

    r2 r6  
    2121*/ 
    2222 
     23#include "WorldSocket.h" 
    2324#include "Common.h" 
    2425#include "Database/DatabaseEnv.h" 
     
    4344WorldSession::WorldSession(uint32 id, WorldSocket *sock, uint32 sec, bool tbc, time_t mute_time, LocaleConstant locale) : 
    4445LookingForGroup_auto_join(false), LookingForGroup_auto_add(false), m_muteTime(mute_time), 
    45 _player(NULL), _socket(sock),_security(sec), _accountId(id), m_isTBC(tbc), 
     46_player(NULL), m_Socket(sock),_security(sec), _accountId(id), m_isTBC(tbc), 
    4647m_sessionDbcLocale(sWorld.GetAvailableDbcLocale(locale)), m_sessionDbLocaleIndex(objmgr.GetIndexForLocale(locale)), 
    4748_logoutTime(0), m_playerLoading(false), m_playerLogout(false), m_playerRecentlyLogout(false), m_latency(0) 
    4849{ 
     50   if (sock) 
     51     { 
     52       m_Address = sock->GetRemoteAddress (); 
     53       sock->AddReference (); 
     54     } 
    4955} 
    5056 
     
    5763 
    5864    /// - If have unclosed socket, close it 
    59     if(_socket) 
    60         _socket->CloseSocket(); 
    61  
    62     _socket = NULL; 
     65  if (m_Socket) 
     66    { 
     67      m_Socket->CloseSocket ();    
     68      m_Socket->RemoveReference (); 
     69      m_Socket = NULL; 
     70    } 
    6371 
    6472    ///- empty incoming packet queue 
     
    6876        delete packet; 
    6977    } 
     78     
     79    sWorld.RemoveQueuedPlayer(this); 
    7080} 
    7181 
     
    8292} 
    8393 
    84 /// Set the WorldSocket associated with this session 
    85 void WorldSession::SetSocket(WorldSocket *sock) 
    86 { 
    87     _socket = sock; 
    88 } 
    89  
    9094/// Send a packet to the client 
    9195void WorldSession::SendPacket(WorldPacket const* packet) 
    9296{ 
    93     if (!_socket) 
     97    if (!m_Socket) 
    9498        return; 
    9599    #ifdef MANGOS_DEBUG 
     
    125129        sendLastPacketBytes = packet->wpos();               // wpos is real written size 
    126130    } 
    127     #endif                                                  // !MANGOS_DEBUG 
    128  
    129     _socket->SendPacket(packet); 
     131#endif                                                  // !MANGOS_DEBUG 
     132 
     133  if (m_Socket->SendPacket (*packet) == -1) 
     134    { 
     135      m_Socket->CloseSocket (); 
     136    } 
    130137} 
    131138 
    132139/// Add an incoming packet to the queue 
    133 void WorldSession::QueuePacket(WorldPacket& packet) 
    134 { 
    135     WorldPacket *pck = new WorldPacket(packet); 
    136     _recvQueue.add(pck); 
     140void WorldSession::QueuePacket(WorldPacket* new_packet) 
     141{ 
     142    _recvQueue.add(new_packet); 
    137143} 
    138144 
     
    149155bool WorldSession::Update(uint32 /*diff*/) 
    150156{ 
     157  if (m_Socket) 
     158    if (m_Socket->IsClosed ()) 
     159      {  
     160        m_Socket->RemoveReference (); 
     161        m_Socket = NULL; 
     162      } 
     163   
    151164    WorldPacket *packet; 
    152165 
     
    211224    ///- If necessary, log the player out 
    212225    time_t currTime = time(NULL); 
    213     if (!_socket || (ShouldLogOut(currTime) && !m_playerLoading)) 
     226    if (!m_Socket || (ShouldLogOut(currTime) && !m_playerLoading)) 
    214227        LogoutPlayer(true); 
    215228 
    216     if (!_socket) 
     229    if (!m_Socket) 
    217230        return false;                                       //Will remove this session from the world session map 
    218231 
     
    344357        // remove player from the group if he is: 
    345358        // a) in group; b) not in raid group; c) logging out normally (not being kicked or disconnected) 
    346         if(_player->GetGroup() && !_player->GetGroup()->isRaidGroup() && _socket) 
     359        if(_player->GetGroup() && !_player->GetGroup()->isRaidGroup() && m_Socket) 
    347360            _player->RemoveFromGroup(); 
    348361 
     
    386399void WorldSession::KickPlayer() 
    387400{ 
    388     if(!_socket) 
    389         return; 
    390  
    391     // player will be logout and session will removed in next update tick 
    392     _socket->CloseSocket(); 
    393     _socket = NULL; 
     401  if (m_Socket) 
     402    { 
     403      m_Socket->CloseSocket (); 
     404    } 
    394405} 
    395406 
     
    462473        recvPacket.GetOpcode()); 
    463474} 
     475 
     476void WorldSession::SendAuthWaitQue(uint32 position) 
     477 { 
     478     if(position == 0) 
     479     { 
     480         WorldPacket packet( SMSG_AUTH_RESPONSE, 1 ); 
     481         packet << uint8( AUTH_OK ); 
     482         SendPacket(&packet); 
     483     } 
     484     else 
     485     { 
     486         WorldPacket packet( SMSG_AUTH_RESPONSE, 5 ); 
     487         packet << uint8( AUTH_WAIT_QUEUE ); 
     488         packet << uint32 (position); 
     489         SendPacket(&packet); 
     490     } 
     491 } 
     492  
     493