mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-03 13:49:40 +00:00
Rename PacketItems, PacketSpells into InventoryChanges, SpellbookChanges
This commit is contained in:
parent
e2c595fc5d
commit
d308897f95
10 changed files with 111 additions and 110 deletions
|
@ -68,8 +68,8 @@ public:
|
||||||
virtual ~Player();
|
virtual ~Player();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
mwmp::PacketItems packetItemsBuffer;
|
mwmp::InventoryChanges inventoryChangesBuffer;
|
||||||
mwmp::PacketSpells packetSpellsBuffer;
|
mwmp::SpellbookChanges spellbookChangesBuffer;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool handshakeState;
|
bool handshakeState;
|
||||||
|
|
|
@ -16,12 +16,12 @@ int ItemFunctions::GetEquipmentSize() noexcept
|
||||||
return MWWorld::InventoryStore::Slots;
|
return MWWorld::InventoryStore::Slots;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int ItemFunctions::GetInventorySize(unsigned short pid) noexcept
|
unsigned int ItemFunctions::GetInventoryChangesSize(unsigned short pid) noexcept
|
||||||
{
|
{
|
||||||
Player *player;
|
Player *player;
|
||||||
GET_PLAYER(pid, player, 0);
|
GET_PLAYER(pid, player, 0);
|
||||||
|
|
||||||
return player->packetItems.count;
|
return player->inventoryChanges.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->packetItemsBuffer.items.push_back(item);
|
player->inventoryChangesBuffer.items.push_back(item);
|
||||||
player->packetItemsBuffer.action = PacketItems::ADD;
|
player->inventoryChangesBuffer.action = InventoryChanges::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->packetItemsBuffer.items.push_back(item);
|
player->inventoryChangesBuffer.items.push_back(item);
|
||||||
player->packetItemsBuffer.action = PacketItems::REMOVE;
|
player->inventoryChangesBuffer.action = InventoryChanges::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->packetItemsBuffer.items.clear();
|
player->inventoryChangesBuffer.items.clear();
|
||||||
player->packetItemsBuffer.action = PacketItems::SET;
|
player->inventoryChangesBuffer.action = InventoryChanges::SET;
|
||||||
}
|
}
|
||||||
|
|
||||||
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->packetItems.count)
|
if (i >= player->inventoryChanges.count)
|
||||||
return "invalid";
|
return "invalid";
|
||||||
|
|
||||||
return player->packetItems.items.at(i).refid.c_str();
|
return player->inventoryChanges.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->packetItems.items.at(i).count;
|
return player->inventoryChanges.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->packetItems.items.at(i).health;
|
return player->inventoryChanges.items.at(i).health;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemFunctions::SendEquipment(unsigned short pid) noexcept
|
void ItemFunctions::SendEquipment(unsigned short pid) noexcept
|
||||||
|
@ -149,13 +149,13 @@ 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::SendItems(unsigned short pid) noexcept
|
void ItemFunctions::SendInventoryChanges(unsigned short pid) noexcept
|
||||||
{
|
{
|
||||||
Player *player;
|
Player *player;
|
||||||
GET_PLAYER(pid, player, );
|
GET_PLAYER(pid, player, );
|
||||||
|
|
||||||
std::swap(player->packetItems, player->packetItemsBuffer);
|
std::swap(player->inventoryChanges, player->inventoryChangesBuffer);
|
||||||
mwmp::Networking::get().getPlayerController()->GetPacket(ID_GAME_INVENTORY)->Send(player, false);
|
mwmp::Networking::get().getPlayerController()->GetPacket(ID_GAME_INVENTORY)->Send(player, false);
|
||||||
player->packetItems = std::move(player->packetItemsBuffer);
|
player->inventoryChanges = std::move(player->inventoryChangesBuffer);
|
||||||
player->packetItemsBuffer.items.clear();
|
player->inventoryChangesBuffer.items.clear();
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,35 +6,35 @@
|
||||||
#define OPENMW_ITEMS_HPP
|
#define OPENMW_ITEMS_HPP
|
||||||
|
|
||||||
#define ITEMAPI \
|
#define ITEMAPI \
|
||||||
{"GetEquipmentSize", ItemFunctions::GetEquipmentSize},\
|
{"GetEquipmentSize", ItemFunctions::GetEquipmentSize},\
|
||||||
{"GetInventorySize", ItemFunctions::GetInventorySize},\
|
{"GetInventoryChangesSize", ItemFunctions::GetInventoryChangesSize},\
|
||||||
\
|
\
|
||||||
{"EquipItem", ItemFunctions::EquipItem},\
|
{"EquipItem", ItemFunctions::EquipItem},\
|
||||||
{"UnequipItem", ItemFunctions::UnequipItem},\
|
{"UnequipItem", ItemFunctions::UnequipItem},\
|
||||||
\
|
\
|
||||||
{"AddItem", ItemFunctions::AddItem},\
|
{"AddItem", ItemFunctions::AddItem},\
|
||||||
{"RemoveItem", ItemFunctions::RemoveItem},\
|
{"RemoveItem", ItemFunctions::RemoveItem},\
|
||||||
{"ClearInventory", ItemFunctions::ClearInventory},\
|
{"ClearInventory", ItemFunctions::ClearInventory},\
|
||||||
\
|
\
|
||||||
{"HasItemEquipped", ItemFunctions::HasItemEquipped},\
|
{"HasItemEquipped", ItemFunctions::HasItemEquipped},\
|
||||||
\
|
\
|
||||||
{"GetEquipmentItemId", ItemFunctions::GetEquipmentItemId},\
|
{"GetEquipmentItemId", ItemFunctions::GetEquipmentItemId},\
|
||||||
{"GetEquipmentItemCount", ItemFunctions::GetEquipmentItemCount},\
|
{"GetEquipmentItemCount", ItemFunctions::GetEquipmentItemCount},\
|
||||||
{"GetEquipmentItemHealth", ItemFunctions::GetEquipmentItemHealth},\
|
{"GetEquipmentItemHealth", ItemFunctions::GetEquipmentItemHealth},\
|
||||||
\
|
\
|
||||||
{"GetInventoryItemId", ItemFunctions::GetInventoryItemId},\
|
{"GetInventoryItemId", ItemFunctions::GetInventoryItemId},\
|
||||||
{"GetInventoryItemCount", ItemFunctions::GetInventoryItemCount},\
|
{"GetInventoryItemCount", ItemFunctions::GetInventoryItemCount},\
|
||||||
{"GetInventoryItemHealth", ItemFunctions::GetInventoryItemHealth},\
|
{"GetInventoryItemHealth", ItemFunctions::GetInventoryItemHealth},\
|
||||||
\
|
\
|
||||||
{"SendEquipment", ItemFunctions::SendEquipment},\
|
{"SendEquipment", ItemFunctions::SendEquipment},\
|
||||||
{"SendItems", ItemFunctions::SendItems}
|
{"SendInventoryChanges", ItemFunctions::SendInventoryChanges}
|
||||||
|
|
||||||
class ItemFunctions
|
class ItemFunctions
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static int GetEquipmentSize() noexcept;
|
static int GetEquipmentSize() noexcept;
|
||||||
static unsigned int GetInventorySize(unsigned short pid) noexcept;
|
static unsigned int GetInventoryChangesSize(unsigned short pid) noexcept;
|
||||||
|
|
||||||
static void EquipItem(unsigned short pid, unsigned short slot, const char* itemId, unsigned int count, int health) noexcept;
|
static void EquipItem(unsigned short pid, unsigned short slot, const char* itemId, unsigned int count, int health) noexcept;
|
||||||
static void UnequipItem(unsigned short pid, unsigned short slot) noexcept;
|
static void UnequipItem(unsigned short pid, unsigned short slot) noexcept;
|
||||||
|
@ -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 SendItems(unsigned short pid) noexcept;
|
static void SendInventoryChanges(unsigned short pid) noexcept;
|
||||||
private:
|
private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,12 +6,12 @@
|
||||||
|
|
||||||
using namespace mwmp;
|
using namespace mwmp;
|
||||||
|
|
||||||
unsigned int SpellFunctions::GetSpellbookSize(unsigned short pid) noexcept
|
unsigned int SpellFunctions::GetSpellbookChangesSize(unsigned short pid) noexcept
|
||||||
{
|
{
|
||||||
Player *player;
|
Player *player;
|
||||||
GET_PLAYER(pid, player, 0);
|
GET_PLAYER(pid, player, 0);
|
||||||
|
|
||||||
return player->packetSpells.count;
|
return player->spellbookChanges.count;
|
||||||
}
|
}
|
||||||
|
|
||||||
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->packetSpellsBuffer.spells.push_back(spell);
|
player->spellbookChangesBuffer.spells.push_back(spell);
|
||||||
player->packetSpellsBuffer.action = PacketSpells::ADD;
|
player->spellbookChangesBuffer.action = SpellbookChanges::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->packetSpellsBuffer.spells.push_back(spell);
|
player->spellbookChangesBuffer.spells.push_back(spell);
|
||||||
player->packetSpellsBuffer.action = PacketSpells::REMOVE;
|
player->spellbookChangesBuffer.action = SpellbookChanges::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->packetSpellsBuffer.spells.clear();
|
player->spellbookChangesBuffer.spells.clear();
|
||||||
player->packetSpellsBuffer.action = PacketSpells::SET;
|
player->spellbookChangesBuffer.action = SpellbookChanges::SET;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *SpellFunctions::GetSpellId(unsigned short pid, unsigned int i) noexcept
|
const char *SpellFunctions::GetSpellId(unsigned short pid, unsigned int i) noexcept
|
||||||
|
@ -52,19 +52,19 @@ 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->packetSpells.count)
|
if (i >= player->spellbookChanges.count)
|
||||||
return "invalid";
|
return "invalid";
|
||||||
|
|
||||||
return player->packetSpells.spells.at(i).mId.c_str();
|
return player->spellbookChanges.spells.at(i).mId.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpellFunctions::SendSpells(unsigned short pid) noexcept
|
void SpellFunctions::SendSpellbookChanges(unsigned short pid) noexcept
|
||||||
{
|
{
|
||||||
Player *player;
|
Player *player;
|
||||||
GET_PLAYER(pid, player, );
|
GET_PLAYER(pid, player, );
|
||||||
|
|
||||||
std::swap(player->packetSpells, player->packetSpellsBuffer);
|
std::swap(player->spellbookChanges, player->spellbookChangesBuffer);
|
||||||
mwmp::Networking::get().getPlayerController()->GetPacket(ID_GAME_SPELLBOOK)->Send(player, false);
|
mwmp::Networking::get().getPlayerController()->GetPacket(ID_GAME_SPELLBOOK)->Send(player, false);
|
||||||
player->packetSpells = std::move(player->packetSpellsBuffer);
|
player->spellbookChanges = std::move(player->spellbookChangesBuffer);
|
||||||
player->packetSpellsBuffer.spells.clear();
|
player->spellbookChangesBuffer.spells.clear();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,21 +2,21 @@
|
||||||
#define OPENMW_SPELLS_HPP
|
#define OPENMW_SPELLS_HPP
|
||||||
|
|
||||||
#define SPELLAPI \
|
#define SPELLAPI \
|
||||||
{"GetSpellbookSize", SpellFunctions::GetSpellbookSize},\
|
{"GetSpellbookChangesSize", SpellFunctions::GetSpellbookChangesSize},\
|
||||||
\
|
\
|
||||||
{"AddSpell", SpellFunctions::AddSpell},\
|
{"AddSpell", SpellFunctions::AddSpell},\
|
||||||
{"RemoveSpell", SpellFunctions::RemoveSpell},\
|
{"RemoveSpell", SpellFunctions::RemoveSpell},\
|
||||||
{"ClearSpellbook", SpellFunctions::ClearSpellbook},\
|
{"ClearSpellbook", SpellFunctions::ClearSpellbook},\
|
||||||
\
|
\
|
||||||
{"GetSpellId", SpellFunctions::GetSpellId},\
|
{"GetSpellId", SpellFunctions::GetSpellId},\
|
||||||
\
|
\
|
||||||
{"SendSpells", SpellFunctions::SendSpells}
|
{"SendSpellbookChanges", SpellFunctions::SendSpellbookChanges}
|
||||||
|
|
||||||
class SpellFunctions
|
class SpellFunctions
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static unsigned int GetSpellbookSize(unsigned short pid) noexcept;
|
static unsigned int GetSpellbookChangesSize(unsigned short pid) noexcept;
|
||||||
|
|
||||||
static void AddSpell(unsigned short pid, const char* spellId) noexcept;
|
static void AddSpell(unsigned short pid, const char* spellId) noexcept;
|
||||||
static void RemoveSpell(unsigned short pid, const char* spellId) noexcept;
|
static void RemoveSpell(unsigned short pid, const char* spellId) noexcept;
|
||||||
|
@ -24,7 +24,7 @@ public:
|
||||||
|
|
||||||
static const char *GetSpellId(unsigned short pid, unsigned int i) noexcept;
|
static const char *GetSpellId(unsigned short pid, unsigned int i) noexcept;
|
||||||
|
|
||||||
static void SendSpells(unsigned short pid) noexcept;
|
static void SendSpellbookChanges(unsigned short pid) noexcept;
|
||||||
private:
|
private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -433,7 +433,7 @@ void LocalPlayer::updateInventory(bool forceUpdate)
|
||||||
|
|
||||||
if (!invChanged)
|
if (!invChanged)
|
||||||
{
|
{
|
||||||
for (vector<Item>::iterator iter = packetItems.items.begin(); iter != packetItems.items.end(); ++iter)
|
for (vector<Item>::iterator iter = inventoryChanges.items.begin(); iter != inventoryChanges.items.end(); ++iter)
|
||||||
{
|
{
|
||||||
MWWorld::ContainerStoreIterator result(ptrInventory.begin());
|
MWWorld::ContainerStoreIterator result(ptrInventory.begin());
|
||||||
for (; result != ptrInventory.end(); ++result)
|
for (; result != ptrInventory.end(); ++result)
|
||||||
|
@ -467,15 +467,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 = packetItems.items.begin();
|
vector<Item>::iterator result = inventoryChanges.items.begin();
|
||||||
|
|
||||||
for (; result != packetItems.items.end(); result++)
|
for (; result != inventoryChanges.items.end(); result++)
|
||||||
{
|
{
|
||||||
if ((*result) == item)
|
if ((*result) == item)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result == packetItems.items.end())
|
if (result == inventoryChanges.items.end())
|
||||||
{
|
{
|
||||||
invChanged = true;
|
invChanged = true;
|
||||||
break;
|
break;
|
||||||
|
@ -624,9 +624,9 @@ void LocalPlayer::addItems()
|
||||||
MWWorld::Ptr ptrPlayer = getPlayerPtr();
|
MWWorld::Ptr ptrPlayer = getPlayerPtr();
|
||||||
MWWorld::ContainerStore &ptrStore = ptrPlayer.getClass().getContainerStore(ptrPlayer);
|
MWWorld::ContainerStore &ptrStore = ptrPlayer.getClass().getContainerStore(ptrPlayer);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < packetItems.count; i++)
|
for (unsigned int i = 0; i < inventoryChanges.count; i++)
|
||||||
{
|
{
|
||||||
mwmp::Item item = packetItems.items[i];
|
mwmp::Item item = inventoryChanges.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);
|
||||||
|
@ -638,7 +638,7 @@ void LocalPlayer::addSpells()
|
||||||
MWWorld::Ptr ptrPlayer = getPlayerPtr();
|
MWWorld::Ptr ptrPlayer = getPlayerPtr();
|
||||||
MWMechanics::Spells &ptrSpells = ptrPlayer.getClass().getCreatureStats(ptrPlayer).getSpells();
|
MWMechanics::Spells &ptrSpells = ptrPlayer.getClass().getCreatureStats(ptrPlayer).getSpells();
|
||||||
|
|
||||||
for (vector<ESM::Spell>::const_iterator spell = packetSpells.spells.begin(); spell != packetSpells.spells.end(); spell++)
|
for (vector<ESM::Spell>::const_iterator spell = spellbookChanges.spells.begin(); spell != spellbookChanges.spells.end(); spell++)
|
||||||
ptrSpells.add(spell->mId);
|
ptrSpells.add(spell->mId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -648,9 +648,9 @@ void LocalPlayer::removeItems()
|
||||||
MWWorld::Ptr ptrPlayer = getPlayerPtr();
|
MWWorld::Ptr ptrPlayer = getPlayerPtr();
|
||||||
MWWorld::ContainerStore &ptrStore = ptrPlayer.getClass().getContainerStore(ptrPlayer);
|
MWWorld::ContainerStore &ptrStore = ptrPlayer.getClass().getContainerStore(ptrPlayer);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < packetItems.count; i++)
|
for (unsigned int i = 0; i < inventoryChanges.count; i++)
|
||||||
{
|
{
|
||||||
mwmp::Item item = packetItems.items[i];
|
mwmp::Item item = inventoryChanges.items[i];
|
||||||
ptrStore.remove(item.refid, item.count, ptrPlayer);
|
ptrStore.remove(item.refid, item.count, ptrPlayer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -660,7 +660,7 @@ void LocalPlayer::removeSpells()
|
||||||
MWWorld::Ptr ptrPlayer = getPlayerPtr();
|
MWWorld::Ptr ptrPlayer = getPlayerPtr();
|
||||||
MWMechanics::Spells &ptrSpells = ptrPlayer.getClass().getCreatureStats(ptrPlayer).getSpells();
|
MWMechanics::Spells &ptrSpells = ptrPlayer.getClass().getCreatureStats(ptrPlayer).getSpells();
|
||||||
|
|
||||||
for (vector<ESM::Spell>::const_iterator spell = packetSpells.spells.begin(); spell != packetSpells.spells.end(); spell++)
|
for (vector<ESM::Spell>::const_iterator spell = spellbookChanges.spells.begin(); spell != spellbookChanges.spells.end(); spell++)
|
||||||
{
|
{
|
||||||
ptrSpells.remove(spell->mId);
|
ptrSpells.remove(spell->mId);
|
||||||
|
|
||||||
|
@ -917,7 +917,7 @@ void LocalPlayer::sendInventory()
|
||||||
MWWorld::InventoryStore &ptrInventory = ptrPlayer.getClass().getInventoryStore(ptrPlayer);
|
MWWorld::InventoryStore &ptrInventory = ptrPlayer.getClass().getInventoryStore(ptrPlayer);
|
||||||
mwmp::Item item;
|
mwmp::Item item;
|
||||||
|
|
||||||
packetItems.items.clear();
|
inventoryChanges.items.clear();
|
||||||
|
|
||||||
for (MWWorld::ContainerStoreIterator iter(ptrInventory.begin()); iter != ptrInventory.end(); ++iter)
|
for (MWWorld::ContainerStoreIterator iter(ptrInventory.begin()); iter != ptrInventory.end(); ++iter)
|
||||||
{
|
{
|
||||||
|
@ -928,11 +928,11 @@ void LocalPlayer::sendInventory()
|
||||||
item.count = iter->getRefData().getCount();
|
item.count = iter->getRefData().getCount();
|
||||||
item.health = iter->getCellRef().getCharge();
|
item.health = iter->getCellRef().getCharge();
|
||||||
|
|
||||||
packetItems.items.push_back(item);
|
inventoryChanges.items.push_back(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
packetItems.count = (unsigned int) packetItems.items.size();
|
inventoryChanges.count = (unsigned int) inventoryChanges.items.size();
|
||||||
packetItems.action = PacketItems::SET;
|
inventoryChanges.action = InventoryChanges::SET;
|
||||||
Main::get().getNetworking()->getPlayerPacket(ID_GAME_INVENTORY)->Send(this);
|
Main::get().getNetworking()->getPlayerPacket(ID_GAME_INVENTORY)->Send(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -941,7 +941,7 @@ void LocalPlayer::sendSpellbook()
|
||||||
MWWorld::Ptr ptrPlayer = getPlayerPtr();
|
MWWorld::Ptr ptrPlayer = getPlayerPtr();
|
||||||
MWMechanics::Spells &ptrSpells = ptrPlayer.getClass().getCreatureStats(ptrPlayer).getSpells();
|
MWMechanics::Spells &ptrSpells = ptrPlayer.getClass().getCreatureStats(ptrPlayer).getSpells();
|
||||||
|
|
||||||
packetSpells.spells.clear();
|
spellbookChanges.spells.clear();
|
||||||
|
|
||||||
// Send spells in spellbook, while ignoring abilities, powers, etc.
|
// Send spells in spellbook, while ignoring abilities, powers, etc.
|
||||||
for (MWMechanics::Spells::TIterator iter = ptrSpells.begin(); iter != ptrSpells.end(); ++iter)
|
for (MWMechanics::Spells::TIterator iter = ptrSpells.begin(); iter != ptrSpells.end(); ++iter)
|
||||||
|
@ -950,11 +950,11 @@ void LocalPlayer::sendSpellbook()
|
||||||
|
|
||||||
if (spell->mData.mType == ESM::Spell::ST_Spell)
|
if (spell->mData.mType == ESM::Spell::ST_Spell)
|
||||||
{
|
{
|
||||||
packetSpells.spells.push_back(*spell);
|
spellbookChanges.spells.push_back(*spell);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
packetSpells.action = PacketSpells::SET;
|
spellbookChanges.action = SpellbookChanges::SET;
|
||||||
Main::get().getNetworking()->getPlayerPacket(ID_GAME_SPELLBOOK)->Send(this);
|
Main::get().getNetworking()->getPlayerPacket(ID_GAME_SPELLBOOK)->Send(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -963,13 +963,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;
|
||||||
|
|
||||||
packetSpells.spells.clear();
|
spellbookChanges.spells.clear();
|
||||||
|
|
||||||
ESM::Spell spell;
|
ESM::Spell spell;
|
||||||
spell.mId = id;
|
spell.mId = id;
|
||||||
packetSpells.spells.push_back(spell);
|
spellbookChanges.spells.push_back(spell);
|
||||||
|
|
||||||
packetSpells.action = PacketSpells::ADD;
|
spellbookChanges.action = SpellbookChanges::ADD;
|
||||||
Main::get().getNetworking()->getPlayerPacket(ID_GAME_SPELLBOOK)->Send(this);
|
Main::get().getNetworking()->getPlayerPacket(ID_GAME_SPELLBOOK)->Send(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -978,13 +978,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;
|
||||||
|
|
||||||
packetSpells.spells.clear();
|
spellbookChanges.spells.clear();
|
||||||
|
|
||||||
ESM::Spell spell;
|
ESM::Spell spell;
|
||||||
spell.mId = id;
|
spell.mId = id;
|
||||||
packetSpells.spells.push_back(spell);
|
spellbookChanges.spells.push_back(spell);
|
||||||
|
|
||||||
packetSpells.action = PacketSpells::REMOVE;
|
spellbookChanges.action = SpellbookChanges::REMOVE;
|
||||||
Main::get().getNetworking()->getPlayerPacket(ID_GAME_SPELLBOOK)->Send(this);
|
Main::get().getNetworking()->getPlayerPacket(ID_GAME_SPELLBOOK)->Send(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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()->packetItems.action;
|
int inventoryAction = getLocalPlayer()->inventoryChanges.action;
|
||||||
|
|
||||||
if (inventoryAction == PacketItems::ADD)
|
if (inventoryAction == InventoryChanges::ADD)
|
||||||
{
|
{
|
||||||
getLocalPlayer()->addItems();
|
getLocalPlayer()->addItems();
|
||||||
}
|
}
|
||||||
else if (inventoryAction == PacketItems::REMOVE)
|
else if (inventoryAction == InventoryChanges::REMOVE)
|
||||||
{
|
{
|
||||||
getLocalPlayer()->removeItems();
|
getLocalPlayer()->removeItems();
|
||||||
}
|
}
|
||||||
else // PacketItems::SET
|
else // InventoryChanges::SET
|
||||||
{
|
{
|
||||||
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()->packetSpells.action;
|
int spellbookAction = getLocalPlayer()->spellbookChanges.action;
|
||||||
|
|
||||||
if (spellbookAction == PacketSpells::ADD)
|
if (spellbookAction == SpellbookChanges::ADD)
|
||||||
{
|
{
|
||||||
getLocalPlayer()->addSpells();
|
getLocalPlayer()->addSpells();
|
||||||
}
|
}
|
||||||
else if (spellbookAction == PacketSpells::REMOVE)
|
else if (spellbookAction == SpellbookChanges::REMOVE)
|
||||||
{
|
{
|
||||||
getLocalPlayer()->removeSpells();
|
getLocalPlayer()->removeSpells();
|
||||||
}
|
}
|
||||||
else // PacketSpells::SET
|
else // SpellbookChanges::SET
|
||||||
{
|
{
|
||||||
getLocalPlayer()->setSpellbook();
|
getLocalPlayer()->setSpellbook();
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ namespace mwmp
|
||||||
unsigned int count;
|
unsigned int count;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PacketItems
|
struct InventoryChanges
|
||||||
{
|
{
|
||||||
std::vector<Item> items;
|
std::vector<Item> items;
|
||||||
unsigned int count;
|
unsigned int count;
|
||||||
|
@ -77,7 +77,7 @@ namespace mwmp
|
||||||
int action; //0 - Clear and set in entirety, 1 - Add item, 2 - Remove item
|
int action; //0 - Clear and set in entirety, 1 - Add item, 2 - Remove item
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PacketSpells
|
struct SpellbookChanges
|
||||||
{
|
{
|
||||||
std::vector<ESM::Spell> spells;
|
std::vector<ESM::Spell> spells;
|
||||||
unsigned int count;
|
unsigned int count;
|
||||||
|
@ -119,9 +119,10 @@ namespace mwmp
|
||||||
|
|
||||||
BasePlayer(RakNet::RakNetGUID guid) : guid(guid)
|
BasePlayer(RakNet::RakNetGUID guid) : guid(guid)
|
||||||
{
|
{
|
||||||
packetItems.action = 0;
|
inventoryChanges.action = 0;
|
||||||
packetItems.count = 0;
|
inventoryChanges.count = 0;
|
||||||
packetItems.action = 0;
|
spellbookChanges.action = 0;
|
||||||
|
spellbookChanges.count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
BasePlayer()
|
BasePlayer()
|
||||||
|
@ -206,8 +207,8 @@ namespace mwmp
|
||||||
int month;
|
int month;
|
||||||
int day;
|
int day;
|
||||||
double hour;
|
double hour;
|
||||||
PacketItems packetItems;
|
InventoryChanges inventoryChanges;
|
||||||
PacketSpells packetSpells;
|
SpellbookChanges spellbookChanges;
|
||||||
bool consoleAllowed;
|
bool consoleAllowed;
|
||||||
bool ignorePosPacket;
|
bool ignorePosPacket;
|
||||||
ESM::ActiveSpells activeSpells;
|
ESM::ActiveSpells activeSpells;
|
||||||
|
|
|
@ -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->packetItems.action, send);
|
RW(player->inventoryChanges.action, send);
|
||||||
|
|
||||||
if (!send)
|
if (!send)
|
||||||
player->packetItems.items.clear();
|
player->inventoryChanges.items.clear();
|
||||||
else
|
else
|
||||||
player->packetItems.count = (unsigned int) (player->packetItems.items.size());
|
player->inventoryChanges.count = (unsigned int) (player->inventoryChanges.items.size());
|
||||||
|
|
||||||
RW(player->packetItems.count, send);
|
RW(player->inventoryChanges.count, send);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < player->packetItems.count; i++)
|
for (unsigned int i = 0; i < player->inventoryChanges.count; i++)
|
||||||
{
|
{
|
||||||
Item item;
|
Item item;
|
||||||
|
|
||||||
if (send)
|
if (send)
|
||||||
{
|
{
|
||||||
item = player->packetItems.items[i];
|
item = player->inventoryChanges.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->packetItems.items.push_back(item);
|
player->inventoryChanges.items.push_back(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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->packetSpells.action, send);
|
RW(player->spellbookChanges.action, send);
|
||||||
|
|
||||||
if (!send)
|
if (!send)
|
||||||
player->packetSpells.spells.clear();
|
player->spellbookChanges.spells.clear();
|
||||||
else
|
else
|
||||||
player->packetSpells.count = (unsigned int) (player->packetSpells.spells.size());
|
player->spellbookChanges.count = (unsigned int) (player->spellbookChanges.spells.size());
|
||||||
|
|
||||||
RW(player->packetSpells.count, send);
|
RW(player->spellbookChanges.count, send);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < player->packetSpells.count; i++)
|
for (unsigned int i = 0; i < player->spellbookChanges.count; i++)
|
||||||
{
|
{
|
||||||
ESM::Spell spell;
|
ESM::Spell spell;
|
||||||
|
|
||||||
if (send)
|
if (send)
|
||||||
{
|
{
|
||||||
spell = player->packetSpells.spells[i];
|
spell = player->spellbookChanges.spells[i];
|
||||||
RW(spell.mId, send);
|
RW(spell.mId, send);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RW(spell.mId, send);
|
RW(spell.mId, send);
|
||||||
player->packetSpells.spells.push_back(spell);
|
player->spellbookChanges.spells.push_back(spell);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue