C++ Shut down the engine

#1
Hi! I can't shut down the engine through C++ in CE 5.4 preview 3 . In 5.3 when map was loaded, I used unload cvar and then exit(0); to shut it down, but in 5.4 if I call exit(0);, then it freezes.
I tried:

Code: Select all

exit(0);

and

gEnv->pGameFramework->ShutdownEngine();

Second one also freezes. No crash, nothing. Console says "Exited with code 0 (0x0)", which is fine, but it doesn't disappear.
Are there any other methods?
Cryengine tutorial videos on my Youtube channel! Check it out !
https://www.youtube.com/user/MusicForLifePL20

Re: C++ Shut down the engine

#4
Hope I understand well the issue, you want to terminate your "game" from c++ code. If not, just ignore this :-)

For me it works like this:

Add to "defaultprofile.xml" another action for the key you want to press for quiting (I use "escape")

Code: Select all

<action name="escape" onPress="1" onRelease="1" retriggerable="1" keyboard="escape"/>


Add in the Initialize function of the player component (in "player.cpp")

Code: Select all

// Register the action
m_pInputComponent->RegisterAction("player", "escape", [this](int activationMode, float value)
   {
      if (activationMode == eIS_Released)
      {
         gEnv->pSystem->Quit();
      }
});

// Bind the escape action to the escape key
m_pInputComponent->BindAction("player", "escape", eAID_KeyboardMouse, EKeyId::eKI_Escape);


Hope that helps
Charalampos :-)

Re: C++ Shut down the engine

#6
I didn't want to show how to get keyboard actions. I've put a little bit more code than just "gEnv->pSystem->Quit();" only because I thought it is better to show exactly what I have done. And sure this is probably not the best way, it just not crash for me :-)

Thanks für pointing out about the defaultprofile.xml, I thought I have to put the actions there anywhere. I don't use the engine very often nor I am a good programmer, just want to test 5.4.

Cheers
Charalampos :-)

Re: C++ Shut down the engine

#8
This topic appears to be solved.

For reference, the console command "Quit" internally just calls pSystem->Quit(); so I wonder why you are having trouble using this function directly. It is the proper method to quit the application.
If there are other issues it may be best to start a new topic, as the subject matter of this topic has been solved.
Uniflare
CRYENGINE Community Coordinator
Here to help the community and social channels grow and thrive.

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

Who is online

Users browsing this forum: No registered users and 0 guests