diff --git a/Source/Core/Core/Src/Boot/Boot.h b/Source/Core/Core/Src/Boot/Boot.h index ffcc629de7..b03ae9afce 100644 --- a/Source/Core/Core/Src/Boot/Boot.h +++ b/Source/Core/Core/Src/Boot/Boot.h @@ -33,7 +33,7 @@ public: static std::string GenerateMapFilename(); - static bool Install_WiiWAD(const char *filename); + static u64 Install_WiiWAD(const char *filename); private: static void RunFunction(u32 _iAddr); diff --git a/Source/Core/Core/Src/Boot/Boot_WiiWAD.cpp b/Source/Core/Core/Src/Boot/Boot_WiiWAD.cpp index 08bf7f1092..7d2044090b 100644 --- a/Source/Core/Core/Src/Boot/Boot_WiiWAD.cpp +++ b/Source/Core/Core/Src/Boot/Boot_WiiWAD.cpp @@ -86,13 +86,13 @@ bool CBoot::Boot_WiiWAD(const char* _pFilename) } -bool CBoot::Install_WiiWAD(const char* _pFilename) +u64 CBoot::Install_WiiWAD(const char* _pFilename) { if (!IsWiiWAD(_pFilename)) - return false; + return 0; const DiscIO::INANDContentLoader& ContentLoader = DiscIO::CNANDContentManager::Access().GetNANDLoader(_pFilename); if (ContentLoader.IsValid() == false) - return false; + return 0; u64 TitleID = ContentLoader.GetTitleID(); u32 TitleID_HI = (u32)(TitleID >> 32); @@ -111,7 +111,7 @@ bool CBoot::Install_WiiWAD(const char* _pFilename) FILE* pTMDFile = fopen(TMDFileName.c_str(), "wb"); if (pTMDFile == NULL) { PanicAlertT("WAD installation failed: error creating %s", TMDFileName.c_str()); - return false; + return 0; } fwrite(ContentLoader.GetTmdHeader(), DiscIO::INANDContentLoader::TMD_HEADER_SIZE, 1, pTMDFile); @@ -140,7 +140,7 @@ bool CBoot::Install_WiiWAD(const char* _pFilename) if (pAPPFile == NULL) { PanicAlertT("WAD installation failed: error creating %s", APPFileName); - return false; + return 0; } fwrite(Content.m_pData, Content.m_Size, 1, pAPPFile); @@ -167,14 +167,14 @@ bool CBoot::Install_WiiWAD(const char* _pFilename) FILE* pTicketFile = fopen(TicketFileName, "wb"); if (pTicketFile == NULL) { PanicAlertT("WAD installation failed: error creating %s", TicketFileName); - return false; + return 0; } DiscIO::WiiWAD Wad(_pFilename); if (!Wad.IsValid()) { fclose(pTicketFile); - return false; + return 0; } fwrite(Wad.GetTicket(), Wad.GetTicketSize(), 1, pTicketFile); @@ -186,7 +186,7 @@ bool CBoot::Install_WiiWAD(const char* _pFilename) INFO_LOG(DISCIO, "Title %08x%08x, already exists in uid.sys", TitleID_HI, TitleID_LO); } - return true; + return TitleID; } diff --git a/Source/Core/Core/Src/CoreParameter.cpp b/Source/Core/Core/Src/CoreParameter.cpp index e88bf6a76b..22a12fec62 100644 --- a/Source/Core/Core/Src/CoreParameter.cpp +++ b/Source/Core/Core/Src/CoreParameter.cpp @@ -205,7 +205,7 @@ bool SCoreStartupParameter::AutoSetup(EBootBS2 _BootBS2) if (ContentLoader.GetContentByIndex(ContentLoader.GetBootIndex()) == NULL) { //WAD is valid yet cannot be booted. Install instead. - bool installed = CBoot::Install_WiiWAD(m_strFilename.c_str()); + u64 installed = CBoot::Install_WiiWAD(m_strFilename.c_str()); if (installed) SuccessAlertT("The WAD has been installed successfully"); return false; //do not boot diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_es.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_es.cpp index af1664eb27..6e03048b2e 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_es.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_es.cpp @@ -824,14 +824,13 @@ u32 CWII_IPC_HLE_Device_es::ES_DIVerify(u8* _pTMD, u32 _sz) { return -1; } - std::string contentPath, - dataPath, - tmdPath; - contentPath = Common::CreateTitleContentPath(tmdTitleID) + DIR_SEP; - dataPath = Common::CreateTitleDataPath(tmdTitleID) + DIR_SEP; - tmdPath = contentPath + "/title.tmd"; + std::string tmdPath, + dataPath; - File::CreateFullPath(contentPath); + tmdPath = Common::CreateTitleContentPath(tmdTitleID) + DIR_SEP + "title.tmd"; + dataPath = Common::CreateTitleDataPath(tmdTitleID) + DIR_SEP; + + File::CreateFullPath(tmdPath); File::CreateFullPath(dataPath); if(!File::Exists(tmdPath)) { diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_es.h b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_es.h index f3db3ee12e..6c31e7be31 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_es.h +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_es.h @@ -97,6 +97,7 @@ private: IOCTL_ES_GETSTOREDTMD = 0x35, IOCTL_ES_GETSHAREDCONTENTCNT = 0x36, IOCTL_ES_GETSHAREDCONTENTS = 0x37, + IOCTL_ES_DELETESHAREDCONTENT = 0x38, IOCTL_ES_CHECKKOREAREGION = 0x45, }; diff --git a/Source/Core/DiscIO/Src/NANDContentLoader.cpp b/Source/Core/DiscIO/Src/NANDContentLoader.cpp index 8de4eff0d5..6d1a8f7240 100644 --- a/Source/Core/DiscIO/Src/NANDContentLoader.cpp +++ b/Source/Core/DiscIO/Src/NANDContentLoader.cpp @@ -366,20 +366,29 @@ CNANDContentManager::~CNANDContentManager() m_Map.clear(); } -const INANDContentLoader& CNANDContentManager::GetNANDLoader(const std::string& _rName) +const INANDContentLoader& CNANDContentManager::GetNANDLoader(const std::string& _rName, bool forceReload) { CNANDContentMap::iterator lb = m_Map.lower_bound(_rName); if(lb == m_Map.end() || (m_Map.key_comp()(_rName, lb->first))) + { m_Map.insert(lb, CNANDContentMap::value_type(_rName, new CNANDContentLoader(_rName))); - + } + else + { + if (!lb->second->IsValid() || forceReload) + { + delete lb->second; + lb->second = new CNANDContentLoader(_rName); + } + } return *m_Map[_rName]; } -const INANDContentLoader& CNANDContentManager::GetNANDLoader(u64 _titleId) +const INANDContentLoader& CNANDContentManager::GetNANDLoader(u64 _titleId, bool forceReload) { std::string _rName = Common::CreateTitleContentPath(_titleId); - return GetNANDLoader(_rName); + return GetNANDLoader(_rName, forceReload); } cUIDsys::cUIDsys() @@ -411,7 +420,7 @@ cUIDsys::cUIDsys() if (pFile) { if (fwrite(&Element, sizeof(SElement), 1, pFile) != 1) - ERROR_LOG(DISCIO, "fwrite failed"); + ERROR_LOG(DISCIO, "Failed to write to %s", uidSys); fclose(pFile); } } diff --git a/Source/Core/DiscIO/Src/NANDContentLoader.h b/Source/Core/DiscIO/Src/NANDContentLoader.h index 85402cbfd3..3543061b22 100644 --- a/Source/Core/DiscIO/Src/NANDContentLoader.h +++ b/Source/Core/DiscIO/Src/NANDContentLoader.h @@ -81,8 +81,8 @@ public: static CNANDContentManager& Access() { return m_Instance; } - const INANDContentLoader& GetNANDLoader(const std::string& _rName); - const INANDContentLoader& GetNANDLoader(u64 _titleId); + const INANDContentLoader& GetNANDLoader(const std::string& _rName, bool forceReload = false); + const INANDContentLoader& GetNANDLoader(u64 _titleId, bool forceReload = false); private: CNANDContentManager() {}; diff --git a/Source/Core/DolphinWX/Src/Frame.cpp b/Source/Core/DolphinWX/Src/Frame.cpp index 8d25c7d971..d2c0657f2a 100644 --- a/Source/Core/DolphinWX/Src/Frame.cpp +++ b/Source/Core/DolphinWX/Src/Frame.cpp @@ -283,7 +283,7 @@ EVT_MENU(IDM_MEMCARD, CFrame::OnMemcard) EVT_MENU(IDM_IMPORTSAVE, CFrame::OnImportSave) EVT_MENU(IDM_CHEATS, CFrame::OnShow_CheatsWindow) EVT_MENU(IDM_CHANGEDISC, CFrame::OnChangeDisc) -EVT_MENU(IDM_INSTALL_WII_MENU, CFrame::OnLoadWiiMenu) +EVT_MENU(IDM_INSTALLWAD, CFrame::OnLoadWiiMenu) EVT_MENU(IDM_LOAD_WII_MENU, CFrame::OnLoadWiiMenu) EVT_MENU(IDM_TOGGLE_FULLSCREEN, CFrame::OnToggleFullscreen) diff --git a/Source/Core/DolphinWX/Src/FrameTools.cpp b/Source/Core/DolphinWX/Src/FrameTools.cpp index 7ef687f35c..9d1e291da7 100644 --- a/Source/Core/DolphinWX/Src/FrameTools.cpp +++ b/Source/Core/DolphinWX/Src/FrameTools.cpp @@ -202,17 +202,14 @@ void CFrame::CreateMenu() toolsMenu->Append(IDM_NETPLAY, _("Start &NetPlay")); - if (DiscIO::CNANDContentManager::Access().GetNANDLoader(TITLEID_SYSMENU).IsValid()) - { - int sysmenuVersion = DiscIO::CNANDContentManager::Access().GetNANDLoader(TITLEID_SYSMENU).GetTitleVersion(); - char sysmenuRegion = DiscIO::CNANDContentManager::Access().GetNANDLoader(TITLEID_SYSMENU).GetCountryChar(); - - toolsMenu->Append(IDM_LOAD_WII_MENU, wxString::Format(_("Load Wii System Menu (%d %c)"), sysmenuVersion, sysmenuRegion)); - } - else - { - toolsMenu->Append(IDM_INSTALL_WII_MENU, _("Install Wii Menu")); - } + toolsMenu->Append(IDM_INSTALLWAD, _("Install WAD")); + + int sysmenuVersion = DiscIO::CNANDContentManager::Access().GetNANDLoader(TITLEID_SYSMENU).GetTitleVersion(); + char sysmenuRegion = DiscIO::CNANDContentManager::Access().GetNANDLoader(TITLEID_SYSMENU).GetCountryChar(); + + toolsMenu->Append(IDM_LOAD_WII_MENU, wxString::Format(_("Load Wii System Menu %d%c"), sysmenuVersion, sysmenuRegion)); + toolsMenu->Enable(IDM_LOAD_WII_MENU, DiscIO::CNANDContentManager::Access().GetNANDLoader(TITLEID_SYSMENU).IsValid()); + toolsMenu->AppendSeparator(); toolsMenu->AppendCheckItem(IDM_CONNECT_WIIMOTE1, GetMenuLabel(HK_WIIMOTE1_CONNECT)); toolsMenu->AppendCheckItem(IDM_CONNECT_WIIMOTE2, GetMenuLabel(HK_WIIMOTE2_CONNECT)); @@ -1319,15 +1316,33 @@ void CFrame::OnLoadWiiMenu(wxCommandEvent& event) { wxString path = wxFileSelector( - _("Select the System Menu wad extracted from the update partition of a disc"), + _("Select a Wii WAD file to install"), wxEmptyString, wxEmptyString, wxEmptyString, - _T("System Menu (*.wad)|*.wad"), + _T("Wii WAD file (*.wad)|*.wad"), wxFD_OPEN | wxFD_PREVIEW | wxFD_FILE_MUST_EXIST, this); - if (CBoot::Install_WiiWAD(path.mb_str())) + wxProgressDialog dialog(_("Installing WAD..."), + _("Working..."), + 1000, // range + this, // parent + wxPD_APP_MODAL | + wxPD_SMOOTH // - makes indeterminate mode bar on WinXP very small + ); + + dialog.CenterOnParent(); + u64 titleID = CBoot::Install_WiiWAD(path.mb_str()); + if (titleID == TITLEID_SYSMENU) { - GetMenuBar()->FindItem(IDM_INSTALL_WII_MENU)->Enable(false); + const DiscIO::INANDContentLoader & _Loader = DiscIO::CNANDContentManager::Access().GetNANDLoader(TITLEID_SYSMENU, true); + if (_Loader.IsValid()) + { + int sysmenuVersion = _Loader.GetTitleVersion(); + char sysmenuRegion = _Loader.GetCountryChar(); + + GetMenuBar()->FindItem(IDM_LOAD_WII_MENU)->Enable(); + GetMenuBar()->FindItem(IDM_LOAD_WII_MENU)->SetText(wxString::Format(_("Load Wii System Menu %d%c"), sysmenuVersion, sysmenuRegion)); + } } } } diff --git a/Source/Core/DolphinWX/Src/Globals.h b/Source/Core/DolphinWX/Src/Globals.h index 29b6a4c0a2..72d8d81701 100644 --- a/Source/Core/DolphinWX/Src/Globals.h +++ b/Source/Core/DolphinWX/Src/Globals.h @@ -94,7 +94,6 @@ enum IDM_PROPERTIES, IDM_GAMEWIKI, IDM_LOAD_WII_MENU, - IDM_INSTALL_WII_MENU, IDM_CONNECT_WIIMOTE1, IDM_CONNECT_WIIMOTE2, IDM_CONNECT_WIIMOTE3, diff --git a/Source/Core/InputCommon/Src/UDPWiimote.cpp b/Source/Core/InputCommon/Src/UDPWiimote.cpp index d31b5ad047..9396da741f 100644 --- a/Source/Core/InputCommon/Src/UDPWiimote.cpp +++ b/Source/Core/InputCommon/Src/UDPWiimote.cpp @@ -7,6 +7,7 @@ #include #define sock_t SOCKET #define ERRNO WSAGetLastError() +#undef EWOULDBLOCK #define EWOULDBLOCK WSAEWOULDBLOCK #define BAD_SOCK INVALID_SOCKET #define close(x) closesocket(x)