Skip to content

Commit

Permalink
Don't set entity world twice (cuberite#4606)
Browse files Browse the repository at this point in the history
* Don't set entity world twice

* Call HookSpawnedEntity when the entity actually spawned
  • Loading branch information
mathiascode authored Apr 9, 2020
1 parent bdedab1 commit d966a12
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 4 deletions.
3 changes: 0 additions & 3 deletions src/Entities/Entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,6 @@ bool cEntity::Initialize(OwnedEntity a_Self, cWorld & a_EntityWorld)
ASSERT(m_World == nullptr);
ASSERT(GetParentChunk() == nullptr);
a_EntityWorld.AddEntity(std::move(a_Self));
ASSERT(m_World != nullptr);

cPluginManager::Get()->CallHookSpawnedEntity(a_EntityWorld, *this);

return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,7 @@ void cWorld::Tick(std::chrono::milliseconds a_Dt, std::chrono::milliseconds a_La
EntityPtr->OnAddToWorld(*this);
ASSERT(!EntityPtr->IsTicking());
EntityPtr->SetIsTicking(true);
cPluginManager::Get()->CallHookSpawnedEntity(*this, *Entity);
}
EntitiesToAdd.clear();

Expand Down Expand Up @@ -3088,7 +3089,6 @@ void cWorld::ScheduleTask(int a_DelayTicks, std::function<void (cWorld &)> a_Tas

void cWorld::AddEntity(OwnedEntity a_Entity)
{
a_Entity->SetWorld(this);
cCSLock Lock(m_CSEntitiesToAdd);
m_EntitiesToAdd.emplace_back(std::move(a_Entity));
}
Expand Down

0 comments on commit d966a12

Please sign in to comment.