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 authored and Nekotekina committed Feb 21, 2020
1 parent 0ba1f8f commit 54f2c27
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions rpcs3/Emu/Cell/Modules/cellGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,8 +545,9 @@ 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 u32 new_data = fs::is_dir(vfs::get(dir)) ? CELL_GAMEDATA_ISNEWDATA_NO : CELL_GAMEDATA_ISNEWDATA_YES;
cbGet->isNewData = new_data;

// 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 +577,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 +594,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 +626,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 54f2c27

Please sign in to comment.