Skip to content

Commit

Permalink
Moved typedef_game into srccoop_api
Browse files Browse the repository at this point in the history
  • Loading branch information
ampreeT committed Jan 5, 2025
1 parent b0543b6 commit 5beb976
Show file tree
Hide file tree
Showing 54 changed files with 1,265 additions and 1,252 deletions.
4 changes: 0 additions & 4 deletions scripting/include/srccoop.inc
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,6 @@

#include <srccoop/util/assert>
#include <srccoop/typedef>
#if defined SRCCOOP_BLACKMESA
#include <srccoop/blackmesa/typedef>
#endif
#include <srccoop/typedef_game>
#include <srccoop/public>
#include <srccoop_api/classdef>
#include <srccoop/utils>
Expand Down
8 changes: 4 additions & 4 deletions scripting/include/srccoop/blackmesa/entitypatch.inc
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ public MRESReturn Hook_PropHevChargerThink(int _this)
public Action BlackMesaFireBulletsTEHook(const char[] szTEName, const int[] iClients, int iNumClients, float flDelay)
{
// Prevent crashes from `npc_sniper` on certain client configurations.
int iAmmoId = TE_ReadNum("m_iAmmoID");
if (iAmmoId == AMMO_SNIPERROUND)
AmmoType_t eAmmoType = view_as<AmmoType_t>(TE_ReadNum("m_iAmmoID"));
if (eAmmoType == AMMO_SNIPERROUND)
return Plugin_Changed;

// TE will crash all clients without a valid entity.
Expand Down Expand Up @@ -1113,8 +1113,8 @@ public MRESReturn Hook_TauFireBeamPost(int _this, Handle hReturn)
//------------------------------------------------------
public MRESReturn Hook_Dissolve(int _this, DHookReturn hReturn, DHookParam hParams)
{
int nDissolveType = hParams.Get(4);
if (nDissolveType == ENTITY_DISSOLVE_FADE || nDissolveType == ENTITY_DISSOLVE_REMOVE_NOW)
EntityDissolveType_t eDissolveType = hParams.Get(4);
if (eDissolveType == ENTITY_DISSOLVE_FADE || eDissolveType == ENTITY_DISSOLVE_REMOVE_NOW)
{
if (CBaseEntity(_this).IsPlayer())
{
Expand Down
28 changes: 0 additions & 28 deletions scripting/include/srccoop/blackmesa/typedef.inc
Original file line number Diff line number Diff line change
@@ -1,28 +0,0 @@
#if defined _srccoop_typedef_bm_included
#endinput
#endif
#define _srccoop_typedef_bm_included

#pragma newdecls required
#pragma semicolon 1

//------------------------------------------------------
// Gamerules gamestates
//------------------------------------------------------
#define STATE_WARMUP "m_StateWarmup"
#define STATE_ROUND "m_StateRound"
#define STATE_INTERMISSION "m_StateIntermission"

enum
{
STATE_WARMUP_INDEX = 0,
STATE_INTERMISSION_INDEX,
STATE_ROUND_INDEX
}

enum
{
STATE_ELEMENT_DONE_TIME = 0,
STATE_ELEMENT_NEXT_STATE,
STATE_ELEMENT_IS_IN_INTERMISSION
}
6 changes: 3 additions & 3 deletions scripting/include/srccoop/checkpoint.inc
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ enum struct CCoopEquipment
for (int i = 0; i < MAX_AMMO_TYPES; i++)
{
if (this.m_iAmmoCount[i] >= 0)
pPlayer.SetAmmoFromIndex(i, this.m_iAmmoCount[i]);
pPlayer.SetAmmoFromIndex(view_as<AmmoType_t>(i), this.m_iAmmoCount[i]);
}

if (this.m_szActiveWeapon[0] != '\0')
Expand Down Expand Up @@ -455,9 +455,9 @@ enum struct CCoopEquipment
}
#endif // SRCCOOP_BLACKMESA

for (int iAmmo = 0; iAmmo < MAX_AMMO_TYPES; iAmmo++)
for (int iAmmoType = 0; iAmmoType < MAX_AMMO_TYPES; ++iAmmoType)
{
this.m_iAmmoCount[iAmmo] = pPlayer.GetAmmoFromIndex(iAmmo);
this.m_iAmmoCount[iAmmoType] = pPlayer.GetAmmoFromIndex(view_as<AmmoType_t>(iAmmoType));
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions scripting/include/srccoop/entitypatch.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1148,8 +1148,8 @@ public MRESReturn Hook_BaseNpcUpdateSleepState(int _this, Handle hParams)
if (pBaseNPC.HasCondition(view_as<int>(COND_IN_PVS)))
{
// OK, we're in the player's PVS. Now switch to regular old AUTO_PVS sleep rules.
pBaseNPC.AddSleepFlags(view_as<int>(AI_SLEEP_FLAG_AUTO_PVS));
pBaseNPC.RemoveSleepFlags(view_as<int>(AI_SLEEP_FLAG_AUTO_PVS_AFTER_PVS));
pBaseNPC.AddSleepFlags(AI_SLEEP_FLAG_AUTO_PVS);
pBaseNPC.RemoveSleepFlags(AI_SLEEP_FLAG_AUTO_PVS_AFTER_PVS);
}
}
}
Expand Down Expand Up @@ -1373,7 +1373,7 @@ public MRESReturn Hook_LoadSavedAcceptInput(int _this, Handle hReturn, Handle hP
int r, g, b, a;
GetEntityRenderColor(_this, r, g, b, a);
float duration = GetEntPropFloat(_this, Prop_Data, "m_Duration");
Client_ScreenFade(iActivator, RoundFloat(duration * 1000), FFADE_OUT|FFADE_STAYOUT, _, r, g, b, a);
Client_ScreenFade(iActivator, RoundFloat(duration * 1000), view_as<int>(FFADE_OUT | FFADE_STAYOUT), _, r, g, b, a);

// This breaks the spectator overlay if the player is already dead
if (pActivator.IsAlive())
Expand Down
14 changes: 7 additions & 7 deletions scripting/include/srccoop/manager.inc
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,12 @@ methodmap CoopManager
if (g_pLevelLump.m_iIntroType == INTRO_FADE)
{
pPlayer.m_fFlags |= (FL_ATCONTROLS | FL_FROZEN | FL_NOTARGET); // Freeze controls and angles.
Client_ScreenFade(pPlayer.entindex, 0, FFADE_STAYOUT);
Client_ScreenFade(pPlayer.entindex, 0, view_as<int>(FFADE_STAYOUT));
}
else if (g_pLevelLump.m_iIntroType == INTRO_FREEZE)
{
pPlayer.m_fFlags |= (FL_ATCONTROLS | FL_NOTARGET); // Freeze controls.
Client_ScreenFade(pPlayer.entindex, Conf.FROZEN_FADE_DUR_IN, FFADE_OUT | FFADE_STAYOUT, _,
Client_ScreenFade(pPlayer.entindex, Conf.FROZEN_FADE_DUR_IN, view_as<int>(FFADE_OUT | FFADE_STAYOUT), _,
Conf.FROZEN_FADE_COLOR[0], Conf.FROZEN_FADE_COLOR[1], Conf.FROZEN_FADE_COLOR[2], Conf.FROZEN_FADE_COLOR[3]);
}

Expand Down Expand Up @@ -561,18 +561,18 @@ methodmap CoopManager
* Must be called after teams had been created.
* Returns -1 on failure / if teams are not to be enforced.
*/
public static int GetEnforcedTeam()
public static Team_t GetEnforcedTeam()
{
char szTeam[MAX_TEAMNAME];
int iTeam;

g_pConvarCoopTeam.GetString(szTeam, sizeof(szTeam));

int iTeam;
if (!StringToIntEx(szTeam, iTeam))
{
iTeam = FindTeamByName(szTeam);
}

return (iTeam > TEAM_SPECTATOR) ? iTeam : -1;
return (view_as<Team_t>(iTeam) > TEAM_SPECTATOR) ? view_as<Team_t>(iTeam) : TEAM_INVALID;
}
}

Expand Down Expand Up @@ -619,7 +619,7 @@ public Action Timer_DecrementUntilMapStart(Handle hTimer)
pPlayer.m_fFlags &= ~(FL_ATCONTROLS | FL_FROZEN | FL_NOTARGET);
if (g_pLevelLump.m_iIntroType == INTRO_FREEZE)
{
Client_ScreenFade(pPlayer.entindex, Conf.FROZEN_FADE_DUR_OUT, FFADE_PURGE | FFADE_IN, 1,
Client_ScreenFade(pPlayer.entindex, Conf.FROZEN_FADE_DUR_OUT, view_as<int>(FFADE_PURGE | FFADE_IN), 1,
Conf.FROZEN_FADE_COLOR[0], Conf.FROZEN_FADE_COLOR[1], Conf.FROZEN_FADE_COLOR[2], Conf.FROZEN_FADE_COLOR[3]);
}
}
Expand Down
6 changes: 3 additions & 3 deletions scripting/include/srccoop/manager_survival.inc
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ methodmap SurvivalManager {
ShowVGUIPanel(client, "specgui", null);

// Remove previous fades
Client_ScreenFade(client, 1500, FFADE_IN|FFADE_PURGE, 1, 0, 0, 0, 255);
Client_ScreenFade(client, 1500, view_as<int>(FFADE_IN | FFADE_PURGE), 1, 0, 0, 0, 255);

SetHudTextParams(0.016, 0.04, 5.0, 255, 255, 255, 255, 1, 1.0, 1.0, 1.0);
if (SurvivalManager.GetRespawnAtCheckpoints() && CCoopSpawnSystem.CountCheckpoints(true, true))
Expand All @@ -166,7 +166,7 @@ methodmap SurvivalManager {
return true;
}

public static void OnPlayerChangeTeam(CBasePlayer pPlayer, int iTeamNum)
public static void OnPlayerChangeTeam(const CBasePlayer pPlayer, const Team_t eTeam)
{
if (SurvivalManager.GetMode())
{
Expand Down Expand Up @@ -298,7 +298,7 @@ methodmap SurvivalManager {
{
CBasePlayer pPlayer = CBasePlayer(i);
if (pPlayer.GetTeam() != TEAM_SPECTATOR)
Client_ScreenFade(i, 1000, FFADE_OUT|FFADE_STAYOUT, _, 0, 0, 0, 255);
Client_ScreenFade(i, 1000, view_as<int>(FFADE_OUT | FFADE_STAYOUT), _, 0, 0, 0, 255);

#if defined SRCCOOP_BLACKMESA
if (!IsTranslatedForLanguage("survival game over", GetClientLanguage(i)))
Expand Down
18 changes: 9 additions & 9 deletions scripting/include/srccoop/playerpatch.inc
Original file line number Diff line number Diff line change
Expand Up @@ -735,16 +735,16 @@ public MRESReturn Hook_PlayerChangeTeam(int iClient, DHookParam hParams)
if (!CMultiplayRules.IsTeamplay())
return MRES_Ignored;

int iTeamNum = hParams.Get(1);
if (iTeamNum == TEAM_UNASSIGNED || iTeamNum > TEAM_SPECTATOR)
Team_t eTeam = hParams.Get(1);
if (eTeam == TEAM_UNASSIGNED || eTeam > TEAM_SPECTATOR)
{
int iEnforcedTeam = CoopManager.GetEnforcedTeam();
if (iEnforcedTeam != -1)
Team_t eEnforcedTeam = CoopManager.GetEnforcedTeam();
if (eEnforcedTeam != TEAM_INVALID)
{
hParams.Set(1, iEnforcedTeam);
hParams.Set(1, eEnforcedTeam);
return MRES_ChangedHandled;
}
if (iTeamNum == TEAM_UNASSIGNED)
if (eTeam == TEAM_UNASSIGNED)
{
hParams.Set(1, TEAM_SCIENTIST);
return MRES_ChangedHandled;
Expand All @@ -759,8 +759,8 @@ public MRESReturn Hook_PlayerChangeTeamPost(int iClient, Handle hParams)
if (CoopManager.IsCoopModeEnabled())
{
CBasePlayer pPlayer = CBasePlayer(iClient);
int iTeamNum = DHookGetParam(hParams, 1);
if (iTeamNum == TEAM_SPECTATOR)
Team_t eTeam = DHookGetParam(hParams, 1);
if (eTeam == TEAM_SPECTATOR)
{
CBaseEntity pRagdoll = pPlayer.GetRagdoll();
if (pRagdoll != NULL_CBASEENTITY)
Expand All @@ -770,7 +770,7 @@ public MRESReturn Hook_PlayerChangeTeamPost(int iClient, Handle hParams)
ClearNpcMemoryForPlayer(pPlayer);
}

SurvivalManager.OnPlayerChangeTeam(pPlayer, iTeamNum);
SurvivalManager.OnPlayerChangeTeam(pPlayer, eTeam);
}
return MRES_Ignored;
}
Expand Down
4 changes: 2 additions & 2 deletions scripting/include/srccoop/public.inc
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ enum struct SpawnOptions
this.bUseSpawnSystem = true;
this.bUseSpawnEquipment = true;
this.bRevive = false;
this.vecOrigin = vec3_origin;
this.vecAngles = vec3_origin;
this.vecOrigin = { 0.0, 0.0, 0.0 };
this.vecAngles = { 0.0, 0.0, 0.0 };
this.bUnstuck = true;
}
}
4 changes: 2 additions & 2 deletions scripting/include/srccoop/utils.inc
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ stock CBasePlayer GetNearestPlayerEx(float vecPos[3], bool bAliveOnly = true, bo
if (!bAlive)
continue;
}
else if (bNoSpectators && GetClientTeam(i) == TEAM_SPECTATOR)
else if (bNoSpectators && view_as<Team_t>(GetClientTeam(i)) == TEAM_SPECTATOR)
{
continue;
}
Expand Down Expand Up @@ -728,7 +728,7 @@ stock int GetRealClientCount(bool bInGameOnly, bool bAliveOnly = false, bool bNo
if ((bInGameOnly? IsClientInGame(i) : IsClientConnected(i))
&& !IsFakeClient(i)
&& (!bAliveOnly || IsPlayerAlive(i))
&& (!bNoSpectators || GetClientTeam(i) != TEAM_SPECTATOR))
&& (!bNoSpectators || view_as<Team_t>(GetClientTeam(i)) != TEAM_SPECTATOR))
{
clients++;
}
Expand Down
4 changes: 0 additions & 4 deletions scripting/include/srccoop_api.inc
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@
#include <topmenus>

#include <srccoop/util/assert>
#include <srccoop/typedef_game>
#include <srccoop/public>
#if defined SRCCOOP_BLACKMESA
#include <srccoop/blackmesa/typedef>
#endif
#include <srccoop_api/classdef>
#include <srccoop/utils>
#include <srccoop/features>
Expand Down
1 change: 1 addition & 0 deletions scripting/include/srccoop_api/classdef.inc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <sdktools>
#include <sourcescramble>
#include <srccoop/util/color>
#include <srccoop_api/typedef>

#include <srccoop_api/classdef/common/CBaseEntity.inc>
#include <srccoop_api/classdef/common/CPointEntity.inc>
Expand Down
28 changes: 16 additions & 12 deletions scripting/include/srccoop_api/classdef/common/CAI_BaseNPC.inc
Original file line number Diff line number Diff line change
Expand Up @@ -148,25 +148,25 @@ methodmap CAI_BaseNPC < CBaseCombatCharacter
{
return GetEntPropFloat(this.entindex, Prop_Data, "m_flWakeRadius");
}
public int GetSleepFlags()
public AI_SleepFlags_t GetSleepFlags()
{
return GetEntProp(this.entindex, Prop_Data, "m_SleepFlags");
return view_as<AI_SleepFlags_t>(GetEntProp(this.entindex, Prop_Data, "m_SleepFlags"));
}
public int SetSleepFlags(const int iSleepFlags)
public int SetSleepFlags(const AI_SleepFlags_t eSleepFlags)
{
SetEntProp(this.entindex, Prop_Data, "m_SleepFlags", iSleepFlags);
SetEntProp(this.entindex, Prop_Data, "m_SleepFlags", eSleepFlags);
}
public bool HasSleepFlags(const int iSleepFlags)
public bool HasSleepFlags(const AI_SleepFlags_t eSleepFlags)
{
return (this.GetSleepFlags() & iSleepFlags) == iSleepFlags;
return (this.GetSleepFlags() & eSleepFlags) == eSleepFlags;
}
public void AddSleepFlags(const int iSleepFlags)
public void AddSleepFlags(const AI_SleepFlags_t eSleepFlags)
{
this.SetSleepFlags(this.GetSleepFlags() | iSleepFlags);
this.SetSleepFlags(this.GetSleepFlags() | eSleepFlags);
}
public void RemoveSleepFlags(const int iSleepFlags)
public void RemoveSleepFlags(const AI_SleepFlags_t eSleepFlags)
{
this.SetSleepFlags(this.GetSleepFlags() & ~iSleepFlags);
this.SetSleepFlags(this.GetSleepFlags() & ~eSleepFlags);
}
public AI_SleepState_t GetSleepState()
{
Expand Down Expand Up @@ -202,7 +202,7 @@ methodmap CAI_BaseNPC < CBaseCombatCharacter
{
SetEntPropEnt(this.entindex, Prop_Data, "m_hEnemy", pEntity.entindex);
}
public int GetSoundInterests()
public Sound_t GetSoundInterests()
{
return SDKCall(g_pGetSoundInterests, this);
}
Expand Down Expand Up @@ -284,10 +284,14 @@ methodmap CAI_BaseNPC < CBaseCombatCharacter
{
return GetEntProp(this.entindex, Prop_Data, "iTaskInterrupt");
}
public GoalType_t GetGoalType()
{
return view_as<GoalType_t>(GetEntProp(this.entindex, Prop_Data, "m_goalType"));
}
public bool IsMoving()
{
// CAI_BaseNPC::IsMoving( void ) ==> GetNavigator()->IsGoalSet() ==> GetPath()->GoalType() != GOALTYPE_NONE
return GetEntProp(this.entindex, Prop_Data, "m_goalType") != GOALTYPE_NONE;
return this.GetGoalType() != GOALTYPE_NONE;
}
public bool ShouldPlayerAvoid()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ methodmap CBaseAnimating < CBaseEntity
SetEntProp(this.entindex, Prop_Send, "m_nForceBone", iForceBone);
}
#if defined SRCCOOP_BLACKMESA
public int SelectWeightedSequence(const int iActivity)
public int SelectWeightedSequence(const Activity_t eActivity)
{
// TODO:
// This is currently only implemented in Black Mesa but it may be required for others.
// Reimplement the logic from scratch.
return SDKCall(g_pSelectWeightedSequence, this.entindex, iActivity);
return SDKCall(g_pSelectWeightedSequence, this.entindex, eActivity);
}
#endif
public float GetPoseParameter(const int iIndex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ methodmap CBaseCombatCharacter < CBaseFlex
return view_as<CBaseCombatCharacter>(CBaseFlex(iEntIndex));
}

public int GetLifeState()
public LifeState_t GetLifeState()
{
return GetEntProp(this.entindex, Prop_Data, "m_lifeState");
return view_as<LifeState_t>(GetEntProp(this.entindex, Prop_Data, "m_lifeState"));
}
public bool IsAlive()
{
Expand Down Expand Up @@ -90,13 +90,13 @@ methodmap CBaseCombatCharacter < CBaseFlex
{
SetEntPropEnt(this.entindex, Prop_Send, "m_hMyWeapons", pWeapon.entindex, iIndex);
}
public int GetAmmoFromIndex(const int iIndex)
public int GetAmmoFromIndex(const AmmoType_t eAmmoType)
{
return GetEntProp(this.entindex, Prop_Send, "m_iAmmo", _, iIndex);
return GetEntProp(this.entindex, Prop_Send, "m_iAmmo", _, view_as<int>(eAmmoType));
}
public void SetAmmoFromIndex(const int iIndex, const int iAmmoCount)
public void SetAmmoFromIndex(const AmmoType_t eAmmoType, const int iAmmoCount)
{
SetEntProp(this.entindex, Prop_Send, "m_iAmmo", iAmmoCount, _, iIndex);
SetEntProp(this.entindex, Prop_Send, "m_iAmmo", iAmmoCount, _, view_as<int>(eAmmoType));
}
public float GetNextAttack()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ methodmap CBaseCombatWeapon < CBaseAnimating
{
SetEntPropFloat(this.entindex, Prop_Data, "m_flTimeWeaponIdle", flTimeIdle);
}
public bool SendWeaponAnim(const int iActivity)
public bool SendWeaponAnim(const Activity_t eActivity)
{
return SDKCall(g_pSendWeaponAnim, this.entindex, iActivity);
return SDKCall(g_pSendWeaponAnim, this.entindex, eActivity);
}
public bool IsReloading()
{
Expand Down
Loading

0 comments on commit 5beb976

Please sign in to comment.