diff options
author | Max Horn | 2004-08-01 10:02:41 +0000 |
---|---|---|
committer | Max Horn | 2004-08-01 10:02:41 +0000 |
commit | 4ef4583523df87d0db73aed58b5d0a4145affa2e (patch) | |
tree | f29ef61cd6d2edad5f33a9f29dcd70f41a146fa7 /saga | |
parent | 69cf6a070a927ef17932f6d4303460ed5e867668 (diff) | |
download | scummvm-rg350-4ef4583523df87d0db73aed58b5d0a4145affa2e.tar.gz scummvm-rg350-4ef4583523df87d0db73aed58b5d0a4145affa2e.tar.bz2 scummvm-rg350-4ef4583523df87d0db73aed58b5d0a4145affa2e.zip |
Oh the beauty of stack based objects: they free themselves automatically, so you don't leak them all the time (fixed 10e6 object leaks :-)
svn-id: r14417
Diffstat (limited to 'saga')
-rw-r--r-- | saga/actionmap.cpp | 18 | ||||
-rw-r--r-- | saga/actor.cpp | 6 | ||||
-rw-r--r-- | saga/animation.cpp | 211 | ||||
-rw-r--r-- | saga/font.cpp | 18 | ||||
-rw-r--r-- | saga/image.cpp | 10 | ||||
-rw-r--r-- | saga/isomap.cpp | 36 |
6 files changed, 139 insertions, 160 deletions
diff --git a/saga/actionmap.cpp b/saga/actionmap.cpp index 055a5100b5..6237d4eb03 100644 --- a/saga/actionmap.cpp +++ b/saga/actionmap.cpp @@ -66,10 +66,10 @@ int ActionMap::load(const byte * exmap_res, size_t exmap_res_len) { assert(_initialized); assert(exmap_res != NULL); - MemoryReadStream *readS = new MemoryReadStream(exmap_res, exmap_res_len); + MemoryReadStream readS(exmap_res, exmap_res_len); // Load exits - exit_ct = readS->readSint16LE(); + exit_ct = readS.readSint16LE(); if (exit_ct < 0) { return R_FAILURE; } @@ -81,12 +81,12 @@ int ActionMap::load(const byte * exmap_res, size_t exmap_res_len) { } for (i = 0; i < exit_ct; i++) { - exmap_entry[i].unknown00 = readS->readSint16LE(); - exmap_entry[i].unknown02 = readS->readSint16LE(); - exmap_entry[i].exit_scene = readS->readSint16LE(); - exmap_entry[i].unknown06 = readS->readSint16LE(); + exmap_entry[i].unknown00 = readS.readSint16LE(); + exmap_entry[i].unknown02 = readS.readSint16LE(); + exmap_entry[i].exit_scene = readS.readSint16LE(); + exmap_entry[i].unknown06 = readS.readSint16LE(); - exmap_entry[i].pt_count = readS->readSint16LE(); + exmap_entry[i].pt_count = readS.readSint16LE(); if (exmap_entry[i].pt_count < 0) { free(exmap_entry); return R_FAILURE; @@ -99,8 +99,8 @@ int ActionMap::load(const byte * exmap_res, size_t exmap_res_len) { } for (pt = 0; pt < exmap_entry[i].pt_count; pt++) { - exmap_pt_tbl[pt].x = readS->readSint16LE(); - exmap_pt_tbl[pt].y = readS->readSint16LE(); + exmap_pt_tbl[pt].x = readS.readSint16LE(); + exmap_pt_tbl[pt].y = readS.readSint16LE(); } exmap_entry[i].pt_tbl = exmap_pt_tbl; diff --git a/saga/actor.cpp b/saga/actor.cpp index a5b4d55b74..6646caeaef 100644 --- a/saga/actor.cpp +++ b/saga/actor.cpp @@ -669,7 +669,7 @@ int LoadActorSpriteIndex(R_ACTOR * actor, int si_rn, int *last_frame_p) { debug(0, "Sprite resource contains %d sprite actions.", s_action_ct); action_p = (R_ACTORACTION *)malloc(sizeof(R_ACTORACTION) * s_action_ct); - MemoryReadStream *readS = new MemoryReadStream(res_p, res_len); + MemoryReadStream readS(res_p, res_len); if (action_p == NULL) { warning("Couldn't allocate memory for sprite actions"); @@ -682,8 +682,8 @@ int LoadActorSpriteIndex(R_ACTOR * actor, int si_rn, int *last_frame_p) { for (i = 0; i < s_action_ct; i++) { for (orient = 0; orient < 4; orient++) { // Load all four orientations - action_p[i].dir[orient].frame_index = readS->readUint16LE(); - action_p[i].dir[orient].frame_count = readS->readUint16LE(); + action_p[i].dir[orient].frame_index = readS.readUint16LE(); + action_p[i].dir[orient].frame_count = readS.readUint16LE(); if (action_p[i].dir[orient].frame_index > last_frame) { last_frame = action_p[i].dir[orient].frame_index; } diff --git a/saga/animation.cpp b/saga/animation.cpp index f9b95a0f63..468fe313f0 100644 --- a/saga/animation.cpp +++ b/saga/animation.cpp @@ -363,20 +363,19 @@ int Anim::getNumFrames(const byte *anim_resource, size_t anim_resource_len, uint return R_FAILURE; } - MemoryReadStream *readS = new MemoryReadStream(anim_resource, anim_resource_len); + MemoryReadStream readS(anim_resource, anim_resource_len); - ah.magic = readS->readUint16LE(); - ah.screen_w = readS->readUint16LE(); - ah.screen_h = readS->readUint16LE(); + ah.magic = readS.readUint16LE(); + ah.screen_w = readS.readUint16LE(); + ah.screen_h = readS.readUint16LE(); - ah.unknown06 = readS->readByte(); - ah.unknown07 = readS->readByte(); - ah.nframes = readS->readByte(); + ah.unknown06 = readS.readByte(); + ah.unknown07 = readS.readByte(); + ah.nframes = readS.readByte(); if (GAME_GetGameType() == R_GAMETYPE_IHNM) { *n_frames = ah.nframes; } - delete readS; if (ah.magic == 68) { for (x = ah.nframes; x > 0; x--) { @@ -426,23 +425,21 @@ int Anim::ITE_DecodeFrame(const byte *resdata, size_t resdata_len, size_t frame_ return R_FAILURE; } - MemoryReadStream *readS = new MemoryReadStream(resdata, resdata_len); + MemoryReadStream headerReadS(resdata, resdata_len); // Read animation header - ah.magic = readS->readUint16LE(); - ah.screen_w = readS->readUint16LE(); - ah.screen_h = readS->readUint16LE(); - ah.unknown06 = readS->readByte(); - ah.unknown07 = readS->readByte(); - ah.nframes = readS->readByte(); - ah.flags = readS->readByte(); - ah.unknown10 = readS->readByte(); - ah.unknown11 = readS->readByte(); + ah.magic = headerReadS.readUint16LE(); + ah.screen_w = headerReadS.readUint16LE(); + ah.screen_h = headerReadS.readUint16LE(); + ah.unknown06 = headerReadS.readByte(); + ah.unknown07 = headerReadS.readByte(); + ah.nframes = headerReadS.readByte(); + ah.flags = headerReadS.readByte(); + ah.unknown10 = headerReadS.readByte(); + ah.unknown11 = headerReadS.readByte(); screen_w = ah.screen_w; screen_h = ah.screen_h; - delete readS; - if ((screen_w * screen_h) > buf_len) { // Buffer argument is too small to hold decoded frame, abort. warning("ITE_DecodeFrame: Buffer size inadequate"); @@ -450,13 +447,12 @@ int Anim::ITE_DecodeFrame(const byte *resdata, size_t resdata_len, size_t frame_ } // Read frame header - readS = new MemoryReadStream(resdata + frame_offset, resdata_len - frame_offset); + MemoryReadStream readS(resdata + frame_offset, resdata_len - frame_offset); // Check for frame magic byte - magic = readS->readByte(); + magic = readS.readByte(); if (magic != SAGA_FRAME_HEADER_MAGIC) { warning("ITE_DecodeFrame: Invalid frame offset"); - delete readS; return R_FAILURE; } @@ -464,13 +460,13 @@ int Anim::ITE_DecodeFrame(const byte *resdata, size_t resdata_len, size_t frame_ // endian format, but the actual RLE encoded frame data, // including the frame header, is in big endian format. - fh.x_start = readS->readUint16BE(); - fh.y_start = readS->readByte(); - readS->readByte(); /* Skip pad byte */ - fh.x_pos = readS->readUint16BE(); - fh.y_pos = readS->readUint16BE(); - fh.width = readS->readUint16BE(); - fh.height = readS->readUint16BE(); + fh.x_start = readS.readUint16BE(); + fh.y_start = readS.readByte(); + readS.readByte(); /* Skip pad byte */ + fh.x_pos = readS.readUint16BE(); + fh.y_pos = readS.readUint16BE(); + fh.width = readS.readUint16BE(); + fh.height = readS.readUint16BE(); x_start = fh.x_start; y_start = fh.y_start; @@ -480,12 +476,12 @@ int Anim::ITE_DecodeFrame(const byte *resdata, size_t resdata_len, size_t frame_ // Begin RLE decompression to output buffer do { - mark_byte = readS->readByte(); + mark_byte = readS.readByte(); switch (mark_byte) { case 0x10: // Long Unencoded Run - runcount = readS->readSint16BE(); + runcount = readS.readSint16BE(); for (i = 0; i < runcount; i++) { - data_byte = readS->readByte(); + data_byte = readS.readByte(); if (data_byte != 0) { *write_p = data_byte; } @@ -494,27 +490,26 @@ int Anim::ITE_DecodeFrame(const byte *resdata, size_t resdata_len, size_t frame_ continue; break; case 0x20: // Long encoded run - runcount = readS->readSint16BE(); - data_byte = readS->readByte(); + runcount = readS.readSint16BE(); + data_byte = readS.readByte(); for (i = 0; i < runcount; i++) { *write_p++ = data_byte; } continue; break; case 0x2F: // End of row - x_vector = readS->readSint16BE(); - new_row = readS->readByte(); + x_vector = readS.readSint16BE(); + new_row = readS.readByte(); // Set write pointer to the new draw origin write_p = buf + ((y_start + new_row) * screen_w) + x_start + x_vector; continue; break; case 0x30: // Reposition command - x_vector = readS->readSint16BE(); + x_vector = readS.readSint16BE(); write_p += x_vector; continue; break; case 0x3F: // End of frame marker - delete readS; return R_SUCCESS; break; default: @@ -534,7 +529,7 @@ int Anim::ITE_DecodeFrame(const byte *resdata, size_t resdata_len, size_t frame_ case 0x80: // 1000 0000 // Run of compressed data runcount = param_ch + 1; - data_byte = readS->readByte(); + data_byte = readS.readByte(); for (i = 0; i < runcount; i++) { *write_p++ = data_byte; } @@ -544,7 +539,7 @@ int Anim::ITE_DecodeFrame(const byte *resdata, size_t resdata_len, size_t frame_ // Uncompressed run runcount = param_ch + 1; for (i = 0; i < runcount; i++) { - data_byte = readS->readByte(); + data_byte = readS.readByte(); if (data_byte != 0) { *write_p = data_byte; } @@ -555,13 +550,11 @@ int Anim::ITE_DecodeFrame(const byte *resdata, size_t resdata_len, size_t frame_ default: // Unknown marker found - abort warning("ITE_DecodeFrame: Invalid RLE marker encountered"); - delete readS; return R_FAILURE; break; } } while (mark_byte != 63); // end of frame marker - delete readS; return R_SUCCESS; } @@ -583,7 +576,7 @@ int Anim::IHNM_DecodeFrame(byte *decode_buf, size_t decode_buf_len, const byte * size_t in_ch_offset; - MemoryReadStream *readS = new MemoryReadStream(thisf_p, thisf_len); + MemoryReadStream readS(thisf_p, thisf_len); byte *outbuf_p = decode_buf; byte *outbuf_endp = (decode_buf + decode_buf_len) - 1; @@ -596,8 +589,8 @@ int Anim::IHNM_DecodeFrame(byte *decode_buf, size_t decode_buf_len, const byte * *nextf_p = NULL; for (; cont_flag; decoded_data = 1) { - in_ch_offset = readS->pos(); - in_ch = readS->readByte(); + in_ch_offset = readS.pos(); + in_ch = readS.readByte(); switch (in_ch) { case 0x0F: // 15: Frame header { @@ -608,18 +601,18 @@ int Anim::IHNM_DecodeFrame(byte *decode_buf, size_t decode_buf_len, const byte * int param5; int param6; - if (thisf_len - readS->pos() < 13) { + if (thisf_len - readS.pos() < 13) { warning("0x%02X: Input buffer underrun", in_ch); return R_FAILURE; } - param1 = readS->readUint16BE(); - param2 = readS->readUint16BE(); - readS->readByte(); // skip 1? - param3 = readS->readUint16BE(); - param4 = readS->readUint16BE(); - param5 = readS->readUint16BE(); - param6 = readS->readUint16BE(); + param1 = readS.readUint16BE(); + param2 = readS.readUint16BE(); + readS.readByte(); // skip 1? + param3 = readS.readUint16BE(); + param4 = readS.readUint16BE(); + param5 = readS.readUint16BE(); + param6 = readS.readUint16BE(); x_origin = param1; y_origin = param2; @@ -629,7 +622,6 @@ int Anim::IHNM_DecodeFrame(byte *decode_buf, size_t decode_buf_len, const byte * if (outbuf_p > outbuf_endp) { warning("0x%02X: (0x%X) Invalid output position. (x: %d, y: %d)", in_ch, in_ch_offset, x_origin, y_origin); - delete readS; return R_FAILURE; } @@ -638,20 +630,18 @@ int Anim::IHNM_DecodeFrame(byte *decode_buf, size_t decode_buf_len, const byte * } break; case 0x10: // Long Unencoded Run - runcount = readS->readSint16BE(); - if (thisf_len - readS->pos() < runcount) { + runcount = readS.readSint16BE(); + if (thisf_len - readS.pos() < runcount) { warning("0x%02X: Input buffer underrun", in_ch); - delete readS; return R_FAILURE; } if (outbuf_remain < runcount) { warning("0x%02X: Output buffer overrun", in_ch); - delete readS; return R_FAILURE; } for (c = 0; c < runcount; c++) { - data_pixel = readS->readByte(); + data_pixel = readS.readByte(); if (data_pixel != 0) { *outbuf_p = data_pixel; } @@ -662,26 +652,24 @@ int Anim::IHNM_DecodeFrame(byte *decode_buf, size_t decode_buf_len, const byte * continue; break; case 0x1F: // 31: Unusued? - if (thisf_len - readS->pos() < 3) { + if (thisf_len - readS.pos() < 3) { warning("0x%02X: Input buffer underrun", in_ch); - delete readS; return R_FAILURE; } - readS->readByte(); - readS->readByte(); - readS->readByte(); + readS.readByte(); + readS.readByte(); + readS.readByte(); continue; break; case 0x20: // Long compressed run - if (thisf_len - readS->pos() <= 3) { + if (thisf_len - readS.pos() <= 3) { warning("0x%02X: Input buffer underrun", in_ch); - delete readS; return R_FAILURE; } - runcount = readS->readSint16BE(); - data_pixel = readS->readByte(); + runcount = readS.readSint16BE(); + data_pixel = readS.readByte(); for (c = 0; c < runcount; c++) { *outbuf_p++ = data_pixel; @@ -692,29 +680,26 @@ int Anim::IHNM_DecodeFrame(byte *decode_buf, size_t decode_buf_len, const byte * break; case 0x2F: // End of row - if (thisf_len - readS->pos() <= 4) { - delete readS; + if (thisf_len - readS.pos() <= 4) { return R_FAILURE; } - x_vector = readS->readSint16BE(); - new_row = readS->readSint16BE(); + x_vector = readS.readSint16BE(); + new_row = readS.readSint16BE(); outbuf_p = decode_buf + ((y_origin + new_row) * di.logical_w) + x_origin + x_vector; outbuf_remain = (outbuf_endp - outbuf_p) + 1; continue; break; case 0x30: // Reposition command - if (thisf_len - readS->pos() < 2) { - delete readS; + if (thisf_len - readS.pos() < 2) { return R_FAILURE; } - x_vector = readS->readSint16BE(); + x_vector = readS.readSint16BE(); if (((x_vector > 0) && ((size_t) x_vector > outbuf_remain)) || (-x_vector > outbuf_p - decode_buf)) { warning("0x30: Invalid x_vector"); - delete readS; return R_FAILURE; } @@ -725,9 +710,9 @@ int Anim::IHNM_DecodeFrame(byte *decode_buf, size_t decode_buf_len, const byte * case 0x3F: // 68: Frame end marker debug(1, "0x3F: Frame end marker"); - if (decoded_data && (thisf_len - readS->pos() > 0)) { - *nextf_p = thisf_p + readS->pos(); - *nextf_len = thisf_len - readS->pos(); + if (decoded_data && (thisf_len - readS.pos() > 0)) { + *nextf_p = thisf_p + readS.pos(); + *nextf_len = thisf_len - readS.pos(); } else { *nextf_p = NULL; *nextf_len = 0; @@ -748,7 +733,6 @@ int Anim::IHNM_DecodeFrame(byte *decode_buf, size_t decode_buf_len, const byte * case 0xC0: // Run of empty pixels runcount = param_ch + 1; if (outbuf_remain < runcount) { - delete readS; return R_FAILURE; } @@ -758,12 +742,11 @@ int Anim::IHNM_DecodeFrame(byte *decode_buf, size_t decode_buf_len, const byte * break; case 0x80: // Run of compressed data runcount = param_ch + 1; - if ((outbuf_remain < runcount) || (thisf_len - readS->pos() <= 1)) { - delete readS; + if ((outbuf_remain < runcount) || (thisf_len - readS.pos() <= 1)) { return R_FAILURE; } - data_pixel = readS->readByte(); + data_pixel = readS.readByte(); for (c = 0; c < runcount; c++) { *outbuf_p++ = data_pixel; @@ -774,13 +757,12 @@ int Anim::IHNM_DecodeFrame(byte *decode_buf, size_t decode_buf_len, const byte * break; case 0x40: // Uncompressed run runcount = param_ch + 1; - if ((outbuf_remain < runcount) || (thisf_len - readS->pos() < runcount)) { - delete readS; + if ((outbuf_remain < runcount) || (thisf_len - readS.pos() < runcount)) { return R_FAILURE; } for (c = 0; c < runcount; c++) { - data_pixel = readS->readByte(); + data_pixel = readS.readByte(); if (data_pixel != 0) { *outbuf_p = data_pixel; } @@ -796,7 +778,6 @@ int Anim::IHNM_DecodeFrame(byte *decode_buf, size_t decode_buf_len, const byte * break; } } - delete readS; return R_SUCCESS; } @@ -818,18 +799,18 @@ int Anim::getFrameOffset(const byte *resdata, size_t resdata_len, uint16 find_fr return R_FAILURE; } - MemoryReadStream *readS = new MemoryReadStream(resdata, resdata_len); + MemoryReadStream readS(resdata, resdata_len); // Read animation header - ah.magic = readS->readUint16LE(); - ah.screen_w = readS->readUint16LE(); - ah.screen_h = readS->readUint16LE(); - ah.unknown06 = readS->readByte(); - ah.unknown07 = readS->readByte(); - ah.nframes = readS->readByte(); - ah.flags = readS->readByte(); - ah.unknown10 = readS->readByte(); - ah.unknown11 = readS->readByte(); + ah.magic = readS.readUint16LE(); + ah.screen_w = readS.readUint16LE(); + ah.screen_h = readS.readUint16LE(); + ah.unknown06 = readS.readByte(); + ah.unknown07 = readS.readByte(); + ah.nframes = readS.readByte(); + ah.flags = readS.readByte(); + ah.unknown10 = readS.readByte(); + ah.unknown11 = readS.readByte(); num_frames = ah.nframes; @@ -838,48 +819,47 @@ int Anim::getFrameOffset(const byte *resdata, size_t resdata_len, uint16 find_fr } for (current_frame = 1; current_frame < find_frame; current_frame++) { - magic = readS->readByte(); + magic = readS.readByte(); if (magic != SAGA_FRAME_HEADER_MAGIC) { // Frame sync failure. Magic Number not found - delete readS; return R_FAILURE; } // skip header for (i = 0; i < SAGA_FRAME_HEADER_LEN; i++) - readS->readByte(); + readS.readByte(); // For some strange reason, the animation header is in little // endian format, but the actual RLE encoded frame data, // including the frame header, is in big endian format. */ do { - mark_byte = readS->readByte(); + mark_byte = readS.readByte(); switch (mark_byte) { case 0x3F: // End of frame marker continue; break; case 0x30: // Reposition command - readS->readByte(); - readS->readByte(); + readS.readByte(); + readS.readByte(); continue; break; case 0x2F: // End of row marker - readS->readByte(); - readS->readByte(); - readS->readByte(); + readS.readByte(); + readS.readByte(); + readS.readByte(); continue; break; case 0x20: // Long compressed run marker - readS->readByte(); - readS->readByte(); - readS->readByte(); + readS.readByte(); + readS.readByte(); + readS.readByte(); continue; break; case 0x10: // (16) 0001 0000 // Long Uncompressed Run - runcount = readS->readSint16BE(); + runcount = readS.readSint16BE(); for (i = 0; i < runcount; i++) - readS->readByte(); + readS.readByte(); continue; break; default: @@ -895,14 +875,14 @@ int Anim::getFrameOffset(const byte *resdata, size_t resdata_len, uint16 find_fr break; case 0x80: // Run of compressed data - readS->readByte(); // Skip data byte + readS.readByte(); // Skip data byte continue; break; case 0x40: // Uncompressed run runcount = (mark_byte & 0x3f) + 1; for (i = 0; i < runcount; i++) - readS->readByte(); + readS.readByte(); continue; break; default: @@ -913,8 +893,7 @@ int Anim::getFrameOffset(const byte *resdata, size_t resdata_len, uint16 find_fr } while (mark_byte != 63); } - *frame_offset_p = readS->pos(); - delete readS; + *frame_offset_p = readS.pos(); return R_SUCCESS; } diff --git a/saga/font.cpp b/saga/font.cpp index 42936fd3c0..02e1a81973 100644 --- a/saga/font.cpp +++ b/saga/font.cpp @@ -118,7 +118,7 @@ int FONT_Load(uint32 font_rn, int font_id) { FontModule.err_str = "Invalid font length."; } - MemoryReadStream *readS = new MemoryReadStream(fontres_p, fontres_len); + MemoryReadStream readS(fontres_p, fontres_len); // Create new font structure font = (R_FONT *)malloc(sizeof *font); @@ -128,9 +128,9 @@ int FONT_Load(uint32 font_rn, int font_id) { } // Read font header - fh.c_height = readS->readUint16LE(); - fh.c_width = readS->readUint16LE(); - fh.row_length = readS->readUint16LE(); + fh.c_height = readS.readUint16LE(); + fh.c_width = readS.readUint16LE(); + fh.row_length = readS.readUint16LE(); debug(1, "FONT_Load(): Reading font resource..."); @@ -152,23 +152,23 @@ int FONT_Load(uint32 font_rn, int font_id) { normal_font->hdr.row_length = fh.row_length; for (c = 0; c < R_FONT_CHARCOUNT; c++) { - normal_font->fce[c].index = readS->readUint16LE(); + normal_font->fce[c].index = readS.readUint16LE(); } for (c = 0; c < R_FONT_CHARCOUNT; c++) { - nbits = normal_font->fce[c].width = readS->readByte(); + nbits = normal_font->fce[c].width = readS.readByte(); normal_font->fce[c].byte_width = GetByteLen(nbits); } for (c = 0; c < R_FONT_CHARCOUNT; c++) { - normal_font->fce[c].flag = readS->readByte(); + normal_font->fce[c].flag = readS.readByte(); } for (c = 0; c < R_FONT_CHARCOUNT; c++) { - normal_font->fce[c].tracking = readS->readByte(); + normal_font->fce[c].tracking = readS.readByte(); } - if (readS->pos() != R_FONT_DESCSIZE) { + if (readS.pos() != R_FONT_DESCSIZE) { warning("Invalid font resource size."); return R_FAILURE; } diff --git a/saga/image.cpp b/saga/image.cpp index d8b09f6f8c..a3978c43d4 100644 --- a/saga/image.cpp +++ b/saga/image.cpp @@ -64,12 +64,12 @@ int SagaEngine::decodeBGImage(const byte *image_data, size_t image_size, return R_FAILURE; } - MemoryReadStream *readS = new MemoryReadStream(image_data, image_size); + MemoryReadStream readS(image_data, image_size); - hdr.width = readS->readUint16LE(); - hdr.height = readS->readUint16LE(); - hdr.unknown4 = readS->readUint16LE(); - hdr.unknown6 = readS->readUint16LE(); + hdr.width = readS.readUint16LE(); + hdr.height = readS.readUint16LE(); + hdr.unknown4 = readS.readUint16LE(); + hdr.unknown6 = readS.readUint16LE(); RLE_data_ptr = image_data + SAGA_IMAGE_DATA_OFFSET; RLE_data_len = image_size - SAGA_IMAGE_DATA_OFFSET; diff --git a/saga/isomap.cpp b/saga/isomap.cpp index e4e7e36d14..65f7b96e1e 100644 --- a/saga/isomap.cpp +++ b/saga/isomap.cpp @@ -49,14 +49,14 @@ int ISOMAP_LoadTileset(const byte *tileres_p, size_t tileres_len) { assert((IsoModule.init) && (!IsoModule.tiles_loaded)); assert((tileres_p != NULL) && (tileres_len > 0)); - MemoryReadStream *readS = new MemoryReadStream(tileres_p, tileres_len); + MemoryReadStream readS(tileres_p, tileres_len); - readS->readUint16LE(); // skip - first_entry.tile_offset = readS->readUint16LE(); + readS.readUint16LE(); // skip + first_entry.tile_offset = readS.readUint16LE(); IsoModule.tile_ct = first_entry.tile_offset / SAGA_ISOTILE_ENTRY_LEN; - readS->seek(0); + readS.seek(0); tile_tbl = (R_ISOTILE_ENTRY *)malloc(IsoModule.tile_ct * sizeof *tile_tbl); if (tile_tbl == NULL) { @@ -64,11 +64,11 @@ int ISOMAP_LoadTileset(const byte *tileres_p, size_t tileres_len) { } for (i = 0; i < IsoModule.tile_ct; i++) { - tile_tbl[i].tile_h = readS->readByte(); - tile_tbl[i].unknown01 = readS->readByte(); - tile_tbl[i].tile_offset = readS->readUint16LE(); - tile_tbl[i].unknown04 = readS->readSint16LE(); - tile_tbl[i].unknown06 = readS->readSint16LE(); + tile_tbl[i].tile_h = readS.readByte(); + tile_tbl[i].unknown01 = readS.readByte(); + tile_tbl[i].tile_offset = readS.readUint16LE(); + tile_tbl[i].unknown04 = readS.readSint16LE(); + tile_tbl[i].unknown06 = readS.readSint16LE(); } IsoModule.tiles_loaded = 1; @@ -88,7 +88,7 @@ int ISOMAP_LoadMetaTileset(const byte *mtileres_p, size_t mtileres_len) { assert(IsoModule.init); assert((mtileres_p != NULL) && (mtileres_len > 0)); - MemoryReadStream *readS = new MemoryReadStream(mtileres_p, mtileres_len); + MemoryReadStream readS(mtileres_p, mtileres_len); mtile_ct = mtileres_len / SAGA_METATILE_ENTRY_LEN; mtile_tbl = (R_ISO_METATILE_ENTRY *)malloc(mtile_ct * sizeof *mtile_tbl); @@ -97,13 +97,13 @@ int ISOMAP_LoadMetaTileset(const byte *mtileres_p, size_t mtileres_len) { } for (ct = 0; ct < mtile_ct; ct++) { - mtile_tbl[ct].mtile_n = readS->readUint16LE(); - mtile_tbl[ct].unknown02 = readS->readSint16LE(); - mtile_tbl[ct].unknown04 = readS->readSint16LE(); - mtile_tbl[ct].unknown06 = readS->readSint16LE(); + mtile_tbl[ct].mtile_n = readS.readUint16LE(); + mtile_tbl[ct].unknown02 = readS.readSint16LE(); + mtile_tbl[ct].unknown04 = readS.readSint16LE(); + mtile_tbl[ct].unknown06 = readS.readSint16LE(); for (i = 0; i < SAGA_METATILE_SIZE; i++) { - mtile_tbl[ct].tile_tbl[i] = readS->readUint16LE(); + mtile_tbl[ct].tile_tbl[i] = readS.readUint16LE(); } } @@ -120,11 +120,11 @@ int ISOMAP_LoadMetaTileset(const byte *mtileres_p, size_t mtileres_len) { int ISOMAP_LoadMetamap(const byte *mm_res_p, size_t mm_res_len) { int i; - MemoryReadStream *readS = new MemoryReadStream(mm_res_p, mm_res_len); - IsoModule.metamap_n = readS->readSint16LE(); + MemoryReadStream readS(mm_res_p, mm_res_len); + IsoModule.metamap_n = readS.readSint16LE(); for (i = 0; i < SAGA_METAMAP_SIZE; i++) { - IsoModule.metamap_tbl[i] = readS->readUint16LE(); + IsoModule.metamap_tbl[i] = readS.readUint16LE(); } IsoModule.mm_res_p = mm_res_p; |