From 8316318c31a870e60a986705d3bb90e0a3c9d9dd Mon Sep 17 00:00:00 2001 From: Steve Dudenhoeffer Date: Tue, 17 Jul 2007 02:18:04 +0000 Subject: [PATCH] Fix for amb343 - tfc_clearmodel didn't function as advertised. --- dlls/tfcx/CMisc.h | 6 ++++++ dlls/tfcx/NBase.cpp | 27 ++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/dlls/tfcx/CMisc.h b/dlls/tfcx/CMisc.h index 1f95792a..27611556 100755 --- a/dlls/tfcx/CMisc.h +++ b/dlls/tfcx/CMisc.h @@ -22,6 +22,12 @@ #define PD_SENTRY_OWNER 83 + LINUXOFFSET #define PD_TIMER_OWNER 932 + LINUXOFFSET +// If somehow TFC updates, the following two offsets can be updated by +// disassembling CBaseEntity::KeyValuePartThree(KeyValueData_s *) +#define PD_REPLACE_MODEL 170 + LINUXOFFSET +#define PD_REPLACE_SKIN 172 + LINUXOFFSET + + #define MAX_TRACE 13 //#define NADE_OFFSET 24 diff --git a/dlls/tfcx/NBase.cpp b/dlls/tfcx/NBase.cpp index bfcdb585..786f3d2e 100755 --- a/dlls/tfcx/NBase.cpp +++ b/dlls/tfcx/NBase.cpp @@ -80,7 +80,31 @@ static cell AMX_NATIVE_CALL TFC_ClearModel(AMX *amx, cell *params) { CHECK_PLAYER(iIndex) edict_t* pPlayer = INDEXENT(iIndex); + + if (pPlayer->pvPrivateData == NULL) + { + MF_LogError(amx, AMX_ERR_NATIVE, "Player has no private data, cannot clear model!"); + return 0; + } + // PD_REPLACE_MODEL is the string_t for the replacement model + // setting it to 0 will reset the model properly + *( (int*)pPlayer->pvPrivateData + PD_REPLACE_MODEL) = 0; + + // PD_REPLACE_SKIN is the integer setting for the skin, by default + // it is 0. + *( (int*)pPlayer->pvPrivateData + PD_REPLACE_SKIN) = 0; + + return 1; + + /* + // the old, buggy method here + int iIndex = params[1]; + + CHECK_PLAYER(iIndex) + + edict_t* pPlayer = INDEXENT(iIndex); + char szModel[32]; memset(szModel, 0x0, strlen(szModel)); @@ -135,8 +159,9 @@ static cell AMX_NATIVE_CALL TFC_ClearModel(AMX *amx, cell *params) { (gpGamedllFuncs->dllapi_table->pfnKeyValue)(pPlayer, &pkvd2); (g_engfuncs.pfnSetClientKeyValue)(iIndex, (g_engfuncs.pfnGetInfoKeyBuffer)(pPlayer), "model", szModel); - + return 1; + */ } // Vexd end :)