SCI: Resmgr cleanup and preparations for moving resource36 handling into resmgr.
svn-id: r41318
This commit is contained in:
parent
77f114ffcb
commit
e3d3195a43
5 changed files with 70 additions and 55 deletions
|
@ -1045,7 +1045,7 @@ reg_t kDoSync(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||||
case kSciAudioSyncStart:
|
case kSciAudioSyncStart:
|
||||||
if (argc == 3) { // KQ5CD, KQ6 floppy
|
if (argc == 3) { // KQ5CD, KQ6 floppy
|
||||||
if (s->_sound._soundSync) {
|
if (s->_sound._soundSync) {
|
||||||
s->resmgr->unlockResource(s->_sound._soundSync, s->_sound._soundSync->number, kResourceTypeSync);
|
s->resmgr->unlockResource(s->_sound._soundSync, s->_sound._soundSync->id.number, kResourceTypeSync);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load sound sync resource and lock it
|
// Load sound sync resource and lock it
|
||||||
|
@ -1072,7 +1072,7 @@ reg_t kDoSync(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||||
case kSciAudioSyncStop:
|
case kSciAudioSyncStop:
|
||||||
if (s->_sound._soundSync) {
|
if (s->_sound._soundSync) {
|
||||||
s->_sound._soundSync->stopSync();
|
s->_sound._soundSync->stopSync();
|
||||||
s->resmgr->unlockResource(s->_sound._soundSync, s->_sound._soundSync->number, kResourceTypeSync);
|
s->resmgr->unlockResource(s->_sound._soundSync, s->_sound._soundSync->id.number, kResourceTypeSync);
|
||||||
s->_sound._soundSync = NULL;
|
s->_sound._soundSync = NULL;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -67,7 +67,7 @@ GfxResManager::GfxResManager(int version, bool isVGA, gfx_options_t *options, Gf
|
||||||
} else {
|
} else {
|
||||||
Resource *res = resManager->findResource(kResourceTypePalette, 999, 0);
|
Resource *res = resManager->findResource(kResourceTypePalette, 999, 0);
|
||||||
if (res && res->data)
|
if (res && res->data)
|
||||||
_staticPalette = gfxr_read_pal1(res->id, res->data, res->size);
|
_staticPalette = gfxr_read_pal1(res->id.number, res->data, res->size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,18 +97,18 @@ int GfxResManager::calculatePic(gfxr_pic_t *scaled_pic, gfxr_pic_t *unscaled_pic
|
||||||
|
|
||||||
if (need_unscaled) {
|
if (need_unscaled) {
|
||||||
if (_version == SCI_VERSION_1_1)
|
if (_version == SCI_VERSION_1_1)
|
||||||
gfxr_draw_pic11(unscaled_pic, flags, default_palette, res->size, res->data, &basic_style, res->id, _staticPalette, _portBounds);
|
gfxr_draw_pic11(unscaled_pic, flags, default_palette, res->size, res->data, &basic_style, res->id.number, _staticPalette, _portBounds);
|
||||||
else
|
else
|
||||||
gfxr_draw_pic01(unscaled_pic, flags, default_palette, res->size, res->data, &basic_style, res->id, _isVGA, _staticPalette, _portBounds);
|
gfxr_draw_pic01(unscaled_pic, flags, default_palette, res->size, res->data, &basic_style, res->id.number, _isVGA, _staticPalette, _portBounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scaled_pic && scaled_pic->undithered_buffer)
|
if (scaled_pic && scaled_pic->undithered_buffer)
|
||||||
memcpy(scaled_pic->visual_map->index_data, scaled_pic->undithered_buffer, scaled_pic->undithered_buffer_size);
|
memcpy(scaled_pic->visual_map->index_data, scaled_pic->undithered_buffer, scaled_pic->undithered_buffer_size);
|
||||||
|
|
||||||
if (_version == SCI_VERSION_1_1)
|
if (_version == SCI_VERSION_1_1)
|
||||||
gfxr_draw_pic11(scaled_pic, flags, default_palette, res->size, res->data, &style, res->id, _staticPalette, _portBounds);
|
gfxr_draw_pic11(scaled_pic, flags, default_palette, res->size, res->data, &style, res->id.number, _staticPalette, _portBounds);
|
||||||
else
|
else
|
||||||
gfxr_draw_pic01(scaled_pic, flags, default_palette, res->size, res->data, &style, res->id, _isVGA, _staticPalette, _portBounds);
|
gfxr_draw_pic01(scaled_pic, flags, default_palette, res->size, res->data, &style, res->id.number, _isVGA, _staticPalette, _portBounds);
|
||||||
|
|
||||||
if (!_isVGA) {
|
if (!_isVGA) {
|
||||||
if (need_unscaled)
|
if (need_unscaled)
|
||||||
|
@ -625,7 +625,7 @@ gfx_bitmap_font_t *GfxResManager::getFont(int num, bool scaled) {
|
||||||
if (!fontRes || !fontRes->data)
|
if (!fontRes || !fontRes->data)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
gfx_bitmap_font_t *font = gfxr_read_font(fontRes->id, fontRes->data, fontRes->size);
|
gfx_bitmap_font_t *font = gfxr_read_font(fontRes->id.number, fontRes->data, fontRes->size);
|
||||||
|
|
||||||
if (!res) {
|
if (!res) {
|
||||||
res = (gfx_resource_t *)malloc(sizeof(gfx_resource_t));
|
res = (gfx_resource_t *)malloc(sizeof(gfx_resource_t));
|
||||||
|
|
|
@ -100,9 +100,6 @@ const char *getResourceTypeName(ResourceType restype) {
|
||||||
//-- Resource main functions --
|
//-- Resource main functions --
|
||||||
Resource::Resource() {
|
Resource::Resource() {
|
||||||
data = NULL;
|
data = NULL;
|
||||||
number = 0;
|
|
||||||
type = kResourceTypeInvalid;
|
|
||||||
id = 0;
|
|
||||||
size = 0;
|
size = 0;
|
||||||
file_offset = 0;
|
file_offset = 0;
|
||||||
status = kResStatusNoMalloc;
|
status = kResStatusNoMalloc;
|
||||||
|
@ -198,19 +195,19 @@ bool ResourceManager::loadPatch(Resource *res, Common::File &file) {
|
||||||
res->header = new byte[res->headerSize];
|
res->header = new byte[res->headerSize];
|
||||||
|
|
||||||
if ((res->data == NULL) || ((res->headerSize > 0) && (res->header == NULL))) {
|
if ((res->data == NULL) || ((res->headerSize > 0) && (res->header == NULL))) {
|
||||||
error("Can't allocate %d bytes needed for loading %s.%i", res->size + res->headerSize, resourceTypeNames[res->type], res->number);
|
error("Can't allocate %d bytes needed for loading %s", res->size + res->headerSize, res->id.toString().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int really_read;
|
unsigned int really_read;
|
||||||
if (res->headerSize > 0) {
|
if (res->headerSize > 0) {
|
||||||
really_read = file.read(res->header, res->headerSize);
|
really_read = file.read(res->header, res->headerSize);
|
||||||
if (really_read != res->headerSize)
|
if (really_read != res->headerSize)
|
||||||
error("Read %d bytes from %s.%i but expected %d", really_read, resourceTypeNames[res->type], res->number, res->headerSize);
|
error("Read %d bytes from %s but expected %d", really_read, res->id.toString().c_str(), res->headerSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
really_read = file.read(res->data, res->size);
|
really_read = file.read(res->data, res->size);
|
||||||
if (really_read != res->size)
|
if (really_read != res->size)
|
||||||
error("Read %d bytes from %s.%i but expected %d", really_read, resourceTypeNames[res->type], res->number, res->size);
|
error("Read %d bytes from %s but expected %d", really_read, res->id.toString().c_str(), res->size);
|
||||||
|
|
||||||
res->status = kResStatusAllocated;
|
res->status = kResStatusAllocated;
|
||||||
return true;
|
return true;
|
||||||
|
@ -240,8 +237,8 @@ bool ResourceManager::loadFromAudioVolume(Resource *res) {
|
||||||
file.seek(res->file_offset, SEEK_SET);
|
file.seek(res->file_offset, SEEK_SET);
|
||||||
|
|
||||||
int type = file.readByte() & 0x7f;
|
int type = file.readByte() & 0x7f;
|
||||||
if (type != res->type) {
|
if (type != res->id.type) {
|
||||||
warning("Resource type mismatch loading %s.%i from %s", resourceTypeNames[res->type], res->number, filename);
|
warning("Resource type mismatch loading %s from %s", res->id.toString().c_str(), filename);
|
||||||
res->unalloc();
|
res->unalloc();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -313,16 +310,16 @@ void ResourceManager::loadResource(Resource *res) {
|
||||||
file->seek(res->file_offset, SEEK_SET);
|
file->seek(res->file_offset, SEEK_SET);
|
||||||
int error = decompress(res, file);
|
int error = decompress(res, file);
|
||||||
if (error) {
|
if (error) {
|
||||||
warning("Error %d occured while reading %s.%03d from resource file: %s",
|
warning("Error %d occured while reading %s from resource file: %s",
|
||||||
error, getResourceTypeName(res->type), res->number, sci_error_types[error]);
|
error, res->id.toString().c_str(), sci_error_types[error]);
|
||||||
res->unalloc();
|
res->unalloc();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Resource *ResourceManager::testResource(ResourceType type, int number) {
|
Resource *ResourceManager::testResource(ResourceType type, int number) {
|
||||||
if (_resMap.contains(RESOURCE_HASH(type, number)))
|
if (_resMap.contains(ResourceId(type, number)))
|
||||||
return _resMap.getVal(RESOURCE_HASH(type, number));
|
return _resMap.getVal(ResourceId(type, number));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -579,7 +576,7 @@ ResourceManager::ResourceManager(int version, int maxMemory) {
|
||||||
|
|
||||||
ResourceManager::~ResourceManager() {
|
ResourceManager::~ResourceManager() {
|
||||||
// freeing resources
|
// freeing resources
|
||||||
Common::HashMap<uint32, Resource *>::iterator itr = _resMap.begin();
|
ResourceMap::iterator itr = _resMap.begin();
|
||||||
while (itr != _resMap.end()) {
|
while (itr != _resMap.end()) {
|
||||||
delete itr->_value;
|
delete itr->_value;
|
||||||
itr ++;
|
itr ++;
|
||||||
|
@ -628,8 +625,7 @@ void ResourceManager::printLRU() {
|
||||||
|
|
||||||
while (it != _LRU.end()) {
|
while (it != _LRU.end()) {
|
||||||
res = *it;
|
res = *it;
|
||||||
debug("\t%s.%03d: %d bytes", getResourceTypeName(res->type),
|
debug("\t%s: %d bytes", res->id.toString().c_str(), res->size);
|
||||||
res->number, res->size);
|
|
||||||
mem += res->size;
|
mem += res->size;
|
||||||
entries ++;
|
entries ++;
|
||||||
it ++;
|
it ++;
|
||||||
|
@ -694,7 +690,7 @@ Resource *ResourceManager::findResource(ResourceType type, int number, bool lock
|
||||||
if (retval->data)
|
if (retval->data)
|
||||||
return retval;
|
return retval;
|
||||||
else {
|
else {
|
||||||
sciprintf("Resmgr: Failed to read %s.%03d\n", getResourceTypeName(retval->type), retval->number);
|
sciprintf("Resmgr: Failed to read %s\n", retval->id.toString().c_str());
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -709,8 +705,7 @@ void ResourceManager::unlockResource(Resource *res, int resnum, ResourceType res
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res->status != kResStatusLocked) {
|
if (res->status != kResStatusLocked) {
|
||||||
sciprintf("Resmgr: Warning: Attempt to unlock unlocked resource %s.%03d\n",
|
sciprintf("Resmgr: Warning: Attempt to unlock unlocked resource %s\n", res->id.toString().c_str());
|
||||||
getResourceTypeName(res->type), res->number);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -865,7 +860,7 @@ int ResourceManager::detectVolVersion() {
|
||||||
void ResourceManager::processPatch(ResourceSource *source, ResourceType restype, int resnumber) {
|
void ResourceManager::processPatch(ResourceSource *source, ResourceType restype, int resnumber) {
|
||||||
Common::File file;
|
Common::File file;
|
||||||
Resource *newrsc;
|
Resource *newrsc;
|
||||||
uint32 resId = RESOURCE_HASH(restype, resnumber);
|
ResourceId resId = ResourceId(restype, resnumber);
|
||||||
byte patchtype, patch_data_offset;
|
byte patchtype, patch_data_offset;
|
||||||
int fsize;
|
int fsize;
|
||||||
|
|
||||||
|
@ -909,9 +904,7 @@ void ResourceManager::processPatch(ResourceSource *source, ResourceType restype,
|
||||||
newrsc = _resMap.getVal(resId);
|
newrsc = _resMap.getVal(resId);
|
||||||
// Overwrite everything, because we're patching
|
// Overwrite everything, because we're patching
|
||||||
newrsc->id = resId;
|
newrsc->id = resId;
|
||||||
newrsc->number = resnumber;
|
|
||||||
newrsc->status = kResStatusNoMalloc;
|
newrsc->status = kResStatusNoMalloc;
|
||||||
newrsc->type = restype;
|
|
||||||
newrsc->source = source;
|
newrsc->source = source;
|
||||||
newrsc->size = fsize - patch_data_offset - 2;
|
newrsc->size = fsize - patch_data_offset - 2;
|
||||||
newrsc->headerSize = patch_data_offset;
|
newrsc->headerSize = patch_data_offset;
|
||||||
|
@ -1001,14 +994,12 @@ int ResourceManager::readResourceMapSCI0(ResourceSource *map) {
|
||||||
|
|
||||||
type = (ResourceType)(id >> 11);
|
type = (ResourceType)(id >> 11);
|
||||||
number = id & 0x7FF;
|
number = id & 0x7FF;
|
||||||
uint32 resId = RESOURCE_HASH(type, number);
|
ResourceId resId = ResourceId(type, number);
|
||||||
// adding a new resource
|
// adding a new resource
|
||||||
if (_resMap.contains(resId) == false) {
|
if (_resMap.contains(resId) == false) {
|
||||||
res = new Resource;
|
res = new Resource;
|
||||||
res->id = resId;//id;
|
|
||||||
res->file_offset = offset & (((~bMask) << 24) | 0xFFFFFF);
|
res->file_offset = offset & (((~bMask) << 24) | 0xFFFFFF);
|
||||||
res->number = number;
|
res->id = resId;
|
||||||
res->type = type;
|
|
||||||
res->source = getVolume(map, offset >> bShift);
|
res->source = getVolume(map, offset >> bShift);
|
||||||
_resMap.setVal(resId, res);
|
_resMap.setVal(resId, res);
|
||||||
}
|
}
|
||||||
|
@ -1026,7 +1017,7 @@ int ResourceManager::readResourceMapSCI1(ResourceSource *map) {
|
||||||
memset(resMap, 0, sizeof(resource_index_t) * 32);
|
memset(resMap, 0, sizeof(resource_index_t) * 32);
|
||||||
byte type = 0, prevtype = 0;
|
byte type = 0, prevtype = 0;
|
||||||
byte nEntrySize = _mapVersion == SCI_VERSION_1_1 ? SCI11_RESMAP_ENTRIES_SIZE : SCI1_RESMAP_ENTRIES_SIZE;
|
byte nEntrySize = _mapVersion == SCI_VERSION_1_1 ? SCI11_RESMAP_ENTRIES_SIZE : SCI1_RESMAP_ENTRIES_SIZE;
|
||||||
uint32 resId;
|
ResourceId resId;
|
||||||
|
|
||||||
// Read resource type and offsets to resource offsets block from .MAP file
|
// Read resource type and offsets to resource offsets block from .MAP file
|
||||||
// The last entry has type=0xFF (0x1F) and offset equals to map file length
|
// The last entry has type=0xFF (0x1F) and offset equals to map file length
|
||||||
|
@ -1067,7 +1058,7 @@ int ResourceManager::readResourceMapSCI1(ResourceSource *map) {
|
||||||
perror("");
|
perror("");
|
||||||
return SCI_ERROR_RESMAP_NOT_FOUND;
|
return SCI_ERROR_RESMAP_NOT_FOUND;
|
||||||
}
|
}
|
||||||
resId = RESOURCE_HASH(type, number);
|
resId = ResourceId((ResourceType)type, number);
|
||||||
// adding new resource only if it does not exist
|
// adding new resource only if it does not exist
|
||||||
if (_resMap.contains(resId) == false) {
|
if (_resMap.contains(resId) == false) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
@ -1080,9 +1071,7 @@ int ResourceManager::readResourceMapSCI1(ResourceSource *map) {
|
||||||
}
|
}
|
||||||
|
|
||||||
_resMap.setVal(resId, res);
|
_resMap.setVal(resId, res);
|
||||||
res->type = (ResourceType)type;
|
res->id = resId;
|
||||||
res->number = number;
|
|
||||||
res->id = resId;//res->number | (res->type << 16);
|
|
||||||
res->source = getVolume(map, volume_nr);
|
res->source = getVolume(map, volume_nr);
|
||||||
res->file_offset = off;
|
res->file_offset = off;
|
||||||
}
|
}
|
||||||
|
@ -1142,13 +1131,11 @@ int ResourceManager::readMap65535(ResourceSource *map) {
|
||||||
ptr += 3;
|
ptr += 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 resId = RESOURCE_HASH(kResourceTypeAudio, n);
|
ResourceId resId = ResourceId(kResourceTypeAudio, n);
|
||||||
// Adding new resource only if it does not exist
|
// Adding new resource only if it does not exist
|
||||||
if (_resMap.contains(resId) == false) {
|
if (_resMap.contains(resId) == false) {
|
||||||
Resource *res = new Resource;
|
Resource *res = new Resource;
|
||||||
_resMap.setVal(resId, res);
|
_resMap.setVal(resId, res);
|
||||||
res->type = kResourceTypeAudio;
|
|
||||||
res->number = n;
|
|
||||||
res->id = resId;
|
res->id = resId;
|
||||||
res->source = src;
|
res->source = src;
|
||||||
res->file_offset = offset;
|
res->file_offset = offset;
|
||||||
|
@ -1206,9 +1193,7 @@ int ResourceManager::readResourceInfo(Resource *res, Common::File *file,
|
||||||
// check if there were errors while reading
|
// check if there were errors while reading
|
||||||
if (file->ioFailed())
|
if (file->ioFailed())
|
||||||
return SCI_ERROR_IO_ERROR;
|
return SCI_ERROR_IO_ERROR;
|
||||||
res->id = RESOURCE_HASH(type, number);
|
res->id = ResourceId(type, number);
|
||||||
res->type = type;
|
|
||||||
res->number = number;
|
|
||||||
res->size = szUnpacked;
|
res->size = szUnpacked;
|
||||||
// checking compression method
|
// checking compression method
|
||||||
switch (wCompression) {
|
switch (wCompression) {
|
||||||
|
@ -1277,8 +1262,7 @@ int ResourceManager::decompress(Resource *res, Common::File *file) {
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
warning("Resource %s #%d: Compression method %d not supported",
|
warning("Resource %s: Compression method %d not supported", res->id.toString().c_str(), compression);
|
||||||
getResourceTypeName(res->type), res->number, compression);
|
|
||||||
return SCI_ERROR_UNKNOWN_COMPRESSION;
|
return SCI_ERROR_UNKNOWN_COMPRESSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1337,7 +1321,7 @@ AudioResource::~AudioResource() {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (_audioMapSCI11)
|
if (_audioMapSCI11)
|
||||||
_resMgr->unlockResource(_audioMapSCI11, _audioMapSCI11->number, kResourceTypeMap);
|
_resMgr->unlockResource(_audioMapSCI11, _audioMapSCI11->id.number, kResourceTypeMap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1513,8 +1497,8 @@ bool AudioResource::findAudEntrySCI11Early(uint32 audioNumber, uint32 &offset, b
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AudioResource::findAudEntrySCI11(uint32 audioNumber, uint32 volume, uint32 &offset, bool getSync, uint32 *size) {
|
bool AudioResource::findAudEntrySCI11(uint32 audioNumber, uint32 volume, uint32 &offset, bool getSync, uint32 *size) {
|
||||||
if (_audioMapSCI11 && _audioMapSCI11->number != volume) {
|
if (_audioMapSCI11 && _audioMapSCI11->id.number != volume) {
|
||||||
_resMgr->unlockResource(_audioMapSCI11, _audioMapSCI11->number, kResourceTypeMap);
|
_resMgr->unlockResource(_audioMapSCI11, _audioMapSCI11->id.number, kResourceTypeMap);
|
||||||
_audioMapSCI11 = 0;
|
_audioMapSCI11 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1625,7 +1609,7 @@ static byte* readSOLAudio(Common::SeekableReadStream *audioStream, uint32 &size,
|
||||||
flags |= Audio::Mixer::FLAG_UNSIGNED;
|
flags |= Audio::Mixer::FLAG_UNSIGNED;
|
||||||
|
|
||||||
if (audioFlags & kSolFlagCompressed) {
|
if (audioFlags & kSolFlagCompressed) {
|
||||||
buffer = new byte[size * 2];
|
buffer = (byte *)malloc(size * 2);
|
||||||
|
|
||||||
if (audioFlags & kSolFlag16Bit)
|
if (audioFlags & kSolFlag16Bit)
|
||||||
deDPCM16(buffer, *audioStream, size);
|
deDPCM16(buffer, *audioStream, size);
|
||||||
|
|
|
@ -141,6 +141,38 @@ struct ResourceSource {
|
||||||
|
|
||||||
class ResourceManager;
|
class ResourceManager;
|
||||||
|
|
||||||
|
class ResourceId {
|
||||||
|
public:
|
||||||
|
ResourceType type;
|
||||||
|
uint16 number;
|
||||||
|
uint32 tuple; // Only used for audio36 and sync36
|
||||||
|
|
||||||
|
ResourceId() : type(kResourceTypeInvalid), number(0), tuple(0) { };
|
||||||
|
ResourceId(ResourceType type_, uint16 number_, uint32 tuple_ = 0) : type(type_), number(number_), tuple(tuple_) { }
|
||||||
|
|
||||||
|
Common::String toString() {
|
||||||
|
char buf[32];
|
||||||
|
|
||||||
|
snprintf(buf, 32, "%s.%i", getResourceTypeName(type), number);
|
||||||
|
Common::String retStr = buf;
|
||||||
|
|
||||||
|
if (tuple != 0) {
|
||||||
|
snprintf(buf, 32, "(%i, %i, %i, %i)", tuple >> 24, (tuple >> 16) & 0xff, (tuple >> 8) & 0xff, tuple & 0xff);
|
||||||
|
retStr += buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
return retStr;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ResourceIdHash : public Common::UnaryFunction<ResourceId, uint> {
|
||||||
|
uint operator()(ResourceId val) const { return ((uint)((val.type << 16) | val.number)) ^ val.tuple; }
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ResourceIdEqualTo : public Common::BinaryFunction<ResourceId, ResourceId, bool> {
|
||||||
|
bool operator()(const ResourceId &x, const ResourceId &y) const { return (x.type == y.type) && (x.number == y.number) && (x.tuple == y.tuple); }
|
||||||
|
};
|
||||||
|
|
||||||
/** Class for storing resources in memory */
|
/** Class for storing resources in memory */
|
||||||
class Resource {
|
class Resource {
|
||||||
friend class ResourceManager;
|
friend class ResourceManager;
|
||||||
|
@ -153,9 +185,7 @@ public:
|
||||||
// to let the rest of the engine compile without changes
|
// to let the rest of the engine compile without changes
|
||||||
public:
|
public:
|
||||||
byte *data;
|
byte *data;
|
||||||
uint16 number;
|
ResourceId id;
|
||||||
ResourceType type;
|
|
||||||
uint32 id; //!< contains number and type.
|
|
||||||
uint32 size;
|
uint32 size;
|
||||||
byte *header;
|
byte *header;
|
||||||
uint32 headerSize;
|
uint32 headerSize;
|
||||||
|
@ -166,6 +196,7 @@ protected:
|
||||||
ResourceSource *source;
|
ResourceSource *source;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef Common::HashMap<ResourceId, Resource *, ResourceIdHash, ResourceIdEqualTo> ResourceMap;
|
||||||
|
|
||||||
class ResourceManager {
|
class ResourceManager {
|
||||||
public:
|
public:
|
||||||
|
@ -223,7 +254,7 @@ protected:
|
||||||
int _memoryLocked; //!< Amount of resource bytes in locked memory
|
int _memoryLocked; //!< Amount of resource bytes in locked memory
|
||||||
int _memoryLRU; //!< Amount of resource bytes under LRU control
|
int _memoryLRU; //!< Amount of resource bytes under LRU control
|
||||||
Common::List<Resource *> _LRU; //!< Last Resource Used list
|
Common::List<Resource *> _LRU; //!< Last Resource Used list
|
||||||
Common::HashMap<uint32, Resource *> _resMap;
|
ResourceMap _resMap;
|
||||||
Common::List<Common::File *> _volumeFiles; //!< list of opened volume files
|
Common::List<Common::File *> _volumeFiles; //!< list of opened volume files
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -242,7 +242,7 @@ void Vocabulary::freeSuffixes() {
|
||||||
resource = _resmgr->findResource(kResourceTypeVocab, VOCAB_RESOURCE_SCI1_SUFFIX_VOCAB, 0);
|
resource = _resmgr->findResource(kResourceTypeVocab, VOCAB_RESOURCE_SCI1_SUFFIX_VOCAB, 0);
|
||||||
|
|
||||||
if (resource)
|
if (resource)
|
||||||
_resmgr->unlockResource(resource, resource->number, kResourceTypeVocab);
|
_resmgr->unlockResource(resource, resource->id.number, kResourceTypeVocab);
|
||||||
|
|
||||||
_parserSuffixes.clear();
|
_parserSuffixes.clear();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue