[Scummvm-cvs-logs] SF.net SVN: scummvm: [29504] scummvm/trunk/engines/parallaction
peres001 at users.sourceforge.net
peres001 at users.sourceforge.net
Wed Nov 14 23:24:26 CET 2007
Revision: 29504
http://scummvm.svn.sourceforge.net/scummvm/?rev=29504&view=rev
Author: peres001
Date: 2007-11-14 14:24:26 -0800 (Wed, 14 Nov 2007)
Log Message:
-----------
* centralized kEngineChangeLocation flag handling
* simplified runGame, moving flags testing into called routines
Modified Paths:
--------------
scummvm/trunk/engines/parallaction/callables_ns.cpp
scummvm/trunk/engines/parallaction/debug.cpp
scummvm/trunk/engines/parallaction/exec_ns.cpp
scummvm/trunk/engines/parallaction/gui_ns.cpp
scummvm/trunk/engines/parallaction/parallaction.cpp
scummvm/trunk/engines/parallaction/parallaction.h
scummvm/trunk/engines/parallaction/parallaction_ns.cpp
scummvm/trunk/engines/parallaction/saveload.cpp
scummvm/trunk/engines/parallaction/walk.cpp
Modified: scummvm/trunk/engines/parallaction/callables_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/callables_ns.cpp 2007-11-14 19:27:08 UTC (rev 29503)
+++ scummvm/trunk/engines/parallaction/callables_ns.cpp 2007-11-14 22:24:26 UTC (rev 29504)
@@ -424,9 +424,7 @@
_gfx->updateScreen();
waitUntilLeftClick();
- strcpy(_location._name, "estgrotta.drki");
-
- _engineFlags |= kEngineChangeLocation;
+ scheduleLocationSwitch("estgrotta.drki");
} else {
_gfx->setFont(_menuFont);
_gfx->displayCenteredString(70, v8C[_language]);
@@ -437,8 +435,7 @@
_gfx->updateScreen();
waitUntilLeftClick();
- selectCharacterForNewLocation();
- _engineFlags |= kEngineChangeLocation;
+ selectStartLocation();
}
cleanupGame();
@@ -534,8 +531,7 @@
waitUntilLeftClick();
_engineFlags &= ~kEngineBlockInput;
- selectCharacterForNewLocation();
- _engineFlags |= kEngineChangeLocation;
+ selectStartLocation();
cleanupGame();
Modified: scummvm/trunk/engines/parallaction/debug.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/debug.cpp 2007-11-14 19:27:08 UTC (rev 29503)
+++ scummvm/trunk/engines/parallaction/debug.cpp 2007-11-14 22:24:26 UTC (rev 29504)
@@ -83,22 +83,21 @@
bool Debugger::Cmd_Location(int argc, const char **argv) {
const char *character = _vm->_char.getName();
- char *location = _vm->_location._name;
+ const char *location = _vm->_location._name;
+ char tmp[PATH_LEN];
+
switch (argc) {
case 3:
character = const_cast<char*>(argv[2]);
location = const_cast<char*>(argv[1]);
- sprintf(_vm->_location._name, "%s.%s", location, character);
- // TODO: check if location exists
- _engineFlags |= kEngineChangeLocation;
+ sprintf(tmp, "%s.%s", location, character);
+ _vm->scheduleLocationSwitch(tmp);
break;
case 2:
location = const_cast<char*>(argv[1]);
- sprintf(_vm->_location._name, "%s", location);
- // TODO: check if location exists
- _engineFlags |= kEngineChangeLocation;
+ _vm->scheduleLocationSwitch(location);
break;
case 1:
Modified: scummvm/trunk/engines/parallaction/exec_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/exec_ns.cpp 2007-11-14 19:27:08 UTC (rev 29503)
+++ scummvm/trunk/engines/parallaction/exec_ns.cpp 2007-11-14 22:24:26 UTC (rev 29504)
@@ -248,8 +248,7 @@
DECLARE_COMMAND_OPCODE(location) {
- strcpy(_location._name, _cmdRunCtxt.cmd->u._string);
- _engineFlags |= kEngineChangeLocation;
+ scheduleLocationSwitch(_cmdRunCtxt.cmd->u._string);
}
Modified: scummvm/trunk/engines/parallaction/gui_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/gui_ns.cpp 2007-11-14 19:27:08 UTC (rev 29503)
+++ scummvm/trunk/engines/parallaction/gui_ns.cpp 2007-11-14 22:24:26 UTC (rev 29504)
@@ -155,7 +155,7 @@
return;
case SELECT_CHARACTER:
- selectCharacterForNewLocation();
+ selectStartLocation();
break;
}
@@ -163,12 +163,12 @@
return;
}
-void Parallaction_ns::selectCharacterForNewLocation() {
+void Parallaction_ns::selectStartLocation() {
int character = guiSelectCharacter();
if (character == -1)
error("invalid character selected from menu screen");
- strcpy(_location._name, _charStartLocation[character]);
+ scheduleLocationSwitch(_charStartLocation[character]);
}
Modified: scummvm/trunk/engines/parallaction/parallaction.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.cpp 2007-11-14 19:27:08 UTC (rev 29503)
+++ scummvm/trunk/engines/parallaction/parallaction.cpp 2007-11-14 22:24:26 UTC (rev 29504)
@@ -274,23 +274,9 @@
while ((_engineFlags & kEngineQuit) == 0) {
_keyDown = updateInput();
-
- debugC(3, kDebugInput, "runGame: input flags (%i, %i, %i, %i)",
- !_mouseHidden,
- (_engineFlags & kEngineBlockInput) == 0,
- (_engineFlags & kEngineWalking) == 0,
- (_engineFlags & kEngineChangeLocation) == 0
- );
-
- // WORKAROUND: the engine doesn't check for displayed labels before performing a location
- // switch, thus crashing whenever a jobDisplayLabel/jEraseLabel pair is left into the
- // queue after the character enters a door.
- // Skipping input processing when kEngineChangeLocation is set solves the issue. It's
- // noteworthy that the programmers added this very check in Big Red Adventure's engine,
- // so it should be ok here in Nippon Safes too.
- if ((!_mouseHidden) && ((_engineFlags & kEngineBlockInput) == 0) && ((_engineFlags & kEngineWalking) == 0) && ((_engineFlags & kEngineChangeLocation) == 0)) {
- InputData *v8 = translateInput();
- if (v8) processInput(v8);
+ InputData *v8 = translateInput();
+ if (v8) {
+ processInput(v8);
}
if (_activeZone) {
@@ -305,20 +291,25 @@
continue;
}
- g_system->delayMillis(30);
-
runJobs();
- if ((_engineFlags & kEnginePauseJobs) == 0 || (_engineFlags & kEngineInventory)) {
- _gfx->swapBuffers();
- _gfx->animatePalette();
- }
+ updateView();
}
- return;
}
+void Parallaction::updateView() {
+
+ if ((_engineFlags & kEnginePauseJobs) && (_engineFlags & kEngineInventory) == 0) {
+ return;
+ }
+
+ _gfx->animatePalette();
+ _gfx->swapBuffers();
+ g_system->delayMillis(30);
+}
+
void Parallaction::showLabel(Label &label) {
label.resetPosition();
_jDrawLabel = addJob(kJobDisplayLabel, (void*)&label, kPriority0);
@@ -429,6 +420,22 @@
Parallaction::InputData *Parallaction::translateInput() {
+ debugC(3, kDebugInput, "translateInput: input flags (%i, %i, %i, %i)",
+ !_mouseHidden,
+ (_engineFlags & kEngineBlockInput) == 0,
+ (_engineFlags & kEngineWalking) == 0,
+ (_engineFlags & kEngineChangeLocation) == 0
+ );
+
+ if ((_mouseHidden) ||
+ (_engineFlags & kEngineBlockInput) ||
+ (_engineFlags & kEngineWalking) ||
+ (_engineFlags & kEngineChangeLocation)) {
+
+ return NULL;
+ }
+
+
if (_keyDown == kEvQuitGame) {
_input._event = kEvQuitGame;
return &_input;
@@ -1047,6 +1054,10 @@
_soundMan->playSfx("beep", 3, false);
}
+void Parallaction::scheduleLocationSwitch(const char *location) {
+ strcpy(_location._name, location);
+ _engineFlags |= kEngineChangeLocation;
+}
} // namespace Parallaction
Modified: scummvm/trunk/engines/parallaction/parallaction.h
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.h 2007-11-14 19:27:08 UTC (rev 29503)
+++ scummvm/trunk/engines/parallaction/parallaction.h 2007-11-14 22:24:26 UTC (rev 29504)
@@ -536,12 +536,15 @@
void initGlobals();
void runGame();
+ void updateView();
uint32 getElapsedTime();
void resetTimer();
InputData *translateInput();
void processInput(InputData*);
+
+ void scheduleLocationSwitch(const char *location);
void doLocationEnterTransition();
virtual void changeLocation(char *location) = 0;
virtual void changeCharacter(const char *name) = 0;
@@ -904,7 +907,7 @@
DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(move);
DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(endscript);
- void selectCharacterForNewLocation();
+ void selectStartLocation();
void guiStart();
int guiSelectCharacter();
@@ -978,7 +981,6 @@
const JobFn *_jobsFn;
JobOpcode* createJobOpcode(uint functionId, Job *job);
-
void changeLocation(char *location);
void changeCharacter(const char *name);
Modified: scummvm/trunk/engines/parallaction/parallaction_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction_ns.cpp 2007-11-14 19:27:08 UTC (rev 29503)
+++ scummvm/trunk/engines/parallaction/parallaction_ns.cpp 2007-11-14 22:24:26 UTC (rev 29504)
@@ -410,6 +410,7 @@
}
+
void Parallaction_ns::changeCharacter(const char *name) {
debugC(1, kDebugExec, "changeCharacter(%s)", name);
Modified: scummvm/trunk/engines/parallaction/saveload.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/saveload.cpp 2007-11-14 19:27:08 UTC (rev 29503)
+++ scummvm/trunk/engines/parallaction/saveload.cpp 2007-11-14 22:24:26 UTC (rev 29504)
@@ -159,8 +159,9 @@
// bugs, but it's a good maneuver anyway
strcpy(_characterName1, "null");
- sprintf(_location._name, "%s.%s" , l, n);
- _engineFlags |= kEngineChangeLocation;
+ char tmp[PATH_LEN];
+ sprintf(tmp, "%s.%s" , l, n);
+ scheduleLocationSwitch(tmp);
return;
}
Modified: scummvm/trunk/engines/parallaction/walk.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/walk.cpp 2007-11-14 19:27:08 UTC (rev 29503)
+++ scummvm/trunk/engines/parallaction/walk.cpp 2007-11-14 22:24:26 UTC (rev 29504)
@@ -344,9 +344,8 @@
if ((z->_flags & kFlagsClosed) == 0) {
_location._startPosition = z->u.door->_startPos;
_location._startFrame = z->u.door->_startFrame;
- strcpy(_location._name, z->u.door->_location);
- _engineFlags |= kEngineChangeLocation;
+ scheduleLocationSwitch(z->u.door->_location);
_zoneTrap = NULL;
} else {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list