mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-07-21 05:14:10 +00:00
[General] Read and use weapon quantity in RecordDynamic packets
This commit is contained in:
parent
001d63b59b
commit
f8c557fbc0
9 changed files with 25 additions and 4 deletions
|
@ -303,6 +303,8 @@ unsigned int RecordsDynamicFunctions::GetRecordQuantity(unsigned int index) noex
|
||||||
|
|
||||||
if (readRecordsType == mwmp::RECORD_TYPE::POTION)
|
if (readRecordsType == mwmp::RECORD_TYPE::POTION)
|
||||||
return WorldstateFunctions::readWorldstate->potionRecords.at(index).quantity;
|
return WorldstateFunctions::readWorldstate->potionRecords.at(index).quantity;
|
||||||
|
else if (readRecordsType == mwmp::RECORD_TYPE::WEAPON)
|
||||||
|
return WorldstateFunctions::readWorldstate->weaponRecords.at(index).quantity;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include <components/openmw-mp/Utils.hpp>
|
#include <components/openmw-mp/Utils.hpp>
|
||||||
#include "../mwmp/Main.hpp"
|
#include "../mwmp/Main.hpp"
|
||||||
#include "../mwmp/Networking.hpp"
|
#include "../mwmp/Networking.hpp"
|
||||||
|
#include "../mwmp/LocalPlayer.hpp"
|
||||||
/*
|
/*
|
||||||
End of tes3mp addition
|
End of tes3mp addition
|
||||||
*/
|
*/
|
||||||
|
@ -320,7 +321,9 @@ namespace MWClass
|
||||||
Send the newly created record to the server and expect it to be
|
Send the newly created record to the server and expect it to be
|
||||||
returned with a server-set id
|
returned with a server-set id
|
||||||
*/
|
*/
|
||||||
mwmp::Main::get().getNetworking()->getWorldstate()->sendWeaponRecord(&newItem, ref->mBase->mId);
|
unsigned int quantity = mwmp::Main::get().getLocalPlayer()->lastEnchantmentQuantity;
|
||||||
|
|
||||||
|
mwmp::Main::get().getNetworking()->getWorldstate()->sendWeaponRecord(&newItem, ref->mBase->mId, quantity);
|
||||||
/*
|
/*
|
||||||
End of tes3mp addition
|
End of tes3mp addition
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include <components/openmw-mp/TimedLog.hpp>
|
#include <components/openmw-mp/TimedLog.hpp>
|
||||||
#include "../mwmp/Main.hpp"
|
#include "../mwmp/Main.hpp"
|
||||||
#include "../mwmp/Networking.hpp"
|
#include "../mwmp/Networking.hpp"
|
||||||
|
#include "../mwmp/LocalPlayer.hpp"
|
||||||
#include "../mwmp/Worldstate.hpp"
|
#include "../mwmp/Worldstate.hpp"
|
||||||
/*
|
/*
|
||||||
End of tes3mp addition
|
End of tes3mp addition
|
||||||
|
@ -118,7 +119,10 @@ namespace MWMechanics
|
||||||
Don't add the new item to the player's inventory and instead expect the server to
|
Don't add the new item to the player's inventory and instead expect the server to
|
||||||
add it
|
add it
|
||||||
|
|
||||||
The applyEnchantment() method is where the record of the newly enchanted will be sent
|
Store the quantity used for the enchantment so it can be retrieved in applyEnchantment()
|
||||||
|
when applicable
|
||||||
|
|
||||||
|
The applyEnchantment() method is where the record of the newly enchanted item will be sent
|
||||||
to the server, causing the server to send back the player's inventory with the new item
|
to the server, causing the server to send back the player's inventory with the new item
|
||||||
included
|
included
|
||||||
*/
|
*/
|
||||||
|
@ -129,6 +133,8 @@ namespace MWMechanics
|
||||||
if(!mSelfEnchanting)
|
if(!mSelfEnchanting)
|
||||||
payForEnchantment();
|
payForEnchantment();
|
||||||
|
|
||||||
|
mwmp::Main::get().getLocalPlayer()->storeLastEnchantmentQuantity(count);
|
||||||
|
|
||||||
std::string newItemId = mOldItemPtr.getClass().applyEnchantment(mOldItemPtr, enchantmentPtr->mId, getGemCharge(), mNewItemName);
|
std::string newItemId = mOldItemPtr.getClass().applyEnchantment(mOldItemPtr, enchantmentPtr->mId, getGemCharge(), mNewItemName);
|
||||||
/*
|
/*
|
||||||
End of tes3mp change (major)
|
End of tes3mp change (major)
|
||||||
|
|
|
@ -1749,6 +1749,11 @@ void LocalPlayer::storeItemRemoval(const std::string& refId, int count)
|
||||||
storedItemRemovals[refId] = storedItemRemovals[refId] + count;
|
storedItemRemovals[refId] = storedItemRemovals[refId] + count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LocalPlayer::storeLastEnchantmentQuantity(unsigned int quantity)
|
||||||
|
{
|
||||||
|
lastEnchantmentQuantity = quantity;
|
||||||
|
}
|
||||||
|
|
||||||
void LocalPlayer::playAnimation()
|
void LocalPlayer::playAnimation()
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getMechanicsManager()->playAnimationGroup(getPlayerPtr(),
|
MWBase::Environment::get().getMechanicsManager()->playAnimationGroup(getPlayerPtr(),
|
||||||
|
|
|
@ -23,6 +23,7 @@ namespace mwmp
|
||||||
bool isReceivingQuickKeys;
|
bool isReceivingQuickKeys;
|
||||||
bool isPlayingAnimation;
|
bool isPlayingAnimation;
|
||||||
bool diedSinceArrestAttempt;
|
bool diedSinceArrestAttempt;
|
||||||
|
unsigned int lastEnchantmentQuantity;
|
||||||
|
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
|
@ -105,6 +106,7 @@ namespace mwmp
|
||||||
void storeCellState(const ESM::Cell& cell, int stateType);
|
void storeCellState(const ESM::Cell& cell, int stateType);
|
||||||
void storeCurrentContainer(const MWWorld::Ptr& container);
|
void storeCurrentContainer(const MWWorld::Ptr& container);
|
||||||
void storeItemRemoval(const std::string& refId, int count);
|
void storeItemRemoval(const std::string& refId, int count);
|
||||||
|
void storeLastEnchantmentQuantity(unsigned int quantity);
|
||||||
|
|
||||||
void playAnimation();
|
void playAnimation();
|
||||||
void playSpeech();
|
void playSpeech();
|
||||||
|
|
|
@ -627,7 +627,7 @@ void Worldstate::sendClothingRecord(const ESM::Clothing* clothing, std::string b
|
||||||
getNetworking()->getWorldstatePacket(ID_RECORD_DYNAMIC)->Send();
|
getNetworking()->getWorldstatePacket(ID_RECORD_DYNAMIC)->Send();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Worldstate::sendWeaponRecord(const ESM::Weapon* weapon, std::string baseId)
|
void Worldstate::sendWeaponRecord(const ESM::Weapon* weapon, std::string baseId, unsigned int quantity)
|
||||||
{
|
{
|
||||||
weaponRecords.clear();
|
weaponRecords.clear();
|
||||||
|
|
||||||
|
@ -637,6 +637,7 @@ void Worldstate::sendWeaponRecord(const ESM::Weapon* weapon, std::string baseId)
|
||||||
|
|
||||||
mwmp::WeaponRecord record;
|
mwmp::WeaponRecord record;
|
||||||
record.data = *weapon;
|
record.data = *weapon;
|
||||||
|
record.quantity = quantity;
|
||||||
record.baseId = baseId;
|
record.baseId = baseId;
|
||||||
record.baseOverrides.hasName = true;
|
record.baseOverrides.hasName = true;
|
||||||
record.baseOverrides.hasEnchantmentId = true;
|
record.baseOverrides.hasEnchantmentId = true;
|
||||||
|
|
|
@ -35,7 +35,7 @@ namespace mwmp
|
||||||
void sendArmorRecord(const ESM::Armor* armor, std::string baseRefId = "");
|
void sendArmorRecord(const ESM::Armor* armor, std::string baseRefId = "");
|
||||||
void sendBookRecord(const ESM::Book* book, std::string baseRefId = "");
|
void sendBookRecord(const ESM::Book* book, std::string baseRefId = "");
|
||||||
void sendClothingRecord(const ESM::Clothing* clothing, std::string baseRefId = "");
|
void sendClothingRecord(const ESM::Clothing* clothing, std::string baseRefId = "");
|
||||||
void sendWeaponRecord(const ESM::Weapon* weapon, std::string baseRefId = "");
|
void sendWeaponRecord(const ESM::Weapon* weapon, std::string baseRefId = "", unsigned int quantity = 1);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -309,6 +309,7 @@ namespace mwmp
|
||||||
struct WeaponRecord
|
struct WeaponRecord
|
||||||
{
|
{
|
||||||
ESM::Weapon data;
|
ESM::Weapon data;
|
||||||
|
unsigned int quantity = 1;
|
||||||
std::string baseId;
|
std::string baseId;
|
||||||
BaseOverrides baseOverrides;
|
BaseOverrides baseOverrides;
|
||||||
};
|
};
|
||||||
|
|
|
@ -368,6 +368,7 @@ void PacketRecordDynamic::Packet(RakNet::BitStream *newBitstream, bool send)
|
||||||
{
|
{
|
||||||
auto &recordData = record.data;
|
auto &recordData = record.data;
|
||||||
|
|
||||||
|
RW(record.quantity, send);
|
||||||
RW(record.baseId, send, true);
|
RW(record.baseId, send, true);
|
||||||
RW(recordData.mId, send, true);
|
RW(recordData.mId, send, true);
|
||||||
RW(recordData.mName, send, true);
|
RW(recordData.mName, send, true);
|
||||||
|
|
Loading…
Reference in a new issue