mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-30 23:15:36 +00:00
[General] Synchronize gold pools for traders via ObjectMiscellaneous
This commit is contained in:
parent
297a254210
commit
23ff7b9610
7 changed files with 81 additions and 5 deletions
|
@ -12,6 +12,14 @@ namespace mwmp
|
||||||
{
|
{
|
||||||
BPP_INIT(ID_OBJECT_MISCELLANEOUS)
|
BPP_INIT(ID_OBJECT_MISCELLANEOUS)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Do(ObjectPacket& packet, Player& player, BaseObjectList& objectList) override
|
||||||
|
{
|
||||||
|
LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Received %s from %s", strPacketID.c_str(), player.npc.mName.c_str());
|
||||||
|
|
||||||
|
packet.Send(false);
|
||||||
|
packet.Send(true);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -396,8 +396,23 @@ namespace MWGui
|
||||||
if (mCurrentBalance != 0)
|
if (mCurrentBalance != 0)
|
||||||
{
|
{
|
||||||
addOrRemoveGold(mCurrentBalance, player);
|
addOrRemoveGold(mCurrentBalance, player);
|
||||||
mPtr.getClass().getCreatureStats(mPtr).setGoldPool(
|
|
||||||
mPtr.getClass().getCreatureStats(mPtr).getGoldPool() - mCurrentBalance );
|
/*
|
||||||
|
Start of tes3mp change (major)
|
||||||
|
|
||||||
|
Don't unilaterally change the merchant's gold pool on our client and instead let the server do it
|
||||||
|
*/
|
||||||
|
//mPtr.getClass().getCreatureStats(mPtr).setGoldPool(
|
||||||
|
// mPtr.getClass().getCreatureStats(mPtr).getGoldPool() - mCurrentBalance);
|
||||||
|
|
||||||
|
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
|
||||||
|
objectList->reset();
|
||||||
|
objectList->packetOrigin = mwmp::CLIENT_GAMEPLAY;
|
||||||
|
objectList->addObjectMiscellaneous(mPtr, mPtr.getClass().getCreatureStats(mPtr).getGoldPool() - mCurrentBalance);
|
||||||
|
objectList->sendObjectMiscellaneous();
|
||||||
|
/*
|
||||||
|
End of tes3mp change (major)
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
eventTradeDone();
|
eventTradeDone();
|
||||||
|
|
|
@ -813,6 +813,33 @@ void ObjectList::playObjectSounds(MWWorld::CellStore* cellStore)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ObjectList::setGoldPoolsForObjects(MWWorld::CellStore* cellStore)
|
||||||
|
{
|
||||||
|
for (const auto& baseObject : baseObjects)
|
||||||
|
{
|
||||||
|
LOG_APPEND(TimedLog::LOG_VERBOSE, "- cellRef: %s %i-%i", baseObject.refId.c_str(), baseObject.refNum, baseObject.mpNum);
|
||||||
|
|
||||||
|
MWWorld::Ptr ptrFound = cellStore->searchExact(baseObject.refNum, baseObject.mpNum);
|
||||||
|
|
||||||
|
if (ptrFound)
|
||||||
|
{
|
||||||
|
LOG_APPEND(TimedLog::LOG_VERBOSE, "-- Found %s %i-%i", ptrFound.getCellRef().getRefId().c_str(),
|
||||||
|
ptrFound.getCellRef().getRefNum(), ptrFound.getCellRef().getMpNum());
|
||||||
|
|
||||||
|
if (ptrFound.getClass().isActor())
|
||||||
|
{
|
||||||
|
LOG_APPEND(TimedLog::LOG_VERBOSE, "-- Setting gold pool to %u", baseObject.goldPool);
|
||||||
|
ptrFound.getClass().getCreatureStats(ptrFound).setGoldPool(baseObject.goldPool);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOG_MESSAGE_SIMPLE(TimedLog::LOG_WARN, "Failed to set gold pool on %s %i-%i because it is not an actor!",
|
||||||
|
ptrFound.getCellRef().getRefId().c_str(), ptrFound.getCellRef().getRefNum(), ptrFound.getCellRef().getMpNum());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ObjectList::activateDoors(MWWorld::CellStore* cellStore)
|
void ObjectList::activateDoors(MWWorld::CellStore* cellStore)
|
||||||
{
|
{
|
||||||
for (const auto &baseObject : baseObjects)
|
for (const auto &baseObject : baseObjects)
|
||||||
|
@ -1166,6 +1193,15 @@ void ObjectList::addObjectLock(const MWWorld::Ptr& ptr, int lockLevel)
|
||||||
addBaseObject(baseObject);
|
addBaseObject(baseObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ObjectList::addObjectMiscellaneous(const MWWorld::Ptr& ptr, unsigned int goldPool)
|
||||||
|
{
|
||||||
|
cell = *ptr.getCell()->getCell();
|
||||||
|
|
||||||
|
mwmp::BaseObject baseObject = getBaseObjectFromPtr(ptr);
|
||||||
|
baseObject.goldPool = goldPool;
|
||||||
|
addBaseObject(baseObject);
|
||||||
|
}
|
||||||
|
|
||||||
void ObjectList::addObjectTrap(const MWWorld::Ptr& ptr, const ESM::Position& pos, bool isDisarmed)
|
void ObjectList::addObjectTrap(const MWWorld::Ptr& ptr, const ESM::Position& pos, bool isDisarmed)
|
||||||
{
|
{
|
||||||
cell = *ptr.getCell()->getCell();
|
cell = *ptr.getCell()->getCell();
|
||||||
|
@ -1322,6 +1358,12 @@ void ObjectList::sendObjectLock()
|
||||||
mwmp::Main::get().getNetworking()->getObjectPacket(ID_OBJECT_LOCK)->Send();
|
mwmp::Main::get().getNetworking()->getObjectPacket(ID_OBJECT_LOCK)->Send();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ObjectList::sendObjectMiscellaneous()
|
||||||
|
{
|
||||||
|
mwmp::Main::get().getNetworking()->getObjectPacket(ID_OBJECT_MISCELLANEOUS)->setObjectList(this);
|
||||||
|
mwmp::Main::get().getNetworking()->getObjectPacket(ID_OBJECT_MISCELLANEOUS)->Send();
|
||||||
|
}
|
||||||
|
|
||||||
void ObjectList::sendObjectRestock()
|
void ObjectList::sendObjectRestock()
|
||||||
{
|
{
|
||||||
mwmp::Main::get().getNetworking()->getObjectPacket(ID_OBJECT_RESTOCK)->setObjectList(this);
|
mwmp::Main::get().getNetworking()->getObjectPacket(ID_OBJECT_RESTOCK)->setObjectList(this);
|
||||||
|
|
|
@ -38,6 +38,7 @@ namespace mwmp
|
||||||
void rotateObjects(MWWorld::CellStore* cellStore);
|
void rotateObjects(MWWorld::CellStore* cellStore);
|
||||||
void animateObjects(MWWorld::CellStore* cellStore);
|
void animateObjects(MWWorld::CellStore* cellStore);
|
||||||
void playObjectSounds(MWWorld::CellStore* cellStore);
|
void playObjectSounds(MWWorld::CellStore* cellStore);
|
||||||
|
void setGoldPoolsForObjects(MWWorld::CellStore* cellStore);
|
||||||
void activateDoors(MWWorld::CellStore* cellStore);
|
void activateDoors(MWWorld::CellStore* cellStore);
|
||||||
void setDoorDestinations(MWWorld::CellStore* cellStore);
|
void setDoorDestinations(MWWorld::CellStore* cellStore);
|
||||||
void runConsoleCommands(MWWorld::CellStore* cellStore);
|
void runConsoleCommands(MWWorld::CellStore* cellStore);
|
||||||
|
@ -59,6 +60,7 @@ namespace mwmp
|
||||||
void addObjectSpawn(const MWWorld::Ptr& ptr);
|
void addObjectSpawn(const MWWorld::Ptr& ptr);
|
||||||
void addObjectSpawn(const MWWorld::Ptr& ptr, const MWWorld::Ptr& master, std::string spellId, int effectId, float duration);
|
void addObjectSpawn(const MWWorld::Ptr& ptr, const MWWorld::Ptr& master, std::string spellId, int effectId, float duration);
|
||||||
void addObjectLock(const MWWorld::Ptr& ptr, int lockLevel);
|
void addObjectLock(const MWWorld::Ptr& ptr, int lockLevel);
|
||||||
|
void addObjectMiscellaneous(const MWWorld::Ptr& ptr, unsigned int goldPool);
|
||||||
void addObjectTrap(const MWWorld::Ptr& ptr, const ESM::Position& pos, bool isDisarmed);
|
void addObjectTrap(const MWWorld::Ptr& ptr, const ESM::Position& pos, bool isDisarmed);
|
||||||
void addObjectScale(const MWWorld::Ptr& ptr, float scale);
|
void addObjectScale(const MWWorld::Ptr& ptr, float scale);
|
||||||
void addObjectSound(const MWWorld::Ptr& ptr, std::string soundId, float volume, float pitch);
|
void addObjectSound(const MWWorld::Ptr& ptr, std::string soundId, float volume, float pitch);
|
||||||
|
@ -78,6 +80,7 @@ namespace mwmp
|
||||||
void sendObjectSpawn();
|
void sendObjectSpawn();
|
||||||
void sendObjectDelete();
|
void sendObjectDelete();
|
||||||
void sendObjectLock();
|
void sendObjectLock();
|
||||||
|
void sendObjectMiscellaneous();
|
||||||
void sendObjectRestock();
|
void sendObjectRestock();
|
||||||
void sendObjectTrap();
|
void sendObjectTrap();
|
||||||
void sendObjectScale();
|
void sendObjectScale();
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
#ifndef OPENMW_PROCESSOROBJECTMISCELLANEOUS_HPP
|
#ifndef OPENMW_PROCESSOROBJECTMISCELLANEOUS_HPP
|
||||||
#define OPENMW_PROCESSOROBJECTMISCELLANEOUS_HPP
|
#define OPENMW_PROCESSOROBJECTMISCELLANEOUS_HPP
|
||||||
|
|
||||||
#include "../ObjectProcessor.hpp"
|
#include "BaseObjectProcessor.hpp"
|
||||||
|
|
||||||
namespace mwmp
|
namespace mwmp
|
||||||
{
|
{
|
||||||
class ProcessorObjectMiscellaneous final: public ObjectProcessor
|
class ProcessorObjectMiscellaneous final: public BaseObjectProcessor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ProcessorObjectMiscellaneous()
|
ProcessorObjectMiscellaneous()
|
||||||
|
@ -16,6 +16,10 @@ namespace mwmp
|
||||||
virtual void Do(ObjectPacket &packet, ObjectList &objectList)
|
virtual void Do(ObjectPacket &packet, ObjectList &objectList)
|
||||||
{
|
{
|
||||||
LOG_MESSAGE_SIMPLE(TimedLog::LOG_VERBOSE, "Received %s", strPacketID.c_str());
|
LOG_MESSAGE_SIMPLE(TimedLog::LOG_VERBOSE, "Received %s", strPacketID.c_str());
|
||||||
|
|
||||||
|
BaseObjectProcessor::Do(packet, objectList);
|
||||||
|
|
||||||
|
objectList.setGoldPoolsForObjects(ptrCellStore);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,8 @@ namespace mwmp
|
||||||
float volume;
|
float volume;
|
||||||
float pitch;
|
float pitch;
|
||||||
|
|
||||||
|
unsigned int goldPool;
|
||||||
|
|
||||||
int doorState;
|
int doorState;
|
||||||
bool teleportState;
|
bool teleportState;
|
||||||
ESM::Cell destinationCell;
|
ESM::Cell destinationCell;
|
||||||
|
|
|
@ -6,9 +6,11 @@ using namespace mwmp;
|
||||||
PacketObjectMiscellaneous::PacketObjectMiscellaneous(RakNet::RakPeerInterface *peer) : ObjectPacket(peer)
|
PacketObjectMiscellaneous::PacketObjectMiscellaneous(RakNet::RakPeerInterface *peer) : ObjectPacket(peer)
|
||||||
{
|
{
|
||||||
packetID = ID_OBJECT_MISCELLANEOUS;
|
packetID = ID_OBJECT_MISCELLANEOUS;
|
||||||
|
hasCellData = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PacketObjectMiscellaneous::Object(BaseObject &baseObject, bool send)
|
void PacketObjectMiscellaneous::Object(BaseObject &baseObject, bool send)
|
||||||
{
|
{
|
||||||
|
ObjectPacket::Object(baseObject, send);
|
||||||
|
RW(baseObject.goldPool, send);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue