Download

About overriding UGameEngine::Init

Hi,

I intend to customize my window therefore I think this is the way to go: create a new C++ (UServerGame) class deriving from UGameEngine and then override virtual function Init.

So for a start, I simply copy+paste the C++ code from UGameEngine::Init into my UServerGame::Init. And then since there are lots of compile error, I also copy+paste all header files in GameEngine.cpp and managed to get pass compilation stage. However, the are link errors:-



Error	5	error MSB3073: The command ""C:\Program Files\Epic Games\4.8\Engine\Build\BatchFiles\Build.bat" Intechange_ServerEditor Win64 Development "C:\Users\lenovo\Documents\Unreal Projects\Intechange_Server\Intechange_Server.uproject" -rocket" exited with code -1.	C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets	38
Error	1	error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class UClass * __cdecl UGameMapsSettings::StaticClass(void)" (__imp_?StaticClass@UGameMapsSettings@@SAPEAVUClass@@XZ) referenced in function "class UGameMapsSettings const * __cdecl GetDefault<class UGameMapsSettings>(void)" (??$GetDefault@VUGameMapsSettings@@@@YAPEBVUGameMapsSettings@@XZ)	C:\Users\lenovo\Documents\Unreal Projects\Intechange_Server\Intermediate\ProjectFiles\ServerGameEngine.cpp.obj
Error	2	error LNK2019: unresolved external symbol "public: void __cdecl FNetworkProfiler::EnableTracking(bool)" (?EnableTracking@FNetworkProfiler@@QEAAX_N@Z) referenced in function "public: virtual void __cdecl UServerGameEngine::Init(class IEngineLoop *)" (?Init@UServerGameEngine@@UEAAXPEAVIEngineLoop@@@Z)	C:\Users\lenovo\Documents\Unreal Projects\Intechange_Server\Intermediate\ProjectFiles\ServerGameEngine.cpp.obj


Any idea how to fix this error?

Ok solved. Turn out I need to add public dependency module in a file named <Project>.build.cs in the Source folder.

However, it is quite cumbersome as I have to guess the correct library. For an example, for 4.8 I open the folder ‘C:\Program Files\Epic Games\4.8\Engine\Binaries\Win64’ and see bunch of lib files and see which function fit into which libs. Is there any proper way to lookup for lib file?

Hi,
I’m trying to customize my window too and I’ma having the same problems you had.
I followed the steps described here: https://wiki.unrealengine.com/Create_Custom_engine_classes_for_your_game_module
but I’m getting the same linker errors you mentioned.

Just for testing, I removed my custom Init() and replaced it with a Super::Init(InEngineLoop): it compiles, but, when i run a standalone game from the editor, it crashes.

Did you ever manage to customize your window? Can I ask what modules you inserted in the build.cs file?

thanks!

the module added was probably “EngineSettings”

Modifying engine functions by copying and pasting them into your own classes is not a good idea in my opinion, because that means if Epic updates the code in future versions of the engine, your code will not be updated. If you need to replace or modify existing code (and not just add new code on top of it) I suggest creating your own branch of the engine and modifying the code directly. In this way you will be able to merge new engine versions from Epic and update your modified code accordingly.