diff --git a/dGame/dComponents/LUPExhibitComponent.cpp b/dGame/dComponents/LUPExhibitComponent.cpp index 67014bbc..9034d7aa 100644 --- a/dGame/dComponents/LUPExhibitComponent.cpp +++ b/dGame/dComponents/LUPExhibitComponent.cpp @@ -3,42 +3,32 @@ #include "EntityManager.h" LUPExhibitComponent::LUPExhibitComponent(Entity* parent) : Component(parent) { - m_Exhibits = { 11121, 11295, 11423, 11979 }; - m_ExhibitIndex = 0; - - m_Exhibit = m_Exhibits[m_ExhibitIndex]; - - -} - -LUPExhibitComponent::~LUPExhibitComponent() { - + m_UpdateTimer = 0.0f; + m_Exhibit = m_Exhibits.front(); + m_DirtyExhibitInfo = true; } void LUPExhibitComponent::Update(float deltaTime) { m_UpdateTimer += deltaTime; + if (m_UpdateTimer < 20.0f) return; - if (m_UpdateTimer > 20.0f) { - NextExhibit(); - - m_UpdateTimer = 0.0f; - } + NextExhibit(); + m_UpdateTimer = 0.0f; } void LUPExhibitComponent::NextExhibit() { m_ExhibitIndex++; - if (m_ExhibitIndex >= m_Exhibits.size()) { - m_ExhibitIndex = 0; - } - - m_Exhibit = m_Exhibits[m_ExhibitIndex]; - + // After 1361 years, this will skip exhibit 4 one time. I think modulo is ok here. + m_Exhibit = m_Exhibits.at(m_ExhibitIndex % m_Exhibits.size()); EntityManager::Instance()->SerializeEntity(m_ParentEntity); } void LUPExhibitComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, uint32_t& flags) { - outBitStream->Write1(); // Dirty flag? - outBitStream->Write(m_Exhibit); + outBitStream->Write(bIsInitialUpdate || m_DirtyExhibitInfo); + if (bIsInitialUpdate || m_DirtyExhibitInfo) { + outBitStream->Write(m_Exhibit); + if (!bIsInitialUpdate) m_DirtyExhibitInfo = false; + } } diff --git a/dGame/dComponents/LUPExhibitComponent.h b/dGame/dComponents/LUPExhibitComponent.h index e8db875b..bfa86b48 100644 --- a/dGame/dComponents/LUPExhibitComponent.h +++ b/dGame/dComponents/LUPExhibitComponent.h @@ -8,13 +8,12 @@ * Component that handles the LOT that is shown in the LUP exhibit in the LUP world. Works by setting a timer and * switching the LOTs around that we'd like to display. */ -class LUPExhibitComponent : public Component +class LUPExhibitComponent final : public Component { public: inline static const eReplicaComponentType ComponentType = eReplicaComponentType::EXHIBIT; LUPExhibitComponent(Entity* parent); - ~LUPExhibitComponent(); void Update(float deltaTime) override; void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, uint32_t& flags); @@ -36,10 +35,13 @@ private: /** * The list of possible exhibits to show */ - std::vector m_Exhibits; + const std::vector m_Exhibits = { 11121, 11295, 11423, 11979 }; /** * The current index in the exhibit list */ size_t m_ExhibitIndex; + + // Whether or not to notify clients of a change in the visible exhibit + bool m_DirtyExhibitInfo; };