From 95753ce4cc65b04835aa628cd3361fee61bc2fb6 Mon Sep 17 00:00:00 2001 From: nullifiedcat Date: Mon, 24 Jul 2017 08:53:56 +0300 Subject: [PATCH] free_node --- src/hacks/Walkbot.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/hacks/Walkbot.cpp b/src/hacks/Walkbot.cpp index 8c7794a5..e3c7e80c 100644 --- a/src/hacks/Walkbot.cpp +++ b/src/hacks/Walkbot.cpp @@ -60,6 +60,17 @@ index_t closest_node { INVALID_NODE }; // Global state EWalkbotState state { WB_DISABLED }; +// A little bit too expensive function, finds next free node or creates one if no free slots exist +index_t free_node() { + for (index_t i = 0; i < nodes.size(); i++) { + if (not (nodes[i].flags & NF_GOOD)) + return i; + } + + nodes.emplace_back(); + return nodes.size() - 1; +} + bool node_good(index_t node) { return node < nodes.size() && (nodes[node].flags & NF_GOOD); } @@ -138,7 +149,7 @@ void DrawNode(index_t node, bool draw_back) { void DrawPath() { for (index_t i = 0; i < state::nodes.size(); i++) { - + DrawNode(i, false); } }