[Scummvm-cvs-logs] SF.net SVN: scummvm: [21533] scummvm/trunk/engines/sword2/resman.cpp
eriktorbjorn at users.sourceforge.net
eriktorbjorn at users.sourceforge.net
Sat Apr 1 13:43:00 CEST 2006
Revision: 21533
Author: eriktorbjorn
Date: 2006-04-01 13:42:11 -0800 (Sat, 01 Apr 2006)
ViewCVS: http://svn.sourceforge.net/scummvm/?rev=21533&view=rev
Log Message:
-----------
Simplified the loading of resource.inf
Modified Paths:
--------------
scummvm/trunk/engines/sword2/resman.cpp
Modified: scummvm/trunk/engines/sword2/resman.cpp
===================================================================
--- scummvm/trunk/engines/sword2/resman.cpp 2006-04-01 21:31:27 UTC (rev 21532)
+++ scummvm/trunk/engines/sword2/resman.cpp 2006-04-01 21:42:11 UTC (rev 21533)
@@ -61,10 +61,13 @@
};
ResourceManager::ResourceManager(Sword2Engine *vm) {
+ uint32 i, j;
+
_vm = vm;
// Until proven differently, assume we're on CD 1. This is so the start
// dialog will be able to play any music at all.
+
setCD(1);
// We read in the resource info which tells us the names of the
@@ -73,8 +76,6 @@
// wish to know what resource files there are and what is in each
Common::File file;
- uint32 size;
- byte *temp;
_totalClusters = 0;
_resConvTable = NULL;
@@ -82,58 +83,23 @@
if (!file.open("resource.inf"))
error("Cannot open resource.inf");
- size = file.size();
+ // The resource.inf file is a simple text file containing the names of
+ // all the resource files.
- // Get some space for the incoming resource file - soon to be trashed
- temp = (byte *)malloc(size);
-
- if (file.read(temp, size) != size) {
- file.close();
- error("init cannot *READ* resource.inf");
- }
-
- file.close();
-
- // Ok, we've loaded in the resource.inf file which contains a list of
- // all the files now extract the filenames.
-
- // Using this method the Gode generated resource.inf must have #0d0a on
- // the last entry
-
- uint32 i = 0;
- uint32 j = 0;
-
- do {
- // item must have an #0d0a
- while (temp[i] != 13) {
- _resFiles[_totalClusters].fileName[j] = temp[i];
- i++;
- j++;
- }
-
- // NULL terminate our extracted string
- _resFiles[_totalClusters].fileName[j] = '\0';
+ while (file.readLine(_resFiles[_totalClusters].fileName, sizeof(_resFiles[_totalClusters].fileName))) {
_resFiles[_totalClusters].numEntries = -1;
_resFiles[_totalClusters].entryTab = NULL;
-
- // Reset position in current slot between entries, skip the
- // 0x0a in the source and increase the number of clusters.
-
- j = 0;
- i += 2;
_totalClusters++;
+ }
- // TODO: put overload check here
- } while (i != size);
+ file.close();
- free(temp);
-
// Now load in the binary id to res conversion table
if (!file.open("resource.tab"))
error("Cannot open resource.tab");
// Find how many resources
- size = file.size();
+ uint32 size = file.size();
_totalResFiles = size / 4;
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