[General] Remove 'using namespace std' from multiplayer components

pull/593/head
David Cernat 4 years ago
parent b3c40913f6
commit 4940687455

@ -5,7 +5,6 @@
using namespace mwmp;
using namespace RakNet;
using namespace std;
PacketMasterAnnounce::PacketMasterAnnounce(RakNet::RakPeerInterface *peer) : BasePacket(peer)
{

@ -6,7 +6,6 @@
using namespace mwmp;
using namespace std;
using namespace RakNet;
PacketMasterQuery::PacketMasterQuery(RakNet::RakPeerInterface *peer) : BasePacket(peer)
@ -26,12 +25,12 @@ void PacketMasterQuery::Packet(RakNet::BitStream *newBitstream, bool send)
RW(serversCount, send);
map<SystemAddress, QueryData>::iterator serverIt;
std::map<SystemAddress, QueryData>::iterator serverIt;
if (send)
serverIt = servers->begin();
QueryData server;
string addr;
std::string addr;
uint16_t port;
while (serversCount--)
{
@ -55,12 +54,12 @@ void PacketMasterQuery::Packet(RakNet::BitStream *newBitstream, bool send)
if (send)
serverIt++;
else
servers->insert(pair<SystemAddress, QueryData>(SystemAddress(addr.c_str(), port), server));
servers->insert(std::pair<SystemAddress, QueryData>(SystemAddress(addr.c_str(), port), server));
}
}
void PacketMasterQuery::SetServers(map<SystemAddress, QueryData> *serverMap)
void PacketMasterQuery::SetServers(std::map<SystemAddress, QueryData> *serverMap)
{
servers = serverMap;
}

@ -3,7 +3,6 @@
#include "ProxyMasterPacket.hpp"
using namespace mwmp;
using namespace std;
using namespace RakNet;
PacketMasterUpdate::PacketMasterUpdate(RakNet::RakPeerInterface *peer) : BasePacket(peer)
@ -19,7 +18,7 @@ void PacketMasterUpdate::Packet(RakNet::BitStream *newBitstream, bool send)
if (send)
bs->Write(packetID);
string addr = server->first.ToString(false);
std::string addr = server->first.ToString(false);
uint16_t port = server->first.GetPort();
RW(addr, send);

@ -22,22 +22,20 @@ namespace mwmp
template<class Packet>
static void addServer(Packet *packet, QueryData &server, bool send)
{
using namespace std;
int32_t rulesSize = server.rules.size();
packet->RW(rulesSize, send);
if (rulesSize > QueryData::maxRules)
rulesSize = 0;
map<string, ServerRule>::iterator ruleIt;
std::map<std::string, ServerRule>::iterator ruleIt;
if (send)
ruleIt = server.rules.begin();
while (rulesSize--)
{
ServerRule *rule = nullptr;
string key;
std::string key;
if (send)
{
key = ruleIt->first;
@ -47,7 +45,7 @@ namespace mwmp
packet->RW(key, send, false, QueryData::maxStringLength);
if (!send)
{
ruleIt = server.rules.insert(pair<string, ServerRule>(key, ServerRule())).first;
ruleIt = server.rules.insert(std::pair<std::string, ServerRule>(key, ServerRule())).first;
rule = &ruleIt->second;
}
@ -62,7 +60,7 @@ namespace mwmp
ruleIt++;
}
vector<string>::iterator plIt;
std::vector<std::string>::iterator plIt;
int32_t playersCount = server.players.size();
packet->RW(playersCount, send);

@ -1,7 +1,6 @@
#include <components/openmw-mp/NetworkMessages.hpp>
#include "PacketPlayerBook.hpp"
using namespace std;
using namespace mwmp;
PacketPlayerBook::PacketPlayerBook(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)

@ -1,7 +1,6 @@
#include <components/openmw-mp/NetworkMessages.hpp>
#include "PacketPlayerFaction.hpp"
using namespace std;
using namespace mwmp;
PacketPlayerFaction::PacketPlayerFaction(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)

@ -1,7 +1,6 @@
#include <components/openmw-mp/NetworkMessages.hpp>
#include "PacketPlayerInventory.hpp"
using namespace std;
using namespace mwmp;
PacketPlayerInventory::PacketPlayerInventory(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)

@ -1,7 +1,6 @@
#include <components/openmw-mp/NetworkMessages.hpp>
#include "PacketPlayerJournal.hpp"
using namespace std;
using namespace mwmp;
PacketPlayerJournal::PacketPlayerJournal(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)

@ -1,7 +1,6 @@
#include "PacketPlayerPosition.hpp"
#include <components/openmw-mp/NetworkMessages.hpp>
using namespace std;
using namespace mwmp;
PacketPlayerPosition::PacketPlayerPosition(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)

@ -1,7 +1,6 @@
#include <components/openmw-mp/NetworkMessages.hpp>
#include "PacketPlayerQuickKeys.hpp"
using namespace std;
using namespace mwmp;
PacketPlayerQuickKeys::PacketPlayerQuickKeys(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)

@ -1,7 +1,6 @@
#include <components/openmw-mp/NetworkMessages.hpp>
#include "PacketPlayerSpellbook.hpp"
using namespace std;
using namespace mwmp;
PacketPlayerSpellbook::PacketPlayerSpellbook(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)

@ -1,7 +1,6 @@
#include <components/openmw-mp/NetworkMessages.hpp>
#include "PacketPlayerTopic.hpp"
using namespace std;
using namespace mwmp;
PacketPlayerTopic::PacketPlayerTopic(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)

@ -2,7 +2,6 @@
#include <components/openmw-mp/TimedLog.hpp>
#include "PacketWorldMap.hpp"
using namespace std;
using namespace mwmp;
PacketWorldMap::PacketWorldMap(RakNet::RakPeerInterface *peer) : WorldstatePacket(peer)

@ -8,8 +8,6 @@
#include <boost/lexical_cast.hpp>
#include "TimedLog.hpp"
using namespace std;
TimedLog *TimedLog::sTimedLog = nullptr;
TimedLog::TimedLog(int logLevel) : logLevel(logLevel)
@ -99,15 +97,15 @@ void TimedLog::print(int level, bool hasPrefix, const char *file, int line, cons
sstr << '\n';
va_list args;
va_start(args, message);
vector<char> buf((unsigned long) (vsnprintf(nullptr, 0, sstr.str().c_str(), args) + 1));
std::vector<char> buf((unsigned long) (vsnprintf(nullptr, 0, sstr.str().c_str(), args) + 1));
va_end(args);
va_start(args, message);
vsnprintf(buf.data(), buf.size(), sstr.str().c_str(), args);
va_end(args);
cout << buf.data() << flush;
std::cout << buf.data() << std::flush;
}
string TimedLog::getFilenameTimestamp()
std::string TimedLog::getFilenameTimestamp()
{
time_t rawtime = time(0);
struct tm *timeinfo = localtime(&rawtime);

@ -11,8 +11,6 @@
#include <boost/filesystem/fstream.hpp>
#include <iomanip>
using namespace std;
#ifdef _WIN32
int setenv(const char *name, const char *value, int overwrite)
{
@ -117,15 +115,15 @@ std::string Utils::toString(int num)
return stream.str();
}
std::string Utils::replaceString(const string& source, const char* find, const char* replace)
std::string Utils::replaceString(const std::string& source, const char* find, const char* replace)
{
unsigned int find_len = strlen(find);
unsigned int replace_len = strlen(replace);
size_t pos = 0;
string dest = source;
std::string dest = source;
while ((pos = dest.find(find, pos)) != string::npos)
while ((pos = dest.find(find, pos)) != std::string::npos)
{
dest.replace(pos, find_len, replace);
pos += replace_len;
@ -134,7 +132,7 @@ std::string Utils::replaceString(const string& source, const char* find, const c
return dest;
}
string& Utils::removeExtension(string& file)
std::string& Utils::removeExtension(std::string& file)
{
size_t pos = file.find_last_of('.');
@ -211,23 +209,23 @@ std::string Utils::getVersionInfo(std::string appName, std::string version, std:
{
std::stringstream stream;
stream << appName << " " << version << " (" << getOperatingSystemType() << " " << getArchitectureType() << ")" << endl;
stream << "Protocol version: " << protocol << endl;
stream << "Oldest compatible commit hash: " << commitHash.substr(0, 10) << endl;
stream << "------------------------------------------------------------" << endl;
stream << appName << " " << version << " (" << getOperatingSystemType() << " " << getArchitectureType() << ")" << std::endl;
stream << "Protocol version: " << protocol << std::endl;
stream << "Oldest compatible commit hash: " << commitHash.substr(0, 10) << std::endl;
stream << "------------------------------------------------------------" << std::endl;
return stream.str();
}
void Utils::printWithWidth(ostringstream &sstr, string str, size_t width)
void Utils::printWithWidth(std::ostringstream &sstr, std::string str, size_t width)
{
sstr << left << setw(width) << setfill(' ') << str;
sstr << std::left << std::setw(width) << std::setfill(' ') << str;
}
string Utils::intToHexStr(unsigned val)
std::string Utils::intToHexStr(unsigned val)
{
ostringstream sstr;
sstr << "0x" << setfill('0') << setw(8) << uppercase << hex << val;
std::ostringstream sstr;
sstr << "0x" << std::setfill('0') << std::setw(8) << std::uppercase << std::hex << val;
return sstr.str();
}

Loading…
Cancel
Save