If the game can be run through Steam, the app is restarted through Steam directly. Make sure OnUserDestroy() gets called if the game is killed when OnUserCreate() returns false to free all resources. Release Build 8224.

pull/57/head
sigonasr2 8 months ago
parent 8768b89f38
commit 6cd34639ef
  1. 7
      Adventures in Lestoria/AdventuresInLestoria.cpp
  2. 2
      Adventures in Lestoria/Version.h
  3. 5
      Adventures in Lestoria/olcPixelGameEngine.h
  4. BIN
      x64/Release/Adventures in Lestoria.exe

@ -322,17 +322,19 @@ bool AiL::OnUserCreate(){
ValidateGameStatus(); //Checks to make sure everything has been initialized properly.
#ifndef __EMSCRIPTEN__
SetupDiscord();
if(SteamAPI_RestartAppIfNecessary(2895980U))return false; //Immediately quit if steam is detected and can be started through it.
if(SteamAPI_Init()){
std::cout<<"Steam API Initialized successfully!"<<std::endl;
}else{
std::cout<<"Steam API failed to initialize!"<<std::endl;
}
if(SteamAPI_IsSteamRunning()){
if(SteamUtils()!=nullptr)
SteamUtils()->SetWarningMessageHook([](int severity,const char*message){
std::cout<<std::format("STEAM[{}]: {}",severity,std::string(message))<<std::endl;
});
if(SteamInput()!=nullptr)
SteamInput()->Init(false);
}
#endif
gameInitialized=true;
@ -2783,6 +2785,7 @@ bool AiL::IsReflectiveTile(TilesheetData tileSheet,int tileID){
}
bool AiL::OnUserDestroy(){
SteamAPI_Shutdown();
GFX.Reset();
for(auto&[key,value]:MAP_DATA){
if(MAP_DATA[key].optimizedTile!=nullptr){

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 0
#define VERSION_MINOR 5
#define VERSION_PATCH 1
#define VERSION_BUILD 8221
#define VERSION_BUILD 8224
#define stringify(a) stringify_(a)
#define stringify_(a) #a

@ -4715,7 +4715,10 @@ namespace olc
// Create user resources as part of this thread
for (auto& ext : vExtensions) ext->OnBeforeUserCreate();
if (!OnUserCreate()) bAtomActive = false;
if (!OnUserCreate()){
bAtomActive = false;
OnUserDestroy();
}
for (auto& ext : vExtensions) ext->OnAfterUserCreate();
while (bAtomActive)

Loading…
Cancel
Save