From: Matthias Braun Date: Wed, 12 Apr 2006 13:24:01 +0000 (+0000) Subject: fade out console X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=e6a940db5904743e8220491ce10b5107e119a44c;p=supertux.git fade out console SVN-Revision: 3315 --- diff --git a/src/audio/sound_file.cpp b/src/audio/sound_file.cpp index bcd6e3eb4..a05fc1a7d 100644 --- a/src/audio/sound_file.cpp +++ b/src/audio/sound_file.cpp @@ -12,7 +12,7 @@ #include #include #include -#include "msg.hpp" +#include "log.hpp" class WavSoundFile : public SoundFile { @@ -55,7 +55,7 @@ WavSoundFile::WavSoundFile(PHYSFS_file* file) if(PHYSFS_read(file, magic, sizeof(magic), 1) != 1) throw std::runtime_error("Couldn't read file magic (not a wave file)"); if(strncmp(magic, "RIFF", 4) != 0) { - msg_debug << "MAGIC: " << magic << std::endl; + log_debug << "MAGIC: " << magic << std::endl; throw std::runtime_error("file is not a RIFF wav file"); } diff --git a/src/audio/sound_manager.cpp b/src/audio/sound_manager.cpp index ab45724a7..7cdc7e0e9 100644 --- a/src/audio/sound_manager.cpp +++ b/src/audio/sound_manager.cpp @@ -8,7 +8,7 @@ #include "sound_file.hpp" #include "sound_source.hpp" #include "stream_sound_source.hpp" -#include "msg.hpp" +#include "log.hpp" SoundManager* sound_manager = 0; @@ -34,7 +34,7 @@ SoundManager::SoundManager() } catch(std::exception& e) { device = 0; context = 0; - msg_warning << "Couldn't initialize audio device:" << e.what() << std::endl; + log_warning << "Couldn't initialize audio device:" << e.what() << std::endl; print_openal_version(); throw e; } @@ -130,7 +130,7 @@ SoundManager::play(const std::string& filename, const Vector& pos) source->play(); sources.push_back(source); } catch(std::exception& e) { - msg_warning << "Couldn't play sound " << filename << ": " << e.what() << std::endl; + log_warning << "Couldn't play sound " << filename << ": " << e.what() << std::endl; } } @@ -199,7 +199,7 @@ SoundManager::play_music(const std::string& filename, bool fade) delete music_source; music_source = newmusic.release(); } catch(std::exception& e) { - msg_warning << "Couldn't play music file '" << filename << "': " << e.what() << std::endl; + log_warning << "Couldn't play music file '" << filename << "': " << e.what() << std::endl; } } @@ -281,10 +281,10 @@ SoundManager::get_sample_format(SoundFile* file) void SoundManager::print_openal_version() { - msg_info << "OpenAL Vendor: " << alGetString(AL_VENDOR) << std::endl; - msg_info << "OpenAL Version: " << alGetString(AL_VERSION) << std::endl; - msg_info << "OpenAL Renderer: " << alGetString(AL_RENDERER) << std::endl; - msg_info << "OpenAl Extensions: " << alGetString(AL_EXTENSIONS) << std::endl; + log_info << "OpenAL Vendor: " << alGetString(AL_VENDOR) << std::endl; + log_info << "OpenAL Version: " << alGetString(AL_VERSION) << std::endl; + log_info << "OpenAL Renderer: " << alGetString(AL_RENDERER) << std::endl; + log_info << "OpenAl Extensions: " << alGetString(AL_EXTENSIONS) << std::endl; } void diff --git a/src/audio/stream_sound_source.cpp b/src/audio/stream_sound_source.cpp index 930f34c50..db061a8bb 100644 --- a/src/audio/stream_sound_source.cpp +++ b/src/audio/stream_sound_source.cpp @@ -6,7 +6,7 @@ #include "stream_sound_source.hpp" #include "sound_manager.hpp" #include "sound_file.hpp" -#include "msg.hpp" +#include "log.hpp" StreamSoundSource::StreamSoundSource() : file(0), fade_state(NoFading), looping(false) @@ -56,7 +56,7 @@ StreamSoundSource::update() return; // we might have to restart the source if we had a buffer underrun - msg_info << "Restarting audio source because of buffer underrun" << std::endl; + log_info << "Restarting audio source because of buffer underrun" << std::endl; play(); } diff --git a/src/badguy/badguy.cpp b/src/badguy/badguy.cpp index a9edc75a4..aa772a280 100644 --- a/src/badguy/badguy.cpp +++ b/src/badguy/badguy.cpp @@ -25,7 +25,7 @@ #include "tile.hpp" #include "statistics.hpp" #include "game_session.hpp" -#include "msg.hpp" +#include "log.hpp" static const float SQUISH_TIME = 2; static const float X_OFFSCREEN_DISTANCE = 1600; @@ -105,7 +105,7 @@ BadGuy::deactivate() void BadGuy::save(lisp::Writer& ) { - msg_warning << "tried to write out a generic badguy" << std::endl; + log_warning << "tried to write out a generic badguy" << std::endl; } void diff --git a/src/badguy/flame.cpp b/src/badguy/flame.cpp index cc017f973..b3f3fa355 100644 --- a/src/badguy/flame.cpp +++ b/src/badguy/flame.cpp @@ -20,7 +20,7 @@ #include #include "flame.hpp" -#include "msg.hpp" +#include "log.hpp" Flame::Flame(const lisp::Lisp& reader) : angle(0), radius(100), speed(2), source(0) @@ -75,7 +75,7 @@ Flame::activate() delete source; source = sound_manager->create_sound_source("sounds/flame.wav"); if(!source) { - msg_warning << "Couldn't start flame sound" << std::endl; + log_warning << "Couldn't start flame sound" << std::endl; return; } source->set_position(get_pos()); diff --git a/src/badguy/totem.cpp b/src/badguy/totem.cpp index 67b467dc5..00f4b078d 100644 --- a/src/badguy/totem.cpp +++ b/src/badguy/totem.cpp @@ -21,7 +21,7 @@ #include #include "totem.hpp" -#include "msg.hpp" +#include "log.hpp" static const float WALKSPEED = 100; static const float JUMP_ON_SPEED_Y = 400; @@ -211,7 +211,7 @@ void Totem::jump_on(Totem* target) { if (target->carrying) { - msg_warning << "target is already carrying someone" << std::endl; + log_warning << "target is already carrying someone" << std::endl; return; } @@ -227,7 +227,7 @@ Totem::jump_on(Totem* target) void Totem::jump_off() { if (!carried_by) { - msg_warning << "not carried by anyone" << std::endl; + log_warning << "not carried by anyone" << std::endl; return; } diff --git a/src/badguy/willowisp.cpp b/src/badguy/willowisp.cpp index 35a7a7c6b..d444961d7 100644 --- a/src/badguy/willowisp.cpp +++ b/src/badguy/willowisp.cpp @@ -20,7 +20,7 @@ #include #include "willowisp.hpp" -#include "msg.hpp" +#include "log.hpp" #include "game_session.hpp" static const float FLYSPEED = 64; /**< speed in px per second */ @@ -119,7 +119,7 @@ WillOWisp::activate() delete soundSource; soundSource = sound_manager->create_sound_source("sounds/willowisp.wav"); if(!soundSource) { - msg_warning << "Couldn't start WillOWisp sound" << std::endl; + log_warning << "Couldn't start WillOWisp sound" << std::endl; return; } soundSource->set_position(get_pos()); diff --git a/src/collision_grid.cpp b/src/collision_grid.cpp index fddc2ce74..9ad005ec9 100644 --- a/src/collision_grid.cpp +++ b/src/collision_grid.cpp @@ -21,7 +21,7 @@ #include #include "collision_grid.hpp" -#include "msg.hpp" +#include "log.hpp" #include "collision.hpp" #include "sector.hpp" #include "collision_grid_iterator.hpp" @@ -76,7 +76,7 @@ CollisionGrid::add_object(MovingObject* object) int gridy = int(y / cell_height); if(gridx < 0 || gridy < 0 || gridx >= int(cells_x) || gridy >= int(cells_y)) { - msg_warning << "Object out of range: " << gridx << ", " << gridy << std::endl; + log_warning << "Object out of range: " << gridx << ", " << gridy << std::endl; continue; } GridEntry* entry = new GridEntry; @@ -102,7 +102,7 @@ CollisionGrid::remove_object(MovingObject* object) assert(wrapper != 0); #else if(wrapper == 0) { - msg_warning << "Tried to remove nonexistant object" << std::endl; + log_warning << "Tried to remove nonexistant object" << std::endl; return; } #endif @@ -114,7 +114,7 @@ CollisionGrid::remove_object(MovingObject* object) int gridy = int(y / cell_height); if(gridx < 0 || gridy < 0 || gridx >= int(cells_x) || gridy >= int(cells_y)) { - msg_warning << "Object out of range: " << gridx << ", " << gridy << std::endl; + log_warning << "Object out of range: " << gridx << ", " << gridy << std::endl; continue; } remove_object_from_gridcell(gridy*cells_x + gridx, wrapper); @@ -136,7 +136,7 @@ CollisionGrid::move_object(ObjectWrapper* wrapper) int gridy = int(y / cell_height); if(gridx < 0 || gridy < 0 || gridx >= int(cells_x) || gridy >= int(cells_y)) { - msg_warning << "Object out of range: " << gridx << ", " << gridy << std::endl; + log_warning << "Object out of range: " << gridx << ", " << gridy << std::endl; continue; } remove_object_from_gridcell(gridy*cells_x + gridx, wrapper); @@ -150,7 +150,7 @@ CollisionGrid::move_object(ObjectWrapper* wrapper) int gridy = int(y / cell_height); if(gridx < 0 || gridy < 0 || gridx >= int(cells_x) || gridy >= int(cells_y)) { - msg_warning << "Object out of range: " << gridx << ", " << gridy << std::endl; + log_warning << "Object out of range: " << gridx << ", " << gridy << std::endl; continue; } @@ -213,7 +213,7 @@ CollisionGrid::collide_object(ObjectWrapper* wrapper) int gridy = int(y / cell_height); if(gridx < 0 || gridy < 0 || gridx >= int(cells_x) || gridy >= int(cells_y)) { - //msg_warning << "Object out of range: " << gridx << ", " << gridy << std::endl; + //log_warning << "Object out of range: " << gridx << ", " << gridy << std::endl; continue; } @@ -291,6 +291,6 @@ CollisionGrid::remove_object_from_gridcell(int gridcell, ObjectWrapper* wrapper) entry = entry->next; }; - msg_warning << "Couldn't find object in cell" << std::endl; + log_warning << "Couldn't find object in cell" << std::endl; } diff --git a/src/collision_grid_iterator.hpp b/src/collision_grid_iterator.hpp index a7979b9bc..202a59fb6 100644 --- a/src/collision_grid_iterator.hpp +++ b/src/collision_grid_iterator.hpp @@ -21,7 +21,7 @@ #define __COLLISION_GRID_ITERATOR_H__ #include "math/rect.hpp" -#include "msg.hpp" +#include "log.hpp" class CollisionGrid; @@ -52,7 +52,7 @@ public: entry = 0; if(start_x >= end_x) { - msg_debug << "bad region" << std::endl; + log_debug << "bad region" << std::endl; y = 0; end_y = 0; return; diff --git a/src/console.cpp b/src/console.cpp index 66b7a6c68..edef8b5a5 100644 --- a/src/console.cpp +++ b/src/console.cpp @@ -30,11 +30,14 @@ #include "resources.hpp" /// speed (pixels/s) the console closes -static const float CLOSE_SPEED = 50; +static const float FADE_SPEED = 1; Console::Console() - : backgroundOffset(0), height(0), offset(0), focused(false), stayOpen(0) + : backgroundOffset(0), height(0), alpha(1.0), offset(0), focused(false), + stayOpen(0) { + font.reset(new Font("images/engine/fonts/white-small.png", + "images/engine/fonts/shadow-small.png", 8, 9, 1)); background.reset(new Surface("images/engine/console.png")); background2.reset(new Surface("images/engine/console2.png")); } @@ -92,7 +95,7 @@ Console::execute_script(const std::string& command) } int newtop = sq_gettop(vm); if(newtop < oldtop) { - msg_fatal << "Script destroyed squirrel stack..." << std::endl; + log_fatal << "Script destroyed squirrel stack..." << std::endl; } else { sq_settop(vm, oldtop); } @@ -149,14 +152,19 @@ Console::addLine(std::string s) s = "..."+s.substr(99-3); } lines.push_front(s); - while (lines.size() >= 65535) lines.pop_back(); + + while (lines.size() >= 1000) + lines.pop_back(); + if (height < 64) { - if (height < 4+9) height=4+9; - height+=9; + if(height < 4) + height = 4; + height += font->get_height(); } + alpha = 1.0; if(stayOpen < 5) - stayOpen += 0.7; + stayOpen += 1; } void @@ -197,7 +205,7 @@ Console::parse(std::string s) // send command to the most recently registered ccr ConsoleCommandReceiver* ccr = i->second.front(); - if (ccr->consoleCommand(command, args) != true) msg_warning << "Sent command to registered ccr, but command was unhandled" << std::endl; + if (ccr->consoleCommand(command, args) != true) log_warning << "Sent command to registered ccr, but command was unhandled" << std::endl; } bool @@ -205,12 +213,12 @@ Console::consoleCommand(std::string command, std::vector arguments) { if (command == "ccrs") { if (arguments.size() != 1) { - msg_info << "Usage: ccrs " << std::endl; + log_info << "Usage: ccrs " << std::endl; return true; } std::map >::iterator i = commands.find(arguments[0]); if ((i == commands.end()) || (i->second.size() == 0)) { - msg_info << "unknown command: \"" << arguments[0] << "\"" << std::endl; + log_info << "unknown command: \"" << arguments[0] << "\"" << std::endl; return true; } @@ -222,7 +230,7 @@ Console::consoleCommand(std::string command, std::vector arguments) ccr_list << "[" << *j << "]"; } - msg_info << "registered ccrs for \"" << arguments[0] << "\": " << ccr_list.str() << std::endl; + log_info << "registered ccrs for \"" << arguments[0] << "\": " << ccr_list.str() << std::endl; return true; } @@ -240,6 +248,7 @@ Console::show() { focused = true; height = 256; + alpha = 1.0; } void @@ -272,9 +281,11 @@ Console::update(float elapsed_time) if(stayOpen < 0) stayOpen = 0; } else if(!focused && height > 0) { - height -= elapsed_time * CLOSE_SPEED; - if(height < 0) + alpha -= elapsed_time * FADE_SPEED; + if(alpha < 0) { + alpha = 0; height = 0; + } } } @@ -284,6 +295,8 @@ Console::draw(DrawingContext& context) if (height == 0) return; + context.push_transform(); + context.set_alpha(alpha); 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); @@ -295,7 +308,7 @@ Console::draw(DrawingContext& context) if (focused) { lineNo++; float py = height-4-1*9; - context.draw_text(white_small_text, "> "+inputBuffer.str()+"_", Vector(4, py), LEFT_ALLIGN, LAYER_FOREGROUND1+1); + context.draw_text(font.get(), "> "+inputBuffer.str()+"_", Vector(4, py), LEFT_ALLIGN, LAYER_FOREGROUND1+1); } int skipLines = -offset; @@ -304,8 +317,10 @@ Console::draw(DrawingContext& context) lineNo++; float py = height-4-lineNo*9; if (py < -9) break; - context.draw_text(white_small_text, *i, Vector(4, py), LEFT_ALLIGN, LAYER_FOREGROUND1+1); + context.draw_text(font.get(), *i, Vector(4, py), LEFT_ALLIGN, LAYER_FOREGROUND1+1); } + + context.pop_transform(); } void @@ -319,12 +334,12 @@ Console::unregisterCommand(std::string command, ConsoleCommandReceiver* ccr) { std::map >::iterator i = commands.find(command); if ((i == commands.end()) || (i->second.size() == 0)) { - msg_warning << "Command \"" << command << "\" not associated with a command receiver. Not dissociated." << std::endl; + log_warning << "Command \"" << command << "\" not associated with a command receiver. Not dissociated." << std::endl; return; } std::list::iterator j = find(i->second.begin(), i->second.end(), ccr); if (j == i->second.end()) { - msg_warning << "Command \"" << command << "\" not associated with given command receiver. Not dissociated." << std::endl; + log_warning << "Command \"" << command << "\" not associated with given command receiver. Not dissociated." << std::endl; return; } i->second.erase(j); diff --git a/src/console.hpp b/src/console.hpp index fd728dfbd..72dedd333 100644 --- a/src/console.hpp +++ b/src/console.hpp @@ -32,6 +32,7 @@ class ConsoleStreamBuffer; class ConsoleCommandReceiver; class DrawingContext; class Surface; +class Font; class Console { @@ -89,8 +90,10 @@ private: int backgroundOffset; /**< current offset of scrolling background image */ float height; /**< height of the console in px */ + float alpha; int offset; /**< decrease to scroll text up */ bool focused; /**< true if console has input focus */ + std::auto_ptr font; float stayOpen; diff --git a/src/control/joystickkeyboardcontroller.cpp b/src/control/joystickkeyboardcontroller.cpp index d154f1574..8b214c50b 100644 --- a/src/control/joystickkeyboardcontroller.cpp +++ b/src/control/joystickkeyboardcontroller.cpp @@ -21,7 +21,7 @@ #include #include "joystickkeyboardcontroller.hpp" -#include "msg.hpp" +#include "log.hpp" #include "gui/menu.hpp" #include "gettext.hpp" #include "lisp/lisp.hpp" @@ -79,12 +79,12 @@ JoystickKeyboardController::JoystickKeyboardController() SDL_Joystick* joystick = SDL_JoystickOpen(i); bool good = true; if(SDL_JoystickNumButtons(joystick) < 2) { - msg_warning << "Joystick " << i << " has less than 2 buttons" << std::endl; + log_warning << "Joystick " << i << " has less than 2 buttons" << std::endl; good = false; } if(SDL_JoystickNumAxes(joystick) < 2 && SDL_JoystickNumHats(joystick) == 0) { - msg_warning << "Joystick " << i << " has less than 2 axes and no hat" << std::endl; + log_warning << "Joystick " << i << " has less than 2 axes and no hat" << std::endl; good = false; } if(!good) { @@ -153,7 +153,7 @@ JoystickKeyboardController::read(const lisp::Lisp& lisp) map->get("key", key); map->get("control", control); if(key < SDLK_FIRST || key >= SDLK_LAST) { - msg_warning << "Invalid key '" << key << "' in keymap" << std::endl; + log_warning << "Invalid key '" << key << "' in keymap" << std::endl; continue; } @@ -163,12 +163,12 @@ JoystickKeyboardController::read(const lisp::Lisp& lisp) break; } if(controlNames[i] == 0) { - msg_warning << "Invalid control '" << control << "' in keymap" << std::endl; + log_warning << "Invalid control '" << control << "' in keymap" << std::endl; continue; } keymap.insert(std::make_pair((SDLKey) key, (Control) i)); } else { - msg_warning << "Invalid lisp element '" << iter.item() << "' in keymap" << std::endl; + log_warning << "Invalid lisp element '" << iter.item() << "' in keymap" << std::endl; } } } @@ -189,7 +189,7 @@ JoystickKeyboardController::read(const lisp::Lisp& lisp) map->get("button", button); map->get("control", control); if(button < 0 || button >= max_joybuttons) { - msg_warning << "Invalid button '" << button << "' in buttonmap" << std::endl; + log_warning << "Invalid button '" << button << "' in buttonmap" << std::endl; continue; } @@ -199,7 +199,7 @@ JoystickKeyboardController::read(const lisp::Lisp& lisp) break; } if(controlNames[i] == 0) { - msg_warning << "Invalid control '" << control << "' in buttonmap" << std::endl; + log_warning << "Invalid control '" << control << "' in buttonmap" << std::endl; continue; } reset_joybutton(button, (Control) i); @@ -321,7 +321,7 @@ JoystickKeyboardController::process_event(const SDL_Event& event) ButtonMap::iterator i = joy_button_map.find(event.jbutton.button); if(i == joy_button_map.end()) { - msg_debug << "Unmapped joybutton " << (int)event.jbutton.button << " pressed" << std::endl; + log_debug << "Unmapped joybutton " << (int)event.jbutton.button << " pressed" << std::endl; return; } @@ -361,7 +361,7 @@ JoystickKeyboardController::process_key_event(const SDL_Event& event) // default action: update controls if(key_mapping == keymap.end()) { - msg_debug << "Key " << event.key.keysym.sym << " is unbound" << std::endl; + log_debug << "Key " << event.key.keysym.sym << " is unbound" << std::endl; return; } Control control = key_mapping->second; diff --git a/src/file_system.cpp b/src/file_system.cpp index d1303078b..0f9778356 100644 --- a/src/file_system.cpp +++ b/src/file_system.cpp @@ -1,6 +1,6 @@ #include -#include "msg.hpp" +#include "log.hpp" #include "file_system.hpp" #include @@ -56,7 +56,7 @@ std::string normalize(const std::string& filename) if(pathelem == "..") { if(path_stack.empty()) { - msg_warning << "Invalid '..' in path '" << filename << "'" << std::endl; + log_warning << "Invalid '..' in path '" << filename << "'" << std::endl; // push it into the result path so that the users sees his error... path_stack.push_back(pathelem); } else { diff --git a/src/game_session.cpp b/src/game_session.cpp index 072e233c4..8aa35aa16 100644 --- a/src/game_session.cpp +++ b/src/game_session.cpp @@ -35,7 +35,7 @@ #include #include "game_session.hpp" -#include "msg.hpp" +#include "log.hpp" #include "worldmap.hpp" #include "mainloop.hpp" #include "video/screen.hpp" @@ -342,7 +342,7 @@ bool GameSession::consoleCommand(std::string command, std::vector) { if (command == "foo") { - msg_info << "bar" << std::endl; + log_info << "bar" << std::endl; return true; } @@ -379,7 +379,7 @@ GameSession::consoleCommand(std::string command, std::vector) return true; } if (command == "whereami") { - msg_info << "You are at x " << tux.get_pos().x << ", y " << tux.get_pos().y << std::endl; + log_info << "You are at x " << tux.get_pos().x << ", y " << tux.get_pos().y << std::endl; return true; } if (command == "gotoend") { @@ -400,7 +400,7 @@ GameSession::consoleCommand(std::string command, std::vector) return true; } if (command == "camera") { - msg_info << "Camera is at " << Sector::current()->camera->get_translation().x << "," << Sector::current()->camera->get_translation().y << std::endl; + log_info << "Camera is at " << Sector::current()->camera->get_translation().x << "," << Sector::current()->camera->get_translation().y << std::endl; return true; } if (command == "quit") { @@ -501,7 +501,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); @@ -773,12 +773,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; } } diff --git a/src/level.cpp b/src/level.cpp index 30e19e62b..110b6859b 100644 --- a/src/level.cpp +++ b/src/level.cpp @@ -30,7 +30,7 @@ #include #include "video/screen.hpp" -#include "msg.hpp" +#include "log.hpp" #include "lisp/parser.hpp" #include "lisp/lisp.hpp" #include "lisp/list_iterator.hpp" @@ -80,7 +80,7 @@ Level::load(const std::string& filepath) if(token == "version") { iter.value()->get(version); if(version > 2) { - msg_warning << "level format newer than application" << std::endl; + log_warning << "level format newer than application" << std::endl; } } else if(token == "name") { iter.value()->get(name); @@ -91,7 +91,7 @@ Level::load(const std::string& filepath) sector->parse(*(iter.lisp())); add_sector(sector); } else { - msg_warning << "Unknown token '" << token << "' in level file" << std::endl; + log_warning << "Unknown token '" << token << "' in level file" << std::endl; continue; } } diff --git a/src/lisp/writer.cpp b/src/lisp/writer.cpp index 1ba15203b..13e6459b5 100644 --- a/src/lisp/writer.cpp +++ b/src/lisp/writer.cpp @@ -23,7 +23,7 @@ #include "writer.hpp" #include "physfs/physfs_stream.hpp" -#include "msg.hpp" +#include "log.hpp" namespace lisp { @@ -45,7 +45,7 @@ Writer::Writer(std::ostream* newout) Writer::~Writer() { if(lists.size() > 0) { - msg_warning << "Not all sections closed in lispwriter" << std::endl; + log_warning << "Not all sections closed in lispwriter" << std::endl; } if(out_owned) delete out; @@ -76,11 +76,11 @@ void Writer::end_list(const std::string& listname) { if(lists.size() == 0) { - msg_warning << "Trying to close list '" << listname << "', which is not open" << std::endl; + log_warning << "Trying to close list '" << listname << "', which is not open" << std::endl; return; } if(lists.back() != listname) { - msg_warning << "trying to close list '" << listname << "' while list '" << lists.back() << "' is open" << std::endl; + log_warning << "trying to close list '" << listname << "' while list '" << lists.back() << "' is open" << std::endl; return; } lists.pop_back(); diff --git a/src/log.hpp b/src/log.hpp new file mode 100644 index 000000000..c666df31e --- /dev/null +++ b/src/log.hpp @@ -0,0 +1,83 @@ +// $Id: debug.cpp 2650 2005-06-28 12:42:08Z sommer $ +// +// SuperTux Debug Helper Functions +// Copyright (C) 2006 Christoph Sommer +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// 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. +#ifndef __SUPERTUX_MSG_H__ +#define __SUPERTUX_MSG_H__ + +#include +#include + +#include "console.hpp" + +#ifdef DEBUG + +namespace { + +inline std::ostream& log_debug_f(const char* file, int line) { + Console::output << "[DEBUG] " << file << " l." << line << ": "; + return Console::output; +} + +inline std::ostream& log_info_f(const char* file, int line) { + Console::output << "[INFO] " << file << " l." << line << ": "; + return Console::output; +} + +inline std::ostream& log_warning_f(const char* file, int line) { + Console::output << "[WARNING] " << file << " l." << line << ": "; + return Console::output; +} + +inline std::ostream& log_fatal_f(const char* file, int line) { + Console::output << "[FATAL] " << file << " l." << line << ": "; + return Console::output; +} + +} + +#define log_debug log_debug_f(__FILE__, __LINE__) +#define log_info log_info_f(__FILE__, __LINE__) +#define log_warning log_warning_f(__FILE__, __LINE__) +#define log_fatal log_fatal_f(__FILE__, __LINE__) + +#else + +namespace { + +inline std::ostream& log_warning_f() { + Console::output << "Warning: "; + return Console::output; +} + +inline std::ostream& log_fatal_f() { + Console::output << "Fatal: "; + return Console::output; +} + +} + +#define log_debug if (0) std::cerr +#define log_info Console::output +#define log_warning log_warning_f() +#define log_fatal log_fatal_f() + +#endif + +#endif + diff --git a/src/main.cpp b/src/main.cpp index 969e602d5..fe54abb5c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -20,7 +20,7 @@ #include #include -#include "msg.hpp" +#include "log.hpp" #include "main.hpp" #include @@ -65,7 +65,7 @@ static void init_config() try { config->load(); } catch(std::exception& e) { - msg_info << "Couldn't load config file: " << e.what() << ", using default settings" << std::endl; + log_info << "Couldn't load config file: " << e.what() << ", using default settings" << std::endl; } } @@ -148,7 +148,7 @@ static void init_physfs(const char* argv0) if(f) { fclose(f); if(!PHYSFS_addToSearchPath(dir.c_str(), 1)) { - msg_warning << "Couldn't add '" << dir << "' to physfs searchpath: " << PHYSFS_getLastError() << std::endl; + log_warning << "Couldn't add '" << dir << "' to physfs searchpath: " << PHYSFS_getLastError() << std::endl; } else { sourcedir = true; } @@ -165,7 +165,7 @@ static void init_physfs(const char* argv0) datadir = APPDATADIR; #endif if(!PHYSFS_addToSearchPath(datadir.c_str(), 1)) { - msg_warning << "Couldn't add '" << datadir << "' to physfs searchpath: " << PHYSFS_getLastError() << std::endl; + log_warning << "Couldn't add '" << datadir << "' to physfs searchpath: " << PHYSFS_getLastError() << std::endl; } #endif } @@ -175,7 +175,7 @@ static void init_physfs(const char* argv0) //show search Path for(char** i = PHYSFS_getSearchPath(); *i != NULL; i++) - msg_info << "[" << *i << "] is in the search path" << std::endl; + log_info << "[" << *i << "] is in the search path" << std::endl; } static void print_usage(const char* argv0) @@ -237,12 +237,12 @@ static bool parse_commandline(int argc, char** argv) print_usage(argv[0]); return true; } else if(arg == "--version") { - msg_info << PACKAGE_NAME << " " << PACKAGE_VERSION << std::endl; + log_info << PACKAGE_NAME << " " << PACKAGE_VERSION << std::endl; return true; } else if(arg[0] != '-') { config->start_level = arg; } else { - msg_warning << "Unknown option '" << arg << "'. Use --help to see a list of options" << std::endl; + log_warning << "Unknown option '" << arg << "'. Use --help to see a list of options" << std::endl; } } @@ -343,7 +343,7 @@ void init_video() } #ifdef DEBUG else { - msg_warning << "Couldn't find icon 'images/engine/icons/supertux.xpm'" << std::endl; + log_warning << "Couldn't find icon 'images/engine/icons/supertux.xpm'" << std::endl; } #endif @@ -447,7 +447,7 @@ static inline void timelog(const char* component) Uint32 current_ticks = SDL_GetTicks(); if(last_timelog_component != 0) { - msg_info << "Component '" << last_timelog_component << "' finished after " << (current_ticks - last_timelog_ticks) / 1000.0 << " seconds" << std::endl; + log_info << "Component '" << last_timelog_component << "' finished after " << (current_ticks - last_timelog_ticks) / 1000.0 << " seconds" << std::endl; } last_timelog_ticks = current_ticks; @@ -480,14 +480,14 @@ int main(int argc, char** argv) init_audio(); timelog("video"); init_video(); - Console::instance = new Console(); + Console::instance = new Console(); timelog("scripting"); init_scripting(); timelog("menu"); setup_menu(); timelog("resources"); - load_shared(); + load_shared(); timelog(0); main_loop = new MainLoop(); @@ -510,10 +510,10 @@ int main(int argc, char** argv) main_loop->run(); } catch(std::exception& e) { - msg_fatal << "Unexpected exception: " << e.what() << std::endl; + log_fatal << "Unexpected exception: " << e.what() << std::endl; result = 1; } catch(...) { - msg_fatal << "Unexpected exception" << std::endl; + log_fatal << "Unexpected exception" << std::endl; result = 1; } diff --git a/src/msg.hpp b/src/msg.hpp deleted file mode 100644 index 1622636fe..000000000 --- a/src/msg.hpp +++ /dev/null @@ -1,84 +0,0 @@ -// $Id: debug.cpp 2650 2005-06-28 12:42:08Z sommer $ -// -// SuperTux Debug Helper Functions -// Copyright (C) 2006 Christoph Sommer -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// 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. - -#ifndef __SUPERTUX_MSG_H__ -#define __SUPERTUX_MSG_H__ - -#include -#include - -#include "console.hpp" - -#ifdef DEBUG - -namespace { - -inline std::ostream& msg_debug_f(const char* file, int line) { - Console::output << "[DEBUG] " << file << " l." << line << ": "; - return Console::output; -} - -inline std::ostream& msg_info_f(const char* file, int line) { - Console::output << "[INFO] " << file << " l." << line << ": "; - return Console::output; -} - -inline std::ostream& msg_warning_f(const char* file, int line) { - Console::output << "[WARNING] " << file << " l." << line << ": "; - return Console::output; -} - -inline std::ostream& msg_fatal_f(const char* file, int line) { - Console::output << "[FATAL] " << file << " l." << line << ": "; - return Console::output; -} - -} - -#define msg_debug msg_debug_f(__FILE__, __LINE__) -#define msg_info msg_info_f(__FILE__, __LINE__) -#define msg_warning msg_warning_f(__FILE__, __LINE__) -#define msg_fatal msg_fatal_f(__FILE__, __LINE__) - -#else - -namespace { - -inline std::ostream& msg_warning_f() { - Console::output << "Warning: "; - return Console::output; -} - -inline std::ostream& msg_fatal_f() { - Console::output << "Fatal: "; - return Console::output; -} - -} - -#define msg_debug if (0) std::cerr -#define msg_info Console::output -#define msg_warning msg_warning_f() -#define msg_fatal msg_fatal_f() - -#endif - -#endif - diff --git a/src/object/ambient_sound.cpp b/src/object/ambient_sound.cpp index a173d29c8..bfe03558d 100644 --- a/src/object/ambient_sound.cpp +++ b/src/object/ambient_sound.cpp @@ -28,7 +28,7 @@ #include "sector.hpp" #include "audio/sound_manager.hpp" #include "audio/sound_source.hpp" -#include "msg.hpp" +#include "log.hpp" AmbientSound::AmbientSound(const lisp::Lisp& lisp) { @@ -44,7 +44,7 @@ AmbientSound::AmbientSound(const lisp::Lisp& lisp) sample=""; if (!(lisp.get("x", position.x)&&lisp.get("y", position.y))) { - msg_warning << "No Position in ambient_sound" << std::endl; + log_warning << "No Position in ambient_sound" << std::endl; } lisp.get("width" , dimension.x); @@ -132,7 +132,7 @@ AmbientSound::start_playing() currentvolume=targetvolume=1e-20; sound_source->play(); } catch(std::exception& e) { - msg_warning << "Couldn't play '" << sample << "': " << e.what() << "" << std::endl; + log_warning << "Couldn't play '" << sample << "': " << e.what() << "" << std::endl; delete sound_source; sound_source = 0; } diff --git a/src/object/anchor_point.cpp b/src/object/anchor_point.cpp index 0173d61a9..37678fcfb 100644 --- a/src/object/anchor_point.cpp +++ b/src/object/anchor_point.cpp @@ -4,7 +4,7 @@ #include #include "anchor_point.hpp" #include "math/rect.hpp" -#include "msg.hpp" +#include "log.hpp" std::string anchor_point_to_string(AnchorPoint point) { @@ -76,7 +76,7 @@ Vector get_anchor_pos(const Rect& rect, AnchorPoint point) #ifdef DEBUG throw std::runtime_error("Invalid anchor point found"); #endif - msg_warning << "Invalid anchor point found" << std::endl; + log_warning << "Invalid anchor point found" << std::endl; result.x = rect.get_left(); break; } @@ -95,7 +95,7 @@ Vector get_anchor_pos(const Rect& rect, AnchorPoint point) #ifdef DEBUG throw std::runtime_error("Invalid anchor point found"); #endif - msg_warning << "Invalid anchor point found" << std::endl; + log_warning << "Invalid anchor point found" << std::endl; result.y = rect.get_top(); break; } @@ -122,7 +122,7 @@ Vector get_anchor_pos(const Rect& destrect, float width, float height, #ifdef DEBUG throw std::runtime_error("Invalid anchor point found"); #endif - msg_warning << "Invalid anchor point found" << std::endl; + log_warning << "Invalid anchor point found" << std::endl; result.x = destrect.get_left(); break; } @@ -141,7 +141,7 @@ Vector get_anchor_pos(const Rect& destrect, float width, float height, #ifdef DEBUG throw std::runtime_error("Invalid anchor point found"); #endif - msg_warning << "Invalid anchor point found" << std::endl; + log_warning << "Invalid anchor point found" << std::endl; result.y = destrect.get_top(); break; } diff --git a/src/object/background.cpp b/src/object/background.cpp index 02fabd176..dc94c3cc9 100644 --- a/src/object/background.cpp +++ b/src/object/background.cpp @@ -27,7 +27,7 @@ #include "object_factory.hpp" #include "resources.hpp" #include "main.hpp" -#include "msg.hpp" +#include "log.hpp" Background::Background() : layer(LAYER_BACKGROUND0) diff --git a/src/object/block.cpp b/src/object/block.cpp index 0e9fe524d..82f310488 100644 --- a/src/object/block.cpp +++ b/src/object/block.cpp @@ -20,7 +20,7 @@ #include #include "block.hpp" -#include "msg.hpp" +#include "log.hpp" #include @@ -134,7 +134,7 @@ BonusBlock::BonusBlock(const Vector& pos, int data) case 4: contents = CONTENT_1UP; break; case 5: contents = CONTENT_ICEGROW; break; default: - msg_warning << "Invalid box contents" << std::endl; + log_warning << "Invalid box contents" << std::endl; contents = CONTENT_COIN; break; } @@ -169,7 +169,7 @@ BonusBlock::BonusBlock(const lisp::Lisp& lisp) } else if(contentstring == "custom") { contents = CONTENT_CUSTOM; } else { - msg_warning << "Invalid box contents '" << contentstring << "'" << std::endl; + log_warning << "Invalid box contents '" << contentstring << "'" << std::endl; } } else { if(contents == CONTENT_CUSTOM) { @@ -179,7 +179,7 @@ BonusBlock::BonusBlock(const lisp::Lisp& lisp) throw std::runtime_error( "Only MovingObjects are allowed inside BonusBlocks"); } else { - msg_warning << "Invalid element '" << token << "' in bonusblock" << std::endl; + log_warning << "Invalid element '" << token << "' in bonusblock" << std::endl; } } } diff --git a/src/object/camera.cpp b/src/object/camera.cpp index 61d404a18..f7105cf15 100644 --- a/src/object/camera.cpp +++ b/src/object/camera.cpp @@ -34,7 +34,7 @@ #include "sector.hpp" #include "main.hpp" #include "object_factory.hpp" -#include "msg.hpp" +#include "log.hpp" #include "path.hpp" #include "path_walker.hpp" diff --git a/src/object/gradient.cpp b/src/object/gradient.cpp index 42950735c..57e530fb3 100644 --- a/src/object/gradient.cpp +++ b/src/object/gradient.cpp @@ -27,7 +27,7 @@ #include "object_factory.hpp" #include "resources.hpp" #include "main.hpp" -#include "msg.hpp" +#include "log.hpp" Gradient::Gradient() : layer(LAYER_BACKGROUND0) @@ -84,10 +84,10 @@ Gradient::set_gradient(Color top, Color bottom) if (gradient_top.red > 1.0 || gradient_top.green > 1.0 || gradient_top.blue > 1.0 || gradient_top.alpha > 1.0) - msg_warning << "top gradient color has values above 1.0" << std::endl; + log_warning << "top gradient color has values above 1.0" << std::endl; if (gradient_bottom.red > 1.0 || gradient_bottom.green > 1.0 || gradient_bottom.blue > 1.0 || gradient_bottom.alpha > 1.0) - msg_warning << "bottom gradient color has values above 1.0" << std::endl; + log_warning << "bottom gradient color has values above 1.0" << std::endl; } void diff --git a/src/object/infoblock.cpp b/src/object/infoblock.cpp index 1300bd4ff..20685d07a 100644 --- a/src/object/infoblock.cpp +++ b/src/object/infoblock.cpp @@ -27,7 +27,7 @@ #include "object_factory.hpp" #include "lisp/lisp.hpp" #include "sector.hpp" -#include "msg.hpp" +#include "log.hpp" InfoBlock::InfoBlock(const lisp::Lisp& lisp) : Block(sprite_manager->create("images/objects/bonus_block/infoblock.sprite")) @@ -38,7 +38,7 @@ InfoBlock::InfoBlock(const lisp::Lisp& lisp) bbox.set_pos(pos); if(!lisp.get("message", message)) { - msg_warning << "No message in InfoBlock" << std::endl; + log_warning << "No message in InfoBlock" << std::endl; } //stopped = false; //ringing = new AmbientSound(get_pos(), 0.5, 300, 1, "sounds/phone.wav"); diff --git a/src/object/level_time.cpp b/src/object/level_time.cpp index 30d21d5c5..f1904a80d 100644 --- a/src/object/level_time.cpp +++ b/src/object/level_time.cpp @@ -12,7 +12,7 @@ #include "object/player.hpp" #include "video/drawing_context.hpp" #include "lisp/list_iterator.hpp" -#include "msg.hpp" +#include "log.hpp" /** When to alert player they're low on time! */ static const float TIME_WARNING = 20; @@ -27,7 +27,7 @@ LevelTime::LevelTime(const lisp::Lisp& reader) iter.value()->get(time); break; } else { - msg_warning << "Unknown token '" << iter.item() << "' in LevelTime object" << std::endl; + log_warning << "Unknown token '" << iter.item() << "' in LevelTime object" << std::endl; } } if(time < 0) diff --git a/src/object/path.cpp b/src/object/path.cpp index 4ed45d056..8095ebd88 100644 --- a/src/object/path.cpp +++ b/src/object/path.cpp @@ -26,7 +26,7 @@ #include "lisp/lisp.hpp" #include "lisp/list_iterator.hpp" #include "object_factory.hpp" -#include "msg.hpp" +#include "log.hpp" #include #include @@ -68,7 +68,7 @@ Path::read(const lisp::Lisp& reader) } if(iter.item() != "node") { - msg_warning << "unknown token '" << iter.item() << "' in Path nodes list. Ignored." << std::endl; + log_warning << "unknown token '" << iter.item() << "' in Path nodes list. Ignored." << std::endl; continue; } const lisp::Lisp* node_lisp = iter.lisp(); @@ -107,7 +107,7 @@ Path::write(lisp::Writer& writer) writer.write_string("mode", "circular"); break; default: - msg_warning << "Don't know how to write mode " << (int) mode << " ?!?" << std::endl; + log_warning << "Don't know how to write mode " << (int) mode << " ?!?" << std::endl; break; } diff --git a/src/object/platform.cpp b/src/object/platform.cpp index 6ffa18210..c28db179f 100644 --- a/src/object/platform.cpp +++ b/src/object/platform.cpp @@ -22,7 +22,7 @@ #include "platform.hpp" #include -#include "msg.hpp" +#include "log.hpp" #include "video/drawing_context.hpp" #include "resources.hpp" #include "player.hpp" diff --git a/src/object/player.cpp b/src/object/player.cpp index 176981104..01167e102 100644 --- a/src/object/player.cpp +++ b/src/object/player.cpp @@ -46,7 +46,7 @@ #include "platform.hpp" #include "badguy/badguy.hpp" #include "player_status.hpp" -#include "msg.hpp" +#include "log.hpp" static const int TILES_FOR_BUTTJUMP = 3; static const float SHOOTING_TIME = .150; @@ -195,7 +195,7 @@ Player::update(float elapsed_time) if(moving_object) { moving_object->set_pos(pos); } else { - msg_debug << "Non MovingObjetc grabbed?!?" << std::endl; + log_debug << "Non MovingObjetc grabbed?!?" << std::endl; } grabbed_object->ungrab(*this, dir); grabbed_object = 0; diff --git a/src/object/powerup.cpp b/src/object/powerup.cpp index f73182231..70306034a 100644 --- a/src/object/powerup.cpp +++ b/src/object/powerup.cpp @@ -27,7 +27,7 @@ #include "audio/sound_manager.hpp" #include "object_factory.hpp" #include "sector.hpp" -#include "msg.hpp" +#include "log.hpp" PowerUp::PowerUp(const lisp::Lisp& lisp) { diff --git a/src/object/text_object.cpp b/src/object/text_object.cpp index 8608b9f05..36939124d 100644 --- a/src/object/text_object.cpp +++ b/src/object/text_object.cpp @@ -6,7 +6,7 @@ #include "resources.hpp" #include "video/drawing_context.hpp" #include "scripting/wrapper_util.hpp" -#include "msg.hpp" +#include "log.hpp" TextObject::TextObject() : fading(0), fadetime(0), visible(false) @@ -48,7 +48,7 @@ TextObject::set_font(const std::string& name) } else if(name == "small") { font = white_small_text; } else { - msg_warning << "Unknown font '" << name << "'." << std::endl; + log_warning << "Unknown font '" << name << "'." << std::endl; } } diff --git a/src/object/tilemap.cpp b/src/object/tilemap.cpp index 88ffba46a..7d5790237 100644 --- a/src/object/tilemap.cpp +++ b/src/object/tilemap.cpp @@ -34,7 +34,7 @@ #include "lisp/writer.hpp" #include "object_factory.hpp" #include "main.hpp" -#include "msg.hpp" +#include "log.hpp" TileMap::TileMap() : solid(false), speed(1), width(0), height(0), layer(LAYER_TILES), @@ -63,14 +63,14 @@ TileMap::TileMap(const lisp::Lisp& reader, TileManager* new_tile_manager) else if(layer_str == "foreground") layer = LAYER_FOREGROUNDTILES; else - msg_warning << "Unknown layer '" << layer_str << "' in tilemap" << std::endl; + log_warning << "Unknown layer '" << layer_str << "' in tilemap" << std::endl; } reader.get("solid", solid); reader.get("speed", speed); if(solid && speed != 1) { - msg_warning << "Speed of solid tilemap is not 1. fixing" << std::endl; + log_warning << "Speed of solid tilemap is not 1. fixing" << std::endl; speed = 1; } if(solid) @@ -122,7 +122,7 @@ TileMap::write(lisp::Writer& writer) writer.write_string("layer", "foreground"); else { writer.write_string("layer", "unknown"); - msg_warning << "unknown layer in tilemap" << std::endl; + log_warning << "unknown layer in tilemap" << std::endl; } writer.write_bool("solid", solid); @@ -254,7 +254,7 @@ const Tile* TileMap::get_tile(int x, int y) const { if(x < 0 || x >= width || y < 0 || y >= height) { - //msg_warning << "tile outside tilemap requested" << std::endl; + //log_warning << "tile outside tilemap requested" << std::endl; return tilemanager->get(0); } diff --git a/src/physfs/physfs_sdl.cpp b/src/physfs/physfs_sdl.cpp index 0afcda8f2..d52da6332 100644 --- a/src/physfs/physfs_sdl.cpp +++ b/src/physfs/physfs_sdl.cpp @@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include #include -#include "msg.hpp" +#include "log.hpp" static int funcSeek(struct SDL_RWops* context, int offset, int whence) { @@ -48,7 +48,7 @@ static int funcSeek(struct SDL_RWops* context, int offset, int whence) break; } if(res == 0) { - msg_warning << "Error seeking in file: " << PHYSFS_getLastError() << std::endl; + log_warning << "Error seeking in file: " << PHYSFS_getLastError() << std::endl; return -1; } diff --git a/src/player_status.cpp b/src/player_status.cpp index 6c9d97ba5..414a24dbf 100644 --- a/src/player_status.cpp +++ b/src/player_status.cpp @@ -28,7 +28,7 @@ #include "sprite/sprite_manager.hpp" #include "math/vector.hpp" #include "main.hpp" -#include "msg.hpp" +#include "log.hpp" static const int START_COINS = 100; static const int MAX_COINS = 99999; @@ -113,7 +113,7 @@ PlayerStatus::write(lisp::Writer& writer) writer.write_string("bonus", "iceflower"); break; default: - msg_warning << "Unknown bonus type." << std::endl; + log_warning << "Unknown bonus type." << std::endl; writer.write_string("bonus", "none"); } writer.write_bool("key-brass", keys & KEY_BRASS); @@ -142,7 +142,7 @@ PlayerStatus::read(const lisp::Lisp& lisp) } else if(bonusname == "iceflower") { bonus = ICE_BONUS; } else { - msg_warning << "Unknown bonus '" << bonusname << "' in savefile" << std::endl; + log_warning << "Unknown bonus '" << bonusname << "' in savefile" << std::endl; bonus = NO_BONUS; } } @@ -214,7 +214,7 @@ PlayerStatus::consoleCommand(std::string command, std::vector argum { if (command == "coins") { if ((arguments.size() < 1) || (!Console::string_is(arguments[0]))) { - msg_info << "Usage: coins " << std::endl; + log_info << "Usage: coins " << std::endl; } else { coins = Console::string_to(arguments[0]); } diff --git a/src/scripting/camera.cpp b/src/scripting/camera.cpp index 93b910437..5ac73dc9d 100644 --- a/src/scripting/camera.cpp +++ b/src/scripting/camera.cpp @@ -6,7 +6,7 @@ #include "scripting/camera.hpp" #include "math/vector.hpp" -#define NOIMPL msg_fatal << __PRETTY_FUNCTION__ << " not implemented." +#define NOIMPL log_fatal << __PRETTY_FUNCTION__ << " not implemented." namespace Scripting { @@ -37,7 +37,7 @@ namespace Scripting } else if(mode == "manual") { camera->mode = ::Camera::MANUAL; } else { - msg_fatal << "Camera mode '" << mode << "' unknown."; + log_fatal << "Camera mode '" << mode << "' unknown."; } } diff --git a/src/scripting/functions.cpp b/src/scripting/functions.cpp index 41e4f0d58..4856d36c1 100644 --- a/src/scripting/functions.cpp +++ b/src/scripting/functions.cpp @@ -32,7 +32,7 @@ #include "script_manager.hpp" #include "resources.hpp" #include "gettext.hpp" -#include "msg.hpp" +#include "log.hpp" #include "mainloop.hpp" #include "worldmap.hpp" #include "world.hpp" diff --git a/src/sector.cpp b/src/sector.cpp index e39227073..063e56b83 100644 --- a/src/sector.cpp +++ b/src/sector.cpp @@ -63,7 +63,7 @@ #include "script_manager.hpp" #include "scripting/wrapper_util.hpp" #include "script_interface.hpp" -#include "msg.hpp" +#include "log.hpp" Sector* Sector::_current = 0; @@ -151,7 +151,7 @@ Sector::parse_object(const std::string& name, const lisp::Lisp& reader) try { return create_object(name, reader); } catch(std::exception& e) { - msg_warning << e.what() << "" << std::endl; + log_warning << e.what() << "" << std::endl; } return 0; @@ -189,7 +189,7 @@ Sector::parse(const lisp::Lisp& sector) fix_old_tiles(); if(!camera) { - msg_warning << "sector '" << name << "' does not contain a camera." << std::endl; + log_warning << "sector '" << name << "' does not contain a camera." << std::endl; update_game_objects(); add_object(new Camera(this)); } @@ -297,7 +297,7 @@ Sector::parse_old_format(const lisp::Lisp& reader) spawnpoints.push_back(sp); } } else { - msg_warning << "Unknown token '" << iter.item() << "' in reset-points." << std::endl; + log_warning << "Unknown token '" << iter.item() << "' in reset-points." << std::endl; } } } @@ -311,7 +311,7 @@ Sector::parse_old_format(const lisp::Lisp& reader) if(object) { add_object(object); } else { - msg_warning << "Unknown object '" << iter.item() << "' in level." << std::endl; + log_warning << "Unknown object '" << iter.item() << "' in level." << std::endl; } } } @@ -435,7 +435,7 @@ Sector::activate(const std::string& spawnpoint) } } if(!sp) { - msg_warning << "Spawnpoint '" << spawnpoint << "' not found." << std::endl; + log_warning << "Spawnpoint '" << spawnpoint << "' not found." << std::endl; if(spawnpoint != "main") { activate("main"); } else { @@ -622,14 +622,14 @@ Sector::before_object_add(GameObject* object) if(solids == 0) { solids = tilemap; } else { - msg_warning << "Another solid tilemaps added. Ignoring" << std::endl; + log_warning << "Another solid tilemaps added. Ignoring" << std::endl; } } Camera* camera = dynamic_cast (object); if(camera) { if(this->camera != 0) { - msg_warning << "Multiple cameras added. Ignoring" << std::endl; + log_warning << "Multiple cameras added. Ignoring" << std::endl; return false; } this->camera = camera; @@ -638,7 +638,7 @@ Sector::before_object_add(GameObject* object) Player* player = dynamic_cast (object); if(player) { if(this->player != 0) { - msg_warning << "Multiple players added. Ignoring" << std::endl; + log_warning << "Multiple players added. Ignoring" << std::endl; return false; } this->player = player; @@ -681,7 +681,7 @@ Sector::try_unexpose(GameObject* object) try { interface->unexpose(vm, -1); } catch(std::exception& e) { - msg_warning << "Couldn't unregister object: " << e.what() << std::endl; + log_warning << "Couldn't unregister object: " << e.what() << std::endl; } sq_settop(vm, oldtop); } diff --git a/src/spawn_point.cpp b/src/spawn_point.cpp index 7ed3a15aa..7f27dc257 100644 --- a/src/spawn_point.cpp +++ b/src/spawn_point.cpp @@ -5,7 +5,7 @@ #include "spawn_point.hpp" #include "lisp/lisp.hpp" #include "lisp/list_iterator.hpp" -#include "msg.hpp" +#include "log.hpp" SpawnPoint::SpawnPoint() {} @@ -28,7 +28,7 @@ SpawnPoint::SpawnPoint(const lisp::Lisp* slisp) } else if(token == "y") { iter.value()->get(pos.y); } else { - msg_warning << "unknown token '" << token << "' in SpawnPoint" << std::endl; + log_warning << "unknown token '" << token << "' in SpawnPoint" << std::endl; } } diff --git a/src/sprite/sprite.cpp b/src/sprite/sprite.cpp index 189f60ef9..a59cfcfec 100644 --- a/src/sprite/sprite.cpp +++ b/src/sprite/sprite.cpp @@ -25,7 +25,7 @@ #include "sprite.hpp" #include "video/drawing_context.hpp" -#include "msg.hpp" +#include "log.hpp" Sprite::Sprite(SpriteData& newdata) : data(newdata), frame(0), animation_loops(-1) @@ -56,7 +56,7 @@ Sprite::set_action(const std::string& name, int loops) SpriteData::Action* newaction = data.get_action(name); if(!newaction) { - msg_debug << "Action '" << name << "' not found." << std::endl; + log_debug << "Action '" << name << "' not found." << std::endl; return; } @@ -99,7 +99,7 @@ Sprite::draw(DrawingContext& context, const Vector& pos, int layer) update(); if((int)frame >= get_frames() || (int)frame < 0) - msg_warning << "frame out of range: " << (int)frame << "/" << get_frames() << " at " << get_name() << "/" << get_action_name() << std::endl; + log_warning << "frame out of range: " << (int)frame << "/" << get_frames() << " at " << get_name() << "/" << get_action_name() << std::endl; else context.draw_surface(action->surfaces[(int)frame], pos - Vector(action->x_offset, action->y_offset), @@ -114,7 +114,7 @@ Sprite::draw_part(DrawingContext& context, const Vector& source, update(); if((int)frame >= get_frames() || (int)frame < 0) - msg_warning << "frame out of range: " << (int)frame << "/" << get_frames() << " at sprite: " << get_name() << "/" << get_action_name() << std::endl; + log_warning << "frame out of range: " << (int)frame << "/" << get_frames() << " at sprite: " << get_name() << "/" << get_action_name() << std::endl; else context.draw_surface_part(action->surfaces[(int)frame], source, size, pos - Vector(action->x_offset, action->y_offset), diff --git a/src/sprite/sprite_data.cpp b/src/sprite/sprite_data.cpp index 6a40a6bd8..470bfc71e 100644 --- a/src/sprite/sprite_data.cpp +++ b/src/sprite/sprite_data.cpp @@ -27,7 +27,7 @@ #include "resources.hpp" #include "video/drawing_context.hpp" #include "lisp/list_iterator.hpp" -#include "msg.hpp" +#include "log.hpp" SpriteData::Action::Action() { @@ -53,7 +53,7 @@ SpriteData::SpriteData(const lisp::Lisp* lisp, const std::string& basedir) } else if(iter.item() == "action") { parse_action(iter.lisp(), basedir); } else { - msg_warning << "Unknown sprite field: " << iter.item() << std::endl; + log_warning << "Unknown sprite field: " << iter.item() << std::endl; } } if(actions.empty()) diff --git a/src/sprite/sprite_manager.cpp b/src/sprite/sprite_manager.cpp index 71e9d3f58..d1bb1c7fb 100644 --- a/src/sprite/sprite_manager.cpp +++ b/src/sprite/sprite_manager.cpp @@ -29,7 +29,7 @@ #include "lisp/parser.hpp" #include "lisp/list_iterator.hpp" #include "file_system.hpp" -#include "msg.hpp" +#include "log.hpp" SpriteManager::SpriteManager() { diff --git a/src/textscroller.cpp b/src/textscroller.cpp index 5b05d2aca..2c7139df5 100644 --- a/src/textscroller.cpp +++ b/src/textscroller.cpp @@ -22,7 +22,7 @@ #include "textscroller.hpp" #include -#include "msg.hpp" +#include "log.hpp" #include "mainloop.hpp" #include "resources.hpp" #include "video/font.hpp" @@ -175,7 +175,7 @@ TextScroller::draw(DrawingContext& context) break; } default: - msg_warning << "text contains an unformated line" << std::endl; + log_warning << "text contains an unformated line" << std::endl; font = white_text; center = false; break; @@ -230,7 +230,7 @@ InfoBox::InfoBox(const std::string& text) } catch (std::exception& e) { - msg_warning << "Could not load scrolling images: " << e.what() << std::endl; + log_warning << "Could not load scrolling images: " << e.what() << std::endl; arrow_scrollup = 0; arrow_scrolldown = 0; } @@ -288,7 +288,7 @@ InfoBox::draw(DrawingContext& context) break; } default: - msg_warning << "text contains an unformatted line" << std::endl; + log_warning << "text contains an unformatted line" << std::endl; font = normal_font; center = false; break; diff --git a/src/tile.cpp b/src/tile.cpp index f2d77ddae..cf3e13c29 100644 --- a/src/tile.cpp +++ b/src/tile.cpp @@ -30,7 +30,7 @@ #include "timer.hpp" #include "math/vector.hpp" #include "video/drawing_context.hpp" -#include "msg.hpp" +#include "log.hpp" Tile::Tile() @@ -127,7 +127,7 @@ Tile::parse_images(const lisp::Lisp& images_lisp) ptr->get_car()->get(h); imagespecs.push_back(ImageSpec(file, Rect(x, y, x+w, y+h))); } else { - msg_warning << "Expected string or list in images tag" << std::endl; + log_warning << "Expected string or list in images tag" << std::endl; continue; } diff --git a/src/tile_manager.cpp b/src/tile_manager.cpp index c551acd75..5da2fe77f 100644 --- a/src/tile_manager.cpp +++ b/src/tile_manager.cpp @@ -26,7 +26,7 @@ #include #include #include "video/drawing_context.hpp" -#include "msg.hpp" +#include "log.hpp" #include "lisp/lisp.hpp" #include "lisp/parser.hpp" #include "lisp/list_iterator.hpp" @@ -41,7 +41,7 @@ TileManager::TileManager(const std::string& filename) #endif load_tileset(filename); #ifdef DEBUG - msg_debug << "Tiles loaded in " << (SDL_GetTicks() - ticks) / 1000.0 << " seconds" << std::endl; + log_debug << "Tiles loaded in " << (SDL_GetTicks() - ticks) / 1000.0 << " seconds" << std::endl; #endif } @@ -81,7 +81,7 @@ void TileManager::load_tileset(std::string filename) tiles.push_back(0); } if(tiles[tile->id] != 0) { - msg_warning << "Tile with ID " << tile->id << " redefined" << std::endl; + log_warning << "Tile with ID " << tile->id << " redefined" << std::endl; } tiles[tile->id] = tile; } else if(iter.item() == "tilegroup") { @@ -138,7 +138,7 @@ void TileManager::load_tileset(std::string filename) } else if(iter.item() == "properties") { // deprecated } else { - msg_warning << "Unknown symbol '" << iter.item() << "' tile defintion file" << std::endl; + log_warning << "Unknown symbol '" << iter.item() << "' tile defintion file" << std::endl; } } } diff --git a/src/tile_manager.hpp b/src/tile_manager.hpp index 5cd6fc2dc..114019390 100644 --- a/src/tile_manager.hpp +++ b/src/tile_manager.hpp @@ -28,7 +28,7 @@ #include #include #include -#include "msg.hpp" +#include "log.hpp" #include "tile.hpp" struct TileGroup @@ -70,7 +70,7 @@ public: assert(id < tiles.size()); Tile* tile = tiles[id]; if(!tile) { - msg_warning << "Invalid tile: " << id << std::endl; + log_warning << "Invalid tile: " << id << std::endl; return tiles[0]; } diff --git a/src/tinygettext/tinygettext.cpp b/src/tinygettext/tinygettext.cpp index 424e97c07..0d3ec237b 100644 --- a/src/tinygettext/tinygettext.cpp +++ b/src/tinygettext/tinygettext.cpp @@ -26,9 +26,9 @@ #include #include "tinygettext.hpp" -#include "msg.hpp" +#include "log.hpp" #include "physfs/physfs_stream.hpp" -#include "msg.hpp" +#include "log.hpp" //#define TRANSLATION_DEBUG @@ -60,8 +60,8 @@ std::string convert(const std::string& text, out_len -= out_len_temp; // see above if (retval == (size_t) -1) { - msg_warning << strerror(errno) << std::endl; - msg_warning << "Error: conversion from " << from_charset << " to " << to_charset << " went wrong: " << retval << std::endl; + log_warning << strerror(errno) << std::endl; + log_warning << "Error: conversion from " << from_charset << " to " << to_charset << " went wrong: " << retval << std::endl; return ""; } iconv_close(cd); @@ -237,7 +237,7 @@ DictionaryManager::get_dictionary(const std::string& spec) } else // Dictionary for languages lang isn't loaded, so we load it { - //msg_debug << "get_dictionary: " << lang << std::endl; + //log_debug << "get_dictionary: " << lang << std::endl; Dictionary& dict = dictionaries[lang]; dict.set_language(get_language_def(lang)); @@ -249,7 +249,7 @@ DictionaryManager::get_dictionary(const std::string& spec) char** files = PHYSFS_enumerateFiles(p->c_str()); if(!files) { - msg_warning << "Error: enumerateFiles() failed on " << *p << std::endl; + log_warning << "Error: enumerateFiles() failed on " << *p << std::endl; } else { @@ -261,8 +261,8 @@ DictionaryManager::get_dictionary(const std::string& spec) IFileStream in(pofile); read_po_file(dict, in); } catch(std::exception& e) { - msg_warning << "Error: Failure file opening: " << pofile << std::endl; - msg_warning << e.what() << "" << std::endl; + log_warning << "Error: Failure file opening: " << pofile << std::endl; + log_warning << e.what() << "" << std::endl; } } } @@ -284,7 +284,7 @@ DictionaryManager::get_languages() char** files = PHYSFS_enumerateFiles(p->c_str()); if (!files) { - msg_warning << "Error: opendir() failed on " << *p << std::endl; + log_warning << "Error: opendir() failed on " << *p << std::endl; } else { @@ -405,10 +405,10 @@ Dictionary::translate(const std::string& msgid, const std::string& msgid2, int n else { #ifdef TRANSLATION_DEBUG - msg_warning << "Couldn't translate: " << msgid << std::endl; - msg_warning << "Candidates: " << std::endl; + log_warning << "Couldn't translate: " << msgid << std::endl; + log_warning << "Candidates: " << std::endl; for (PluralEntries::iterator i = plural_entries.begin(); i != plural_entries.end(); ++i) - msg_debug << "'" << i->first << "'" << std::endl; + log_debug << "'" << i->first << "'" << std::endl; #endif if (plural2_1(num)) // default to english rules @@ -429,7 +429,7 @@ Dictionary::translate(const char* msgid) else { #ifdef TRANSLATION_DBEUG - msg_warning << "Couldn't translate: " << msgid << std::endl; + log_warning << "Couldn't translate: " << msgid << std::endl; #endif return msgid; } @@ -446,7 +446,7 @@ Dictionary::translate(const std::string& msgid) else { #ifdef TRANSLATION_DBEUG - msg_warning << "Couldn't translate: " << msgid << std::endl; + log_warning << "Couldn't translate: " << msgid << std::endl; #endif return msgid; } @@ -530,7 +530,7 @@ public: if (from_charset.empty() || from_charset == "CHARSET") { - msg_warning << "Error: Charset not specified for .po, fallback to ISO-8859-1" << std::endl; + log_warning << "Error: Charset not specified for .po, fallback to ISO-8859-1" << std::endl; from_charset = "ISO-8859-1"; } @@ -554,11 +554,11 @@ public: } else if (token.keyword.empty()) { - //msg_warning << "Got EOF, everything looks ok." << std::endl; + //log_warning << "Got EOF, everything looks ok." << std::endl; } else { - msg_warning << "tinygettext: expected 'msgid' keyword, got " << token.keyword << " at line " << line_num << std::endl; + log_warning << "tinygettext: expected 'msgid' keyword, got " << token.keyword << " at line " << line_num << std::endl; } break; @@ -590,7 +590,7 @@ public: } else { - msg_warning << "tinygettext: expected 'msgstr' keyword, got " << token.keyword << " at line " << line_num << std::endl; + log_warning << "tinygettext: expected 'msgstr' keyword, got " << token.keyword << " at line " << line_num << std::endl; } break; @@ -600,7 +600,7 @@ public: int num; if (sscanf(token.keyword.c_str(), "msgstr[%d]", &num) != 1) { - msg_warning << "Error: Couldn't parse: " << token.keyword << std::endl; + log_warning << "Error: Couldn't parse: " << token.keyword << std::endl; } else { @@ -639,7 +639,7 @@ public: while((c = getchar(in)) != EOF) { - //msg_debug << "Lexing char: " << char(c) << " " << state << std::endl; + //log_debug << "Lexing char: " << char(c) << " " << state << std::endl; switch(state) { case READ_KEYWORD: @@ -690,12 +690,12 @@ public: else if (c == '"') token.content += '"'; else { - msg_warning << "Unhandled escape character: " << char(c) << std::endl; + log_warning << "Unhandled escape character: " << char(c) << std::endl; } } else { - msg_warning << "Unterminated string" << std::endl; + log_warning << "Unterminated string" << std::endl; } } else if (c == '"') { // Content string is terminated state = READ_CONTENT; diff --git a/src/title.cpp b/src/title.cpp index 7dca58137..b647423d9 100644 --- a/src/title.cpp +++ b/src/title.cpp @@ -61,7 +61,7 @@ #include "control/joystickkeyboardcontroller.hpp" #include "control/codecontroller.hpp" #include "main.hpp" -#include "msg.hpp" +#include "log.hpp" #include "console.hpp" void @@ -120,7 +120,7 @@ TitleScreen::generate_contrib_menu() contrib_worlds.push_back(world.release()); } catch(std::exception& e) { #ifdef DEBUG - msg_warning << "Couldn't parse levelset info for '" << *it << "': " << e.what() << std::endl; + log_warning << "Couldn't parse levelset info for '" << *it << "': " << e.what() << std::endl; #endif } } @@ -144,7 +144,7 @@ TitleScreen::get_level_name(const std::string& filename) level->get("name", name); return name; } catch(std::exception& e) { - msg_warning << "Problem getting name of '" << filename << "'." << std::endl; + log_warning << "Problem getting name of '" << filename << "'." << std::endl; return ""; } } @@ -357,7 +357,7 @@ TitleScreen::update(float elapsed_time) if(confirm_dialog(bkg_title, str.c_str())) { str = "save/slot" + stream.str() + ".stsg"; - msg_debug << "Removing: " << str << std::endl; + log_debug << "Removing: " << str << std::endl; PHYSFS_delete(str.c_str()); } @@ -436,7 +436,7 @@ TitleScreen::process_load_game_menu() current_world->set_savegame_filename(slotfile); current_world->run(); } catch(std::exception& e) { - msg_fatal << "Couldn't start world: " << e.what() << std::endl; + log_fatal << "Couldn't start world: " << e.what() << std::endl; } return true; diff --git a/src/video/color.hpp b/src/video/color.hpp index aca0d9331..1cc32eba2 100644 --- a/src/video/color.hpp +++ b/src/video/color.hpp @@ -1,8 +1,27 @@ +// $Id: main.cpp 3314 2006-04-12 12:36:29Z matzebraun $ +// +// SuperTux +// Copyright (C) 2005 Matthias Braun +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// 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. #ifndef __COLOR_HPP__ #define __COLOR_HPP__ #include -#include "msg.hpp" +#include "log.hpp" class Color { @@ -36,7 +55,7 @@ public: if(red < 0 || red > 1.0 || green < 0 || green > 1.0 || blue < 0 || blue > 1.0 || alpha < 0 || alpha > 1.0) - msg_warning << "color value out of range: " << red << ", " << green << ", " << blue << ", " << alpha << std::endl; + log_warning << "color value out of range: " << red << ", " << green << ", " << blue << ", " << alpha << std::endl; } float red, green, blue, alpha; diff --git a/src/video/font.cpp b/src/video/font.cpp index f007dabfa..30786e0e2 100644 --- a/src/video/font.cpp +++ b/src/video/font.cpp @@ -28,7 +28,7 @@ #include "screen.hpp" #include "font.hpp" #include "drawing_context.hpp" -#include "msg.hpp" +#include "log.hpp" Font::Font(const std::string& file, const std::string& shadowfile, int w, int h, int shadowsize) @@ -214,13 +214,13 @@ Font::draw_chars(Surface* pchars, const std::string& text, const Vector& pos, if(c >= 0x80) { font_index -= 32; if(c <= 0xa0) { - msg_debug << "Unsupported utf-8 character '" << c << "' found" << std::endl; + log_debug << "Unsupported utf-8 character '" << c << "' found" << std::endl; font_index = 0; } } if(font_index < 0 || font_index >= (ssize_t) char_count) { - msg_debug << "Unsupported utf-8 character found" << std::endl; + log_debug << "Unsupported utf-8 character found" << std::endl; font_index = 0; } diff --git a/src/video/texture_manager.cpp b/src/video/texture_manager.cpp index 255efba48..9ecba978e 100644 --- a/src/video/texture_manager.cpp +++ b/src/video/texture_manager.cpp @@ -14,7 +14,7 @@ #include "image_texture.hpp" #include "glutil.hpp" #include "file_system.hpp" -#include "msg.hpp" +#include "log.hpp" TextureManager* texture_manager = NULL; @@ -28,7 +28,7 @@ TextureManager::~TextureManager() i != image_textures.end(); ++i) { if(i->second == NULL) continue; - msg_warning << "Texture '" << i->first << "' not freed" << std::endl; + log_warning << "Texture '" << i->first << "' not freed" << std::endl; delete i->second; } } diff --git a/src/world.cpp b/src/world.cpp index 1c66ab441..b2bd524c7 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -31,7 +31,7 @@ #include "script_manager.hpp" #include "scripting/wrapper_util.hpp" #include "scripting/serialize.hpp" -#include "msg.hpp" +#include "log.hpp" #include "worldmap.hpp" #include "mainloop.hpp" @@ -108,7 +108,7 @@ World::load(const std::string& filename) std::string path = basedir + "/"; char** files = PHYSFS_enumerateFiles(path.c_str()); if(!files) { - msg_warning << "Couldn't read subset dir '" << path << "'" << std::endl; + log_warning << "Couldn't read subset dir '" << path << "'" << std::endl; return; } @@ -225,7 +225,7 @@ World::load_state() throw std::runtime_error("Couldn't create state table"); sq_pop(vm, 1); } catch(std::exception& e) { - msg_debug << "Couldn't load savegame: " << e.what() << std::endl; + log_debug << "Couldn't load savegame: " << e.what() << std::endl; } } diff --git a/src/worldmap.cpp b/src/worldmap.cpp index 25274b0a7..ad17b0100 100644 --- a/src/worldmap.cpp +++ b/src/worldmap.cpp @@ -31,7 +31,7 @@ #include "worldmap.hpp" #include "gettext.hpp" -#include "msg.hpp" +#include "log.hpp" #include "mainloop.hpp" #include "video/surface.hpp" #include "video/screen.hpp" @@ -47,7 +47,7 @@ #include "worldmap.hpp" #include "resources.hpp" #include "misc.hpp" -#include "msg.hpp" +#include "log.hpp" #include "world.hpp" #include "player_status.hpp" #include "textscroller.hpp" @@ -154,7 +154,7 @@ Tux::draw(DrawingContext& context) tux_sprite->set_action(moving ? "small-walking" : "small-stop"); break; default: - msg_debug << "Bonus type not handled in worldmap." << std::endl; + log_debug << "Bonus type not handled in worldmap." << std::endl; tux_sprite->set_action("large-stop"); break; } @@ -299,7 +299,7 @@ Tux::tryContinueWalking(float elapsed_time) if (dir == D_NONE) { // Should never be reached if tiledata is good - msg_warning << "Could not determine where to walk next" << std::endl; + log_warning << "Could not determine where to walk next" << std::endl; stop(); return; } @@ -319,7 +319,7 @@ Tux::tryContinueWalking(float elapsed_time) } else { - msg_warning << "Tilemap data is buggy" << std::endl; + log_warning << "Tilemap data is buggy" << std::endl; stop(); } } @@ -450,7 +450,7 @@ WorldMap::load_map() } else if(iter.item() == "name") { // skip } else { - msg_warning << "Unknown token '" << iter.item() << "' in worldmap" << std::endl; + log_warning << "Unknown token '" << iter.item() << "' in worldmap" << std::endl; } } if(solids == 0) @@ -553,7 +553,7 @@ WorldMap::parse_level_tile(const lisp::Lisp* level_lisp) // Do we want to bail out instead...? We might get messages from modders // who can't make their levels run because they're too dumb to watch // their terminals... - msg_warning << "level file '" << level.name << "' does not exist and will not be added to the worldmap" << std::endl; + log_warning << "level file '" << level.name << "' does not exist and will not be added to the worldmap" << std::endl; return; } @@ -585,7 +585,7 @@ WorldMap::get_level_title(Level& level) level_lisp->get("name", level.title); } catch(std::exception& e) { - msg_warning << "Problem when reading leveltitle: " << e.what() << std::endl; + log_warning << "Problem when reading leveltitle: " << e.what() << std::endl; return; } } @@ -726,7 +726,7 @@ WorldMap::finished_level(const std::string& filename) interpreter->run_script(in, "level-extro-script"); add_object(interpreter.release()); } catch(std::exception& e) { - msg_fatal << "Couldn't run level-extro-script:" << e.what() << std::endl; + log_fatal << "Couldn't run level-extro-script:" << e.what() << std::endl; } */ } @@ -824,7 +824,7 @@ WorldMap::update(float delta) /* Check level action */ Level* level = at_level(); if (!level) { - msg_warning << "No level to enter at: " << tux->get_tile_pos().x << ", " << tux->get_tile_pos().y << std::endl; + log_warning << "No level to enter at: " << tux->get_tile_pos().x << ", " << tux->get_tile_pos().y << std::endl; return; } @@ -839,7 +839,7 @@ WorldMap::update(float delta) ST_GL_LOAD_LEVEL_FILE, &level->statistics); main_loop->push_screen(session); } catch(std::exception& e) { - msg_fatal << "Couldn't load level: " << e.what() << std::endl; + log_fatal << "Couldn't load level: " << e.what() << std::endl; } } } @@ -1196,7 +1196,7 @@ WorldMap::load_state() sq_pop(vm, 1); } catch(std::exception& e) { - msg_debug << "Not loading worldmap state: " << e.what() << std::endl; + log_debug << "Not loading worldmap state: " << e.what() << std::endl; } sq_settop(vm, oldtop); }