MassManager: change how hangars are handled.

This commit is contained in:
Guillaume Jacquemin 2022-03-30 20:34:37 +02:00
parent 718a6fd754
commit 4ed7aff835
2 changed files with 4 additions and 6 deletions

View file

@ -29,12 +29,10 @@ MassManager::MassManager(Containers::StringView save_path, Containers::StringVie
_demo{demo}, _demo{demo},
_stagingAreaDirectory{staging_dir} _stagingAreaDirectory{staging_dir}
{ {
Containers::arrayReserve(_hangars, 32);
Containers::String mass_filename = ""; Containers::String mass_filename = "";
for(int i = 0; i < 32; i++) { for(UnsignedInt i = 0; i < _hangars.size(); i++) {
mass_filename = Utility::Path::join(_saveDirectory, Utility::format("{}Unit{:.2d}{}.sav", demo ? "Demo"_s : ""_s, i, _account)); mass_filename = Utility::Path::join(_saveDirectory, Utility::format("{}Unit{:.2d}{}.sav", demo ? "Demo"_s : ""_s, i, _account));
Containers::arrayAppend(_hangars, Mass{mass_filename}); new(&_hangars[i]) Mass{mass_filename};
} }
if(!Utility::Path::exists(_stagingAreaDirectory)) { if(!Utility::Path::exists(_stagingAreaDirectory)) {

View file

@ -18,7 +18,7 @@
#include <map> #include <map>
#include <Corrade/Containers/GrowableArray.h> #include <Corrade/Containers/StaticArray.h>
#include <Corrade/Containers/String.h> #include <Corrade/Containers/String.h>
#include <Corrade/Containers/StringView.h> #include <Corrade/Containers/StringView.h>
@ -53,7 +53,7 @@ class MassManager {
Containers::String _lastError; Containers::String _lastError;
Containers::Array<Mass> _hangars; Containers::StaticArray<32, Mass> _hangars{NoInit};
Containers::StringView _stagingAreaDirectory; Containers::StringView _stagingAreaDirectory;