mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-10-15 12:56:43 +00:00
[General] Modernize packet style for PlayerSpellbook
This commit is contained in:
parent
be0690b024
commit
904f804ea2
3 changed files with 13 additions and 18 deletions
|
@ -21,7 +21,7 @@ unsigned int SpellFunctions::GetSpellbookChangesSize(unsigned short pid) noexcep
|
||||||
Player *player;
|
Player *player;
|
||||||
GET_PLAYER(pid, player, 0);
|
GET_PLAYER(pid, player, 0);
|
||||||
|
|
||||||
return player->spellbookChanges.count;
|
return player->spellbookChanges.spells.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int SpellFunctions::GetSpellbookChangesAction(unsigned short pid) noexcept
|
unsigned int SpellFunctions::GetSpellbookChangesAction(unsigned short pid) noexcept
|
||||||
|
@ -56,7 +56,7 @@ const char *SpellFunctions::GetSpellId(unsigned short pid, unsigned int index) n
|
||||||
Player *player;
|
Player *player;
|
||||||
GET_PLAYER(pid, player, "");
|
GET_PLAYER(pid, player, "");
|
||||||
|
|
||||||
if (index >= player->spellbookChanges.count)
|
if (index >= player->spellbookChanges.spells.size())
|
||||||
return "invalid";
|
return "invalid";
|
||||||
|
|
||||||
return player->spellbookChanges.spells.at(index).mId.c_str();
|
return player->spellbookChanges.spells.at(index).mId.c_str();
|
||||||
|
|
|
@ -119,7 +119,6 @@ namespace mwmp
|
||||||
struct SpellbookChanges
|
struct SpellbookChanges
|
||||||
{
|
{
|
||||||
std::vector<ESM::Spell> spells;
|
std::vector<ESM::Spell> spells;
|
||||||
unsigned int count;
|
|
||||||
enum ACTION_TYPE
|
enum ACTION_TYPE
|
||||||
{
|
{
|
||||||
SET = 0,
|
SET = 0,
|
||||||
|
@ -176,7 +175,6 @@ namespace mwmp
|
||||||
inventoryChanges.action = 0;
|
inventoryChanges.action = 0;
|
||||||
inventoryChanges.count = 0;
|
inventoryChanges.count = 0;
|
||||||
spellbookChanges.action = 0;
|
spellbookChanges.action = 0;
|
||||||
spellbookChanges.count = 0;
|
|
||||||
|
|
||||||
exchangeFullInfo = false;
|
exchangeFullInfo = false;
|
||||||
displayCreatureName = false;
|
displayCreatureName = false;
|
||||||
|
|
|
@ -15,24 +15,21 @@ void PacketPlayerSpellbook::Packet(RakNet::BitStream *bs, bool send)
|
||||||
|
|
||||||
RW(player->spellbookChanges.action, send);
|
RW(player->spellbookChanges.action, send);
|
||||||
|
|
||||||
if (send)
|
uint32_t count;
|
||||||
player->spellbookChanges.count = (unsigned int) (player->spellbookChanges.spells.size());
|
|
||||||
else
|
|
||||||
player->spellbookChanges.spells.clear();
|
|
||||||
|
|
||||||
RW(player->spellbookChanges.count, send);
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < player->spellbookChanges.count; i++)
|
|
||||||
{
|
|
||||||
ESM::Spell spell;
|
|
||||||
|
|
||||||
if (send)
|
if (send)
|
||||||
spell = player->spellbookChanges.spells.at(i);
|
count = static_cast<uint32_t>(player->spellbookChanges.spells.size());
|
||||||
|
|
||||||
RW(spell.mId, send, true);
|
RW(count, send);
|
||||||
|
|
||||||
if (!send)
|
if (!send)
|
||||||
player->spellbookChanges.spells.push_back(spell);
|
{
|
||||||
|
player->spellbookChanges.spells.clear();
|
||||||
|
player->spellbookChanges.spells.resize(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (auto &&spell : player->spellbookChanges.spells)
|
||||||
|
{
|
||||||
|
RW(spell.mId, send, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue