forked from teamnwah/openmw-tes3coop
[General] Fix code style inconsistencies
This commit is contained in:
parent
97bf0252a4
commit
a353a21280
25 changed files with 65 additions and 65 deletions
|
@ -97,4 +97,4 @@ endif()
|
|||
if (BUILD_WITH_CODE_COVERAGE)
|
||||
add_definitions (--coverage)
|
||||
target_link_libraries(tes3mp-browser gcov)
|
||||
endif()
|
||||
endif()
|
||||
|
|
|
@ -70,7 +70,7 @@ void MainWindow::addServerAndUpdate(QString addr)
|
|||
//NetController::get()->updateInfo(favorites, mi);
|
||||
//QueryClient::Update(RakNet::SystemAddress())
|
||||
/*auto data = QueryClient::Get().Query();
|
||||
if(data.empty())
|
||||
if (data.empty())
|
||||
return;
|
||||
transform(data.begin(), data.end(), back_inserter());*/
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ void MainWindow::addServer()
|
|||
{
|
||||
int id = tblServerBrowser->selectionModel()->currentIndex().row();
|
||||
|
||||
if(id >= 0)
|
||||
if (id >= 0)
|
||||
{
|
||||
int sourceId = proxyModel->mapToSource(proxyModel->index(id, ServerData::ADDR)).row();
|
||||
favorites->myData.push_back(browser->myData[sourceId]);
|
||||
|
@ -90,20 +90,20 @@ void MainWindow::addServerByIP()
|
|||
{
|
||||
bool 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);
|
||||
}
|
||||
|
||||
void MainWindow::deleteServer()
|
||||
{
|
||||
if(tabWidget->currentIndex() != 1)
|
||||
if (tabWidget->currentIndex() != 1)
|
||||
return;
|
||||
int id = tblFavorites->selectionModel()->currentIndex().row();
|
||||
if(id >= 0)
|
||||
if (id >= 0)
|
||||
{
|
||||
int sourceId = proxyModel->mapToSource(proxyModel->index(id, ServerData::ADDR)).row();
|
||||
favorites->removeRow(sourceId);
|
||||
if(favorites->myData.isEmpty())
|
||||
if (favorites->myData.isEmpty())
|
||||
{
|
||||
actionPlay->setEnabled(false);
|
||||
actionDelete->setEnabled(false);
|
||||
|
@ -115,7 +115,7 @@ void MainWindow::play()
|
|||
{
|
||||
QTableView *curTable = tabWidget->currentIndex() ? tblFavorites : tblServerBrowser;
|
||||
int id = curTable->selectionModel()->currentIndex().row();
|
||||
if(id < 0)
|
||||
if (id < 0)
|
||||
return;
|
||||
|
||||
ServerInfoDialog infoDialog(this);
|
||||
|
@ -130,17 +130,17 @@ void MainWindow::play()
|
|||
return;
|
||||
}
|
||||
|
||||
if(!infoDialog.exec())
|
||||
if (!infoDialog.exec())
|
||||
return;
|
||||
|
||||
QStringList arguments;
|
||||
arguments.append(QLatin1String("--connect=") + sm->myData[sourceId].addr.toLatin1());
|
||||
|
||||
if(sm->myData[sourceId].GetPassword() == 1)
|
||||
if (sm->myData[sourceId].GetPassword() == 1)
|
||||
{
|
||||
bool ok;
|
||||
QString passw = QInputDialog::getText(this, "Connecting to: " + sm->myData[sourceId].addr, "Password: ", QLineEdit::Password, "", &ok);
|
||||
if(!ok)
|
||||
if (!ok)
|
||||
return;
|
||||
arguments.append(QLatin1String("--password=") + passw.toLatin1());
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ void MainWindow::play()
|
|||
|
||||
void MainWindow::tabSwitched(int index)
|
||||
{
|
||||
if(index == 0)
|
||||
if (index == 0)
|
||||
{
|
||||
proxyModel->setSourceModel(browser);
|
||||
actionDelete->setEnabled(false);
|
||||
|
@ -167,9 +167,9 @@ void MainWindow::tabSwitched(int index)
|
|||
void MainWindow::serverSelected()
|
||||
{
|
||||
actionPlay->setEnabled(true);
|
||||
if(tabWidget->currentIndex() == 0)
|
||||
if (tabWidget->currentIndex() == 0)
|
||||
actionAdd->setEnabled(true);
|
||||
if(tabWidget->currentIndex() == 1)
|
||||
if (tabWidget->currentIndex() == 1)
|
||||
actionDelete->setEnabled(true);
|
||||
}
|
||||
|
||||
|
@ -179,12 +179,12 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
|||
QString cfgPath = QString::fromStdString((cfgMgr.getUserConfigPath() / "favorites.dat").string());
|
||||
|
||||
QJsonArray saveData;
|
||||
for(auto server : favorites->myData)
|
||||
for (auto server : favorites->myData)
|
||||
saveData.push_back(server.addr);
|
||||
|
||||
QFile file(cfgPath);
|
||||
|
||||
if(!file.open(QIODevice::WriteOnly))
|
||||
if (!file.open(QIODevice::WriteOnly))
|
||||
{
|
||||
qDebug() << "Cannot save " << cfgPath;
|
||||
return;
|
||||
|
@ -201,7 +201,7 @@ void MainWindow::loadFavorites()
|
|||
QString cfgPath = QString::fromStdString((cfgMgr.getUserConfigPath() / "favorites.dat").string());
|
||||
|
||||
QFile file(cfgPath);
|
||||
if(!file.open(QIODevice::ReadOnly))
|
||||
if (!file.open(QIODevice::ReadOnly))
|
||||
{
|
||||
qDebug() << "Cannot open " << cfgPath;
|
||||
return;
|
||||
|
@ -209,7 +209,7 @@ void MainWindow::loadFavorites()
|
|||
|
||||
QJsonDocument jsonDoc(QJsonDocument::fromJson(file.readAll()));
|
||||
|
||||
for(auto server : jsonDoc.array())
|
||||
for (auto server : jsonDoc.array())
|
||||
addServerAndUpdate(server.toString());
|
||||
|
||||
file.close();
|
||||
|
|
|
@ -18,11 +18,11 @@ bool MySortFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &
|
|||
int players = sourceModel()->data(plIndex).toInt();
|
||||
int maxPlayers = sourceModel()->data(maxPlIndex).toInt();
|
||||
|
||||
if(maxPing > 0 && (ping == -1 || ping > maxPing))
|
||||
if (maxPing > 0 && (ping == -1 || ping > maxPing))
|
||||
return false;
|
||||
if(filterEmpty && players == 0)
|
||||
if (filterEmpty && players == 0)
|
||||
return false;
|
||||
if(filterFull && players >= maxPlayers)
|
||||
if (filterFull && players >= maxPlayers)
|
||||
return false;
|
||||
|
||||
return QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent);
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
void PingHelper::Add(int row, AddrPair addrPair)
|
||||
{
|
||||
pingUpdater->addServer(row, addrPair);
|
||||
if(!pingThread->isRunning())
|
||||
if (!pingThread->isRunning())
|
||||
pingThread->start();
|
||||
}
|
||||
|
||||
|
|
|
@ -23,12 +23,12 @@ void PingUpdater::addServer(int row, AddrPair addr)
|
|||
|
||||
void PingUpdater::process()
|
||||
{
|
||||
while(run)
|
||||
while (run)
|
||||
{
|
||||
if(servers.count() == 0)
|
||||
if (servers.count() == 0)
|
||||
{
|
||||
QThread::msleep(1000);
|
||||
if(servers.count() == 0)
|
||||
if (servers.count() == 0)
|
||||
{
|
||||
qDebug() << "PingUpdater stopped due to inactivity";
|
||||
run = false;
|
||||
|
|
|
@ -26,7 +26,7 @@ QueryHelper::QueryHelper(QAbstractItemModel *model)
|
|||
|
||||
void QueryHelper::refresh()
|
||||
{
|
||||
if(!queryThread->isRunning())
|
||||
if (!queryThread->isRunning())
|
||||
_model->removeRows(0, _model->rowCount());
|
||||
queryThread->start();
|
||||
emit started();
|
||||
|
@ -72,13 +72,13 @@ void QueryHelper::update(QString addr, unsigned short port, QueryData data)
|
|||
void QueryUpdate::process()
|
||||
{
|
||||
auto data = QueryClient::Get().Query();
|
||||
if(QueryClient::Get().Status() != ID_MASTER_QUERY)
|
||||
if (QueryClient::Get().Status() != ID_MASTER_QUERY)
|
||||
{
|
||||
emit finished();
|
||||
return;
|
||||
}
|
||||
|
||||
for(auto server : data)
|
||||
for (auto server : data)
|
||||
emit updateModel(server.first.ToString(false), server.first.GetPort(), server.second);
|
||||
emit finished();
|
||||
}
|
||||
|
|
|
@ -43,4 +43,4 @@ public slots:
|
|||
void process();
|
||||
};
|
||||
|
||||
#endif //OPENMW_QUERYHELPER_HPP
|
||||
#endif //OPENMW_QUERYHELPER_HPP
|
||||
|
|
|
@ -42,21 +42,21 @@ bool ServerInfoDialog::refresh()
|
|||
|
||||
listPlayers->clear();
|
||||
|
||||
for(auto player : sd.second.players)
|
||||
for (auto player : sd.second.players)
|
||||
listPlayers->addItem(QString::fromStdString(player));
|
||||
|
||||
listPlugins->clear();
|
||||
for(auto plugin : sd.second.plugins)
|
||||
for (auto plugin : sd.second.plugins)
|
||||
listPlugins->addItem(QString::fromStdString(plugin.name));
|
||||
|
||||
listRules->clear();
|
||||
const static vector<std::string> defaultRules {"gamemode", "maxPlayers", "name", "passw", "players", "version"};
|
||||
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;
|
||||
QString ruleStr = QString::fromStdString(rule.first) + " : ";
|
||||
if(rule.second.type == 's')
|
||||
if (rule.second.type == 's')
|
||||
ruleStr += QString::fromStdString(rule.second.str);
|
||||
else
|
||||
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());
|
||||
|
||||
if(role == Qt::DisplayRole)
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
QVariant var;
|
||||
switch (index.column())
|
||||
|
@ -52,7 +52,7 @@ QVariant ServerModel::data(const QModelIndex &index, int role) const
|
|||
var = sd.ping;
|
||||
break;
|
||||
case ServerData::MODNAME:
|
||||
if(sd.rules.at("gamemode").str == "")
|
||||
if (sd.rules.at("gamemode").str == "")
|
||||
var = "default";
|
||||
else
|
||||
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(section == ServerData::HOSTNAME)
|
||||
/*if (section == ServerData::HOSTNAME)
|
||||
var = QSize(200, 25);*/
|
||||
}
|
||||
else if (role == Qt::DisplayRole)
|
||||
|
@ -158,7 +158,7 @@ bool ServerModel::setData(const QModelIndex &index, const QVariant &value, int r
|
|||
default:
|
||||
return false;
|
||||
}
|
||||
if(ok)
|
||||
if (ok)
|
||||
emit(dataChanged(index, index));
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -45,4 +45,4 @@ int main(int argc, char *argv[])
|
|||
|
||||
d.show();
|
||||
return app.exec();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ MASTER_PACKETS QueryClient::GetAnswer()
|
|||
bool update = true;
|
||||
unsigned char pid = 0;
|
||||
int id;
|
||||
while(update)
|
||||
while (update)
|
||||
{
|
||||
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)
|
||||
{
|
||||
RakNet::TimeMS now = RakNet::GetTimeMS();
|
||||
if(now - start >= PING_UNREACHABLE)
|
||||
if (now - start >= PING_UNREACHABLE)
|
||||
break;
|
||||
|
||||
packet = peer->Receive();
|
||||
|
|
|
@ -148,7 +148,7 @@ void MasterServer::Thread()
|
|||
keepAliveFunc();
|
||||
}
|
||||
}
|
||||
else if(pma.GetFunc() == PacketMasterAnnounce::FUNCTION_ANNOUNCE)
|
||||
else if (pma.GetFunc() == PacketMasterAnnounce::FUNCTION_ANNOUNCE)
|
||||
{
|
||||
cout << "Added";
|
||||
iter = servers.insert({packet->systemAddress, server}).first;
|
||||
|
|
|
@ -60,7 +60,7 @@ void RestServer::start()
|
|||
static const string ServersRegex = "^/api/servers(?:/(" + ValidIpAddressRegex + "\\:" + ValidPortRegex + "))?";
|
||||
|
||||
httpServer.resource[ServersRegex]["GET"] = [this](auto response, auto request) {
|
||||
if(request->path_match[1].length() > 0)
|
||||
if (request->path_match[1].length() > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -81,7 +81,7 @@ void RestServer::start()
|
|||
{
|
||||
static string str;
|
||||
|
||||
//if(updatedCache)
|
||||
//if (updatedCache)
|
||||
{
|
||||
stringstream ss;
|
||||
ss << "{";
|
||||
|
@ -131,14 +131,14 @@ void RestServer::start()
|
|||
|
||||
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;
|
||||
*response << response400;
|
||||
return;
|
||||
}
|
||||
|
||||
if(request->content.size() != 0)
|
||||
if (request->content.size() != 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -166,7 +166,7 @@ void RestServer::start()
|
|||
ss << '{';
|
||||
ss << "servers: " << serverMap->size();
|
||||
unsigned int players = 0;
|
||||
for(auto s : *serverMap)
|
||||
for (auto s : *serverMap)
|
||||
players += s.second.GetPlayers();
|
||||
ss << ", players: " << players;
|
||||
ss << "}";
|
||||
|
|
|
@ -183,4 +183,4 @@ int main()
|
|||
}
|
||||
peer->Shutdown(1000);
|
||||
RakPeerInterface::DestroyInstance(peer);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,4 +34,4 @@ int main()
|
|||
masterServer->Wait();
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -380,7 +380,7 @@ PacketPreInit::PluginContainer Networking::getPluginListSample()
|
|||
{
|
||||
PacketPreInit::PluginContainer pls;
|
||||
unsigned id = 0;
|
||||
while(true)
|
||||
while (true)
|
||||
{
|
||||
unsigned field = 0;
|
||||
auto name = "";
|
||||
|
@ -388,7 +388,7 @@ PacketPreInit::PluginContainer Networking::getPluginListSample()
|
|||
if (strlen(name) == 0)
|
||||
break;
|
||||
PacketPreInit::HashList hashList;
|
||||
while(true)
|
||||
while (true)
|
||||
{
|
||||
auto hash = "";
|
||||
Script::Call<Script::CallbackIdentity("OnRequestPluginList")>(hash, id, field++);
|
||||
|
@ -501,11 +501,11 @@ void Networking::postInit()
|
|||
{
|
||||
Script::Call<Script::CallbackIdentity("OnServerPostInit")>();
|
||||
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]});
|
||||
else
|
||||
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
|
||||
{
|
||||
auto mc = mwmp::Networking::getPtr()->getMasterClient();
|
||||
if(mc)
|
||||
if (mc)
|
||||
mc->SetRuleString(key, value);
|
||||
}
|
||||
|
||||
void ScriptFunctions::SetRuleValue(const char *key, double value) noexcept
|
||||
{
|
||||
auto mc = mwmp::Networking::getPtr()->getMasterClient();
|
||||
if(mc)
|
||||
if (mc)
|
||||
mc->SetRuleValue(key, value);
|
||||
}
|
||||
|
|
|
@ -301,7 +301,7 @@ int main(int argc, char *argv[])
|
|||
if (code == 0)
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Quitting peacefully.");
|
||||
|
||||
if(!variables["no-logs"].as<bool>())
|
||||
if (!variables["no-logs"].as<bool>())
|
||||
{
|
||||
// Restore cout and cerr
|
||||
std::cout.rdbuf(cout_rdbuf);
|
||||
|
|
|
@ -252,7 +252,7 @@ void DedicatedPlayer::updateMarker()
|
|||
if (gui->mPlayerMarkers.contains(marker))
|
||||
{
|
||||
gui->mPlayerMarkers.deleteMarker(marker);
|
||||
marker = gui->CreateMarker(guid);
|
||||
marker = gui->createMarker(guid);
|
||||
gui->mPlayerMarkers.addMarker(marker);
|
||||
}
|
||||
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);
|
||||
ESM::CustomMarker mEditingMarker;
|
||||
|
|
|
@ -58,7 +58,7 @@ namespace mwmp
|
|||
void updatePlayersMarkers(MWGui::LocalMapBase *localMapBase);
|
||||
void updateGlobalMapMarkerTooltips(MWGui::MapWindow *pWindow);
|
||||
|
||||
ESM::CustomMarker CreateMarker(const RakNet::RakNetGUID &guid);
|
||||
ESM::CustomMarker createMarker(const RakNet::RakNetGUID &guid);
|
||||
PlayerMarkerCollection mPlayerMarkers;
|
||||
private:
|
||||
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;
|
||||
string addr;
|
||||
unsigned short port;
|
||||
while(serversCount--)
|
||||
while (serversCount--)
|
||||
{
|
||||
if (send)
|
||||
{
|
||||
|
|
|
@ -28,7 +28,7 @@ void PacketMasterUpdate::Packet(RakNet::BitStream *bs, bool send)
|
|||
RW(addr, send);
|
||||
RW(port, send);
|
||||
|
||||
if(!send)
|
||||
if (!send)
|
||||
server->first = SystemAddress(addr.c_str(), port);
|
||||
|
||||
ProxyMasterPacket::addServer(this, server->second, send);
|
||||
|
|
|
@ -54,14 +54,14 @@ namespace mwmp
|
|||
{
|
||||
if (write)
|
||||
{
|
||||
if(compress)
|
||||
if (compress)
|
||||
bs->WriteCompressed(data);
|
||||
else
|
||||
bs->Write(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(compress)
|
||||
if (compress)
|
||||
bs->ReadCompressed(data);
|
||||
else
|
||||
bs->Read(data);
|
||||
|
@ -88,7 +88,7 @@ namespace mwmp
|
|||
if (write)
|
||||
{
|
||||
RakNet::RakString rstr(str.c_str());
|
||||
if(compress)
|
||||
if (compress)
|
||||
rstr.SerializeCompressed(bs);
|
||||
else
|
||||
bs->Write(rstr);
|
||||
|
@ -96,7 +96,7 @@ namespace mwmp
|
|||
else
|
||||
{
|
||||
RakNet::RakString rstr;
|
||||
if(compress)
|
||||
if (compress)
|
||||
rstr.DeserializeCompressed(bs);
|
||||
else
|
||||
bs->Read(rstr);
|
||||
|
|
Loading…
Reference in a new issue