[Scummvm-git-logs] scummvm master -> b7aeac773bdd2df5b15dd9ca0890b7c3e7be5377

mduggan mgithub at guarana.org
Sat Jun 19 09:04:33 UTC 2021


This automated email contains information about 9 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
8bf1fdc28e ULTIMA8: Remove duplicate Crusader shield type variables
cb34bb7f05 ULTIMA8: Fix subtitle display on some Crusader movies
e686fbdf51 ULTIMA8: Clear Crusader stasis flag on load to fix loading from F7
c050663500 ULTIMA8: Avoid possible crash during Crusader teleport
27829683aa ULTIMA8: Fix pointer-write endianness for Usecode globals
4c8707970c ULTIMA8: Update comments and remove dead code
adebe08365 ULTIMA8: Make stack size calculation a little clearer
6b66d7007a ULTIMA8: Add a helper function to clean up list code
b7aeac773b ULTIMA8: Correct range calculation for Crusader intrinsic


Commit: 8bf1fdc28eb2845f73289096d92bca984ebf8050
    https://github.com/scummvm/scummvm/commit/8bf1fdc28eb2845f73289096d92bca984ebf8050
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-06-19T18:00:29+09:00

Commit Message:
ULTIMA8: Remove duplicate Crusader shield type variables

Changed paths:
    engines/ultima/ultima8/world/actors/actor.cpp
    engines/ultima/ultima8/world/actors/actor.h
    engines/ultima/ultima8/world/actors/main_actor.cpp
    engines/ultima/ultima8/world/actors/main_actor.h


diff --git a/engines/ultima/ultima8/world/actors/actor.cpp b/engines/ultima/ultima8/world/actors/actor.cpp
index 412cfe3683..39c6b80eec 100644
--- a/engines/ultima/ultima8/world/actors/actor.cpp
+++ b/engines/ultima/ultima8/world/actors/actor.cpp
@@ -73,7 +73,7 @@ Actor::Actor() : _strength(0), _dexterity(0), _intelligence(0),
 		_fallStart(0), _unkByte(0), _actorFlags(0), _combatTactic(0),
 		_homeX(0), _homeY(0), _homeZ(0), _currentActivityNo(0),
 		_lastActivityNo(0), _activeWeapon(0), _lastTimeWasHit(0),
-		_shieldType(0), _attackMoveStartTime(0), _attackMoveTimeout(0),
+		_attackMoveStartTime(0), _attackMoveTimeout(0),
 		_attackMoveDodgeFactor(1), _attackAimFlag(false) {
 	_defaultActivity[0] = 0;
 	_defaultActivity[1] = 0;
@@ -1929,7 +1929,7 @@ void Actor::saveData(Common::WriteStream *ws) {
 		ws->writeUint16LE(_lastActivityNo);
 		ws->writeUint16LE(_activeWeapon);
 		ws->writeSint32LE(_lastTimeWasHit);
-		ws->writeByte(_shieldType);
+		ws->writeByte(0); // unused, keep for backward compatibility
 		ws->writeUint32LE(_attackMoveStartTime);
 		ws->writeUint32LE(_attackMoveTimeout);
 		ws->writeUint16LE(_attackMoveDodgeFactor);
@@ -1966,7 +1966,7 @@ bool Actor::loadData(Common::ReadStream *rs, uint32 version) {
 		_lastActivityNo = rs->readUint16LE();
 		_activeWeapon = rs->readUint16LE();
 		_lastTimeWasHit = rs->readSint32LE();
-		_shieldType = rs->readByte();
+		rs->readByte();  // unused, keep for backward compatibility
 		_attackMoveStartTime = rs->readUint32LE();
 		_attackMoveTimeout = rs->readUint32LE();
 		_attackMoveDodgeFactor = rs->readUint16LE();
diff --git a/engines/ultima/ultima8/world/actors/actor.h b/engines/ultima/ultima8/world/actors/actor.h
index 05d72961f2..b26bb95472 100644
--- a/engines/ultima/ultima8/world/actors/actor.h
+++ b/engines/ultima/ultima8/world/actors/actor.h
@@ -288,14 +288,6 @@ public:
 		return damage;
 	}
 
-	uint8 getShieldType() const {
-		return _shieldType;
-	}
-
-	void setShieldType(uint8 type) {
-		_shieldType = type;
-	}
-
 	uint16 getActiveWeapon() const {
 		return _activeWeapon;
 	}
@@ -462,9 +454,6 @@ protected:
 	//! Kernel timer last time NPC was hit (only used in Crusader)
 	int32 _lastTimeWasHit;
 
-	//! Type of shield (only used in Crusader)
-	uint8 _shieldType;
-
 	//! The frame certain animations last happened (for Crusader).
 	//! Used in calcualting how hard controlled actor is to hit.
 	uint32 _attackMoveStartTime;
diff --git a/engines/ultima/ultima8/world/actors/main_actor.cpp b/engines/ultima/ultima8/world/actors/main_actor.cpp
index caae02630a..f42568ac14 100644
--- a/engines/ultima/ultima8/world/actors/main_actor.cpp
+++ b/engines/ultima/ultima8/world/actors/main_actor.cpp
@@ -257,7 +257,7 @@ int16 MainActor::addItemCru(Item *item, bool showtoast) {
 			if (!existing) {
 				// Shields. Note, these are the same in Remorse and Regret.
 				if ((shapeno == 0x52e) || (shapeno == 0x52f) || (shapeno == 0x530)) {
-					int shieldtype;
+					uint16 shieldtype;
 					switch (shapeno) {
 						default:
 						case 0x52e:
@@ -950,7 +950,7 @@ void MainActor::useInventoryItem(Item *item) {
 }
 
 int MainActor::receiveShieldHit(int damage, uint16 damage_type) {
-	uint8 shieldtype = getShieldType();
+	uint16 shieldtype = getShieldType();
 	if (shieldtype == 3) {
 		shieldtype = 4;
 	}
diff --git a/engines/ultima/ultima8/world/actors/main_actor.h b/engines/ultima/ultima8/world/actors/main_actor.h
index 83aaeeb1a1..2fd16e8683 100644
--- a/engines/ultima/ultima8/world/actors/main_actor.h
+++ b/engines/ultima/ultima8/world/actors/main_actor.h
@@ -123,6 +123,14 @@ public:
 		setMana(getMaxEnergy());
 	}
 
+	void setShieldType(uint16 shieldtype) {
+		_shieldType = shieldtype;
+	}
+
+	uint16 getShieldType() {
+		return _shieldType;
+	}
+
 	bool hasKeycard(int num) const;
 	void addKeycard(int bitno);
 
@@ -184,7 +192,9 @@ protected:
 
 	Std::string _name;
 
+	//! Process for a shield zap animation sprite
 	uint16 _shieldSpriteProc;
+	//! Type of shield (only used in Crusader)
 	uint16 _shieldType;
 
 	static ShapeInfo *_kneelingShapeInfo;


Commit: cb34bb7f05590eb99b1c7ae482f30f35c3abecf8
    https://github.com/scummvm/scummvm/commit/cb34bb7f05590eb99b1c7ae482f30f35c3abecf8
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-06-19T18:00:29+09:00

Commit Message:
ULTIMA8: Fix subtitle display on some Crusader movies

Changed paths:
    engines/ultima/ultima8/gumps/movie_gump.cpp
    engines/ultima/ultima8/gumps/movie_gump.h


diff --git a/engines/ultima/ultima8/gumps/movie_gump.cpp b/engines/ultima/ultima8/gumps/movie_gump.cpp
index 9a1fa841dc..b45ab72120 100644
--- a/engines/ultima/ultima8/gumps/movie_gump.cpp
+++ b/engines/ultima/ultima8/gumps/movie_gump.cpp
@@ -104,7 +104,7 @@ MovieGump::MovieGump() : ModalGump(), _player(nullptr), _subtitleWidget(0) {
 MovieGump::MovieGump(int width, int height, Common::SeekableReadStream *rs,
 					 bool introMusicHack, bool noScale, const byte *overridePal,
 					 uint32 flags, int32 layer)
-		: ModalGump(50, 50, width, height, 0, flags, layer), _subtitleWidget(0) {
+		: ModalGump(50, 50, width, height, 0, flags, layer), _subtitleWidget(0), _lastFrameNo(-1) {
 	uint32 stream_id = rs->readUint32BE();
 	rs->seek(-4, SEEK_CUR);
 	if (stream_id == 0x52494646) {// 'RIFF' - crusader AVIs
@@ -152,19 +152,24 @@ void MovieGump::run() {
 
 	AVIPlayer *aviplayer = dynamic_cast<AVIPlayer *>(_player);
 	if (aviplayer) {
+		// The AVI player can skip frame numbers, so search back from the
+		// last frame to make sure we don't miss subtitles
 		const int frameno = aviplayer->getFrameNo();
-		if (_subtitles.contains(frameno)) {
-			TextWidget *subtitle = dynamic_cast<TextWidget *>(getGump(_subtitleWidget));
-			if (subtitle)
-				subtitle->Close();
-			// Create a new TextWidget
-			TextWidget *widget = new TextWidget(0, 0, _subtitles[frameno], true, 4, 640, 10);
-			widget->InitGump(this);
-			widget->setRelativePosition(BOTTOM_CENTER, 0, -10);
-			// Subtitles should be white.
-			widget->setBlendColour(0xffffffff);
-			_subtitleWidget = widget->getObjId();
+		for (int f = _lastFrameNo + 1; f <= frameno; f++) {
+			if (_subtitles.contains(f)) {
+				TextWidget *subtitle = dynamic_cast<TextWidget *>(getGump(_subtitleWidget));
+				if (subtitle)
+					subtitle->Close();
+				// Create a new TextWidget
+				TextWidget *widget = new TextWidget(0, 0, _subtitles[f], true, 4, 640, 10);
+				widget->InitGump(this);
+				widget->setRelativePosition(BOTTOM_CENTER, 0, -10);
+				// Subtitles should be white.
+				widget->setBlendColour(0xffffffff);
+				_subtitleWidget = widget->getObjId();
+			}
 		}
+		_lastFrameNo = frameno;
 	}
 
 	if (!_player->isPlaying()) {
@@ -308,13 +313,18 @@ uint32 MovieGump::I_playMovieCutsceneAlt(const uint8 *args, unsigned int /*argsi
 
 	if (!x)
 		x = 640;
+	else
+		x *= 3;
+
 	if (!y)
 		y = 480;
+	else
+		y *= 3;
 
 	warning("MovieGump::I_playMovieCutsceneAlt: TODO: This intrinsic should pause and fade the background to grey (%s, %d)",
 			name.c_str(), item ? item->getObjId() : 0);
 
-	CruMovieViewer(name, x * 3, y * 3, nullptr, nullptr);
+	CruMovieViewer(name, x, y, nullptr, nullptr);
 
 	return 0;
 }
diff --git a/engines/ultima/ultima8/gumps/movie_gump.h b/engines/ultima/ultima8/gumps/movie_gump.h
index bcc8af0596..38ed46d88d 100644
--- a/engines/ultima/ultima8/gumps/movie_gump.h
+++ b/engines/ultima/ultima8/gumps/movie_gump.h
@@ -80,6 +80,7 @@ protected:
 
 	Common::HashMap<int, Common::String> _subtitles;
 	uint16 _subtitleWidget;
+	int _lastFrameNo;
 
 };
 


Commit: e686fbdf514913156df5c1b7e32d64c89c3431c8
    https://github.com/scummvm/scummvm/commit/e686fbdf514913156df5c1b7e32d64c89c3431c8
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-06-19T18:00:29+09:00

Commit Message:
ULTIMA8: Clear Crusader stasis flag on load to fix loading from F7

Changed paths:
    engines/ultima/ultima8/ultima8.cpp


diff --git a/engines/ultima/ultima8/ultima8.cpp b/engines/ultima/ultima8/ultima8.cpp
index ba97fdc86d..44d340b906 100644
--- a/engines/ultima/ultima8/ultima8.cpp
+++ b/engines/ultima/ultima8/ultima8.cpp
@@ -1340,6 +1340,20 @@ Common::Error Ultima8Engine::loadGameStream(Common::SeekableReadStream *stream)
 	_mouse->popAllCursors();
 	_mouse->pushMouseCursor();
 
+	/*
+	// In case of bugs, ensure persistent processes are around?
+	if (!TargetReticleProcess::get_instance())
+		_kernel->addProcess(new TargetReticleProcess());
+	if (!ItemSelectionProcess::get_instance())
+		_kernel->addProcess(new ItemSelectionProcess());
+	if (!CrosshairProcess::get_instance())
+		_kernel->addProcess(new CrosshairProcess());
+	if (!CycleProcess::get_instance())
+		_kernel->addProcess(new CycleProcess());
+	if (!SnapProcess::get_instance())
+		_kernel->addProcess(new SnapProcess());
+	 */
+
 	if (!totalok) {
 		Error(message, "Error Loading savegame");
 		delete sg;
@@ -1435,6 +1449,7 @@ bool Ultima8Engine::load(Common::ReadStream *rs, uint32 version) {
 
 	if (GAME_IS_CRUSADER) {
 		_unkCrusaderFlag  = (rs->readByte() != 0);
+		_cruStasis = false;
 	}
 
 	// no gump should be moused over after load


Commit: c0506635006eb6c472e4deb7cc84edc4b7180a30
    https://github.com/scummvm/scummvm/commit/c0506635006eb6c472e4deb7cc84edc4b7180a30
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-06-19T18:00:29+09:00

Commit Message:
ULTIMA8: Avoid possible crash during Crusader teleport

Changed paths:
    engines/ultima/ultima8/world/crosshair_process.cpp


diff --git a/engines/ultima/ultima8/world/crosshair_process.cpp b/engines/ultima/ultima8/world/crosshair_process.cpp
index 3db2f19076..07de168195 100644
--- a/engines/ultima/ultima8/world/crosshair_process.cpp
+++ b/engines/ultima/ultima8/world/crosshair_process.cpp
@@ -90,13 +90,15 @@ void CrosshairProcess::run() {
 										   0, 0, Item::EXT_SPRITE, true);
 			setItemNum(item->getObjId());
 		}
-		assert(item);
-		item->move(ax, ay, az);
+		if (item)
+			item->move(ax, ay, az);
+		else
+			_itemNum = 0; // sprite gone? can happen during teleport.
 	} else {
 		if (_itemNum) {
 			Item *item = getItem(_itemNum);
-			assert(item);
-			item->destroy();
+			if (item)
+				item->destroy();
 			_itemNum = 0;
 		}
 	}


Commit: 27829683aa29ee5c21431ed30baccd4839a4eb43
    https://github.com/scummvm/scummvm/commit/27829683aa29ee5c21431ed30baccd4839a4eb43
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-06-19T18:00:29+09:00

Commit Message:
ULTIMA8: Fix pointer-write endianness for Usecode globals

I don't think this actually ever gets used by the usecode so probably makes no
difference, fixed it to be sure anyway. Pointer read gets used a lot, but it
was already correct.

Changed paths:
    engines/ultima/ultima8/usecode/uc_machine.cpp


diff --git a/engines/ultima/ultima8/usecode/uc_machine.cpp b/engines/ultima/ultima8/usecode/uc_machine.cpp
index 4f6846319a..560dc1186e 100644
--- a/engines/ultima/ultima8/usecode/uc_machine.cpp
+++ b/engines/ultima/ultima8/usecode/uc_machine.cpp
@@ -1427,6 +1427,10 @@ void UCMachine::execProcess(UCProcess *p) {
 			int this_size = cs->readByte();
 			int unknown = cs->readByte(); // ??
 
+			// This only gets used in U8.  If it were used in Crusader it would
+			// need the offset translation done in 0x57.
+			assert(GAME_IS_U8);
+
 			debug(MM_INFO, "spawn inline\t%04X:%04X+%04X=%04X %02X %02X\n",
 				classid, offset, delta, offset + delta, this_size, unknown);
 
@@ -2217,7 +2221,7 @@ bool UCMachine::assignPointer(uint32 ptr, const uint8 *data, uint32 size) {
 		if (size == 1) {
 			_globals->setEntries(offset, 1, data[0]);
 		} else if (size == 2) {
-			uint16 val = ((data[0] << 8) | data[1]);
+			uint16 val = ((data[1] << 8) | data[0]);
 			_globals->setEntries(offset, 2, val);
 		} else {
 			CANT_HAPPEN_MSG("Global pointers must be size 1 or 2");


Commit: 4c8707970c33773d220399e79b37090962e77ddc
    https://github.com/scummvm/scummvm/commit/4c8707970c33773d220399e79b37090962e77ddc
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-06-19T18:00:29+09:00

Commit Message:
ULTIMA8: Update comments and remove dead code

Changed paths:
    engines/ultima/ultima8/usecode/uc_machine.cpp


diff --git a/engines/ultima/ultima8/usecode/uc_machine.cpp b/engines/ultima/ultima8/usecode/uc_machine.cpp
index 560dc1186e..94e447d4dd 100644
--- a/engines/ultima/ultima8/usecode/uc_machine.cpp
+++ b/engines/ultima/ultima8/usecode/uc_machine.cpp
@@ -1850,10 +1850,6 @@ void UCMachine::execProcess(UCProcess *p) {
 			UCList *itemlist = getList(itemlistID);
 			uint16 index = p->_stack.access2(sp + 2);
 			si16a = static_cast<int16>(p->_stack.access2(sp + 4));
-#if 0
-			uint16 scriptsize = p->_stack.access2(sp + 6);
-			const uint8 *loopscript = p->_stack.access(sp + 8);
-#endif
 
 			if (!itemlist) {
 				perr << "Invalid item list in loopnext!" << Std::endl;
@@ -1872,11 +1868,7 @@ void UCMachine::execProcess(UCProcess *p) {
 				uint16 objid = p->_stack.access2(p->_bp + si16a);
 				Item *item = getItem(objid);
 				if (item) {
-#if 0
-					valid = item->checkLoopScript(loopscript, scriptsize);
-#else
 					valid = true;
-#endif
 				}
 
 				if (!valid) index++;
@@ -1908,42 +1900,21 @@ void UCMachine::execProcess(UCProcess *p) {
 
 		case 0x75:
 		case 0x76:
-			// 75 xx yy zz zz
-			// 76 xx yy zz zz
-			// xx appears to be the location to store 'current' value from the
-			//   list (BP+xx)
+			// 75 xx yy zz zz  (foreach list)
+			// 76 xx yy zz zz  (foreach string list)
+			// xx is the stack offset to store 'current' value from the list
+			//   (BP+xx)
 			// yy is the 'datasize' of the list, identical to the second parameter
 			//   of the create list/slist opcodes
-			// zzzz appears to be the offset to jump to after it's finished the
-			//   iteration, the opcode before is a 'jmp' to the original position
-			//   of the opcode.
-			// (all guesses from Remorse1.21 usecode, _may_ be different in u8,
-			//   unlikely though)
-			// the way it appears to operate is it pops a 'word' off the stack
-			//   (maximum number of items to iterate through? No idea, I've only
-			//   seen 0xFFFF pushed before it (in Remorse1.21)), then pops
-			//   the 'list' off to iterate through
-
-			// it seems as if there's no way provided to store index
-			// and list. Assuming there are no nested loops, this isn't
-			// a problem. If there -are- nested loops, we could use a stack
-			// for these.
-			// There may be problems with jumps from inside the loop to outside
-			// Either these are forbidden, or we have to detect when jumping
-			// to outside a loop? (yuck)
-			// (this will be _very_ messy when combined with nested loops,
-			//  let's hope it won't be necessary)
-
-			// random idea: maybe the 0xFFFF on the stack is used to
-			// indicate the start of a loop? Would be mildly ugly, but could
-			// be useful for nested loops or loop-escaping jumps
-
-			// other random idea: 0xFFFF could also be the loop index
-			// to start with minus 1. (This would clean up the 'loop_index=0'
-			// or 'loop_index++' distinction a bit)
+			// zzzz is the offset to jump to after it's finished iteration
+			//	 (the opcode before is always a 'jmp' to the start of the loop)
+			// 2 16 bit values are on the stack and left there during each
+			//   iteration:
+			//   - loop index (always starts at 0xffff), updated each iteration
+			//   - list id
 
 			// 75 is for lists, 76 for slists
-			// Only difference should be in the freeing afterwards.
+			// The only difference should be in the freeing afterwards.
 			// Strings are _not_ duplicated when putting them in the loopvar
 			// Lists _are_ freed afterwards
 


Commit: adebe08365b9e46e4bf4f578af0a0a85fc225d9a
    https://github.com/scummvm/scummvm/commit/adebe08365b9e46e4bf4f578af0a0a85fc225d9a
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-06-19T18:00:29+09:00

Commit Message:
ULTIMA8: Make stack size calculation a little clearer

Changed paths:
    engines/ultima/ultima8/usecode/uc_machine.cpp


diff --git a/engines/ultima/ultima8/usecode/uc_machine.cpp b/engines/ultima/ultima8/usecode/uc_machine.cpp
index 94e447d4dd..ad1118f29d 100644
--- a/engines/ultima/ultima8/usecode/uc_machine.cpp
+++ b/engines/ultima/ultima8/usecode/uc_machine.cpp
@@ -1747,8 +1747,7 @@ void UCMachine::execProcess(UCProcess *p) {
 			case 2:
 			case 3: {
 				// area search (3 = recursive)
-				stacksize = 0x34;
-				if (GAME_IS_CRUSADER) stacksize = 0x3A;
+				stacksize = GAME_IS_U8 ? 0x34 : 0x3A;
 				if (searchtype == 3) recurse = true;
 
 				// ui16a = item, ui16b = range
@@ -1768,9 +1767,8 @@ void UCMachine::execProcess(UCProcess *p) {
 			}
 			case 4:
 			case 5: {
-				// container search (4 = recursive)
-				stacksize = 0x28;
-				if (GAME_IS_CRUSADER) stacksize = 0x2A;
+				// container search (5 = recursive)
+				stacksize = GAME_IS_U8 ? 0x28 : 0x2A;
 				if (searchtype == 5) {
 					stacksize += 2;
 					recurse = true;
@@ -1796,8 +1794,7 @@ void UCMachine::execProcess(UCProcess *p) {
 			}
 			case 6: {
 				// Surface search
-				stacksize = 0x3D;
-				if (GAME_IS_CRUSADER) stacksize = 0x43;
+				stacksize = GAME_IS_U8 ? 0x3D : 0x43;
 
 				bool above = ui16a != 0xFFFF;
 				bool below = ui16b != 0xFFFF;


Commit: 6b66d7007a16bd0ffbdf2800802c3f8a10991a63
    https://github.com/scummvm/scummvm/commit/6b66d7007a16bd0ffbdf2800802c3f8a10991a63
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-06-19T18:00:29+09:00

Commit Message:
ULTIMA8: Add a helper function to clean up list code

Changed paths:
    engines/ultima/ultima8/usecode/uc_list.h
    engines/ultima/ultima8/world/container.cpp
    engines/ultima/ultima8/world/current_map.cpp


diff --git a/engines/ultima/ultima8/usecode/uc_list.h b/engines/ultima/ultima8/usecode/uc_list.h
index fbba166f89..c323192536 100644
--- a/engines/ultima/ultima8/usecode/uc_list.h
+++ b/engines/ultima/ultima8/usecode/uc_list.h
@@ -77,6 +77,14 @@ public:
 		_size++;
 	}
 
+	void appenduint16(uint16 val) {
+		assert(_elementSize == 2);
+		uint8 buf[2];
+		buf[0] = static_cast<uint8>(val);
+		buf[1] = static_cast<uint8>(val >> 8);
+		append(buf);
+	}
+
 	void remove(const uint8 *e) {
 		// do we need to erase all occurences of e or just the first one?
 		// (deleting all, currently)
@@ -105,20 +113,23 @@ public:
 	}
 
 	void appendList(const UCList &l) {
-		// need to check if elementsizes match...
+		// elementsizes should match...
+		assert(_elementSize == l.getElementSize());
 		_elements.reserve(_elementSize * (_size + l._size));
-		unsigned int lsize = l._size;
-		for (unsigned int i = 0; i < lsize; i++)
+		for (unsigned int i = 0; i < l._size; i++)
 			append(l[i]);
 	}
 	void unionList(const UCList &l) { // like append, but remove duplicates
-		// need to check if elementsizes match...
+		// elementsizes should match...
+		assert(_elementSize == l.getElementSize());
 		_elements.reserve(_elementSize * (_size + l._size));
 		for (unsigned int i = 0; i < l._size; i++)
 			if (!inList(l[i]))
 				append(l[i]);
 	}
 	void subtractList(const UCList &l) {
+		// elementsizes should match...
+		assert(_elementSize == l.getElementSize());
 		for (unsigned int i = 0; i < l._size; i++)
 			remove(l[i]);
 	}
diff --git a/engines/ultima/ultima8/world/container.cpp b/engines/ultima/ultima8/world/container.cpp
index 7a65f93b35..49c46100b7 100644
--- a/engines/ultima/ultima8/world/container.cpp
+++ b/engines/ultima/ultima8/world/container.cpp
@@ -275,10 +275,7 @@ void Container::containerSearch(UCList *itemlist, const uint8 *loopscript,
 		if ((*iter)->checkLoopScript(loopscript, scriptsize)) {
 			assert(itemlist->getElementSize() == 2);
 			uint16 oId = (*iter)->getObjId();
-			uint8 buf[2];
-			buf[0] = static_cast<uint8>(oId);
-			buf[1] = static_cast<uint8>(oId >> 8);
-			itemlist->append(buf);
+			itemlist->appenduint16(oId);
 		}
 
 		if (recurse) {
diff --git a/engines/ultima/ultima8/world/current_map.cpp b/engines/ultima/ultima8/world/current_map.cpp
index ad342033ed..46c27da22c 100644
--- a/engines/ultima/ultima8/world/current_map.cpp
+++ b/engines/ultima/ultima8/world/current_map.cpp
@@ -607,11 +607,7 @@ void CurrentMap::areaSearch(UCList *itemlist, const uint8 *loopscript,
 				// check item against loopscript
 				if (item->checkLoopScript(loopscript, scriptsize)) {
 					assert(itemlist->getElementSize() == 2);
-					const uint16 objid = item->getObjId();
-					uint8 buf[2];
-					buf[0] = static_cast<uint8>(objid);
-					buf[1] = static_cast<uint8>(objid >> 8);
-					itemlist->append(buf);
+					itemlist->appenduint16(item->getObjId());
 				}
 
 				if (recurse) {
@@ -696,11 +692,7 @@ void CurrentMap::surfaceSearch(UCList *itemlist, const uint8 *loopscript,
 				// check item against loopscript
 				if (item->checkLoopScript(loopscript, scriptsize)) {
 					assert(itemlist->getElementSize() == 2);
-					uint16 objid = item->getObjId();
-					uint8 buf[2];
-					buf[0] = static_cast<uint8>(objid);
-					buf[1] = static_cast<uint8>(objid >> 8);
-					itemlist->append(buf);
+					itemlist->appenduint16(item->getObjId());
 				}
 			}
 		}


Commit: b7aeac773bdd2df5b15dd9ca0890b7c3e7be5377
    https://github.com/scummvm/scummvm/commit/b7aeac773bdd2df5b15dd9ca0890b7c3e7be5377
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-06-19T18:00:29+09:00

Commit Message:
ULTIMA8: Correct range calculation for Crusader intrinsic

Changed paths:
    engines/ultima/ultima8/world/item.cpp


diff --git a/engines/ultima/ultima8/world/item.cpp b/engines/ultima/ultima8/world/item.cpp
index e6c25a2424..6c0d7f19f1 100644
--- a/engines/ultima/ultima8/world/item.cpp
+++ b/engines/ultima/ultima8/world/item.cpp
@@ -3904,7 +3904,7 @@ uint32 Item::I_getRangeIfVisible(const uint8 *args, unsigned int /*argsize*/) {
 		return 0;
 
 	// Somewhat arbitrary maths in here to replicate Crusader behavior.
-	int range = item->getRangeIfVisible(*other) / 16;
+	int range = item->getRangeIfVisible(*other) / 32;
 	if ((range & 0xf) != 0)
 		range++;
 




More information about the Scummvm-git-logs mailing list