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

mduggan mgithub at guarana.org
Sun Jan 24 02:39:23 UTC 2021


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

Summary:
a7e38c926d ULTIMA8: Highlight avatar position in fast area vis
b017d422d8 ULTIMA8: Skip trying to render 0-width strings
e7e5f32d62 ULTIMA8: Extra assertion on rendering shapes
ece852a6b4 ULTIMA8: Don't do Crusader NPC reset stuff to avatar on enterFastArea
b5e252325a ULTIMA8: Only update Crusader camera for 'real' teleports
ad2129d1fb ULTIMA8: Set fast area bounds using map chunk size instead of magic numbers
7854b34c09 ULTIMA8: Clear screen before paint in DEBUG mode
c58b8841b9 ULTIMA8: Better keyboard support for Crusader keypads


Commit: a7e38c926d193487918f1d995dbb20f0ac965827
    https://github.com/scummvm/scummvm/commit/a7e38c926d193487918f1d995dbb20f0ac965827
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-01-24T11:39:00+09:00

Commit Message:
ULTIMA8: Highlight avatar position in fast area vis

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


diff --git a/engines/ultima/ultima8/gumps/fast_area_vis_gump.cpp b/engines/ultima/ultima8/gumps/fast_area_vis_gump.cpp
index 3459409463..75e9f20a8a 100644
--- a/engines/ultima/ultima8/gumps/fast_area_vis_gump.cpp
+++ b/engines/ultima/ultima8/gumps/fast_area_vis_gump.cpp
@@ -23,6 +23,8 @@
 #include "ultima/ultima8/gumps/fast_area_vis_gump.h"
 #include "ultima/ultima8/world/world.h"
 #include "ultima/ultima8/world/current_map.h"
+#include "ultima/ultima8/world/get_object.h"
+#include "ultima/ultima8/world/item.h"
 #include "ultima/ultima8/graphics/render_surface.h"
 
 namespace Ultima {
@@ -47,6 +49,18 @@ void FastAreaVisGump::PaintThis(RenderSurface *surf, int32 lerp_factor, bool sca
 	for (int yp = 0; yp < MAP_NUM_CHUNKS; yp++)
 		for (int xp = 0; xp < MAP_NUM_CHUNKS; xp++)
 			if (currentmap->isChunkFast(xp, yp)) surf->Fill32(0xFFFFFFFF, xp + 1, yp + 1, 1, 1);
+
+	// Put a red dot where the avatar is
+	Item *avatar = getItem(1);
+	if (avatar) {
+		int32 x, y, z;
+		avatar->getLocation(x, y, z);
+		int chunksize = currentmap->getChunkSize();
+		x /= chunksize;
+		y /= chunksize;
+		if (x >= 0 && x < MAP_NUM_CHUNKS && y >= 0 && y < MAP_NUM_CHUNKS)
+			surf->Fill32(0xFFFF1010, x + 1, y + 1, 1, 1);
+	}
 }
 
 uint16 FastAreaVisGump::TraceObjId(int32 mx, int32 my) {


Commit: b017d422d8d1ecd4100ca739d286128f80d93725
    https://github.com/scummvm/scummvm/commit/b017d422d8d1ecd4100ca739d286128f80d93725
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-01-24T11:39:00+09:00

Commit Message:
ULTIMA8: Skip trying to render 0-width strings

Changed paths:
    engines/ultima/ultima8/graphics/fonts/ttf_rendered_text.cpp


diff --git a/engines/ultima/ultima8/graphics/fonts/ttf_rendered_text.cpp b/engines/ultima/ultima8/graphics/fonts/ttf_rendered_text.cpp
index d5b8258a7f..7ba39448c3 100644
--- a/engines/ultima/ultima8/graphics/fonts/ttf_rendered_text.cpp
+++ b/engines/ultima/ultima8/graphics/fonts/ttf_rendered_text.cpp
@@ -40,6 +40,8 @@ TTFRenderedText::~TTFRenderedText() {
 }
 
 void TTFRenderedText::draw(RenderSurface *surface, int x, int y, bool destmasked) {
+	if (!_width)
+		return;
 	if (!destmasked)
 		surface->Blit(_texture, 0, 0, _width, _height, x, y - _font->getBaseline(),
 			_font->isAntialiased());


Commit: e7e5f32d62f29ad02ca8e69e97a95efd4059d617
    https://github.com/scummvm/scummvm/commit/e7e5f32d62f29ad02ca8e69e97a95efd4059d617
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-01-24T11:39:00+09:00

Commit Message:
ULTIMA8: Extra assertion on rendering shapes

Changed paths:
    engines/ultima/ultima8/graphics/soft_render_surface.inl


diff --git a/engines/ultima/ultima8/graphics/soft_render_surface.inl b/engines/ultima/ultima8/graphics/soft_render_surface.inl
index 1e345837bb..e9d920a2b9 100644
--- a/engines/ultima/ultima8/graphics/soft_render_surface.inl
+++ b/engines/ultima/ultima8/graphics/soft_render_surface.inl
@@ -191,7 +191,7 @@ const int32 neg = (FLIP_CONDITIONAL)?-1:0;
 	x -= XNEG(frame->_xoff);
 	y -= frame->_yoff;
 
-	assert(_pixels && srcpixels && srcmask);
+	assert(_pixels00 && _pixels && srcpixels && srcmask);
 
 	for (int i = 0; i < height_; i++)  {
 		int line = y + i;


Commit: ece852a6b4726d170dd48bc809373a71f6e72ba8
    https://github.com/scummvm/scummvm/commit/ece852a6b4726d170dd48bc809373a71f6e72ba8
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-01-24T11:39:01+09:00

Commit Message:
ULTIMA8: Don't do Crusader NPC reset stuff to avatar on enterFastArea

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 4ed01f5591..f9be477a74 100644
--- a/engines/ultima/ultima8/world/item.cpp
+++ b/engines/ultima/ultima8/world/item.cpp
@@ -1779,7 +1779,7 @@ void Item::enterFastArea() {
 		if (actor && actor->isDead() && !call_even_if_dead) {
 			// dead actor, don't call the usecode
 		} else {
-			if (actor && GAME_IS_CRUSADER) {
+			if (actor && _objId != 1 && GAME_IS_CRUSADER) {
 				uint16 lastactivity = actor->getLastActivityNo();
 				actor->clearLastActivityNo();
 				actor->clearInCombat();
@@ -1816,6 +1816,10 @@ void Item::enterFastArea() {
 
 // Called when an item is leaving the fast area
 void Item::leaveFastArea() {
+	if (_objId == 1) {
+		debug(6, "avatar leaving fast area");
+	}
+
 	// Call usecode
 	if ((!(_flags & FLG_FAST_ONLY) || getShapeInfo()->is_noisy()) &&
 	        (_flags & FLG_FASTAREA))
@@ -1827,10 +1831,6 @@ void Item::leaveFastArea() {
 		if (g) g->Close();
 	}
 
-	if (_objId == 1) {
-		debug(6, "avatar leaving fast area");
-	}
-
 	// Unset the flag
 	_flags &= ~FLG_FASTAREA;
 


Commit: b5e252325ac2a1993468cc079c60cc309a083dc3
    https://github.com/scummvm/scummvm/commit/b5e252325ac2a1993468cc079c60cc309a083dc3
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-01-24T11:39:01+09:00

Commit Message:
ULTIMA8: Only update Crusader camera for 'real' teleports

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


diff --git a/engines/ultima/ultima8/world/actors/main_actor.cpp b/engines/ultima/ultima8/world/actors/main_actor.cpp
index 84f2dd8e1d..47d5050ef2 100644
--- a/engines/ultima/ultima8/world/actors/main_actor.cpp
+++ b/engines/ultima/ultima8/world/actors/main_actor.cpp
@@ -329,7 +329,7 @@ void MainActor::teleport(int mapNum, int32 x, int32 y, int32 z) {
 
 	Actor::teleport(mapNum, x, y, z);
 
-	if (GAME_IS_CRUSADER) {
+	if (GAME_IS_CRUSADER && (x || y)) {
 		// Keep the camera on the avatar (the snap process will update on next move)
 		CameraProcess::SetCameraProcess(new CameraProcess(x, y, z));
 	}


Commit: ad2129d1fb25b48287335bfb58bc6c4b022ee760
    https://github.com/scummvm/scummvm/commit/ad2129d1fb25b48287335bfb58bc6c4b022ee760
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-01-24T11:39:01+09:00

Commit Message:
ULTIMA8: Set fast area bounds using map chunk size instead of magic numbers

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


diff --git a/engines/ultima/ultima8/world/current_map.cpp b/engines/ultima/ultima8/world/current_map.cpp
index 4516b34534..7b18d361fc 100644
--- a/engines/ultima/ultima8/world/current_map.cpp
+++ b/engines/ultima/ultima8/world/current_map.cpp
@@ -225,8 +225,8 @@ void CurrentMap::addItem(Item *item) {
 
 	if (ix < 0 || ix >= _mapChunkSize * MAP_NUM_CHUNKS ||
 	        iy < 0 || iy >= _mapChunkSize * MAP_NUM_CHUNKS) {
-		perr << "Skipping item " << item->getObjId() << ": out of range ("
-		     << ix << "," << iy << ")" << Std::endl;
+		/*perr << "Skipping item " << item->getObjId() << ": out of range ("
+		     << ix << "," << iy << ")" << Std::endl;*/
 		return;
 	}
 
@@ -251,8 +251,8 @@ void CurrentMap::addItemToEnd(Item *item) {
 
 	if (ix < 0 || ix >= _mapChunkSize * MAP_NUM_CHUNKS ||
 	        iy < 0 || iy >= _mapChunkSize * MAP_NUM_CHUNKS) {
-		perr << "Skipping item " << item->getObjId() << ": out of range ("
-		     << ix << "," << iy << ")" << Std::endl;
+		/*perr << "Skipping item " << item->getObjId() << ": out of range ("
+		     << ix << "," << iy << ")" << Std::endl;*/
 		return;
 	}
 
@@ -360,8 +360,8 @@ void CurrentMap::removeItemFromList(Item *item, int32 oldx, int32 oldy) {
 
 	if (oldx < 0 || oldx >= _mapChunkSize * MAP_NUM_CHUNKS ||
 	        oldy < 0 || oldy >= _mapChunkSize * MAP_NUM_CHUNKS) {
-		perr << "Skipping item " << item->getObjId() << ": out of range ("
-		     << oldx << "," << oldy << ")" << Std::endl;
+		/*perr << "Skipping item " << item->getObjId() << ": out of range ("
+		     << oldx << "," << oldy << ")" << Std::endl;*/
 		return;
 	}
 
@@ -375,7 +375,7 @@ void CurrentMap::removeItemFromList(Item *item, int32 oldx, int32 oldy) {
 // Check to see if the chunk is on the screen
 static inline bool ChunkOnScreen(int32 cx, int32 cy, int32 sleft, int32 stop, int32 sright, int32 sbot, int mapChunkSize) {
 	int32 scx = (cx * mapChunkSize - cy * mapChunkSize) / 4;
-	int32 scy = ((cx * mapChunkSize + cy * mapChunkSize) / 8);
+	int32 scy = (cx * mapChunkSize + cy * mapChunkSize) / 8;
 
 	// Screenspace bounding box left extent    (LNT x coord)
 	int32 cxleft = scx - mapChunkSize / 4;
@@ -383,9 +383,9 @@ static inline bool ChunkOnScreen(int32 cx, int32 cy, int32 sleft, int32 stop, in
 	int32 cxright = scx + mapChunkSize / 4;
 
 	// Screenspace bounding box top extent     (LFT y coord)
-	int32 cytop = scy - 256;
+	int32 cytop = scy - mapChunkSize / 2;
 	// Screenspace bounding box bottom extent  (RNB y coord)
-	int32 cybot = scy + 128;
+	int32 cybot = scy + mapChunkSize / 4;
 
 	const bool right_clear = cxright <= sleft;
 	const bool left_clear = cxleft >= sright;
@@ -400,12 +400,16 @@ static inline bool ChunkOnScreen(int32 cx, int32 cy, int32 sleft, int32 stop, in
 static inline void CalcFastAreaLimits(int32 &sx_limit,
                                       int32 &sy_limit,
                                       int32 &xy_limit,
-                                      const Rect &dims) {
-	// By default the fastArea is the screensize plus a border of no more
-	// than 256 pixels wide and 384 pixels high
-	// dims.w and dims.h need to be divided by 2 for crusader
-	sx_limit = dims.width() / 256 + 3;
-	sy_limit = dims.height() / 128 + 7;
+                                      const Rect &dims,
+									  int mapChunkSize) {
+	// By default the fastArea is the screensize rounded down to the nearest
+	// map chunk, plus 3 wide and 7 high.
+
+	// In the original games, the fast area is +/- 3,7 in U8
+	// map chunks and +/- 3,5 for Cruasder.  We have to do it a
+	// bit differently because the screen size is adjustable.
+	sx_limit = dims.width() / (mapChunkSize / 2) + 3;
+	sy_limit = dims.height() / (mapChunkSize / 4) + 7;
 	xy_limit = (sy_limit + sx_limit) / 2;
 }
 
@@ -444,7 +448,7 @@ void CurrentMap::updateFastArea(int32 from_x, int32 from_y, int32 from_z, int32
 	int32 sy_limit;
 	int32 xy_limit;
 
-	CalcFastAreaLimits(sx_limit, sy_limit, xy_limit, dims);
+	CalcFastAreaLimits(sx_limit, sy_limit, xy_limit, dims, _mapChunkSize);
 
 	x_min = x_min / _mapChunkSize - xy_limit;
 	x_max = x_max / _mapChunkSize + xy_limit;


Commit: 7854b34c09152d876f507585f6c8a2507681234d
    https://github.com/scummvm/scummvm/commit/7854b34c09152d876f507585f6c8a2507681234d
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-01-24T11:39:01+09:00

Commit Message:
ULTIMA8: Clear screen before paint in DEBUG mode

The screen should always be fully painted during the game, so when DEBUG is
defined fill it with a color first so we can more easily see if there are any
fast area or painting bugs.

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


diff --git a/engines/ultima/ultima8/ultima8.cpp b/engines/ultima/ultima8/ultima8.cpp
index 2e940bc87d..b6dd2582ba 100644
--- a/engines/ultima/ultima8/ultima8.cpp
+++ b/engines/ultima/ultima8/ultima8.cpp
@@ -576,6 +576,14 @@ void Ultima8Engine::paint() {
 	_screen->BeginPainting();
 
 	tpaint -= g_system->getMillis();
+
+#ifdef DEBUG
+	// Fill the screen with an annoying color so we can see fast area bugs
+	Rect r;
+	_screen->GetSurfaceDims(r);
+	_screen->Fill32(0xFF1010FF, 0, 0, r.width(), r.height());
+#endif
+
 	_desktopGump->Paint(_screen, _lerpFactor, false);
 	tpaint += g_system->getMillis();
 


Commit: c58b8841b9f3a1e3a03fdb4e84d9f4282fff27cd
    https://github.com/scummvm/scummvm/commit/c58b8841b9f3a1e3a03fdb4e84d9f4282fff27cd
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-01-24T11:39:01+09:00

Commit Message:
ULTIMA8: Better keyboard support for Crusader keypads

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


diff --git a/engines/ultima/ultima8/gumps/keypad_gump.cpp b/engines/ultima/ultima8/gumps/keypad_gump.cpp
index 87e7e5f82c..4204de7590 100644
--- a/engines/ultima/ultima8/gumps/keypad_gump.cpp
+++ b/engines/ultima/ultima8/gumps/keypad_gump.cpp
@@ -39,6 +39,12 @@ static const int TXT_CONTAINER_IDX = 0x100;
 static const int MAX_CODE_VAL = 9999999;
 static const int CHEAT_CODE_VAL = 74697689;
 
+static const uint16 SFXNO_BUTTON = 0x3b;
+static const uint16 SFXNO_CORRECT = 0x32;
+static const uint16 SFXNO_WRONG = 0x31;
+static const uint16 SFXNO_DEL = 0x3a;
+
+
 KeypadGump::KeypadGump(int targetValue, uint16 ucnotifypid): ModalGump(0, 0, 5, 5),
 		_value(0), _targetValue(targetValue), _ucNotifyPid(ucnotifypid) {
 	Mouse *mouse = Mouse::get_instance();
@@ -80,16 +86,32 @@ void KeypadGump::InitGump(Gump *newparent, bool take_focus) {
 
 void KeypadGump::PaintThis(RenderSurface *surf, int32 lerp_factor, bool scaled) {
 	Gump::PaintThis(surf, lerp_factor, scaled);
-	// TODO: paint text version of _value.
 }
 
 bool KeypadGump::OnKeyDown(int key, int mod) {
+	uint16 sfxno = 0;
+	bool shouldclose = false;
+
 	switch (key) {
-	case Common::KEYCODE_ESCAPE: {
-		_value = 0xff;
-		Close();
+	case Common::KEYCODE_ESCAPE:
+		_value = -1;
+		shouldclose = true;
+		break;
+	case Common::KEYCODE_BACKSPACE:
+		_value /= 10;
+		sfxno = SFXNO_DEL;
+		break;
+	case Common::KEYCODE_RETURN:
+		if (_value == _targetValue || _value == CHEAT_CODE_VAL) {
+			sfxno = SFXNO_CORRECT;
+			SetResult(_value);
+		} else {
+			// wrong.
+			sfxno = SFXNO_WRONG;
+			SetResult(0);
+		}
+		shouldclose = true;
 		break;
-	}
 	case Common::KEYCODE_0:
 	case Common::KEYCODE_1:
 	case Common::KEYCODE_2:
@@ -99,19 +121,22 @@ bool KeypadGump::OnKeyDown(int key, int mod) {
 	case Common::KEYCODE_6:
 	case Common::KEYCODE_7:
 	case Common::KEYCODE_8:
-	case Common::KEYCODE_9: {
+	case Common::KEYCODE_9:
 		onDigit(key - (int)Common::KEYCODE_0);
 		updateDigitDisplay();
-		AudioProcess *audio = AudioProcess::get_instance();
-		if (audio)
-			audio->playSFX(0x3b, 0x10, _objId, 1);
+		sfxno = SFXNO_BUTTON;
 		break;
-	}
-	break;
 	default:
 		break;
 	}
 
+	AudioProcess *audio = AudioProcess::get_instance();
+	if (audio && sfxno)
+		audio->playSFX(sfxno, 0x10, _objId, 1);
+
+	if (shouldclose)
+		Close();
+
 	return true;
 }
 
@@ -124,38 +149,39 @@ void KeypadGump::onDigit(int digit) {
 }
 
 void KeypadGump::ChildNotify(Gump *child, uint32 message) {
-	//ObjId cid = child->getObjId();
 	bool update = true;
+	bool shouldclose = false;
 	if (message == ButtonWidget::BUTTON_CLICK) {
-		uint16 sfxno = 0x3b;
+		uint16 sfxno = SFXNO_BUTTON;
 		int buttonNo = child->GetIndex();
 		if (buttonNo < 9) {
 			onDigit(buttonNo + 1);
 		} else if (buttonNo == 10) {
 			onDigit(0);
 		} else if (buttonNo == 9) {
+			// Backspace key
 			_value /= 10;
-			sfxno = 0x3a;
+			sfxno = SFXNO_DEL;
 		} else if (buttonNo == 11) {
 			update = false;
 			if (_value == _targetValue || _value == CHEAT_CODE_VAL) {
-				sfxno = 0x32;
+				sfxno = SFXNO_CORRECT;
 				SetResult(_value);
 			} else {
 				// wrong.
-				sfxno = 0x31;
+				sfxno = SFXNO_WRONG;
 				SetResult(0);
 			}
-			Close();
-			// Note: careful, this is now deleted.
+			shouldclose = true;
 		}
 		AudioProcess *audio = AudioProcess::get_instance();
 		if (audio && sfxno)
 			audio->playSFX(sfxno, 0x10, _objId, 1);
 	}
-	if (update) {
+	if (update)
 		updateDigitDisplay();
-	}
+	if (shouldclose)
+		Close();
 }
 
 void KeypadGump::updateDigitDisplay() {




More information about the Scummvm-git-logs mailing list