void NavMeshLoader::Process() { if (m_autoReload) { clock::time_point now = clock::now(); if (now - m_lastUpdate > std::chrono::seconds(1)) { m_lastUpdate = now; if (!m_loadedDataFile.empty()) { // Get the current filetime FILETIME currentFileTime; HANDLE hFile = CreateFile(m_loadedDataFile.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); if (hFile != INVALID_HANDLE_VALUE) { GetFileTime(hFile, NULL, NULL, ¤tFileTime); // Reload file *if* it is 5 seconds old AND newer than existing if (CompareFileTime(¤tFileTime, &m_fileTime)) { DebugSpewAlways("Current file time is newer than old file time, refreshing"); LoadNavMesh(); } } CloseHandle(hFile); } } } }
void NavMeshLoader::SetZoneId(DWORD zoneId) { if (m_zoneId != zoneId) { m_zoneId = zoneId; Reset(); // set or clear zone name PCHAR zoneName = GetShortZone(zoneId); m_zoneShortName = zoneName ? zoneName : std::string(); if (m_zoneShortName == "UNKNOWN_ZONE") { // invalid / unsupported zone id DebugSpewAlways("[MQ2Nav] Unrecognized zone id: %d", zoneId); Reset(); } else { DebugSpewAlways("[MQ2Nav] Zone changed to: %s", m_zoneShortName.c_str()); if (m_autoLoad) { LoadNavMesh(); } } } }
/// VManagedResource overrides just so we can register callbacks BOOL vHavokAiNavMeshResource::Reload() { const char* pszFilename = GetFilename(); if (pszFilename == NULL) { return FALSE; } IVFileInStream *pIn = GetParentManager()->CreateFileInStream(pszFilename,this); if (!pIn) { return FALSE; } VASSERT(m_navMesh == HK_NULL && m_mediator == HK_NULL); if (!LoadNavMesh(pIn, m_navMesh, m_mediator)) { return FALSE; } VASSERT(m_navMesh != HK_NULL && m_mediator != HK_NULL); VASSERT(m_navMesh->getReferenceCount() == 2 && m_mediator->getReferenceCount() == 1); FlagAsLoaded(); UpdateMemoryFootprint(); return TRUE; }
CZone::CZone(ZONEID ZoneID, REGIONTYPE RegionID, CONTINENTTYPE ContinentID) { ZoneTimer = NULL; m_zoneID = ZoneID; m_zoneType = ZONETYPE_NONE; m_regionID = RegionID; m_continentID = ContinentID; m_Transport = 0; m_TreasurePool = 0; m_RegionCheckTime = 0; m_InstanceHandler = NULL; m_Weather = WEATHER_NONE; m_WeatherChangeTime = 0; m_IsWeatherStatic = 0; m_useNavMesh = false; m_navMesh = NULL; // settings should load first LoadZoneSettings(); LoadZoneLines(); LoadZoneWeather(); LoadNavMesh(); }
CZone::CZone(ZONEID ZoneID, REGIONTYPE RegionID, CONTINENTTYPE ContinentID) { ZoneTimer = nullptr; m_zoneID = ZoneID; m_zoneType = ZONETYPE_NONE; m_regionID = RegionID; m_continentID = ContinentID; m_TreasurePool = 0; m_RegionCheckTime = 0; m_BattlefieldHandler = nullptr; m_Weather = WEATHER_NONE; m_WeatherChangeTime = 0; m_useNavMesh = false; m_navMesh = nullptr; m_zoneEntities = new CZoneEntities(this); m_eventType = EVENTTYPE_NONE; // settings should load first LoadZoneSettings(); LoadZoneLines(); LoadZoneWeather(); LoadNavMesh(); }
bool vHavokAiNavMeshResource::LoadNavMesh(const char* filePath, hkRefPtr<hkaiNavMesh>& navMeshOut, hkRefPtr<hkaiNavMeshQueryMediator>& mediatorOut ) { IVFileInStream* inStream = Vision::File.Open(filePath); return LoadNavMesh(inStream, navMeshOut, mediatorOut); }