Skip to content

Commit cc7a41c

Browse files
authored
Moved utils, refactoring (#214)
* Moved utils, refactoring * Update srccoop_addon_landing_screen.sp * Retype dhooks handles * Convert sleep flags to property * Split Class_T per game * Shared config loading * Add StrStartsWith * Consolidate generic trace filters * Cleanup KeyValue functions * Add guards to some bms only variables * Return null in InitSourceCoopAddon * Make CanTeleportPlayer dependencies static * Add CRagdollProp - CreateServerRagdoll * fix sdkcall init * Re-add stock modifier * Fail CI on warnings
1 parent 94ea558 commit cc7a41c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+3819
-1695
lines changed

.github/workflows/plugin.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ jobs:
3636
do
3737
plugin="$(basename "${file%.*}")"
3838
echo -e "\nCompiling $plugin\n"
39-
spcomp -v2 -i scripting/include -o plugins/"$plugin".smx "$file" NO_DEBUG=1 ${{ matrix.game.args }}
40-
spcomp -v2 -i scripting/include -o plugins/disabled/srccoop_debug/"$plugin".smx "$file" ${{ matrix.game.args }}
39+
spcomp -v2 --warnings-as-errors -i scripting/include -o plugins/"$plugin".smx "$file" NO_DEBUG=1 ${{ matrix.game.args }}
40+
spcomp -v2 --warnings-as-errors -i scripting/include -o plugins/disabled/srccoop_debug/"$plugin".smx "$file" ${{ matrix.game.args }}
4141
done
4242
4343
- name: Create package

scripting/include/logdebug.inc

-5
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@
77
* Define NO_DEBUG before including this file to completely disable all debugging
88
*/
99

10-
#if defined _logdebug_included
11-
#endinput
12-
#endif
13-
#define _logdebug_included
14-
1510
#pragma newdecls required
1611
#pragma semicolon 1
1712

scripting/include/srccoop.inc

+5-13
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
#if defined _srccoop_included
2-
#endinput
3-
#endif
4-
#define _srccoop_included
5-
61
#pragma newdecls required
72
#pragma semicolon 1
83

@@ -142,22 +137,19 @@
142137
// Includes
143138
//------------------------------------------------------
144139

145-
146140
#include <sourcemod>
147141
#include <sdktools>
148142
#include <sdkhooks>
149143
#include <regex>
150144
#include <dhooks>
151145
#include <topmenus>
152-
#include <sourcescramble>
153146

147+
#include <sourcescramble>
154148
#include <logdebug>
155149

156-
#include <srccoop/util/assert>
157150
#include <srccoop/typedef>
158151
#include <srccoop/public>
159-
#include <srccoop_api/classdef>
160-
#include <srccoop/utils>
152+
#include <srccoop_api>
161153
#include <srccoop/config>
162154
#include <srccoop/features>
163155
#include <srccoop/globals>
@@ -168,9 +160,9 @@
168160
#include <srccoop/manager_persistence>
169161
#include <srccoop/entitypatch>
170162
#if defined SRCCOOP_BLACKMESA
171-
#include <srccoop/blackmesa/entitypatch>
172-
#include <srccoop/blackmesa/deathnotice>
173-
#include <srccoop/blackmesa/idle_anims>
163+
#include <srccoop/bms/entitypatch>
164+
#include <srccoop/bms/deathnotice>
165+
#include <srccoop/bms/idle_anims>
174166
#elseif defined SRCCOOP_HL2DM
175167
#include <srccoop/hl2dm/deathnotice>
176168
#endif

scripting/include/srccoop/blackmesa/typedef.inc

Whitespace-only changes.

scripting/include/srccoop/blackmesa/deathnotice.inc renamed to scripting/include/srccoop/bms/deathnotice.inc

-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
#if defined _srccoop_deathnotice_game_included
2-
#endinput
3-
#endif
4-
#define _srccoop_deathnotice_game_included
5-
61
#pragma newdecls required
72
#pragma semicolon 1
83

scripting/include/srccoop/blackmesa/entitypatch.inc renamed to scripting/include/srccoop/bms/entitypatch.inc

+23-29
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
#if defined _srccoop_entitypatch_bm_included
2-
#endinput
3-
#endif
4-
#define _srccoop_entitypatch_bm_included
5-
61
#pragma newdecls required
72
#pragma semicolon 1
83

@@ -15,7 +10,7 @@ static bool g_pPlayerIronsightClassic[MAXPLAYERS + 1];
1510
// scientists should classify as allies (in MP, base function returns false when player is not passed in)
1611
// this allows npcs to pass filter in "player ally only" triggers
1712
//------------------------------------------------------
18-
public MRESReturn Hook_IsPlayerAlly(int _this, Handle hReturn, Handle hParams)
13+
public MRESReturn Hook_IsPlayerAlly(int _this, DHookReturn hReturn, DHookParam hParams)
1914
{
2015
DHookSetReturn(hReturn, true);
2116
return MRES_Supercede;
@@ -66,7 +61,7 @@ public void Hook_GargSpawnPost(int iEntIndex)
6661
// CAI_BaseNPC - npc_gargantua
6762
// fix the 'ChasePlayer' input by setting a target ent.
6863
//------------------------------------------------------
69-
public MRESReturn Hook_GargAcceptInputPost(int _this, Handle hReturn, Handle hParams)
64+
public MRESReturn Hook_GargAcceptInputPost(int _this, DHookReturn hReturn, DHookParam hParams)
7065
{
7166
if (!DHookIsNullParam(hParams, 1))
7267
{
@@ -262,7 +257,7 @@ public void Hook_XenTurretSpawnPost(int iEntIndex)
262257
//------------------------------------------------------
263258
CBaseEntity g_pActiveMarionettist[MAXPLAYERS+1] = {view_as<CBaseEntity>(-1), ...};
264259

265-
public MRESReturn Hook_MarionettistAcceptInput(int _this, Handle hReturn, Handle hParams)
260+
public MRESReturn Hook_MarionettistAcceptInput(int _this, DHookReturn hReturn, DHookParam hParams)
266261
{
267262
if (CoopManager.IsCoopModeEnabled())
268263
{
@@ -543,7 +538,7 @@ public MRESReturn Hook_MusicTrackThink(int _this)
543538
return MRES_Supercede;
544539
}
545540

546-
public MRESReturn Hook_MusicTrackAcceptInput(int _this, Handle hReturn, Handle hParams)
541+
public MRESReturn Hook_MusicTrackAcceptInput(int _this, DHookReturn hReturn, DHookParam hParams)
547542
{
548543
char szInputType[MAX_FORMAT];
549544
char szBuffer[MAX_VALUE];
@@ -648,7 +643,7 @@ public MRESReturn Hook_TestGroundMove(Address _this, DHookReturn hReturn, DHookP
648643
// `env_xen_portal_effect`
649644
// Fixes xen portals not pushing players.
650645
//------------------------------------------------------
651-
public MRESReturn Hook_XenPortalEffect_AcceptInput(int _this, Handle hReturn, Handle hParams)
646+
public MRESReturn Hook_XenPortalEffect_AcceptInput(int _this, DHookReturn hReturn, DHookParam hParams)
652647
{
653648
char szInputType[MAX_FORMAT];
654649
DHookGetParamString(hParams, 1, szInputType, sizeof(szInputType));
@@ -823,7 +818,7 @@ public void Hook_GrenadeFragSpawnPost(const int iEntIndex)
823818
// weapon_357/weapon_crossbow
824819
// New constructed logic of toggling ironsights.
825820
//------------------------------------------------------
826-
public MRESReturn Hook_ToggleIronsights(int _this, Handle hParams)
821+
public MRESReturn Hook_ToggleIronsights(int _this, DHookParam hParams)
827822
{
828823
if (CoopManager.IsFeatureEnabled(FT_SP_WEAPONS))
829824
{
@@ -875,8 +870,7 @@ public MRESReturn Hook_ToggleIronsights(int _this, Handle hParams)
875870
}
876871
pPlayer.SetFOV(pWeapon, bWillBeUsingIronsights ? iFOV : 0, 0.5);
877872
pWeapon.SetIronsights(bWillBeUsingIronsights);
878-
879-
PreventWeaponFiring(pWeapon, 0.5);
873+
pWeapon.DelayNextAttack(0.5);
880874

881875
return MRES_Supercede;
882876
}
@@ -887,7 +881,7 @@ public MRESReturn Hook_ToggleIronsights(int _this, Handle hParams)
887881
// weapon_357
888882
// Fixes the shooting animation played while using ironsights.
889883
//------------------------------------------------------
890-
public MRESReturn Hook_IronsightGetPrimaryAttackActivity(int _this, Handle hReturn)
884+
public MRESReturn Hook_IronsightGetPrimaryAttackActivity(int _this, DHookReturn hReturn)
891885
{
892886
if (CoopManager.IsFeatureEnabled(FT_SP_WEAPONS))
893887
{
@@ -909,7 +903,7 @@ public MRESReturn Hook_IronsightGetPrimaryAttackActivity(int _this, Handle hRetu
909903
// weapon_crossbow
910904
// Fixes the shooting animation played while using ironsights.
911905
//------------------------------------------------------
912-
public MRESReturn Hook_CrossbowGetPrimaryAttackActivity(int _this, Handle hReturn)
906+
public MRESReturn Hook_CrossbowGetPrimaryAttackActivity(int _this, DHookReturn hReturn)
913907
{
914908
if (CoopManager.IsFeatureEnabled(FT_SP_WEAPONS))
915909
{
@@ -941,7 +935,7 @@ void ConvarQuery_IronsightClassic(QueryCookie hCookie, int iClient, ConVarQueryR
941935
//------------------------------------------------------
942936
// Caches the client settings used for ironsights.
943937
//------------------------------------------------------
944-
public MRESReturn Hook_IronsightDeployPost_SaveSettings(int _this, Handle hReturn)
938+
public MRESReturn Hook_IronsightDeployPost_SaveSettings(int _this, DHookReturn hReturn)
945939
{
946940
if (CoopManager.IsFeatureEnabled(FT_SP_WEAPONS))
947941
{
@@ -959,7 +953,7 @@ public MRESReturn Hook_IronsightDeployPost_SaveSettings(int _this, Handle hRetur
959953
// grenade_bolt
960954
// Disables explosive bolts by blocking the call.
961955
//------------------------------------------------------
962-
public MRESReturn Hook_GrenadeBoltAcceptInput(int _this, Handle hReturn, Handle hParams)
956+
public MRESReturn Hook_GrenadeBoltAcceptInput(int _this, DHookReturn hReturn, DHookParam hParams)
963957
{
964958
if (CoopManager.IsFeatureEnabled(FT_SP_WEAPONS))
965959
{
@@ -978,7 +972,7 @@ public MRESReturn Hook_GrenadeBoltAcceptInput(int _this, Handle hReturn, Handle
978972
// weapon_crossbow
979973
// Sets the skin of the crossbow.
980974
//------------------------------------------------------
981-
public MRESReturn Hook_CrossbowDeployPost(int _this, Handle hReturn)
975+
public MRESReturn Hook_CrossbowDeployPost(int _this, DHookReturn hReturn)
982976
{
983977
if (CoopManager.IsFeatureEnabled(FT_SP_WEAPONS))
984978
{
@@ -1004,7 +998,7 @@ public MRESReturn Hook_CrossbowDeployPost(int _this, Handle hReturn)
1004998
// TODO: Hooking ItemPostFrame with IsMultiplayer = false causes prediction issues.
1005999
// Fix this by not calling IsMultiplayer = false.
10061000
//------------------------------------------------------
1007-
public MRESReturn Hook_CrossbowItemPostFrame(int _this, Handle hReturn)
1001+
public MRESReturn Hook_CrossbowItemPostFrame(int _this, DHookReturn hReturn)
10081002
{
10091003
if (CoopManager.IsFeatureEnabled(FT_SP_WEAPONS))
10101004
{
@@ -1032,7 +1026,7 @@ public MRESReturn Hook_CrossbowItemPostFrame(int _this, Handle hReturn)
10321026
// weapon_crossbow
10331027
// See `Hook_CrossbowItemPostFrame` for details.
10341028
//------------------------------------------------------
1035-
public MRESReturn Hook_CrossbowItemPostFramePost(int _this, Handle hReturn)
1029+
public MRESReturn Hook_CrossbowItemPostFramePost(int _this, DHookReturn hReturn)
10361030
{
10371031
if (CoopManager.IsFeatureEnabled(FT_SP_WEAPONS))
10381032
{
@@ -1049,7 +1043,7 @@ public MRESReturn Hook_CrossbowItemPostFramePost(int _this, Handle hReturn)
10491043
// - Sets the rearm bool
10501044
// - Sets animations
10511045
//------------------------------------------------------
1052-
public MRESReturn Hook_CrossbowPrimaryAttack(int _this, Handle hReturn, Handle hParams)
1046+
public MRESReturn Hook_CrossbowPrimaryAttack(int _this, DHookReturn hReturn, DHookParam hParams)
10531047
{
10541048
if (CoopManager.IsFeatureEnabled(FT_SP_WEAPONS))
10551049
{
@@ -1062,7 +1056,7 @@ public MRESReturn Hook_CrossbowPrimaryAttack(int _this, Handle hReturn, Handle h
10621056
// weapon_crossbow
10631057
// See `Hook_CrossbowPrimaryAttack` for details.
10641058
//------------------------------------------------------
1065-
public MRESReturn Hook_CrossbowPrimaryAttackPost(int _this, Handle hReturn, Handle hParams)
1059+
public MRESReturn Hook_CrossbowPrimaryAttackPost(int _this, DHookReturn hReturn, DHookParam hParams)
10661060
{
10671061
if (CoopManager.IsFeatureEnabled(FT_SP_WEAPONS))
10681062
{
@@ -1075,7 +1069,7 @@ public MRESReturn Hook_CrossbowPrimaryAttackPost(int _this, Handle hReturn, Hand
10751069
// weapon_crossbow
10761070
// Fixes the rearm animation when pulling out the crossbow.
10771071
//------------------------------------------------------
1078-
public MRESReturn Hook_CrossbowGetDrawActivity(int _this, Handle hReturn)
1072+
public MRESReturn Hook_CrossbowGetDrawActivity(int _this, DHookReturn hReturn)
10791073
{
10801074
if (CoopManager.IsFeatureEnabled(FT_SP_WEAPONS))
10811075
{
@@ -1088,7 +1082,7 @@ public MRESReturn Hook_CrossbowGetDrawActivity(int _this, Handle hReturn)
10881082
// weapon_crossbow
10891083
// See `Hook_CrossbowGetDrawActivity` for details.
10901084
//------------------------------------------------------
1091-
public MRESReturn Hook_CrossbowGetDrawActivityPost(int _this, Handle hReturn)
1085+
public MRESReturn Hook_CrossbowGetDrawActivityPost(int _this, DHookReturn hReturn)
10921086
{
10931087
if (CoopManager.IsFeatureEnabled(FT_SP_WEAPONS))
10941088
{
@@ -1102,7 +1096,7 @@ public MRESReturn Hook_CrossbowGetDrawActivityPost(int _this, Handle hReturn)
11021096
// `CWeapon_Crossbow::FireBolt` is only called by `CWeapon_Crossbow::PrimaryAttack` which is hooked.
11031097
// If this gets called with singleplayer being set, this will crash the server.
11041098
//------------------------------------------------------
1105-
public MRESReturn Hook_CrossbowFireBolt(int _this, Handle hReturn, Handle hParams)
1099+
public MRESReturn Hook_CrossbowFireBolt(int _this, DHookReturn hReturn, DHookParam hParams)
11061100
{
11071101
if (CoopManager.IsFeatureEnabled(FT_SP_WEAPONS))
11081102
{
@@ -1115,7 +1109,7 @@ public MRESReturn Hook_CrossbowFireBolt(int _this, Handle hReturn, Handle hParam
11151109
// weapon_crossbow
11161110
// See `Hook_CrossbowFireBolt` for details.
11171111
//------------------------------------------------------
1118-
public MRESReturn Hook_CrossbowFireBoltPost(int _this, Handle hReturn, Handle hParams)
1112+
public MRESReturn Hook_CrossbowFireBoltPost(int _this, DHookReturn hReturn, DHookParam hParams)
11191113
{
11201114
if (CoopManager.IsFeatureEnabled(FT_SP_WEAPONS))
11211115
{
@@ -1128,7 +1122,7 @@ public MRESReturn Hook_CrossbowFireBoltPost(int _this, Handle hReturn, Handle hP
11281122
// weapon_tau
11291123
// Fixes the tau velocity.
11301124
//------------------------------------------------------
1131-
public MRESReturn Hook_TauFireBeam(int _this, Handle hReturn)
1125+
public MRESReturn Hook_TauFireBeam(int _this, DHookReturn hReturn)
11321126
{
11331127
if (CoopManager.IsFeatureEnabled(FT_SP_WEAPONS))
11341128
{
@@ -1141,7 +1135,7 @@ public MRESReturn Hook_TauFireBeam(int _this, Handle hReturn)
11411135
// weapon_tau
11421136
// See `Hook_TauFireBeamPost` for details.
11431137
//------------------------------------------------------
1144-
public MRESReturn Hook_TauFireBeamPost(int _this, Handle hReturn)
1138+
public MRESReturn Hook_TauFireBeamPost(int _this, DHookReturn hReturn)
11451139
{
11461140
if (CoopManager.IsFeatureEnabled(FT_SP_WEAPONS))
11471141
{
@@ -1171,7 +1165,7 @@ public MRESReturn Hook_Dissolve(int _this, DHookReturn hReturn, DHookParam hPara
11711165

11721166
// Switches between using singleplayer and multiplayer weapon values.
11731167
// This will get triggered by the command `params_reload_server`.
1174-
public MRESReturn Hook_CParamsManager_InitInstances(Address _this, Handle hReturn, Handle hParams)
1168+
public MRESReturn Hook_CParamsManager_InitInstances(Address _this, DHookReturn hReturn, DHookParam hParams)
11751169
{
11761170
// TODO:
11771171
// Currently, this is getting only called during level init, but

scripting/include/srccoop/blackmesa/idle_anims.inc renamed to scripting/include/srccoop/bms/idle_anims.inc

-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
#if defined _srccoop_idle_anims_game_included
2-
#endinput
3-
#endif
4-
#define _srccoop_idle_anims_game_included
5-
61
#pragma newdecls required
72
#pragma semicolon 1
83

scripting/include/srccoop/checkpoint.inc

-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
#if defined _srccoop_checkpoint_included
2-
#endinput
3-
#endif
4-
#define _srccoop_checkpoint_included
5-
61
#pragma newdecls required
72
#pragma semicolon 1
83

scripting/include/srccoop/commands.inc

-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
#if defined _srccoop_commands_included
2-
#endinput
3-
#endif
4-
#define _srccoop_commands_included
5-
61
#pragma newdecls required
72
#pragma semicolon 1
83

scripting/include/srccoop/config.inc

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
#if defined _srccoop_config_included
2-
#endinput
3-
#endif
4-
#define _srccoop_config_included
5-
61
#pragma newdecls required
72
#pragma semicolon 1
83

@@ -21,11 +16,11 @@ enum struct SourceCoopConfig
2116
float PORTAL_TOUCH_SIZE;
2217

2318
//------------------------------------------------------
24-
// MANAGER
19+
// COOPMANAGER
2520
//------------------------------------------------------
2621

2722
// Freeze intro - screenfade properties
28-
int FROZEN_FADE_COLOR[4];
23+
RGBA FROZEN_FADE_COLOR;
2924
int FROZEN_FADE_DUR_IN;
3025
int FROZEN_FADE_DUR_OUT;
3126

scripting/include/srccoop/deathnotice.inc

-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
#if defined _srccoop_deathnotice_included
2-
#endinput
3-
#endif
4-
#define _srccoop_deathnotice_included
5-
61
#pragma newdecls required
72
#pragma semicolon 1
83

0 commit comments

Comments
 (0)