diff --git a/apps/openmw/mwscript/cellextensions.cpp b/apps/openmw/mwscript/cellextensions.cpp index 4d30254693..2dd46022b0 100644 --- a/apps/openmw/mwscript/cellextensions.cpp +++ b/apps/openmw/mwscript/cellextensions.cpp @@ -8,6 +8,7 @@ #include #include "../mwworld/world.hpp" +#include "../mwworld/player.hpp" #include "interpretercontext.hpp" @@ -84,9 +85,27 @@ namespace MWScript } }; + class OpGetInterior : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + InterpreterContext& context + = static_cast (runtime.getContext()); + + bool interior = + context.getWorld().getPlayer().getPlayer().getCell()->cell->data.flags & + ESM::Cell::Interior; + + runtime.push (interior ? 1 : 0); + } + }; + const int opcodeCellChanged = 0x2000000; const int opcodeCOC = 0x2000026; const int opcodeCOE = 0x200008e; + const int opcodeGetInterior = 0x2000131; void registerExtensions (Compiler::Extensions& extensions) { @@ -95,6 +114,7 @@ namespace MWScript extensions.registerInstruction ("centeroncell", "S", opcodeCOC); extensions.registerInstruction ("coe", "ll", opcodeCOE); extensions.registerInstruction ("centeronexterior", "ll", opcodeCOE); + extensions.registerFunction ("getinterior", 'l', "", opcodeGetInterior); } void installOpcodes (Interpreter::Interpreter& interpreter) @@ -102,6 +122,7 @@ namespace MWScript interpreter.installSegment5 (opcodeCellChanged, new OpCellChanged); interpreter.installSegment5 (opcodeCOC, new OpCOC); interpreter.installSegment5 (opcodeCOE, new OpCOE); + interpreter.installSegment5 (opcodeGetInterior, new OpGetInterior); } } } diff --git a/apps/openmw/mwscript/docs/vmformat.txt b/apps/openmw/mwscript/docs/vmformat.txt index ac78f80054..8f9ad70cb4 100644 --- a/apps/openmw/mwscript/docs/vmformat.txt +++ b/apps/openmw/mwscript/docs/vmformat.txt @@ -102,4 +102,5 @@ op 0x20000df-0x20000f9: SetSkill, explicit reference op 0x20000fa-0x2000114: ModSkill op 0x2000115-0x200012f: ModSKill, explicit reference op 0x2000130: ToggleCollision -opcodes 0x2000131-0x3ffffff unused +op 0x2000131: GetInterior +opcodes 0x2000132-0x3ffffff unused