[Scummvm-git-logs] scummvm master -> 2aec80b8c04268879b7cccf903683674d921c100

mduggan mgithub at guarana.org
Sun Jan 17 12:18:39 UTC 2021


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

Summary:
4099a785a0 ULTIMA8: Minor optimizations for pathfinding
0e685282df ULTIMA: Remove unused Std::queue
2aec80b8c0 ULTIMA8: Make enterFastArea code more like original games


Commit: 4099a785a0d889d1fb9900c1c58b121f46d64209
    https://github.com/scummvm/scummvm/commit/4099a785a0d889d1fb9900c1c58b121f46d64209
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-01-17T12:43:09+09:00

Commit Message:
ULTIMA8: Minor optimizations for pathfinding

Changed paths:
    engines/ultima/ultima8/world/actors/animation_tracker.cpp
    engines/ultima/ultima8/world/actors/pathfinder.cpp
    engines/ultima/ultima8/world/actors/pathfinder.h
    engines/ultima/ultima8/world/current_map.cpp
    engines/ultima/ultima8/world/current_map.h


diff --git a/engines/ultima/ultima8/world/actors/animation_tracker.cpp b/engines/ultima/ultima8/world/actors/animation_tracker.cpp
index d5934b8d66..08a64cc5ba 100644
--- a/engines/ultima/ultima8/world/actors/animation_tracker.cpp
+++ b/engines/ultima/ultima8/world/actors/animation_tracker.cpp
@@ -280,7 +280,7 @@ bool AnimationTracker::step() {
 		// Do the sweep test
 		Std::list<CurrentMap::SweepItem> collisions;
 		Std::list<CurrentMap::SweepItem>::const_iterator it;
-		cm->sweepTest(start, end, dims, a->getShapeInfo()->_flags, a->getObjId(),
+		cm->sweepTest(start, end, dims, a->getShapeInfo()->_flags, _actor,
 		              false, &collisions);
 
 
diff --git a/engines/ultima/ultima8/world/actors/pathfinder.cpp b/engines/ultima/ultima8/world/actors/pathfinder.cpp
index 98848f13c7..d2ba08a7cb 100644
--- a/engines/ultima/ultima8/world/actors/pathfinder.cpp
+++ b/engines/ultima/ultima8/world/actors/pathfinder.cpp
@@ -90,7 +90,7 @@ bool PathfindingState::checkItem(const Item *item, int xyRange, int zRange) cons
 	return (range <= xyRange);
 }
 
-bool PathfindingState::checkHit(const Actor *_actor, const Actor *target) const {
+bool PathfindingState::checkHit(const Actor *_actor, const Item *target) const {
 	assert(target);
 #if 0
 	pout << "Trying hit in _direction " << _actor->getDirToItemCentre(*target) << Std::endl;
@@ -201,8 +201,7 @@ bool Pathfinder::checkTarget(const PathNode *node) const {
 	// but otherwise it won't work properly yet -wjp
 	if (_targetItem) {
 		if (_hitMode) {
-			return node->state.checkHit(_actor,
-			                            dynamic_cast<Actor *>(_targetItem));
+			return node->state.checkHit(_actor, _targetItem);
 		} else {
 			return node->state.checkItem(_targetItem, 32, 8);
 		}
diff --git a/engines/ultima/ultima8/world/actors/pathfinder.h b/engines/ultima/ultima8/world/actors/pathfinder.h
index 9ea44caae9..c11a662fff 100644
--- a/engines/ultima/ultima8/world/actors/pathfinder.h
+++ b/engines/ultima/ultima8/world/actors/pathfinder.h
@@ -47,7 +47,7 @@ struct PathfindingState {
 	void load(const Actor *actor);
 	bool checkPoint(int32 x, int32 y, int32 z, int range) const;
 	bool checkItem(const Item *item, int xyRange, int zRange) const;
-	bool checkHit(const Actor *actor, const Actor *target) const;
+	bool checkHit(const Actor *actor, const Item *target) const;
 };
 
 struct PathfindingAction {
diff --git a/engines/ultima/ultima8/world/current_map.cpp b/engines/ultima/ultima8/world/current_map.cpp
index fce71a36d6..4516b34534 100644
--- a/engines/ultima/ultima8/world/current_map.cpp
+++ b/engines/ultima/ultima8/world/current_map.cpp
@@ -495,7 +495,7 @@ void CurrentMap::unsetChunkFast(int32 cx, int32 cy) {
 	}
 }
 
-void CurrentMap::clipMapChunks(int &minx, int &maxx, int &miny, int &maxy) const {
+inline void CurrentMap::clipMapChunks(int &minx, int &maxx, int &miny, int &maxy) {
 	minx = CLIP(minx, 0, MAP_NUM_CHUNKS - 1);
 	maxx = CLIP(maxx, 0, MAP_NUM_CHUNKS - 1);
 	miny = CLIP(miny, 0, MAP_NUM_CHUNKS - 1);
@@ -707,9 +707,9 @@ bool CurrentMap::isValidPosition(int32 x, int32 y, int32 z,
                                  uint32 shapeflags,
                                  ObjId item_, const Item **support_,
                                  ObjId *roof_, const Item **blocker_) const {
-	const uint32 flagmask = (ShapeInfo::SI_SOLID | ShapeInfo::SI_DAMAGING |
+	static const uint32 flagmask = (ShapeInfo::SI_SOLID | ShapeInfo::SI_DAMAGING |
 	                         ShapeInfo::SI_ROOF);
-	const uint32 blockflagmask = (ShapeInfo::SI_SOLID | ShapeInfo::SI_DAMAGING);
+	static const uint32 blockflagmask = (ShapeInfo::SI_SOLID | ShapeInfo::SI_DAMAGING);
 
 	bool valid = true;
 	const Item *support = nullptr;
diff --git a/engines/ultima/ultima8/world/current_map.h b/engines/ultima/ultima8/world/current_map.h
index ecefeca23e..1c1a11c64b 100644
--- a/engines/ultima/ultima8/world/current_map.h
+++ b/engines/ultima/ultima8/world/current_map.h
@@ -221,7 +221,7 @@ private:
 	void createEggHatcher();
 
 	//! clip the given map chunk numbers to iterate over them safely
-	void clipMapChunks(int &minx, int &maxx, int &miny, int &maxy) const;
+	static void clipMapChunks(int &minx, int &maxx, int &miny, int &maxy);
 
 	Map *_currentMap;
 


Commit: 0e685282df8e1503979dd48f0d32c6ee6d8a7f41
    https://github.com/scummvm/scummvm/commit/0e685282df8e1503979dd48f0d32c6ee6d8a7f41
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-01-17T12:43:56+09:00

Commit Message:
ULTIMA: Remove unused Std::queue

Changed paths:
    engines/ultima/shared/std/containers.h


diff --git a/engines/ultima/shared/std/containers.h b/engines/ultima/shared/std/containers.h
index d89e212029..bd93bd2200 100644
--- a/engines/ultima/shared/std/containers.h
+++ b/engines/ultima/shared/std/containers.h
@@ -311,10 +311,6 @@ template<class VAL>
 class stack : public Common::Stack<VAL> {
 };
 
-template<class T>
-class queue : public Common::Queue<T> {
-};
-
 /**
  * Queue ordered by a provided priority function
  * NOTE: Unlike in the C std library, we have to provde a comparitor that sorts


Commit: 2aec80b8c04268879b7cccf903683674d921c100
    https://github.com/scummvm/scummvm/commit/2aec80b8c04268879b7cccf903683674d921c100
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-01-17T21:10:42+09:00

Commit Message:
ULTIMA8: Make enterFastArea code more like original games

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


diff --git a/engines/ultima/ultima8/world/actors/actor.cpp b/engines/ultima/ultima8/world/actors/actor.cpp
index 44f1b2a45c..96d23a67f6 100644
--- a/engines/ultima/ultima8/world/actors/actor.cpp
+++ b/engines/ultima/ultima8/world/actors/actor.cpp
@@ -517,6 +517,21 @@ bool Actor::hasAnim(Animation::Sequence anim) {
 	return tracker.init(this, anim, dir_north);
 }
 
+void Actor::setToStartOfAnim(Animation::Sequence anim) {
+	AnimationTracker tracker;
+	if (tracker.init(this, anim, getDir())) {
+		const AnimFrame *f = tracker.getAnimFrame();
+		setFrame(f->_frame);
+		if ((GAME_IS_U8 && f->is_flipped())
+			|| (GAME_IS_CRUSADER && f->is_cruflipped())) {
+			setFlag(Item::FLG_FLIPPED);
+		} else {
+			clearFlag(Item::FLG_FLIPPED);
+		}
+		setLastAnim(anim);
+	}
+}
+
 Animation::Result Actor::tryAnim(Animation::Sequence anim, Direction dir,
                                  unsigned int steps, PathfindingState *state) {
 	if (dir < 0 || dir > 16) return Animation::FAILURE;
diff --git a/engines/ultima/ultima8/world/actors/actor.h b/engines/ultima/ultima8/world/actors/actor.h
index 868c20e65d..8da4011f2f 100644
--- a/engines/ultima/ultima8/world/actors/actor.h
+++ b/engines/ultima/ultima8/world/actors/actor.h
@@ -232,6 +232,10 @@ public:
 	//! check if this actor has a specific animation
 	bool hasAnim(Animation::Sequence anim);
 
+	//! Set the frame to the first frame of an anim (used in resetting NPCs etc)
+	//! Uses current direction and sets last anim no.
+	void setToStartOfAnim(Animation::Sequence anim);
+
 	//! check if the given animation can be done from the location in state,
 	//! without walking into things. If state is non-zero, and successful,
 	//! state will be updated to after the animation. If unsuccessful,
diff --git a/engines/ultima/ultima8/world/item.cpp b/engines/ultima/ultima8/world/item.cpp
index c26b479942..4ed01f5591 100644
--- a/engines/ultima/ultima8/world/item.cpp
+++ b/engines/ultima/ultima8/world/item.cpp
@@ -1768,6 +1768,8 @@ void Item::enterFastArea() {
 	if (_shape == 0x2c8 && GAME_IS_U8)
 		return;
 
+	const ShapeInfo *si = getShapeInfo();
+
 	// Call usecode
 	if (!(_flags & FLG_FASTAREA)) {
 		Actor *actor = dynamic_cast<Actor *>(this);
@@ -1778,16 +1780,26 @@ void Item::enterFastArea() {
 			// dead actor, don't call the usecode
 		} else {
 			if (actor && GAME_IS_CRUSADER) {
+				uint16 lastactivity = actor->getLastActivityNo();
 				actor->clearLastActivityNo();
 				actor->clearInCombat();
+				actor->setToStartOfAnim(Animation::stand);
 				actor->clearActorFlag(Actor::ACT_WEAPONREADY);
+				actor->setActivity(lastactivity);
 			}
+
+			//
+			// TODO: Check this. The original games only call usecode for actors or
+			// NOISY types.  Calling for all types like this shouldn't cause any issues
+			// as long as all the types which implement event F are NPC or NOISY.
+			// Should confirm if that is the case.
+			//
+			// if (actor || si->_flags & ShapeInfo::SI_NOISY)
 			callUsecodeEvent_enterFastArea();
 		}
 	}
 
 	if (!hasFlags(FLG_BROKEN) && GAME_IS_CRUSADER) {
-		const ShapeInfo *si = getShapeInfo();
 		if ((si->_flags & ShapeInfo::SI_CRU_TARGETABLE) || (si->_flags & ShapeInfo::SI_OCCL)) {
 			World::get_instance()->getCurrentMap()->addTargetItem(this);
 		}




More information about the Scummvm-git-logs mailing list