[Scummvm-git-logs] scummvm master -> 2c5de6e053eb04b8f8ae4b8998efd880be511502
OMGPizzaGuy
noreply at scummvm.org
Mon Jun 10 02:14:54 UTC 2024
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:
be44e64a39 ULTIMA8: Use Point3 for update fast area
2c5de6e053 ULTIMA8: Expand fast area during item create from usecode.
Commit: be44e64a3940ec5ba78c67c242db39751dd71b53
https://github.com/scummvm/scummvm/commit/be44e64a3940ec5ba78c67c242db39751dd71b53
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2024-06-09T19:20:40-05:00
Commit Message:
ULTIMA8: Use Point3 for update fast area
Changed paths:
engines/ultima/ultima8/world/camera_process.cpp
engines/ultima/ultima8/world/current_map.cpp
engines/ultima/ultima8/world/current_map.h
diff --git a/engines/ultima/ultima8/world/camera_process.cpp b/engines/ultima/ultima8/world/camera_process.cpp
index a11ea3f14c9..11fefb1a84b 100644
--- a/engines/ultima/ultima8/world/camera_process.cpp
+++ b/engines/ultima/ultima8/world/camera_process.cpp
@@ -194,7 +194,7 @@ void CameraProcess::itemMoved() {
_s.y = _e.y = pt.y;
_e.z = pt.z;
_s.z = _e.z += 20;
- World::get_instance()->getCurrentMap()->updateFastArea(_s.x, _s.y, _s.z, _e.x, _e.y, _e.z);
+ World::get_instance()->getCurrentMap()->updateFastArea(_s, _e);
}
}
@@ -226,7 +226,7 @@ Point3 CameraProcess::GetLerped(int32 factor, bool noupdate) {
}
}
// Update the fast area
- World::get_instance()->getCurrentMap()->updateFastArea(_s.x, _s.y, _s.z, _e.x, _e.y, _e.z);
+ World::get_instance()->getCurrentMap()->updateFastArea(_s, _e);
}
}
@@ -248,21 +248,24 @@ Point3 CameraProcess::GetLerped(int32 factor, bool noupdate) {
if (sfactor > _time) sfactor = _time;
if (efactor > _time) efactor = _time;
- int32 lsx = ((_s.x * (_time - sfactor) + _e.x * sfactor) / _time);
- int32 lsy = ((_s.y * (_time - sfactor) + _e.y * sfactor) / _time);
- int32 lsz = ((_s.z * (_time - sfactor) + _e.z * sfactor) / _time);
+ Point3 ls;
+ ls.x = ((_s.x * (_time - sfactor) + _e.x * sfactor) / _time);
+ ls.y = ((_s.y * (_time - sfactor) + _e.y * sfactor) / _time);
+ ls.z = ((_s.z * (_time - sfactor) + _e.z * sfactor) / _time);
- int32 lex = ((_s.x * (_time - efactor) + _e.x * efactor) / _time);
- int32 ley = ((_s.y * (_time - efactor) + _e.y * efactor) / _time);
- int32 lez = ((_s.z * (_time - efactor) + _e.z * efactor) / _time);
+ Point3 le;
+ le.x = ((_s.x * (_time - efactor) + _e.x * efactor) / _time);
+ le.y = ((_s.y * (_time - efactor) + _e.y * efactor) / _time);
+ le.z = ((_s.z * (_time - efactor) + _e.z * efactor) / _time);
// Update the fast area
- if (!noupdate) World::get_instance()->getCurrentMap()->updateFastArea(lsx, lsy, lsz, lex, ley, lez);
+ if (!noupdate)
+ World::get_instance()->getCurrentMap()->updateFastArea(ls, le);
// This way while possibly slower is more accurate
- pt.x = ((lsx * (256 - factor) + lex * factor) >> 8);
- pt.y = ((lsy * (256 - factor) + ley * factor) >> 8);
- pt.z = ((lsz * (256 - factor) + lez * factor) >> 8);
+ pt.x = ((ls.x * (256 - factor) + le.x * factor) >> 8);
+ pt.y = ((ls.y * (256 - factor) + le.y * factor) >> 8);
+ pt.z = ((ls.z * (256 - factor) + le.z * factor) >> 8);
}
if (_earthquake) {
diff --git a/engines/ultima/ultima8/world/current_map.cpp b/engines/ultima/ultima8/world/current_map.cpp
index 0ed495fcbe2..15c2fcdf1de 100644
--- a/engines/ultima/ultima8/world/current_map.cpp
+++ b/engines/ultima/ultima8/world/current_map.cpp
@@ -449,15 +449,15 @@ static inline void CalcFastAreaLimits(int32 &sx_limit,
xy_limit = (sy_limit + sx_limit) / 2;
}
-void CurrentMap::updateFastArea(int32 from_x, int32 from_y, int32 from_z, int32 to_x, int32 to_y, int32 to_z) {
- int x_min = MIN(from_x, to_x);
- int x_max = MAX(from_x, to_x);
+void CurrentMap::updateFastArea(const Point3 &from, const Point3 &to) {
+ int x_min = MIN(from.x, to.x);
+ int x_max = MAX(from.x, to.x);
- int y_min = MIN(from_y, to_y);
- int y_max = MAX(from_y, to_y);
+ int y_min = MIN(from.y, to.y);
+ int y_max = MAX(from.y, to.y);
- int z_min = MIN(from_z, to_z);
- int z_max = MAX(from_z, to_z);
+ int z_min = MIN(from.z, to.z);
+ int z_max = MAX(from.z, to.z);
// Work out Fine (screenspace) Limits of chunks with half chunk border
Rect dims;
diff --git a/engines/ultima/ultima8/world/current_map.h b/engines/ultima/ultima8/world/current_map.h
index e0f463264a7..f7bf18aa24b 100644
--- a/engines/ultima/ultima8/world/current_map.h
+++ b/engines/ultima/ultima8/world/current_map.h
@@ -81,7 +81,7 @@ public:
Item *findBestTargetItem(int32 x, int32 y, int32 z, Direction dir, DirectionMode dirmode);
//! Update the fast area for the cameras position
- void updateFastArea(int32 from_x, int32 from_y, int32 from_z, int32 to_x, int32 to_y, int32 to_z);
+ void updateFastArea(const Point3 &from, const Point3 &to);
//! search an area for items matching a loopscript
//! \param itemlist the list to return objids in
Commit: 2c5de6e053eb04b8f8ae4b8998efd880be511502
https://github.com/scummvm/scummvm/commit/2c5de6e053eb04b8f8ae4b8998efd880be511502
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2024-06-09T21:14:27-05:00
Commit Message:
ULTIMA8: Expand fast area during item create from usecode.
The previous attempt to fix would cause NPCs to blink in & out to existence when moving in Central Tenebrae.
Fixes invalid placement of barrel #14839
Changed paths:
engines/ultima/ultima8/world/current_map.cpp
engines/ultima/ultima8/world/current_map.h
engines/ultima/ultima8/world/item.cpp
diff --git a/engines/ultima/ultima8/world/current_map.cpp b/engines/ultima/ultima8/world/current_map.cpp
index 15c2fcdf1de..5b5549a8958 100644
--- a/engines/ultima/ultima8/world/current_map.cpp
+++ b/engines/ultima/ultima8/world/current_map.cpp
@@ -1215,6 +1215,14 @@ bool CurrentMap::sweepTest(const Point3 &start, const Point3 &end,
return hit && hit->size();
}
+void CurrentMap::setFastAtPoint(const Point3 &pt) {
+ int32 cx = pt.x / _mapChunkSize;
+ int32 cy = pt.y / _mapChunkSize;
+
+ if (!isChunkFast(cx, cy))
+ setChunkFast(cx, cy);
+}
+
void CurrentMap::setWholeMapFast() {
for (unsigned int i = 0; i < MAP_NUM_CHUNKS; ++i) {
for (unsigned int j = 0; j < MAP_NUM_CHUNKS; ++j) {
diff --git a/engines/ultima/ultima8/world/current_map.h b/engines/ultima/ultima8/world/current_map.h
index f7bf18aa24b..550c776fabd 100644
--- a/engines/ultima/ultima8/world/current_map.h
+++ b/engines/ultima/ultima8/world/current_map.h
@@ -181,6 +181,8 @@ public:
return (_fast[cy][cx / 32] & (1 << (cx & 31))) != 0;
}
+ void setFastAtPoint(const Point3 &pt);
+
// Set the entire map as being 'fast'
void setWholeMapFast();
diff --git a/engines/ultima/ultima8/world/item.cpp b/engines/ultima/ultima8/world/item.cpp
index 25490bb207b..a795ecb368c 100644
--- a/engines/ultima/ultima8/world/item.cpp
+++ b/engines/ultima/ultima8/world/item.cpp
@@ -3170,8 +3170,11 @@ uint32 Item::I_legalCreateAtPoint(const uint8 *args, unsigned int /*argsize*/) {
World_FromUsecodeXY(x, y);
- // check if item can exist
+ Point3 pt(x, y, z);
CurrentMap *cm = World::get_instance()->getCurrentMap();
+ cm->setFastAtPoint(pt);
+
+ // check if item can exist
PositionInfo info = cm->getPositionInfo(x, y, z, shape, 0);
if (!info.valid)
return 0;
@@ -3202,8 +3205,11 @@ uint32 Item::I_legalCreateAtCoords(const uint8 *args, unsigned int /*argsize*/)
World_FromUsecodeXY(x, y);
- // check if item can exist
+ Point3 pt(x, y, z);
CurrentMap *cm = World::get_instance()->getCurrentMap();
+ cm->setFastAtPoint(pt);
+
+ // check if item can exist
PositionInfo info = cm->getPositionInfo(x, y, z, shape, 0);
if (!info.valid)
return 0;
More information about the Scummvm-git-logs
mailing list