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

mduggan mgithub at guarana.org
Sat May 1 22:49:14 UTC 2021


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:
a4d1be0186 ULTIMA8: Fix loopscript search range in Crusader
e42fd1a910 ULTIMA8: Make Crusader status gumps work for other NPCs


Commit: a4d1be0186e143547608c9360a512f51eefe13c1
    https://github.com/scummvm/scummvm/commit/a4d1be0186e143547608c9360a512f51eefe13c1
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-05-02T07:49:05+09:00

Commit Message:
ULTIMA8: Fix loopscript search range in Crusader

With this bugfix, the first mission and first stay at the rebel base can now be
properly completed without a single use of the cheat mover!

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 a6f6b042d3..34dd51200f 100644
--- a/engines/ultima/ultima8/usecode/uc_machine.cpp
+++ b/engines/ultima/ultima8/usecode/uc_machine.cpp
@@ -1748,12 +1748,13 @@ void UCMachine::execProcess(UCProcess *p) {
 				if (searchtype == 3) recurse = true;
 
 				// ui16a = item, ui16b = range
-				Item *item = getItem(ui16a);
+				const Item *item = getItem(ui16a);
+				const uint16 range = GAME_IS_CRUSADER ? ui16b * 2 : ui16b;
 
 				if (item) {
 					world->getCurrentMap()->areaSearch(itemlist, script,
 					                                   scriptsize, item,
-					                                   ui16b, recurse);
+					                                   range, recurse);
 				} else {
 					// return error or return empty list?
 					perr << "Warning: invalid item " << ui16a << " passed to area search"


Commit: e42fd1a910de8519908aaa07a52263a1ff11c3e9
    https://github.com/scummvm/scummvm/commit/e42fd1a910de8519908aaa07a52263a1ff11c3e9
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-05-02T07:49:05+09:00

Commit Message:
ULTIMA8: Make Crusader status gumps work for other NPCs

Changed paths:
    engines/ultima/ultima8/gumps/cru_ammo_gump.cpp
    engines/ultima/ultima8/gumps/cru_energy_gump.cpp
    engines/ultima/ultima8/gumps/cru_health_gump.cpp
    engines/ultima/ultima8/gumps/cru_inventory_gump.cpp
    engines/ultima/ultima8/gumps/cru_inventory_gump.h
    engines/ultima/ultima8/gumps/cru_weapon_gump.cpp


diff --git a/engines/ultima/ultima8/gumps/cru_ammo_gump.cpp b/engines/ultima/ultima8/gumps/cru_ammo_gump.cpp
index efd4f87adb..006906b0c7 100644
--- a/engines/ultima/ultima8/gumps/cru_ammo_gump.cpp
+++ b/engines/ultima/ultima8/gumps/cru_ammo_gump.cpp
@@ -45,14 +45,9 @@ CruAmmoGump::~CruAmmoGump() {
 
 void CruAmmoGump::InitGump(Gump *newparent, bool take_focus) {
 	CruStatGump::InitGump(newparent, take_focus);
-
-	_bulletsText = new TextWidget();
-	_clipsText = new TextWidget();
 }
 
 void CruAmmoGump::PaintThis(RenderSurface *surf, int32 lerp_factor, bool scaled) {
-	CruStatGump::PaintThis(surf, lerp_factor, scaled);
-
 	MainActor *a = getMainActor();
 	if (!a) {
 		// avatar gone??
@@ -61,51 +56,64 @@ void CruAmmoGump::PaintThis(RenderSurface *surf, int32 lerp_factor, bool scaled)
 
 	uint16 active = a->getActiveWeapon();
 	uint16 ammoitem = 0;
-	uint16 bullets = 0;
+	int bullets = -1;
 	uint16 clips = 0;
-	if (!active) {
-		bullets = 0;
-	} else {
+	if (active) {
 		Item *item = getItem(active);
-		if (!item) {
-			bullets = 0;
-		} else {
+		if (item) {
 			WeaponInfo *weaponinfo = item->getShapeInfo()->_weaponInfo;
 			//uint16 frameno = 0;
-			if (weaponinfo) {
+			if (weaponinfo && weaponinfo->_ammoType) {
 				//frameno = weaponinfo->_ammoType;
 				ammoitem = weaponinfo->_ammoShape;
+				bullets = item->getQuality();
 			}
-
-			bullets = item->getQuality();
 		}
 	}
 
-	const Std::string bulletstr = Std::string::format("%d", bullets);
-	if (!bulletstr.equals(_bulletsText->getText())) {
-		RemoveChild(_bulletsText);
-		_bulletsText->Close();
-		_bulletsText = new TextWidget(22, _dims.height() / 2 - 3, bulletstr, true, 15);
-		_bulletsText->InitGump(this, false);
-	}
+	// Only paint if this weapon has bullets that get used up.
+	if (bullets >= 0 && a == getControlledActor()) {
+		const Std::string bulletstr = Std::string::format("%d", bullets);
+		if (!_bulletsText || !bulletstr.equals(_bulletsText->getText())) {
+			if (_bulletsText) {
+				RemoveChild(_bulletsText);
+				_bulletsText->Close();
+			}
+			_bulletsText = new TextWidget(22, _dims.height() / 2 - 3, bulletstr, true, 15);
+			_bulletsText->InitGump(this, false);
+		}
 
-	if (ammoitem) {
-		Item *item = a->getFirstItemWithShape(ammoitem, true);
-		if (item) {
-			clips = item->getQuality();
-		} else {
-			clips = 0;
+		if (ammoitem) {
+			Item *item = a->getFirstItemWithShape(ammoitem, true);
+			if (item) {
+				clips = item->getQuality();
+			} else {
+				clips = 0;
+			}
 		}
-	}
 
-	const Std::string clipstr = Std::string::format("%d", clips);
-	if (!clipstr.equals(_clipsText->getText())) {
-		RemoveChild(_clipsText);
-		_clipsText->Close();
-		_clipsText = new TextWidget(_dims.width() / 2 + 22, _dims.height() / 2 - 3, clipstr, true, 15);
-		_clipsText->InitGump(this, false);
+		const Std::string clipstr = Std::string::format("%d", clips);
+		if (!_clipsText || !clipstr.equals(_clipsText->getText())) {
+			if (_clipsText) {
+				RemoveChild(_clipsText);
+				_clipsText->Close();
+			}
+			_clipsText = new TextWidget(_dims.width() / 2 + 22, _dims.height() / 2 - 3, clipstr, true, 15);
+			_clipsText->InitGump(this, false);
+		}
+		CruStatGump::PaintThis(surf, lerp_factor, scaled);
+	} else {
+		if (_bulletsText) {
+			RemoveChild(_bulletsText);
+			_bulletsText->Close();
+			_bulletsText = nullptr;
+		}
+		if (_clipsText) {
+			RemoveChild(_clipsText);
+			_clipsText->Close();
+			_clipsText = nullptr;
+		}
 	}
-
 }
 
 void CruAmmoGump::saveData(Common::WriteStream *ws) {
diff --git a/engines/ultima/ultima8/gumps/cru_energy_gump.cpp b/engines/ultima/ultima8/gumps/cru_energy_gump.cpp
index a5ee5388e0..0cbfb6b7c1 100644
--- a/engines/ultima/ultima8/gumps/cru_energy_gump.cpp
+++ b/engines/ultima/ultima8/gumps/cru_energy_gump.cpp
@@ -53,9 +53,7 @@ void CruEnergyGump::InitGump(Gump *newparent, bool take_focus) {
 }
 
 void CruEnergyGump::PaintThis(RenderSurface *surf, int32 lerp_factor, bool scaled) {
-	CruStatGump::PaintThis(surf, lerp_factor, scaled);
-
-	const MainActor *a = getMainActor();
+	const Actor *a = getControlledActor();
 	if (!a) {
 		// avatar gone??
 		return;
@@ -63,7 +61,14 @@ void CruEnergyGump::PaintThis(RenderSurface *surf, int32 lerp_factor, bool scale
 
 	int16 energy = a->getMana();
 	int16 max_energy = a->getMaxMana();
-	int width = max_energy ? ((energy * 67) / max_energy) : 67;
+
+	// Don't display for NPCs without energy
+	if (!max_energy)
+		return;
+
+	CruStatGump::PaintThis(surf, lerp_factor, scaled);
+
+	int width = (energy * 67) / max_energy;
 	const Palette *gamepal = PaletteManager::get_instance()->getPalette(PaletteManager::Pal_Game);
 	if (!gamepal)
 		return;
diff --git a/engines/ultima/ultima8/gumps/cru_health_gump.cpp b/engines/ultima/ultima8/gumps/cru_health_gump.cpp
index 81007e6dcd..df6026e66f 100644
--- a/engines/ultima/ultima8/gumps/cru_health_gump.cpp
+++ b/engines/ultima/ultima8/gumps/cru_health_gump.cpp
@@ -55,14 +55,9 @@ void CruHealthGump::InitGump(Gump *newparent, bool take_focus) {
 void CruHealthGump::PaintThis(RenderSurface *surf, int32 lerp_factor, bool scaled) {
 	CruStatGump::PaintThis(surf, lerp_factor, scaled);
 
-	const MainActor *a = getMainActor();
-	if (!a) {
-		// avatar gone??
-		return;
-	}
-
-	int current_hp = a->getHP();
-	int max_hp = a->getMaxHP();
+	const Actor *a = getControlledActor();
+	int current_hp = a ? a->getHP() : 0;
+	int max_hp = a ? a->getMaxHP() : 1;
 	// max width = 67
 	int width = max_hp ? ((current_hp * 67) / max_hp) : 67;
 
diff --git a/engines/ultima/ultima8/gumps/cru_inventory_gump.cpp b/engines/ultima/ultima8/gumps/cru_inventory_gump.cpp
index c7abfc49ea..4c2deb34a5 100644
--- a/engines/ultima/ultima8/gumps/cru_inventory_gump.cpp
+++ b/engines/ultima/ultima8/gumps/cru_inventory_gump.cpp
@@ -59,10 +59,19 @@ void CruInventoryGump::InitGump(Gump *newparent, bool take_focus) {
 	_inventoryItemGump->InitGump(this, false);
 	// we'll set the shape for this gump later.
 
+	resetText();
+}
+
+void CruInventoryGump::resetText() {
+	if (_inventoryText) {
+		RemoveChild(_inventoryText);
+		_inventoryText->Close();
+	}
 	_inventoryText = new TextWidget();
 	_inventoryText->InitGump(this, false);
 }
 
+
 void CruInventoryGump::PaintThis(RenderSurface *surf, int32 lerp_factor, bool scaled) {
 	const MainActor *a = getMainActor();
 	if (!a) {
@@ -71,7 +80,8 @@ void CruInventoryGump::PaintThis(RenderSurface *surf, int32 lerp_factor, bool sc
 	}
 
 	uint16 activeitem = a->getActiveInvItem();
-	if (!activeitem) {
+	if (!activeitem || a != getControlledActor()) {
+		resetText();
 		_inventoryItemGump->SetShape(0, 0);
 	} else {
 		Item *item = getItem(activeitem);
@@ -108,17 +118,13 @@ void CruInventoryGump::PaintThis(RenderSurface *surf, int32 lerp_factor, bool sc
 				}
 			} else {
 				if (_inventoryText->getText().length() > 0) {
-					RemoveChild(_inventoryText);
-					_inventoryText->Close();
-					_inventoryText = new TextWidget();
-					_inventoryText->InitGump(this, false);
+					resetText();
 				}
 			}
 		}
+		// Now that the shape is configured, we can paint.
+		CruStatGump::PaintThis(surf, lerp_factor, scaled);
 	}
-
-	// Now that the shape is configured, we can paint.
-	CruStatGump::PaintThis(surf, lerp_factor, scaled);
 }
 
 void CruInventoryGump::saveData(Common::WriteStream *ws) {
diff --git a/engines/ultima/ultima8/gumps/cru_inventory_gump.h b/engines/ultima/ultima8/gumps/cru_inventory_gump.h
index f69a7941d9..f82e55cff8 100644
--- a/engines/ultima/ultima8/gumps/cru_inventory_gump.h
+++ b/engines/ultima/ultima8/gumps/cru_inventory_gump.h
@@ -54,6 +54,8 @@ public:
 private:
 	Gump *_inventoryItemGump;
 	TextWidget *_inventoryText;
+
+	void resetText();
 };
 
 } // End of namespace Ultima8
diff --git a/engines/ultima/ultima8/gumps/cru_weapon_gump.cpp b/engines/ultima/ultima8/gumps/cru_weapon_gump.cpp
index c9246d5994..26dc83a60a 100644
--- a/engines/ultima/ultima8/gumps/cru_weapon_gump.cpp
+++ b/engines/ultima/ultima8/gumps/cru_weapon_gump.cpp
@@ -75,6 +75,15 @@ void CruWeaponGump::PaintThis(RenderSurface *surf, int32 lerp_factor, bool scale
 	}
 
 	Gump *weaponGump = _children.front();
+
+	if (a != getControlledActor()) {
+		// Only paint when controlling avatar
+		weaponGump->HideGump();
+		return;
+	} else {
+		weaponGump->UnhideGump();
+	}
+
 	assert(weaponGump);
 	uint16 active = a->getActiveWeapon();
 	if (!active) {




More information about the Scummvm-git-logs mailing list