summaryrefslogtreecommitdiff
path: root/src/spriteloader
diff options
context:
space:
mode:
authorMichael Lutz <michi@icosahedron.de>2019-04-14 16:36:06 +0200
committerCharles Pigott <charlespigott@googlemail.com>2019-04-15 22:52:50 +0100
commit38729297f98f6abb154a6acd37b6c5a1b9dea134 (patch)
treef102e34858e04034090bd8c0cf6fce84da8ab70b /src/spriteloader
parent4e85ccf3c049cb508873bb8320f770c328e76513 (diff)
downloadopenttd-38729297f98f6abb154a6acd37b6c5a1b9dea134.tar.xz
Codechange: No need for AutoFreePtr if there's std::unique_ptr.
Diffstat (limited to 'src/spriteloader')
-rw-r--r--src/spriteloader/grf.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/spriteloader/grf.cpp b/src/spriteloader/grf.cpp
index b21e70b1d..4a4d7daad 100644
--- a/src/spriteloader/grf.cpp
+++ b/src/spriteloader/grf.cpp
@@ -69,8 +69,8 @@ static bool WarnCorruptSprite(uint8 file_slot, size_t file_pos, int line)
*/
bool DecodeSingleSprite(SpriteLoader::Sprite *sprite, uint8 file_slot, size_t file_pos, SpriteType sprite_type, int64 num, byte type, ZoomLevel zoom_lvl, byte colour_fmt, byte container_format)
{
- AutoFreePtr<byte> dest_orig(MallocT<byte>(num));
- byte *dest = dest_orig;
+ std::unique_ptr<byte[]> dest_orig(new byte[num]);
+ byte *dest = dest_orig.get();
const int64 dest_size = num;
/* Read the file, which has some kind of compression */
@@ -89,7 +89,7 @@ bool DecodeSingleSprite(SpriteLoader::Sprite *sprite, uint8 file_slot, size_t fi
} else {
/* Copy bytes from earlier in the sprite */
const uint data_offset = ((code & 7) << 8) | FioReadByte();
- if (dest - data_offset < dest_orig) return WarnCorruptSprite(file_slot, file_pos, __LINE__);
+ if (dest - data_offset < dest_orig.get()) return WarnCorruptSprite(file_slot, file_pos, __LINE__);
int size = -(code >> 3);
num -= size;
if (num < 0) return WarnCorruptSprite(file_slot, file_pos, __LINE__);
@@ -123,10 +123,10 @@ bool DecodeSingleSprite(SpriteLoader::Sprite *sprite, uint8 file_slot, size_t fi
}
/* Go to that row */
- dest = dest_orig + offset;
+ dest = dest_orig.get() + offset;
do {
- if (dest + (container_format >= 2 && sprite->width > 256 ? 4 : 2) > dest_orig + dest_size) {
+ if (dest + (container_format >= 2 && sprite->width > 256 ? 4 : 2) > dest_orig.get() + dest_size) {
return WarnCorruptSprite(file_slot, file_pos, __LINE__);
}
@@ -152,7 +152,7 @@ bool DecodeSingleSprite(SpriteLoader::Sprite *sprite, uint8 file_slot, size_t fi
data = &sprite->data[y * sprite->width + skip];
- if (skip + length > sprite->width || dest + length * bpp > dest_orig + dest_size) {
+ if (skip + length > sprite->width || dest + length * bpp > dest_orig.get() + dest_size) {
return WarnCorruptSprite(file_slot, file_pos, __LINE__);
}
@@ -188,7 +188,7 @@ bool DecodeSingleSprite(SpriteLoader::Sprite *sprite, uint8 file_slot, size_t fi
warning_level = 6;
}
- dest = dest_orig;
+ dest = dest_orig.get();
for (int i = 0; i < sprite->width * sprite->height; i++) {
byte *pixel = &dest[i * bpp];