Compiling Cryengine in release mode help

#1
Hi,

I'm compiling CryEngine 5.4 but I'm encountering problems.
I have all the files packed in *.pak and the game works when they are not encrypted. If I encrypt them the game won't start.
I've enabled the key in the GameStartup.cpp and I've tested it both with "release" and "profile" compilation.
Here it is the logs of the game lauched in "profile" mode:
logs.zip
(7.43 KiB) Downloaded 56 times
Can someone help me please? I've never had those problems with my previous game made with EaaS.

Re: Compiling Cryengine in release mode help

#2
Hey guzzo,

CRYENGINE 5.4 will require some edits to the PAK file system initialization to be able to read the key. The key is no longer read via the gamestartup.cpp file.
Instead of placing the key inside the gamestartup.cpp, you will need to plae the key inside the CryPak.cpp with a couple edits.

For example, if your key is:

Code: Select all

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
You would modify this:

Code: Select all

if (pGameStartup)
{
uint32 keyLen;
const uint8* pKeyData = pGameStartup->GetRSAKey(&keyLen);
if (pKeyData && keyLen > 0)
{
ZipEncrypt::Init(pKeyData, keyLen);
}
}
To look like this (embedding your key there):

Code: Select all

if (pGameStartup)
{
uint32 keyLen;
const uint8* pKeyData = pGameStartup->GetRSAKey(&keyLen);
if (pKeyData && keyLen > 0)
{
ZipEncrypt::Init(pKeyData, keyLen);
}
}
#ifdef _RELEASE
else
{
static const unsigned char rsa_public_key_data[] =
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
uint32 keyLen = sizeof(rsa_public_key_data);
ZipEncrypt::Init(rsa_public_key_data, keyLen);
}
#endif
You can find the place to modify this in file "Code/CryEngine/CrySystem/CryPak.cpp" line #430
Let me know if this solves your issue. (You will need to recompile CrySystem project after making this change.
Uniflare
CRYENGINE Technical Community Manager
Here to help the community and social channels grow and thrive.

My personal belongings;
Beginner Guides | My GitHub | Splash Plugin

Re: Compiling Cryengine in release mode help

#3
hi thank you.

The compilation tells me that an "endif" is missing.
I added it to look like this:

Code: Select all


#ifdef INCLUDE_LIBTOMCRYPT
if (pGameStartup)
{
uint32 keyLen;
const uint8* pKeyData = pGameStartup->GetRSAKey(&keyLen);
if (pKeyData && keyLen > 0)
{
ZipEncrypt::Init(pKeyData, keyLen);
}
}
#endif
#ifdef _RELEASE
else
{
static const unsigned char rsa_public_key_data[] =
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
uint32 keyLen = sizeof(rsa_public_key_data);
ZipEncrypt::Init(rsa_public_key_data, keyLen);
}
#endif
}
}
Is this ok now? Of course I've inserted my key not showed here.

Moreover with the key enabled and the encrypted paks, can I test it only with "release" or also with "profile"?

UPDATE:
with the "endif" added the compilation works, but the game won't launch in release mode and with encrypted files. The log says:

Non-existent asset directory C:/CRYENGINE_5_4_Packaging/Tools/rc/client/PC/TheAlienCube_demo/assets detected, user opted to quit
System Shutdown


However every time I delete the file "game.cryproject" the game starts, but with a black screen, without splashscreen or any other image. I can hear only the menu music. I tought that it can be related to "CryScaleformHelper.dll" that I picked from the Cryengine release folder, but you said in another thread that this file should work.
If I re-launch the game without deleting "game.cryproject", the game won't start at all and the log display the error mentioned before (Non-existent asset directory).

Can you help me please?

/Edited by Cry-Flare (Syntax tags instead of Code tags)

Re: Compiling Cryengine in release mode help

#4
There are a couple more edits required it seems. These issues were fixed in later versions so I cannot provide the fixes we used unless you opt for the CE 5.5+ business model.
I can however provide workarounds for these issues.

Edits required in source code
Code/CryEngine/CrySystem/CryPak.cpp #439 (Replace the original line)

Code: Select all

#ifdef _RELEASE
else
{
static const unsigned char rsa_public_key_data[] =
{
0x30,0x81,0x89,0x02,0x81,0x81,0x00,0xE9,0x1C,0xDB,0xD7,0x10,0x98,0xFF,0x78,0x2E,0x1D,0x22,0xFD,0xD9,
0x19,0xB9,0x89,0xED,0x40,0x71,0xBC,0xF6,0x94,0x24,0xF8,0x06,0xC5,0x83,0xF6,0xC3,0x1E,0xB1,0xFB,0xC2,
0x06,0xEB,0x75,0xD9,0x99,0x70,0xC7,0xA2,0x7A,0xEA,0x4E,0x3A,0xD8,0x20,0x77,0x3D,0x31,0xB8,0xA0,0xDB,
0x3C,0x8F,0xC5,0x17,0x2D,0xDB,0x8C,0x66,0xB8,0x4E,0xC3,0x0A,0x2E,0x50,0xF6,0xF2,0x73,0x73,0x44,0xF9,
0x90,0xDE,0x6F,0xEA,0xDB,0x91,0xD3,0xA5,0x73,0x72,0x3F,0x5A,0xA6,0xF4,0x24,0x9C,0xB2,0x1D,0xE6,0xC3,
0xF5,0x16,0x8F,0xA4,0xC7,0x4A,0xA1,0x9A,0xD8,0x59,0xE4,0xEE,0x4D,0xCE,0x92,0xCF,0x70,0x31,0xF2,0x3E,
0x0C,0x01,0x3E,0xCF,0x80,0xC8,0xA0,0xCA,0xBA,0x12,0x43,0x85,0x5A,0x86,0x6D,0x02,0x03,0x01,0x00,0x01
};
uint32 keyLen = sizeof(rsa_public_key_data);
ZipEncrypt::Init(rsa_public_key_data, keyLen);
}
#endif /* _RELEASE */
#endif /* INCLUDE_LIBTOMCRYPT */
NOTE: The key is just an example. Replace with your key data found in your own key.dat you used to encrypt your pak files.


Code/CryEngine/CrySystem/ProjectManager/ProjectManager.cpp #145 (Replace the original line)

Code: Select all

if (!gEnv->pCryPak->IsFileExist(m_project.assetDirectoryFullPath, ICryPak::eFileLocation_OnDisk))

Code/CryEngine/RenderDll/Common/Shaders/ShaderFXParseBin.cpp #1035 (Add this line after line 1034)

Code: Select all

nameBin = PathUtil::GetEnginePath() + "/engine/" + nameBin;

Steps to package:
1. Follow this guide to rebuilding your shader cache and engine pak files. Use DX11 rather than Vulkan though.
2. Copy your packaged assets, engine paks, engine binaries, config files and project file to a staging folder (same directory structure, just somewhere separate, like a release folder without all the extra stuff like code etc).
3. Rename your .cryproject to .crygame. (Some console variables here, you may want to hard-code in the engine/game source code as RELEASE mode will prevent CVars marked with VF_CHEAT from changing).
4. Run Parsebuild using your key.dat on your staging folder to a new output folder.
5. Test the build.

Please let us know if this worked for you.
Uniflare
CRYENGINE Technical Community Manager
Here to help the community and social channels grow and thrive.

My personal belongings;
Beginner Guides | My GitHub | Splash Plugin

Re: Compiling Cryengine in release mode help

#5
thanks now the game is launching in release mode as I'm able to go in the main menu.
However when I load a level the game crashes. It seems a shaders compilation problem. That's because I've tested with a small level where you start inside a visarea and in this case it works and the level was loaded, but I saw that the game has to compile all the shaders (you can't see nothing at the beginning, then after a while the tings starts to appear, with shaders compilation on Console).
However, if I go outside of the VisArea, the game crashes.
I don't know why it has to re-compile all the shaders as I've used the same user folder as before where all the shaders was created in the editor and in the previous gameplays.

I've tried to rebuild shaders following your link but it doesn't work as the shader compiler continue to show errors and it does not compile anything.

Is it possible that it is so complex to release a game whit this new CryEngine? I'm loosing more time doing all this stuff than creating the game itself.

Re: Compiling Cryengine in release mode help

#6
Shaders needing to be compiled means they are not in the shadercache.
IIRC Shader compilation is disabled in release.

You can always release the game in profile mode, with encrypted assets if you are having trouble with release binaries.
Setting up a high-performance and optimized build means extra steps, like building a complete shader cache so they are not compiled at run time.

If you have not finished your game, I would advise leaving the release process until you are ready.
If you want to continue creating this release package, please show us the steps you took and the errors you are facing and hopefully we can guide you in the right direction.
Uniflare
CRYENGINE Technical Community Manager
Here to help the community and social channels grow and thrive.

My personal belongings;
Beginner Guides | My GitHub | Splash Plugin

Re: Compiling Cryengine in release mode help

#7
You can always release the game in profile mode, with encrypted assets if you are having trouble with release binaries.
My profile mode doesn't work with encrypted assets.Here is the game.log attached:
game.zip
(3.85 KiB) Downloaded 37 times

As the profile mode doesn't work with encrypted assets, I am compiling the shaders with another build that is inside the editor folder and without assets encrypted. I'm using the same compiled binaries (profile mode). I followed the steps you gived me for compiling the shadercache. However the compiler doesn't work.
Here is the log:
errors_shaders_compiling.zip
(21.97 KiB) Downloaded 41 times
thank you

Who is online

Users browsing this forum: No registered users and 1 guest

cron