Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SourceMod 1.12 Migration #164

Merged
merged 6 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
id: setup-sp
uses: rumblefrog/setup-sp@master
with:
version: '1.11.6960'
version: '1.12.7163'
version-file: ./scripting/include/srccoop/public.inc
define-name: SRCCOOP_VERSION

Expand All @@ -35,8 +35,8 @@ jobs:
do
plugin="$(basename "${file%.*}")"
echo -e "\nCompiling $plugin\n"
spcomp -v2 -i scripting/include -o plugins/"$plugin" "$file" NO_DEBUG=1 ${{ matrix.game.args }}
spcomp -v2 -i scripting/include -o plugins/disabled/srccoop_debug/"$plugin" "$file" ${{ matrix.game.args }}
spcomp -v2 -i scripting/include -o plugins/"$plugin".smx "$file" NO_DEBUG=1 ${{ matrix.game.args }}
spcomp -v2 -i scripting/include -o plugins/disabled/srccoop_debug/"$plugin".smx "$file" ${{ matrix.game.args }}
done

- name: Create package
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ The script installation will automatically go through the process of installing
quit
```
- Install [Metamod:Source](https://www.sourcemm.net/downloads.php?branch=stable) (latest tested build ➤ __1155__) onto the server.
- Install [SourceMod](https://www.sourcemod.net/downloads.php?branch=stable) (latest tested build ➤ __6968__) onto the server.
- Install [SourceMod](https://www.sourcemod.net/downloads.php?branch=stable) (latest tested build ➤ __7163__) onto the server.
- Install [the latest SourceCoop release](https://github.com/ampreeT/SourceCoop/releases) onto the server.
- [Forward the necessary ports.](#port-forwarding)

Expand Down
10 changes: 2 additions & 8 deletions scripting/include/srccoop.inc
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,10 @@

#if !defined SRCCOOP_CUSTOM_COMPILE

// Uncomment to disable debugging
// #define NO_DEBUG

#if defined SRCCOOP_HL2DM

#define CHECK_ENGINE "HL2DM"; if (GetEngineVersion() != Engine_HL2DM)
#define OUTPUT_SEPARATOR ','
#define OUTPUT_SEPARATOR ","
#define INTRO_TIMER_HUDTEXT

#define ENTPATCH_CUSTOM_NPC_MODELS
Expand Down Expand Up @@ -63,7 +60,7 @@
#define SRCCOOP_BLACKMESA
#endif
#define CHECK_ENGINE "Black Mesa"; if (GetEngineVersion() != Engine_BlackMesa)
#define OUTPUT_SEPARATOR '\27'
#define OUTPUT_SEPARATOR "\27"

#define ENTPATCH_CUSTOM_NPC_MODELS
#define ENTPATCH_UPDATE_ENEMY_MEMORY
Expand Down Expand Up @@ -145,9 +142,6 @@
#include <topmenus>
#include <sourcescramble>

#pragma newdecls required
#pragma semicolon 1

#include <logdebug>

#include <srccoop/util/assert>
Expand Down
19 changes: 8 additions & 11 deletions scripting/include/srccoop/blackmesa/entitypatch.inc
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ public Action Hook_IntroCreditsMsg(UserMsg msg_id, BfRead msg, const int[] playe
return Plugin_Handled;
}

public Action IntroCreditsMsgRepeater(Handle timer, DataPack dp)
public void IntroCreditsMsgRepeater(Handle timer, DataPack dp)
{
Handle pNewMsg = StartMessageAll("IntroCredits", USERMSG_RELIABLE|USERMSG_BLOCKHOOKS);
if (pNewMsg != null)
Expand All @@ -435,7 +435,6 @@ public Action IntroCreditsMsgRepeater(Handle timer, DataPack dp)
}
EndMessage();
}
return Plugin_Handled;
}

//------------------------------------------------------
Expand Down Expand Up @@ -641,35 +640,35 @@ public void Hook_SpriteTeamSpawnPost(int iEntIndex)

// Fixes map-placed tripmines not having the proper color with `mp_teamplay 1`.
//
public Action Timer_SetTripmineSpriteColor(Handle timer, CSpriteTeam pSpriteTeam)
public void Timer_SetTripmineSpriteColor(Handle timer, CSpriteTeam pSpriteTeam)
{
if (!pSpriteTeam.IsValid())
return Plugin_Continue;
return;

CBlackMesaBaseDetonator pTripmine = pSpriteTeam.GetTripmine();
if (!pTripmine.IsValid())
return Plugin_Continue;
return;

CEnvBeamTeam pBeamTeam = pTripmine.GetBeam();
if (!pBeamTeam.IsValid())
return Plugin_Continue;
return;

// Check if a player created this tripmine.
// TODO:
// This should assign a team color if a player disconnected before the tripmine is active.
CBlackMesaPlayer pOwner = pSpriteTeam.GetOwner();
if (pTripmine.GetTeam() != TEAM_UNASSIGNED || pOwner.IsValid())
return Plugin_Continue;
return;

CSprite pSprite = CSprite.Create();
if (!pSprite.IsValid())
return Plugin_Continue;
return;

CEnvBeam pBeam = CEnvBeam.Create();
if (!pBeam.IsValid())
{
pSprite.Kill();
return Plugin_Continue;
return;
}

int r, g, b;
Expand Down Expand Up @@ -733,8 +732,6 @@ public Action Timer_SetTripmineSpriteColor(Handle timer, CSpriteTeam pSpriteTeam
// Hide the original tripmine's entities.
pBeamTeam.SetRenderAlpha(0);
pSpriteTeam.SetRenderAlpha(0);

return Plugin_Continue;
}

//------------------------------------------------------
Expand Down
3 changes: 1 addition & 2 deletions scripting/include/srccoop/checkpoint.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1125,10 +1125,9 @@ public void Hook_CheckpointRadius(int iEntity)
}
}

public Action Timer_ActivateCheckpoint(Handle pTimer, int iSerial)
public void Timer_ActivateCheckpoint(Handle pTimer, int iSerial)
{
CCoopSpawnSystem.ActivateCheckpoint(CCoopSpawnSystem.FindCheckpointBySerial(iSerial));
return Plugin_Handled;
}

public void Hook_TouchPortal(int iEntity, int iOther)
Expand Down
6 changes: 1 addition & 5 deletions scripting/include/srccoop/classdef.inc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

IServerGameClients g_ServerGameClients;
CPlayerInfoManager g_pPlayerInfoManager;
CGlobalVars gpGlobals;

ConVar ai_los_mode;

Expand Down Expand Up @@ -412,9 +411,6 @@ stock void InitClassdef(GameData pGameConfig)
#if defined SRCCOOP_BLACKMESA
InitClassdefBM(pGameConfig);
#endif

if (!(gpGlobals = g_pPlayerInfoManager.GetGlobalVars()))
SetFailState("Could not get gpGlobals from PlayerInfoManager");
}

#define NULL_CBASEENTITY view_as<any>(-1)
Expand Down Expand Up @@ -3307,7 +3303,7 @@ methodmap CGlobalVarsBase
public void SetMaxPlayers(const int iMaxPlayers)
{
assert(this.IsValid(), "Invalid state")
assert(IsInBounds(iMaxPlayers, 0, MaxClients), "Invalid maxplayers [%d]", iMaxPlayers)
assert1(IsInBounds(iMaxPlayers, 0, MaxClients), "Invalid maxplayers [%d]", iMaxPlayers)

StoreToAddress(view_as<Address>(this) + 0x14, iMaxPlayers, NumberType_Int32);
}
Expand Down
46 changes: 23 additions & 23 deletions scripting/include/srccoop/config.inc
Original file line number Diff line number Diff line change
Expand Up @@ -53,29 +53,29 @@ enum struct SourceCoopConfig

//------------------------------------------------------

CONF_INIT(\
CONF_STR(SND_BRINGALL)\
CONF_FLT(SND_BRINGALL_VOL)\
CONF_STR(SND_PORTAL)\
CONF_FLT(SND_PORTAL_VOL)\
CONF_STR(PORTAL_PARTICLE)\
CONF_FLT(PORTAL_TOUCH_SIZE)\
CONF_CLR(FROZEN_FADE_COLOR)\
CONF_INT(FROZEN_FADE_DUR_IN)\
CONF_INT(FROZEN_FADE_DUR_OUT)\
CONF_STR(SND_TICK)\
CONF_FLT(SND_TICK_VOL)\
CONF_STR(SND_3)\
CONF_STR(SND_2)\
CONF_STR(SND_1)\
CONF_STR(SND_CHANGELEVEL)\
CONF_FLT(SND_CHANGELEVEL_VOL)\
CONF_STR(SND_CHANGELEVEL_TICK)\
CONF_FLT(SND_CHANGELEVEL_TICK_VOL)\
CONF_STR(CHANGELEVEL_EFFECT_MODEL)\
CONF_INT(CHANGELEVEL_EFFECT_AMOUNT)\
CONF_FLT(CHANGELEVEL_EFFECT_SPEED)\
CONF_FLT(CHANGELEVEL_EFFECT_PERIOD)\
CONF_INIT(
CONF_STR(SND_BRINGALL)
CONF_FLT(SND_BRINGALL_VOL)
CONF_STR(SND_PORTAL)
CONF_FLT(SND_PORTAL_VOL)
CONF_STR(PORTAL_PARTICLE)
CONF_FLT(PORTAL_TOUCH_SIZE)
CONF_CLR(FROZEN_FADE_COLOR)
CONF_INT(FROZEN_FADE_DUR_IN)
CONF_INT(FROZEN_FADE_DUR_OUT)
CONF_STR(SND_TICK)
CONF_FLT(SND_TICK_VOL)
CONF_STR(SND_3)
CONF_STR(SND_2)
CONF_STR(SND_1)
CONF_STR(SND_CHANGELEVEL)
CONF_FLT(SND_CHANGELEVEL_VOL)
CONF_STR(SND_CHANGELEVEL_TICK)
CONF_FLT(SND_CHANGELEVEL_TICK_VOL)
CONF_STR(CHANGELEVEL_EFFECT_MODEL)
CONF_INT(CHANGELEVEL_EFFECT_AMOUNT)
CONF_FLT(CHANGELEVEL_EFFECT_SPEED)
CONF_FLT(CHANGELEVEL_EFFECT_PERIOD)
)

}
Expand Down
5 changes: 2 additions & 3 deletions scripting/include/srccoop/entitypatch.inc
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ public void Hook_EnvSpriteSpawnPost(int iEntIndex)
CreateTimer(0.1, Timer_EnvSpritePostSpawn, CBaseEntity(iEntIndex), TIMER_FLAG_NO_MAPCHANGE);
}

public Action Timer_EnvSpritePostSpawn(Handle timer, CBaseEntity pEntity)
public void Timer_EnvSpritePostSpawn(Handle timer, CBaseEntity pEntity)
{
if (pEntity.IsValid())
{
Expand All @@ -904,7 +904,6 @@ public Action Timer_EnvSpritePostSpawn(Handle timer, CBaseEntity pEntity)
}
}
}
return Plugin_Handled;
}

//------------------------------------------------------
Expand Down Expand Up @@ -972,7 +971,7 @@ public MRESReturn Hook_AIConditionsThink(int _this)
if (!conditionsElement)
continue;

CBaseEntity pActor = CBaseEntity(LoadEntityHandleFromAddress(conditionsElement));
CBaseEntity pActor = CBaseEntity(LoadEntityFromHandleAddress(conditionsElement));
if (!pActor.IsValid())
continue;

Expand Down
1 change: 1 addition & 0 deletions scripting/include/srccoop/globals.inc
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ ArrayList g_pCoopModeMemPatchList;
// ----------------------------
IServerGameDLL g_ServerGameDLL;
IServerTools g_ServerTools;
CGlobalVars gpGlobals;

// ----------------------------
// Plugin variables
Expand Down
18 changes: 6 additions & 12 deletions scripting/include/srccoop/levellump.inc
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
#pragma newdecls required
#pragma semicolon 1

// Output data seperator, varies per game
static char g_szOutputSeparator[2];

// Temporary brush entity model placeholders to be identified and fixed up at entity spawn
#define BRUSH_FIXUP_MDL "models/error.mdl" /* actual model that will be set on fixed up ents */
#define BRUSH_FIXUP_IDENT "$BRUSHFIXUP$" /* identifier that the entities with customized brush models will have their "model" property start with */
Expand Down Expand Up @@ -38,7 +35,7 @@ enum struct CEntityOutputLump
bool LoadFromEntityKeyLump(const CEntityKeyLump pEntityKeyLump)
{
char buffers[5][MAX_VALUE];
if (sizeof(buffers) != ExplodeString(pEntityKeyLump.m_szValue, g_szOutputSeparator, buffers, sizeof(buffers), sizeof(buffers[])))
if (sizeof(buffers) != ExplodeString(pEntityKeyLump.m_szValue, OUTPUT_SEPARATOR, buffers, sizeof(buffers), sizeof(buffers[])))
{
return false;
}
Expand All @@ -59,10 +56,10 @@ enum struct CEntityOutputLump
void SaveToEntityKeyLump(CEntityKeyLump pEntityKeyLump)
{
FormatEx(pEntityKeyLump.m_szValue, sizeof(pEntityKeyLump.m_szValue), "%s%s%s%s%s%s%.2f%s%d",
this.m_szTargetEntity, g_szOutputSeparator,
this.m_szInputName, g_szOutputSeparator,
this.m_szParameter, g_szOutputSeparator,
this.m_flDelay, g_szOutputSeparator,
this.m_szTargetEntity, OUTPUT_SEPARATOR,
this.m_szInputName, OUTPUT_SEPARATOR,
this.m_szParameter, OUTPUT_SEPARATOR,
this.m_flDelay, OUTPUT_SEPARATOR,
this.m_iTimesToFire);
}

Expand Down Expand Up @@ -276,7 +273,7 @@ methodmap CEntityListLump < ArrayList
{
public CEntityListLump()
{
return view_as<CEntityListLump>(new ArrayList(sizeof(CEntityInfoLump)));
return view_as<CEntityListLump>(new ArrayList());
}

// cast
Expand Down Expand Up @@ -452,9 +449,6 @@ enum struct CGlobalLevelLump
this.m_pClientCvarList = new CClientConsoleCommandList();
this.m_pOutputHookList = new COutputHookList();
this.m_EdtDefinesMap = new StringMap();

g_szOutputSeparator[0] = OUTPUT_SEPARATOR;
g_szOutputSeparator[1] = 0;
}

void Clear()
Expand Down
3 changes: 1 addition & 2 deletions scripting/include/srccoop/manager.inc
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ public Action StartTimerCallback(Handle pTimer)
return Plugin_Continue;
}

public Action ChangeLevelTimerCallback(Handle pTimer)
public void ChangeLevelTimerCallback(Handle pTimer)
{
if (!data.m_iTicksToEnd--)
{
Expand All @@ -573,7 +573,6 @@ public Action ChangeLevelTimerCallback(Handle pTimer)
data.m_pChangeLevelMgr.UpdateStatus(data.m_iTicksToEnd);
data.m_pChangeLevelTimer = CreateTimer(CoopManager.GetChangeLevelTimerInterval(), ChangeLevelTimerCallback, _, TIMER_FLAG_NO_MAPCHANGE);
}
return Plugin_Handled;
}

// end shortcut
Expand Down
7 changes: 2 additions & 5 deletions scripting/include/srccoop/manager_survival.inc
Original file line number Diff line number Diff line change
Expand Up @@ -313,14 +313,13 @@ methodmap SurvivalManager {
}
}

public Action Timer_SurvivalRespawnPlayers(Handle timer)
public void Timer_SurvivalRespawnPlayers(Handle timer)
{
data.m_pRestartTimer = null;
SurvivalManager.RespawnPlayers("survival restart last checkpoint");
return Plugin_Handled;
}

public Action Timer_SurvivalRestartLevel(Handle timer)
public void Timer_SurvivalRestartLevel(Handle timer)
{
data.m_pRestartTimer = null;

Expand All @@ -329,8 +328,6 @@ public Action Timer_SurvivalRestartLevel(Handle timer)

strcopy(g_szMapName, sizeof(g_szMapName), g_szPrevMapName);
ForceChangeLevel(szMapName, SC_SURVIVAL_RESTART_MAPCHANGE);

return Plugin_Handled;
}

public void ConVarSurvivalModeChanged(ConVar hConVar, const char[] szOldValue, const char[] szNewValue)
Expand Down
4 changes: 1 addition & 3 deletions scripting/include/srccoop/playerpatch.inc
Original file line number Diff line number Diff line change
Expand Up @@ -914,12 +914,10 @@ bool FixWeaponPrediction(CBasePlayer pPlayer)
return true;
}

Action Timer_FixWeaponPrediction(Handle timer, CBasePlayer pPlayer)
void Timer_FixWeaponPrediction(Handle timer, CBasePlayer pPlayer)
{
if (pPlayer.IsValid() && pPlayer.IsAlive())
RestorePackedItems(pPlayer);

return Plugin_Handled;
}

//------------------------------------------------------
Expand Down
12 changes: 9 additions & 3 deletions scripting/include/srccoop/util/assert.inc
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,21 @@

/*
* Assertion utility - only compiled into debug code
* Params: 1 => condition, 2 => message + format arguments
* Params: 0 => condition, 1 => message, 2+ => format arguments
*/

#if defined DEBUG

#define assert(%1,%2) if (!(%1)) SetFailState(%2);
#define assert(%0,%1) if (!(%0)) SetFailState(%1);
#define assert1(%0,%1,%2) if (!(%0)) SetFailState(%1,%2);
#define assert2(%0,%1,%2,%3) if (!(%0)) SetFailState(%1,%2,%3);
#define assert3(%0,%1,%2,%3,%4) if (!(%0)) SetFailState(%1,%2,%3,%4);

#else

#define assert(%1,%2)
#define assert(%0,%1)
#define assert1(%0,%1,%2)
#define assert2(%0,%1,%2,%3)
#define assert3(%0,%1,%2,%3,%4)

#endif
Loading