Announcement

Collapse
No announcement yet.

Server-only config?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Server-only config?

    I'm looking for a way to designate a config value as "dedicated server only"; that is, I want it such that when UE4 builds a client (non-dedicated server), it automatically strips the given configuration value from the build so that it is not included in the final client package.

    Our plugin involves the use of a public/private key pair, and while I want the private key pair to be present during development (when you're using the editor, so that multiplayer PIE works), I need to ensure that the private key never gets shipped with the game.

    So far I haven't been able to find anything on this topic. Does anyone have any ideas?

    EDIT: Actually, I'd also settle for having a configuration item that is stripped out of all builds if server-only is not an option, since our plugin can also accept the private key as an environment variable for the dedicated server.

    #2
    From Build.h
    Code:
    /**
     *   Whether compiling for dedicated server or not.
     */
    #ifndef UE_SERVER
        #define UE_SERVER                    0
    #endif
    So you can likely wrap your code in
    Code:
    int64 GetPrivateKey() const
    {
    #if !defined(UE_SERVER)
     // Client
     return 0;
    #else
     return MyKey; // Server
    #endif
    }
    Able Ability System - A high performance, robust ability system for UE4. Now Available!

    Comment


      #3
      Hmm, that's not quite what I'm after.

      That will change the code so that it doesn't load the value at runtime if it's on the client. But what I actually want is for the value to not appear in the config files at all on the client. Effectively, I want the packaging process to strip out config values that are "server only" when building the game client.

      Comment


        #4
        Create a custom UObject and add PrivateKey as a UProperty to that object like this:

        Code:
        #if WITH_EDITORONLY_DATA
        
              UPROPERTY(config)
              FKeyType  MyPrivateKey;
        
        #endif
        Functions that manipulate the private key, strip them out of clients and builds like this:

        Code:
        void DoSomethingWithKey()
        {
            #if WITH_SERVER_CODE
                #if WITH_EDITOR
                    // Use private key value...
                #endif
            #endif
        }

        Neither the key nor the code that manipulates the key should be added to packaged game that way.
        Only server in editor mode will be able to see it.

        Note that the UObject class must specify a config = ConfigFileName in its UCLASS() declaration.
        | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

        Comment

        Working...
        X