Some minor code cleanup resulting from a user running code through cppcheck, mostly...
[supertux.git] / src / supertux / info_box_line.cpp
index 16a69d6..e7ff52e 100644 (file)
@@ -26,25 +26,21 @@ static const float ITEMS_SPACE = 4;
 
 namespace {
 
-Font* get_font_by_format_char(char format_char) {
+FontPtr get_font_by_format_char(char format_char) {
   switch(format_char)
   {
     case ' ':
       return Resources::small_font;
-      break;
     case '-':
       return Resources::big_font;
-      break;
     case '\t':
     case '*':
     case '#':
     case '!':
       return Resources::normal_font;
-    break;
     default:
       return Resources::normal_font;
-      log_warning << "Unknown format_char: '" << format_char << "'" << std::endl;
-      break;
+      //log_warning << "Unknown format_char: '" << format_char << "'" << std::endl;
   }
 }
 
@@ -53,21 +49,17 @@ Color get_color_by_format_char(char format_char) {
   {
     case ' ':
       return TextScroller::small_color;
-      break;
     case '-':
       return TextScroller::heading_color;
-      break;
     case '*':
       return TextScroller::reference_color;
     case '\t':
     case '#':
     case '!':
       return TextScroller::normal_color;
-    break;
     default:
       return Color(0,0,0);
-      log_warning << "Unknown format_char: '" << format_char << "'" << std::endl;
-      break;
+      //log_warning << "Unknown format_char: '" << format_char << "'" << std::endl;
   }
 }
 
@@ -76,26 +68,20 @@ InfoBoxLine::LineType get_linetype_by_format_char(char format_char) {
   {
     case ' ':
       return InfoBoxLine::SMALL;
-      break;
+
     case '\t':
       return InfoBoxLine::NORMAL;
-      break;
     case '-':
       return InfoBoxLine::HEADING;
-      break;
     case '*':
       return InfoBoxLine::REFERENCE;
-      break;
     case '#':
       return InfoBoxLine::NORMAL_LEFT;
-      break;
     case '!':
       return InfoBoxLine::IMAGE;
-      break;
     default:
       return InfoBoxLine::SMALL;
-      log_warning << "Unknown format_char: '" << format_char << "'" << std::endl;
-      break;
+      //log_warning << "Unknown format_char: '" << format_char << "'" << std::endl;
   }
 }
 
@@ -106,7 +92,7 @@ InfoBoxLine::InfoBoxLine(char format_char, const std::string& text) :
   font(Resources::normal_font), 
   color(),
   text(text), 
-  image(0)
+  image()
 {
   font = get_font_by_format_char(format_char);
   lineType = get_linetype_by_format_char(format_char);
@@ -157,7 +143,7 @@ InfoBoxLine::split(const std::string& text, float width)
     // append wrapped parts of line into list
     std::string overflow;
     do {
-      Font* font = get_font_by_format_char(format_char);
+      FontPtr font = get_font_by_format_char(format_char);
       std::string s2 = s;
       if (font) s2 = font->wrap_to_width(s2, width, &overflow);
       lines.push_back(new InfoBoxLine(format_char, s2));
@@ -174,7 +160,7 @@ InfoBoxLine::draw(DrawingContext& context, const Rectf& bbox, int layer)
   Vector position = bbox.p1;
   switch (lineType) {
     case IMAGE:
-      context.draw_surface(image.get(), Vector( (bbox.p1.x + bbox.p2.x - image->get_width()) / 2, position.y), layer);
+      context.draw_surface(image, Vector( (bbox.p1.x + bbox.p2.x - image->get_width()) / 2, position.y), layer);
       break;
     case NORMAL_LEFT:
       context.draw_text(font, text, Vector(position.x, position.y), ALIGN_LEFT, layer, color);