From 46a8ccc2ff114f50d73fedded2074eca5464ad7f Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 9 Jan 2011 21:07:27 +0100 Subject: [PATCH] changed collision mode instruction from enable/disable to toggle --- apps/openmw/mwscript/controlextensions.cpp | 20 +++++--------------- apps/openmw/mwscript/docs/vmformat.txt | 5 ++--- apps/openmw/mwworld/player.hpp | 4 ++-- 3 files changed, 9 insertions(+), 20 deletions(-) diff --git a/apps/openmw/mwscript/controlextensions.cpp b/apps/openmw/mwscript/controlextensions.cpp index a560a28c6..5020675d1 100644 --- a/apps/openmw/mwscript/controlextensions.cpp +++ b/apps/openmw/mwscript/controlextensions.cpp @@ -37,32 +37,24 @@ namespace MWScript } }; - class OpSetCollision : public Interpreter::Opcode0 + class OpToggleCollision : public Interpreter::Opcode0 { - bool mEnable; - public: - OpSetCollision (bool enable) - : mEnable (enable) - {} - virtual void execute (Interpreter::Runtime& runtime) { InterpreterContext& context = static_cast (runtime.getContext()); - context.getWorld().getPlayer().setCollisionMode (mEnable); + context.getWorld().getPlayer().toggleCollisionMode(); } - }; const int numberOfControls = 7; const int opcodeEnable = 0x200007e; const int opcodeDisable = 0x2000085; - const int opcodeEnableCollision = 0x2000130; - const int opcodeDisableCollision = 0x2000131; + const int opcodeToggleCollision = 0x2000130; const char *controls[numberOfControls] = { @@ -81,8 +73,7 @@ namespace MWScript extensions.registerInstruction (disable + controls[i], "", opcodeDisable+i); } - extensions.registerInstruction ("enablecollision", "", opcodeEnableCollision); - extensions.registerInstruction ("disablecollision", "", opcodeDisableCollision); + extensions.registerInstruction ("togglecollision", "", opcodeToggleCollision); } void installOpcodes (Interpreter::Interpreter& interpreter) @@ -93,8 +84,7 @@ namespace MWScript interpreter.installSegment5 (opcodeDisable+i, new OpSetControl (controls[i], false)); } - interpreter.installSegment5 (opcodeEnableCollision, new OpSetCollision (true)); - interpreter.installSegment5 (opcodeDisableCollision, new OpSetCollision (false)); + interpreter.installSegment5 (opcodeToggleCollision, new OpToggleCollision); } } } diff --git a/apps/openmw/mwscript/docs/vmformat.txt b/apps/openmw/mwscript/docs/vmformat.txt index b77f53221..ac78f8005 100644 --- a/apps/openmw/mwscript/docs/vmformat.txt +++ b/apps/openmw/mwscript/docs/vmformat.txt @@ -101,6 +101,5 @@ op 0x20000c4-0x20000de: SetSkill op 0x20000df-0x20000f9: SetSkill, explicit reference op 0x20000fa-0x2000114: ModSkill op 0x2000115-0x200012f: ModSKill, explicit reference -op 0x2000130: EnableCollision -op 0x2000131: DisableCollision -opcodes 0x2000130-0x3ffffff unused +op 0x2000130: ToggleCollision +opcodes 0x2000131-0x3ffffff unused diff --git a/apps/openmw/mwworld/player.hpp b/apps/openmw/mwworld/player.hpp index b54afad56..997282ca6 100644 --- a/apps/openmw/mwworld/player.hpp +++ b/apps/openmw/mwworld/player.hpp @@ -104,9 +104,9 @@ namespace MWWorld return *mClass; } - void setCollisionMode (bool enable) + void toggleCollisionMode() { - mCollisionMode = enable; + mCollisionMode = !mCollisionMode; } }; }