[General] Make coding style consistent

pull/249/merge
David Cernat 8 years ago
parent afcf5a7fc8
commit c3c04bbfc3

@ -188,7 +188,7 @@ void MasterClient::Thread()
SetPlayers((int) players->size()); SetPlayers((int) players->size());
auto pIt = players->begin(); auto pIt = players->begin();
if(queryData.players.size() != players->size()) if (queryData.players.size() != players->size())
{ {
queryData.players.clear(); queryData.players.clear();
updated = true; updated = true;
@ -211,9 +211,9 @@ void MasterClient::Thread()
updated = false; updated = false;
if (pIt != players->end()) if (pIt != players->end())
{ {
for(auto player : *players) for (auto player : *players)
{ {
if(!player.second->npc.mName.empty()) if (!player.second->npc.mName.empty())
queryData.players.push_back(player.second->npc.mName); queryData.players.push_back(player.second->npc.mName);
} }
} }

@ -216,7 +216,7 @@ void Networking::update(RakNet::Packet *packet)
if (hashList.empty()) // and server do not allow to have custom hash for plugin if (hashList.empty()) // and server do not allow to have custom hash for plugin
continue; continue;
auto it = find(hashList.begin(), hashList.end(), plugin->second[0]); auto it = find(hashList.begin(), hashList.end(), plugin->second[0]);
if(it == hashList.end()) // hash not found in sample if (it == hashList.end()) // hash not found in sample
break; break;
} }
@ -226,7 +226,7 @@ void Networking::update(RakNet::Packet *packet)
} }
RakNet::BitStream bs; RakNet::BitStream bs;
packetPreInit.SetSendStream(&bs); packetPreInit.SetSendStream(&bs);
if(plugin != plugins.end()) // if condition is true, then client have wrong plugin list if (plugin != plugins.end()) // if condition is true, then client have wrong plugin list
{ {
packetPreInit.setChecksums(&samples); packetPreInit.setChecksums(&samples);
packetPreInit.Send(packet->systemAddress); packetPreInit.Send(packet->systemAddress);
@ -390,14 +390,14 @@ PacketPreInit::PluginContainer Networking::getPluginListSample()
unsigned field = 0; unsigned field = 0;
auto name = ""; auto name = "";
Script::Call<Script::CallbackIdentity("OnRequestPluginList")>(name, id, field++); Script::Call<Script::CallbackIdentity("OnRequestPluginList")>(name, id, field++);
if(strlen(name) == 0) if (strlen(name) == 0)
break; break;
PacketPreInit::HashList hashList; PacketPreInit::HashList hashList;
while(true) while(true)
{ {
auto hash = ""; auto hash = "";
Script::Call<Script::CallbackIdentity("OnRequestPluginList")>(hash, id, field++); Script::Call<Script::CallbackIdentity("OnRequestPluginList")>(hash, id, field++);
if(strlen(hash) == 0) if (strlen(hash) == 0)
break; break;
hashList.push_back((unsigned)stoul(hash)); hashList.push_back((unsigned)stoul(hash));
} }

@ -23,12 +23,12 @@ bool ActorProcessor::Process(RakNet::Packet &packet, ActorList &actorList)
BOOST_FOREACH(processors_t::value_type &processor, processors) BOOST_FOREACH(processors_t::value_type &processor, processors)
{ {
if(processor.first == packet.data[0]) if (processor.first == packet.data[0])
{ {
myGuid = Main::get().getLocalPlayer()->guid; myGuid = Main::get().getLocalPlayer()->guid;
request = packet.length == myPacket->headerSize(); request = packet.length == myPacket->headerSize();
if(!request && !processor.second->avoidReading) if (!request && !processor.second->avoidReading)
{ {
myPacket->Read(); myPacket->Read();
} }
@ -45,7 +45,7 @@ void ActorProcessor::AddProcessor(mwmp::ActorProcessor *processor)
{ {
BOOST_FOREACH(processors_t::value_type &p, processors) BOOST_FOREACH(processors_t::value_type &p, processors)
{ {
if(processor->packetID == p.first) if (processor->packetID == p.first)
throw std::logic_error("processor " + p.second->strPacketID + " already registered. Check " + throw std::logic_error("processor " + p.second->strPacketID + " already registered. Check " +
processor->className + " and " + p.second->className); processor->className + " and " + p.second->className);
} }

@ -349,7 +349,7 @@ void CellController::openContainer(const MWWorld::Ptr &container, bool loot)
LOG_APPEND(Log::LOG_VERBOSE, " - Item. Refid: \"%s\" Count: %d", name.c_str(), count); LOG_APPEND(Log::LOG_VERBOSE, " - Item. Refid: \"%s\" Count: %d", name.c_str(), count);
/*if(::Misc::StringUtils::ciEqual(name, "gold_001")) /*if (::Misc::StringUtils::ciEqual(name, "gold_001"))
cont.remove("gold_001", count, container);*/ cont.remove("gold_001", count, container);*/
} }

@ -98,9 +98,9 @@ void mwmp::GUIController::showDialogList(const mwmp::BasePlayer::GUIMessageBox &
std::string buf; std::string buf;
for(size_t i = 0; i < guiMessageBox.data.size(); i++) for (size_t i = 0; i < guiMessageBox.data.size(); i++)
{ {
if(guiMessageBox.data[i] == '\n') if (guiMessageBox.data[i] == '\n')
{ {
list.push_back(buf); list.push_back(buf);
buf.erase(); buf.erase();
@ -224,7 +224,7 @@ void mwmp::GUIController::WM_UpdateVisible(MWGui::GuiMode mode)
} }
case GM_TES3MP_ListBox: case GM_TES3MP_ListBox:
{ {
if(mListBox != 0) if (mListBox != 0)
mListBox->setVisible(true); mListBox->setVisible(true);
break; break;
} }

@ -29,7 +29,7 @@ GUIDialogList::GUIDialogList(const std::string &message, const std::vector<std::
mButton->eventMouseButtonClick += MyGUI::newDelegate(this, &GUIDialogList::mousePressed); mButton->eventMouseButtonClick += MyGUI::newDelegate(this, &GUIDialogList::mousePressed);
mMessage->setCaptionWithReplacing(message); mMessage->setCaptionWithReplacing(message);
for(size_t i = 0; i < list.size(); i++) for (size_t i = 0; i < list.size(); i++)
mListBox->addItem(list[i]); mListBox->addItem(list[i]);
} }
@ -46,7 +46,7 @@ void GUIDialogList::mousePressed(MyGUI::Widget * /*widget*/)
Main::get().getNetworking()->getPlayerPacket(ID_GUI_MESSAGEBOX)->Send(); Main::get().getNetworking()->getPlayerPacket(ID_GUI_MESSAGEBOX)->Send();
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Selected id: %d", id); LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Selected id: %d", id);
if(id == MyGUI::ITEM_NONE) if (id == MyGUI::ITEM_NONE)
return; return;
std::string itemName = mListBox->getItemNameAt(mListBox->getIndexSelected()).asUTF8(); std::string itemName = mListBox->getItemNameAt(mListBox->getIndexSelected()).asUTF8();

@ -63,12 +63,12 @@ string comparePlugins(PacketPreInit::PluginContainer checksums, PacketPreInit::P
sstr << "Note: Use the same load order as the server.\n"; sstr << "Note: Use the same load order as the server.\n";
size_t pluginNameLen1 = 0; size_t pluginNameLen1 = 0;
size_t pluginNameLen2 = 0; size_t pluginNameLen2 = 0;
for(size_t i = 0; i < checksums.size(); i++) for (size_t i = 0; i < checksums.size(); i++)
if(pluginNameLen1 < checksums[i].first.size()) if (pluginNameLen1 < checksums[i].first.size())
pluginNameLen1 = checksums[i].first.size(); pluginNameLen1 = checksums[i].first.size();
for(size_t i = 0; i < checksumsResponse.size(); i++) for (size_t i = 0; i < checksumsResponse.size(); i++)
if(pluginNameLen2 < checksumsResponse[i].first.size()) if (pluginNameLen2 < checksumsResponse[i].first.size())
pluginNameLen2 = checksumsResponse[i].first.size(); pluginNameLen2 = checksumsResponse[i].first.size();
printWithWidth(sstr, "Your current plugins are:", pluginNameLen1 + 16); printWithWidth(sstr, "Your current plugins are:", pluginNameLen1 + 16);
@ -78,7 +78,7 @@ string comparePlugins(PacketPreInit::PluginContainer checksums, PacketPreInit::P
printWithWidth(sstr, "hash", 14); printWithWidth(sstr, "hash", 14);
printWithWidth(sstr, "name", pluginNameLen2 + 2); printWithWidth(sstr, "name", pluginNameLen2 + 2);
sstr << "hash\n"; sstr << "hash\n";
for(size_t i = 0; i < checksumsResponse.size(); i++) for (size_t i = 0; i < checksumsResponse.size(); i++)
{ {
string plugin; string plugin;
unsigned val; unsigned val;
@ -95,10 +95,10 @@ string comparePlugins(PacketPreInit::PluginContainer checksums, PacketPreInit::P
printWithWidth(sstr, plugin, pluginNameLen1 + 2); printWithWidth(sstr, plugin, pluginNameLen1 + 2);
printWithWidth(sstr, intToHexStr(val), 14); printWithWidth(sstr, intToHexStr(val), 14);
printWithWidth(sstr, checksumsResponse[i].first, pluginNameLen2 + 2); printWithWidth(sstr, checksumsResponse[i].first, pluginNameLen2 + 2);
if(checksumsResponse[i].second.size() > 0) if (checksumsResponse[i].second.size() > 0)
{ {
if(full) if (full)
for(size_t j = 0; j < checksumsResponse[i].second.size(); j++) for (size_t j = 0; j < checksumsResponse[i].second.size(); j++)
printWithWidth(sstr, intToHexStr(checksumsResponse[i].second[j]), 14); printWithWidth(sstr, intToHexStr(checksumsResponse[i].second[j]), 14);
else else
sstr << intToHexStr(checksumsResponse[i].second[0]); sstr << intToHexStr(checksumsResponse[i].second[0]);
@ -289,7 +289,7 @@ void Networking::preInit(std::vector<std::string> &content, Files::Collections &
while (!done) while (!done)
{ {
RakNet::Packet *packet = peer->Receive(); RakNet::Packet *packet = peer->Receive();
if(!packet) if (!packet)
{ {
RakSleep(500); RakSleep(500);
continue; continue;
@ -315,7 +315,7 @@ void Networking::preInit(std::vector<std::string> &content, Files::Collections &
peer->DeallocatePacket(packet); peer->DeallocatePacket(packet);
} }
if(!checksumsResponse.empty()) // something wrong if (!checksumsResponse.empty()) // something wrong
errmsg = comparePlugins(checksums, checksumsResponse); errmsg = comparePlugins(checksums, checksumsResponse);
@ -334,7 +334,7 @@ void Networking::receiveMessage(RakNet::Packet *packet)
if (playerPacketController.ContainsPacket(packet->data[0])) if (playerPacketController.ContainsPacket(packet->data[0]))
{ {
if(!PlayerProcessor::Process(*packet)) if (!PlayerProcessor::Process(*packet))
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Unhandled PlayerPacket with identifier %i has arrived", packet->data[0]); LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Unhandled PlayerPacket with identifier %i has arrived", packet->data[0]);
} }
else if (actorPacketController.ContainsPacket(packet->data[0])) else if (actorPacketController.ContainsPacket(packet->data[0]))

@ -15,7 +15,7 @@ void PlayerProcessor::AddProcessor(PlayerProcessor *processor)
{ {
BOOST_FOREACH(processors_t::value_type &p, processors) BOOST_FOREACH(processors_t::value_type &p, processors)
{ {
if(processor->packetID == p.first) if (processor->packetID == p.first)
throw std::logic_error("processor " + p.second->strPacketID + " already registered. Check " + throw std::logic_error("processor " + p.second->strPacketID + " already registered. Check " +
processor->className + " and " + p.second->className); processor->className + " and " + p.second->className);
} }
@ -30,14 +30,14 @@ bool PlayerProcessor::Process(RakNet::Packet &packet)
PlayerPacket *myPacket = Main::get().getNetworking()->getPlayerPacket(packet.data[0]); PlayerPacket *myPacket = Main::get().getNetworking()->getPlayerPacket(packet.data[0]);
myPacket->SetReadStream(&bsIn); myPacket->SetReadStream(&bsIn);
/*if(myPacket == 0) /*if (myPacket == 0)
{ {
// error: packet not found // error: packet not found
}*/ }*/
BOOST_FOREACH(processors_t::value_type &processor, processors) BOOST_FOREACH(processors_t::value_type &processor, processors)
{ {
if(processor.first == packet.data[0]) if (processor.first == packet.data[0])
{ {
myGuid = Main::get().getLocalPlayer()->guid; myGuid = Main::get().getLocalPlayer()->guid;
request = packet.length == myPacket->headerSize(); request = packet.length == myPacket->headerSize();
@ -48,7 +48,7 @@ bool PlayerProcessor::Process(RakNet::Packet &packet)
else else
player = Main::get().getLocalPlayer(); player = Main::get().getLocalPlayer();
if(!request && !processor.second->avoidReading && player != 0) if (!request && !processor.second->avoidReading && player != 0)
{ {
myPacket->setPlayer(player); myPacket->setPlayer(player);
myPacket->Read(); myPacket->Read();

@ -23,12 +23,12 @@ bool WorldProcessor::Process(RakNet::Packet &packet, WorldEvent &event)
BOOST_FOREACH(processors_t::value_type &processor, processors) BOOST_FOREACH(processors_t::value_type &processor, processors)
{ {
if(processor.first == packet.data[0]) if (processor.first == packet.data[0])
{ {
myGuid = Main::get().getLocalPlayer()->guid; myGuid = Main::get().getLocalPlayer()->guid;
request = packet.length == myPacket->headerSize(); request = packet.length == myPacket->headerSize();
if(!request && !processor.second->avoidReading) if (!request && !processor.second->avoidReading)
{ {
myPacket->Read(); myPacket->Read();
} }
@ -45,7 +45,7 @@ void WorldProcessor::AddProcessor(mwmp::WorldProcessor *processor)
{ {
BOOST_FOREACH(processors_t::value_type &p, processors) BOOST_FOREACH(processors_t::value_type &p, processors)
{ {
if(processor->packetID == p.first) if (processor->packetID == p.first)
throw std::logic_error("processor " + p.second->strPacketID + " already registered. Check " + throw std::logic_error("processor " + p.second->strPacketID + " already registered. Check " +
processor->className + " and " + p.second->className); processor->className + " and " + p.second->className);
} }

@ -22,7 +22,7 @@ namespace mwmp
{ {
if (isLocal()) if (isLocal())
{ {
if(isRequest()) if (isRequest())
static_cast<LocalPlayer *>(player)->updateAnimFlags(true); static_cast<LocalPlayer *>(player)->updateAnimFlags(true);
} }
else if (player != 0) else if (player != 0)

@ -24,7 +24,7 @@ namespace mwmp
{ {
if (isLocal()) if (isLocal())
{ {
if(isRequest()) if (isRequest())
static_cast<LocalPlayer *>(player)->updateAttributes(true); static_cast<LocalPlayer *>(player)->updateAttributes(true);
else else
static_cast<LocalPlayer *>(player)->setAttributes(); static_cast<LocalPlayer *>(player)->setAttributes();

@ -21,11 +21,11 @@ namespace mwmp
{ {
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_PLAYER_BASEINFO from server"); LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_PLAYER_BASEINFO from server");
if(isLocal()) if (isLocal())
{ {
LOG_APPEND(Log::LOG_INFO, "- Packet was about my id"); LOG_APPEND(Log::LOG_INFO, "- Packet was about my id");
if(isRequest()) if (isRequest())
{ {
LOG_APPEND(Log::LOG_INFO, "- Requesting info"); LOG_APPEND(Log::LOG_INFO, "- Requesting info");
packet.Send(serverAddr); packet.Send(serverAddr);

@ -18,7 +18,7 @@ namespace mwmp
{ {
if (isLocal()) if (isLocal())
{ {
if(isRequest()) if (isRequest())
static_cast<LocalPlayer *>(player)->updateBounty(true); static_cast<LocalPlayer *>(player)->updateBounty(true);
else else
static_cast<LocalPlayer *>(player)->setBounty(); static_cast<LocalPlayer *>(player)->setBounty();

@ -22,7 +22,7 @@ namespace mwmp
{ {
if (isLocal()) if (isLocal())
{ {
if(isRequest()) if (isRequest())
static_cast<LocalPlayer *>(player)->sendClass(); static_cast<LocalPlayer *>(player)->sendClass();
else else
static_cast<LocalPlayer *>(player)->setClass(); static_cast<LocalPlayer *>(player)->setClass();

@ -22,7 +22,7 @@ namespace mwmp
{ {
if (isLocal()) if (isLocal())
{ {
if(isRequest()) if (isRequest())
static_cast<LocalPlayer *>(player)->updateLevel(true); static_cast<LocalPlayer *>(player)->updateLevel(true);
else else
static_cast<LocalPlayer *>(player)->setLevel(); static_cast<LocalPlayer *>(player)->setLevel();

@ -22,7 +22,7 @@ namespace mwmp
{ {
if (isLocal()) if (isLocal())
{ {
if(isRequest()) if (isRequest())
static_cast<LocalPlayer *>(player)->updateSkills(true); static_cast<LocalPlayer *>(player)->updateSkills(true);
else else
static_cast<LocalPlayer *>(player)->setSkills(); static_cast<LocalPlayer *>(player)->setSkills();

@ -25,7 +25,7 @@ void PacketMasterAnnounce::Packet(BitStream *bs, bool send)
RW(func, send); RW(func, send);
if(func == FUNCTION_ANNOUNCE) if (func == FUNCTION_ANNOUNCE)
ProxyMasterPacket::addServer(this, *server, send); ProxyMasterPacket::addServer(this, *server, send);
} }

@ -30,14 +30,14 @@ void PacketMasterQuery::Packet(RakNet::BitStream *bs, bool send)
RW(serversCount, send); RW(serversCount, send);
map<SystemAddress, QueryData>::iterator serverIt; map<SystemAddress, QueryData>::iterator serverIt;
if(send) if (send)
serverIt = servers->begin(); serverIt = servers->begin();
QueryData server; QueryData server;
SystemAddress sa; SystemAddress sa;
while(serversCount--) while(serversCount--)
{ {
if(send) if (send)
{ {
sa = serverIt->first; sa = serverIt->first;
server = serverIt->second; server = serverIt->second;
@ -46,7 +46,7 @@ void PacketMasterQuery::Packet(RakNet::BitStream *bs, bool send)
RW(sa, send); RW(sa, send);
ProxyMasterPacket::addServer(this, server, send); ProxyMasterPacket::addServer(this, server, send);
if(send) if (send)
serverIt++; serverIt++;
else else
servers->insert(pair<SystemAddress, QueryData>(sa, server)); servers->insert(pair<SystemAddress, QueryData>(sa, server));

@ -18,26 +18,26 @@ void mwmp::PacketPreInit::Packet(RakNet::BitStream *bs, bool send)
size_t size = checksums->size(); size_t size = checksums->size();
RW(size, send); RW(size, send);
for(size_t i = 0; i < size; i++) for (size_t i = 0; i < size; i++)
{ {
PluginPair ppair; PluginPair ppair;
if(send) if (send)
ppair = (*checksums)[i]; ppair = (*checksums)[i];
RW(ppair.first, send); RW(ppair.first, send);
size_t hashSize = ppair.second.size(); size_t hashSize = ppair.second.size();
RW(hashSize, send); RW(hashSize, send);
for(size_t j = 0; j < hashSize; j++) for (size_t j = 0; j < hashSize; j++)
{ {
unsigned hash; unsigned hash;
if(send) if (send)
hash = ppair.second[j]; hash = ppair.second[j];
RW(hash, send); RW(hash, send);
if(!send) if (!send)
ppair.second.push_back(hash); ppair.second.push_back(hash);
} }
if(!send) if (!send)
checksums->push_back(ppair); checksums->push_back(ppair);
} }
} }

Loading…
Cancel
Save