diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp index d7fb08f5c6..0fd967c167 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp @@ -316,30 +316,12 @@ void ExecuteCommand(u32 _Address) } else { - CmdSuccess = true; - // The device is already created - pDevice = AccessDeviceByID(DeviceID); - // F|RES: prolly the re-open is just a mode change + pDevice = AccessDeviceByID(DeviceID); + CmdSuccess = pDevice->Open(_Address, Mode); INFO_LOG(WII_IPC_FILEIO, "IOP: ReOpen (Device=%s, DeviceID=%08x, Mode=%i)", pDevice->GetDeviceName().c_str(), DeviceID, Mode); - - if (pDevice->IsHardware()) - { - pDevice->Open(_Address, Mode); - } - else - { - // We may not have a file handle at this point, in Mario Kart I got a - // Open > Failed > ... other stuff > ReOpen call sequence, in that case - // we have no file and no file handle, so we call Open again to basically - // get a -106 error so that the game call CreateFile and then ReOpen again. - if (pDevice->ReturnFileHandle()) - Memory::Write_U32(DeviceID, _Address + 4); - else - pDevice->Open(_Address, Mode); - } } } break; diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device.h b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device.h index 7dd451be97..36709a084f 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device.h +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device.h @@ -91,8 +91,6 @@ public: virtual u32 Update() { return 0; } - virtual bool ReturnFileHandle() { return false; } - virtual bool IsHardware() { return m_Hardware; } virtual bool IsOpened() { return m_Active; } diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp index 09ffb418a3..831d056107 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp @@ -147,7 +147,7 @@ bool CWII_IPC_HLE_Device_FileIO::Open(u32 _CommandAddress, u32 _Mode) { case ISFS_OPEN_READ: m_pFileHandle = fopen(m_Filename.c_str(), "rb"); break; case ISFS_OPEN_WRITE: m_pFileHandle = fopen(m_Filename.c_str(), "r+b"); break; - // MK Wii gets here corrupting its saves, however using rb+ mode works fine + // MK Wii gets here corrupting its saves (truncating rksys.dat), however using rb+ mode works fine // TODO : figure it properly... case ISFS_OPEN_RW: m_pFileHandle = fopen(m_Filename.c_str(), "r+b"); break; default: PanicAlert("FileIO: Unknown open mode : 0x%02x", _Mode); break; @@ -182,7 +182,7 @@ bool CWII_IPC_HLE_Device_FileIO::Seek(u32 _CommandAddress) s32 SeekPosition = Memory::Read_U32(_CommandAddress + 0xC); s32 Mode = Memory::Read_U32(_CommandAddress + 0x10); - INFO_LOG(WII_IPC_FILEIO, "FileIO: Seek Pos: 0x%08x, Mode: %i (%s, Length=0x%08x)", SeekPosition, Mode, m_Name.c_str(), m_FileLength); + INFO_LOG(WII_IPC_FILEIO, "FileIO: Seek Pos: 0x%08x, Mode: %i (%s, Length=0x%08x)", SeekPosition, Mode, m_Name.c_str(), File::GetSize(m_pFileHandle)); /* TODO: Check if the new changes and the removed hack "magically" fixes Zelda - Twilight Princess as well */ @@ -299,11 +299,6 @@ bool CWII_IPC_HLE_Device_FileIO::IOCtl(u32 _CommandAddress) return true; } -bool CWII_IPC_HLE_Device_FileIO::ReturnFileHandle() -{ - return (m_pFileHandle) ? true : false; -} - void CWII_IPC_HLE_Device_FileIO::DoState(PointerWrap &p) { if (p.GetMode() == PointerWrap::MODE_WRITE) diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.h b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.h index 934fc08fe2..ef2a3a5119 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.h +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.h @@ -35,7 +35,6 @@ public: bool Read(u32 _CommandAddress); bool Write(u32 _CommandAddress); bool IOCtl(u32 _CommandAddress); - bool ReturnFileHandle(); void DoState(PointerWrap &p); private: