aboutsummaryrefslogtreecommitdiff
path: root/engines/neverhood
diff options
context:
space:
mode:
authorjohndoe1232013-01-17 09:09:39 +0000
committerWillem Jan Palenstijn2013-05-08 20:47:40 +0200
commit57497817e1f086a62471587e3601d8f0f7d7f13b (patch)
tree76e1f76ff059b7d2bad82189ffbc9638b12bb0c1 /engines/neverhood
parenta98d9aa58afb4dd944616e7f194c09ff28456e1b (diff)
downloadscummvm-rg350-57497817e1f086a62471587e3601d8f0f7d7f13b.tar.gz
scummvm-rg350-57497817e1f086a62471587e3601d8f0f7d7f13b.tar.bz2
scummvm-rg350-57497817e1f086a62471587e3601d8f0f7d7f13b.zip
NEVERHOOD: Add enum for the resource types
Diffstat (limited to 'engines/neverhood')
-rw-r--r--engines/neverhood/resource.cpp18
-rw-r--r--engines/neverhood/resource.h11
-rw-r--r--engines/neverhood/smackerscene.cpp2
-rw-r--r--engines/neverhood/sound.cpp7
4 files changed, 23 insertions, 15 deletions
diff --git a/engines/neverhood/resource.cpp b/engines/neverhood/resource.cpp
index 7f897a415f..6cbbf12a25 100644
--- a/engines/neverhood/resource.cpp
+++ b/engines/neverhood/resource.cpp
@@ -27,10 +27,6 @@
namespace Neverhood {
-// TODO: Since the load() methods are similar in most cases some of the code therein
-// can probably be copied into another method (e.g. inside the resource manager)
-// to reduce code.
-
// SpriteResource
SpriteResource::SpriteResource(NeverhoodEngine *vm)
@@ -55,7 +51,7 @@ bool SpriteResource::load(uint32 fileHash) {
// TODO: Later merge with load2 and make the mode a parameter
unload();
_vm->_res->queryResource(fileHash, _resourceHandle);
- if (_resourceHandle.isValid() && _resourceHandle.type() == 2) {
+ if (_resourceHandle.isValid() && _resourceHandle.type() == kResTypeBitmap) {
_vm->_res->loadResource(_resourceHandle);
const byte *spriteData = _resourceHandle.data();
parseBitmapResource(spriteData, &_rle, &_dimensions, NULL, NULL, &_pixels);
@@ -67,7 +63,7 @@ bool SpriteResource::load2(uint32 fileHash) {
debug(2, "SpriteResource::load2(%08X)", fileHash);
unload();
_vm->_res->queryResource(fileHash, _resourceHandle);
- if (_resourceHandle.isValid() && _resourceHandle.type() == 2) {
+ if (_resourceHandle.isValid() && _resourceHandle.type() == kResTypeBitmap) {
_vm->_res->loadResource(_resourceHandle);
const byte *spriteData = _resourceHandle.data();
parseBitmapResource(spriteData, &_rle, &_dimensions, &_position, NULL, &_pixels);
@@ -97,11 +93,11 @@ bool PaletteResource::load(uint32 fileHash) {
unload();
_vm->_res->queryResource(fileHash, _resourceHandle);
if (_resourceHandle.isValid() &&
- (_resourceHandle.type() == 2 || _resourceHandle.type() == 3)) {
+ (_resourceHandle.type() == kResTypeBitmap || _resourceHandle.type() == kResTypePalette)) {
_vm->_res->loadResource(_resourceHandle);
_palette = _resourceHandle.data();
// Check if the palette is stored in a bitmap
- if (_resourceHandle.type() == 2)
+ if (_resourceHandle.type() == kResTypeBitmap)
parseBitmapResource(_palette, NULL, NULL, NULL, &_palette, NULL);
}
@@ -152,7 +148,7 @@ bool AnimResource::load(uint32 fileHash) {
unload();
_vm->_res->queryResource(fileHash, _resourceHandle);
- if (!_resourceHandle.isValid() || _resourceHandle.type() != 4)
+ if (!_resourceHandle.isValid() || _resourceHandle.type() != kResTypeAnimation)
return false;
const byte *resourceData, *animList, *frameList;
@@ -336,7 +332,7 @@ void TextResource::load(uint32 fileHash) {
debug(2, "TextResource::load(%08X)", fileHash);
unload();
_vm->_res->queryResource(fileHash, _resourceHandle);
- if (_resourceHandle.isValid() && _resourceHandle.type() == 6) {
+ if (_resourceHandle.isValid() && _resourceHandle.type() == kResTypeText) {
_vm->_res->loadResource(_resourceHandle);
_textData = _resourceHandle.data();
_count = READ_LE_UINT32(_textData);
@@ -371,7 +367,7 @@ void DataResource::load(uint32 fileHash) {
uint32 dataSize = 0;
unload();
_vm->_res->queryResource(fileHash, _resourceHandle);
- if (_resourceHandle.isValid() && _resourceHandle.type() == 5) {
+ if (_resourceHandle.isValid() && _resourceHandle.type() == kResTypeData) {
_vm->_res->loadResource(_resourceHandle);
data = _resourceHandle.data();
dataSize = _resourceHandle.size();
diff --git a/engines/neverhood/resource.h b/engines/neverhood/resource.h
index 996579bc41..c6f63bf92d 100644
--- a/engines/neverhood/resource.h
+++ b/engines/neverhood/resource.h
@@ -31,6 +31,17 @@
namespace Neverhood {
+enum {
+ kResTypeBitmap = 2,
+ kResTypePalette = 3,
+ kResTypeAnimation = 4,
+ kResTypeData = 5,
+ kResTypeText = 6,
+ kResTypeSound = 7,
+ kResTypeMusic = 8,
+ kResTypeVideo = 10
+};
+
class SpriteResource {
public:
SpriteResource(NeverhoodEngine *vm);
diff --git a/engines/neverhood/smackerscene.cpp b/engines/neverhood/smackerscene.cpp
index 7470acbdad..290b8fa23c 100644
--- a/engines/neverhood/smackerscene.cpp
+++ b/engines/neverhood/smackerscene.cpp
@@ -72,7 +72,7 @@ void SmackerScene::nextVideo() {
uint32 smackerFileHash = _fileHashList[_fileHashListIndex];
ResourceHandle resourceHandle;
_vm->_res->queryResource(smackerFileHash, resourceHandle);
- if (resourceHandle.type() != 10) {
+ if (resourceHandle.type() != kResTypeVideo) {
// Not a Smacker file
_vm->_screen->setSmackerDecoder(NULL);
sendMessage(_parentModule, 0x1009, 0);
diff --git a/engines/neverhood/sound.cpp b/engines/neverhood/sound.cpp
index 3cbcf96354..13ac87fbad 100644
--- a/engines/neverhood/sound.cpp
+++ b/engines/neverhood/sound.cpp
@@ -128,8 +128,8 @@ MusicItem::~MusicItem() {
}
SoundItem::SoundItem(NeverhoodEngine *vm, uint32 nameHash, uint32 soundFileHash,
- bool playOnceAfterRandomCountdown, int16 minCountdown, int16 maxCountdown,
- bool playOnceAfterCountdown, int16 initialCountdown, bool playLooping, int16 currCountdown)
+ bool playOnceAfterRandomCountdown, int16 minCountdown, int16 maxCountdown,
+ bool playOnceAfterCountdown, int16 initialCountdown, bool playLooping, int16 currCountdown)
: _soundResource(NULL), _nameHash(nameHash), _soundFileHash(soundFileHash),
_playOnceAfterRandomCountdown(false), _minCountdown(0), _maxCountdown(0),
_playOnceAfterCountdown(_playOnceAfterCountdown), _initialCountdown(initialCountdown),
@@ -546,7 +546,8 @@ void AudioResourceMan::removeSound(int16 soundIndex) {
void AudioResourceMan::loadSound(int16 soundIndex) {
AudioResourceManSoundItem *soundItem = _soundItems[soundIndex];
- if (!soundItem->_data && soundItem->_resourceHandle.isValid()) {
+ if (!soundItem->_data && soundItem->_resourceHandle.isValid() &&
+ (soundItem->_resourceHandle.type() == kResTypeSound || soundItem->_resourceHandle.type() == kResTypeMusic)) {
// TODO Check if it's a sound resource
_vm->_res->loadResource(soundItem->_resourceHandle);
soundItem->_data = soundItem->_resourceHandle.data();