|
@@ -7,7 +7,7 @@
|
|
|
#include "logging.h"
|
|
|
#include "utils.h"
|
|
|
|
|
|
-Dispatch::Dispatch(Director &d) : director{d} {};
|
|
|
+Dispatch::Dispatch(Director &d) : director{d} { aborted = false; };
|
|
|
Dispatch::~Dispatch(){};
|
|
|
|
|
|
void Dispatch::to_server(const std::string &send) { director.to_server(send); }
|
|
@@ -52,7 +52,10 @@ void Dispatch::chain_server_prompt(const std::string &prompt) {
|
|
|
void Dispatch::server_line(const std::string &line,
|
|
|
const std::string &raw_line) {}
|
|
|
void Dispatch::server_prompt(const std::string &prompt) {}
|
|
|
-void Dispatch::client_input(const std::string &input) {}
|
|
|
+void Dispatch::client_input(const std::string &input) {
|
|
|
+ aborted = true;
|
|
|
+ deactivate();
|
|
|
+}
|
|
|
|
|
|
#ifdef NOMORE
|
|
|
MainDispatch::MainDispatch(Director &d) : Dispatch{d}, id{d}, md{d} {
|
|
@@ -265,11 +268,10 @@ void InputDispatch::client_input(const std::string &cinput) {
|
|
|
// BUGZ_LOG(info) << "InputDispatch::client_input(" << cinput << ")";
|
|
|
for (const char ch : cinput) {
|
|
|
if (isprint(ch)) {
|
|
|
- // Ok!
|
|
|
+ // Ok!
|
|
|
if (numeric) {
|
|
|
// numbers only
|
|
|
- if (!isdigit(ch))
|
|
|
- continue;
|
|
|
+ if (!isdigit(ch)) continue;
|
|
|
}
|
|
|
if (input.length() < max_length) {
|
|
|
to_client(std::string(1, ch));
|
|
@@ -286,6 +288,10 @@ void InputDispatch::client_input(const std::string &cinput) {
|
|
|
BUGZ_LOG(info) << "InputDispatch done: " << input;
|
|
|
to_client("\x1b[0m\n\r");
|
|
|
deactivate();
|
|
|
+ } else if (ch == '\x1b') {
|
|
|
+ aborted = true;
|
|
|
+ to_client("\x1b[0m\n\r");
|
|
|
+ deactivate();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -484,6 +490,7 @@ void MenuDispatch::client_input(const std::string &cinput) {
|
|
|
input.erase(input.length() - 1);
|
|
|
}
|
|
|
|
|
|
+ aborted = true;
|
|
|
// Exit - allow escape from menu
|
|
|
deactivate();
|
|
|
return;
|
|
@@ -717,22 +724,22 @@ void MoveDispatch::server_prompt(const std::string &prompt) {
|
|
|
BUGZ_LOG(fatal) << "Using Express";
|
|
|
to_server("E");
|
|
|
} else {
|
|
|
- int to_check = warp_lane[warp_pos + 1];
|
|
|
- // check density scan
|
|
|
- density d = director.galaxy.dscan.find(to_check);
|
|
|
- /*
|
|
|
- int density =
|
|
|
- director.galaxy.meta["density"][to_check]["density"].as<int>();
|
|
|
- */
|
|
|
- if (density_clear(d)) { // to_check, density)) {
|
|
|
- to_server("S");
|
|
|
- ++warp_pos;
|
|
|
- } else {
|
|
|
- to_server("N");
|
|
|
- BUGZ_LOG(fatal) << "density_clear(" << to_check << ") : false";
|
|
|
- success = false;
|
|
|
- deactivate();
|
|
|
- }
|
|
|
+ int to_check = warp_lane[warp_pos + 1];
|
|
|
+ // check density scan
|
|
|
+ density d = director.galaxy.dscan.find(to_check);
|
|
|
+ /*
|
|
|
+ int density =
|
|
|
+ director.galaxy.meta["density"][to_check]["density"].as<int>();
|
|
|
+ */
|
|
|
+ if (density_clear(d)) { // to_check, density)) {
|
|
|
+ to_server("S");
|
|
|
+ ++warp_pos;
|
|
|
+ } else {
|
|
|
+ to_server("N");
|
|
|
+ BUGZ_LOG(fatal) << "density_clear(" << to_check << ") : false";
|
|
|
+ success = false;
|
|
|
+ deactivate();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
if (prompt == "Stop in this sector (Y,N,E,I,R,S,D,P,?) (?=Help) [N] ? ") {
|
|
@@ -772,6 +779,7 @@ void MoveDispatch::client_input(const std::string &input) {
|
|
|
// This exits us out quickly -- should I stop at a better spot?
|
|
|
// As in answer "Y" to Stop in this sector?
|
|
|
success = 0;
|
|
|
+ aborted = true;
|
|
|
deactivate();
|
|
|
}
|
|
|
|
|
@@ -847,7 +855,7 @@ void TraderDispatch::activate(void) {
|
|
|
void TraderDispatch::deactivate(void) { notify(); }
|
|
|
|
|
|
void TraderDispatch::server_line(const std::string &line,
|
|
|
- const std::string &raw_line) {
|
|
|
+ const std::string &raw_line) {
|
|
|
// FUTURE: powering up weapons check
|
|
|
|
|
|
// Show what's going on...
|
|
@@ -1224,7 +1232,10 @@ void TraderDispatch::server_prompt(const std::string &prompt) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void TraderDispatch::client_input(const std::string &cinput) { deactivate(); };
|
|
|
+void TraderDispatch::client_input(const std::string &cinput) {
|
|
|
+ aborted = true;
|
|
|
+ deactivate();
|
|
|
+};
|
|
|
|
|
|
/*
|
|
|
* CoreDispatch: This is an example class that does dispatch.
|
|
@@ -1248,4 +1259,6 @@ void CoreDispatch::server_line(const std::string &line,
|
|
|
void CoreDispatch::server_prompt(const std::string &prompt) {}
|
|
|
void CoreDispatch::client_input(const std::string &input) {
|
|
|
BUGZ_LOG(warning) << "Got: " << input << " prompt=" << get_prompt();
|
|
|
+ aborted = true;
|
|
|
+ deactivate();
|
|
|
}
|