aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schickel2006-06-03 17:58:13 +0000
committerJohannes Schickel2006-06-03 17:58:13 +0000
commit6cfb416d44b04960b2ddc304641f873a71085a31 (patch)
treed45089ad99419abb0551a0fe47ae0397d9f4d626
parent680d309a3145a47ce1f845c9048248337e0013ad (diff)
downloadscummvm-rg350-6cfb416d44b04960b2ddc304641f873a71085a31.tar.gz
scummvm-rg350-6cfb416d44b04960b2ddc304641f873a71085a31.tar.bz2
scummvm-rg350-6cfb416d44b04960b2ddc304641f873a71085a31.zip
- Replaces usage of PAKChunk* with PAKChunk for Common::List, should solve some strange MSVC6 warnings/(errors).
svn-id: r22900
-rw-r--r--engines/kyra/resource.cpp42
-rw-r--r--engines/kyra/resource.h4
2 files changed, 20 insertions, 26 deletions
diff --git a/engines/kyra/resource.cpp b/engines/kyra/resource.cpp
index fe597105bd..42a194a7b0 100644
--- a/engines/kyra/resource.cpp
+++ b/engines/kyra/resource.cpp
@@ -265,7 +265,7 @@ bool Resource::fileHandle(const char *file, uint32 *size, Common::File &filehand
///////////////////////////////////////////
// Pak file manager
-#define PAKFile_Iterate Common::List<PakChunk*>::iterator start=_files.begin();start != _files.end(); ++start
+#define PAKFile_Iterate Common::List<PakChunk>::iterator start=_files.begin();start != _files.end(); ++start
PAKFile::PAKFile(const Common::String& file, bool isAmiga) {
_filename = 0;
_isAmiga = isAmiga;
@@ -297,15 +297,14 @@ PAKFile::PAKFile(const Common::String& file, bool isAmiga) {
pos += 4;
while (pos < filesize) {
- PakChunk* chunk = new PakChunk;
- assert(chunk);
+ PakChunk chunk;
// saves the name
- chunk->_name = new char[strlen((const char*)buffer + pos) + 1];
- assert(chunk->_name);
- strcpy(chunk->_name, (const char*)buffer + pos);
- pos += strlen(chunk->_name) + 1;
- if (!(*chunk->_name))
+ int strLen = strlen((const char*)buffer + pos) + 1;
+ assert(ARRAYSIZE(chunk._name) > strLen);
+ strncpy(chunk._name, (const char*)buffer + pos, ARRAYSIZE(chunk._name));
+ pos += strlen(chunk._name) + 1;
+ if (!(*chunk._name))
break;
if (!_isAmiga) {
@@ -319,8 +318,8 @@ PAKFile::PAKFile(const Common::String& file, bool isAmiga) {
endoffset = filesize;
}
- chunk->_start = startoffset;
- chunk->_size = endoffset - startoffset;
+ chunk._start = startoffset;
+ chunk._size = endoffset - startoffset;
_files.push_back(chunk);
@@ -342,26 +341,21 @@ PAKFile::~PAKFile() {
_filename = 0;
_open = false;
- for (PAKFile_Iterate) {
- delete [] (*start)->_name;
- (*start)->_name = 0;
- delete *start;
- *start = 0;
- }
+ _files.clear();
}
uint8 *PAKFile::getFile(const char *file) {
for (PAKFile_Iterate) {
- if (!scumm_stricmp((*start)->_name, file)) {
+ if (!scumm_stricmp(start->_name, file)) {
Common::File pakfile;
if (!pakfile.open(_filename)) {
debug(3, "couldn't open pakfile '%s'\n", _filename);
return 0;
}
- pakfile.seek((*start)->_start);
- uint8 *buffer = new uint8[(*start)->_size];
+ pakfile.seek(start->_start);
+ uint8 *buffer = new uint8[start->_size];
assert(buffer);
- pakfile.read(buffer, (*start)->_size);
+ pakfile.read(buffer, start->_size);
return buffer;
}
}
@@ -372,12 +366,12 @@ bool PAKFile::getFileHandle(const char *file, Common::File &filehandle) {
filehandle.close();
for (PAKFile_Iterate) {
- if (!scumm_stricmp((*start)->_name, file)) {
+ if (!scumm_stricmp(start->_name, file)) {
if (!filehandle.open(_filename)) {
debug(3, "couldn't open pakfile '%s'\n", _filename);
return 0;
}
- filehandle.seek((*start)->_start);
+ filehandle.seek(start->_start);
return true;
}
}
@@ -386,8 +380,8 @@ bool PAKFile::getFileHandle(const char *file, Common::File &filehandle) {
uint32 PAKFile::getFileSize(const char* file) {
for (PAKFile_Iterate) {
- if (!scumm_stricmp((*start)->_name, file))
- return (*start)->_size;
+ if (!scumm_stricmp(start->_name, file))
+ return start->_size;
}
return 0;
}
diff --git a/engines/kyra/resource.h b/engines/kyra/resource.h
index 702f6a7d35..d8fca843bb 100644
--- a/engines/kyra/resource.h
+++ b/engines/kyra/resource.h
@@ -36,7 +36,7 @@ namespace Kyra {
// standard Package format for Kyrandia games
class PAKFile {
struct PakChunk {
- char* _name;
+ char _name[32];
uint32 _start;
uint32 _size;
};
@@ -58,7 +58,7 @@ private:
bool _open;
bool _isAmiga;
char *_filename;
- Common::List<PakChunk*> _files; // the entries
+ Common::List<PakChunk> _files; // the entries
};
class Resource {