From de1f423bd7e32ba8db78fd8cf8d8249ac7baa9f0 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 6 Aug 2013 20:38:41 -0400 Subject: [PATCH] initial move of script opcodes and registerExtensions functions to components/compiler --- apps/openmw/engine.cpp | 9 +- apps/openmw/mwgui/console.cpp | 3 +- apps/openmw/mwscript/aiextensions.cpp | 170 ++----- apps/openmw/mwscript/aiextensions.hpp | 2 - apps/openmw/mwscript/animationextensions.cpp | 28 +- apps/openmw/mwscript/cellextensions.cpp | 39 +- apps/openmw/mwscript/cellextensions.hpp | 4 +- apps/openmw/mwscript/consoleextensions.cpp | 6 +- apps/openmw/mwscript/consoleextensions.hpp | 2 - apps/openmw/mwscript/containerextensions.cpp | 63 +-- apps/openmw/mwscript/containerextensions.hpp | 2 - apps/openmw/mwscript/controlextensions.cpp | 95 +--- apps/openmw/mwscript/controlextensions.hpp | 2 - apps/openmw/mwscript/dialogueextensions.cpp | 70 +-- apps/openmw/mwscript/dialogueextensions.hpp | 2 - apps/openmw/mwscript/extensions.cpp | 22 - apps/openmw/mwscript/extensions.hpp | 3 - apps/openmw/mwscript/guiextensions.cpp | 81 +-- apps/openmw/mwscript/guiextensions.hpp | 4 +- apps/openmw/mwscript/miscextensions.cpp | 212 +++----- apps/openmw/mwscript/miscextensions.hpp | 4 +- apps/openmw/mwscript/skyextensions.cpp | 38 +- apps/openmw/mwscript/skyextensions.hpp | 4 +- apps/openmw/mwscript/soundextensions.cpp | 80 +-- apps/openmw/mwscript/soundextensions.hpp | 5 +- apps/openmw/mwscript/statsextensions.cpp | 366 +++----------- apps/openmw/mwscript/statsextensions.hpp | 4 +- .../mwscript/transformationextensions.cpp | 138 ++---- .../mwscript/transformationextensions.hpp | 4 +- apps/openmw/mwscript/userextensions.cpp | 29 +- apps/openmw/mwscript/userextensions.hpp | 2 - components/CMakeLists.txt | 2 +- components/compiler/opcodes.cpp | 13 + components/compiler/opcodes.hpp | 411 ++++++++++++++++ components/compiler/registerextensions.cpp | 461 ++++++++++++++++++ components/compiler/registerextensions.hpp | 81 +++ 36 files changed, 1324 insertions(+), 1137 deletions(-) create mode 100644 components/compiler/opcodes.cpp create mode 100644 components/compiler/opcodes.hpp create mode 100644 components/compiler/registerextensions.cpp create mode 100644 components/compiler/registerextensions.hpp diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index b35d693a6b..9be158a604 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -7,6 +7,8 @@ #include +#include + #include #include #include @@ -395,7 +397,8 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings) mTranslationDataStorage.loadTranslationData(mFileCollections, mMaster[i]); // Create window manager - this manages all the MW-specific GUI windows - MWScript::registerExtensions (mExtensions); + // MWScript::registerExtensions (mExtensions); // WHY DOES THIS NOT HAVE THE BOOL PARAMETER? + Compiler::registerExtensions (mExtensions, false); mEnvironment.setWindowManager (new MWGui::WindowManager( mExtensions, mFpsLevel, mOgre, mCfgMgr.getLogPath().string() + std::string("/"), @@ -478,7 +481,7 @@ void OMW::Engine::go() assert (!mOgre); Settings::Manager settings; - std::string settingspath; + std::string settingspath; settingspath = loadSettings (settings); @@ -595,4 +598,4 @@ void OMW::Engine::setStartupScript (const std::string& path) void OMW::Engine::setActivationDistanceOverride (int distance) { mActivationDistanceOverride = distance; -} +} \ No newline at end of file diff --git a/apps/openmw/mwgui/console.cpp b/apps/openmw/mwgui/console.cpp index ff774b531e..7779488a69 100644 --- a/apps/openmw/mwgui/console.cpp +++ b/apps/openmw/mwgui/console.cpp @@ -1,6 +1,7 @@ #include "console.hpp" #include +#include #include "../mwscript/extensions.hpp" @@ -122,7 +123,7 @@ namespace MWGui mHistory->setVisibleVScroll(true); // compiler - MWScript::registerExtensions (mExtensions, mConsoleOnlyScripts); + Compiler::registerExtensions (mExtensions, mConsoleOnlyScripts); mCompilerContext.setExtensions (&mExtensions); } diff --git a/apps/openmw/mwscript/aiextensions.cpp b/apps/openmw/mwscript/aiextensions.cpp index 9f29163afc..b77d61aa51 100644 --- a/apps/openmw/mwscript/aiextensions.cpp +++ b/apps/openmw/mwscript/aiextensions.cpp @@ -2,6 +2,7 @@ #include "aiextensions.hpp" #include +#include #include #include @@ -365,137 +366,56 @@ namespace MWScript }; - const int opcodeAiTravel = 0x20000; - const int opcodeAiTravelExplicit = 0x20001; - const int opcodeAiEscort = 0x20002; - const int opcodeAiEscortExplicit = 0x20003; - const int opcodeGetAiPackageDone = 0x200007c; - const int opcodeGetAiPackageDoneExplicit = 0x200007d; - const int opcodeGetCurrentAiPackage = 0x20001ef; - const int opcodeGetCurrentAiPackageExplicit = 0x20001f0; - const int opcodeGetDetected = 0x20001f1; - const int opcodeGetDetectedExplicit = 0x20001f2; - const int opcodeAiWander = 0x20010; - const int opcodeAiWanderExplicit = 0x20011; - const int opcodeAIActivate = 0x2001e; - const int opcodeAIActivateExplicit = 0x2001f; - const int opcodeAiEscortCell = 0x20020; - const int opcodeAiEscortCellExplicit = 0x20021; - const int opcodeAiFollow = 0x20022; - const int opcodeAiFollowExplicit = 0x20023; - const int opcodeAiFollowCell = 0x20024; - const int opcodeAiFollowCellExplicit = 0x20025; - const int opcodeSetHello = 0x200015e; - const int opcodeSetHelloExplicit = 0x200015d; - const int opcodeSetFight = 0x200015e; - const int opcodeSetFightExplicit = 0x200015f; - const int opcodeSetFlee = 0x2000160; - const int opcodeSetFleeExplicit = 0x2000161; - const int opcodeSetAlarm = 0x2000162; - const int opcodeSetAlarmExplicit = 0x2000163; - const int opcodeModHello = 0x20001b7; - const int opcodeModHelloExplicit = 0x20001b8; - const int opcodeModFight = 0x20001b9; - const int opcodeModFightExplicit = 0x20001ba; - const int opcodeModFlee = 0x20001bb; - const int opcodeModFleeExplicit = 0x20001bc; - const int opcodeModAlarm = 0x20001bd; - const int opcodeModAlarmExplicit = 0x20001be; - const int opcodeGetHello = 0x20001bf; - const int opcodeGetHelloExplicit = 0x20001c0; - const int opcodeGetFight = 0x20001c1; - const int opcodeGetFightExplicit = 0x20001c2; - const int opcodeGetFlee = 0x20001c3; - const int opcodeGetFleeExplicit = 0x20001c4; - const int opcodeGetAlarm = 0x20001c5; - const int opcodeGetAlarmExplicit = 0x20001c6; - - void registerExtensions (Compiler::Extensions& extensions) - { - extensions.registerInstruction ("aiactivate", "c/l", opcodeAIActivate, - opcodeAIActivateExplicit); - extensions.registerInstruction ("aitravel", "fff/l", opcodeAiTravel, - opcodeAiTravelExplicit); - extensions.registerInstruction ("aiescort", "cffff/l", opcodeAiEscort, - opcodeAiEscortExplicit); - extensions.registerInstruction ("aiescortcell", "ccffff/l", opcodeAiEscortCell, - opcodeAiEscortCellExplicit); - extensions.registerInstruction ("aiwander", "fff/llllllllll", opcodeAiWander, - opcodeAiWanderExplicit); - extensions.registerInstruction ("aifollow", "cffff/l", opcodeAiFollow, - opcodeAiFollowExplicit); - extensions.registerInstruction ("aifollowcell", "ccffff/l", opcodeAiFollowCell, - opcodeAiFollowCellExplicit); - extensions.registerFunction ("getaipackagedone", 'l', "", opcodeGetAiPackageDone, - opcodeGetAiPackageDoneExplicit); - extensions.registerFunction ("getcurrentaipackage", 'l', "", opcodeGetCurrentAiPackage, - opcodeGetAiPackageDoneExplicit); - extensions.registerFunction ("getdetected", 'l', "c", opcodeGetDetected, - opcodeGetDetectedExplicit); - extensions.registerInstruction ("sethello", "l", opcodeSetHello, opcodeSetHelloExplicit); - extensions.registerInstruction ("setfight", "l", opcodeSetFight, opcodeSetFightExplicit); - extensions.registerInstruction ("setflee", "l", opcodeSetFlee, opcodeSetFleeExplicit); - extensions.registerInstruction ("setalarm", "l", opcodeSetAlarm, opcodeSetAlarmExplicit); - extensions.registerInstruction ("modhello", "l", opcodeModHello, opcodeModHelloExplicit); - extensions.registerInstruction ("modfight", "l", opcodeModFight, opcodeModFightExplicit); - extensions.registerInstruction ("modflee", "l", opcodeModFlee, opcodeModFleeExplicit); - extensions.registerInstruction ("modalarm", "l", opcodeModAlarm, opcodeModAlarmExplicit); - extensions.registerFunction ("gethello", 'l', "", opcodeGetHello, opcodeGetHelloExplicit); - extensions.registerFunction ("getfight", 'l', "", opcodeGetFight, opcodeGetFightExplicit); - extensions.registerFunction ("getflee", 'l', "", opcodeGetFlee, opcodeGetFleeExplicit); - extensions.registerFunction ("getalarm", 'l', "", opcodeGetAlarm, opcodeGetAlarmExplicit); - } - void installOpcodes (Interpreter::Interpreter& interpreter) { - interpreter.installSegment3 (opcodeAIActivate, new OpAiActivate); - interpreter.installSegment3 (opcodeAIActivateExplicit, new OpAiActivate); - interpreter.installSegment3 (opcodeAiTravel, new OpAiTravel); - interpreter.installSegment3 (opcodeAiTravelExplicit, new OpAiTravel); - interpreter.installSegment3 (opcodeAiEscort, new OpAiEscort); - interpreter.installSegment3 (opcodeAiEscortExplicit, new OpAiEscort); - interpreter.installSegment3 (opcodeAiEscortCell, new OpAiEscortCell); - interpreter.installSegment3 (opcodeAiEscortCellExplicit, new OpAiEscortCell); - interpreter.installSegment3 (opcodeAiWander, new OpAiWander); - interpreter.installSegment3 (opcodeAiWanderExplicit, new OpAiWander); - interpreter.installSegment3 (opcodeAiFollow, new OpAiFollow); - interpreter.installSegment3 (opcodeAiFollowExplicit, new OpAiFollow); - interpreter.installSegment3 (opcodeAiFollowCell, new OpAiFollowCell); - interpreter.installSegment3 (opcodeAiFollowCellExplicit, new OpAiFollowCell); - interpreter.installSegment5 (opcodeGetAiPackageDone, new OpGetAiPackageDone); + interpreter.installSegment3 (Compiler::Ai::opcodeAIActivate, new OpAiActivate); + interpreter.installSegment3 (Compiler::Ai::opcodeAIActivateExplicit, new OpAiActivate); + interpreter.installSegment3 (Compiler::Ai::opcodeAiTravel, new OpAiTravel); + interpreter.installSegment3 (Compiler::Ai::opcodeAiTravelExplicit, new OpAiTravel); + interpreter.installSegment3 (Compiler::Ai::opcodeAiEscort, new OpAiEscort); + interpreter.installSegment3 (Compiler::Ai::opcodeAiEscortExplicit, new OpAiEscort); + interpreter.installSegment3 (Compiler::Ai::opcodeAiEscortCell, new OpAiEscortCell); + interpreter.installSegment3 (Compiler::Ai::opcodeAiEscortCellExplicit, new OpAiEscortCell); + interpreter.installSegment3 (Compiler::Ai::opcodeAiWander, new OpAiWander); + interpreter.installSegment3 (Compiler::Ai::opcodeAiWanderExplicit, new OpAiWander); + interpreter.installSegment3 (Compiler::Ai::opcodeAiFollow, new OpAiFollow); + interpreter.installSegment3 (Compiler::Ai::opcodeAiFollowExplicit, new OpAiFollow); + interpreter.installSegment3 (Compiler::Ai::opcodeAiFollowCell, new OpAiFollowCell); + interpreter.installSegment3 (Compiler::Ai::opcodeAiFollowCellExplicit, new OpAiFollowCell); + interpreter.installSegment5 (Compiler::Ai::opcodeGetAiPackageDone, new OpGetAiPackageDone); - interpreter.installSegment5 (opcodeGetAiPackageDoneExplicit, + interpreter.installSegment5 (Compiler::Ai::opcodeGetAiPackageDoneExplicit, new OpGetAiPackageDone); - interpreter.installSegment5 (opcodeGetCurrentAiPackage, new OpGetCurrentAIPackage); - interpreter.installSegment5 (opcodeGetCurrentAiPackageExplicit, new OpGetCurrentAIPackage); - interpreter.installSegment3 (opcodeGetDetected, new OpGetDetected); - interpreter.installSegment3 (opcodeGetDetectedExplicit, new OpGetDetected); - interpreter.installSegment5 (opcodeSetHello, new OpSetAiSetting(0)); - interpreter.installSegment5 (opcodeSetHelloExplicit, new OpSetAiSetting(0)); - interpreter.installSegment5 (opcodeSetFight, new OpSetAiSetting(1)); - interpreter.installSegment5 (opcodeSetFightExplicit, new OpSetAiSetting(1)); - interpreter.installSegment5 (opcodeSetFlee, new OpSetAiSetting(2)); - interpreter.installSegment5 (opcodeSetFleeExplicit, new OpSetAiSetting(2)); - interpreter.installSegment5 (opcodeSetAlarm, new OpSetAiSetting(3)); - interpreter.installSegment5 (opcodeSetAlarmExplicit, new OpSetAiSetting(3)); + interpreter.installSegment5 (Compiler::Ai::opcodeGetCurrentAiPackage, new OpGetCurrentAIPackage); + interpreter.installSegment5 (Compiler::Ai::opcodeGetCurrentAiPackageExplicit, new OpGetCurrentAIPackage); + interpreter.installSegment3 (Compiler::Ai::opcodeGetDetected, new OpGetDetected); + interpreter.installSegment3 (Compiler::Ai::opcodeGetDetectedExplicit, new OpGetDetected); + interpreter.installSegment5 (Compiler::Ai::opcodeSetHello, new OpSetAiSetting(0)); + interpreter.installSegment5 (Compiler::Ai::opcodeSetHelloExplicit, new OpSetAiSetting(0)); + interpreter.installSegment5 (Compiler::Ai::opcodeSetFight, new OpSetAiSetting(1)); + interpreter.installSegment5 (Compiler::Ai::opcodeSetFightExplicit, new OpSetAiSetting(1)); + interpreter.installSegment5 (Compiler::Ai::opcodeSetFlee, new OpSetAiSetting(2)); + interpreter.installSegment5 (Compiler::Ai::opcodeSetFleeExplicit, new OpSetAiSetting(2)); + interpreter.installSegment5 (Compiler::Ai::opcodeSetAlarm, new OpSetAiSetting(3)); + interpreter.installSegment5 (Compiler::Ai::opcodeSetAlarmExplicit, new OpSetAiSetting(3)); - interpreter.installSegment5 (opcodeModHello, new OpModAiSetting(0)); - interpreter.installSegment5 (opcodeModHelloExplicit, new OpModAiSetting(0)); - interpreter.installSegment5 (opcodeModFight, new OpModAiSetting(1)); - interpreter.installSegment5 (opcodeModFightExplicit, new OpModAiSetting(1)); - interpreter.installSegment5 (opcodeModFlee, new OpModAiSetting(2)); - interpreter.installSegment5 (opcodeModFleeExplicit, new OpModAiSetting(2)); - interpreter.installSegment5 (opcodeModAlarm, new OpModAiSetting(3)); - interpreter.installSegment5 (opcodeModAlarmExplicit, new OpModAiSetting(3)); + interpreter.installSegment5 (Compiler::Ai::opcodeModHello, new OpModAiSetting(0)); + interpreter.installSegment5 (Compiler::Ai::opcodeModHelloExplicit, new OpModAiSetting(0)); + interpreter.installSegment5 (Compiler::Ai::opcodeModFight, new OpModAiSetting(1)); + interpreter.installSegment5 (Compiler::Ai::opcodeModFightExplicit, new OpModAiSetting(1)); + interpreter.installSegment5 (Compiler::Ai::opcodeModFlee, new OpModAiSetting(2)); + interpreter.installSegment5 (Compiler::Ai::opcodeModFleeExplicit, new OpModAiSetting(2)); + interpreter.installSegment5 (Compiler::Ai::opcodeModAlarm, new OpModAiSetting(3)); + interpreter.installSegment5 (Compiler::Ai::opcodeModAlarmExplicit, new OpModAiSetting(3)); - interpreter.installSegment5 (opcodeGetHello, new OpGetAiSetting(0)); - interpreter.installSegment5 (opcodeGetHelloExplicit, new OpGetAiSetting(0)); - interpreter.installSegment5 (opcodeGetFight, new OpGetAiSetting(1)); - interpreter.installSegment5 (opcodeGetFightExplicit, new OpGetAiSetting(1)); - interpreter.installSegment5 (opcodeGetFlee, new OpGetAiSetting(2)); - interpreter.installSegment5 (opcodeGetFleeExplicit, new OpGetAiSetting(2)); - interpreter.installSegment5 (opcodeGetAlarm, new OpGetAiSetting(3)); - interpreter.installSegment5 (opcodeGetAlarmExplicit, new OpGetAiSetting(3)); + interpreter.installSegment5 (Compiler::Ai::opcodeGetHello, new OpGetAiSetting(0)); + interpreter.installSegment5 (Compiler::Ai::opcodeGetHelloExplicit, new OpGetAiSetting(0)); + interpreter.installSegment5 (Compiler::Ai::opcodeGetFight, new OpGetAiSetting(1)); + interpreter.installSegment5 (Compiler::Ai::opcodeGetFightExplicit, new OpGetAiSetting(1)); + interpreter.installSegment5 (Compiler::Ai::opcodeGetFlee, new OpGetAiSetting(2)); + interpreter.installSegment5 (Compiler::Ai::opcodeGetFleeExplicit, new OpGetAiSetting(2)); + interpreter.installSegment5 (Compiler::Ai::opcodeGetAlarm, new OpGetAiSetting(3)); + interpreter.installSegment5 (Compiler::Ai::opcodeGetAlarmExplicit, new OpGetAiSetting(3)); } } } diff --git a/apps/openmw/mwscript/aiextensions.hpp b/apps/openmw/mwscript/aiextensions.hpp index 547341476e..e9e36113cf 100644 --- a/apps/openmw/mwscript/aiextensions.hpp +++ b/apps/openmw/mwscript/aiextensions.hpp @@ -16,8 +16,6 @@ namespace MWScript /// \brief AI-related script functionality namespace Ai { - void registerExtensions (Compiler::Extensions& extensions); - void installOpcodes (Interpreter::Interpreter& interpreter); } } diff --git a/apps/openmw/mwscript/animationextensions.cpp b/apps/openmw/mwscript/animationextensions.cpp index fc52e5e167..52de8e0421 100644 --- a/apps/openmw/mwscript/animationextensions.cpp +++ b/apps/openmw/mwscript/animationextensions.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -90,29 +91,16 @@ namespace MWScript MWBase::Environment::get().getMechanicsManager()->playAnimationGroup (ptr, group, mode, loops); } }; - - const int opcodeSkipAnim = 0x2000138; - const int opcodeSkipAnimExplicit = 0x2000139; - const int opcodePlayAnim = 0x20006; - const int opcodePlayAnimExplicit = 0x20007; - const int opcodeLoopAnim = 0x20008; - const int opcodeLoopAnimExplicit = 0x20009; - - void registerExtensions (Compiler::Extensions& extensions) - { - extensions.registerInstruction ("skipanim", "", opcodeSkipAnim, opcodeSkipAnimExplicit); - extensions.registerInstruction ("playgroup", "c/l", opcodePlayAnim, opcodePlayAnimExplicit); - extensions.registerInstruction ("loopgroup", "cl/l", opcodeLoopAnim, opcodeLoopAnimExplicit); - } + void installOpcodes (Interpreter::Interpreter& interpreter) { - interpreter.installSegment5 (opcodeSkipAnim, new OpSkipAnim); - interpreter.installSegment5 (opcodeSkipAnimExplicit, new OpSkipAnim); - interpreter.installSegment3 (opcodePlayAnim, new OpPlayAnim); - interpreter.installSegment3 (opcodePlayAnimExplicit, new OpPlayAnim); - interpreter.installSegment3 (opcodeLoopAnim, new OpLoopAnim); - interpreter.installSegment3 (opcodeLoopAnimExplicit, new OpLoopAnim); + interpreter.installSegment5 (Compiler::Animation::opcodeSkipAnim, new OpSkipAnim); + interpreter.installSegment5 (Compiler::Animation::opcodeSkipAnimExplicit, new OpSkipAnim); + interpreter.installSegment3 (Compiler::Animation::opcodePlayAnim, new OpPlayAnim); + interpreter.installSegment3 (Compiler::Animation::opcodePlayAnimExplicit, new OpPlayAnim); + interpreter.installSegment3 (Compiler::Animation::opcodeLoopAnim, new OpLoopAnim); + interpreter.installSegment3 (Compiler::Animation::opcodeLoopAnimExplicit, new OpLoopAnim); } } } diff --git a/apps/openmw/mwscript/cellextensions.cpp b/apps/openmw/mwscript/cellextensions.cpp index d2e11c19f7..316f912dad 100644 --- a/apps/openmw/mwscript/cellextensions.cpp +++ b/apps/openmw/mwscript/cellextensions.cpp @@ -4,6 +4,7 @@ #include "../mwworld/esmstore.hpp" #include +#include #include #include @@ -165,39 +166,17 @@ namespace MWScript } }; - const int opcodeCellChanged = 0x2000000; - const int opcodeCOC = 0x2000026; - const int opcodeCOE = 0x200008e; - const int opcodeGetInterior = 0x2000131; - const int opcodeGetPCCell = 0x2000136; - const int opcodeGetWaterLevel = 0x2000141; - const int opcodeSetWaterLevel = 0x2000142; - const int opcodeModWaterLevel = 0x2000143; - - void registerExtensions (Compiler::Extensions& extensions) - { - extensions.registerFunction ("cellchanged", 'l', "", opcodeCellChanged); - extensions.registerInstruction ("coc", "S", opcodeCOC); - extensions.registerInstruction ("centeroncell", "S", opcodeCOC); - extensions.registerInstruction ("coe", "ll", opcodeCOE); - extensions.registerInstruction ("centeronexterior", "ll", opcodeCOE); - extensions.registerInstruction ("setwaterlevel", "f", opcodeSetWaterLevel); - extensions.registerInstruction ("modwaterlevel", "f", opcodeModWaterLevel); - extensions.registerFunction ("getinterior", 'l', "", opcodeGetInterior); - extensions.registerFunction ("getpccell", 'l', "c", opcodeGetPCCell); - extensions.registerFunction ("getwaterlevel", 'f', "", opcodeGetWaterLevel); - } void installOpcodes (Interpreter::Interpreter& interpreter) { - interpreter.installSegment5 (opcodeCellChanged, new OpCellChanged); - interpreter.installSegment5 (opcodeCOC, new OpCOC); - interpreter.installSegment5 (opcodeCOE, new OpCOE); - interpreter.installSegment5 (opcodeGetInterior, new OpGetInterior); - interpreter.installSegment5 (opcodeGetPCCell, new OpGetPCCell); - interpreter.installSegment5 (opcodeGetWaterLevel, new OpGetWaterLevel); - interpreter.installSegment5 (opcodeSetWaterLevel, new OpSetWaterLevel); - interpreter.installSegment5 (opcodeModWaterLevel, new OpModWaterLevel); + interpreter.installSegment5 (Compiler::Cell::opcodeCellChanged, new OpCellChanged); + interpreter.installSegment5 (Compiler::Cell::opcodeCOC, new OpCOC); + interpreter.installSegment5 (Compiler::Cell::opcodeCOE, new OpCOE); + interpreter.installSegment5 (Compiler::Cell::opcodeGetInterior, new OpGetInterior); + interpreter.installSegment5 (Compiler::Cell::opcodeGetPCCell, new OpGetPCCell); + interpreter.installSegment5 (Compiler::Cell::opcodeGetWaterLevel, new OpGetWaterLevel); + interpreter.installSegment5 (Compiler::Cell::opcodeSetWaterLevel, new OpSetWaterLevel); + interpreter.installSegment5 (Compiler::Cell::opcodeModWaterLevel, new OpModWaterLevel); } } } diff --git a/apps/openmw/mwscript/cellextensions.hpp b/apps/openmw/mwscript/cellextensions.hpp index 4aef25d1ae..0891cb9dc8 100644 --- a/apps/openmw/mwscript/cellextensions.hpp +++ b/apps/openmw/mwscript/cellextensions.hpp @@ -15,9 +15,7 @@ namespace MWScript { /// \brief cell-related script functionality namespace Cell - { - void registerExtensions (Compiler::Extensions& extensions); - + { void installOpcodes (Interpreter::Interpreter& interpreter); } } diff --git a/apps/openmw/mwscript/consoleextensions.cpp b/apps/openmw/mwscript/consoleextensions.cpp index 00b4f74e54..30956d429f 100644 --- a/apps/openmw/mwscript/consoleextensions.cpp +++ b/apps/openmw/mwscript/consoleextensions.cpp @@ -2,6 +2,7 @@ #include "consoleextensions.hpp" #include +#include #include #include @@ -11,11 +12,6 @@ namespace MWScript { namespace Console { - void registerExtensions (Compiler::Extensions& extensions) - { - - } - void installOpcodes (Interpreter::Interpreter& interpreter) { diff --git a/apps/openmw/mwscript/consoleextensions.hpp b/apps/openmw/mwscript/consoleextensions.hpp index b10bf06a8d..5571a54694 100644 --- a/apps/openmw/mwscript/consoleextensions.hpp +++ b/apps/openmw/mwscript/consoleextensions.hpp @@ -16,8 +16,6 @@ namespace MWScript /// \brief Script functionality limited to the console namespace Console { - void registerExtensions (Compiler::Extensions& extensions); - void installOpcodes (Interpreter::Interpreter& interpreter); } } diff --git a/apps/openmw/mwscript/containerextensions.cpp b/apps/openmw/mwscript/containerextensions.cpp index 3a46f62d6b..3a69fa3a7f 100644 --- a/apps/openmw/mwscript/containerextensions.cpp +++ b/apps/openmw/mwscript/containerextensions.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -360,55 +361,25 @@ namespace MWScript } }; - const int opcodeAddItem = 0x2000076; - const int opcodeAddItemExplicit = 0x2000077; - const int opcodeGetItemCount = 0x2000078; - const int opcodeGetItemCountExplicit = 0x2000079; - const int opcodeRemoveItem = 0x200007a; - const int opcodeRemoveItemExplicit = 0x200007b; - const int opcodeEquip = 0x20001b3; - const int opcodeEquipExplicit = 0x20001b4; - const int opcodeGetArmorType = 0x20001d1; - const int opcodeGetArmorTypeExplicit = 0x20001d2; - const int opcodeHasItemEquipped = 0x20001d5; - const int opcodeHasItemEquippedExplicit = 0x20001d6; - const int opcodeHasSoulGem = 0x20001de; - const int opcodeHasSoulGemExplicit = 0x20001df; - const int opcodeGetWeaponType = 0x20001e0; - const int opcodeGetWeaponTypeExplicit = 0x20001e1; - - void registerExtensions (Compiler::Extensions& extensions) - { - extensions.registerInstruction ("additem", "cl", opcodeAddItem, opcodeAddItemExplicit); - extensions.registerFunction ("getitemcount", 'l', "c", opcodeGetItemCount, - opcodeGetItemCountExplicit); - extensions.registerInstruction ("removeitem", "cl", opcodeRemoveItem, - opcodeRemoveItemExplicit); - extensions.registerInstruction ("equip", "c", opcodeEquip, opcodeEquipExplicit); - extensions.registerFunction ("getarmortype", 'l', "l", opcodeGetArmorType, opcodeGetArmorTypeExplicit); - extensions.registerFunction ("hasitemequipped", 'l', "c", opcodeHasItemEquipped, opcodeHasItemEquippedExplicit); - extensions.registerFunction ("hassoulgem", 'l', "c", opcodeHasSoulGem, opcodeHasSoulGemExplicit); - extensions.registerFunction ("getweapontype", 'l', "", opcodeGetWeaponType, opcodeGetWeaponTypeExplicit); - } void installOpcodes (Interpreter::Interpreter& interpreter) { - interpreter.installSegment5 (opcodeAddItem, new OpAddItem); - interpreter.installSegment5 (opcodeAddItemExplicit, new OpAddItem); - interpreter.installSegment5 (opcodeGetItemCount, new OpGetItemCount); - interpreter.installSegment5 (opcodeGetItemCountExplicit, new OpGetItemCount); - interpreter.installSegment5 (opcodeRemoveItem, new OpRemoveItem); - interpreter.installSegment5 (opcodeRemoveItemExplicit, new OpRemoveItem); - interpreter.installSegment5 (opcodeEquip, new OpEquip); - interpreter.installSegment5 (opcodeEquipExplicit, new OpEquip); - interpreter.installSegment5 (opcodeGetArmorType, new OpGetArmorType); - interpreter.installSegment5 (opcodeGetArmorTypeExplicit, new OpGetArmorType); - interpreter.installSegment5 (opcodeHasItemEquipped, new OpHasItemEquipped); - interpreter.installSegment5 (opcodeHasItemEquippedExplicit, new OpHasItemEquipped); - interpreter.installSegment5 (opcodeHasSoulGem, new OpHasSoulGem); - interpreter.installSegment5 (opcodeHasSoulGemExplicit, new OpHasSoulGem); - interpreter.installSegment5 (opcodeGetWeaponType, new OpGetWeaponType); - interpreter.installSegment5 (opcodeGetWeaponTypeExplicit, new OpGetWeaponType); + interpreter.installSegment5 (Compiler::Container::opcodeAddItem, new OpAddItem); + interpreter.installSegment5 (Compiler::Container::opcodeAddItemExplicit, new OpAddItem); + interpreter.installSegment5 (Compiler::Container::opcodeGetItemCount, new OpGetItemCount); + interpreter.installSegment5 (Compiler::Container::opcodeGetItemCountExplicit, new OpGetItemCount); + interpreter.installSegment5 (Compiler::Container::opcodeRemoveItem, new OpRemoveItem); + interpreter.installSegment5 (Compiler::Container::opcodeRemoveItemExplicit, new OpRemoveItem); + interpreter.installSegment5 (Compiler::Container::opcodeEquip, new OpEquip); + interpreter.installSegment5 (Compiler::Container::opcodeEquipExplicit, new OpEquip); + interpreter.installSegment5 (Compiler::Container::opcodeGetArmorType, new OpGetArmorType); + interpreter.installSegment5 (Compiler::Container::opcodeGetArmorTypeExplicit, new OpGetArmorType); + interpreter.installSegment5 (Compiler::Container::opcodeHasItemEquipped, new OpHasItemEquipped); + interpreter.installSegment5 (Compiler::Container::opcodeHasItemEquippedExplicit, new OpHasItemEquipped); + interpreter.installSegment5 (Compiler::Container::opcodeHasSoulGem, new OpHasSoulGem); + interpreter.installSegment5 (Compiler::Container::opcodeHasSoulGemExplicit, new OpHasSoulGem); + interpreter.installSegment5 (Compiler::Container::opcodeGetWeaponType, new OpGetWeaponType); + interpreter.installSegment5 (Compiler::Container::opcodeGetWeaponTypeExplicit, new OpGetWeaponType); } } } diff --git a/apps/openmw/mwscript/containerextensions.hpp b/apps/openmw/mwscript/containerextensions.hpp index 92c52e5c18..d5be8fb2a6 100644 --- a/apps/openmw/mwscript/containerextensions.hpp +++ b/apps/openmw/mwscript/containerextensions.hpp @@ -16,8 +16,6 @@ namespace MWScript /// \brief Container-related script functionality (chests, NPCs, creatures) namespace Container { - void registerExtensions (Compiler::Extensions& extensions); - void installOpcodes (Interpreter::Interpreter& interpreter); } } diff --git a/apps/openmw/mwscript/controlextensions.cpp b/apps/openmw/mwscript/controlextensions.cpp index ac53b8ee25..e46302b183 100644 --- a/apps/openmw/mwscript/controlextensions.cpp +++ b/apps/openmw/mwscript/controlextensions.cpp @@ -2,6 +2,7 @@ #include "controlextensions.hpp" #include +#include #include #include @@ -159,97 +160,41 @@ namespace MWScript } }; - const int numberOfControls = 7; - - const int opcodeEnable = 0x200007e; - const int opcodeDisable = 0x2000085; - const int opcodeToggleCollision = 0x2000130; - const int opcodeClearForceRun = 0x2000154; - const int opcodeClearForceRunExplicit = 0x2000155; - const int opcodeForceRun = 0x2000156; - const int opcodeForceRunExplicit = 0x2000157; - const int opcodeClearForceSneak = 0x2000158; - const int opcodeClearForceSneakExplicit = 0x2000159; - const int opcodeForceSneak = 0x200015a; - const int opcodeForceSneakExplicit = 0x200015b; - const int opcodeGetDisabled = 0x2000175; - const int opcodeGetPcRunning = 0x20001c9; - const int opcodeGetPcSneaking = 0x20001ca; - const int opcodeGetForceRun = 0x20001cb; - const int opcodeGetForceSneak = 0x20001cc; - const int opcodeGetForceRunExplicit = 0x20001cd; - const int opcodeGetForceSneakExplicit = 0x20001ce; - - const char *controls[numberOfControls] = - { - "playercontrols", "playerfighting", "playerjumping", "playerlooking", "playermagic", - "playerviewswitch", "vanitymode" - }; - - void registerExtensions (Compiler::Extensions& extensions) - { - std::string enable ("enable"); - std::string disable ("disable"); - - for (int i=0; i (MWMechanics::NpcStats::Flag_ForceRun)); - interpreter.installSegment5 (opcodeForceRun, + interpreter.installSegment5 (Compiler::Control::opcodeForceRun, new OpSetMovementFlag (MWMechanics::NpcStats::Flag_ForceRun)); - interpreter.installSegment5 (opcodeClearForceSneak, + interpreter.installSegment5 (Compiler::Control::opcodeClearForceSneak, new OpClearMovementFlag (MWMechanics::NpcStats::Flag_ForceSneak)); - interpreter.installSegment5 (opcodeForceSneak, + interpreter.installSegment5 (Compiler::Control::opcodeForceSneak, new OpSetMovementFlag (MWMechanics::NpcStats::Flag_ForceSneak)); - interpreter.installSegment5 (opcodeClearForceRunExplicit, + interpreter.installSegment5 (Compiler::Control::opcodeClearForceRunExplicit, new OpClearMovementFlag (MWMechanics::NpcStats::Flag_ForceRun)); - interpreter.installSegment5 (opcodeForceRunExplicit, + interpreter.installSegment5 (Compiler::Control::opcodeForceRunExplicit, new OpSetMovementFlag (MWMechanics::NpcStats::Flag_ForceRun)); - interpreter.installSegment5 (opcodeClearForceSneakExplicit, + interpreter.installSegment5 (Compiler::Control::opcodeClearForceSneakExplicit, new OpClearMovementFlag (MWMechanics::NpcStats::Flag_ForceSneak)); - interpreter.installSegment5 (opcodeForceSneakExplicit, + interpreter.installSegment5 (Compiler::Control::opcodeForceSneakExplicit, new OpSetMovementFlag (MWMechanics::NpcStats::Flag_ForceSneak)); - interpreter.installSegment5 (opcodeGetPcRunning, new OpGetPcRunning); - interpreter.installSegment5 (opcodeGetPcSneaking, new OpGetPcSneaking); - interpreter.installSegment5 (opcodeGetForceRun, new OpGetForceRun); - interpreter.installSegment5 (opcodeGetForceRunExplicit, new OpGetForceRun); - interpreter.installSegment5 (opcodeGetForceSneak, new OpGetForceSneak); - interpreter.installSegment5 (opcodeGetForceSneakExplicit, new OpGetForceSneak); + interpreter.installSegment5 (Compiler::Control::opcodeGetPcRunning, new OpGetPcRunning); + interpreter.installSegment5 (Compiler::Control::opcodeGetPcSneaking, new OpGetPcSneaking); + interpreter.installSegment5 (Compiler::Control::opcodeGetForceRun, new OpGetForceRun); + interpreter.installSegment5 (Compiler::Control::opcodeGetForceRunExplicit, new OpGetForceRun); + interpreter.installSegment5 (Compiler::Control::opcodeGetForceSneak, new OpGetForceSneak); + interpreter.installSegment5 (Compiler::Control::opcodeGetForceSneakExplicit, new OpGetForceSneak); } } } diff --git a/apps/openmw/mwscript/controlextensions.hpp b/apps/openmw/mwscript/controlextensions.hpp index 8e6111705f..b9c6654fea 100644 --- a/apps/openmw/mwscript/controlextensions.hpp +++ b/apps/openmw/mwscript/controlextensions.hpp @@ -16,8 +16,6 @@ namespace MWScript /// \brief player controls-related script functionality namespace Control { - void registerExtensions (Compiler::Extensions& extensions); - void installOpcodes (Interpreter::Interpreter& interpreter); } } diff --git a/apps/openmw/mwscript/dialogueextensions.cpp b/apps/openmw/mwscript/dialogueextensions.cpp index f636232751..5e797ee589 100644 --- a/apps/openmw/mwscript/dialogueextensions.cpp +++ b/apps/openmw/mwscript/dialogueextensions.cpp @@ -2,6 +2,7 @@ #include "dialogueextensions.hpp" #include +#include #include #include @@ -188,62 +189,25 @@ namespace MWScript } }; - const int opcodeJournal = 0x2000133; - const int opcodeSetJournalIndex = 0x2000134; - const int opcodeGetJournalIndex = 0x2000135; - const int opcodeAddTopic = 0x200013a; - const int opcodeChoice = 0x2000a; - const int opcodeForceGreeting = 0x200014f; - const int opcodeForceGreetingExplicit = 0x2000150; - const int opcodeGoodbye = 0x2000152; - const int opcodeSetReputation = 0x20001ad; - const int opcodeModReputation = 0x20001ae; - const int opcodeSetReputationExplicit = 0x20001af; - const int opcodeModReputationExplicit = 0x20001b0; - const int opcodeGetReputation = 0x20001b1; - const int opcodeGetReputationExplicit = 0x20001b2; - const int opcodeSameFaction = 0x20001b5; - const int opcodeSameFactionExplicit = 0x20001b6; - - void registerExtensions (Compiler::Extensions& extensions) - { - extensions.registerInstruction ("journal", "cl", opcodeJournal); - extensions.registerInstruction ("setjournalindex", "cl", opcodeSetJournalIndex); - extensions.registerFunction ("getjournalindex", 'l', "c", opcodeGetJournalIndex); - extensions.registerInstruction ("addtopic", "S" , opcodeAddTopic); - extensions.registerInstruction ("choice", "/SlSlSlSlSlSlSlSlSlSlSlSlSlSlSlSl", opcodeChoice); - extensions.registerInstruction("forcegreeting","",opcodeForceGreeting); - extensions.registerInstruction("forcegreeting","",opcodeForceGreeting, - opcodeForceGreetingExplicit); - extensions.registerInstruction("goodbye", "", opcodeGoodbye); - extensions.registerInstruction("setreputation", "l", opcodeSetReputation, - opcodeSetReputationExplicit); - extensions.registerInstruction("modreputation", "l", opcodeModReputation, - opcodeModReputationExplicit); - extensions.registerFunction("getreputation", 'l', "", opcodeGetReputation, - opcodeGetReputationExplicit); - extensions.registerFunction("samefaction", 'l', "", opcodeSameFaction, - opcodeSameFactionExplicit); - } void installOpcodes (Interpreter::Interpreter& interpreter) { - interpreter.installSegment5 (opcodeJournal, new OpJournal); - interpreter.installSegment5 (opcodeSetJournalIndex, new OpSetJournalIndex); - interpreter.installSegment5 (opcodeGetJournalIndex, new OpGetJournalIndex); - interpreter.installSegment5 (opcodeAddTopic, new OpAddTopic); - interpreter.installSegment3 (opcodeChoice,new OpChoice); - interpreter.installSegment5 (opcodeForceGreeting, new OpForceGreeting); - interpreter.installSegment5 (opcodeForceGreetingExplicit, new OpForceGreeting); - interpreter.installSegment5 (opcodeGoodbye, new OpGoodbye); - interpreter.installSegment5 (opcodeGetReputation, new OpGetReputation); - interpreter.installSegment5 (opcodeSetReputation, new OpSetReputation); - interpreter.installSegment5 (opcodeModReputation, new OpModReputation); - interpreter.installSegment5 (opcodeSetReputationExplicit, new OpSetReputation); - interpreter.installSegment5 (opcodeModReputationExplicit, new OpModReputation); - interpreter.installSegment5 (opcodeGetReputationExplicit, new OpGetReputation); - interpreter.installSegment5 (opcodeSameFaction, new OpSameFaction); - interpreter.installSegment5 (opcodeSameFactionExplicit, new OpSameFaction); + interpreter.installSegment5 (Compiler::Dialogue::opcodeJournal, new OpJournal); + interpreter.installSegment5 (Compiler::Dialogue::opcodeSetJournalIndex, new OpSetJournalIndex); + interpreter.installSegment5 (Compiler::Dialogue::opcodeGetJournalIndex, new OpGetJournalIndex); + interpreter.installSegment5 (Compiler::Dialogue::opcodeAddTopic, new OpAddTopic); + interpreter.installSegment3 (Compiler::Dialogue::opcodeChoice,new OpChoice); + interpreter.installSegment5 (Compiler::Dialogue::opcodeForceGreeting, new OpForceGreeting); + interpreter.installSegment5 (Compiler::Dialogue::opcodeForceGreetingExplicit, new OpForceGreeting); + interpreter.installSegment5 (Compiler::Dialogue::opcodeGoodbye, new OpGoodbye); + interpreter.installSegment5 (Compiler::Dialogue::opcodeGetReputation, new OpGetReputation); + interpreter.installSegment5 (Compiler::Dialogue::opcodeSetReputation, new OpSetReputation); + interpreter.installSegment5 (Compiler::Dialogue::opcodeModReputation, new OpModReputation); + interpreter.installSegment5 (Compiler::Dialogue::opcodeSetReputationExplicit, new OpSetReputation); + interpreter.installSegment5 (Compiler::Dialogue::opcodeModReputationExplicit, new OpModReputation); + interpreter.installSegment5 (Compiler::Dialogue::opcodeGetReputationExplicit, new OpGetReputation); + interpreter.installSegment5 (Compiler::Dialogue::opcodeSameFaction, new OpSameFaction); + interpreter.installSegment5 (Compiler::Dialogue::opcodeSameFactionExplicit, new OpSameFaction); } } diff --git a/apps/openmw/mwscript/dialogueextensions.hpp b/apps/openmw/mwscript/dialogueextensions.hpp index ece7d62ce8..7b03154dfb 100644 --- a/apps/openmw/mwscript/dialogueextensions.hpp +++ b/apps/openmw/mwscript/dialogueextensions.hpp @@ -16,8 +16,6 @@ namespace MWScript /// \brief Dialogue/Journal-related script functionality namespace Dialogue { - void registerExtensions (Compiler::Extensions& extensions); - void installOpcodes (Interpreter::Interpreter& interpreter); } } diff --git a/apps/openmw/mwscript/extensions.cpp b/apps/openmw/mwscript/extensions.cpp index 1b15608202..2170ba4fb3 100644 --- a/apps/openmw/mwscript/extensions.cpp +++ b/apps/openmw/mwscript/extensions.cpp @@ -21,28 +21,6 @@ namespace MWScript { - void registerExtensions (Compiler::Extensions& extensions, bool consoleOnly) - { - Cell::registerExtensions (extensions); - Misc::registerExtensions (extensions); - Gui::registerExtensions (extensions); - Sound::registerExtensions (extensions); - Sky::registerExtensions (extensions); - Stats::registerExtensions (extensions); - Container::registerExtensions (extensions); - Ai::registerExtensions (extensions); - Control::registerExtensions (extensions); - Dialogue::registerExtensions (extensions); - Animation::registerExtensions (extensions); - Transformation::registerExtensions (extensions); - - if (consoleOnly) - { - Console::registerExtensions (extensions); - User::registerExtensions (extensions); - } - } - void installOpcodes (Interpreter::Interpreter& interpreter, bool consoleOnly) { Interpreter::installOpcodes (interpreter); diff --git a/apps/openmw/mwscript/extensions.hpp b/apps/openmw/mwscript/extensions.hpp index cb1aaf9db2..67f6de5c58 100644 --- a/apps/openmw/mwscript/extensions.hpp +++ b/apps/openmw/mwscript/extensions.hpp @@ -13,9 +13,6 @@ namespace Interpreter namespace MWScript { - void registerExtensions (Compiler::Extensions& extensions, bool consoleOnly = false); - ///< \param consoleOnly include console only extensions - void installOpcodes (Interpreter::Interpreter& interpreter, bool consoleOnly = false); ///< \param consoleOnly include console only opcodes } diff --git a/apps/openmw/mwscript/guiextensions.cpp b/apps/openmw/mwscript/guiextensions.cpp index bfe69c79ea..4bb10dad52 100644 --- a/apps/openmw/mwscript/guiextensions.cpp +++ b/apps/openmw/mwscript/guiextensions.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -150,90 +151,42 @@ namespace MWScript }; - const int opcodeEnableBirthMenu = 0x200000e; - const int opcodeEnableClassMenu = 0x200000f; - const int opcodeEnableNameMenu = 0x2000010; - const int opcodeEnableRaceMenu = 0x2000011; - const int opcodeEnableStatsReviewMenu = 0x2000012; - const int opcodeEnableInventoryMenu = 0x2000013; - const int opcodeEnableMagicMenu = 0x2000014; - const int opcodeEnableMapMenu = 0x2000015; - const int opcodeEnableStatsMenu = 0x2000016; - const int opcodeEnableRest = 0x2000017; - const int opcodeShowRestMenu = 0x2000018; - const int opcodeGetButtonPressed = 0x2000137; - const int opcodeToggleFogOfWar = 0x2000145; - const int opcodeToggleFullHelp = 0x2000151; - const int opcodeShowMap = 0x20001a0; - const int opcodeFillMap = 0x20001a1; - - void registerExtensions (Compiler::Extensions& extensions) - { - extensions.registerInstruction ("enablebirthmenu", "", opcodeEnableBirthMenu); - extensions.registerInstruction ("enableclassmenu", "", opcodeEnableClassMenu); - extensions.registerInstruction ("enablenamemenu", "", opcodeEnableNameMenu); - extensions.registerInstruction ("enableracemenu", "", opcodeEnableRaceMenu); - extensions.registerInstruction ("enablestatreviewmenu", "", -opcodeEnableStatsReviewMenu); - - extensions.registerInstruction ("enableinventorymenu", "", opcodeEnableInventoryMenu); - extensions.registerInstruction ("enablemagicmenu", "", opcodeEnableMagicMenu); - extensions.registerInstruction ("enablemapmenu", "", opcodeEnableMapMenu); - extensions.registerInstruction ("enablestatsmenu", "", opcodeEnableStatsMenu); - - extensions.registerInstruction ("enablerest", "", opcodeEnableRest); - extensions.registerInstruction ("enablelevelupmenu", "", opcodeEnableRest); - - extensions.registerInstruction ("showrestmenu", "", opcodeShowRestMenu); - - extensions.registerFunction ("getbuttonpressed", 'l', "", opcodeGetButtonPressed); - - extensions.registerInstruction ("togglefogofwar", "", opcodeToggleFogOfWar); - extensions.registerInstruction ("tfow", "", opcodeToggleFogOfWar); - - extensions.registerInstruction ("togglefullhelp", "", opcodeToggleFullHelp); - extensions.registerInstruction ("tfh", "", opcodeToggleFullHelp); - - extensions.registerInstruction ("showmap", "S", opcodeShowMap); - extensions.registerInstruction ("fillmap", "", opcodeFillMap); - } - void installOpcodes (Interpreter::Interpreter& interpreter) { - interpreter.installSegment5 (opcodeEnableBirthMenu, + interpreter.installSegment5 (Compiler::Gui::opcodeEnableBirthMenu, new OpShowDialogue (MWGui::GM_Birth)); - interpreter.installSegment5 (opcodeEnableClassMenu, + interpreter.installSegment5 (Compiler::Gui::opcodeEnableClassMenu, new OpShowDialogue (MWGui::GM_Class)); - interpreter.installSegment5 (opcodeEnableNameMenu, + interpreter.installSegment5 (Compiler::Gui::opcodeEnableNameMenu, new OpShowDialogue (MWGui::GM_Name)); - interpreter.installSegment5 (opcodeEnableRaceMenu, + interpreter.installSegment5 (Compiler::Gui::opcodeEnableRaceMenu, new OpShowDialogue (MWGui::GM_Race)); - interpreter.installSegment5 (opcodeEnableStatsReviewMenu, + interpreter.installSegment5 (Compiler::Gui::opcodeEnableStatsReviewMenu, new OpShowDialogue (MWGui::GM_Review)); - interpreter.installSegment5 (opcodeEnableInventoryMenu, + interpreter.installSegment5 (Compiler::Gui::opcodeEnableInventoryMenu, new OpEnableWindow (MWGui::GW_Inventory)); - interpreter.installSegment5 (opcodeEnableMagicMenu, + interpreter.installSegment5 (Compiler::Gui::opcodeEnableMagicMenu, new OpEnableWindow (MWGui::GW_Magic)); - interpreter.installSegment5 (opcodeEnableMapMenu, + interpreter.installSegment5 (Compiler::Gui::opcodeEnableMapMenu, new OpEnableWindow (MWGui::GW_Map)); - interpreter.installSegment5 (opcodeEnableStatsMenu, + interpreter.installSegment5 (Compiler::Gui::opcodeEnableStatsMenu, new OpEnableWindow (MWGui::GW_Stats)); - interpreter.installSegment5 (opcodeEnableRest, + interpreter.installSegment5 (Compiler::Gui::opcodeEnableRest, new OpEnableRest ()); - interpreter.installSegment5 (opcodeShowRestMenu, + interpreter.installSegment5 (Compiler::Gui::opcodeShowRestMenu, new OpShowDialogue (MWGui::GM_RestBed)); - interpreter.installSegment5 (opcodeGetButtonPressed, new OpGetButtonPressed); + interpreter.installSegment5 (Compiler::Gui::opcodeGetButtonPressed, new OpGetButtonPressed); - interpreter.installSegment5 (opcodeToggleFogOfWar, new OpToggleFogOfWar); + interpreter.installSegment5 (Compiler::Gui::opcodeToggleFogOfWar, new OpToggleFogOfWar); - interpreter.installSegment5 (opcodeToggleFullHelp, new OpToggleFullHelp); + interpreter.installSegment5 (Compiler::Gui::opcodeToggleFullHelp, new OpToggleFullHelp); - interpreter.installSegment5 (opcodeShowMap, new OpShowMap); - interpreter.installSegment5 (opcodeFillMap, new OpFillMap); + interpreter.installSegment5 (Compiler::Gui::opcodeShowMap, new OpShowMap); + interpreter.installSegment5 (Compiler::Gui::opcodeFillMap, new OpFillMap); } } } diff --git a/apps/openmw/mwscript/guiextensions.hpp b/apps/openmw/mwscript/guiextensions.hpp index 83447e8fb7..ec775a51c9 100644 --- a/apps/openmw/mwscript/guiextensions.hpp +++ b/apps/openmw/mwscript/guiextensions.hpp @@ -15,9 +15,7 @@ namespace MWScript { /// \brief GUI-related script functionality namespace Gui - { - void registerExtensions (Compiler::Extensions& extensions); - + { void installOpcodes (Interpreter::Interpreter& interpreter); } } diff --git a/apps/openmw/mwscript/miscextensions.cpp b/apps/openmw/mwscript/miscextensions.cpp index 6b1adc9387..b9d6654654 100644 --- a/apps/openmw/mwscript/miscextensions.cpp +++ b/apps/openmw/mwscript/miscextensions.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -627,166 +628,63 @@ namespace MWScript world->enableTeleporting(Enable); } }; - - 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; - const int opcodeToggleCollisionDebug = 0x2000132; - const int opcodeToggleCollisionBoxes = 0x20001ac; - const int opcodeToggleWireframe = 0x200013b; - const int opcodeFadeIn = 0x200013c; - const int opcodeFadeOut = 0x200013d; - const int opcodeFadeTo = 0x200013e; - const int opcodeToggleWater = 0x2000144; - const int opcodeTogglePathgrid = 0x2000146; - const int opcodeDontSaveObject = 0x2000153; - const int opcodeToggleVanityMode = 0x2000174; - const int opcodeGetPcSleep = 0x200019f; - const int opcodeWakeUpPc = 0x20001a2; - const int opcodeGetLocked = 0x20001c7; - const int opcodeGetLockedExplicit = 0x20001c8; - const int opcodeGetEffect = 0x20001cf; - const int opcodeGetEffectExplicit = 0x20001d0; - const int opcodeAddSoulGem = 0x20001f3; - const int opcodeAddSoulGemExplicit = 0x20001f4; - const int opcodeRemoveSoulGem = 0x20001f5; - const int opcodeRemoveSoulGemExplicit = 0x20001f6; - const int opcodeDrop = 0x20001f8; - const int opcodeDropExplicit = 0x20001f9; - const int opcodeDropSoulGem = 0x20001fa; - const int opcodeDropSoulGemExplicit = 0x20001fb; - const int opcodeGetAttacked = 0x20001d3; - const int opcodeGetAttackedExplicit = 0x20001d4; - const int opcodeGetWeaponDrawn = 0x20001d7; - const int opcodeGetWeaponDrawnExplicit = 0x20001d8; - const int opcodeGetSpellEffects = 0x20001db; - const int opcodeGetSpellEffectsExplicit = 0x20001dc; - const int opcodeGetCurrentTime = 0x20001dd; - const int opcodeSetDelete = 0x20001e5; - const int opcodeSetDeleteExplicit = 0x20001e6; - const int opcodeGetSquareRoot = 0x20001e7; - const int opcodeFall = 0x200020a; - const int opcodeFallExplicit = 0x200020b; - const int opcodeGetStandingPc = 0x200020c; - const int opcodeGetStandingPcExplicit = 0x200020d; - const int opcodeGetStandingActor = 0x200020e; - const int opcodeGetStandingActorExplicit = 0x200020f; - const int opcodeGetWindSpeed = 0x2000212; - - const int opcodePlayBink = 0x20001f7; - - const int opcodeHitOnMe = 0x2000213; - const int opcodeHitOnMeExplicit = 0x2000214; - - const int opcodeDisableTeleporting = 0x2000215; - const int opcodeEnableTeleporting = 0x2000216; - - 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); - extensions.registerInstruction ("togglecollisionboxes", "", opcodeToggleCollisionBoxes); - extensions.registerInstruction ("togglecollisiongrid", "", opcodeToggleCollisionDebug); - extensions.registerInstruction ("tcb", "", opcodeToggleCollisionBoxes); - extensions.registerInstruction ("tcg", "", opcodeToggleCollisionDebug); - extensions.registerInstruction ("twf", "", opcodeToggleWireframe); - extensions.registerInstruction ("togglewireframe", "", opcodeToggleWireframe); - extensions.registerInstruction ("fadein", "f", opcodeFadeIn); - extensions.registerInstruction ("fadeout", "f", opcodeFadeOut); - extensions.registerInstruction ("fadeto", "ff", opcodeFadeTo); - extensions.registerInstruction ("togglewater", "", opcodeToggleWater); - extensions.registerInstruction ("twa", "", opcodeToggleWater); - extensions.registerInstruction ("togglepathgrid", "", opcodeTogglePathgrid); - extensions.registerInstruction ("tpg", "", opcodeTogglePathgrid); - extensions.registerInstruction ("dontsaveobject", "", opcodeDontSaveObject); - extensions.registerInstruction ("togglevanitymode", "", opcodeToggleVanityMode); - extensions.registerInstruction ("tvm", "", opcodeToggleVanityMode); - extensions.registerFunction ("getpcsleep", 'l', "", opcodeGetPcSleep); - extensions.registerInstruction ("wakeuppc", "", opcodeWakeUpPc); - extensions.registerInstruction ("playbink", "Sl", opcodePlayBink); - extensions.registerFunction ("getlocked", 'l', "", opcodeGetLocked, opcodeGetLockedExplicit); - extensions.registerFunction ("geteffect", 'l', "l", opcodeGetEffect, opcodeGetEffectExplicit); - extensions.registerInstruction ("addsoulgem", "cc", opcodeAddSoulGem, opcodeAddSoulGemExplicit); - extensions.registerInstruction ("removesoulgem", "c", opcodeRemoveSoulGem, opcodeRemoveSoulGemExplicit); - extensions.registerInstruction ("drop", "cl", opcodeDrop, opcodeDropExplicit); - extensions.registerInstruction ("dropsoulgem", "c", opcodeDropSoulGem, opcodeDropSoulGemExplicit); - extensions.registerFunction ("getattacked", 'l', "", opcodeGetAttacked, opcodeGetAttackedExplicit); - extensions.registerFunction ("getweapondrawn", 'l', "", opcodeGetWeaponDrawn, opcodeGetWeaponDrawnExplicit); - extensions.registerFunction ("getspelleffects", 'l', "c", opcodeGetSpellEffects, opcodeGetSpellEffectsExplicit); - extensions.registerFunction ("getcurrenttime", 'f', "", opcodeGetCurrentTime); - extensions.registerInstruction ("setdelete", "l", opcodeSetDelete, opcodeSetDeleteExplicit); - extensions.registerFunction ("getsquareroot", 'f', "f", opcodeGetSquareRoot); - extensions.registerInstruction ("fall", "", opcodeFall, opcodeFallExplicit); - extensions.registerFunction ("getstandingpc", 'l', "", opcodeGetStandingPc, opcodeGetStandingPcExplicit); - extensions.registerFunction ("getstandingactor", 'l', "", opcodeGetStandingActor, opcodeGetStandingActorExplicit); - extensions.registerFunction ("getwindspeed", 'f', "", opcodeGetWindSpeed); - extensions.registerFunction ("hitonme", 'l', "S", opcodeHitOnMe, opcodeHitOnMeExplicit); - extensions.registerInstruction ("disableteleporting", "", opcodeDisableTeleporting); - extensions.registerInstruction ("enableteleporting", "", opcodeEnableTeleporting); - } + void installOpcodes (Interpreter::Interpreter& interpreter) { - interpreter.installSegment5 (opcodeXBox, new OpXBox); - interpreter.installSegment5 (opcodeOnActivate, new OpOnActivate); - interpreter.installSegment5 (opcodeActivate, new OpActivate); - interpreter.installSegment3 (opcodeLock, new OpLock); - interpreter.installSegment3 (opcodeLockExplicit, new OpLock); - interpreter.installSegment5 (opcodeUnlock, new OpUnlock); - interpreter.installSegment5 (opcodeUnlockExplicit, new OpUnlock); - interpreter.installSegment5 (opcodeToggleCollisionDebug, new OpToggleCollisionDebug); - interpreter.installSegment5 (opcodeToggleCollisionBoxes, new OpToggleCollisionBoxes); - interpreter.installSegment5 (opcodeToggleWireframe, new OpToggleWireframe); - interpreter.installSegment5 (opcodeFadeIn, new OpFadeIn); - interpreter.installSegment5 (opcodeFadeOut, new OpFadeOut); - interpreter.installSegment5 (opcodeFadeTo, new OpFadeTo); - interpreter.installSegment5 (opcodeTogglePathgrid, new OpTogglePathgrid); - interpreter.installSegment5 (opcodeToggleWater, new OpToggleWater); - interpreter.installSegment5 (opcodeDontSaveObject, new OpDontSaveObject); - interpreter.installSegment5 (opcodeToggleVanityMode, new OpToggleVanityMode); - interpreter.installSegment5 (opcodeGetPcSleep, new OpGetPcSleep); - interpreter.installSegment5 (opcodeWakeUpPc, new OpWakeUpPc); - interpreter.installSegment5 (opcodePlayBink, new OpPlayBink); - interpreter.installSegment5 (opcodeGetLocked, new OpGetLocked); - interpreter.installSegment5 (opcodeGetLockedExplicit, new OpGetLocked); - interpreter.installSegment5 (opcodeGetEffect, new OpGetEffect); - interpreter.installSegment5 (opcodeGetEffectExplicit, new OpGetEffect); - interpreter.installSegment5 (opcodeAddSoulGem, new OpAddSoulGem); - interpreter.installSegment5 (opcodeAddSoulGemExplicit, new OpAddSoulGem); - interpreter.installSegment5 (opcodeRemoveSoulGem, new OpRemoveSoulGem); - interpreter.installSegment5 (opcodeRemoveSoulGemExplicit, new OpRemoveSoulGem); - interpreter.installSegment5 (opcodeDrop, new OpDrop); - interpreter.installSegment5 (opcodeDropExplicit, new OpDrop); - interpreter.installSegment5 (opcodeDropSoulGem, new OpDropSoulGem); - interpreter.installSegment5 (opcodeDropSoulGemExplicit, new OpDropSoulGem); - interpreter.installSegment5 (opcodeGetAttacked, new OpGetAttacked); - interpreter.installSegment5 (opcodeGetAttackedExplicit, new OpGetAttacked); - interpreter.installSegment5 (opcodeGetWeaponDrawn, new OpGetWeaponDrawn); - interpreter.installSegment5 (opcodeGetWeaponDrawnExplicit, new OpGetWeaponDrawn); - interpreter.installSegment5 (opcodeGetSpellEffects, new OpGetSpellEffects); - interpreter.installSegment5 (opcodeGetSpellEffectsExplicit, new OpGetSpellEffects); - interpreter.installSegment5 (opcodeGetCurrentTime, new OpGetCurrentTime); - interpreter.installSegment5 (opcodeSetDelete, new OpSetDelete); - interpreter.installSegment5 (opcodeSetDeleteExplicit, new OpSetDelete); - interpreter.installSegment5 (opcodeGetSquareRoot, new OpGetSquareRoot); - interpreter.installSegment5 (opcodeFall, new OpFall); - interpreter.installSegment5 (opcodeFallExplicit, new OpFall); - interpreter.installSegment5 (opcodeGetStandingPc, new OpGetStandingPc); - interpreter.installSegment5 (opcodeGetStandingPcExplicit, new OpGetStandingPc); - interpreter.installSegment5 (opcodeGetStandingActor, new OpGetStandingActor); - interpreter.installSegment5 (opcodeGetStandingActorExplicit, new OpGetStandingActor); - interpreter.installSegment5 (opcodeGetWindSpeed, new OpGetWindSpeed); - interpreter.installSegment5 (opcodeHitOnMe, new OpHitOnMe); - interpreter.installSegment5 (opcodeHitOnMeExplicit, new OpHitOnMe); - interpreter.installSegment5 (opcodeDisableTeleporting, new OpEnableTeleporting); - interpreter.installSegment5 (opcodeEnableTeleporting, new OpEnableTeleporting); + interpreter.installSegment5 (Compiler::Misc::opcodeXBox, new OpXBox); + interpreter.installSegment5 (Compiler::Misc::opcodeOnActivate, new OpOnActivate); + interpreter.installSegment5 (Compiler::Misc::opcodeActivate, new OpActivate); + interpreter.installSegment3 (Compiler::Misc::opcodeLock, new OpLock); + interpreter.installSegment3 (Compiler::Misc::opcodeLockExplicit, new OpLock); + interpreter.installSegment5 (Compiler::Misc::opcodeUnlock, new OpUnlock); + interpreter.installSegment5 (Compiler::Misc::opcodeUnlockExplicit, new OpUnlock); + interpreter.installSegment5 (Compiler::Misc::opcodeToggleCollisionDebug, new OpToggleCollisionDebug); + interpreter.installSegment5 (Compiler::Misc::opcodeToggleCollisionBoxes, new OpToggleCollisionBoxes); + interpreter.installSegment5 (Compiler::Misc::opcodeToggleWireframe, new OpToggleWireframe); + interpreter.installSegment5 (Compiler::Misc::opcodeFadeIn, new OpFadeIn); + interpreter.installSegment5 (Compiler::Misc::opcodeFadeOut, new OpFadeOut); + interpreter.installSegment5 (Compiler::Misc::opcodeFadeTo, new OpFadeTo); + interpreter.installSegment5 (Compiler::Misc::opcodeTogglePathgrid, new OpTogglePathgrid); + interpreter.installSegment5 (Compiler::Misc::opcodeToggleWater, new OpToggleWater); + interpreter.installSegment5 (Compiler::Misc::opcodeDontSaveObject, new OpDontSaveObject); + interpreter.installSegment5 (Compiler::Misc::opcodeToggleVanityMode, new OpToggleVanityMode); + interpreter.installSegment5 (Compiler::Misc::opcodeGetPcSleep, new OpGetPcSleep); + interpreter.installSegment5 (Compiler::Misc::opcodeWakeUpPc, new OpWakeUpPc); + interpreter.installSegment5 (Compiler::Misc::opcodePlayBink, new OpPlayBink); + interpreter.installSegment5 (Compiler::Misc::opcodeGetLocked, new OpGetLocked); + interpreter.installSegment5 (Compiler::Misc::opcodeGetLockedExplicit, new OpGetLocked); + interpreter.installSegment5 (Compiler::Misc::opcodeGetEffect, new OpGetEffect); + interpreter.installSegment5 (Compiler::Misc::opcodeGetEffectExplicit, new OpGetEffect); + interpreter.installSegment5 (Compiler::Misc::opcodeAddSoulGem, new OpAddSoulGem); + interpreter.installSegment5 (Compiler::Misc::opcodeAddSoulGemExplicit, new OpAddSoulGem); + interpreter.installSegment5 (Compiler::Misc::opcodeRemoveSoulGem, new OpRemoveSoulGem); + interpreter.installSegment5 (Compiler::Misc::opcodeRemoveSoulGemExplicit, new OpRemoveSoulGem); + interpreter.installSegment5 (Compiler::Misc::opcodeDrop, new OpDrop); + interpreter.installSegment5 (Compiler::Misc::opcodeDropExplicit, new OpDrop); + interpreter.installSegment5 (Compiler::Misc::opcodeDropSoulGem, new OpDropSoulGem); + interpreter.installSegment5 (Compiler::Misc::opcodeDropSoulGemExplicit, new OpDropSoulGem); + interpreter.installSegment5 (Compiler::Misc::opcodeGetAttacked, new OpGetAttacked); + interpreter.installSegment5 (Compiler::Misc::opcodeGetAttackedExplicit, new OpGetAttacked); + interpreter.installSegment5 (Compiler::Misc::opcodeGetWeaponDrawn, new OpGetWeaponDrawn); + interpreter.installSegment5 (Compiler::Misc::opcodeGetWeaponDrawnExplicit, new OpGetWeaponDrawn); + interpreter.installSegment5 (Compiler::Misc::opcodeGetSpellEffects, new OpGetSpellEffects); + interpreter.installSegment5 (Compiler::Misc::opcodeGetSpellEffectsExplicit, new OpGetSpellEffects); + interpreter.installSegment5 (Compiler::Misc::opcodeGetCurrentTime, new OpGetCurrentTime); + interpreter.installSegment5 (Compiler::Misc::opcodeSetDelete, new OpSetDelete); + interpreter.installSegment5 (Compiler::Misc::opcodeSetDeleteExplicit, new OpSetDelete); + interpreter.installSegment5 (Compiler::Misc::opcodeGetSquareRoot, new OpGetSquareRoot); + interpreter.installSegment5 (Compiler::Misc::opcodeFall, new OpFall); + interpreter.installSegment5 (Compiler::Misc::opcodeFallExplicit, new OpFall); + interpreter.installSegment5 (Compiler::Misc::opcodeGetStandingPc, new OpGetStandingPc); + interpreter.installSegment5 (Compiler::Misc::opcodeGetStandingPcExplicit, new OpGetStandingPc); + interpreter.installSegment5 (Compiler::Misc::opcodeGetStandingActor, new OpGetStandingActor); + interpreter.installSegment5 (Compiler::Misc::opcodeGetStandingActorExplicit, new OpGetStandingActor); + interpreter.installSegment5 (Compiler::Misc::opcodeGetWindSpeed, new OpGetWindSpeed); + interpreter.installSegment5 (Compiler::Misc::opcodeHitOnMe, new OpHitOnMe); + interpreter.installSegment5 (Compiler::Misc::opcodeHitOnMeExplicit, new OpHitOnMe); + interpreter.installSegment5 (Compiler::Misc::opcodeDisableTeleporting, new OpEnableTeleporting); + interpreter.installSegment5 (Compiler::Misc::opcodeEnableTeleporting, new OpEnableTeleporting); } } } diff --git a/apps/openmw/mwscript/miscextensions.hpp b/apps/openmw/mwscript/miscextensions.hpp index 69818f466e..16ed9301ed 100644 --- a/apps/openmw/mwscript/miscextensions.hpp +++ b/apps/openmw/mwscript/miscextensions.hpp @@ -14,9 +14,7 @@ namespace Interpreter namespace MWScript { namespace Misc - { - void registerExtensions (Compiler::Extensions& extensions); - + { void installOpcodes (Interpreter::Interpreter& interpreter); } } diff --git a/apps/openmw/mwscript/skyextensions.cpp b/apps/openmw/mwscript/skyextensions.cpp index 393c9c55b8..8b9efd74e1 100644 --- a/apps/openmw/mwscript/skyextensions.cpp +++ b/apps/openmw/mwscript/skyextensions.cpp @@ -2,6 +2,7 @@ #include "skyextensions.hpp" #include +#include #include #include @@ -118,38 +119,17 @@ namespace MWScript } }; - const int opcodeToggleSky = 0x2000021; - const int opcodeTurnMoonWhite = 0x2000022; - const int opcodeTurnMoonRed = 0x2000023; - const int opcodeGetMasserPhase = 0x2000024; - const int opcodeGetSecundaPhase = 0x2000025; - const int opcodeGetCurrentWeather = 0x200013f; - const int opcodeChangeWeather = 0x2000140; - const int opcodeModRegion = 0x20026; - - void registerExtensions (Compiler::Extensions& extensions) - { - extensions.registerInstruction ("togglesky", "", opcodeToggleSky); - extensions.registerInstruction ("ts", "", opcodeToggleSky); - extensions.registerInstruction ("turnmoonwhite", "", opcodeTurnMoonWhite); - extensions.registerInstruction ("turnmoonred", "", opcodeTurnMoonRed); - extensions.registerInstruction ("changeweather", "Sl", opcodeChangeWeather); - extensions.registerFunction ("getmasserphase", 'l', "", opcodeGetMasserPhase); - extensions.registerFunction ("getsecundaphase", 'l', "", opcodeGetSecundaPhase); - extensions.registerFunction ("getcurrentweather", 'l', "", opcodeGetCurrentWeather); - extensions.registerInstruction ("modregion", "S/llllllllll", opcodeModRegion); - } void installOpcodes (Interpreter::Interpreter& interpreter) { - interpreter.installSegment5 (opcodeToggleSky, new OpToggleSky); - interpreter.installSegment5 (opcodeTurnMoonWhite, new OpTurnMoonWhite); - interpreter.installSegment5 (opcodeTurnMoonRed, new OpTurnMoonRed); - interpreter.installSegment5 (opcodeGetMasserPhase, new OpGetMasserPhase); - interpreter.installSegment5 (opcodeGetSecundaPhase, new OpGetSecundaPhase); - interpreter.installSegment5 (opcodeGetCurrentWeather, new OpGetCurrentWeather); - interpreter.installSegment5 (opcodeChangeWeather, new OpChangeWeather); - interpreter.installSegment3 (opcodeModRegion, new OpModRegion); + interpreter.installSegment5 (Compiler::Sky::opcodeToggleSky, new OpToggleSky); + interpreter.installSegment5 (Compiler::Sky::opcodeTurnMoonWhite, new OpTurnMoonWhite); + interpreter.installSegment5 (Compiler::Sky::opcodeTurnMoonRed, new OpTurnMoonRed); + interpreter.installSegment5 (Compiler::Sky::opcodeGetMasserPhase, new OpGetMasserPhase); + interpreter.installSegment5 (Compiler::Sky::opcodeGetSecundaPhase, new OpGetSecundaPhase); + interpreter.installSegment5 (Compiler::Sky::opcodeGetCurrentWeather, new OpGetCurrentWeather); + interpreter.installSegment5 (Compiler::Sky::opcodeChangeWeather, new OpChangeWeather); + interpreter.installSegment3 (Compiler::Sky::opcodeModRegion, new OpModRegion); } } } diff --git a/apps/openmw/mwscript/skyextensions.hpp b/apps/openmw/mwscript/skyextensions.hpp index b9bffb27eb..003f2fb190 100644 --- a/apps/openmw/mwscript/skyextensions.hpp +++ b/apps/openmw/mwscript/skyextensions.hpp @@ -15,9 +15,7 @@ namespace MWScript { /// \brief sky-related script functionality namespace Sky - { - void registerExtensions (Compiler::Extensions& extensions); - + { void installOpcodes (Interpreter::Interpreter& interpreter); } } diff --git a/apps/openmw/mwscript/soundextensions.cpp b/apps/openmw/mwscript/soundextensions.cpp index e4c7a4968c..73c3ec93a5 100644 --- a/apps/openmw/mwscript/soundextensions.cpp +++ b/apps/openmw/mwscript/soundextensions.cpp @@ -2,6 +2,7 @@ #include "extensions.hpp" #include +#include #include #include @@ -188,75 +189,34 @@ namespace MWScript } }; - const int opcodeSay = 0x2000001; - const int opcodeSayDone = 0x2000002; - const int opcodeStreamMusic = 0x2000003; - const int opcodePlaySound = 0x2000004; - const int opcodePlaySoundVP = 0x2000005; - const int opcodePlaySound3D = 0x2000006; - const int opcodePlaySound3DVP = 0x2000007; - const int opcodePlayLoopSound3D = 0x2000008; - const int opcodePlayLoopSound3DVP = 0x2000009; - const int opcodeStopSound = 0x200000a; - const int opcodeGetSoundPlaying = 0x200000b; - - const int opcodeSayExplicit = 0x2000019; - const int opcodeSayDoneExplicit = 0x200001a; - const int opcodePlaySound3DExplicit = 0x200001b; - const int opcodePlaySound3DVPExplicit = 0x200001c; - const int opcodePlayLoopSound3DExplicit = 0x200001d; - const int opcodePlayLoopSound3DVPExplicit = 0x200001e; - const int opcodeStopSoundExplicit = 0x200001f; - const int opcodeGetSoundPlayingExplicit = 0x2000020; - - void registerExtensions (Compiler::Extensions& extensions) - { - extensions.registerInstruction ("say", "SS", opcodeSay, opcodeSayExplicit); - extensions.registerFunction ("saydone", 'l', "", opcodeSayDone, opcodeSayDoneExplicit); - extensions.registerInstruction ("streammusic", "S", opcodeStreamMusic); - extensions.registerInstruction ("playsound", "c", opcodePlaySound); - extensions.registerInstruction ("playsoundvp", "cff", opcodePlaySoundVP); - extensions.registerInstruction ("playsound3d", "c", opcodePlaySound3D, - opcodePlaySound3DExplicit); - extensions.registerInstruction ("playsound3dvp", "cff", opcodePlaySound3DVP, - opcodePlaySound3DVPExplicit); - extensions.registerInstruction ("playloopsound3d", "c", opcodePlayLoopSound3D, - opcodePlayLoopSound3DExplicit); - extensions.registerInstruction ("playloopsound3dvp", "cff", opcodePlayLoopSound3DVP, - opcodePlayLoopSound3DVPExplicit); - extensions.registerInstruction ("stopsound", "c", opcodeStopSound, - opcodeStopSoundExplicit); - extensions.registerFunction ("getsoundplaying", 'l', "c", opcodeGetSoundPlaying, - opcodeGetSoundPlayingExplicit); - } void installOpcodes (Interpreter::Interpreter& interpreter) { - interpreter.installSegment5 (opcodeSay, new OpSay); - interpreter.installSegment5 (opcodeSayDone, new OpSayDone); - interpreter.installSegment5 (opcodeStreamMusic, new OpStreamMusic); - interpreter.installSegment5 (opcodePlaySound, new OpPlaySound); - interpreter.installSegment5 (opcodePlaySoundVP, new OpPlaySoundVP); - interpreter.installSegment5 (opcodePlaySound3D, new OpPlaySound3D (false)); - interpreter.installSegment5 (opcodePlaySound3DVP, new OpPlaySoundVP3D (false)); - interpreter.installSegment5 (opcodePlayLoopSound3D, new OpPlaySound3D (true)); - interpreter.installSegment5 (opcodePlayLoopSound3DVP, + interpreter.installSegment5 (Compiler::Sound::opcodeSay, new OpSay); + interpreter.installSegment5 (Compiler::Sound::opcodeSayDone, new OpSayDone); + interpreter.installSegment5 (Compiler::Sound::opcodeStreamMusic, new OpStreamMusic); + interpreter.installSegment5 (Compiler::Sound::opcodePlaySound, new OpPlaySound); + interpreter.installSegment5 (Compiler::Sound::opcodePlaySoundVP, new OpPlaySoundVP); + interpreter.installSegment5 (Compiler::Sound::opcodePlaySound3D, new OpPlaySound3D (false)); + interpreter.installSegment5 (Compiler::Sound::opcodePlaySound3DVP, new OpPlaySoundVP3D (false)); + interpreter.installSegment5 (Compiler::Sound::opcodePlayLoopSound3D, new OpPlaySound3D (true)); + interpreter.installSegment5 (Compiler::Sound::opcodePlayLoopSound3DVP, new OpPlaySoundVP3D (true)); - interpreter.installSegment5 (opcodeStopSound, new OpStopSound); - interpreter.installSegment5 (opcodeGetSoundPlaying, new OpGetSoundPlaying); + interpreter.installSegment5 (Compiler::Sound::opcodeStopSound, new OpStopSound); + interpreter.installSegment5 (Compiler::Sound::opcodeGetSoundPlaying, new OpGetSoundPlaying); - interpreter.installSegment5 (opcodeSayExplicit, new OpSay); - interpreter.installSegment5 (opcodeSayDoneExplicit, new OpSayDone); - interpreter.installSegment5 (opcodePlaySound3DExplicit, + interpreter.installSegment5 (Compiler::Sound::opcodeSayExplicit, new OpSay); + interpreter.installSegment5 (Compiler::Sound::opcodeSayDoneExplicit, new OpSayDone); + interpreter.installSegment5 (Compiler::Sound::opcodePlaySound3DExplicit, new OpPlaySound3D (false)); - interpreter.installSegment5 (opcodePlaySound3DVPExplicit, + interpreter.installSegment5 (Compiler::Sound::opcodePlaySound3DVPExplicit, new OpPlaySoundVP3D (false)); - interpreter.installSegment5 (opcodePlayLoopSound3DExplicit, + interpreter.installSegment5 (Compiler::Sound::opcodePlayLoopSound3DExplicit, new OpPlaySound3D (true)); - interpreter.installSegment5 (opcodePlayLoopSound3DVPExplicit, + interpreter.installSegment5 (Compiler::Sound::opcodePlayLoopSound3DVPExplicit, new OpPlaySoundVP3D (true)); - interpreter.installSegment5 (opcodeStopSoundExplicit, new OpStopSound); - interpreter.installSegment5 (opcodeGetSoundPlayingExplicit, + interpreter.installSegment5 (Compiler::Sound::opcodeStopSoundExplicit, new OpStopSound); + interpreter.installSegment5 (Compiler::Sound::opcodeGetSoundPlayingExplicit, new OpGetSoundPlaying); } } diff --git a/apps/openmw/mwscript/soundextensions.hpp b/apps/openmw/mwscript/soundextensions.hpp index 85416a6dfc..b92d7ea1bb 100644 --- a/apps/openmw/mwscript/soundextensions.hpp +++ b/apps/openmw/mwscript/soundextensions.hpp @@ -15,10 +15,7 @@ namespace MWScript { namespace Sound { - // Script-extensions related to sound - - void registerExtensions (Compiler::Extensions& extensions); - + // Script-extensions related to sound void installOpcodes (Interpreter::Interpreter& interpreter); } } diff --git a/apps/openmw/mwscript/statsextensions.cpp b/apps/openmw/mwscript/statsextensions.cpp index 04e89edc66..edcd24b689 100644 --- a/apps/openmw/mwscript/statsextensions.cpp +++ b/apps/openmw/mwscript/statsextensions.cpp @@ -10,6 +10,7 @@ #include "../mwworld/esmstore.hpp" #include +#include #include #include @@ -1056,336 +1057,125 @@ namespace MWScript } }; - const int numberOfAttributes = 8; - - const int opcodeGetAttribute = 0x2000027; - const int opcodeGetAttributeExplicit = 0x200002f; - const int opcodeSetAttribute = 0x2000037; - const int opcodeSetAttributeExplicit = 0x200003f; - const int opcodeModAttribute = 0x2000047; - const int opcodeModAttributeExplicit = 0x200004f; - - const int numberOfDynamics = 3; - - const int opcodeGetDynamic = 0x2000057; - const int opcodeGetDynamicExplicit = 0x200005a; - const int opcodeSetDynamic = 0x200005d; - const int opcodeSetDynamicExplicit = 0x2000060; - const int opcodeModDynamic = 0x2000063; - const int opcodeModDynamicExplicit = 0x2000066; - const int opcodeModCurrentDynamic = 0x2000069; - const int opcodeModCurrentDynamicExplicit = 0x200006c; - const int opcodeGetDynamicGetRatio = 0x200006f; - const int opcodeGetDynamicGetRatioExplicit = 0x2000072; - - const int numberOfSkills = 27; - - const int opcodeGetSkill = 0x200008e; - const int opcodeGetSkillExplicit = 0x20000a9; - const int opcodeSetSkill = 0x20000c4; - const int opcodeSetSkillExplicit = 0x20000df; - const int opcodeModSkill = 0x20000fa; - const int opcodeModSkillExplicit = 0x2000115; - - const int opcodeGetPCCrimeLevel = 0x20001ec; - const int opcodeSetPCCrimeLevel = 0x20001ed; - const int opcodeModPCCrimeLevel = 0x20001ee; - - const int opcodeAddSpell = 0x2000147; - const int opcodeAddSpellExplicit = 0x2000148; - const int opcodeRemoveSpell = 0x2000149; - const int opcodeRemoveSpellExplicit = 0x200014a; - const int opcodeGetSpell = 0x200014b; - const int opcodeGetSpellExplicit = 0x200014c; - - const int opcodePCRaiseRank = 0x2000b; - const int opcodePCLowerRank = 0x2000c; - const int opcodePCJoinFaction = 0x2000d; - const int opcodeGetPCRank = 0x2000e; - const int opcodeGetPCRankExplicit = 0x2000f; - const int opcodeModDisposition = 0x200014d; - const int opcodeModDispositionExplicit = 0x200014e; - const int opcodeSetDisposition = 0x20001a4; - const int opcodeSetDispositionExplicit = 0x20001a5; - const int opcodeGetDisposition = 0x20001a6; - const int opcodeGetDispositionExplicit = 0x20001a7; - - const int opcodeGetLevel = 0x200018c; - const int opcodeGetLevelExplicit = 0x200018d; - const int opcodeSetLevel = 0x200018e; - const int opcodeSetLevelExplicit = 0x200018f; - - const int opcodeGetDeadCount = 0x20001a3; - - const int opcodeGetPCFacRep = 0x20012; - const int opcodeGetPCFacRepExplicit = 0x20013; - const int opcodeSetPCFacRep = 0x20014; - const int opcodeSetPCFacRepExplicit = 0x20015; - const int opcodeModPCFacRep = 0x20016; - const int opcodeModPCFacRepExplicit = 0x20017; - - const int opcodeGetCommonDisease = 0x20001a8; - const int opcodeGetCommonDiseaseExplicit = 0x20001a9; - const int opcodeGetBlightDisease = 0x20001aa; - const int opcodeGetBlightDiseaseExplicit = 0x20001ab; - - const int opcodeGetRace = 0x20001d9; - const int opcodeGetRaceExplicit = 0x20001da; - - const int opcodeGetWerewolfKills = 0x20001e2; - - const int opcodePcExpelled = 0x20018; - const int opcodePcExpelledExplicit = 0x20019; - const int opcodePcExpell = 0x2001a; - const int opcodePcExpellExplicit = 0x2001b; - const int opcodePcClearExpelled = 0x2001c; - const int opcodePcClearExpelledExplicit = 0x2001d; - const int opcodeRaiseRank = 0x20001e8; - const int opcodeRaiseRankExplicit = 0x20001e9; - const int opcodeLowerRank = 0x20001ea; - const int opcodeLowerRankExplicit = 0x20001eb; - const int opcodeOnDeath = 0x20001fc; - const int opcodeOnDeathExplicit = 0x2000205; - const int opcodeIsWerewolf = 0x20001fd; - const int opcodeIsWerewolfExplicit = 0x20001fe; - - void registerExtensions (Compiler::Extensions& extensions) - { - static const char *attributes[numberOfAttributes] = - { - "strength", "intelligence", "willpower", "agility", "speed", "endurance", - "personality", "luck" - }; - - static const char *dynamics[numberOfDynamics] = - { - "health", "magicka", "fatigue" - }; - - static const char *skills[numberOfSkills] = - { - "block", "armorer", "mediumarmor", "heavyarmor", "bluntweapon", - "longblade", "axe", "spear", "athletics", "enchant", "destruction", - "alteration", "illusion", "conjuration", "mysticism", - "restoration", "alchemy", "unarmored", "security", "sneak", - "acrobatics", "lightarmor", "shortblade", "marksman", - "mercantile", "speechcraft", "handtohand" - }; - - std::string get ("get"); - std::string set ("set"); - std::string mod ("mod"); - std::string modCurrent ("modcurrent"); - std::string getRatio ("getratio"); - - for (int i=0; i (i)); - interpreter.installSegment5 (opcodeGetAttributeExplicit+i, + interpreter.installSegment5 (Compiler::Stats::opcodeGetAttribute+i, new OpGetAttribute (i)); + interpreter.installSegment5 (Compiler::Stats::opcodeGetAttributeExplicit+i, new OpGetAttribute (i)); - interpreter.installSegment5 (opcodeSetAttribute+i, new OpSetAttribute (i)); - interpreter.installSegment5 (opcodeSetAttributeExplicit+i, + interpreter.installSegment5 (Compiler::Stats::opcodeSetAttribute+i, new OpSetAttribute (i)); + interpreter.installSegment5 (Compiler::Stats::opcodeSetAttributeExplicit+i, new OpSetAttribute (i)); - interpreter.installSegment5 (opcodeModAttribute+i, new OpModAttribute (i)); - interpreter.installSegment5 (opcodeModAttributeExplicit+i, + interpreter.installSegment5 (Compiler::Stats::opcodeModAttribute+i, new OpModAttribute (i)); + interpreter.installSegment5 (Compiler::Stats::opcodeModAttributeExplicit+i, new OpModAttribute (i)); } - for (int i=0; i (i)); - interpreter.installSegment5 (opcodeGetDynamicExplicit+i, + interpreter.installSegment5 (Compiler::Stats::opcodeGetDynamic+i, new OpGetDynamic (i)); + interpreter.installSegment5 (Compiler::Stats::opcodeGetDynamicExplicit+i, new OpGetDynamic (i)); - interpreter.installSegment5 (opcodeSetDynamic+i, new OpSetDynamic (i)); - interpreter.installSegment5 (opcodeSetDynamicExplicit+i, + interpreter.installSegment5 (Compiler::Stats::opcodeSetDynamic+i, new OpSetDynamic (i)); + interpreter.installSegment5 (Compiler::Stats::opcodeSetDynamicExplicit+i, new OpSetDynamic (i)); - interpreter.installSegment5 (opcodeModDynamic+i, new OpModDynamic (i)); - interpreter.installSegment5 (opcodeModDynamicExplicit+i, + interpreter.installSegment5 (Compiler::Stats::opcodeModDynamic+i, new OpModDynamic (i)); + interpreter.installSegment5 (Compiler::Stats::opcodeModDynamicExplicit+i, new OpModDynamic (i)); - interpreter.installSegment5 (opcodeModCurrentDynamic+i, + interpreter.installSegment5 (Compiler::Stats::opcodeModCurrentDynamic+i, new OpModCurrentDynamic (i)); - interpreter.installSegment5 (opcodeModCurrentDynamicExplicit+i, + interpreter.installSegment5 (Compiler::Stats::opcodeModCurrentDynamicExplicit+i, new OpModCurrentDynamic (i)); - interpreter.installSegment5 (opcodeGetDynamicGetRatio+i, + interpreter.installSegment5 (Compiler::Stats::opcodeGetDynamicGetRatio+i, new OpGetDynamicGetRatio (i)); - interpreter.installSegment5 (opcodeGetDynamicGetRatioExplicit+i, + interpreter.installSegment5 (Compiler::Stats::opcodeGetDynamicGetRatioExplicit+i, new OpGetDynamicGetRatio (i)); } - for (int i=0; i (i)); - interpreter.installSegment5 (opcodeGetSkillExplicit+i, new OpGetSkill (i)); + interpreter.installSegment5 (Compiler::Stats::opcodeGetSkill+i, new OpGetSkill (i)); + interpreter.installSegment5 (Compiler::Stats::opcodeGetSkillExplicit+i, new OpGetSkill (i)); - interpreter.installSegment5 (opcodeSetSkill+i, new OpSetSkill (i)); - interpreter.installSegment5 (opcodeSetSkillExplicit+i, new OpSetSkill (i)); + interpreter.installSegment5 (Compiler::Stats::opcodeSetSkill+i, new OpSetSkill (i)); + interpreter.installSegment5 (Compiler::Stats::opcodeSetSkillExplicit+i, new OpSetSkill (i)); - interpreter.installSegment5 (opcodeModSkill+i, new OpModSkill (i)); - interpreter.installSegment5 (opcodeModSkillExplicit+i, new OpModSkill (i)); + interpreter.installSegment5 (Compiler::Stats::opcodeModSkill+i, new OpModSkill (i)); + interpreter.installSegment5 (Compiler::Stats::opcodeModSkillExplicit+i, new OpModSkill (i)); } - interpreter.installSegment5 (opcodeGetPCCrimeLevel, new OpGetPCCrimeLevel); - interpreter.installSegment5 (opcodeSetPCCrimeLevel, new OpSetPCCrimeLevel); - interpreter.installSegment5 (opcodeModPCCrimeLevel, new OpModPCCrimeLevel); + interpreter.installSegment5 (Compiler::Stats::opcodeGetPCCrimeLevel, new OpGetPCCrimeLevel); + interpreter.installSegment5 (Compiler::Stats::opcodeSetPCCrimeLevel, new OpSetPCCrimeLevel); + interpreter.installSegment5 (Compiler::Stats::opcodeModPCCrimeLevel, new OpModPCCrimeLevel); - interpreter.installSegment5 (opcodeAddSpell, new OpAddSpell); - interpreter.installSegment5 (opcodeAddSpellExplicit, new OpAddSpell); - interpreter.installSegment5 (opcodeRemoveSpell, new OpRemoveSpell); - interpreter.installSegment5 (opcodeRemoveSpellExplicit, + interpreter.installSegment5 (Compiler::Stats::opcodeAddSpell, new OpAddSpell); + interpreter.installSegment5 (Compiler::Stats::opcodeAddSpellExplicit, new OpAddSpell); + interpreter.installSegment5 (Compiler::Stats::opcodeRemoveSpell, new OpRemoveSpell); + interpreter.installSegment5 (Compiler::Stats::opcodeRemoveSpellExplicit, new OpRemoveSpell); - interpreter.installSegment5 (opcodeGetSpell, new OpGetSpell); - interpreter.installSegment5 (opcodeGetSpellExplicit, new OpGetSpell); + interpreter.installSegment5 (Compiler::Stats::opcodeGetSpell, new OpGetSpell); + interpreter.installSegment5 (Compiler::Stats::opcodeGetSpellExplicit, new OpGetSpell); - interpreter.installSegment3(opcodePCRaiseRank,new OpPCRaiseRank); - interpreter.installSegment3(opcodePCLowerRank,new OpPCLowerRank); - interpreter.installSegment3(opcodePCJoinFaction,new OpPCJoinFaction); - interpreter.installSegment3(opcodeGetPCRank,new OpGetPCRank); - interpreter.installSegment3(opcodeGetPCRankExplicit,new OpGetPCRank); + interpreter.installSegment3(Compiler::Stats::opcodePCRaiseRank,new OpPCRaiseRank); + interpreter.installSegment3(Compiler::Stats::opcodePCLowerRank,new OpPCLowerRank); + interpreter.installSegment3(Compiler::Stats::opcodePCJoinFaction,new OpPCJoinFaction); + interpreter.installSegment3(Compiler::Stats::opcodeGetPCRank,new OpGetPCRank); + interpreter.installSegment3(Compiler::Stats::opcodeGetPCRankExplicit,new OpGetPCRank); - interpreter.installSegment5(opcodeModDisposition,new OpModDisposition); - interpreter.installSegment5(opcodeModDispositionExplicit,new OpModDisposition); - interpreter.installSegment5(opcodeSetDisposition,new OpSetDisposition); - interpreter.installSegment5(opcodeSetDispositionExplicit,new OpSetDisposition); - interpreter.installSegment5(opcodeGetDisposition,new OpGetDisposition); - interpreter.installSegment5(opcodeGetDispositionExplicit,new OpGetDisposition); + interpreter.installSegment5(Compiler::Stats::opcodeModDisposition,new OpModDisposition); + interpreter.installSegment5(Compiler::Stats::opcodeModDispositionExplicit,new OpModDisposition); + interpreter.installSegment5(Compiler::Stats::opcodeSetDisposition,new OpSetDisposition); + interpreter.installSegment5(Compiler::Stats::opcodeSetDispositionExplicit,new OpSetDisposition); + interpreter.installSegment5(Compiler::Stats::opcodeGetDisposition,new OpGetDisposition); + interpreter.installSegment5(Compiler::Stats::opcodeGetDispositionExplicit,new OpGetDisposition); - interpreter.installSegment5 (opcodeGetLevel, new OpGetLevel); - interpreter.installSegment5 (opcodeGetLevelExplicit, new OpGetLevel); - interpreter.installSegment5 (opcodeSetLevel, new OpSetLevel); - interpreter.installSegment5 (opcodeSetLevelExplicit, new OpSetLevel); + interpreter.installSegment5 (Compiler::Stats::opcodeGetLevel, new OpGetLevel); + interpreter.installSegment5 (Compiler::Stats::opcodeGetLevelExplicit, new OpGetLevel); + interpreter.installSegment5 (Compiler::Stats::opcodeSetLevel, new OpSetLevel); + interpreter.installSegment5 (Compiler::Stats::opcodeSetLevelExplicit, new OpSetLevel); - interpreter.installSegment5 (opcodeGetDeadCount, new OpGetDeadCount); + interpreter.installSegment5 (Compiler::Stats::opcodeGetDeadCount, new OpGetDeadCount); - interpreter.installSegment3 (opcodeGetPCFacRep, new OpGetPCFacRep); - interpreter.installSegment3 (opcodeGetPCFacRepExplicit, new OpGetPCFacRep); - interpreter.installSegment3 (opcodeSetPCFacRep, new OpSetPCFacRep); - interpreter.installSegment3 (opcodeSetPCFacRepExplicit, new OpSetPCFacRep); - interpreter.installSegment3 (opcodeModPCFacRep, new OpModPCFacRep); - interpreter.installSegment3 (opcodeModPCFacRepExplicit, new OpModPCFacRep); + interpreter.installSegment3 (Compiler::Stats::opcodeGetPCFacRep, new OpGetPCFacRep); + interpreter.installSegment3 (Compiler::Stats::opcodeGetPCFacRepExplicit, new OpGetPCFacRep); + interpreter.installSegment3 (Compiler::Stats::opcodeSetPCFacRep, new OpSetPCFacRep); + interpreter.installSegment3 (Compiler::Stats::opcodeSetPCFacRepExplicit, new OpSetPCFacRep); + interpreter.installSegment3 (Compiler::Stats::opcodeModPCFacRep, new OpModPCFacRep); + interpreter.installSegment3 (Compiler::Stats::opcodeModPCFacRepExplicit, new OpModPCFacRep); - interpreter.installSegment5 (opcodeGetCommonDisease, new OpGetCommonDisease); - interpreter.installSegment5 (opcodeGetCommonDiseaseExplicit, new OpGetCommonDisease); - interpreter.installSegment5 (opcodeGetBlightDisease, new OpGetBlightDisease); - interpreter.installSegment5 (opcodeGetBlightDiseaseExplicit, new OpGetBlightDisease); + interpreter.installSegment5 (Compiler::Stats::opcodeGetCommonDisease, new OpGetCommonDisease); + interpreter.installSegment5 (Compiler::Stats::opcodeGetCommonDiseaseExplicit, new OpGetCommonDisease); + interpreter.installSegment5 (Compiler::Stats::opcodeGetBlightDisease, new OpGetBlightDisease); + interpreter.installSegment5 (Compiler::Stats::opcodeGetBlightDiseaseExplicit, new OpGetBlightDisease); - interpreter.installSegment5 (opcodeGetRace, new OpGetRace); - interpreter.installSegment5 (opcodeGetRaceExplicit, new OpGetRace); - interpreter.installSegment5 (opcodeGetWerewolfKills, new OpGetWerewolfKills); + interpreter.installSegment5 (Compiler::Stats::opcodeGetRace, new OpGetRace); + interpreter.installSegment5 (Compiler::Stats::opcodeGetRaceExplicit, new OpGetRace); + interpreter.installSegment5 (Compiler::Stats::opcodeGetWerewolfKills, new OpGetWerewolfKills); - interpreter.installSegment3 (opcodePcExpelled, new OpPcExpelled); - interpreter.installSegment3 (opcodePcExpelledExplicit, new OpPcExpelled); - interpreter.installSegment3 (opcodePcExpell, new OpPcExpell); - interpreter.installSegment3 (opcodePcExpellExplicit, new OpPcExpell); - interpreter.installSegment3 (opcodePcClearExpelled, new OpPcClearExpelled); - interpreter.installSegment3 (opcodePcClearExpelledExplicit, new OpPcClearExpelled); - interpreter.installSegment5 (opcodeRaiseRank, new OpRaiseRank); - interpreter.installSegment5 (opcodeRaiseRankExplicit, new OpRaiseRank); - interpreter.installSegment5 (opcodeLowerRank, new OpLowerRank); - interpreter.installSegment5 (opcodeLowerRankExplicit, new OpLowerRank); + interpreter.installSegment3 (Compiler::Stats::opcodePcExpelled, new OpPcExpelled); + interpreter.installSegment3 (Compiler::Stats::opcodePcExpelledExplicit, new OpPcExpelled); + interpreter.installSegment3 (Compiler::Stats::opcodePcExpell, new OpPcExpell); + interpreter.installSegment3 (Compiler::Stats::opcodePcExpellExplicit, new OpPcExpell); + interpreter.installSegment3 (Compiler::Stats::opcodePcClearExpelled, new OpPcClearExpelled); + interpreter.installSegment3 (Compiler::Stats::opcodePcClearExpelledExplicit, new OpPcClearExpelled); + interpreter.installSegment5 (Compiler::Stats::opcodeRaiseRank, new OpRaiseRank); + interpreter.installSegment5 (Compiler::Stats::opcodeRaiseRankExplicit, new OpRaiseRank); + interpreter.installSegment5 (Compiler::Stats::opcodeLowerRank, new OpLowerRank); + interpreter.installSegment5 (Compiler::Stats::opcodeLowerRankExplicit, new OpLowerRank); - interpreter.installSegment5 (opcodeOnDeath, new OpOnDeath); - interpreter.installSegment5 (opcodeOnDeathExplicit, new OpOnDeath); + interpreter.installSegment5 (Compiler::Stats::opcodeOnDeath, new OpOnDeath); + interpreter.installSegment5 (Compiler::Stats::opcodeOnDeathExplicit, new OpOnDeath); - interpreter.installSegment5 (opcodeIsWerewolf, new OpIsWerewolf); - interpreter.installSegment5 (opcodeIsWerewolfExplicit, new OpIsWerewolf); + interpreter.installSegment5 (Compiler::Stats::opcodeIsWerewolf, new OpIsWerewolf); + interpreter.installSegment5 (Compiler::Stats::opcodeIsWerewolfExplicit, new OpIsWerewolf); } } } diff --git a/apps/openmw/mwscript/statsextensions.hpp b/apps/openmw/mwscript/statsextensions.hpp index 372266d015..213b549674 100644 --- a/apps/openmw/mwscript/statsextensions.hpp +++ b/apps/openmw/mwscript/statsextensions.hpp @@ -15,9 +15,7 @@ namespace MWScript { /// \brief stats-related script functionality (creatures and NPCs) namespace Stats - { - void registerExtensions (Compiler::Extensions& extensions); - + { void installOpcodes (Interpreter::Interpreter& interpreter); } } diff --git a/apps/openmw/mwscript/transformationextensions.cpp b/apps/openmw/mwscript/transformationextensions.cpp index 9b7b51a5a2..6246daee22 100644 --- a/apps/openmw/mwscript/transformationextensions.cpp +++ b/apps/openmw/mwscript/transformationextensions.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -707,108 +708,45 @@ namespace MWScript }; - const int opcodeSetScale = 0x2000164; - const int opcodeSetScaleExplicit = 0x2000165; - const int opcodeSetAngle = 0x2000166; - const int opcodeSetAngleExplicit = 0x2000167; - const int opcodeGetScale = 0x2000168; - const int opcodeGetScaleExplicit = 0x2000169; - const int opcodeGetAngle = 0x200016a; - const int opcodeGetAngleExplicit = 0x200016b; - const int opcodeGetPos = 0x2000190; - const int opcodeGetPosExplicit = 0x2000191; - const int opcodeSetPos = 0x2000192; - const int opcodeSetPosExplicit = 0x2000193; - const int opcodeGetStartingPos = 0x2000194; - const int opcodeGetStartingPosExplicit = 0x2000195; - const int opcodeGetStartingAngle = 0x2000210; - const int opcodeGetStartingAngleExplicit = 0x2000211; - const int opcodePosition = 0x2000196; - const int opcodePositionExplicit = 0x2000197; - const int opcodePositionCell = 0x2000198; - const int opcodePositionCellExplicit = 0x2000199; - - const int opcodePlaceItemCell = 0x200019a; - const int opcodePlaceItem = 0x200019b; - const int opcodePlaceAtPc = 0x200019c; - const int opcodePlaceAtMe = 0x200019d; - const int opcodePlaceAtMeExplicit = 0x200019e; - const int opcodeModScale = 0x20001e3; - const int opcodeModScaleExplicit = 0x20001e4; - const int opcodeRotate = 0x20001ff; - const int opcodeRotateExplicit = 0x2000200; - const int opcodeRotateWorld = 0x2000201; - const int opcodeRotateWorldExplicit = 0x2000202; - const int opcodeSetAtStart = 0x2000203; - const int opcodeSetAtStartExplicit = 0x2000204; - const int opcodeMove = 0x2000206; - const int opcodeMoveExplicit = 0x2000207; - const int opcodeMoveWorld = 0x2000208; - const int opcodeMoveWorldExplicit = 0x2000209; - - void registerExtensions (Compiler::Extensions& extensions) - { - extensions.registerInstruction("setscale","f",opcodeSetScale,opcodeSetScaleExplicit); - extensions.registerFunction("getscale",'f',"",opcodeGetScale,opcodeGetScaleExplicit); - extensions.registerInstruction("setangle","cf",opcodeSetAngle,opcodeSetAngleExplicit); - extensions.registerFunction("getangle",'f',"c",opcodeGetAngle,opcodeGetAngleExplicit); - extensions.registerInstruction("setpos","cf",opcodeSetPos,opcodeSetPosExplicit); - extensions.registerFunction("getpos",'f',"c",opcodeGetPos,opcodeGetPosExplicit); - extensions.registerFunction("getstartingpos",'f',"c",opcodeGetStartingPos,opcodeGetStartingPosExplicit); - extensions.registerInstruction("position","ffff",opcodePosition,opcodePositionExplicit); - extensions.registerInstruction("positioncell","ffffc",opcodePositionCell,opcodePositionCellExplicit); - extensions.registerInstruction("placeitemcell","ccffff",opcodePlaceItemCell); - extensions.registerInstruction("placeitem","cffff",opcodePlaceItem); - extensions.registerInstruction("placeatpc","clfl",opcodePlaceAtPc); - extensions.registerInstruction("placeatme","clfl",opcodePlaceAtMe,opcodePlaceAtMeExplicit); - extensions.registerInstruction("modscale","f",opcodeModScale,opcodeModScaleExplicit); - extensions.registerInstruction("rotate","cf",opcodeRotate,opcodeRotateExplicit); - extensions.registerInstruction("rotateworld","cf",opcodeRotateWorld,opcodeRotateWorldExplicit); - extensions.registerInstruction("setatstart","",opcodeSetAtStart,opcodeSetAtStartExplicit); - extensions.registerInstruction("move","cf",opcodeMove,opcodeMoveExplicit); - extensions.registerInstruction("moveworld","cf",opcodeMoveWorld,opcodeMoveWorldExplicit); - extensions.registerFunction("getstartingangle",'f',"c",opcodeGetStartingAngle,opcodeGetStartingAngleExplicit); - } - void installOpcodes (Interpreter::Interpreter& interpreter) { - interpreter.installSegment5(opcodeSetScale,new OpSetScale); - interpreter.installSegment5(opcodeSetScaleExplicit,new OpSetScale); - interpreter.installSegment5(opcodeSetAngle,new OpSetAngle); - interpreter.installSegment5(opcodeSetAngleExplicit,new OpSetAngle); - interpreter.installSegment5(opcodeGetScale,new OpGetScale); - interpreter.installSegment5(opcodeGetScaleExplicit,new OpGetScale); - interpreter.installSegment5(opcodeGetAngle,new OpGetAngle); - interpreter.installSegment5(opcodeGetAngleExplicit,new OpGetAngle); - interpreter.installSegment5(opcodeGetPos,new OpGetPos); - interpreter.installSegment5(opcodeGetPosExplicit,new OpGetPos); - interpreter.installSegment5(opcodeSetPos,new OpSetPos); - interpreter.installSegment5(opcodeSetPosExplicit,new OpSetPos); - interpreter.installSegment5(opcodeGetStartingPos,new OpGetStartingPos); - interpreter.installSegment5(opcodeGetStartingPosExplicit,new OpGetStartingPos); - interpreter.installSegment5(opcodePosition,new OpPosition); - interpreter.installSegment5(opcodePositionExplicit,new OpPosition); - interpreter.installSegment5(opcodePositionCell,new OpPositionCell); - interpreter.installSegment5(opcodePositionCellExplicit,new OpPositionCell); - interpreter.installSegment5(opcodePlaceItemCell,new OpPlaceItemCell); - interpreter.installSegment5(opcodePlaceItem,new OpPlaceItem); - interpreter.installSegment5(opcodePlaceAtPc,new OpPlaceAtPc); - interpreter.installSegment5(opcodePlaceAtMe,new OpPlaceAtMe); - interpreter.installSegment5(opcodePlaceAtMeExplicit,new OpPlaceAtMe); - interpreter.installSegment5(opcodeModScale,new OpModScale); - interpreter.installSegment5(opcodeModScaleExplicit,new OpModScale); - interpreter.installSegment5(opcodeRotate,new OpRotate); - interpreter.installSegment5(opcodeRotateExplicit,new OpRotate); - interpreter.installSegment5(opcodeRotateWorld,new OpRotateWorld); - interpreter.installSegment5(opcodeRotateWorldExplicit,new OpRotateWorld); - interpreter.installSegment5(opcodeSetAtStart,new OpSetAtStart); - interpreter.installSegment5(opcodeSetAtStartExplicit,new OpSetAtStart); - interpreter.installSegment5(opcodeMove,new OpMove); - interpreter.installSegment5(opcodeMoveExplicit,new OpMove); - interpreter.installSegment5(opcodeMoveWorld,new OpMoveWorld); - interpreter.installSegment5(opcodeMoveWorldExplicit,new OpMoveWorld); - interpreter.installSegment5(opcodeGetStartingAngle, new OpGetStartingAngle); - interpreter.installSegment5(opcodeGetStartingAngleExplicit, new OpGetStartingAngle); + interpreter.installSegment5(Compiler::Transformation::opcodeSetScale,new OpSetScale); + interpreter.installSegment5(Compiler::Transformation::opcodeSetScaleExplicit,new OpSetScale); + interpreter.installSegment5(Compiler::Transformation::opcodeSetAngle,new OpSetAngle); + interpreter.installSegment5(Compiler::Transformation::opcodeSetAngleExplicit,new OpSetAngle); + interpreter.installSegment5(Compiler::Transformation::opcodeGetScale,new OpGetScale); + interpreter.installSegment5(Compiler::Transformation::opcodeGetScaleExplicit,new OpGetScale); + interpreter.installSegment5(Compiler::Transformation::opcodeGetAngle,new OpGetAngle); + interpreter.installSegment5(Compiler::Transformation::opcodeGetAngleExplicit,new OpGetAngle); + interpreter.installSegment5(Compiler::Transformation::opcodeGetPos,new OpGetPos); + interpreter.installSegment5(Compiler::Transformation::opcodeGetPosExplicit,new OpGetPos); + interpreter.installSegment5(Compiler::Transformation::opcodeSetPos,new OpSetPos); + interpreter.installSegment5(Compiler::Transformation::opcodeSetPosExplicit,new OpSetPos); + interpreter.installSegment5(Compiler::Transformation::opcodeGetStartingPos,new OpGetStartingPos); + interpreter.installSegment5(Compiler::Transformation::opcodeGetStartingPosExplicit,new OpGetStartingPos); + interpreter.installSegment5(Compiler::Transformation::opcodePosition,new OpPosition); + interpreter.installSegment5(Compiler::Transformation::opcodePositionExplicit,new OpPosition); + interpreter.installSegment5(Compiler::Transformation::opcodePositionCell,new OpPositionCell); + interpreter.installSegment5(Compiler::Transformation::opcodePositionCellExplicit,new OpPositionCell); + interpreter.installSegment5(Compiler::Transformation::opcodePlaceItemCell,new OpPlaceItemCell); + interpreter.installSegment5(Compiler::Transformation::opcodePlaceItem,new OpPlaceItem); + interpreter.installSegment5(Compiler::Transformation::opcodePlaceAtPc,new OpPlaceAtPc); + interpreter.installSegment5(Compiler::Transformation::opcodePlaceAtMe,new OpPlaceAtMe); + interpreter.installSegment5(Compiler::Transformation::opcodePlaceAtMeExplicit,new OpPlaceAtMe); + interpreter.installSegment5(Compiler::Transformation::opcodeModScale,new OpModScale); + interpreter.installSegment5(Compiler::Transformation::opcodeModScaleExplicit,new OpModScale); + interpreter.installSegment5(Compiler::Transformation::opcodeRotate,new OpRotate); + interpreter.installSegment5(Compiler::Transformation::opcodeRotateExplicit,new OpRotate); + interpreter.installSegment5(Compiler::Transformation::opcodeRotateWorld,new OpRotateWorld); + interpreter.installSegment5(Compiler::Transformation::opcodeRotateWorldExplicit,new OpRotateWorld); + interpreter.installSegment5(Compiler::Transformation::opcodeSetAtStart,new OpSetAtStart); + interpreter.installSegment5(Compiler::Transformation::opcodeSetAtStartExplicit,new OpSetAtStart); + interpreter.installSegment5(Compiler::Transformation::opcodeMove,new OpMove); + interpreter.installSegment5(Compiler::Transformation::opcodeMoveExplicit,new OpMove); + interpreter.installSegment5(Compiler::Transformation::opcodeMoveWorld,new OpMoveWorld); + interpreter.installSegment5(Compiler::Transformation::opcodeMoveWorldExplicit,new OpMoveWorld); + interpreter.installSegment5(Compiler::Transformation::opcodeGetStartingAngle, new OpGetStartingAngle); + interpreter.installSegment5(Compiler::Transformation::opcodeGetStartingAngleExplicit, new OpGetStartingAngle); } } } diff --git a/apps/openmw/mwscript/transformationextensions.hpp b/apps/openmw/mwscript/transformationextensions.hpp index 6ee1db1b8e..a25cc0c3d8 100644 --- a/apps/openmw/mwscript/transformationextensions.hpp +++ b/apps/openmw/mwscript/transformationextensions.hpp @@ -15,9 +15,7 @@ namespace MWScript { /// \brief stats-related script functionality (creatures and NPCs) namespace Transformation - { - void registerExtensions (Compiler::Extensions& extensions); - + { void installOpcodes (Interpreter::Interpreter& interpreter); } } diff --git a/apps/openmw/mwscript/userextensions.cpp b/apps/openmw/mwscript/userextensions.cpp index 9c97388159..538133c65d 100644 --- a/apps/openmw/mwscript/userextensions.cpp +++ b/apps/openmw/mwscript/userextensions.cpp @@ -2,6 +2,7 @@ #include "userextensions.hpp" #include +#include #include #include @@ -62,30 +63,16 @@ namespace MWScript runtime.getContext().report ("user4: not in use"); } }; - - const int opcodeUser1 = 0x200016c; - const int opcodeUser2 = 0x200016d; - const int opcodeUser3 = 0x200016e; - const int opcodeUser3Explicit = 0x200016f; - const int opcodeUser4 = 0x2000170; - const int opcodeUser4Explicit = 0x2000171; - - void registerExtensions (Compiler::Extensions& extensions) - { - extensions.registerInstruction ("user1", "", opcodeUser1); - extensions.registerInstruction ("user2", "", opcodeUser2); - extensions.registerInstruction ("user3", "", opcodeUser3, opcodeUser3); - extensions.registerInstruction ("user4", "", opcodeUser4, opcodeUser4); - } + void installOpcodes (Interpreter::Interpreter& interpreter) { - interpreter.installSegment5 (opcodeUser1, new OpUser1); - interpreter.installSegment5 (opcodeUser2, new OpUser2); - interpreter.installSegment5 (opcodeUser3, new OpUser3); - interpreter.installSegment5 (opcodeUser3Explicit, new OpUser3); - interpreter.installSegment5 (opcodeUser4, new OpUser4); - interpreter.installSegment5 (opcodeUser4Explicit, new OpUser4); + interpreter.installSegment5 (Compiler::User::opcodeUser1, new OpUser1); + interpreter.installSegment5 (Compiler::User::opcodeUser2, new OpUser2); + interpreter.installSegment5 (Compiler::User::opcodeUser3, new OpUser3); + interpreter.installSegment5 (Compiler::User::opcodeUser3Explicit, new OpUser3); + interpreter.installSegment5 (Compiler::User::opcodeUser4, new OpUser4); + interpreter.installSegment5 (Compiler::User::opcodeUser4Explicit, new OpUser4); } } } diff --git a/apps/openmw/mwscript/userextensions.hpp b/apps/openmw/mwscript/userextensions.hpp index 4bc3b46ec0..da6e0faa66 100644 --- a/apps/openmw/mwscript/userextensions.hpp +++ b/apps/openmw/mwscript/userextensions.hpp @@ -16,8 +16,6 @@ namespace MWScript /// \brief Temporary script functionality limited to the console namespace User { - void registerExtensions (Compiler::Extensions& extensions); - void installOpcodes (Interpreter::Interpreter& interpreter); } } diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index e1e5fbe9bf..acb0c39ab3 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -54,7 +54,7 @@ add_component_dir (files add_component_dir (compiler context controlparser errorhandler exception exprparser extensions fileparser generator lineparser literals locals output parser scanner scriptparser skipparser streamerrorhandler - stringparser tokenloc nullerrorhandler + stringparser tokenloc nullerrorhandler opcodes registerextensions ) add_component_dir (interpreter diff --git a/components/compiler/opcodes.cpp b/components/compiler/opcodes.cpp new file mode 100644 index 0000000000..776d1209de --- /dev/null +++ b/components/compiler/opcodes.cpp @@ -0,0 +1,13 @@ +#include "opcodes.hpp" + +namespace Compiler +{ + namespace Control + { + const char *controls[numberOfControls] = + { + "playercontrols", "playerfighting", "playerjumping", "playerlooking", "playermagic", + "playerviewswitch", "vanitymode" + }; + } +} \ No newline at end of file diff --git a/components/compiler/opcodes.hpp b/components/compiler/opcodes.hpp new file mode 100644 index 0000000000..32c19c9c24 --- /dev/null +++ b/components/compiler/opcodes.hpp @@ -0,0 +1,411 @@ +#ifndef COMPILER_OPCODES_H +#define COMPILER_OPCODES_H + +namespace Compiler +{ + namespace Ai + { + const int opcodeAiTravel = 0x20000; + const int opcodeAiTravelExplicit = 0x20001; + const int opcodeAiEscort = 0x20002; + const int opcodeAiEscortExplicit = 0x20003; + const int opcodeGetAiPackageDone = 0x200007c; + const int opcodeGetAiPackageDoneExplicit = 0x200007d; + const int opcodeGetCurrentAiPackage = 0x20001ef; + const int opcodeGetCurrentAiPackageExplicit = 0x20001f0; + const int opcodeGetDetected = 0x20001f1; + const int opcodeGetDetectedExplicit = 0x20001f2; + const int opcodeAiWander = 0x20010; + const int opcodeAiWanderExplicit = 0x20011; + const int opcodeAIActivate = 0x2001e; + const int opcodeAIActivateExplicit = 0x2001f; + const int opcodeAiEscortCell = 0x20020; + const int opcodeAiEscortCellExplicit = 0x20021; + const int opcodeAiFollow = 0x20022; + const int opcodeAiFollowExplicit = 0x20023; + const int opcodeAiFollowCell = 0x20024; + const int opcodeAiFollowCellExplicit = 0x20025; + const int opcodeSetHello = 0x200015e; + const int opcodeSetHelloExplicit = 0x200015d; + const int opcodeSetFight = 0x200015e; + const int opcodeSetFightExplicit = 0x200015f; + const int opcodeSetFlee = 0x2000160; + const int opcodeSetFleeExplicit = 0x2000161; + const int opcodeSetAlarm = 0x2000162; + const int opcodeSetAlarmExplicit = 0x2000163; + const int opcodeModHello = 0x20001b7; + const int opcodeModHelloExplicit = 0x20001b8; + const int opcodeModFight = 0x20001b9; + const int opcodeModFightExplicit = 0x20001ba; + const int opcodeModFlee = 0x20001bb; + const int opcodeModFleeExplicit = 0x20001bc; + const int opcodeModAlarm = 0x20001bd; + const int opcodeModAlarmExplicit = 0x20001be; + const int opcodeGetHello = 0x20001bf; + const int opcodeGetHelloExplicit = 0x20001c0; + const int opcodeGetFight = 0x20001c1; + const int opcodeGetFightExplicit = 0x20001c2; + const int opcodeGetFlee = 0x20001c3; + const int opcodeGetFleeExplicit = 0x20001c4; + const int opcodeGetAlarm = 0x20001c5; + const int opcodeGetAlarmExplicit = 0x20001c6; + } + + namespace Animation + { + const int opcodeSkipAnim = 0x2000138; + const int opcodeSkipAnimExplicit = 0x2000139; + const int opcodePlayAnim = 0x20006; + const int opcodePlayAnimExplicit = 0x20007; + const int opcodeLoopAnim = 0x20008; + const int opcodeLoopAnimExplicit = 0x20009; + } + + namespace Cell + { + const int opcodeCellChanged = 0x2000000; + const int opcodeCOC = 0x2000026; + const int opcodeCOE = 0x200008e; + const int opcodeGetInterior = 0x2000131; + const int opcodeGetPCCell = 0x2000136; + const int opcodeGetWaterLevel = 0x2000141; + const int opcodeSetWaterLevel = 0x2000142; + const int opcodeModWaterLevel = 0x2000143; + } + + namespace Console + { + + } + + namespace Container + { + const int opcodeAddItem = 0x2000076; + const int opcodeAddItemExplicit = 0x2000077; + const int opcodeGetItemCount = 0x2000078; + const int opcodeGetItemCountExplicit = 0x2000079; + const int opcodeRemoveItem = 0x200007a; + const int opcodeRemoveItemExplicit = 0x200007b; + const int opcodeEquip = 0x20001b3; + const int opcodeEquipExplicit = 0x20001b4; + const int opcodeGetArmorType = 0x20001d1; + const int opcodeGetArmorTypeExplicit = 0x20001d2; + const int opcodeHasItemEquipped = 0x20001d5; + const int opcodeHasItemEquippedExplicit = 0x20001d6; + const int opcodeHasSoulGem = 0x20001de; + const int opcodeHasSoulGemExplicit = 0x20001df; + const int opcodeGetWeaponType = 0x20001e0; + const int opcodeGetWeaponTypeExplicit = 0x20001e1; + } + + namespace Control + { + // not opcodes, but are required by apps/openmw and components/compiler + // do they belong here? + const int numberOfControls = 7; + + extern const char *controls[numberOfControls]; + + const int opcodeEnable = 0x200007e; + const int opcodeDisable = 0x2000085; + const int opcodeToggleCollision = 0x2000130; + const int opcodeClearForceRun = 0x2000154; + const int opcodeClearForceRunExplicit = 0x2000155; + const int opcodeForceRun = 0x2000156; + const int opcodeForceRunExplicit = 0x2000157; + const int opcodeClearForceSneak = 0x2000158; + const int opcodeClearForceSneakExplicit = 0x2000159; + const int opcodeForceSneak = 0x200015a; + const int opcodeForceSneakExplicit = 0x200015b; + const int opcodeGetDisabled = 0x2000175; + const int opcodeGetPcRunning = 0x20001c9; + const int opcodeGetPcSneaking = 0x20001ca; + const int opcodeGetForceRun = 0x20001cb; + const int opcodeGetForceSneak = 0x20001cc; + const int opcodeGetForceRunExplicit = 0x20001cd; + const int opcodeGetForceSneakExplicit = 0x20001ce; + } + + namespace Dialogue + { + const int opcodeJournal = 0x2000133; + const int opcodeSetJournalIndex = 0x2000134; + const int opcodeGetJournalIndex = 0x2000135; + const int opcodeAddTopic = 0x200013a; + const int opcodeChoice = 0x2000a; + const int opcodeForceGreeting = 0x200014f; + const int opcodeForceGreetingExplicit = 0x2000150; + const int opcodeGoodbye = 0x2000152; + const int opcodeSetReputation = 0x20001ad; + const int opcodeModReputation = 0x20001ae; + const int opcodeSetReputationExplicit = 0x20001af; + const int opcodeModReputationExplicit = 0x20001b0; + const int opcodeGetReputation = 0x20001b1; + const int opcodeGetReputationExplicit = 0x20001b2; + const int opcodeSameFaction = 0x20001b5; + const int opcodeSameFactionExplicit = 0x20001b6; + } + + namespace Gui + { + const int opcodeEnableBirthMenu = 0x200000e; + const int opcodeEnableClassMenu = 0x200000f; + const int opcodeEnableNameMenu = 0x2000010; + const int opcodeEnableRaceMenu = 0x2000011; + const int opcodeEnableStatsReviewMenu = 0x2000012; + const int opcodeEnableInventoryMenu = 0x2000013; + const int opcodeEnableMagicMenu = 0x2000014; + const int opcodeEnableMapMenu = 0x2000015; + const int opcodeEnableStatsMenu = 0x2000016; + const int opcodeEnableRest = 0x2000017; + const int opcodeShowRestMenu = 0x2000018; + const int opcodeGetButtonPressed = 0x2000137; + const int opcodeToggleFogOfWar = 0x2000145; + const int opcodeToggleFullHelp = 0x2000151; + const int opcodeShowMap = 0x20001a0; + const int opcodeFillMap = 0x20001a1; + } + + namespace Misc + { + 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; + const int opcodeToggleCollisionDebug = 0x2000132; + const int opcodeToggleCollisionBoxes = 0x20001ac; + const int opcodeToggleWireframe = 0x200013b; + const int opcodeFadeIn = 0x200013c; + const int opcodeFadeOut = 0x200013d; + const int opcodeFadeTo = 0x200013e; + const int opcodeToggleWater = 0x2000144; + const int opcodeTogglePathgrid = 0x2000146; + const int opcodeDontSaveObject = 0x2000153; + const int opcodeToggleVanityMode = 0x2000174; + const int opcodeGetPcSleep = 0x200019f; + const int opcodeWakeUpPc = 0x20001a2; + const int opcodeGetLocked = 0x20001c7; + const int opcodeGetLockedExplicit = 0x20001c8; + const int opcodeGetEffect = 0x20001cf; + const int opcodeGetEffectExplicit = 0x20001d0; + const int opcodeAddSoulGem = 0x20001f3; + const int opcodeAddSoulGemExplicit = 0x20001f4; + const int opcodeRemoveSoulGem = 0x20001f5; + const int opcodeRemoveSoulGemExplicit = 0x20001f6; + const int opcodeDrop = 0x20001f8; + const int opcodeDropExplicit = 0x20001f9; + const int opcodeDropSoulGem = 0x20001fa; + const int opcodeDropSoulGemExplicit = 0x20001fb; + const int opcodeGetAttacked = 0x20001d3; + const int opcodeGetAttackedExplicit = 0x20001d4; + const int opcodeGetWeaponDrawn = 0x20001d7; + const int opcodeGetWeaponDrawnExplicit = 0x20001d8; + const int opcodeGetSpellEffects = 0x20001db; + const int opcodeGetSpellEffectsExplicit = 0x20001dc; + const int opcodeGetCurrentTime = 0x20001dd; + const int opcodeSetDelete = 0x20001e5; + const int opcodeSetDeleteExplicit = 0x20001e6; + const int opcodeGetSquareRoot = 0x20001e7; + const int opcodeFall = 0x200020a; + const int opcodeFallExplicit = 0x200020b; + const int opcodeGetStandingPc = 0x200020c; + const int opcodeGetStandingPcExplicit = 0x200020d; + const int opcodeGetStandingActor = 0x200020e; + const int opcodeGetStandingActorExplicit = 0x200020f; + const int opcodeGetWindSpeed = 0x2000212; + const int opcodePlayBink = 0x20001f7; + const int opcodeHitOnMe = 0x2000213; + const int opcodeHitOnMeExplicit = 0x2000214; + const int opcodeDisableTeleporting = 0x2000215; + const int opcodeEnableTeleporting = 0x2000216; + } + + namespace Sky + { + const int opcodeToggleSky = 0x2000021; + const int opcodeTurnMoonWhite = 0x2000022; + const int opcodeTurnMoonRed = 0x2000023; + const int opcodeGetMasserPhase = 0x2000024; + const int opcodeGetSecundaPhase = 0x2000025; + const int opcodeGetCurrentWeather = 0x200013f; + const int opcodeChangeWeather = 0x2000140; + const int opcodeModRegion = 0x20026; + } + + namespace Sound + { + const int opcodeSay = 0x2000001; + const int opcodeSayDone = 0x2000002; + const int opcodeStreamMusic = 0x2000003; + const int opcodePlaySound = 0x2000004; + const int opcodePlaySoundVP = 0x2000005; + const int opcodePlaySound3D = 0x2000006; + const int opcodePlaySound3DVP = 0x2000007; + const int opcodePlayLoopSound3D = 0x2000008; + const int opcodePlayLoopSound3DVP = 0x2000009; + const int opcodeStopSound = 0x200000a; + const int opcodeGetSoundPlaying = 0x200000b; + + const int opcodeSayExplicit = 0x2000019; + const int opcodeSayDoneExplicit = 0x200001a; + const int opcodePlaySound3DExplicit = 0x200001b; + const int opcodePlaySound3DVPExplicit = 0x200001c; + const int opcodePlayLoopSound3DExplicit = 0x200001d; + const int opcodePlayLoopSound3DVPExplicit = 0x200001e; + const int opcodeStopSoundExplicit = 0x200001f; + const int opcodeGetSoundPlayingExplicit = 0x2000020; + } + + namespace Stats + { + // not opcodes, but are required by apps/openmw and components/compiler + // do they belong here? + const int numberOfAttributes = 8; + const int numberOfDynamics = 3; + const int numberOfSkills = 27; + + const int opcodeGetAttribute = 0x2000027; + const int opcodeGetAttributeExplicit = 0x200002f; + const int opcodeSetAttribute = 0x2000037; + const int opcodeSetAttributeExplicit = 0x200003f; + const int opcodeModAttribute = 0x2000047; + const int opcodeModAttributeExplicit = 0x200004f; + + const int opcodeGetDynamic = 0x2000057; + const int opcodeGetDynamicExplicit = 0x200005a; + const int opcodeSetDynamic = 0x200005d; + const int opcodeSetDynamicExplicit = 0x2000060; + const int opcodeModDynamic = 0x2000063; + const int opcodeModDynamicExplicit = 0x2000066; + const int opcodeModCurrentDynamic = 0x2000069; + const int opcodeModCurrentDynamicExplicit = 0x200006c; + const int opcodeGetDynamicGetRatio = 0x200006f; + const int opcodeGetDynamicGetRatioExplicit = 0x2000072; + + const int opcodeGetSkill = 0x200008e; + const int opcodeGetSkillExplicit = 0x20000a9; + const int opcodeSetSkill = 0x20000c4; + const int opcodeSetSkillExplicit = 0x20000df; + const int opcodeModSkill = 0x20000fa; + const int opcodeModSkillExplicit = 0x2000115; + + const int opcodeGetPCCrimeLevel = 0x20001ec; + const int opcodeSetPCCrimeLevel = 0x20001ed; + const int opcodeModPCCrimeLevel = 0x20001ee; + + const int opcodeAddSpell = 0x2000147; + const int opcodeAddSpellExplicit = 0x2000148; + const int opcodeRemoveSpell = 0x2000149; + const int opcodeRemoveSpellExplicit = 0x200014a; + const int opcodeGetSpell = 0x200014b; + const int opcodeGetSpellExplicit = 0x200014c; + + const int opcodePCRaiseRank = 0x2000b; + const int opcodePCLowerRank = 0x2000c; + const int opcodePCJoinFaction = 0x2000d; + const int opcodeGetPCRank = 0x2000e; + const int opcodeGetPCRankExplicit = 0x2000f; + const int opcodeModDisposition = 0x200014d; + const int opcodeModDispositionExplicit = 0x200014e; + const int opcodeSetDisposition = 0x20001a4; + const int opcodeSetDispositionExplicit = 0x20001a5; + const int opcodeGetDisposition = 0x20001a6; + const int opcodeGetDispositionExplicit = 0x20001a7; + + const int opcodeGetLevel = 0x200018c; + const int opcodeGetLevelExplicit = 0x200018d; + const int opcodeSetLevel = 0x200018e; + const int opcodeSetLevelExplicit = 0x200018f; + + const int opcodeGetDeadCount = 0x20001a3; + + const int opcodeGetPCFacRep = 0x20012; + const int opcodeGetPCFacRepExplicit = 0x20013; + const int opcodeSetPCFacRep = 0x20014; + const int opcodeSetPCFacRepExplicit = 0x20015; + const int opcodeModPCFacRep = 0x20016; + const int opcodeModPCFacRepExplicit = 0x20017; + + const int opcodeGetCommonDisease = 0x20001a8; + const int opcodeGetCommonDiseaseExplicit = 0x20001a9; + const int opcodeGetBlightDisease = 0x20001aa; + const int opcodeGetBlightDiseaseExplicit = 0x20001ab; + + const int opcodeGetRace = 0x20001d9; + const int opcodeGetRaceExplicit = 0x20001da; + + const int opcodeGetWerewolfKills = 0x20001e2; + + const int opcodePcExpelled = 0x20018; + const int opcodePcExpelledExplicit = 0x20019; + const int opcodePcExpell = 0x2001a; + const int opcodePcExpellExplicit = 0x2001b; + const int opcodePcClearExpelled = 0x2001c; + const int opcodePcClearExpelledExplicit = 0x2001d; + const int opcodeRaiseRank = 0x20001e8; + const int opcodeRaiseRankExplicit = 0x20001e9; + const int opcodeLowerRank = 0x20001ea; + const int opcodeLowerRankExplicit = 0x20001eb; + const int opcodeOnDeath = 0x20001fc; + const int opcodeOnDeathExplicit = 0x2000205; + const int opcodeIsWerewolf = 0x20001fd; + const int opcodeIsWerewolfExplicit = 0x20001fe; + } + + namespace Transformation + { + const int opcodeSetScale = 0x2000164; + const int opcodeSetScaleExplicit = 0x2000165; + const int opcodeSetAngle = 0x2000166; + const int opcodeSetAngleExplicit = 0x2000167; + const int opcodeGetScale = 0x2000168; + const int opcodeGetScaleExplicit = 0x2000169; + const int opcodeGetAngle = 0x200016a; + const int opcodeGetAngleExplicit = 0x200016b; + const int opcodeGetPos = 0x2000190; + const int opcodeGetPosExplicit = 0x2000191; + const int opcodeSetPos = 0x2000192; + const int opcodeSetPosExplicit = 0x2000193; + const int opcodeGetStartingPos = 0x2000194; + const int opcodeGetStartingPosExplicit = 0x2000195; + const int opcodeGetStartingAngle = 0x2000210; + const int opcodeGetStartingAngleExplicit = 0x2000211; + const int opcodePosition = 0x2000196; + const int opcodePositionExplicit = 0x2000197; + const int opcodePositionCell = 0x2000198; + const int opcodePositionCellExplicit = 0x2000199; + + const int opcodePlaceItemCell = 0x200019a; + const int opcodePlaceItem = 0x200019b; + const int opcodePlaceAtPc = 0x200019c; + const int opcodePlaceAtMe = 0x200019d; + const int opcodePlaceAtMeExplicit = 0x200019e; + const int opcodeModScale = 0x20001e3; + const int opcodeModScaleExplicit = 0x20001e4; + const int opcodeRotate = 0x20001ff; + const int opcodeRotateExplicit = 0x2000200; + const int opcodeRotateWorld = 0x2000201; + const int opcodeRotateWorldExplicit = 0x2000202; + const int opcodeSetAtStart = 0x2000203; + const int opcodeSetAtStartExplicit = 0x2000204; + const int opcodeMove = 0x2000206; + const int opcodeMoveExplicit = 0x2000207; + const int opcodeMoveWorld = 0x2000208; + const int opcodeMoveWorldExplicit = 0x2000209; + } + + namespace User + { + const int opcodeUser1 = 0x200016c; + const int opcodeUser2 = 0x200016d; + const int opcodeUser3 = 0x200016e; + const int opcodeUser3Explicit = 0x200016f; + const int opcodeUser4 = 0x2000170; + const int opcodeUser4Explicit = 0x2000171; + } +} + +#endif \ No newline at end of file diff --git a/components/compiler/registerextensions.cpp b/components/compiler/registerextensions.cpp new file mode 100644 index 0000000000..274b7f06eb --- /dev/null +++ b/components/compiler/registerextensions.cpp @@ -0,0 +1,461 @@ +#include "registerextensions.hpp" + +#include "opcodes.hpp" +#include "extensions.hpp" + +namespace Compiler +{ + void registerExtensions (Extensions& extensions, bool consoleOnly) + { + Ai::registerExtensions (extensions); + Animation::registerExtensions (extensions); + Cell::registerExtensions (extensions); + Container::registerExtensions (extensions); + Control::registerExtensions (extensions); + Dialogue::registerExtensions (extensions); + Gui::registerExtensions (extensions); + Misc::registerExtensions (extensions); + Sky::registerExtensions (extensions); + Sound::registerExtensions (extensions); + Stats::registerExtensions (extensions); + Transformation::registerExtensions (extensions); + + if (consoleOnly) + { + Console::registerExtensions (extensions); + User::registerExtensions (extensions); + } + } + + namespace Ai + { + void registerExtensions (Extensions& extensions) + { + extensions.registerInstruction ("aiactivate", "c/l", opcodeAIActivate, + opcodeAIActivateExplicit); + extensions.registerInstruction ("aitravel", "fff/l", opcodeAiTravel, + opcodeAiTravelExplicit); + extensions.registerInstruction ("aiescort", "cffff/l", opcodeAiEscort, + opcodeAiEscortExplicit); + extensions.registerInstruction ("aiescortcell", "ccffff/l", opcodeAiEscortCell, + opcodeAiEscortCellExplicit); + extensions.registerInstruction ("aiwander", "fff/llllllllll", opcodeAiWander, + opcodeAiWanderExplicit); + extensions.registerInstruction ("aifollow", "cffff/l", opcodeAiFollow, + opcodeAiFollowExplicit); + extensions.registerInstruction ("aifollowcell", "ccffff/l", opcodeAiFollowCell, + opcodeAiFollowCellExplicit); + extensions.registerFunction ("getaipackagedone", 'l', "", opcodeGetAiPackageDone, + opcodeGetAiPackageDoneExplicit); + extensions.registerFunction ("getcurrentaipackage", 'l', "", opcodeGetCurrentAiPackage, + opcodeGetAiPackageDoneExplicit); + extensions.registerFunction ("getdetected", 'l', "c", opcodeGetDetected, + opcodeGetDetectedExplicit); + extensions.registerInstruction ("sethello", "l", opcodeSetHello, opcodeSetHelloExplicit); + extensions.registerInstruction ("setfight", "l", opcodeSetFight, opcodeSetFightExplicit); + extensions.registerInstruction ("setflee", "l", opcodeSetFlee, opcodeSetFleeExplicit); + extensions.registerInstruction ("setalarm", "l", opcodeSetAlarm, opcodeSetAlarmExplicit); + extensions.registerInstruction ("modhello", "l", opcodeModHello, opcodeModHelloExplicit); + extensions.registerInstruction ("modfight", "l", opcodeModFight, opcodeModFightExplicit); + extensions.registerInstruction ("modflee", "l", opcodeModFlee, opcodeModFleeExplicit); + extensions.registerInstruction ("modalarm", "l", opcodeModAlarm, opcodeModAlarmExplicit); + extensions.registerFunction ("gethello", 'l', "", opcodeGetHello, opcodeGetHelloExplicit); + extensions.registerFunction ("getfight", 'l', "", opcodeGetFight, opcodeGetFightExplicit); + extensions.registerFunction ("getflee", 'l', "", opcodeGetFlee, opcodeGetFleeExplicit); + extensions.registerFunction ("getalarm", 'l', "", opcodeGetAlarm, opcodeGetAlarmExplicit); + } + } + + namespace Animation + { + void registerExtensions (Extensions& extensions) + { + extensions.registerInstruction ("skipanim", "", opcodeSkipAnim, opcodeSkipAnimExplicit); + extensions.registerInstruction ("playgroup", "c/l", opcodePlayAnim, opcodePlayAnimExplicit); + extensions.registerInstruction ("loopgroup", "cl/l", opcodeLoopAnim, opcodeLoopAnimExplicit); + } + } + + namespace Cell + { + void registerExtensions (Extensions& extensions) + { + extensions.registerFunction ("cellchanged", 'l', "", opcodeCellChanged); + extensions.registerInstruction ("coc", "S", opcodeCOC); + extensions.registerInstruction ("centeroncell", "S", opcodeCOC); + extensions.registerInstruction ("coe", "ll", opcodeCOE); + extensions.registerInstruction ("centeronexterior", "ll", opcodeCOE); + extensions.registerInstruction ("setwaterlevel", "f", opcodeSetWaterLevel); + extensions.registerInstruction ("modwaterlevel", "f", opcodeModWaterLevel); + extensions.registerFunction ("getinterior", 'l', "", opcodeGetInterior); + extensions.registerFunction ("getpccell", 'l', "c", opcodeGetPCCell); + extensions.registerFunction ("getwaterlevel", 'f', "", opcodeGetWaterLevel); + } + } + + namespace Console + { + void registerExtensions (Extensions& extensions) + { + + } + } + + namespace Container + { + void registerExtensions (Extensions& extensions) + { + extensions.registerInstruction ("additem", "cl", opcodeAddItem, opcodeAddItemExplicit); + extensions.registerFunction ("getitemcount", 'l', "c", opcodeGetItemCount, + opcodeGetItemCountExplicit); + extensions.registerInstruction ("removeitem", "cl", opcodeRemoveItem, + opcodeRemoveItemExplicit); + extensions.registerInstruction ("equip", "c", opcodeEquip, opcodeEquipExplicit); + extensions.registerFunction ("getarmortype", 'l', "l", opcodeGetArmorType, opcodeGetArmorTypeExplicit); + extensions.registerFunction ("hasitemequipped", 'l', "c", opcodeHasItemEquipped, opcodeHasItemEquippedExplicit); + extensions.registerFunction ("hassoulgem", 'l', "c", opcodeHasSoulGem, opcodeHasSoulGemExplicit); + extensions.registerFunction ("getweapontype", 'l', "", opcodeGetWeaponType, opcodeGetWeaponTypeExplicit); + } + } + + namespace Control + { + void registerExtensions (Extensions& extensions) + { + std::string enable ("enable"); + std::string disable ("disable"); + + for (int i=0; i