Browse Source

Fixing #4 - we transfer all cargo to the planet.

Steve Thielemann 3 years ago
parent
commit
8f9f70f40a
2 changed files with 28 additions and 1 deletions
  1. 26 0
      scripts.cpp
  2. 2 1
      scripts.h

+ 26 - 0
scripts.cpp

@@ -855,6 +855,23 @@ void ScriptPlanet::server_prompt(const std::string &prompt) {
 
       BUGZ_LOG(fatal) << "Total population: " << total_population;
 
+      // FIXUP:  Empty out the ship holds if they aren't empty.
+
+      for (int x = 0; x < 3; ++x) {
+        if (ship[x] != 0) {
+          std::string message = str(
+              boost::format("Transfer ship cargo %1% (%2%) to planet.\n\r") %
+              foe[x] % ship[x]);
+          to_client(message);
+          std::string transfer = "TNL";
+          transfer.append(std::to_string(x + 1));
+          transfer.append("\r");
+          to_server(transfer);
+          ship[x] = 0;
+          return;
+        }
+      }
+
       // citadel, upgrade
       // what is the message when you don't have a citadel yet?
       state = 6;
@@ -867,9 +884,14 @@ void ScriptPlanet::server_prompt(const std::string &prompt) {
         endswith(prompt, "? ")) {
       // Do we have what we need?
       bool ready = true;
+
       if (total_population < support_construction) {
         ready = false;
         state = 9;
+        std::string message =
+            str(boost::format("Planet has %1% people, need %2%.\n\r") %
+                total_population % support_construction);
+        to_client(message);
         BUGZ_LOG(fatal) << "Need people ["
                         << support_construction - total_population << "]";
       }
@@ -880,6 +902,10 @@ void ScriptPlanet::server_prompt(const std::string &prompt) {
             ready = false;
             state = 12;
           }
+          std::string message =
+              str(boost::format("Has %1% of %2%, needs %3%\n\r") % amount[x] %
+                  foe[x] % needs[x]);
+          to_client(message);
           BUGZ_LOG(fatal) << "Need " << x << " :" << needs[x] - amount[x];
         }
       }

+ 2 - 1
scripts.h

@@ -101,7 +101,8 @@ class ScriptPlanet : public Dispatch {
     std::shared_ptr<Dispatch> trader;
     void next(void);
     std::shared_ptr<Dispatch> us;
-    
+    const char * foe[3] = {"Fuel", "Organics", "Equipment"};
+
   public:
     ScriptPlanet(Director &, const char *called = nullptr);
     ~ScriptPlanet();