From 871a750f66354e8d2d9fbd344c22b0c6c077901c Mon Sep 17 00:00:00 2001 From: Guillaume Jacquemin Date: Fri, 6 Dec 2024 18:24:10 +0100 Subject: [PATCH] Mass: improve reliability of staged builds. --- src/GameObjects/Mass.cpp | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/src/GameObjects/Mass.cpp b/src/GameObjects/Mass.cpp index 6025185..b31fce5 100644 --- a/src/GameObjects/Mass.cpp +++ b/src/GameObjects/Mass.cpp @@ -56,28 +56,14 @@ Mass::getNameFromFile(Containers::StringView path) { return Containers::NullOpt; } - Gvas::File mass{path}; + Mass mass{path}; - if(!mass.valid()) { - LOG_ERROR_FORMAT("{} is invalid: {}", path, mass.lastError()); + if(mass._state != State::Valid) { + LOG_ERROR_FORMAT("{} is invalid: {}", path, mass._lastError); return Containers::NullOpt; } - auto unit_data = mass.at(MASS_UNIT_DATA); - - if(!unit_data) { - LOG_ERROR_FORMAT("Couldn't find {} in {}.", MASS_UNIT_DATA, path); - return Containers::NullOpt; - } - - auto name_prop = unit_data->at(MASS_NAME); - - if(!name_prop) { - LOG_ERROR_FORMAT("Couldn't find {} in {}.", MASS_NAME, path); - return Containers::NullOpt; - } - - return {name_prop->value}; + return mass._name; } void