diff --git a/apps/openmw-mp/Script/Functions/Cells.cpp b/apps/openmw-mp/Script/Functions/Cells.cpp index 68e0fb3e5..221a0c376 100644 --- a/apps/openmw-mp/Script/Functions/Cells.cpp +++ b/apps/openmw-mp/Script/Functions/Cells.cpp @@ -8,6 +8,25 @@ #include using namespace std; +unsigned int CellFunctions::GetCellStateChangesSize(unsigned short pid) noexcept +{ + Player *player; + GET_PLAYER(pid, player, 0); + + return player->cellStateChanges.count; +} + +const char* CellFunctions::GetCellStateDescription(unsigned short pid, unsigned int i) noexcept +{ + Player *player; + GET_PLAYER(pid, player, ""); + + if (i >= player->cellStateChanges.count) + return "invalid"; + + return player->cellStateChanges.cells.at(i).getDescription().c_str(); +} + const char* CellFunctions::GetCell(unsigned short pid) noexcept { Player *player; diff --git a/apps/openmw-mp/Script/Functions/Cells.hpp b/apps/openmw-mp/Script/Functions/Cells.hpp index 2761ca0a5..e008a525c 100644 --- a/apps/openmw-mp/Script/Functions/Cells.hpp +++ b/apps/openmw-mp/Script/Functions/Cells.hpp @@ -4,19 +4,27 @@ #include "../Types.hpp" #define CELLAPI \ - {"GetCell", CellFunctions::GetCell},\ - {"SetCell", CellFunctions::SetCell},\ - {"SetExterior", CellFunctions::SetExterior},\ - {"GetExteriorX", CellFunctions::GetExteriorX},\ - {"GetExteriorY", CellFunctions::GetExteriorY},\ - {"IsInExterior", CellFunctions::IsInExterior},\ + {"GetCellStateChangesSize", CellFunctions:GetCellStateChangesSize},\ \ - {"SendCell", CellFunctions::SendCell} + {"GetCellStateDescription", CellFunctions:GetCellStateDescription},\ +\ + {"GetCell", CellFunctions::GetCell},\ + {"SetCell", CellFunctions::SetCell},\ + {"SetExterior", CellFunctions::SetExterior},\ + {"GetExteriorX", CellFunctions::GetExteriorX},\ + {"GetExteriorY", CellFunctions::GetExteriorY},\ + {"IsInExterior", CellFunctions::IsInExterior},\ +\ + {"SendCell", CellFunctions::SendCell} class CellFunctions { public: + static unsigned int GetCellStateChangesSize(unsigned short pid) noexcept; + + static const char *GetCellStateDescription(unsigned short pid, unsigned int i) noexcept; + static const char *GetCell(unsigned short pid) noexcept; static void SetCell(unsigned short pid, const char *name) noexcept; static void SetExterior(unsigned short pid, int x, int y) noexcept;