map.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. #define BEST_Z_INVALID -99999
  23. class Map
  24. {
  25. public:
  26. Map(string filename);
  27. ~Map();
  28. float FindBestZ(glm::vec3 &start, glm::vec3 *result);
  29. float FindClosestZ(glm::vec3 &start, glm::vec3 *result);
  30. bool LineIntersectsZone(glm::vec3 start, glm::vec3 end, float step, glm::vec3 *result);
  31. bool LineIntersectsZoneNoZLeaps(glm::vec3 start, glm::vec3 end, float step_mag, glm::vec3 *result);
  32. bool CheckLoS(glm::vec3 myloc, glm::vec3 oloc);
  33. bool DoCollisionCheck(glm::vec3 myloc, glm::vec3 oloc, glm::vec3 &outnorm, float &distance);
  34. #ifdef USE_MAP_MMFS
  35. bool Load(std::string filename, bool force_mmf_overwrite = false);
  36. #else
  37. bool Load(const std::string& filename);
  38. #endif
  39. static Map *LoadMapFile(std::string file);
  40. std::string GetFileName() { return m_ZoneFile; }
  41. void SetMapLoaded(bool val) {
  42. bool isMapLoaded = false;
  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. private:
  55. void RotateVertex(glm::vec3 &v, float rx, float ry, float rz);
  56. void ScaleVertex(glm::vec3 &v, float sx, float sy, float sz);
  57. void TranslateVertex(glm::vec3 &v, float tx, float ty, float tz);
  58. bool LoadV2(FILE *f);
  59. #ifdef USE_MAP_MMFS
  60. bool LoadMMF(const std::string& map_file_name, bool force_mmf_overwrite);
  61. bool SaveMMF(const std::string& map_file_name, bool force_mmf_overwrite);
  62. #endif /*USE_MAP_MMFS*/
  63. string m_ZoneFile;
  64. int32 m_CellSize;
  65. float m_MinX;
  66. float m_MinZ;
  67. float m_MaxX;
  68. float m_MaxZ;
  69. int32 m_NumCellsX;
  70. int32 m_NumCellsZ;
  71. int32 m_NumFaceCellsX;
  72. int32 m_NumFaceCellsZ;
  73. struct impl;
  74. impl *imp;
  75. bool mapLoaded;
  76. Mutex CheckMapMutex;
  77. };
  78. #endif