1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-07-21 03:14:06 +00:00

[General] When changing region, send new region name in PlayerCellChange

This commit is contained in:
David Cernat 2017-06-10 11:43:40 +03:00
parent e5f5b047bc
commit ee5c9b65c5
6 changed files with 42 additions and 1 deletions

View file

@ -105,6 +105,22 @@ bool CellFunctions::IsInExterior(unsigned short pid) noexcept
return player->cell.isExterior(); 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::SendCell(unsigned short pid) noexcept void CellFunctions::SendCell(unsigned short pid) noexcept
{ {
Player *player; Player *player;

View file

@ -16,6 +16,9 @@
{"GetExteriorY", CellFunctions::GetExteriorY},\ {"GetExteriorY", CellFunctions::GetExteriorY},\
{"IsInExterior", CellFunctions::IsInExterior},\ {"IsInExterior", CellFunctions::IsInExterior},\
\ \
{"GetRegion", CellFunctions::GetRegion},\
{"IsChangingRegion", CellFunctions::IsChangingRegion},\
\
{"SendCell", CellFunctions::SendCell} {"SendCell", CellFunctions::SendCell}
@ -34,6 +37,9 @@ public:
static int GetExteriorY(unsigned short pid) noexcept; static int GetExteriorY(unsigned short pid) noexcept;
static bool IsInExterior(unsigned short pid) noexcept; static bool IsInExterior(unsigned short pid) noexcept;
static const char *GetRegion(unsigned short pid) noexcept;
static bool IsChangingRegion(unsigned short pid) noexcept;
static void SendCell(unsigned short pid) noexcept; static void SendCell(unsigned short pid) noexcept;
}; };

View file

@ -52,6 +52,7 @@ LocalPlayer::LocalPlayer()
attack.shouldSend = false; attack.shouldSend = false;
deathReason = "suicide"; deathReason = "suicide";
isChangingRegion = false;
} }
LocalPlayer::~LocalPlayer() LocalPlayer::~LocalPlayer()
@ -363,6 +364,15 @@ void LocalPlayer::updateCell(bool forceUpdate)
LOG_APPEND(Log::LOG_INFO, "- Moved from %s to %s", cell.getDescription().c_str(), ptrCell->getDescription().c_str()); LOG_APPEND(Log::LOG_INFO, "- Moved from %s to %s", cell.getDescription().c_str(), ptrCell->getDescription().c_str());
if (!Misc::StringUtils::ciEqual(cell.mRegion, ptrCell->mRegion))
{
LOG_APPEND(Log::LOG_INFO, "- Changed region from %s to %s",
cell.mRegion.empty() ? "none" : cell.mRegion.c_str(),
ptrCell->mRegion.empty() ? "none" : ptrCell->mRegion.c_str());
isChangingRegion = true;
}
cell = *ptrCell; cell = *ptrCell;
// Make sure the position is updated before a cell packet is sent, or else // Make sure the position is updated before a cell packet is sent, or else
@ -372,6 +382,8 @@ void LocalPlayer::updateCell(bool forceUpdate)
getNetworking()->getPlayerPacket(ID_PLAYER_CELL_CHANGE)->setPlayer(this); getNetworking()->getPlayerPacket(ID_PLAYER_CELL_CHANGE)->setPlayer(this);
getNetworking()->getPlayerPacket(ID_PLAYER_CELL_CHANGE)->Send(); getNetworking()->getPlayerPacket(ID_PLAYER_CELL_CHANGE)->Send();
isChangingRegion = false;
// Also force an update to skills (to send all progress to skill increases) // Also force an update to skills (to send all progress to skill increases)
updateSkills(true); updateSkills(true);

View file

@ -199,6 +199,8 @@ namespace mwmp
std::string creatureModel; std::string creatureModel;
bool useCreatureName; bool useCreatureName;
bool isChangingRegion;
std::string deathReason; std::string deathReason;
}; };
} }

View file

@ -35,7 +35,7 @@ void ActorPacket::Packet(RakNet::BitStream *bs, bool send)
for (unsigned int i = 0; i < actorList->count; i++) for (unsigned int i = 0; i < actorList->count; i++)
{ {
if (send) if (send)
actor = actorList->baseActors[i]; actor = actorList->baseActors.at(i);
RW(actor.refNumIndex, send); RW(actor.refNumIndex, send);
RW(actor.mpNum, send); RW(actor.mpNum, send);

View file

@ -19,4 +19,9 @@ void mwmp::PacketPlayerCellChange::Packet(RakNet::BitStream *bs, bool send)
RW(player->cell.mData, send, 1); RW(player->cell.mData, send, 1);
RW(player->cell.mName, send, 1); RW(player->cell.mName, send, 1);
RW(player->isChangingRegion, send);
if (player->isChangingRegion)
RW(player->cell.mRegion, send, 1);
} }