How to set project macros on game Target.cs file?

The following macros have been added and should be defined in the project’s Target.cs file:
For projects that use dedicated servers, these must be defined for your servers:

UE4_PROJECT_STEAMPRODUCTNAME

UE4_PROJECT_STEAMGAMEDESC

UE4_PROJECT_STEAMGAMEDIR

Clients for dedicated server projects must have the following defined:

UE4_PROJECT_STEAMGAMEDIR

All Steam-based projects must have the following defined:

UE4_PROJECT_STEAMSHIPPINGID

How to properly set those new Unreal 4.22 macros on my game’s Target.cs file? Do I also need to set anything on my game’s Server.Target.cs?

1 Like

Thanks a lot for the reply! I’ll try that out soon.

Just a few other questions:

  1. Do I need to use quotation marks to define SteamProductName since it’s a string. Like so:
    GlobalDefinitions.Add(“UE4_PROJECT_STEAMPRODUCTNAME=“gameName””);

  2. Defining those macros only on my Server.Target.cs is enough? Or do I also have to define UE4_PROJECT_STEAMGAMEDIR and UE4_PROJECT_STEAMSHIPPINGID on my game’s target.cs file?

Yep according a post on this thread you’re correct with your string escaping.

https://forums.unrealengine.com/community/community-content-tools-and-tutorials/41043-advanced-sessions-plugin/page139

I’m defining all of them in both the Editor and Server target files (for when running the editor binary with the -server arg), then for the main Target file I’m doing these 2 (note that the app ID for your dedicated server should be different than your main game):

UE4_PROJECT_STEAMGAMEDIR
UE4_PROJECT_STEAMSHIPPINGID

I assumed you would have to do the following in Server.Target.cs:

GlobalDefinitions.Add("UE4_PROJECT_STEAMPRODUCTNAME=XXX");
GlobalDefinitions.Add("UE4_PROJECT_STEAMGAMEDESC=XXX");
GlobalDefinitions.Add("UE4_PROJECT_STEAMGAMEDIR=XXX");
GlobalDefinitions.Add("UE4_PROJECT_STEAMSHIPPINGID=XXX");

Here is what the release notes said about what needs to be defined where:

For projects that use dedicated servers, these must be defined for your servers:
UE4_PROJECT_STEAMPRODUCTNAME
UE4_PROJECT_STEAMGAMEDESC
UE4_PROJECT_STEAMGAMEDIR

Clients for dedicated server projects must have the following defined:
UE4_PROJECT_STEAMGAMEDIR

All Steam-based projects must have the following defined:
UE4_PROJECT_STEAMSHIPPINGID

But changing GlobalDefinitions requires a unique build environment. There is also ProjectDefinitions but I don’t think steam wil be able to pick it up from there. I will debug properly soon to find out but it would be nice if Epic documented this a little more.

1 Like

Don’t be shy to post this as answer :stuck_out_tongue:

Thanks! It worked!

I formatted the string as I said and defined all of those macros on the Server.Target.cs. Then I also defined UE4_PROJECT_STEAMSHIPPINGID and UE4_PROJECT_STEAMGAMEDIR on my main Target.cs file. I didn’t need to edit anything on the Editor.Target.cs.

Please note that I’ve only tested with a Development (Dedicated) Server build, defining the shipping ID always as my game’s ID (not the dedicated server ID as a steam tool).

That’s strange I’ve just tested it and it hasn’t worked for me yet! This was running an Development Editor build with the -server arg. Just building a server build to test that to see if it’s any different but I don’t see why it would be (I have the same macros defined in the Editor.Target.cs)

EDIT: So it works ok for the Development Server build which is good at least, I’ll see if I can figure out why the Editor ones aren’t being used.