diff options
author | Kari Salminen | 2008-08-11 21:45:47 +0000 |
---|---|---|
committer | Kari Salminen | 2008-08-11 21:45:47 +0000 |
commit | 8aaba9d38e8a0c2259cf7617bb1b07c725a49b0b (patch) | |
tree | cd190d9883871bbfbc6964368f22a9af327c5e4c | |
parent | d6dde4b85f3f32fe0f602270b9223eaa299db91c (diff) | |
download | scummvm-rg350-8aaba9d38e8a0c2259cf7617bb1b07c725a49b0b.tar.gz scummvm-rg350-8aaba9d38e8a0c2259cf7617bb1b07c725a49b0b.tar.bz2 scummvm-rg350-8aaba9d38e8a0c2259cf7617bb1b07c725a49b0b.zip |
Changed palPtr from a pointer to a Common::Array named palArray. Removed palEntriesCount variable as it's now equivalent to palArray.size().
svn-id: r33785
-rw-r--r-- | engines/cine/cine.cpp | 2 | ||||
-rw-r--r-- | engines/cine/pal.cpp | 36 | ||||
-rw-r--r-- | engines/cine/pal.h | 2 |
3 files changed, 14 insertions, 26 deletions
diff --git a/engines/cine/cine.cpp b/engines/cine/cine.cpp index cf33b2c186..5e0506c286 100644 --- a/engines/cine/cine.cpp +++ b/engines/cine/cine.cpp @@ -73,8 +73,6 @@ CineEngine::~CineEngine() { freeErrmessDat(); } Common::clearAllSpecialDebugLevels(); - - free(palPtr); } int CineEngine::init() { diff --git a/engines/cine/pal.cpp b/engines/cine/pal.cpp index 3e6f5adf40..7f6307c640 100644 --- a/engines/cine/pal.cpp +++ b/engines/cine/pal.cpp @@ -28,10 +28,7 @@ namespace Cine { -uint16 palEntriesCount; - -PalEntry *palPtr = NULL; - +Common::Array<PalEntry> palArray; static byte paletteBuffer1[16]; static byte paletteBuffer2[16]; @@ -41,27 +38,20 @@ void loadPal(const char *fileName) { removeExtention(buffer, fileName); strcat(buffer, ".PAL"); - - if (palPtr) { - free(palPtr); - palPtr = NULL; - } - - palEntriesCount = 0; + palArray.clear(); Common::File palFileHandle; if (!palFileHandle.open(buffer)) error("loadPal(): Cannot open file %s", fileName); - palEntriesCount = palFileHandle.readUint16LE(); + uint16 palEntriesCount = palFileHandle.readUint16LE(); palFileHandle.readUint16LE(); // entry size - palPtr = (PalEntry *)malloc(palEntriesCount * sizeof(PalEntry)); - assert(palPtr); - for (int i = 0; i < palEntriesCount; ++i) { - palFileHandle.read(palPtr[i].name, 10); - palFileHandle.read(palPtr[i].pal1, 16); - palFileHandle.read(palPtr[i].pal2, 16); + palArray.resize(palEntriesCount); + for (uint i = 0; i < palArray.size(); ++i) { + palFileHandle.read(palArray[i].name, 10); + palFileHandle.read(palArray[i].pal1, 16); + palFileHandle.read(palArray[i].pal2, 16); } palFileHandle.close(); } @@ -81,8 +71,8 @@ int16 findPaletteFromName(const char *fileName) { position++; } - for (i = 0; i < palEntriesCount; i++) { - if (!strcmp(buffer, palPtr[i].name)) { + for (i = 0; i < palArray.size(); i++) { + if (!strcmp(buffer, palArray[i].name)) { return i; } } @@ -105,9 +95,9 @@ void loadRelatedPalette(const char *fileName) { paletteBuffer1[i] = paletteBuffer2[i] = (i << 4) + i; } } else { - assert(paletteIndex < palEntriesCount); - memcpy(paletteBuffer1, palPtr[paletteIndex].pal1, 16); - memcpy(paletteBuffer2, palPtr[paletteIndex].pal2, 16); + assert(paletteIndex < (int32)palArray.size()); + memcpy(paletteBuffer1, palArray[paletteIndex].pal1, 16); + memcpy(paletteBuffer2, palArray[paletteIndex].pal2, 16); } } diff --git a/engines/cine/pal.h b/engines/cine/pal.h index 768cf0d27d..819680973c 100644 --- a/engines/cine/pal.h +++ b/engines/cine/pal.h @@ -34,7 +34,7 @@ struct PalEntry { byte pal2[16]; }; -extern PalEntry *palPtr; +extern Common::Array<PalEntry> palArray; void loadPal(const char *fileName); |