# HG changeset patch # User glx # Date 1218838018 0 # Node ID e6abeb1fc804f7cfc4b5ba58b4b2a283564b92b5 # Parent 329dcdbf283a7fce4c3332379acc41c61f51271b (svn r14080) -Fix (r14052): assert triggered when drawing chat window with 32bpp-anim blitter (backup buffer was too small) diff -r 329dcdbf283a -r e6abeb1fc804 src/blitter/32bpp_anim.hpp --- a/src/blitter/32bpp_anim.hpp Fri Aug 15 19:18:55 2008 +0000 +++ b/src/blitter/32bpp_anim.hpp Fri Aug 15 22:06:58 2008 +0000 @@ -34,6 +34,7 @@ /* virtual */ Blitter::PaletteAnimation UsePaletteAnimation(); /* virtual */ const char *GetName() { return "32bpp-anim"; } + /* virtual */ int GetBytesPerPixel() { return 5; } template void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom); }; diff -r 329dcdbf283a -r e6abeb1fc804 src/blitter/32bpp_base.hpp --- a/src/blitter/32bpp_base.hpp Fri Aug 15 19:18:55 2008 +0000 +++ b/src/blitter/32bpp_base.hpp Fri Aug 15 22:06:58 2008 +0000 @@ -26,6 +26,7 @@ /* virtual */ int BufferSize(int width, int height); /* virtual */ void PaletteAnimate(uint start, uint count); /* virtual */ Blitter::PaletteAnimation UsePaletteAnimation(); + /* virtual */ int GetBytesPerPixel() { return 4; } /** * Compose a colour based on RGB values. diff -r 329dcdbf283a -r e6abeb1fc804 src/blitter/8bpp_base.hpp --- a/src/blitter/8bpp_base.hpp Fri Aug 15 19:18:55 2008 +0000 +++ b/src/blitter/8bpp_base.hpp Fri Aug 15 22:06:58 2008 +0000 @@ -25,6 +25,7 @@ /* virtual */ int BufferSize(int width, int height); /* virtual */ void PaletteAnimate(uint start, uint count); /* virtual */ Blitter::PaletteAnimation UsePaletteAnimation(); + /* virtual */ int GetBytesPerPixel() { return 1; } }; #endif /* BLITTER_8BPP_BASE_HPP */ diff -r 329dcdbf283a -r e6abeb1fc804 src/blitter/base.hpp --- a/src/blitter/base.hpp Fri Aug 15 19:18:55 2008 +0000 +++ b/src/blitter/base.hpp Fri Aug 15 22:06:58 2008 +0000 @@ -183,10 +183,15 @@ virtual Blitter::PaletteAnimation UsePaletteAnimation() = 0; /** - * Get the naem of the blitter, the same as the Factory-instance returns. + * Get the name of the blitter, the same as the Factory-instance returns. */ virtual const char *GetName() = 0; + /** + * Get how many bytes are needed to store a pixel. + */ + virtual int GetBytesPerPixel() = 0; + virtual ~Blitter() { } }; diff -r 329dcdbf283a -r e6abeb1fc804 src/blitter/null.hpp --- a/src/blitter/null.hpp Fri Aug 15 19:18:55 2008 +0000 +++ b/src/blitter/null.hpp Fri Aug 15 22:06:58 2008 +0000 @@ -28,6 +28,7 @@ /* virtual */ Blitter::PaletteAnimation UsePaletteAnimation() { return Blitter::PALETTE_ANIMATION_NONE; }; /* virtual */ const char *GetName() { return "null"; } + /* virtual */ int GetBytesPerPixel() { return 0; } }; class FBlitter_Null: public BlitterFactory { diff -r 329dcdbf283a -r e6abeb1fc804 src/network/network_chat_gui.cpp --- a/src/network/network_chat_gui.cpp Fri Aug 15 19:18:55 2008 +0000 +++ b/src/network/network_chat_gui.cpp Fri Aug 15 22:06:58 2008 +0000 @@ -119,7 +119,7 @@ _chatmsg_box.y = 30; _chatmsg_box.width = _settings_client.gui.network_chat_box_width; _chatmsg_box.height = _settings_client.gui.network_chat_box_height * NETWORK_CHAT_LINE_HEIGHT; - _chatmessage_backup = ReallocT(_chatmessage_backup, _chatmsg_box.width * _chatmsg_box.height * sizeof(uint32)); + _chatmessage_backup = ReallocT(_chatmessage_backup, _chatmsg_box.width * _chatmsg_box.height * BlitterFactoryBase::GetCurrentBlitter()->GetBytesPerPixel()); for (uint i = 0; i < MAX_CHAT_MESSAGES; i++) { _chatmsg_list[i].message[0] = '\0'; @@ -224,7 +224,7 @@ } if (width <= 0 || height <= 0) return; - assert(blitter->BufferSize(width, height) < (int)(_chatmsg_box.width * _chatmsg_box.height * sizeof(uint32))); + assert(blitter->BufferSize(width, height) <= (int)(_chatmsg_box.width * _chatmsg_box.height * blitter->GetBytesPerPixel())); /* Make a copy of the screen as it is before painting (for undraw) */ blitter->CopyToBuffer(blitter->MoveTo(_screen.dst_ptr, x, y), _chatmessage_backup, width, height);