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

pull/158/head
David Cernat 8 years ago
parent ee1ba1728e
commit eb0744aa77

@ -71,6 +71,15 @@ CellController *CellController::get()
return sThis; 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) Cell *CellController::getCellByXY(int x, int y)
{ {
auto it = find_if(cells.begin(), cells.end(), [x, y](const Cell *c) { auto it = find_if(cells.begin(), cells.end(), [x, y](const Cell *c) {

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

Loading…
Cancel
Save