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)
@ -1208,4 +1207,4 @@ BOOL CBaseEntity::FVisible(const Vector &vecOrigin)
return FVisible_(vecOrigin);
}
#endif // HOOK_GAMEDLL
#endif // HOOK_GAMEDLL

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;
}
}
@ -991,9 +991,14 @@ void CHalfLifeMultiplay::QueueCareerRoundEndMenu(float tmDelay, int iWinStatus)
if (m_iNumTerroristWins < m_iCareerMatchWins || (m_iNumTerroristWins - m_iNumCTWins < m_iRoundWinDifference))
canTsWin = false;
if (!TheCareerTasks->AreAllTasksComplete() && !humansAreCTs)
canTsWin = false;
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,8 +1774,8 @@ 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,38 +2569,36 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(Think)(void)
}
else
{
if (m_fCareerMatchMenuTime + 10 > gpGlobals->time && !IsBotSpeaking())
{
return;
if (m_fCareerMatchMenuTime + 10 <= gpGlobals->time || !IsBotSpeaking())
{
UTIL_CareerDPrintf("Ending career match...one team has won the specified number of rounds\n");
MESSAGE_BEGIN(MSG_ALL, gmsgCZCareer);
WRITE_STRING("MATCH");
WRITE_LONG(m_iNumCTWins);
WRITE_LONG(m_iNumTerroristWins);
MESSAGE_END();
MESSAGE_BEGIN(MSG_ALL, gmsgCZCareerHUD);
WRITE_STRING("MATCH");
WRITE_LONG(m_iNumCTWins);
WRITE_LONG(m_iNumTerroristWins);
WRITE_BYTE(m_iCareerMatchWins);
WRITE_BYTE(m_iRoundWinDifference);
WRITE_BYTE(m_iRoundWinStatus);
MESSAGE_END();
UTIL_LogPrintf
(
"Career Match %d %d %d %d\n",
m_iRoundWinStatus,
m_iNumCTWins,
m_iNumTerroristWins,
TheCareerTasks->AreAllTasksComplete()
);
SERVER_COMMAND("setpause\n");
}
UTIL_CareerDPrintf("Ending career match...one team has won the specified number of rounds\n");
MESSAGE_BEGIN(MSG_ALL, gmsgCZCareer);
WRITE_STRING("MATCH");
WRITE_LONG(m_iNumCTWins);
WRITE_LONG(m_iNumTerroristWins);
MESSAGE_END();
MESSAGE_BEGIN(MSG_ALL, gmsgCZCareerHUD);
WRITE_STRING("MATCH");
WRITE_LONG(m_iNumCTWins);
WRITE_LONG(m_iNumTerroristWins);
WRITE_BYTE(m_iCareerMatchWins);
WRITE_BYTE(m_iRoundWinDifference);
WRITE_BYTE(m_iRoundWinStatus);
MESSAGE_END();
UTIL_LogPrintf
(
"Career Match %d %d %d %d\n",
m_iRoundWinStatus,
m_iNumCTWins,
m_iNumTerroristWins,
TheCareerTasks->AreAllTasksComplete()
);
SERVER_COMMAND("setpause\n");
}
}
@ -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");
UTIL_LogPrintf
(
"Team \"CT\" scored \"%i\" with \"%i\" players\n",
m_iNumCTWins,
m_iNumCT
);
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 \"TERRORIST\" scored \"%i\" with \"%i\" players\n",
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++)
{

File diff suppressed because it is too large Load Diff

View File

@ -1,35 +1,37 @@
/*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#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;
}
@ -198,34 +200,34 @@ int Q_UChar32ToUTF16(uchar32 uVal, uchar16 *pUTF16Out)
}
/* <f3192> ../engine/unicode_strtools.cpp:180 */
int Q_UChar32ToUTF8(uchar32 uVal, char *pUTF8Out)
{
if (uVal <= 0x7F)
{
*pUTF8Out = uVal;
return 1;
}
else if (uVal <= 0x7FF)
{
*pUTF8Out = (uVal >> 6) | 0xC0;
pUTF8Out[1] = uVal & 0x3F | 0x80;
return 2;
}
else if (uVal <= 0xFFFF)
{
*pUTF8Out = (uVal >> 12) | 0xE0;
pUTF8Out[2] = uVal & 0x3F | 0x80;
pUTF8Out[1] = (uVal >> 6) & 0x3F | 0x80;
return 3;
}
else
{
*pUTF8Out = (uVal >> 18) & 7 | 0xF0;
pUTF8Out[1] = (uVal >> 12) & 0x3F | 0x80;
pUTF8Out[3] = uVal & 0x3F | 0x80;
pUTF8Out[2] = (uVal >> 6) & 0x3F | 0x80;
return 4;
}
int Q_UChar32ToUTF8(uchar32 uVal, char *pUTF8Out)
{
if (uVal <= 0x7F)
{
*pUTF8Out = uVal;
return 1;
}
else if (uVal <= 0x7FF)
{
*pUTF8Out = (uVal >> 6) | 0xC0;
pUTF8Out[1] = uVal & 0x3F | 0x80;
return 2;
}
else if (uVal <= 0xFFFF)
{
*pUTF8Out = (uVal >> 12) | 0xE0;
pUTF8Out[2] = uVal & 0x3F | 0x80;
pUTF8Out[1] = (uVal >> 6) & 0x3F | 0x80;
return 3;
}
else
{
*pUTF8Out = (uVal >> 18) & 7 | 0xF0;
pUTF8Out[1] = (uVal >> 12) & 0x3F | 0x80;
pUTF8Out[3] = uVal & 0x3F | 0x80;
pUTF8Out[2] = (uVal >> 6) & 0x3F | 0x80;
return 4;
}
}
/* <f32b4> ../engine/unicode_strtools.cpp:209 */
@ -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,43 +424,45 @@ NOXREF char *Q_UnicodeAdvance(char *pUTF8, int nChars)
return pUTF8;
}
// 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)
//-----------------------------------------------------------------------------
// 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()
//-----------------------------------------------------------------------------
bool Q_IsMeanSpaceW(uchar32 wch)
{
bool bIsMean = false;
switch (wch)
{
case 0x0082: // BREAK PERMITTED HERE
case 0x0083: // NO BREAK PERMITTED HERE
case 0x00A0: // NO-BREAK SPACE
case 0x034F: // COMBINING GRAPHEME JOINER
case 0x2000: // EN QUAD
case 0x2001: // EM QUAD
case 0x2002: // EN SPACE
case 0x2003: // EM SPACE
case 0x2004: // THICK SPACE
case 0x2005: // MID SPACE
case 0x2006: // SIX SPACE
case 0x2007: // figure space
case 0x2008: // PUNCTUATION SPACE
case 0x2009: // THIN SPACE
case 0x200A: // HAIR SPACE
case 0x200B: // ZERO-WIDTH SPACE
case 0x200C: // ZERO-WIDTH NON-JOINER
case 0x200D: // ZERO WIDTH JOINER
case 0x2028: // LINE SEPARATOR
case 0x2029: // PARAGRAPH SEPARATOR
case 0x202F: // NARROW NO-BREAK SPACE
case 0x2060: // word joiner
case 0xFEFF: // ZERO-WIDTH NO BREAK SPACE
case 0xFFFC: // OBJECT REPLACEMENT CHARACTER
case 0x0082: // BREAK PERMITTED HERE
case 0x0083: // NO BREAK PERMITTED HERE
case 0x00A0: // NO-BREAK SPACE
case 0x034F: // COMBINING GRAPHEME JOINER
case 0x2000: // EN QUAD
case 0x2001: // EM QUAD
case 0x2002: // EN SPACE
case 0x2003: // EM SPACE
case 0x2004: // THICK SPACE
case 0x2005: // MID SPACE
case 0x2006: // SIX SPACE
case 0x2007: // figure space
case 0x2008: // PUNCTUATION SPACE
case 0x2009: // THIN SPACE
case 0x200A: // HAIR SPACE
case 0x200B: // ZERO-WIDTH SPACE
case 0x200C: // ZERO-WIDTH NON-JOINER
case 0x200D: // ZERO WIDTH JOINER
case 0x2028: // LINE SEPARATOR
case 0x2029: // PARAGRAPH SEPARATOR
case 0x202F: // NARROW NO-BREAK SPACE
case 0x2060: // word joiner
case 0xFEFF: // ZERO-WIDTH NO BREAK SPACE
case 0xFFFC: // OBJECT REPLACEMENT CHARACTER
bIsMean = true;
break;
}
@ -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);
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);
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, ...);