mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:53:51 +00:00
[General] Modernize packet style for PlayerCellState
This commit is contained in:
parent
96a71c1ced
commit
4f9e6b0e3e
5 changed files with 20 additions and 28 deletions
|
@ -162,7 +162,7 @@ void CellController::update(Player *player)
|
|||
{
|
||||
std::vector<Cell*> toDelete;
|
||||
|
||||
for (auto &&cell : player->cellStateChanges.cellStates)
|
||||
for (auto &&cell : player->cellStateChanges)
|
||||
{
|
||||
if (cell.type == mwmp::CellState::LOAD)
|
||||
{
|
||||
|
|
|
@ -17,7 +17,7 @@ unsigned int CellFunctions::GetCellStateChangesSize(unsigned short pid) noexcept
|
|||
Player *player;
|
||||
GET_PLAYER(pid, player, 0);
|
||||
|
||||
return player->cellStateChanges.count;
|
||||
return player->cellStateChanges.size();
|
||||
}
|
||||
|
||||
unsigned int CellFunctions::GetCellStateType(unsigned short pid, unsigned int index) noexcept
|
||||
|
@ -25,7 +25,7 @@ unsigned int CellFunctions::GetCellStateType(unsigned short pid, unsigned int in
|
|||
Player *player;
|
||||
GET_PLAYER(pid, player, 0);
|
||||
|
||||
return player->cellStateChanges.cellStates.at(index).type;
|
||||
return player->cellStateChanges.at(index).type;
|
||||
}
|
||||
|
||||
const char *CellFunctions::GetCellStateDescription(unsigned short pid, unsigned int index) noexcept
|
||||
|
@ -33,10 +33,10 @@ const char *CellFunctions::GetCellStateDescription(unsigned short pid, unsigned
|
|||
Player *player;
|
||||
GET_PLAYER(pid, player, "");
|
||||
|
||||
if (index >= player->cellStateChanges.count)
|
||||
if (index >= player->cellStateChanges.size())
|
||||
return "invalid";
|
||||
|
||||
tempCellDescription = player->cellStateChanges.cellStates.at(index).cell.getDescription();
|
||||
tempCellDescription = player->cellStateChanges.at(index).cell.getDescription();
|
||||
return tempCellDescription.c_str();
|
||||
}
|
||||
|
||||
|
|
|
@ -1675,7 +1675,7 @@ void LocalPlayer::sendCellStates()
|
|||
|
||||
void LocalPlayer::clearCellStates()
|
||||
{
|
||||
cellStateChanges.cellStates.clear();
|
||||
cellStateChanges.clear();
|
||||
}
|
||||
|
||||
void LocalPlayer::clearCurrentContainer()
|
||||
|
@ -1689,12 +1689,12 @@ void LocalPlayer::storeCellState(const ESM::Cell& cell, int stateType)
|
|||
{
|
||||
std::vector<CellState>::iterator iter;
|
||||
|
||||
for (iter = cellStateChanges.cellStates.begin(); iter != cellStateChanges.cellStates.end(); )
|
||||
for (iter = cellStateChanges.begin(); iter != cellStateChanges.end(); )
|
||||
{
|
||||
// If there's already a cell state recorded for this particular cell,
|
||||
// remove it
|
||||
if (cell.getDescription() == (*iter).cell.getDescription())
|
||||
iter = cellStateChanges.cellStates.erase(iter);
|
||||
iter = cellStateChanges.erase(iter);
|
||||
else
|
||||
++iter;
|
||||
}
|
||||
|
@ -1703,7 +1703,7 @@ void LocalPlayer::storeCellState(const ESM::Cell& cell, int stateType)
|
|||
cellState.cell = cell;
|
||||
cellState.type = stateType;
|
||||
|
||||
cellStateChanges.cellStates.push_back(cellState);
|
||||
cellStateChanges.push_back(cellState);
|
||||
}
|
||||
|
||||
void LocalPlayer::storeCurrentContainer(const MWWorld::Ptr &container)
|
||||
|
|
|
@ -129,12 +129,6 @@ namespace mwmp
|
|||
int action; // 0 - Clear and set in entirety, 1 - Add spell, 2 - Remove spell
|
||||
};
|
||||
|
||||
struct CellStateChanges
|
||||
{
|
||||
std::vector<CellState> cellStates;
|
||||
unsigned int count;
|
||||
};
|
||||
|
||||
enum RESURRECT_TYPE
|
||||
{
|
||||
REGULAR = 0,
|
||||
|
@ -225,7 +219,7 @@ namespace mwmp
|
|||
FactionChanges factionChanges;
|
||||
std::vector<Topic> topicChanges;
|
||||
std::vector<Book> bookChanges;
|
||||
CellStateChanges cellStateChanges;
|
||||
std::vector<CellState> cellStateChanges;
|
||||
|
||||
ESM::ActiveSpells activeSpells;
|
||||
CurrentContainer currentContainer;
|
||||
|
|
|
@ -13,25 +13,23 @@ void mwmp::PacketPlayerCellState::Packet(RakNet::BitStream *bs, bool send)
|
|||
{
|
||||
PlayerPacket::Packet(bs, send);
|
||||
|
||||
uint32_t count;
|
||||
|
||||
if (send)
|
||||
player->cellStateChanges.count = (unsigned int)(player->cellStateChanges.cellStates.size());
|
||||
else
|
||||
player->cellStateChanges.cellStates.clear();
|
||||
count = static_cast<uint32_t>(player->cellStateChanges.size());
|
||||
|
||||
RW(player->cellStateChanges.count, send);
|
||||
RW(count, send);
|
||||
|
||||
for (unsigned int i = 0; i < player->cellStateChanges.count; i++)
|
||||
if (!send)
|
||||
{
|
||||
CellState cellState;
|
||||
|
||||
if (send)
|
||||
cellState = player->cellStateChanges.cellStates.at(i);
|
||||
player->cellStateChanges.clear();
|
||||
player->cellStateChanges.resize(count);
|
||||
}
|
||||
|
||||
for (auto &&cellState : player->cellStateChanges)
|
||||
{
|
||||
RW(cellState.type, send);
|
||||
RW(cellState.cell.mData, send, true);
|
||||
RW(cellState.cell.mName, send, true);
|
||||
|
||||
if (!send)
|
||||
player->cellStateChanges.cellStates.push_back(cellState);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue