Opened 4 months ago

Closed 4 months ago

#15600 closed defect (fixed)

PEGASUS: Possible bug in Cursor::loadCursorImage()

Reported by: eriktorbjorn Owned by: eriktorbjorn
Priority: normal Component: Engine: Pegasus
Version: Keywords:
Cc: Game: Journeyman Project Pegasus Prime

Description

I don't know where this happens, but I was looking at the Pegasus engine's Cursor::loadCursorImage() for reference and noticed this:

	// Mask section
	cicnStream->readUint32BE(); // mask baseAddr
	uint16 maskRowBytes = cicnStream->readUint16BE(); // mask rowBytes
	cicnStream->skip(3 * 2); // mask rect
	/* uint16 maskHeight = */ cicnStream->readUint16BE();

	// Bitmap section
	cicnStream->readUint32BE(); // baseAddr
	uint16 rowBytes = cicnStream->readUint16BE();
	cicnStream->readUint16BE(); // top
	cicnStream->readUint16BE(); // left
	uint16 height = cicnStream->readUint16BE(); // bottom
	cicnStream->readUint16BE(); // right

	// Data section
	cicnStream->readUint32BE(); // icon handle
	cicnStream->skip(maskRowBytes * height); // FIXME: maskHeight doesn't work here, though the specs say it should
	cicnStream->skip(rowBytes * height);

It's using height to skip the mask because "maskHeight doesn't work here". But it would have read maskHeight from the last field in the mask rect. Judging by how it reads height, it should have used the third field, because the fourth one would be the width, wouldn't it? (Assuming the top and left fields are both zero.)

Change History (3)

comment:1 by eriktorbjorn, 4 months ago

I'll see if I can rewrite this to use the new cicn decoder that was added recently. It's only been tested with the Mac SCUMM games, but it was based partly on the code in this engine.

comment:2 by Torbjörn Andersson <eriktorbjorn@…>, 4 months ago

In 7a4ef281:

PEGASUS: Replaced cicn cursor loader, fixing #15600 in the process

The cicn cursor loader was introduced recently for the Mac SCUMM v6-7
games. I still haven't played Pegasus Prime, but I have forced it to
load all the nine cursors (ID 128-133, 900-901, and 20000) and it seems
to work fine for all of them. At least after I made a few fixes to the
loader itself.

I did get some crashes with the old code when trying to compare them, so
it's possible that we should backport this to 2.9. But I haven't seen
any bug reports about it, so maybe not...?

comment:3 by eriktorbjorn, 4 months ago

Owner: set to eriktorbjorn
Resolution: fixed
Status: newclosed

I have replaced the old cicn loading code, fixing some issues with the new one in the process. I haven't played the game, but I've tried it with all nine cicn resources I could find, as well as the cicn resources from the Mac SCUMM games to make sure it didn't regress.

Note: See TracTickets for help on using tickets.