From a4e6dbadb594d0934ee4dc76db568768cb991e1a Mon Sep 17 00:00:00 2001 From: "Pavel Dmytriiev (Github)" Date: Thu, 26 Jul 2018 18:57:44 +0300 Subject: [PATCH 1/4] Fix to windows OpenFile dialog Now it actually says something about what exactly it tries to open, also on "cancel" it exits gracefully. Proposal: instead of checking one thousand return codes, which are easily ignored, I suggest using an exceptions (this part of emulator doesn't require execution speed, so exceptions here would be just fine). --- core/cfg/cfg.cpp | 13 ++-- core/cfg/cfg.h | 4 +- core/cfg/ini.cpp | 11 +-- core/cfg/ini.h | 2 +- core/hw/naomi/naomi_cart.cpp | 19 ++--- core/imgread/common.cpp | 130 ++++++++++++++--------------------- core/imgread/common.h | 2 +- core/nullDC.cpp | 58 +++++++++------- core/types.h | 4 +- core/windows/winmain.cpp | 5 +- 10 files changed, 113 insertions(+), 135 deletions(-) diff --git a/core/cfg/cfg.cpp b/core/cfg/cfg.cpp index 56cfa01cc..34dffd536 100644 --- a/core/cfg/cfg.cpp +++ b/core/cfg/cfg.cpp @@ -125,18 +125,17 @@ s32 cfgExists(const wchar * Section, const wchar * Key) return (cfgdb.has_section(string(Section)) ? 1 : 0); } } -void cfgLoadStr(const wchar * Section, const wchar * Key, wchar * Return,const wchar* Default) + +void cfgLoadStr(const std::string& Section, const std::string& Key, std::string& Return, const std::string& Default) { - string value = cfgdb.get(Section, Key, Default); - // FIXME: Buffer overflow possible - strcpy(Return, value.c_str()); + Return = cfgdb.get(Section, Key, Default); } -string cfgLoadStr(const wchar * Section, const wchar * Key, const wchar* Default) +string cfgLoadStr(const std::string& Section, const std::string& Key, const std::string& Default) { - if(!cfgdb.has_entry(string(Section), string(Key))) + if(!cfgdb.has_entry(Section, Key)) { - cfgSaveStr(Section, Key, Default); + cfgSaveStr(Section.c_str(), Key.c_str(), Default.c_str()); } return cfgdb.get(string(Section), string(Key), string(Default)); } diff --git a/core/cfg/cfg.h b/core/cfg/cfg.h index b4bef336b..b42372f2b 100644 --- a/core/cfg/cfg.h +++ b/core/cfg/cfg.h @@ -13,8 +13,8 @@ bool cfgOpen(); s32 cfgLoadInt(const wchar * lpSection, const wchar * lpKey,s32 Default); s32 cfgGameInt(const wchar * lpSection, const wchar * lpKey,s32 Default); void cfgSaveInt(const wchar * lpSection, const wchar * lpKey, s32 Int); -void cfgLoadStr(const wchar * lpSection, const wchar * lpKey, wchar * lpReturn,const wchar* lpDefault); -string cfgLoadStr(const wchar * Section, const wchar * Key, const wchar* Default); +void cfgLoadStr(const std::string& Section, const std::string& Key, std::string& Return, const std::string& Default); +std::string cfgLoadStr(const std::string& Section, const std::string& Key, const std::string& Default); void cfgSaveStr(const wchar * lpSection, const wchar * lpKey, const wchar * lpString); void cfgSaveBool(const wchar * Section, const wchar * Key, bool BoolValue); bool cfgLoadBool(const wchar * Section, const wchar * Key,bool Default); diff --git a/core/cfg/ini.cpp b/core/cfg/ini.cpp index ca114f2c5..58ec645b0 100644 --- a/core/cfg/ini.cpp +++ b/core/cfg/ini.cpp @@ -125,17 +125,10 @@ ConfigEntry* ConfigFile::get_entry(string section_name, string entry_name) } -string ConfigFile::get(string section_name, string entry_name, string default_value) +std::string ConfigFile::get(const string& section_name, const string& entry_name, const string& default_value /*= ""*/) { ConfigEntry* entry = this->get_entry(section_name, entry_name); - if (entry == NULL) - { - return default_value; - } - else - { - return entry->get_string(); - } + return (!entry) ? default_value : entry->get_string(); } int ConfigFile::get_int(string section_name, string entry_name, int default_value) diff --git a/core/cfg/ini.h b/core/cfg/ini.h index 8cbc80d46..66bd85b9d 100644 --- a/core/cfg/ini.h +++ b/core/cfg/ini.h @@ -33,7 +33,7 @@ struct ConfigFile { void save(FILE* fd); /* getting values */ - string get(string section_name, string entry_name, string default_value = ""); + std::string get(const string& section_name, const string& entry_name, const string& default_value = ""); int get_int(string section_name, string entry_name, int default_value = 0); bool get_bool(string section_name, string entry_name, bool default_value = false); /* setting values */ diff --git a/core/hw/naomi/naomi_cart.cpp b/core/hw/naomi/naomi_cart.cpp index 49e707d00..1e7b553c0 100644 --- a/core/hw/naomi/naomi_cart.cpp +++ b/core/hw/naomi/naomi_cart.cpp @@ -19,9 +19,9 @@ u32 RomSize; fd_t* RomCacheMap; u32 RomCacheMapCount; -char SelectedFile[512]; +std::string SelectedFile; -bool naomi_cart_LoadRom(char* file) +bool naomi_cart_LoadRom(const char* file) { printf("\nnullDC-Naomi rom loader v1.2\n"); @@ -50,7 +50,7 @@ bool naomi_cart_LoadRom(char* file) char* eon = strstr(line, "\n"); if (!eon) - printf("+Loading naomi rom that has no name\n"); + printf("+Loading naomi rom that has no name %s\n", line); else *eon = 0; @@ -204,13 +204,14 @@ bool naomi_cart_LoadRom(char* file) bool naomi_cart_SelectFile(void* handle) { cfgLoadStr("config", "image", SelectedFile, "null"); - + #if HOST_OS == OS_WINDOWS - if (strcmp(SelectedFile, "null") == 0) { + if (SelectedFile == "null") + { OPENFILENAME ofn = { 0 }; ofn.lStructSize = sizeof(OPENFILENAME); ofn.hInstance = (HINSTANCE)GetModuleHandle(0); - ofn.lpstrFile = SelectedFile; + ofn.lpstrFile = &SelectedFile[0]; ofn.nMaxFile = MAX_PATH; ofn.lpstrFilter = "*.lst\0*.lst\0\0"; ofn.nFilterIndex = 0; @@ -221,17 +222,17 @@ bool naomi_cart_SelectFile(void* handle) return true; } #endif - if (!naomi_cart_LoadRom(SelectedFile)) + if (!naomi_cart_LoadRom(SelectedFile.c_str())) { cfgSaveStr("emu", "gamefile", "naomi_bios"); } else { - cfgSaveStr("emu", "gamefile", SelectedFile); + cfgSaveStr("emu", "gamefile", SelectedFile.c_str()); } - printf("EEPROM file : %s.eeprom\n", SelectedFile); + printf("EEPROM file : %s.eeprom\n", SelectedFile.c_str()); return true; } diff --git a/core/imgread/common.cpp b/core/imgread/common.cpp index 3a08a564c..5ef84ddbf 100644 --- a/core/imgread/common.cpp +++ b/core/imgread/common.cpp @@ -23,6 +23,13 @@ Disc*(*drivers[])(const wchar* path)= u8 q_subchannel[96]; +void SetSnsCodes(const u32 asc, const u32 ascq, const u32 key) +{ + sns_asc = asc; + sns_ascq = ascq; + sns_key = key; +} + void PatchRegion_0(u8* sector,int size) { #ifndef NOT_REICAST @@ -150,7 +157,7 @@ Disc* OpenDisc(const wchar* fn) return rv; } -bool InitDrive_(wchar* fn) +bool InitDrive_(const wchar* const fn) { TermDrive(); @@ -176,132 +183,99 @@ bool InitDrive_(wchar* fn) } #ifndef NOT_REICAST -bool InitDrive(u32 fileflags) +bool InitDrive(u32 fileflags/*=0*/) { if (settings.imgread.LoadDefaultImage) { - printf("Loading default image \"%s\"\n",settings.imgread.DefaultImage); - if (!InitDrive_(settings.imgread.DefaultImage)) + printf("Loading default image \"%s\"\n", settings.imgread.DefaultImage.c_str()); + if (!InitDrive_(settings.imgread.DefaultImage.c_str())) { - msgboxf("Default image \"%s\" failed to load",MBX_ICONERROR,settings.imgread.DefaultImage); + msgboxf("Default image \"%s\" failed to load",MBX_ICONERROR,settings.imgread.DefaultImage.c_str()); return false; } else return true; } - // FIXME: Data loss if buffer is too small - wchar fn[512]; - strncpy(fn,settings.imgread.LastImage, sizeof(fn)); - fn[sizeof(fn) - 1] = '\0'; - + std::string diskImageFileName{ settings.imgread.LastImage }; #ifdef BUILD_DREAMCAST - int gfrv=GetFile(fn,0,fileflags); + int gfrv = GetFile(diskImageFileName); #else - int gfrv=0; + int gfrv = rv_error; #endif - if (gfrv == 0) - { - NullDriveDiscType=NoDisk; - gd_setdisc(); - sns_asc=0x29; - sns_ascq=0x00; - sns_key=0x6; - return true; - } - else if (gfrv == -1) + if (gfrv != rv_ok) { return false; } // FIXME: Data loss if buffer is too small - strncpy(settings.imgread.LastImage, fn, sizeof(settings.imgread.LastImage)); - settings.imgread.LastImage[sizeof(settings.imgread.LastImage) - 1] = '\0'; + settings.imgread.LastImage = diskImageFileName; SaveSettings(); - if (!InitDrive_(fn)) + if (!InitDrive_(diskImageFileName.c_str())) { //msgboxf("Selected image failed to load",MBX_ICONERROR); - NullDriveDiscType=NoDisk; - gd_setdisc(); - sns_asc=0x29; - sns_ascq=0x00; - sns_key=0x6; - return true; - } - else - { - return true; + NullDriveDiscType = NoDisk; + gd_setdisc(); + SetSnsCodes(0x29, 0x00, 0x06); + return false; } + return true; } bool DiscSwap(u32 fileflags) { if (settings.imgread.LoadDefaultImage) { - printf("Loading default image \"%s\"\n",settings.imgread.DefaultImage); - if (!InitDrive_(settings.imgread.DefaultImage)) + printf("Loading default image \"%s\"\n", settings.imgread.DefaultImage.c_str()); + if (!InitDrive_(settings.imgread.DefaultImage.c_str())) { - msgboxf("Default image \"%s\" failed to load",MBX_ICONERROR,settings.imgread.DefaultImage); + msgboxf("Default image \"%s\" failed to load",MBX_ICONERROR,settings.imgread.DefaultImage.c_str()); return false; } else return true; } - // FIXME: Data loss if buffer is too small - wchar fn[512]; - strncpy(fn, settings.imgread.LastImage, sizeof(fn)); - fn[sizeof(fn) - 1] = '\0'; - + std::string diskImageFileName{ settings.imgread.LastImage }; #ifdef BUILD_DREAMCAST - int gfrv=GetFile(fn,0,fileflags); + int gfrv = GetFile(diskImageFileName); #else - int gfrv=0; + int gfrv = rv_error; #endif - if (gfrv == 0) + if (gfrv == rv_ok) { - NullDriveDiscType=Open; + NullDriveDiscType = Open; gd_setdisc(); - sns_asc=0x28; - sns_ascq=0x00; - sns_key=0x6; - return true; - } - else if (gfrv == -1) - { - sns_asc=0x28; - sns_ascq=0x00; - sns_key=0x6; - return false; - } - - // FIXME: Data loss if buffer is too small - strncpy(settings.imgread.LastImage, fn, sizeof(settings.imgread.LastImage)); - settings.imgread.LastImage[sizeof(settings.imgread.LastImage) - 1] = '\0'; - - - SaveSettings(); - - if (!InitDrive_(fn)) - { - //msgboxf("Selected image failed to load",MBX_ICONERROR); - NullDriveDiscType=Open; - gd_setdisc(); - sns_asc=0x28; - sns_ascq=0x00; - sns_key=0x6; + SetSnsCodes(0x28, 0x00, 0x06); return true; } else { - sns_asc=0x28; - sns_ascq=0x00; - sns_key=0x6; + SetSnsCodes(0x28, 0x00, 0x06); // to fix: we have same return codes as previous branch, looks suspicious + return false; + } + + + settings.imgread.LastImage = diskImageFileName; + + SaveSettings(); + + if (!InitDrive_(diskImageFileName.c_str())) + { + //msgboxf("Selected image failed to load",MBX_ICONERROR); + NullDriveDiscType = Open; + gd_setdisc(); + SetSnsCodes(0x28, 0x00, 0x06); return true; } + else + { + SetSnsCodes(0x28, 0x00, 0x06); + return false; + } } #endif diff --git a/core/imgread/common.h b/core/imgread/common.h index cccafde49..b476723fc 100644 --- a/core/imgread/common.h +++ b/core/imgread/common.h @@ -97,7 +97,7 @@ void GetDriveToc(u32* to,DiskArea area); void GetDriveSector(u8 * buff,u32 StartSector,u32 SectorCount,u32 secsz); void GetDriveSessionInfo(u8* to,u8 session); -int GetFile(char *szFileName, char *szParse=0,u32 flags=0); +int GetFile(std::string& diskFileName); int msgboxf(wchar* text,unsigned int type,...); void printtoc(TocInfo* toc,SessionInfo* ses); extern u8 q_subchannel[96]; diff --git a/core/nullDC.cpp b/core/nullDC.cpp index 2ebcc066d..1497ba69b 100755 --- a/core/nullDC.cpp +++ b/core/nullDC.cpp @@ -40,35 +40,38 @@ settings_t settings; #include #endif -int GetFile(char *szFileName, char *szParse=0, u32 flags=0) +int GetFile(std::string& diskFileName) { - cfgLoadStr("config","image",szFileName,"null"); - if (strcmp(szFileName,"null")==0) + cfgLoadStr("config", "image", diskFileName, ""); +#if HOST_OS==OS_WINDOWS + if (diskFileName.empty()) { - #if HOST_OS==OS_WINDOWS + diskFileName.resize(MAX_PATH); OPENFILENAME ofn; - ZeroMemory( &ofn , sizeof( ofn)); - ofn.lStructSize = sizeof ( ofn ); - ofn.hwndOwner = NULL ; - ofn.lpstrFile = szFileName ; - ofn.lpstrFile[0] = '\0'; - ofn.nMaxFile = MAX_PATH; - ofn.lpstrFilter = "All\0*.*\0\0"; - ofn.nFilterIndex =1; - ofn.lpstrFileTitle = NULL ; - ofn.nMaxFileTitle = 0 ; - ofn.lpstrInitialDir=NULL ; - ofn.Flags = OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST ; + ZeroMemory(&ofn, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + ofn.lpstrFile = &diskFileName[0]; + ofn.nMaxFile = MAX_PATH; + ofn.lpstrFilter = "Supported Disk Image Files(.CDI, .GDI)\0*.CDI;*.GDI\0\0"; + ofn.nFilterIndex = 1; + ofn.lpstrTitle = "Open disk image file"; + ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; - if (GetOpenFileNameA(&ofn)) + while (!GetOpenFileName(&ofn)) { - //already there - //strcpy(szFileName,ofn.lpstrFile); + const DWORD errorCode = CommDlgExtendedError(); + if (errorCode == FNERR_BUFFERTOOSMALL) + { + //The first two bytes of the lpstrFile buffer contain an integer value specifying the size required to receive the full name, in characters. + const size_t newBufferSize = ((size_t)ofn.lpstrFile[0] | (size_t)ofn.lpstrFile[1] << 8); + diskFileName.resize(newBufferSize); + //try again + } + else return (errorCode == ERROR_SUCCESS) ? rv_ok : rv_error; } - #endif } - - return 1; +#endif + return rv_ok; } @@ -94,8 +97,6 @@ s32 plugins_Init() //if (s32 rv = libExtDevice_Init()) // return rv; - - return rv_ok; } @@ -204,7 +205,14 @@ int dc_init(int argc,wchar* argv[]) } } - plugins_Init(); + if (plugins_Init() != rv_ok) { +#if defined(_ANDROID) + reios_init_value = rv_error; + return; +#else + return rv_error; +#endif + } #if defined(_ANDROID) } diff --git a/core/types.h b/core/types.h index 6aa8a3c6c..61b02d057 100644 --- a/core/types.h +++ b/core/types.h @@ -677,8 +677,8 @@ struct settings_t { bool PatchRegion; bool LoadDefaultImage; - char DefaultImage[512]; - char LastImage[512]; + std::string DefaultImage; + std::string LastImage; } imgread; struct diff --git a/core/windows/winmain.cpp b/core/windows/winmain.cpp index 95f47f6c2..8e50127ad 100644 --- a/core/windows/winmain.cpp +++ b/core/windows/winmain.cpp @@ -695,7 +695,10 @@ int CALLBACK WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine int dc_init(int argc,wchar* argv[]); void dc_run(); void dc_term(); - dc_init(argc,argv); + if(dc_init(argc,argv)!=rv_ok) + { + return 0; + } #ifdef _WIN64 setup_seh(); From 3677e23e1d58ba9812593fd1c6c8d6fd2af12267 Mon Sep 17 00:00:00 2001 From: "Pavel Dmytriiev (Github)" Date: Fri, 3 Aug 2018 19:21:32 +0300 Subject: [PATCH 2/4] Fixed magic digits sense codes with some meaningful values --- core/imgread/common.cpp | 118 +++++++++++++++++++++------------------- core/nullDC.cpp | 5 +- core/webui/server.cpp | 13 ++--- 3 files changed, 73 insertions(+), 63 deletions(-) diff --git a/core/imgread/common.cpp b/core/imgread/common.cpp index 5ef84ddbf..f4ccbe000 100644 --- a/core/imgread/common.cpp +++ b/core/imgread/common.cpp @@ -23,11 +23,22 @@ Disc*(*drivers[])(const wchar* path)= u8 q_subchannel[96]; -void SetSnsCodes(const u32 asc, const u32 ascq, const u32 key) +struct SenseErrorCode { - sns_asc = asc; - sns_ascq = ascq; - sns_key = key; + int sns_asc; + int sns_ascq; + int sns_key; +}; + +//No disc inserted at the time of power-on, reset or hard reset, or TOC cannot be read. +const SenseErrorCode NoDiskInsertedSenseCode{ 0x29, 0, 6 }; +const SenseErrorCode NoErrorSenseCode{ 0, 0, 0 }; + +void SetSnsCodes(const SenseErrorCode& errorCode) +{ + sns_asc = errorCode.sns_asc; + sns_ascq = errorCode.sns_ascq; + sns_key = errorCode.sns_key; } void PatchRegion_0(u8* sector,int size) @@ -159,27 +170,26 @@ Disc* OpenDisc(const wchar* fn) bool InitDrive_(const wchar* const fn) { - TermDrive(); + TermDrive(); - //try all drivers - disc = OpenDisc(fn); + //try all drivers + disc = OpenDisc(fn); - if (disc!=0) - { - printf("gdrom: Opened image \"%s\"\n",fn); - NullDriveDiscType=Busy; + if (disc) + { + printf("gdrom: Opened image \"%s\"\n", fn); + NullDriveDiscType = Busy; #ifndef NOT_REICAST - libCore_gdrom_disc_change(); + libCore_gdrom_disc_change(); #endif -// Sleep(400); //busy for a bit // what, really ? - return true; - } - else - { - printf("gdrom: Failed to open image \"%s\"\n",fn); - NullDriveDiscType=NoDisk; //no disc :) - } - return false; + return true; + } + else + { + printf("gdrom: Failed to open image \"%s\"\n", fn); + NullDriveDiscType = NoDisk; //no disc :) + return false; + } } #ifndef NOT_REICAST @@ -208,17 +218,15 @@ bool InitDrive(u32 fileflags/*=0*/) return false; } - // FIXME: Data loss if buffer is too small settings.imgread.LastImage = diskImageFileName; SaveSettings(); if (!InitDrive_(diskImageFileName.c_str())) { - //msgboxf("Selected image failed to load",MBX_ICONERROR); NullDriveDiscType = NoDisk; gd_setdisc(); - SetSnsCodes(0x29, 0x00, 0x06); + SetSnsCodes(NoDiskInsertedSenseCode); return false; } return true; @@ -238,44 +246,44 @@ bool DiscSwap(u32 fileflags) return true; } - std::string diskImageFileName{ settings.imgread.LastImage }; + std::string diskImageFileName = settings.imgread.LastImage; #ifdef BUILD_DREAMCAST - int gfrv = GetFile(diskImageFileName); + int gfrv = GetFile(diskImageFileName); #else - int gfrv = rv_error; + int gfrv = rv_error; #endif - if (gfrv == rv_ok) - { - NullDriveDiscType = Open; - gd_setdisc(); - SetSnsCodes(0x28, 0x00, 0x06); - return true; - } - else - { - SetSnsCodes(0x28, 0x00, 0x06); // to fix: we have same return codes as previous branch, looks suspicious - return false; - } + if (gfrv == rv_ok) + { + NullDriveDiscType = Open; + gd_setdisc(); + SetSnsCodes(NoErrorSenseCode); + return true; + } + else + { + SetSnsCodes(NoDiskInsertedSenseCode); + return false; + } - settings.imgread.LastImage = diskImageFileName; + settings.imgread.LastImage = diskImageFileName; - SaveSettings(); + SaveSettings(); - if (!InitDrive_(diskImageFileName.c_str())) - { - //msgboxf("Selected image failed to load",MBX_ICONERROR); - NullDriveDiscType = Open; - gd_setdisc(); - SetSnsCodes(0x28, 0x00, 0x06); - return true; - } - else - { - SetSnsCodes(0x28, 0x00, 0x06); - return false; - } + if (!InitDrive_(diskImageFileName.c_str())) + { + msgboxf("Selected image failed to load", MBX_ICONERROR); + NullDriveDiscType = Open; + gd_setdisc(); + SetSnsCodes(NoDiskInsertedSenseCode); + return false; + } + else + { + SetSnsCodes(NoErrorSenseCode); + return true; + } } #endif @@ -419,4 +427,4 @@ DiscType GuessDiscType(bool m1, bool m2, bool da) return CdRom_Extra; else return CdRom; -} +} \ No newline at end of file diff --git a/core/nullDC.cpp b/core/nullDC.cpp index 1497ba69b..3c34198d5 100755 --- a/core/nullDC.cpp +++ b/core/nullDC.cpp @@ -67,7 +67,10 @@ int GetFile(std::string& diskFileName) diskFileName.resize(newBufferSize); //try again } - else return (errorCode == ERROR_SUCCESS) ? rv_ok : rv_error; + else + { + return (errorCode == ERROR_SUCCESS) ? rv_ok : rv_error; + } } } #endif diff --git a/core/webui/server.cpp b/core/webui/server.cpp index e275ad867..4f44261c4 100644 --- a/core/webui/server.cpp +++ b/core/webui/server.cpp @@ -21,15 +21,14 @@ #ifdef CMAKE_BUILD #include "lws_config.h" #endif - -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include -#include - #ifdef _WIN32 #include #ifdef EXTERNAL_POLL From 88c104580c5ca281209c405946a6d944a7252a51 Mon Sep 17 00:00:00 2001 From: "Pavel Dmytriiev (Github)" Date: Wed, 8 Aug 2018 19:14:52 +0300 Subject: [PATCH 3/4] Revert C++11 changes --- core/imgread/common.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/core/imgread/common.cpp b/core/imgread/common.cpp index f4ccbe000..41e826650 100644 --- a/core/imgread/common.cpp +++ b/core/imgread/common.cpp @@ -31,8 +31,8 @@ struct SenseErrorCode }; //No disc inserted at the time of power-on, reset or hard reset, or TOC cannot be read. -const SenseErrorCode NoDiskInsertedSenseCode{ 0x29, 0, 6 }; -const SenseErrorCode NoErrorSenseCode{ 0, 0, 0 }; +const SenseErrorCode NoDiskInsertedSenseCode = { 0x29, 0, 6 }; +const SenseErrorCode NoErrorSenseCode = { 0, 0, 0 }; void SetSnsCodes(const SenseErrorCode& errorCode) { @@ -207,17 +207,14 @@ bool InitDrive(u32 fileflags/*=0*/) return true; } - std::string diskImageFileName{ settings.imgread.LastImage }; + std::string diskImageFileName = settings.imgread.LastImage; #ifdef BUILD_DREAMCAST - int gfrv = GetFile(diskImageFileName); + int returnCode = GetFile(diskImageFileName); + if (!returnCode) + return false; #else - int gfrv = rv_error; + int returnCode = rv_error; #endif - if (gfrv != rv_ok) - { - return false; - } - settings.imgread.LastImage = diskImageFileName; SaveSettings(); From 95c06b942b5e47a65a67f70c3aa9305ec8a8350c Mon Sep 17 00:00:00 2001 From: Abandoned Cart <1173913+AbandonedCart@users.noreply.github.com> Date: Tue, 28 Aug 2018 07:50:30 -0400 Subject: [PATCH 4/4] Fix formatting to force restart wercker --- core/imgread/common.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/imgread/common.cpp b/core/imgread/common.cpp index 41e826650..dde853bd9 100644 --- a/core/imgread/common.cpp +++ b/core/imgread/common.cpp @@ -210,8 +210,8 @@ bool InitDrive(u32 fileflags/*=0*/) std::string diskImageFileName = settings.imgread.LastImage; #ifdef BUILD_DREAMCAST int returnCode = GetFile(diskImageFileName); - if (!returnCode) - return false; + if (!returnCode) + return false; #else int returnCode = rv_error; #endif @@ -424,4 +424,4 @@ DiscType GuessDiscType(bool m1, bool m2, bool da) return CdRom_Extra; else return CdRom; -} \ No newline at end of file +}