mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-15 15:19:55 +00:00
7393e3def6
ESM::Cell's getDescription() method was modified by aa5161f99e
despite being used heavily by TES3MP. All instances of it in the TES3MP code have now been changed into the newly added getShortDescription() that is identical to the previous getDescription().
126 lines
3.3 KiB
C++
126 lines
3.3 KiB
C++
#include "Cells.hpp"
|
|
|
|
#include <components/openmw-mp/TimedLog.hpp>
|
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
|
|
|
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
|
|
#include <apps/openmw-mp/Player.hpp>
|
|
#include <apps/openmw-mp/Networking.hpp>
|
|
|
|
#include <iostream>
|
|
|
|
static std::string tempCellDescription;
|
|
|
|
unsigned int CellFunctions::GetCellStateChangesSize(unsigned short pid) noexcept
|
|
{
|
|
Player *player;
|
|
GET_PLAYER(pid, player, 0);
|
|
|
|
return player->cellStateChanges.size();
|
|
}
|
|
|
|
unsigned int CellFunctions::GetCellStateType(unsigned short pid, unsigned int index) noexcept
|
|
{
|
|
Player *player;
|
|
GET_PLAYER(pid, player, 0);
|
|
|
|
return player->cellStateChanges.at(index).type;
|
|
}
|
|
|
|
const char *CellFunctions::GetCellStateDescription(unsigned short pid, unsigned int index) noexcept
|
|
{
|
|
Player *player;
|
|
GET_PLAYER(pid, player, "");
|
|
|
|
if (index >= player->cellStateChanges.size())
|
|
return "invalid";
|
|
|
|
tempCellDescription = player->cellStateChanges.at(index).cell.getShortDescription();
|
|
return tempCellDescription.c_str();
|
|
}
|
|
|
|
const char *CellFunctions::GetCell(unsigned short pid) noexcept
|
|
{
|
|
Player *player;
|
|
GET_PLAYER(pid, player, 0);
|
|
|
|
tempCellDescription = player->cell.getShortDescription().c_str();
|
|
return tempCellDescription.c_str();
|
|
}
|
|
|
|
int CellFunctions::GetExteriorX(unsigned short pid) noexcept
|
|
{
|
|
Player *player;
|
|
GET_PLAYER(pid, player, 0);
|
|
return player->cell.mData.mX;
|
|
}
|
|
|
|
int CellFunctions::GetExteriorY(unsigned short pid) noexcept
|
|
{
|
|
Player *player;
|
|
GET_PLAYER(pid, player, 0);
|
|
return player->cell.mData.mY;
|
|
}
|
|
|
|
bool CellFunctions::IsInExterior(unsigned short pid) noexcept
|
|
{
|
|
Player *player;
|
|
GET_PLAYER(pid, player, false);
|
|
|
|
return player->cell.isExterior();
|
|
}
|
|
|
|
const char *CellFunctions::GetRegion(unsigned short pid) noexcept
|
|
{
|
|
Player *player;
|
|
GET_PLAYER(pid, player, 0);
|
|
|
|
return player->cell.mRegion.c_str();
|
|
}
|
|
|
|
bool CellFunctions::IsChangingRegion(unsigned short pid) noexcept
|
|
{
|
|
Player *player;
|
|
GET_PLAYER(pid, player, false);
|
|
|
|
return player->isChangingRegion;
|
|
}
|
|
|
|
void CellFunctions::SetCell(unsigned short pid, const char *cellDescription) noexcept
|
|
{
|
|
Player *player;
|
|
GET_PLAYER(pid, player,);
|
|
|
|
LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Script is moving %s from %s to %s", player->npc.mName.c_str(),
|
|
player->cell.getShortDescription().c_str(), cellDescription);
|
|
|
|
player->cell = Utils::getCellFromDescription(cellDescription);
|
|
}
|
|
|
|
void CellFunctions::SetExteriorCell(unsigned short pid, int x, int y) noexcept
|
|
{
|
|
Player *player;
|
|
GET_PLAYER(pid, player,);
|
|
|
|
LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Script is moving %s from %s to %i,%i", player->npc.mName.c_str(),
|
|
player->cell.getShortDescription().c_str(), x, y);
|
|
|
|
// If the player is currently in an interior, turn off the interior flag
|
|
// from the cell
|
|
if (!player->cell.isExterior())
|
|
player->cell.mData.mFlags &= ~ESM::Cell::Interior;
|
|
|
|
player->cell.mData.mX = x;
|
|
player->cell.mData.mY = y;
|
|
}
|
|
|
|
void CellFunctions::SendCell(unsigned short pid) noexcept
|
|
{
|
|
Player *player;
|
|
GET_PLAYER(pid, player, );
|
|
|
|
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_CELL_CHANGE);
|
|
packet->setPlayer(player);
|
|
|
|
packet->Send(false);
|
|
}
|