[Widelands-cvs] SF.net SVN: widelands: [2162] trunk/src
Status: Beta
Brought to you by:
sirver
From: <si...@us...> - 2007-03-26 20:56:22
|
Revision: 2162 http://svn.sourceforge.net/widelands/?rev=2162&view=rev Author: sigra Date: 2007-03-26 13:54:34 -0700 (Mon, 26 Mar 2007) Log Message: ----------- Type and const fixes. Modified Paths: -------------- trunk/src/font_handler.cc trunk/src/font_handler.h trunk/src/graphic.cc trunk/src/graphic.h trunk/src/graphic_impl.h trunk/src/render.cc trunk/src/rgbcolor.h trunk/src/terrain.cc trunk/src/widelands_map_extradata_data_packet.cc trunk/src/wlapplication.cc trunk/src/world.cc Modified: trunk/src/font_handler.cc =================================================================== --- trunk/src/font_handler.cc 2007-03-25 20:08:46 UTC (rev 2161) +++ trunk/src/font_handler.cc 2007-03-26 20:54:34 UTC (rev 2162) @@ -79,9 +79,8 @@ // TODO: rename this to draw text void Font_Handler::draw_string (RenderTarget & dst, - const std::string & font, - const int size, - const RGBColor fg, const RGBColor bg, + const std::string & fontname, + const int fontsize, const RGBColor fg, const RGBColor bg, Point dstpoint, const std::string & text, const Align align, @@ -90,7 +89,7 @@ uint * const widget_cache_id, const int caret) { - TTF_Font* f = m_font_loader->get_font(font,size); + TTF_Font & font = *m_font_loader->get_font(fontname, fontsize); //Width and height of text, needed for alignment uint w, h; uint picid; @@ -100,7 +99,7 @@ _Cache_Infos ci = { 0, text, - f, + &font, fg, bg, 0, @@ -121,10 +120,11 @@ } else { //not cached, create a new surface - ci.surface_id = create_text_surface(f, fg, bg, text, align, wrap, caret); + ci.surface_id = + create_text_surface(font, fg, bg, text, align, wrap, caret); // Now cache it g_gr->get_picture_size(ci.surface_id, ci.w, ci.h); - ci.f = f; + ci.f = &font; m_cache.push_front (ci); while( m_cache.size() > CACHE_ARRAY_SIZE) { @@ -146,7 +146,8 @@ else { if (widget_cache == Widget_Cache_Update) g_gr->free_surface(*widget_cache_id); - *widget_cache_id = create_text_surface(f, fg, bg, text, align, wrap,caret); + *widget_cache_id = + create_text_surface(font, fg, bg, text, align, wrap, caret); g_gr->get_picture_size(*widget_cache_id, w, h); picid = *widget_cache_id; } @@ -157,40 +158,47 @@ /* * Creates a Widelands surface of the given text, checks if multiline or not */ -uint Font_Handler::create_text_surface(TTF_Font* f, RGBColor fg, RGBColor bg, - std::string text, Align align, int wrap, int caret) { - SDL_Surface *surface = (wrap > 0 ? create_static_long_text_surface(f, fg, bg, text, align, wrap, 0, caret) - : create_single_line_text_surface(f, fg, bg, text, align, caret)); - return convert_sdl_surface(surface); +uint Font_Handler::create_text_surface +(TTF_Font & f, const RGBColor fg, const RGBColor bg, + const std::string & text, const Align align, const int wrap, + const int caret) +{ + return convert_sdl_surface + (*(wrap > 0 ? + create_static_long_text_surface(f, fg, bg, text, align, wrap, 0, caret) + : + create_single_line_text_surface(f, fg, bg, text, align, caret))); } /* * This function renders a short (single line) text surface */ SDL_Surface* Font_Handler::create_single_line_text_surface -(TTF_Font* f, RGBColor fg, RGBColor bg, std::string text, Align, int caret) +(TTF_Font & font, const RGBColor fg, const RGBColor bg, + std::string text, const Align, + const int caret) { // render this block in a SDL Surface SDL_Color sdl_fg = { fg.r(), fg.g(), fg.b(),0 }; SDL_Color sdl_bg = { bg.r(), bg.g(), bg.b(),0 }; - SDL_Surface *surface; - if( !text.size() ) text = " "; - if (!(surface = TTF_RenderUTF8_Shaded(f, text.c_str(), sdl_fg, sdl_bg))) { + if + (SDL_Surface * const surface = TTF_RenderUTF8_Shaded + (&font, text.c_str(), sdl_fg, sdl_bg)) + { + if (caret != -1) { + std::string text_caret_pos = text.substr(0,caret); + render_caret(font, *surface, text_caret_pos); + } + return surface; + } else { log("Font_Handler::create_single_line_text_surface, an error : %s\n", TTF_GetError()); log("Text was: '%s'\n", text.c_str()); return 0; // This will skip this line hopefully } - - if (caret != -1) { - std::string text_caret_pos = text.substr(0,caret); - render_caret(f,surface,text_caret_pos); - } - - return surface; } /* @@ -200,8 +208,12 @@ * This function also completly ignores vertical alignement * Horizontal alignment is now recognized correctly */ -SDL_Surface* Font_Handler::create_static_long_text_surface(TTF_Font* f, RGBColor fg, RGBColor bg, - std::string text, Align align, int wrap, int line_spacing, int caret) { +SDL_Surface* Font_Handler::create_static_long_text_surface +(TTF_Font & font, + const RGBColor fg, const RGBColor bg, + std::string text, const Align align, const int wrap, const int line_spacing, + int caret) +{ assert( wrap > 0); assert( text.size() > 0 ); @@ -210,7 +222,7 @@ std::vector<SDL_Surface*> m_rendered_lines; std::vector<std::string> lines; - text = word_wrap_text(f,text,wrap); + text = word_wrap_text(font, text, wrap); split_string(text, &lines, "\n"); SDL_Color sdl_fg = { fg.r(), fg.g(), fg.b(),0 }; @@ -225,20 +237,16 @@ line = " "; // render this block in a SDL Surface - SDL_Surface *surface; - - if (!(surface = TTF_RenderUTF8_Shaded(f, line.c_str(),sdl_fg,sdl_bg))) { - log("Font_Handler::create_static_long_text_surface, an error : %s\n", TTF_GetError()); - log("Text was: %s\n", text.c_str()); - continue; // Ignore this line - } - + if + (SDL_Surface * const surface = TTF_RenderUTF8_Shaded + (&font, line.c_str(),sdl_fg,sdl_bg)) + { uint new_text_pos = cur_text_pos + line.size(); if (caret != -1) { if (new_text_pos >= caret - i) { int caret_line_pos = caret - cur_text_pos - i; std::string text_caret_pos = line.substr(0,caret_line_pos); - render_caret(f,surface,text_caret_pos); + render_caret(font, *surface, text_caret_pos); caret = -1; } else { @@ -251,6 +259,13 @@ global_surface_height += surface->h + line_spacing; if( global_surface_width < surface->w) global_surface_width = surface->w; + } else { + log + ("Font_Handler::create_static_long_text_surface, an error : %s\n", + TTF_GetError()); + log("Text was: %s\n", text.c_str()); + } + } // blit all this together in one Surface @@ -258,10 +273,14 @@ } -void Font_Handler::render_caret(TTF_Font *f, SDL_Surface *line, const std::string &text_caret_pos) { +void Font_Handler::render_caret +(TTF_Font & font, + SDL_Surface & line, + const std::string & text_caret_pos) +{ int caret_x,caret_y; - TTF_SizeUTF8(f, text_caret_pos.c_str(), &caret_x, &caret_y); + TTF_SizeUTF8(&font, text_caret_pos.c_str(), &caret_x, &caret_y); Surface* caret_surf = static_cast<const GraphicImpl * const>(g_gr)->get_picture_surface @@ -272,7 +291,7 @@ r.x = caret_x - caret_surf_sdl->w; r.y = (caret_y - caret_surf_sdl->h) / 2; - SDL_BlitSurface(caret_surf_sdl, 0, line, &r); + SDL_BlitSurface(caret_surf_sdl, 0, &line, &r); } /* @@ -280,19 +299,32 @@ * Richtext works with this method, because whole richtext content * is blit into one big surface by the richtext widget itself */ -SDL_Surface* Font_Handler::draw_string_sdl_surface(std::string font, int size, RGBColor fg, RGBColor bg, std::string text, Align align, int wrap, int style, int line_spacing) { - TTF_Font* f = m_font_loader->get_font(font,size); - TTF_SetFontStyle(f,style); - return create_sdl_text_surface(f,fg,bg,text,align,wrap,line_spacing); +SDL_Surface* Font_Handler::draw_string_sdl_surface +(const std::string & fontname, const int fontsize, + const RGBColor fg, const RGBColor bg, + const std::string & text, + const Align align, const int wrap, const int style, const int line_spacing) +{ + TTF_Font & font = *m_font_loader->get_font(fontname, fontsize); + TTF_SetFontStyle(&font, style); + return create_sdl_text_surface + (font, fg, bg, text, align, wrap, line_spacing); } /* * Creates the SDL surface, checks if multiline or not */ -SDL_Surface* Font_Handler::create_sdl_text_surface(TTF_Font* f, RGBColor fg, RGBColor bg, - std::string text, Align align, int wrap, int line_spacing) { - return (wrap > 0 ? create_static_long_text_surface(f, fg, bg, text, align, wrap, line_spacing) - : create_single_line_text_surface(f, fg, bg, text, align)); +SDL_Surface* Font_Handler::create_sdl_text_surface +(TTF_Font & font, const RGBColor fg, const RGBColor bg, + const std::string & text, + const Align align, const int wrap, const int line_spacing) +{ + return + (wrap > 0 ? + create_static_long_text_surface + (font, fg, bg, text, align, wrap, line_spacing) + : + create_single_line_text_surface(font, fg, bg, text, align)); } //draws richtext, specified by blocks @@ -517,8 +549,8 @@ } SDL_FreeSurface(block_images); } - SDL_Surface* global_surface = join_sdl_surfaces(wrap, global_h, rend_blocks, bg); - picid = convert_sdl_surface(global_surface); + picid = convert_sdl_surface + (*join_sdl_surfaces(wrap, global_h, rend_blocks, bg)); *widget_cache_id = picid; } dst.blit(dstpoint, picid); @@ -598,12 +630,13 @@ /* * Converts a SDLSurface in a widelands one */ -uint Font_Handler::convert_sdl_surface( SDL_Surface* surface ) { - Surface* surf = new Surface(); - SDL_SetColorKey( surface, SDL_SRCCOLORKEY, SDL_MapRGB( surface->format, 107,87,55 )); - surf->set_sdl_surface( surface ); +uint Font_Handler::convert_sdl_surface(SDL_Surface & surface) { + Surface & surf = *new Surface(); + SDL_SetColorKey + (&surface, SDL_SRCCOLORKEY, SDL_MapRGB(surface.format, 107, 87, 55)); + surf.set_sdl_surface(surface); - uint picid = g_gr->get_picture(PicMod_Font, surf ); + uint picid = g_gr->get_picture(PicMod_Font, surf); return picid; } @@ -643,7 +676,9 @@ //Inserts linebreaks into a text, so it doesn't get bigger than max_width when rendered //Method taken from Wesnoth. //http://www.wesnoth.org -std::string Font_Handler::word_wrap_text(TTF_Font* f, const std::string &unwrapped_text, int max_width) { +std::string Font_Handler::word_wrap_text +(TTF_Font & font, const std::string & unwrapped_text, const int max_width) +{ //std::cerr << "Wrapping word " << unwrapped_text << "\n"; std::string wrapped_text; // the final result @@ -674,13 +709,13 @@ // Test if the line should be wrapped or not std::string tmp_str = cur_line + cur_word; - if (calc_linewidth(f,tmp_str) > max_width) { - if (calc_linewidth(f,cur_word) > (max_width /*/ 2*/)) { + if (calc_linewidth(font, tmp_str) > max_width) { + if (calc_linewidth(font, cur_word) > (max_width /*/ 2*/)) { // The last word is too big to fit in a nice way, split it on a char basis //std::vector<std::string> split_word = split_utf8_string(cur_word); for (uint i=0;i<cur_word.length();i++) { tmp_str = cur_line + cur_word[i]; - if (calc_linewidth(f, tmp_str) > max_width) { + if (calc_linewidth(font, tmp_str) > max_width) { wrapped_text += cur_line + '\n'; cur_line = ""; } @@ -713,8 +748,12 @@ return wrapped_text; } -std::string Font_Handler::word_wrap_text(std::string font, int size, const std::string &unwrapped_text,int max_width) { - return word_wrap_text(m_font_loader->get_font(font,size),unwrapped_text,max_width); +std::string Font_Handler::word_wrap_text +(const std::string & fontname, const int fontsize, + const std::string & unwrapped_text, const int max_width) +{ + return word_wrap_text + (*m_font_loader->get_font(fontname,fontsize), unwrapped_text, max_width); } //removes a leading spacer @@ -727,11 +766,15 @@ } //calculates size of a given text -void Font_Handler::get_size(std::string font, int size, std::string text, int *w, int *h, int wrap) { - TTF_Font* f = m_font_loader->get_font(font,size); +void Font_Handler::get_size +(const std::string & fontname, const int fontsize, + std::string text, + int *w, int *h, int wrap) +{ + TTF_Font & font = *m_font_loader->get_font(fontname, fontsize); if (wrap > 0) - text = word_wrap_text(f,text,wrap); + text = word_wrap_text(font, text, wrap); std::vector<std::string> lines; split_string(text, &lines, "\n"); @@ -743,7 +786,7 @@ line = " "; int line_w,line_h; - TTF_SizeUTF8(f, line.c_str(), &line_w, &line_h); + TTF_SizeUTF8(&font, line.c_str(), &line_w, &line_h); if (*w < line_w) *w = line_w; @@ -752,9 +795,9 @@ } //calcultes linewidth of a given text -int Font_Handler::calc_linewidth(TTF_Font* f, std::string &text) { +int Font_Handler::calc_linewidth(TTF_Font & font, const std::string & text) { int w,h; - TTF_SizeText(f, text.c_str(), &w, &h); + TTF_SizeText(&font, text.c_str(), &w, &h); return w; } Modified: trunk/src/font_handler.h =================================================================== --- trunk/src/font_handler.h 2007-03-25 20:08:46 UTC (rev 2161) +++ trunk/src/font_handler.h 2007-03-26 20:54:34 UTC (rev 2162) @@ -84,12 +84,20 @@ const Widget_Cache widget_cache = Widget_Cache_None, uint * const widget_cache_id = 0, const int caret = -1); - void get_size(std::string font, int size, std::string text, int *w, int *h, int wrap = -1); - int calc_linewidth(TTF_Font* f, std::string &text); + void get_size + (const std::string & fontname, const int size, + std::string text, + int *w, int *h, int wrap = -1); + int calc_linewidth(TTF_Font &, const std::string & text); uint get_fontheight(const std::string & name, const int size); std::string remove_first_space(const std::string &text); - std::string word_wrap_text(TTF_Font* f, const std::string &unwrapped_text, int max_width); - std::string word_wrap_text(std::string font, int size, const std::string &unwrapped_text,int max_width); + std::string word_wrap_text + (TTF_Font &, + const std::string & unwrapped_text, + const int max_width); + std::string word_wrap_text + (const std::string & font, const int size, + const std::string & unwrapped_text,const int max_width); void do_align(Align align, int *dstx, int *dsty, int w, int h); // This deletes all cached pictures, it is called // from the graphics code before the graphics are flushed, @@ -114,7 +122,7 @@ struct _Cache_Infos { uint surface_id; std::string str; - TTF_Font* f; + const TTF_Font * f; RGBColor fg; RGBColor bg; uint w; @@ -137,12 +145,31 @@ void* m_cbdata; private: - uint create_text_surface( TTF_Font* f, RGBColor fg, RGBColor bg, std::string text, Align align, int wrap, int caret = -1); - uint convert_sdl_surface( SDL_Surface* ); - SDL_Surface* draw_string_sdl_surface(std::string font, int size, RGBColor fg, RGBColor bg, std::string text, Align align, int wrap, int style = TTF_STYLE_NORMAL, int line_spacing = 0); - SDL_Surface* create_sdl_text_surface( TTF_Font* f, RGBColor fg, RGBColor bg, std::string text, Align align, int wrap, int line_spacing = 0); - SDL_Surface* create_static_long_text_surface( TTF_Font* f, RGBColor fg, RGBColor bg, std::string text, Align align, int wrap, int line_spacing = 0, int caret = -1); - SDL_Surface* create_single_line_text_surface( TTF_Font* f, RGBColor fg, RGBColor bg, std::string text, Align align, int caret = -1); + uint create_text_surface + (TTF_Font &, + const RGBColor fg, const RGBColor bg, + const std::string & text, const Align, const int wrap, + const int caret = -1); + uint convert_sdl_surface(SDL_Surface &); + SDL_Surface * draw_string_sdl_surface + (const std::string & fontname, const int fontsize, + const RGBColor fg, const RGBColor bg, + const std::string & text, + const Align align, const int wrap, const int style = TTF_STYLE_NORMAL, + const int line_spacing = 0); + SDL_Surface* create_sdl_text_surface + (TTF_Font &, const RGBColor fg, const RGBColor bg, + const std::string & text, + const Align align, const int wrap, const int line_spacing = 0); + SDL_Surface * create_static_long_text_surface + (TTF_Font &, const RGBColor fg, const RGBColor bg, + std::string text, + const Align align, const int wrap, const int line_spacing = 0, + const int caret = -1); + SDL_Surface* create_single_line_text_surface + (TTF_Font &, const RGBColor fg, const RGBColor bg, + std::string text, + const Align align, const int caret = -1); SDL_Surface* create_empty_sdl_surface(uint w, uint h); SDL_Surface* join_sdl_surfaces (const uint w, const uint h, @@ -154,7 +181,10 @@ const bool keep_surfaces = false); SDL_Surface* load_image(std::string file); SDL_Surface* render_space(Text_Block &block, RGBColor bg, int style = TTF_STYLE_NORMAL); - void render_caret(TTF_Font *f, SDL_Surface *line, const std::string &text_caret_pos); + void render_caret + (TTF_Font &, + SDL_Surface & line, + const std::string & text_caret_pos); }; extern Font_Handler* g_fh; // the default font Modified: trunk/src/graphic.cc =================================================================== --- trunk/src/graphic.cc 2007-03-25 20:08:46 UTC (rev 2161) +++ trunk/src/graphic.cc 2007-03-26 20:54:34 UTC (rev 2162) @@ -959,11 +959,11 @@ if (!sdlsurface) throw wexception("Couldn't set video mode: %s", SDL_GetError()); - assert( sdlsurface->format->BytesPerPixel == 2 || sdlsurface->format->BytesPerPixel == 4 ); + assert(sdlsurface->format->BytesPerPixel == 2 || sdlsurface->format->BytesPerPixel == 4); SDL_WM_SetCaption("Widelands " BUILD_ID, "Widelands"); - m_screen.set_sdl_surface( sdlsurface ); + m_screen.set_sdl_surface(*sdlsurface); m_rendertarget = new RenderTargetImpl(&m_screen); } @@ -1191,13 +1191,9 @@ } // Convert the surface accordingly - SDL_Surface* use_surface = SDL_DisplayFormatAlpha( bmp ); + SDL_Surface & use_surface = *SDL_DisplayFormatAlpha(bmp); SDL_FreeSurface(bmp); - if (not use_surface) throw wexception - ("GraphicImpl::get_picture(): no success in converting loaded surface!" - "\n"); - // Fill in a free slot in the pictures array id = find_free_picture(); Picture & pic = m_pictures[id]; @@ -1215,12 +1211,13 @@ return id; } -uint GraphicImpl::get_picture(int mod, Surface* surf, const char* fname ) +uint GraphicImpl::get_picture +(const int mod, Surface & surf, const char * const fname) { const std::vector<Picture>::size_type id = find_free_picture(); Picture & pic = m_pictures[id]; pic.mod = mod; - pic.surface = surf; + pic.surface = &surf; if (fname) { pic.u.fname = strdup(fname); m_picturemap[fname] = id; @@ -1264,11 +1261,13 @@ */ uint GraphicImpl::create_surface(int w, int h) { + const SDL_PixelFormat & format = m_screen.format(); + SDL_Surface & surf = *SDL_CreateRGBSurface + (SDL_SWSURFACE, + w, h, + format.BitsPerPixel, + format.Rmask, format.Gmask, format.Bmask, format.Amask); - SDL_Surface* surf = SDL_CreateRGBSurface( SDL_SWSURFACE, w, h, m_screen.get_format()->BitsPerPixel, - m_screen.get_format()->Rmask, m_screen.get_format()->Gmask, m_screen.get_format()->Bmask, - m_screen.get_format()->Amask); - const std::vector<Picture>::size_type id = find_free_picture(); Picture & pic = m_pictures[id]; pic.mod = -1; // mark as surface @@ -1355,18 +1354,16 @@ These textures are freed when PicMod_Game is flushed. =============== */ -uint GraphicImpl::get_maptexture(const char* fnametempl, uint frametime) +uint GraphicImpl::get_maptexture(const char & fnametempl, const uint frametime) { try { - Texture* tex = new Texture(fnametempl, frametime, m_screen.get_format()); - - m_maptextures.push_back(tex); - - return m_maptextures.size(); // ID 1 is at m_maptextures[0] + m_maptextures.push_back + (new Texture(fnametempl, frametime, m_screen.format())); } catch(std::exception& e) { - log("Failed to load maptexture %s: %s\n", fnametempl, e.what()); + log("Failed to load maptexture %s: %s\n", &fnametempl, e.what()); return 0; } + return m_maptextures.size(); // ID 1 is at m_maptextures[0] } @@ -1518,8 +1515,7 @@ Save a screenshot in the given file. =============== */ -void GraphicImpl::screenshot(const char* fname) -{ +void GraphicImpl::screenshot(const char & fname) const { // TODO: this is incorrect; it bypasses the files code m_screen.save_bmp(fname); } @@ -1597,7 +1593,10 @@ uint i = 0; for( uint x = 0; x < surf->get_w(); x++ ) { uchar r, g, b, a; - SDL_GetRGBA( surf->get_pixel(x,y), surf->get_format(), &r, &g, &b, &a); + SDL_GetRGBA + (surf->get_pixel(x, y), + &const_cast<SDL_PixelFormat &>(surf->format()), + &r, &g, &b, &a); row[i+0] = r; row[i+1] = g; row[i+2] = b; Modified: trunk/src/graphic.h =================================================================== --- trunk/src/graphic.h 2007-03-25 20:08:46 UTC (rev 2161) +++ trunk/src/graphic.h 2007-03-26 20:54:34 UTC (rev 2162) @@ -61,13 +61,16 @@ virtual void flush(int mod) = 0; virtual uint get_picture(int mod, const char* fname) = 0; virtual void get_picture_size(const uint pic, uint & w, uint & h) = 0; - virtual uint get_picture(int mod, Surface*, const char* name = 0 ) = 0; + virtual uint get_picture + (const int mod, Surface &, const char * const name = 0) + = 0; virtual void save_png(uint, FileWrite* )=0; virtual uint create_surface(int w, int h) = 0; virtual void free_surface(uint pic) = 0; virtual RenderTarget* get_surface_renderer(uint pic) = 0; - virtual uint get_maptexture(const char* fnametempl, uint frametime) = 0; + virtual uint get_maptexture(const char & fnametempl, const uint frametime) + = 0; virtual void animate_maptextures(uint time) = 0; virtual void reset_texture_animation_reminder( void ) = 0; @@ -77,7 +80,7 @@ (const uint anim, const uint time, uint & w, uint & h) = 0; - virtual void screenshot(const char* fname) = 0; + virtual void screenshot(const char & fname) const = 0; virtual const char* get_maptexture_picture (uint id) = 0; }; Modified: trunk/src/graphic_impl.h =================================================================== --- trunk/src/graphic_impl.h 2007-03-25 20:08:46 UTC (rev 2161) +++ trunk/src/graphic_impl.h 2007-03-26 20:54:34 UTC (rev 2162) @@ -62,27 +62,41 @@ ~Surface( void ) { if( m_surface ) SDL_FreeSurface( m_surface ); m_surface = 0; } // Set surface, only call once - void set_sdl_surface( SDL_Surface* surface ) { m_surface = surface; m_w = m_surface->w; m_h = m_surface->h; } + void set_sdl_surface(SDL_Surface & surface) throw() + {m_surface = &surface; m_w = m_surface->w; m_h = m_surface->h;} SDL_Surface* get_sdl_surface() { return m_surface; } // Get width and height - inline uint get_w( void ) { return m_w; } - inline uint get_h( void ) { return m_h; } + uint get_w() const throw () {return m_w;} + uint get_h() const throw () {return m_h;} void update( void ); // Save a bitmap of this to a file - void save_bmp( const char* fname ); + void save_bmp(const char & fname) const; // For the bravest: Direct Pixel access. Use carefully void force_disable_alpha( void ); // Needed if you want to blit directly to the screen by memcpy - inline SDL_PixelFormat* get_format() { assert(m_surface); return m_surface->format; } - inline ushort get_pitch( void ) { assert(m_surface); return m_surface->pitch; } + const SDL_PixelFormat * get_format() const + throw () + {return m_surface->format;} + const SDL_PixelFormat & format() const throw () + {assert(m_surface); return *m_surface->format;} + ushort get_pitch() const throw () {return m_surface->pitch;} void * get_pixels() { assert(m_surface); return static_cast<uchar * const>(m_surface->pixels) + m_offsy*m_surface->pitch + m_offsx*m_surface->format->BytesPerPixel; } + const void * get_pixels() const throw () { + assert(m_surface); + return + static_cast<uchar * const>(m_surface->pixels) + + + m_offsy * m_surface->pitch + + + m_offsx * m_surface->format->BytesPerPixel; + } // Lock inline void lock( void ) { if( SDL_MUSTLOCK( m_surface )) SDL_LockSurface( m_surface ); } @@ -183,7 +197,6 @@ class Colormap { // friend class Texture; -private: SDL_Color palette[256]; void * colormap; // maps 8 bit color and brightness value to the shaded color // NOTE: brightness is currently 8 bits. Restricting brightness @@ -191,7 +204,7 @@ // table, and thus improve memory cache impact inside the renderer. public: - Colormap (const SDL_Color*, SDL_PixelFormat* fmt); + Colormap (const SDL_Color &, const SDL_PixelFormat & fmt); ~Colormap (); SDL_Color* get_palette() { return palette; } @@ -221,7 +234,8 @@ bool m_was_animated; public: - Texture (const char* fnametempl, uint frametime, SDL_PixelFormat*); + Texture + (const char & fnametempl, const uint frametime, const SDL_PixelFormat &); ~Texture (); inline const char* get_texture_picture(void) { return m_texture_picture.c_str(); } @@ -358,7 +372,7 @@ Surface* get_picture_surface(uint id); // Map textures - virtual uint get_maptexture(const char* fnametempl, uint frametime); + virtual uint get_maptexture(const char & fnametempl, const uint frametime); virtual void animate_maptextures(uint time); virtual void reset_texture_animation_reminder( void ); Texture* get_maptexture_data(uint id); @@ -374,9 +388,9 @@ (const uint anim, const uint time, uint & w, uint & h); // Misc functions - virtual void screenshot(const char* fname); + virtual void screenshot(const char & fname) const; - virtual uint get_picture(int mod, Surface* surf, const char* = 0 ); + virtual uint get_picture(const int mod, Surface &, const char * const = 0); virtual const char* get_maptexture_picture(uint id); private: Modified: trunk/src/render.cc =================================================================== --- trunk/src/render.cc 2007-03-25 20:08:46 UTC (rev 2161) +++ trunk/src/render.cc 2007-03-26 20:54:34 UTC (rev 2162) @@ -63,9 +63,9 @@ /* * Save a bitmap */ -void Surface::save_bmp( const char* fname ) { +void Surface::save_bmp(const char & fname) const { assert( m_surface ); - SDL_SaveBMP( m_surface, fname ); + SDL_SaveBMP(m_surface, &fname); } /* @@ -93,7 +93,7 @@ assert(rc.y >= 0); assert(rc.w >= 1); assert(rc.h >= 1); - ulong color = clr.map( get_format() ); + const ulong color = clr.map(format()); const Point bl = rc.bottom_left() - Point(1, 1); @@ -121,7 +121,7 @@ assert(rc.y >= 0); assert(rc.w >= 1); assert(rc.h >= 1); - ulong color = clr.map( get_format() ); + const ulong color = clr.map(format()); SDL_Rect r = { rc.x, rc.y, rc.w, rc.h }; SDL_FillRect( m_surface, &r, color); @@ -194,12 +194,16 @@ /* * Blend to colors; only needed for calc_minimap_color below */ -static inline ulong blend_color( SDL_PixelFormat* fmt, ulong clr1, uchar r2, uchar g2, uchar b2 ) { - uchar r1, g1, b1; - - SDL_GetRGB( clr1, fmt, &r1, &g1, &b1); - - return SDL_MapRGB( fmt, (r1 + r2) >> 1, ( g1 + g2 ) >> 1, ( b1 + b2 ) >> 1 ); +static inline ulong blend_color +(const SDL_PixelFormat & format, + const ulong clr1, + const Uint8 r2, const Uint8 g2, const Uint8 b2) +{ + Uint8 r1, g1, b1; + SDL_GetRGB(clr1, &const_cast<SDL_PixelFormat &>(format), &r1, &g1, &b1); + return SDL_MapRGB + (&const_cast<SDL_PixelFormat &>(format), + (r1 + r2) / 2, (g1 + g2) / 2, (b1 + b2) / 2); } /* @@ -210,7 +214,7 @@ =============== */ static inline ulong calc_minimap_color -(SDL_PixelFormat * const fmt, +(const SDL_PixelFormat & format, const Editor_Game_Base & egbase, const FCoords f, const uint flags) @@ -233,7 +237,7 @@ // ...and add the player's color to the old color. pixelcolor = blend_color - (fmt, + (format, pixelcolor, playercolors[3].r(), playercolors[3].g(), playercolors[3].b()); } @@ -242,14 +246,15 @@ const PlayerImmovable * const immovable = dynamic_cast<const PlayerImmovable * const>(f.field->get_immovable()); if (flags & MiniMap::Roads and dynamic_cast<const Road * const>(immovable)) - pixelcolor = blend_color(fmt, pixelcolor, 255, 255, 255 ); + pixelcolor = blend_color(format, pixelcolor, 255, 255, 255); if ((flags & MiniMap::Flags and dynamic_cast<const Flag * const>(immovable)) or (flags & MiniMap::Bldns and dynamic_cast<const Building * const>(immovable))) - pixelcolor = SDL_MapRGB( fmt, 255, 255, 255 ); + pixelcolor = SDL_MapRGB + (&const_cast<SDL_PixelFormat &>(format), 255, 255, 255); return pixelcolor; @@ -260,10 +265,10 @@ } template<typename T> -void draw_minimap_int +static void draw_minimap_int (Uint8 * const pixels, const ushort pitch, - SDL_PixelFormat * const fmt, + const SDL_PixelFormat & format, const uint mapwidth, const Editor_Game_Base & egbase, const std::vector<bool> & visibility, @@ -282,15 +287,15 @@ move_r(mapwidth, f, i); *reinterpret_cast<T * const>(pix) = static_cast<const T> (not visibility[i] ? - 0 : calc_minimap_color(fmt, egbase, f, flags)); + 0 : calc_minimap_color(format, egbase, f, flags)); } } } template<typename T> -void draw_minimap_int +static void draw_minimap_int (Uint8 * const pixels, const ushort pitch, - SDL_PixelFormat * const fmt, + const SDL_PixelFormat & format, const uint mapwidth, const Editor_Game_Base & egbase, const Rect rc, @@ -307,7 +312,7 @@ for (uint x = 0; x < rc.w; ++x, pix += sizeof(T)) { move_r(mapwidth, f, i); *reinterpret_cast<T * const>(pix) = static_cast<const T> - (calc_minimap_color(fmt, egbase, f, flags)); + (calc_minimap_color(format, egbase, f, flags)); } } } @@ -329,16 +334,15 @@ { Uint8 * const pixels = static_cast<Uint8 * const>(get_pixels()); const ushort pitch = get_pitch(); - SDL_PixelFormat * const fmt = get_format(); const X_Coordinate w = egbase.map().get_width(); - switch (fmt->BytesPerPixel) { + switch (format().BytesPerPixel) { case sizeof(Uint16): draw_minimap_int<Uint16> - (pixels, pitch, fmt, w, egbase, visibility, rc, viewpt, flags); + (pixels, pitch, format(), w, egbase, visibility, rc, viewpt, flags); break; case sizeof(Uint32): draw_minimap_int<Uint32> - (pixels, pitch, fmt, w, egbase, visibility, rc, viewpt, flags); + (pixels, pitch, format(), w, egbase, visibility, rc, viewpt, flags); break; default: assert (false); } @@ -351,16 +355,15 @@ { Uint8 * const pixels = static_cast<Uint8 * const>(get_pixels()); const ushort pitch = get_pitch(); - SDL_PixelFormat * const fmt = get_format(); const X_Coordinate w = egbase.map().get_width(); - switch (fmt->BytesPerPixel) { + switch (format().BytesPerPixel) { case sizeof(Uint16): draw_minimap_int<Uint16> - (pixels, pitch, fmt, w, egbase, rc, viewpoint, flags); + (pixels, pitch, format(), w, egbase, rc, viewpoint, flags); break; case sizeof(Uint32): draw_minimap_int<Uint32> - (pixels, pitch, fmt, w, egbase, rc, viewpoint, flags); + (pixels, pitch, format(), w, egbase, rc, viewpoint, flags); break; default: assert (false); } @@ -401,17 +404,15 @@ m_plrframes = new std::vector<Surface*>[MAX_PLAYERS+1]; std::vector<Surface*> frames; - for(;;) { + for(;;) { char fname[256]; int nr = frames.size(); char *p; - bool done=false; bool alldone=false; bool cycling=false; - for(int i=0; i<nextensions; i++) { - if(done) continue; + for (uint i = 0; i < nextensions; ++i) { // create the file name by reverse-scanning for '?' and replacing nr=frames.size(); @@ -440,9 +441,13 @@ // Load the image SDL_Surface* bmp = 0; - try - { - bmp = LoadImage(fname); + try { + SDL_Surface & bmp = *LoadImage(fname); + + // Get a new AnimFrame + Surface* frame = new Surface(); + frames.push_back( frame ); + frame->set_sdl_surface(bmp); } catch(std::exception& e) { @@ -450,12 +455,7 @@ continue; } - // Get a new AnimFrame - Surface* frame = new Surface(); - frames.push_back( frame ); - frame->set_sdl_surface( bmp ); - done=true; if(!cycling) alldone=true; } @@ -503,38 +503,37 @@ for( uint i = 0; i < m_plrframes[0].size(); i++ ) { // Copy the old surface - Surface* origsurface = m_plrframes[0][i]; - SDL_Surface* tempsurface = SDL_ConvertSurface(origsurface->m_surface, - origsurface->get_format(), SDL_HWSURFACE | SDL_SRCALPHA ); - Surface* newsurface = new Surface(); - newsurface->set_sdl_surface( tempsurface ); + Surface & origsurface = *m_plrframes[0][i]; + SDL_Surface & tempsurface = *SDL_ConvertSurface + (origsurface.m_surface, + &const_cast<SDL_PixelFormat &>(origsurface.format()), + SDL_HWSURFACE | SDL_SRCALPHA); + Surface & newsurface = *new Surface(); + newsurface.set_sdl_surface(tempsurface); + const SDL_PixelFormat & format = newsurface.format(); - ulong plrclr1 = m_encodedata.plrclr[0].map( newsurface->get_format()); - ulong plrclr2 = m_encodedata.plrclr[1].map( newsurface->get_format()); - ulong plrclr3 = m_encodedata.plrclr[2].map( newsurface->get_format()); - ulong plrclr4 = m_encodedata.plrclr[3].map( newsurface->get_format()); + ulong plrclr1 = m_encodedata.plrclr[0].map(format); + ulong plrclr2 = m_encodedata.plrclr[1].map(format); + ulong plrclr3 = m_encodedata.plrclr[2].map(format); + ulong plrclr4 = m_encodedata.plrclr[3].map(format); - ulong new_plrclr1 = plrclrs[0].map( newsurface->get_format()); - ulong new_plrclr2 = plrclrs[1].map( newsurface->get_format()); - ulong new_plrclr3 = plrclrs[2].map( newsurface->get_format()); - ulong new_plrclr4 = plrclrs[3].map( newsurface->get_format()); + ulong new_plrclr1 = plrclrs[0].map(format); + ulong new_plrclr2 = plrclrs[1].map(format); + ulong new_plrclr3 = plrclrs[2].map(format); + ulong new_plrclr4 = plrclrs[3].map(format); // Walk the surface, replace all playercolors - for( uint y = 0; y < newsurface->get_h(); y++) { - for( uint x = 0; x < newsurface->get_w(); x++) { - ulong clr = newsurface->get_pixel(x,y); - if( clr == plrclr1 ) - newsurface->set_pixel( x, y, new_plrclr1 ); - else if( clr == plrclr2 ) - newsurface->set_pixel( x, y, new_plrclr2 ); - else if( clr == plrclr3 ) - newsurface->set_pixel( x, y, new_plrclr3 ); - else if( clr == plrclr4 ) - newsurface->set_pixel( x, y, new_plrclr4 ); + for (uint y = 0; y < newsurface.get_h(); ++y) { + for (uint x = 0; x < newsurface.get_w(); ++x) { + const ulong clr = newsurface.get_pixel(x, y); + if (clr == plrclr1) newsurface.set_pixel(x, y, new_plrclr1); + else if (clr == plrclr2) newsurface.set_pixel(x, y, new_plrclr2); + else if (clr == plrclr3) newsurface.set_pixel(x, y, new_plrclr3); + else if (clr == plrclr4) newsurface.set_pixel(x, y, new_plrclr4); } } // Add to the framse - frames.push_back( newsurface ); + frames.push_back(&newsurface); } } Modified: trunk/src/rgbcolor.h =================================================================== --- trunk/src/rgbcolor.h 2007-03-25 20:08:46 UTC (rev 2161) +++ trunk/src/rgbcolor.h 2007-03-26 20:54:34 UTC (rev 2162) @@ -45,8 +45,8 @@ Uint8 g() const throw () {return SDL_Color::g;} Uint8 b() const throw () {return SDL_Color::b;} - ulong map(SDL_PixelFormat * const fmt) const throw () - {return SDL_MapRGB(fmt, r(), g(), b());} + ulong map(const SDL_PixelFormat & fmt) const throw () + {return SDL_MapRGB(&const_cast<SDL_PixelFormat &>(fmt), r(), g(), b());} void set(SDL_PixelFormat * const fmt, ulong clr) throw () {SDL_GetRGB(clr, fmt, &(SDL_Color::r), &(SDL_Color::g), &(SDL_Color::b));} Modified: trunk/src/terrain.cc =================================================================== --- trunk/src/terrain.cc 2007-03-25 20:08:46 UTC (rev 2161) +++ trunk/src/terrain.cc 2007-03-26 20:54:34 UTC (rev 2162) @@ -46,14 +46,13 @@ * Create a new Colormap, taking the palette as a parameter. * It automatically creates the colormap for shading. */ -Colormap::Colormap (const SDL_Color *pal, SDL_PixelFormat* fmt) -{ +Colormap::Colormap (const SDL_Color & pal, const SDL_PixelFormat & format) { int i,j,r,g,b; - memcpy(palette, pal, sizeof(palette)); + memcpy(palette, &pal, sizeof(palette)); - assert(fmt->BytesPerPixel == 2 or fmt->BytesPerPixel == 4); - colormap = malloc(fmt->BytesPerPixel * 65536); + assert(format.BytesPerPixel == 2 or format.BytesPerPixel == 4); + colormap = malloc(format.BytesPerPixel * 65536); // log ("Creating color map\n"); for (i=0;i<256;i++) @@ -69,8 +68,9 @@ if (g>255) g=255; if (b>255) b=255; - const Uint32 value = SDL_MapRGB(fmt, r, g, b); - if (fmt->BytesPerPixel == 2) + const Uint32 value = + SDL_MapRGB(&const_cast<SDL_PixelFormat &>(format), r, g, b); + if (format.BytesPerPixel == 2) static_cast<Uint16 * const>(colormap)[(j << 8) | i] = value; else static_cast<Uint32 * const>(colormap)[(j << 8) | i] = value; @@ -102,13 +102,16 @@ * Currently it converts a 16 bit pic to a 8 bit texture. This should * be changed to load a 8 bit file directly, however. */ -Texture::Texture (const char* fnametmpl, uint frametime, SDL_PixelFormat* screenfmt) +Texture::Texture +(const char & fnametmpl, + const uint frametime, + const SDL_PixelFormat & format) { m_colormap = 0; m_nrframes = 0; m_pixels = 0; m_frametime = frametime; - is_32bit = screenfmt->BytesPerPixel == 4; + is_32bit = format.BytesPerPixel == 4; // Load the pictures one by one char fname[256]; @@ -118,7 +121,7 @@ char *p; // create the file name by reverse-scanning for '?' and replacing - snprintf(fname, sizeof(fname), "%s", fnametmpl); + snprintf(fname, sizeof(fname), "%s", &fnametmpl); p = fname + strlen(fname); while(p > fname) { if (*--p != '?') @@ -159,7 +162,7 @@ // Determine color map if it's the first frame if (!m_nrframes) { if (surf->format->BitsPerPixel == 8) - m_colormap = new Colormap(surf->format->palette->colors, screenfmt); + m_colormap = new Colormap(*surf->format->palette->colors, format); else { SDL_Color pal[256]; @@ -173,7 +176,7 @@ pal[(r<<5) | (g<<2) | b].b=b<<6; } - m_colormap = new Colormap(pal, screenfmt); + m_colormap = new Colormap(*pal, format); } } @@ -208,7 +211,7 @@ } if (!m_nrframes) - throw wexception("%s: texture has no frames", fnametmpl); + throw wexception("%s: texture has no frames", &fnametmpl); } @@ -282,8 +285,7 @@ mu=-u2/det; } -template<typename T> -void render_top_triangle +template<typename T> static void render_top_triangle (Surface & dst, const Texture & tex, Vertex & p1, Vertex & p2, Vertex & p3, @@ -370,8 +372,7 @@ } } -template<typename T> -void render_bottom_triangle +template<typename T> static void render_bottom_triangle (Surface & dst, const Texture & tex, Vertex & p1, Vertex & p2, Vertex & p3, @@ -471,8 +472,7 @@ * render_bottom_triangle, which require a horizontal edge at the bottom * or at the top, respectively. */ -template<typename T> -void render_triangle +template<typename T> static void render_triangle (Surface & dst, Vertex & p1, Vertex & p2, Vertex & p3, const Texture & tex) { Vertex * p[3]= {&p1, &p2, &p3}; @@ -532,8 +532,7 @@ #define DITHER_RAND_MASK (DITHER_WIDTH * 2 - 1) #define DITHER_RAND_SHIFT (16 / DITHER_WIDTH) -template<typename T> -void dither_edge_horiz +template<typename T> static void dither_edge_horiz (Surface & dst, const Vertex & start, const Vertex & end, const Texture & ttex, const Texture & btex) @@ -609,8 +608,7 @@ } -template<typename T> -static void dither_edge_vert +template<typename T> static void dither_edge_vert (Surface & dst, const Vertex & start, const Vertex & end, const Texture & ltex, const Texture & rtex) @@ -704,11 +702,11 @@ Render a road. =============== */ -template<typename T> -void render_road_horiz(Surface* dst, const Point& start, const Point& end, Surface* src ) +template<typename T> static void render_road_horiz +(Surface & dst, const Point start, const Point end, const Surface & src) { - int dstw = dst->get_w(); - int dsth = dst->get_h(); + int dstw = dst.get_w(); + int dsth = dst.get_h(); int ydiff = ((end.y - start.y) << 16) / (end.x - start.x); int centery = start.y << 16; @@ -719,22 +717,26 @@ int y = (centery >> 16) - 2; - for(int i = 0; i < 5; i++, y++) { - if (y < 0 || y >= dsth) - continue; - - T * const dpix = reinterpret_cast<T * const>(static_cast<uchar * const>(dst->get_pixels()) + y * dst->get_pitch()) + x; - T * const spix = reinterpret_cast<T * const>(static_cast<uchar * const>(src->get_pixels()) + i * src->get_pitch()) + sx; - *dpix = *spix; - } + for(int i = 0; i < 5; i++, y++) if (0 < y and y < dsth) + *(reinterpret_cast<T * const> + (static_cast<uchar * const>(dst.get_pixels()) + y * dst.get_pitch()) + + + x) + = + *(reinterpret_cast<const T * const> + (static_cast<const uchar * const>(src.get_pixels()) + + + i * src.get_pitch()) + + + sx); } } -template<typename T> -void render_road_vert(Surface* dst, const Point& start, const Point& end, Surface* src) +template<typename T> static void render_road_vert +(Surface & dst, const Point start, const Point end, const Surface & src) { - int dstw = dst->get_w(); - int dsth = dst->get_h(); + int dstw = dst.get_w(); + int dsth = dst.get_h(); int xdiff = ((end.x - start.x) << 16) / (end.y - start.y); int centerx = start.x << 16; @@ -745,15 +747,18 @@ int x = (centerx >> 16) - 2; - for(int i = 0; i < 5; i++, x++) { - if (x < 0 || x >= dstw) - continue; - - - T * const dpix = reinterpret_cast<T * const>(static_cast<uchar *>(dst->get_pixels()) + y * dst->get_pitch()) + x; - T * const spix = reinterpret_cast<T * const>(static_cast<uchar *>(src->get_pixels()) + sy * src->get_pitch()) + i; - *dpix = *spix; - } + for(int i = 0; i < 5; i++, x++) if (0 < x and x < dstw) + *(reinterpret_cast<T * const> + (static_cast<uchar * const>(dst.get_pixels()) + y * dst.get_pitch()) + + + x) + = + *(reinterpret_cast<const T * const> + (static_cast<const uchar * const>(src.get_pixels()) + + + sy * src.get_pitch()) + + + i); } } @@ -791,8 +796,8 @@ Vertex bl_vert (blposx, blposy - bl->get_height() * HEIGHT_FACTOR, bl_brightness, 64, 64); - Surface* rt_normal = get_graphicimpl()->get_road_texture(Road_Normal); - Surface* rt_busy = get_graphicimpl()->get_road_texture(Road_Busy); + const Surface & rt_normal = *get_graphicimpl()->get_road_texture(Road_Normal); + const Surface & rt_busy = *get_graphicimpl()->get_road_texture(Road_Busy); if( draw_all ) { render_triangle<T> (dst, r_vert, f_vert, br_vert, f_r_texture); @@ -812,10 +817,10 @@ if (road) { switch(road) { case Road_Normal: - render_road_horiz<T> (&dst, f_vert, r_vert, rt_normal); + render_road_horiz<T> (dst, f_vert, r_vert, rt_normal); break; case Road_Busy: - render_road_horiz<T> (&dst, f_vert, r_vert, rt_busy); + render_road_horiz<T> (dst, f_vert, r_vert, rt_busy); break; default: assert(false); break; // never here } @@ -835,10 +840,10 @@ if (road) { switch(road) { case Road_Normal: - render_road_vert<T> (&dst, f_vert, br_vert, rt_normal); + render_road_vert<T> (dst, f_vert, br_vert, rt_normal); break; case Road_Busy: - render_road_vert<T> (&dst, f_vert, br_vert, rt_busy); + render_road_vert<T> (dst, f_vert, br_vert, rt_busy); break; default: assert(0); break; // never here @@ -859,10 +864,10 @@ if (road) { switch(road) { case Road_Normal: - render_road_vert<T> (&dst, f_vert, bl_vert, rt_normal); + render_road_vert<T> (dst, f_vert, bl_vert, rt_normal); break; case Road_Busy: - render_road_vert<T> (&dst, f_vert, bl_vert, rt_busy); + render_road_vert<T> (dst, f_vert, bl_vert, rt_busy); break; default: assert(0); break; // never here Modified: trunk/src/widelands_map_extradata_data_packet.cc =================================================================== --- trunk/src/widelands_map_extradata_data_packet.cc 2007-03-25 20:08:46 UTC (rev 2161) +++ trunk/src/widelands_map_extradata_data_packet.cc 2007-03-26 20:54:34 UTC (rev 2162) @@ -74,13 +74,14 @@ SDL_Surface* surf = IMG_Load_RW(SDL_RWFromMem(fr.Data(0), fr.GetSize()), 1); if (!surf) continue; // Illegal pic. Skip it - Surface* picsurf = new Surface( ); - picsurf->set_sdl_surface( surf ); + Surface & picsurf = *new Surface(); + picsurf.set_sdl_surface(*surf); std::string picname = FileSystem::FS_Filename( (*pname).c_str() ); picname = "map:" + picname; - uint data = g_gr->get_picture( PicMod_Game, picsurf, picname.c_str()); + const uint data = + g_gr->get_picture(PicMod_Game, picsurf, picname.c_str()); // ok, the pic is now known to the game. But when the game is saved, this data has to be // regenerated. Modified: trunk/src/wlapplication.cc =================================================================== --- trunk/src/wlapplication.cc 2007-03-25 20:08:46 UTC (rev 2161) +++ trunk/src/wlapplication.cc 2007-03-26 20:54:34 UTC (rev 2162) @@ -584,7 +584,7 @@ snprintf(buf, sizeof(buf), "shot%04i.bmp", nr); if (g_fs->FileExists(buf)) continue; - g_gr->screenshot(buf); + g_gr->screenshot(*buf); break; } } Modified: trunk/src/world.cc =================================================================== --- trunk/src/world.cc 2007-03-25 20:08:46 UTC (rev 2161) +++ trunk/src/world.cc 2007-03-26 20:54:34 UTC (rev 2162) @@ -506,5 +506,5 @@ void Terrain_Descr::load_graphics() { if (m_picnametempl) - m_texture = g_gr->get_maptexture(m_picnametempl, m_frametime); + m_texture = g_gr->get_maptexture(*m_picnametempl, m_frametime); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |