diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2004-12-11 21:10:51 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2004-12-11 21:10:51 +0000 |
commit | 3fcbf718bcf5c937fa62c31abb13dacc606f3893 (patch) | |
tree | e1b766c3e87bda03555287acb07d94e96a293369 /src/graphic/image.h | |
parent | 05d33ff0f45fce64889b18bc95818fe1610839ad (diff) | |
download | mana-client-3fcbf718bcf5c937fa62c31abb13dacc606f3893.tar.gz mana-client-3fcbf718bcf5c937fa62c31abb13dacc606f3893.tar.bz2 mana-client-3fcbf718bcf5c937fa62c31abb13dacc606f3893.tar.xz mana-client-3fcbf718bcf5c937fa62c31abb13dacc606f3893.zip |
Pretty much fix the segfault by removing the copying and not unloading the
datafile. Not sure what was wrong exactly though.
Diffstat (limited to 'src/graphic/image.h')
-rw-r--r-- | src/graphic/image.h | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/graphic/image.h b/src/graphic/image.h index f4e5fc5d..bd3545e3 100644 --- a/src/graphic/image.h +++ b/src/graphic/image.h @@ -63,6 +63,7 @@ class SPRITESET { int i = 0; while(datafile[i].type!=DAT_END) { IMAGE *temp_image; + if(gfx_capabilities & GFX_HW_VRAM_BLIT) { BITMAP *temp_video_bitmap = create_video_bitmap(((RLE_SPRITE *)datafile[i].dat)->w, ((RLE_SPRITE *)datafile[i].dat)->h); if(temp_video_bitmap) { @@ -70,20 +71,18 @@ class SPRITESET { draw_rle_sprite(temp_video_bitmap, (RLE_SPRITE *)datafile[i].dat, 0, 0); temp_image = new VIDEO_IMAGE(temp_video_bitmap, get_property(&datafile[i], DAT_ID('X','C','R','P')), get_property(&datafile[i], DAT_ID('Y','C','R','P'))); } else { - warning("You run out of video memory"); - RLE_SPRITE *temp_rle_sprite = (RLE_SPRITE *)malloc(datafile[i].size); - memcpy(temp_rle_sprite, datafile[i].dat, datafile[i].size); - temp_image = new RLE_IMAGE(temp_rle_sprite, get_property(&datafile[i], DAT_ID('X','C','R','P')), get_property(&datafile[i], DAT_ID('Y','C','R','P'))); + warning("You ran out of video memory!"); + temp_image = new RLE_IMAGE((RLE_SPRITE*)datafile[i].dat, get_property(&datafile[i], DAT_ID('X','C','R','P')), get_property(&datafile[i], DAT_ID('Y','C','R','P'))); } } else { - RLE_SPRITE *temp_rle_sprite = (RLE_SPRITE *)malloc(datafile[i].size); - memcpy(temp_rle_sprite, datafile[i].dat, datafile[i].size); - temp_image = new RLE_IMAGE(temp_rle_sprite, get_property(&datafile[i], DAT_ID('X','C','R','P')), get_property(&datafile[i], DAT_ID('Y','C','R','P'))); + temp_image = new RLE_IMAGE((RLE_SPRITE*)datafile[i].dat, get_property(&datafile[i], DAT_ID('X','C','R','P')), get_property(&datafile[i], DAT_ID('Y','C','R','P'))); } spriteset.push_back(temp_image); i++; } - unload_datafile(datafile); + // Do not unload the datafile, instead just use the allocated memory + // directly without making copies. + //unload_datafile(datafile); } }; |