[General] Simplify ProxyMasterPacket

pull/367/head
Koncord 7 years ago
parent 5b8f4f3e92
commit ef0384b296

@ -64,29 +64,21 @@ namespace mwmp
vector<string>::iterator plIt; vector<string>::iterator plIt;
if (send)
plIt = server.players.begin();
else
server.players.clear();
int32_t playersCount = server.players.size(); int32_t playersCount = server.players.size();
packet->RW(playersCount, send); packet->RW(playersCount, send);
if (playersCount > 2000) if (playersCount > 2000)
playersCount = 0; playersCount = 0;
while (playersCount--) if(!send)
{ {
string player; server.players.clear();
if (send) server.players.resize(playersCount);
player = *plIt; }
for(auto &&player : server.players)
packet->RW(player, send); packet->RW(player, send);
if (!send)
server.players.push_back(player);
else
plIt++;
}
int32_t pluginsCount = server.plugins.size(); int32_t pluginsCount = server.plugins.size();
packet->RW(pluginsCount, send); packet->RW(pluginsCount, send);
@ -94,25 +86,16 @@ namespace mwmp
if (pluginsCount > 2000) if (pluginsCount > 2000)
pluginsCount = 0; pluginsCount = 0;
vector<Plugin>::iterator pluginIt; if(!send)
{
if (send)
pluginIt = server.plugins.begin();
else
server.plugins.clear(); server.plugins.clear();
server.plugins.resize(pluginsCount);
}
while (pluginsCount--) for(auto &&plugin : server.plugins)
{ {
Plugin plugin;
if (send)
plugin = *pluginIt;
packet->RW(plugin.name, send); packet->RW(plugin.name, send);
packet->RW(plugin.hash, send); packet->RW(plugin.hash, send);
if (!send)
server.plugins.push_back(plugin);
else
pluginIt++;
} }
} }
}; };

Loading…
Cancel
Save