Added FEATURE flag, fixed rare segfault

This commit is contained in:
2021-03-09 09:27:15 +01:00
parent bb502b37f4
commit fbe122a5b9
6 changed files with 71 additions and 19 deletions
+26 -9
View File
@@ -27,6 +27,12 @@ void addMainSceneItems( SDLPP::Scene &scene,
bg->setPermanent();
bg->setId( BACKGROUND_ID );
scene.addObject( bg );
#ifdef FEATURE
auto testcircle = std::make_shared< SDLPP::CircleRender >(
LEFT_BORDER, 0.2, 0.05, r, "#FF00AA", true );
testcircle->centerX();
scene.addObject( testcircle );
#endif
// create coliders for counting blocks in line
double posy = 1;
@@ -311,6 +317,9 @@ void handleKeyDownMain( SDL_Keycode key, SDLPP::Scene &scene ) {
g_update_scenes.push_back( g_menu_scene );
g_active_scenes.push_back( g_menu_scene );
g_input_functions.push_back( menuSceneInput );
#ifdef FEATURE
pauseBlocks();
#endif
break;
case SDLK_LEFT:
case SDLK_a:
@@ -422,7 +431,7 @@ void pollEventsMain( SDLPP::Scene &scene ) {
case SDL_WINDOWEVENT:
if ( event.window.event == SDL_WINDOWEVENT_RESIZED ) {
for ( auto &x : g_active_scenes )
g_update_scenes.push_back(x);
g_update_scenes.push_back( x );
g_update_size = true;
}
default:
@@ -490,6 +499,9 @@ void handleKeyDownMenu( SDL_Keycode key ) {
g_main_scene->setPrevTicks( SDL_GetTicks() );
g_active_scenes.pop_back();
g_input_functions.pop_back();
#ifdef FEATURE
resumeBlocks();
#endif
} break;
#ifdef DEBUG
case SDLK_r:
@@ -523,7 +535,7 @@ void handleKeyDownMenu( SDL_Keycode key ) {
g_input_functions.pop_back();
} break;
case MAIN_MENU_OPTIONS:
g_update_scenes.push_back(g_options_scene);
g_update_scenes.push_back( g_options_scene );
g_active_scenes.push_back( g_options_scene );
g_input_functions.push_back( optionsSceneInput );
break;
@@ -554,7 +566,7 @@ void pollEventsMenu() {
case SDL_WINDOWEVENT:
if ( event.window.event == SDL_WINDOWEVENT_RESIZED ) {
for ( auto &x : g_active_scenes )
g_update_scenes.push_back(x);
g_update_scenes.push_back( x );
g_update_size = true;
}
default:
@@ -599,6 +611,9 @@ void handleKeyDownGameOver( SDL_Keycode key ) {
case SDLK_RETURN:
switch ( g_game_over_select ) {
case GAME_OVER_RESTART:
#ifdef FEATURE
resumeBlocks();
#endif
resetGame();
break;
case GAME_OVER_QUIT:
@@ -625,7 +640,7 @@ void pollEventsGameOver() {
case SDL_WINDOWEVENT:
if ( event.window.event == SDL_WINDOWEVENT_RESIZED ) {
for ( auto &x : g_active_scenes )
g_update_scenes.push_back(x);
g_update_scenes.push_back( x );
g_update_size = true;
}
default:
@@ -693,7 +708,8 @@ void handleKeyDownOptions( SDL_Keycode key ) {
g_options_options[OPTIONS_MENU_SHADOW].get() )
->changeText( std::string( "Show shadow: " ) +
( g_show_shadow ? "YES" : "NO" ) );
g_update_objects.push_back(g_options_options[OPTIONS_MENU_SHADOW]);
g_update_objects.push_back(
g_options_options[OPTIONS_MENU_SHADOW] );
break;
case OPTIONS_MENU_3D:
g_show_3d = !g_show_3d;
@@ -701,7 +717,7 @@ void handleKeyDownOptions( SDL_Keycode key ) {
g_options_options[OPTIONS_MENU_3D].get() )
->changeText( std::string( "Show block texture: " ) +
( g_show_3d ? "YES" : "NO" ) );
g_update_objects.push_back(g_options_options[OPTIONS_MENU_3D]);
g_update_objects.push_back( g_options_options[OPTIONS_MENU_3D] );
g_update_3d = true;
default:
break;
@@ -726,7 +742,8 @@ void handleKeyDownOptions( SDL_Keycode key ) {
g_options_options[OPTIONS_MENU_SHADOW].get() )
->changeText( std::string( "Show shadow: " ) +
( g_show_shadow ? "YES" : "NO" ) );
g_update_objects.push_back(g_options_options[OPTIONS_MENU_SHADOW]);
g_update_objects.push_back(
g_options_options[OPTIONS_MENU_SHADOW] );
break;
case OPTIONS_MENU_3D:
g_show_3d = !g_show_3d;
@@ -734,7 +751,7 @@ void handleKeyDownOptions( SDL_Keycode key ) {
g_options_options[OPTIONS_MENU_3D].get() )
->changeText( std::string( "Show block texture: " ) +
( g_show_3d ? "YES" : "NO" ) );
g_update_objects.push_back(g_options_options[OPTIONS_MENU_3D]);
g_update_objects.push_back( g_options_options[OPTIONS_MENU_3D] );
g_update_3d = true;
default:
break;
@@ -774,7 +791,7 @@ void pollEventsOptions() {
case SDL_WINDOWEVENT:
if ( event.window.event == SDL_WINDOWEVENT_RESIZED ) {
for ( auto &x : g_active_scenes )
g_update_scenes.push_back(x);
g_update_scenes.push_back( x );
g_update_size = true;
}
default: