Jelajahi Sumber

Save the known for density scans. (galaxy)

Steve Thielemann 3 tahun lalu
induk
melakukan
fcff86add2
4 mengubah file dengan 10 tambahan dan 11 penghapusan
  1. 1 1
      director.cpp
  2. 2 4
      galaxy.cpp
  3. 1 0
      galaxy.h
  4. 6 6
      test-director.cpp

+ 1 - 1
director.cpp

@@ -893,7 +893,7 @@ void Director::SL_densityline(const std::string &line) {
     uint16_t navhaz = std::stoi(dense.at(7));
     bool anom = in(dense.at(9), "Yes");
 
-    struct density d = {sector, density, warps, navhaz, anom};
+    struct density d = {sector, density, warps, navhaz, anom, known};
     galaxy.dscan.add_scan(d);
 
     // Commit data

+ 2 - 4
galaxy.cpp

@@ -68,7 +68,7 @@ density density_scan::find(sector_type sector) {
 bool operator==(const density lhs, const density rhs) {
   return ((lhs.sector == rhs.sector) && (lhs.density == rhs.density) &&
           (lhs.navhaz == rhs.navhaz) && (lhs.anomaly == rhs.anomaly) &&
-          (lhs.warps == rhs.warps));
+          (lhs.warps == rhs.warps) && (lhs.known == rhs.known));
 }
 
 trade_type_result trade_type_info(port_type port1, port_type port2) {
@@ -127,9 +127,7 @@ int trade_type(port_type port1, port_type port2) {
   return r.type;
 }
 
-sector_warps::sector_warps() {
-  sector = 0;
-}
+sector_warps::sector_warps() { sector = 0; }
 
 void sector_warps::add(sector_type new_sector) {
   warps.insert(new_sector);

+ 1 - 0
galaxy.h

@@ -81,6 +81,7 @@ struct density {
   uint16_t warps;
   uint16_t navhaz;
   bool anomaly;
+  bool known;
   friend bool operator==(const struct density lhs, const struct density rhs);
 };
 

+ 6 - 6
test-director.cpp

@@ -119,12 +119,12 @@ TEST(director, director_parsing_density) {
     }
   }
 
-  std::array<density, 6> dense = {{{70, 0, 6, 0, false},
-                                   {441, 100, 2, 0, false},
-                                   {575, 1000, 2, 15, true},
-                                   {600, 40, 6, 0, false},
-                                   {629, 1, 4, 0, false},
-                                   {711, 101, 6, 0, false}}};
+  std::array<density, 6> dense = {{{70, 0, 6, 0, false, true},
+                                   {441, 100, 2, 0, false, true},
+                                   {575, 1000, 2, 15, true, false},
+                                   {600, 40, 6, 0, false, true},
+                                   {629, 1, 4, 0, false, true},
+                                   {711, 101, 6, 0, false, true}}};
 
   for (auto const& s : dense) {
     auto d = dir.galaxy.dscan.find(s.sector);