region_map_v1.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #ifndef EQ2EMU_REGION_MAP_V1_H
  2. #define EQ2EMU_REGION_MAP_V1_H
  3. #include <mutex>
  4. #include <shared_mutex>
  5. #include <map>
  6. #include "region_map.h"
  7. class Client;
  8. class Spawn;
  9. #define SPECIAL_REGION_LAVA_OR_DEATH 4294967293
  10. #define SPECIAL_REGION_WATER 1
  11. #pragma pack(1)
  12. typedef struct ZBSP_Node {
  13. int32 node_number;
  14. float normal[3], splitdistance;
  15. int32 region;
  16. int32 special;
  17. int32 left, right;
  18. } ZBSP_Node;
  19. typedef struct Region_Node {
  20. int32 region_type;
  21. float x;
  22. float y;
  23. float z;
  24. float dist;
  25. string regionEnvFileName;
  26. string regionName;
  27. int32 grid_id;
  28. string regionScriptName;
  29. int32 vert_count;
  30. int32 trigger_widget_id;
  31. } Region_Node;
  32. #pragma pack()
  33. struct Region_Status {
  34. bool inRegion;
  35. int32 timerTic;
  36. int32 lastTimerTic;
  37. int32 regionType;
  38. };
  39. class RegionMapV1 : public RegionMap
  40. {
  41. public:
  42. RegionMapV1();
  43. ~RegionMapV1();
  44. virtual WaterRegionType ReturnRegionType(const glm::vec3& location, int32 grid_id=0) const;
  45. virtual bool InWater(const glm::vec3& location, int32 grid_id=0) const;
  46. virtual bool InLava(const glm::vec3& location, int32 grid_id=0) const;
  47. virtual bool InLiquid(const glm::vec3& location) const;
  48. virtual bool InPvP(const glm::vec3& location) const;
  49. virtual bool InZoneLine(const glm::vec3& location) const;
  50. virtual void IdentifyRegionsInGrid(Client* client, const glm::vec3& location) const;
  51. virtual void MapRegionsNearSpawn(Spawn* spawn, Client* client=0) const;
  52. virtual void UpdateRegionsNearSpawn(Spawn* spawn, Client* client=0) const;
  53. virtual void TicRegionsNearSpawn(Spawn* spawn, Client* client=0) const;
  54. virtual void InsertRegionNode(ZoneServer* zone, int32 version, std::string regionName, std::string envName, uint32 gridID, uint32 triggerWidgetID, float dist = 0.0f);
  55. virtual void RemoveRegionNode(std::string regionName);
  56. protected:
  57. virtual bool Load(FILE *fp, std::string inZoneLowerName, int32 regionVersion);
  58. private:
  59. WaterRegionType BSPReturnRegionType(int32 node_number, const glm::vec3& location, int32 gridid=0) const;
  60. WaterRegionType BSPReturnRegionTypeNode(const Region_Node* node, const ZBSP_Node* BSP_Root, int32 node_number, const glm::vec3& location, float distToNode=0.0f) const;
  61. WaterRegionType BSPReturnRegionWaterRegion(const Region_Node* node, const ZBSP_Node* BSP_Root, int32 node_number, const glm::vec3& location, float distToNode=0.0f) const;
  62. map<Region_Node*, ZBSP_Node*> Regions;
  63. WaterRegionType EstablishDistanceAtAngle(const Region_Node* region_node, const ZBSP_Node* current_node, float distance, float absDistance, float absSplitDist, bool checkEdgedAngle=false) const;
  64. std::string TestFile(std::string testFile);
  65. friend class RegionMap;
  66. int32 mVersion;
  67. std::string mZoneNameLower;
  68. mutable std::shared_mutex MRegions;
  69. std::map<Region_Node*, bool> dead_nodes;
  70. };
  71. #endif