[Server] Minor fixes

new-script-api
Koncord 7 years ago
parent 6cb9c3c713
commit 62588ce088

@ -109,7 +109,7 @@ void MasterClient::SetRuleValue(std::string key, double value)
void MasterClient::PushPlugin(Plugin plugin) void MasterClient::PushPlugin(Plugin plugin)
{ {
mutexData.lock(); mutexData.lock();
queryData.plugins.push_back(plugin); queryData.plugins.push_back(move(plugin));
updated = true; updated = true;
mutexData.unlock(); mutexData.unlock();
} }

@ -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);
} }

@ -55,7 +55,7 @@ namespace mwmp
int incrementMpNum(); int incrementMpNum();
MasterClient *getMasterClient(); MasterClient *getMasterClient();
void InitQuery(std::string queryAddr, unsigned short queryPort); void InitQuery(const std::string &queryAddr, unsigned short queryPort);
void setServerPassword(std::string passw) noexcept; void setServerPassword(std::string passw) noexcept;
bool isPassworded() const; bool isPassworded() const;

Loading…
Cancel
Save