[Scummvm-git-logs] scummvm master -> 3d2a2cc6101fb236fd7a7de418e4a89fbb432bdc

mduggan noreply at scummvm.org
Fri Mar 25 04:38:20 UTC 2022


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

Summary:
8d9081e7aa ULTIMA8: Destroy actor contents on death only for FAST_ONLY
3d2a2cc610 ULTIMA8: Small const correctness improvements


Commit: 8d9081e7aaa72fda578b368771160bd2d01ebb79
    https://github.com/scummvm/scummvm/commit/8d9081e7aaa72fda578b368771160bd2d01ebb79
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2022-03-25T13:34:07+09:00

Commit Message:
ULTIMA8: Destroy actor contents on death only for FAST_ONLY

On death, the original game only destroys the contents for actors who are
marked as FAST_ONLY, so important NPCs should not lose their contents.

This should improve the behavior a bit and might help to fix bug #12504 (where
malchir should drop a book) - but it does not totally fix that problem so there
is still something else that needs fixing.

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


diff --git a/engines/ultima/ultima8/world/actors/actor.cpp b/engines/ultima/ultima8/world/actors/actor.cpp
index 45738302eb4..46706d2698c 100644
--- a/engines/ultima/ultima8/world/actors/actor.cpp
+++ b/engines/ultima/ultima8/world/actors/actor.cpp
@@ -1345,7 +1345,8 @@ ProcId Actor::dieU8(uint16 damageType) {
 		}
 	}
 
-	destroyContents();
+	if (getFlags() & Item::FLG_FAST_ONLY)
+		destroyContents();
 	giveTreasure();
 
 	const ShapeInfo *shapeinfo = getShapeInfo();
@@ -1425,9 +1426,6 @@ ProcId Actor::dieCru(uint16 damageType, uint16 damagePts, Direction srcDir) {
 	ProcId lastanim = 0;
 	Kernel::get_instance()->killProcesses(_objId, Kernel::PROC_TYPE_ALL, true);
 
-	destroyContents();
-	giveTreasure();
-
 	if (getShape() == 0x5d6 && GAME_IS_REGRET) {
 		// you only die twice.. (frozen person breaking into pieces)
 		if (!isBusy()) {


Commit: 3d2a2cc6101fb236fd7a7de418e4a89fbb432bdc
    https://github.com/scummvm/scummvm/commit/3d2a2cc6101fb236fd7a7de418e4a89fbb432bdc
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2022-03-25T13:37:07+09:00

Commit Message:
ULTIMA8: Small const correctness improvements

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


diff --git a/engines/ultima/ultima8/world/container.cpp b/engines/ultima/ultima8/world/container.cpp
index 7d1b78935b7..e0086a60c5c 100644
--- a/engines/ultima/ultima8/world/container.cpp
+++ b/engines/ultima/ultima8/world/container.cpp
@@ -120,8 +120,8 @@ bool Container::CanAddItem(Item *item, bool checkwghtvol) {
 		if (volume + item->getVolume() > capacity)
 			return false;
 
-		Item *p = getTopItem();
-		Item *current = item->getTopItem();
+		const Item *p = getTopItem();
+		const Item *current = item->getTopItem();
 
 		// From outside to inside Avatar's inventory?
 		if (p->getObjId() == 1 && current->getObjId() != 1) {
@@ -289,7 +289,7 @@ void Container::containerSearch(UCList *itemlist, const uint8 *loopscript,
 }
 
 Item *Container::getFirstItemWithShape(uint16 shapeno, bool recurse) {
-	Std::list<Item *>::iterator iter;
+	Std::list<Item *>::const_iterator iter;
 	for (iter = _contents.begin(); iter != _contents.end(); ++iter) {
 		if ((*iter)->getShape() == shapeno)
 			return *iter;
@@ -309,7 +309,7 @@ Item *Container::getFirstItemWithShape(uint16 shapeno, bool recurse) {
 }
 
 void Container::getItemsWithShapeFamily(Std::vector<Item *> &itemlist, uint16 family, bool recurse) {
-	Std::list<Item *>::iterator iter;
+	Std::list<Item *>::const_iterator iter;
 	for (iter = _contents.begin(); iter != _contents.end(); ++iter) {
 		if ((*iter)->getShapeInfo()->_family == family)
 			itemlist.push_back(*iter);
diff --git a/engines/ultima/ultima8/world/item.cpp b/engines/ultima/ultima8/world/item.cpp
index f9d46ede68a..071196d4ac4 100644
--- a/engines/ultima/ultima8/world/item.cpp
+++ b/engines/ultima/ultima8/world/item.cpp
@@ -133,8 +133,8 @@ Container *Item::getParentAsContainer() const {
 	return p;
 }
 
-Item *Item::getTopItem() {
-	Container *parentItem = getParentAsContainer();
+const Item *Item::getTopItem() const {
+	const Container *parentItem = getParentAsContainer();
 
 	if (!parentItem) return this;
 
@@ -1503,7 +1503,7 @@ int32 Item::getTargetZRelativeToAttackerZ(int32 otherz) const {
 }
 
 
-unsigned int Item::countNearby(uint32 shape, uint16 range) {
+unsigned int Item::countNearby(uint32 shape, uint16 range) const {
 	const CurrentMap *currentmap = World::get_instance()->getCurrentMap();
 	UCList itemlist(2);
 	LOOPSCRIPT(script, LS_SHAPE_EQUAL(shape));
@@ -2338,12 +2338,12 @@ void Item::receiveHitCru(uint16 other, Direction dir, int damage, uint16 type) {
 }
 
 
-bool Item::canDrag() {
+bool Item::canDrag() const {
 	const ShapeInfo *si = getShapeInfo();
 	if (si->is_fixed()) return false;
 	if (si->_weight == 0) return false;
 
-	Actor *actor = dynamic_cast<Actor *>(this);
+	const Actor *actor = dynamic_cast<const Actor *>(this);
 	if (actor) {
 		// living actors can't be moved
 		if (!actor->isDead()) return false;
@@ -2354,10 +2354,10 @@ bool Item::canDrag() {
 	return true;
 }
 
-int Item::getThrowRange() {
+int Item::getThrowRange() const {
 	if (!canDrag()) return 0;
 
-	Actor *avatar = getMainActor();
+	const Actor *avatar = getMainActor();
 
 	int range = 64 - getTotalWeight() + avatar->getStr();
 	if (range < 1) range = 1;
@@ -2393,8 +2393,8 @@ static bool checkLineOfSightCollisions(
 	return (blocked_time >= other_hit_time);
 }
 
-bool Item::canReach(Item *other, int range,
-					int32 otherX, int32 otherY, int32 otherZ) {
+bool Item::canReach(const Item *other, int range,
+					int32 otherX, int32 otherY, int32 otherZ) const {
 	// get location and dimensions of self and other (or their root containers)
 	int32 thisX, thisY, thisZ;
 	int32 thisXd, thisYd, thisZd;
@@ -2485,7 +2485,7 @@ static inline bool bothInRange(uint32 x, uint32 y, uint32 lo, uint32 hi) {
 	return (x >= lo && x <= hi && y >= lo && y <= hi);
 }
 
-bool Item::canMergeWith(Item *other) {
+bool Item::canMergeWith(const Item *other) const {
 	// can't merge with self
 	if (other->getObjId() == getObjId()) return false;
 
diff --git a/engines/ultima/ultima8/world/item.h b/engines/ultima/ultima8/world/item.h
index 57261adc14f..e8fd1ef3b6c 100644
--- a/engines/ultima/ultima8/world/item.h
+++ b/engines/ultima/ultima8/world/item.h
@@ -63,7 +63,7 @@ public:
 
 	//! Get the top-most Container this Item is in, or the Item itself if not
 	//! in a container
-	Item *getTopItem();
+	const Item *getTopItem() const;
 
 	//! Set item location. This strictly sets the location, and does not
 	//! even update CurrentMap
@@ -252,7 +252,7 @@ public:
 	uint16 getFamily() const;
 
 	//! Check if we can merge with another item.
-	bool canMergeWith(Item *other);
+	bool canMergeWith(const Item *other) const;
 
 	//! Get the open ContainerGump for this Item, if any. (NULL if not open.)
 	ObjId getGump() const {
@@ -312,7 +312,7 @@ public:
 	//! \param x x coordinate of other to use, If zero, use real coords.
 	//! \param y y coordinate of other to use
 	//! \param z z coordinate of other to use.
-	bool canReach(Item *other, int range, int32 x = 0, int32 y = 0, int32 z = 0);
+	bool canReach(const Item *other, int range, int32 x = 0, int32 y = 0, int32 z = 0) const;
 
 	//! Move the object to (x,y,z) colliding with objects in the way.
 	//! \param teleport move without colliding with objects between source and
@@ -411,14 +411,14 @@ public:
 	int32 getTargetZRelativeToAttackerZ(int32 attackerz) const;
 
 	//! count nearby objects of a given shape
-	unsigned int countNearby(uint32 shape, uint16 range);
+	unsigned int countNearby(uint32 shape, uint16 range) const;
 
 	//! can this item be dragged?
-	bool canDrag();
+	bool canDrag() const;
 
 	//! how far can this item be thrown?
 	//! \return range, or 0 if item can't be thrown
-	int getThrowRange();
+	int getThrowRange() const;
 
 	//! Check this Item against the given loopscript
 	//! \param script The loopscript to run




More information about the Scummvm-git-logs mailing list