2010-08-11 15:23:10 +02:00
|
|
|
// ***************************************************************************
|
|
|
|
|
//
|
|
|
|
|
// Reality - The Matrix Online Server Emulator
|
2009-08-11 12:17:38 +00:00
|
|
|
// Copyright (C) 2006-2010 Rajko Stojadinovic
|
2010-08-11 15:23:10 +02:00
|
|
|
// http://mxoemu.info
|
2009-08-11 12:17:38 +00:00
|
|
|
//
|
2010-08-11 15:23:10 +02:00
|
|
|
// ---------------------------------------------------------------------------
|
2009-08-11 12:17:38 +00:00
|
|
|
//
|
2010-08-11 15:23:10 +02:00
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU Affero General Public License as
|
|
|
|
|
// published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
// License, or (at your option) any later version.
|
2009-08-11 12:17:38 +00:00
|
|
|
//
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2010-08-11 15:23:10 +02:00
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2009-08-11 12:17:38 +00:00
|
|
|
//
|
2010-08-11 15:23:10 +02:00
|
|
|
// ---------------------------------------------------------------------------
|
2009-08-11 12:17:38 +00:00
|
|
|
//
|
2010-08-11 15:23:10 +02:00
|
|
|
// ***************************************************************************
|
2009-08-18 16:39:50 +00:00
|
|
|
|
|
|
|
|
#include "MarginHandler.h"
|
2010-02-08 14:51:16 +00:00
|
|
|
#include "Common.h"
|
|
|
|
|
#include "MarginSocket.h"
|
2009-08-18 16:39:50 +00:00
|
|
|
|
|
|
|
|
MarginHandler::MarginHandler()
|
|
|
|
|
:SocketHandler()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MarginHandler::~MarginHandler()
|
|
|
|
|
{
|
2010-02-08 14:51:16 +00:00
|
|
|
}
|
|
|
|
|
|
2010-02-25 17:37:59 +01:00
|
|
|
vector<MarginSocket*> MarginHandler::FindByCharacterUID( uint64 charUID )
|
2010-02-08 14:51:16 +00:00
|
|
|
{
|
2010-02-25 17:37:59 +01:00
|
|
|
vector<MarginSocket*> tempVect;
|
2010-02-08 14:51:16 +00:00
|
|
|
for (socket_m::iterator it = m_sockets.begin(); it != m_sockets.end(); it++)
|
|
|
|
|
{
|
|
|
|
|
Socket *p = it->second;
|
|
|
|
|
if (p == NULL)
|
|
|
|
|
continue;
|
|
|
|
|
TcpSocket *tcpSock = dynamic_cast<TcpSocket *>(p);
|
|
|
|
|
if (tcpSock == NULL)
|
|
|
|
|
continue;
|
|
|
|
|
MarginSocket *margSock = dynamic_cast<MarginSocket *>(tcpSock);
|
|
|
|
|
if (margSock == NULL)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (margSock->GetCharUID() == charUID)
|
2010-02-25 17:37:59 +01:00
|
|
|
{
|
|
|
|
|
tempVect.push_back(margSock);
|
|
|
|
|
}
|
2010-02-08 14:51:16 +00:00
|
|
|
}
|
2010-02-25 17:37:59 +01:00
|
|
|
return tempVect;
|
2010-02-08 14:51:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class MarginSocket *MarginHandler::FindBySessionId( uint32 sessionId )
|
|
|
|
|
{
|
|
|
|
|
for (socket_m::iterator it = m_sockets.begin(); it != m_sockets.end(); it++)
|
|
|
|
|
{
|
|
|
|
|
Socket *p = it->second;
|
|
|
|
|
if (p == NULL)
|
|
|
|
|
continue;
|
|
|
|
|
TcpSocket *tcpSock = dynamic_cast<TcpSocket *>(p);
|
|
|
|
|
if (tcpSock == NULL)
|
|
|
|
|
continue;
|
|
|
|
|
MarginSocket *margSock = dynamic_cast<MarginSocket *>(tcpSock);
|
|
|
|
|
if (margSock == NULL)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (margSock->GetSessionId() == sessionId)
|
|
|
|
|
return margSock;
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
2009-08-11 12:17:38 +00:00
|
|
|
}
|