|
@@ -3,6 +3,8 @@
|
|
|
#include "logging.h"
|
|
|
#include <boost/format.hpp>
|
|
|
|
|
|
+#ifdef DEPRECATED_SEE_TRADER_DISPATCH
|
|
|
+
|
|
|
ScriptTrader::ScriptTrader(Director &d) : Dispatch(d) {
|
|
|
BUGZ_LOG(fatal) << "ScriptTrader()";
|
|
|
state = 0;
|
|
@@ -485,8 +487,11 @@ void ScriptTrader::server_prompt(const std::string &prompt) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
void ScriptTrader::client_input(const std::string &cinput) { deactivate(); };
|
|
|
|
|
|
+#endif
|
|
|
+
|
|
|
ScriptTerror::ScriptTerror(Director &d) : Dispatch(d) {
|
|
|
BUGZ_LOG(warning) << "ScriptTerror()";
|
|
|
init();
|
|
@@ -546,7 +551,7 @@ void ScriptTerror::input_notify(void) {
|
|
|
}
|
|
|
id->input.clear();
|
|
|
BUGZ_LOG(warning) << "Loops of terror: " << max_loops;
|
|
|
- loops = 0;
|
|
|
+ loops = max_loops;
|
|
|
// find nearest
|
|
|
ppt = director.galaxy.find_closest_trade(director.current_sector, 3);
|
|
|
if (ppt.type == 0) {
|
|
@@ -585,6 +590,40 @@ void ScriptTerror::move_notify(void) {
|
|
|
|
|
|
void ScriptTerror::trade_notify(void) {
|
|
|
// Done trading -- maybe! :P
|
|
|
+ if (td->success) {
|
|
|
+ // success!
|
|
|
+ ppt = director.galaxy.find_closest_trade(director.current_sector, 3);
|
|
|
+ if (ppt.type == 0) {
|
|
|
+ to_client("No trades found! You've burnt the galaxy!\n\r");
|
|
|
+ deactivate();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if ((director.current_sector == ppt.s1) || (director.current_sector == ppt.s2)) {
|
|
|
+ // We're still here...
|
|
|
+ BUGZ_LOG(fatal) << "Trade it again, Sam.";
|
|
|
+ to_client("Keep trading.\n\r");
|
|
|
+ td->port[0] = ppt.s1;
|
|
|
+ td->port[1] = ppt.s2;
|
|
|
+ td->trades = ppt.trades;
|
|
|
+ td->type = ppt.type;
|
|
|
+ director.chain = trader;
|
|
|
+ director.chain->activate();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // Ok, this isn't a local trade.
|
|
|
+ if (loops == 0) {
|
|
|
+ to_client("We're done terrorizing, for now...\n\r");
|
|
|
+ deactivate();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ --loops;
|
|
|
+ // Move to our next target
|
|
|
+ BUGZ_LOG(fatal) << "Moving to: " << ppt.s1;
|
|
|
+ md->move_to = ppt.s1;
|
|
|
+ director.chain = move;
|
|
|
+ director.chain->activate();
|
|
|
+ return;
|
|
|
+ }
|
|
|
to_client("Ok, trade is done.\n\r");
|
|
|
deactivate();
|
|
|
}
|