summaryrefslogtreecommitdiff
path: root/bench/bench_window.cpp
diff options
context:
space:
mode:
authorBenji Dial <benji@benjidial.net>2023-07-18 10:19:42 -0400
committerBenji Dial <benji@benjidial.net>2023-07-18 10:19:42 -0400
commit651b851fdd2a36958e09a66cb2877c66cf160a5e (patch)
tree2f4e0e35f0f27b9dbb28bd9f7fbe4e0b937ce378 /bench/bench_window.cpp
parent723437674e0002f7b0e2b727bc24ec3080ac069f (diff)
downloadlib94-651b851fdd2a36958e09a66cb2877c66cf160a5e.tar.gz
better warrior placement, including handling the case where they don't fit
Diffstat (limited to 'bench/bench_window.cpp')
-rw-r--r--bench/bench_window.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/bench/bench_window.cpp b/bench/bench_window.cpp
index 70cbbbf..99d7926 100644
--- a/bench/bench_window.cpp
+++ b/bench/bench_window.cpp
@@ -1,3 +1,4 @@
+#include <cassert>
#include <fstream>
#include "bench_window.hpp"
@@ -193,7 +194,22 @@ void bench_window::on_click_new_round() {
.bnumber = 0
});
- lib94::init_round(warriors.data(), warriors.size());
+ if (!lib94::init_round(warriors.data(), warriors.size())) {
+ Gtk::MessageDialog *md = new Gtk::MessageDialog("warriors do not fit in core; removing last warrior");
+ md->set_transient_for(*this);
+ md->set_modal();
+ md->signal_response().connect([md](int) {delete md;});
+ md->show();
+
+ //is this safe?
+ delete warriors.back();
+ warriors.pop_back();
+ if (warriors.size() == 0) {
+ update_ui();
+ return;
+ }
+ assert(lib94::init_round(warriors.data(), warriors.size()));
+ }
core.mut.lock();
core.age_scale = std::pow(2.0 / 3.0, 1.0 / (float)warriors.size());