aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwhiterandrek2018-06-14 20:43:59 +0300
committerEugene Sandulenko2018-06-28 23:51:32 +0200
commitbc4d32df8bb40b26d1999e08ecfe5d74f0e1e3b6 (patch)
tree448573e39005d37b21cbfe89226be468d22c62ab
parente4402a90ebf15687b656a17bf080c74d9ee9a5b6 (diff)
downloadscummvm-rg350-bc4d32df8bb40b26d1999e08ecfe5d74f0e1e3b6.tar.gz
scummvm-rg350-bc4d32df8bb40b26d1999e08ecfe5d74f0e1e3b6.tar.bz2
scummvm-rg350-bc4d32df8bb40b26d1999e08ecfe5d74f0e1e3b6.zip
PINK: file code cleanup
-rw-r--r--engines/pink/file.cpp24
-rw-r--r--engines/pink/file.h17
-rw-r--r--engines/pink/resource_mgr.cpp2
3 files changed, 15 insertions, 28 deletions
diff --git a/engines/pink/file.cpp b/engines/pink/file.cpp
index 861ffc4948..f14d459049 100644
--- a/engines/pink/file.cpp
+++ b/engines/pink/file.cpp
@@ -20,10 +20,7 @@
*
*/
-#include "common/str.h"
-
#include "pink/pink.h"
-#include "pink/objects/pages/game_page.h"
namespace Pink {
@@ -31,7 +28,7 @@ void ObjectDescription::load(Common::File &file) {
file.read(name, sizeof(name));
objectsOffset = file.readUint32LE();
- objectsCount = file.readUint32LE();
+ /*objectsCount*/ file.readUint32LE();
resourcesOffset = file.readUint32LE();
resourcesCount = file.readUint32LE();
}
@@ -44,10 +41,8 @@ void ResourceDescription::load(Common::File &file) {
inBro = (bool) file.readUint16LE();
}
-
OrbFile::OrbFile()
: File(), _timestamp(0),
- _tableOffset(0),
_tableSize(0),
_table(nullptr) {}
@@ -56,28 +51,24 @@ OrbFile::~OrbFile() {
}
bool OrbFile::open(const Common::String &name) {
- if (!File::open(name))
- return false;
-
- if (readUint32BE() != 'ORB\0')
+ if (!File::open(name) || readUint32BE() != 'ORB\0')
return false;
uint16 minor = readUint16LE();
uint16 major = readUint16LE();
- debug("Orb v%hu.%hu loaded", major, minor);
-
if (major != kOrbMajorVersion || minor != kOrbMinorVersion)
return false;
if (!(_timestamp = readUint32LE()))
return false;
- _tableOffset = readUint32LE();
+ uint32 tableOffset = readUint32LE();
+
_tableSize = readUint32LE();
_table = new ObjectDescription[_tableSize];
- seek(_tableOffset);
+ seek(tableOffset);
for (uint i = 0; i < _tableSize; ++i) {
_table[i].load(*this);
@@ -115,7 +106,7 @@ ObjectDescription *OrbFile::getObjDesc(const char *name){
return desc;
}
-ResourceDescription *OrbFile::getResDescTable(ObjectDescription *objDesc){
+ResourceDescription *OrbFile::createResDescTable(ObjectDescription *objDesc){
ResourceDescription *table = new ResourceDescription[objDesc->resourcesCount];
seek(objDesc->resourcesOffset);
@@ -131,7 +122,6 @@ void OrbFile::seekToObject(const char *name) {
seek(desc->objectsOffset);
}
-
bool BroFile::open(const Common::String &name, uint32 orbTimestamp) {
if (!File::open(name) || readUint32BE() != 'BRO\0')
return false;
@@ -139,8 +129,6 @@ bool BroFile::open(const Common::String &name, uint32 orbTimestamp) {
uint16 minor = readUint16LE();
uint16 major = readUint16LE();
- debug("Bro v%hu.%hu loaded", major, minor);
-
if (major != kBroMajorVersion || minor != kBroMinorVersion)
return false;
diff --git a/engines/pink/file.h b/engines/pink/file.h
index 80b7ec6f44..9901a67256 100644
--- a/engines/pink/file.h
+++ b/engines/pink/file.h
@@ -32,7 +32,7 @@ struct ObjectDescription {
char name[16];
uint32 objectsOffset;
- uint32 objectsCount;
+ //uint32 objectsCount; never used
uint32 resourcesOffset;
uint32 resourcesCount;
};
@@ -43,8 +43,7 @@ struct ResourceDescription {
char name[16];
uint32 offset;
uint32 size;
- bool inBro; // in original it is short.
- // Don't know what's better to use.(Perhaps no difference because of padding)
+ bool inBro;
};
class PinkEngine;
@@ -56,28 +55,28 @@ public:
virtual ~OrbFile();
virtual bool open(const Common::String &name);
+public:
void loadGame(PinkEngine *game);
void loadObject(Object *obj, const Common::String &name);
void loadObject(Object *obj, ObjectDescription *objDesc);
- ObjectDescription *getObjDesc(const char *name);
-
- ResourceDescription *getResDescTable(ObjectDescription *objDesc);
+ ResourceDescription *createResDescTable(ObjectDescription *objDesc);
+ ObjectDescription *getObjDesc(const char *name);
uint32 getTimestamp() { return _timestamp; }
private:
void seekToObject(const char *name);
+private:
ObjectDescription *_table;
- uint32 _timestamp;
- uint32 _tableOffset;
uint32 _tableSize;
+ uint32 _timestamp;
};
class BroFile : public Common::File {
public:
- virtual bool open(const Common::String &name, uint32 orbTimestamp);
+ bool open(const Common::String &name, uint32 orbTimestamp);
};
} // End of namespace Pink
diff --git a/engines/pink/resource_mgr.cpp b/engines/pink/resource_mgr.cpp
index 6b6882888e..b2652ffc6e 100644
--- a/engines/pink/resource_mgr.cpp
+++ b/engines/pink/resource_mgr.cpp
@@ -45,7 +45,7 @@ void ResourceMgr::init(PinkEngine *game, Page *page) {
ObjectDescription *objDesc = orb->getObjDesc(page->getName().c_str());
_resCount = objDesc->resourcesCount;
orb->loadObject(page, objDesc);
- _resDescTable = orb->getResDescTable(objDesc);
+ _resDescTable = orb->createResDescTable(objDesc);
}
void ResourceMgr::clear() {