Download

Extended steam functionality

Hi!

We really want to try using Steam’s new Inventory api, but we’re having some issues with accessing steams libraries. Here’s my specific problem; but I’ll follow up with a generalized question:


#include "ThirdParty/Steamworks/Steamv132/sdk/public/steam/steam_api.h"
#include "ThirdParty/Steamworks/Steamv132/sdk/public/steam/isteaminventory.h"

void AWGamePlayerController::GrantTestItems()
{
	SteamItemDef_t newItems[1];
	uint32 quantities[1];
	newItems[0] = 100;
	quantities[0] = 1;
	SteamInventoryResult_t s_GenerateRequestResult;
	SteamInventory()->GenerateItems(&s_GenerateRequestResult, newItems, quantities, 1);
}

Basically I want to test out GenerateItems, but it throws me this linker error:


error LNK2019: unresolved external symbol __imp_SteamInventory referenced in function "void __cdecl GrantTestItems(void)" (?GrantTestItems@@YAXXZ)

So the question is;
Are there any easy steps I can follow to set up extended functionality with steam?

Ps: I have followed all the steps in rama’s wiki tutorial for implementing new versions of steam sdk and Unreal’s steam sdk version tutorial.

Thank you; and if you have a similar problem don’t hesitate to post on this thread - I’ll try to help best I can.

Baseline Steam functionality is wrapped behind the Online Subsystem interface, so existing tutorials won’t cover things beyond that. Recommended practice is to go through the online subsystems to use Steam, but there doesn’t seem to be an existing subsystem for Steam Inventory. I think this is what the IOnlineEntitlements interface is meant to implement, but right now there is no such implementation for Steam.

That said, when you want to use external dependencies (like Steam), you should avoid plain old full include paths. UE’s build system is tailored to support modules easily, and you should use that to add your include dependencies as well as module dependencies. Currently, the project isn’t linking against Steam, which is why you’re getting unresolved symboles.

Since the Steam subsystem already pulls those dependencies, you can probably base yourself on it for inspiration. Look at OnlineSubsystemSteam.Build.cs, you’ll see it’s adding a third party dependency:


AddThirdPartyPrivateStaticDependencies(Target, "Steamworks");

That should solve the linker error, at least. I don’t know if it also handles include dependencies, but I believe it does, since the Steam subsystem PCH uses partial paths for includes:


#include "steam/steam_api.h"
#include "steam/steam_gameserver.h"

-Camille

Thank you. I will try this right away and report back with results. I appreciate the quick response!

I’m afraid it still doesn’t link properly… Now I no longer need the full paths however.

So it turns out I needed to add further properties in our Game.Build.cs file.

They are:



        PrivateDependencyModuleNames.AddRange(
            new string] { 
                "Slate", 
                ...,                
 	        "OnlineSubsystemSteam",                
 	         "Steamworks"
            });

and



PublicDependencyModuleNames.AddRange(
            new string] {
		"Core",
		"CoreUObject",
		"Engine",
		"InputCore",
                ...,
 	        "OnlineSubsystemUtils",                
 	        "OnlineSubsystemSteam",                
 	        "Steamworks"
		});

Now it crashes in runtime instead when trying to call SteamInventory()->GrantItems(…)
Anyone else trying to use this functionality?