|
@@ -562,7 +562,7 @@ void MoveDispatch::activate(void) {
|
|
|
state = 1;
|
|
|
warp_lane.clear();
|
|
|
warp_pos = 0;
|
|
|
-
|
|
|
+
|
|
|
// build final string to match against
|
|
|
at_destination = "Auto Warping to sector ";
|
|
|
at_destination.append(std::to_string(move_to));
|
|
@@ -573,29 +573,52 @@ void MoveDispatch::deactivate(void) { notify(); }
|
|
|
// optional here
|
|
|
void MoveDispatch::server_line(const std::string &line,
|
|
|
const std::string &raw_line) {
|
|
|
- BUGZ_LOG(fatal) << "server_line: " << line;
|
|
|
-
|
|
|
if (state == 1) {
|
|
|
if (endswith(line, "Relative Density Scan")) {
|
|
|
state = 2;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if ((state != 2) && (state != 5)) {
|
|
|
+ // hide the density scan part
|
|
|
+ std::string temp = raw_line;
|
|
|
+ temp.append("\n\r");
|
|
|
+ to_client(temp);
|
|
|
+ }
|
|
|
+
|
|
|
if (state == 3) {
|
|
|
+ if (line == "You are already in that sector!") {
|
|
|
+ success = true;
|
|
|
+ deactivate();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
if (line == "That Warp Lane is not adjacent.") {
|
|
|
- //ok! Parse out the path that we need to take...
|
|
|
+ // ok! Parse out the path that we need to take...
|
|
|
}
|
|
|
// [611 > 612 > 577 > 543 > 162 > 947 > 185 > 720 > 894 > 3 > 1]
|
|
|
- // multiple lines possible here?
|
|
|
- // watch for <Move> it contains >
|
|
|
+ // multiple lines possible here? Yes.
|
|
|
+ // [344 > 23328 > 2981 > 10465 > 14016 > 8979 > 1916 > 18734 > 5477 > 131 >
|
|
|
+ // 27464 >] watch for <Move> it contains >
|
|
|
if ((line != "<Move>") && in(line, ">")) {
|
|
|
+ bool more = false;
|
|
|
std::string work = line;
|
|
|
+
|
|
|
+ if (endswith(work, " >")) {
|
|
|
+ more = true;
|
|
|
+ work = work.substr(0, work.length() - 2);
|
|
|
+ }
|
|
|
+
|
|
|
replace(work, " > ", " ");
|
|
|
+ replace(work, "(", "");
|
|
|
+ replace(work, ")", "");
|
|
|
auto warps = split(work);
|
|
|
- for( auto const & w : warps) {
|
|
|
+ for (auto const &w : warps) {
|
|
|
BUGZ_LOG(fatal) << "lane: " << w;
|
|
|
warp_lane.push_back(stoi(w));
|
|
|
}
|
|
|
- state = 4;
|
|
|
+
|
|
|
+ if (!more) state = 4;
|
|
|
}
|
|
|
}
|
|
|
if (state == 4) {
|
|
@@ -606,7 +629,7 @@ void MoveDispatch::server_line(const std::string &line,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-bool MoveDispatch::density_clear(int density) {
|
|
|
+bool MoveDispatch::density_clear(int sector, int density) {
|
|
|
switch (density) {
|
|
|
case 0:
|
|
|
case 1:
|
|
@@ -614,6 +637,9 @@ bool MoveDispatch::density_clear(int density) {
|
|
|
case 101:
|
|
|
return true;
|
|
|
}
|
|
|
+ // special case for sector 1:
|
|
|
+ if ((sector == 1) && (density == 601))
|
|
|
+ return true;
|
|
|
return false;
|
|
|
}
|
|
|
|
|
@@ -623,16 +649,27 @@ void MoveDispatch::server_prompt(const std::string &prompt) {
|
|
|
if (state == 2) {
|
|
|
if (at_command_prompt(prompt)) {
|
|
|
// Ok, density is done
|
|
|
+ // BUG: If the sector is adjacent, this doesn't check density!
|
|
|
std::string command = str(boost::format("M%1%\r") % move_to);
|
|
|
to_server(command);
|
|
|
state = 3;
|
|
|
}
|
|
|
+ } else if (state == 3) {
|
|
|
+ if (at_command_prompt(prompt)) {
|
|
|
+ // this happens when the sector is adject to current_sector.
|
|
|
+ BUGZ_LOG(fatal) << "Are we there yet?";
|
|
|
+ success = true;
|
|
|
+ deactivate();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
} else if (state == 4) {
|
|
|
if (prompt == "Engage the Autopilot? (Y/N/Single step/Express) [Y] ") {
|
|
|
- int to_check = warp_lane[warp_pos+1];
|
|
|
+ int to_check = warp_lane[warp_pos + 1];
|
|
|
// check density scan
|
|
|
- int density = director.galaxy.meta["density"][to_check]["density"].as<int>();
|
|
|
- if (density_clear(density)) {
|
|
|
+ int density =
|
|
|
+ director.galaxy.meta["density"][to_check]["density"].as<int>();
|
|
|
+ if (density_clear(to_check, density)) {
|
|
|
to_server("S");
|
|
|
++warp_pos;
|
|
|
}
|
|
@@ -644,9 +681,10 @@ void MoveDispatch::server_prompt(const std::string &prompt) {
|
|
|
} else if (state == 5) {
|
|
|
// 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];
|
|
|
- int density = director.galaxy.meta["density"][to_check]["density"].as<int>();
|
|
|
- if (density_clear(density)) {
|
|
|
+ int to_check = warp_lane[warp_pos + 1];
|
|
|
+ int density =
|
|
|
+ director.galaxy.meta["density"][to_check]["density"].as<int>();
|
|
|
+ if (density_clear(to_check, density)) {
|
|
|
to_server("N");
|
|
|
++warp_pos;
|
|
|
state = 4;
|
|
@@ -655,7 +693,7 @@ void MoveDispatch::server_prompt(const std::string &prompt) {
|
|
|
BUGZ_LOG(fatal) << "Stopped by density: " << density;
|
|
|
success = 0;
|
|
|
deactivate();
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
} else if (state == 6) {
|
|
|
if (at_command_prompt(prompt)) {
|