#include <physfs.h>
#include <vorbis/codec.h>
#include <vorbis/vorbisfile.h>
+#include "msg.hpp"
class WavSoundFile : public SoundFile
{
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) {
- printf("MAGIC: %4s.\n", magic);
+ msg_debug("MAGIC: " << magic);
throw std::runtime_error("file is not a RIFF wav file");
}
#include "sound_file.hpp"
#include "sound_source.hpp"
#include "stream_sound_source.hpp"
+#include "msg.hpp"
SoundManager* sound_manager = 0;
} catch(std::exception& e) {
device = 0;
context = 0;
- std::cerr << "Couldn't initialize audio device:" << e.what() << "\n";
+ msg_warning("Couldn't initialize audio device:" << e.what());
print_openal_version();
}
}
source->play();
sources.push_back(source);
} catch(std::exception& e) {
- std::cout << "Couldn't play sound " << filename << ": " << e.what() << "\n";
+ msg_warning("Couldn't play sound " << filename << ": " << e.what());
}
}
delete music_source;
music_source = newmusic.release();
} catch(std::exception& e) {
- std::cerr << "Couldn't play music file '" << filename << "': "
- << e.what() << "\n";
+ msg_warning("Couldn't play music file '" << filename << "': "
+ << e.what());
}
}
void
SoundManager::print_openal_version()
{
- std::cout << "OpenAL Vendor: " << alGetString(AL_VENDOR) << "\n"
- << "OpenAL Version: " << alGetString(AL_VERSION) << "\n"
- << "OpenAL Renderer: " << alGetString(AL_RENDERER) << "\n"
- << "OpenAl Extensions: " << alGetString(AL_EXTENSIONS) << "\n";
+ msg_info("OpenAL Vendor: " << alGetString(AL_VENDOR));
+ msg_info("OpenAL Version: " << alGetString(AL_VERSION));
+ msg_info("OpenAL Renderer: " << alGetString(AL_RENDERER));
+ msg_info("OpenAl Extensions: " << alGetString(AL_EXTENSIONS));
}
void
#include "stream_sound_source.hpp"
#include "sound_manager.hpp"
#include "sound_file.hpp"
+#include "msg.hpp"
StreamSoundSource::StreamSoundSource()
: file(0), fade_state(NoFading), looping(false)
return;
// we might have to restart the source if we had a buffer underrun
- std::cerr << "Restarting audio source because of buffer underrun.\n";
+ msg_info("Restarting audio source because of buffer underrun");
play();
}
#include "tile.hpp"
#include "statistics.hpp"
#include "game_session.hpp"
+#include "msg.hpp"
static const float SQUISH_TIME = 2;
static const float X_OFFSCREEN_DISTANCE = 1600;
void
BadGuy::save(lisp::Writer& )
{
- std::cout << "Warning: tried to write out a generic badguy." << std::endl;
+ msg_warning("tried to write out a generic badguy");
}
void
#include <config.h>
#include "flame.hpp"
+#include "msg.hpp"
Flame::Flame(const lisp::Lisp& reader)
: angle(0), radius(100), speed(2), source(0)
delete source;
source = sound_manager->create_sound_source("sounds/flame.wav");
if(!source) {
- std::cerr << "Couldn't start flame sound.\n";
+ msg_warning("Couldn't start flame sound");
return;
}
source->set_position(get_pos());
#include <iostream>
#include "collision_grid.hpp"
+#include "msg.hpp"
#include "collision.hpp"
#include "sector.hpp"
#include "collision_grid_iterator.hpp"
int gridy = int(y / cell_height);
if(gridx < 0 || gridy < 0
|| gridx >= int(cells_x) || gridy >= int(cells_y)) {
- std::cerr << "Object out of range: " << gridx << ", " << gridy << "\n";
+ msg_warning("Object out of range: " << gridx << ", " << gridy);
continue;
}
GridEntry* entry = new GridEntry;
assert(wrapper != 0);
#else
if(wrapper == 0) {
- std::cerr << "Tried to remove nonexistant object!\n";
+ msg_warning("Tried to remove nonexistant object");
return;
}
#endif
int gridy = int(y / cell_height);
if(gridx < 0 || gridy < 0
|| gridx >= int(cells_x) || gridy >= int(cells_y)) {
- std::cerr << "Object out of range: " << gridx << ", " << gridy << "\n";
+ msg_warning("Object out of range: " << gridx << ", " << gridy);
continue;
}
remove_object_from_gridcell(gridy*cells_x + gridx, wrapper);
int gridy = int(y / cell_height);
if(gridx < 0 || gridy < 0 ||
gridx >= int(cells_x) || gridy >= int(cells_y)) {
- std::cerr << "Object out of range: " << gridx << ", " << gridy << "\n";
+ msg_warning("Object out of range: " << gridx << ", " << gridy);
continue;
}
remove_object_from_gridcell(gridy*cells_x + gridx, wrapper);
int gridy = int(y / cell_height);
if(gridx < 0 || gridy < 0
|| gridx >= int(cells_x) || gridy >= int(cells_y)) {
- std::cerr << "Object out of range: " << gridx << ", " << gridy << "\n";
+ msg_warning("Object out of range: " << gridx << ", " << gridy);
continue;
}
int gridy = int(y / cell_height);
if(gridx < 0 || gridy < 0
|| gridx >= int(cells_x) || gridy >= int(cells_y)) {
- //std::cerr << "Object out of range: " << gridx << ", " << gridy << "\n";
+ //msg_warning("Object out of range: " << gridx << ", " << gridy);
continue;
}
entry = entry->next;
};
- std::cerr << "Couldn't find object in cell.\n";
+ msg_warning("Couldn't find object in cell");
}
#define __COLLISION_GRID_ITERATOR_H__
#include "math/rect.hpp"
+#include "msg.hpp"
class CollisionGrid;
entry = 0;
if(start_x >= end_x) {
- printf("bad region.\n");
+ msg_debug("bad region");
y = 0;
end_y = 0;
return;
#include <sstream>
#include "joystickkeyboardcontroller.hpp"
+#include "msg.hpp"
#include "gui/menu.hpp"
#include "gettext.hpp"
#include "lisp/lisp.hpp"
SDL_Joystick* joystick = SDL_JoystickOpen(i);
bool good = true;
if(SDL_JoystickNumButtons(joystick) < 2) {
- std::cerr << "Joystick " << i << " has less than 2 buttons.\n";
+ msg_warning("Joystick " << i << " has less than 2 buttons");
good = false;
}
if(SDL_JoystickNumAxes(joystick) < 2
&& SDL_JoystickNumHats(joystick) == 0) {
- std::cerr << "Joystick " << i << " has less than 2 axes and no hat.\n";
+ msg_warning("Joystick " << i << " has less than 2 axes and no hat");
good = false;
}
if(!good) {
map->get("key", key);
map->get("control", control);
if(key < SDLK_FIRST || key >= SDLK_LAST) {
- std::cerr << "Invalid key '" << key << "' in keymap.\n";
+ msg_warning("Invalid key '" << key << "' in keymap");
continue;
}
break;
}
if(controlNames[i] == 0) {
- std::cerr << "Invalid control '" << control << "' in keymap.\n";
+ msg_warning("Invalid control '" << control << "' in keymap");
continue;
}
keymap.insert(std::make_pair((SDLKey) key, (Control) i));
} else {
- std::cerr << "Invalid lisp element '" << iter.item() << "' in keymap.\n";
+ msg_warning("Invalid lisp element '" << iter.item() << "' in keymap");
}
}
}
map->get("button", button);
map->get("control", control);
if(button < 0 || button >= max_joybuttons) {
- std::cerr << "Invalid button '" << button << "' in buttonmap.\n";
+ msg_warning("Invalid button '" << button << "' in buttonmap");
continue;
}
break;
}
if(controlNames[i] == 0) {
- std::cerr << "Invalid control '" << control << "' in buttonmap.\n";
+ msg_warning("Invalid control '" << control << "' in buttonmap");
continue;
}
reset_joybutton(button, (Control) i);
// normal mode, find key in keymap
KeyMap::iterator i = keymap.find(event.key.keysym.sym);
if(i == keymap.end()) {
-#ifdef DEBUG
- std::cerr << "Pressed key without mapping.\n";
-#endif
+ msg_debug("Pressed key without mapping");
return;
}
Control control = i->second;
ButtonMap::iterator i = joy_button_map.find(event.jbutton.button);
if(i == joy_button_map.end()) {
-#ifdef DEBUG
- std::cerr << "Unmapped joybutton " << (int) event.jbutton.button
- << " pressed.\n";
-#endif
+ msg_debug("Unmapped joybutton " << (int) event.jbutton.button
+ << " pressed");
return;
}
JoystickKeyboardController::check_cheatcode(const std::string& cheatcode)
{
if(cheatcode.size() > sizeof(last_keys)) {
-#ifdef DEBUG
- std::cerr << "Cheat Code too long.\n";
-#endif
+ msg_debug("Cheat Code too long");
return false;
}
#include <config.h>
+#include "msg.hpp"
#include "file_system.hpp"
#include <string>
#include <vector>
-#include <iostream>
#include <sstream>
namespace FileSystem
if(pathelem == "..") {
if(path_stack.empty()) {
- std::cout << "Invalid '..' in path '" << filename << "'.\n";
+
+ msg_warning("Invalid '..' in path '" << filename << "'");
// push it into the result path so that the users sees his error...
path_stack.push_back(pathelem);
} else {
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <config.h>
-#include <iostream>
#include <fstream>
#include <sstream>
#include <cassert>
#include <SDL.h>
#include "game_session.hpp"
+#include "msg.hpp"
#include "video/screen.hpp"
#include "audio/sound_manager.hpp"
#include "gui/menu.hpp"
tux.kill(tux.KILL);
}
if(main_controller->check_cheatcode("whereami")) {
- std::cout << "You are at x " << tux.get_pos().x << ", y " << tux.get_pos().y << "." << std::endl;
+ msg_info("You are at x " << tux.get_pos().x << ", y " << tux.get_pos().y);
}
#if 0
if(main_controller->check_cheatcode("grid")) {
// don't add points to stats though...
}
if(main_controller->check_cheatcode("camera")) {
- std::cout << "Camera is at "
+ msg_info("Camera is at "
<< Sector::current()->camera->get_translation().x << ","
- << Sector::current()->camera->get_translation().y << "\n";
+ << Sector::current()->camera->get_translation().y);
}
}
if(newsector != "" && newspawnpoint != "") {
Sector* sector = level->get_sector(newsector);
if(sector == 0) {
- std::cerr << "Sector '" << newsector << "' not found.\n";
+ msg_warning("Sector '" << newsector << "' not found");
}
sector->activate(newspawnpoint);
sector->play_music(LEVEL_MUSIC);
}
} else if(sequencename == "stoptux") {
if(!end_sequence) {
- std::cout << "WARNING: Final target reached without "
- << "an active end sequence." << std::endl;
+ msg_warning("Final target reached without "
+ << "an active end sequence");
this->start_sequence("endsequence");
}
end_sequence = ENDSEQUENCE_WAITING;
} else {
- std::cout << "Unknown sequence '" << sequencename << "'.\n";
+ msg_warning("Unknown sequence '" << sequencename << "'");
}
}
#include <stdexcept>
#include "video/screen.hpp"
+#include "msg.hpp"
#include "lisp/parser.hpp"
#include "lisp/lisp.hpp"
#include "lisp/list_iterator.hpp"
if(token == "version") {
iter.value()->get(version);
if(version > 2) {
- std::cerr << "Warning: level format newer than application.\n";
+ msg_warning("level format newer than application");
}
} else if(token == "name") {
iter.value()->get(name);
sector->parse(*(iter.lisp()));
add_sector(sector);
} else {
- std::cerr << "Unknown token '" << token << "' in level file.\n";
+ msg_warning("Unknown token '" << token << "' in level file");
continue;
}
}
#include <unistd.h>
#include <physfs.h>
#include "level.hpp"
+#include "msg.hpp"
#include "resources.hpp"
#include "file_system.hpp"
#include "video/surface.hpp"
std::string path = subset + "/";
char** files = PHYSFS_enumerateFiles(path.c_str());
if(!files) {
- std::cerr << "Warning: Couldn't read subset dir '"
- << path << "'.\n";
+ msg_warning("Couldn't read subset dir '"
+ << path << "'");
return;
}
#include "writer.hpp"
#include "physfs/physfs_stream.hpp"
+#include "msg.hpp"
namespace lisp
{
Writer::~Writer()
{
if(lists.size() > 0) {
- std::cerr << "Warning: Not all sections closed in lispwriter!\n";
+ msg_warning("Not all sections closed in lispwriter");
}
if(out_owned)
delete out;
Writer::end_list(const std::string& listname)
{
if(lists.size() == 0) {
- std::cerr << "Trying to close list '" << listname
- << "', which is not open.\n";
+ msg_warning("Trying to close list '" << listname
+ << "', which is not open");
return;
}
if(lists.back() != listname) {
- std::cerr << "Warning: trying to close list '" << listname
- << "' while list '" << lists.back() << "' is open.\n";
+ msg_warning("trying to close list '" << listname
+ << "' while list '" << lists.back() << "' is open");
return;
}
lists.pop_back();
#include <config.h>
#include <assert.h>
+#include "msg.hpp"
#include "main.hpp"
#include <stdexcept>
-#include <iostream>
#include <sstream>
#include <time.h>
#include <stdlib.h>
try {
config->load();
} catch(std::exception& e) {
- std::cerr << "Couldn't load config file: " << e.what() << "\n";
- std::cerr << "Using default settings.\n";
+ msg_info("Couldn't load config file: " << e.what() << ", using default settings");
}
}
if(f) {
fclose(f);
if(!PHYSFS_addToSearchPath(dir.c_str(), 1)) {
- std::cout << "Warning: Couldn't add '" << dir
- << "' to physfs searchpath: " << PHYSFS_getLastError() << "\n";
+ msg_warning("Couldn't add '" << dir
+ << "' to physfs searchpath: " << PHYSFS_getLastError());
} else {
sourcedir = true;
}
datadir = APPDATADIR;
#endif
if(!PHYSFS_addToSearchPath(datadir.c_str(), 1)) {
- std::cout << "Couldn't add '" << datadir
- << "' to physfs searchpath: " << PHYSFS_getLastError() << "\n";
+ msg_warning("Couldn't add '" << datadir
+ << "' to physfs searchpath: " << PHYSFS_getLastError());
}
#endif
}
//show search Path
for(char** i = PHYSFS_getSearchPath(); *i != NULL; i++)
- printf("[%s] is in the search path.\n", *i);
+ msg_info("[" << *i << "] is in the search path");
}
static void print_usage(const char* argv0)
print_usage(argv[0]);
throw graceful_shutdown();
} else if(arg == "--version") {
- std::cerr << PACKAGE_NAME << " " << PACKAGE_VERSION << "\n";
+ msg_info(PACKAGE_NAME << " " << PACKAGE_VERSION);
throw graceful_shutdown();
} else if(arg[0] != '-') {
config->start_level = arg;
} else {
- std::cerr << "Unknown option '" << arg << "'.\n";
- std::cerr << "Use --help to see a list of options.\n";
+ msg_warning("Unknown option '" << arg << "'. Use --help to see a list of options");
}
}
}
#ifdef DEBUG
else {
- std::cerr << "Warning: Couldn't find icon 'images/engine/icons/supertux.xpm'.\n";
+ msg_warning("Couldn't find icon 'images/engine/icons/supertux.xpm'");
}
#endif
Uint32 current_ticks = SDL_GetTicks();
if(last_timelog_component != 0) {
- printf("Component '%s' finished after %f seconds\n",
- last_timelog_component, (current_ticks - last_timelog_ticks) / 1000.0);
+ msg_info("Component '" << last_timelog_component << "' finished after " << (current_ticks - last_timelog_ticks) / 1000.0 << " seconds");
}
last_timelog_ticks = current_ticks;
}
} catch(graceful_shutdown& e) {
} catch(std::exception& e) {
- std::cerr << "Unexpected exception: " << e.what() << std::endl;
+ msg_fatal("Unexpected exception: " << e.what());
return 1;
} catch(...) {
- std::cerr << "Unexpected exception." << std::endl;
+ msg_fatal("Unexpected exception");
return 1;
}
--- /dev/null
+// $Id: debug.cpp 2650 2005-06-28 12:42:08Z sommer $
+//
+// SuperTux Debug Helper Functions
+// Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
+//
+// 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_DEBUG_H__
+#define __SUPERTUX_DEBUG_H__
+
+#include <iostream>
+#include <stdio.h>
+
+#ifdef DEBUG
+
+#define msg_debug(message) std::cerr << "[DEBUG] " << __FILE__ << " l." << __LINE__ << ": " << message << std::endl
+#define msg_info(message) std::cout << "[INFO] " << message << std::endl
+#define msg_warning(message) std::cerr << "[WARNING] " << __FILE__ << " l." << __LINE__ << ": " << message << std::endl
+#define msg_fatal(message) std::cerr << "[FATAL] " << __FILE__ << " l." << __LINE__ << ": " << message << std::endl
+
+#else
+
+#define msg_debug(message)
+#define msg_info(message) std::cout << message << std::endl
+#define msg_warning(message) std::cerr << "Warning: " << message << std::endl
+#define msg_fatal(message) std::cerr << "Fatal: " << message << std::endl
+
+#endif
+
+#endif
+
#include "sector.hpp"
#include "audio/sound_manager.hpp"
#include "audio/sound_source.hpp"
+#include "msg.hpp"
AmbientSound::AmbientSound(const lisp::Lisp& lisp)
{
sample="";
if (!(lisp.get("x", position.x)&&lisp.get("y", position.y))) {
- std::cerr << "No Position in ambient_sound" << std::endl;
+ msg_warning("No Position in ambient_sound");
}
lisp.get("width" , dimension.x);
currentvolume=targetvolume=1e-20;
sound_source->play();
} catch(std::exception& e) {
- std::cerr << "Couldn't play '" << sample << "': " << e.what() << "\n";
+ msg_warning("Couldn't play '" << sample << "': " << e.what() << "");
delete sound_source;
sound_source = 0;
}
#include <sstream>
#include "anchor_point.hpp"
#include "math/rect.hpp"
+#include "msg.hpp"
std::string anchor_point_to_string(AnchorPoint point)
{
#ifdef DEBUG
throw new std::runtime_error("Invalid anchor point found");
#endif
- printf("Invalid anchor point found");
+ msg_warning("Invalid anchor point found");
result.x = rect.get_left();
break;
}
#ifdef DEBUG
throw new std::runtime_error("Invalid anchor point found");
#endif
- printf("Invalid anchor point found");
+ msg_warning("Invalid anchor point found");
result.y = rect.get_top();
break;
}
#ifdef DEBUG
throw new std::runtime_error("Invalid anchor point found");
#endif
- printf("Invalid anchor point found");
+ msg_warning("Invalid anchor point found");
result.x = destrect.get_left();
break;
}
#ifdef DEBUG
throw new std::runtime_error("Invalid anchor point found");
#endif
- printf("Invalid anchor point found");
+ msg_warning("Invalid anchor point found");
result.y = destrect.get_top();
break;
}
#include "object_factory.hpp"
#include "resources.hpp"
#include "main.hpp"
+#include "msg.hpp"
Background::Background()
: type(INVALID), layer(LAYER_BACKGROUND0), image(0)
if (gradient_top.red > 1.0 || gradient_top.green > 1.0
|| gradient_top.blue > 1.0 || gradient_top.alpha > 1.0)
- std::cerr << "Warning: top gradient color has values above 1.0." << std::endl;
+ msg_warning("top gradient color has values above 1.0");
if (gradient_bottom.red > 1.0 || gradient_bottom.green > 1.0
|| gradient_bottom.blue > 1.0 || gradient_bottom.alpha > 1.0)
- std::cerr << "Warning: bottom gradient color has values above 1.0." << std::endl;
+ msg_warning("bottom gradient color has values above 1.0");
delete image;
image = NULL;
#include <config.h>
#include "block.hpp"
+#include "msg.hpp"
#include <stdexcept>
case 4: contents = CONTENT_1UP; break;
case 5: contents = CONTENT_ICEGROW; break;
default:
- std::cerr << "Invalid box contents!\n";
+ msg_warning("Invalid box contents");
contents = CONTENT_COIN;
break;
}
} else if(contentstring == "custom") {
contents = CONTENT_CUSTOM;
} else {
- std::cerr << "Invalid box contents '" << contentstring << "'.\n";
+ msg_warning("Invalid box contents '" << contentstring << "'");
}
} else {
if(contents == CONTENT_CUSTOM) {
throw std::runtime_error(
"Only MovingObjects are allowed inside BonusBlocks");
} else {
- std::cerr << "Invalid element '" << token << "' in bonusblock.\n";
+ msg_warning("Invalid element '" << token << "' in bonusblock");
}
}
}
#include "sector.hpp"
#include "main.hpp"
#include "object_factory.hpp"
+#include "msg.hpp"
Camera::Camera(Sector* newsector)
: sector(newsector), do_backscrolling(true), scrollchange(NONE)
autoscrollPath = Path::GetByName(use_path);
if (autoscrollPath == NULL) {
- std::cerr << "Warning: Path for autoscroll camera not found! Make sure that the name is spelled correctly and that the path is initialized before the platform in the level file!" << std::endl;
+ msg_warning("Path for autoscroll camera not found! Make sure that the name is spelled correctly and that the path is initialized before the platform in the level file!");
}
} else if(modename == "manual") {
#include "object_factory.hpp"
#include "lisp/lisp.hpp"
#include "sector.hpp"
+#include "msg.hpp"
InfoBlock::InfoBlock(const lisp::Lisp& lisp)
: Block(sprite_manager->create("images/objects/bonus_block/infoblock.sprite"))
bbox.set_pos(pos);
if(!lisp.get("message", message)) {
- std::cerr << "No message in InfoBlock!\n";
+ msg_warning("No message in InfoBlock");
}
stopped = false;
ringing = new AmbientSound(get_pos(), 0.5, 300, 1, "phone");
#include "object/player.hpp"
#include "video/drawing_context.hpp"
#include "lisp/list_iterator.hpp"
+#include "msg.hpp"
/** When to alert player they're low on time! */
static const float TIME_WARNING = 20;
iter.value()->get(time);
break;
} else {
- std::cerr << "Unknown token '" << iter.item()
- << "' in LevelTime object.\n";
+ msg_warning("Unknown token '" << iter.item()
+ << "' in LevelTime object");
}
}
if(time < 0)
#include "lisp/lisp.hpp"
#include "lisp/list_iterator.hpp"
#include "object_factory.hpp"
+#include "msg.hpp"
#include <assert.h>
#include <iostream>
while(iter.next()) {
if(iter.item() != "node") {
- std::cerr << "Warning: unknown token '" << iter.item() << "' in Path nodes list. Ignored." << std::endl;
+ msg_warning("unknown token '" << iter.item() << "' in Path nodes list. Ignored.");
continue;
}
const lisp::Lisp* node_lisp = iter.lisp();
#include "platform.hpp"
-#include <iostream>
+#include "msg.hpp"
#include "video/drawing_context.hpp"
#include "resources.hpp"
#include "player.hpp"
flags |= FLAG_SOLID;
path = Path::GetByName(use_path);
- if (path == NULL) {
- std::cerr << "Warning: Path for moving platform not found! Make sure that the name is spelled correctly,\nand that the path is initialized before the platform in the level file!\n";
+
+ if (path == NULL) {
+ msg_warning("Path \"" << use_path << "\" for moving platform not found! Make sure that the name is spelled correctly and that the path is initialized before the platform in the level file!");
}
path_offset = bbox.p1;
#include "main.hpp"
#include "badguy/badguy.hpp"
#include "player_status.hpp"
+#include "msg.hpp"
static const int TILES_FOR_BUTTJUMP = 3;
static const float SHOOTING_TIME = .150;
if(moving_object) {
moving_object->set_pos(pos);
} else {
-#ifdef DEBUG
- std::cout << "Non MovingObjetc grabbed?!?\n";
-#endif
+ msg_debug("Non MovingObjetc grabbed?!?");
}
grabbed_object->ungrab(*this, dir);
grabbed_object = 0;
#include "object_factory.hpp"
#include "sector.hpp"
#include "scripting/script_interpreter.hpp"
+#include "msg.hpp"
PowerUp::PowerUp(const lisp::Lisp& lisp)
{
if(fabsf(hit.normal.y) > .5) { // roof or ground
physic.set_velocity_y(0);
} else { // bumped left or right
- printf("Normal: %f %f\n", hit.normal.x, hit.normal.y);
- printf("LRbounce, new speed. %f\n", physic.get_velocity_x());
+ msg_debug("Normal: " << hit.normal.x << "," << hit.normal.y);
+ msg_debug("LRbounce, new speed: " << physic.get_velocity_x());
physic.set_velocity_x(-physic.get_velocity_x());
}
#include <iostream>
#include "resources.hpp"
#include "video/drawing_context.hpp"
+#include "msg.hpp"
TextObject::TextObject()
: fading(0), fadetime(0), visible(false)
} else if(name == "small") {
font = white_small_text;
} else {
- std::cerr << "Unknown font '" << name << "'.\n";
+ msg_warning("Unknown font '" << name << "'.");
}
}
#include "lisp/writer.hpp"
#include "object_factory.hpp"
#include "main.hpp"
+#include "msg.hpp"
TileMap::TileMap()
: solid(false), speed(1), width(0), height(0), layer(LAYER_TILES),
else if(layer_str == "foreground")
layer = LAYER_FOREGROUNDTILES;
else
- std::cerr << "Unknown layer '" << layer_str << "' in tilemap.\n";
+ msg_warning("Unknown layer '" << layer_str << "' in tilemap");
}
reader.get("solid", solid);
reader.get("speed", speed);
if(solid && speed != 1) {
- std::cout << "Speed of solid tilemap is not 1. fixing.\n";
+ msg_warning("Speed of solid tilemap is not 1. fixing");
speed = 1;
}
if(solid)
writer.write_string("layer", "foreground");
else {
writer.write_string("layer", "unknown");
- std::cerr << "Warning unknown layer in tilemap.\n";
+ msg_warning("unknown layer in tilemap");
}
writer.write_bool("solid", solid);
TileMap::get_tile(int x, int y) const
{
if(x < 0 || x >= width || y < 0 || y >= height) {
-#ifdef DEBUG
- //std::cout << "Warning: tile outside tilemap requested!\n";
-#endif
+ //msg_warning("tile outside tilemap requested");
return tilemanager->get(0);
}
#include <iostream>
#include <assert.h>
+#include "msg.hpp"
static int funcSeek(struct SDL_RWops* context, int offset, int whence)
{
break;
}
if(res == 0) {
- std::cerr << "Error seeking in file: " << PHYSFS_getLastError() << "\n";
+ msg_warning("Error seeking in file: " << PHYSFS_getLastError());
return -1;
}
#include "sprite/sprite_manager.hpp"
#include "math/vector.hpp"
#include "main.hpp"
+#include "msg.hpp"
static const int START_LIVES = 4;
static const int MAX_LIVES = 99;
writer.write_string("bonus", "iceflower");
break;
default:
- std::cerr << "Unknown bonus type.\n";
+ msg_warning("Unknown bonus type.");
writer.write_string("bonus", "none");
}
writer.write_bool("key-brass", keys & KEY_BRASS);
} else if(bonusname == "iceflower") {
bonus = ICE_BONUS;
} else {
- std::cerr << "Unknown bonus '" << bonusname << "' in savefile.\n";
+ msg_warning("Unknown bonus '" << bonusname << "' in savefile");
bonus = NO_BONUS;
}
}
#include "tinygettext/tinygettext.hpp"
#include "resources.hpp"
#include "gettext.hpp"
+#include "msg.hpp"
namespace Scripting
{
std::string file
= ScriptInterpreter::current()->get_working_directory() + filename;
if(sqstd_loadfile(v, file.c_str(), true) < 0) {
- std::cerr << "Warning couldn't load script '" << filename << "' ("
- << file << ").\n";
+ msg_warning("couldn't load script '" << filename << "' ("
+ << file << ")");
return;
}
sq_push(v, -2);
if(sq_call(v, 1, false) < 0) {
- std::cerr << "Couldn't execute script '" << filename << "' ("
- << file << ").\n";
+ msg_warning("Couldn't execute script '" << filename << "' ("
+ << file << ")");
return;
}
}
#include <sqstdmath.h>
#include <sqstdstring.h>
+#include "msg.hpp"
#include "wrapper.hpp"
#include "wrapper_util.hpp"
#include "sector.hpp"
interpreter->run_script(in, name);
sector->add_object(interpreter.release());
} catch(std::exception& e) {
- std::cerr << "Couldn't start '" << name << "' script: " << e.what() << "\n";
+ msg_warning("Couldn't start '" << name << "' script: " << e.what());
}
}
#include "scripting/sound.hpp"
#include "scripting/scripted_object.hpp"
#include "scripting/text.hpp"
+#include "msg.hpp"
Sector* Sector::_current = 0;
try {
return create_object(name, reader);
} catch(std::exception& e) {
- std::cerr << e.what() << "\n";
+ msg_warning(e.what() << "");
}
return 0;
fix_old_tiles();
if(!camera) {
- std::cerr << "sector '" << name << "' does not contain a camera.\n";
+ msg_warning("sector '" << name << "' does not contain a camera.");
update_game_objects();
add_object(new Camera(this));
}
spawnpoints.push_back(sp);
}
} else {
- std::cerr << "Unknown token '" << iter.item() << "' in reset-points.\n";
+ msg_warning("Unknown token '" << iter.item() << "' in reset-points.");
}
}
}
if(object) {
add_object(object);
} else {
- std::cerr << "Unknown object '" << iter.item() << "' in level.\n";
+ msg_warning("Unknown object '" << iter.item() << "' in level.");
}
}
}
}
}
if(!sp) {
- std::cerr << "Spawnpoint '" << spawnpoint << "' not found.\n";
+ msg_warning("Spawnpoint '" << spawnpoint << "' not found.");
if(spawnpoint != "main") {
activate("main");
} else {
if(solids == 0) {
solids = tilemap;
} else {
- std::cerr << "Another solid tilemaps added. Ignoring.";
+ msg_warning("Another solid tilemaps added. Ignoring");
}
}
Camera* camera = dynamic_cast<Camera*> (object);
if(camera) {
if(this->camera != 0) {
- std::cerr << "Warning: Multiple cameras added. Ignoring.";
+ msg_warning("Multiple cameras added. Ignoring");
continue;
}
this->camera = camera;
#include "spawn_point.hpp"
#include "lisp/lisp.hpp"
#include "lisp/list_iterator.hpp"
+#include "msg.hpp"
SpawnPoint::SpawnPoint()
{}
} else if(token == "y") {
iter.value()->get(pos.y);
} else {
- std::cerr << "Warning: unknown token '" << token
- << "' in SpawnPoint\n";
+ msg_warning("unknown token '" << token
+ << "' in SpawnPoint");
}
}
#include "sprite.hpp"
#include "video/drawing_context.hpp"
+#include "msg.hpp"
Sprite::Sprite(SpriteData& newdata)
: data(newdata), frame(0), animation_loops(-1)
SpriteData::Action* newaction = data.get_action(name);
if(!newaction) {
-#ifdef DEBUG
- std::cerr << "Action '" << name << "' not found.\n";
-#endif
+ msg_debug("Action '" << name << "' not found.");
return;
}
update();
if((int)frame >= get_frames() || (int)frame < 0)
- std::cerr << "Warning: frame out of range: " << (int)frame
+ msg_warning("frame out of range: " << (int)frame
<< "/" << get_frames() << " at " << get_name()
- << "/" << get_action_name() << std::endl;
+ << "/" << get_action_name());
else
context.draw_surface(action->surfaces[(int)frame],
pos - Vector(action->x_offset, action->y_offset),
update();
if((int)frame >= get_frames() || (int)frame < 0)
- std::cerr << "Warning: frame out of range: " << (int)frame
+ msg_warning("frame out of range: " << (int)frame
<< "/" << get_frames() << " at sprite: " << get_name()
- << "/" << get_action_name() << std::endl;
+ << "/" << get_action_name());
else
context.draw_surface_part(action->surfaces[(int)frame], source, size,
pos - Vector(action->x_offset, action->y_offset),
#include "resources.hpp"
#include "video/drawing_context.hpp"
#include "lisp/list_iterator.hpp"
+#include "msg.hpp"
SpriteData::Action::Action()
{
} else if(iter.item() == "action") {
parse_action(iter.lisp(), basedir);
} else {
- std::cerr << "Unknown sprite field: " << iter.item() << "\n";
+ msg_warning("Unknown sprite field: " << iter.item());
}
}
if(actions.empty())
#include "lisp/parser.hpp"
#include "lisp/list_iterator.hpp"
#include "file_system.hpp"
+#include "msg.hpp"
SpriteManager::SpriteManager(const std::string& filename)
{
#endif
load_resfile(filename);
#ifdef DEBUG
- printf("Loaded sprites in %f seconds\n", (SDL_GetTicks() - ticks) / 1000.0f);
+ msg_debug("Loaded sprites in " << (SDL_GetTicks() - ticks) / 1000.0f << " seconds");
#endif
}
} else {
delete i->second;
i->second = spritedata;
- std::cout << "Warning: dulpicate entry: '" << spritedata->get_name()
- << "' in spritefile." << std::endl;
+ msg_warning("dulpicate entry: '" << spritedata->get_name()
+ << "' in spritefile.");
}
} else {
- std::cout << "SpriteManager: Unknown tag '" << iter.item()
- << "' in spritefile.\n";
+ msg_warning("Unknown tag '" << iter.item()
+ << "' in spritefile.");
}
}
} catch(std::exception& e) {
#include "textscroller.hpp"
#include <stdexcept>
+#include "msg.hpp"
#include "resources.hpp"
#include "video/font.hpp"
#include "video/drawing_context.hpp"
if(text_lisp->get("speed", defaultspeed))
defaultspeed /= 50;
} catch(std::exception& e) {
- std::cerr << "Couldn't load file '" << filename << "': " << e.what() <<
- "\n";
+ msg_warning("Couldn't load file '" << filename << "': " << e.what());
return;
}
continue;
if(line[0] == '!') {
std::string imagename = line.substr(1, line.size()-1);
- std::cout << "Imagename: " << imagename << "\n";
+ msg_debug("Imagename: " << imagename);
images.insert(std::make_pair(imagename, new Surface(imagename)));
}
}
break;
}
default:
- std::cerr << "Warning: text contains an unformated line.\n";
+ msg_warning("text contains an unformated line");
font = normal_font;
center = false;
break;
}
catch (std::exception& e)
{
- std::cout << "Could not load scrolling images: " << e.what() << std::endl;
+ msg_warning("Could not load scrolling images: " << e.what());
arrow_scrollup = 0;
arrow_scrolldown = 0;
}
break;
}
default:
- std::cerr << "Warning: text contains an unformatted line.\n";
+ msg_warning("text contains an unformatted line");
font = normal_font;
center = false;
break;
#include "timer.hpp"
#include "math/vector.hpp"
#include "video/drawing_context.hpp"
+#include "msg.hpp"
+
Tile::Tile()
: id(0), editor_image(0), attributes(0), data(0), anim_fps(1)
ptr->get_car()->get(h);
imagespecs.push_back(ImageSpec(file, Rect(x, y, x+w, y+h)));
} else {
- std::cerr << "Expected string or list in images tag.\n";
+ msg_warning("Expected string or list in images tag");
continue;
}
#include <assert.h>
#include <SDL.h>
#include "video/drawing_context.hpp"
+#include "msg.hpp"
#include "lisp/lisp.hpp"
#include "lisp/parser.hpp"
#include "lisp/list_iterator.hpp"
#endif
load_tileset(filename);
#ifdef DEBUG
- printf("Tiles loaded in %f seconds\n", (SDL_GetTicks() - ticks) / 1000.0);
+ msg_debug("Tiles loaded in " << (SDL_GetTicks() - ticks) / 1000.0 << "seconds");
#endif
}
tiles.push_back(0);
}
if(tiles[tile->id] != 0) {
- std::cout << "Warning: Tile with ID " << tile->id << " redefined\n";
+ msg_warning("Tile with ID " << tile->id << " redefined");
}
tiles[tile->id] = tile;
} else if(iter.item() == "tilegroup") {
} else if(iter.item() == "properties") {
// deprecated
} else {
- std::cerr << "Unknown symbol '" << iter.item() << "' tile defintion file.\n";
+ msg_warning("Unknown symbol '" << iter.item() << "' tile defintion file");
}
}
}
#include <iostream>
#include <stdint.h>
#include <assert.h>
+#include "msg.hpp"
#include "tile.hpp"
struct TileGroup
assert(id < tiles.size());
Tile* tile = tiles[id];
if(!tile) {
- std::cout << "TileManager: Invalid tile: " << id << std::endl;
+ msg_warning("Invalid tile: " << id);
return tiles[0];
}
#include <errno.h>
#include "tinygettext.hpp"
+#include "msg.hpp"
#include "physfs/physfs_stream.hpp"
+#include "msg.hpp"
//#define TRANSLATION_DEBUG
out_len -= out_len_temp; // see above
if (retval == (size_t) -1)
{
- std::cerr << strerror(errno) << std::endl;
- std::cerr << "Error: conversion from " << from_charset
- << " to " << to_charset << " went wrong: " << retval << std::endl;
+ msg_warning(strerror(errno));
+ msg_warning("Error: conversion from " << from_charset
+ << " to " << to_charset << " went wrong: " << retval);
return "";
}
iconv_close(cd);
}
else // Dictionary for languages lang isn't loaded, so we load it
{
- //std::cout << "get_dictionary: " << lang << std::endl;
+ //msg_debug("get_dictionary: " << lang);
Dictionary& dict = dictionaries[lang];
dict.set_language(get_language_def(lang));
char** files = PHYSFS_enumerateFiles(p->c_str());
if(!files)
{
- std::cerr << "Error: enumerateFiles() failed on " << *p << std::endl;
+ msg_warning("Error: enumerateFiles() failed on " << *p);
}
else
{
IFileStream in(pofile);
read_po_file(dict, in);
} catch(std::exception& e) {
- std::cerr << "Error: Failure file opening: " << pofile << std::endl;
- std::cerr << e.what() << "\n";
+ msg_warning("Error: Failure file opening: " << pofile);
+ msg_warning(e.what() << "");
}
}
}
char** files = PHYSFS_enumerateFiles(p->c_str());
if (!files)
{
- std::cerr << "Error: opendir() failed on " << *p << std::endl;
+ msg_warning("Error: opendir() failed on " << *p);
}
else
{
else
{
#ifdef TRANSLATION_DEBUG
- std::cerr << "Warning: Couldn't translate: " << msgid << std::endl;
- std::cerr << "Candidates: " << std::endl;
+ msg_warning("Couldn't translate: " << msgid);
+ msg_warning("Candidates: ");
for (PluralEntries::iterator i = plural_entries.begin(); i != plural_entries.end(); ++i)
- std::cout << "'" << i->first << "'" << std::endl;
+ msg_debug("'" << i->first << "'");
#endif
if (plural2_1(num)) // default to english rules
else
{
#ifdef TRANSLATION_DBEUG
- std::cout << "Error: Couldn't translate: " << msgid << std::endl;
+ msg_warning("Couldn't translate: " << msgid);
#endif
return msgid;
}
else
{
#ifdef TRANSLATION_DBEUG
- std::cout << "Error: Couldn't translate: " << msgid << std::endl;
+ msg_warning("Couldn't translate: " << msgid);
#endif
return msgid;
}
if (from_charset.empty() || from_charset == "CHARSET")
{
- std::cerr << "Error: Charset not specified for .po, fallback to ISO-8859-1" << std::endl;
+ msg_warning("Error: Charset not specified for .po, fallback to ISO-8859-1");
from_charset = "ISO-8859-1";
}
}
else if (token.keyword.empty())
{
- //std::cerr << "Got EOF, everything looks ok." << std::endl;
+ //msg_warning("Got EOF, everything looks ok.");
}
else
{
- std::cerr << "tinygettext: expected 'msgid' keyword, got " << token.keyword
- << " at line " << line_num << std::endl;
+ msg_warning("tinygettext: expected 'msgid' keyword, got " << token.keyword
+ << " at line " << line_num);
}
break;
}
else
{
- std::cerr << "tinygettext: expected 'msgstr' keyword, got " << token.keyword
- << " at line " << line_num << std::endl;
+ msg_warning("tinygettext: expected 'msgstr' keyword, got " << token.keyword
+ << " at line " << line_num);
}
break;
int num;
if (sscanf(token.keyword.c_str(), "msgstr[%d]", &num) != 1)
{
- std::cerr << "Error: Couldn't parse: " << token.keyword << std::endl;
+ msg_warning("Error: Couldn't parse: " << token.keyword);
}
else
{
while((c = getchar(in)) != EOF)
{
- //std::cout << "Lexing char: " << char(c) << " " << state << std::endl;
+ //msg_debug("Lexing char: " << char(c) << " " << state);
switch(state)
{
case READ_KEYWORD:
else if (c == '"') token.content += '"';
else
{
- std::cout << "Unhandled escape character: " << char(c) << std::endl;
+ msg_warning("Unhandled escape character: " << char(c));
}
}
else
{
- std::cout << "Unterminated string" << std::endl;
+ msg_warning("Unterminated string");
}
} else if (c == '"') { // Content string is terminated
state = READ_CONTENT;
#include "control/codecontroller.hpp"
#include "main.hpp"
#include "exceptions.hpp"
+#include "msg.hpp"
static Surface* bkg_title;
static Surface* logo;
void update_load_save_game_menu(Menu* menu)
{
- printf("update loadsavemenu.\n");
+ msg_debug("update loadsavemenu");
for(int i = 1; i < 6; ++i) {
MenuItem& item = menu->get_item_by_id(i);
item.kind = MN_ACTION;
contrib_subsets.push_back(subset.release());
} catch(std::exception& e) {
#ifdef DEBUG
- std::cerr << "Couldn't parse levelset info for '"
- << *it << "': " << e.what() << "\n";
+ msg_warning("Couldn't parse levelset info for '"
+ << *it << "': " << e.what() << "");
#endif
}
}
level->get("name", name);
return name;
} catch(std::exception& e) {
- std::cerr << "Problem getting name of '" << filename << "'.\n";
+ msg_warning("Problem getting name of '" << filename << "'.");
return "";
}
}
if(confirm_dialog(bkg_title, str.c_str())) {
str = "save/slot" + stream.str() + ".stsg";
- printf("Removing: %s\n",str.c_str());
+ msg_debug("Removing: " << str);
PHYSFS_delete(str.c_str());
}
#define __COLOR_HPP__
#include <vector>
+#include "msg.hpp"
class Color
{
if(red < 0 || red > 1.0 || green < 0 || green > 1.0
|| blue < 0 || blue > 1.0
|| alpha < 0 || alpha > 1.0)
- printf("Warning: color value out of range: %f %f %f %f\n",
- red, green, blue, alpha);
+ msg_warning("color value out of range: " << red << ", " << green << ", " << blue << ", " << alpha);
}
float red, green, blue, alpha;
#include "screen.hpp"
#include "font.hpp"
#include "drawing_context.hpp"
+#include "msg.hpp"
Font::Font(const std::string& file, const std::string& shadowfile,
int w, int h, int shadowsize)
if(c >= 0x80) {
font_index -= 32;
if(c <= 0xa0) {
-#ifdef DEBUG
- std::cout << "Unsupported utf-8 character '" << c << "' found\n";
-#endif
+ msg_debug("Unsupported utf-8 character '" << c << "' found");
font_index = 0;
}
}
if(font_index < 0 || font_index >= (ssize_t) char_count) {
-#ifdef DEBUG
- std::cout << "Unsupported utf-8 character found\n";
-#endif
+ msg_debug("Unsupported utf-8 character found");
font_index = 0;
}
#include "image_texture.hpp"
#include "glutil.hpp"
#include "file_system.hpp"
+#include "msg.hpp"
TextureManager* texture_manager = NULL;
i != image_textures.end(); ++i) {
if(i->second == NULL)
continue;
-#ifdef DEBUG
- std::cerr << "Warning: Texture '" << i->first << "' not freed\n";
-#endif
+ msg_warning("Texture '" << i->first << "' not freed");
delete i->second;
}
}
#include <physfs.h>
#include "gettext.hpp"
+#include "msg.hpp"
#include "video/surface.hpp"
#include "video/screen.hpp"
#include "video/drawing_context.hpp"
tux_sprite->set_action(moving ? "small-walking" : "small-stop");
break;
default:
-#ifdef DEBUG
- std::cerr << "Bonus type not handled in worldmap.\n";
-#endif
+ msg_debug("Bonus type not handled in worldmap.");
tux_sprite->set_action("large-stop");
break;
}
} else if(iter.item() == "special-tile") {
parse_special_tile(iter.lisp());
} else {
- std::cerr << "Unknown token '" << iter.item() << "' in worldmap.\n";
+ msg_warning("Unknown token '" << iter.item() << "' in worldmap");
}
}
if(solids == 0)
// 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...
- std::cerr << "Error: level file '" << level.name
- << "' does not exist and will not be added to the worldmap." << std::endl;
+ msg_warning("level file '" << level.name
+ << "' does not exist and will not be added to the worldmap");
return;
}
level_lisp->get("name", level.title);
} catch(std::exception& e) {
- std::cerr << "Problem when reading leveltitle: " << e.what() << "\n";
+ msg_warning("Problem when reading leveltitle: " << e.what());
return;
}
}
Level* level = at_level();
if (!level)
{
- std::cout << "No level to enter at: "
- << tux->get_tile_pos().x << ", " << tux->get_tile_pos().y
- << std::endl;
+ msg_warning("No level to enter at: "
+ << tux->get_tile_pos().x << ", " << tux->get_tile_pos().y);
return;
}
interpreter->run_script(in, "level-extro-script");
add_object(interpreter.release());
} catch(std::exception& e) {
- std::cerr << "Couldn't run level-extro-script:" << e.what() << "\n";
+ msg_warning("Couldn't run level-extro-script:" << e.what());
}
}
interpreter->run_script(in, "worldmap-intro-script");
add_object(interpreter.release());
} catch(std::exception& e) {
- std::cerr << "Couldn't execute worldmap-intro-script: "
- << e.what() << "\n";
+ msg_warning("Couldn't execute worldmap-intro-script: "
+ << e.what());
}
intro_displayed = true;
void
WorldMap::loadgame(const std::string& filename)
{
- std::cout << "loadgame: " << filename << std::endl;
+ msg_debug("loadgame: " << filename);
savegame_file = filename;
if (PHYSFS_exists(filename.c_str())) // savegame exists
}
}
} else {
- std::cerr << "Unknown token '" << iter.item()
- << "' in levels block in worldmap.\n";
+ msg_warning("Unknown token '" << iter.item()
+ << "' in levels block in worldmap");
}
}
}
} catch(std::exception& e) {
- std::cerr << "Problem loading game '" << filename << "': " << e.what()
- << "\n";
+ msg_warning("Problem loading game '" << filename << "': " << e.what());
load_map();
player_status->reset();
}