forked from mirror/openmw-tes3mp
[General] When changing region, send new region name in PlayerCellChange
This commit is contained in:
parent
e5f5b047bc
commit
ee5c9b65c5
6 changed files with 42 additions and 1 deletions
|
@ -105,6 +105,22 @@ bool CellFunctions::IsInExterior(unsigned short pid) noexcept
|
|||
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
|
||||
{
|
||||
Player *player;
|
||||
|
|
|
@ -16,6 +16,9 @@
|
|||
{"GetExteriorY", CellFunctions::GetExteriorY},\
|
||||
{"IsInExterior", CellFunctions::IsInExterior},\
|
||||
\
|
||||
{"GetRegion", CellFunctions::GetRegion},\
|
||||
{"IsChangingRegion", CellFunctions::IsChangingRegion},\
|
||||
\
|
||||
{"SendCell", CellFunctions::SendCell}
|
||||
|
||||
|
||||
|
@ -34,6 +37,9 @@ public:
|
|||
static int GetExteriorY(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;
|
||||
};
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@ LocalPlayer::LocalPlayer()
|
|||
attack.shouldSend = false;
|
||||
|
||||
deathReason = "suicide";
|
||||
isChangingRegion = false;
|
||||
}
|
||||
|
||||
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());
|
||||
|
||||
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;
|
||||
|
||||
// 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)->Send();
|
||||
|
||||
isChangingRegion = false;
|
||||
|
||||
// Also force an update to skills (to send all progress to skill increases)
|
||||
updateSkills(true);
|
||||
|
||||
|
|
|
@ -199,6 +199,8 @@ namespace mwmp
|
|||
std::string creatureModel;
|
||||
bool useCreatureName;
|
||||
|
||||
bool isChangingRegion;
|
||||
|
||||
std::string deathReason;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ void ActorPacket::Packet(RakNet::BitStream *bs, bool send)
|
|||
for (unsigned int i = 0; i < actorList->count; i++)
|
||||
{
|
||||
if (send)
|
||||
actor = actorList->baseActors[i];
|
||||
actor = actorList->baseActors.at(i);
|
||||
|
||||
RW(actor.refNumIndex, send);
|
||||
RW(actor.mpNum, send);
|
||||
|
|
|
@ -19,4 +19,9 @@ void mwmp::PacketPlayerCellChange::Packet(RakNet::BitStream *bs, bool send)
|
|||
|
||||
RW(player->cell.mData, send, 1);
|
||||
RW(player->cell.mName, send, 1);
|
||||
|
||||
RW(player->isChangingRegion, send);
|
||||
|
||||
if (player->isChangingRegion)
|
||||
RW(player->cell.mRegion, send, 1);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue