Rename BasePlayer Inventory & Spellbook into PacketItems & PacketSpells

This avoids confusion when either of those is used to store and send a single item, and no longer requires coming up with confusing variable names like realSpellbook or realInventory for actual full spellbooks and inventories.
This commit is contained in:
David Cernat 2017-01-19 18:06:59 +02:00
parent be851f5e1a
commit 33e85c54de
11 changed files with 100 additions and 100 deletions

View file

@ -238,21 +238,21 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
myPacket->Read(player); myPacket->Read(player);
string str; string str;
for (auto spell : player->spellbook.spells) for (auto spell : player->packetSpells.spells)
{ {
str += spell.mId; str += spell.mId;
if (spell.mId != player->spellbook.spells.back().mId) if (spell.mId != player->packetSpells.spells.back().mId)
str += ";"; str += ";";
if (player->spellbook.action == Spellbook::ADD) if (player->packetSpells.action == PacketSpells::ADD)
player->realSpellbook.push_back(spell); player->spellbook.push_back(spell);
else if (player->spellbook.action == Spellbook::REMOVE) else if (player->packetSpells.action == PacketSpells::REMOVE)
{ {
player->realSpellbook.erase(remove_if(player->realSpellbook.begin(), player->realSpellbook.end(), [&spell](ESM::Spell s)->bool player->spellbook.erase(remove_if(player->spellbook.begin(), player->spellbook.end(), [&spell](ESM::Spell s)->bool
{return spell.mId == s.mId; }), player->realSpellbook.end()); {return spell.mId == s.mId; }), player->spellbook.end());
} }
} }
Script::Call<Script::CallbackIdentity("OnPlayerChangeSpellbook")>(player->getId(), player->spellbook.action, str.c_str()); Script::Call<Script::CallbackIdentity("OnPlayerChangeSpellbook")>(player->getId(), player->packetSpells.action, str.c_str());
break; break;
} }

View file

@ -68,9 +68,9 @@ public:
virtual ~Player(); virtual ~Player();
public: public:
mwmp::Inventory inventorySendBuffer; mwmp::PacketItems packetItemsBuffer;
mwmp::Spellbook spellbookSendBuffer; mwmp::PacketSpells packetSpellsBuffer;
std::vector<ESM::Spell> realSpellbook; std::vector<ESM::Spell> spellbook;
private: private:
bool handshakeState; bool handshakeState;

View file

@ -21,7 +21,7 @@ unsigned int ItemFunctions::GetInventorySize(unsigned short pid) noexcept
Player *player; Player *player;
GET_PLAYER(pid, player, 0); GET_PLAYER(pid, player, 0);
return player->inventory.count; return player->packetItems.count;
} }
void ItemFunctions::EquipItem(unsigned short pid, unsigned short slot, const char *itemId, unsigned int count, int health) noexcept void ItemFunctions::EquipItem(unsigned short pid, unsigned short slot, const char *itemId, unsigned int count, int health) noexcept
@ -52,8 +52,8 @@ void ItemFunctions::AddItem(unsigned short pid, const char* itemId, unsigned int
item.count = count; item.count = count;
item.health = health; item.health = health;
player->inventorySendBuffer.items.push_back(item); player->packetItemsBuffer.items.push_back(item);
player->inventorySendBuffer.action = Inventory::ADD; player->packetItemsBuffer.action = PacketItems::ADD;
} }
void ItemFunctions::RemoveItem(unsigned short pid, const char* itemId, unsigned short count) noexcept void ItemFunctions::RemoveItem(unsigned short pid, const char* itemId, unsigned short count) noexcept
@ -65,8 +65,8 @@ void ItemFunctions::RemoveItem(unsigned short pid, const char* itemId, unsigned
item.refid = itemId; item.refid = itemId;
item.count = count; item.count = count;
player->inventorySendBuffer.items.push_back(item); player->packetItemsBuffer.items.push_back(item);
player->inventorySendBuffer.action = Inventory::REMOVE; player->packetItemsBuffer.action = PacketItems::REMOVE;
} }
void ItemFunctions::ClearInventory(unsigned short pid) noexcept void ItemFunctions::ClearInventory(unsigned short pid) noexcept
@ -74,8 +74,8 @@ void ItemFunctions::ClearInventory(unsigned short pid) noexcept
Player *player; Player *player;
GET_PLAYER(pid, player, ); GET_PLAYER(pid, player, );
player->inventorySendBuffer.items.clear(); player->packetItemsBuffer.items.clear();
player->inventorySendBuffer.action = Inventory::UPDATE; player->packetItemsBuffer.action = PacketItems::UPDATE;
} }
bool ItemFunctions::HasItemEquipped(unsigned short pid, const char* itemId) bool ItemFunctions::HasItemEquipped(unsigned short pid, const char* itemId)
@ -118,10 +118,10 @@ const char *ItemFunctions::GetInventoryItemId(unsigned short pid, unsigned int i
Player *player; Player *player;
GET_PLAYER(pid, player, ""); GET_PLAYER(pid, player, "");
if (i >= player->inventory.count) if (i >= player->packetItems.count)
return "invalid"; return "invalid";
return player->inventory.items.at(i).refid.c_str(); return player->packetItems.items.at(i).refid.c_str();
} }
int ItemFunctions::GetInventoryItemCount(unsigned short pid, unsigned int i) noexcept int ItemFunctions::GetInventoryItemCount(unsigned short pid, unsigned int i) noexcept
@ -129,7 +129,7 @@ int ItemFunctions::GetInventoryItemCount(unsigned short pid, unsigned int i) noe
Player *player; Player *player;
GET_PLAYER(pid, player, 0); GET_PLAYER(pid, player, 0);
return player->inventory.items.at(i).count; return player->packetItems.items.at(i).count;
} }
int ItemFunctions::GetInventoryItemHealth(unsigned short pid, unsigned int i) noexcept int ItemFunctions::GetInventoryItemHealth(unsigned short pid, unsigned int i) noexcept
@ -137,7 +137,7 @@ int ItemFunctions::GetInventoryItemHealth(unsigned short pid, unsigned int i) no
Player *player; Player *player;
GET_PLAYER(pid, player, 0); GET_PLAYER(pid, player, 0);
return player->inventory.items.at(i).health; return player->packetItems.items.at(i).health;
} }
void ItemFunctions::SendEquipment(unsigned short pid) noexcept void ItemFunctions::SendEquipment(unsigned short pid) noexcept
@ -149,12 +149,12 @@ void ItemFunctions::SendEquipment(unsigned short pid) noexcept
mwmp::Networking::get().getPlayerController()->GetPacket(ID_GAME_EQUIPMENT)->Send(player, true); mwmp::Networking::get().getPlayerController()->GetPacket(ID_GAME_EQUIPMENT)->Send(player, true);
} }
void ItemFunctions::SendInventory(unsigned short pid) noexcept void ItemFunctions::SendItems(unsigned short pid) noexcept
{ {
Player *player; Player *player;
GET_PLAYER(pid, player, ); GET_PLAYER(pid, player, );
std::swap(player->inventory, player->inventorySendBuffer); std::swap(player->packetItems, player->packetItemsBuffer);
mwmp::Networking::get().getPlayerController()->GetPacket(ID_GAME_INVENTORY)->Send(player, false); mwmp::Networking::get().getPlayerController()->GetPacket(ID_GAME_INVENTORY)->Send(player, false);
player->inventory = std::move(player->inventorySendBuffer); player->packetItems = std::move(player->packetItemsBuffer);
player->inventorySendBuffer.items.clear(); player->packetItemsBuffer.items.clear();
} }

View file

@ -27,7 +27,7 @@
{"GetInventoryItemHealth", ItemFunctions::GetInventoryItemHealth},\ {"GetInventoryItemHealth", ItemFunctions::GetInventoryItemHealth},\
\ \
{"SendEquipment", ItemFunctions::SendEquipment},\ {"SendEquipment", ItemFunctions::SendEquipment},\
{"SendInventory", ItemFunctions::SendInventory} {"SendInventory", ItemFunctions::SendItems}
class ItemFunctions class ItemFunctions
{ {
@ -54,7 +54,7 @@ public:
static int GetInventoryItemHealth(unsigned short pid, unsigned int i) noexcept; static int GetInventoryItemHealth(unsigned short pid, unsigned int i) noexcept;
static void SendEquipment(unsigned short pid) noexcept; static void SendEquipment(unsigned short pid) noexcept;
static void SendInventory(unsigned short pid) noexcept; static void SendItems(unsigned short pid) noexcept;
private: private:
}; };

View file

@ -11,7 +11,7 @@ unsigned int SpellFunctions::GetSpellbookSize(unsigned short pid) noexcept
Player *player; Player *player;
GET_PLAYER(pid, player, 0); GET_PLAYER(pid, player, 0);
return player->realSpellbook.size(); return player->spellbook.size();
} }
void SpellFunctions::AddSpell(unsigned short pid, const char* spellId) noexcept void SpellFunctions::AddSpell(unsigned short pid, const char* spellId) noexcept
@ -22,8 +22,8 @@ void SpellFunctions::AddSpell(unsigned short pid, const char* spellId) noexcept
ESM::Spell spell; ESM::Spell spell;
spell.mId = spellId; spell.mId = spellId;
player->spellbookSendBuffer.spells.push_back(spell); player->packetSpellsBuffer.spells.push_back(spell);
player->spellbookSendBuffer.action = Spellbook::ADD; player->packetSpellsBuffer.action = PacketSpells::ADD;
} }
void SpellFunctions::RemoveSpell(unsigned short pid, const char* spellId) noexcept void SpellFunctions::RemoveSpell(unsigned short pid, const char* spellId) noexcept
@ -34,8 +34,8 @@ void SpellFunctions::RemoveSpell(unsigned short pid, const char* spellId) noexce
ESM::Spell spell; ESM::Spell spell;
spell.mId = spellId; spell.mId = spellId;
player->spellbookSendBuffer.spells.push_back(spell); player->packetSpellsBuffer.spells.push_back(spell);
player->spellbookSendBuffer.action = Spellbook::REMOVE; player->packetSpellsBuffer.action = PacketSpells::REMOVE;
} }
void SpellFunctions::ClearSpellbook(unsigned short pid) noexcept void SpellFunctions::ClearSpellbook(unsigned short pid) noexcept
@ -43,8 +43,8 @@ void SpellFunctions::ClearSpellbook(unsigned short pid) noexcept
Player *player; Player *player;
GET_PLAYER(pid, player, ); GET_PLAYER(pid, player, );
player->spellbookSendBuffer.spells.clear(); player->packetSpellsBuffer.spells.clear();
player->spellbookSendBuffer.action = Spellbook::UPDATE; player->packetSpellsBuffer.action = PacketSpells::UPDATE;
} }
bool SpellFunctions::HasSpell(unsigned short pid, const char* spellId) bool SpellFunctions::HasSpell(unsigned short pid, const char* spellId)
@ -52,8 +52,8 @@ bool SpellFunctions::HasSpell(unsigned short pid, const char* spellId)
Player *player; Player *player;
GET_PLAYER(pid, player, false); GET_PLAYER(pid, player, false);
for (unsigned int i = 0; i < player->realSpellbook.size(); i++) for (unsigned int i = 0; i < player->spellbook.size(); i++)
if (Misc::StringUtils::ciEqual(player->realSpellbook.at(i).mId, spellId)) if (Misc::StringUtils::ciEqual(player->spellbook.at(i).mId, spellId))
return true; return true;
return false; return false;
} }
@ -63,28 +63,28 @@ const char *SpellFunctions::GetSpellId(unsigned short pid, unsigned int i) noexc
Player *player; Player *player;
GET_PLAYER(pid, player, ""); GET_PLAYER(pid, player, "");
if (i >= player->realSpellbook.size()) if (i >= player->spellbook.size())
return "invalid"; return "invalid";
return player->realSpellbook.at(i).mId.c_str(); return player->spellbook.at(i).mId.c_str();
} }
void SpellFunctions::SendSpellbook(unsigned short pid) noexcept void SpellFunctions::SendSpells(unsigned short pid) noexcept
{ {
Player *player; Player *player;
GET_PLAYER(pid, player, ); GET_PLAYER(pid, player, );
for (auto spell : player->spellbookSendBuffer.spells) for (auto spell : player->packetSpellsBuffer.spells)
{ {
if (player->spellbookSendBuffer.action == Spellbook::ADD) if (player->packetSpellsBuffer.action == PacketSpells::ADD)
player->realSpellbook.push_back(spell); player->spellbook.push_back(spell);
else if (player->spellbook.action == Spellbook::REMOVE) else if (player->packetSpells.action == PacketSpells::REMOVE)
player->realSpellbook.erase(remove_if(player->realSpellbook.begin(), player->realSpellbook.end(), [&spell](ESM::Spell s)->bool player->spellbook.erase(remove_if(player->spellbook.begin(), player->spellbook.end(), [&spell](ESM::Spell s)->bool
{return spell.mId == s.mId; }), player->realSpellbook.end()); {return spell.mId == s.mId; }), player->spellbook.end());
} }
std::swap(player->spellbook, player->spellbookSendBuffer); std::swap(player->packetSpells, player->packetSpellsBuffer);
mwmp::Networking::get().getPlayerController()->GetPacket(ID_GAME_SPELLBOOK)->Send(player, false); mwmp::Networking::get().getPlayerController()->GetPacket(ID_GAME_SPELLBOOK)->Send(player, false);
player->spellbook = std::move(player->spellbookSendBuffer); player->packetSpells = std::move(player->packetSpellsBuffer);
player->spellbookSendBuffer.spells.clear(); player->packetSpellsBuffer.spells.clear();
} }

View file

@ -11,7 +11,7 @@
{"HasSpell", SpellFunctions::HasSpell},\ {"HasSpell", SpellFunctions::HasSpell},\
{"GetSpellId", SpellFunctions::GetSpellId},\ {"GetSpellId", SpellFunctions::GetSpellId},\
\ \
{"SendSpellbook", SpellFunctions::SendSpellbook} {"SendSpellbook", SpellFunctions::SendSpells}
class SpellFunctions class SpellFunctions
{ {
@ -26,7 +26,7 @@ public:
static bool HasSpell(unsigned short pid, const char* itemName); static bool HasSpell(unsigned short pid, const char* itemName);
static const char *GetSpellId(unsigned short pid, unsigned int i) noexcept; static const char *GetSpellId(unsigned short pid, unsigned int i) noexcept;
static void SendSpellbook(unsigned short pid) noexcept; static void SendSpells(unsigned short pid) noexcept;
private: private:
}; };

View file

@ -432,7 +432,7 @@ void LocalPlayer::updateInventory(bool forceUpdate)
if (!invChanged) if (!invChanged)
{ {
for (vector<Item>::iterator iter = inventory.items.begin(); iter != inventory.items.end(); ++iter) for (vector<Item>::iterator iter = packetItems.items.begin(); iter != packetItems.items.end(); ++iter)
{ {
MWWorld::ContainerStoreIterator result(ptrInventory.begin()); MWWorld::ContainerStoreIterator result(ptrInventory.begin());
for (; result != ptrInventory.end(); ++result) for (; result != ptrInventory.end(); ++result)
@ -466,15 +466,15 @@ void LocalPlayer::updateInventory(bool forceUpdate)
item.count = iter->getRefData().getCount(); item.count = iter->getRefData().getCount();
item.health = iter->getCellRef().getCharge(); item.health = iter->getCellRef().getCharge();
vector<Item>::iterator result = inventory.items.begin(); vector<Item>::iterator result = packetItems.items.begin();
for (; result != inventory.items.end(); result++) for (; result != packetItems.items.end(); result++)
{ {
if ((*result) == item) if ((*result) == item)
break; break;
} }
if (result == inventory.items.end()) if (result == packetItems.items.end())
{ {
invChanged = true; invChanged = true;
break; break;
@ -623,9 +623,9 @@ void LocalPlayer::addItems()
MWWorld::Ptr ptrPlayer = MWBase::Environment::get().getWorld()->getPlayerPtr(); MWWorld::Ptr ptrPlayer = MWBase::Environment::get().getWorld()->getPlayerPtr();
MWWorld::ContainerStore &ptrStore = ptrPlayer.getClass().getContainerStore(ptrPlayer); MWWorld::ContainerStore &ptrStore = ptrPlayer.getClass().getContainerStore(ptrPlayer);
for (unsigned int i = 0; i < inventory.count; i++) for (unsigned int i = 0; i < packetItems.count; i++)
{ {
mwmp::Item item = inventory.items[i]; mwmp::Item item = packetItems.items[i];
MWWorld::Ptr itemPtr = *ptrStore.add(item.refid, item.count, ptrPlayer); MWWorld::Ptr itemPtr = *ptrStore.add(item.refid, item.count, ptrPlayer);
if (item.health != -1) if (item.health != -1)
itemPtr.getCellRef().setCharge(item.health); itemPtr.getCellRef().setCharge(item.health);
@ -637,7 +637,7 @@ void LocalPlayer::addSpells()
MWWorld::Ptr ptrPlayer = MWBase::Environment::get().getWorld()->getPlayerPtr(); MWWorld::Ptr ptrPlayer = MWBase::Environment::get().getWorld()->getPlayerPtr();
MWMechanics::Spells &ptrSpells = ptrPlayer.getClass().getCreatureStats(ptrPlayer).getSpells(); MWMechanics::Spells &ptrSpells = ptrPlayer.getClass().getCreatureStats(ptrPlayer).getSpells();
for (vector<ESM::Spell>::const_iterator spell = spellbook.spells.begin(); spell != spellbook.spells.end(); spell++) for (vector<ESM::Spell>::const_iterator spell = packetSpells.spells.begin(); spell != packetSpells.spells.end(); spell++)
ptrSpells.add(spell->mId); ptrSpells.add(spell->mId);
} }
@ -646,9 +646,9 @@ void LocalPlayer::removeItems()
MWWorld::Ptr ptrPlayer = MWBase::Environment::get().getWorld()->getPlayerPtr(); MWWorld::Ptr ptrPlayer = MWBase::Environment::get().getWorld()->getPlayerPtr();
MWWorld::ContainerStore &ptrStore = ptrPlayer.getClass().getContainerStore(ptrPlayer); MWWorld::ContainerStore &ptrStore = ptrPlayer.getClass().getContainerStore(ptrPlayer);
for (unsigned int i = 0; i < inventory.count; i++) for (unsigned int i = 0; i < packetItems.count; i++)
{ {
mwmp::Item item = inventory.items[i]; mwmp::Item item = packetItems.items[i];
ptrStore.remove(item.refid, item.count, ptrPlayer); ptrStore.remove(item.refid, item.count, ptrPlayer);
} }
} }
@ -658,7 +658,7 @@ void LocalPlayer::removeSpells()
MWWorld::Ptr ptrPlayer = MWBase::Environment::get().getWorld()->getPlayerPtr(); MWWorld::Ptr ptrPlayer = MWBase::Environment::get().getWorld()->getPlayerPtr();
MWMechanics::Spells &ptrSpells = ptrPlayer.getClass().getCreatureStats(ptrPlayer).getSpells(); MWMechanics::Spells &ptrSpells = ptrPlayer.getClass().getCreatureStats(ptrPlayer).getSpells();
for (vector<ESM::Spell>::const_iterator spell = spellbook.spells.begin(); spell != spellbook.spells.end(); spell++) for (vector<ESM::Spell>::const_iterator spell = packetSpells.spells.begin(); spell != packetSpells.spells.end(); spell++)
{ {
ptrSpells.remove(spell->mId); ptrSpells.remove(spell->mId);
@ -907,7 +907,7 @@ void LocalPlayer::sendInventory()
MWWorld::InventoryStore &ptrInventory = ptrPlayer.getClass().getInventoryStore(ptrPlayer); MWWorld::InventoryStore &ptrInventory = ptrPlayer.getClass().getInventoryStore(ptrPlayer);
mwmp::Item item; mwmp::Item item;
inventory.items.clear(); packetItems.items.clear();
for (MWWorld::ContainerStoreIterator iter(ptrInventory.begin()); iter != ptrInventory.end(); ++iter) for (MWWorld::ContainerStoreIterator iter(ptrInventory.begin()); iter != ptrInventory.end(); ++iter)
{ {
@ -918,11 +918,11 @@ void LocalPlayer::sendInventory()
item.count = iter->getRefData().getCount(); item.count = iter->getRefData().getCount();
item.health = iter->getCellRef().getCharge(); item.health = iter->getCellRef().getCharge();
inventory.items.push_back(item); packetItems.items.push_back(item);
} }
inventory.count = (unsigned int)inventory.items.size(); packetItems.count = (unsigned int) packetItems.items.size();
inventory.action = Inventory::UPDATE; packetItems.action = PacketItems::UPDATE;
Main::get().getNetworking()->getPlayerPacket(ID_GAME_INVENTORY)->Send(this); Main::get().getNetworking()->getPlayerPacket(ID_GAME_INVENTORY)->Send(this);
} }
@ -931,13 +931,13 @@ void LocalPlayer::sendSpellAddition(std::string id)
if (id.find("$dynamic") != string::npos) // skip custom spells if (id.find("$dynamic") != string::npos) // skip custom spells
return; return;
spellbook.spells.clear(); packetSpells.spells.clear();
ESM::Spell spell; ESM::Spell spell;
spell.mId = id; spell.mId = id;
spellbook.spells.push_back(spell); packetSpells.spells.push_back(spell);
spellbook.action = Spellbook::ADD; packetSpells.action = PacketSpells::ADD;
Main::get().getNetworking()->getPlayerPacket(ID_GAME_SPELLBOOK)->Send(this); Main::get().getNetworking()->getPlayerPacket(ID_GAME_SPELLBOOK)->Send(this);
} }
@ -946,13 +946,13 @@ void LocalPlayer::sendSpellRemoval(std::string id)
if (id.find("$dynamic") != string::npos) // skip custom spells if (id.find("$dynamic") != string::npos) // skip custom spells
return; return;
spellbook.spells.clear(); packetSpells.spells.clear();
ESM::Spell spell; ESM::Spell spell;
spell.mId = id; spell.mId = id;
spellbook.spells.push_back(spell); packetSpells.spells.push_back(spell);
spellbook.action = Spellbook::REMOVE; packetSpells.action = PacketSpells::REMOVE;
Main::get().getNetworking()->getPlayerPacket(ID_GAME_SPELLBOOK)->Send(this); Main::get().getNetworking()->getPlayerPacket(ID_GAME_SPELLBOOK)->Send(this);
} }

View file

@ -299,17 +299,17 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
else else
{ {
myPacket->Packet(&bsIn, getLocalPlayer(), false); myPacket->Packet(&bsIn, getLocalPlayer(), false);
int inventoryAction = getLocalPlayer()->inventory.action; int inventoryAction = getLocalPlayer()->packetItems.action;
if (inventoryAction == Inventory::ADD) if (inventoryAction == PacketItems::ADD)
{ {
getLocalPlayer()->addItems(); getLocalPlayer()->addItems();
} }
else if (inventoryAction == Inventory::REMOVE) else if (inventoryAction == PacketItems::REMOVE)
{ {
getLocalPlayer()->removeItems(); getLocalPlayer()->removeItems();
} }
else // Inventory::UPDATE else // PacketItems::UPDATE
{ {
getLocalPlayer()->setInventory(); getLocalPlayer()->setInventory();
} }
@ -328,17 +328,17 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
else else
{ {
myPacket->Packet(&bsIn, getLocalPlayer(), false); myPacket->Packet(&bsIn, getLocalPlayer(), false);
int spellbookAction = getLocalPlayer()->spellbook.action; int spellbookAction = getLocalPlayer()->packetSpells.action;
if (spellbookAction == Spellbook::ADD) if (spellbookAction == PacketSpells::ADD)
{ {
getLocalPlayer()->addSpells(); getLocalPlayer()->addSpells();
} }
else if (spellbookAction == Spellbook::REMOVE) else if (spellbookAction == PacketSpells::REMOVE)
{ {
getLocalPlayer()->removeSpells(); getLocalPlayer()->removeSpells();
} }
else // Spellbook::UPDATE else // PacketSpells::UPDATE
{ {
getLocalPlayer()->setSpellbook(); getLocalPlayer()->setSpellbook();
} }

View file

@ -46,7 +46,7 @@ namespace mwmp
} }
}; };
struct Inventory struct PacketItems
{ {
std::vector<Item> items; std::vector<Item> items;
unsigned int count; unsigned int count;
@ -59,7 +59,7 @@ namespace mwmp
int action; //0 - Full update, 1 - Add item, 2 - Remove item int action; //0 - Full update, 1 - Add item, 2 - Remove item
}; };
struct Spellbook struct PacketSpells
{ {
std::vector<ESM::Spell> spells; std::vector<ESM::Spell> spells;
unsigned int count; unsigned int count;
@ -101,9 +101,9 @@ namespace mwmp
BasePlayer(RakNet::RakNetGUID guid) : guid(guid) BasePlayer(RakNet::RakNetGUID guid) : guid(guid)
{ {
inventory.action = 0; packetItems.action = 0;
inventory.count = 0; packetItems.count = 0;
spellbook.action = 0; packetItems.action = 0;
} }
BasePlayer() BasePlayer()
@ -188,8 +188,8 @@ namespace mwmp
int month; int month;
int day; int day;
double hour; double hour;
Inventory inventory; PacketItems packetItems;
Spellbook spellbook; PacketSpells packetSpells;
bool consoleAllowed; bool consoleAllowed;
bool ignorePosPacket; bool ignorePosPacket;
ESM::ActiveSpells activeSpells; ESM::ActiveSpells activeSpells;

View file

@ -17,22 +17,22 @@ void PacketInventory::Packet(RakNet::BitStream *bs, BasePlayer *player, bool sen
{ {
PlayerPacket::Packet(bs, player, send); PlayerPacket::Packet(bs, player, send);
RW(player->inventory.action, send); RW(player->packetItems.action, send);
if (!send) if (!send)
player->inventory.items.clear(); player->packetItems.items.clear();
else else
player->inventory.count = (unsigned int) (player->inventory.items.size()); player->packetItems.count = (unsigned int) (player->packetItems.items.size());
RW(player->inventory.count, send); RW(player->packetItems.count, send);
for (unsigned int i = 0; i < player->inventory.count; i++) for (unsigned int i = 0; i < player->packetItems.count; i++)
{ {
Item item; Item item;
if (send) if (send)
{ {
item = player->inventory.items[i]; item = player->packetItems.items[i];
RW(item.refid, send); RW(item.refid, send);
RW(item.count, send); RW(item.count, send);
RW(item.health, send); RW(item.health, send);
@ -42,7 +42,7 @@ void PacketInventory::Packet(RakNet::BitStream *bs, BasePlayer *player, bool sen
RW(item.refid, send); RW(item.refid, send);
RW(item.count, send); RW(item.count, send);
RW(item.health, send); RW(item.health, send);
player->inventory.items.push_back(item); player->packetItems.items.push_back(item);
} }
} }
} }

View file

@ -13,28 +13,28 @@ void PacketSpellbook::Packet(RakNet::BitStream *bs, BasePlayer *player, bool sen
{ {
PlayerPacket::Packet(bs, player, send); PlayerPacket::Packet(bs, player, send);
RW(player->spellbook.action, send); RW(player->packetSpells.action, send);
if (!send) if (!send)
player->spellbook.spells.clear(); player->packetSpells.spells.clear();
else else
player->spellbook.count = (unsigned int) (player->spellbook.spells.size()); player->packetSpells.count = (unsigned int) (player->packetSpells.spells.size());
RW(player->spellbook.count, send); RW(player->packetSpells.count, send);
for (unsigned int i = 0; i < player->spellbook.count; i++) for (unsigned int i = 0; i < player->packetSpells.count; i++)
{ {
ESM::Spell spell; ESM::Spell spell;
if (send) if (send)
{ {
spell = player->spellbook.spells[i]; spell = player->packetSpells.spells[i];
RW(spell.mId, send); RW(spell.mId, send);
} }
else else
{ {
RW(spell.mId, send); RW(spell.mId, send);
player->spellbook.spells.push_back(spell); player->packetSpells.spells.push_back(spell);
} }
} }