From 887b436ee7f6d949e34ba94d99507c4322b0d5fb Mon Sep 17 00:00:00 2001 From: David Cernat Date: Sun, 19 Feb 2017 16:53:15 +0200 Subject: [PATCH] [Server] Make style for new methods consistent with rest of project --- apps/openmw-mp/Cell.cpp | 28 ++++++++++++++-------------- apps/openmw-mp/MasterClient.cpp | 6 +++--- apps/openmw-mp/Networking.cpp | 2 +- apps/openmw-mp/Player.cpp | 14 +++++++------- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/apps/openmw-mp/Cell.cpp b/apps/openmw-mp/Cell.cpp index 9b78228c7..1726b744a 100644 --- a/apps/openmw-mp/Cell.cpp +++ b/apps/openmw-mp/Cell.cpp @@ -12,19 +12,19 @@ using namespace std; void Cell::addPlayer(Player *player) { auto it = find(player->cells.begin(), player->cells.end(), this); - if(it == player->cells.end()) + if (it == player->cells.end()) player->cells.push_back(this); players.push_back(player); } void Cell::removePlayer(Player *player) { - for(Iterator it = begin(); it != end(); it++) + for (Iterator it = begin(); it != end(); it++) { - if(*it == player) + if (*it == player) { auto it2 = find(player->cells.begin(), player->cells.end(), this); - if(it2 != player->cells.end()) + if (it2 != player->cells.end()) player->cells.erase(it2); players.erase(it); return; @@ -73,7 +73,7 @@ Cell *CellController::getCellByXY(int x, int y) auto it = find_if(cells.begin(), cells.end(), [x, y](const Cell *c) { return c->cell.mData.mX == x && c->cell.mData.mY == y; }); - if(it == cells.end()) + if (it == cells.end()) return nullptr; return *it; } @@ -83,7 +83,7 @@ Cell *CellController::getCellByID(std::string cellid) auto it = find_if(cells.begin(), cells.end(), [cellid](const Cell *c) { return c->cell.mName == cellid; }); - if(it == cells.end()) + if (it == cells.end()) return nullptr; return *it; } @@ -98,7 +98,7 @@ Cell *CellController::addCell(ESM::Cell cellData) c->cell.mCellId.mWorldspace == cellData.mCellId.mWorldspace; }); Cell *cell; - if(it == cells.end()) + if (it == cells.end()) { cell = new Cell(cellData); cells.push_back(cell); @@ -112,11 +112,11 @@ Cell *CellController::addCell(ESM::Cell cellData) void CellController::removeCell(Cell *cell) { - if(cell == nullptr) + if (cell == nullptr) return; for (auto it = cells.begin(); it != cells.end();) { - if(*it != nullptr && *it == cell) + if (*it != nullptr && *it == cell) { delete *it; it = cells.erase(it); @@ -131,7 +131,7 @@ void CellController::removePlayer(Cell *cell, Player *player) cell->removePlayer(player); - if(cell->players.empty()) + if (cell->players.empty()) { LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Deleting empty cell from memory: %s", player->npc.mName, player->getId(), cell->cell.getDescription().c_str()); auto it = find(cells.begin(), cells.end(), cell); @@ -156,9 +156,9 @@ void CellController::deletePlayer(Player *player) void CellController::update(Player *player) { - for(auto cell : player->cellStateChanges.cellStates) + for (auto cell : player->cellStateChanges.cellStates) { - if(cell.type == mwmp::CellState::LOAD) + if (cell.type == mwmp::CellState::LOAD) { Cell *c = addCell(cell.cell); c->addPlayer(player); @@ -167,12 +167,12 @@ void CellController::update(Player *player) { LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Player %s (%d) unloaded cell: %s", player->npc.mName, player->getId(), cell.cell.getDescription().c_str()); Cell *c; - if(!cell.cell.isExterior()) + if (!cell.cell.isExterior()) c = getCellByID(cell.cell.mName); else c = getCellByXY(cell.cell.getGridX(), cell.cell.getGridY()); - if(c != nullptr) + if (c != nullptr) removePlayer(c, player); } } diff --git a/apps/openmw-mp/MasterClient.cpp b/apps/openmw-mp/MasterClient.cpp index bdd915123..dcb787e69 100644 --- a/apps/openmw-mp/MasterClient.cpp +++ b/apps/openmw-mp/MasterClient.cpp @@ -152,7 +152,7 @@ void MasterClient::Update() { LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Update rate is too low, and the master server has deleted information about" " the server. Trying low rate..."); - if((timeout - step_rate) >= step_rate) + if ((timeout - step_rate) >= step_rate) SetUpdateRate(timeout - step_rate); update = false; } @@ -177,10 +177,10 @@ void MasterClient::Start() void MasterClient::Stop() { - if(!sRun) + if (!sRun) return; sRun = false; - if(thrQuery.joinable()) + if (thrQuery.joinable()) thrQuery.join(); } diff --git a/apps/openmw-mp/Networking.cpp b/apps/openmw-mp/Networking.cpp index 0d78468f3..9c9db8a14 100644 --- a/apps/openmw-mp/Networking.cpp +++ b/apps/openmw-mp/Networking.cpp @@ -857,7 +857,7 @@ int Networking::mainLoop() RakNet::BitStream bs; bs.Write((unsigned char) ID_MASTER_QUERY); bs.Write(Players::getPlayers()->size()); - for(auto player : *Players::getPlayers()) + for (auto player : *Players::getPlayers()) bs.Write(RakNet::RakString(player.second->npc.mName.c_str())); bs.Write(0); // plugins peer->Send(&bs, HIGH_PRIORITY, RELIABLE_ORDERED, 0, packet->systemAddress, false); diff --git a/apps/openmw-mp/Player.cpp b/apps/openmw-mp/Player.cpp index 22a1cd994..6f9b5ee3e 100644 --- a/apps/openmw-mp/Player.cpp +++ b/apps/openmw-mp/Player.cpp @@ -54,7 +54,7 @@ void Players::newPlayer(RakNet::RakNetGUID guid) Player *Players::getPlayer(RakNet::RakNetGUID guid) { - if(players.count(guid) == 0) + if (players.count(guid) == 0) return nullptr; return players[guid]; } @@ -147,16 +147,16 @@ void Player::sendToLoaded(mwmp::PlayerPacket *myPacket) { std::list plList; - for(auto cell : getCells()) + for (auto cell : getCells()) for (auto pl : *cell) plList.push_back(pl); plList.sort(); plList.unique(); - for(auto pl : plList) + for (auto pl : plList) { - if(pl == this) continue; + if (pl == this) continue; myPacket->Send(this, pl->guid); } } @@ -165,16 +165,16 @@ void Player::forEachLoaded(std::function func) { std::list plList; - for(auto cell : getCells()) + for (auto cell : getCells()) for (auto pl : *cell) plList.push_back(pl); plList.sort(); plList.unique(); - for(auto pl : plList) + for (auto pl : plList) { - if(pl == this) continue; + if (pl == this) continue; func(this, pl); } }