From 0b60c77a1a01e753919be95aafc22ee38a0fcb62 Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Wed, 12 Apr 2006 12:36:29 +0000 Subject: [PATCH] - remove pointless leveltime from world1 levels - rework console to not have static functions everywhere - fix a few crashs/assertions - minor fixes I forgot... SVN-Revision: 3314 --- data/levels/world1/01 - Welcome to Antarctica.stl | 3 - data/levels/world1/02 - The Journey Begins.stl | 3 - data/levels/world1/03 - Via Nostalgica.stl | 3 - data/levels/world1/04 - Tobgle Road.stl | 3 - .../world1/05 - The Somewhat Smaller Bath.stl | 3 - data/levels/world1/07 - Oh No More Snowballs.stl | 3 - data/levels/world1/08 - Stone Cold.stl | 3 - data/levels/world1/09 - Grumbels Sense of Snow.stl | 3 - data/levels/world1/10 - 23rd Airborne.stl | 3 - data/levels/world1/11 - Night Chill.stl | 3 - data/levels/world1/12 - Into the Stars.stl | 3 - data/levels/world1/13 - Above the Arctic Skies.stl | 3 - data/levels/world1/14 - Entrance to the Cave.stl | 3 - data/levels/world1/15 - Under the Ice.stl | 3 - data/levels/world1/16 - Living in a Fridge.stl | 3 - data/levels/world1/17 - Or is it just me.stl | 3 - data/levels/world1/18 - Ice in the Hole.stl | 3 - data/levels/world1/19 - Miyamoto Monument.stl | 3 - data/levels/world1/20 - End of the Tunnel.stl | 3 - data/levels/world1/21 - A Path in the Clouds.stl | 3 - .../world1/22 - A Mysterious House of Ice.stl | 3 - data/levels/world1/23 - The Escape.stl | 3 - data/levels/world1/24 - The Shattered Bridge.stl | 3 - data/levels/world1/25 - Arctic Ruins.stl | 3 - data/levels/world1/26 - The Castle of Nolok.stl | 3 - data/levels/world1/27 - No More Mr Ice Guy.stl | 9 +- data/levels/world1/yeti.stl | 147 --------------------- src/console.cpp | 55 ++++---- src/console.hpp | 127 +++++++++--------- src/control/joystickkeyboardcontroller.cpp | 18 +-- src/game_session.cpp | 12 +- src/game_session.hpp | 7 +- src/main.cpp | 19 ++- src/mainloop.cpp | 4 +- src/player_status.cpp | 2 +- src/sector.cpp | 10 +- src/title.cpp | 9 +- src/world.cpp | 16 +++ 38 files changed, 162 insertions(+), 348 deletions(-) delete mode 100644 data/levels/world1/yeti.stl diff --git a/data/levels/world1/01 - Welcome to Antarctica.stl b/data/levels/world1/01 - Welcome to Antarctica.stl index 78ffbc44e..4dc546bc9 100644 --- a/data/levels/world1/01 - Welcome to Antarctica.stl +++ b/data/levels/world1/01 - Welcome to Antarctica.stl @@ -96,9 +96,6 @@ (image "images/background/arctis.jpg") (speed 0.5) ) - (leveltime - (time 300) - ) (camera (mode "normal") ) diff --git a/data/levels/world1/02 - The Journey Begins.stl b/data/levels/world1/02 - The Journey Begins.stl index b121544b3..ba3241732 100644 --- a/data/levels/world1/02 - The Journey Begins.stl +++ b/data/levels/world1/02 - The Journey Begins.stl @@ -96,9 +96,6 @@ (image "images/background/arctis.jpg") (speed 0.5) ) - (leveltime - (time 300) - ) (camera (mode "normal") ) diff --git a/data/levels/world1/03 - Via Nostalgica.stl b/data/levels/world1/03 - Via Nostalgica.stl index 7cc665560..b6b8e2626 100644 --- a/data/levels/world1/03 - Via Nostalgica.stl +++ b/data/levels/world1/03 - Via Nostalgica.stl @@ -96,9 +96,6 @@ (image "images/background/arctis.jpg") (speed 0.5) ) - (leveltime - (time 300) - ) (camera (mode "normal") ) diff --git a/data/levels/world1/04 - Tobgle Road.stl b/data/levels/world1/04 - Tobgle Road.stl index 6258099bf..bcbe6d3cf 100644 --- a/data/levels/world1/04 - Tobgle Road.stl +++ b/data/levels/world1/04 - Tobgle Road.stl @@ -96,9 +96,6 @@ (image "images/background/arctis.jpg") (speed 0.5) ) - (leveltime - (time 300) - ) (camera (mode "normal") ) diff --git a/data/levels/world1/05 - The Somewhat Smaller Bath.stl b/data/levels/world1/05 - The Somewhat Smaller Bath.stl index 174970a60..b71fe88d1 100644 --- a/data/levels/world1/05 - The Somewhat Smaller Bath.stl +++ b/data/levels/world1/05 - The Somewhat Smaller Bath.stl @@ -96,9 +96,6 @@ (image "images/background/arctis.jpg") (speed 0.5) ) - (leveltime - (time 300) - ) (camera (mode "normal") ) diff --git a/data/levels/world1/07 - Oh No More Snowballs.stl b/data/levels/world1/07 - Oh No More Snowballs.stl index 4a85e9103..94f3c185d 100644 --- a/data/levels/world1/07 - Oh No More Snowballs.stl +++ b/data/levels/world1/07 - Oh No More Snowballs.stl @@ -96,9 +96,6 @@ (image "images/background/arctis.jpg") (speed 0.5) ) - (leveltime - (time 300) - ) (camera (mode "normal") ) diff --git a/data/levels/world1/08 - Stone Cold.stl b/data/levels/world1/08 - Stone Cold.stl index 2872957d6..91a72f161 100644 --- a/data/levels/world1/08 - Stone Cold.stl +++ b/data/levels/world1/08 - Stone Cold.stl @@ -96,9 +96,6 @@ (image "images/background/arctis.jpg") (speed 0.5) ) - (leveltime - (time 300) - ) (camera (mode "normal") ) diff --git a/data/levels/world1/09 - Grumbels Sense of Snow.stl b/data/levels/world1/09 - Grumbels Sense of Snow.stl index 39a9db075..649b59a01 100644 --- a/data/levels/world1/09 - Grumbels Sense of Snow.stl +++ b/data/levels/world1/09 - Grumbels Sense of Snow.stl @@ -96,9 +96,6 @@ (image "images/background/arctis.jpg") (speed 0.5) ) - (leveltime - (time 300) - ) (particles-snow (layer -200) ) diff --git a/data/levels/world1/10 - 23rd Airborne.stl b/data/levels/world1/10 - 23rd Airborne.stl index fd9ab8ea6..f60131fa5 100644 --- a/data/levels/world1/10 - 23rd Airborne.stl +++ b/data/levels/world1/10 - 23rd Airborne.stl @@ -96,9 +96,6 @@ (image "images/background/arctis.jpg") (speed 0.5) ) - (leveltime - (time 300) - ) (camera (mode "normal") ) diff --git a/data/levels/world1/11 - Night Chill.stl b/data/levels/world1/11 - Night Chill.stl index e312ae99e..d3587da84 100644 --- a/data/levels/world1/11 - Night Chill.stl +++ b/data/levels/world1/11 - Night Chill.stl @@ -96,9 +96,6 @@ (top_color 0.0 0.0 0.0) (bottom_color 0.0 0.0 0.4) ) - (leveltime - (time 300) - ) (particles-snow (layer -200) ) diff --git a/data/levels/world1/12 - Into the Stars.stl b/data/levels/world1/12 - Into the Stars.stl index f8a92d70c..821136b8b 100644 --- a/data/levels/world1/12 - Into the Stars.stl +++ b/data/levels/world1/12 - Into the Stars.stl @@ -96,9 +96,6 @@ (top_color 0.0 0.0 0.0) (bottom_color 0.0 0.0 0.4) ) - (leveltime - (time 300) - ) (particles-snow (layer -200) ) diff --git a/data/levels/world1/13 - Above the Arctic Skies.stl b/data/levels/world1/13 - Above the Arctic Skies.stl index bcb6d5478..0aec9d227 100644 --- a/data/levels/world1/13 - Above the Arctic Skies.stl +++ b/data/levels/world1/13 - Above the Arctic Skies.stl @@ -97,9 +97,6 @@ (top_color 0.4 0.6 1.0) (bottom_color 1.0 1.0 1.0) ) - (leveltime - (time 200) - ) (particles-clouds (layer -200) ) diff --git a/data/levels/world1/14 - Entrance to the Cave.stl b/data/levels/world1/14 - Entrance to the Cave.stl index 9b644fe4c..ab10d5e42 100644 --- a/data/levels/world1/14 - Entrance to the Cave.stl +++ b/data/levels/world1/14 - Entrance to the Cave.stl @@ -95,9 +95,6 @@ (image "images/background/arctis.jpg") (speed 0.5) ) - (leveltime - (time 300) - ) (camera (mode "normal") ) diff --git a/data/levels/world1/15 - Under the Ice.stl b/data/levels/world1/15 - Under the Ice.stl index 68eb7c049..19e84f60d 100644 --- a/data/levels/world1/15 - Under the Ice.stl +++ b/data/levels/world1/15 - Under the Ice.stl @@ -95,9 +95,6 @@ (image "images/background/cave2.jpg") (speed 0.5) ) - (leveltime - (time 300) - ) (camera (mode "normal") ) diff --git a/data/levels/world1/16 - Living in a Fridge.stl b/data/levels/world1/16 - Living in a Fridge.stl index 14aaf01b3..625c0540e 100644 --- a/data/levels/world1/16 - Living in a Fridge.stl +++ b/data/levels/world1/16 - Living in a Fridge.stl @@ -95,9 +95,6 @@ (image "images/background/cave2.jpg") (speed 0.5) ) - (leveltime - (time 300) - ) (camera (mode "normal") ) diff --git a/data/levels/world1/17 - Or is it just me.stl b/data/levels/world1/17 - Or is it just me.stl index cf2ea2874..cd3485cb2 100644 --- a/data/levels/world1/17 - Or is it just me.stl +++ b/data/levels/world1/17 - Or is it just me.stl @@ -95,9 +95,6 @@ (image "images/background/cave2.jpg") (speed 0.5) ) - (leveltime - (time 300) - ) (camera (mode "normal") ) diff --git a/data/levels/world1/18 - Ice in the Hole.stl b/data/levels/world1/18 - Ice in the Hole.stl index 275fb93c1..0f10ee26e 100644 --- a/data/levels/world1/18 - Ice in the Hole.stl +++ b/data/levels/world1/18 - Ice in the Hole.stl @@ -95,9 +95,6 @@ (image "images/background/cave2.jpg") (speed 0.5) ) - (leveltime - (time 300) - ) (camera (mode "normal") ) diff --git a/data/levels/world1/19 - Miyamoto Monument.stl b/data/levels/world1/19 - Miyamoto Monument.stl index 6291835cb..276c139a8 100644 --- a/data/levels/world1/19 - Miyamoto Monument.stl +++ b/data/levels/world1/19 - Miyamoto Monument.stl @@ -95,9 +95,6 @@ (image "images/background/cave2.jpg") (speed 0.5) ) - (leveltime - (time 300) - ) (camera (mode "normal") ) diff --git a/data/levels/world1/20 - End of the Tunnel.stl b/data/levels/world1/20 - End of the Tunnel.stl index 903f1ad5b..a6c7b217f 100644 --- a/data/levels/world1/20 - End of the Tunnel.stl +++ b/data/levels/world1/20 - End of the Tunnel.stl @@ -95,9 +95,6 @@ (image "images/background/cave2.jpg") (speed 0.5) ) - (leveltime - (time 300) - ) (camera (mode "normal") ) diff --git a/data/levels/world1/21 - A Path in the Clouds.stl b/data/levels/world1/21 - A Path in the Clouds.stl index 81d3c4ea1..cce1c96df 100644 --- a/data/levels/world1/21 - A Path in the Clouds.stl +++ b/data/levels/world1/21 - A Path in the Clouds.stl @@ -95,9 +95,6 @@ (image "images/background/arctis.jpg") (speed 0.5) ) - (leveltime - (time 300) - ) (camera (mode "normal") ) diff --git a/data/levels/world1/22 - A Mysterious House of Ice.stl b/data/levels/world1/22 - A Mysterious House of Ice.stl index d0f49daf6..19ad7ce26 100644 --- a/data/levels/world1/22 - A Mysterious House of Ice.stl +++ b/data/levels/world1/22 - A Mysterious House of Ice.stl @@ -95,9 +95,6 @@ (image "images/background/arctis.jpg") (speed 0.5) ) - (leveltime - (time 300) - ) (camera (mode "normal") ) diff --git a/data/levels/world1/23 - The Escape.stl b/data/levels/world1/23 - The Escape.stl index 4d636a926..0a022528e 100644 --- a/data/levels/world1/23 - The Escape.stl +++ b/data/levels/world1/23 - The Escape.stl @@ -96,9 +96,6 @@ (image "images/background/arctis.jpg") (speed 0.5) ) - (leveltime - (time 300) - ) (camera (mode "normal") ) diff --git a/data/levels/world1/24 - The Shattered Bridge.stl b/data/levels/world1/24 - The Shattered Bridge.stl index 81339256c..7c2cf5e1a 100644 --- a/data/levels/world1/24 - The Shattered Bridge.stl +++ b/data/levels/world1/24 - The Shattered Bridge.stl @@ -96,9 +96,6 @@ (image "images/background/ocean.jpg") (speed 0.500000) ) - (leveltime - (time 300.000000) - ) (spawnpoint (name "main") (x 96) (y 160)) (firefly (x 6860) (y 222)) (mriceblock (x 757) (y 221)) diff --git a/data/levels/world1/25 - Arctic Ruins.stl b/data/levels/world1/25 - Arctic Ruins.stl index b1a4e019f..86c833db0 100644 --- a/data/levels/world1/25 - Arctic Ruins.stl +++ b/data/levels/world1/25 - Arctic Ruins.stl @@ -97,9 +97,6 @@ (image "images/background/ocean.jpg") (speed 0.5) ) - (leveltime - (time 300) - ) (camera (mode "normal") ) diff --git a/data/levels/world1/26 - The Castle of Nolok.stl b/data/levels/world1/26 - The Castle of Nolok.stl index 9958c7a41..4bccd2e9e 100644 --- a/data/levels/world1/26 - The Castle of Nolok.stl +++ b/data/levels/world1/26 - The Castle of Nolok.stl @@ -95,9 +95,6 @@ (top_color 0.0 0.0 0.0) (bottom_color 0.6 0.0 0.0) ) - (leveltime - (time 300) - ) (camera (mode "normal") ) diff --git a/data/levels/world1/27 - No More Mr Ice Guy.stl b/data/levels/world1/27 - No More Mr Ice Guy.stl index 9f60d7e73..787ade220 100644 --- a/data/levels/world1/27 - No More Mr Ice Guy.stl +++ b/data/levels/world1/27 - No More Mr Ice Guy.stl @@ -101,7 +101,7 @@ ) (spawnpoint (name "main") (x 480) (y 448)) (init-script " -DisplayEffect.fade_in(2.5); +Effect.fade_in(1); ") (yeti (x 2) @@ -112,12 +112,9 @@ Text.set_text(\"You Made It BIG TIME!\"); Text.set_font(\"big\"); Text.fade_in(1.5); wait(6); -DisplayEffect.fade_out(1.5); +Effect.fade_out(1.5); wait(1.5); - - - -Level.finish(); +Level.finish(true); ") ) (particles-snow diff --git a/data/levels/world1/yeti.stl b/data/levels/world1/yeti.stl deleted file mode 100644 index d909f4ae5..000000000 --- a/data/levels/world1/yeti.stl +++ /dev/null @@ -1,147 +0,0 @@ -;; Generated by Flexlay Editor -(supertux-level - (version 2) - (name (_ "Yeti Test")) - (author "Team") - (sector - (name "main") - (music "music/bossattack.ogg") - (gravity 10.000000) - (tilemap - (layer "background") - (solid #f) - (speed 1.000000) - (width 25) - (height 20) - (tiles - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - )) - (tilemap - (layer "interactive") - (solid #t) - (speed 1.000000) - (width 25) - (height 20) - (tiles - 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 - 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 8 8 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 8 8 - 14 14 15 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 13 14 14 - 11 11 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 11 11 - 11 11 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 11 11 - 11 11 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 11 11 - 11 11 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 11 11 - 11 11 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 11 11 - 11 11 21 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 22 11 11 - 11 11 20 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 23 11 11 - )) - (tilemap - (layer "foreground") - (solid #f) - (speed 1.000000) - (width 25) - (height 20) - (tiles - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - )) - (camera - (mode "normal") - ) - - (background - (image "images/background/semi_arctic.jpg") - (speed 0.500000) - ) - (spawnpoint (name "main") (x 480) (y 448)) - (init-script " -DisplayEffect.fade_in(2.5); -") - (yeti - (x 2) - (y 177) - (dead-script " -Sound.play(\"sounds/invincible.wav\"); -Text.set_text(\"You Made It BIG TIME!\"); -Text.set_font(\"big\"); -Text.fade_in(1.5); -wait(6); -DisplayEffect.fade_out(1.5); -wait(1.5); - - - -Level.finish(); -") - ) - (particles-snow - ) - (yeti_stalactite (x 97) (y 32)) - (yeti_stalactite (x 128) (y 32)) - (yeti_stalactite (x 161) (y 32)) - (yeti_stalactite (x 191) (y 32)) - (yeti_stalactite (x 223) (y 32)) - (yeti_stalactite (x 255) (y 32)) - (yeti_stalactite (x 288) (y 32)) - (yeti_stalactite (x 321) (y 32)) - (yeti_stalactite (x 352) (y 32)) - (yeti_stalactite (x 384) (y 32)) - (yeti_stalactite (x 417) (y 32)) - (yeti_stalactite (x 576) (y 32)) - (yeti_stalactite (x 545) (y 32)) - (yeti_stalactite (x 512) (y 32)) - (yeti_stalactite (x 479) (y 32)) - (yeti_stalactite (x 448) (y 32)) - (yeti_stalactite (x 607) (y 32)) - (yeti_stalactite (x 639) (y 32)) - (yeti_stalactite (x 671) (y 32)) - ) - ) - -;; EOF ;; diff --git a/src/console.cpp b/src/console.cpp index 257172c77..66b7a6c68 100644 --- a/src/console.cpp +++ b/src/console.cpp @@ -29,20 +29,18 @@ #include "main.hpp" #include "resources.hpp" -namespace { - int ticks; // TODO: use a clock? -} +/// speed (pixels/s) the console closes +static const float CLOSE_SPEED = 50; Console::Console() + : backgroundOffset(0), height(0), offset(0), focused(false), stayOpen(0) { - background = new Surface("images/engine/console.png"); - background2 = new Surface("images/engine/console2.png"); + background.reset(new Surface("images/engine/console.png")); + background2.reset(new Surface("images/engine/console2.png")); } Console::~Console() { - delete background; - delete background2; } void @@ -156,7 +154,9 @@ Console::addLine(std::string s) if (height < 4+9) height=4+9; height+=9; } - ticks=60; + + if(stayOpen < 5) + stayOpen += 0.7; } void @@ -247,6 +247,7 @@ Console::hide() { focused = false; height = 0; + stayOpen = 0; // clear input buffer inputBuffer.str(std::string()); @@ -263,22 +264,29 @@ Console::toggle() } } +void +Console::update(float elapsed_time) +{ + if(stayOpen > 0) { + stayOpen -= elapsed_time; + if(stayOpen < 0) + stayOpen = 0; + } else if(!focused && height > 0) { + height -= elapsed_time * CLOSE_SPEED; + if(height < 0) + height = 0; + } +} + void Console::draw(DrawingContext& context) { - if (height == 0) return; - if (!focused) { - if (ticks-- < 0) { - height-=10; - ticks=0; - if (height < 0) height=0; - } - if (height == 0) return; - } + if (height == 0) + return; - context.draw_surface(background2, Vector(SCREEN_WIDTH/2 - background->get_width()/2 - background->get_width() + backgroundOffset, height - background->get_height()), LAYER_FOREGROUND1+1); - context.draw_surface(background2, Vector(SCREEN_WIDTH/2 - background->get_width()/2 + backgroundOffset, height - background->get_height()), LAYER_FOREGROUND1+1); - context.draw_surface(background, Vector(SCREEN_WIDTH/2 - background->get_width()/2, height - background->get_height()), LAYER_FOREGROUND1+1); + context.draw_surface(background2.get(), Vector(SCREEN_WIDTH/2 - background->get_width()/2 - background->get_width() + backgroundOffset, height - background->get_height()), LAYER_FOREGROUND1+1); + context.draw_surface(background2.get(), Vector(SCREEN_WIDTH/2 - background->get_width()/2 + backgroundOffset, height - background->get_height()), LAYER_FOREGROUND1+1); + context.draw_surface(background.get(), Vector(SCREEN_WIDTH/2 - background->get_width()/2, height - background->get_height()), LAYER_FOREGROUND1+1); backgroundOffset+=10; if (backgroundOffset > (int)background->get_width()) backgroundOffset -= (int)background->get_width(); @@ -334,14 +342,9 @@ Console::unregisterCommands(ConsoleCommandReceiver* ccr) } } -int Console::height = 0; -bool Console::focused = false; -std::list Console::lines; -std::map > Console::commands; +Console* Console::instance = NULL; ConsoleStreamBuffer Console::inputBuffer; ConsoleStreamBuffer Console::outputBuffer; std::ostream Console::input(&Console::inputBuffer); std::ostream Console::output(&Console::outputBuffer); -int Console::offset = 0; -int Console::backgroundOffset = 0; diff --git a/src/console.hpp b/src/console.hpp index 1863309f8..fd728dfbd 100644 --- a/src/console.hpp +++ b/src/console.hpp @@ -35,70 +35,78 @@ class Surface; class Console { - public: - Console(); - ~Console(); - - static std::ostream input; /**< stream of keyboard input to send to the console. Do not forget to send std::endl or to flush the stream. */ - static std::ostream output; /**< stream of characters to output to the console. Do not forget to send std::endl or to flush the stream. */ - - static void backspace(); /**< delete last character sent to the input stream */ - static void scroll(int offset); /**< scroll console text up or down by @c offset lines */ - static void autocomplete(); /**< autocomplete current command */ - - void draw(DrawingContext& context); /**< draw the console in a DrawingContext */ - static void show(); /**< display the console */ - static void hide(); /**< hide the console */ - static void toggle(); /**< display the console if hidden, hide otherwise */ - - static bool hasFocus(); /**< true if characters should be sent to the console instead of their normal target */ - static void registerCommand(std::string command, ConsoleCommandReceiver* ccr); /**< associate command with the given CCR */ - static void unregisterCommand(std::string command, ConsoleCommandReceiver* ccr); /**< dissociate command and CCR */ - static void unregisterCommands(ConsoleCommandReceiver* ccr); /**< dissociate all commands of given CCR */ - - template static bool string_is(std::string s) { - std::istringstream iss(s); - T i; - if ((iss >> i) && iss.eof()) { - return true; - } else { - return false; - } +public: + Console(); + ~Console(); + + static Console* instance; + + static std::ostream input; /**< stream of keyboard input to send to the console. Do not forget to send std::endl or to flush the stream. */ + static std::ostream output; /**< stream of characters to output to the console. Do not forget to send std::endl or to flush the stream. */ + + void backspace(); /**< delete last character sent to the input stream */ + void scroll(int offset); /**< scroll console text up or down by @c offset lines */ + void autocomplete(); /**< autocomplete current command */ + + void draw(DrawingContext& context); /**< draw the console in a DrawingContext */ + void update(float elapsed_time); + + void show(); /**< display the console */ + void hide(); /**< hide the console */ + void toggle(); /**< display the console if hidden, hide otherwise */ + + bool hasFocus(); /**< true if characters should be sent to the console instead of their normal target */ + void registerCommand(std::string command, ConsoleCommandReceiver* ccr); /**< associate command with the given CCR */ + void unregisterCommand(std::string command, ConsoleCommandReceiver* ccr); /**< dissociate command and CCR */ + void unregisterCommands(ConsoleCommandReceiver* ccr); /**< dissociate all commands of given CCR */ + + template static bool string_is(std::string s) { + std::istringstream iss(s); + T i; + if ((iss >> i) && iss.eof()) { + return true; + } else { + return false; } + } - template static T string_to(std::string s) { - std::istringstream iss(s); - T i; - if ((iss >> i) && iss.eof()) { - return i; - } else { - return T(); - } + template static T string_to(std::string s) { + std::istringstream iss(s); + T i; + if ((iss >> i) && iss.eof()) { + return i; + } else { + return T(); } + } - protected: - static std::list lines; /**< backbuffer of lines sent to the console */ - static std::map > commands; /**< map of console commands and a list of associated ConsoleCommandReceivers */ - Surface* background; /**< console background image */ - Surface* background2; /**< second, moving console background image */ - static int backgroundOffset; /**< current offset of scrolling background image */ - static int height; /**< height of the console in px */ - static int offset; /**< decrease to scroll text up */ - static bool focused; /**< true if console has input focus */ - - static ConsoleStreamBuffer inputBuffer; /**< stream buffer used by input stream */ - static ConsoleStreamBuffer outputBuffer; /**< stream buffer used by output stream */ - - static void addLine(std::string s); /**< display a line in the console */ - static void parse(std::string s); /**< react to a given command */ +private: + std::list lines; /**< backbuffer of lines sent to the console */ + std::map > commands; /**< map of console commands and a list of associated ConsoleCommandReceivers */ + + std::auto_ptr background; /**< console background image */ + std::auto_ptr background2; /**< second, moving console background image */ + + int backgroundOffset; /**< current offset of scrolling background image */ + float height; /**< height of the console in px */ + int offset; /**< decrease to scroll text up */ + bool focused; /**< true if console has input focus */ + + float stayOpen; + + static ConsoleStreamBuffer inputBuffer; /**< stream buffer used by input stream */ + static ConsoleStreamBuffer outputBuffer; /**< stream buffer used by output stream */ + + void addLine(std::string s); /**< display a line in the console */ + void parse(std::string s); /**< react to a given command */ - /** execute squirrel script and output result */ - static void execute_script(const std::string& s); + /** execute squirrel script and output result */ + void execute_script(const std::string& s); - static bool consoleCommand(std::string command, std::vector arguments); /**< process internal command; return false if command was unknown, true otherwise */ + bool consoleCommand(std::string command, std::vector arguments); /**< process internal command; return false if command was unknown, true otherwise */ - friend class ConsoleStreamBuffer; - static void flush(ConsoleStreamBuffer* buffer); /**< act upon changes in a ConsoleStreamBuffer */ + friend class ConsoleStreamBuffer; + void flush(ConsoleStreamBuffer* buffer); /**< act upon changes in a ConsoleStreamBuffer */ }; class ConsoleStreamBuffer : public std::stringbuf @@ -107,7 +115,8 @@ class ConsoleStreamBuffer : public std::stringbuf int sync() { int result = std::stringbuf::sync(); - Console::flush(this); + if(Console::instance != NULL) + Console::instance->flush(this); return result; } }; @@ -117,7 +126,7 @@ class ConsoleCommandReceiver public: virtual ~ConsoleCommandReceiver() { - Console::unregisterCommands(this); + Console::instance->unregisterCommands(this); } /** diff --git a/src/control/joystickkeyboardcontroller.cpp b/src/control/joystickkeyboardcontroller.cpp index cffa6f5cb..d154f1574 100644 --- a/src/control/joystickkeyboardcontroller.cpp +++ b/src/control/joystickkeyboardcontroller.cpp @@ -343,12 +343,12 @@ JoystickKeyboardController::process_key_event(const SDL_Event& event) // if console key was pressed: toggle console if ((key_mapping != keymap.end()) && (key_mapping->second == CONSOLE)) { if (event.type != SDL_KEYDOWN) return; - Console::toggle(); + Console::instance->toggle(); return; } // if console is open: send key there - if (Console::hasFocus()) { + if (Console::instance->hasFocus()) { process_console_key_event(event); return; } @@ -375,27 +375,27 @@ JoystickKeyboardController::process_console_key_event(const SDL_Event& event) switch (event.key.keysym.sym) { case SDLK_RETURN: - Console::input << std::endl; + Console::instance->input << std::endl; break; case SDLK_BACKSPACE: - Console::backspace(); + Console::instance->backspace(); break; case SDLK_TAB: - Console::autocomplete(); + Console::instance->autocomplete(); break; case SDLK_PAGEUP: - Console::scroll(-1); + Console::instance->scroll(-1); break; case SDLK_PAGEDOWN: - Console::scroll(+1); + Console::instance->scroll(+1); break; case SDLK_END: - Console::scroll(+65535); + Console::instance->scroll(+65535); break; default: int c = event.key.keysym.unicode; if ((c >= 32) && (c <= 126)) { - Console::input << (char)c; + Console::instance->input << (char)c; } break; } diff --git a/src/game_session.cpp b/src/game_session.cpp index 2d21d6715..072e233c4 100644 --- a/src/game_session.cpp +++ b/src/game_session.cpp @@ -111,10 +111,10 @@ GameSession::GameSession(const std::string& levelfile_, GameSessionMode mode, fps_fps = 0; for (uint16_t i=0; i < sizeof(::consoleCommands)/sizeof(typeof(consoleCommands[0])); i++) { - Console::registerCommand(consoleCommands[i], this); + Console::instance->registerCommand(consoleCommands[i], this); } - statistics_backdrop = new Surface("images/engine/menu/score-backdrop.png"); + statistics_backdrop.reset(new Surface("images/engine/menu/score-backdrop.png")); restart_level(true); } @@ -127,10 +127,9 @@ GameSession::restart_level(bool fromBeginning) main_controller->reset(); - delete level; currentsector = 0; - level = new Level; + level.reset(new Level); level->load(levelfile); global_stats.reset(); @@ -187,9 +186,6 @@ GameSession::~GameSession() delete demo_controller; delete end_sequence_controller; - delete level; - - delete statistics_backdrop; current_ = NULL; } @@ -802,7 +798,7 @@ GameSession::drawstatus(DrawingContext& context) // draw level stats while end_sequence is running if (end_sequence) { - global_stats.draw_endseq_panel(context, best_level_statistics, statistics_backdrop); + global_stats.draw_endseq_panel(context, best_level_statistics, statistics_backdrop.get()); } } diff --git a/src/game_session.hpp b/src/game_session.hpp index 6b7245082..69e93f626 100644 --- a/src/game_session.hpp +++ b/src/game_session.hpp @@ -87,7 +87,7 @@ public: { return currentsector; } Level* get_current_level() - { return level; } + { return level.get(); } void start_sequence(const std::string& sequencename); @@ -113,8 +113,8 @@ private: void process_menu(); Timer endsequence_timer; - Level* level; - Surface* statistics_backdrop; // FIXME: where to put this? + std::auto_ptr level; + std::auto_ptr statistics_backdrop; Sector* currentsector; @@ -154,7 +154,6 @@ private: std::string capture_file; std::istream* playback_demo_stream; CodeController* demo_controller; - Console* console; }; #endif /*SUPERTUX_GAMELOOP_H*/ diff --git a/src/main.cpp b/src/main.cpp index 7536cabeb..969e602d5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -256,6 +256,8 @@ static void init_sdl() msg << "Couldn't initialize SDL: " << SDL_GetError(); throw std::runtime_error(msg.str()); } + // just to be sure + atexit(SDL_Quit); SDL_EnableUNICODE(1); @@ -459,6 +461,8 @@ static inline void timelog(const char* ) int main(int argc, char** argv) { + int result = 0; + try { srand(time(0)); init_physfs(argv[0]); @@ -476,6 +480,7 @@ int main(int argc, char** argv) init_audio(); timelog("video"); init_video(); + Console::instance = new Console(); timelog("scripting"); init_scripting(); @@ -504,17 +509,17 @@ int main(int argc, char** argv) } main_loop->run(); - - delete main_loop; - main_loop = NULL; } catch(std::exception& e) { msg_fatal << "Unexpected exception: " << e.what() << std::endl; - return 1; + result = 1; } catch(...) { msg_fatal << "Unexpected exception" << std::endl; - return 1; + result = 1; } + delete main_loop; + main_loop = NULL; + free_menu(); delete ScriptManager::instance; ScriptManager::instance = NULL; @@ -527,10 +532,12 @@ int main(int argc, char** argv) config = NULL; delete main_controller; main_controller = NULL; + delete Console::instance; + Console::instance = NULL; delete texture_manager; texture_manager = NULL; SDL_Quit(); PHYSFS_deinit(); - return 0; + return result; } diff --git a/src/mainloop.cpp b/src/mainloop.cpp index 575005bb8..6c21a3a1f 100644 --- a/src/mainloop.cpp +++ b/src/mainloop.cpp @@ -43,7 +43,6 @@ MainLoop* main_loop = NULL; MainLoop::MainLoop() : speed(1.0) { - console.reset(new Console()); } MainLoop::~MainLoop() @@ -142,7 +141,7 @@ MainLoop::run() current_screen->draw(context); if(Menu::current() != NULL) Menu::current()->draw(context); - console->draw(context); + Console::instance->draw(context); context.do_drawing(); @@ -165,6 +164,7 @@ MainLoop::run() game_time += elapsed_time; ScriptManager::instance->update(); current_screen->update(elapsed_time); + Console::instance->update(elapsed_time); main_controller->update(); SDL_Event event; diff --git a/src/player_status.cpp b/src/player_status.cpp index 02a44e9d9..6c9d97ba5 100644 --- a/src/player_status.cpp +++ b/src/player_status.cpp @@ -55,7 +55,7 @@ PlayerStatus::PlayerStatus() tux_life.reset(sprite_manager->create("images/creatures/tux_small/tux-life.sprite")); - Console::registerCommand("coins", this); + Console::instance->registerCommand("coins", this); } PlayerStatus::~PlayerStatus() diff --git a/src/sector.cpp b/src/sector.cpp index d0c4a9591..e39227073 100644 --- a/src/sector.cpp +++ b/src/sector.cpp @@ -473,6 +473,7 @@ Sector::activate(const Vector& player_pos) player->move(player_pos); camera->reset(player->get_pos()); + update_game_objects(); // Run init script if(init_script != "") { @@ -675,9 +676,14 @@ Sector::try_unexpose(GameObject* object) ScriptInterface* interface = dynamic_cast (object); if(interface != NULL) { HSQUIRRELVM vm = script_manager->get_vm(); + int oldtop = sq_gettop(vm); sq_pushobject(vm, sector_table); - interface->unexpose(vm, -1); - sq_pop(vm, 1); + try { + interface->unexpose(vm, -1); + } catch(std::exception& e) { + msg_warning << "Couldn't unregister object: " << e.what() << std::endl; + } + sq_settop(vm, oldtop); } } diff --git a/src/title.cpp b/src/title.cpp index 187b6f0e1..7dca58137 100644 --- a/src/title.cpp +++ b/src/title.cpp @@ -430,11 +430,14 @@ TitleScreen::process_load_game_menu() stream << "save/" << worlddirname << "_" << slot << ".stsg"; std::string slotfile = stream.str(); - sound_manager->stop_music(); fadeout(256); - current_world->set_savegame_filename(slotfile); - current_world->run(); + try { + current_world->set_savegame_filename(slotfile); + current_world->run(); + } catch(std::exception& e) { + msg_fatal << "Couldn't start world: " << e.what() << std::endl; + } return true; } diff --git a/src/world.cpp b/src/world.cpp index 85f3d9c9f..1c66ab441 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -61,6 +61,22 @@ void World::set_savegame_filename(const std::string& filename) { this->savegame_filename = filename; + // make sure the savegame directory exists + std::string dirname = FileSystem::dirname(filename); + if(!PHYSFS_exists(dirname.c_str())) { + if(PHYSFS_mkdir(dirname.c_str())) { + std::ostringstream msg; + msg << "Couldn't create directory for savegames '" + << dirname << "': " <