Tested with 4.5.1 and 4.6.0 and 4.6.1
Shipping build do not accept comand line arguments like “?Param1=Value1?Param2=Value2”.
Is it a bug, or there is some trick to turn it on?
Did you custom the console command that is being used by you? First you should know that UE will not allow you run most console command when you shipping your project, unless you created it and parsed it self.
It is not console commands. I have my own launch parameters and I parse them. Shipping build have no log output so I can’t to see what is going wrong there.
You can unzip your package for checking the parameters if has been added to the launch command line. There is one launch command txt file in your final package. If my memory is correctly. Have you tested in development mode?
UE launch command template is :: …/…/…/Samples/Showcases/Mobile/Mobile.uproject -filehostip=###.###.###.### -nosound -streaming. It seems like it will not register new parameter as you added . If you can launch your game with your customization arguments in development mode. It seems like your parse code has been forbid run when you shipping your game. So you just need to adjust the place of your code.
With development build it works fine. Issue happened only with shipping build
It indicates the parse code was written in wrong place. Your code was forbidden to exec by UE_SHIPPING_BUILD macro. The UE_SHIPPING_BUILD macro always is false in shipping build.
there is no macro in my code:
i am launching shipping build x32 with that line:
game.exe
?Name=TestUser?id=1?serv=127.0.0.1?port=15?ql=2?lng=Russian
this parameters string is parsed at game start:
void AGameGameMode::InitGame(const FString& MapName, const FString& Options, FString& ErrorMessage)
{
const FString lname = ParseOption(Options, “name”);
const int32 lid = GetIntOption(Options, “id”, 0);
const FString lip = ParseOption(Options, “serv”);
const int32 lport = GetIntOption(Options, “port”, 0);
const int32 lquality = GetIntOption(Options, “ql”, 0);
const FString llng = ParseOption(Options, “lng”);
Super::InitGame(MapName, Options, ErrorMessage);
// other code
}
so, no one of those params goes to InitGame(). It is look like Options=“” so it is empty string.
when launching development build x64 with same line, then Options string have all parameters i set for launch
Ok, Do you want to use these parameters when you travel to new map or in the default map when the engine was started? this function is used to create one game mode when you travel to new map. These parameters should be included into the map url, it should be looked like: testmap?game=mygamemode?id= . and you can invoke servertravel function to travel the url, and then you can correctly parse them in your project.
Here is the code that epic uses to create the game mode for default map when game engine is being loaded.
void UGameInstance::StartGameInstance()
{
UEngine* const Engine = GetEngine();
// Create default URL.
// @note: if we change how we determine the valid start up map update LaunchEngineLoop's GetStartupMap()
FURL DefaultURL;
DefaultURL.LoadURLConfig(TEXT("DefaultPlayer"), GGameIni);
// Enter initial world.
EBrowseReturnVal::Type BrowseRet = EBrowseReturnVal::Failure;
FString Error;
TCHAR Parm[4096] = TEXT("");
const TCHAR* Tmp = FCommandLine::Get();
#if UE_BUILD_SHIPPING
// In shipping don’t allow an override
Tmp = TEXT(“”);
#endif // UE_BUILD_SHIPPING
//other code
}
so you can get the real reason in here.
Hi h2o,
I created a new project to test this issue in, and I was not able to see the same results that you described. I used the code first person template and added the code you provided in one of your comments to the default GameMode class that came with the template. I then made a Blueprint from that GameMode class to output the values retrieved from the command line arguments to the screen. I packaged the game for both Win64 and Win32, and with both versions of the packaged game the values that were output matched the arguments I sent in through the command line.
Could you provide some more details about how you are setting this up?
Did you build configuration was selected as “Shipping”?
This happened only in shipping build configuration.
As zql said right there is void UGameInstance::StartGameInstance() where this params cleared for shipping build, so i just override this function.
tnx
zql tnx
this was the real reason.
That’s cool.
For anyone wanting to disable this behaviour, you can hack around it by creating a new derived class from UGameInstance inside your game project which completely overrides StartGameInstance() with the same implementation (minus the offending Tmp = TEXT(“”) line.) This works for non-source builds too, just remember to update the code again if you upgrade engine versions. If you’re lazy (like me) you can catch engine upgrades with a compile error using the following snippit somewhere inside your override of StartGameInstance(), eg. for catching upgrades from UE4.14:
#include "Runtime/Launch/Resources/Version.h"
...
#if ENGINE_MINOR_VERSION > 14
#error "You have upgraded from UE4.14 to a newer version. Please recreate StartGameInstance() as an exact copy of UGameInstance::StartGameInstance() and comment out the Tmp = TEXT("") line again."
#endif
For people still having issues with this, I got it working by being very specific with the way I added my arguments to the server build executable:
GameBuildExecuteable-Platform-Shipping LevelName?Listen?port=9999
No spaces in between the first command line arguments, only question marks in one long string.
How to carrectly override UGameInstance::StartGameInstance()
?