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 | |
parent | 05d33ff0f45fce64889b18bc95818fe1610839ad (diff) | |
download | mana-3fcbf718bcf5c937fa62c31abb13dacc606f3893.tar.gz mana-3fcbf718bcf5c937fa62c31abb13dacc606f3893.tar.bz2 mana-3fcbf718bcf5c937fa62c31abb13dacc606f3893.tar.xz mana-3fcbf718bcf5c937fa62c31abb13dacc606f3893.zip |
Pretty much fix the segfault by removing the copying and not unloading the
datafile. Not sure what was wrong exactly though.
-rw-r--r-- | src/graphic/image.h | 15 | ||||
-rw-r--r-- | src/log.cpp | 2 |
2 files changed, 8 insertions, 9 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); } }; diff --git a/src/log.cpp b/src/log.cpp index 578fa957..ecc54aea 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -85,7 +85,7 @@ void error(const string error_text) { #ifdef WIN32 MessageBox(NULL, error_text.c_str(), "Error", MB_ICONERROR|MB_OK); #else - fprintf(stderr, "Error: %s\n", error_text); + fprintf(stderr, "Error: %s\n", error_text.c_str()); #endif exit(1); } |