1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 19:19:56 +00:00

[Server] Modernize getting and setting of player cells

This commit is contained in:
David Cernat 2017-06-10 17:49:41 +03:00
parent 0d3976950b
commit db7709ee18
2 changed files with 8 additions and 14 deletions

View file

@ -46,27 +46,21 @@ const char *CellFunctions::GetCell(unsigned short pid) noexcept
Player *player;
GET_PLAYER(pid, player, 0);
return player->cell.mName.c_str();
return player->cell.getDescription().c_str();
}
void CellFunctions::SetCell(unsigned short pid, const char *name) noexcept
void CellFunctions::SetCell(unsigned short pid, const char *cellDescription) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Script is moving %s from %s to %s", player->npc.mName.c_str(),
player->cell.getDescription().c_str(), name);
player->cell.getDescription().c_str(), cellDescription);
// If the player is currently in an exterior, turn on the interior flag
// from the cell so the player doesn't get teleported to their exterior
// grid position (which we haven't changed)
if (player->cell.isExterior())
player->cell.mData.mFlags |= ESM::Cell::Interior;
player->cell.mName = name;
player->cell = Utils::getCellFromDescription(cellDescription);
}
void CellFunctions::SetExterior(unsigned short pid, int x, int y) noexcept
void CellFunctions::SetExteriorCell(unsigned short pid, int x, int y) noexcept
{
Player *player;
GET_PLAYER(pid, player,);

View file

@ -11,7 +11,7 @@
\
{"GetCell", CellFunctions::GetCell},\
{"SetCell", CellFunctions::SetCell},\
{"SetExterior", CellFunctions::SetExterior},\
{"SetExteriorCell", CellFunctions::SetExteriorCell},\
{"GetExteriorX", CellFunctions::GetExteriorX},\
{"GetExteriorY", CellFunctions::GetExteriorY},\
{"IsInExterior", CellFunctions::IsInExterior},\
@ -31,8 +31,8 @@ public:
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;
static void SetCell(unsigned short pid, const char *cellDescription) noexcept;
static void SetExteriorCell(unsigned short pid, int x, int y) noexcept;
static int GetExteriorX(unsigned short pid) noexcept;
static int GetExteriorY(unsigned short pid) noexcept;
static bool IsInExterior(unsigned short pid) noexcept;