diff options
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/common/Collision/Management/VMapManager2.cpp | 5 | ||||
| -rw-r--r-- | src/common/Collision/Management/VMapManager2.h | 2 | ||||
| -rw-r--r-- | src/common/Collision/Maps/MapTree.cpp | 6 | ||||
| -rw-r--r-- | src/common/Collision/Models/ModelInstance.h | 3 | ||||
| -rw-r--r-- | src/common/Collision/Models/WorldModel.cpp | 19 | ||||
| -rw-r--r-- | src/common/Collision/Models/WorldModel.h | 10 | ||||
| -rw-r--r-- | src/common/Common.h | 26 | ||||
| -rw-r--r-- | src/common/Debugging/WheatyExceptionReport.cpp | 72 | ||||
| -rw-r--r-- | src/common/Debugging/WheatyExceptionReport.h | 4 |
10 files changed, 121 insertions, 28 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 2339399e022..7f20fe36ab6 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -83,6 +83,8 @@ add_library(common STATIC ${common_STAT_PCH_SRC} ) +add_dependencies(common revision_data.h) + # Generate precompiled header if (USE_COREPCH) add_cxx_pch(common ${common_STAT_PCH_HDR} ${common_STAT_PCH_SRC}) diff --git a/src/common/Collision/Management/VMapManager2.cpp b/src/common/Collision/Management/VMapManager2.cpp index 9594951196f..a63eac1b935 100644 --- a/src/common/Collision/Management/VMapManager2.cpp +++ b/src/common/Collision/Management/VMapManager2.cpp @@ -326,4 +326,9 @@ namespace VMAP return StaticMapTree::CanLoadMap(std::string(basePath), mapId, x, y); } + void VMapManager2::getInstanceMapTree(InstanceTreeMap &instanceMapTree) + { + instanceMapTree = iInstanceMapTrees; + } + } // namespace VMAP diff --git a/src/common/Collision/Management/VMapManager2.h b/src/common/Collision/Management/VMapManager2.h index a5891e9642b..c2e1aee1ff7 100644 --- a/src/common/Collision/Management/VMapManager2.h +++ b/src/common/Collision/Management/VMapManager2.h @@ -128,7 +128,7 @@ namespace VMAP return getMapFileName(mapId); } virtual bool existsMap(const char* basePath, unsigned int mapId, int x, int y) override; - public: + void getInstanceMapTree(InstanceTreeMap &instanceMapTree); typedef uint32(*GetLiquidFlagsFn)(uint32 liquidType); diff --git a/src/common/Collision/Maps/MapTree.cpp b/src/common/Collision/Maps/MapTree.cpp index b493ec18f5f..e374da4f1b9 100644 --- a/src/common/Collision/Maps/MapTree.cpp +++ b/src/common/Collision/Maps/MapTree.cpp @@ -474,4 +474,10 @@ namespace VMAP } iLoadedTiles.erase(tile); } + + void StaticMapTree::getModelInstances(ModelInstance* &models, uint32 &count) + { + models = iTreeValues; + count = iNTreeValues; + } } diff --git a/src/common/Collision/Models/ModelInstance.h b/src/common/Collision/Models/ModelInstance.h index dfdb001db0a..f8bbfa4fa73 100644 --- a/src/common/Collision/Models/ModelInstance.h +++ b/src/common/Collision/Models/ModelInstance.h @@ -70,12 +70,11 @@ namespace VMAP void intersectPoint(const G3D::Vector3& p, AreaInfo &info) const; bool GetLocationInfo(const G3D::Vector3& p, LocationInfo &info) const; bool GetLiquidLevel(const G3D::Vector3& p, LocationInfo &info, float &liqHeight) const; + WorldModel* getWorldModel() { return iModel; } protected: G3D::Matrix3 iInvRot; float iInvScale; WorldModel* iModel; - public: - WorldModel* getWorldModel(); }; } // namespace VMAP diff --git a/src/common/Collision/Models/WorldModel.cpp b/src/common/Collision/Models/WorldModel.cpp index 86ab9366c71..7f4d76b244a 100644 --- a/src/common/Collision/Models/WorldModel.cpp +++ b/src/common/Collision/Models/WorldModel.cpp @@ -249,6 +249,13 @@ namespace VMAP return result; } + void WmoLiquid::getPosInfo(uint32 &tilesX, uint32 &tilesY, G3D::Vector3 &corner) const + { + tilesX = iTilesX; + tilesY = iTilesY; + corner = iCorner; + } + // ===================== GroupModel ================================== GroupModel::GroupModel(const GroupModel &other): @@ -409,6 +416,13 @@ namespace VMAP return 0; } + void GroupModel::getMeshData(std::vector<G3D::Vector3>& outVertices, std::vector<MeshTriangle>& outTriangles, WmoLiquid*& liquid) + { + outVertices = vertices; + outTriangles = triangles; + liquid = iLiquid; + } + // ===================== WorldModel ================================== void WorldModel::setGroupModels(std::vector<GroupModel> &models) @@ -582,4 +596,9 @@ namespace VMAP fclose(rf); return result; } + + void WorldModel::getGroupModels(std::vector<GroupModel>& outGroupModels) + { + outGroupModels = groupModels; + } } diff --git a/src/common/Collision/Models/WorldModel.h b/src/common/Collision/Models/WorldModel.h index 6a901a59fdf..afa9d15b264 100644 --- a/src/common/Collision/Models/WorldModel.h +++ b/src/common/Collision/Models/WorldModel.h @@ -58,6 +58,7 @@ namespace VMAP uint32 GetFileSize(); bool writeToFile(FILE* wf); static bool readFromFile(FILE* rf, WmoLiquid* &liquid); + void getPosInfo(uint32 &tilesX, uint32 &tilesY, G3D::Vector3 &corner) const; private: WmoLiquid() : iTilesX(0), iTilesY(0), iCorner(), iType(0), iHeight(NULL), iFlags(NULL) { } uint32 iTilesX; //!< number of tiles in x direction, each @@ -66,8 +67,6 @@ namespace VMAP uint32 iType; //!< liquid type float *iHeight; //!< (tilesX + 1)*(tilesY + 1) height values uint8 *iFlags; //!< info if liquid tile is used - public: - void getPosInfo(uint32 &tilesX, uint32 &tilesY, G3D::Vector3 &corner) const; }; /*! holding additional info for WMO group files */ @@ -92,6 +91,7 @@ namespace VMAP const G3D::AABox& GetBound() const { return iBound; } uint32 GetMogpFlags() const { return iMogpFlags; } uint32 GetWmoID() const { return iGroupWMOID; } + void getMeshData(std::vector<G3D::Vector3>& outVertices, std::vector<MeshTriangle>& outTriangles, WmoLiquid*& liquid); protected: G3D::AABox iBound; uint32 iMogpFlags;// 0x8 outdor; 0x2000 indoor @@ -100,9 +100,8 @@ namespace VMAP std::vector<MeshTriangle> triangles; BIH meshTree; WmoLiquid* iLiquid; - public: - void getMeshData(std::vector<G3D::Vector3> &vertices, std::vector<MeshTriangle> &triangles, WmoLiquid* &liquid); }; + /*! Holds a model (converted M2 or WMO) in its original coordinate space */ class WorldModel { @@ -117,12 +116,11 @@ namespace VMAP bool GetLocationInfo(const G3D::Vector3 &p, const G3D::Vector3 &down, float &dist, LocationInfo &info) const; bool writeFile(const std::string &filename); bool readFile(const std::string &filename); + void getGroupModels(std::vector<GroupModel>& outGroupModels); protected: uint32 RootWMOID; std::vector<GroupModel> groupModels; BIH groupTree; - public: - void getGroupModels(std::vector<GroupModel> &groupModels); }; } // namespace VMAP diff --git a/src/common/Common.h b/src/common/Common.h index 4c209f89ec8..7a1ea247a94 100644 --- a/src/common/Common.h +++ b/src/common/Common.h @@ -21,7 +21,6 @@ #include "Define.h" -#include <unordered_map> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -32,14 +31,19 @@ #include <assert.h> #include <set> +#include <unordered_set> #include <list> #include <string> #include <map> +#include <unordered_map> #include <queue> #include <sstream> #include <algorithm> #include <memory> #include <vector> +#include <array> + +#include <boost/functional/hash.hpp> #include "Debugging/Errors.h" @@ -116,10 +120,11 @@ enum LocaleConstant LOCALE_zhTW = 5, LOCALE_esES = 6, LOCALE_esMX = 7, - LOCALE_ruRU = 8 + LOCALE_ruRU = 8, + + TOTAL_LOCALES }; -const uint8 TOTAL_LOCALES = 9; #define DEFAULT_LOCALE LOCALE_enUS #define MAX_LOCALES 8 @@ -156,4 +161,19 @@ namespace Trinity } } +//! Hash implementation for std::pair to allow using pairs in unordered_set or as key for unordered_map +//! Individual types used in pair must be hashable by boost::hash +namespace std +{ + template<class K, class V> + struct hash<std::pair<K, V>> + { + public: + size_t operator()(std::pair<K, V> const& key) const + { + return boost::hash_value(key); + } + }; +} + #endif diff --git a/src/common/Debugging/WheatyExceptionReport.cpp b/src/common/Debugging/WheatyExceptionReport.cpp index 7cf109b4070..5b9a1b1bd6c 100644 --- a/src/common/Debugging/WheatyExceptionReport.cpp +++ b/src/common/Debugging/WheatyExceptionReport.cpp @@ -63,6 +63,8 @@ std::stack<SymbolDetail> WheatyExceptionReport::symbolDetails; bool WheatyExceptionReport::stackOverflowException; bool WheatyExceptionReport::alreadyCrashed; std::mutex WheatyExceptionReport::alreadyCrashedLock; +WheatyExceptionReport::pRtlGetVersion WheatyExceptionReport::RtlGetVersion; + // Declare global instance of class WheatyExceptionReport g_WheatyExceptionReport; @@ -76,6 +78,7 @@ WheatyExceptionReport::WheatyExceptionReport() // Constructor m_hProcess = GetCurrentProcess(); stackOverflowException = false; alreadyCrashed = false; + RtlGetVersion = (pRtlGetVersion)GetProcAddress(GetModuleHandle(_T("ntdll.dll")), "RtlGetVersion"); if (!IsDebuggerPresent()) { _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE); @@ -207,21 +210,36 @@ BOOL WheatyExceptionReport::_GetProcessorName(TCHAR* sProcessorName, DWORD maxco return TRUE; } +template<size_t size> +void ToTchar(wchar_t const* src, TCHAR (&dst)[size], std::true_type) +{ + wcstombs_s(nullptr, dst, src, size); +} + +template<size_t size> +void ToTchar(wchar_t const* src, TCHAR (&dst)[size], std::false_type) +{ + wcscpy_s(dst, src); +} + BOOL WheatyExceptionReport::_GetWindowsVersion(TCHAR* szVersion, DWORD cntMax) { // Try calling GetVersionEx using the OSVERSIONINFOEX structure. // If that fails, try using the OSVERSIONINFO structure. - OSVERSIONINFOEX osvi = { 0 }; - osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); - BOOL bOsVersionInfoEx; - bOsVersionInfoEx = ::GetVersionEx((LPOSVERSIONINFO)(&osvi)); - if (!bOsVersionInfoEx) + RTL_OSVERSIONINFOEXW osvi = { 0 }; + osvi.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOEXW); + NTSTATUS bVersionEx = RtlGetVersion((PRTL_OSVERSIONINFOW)&osvi); + if (bVersionEx < 0) { - osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - if (!::GetVersionEx((OSVERSIONINFO*)&osvi)) + osvi.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOW); + if (!RtlGetVersion((PRTL_OSVERSIONINFOW)&osvi)) return FALSE; } *szVersion = _T('\0'); + + TCHAR szCSDVersion[256]; + ToTchar(osvi.szCSDVersion, szCSDVersion, std::is_same<TCHAR, char>::type()); + TCHAR wszTmp[128]; switch (osvi.dwPlatformId) { @@ -237,17 +255,28 @@ BOOL WheatyExceptionReport::_GetWindowsVersion(TCHAR* szVersion, DWORD cntMax) #endif // WINVER < 0x0500 // Test for the specific product family. - if (osvi.dwMajorVersion == 6) + if (osvi.dwMajorVersion == 10) + { + if (productType == VER_NT_WORKSTATION) + _tcsncat(szVersion, _T("Windows 10 "), cntMax); + else + _tcsncat(szVersion, _T("Windows Server 2016 "), cntMax); + } + else if (osvi.dwMajorVersion == 6) { if (productType == VER_NT_WORKSTATION) { - if (osvi.dwMinorVersion == 2) + if (osvi.dwMinorVersion == 3) + _tcsncat(szVersion, _T("Windows 8.1 "), cntMax); + else if (osvi.dwMinorVersion == 2) _tcsncat(szVersion, _T("Windows 8 "), cntMax); else if (osvi.dwMinorVersion == 1) _tcsncat(szVersion, _T("Windows 7 "), cntMax); else _tcsncat(szVersion, _T("Windows Vista "), cntMax); } + else if (osvi.dwMinorVersion == 3) + _tcsncat(szVersion, _T("Windows Server 2012 R2 "), cntMax); else if (osvi.dwMinorVersion == 2) _tcsncat(szVersion, _T("Windows Server 2012 "), cntMax); else if (osvi.dwMinorVersion == 1) @@ -265,7 +294,7 @@ BOOL WheatyExceptionReport::_GetWindowsVersion(TCHAR* szVersion, DWORD cntMax) _tcsncat(szVersion, _T("Microsoft Windows NT "), cntMax); // Test for specific product on Windows NT 4.0 SP6 and later. - if (bOsVersionInfoEx) + if (bVersionEx >= 0) { // Test for the workstation type. if (productType == VER_NT_WORKSTATION) @@ -282,7 +311,18 @@ BOOL WheatyExceptionReport::_GetWindowsVersion(TCHAR* szVersion, DWORD cntMax) // Test for the server type. else if (productType == VER_NT_SERVER) { - if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2) + if (osvi.dwMajorVersion == 6 || osvi.dwMajorVersion == 10) + { + if (suiteMask & VER_SUITE_SMALLBUSINESS_RESTRICTED) + _tcsncat(szVersion, _T("Essentials "), cntMax); + else if (suiteMask & VER_SUITE_DATACENTER) + _tcsncat(szVersion, _T("Datacenter "), cntMax); + else if (suiteMask & VER_SUITE_ENTERPRISE) + _tcsncat(szVersion, _T("Enterprise "), cntMax); + else + _tcsncat(szVersion, _T("Standard "), cntMax); + } + else if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2) { if (suiteMask & VER_SUITE_DATACENTER) _tcsncat(szVersion, _T("Datacenter Edition "), cntMax); @@ -313,7 +353,7 @@ BOOL WheatyExceptionReport::_GetWindowsVersion(TCHAR* szVersion, DWORD cntMax) } // Display service pack (if any) and build number. - if (osvi.dwMajorVersion == 4 && _tcsicmp(osvi.szCSDVersion, _T("Service Pack 6")) == 0) + if (osvi.dwMajorVersion == 4 && _tcsicmp(szCSDVersion, _T("Service Pack 6")) == 0) { HKEY hKey; LONG lRet; @@ -329,26 +369,26 @@ BOOL WheatyExceptionReport::_GetWindowsVersion(TCHAR* szVersion, DWORD cntMax) else // Windows NT 4.0 prior to SP6a { _stprintf(wszTmp, _T("%s (Version %d.%d, Build %d)"), - osvi.szCSDVersion, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF); + szCSDVersion, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF); _tcsncat(szVersion, wszTmp, cntMax); } ::RegCloseKey(hKey); } else // Windows NT 3.51 and earlier or Windows 2000 and later { - if (!_tcslen(osvi.szCSDVersion)) + if (!_tcslen(szCSDVersion)) _stprintf(wszTmp, _T("(Version %d.%d, Build %d)"), osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF); else _stprintf(wszTmp, _T("%s (Version %d.%d, Build %d)"), - osvi.szCSDVersion, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF); + szCSDVersion, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF); _tcsncat(szVersion, wszTmp, cntMax); } break; } default: _stprintf(wszTmp, _T("%s (Version %d.%d, Build %d)"), - osvi.szCSDVersion, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF); + szCSDVersion, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF); _tcsncat(szVersion, wszTmp, cntMax); break; } diff --git a/src/common/Debugging/WheatyExceptionReport.h b/src/common/Debugging/WheatyExceptionReport.h index 8c2479d5232..eb62d8bceef 100644 --- a/src/common/Debugging/WheatyExceptionReport.h +++ b/src/common/Debugging/WheatyExceptionReport.h @@ -3,6 +3,8 @@ #if PLATFORM == PLATFORM_WINDOWS && !defined(__MINGW32__) +#include <winnt.h> +#include <winternl.h> #include <dbghelp.h> #include <set> #include <stdlib.h> @@ -197,6 +199,8 @@ class WheatyExceptionReport static bool stackOverflowException; static bool alreadyCrashed; static std::mutex alreadyCrashedLock; + typedef NTSTATUS(NTAPI* pRtlGetVersion)(PRTL_OSVERSIONINFOW lpVersionInformation); + static pRtlGetVersion RtlGetVersion; static char* PushSymbolDetail(char* pszCurrBuffer); static char* PopSymbolDetail(char* pszCurrBuffer); |
