Permalink
Browse files

Temporary fix for the Baselines caching problem. Before this point we…

… would amass an arbitrarily large "cache" of baselines and send them.
  • Loading branch information...
rcythr committed Mar 19, 2013
1 parent 59c32cf commit 3993e57e8864da04c74e163f01335fa5df0f2ae0
@@ -21,14 +21,9 @@ void BuildingMessageBuilder::RegisterEventHandlers()
void BuildingMessageBuilder::SendBaselines(const shared_ptr<Building>& tangible, const shared_ptr<swganh::observer::ObserverInterface>& observer)
{
- tangible->AddBaselineToCache(&BuildBaseline3(tangible));
- tangible->AddBaselineToCache(&BuildBaseline6(tangible));
-
- for (auto& baseline : tangible->GetBaselines())
- {
- observer->Notify(&baseline);
- }
-
+ observer->Notify(&BuildBaseline3(tangible));
+ observer->Notify(&BuildBaseline6(tangible));
+
SendEndBaselines(tangible, observer);
}
@@ -22,14 +22,9 @@ void CellMessageBuilder::RegisterEventHandlers()
void CellMessageBuilder::SendBaselines(const std::shared_ptr<Cell>& cell, const std::shared_ptr<swganh::observer::ObserverInterface>& observer)
{
- cell->AddBaselineToCache(&BuildBaseline3(cell));
- cell->AddBaselineToCache(&BuildBaseline6(cell));
-
- for (auto& baseline : cell->GetBaselines())
- {
- observer->Notify(&baseline);
- }
-
+ observer->Notify(&BuildBaseline3(cell));
+ observer->Notify(&BuildBaseline6(cell));
+
SendEndBaselines(cell, observer);
}
@@ -219,14 +219,10 @@ void CreatureMessageBuilder::RegisterEventHandlers()
}
void CreatureMessageBuilder::SendBaselines(const shared_ptr<Creature>& creature, const shared_ptr<swganh::observer::ObserverInterface>& observer)
{
- creature->AddBaselineToCache(&BuildBaseline1(creature));
- creature->AddBaselineToCache(&BuildBaseline3(creature));
- creature->AddBaselineToCache(&BuildBaseline4(creature));
- creature->AddBaselineToCache(&BuildBaseline6(creature));
- for (auto& baseline : creature->GetBaselines())
- {
- observer->Notify(&baseline);
- }
+ observer->Notify(&BuildBaseline1(creature));
+ observer->Notify(&BuildBaseline3(creature));
+ observer->Notify(&BuildBaseline4(creature));
+ observer->Notify(&BuildBaseline6(creature));
SendEndBaselines(creature, observer);
@@ -21,13 +21,8 @@ void FactoryCrateMessageBuilder::RegisterEventHandlers()
void FactoryCrateMessageBuilder::SendBaselines(const shared_ptr<FactoryCrate>& factory_crate, const shared_ptr<swganh::observer::ObserverInterface>& observer)
{
- factory_crate->AddBaselineToCache(&BuildBaseline3(factory_crate));
- factory_crate->AddBaselineToCache(&BuildBaseline6(factory_crate));
-
- for (auto& baseline : factory_crate->GetBaselines())
- {
- observer->Notify(&baseline);
- }
+ observer->Notify(&BuildBaseline3(factory_crate));
+ observer->Notify(&BuildBaseline6(factory_crate));
SendEndBaselines(factory_crate, observer);
}
@@ -63,13 +63,8 @@ void GroupMessageBuilder::BuildLootMasterDelta(const shared_ptr<Group>& group)
void GroupMessageBuilder::SendBaselines(const std::shared_ptr<Group>& group, const std::shared_ptr<swganh::observer::ObserverInterface>& observer)
{
- group->AddBaselineToCache(&BuildBaseline3(group));
- group->AddBaselineToCache(&BuildBaseline6(group));
-
- for (auto& baseline : group->GetBaselines())
- {
- observer->Notify(&baseline);
- }
+ observer->Notify(&BuildBaseline3(group));
+ observer->Notify(&BuildBaseline6(group));
SendEndBaselines(group, observer);
}
@@ -30,8 +30,8 @@ void GuildMessageBuilder::BuildGuildTagsDelta(const shared_ptr<Guild>& guild)
void GuildMessageBuilder::SendBaselines(const std::shared_ptr<Guild>& guild, const std::shared_ptr<swganh::observer::ObserverInterface>& observer)
{
- guild->AddBaselineToCache(&BuildBaseline3(guild));
- guild->AddBaselineToCache(&BuildBaseline6(guild));
+ observer->Notify(&BuildBaseline3(guild));
+ observer->Notify(&BuildBaseline6(guild));
for (auto& baseline : guild->GetBaselines())
{
@@ -21,14 +21,9 @@ void HarvesterInstallationMessageBuilder::RegisterEventHandlers()
void HarvesterInstallationMessageBuilder::SendBaselines(const shared_ptr<HarvesterInstallation>& harvester_installation, const shared_ptr<swganh::observer::ObserverInterface>& observer)
{
- harvester_installation->AddBaselineToCache(&BuildBaseline3(harvester_installation));
- harvester_installation->AddBaselineToCache(&BuildBaseline6(harvester_installation));
- harvester_installation->AddBaselineToCache(&BuildBaseline7(harvester_installation));
-
- for (auto& baseline : harvester_installation->GetBaselines())
- {
- observer->Notify(&baseline);
- }
+ observer->Notify(&BuildBaseline3(harvester_installation));
+ observer->Notify(&BuildBaseline6(harvester_installation));
+ observer->Notify(&BuildBaseline7(harvester_installation));
SendEndBaselines(harvester_installation, observer);
}
@@ -86,9 +86,9 @@ void InstallationMessageBuilder::RegisterEventHandlers()
void InstallationMessageBuilder::SendBaselines(const std::shared_ptr<Installation>& installation, const std::shared_ptr<swganh::observer::ObserverInterface>& observer)
{
- installation->AddBaselineToCache(&BuildBaseline3(installation));
- installation->AddBaselineToCache(&BuildBaseline6(installation));
- installation->AddBaselineToCache(&BuildBaseline7(installation));
+ observer->Notify(&BuildBaseline3(installation));
+ observer->Notify(&BuildBaseline6(installation));
+ observer->Notify(&BuildBaseline7(installation));
for (auto& baseline : installation->GetBaselines())
{
@@ -19,8 +19,8 @@ void IntangibleMessageBuilder::RegisterEventHandlers()
void IntangibleMessageBuilder::SendBaselines(const std::shared_ptr<Intangible>& intangible, const std::shared_ptr<swganh::observer::ObserverInterface>& observer)
{
- intangible->AddBaselineToCache(&BuildBaseline3(intangible));
- intangible->AddBaselineToCache(&BuildBaseline6(intangible));
+ observer->Notify(&BuildBaseline3(intangible));
+ observer->Notify(&BuildBaseline6(intangible));
for (auto& baseline : intangible->GetBaselines())
{
@@ -95,14 +95,9 @@ void ManufactureSchematicMessageBuilder::SendBaselines(
const std::shared_ptr<ManufactureSchematic>& manufacture_schematic,
const std::shared_ptr<swganh::observer::ObserverInterface>& observer)
{
- manufacture_schematic->AddBaselineToCache(&BuildBaseline3(manufacture_schematic));
- manufacture_schematic->AddBaselineToCache(&BuildBaseline6(manufacture_schematic));
- manufacture_schematic->AddBaselineToCache(&BuildBaseline7(manufacture_schematic));
-
- for (auto& baseline : manufacture_schematic->GetBaselines())
- {
- observer->Notify(&baseline);
- }
+ observer->Notify(&BuildBaseline3(manufacture_schematic));
+ observer->Notify(&BuildBaseline6(manufacture_schematic));
+ observer->Notify(&BuildBaseline7(manufacture_schematic));
SendEndBaselines(manufacture_schematic, observer);
}
@@ -236,13 +236,8 @@ void MissionMessageBuilder::BuildMissionWaypointDelta(const std::shared_ptr<Miss
void MissionMessageBuilder::SendBaselines(const std::shared_ptr<Mission>& mission, const std::shared_ptr<swganh::observer::ObserverInterface>& observer)
{
- mission->AddBaselineToCache(&BuildBaseline3(mission));
- mission->AddBaselineToCache(&BuildBaseline6(mission));
-
- for (auto& baseline : mission->GetBaselines())
- {
- observer->Notify(&baseline);
- }
+ observer->Notify(&BuildBaseline3(mission));
+ observer->Notify(&BuildBaseline6(mission));
SendEndBaselines(mission, observer);
}
@@ -568,40 +568,21 @@ void Object::NotifyObservers(swganh::messages::BaseSwgMessage* message)
});
}
-bool Object::IsDirty()
-{
- boost::lock_guard<boost::mutex> lock(object_mutex_);
- return !deltas_.empty();
-}
void Object::ClearBaselines()
{
boost::lock_guard<boost::mutex> lock(object_mutex_);
baselines_.clear();
}
-void Object::ClearDeltas()
-{
- boost::lock_guard<boost::mutex> lock(object_mutex_);
- deltas_.clear();
-}
BaselinesCacheContainer Object::GetBaselines()
{
boost::lock_guard<boost::mutex> lock(object_mutex_);
return baselines_;
}
-DeltasCacheContainer Object::GetDeltas(uint64_t viewer_id)
-{
- boost::lock_guard<boost::mutex> lock(object_mutex_);
- return deltas_;
-}
-
void Object::AddDeltasUpdate(DeltasMessage* message)
{
NotifyObservers(message);
-
- boost::lock_guard<boost::mutex> lock(object_mutex_);
- deltas_.push_back(*message);
}
void Object::AddBaselineToCache(swganh::messages::BaselinesMessage* baseline)
{
@@ -48,10 +48,6 @@ typedef std::vector<
swganh::messages::BaselinesMessage
> BaselinesCacheContainer;
-typedef std::vector<
- swganh::messages::DeltasMessage
-> DeltasCacheContainer;
-
typedef std::map<
swganh::HashString,
boost::variant<float, int64_t, std::wstring>
@@ -233,15 +229,6 @@ class Object :
*/
BaselinesCacheContainer GetBaselines() ;
- /**
- * Returns the deltas messages generated since the last time the
- * object was made clean.
- *
- * @param viewer_id The id of the object viewing this Object instance.
- * @return The most recently generated deltas.
- */
- DeltasCacheContainer GetDeltas(uint64_t viewer_id) ;
-
/**
* Return the client iff template file that describes this Object.
*
@@ -707,7 +694,6 @@ class Object :
AwareObjectContainer aware_objects_;
BaselinesCacheContainer baselines_;
- DeltasCacheContainer deltas_;
std::shared_ptr<ContainerInterface> container_;
@@ -175,16 +175,10 @@ void PlayerMessageBuilder::RegisterEventHandlers()
void PlayerMessageBuilder::SendBaselines(const shared_ptr<Player>& player, const shared_ptr<swganh::observer::ObserverInterface>& observer)
{
- player->AddBaselineToCache(&BuildBaseline3(player));
- player->AddBaselineToCache(&BuildBaseline6(player));
- player->AddBaselineToCache(&BuildBaseline8(player));
- player->AddBaselineToCache(&BuildBaseline9(player));
-
-
- for (auto& baseline : player->GetBaselines())
- {
- observer->Notify(&baseline);
- }
+ observer->Notify(&BuildBaseline3(player));
+ observer->Notify(&BuildBaseline6(player));
+ observer->Notify(&BuildBaseline8(player));
+ observer->Notify(&BuildBaseline9(player));
SendEndBaselines(player, observer);
}
@@ -103,13 +103,8 @@ void ResourceContainerMessageBuilder::BuildVariationNameDelta(const std::shared_
void ResourceContainerMessageBuilder::SendBaselines(const std::shared_ptr<ResourceContainer>& resource_container, const std::shared_ptr<swganh::observer::ObserverInterface>& observer)
{
- resource_container->AddBaselineToCache(&BuildBaseline3(resource_container));
- resource_container->AddBaselineToCache(&BuildBaseline6(resource_container));
-
- for (auto& baseline : resource_container->GetBaselines())
- {
- observer->Notify(&baseline);
- }
+ observer->Notify(&BuildBaseline3(resource_container));
+ observer->Notify(&BuildBaseline6(resource_container));
SendEndBaselines(resource_container, observer);
}
@@ -15,8 +15,8 @@ void StaticMessageBuilder::RegisterEventHandlers()
void StaticMessageBuilder::SendBaselines(const std::shared_ptr<Static>& static_object, const std::shared_ptr<swganh::observer::ObserverInterface>& observer)
{
- static_object->AddBaselineToCache(&BuildBaseline3(static_object));
- static_object->AddBaselineToCache(&BuildBaseline6(static_object));
+ observer->Notify(&BuildBaseline3(static_object));
+ observer->Notify(&BuildBaseline6(static_object));
for (auto& baseline : static_object->GetBaselines())
{
@@ -73,14 +73,9 @@ void TangibleMessageBuilder::RegisterEventHandlers()
}
void TangibleMessageBuilder::SendBaselines(const shared_ptr<Tangible>& tangible, const shared_ptr<swganh::observer::ObserverInterface>& observer)
{
- tangible->AddBaselineToCache(&BuildBaseline3(tangible));
- tangible->AddBaselineToCache(&BuildBaseline6(tangible));
- tangible->AddBaselineToCache(&BuildBaseline7(tangible));
-
- for (auto& baseline : tangible->GetBaselines())
- {
- observer->Notify(&baseline);
- }
+ observer->Notify(&BuildBaseline3(tangible));
+ observer->Notify(&BuildBaseline6(tangible));
+ observer->Notify(&BuildBaseline7(tangible));
SendEndBaselines(tangible, observer);
}
@@ -91,8 +91,8 @@ void WaypointMessageBuilder::BuildColorDelta(const shared_ptr<Waypoint>& object)
void WaypointMessageBuilder::SendBaselines(const std::shared_ptr<Waypoint>& waypoint, const std::shared_ptr<swganh::observer::ObserverInterface>& observer)
{
- waypoint->AddBaselineToCache(&BuildBaseline3(waypoint));
- waypoint->AddBaselineToCache(&BuildBaseline6(waypoint));
+ observer->Notify(&BuildBaseline3(waypoint));
+ observer->Notify(&BuildBaseline6(waypoint));
for (auto& baseline : waypoint->GetBaselines())
{
@@ -21,13 +21,8 @@ void WeaponMessageBuilder::RegisterEventHandlers()
void WeaponMessageBuilder::SendBaselines(const shared_ptr<Weapon>& weapon, const shared_ptr<swganh::observer::ObserverInterface>& observer)
{
- weapon->AddBaselineToCache(&BuildBaseline3(weapon));
- weapon->AddBaselineToCache(&BuildBaseline6(weapon));
-
- for (auto& baseline : weapon->GetBaselines())
- {
- observer->Notify(&baseline);
- }
+ observer->Notify(&BuildBaseline3(weapon));
+ observer->Notify(&BuildBaseline6(weapon));
SendEndBaselines(weapon, observer);
}

0 comments on commit 3993e57

Please sign in to comment.