Browse Source

fix lighting server ordering

feature/replace-renderer
Martin Dørum 3 years ago
parent
commit
a3bb6ea0e7
2 changed files with 8 additions and 4 deletions
  1. 6
    2
      libswan/include/swan/WorldPlane.h
  2. 2
    2
      libswan/src/WorldPlane.cc

+ 6
- 2
libswan/include/swan/WorldPlane.h View File

@@ -88,8 +88,6 @@ public:
std::mutex mut_;

private:
std::unique_ptr<LightServer> lighting_;

std::map<std::pair<int, int>, Chunk> chunks_;
std::vector<Chunk *> activeChunks_;
std::vector<std::pair<ChunkPos, Chunk *>> tickChunks_;
@@ -99,6 +97,12 @@ private:

std::deque<Chunk *> chunkInitList_;
std::vector<TilePos> debugBoxes_;

// The lighting server must destruct first. Until it has been destructed,
// it might call onLightChunkUpdated. If that happens after some other
// members have destructed, we have a problem.
// TODO: Rewrite this to not use a callback-based interface.
std::unique_ptr<LightServer> lighting_;
};

/*

+ 2
- 2
libswan/src/WorldPlane.cc View File

@@ -44,8 +44,8 @@ WorldPlane::WorldPlane(
ID id, World *world, std::unique_ptr<WorldGen> gen,
std::vector<std::unique_ptr<EntityCollection>> &&colls):
id_(id), world_(world), gen_(std::move(gen)),
lighting_(std::make_unique<LightServer>(*this)),
entColls_(std::move(colls)) {
entColls_(std::move(colls)),
lighting_(std::make_unique<LightServer>(*this)) {

for (auto &coll: entColls_) {
entCollsByType_[coll->type()] = coll.get();

Loading…
Cancel
Save