@WorldVer.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /******************************************************************************/
  2. class WorldVer
  3. {
  4. static bool CreateRebuild (byte &area_rebuild_flag, C VecI2 &area_xy, ptr); // set empty initially
  5. static bool CreateObjEmbed(RectI &obj_area , C UID &id , ptr); // set invalid initially
  6. bool changed; // if any member was changed, and the 'WorldVer' needs to be flushed to disk
  7. Str path;
  8. UID world_id;
  9. ThreadSafeMap<VecI2, AreaVer > areas ; // make this thread-safe because Area.getVer uses this and needs to be thread-safe
  10. ThreadSafeMap<VecI2, byte > rebuild ; // AREA_REBUILD_FLAG areas that need to be rebuilt, make this thread-safe just in case
  11. ThreadSafeMap<UID , ObjVer > obj ; // !! can be modified only after locking !! , make this thread-safe just in case
  12. ThreadSafeMap<UID , RectI > obj_embed; // map of objects that are currently embedded !! can be modified only after locking !!, make this thread-safe just in case
  13. ThreadSafeMap<UID , Version > waypoints; // make this thread-safe just in case
  14. ThreadSafeMap<UID , WaterVer> lakes ; // make this thread-safe just in case
  15. ThreadSafeMap<UID , WaterVer> rivers ; // make this thread-safe just in case
  16. ~WorldVer();
  17. WorldVer& setChanged();
  18. void operator=(C WorldVer&src);
  19. // get
  20. bool embedded(C ObjData &obj); // !! this function must be multi-threaded SAFE !!
  21. bool hasHm(C VecI2 &area_xy);
  22. RectI getTerrainAreas();
  23. RectI getObjAreas();
  24. RectI getObjEmbedAreas();
  25. RectI getLakeAreas();
  26. RectI getRiverAreas();
  27. // rebuild
  28. void rebuildAreaNeighbor(C VecI2 &area_xy, uint flag, uint neighbor_flag_if_exists=0); // !! 'neighbor_flag_if_exists' is processed only if that neighbor area already exists !!
  29. void rebuildArea(C VecI2 &area_xy, uint sync_flag, bool skip_mesh=false);
  30. void rebuildPaths(C RectI &area);
  31. void rebuildPaths(C UID &obj_id, C VecI2 &obj_area_xy);
  32. void rebuildEmbedObj(C RectI &area);
  33. void rebuildGameAreaObjs(C VecI2 &area_xy);
  34. void rebuildWater(C RectI &area);
  35. // changed
  36. void changedObj(C ObjData &obj, C VecI2 &area_xy);
  37. void changedWaypoint(C UID &waypoint_id);
  38. void changedLake (C UID & lake_id);
  39. void changedRiver (C UID & river_id);
  40. // io
  41. bool save(File &f, bool network=false);
  42. bool load(File &f, bool network=false);
  43. bool save(C Str &name);
  44. bool load(C Str &name); // name is "<WorldID>\\Data"
  45. void flush();
  46. public:
  47. WorldVer();
  48. };
  49. /******************************************************************************/
  50. /******************************************************************************/
  51. /******************************************************************************/