Skip to content

Commit 6a952b8

Browse files
committed
fix(core): Adapt latest steam api
1 parent eb9506b commit 6a952b8

File tree

6 files changed

+7
-9
lines changed

6 files changed

+7
-9
lines changed

managed/src/TestPlugin/TestPlugin.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ public void TestCommand( ICommandContext context )
327327
public void TestCommand1( ICommandContext context )
328328
{
329329
var ret = SteamGameServerUGC.DownloadItem(new PublishedFileId_t(3596198331), true);
330-
Console.WriteLine(ret);
330+
Console.WriteLine(Core.Engine.ServerIP);
331331
}
332332

333333
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]

src/core/bridge/metamod.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ bool SwiftlyMMBridge::Load(PluginId id, ISmmAPI* ismm, char* error, size_t maxle
4545

4646
if (late)
4747
{
48-
g_SteamAPI.Init();
4948
static auto playermanager = g_ifaceService.FetchInterface<IPlayerManager>(PLAYERMANAGER_INTERFACE_VERSION);
5049
playermanager->SteamAPIServerActivated();
5150
}

src/core/entrypoint.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353

5454
SwiftlyCore g_SwiftlyCore;
5555
InterfacesManager g_ifaceService;
56-
CSteamGameServerAPIContext g_SteamAPI;
5756

5857
IVFunctionHook* g_pGameServerSteamAPIActivated = nullptr;
5958
IVFunctionHook* g_pGameServerSteamAPIDeactivated = nullptr;
@@ -263,10 +262,9 @@ bool SwiftlyCore::Unload()
263262

264263
void GameServerSteamAPIActivatedHook(void* _this)
265264
{
266-
if (!CommandLine()->HasParm("-dedicated") || g_SteamAPI.SteamUGC())
265+
if (!CommandLine()->HasParm("-dedicated"))
267266
return;
268267

269-
g_SteamAPI.Init();
270268
static auto playermanager = g_ifaceService.FetchInterface<IPlayerManager>(PLAYERMANAGER_INTERFACE_VERSION);
271269
playermanager->SteamAPIServerActivated();
272270

src/core/entrypoint.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,5 @@ class SwiftlyCore
5353
};
5454

5555
extern SwiftlyCore g_SwiftlyCore;
56-
extern CSteamGameServerAPIContext g_SteamAPI;
5756

5857
#endif

src/engine/fixes/serverlist.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <core/bridge/metamod.h>
2222

2323
#include <public/tier0/platform.h>
24+
#include <public/steam/isteamclient.h>
2425
#include <public/steam/isteamgameserver.h>
2526

2627
#include <s2binlib/s2binlib.h>
@@ -82,7 +83,8 @@ void GameFrame(void* _this, bool simulate, bool first, bool last)
8283
auto controller = player->GetController();
8384
if (!controller) continue;
8485

85-
g_SteamAPI.SteamGameServer()->BUpdateUserData(*steamid, (const char*)(schema->GetPropPtr(controller, 4141622183986322747)), gameclients->GetPlayerScore(i)); // CBasePlayerController::PlayerName
86+
if (SteamGameServer())
87+
SteamGameServer()->BUpdateUserData(*steamid, (const char*)(schema->GetPropPtr(controller, 4141622183986322747)), gameclients->GetPlayerScore(i)); // CBasePlayerController::PlayerName
8688
}
8789
}
8890
}

src/scripting/engine/enginehelpers.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ struct CBaseGameSystemFactory_t : public IGameSystemFactory {
4242
int Bridge_EngineHelpers_GetServerIP(char* out)
4343
{
4444
static std::string s;
45-
if (!g_SteamAPI.SteamGameServer()) s = "0.0.0.0";
45+
if (!SteamGameServer()) s = "0.0.0.0";
4646
else {
47-
auto ip_addr = g_SteamAPI.SteamGameServer()->GetPublicIP();
47+
auto ip_addr = SteamGameServer()->GetPublicIP();
4848
s = fmt::format("{}.{}.{}.{}", (ip_addr.m_unIPv4 >> 24) & 0xFF, (ip_addr.m_unIPv4 >> 16) & 0xFF, (ip_addr.m_unIPv4 >> 8) & 0xFF, ip_addr.m_unIPv4 & 0xFF);
4949
}
5050

0 commit comments

Comments
 (0)