aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2007-11-17 06:53:13 +0000
committerPaul Gilbert2007-11-17 06:53:13 +0000
commitca10a4db08c3a3344034def39f8599a1ed14db4b (patch)
tree388d036c38cd976b768736231442c87b48dd7362 /engines
parent1002a58f011db47fc74fe23dd5dc5b802f4960de (diff)
downloadscummvm-rg350-ca10a4db08c3a3344034def39f8599a1ed14db4b.tar.gz
scummvm-rg350-ca10a4db08c3a3344034def39f8599a1ed14db4b.tar.bz2
scummvm-rg350-ca10a4db08c3a3344034def39f8599a1ed14db4b.zip
Bugfixes to the fighting animations and proper reset of fight data between save sessions
svn-id: r29526
Diffstat (limited to 'engines')
-rw-r--r--engines/lure/fights.cpp43
-rw-r--r--engines/lure/fights.h2
-rw-r--r--engines/lure/game.cpp1
-rw-r--r--engines/lure/game.h1
-rw-r--r--engines/lure/room.cpp12
5 files changed, 45 insertions, 14 deletions
diff --git a/engines/lure/fights.cpp b/engines/lure/fights.cpp
index d74047d162..bdbd31e884 100644
--- a/engines/lure/fights.cpp
+++ b/engines/lure/fights.cpp
@@ -30,7 +30,7 @@
namespace Lure {
// Three records containing initial states for player, pig, and Skorl
-FighterRecord fighterList[3] = {
+const FighterRecord initialFighterList[3] = {
{0x23C, 0x440, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0},
{0, 0x441, 0x1092, 0, 3, 0, 0, 0, 0xB94, 8, 0xA34, 0x8D4, 0xD06, 0,
0, 0, 0, 0, 0xDDC, PLAYER_ID},
@@ -44,6 +44,7 @@ FightsManager::FightsManager() {
int_fights = this;
_fightData = NULL;
_mouseFlags = 0;
+ reset();
}
FightsManager::~FightsManager() {
@@ -57,9 +58,9 @@ FightsManager &FightsManager::getReference() {
}
FighterRecord &FightsManager::getDetails(uint16 hotspotId) {
- if (hotspotId == PLAYER_ID) return fighterList[0];
- else if (hotspotId == PIG_ID) return fighterList[1];
- else if (hotspotId == SKORL_FIGHTER_ID) return fighterList[2];
+ if (hotspotId == PLAYER_ID) return _fighterList[0];
+ else if (hotspotId == PIG_ID) return _fighterList[1];
+ else if (hotspotId == SKORL_FIGHTER_ID) return _fighterList[2];
error("Unknown NPC %d attempted to fight", hotspotId);
}
@@ -108,6 +109,7 @@ bool FightsManager::isFighting() {
void FightsManager::fightLoop() {
Resources &res = Resources::getReference();
+ Game &game = Game::getReference();
Events &events = Events::getReference();
FighterRecord &playerFight = getDetails(PLAYER_ID);
@@ -120,13 +122,16 @@ void FightsManager::fightLoop() {
res.delayList().tick();
Screen::getReference().update();
+ if (game.debugger().isAttached())
+ game.debugger().onFrame();
+
g_system->delayMillis(20);
}
}
void FightsManager::saveToStream(Common::WriteStream *stream) {
for (int fighterCtr = 0; fighterCtr < 3; ++fighterCtr) {
- FighterRecord &rec = fighterList[fighterCtr];
+ FighterRecord &rec = _fighterList[fighterCtr];
stream->writeUint16LE(rec.fwseq_no);
stream->writeUint16LE(rec.fwseq_ad);
@@ -138,8 +143,10 @@ void FightsManager::saveToStream(Common::WriteStream *stream) {
}
void FightsManager::loadFromStream(Common::ReadStream *stream) {
+ reset();
+
for (int fighterCtr = 0; fighterCtr < 3; ++fighterCtr) {
- FighterRecord &rec = fighterList[fighterCtr];
+ FighterRecord &rec = _fighterList[fighterCtr];
rec.fwseq_no = stream->readUint16LE();
rec.fwseq_ad = stream->readUint16LE();
@@ -150,6 +157,12 @@ void FightsManager::loadFromStream(Common::ReadStream *stream) {
}
}
+void FightsManager::reset() {
+ _fighterList[0] = initialFighterList[0];
+ _fighterList[1] = initialFighterList[1];
+ _fighterList[2] = initialFighterList[2];
+}
+
const CursorType moveList[] = {CURSOR_LEFT_ARROW, CURSOR_FIGHT_UPPER,
CURSOR_FIGHT_MIDDLE, CURSOR_FIGHT_LOWER, CURSOR_RIGHT_ARROW};
@@ -165,6 +178,7 @@ const KeyMapping keyList[] = {
{Common::KEYCODE_INVALID, 0}};
void FightsManager::checkEvents() {
+ Game &game = Game::getReference();
Events &events = Events::getReference();
if (!events.pollEvent()) return;
FighterRecord &rec = getDetails(PLAYER_ID);
@@ -179,6 +193,12 @@ void FightsManager::checkEvents() {
events.quitFlag = true;
break;
+ case Common::KEYCODE_d:
+ if (events.event().kbd.flags == Common::KBD_CTRL)
+ // Activate the debugger
+ game.debugger().attach();
+ break;
+
default:
// Scan through the mapping list for a move for the keypress
const KeyMapping *keyPtr = &keyList[0];
@@ -326,10 +346,13 @@ void FightsManager::fightHandler(Hotspot &h, uint16 moveOffset) {
if (fighter.fwweapon != 0) {
Hotspot *weaponHotspot = res.getActiveHotspot(fighter.fwweapon);
assert(weaponHotspot);
- weaponHotspot->setFrameNumber(getWord(moveOffset + 4));
- weaponHotspot->setPosition(weaponHotspot->x() +
- (int16)getWord(moveOffset + 6),
- weaponHotspot->y() + getWord(moveOffset + 8));
+
+ uint16 newFrameNumber = getWord(moveOffset + 4);
+ int16 xChange = (int16)getWord(moveOffset + 6);
+ int16 yChange = (int16)getWord(moveOffset + 8);
+
+ weaponHotspot->setFrameNumber(newFrameNumber);
+ weaponHotspot->setPosition(h.x() + xChange, h.y() + yChange);
}
moveOffset += 5 * sizeof(uint16);
diff --git a/engines/lure/fights.h b/engines/lure/fights.h
index 048949f2b6..9da9dbcc96 100644
--- a/engines/lure/fights.h
+++ b/engines/lure/fights.h
@@ -67,6 +67,7 @@ private:
MemoryBlock *_fightData;
Common::RandomSource _rnd;
uint8 _mouseFlags;
+ FighterRecord _fighterList[3];
FighterRecord &getDetails(uint16 hotspotId);
uint16 fetchFighterDistance(FighterRecord &f1, FighterRecord &f2);
@@ -99,6 +100,7 @@ public:
void fightLoop();
void saveToStream(Common::WriteStream *stream);
void loadFromStream(Common::ReadStream *stream);
+ void reset();
void fighterAnimHandler(Hotspot &h);
void playerAnimHandler(Hotspot &h);
diff --git a/engines/lure/game.cpp b/engines/lure/game.cpp
index 1026925f32..a871a3e831 100644
--- a/engines/lure/game.cpp
+++ b/engines/lure/game.cpp
@@ -142,6 +142,7 @@ void Game::execute() {
if ((_state & GS_RESTART) != 0) {
res.reset();
+ Fights.reset();
if (!initialRestart) room.reset();
setState(0);
diff --git a/engines/lure/game.h b/engines/lure/game.h
index 078fe9b3ee..79c36804ba 100644
--- a/engines/lure/game.h
+++ b/engines/lure/game.h
@@ -80,6 +80,7 @@ public:
bool &preloadFlag() { return _preloadFlag; }
bool fastTextFlag() { return _fastTextFlag; }
bool soundFlag() { return _soundFlag; }
+ Debugger &debugger() { return *_debugger; }
// Menu item support methods
void doDebugMenu();
diff --git a/engines/lure/room.cpp b/engines/lure/room.cpp
index 2fca7fbc71..fa69255ee7 100644
--- a/engines/lure/room.cpp
+++ b/engines/lure/room.cpp
@@ -533,18 +533,22 @@ void Room::setRoomNumber(uint16 newRoomNumber, bool showOverlay) {
_roomData = res.getRoom(newRoomNumber);
if (!_roomData)
error("Tried to change to non-existant room: %d", newRoomNumber);
- bool leaveFlag = (newRoomNumber != _roomNumber) && (_roomNumber != 0);
+
+ bool fadeFlag = (newRoomNumber != _roomNumber) && (_roomNumber != 0);
+ bool leaveFlag = _roomNumber != 999;
_roomNumber = _roomData->roomNumber;
_descId = _roomData->descId;
- if (leaveFlag) {
+ if (fadeFlag) {
// Fade out all the colours except the high index 0FFh, which is used to show the
// disk cursor as a room changes
_screen.paletteFadeOut(GAME_COLOURS - 1);
- leaveRoom();
- Sound.removeSounds();
+ if (leaveFlag) {
+ leaveRoom();
+ Sound.removeSounds();
+ }
}
_screen.empty();