2025-01-23 14:39:56 +00:00
|
|
|
/*
|
|
|
|
* PathfinderCache.h, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "PathfinderOptions.h"
|
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
2025-05-14 15:50:13 +03:00
|
|
|
class IGameInfoCallback;
|
2025-01-23 14:39:56 +00:00
|
|
|
class CGHeroInstance;
|
|
|
|
class PathfinderConfig;
|
|
|
|
struct CPathsInfo;
|
|
|
|
|
|
|
|
class DLL_LINKAGE PathfinderCache
|
|
|
|
{
|
2025-05-14 15:50:13 +03:00
|
|
|
const IGameInfoCallback * cb;
|
2025-01-23 14:39:56 +00:00
|
|
|
std::mutex pathCacheMutex;
|
|
|
|
std::map<const CGHeroInstance *, std::shared_ptr<CPathsInfo>> pathCache;
|
|
|
|
PathfinderOptions options;
|
|
|
|
|
|
|
|
std::shared_ptr<PathfinderConfig> createConfig(const CGHeroInstance *h, CPathsInfo &out);
|
|
|
|
std::shared_ptr<CPathsInfo> buildPaths(const CGHeroInstance *h);
|
|
|
|
public:
|
2025-05-14 15:50:13 +03:00
|
|
|
PathfinderCache(const IGameInfoCallback * cb, const PathfinderOptions & options);
|
2025-01-23 14:39:56 +00:00
|
|
|
|
|
|
|
/// Invalidates and erases all existing paths from the cache
|
|
|
|
void invalidatePaths();
|
|
|
|
|
|
|
|
/// Returns compute path information for requested hero
|
|
|
|
std::shared_ptr<const CPathsInfo> getPathsInfo(const CGHeroInstance * h);
|
|
|
|
};
|
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|