This commit is contained in:
Nekotekina 2014-04-19 18:45:55 +04:00
commit 678a964ff4

View File

@ -21,21 +21,38 @@ struct sceNpTrophyInternalContext
{ {
// TODO // TODO
std::string trp_name; std::string trp_name;
vfsStream* trp_stream; std::unique_ptr<vfsStream> trp_stream;
TROPUSRLoader* tropusr; std::unique_ptr<TROPUSRLoader> tropusr;
//TODO: remove the following code when Visual C++ no longer generates
//compiler errors for it. All of this should be auto-generated
#if defined(_MSC_VER) && _MSC_VER <= 1800
sceNpTrophyInternalContext() sceNpTrophyInternalContext()
: trp_stream(nullptr), : trp_stream(),
tropusr(nullptr) tropusr()
{ {
} }
~sceNpTrophyInternalContext() sceNpTrophyInternalContext(sceNpTrophyInternalContext&& other)
{ {
safe_delete(trp_stream); std::swap(trp_stream,other.trp_stream);
safe_delete(tropusr); std::swap(tropusr, other.tropusr);
std::swap(trp_name, other.trp_name);
} }
sceNpTrophyInternalContext& operator =(sceNpTrophyInternalContext&& other)
{
std::swap(trp_stream, other.trp_stream);
std::swap(tropusr, other.tropusr);
std::swap(trp_name, other.trp_name);
return *this;
}
sceNpTrophyInternalContext(sceNpTrophyInternalContext& other) = delete;
sceNpTrophyInternalContext& operator =(sceNpTrophyInternalContext& other) = delete;
#endif
}; };
struct sceNpTrophyInternal struct sceNpTrophyInternal
@ -92,10 +109,10 @@ int sceNpTrophyCreateContext(mem32_t context, mem_ptr_t<SceNpCommunicationId> co
if (stream && stream->IsOpened()) if (stream && stream->IsOpened())
{ {
sceNpTrophyInternalContext ctxt; s_npTrophyInstance.contexts.emplace_back();
ctxt.trp_stream = stream; sceNpTrophyInternalContext& ctxt = s_npTrophyInstance.contexts.back();
ctxt.trp_stream.reset(stream);
ctxt.trp_name = entry->name; ctxt.trp_name = entry->name;
s_npTrophyInstance.contexts.push_back(ctxt);
stream = nullptr; stream = nullptr;
return CELL_OK; return CELL_OK;
} }
@ -178,7 +195,7 @@ int sceNpTrophyRegisterContext(u32 context, u32 handle, u32 statusCb_addr, u32 a
std::string trophyUsrPath = trophyPath + "/TROPUSR.DAT"; std::string trophyUsrPath = trophyPath + "/TROPUSR.DAT";
std::string trophyConfPath = trophyPath + "/TROPCONF.SFM"; std::string trophyConfPath = trophyPath + "/TROPCONF.SFM";
tropusr->Load(trophyUsrPath, trophyConfPath); tropusr->Load(trophyUsrPath, trophyConfPath);
ctxt.tropusr = tropusr; ctxt.tropusr.reset(tropusr);
// TODO: Callbacks // TODO: Callbacks