mirror of
https://github.com/s1lentq/ReGameDLL_CS.git
synced 2025-01-14 15:48:01 +03:00
Bugfix: game_playerspawn called when fullupdate (ResetHUD)
Mini-refactoring
This commit is contained in:
parent
64baf253c6
commit
1fc388a2cc
@ -1249,8 +1249,7 @@ void BuyItem(CBasePlayer *pPlayer, int iSlot)
|
||||
bEnoughMoney = true;
|
||||
pPlayer->m_bHasNightVision = true;
|
||||
pPlayer->AddAccount(-NVG_PRICE, RT_PLAYER_BOUGHT_SOMETHING);
|
||||
|
||||
SendItemStatus(pPlayer);
|
||||
pPlayer->SendItemStatus();
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -1286,7 +1285,7 @@ void BuyItem(CBasePlayer *pPlayer, int iSlot)
|
||||
pPlayer->AddAccount(-DEFUSEKIT_PRICE, RT_PLAYER_BOUGHT_SOMETHING);
|
||||
|
||||
EMIT_SOUND(ENT(pPlayer->pev), CHAN_ITEM, "items/kevlar.wav", VOL_NORM, ATTN_NORM);
|
||||
SendItemStatus(pPlayer);
|
||||
pPlayer->SendItemStatus();
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -1800,8 +1799,8 @@ BOOL __API_HOOK(HandleMenu_ChooseTeam)(CBasePlayer *player, int slot)
|
||||
player->has_disconnected = false;
|
||||
|
||||
player->m_iJoiningState = GETINTOGAME;
|
||||
player->SendItemStatus();
|
||||
|
||||
SendItemStatus(player);
|
||||
SET_CLIENT_MAXSPEED(ENT(player->pev), 1);
|
||||
SET_MODEL(ENT(player->pev), "models/player.mdl");
|
||||
}
|
||||
@ -3387,6 +3386,10 @@ void EXT_FUNC ServerActivate(edict_t *pEdictList, int edictCount, int clientMax)
|
||||
{
|
||||
g_pHostages->ServerActivate();
|
||||
}
|
||||
|
||||
#ifdef REGAMEDLL_ADD
|
||||
CSGameRules()->ServerActivate();
|
||||
#endif
|
||||
}
|
||||
|
||||
void EXT_FUNC PlayerPreThink(edict_t *pEntity)
|
||||
@ -4535,21 +4538,21 @@ void EXT_FUNC UpdateClientData(const struct edict_s *ent, int sendweapons, struc
|
||||
|
||||
if (g_pGameRules->IsFreezePeriod())
|
||||
iUser3 |= DATA_IUSER3_FREEZETIMEOVER;
|
||||
else
|
||||
iUser3 &= ~DATA_IUSER3_FREEZETIMEOVER;
|
||||
|
||||
if (pl->m_signals.GetState() & SIGNAL_BOMB)
|
||||
iUser3 |= DATA_IUSER3_INBOMBZONE;
|
||||
else
|
||||
iUser3 &= ~DATA_IUSER3_INBOMBZONE;
|
||||
|
||||
if (pl->HasShield())
|
||||
iUser3 |= DATA_IUSER3_HOLDINGSHIELD;
|
||||
else
|
||||
iUser3 &= ~DATA_IUSER3_HOLDINGSHIELD;
|
||||
|
||||
if (!pl->pev->iuser1 && !pevOrg)
|
||||
{
|
||||
#ifdef REGAMEDLL_ADD
|
||||
// useful for mods
|
||||
iUser3 |= pev->iuser3;
|
||||
#endif
|
||||
cd->iuser3 = iUser3;
|
||||
}
|
||||
|
||||
if (pl->m_pActiveItem != NULL)
|
||||
{
|
||||
|
@ -33,7 +33,7 @@ BOOL CGameRules::__MAKE_VHOOK(CanHaveAmmo)(CBasePlayer *pPlayer, const char *psz
|
||||
edict_t *CGameRules::__MAKE_VHOOK(GetPlayerSpawnSpot)(CBasePlayer *pPlayer)
|
||||
{
|
||||
// gat valid spawn point
|
||||
edict_t *pentSpawnSpot = EntSelectSpawnPoint(pPlayer);
|
||||
edict_t *pentSpawnSpot = pPlayer->EntSelectSpawnPoint();
|
||||
|
||||
// Move the player to the place it said.
|
||||
#ifndef PLAY_GAMEDLL
|
||||
|
@ -499,6 +499,9 @@ public:
|
||||
#endif
|
||||
|
||||
public:
|
||||
void ServerActivate();
|
||||
void ReadMultiplayCvars();
|
||||
|
||||
// Checks if it still needs players to start a round, or if it has enough players to start rounds.
|
||||
// Starts a round and returns true if there are enough players.
|
||||
bool NeededPlayersCheck();
|
||||
@ -670,7 +673,7 @@ public:
|
||||
float m_flForceChaseCamValue;
|
||||
float m_flFadeToBlackValue;
|
||||
CBasePlayer *m_pVIP;
|
||||
CBasePlayer *VIPQueue[MAX_VIP_QUEUES];
|
||||
CBasePlayer *m_pVIPQueue[MAX_VIP_QUEUES];
|
||||
|
||||
protected:
|
||||
float m_flIntermissionEndTime;
|
||||
@ -793,7 +796,6 @@ void SV_CareerMatchLimit_f();
|
||||
void Broadcast(const char *sentence);
|
||||
char *GetTeam(int teamNo);
|
||||
void EndRoundMessage(const char *sentence, int event);
|
||||
void ReadMultiplayCvars(CHalfLifeMultiplay *mp);
|
||||
void DestroyMapCycle(mapcycle_t *cycle);
|
||||
|
||||
char *MP_COM_GetToken();
|
||||
|
@ -375,7 +375,7 @@ BOOL CItemThighPack::__MAKE_VHOOK(MyTouch)(CBasePlayer *pPlayer)
|
||||
WRITE_BYTE(0);
|
||||
MESSAGE_END();
|
||||
|
||||
SendItemStatus(pPlayer);
|
||||
pPlayer->SendItemStatus();
|
||||
EMIT_SOUND(pPlayer->edict(), CHAN_VOICE, "items/kevlar.wav", VOL_NORM, ATTN_NORM);
|
||||
|
||||
if (TheTutor != NULL)
|
||||
|
@ -323,86 +323,85 @@ void EXT_FUNC EndRoundMessage(const char *sentence, int event)
|
||||
UTIL_LogPrintf("World triggered \"Round_End\"\n");
|
||||
}
|
||||
|
||||
void ReadMultiplayCvars(CHalfLifeMultiplay *mp)
|
||||
void CHalfLifeMultiplay::ReadMultiplayCvars()
|
||||
{
|
||||
mp->m_iRoundTime = int(CVAR_GET_FLOAT("mp_roundtime") * 60);
|
||||
mp->m_iC4Timer = int(CVAR_GET_FLOAT("mp_c4timer"));
|
||||
mp->m_iIntroRoundTime = int(CVAR_GET_FLOAT("mp_freezetime"));
|
||||
mp->m_iLimitTeams = int(CVAR_GET_FLOAT("mp_limitteams"));
|
||||
m_iRoundTime = int(CVAR_GET_FLOAT("mp_roundtime") * 60);
|
||||
m_iC4Timer = int(CVAR_GET_FLOAT("mp_c4timer"));
|
||||
m_iIntroRoundTime = int(CVAR_GET_FLOAT("mp_freezetime"));
|
||||
m_iLimitTeams = int(CVAR_GET_FLOAT("mp_limitteams"));
|
||||
|
||||
#ifndef REGAMEDLL_ADD
|
||||
if (mp->m_iRoundTime > 540)
|
||||
if (m_iRoundTime > 540)
|
||||
{
|
||||
CVAR_SET_FLOAT("mp_roundtime", 9);
|
||||
mp->m_iRoundTime = 540;
|
||||
m_iRoundTime = 540;
|
||||
}
|
||||
else if (mp->m_iRoundTime < 60)
|
||||
else if (m_iRoundTime < 60)
|
||||
{
|
||||
CVAR_SET_FLOAT("mp_roundtime", 1);
|
||||
mp->m_iRoundTime = 60;
|
||||
m_iRoundTime = 60;
|
||||
}
|
||||
|
||||
if (mp->m_iIntroRoundTime > 60)
|
||||
if (m_iIntroRoundTime > 60)
|
||||
{
|
||||
CVAR_SET_FLOAT("mp_freezetime", 60);
|
||||
mp->m_iIntroRoundTime = 60;
|
||||
m_iIntroRoundTime = 60;
|
||||
}
|
||||
else if (mp->m_iIntroRoundTime < 0)
|
||||
else if (m_iIntroRoundTime < 0)
|
||||
{
|
||||
CVAR_SET_FLOAT("mp_freezetime", 0);
|
||||
mp->m_iIntroRoundTime = 0;
|
||||
m_iIntroRoundTime = 0;
|
||||
}
|
||||
|
||||
if (mp->m_iC4Timer > 90)
|
||||
if (m_iC4Timer > 90)
|
||||
{
|
||||
CVAR_SET_FLOAT("mp_c4timer", 90);
|
||||
mp->m_iC4Timer = 90;
|
||||
m_iC4Timer = 90;
|
||||
}
|
||||
else if (mp->m_iC4Timer < 10)
|
||||
else if (m_iC4Timer < 10)
|
||||
{
|
||||
CVAR_SET_FLOAT("mp_c4timer", 10);
|
||||
mp->m_iC4Timer = 10;
|
||||
m_iC4Timer = 10;
|
||||
}
|
||||
|
||||
if (mp->m_iLimitTeams > 20)
|
||||
if (m_iLimitTeams > 20)
|
||||
{
|
||||
CVAR_SET_FLOAT("mp_limitteams", 20);
|
||||
mp->m_iLimitTeams = 20;
|
||||
m_iLimitTeams = 20;
|
||||
}
|
||||
else if (mp->m_iLimitTeams < 0)
|
||||
else if (m_iLimitTeams < 0)
|
||||
{
|
||||
CVAR_SET_FLOAT("mp_limitteams", 0);
|
||||
mp->m_iLimitTeams = 0;
|
||||
m_iLimitTeams = 0;
|
||||
}
|
||||
#else
|
||||
// a limit of 500 minutes because
|
||||
// if you do more minutes would be a bug in the HUD RoundTime in the form 00:00
|
||||
if (mp->m_iRoundTime > 30000)
|
||||
if (m_iRoundTime > 30000)
|
||||
{
|
||||
CVAR_SET_FLOAT("mp_roundtime", 500);
|
||||
mp->m_iRoundTime = 30000;
|
||||
m_iRoundTime = 30000;
|
||||
}
|
||||
else if (mp->m_iRoundTime < 0)
|
||||
else if (m_iRoundTime < 0)
|
||||
{
|
||||
CVAR_SET_FLOAT("mp_roundtime", 0);
|
||||
mp->m_iRoundTime = 0;
|
||||
m_iRoundTime = 0;
|
||||
}
|
||||
if (mp->m_iIntroRoundTime < 0)
|
||||
if (m_iIntroRoundTime < 0)
|
||||
{
|
||||
CVAR_SET_FLOAT("mp_freezetime", 0);
|
||||
mp->m_iIntroRoundTime = 0;
|
||||
m_iIntroRoundTime = 0;
|
||||
}
|
||||
if (mp->m_iC4Timer < 0)
|
||||
if (m_iC4Timer < 0)
|
||||
{
|
||||
CVAR_SET_FLOAT("mp_c4timer", 0);
|
||||
mp->m_iC4Timer = 0;
|
||||
m_iC4Timer = 0;
|
||||
}
|
||||
if (mp->m_iLimitTeams < 0)
|
||||
if (m_iLimitTeams < 0)
|
||||
{
|
||||
CVAR_SET_FLOAT("mp_limitteams", 0);
|
||||
mp->m_iLimitTeams = 0;
|
||||
m_iLimitTeams = 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
@ -485,11 +484,11 @@ CHalfLifeMultiplay::CHalfLifeMultiplay()
|
||||
|
||||
for (int j = 0; j < MAX_VIP_QUEUES; ++j)
|
||||
{
|
||||
VIPQueue[j] = NULL;
|
||||
m_pVIPQueue[j] = NULL;
|
||||
}
|
||||
|
||||
CVAR_SET_FLOAT("cl_himodels", 0);
|
||||
ReadMultiplayCvars(this);
|
||||
ReadMultiplayCvars();
|
||||
|
||||
m_iIntroRoundTime += 2;
|
||||
m_fMaxIdlePeriod = m_iRoundTime * 2;
|
||||
@ -1327,7 +1326,6 @@ bool CHalfLifeMultiplay::PrisonRoundEndCheck(int NumAliveTerrorist, int NumAlive
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool CHalfLifeMultiplay::Target_Bombed_internal(int winStatus, ScenarioEventEndRound event, float tmDelay) {
|
||||
|
||||
Broadcast("terwin");
|
||||
@ -1840,7 +1838,7 @@ void CHalfLifeMultiplay::__API_VHOOK(RestartRound)()
|
||||
m_bFreezePeriod = TRUE;
|
||||
m_bRoundTerminating = false;
|
||||
|
||||
ReadMultiplayCvars(this);
|
||||
ReadMultiplayCvars();
|
||||
|
||||
float flAutoKickIdle = CVAR_GET_FLOAT("mp_autokick_timeout");
|
||||
|
||||
@ -2195,19 +2193,19 @@ void CHalfLifeMultiplay::StackVIPQueue()
|
||||
{
|
||||
for (int i = MAX_VIP_QUEUES - 2; i > 0; --i)
|
||||
{
|
||||
if (VIPQueue[i - 1])
|
||||
if (m_pVIPQueue[i - 1])
|
||||
{
|
||||
if (!VIPQueue[i])
|
||||
if (!m_pVIPQueue[i])
|
||||
{
|
||||
VIPQueue[i] = VIPQueue[i + 1];
|
||||
VIPQueue[i + 1] = NULL;
|
||||
m_pVIPQueue[i] = m_pVIPQueue[i + 1];
|
||||
m_pVIPQueue[i + 1] = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
VIPQueue[i - 1] = VIPQueue[i];
|
||||
VIPQueue[i] = VIPQueue[i + 1];
|
||||
VIPQueue[i + 1] = NULL;
|
||||
m_pVIPQueue[i - 1] = m_pVIPQueue[i];
|
||||
m_pVIPQueue[i] = m_pVIPQueue[i + 1];
|
||||
m_pVIPQueue[i + 1] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2216,27 +2214,27 @@ bool CHalfLifeMultiplay::IsVIPQueueEmpty()
|
||||
{
|
||||
for (int i = 0; i < MAX_VIP_QUEUES; ++i)
|
||||
{
|
||||
CBasePlayer *toCheck = VIPQueue[i];
|
||||
CBasePlayer *toCheck = m_pVIPQueue[i];
|
||||
|
||||
if (toCheck != NULL && toCheck->m_iTeam != CT)
|
||||
{
|
||||
VIPQueue[i] = NULL;
|
||||
m_pVIPQueue[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
StackVIPQueue();
|
||||
return (VIPQueue[0] == NULL && VIPQueue[1] == NULL && VIPQueue[2] == NULL && VIPQueue[3] == NULL && VIPQueue[4] == NULL);
|
||||
return (m_pVIPQueue[0] == NULL && m_pVIPQueue[1] == NULL && m_pVIPQueue[2] == NULL && m_pVIPQueue[3] == NULL && m_pVIPQueue[4] == NULL);
|
||||
}
|
||||
|
||||
bool CHalfLifeMultiplay::AddToVIPQueue(CBasePlayer *toAdd)
|
||||
{
|
||||
for (int i = 0; i < MAX_VIP_QUEUES; ++i)
|
||||
{
|
||||
CBasePlayer *toCheck = VIPQueue[i];
|
||||
CBasePlayer *toCheck = m_pVIPQueue[i];
|
||||
|
||||
if (toCheck != NULL && toCheck->m_iTeam != CT)
|
||||
{
|
||||
VIPQueue[i] = NULL;
|
||||
m_pVIPQueue[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2247,7 +2245,7 @@ bool CHalfLifeMultiplay::AddToVIPQueue(CBasePlayer *toAdd)
|
||||
int j;
|
||||
for (j = 0; j < MAX_VIP_QUEUES; ++j)
|
||||
{
|
||||
if (VIPQueue[j] == toAdd)
|
||||
if (m_pVIPQueue[j] == toAdd)
|
||||
{
|
||||
ClientPrint(toAdd->pev, HUD_PRINTCENTER, "#Game_in_position", UTIL_dtos1(j + 1));
|
||||
return FALSE;
|
||||
@ -2256,9 +2254,9 @@ bool CHalfLifeMultiplay::AddToVIPQueue(CBasePlayer *toAdd)
|
||||
|
||||
for (j = 0; j < MAX_VIP_QUEUES; ++j)
|
||||
{
|
||||
if (!VIPQueue[j])
|
||||
if (!m_pVIPQueue[j])
|
||||
{
|
||||
VIPQueue[j] = toAdd;
|
||||
m_pVIPQueue[j] = toAdd;
|
||||
|
||||
StackVIPQueue();
|
||||
ClientPrint(toAdd->pev, HUD_PRINTCENTER, "#Game_added_position", UTIL_dtos1(j + 1));
|
||||
@ -2320,12 +2318,12 @@ void CHalfLifeMultiplay::PickNextVIP()
|
||||
|
||||
for (int i = 0; i < MAX_VIP_QUEUES; ++i)
|
||||
{
|
||||
if (VIPQueue[i] != NULL)
|
||||
if (m_pVIPQueue[i] != NULL)
|
||||
{
|
||||
m_pVIP = VIPQueue[i];
|
||||
m_pVIP = m_pVIPQueue[i];
|
||||
m_pVIP->MakeVIP();
|
||||
|
||||
VIPQueue[i] = NULL; // remove this player from the VIP queue
|
||||
m_pVIPQueue[i] = NULL; // remove this player from the VIP queue
|
||||
StackVIPQueue(); // and re-organize the queue
|
||||
m_iConsecutiveVIP = 0;
|
||||
return;
|
||||
@ -3772,9 +3770,11 @@ void CHalfLifeMultiplay::__API_VHOOK(DeathNotice)(CBasePlayer *pVictim, entvars_
|
||||
const char *killer_weapon_name = "world";
|
||||
int killer_index = 0;
|
||||
|
||||
#ifndef REGAMEDLL_FIXES
|
||||
// Hack to fix name change
|
||||
char *tau = "tau_cannon";
|
||||
char *gluon = "gluon gun";
|
||||
#endif
|
||||
|
||||
// Is the killer a client?
|
||||
if (pKiller->flags & FL_CLIENT)
|
||||
@ -3801,6 +3801,9 @@ void CHalfLifeMultiplay::__API_VHOOK(DeathNotice)(CBasePlayer *pVictim, entvars_
|
||||
}
|
||||
}
|
||||
else
|
||||
#ifdef REGAMEDLL_FIXES
|
||||
if (pevInflictor)
|
||||
#endif
|
||||
killer_weapon_name = STRING(pevInflictor->classname);
|
||||
|
||||
// strip the monster_* or weapon_* from the inflictor's classname
|
||||
@ -3828,12 +3831,15 @@ void CHalfLifeMultiplay::__API_VHOOK(DeathNotice)(CBasePlayer *pVictim, entvars_
|
||||
MESSAGE_END();
|
||||
}
|
||||
|
||||
// This weapons from HL isn't it?
|
||||
#ifndef REGAMEDLL_FIXES
|
||||
// replace the code names with the 'real' names
|
||||
if (!Q_strcmp(killer_weapon_name, "egon"))
|
||||
killer_weapon_name = gluon;
|
||||
|
||||
else if (!Q_strcmp(killer_weapon_name, "gauss"))
|
||||
killer_weapon_name = tau;
|
||||
#endif
|
||||
|
||||
// Did he kill himself?
|
||||
if (pVictim->pev == pKiller)
|
||||
@ -4789,3 +4795,48 @@ void CHalfLifeMultiplay::__API_VHOOK(ClientUserInfoChanged)(CBasePlayer *pPlayer
|
||||
pPlayer->SetPlayerModel(pPlayer->m_bHasC4);
|
||||
pPlayer->SetPrefsFromUserinfo(infobuffer);
|
||||
}
|
||||
|
||||
void CHalfLifeMultiplay::ServerActivate()
|
||||
{
|
||||
// Check to see if there's a mapping info paramater entity
|
||||
CMapInfo *mi = (CMapInfo *)UTIL_FindEntityByClassname(NULL, "info_map_parameters");
|
||||
if (mi != nullptr)
|
||||
{
|
||||
switch (mi->m_iBuyingStatus)
|
||||
{
|
||||
case BUYING_EVERYONE:
|
||||
m_bCTCantBuy = false;
|
||||
m_bTCantBuy = false;
|
||||
|
||||
ALERT(at_console, "EVERYONE CAN BUY!\n");
|
||||
break;
|
||||
case BUYING_ONLY_CTS:
|
||||
m_bCTCantBuy = false;
|
||||
m_bTCantBuy = true;
|
||||
|
||||
ALERT(at_console, "Only CT's can buy!!\n");
|
||||
break;
|
||||
case BUYING_ONLY_TERRORISTS:
|
||||
m_bCTCantBuy = true;
|
||||
m_bTCantBuy = false;
|
||||
|
||||
ALERT(at_console, "Only T's can buy!!\n");
|
||||
break;
|
||||
case BUYING_NO_ONE:
|
||||
m_bCTCantBuy = true;
|
||||
m_bTCantBuy = true;
|
||||
|
||||
ALERT(at_console, "No one can buy!!\n");
|
||||
break;
|
||||
default:
|
||||
m_bCTCantBuy = false;
|
||||
m_bTCantBuy = false;
|
||||
break;
|
||||
}
|
||||
|
||||
m_flBombRadius = mi->m_flBombRadius;
|
||||
}
|
||||
|
||||
ReadMultiplayCvars();
|
||||
CheckMapConditions();
|
||||
}
|
||||
|
@ -285,16 +285,16 @@ void WriteSigonMessages()
|
||||
|
||||
LINK_ENTITY_TO_CLASS(player, CBasePlayer, CCSPlayer);
|
||||
|
||||
void SendItemStatus(CBasePlayer *pPlayer)
|
||||
void CBasePlayer::SendItemStatus()
|
||||
{
|
||||
int itemStatus = 0;
|
||||
if (pPlayer->m_bHasNightVision)
|
||||
if (m_bHasNightVision)
|
||||
itemStatus |= ITEM_STATUS_NIGHTVISION;
|
||||
|
||||
if (pPlayer->m_bHasDefuser)
|
||||
if (m_bHasDefuser)
|
||||
itemStatus |= ITEM_STATUS_DEFUSER;
|
||||
|
||||
MESSAGE_BEGIN(MSG_ONE, gmsgItemStatus, NULL, pPlayer->pev);
|
||||
MESSAGE_BEGIN(MSG_ONE, gmsgItemStatus, NULL, pev);
|
||||
WRITE_BYTE(itemStatus);
|
||||
MESSAGE_END();
|
||||
}
|
||||
@ -1548,7 +1548,7 @@ void CBasePlayer::RemoveAllItems(BOOL removeSuit)
|
||||
WRITE_STRING("defuser");
|
||||
MESSAGE_END();
|
||||
|
||||
SendItemStatus(this);
|
||||
SendItemStatus();
|
||||
bKillProgBar = true;
|
||||
}
|
||||
|
||||
@ -2165,7 +2165,7 @@ void CBasePlayer::__API_VHOOK(Killed)(entvars_t *pevAttacker, int iGib)
|
||||
WRITE_STRING("defuser");
|
||||
MESSAGE_END();
|
||||
|
||||
SendItemStatus(this);
|
||||
SendItemStatus();
|
||||
}
|
||||
|
||||
if (m_bIsDefusing)
|
||||
@ -3284,7 +3284,7 @@ void CBasePlayer::JoiningThink()
|
||||
m_fLastMovement = gpGlobals->time;
|
||||
m_bMissionBriefing = false;
|
||||
|
||||
SendItemStatus(this);
|
||||
SendItemStatus();
|
||||
break;
|
||||
}
|
||||
case READINGLTEXT:
|
||||
@ -3469,7 +3469,7 @@ void CBasePlayer::Disappear()
|
||||
WRITE_STRING("defuser");
|
||||
MESSAGE_END();
|
||||
|
||||
SendItemStatus(this);
|
||||
SendItemStatus();
|
||||
SetProgressBarTime(0);
|
||||
}
|
||||
|
||||
@ -4082,7 +4082,6 @@ bool CBasePlayer::CanPlayerBuy(bool display)
|
||||
}
|
||||
|
||||
int buyTime = int(CVAR_GET_FLOAT("mp_buytime") * 60.0f);
|
||||
|
||||
if (buyTime < MIN_BUY_TIME)
|
||||
{
|
||||
buyTime = MIN_BUY_TIME;
|
||||
@ -4951,10 +4950,9 @@ bool CBasePlayer::SelectSpawnSpot(const char *pEntClassName, CBaseEntity *&pSpot
|
||||
return false;
|
||||
}
|
||||
|
||||
edict_t *EntSelectSpawnPoint(CBaseEntity *pPlayer)
|
||||
edict_t *CBasePlayer::EntSelectSpawnPoint()
|
||||
{
|
||||
CBaseEntity *pSpot;
|
||||
edict_t *player = pPlayer->edict();
|
||||
|
||||
// choose a info_player_deathmatch point
|
||||
if (g_pGameRules->IsCoOp())
|
||||
@ -4970,7 +4968,7 @@ edict_t *EntSelectSpawnPoint(CBaseEntity *pPlayer)
|
||||
goto ReturnSpot;
|
||||
}
|
||||
// VIP spawn point
|
||||
else if (g_pGameRules->IsDeathmatch() && ((CBasePlayer *)pPlayer)->m_bIsVIP)
|
||||
else if (g_pGameRules->IsDeathmatch() && m_bIsVIP)
|
||||
{
|
||||
pSpot = UTIL_FindEntityByClassname(NULL, "info_vip_start");
|
||||
|
||||
@ -4983,22 +4981,22 @@ edict_t *EntSelectSpawnPoint(CBaseEntity *pPlayer)
|
||||
goto CTSpawn;
|
||||
}
|
||||
// the counter-terrorist spawns at "info_player_start"
|
||||
else if (g_pGameRules->IsDeathmatch() && ((CBasePlayer *)pPlayer)->m_iTeam == CT)
|
||||
else if (g_pGameRules->IsDeathmatch() && m_iTeam == CT)
|
||||
{
|
||||
CTSpawn:
|
||||
pSpot = g_pLastCTSpawn;
|
||||
|
||||
if (((CBasePlayer *)pPlayer)->SelectSpawnSpot("info_player_start", pSpot))
|
||||
if (SelectSpawnSpot("info_player_start", pSpot))
|
||||
{
|
||||
goto ReturnSpot;
|
||||
}
|
||||
}
|
||||
// The terrorist spawn points
|
||||
else if (g_pGameRules->IsDeathmatch() && ((CBasePlayer *)pPlayer)->m_iTeam == TERRORIST)
|
||||
else if (g_pGameRules->IsDeathmatch() && m_iTeam == TERRORIST)
|
||||
{
|
||||
pSpot = g_pLastTerroristSpawn;
|
||||
|
||||
if (((CBasePlayer *)pPlayer)->SelectSpawnSpot("info_player_deathmatch", pSpot))
|
||||
if (SelectSpawnSpot("info_player_deathmatch", pSpot))
|
||||
{
|
||||
goto ReturnSpot;
|
||||
}
|
||||
@ -5027,7 +5025,7 @@ ReturnSpot:
|
||||
return INDEXENT(0);
|
||||
}
|
||||
|
||||
if (((CBasePlayer *)pPlayer)->m_iTeam == TERRORIST)
|
||||
if (m_iTeam == TERRORIST)
|
||||
g_pLastTerroristSpawn = pSpot;
|
||||
else
|
||||
g_pLastCTSpawn = pSpot;
|
||||
@ -5035,22 +5033,22 @@ ReturnSpot:
|
||||
return pSpot->edict();
|
||||
}
|
||||
|
||||
void SetScoreAttrib(CBasePlayer *dest, CBasePlayer *src)
|
||||
void CBasePlayer::SetScoreAttrib(CBasePlayer *dest)
|
||||
{
|
||||
int state = 0;
|
||||
if (src->pev->deadflag != DEAD_NO)
|
||||
if (pev->deadflag != DEAD_NO)
|
||||
state |= SCORE_STATUS_DEAD;
|
||||
|
||||
if (src->m_bHasC4)
|
||||
if (m_bHasC4)
|
||||
state |= SCORE_STATUS_BOMB;
|
||||
|
||||
if (src->m_bIsVIP)
|
||||
if (m_bIsVIP)
|
||||
state |= SCORE_STATUS_VIP;
|
||||
|
||||
if (gmsgScoreAttrib)
|
||||
{
|
||||
MESSAGE_BEGIN(MSG_ONE, gmsgScoreAttrib, NULL, dest->pev);
|
||||
WRITE_BYTE(src->entindex());
|
||||
WRITE_BYTE(entindex());
|
||||
WRITE_BYTE(state);
|
||||
MESSAGE_END();
|
||||
}
|
||||
@ -5291,7 +5289,7 @@ void CBasePlayer::__API_VHOOK(Spawn)()
|
||||
m_bHasPrimary = false;
|
||||
m_bHasNightVision = false;
|
||||
|
||||
SendItemStatus(this);
|
||||
SendItemStatus();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -5383,6 +5381,13 @@ void CBasePlayer::__API_VHOOK(Spawn)()
|
||||
|
||||
for (i = 0; i < COMMANDS_TO_TRACK; ++i)
|
||||
m_flLastCommandTime[i] = -1;
|
||||
|
||||
#ifdef REGAMEDLL_FIXES
|
||||
if (!m_bJustConnected) {
|
||||
FireTargets("game_playerspawn", this, this, USE_TOGGLE, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
LINK_HOOK_CLASS_VOID_CHAIN2(CBasePlayer, Precache);
|
||||
@ -5441,7 +5446,7 @@ void CBasePlayer::SetScoreboardAttributes(CBasePlayer *destination)
|
||||
{
|
||||
if (destination != NULL)
|
||||
{
|
||||
SetScoreAttrib(destination, this);
|
||||
SetScoreAttrib(destination);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -5474,7 +5479,7 @@ int CBasePlayer::__MAKE_VHOOK(Restore)(CRestore &restore)
|
||||
ALERT(at_console, "No Landmark:%s\n", pSaveData->szLandmarkName);
|
||||
|
||||
// default to normal spawn
|
||||
edict_t *pentSpawnSpot = EntSelectSpawnPoint(this);
|
||||
edict_t *pentSpawnSpot = EntSelectSpawnPoint();
|
||||
|
||||
pev->origin = pentSpawnSpot->v.origin + Vector(0, 0, 1);
|
||||
pev->angles = pentSpawnSpot->v.angles;
|
||||
@ -5508,10 +5513,12 @@ void CBasePlayer::Reset()
|
||||
m_iDeaths = 0;
|
||||
m_iAccount = 0;
|
||||
|
||||
#ifndef REGAMEDLL_FIXES
|
||||
MESSAGE_BEGIN(MSG_ONE, gmsgMoney, NULL, pev);
|
||||
WRITE_LONG(m_iAccount);
|
||||
WRITE_BYTE(0);
|
||||
MESSAGE_END();
|
||||
#endif
|
||||
|
||||
m_bNotKilled = false;
|
||||
|
||||
@ -6640,8 +6647,9 @@ void CBasePlayer::__API_VHOOK(UpdateClientData)()
|
||||
SetObserverAutoDirector(false);
|
||||
}
|
||||
|
||||
#ifndef REGAMEDLL_FIXES
|
||||
FireTargets("game_playerspawn", this, this, USE_TOGGLE, 0);
|
||||
|
||||
#endif
|
||||
MESSAGE_BEGIN(MSG_ONE, gmsgMoney, NULL, pev);
|
||||
WRITE_LONG(m_iAccount);
|
||||
WRITE_BYTE(0);
|
||||
@ -7536,7 +7544,7 @@ void CBasePlayer::SwitchTeam()
|
||||
WRITE_STRING("defuser");
|
||||
MESSAGE_END();
|
||||
|
||||
SendItemStatus(this);
|
||||
SendItemStatus();
|
||||
SetProgressBarTime(0);
|
||||
|
||||
for (int i = 0; i < MAX_ITEM_TYPES; ++i)
|
||||
|
@ -584,11 +584,10 @@ public:
|
||||
void SetObserverAutoDirector(bool val) { m_bObserverAutoDirector = val; }
|
||||
bool IsObservingPlayer(CBasePlayer *pPlayer);
|
||||
bool CanSwitchObserverModes() const { return m_canSwitchObserverModes; }
|
||||
void Intense()
|
||||
{
|
||||
//m_musicState = INTENSE;
|
||||
//m_intenseTimestamp = gpGlobals->time;
|
||||
}
|
||||
void SendItemStatus();
|
||||
edict_t *EntSelectSpawnPoint();
|
||||
void SetScoreAttrib(CBasePlayer *dest);
|
||||
|
||||
#ifdef REGAMEDLL_ADD
|
||||
CCSPlayer *CSPlayer() const;
|
||||
#endif
|
||||
@ -954,8 +953,6 @@ void FixPlayerCrouchStuck(edict_t *pPlayer);
|
||||
BOOL IsSpawnPointValid(CBaseEntity *pPlayer, CBaseEntity *pSpot);
|
||||
void InitZombieSpawns();
|
||||
CBaseEntity *FindZombieSpawn(CBaseEntity *player, bool forceSpawn);
|
||||
edict_t *EntSelectSpawnPoint(CBaseEntity *pPlayer);
|
||||
void SetScoreAttrib(CBasePlayer *dest, CBasePlayer *src);
|
||||
CBaseEntity *FindEntityForward(CBaseEntity *pMe);
|
||||
float_precision GetPlayerPitch(const edict_t *pEdict);
|
||||
float_precision GetPlayerYaw(const edict_t *pEdict);
|
||||
|
@ -454,7 +454,7 @@ public:
|
||||
float m_flForceChaseCamValue;
|
||||
float m_flFadeToBlackValue;
|
||||
CBasePlayer *m_pVIP;
|
||||
CBasePlayer *VIPQueue[MAX_VIP_QUEUES];
|
||||
CBasePlayer *m_pVIPQueue[MAX_VIP_QUEUES];
|
||||
float m_flIntermissionEndTime;
|
||||
float m_flIntermissionStartTime;
|
||||
BOOL m_iEndIntermissionButtonHit;
|
||||
|
@ -30,6 +30,8 @@
|
||||
#include "regamedll_interfaces.h"
|
||||
#include "hookchains.h"
|
||||
#include "interface.h"
|
||||
#include "player.h"
|
||||
#include "gamerules.h"
|
||||
|
||||
#define REGAMEDLL_API_VERSION_MAJOR 2
|
||||
#define REGAMEDLL_API_VERSION_MINOR 1
|
||||
@ -140,8 +142,8 @@ typedef IVoidHookChain<const char *> IReGameHook_CBasePlayer_GiveNamedItem;
|
||||
typedef IVoidHookChainRegistryClass<class CBasePlayer, const char *> IReGameHookRegistry_CBasePlayer_GiveNamedItem;
|
||||
|
||||
// CBasePlayer::AddAccount hook
|
||||
typedef IVoidHookChain<int, enum RewardType, bool> IReGameHook_CBasePlayer_AddAccount;
|
||||
typedef IVoidHookChainRegistryClass<class CBasePlayer, int, enum RewardType, bool> IReGameHookRegistry_CBasePlayer_AddAccount;
|
||||
typedef IVoidHookChain<int, RewardType, bool> IReGameHook_CBasePlayer_AddAccount;
|
||||
typedef IVoidHookChainRegistryClass<class CBasePlayer, int, RewardType, bool> IReGameHookRegistry_CBasePlayer_AddAccount;
|
||||
|
||||
// CBasePlayer::GiveShield hook
|
||||
typedef IVoidHookChain<bool> IReGameHook_CBasePlayer_GiveShield;
|
||||
@ -173,8 +175,8 @@ typedef IVoidHookChain<class CBasePlayer *, struct entvars_s *, struct entvars_s
|
||||
typedef IVoidHookChainRegistry<class CBasePlayer *, struct entvars_s *, struct entvars_s *, Vector &, Vector &, struct TraceResult *> IReGameHookRegistry_RadiusFlash_TraceLine;
|
||||
|
||||
// RoundEnd hook
|
||||
typedef IHookChain<bool, int, enum ScenarioEventEndRound, float> IReGameHook_RoundEnd;
|
||||
typedef IHookChainRegistry<bool, int, enum ScenarioEventEndRound, float> IReGameHookRegistry_RoundEnd;
|
||||
typedef IHookChain<bool, int, ScenarioEventEndRound, float> IReGameHook_RoundEnd;
|
||||
typedef IHookChainRegistry<bool, int, ScenarioEventEndRound, float> IReGameHookRegistry_RoundEnd;
|
||||
|
||||
// CanBuyThis hook
|
||||
typedef IHookChain<bool, class CBasePlayer *, int> IReGameHook_CanBuyThis;
|
||||
|
@ -65,9 +65,17 @@ public:
|
||||
virtual void DropPlayerItem(const char *pszItemName);
|
||||
virtual void RemoveShield();
|
||||
virtual void RemoveAllItems(bool bRemoveSuit);
|
||||
virtual bool RemovePlayerItem(const char* pszItemName);
|
||||
virtual void SetPlayerModel(bool bHasC4);
|
||||
virtual void SetPlayerModelEx(const char *modelName);
|
||||
virtual void SetNewPlayerModel(const char *modelName);
|
||||
virtual void ClientCommand(const char *cmd, const char *arg1 = nullptr, const char *arg2 = nullptr, const char *arg3 = nullptr);
|
||||
virtual void SetProgressBarTime(int time);
|
||||
virtual void SetProgressBarTime2(int time, float timeElapsed);
|
||||
virtual struct edict_s *EntSelectSpawnPoint();
|
||||
virtual void SetBombIcon(bool bFlash = false);
|
||||
virtual void SetScoreAttrib(CBasePlayer *dest);
|
||||
virtual void SendItemStatus();
|
||||
|
||||
CBasePlayer *BasePlayer() const;
|
||||
public:
|
||||
|
@ -24,7 +24,8 @@
|
||||
* you do not wish to do so, delete this exception statement from your
|
||||
* version.
|
||||
*
|
||||
*/#ifndef ARCHTYPES_H
|
||||
*/
|
||||
#ifndef ARCHTYPES_H
|
||||
#define ARCHTYPES_H
|
||||
|
||||
#ifdef __x86_64__
|
||||
@ -33,8 +34,6 @@
|
||||
|
||||
#if defined( _WIN32 ) && (! defined( __MINGW32__ ))
|
||||
|
||||
typedef __int8 int8;
|
||||
typedef unsigned __int8 uint8;
|
||||
typedef __int16 int16;
|
||||
typedef unsigned __int16 uint16;
|
||||
typedef __int32 int32;
|
||||
@ -45,8 +44,7 @@ typedef __int32 intp; // intp is an integer that can accomodate a pointer
|
||||
typedef unsigned __int32 uintp; // (ie, sizeof(intp) >= sizeof(int) && sizeof(intp) >= sizeof(void *)
|
||||
|
||||
#else /* _WIN32 */
|
||||
typedef char int8;
|
||||
typedef unsigned char uint8;
|
||||
|
||||
typedef short int16;
|
||||
typedef unsigned short uint16;
|
||||
typedef int int32;
|
||||
|
@ -35,7 +35,7 @@
|
||||
#include "model.h"
|
||||
|
||||
#define REHLDS_API_VERSION_MAJOR 2
|
||||
#define REHLDS_API_VERSION_MINOR 11
|
||||
#define REHLDS_API_VERSION_MINOR 12
|
||||
|
||||
//Steam_NotifyClientConnect hook
|
||||
typedef IHookChain<qboolean, IGameClient*, const void*, unsigned int> IRehldsHook_Steam_NotifyClientConnect;
|
||||
@ -181,6 +181,10 @@ typedef IVoidHookChainRegistry<IGameClient *, struct usercmd_s *, int, int, int>
|
||||
typedef IVoidHookChain<> IRehldsHook_SV_Spawn_f;
|
||||
typedef IVoidHookChainRegistry<> IRehldsHookRegistry_SV_Spawn_f;
|
||||
|
||||
//SV_CreatePacketEntities hook
|
||||
typedef IHookChain<int, enum sv_delta_s, IGameClient *, struct packet_entities_s *, struct sizebuf_s *> IRehldsHook_SV_CreatePacketEntities;
|
||||
typedef IHookChainRegistry<int, enum sv_delta_s, IGameClient *, struct packet_entities_s *, struct sizebuf_s *> IRehldsHookRegistry_SV_CreatePacketEntities;
|
||||
|
||||
class IRehldsHookchains {
|
||||
public:
|
||||
virtual ~IRehldsHookchains() { }
|
||||
@ -221,6 +225,7 @@ public:
|
||||
virtual IRehldsHookRegistry_Cvar_DirectSet* Cvar_DirectSet() = 0;
|
||||
virtual IRehldsHookRegistry_SV_EstablishTimeBase* SV_EstablishTimeBase() = 0;
|
||||
virtual IRehldsHookRegistry_SV_Spawn_f* SV_Spawn_f() = 0;
|
||||
virtual IRehldsHookRegistry_SV_CreatePacketEntities* SV_CreatePacketEntities() = 0;
|
||||
};
|
||||
|
||||
struct RehldsFuncs_t {
|
||||
@ -283,4 +288,4 @@ public:
|
||||
virtual IRehldsFlightRecorder* GetFlightRecorder() = 0;
|
||||
};
|
||||
|
||||
#define VREHLDS_HLDS_API_VERSION "VREHLDS_HLDS_API_VERSION001"
|
||||
#define VREHLDS_HLDS_API_VERSION "VREHLDS_HLDS_API_VERSION001"
|
||||
|
@ -126,4 +126,7 @@ public:
|
||||
virtual double GetTime() = 0;
|
||||
virtual void SetResourcesNum(int num) = 0;
|
||||
virtual struct resource_s *GetResource(int index) = 0;
|
||||
virtual void SetName(const char* name) = 0;
|
||||
virtual class ISteamGameServer *GetSteamGameServer() = 0;
|
||||
virtual struct netadr_s *GetNetFrom() = 0;
|
||||
};
|
||||
|
300
regamedll/extra/cssdk/public/basetypes.h
Normal file
300
regamedll/extra/cssdk/public/basetypes.h
Normal file
@ -0,0 +1,300 @@
|
||||
//========= Copyright 1996-2001, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#ifndef BASETYPES_H
|
||||
#define BASETYPES_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "osconfig.h"
|
||||
#include "protected_things.h"
|
||||
#include "commonmacros.h"
|
||||
|
||||
|
||||
// For backward compatibilty only...
|
||||
//#include "tier0/platform.h"
|
||||
|
||||
// stdio.h
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
|
||||
#define ExecuteNTimes( nTimes, x ) \
|
||||
{ \
|
||||
static int __executeCount=0;\
|
||||
if ( __executeCount < nTimes )\
|
||||
{ \
|
||||
x; \
|
||||
++__executeCount; \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
#define ExecuteOnce( x ) ExecuteNTimes( 1, x )
|
||||
|
||||
|
||||
// Pad a number so it lies on an N byte boundary.
|
||||
// So PAD_NUMBER(0,4) is 0 and PAD_NUMBER(1,4) is 4
|
||||
#define PAD_NUMBER(number, boundary) \
|
||||
( ((number) + ((boundary)-1)) / (boundary) ) * (boundary)
|
||||
|
||||
// In case this ever changes
|
||||
#define M_PI 3.14159265358979323846
|
||||
|
||||
// #ifndef min
|
||||
// #define min(a,b) (((a) < (b)) ? (a) : (b))
|
||||
// #endif
|
||||
|
||||
// #ifndef max
|
||||
// #define max(a,b) (((a) > (b)) ? (a) : (b))
|
||||
// #endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
template<typename T>
|
||||
inline T clamp2(T const &val, T const &minVal, T const &maxVal) //renamed to clamp2 to avoid conflicts with clamp defined in mathlib
|
||||
{
|
||||
if (val < minVal)
|
||||
return minVal;
|
||||
else if (val > maxVal)
|
||||
return maxVal;
|
||||
else
|
||||
return val;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#define TRUE (!FALSE)
|
||||
#endif
|
||||
|
||||
|
||||
typedef int BOOL;
|
||||
typedef int qboolean;
|
||||
typedef unsigned long ULONG;
|
||||
typedef unsigned char BYTE;
|
||||
typedef unsigned char byte;
|
||||
typedef unsigned short word;
|
||||
|
||||
//#include "string_t.h"
|
||||
|
||||
typedef float vec_t;
|
||||
|
||||
|
||||
// FIXME: this should move
|
||||
#ifndef __cplusplus
|
||||
#define true TRUE
|
||||
#define false FALSE
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// look for NANs, infinities, and underflows.
|
||||
// This assumes the ANSI/IEEE 754-1985 standard
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
inline unsigned long& FloatBits(vec_t& f)
|
||||
{
|
||||
return *reinterpret_cast<unsigned long*>(&f);
|
||||
}
|
||||
|
||||
inline unsigned long const& FloatBits(vec_t const& f)
|
||||
{
|
||||
return *reinterpret_cast<unsigned long const*>(&f);
|
||||
}
|
||||
|
||||
inline vec_t BitsToFloat(unsigned long i)
|
||||
{
|
||||
return *reinterpret_cast<vec_t*>(&i);
|
||||
}
|
||||
|
||||
inline bool IsFinite(vec_t f)
|
||||
{
|
||||
return ((FloatBits(f) & 0x7F800000) != 0x7F800000);
|
||||
}
|
||||
|
||||
inline unsigned long FloatAbsBits(vec_t f)
|
||||
{
|
||||
return FloatBits(f) & 0x7FFFFFFF;
|
||||
}
|
||||
|
||||
inline float FloatMakeNegative(vec_t f)
|
||||
{
|
||||
return BitsToFloat(FloatBits(f) | 0x80000000);
|
||||
}
|
||||
|
||||
#if defined( WIN32 )
|
||||
|
||||
//#include <math.h>
|
||||
// Just use prototype from math.h
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
double __cdecl fabs(double);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
// In win32 try to use the intrinsic fabs so the optimizer can do it's thing inline in the code
|
||||
#pragma intrinsic( fabs )
|
||||
// Also, alias float make positive to use fabs, too
|
||||
// NOTE: Is there a perf issue with double<->float conversion?
|
||||
inline float FloatMakePositive(vec_t f)
|
||||
{
|
||||
return fabs(f);
|
||||
}
|
||||
#else
|
||||
inline float FloatMakePositive(vec_t f)
|
||||
{
|
||||
return BitsToFloat(FloatBits(f) & 0x7FFFFFFF);
|
||||
}
|
||||
#endif
|
||||
|
||||
inline float FloatNegate(vec_t f)
|
||||
{
|
||||
return BitsToFloat(FloatBits(f) ^ 0x80000000);
|
||||
}
|
||||
|
||||
|
||||
#define FLOAT32_NAN_BITS (unsigned long)0x7FC00000 // not a number!
|
||||
#define FLOAT32_NAN BitsToFloat( FLOAT32_NAN_BITS )
|
||||
|
||||
#define VEC_T_NAN FLOAT32_NAN
|
||||
|
||||
#endif
|
||||
|
||||
// FIXME: why are these here? Hardly anyone actually needs them.
|
||||
struct valve_color24
|
||||
{
|
||||
byte r, g, b;
|
||||
};
|
||||
|
||||
typedef struct valve_color32_s
|
||||
{
|
||||
bool operator!=(const struct valve_color32_s &other) const;
|
||||
|
||||
byte r, g, b, a;
|
||||
} valve_color32;
|
||||
|
||||
inline bool valve_color32::operator!=(const valve_color32 &other) const
|
||||
{
|
||||
return r != other.r || g != other.g || b != other.b || a != other.a;
|
||||
}
|
||||
|
||||
struct valve_colorRGBExp32
|
||||
{
|
||||
byte r, g, b;
|
||||
signed char exponent;
|
||||
};
|
||||
|
||||
struct valve_colorVec
|
||||
{
|
||||
unsigned r, g, b, a;
|
||||
};
|
||||
|
||||
|
||||
#ifndef UNUSED
|
||||
#define UNUSED(x) (x = x) // for pesky compiler / lint warnings
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
struct vrect_t
|
||||
{
|
||||
int x, y, width, height;
|
||||
vrect_t *pnext;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// MaterialRect_t struct - used for DrawDebugText
|
||||
//-----------------------------------------------------------------------------
|
||||
struct Rect_t
|
||||
{
|
||||
int x, y;
|
||||
int width, height;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Declares a type-safe handle type; you can't assign one handle to the next
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// 32-bit pointer handles.
|
||||
|
||||
// Typesafe 8-bit and 16-bit handles.
|
||||
template< class HandleType >
|
||||
class CBaseIntHandle
|
||||
{
|
||||
public:
|
||||
|
||||
inline bool operator==(const CBaseIntHandle &other) { return m_Handle == other.m_Handle; }
|
||||
inline bool operator!=(const CBaseIntHandle &other) { return m_Handle != other.m_Handle; }
|
||||
|
||||
// Only the code that doles out these handles should use these functions.
|
||||
// Everyone else should treat them as a transparent type.
|
||||
inline HandleType GetHandleValue() { return m_Handle; }
|
||||
inline void SetHandleValue(HandleType val) { m_Handle = val; }
|
||||
|
||||
typedef HandleType HANDLE_TYPE;
|
||||
|
||||
protected:
|
||||
|
||||
HandleType m_Handle;
|
||||
};
|
||||
|
||||
template< class DummyType >
|
||||
class CIntHandle16 : public CBaseIntHandle < unsigned short >
|
||||
{
|
||||
public:
|
||||
inline CIntHandle16() {}
|
||||
|
||||
static inline CIntHandle16<DummyType> MakeHandle(HANDLE_TYPE val)
|
||||
{
|
||||
return CIntHandle16<DummyType>(val);
|
||||
}
|
||||
|
||||
protected:
|
||||
inline CIntHandle16(HANDLE_TYPE val)
|
||||
{
|
||||
m_Handle = val;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template< class DummyType >
|
||||
class CIntHandle32 : public CBaseIntHandle < unsigned long >
|
||||
{
|
||||
public:
|
||||
inline CIntHandle32() {}
|
||||
|
||||
static inline CIntHandle32<DummyType> MakeHandle(HANDLE_TYPE val)
|
||||
{
|
||||
return CIntHandle32<DummyType>(val);
|
||||
}
|
||||
|
||||
protected:
|
||||
inline CIntHandle32(HANDLE_TYPE val)
|
||||
{
|
||||
m_Handle = val;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// NOTE: This macro is the same as windows uses; so don't change the guts of it
|
||||
#define DECLARE_HANDLE_16BIT(name) typedef CIntHandle16< struct name##__handle * > name;
|
||||
#define DECLARE_HANDLE_32BIT(name) typedef CIntHandle32< struct name##__handle * > name;
|
||||
|
||||
#define DECLARE_POINTER_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name
|
||||
#define FORWARD_DECLARE_HANDLE(name) typedef struct name##__ *name
|
||||
|
||||
#endif // BASETYPES_H
|
30
regamedll/extra/cssdk/public/commonmacros.h
Normal file
30
regamedll/extra/cssdk/public/commonmacros.h
Normal file
@ -0,0 +1,30 @@
|
||||
#ifndef COMMONMACROS_H
|
||||
#define COMMONMACROS_H
|
||||
#pragma once
|
||||
|
||||
|
||||
// -------------------------------------------------------
|
||||
//
|
||||
// commonmacros.h
|
||||
//
|
||||
// This should contain ONLY general purpose macros that are
|
||||
// appropriate for use in engine/launcher/all tools
|
||||
//
|
||||
// -------------------------------------------------------
|
||||
|
||||
#include "osconfig.h"
|
||||
// Makes a 4-byte "packed ID" int out of 4 characters
|
||||
#define MAKEID(d,c,b,a) ( ((int)(a) << 24) | ((int)(b) << 16) | ((int)(c) << 8) | ((int)(d)) )
|
||||
|
||||
// Compares a string with a 4-byte packed ID constant
|
||||
#define STRING_MATCHES_ID( p, id ) ( (*((int *)(p)) == (id) ) ? true : false )
|
||||
#define ID_TO_STRING( id, p ) ( (p)[3] = (((id)>>24) & 0xFF), (p)[2] = (((id)>>16) & 0xFF), (p)[1] = (((id)>>8) & 0xFF), (p)[0] = (((id)>>0) & 0xFF) )
|
||||
|
||||
#define ARRAYSIZE(p) (sizeof(p)/sizeof(p[0]))
|
||||
|
||||
// Keeps clutter down a bit, when using a float as a bit-vector
|
||||
#define SETBITS(flBitVector, bits) ((flBitVector) = (int)(flBitVector) | (bits))
|
||||
#define CLEARBITS(flBitVector, bits) ((flBitVector) = (int)(flBitVector) & ~(bits))
|
||||
#define FBitSet(flBitVector, bit) ((flBitVector) & (bit))
|
||||
|
||||
#endif // COMMONMACROS_H
|
187
regamedll/extra/cssdk/public/protected_things.h
Normal file
187
regamedll/extra/cssdk/public/protected_things.h
Normal file
@ -0,0 +1,187 @@
|
||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#ifndef PROTECTED_THINGS_H
|
||||
#define PROTECTED_THINGS_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
// This header tries to prevent people from using potentially dangerous functions
|
||||
// (like the notorious non-null-terminating strncpy) and functions that will break
|
||||
// VCR mode (like time, input, registry, etc).
|
||||
//
|
||||
// This header should be included by ALL of our source code.
|
||||
|
||||
// Eventually, ALL of these should be protected, but one man can only accomplish so much in
|
||||
// one day AND work on features too!
|
||||
#if defined( PROTECT_STRING_FUNCTIONS )
|
||||
#if defined( strncpy )
|
||||
#undef strncpy
|
||||
#endif
|
||||
#define strncpy strncpy__HEY_YOU__USE_VSTDLIB
|
||||
|
||||
|
||||
#if defined( _snprintf )
|
||||
#undef _snprintf
|
||||
#endif
|
||||
#define _snprintf snprintf__HEY_YOU__USE_VSTDLIB
|
||||
|
||||
|
||||
#if defined( sprintf )
|
||||
#undef sprintf
|
||||
#endif
|
||||
#define sprintf sprintf__HEY_YOU__USE_VSTDLIB
|
||||
|
||||
|
||||
#if defined( _vsnprintf )
|
||||
#undef _vsnprintf
|
||||
#endif
|
||||
#define _vsnprintf vsnprintf__HEY_YOU__USE_VSTDLIB
|
||||
|
||||
|
||||
#if defined( strcat )
|
||||
#undef strcat
|
||||
#endif
|
||||
#define strcat strcat__HEY_YOU__USE_VSTDLIB
|
||||
#endif
|
||||
|
||||
|
||||
#if defined( PROTECT_FILEIO_FUNCTIONS )
|
||||
#if defined( fopen )
|
||||
#undef fopen
|
||||
#endif
|
||||
#define fopen fopen_USE_FILESYSTEM_INSTEAD
|
||||
#endif
|
||||
|
||||
|
||||
#if defined( PROTECTED_THINGS_ENABLE )
|
||||
|
||||
#if defined( GetTickCount )
|
||||
#undef GetTickCount
|
||||
#endif
|
||||
#define GetTickCount GetTickCount__HEY_YOU__USE_PLATFORM_LIB
|
||||
|
||||
|
||||
#if defined( timeGetTime )
|
||||
#undef timeGetTime
|
||||
#endif
|
||||
#define timeGetTime timeGetTime__HEY_YOU__USE_PLATFORM_LIB
|
||||
|
||||
|
||||
#if defined( clock )
|
||||
#undef clock
|
||||
#endif
|
||||
#define time time__HEY_YOU__USE_PLATFORM_LIB
|
||||
|
||||
|
||||
#if defined( recvfrom )
|
||||
#undef recvfrom
|
||||
#endif
|
||||
#define recvfrom recvfrom__HEY_YOU__USE_PLATFORM_LIB
|
||||
|
||||
|
||||
#if defined( GetCursorPos )
|
||||
#undef GetCursorPos
|
||||
#endif
|
||||
#define GetCursorPos GetCursorPos__HEY_YOU__USE_PLATFORM_LIB
|
||||
|
||||
|
||||
#if defined( ScreenToClient )
|
||||
#undef ScreenToClient
|
||||
#endif
|
||||
#define ScreenToClient ScreenToClient__HEY_YOU__USE_PLATFORM_LIB
|
||||
|
||||
|
||||
#if defined( GetCommandLine )
|
||||
#undef GetCommandLine
|
||||
#endif
|
||||
#define GetCommandLine GetCommandLine__HEY_YOU__USE_PLATFORM_LIB
|
||||
|
||||
|
||||
#if defined( RegOpenKeyEx )
|
||||
#undef RegOpenKeyEx
|
||||
#endif
|
||||
#define RegOpenKeyEx RegOpenKeyEx__HEY_YOU__USE_PLATFORM_LIB
|
||||
|
||||
|
||||
#if defined( RegOpenKey )
|
||||
#undef RegOpenKey
|
||||
#endif
|
||||
#define RegOpenKey RegOpenKey__HEY_YOU__USE_PLATFORM_LIB
|
||||
|
||||
|
||||
#if defined( RegSetValueEx )
|
||||
#undef RegSetValueEx
|
||||
#endif
|
||||
#define RegSetValueEx RegSetValueEx__HEY_YOU__USE_PLATFORM_LIB
|
||||
|
||||
|
||||
#if defined( RegSetValue )
|
||||
#undef RegSetValue
|
||||
#endif
|
||||
#define RegSetValue RegSetValue__HEY_YOU__USE_PLATFORM_LIB
|
||||
|
||||
|
||||
#if defined( RegQueryValueEx )
|
||||
#undef RegQueryValueEx
|
||||
#endif
|
||||
#define RegQueryValueEx RegQueryValueEx__HEY_YOU__USE_PLATFORM_LIB
|
||||
|
||||
|
||||
#if defined( RegQueryValue )
|
||||
#undef RegQueryValue
|
||||
#endif
|
||||
#define RegQueryValue RegQueryValue__HEY_YOU__USE_PLATFORM_LIB
|
||||
|
||||
|
||||
#if defined( RegCreateKeyEx )
|
||||
#undef RegCreateKeyEx
|
||||
#endif
|
||||
#define RegCreateKeyEx RegCreateKeyEx__HEY_YOU__USE_PLATFORM_LIB
|
||||
|
||||
|
||||
#if defined( RegCreateKey )
|
||||
#undef RegCreateKey
|
||||
#endif
|
||||
#define RegCreateKey RegCreateKey__HEY_YOU__USE_PLATFORM_LIB
|
||||
|
||||
|
||||
#if defined( RegCloseKey )
|
||||
#undef RegCloseKey
|
||||
#endif
|
||||
#define RegCloseKey RegCloseKey__HEY_YOU__USE_PLATFORM_LIB
|
||||
|
||||
|
||||
#if defined( GetNumberOfConsoleInputEvents )
|
||||
#undef GetNumberOfConsoleInputEvents
|
||||
#endif
|
||||
#define GetNumberOfConsoleInputEvents GetNumberOfConsoleInputEvents__HEY_YOU__USE_PLATFORM_LIB
|
||||
|
||||
|
||||
#if defined( ReadConsoleInput )
|
||||
#undef ReadConsoleInput
|
||||
#endif
|
||||
#define ReadConsoleInput ReadConsoleInput__HEY_YOU__USE_PLATFORM_LIB
|
||||
|
||||
|
||||
#if defined( GetAsyncKeyState )
|
||||
#undef GetAsyncKeyState
|
||||
#endif
|
||||
#define GetAsyncKeyState GetAsyncKeyState__HEY_YOU__USE_PLATFORM_LIB
|
||||
|
||||
|
||||
#if defined( GetKeyState )
|
||||
#undef GetKeyState
|
||||
#endif
|
||||
#define GetKeyState GetKeyState__HEY_YOU__USE_PLATFORM_LIB
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif // PROTECTED_THINGS_H
|
444
regamedll/extra/cssdk/public/tier0/dbg.cpp
Normal file
444
regamedll/extra/cssdk/public/tier0/dbg.cpp
Normal file
@ -0,0 +1,444 @@
|
||||
//=========== (C) Copyright 1999 Valve, L.L.C. All rights reserved. ===========
|
||||
//
|
||||
// The copyright to the contents herein is the property of Valve, L.L.C.
|
||||
// The contents may be used and/or copied only with the written permission of
|
||||
// Valve, L.L.C., or in accordance with the terms and conditions stipulated in
|
||||
// the agreement/contract under which the contents have been supplied.
|
||||
//
|
||||
// $Header: $
|
||||
// $NoKeywords: $
|
||||
//
|
||||
// The main debug library implementation
|
||||
//=============================================================================
|
||||
|
||||
#include "precompiled.h"
|
||||
#include <assert.h>
|
||||
#include <malloc.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include "tier0/dbg.h"
|
||||
#include <math.h>
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// internal structures
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#define MAX_GROUP_NAME_LENGTH 48
|
||||
//enum
|
||||
//{
|
||||
// MAX_GROUP_NAME_LENGTH = 48
|
||||
//};
|
||||
|
||||
struct SpewGroup_t
|
||||
{
|
||||
char m_GroupName[MAX_GROUP_NAME_LENGTH];
|
||||
int m_Level;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Templates to assist in validating pointers:
|
||||
|
||||
void _AssertValidReadPtr(void* ptr, int count/* = 1*/)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
Assert(!IsBadReadPtr(ptr, count));
|
||||
#else
|
||||
Assert(ptr);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void _AssertValidWritePtr(void* ptr, int count/* = 1*/)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
Assert(!IsBadWritePtr(ptr, count));
|
||||
#else
|
||||
Assert(ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
void _AssertValidReadWritePtr(void* ptr, int count/* = 1*/)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
Assert(!(IsBadWritePtr(ptr, count) || IsBadReadPtr(ptr, count)));
|
||||
#else
|
||||
Assert(ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
void AssertValidStringPtr(const char* ptr, int maxchar/* = 0xFFFFFF */)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
Assert(!IsBadStringPtr(ptr, maxchar));
|
||||
#else
|
||||
Assert(ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// globals
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
SpewRetval_t DefaultSpewFunc(SpewType_t type, char const *pMsg)
|
||||
{
|
||||
printf("%s", pMsg);
|
||||
if (type == SPEW_ASSERT)
|
||||
return SPEW_DEBUGGER;
|
||||
else if (type == SPEW_ERROR)
|
||||
return SPEW_ABORT;
|
||||
else
|
||||
return SPEW_CONTINUE;
|
||||
}
|
||||
|
||||
static SpewOutputFunc_t s_SpewOutputFunc = DefaultSpewFunc;
|
||||
|
||||
static char const* s_pFileName;
|
||||
static int s_Line;
|
||||
static SpewType_t s_SpewType;
|
||||
|
||||
static SpewGroup_t* s_pSpewGroups = 0;
|
||||
static int s_GroupCount = 0;
|
||||
static int s_DefaultLevel = 0;
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Spew output management.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void SpewOutputFunc(SpewOutputFunc_t func)
|
||||
{
|
||||
s_SpewOutputFunc = func ? func : DefaultSpewFunc;
|
||||
}
|
||||
|
||||
SpewOutputFunc_t GetSpewOutputFunc(void)
|
||||
{
|
||||
if (s_SpewOutputFunc)
|
||||
{
|
||||
return s_SpewOutputFunc;
|
||||
}
|
||||
else
|
||||
{
|
||||
return DefaultSpewFunc;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Spew functions
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void _SpewInfo(SpewType_t type, char const* pFile, int line)
|
||||
{
|
||||
// Only grab the file name. Ignore the path.
|
||||
char const* pSlash = strrchr(pFile, '\\');
|
||||
char const* pSlash2 = strrchr(pFile, '/');
|
||||
if (pSlash < pSlash2) pSlash = pSlash2;
|
||||
|
||||
s_pFileName = pSlash ? pSlash + 1 : pFile;
|
||||
s_Line = line;
|
||||
s_SpewType = type;
|
||||
}
|
||||
|
||||
SpewRetval_t _SpewMessage(SpewType_t spewType, char const* pMsgFormat, va_list args)
|
||||
{
|
||||
char pTempBuffer[1024];
|
||||
|
||||
/* Printf the file and line for warning + assert only... */
|
||||
int len = 0;
|
||||
if ((spewType == SPEW_ASSERT))
|
||||
{
|
||||
len = sprintf(pTempBuffer, "%s (%d) : ", s_pFileName, s_Line);
|
||||
}
|
||||
|
||||
/* Create the message.... */
|
||||
len += vsprintf(&pTempBuffer[len], pMsgFormat, args);
|
||||
|
||||
// Add \n for warning and assert
|
||||
if ((spewType == SPEW_ASSERT))
|
||||
{
|
||||
len += sprintf(&pTempBuffer[len], "\n");
|
||||
}
|
||||
|
||||
assert(len < 1024); /* use normal assert here; to avoid recursion. */
|
||||
assert(s_SpewOutputFunc);
|
||||
|
||||
/* direct it to the appropriate target(s) */
|
||||
SpewRetval_t ret = s_SpewOutputFunc(spewType, pTempBuffer);
|
||||
switch (ret)
|
||||
{
|
||||
// Put the break into the macro so it would occur in the right place
|
||||
// case SPEW_DEBUGGER:
|
||||
// DebuggerBreak();
|
||||
// break;
|
||||
|
||||
case SPEW_ABORT:
|
||||
// MessageBox(NULL,"Error in _SpewMessage","Error",MB_OK);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
SpewRetval_t _SpewMessage(char const* pMsgFormat, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, pMsgFormat);
|
||||
SpewRetval_t ret = _SpewMessage(s_SpewType, pMsgFormat, args);
|
||||
va_end(args);
|
||||
return ret;
|
||||
}
|
||||
|
||||
SpewRetval_t _DSpewMessage(char const *pGroupName, int level, char const* pMsgFormat, ...)
|
||||
{
|
||||
if (!IsSpewActive(pGroupName, level))
|
||||
return SPEW_CONTINUE;
|
||||
|
||||
va_list args;
|
||||
va_start(args, pMsgFormat);
|
||||
SpewRetval_t ret = _SpewMessage(s_SpewType, pMsgFormat, args);
|
||||
va_end(args);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Msg(char const* pMsgFormat, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, pMsgFormat);
|
||||
_SpewMessage(SPEW_MESSAGE, pMsgFormat, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void DMsg(char const *pGroupName, int level, char const *pMsgFormat, ...)
|
||||
{
|
||||
if (!IsSpewActive(pGroupName, level))
|
||||
return;
|
||||
|
||||
va_list args;
|
||||
va_start(args, pMsgFormat);
|
||||
_SpewMessage(SPEW_MESSAGE, pMsgFormat, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void Warning(char const *pMsgFormat, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, pMsgFormat);
|
||||
_SpewMessage(SPEW_WARNING, pMsgFormat, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void DWarning(char const *pGroupName, int level, char const *pMsgFormat, ...)
|
||||
{
|
||||
if (!IsSpewActive(pGroupName, level))
|
||||
return;
|
||||
|
||||
va_list args;
|
||||
va_start(args, pMsgFormat);
|
||||
_SpewMessage(SPEW_WARNING, pMsgFormat, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void Log(char const *pMsgFormat, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, pMsgFormat);
|
||||
_SpewMessage(SPEW_LOG, pMsgFormat, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void DLog(char const *pGroupName, int level, char const *pMsgFormat, ...)
|
||||
{
|
||||
if (!IsSpewActive(pGroupName, level))
|
||||
return;
|
||||
|
||||
va_list args;
|
||||
va_start(args, pMsgFormat);
|
||||
_SpewMessage(SPEW_LOG, pMsgFormat, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void Error(char const *pMsgFormat, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, pMsgFormat);
|
||||
_SpewMessage(SPEW_ERROR, pMsgFormat, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// A couple of super-common dynamic spew messages, here for convenience
|
||||
// These looked at the "developer" group, print if it's level 1 or higher
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void DevMsg(int level, char const* pMsgFormat, ...)
|
||||
{
|
||||
if (!IsSpewActive("developer", level))
|
||||
return;
|
||||
|
||||
va_list args;
|
||||
va_start(args, pMsgFormat);
|
||||
_SpewMessage(SPEW_MESSAGE, pMsgFormat, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void DevWarning(int level, char const *pMsgFormat, ...)
|
||||
{
|
||||
if (!IsSpewActive("developer", level))
|
||||
return;
|
||||
|
||||
va_list args;
|
||||
va_start(args, pMsgFormat);
|
||||
_SpewMessage(SPEW_WARNING, pMsgFormat, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void DevLog(int level, char const *pMsgFormat, ...)
|
||||
{
|
||||
if (!IsSpewActive("developer", level))
|
||||
return;
|
||||
|
||||
va_list args;
|
||||
va_start(args, pMsgFormat);
|
||||
_SpewMessage(SPEW_LOG, pMsgFormat, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void DevMsg(char const *pMsgFormat, ...)
|
||||
{
|
||||
if (!IsSpewActive("developer", 1))
|
||||
return;
|
||||
|
||||
va_list args;
|
||||
va_start(args, pMsgFormat);
|
||||
_SpewMessage(SPEW_MESSAGE, pMsgFormat, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void DevWarning(char const *pMsgFormat, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, pMsgFormat);
|
||||
_SpewMessage(SPEW_WARNING, pMsgFormat, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void DevLog(char const *pMsgFormat, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, pMsgFormat);
|
||||
_SpewMessage(SPEW_LOG, pMsgFormat, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Find a group, return true if found, false if not. Return in ind the
|
||||
// index of the found group, or the index of the group right before where the
|
||||
// group should be inserted into the list to maintain sorted order.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool FindSpewGroup(char const* pGroupName, int* pInd)
|
||||
{
|
||||
int s = 0;
|
||||
if (s_GroupCount)
|
||||
{
|
||||
int e = (int)(s_GroupCount - 1);
|
||||
while (s <= e)
|
||||
{
|
||||
int m = (s + e) >> 1;
|
||||
int cmp = Q_stricmp(pGroupName, s_pSpewGroups[m].m_GroupName);
|
||||
if (!cmp)
|
||||
{
|
||||
*pInd = m;
|
||||
return true;
|
||||
}
|
||||
if (cmp < 0)
|
||||
e = m - 1;
|
||||
else
|
||||
s = m + 1;
|
||||
}
|
||||
}
|
||||
*pInd = s;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Sets the priority level for a spew group
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void SpewActivate(char const* pGroupName, int level)
|
||||
{
|
||||
Assert(pGroupName);
|
||||
|
||||
// check for the default group first...
|
||||
if ((pGroupName[0] == '*') && (pGroupName[1] == '\0'))
|
||||
{
|
||||
s_DefaultLevel = level;
|
||||
return;
|
||||
}
|
||||
|
||||
// Normal case, search in group list using binary search.
|
||||
// If not found, grow the list of groups and insert it into the
|
||||
// right place to maintain sorted order. Then set the level.
|
||||
int ind;
|
||||
if (!FindSpewGroup(pGroupName, &ind))
|
||||
{
|
||||
// not defined yet, insert an entry.
|
||||
++s_GroupCount;
|
||||
if (s_pSpewGroups)
|
||||
{
|
||||
s_pSpewGroups = (SpewGroup_t*)realloc(s_pSpewGroups,
|
||||
s_GroupCount * sizeof(SpewGroup_t));
|
||||
|
||||
// shift elements down to preserve order
|
||||
int numToMove = s_GroupCount - ind - 1;
|
||||
memmove(&s_pSpewGroups[ind + 1], &s_pSpewGroups[ind],
|
||||
numToMove * sizeof(SpewGroup_t));
|
||||
}
|
||||
else
|
||||
s_pSpewGroups = (SpewGroup_t*)malloc(s_GroupCount * sizeof(SpewGroup_t));
|
||||
|
||||
Assert(strlen(pGroupName) < MAX_GROUP_NAME_LENGTH);
|
||||
strcpy(s_pSpewGroups[ind].m_GroupName, pGroupName);
|
||||
}
|
||||
s_pSpewGroups[ind].m_Level = level;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Tests to see if a particular spew is active
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool IsSpewActive(char const* pGroupName, int level)
|
||||
{
|
||||
// If we don't find the spew group, use the default level.
|
||||
int ind;
|
||||
if (FindSpewGroup(pGroupName, &ind))
|
||||
return s_pSpewGroups[ind].m_Level >= level;
|
||||
else
|
||||
return s_DefaultLevel >= level;
|
||||
}
|
||||
|
||||
|
||||
// If we don't have a function from math.h, then it doesn't link certain floating-point
|
||||
// functions in and printfs with %f cause runtime errors in the C libraries.
|
||||
float CrackSmokingCompiler(float a)
|
||||
{
|
||||
return fabs(a);
|
||||
}
|
||||
|
||||
void* Plat_SimpleLog(const char* file, int line)
|
||||
{
|
||||
FILE* f = fopen("simple.log", "at+");
|
||||
fprintf(f, "%s:%i\n", file, line);
|
||||
fclose(f);
|
||||
|
||||
return NULL;
|
||||
}
|
451
regamedll/extra/cssdk/public/tier0/dbg.h
Normal file
451
regamedll/extra/cssdk/public/tier0/dbg.h
Normal file
@ -0,0 +1,451 @@
|
||||
//=========== (C) Copyright 1999 Valve, L.L.C. All rights reserved. ===========
|
||||
//
|
||||
// The copyright to the contents herein is the property of Valve, L.L.C.
|
||||
// The contents may be used and/or copied only with the written permission of
|
||||
// Valve, L.L.C., or in accordance with the terms and conditions stipulated in
|
||||
// the agreement/contract under which the contents have been supplied.
|
||||
//
|
||||
// $Header: $
|
||||
// $NoKeywords: $
|
||||
//
|
||||
// The main debug library interfaces
|
||||
//=============================================================================
|
||||
|
||||
|
||||
#ifndef DBG_H
|
||||
#define DBG_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "osconfig.h"
|
||||
#include "basetypes.h"
|
||||
#include "tier0/platform.h"
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// dll export stuff
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifdef TIER0_DLL_EXPORT
|
||||
#define DBG_INTERFACE DLL_EXPORT
|
||||
#define DBG_OVERLOAD DLL_GLOBAL_EXPORT
|
||||
#define DBG_CLASS DLL_CLASS_EXPORT
|
||||
#else
|
||||
#define DBG_INTERFACE DLL_IMPORT
|
||||
#define DBG_OVERLOAD DLL_GLOBAL_IMPORT
|
||||
#define DBG_CLASS DLL_CLASS_IMPORT
|
||||
#endif
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Usage model for the Dbg library
|
||||
//
|
||||
// 1. Spew.
|
||||
//
|
||||
// Spew can be used in a static and a dynamic mode. The static
|
||||
// mode allows us to display assertions and other messages either only
|
||||
// in debug builds, or in non-release builds. The dynamic mode allows us to
|
||||
// turn on and off certain spew messages while the application is running.
|
||||
//
|
||||
// Static Spew messages:
|
||||
//
|
||||
// Assertions are used to detect and warn about invalid states
|
||||
// Spews are used to display a particular status/warning message.
|
||||
//
|
||||
// To use an assertion, use
|
||||
//
|
||||
// Assert( (f == 5) );
|
||||
// AssertMsg( (f == 5), ("F needs to be %d here!\n", 5) );
|
||||
// AssertFunc( (f == 5), BadFunc() );
|
||||
// AssertEquals( f, 5 );
|
||||
// AssertFloatEquals( f, 5.0f, 1e-3 );
|
||||
//
|
||||
// The first will simply report that an assertion failed on a particular
|
||||
// code file and line. The second version will display a print-f formatted message
|
||||
// along with the file and line, the third will display a generic message and
|
||||
// will also cause the function BadFunc to be executed, and the last two
|
||||
// will report an error if f is not equal to 5 (the last one asserts within
|
||||
// a particular tolerance).
|
||||
//
|
||||
// To use a warning, use
|
||||
//
|
||||
// Warning("Oh I feel so %s all over\n", "yummy");
|
||||
//
|
||||
// Warning will do its magic in only Debug builds. To perform spew in *all*
|
||||
// builds, use RelWarning.
|
||||
//
|
||||
// Three other spew types, Msg, Log, and Error, are compiled into all builds.
|
||||
// These error types do *not* need two sets of parenthesis.
|
||||
//
|
||||
// Msg( "Isn't this exciting %d?", 5 );
|
||||
// Error( "I'm just thrilled" );
|
||||
//
|
||||
// Dynamic Spew messages
|
||||
//
|
||||
// It is possible to dynamically turn spew on and off. Dynamic spew is
|
||||
// identified by a spew group and priority level. To turn spew on for a
|
||||
// particular spew group, use SpewActivate( "group", level ). This will
|
||||
// cause all spew in that particular group with priority levels <= the
|
||||
// level specified in the SpewActivate function to be printed. Use DSpew
|
||||
// to perform the spew:
|
||||
//
|
||||
// DWarning( "group", level, "Oh I feel even yummier!\n" );
|
||||
//
|
||||
// Priority level 0 means that the spew will *always* be printed, and group
|
||||
// '*' is the default spew group. If a DWarning is encountered using a group
|
||||
// whose priority has not been set, it will use the priority of the default
|
||||
// group. The priority of the default group is initially set to 0.
|
||||
//
|
||||
// Spew output
|
||||
//
|
||||
// The output of the spew system can be redirected to an externally-supplied
|
||||
// function which is responsible for outputting the spew. By default, the
|
||||
// spew is simply printed using printf.
|
||||
//
|
||||
// To redirect spew output, call SpewOutput.
|
||||
//
|
||||
// SpewOutputFunc( OutputFunc );
|
||||
//
|
||||
// This will cause OutputFunc to be called every time a spew message is
|
||||
// generated. OutputFunc will be passed a spew type and a message to print.
|
||||
// It must return a value indicating whether the debugger should be invoked,
|
||||
// whether the program should continue running, or whether the program
|
||||
// should abort.
|
||||
//
|
||||
// 2. Code activation
|
||||
//
|
||||
// To cause code to be run only in debug builds, use DBG_CODE:
|
||||
// An example is below.
|
||||
//
|
||||
// DBG_CODE(
|
||||
// {
|
||||
// int x = 5;
|
||||
// ++x;
|
||||
// }
|
||||
// );
|
||||
//
|
||||
// Code can be activated based on the dynamic spew groups also. Use
|
||||
//
|
||||
// DBG_DCODE( "group", level,
|
||||
// { int x = 5; ++x; }
|
||||
// );
|
||||
//
|
||||
// 3. Breaking into the debugger.
|
||||
//
|
||||
// To cause an unconditional break into the debugger in debug builds only, use DBG_BREAK
|
||||
//
|
||||
// DBG_BREAK();
|
||||
//
|
||||
// You can force a break in any build (release or debug) using
|
||||
//
|
||||
// DebuggerBreak();
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/* Various types of spew messages */
|
||||
// I'm sure you're asking yourself why SPEW_ instead of DBG_ ?
|
||||
// It's because DBG_ is used all over the place in windows.h
|
||||
// For example, DBG_CONTINUE is defined. Feh.
|
||||
enum SpewType_t
|
||||
{
|
||||
SPEW_MESSAGE = 0,
|
||||
SPEW_WARNING,
|
||||
SPEW_ASSERT,
|
||||
SPEW_ERROR,
|
||||
SPEW_LOG,
|
||||
|
||||
SPEW_TYPE_COUNT
|
||||
};
|
||||
|
||||
enum SpewRetval_t
|
||||
{
|
||||
SPEW_DEBUGGER = 0,
|
||||
SPEW_CONTINUE,
|
||||
SPEW_ABORT
|
||||
};
|
||||
|
||||
/* type of externally defined function used to display debug spew */
|
||||
typedef SpewRetval_t(*SpewOutputFunc_t)(SpewType_t spewType, char const *pMsg);
|
||||
|
||||
/* Used to redirect spew output */
|
||||
void SpewOutputFunc(SpewOutputFunc_t func);
|
||||
|
||||
/* Used ot get the current spew output function */
|
||||
SpewOutputFunc_t GetSpewOutputFunc(void);
|
||||
|
||||
/* Used to manage spew groups and subgroups */
|
||||
void SpewActivate(char const* pGroupName, int level);
|
||||
bool IsSpewActive(char const* pGroupName, int level);
|
||||
|
||||
/* Used to display messages, should never be called directly. */
|
||||
void _SpewInfo(SpewType_t type, char const* pFile, int line);
|
||||
SpewRetval_t _SpewMessage(char const* pMsg, ...);
|
||||
SpewRetval_t _DSpewMessage(char const *pGroupName, int level, char const* pMsg, ...);
|
||||
|
||||
/* Used to define macros, never use these directly. */
|
||||
#define _Assert( _exp ) do { \
|
||||
if (!(_exp)) \
|
||||
{ \
|
||||
_SpewInfo( SPEW_ASSERT, __FILE__, __LINE__ ); \
|
||||
if (_SpewMessage("Assertion Failed: " #_exp) == SPEW_DEBUGGER) \
|
||||
{ \
|
||||
DebuggerBreak(); \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define _AssertMsg( _exp, _msg ) do { \
|
||||
if (!(_exp)) \
|
||||
{ \
|
||||
_SpewInfo( SPEW_ASSERT, __FILE__, __LINE__ ); \
|
||||
if (_SpewMessage(_msg) == SPEW_DEBUGGER) \
|
||||
{ \
|
||||
DebuggerBreak(); \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define _AssertFunc( _exp, _f ) do { \
|
||||
if (!(_exp)) \
|
||||
{ \
|
||||
_SpewInfo( SPEW_ASSERT, __FILE__, __LINE__ ); \
|
||||
SpewRetval_t ret = _SpewMessage("Assertion Failed!" #_exp); \
|
||||
_f; \
|
||||
if (ret == SPEW_DEBUGGER) \
|
||||
{ \
|
||||
DebuggerBreak(); \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define _AssertEquals( _exp, _expectedValue ) \
|
||||
do { \
|
||||
if ((_exp) != (_expectedValue)) \
|
||||
{ \
|
||||
_SpewInfo( SPEW_ASSERT, __FILE__, __LINE__ ); \
|
||||
SpewRetval_t ret = _SpewMessage("Expected %d but got %d!", (_expectedValue), (_exp)); \
|
||||
if (ret == SPEW_DEBUGGER) \
|
||||
{ \
|
||||
DebuggerBreak(); \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define _AssertFloatEquals( _exp, _expectedValue, _tol ) \
|
||||
do { \
|
||||
if (fabs((_exp) - (_expectedValue)) > (_tol)) \
|
||||
{ \
|
||||
_SpewInfo( SPEW_ASSERT, __FILE__, __LINE__ ); \
|
||||
SpewRetval_t ret = _SpewMessage("Expected %f but got %f!", (_expectedValue), (_exp)); \
|
||||
if (ret == SPEW_DEBUGGER) \
|
||||
{ \
|
||||
DebuggerBreak(); \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/* Spew macros... */
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
#define Assert( _exp ) _Assert( _exp )
|
||||
#define AssertMsg( _exp, _msg ) _AssertMsg( _exp, _msg )
|
||||
#define AssertFunc( _exp, _f ) _AssertFunc( _exp, _f )
|
||||
#define AssertEquals( _exp, _expectedValue ) _AssertEquals( _exp, _expectedValue )
|
||||
#define AssertFloatEquals( _exp, _expectedValue, _tol ) _AssertFloatEquals( _exp, _expectedValue, _tol )
|
||||
#define Verify( _exp ) _Assert( _exp )
|
||||
|
||||
#define AssertMsg1( _exp, _msg, a1 ) _AssertMsg( _exp, CDbgFmtMsg( _msg, a1 ) )
|
||||
#define AssertMsg2( _exp, _msg, a1, a2 ) _AssertMsg( _exp, CDbgFmtMsg( _msg, a1, a2 ) )
|
||||
#define AssertMsg3( _exp, _msg, a1, a2, a3 ) _AssertMsg( _exp, CDbgFmtMsg( _msg, a1, a2, a3 ) )
|
||||
#define AssertMsg4( _exp, _msg, a1, a2, a3, a4 ) _AssertMsg( _exp, CDbgFmtMsg( _msg, a1, a2, a3, a4 ) )
|
||||
#define AssertMsg5( _exp, _msg, a1, a2, a3, a4, a5 ) _AssertMsg( _exp, CDbgFmtMsg( _msg, a1, a2, a3, a4, a5 ) )
|
||||
#define AssertMsg6( _exp, _msg, a1, a2, a3, a4, a5, a6 ) _AssertMsg( _exp, CDbgFmtMsg( _msg, a1, a2, a3, a4, a5, a6 ) )
|
||||
#define AssertMsg6( _exp, _msg, a1, a2, a3, a4, a5, a6 ) _AssertMsg( _exp, CDbgFmtMsg( _msg, a1, a2, a3, a4, a5, a6 ) )
|
||||
#define AssertMsg7( _exp, _msg, a1, a2, a3, a4, a5, a6, a7 ) _AssertMsg( _exp, CDbgFmtMsg( _msg, a1, a2, a3, a4, a5, a6, a7 ) )
|
||||
#define AssertMsg8( _exp, _msg, a1, a2, a3, a4, a5, a6, a7, a8 ) _AssertMsg( _exp, CDbgFmtMsg( _msg, a1, a2, a3, a4, a5, a6, a7, a8 ) )
|
||||
#define AssertMsg9( _exp, _msg, a1, a2, a3, a4, a5, a6, a7, a8, a9 ) _AssertMsg( _exp, CDbgFmtMsg( _msg, a1, a2, a3, a4, a5, a6, a7, a8, a9 ) )
|
||||
|
||||
|
||||
#else /* Not _DEBUG */
|
||||
|
||||
#define Assert( _exp ) ((void)0)
|
||||
#define AssertMsg( _exp, _msg ) ((void)0)
|
||||
#define AssertFunc( _exp, _f ) ((void)0)
|
||||
#define AssertEquals( _exp, _expectedValue ) ((void)0)
|
||||
#define AssertFloatEquals( _exp, _expectedValue, _tol ) ((void)0)
|
||||
#define Verify( _exp ) (_exp)
|
||||
|
||||
#define AssertMsg1( _exp, _msg, a1 ) ((void)0)
|
||||
#define AssertMsg2( _exp, _msg, a1, a2 ) ((void)0)
|
||||
#define AssertMsg3( _exp, _msg, a1, a2, a3 ) ((void)0)
|
||||
#define AssertMsg4( _exp, _msg, a1, a2, a3, a4 ) ((void)0)
|
||||
#define AssertMsg5( _exp, _msg, a1, a2, a3, a4, a5 ) ((void)0)
|
||||
#define AssertMsg6( _exp, _msg, a1, a2, a3, a4, a5, a6 ) ((void)0)
|
||||
#define AssertMsg6( _exp, _msg, a1, a2, a3, a4, a5, a6 ) ((void)0)
|
||||
#define AssertMsg7( _exp, _msg, a1, a2, a3, a4, a5, a6, a7 ) ((void)0)
|
||||
#define AssertMsg8( _exp, _msg, a1, a2, a3, a4, a5, a6, a7, a8 ) ((void)0)
|
||||
#define AssertMsg9( _exp, _msg, a1, a2, a3, a4, a5, a6, a7, a8, a9 ) ((void)0)
|
||||
|
||||
#endif /* _DEBUG */
|
||||
|
||||
|
||||
|
||||
/* These are always compiled in */
|
||||
void Msg(char const* pMsg, ...);
|
||||
void DMsg(char const *pGroupName, int level, char const *pMsg, ...);
|
||||
|
||||
void Warning(char const *pMsg, ...);
|
||||
void DWarning(char const *pGroupName, int level, char const *pMsg, ...);
|
||||
|
||||
void Log(char const *pMsg, ...);
|
||||
void DLog(char const *pGroupName, int level, char const *pMsg, ...);
|
||||
|
||||
void Error(char const *pMsg, ...);
|
||||
|
||||
// You can use this macro like a runtime assert macro.
|
||||
// If the condition fails, then Error is called with the message. This macro is called
|
||||
// like AssertMsg, where msg must be enclosed in parenthesis:
|
||||
//
|
||||
// ErrorIfNot( bCondition, ("a b c %d %d %d", 1, 2, 3) );
|
||||
#define ErrorIfNot( condition, msg ) \
|
||||
if ( (condition) ) \
|
||||
; \
|
||||
else \
|
||||
{ \
|
||||
Error msg; \
|
||||
}
|
||||
|
||||
/* A couple of super-common dynamic spew messages, here for convenience */
|
||||
/* These looked at the "developer" group */
|
||||
void DevMsg(int level, char const* pMsg, ...);
|
||||
void DevWarning(int level, char const *pMsg, ...);
|
||||
void DevLog(int level, char const *pMsg, ...);
|
||||
|
||||
/* default level versions (level 1) */
|
||||
void DevMsg(char const* pMsg, ...);
|
||||
void DevWarning(char const *pMsg, ...);
|
||||
void DevLog(char const *pMsg, ...);
|
||||
|
||||
/* Code macros, debugger interface */
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
#define DBG_CODE( _code ) if (0) ; else { _code }
|
||||
#define DBG_DCODE( _g, _l, _code ) if (IsSpewActive( _g, _l )) { _code } else {}
|
||||
#define DBG_BREAK() DebuggerBreak() /* defined in platform.h */
|
||||
|
||||
#else /* not _DEBUG */
|
||||
|
||||
#define DBG_CODE( _code ) ((void)0)
|
||||
#define DBG_DCODE( _g, _l, _code ) ((void)0)
|
||||
#define DBG_BREAK() ((void)0)
|
||||
|
||||
#endif /* _DEBUG */
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Macro to assist in asserting constant invariants during compilation
|
||||
|
||||
#define UID_PREFIX generated_id_
|
||||
#define UID_CAT1(a,c) a ## c
|
||||
#define UID_CAT2(a,c) UID_CAT1(a,c)
|
||||
#define UNIQUE_ID UID_CAT2(UID_PREFIX,__LINE__)
|
||||
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define COMPILE_TIME_ASSERT( pred ) switch(0){case 0:case pred:;}
|
||||
#define ASSERT_INVARIANT( pred ) static void UNIQUE_ID() { COMPILE_TIME_ASSERT( pred ) }
|
||||
#else
|
||||
#define COMPILE_TIME_ASSERT( pred )
|
||||
#define ASSERT_INVARIANT( pred )
|
||||
#endif
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Templates to assist in validating pointers:
|
||||
|
||||
// Have to use these stubs so we don't have to include windows.h here.
|
||||
void _AssertValidReadPtr(void* ptr, int count = 1);
|
||||
void _AssertValidWritePtr(void* ptr, int count = 1);
|
||||
void _AssertValidReadWritePtr(void* ptr, int count = 1);
|
||||
|
||||
void AssertValidStringPtr(const char* ptr, int maxchar = 0xFFFFFF);
|
||||
template<class T> inline void AssertValidReadPtr(T* ptr, int count = 1) { _AssertValidReadPtr((void*)ptr, count); }
|
||||
template<class T> inline void AssertValidWritePtr(T* ptr, int count = 1) { _AssertValidWritePtr((void*)ptr, count); }
|
||||
template<class T> inline void AssertValidReadWritePtr(T* ptr, int count = 1) { _AssertValidReadWritePtr((void*)ptr, count); }
|
||||
|
||||
#define AssertValidThis() AssertValidReadWritePtr(this,sizeof(*this))
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Macro to protect functions that are not reentrant
|
||||
|
||||
#ifdef _DEBUG
|
||||
class CReentryGuard
|
||||
{
|
||||
public:
|
||||
CReentryGuard(int *pSemaphore)
|
||||
: m_pSemaphore(pSemaphore)
|
||||
{
|
||||
++(*m_pSemaphore);
|
||||
}
|
||||
|
||||
~CReentryGuard()
|
||||
{
|
||||
--(*m_pSemaphore);
|
||||
}
|
||||
|
||||
private:
|
||||
int *m_pSemaphore;
|
||||
};
|
||||
|
||||
#define ASSERT_NO_REENTRY() \
|
||||
static int fSemaphore##__LINE__; \
|
||||
Assert( !fSemaphore##__LINE__ ); \
|
||||
CReentryGuard ReentryGuard##__LINE__( &fSemaphore##__LINE__ )
|
||||
#else
|
||||
#define ASSERT_NO_REENTRY()
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Purpose: Inline string formatter
|
||||
//
|
||||
|
||||
class CDbgFmtMsg
|
||||
{
|
||||
public:
|
||||
CDbgFmtMsg(const char *pszFormat, ...)
|
||||
{
|
||||
va_list arg_ptr;
|
||||
|
||||
va_start(arg_ptr, pszFormat);
|
||||
_vsnprintf(m_szBuf, sizeof(m_szBuf) - 1, pszFormat, arg_ptr);
|
||||
va_end(arg_ptr);
|
||||
|
||||
m_szBuf[sizeof(m_szBuf) - 1] = 0;
|
||||
}
|
||||
|
||||
operator const char *() const
|
||||
{
|
||||
return m_szBuf;
|
||||
}
|
||||
|
||||
private:
|
||||
char m_szBuf[256];
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Purpose: Embed debug info in each file.
|
||||
//
|
||||
//#ifdef _WIN32
|
||||
//#ifdef _DEBUG
|
||||
//#pragma comment(compiler)
|
||||
//#pragma comment(exestr,"*** DEBUG file detected, Last Compile: " __DATE__ ", " __TIME__ " ***")
|
||||
//#endif
|
||||
//#endif
|
||||
|
||||
#endif /* DBG_H */
|
651
regamedll/extra/cssdk/public/tier0/platform.h
Normal file
651
regamedll/extra/cssdk/public/tier0/platform.h
Normal file
@ -0,0 +1,651 @@
|
||||
//=========== (C) Copyright 1999 Valve, L.L.C. All rights reserved. ===========
|
||||
//
|
||||
// The copyright to the contents herein is the property of Valve, L.L.C.
|
||||
// The contents may be used and/or copied only with the written permission of
|
||||
// Valve, L.L.C., or in accordance with the terms and conditions stipulated in
|
||||
// the agreement/contract under which the contents have been supplied.
|
||||
//
|
||||
// $Header: $
|
||||
// $NoKeywords: $
|
||||
//
|
||||
// Extremely low-level platform-specific stuff
|
||||
//=============================================================================
|
||||
|
||||
|
||||
#ifndef PLATFORM_H
|
||||
#define PLATFORM_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "osconfig.h"
|
||||
|
||||
// need this for _alloca
|
||||
#include <malloc.h>
|
||||
|
||||
// need this for memset
|
||||
#include <string.h>
|
||||
|
||||
// for when we care about how many bits we use
|
||||
typedef signed char int8;
|
||||
typedef signed short int16;
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef _MSC_VER
|
||||
typedef signed __int64 int64;
|
||||
#endif
|
||||
#elif defined __linux__
|
||||
typedef long long int64;
|
||||
#endif
|
||||
|
||||
typedef unsigned char uint8;
|
||||
typedef unsigned short uint16;
|
||||
#ifdef _WIN32
|
||||
#ifdef _MSC_VER
|
||||
typedef unsigned __int64 uint64;
|
||||
#endif
|
||||
#elif defined __linux__
|
||||
typedef unsigned long long uint64;
|
||||
#endif
|
||||
|
||||
|
||||
typedef float float32;
|
||||
typedef double float64;
|
||||
|
||||
// for when we don't care about how many bits we use
|
||||
typedef unsigned int uint;
|
||||
|
||||
// This can be used to ensure the size of pointers to members when declaring
|
||||
// a pointer type for a class that has only been forward declared
|
||||
#ifdef _MSC_VER
|
||||
#define SINGLE_INHERITANCE __single_inheritance
|
||||
#define MULTIPLE_INHERITANCE __multiple_inheritance
|
||||
#else
|
||||
#define SINGLE_INHERITANCE
|
||||
#define MULTIPLE_INHERITANCE
|
||||
#endif
|
||||
|
||||
/*
|
||||
FIXME: Enable this when we no longer fear change =)
|
||||
|
||||
// need these for the limits
|
||||
#include <limits.h>
|
||||
#include <float.h>
|
||||
|
||||
// Maximum and minimum representable values
|
||||
#define INT8_MAX SCHAR_MAX
|
||||
#define INT16_MAX SHRT_MAX
|
||||
#define INT32_MAX LONG_MAX
|
||||
#define INT64_MAX (((int64)~0) >> 1)
|
||||
|
||||
#define INT8_MIN SCHAR_MIN
|
||||
#define INT16_MIN SHRT_MIN
|
||||
#define INT32_MIN LONG_MIN
|
||||
#define INT64_MIN (((int64)1) << 63)
|
||||
|
||||
#define UINT8_MAX ((uint8)~0)
|
||||
#define UINT16_MAX ((uint16)~0)
|
||||
#define UINT32_MAX ((uint32_t)~0)
|
||||
#define UINT64_MAX ((uint64)~0)
|
||||
|
||||
#define UINT8_MIN 0
|
||||
#define UINT16_MIN 0
|
||||
#define UINT32_MIN 0
|
||||
#define UINT64_MIN 0
|
||||
|
||||
#ifndef UINT_MIN
|
||||
#define UINT_MIN UINT32_MIN
|
||||
#endif
|
||||
|
||||
#define FLOAT32_MAX FLT_MAX
|
||||
#define FLOAT64_MAX DBL_MAX
|
||||
|
||||
#define FLOAT32_MIN FLT_MIN
|
||||
#define FLOAT64_MIN DBL_MIN
|
||||
*/
|
||||
|
||||
// portability / compiler settings
|
||||
#if defined(_WIN32) && !defined(WINDED)
|
||||
|
||||
#if defined(_M_IX86)
|
||||
#define __i386__ 1
|
||||
#endif
|
||||
|
||||
#elif __linux__
|
||||
typedef void * HINSTANCE;
|
||||
#define _MAX_PATH PATH_MAX
|
||||
#endif // defined(_WIN32) && !defined(WINDED)
|
||||
|
||||
|
||||
// Defines MAX_PATH
|
||||
#ifndef MAX_PATH
|
||||
#define MAX_PATH 260
|
||||
#endif
|
||||
|
||||
// Used to step into the debugger
|
||||
#define DebuggerBreak() __asm { int 3 }
|
||||
|
||||
// C functions for external declarations that call the appropriate C++ methods
|
||||
#ifndef EXPORT
|
||||
#ifdef _WIN32
|
||||
#define EXPORT _declspec( dllexport )
|
||||
#else
|
||||
#define EXPORT /* */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined __i386__ && !defined __linux__
|
||||
#define id386 1
|
||||
#else
|
||||
#define id386 0
|
||||
#endif // __i386__
|
||||
|
||||
#ifdef _WIN32
|
||||
// Used for dll exporting and importing
|
||||
#define DLL_EXPORT extern "C" __declspec( dllexport )
|
||||
#define DLL_IMPORT extern "C" __declspec( dllimport )
|
||||
|
||||
// Can't use extern "C" when DLL exporting a class
|
||||
#define DLL_CLASS_EXPORT __declspec( dllexport )
|
||||
#define DLL_CLASS_IMPORT __declspec( dllimport )
|
||||
|
||||
// Can't use extern "C" when DLL exporting a global
|
||||
#define DLL_GLOBAL_EXPORT extern __declspec( dllexport )
|
||||
#define DLL_GLOBAL_IMPORT extern __declspec( dllimport )
|
||||
#elif defined __linux__
|
||||
|
||||
// Used for dll exporting and importing
|
||||
#define DLL_EXPORT extern "C"
|
||||
#define DLL_IMPORT extern "C"
|
||||
|
||||
// Can't use extern "C" when DLL exporting a class
|
||||
#define DLL_CLASS_EXPORT
|
||||
#define DLL_CLASS_IMPORT
|
||||
|
||||
// Can't use extern "C" when DLL exporting a global
|
||||
#define DLL_GLOBAL_EXPORT extern
|
||||
#define DLL_GLOBAL_IMPORT extern
|
||||
|
||||
#else
|
||||
#error "Unsupported Platform."
|
||||
#endif
|
||||
|
||||
// Used for standard calling conventions
|
||||
#ifdef _WIN32
|
||||
#define FASTCALL __fastcall
|
||||
#define FORCEINLINE __forceinline
|
||||
#else
|
||||
#define FASTCALL
|
||||
#define FORCEINLINE inline
|
||||
#endif
|
||||
|
||||
// Force a function call site -not- to inlined. (useful for profiling)
|
||||
#define DONT_INLINE(a) (((int)(a)+1)?(a):(a))
|
||||
|
||||
// Pass hints to the compiler to prevent it from generating unnessecary / stupid code
|
||||
// in certain situations. Several compilers other than MSVC also have an equivilent
|
||||
// construct.
|
||||
//
|
||||
// Essentially the 'Hint' is that the condition specified is assumed to be true at
|
||||
// that point in the compilation. If '0' is passed, then the compiler assumes that
|
||||
// any subsequent code in the same 'basic block' is unreachable, and thus usually
|
||||
// removed.
|
||||
#ifdef _MSC_VER
|
||||
#define HINT(THE_HINT) __assume((THE_HINT))
|
||||
#else
|
||||
#define HINT(THE_HINT) 0
|
||||
#endif
|
||||
|
||||
// Marks the codepath from here until the next branch entry point as unreachable,
|
||||
// and asserts if any attempt is made to execute it.
|
||||
#define UNREACHABLE() { Assert(0); HINT(0); }
|
||||
|
||||
// In cases where no default is present or appropriate, this causes MSVC to generate
|
||||
// as little code as possible, and throw an assertion in debug.
|
||||
#define NO_DEFAULT default: UNREACHABLE();
|
||||
|
||||
#ifdef _WIN32
|
||||
// Alloca defined for this platform
|
||||
#define stackalloc( _size ) _alloca( _size )
|
||||
#define stackfree( _p ) 0
|
||||
#elif __linux__
|
||||
// Alloca defined for this platform
|
||||
#define stackalloc( _size ) alloca( _size )
|
||||
#define stackfree( _p ) 0
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
// Remove warnings from warning level 4.
|
||||
#pragma warning(disable : 4514) // warning C4514: 'acosl' : unreferenced inline function has been removed
|
||||
#pragma warning(disable : 4100) // warning C4100: 'hwnd' : unreferenced formal parameter
|
||||
#pragma warning(disable : 4127) // warning C4127: conditional expression is constant
|
||||
#pragma warning(disable : 4512) // warning C4512: 'InFileRIFF' : assignment operator could not be generated
|
||||
#pragma warning(disable : 4611) // warning C4611: interaction between '_setjmp' and C++ object destruction is non-portable
|
||||
#pragma warning(disable : 4706) // warning C4706: assignment within conditional expression
|
||||
#pragma warning(disable : 4710) // warning C4710: function 'x' not inlined
|
||||
#pragma warning(disable : 4702) // warning C4702: unreachable code
|
||||
#pragma warning(disable : 4505) // unreferenced local function has been removed
|
||||
#pragma warning(disable : 4239) // nonstandard extension used : 'argument' ( conversion from class Vector to class Vector& )
|
||||
#pragma warning(disable : 4097) // typedef-name 'BaseClass' used as synonym for class-name 'CFlexCycler::CBaseFlex'
|
||||
#pragma warning(disable : 4324) // Padding was added at the end of a structure
|
||||
#pragma warning(disable : 4244) // type conversion warning.
|
||||
#pragma warning(disable : 4305) // truncation from 'const double ' to 'float '
|
||||
#pragma warning(disable : 4786) // Disable warnings about long symbol names
|
||||
|
||||
#if _MSC_VER >= 1300
|
||||
#pragma warning(disable : 4511) // Disable warnings about private copy constructors
|
||||
#endif
|
||||
#endif
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Standard functions for handling endian-ness
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------
|
||||
// Basic swaps
|
||||
//-------------------------------------
|
||||
|
||||
template <typename T>
|
||||
inline T WordSwapC(T w)
|
||||
{
|
||||
uint16 temp;
|
||||
|
||||
temp = ((*((uint16 *)&w) & 0xff00) >> 8);
|
||||
temp |= ((*((uint16 *)&w) & 0x00ff) << 8);
|
||||
|
||||
return *((T*)&temp);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline T DWordSwapC(T dw)
|
||||
{
|
||||
uint32_t temp;
|
||||
|
||||
temp = *((uint32_t *)&dw) >> 24;
|
||||
temp |= ((*((uint32_t *)&dw) & 0x00FF0000) >> 8);
|
||||
temp |= ((*((uint32_t *)&dw) & 0x0000FF00) << 8);
|
||||
temp |= ((*((uint32_t *)&dw) & 0x000000FF) << 24);
|
||||
|
||||
return *((T*)&temp);
|
||||
}
|
||||
|
||||
//-------------------------------------
|
||||
// Fast swaps
|
||||
//-------------------------------------
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
#define WordSwap WordSwapAsm
|
||||
#define DWordSwap DWordSwapAsm
|
||||
|
||||
#pragma warning(push)
|
||||
#pragma warning (disable:4035) // no return value
|
||||
|
||||
template <typename T>
|
||||
inline T WordSwapAsm(T w)
|
||||
{
|
||||
__asm
|
||||
{
|
||||
mov ax, w
|
||||
xchg al, ah
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline T DWordSwapAsm(T dw)
|
||||
{
|
||||
__asm
|
||||
{
|
||||
mov eax, dw
|
||||
bswap eax
|
||||
}
|
||||
}
|
||||
|
||||
#pragma warning(pop)
|
||||
|
||||
// The assembly implementation is not compatible with floats
|
||||
template <>
|
||||
inline float DWordSwapAsm<float>(float f)
|
||||
{
|
||||
return DWordSwapC(f);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#define WordSwap WordSwapC
|
||||
#define DWordSwap DWordSwapC
|
||||
|
||||
#endif
|
||||
|
||||
//-------------------------------------
|
||||
// The typically used methods.
|
||||
//-------------------------------------
|
||||
|
||||
#if defined(__i386__)
|
||||
#define VALVE_LITTLE_ENDIAN 1
|
||||
#endif
|
||||
|
||||
#ifdef _SGI_SOURCE
|
||||
#define VALVE_BIG_ENDIAN 1
|
||||
#endif
|
||||
|
||||
#if defined(VALVE_LITTLE_ENDIAN)
|
||||
|
||||
#define Valve_BigShort( val ) WordSwap( val )
|
||||
#define Valve_BigWord( val ) WordSwap( val )
|
||||
#define Valve_BigLong( val ) DWordSwap( val )
|
||||
#define Valve_BigDWord( val ) DWordSwap( val )
|
||||
#define Valve_BigFloat( val ) DWordSwap( val )
|
||||
#define Valve_LittleShort( val ) ( val )
|
||||
#define Valve_LittleWord( val ) ( val )
|
||||
#define Valve_LittleLong( val ) ( val )
|
||||
#define Valve_LittleDWord( val ) ( val )
|
||||
#define Valve_LittleFloat( val ) ( val )
|
||||
|
||||
#elif defined(BIG_ENDIAN)
|
||||
|
||||
#define Valve_BigShort( val ) ( val )
|
||||
#define Valve_BigWord( val ) ( val )
|
||||
#define Valve_BigLong( val ) ( val )
|
||||
#define Valve_BigDWord( val ) ( val )
|
||||
#define Valve_BigFloat( val ) ( val )
|
||||
#define Valve_LittleShort( val ) WordSwap( val )
|
||||
#define Valve_LittleWord( val ) WordSwap( val )
|
||||
#define Valve_LittleLong( val ) DWordSwap( val )
|
||||
#define Valve_LittleDWord( val ) DWordSwap( val )
|
||||
#define Valve_LittleFloat( val ) DWordSwap( val )
|
||||
|
||||
#else
|
||||
|
||||
// @Note (toml 05-02-02): this technique expects the compiler to
|
||||
// optimize the expression and eliminate the other path. On any new
|
||||
// platform/compiler this should be tested.
|
||||
inline short BigShort(short val) { int test = 1; return (*(char *)&test == 1) ? WordSwap(val) : val; }
|
||||
inline uint16 BigWord(uint16 val) { int test = 1; return (*(char *)&test == 1) ? WordSwap(val) : val; }
|
||||
inline long BigLong(long val) { int test = 1; return (*(char *)&test == 1) ? DWordSwap(val) : val; }
|
||||
inline uint32_t BigDWord(uint32_t val) { int test = 1; return (*(char *)&test == 1) ? DWordSwap(val) : val; }
|
||||
inline float BigFloat(float val) { int test = 1; return (*(char *)&test == 1) ? DWordSwap(val) : val; }
|
||||
inline short LittleShort(short val) { int test = 1; return (*(char *)&test == 1) ? val : WordSwap(val); }
|
||||
inline uint16 LittleWord(uint16 val) { int test = 1; return (*(char *)&test == 1) ? val : WordSwap(val); }
|
||||
inline long LittleLong(long val) { int test = 1; return (*(char *)&test == 1) ? val : DWordSwap(val); }
|
||||
inline uint32_t LittleDWord(uint32_t val) { int test = 1; return (*(char *)&test == 1) ? val : DWordSwap(val); }
|
||||
inline float LittleFloat(float val) { int test = 1; return (*(char *)&test == 1) ? val : DWordSwap(val); }
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifdef TIER0_DLL_EXPORT
|
||||
#define PLATFORM_INTERFACE DLL_EXPORT
|
||||
#define PLATFORM_OVERLOAD DLL_GLOBAL_EXPORT
|
||||
#else
|
||||
#define PLATFORM_INTERFACE DLL_IMPORT
|
||||
#define PLATFORM_OVERLOAD DLL_GLOBAL_IMPORT
|
||||
#endif
|
||||
|
||||
/*
|
||||
PLATFORM_INTERFACE double Plat_FloatTime(); // Returns time in seconds since the module was loaded.
|
||||
PLATFORM_INTERFACE unsigned long Plat_MSTime(); // Time in milliseconds.
|
||||
|
||||
// b/w compatibility
|
||||
#define Sys_FloatTime Plat_FloatTime
|
||||
*/
|
||||
|
||||
// Processor Information:
|
||||
struct CPUInformation
|
||||
{
|
||||
int m_Size; // Size of this structure, for forward compatability.
|
||||
|
||||
bool m_bRDTSC : 1, // Is RDTSC supported?
|
||||
m_bCMOV : 1, // Is CMOV supported?
|
||||
m_bFCMOV : 1, // Is FCMOV supported?
|
||||
m_bSSE : 1, // Is SSE supported?
|
||||
m_bSSE2 : 1, // Is SSE2 Supported?
|
||||
m_b3DNow : 1, // Is 3DNow! Supported?
|
||||
m_bMMX : 1, // Is MMX supported?
|
||||
m_bHT : 1; // Is HyperThreading supported?
|
||||
|
||||
unsigned char m_nLogicalProcessors, // Number op logical processors.
|
||||
m_nPhysicalProcessors; // Number of physical processors
|
||||
|
||||
int64 m_Speed; // In cycles per second.
|
||||
|
||||
char* m_szProcessorID; // Processor vendor Identification.
|
||||
};
|
||||
|
||||
PLATFORM_INTERFACE const CPUInformation& GetCPUInformation();
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Thread related functions
|
||||
//-----------------------------------------------------------------------------
|
||||
// Registers the current thread with Tier0's thread management system.
|
||||
// This should be called on every thread created in the game.
|
||||
PLATFORM_INTERFACE unsigned long Plat_RegisterThread(const char *pName = "Source Thread");
|
||||
|
||||
// Registers the current thread as the primary thread.
|
||||
PLATFORM_INTERFACE unsigned long Plat_RegisterPrimaryThread();
|
||||
|
||||
// VC-specific. Sets the thread's name so it has a friendly name in the debugger.
|
||||
// This should generally only be handled by Plat_RegisterThread and Plat_RegisterPrimaryThread
|
||||
PLATFORM_INTERFACE void Plat_SetThreadName(unsigned long dwThreadID, const char *pName);
|
||||
|
||||
// These would be private if it were possible to export private variables from a .DLL.
|
||||
// They need to be variables because they are checked by inline functions at performance
|
||||
// critical places.
|
||||
PLATFORM_INTERFACE unsigned long Plat_PrimaryThreadID;
|
||||
|
||||
// Returns the ID of the currently executing thread.
|
||||
PLATFORM_INTERFACE unsigned long Plat_GetCurrentThreadID();
|
||||
|
||||
// Returns the ID of the primary thread.
|
||||
inline unsigned long Plat_GetPrimaryThreadID()
|
||||
{
|
||||
return Plat_PrimaryThreadID;
|
||||
}
|
||||
|
||||
// Returns true if the current thread is the primary thread.
|
||||
inline bool Plat_IsPrimaryThread()
|
||||
{
|
||||
//return true;
|
||||
return (Plat_GetPrimaryThreadID() == Plat_GetCurrentThreadID());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Security related functions
|
||||
//-----------------------------------------------------------------------------
|
||||
// Ensure that the hardware key's drivers have been installed.
|
||||
PLATFORM_INTERFACE bool Plat_VerifyHardwareKeyDriver();
|
||||
|
||||
// Ok, so this isn't a very secure way to verify the hardware key for now. It
|
||||
// is primarially depending on the fact that all the binaries have been wrapped
|
||||
// with the secure wrapper provided by the hardware keys vendor.
|
||||
PLATFORM_INTERFACE bool Plat_VerifyHardwareKey();
|
||||
|
||||
// The same as above, but notifies user with a message box when the key isn't in
|
||||
// and gives him an opportunity to correct the situation.
|
||||
PLATFORM_INTERFACE bool Plat_VerifyHardwareKeyPrompt();
|
||||
|
||||
// Can be called in real time, doesn't perform the verify every frame. Mainly just
|
||||
// here to allow the game to drop out quickly when the key is removed, rather than
|
||||
// allowing the wrapper to pop up it's own blocking dialog, which the engine doesn't
|
||||
// like much.
|
||||
PLATFORM_INTERFACE bool Plat_FastVerifyHardwareKey();
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Include additional dependant header components.
|
||||
//-----------------------------------------------------------------------------
|
||||
//#include "tier0/fasttimer.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Just logs file and line to simple.log
|
||||
//-----------------------------------------------------------------------------
|
||||
void* Plat_SimpleLog(const char* file, int line);
|
||||
|
||||
//#define Plat_dynamic_cast Plat_SimpleLog(__FILE__,__LINE__),dynamic_cast
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Methods to invoke the constructor, copy constructor, and destructor
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
template <class T>
|
||||
inline void Construct(T* pMemory)
|
||||
{
|
||||
new(pMemory)T;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void CopyConstruct(T* pMemory, T const& src)
|
||||
{
|
||||
new(pMemory)T(src);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void Destruct(T* pMemory)
|
||||
{
|
||||
pMemory->~T();
|
||||
|
||||
#ifdef _DEBUG
|
||||
memset(pMemory, 0xDD, sizeof(T));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// GET_OUTER()
|
||||
//
|
||||
// A platform-independent way for a contained class to get a pointer to its
|
||||
// owner. If you know a class is exclusively used in the context of some
|
||||
// "outer" class, this is a much more space efficient way to get at the outer
|
||||
// class than having the inner class store a pointer to it.
|
||||
//
|
||||
// class COuter
|
||||
// {
|
||||
// class CInner // Note: this does not need to be a nested class to work
|
||||
// {
|
||||
// void PrintAddressOfOuter()
|
||||
// {
|
||||
// printf( "Outer is at 0x%x\n", GET_OUTER( COuter, m_Inner ) );
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// CInner m_Inner;
|
||||
// friend class CInner;
|
||||
// };
|
||||
|
||||
#define GET_OUTER( OuterType, OuterMember ) \
|
||||
( ( OuterType * ) ( (char *)this - offsetof( OuterType, OuterMember ) ) )
|
||||
|
||||
|
||||
/* TEMPLATE_FUNCTION_TABLE()
|
||||
|
||||
(Note added to platform.h so platforms that correctly support templated
|
||||
functions can handle portions as templated functions rather than wrapped
|
||||
functions)
|
||||
|
||||
Helps automate the process of creating an array of function
|
||||
templates that are all specialized by a single integer.
|
||||
This sort of thing is often useful in optimization work.
|
||||
|
||||
For example, using TEMPLATE_FUNCTION_TABLE, this:
|
||||
|
||||
TEMPLATE_FUNCTION_TABLE(int, Function, ( int blah, int blah ), 10)
|
||||
{
|
||||
return argument * argument;
|
||||
}
|
||||
|
||||
is equivilent to the following:
|
||||
|
||||
(NOTE: the function has to be wrapped in a class due to code
|
||||
generation bugs involved with directly specializing a function
|
||||
based on a constant.)
|
||||
|
||||
template<int argument>
|
||||
class FunctionWrapper
|
||||
{
|
||||
public:
|
||||
int Function( int blah, int blah )
|
||||
{
|
||||
return argument*argument;
|
||||
}
|
||||
}
|
||||
|
||||
typedef int (*FunctionType)( int blah, int blah );
|
||||
|
||||
class FunctionName
|
||||
{
|
||||
public:
|
||||
enum { count = 10 };
|
||||
FunctionType functions[10];
|
||||
};
|
||||
|
||||
FunctionType FunctionName::functions[] =
|
||||
{
|
||||
FunctionWrapper<0>::Function,
|
||||
FunctionWrapper<1>::Function,
|
||||
FunctionWrapper<2>::Function,
|
||||
FunctionWrapper<3>::Function,
|
||||
FunctionWrapper<4>::Function,
|
||||
FunctionWrapper<5>::Function,
|
||||
FunctionWrapper<6>::Function,
|
||||
FunctionWrapper<7>::Function,
|
||||
FunctionWrapper<8>::Function,
|
||||
FunctionWrapper<9>::Function
|
||||
};
|
||||
*/
|
||||
|
||||
bool vtune(bool resume);
|
||||
|
||||
|
||||
#define TEMPLATE_FUNCTION_TABLE(RETURN_TYPE, NAME, ARGS, COUNT) \
|
||||
\
|
||||
typedef RETURN_TYPE (FASTCALL *__Type_##NAME) ARGS; \
|
||||
\
|
||||
template<const int nArgument> \
|
||||
struct __Function_##NAME \
|
||||
{ \
|
||||
static RETURN_TYPE FASTCALL Run ARGS; \
|
||||
}; \
|
||||
\
|
||||
template <int i> \
|
||||
struct __MetaLooper_##NAME : __MetaLooper_##NAME<i-1> \
|
||||
{ \
|
||||
__Type_##NAME func; \
|
||||
inline __MetaLooper_##NAME() { func = __Function_##NAME<i>::Run; } \
|
||||
}; \
|
||||
\
|
||||
template<> \
|
||||
struct __MetaLooper_##NAME<0> \
|
||||
{ \
|
||||
__Type_##NAME func; \
|
||||
inline __MetaLooper_##NAME() { func = __Function_##NAME<0>::Run; } \
|
||||
}; \
|
||||
\
|
||||
class NAME \
|
||||
{ \
|
||||
private: \
|
||||
static const __MetaLooper_##NAME<COUNT> m; \
|
||||
public: \
|
||||
enum { count = COUNT }; \
|
||||
static const __Type_##NAME* functions; \
|
||||
}; \
|
||||
const __MetaLooper_##NAME<COUNT> NAME::m; \
|
||||
const __Type_##NAME* NAME::functions = (__Type_##NAME*)&m; \
|
||||
template<int nArgument> \
|
||||
RETURN_TYPE FASTCALL __Function_##NAME<nArgument>::Run ARGS
|
||||
|
||||
|
||||
#define LOOP_INTERCHANGE(BOOLEAN, CODE)\
|
||||
if( (BOOLEAN) )\
|
||||
{\
|
||||
CODE;\
|
||||
} else\
|
||||
{\
|
||||
CODE;\
|
||||
}
|
||||
|
||||
|
||||
#endif /* PLATFORM_H */
|
@ -34,6 +34,7 @@
|
||||
#endif
|
||||
|
||||
#include "osconfig.h"
|
||||
#include "tier0/dbg.h"
|
||||
#include <string.h>
|
||||
|
||||
#pragma warning (disable:4100)
|
||||
|
@ -806,7 +806,7 @@ FunctionHook g_FunctionHooks[] =
|
||||
//{ 0x0, "_ZN11CBasePlayer7IntenseEv", mfunc_ptr_cast(&CBasePlayer::Intense) }, // NOXREF
|
||||
{ 0x01D9AB20, "_Z16LinkUserMessagesv", (size_t)&LinkUserMessages },
|
||||
{ 0x01D9B0F0, "_Z18WriteSigonMessagesv", (size_t)&WriteSigonMessages },
|
||||
{ 0x01D9B280, "_Z14SendItemStatusP11CBasePlayer", (size_t)&SendItemStatus },
|
||||
//{ 0x01D9B280, "_Z14SendItemStatusP11CBasePlayer", (size_t)&SendItemStatus },
|
||||
{ 0x01D9D8A0, "_ZL14GetCSModelNamei", (size_t)&GetCSModelName },
|
||||
{ 0x01D9B2D0, "_ZN11CBasePlayer14SetPlayerModelEi", mfunc_ptr_cast(&CBasePlayer::SetPlayerModel) },
|
||||
//{ 0x01D9BB40, "_Z20VecVelocityForDamagef", (size_t)&VecVelocityForDamage }, // NOXREF
|
||||
@ -819,10 +819,10 @@ FunctionHook g_FunctionHooks[] =
|
||||
//{ 0x01DA4A90, "_Z17IsSpawnPointValidP11CBaseEntityS0_", (size_t)&IsSpawnPointValid }, // NOXREF
|
||||
//{ 0x01DA4B20, "_Z16InitZombieSpawnsv", (size_t)&InitZombieSpawns }, // NOXREF
|
||||
//{ 0x01DA4BC0, "_Z15FindZombieSpawnP11CBaseEntityb", (size_t)&FindZombieSpawn }, // NOXREF
|
||||
{ 0x01DA4BD0, "_Z19EntSelectSpawnPointP11CBaseEntity", (size_t)&EntSelectSpawnPoint },
|
||||
//{ 0x01DA4BD0, "_Z19EntSelectSpawnPointP11CBaseEntity", (size_t)&EntSelectSpawnPoint },
|
||||
|
||||
#ifdef _WIN32
|
||||
{ 0x01DA5180, "", (size_t)&SetScoreAttrib },
|
||||
//{ 0x01DA5180, "", (size_t)&SetScoreAttrib },
|
||||
#endif // _WIN32
|
||||
|
||||
//{ 0x01DA6D60, "_Z17FindEntityForwardP11CBaseEntity", (size_t)&FindEntityForward }, // NOXREF
|
||||
@ -2716,7 +2716,7 @@ FunctionHook g_FunctionHooks[] =
|
||||
{ 0x01D8B6E0, "_Z9BroadcastPKc", (size_t)&Broadcast },
|
||||
{ 0x01D8B780, "_Z7GetTeami", (size_t)&GetTeam },
|
||||
{ 0x01D8B7B0, "_Z15EndRoundMessagePKci", (size_t)&EndRoundMessage },
|
||||
{ 0x01D8BD80, "_ZL18ReadMultiplayCvarsP18CHalfLifeMultiplay", (size_t)&ReadMultiplayCvars },
|
||||
//{ 0x01D8BD80, "_ZL18ReadMultiplayCvarsP18CHalfLifeMultiplay", (size_t)&ReadMultiplayCvars },
|
||||
//{ 0x01D92670, "_Z15DestroyMapCycleP10mapcycle_s", (size_t)&DestroyMapCycle }, // NOXREF
|
||||
{ 0x01D926B0, "_Z15MP_COM_GetTokenv", (size_t)&MP_COM_GetToken },
|
||||
{ 0x01D926C0, "_Z12MP_COM_ParsePc", (size_t)&MP_COM_Parse },
|
||||
|
@ -30,6 +30,8 @@
|
||||
#include "regamedll_interfaces.h"
|
||||
#include "hookchains.h"
|
||||
#include "interface.h"
|
||||
#include "player.h"
|
||||
#include "gamerules.h"
|
||||
|
||||
#define REGAMEDLL_API_VERSION_MAJOR 2
|
||||
#define REGAMEDLL_API_VERSION_MINOR 1
|
||||
@ -140,8 +142,8 @@ typedef IVoidHookChain<const char *> IReGameHook_CBasePlayer_GiveNamedItem;
|
||||
typedef IVoidHookChainRegistryClass<class CBasePlayer, const char *> IReGameHookRegistry_CBasePlayer_GiveNamedItem;
|
||||
|
||||
// CBasePlayer::AddAccount hook
|
||||
typedef IVoidHookChain<int, enum RewardType, bool> IReGameHook_CBasePlayer_AddAccount;
|
||||
typedef IVoidHookChainRegistryClass<class CBasePlayer, int, enum RewardType, bool> IReGameHookRegistry_CBasePlayer_AddAccount;
|
||||
typedef IVoidHookChain<int, RewardType, bool> IReGameHook_CBasePlayer_AddAccount;
|
||||
typedef IVoidHookChainRegistryClass<class CBasePlayer, int, RewardType, bool> IReGameHookRegistry_CBasePlayer_AddAccount;
|
||||
|
||||
// CBasePlayer::GiveShield hook
|
||||
typedef IVoidHookChain<bool> IReGameHook_CBasePlayer_GiveShield;
|
||||
@ -173,8 +175,8 @@ typedef IVoidHookChain<class CBasePlayer *, struct entvars_s *, struct entvars_s
|
||||
typedef IVoidHookChainRegistry<class CBasePlayer *, struct entvars_s *, struct entvars_s *, Vector &, Vector &, struct TraceResult *> IReGameHookRegistry_RadiusFlash_TraceLine;
|
||||
|
||||
// RoundEnd hook
|
||||
typedef IHookChain<bool, int, enum ScenarioEventEndRound, float> IReGameHook_RoundEnd;
|
||||
typedef IHookChainRegistry<bool, int, enum ScenarioEventEndRound, float> IReGameHookRegistry_RoundEnd;
|
||||
typedef IHookChain<bool, int, ScenarioEventEndRound, float> IReGameHook_RoundEnd;
|
||||
typedef IHookChainRegistry<bool, int, ScenarioEventEndRound, float> IReGameHookRegistry_RoundEnd;
|
||||
|
||||
// CanBuyThis hook
|
||||
typedef IHookChain<bool, class CBasePlayer *, int> IReGameHook_CanBuyThis;
|
||||
|
@ -65,9 +65,17 @@ public:
|
||||
virtual void DropPlayerItem(const char *pszItemName);
|
||||
virtual void RemoveShield();
|
||||
virtual void RemoveAllItems(bool bRemoveSuit);
|
||||
virtual bool RemovePlayerItem(const char* pszItemName);
|
||||
virtual void SetPlayerModel(bool bHasC4);
|
||||
virtual void SetPlayerModelEx(const char *modelName);
|
||||
virtual void SetNewPlayerModel(const char *modelName);
|
||||
virtual void ClientCommand(const char *cmd, const char *arg1 = nullptr, const char *arg2 = nullptr, const char *arg3 = nullptr);
|
||||
virtual void SetProgressBarTime(int time);
|
||||
virtual void SetProgressBarTime2(int time, float timeElapsed);
|
||||
virtual struct edict_s *EntSelectSpawnPoint();
|
||||
virtual void SetBombIcon(bool bFlash = false);
|
||||
virtual void SetScoreAttrib(CBasePlayer *dest);
|
||||
virtual void SendItemStatus();
|
||||
|
||||
CBasePlayer *BasePlayer() const;
|
||||
public:
|
||||
|
@ -34,6 +34,7 @@
|
||||
#endif
|
||||
|
||||
#include "osconfig.h"
|
||||
#include "tier0/dbg.h"
|
||||
#include <string.h>
|
||||
|
||||
#pragma warning (disable:4100)
|
||||
|
@ -36,6 +36,33 @@ Vector CCSEntity::FireBullets3(Vector &vecSrc, Vector &vecDirShooting, float vec
|
||||
return m_pContainingEntity->FireBullets3(vecSrc, vecDirShooting, vecSpread, flDistance, iPenetration, iBulletType, iDamage, flRangeModifier, pevAttacker, bPistol, shared_rand);
|
||||
};
|
||||
|
||||
bool CCSPlayer::RemovePlayerItem(const char* pszItemName)
|
||||
{
|
||||
CBasePlayer *pPlayer = BasePlayer();
|
||||
|
||||
for (auto pItem : pPlayer->m_rgpPlayerItems) {
|
||||
while (pItem != nullptr)
|
||||
{
|
||||
if (FClassnameIs(pItem->pev, pszItemName))
|
||||
{
|
||||
CBasePlayerWeapon *pWeapon = static_cast<CBasePlayerWeapon *>(pItem);
|
||||
if (pWeapon->IsWeapon()) {
|
||||
pWeapon->RetireWeapon();
|
||||
}
|
||||
|
||||
pPlayer->pev->weapons &= ~(1 << pItem->m_iId);
|
||||
pPlayer->RemovePlayerItem(pItem);
|
||||
pItem->Kill();
|
||||
return true;
|
||||
}
|
||||
|
||||
pItem = pItem->m_pNext;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CCSPlayer::IsConnected() const { return m_pContainingEntity->has_disconnected == false; }
|
||||
void CCSPlayer::SetAnimation(PLAYER_ANIM playerAnim) { BasePlayer()->SetAnimation(playerAnim); }
|
||||
void CCSPlayer::AddAccount(int amount, RewardType type, bool bTrackChange) { BasePlayer()->AddAccount(amount, type, bTrackChange); }
|
||||
@ -50,3 +77,10 @@ void CCSPlayer::RemoveAllItems(bool bRemoveSuit) { BasePlayer()->RemoveAllItems(
|
||||
void CCSPlayer::SetPlayerModel(bool bHasC4) { BasePlayer()->SetPlayerModel(bHasC4 ? TRUE : FALSE); }
|
||||
void CCSPlayer::SetPlayerModelEx(const char *modelName) { strncpy(m_szModel, modelName, sizeof(m_szModel) - 1); m_szModel[sizeof(m_szModel) - 1] = '\0'; };
|
||||
void CCSPlayer::SetNewPlayerModel(const char *modelName) { BasePlayer()->SetNewPlayerModel(modelName); }
|
||||
void CCSPlayer::ClientCommand(const char *cmd, const char *arg1, const char *arg2, const char *arg3) { BasePlayer()->ClientCommand(cmd, arg1, arg2, arg3); }
|
||||
void CCSPlayer::SetProgressBarTime(int time) { BasePlayer()->SetProgressBarTime(time); }
|
||||
void CCSPlayer::SetProgressBarTime2(int time, float timeElapsed) { BasePlayer()->SetProgressBarTime2(time, timeElapsed); }
|
||||
edict_t *CCSPlayer::EntSelectSpawnPoint() { return BasePlayer()->EntSelectSpawnPoint(); }
|
||||
void CCSPlayer::SendItemStatus() { BasePlayer()->SendItemStatus(); }
|
||||
void CCSPlayer::SetBombIcon(bool bFlash) { BasePlayer()->SetBombIcon(bFlash ? TRUE : FALSE); }
|
||||
void CCSPlayer::SetScoreAttrib(CBasePlayer *dest) { BasePlayer()->SetScoreAttrib(dest); }
|
||||
|
Loading…
x
Reference in New Issue
Block a user