From c3c04bbfc361be099105407b6b501862c6cf8ff9 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Tue, 2 May 2017 22:47:58 +0300 Subject: [PATCH] [General] Make coding style consistent --- apps/openmw-mp/MasterClient.cpp | 6 ++--- apps/openmw-mp/Networking.cpp | 8 +++---- apps/openmw/mwmp/ActorProcessor.cpp | 6 ++--- apps/openmw/mwmp/CellController.cpp | 2 +- apps/openmw/mwmp/GUIController.cpp | 6 ++--- apps/openmw/mwmp/GUIDialogList.cpp | 4 ++-- apps/openmw/mwmp/Networking.cpp | 22 +++++++++---------- apps/openmw/mwmp/PlayerProcessor.cpp | 8 +++---- apps/openmw/mwmp/WorldProcessor.cpp | 6 ++--- .../player/ProcessorPlayerAnimFlags.hpp | 2 +- .../player/ProcessorPlayerAttribute.hpp | 2 +- .../player/ProcessorPlayerBaseInfo.hpp | 4 ++-- .../player/ProcessorPlayerBounty.hpp | 2 +- .../player/ProcessorPlayerCharClass.hpp | 2 +- .../player/ProcessorPlayerLevel.hpp | 2 +- .../player/ProcessorPlayerSkill.hpp | 2 +- .../openmw-mp/Master/PacketMasterAnnounce.cpp | 2 +- .../openmw-mp/Master/PacketMasterQuery.cpp | 6 ++--- .../openmw-mp/Packets/PacketPreInit.cpp | 12 +++++----- 19 files changed, 52 insertions(+), 52 deletions(-) diff --git a/apps/openmw-mp/MasterClient.cpp b/apps/openmw-mp/MasterClient.cpp index 10653fc3a..06a6a743e 100644 --- a/apps/openmw-mp/MasterClient.cpp +++ b/apps/openmw-mp/MasterClient.cpp @@ -188,7 +188,7 @@ void MasterClient::Thread() SetPlayers((int) players->size()); auto pIt = players->begin(); - if(queryData.players.size() != players->size()) + if (queryData.players.size() != players->size()) { queryData.players.clear(); updated = true; @@ -211,9 +211,9 @@ void MasterClient::Thread() updated = false; 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); } } diff --git a/apps/openmw-mp/Networking.cpp b/apps/openmw-mp/Networking.cpp index 86aa3ff10..5b2b18728 100644 --- a/apps/openmw-mp/Networking.cpp +++ b/apps/openmw-mp/Networking.cpp @@ -216,7 +216,7 @@ void Networking::update(RakNet::Packet *packet) if (hashList.empty()) // and server do not allow to have custom hash for plugin continue; 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; } @@ -226,7 +226,7 @@ void Networking::update(RakNet::Packet *packet) } RakNet::BitStream 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.Send(packet->systemAddress); @@ -390,14 +390,14 @@ PacketPreInit::PluginContainer Networking::getPluginListSample() unsigned field = 0; auto name = ""; Script::Call(name, id, field++); - if(strlen(name) == 0) + if (strlen(name) == 0) break; PacketPreInit::HashList hashList; while(true) { auto hash = ""; Script::Call(hash, id, field++); - if(strlen(hash) == 0) + if (strlen(hash) == 0) break; hashList.push_back((unsigned)stoul(hash)); } diff --git a/apps/openmw/mwmp/ActorProcessor.cpp b/apps/openmw/mwmp/ActorProcessor.cpp index 4400aae22..73de608ff 100644 --- a/apps/openmw/mwmp/ActorProcessor.cpp +++ b/apps/openmw/mwmp/ActorProcessor.cpp @@ -23,12 +23,12 @@ bool ActorProcessor::Process(RakNet::Packet &packet, ActorList &actorList) 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; request = packet.length == myPacket->headerSize(); - if(!request && !processor.second->avoidReading) + if (!request && !processor.second->avoidReading) { myPacket->Read(); } @@ -45,7 +45,7 @@ void ActorProcessor::AddProcessor(mwmp::ActorProcessor *processor) { 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 " + processor->className + " and " + p.second->className); } diff --git a/apps/openmw/mwmp/CellController.cpp b/apps/openmw/mwmp/CellController.cpp index d7508f0ce..f3aaef2ce 100644 --- a/apps/openmw/mwmp/CellController.cpp +++ b/apps/openmw/mwmp/CellController.cpp @@ -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); - /*if(::Misc::StringUtils::ciEqual(name, "gold_001")) + /*if (::Misc::StringUtils::ciEqual(name, "gold_001")) cont.remove("gold_001", count, container);*/ } diff --git a/apps/openmw/mwmp/GUIController.cpp b/apps/openmw/mwmp/GUIController.cpp index d253b7d7d..670115e72 100644 --- a/apps/openmw/mwmp/GUIController.cpp +++ b/apps/openmw/mwmp/GUIController.cpp @@ -98,9 +98,9 @@ void mwmp::GUIController::showDialogList(const mwmp::BasePlayer::GUIMessageBox & 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); buf.erase(); @@ -224,7 +224,7 @@ void mwmp::GUIController::WM_UpdateVisible(MWGui::GuiMode mode) } case GM_TES3MP_ListBox: { - if(mListBox != 0) + if (mListBox != 0) mListBox->setVisible(true); break; } diff --git a/apps/openmw/mwmp/GUIDialogList.cpp b/apps/openmw/mwmp/GUIDialogList.cpp index b6990d063..4a6f1827d 100644 --- a/apps/openmw/mwmp/GUIDialogList.cpp +++ b/apps/openmw/mwmp/GUIDialogList.cpp @@ -29,7 +29,7 @@ GUIDialogList::GUIDialogList(const std::string &message, const std::vectoreventMouseButtonClick += MyGUI::newDelegate(this, &GUIDialogList::mousePressed); 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]); } @@ -46,7 +46,7 @@ void GUIDialogList::mousePressed(MyGUI::Widget * /*widget*/) Main::get().getNetworking()->getPlayerPacket(ID_GUI_MESSAGEBOX)->Send(); LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Selected id: %d", id); - if(id == MyGUI::ITEM_NONE) + if (id == MyGUI::ITEM_NONE) return; std::string itemName = mListBox->getItemNameAt(mListBox->getIndexSelected()).asUTF8(); diff --git a/apps/openmw/mwmp/Networking.cpp b/apps/openmw/mwmp/Networking.cpp index 5c3843405..9791ff243 100644 --- a/apps/openmw/mwmp/Networking.cpp +++ b/apps/openmw/mwmp/Networking.cpp @@ -63,12 +63,12 @@ string comparePlugins(PacketPreInit::PluginContainer checksums, PacketPreInit::P sstr << "Note: Use the same load order as the server.\n"; size_t pluginNameLen1 = 0; size_t pluginNameLen2 = 0; - for(size_t i = 0; i < checksums.size(); i++) - if(pluginNameLen1 < checksums[i].first.size()) + for (size_t i = 0; i < checksums.size(); i++) + if (pluginNameLen1 < checksums[i].first.size()) pluginNameLen1 = checksums[i].first.size(); - for(size_t i = 0; i < checksumsResponse.size(); i++) - if(pluginNameLen2 < checksumsResponse[i].first.size()) + for (size_t i = 0; i < checksumsResponse.size(); i++) + if (pluginNameLen2 < checksumsResponse[i].first.size()) pluginNameLen2 = checksumsResponse[i].first.size(); 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, "name", pluginNameLen2 + 2); sstr << "hash\n"; - for(size_t i = 0; i < checksumsResponse.size(); i++) + for (size_t i = 0; i < checksumsResponse.size(); i++) { string plugin; unsigned val; @@ -95,10 +95,10 @@ string comparePlugins(PacketPreInit::PluginContainer checksums, PacketPreInit::P printWithWidth(sstr, plugin, pluginNameLen1 + 2); printWithWidth(sstr, intToHexStr(val), 14); printWithWidth(sstr, checksumsResponse[i].first, pluginNameLen2 + 2); - if(checksumsResponse[i].second.size() > 0) + if (checksumsResponse[i].second.size() > 0) { - if(full) - for(size_t j = 0; j < checksumsResponse[i].second.size(); j++) + if (full) + for (size_t j = 0; j < checksumsResponse[i].second.size(); j++) printWithWidth(sstr, intToHexStr(checksumsResponse[i].second[j]), 14); else sstr << intToHexStr(checksumsResponse[i].second[0]); @@ -289,7 +289,7 @@ void Networking::preInit(std::vector &content, Files::Collections & while (!done) { RakNet::Packet *packet = peer->Receive(); - if(!packet) + if (!packet) { RakSleep(500); continue; @@ -315,7 +315,7 @@ void Networking::preInit(std::vector &content, Files::Collections & peer->DeallocatePacket(packet); } - if(!checksumsResponse.empty()) // something wrong + if (!checksumsResponse.empty()) // something wrong errmsg = comparePlugins(checksums, checksumsResponse); @@ -334,7 +334,7 @@ void Networking::receiveMessage(RakNet::Packet *packet) 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]); } else if (actorPacketController.ContainsPacket(packet->data[0])) diff --git a/apps/openmw/mwmp/PlayerProcessor.cpp b/apps/openmw/mwmp/PlayerProcessor.cpp index cfa56b6b0..068362ae7 100644 --- a/apps/openmw/mwmp/PlayerProcessor.cpp +++ b/apps/openmw/mwmp/PlayerProcessor.cpp @@ -15,7 +15,7 @@ void PlayerProcessor::AddProcessor(PlayerProcessor *processor) { 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 " + 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]); myPacket->SetReadStream(&bsIn); - /*if(myPacket == 0) + /*if (myPacket == 0) { // error: packet not found }*/ 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; request = packet.length == myPacket->headerSize(); @@ -48,7 +48,7 @@ bool PlayerProcessor::Process(RakNet::Packet &packet) else player = Main::get().getLocalPlayer(); - if(!request && !processor.second->avoidReading && player != 0) + if (!request && !processor.second->avoidReading && player != 0) { myPacket->setPlayer(player); myPacket->Read(); diff --git a/apps/openmw/mwmp/WorldProcessor.cpp b/apps/openmw/mwmp/WorldProcessor.cpp index 8050e1a6e..369db777e 100644 --- a/apps/openmw/mwmp/WorldProcessor.cpp +++ b/apps/openmw/mwmp/WorldProcessor.cpp @@ -23,12 +23,12 @@ bool WorldProcessor::Process(RakNet::Packet &packet, WorldEvent &event) 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; request = packet.length == myPacket->headerSize(); - if(!request && !processor.second->avoidReading) + if (!request && !processor.second->avoidReading) { myPacket->Read(); } @@ -45,7 +45,7 @@ void WorldProcessor::AddProcessor(mwmp::WorldProcessor *processor) { 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 " + processor->className + " and " + p.second->className); } diff --git a/apps/openmw/mwmp/processors/player/ProcessorPlayerAnimFlags.hpp b/apps/openmw/mwmp/processors/player/ProcessorPlayerAnimFlags.hpp index e77de681f..0390278fd 100644 --- a/apps/openmw/mwmp/processors/player/ProcessorPlayerAnimFlags.hpp +++ b/apps/openmw/mwmp/processors/player/ProcessorPlayerAnimFlags.hpp @@ -22,7 +22,7 @@ namespace mwmp { if (isLocal()) { - if(isRequest()) + if (isRequest()) static_cast(player)->updateAnimFlags(true); } else if (player != 0) diff --git a/apps/openmw/mwmp/processors/player/ProcessorPlayerAttribute.hpp b/apps/openmw/mwmp/processors/player/ProcessorPlayerAttribute.hpp index 6ac649e05..a2d270b90 100644 --- a/apps/openmw/mwmp/processors/player/ProcessorPlayerAttribute.hpp +++ b/apps/openmw/mwmp/processors/player/ProcessorPlayerAttribute.hpp @@ -24,7 +24,7 @@ namespace mwmp { if (isLocal()) { - if(isRequest()) + if (isRequest()) static_cast(player)->updateAttributes(true); else static_cast(player)->setAttributes(); diff --git a/apps/openmw/mwmp/processors/player/ProcessorPlayerBaseInfo.hpp b/apps/openmw/mwmp/processors/player/ProcessorPlayerBaseInfo.hpp index 110d96029..e56e90720 100644 --- a/apps/openmw/mwmp/processors/player/ProcessorPlayerBaseInfo.hpp +++ b/apps/openmw/mwmp/processors/player/ProcessorPlayerBaseInfo.hpp @@ -21,11 +21,11 @@ namespace mwmp { 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"); - if(isRequest()) + if (isRequest()) { LOG_APPEND(Log::LOG_INFO, "- Requesting info"); packet.Send(serverAddr); diff --git a/apps/openmw/mwmp/processors/player/ProcessorPlayerBounty.hpp b/apps/openmw/mwmp/processors/player/ProcessorPlayerBounty.hpp index d58a44ede..51f52021d 100644 --- a/apps/openmw/mwmp/processors/player/ProcessorPlayerBounty.hpp +++ b/apps/openmw/mwmp/processors/player/ProcessorPlayerBounty.hpp @@ -18,7 +18,7 @@ namespace mwmp { if (isLocal()) { - if(isRequest()) + if (isRequest()) static_cast(player)->updateBounty(true); else static_cast(player)->setBounty(); diff --git a/apps/openmw/mwmp/processors/player/ProcessorPlayerCharClass.hpp b/apps/openmw/mwmp/processors/player/ProcessorPlayerCharClass.hpp index 4019e79c9..143c636c4 100644 --- a/apps/openmw/mwmp/processors/player/ProcessorPlayerCharClass.hpp +++ b/apps/openmw/mwmp/processors/player/ProcessorPlayerCharClass.hpp @@ -22,7 +22,7 @@ namespace mwmp { if (isLocal()) { - if(isRequest()) + if (isRequest()) static_cast(player)->sendClass(); else static_cast(player)->setClass(); diff --git a/apps/openmw/mwmp/processors/player/ProcessorPlayerLevel.hpp b/apps/openmw/mwmp/processors/player/ProcessorPlayerLevel.hpp index 6c0dc850d..4a9886129 100644 --- a/apps/openmw/mwmp/processors/player/ProcessorPlayerLevel.hpp +++ b/apps/openmw/mwmp/processors/player/ProcessorPlayerLevel.hpp @@ -22,7 +22,7 @@ namespace mwmp { if (isLocal()) { - if(isRequest()) + if (isRequest()) static_cast(player)->updateLevel(true); else static_cast(player)->setLevel(); diff --git a/apps/openmw/mwmp/processors/player/ProcessorPlayerSkill.hpp b/apps/openmw/mwmp/processors/player/ProcessorPlayerSkill.hpp index 83970d5f6..5ab50a99b 100644 --- a/apps/openmw/mwmp/processors/player/ProcessorPlayerSkill.hpp +++ b/apps/openmw/mwmp/processors/player/ProcessorPlayerSkill.hpp @@ -22,7 +22,7 @@ namespace mwmp { if (isLocal()) { - if(isRequest()) + if (isRequest()) static_cast(player)->updateSkills(true); else static_cast(player)->setSkills(); diff --git a/components/openmw-mp/Master/PacketMasterAnnounce.cpp b/components/openmw-mp/Master/PacketMasterAnnounce.cpp index adb7f50b0..dbdc7c4f5 100644 --- a/components/openmw-mp/Master/PacketMasterAnnounce.cpp +++ b/components/openmw-mp/Master/PacketMasterAnnounce.cpp @@ -25,7 +25,7 @@ void PacketMasterAnnounce::Packet(BitStream *bs, bool send) RW(func, send); - if(func == FUNCTION_ANNOUNCE) + if (func == FUNCTION_ANNOUNCE) ProxyMasterPacket::addServer(this, *server, send); } diff --git a/components/openmw-mp/Master/PacketMasterQuery.cpp b/components/openmw-mp/Master/PacketMasterQuery.cpp index a36735fdb..04ae376fa 100644 --- a/components/openmw-mp/Master/PacketMasterQuery.cpp +++ b/components/openmw-mp/Master/PacketMasterQuery.cpp @@ -30,14 +30,14 @@ void PacketMasterQuery::Packet(RakNet::BitStream *bs, bool send) RW(serversCount, send); map::iterator serverIt; - if(send) + if (send) serverIt = servers->begin(); QueryData server; SystemAddress sa; while(serversCount--) { - if(send) + if (send) { sa = serverIt->first; server = serverIt->second; @@ -46,7 +46,7 @@ void PacketMasterQuery::Packet(RakNet::BitStream *bs, bool send) RW(sa, send); ProxyMasterPacket::addServer(this, server, send); - if(send) + if (send) serverIt++; else servers->insert(pair(sa, server)); diff --git a/components/openmw-mp/Packets/PacketPreInit.cpp b/components/openmw-mp/Packets/PacketPreInit.cpp index eb7b8182a..cc5e2c95e 100644 --- a/components/openmw-mp/Packets/PacketPreInit.cpp +++ b/components/openmw-mp/Packets/PacketPreInit.cpp @@ -18,26 +18,26 @@ void mwmp::PacketPreInit::Packet(RakNet::BitStream *bs, bool send) size_t size = checksums->size(); RW(size, send); - for(size_t i = 0; i < size; i++) + for (size_t i = 0; i < size; i++) { PluginPair ppair; - if(send) + if (send) ppair = (*checksums)[i]; RW(ppair.first, send); size_t hashSize = ppair.second.size(); RW(hashSize, send); - for(size_t j = 0; j < hashSize; j++) + for (size_t j = 0; j < hashSize; j++) { unsigned hash; - if(send) + if (send) hash = ppair.second[j]; RW(hash, send); - if(!send) + if (!send) ppair.second.push_back(hash); } - if(!send) + if (!send) checksums->push_back(ppair); } }