[Scummvm-git-logs] scummvm master -> 23ddfc7c208bbfe91d3ddf432c2ef376b90abed3

dreammaster paulfgilbert at gmail.com
Fri May 1 20:01:24 UTC 2020


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:
3fd696e81f ULTIMA4: New keybinding group for configuration keys
23ddfc7c20 ULTIMA4: Cleanup of dungeon room party/creature positions


Commit: 3fd696e81f20333471c6e0b9672152177d95884c
    https://github.com/scummvm/scummvm/commit/3fd696e81f20333471c6e0b9672152177d95884c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-05-01T12:59:42-07:00

Commit Message:
ULTIMA4: New keybinding group for configuration keys

Changed paths:
    engines/ultima/ultima4/controllers/combat_controller.cpp
    engines/ultima/ultima4/core/debugger.cpp
    engines/ultima/ultima4/core/debugger.h
    engines/ultima/ultima4/meta_engine.cpp
    engines/ultima/ultima4/meta_engine.h


diff --git a/engines/ultima/ultima4/controllers/combat_controller.cpp b/engines/ultima/ultima4/controllers/combat_controller.cpp
index 1681a792ef..9ab217f191 100644
--- a/engines/ultima/ultima4/controllers/combat_controller.cpp
+++ b/engines/ultima/ultima4/controllers/combat_controller.cpp
@@ -880,57 +880,6 @@ bool CombatController::keyPressed(int key) {
 		break;
 	}
 
-	// Change the speed of battle
-	case '+':
-	case '-':
-	case Common::KEYCODE_KP_ENTER: {
-		int old_speed = settings._battleSpeed;
-		if (key == '+' && ++settings._battleSpeed > MAX_BATTLE_SPEED)
-			settings._battleSpeed = MAX_BATTLE_SPEED;
-		else if (key == '-' && --settings._battleSpeed == 0)
-			settings._battleSpeed = 1;
-		else if (key == Common::KEYCODE_KP_ENTER)
-			settings._battleSpeed = DEFAULT_BATTLE_SPEED;
-
-		if (old_speed != settings._battleSpeed) {
-			if (settings._battleSpeed == DEFAULT_BATTLE_SPEED)
-				g_screen->screenMessage("Battle Speed:\nNormal\n");
-			else if (key == '+')
-				g_screen->screenMessage("Battle Speed:\nUp (%d)\n", settings._battleSpeed);
-			else g_screen->screenMessage("Battle Speed:\nDown (%d)\n", settings._battleSpeed);
-		} else if (settings._battleSpeed == DEFAULT_BATTLE_SPEED)
-			g_screen->screenMessage("Battle Speed:\nNormal\n");
-	}
-
-	valid = false;
-	break;
-
-	/* handle music volume adjustments */
-	case ',':
-		// decrease the volume if possible
-		g_screen->screenMessage("Music: %d%s\n", g_music->decreaseMusicVolume(), "%");
-		endTurn = false;
-		break;
-	case '.':
-		// increase the volume if possible
-		g_screen->screenMessage("Music: %d%s\n", g_music->increaseMusicVolume(), "%");
-		endTurn = false;
-		break;
-
-	/* handle sound volume adjustments */
-	case '<':
-		// decrease the volume if possible
-		g_screen->screenMessage("Sound: %d%s\n", g_music->decreaseSoundVolume(), "%");
-		soundPlay(SOUND_FLEE);
-		endTurn = false;
-		break;
-	case '>':
-		// increase the volume if possible
-		g_screen->screenMessage("Sound: %d%s\n", g_music->increaseSoundVolume(), "%");
-		soundPlay(SOUND_FLEE);
-		endTurn = false;
-		break;
-
 	case 'a':
 		attack();
 		break;
diff --git a/engines/ultima/ultima4/core/debugger.cpp b/engines/ultima/ultima4/core/debugger.cpp
index 0a9d31d85f..8a227fdd11 100644
--- a/engines/ultima/ultima4/core/debugger.cpp
+++ b/engines/ultima/ultima4/core/debugger.cpp
@@ -69,7 +69,6 @@ Debugger::Debugger() : Shared::Debugger() {
 	registerCmd("jimmy", WRAP_METHOD(Debugger, cmdJimmy));
 	registerCmd("locate", WRAP_METHOD(Debugger, cmdLocate));
 	registerCmd("mix", WRAP_METHOD(Debugger, cmdMixReagents));
-	registerCmd("musicToggle", WRAP_METHOD(Debugger, cmdMusicToggle));
 	registerCmd("open", WRAP_METHOD(Debugger, cmdOpenDoor));
 	registerCmd("order", WRAP_METHOD(Debugger, cmdNewOrder));
 	registerCmd("party", WRAP_METHOD(Debugger, cmdParty));
@@ -84,6 +83,10 @@ Debugger::Debugger() : Shared::Debugger() {
 	registerCmd("wear", WRAP_METHOD(Debugger, cmdWearArmor));
 	registerCmd("yell", WRAP_METHOD(Debugger, cmdYell));
 
+	registerCmd("speed", WRAP_METHOD(Debugger, cmdSpeed));
+	registerCmd("combat_speed", WRAP_METHOD(Debugger, cmdCombatSpeed));
+	registerCmd("musicToggle", WRAP_METHOD(Debugger, cmdMusicToggle));
+
 	registerCmd("3d", WRAP_METHOD(Debugger, cmd3d));
 	registerCmd("abyss", WRAP_METHOD(Debugger, cmdAbyss));
 	registerCmd("collisions", WRAP_METHOD(Debugger, cmdCollisions));
@@ -1020,7 +1023,7 @@ bool Debugger::cmdSearch(int argc, const char **argv) {
 
 bool Debugger::cmdSpeed(int argc, const char **argv) {
 	Common::String action = argv[1];
-	int old_cycles = settings._gameCyclesPerSecond;
+	int oldCycles = settings._gameCyclesPerSecond;
 
 	if (action == "up") {
 		if (++settings._gameCyclesPerSecond > MAX_CYCLES_PER_SECOND)
@@ -1032,7 +1035,7 @@ bool Debugger::cmdSpeed(int argc, const char **argv) {
 		settings._gameCyclesPerSecond = DEFAULT_CYCLES_PER_SECOND;
 	}
 
-	if (old_cycles != settings._gameCyclesPerSecond) {
+	if (oldCycles != settings._gameCyclesPerSecond) {
 		settings._eventTimerGranularity = (1000 / settings._gameCyclesPerSecond);
 		eventHandler->getTimer()->reset(settings._eventTimerGranularity);
 
@@ -1050,6 +1053,33 @@ bool Debugger::cmdSpeed(int argc, const char **argv) {
 	return isDebuggerActive();
 }
 
+bool Debugger::cmdCombatSpeed(int argc, const char **argv) {
+	Common::String action = argv[1];
+	int oldSpeed = settings._battleSpeed;
+
+	if (action == "up" && ++settings._battleSpeed > MAX_BATTLE_SPEED)
+		settings._battleSpeed = MAX_BATTLE_SPEED;
+	else if (action == "down" && --settings._battleSpeed == 0)
+		settings._battleSpeed = 1;
+	else if (action == "normal")
+		settings._battleSpeed = DEFAULT_BATTLE_SPEED;
+
+	if (oldSpeed != settings._battleSpeed) {
+		if (settings._battleSpeed == DEFAULT_BATTLE_SPEED) {
+			print("Battle Speed:\nNormal");
+		} else if (action == "up") {
+			print("Battle Speed:\nUp (%d)", settings._battleSpeed);
+		} else {
+			print("Battle Speed:\nDown (%d)", settings._battleSpeed);
+		}
+	} else if (settings._battleSpeed == DEFAULT_BATTLE_SPEED) {
+		print("Battle Speed:\nNormal");
+	}
+
+	dontEndTurn();
+	return isDebuggerActive();
+}
+
 bool Debugger::cmdStats(int argc, const char **argv) {
 	int player = -1;
 	if (argc == 2)
diff --git a/engines/ultima/ultima4/core/debugger.h b/engines/ultima/ultima4/core/debugger.h
index e4871c5307..66dc2cb0fd 100644
--- a/engines/ultima/ultima4/core/debugger.h
+++ b/engines/ultima/ultima4/core/debugger.h
@@ -210,6 +210,12 @@ private:
 	 */
 	bool cmdSpeed(int argc, const char **argv);
 
+	/**
+	 * Combat speed up, down, or normal
+	 */
+	bool cmdCombatSpeed(int argc, const char **argv);
+
+
 	/**
 	 * Show character stats
 	 */
diff --git a/engines/ultima/ultima4/meta_engine.cpp b/engines/ultima/ultima4/meta_engine.cpp
index b9d0c8651c..20bdb80bd8 100644
--- a/engines/ultima/ultima4/meta_engine.cpp
+++ b/engines/ultima/ultima4/meta_engine.cpp
@@ -66,12 +66,8 @@ static const KeybindingRecord NORMAL_KEYS[] = {
 	{ KEYBIND_QUIT_SAVE, "QUIT-SAVE", "Quit and Save", "quitAndSave", "q", nullptr },
 	{ KEYBIND_READY_WEAPON, "READY-WEAPON", "Ready Weapon", "ready", "r", nullptr },
 	{ KEYBIND_SEARCH, "SEARCH", "Search", "search", "s", nullptr },
-	{ KEYBIND_SPEED_UP, "SPEED-UP", "Speed Up", "speed up", "PLUS", nullptr },
-	{ KEYBIND_SPEED_DOWN, "SPEED-DOWN", "Speed Down", "speed down", "MINUS", nullptr },
-	{ KEYBIND_SPEED_NORMAL, "SPEED-NORMAL", "Speed Normal", "speed normal", "KP_ENTER", nullptr },
 	{ KEYBIND_STATS, "STATS", "Stats", "stats", "z", nullptr },
 	{ KEYBIND_TALK, "TALK", "Talk", "talk", "t", nullptr },
-	{ KEYBIND_TOGGLE_MUSIC, "TOGGLE-MUSIC", "Toggle Music", "musicToggle", "v", nullptr },
 	{ KEYBIND_USE, "USE", "Use", "use", "u", nullptr },
 	{ KEYBIND_WEAR, "WEAR", "Wear Armor", "wear", "w", nullptr },
 	{ KEYBIND_YELL, "YELL", "Yell", "yell", "y", nullptr },
@@ -79,6 +75,17 @@ static const KeybindingRecord NORMAL_KEYS[] = {
 	{ KEYBIND_NONE, nullptr, nullptr, nullptr, nullptr, nullptr }
 };
 
+static const KeybindingRecord CONFIG_KEYS[] = {
+	{ KEYBIND_SPEED_UP, "SPEED-UP", "Speed Up", "speed up", "KP_PLUS", nullptr },
+	{ KEYBIND_SPEED_DOWN, "SPEED-DOWN", "Speed Down", "speed down", "KP_MINUS", nullptr },
+	{ KEYBIND_SPEED_NORMAL, "SPEED-NORMAL", "Speed Normal", "speed normal", "KP_ENTER", nullptr },
+	{ KEYBIND_COMBATSPEED_UP, "COMBATSPEED-UP", "Combat Speed Up", "combat_speed up", "A+KP_PLUS", nullptr },
+	{ KEYBIND_COMBATSPEED_DOWN, "COMBATSPEED-DOWN", "Combat Speed Down", "combat_speed down", "A+KP_MINUS", nullptr },
+	{ KEYBIND_COMBATSPEED_NORMAL, "COMBATSPEED-NORMAL", "Combat Speed Normal", "combat_speed normal", "A+KP_ENTER", nullptr },
+
+	{ KEYBIND_NONE, nullptr, nullptr, nullptr, nullptr, nullptr }
+};
+
 static const KeybindingRecord PARTY_KEYS[] = {
 	{ KEYBIND_PARTY0, "PARTY0", "Party - None", "party 0", "0", nullptr },
 	{ KEYBIND_PARTY1, "PARTY1", "Party - Character #1", "party 1", "1", nullptr },
@@ -147,6 +154,7 @@ struct KeysRecord {
 
 static const KeysRecord NORMAL_RECORDS[] = {
 	{ "ultima4", "Ultima IV", NORMAL_KEYS },
+	{ "ultima4_config", "Ultima IV - Configuration", CONFIG_KEYS },
 	{ "ultima4_party", "Ultima IV - Party", PARTY_KEYS },
 	{ "ultima4_cheats", "Ultima IV - Cheats", CHEAT_KEYS },
 	{ nullptr, nullptr, nullptr }
@@ -164,6 +172,7 @@ static const KeysRecord DIRECTION_RECORDS[] = {
 
 static const KeysRecord COMBAT_RECORDS[] = {
 	{ "ultima4", "Ultima IV", COMBAT_KEYS },
+	{ "ultima4_config", "Ultima IV - Configuration", CONFIG_KEYS },
 	{ "ultima4_party", "Ultima IV - Party", PARTY_KEYS },
 	{ "ultima4_cheats", "Ultima IV - Cheats", CHEAT_KEYS },
 	{ nullptr, nullptr, nullptr }
diff --git a/engines/ultima/ultima4/meta_engine.h b/engines/ultima/ultima4/meta_engine.h
index 0dacc157ae..4afddc8883 100644
--- a/engines/ultima/ultima4/meta_engine.h
+++ b/engines/ultima/ultima4/meta_engine.h
@@ -35,10 +35,13 @@ enum KeybindingAction {
 	KEYBIND_GET, KEYBIND_HOLE_UP, KEYBIND_IGNITE, KEYBIND_JIMMY,
 	KEYBIND_LOCATE, KEYBIND_MIX, KEYBIND_NEW_ORDER,
 	KEYBIND_OPEN_DOOR, KEYBIND_PASS, KEYBIND_PEER,
-	KEYBIND_QUIT_SAVE, KEYBIND_SPEED_UP, KEYBIND_SPEED_DOWN,
-	KEYBIND_SPEED_NORMAL, KEYBIND_READY_WEAPON, KEYBIND_SEARCH,
-	KEYBIND_STATS, KEYBIND_TALK, KEYBIND_TOGGLE_MUSIC, KEYBIND_USE,
-	KEYBIND_WEAR, KEYBIND_YELL, KEYBIND_INTERACT, KEYBIND_ESCAPE,
+	KEYBIND_QUIT_SAVE, KEYBIND_READY_WEAPON, KEYBIND_SEARCH,
+	KEYBIND_STATS, KEYBIND_TALK, KEYBIND_USE, KEYBIND_WEAR,
+	KEYBIND_YELL, KEYBIND_INTERACT, KEYBIND_ESCAPE,
+
+	KEYBIND_SPEED_UP, KEYBIND_SPEED_DOWN, KEYBIND_SPEED_NORMAL,
+	KEYBIND_COMBATSPEED_UP, KEYBIND_COMBATSPEED_DOWN,
+	KEYBIND_COMBATSPEED_NORMAL,
 
 	KEYBIND_PARTY0, KEYBIND_PARTY1, KEYBIND_PARTY2, KEYBIND_PARTY3,
 	KEYBIND_PARTY4, KEYBIND_PARTY5, KEYBIND_PARTY6, KEYBIND_PARTY7,


Commit: 23ddfc7c208bbfe91d3ddf432c2ef376b90abed3
    https://github.com/scummvm/scummvm/commit/23ddfc7c208bbfe91d3ddf432c2ef376b90abed3
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-05-01T12:59:42-07:00

Commit Message:
ULTIMA4: Cleanup of dungeon room party/creature positions

Changed paths:
    engines/ultima/ultima4/controllers/combat_controller.cpp
    engines/ultima/ultima4/map/dungeon.cpp
    engines/ultima/ultima4/map/dungeon.h
    engines/ultima/ultima4/map/maploader.cpp


diff --git a/engines/ultima/ultima4/controllers/combat_controller.cpp b/engines/ultima/ultima4/controllers/combat_controller.cpp
index 9ab217f191..23c9fbf71b 100644
--- a/engines/ultima/ultima4/controllers/combat_controller.cpp
+++ b/engines/ultima/ultima4/controllers/combat_controller.cpp
@@ -204,7 +204,7 @@ void CombatController::init(class Creature *m) {
 }
 
 void CombatController::initDungeonRoom(int room, Direction from) {
-	int offset, i;
+	int i;
 	init(nullptr);
 
 	ASSERT(g_context->_location->_prev->_context & CTX_DUNGEON, "Error: called initDungeonRoom from non-dungeon context");
@@ -212,8 +212,7 @@ void CombatController::initDungeonRoom(int room, Direction from) {
 		Dungeon *dng = dynamic_cast<Dungeon *>(g_context->_location->_prev->_map);
 		assert(dng);
 
-		byte *party_x = &dng->_rooms[room]._partyNorthStartX[0],
-			*party_y = &dng->_rooms[room]._partyNorthStartY[0];
+		DngRoom &dngRoom = dng->_rooms[room];
 
 		/* load the dungeon room properties */
 		_winOrLose = false;
@@ -236,23 +235,16 @@ void CombatController::initDungeonRoom(int room, Direction from) {
 				_placeCreaturesOnMap = true;
 				_creatureTable[i] = creatureMgr->getByTile(dng->_rooms[room]._creatureTiles[i]);
 			}
-			_map->creature_start[i].x = dng->_rooms[room]._creatureStartX[i];
-			_map->creature_start[i].y = dng->_rooms[room]._creatureStartY[i];
+			_map->creature_start[i].x = dng->_rooms[room]._creatureStart[i].x;
+			_map->creature_start[i].y = dng->_rooms[room]._creatureStart[i].y;
 		}
 
-		/* figure out party start coordinates */
+		// Validate direction
 		switch (from) {
 		case DIR_WEST:
-			offset = 3;
-			break;
 		case DIR_NORTH:
-			offset = 0;
-			break;
 		case DIR_EAST:
-			offset = 1;
-			break;
 		case DIR_SOUTH:
-			offset = 2;
 			break;
 		case DIR_ADVANCE:
 		case DIR_RETREAT:
@@ -260,10 +252,9 @@ void CombatController::initDungeonRoom(int room, Direction from) {
 			error("Invalid 'from' direction passed to initDungeonRoom()");
 		}
 
-		// TODO: Check for possible memory overrun below
 		for (i = 0; i < AREA_PLAYERS; i++) {
-			_map->player_start[i].x = *(party_x + (offset * AREA_PLAYERS * 2) + i);
-			_map->player_start[i].y = *(party_y + (offset * AREA_PLAYERS * 2) + i);
+			_map->player_start[i].x = dngRoom._partyStart[i][from].x;
+			_map->player_start[i].y = dngRoom._partyStart[i][from].y;
 		}
 	}
 }
diff --git a/engines/ultima/ultima4/map/dungeon.cpp b/engines/ultima/ultima4/map/dungeon.cpp
index c3bc45b839..aee0c333fe 100644
--- a/engines/ultima/ultima4/map/dungeon.cpp
+++ b/engines/ultima/ultima4/map/dungeon.cpp
@@ -27,6 +27,7 @@
 #include "ultima/ultima4/game/item.h"
 #include "ultima/ultima4/map/location.h"
 #include "ultima/ultima4/map/mapmgr.h"
+#include "ultima/ultima4/map/tilemap.h"
 #include "ultima/ultima4/game/player.h"
 #include "ultima/ultima4/gfx/screen.h"
 #include "ultima/ultima4/game/stats.h"
@@ -44,6 +45,96 @@ bool isDungeon(Map *punknown) {
 		return false;
 }
 
+/*-------------------------------------------------------------------*/
+
+void DngRoom::load(Common::SeekableReadStream &s) {
+	int i;
+
+	s.read(_creatureTiles, 16);
+	for (i = 0; i < 16; ++i)
+		_creatureStart[i].x = s.readByte();
+	for (i = 0; i < 16; ++i)
+		_creatureStart[i].y = s.readByte();
+
+	#define READ_DIR(DIR, XY) \
+		for (i = 0; i < 8; ++i) \
+			_partyStart[i][DIR].XY = s.readByte()
+
+	READ_DIR(DIR_NORTH, x);
+	READ_DIR(DIR_NORTH, y);
+	READ_DIR(DIR_EAST, x);
+	READ_DIR(DIR_EAST, y);
+	READ_DIR(DIR_SOUTH, x);
+	READ_DIR(DIR_SOUTH, y);
+	READ_DIR(DIR_WEST, x);
+	READ_DIR(DIR_WEST, y);
+
+	#undef READ_DIR
+}
+
+void DngRoom::hythlothFix7() {
+	int i;
+
+	// Update party start positions when entering from the east
+	const byte X1[8] = { 0x8, 0x8, 0x9, 0x9, 0x9, 0xA, 0xA, 0xA },
+		Y1[8] = { 0x3, 0x2, 0x3, 0x2, 0x1, 0x3, 0x2, 0x1 };
+
+	for (i = 0; i < 8; ++i)
+		_partyStart[i]._eastStart.x = X1[i];
+	for (i = 0; i < 8; ++i)
+		_partyStart[i]._eastStart.y = Y1[i];
+
+	// Update party start positions when entering from the south
+	const byte X2[8] = { 0x3, 0x2, 0x3, 0x2, 0x1, 0x3, 0x2, 0x1 },
+		Y2[8] = { 0x8, 0x8, 0x9, 0x9, 0x9, 0xA, 0xA, 0xA };
+
+	for (i = 0; i < 8; ++i)
+		_partyStart[i]._southStart.x = X2[i];
+	for (i = 0; i < 8; ++i)
+		_partyStart[i]._southStart.y = Y2[i];
+}
+
+void DngRoom::hythlothFix9() {
+	int i;
+
+	// Update the starting position of monsters 7, 8, and 9
+	const byte X1[3] = { 0x4, 0x6, 0x5 },
+		Y1[3] = { 0x5, 0x5, 0x6 };
+
+	for (i = 0; i < 3; ++i)
+		_creatureStart[i + 7].x = X1[i];
+	for (i = 0; i < 3; ++i)
+		_creatureStart[i + 7].y = Y1[i];
+
+	// Update party start positions when entering from the west
+	const byte X2[8] = { 0x2, 0x2, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0 },
+		Y2[8] = { 0x9, 0x8, 0x9, 0x8, 0x7, 0x9, 0x8, 0x7 };
+
+	for (i = 0; i < 8; ++i)
+		_partyStart[i]._westStart.x = X2[i];
+	for (i = 0; i < 8; ++i)
+		_partyStart[i]._westStart.y = Y2[i];
+
+	// Update the map data, moving the chest to the center of the room,
+	// and removing the walls at the lower-left corner thereby creating
+	// a connection to room 8
+	const Coords tile[6] = {
+		Coords(5, 5, 0x3C),  // Chest
+		Coords(0, 7, 0x16),  // Floor
+		Coords(1, 7, 0x16),
+		Coords(0, 8, 0x16),
+		Coords(1, 8, 0x16),
+		Coords(0, 9, 0x16)
+	};
+
+	for (i = 0; i < 6; ++i) {
+		const int index = (tile[i].y * CON_WIDTH) + tile[i].x;
+		_mapData[index] = g_tileMaps->get("base")->translate(tile[i].z);
+	}
+}
+
+/*-------------------------------------------------------------------*/
+
 Dungeon::Dungeon() : _nRooms(0), _rooms(nullptr),
 		_roomMaps(nullptr), _currentRoom(0) {
 	Common::fill(&_partyStartX[0], &_partyStartX[8], 0);
diff --git a/engines/ultima/ultima4/map/dungeon.h b/engines/ultima/ultima4/map/dungeon.h
index 942ae62100..fb3863e9a6 100644
--- a/engines/ultima/ultima4/map/dungeon.h
+++ b/engines/ultima/ultima4/map/dungeon.h
@@ -44,22 +44,56 @@ struct Trigger {
 	byte _changeX1, _changeY1, changeX2, changeY2;
 };
 
+struct PartyEntry {
+private:
+	Common::Point *_array[5];
+public:
+	Common::Point _northStart;
+	Common::Point _eastStart;
+	Common::Point _southStart;
+	Common::Point _westStart;
+
+	PartyEntry() {
+		_array[DIR_NONE] = nullptr;
+		_array[DIR_NORTH] = &_northStart;
+		_array[DIR_EAST] = &_eastStart;
+		_array[DIR_SOUTH] = &_southStart;
+		_array[DIR_WEST] = &_westStart;
+	}
+
+	Common::Point &operator[](int dir) {
+		return *_array[dir];
+	}
+};
+
 struct DngRoom {
 	Trigger _triggers[DNGROOM_NTRIGGERS];
 	byte _creatureTiles[16];
-	byte _creatureStartX[16];
-	byte _creatureStartY[16];
-	byte _partyNorthStartX[8];
-	byte _partyNorthStartY[8];
-	byte _partyEastStartX[8];
-	byte _partyEastStartY[8];
-	byte _partySouthStartX[8];
-	byte _partySouthStartY[8];
-	byte _partyWestStartX[8];
-	byte _partyWestStartY[8];
+	Common::Point _creatureStart[16];
+	PartyEntry _partyStart[8];
+
 	MapData  _mapData;  // This is OK to change to MapData since sizeof(DngRoom) or
 	// anything like it is not being used.
 	byte _buffer[7];
+
+	/**
+	 * Load room data
+	 */
+	void load(Common::SeekableReadStream &s);
+
+	/**
+	 * A couple rooms in hythloth have nullptr player start positions,
+	 * which causes the entire party to appear in the upper-left
+	 * tile when entering the dungeon room.
+	 *
+	 * Also, one dungeon room is apparently supposed to be connected
+	 * to another, although the the connection does not exist in the
+	 * DOS U4 dungeon data file.  This was fixed by removing a few
+	 * wall tiles, and relocating a chest and the few monsters around
+	 * it to the center of the room.
+	 */
+	void hythlothFix7();
+	void hythlothFix9();
 };
 
 /**
diff --git a/engines/ultima/ultima4/map/maploader.cpp b/engines/ultima/ultima4/map/maploader.cpp
index b9fb1a5b68..bf0ee92c7a 100644
--- a/engines/ultima/ultima4/map/maploader.cpp
+++ b/engines/ultima/ultima4/map/maploader.cpp
@@ -55,7 +55,7 @@ MapLoaders::MapLoaders() {
 	(*this)[Map::SHRINE] = new ConMapLoader();
 	(*this)[Map::DUNGEON] = new DngMapLoader();
 	(*this)[Map::WORLD] = new WorldMapLoader();
-	(*this)[Map::COMBAT] = new WorldMapLoader();
+	(*this)[Map::COMBAT] = new ConMapLoader();
 }
 
 MapLoaders::~MapLoaders() {
@@ -336,17 +336,7 @@ bool DngMapLoader::load(Map *map) {
 			dungeon->_rooms[i]._triggers[j].changeY2 = tmp & 0x0F;
 		}
 
-		u4fread(dungeon->_rooms[i]._creatureTiles, sizeof(dungeon->_rooms[i]._creatureTiles), 1, dng);
-		u4fread(dungeon->_rooms[i]._creatureStartX, sizeof(dungeon->_rooms[i]._creatureStartX), 1, dng);
-		u4fread(dungeon->_rooms[i]._creatureStartY, sizeof(dungeon->_rooms[i]._creatureStartY), 1, dng);
-		u4fread(dungeon->_rooms[i]._partyNorthStartX, sizeof(dungeon->_rooms[i]._partyNorthStartX), 1, dng);
-		u4fread(dungeon->_rooms[i]._partyNorthStartY, sizeof(dungeon->_rooms[i]._partyNorthStartY), 1, dng);
-		u4fread(dungeon->_rooms[i]._partyEastStartX, sizeof(dungeon->_rooms[i]._partyEastStartX), 1, dng);
-		u4fread(dungeon->_rooms[i]._partyEastStartY, sizeof(dungeon->_rooms[i]._partyEastStartY), 1, dng);
-		u4fread(dungeon->_rooms[i]._partySouthStartX, sizeof(dungeon->_rooms[i]._partySouthStartX), 1, dng);
-		u4fread(dungeon->_rooms[i]._partySouthStartY, sizeof(dungeon->_rooms[i]._partySouthStartY), 1, dng);
-		u4fread(dungeon->_rooms[i]._partyWestStartX, sizeof(dungeon->_rooms[i]._partyWestStartX), 1, dng);
-		u4fread(dungeon->_rooms[i]._partyWestStartY, sizeof(dungeon->_rooms[i]._partyWestStartY), 1, dng);
+		dungeon->_rooms[i].load(*dng);
 		u4fread(room_tiles, sizeof(room_tiles), 1, dng);
 		u4fread(dungeon->_rooms[i]._buffer, sizeof(dungeon->_rooms[i]._buffer), 1, dng);
 
@@ -362,56 +352,10 @@ bool DngMapLoader::load(Map *map) {
 		// dungeon room fixup
 		//
 		if (map->_id == MAP_HYTHLOTH) {
-			// A couple rooms in hythloth have nullptr player start positions,
-			// which causes the entire party to appear in the upper-left
-			// tile when entering the dungeon room.
-			//
-			// Also, one dungeon room is apparently supposed to be connected
-			// to another, although the the connection does not exist in the
-			// DOS U4 dungeon data file.  This was fixed by removing a few
-			// wall tiles, and relocating a chest and the few monsters around
-			// it to the center of the room.
-			//
 			if (i == 0x7) {
-				// update party start positions when entering from the east
-				const byte x1[8] = { 0x8, 0x8, 0x9, 0x9, 0x9, 0xA, 0xA, 0xA },
-				                            y1[8] = { 0x3, 0x2, 0x3, 0x2, 0x1, 0x3, 0x2, 0x1 };
-				memcpy(dungeon->_rooms[i]._partyEastStartX, x1, sizeof(x1));
-				memcpy(dungeon->_rooms[i]._partyEastStartY, y1, sizeof(y1));
-
-				// update party start positions when entering from the south
-				const byte x2[8] = { 0x3, 0x2, 0x3, 0x2, 0x1, 0x3, 0x2, 0x1 },
-				                            y2[8] = { 0x8, 0x8, 0x9, 0x9, 0x9, 0xA, 0xA, 0xA };
-				memcpy(dungeon->_rooms[i]._partySouthStartX, x2, sizeof(x2));
-				memcpy(dungeon->_rooms[i]._partySouthStartY, y2, sizeof(y2));
+				dungeon->_rooms[i].hythlothFix7();
 			} else if (i == 0x9) {
-				// Update the starting position of monsters 7, 8, and 9
-				const byte x1[3] = { 0x4, 0x6, 0x5 },
-				                            y1[3] = { 0x5, 0x5, 0x6 };
-				memcpy(dungeon->_rooms[i]._creatureStartX + 7, x1, sizeof(x1));
-				memcpy(dungeon->_rooms[i]._creatureStartY + 7, y1, sizeof(y1));
-
-				// Update party start positions when entering from the west
-				const byte x2[8] = { 0x2, 0x2, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0 },
-				                            y2[8] = { 0x9, 0x8, 0x9, 0x8, 0x7, 0x9, 0x8, 0x7 };
-				memcpy(dungeon->_rooms[i]._partyWestStartX, x2, sizeof(x2));
-				memcpy(dungeon->_rooms[i]._partyWestStartY, y2, sizeof(y2));
-
-				// update the map data, moving the chest to the center of the room,
-				// and removing the walls at the lower-left corner thereby creating
-				// a connection to room 8
-				const Coords tile[] = { Coords(5, 5, 0x3C),  // chest
-				                        Coords(0, 7, 0x16),  // floor
-				                        Coords(1, 7, 0x16),
-				                        Coords(0, 8, 0x16),
-				                        Coords(1, 8, 0x16),
-				                        Coords(0, 9, 0x16)
-				                      };
-
-				for (j = 0; j < int(sizeof(tile) / sizeof(Coords)); j++) {
-					const int index = (tile[j].y * CON_WIDTH) + tile[j].x;
-					dungeon->_rooms[i]._mapData[index] = g_tileMaps->get("base")->translate(tile[j].z);
-				}
+				dungeon->_rooms[i].hythlothFix9();
 			}
 		}
 	}




More information about the Scummvm-git-logs mailing list