9
3

map.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. EQEMu: Everquest Server Emulator
  3. Copyright (C) 2001-2014 EQEMu Development Team (http://eqemulator.net)
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; version 2 of the License.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY except by those people which sell it, which
  9. are required to give you total support for your newly bought product;
  10. without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  15. */
  16. #ifndef ZONE_MAP_H
  17. #define ZONE_MAP_H
  18. #include "../../common/types.h"
  19. #include "../../common/Mutex.h"
  20. #include "position.h"
  21. #include <stdio.h>
  22. #include "SPGrid.h"
  23. #define BEST_Z_INVALID -99999
  24. class Map
  25. {
  26. public:
  27. Map(string filename, SPGrid* grid=nullptr);
  28. ~Map();
  29. float FindBestZ(glm::vec3 &start, glm::vec3 *result);
  30. float FindClosestZ(glm::vec3 &start, glm::vec3 *result);
  31. bool LineIntersectsZone(glm::vec3 start, glm::vec3 end, float step, glm::vec3 *result);
  32. bool LineIntersectsZoneNoZLeaps(glm::vec3 start, glm::vec3 end, float step_mag, glm::vec3 *result);
  33. bool CheckLoS(glm::vec3 myloc, glm::vec3 oloc);
  34. bool DoCollisionCheck(glm::vec3 myloc, glm::vec3 oloc, glm::vec3 &outnorm, float &distance);
  35. #ifdef USE_MAP_MMFS
  36. bool Load(std::string filename, bool force_mmf_overwrite = false);
  37. #else
  38. bool Load(const std::string& filename);
  39. #endif
  40. static Map *LoadMapFile(std::string file, SPGrid* grid=nullptr);
  41. std::string GetFileName() { return m_ZoneFile; }
  42. void SetMapLoaded(bool val) {
  43. CheckMapMutex.writelock();
  44. mapLoaded = val;
  45. CheckMapMutex.releasewritelock();
  46. }
  47. bool IsMapLoaded() {
  48. bool isMapLoaded = false;
  49. CheckMapMutex.readlock();
  50. isMapLoaded = mapLoaded;
  51. CheckMapMutex.releasereadlock();
  52. return isMapLoaded;
  53. }
  54. void SetMapLoading(bool val) {
  55. CheckMapMutex.writelock();
  56. mapLoading = val;
  57. CheckMapMutex.releasewritelock();
  58. }
  59. bool IsMapLoading() {
  60. bool isMapLoading = false;
  61. CheckMapMutex.readlock();
  62. isMapLoading = mapLoading;
  63. CheckMapMutex.releasereadlock();
  64. return isMapLoading;
  65. }
  66. private:
  67. void RotateVertex(glm::vec3 &v, float rx, float ry, float rz);
  68. void ScaleVertex(glm::vec3 &v, float sx, float sy, float sz);
  69. void TranslateVertex(glm::vec3 &v, float tx, float ty, float tz);
  70. bool LoadV2(FILE *f);
  71. #ifdef USE_MAP_MMFS
  72. bool LoadMMF(const std::string& map_file_name, bool force_mmf_overwrite);
  73. bool SaveMMF(const std::string& map_file_name, bool force_mmf_overwrite);
  74. #endif /*USE_MAP_MMFS*/
  75. string m_ZoneFile;
  76. int32 m_CellSize;
  77. float m_MinX;
  78. float m_MinZ;
  79. float m_MaxX;
  80. float m_MaxZ;
  81. int32 m_NumCellsX;
  82. int32 m_NumCellsZ;
  83. int32 m_NumFaceCellsX;
  84. int32 m_NumFaceCellsZ;
  85. struct impl;
  86. impl *imp;
  87. bool mapLoaded;
  88. bool mapLoading;
  89. Mutex CheckMapMutex;
  90. SPGrid* mGrid;
  91. };
  92. #endif