@@ -111,8 +111,7 @@ OTRVersion DetectOTRVersion(std::string fileName) {
111111}
112112
113113bool VerifyArchiveVersion (OTRVersion version) {
114- return version.major != INT16_MAX && version.minor != INT16_MAX &&
115- (version.major == gBuildVersionMajor || version.minor == gBuildVersionMinor );
114+ return version.major == gBuildVersionMajor && version.minor == gBuildVersionMinor ;
116115}
117116
118117GameEngine::GameEngine () : dictionary(nullptr ) {
@@ -127,42 +126,36 @@ GameEngine::GameEngine() : dictionary(nullptr) {
127126 this ->context ->InitConsoleVariables (); // without this line the controldeck constructor failes in
128127 // ShipDeviceIndexMappingManager::UpdateControllerNamesFromConfig()
129128
130- #if (_DEBUG)
131- auto defaultLogLevel = spdlog::level::debug;
132- #else
133- auto defaultLogLevel = spdlog::level::info;
134- #endif
135- auto logLevel =
136- static_cast <spdlog::level::level_enum>(CVarGetInteger (CVAR_DEVELOPER_TOOLS (" LogLevel" ), defaultLogLevel));
137- context->InitLogging (logLevel, logLevel);
138- Ship::Context::GetInstance ()->GetLogger ()->set_pattern (" [%H:%M:%S.%e] [%s:%#] [%l] %v" );
139- SPDLOG_INFO (" Starting Ghostship version {} (Branch: {} | Commit: {})" , (char *)gBuildVersion , (char *)gGitBranch ,
140- (char *)gGitCommitHash );
141-
142129 std::vector<std::string> archiveFiles;
143130 const std::string main_path = Ship::Context::GetPathRelativeToAppDirectory (" sm64.o2r" );
144131 const std::string assets_path = Ship::Context::LocateFileAcrossAppDirs (" ghostship.o2r" );
145132
146- bool shouldRegen = !VerifyArchiveVersion (DetectOTRVersion (" sm64.o2r" ));
147-
148- #ifdef _WIN32
149- AllocConsole ();
150- #endif
133+ OTRVersion curVer = DetectOTRVersion (" sm64.o2r" );
134+ bool shouldRegen = !VerifyArchiveVersion (curVer) && curVer.major != INT16_MAX ;
151135
152136 if (std::filesystem::exists (main_path) && !shouldRegen) {
153137 archiveFiles.push_back (main_path);
154138 } else {
155- if (shouldRegen && std::filesystem::exists (main_path)) {
156- std::filesystem::remove (main_path);
157- }
158139 std::string msg = (shouldRegen ? " Your ROM O2R is outdated, and needs to be re-extracted.\n\n " : " " ) +
159140 std::string (" Please provide a Super Mario 64 ROM.\n\n Supported Versions:\n US\n JP\n\n "
160141 " Assets will be extracted into an O2R file." );
161142 if (ShowYesNoBox (" Ghostship - Asset Extraction" , msg.c_str ()) == IDYES ) {
143+ if (shouldRegen && std::filesystem::exists (main_path)) {
144+ std::filesystem::remove (main_path);
145+ }
146+ #ifdef _WIN32
147+ AllocConsole ();
148+ #endif
162149 if (!GenAssetFile ()) {
150+ #if defined(_WIN32) && !defined(_DEBUG)
151+ FreeConsole ();
152+ #endif
163153 ShowMessage (" Error" , " An error occured, no O2R file was generated.\n\n Exiting..." );
164154 exit (1 );
165155 } else {
156+ #if defined(_WIN32) && !defined(_DEBUG)
157+ FreeConsole ();
158+ #endif
166159 archiveFiles.push_back (main_path);
167160 }
168161 } else {
@@ -194,6 +187,18 @@ GameEngine::GameEngine() : dictionary(nullptr) {
194187 }
195188 }
196189
190+ #if (_DEBUG)
191+ auto defaultLogLevel = spdlog::level::debug;
192+ #else
193+ auto defaultLogLevel = spdlog::level::info;
194+ #endif
195+ auto logLevel =
196+ static_cast <spdlog::level::level_enum>(CVarGetInteger (CVAR_DEVELOPER_TOOLS (" LogLevel" ), defaultLogLevel));
197+ context->InitLogging (logLevel, logLevel);
198+ Ship::Context::GetInstance ()->GetLogger ()->set_pattern (" [%H:%M:%S.%e] [%s:%#] [%l] %v" );
199+ SPDLOG_INFO (" Starting Ghostship version {} (Branch: {} | Commit: {})" , (char *)gBuildVersion , (char *)gGitBranch ,
200+ (char *)gGitCommitHash );
201+
197202 auto controlDeck = std::make_shared<LUS ::ControlDeck>();
198203 this ->context ->InitControlDeck (controlDeck);
199204
0 commit comments