Explorar el Código

extractor reporting invalid percentages

David Rose hace 23 años
padre
commit
1f805b0644

+ 0 - 14
panda/src/downloader/extractor.I

@@ -15,17 +15,3 @@
 // [email protected] .
 //
 ////////////////////////////////////////////////////////////////////
-
-#include "config_downloader.h"
-
-////////////////////////////////////////////////////////////////////
-//     Function: Extractor::get_progress
-//       Access: Public
-//  Description: Returns the fraction of the Multifile extracted so
-//               far.
-////////////////////////////////////////////////////////////////////
-INLINE float Extractor::
-get_progress() const {
-  nassertr(_initiated, 0.0f);
-  return ((float)_subfile_index / (float)(_multifile.get_num_subfiles() + 1));
-}

+ 34 - 0
panda/src/downloader/extractor.cxx

@@ -208,6 +208,40 @@ step() {
   return EU_ok;
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: Extractor::get_progress
+//       Access: Public
+//  Description: Returns the fraction of the Multifile extracted so
+//               far.
+////////////////////////////////////////////////////////////////////
+float Extractor::
+get_progress() const {
+  if (!_initiated) {
+    return 0.0f;
+  }
+
+  float progress_through_file;
+
+  if (_read == (istream *)NULL) {
+    // Time to open the next subfile.
+    progress_through_file = 0.0f;
+
+  } else if (_subfile_pos >= _subfile_length) {
+    // Time to close this subfile.
+    progress_through_file = 1.0f;
+
+  } else {
+    // In the middle of processing a subfile.
+    progress_through_file = (float)_subfile_pos / (float)_subfile_length;
+  }
+
+  float progress_through_list =
+    (((float)_request_index + progress_through_file) / 
+     (float)(_requests.size() + 1));
+
+  return progress_through_list;
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: Extractor::run
 //       Access: Published

+ 1 - 1
panda/src/downloader/extractor.h

@@ -51,7 +51,7 @@ PUBLISHED:
   int request_all_subfiles();
 
   int step();
-  INLINE float get_progress(void) const;
+  float get_progress(void) const;
 
   bool run();