From ca94e31472124f39ec72b02c4fe009d13b2351a2 Mon Sep 17 00:00:00 2001 From: ds Date: Fri, 6 Nov 2020 09:10:19 +0300 Subject: [PATCH] api: add some new functions --- inc/module.h | 6 ++++++ src/module.cpp | 18 +++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/inc/module.h b/inc/module.h index 249ab3f..ada9c1e 100644 --- a/inc/module.h +++ b/inc/module.h @@ -42,4 +42,10 @@ public: // force bot to go to selected origin virtual void setBotGoalOrigin (int entity, float *origin) = 0; + + // checks whether graph nodes is available on map + virtual bool hasGraph () = 0; + + // get's the graph node flags + virtual int getNodeFlags (int node) = 0; }; \ No newline at end of file diff --git a/src/module.cpp b/src/module.cpp index 0f89386..1fa203c 100644 --- a/src/module.cpp +++ b/src/module.cpp @@ -9,6 +9,9 @@ // module interface implementation class YaPBModule : public IYaPBModule { +public: + virtual ~YaPBModule () override = default; + private: Bot *getBot (int index) { if (index < 1) { @@ -36,7 +39,7 @@ public: // gets the node nearest to origin virtual int getNearestNode (float *origin) override { if (graph.length () > 0) { - return graph.getNearestNoBuckets (origin); + return graph.getNearest (origin); } return kInvalidNodeIndex; } @@ -84,6 +87,19 @@ public: return bot->sendBotToOrigin (origin); } } + + // checks whether graph nodes is available on map + virtual bool hasGraph () override { + return graph.length () > 0; + } + + // get's the graph node flags + virtual int getNodeFlags (int node) override { + if (graph.length () > 0 && graph.exists (node)) { + return graph[node].flags; + } + return 0; + } }; // export all the stuff, maybe add versioned interface ?