|
@@ -562,7 +562,7 @@ void MoveDispatch::activate(void) {
|
|
|
state = 1;
|
|
|
warp_lane.clear();
|
|
|
warp_pos = 0;
|
|
|
-
|
|
|
+
|
|
|
|
|
|
at_destination = "Auto Warping to sector ";
|
|
|
at_destination.append(std::to_string(move_to));
|
|
@@ -573,29 +573,52 @@ void MoveDispatch::deactivate(void) { notify(); }
|
|
|
|
|
|
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)) {
|
|
|
+
|
|
|
+ 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.") {
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
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;
|
|
|
}
|
|
|
+
|
|
|
+ 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)) {
|
|
|
|
|
|
+
|
|
|
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)) {
|
|
|
+
|
|
|
+ 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];
|
|
|
|
|
|
- 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) {
|
|
|
|
|
|
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)) {
|