Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // ChunkManager.h
- // Chunky
- //
- // Created by Dylan Lukes on 2/17/11.
- // Copyright 2011 Dylan Lukes. All rights reserved.
- //
- #include <map>
- /* Constants */
- // Size of chunk in memory
- static const long ChunkMemSize = 81920;
- // Approx. 2GB swap space
- static const long SmallSwapSize = 26215;
- // Approx. 4GB swap space
- static const long MediumSwapSize = SmallSwapSize * 2;
- /** struct ChunkPos: Chunk key container (for map)
- *
- */
- struct ChunkPos {
- long x;
- long z;
- };
- /** struct ChunkInfo: Chunk information container (for map)
- * dirty: Has the chunk been modified since it's last load?
- * resident: Is the chunk in memory? (alternatively, it's on disk)
- * occupied: Is there a player near or in this chunk?
- * offset: What is the offset into the swap file (only valid for non-resident)
- */
- struct ChunkInfo {
- bool dirty;
- bool resident;
- bool occupied;
- long offset;
- };
- class ChunkManager {
- std::map<ChunkPos, ChunkInfo> chunkLookup;
- long swapSize;
- public:
- ChunkManager(long swapSize);
- ~ChunkManager();
- /* Testing methods: both of these modify the chunk info (in different ways) */
- void playerInChunk(ChunkPos chunk);
- void blockEditInChunk(ChunkPos chunk);
- };
Add Comment
Please, Sign In to add comment