From 34723c8ea8e451c3a205ec3f4b93f2164ccb5a8d Mon Sep 17 00:00:00 2001 From: Matt <3397065-ZehMatt@users.noreply.gitlab.com> Date: Thu, 27 Jan 2022 19:18:57 +0000 Subject: [PATCH] Cleanup interpreter code a bit --- CHANGELOG.md | 1 + apps/openmw/mwscript/aiextensions.cpp | 123 +++++---- apps/openmw/mwscript/animationextensions.cpp | 12 +- apps/openmw/mwscript/cellextensions.cpp | 20 +- apps/openmw/mwscript/containerextensions.cpp | 32 +-- apps/openmw/mwscript/controlextensions.cpp | 82 +++--- apps/openmw/mwscript/dialogueextensions.cpp | 44 +-- apps/openmw/mwscript/guiextensions.cpp | 66 ++--- apps/openmw/mwscript/miscextensions.cpp | 238 ++++++++--------- apps/openmw/mwscript/skyextensions.cpp | 16 +- apps/openmw/mwscript/soundextensions.cpp | 64 ++--- apps/openmw/mwscript/statsextensions.cpp | 250 +++++++++--------- .../mwscript/transformationextensions.cpp | 82 +++--- apps/openmw/mwscript/userextensions.cpp | 12 +- .../mwscript/test_scripts.cpp | 12 +- components/interpreter/installopcodes.cpp | 134 +++++----- components/interpreter/interpreter.cpp | 132 +++------ components/interpreter/interpreter.hpp | 62 +++-- components/interpreter/localopcodes.hpp | 42 +-- 19 files changed, 647 insertions(+), 777 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c45d15e6d..c8a17898f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -130,6 +130,7 @@ Feature #6534: Shader-based object texture blending Task #6201: Remove the "Note: No relevant classes found. No output generated" warnings Task #6264: Remove the old classes in animation.cpp + Task #6553: Simplify interpreter instruction registration 0.47.0 ------ diff --git a/apps/openmw/mwscript/aiextensions.cpp b/apps/openmw/mwscript/aiextensions.cpp index b7b6de9463..f862508ee4 100644 --- a/apps/openmw/mwscript/aiextensions.cpp +++ b/apps/openmw/mwscript/aiextensions.cpp @@ -553,69 +553,68 @@ namespace MWScript } }; - void installOpcodes (Interpreter::Interpreter& interpreter) + void installOpcodes(Interpreter::Interpreter& interpreter) { - 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 (Compiler::Ai::opcodeGetAiPackageDoneExplicit, - new OpGetAiPackageDone); - interpreter.installSegment5 (Compiler::Ai::opcodeGetCurrentAiPackage, new OpGetCurrentAIPackage); - interpreter.installSegment5 (Compiler::Ai::opcodeGetCurrentAiPackageExplicit, new OpGetCurrentAIPackage); - interpreter.installSegment5 (Compiler::Ai::opcodeGetDetected, new OpGetDetected); - interpreter.installSegment5 (Compiler::Ai::opcodeGetDetectedExplicit, new OpGetDetected); - interpreter.installSegment5 (Compiler::Ai::opcodeGetLineOfSight, new OpGetLineOfSight); - interpreter.installSegment5 (Compiler::Ai::opcodeGetLineOfSightExplicit, new OpGetLineOfSight); - interpreter.installSegment5 (Compiler::Ai::opcodeGetTarget, new OpGetTarget); - interpreter.installSegment5 (Compiler::Ai::opcodeGetTargetExplicit, new OpGetTarget); - interpreter.installSegment5 (Compiler::Ai::opcodeStartCombat, new OpStartCombat); - interpreter.installSegment5 (Compiler::Ai::opcodeStartCombatExplicit, new OpStartCombat); - interpreter.installSegment5 (Compiler::Ai::opcodeStopCombat, new OpStopCombat); - interpreter.installSegment5 (Compiler::Ai::opcodeStopCombatExplicit, new OpStopCombat); - interpreter.installSegment5 (Compiler::Ai::opcodeToggleAI, new OpToggleAI); - - interpreter.installSegment5 (Compiler::Ai::opcodeSetHello, new OpSetAiSetting(MWMechanics::CreatureStats::AiSetting::AI_Hello)); - interpreter.installSegment5 (Compiler::Ai::opcodeSetHelloExplicit, new OpSetAiSetting(MWMechanics::CreatureStats::AiSetting::AI_Hello)); - interpreter.installSegment5 (Compiler::Ai::opcodeSetFight, new OpSetAiSetting(MWMechanics::CreatureStats::AiSetting::AI_Fight)); - interpreter.installSegment5 (Compiler::Ai::opcodeSetFightExplicit, new OpSetAiSetting(MWMechanics::CreatureStats::AiSetting::AI_Fight)); - interpreter.installSegment5 (Compiler::Ai::opcodeSetFlee, new OpSetAiSetting(MWMechanics::CreatureStats::AiSetting::AI_Flee)); - interpreter.installSegment5 (Compiler::Ai::opcodeSetFleeExplicit, new OpSetAiSetting(MWMechanics::CreatureStats::AiSetting::AI_Flee)); - interpreter.installSegment5 (Compiler::Ai::opcodeSetAlarm, new OpSetAiSetting(MWMechanics::CreatureStats::AiSetting::AI_Alarm)); - interpreter.installSegment5 (Compiler::Ai::opcodeSetAlarmExplicit, new OpSetAiSetting(MWMechanics::CreatureStats::AiSetting::AI_Alarm)); - - interpreter.installSegment5 (Compiler::Ai::opcodeModHello, new OpModAiSetting(MWMechanics::CreatureStats::AiSetting::AI_Hello)); - interpreter.installSegment5 (Compiler::Ai::opcodeModHelloExplicit, new OpModAiSetting(MWMechanics::CreatureStats::AiSetting::AI_Hello)); - interpreter.installSegment5 (Compiler::Ai::opcodeModFight, new OpModAiSetting(MWMechanics::CreatureStats::AiSetting::AI_Fight)); - interpreter.installSegment5 (Compiler::Ai::opcodeModFightExplicit, new OpModAiSetting(MWMechanics::CreatureStats::AiSetting::AI_Fight)); - interpreter.installSegment5 (Compiler::Ai::opcodeModFlee, new OpModAiSetting(MWMechanics::CreatureStats::AiSetting::AI_Flee)); - interpreter.installSegment5 (Compiler::Ai::opcodeModFleeExplicit, new OpModAiSetting(MWMechanics::CreatureStats::AiSetting::AI_Flee)); - interpreter.installSegment5 (Compiler::Ai::opcodeModAlarm, new OpModAiSetting(MWMechanics::CreatureStats::AiSetting::AI_Alarm)); - interpreter.installSegment5 (Compiler::Ai::opcodeModAlarmExplicit, new OpModAiSetting(MWMechanics::CreatureStats::AiSetting::AI_Alarm)); - - interpreter.installSegment5 (Compiler::Ai::opcodeGetHello, new OpGetAiSetting(MWMechanics::CreatureStats::AiSetting::AI_Hello)); - interpreter.installSegment5 (Compiler::Ai::opcodeGetHelloExplicit, new OpGetAiSetting(MWMechanics::CreatureStats::AiSetting::AI_Hello)); - interpreter.installSegment5 (Compiler::Ai::opcodeGetFight, new OpGetAiSetting(MWMechanics::CreatureStats::AiSetting::AI_Fight)); - interpreter.installSegment5 (Compiler::Ai::opcodeGetFightExplicit, new OpGetAiSetting(MWMechanics::CreatureStats::AiSetting::AI_Fight)); - interpreter.installSegment5 (Compiler::Ai::opcodeGetFlee, new OpGetAiSetting(MWMechanics::CreatureStats::AiSetting::AI_Flee)); - interpreter.installSegment5 (Compiler::Ai::opcodeGetFleeExplicit, new OpGetAiSetting(MWMechanics::CreatureStats::AiSetting::AI_Flee)); - interpreter.installSegment5 (Compiler::Ai::opcodeGetAlarm, new OpGetAiSetting(MWMechanics::CreatureStats::AiSetting::AI_Alarm)); - interpreter.installSegment5 (Compiler::Ai::opcodeGetAlarmExplicit, new OpGetAiSetting(MWMechanics::CreatureStats::AiSetting::AI_Alarm)); - - interpreter.installSegment5 (Compiler::Ai::opcodeFace, new OpFace); - interpreter.installSegment5 (Compiler::Ai::opcodeFaceExplicit, new OpFace); + interpreter.installSegment3>(Compiler::Ai::opcodeAIActivate); + interpreter.installSegment3>(Compiler::Ai::opcodeAIActivateExplicit); + interpreter.installSegment3>(Compiler::Ai::opcodeAiTravel); + interpreter.installSegment3>(Compiler::Ai::opcodeAiTravelExplicit); + interpreter.installSegment3>(Compiler::Ai::opcodeAiEscort); + interpreter.installSegment3>(Compiler::Ai::opcodeAiEscortExplicit); + interpreter.installSegment3>(Compiler::Ai::opcodeAiEscortCell); + interpreter.installSegment3>(Compiler::Ai::opcodeAiEscortCellExplicit); + interpreter.installSegment3>(Compiler::Ai::opcodeAiWander); + interpreter.installSegment3>(Compiler::Ai::opcodeAiWanderExplicit); + interpreter.installSegment3>(Compiler::Ai::opcodeAiFollow); + interpreter.installSegment3>(Compiler::Ai::opcodeAiFollowExplicit); + interpreter.installSegment3>(Compiler::Ai::opcodeAiFollowCell); + interpreter.installSegment3>(Compiler::Ai::opcodeAiFollowCellExplicit); + interpreter.installSegment5>(Compiler::Ai::opcodeGetAiPackageDone); + + interpreter.installSegment5>(Compiler::Ai::opcodeGetAiPackageDoneExplicit); + interpreter.installSegment5>(Compiler::Ai::opcodeGetCurrentAiPackage); + interpreter.installSegment5>(Compiler::Ai::opcodeGetCurrentAiPackageExplicit); + interpreter.installSegment5>(Compiler::Ai::opcodeGetDetected); + interpreter.installSegment5>(Compiler::Ai::opcodeGetDetectedExplicit); + interpreter.installSegment5>(Compiler::Ai::opcodeGetLineOfSight); + interpreter.installSegment5>(Compiler::Ai::opcodeGetLineOfSightExplicit); + interpreter.installSegment5>(Compiler::Ai::opcodeGetTarget); + interpreter.installSegment5>(Compiler::Ai::opcodeGetTargetExplicit); + interpreter.installSegment5>(Compiler::Ai::opcodeStartCombat); + interpreter.installSegment5>(Compiler::Ai::opcodeStartCombatExplicit); + interpreter.installSegment5>(Compiler::Ai::opcodeStopCombat); + interpreter.installSegment5>(Compiler::Ai::opcodeStopCombatExplicit); + interpreter.installSegment5(Compiler::Ai::opcodeToggleAI); + + interpreter.installSegment5>(Compiler::Ai::opcodeSetHello, MWMechanics::CreatureStats::AiSetting::AI_Hello); + interpreter.installSegment5>(Compiler::Ai::opcodeSetHelloExplicit, MWMechanics::CreatureStats::AiSetting::AI_Hello); + interpreter.installSegment5>(Compiler::Ai::opcodeSetFight, MWMechanics::CreatureStats::AiSetting::AI_Fight); + interpreter.installSegment5>(Compiler::Ai::opcodeSetFightExplicit, MWMechanics::CreatureStats::AiSetting::AI_Fight); + interpreter.installSegment5>(Compiler::Ai::opcodeSetFlee, MWMechanics::CreatureStats::AiSetting::AI_Flee); + interpreter.installSegment5>(Compiler::Ai::opcodeSetFleeExplicit, MWMechanics::CreatureStats::AiSetting::AI_Flee); + interpreter.installSegment5>(Compiler::Ai::opcodeSetAlarm, MWMechanics::CreatureStats::AiSetting::AI_Alarm); + interpreter.installSegment5>(Compiler::Ai::opcodeSetAlarmExplicit, MWMechanics::CreatureStats::AiSetting::AI_Alarm); + + interpreter.installSegment5>(Compiler::Ai::opcodeModHello, MWMechanics::CreatureStats::AiSetting::AI_Hello); + interpreter.installSegment5>(Compiler::Ai::opcodeModHelloExplicit, MWMechanics::CreatureStats::AiSetting::AI_Hello); + interpreter.installSegment5>(Compiler::Ai::opcodeModFight, MWMechanics::CreatureStats::AiSetting::AI_Fight); + interpreter.installSegment5>(Compiler::Ai::opcodeModFightExplicit, MWMechanics::CreatureStats::AiSetting::AI_Fight); + interpreter.installSegment5>(Compiler::Ai::opcodeModFlee, MWMechanics::CreatureStats::AiSetting::AI_Flee); + interpreter.installSegment5>(Compiler::Ai::opcodeModFleeExplicit, MWMechanics::CreatureStats::AiSetting::AI_Flee); + interpreter.installSegment5>(Compiler::Ai::opcodeModAlarm, MWMechanics::CreatureStats::AiSetting::AI_Alarm); + interpreter.installSegment5>(Compiler::Ai::opcodeModAlarmExplicit, MWMechanics::CreatureStats::AiSetting::AI_Alarm); + + interpreter.installSegment5>(Compiler::Ai::opcodeGetHello, MWMechanics::CreatureStats::AiSetting::AI_Hello); + interpreter.installSegment5>(Compiler::Ai::opcodeGetHelloExplicit, MWMechanics::CreatureStats::AiSetting::AI_Hello); + interpreter.installSegment5>(Compiler::Ai::opcodeGetFight, MWMechanics::CreatureStats::AiSetting::AI_Fight); + interpreter.installSegment5>(Compiler::Ai::opcodeGetFightExplicit, MWMechanics::CreatureStats::AiSetting::AI_Fight); + interpreter.installSegment5>(Compiler::Ai::opcodeGetFlee, MWMechanics::CreatureStats::AiSetting::AI_Flee); + interpreter.installSegment5>(Compiler::Ai::opcodeGetFleeExplicit, MWMechanics::CreatureStats::AiSetting::AI_Flee); + interpreter.installSegment5>(Compiler::Ai::opcodeGetAlarm, MWMechanics::CreatureStats::AiSetting::AI_Alarm); + interpreter.installSegment5>(Compiler::Ai::opcodeGetAlarmExplicit, MWMechanics::CreatureStats::AiSetting::AI_Alarm); + + interpreter.installSegment5>(Compiler::Ai::opcodeFace); + interpreter.installSegment5>(Compiler::Ai::opcodeFaceExplicit); } } } diff --git a/apps/openmw/mwscript/animationextensions.cpp b/apps/openmw/mwscript/animationextensions.cpp index 8bb6cc6ada..9320c86a88 100644 --- a/apps/openmw/mwscript/animationextensions.cpp +++ b/apps/openmw/mwscript/animationextensions.cpp @@ -101,12 +101,12 @@ namespace MWScript void installOpcodes (Interpreter::Interpreter& interpreter) { - 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); + interpreter.installSegment5>(Compiler::Animation::opcodeSkipAnim); + interpreter.installSegment5>(Compiler::Animation::opcodeSkipAnimExplicit); + interpreter.installSegment3>(Compiler::Animation::opcodePlayAnim); + interpreter.installSegment3>(Compiler::Animation::opcodePlayAnimExplicit); + interpreter.installSegment3>(Compiler::Animation::opcodeLoopAnim); + interpreter.installSegment3>(Compiler::Animation::opcodeLoopAnimExplicit); } } } diff --git a/apps/openmw/mwscript/cellextensions.cpp b/apps/openmw/mwscript/cellextensions.cpp index b0977984fb..d5ac222244 100644 --- a/apps/openmw/mwscript/cellextensions.cpp +++ b/apps/openmw/mwscript/cellextensions.cpp @@ -250,16 +250,16 @@ namespace MWScript void installOpcodes (Interpreter::Interpreter& interpreter) { - interpreter.installSegment5 (Compiler::Cell::opcodeCellChanged, new OpCellChanged); - interpreter.installSegment5 (Compiler::Cell::opcodeTestCells, new OpTestCells); - interpreter.installSegment5 (Compiler::Cell::opcodeTestInteriorCells, new OpTestInteriorCells); - 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); + interpreter.installSegment5(Compiler::Cell::opcodeCellChanged); + interpreter.installSegment5(Compiler::Cell::opcodeTestCells); + interpreter.installSegment5(Compiler::Cell::opcodeTestInteriorCells); + interpreter.installSegment5(Compiler::Cell::opcodeCOC); + interpreter.installSegment5(Compiler::Cell::opcodeCOE); + interpreter.installSegment5(Compiler::Cell::opcodeGetInterior); + interpreter.installSegment5(Compiler::Cell::opcodeGetPCCell); + interpreter.installSegment5(Compiler::Cell::opcodeGetWaterLevel); + interpreter.installSegment5(Compiler::Cell::opcodeSetWaterLevel); + interpreter.installSegment5(Compiler::Cell::opcodeModWaterLevel); } } } diff --git a/apps/openmw/mwscript/containerextensions.cpp b/apps/openmw/mwscript/containerextensions.cpp index 501404e958..ec86ba4869 100644 --- a/apps/openmw/mwscript/containerextensions.cpp +++ b/apps/openmw/mwscript/containerextensions.cpp @@ -488,22 +488,22 @@ namespace MWScript void installOpcodes (Interpreter::Interpreter& interpreter) { - 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); + interpreter.installSegment5>(Compiler::Container::opcodeAddItem); + interpreter.installSegment5>(Compiler::Container::opcodeAddItemExplicit); + interpreter.installSegment5>(Compiler::Container::opcodeGetItemCount); + interpreter.installSegment5>(Compiler::Container::opcodeGetItemCountExplicit); + interpreter.installSegment5>(Compiler::Container::opcodeRemoveItem); + interpreter.installSegment5>(Compiler::Container::opcodeRemoveItemExplicit); + interpreter.installSegment5>(Compiler::Container::opcodeEquip); + interpreter.installSegment5>(Compiler::Container::opcodeEquipExplicit); + interpreter.installSegment5>(Compiler::Container::opcodeGetArmorType); + interpreter.installSegment5>(Compiler::Container::opcodeGetArmorTypeExplicit); + interpreter.installSegment5>(Compiler::Container::opcodeHasItemEquipped); + interpreter.installSegment5>(Compiler::Container::opcodeHasItemEquippedExplicit); + interpreter.installSegment5>(Compiler::Container::opcodeHasSoulGem); + interpreter.installSegment5>(Compiler::Container::opcodeHasSoulGemExplicit); + interpreter.installSegment5>(Compiler::Container::opcodeGetWeaponType); + interpreter.installSegment5>(Compiler::Container::opcodeGetWeaponTypeExplicit); } } } diff --git a/apps/openmw/mwscript/controlextensions.cpp b/apps/openmw/mwscript/controlextensions.cpp index 2716630d72..74d2067394 100644 --- a/apps/openmw/mwscript/controlextensions.cpp +++ b/apps/openmw/mwscript/controlextensions.cpp @@ -188,67 +188,51 @@ namespace MWScript }; - void installOpcodes (Interpreter::Interpreter& interpreter) + void installOpcodes(Interpreter::Interpreter& interpreter) { - for (int i=0; i(Compiler::Control::opcodeEnable + i, Compiler::Control::controls[i], true); + interpreter.installSegment5(Compiler::Control::opcodeDisable + i, Compiler::Control::controls[i], false); + interpreter.installSegment5(Compiler::Control::opcodeGetDisabled + i, Compiler::Control::controls[i]); } - interpreter.installSegment5 (Compiler::Control::opcodeToggleCollision, new OpToggleCollision); + interpreter.installSegment5(Compiler::Control::opcodeToggleCollision); //Force Run - interpreter.installSegment5 (Compiler::Control::opcodeClearForceRun, - new OpClearMovementFlag (MWMechanics::CreatureStats::Flag_ForceRun)); - interpreter.installSegment5 (Compiler::Control::opcodeClearForceRunExplicit, - new OpClearMovementFlag (MWMechanics::CreatureStats::Flag_ForceRun)); - interpreter.installSegment5 (Compiler::Control::opcodeForceRun, - new OpSetMovementFlag (MWMechanics::CreatureStats::Flag_ForceRun)); - interpreter.installSegment5 (Compiler::Control::opcodeForceRunExplicit, - new OpSetMovementFlag (MWMechanics::CreatureStats::Flag_ForceRun)); + interpreter.installSegment5>(Compiler::Control::opcodeClearForceRun, MWMechanics::CreatureStats::Flag_ForceRun); + interpreter.installSegment5>(Compiler::Control::opcodeClearForceRunExplicit, MWMechanics::CreatureStats::Flag_ForceRun); + interpreter.installSegment5>(Compiler::Control::opcodeForceRun, MWMechanics::CreatureStats::Flag_ForceRun); + interpreter.installSegment5>(Compiler::Control::opcodeForceRunExplicit, MWMechanics::CreatureStats::Flag_ForceRun); //Force Jump - interpreter.installSegment5 (Compiler::Control::opcodeClearForceJump, - new OpClearMovementFlag (MWMechanics::CreatureStats::Flag_ForceJump)); - interpreter.installSegment5 (Compiler::Control::opcodeClearForceJumpExplicit, - new OpClearMovementFlag (MWMechanics::CreatureStats::Flag_ForceJump)); - interpreter.installSegment5 (Compiler::Control::opcodeForceJump, - new OpSetMovementFlag (MWMechanics::CreatureStats::Flag_ForceJump)); - interpreter.installSegment5 (Compiler::Control::opcodeForceJumpExplicit, - new OpSetMovementFlag (MWMechanics::CreatureStats::Flag_ForceJump)); + interpreter.installSegment5>(Compiler::Control::opcodeClearForceJump, MWMechanics::CreatureStats::Flag_ForceJump); + interpreter.installSegment5>(Compiler::Control::opcodeClearForceJumpExplicit, MWMechanics::CreatureStats::Flag_ForceJump); + interpreter.installSegment5>(Compiler::Control::opcodeForceJump, MWMechanics::CreatureStats::Flag_ForceJump); + interpreter.installSegment5>(Compiler::Control::opcodeForceJumpExplicit, MWMechanics::CreatureStats::Flag_ForceJump); //Force MoveJump - interpreter.installSegment5 (Compiler::Control::opcodeClearForceMoveJump, - new OpClearMovementFlag (MWMechanics::CreatureStats::Flag_ForceMoveJump)); - interpreter.installSegment5 (Compiler::Control::opcodeClearForceMoveJumpExplicit, - new OpClearMovementFlag (MWMechanics::CreatureStats::Flag_ForceMoveJump)); - interpreter.installSegment5 (Compiler::Control::opcodeForceMoveJump, - new OpSetMovementFlag (MWMechanics::CreatureStats::Flag_ForceMoveJump)); - interpreter.installSegment5 (Compiler::Control::opcodeForceMoveJumpExplicit, - new OpSetMovementFlag (MWMechanics::CreatureStats::Flag_ForceMoveJump)); + interpreter.installSegment5>(Compiler::Control::opcodeClearForceMoveJump, MWMechanics::CreatureStats::Flag_ForceMoveJump); + interpreter.installSegment5>(Compiler::Control::opcodeClearForceMoveJumpExplicit, MWMechanics::CreatureStats::Flag_ForceMoveJump); + interpreter.installSegment5>(Compiler::Control::opcodeForceMoveJump, MWMechanics::CreatureStats::Flag_ForceMoveJump); + interpreter.installSegment5>(Compiler::Control::opcodeForceMoveJumpExplicit, MWMechanics::CreatureStats::Flag_ForceMoveJump); //Force Sneak - interpreter.installSegment5 (Compiler::Control::opcodeClearForceSneak, - new OpClearMovementFlag (MWMechanics::CreatureStats::Flag_ForceSneak)); - interpreter.installSegment5 (Compiler::Control::opcodeClearForceSneakExplicit, - new OpClearMovementFlag (MWMechanics::CreatureStats::Flag_ForceSneak)); - interpreter.installSegment5 (Compiler::Control::opcodeForceSneak, - new OpSetMovementFlag (MWMechanics::CreatureStats::Flag_ForceSneak)); - interpreter.installSegment5 (Compiler::Control::opcodeForceSneakExplicit, - new OpSetMovementFlag (MWMechanics::CreatureStats::Flag_ForceSneak)); - - 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::opcodeGetForceJump, new OpGetForceJump); - interpreter.installSegment5 (Compiler::Control::opcodeGetForceJumpExplicit, new OpGetForceJump); - interpreter.installSegment5 (Compiler::Control::opcodeGetForceMoveJump, new OpGetForceMoveJump); - interpreter.installSegment5 (Compiler::Control::opcodeGetForceMoveJumpExplicit, new OpGetForceMoveJump); - interpreter.installSegment5 (Compiler::Control::opcodeGetForceSneak, new OpGetForceSneak); - interpreter.installSegment5 (Compiler::Control::opcodeGetForceSneakExplicit, new OpGetForceSneak); + interpreter.installSegment5>(Compiler::Control::opcodeClearForceSneak, MWMechanics::CreatureStats::Flag_ForceSneak); + interpreter.installSegment5>(Compiler::Control::opcodeClearForceSneakExplicit, MWMechanics::CreatureStats::Flag_ForceSneak); + interpreter.installSegment5>(Compiler::Control::opcodeForceSneak, MWMechanics::CreatureStats::Flag_ForceSneak); + interpreter.installSegment5>(Compiler::Control::opcodeForceSneakExplicit, MWMechanics::CreatureStats::Flag_ForceSneak); + + interpreter.installSegment5(Compiler::Control::opcodeGetPcRunning); + interpreter.installSegment5(Compiler::Control::opcodeGetPcSneaking); + interpreter.installSegment5>(Compiler::Control::opcodeGetForceRun); + interpreter.installSegment5>(Compiler::Control::opcodeGetForceRunExplicit); + interpreter.installSegment5>(Compiler::Control::opcodeGetForceJump); + interpreter.installSegment5>(Compiler::Control::opcodeGetForceJumpExplicit); + interpreter.installSegment5>(Compiler::Control::opcodeGetForceMoveJump); + interpreter.installSegment5>(Compiler::Control::opcodeGetForceMoveJumpExplicit); + interpreter.installSegment5>(Compiler::Control::opcodeGetForceSneak); + interpreter.installSegment5>(Compiler::Control::opcodeGetForceSneakExplicit); } } } diff --git a/apps/openmw/mwscript/dialogueextensions.cpp b/apps/openmw/mwscript/dialogueextensions.cpp index b99a043bf5..a147bce6ea 100644 --- a/apps/openmw/mwscript/dialogueextensions.cpp +++ b/apps/openmw/mwscript/dialogueextensions.cpp @@ -284,28 +284,28 @@ namespace MWScript void installOpcodes (Interpreter::Interpreter& interpreter) { - interpreter.installSegment5 (Compiler::Dialogue::opcodeJournal, new OpJournal); - interpreter.installSegment5 (Compiler::Dialogue::opcodeJournalExplicit, 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); - interpreter.installSegment5 (Compiler::Dialogue::opcodeModFactionReaction, new OpModFactionReaction); - interpreter.installSegment5 (Compiler::Dialogue::opcodeSetFactionReaction, new OpSetFactionReaction); - interpreter.installSegment5 (Compiler::Dialogue::opcodeGetFactionReaction, new OpGetFactionReaction); - interpreter.installSegment5 (Compiler::Dialogue::opcodeClearInfoActor, new OpClearInfoActor); - interpreter.installSegment5 (Compiler::Dialogue::opcodeClearInfoActorExplicit, new OpClearInfoActor); + interpreter.installSegment5>(Compiler::Dialogue::opcodeJournal); + interpreter.installSegment5>(Compiler::Dialogue::opcodeJournalExplicit); + interpreter.installSegment5(Compiler::Dialogue::opcodeSetJournalIndex); + interpreter.installSegment5(Compiler::Dialogue::opcodeGetJournalIndex); + interpreter.installSegment5(Compiler::Dialogue::opcodeAddTopic); + interpreter.installSegment3(Compiler::Dialogue::opcodeChoice); + interpreter.installSegment5>(Compiler::Dialogue::opcodeForceGreeting); + interpreter.installSegment5>(Compiler::Dialogue::opcodeForceGreetingExplicit); + interpreter.installSegment5(Compiler::Dialogue::opcodeGoodbye); + interpreter.installSegment5>(Compiler::Dialogue::opcodeGetReputation); + interpreter.installSegment5>(Compiler::Dialogue::opcodeSetReputation); + interpreter.installSegment5>(Compiler::Dialogue::opcodeModReputation); + interpreter.installSegment5>(Compiler::Dialogue::opcodeSetReputationExplicit); + interpreter.installSegment5>(Compiler::Dialogue::opcodeModReputationExplicit); + interpreter.installSegment5>(Compiler::Dialogue::opcodeGetReputationExplicit); + interpreter.installSegment5>(Compiler::Dialogue::opcodeSameFaction); + interpreter.installSegment5>(Compiler::Dialogue::opcodeSameFactionExplicit); + interpreter.installSegment5(Compiler::Dialogue::opcodeModFactionReaction); + interpreter.installSegment5(Compiler::Dialogue::opcodeSetFactionReaction); + interpreter.installSegment5(Compiler::Dialogue::opcodeGetFactionReaction); + interpreter.installSegment5>(Compiler::Dialogue::opcodeClearInfoActor); + interpreter.installSegment5>(Compiler::Dialogue::opcodeClearInfoActorExplicit); } } diff --git a/apps/openmw/mwscript/guiextensions.cpp b/apps/openmw/mwscript/guiextensions.cpp index f0bc90e044..e44c94e686 100644 --- a/apps/openmw/mwscript/guiextensions.cpp +++ b/apps/openmw/mwscript/guiextensions.cpp @@ -218,45 +218,33 @@ namespace MWScript void installOpcodes (Interpreter::Interpreter& interpreter) { - interpreter.installSegment5 (Compiler::Gui::opcodeEnableBirthMenu, - new OpShowDialogue (MWGui::GM_Birth)); - interpreter.installSegment5 (Compiler::Gui::opcodeEnableClassMenu, - new OpShowDialogue (MWGui::GM_Class)); - interpreter.installSegment5 (Compiler::Gui::opcodeEnableNameMenu, - new OpShowDialogue (MWGui::GM_Name)); - interpreter.installSegment5 (Compiler::Gui::opcodeEnableRaceMenu, - new OpShowDialogue (MWGui::GM_Race)); - interpreter.installSegment5 (Compiler::Gui::opcodeEnableStatsReviewMenu, - new OpShowDialogue (MWGui::GM_Review)); - interpreter.installSegment5 (Compiler::Gui::opcodeEnableLevelupMenu, - new OpShowDialogue (MWGui::GM_Levelup)); - - interpreter.installSegment5 (Compiler::Gui::opcodeEnableInventoryMenu, - new OpEnableWindow (MWGui::GW_Inventory)); - interpreter.installSegment5 (Compiler::Gui::opcodeEnableMagicMenu, - new OpEnableWindow (MWGui::GW_Magic)); - interpreter.installSegment5 (Compiler::Gui::opcodeEnableMapMenu, - new OpEnableWindow (MWGui::GW_Map)); - interpreter.installSegment5 (Compiler::Gui::opcodeEnableStatsMenu, - new OpEnableWindow (MWGui::GW_Stats)); - - interpreter.installSegment5 (Compiler::Gui::opcodeEnableRest, - new OpEnableRest ()); - - interpreter.installSegment5 (Compiler::Gui::opcodeShowRestMenu, - new OpShowRestMenu); - interpreter.installSegment5 (Compiler::Gui::opcodeShowRestMenuExplicit, new OpShowRestMenu); - - interpreter.installSegment5 (Compiler::Gui::opcodeGetButtonPressed, new OpGetButtonPressed); - - interpreter.installSegment5 (Compiler::Gui::opcodeToggleFogOfWar, new OpToggleFogOfWar); - - interpreter.installSegment5 (Compiler::Gui::opcodeToggleFullHelp, new OpToggleFullHelp); - - interpreter.installSegment5 (Compiler::Gui::opcodeShowMap, new OpShowMap); - interpreter.installSegment5 (Compiler::Gui::opcodeFillMap, new OpFillMap); - interpreter.installSegment3 (Compiler::Gui::opcodeMenuTest, new OpMenuTest); - interpreter.installSegment5 (Compiler::Gui::opcodeToggleMenus, new OpToggleMenus); + interpreter.installSegment5(Compiler::Gui::opcodeEnableBirthMenu, MWGui::GM_Birth); + interpreter.installSegment5(Compiler::Gui::opcodeEnableClassMenu, MWGui::GM_Class); + interpreter.installSegment5(Compiler::Gui::opcodeEnableNameMenu, MWGui::GM_Name); + interpreter.installSegment5(Compiler::Gui::opcodeEnableRaceMenu, MWGui::GM_Race); + interpreter.installSegment5(Compiler::Gui::opcodeEnableStatsReviewMenu, MWGui::GM_Review); + interpreter.installSegment5(Compiler::Gui::opcodeEnableLevelupMenu, MWGui::GM_Levelup); + + interpreter.installSegment5(Compiler::Gui::opcodeEnableInventoryMenu, MWGui::GW_Inventory); + interpreter.installSegment5(Compiler::Gui::opcodeEnableMagicMenu, MWGui::GW_Magic); + interpreter.installSegment5(Compiler::Gui::opcodeEnableMapMenu, MWGui::GW_Map); + interpreter.installSegment5(Compiler::Gui::opcodeEnableStatsMenu, MWGui::GW_Stats); + + interpreter.installSegment5(Compiler::Gui::opcodeEnableRest); + + interpreter.installSegment5>(Compiler::Gui::opcodeShowRestMenu); + interpreter.installSegment5>(Compiler::Gui::opcodeShowRestMenuExplicit); + + interpreter.installSegment5(Compiler::Gui::opcodeGetButtonPressed); + + interpreter.installSegment5(Compiler::Gui::opcodeToggleFogOfWar); + + interpreter.installSegment5(Compiler::Gui::opcodeToggleFullHelp); + + interpreter.installSegment5(Compiler::Gui::opcodeShowMap); + interpreter.installSegment5(Compiler::Gui::opcodeFillMap); + interpreter.installSegment3(Compiler::Gui::opcodeMenuTest); + interpreter.installSegment5(Compiler::Gui::opcodeToggleMenus); } } } diff --git a/apps/openmw/mwscript/miscextensions.cpp b/apps/openmw/mwscript/miscextensions.cpp index 5d9f037357..fe8caf4567 100644 --- a/apps/openmw/mwscript/miscextensions.cpp +++ b/apps/openmw/mwscript/miscextensions.cpp @@ -1616,125 +1616,125 @@ namespace MWScript void installOpcodes (Interpreter::Interpreter& interpreter) { - interpreter.installSegment5 (Compiler::Misc::opcodeMenuMode, new OpMenuMode); - interpreter.installSegment5 (Compiler::Misc::opcodeRandom, new OpRandom); - interpreter.installSegment5 (Compiler::Misc::opcodeScriptRunning, new OpScriptRunning); - interpreter.installSegment5 (Compiler::Misc::opcodeStartScript, new OpStartScript); - interpreter.installSegment5 (Compiler::Misc::opcodeStartScriptExplicit, new OpStartScript); - interpreter.installSegment5 (Compiler::Misc::opcodeStopScript, new OpStopScript); - interpreter.installSegment5 (Compiler::Misc::opcodeGetSecondsPassed, new OpGetSecondsPassed); - interpreter.installSegment5 (Compiler::Misc::opcodeEnable, new OpEnable); - interpreter.installSegment5 (Compiler::Misc::opcodeEnableExplicit, new OpEnable); - interpreter.installSegment5 (Compiler::Misc::opcodeDisable, new OpDisable); - interpreter.installSegment5 (Compiler::Misc::opcodeDisableExplicit, new OpDisable); - interpreter.installSegment5 (Compiler::Misc::opcodeGetDisabled, new OpGetDisabled); - interpreter.installSegment5 (Compiler::Misc::opcodeGetDisabledExplicit, new OpGetDisabled); - interpreter.installSegment5 (Compiler::Misc::opcodeXBox, new OpXBox); - interpreter.installSegment5 (Compiler::Misc::opcodeOnActivate, new OpOnActivate); - interpreter.installSegment5 (Compiler::Misc::opcodeOnActivateExplicit, new OpOnActivate); - interpreter.installSegment5 (Compiler::Misc::opcodeActivate, new OpActivate); - interpreter.installSegment5 (Compiler::Misc::opcodeActivateExplicit, 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::opcodeToggleWorld, new OpToggleWorld); - interpreter.installSegment5 (Compiler::Misc::opcodeDontSaveObject, new OpDontSaveObject); - interpreter.installSegment5 (Compiler::Misc::opcodePcForce1stPerson, new OpPcForce1stPerson); - interpreter.installSegment5 (Compiler::Misc::opcodePcForce3rdPerson, new OpPcForce3rdPerson); - interpreter.installSegment5 (Compiler::Misc::opcodePcGet3rdPerson, new OpPcGet3rdPerson); - interpreter.installSegment5 (Compiler::Misc::opcodeToggleVanityMode, new OpToggleVanityMode); - interpreter.installSegment5 (Compiler::Misc::opcodeGetPcSleep, new OpGetPcSleep); - interpreter.installSegment5 (Compiler::Misc::opcodeGetPcJumping, new OpGetPcJumping); - interpreter.installSegment5 (Compiler::Misc::opcodeWakeUpPc, new OpWakeUpPc); - interpreter.installSegment5 (Compiler::Misc::opcodePlayBink, new OpPlayBink); - interpreter.installSegment5 (Compiler::Misc::opcodePayFine, new OpPayFine); - interpreter.installSegment5 (Compiler::Misc::opcodePayFineThief, new OpPayFineThief); - interpreter.installSegment5 (Compiler::Misc::opcodeGoToJail, new OpGoToJail); - 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.installSegment3 (Compiler::Misc::opcodeRemoveSoulGem, new OpRemoveSoulGem); - interpreter.installSegment3 (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::opcodeGetSpellReadied, new OpGetSpellReadied); - interpreter.installSegment5 (Compiler::Misc::opcodeGetSpellReadiedExplicit, new OpGetSpellReadied); - 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::opcodeGetCollidingPc, new OpGetCollidingPc); - interpreter.installSegment5 (Compiler::Misc::opcodeGetCollidingPcExplicit, new OpGetCollidingPc); - interpreter.installSegment5 (Compiler::Misc::opcodeGetCollidingActor, new OpGetCollidingActor); - interpreter.installSegment5 (Compiler::Misc::opcodeGetCollidingActorExplicit, new OpGetCollidingActor); - interpreter.installSegment5 (Compiler::Misc::opcodeHurtStandingActor, new OpHurtStandingActor); - interpreter.installSegment5 (Compiler::Misc::opcodeHurtStandingActorExplicit, new OpHurtStandingActor); - interpreter.installSegment5 (Compiler::Misc::opcodeHurtCollidingActor, new OpHurtCollidingActor); - interpreter.installSegment5 (Compiler::Misc::opcodeHurtCollidingActorExplicit, new OpHurtCollidingActor); - 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::opcodeHitAttemptOnMe, new OpHitAttemptOnMe); - interpreter.installSegment5 (Compiler::Misc::opcodeHitAttemptOnMeExplicit, new OpHitAttemptOnMe); - interpreter.installSegment5 (Compiler::Misc::opcodeDisableTeleporting, new OpEnableTeleporting); - interpreter.installSegment5 (Compiler::Misc::opcodeEnableTeleporting, new OpEnableTeleporting); - interpreter.installSegment5 (Compiler::Misc::opcodeShowVars, new OpShowVars); - interpreter.installSegment5 (Compiler::Misc::opcodeShowVarsExplicit, new OpShowVars); - interpreter.installSegment5 (Compiler::Misc::opcodeShow, new OpShow); - interpreter.installSegment5 (Compiler::Misc::opcodeShowExplicit, new OpShow); - interpreter.installSegment5 (Compiler::Misc::opcodeToggleGodMode, new OpToggleGodMode); - interpreter.installSegment5 (Compiler::Misc::opcodeToggleScripts, new OpToggleScripts); - interpreter.installSegment5 (Compiler::Misc::opcodeDisableLevitation, new OpEnableLevitation); - interpreter.installSegment5 (Compiler::Misc::opcodeEnableLevitation, new OpEnableLevitation); - interpreter.installSegment5 (Compiler::Misc::opcodeCast, new OpCast); - interpreter.installSegment5 (Compiler::Misc::opcodeCastExplicit, new OpCast); - interpreter.installSegment5 (Compiler::Misc::opcodeExplodeSpell, new OpExplodeSpell); - interpreter.installSegment5 (Compiler::Misc::opcodeExplodeSpellExplicit, new OpExplodeSpell); - interpreter.installSegment5 (Compiler::Misc::opcodeGetPcInJail, new OpGetPcInJail); - interpreter.installSegment5 (Compiler::Misc::opcodeGetPcTraveling, new OpGetPcTraveling); - interpreter.installSegment3 (Compiler::Misc::opcodeBetaComment, new OpBetaComment); - interpreter.installSegment3 (Compiler::Misc::opcodeBetaCommentExplicit, new OpBetaComment); - interpreter.installSegment5 (Compiler::Misc::opcodeAddToLevCreature, new OpAddToLevCreature); - interpreter.installSegment5 (Compiler::Misc::opcodeRemoveFromLevCreature, new OpRemoveFromLevCreature); - interpreter.installSegment5 (Compiler::Misc::opcodeAddToLevItem, new OpAddToLevItem); - interpreter.installSegment5 (Compiler::Misc::opcodeRemoveFromLevItem, new OpRemoveFromLevItem); - interpreter.installSegment3 (Compiler::Misc::opcodeShowSceneGraph, new OpShowSceneGraph); - interpreter.installSegment3 (Compiler::Misc::opcodeShowSceneGraphExplicit, new OpShowSceneGraph); - interpreter.installSegment5 (Compiler::Misc::opcodeToggleBorders, new OpToggleBorders); - interpreter.installSegment5 (Compiler::Misc::opcodeToggleNavMesh, new OpToggleNavMesh); - interpreter.installSegment5 (Compiler::Misc::opcodeToggleActorsPaths, new OpToggleActorsPaths); - interpreter.installSegment5 (Compiler::Misc::opcodeSetNavMeshNumberToRender, new OpSetNavMeshNumberToRender); - interpreter.installSegment5 (Compiler::Misc::opcodeRepairedOnMe, new OpRepairedOnMe); - interpreter.installSegment5 (Compiler::Misc::opcodeRepairedOnMeExplicit, new OpRepairedOnMe); - interpreter.installSegment5 (Compiler::Misc::opcodeToggleRecastMesh, new OpToggleRecastMesh); - interpreter.installSegment5 (Compiler::Misc::opcodeHelp, new OpHelp); - interpreter.installSegment5 (Compiler::Misc::opcodeReloadLua, new OpReloadLua); + interpreter.installSegment5(Compiler::Misc::opcodeMenuMode); + interpreter.installSegment5(Compiler::Misc::opcodeRandom); + interpreter.installSegment5(Compiler::Misc::opcodeScriptRunning); + interpreter.installSegment5>(Compiler::Misc::opcodeStartScript); + interpreter.installSegment5>(Compiler::Misc::opcodeStartScriptExplicit); + interpreter.installSegment5(Compiler::Misc::opcodeStopScript); + interpreter.installSegment5(Compiler::Misc::opcodeGetSecondsPassed); + interpreter.installSegment5>(Compiler::Misc::opcodeEnable); + interpreter.installSegment5>(Compiler::Misc::opcodeEnableExplicit); + interpreter.installSegment5>(Compiler::Misc::opcodeDisable); + interpreter.installSegment5>(Compiler::Misc::opcodeDisableExplicit); + interpreter.installSegment5>(Compiler::Misc::opcodeGetDisabled); + interpreter.installSegment5>(Compiler::Misc::opcodeGetDisabledExplicit); + interpreter.installSegment5(Compiler::Misc::opcodeXBox); + interpreter.installSegment5>(Compiler::Misc::opcodeOnActivate); + interpreter.installSegment5>(Compiler::Misc::opcodeOnActivateExplicit); + interpreter.installSegment5>(Compiler::Misc::opcodeActivate); + interpreter.installSegment5>(Compiler::Misc::opcodeActivateExplicit); + interpreter.installSegment3>(Compiler::Misc::opcodeLock); + interpreter.installSegment3>(Compiler::Misc::opcodeLockExplicit); + interpreter.installSegment5>(Compiler::Misc::opcodeUnlock); + interpreter.installSegment5>(Compiler::Misc::opcodeUnlockExplicit); + interpreter.installSegment5(Compiler::Misc::opcodeToggleCollisionDebug); + interpreter.installSegment5(Compiler::Misc::opcodeToggleCollisionBoxes); + interpreter.installSegment5(Compiler::Misc::opcodeToggleWireframe); + interpreter.installSegment5(Compiler::Misc::opcodeFadeIn); + interpreter.installSegment5(Compiler::Misc::opcodeFadeOut); + interpreter.installSegment5(Compiler::Misc::opcodeFadeTo); + interpreter.installSegment5(Compiler::Misc::opcodeTogglePathgrid); + interpreter.installSegment5(Compiler::Misc::opcodeToggleWater); + interpreter.installSegment5(Compiler::Misc::opcodeToggleWorld); + interpreter.installSegment5(Compiler::Misc::opcodeDontSaveObject); + interpreter.installSegment5(Compiler::Misc::opcodePcForce1stPerson); + interpreter.installSegment5(Compiler::Misc::opcodePcForce3rdPerson); + interpreter.installSegment5(Compiler::Misc::opcodePcGet3rdPerson); + interpreter.installSegment5(Compiler::Misc::opcodeToggleVanityMode); + interpreter.installSegment5(Compiler::Misc::opcodeGetPcSleep); + interpreter.installSegment5(Compiler::Misc::opcodeGetPcJumping); + interpreter.installSegment5(Compiler::Misc::opcodeWakeUpPc); + interpreter.installSegment5(Compiler::Misc::opcodePlayBink); + interpreter.installSegment5(Compiler::Misc::opcodePayFine); + interpreter.installSegment5(Compiler::Misc::opcodePayFineThief); + interpreter.installSegment5(Compiler::Misc::opcodeGoToJail); + interpreter.installSegment5>(Compiler::Misc::opcodeGetLocked); + interpreter.installSegment5>(Compiler::Misc::opcodeGetLockedExplicit); + interpreter.installSegment5>(Compiler::Misc::opcodeGetEffect); + interpreter.installSegment5>(Compiler::Misc::opcodeGetEffectExplicit); + interpreter.installSegment5>(Compiler::Misc::opcodeAddSoulGem); + interpreter.installSegment5>(Compiler::Misc::opcodeAddSoulGemExplicit); + interpreter.installSegment3>(Compiler::Misc::opcodeRemoveSoulGem); + interpreter.installSegment3>(Compiler::Misc::opcodeRemoveSoulGemExplicit); + interpreter.installSegment5>(Compiler::Misc::opcodeDrop); + interpreter.installSegment5>(Compiler::Misc::opcodeDropExplicit); + interpreter.installSegment5>(Compiler::Misc::opcodeDropSoulGem); + interpreter.installSegment5>(Compiler::Misc::opcodeDropSoulGemExplicit); + interpreter.installSegment5>(Compiler::Misc::opcodeGetAttacked); + interpreter.installSegment5>(Compiler::Misc::opcodeGetAttackedExplicit); + interpreter.installSegment5>(Compiler::Misc::opcodeGetWeaponDrawn); + interpreter.installSegment5>(Compiler::Misc::opcodeGetWeaponDrawnExplicit); + interpreter.installSegment5>(Compiler::Misc::opcodeGetSpellReadied); + interpreter.installSegment5>(Compiler::Misc::opcodeGetSpellReadiedExplicit); + interpreter.installSegment5>(Compiler::Misc::opcodeGetSpellEffects); + interpreter.installSegment5>(Compiler::Misc::opcodeGetSpellEffectsExplicit); + interpreter.installSegment5(Compiler::Misc::opcodeGetCurrentTime); + interpreter.installSegment5>(Compiler::Misc::opcodeSetDelete); + interpreter.installSegment5>(Compiler::Misc::opcodeSetDeleteExplicit); + interpreter.installSegment5(Compiler::Misc::opcodeGetSquareRoot); + interpreter.installSegment5>(Compiler::Misc::opcodeFall); + interpreter.installSegment5>(Compiler::Misc::opcodeFallExplicit); + interpreter.installSegment5>(Compiler::Misc::opcodeGetStandingPc); + interpreter.installSegment5>(Compiler::Misc::opcodeGetStandingPcExplicit); + interpreter.installSegment5>(Compiler::Misc::opcodeGetStandingActor); + interpreter.installSegment5>(Compiler::Misc::opcodeGetStandingActorExplicit); + interpreter.installSegment5>(Compiler::Misc::opcodeGetCollidingPc); + interpreter.installSegment5>(Compiler::Misc::opcodeGetCollidingPcExplicit); + interpreter.installSegment5>(Compiler::Misc::opcodeGetCollidingActor); + interpreter.installSegment5>(Compiler::Misc::opcodeGetCollidingActorExplicit); + interpreter.installSegment5>(Compiler::Misc::opcodeHurtStandingActor); + interpreter.installSegment5>(Compiler::Misc::opcodeHurtStandingActorExplicit); + interpreter.installSegment5>(Compiler::Misc::opcodeHurtCollidingActor); + interpreter.installSegment5>(Compiler::Misc::opcodeHurtCollidingActorExplicit); + interpreter.installSegment5(Compiler::Misc::opcodeGetWindSpeed); + interpreter.installSegment5>(Compiler::Misc::opcodeHitOnMe); + interpreter.installSegment5>(Compiler::Misc::opcodeHitOnMeExplicit); + interpreter.installSegment5>(Compiler::Misc::opcodeHitAttemptOnMe); + interpreter.installSegment5>(Compiler::Misc::opcodeHitAttemptOnMeExplicit); + interpreter.installSegment5>(Compiler::Misc::opcodeDisableTeleporting); + interpreter.installSegment5>(Compiler::Misc::opcodeEnableTeleporting); + interpreter.installSegment5>(Compiler::Misc::opcodeShowVars); + interpreter.installSegment5>(Compiler::Misc::opcodeShowVarsExplicit); + interpreter.installSegment5>(Compiler::Misc::opcodeShow); + interpreter.installSegment5>(Compiler::Misc::opcodeShowExplicit); + interpreter.installSegment5(Compiler::Misc::opcodeToggleGodMode); + interpreter.installSegment5(Compiler::Misc::opcodeToggleScripts); + interpreter.installSegment5>(Compiler::Misc::opcodeDisableLevitation); + interpreter.installSegment5>(Compiler::Misc::opcodeEnableLevitation); + interpreter.installSegment5>(Compiler::Misc::opcodeCast); + interpreter.installSegment5>(Compiler::Misc::opcodeCastExplicit); + interpreter.installSegment5>(Compiler::Misc::opcodeExplodeSpell); + interpreter.installSegment5>(Compiler::Misc::opcodeExplodeSpellExplicit); + interpreter.installSegment5(Compiler::Misc::opcodeGetPcInJail); + interpreter.installSegment5(Compiler::Misc::opcodeGetPcTraveling); + interpreter.installSegment3>(Compiler::Misc::opcodeBetaComment); + interpreter.installSegment3>(Compiler::Misc::opcodeBetaCommentExplicit); + interpreter.installSegment5(Compiler::Misc::opcodeAddToLevCreature); + interpreter.installSegment5(Compiler::Misc::opcodeRemoveFromLevCreature); + interpreter.installSegment5(Compiler::Misc::opcodeAddToLevItem); + interpreter.installSegment5(Compiler::Misc::opcodeRemoveFromLevItem); + interpreter.installSegment3>(Compiler::Misc::opcodeShowSceneGraph); + interpreter.installSegment3>(Compiler::Misc::opcodeShowSceneGraphExplicit); + interpreter.installSegment5(Compiler::Misc::opcodeToggleBorders); + interpreter.installSegment5(Compiler::Misc::opcodeToggleNavMesh); + interpreter.installSegment5(Compiler::Misc::opcodeToggleActorsPaths); + interpreter.installSegment5(Compiler::Misc::opcodeSetNavMeshNumberToRender); + interpreter.installSegment5>(Compiler::Misc::opcodeRepairedOnMe); + interpreter.installSegment5>(Compiler::Misc::opcodeRepairedOnMeExplicit); + interpreter.installSegment5(Compiler::Misc::opcodeToggleRecastMesh); + interpreter.installSegment5(Compiler::Misc::opcodeHelp); + interpreter.installSegment5(Compiler::Misc::opcodeReloadLua); } } } diff --git a/apps/openmw/mwscript/skyextensions.cpp b/apps/openmw/mwscript/skyextensions.cpp index 81984ad7b7..1d00b8c052 100644 --- a/apps/openmw/mwscript/skyextensions.cpp +++ b/apps/openmw/mwscript/skyextensions.cpp @@ -126,14 +126,14 @@ namespace MWScript void installOpcodes (Interpreter::Interpreter& interpreter) { - 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); + interpreter.installSegment5(Compiler::Sky::opcodeToggleSky); + interpreter.installSegment5(Compiler::Sky::opcodeTurnMoonWhite); + interpreter.installSegment5(Compiler::Sky::opcodeTurnMoonRed); + interpreter.installSegment5(Compiler::Sky::opcodeGetMasserPhase); + interpreter.installSegment5(Compiler::Sky::opcodeGetSecundaPhase); + interpreter.installSegment5(Compiler::Sky::opcodeGetCurrentWeather); + interpreter.installSegment5(Compiler::Sky::opcodeChangeWeather); + interpreter.installSegment3(Compiler::Sky::opcodeModRegion); } } } diff --git a/apps/openmw/mwscript/soundextensions.cpp b/apps/openmw/mwscript/soundextensions.cpp index 6eab758f19..b8d1470ea8 100644 --- a/apps/openmw/mwscript/soundextensions.cpp +++ b/apps/openmw/mwscript/soundextensions.cpp @@ -104,15 +104,11 @@ namespace MWScript } }; - template + template class OpPlaySound3D : public Interpreter::Opcode0 { - bool mLoop; - public: - OpPlaySound3D (bool loop) : mLoop (loop) {} - void execute (Interpreter::Runtime& runtime) override { MWWorld::Ptr ptr = R()(runtime); @@ -122,20 +118,16 @@ namespace MWScript MWBase::Environment::get().getSoundManager()->playSound3D(ptr, sound, 1.0, 1.0, MWSound::Type::Sfx, - mLoop ? MWSound::PlayMode::LoopRemoveAtDistance + TLoop ? MWSound::PlayMode::LoopRemoveAtDistance : MWSound::PlayMode::Normal); } }; - template + template class OpPlaySoundVP3D : public Interpreter::Opcode0 { - bool mLoop; - public: - OpPlaySoundVP3D (bool loop) : mLoop (loop) {} - void execute (Interpreter::Runtime& runtime) override { MWWorld::Ptr ptr = R()(runtime); @@ -151,7 +143,7 @@ namespace MWScript MWBase::Environment::get().getSoundManager()->playSound3D(ptr, sound, volume, pitch, MWSound::Type::Sfx, - mLoop ? MWSound::PlayMode::LoopRemoveAtDistance + TLoop ? MWSound::PlayMode::LoopRemoveAtDistance : MWSound::PlayMode::Normal); } @@ -205,34 +197,28 @@ namespace MWScript }; - void installOpcodes (Interpreter::Interpreter& interpreter) + void installOpcodes(Interpreter::Interpreter& interpreter) { - 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 (Compiler::Sound::opcodeStopSound, new OpStopSound); - interpreter.installSegment5 (Compiler::Sound::opcodeGetSoundPlaying, new OpGetSoundPlaying); - - interpreter.installSegment5 (Compiler::Sound::opcodeSayExplicit, new OpSay); - interpreter.installSegment5 (Compiler::Sound::opcodeSayDoneExplicit, new OpSayDone); - interpreter.installSegment5 (Compiler::Sound::opcodePlaySound3DExplicit, - new OpPlaySound3D (false)); - interpreter.installSegment5 (Compiler::Sound::opcodePlaySound3DVPExplicit, - new OpPlaySoundVP3D (false)); - interpreter.installSegment5 (Compiler::Sound::opcodePlayLoopSound3DExplicit, - new OpPlaySound3D (true)); - interpreter.installSegment5 (Compiler::Sound::opcodePlayLoopSound3DVPExplicit, - new OpPlaySoundVP3D (true)); - interpreter.installSegment5 (Compiler::Sound::opcodeStopSoundExplicit, new OpStopSound); - interpreter.installSegment5 (Compiler::Sound::opcodeGetSoundPlayingExplicit, - new OpGetSoundPlaying); + interpreter.installSegment5>(Compiler::Sound::opcodeSay); + interpreter.installSegment5>(Compiler::Sound::opcodeSayDone); + interpreter.installSegment5(Compiler::Sound::opcodeStreamMusic); + interpreter.installSegment5(Compiler::Sound::opcodePlaySound); + interpreter.installSegment5(Compiler::Sound::opcodePlaySoundVP); + interpreter.installSegment5>(Compiler::Sound::opcodePlaySound3D); + interpreter.installSegment5>(Compiler::Sound::opcodePlaySound3DVP); + interpreter.installSegment5>(Compiler::Sound::opcodePlayLoopSound3D); + interpreter.installSegment5>(Compiler::Sound::opcodePlayLoopSound3DVP); + interpreter.installSegment5>(Compiler::Sound::opcodeStopSound); + interpreter.installSegment5>(Compiler::Sound::opcodeGetSoundPlaying); + + interpreter.installSegment5>(Compiler::Sound::opcodeSayExplicit); + interpreter.installSegment5>(Compiler::Sound::opcodeSayDoneExplicit); + interpreter.installSegment5>(Compiler::Sound::opcodePlaySound3DExplicit); + interpreter.installSegment5>(Compiler::Sound::opcodePlaySound3DVPExplicit); + interpreter.installSegment5>(Compiler::Sound::opcodePlayLoopSound3DExplicit); + interpreter.installSegment5>(Compiler::Sound::opcodePlayLoopSound3DVPExplicit); + interpreter.installSegment5>(Compiler::Sound::opcodeStopSoundExplicit); + interpreter.installSegment5>(Compiler::Sound::opcodeGetSoundPlayingExplicit); } } } diff --git a/apps/openmw/mwscript/statsextensions.cpp b/apps/openmw/mwscript/statsextensions.cpp index 186d1edf26..048029c72a 100644 --- a/apps/openmw/mwscript/statsextensions.cpp +++ b/apps/openmw/mwscript/statsextensions.cpp @@ -1325,146 +1325,132 @@ namespace MWScript { for (int i=0; i (i)); - interpreter.installSegment5 (Compiler::Stats::opcodeGetAttributeExplicit+i, - new OpGetAttribute (i)); + interpreter.installSegment5>(Compiler::Stats::opcodeGetAttribute + i, i); + interpreter.installSegment5>(Compiler::Stats::opcodeGetAttributeExplicit + i, i); - interpreter.installSegment5 (Compiler::Stats::opcodeSetAttribute+i, new OpSetAttribute (i)); - interpreter.installSegment5 (Compiler::Stats::opcodeSetAttributeExplicit+i, - new OpSetAttribute (i)); + interpreter.installSegment5>(Compiler::Stats::opcodeSetAttribute + i, i); + interpreter.installSegment5>(Compiler::Stats::opcodeSetAttributeExplicit + i, i); - interpreter.installSegment5 (Compiler::Stats::opcodeModAttribute+i, new OpModAttribute (i)); - interpreter.installSegment5 (Compiler::Stats::opcodeModAttributeExplicit+i, - new OpModAttribute (i)); + interpreter.installSegment5>(Compiler::Stats::opcodeModAttribute + i, i); + interpreter.installSegment5>(Compiler::Stats::opcodeModAttributeExplicit + i, i); } for (int i=0; i (i)); - interpreter.installSegment5 (Compiler::Stats::opcodeGetDynamicExplicit+i, - new OpGetDynamic (i)); - - interpreter.installSegment5 (Compiler::Stats::opcodeSetDynamic+i, new OpSetDynamic (i)); - interpreter.installSegment5 (Compiler::Stats::opcodeSetDynamicExplicit+i, - new OpSetDynamic (i)); - - interpreter.installSegment5 (Compiler::Stats::opcodeModDynamic+i, new OpModDynamic (i)); - interpreter.installSegment5 (Compiler::Stats::opcodeModDynamicExplicit+i, - new OpModDynamic (i)); - - interpreter.installSegment5 (Compiler::Stats::opcodeModCurrentDynamic+i, - new OpModCurrentDynamic (i)); - interpreter.installSegment5 (Compiler::Stats::opcodeModCurrentDynamicExplicit+i, - new OpModCurrentDynamic (i)); - - interpreter.installSegment5 (Compiler::Stats::opcodeGetDynamicGetRatio+i, - new OpGetDynamicGetRatio (i)); - interpreter.installSegment5 (Compiler::Stats::opcodeGetDynamicGetRatioExplicit+i, - new OpGetDynamicGetRatio (i)); + interpreter.installSegment5>(Compiler::Stats::opcodeGetDynamic + i, i); + interpreter.installSegment5>(Compiler::Stats::opcodeGetDynamicExplicit + i, i); + + interpreter.installSegment5>(Compiler::Stats::opcodeSetDynamic + i, i); + interpreter.installSegment5>(Compiler::Stats::opcodeSetDynamicExplicit + i, i); + + interpreter.installSegment5>(Compiler::Stats::opcodeModDynamic + i, i); + interpreter.installSegment5>(Compiler::Stats::opcodeModDynamicExplicit + i, i); + + interpreter.installSegment5>(Compiler::Stats::opcodeModCurrentDynamic + i, i); + interpreter.installSegment5>(Compiler::Stats::opcodeModCurrentDynamicExplicit + i, i); + + interpreter.installSegment5>(Compiler::Stats::opcodeGetDynamicGetRatio + i, i); + interpreter.installSegment5>(Compiler::Stats::opcodeGetDynamicGetRatioExplicit + i, i); } for (int i=0; i (i)); - interpreter.installSegment5 (Compiler::Stats::opcodeGetSkillExplicit+i, new OpGetSkill (i)); + interpreter.installSegment5>(Compiler::Stats::opcodeGetSkill + i, i); + interpreter.installSegment5>(Compiler::Stats::opcodeGetSkillExplicit + i, i); - interpreter.installSegment5 (Compiler::Stats::opcodeSetSkill+i, new OpSetSkill (i)); - interpreter.installSegment5 (Compiler::Stats::opcodeSetSkillExplicit+i, new OpSetSkill (i)); + interpreter.installSegment5>(Compiler::Stats::opcodeSetSkill + i, i); + interpreter.installSegment5>(Compiler::Stats::opcodeSetSkillExplicit + i, i); - interpreter.installSegment5 (Compiler::Stats::opcodeModSkill+i, new OpModSkill (i)); - interpreter.installSegment5 (Compiler::Stats::opcodeModSkillExplicit+i, new OpModSkill (i)); + interpreter.installSegment5>(Compiler::Stats::opcodeModSkill + i, i); + interpreter.installSegment5>(Compiler::Stats::opcodeModSkillExplicit + i, i); } - interpreter.installSegment5 (Compiler::Stats::opcodeGetPCCrimeLevel, new OpGetPCCrimeLevel); - interpreter.installSegment5 (Compiler::Stats::opcodeSetPCCrimeLevel, new OpSetPCCrimeLevel); - interpreter.installSegment5 (Compiler::Stats::opcodeModPCCrimeLevel, new OpModPCCrimeLevel); - - 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 (Compiler::Stats::opcodeRemoveSpellEffects, new OpRemoveSpellEffects); - interpreter.installSegment5 (Compiler::Stats::opcodeRemoveSpellEffectsExplicit, - new OpRemoveSpellEffects); - interpreter.installSegment5 (Compiler::Stats::opcodeResurrect, new OpResurrect); - interpreter.installSegment5 (Compiler::Stats::opcodeResurrectExplicit, - new OpResurrect); - interpreter.installSegment5 (Compiler::Stats::opcodeRemoveEffects, new OpRemoveEffects); - interpreter.installSegment5 (Compiler::Stats::opcodeRemoveEffectsExplicit, - new OpRemoveEffects); - - interpreter.installSegment5 (Compiler::Stats::opcodeGetSpell, new OpGetSpell); - interpreter.installSegment5 (Compiler::Stats::opcodeGetSpellExplicit, new OpGetSpell); - - 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::opcodePCRaiseRankExplicit,new OpPCRaiseRank); - interpreter.installSegment3(Compiler::Stats::opcodePCLowerRankExplicit,new OpPCLowerRank); - interpreter.installSegment3(Compiler::Stats::opcodePCJoinFactionExplicit,new OpPCJoinFaction); - interpreter.installSegment3(Compiler::Stats::opcodeGetPCRank,new OpGetPCRank); - interpreter.installSegment3(Compiler::Stats::opcodeGetPCRankExplicit,new OpGetPCRank); - - 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 (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 (Compiler::Stats::opcodeGetDeadCount, new OpGetDeadCount); - - 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 (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 (Compiler::Stats::opcodeGetRace, new OpGetRace); - interpreter.installSegment5 (Compiler::Stats::opcodeGetRaceExplicit, new OpGetRace); - interpreter.installSegment5 (Compiler::Stats::opcodeGetWerewolfKills, new OpGetWerewolfKills); - - 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 (Compiler::Stats::opcodeOnDeath, new OpOnDeath); - interpreter.installSegment5 (Compiler::Stats::opcodeOnDeathExplicit, new OpOnDeath); - interpreter.installSegment5 (Compiler::Stats::opcodeOnMurder, new OpOnMurder); - interpreter.installSegment5 (Compiler::Stats::opcodeOnMurderExplicit, new OpOnMurder); - interpreter.installSegment5 (Compiler::Stats::opcodeOnKnockout, new OpOnKnockout); - interpreter.installSegment5 (Compiler::Stats::opcodeOnKnockoutExplicit, new OpOnKnockout); - - interpreter.installSegment5 (Compiler::Stats::opcodeIsWerewolf, new OpIsWerewolf); - interpreter.installSegment5 (Compiler::Stats::opcodeIsWerewolfExplicit, new OpIsWerewolf); - - interpreter.installSegment5 (Compiler::Stats::opcodeBecomeWerewolf, new OpSetWerewolf); - interpreter.installSegment5 (Compiler::Stats::opcodeBecomeWerewolfExplicit, new OpSetWerewolf); - interpreter.installSegment5 (Compiler::Stats::opcodeUndoWerewolf, new OpSetWerewolf); - interpreter.installSegment5 (Compiler::Stats::opcodeUndoWerewolfExplicit, new OpSetWerewolf); - interpreter.installSegment5 (Compiler::Stats::opcodeSetWerewolfAcrobatics, new OpSetWerewolfAcrobatics); - interpreter.installSegment5 (Compiler::Stats::opcodeSetWerewolfAcrobaticsExplicit, new OpSetWerewolfAcrobatics); - interpreter.installSegment5 (Compiler::Stats::opcodeGetStat, new OpGetStat); - interpreter.installSegment5 (Compiler::Stats::opcodeGetStatExplicit, new OpGetStat); + interpreter.installSegment5(Compiler::Stats::opcodeGetPCCrimeLevel); + interpreter.installSegment5(Compiler::Stats::opcodeSetPCCrimeLevel); + interpreter.installSegment5(Compiler::Stats::opcodeModPCCrimeLevel); + + interpreter.installSegment5>(Compiler::Stats::opcodeAddSpell); + interpreter.installSegment5>(Compiler::Stats::opcodeAddSpellExplicit); + interpreter.installSegment5>(Compiler::Stats::opcodeRemoveSpell); + interpreter.installSegment5>(Compiler::Stats::opcodeRemoveSpellExplicit); + interpreter.installSegment5>(Compiler::Stats::opcodeRemoveSpellEffects); + interpreter.installSegment5>(Compiler::Stats::opcodeRemoveSpellEffectsExplicit); + interpreter.installSegment5>(Compiler::Stats::opcodeResurrect); + interpreter.installSegment5>(Compiler::Stats::opcodeResurrectExplicit); + interpreter.installSegment5>(Compiler::Stats::opcodeRemoveEffects); + interpreter.installSegment5>(Compiler::Stats::opcodeRemoveEffectsExplicit); + + interpreter.installSegment5>(Compiler::Stats::opcodeGetSpell); + interpreter.installSegment5>(Compiler::Stats::opcodeGetSpellExplicit); + + interpreter.installSegment3>(Compiler::Stats::opcodePCRaiseRank); + interpreter.installSegment3>(Compiler::Stats::opcodePCLowerRank); + interpreter.installSegment3>(Compiler::Stats::opcodePCJoinFaction); + interpreter.installSegment3>(Compiler::Stats::opcodePCRaiseRankExplicit); + interpreter.installSegment3>(Compiler::Stats::opcodePCLowerRankExplicit); + interpreter.installSegment3>(Compiler::Stats::opcodePCJoinFactionExplicit); + interpreter.installSegment3>(Compiler::Stats::opcodeGetPCRank); + interpreter.installSegment3>(Compiler::Stats::opcodeGetPCRankExplicit); + + interpreter.installSegment5>(Compiler::Stats::opcodeModDisposition); + interpreter.installSegment5>(Compiler::Stats::opcodeModDispositionExplicit); + interpreter.installSegment5>(Compiler::Stats::opcodeSetDisposition); + interpreter.installSegment5>(Compiler::Stats::opcodeSetDispositionExplicit); + interpreter.installSegment5>(Compiler::Stats::opcodeGetDisposition); + interpreter.installSegment5>(Compiler::Stats::opcodeGetDispositionExplicit); + + interpreter.installSegment5>(Compiler::Stats::opcodeGetLevel); + interpreter.installSegment5>(Compiler::Stats::opcodeGetLevelExplicit); + interpreter.installSegment5>(Compiler::Stats::opcodeSetLevel); + interpreter.installSegment5>(Compiler::Stats::opcodeSetLevelExplicit); + + interpreter.installSegment5(Compiler::Stats::opcodeGetDeadCount); + + interpreter.installSegment3>(Compiler::Stats::opcodeGetPCFacRep); + interpreter.installSegment3>(Compiler::Stats::opcodeGetPCFacRepExplicit); + interpreter.installSegment3>(Compiler::Stats::opcodeSetPCFacRep); + interpreter.installSegment3>(Compiler::Stats::opcodeSetPCFacRepExplicit); + interpreter.installSegment3>(Compiler::Stats::opcodeModPCFacRep); + interpreter.installSegment3>(Compiler::Stats::opcodeModPCFacRepExplicit); + + interpreter.installSegment5>(Compiler::Stats::opcodeGetCommonDisease); + interpreter.installSegment5>(Compiler::Stats::opcodeGetCommonDiseaseExplicit); + interpreter.installSegment5>(Compiler::Stats::opcodeGetBlightDisease); + interpreter.installSegment5>(Compiler::Stats::opcodeGetBlightDiseaseExplicit); + + interpreter.installSegment5>(Compiler::Stats::opcodeGetRace); + interpreter.installSegment5>(Compiler::Stats::opcodeGetRaceExplicit); + interpreter.installSegment5(Compiler::Stats::opcodeGetWerewolfKills); + + interpreter.installSegment3>(Compiler::Stats::opcodePcExpelled); + interpreter.installSegment3>(Compiler::Stats::opcodePcExpelledExplicit); + interpreter.installSegment3>(Compiler::Stats::opcodePcExpell); + interpreter.installSegment3>(Compiler::Stats::opcodePcExpellExplicit); + interpreter.installSegment3>(Compiler::Stats::opcodePcClearExpelled); + interpreter.installSegment3>(Compiler::Stats::opcodePcClearExpelledExplicit); + interpreter.installSegment5>(Compiler::Stats::opcodeRaiseRank); + interpreter.installSegment5>(Compiler::Stats::opcodeRaiseRankExplicit); + interpreter.installSegment5>(Compiler::Stats::opcodeLowerRank); + interpreter.installSegment5>(Compiler::Stats::opcodeLowerRankExplicit); + + interpreter.installSegment5>(Compiler::Stats::opcodeOnDeath); + interpreter.installSegment5>(Compiler::Stats::opcodeOnDeathExplicit); + interpreter.installSegment5>(Compiler::Stats::opcodeOnMurder); + interpreter.installSegment5>(Compiler::Stats::opcodeOnMurderExplicit); + interpreter.installSegment5>(Compiler::Stats::opcodeOnKnockout); + interpreter.installSegment5>(Compiler::Stats::opcodeOnKnockoutExplicit); + + interpreter.installSegment5>(Compiler::Stats::opcodeIsWerewolf); + interpreter.installSegment5>(Compiler::Stats::opcodeIsWerewolfExplicit); + + interpreter.installSegment5>(Compiler::Stats::opcodeBecomeWerewolf); + interpreter.installSegment5>(Compiler::Stats::opcodeBecomeWerewolfExplicit); + interpreter.installSegment5>(Compiler::Stats::opcodeUndoWerewolf); + interpreter.installSegment5>(Compiler::Stats::opcodeUndoWerewolfExplicit); + interpreter.installSegment5>(Compiler::Stats::opcodeSetWerewolfAcrobatics); + interpreter.installSegment5>(Compiler::Stats::opcodeSetWerewolfAcrobaticsExplicit); + interpreter.installSegment5>(Compiler::Stats::opcodeGetStat); + interpreter.installSegment5>(Compiler::Stats::opcodeGetStatExplicit); static const MagicEffect sMagicEffects[] = { { ESM::MagicEffect::ResistMagicka, ESM::MagicEffect::WeaknessToMagicka }, @@ -1498,14 +1484,14 @@ namespace MWScript int positive = sMagicEffects[i].mPositiveEffect; int negative = sMagicEffects[i].mNegativeEffect; - interpreter.installSegment5 (Compiler::Stats::opcodeGetMagicEffect+i, new OpGetMagicEffect (positive, negative)); - interpreter.installSegment5 (Compiler::Stats::opcodeGetMagicEffectExplicit+i, new OpGetMagicEffect (positive, negative)); + interpreter.installSegment5>(Compiler::Stats::opcodeGetMagicEffect + i, positive, negative); + interpreter.installSegment5>(Compiler::Stats::opcodeGetMagicEffectExplicit + i, positive, negative); - interpreter.installSegment5 (Compiler::Stats::opcodeSetMagicEffect+i, new OpSetMagicEffect (positive, negative)); - interpreter.installSegment5 (Compiler::Stats::opcodeSetMagicEffectExplicit+i, new OpSetMagicEffect (positive, negative)); + interpreter.installSegment5>(Compiler::Stats::opcodeSetMagicEffect + i, positive, negative); + interpreter.installSegment5>(Compiler::Stats::opcodeSetMagicEffectExplicit + i, positive, negative); - interpreter.installSegment5 (Compiler::Stats::opcodeModMagicEffect+i, new OpModMagicEffect (positive, negative)); - interpreter.installSegment5 (Compiler::Stats::opcodeModMagicEffectExplicit+i, new OpModMagicEffect (positive, negative)); + interpreter.installSegment5>(Compiler::Stats::opcodeModMagicEffect + i, positive, negative); + interpreter.installSegment5>(Compiler::Stats::opcodeModMagicEffectExplicit + i, positive, negative); } } } diff --git a/apps/openmw/mwscript/transformationextensions.cpp b/apps/openmw/mwscript/transformationextensions.cpp index 8a159a5685..57399cf02b 100644 --- a/apps/openmw/mwscript/transformationextensions.cpp +++ b/apps/openmw/mwscript/transformationextensions.cpp @@ -799,47 +799,47 @@ namespace MWScript void installOpcodes (Interpreter::Interpreter& interpreter) { - interpreter.installSegment5(Compiler::Transformation::opcodeGetDistance, new OpGetDistance); - interpreter.installSegment5(Compiler::Transformation::opcodeGetDistanceExplicit, new OpGetDistance); - 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 OpPlaceAt); - interpreter.installSegment5(Compiler::Transformation::opcodePlaceAtMe,new OpPlaceAt); - interpreter.installSegment5(Compiler::Transformation::opcodePlaceAtMeExplicit,new OpPlaceAt); - 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); - interpreter.installSegment5(Compiler::Transformation::opcodeResetActors, new OpResetActors); - interpreter.installSegment5(Compiler::Transformation::opcodeFixme, new OpFixme); + interpreter.installSegment5>(Compiler::Transformation::opcodeGetDistance); + interpreter.installSegment5>(Compiler::Transformation::opcodeGetDistanceExplicit); + interpreter.installSegment5>(Compiler::Transformation::opcodeSetScale); + interpreter.installSegment5>(Compiler::Transformation::opcodeSetScaleExplicit); + interpreter.installSegment5>(Compiler::Transformation::opcodeSetAngle); + interpreter.installSegment5>(Compiler::Transformation::opcodeSetAngleExplicit); + interpreter.installSegment5>(Compiler::Transformation::opcodeGetScale); + interpreter.installSegment5>(Compiler::Transformation::opcodeGetScaleExplicit); + interpreter.installSegment5>(Compiler::Transformation::opcodeGetAngle); + interpreter.installSegment5>(Compiler::Transformation::opcodeGetAngleExplicit); + interpreter.installSegment5>(Compiler::Transformation::opcodeGetPos); + interpreter.installSegment5>(Compiler::Transformation::opcodeGetPosExplicit); + interpreter.installSegment5>(Compiler::Transformation::opcodeSetPos); + interpreter.installSegment5>(Compiler::Transformation::opcodeSetPosExplicit); + interpreter.installSegment5>(Compiler::Transformation::opcodeGetStartingPos); + interpreter.installSegment5>(Compiler::Transformation::opcodeGetStartingPosExplicit); + interpreter.installSegment5>(Compiler::Transformation::opcodePosition); + interpreter.installSegment5>(Compiler::Transformation::opcodePositionExplicit); + interpreter.installSegment5>(Compiler::Transformation::opcodePositionCell); + interpreter.installSegment5>(Compiler::Transformation::opcodePositionCellExplicit); + interpreter.installSegment5(Compiler::Transformation::opcodePlaceItemCell); + interpreter.installSegment5(Compiler::Transformation::opcodePlaceItem); + interpreter.installSegment5>(Compiler::Transformation::opcodePlaceAtPc); + interpreter.installSegment5>(Compiler::Transformation::opcodePlaceAtMe); + interpreter.installSegment5>(Compiler::Transformation::opcodePlaceAtMeExplicit); + interpreter.installSegment5>(Compiler::Transformation::opcodeModScale); + interpreter.installSegment5>(Compiler::Transformation::opcodeModScaleExplicit); + interpreter.installSegment5>(Compiler::Transformation::opcodeRotate); + interpreter.installSegment5>(Compiler::Transformation::opcodeRotateExplicit); + interpreter.installSegment5>(Compiler::Transformation::opcodeRotateWorld); + interpreter.installSegment5>(Compiler::Transformation::opcodeRotateWorldExplicit); + interpreter.installSegment5>(Compiler::Transformation::opcodeSetAtStart); + interpreter.installSegment5>(Compiler::Transformation::opcodeSetAtStartExplicit); + interpreter.installSegment5>(Compiler::Transformation::opcodeMove); + interpreter.installSegment5>(Compiler::Transformation::opcodeMoveExplicit); + interpreter.installSegment5>(Compiler::Transformation::opcodeMoveWorld); + interpreter.installSegment5>(Compiler::Transformation::opcodeMoveWorldExplicit); + interpreter.installSegment5>(Compiler::Transformation::opcodeGetStartingAngle); + interpreter.installSegment5>(Compiler::Transformation::opcodeGetStartingAngleExplicit); + interpreter.installSegment5(Compiler::Transformation::opcodeResetActors); + interpreter.installSegment5(Compiler::Transformation::opcodeFixme); } } } diff --git a/apps/openmw/mwscript/userextensions.cpp b/apps/openmw/mwscript/userextensions.cpp index 3f443304d7..f929425a9c 100644 --- a/apps/openmw/mwscript/userextensions.cpp +++ b/apps/openmw/mwscript/userextensions.cpp @@ -66,12 +66,12 @@ namespace MWScript void installOpcodes (Interpreter::Interpreter& interpreter) { - 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); + interpreter.installSegment5(Compiler::User::opcodeUser1); + interpreter.installSegment5(Compiler::User::opcodeUser2); + interpreter.installSegment5>(Compiler::User::opcodeUser3); + interpreter.installSegment5>(Compiler::User::opcodeUser3Explicit); + interpreter.installSegment5>(Compiler::User::opcodeUser4); + interpreter.installSegment5>(Compiler::User::opcodeUser4Explicit); } } } diff --git a/apps/openmw_test_suite/mwscript/test_scripts.cpp b/apps/openmw_test_suite/mwscript/test_scripts.cpp index c04860afdf..dea2a0dc8a 100644 --- a/apps/openmw_test_suite/mwscript/test_scripts.cpp +++ b/apps/openmw_test_suite/mwscript/test_scripts.cpp @@ -49,10 +49,12 @@ namespace mInterpreter.run(&script.mByteCode[0], static_cast(script.mByteCode.size()), context); } - void installOpcode(int code, Interpreter::Opcode0* opcode) + template + void installOpcode(int code, TArgs&& ...args) { - mInterpreter.installSegment5(code, opcode); + mInterpreter.installSegment5(code, std::forward(args)...); } + protected: void SetUp() override { @@ -472,7 +474,7 @@ messagebox,"this is a %g",a EXPECT_EQ(topic, "OpenMW Unit Test"); } }; - installOpcode(Compiler::Dialogue::opcodeAddTopic, new AddTopic(failed)); + installOpcode(Compiler::Dialogue::opcodeAddTopic, failed); TestInterpreterContext context; run(*script, context); } @@ -715,7 +717,7 @@ messagebox,"this is a %g",a mTopics.erase(mTopics.begin()); } }; - installOpcode(Compiler::Dialogue::opcodeAddTopic, new AddTopic(topics)); + installOpcode(Compiler::Dialogue::opcodeAddTopic, topics); TestInterpreterContext context; run(*script, context); EXPECT_TRUE(topics.empty()); @@ -826,7 +828,7 @@ messagebox,"this is a %g",a } }; bool ran = false; - installOpcode(Compiler::Transformation::opcodePositionCell, new PositionCell(ran)); + installOpcode(Compiler::Transformation::opcodePositionCell, ran); TestInterpreterContext context; context.setLocalShort(0, 0); run(*script, context); diff --git a/components/interpreter/installopcodes.cpp b/components/interpreter/installopcodes.cpp index b5cb229e84..d5e9bb0cc5 100644 --- a/components/interpreter/installopcodes.cpp +++ b/components/interpreter/installopcodes.cpp @@ -11,89 +11,77 @@ namespace Interpreter { - void installOpcodes (Interpreter& interpreter) + void installOpcodes(Interpreter& interpreter) { // generic - interpreter.installSegment0 (0, new OpPushInt); - interpreter.installSegment5 (3, new OpIntToFloat); - interpreter.installSegment5 (6, new OpFloatToInt); - interpreter.installSegment5 (7, new OpNegateInt); - interpreter.installSegment5 (8, new OpNegateFloat); - interpreter.installSegment5 (17, new OpIntToFloat1); - interpreter.installSegment5 (18, new OpFloatToInt1); + interpreter.installSegment0(0); + interpreter.installSegment5(3); + interpreter.installSegment5(6); + interpreter.installSegment5(7); + interpreter.installSegment5(8); + interpreter.installSegment5(17); + interpreter.installSegment5(18); // local variables, global variables & literals - interpreter.installSegment5 (0, new OpStoreLocalShort); - interpreter.installSegment5 (1, new OpStoreLocalLong); - interpreter.installSegment5 (2, new OpStoreLocalFloat); - interpreter.installSegment5 (4, new OpFetchIntLiteral); - interpreter.installSegment5 (5, new OpFetchFloatLiteral); - interpreter.installSegment5 (21, new OpFetchLocalShort); - interpreter.installSegment5 (22, new OpFetchLocalLong); - interpreter.installSegment5 (23, new OpFetchLocalFloat); - interpreter.installSegment5 (39, new OpStoreGlobalShort); - interpreter.installSegment5 (40, new OpStoreGlobalLong); - interpreter.installSegment5 (41, new OpStoreGlobalFloat); - interpreter.installSegment5 (42, new OpFetchGlobalShort); - interpreter.installSegment5 (43, new OpFetchGlobalLong); - interpreter.installSegment5 (44, new OpFetchGlobalFloat); - interpreter.installSegment5 (59, new OpStoreMemberShort (false)); - interpreter.installSegment5 (60, new OpStoreMemberLong (false)); - interpreter.installSegment5 (61, new OpStoreMemberFloat (false)); - interpreter.installSegment5 (62, new OpFetchMemberShort (false)); - interpreter.installSegment5 (63, new OpFetchMemberLong (false)); - interpreter.installSegment5 (64, new OpFetchMemberFloat (false)); - interpreter.installSegment5 (65, new OpStoreMemberShort (true)); - interpreter.installSegment5 (66, new OpStoreMemberLong (true)); - interpreter.installSegment5 (67, new OpStoreMemberFloat (true)); - interpreter.installSegment5 (68, new OpFetchMemberShort (true)); - interpreter.installSegment5 (69, new OpFetchMemberLong (true)); - interpreter.installSegment5 (70, new OpFetchMemberFloat (true)); + interpreter.installSegment5(0); + interpreter.installSegment5(1); + interpreter.installSegment5(2); + interpreter.installSegment5(4); + interpreter.installSegment5(5); + interpreter.installSegment5(21); + interpreter.installSegment5(22); + interpreter.installSegment5(23); + interpreter.installSegment5(39); + interpreter.installSegment5(40); + interpreter.installSegment5(41); + interpreter.installSegment5(42); + interpreter.installSegment5(43); + interpreter.installSegment5(44); + interpreter.installSegment5>(59); + interpreter.installSegment5>(60); + interpreter.installSegment5>(61); + interpreter.installSegment5>(62); + interpreter.installSegment5>(63); + interpreter.installSegment5>(64); + interpreter.installSegment5>(65); + interpreter.installSegment5>(66); + interpreter.installSegment5>(67); + interpreter.installSegment5>(68); + interpreter.installSegment5>(69); + interpreter.installSegment5>(70); // math - interpreter.installSegment5 (9, new OpAddInt); - interpreter.installSegment5 (10, new OpAddInt); - interpreter.installSegment5 (11, new OpSubInt); - interpreter.installSegment5 (12, new OpSubInt); - interpreter.installSegment5 (13, new OpMulInt); - interpreter.installSegment5 (14, new OpMulInt); - interpreter.installSegment5 (15, new OpDivInt); - interpreter.installSegment5 (16, new OpDivInt); - interpreter.installSegment5 (26, - new OpCompare >); - interpreter.installSegment5 (27, - new OpCompare >); - interpreter.installSegment5 (28, - new OpCompare >); - interpreter.installSegment5 (29, - new OpCompare >); - interpreter.installSegment5 (30, - new OpCompare >); - interpreter.installSegment5 (31, - new OpCompare >); + interpreter.installSegment5>(9); + interpreter.installSegment5>(10); + interpreter.installSegment5>(11); + interpreter.installSegment5>(12); + interpreter.installSegment5>(13); + interpreter.installSegment5>(14); + interpreter.installSegment5>(15); + interpreter.installSegment5>(16); + interpreter.installSegment5 >>(26); + interpreter.installSegment5 >>(27); + interpreter.installSegment5 >>(28); + interpreter.installSegment5 >>(29); + interpreter.installSegment5 >>(30); + interpreter.installSegment5 >>(31); - interpreter.installSegment5 (32, - new OpCompare >); - interpreter.installSegment5 (33, - new OpCompare >); - interpreter.installSegment5 (34, - new OpCompare >); - interpreter.installSegment5 (35, - new OpCompare >); - interpreter.installSegment5 (36, - new OpCompare >); - interpreter.installSegment5 (37, - new OpCompare >); + interpreter.installSegment5 >>(32); + interpreter.installSegment5 >>(33); + interpreter.installSegment5 >>(34); + interpreter.installSegment5 >>(35); + interpreter.installSegment5 >>(36); + interpreter.installSegment5 >>(37); // control structures - interpreter.installSegment5 (20, new OpReturn); - interpreter.installSegment5 (24, new OpSkipZero); - interpreter.installSegment5 (25, new OpSkipNonZero); - interpreter.installSegment0 (1, new OpJumpForward); - interpreter.installSegment0 (2, new OpJumpBackward); + interpreter.installSegment5(20); + interpreter.installSegment5(24); + interpreter.installSegment5(25); + interpreter.installSegment0(1); + interpreter.installSegment0(2); // misc - interpreter.installSegment3 (0, new OpMessageBox); - interpreter.installSegment5 (58, new OpReport); + interpreter.installSegment3(0); + interpreter.installSegment5(58); } } diff --git a/components/interpreter/interpreter.cpp b/components/interpreter/interpreter.cpp index c04352a90f..69f3111440 100644 --- a/components/interpreter/interpreter.cpp +++ b/components/interpreter/interpreter.cpp @@ -7,92 +7,75 @@ namespace Interpreter { + [[noreturn]] static void abortUnknownCode(int segment, int opcode) + { + const std::string error = "unknown opcode " + std::to_string(opcode) + " in segment " + std::to_string(segment); + throw std::runtime_error(error); + } + + [[noreturn]] static void abortUnknownSegment(Type_Code code) + { + const std::string error = "opcode outside of the allocated segment range: " + std::to_string(code); + throw std::runtime_error(error); + } + + template + auto& getDispatcher(const T& segment, unsigned int seg, int opcode) + { + auto it = segment.find(opcode); + if (it == segment.end()) + { + abortUnknownCode(seg, opcode); + } + return it->second; + } + void Interpreter::execute (Type_Code code) { - unsigned int segSpec = code>>30; + unsigned int segSpec = code >> 30; switch (segSpec) { case 0: { - int opcode = code>>24; - unsigned int arg0 = code & 0xffffff; + const int opcode = code >> 24; + const unsigned int arg0 = code & 0xffffff; - std::map::iterator iter = mSegment0.find (opcode); - - if (iter==mSegment0.end()) - abortUnknownCode (0, opcode); - - iter->second->execute (mRuntime, arg0); - - return; + return getDispatcher(mSegment0, 0, opcode)->execute(mRuntime, arg0); } case 2: { - int opcode = (code>>20) & 0x3ff; - unsigned int arg0 = code & 0xfffff; - - std::map::iterator iter = mSegment2.find (opcode); + const int opcode = (code >> 20) & 0x3ff; + const unsigned int arg0 = code & 0xfffff; - if (iter==mSegment2.end()) - abortUnknownCode (2, opcode); - - iter->second->execute (mRuntime, arg0); - - return; + return getDispatcher(mSegment2, 2, opcode)->execute(mRuntime, arg0); } } - segSpec = code>>26; + segSpec = code >> 26; switch (segSpec) { case 0x30: { - int opcode = (code>>8) & 0x3ffff; - unsigned int arg0 = code & 0xff; - - std::map::iterator iter = mSegment3.find (opcode); + const int opcode = (code >> 8) & 0x3ffff; + const unsigned int arg0 = code & 0xff; - if (iter==mSegment3.end()) - abortUnknownCode (3, opcode); - - iter->second->execute (mRuntime, arg0); - - return; + return getDispatcher(mSegment3, 3, opcode)->execute(mRuntime, arg0); } case 0x32: { - int opcode = code & 0x3ffffff; - - std::map::iterator iter = mSegment5.find (opcode); + const int opcode = code & 0x3ffffff; - if (iter==mSegment5.end()) - abortUnknownCode (5, opcode); - - iter->second->execute (mRuntime); - - return; + return getDispatcher(mSegment5, 5, opcode)->execute(mRuntime); } } abortUnknownSegment (code); } - [[noreturn]] void Interpreter::abortUnknownCode (int segment, int opcode) - { - const std::string error = "unknown opcode " + std::to_string(opcode) + " in segment " + std::to_string(segment); - throw std::runtime_error (error); - } - - [[noreturn]] void Interpreter::abortUnknownSegment (Type_Code code) - { - const std::string error = "opcode outside of the allocated segment range: " + std::to_string(code); - throw std::runtime_error (error); - } - void Interpreter::begin() { if (mRunning) @@ -123,49 +106,6 @@ namespace Interpreter Interpreter::Interpreter() : mRunning (false) {} - Interpreter::~Interpreter() - { - for (std::map::iterator iter (mSegment0.begin()); - iter!=mSegment0.end(); ++iter) - delete iter->second; - - for (std::map::iterator iter (mSegment2.begin()); - iter!=mSegment2.end(); ++iter) - delete iter->second; - - for (std::map::iterator iter (mSegment3.begin()); - iter!=mSegment3.end(); ++iter) - delete iter->second; - - for (std::map::iterator iter (mSegment5.begin()); - iter!=mSegment5.end(); ++iter) - delete iter->second; - } - - void Interpreter::installSegment0 (int code, Opcode1 *opcode) - { - assert(mSegment0.find(code) == mSegment0.end()); - mSegment0.insert (std::make_pair (code, opcode)); - } - - void Interpreter::installSegment2 (int code, Opcode1 *opcode) - { - assert(mSegment2.find(code) == mSegment2.end()); - mSegment2.insert (std::make_pair (code, opcode)); - } - - void Interpreter::installSegment3 (int code, Opcode1 *opcode) - { - assert(mSegment3.find(code) == mSegment3.end()); - mSegment3.insert (std::make_pair (code, opcode)); - } - - void Interpreter::installSegment5 (int code, Opcode0 *opcode) - { - assert(mSegment5.find(code) == mSegment5.end()); - mSegment5.insert (std::make_pair (code, opcode)); - } - void Interpreter::run (const Type_Code *code, int codeSize, Context& context) { assert (codeSize>=4); diff --git a/components/interpreter/interpreter.hpp b/components/interpreter/interpreter.hpp index 3aa5e36d58..2e08e6614b 100644 --- a/components/interpreter/interpreter.hpp +++ b/components/interpreter/interpreter.hpp @@ -3,24 +3,25 @@ #include #include +#include +#include +#include #include "runtime.hpp" #include "types.hpp" +#include "opcodes.hpp" namespace Interpreter { - class Opcode0; - class Opcode1; - class Interpreter { std::stack mCallstack; bool mRunning; Runtime mRuntime; - std::map mSegment0; - std::map mSegment2; - std::map mSegment3; - std::map mSegment5; + std::map> mSegment0; + std::map> mSegment2; + std::map> mSegment3; + std::map> mSegment5; // not implemented Interpreter (const Interpreter&); @@ -28,31 +29,44 @@ namespace Interpreter void execute (Type_Code code); - [[noreturn]] void abortUnknownCode (int segment, int opcode); - - [[noreturn]] void abortUnknownSegment (Type_Code code); - void begin(); void end(); + template + void installSegment(TSeg& seg, int code, TOp&& op) + { + assert(seg.find(code) == seg.end()); + seg.emplace(code, std::move(op)); + } + public: Interpreter(); - ~Interpreter(); - - void installSegment0 (int code, Opcode1 *opcode); - ///< ownership of \a opcode is transferred to *this. - - void installSegment2 (int code, Opcode1 *opcode); - ///< ownership of \a opcode is transferred to *this. - - void installSegment3 (int code, Opcode1 *opcode); - ///< ownership of \a opcode is transferred to *this. - - void installSegment5 (int code, Opcode0 *opcode); - ///< ownership of \a opcode is transferred to *this. + template + void installSegment0(int code, TArgs&& ...args) + { + installSegment(mSegment0, code, std::make_unique(std::forward(args)...)); + } + + template + void installSegment2(int code, TArgs&& ...args) + { + installSegment(mSegment2, code, std::make_unique(std::forward(args)...)); + } + + template + void installSegment3(int code, TArgs&& ...args) + { + installSegment(mSegment3, code, std::make_unique(std::forward(args)...)); + } + + template + void installSegment5(int code, TArgs&& ...args) + { + installSegment(mSegment5, code, std::make_unique(std::forward(args)...)); + } void run (const Type_Code *code, int codeSize, Context& context); }; diff --git a/components/interpreter/localopcodes.hpp b/components/interpreter/localopcodes.hpp index 0227327b3a..72a730ae99 100644 --- a/components/interpreter/localopcodes.hpp +++ b/components/interpreter/localopcodes.hpp @@ -206,14 +206,11 @@ namespace Interpreter } }; + template class OpStoreMemberShort : public Opcode0 { - bool mGlobal; - public: - OpStoreMemberShort (bool global) : mGlobal (global) {} - void execute (Runtime& runtime) override { Type_Integer data = runtime[0].mInteger; @@ -222,7 +219,7 @@ namespace Interpreter index = runtime[2].mInteger; std::string variable = runtime.getStringLiteral (index); - runtime.getContext().setMemberShort (id, variable, data, mGlobal); + runtime.getContext().setMemberShort (id, variable, data, TGlobal); runtime.pop(); runtime.pop(); @@ -230,14 +227,11 @@ namespace Interpreter } }; + template class OpStoreMemberLong : public Opcode0 { - bool mGlobal; - public: - OpStoreMemberLong (bool global) : mGlobal (global) {} - void execute (Runtime& runtime) override { Type_Integer data = runtime[0].mInteger; @@ -246,7 +240,7 @@ namespace Interpreter index = runtime[2].mInteger; std::string variable = runtime.getStringLiteral (index); - runtime.getContext().setMemberLong (id, variable, data, mGlobal); + runtime.getContext().setMemberLong (id, variable, data, TGlobal); runtime.pop(); runtime.pop(); @@ -254,14 +248,11 @@ namespace Interpreter } }; + template class OpStoreMemberFloat : public Opcode0 { - bool mGlobal; - public: - OpStoreMemberFloat (bool global) : mGlobal (global) {} - void execute (Runtime& runtime) override { Type_Float data = runtime[0].mFloat; @@ -270,7 +261,7 @@ namespace Interpreter index = runtime[2].mInteger; std::string variable = runtime.getStringLiteral (index); - runtime.getContext().setMemberFloat (id, variable, data, mGlobal); + runtime.getContext().setMemberFloat (id, variable, data, TGlobal); runtime.pop(); runtime.pop(); @@ -278,14 +269,11 @@ namespace Interpreter } }; + template class OpFetchMemberShort : public Opcode0 { - bool mGlobal; - public: - OpFetchMemberShort (bool global) : mGlobal (global) {} - void execute (Runtime& runtime) override { Type_Integer index = runtime[0].mInteger; @@ -294,19 +282,16 @@ namespace Interpreter std::string variable = runtime.getStringLiteral (index); runtime.pop(); - int value = runtime.getContext().getMemberShort (id, variable, mGlobal); + int value = runtime.getContext().getMemberShort (id, variable, TGlobal); runtime[0].mInteger = value; } }; + template class OpFetchMemberLong : public Opcode0 { - bool mGlobal; - public: - OpFetchMemberLong (bool global) : mGlobal (global) {} - void execute (Runtime& runtime) override { Type_Integer index = runtime[0].mInteger; @@ -315,19 +300,16 @@ namespace Interpreter std::string variable = runtime.getStringLiteral (index); runtime.pop(); - int value = runtime.getContext().getMemberLong (id, variable, mGlobal); + int value = runtime.getContext().getMemberLong (id, variable, TGlobal); runtime[0].mInteger = value; } }; + template class OpFetchMemberFloat : public Opcode0 { - bool mGlobal; - public: - OpFetchMemberFloat (bool global) : mGlobal (global) {} - void execute (Runtime& runtime) override { Type_Integer index = runtime[0].mInteger; @@ -336,7 +318,7 @@ namespace Interpreter std::string variable = runtime.getStringLiteral (index); runtime.pop(); - float value = runtime.getContext().getMemberFloat (id, variable, mGlobal); + float value = runtime.getContext().getMemberFloat (id, variable, TGlobal); runtime[0].mFloat = value; } };