Merge pull request #1991 from thedax/pangyaFix

Fix Pangya Fantasy golf properly (redux)
This commit is contained in:
Henrik Rydgård 2013-05-31 01:36:01 -07:00
commit 7e3ff382d6
2 changed files with 29 additions and 12 deletions

View File

@ -171,6 +171,7 @@ IFileSystem *MetaFileSystem::GetHandleOwner(u32 handle)
return 0;
}
extern u32 errorCode;
bool MetaFileSystem::MapFilePath(const std::string &_inpath, std::string &outpath, MountPoint **system)
{
std::string realpath;
@ -187,15 +188,18 @@ bool MetaFileSystem::MapFilePath(const std::string &_inpath, std::string &outpat
int currentThread = __KernelGetCurThread();
currentDir_t::iterator it = currentDir.find(currentThread);
if (it == currentDir.end())
if (it == currentDir.end())
{
//TODO: emulate PSP's error 8002032C: "no current working directory" if relative... may break things requiring fixes elsewhere
if (inpath.find(':') == std::string::npos /* means path is relative */)
WARN_LOG_REPORT(HLE, "Path is relative, but current directory not set for thread %i. Should give error, instead falling back to %s", currentThread, startingDirectory.c_str());
}
else
{
currentDirectory = &(it->second);
//Attempt to emulate SCE_KERNEL_ERROR_NOCWD / 8002032C: may break things requiring fixes elsewhere
if (inpath.find(':') == std::string::npos /* means path is relative */)
{
errorCode = SCE_KERNEL_ERROR_NOCWD;
WARN_LOG_REPORT(HLE, "Path is relative, but current directory not set for thread %i. returning 8002032C(SCE_KERNEL_ERROR_NOCWD) instead.", currentThread, startingDirectory.c_str());
}
else
{
currentDirectory = &(it->second);
}
}
if ( RealPath(*currentDirectory, inpath, realpath) )

View File

@ -98,6 +98,7 @@ typedef s64 SceOff;
typedef u64 SceIores;
int asyncNotifyEvent = -1;
u32 errorCode = 0;
#define SCE_STM_FDIR 0x1000
#define SCE_STM_FREG 0x2000
@ -742,6 +743,9 @@ FileNode *__IoOpen(const char* filename, int flags, int mode) {
access |= FILEACCESS_CREATE;
PSPFileInfo info = pspFileSystem.GetFileInfo(filename);
errorCode = 0;
u32 h = pspFileSystem.OpenFile(filename, (FileAccess) access);
if (h == 0) {
return NULL;
@ -766,10 +770,19 @@ u32 sceIoOpen(const char* filename, int flags, int mode) {
return -1;
FileNode *f = __IoOpen(filename, flags, mode);
if (f == NULL) {
ERROR_LOG(HLE, "ERROR_ERRNO_FILE_NOT_FOUND=sceIoOpen(%s, %08x, %08x) - file not found", filename, flags, mode);
// Timing is not accurate, aiming low for now.
return hleDelayResult(ERROR_ERRNO_FILE_NOT_FOUND, "file opened", 100);
if (f == NULL)
{
//Timing is not accurate, aiming low for now.
if(errorCode == SCE_KERNEL_ERROR_NOCWD)
{
ERROR_LOG(HLE, "SCE_KERNEL_ERROR_NOCWD=sceIoOpen(%s, %08x, %08x) - no current working directory", filename, flags, mode);
return hleDelayResult(SCE_KERNEL_ERROR_NOCWD , "no cwd", 10000);
}
else
{
ERROR_LOG(HLE, "ERROR_ERRNO_FILE_NOT_FOUND=sceIoOpen(%s, %08x, %08x) - file not found", filename, flags, mode);
return hleDelayResult(ERROR_ERRNO_FILE_NOT_FOUND , "file opened", 10000);
}
}
SceUID id = f->GetUID();