[Server] Add CellController:getCell() for getting Cell through ESM::Cell

This commit is contained in:
David Cernat 2017-02-19 19:39:53 +02:00
parent ee1ba1728e
commit eb0744aa77
2 changed files with 11 additions and 0 deletions

View file

@ -71,6 +71,15 @@ CellController *CellController::get()
return sThis;
}
Cell *CellController::getCell(ESM::Cell *esmCell)
{
if (esmCell->isExterior())
return getCellByXY(esmCell->mData.mX, esmCell->mData.mY);
else
return getCellByName(esmCell->mName);
}
Cell *CellController::getCellByXY(int x, int y)
{
auto it = find_if(cells.begin(), cells.end(), [x, y](const Cell *c) {

View file

@ -34,6 +34,7 @@ public:
void removePlayer(Cell *cell, Player *player);
void deletePlayer(Player *player);
Cell *getCell(ESM::Cell *esmCell);
Cell *getCellByXY(int x, int y);
Cell *getCellByName(std::string cellName);
@ -61,6 +62,7 @@ public:
TPlayers getPlayers();
std::string getDescription() const;
private:
TPlayers players;
ESM::Cell cell;