Skip to content

Commit

Permalink
cellGameDataCheckCreate(2): Set nullptr in setParam
Browse files Browse the repository at this point in the history
* setParam is nullptr by default.
* if setParam is null and it's new data, return error code.
  • Loading branch information
elad335 committed Feb 21, 2020
1 parent 88efa9e commit 60d3a88
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions rpcs3/Emu/Cell/Modules/cellGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,8 +545,7 @@ error_code cellGameDataCheckCreate2(ppu_thread& ppu, u32 version, vm::cptr<char>
vm::var<CellGameDataCBResult> cbResult;
vm::var<CellGameDataStatGet> cbGet;
vm::var<CellGameDataStatSet> cbSet;
cbGet->isNewData = fs::is_dir(vfs::get(dir)) ? CELL_GAMEDATA_ISNEWDATA_NO : CELL_GAMEDATA_ISNEWDATA_YES;

const bool new_data = cbGet->isNewData = fs::is_dir(vfs::get(dir)) ? CELL_GAMEDATA_ISNEWDATA_NO : CELL_GAMEDATA_ISNEWDATA_YES;

// TODO: Use the free space of the computer's HDD where RPCS3 is being run.
cbGet->hddFreeSizeKB = 40 * 1024 * 1024 - 1; // Read explanation in cellHddGameCheck
Expand Down Expand Up @@ -576,10 +575,6 @@ error_code cellGameDataCheckCreate2(ppu_thread& ppu, u32 version, vm::cptr<char>
strcpy_trunc(cbGet->getParam.titleLang[i], psf::get_string(sfo, fmt::format("TITLE_%02d", i)));
}

vm::var<CellGameDataSystemFileParam> setParam;
*setParam = cbGet->getParam;
cbSet->setParam = setParam;

funcStat(ppu, cbResult, cbGet, cbSet);

switch (cbResult->result)
Expand All @@ -597,7 +592,7 @@ error_code cellGameDataCheckCreate2(ppu_thread& ppu, u32 version, vm::cptr<char>
const std::string usrdir = dir + "/USRDIR";
const std::string vusrdir = vfs::get(usrdir);

if (!fs::is_dir(vusrdir) && !fs::create_path(vusrdir))
if (new_data && !fs::create_path(vusrdir))
{
return {CELL_GAME_ERROR_ACCESS_ERROR, usrdir};
}
Expand Down Expand Up @@ -629,6 +624,10 @@ error_code cellGameDataCheckCreate2(ppu_thread& ppu, u32 version, vm::cptr<char>

psf::save_object(fs::file(vdir + "/PARAM.SFO", fs::rewrite), sfo);
}
else if (new_data)
{
return CELL_GAMEDATA_ERROR_PARAM;
}

return CELL_OK;
}
Expand Down

0 comments on commit 60d3a88

Please sign in to comment.