Reversed functions: CBasePlayer::PickPrimaryCareerTaskWeapon, CBasePlayer::PickSecondaryCareerTaskWeapon.
Added comments to some parts of the code.
Fixed some bugs in CZ:Career.
This commit is contained in:
s1lentq 2015-11-06 20:58:48 +06:00
parent ed1dd85d6e
commit 0fc3351cb8
25 changed files with 1095 additions and 953 deletions

View File

@ -67,15 +67,14 @@ typedef union DLONG_u
#define M_PI 3.14159265358979323846
#define clamp(val, x, y) (((val) > (y)) ? (y) : (((val) < (x)) ? (x) : (val)))
template <typename T>
T Q_min(T a, T b) { return (a < b) ? a : b; }
#ifndef Q_max
#define Q_max(a,b) ((a) > (b) ? (a) : (b)) // std::max(a, b)
#endif // Q_max
template <typename T>
T Q_max(T a, T b) { return (a > b) ? a : b; }
#ifndef Q_min
#define Q_min(a,b) ((a) < (b) ? (a) : (b)) // std::min(a, b)
#endif // Q_min
template <typename T>
T clamp(T a, T min, T max) { return (a > max) ? max : (a < min) ? min : a; }
#define VectorSubtract(a,b,c) {(c)[0]=(a)[0]-(b)[0];(c)[1]=(a)[1]-(b)[1];(c)[2]=(a)[2]-(b)[2];}
#define VectorAdd(a,b,c) {(c)[0]=(a)[0]+(b)[0];(c)[1]=(a)[1]+(b)[1];(c)[2]=(a)[2]+(b)[2];}

View File

@ -370,7 +370,7 @@ void CCSBotManager::__MAKE_VHOOK(ServerCommand)(const char *pcmd)
for (int iIndex = 1; iIndex <= gpGlobals->maxClients; iIndex++)
{
CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex(iIndex);
CBasePlayer *pPlayer = reinterpret_cast<CBasePlayer *>(UTIL_PlayerByIndex(iIndex));
if (pPlayer == NULL)
continue;
@ -402,7 +402,7 @@ void CCSBotManager::__MAKE_VHOOK(ServerCommand)(const char *pcmd)
for (int iIndex = 1; iIndex <= gpGlobals->maxClients; iIndex++)
{
CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex(iIndex);
CBasePlayer *pPlayer = reinterpret_cast<CBasePlayer *>(UTIL_PlayerByIndex(iIndex));
if (pPlayer == NULL)
continue;

View File

@ -414,11 +414,11 @@ void CCareerTask::__MAKE_VHOOK(OnEvent)(GameEventType event, CBasePlayer *pVicti
if (m_event == EVENT_ROUND_WIN && !Q_strcmp(m_name, "winfast"))
{
TheCareerTasks->SetFinishedTaskTime((signed __int64)(TheCareerTasks->GetRoundElapsedTime()));
TheCareerTasks->SetFinishedTaskTime((int)TheCareerTasks->GetRoundElapsedTime());
UTIL_GetLocalPlayer()->SyncRoundTimer();
}
if (TheTutor)
if (TheTutor != NULL)
{
TheTutor->OnEvent(EVENT_CAREER_TASK_DONE);
}
@ -614,7 +614,7 @@ void CCareerTaskManager::HandleDeath(int team, CBasePlayer *pAttacker)
for (int i = 1; i <= gpGlobals->maxClients; i++)
{
CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex(i);
CBasePlayer *pPlayer = reinterpret_cast<CBasePlayer *>(UTIL_PlayerByIndex(i));
if (pPlayer && pPlayer->m_iTeam == enemyTeam && pPlayer->IsAlive())
++numEnemies;

View File

@ -687,7 +687,6 @@ int DispatchRestore(edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity)
return 0;
}
}
if (pEntity->ObjectCaps() & FCAP_MUST_SPAWN)

View File

@ -3601,7 +3601,7 @@ void ClientCommand(edict_t *pEntity)
for (int i = 1; i <= gpGlobals->maxClients; i++)
{
CBasePlayer *pObserver = (CBasePlayer *)UTIL_PlayerByIndex(i);
CBasePlayer *pObserver = reinterpret_cast<CBasePlayer *>(UTIL_PlayerByIndex(i));
if (pObserver && pObserver->IsObservingPlayer(player))
{
@ -3627,7 +3627,7 @@ void ClientCommand(edict_t *pEntity)
for (int i = 1; i <= gpGlobals->maxClients; i++)
{
CBasePlayer *pObserver = (CBasePlayer *)UTIL_PlayerByIndex(i);
CBasePlayer *pObserver = reinterpret_cast<CBasePlayer *>(UTIL_PlayerByIndex(i));
if (pObserver && pObserver->IsObservingPlayer(player))
{
@ -3664,7 +3664,7 @@ void ClientCommand(edict_t *pEntity)
// player is dropping an item.
if (player->HasShield())
{
if (player->m_pActiveItem && player->m_pActiveItem->m_iId == WEAPON_C4)
if (player->m_pActiveItem != NULL && player->m_pActiveItem->m_iId == WEAPON_C4)
{
player->DropPlayerItem("weapon_c4");
}

View File

@ -1053,7 +1053,7 @@ void RadiusFlash(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker,
for (int i = 1; i <= gpGlobals->maxClients; i++)
{
CBasePlayer *pObserver = (CBasePlayer *)UTIL_PlayerByIndex(i);
CBasePlayer *pObserver = reinterpret_cast<CBasePlayer *>(UTIL_PlayerByIndex(i));
if (!pObserver || !pObserver->IsObservingPlayer(pPlayer))
continue;

View File

@ -40,8 +40,13 @@ edict_t *CGameRules::__MAKE_VHOOK(GetPlayerSpawnSpot)(CBasePlayer *pPlayer)
{
edict_t *pentSpawnSpot = EntSelectSpawnPoint(pPlayer);
pPlayer->pev->origin = VARS(pentSpawnSpot)->origin;// + Vector(0, 0, 1);
#if HOOK_GAMEDLL
// TODO: fix test demo
pPlayer->pev->origin = VARS(pentSpawnSpot)->origin;
pPlayer->pev->origin.z += 1;
#else
pPlayer->pev->origin = VARS(pentSpawnSpot)->origin + Vector(0, 0, 1);
#endif // HOOK_GAMEDLL
pPlayer->pev->v_angle = g_vecZero;
pPlayer->pev->velocity = g_vecZero;

View File

@ -23,7 +23,7 @@ bool IsBotSpeaking(void)
{
for (int i = 1; i <= gpGlobals->maxClients; i++)
{
CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex(i);
CBasePlayer *pPlayer = reinterpret_cast<CBasePlayer *>(UTIL_PlayerByIndex(i));
if (pPlayer == NULL || !pPlayer->IsBot())
continue;
@ -53,7 +53,7 @@ void SV_Continue_f(void)
for (int i = 1; i <= gpGlobals->maxClients; i++)
{
CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex(i);
CBasePlayer *pPlayer = reinterpret_cast<CBasePlayer *>(UTIL_PlayerByIndex(i));
if (pPlayer && !pPlayer->IsBot())
{
@ -101,7 +101,7 @@ void SV_Career_EndRound_f(void)
for (int i = 1; i <= gpGlobals->maxClients; i++)
{
CBasePlayer *player = (CBasePlayer *)UTIL_PlayerByIndex(i);
CBasePlayer *player = reinterpret_cast<CBasePlayer *>(UTIL_PlayerByIndex(i));
if (!player || FNullEnt(player->pev))
continue;
@ -784,7 +784,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(GiveC4)(void)
{
for (int i = 1; i <= gpGlobals->maxClients; i++)
{
CBasePlayer *player = (CBasePlayer *)UTIL_PlayerByIndex(i);
CBasePlayer *player = reinterpret_cast<CBasePlayer *>(UTIL_PlayerByIndex(i));
if (!player || FNullEnt(player->edict()))
continue;
@ -846,7 +846,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(GiveC4)(void)
GETPLAYERAUTHID(player->edict())
);
g_pGameRules->m_bBombDropped = FALSE;
m_bBombDropped = FALSE;
}
}
@ -889,7 +889,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(GiveC4)(void)
GETPLAYERAUTHID(player->edict())
);
g_pGameRules->m_bBombDropped = FALSE;
m_bBombDropped = FALSE;
return;
}
}
@ -992,8 +992,13 @@ void CHalfLifeMultiplay::QueueCareerRoundEndMenu(float tmDelay, int iWinStatus)
if (m_iNumTerroristWins < m_iCareerMatchWins || (m_iNumTerroristWins - m_iNumCTWins < m_iRoundWinDifference))
canTsWin = false;
if (!TheCareerTasks->AreAllTasksComplete() && !humansAreCTs)
if (!TheCareerTasks->AreAllTasksComplete())
{
if (humansAreCTs)
return;
canTsWin = false;
}
if (canCTsWin || canTsWin)
{
@ -1138,7 +1143,7 @@ bool CHalfLifeMultiplay::NeededPlayersCheck(bool &bNeededPlayers)
{
if (IsCareer())
{
CBasePlayer *player = (CBasePlayer *)UTIL_PlayerByIndex(gpGlobals->maxClients);
CBasePlayer *player = reinterpret_cast<CBasePlayer *>(UTIL_PlayerByIndex(gpGlobals->maxClients));
if (!player || !player->IsBot())
{
@ -1666,7 +1671,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(RestartRound)(void)
// tell bots that the round is restarting
TheBots->RestartRound();
if (g_pHostages)
if (g_pHostages != NULL)
{
g_pHostages->RestartRound();
}
@ -1693,7 +1698,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(RestartRound)(void)
MESSAGE_END();
}
g_pGameRules->m_bBombDropped = FALSE;
m_bBombDropped = FALSE;
// reset all players health for HLTV
MESSAGE_BEGIN(MSG_SPEC, gmsgHLTV);
@ -1769,7 +1774,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(RestartRound)(void)
// Reset the player stats
for (int i = 1; i <= gpGlobals->maxClients; i++)
{
CBasePlayer *plr = (CBasePlayer *)UTIL_PlayerByIndex(i);
CBasePlayer *plr = reinterpret_cast<CBasePlayer *>(UTIL_PlayerByIndex(i));
if (plr && !FNullEnt(plr->pev))
plr->Reset();
@ -1837,8 +1842,8 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(RestartRound)(void)
if (m_bMapHasEscapeZone)
{
m_iHaveEscaped = 0;
m_iNumEscapers = 0; // Will increase this later when we count how many Ts are starting
// Will increase this later when we count how many Ts are starting
m_iNumEscapers = m_iHaveEscaped = 0;
if (m_iNumEscapeRounds >= 3)
{
@ -2564,11 +2569,8 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(Think)(void)
}
else
{
if (m_fCareerMatchMenuTime + 10 > gpGlobals->time && !IsBotSpeaking())
if (m_fCareerMatchMenuTime + 10 <= gpGlobals->time || !IsBotSpeaking())
{
return;
}
UTIL_CareerDPrintf("Ending career match...one team has won the specified number of rounds\n");
MESSAGE_BEGIN(MSG_ALL, gmsgCZCareer);
@ -2598,6 +2600,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(Think)(void)
SERVER_COMMAND("setpause\n");
}
}
}
bool CHalfLifeMultiplay::CheckGameOver(void)
{
@ -2911,27 +2914,21 @@ void CHalfLifeMultiplay::CheckRestartRound(void)
if (iRestartDelay > 60)
iRestartDelay = 60;
CHalfLifeMultiplay *mp = g_pGameRules;
// log the restart
UTIL_LogPrintf("World triggered \"Restart_Round_(%i_%s)\"\n", iRestartDelay, (iRestartDelay == 1) ? "second" : "seconds");
if (mp != NULL)
{
UTIL_LogPrintf
(
"Team \"CT\" scored \"%i\" with \"%i\" players\n",
mp->m_iNumCTWins,
mp->m_iNumCT
m_iNumCTWins,
m_iNumCT
);
UTIL_LogPrintf
(
"Team \"TERRORIST\" scored \"%i\" with \"%i\" players\n",
mp->m_iNumTerroristWins,
mp->m_iNumTerrorist
m_iNumTerroristWins,
m_iNumTerrorist
);
}
// let the players know
UTIL_ClientPrintAll(HUD_PRINTCENTER, "#Game_will_restart_in", UTIL_dtos1(iRestartDelay), (iRestartDelay == 1) ? "SECOND" : "SECONDS");
@ -3295,7 +3292,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(InitHUD)(CBasePlayer *pl)
}
}
if (g_pGameRules->m_bBombDropped)
if (m_bBombDropped)
{
CBaseEntity *pWeaponC4 = UTIL_FindEntityByClassname(NULL, "weapon_c4");
@ -4111,13 +4108,8 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(GoToIntermission)(void)
if (g_fGameOver)
return;
CHalfLifeMultiplay *mp = g_pGameRules;
if (mp != NULL)
{
UTIL_LogPrintf("Team \"CT\" scored \"%i\" with \"%i\" players\n", mp->m_iNumCTWins, mp->m_iNumCT);
UTIL_LogPrintf("Team \"TERRORIST\" scored \"%i\" with \"%i\" players\n", mp->m_iNumTerroristWins, mp->m_iNumTerrorist);
}
UTIL_LogPrintf("Team \"CT\" scored \"%i\" with \"%i\" players\n", m_iNumCTWins, m_iNumCT);
UTIL_LogPrintf("Team \"TERRORIST\" scored \"%i\" with \"%i\" players\n", m_iNumTerroristWins, m_iNumTerrorist);
if (IsCareer())
{

View File

@ -1,7 +1,7 @@
#include "precompiled.h"
/* <11c190> ../cstrike/dlls/observer.cpp:36 */
NOXREF int GetForceCamera(void)
int GetForceCamera(void)
{
int retVal;
@ -49,7 +49,7 @@ void UpdateClientEffects(CBasePlayer *pObserver, int oldMode)
if (pObserver->m_hObserverTarget->IsPlayer())
{
CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex(ENTINDEX(pObserver->m_hObserverTarget->edict()));
CBasePlayer *pPlayer = reinterpret_cast<CBasePlayer *>(UTIL_PlayerByIndex(ENTINDEX(pObserver->m_hObserverTarget->edict())));
if (pPlayer)
{
@ -167,7 +167,7 @@ void CBasePlayer::Observer_FindNextPlayer(bool bReverse, const char *name)
if (!name)
break;
pPlayer = (CBasePlayer *)UTIL_PlayerByIndex(ENTINDEX(m_hObserverTarget->edict()));
pPlayer = reinterpret_cast<CBasePlayer *>(UTIL_PlayerByIndex(ENTINDEX(m_hObserverTarget->edict())));
if (!Q_strcmp(name, STRING(pPlayer->pev->netname)))
break;
@ -273,7 +273,7 @@ void CBasePlayer::Observer_CheckTarget(void)
if (m_hObserverTarget)
{
int iPlayerIndex = ENTINDEX(m_hObserverTarget->edict());
CBasePlayer *target = (CBasePlayer *)UTIL_PlayerByIndex(iPlayerIndex);
CBasePlayer *target = reinterpret_cast<CBasePlayer *>(UTIL_PlayerByIndex(iPlayerIndex));
// check taget
if (!target || target->pev->deadflag == DEAD_RESPAWNABLE || (target->pev->effects & EF_NODRAW))
@ -310,7 +310,7 @@ void CBasePlayer::Observer_CheckProperties(void)
// try to find a traget if we have no current one
if (pev->iuser1 == OBS_IN_EYE && m_hObserverTarget != NULL)
{
CBasePlayer *target = (CBasePlayer *)UTIL_PlayerByIndex(ENTINDEX(m_hObserverTarget->edict()));
CBasePlayer *target = reinterpret_cast<CBasePlayer *>(UTIL_PlayerByIndex(ENTINDEX(m_hObserverTarget->edict())));
if (!target)
return;

View File

@ -36,7 +36,7 @@
#define CAMERA_MODE_SPEC_ONLY_TEAM 1
#define CAMERA_MODE_SPEC_ONLY_FRIST_PERSON 2
NOXREF int GetForceCamera(void);
int GetForceCamera(void);
void UpdateClientEffects(CBasePlayer *pObserver, int oldMode);
#endif // OBSERVER_H

View File

@ -1249,8 +1249,6 @@ void CFuncTrackTrain::Next(void)
if (m_flBank != 0)
{
double dbl_v33 = m_flBank;
if (pev->avelocity.y < -5)
{
pev->avelocity.z = UTIL_AngleDistance(UTIL_ApproachAngle(-m_flBank, pev->angles.z, m_flBank * 2), pev->angles.z);

File diff suppressed because it is too large Load Diff

View File

@ -128,8 +128,8 @@
#define AUTOAIM_8DEGREES 0.1391731009601
#define AUTOAIM_10DEGREES 0.1736481776669
//#define SOUND_FLASHLIGHT_ON "items/flashlight1.wav"
//#define SOUND_FLASHLIGHT_OFF "items/flashlight1.wav"
#define SOUND_FLASHLIGHT_ON "items/flashlight1.wav"
#define SOUND_FLASHLIGHT_OFF "items/flashlight1.wav"
typedef enum
{
@ -740,6 +740,7 @@ public:
void DropShield(bool bDeploy = true);
void GiveShield(bool bDeploy = true);
bool IsHittingShield(Vector &vecDirection, TraceResult *ptr);
bool SelectSpawnSpot(const char *pEntClassName, CBaseEntity* &pSpot);
bool IsReloading(void)
{
if (m_pActiveItem && ((CBasePlayerWeapon *)m_pActiveItem)->m_fInReload)
@ -768,8 +769,8 @@ public:
void AutoBuy(void);
void ClientCommand(const char *cmd, const char *arg1 = NULL, const char *arg2 = NULL, const char *arg3 = NULL);
void PrioritizeAutoBuyString(char *autobuyString, const char *priorityString);
NOBODY const char *PickPrimaryCareerTaskWeapon(void);
NOBODY const char *PickSecondaryCareerTaskWeapon(void);
const char *PickPrimaryCareerTaskWeapon(void);
const char *PickSecondaryCareerTaskWeapon(void);
const char *PickFlashKillWeaponString(void);
const char *PickGrenadeKillWeaponString(void);
bool ShouldExecuteAutoBuyCommand(AutoBuyInfoStruct *commandInfo, bool boughtPrimary, bool boughtSecondary);
@ -1185,8 +1186,4 @@ bool IsSecondaryWeaponId(int id);
const char *GetWeaponAliasFromName(const char *weaponName);
bool CurrentWeaponSatisfies(CBasePlayerWeapon *pWeapon, int id, int classId);
// refs
extern void (*pCBasePlayer__PickPrimaryCareerTaskWeapon)(void);
extern void (*pCBasePlayer__PickSecondaryCareerTaskWeapon)(void);
#endif // PLAYER_H

View File

@ -52,7 +52,7 @@ void CHalfLifeTraining::__MAKE_VHOOK(InitHUD)(CBasePlayer *pl)
/* <18bcff> ../cstrike/dlls/training_gamerules.cpp:29 */
void CHalfLifeTraining::HostageDied(void)
{
CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex(1);
CBasePlayer *pPlayer = reinterpret_cast<CBasePlayer *>(UTIL_PlayerByIndex(1));
if (pPlayer)
{

View File

@ -1889,7 +1889,7 @@ void CEscapeZone::EscapeTouch(CBaseEntity *pOther)
for (int i = 1; i <= gpGlobals->maxClients; i++)
{
CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex(i);
CBasePlayer *pPlayer = reinterpret_cast<CBasePlayer *>(UTIL_PlayerByIndex(i));
if (pPlayer == NULL || FNullEnt(pPlayer->pev))
continue;

View File

@ -574,9 +574,10 @@ CBaseEntity *UTIL_PlayerByIndex(int playerIndex)
if (playerIndex > 0 && playerIndex <= gpGlobals->maxClients)
{
edict_t *pPlayerEdict = INDEXENT(playerIndex);
if (pPlayerEdict && !pPlayerEdict->free)
if (pPlayerEdict != NULL && !pPlayerEdict->free)
pPlayer = CBaseEntity::Instance(pPlayerEdict);
}
return pPlayer;
}
@ -2430,7 +2431,7 @@ char UTIL_TextureHit(TraceResult *ptr, Vector vecSrc, Vector vecEnd)
/* <1b5330> ../cstrike/dlls/util.cpp:2767 */
NOXREF int GetPlayerTeam(int index)
{
CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex(index);
CBasePlayer *pPlayer = reinterpret_cast<CBasePlayer *>(UTIL_PlayerByIndex(index));
if (pPlayer != NULL)
{
return pPlayer->m_iTeam;
@ -2455,7 +2456,7 @@ bool UTIL_IsGame(const char *gameName)
/* <1b5470> ../cstrike/dlls/util.cpp:2802 */
float_precision UTIL_GetPlayerGaitYaw(int playerIndex)
{
CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex(playerIndex);
CBasePlayer *pPlayer = reinterpret_cast<CBasePlayer *>(UTIL_PlayerByIndex(playerIndex));
if (pPlayer != NULL)
{
return pPlayer->m_flGaityaw;

View File

@ -49,14 +49,14 @@ const char *g_pModelNameLaser;
#endif // HOOK_GAMEDLL
short g_sModelIndexLaser;
short g_sModelIndexLaserDot;
short g_sModelIndexFireball;
short g_sModelIndexSmoke;
short g_sModelIndexWExplosion;
short g_sModelIndexBubbles;
short g_sModelIndexBloodDrop;
short g_sModelIndexBloodSpray;
short g_sModelIndexLaser; // holds the index for the laser beam
short g_sModelIndexLaserDot; // holds the index for the laser beam dot
short g_sModelIndexFireball; // holds the index for the fireball
short g_sModelIndexSmoke; // holds the index for the smoke cloud
short g_sModelIndexWExplosion; // holds the index for the underwater explosion
short g_sModelIndexBubbles; // holds the index for the bubbles model
short g_sModelIndexBloodDrop; // holds the sprite index for the initial blood
short g_sModelIndexBloodSpray; // holds the sprite index for splattered blood
short g_sModelIndexSmokePuff;
short g_sModelIndexFireball2;
short g_sModelIndexFireball3;

View File

@ -229,7 +229,7 @@ WeaponInfoStruct weaponInfo[27];
/* <22cd2a> ../cstrike/dlls/weapontype.cpp:208 */
WeaponIdType AliasToWeaponID(const char *alias)
{
if (alias)
if (alias != NULL)
{
for (int i = 0; weaponAliasInfo[i].alias != NULL; i++)
{
@ -275,7 +275,7 @@ const char *WeaponIDToAlias(int id)
/* <22cdfe> ../cstrike/dlls/weapontype.cpp:259 */
WeaponClassType AliasToWeaponClass(const char *alias)
{
if (alias)
if (alias != NULL)
{
for (int i = 0; weaponClassAliasInfo[i].alias != NULL; i++)
{

View File

@ -142,12 +142,14 @@ NOXREF void CKnife::WeaponAnimation(int iAnimation)
void FindHullIntersection(Vector &vecSrc, TraceResult &tr, float *mins, float *maxs, edict_t *pEntity)
{
int i, j, k;
float distance = 1000000.0;
float distance;
float *minmaxs[2] = { mins, maxs };
TraceResult tmpTrace;
Vector vecHullEnd, vecEnd;
vecHullEnd = ((tr.vecEndPos - vecSrc) * 2) + vecSrc;
distance = 1e6f;
vecHullEnd = vecSrc + ((tr.vecEndPos - vecSrc) * 2);
UTIL_TraceLine(vecSrc, vecHullEnd, dont_ignore_monsters, pEntity, &tmpTrace);
if (tmpTrace.flFraction < 1.0f)
@ -286,16 +288,16 @@ void CKnife::__MAKE_VHOOK(WeaponIdle)(void)
m_pPlayer->GetAutoaimVector(AUTOAIM_10DEGREES);
if (m_flTimeWeaponIdle > UTIL_WeaponTimeBase())
{
return;
}
if (!m_pPlayer->m_bShieldDrawn)
{
if (m_pPlayer->m_bShieldDrawn)
return;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 20.0;
// only idle if the slid isn't back
SendWeaponAnim(KNIFE_IDLE, UseDecrement() != FALSE);
}
}
/* <270fa7> ../cstrike/dlls/wpn_shared/wpn_knife.cpp:283 */
int CKnife::Swing(int fFirst)
@ -317,6 +319,8 @@ int CKnife::Swing(int fFirst)
if (tr.flFraction < 1.0f)
{
// Calculate the point of intersection of the line (or hull) and the object we hit
// This is and approximation of the "best" intersection
CBaseEntity *pHit = CBaseEntity::Instance(tr.pHit);
if (!pHit || pHit->IsBSPModel())
@ -324,6 +328,7 @@ int CKnife::Swing(int fFirst)
FindHullIntersection(vecSrc, tr, VEC_DUCK_HULL_MIN, VEC_DUCK_HULL_MAX, m_pPlayer->edict());
}
// This is the point on the actual surface (the hull could have hit space)
vecEnd = tr.vecEndPos;
}
}
@ -334,12 +339,13 @@ int CKnife::Swing(int fFirst)
{
if (!m_pPlayer->HasShield())
{
switch (m_iSwing++ % 2)
switch ((m_iSwing++) % 2)
{
case 0: SendWeaponAnim(KNIFE_MIDATTACK1HIT, UseDecrement() != FALSE); break;
case 1: SendWeaponAnim(KNIFE_MIDATTACK2HIT, UseDecrement() != FALSE); break;
}
// miss
m_flNextPrimaryAttack = GetNextAttackDelay(0.35);
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5;
}
@ -353,21 +359,24 @@ int CKnife::Swing(int fFirst)
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0;
// play wiff or swish sound
if (RANDOM_LONG(0, 1))
EMIT_SOUND_DYN(m_pPlayer->edict(), CHAN_WEAPON, "weapons/knife_slash1.wav", VOL_NORM, ATTN_NORM, 0, 94);
else
EMIT_SOUND_DYN(m_pPlayer->edict(), CHAN_WEAPON, "weapons/knife_slash2.wav", VOL_NORM, ATTN_NORM, 0, 94);
// player "shoot" animation
m_pPlayer->SetAnimation(PLAYER_ATTACK1);
}
}
else
{
// hit
fDidHit = TRUE;
if (!m_pPlayer->HasShield())
{
switch (m_iSwing++ % 2)
switch ((m_iSwing++) % 2)
{
case 0: SendWeaponAnim(KNIFE_MIDATTACK1HIT, UseDecrement() != FALSE); break;
case 1: SendWeaponAnim(KNIFE_MIDATTACK2HIT, UseDecrement() != FALSE); break;
@ -386,9 +395,14 @@ int CKnife::Swing(int fFirst)
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0;
// play thwack, smack, or dong sound
float flVol = 1.0f;
int fHitWorld = TRUE;
CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit);
SetPlayerShieldAnim();
// player "shoot" animation
m_pPlayer->SetAnimation(PLAYER_ATTACK1);
ClearMultiDamage();
@ -399,11 +413,11 @@ int CKnife::Swing(int fFirst)
ApplyMultiDamage(m_pPlayer->pev, m_pPlayer->pev);
float flVol = 1;
int fHitWorld = TRUE;
if (pEntity != NULL && pEntity->Classify() != CLASS_NONE && pEntity->Classify() != CLASS_MACHINE)
if (pEntity != NULL)
{
if (pEntity->Classify() != CLASS_NONE && pEntity->Classify() != CLASS_MACHINE)
{
// play thwack or smack sound
switch (RANDOM_LONG(0, 3))
{
case 0: EMIT_SOUND(m_pPlayer->edict(), CHAN_WEAPON, "weapons/knife_hit1.wav", VOL_NORM, ATTN_NORM); break;
@ -415,17 +429,21 @@ int CKnife::Swing(int fFirst)
m_pPlayer->m_iWeaponVolume = KNIFE_BODYHIT_VOLUME;
if (!pEntity->IsAlive())
{
return TRUE;
}
else
flVol = 0.1f;
flVol = 0.1;
fHitWorld = FALSE;
}
}
// play texture hit sound
// UNDONE: Calculate the correct point of intersection when we hit with the hull instead of the line
if (fHitWorld)
{
TEXTURETYPE_PlaySound(&tr, vecSrc, vecSrc + (vecEnd - vecSrc) * 2, BULLET_PLAYER_CROWBAR);
float fvolbar = TEXTURETYPE_PlaySound(&tr, vecSrc, vecSrc + (vecEnd - vecSrc) * 2, BULLET_PLAYER_CROWBAR);
//fvolbar = 1.0;
if (RANDOM_LONG(0, 1) > 1)
{
@ -435,6 +453,7 @@ int CKnife::Swing(int fFirst)
if (!fHitWorld)
{
// delay the decal a bit
m_trHit = tr;
SetThink(&CKnife::Smack);
@ -445,8 +464,8 @@ int CKnife::Swing(int fFirst)
}
else
{
float fvolbar = RANDOM_LONG(0, 3) + 98;
EMIT_SOUND_DYN(m_pPlayer->edict(), CHAN_ITEM, "weapons/knife_hitwall1.wav", VOL_NORM, ATTN_NORM, 0, fvolbar);
// also play knife strike
EMIT_SOUND_DYN(m_pPlayer->edict(), CHAN_ITEM, "weapons/knife_hitwall1.wav", VOL_NORM, ATTN_NORM, 0, RANDOM_LONG(0, 3) + 98);
}
}
@ -473,6 +492,8 @@ int CKnife::Stab(int fFirst)
if (tr.flFraction < 1.0f)
{
// Calculate the point of intersection of the line (or hull) and the object we hit
// This is and approximation of the "best" intersection
CBaseEntity *pHit = CBaseEntity::Instance(tr.pHit);
if (!pHit || pHit->IsBSPModel())
@ -480,6 +501,7 @@ int CKnife::Stab(int fFirst)
FindHullIntersection(vecSrc, tr, VEC_DUCK_HULL_MIN, VEC_DUCK_HULL_MAX, m_pPlayer->edict());
}
// This is the point on the actual surface (the hull could have hit space)
vecEnd = tr.vecEndPos;
}
}
@ -493,16 +515,19 @@ int CKnife::Stab(int fFirst)
m_flNextPrimaryAttack = GetNextAttackDelay(1.0);
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.0;
// play wiff or swish sound
if (RANDOM_LONG(0, 1))
EMIT_SOUND_DYN(m_pPlayer->edict(), CHAN_WEAPON, "weapons/knife_slash1.wav", VOL_NORM, ATTN_NORM, 0, 94);
else
EMIT_SOUND_DYN(m_pPlayer->edict(), CHAN_WEAPON, "weapons/knife_slash2.wav", VOL_NORM, ATTN_NORM, 0, 94);
// player "shoot" animation
m_pPlayer->SetAnimation(PLAYER_ATTACK1);
}
}
else
{
// hit
fDidHit = TRUE;
SendWeaponAnim(KNIFE_STABHIT, UseDecrement() != FALSE);
@ -510,11 +535,16 @@ int CKnife::Stab(int fFirst)
m_flNextPrimaryAttack = GetNextAttackDelay(1.1);
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.1;
// play thwack, smack, or dong sound
float flVol = 1.0f;
int fHitWorld = TRUE;
CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit);
// player "shoot" animation
m_pPlayer->SetAnimation(PLAYER_ATTACK1);
float flDamage = 65.0;
float flDamage = 65.0f;
if (pEntity && pEntity->IsPlayer())
{
@ -529,7 +559,8 @@ int CKnife::Stab(int fFirst)
flDot = DotProduct(vec2LOS, gpGlobals->v_forward.Make2D());
if (flDot > 0.8)
//Triple the damage if we are stabbing them in the back.
if (flDot > 0.80f)
{
flDamage *= 3.0;
}
@ -541,26 +572,29 @@ int CKnife::Stab(int fFirst)
pEntity->TraceAttack(m_pPlayer->pev, flDamage, gpGlobals->v_forward, &tr, (DMG_NEVERGIB | DMG_BULLET));
ApplyMultiDamage(m_pPlayer->pev, m_pPlayer->pev);
float flVol = 1.0f;
int fHitWorld = TRUE;
if (pEntity != NULL && pEntity->Classify() != CLASS_NONE && pEntity->Classify() != CLASS_MACHINE)
if (pEntity != NULL)
{
if (pEntity->Classify() != CLASS_NONE && pEntity->Classify() != CLASS_MACHINE)
{
EMIT_SOUND(m_pPlayer->edict(), CHAN_WEAPON, "weapons/knife_stab.wav", VOL_NORM, ATTN_NORM);
m_pPlayer->m_iWeaponVolume = KNIFE_BODYHIT_VOLUME;
if (!pEntity->IsAlive())
{
return TRUE;
}
else
flVol = 0.1f;
flVol = 0.1;
fHitWorld = FALSE;
}
}
// play texture hit sound
// UNDONE: Calculate the correct point of intersection when we hit with the hull instead of the line
if (fHitWorld)
{
TEXTURETYPE_PlaySound(&tr, vecSrc, vecSrc + (vecEnd - vecSrc) * 2, BULLET_PLAYER_CROWBAR);
float fvolbar = TEXTURETYPE_PlaySound(&tr, vecSrc, vecSrc + (vecEnd - vecSrc) * 2, BULLET_PLAYER_CROWBAR);
//fvolbar = 1.0;
if (RANDOM_LONG(0, 1) > 1)
{
@ -570,6 +604,7 @@ int CKnife::Stab(int fFirst)
if (!fHitWorld)
{
// delay the decal a bit
m_trHit = tr;
m_pPlayer->m_iWeaponVolume = (int)(flVol * KNIFE_WALLHIT_VOLUME);
@ -580,8 +615,8 @@ int CKnife::Stab(int fFirst)
}
else
{
float fvolbar = RANDOM_LONG(0, 3) + 98;
EMIT_SOUND_DYN(m_pPlayer->edict(), CHAN_ITEM, "weapons/knife_hitwall1.wav", VOL_NORM, ATTN_NORM, 0, fvolbar);
// also play knife strike
EMIT_SOUND_DYN(m_pPlayer->edict(), CHAN_ITEM, "weapons/knife_hitwall1.wav", VOL_NORM, ATTN_NORM, 0, RANDOM_LONG(0, 3) + 98);
}
}

View File

@ -28,8 +28,10 @@
#include "precompiled.h"
// Purpose: determine if a uchar32 represents a valid Unicode code point
/* <f2fc1> ../engine/unicode_strtools.cpp:23 */
//-----------------------------------------------------------------------------
// Purpose: determine if a uchar32 represents a valid Unicode code point
//-----------------------------------------------------------------------------
bool Q_IsValidUChar32(uchar32 uVal)
{
// Values > 0x10FFFF are explicitly invalid; ditto for UTF-16 surrogate halves,
@ -99,7 +101,7 @@ template<
int(UCHAR32_TO_OUT_LEN)(uchar32 uVal),
int(UCHAR32_TO_OUT)(uchar32 uVal, T_OUT *pUTF8Out)
>
int Q_UnicodeConvertT(const T_IN *pIn, T_OUT *pOut, int nOutBytes, enum EStringConvertErrorPolicy ePolicy)
int Q_UnicodeConvertT(const T_IN *pIn, T_OUT *pOut, int nOutBytes, EStringConvertErrorPolicy ePolicy)
{
int nOut = 0;
if (pOut)
@ -130,7 +132,7 @@ int Q_UnicodeConvertT(const T_IN *pIn, T_OUT *pOut, int nOutBytes, enum EStringC
}
}
};
}
pOut[nOut] = 0;
}
@ -295,17 +297,16 @@ NOXREF int Q_UTF32ToUTF16(const uchar32 *pUTF32, uchar16 *pUTF16, int cubDestSiz
return Q_UnicodeConvertT<uchar32, uchar16, true, Q_UTF32ToUChar32, Q_UChar32ToUTF16Len, Q_UChar32ToUTF16>(pUTF32, pUTF16, cubDestSizeInBytes, ePolicy);
}
/* <f4251> ../engine/unicode_strtools.cpp:346 */
// Decode one character from a UTF-8 encoded string. Treats 6-byte CESU-8 sequences
// as a single character, as if they were a correctly-encoded 4-byte UTF-8 sequence.
/* <f4251> ../engine/unicode_strtools.cpp:346 */
int Q_UTF8ToUChar32(const char *pUTF8_, uchar32 &uValueOut, bool &bErrorOut)
{
const uint8_t *pUTF8 = (const uint8_t *)pUTF8_;
const uint8 *pUTF8 = (const uint8 *)pUTF8_;
int nBytes = 1;
uint32_t uValue = pUTF8[0];
uint32_t uMinValue = 0;
uint32 uValue = pUTF8[0];
uint32 uMinValue = 0;
// 0....... single byte
if (uValue < 0x80)
@ -361,17 +362,19 @@ decodeError:
decodeFinishedMaybeCESU8:
// Do we have a full UTF-16 surrogate pair that's been UTF-8 encoded afterwards?
// That is, do we have 0xD800-0xDBFF followed by 0xDC00-0xDFFF? If so, decode it all.
if ((uValue - 0xD800u) < 0x400u && pUTF8[3] == 0xED && (uint8_t)(pUTF8[4] - 0xB0) < 0x10 && (pUTF8[5] & 0xC0) == 0x80)
if ((uValue - 0xD800u) < 0x400u && pUTF8[3] == 0xED && (uint8)(pUTF8[4] - 0xB0) < 0x10 && (pUTF8[5] & 0xC0) == 0x80)
{
uValue = 0x10000 + ((uValue - 0xD800u) << 10) + ((uint8_t)(pUTF8[4] - 0xB0) << 6) + pUTF8[5] - 0x80;
uValue = 0x10000 + ((uValue - 0xD800u) << 10) + ((uint8)(pUTF8[4] - 0xB0) << 6) + pUTF8[5] - 0x80;
nBytes = 6;
uMinValue = 0x10000;
}
goto decodeFinished;
}
// Purpose: Returns false if UTF-8 string contains invalid sequences.
/* <f45fd> ../engine/unicode_strtools.cpp:423 */
//-----------------------------------------------------------------------------
// Purpose: Returns false if UTF-8 string contains invalid sequences.
//-----------------------------------------------------------------------------
qboolean Q_UnicodeValidate(const char *pUTF8)
{
bool bError = false;
@ -421,14 +424,16 @@ NOXREF char *Q_UnicodeAdvance(char *pUTF8, int nChars)
return pUTF8;
}
/* <f4737> ../engine/unicode_strtools.cpp:479 */
//-----------------------------------------------------------------------------
// Purpose: returns true if a wide character is a "mean" space; that is,
// if it is technically a space or punctuation, but causes disruptive
// behavior when used in names, web pages, chat windows, etc.
//
// characters in this set are removed from the beginning and/or end of strings
// by Q_AggressiveStripPrecedingAndTrailingWhitespaceW()
/* <f4737> ../engine/unicode_strtools.cpp:479 */
qboolean Q_IsMeanSpaceW(uchar16 wch)
//-----------------------------------------------------------------------------
bool Q_IsMeanSpaceW(uchar32 wch)
{
bool bIsMean = false;
@ -466,9 +471,9 @@ qboolean Q_IsMeanSpaceW(uchar16 wch)
}
/* <f37f5> ../engine/unicode_strtools.cpp:566 */
qboolean Q_IsDeprecatedW(uchar16 wch)
bool Q_IsDeprecatedW(uchar16 wch)
{
qboolean bIsDeprecated = FALSE;
bool bIsDeprecated = false;
switch (wch)
{
@ -483,21 +488,22 @@ qboolean Q_IsDeprecatedW(uchar16 wch)
case 0x206D:
case 0x206E:
case 0x206F:
bIsDeprecated = TRUE;
bIsDeprecated = true;
break;
}
return bIsDeprecated;
}
/* <f47bc> ../engine/unicode_strtools.cpp:600 */
//-----------------------------------------------------------------------------
// Purpose: strips trailing whitespace; returns pointer inside string just past
// any leading whitespace.
//
// bAggresive = true causes this function to also check for "mean" spaces,
// which we don't want in persona names or chat strings as they're disruptive
// to the user experience.
/* <f47bc> ../engine/unicode_strtools.cpp:600 */
//-----------------------------------------------------------------------------
static uchar16 *StripWhitespaceWorker(uchar16 *pwch, int cchLength, bool *pbStrippedWhitespace)
{
// walk backwards from the end of the string, killing any whitespace
@ -554,20 +560,19 @@ qboolean Q_StripUnprintableAndSpace(char *pch)
{
bool bStrippedAny;
bool bStrippedWhitespace;
int cch = Q_strlen(pch);
int cubDest = (cch + 1) * sizeof(uchar16);
uchar16 *pwch_alloced = (uchar16 *)malloc(cubDest);
bStrippedAny = false;
bStrippedWhitespace = false;
// TODO: here is used Q_UTF8ToUTF32, and not this Q_UTF8ToUTF16
// TODO: here is using Q_UTF8ToUTF32 by DWARF
int cwch = (unsigned int)Q_UTF8ToUTF16(pch, (uchar16 *)pwch_alloced, cubDest, _STRINGCONVERTFLAG_ASSERT) >> 1;
uchar16 *pwch = StripUnprintableWorker(pwch_alloced, &bStrippedAny);
pwch = StripWhitespaceWorker(pwch, cwch - 1, &bStrippedWhitespace);
if (bStrippedWhitespace || bStrippedAny)
{
// TODO:: here is used Q_UTF32ToUTF8
// TODO: here is using Q_UTF32ToUTF8 by DWARF
Q_UTF16ToUTF8(pwch, pch, cch, STRINGCONVERT_ASSERT_REPLACE);
}

View File

@ -78,8 +78,8 @@ int Q_UTF8ToUChar32(const char *pUTF8_, uchar32 &uValueOut, bool &bErrorOut);
qboolean Q_UnicodeValidate(const char *pUTF8);
NOXREF int Q_UnicodeLength(const char *pUTF8);
NOXREF char *Q_UnicodeAdvance(char *pUTF8, int nChars);
qboolean Q_IsMeanSpaceW(uchar16 wch);
qboolean Q_IsDeprecatedW(uchar16 wch);
//bool Q_IsMeanSpaceW(uchar16 wch);
bool Q_IsDeprecatedW(uchar16 wch);
uchar16 *StripUnprintableWorker(uchar16 *pwch, bool *pbStrippedAny);
qboolean Q_StripUnprintableAndSpace(char *pch);
NOXREF qboolean V_UTF8ToUChar32(const char *pUTF8_, uchar32 *uValueOut);

View File

@ -107,7 +107,7 @@ void CBotManager::__MAKE_VHOOK(StartFrame)(void)
// Process each active bot
for (int i = 1; i <= gpGlobals->maxClients; ++i)
{
CBasePlayer *pPlayer = (CBasePlayer *)UTIL_PlayerByIndex(i);
CBasePlayer *pPlayer = reinterpret_cast<CBasePlayer *>(UTIL_PlayerByIndex(i));
if (!pPlayer)
continue;

View File

@ -782,8 +782,8 @@ FunctionHook g_FunctionHooks[] =
{ 0x01DAD280, "_ZN11CBasePlayer7AutoBuyEv", mfunc_ptr_cast(&CBasePlayer::AutoBuy) },
{ 0x01DAD0D0, "_ZN11CBasePlayer13ClientCommandEPKcS1_S1_S1_", mfunc_ptr_cast(&CBasePlayer::ClientCommand) },
{ 0x01DADD00, "_ZN11CBasePlayer23PrioritizeAutoBuyStringEPcPKc", mfunc_ptr_cast(&CBasePlayer::PrioritizeAutoBuyString) },
//{ 0x01DAD590, "_ZN11CBasePlayer27PickPrimaryCareerTaskWeaponEv", mfunc_ptr_cast(&CBasePlayer::PickPrimaryCareerTaskWeapon) },
//{ 0x01DAD930, "_ZN11CBasePlayer29PickSecondaryCareerTaskWeaponEv", mfunc_ptr_cast(&CBasePlayer::PickSecondaryCareerTaskWeapon) },
{ 0x01DAD590, "_ZN11CBasePlayer27PickPrimaryCareerTaskWeaponEv", mfunc_ptr_cast(&CBasePlayer::PickPrimaryCareerTaskWeapon) },
{ 0x01DAD930, "_ZN11CBasePlayer29PickSecondaryCareerTaskWeaponEv", mfunc_ptr_cast(&CBasePlayer::PickSecondaryCareerTaskWeapon) },
//{ 0x01DADC60, "_ZN11CBasePlayer25PickFlashKillWeaponStringEv", mfunc_ptr_cast(&CBasePlayer::PickFlashKillWeaponString) }, // NOXREF
//{ 0x01DADCC0, "_ZN11CBasePlayer27PickGrenadeKillWeaponStringEv", mfunc_ptr_cast(&CBasePlayer::PickGrenadeKillWeaponString) }, // NOXREF
//{ 0x01DADF70, "_ZN11CBasePlayer27ShouldExecuteAutoBuyCommandEPK17AutoBuyInfoStructbb", mfunc_ptr_cast(&CBasePlayer::ShouldExecuteAutoBuyCommand) }, // NOXREF
@ -5534,8 +5534,6 @@ AddressRef g_FunctionRefs[] =
{ 0x01D2D9B0, "_ZN6CCSBot6UpdateEv", (size_t)&pCCSBot__Update },
{ 0x01D5B350, "_Z16QuaternionMatrixPfPA4_f", (size_t)&pQuaternionMatrix },
{ 0x01DAD590, "_ZN11CBasePlayer27PickPrimaryCareerTaskWeaponEv", (size_t)&pCBasePlayer__PickPrimaryCareerTaskWeapon },
{ 0x01DAD930, "_ZN11CBasePlayer29PickSecondaryCareerTaskWeaponEv", (size_t)&pCBasePlayer__PickSecondaryCareerTaskWeapon },
{ 0x01D46310, "_Z17LoadNavigationMapv", (size_t)&pLoadNavigationMap },
{ 0x01D19C70, "_ZN9BotPhrase9RandomizeEv", (size_t)&pBotPhrase__Randomize },

View File

@ -49,6 +49,23 @@ void _print_chat(class CBasePlayer *pPlayer, const char *fmt, ...)
UTIL_SayText(Dest, (class CBaseEntity *)pPlayer);
}
void _print_console(struct entvars_s *pev, const char *fmt, ...)
{
static char Dest[4096];
va_list ap;
va_start(ap, fmt);
vsnprintf(Dest, sizeof(Dest), fmt, ap);
va_end(ap);
if (Q_strlen(Dest) < sizeof(Dest) - 2)
Q_strcat(Dest, "\n");
else Dest[Q_strlen(Dest) - 1] = '\n';
ClientPrint(pev, HUD_PRINTCONSOLE, Dest);
}
void _printf2(const char *fmt, ...)
{
/*

View File

@ -20,3 +20,4 @@ extern void Regamedll_Game_Init(void);
extern void _printf2(const char *fmt, ...);
extern void _print_chat(class CBasePlayer *pPlayer, const char *fmt, ...);
extern void _print_console(struct entvars_s *pev, const char *fmt, ...);