Added a debugger command 'script' to allow execution of script engine methods
svn-id: r31568
This commit is contained in:
parent
5b742734ab
commit
76b1f4bcea
4 changed files with 42 additions and 0 deletions
|
@ -33,6 +33,7 @@
|
||||||
#include "lure/res.h"
|
#include "lure/res.h"
|
||||||
#include "lure/res_struct.h"
|
#include "lure/res_struct.h"
|
||||||
#include "lure/room.h"
|
#include "lure/room.h"
|
||||||
|
#include "lure/scripts.h"
|
||||||
#include "lure/strings.h"
|
#include "lure/strings.h"
|
||||||
|
|
||||||
namespace Lure {
|
namespace Lure {
|
||||||
|
@ -51,6 +52,7 @@ Debugger::Debugger(): GUI::Debugger() {
|
||||||
DCmd_Register("showanim", WRAP_METHOD(Debugger, cmd_showAnim));
|
DCmd_Register("showanim", WRAP_METHOD(Debugger, cmd_showAnim));
|
||||||
DCmd_Register("strings", WRAP_METHOD(Debugger, cmd_saveStrings));
|
DCmd_Register("strings", WRAP_METHOD(Debugger, cmd_saveStrings));
|
||||||
DCmd_Register("debug", WRAP_METHOD(Debugger, cmd_debug));
|
DCmd_Register("debug", WRAP_METHOD(Debugger, cmd_debug));
|
||||||
|
DCmd_Register("script", WRAP_METHOD(Debugger, cmd_script));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int strToInt(const char *s) {
|
static int strToInt(const char *s) {
|
||||||
|
@ -596,4 +598,29 @@ bool Debugger::cmd_debug(int argc, const char **argv) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Debugger::cmd_script(int argc, const char **argv) {
|
||||||
|
if (argc < 2) {
|
||||||
|
DebugPrintf("script <script number> [param 1] [param 2] [param 3] [exit flag]\n");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int scriptNumber = strToInt(argv[1]);
|
||||||
|
if ((scriptNumber < 0) || (scriptNumber > 66)) {
|
||||||
|
DebugPrintf("An invalid script number was specified\n");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16 param1 = 0, param2 = 0, param3 = 0;
|
||||||
|
if (argc >= 3)
|
||||||
|
param1 = strToInt(argv[2]);
|
||||||
|
if (argc >= 4)
|
||||||
|
param2 = strToInt(argv[3]);
|
||||||
|
if (argc >= 5)
|
||||||
|
param3 = strToInt(argv[4]);
|
||||||
|
|
||||||
|
Script::executeMethod(scriptNumber, param1, param2, param3);
|
||||||
|
DebugPrintf("Script executed\n");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
} // End of namespace Lure
|
} // End of namespace Lure
|
||||||
|
|
|
@ -48,6 +48,7 @@ protected:
|
||||||
bool cmd_showAnim(int argc, const char **argv);
|
bool cmd_showAnim(int argc, const char **argv);
|
||||||
bool cmd_saveStrings(int argc, const char **argv);
|
bool cmd_saveStrings(int argc, const char **argv);
|
||||||
bool cmd_debug(int argc, const char **argv);
|
bool cmd_debug(int argc, const char **argv);
|
||||||
|
bool cmd_script(int argc, const char **argv);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const char *directionList[5];
|
extern const char *directionList[5];
|
||||||
|
|
|
@ -1171,6 +1171,19 @@ uint16 Script::execute(uint16 startOffset) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Script::executeMethod(int methodIndex, uint16 v1, uint16 v2, uint16 v3) {
|
||||||
|
const SequenceMethodRecord *rec = &scriptMethods[0];
|
||||||
|
while ((rec->methodIndex != 0xff) && (rec->methodIndex != methodIndex))
|
||||||
|
++rec;
|
||||||
|
|
||||||
|
if (rec->methodIndex == 0xff)
|
||||||
|
warning("Undefined script method %d", methodIndex);
|
||||||
|
else {
|
||||||
|
SequenceMethodPtr ptr = rec->proc;
|
||||||
|
ptr(v1, v2, v3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
/*- Hotspot Script Handler -*/
|
/*- Hotspot Script Handler -*/
|
||||||
/*- -*/
|
/*- -*/
|
||||||
|
|
|
@ -77,6 +77,7 @@ class Script {
|
||||||
public:
|
public:
|
||||||
static uint16 execute(uint16 startOffset);
|
static uint16 execute(uint16 startOffset);
|
||||||
|
|
||||||
|
static void executeMethod(int methodIndex, uint16 v1, uint16 v2, uint16 v3);
|
||||||
static void activateHotspot(uint16 hotspotId, uint16 v2, uint16 v3);
|
static void activateHotspot(uint16 hotspotId, uint16 v2, uint16 v3);
|
||||||
static void setHotspotScript(uint16 hotspotId, uint16 scriptIndex, uint16 v3);
|
static void setHotspotScript(uint16 hotspotId, uint16 scriptIndex, uint16 v3);
|
||||||
static void addSound2(uint16 soundIndex, uint16 v2, uint16 v3);
|
static void addSound2(uint16 soundIndex, uint16 v2, uint16 v3);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue