From 66e67d5aff8fbbbf416ef18189ef3eb9d9436e45 Mon Sep 17 00:00:00 2001 From: aap Date: Thu, 17 Dec 2015 22:15:59 +0100 Subject: [PATCH] made switching platforms a little nicer --- src/gtaplg.cpp | 35 +++++++++++++++++++++++++++++++++++ src/gtaplg.h | 5 +++++ tools/insttest/insttest.cpp | 18 +++++++++++++++--- 3 files changed, 55 insertions(+), 3 deletions(-) diff --git a/src/gtaplg.cpp b/src/gtaplg.cpp index 77e4eb2..71aeda7 100644 --- a/src/gtaplg.cpp +++ b/src/gtaplg.cpp @@ -16,6 +16,40 @@ using namespace std; +namespace rw { + +int32 +findPlatform(Clump *c) +{ + for(int32 i = 0; i < c->numAtomics; i++){ + Geometry *g = c->atomicList[i]->geometry; + if(g->instData) + return g->instData->platform; + } + return 0; +} + +void +switchPipes(Clump *c, int32 platform) +{ + for(int32 i = 0; i < c->numAtomics; i++){ + Atomic *a = c->atomicList[i]; + if(a->pipeline && a->pipeline->platform != platform){ + uint32 plgid = a->pipeline->pluginID; + switch(plgid){ + case ID_SKIN: + a->pipeline = skinGlobals.pipelines[platform]; + break; + case ID_MATFX: + a->pipeline = matFXGlobals.pipelines[platform]; + break; + } + } + } +} + +} + namespace gta { void @@ -579,6 +613,7 @@ static void readPipeline(Stream *stream, int32, void *object, int32 offset, int32) { *PLUGINOFFSET(uint32, object, offset) = stream->readU32(); + printf("%x\n", *PLUGINOFFSET(uint32, object, offset)); } static void diff --git a/src/gtaplg.h b/src/gtaplg.h index 664d642..b31a51d 100644 --- a/src/gtaplg.h +++ b/src/gtaplg.h @@ -1,3 +1,8 @@ +namespace rw { +int32 findPlatform(Clump *c); +void switchPipes(Clump *c, int32 platform); +}; + namespace gta { using namespace rw; diff --git a/tools/insttest/insttest.cpp b/tools/insttest/insttest.cpp index 47a13a6..e24593a 100644 --- a/tools/insttest/insttest.cpp +++ b/tools/insttest/insttest.cpp @@ -15,12 +15,13 @@ main(int argc, char *argv[]) { gta::attachPlugins(); - rw::version = 0x34003; + rw::version = 0; +// rw::version = 0x34003; // rw::version = 0x33002; - rw::platform = rw::PLATFORM_PS2; +// rw::platform = rw::PLATFORM_PS2; // rw::platform = rw::PLATFORM_OGL; // rw::platform = rw::PLATFORM_XBOX; -// rw::platform = rw::PLATFORM_D3D8; + rw::platform = rw::PLATFORM_D3D8; // rw::platform = rw::PLATFORM_D3D9; int uninstance = 0; @@ -74,6 +75,12 @@ main(int argc, char *argv[]) } */ + int32 platform = findPlatform(c); + if(platform){ + rw::platform = platform; + switchPipes(c, platform); + } + for(int32 i = 0; i < c->numAtomics; i++){ Atomic *a = c->atomicList[i]; ObjPipeline *p = a->getPipeline(); @@ -83,6 +90,11 @@ main(int argc, char *argv[]) p->instance(a); } + if(rw::version == 0){ + rw::version = header.version; + rw::build = header.build; + } + if(uninstance) rw::platform = rw::PLATFORM_D3D8;