aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorwhiterandrek2018-04-27 08:27:01 +0300
committerEugene Sandulenko2018-06-28 23:51:32 +0200
commit8c5bfed75678dd8b083c1cc024bbd80f1facb13c (patch)
tree3e20475370adc9a4e93b62e013676c42b9666334 /engines
parentdac8d2a72b427cdecedfe4a951aa6166ce7b3720 (diff)
downloadscummvm-rg350-8c5bfed75678dd8b083c1cc024bbd80f1facb13c.tar.gz
scummvm-rg350-8c5bfed75678dd8b083c1cc024bbd80f1facb13c.tar.bz2
scummvm-rg350-8c5bfed75678dd8b083c1cc024bbd80f1facb13c.zip
PINK: created constants for magic numbers, improved code in file
Diffstat (limited to 'engines')
-rw-r--r--engines/pink/constants.h10
-rw-r--r--engines/pink/file.cpp36
-rw-r--r--engines/pink/file.h2
3 files changed, 27 insertions, 21 deletions
diff --git a/engines/pink/constants.h b/engines/pink/constants.h
index db9c60abac..da572d1f91 100644
--- a/engines/pink/constants.h
+++ b/engines/pink/constants.h
@@ -131,6 +131,16 @@ enum {
kLoadingNewGame = 0
};
+enum {
+ kOrbMajorVersion = 2,
+ kOrbMinorVersion = 0,
+ kBroMajorVersion = 1,
+ kBroMinorVersion = 0,
+};
+
+
+const char *kPinkGame = "PinkGame";
+
} // End of namespace Pink
#endif
diff --git a/engines/pink/file.cpp b/engines/pink/file.cpp
index 47290329e6..4f2867b10c 100644
--- a/engines/pink/file.cpp
+++ b/engines/pink/file.cpp
@@ -41,7 +41,6 @@ bool OrbFile::open(const Common::String &name) {
return false;
if (readUint32BE() != 'ORB\0'){
- close();
return false;
}
@@ -50,7 +49,7 @@ bool OrbFile::open(const Common::String &name) {
debug("Orb v%hu.%hu loaded", major, minor);
- if (minor || major != 2){
+ if (major != kOrbMajorVersion || minor != kOrbMinorVersion){
return false;
}
@@ -73,7 +72,7 @@ bool OrbFile::open(const Common::String &name) {
}
void OrbFile::loadGame(PinkEngine *game) {
- seekToObject("PinkGame");
+ seekToObject(kPinkGame);
Archive archive(this);
archive.mapObject(reinterpret_cast<Object*>(game)); // hack
game->load(archive);
@@ -91,7 +90,6 @@ void OrbFile::loadObject(Object *obj, ObjectDescription *objDesc) {
obj->load(archive);
}
-
uint32 OrbFile::getTimestamp() {
return _timestamp;
}
@@ -110,11 +108,10 @@ ObjectDescription *OrbFile::getObjDesc(const char *name){
}
ResourceDescription *OrbFile::getResDescTable(ObjectDescription *objDesc){
- const uint32 size = objDesc->resourcesCount;
+ ResourceDescription *table = new ResourceDescription[objDesc->resourcesCount];
seek(objDesc->resourcesOffset);
- ResourceDescription *table = new ResourceDescription[size];
- for (size_t i = 0; i < size; ++i) {
+ for (size_t i = 0; i < objDesc->resourcesCount; ++i) {
table[i].load(*this);
}
@@ -122,7 +119,7 @@ ResourceDescription *OrbFile::getResDescTable(ObjectDescription *objDesc){
}
-bool BroFile::open(Common::String &name, uint32 orbTimestamp) {
+bool BroFile::open(const Common::String &name, uint32 orbTimestamp) {
if (!File::open(name) || readUint32BE() != 'BRO\0')
return false;
@@ -131,31 +128,30 @@ bool BroFile::open(Common::String &name, uint32 orbTimestamp) {
debug("Bro v%hu.%hu loaded", major, minor);
- if (major != 1 || minor != 0){
+ if (major != kBroMajorVersion || minor != kBroMinorVersion){
return false;
}
- uint32 _timestamp = readUint32LE();
+ uint32 timestamp = readUint32LE();
- return _timestamp == orbTimestamp;
+ return timestamp == orbTimestamp;
}
void ObjectDescription::load(Common::File &file) {
file.read(name, sizeof(name));
- file.read(&objectsOffset, sizeof(objectsOffset));
- file.read(&objectsCount, sizeof(objectsCount));
- file.read(&resourcesOffset, sizeof(resourcesOffset));
- file.read(&resourcesCount, sizeof(resourcesCount));
+
+ objectsOffset = file.readUint32LE();
+ objectsCount = file.readUint32LE();
+ resourcesOffset = file.readUint32LE();
+ resourcesCount = file.readUint32LE();
}
void ResourceDescription::load(Common::File &file) {
file.read(name, sizeof(name));
- file.read(&offset, sizeof(offset));
- file.read(&size, sizeof(offset));
- uint16 temp;
- file.read(&temp, sizeof(temp));
- inBro = (bool) temp;
+ offset = file.readUint32LE();
+ size = file.readUint32LE();
+ inBro = (bool) file.readUint16LE();
}
} // End of namespace Pink \ No newline at end of file
diff --git a/engines/pink/file.h b/engines/pink/file.h
index c87fd79ece..0e78eeb290 100644
--- a/engines/pink/file.h
+++ b/engines/pink/file.h
@@ -76,7 +76,7 @@ private:
class BroFile : public Common::File {
public:
- virtual bool open(Common::String &name, uint32 orbTimestamp);
+ virtual bool open(const Common::String &name, uint32 orbTimestamp);
};
} // End of namespace Pink