changed collision mode instruction from enable/disable to toggle

This commit is contained in:
Marc Zinnschlag 2011-01-09 21:07:27 +01:00
parent 42ef7a61a0
commit 46a8ccc2ff
3 changed files with 9 additions and 20 deletions

View file

@ -37,32 +37,24 @@ namespace MWScript
} }
}; };
class OpSetCollision : public Interpreter::Opcode0 class OpToggleCollision : public Interpreter::Opcode0
{ {
bool mEnable;
public: public:
OpSetCollision (bool enable)
: mEnable (enable)
{}
virtual void execute (Interpreter::Runtime& runtime) virtual void execute (Interpreter::Runtime& runtime)
{ {
InterpreterContext& context InterpreterContext& context
= static_cast<InterpreterContext&> (runtime.getContext()); = static_cast<InterpreterContext&> (runtime.getContext());
context.getWorld().getPlayer().setCollisionMode (mEnable); context.getWorld().getPlayer().toggleCollisionMode();
} }
}; };
const int numberOfControls = 7; const int numberOfControls = 7;
const int opcodeEnable = 0x200007e; const int opcodeEnable = 0x200007e;
const int opcodeDisable = 0x2000085; const int opcodeDisable = 0x2000085;
const int opcodeEnableCollision = 0x2000130; const int opcodeToggleCollision = 0x2000130;
const int opcodeDisableCollision = 0x2000131;
const char *controls[numberOfControls] = const char *controls[numberOfControls] =
{ {
@ -81,8 +73,7 @@ namespace MWScript
extensions.registerInstruction (disable + controls[i], "", opcodeDisable+i); extensions.registerInstruction (disable + controls[i], "", opcodeDisable+i);
} }
extensions.registerInstruction ("enablecollision", "", opcodeEnableCollision); extensions.registerInstruction ("togglecollision", "", opcodeToggleCollision);
extensions.registerInstruction ("disablecollision", "", opcodeDisableCollision);
} }
void installOpcodes (Interpreter::Interpreter& interpreter) void installOpcodes (Interpreter::Interpreter& interpreter)
@ -93,8 +84,7 @@ namespace MWScript
interpreter.installSegment5 (opcodeDisable+i, new OpSetControl (controls[i], false)); interpreter.installSegment5 (opcodeDisable+i, new OpSetControl (controls[i], false));
} }
interpreter.installSegment5 (opcodeEnableCollision, new OpSetCollision (true)); interpreter.installSegment5 (opcodeToggleCollision, new OpToggleCollision);
interpreter.installSegment5 (opcodeDisableCollision, new OpSetCollision (false));
} }
} }
} }

View file

@ -101,6 +101,5 @@ op 0x20000c4-0x20000de: SetSkill
op 0x20000df-0x20000f9: SetSkill, explicit reference op 0x20000df-0x20000f9: SetSkill, explicit reference
op 0x20000fa-0x2000114: ModSkill op 0x20000fa-0x2000114: ModSkill
op 0x2000115-0x200012f: ModSKill, explicit reference op 0x2000115-0x200012f: ModSKill, explicit reference
op 0x2000130: EnableCollision op 0x2000130: ToggleCollision
op 0x2000131: DisableCollision opcodes 0x2000131-0x3ffffff unused
opcodes 0x2000130-0x3ffffff unused

View file

@ -104,9 +104,9 @@ namespace MWWorld
return *mClass; return *mClass;
} }
void setCollisionMode (bool enable) void toggleCollisionMode()
{ {
mCollisionMode = enable; mCollisionMode = !mCollisionMode;
} }
}; };
} }