Skip to content

Commit

Permalink
feature: extra-natives/five: allow replacing embedded #ft/#dr texture…
Browse files Browse the repository at this point in the history
…s using ADD_REPLACE_TEXTURE
  • Loading branch information
blattersturm committed Feb 6, 2020
1 parent 94e6651 commit 0e74e81
Showing 1 changed file with 32 additions and 1 deletion.
Expand Up @@ -11,14 +11,15 @@

#define RAGE_FORMATS_IN_GAME
#include <gtaDrawable.h>
#include <fragType.h>

rage::grcTexture* LookupTexture(const std::string& txd, const std::string& txn)
{
streaming::Manager* streaming = streaming::Manager::GetInstance();
auto txdStore = streaming->moduleMgr.GetStreamingModule("ytd");

uint32_t id = -1;
txdStore->FindSlotFromHashKey(&id, txd.c_str());
txdStore->FindSlot(&id, txd.c_str());

if (id != 0xFFFFFFFF)
{
Expand All @@ -30,6 +31,36 @@ rage::grcTexture* LookupTexture(const std::string& txd, const std::string& txn)
}
}

auto drbStore = streaming->moduleMgr.GetStreamingModule("ydr");

id = -1;
drbStore->FindSlot(&id, txd.c_str());

if (id != 0xFFFFFFFF)
{
auto txdRef = (rage::five::gtaDrawable*)drbStore->GetPtr(id);

if (txdRef && txdRef->GetShaderGroup() && txdRef->GetShaderGroup()->GetTextures())
{
return (rage::grcTexture*)txdRef->GetShaderGroup()->GetTextures()->Get(txn.c_str());
}
}

auto fragStore = streaming->moduleMgr.GetStreamingModule("yft");

id = -1;
fragStore->FindSlot(&id, txd.c_str());

if (id != 0xFFFFFFFF)
{
auto txdRef = (rage::five::fragType*)fragStore->GetPtr(id);

if (txdRef && txdRef->GetPrimaryDrawable() && txdRef->GetPrimaryDrawable()->GetShaderGroup() && txdRef->GetPrimaryDrawable()->GetShaderGroup()->GetTextures())
{
return (rage::grcTexture*)txdRef->GetPrimaryDrawable()->GetShaderGroup()->GetTextures()->Get(txn.c_str());
}
}

return nullptr;
}

Expand Down

0 comments on commit 0e74e81

Please sign in to comment.