Updated vendor component

Fixed a few issues in VendorComponent.
- Corrected serialization to only happen on construction.
- Added functionality to refresh the vendor based on info from the vendor component table
- some whitespaceing inconsistencies.
- Sorted includes.
Tested the vendor in Nimbus Station and when the player re-enters the world, the vendor inventory refreshes, as opposed to previously where the world would need to reset in order to refresh the inventory.
This commit is contained in:
EmosewaMC
2022-04-26 03:41:16 -07:00
parent aca2bb1090
commit 5afeb265cd
5 changed files with 133 additions and 93 deletions

View File

@@ -1252,8 +1252,7 @@ void GameMessages::SendVendorOpenWindow(Entity* entity, const SystemAddress& sys
SEND_PACKET
}
// ah yes, impl code in a send function, beautiful!
void GameMessages::SendVendorStatusUpdate(Entity* entity, const SystemAddress& sysAddr) {
void GameMessages::SendVendorStatusUpdate(Entity* entity, const SystemAddress& sysAddr, bool bUpdateOnly) {
CBITSTREAM
CMSGHEADER
@@ -1265,7 +1264,7 @@ void GameMessages::SendVendorStatusUpdate(Entity* entity, const SystemAddress& s
bitStream.Write(entity->GetObjectID());
bitStream.Write(GAME_MSG::GAME_MSG_VENDOR_STATUS_UPDATE);
bitStream.Write(false);
bitStream.Write(bUpdateOnly);
bitStream.Write(static_cast<uint32_t>(vendorItems.size()));
for (std::pair<LOT, int> item : vendorItems) {
@@ -1273,6 +1272,7 @@ void GameMessages::SendVendorStatusUpdate(Entity* entity, const SystemAddress& s
bitStream.Write(static_cast<int>(item.second));
}
if (sysAddr == UNASSIGNED_SYSTEM_ADDRESS) SEND_PACKET_BROADCAST
SEND_PACKET
}

View File

@@ -109,7 +109,7 @@ namespace GameMessages {
void SendModularBuildEnd(Entity* entity);
void SendVendorOpenWindow(Entity* entity, const SystemAddress& sysAddr);
void SendVendorStatusUpdate(Entity* entity, const SystemAddress& sysAddr);
void SendVendorStatusUpdate(Entity* entity, const SystemAddress& sysAddr, bool bUpdateOnly = false);
void SendVendorTransactionResult(Entity* entity, const SystemAddress& sysAddr);
void SendRemoveItemFromInventory(Entity* entity, const SystemAddress& sysAddr, LWOOBJID iObjID, LOT templateID, int inventoryType, uint32_t stackCount, uint32_t stackRemaining);