From 4e8da870d9331175f7b2b8773feefa113f2e45aa Mon Sep 17 00:00:00 2001 From: JackCarterSmith Date: Sun, 4 Sep 2022 13:19:23 +0200 Subject: [PATCH] Reviewed material resolver --- .gitignore | 4 ++-- CMakeLists.txt | 2 +- Jenkinsfile | 2 +- RSPTextureLib/include/RSPTexture.h | 4 +--- RSPTextureLib/src/RSPTexture.c | 22 ++-------------------- RSPTextureLib/src/config.h | 6 ------ RSPTextureLib/src/hmt_parser.c | 3 ++- 7 files changed, 9 insertions(+), 34 deletions(-) delete mode 100644 RSPTextureLib/src/config.h diff --git a/.gitignore b/.gitignore index 25478cc..0f2e944 100644 --- a/.gitignore +++ b/.gitignore @@ -15,8 +15,8 @@ # Precompiled Headers *.gch *.pch -RSPTerrainLib/src/config.h -RSETerrain/src/config.h +RSPTextureLib/src/config.h +RSETexture/src/config.h # Libraries *.lib diff --git a/CMakeLists.txt b/CMakeLists.txt index cf1ceb5..152d9d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,7 @@ if(DEFINED ENV{CI}) # Jenkins CI integration mode project(rse-texture VERSION $ENV{CI_VERSION}.$ENV{CI_BUILD_NUMBER} DESCRIPTION "RogueSquadron Extractor - Texture" LANGUAGES C) set(RSE_TEXTURE_NAME $ENV{CI_OUTPUT_NAME}) else() # Standalone project mode, should not be used for release. - project(rse-texture VERSION 2.0.0 DESCRIPTION "RogueSquadron Extractor - Texture" LANGUAGES C) + project(rse-texture VERSION 2.1.0 DESCRIPTION "RogueSquadron Extractor - Texture" LANGUAGES C) set(RSE_TEXTURE_NAME RSETexture) endif() set(RSP_TEXTURE_LIB_NAME RSPTexture${PROJECT_VERSION_MAJOR}${PROJECT_VERSION_MINOR}) diff --git a/Jenkinsfile b/Jenkinsfile index 594a860..5ac09a1 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -5,7 +5,7 @@ pipeline { } environment { CI_OUTPUT_NAME = "RSETexture" - CI_VERSION = "2.0.1" + CI_VERSION = "2.1.0" CI_BUILD_NUMBER = "$BUILD_NUMBER" } stages { diff --git a/RSPTextureLib/include/RSPTexture.h b/RSPTextureLib/include/RSPTexture.h index d5150bc..f7544f4 100644 --- a/RSPTextureLib/include/RSPTexture.h +++ b/RSPTextureLib/include/RSPTexture.h @@ -97,13 +97,11 @@ RSPTEXTURE_EXTERN unsigned short RSPTexture_processHMTFileMemory( * * @param[in] pHmt HMT texture structure to be analyzed. * @param[in] mat_id ID of the material. - * @param[in] mat_type Type of the material. * * @return Pointer to T_RSPTEXTURE_MATERIAL if found or NULL otherwise. */ RSPTEXTURE_EXTERN T_RSPTEXTURE_MATERIAL* RSPTexture_getMaterialFromID( - const T_RSPTEXTURE_HMT* pHmt, const unsigned short mat_id, - const RSPTEX_MAT_TYPE mat_type + const T_RSPTEXTURE_HMT* pHmt, const unsigned short mat_id ); RSPTEXTURE_EXTERN char* RSPTexture_getMaterialName( const T_RSPTEXTURE_MATERIAL* mat ); diff --git a/RSPTextureLib/src/RSPTexture.c b/RSPTextureLib/src/RSPTexture.c index 32f7b01..f207b73 100644 --- a/RSPTextureLib/src/RSPTexture.c +++ b/RSPTextureLib/src/RSPTexture.c @@ -50,29 +50,11 @@ unsigned short RSPTexture_processHMTFileMemory( T_RSPTEXTURE_HMT* hmtStruct, con /* * Material utilities */ -T_RSPTEXTURE_MATERIAL* RSPTexture_getMaterialFromID( const T_RSPTEXTURE_HMT* pHmt, - const unsigned short mat_id, const RSPTEX_MAT_TYPE mat_type ) { - unsigned int i; - char mat_template_str[17]; - +T_RSPTEXTURE_MATERIAL* RSPTexture_getMaterialFromID( const T_RSPTEXTURE_HMT* pHmt, const unsigned short mat_id ) { if ( pHmt == NULL ) return NULL; if ( pHmt->materials == NULL ) return NULL; - if (mat_type == RSPTEX_MAT_TYPE_SOLID) { - snprintf(mat_template_str, 16, "mat_%d", mat_id); - - for ( i = 0; i < pHmt->materials_count; i++ ) { - if (strcmp((char *)pHmt->materials[i].name, mat_template_str) == 0) - return &(pHmt->materials[i]); - } - } else if (mat_type == RSPTEX_MAT_TYPE_TEXTURED) { - for ( i = 0; i < pHmt->materials_count; i++ ) { - if (pHmt->materials[i].id == mat_id && pHmt->materials[i].type == RSPTEX_MAT_TYPE_TEXTURED) - return &(pHmt->materials[i]); - } - } - - return NULL; + return &(pHmt->materials[mat_id]); } char* RSPTexture_getMaterialName( const T_RSPTEXTURE_MATERIAL* mat ) { diff --git a/RSPTextureLib/src/config.h b/RSPTextureLib/src/config.h deleted file mode 100644 index 9b62256..0000000 --- a/RSPTextureLib/src/config.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef CONFIG_H_ -#define CONFIG_H_ - -#define PRG_VERSION "2.0.0" - -#endif /* CONFIG_H_ */ diff --git a/RSPTextureLib/src/hmt_parser.c b/RSPTextureLib/src/hmt_parser.c index 5dcdcb7..21afbc2 100644 --- a/RSPTextureLib/src/hmt_parser.c +++ b/RSPTextureLib/src/hmt_parser.c @@ -170,7 +170,8 @@ static unsigned short ExtractMaterials(T_RSPTEXTURE_HMT* pHmt, const MEMFILE pMe if (pParams->verbose_mode) { printf("[INFO] > Material name: %s\n", pHmt->materials[i].name); printf("[INFO] > Material type: %d\n", pHmt->materials[i].type); - printf("[INFO] > Material text. index: %d\n", pHmt->materials[i].id); + printf("[INFO] > Material id: %d\n", pHmt->materials[i].id); + printf("[INFO] > Material text. index: %d\n", i); if (pHmt->materials[i].type == RSPTEX_MAT_TYPE_TEXTURED) printf("[INFO] > Linked texture name: %s (should correspond to material name)\n", pHmt->materials[i].texture->name); }