SAGA: replace Resource:loadResource malloc with ByteArray class

svn-id: r53779
This commit is contained in:
Andrew Kurushin 2010-10-24 22:17:44 +00:00
parent 859c1c2c08
commit 67cc1b8a84
28 changed files with 313 additions and 400 deletions

View file

@ -173,13 +173,11 @@ void Gfx::initPalette() {
error("Resource::loadGlobalResources() resource context not found");
}
byte *resourcePointer;
size_t resourceLength;
ByteArray resourceData;
_vm->_resource->loadResource(resourceContext, RID_IHNM_DEFAULT_PALETTE,
resourcePointer, resourceLength);
_vm->_resource->loadResource(resourceContext, RID_IHNM_DEFAULT_PALETTE, resourceData);
MemoryReadStream metaS(resourcePointer, resourceLength);
ByteArrayReadStreamEndian metaS(resourceData);
for (int i = 0; i < 256; i++) {
_globalPalette[i].red = metaS.readByte();
@ -187,8 +185,6 @@ void Gfx::initPalette() {
_globalPalette[i].blue = metaS.readByte();
}
free(resourcePointer);
setPalette(_globalPalette, true);
}
@ -504,19 +500,17 @@ void Gfx::setCursor(CursorType cursorType) {
break;
}
byte *resource;
size_t resourceLength;
ByteArray resourceData;
ByteArray image;
int width, height;
if (resourceId != (uint32)-1) {
ResourceContext *context = _vm->_resource->getContext(GAME_RESOURCEFILE);
_vm->_resource->loadResource(context, resourceId, resource, resourceLength);
_vm->_resource->loadResource(context, resourceId, resourceData);
_vm->decodeBGImage(resource, resourceLength, image, &width, &height);
_vm->decodeBGImage(resourceData, image, &width, &height);
} else {
resource = NULL;
width = height = 31;
image.resize(width * height);
@ -530,8 +524,6 @@ void Gfx::setCursor(CursorType cursorType) {
// Note: Hard-coded hotspot
CursorMan.replaceCursor(image.getBuffer(), width, height, 15, 15, 0);
free(resource);
}
}