[Scummvm-cvs-logs] SF.net SVN: scummvm: [22900] scummvm/trunk/engines/kyra
lordhoto at users.sourceforge.net
lordhoto at users.sourceforge.net
Sat Jun 3 19:58:19 CEST 2006
Revision: 22900
Author: lordhoto
Date: 2006-06-03 10:58:13 -0700 (Sat, 03 Jun 2006)
ViewCVS: http://svn.sourceforge.net/scummvm/?rev=22900&view=rev
Log Message:
-----------
- Replaces usage of PAKChunk* with PAKChunk for Common::List, should solve some strange MSVC6 warnings/(errors).
Modified Paths:
--------------
scummvm/trunk/engines/kyra/resource.cpp
scummvm/trunk/engines/kyra/resource.h
Modified: scummvm/trunk/engines/kyra/resource.cpp
===================================================================
--- scummvm/trunk/engines/kyra/resource.cpp 2006-06-03 17:21:18 UTC (rev 22899)
+++ scummvm/trunk/engines/kyra/resource.cpp 2006-06-03 17:58:13 UTC (rev 22900)
@@ -265,7 +265,7 @@
///////////////////////////////////////////
// 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 @@
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 @@
endoffset = filesize;
}
- chunk->_start = startoffset;
- chunk->_size = endoffset - startoffset;
+ chunk._start = startoffset;
+ chunk._size = endoffset - startoffset;
_files.push_back(chunk);
@@ -342,26 +341,21 @@
_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 @@
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 @@
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;
}
Modified: scummvm/trunk/engines/kyra/resource.h
===================================================================
--- scummvm/trunk/engines/kyra/resource.h 2006-06-03 17:21:18 UTC (rev 22899)
+++ scummvm/trunk/engines/kyra/resource.h 2006-06-03 17:58:13 UTC (rev 22900)
@@ -36,7 +36,7 @@
// standard Package format for Kyrandia games
class PAKFile {
struct PakChunk {
- char* _name;
+ char _name[32];
uint32 _start;
uint32 _size;
};
@@ -58,7 +58,7 @@
bool _open;
bool _isAmiga;
char *_filename;
- Common::List<PakChunk*> _files; // the entries
+ Common::List<PakChunk> _files; // the entries
};
class Resource {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list