|
|
@ -30,7 +30,7 @@
|
|
|
|
using namespace mwmp;
|
|
|
|
using namespace mwmp;
|
|
|
|
using namespace std;
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
|
|
Networking *Networking::sThis = 0;
|
|
|
|
Networking *Networking::sThis = nullptr;
|
|
|
|
|
|
|
|
|
|
|
|
static int currentMpNum = 0;
|
|
|
|
static int currentMpNum = 0;
|
|
|
|
|
|
|
|
|
|
|
@ -48,9 +48,9 @@ Networking::Networking(RakNet::RakPeerInterface *peer) : mclient(nullptr)
|
|
|
|
worldPacketController = new WorldPacketController(peer);
|
|
|
|
worldPacketController = new WorldPacketController(peer);
|
|
|
|
|
|
|
|
|
|
|
|
// Set send stream
|
|
|
|
// Set send stream
|
|
|
|
playerPacketController->SetStream(0, &bsOut);
|
|
|
|
playerPacketController->SetStream(nullptr, &bsOut);
|
|
|
|
actorPacketController->SetStream(0, &bsOut);
|
|
|
|
actorPacketController->SetStream(nullptr, &bsOut);
|
|
|
|
worldPacketController->SetStream(0, &bsOut);
|
|
|
|
worldPacketController->SetStream(nullptr, &bsOut);
|
|
|
|
|
|
|
|
|
|
|
|
running = true;
|
|
|
|
running = true;
|
|
|
|
exitCode = 0;
|
|
|
|
exitCode = 0;
|
|
|
@ -244,7 +244,7 @@ bool Networking::update(RakNet::Packet *packet)
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
playerPacketController->SetStream(&bsIn, 0);
|
|
|
|
playerPacketController->SetStream(&bsIn, nullptr);
|
|
|
|
|
|
|
|
|
|
|
|
playerPacketController->GetPacket(ID_HANDSHAKE)->RequestData(packet->guid);
|
|
|
|
playerPacketController->GetPacket(ID_HANDSHAKE)->RequestData(packet->guid);
|
|
|
|
player = Players::addPlayer(packet->guid);
|
|
|
|
player = Players::addPlayer(packet->guid);
|
|
|
@ -253,21 +253,21 @@ bool Networking::update(RakNet::Packet *packet)
|
|
|
|
|
|
|
|
|
|
|
|
if (playerPacketController->ContainsPacket(packet->data[0]))
|
|
|
|
if (playerPacketController->ContainsPacket(packet->data[0]))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
playerPacketController->SetStream(&bsIn, 0);
|
|
|
|
playerPacketController->SetStream(&bsIn, nullptr);
|
|
|
|
processPlayerPacket(packet);
|
|
|
|
processPlayerPacket(packet);
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (actorPacketController->ContainsPacket(packet->data[0]))
|
|
|
|
if (actorPacketController->ContainsPacket(packet->data[0]))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
actorPacketController->SetStream(&bsIn, 0);
|
|
|
|
actorPacketController->SetStream(&bsIn, nullptr);
|
|
|
|
processActorPacket(packet);
|
|
|
|
processActorPacket(packet);
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (worldPacketController->ContainsPacket(packet->data[0]))
|
|
|
|
if (worldPacketController->ContainsPacket(packet->data[0]))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
worldPacketController->SetStream(&bsIn, 0);
|
|
|
|
worldPacketController->SetStream(&bsIn, nullptr);
|
|
|
|
processWorldPacket(packet);
|
|
|
|
processWorldPacket(packet);
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -398,17 +398,17 @@ PacketPreInit::PluginContainer Networking::getPluginListSample()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
unsigned field = 0;
|
|
|
|
unsigned field = 0;
|
|
|
|
auto name = luaState.getEventCtrl().Call<CoreEvent::ON_REQUEST_PLUGIN_LIST, string>(id, field++);
|
|
|
|
auto name = luaState.getEventCtrl().Call<CoreEvent::ON_REQUEST_PLUGIN_LIST, string>(id, field++);
|
|
|
|
if (name.size() == 0)
|
|
|
|
if (name.empty())
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
PacketPreInit::HashList hashList;
|
|
|
|
PacketPreInit::HashList hashList;
|
|
|
|
while (true)
|
|
|
|
while (true)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
auto hash = luaState.getEventCtrl().Call<CoreEvent::ON_REQUEST_PLUGIN_LIST, string>(id, field++);
|
|
|
|
auto hash = luaState.getEventCtrl().Call<CoreEvent::ON_REQUEST_PLUGIN_LIST, string>(id, field++);
|
|
|
|
if (hash.size() == 0)
|
|
|
|
if (hash.empty())
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
hashList.push_back((unsigned)stoul(hash));
|
|
|
|
hashList.push_back((unsigned)stoul(hash));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pls.push_back({name, hashList});
|
|
|
|
pls.emplace_back(name, hashList);
|
|
|
|
id++;
|
|
|
|
id++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return pls;
|
|
|
|
return pls;
|
|
|
@ -525,7 +525,7 @@ MasterClient *Networking::getMasterClient()
|
|
|
|
return mclient;
|
|
|
|
return mclient;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Networking::InitQuery(std::string queryAddr, unsigned short queryPort)
|
|
|
|
void Networking::InitQuery(const std::string &queryAddr, unsigned short queryPort)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mclient = new MasterClient(peer, queryAddr, queryPort);
|
|
|
|
mclient = new MasterClient(peer, queryAddr, queryPort);
|
|
|
|
}
|
|
|
|
}
|
|
|
|