Page 1 of 1

Game Client Crash. (Part 2!)

Posted: 22 Aug 2006, 14:32
by Pauan
(I apologize in advance to Bjorn if this post is too long. :wink: )

Thanks to Bjorn's advice and help, I got the debug client working. Lo and behold... it crashed! My guess is that I'm missing some sort of graphic file (tile, sprite, etc.) that somebody put in, but I never got. Either way, here is the code:

Code: Select all

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1219119424 (LWP 27004)]
0x080e6299 in Graphics::drawImage (this=0x8133918, image=0x0, x=448, y=288)
    at graphics.cpp:123
123     graphics.cpp: No such file or directory.
        in graphics.cpp
(gdb) bt
#0  0x080e6299 in Graphics::drawImage (this=0x8133918, image=0x0, x=448, y=288)
    at graphics.cpp:123
#1  0x080e1d86 in FloorItem::draw (this=0x8334d70, graphics=0x8133918,
    offsetX=-544, offsetY=-1248) at floor_item.h:93
#2  0x080ef2ef in Map::draw (this=0x822ca70, graphics=0x8133918, scrollX=544,
    scrollY=1248, layer=1) at map.cpp:135
#3  0x080df5b0 in Engine::draw (this=0x81d0f60, graphics=0x8133918)
    at engine.cpp:203
#4  0x080e3bf8 in Game::logic (this=0x812e408) at game.cpp:377
#5  0x080edbc2 in main (argc=1, argv=0xbfe44914) at main.cpp:665

Posted: 24 Aug 2006, 22:54
by Bjørn
You were definately missing some graphic file (since image parameter is 0x0 for drawImage). I'm assuming you're using the trunk development version. Recently the image containing all item icons got split up, and the large set of loose images is not being installed correctly yet when doing a 'make install'.

For developers this is not really a critical issue, since they don't generally install the game but run it like 'src/tmw' instead (from the tmw dir). The game will then find everything it needs directly from the "data" directory. If you had run it like that, the debugger (gdb) also would not have had a problem finding that graphics.cpp file.

There is two things we'll need to do to resolve this issue:

* Made sure a missing item icon produces a nice error message instead of a crash.
* Fix installing of the item icons

Posted: 24 Aug 2006, 23:12
by Crush
that's odd. The drawImage function shouldn't crash when attempting to draw a "NULL image" but do nothing instead.

Code: Select all

bool Graphics::drawImage(Image *image, int srcX, int srcY, int dstX, int dstY,
        int width, int height)
{
    // Check that preconditions for blitting are met.
    if (!mScreen || !image || !image->mImage) return false;
[...]

Posted: 24 Aug 2006, 23:21
by Bjørn
Crush wrote:that's odd. The drawImage function shouldn't crash when attempting to draw a "NULL image" but do nothing instead.
There's multiple versions of drawImage. Check the line number in the crash and you can see the crash was in this one (and note mBounds accessing):

Code: Select all

bool Graphics::drawImage(Image *image, int x, int y)
{
    return drawImage(image, 0, 0, x, y, image->mBounds.w, image->mBounds.h);
}
Btw I actually think the image should not be checked for NULL since this simply hides the error, and instead the image would mysteriously fail to show up. Only valid images should be passed to drawImage.