|
@@ -16,11 +16,11 @@ Dispatch::Dispatch(Director &d, const char *called) : director{d} {
|
|
|
};
|
|
|
Dispatch::~Dispatch(){};
|
|
|
|
|
|
-void Dispatch::deactivate(void) {
|
|
|
- notify();
|
|
|
-}
|
|
|
+void Dispatch::deactivate(void) { notify(); }
|
|
|
|
|
|
-void Dispatch::to_server(const std::string &send) { director.to_server(send, name); }
|
|
|
+void Dispatch::to_server(const std::string &send) {
|
|
|
+ director.to_server(send, name);
|
|
|
+}
|
|
|
void Dispatch::to_client(const std::string &send) { director.to_client(send); }
|
|
|
const std::string &Dispatch::get_prompt(void) {
|
|
|
return director.current_prompt;
|
|
@@ -433,11 +433,11 @@ void CIMDispatch::server_line(const std::string &line,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-MoveDispatch::MoveDispatch(Director &d, const char * called) : Dispatch(d, called) {
|
|
|
+MoveDispatch::MoveDispatch(Director &d, const char *called)
|
|
|
+ : Dispatch(d, called) {
|
|
|
BUGZ_LOG(warning) << "MoveDispatch()";
|
|
|
use_express = false;
|
|
|
- if (called == nullptr)
|
|
|
- name = "Move";
|
|
|
+ if (called == nullptr) name = "Move";
|
|
|
}
|
|
|
|
|
|
MoveDispatch::~MoveDispatch() { BUGZ_LOG(warning) << "~MoveDispatch()"; }
|
|
@@ -471,7 +471,7 @@ void MoveDispatch::activate(void) {
|
|
|
to_server(command);
|
|
|
state = 3;
|
|
|
} else {
|
|
|
- to_server("SD");
|
|
|
+ to_server("S"); // because we might not have a scanner
|
|
|
state = 1;
|
|
|
}
|
|
|
|
|
@@ -480,14 +480,16 @@ void MoveDispatch::activate(void) {
|
|
|
at_destination.append(std::to_string(move_to));
|
|
|
}
|
|
|
|
|
|
-void MoveDispatch::deactivate(void) {
|
|
|
+void MoveDispatch::deactivate(void) {
|
|
|
BUGZ_LOG(fatal) << "MoveDispatch::deactivate() " << success;
|
|
|
- notify();
|
|
|
+ notify();
|
|
|
}
|
|
|
|
|
|
// optional here
|
|
|
void MoveDispatch::server_line(const std::string &line,
|
|
|
const std::string &raw_line) {
|
|
|
+ if (!line.empty()) BUGZ_LOG(fatal) << state << " : " << line;
|
|
|
+
|
|
|
if (state == 1) {
|
|
|
if (endswith(line, "Relative Density Scan")) {
|
|
|
state = 2;
|
|
@@ -537,7 +539,9 @@ void MoveDispatch::server_line(const std::string &line,
|
|
|
deactivate();
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
+ if (line == "You don't have a long range scanner.") {
|
|
|
+ use_express = true;
|
|
|
+ }
|
|
|
if (line == "That Warp Lane is not adjacent.") {
|
|
|
// ok! Parse out the path that we need to take...
|
|
|
}
|
|
@@ -616,12 +620,16 @@ bool MoveDispatch::density_clear(density d) { // int sector, int density) {
|
|
|
} */
|
|
|
|
|
|
void MoveDispatch::server_prompt(const std::string &prompt) {
|
|
|
- BUGZ_LOG(fatal) << "server_prompt: " << prompt;
|
|
|
+ BUGZ_LOG(fatal) << "server_prompt: " << state << " SP: [" << prompt << "]";
|
|
|
|
|
|
// SL: [###### DANGER! You have marked sector 740 to be avoided!]
|
|
|
// SP: [Do you really want to warp there? (Y/N) ]
|
|
|
|
|
|
- if (state == 2) {
|
|
|
+ if (state == 1) {
|
|
|
+ if (prompt == "Select (H)olo Scan or (D)ensity Scan or (Q)uit? [D] ") {
|
|
|
+ to_server("D");
|
|
|
+ }
|
|
|
+ } else if (state == 2) {
|
|
|
if (at_command_prompt(prompt)) {
|
|
|
// Ok, density is done
|
|
|
// BUG: If the sector is adjacent, this doesn't check density!
|
|
@@ -644,12 +652,23 @@ void MoveDispatch::server_prompt(const std::string &prompt) {
|
|
|
} else if (state == 3) {
|
|
|
if (at_command_prompt(prompt)) {
|
|
|
// this happens when the sector is adjcent to current_sector.
|
|
|
- BUGZ_LOG(fatal) << "Are we there yet? / Adjacent sector.";
|
|
|
- success = true;
|
|
|
- deactivate();
|
|
|
+ // Or it happens when the ship is FUBAR.
|
|
|
+
|
|
|
+ // NO!!!!
|
|
|
+ if (director.current_sector == move_to) {
|
|
|
+ BUGZ_LOG(fatal) << "Are we there yet? / Adjacent sector.";
|
|
|
+ success = true;
|
|
|
+ deactivate();
|
|
|
+ } else {
|
|
|
+ // Nope! Wrong!
|
|
|
+ }
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (prompt == "Engage the Autopilot? (Y/N/Single step/Express) [Y] ") {
|
|
|
+ to_server("E");
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
} else if (state == 4) {
|
|
|
if (prompt == "Engage the Autopilot? (Y/N/Single step/Express) [Y] ") {
|
|
|
if (use_express) {
|
|
@@ -679,9 +698,18 @@ void MoveDispatch::server_prompt(const std::string &prompt) {
|
|
|
}
|
|
|
if (prompt == "Stop in this sector (Y,N,E,I,R,S,D,P,?) (?=Help) [N] ? ") {
|
|
|
state = 5;
|
|
|
- to_server("SD");
|
|
|
+ // BUT? Do we have a scanner?
|
|
|
+ if (use_express) {
|
|
|
+ to_server("E");
|
|
|
+ } else
|
|
|
+ to_server("SD");
|
|
|
+ return;
|
|
|
}
|
|
|
} else if (state == 5) {
|
|
|
+ if (prompt == "Engage Express mode? (Y/N) [N] ") {
|
|
|
+ to_server("Y");
|
|
|
+ return;
|
|
|
+ }
|
|
|
// finished scan
|
|
|
if (prompt == "Stop in this sector (Y,N,E,I,R,S,D,P,?) (?=Help) [N] ? ") {
|
|
|
int to_check = warp_lane[warp_pos + 1];
|
|
@@ -699,6 +727,14 @@ void MoveDispatch::server_prompt(const std::string &prompt) {
|
|
|
deactivate();
|
|
|
}
|
|
|
}
|
|
|
+ if (at_command_prompt(prompt)) {
|
|
|
+ if (director.current_sector == move_to) {
|
|
|
+ success = 1;
|
|
|
+ } else
|
|
|
+ success = 0;
|
|
|
+ deactivate();
|
|
|
+ return;
|
|
|
+ }
|
|
|
} else if (state == 6) {
|
|
|
if (at_command_prompt(prompt)) {
|
|
|
// We're done!
|
|
@@ -716,12 +752,12 @@ void MoveDispatch::client_input(const std::string &input) {
|
|
|
deactivate();
|
|
|
}
|
|
|
|
|
|
-TraderDispatch::TraderDispatch(Director &d, const char * called) : Dispatch(d, called) {
|
|
|
+TraderDispatch::TraderDispatch(Director &d, const char *called)
|
|
|
+ : Dispatch(d, called) {
|
|
|
BUGZ_LOG(fatal) << "TraderDispatch()";
|
|
|
state = 0;
|
|
|
success = false;
|
|
|
- if (called == nullptr)
|
|
|
- name = "Trader";
|
|
|
+ if (called == nullptr) name = "Trader";
|
|
|
director.galaxy.meta["help"]["stop_percent"] =
|
|
|
"ScriptTrader stop trading if below this percent.";
|
|
|
director.galaxy.meta["help"]["trade_end_empty"] =
|
|
@@ -1276,10 +1312,10 @@ void TraderDispatch::client_input(const std::string &cinput) {
|
|
|
* CoreDispatch: This is an example class that does dispatch.
|
|
|
* Copy this and make changes from there...
|
|
|
*/
|
|
|
-CoreDispatch::CoreDispatch(Director &d, const char * called) : Dispatch(d, called) {
|
|
|
+CoreDispatch::CoreDispatch(Director &d, const char *called)
|
|
|
+ : Dispatch(d, called) {
|
|
|
BUGZ_LOG(warning) << "CoreDispatch()";
|
|
|
- if (called == nullptr)
|
|
|
- name = "Core";
|
|
|
+ if (called == nullptr) name = "Core";
|
|
|
}
|
|
|
|
|
|
void CoreDispatch::activate(void) {
|