forked from teamnwah/openmw-tes3coop
[Server] Make style for new methods consistent with rest of project
This commit is contained in:
parent
fd36ec7613
commit
887b436ee7
4 changed files with 25 additions and 25 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 <Player*> 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<void(Player *pl, Player *other)> func)
|
|||
{
|
||||
std::list <Player*> 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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue