mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-29 08:15:35 +00:00
added Lock and Unlock instructions
This commit is contained in:
parent
61c4fa0630
commit
147dd57162
2 changed files with 101 additions and 2 deletions
|
@ -17,7 +17,9 @@ op 0x20000: AiTravel
|
|||
op 0x20001: AiTravel, explicit reference
|
||||
op 0x20002: AiEscort
|
||||
op 0x20003: AiEscort, explicit reference
|
||||
opcodes 0x20004-0x3ffff unused
|
||||
op 0x20004: Lock
|
||||
op 0x20005: Lock, explicit reference
|
||||
opcodes 0x20006-0x3ffff unused
|
||||
|
||||
Segment 4:
|
||||
(not implemented yet)
|
||||
|
@ -90,4 +92,6 @@ op 0x200007c: GetAiPackageDone
|
|||
op 0x200007d: GetAiPackageDone, explicit reference
|
||||
op 0x200007e-0x2000084: Enable Controls
|
||||
op 0x2000085-0x200008b: Disable Controls
|
||||
opcodes 0x200008c-0x3ffffff unused
|
||||
op 0x200008c: Unlock
|
||||
op 0x200008d: Unlock, explicit reference
|
||||
opcodes 0x200008e-0x3ffffff unused
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
#include "interpretercontext.hpp"
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWScript
|
||||
{
|
||||
namespace Misc
|
||||
|
@ -53,15 +55,104 @@ namespace MWScript
|
|||
}
|
||||
};
|
||||
|
||||
class OpLock : public Interpreter::Opcode1
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
|
||||
{
|
||||
InterpreterContext& context =
|
||||
static_cast<InterpreterContext&> (runtime.getContext());
|
||||
|
||||
MWWorld::Ptr ptr = context.getReference();
|
||||
|
||||
Interpreter::Type_Integer lockLevel = 100;
|
||||
|
||||
if (arg0==1)
|
||||
{
|
||||
lockLevel = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
}
|
||||
|
||||
MWWorld::Class::get (ptr).lock (ptr, lockLevel);
|
||||
}
|
||||
};
|
||||
|
||||
class OpLockExplicit : public Interpreter::Opcode1
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
|
||||
{
|
||||
InterpreterContext& context =
|
||||
static_cast<InterpreterContext&> (runtime.getContext());
|
||||
|
||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
||||
|
||||
Interpreter::Type_Integer lockLevel = 100;
|
||||
|
||||
if (arg0==1)
|
||||
{
|
||||
lockLevel = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
}
|
||||
|
||||
MWWorld::Class::get (ptr).lock (ptr, lockLevel);
|
||||
}
|
||||
};
|
||||
|
||||
class OpUnlock : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
InterpreterContext& context =
|
||||
static_cast<InterpreterContext&> (runtime.getContext());
|
||||
|
||||
MWWorld::Ptr ptr = context.getReference();
|
||||
|
||||
MWWorld::Class::get (ptr).unlock (ptr);
|
||||
}
|
||||
};
|
||||
|
||||
class OpUnlockExplicit : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
InterpreterContext& context =
|
||||
static_cast<InterpreterContext&> (runtime.getContext());
|
||||
|
||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
||||
|
||||
MWWorld::Class::get (ptr).unlock (ptr);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const int opcodeXBox = 0x200000c;
|
||||
const int opcodeOnActivate = 0x200000d;
|
||||
const int opcodeActivate = 0x2000075;
|
||||
const int opcodeLock = 0x20004;
|
||||
const int opcodeLockExplicit = 0x20005;
|
||||
const int opcodeUnlock = 0x200008c;
|
||||
const int opcodeUnlockExplicit = 0x200008d;
|
||||
|
||||
void registerExtensions (Compiler::Extensions& extensions)
|
||||
{
|
||||
extensions.registerFunction ("xbox", 'l', "", opcodeXBox);
|
||||
extensions.registerFunction ("onactivate", 'l', "", opcodeOnActivate);
|
||||
extensions.registerInstruction ("activate", "", opcodeActivate);
|
||||
extensions.registerInstruction ("lock", "/l", opcodeLock, opcodeLockExplicit);
|
||||
extensions.registerInstruction ("unlock", "", opcodeUnlock, opcodeUnlockExplicit);
|
||||
}
|
||||
|
||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||
|
@ -69,6 +160,10 @@ namespace MWScript
|
|||
interpreter.installSegment5 (opcodeXBox, new OpXBox);
|
||||
interpreter.installSegment5 (opcodeOnActivate, new OpOnActivate);
|
||||
interpreter.installSegment5 (opcodeActivate, new OpActivate);
|
||||
interpreter.installSegment3 (opcodeLock, new OpLock);
|
||||
interpreter.installSegment3 (opcodeLockExplicit, new OpLockExplicit);
|
||||
interpreter.installSegment5 (opcodeUnlock, new OpUnlock);
|
||||
interpreter.installSegment5 (opcodeUnlockExplicit, new OpUnlockExplicit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue