From 922a7b7dc9b723968ceae7ed696506f92f505717 Mon Sep 17 00:00:00 2001 From: Kp Date: Sun, 25 Jan 2015 05:32:44 +0000 Subject: [PATCH] Pass grs_main_bitmap to iff_read_animbrush --- common/include/iff.h | 2 +- d1x-rebirth/main/bmread.cpp | 2 +- d2x-rebirth/main/bmread.cpp | 2 +- similar/main/iff.cpp | 17 ++++++++--------- similar/main/multi.cpp | 2 +- similar/main/piggy.cpp | 2 +- 6 files changed, 13 insertions(+), 14 deletions(-) diff --git a/common/include/iff.h b/common/include/iff.h index dc5e6f53a..ff3497513 100644 --- a/common/include/iff.h +++ b/common/include/iff.h @@ -55,7 +55,7 @@ int iff_read_into_bitmap(const char *ifilename,grs_bitmap *bm, palette_array_t * //read in animator brush (.abm) file //fills in array of pointers, and n_bitmaps. //returns iff error codes. max_bitmaps is size of array. -int iff_read_animbrush(const char *ifilename,array, MAX_BITMAPS_PER_BRUSH> &bm,unsigned *n_bitmaps,palette_array_t &palette); +int iff_read_animbrush(const char *ifilename,array, MAX_BITMAPS_PER_BRUSH> &bm,unsigned *n_bitmaps,palette_array_t &palette); // After a read extern ubyte iff_transparent_color; diff --git a/d1x-rebirth/main/bmread.cpp b/d1x-rebirth/main/bmread.cpp index 87a1ad01c..1ddb48e40 100644 --- a/d1x-rebirth/main/bmread.cpp +++ b/d1x-rebirth/main/bmread.cpp @@ -232,7 +232,7 @@ static void ab_load(int skip, const char * filename, array, MAX_BITMAPS_PER_BRUSH> bm; + array, MAX_BITMAPS_PER_BRUSH> bm; iff_error = iff_read_animbrush(filename,bm,nframes,newpal); if (iff_error != IFF_NO_ERROR) { Error("File %s - IFF error: %s",filename,iff_errormsg(iff_error)); diff --git a/d2x-rebirth/main/bmread.cpp b/d2x-rebirth/main/bmread.cpp index d4e27c8cf..cf9725166 100644 --- a/d2x-rebirth/main/bmread.cpp +++ b/d2x-rebirth/main/bmread.cpp @@ -252,7 +252,7 @@ static void ab_load(int skip, const char * filename, bitmap_index bmp[], unsigne // Note that last argument passes an address to the array newpal (which is a pointer). // type mismatch found using lint, will substitute this line with an adjusted // one. If fatal error, then it can be easily changed. - array, MAX_BITMAPS_PER_BRUSH> bm; + array, MAX_BITMAPS_PER_BRUSH> bm; iff_error = iff_read_animbrush(filename,bm,nframes,newpal); if (iff_error != IFF_NO_ERROR) { Error("File <%s> - IFF error: %s, line %d",filename,iff_errormsg(iff_error),linenum); diff --git a/similar/main/iff.cpp b/similar/main/iff.cpp index 611ab6371..43ca9df36 100644 --- a/similar/main/iff.cpp +++ b/similar/main/iff.cpp @@ -490,11 +490,9 @@ static int convert_rgb15(grs_bitmap *bm,iff_bitmap_header *bmheader) palette_array_t::iterator palptr = begin(bmheader->palette); #if defined(DXX_BUILD_DESCENT_I) - gr_init_bitmap(*bm, bm->bm_type, 0, 0, bm->bm_w, bm->bm_h, bm->bm_rowsize, 0); - for (int y=0; ybm_h; y++) { for (int x=0; xw; x++) - gr_bm_pixel(*bm, x, y, INDEX_TO_15BPP(bmheader->raw_data[y*bmheader->w+x])); + gr_bm_pixel(*bm, x, y, INDEX_TO_15BPP(bm->get_bitmap_data()[y*bmheader->w+x])); } #elif defined(DXX_BUILD_DESCENT_II) ushort *new_data; @@ -506,7 +504,7 @@ static int convert_rgb15(grs_bitmap *bm,iff_bitmap_header *bmheader) for (int y=0; ybm_h; y++) { for (int x=0; xw; x++) - new_data[newptr++] = INDEX_TO_15BPP(bmheader->raw_data[y*bmheader->w+x]); + new_data[newptr++] = INDEX_TO_15BPP(bm->get_bitmap_data()[y*bmheader->w+x]); } @@ -522,7 +520,7 @@ static int convert_rgb15(grs_bitmap *bm,iff_bitmap_header *bmheader) //copy an iff header structure to a grs_bitmap structure static void copy_iff_to_grs(grs_bitmap *bm,iff_bitmap_header *bmheader) { - gr_init_bitmap(*bm, bmheader->type, 0, 0, bmheader->w, bmheader->h, bmheader->w, bmheader->raw_data); + gr_init_bitmap(*bm, bmheader->type, 0, 0, bmheader->w, bmheader->h, bmheader->w, bmheader->raw_data.release()); } //if bm->bm_data is set, use it (making sure w & h are correct), else @@ -920,7 +918,7 @@ int iff_write_bitmap(const char *ofilename,grs_bitmap *bm,palette_array_t *palet //read in many brushes. fills in array of pointers, and n_bitmaps. //returns iff error codes -int iff_read_animbrush(const char *ifilename,array, MAX_BITMAPS_PER_BRUSH> &bm_list,unsigned *n_bitmaps,palette_array_t &palette) +int iff_read_animbrush(const char *ifilename,array, MAX_BITMAPS_PER_BRUSH> &bm_list,unsigned *n_bitmaps,palette_array_t &palette) { int ret = IFF_NO_ERROR; //return code int sig,form_len; @@ -953,10 +951,11 @@ int iff_read_animbrush(const char *ifilename,array, prev_bm = *n_bitmaps>0?bm_list[*n_bitmaps-1].get() : nullptr; - bm_list[*n_bitmaps] = make_unique(); - gr_init_bitmap_data(*bm_list[*n_bitmaps].get()); + auto &n = bm_list[*n_bitmaps]; + n = make_unique(); + gr_init_bitmap_data(*n.get()); - ret = iff_parse_bitmap(ifile,bm_list[*n_bitmaps].get(),form_type,*n_bitmaps>0 ? nullptr : &palette,prev_bm); + ret = iff_parse_bitmap(ifile, n.get(), form_type, *n_bitmaps > 0 ? nullptr : &palette, prev_bm); if (ret != IFF_NO_ERROR) goto done; diff --git a/similar/main/multi.cpp b/similar/main/multi.cpp index bb0f5d362..f4ec54786 100644 --- a/similar/main/multi.cpp +++ b/similar/main/multi.cpp @@ -5017,7 +5017,7 @@ void save_hoard_data(void) auto ofile = PHYSFSX_openWriteBuffered("hoard.ham"); - array, MAX_BITMAPS_PER_BRUSH> bm; + array, MAX_BITMAPS_PER_BRUSH> bm; iff_error = iff_read_animbrush("orb.abm",bm,&nframes,palette); Assert(iff_error == IFF_NO_ERROR); PHYSFS_writeULE16(ofile, nframes); diff --git a/similar/main/piggy.cpp b/similar/main/piggy.cpp index 8eddaee6a..46a3d3701 100644 --- a/similar/main/piggy.cpp +++ b/similar/main/piggy.cpp @@ -840,7 +840,7 @@ void piggy_new_pigfile(char *pigname) sprintf( abmname, "%s.abm", basename ); - array, MAX_BITMAPS_PER_BRUSH> bm; + array, MAX_BITMAPS_PER_BRUSH> bm; iff_error = iff_read_animbrush(abmname,bm,&nframes,newpal); if (iff_error != IFF_NO_ERROR) {