[General] Fix code style inconsistencies

0.6.1
David Cernat 8 years ago
parent 97bf0252a4
commit a353a21280

@ -97,4 +97,4 @@ endif()
if (BUILD_WITH_CODE_COVERAGE) if (BUILD_WITH_CODE_COVERAGE)
add_definitions (--coverage) add_definitions (--coverage)
target_link_libraries(tes3mp-browser gcov) target_link_libraries(tes3mp-browser gcov)
endif() endif()

@ -70,7 +70,7 @@ void MainWindow::addServerAndUpdate(QString addr)
//NetController::get()->updateInfo(favorites, mi); //NetController::get()->updateInfo(favorites, mi);
//QueryClient::Update(RakNet::SystemAddress()) //QueryClient::Update(RakNet::SystemAddress())
/*auto data = QueryClient::Get().Query(); /*auto data = QueryClient::Get().Query();
if(data.empty()) if (data.empty())
return; return;
transform(data.begin(), data.end(), back_inserter());*/ transform(data.begin(), data.end(), back_inserter());*/
} }
@ -79,7 +79,7 @@ void MainWindow::addServer()
{ {
int id = tblServerBrowser->selectionModel()->currentIndex().row(); int id = tblServerBrowser->selectionModel()->currentIndex().row();
if(id >= 0) if (id >= 0)
{ {
int sourceId = proxyModel->mapToSource(proxyModel->index(id, ServerData::ADDR)).row(); int sourceId = proxyModel->mapToSource(proxyModel->index(id, ServerData::ADDR)).row();
favorites->myData.push_back(browser->myData[sourceId]); favorites->myData.push_back(browser->myData[sourceId]);
@ -90,20 +90,20 @@ void MainWindow::addServerByIP()
{ {
bool ok; bool ok;
QString text = QInputDialog::getText(this, tr("Add Server by address"), tr("Address:"), QLineEdit::Normal, "", &ok); QString text = QInputDialog::getText(this, tr("Add Server by address"), tr("Address:"), QLineEdit::Normal, "", &ok);
if(ok && !text.isEmpty()) if (ok && !text.isEmpty())
addServerAndUpdate(text); addServerAndUpdate(text);
} }
void MainWindow::deleteServer() void MainWindow::deleteServer()
{ {
if(tabWidget->currentIndex() != 1) if (tabWidget->currentIndex() != 1)
return; return;
int id = tblFavorites->selectionModel()->currentIndex().row(); int id = tblFavorites->selectionModel()->currentIndex().row();
if(id >= 0) if (id >= 0)
{ {
int sourceId = proxyModel->mapToSource(proxyModel->index(id, ServerData::ADDR)).row(); int sourceId = proxyModel->mapToSource(proxyModel->index(id, ServerData::ADDR)).row();
favorites->removeRow(sourceId); favorites->removeRow(sourceId);
if(favorites->myData.isEmpty()) if (favorites->myData.isEmpty())
{ {
actionPlay->setEnabled(false); actionPlay->setEnabled(false);
actionDelete->setEnabled(false); actionDelete->setEnabled(false);
@ -115,7 +115,7 @@ void MainWindow::play()
{ {
QTableView *curTable = tabWidget->currentIndex() ? tblFavorites : tblServerBrowser; QTableView *curTable = tabWidget->currentIndex() ? tblFavorites : tblServerBrowser;
int id = curTable->selectionModel()->currentIndex().row(); int id = curTable->selectionModel()->currentIndex().row();
if(id < 0) if (id < 0)
return; return;
ServerInfoDialog infoDialog(this); ServerInfoDialog infoDialog(this);
@ -130,17 +130,17 @@ void MainWindow::play()
return; return;
} }
if(!infoDialog.exec()) if (!infoDialog.exec())
return; return;
QStringList arguments; QStringList arguments;
arguments.append(QLatin1String("--connect=") + sm->myData[sourceId].addr.toLatin1()); arguments.append(QLatin1String("--connect=") + sm->myData[sourceId].addr.toLatin1());
if(sm->myData[sourceId].GetPassword() == 1) if (sm->myData[sourceId].GetPassword() == 1)
{ {
bool ok; bool ok;
QString passw = QInputDialog::getText(this, "Connecting to: " + sm->myData[sourceId].addr, "Password: ", QLineEdit::Password, "", &ok); QString passw = QInputDialog::getText(this, "Connecting to: " + sm->myData[sourceId].addr, "Password: ", QLineEdit::Password, "", &ok);
if(!ok) if (!ok)
return; return;
arguments.append(QLatin1String("--password=") + passw.toLatin1()); arguments.append(QLatin1String("--password=") + passw.toLatin1());
} }
@ -151,7 +151,7 @@ void MainWindow::play()
void MainWindow::tabSwitched(int index) void MainWindow::tabSwitched(int index)
{ {
if(index == 0) if (index == 0)
{ {
proxyModel->setSourceModel(browser); proxyModel->setSourceModel(browser);
actionDelete->setEnabled(false); actionDelete->setEnabled(false);
@ -167,9 +167,9 @@ void MainWindow::tabSwitched(int index)
void MainWindow::serverSelected() void MainWindow::serverSelected()
{ {
actionPlay->setEnabled(true); actionPlay->setEnabled(true);
if(tabWidget->currentIndex() == 0) if (tabWidget->currentIndex() == 0)
actionAdd->setEnabled(true); actionAdd->setEnabled(true);
if(tabWidget->currentIndex() == 1) if (tabWidget->currentIndex() == 1)
actionDelete->setEnabled(true); actionDelete->setEnabled(true);
} }
@ -179,12 +179,12 @@ void MainWindow::closeEvent(QCloseEvent *event)
QString cfgPath = QString::fromStdString((cfgMgr.getUserConfigPath() / "favorites.dat").string()); QString cfgPath = QString::fromStdString((cfgMgr.getUserConfigPath() / "favorites.dat").string());
QJsonArray saveData; QJsonArray saveData;
for(auto server : favorites->myData) for (auto server : favorites->myData)
saveData.push_back(server.addr); saveData.push_back(server.addr);
QFile file(cfgPath); QFile file(cfgPath);
if(!file.open(QIODevice::WriteOnly)) if (!file.open(QIODevice::WriteOnly))
{ {
qDebug() << "Cannot save " << cfgPath; qDebug() << "Cannot save " << cfgPath;
return; return;
@ -201,7 +201,7 @@ void MainWindow::loadFavorites()
QString cfgPath = QString::fromStdString((cfgMgr.getUserConfigPath() / "favorites.dat").string()); QString cfgPath = QString::fromStdString((cfgMgr.getUserConfigPath() / "favorites.dat").string());
QFile file(cfgPath); QFile file(cfgPath);
if(!file.open(QIODevice::ReadOnly)) if (!file.open(QIODevice::ReadOnly))
{ {
qDebug() << "Cannot open " << cfgPath; qDebug() << "Cannot open " << cfgPath;
return; return;
@ -209,7 +209,7 @@ void MainWindow::loadFavorites()
QJsonDocument jsonDoc(QJsonDocument::fromJson(file.readAll())); QJsonDocument jsonDoc(QJsonDocument::fromJson(file.readAll()));
for(auto server : jsonDoc.array()) for (auto server : jsonDoc.array())
addServerAndUpdate(server.toString()); addServerAndUpdate(server.toString());
file.close(); file.close();

@ -18,11 +18,11 @@ bool MySortFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &
int players = sourceModel()->data(plIndex).toInt(); int players = sourceModel()->data(plIndex).toInt();
int maxPlayers = sourceModel()->data(maxPlIndex).toInt(); int maxPlayers = sourceModel()->data(maxPlIndex).toInt();
if(maxPing > 0 && (ping == -1 || ping > maxPing)) if (maxPing > 0 && (ping == -1 || ping > maxPing))
return false; return false;
if(filterEmpty && players == 0) if (filterEmpty && players == 0)
return false; return false;
if(filterFull && players >= maxPlayers) if (filterFull && players >= maxPlayers)
return false; return false;
return QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent); return QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent);

@ -10,7 +10,7 @@
void PingHelper::Add(int row, AddrPair addrPair) void PingHelper::Add(int row, AddrPair addrPair)
{ {
pingUpdater->addServer(row, addrPair); pingUpdater->addServer(row, addrPair);
if(!pingThread->isRunning()) if (!pingThread->isRunning())
pingThread->start(); pingThread->start();
} }

@ -23,12 +23,12 @@ void PingUpdater::addServer(int row, AddrPair addr)
void PingUpdater::process() void PingUpdater::process()
{ {
while(run) while (run)
{ {
if(servers.count() == 0) if (servers.count() == 0)
{ {
QThread::msleep(1000); QThread::msleep(1000);
if(servers.count() == 0) if (servers.count() == 0)
{ {
qDebug() << "PingUpdater stopped due to inactivity"; qDebug() << "PingUpdater stopped due to inactivity";
run = false; run = false;

@ -26,7 +26,7 @@ QueryHelper::QueryHelper(QAbstractItemModel *model)
void QueryHelper::refresh() void QueryHelper::refresh()
{ {
if(!queryThread->isRunning()) if (!queryThread->isRunning())
_model->removeRows(0, _model->rowCount()); _model->removeRows(0, _model->rowCount());
queryThread->start(); queryThread->start();
emit started(); emit started();
@ -72,13 +72,13 @@ void QueryHelper::update(QString addr, unsigned short port, QueryData data)
void QueryUpdate::process() void QueryUpdate::process()
{ {
auto data = QueryClient::Get().Query(); auto data = QueryClient::Get().Query();
if(QueryClient::Get().Status() != ID_MASTER_QUERY) if (QueryClient::Get().Status() != ID_MASTER_QUERY)
{ {
emit finished(); emit finished();
return; return;
} }
for(auto server : data) for (auto server : data)
emit updateModel(server.first.ToString(false), server.first.GetPort(), server.second); emit updateModel(server.first.ToString(false), server.first.GetPort(), server.second);
emit finished(); emit finished();
} }

@ -43,4 +43,4 @@ public slots:
void process(); void process();
}; };
#endif //OPENMW_QUERYHELPER_HPP #endif //OPENMW_QUERYHELPER_HPP

@ -42,21 +42,21 @@ bool ServerInfoDialog::refresh()
listPlayers->clear(); listPlayers->clear();
for(auto player : sd.second.players) for (auto player : sd.second.players)
listPlayers->addItem(QString::fromStdString(player)); listPlayers->addItem(QString::fromStdString(player));
listPlugins->clear(); listPlugins->clear();
for(auto plugin : sd.second.plugins) for (auto plugin : sd.second.plugins)
listPlugins->addItem(QString::fromStdString(plugin.name)); listPlugins->addItem(QString::fromStdString(plugin.name));
listRules->clear(); listRules->clear();
const static vector<std::string> defaultRules {"gamemode", "maxPlayers", "name", "passw", "players", "version"}; const static vector<std::string> defaultRules {"gamemode", "maxPlayers", "name", "passw", "players", "version"};
for (auto rule : sd.second.rules) for (auto rule : sd.second.rules)
{ {
if(::find(defaultRules.begin(), defaultRules.end(), rule.first) != defaultRules.end()) if (::find(defaultRules.begin(), defaultRules.end(), rule.first) != defaultRules.end())
continue; continue;
QString ruleStr = QString::fromStdString(rule.first) + " : "; QString ruleStr = QString::fromStdString(rule.first) + " : ";
if(rule.second.type == 's') if (rule.second.type == 's')
ruleStr += QString::fromStdString(rule.second.str); ruleStr += QString::fromStdString(rule.second.str);
else else
ruleStr += QString::number(rule.second.val); ruleStr += QString::number(rule.second.val);

@ -25,7 +25,7 @@ QVariant ServerModel::data(const QModelIndex &index, int role) const
const ServerData &sd = myData.at(index.row()); const ServerData &sd = myData.at(index.row());
if(role == Qt::DisplayRole) if (role == Qt::DisplayRole)
{ {
QVariant var; QVariant var;
switch (index.column()) switch (index.column())
@ -52,7 +52,7 @@ QVariant ServerModel::data(const QModelIndex &index, int role) const
var = sd.ping; var = sd.ping;
break; break;
case ServerData::MODNAME: case ServerData::MODNAME:
if(sd.rules.at("gamemode").str == "") if (sd.rules.at("gamemode").str == "")
var = "default"; var = "default";
else else
var = QString(sd.rules.at("gamemode").str.c_str()); var = QString(sd.rules.at("gamemode").str.c_str());
@ -70,7 +70,7 @@ QVariant ServerModel::headerData(int section, Qt::Orientation orientation, int r
{ {
if (role == Qt::SizeHintRole) if (role == Qt::SizeHintRole)
{ {
/*if(section == ServerData::HOSTNAME) /*if (section == ServerData::HOSTNAME)
var = QSize(200, 25);*/ var = QSize(200, 25);*/
} }
else if (role == Qt::DisplayRole) else if (role == Qt::DisplayRole)
@ -158,7 +158,7 @@ bool ServerModel::setData(const QModelIndex &index, const QVariant &value, int r
default: default:
return false; return false;
} }
if(ok) if (ok)
emit(dataChanged(index, index)); emit(dataChanged(index, index));
return true; return true;
} }

@ -45,4 +45,4 @@ int main(int argc, char *argv[])
d.show(); d.show();
return app.exec(); return app.exec();
} }

@ -84,7 +84,7 @@ MASTER_PACKETS QueryClient::GetAnswer()
bool update = true; bool update = true;
unsigned char pid = 0; unsigned char pid = 0;
int id; int id;
while(update) while (update)
{ {
for (packet = peer->Receive(); packet; peer->DeallocatePacket(packet), packet = peer->Receive()) for (packet = peer->Receive(); packet; peer->DeallocatePacket(packet), packet = peer->Receive())
{ {

@ -29,7 +29,7 @@ unsigned int PingRakNetServer(const char *addr, unsigned short port)
while (!done) while (!done)
{ {
RakNet::TimeMS now = RakNet::GetTimeMS(); RakNet::TimeMS now = RakNet::GetTimeMS();
if(now - start >= PING_UNREACHABLE) if (now - start >= PING_UNREACHABLE)
break; break;
packet = peer->Receive(); packet = peer->Receive();

@ -148,7 +148,7 @@ void MasterServer::Thread()
keepAliveFunc(); keepAliveFunc();
} }
} }
else if(pma.GetFunc() == PacketMasterAnnounce::FUNCTION_ANNOUNCE) else if (pma.GetFunc() == PacketMasterAnnounce::FUNCTION_ANNOUNCE)
{ {
cout << "Added"; cout << "Added";
iter = servers.insert({packet->systemAddress, server}).first; iter = servers.insert({packet->systemAddress, server}).first;

@ -60,7 +60,7 @@ void RestServer::start()
static const string ServersRegex = "^/api/servers(?:/(" + ValidIpAddressRegex + "\\:" + ValidPortRegex + "))?"; static const string ServersRegex = "^/api/servers(?:/(" + ValidIpAddressRegex + "\\:" + ValidPortRegex + "))?";
httpServer.resource[ServersRegex]["GET"] = [this](auto response, auto request) { httpServer.resource[ServersRegex]["GET"] = [this](auto response, auto request) {
if(request->path_match[1].length() > 0) if (request->path_match[1].length() > 0)
{ {
try try
{ {
@ -81,7 +81,7 @@ void RestServer::start()
{ {
static string str; static string str;
//if(updatedCache) //if (updatedCache)
{ {
stringstream ss; stringstream ss;
ss << "{"; ss << "{";
@ -131,14 +131,14 @@ void RestServer::start()
auto query = serverMap->find(RakNet::SystemAddress(request->remote_endpoint_address.c_str(), port)); auto query = serverMap->find(RakNet::SystemAddress(request->remote_endpoint_address.c_str(), port));
if(query == serverMap->end()) if (query == serverMap->end())
{ {
cout << request->remote_endpoint_address + ": Trying to update a non-existent server or without permissions." << endl; cout << request->remote_endpoint_address + ": Trying to update a non-existent server or without permissions." << endl;
*response << response400; *response << response400;
return; return;
} }
if(request->content.size() != 0) if (request->content.size() != 0)
{ {
try try
{ {
@ -166,7 +166,7 @@ void RestServer::start()
ss << '{'; ss << '{';
ss << "servers: " << serverMap->size(); ss << "servers: " << serverMap->size();
unsigned int players = 0; unsigned int players = 0;
for(auto s : *serverMap) for (auto s : *serverMap)
players += s.second.GetPlayers(); players += s.second.GetPlayers();
ss << ", players: " << players; ss << ", players: " << players;
ss << "}"; ss << "}";

@ -183,4 +183,4 @@ int main()
} }
peer->Shutdown(1000); peer->Shutdown(1000);
RakPeerInterface::DestroyInstance(peer); RakPeerInterface::DestroyInstance(peer);
} }

@ -34,4 +34,4 @@ int main()
masterServer->Wait(); masterServer->Wait();
return 0; return 0;
} }

@ -380,7 +380,7 @@ PacketPreInit::PluginContainer Networking::getPluginListSample()
{ {
PacketPreInit::PluginContainer pls; PacketPreInit::PluginContainer pls;
unsigned id = 0; unsigned id = 0;
while(true) while (true)
{ {
unsigned field = 0; unsigned field = 0;
auto name = ""; auto name = "";
@ -388,7 +388,7 @@ PacketPreInit::PluginContainer Networking::getPluginListSample()
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++);
@ -501,11 +501,11 @@ void Networking::postInit()
{ {
Script::Call<Script::CallbackIdentity("OnServerPostInit")>(); Script::Call<Script::CallbackIdentity("OnServerPostInit")>();
samples = getPluginListSample(); samples = getPluginListSample();
if(mclient) if (mclient)
{ {
for(auto plugin : samples) for (auto plugin : samples)
{ {
if(!plugin.second.empty()) if (!plugin.second.empty())
mclient->PushPlugin({plugin.first, plugin.second[0]}); mclient->PushPlugin({plugin.first, plugin.second[0]});
else else
mclient->PushPlugin({plugin.first, 0}); mclient->PushPlugin({plugin.first, 0});

@ -148,13 +148,13 @@ void ScriptFunctions::SetServerPassword(const char *passw) noexcept
void ScriptFunctions::SetRuleString(const char *key, const char *value) noexcept void ScriptFunctions::SetRuleString(const char *key, const char *value) noexcept
{ {
auto mc = mwmp::Networking::getPtr()->getMasterClient(); auto mc = mwmp::Networking::getPtr()->getMasterClient();
if(mc) if (mc)
mc->SetRuleString(key, value); mc->SetRuleString(key, value);
} }
void ScriptFunctions::SetRuleValue(const char *key, double value) noexcept void ScriptFunctions::SetRuleValue(const char *key, double value) noexcept
{ {
auto mc = mwmp::Networking::getPtr()->getMasterClient(); auto mc = mwmp::Networking::getPtr()->getMasterClient();
if(mc) if (mc)
mc->SetRuleValue(key, value); mc->SetRuleValue(key, value);
} }

@ -301,7 +301,7 @@ int main(int argc, char *argv[])
if (code == 0) if (code == 0)
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Quitting peacefully."); LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Quitting peacefully.");
if(!variables["no-logs"].as<bool>()) if (!variables["no-logs"].as<bool>())
{ {
// Restore cout and cerr // Restore cout and cerr
std::cout.rdbuf(cout_rdbuf); std::cout.rdbuf(cout_rdbuf);

@ -252,7 +252,7 @@ void DedicatedPlayer::updateMarker()
if (gui->mPlayerMarkers.contains(marker)) if (gui->mPlayerMarkers.contains(marker))
{ {
gui->mPlayerMarkers.deleteMarker(marker); gui->mPlayerMarkers.deleteMarker(marker);
marker = gui->CreateMarker(guid); marker = gui->createMarker(guid);
gui->mPlayerMarkers.addMarker(marker); gui->mPlayerMarkers.addMarker(marker);
} }
else else

@ -264,7 +264,7 @@ private:
} }
}; };
ESM::CustomMarker mwmp::GUIController::CreateMarker(const RakNet::RakNetGUID &guid) ESM::CustomMarker mwmp::GUIController::createMarker(const RakNet::RakNetGUID &guid)
{ {
DedicatedPlayer *player = PlayerList::getPlayer(guid); DedicatedPlayer *player = PlayerList::getPlayer(guid);
ESM::CustomMarker mEditingMarker; ESM::CustomMarker mEditingMarker;

@ -58,7 +58,7 @@ namespace mwmp
void updatePlayersMarkers(MWGui::LocalMapBase *localMapBase); void updatePlayersMarkers(MWGui::LocalMapBase *localMapBase);
void updateGlobalMapMarkerTooltips(MWGui::MapWindow *pWindow); void updateGlobalMapMarkerTooltips(MWGui::MapWindow *pWindow);
ESM::CustomMarker CreateMarker(const RakNet::RakNetGUID &guid); ESM::CustomMarker createMarker(const RakNet::RakNetGUID &guid);
PlayerMarkerCollection mPlayerMarkers; PlayerMarkerCollection mPlayerMarkers;
private: private:
void setGlobalMapMarkerTooltip(MWGui::MapWindow *mapWindow ,MyGUI::Widget* markerWidget, int x, int y); void setGlobalMapMarkerTooltip(MWGui::MapWindow *mapWindow ,MyGUI::Widget* markerWidget, int x, int y);

@ -36,7 +36,7 @@ void PacketMasterQuery::Packet(RakNet::BitStream *bs, bool send)
QueryData server; QueryData server;
string addr; string addr;
unsigned short port; unsigned short port;
while(serversCount--) while (serversCount--)
{ {
if (send) if (send)
{ {

@ -28,7 +28,7 @@ void PacketMasterUpdate::Packet(RakNet::BitStream *bs, bool send)
RW(addr, send); RW(addr, send);
RW(port, send); RW(port, send);
if(!send) if (!send)
server->first = SystemAddress(addr.c_str(), port); server->first = SystemAddress(addr.c_str(), port);
ProxyMasterPacket::addServer(this, server->second, send); ProxyMasterPacket::addServer(this, server->second, send);

@ -54,14 +54,14 @@ namespace mwmp
{ {
if (write) if (write)
{ {
if(compress) if (compress)
bs->WriteCompressed(data); bs->WriteCompressed(data);
else else
bs->Write(data); bs->Write(data);
} }
else else
{ {
if(compress) if (compress)
bs->ReadCompressed(data); bs->ReadCompressed(data);
else else
bs->Read(data); bs->Read(data);
@ -88,7 +88,7 @@ namespace mwmp
if (write) if (write)
{ {
RakNet::RakString rstr(str.c_str()); RakNet::RakString rstr(str.c_str());
if(compress) if (compress)
rstr.SerializeCompressed(bs); rstr.SerializeCompressed(bs);
else else
bs->Write(rstr); bs->Write(rstr);
@ -96,7 +96,7 @@ namespace mwmp
else else
{ {
RakNet::RakString rstr; RakNet::RakString rstr;
if(compress) if (compress)
rstr.DeserializeCompressed(bs); rstr.DeserializeCompressed(bs);
else else
bs->Read(rstr); bs->Read(rstr);

Loading…
Cancel
Save