From 8999fcc3a765d266cab7c2b120421509e9173ae4 Mon Sep 17 00:00:00 2001 From: mattn Date: Tue, 4 Mar 2008 17:33:05 +0000 Subject: [PATCH 1/1] * improved quake2 support by added a quake2 boolean to the CGameDescription class - this allows us to even use the quake2 surfaceplugin function (like e.g. SetFaceTexdef_Q2) without a hardcoded game name of q2.game or heretic2.game * added support for relative md2 skin paths * fixed wrong _pico_printf call git-svn-id: svn://svn.icculus.org/gtkradiant/GtkRadiant/branches/ZeroRadiant@203 8a3a26a2-13c4-0310-b231-cf6edde360e5 --- libs/picomodel/pm_md2.c | 24 +++++++++++++++++++++--- radiant/preferences.cpp | 12 ++++++++++++ radiant/preferences.h | 1 + radiant/surfaceplugin.cpp | 2 +- 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/libs/picomodel/pm_md2.c b/libs/picomodel/pm_md2.c index 8a603a5d..b0ff40ca 100644 --- a/libs/picomodel/pm_md2.c +++ b/libs/picomodel/pm_md2.c @@ -337,9 +337,10 @@ static picoModel_t *_md2_load( PM_PARAMS_LOAD ) index_DUP_LUT_t *p_index_LUT_DUPS; md2Triangle_t *p_md2Triangle; + char path[ MD2_MAX_SKINNAME ]; char skinname[ MD2_MAX_SKINNAME ]; - md2_t *md2; - md2St_t *texCoord; + md2_t *md2; + md2St_t *texCoord; md2Frame_t *frame; md2Triangle_t *triangle; md2XyzNormal_t *vertex; @@ -435,8 +436,25 @@ static picoModel_t *_md2_load( PM_PARAMS_LOAD ) strncpy(skinname, (bb + md2->ofsSkins), MD2_MAX_SKINNAME ); // Print out md2 values - _pico_printf(PICO_VERBOSE,"Skins: %d Verts: %d STs: %d Triangles: %d Frames: %d\nSkin Name \"%s\"\n", md2->numSkins, md2->numXYZ, md2->numST, md2->numTris, md2->numFrames, &skinname ); + _pico_printf(PICO_VERBOSE,"Skins: %d Verts: %d STs: %d Triangles: %d Frames: %d\nSkin Name \"%s\"\n", md2->numSkins, md2->numXYZ, md2->numST, md2->numTris, md2->numFrames, skinname ); + + // relative texture path - allows moving of models in game dir structure without changing the skinpath + // e.g. used in ufo:ai + if (skinname[0] == '.') { + strncpy(path, fileName, MD2_MAX_SKINNAME); + for (i = MD2_MAX_SKINNAME; i--;) { + // skip filename + if (path[i] == '/' || path[i] == '\\') + break; + path[i] = '\0'; + } + strncat(path, &skinname[1], MD2_MAX_SKINNAME); + strncpy(skinname, path, MD2_MAX_SKINNAME); + // Print out md2 values + _pico_printf(PICO_VERBOSE,"Relative skin path converted to: \"%s\" (%s)\n", skinname, fileName ); + } + // detox Skin name _pico_setfext( skinname, "" ); _pico_unixify( skinname ); diff --git a/radiant/preferences.cpp b/radiant/preferences.cpp index 3090695e..88fb4fe4 100644 --- a/radiant/preferences.cpp +++ b/radiant/preferences.cpp @@ -746,6 +746,18 @@ CGameDescription::CGameDescription(xmlDocPtr pDoc, const Str &GameFile) mGameFile = GameFile; + prop = (char*)xmlGetProp(pNode, (xmlChar*)"quake2"); + if (prop == NULL) + { + // default + quake2 = false; + } + else + { + quake2 = true; + xmlFree(prop); + } + prop = (char*)xmlGetProp(pNode, (xmlChar*)"basegame"); if (prop == NULL) { diff --git a/radiant/preferences.h b/radiant/preferences.h index dfc1be5c..79df8700 100644 --- a/radiant/preferences.h +++ b/radiant/preferences.h @@ -180,6 +180,7 @@ public: bool mEClassSingleLoad; ///< only load a single eclass definition file bool mNoPatch; ///< this game doesn't support patch technology Str mCaulkShader; ///< the shader to use for caulking + bool quake2; ///< set this to true to get quake2 CGameDescription() { mpDoc = NULL; } /*! diff --git a/radiant/surfaceplugin.cpp b/radiant/surfaceplugin.cpp index 3a1ef306..320ee86c 100644 --- a/radiant/surfaceplugin.cpp +++ b/radiant/surfaceplugin.cpp @@ -168,7 +168,7 @@ void SI_SetTexdef_FaceList(texdef_to_face_t* texdef_face_list, bool b_SetUndoPoi texdef_to_face_t* texdef_to_face; bool b_isQuake2; - if ( ( g_pGameDescription->mGameFile == "q2.game" ) || ( g_pGameDescription->mGameFile == "heretic2.game" ) ) + if ( ( g_pGameDescription->quake2 ) || ( g_pGameDescription->mGameFile == "q2.game" ) || ( g_pGameDescription->mGameFile == "heretic2.game" ) ) b_isQuake2 = true; else b_isQuake2 = false; -- 2.39.2