Allow script-induced setting of equipment

pull/76/head
David Cernat 8 years ago
parent 4b96080521
commit e0361835b0

@ -366,7 +366,7 @@ void LocalPlayer::updateInventory(bool forceUpdate)
MWWorld::InventoryStore &invStore = player.getClass().getInventoryStore(player);
for (int slot = 0; slot < MWWorld::InventoryStore::Slots; ++slot)
for (int slot = 0; slot < MWWorld::InventoryStore::Slots; slot++)
{
MWWorld::ContainerStoreIterator it = invStore.getSlot(slot);
if (it != invStore.end() && !::Misc::StringUtils::ciEqual(it->getCellRef().getRefId(), EquipedItem(slot)->refid))
@ -659,6 +659,26 @@ void LocalPlayer::setClass()
}
}
void LocalPlayer::setInventory()
{
MWWorld::Ptr ptrPlayer = GetPlayerPtr();
MWWorld::InventoryStore &ptrInventory = ptrPlayer.getClass().getInventoryStore(ptrPlayer);
ptrInventory.clear();
for (int slot = 0; slot < MWWorld::InventoryStore::Slots; slot++)
{
mwmp::Item *currentItem = EquipedItem(slot);
//printf("Setting currentItem: %s in slot %i\n", currentItem->refid, slot);
if (!currentItem->refid.empty())
{
ptrInventory.equip(slot, ptrInventory.ContainerStore::add(EquipedItem(slot)->refid.c_str(), 1, ptrPlayer), ptrPlayer);
}
}
}
void LocalPlayer::sendClass()
{
MWBase::World *world = MWBase::Environment::get().getWorld();

@ -42,6 +42,7 @@ namespace mwmp
void setPosition();
void setCell();
void setClass();
void setInventory();
void sendClass();
void sendAttack(char type);

@ -259,8 +259,15 @@ void Networking::ReceiveMessage(RakNet::Packet *packet)
{
if (id == myid)
{
getLocalPlayer()->updateInventory(true);
myPacket->Send(getLocalPlayer(), serverAddr);
if (packet->length == myPacket->headerSize())
{
getLocalPlayer()->updateInventory(true);
}
else
{
myPacket->Packet(&bsIn, getLocalPlayer(), false);
getLocalPlayer()->setInventory();
}
}
else if (pl != 0)
{

Loading…
Cancel
Save