Guest User

Untitled

a guest
Jul 22nd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. //
  2. // ChunkManager.h
  3. // Chunky
  4. //
  5. // Created by Dylan Lukes on 2/17/11.
  6. // Copyright 2011 Dylan Lukes. All rights reserved.
  7. //
  8.  
  9. #include <map>
  10.  
  11. /* Constants */
  12.  
  13. // Size of chunk in memory
  14. static const long ChunkMemSize = 81920;
  15. // Approx. 2GB swap space
  16. static const long SmallSwapSize = 26215;
  17. // Approx. 4GB swap space
  18. static const long MediumSwapSize = SmallSwapSize * 2;
  19.  
  20. /** struct ChunkPos: Chunk key container (for map)
  21. *
  22. */
  23. struct ChunkPos {
  24. long x;
  25. long z;
  26. };
  27.  
  28. /** struct ChunkInfo: Chunk information container (for map)
  29. * dirty: Has the chunk been modified since it's last load?
  30. * resident: Is the chunk in memory? (alternatively, it's on disk)
  31. * occupied: Is there a player near or in this chunk?
  32. * offset: What is the offset into the swap file (only valid for non-resident)
  33. */
  34. struct ChunkInfo {
  35. bool dirty;
  36. bool resident;
  37. bool occupied;
  38. long offset;
  39. };
  40.  
  41. class ChunkManager {
  42. std::map<ChunkPos, ChunkInfo> chunkLookup;
  43. long swapSize;
  44. public:
  45. ChunkManager(long swapSize);
  46. ~ChunkManager();
  47.  
  48. /* Testing methods: both of these modify the chunk info (in different ways) */
  49. void playerInChunk(ChunkPos chunk);
  50. void blockEditInChunk(ChunkPos chunk);
  51. };
Add Comment
Please, Sign In to add comment