X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fgame_session.cpp;h=1532e3942a91600bb79296b76e7df80974487bae;hb=edd21bac021e9586d8edc831c231c226d5ff1bc7;hp=072e233c4c16ec05989f4c26419c50ec6bd883d0;hpb=0b60c77a1a01e753919be95aafc22ee38a0fcb62;p=supertux.git diff --git a/src/game_session.cpp b/src/game_session.cpp index 072e233c4..1532e3942 100644 --- a/src/game_session.cpp +++ b/src/game_session.cpp @@ -1,9 +1,7 @@ // $Id$ -// +// // SuperTux -// Copyright (C) 2000 Bill Kendrick -// Copyright (C) 2004 Tobias Glaesser -// Copyright (C) 2004 Ingo Ruhnke +// Copyright (C) 2006 Matthias Braun // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -14,7 +12,7 @@ // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. @@ -35,8 +33,8 @@ #include #include "game_session.hpp" -#include "msg.hpp" -#include "worldmap.hpp" +#include "log.hpp" +#include "worldmap/worldmap.hpp" #include "mainloop.hpp" #include "video/screen.hpp" #include "audio/sound_manager.hpp" @@ -55,7 +53,6 @@ #include "lisp/lisp.hpp" #include "lisp/parser.hpp" #include "resources.hpp" -#include "worldmap.hpp" #include "misc.hpp" #include "statistics.hpp" #include "timer.hpp" @@ -75,27 +72,7 @@ // binary fraction... static const float LOGICAL_FPS = 64.0; -namespace { - const char* consoleCommands[] = { - "foo", - "whereami", - "camera", - "grease", - "invincible", - "mortal", - "shrink", - "kill", - "gotoend", - "flip", - "finish", - "restart", - "quit" - }; -} - -using namespace WorldMapNS; - -GameSession* GameSession::current_ = 0; +GameSession* GameSession::current_ = NULL; GameSession::GameSession(const std::string& levelfile_, GameSessionMode mode, Statistics* statistics) @@ -105,15 +82,11 @@ GameSession::GameSession(const std::string& levelfile_, GameSessionMode mode, capture_demo_stream(0), playback_demo_stream(0), demo_controller(0) { current_ = this; - currentsector = 0; + currentsector = NULL; game_pause = false; fps_fps = 0; - for (uint16_t i=0; i < sizeof(::consoleCommands)/sizeof(typeof(consoleCommands[0])); i++) { - Console::instance->registerCommand(consoleCommands[i], this); - } - statistics_backdrop.reset(new Surface("images/engine/menu/score-backdrop.png")); restart_level(true); @@ -277,6 +250,7 @@ GameSession::on_escape_press() game_menu->set_active_item(MNID_CONTINUE); game_pause = true; } else { + Menu::set_current(NULL); game_pause = false; } } @@ -338,79 +312,6 @@ GameSession::process_events() } } -bool -GameSession::consoleCommand(std::string command, std::vector) -{ - if (command == "foo") { - msg_info << "bar" << std::endl; - return true; - } - - if (currentsector == 0) return false; - Player& tux = *currentsector->player; - - // Cheating words (the goal of this is really for debugging, - // but could be used for some cheating, nothing wrong with that) - if (command == "grease") { - tux.physic.set_velocity_x(tux.physic.get_velocity_x()*3); - return true; - } - if (command == "invincible") { - // be invincle for the rest of the level - tux.invincible_timer.start(10000); - return true; - } - if (command == "mortal") { - // give up invincibility - tux.invincible_timer.stop(); - return true; - } - if (command == "shrink") { - // remove powerups - tux.kill(tux.SHRINK); - return true; - } - if (command == "kill") { - tux.kill(tux.KILL); - return true; - } - if (command == "restart") { - restart_level(true); - return true; - } - if (command == "whereami") { - msg_info << "You are at x " << tux.get_pos().x << ", y " << tux.get_pos().y << std::endl; - return true; - } - if (command == "gotoend") { - // goes to the end of the level - tux.move(Vector( - (currentsector->solids->get_width()*32) - (SCREEN_WIDTH*2), 0)); - currentsector->camera->reset( - Vector(tux.get_pos().x, tux.get_pos().y)); - return true; - } - if (command == "flip") { - FlipLevelTransformer flip_transformer; - flip_transformer.transform(GameSession::current()->get_current_level()); - return true; - } - if (command == "finish") { - finish(true); - return true; - } - if (command == "camera") { - msg_info << "Camera is at " << Sector::current()->camera->get_translation().x << "," << Sector::current()->camera->get_translation().y << std::endl; - return true; - } - if (command == "quit") { - main_loop->quit(); - return true; - } - - return false; -} - void GameSession::check_end_conditions() { @@ -501,7 +402,7 @@ GameSession::update(float elapsed_time) if(newsector != "" && newspawnpoint != "") { Sector* sector = level->get_sector(newsector); if(sector == 0) { - msg_warning << "Sector '" << newsector << "' not found" << std::endl; + log_warning << "Sector '" << newsector << "' not found" << std::endl; } sector->activate(newspawnpoint); sector->play_music(LEVEL_MUSIC); @@ -658,6 +559,8 @@ GameSession::run() void GameSession::finish(bool win) { + using namespace WorldMapNS; + if(win) { if(WorldMap::current()) WorldMap::current()->finished_level(levelfile); @@ -773,12 +676,12 @@ GameSession::start_sequence(const std::string& sequencename) } } else if(sequencename == "stoptux") { if(!end_sequence) { - msg_warning << "Final target reached without an active end sequence" << std::endl; + log_warning << "Final target reached without an active end sequence" << std::endl; this->start_sequence("endsequence"); } end_sequence = ENDSEQUENCE_WAITING; } else { - msg_warning << "Unknown sequence '" << sequencename << "'" << std::endl; + log_warning << "Unknown sequence '" << sequencename << "'" << std::endl; } }