From 1abdceb303bb9742fa5f71409b2290cfe35764fe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Bergstr=C3=B6m?= <davbe125@student.liu.se>
Date: Fri, 29 Jun 2018 13:02:25 +0200
Subject: [PATCH] Remove BuildOrder and BuildOrderQueue

---
 src/BuildOrder.cpp      |  33 --------
 src/BuildOrder.h        |  20 -----
 src/BuildOrderQueue.cpp | 179 ----------------------------------------
 src/BuildOrderQueue.h   |  51 ------------
 4 files changed, 283 deletions(-)
 delete mode 100644 src/BuildOrder.cpp
 delete mode 100644 src/BuildOrder.h
 delete mode 100644 src/BuildOrderQueue.cpp
 delete mode 100644 src/BuildOrderQueue.h

diff --git a/src/BuildOrder.cpp b/src/BuildOrder.cpp
deleted file mode 100644
index 532a406f5..000000000
--- a/src/BuildOrder.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-#include "BuildOrder.h"
-
-BuildOrder::BuildOrder()
-{
-
-}
-
-
-BuildOrder::BuildOrder(const std::vector<MetaType> & vec)
-    : m_buildOrder(vec)
-{
-
-}
-
-void BuildOrder::add(const MetaType & type)
-{
-    m_buildOrder.push_back(type);
-}
-
-size_t BuildOrder::size() const
-{
-    return m_buildOrder.size();
-}
-
-const MetaType & BuildOrder::operator [] (const size_t & index) const
-{
-    return m_buildOrder[index];
-}
-
-MetaType & BuildOrder::operator [] (const size_t & index)
-{
-    return m_buildOrder[index];
-}
\ No newline at end of file
diff --git a/src/BuildOrder.h b/src/BuildOrder.h
deleted file mode 100644
index 95a6c6038..000000000
--- a/src/BuildOrder.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#pragma once
-
-#include "Common.h"
-#include "MetaType.h"
-
-class BuildOrder
-{
-    std::vector<MetaType> m_buildOrder;
-
-public:
-
-    BuildOrder();
-    BuildOrder(const std::vector<MetaType> & buildVector);
-
-    void add(const MetaType & type);
-    size_t size() const;
-    const MetaType & operator [] (const size_t & index) const;
-    MetaType & operator [] (const size_t & index);
-};
-
diff --git a/src/BuildOrderQueue.cpp b/src/BuildOrderQueue.cpp
deleted file mode 100644
index b2ff986e5..000000000
--- a/src/BuildOrderQueue.cpp
+++ /dev/null
@@ -1,179 +0,0 @@
-#include "BuildOrderQueue.h"
-#include "IDABot.h"
-
-BuildOrderQueue::BuildOrderQueue(IDABot & bot)
-    : m_bot(bot)
-    , m_highestPriority(0)
-    , m_lowestPriority(0)
-    , m_defaultPrioritySpacing(10)
-    , m_numSkippedItems(0)
-{
-
-}
-
-void BuildOrderQueue::clearAll()
-{
-    // clear the queue
-    m_queue.clear();
-
-    // reset the priorities
-    m_highestPriority = 0;
-    m_lowestPriority = 0;
-}
-
-BuildOrderItem & BuildOrderQueue::getHighestPriorityItem()
-{
-    // reset the number of skipped items to zero
-    m_numSkippedItems = 0;
-
-    // the queue will be sorted with the highest priority at the back
-    return m_queue.back();
-}
-
-BuildOrderItem & BuildOrderQueue::getNextHighestPriorityItem()
-{
-    assert(m_queue.size() - 1 - m_numSkippedItems >= 0);
-
-    // the queue will be sorted with the highest priority at the back
-    return m_queue[m_queue.size() - 1 - m_numSkippedItems];
-}
-
-void BuildOrderQueue::skipItem()
-{
-    // make sure we can skip
-    assert(canSkipItem());
-
-    // skip it
-    m_numSkippedItems++;
-}
-
-bool BuildOrderQueue::canSkipItem()
-{
-    // does the queue have more elements
-    bool bigEnough = m_queue.size() > (size_t)(1 + m_numSkippedItems);
-
-    if (!bigEnough)
-    {
-        return false;
-    }
-
-    // is the current highest priority item not blocking a skip
-    bool highestNotBlocking = !m_queue[m_queue.size() - 1 - m_numSkippedItems].blocking;
-
-    // this tells us if we can skip
-    return highestNotBlocking;
-}
-
-void BuildOrderQueue::queueItem(const BuildOrderItem & b)
-{
-    // if the queue is empty, set the highest and lowest priorities
-    if (m_queue.empty())
-    {
-        m_highestPriority = b.priority;
-        m_lowestPriority = b.priority;
-    }
-
-    // push the item into the queue
-    if (b.priority <= m_lowestPriority)
-    {
-        m_queue.push_front(b);
-    }
-    else
-    {
-        m_queue.push_back(b);
-    }
-
-    // if the item is somewhere in the middle, we have to sort again
-    if ((m_queue.size() > 1) && (b.priority < m_highestPriority) && (b.priority > m_lowestPriority))
-    {
-        // sort the list in ascending order, putting highest priority at the top
-        std::sort(m_queue.begin(), m_queue.end());
-    }
-
-    // update the highest or lowest if it is beaten
-    m_highestPriority = (b.priority > m_highestPriority) ? b.priority : m_highestPriority;
-    m_lowestPriority  = (b.priority < m_lowestPriority)  ? b.priority : m_lowestPriority;
-}
-
-void BuildOrderQueue::queueAsHighestPriority(const MetaType & type, bool blocking)
-{
-    // the new priority will be higher
-    int newPriority = m_highestPriority + m_defaultPrioritySpacing;
-
-    // queue the item
-    queueItem(BuildOrderItem(type, newPriority, blocking));
-}
-
-void BuildOrderQueue::queueAsLowestPriority(const MetaType & type, bool blocking)
-{
-    // the new priority will be higher
-    int newPriority = m_lowestPriority - m_defaultPrioritySpacing;
-
-    // queue the item
-    queueItem(BuildOrderItem(type, newPriority, blocking));
-}
-
-void BuildOrderQueue::removeHighestPriorityItem()
-{
-    // remove the back element of the vector
-    m_queue.pop_back();
-
-    // if the list is not empty, set the highest accordingly
-    m_highestPriority = m_queue.empty() ? 0 : m_queue.back().priority;
-    m_lowestPriority  = m_queue.empty() ? 0 : m_lowestPriority;
-}
-
-void BuildOrderQueue::removeCurrentHighestPriorityItem()
-{
-    // remove the back element of the vector
-    m_queue.erase(m_queue.begin() + m_queue.size() - 1 - m_numSkippedItems);
-
-    //assert((int)(queue.size()) < size);
-
-    // if the list is not empty, set the highest accordingly
-    m_highestPriority = m_queue.empty() ? 0 : m_queue.back().priority;
-    m_lowestPriority  = m_queue.empty() ? 0 : m_lowestPriority;
-}
-
-size_t BuildOrderQueue::size()
-{
-    return m_queue.size();
-}
-
-bool BuildOrderQueue::isEmpty()
-{
-    return (m_queue.size() == 0);
-}
-
-BuildOrderItem BuildOrderQueue::operator [] (int i)
-{
-    return m_queue[i];
-}
-
-std::string BuildOrderQueue::getQueueInformation() const
-{
-    size_t reps = m_queue.size() < 30 ? m_queue.size() : 30;
-    std::stringstream ss;
-
-    // for each unit in the queue
-    for (size_t i(0); i<reps; i++)
-    {
-        const MetaType & type = m_queue[m_queue.size() - 1 - i].type;
-        ss << type.getName() << "\n";
-    }
-
-    return ss.str();
-}
-
-
-BuildOrderItem::BuildOrderItem(const MetaType & t, int p, bool b)
-    : type(t)
-    , priority(p)
-    , blocking(b)
-{
-}
-
-bool BuildOrderItem::operator < (const BuildOrderItem & x) const
-{
-    return priority < x.priority;
-}
\ No newline at end of file
diff --git a/src/BuildOrderQueue.h b/src/BuildOrderQueue.h
deleted file mode 100644
index 26bf868bf..000000000
--- a/src/BuildOrderQueue.h
+++ /dev/null
@@ -1,51 +0,0 @@
-#pragma once
-
-#include "Common.h"
-#include "MetaType.h"
-
-class IDABot;
-
-struct BuildOrderItem
-{
-    MetaType       type;		// the thing we want to 'build'
-    int             priority;	// the priority at which to place it in the queue
-    bool            blocking;	// whether or not we block further items
-
-    BuildOrderItem(const MetaType & t, int p, bool b);
-    bool operator<(const BuildOrderItem & x) const;
-};
-
-class BuildOrderQueue
-{
-    IDABot & m_bot;
-    std::deque<BuildOrderItem> m_queue;
-
-    int m_lowestPriority;
-    int m_highestPriority;
-    int m_defaultPrioritySpacing;
-    int m_numSkippedItems;
-
-public:
-
-    BuildOrderQueue(IDABot & bot);
-
-    void clearAll();											// clears the entire build order queue
-    void skipItem();											// increments skippedItems
-    void queueAsHighestPriority(const MetaType & type, bool blocking);		// queues something at the highest priority
-    void queueAsLowestPriority(const MetaType & type, bool blocking);		// queues something at the lowest priority
-    void queueItem(const BuildOrderItem & b);			// queues something with a given priority
-    void removeHighestPriorityItem();								// removes the highest priority item
-    void removeCurrentHighestPriorityItem();
-
-    size_t size();													// returns the size of the queue
-
-    bool isEmpty();
-    BuildOrderItem & getHighestPriorityItem();	// returns the highest priority item
-    BuildOrderItem & getNextHighestPriorityItem();	// returns the highest priority item
-
-    bool canSkipItem();
-    std::string getQueueInformation() const;
-
-    // overload the bracket operator for ease of use
-    BuildOrderItem operator [] (int i);
-};
-- 
GitLab