From 020b3a596350789fb1a8f36e9b6ec749b12ddb1f Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 22 Sep 2006 03:47:04 +0000 Subject: [PATCH] test fix for bug am44973 (knife headshots) --- dlls/csx/source/CMisc.h | 1 + dlls/csx/source/amxxmodule.cpp | 2 +- dlls/csx/source/meta_api.cpp | 48 ++++++++++++++++++++-------------- dlls/csx/source/moduleconfig.h | 2 +- dlls/csx/source/rank.h | 2 +- dlls/csx/source/usermsg.cpp | 38 +++++++++++++++++++++++++++ 6 files changed, 71 insertions(+), 22 deletions(-) diff --git a/dlls/csx/source/CMisc.h b/dlls/csx/source/CMisc.h index 5f5aaddb..6dac8ca5 100755 --- a/dlls/csx/source/CMisc.h +++ b/dlls/csx/source/CMisc.h @@ -11,6 +11,7 @@ #define CSW_HEGRENADE 4 #define CSW_C4 6 #define CSW_SMOKEGRENADE 9 +#define CSW_KNIFE 29 #define CSW_FLASHBANG 25 // ***************************************************** diff --git a/dlls/csx/source/amxxmodule.cpp b/dlls/csx/source/amxxmodule.cpp index 30ef9c79..d8c8c56c 100755 --- a/dlls/csx/source/amxxmodule.cpp +++ b/dlls/csx/source/amxxmodule.cpp @@ -2773,7 +2773,7 @@ void ValidateMacros_DontCallThis_Smiley() MF_FindLibrary(NULL, LibType_Class); MF_AddLibraries(NULL, LibType_Class, NULL); MF_RemoveLibraries(NULL); - MF_OverrideNatives(NULL); + MF_OverrideNatives(NULL, ""); } #endif diff --git a/dlls/csx/source/meta_api.cpp b/dlls/csx/source/meta_api.cpp index 5ebbe8e6..6e4a418b 100755 --- a/dlls/csx/source/meta_api.cpp +++ b/dlls/csx/source/meta_api.cpp @@ -43,7 +43,6 @@ int gmsgResetHUD; int gmsgAmmoX; int gmsgScoreInfo; int gmsgAmmoPickup; - int gmsgSendAudio; int gmsgTextMsg; int gmsgBarTime; @@ -62,26 +61,27 @@ cvar_t* csstats_pause; cvar_t init_csstats_rankbots ={"csstats_rankbots","1"}; cvar_t init_csstats_pause = {"csstats_pause","0"}; -struct sUserMsg { +struct sUserMsg +{ const char* name; int* id; funEventCall func; bool endmsg; } g_user_msg[] = { - { "CurWeapon" , &gmsgCurWeapon , Client_CurWeapon, false }, - { "Damage" , &gmsgDamage,Client_Damage, false }, - { "Damage" , &gmsgDamageEnd, Client_Damage_End, true }, - { "WeaponList" , &gmsgWeaponList, Client_WeaponList, false }, - { "ResetHUD" , &gmsgResetHUD,Client_ResetHUD, true }, - { "AmmoX" , &gmsgAmmoX, Client_AmmoX , false }, - { "ScoreInfo" , &gmsgScoreInfo, Client_ScoreInfo, false }, - { "AmmoPickup" , &gmsgAmmoPickup, Client_AmmoPickup , false }, + {"CurWeapon", &gmsgCurWeapon, Client_CurWeapon, false}, + {"Damage", &gmsgDamage, Client_Damage, false}, + {"Damage", &gmsgDamageEnd, Client_Damage_End, true}, + {"WeaponList", &gmsgWeaponList, Client_WeaponList, false}, + {"ResetHUD", &gmsgResetHUD, Client_ResetHUD, true}, + {"AmmoX", &gmsgAmmoX, Client_AmmoX, false}, + {"ScoreInfo", &gmsgScoreInfo, Client_ScoreInfo, false}, + {"AmmoPickup", &gmsgAmmoPickup, Client_AmmoPickup, false}, + {"SendAudio", &gmsgSendAudio, Client_SendAudio, false}, + {"TextMsg", &gmsgTextMsg, Client_TextMsg, false}, + {"BarTime", &gmsgBarTime, Client_BarTime, false}, + {"DeathMsg", &gmsgDeathMsg, Client_DeathMsg, false}, - { "SendAudio" , &gmsgSendAudio , Client_SendAudio , false }, - { "TextMsg" , &gmsgTextMsg , Client_TextMsg , false }, - { "BarTime" , &gmsgBarTime , Client_BarTime , false }, - - { 0 , 0,0,false } + {0, 0, 0, false} }; int RegUserMsg_Post(const char *pszName, int iSize) @@ -330,10 +330,20 @@ void EmitSound_Post(edict_t *entity, int channel, const char *sample, /*int*/flo RETURN_META(MRES_IGNORED); } -void TraceLine_Post(const float *v1, const float *v2, int fNoMonsters, edict_t *e, TraceResult *ptr) { - if (ptr->pHit&&(ptr->pHit->v.flags& (FL_CLIENT | FL_FAKECLIENT) )&& - e&&(e->v.flags& (FL_CLIENT | FL_FAKECLIENT) )&&ptr->iHitgroup) - GET_PLAYER_POINTER(e)->aiming = ptr->iHitgroup; +void TraceLine_Post(const float *v1, const float *v2, int fNoMonsters, edict_t *e, TraceResult *ptr) +{ + if (ptr->pHit && (ptr->pHit->v.flags & (FL_CLIENT|FL_FAKECLIENT)) + && e + && (e->v.flags & (FL_CLIENT|FL_FAKECLIENT)) + && ptr->iHitgroup) + { + CPlayer *pPlayer = GET_PLAYER_POINTER(e); + if (pPlayer->current != CSW_KNIFE) + { + pPlayer->aiming = ptr->iHitgroup; + } + } + RETURN_META(MRES_IGNORED); } diff --git a/dlls/csx/source/moduleconfig.h b/dlls/csx/source/moduleconfig.h index 0b5a2cbe..bba5b283 100755 --- a/dlls/csx/source/moduleconfig.h +++ b/dlls/csx/source/moduleconfig.h @@ -367,7 +367,7 @@ #define FN_TraceLine_Post TraceLine_Post // #define FN_TraceToss_Post TraceToss_Post // #define FN_TraceMonsterHull_Post TraceMonsterHull_Post -// #define FN_TraceHull_Post TraceHull_Post +// #define FN_TraceHull_Post TraceHull_Post // #define FN_TraceModel_Post TraceModel_Post // #define FN_TraceTexture_Post TraceTexture_Post // #define FN_TraceSphere_Post TraceSphere_Post diff --git a/dlls/csx/source/rank.h b/dlls/csx/source/rank.h index 62db6cf5..c9e4c1bc 100755 --- a/dlls/csx/source/rank.h +++ b/dlls/csx/source/rank.h @@ -88,10 +88,10 @@ void Client_AmmoPickup(void*); void Client_Damage_End(void*); void Client_ScoreInfo(void*); void Client_ResetHUD(void*); - void Client_SendAudio(void*); void Client_TextMsg(void*); void Client_BarTime(void*); +void Client_DeathMsg(void*); bool ignoreBots (edict_t *pEnt, edict_t *pOther = NULL ); bool isModuleActive(); diff --git a/dlls/csx/source/usermsg.cpp b/dlls/csx/source/usermsg.cpp index d05b0075..1e9f821c 100755 --- a/dlls/csx/source/usermsg.cpp +++ b/dlls/csx/source/usermsg.cpp @@ -17,6 +17,44 @@ void Client_ResetHUD(void* mValue){ } } +void Client_DeathMsg(void *mValue) +{ + static int killer_id; + static int victim_id; + static int is_headshot; + const char *name; + + switch (mState++) + { + case 0: + { + killer_id = *(int *)mValue; + break; + } + case 1: + { + victim_id = *(int *)mValue; + break; + } + case 2: + { + is_headshot = *(int *)mValue; + break; + } + case 3: + { + name = (const char *)mValue; + if (killer_id + && (strcmp(name, "knife") == 0)) + { + CPlayer *pPlayer = GET_PLAYER_POINTER_I(killer_id); + pPlayer->aiming = is_headshot ? 1 : 0; + } + break; + } + } +} + void Client_WeaponList(void* mValue){ static int wpnList; static int iSlot;