Skip to content

Commit

Permalink
Made Empire::PlaceBuildInQueue abort rather than proceed-with-log-not…
Browse files Browse the repository at this point in the history
…e when something weird is enqueued.
  • Loading branch information
geoffthemedio committed Oct 4, 2015
1 parent dafe60a commit 5810323
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions Empire/Empire.cpp
Expand Up @@ -2404,17 +2404,21 @@ const unsigned int MAX_PROD_QUEUE_SIZE = 500;

void Empire::PlaceBuildInQueue(BuildType build_type, const std::string& name, int number, int location, int pos/* = -1*/) {
if (!EnqueuableItem(build_type, name, location)) {
DebugLogger() << "Empire::PlaceBuildInQueue() : Attempted to place non-enqueuable item in queue";
ErrorLogger() << "Empire::PlaceBuildInQueue() : Attempted to place non-enqueuable item in queue: build_type: "
<< boost::lexical_cast<std::string>(build_type) << " name: " << name << " location: " << location;
return;
}

if (m_production_queue.size() >= MAX_PROD_QUEUE_SIZE) {
DebugLogger() << "Empire::PlaceBuildInQueue() : Maximum queue size reached. Aborting enqueue";
ErrorLogger() << "Empire::PlaceBuildInQueue() : Maximum queue size reached. Aborting enqueue";
return;
}

if (!ProducibleItem(build_type, name, location))
DebugLogger() << "Empire::PlaceBuildInQueue() : Placed a non-buildable item in queue...";
if (!ProducibleItem(build_type, name, location)) {
ErrorLogger() << "Empire::PlaceBuildInQueue() : Placed a non-buildable item in queue: build_type: "
<< boost::lexical_cast<std::string>(build_type) << " name: " << name << " location: " << location;
return;
}

ProductionQueue::Element build(build_type, name, m_id, number, number, location);
if (pos < 0 || static_cast<int>(m_production_queue.size()) <= pos)
Expand All @@ -2424,11 +2428,18 @@ void Empire::PlaceBuildInQueue(BuildType build_type, const std::string& name, in
}

void Empire::PlaceBuildInQueue(BuildType build_type, int design_id, int number, int location, int pos/* = -1*/) {
if (!ProducibleItem(build_type, design_id, location))
DebugLogger() << "Empire::PlaceBuildInQueue() : Placed a non-buildable item in queue...";
// ship designs don't have a distinction between enqueuable and producible...

if (m_production_queue.size() >= MAX_PROD_QUEUE_SIZE)
if (m_production_queue.size() >= MAX_PROD_QUEUE_SIZE) {
ErrorLogger() << "Empire::PlaceBuildInQueue() : Maximum queue size reached. Aborting enqueue";
return;
}

if (!ProducibleItem(build_type, design_id, location)) {
ErrorLogger() << "Empire::PlaceBuildInQueue() : Placed a non-buildable item in queue: build_type: "
<< boost::lexical_cast<std::string>(build_type) << " design_id: " << design_id << " location: " << location;
return;
}

ProductionQueue::Element build(build_type, design_id, m_id, number, number, location);
if (pos < 0 || static_cast<int>(m_production_queue.size()) <= pos)
Expand Down

0 comments on commit 5810323

Please sign in to comment.