From 2ffe1206a64111b2fd7c051fa86cf02815a77db2 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 31 Dec 2010 19:09:25 +0100 Subject: [PATCH 01/18] merged opcode classes that came in explicit and implicit variants --- apps/openmw/CMakeLists.txt | 1 + apps/openmw/mwscript/aiextensions.cpp | 121 +----- apps/openmw/mwscript/containerextensions.cpp | 145 +------ apps/openmw/mwscript/miscextensions.cpp | 69 +-- apps/openmw/mwscript/ref.hpp | 41 ++ apps/openmw/mwscript/soundextensions.cpp | 335 +++++--------- apps/openmw/mwscript/statsextensions.cpp | 434 ++----------------- 7 files changed, 237 insertions(+), 909 deletions(-) create mode 100644 apps/openmw/mwscript/ref.hpp diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 88aaaecd48..ffbcf590f2 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -103,6 +103,7 @@ set(GAMESCRIPT_HEADER mwscript/controlextensions.hpp mwscript/extensions.hpp mwscript/globalscripts.hpp + mwscript/ref.hpp ) source_group(apps\\openmw\\mwscript FILES ${GAMESCRIPT} ${GAMESCRIPT_HEADER}) diff --git a/apps/openmw/mwscript/aiextensions.cpp b/apps/openmw/mwscript/aiextensions.cpp index cd36eac9e1..6d74ae45a2 100644 --- a/apps/openmw/mwscript/aiextensions.cpp +++ b/apps/openmw/mwscript/aiextensions.cpp @@ -8,6 +8,7 @@ #include #include "interpretercontext.hpp" +#include "ref.hpp" #include @@ -15,46 +16,14 @@ namespace MWScript { namespace Ai { + template class OpAiTravel : public Interpreter::Opcode1 { public: virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0) { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - - MWWorld::Ptr ptr = context.getReference(); - - Interpreter::Type_Float x = runtime[0].mInteger; - runtime.pop(); - - Interpreter::Type_Float y = runtime[0].mInteger; - runtime.pop(); - - Interpreter::Type_Float z = runtime[0].mInteger; - runtime.pop(); - - // discard additional arguments (reset), because we have no idea what they mean. - for (unsigned int i=0; i (runtime.getContext()); - - std::string id = runtime.getStringLiteral (runtime[0].mInteger); - runtime.pop(); - - MWWorld::Ptr ptr = context.getWorld().getPtr (id, false); + MWWorld::Ptr ptr = R()(runtime); Interpreter::Type_Float x = runtime[0].mInteger; runtime.pop(); @@ -72,56 +41,14 @@ namespace MWScript } }; + template class OpAiEscort : public Interpreter::Opcode1 { public: virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0) { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - - std::string id = runtime.getStringLiteral (runtime[0].mInteger); - runtime.pop(); - - MWWorld::Ptr ptr = context.getReference(); - - std::string actor = runtime.getStringLiteral (runtime[0].mInteger); - runtime.pop(); - - Interpreter::Type_Float duration = runtime[0].mInteger; - runtime.pop(); - - Interpreter::Type_Float x = runtime[0].mInteger; - runtime.pop(); - - Interpreter::Type_Float y = runtime[0].mInteger; - runtime.pop(); - - Interpreter::Type_Float z = runtime[0].mInteger; - runtime.pop(); - - // discard additional arguments (reset), because we have no idea what they mean. - for (unsigned int i=0; i (runtime.getContext()); - - std::string id = runtime.getStringLiteral (runtime[0].mInteger); - runtime.pop(); - - MWWorld::Ptr ptr = context.getWorld().getPtr (id, false); + MWWorld::Ptr ptr = R()(runtime); std::string actor = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); @@ -146,16 +73,14 @@ namespace MWScript } }; + template class OpGetAiPackageDone : public Interpreter::Opcode0 { public: virtual void execute (Interpreter::Runtime& runtime) { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - - MWWorld::Ptr ptr = context.getReference(); + MWWorld::Ptr ptr = R()(runtime); Interpreter::Type_Integer value = 0; @@ -163,25 +88,6 @@ namespace MWScript } }; - class OpGetAiPackageDoneExplicit : public Interpreter::Opcode0 - { - public: - - virtual void execute (Interpreter::Runtime& runtime) - { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - - std::string id = runtime.getStringLiteral (runtime[0].mInteger); - runtime.pop(); - - MWWorld::Ptr ptr = context.getWorld().getPtr (id, false); - - Interpreter::Type_Integer value = 0; - - runtime.push (value); - } - }; const int opcodeAiTravel = 0x20000; @@ -204,12 +110,13 @@ namespace MWScript void installOpcodes (Interpreter::Interpreter& interpreter) { - interpreter.installSegment3 (opcodeAiTravel, new OpAiTravel); - interpreter.installSegment3 (opcodeAiTravelExplicit, new OpAiTravelExplicit); - interpreter.installSegment3 (opcodeAiEscort, new OpAiEscort); - interpreter.installSegment3 (opcodeAiEscortExplicit, new OpAiEscortExplicit); - interpreter.installSegment5 (opcodeGetAiPackageDone, new OpGetAiPackageDone); - interpreter.installSegment5 (opcodeGetAiPackageDoneExplicit, new OpGetAiPackageDoneExplicit); + interpreter.installSegment3 (opcodeAiTravel, new OpAiTravel); + interpreter.installSegment3 (opcodeAiTravelExplicit, new OpAiTravel); + interpreter.installSegment3 (opcodeAiEscort, new OpAiEscort); + interpreter.installSegment3 (opcodeAiEscortExplicit, new OpAiEscort); + interpreter.installSegment5 (opcodeGetAiPackageDone, new OpGetAiPackageDone); + interpreter.installSegment5 (opcodeGetAiPackageDoneExplicit, + new OpGetAiPackageDone); } } } diff --git a/apps/openmw/mwscript/containerextensions.cpp b/apps/openmw/mwscript/containerextensions.cpp index 1121d8eff4..aef48ddecd 100644 --- a/apps/openmw/mwscript/containerextensions.cpp +++ b/apps/openmw/mwscript/containerextensions.cpp @@ -14,17 +14,21 @@ #include "../mwworld/containerutil.hpp" #include "interpretercontext.hpp" +#include "ref.hpp" namespace MWScript { namespace Container { + template class OpAddItem : public Interpreter::Opcode0 { public: virtual void execute (Interpreter::Runtime& runtime) { + MWWorld::Ptr ptr = R()(runtime); + MWScript::InterpreterContext& context = static_cast (runtime.getContext()); @@ -37,40 +41,6 @@ namespace MWScript if (count<0) throw std::runtime_error ("second argument for AddItem must be non-negative"); - MWWorld::Ptr ptr = context.getReference(); - - MWWorld::ManualRef ref (context.getWorld().getStore(), item); - - ref.getPtr().getRefData().setCount (count); - - MWWorld::Class::get (ref.getPtr()).insertIntoContainer (ref.getPtr(), - MWWorld::Class::get (ptr).getContainerStore (ptr)); - } - }; - - class OpAddItemExplicit : public Interpreter::Opcode0 - { - public: - - virtual void execute (Interpreter::Runtime& runtime) - { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - - std::string id = runtime.getStringLiteral (runtime[0].mInteger); - runtime.pop(); - - std::string item = runtime.getStringLiteral (runtime[0].mInteger); - runtime.pop(); - - Interpreter::Type_Integer count = runtime[0].mInteger; - runtime.pop(); - - if (count<0) - throw std::runtime_error ("second argument for AddItem must be non-negative"); - - MWWorld::Ptr ptr = context.getWorld().getPtr (id, false); - MWWorld::ManualRef ref (context.getWorld().getStore(), item); ref.getPtr().getRefData().setCount (count); @@ -80,55 +50,21 @@ namespace MWScript } }; + template class OpGetItemCount : public Interpreter::Opcode0 { public: virtual void execute (Interpreter::Runtime& runtime) { + MWWorld::Ptr ptr = R()(runtime); + MWScript::InterpreterContext& context = static_cast (runtime.getContext()); std::string item = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); - MWWorld::Ptr ptr = context.getReference(); - - std::vector list; - - MWWorld::listItemsInContainer (item, - MWWorld::Class::get (ptr).getContainerStore (ptr), - context.getWorld().getStore(), list); - - Interpreter::Type_Integer sum = 0; - - for (std::vector::iterator iter (list.begin()); iter!=list.end(); - ++iter) - { - sum += iter->getRefData().getCount(); - } - - runtime.push (sum); - } - }; - - class OpGetItemCountExplicit : public Interpreter::Opcode0 - { - public: - - virtual void execute (Interpreter::Runtime& runtime) - { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - - std::string id = runtime.getStringLiteral (runtime[0].mInteger); - runtime.pop(); - - std::string item = runtime.getStringLiteral (runtime[0].mInteger); - runtime.pop(); - - MWWorld::Ptr ptr = context.getWorld().getPtr (id, false); - std::vector list; MWWorld::listItemsInContainer (item, @@ -147,12 +83,15 @@ namespace MWScript } }; + template class OpRemoveItem : public Interpreter::Opcode0 { public: virtual void execute (Interpreter::Runtime& runtime) { + MWWorld::Ptr ptr = R()(runtime); + MWScript::InterpreterContext& context = static_cast (runtime.getContext()); @@ -165,58 +104,6 @@ namespace MWScript if (count<0) throw std::runtime_error ("second argument for RemoveItem must be non-negative"); - MWWorld::Ptr ptr = context.getReference(); - - std::vector list; - - MWWorld::listItemsInContainer (item, - MWWorld::Class::get (ptr).getContainerStore (ptr), - context.getWorld().getStore(), list); - - for (std::vector::iterator iter (list.begin()); - iter!=list.end() && count; - ++iter) - { - if (iter->getRefData().getCount()<=count) - { - count -= iter->getRefData().getCount(); - iter->getRefData().setCount (0); - } - else - { - iter->getRefData().setCount (iter->getRefData().getCount()-count); - count = 0; - } - } - - // To be fully compatible with original Morrowind, we would need to check if - // count is >= 0 here and throw an exception. But let's be tollerant instead. - } - }; - - class OpRemoveItemExplicit : public Interpreter::Opcode0 - { - public: - - virtual void execute (Interpreter::Runtime& runtime) - { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - - std::string id = runtime.getStringLiteral (runtime[0].mInteger); - runtime.pop(); - - std::string item = runtime.getStringLiteral (runtime[0].mInteger); - runtime.pop(); - - Interpreter::Type_Integer count = runtime[0].mInteger; - runtime.pop(); - - if (count<0) - throw std::runtime_error ("second argument for RemoveItem must be non-negative"); - - MWWorld::Ptr ptr = context.getWorld().getPtr (id, false); - std::vector list; MWWorld::listItemsInContainer (item, @@ -262,12 +149,12 @@ namespace MWScript void installOpcodes (Interpreter::Interpreter& interpreter) { - interpreter.installSegment5 (opcodeAddItem, new OpAddItem); - interpreter.installSegment5 (opcodeAddItemExplicit, new OpAddItemExplicit); - interpreter.installSegment5 (opcodeGetItemCount, new OpGetItemCount); - interpreter.installSegment5 (opcodeGetItemCountExplicit, new OpGetItemCountExplicit); - interpreter.installSegment5 (opcodeRemoveItem, new OpRemoveItem); - interpreter.installSegment5 (opcodeRemoveItemExplicit, new OpRemoveItemExplicit); + interpreter.installSegment5 (opcodeAddItem, new OpAddItem); + interpreter.installSegment5 (opcodeAddItemExplicit, new OpAddItem); + interpreter.installSegment5 (opcodeGetItemCount, new OpGetItemCount); + interpreter.installSegment5 (opcodeGetItemCountExplicit, new OpGetItemCount); + interpreter.installSegment5 (opcodeRemoveItem, new OpRemoveItem); + interpreter.installSegment5 (opcodeRemoveItemExplicit, new OpRemoveItem); } } } diff --git a/apps/openmw/mwscript/miscextensions.cpp b/apps/openmw/mwscript/miscextensions.cpp index 9cb65dcd7f..a04065f9cf 100644 --- a/apps/openmw/mwscript/miscextensions.cpp +++ b/apps/openmw/mwscript/miscextensions.cpp @@ -7,10 +7,11 @@ #include #include -#include "interpretercontext.hpp" - #include "../mwworld/class.hpp" +#include "interpretercontext.hpp" +#include "ref.hpp" + namespace MWScript { namespace Misc @@ -55,42 +56,14 @@ namespace MWScript } }; + template class OpLock : public Interpreter::Opcode1 { public: virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0) { - InterpreterContext& context = - static_cast (runtime.getContext()); - - MWWorld::Ptr ptr = context.getReference(); - - Interpreter::Type_Integer lockLevel = 100; - - if (arg0==1) - { - lockLevel = runtime[0].mInteger; - runtime.pop(); - } - - MWWorld::Class::get (ptr).lock (ptr, lockLevel); - } - }; - - class OpLockExplicit : public Interpreter::Opcode1 - { - public: - - virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0) - { - InterpreterContext& context = - static_cast (runtime.getContext()); - - std::string id = runtime.getStringLiteral (runtime[0].mInteger); - runtime.pop(); - - MWWorld::Ptr ptr = context.getWorld().getPtr (id, false); + MWWorld::Ptr ptr = R()(runtime); Interpreter::Type_Integer lockLevel = 100; @@ -104,34 +77,14 @@ namespace MWScript } }; + template class OpUnlock : public Interpreter::Opcode0 { public: virtual void execute (Interpreter::Runtime& runtime) { - InterpreterContext& context = - static_cast (runtime.getContext()); - - MWWorld::Ptr ptr = context.getReference(); - - MWWorld::Class::get (ptr).unlock (ptr); - } - }; - - class OpUnlockExplicit : public Interpreter::Opcode0 - { - public: - - virtual void execute (Interpreter::Runtime& runtime) - { - InterpreterContext& context = - static_cast (runtime.getContext()); - - std::string id = runtime.getStringLiteral (runtime[0].mInteger); - runtime.pop(); - - MWWorld::Ptr ptr = context.getWorld().getPtr (id, false); + MWWorld::Ptr ptr = R()(runtime); MWWorld::Class::get (ptr).unlock (ptr); } @@ -160,10 +113,10 @@ namespace MWScript interpreter.installSegment5 (opcodeXBox, new OpXBox); interpreter.installSegment5 (opcodeOnActivate, new OpOnActivate); interpreter.installSegment5 (opcodeActivate, new OpActivate); - interpreter.installSegment3 (opcodeLock, new OpLock); - interpreter.installSegment3 (opcodeLockExplicit, new OpLockExplicit); - interpreter.installSegment5 (opcodeUnlock, new OpUnlock); - interpreter.installSegment5 (opcodeUnlockExplicit, new OpUnlockExplicit); + interpreter.installSegment3 (opcodeLock, new OpLock); + interpreter.installSegment3 (opcodeLockExplicit, new OpLock); + interpreter.installSegment5 (opcodeUnlock, new OpUnlock); + interpreter.installSegment5 (opcodeUnlockExplicit, new OpUnlock); } } } diff --git a/apps/openmw/mwscript/ref.hpp b/apps/openmw/mwscript/ref.hpp new file mode 100644 index 0000000000..5ca1ea4d62 --- /dev/null +++ b/apps/openmw/mwscript/ref.hpp @@ -0,0 +1,41 @@ +#ifndef GAME_MWSCRIPT_REF_H +#define GAME_MWSCRIPT_REF_H + +#include + +#include + +#include "../mwworld/ptr.hpp" +#include "../mwworld/world.hpp" + +#include "interpretercontext.hpp" + +namespace MWScript +{ + struct ExplicitRef + { + MWWorld::Ptr operator() (Interpreter::Runtime& runtime) const + { + MWScript::InterpreterContext& context + = static_cast (runtime.getContext()); + + std::string id = runtime.getStringLiteral (runtime[0].mInteger); + runtime.pop(); + + return context.getWorld().getPtr (id, false); + } + }; + + struct ImplicitRef + { + MWWorld::Ptr operator() (Interpreter::Runtime& runtime) const + { + MWScript::InterpreterContext& context + = static_cast (runtime.getContext()); + + return context.getReference(); + } + }; +} + +#endif diff --git a/apps/openmw/mwscript/soundextensions.cpp b/apps/openmw/mwscript/soundextensions.cpp index 58554ef163..d5cc41b76f 100644 --- a/apps/openmw/mwscript/soundextensions.cpp +++ b/apps/openmw/mwscript/soundextensions.cpp @@ -7,22 +7,26 @@ #include #include -#include "interpretercontext.hpp" - #include "../mwworld/world.hpp" #include "../mwsound/soundmanager.hpp" +#include "interpretercontext.hpp" +#include "ref.hpp" + namespace MWScript { namespace Sound { + template class OpSay : public Interpreter::Opcode0 { public: - + virtual void execute (Interpreter::Runtime& runtime) { + MWWorld::Ptr ptr = R()(runtime); + MWScript::InterpreterContext& context = static_cast (runtime.getContext()); @@ -32,296 +36,173 @@ namespace MWScript std::string text = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); - context.getSoundManager().say (context.getReference(), file); + context.getSoundManager().say (ptr, file); context.messageBox (text); - } - }; - + } + }; + + template class OpSayDone : public Interpreter::Opcode0 { public: - + virtual void execute (Interpreter::Runtime& runtime) { + MWWorld::Ptr ptr = R()(runtime); + MWScript::InterpreterContext& context = static_cast (runtime.getContext()); - - runtime.push (context.getSoundManager().sayDone (context.getReference())); - } - }; - + + runtime.push (context.getSoundManager().sayDone (ptr)); + } + }; + class OpStreamMusic : public Interpreter::Opcode0 { public: - + virtual void execute (Interpreter::Runtime& runtime) { MWScript::InterpreterContext& context = static_cast (runtime.getContext()); - + std::string sound = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); - + context.getSoundManager().streamMusic (sound); - } - }; + } + }; class OpPlaySound : public Interpreter::Opcode0 { public: - + virtual void execute (Interpreter::Runtime& runtime) { MWScript::InterpreterContext& context = static_cast (runtime.getContext()); - + std::string sound = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); - + context.getSoundManager().playSound (sound, 1.0, 1.0); - } - }; - + } + }; + class OpPlaySoundVP : public Interpreter::Opcode0 { public: - + virtual void execute (Interpreter::Runtime& runtime) { MWScript::InterpreterContext& context = static_cast (runtime.getContext()); - + std::string sound = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); - + Interpreter::Type_Float volume = runtime[0].mFloat; runtime.pop(); Interpreter::Type_Float pitch = runtime[0].mFloat; runtime.pop(); - + context.getSoundManager().playSound (sound, volume, pitch); - } - }; - + } + }; + + template class OpPlaySound3D : public Interpreter::Opcode0 { bool mLoop; - + public: - + OpPlaySound3D (bool loop) : mLoop (loop) {} - + virtual void execute (Interpreter::Runtime& runtime) { + MWWorld::Ptr ptr = R()(runtime); + MWScript::InterpreterContext& context = static_cast (runtime.getContext()); - + std::string sound = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); - - context.getSoundManager().playSound3D (context.getReference(), sound, - 1.0, 1.0, mLoop); - } - }; - + + context.getSoundManager().playSound3D (ptr, sound, 1.0, 1.0, mLoop); + } + }; + + template class OpPlaySoundVP3D : public Interpreter::Opcode0 { bool mLoop; - + public: - + OpPlaySoundVP3D (bool loop) : mLoop (loop) {} - + virtual void execute (Interpreter::Runtime& runtime) { + MWWorld::Ptr ptr = R()(runtime); + MWScript::InterpreterContext& context = static_cast (runtime.getContext()); - + std::string sound = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); - + Interpreter::Type_Float volume = runtime[0].mFloat; runtime.pop(); Interpreter::Type_Float pitch = runtime[0].mFloat; runtime.pop(); - - context.getSoundManager().playSound3D (context.getReference(), sound, volume, - pitch, mLoop); - } - }; + context.getSoundManager().playSound3D (ptr, sound, volume, pitch, mLoop); + } + }; + + template class OpStopSound : public Interpreter::Opcode0 { public: - + virtual void execute (Interpreter::Runtime& runtime) { + MWWorld::Ptr ptr = R()(runtime); + MWScript::InterpreterContext& context = static_cast (runtime.getContext()); - + std::string sound = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); - - context.getSoundManager().stopSound3D (context.getReference(), sound); - } - }; - + + context.getSoundManager().stopSound3D (ptr, sound); + } + }; + + template class OpGetSoundPlaying : public Interpreter::Opcode0 { public: - + virtual void execute (Interpreter::Runtime& runtime) { + MWWorld::Ptr ptr = R()(runtime); + MWScript::InterpreterContext& context = static_cast (runtime.getContext()); - + int index = runtime[0].mInteger; runtime.pop(); - + runtime.push (context.getSoundManager().getSoundPlaying ( - context.getReference(), runtime.getStringLiteral (index))); - } + ptr, runtime.getStringLiteral (index))); + } }; - - class OpSayExplicit : public Interpreter::Opcode0 - { - public: - - virtual void execute (Interpreter::Runtime& runtime) - { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - std::string id = runtime.getStringLiteral (runtime[0].mInteger); - runtime.pop(); - - std::string file = runtime.getStringLiteral (runtime[0].mInteger); - runtime.pop(); - - std::string text = runtime.getStringLiteral (runtime[0].mInteger); - runtime.pop(); - - context.getSoundManager().say (context.getWorld().getPtr (id, true), - file); - } - }; - - class OpSayDoneExplicit : public Interpreter::Opcode0 - { - public: - - virtual void execute (Interpreter::Runtime& runtime) - { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - - std::string id = runtime.getStringLiteral (runtime[0].mInteger); - runtime.pop(); - - runtime.push (context.getSoundManager().sayDone ( - context.getWorld().getPtr (id, true))); - } - }; - - class OpPlaySound3DExplicit : public Interpreter::Opcode0 - { - bool mLoop; - - public: - - OpPlaySound3DExplicit (bool loop) : mLoop (loop) {} - - virtual void execute (Interpreter::Runtime& runtime) - { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - - std::string id = runtime.getStringLiteral (runtime[0].mInteger); - runtime.pop(); - - std::string sound = runtime.getStringLiteral (runtime[0].mInteger); - runtime.pop(); - - context.getSoundManager().playSound3D ( - context.getWorld().getPtr (id, true), sound, 1.0, 1.0, mLoop); - } - }; - - class OpPlaySoundVP3DExplicit : public Interpreter::Opcode0 - { - bool mLoop; - - public: - - OpPlaySoundVP3DExplicit (bool loop) : mLoop (loop) {} - - virtual void execute (Interpreter::Runtime& runtime) - { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - - std::string id = runtime.getStringLiteral (runtime[0].mInteger); - runtime.pop(); - - std::string sound = runtime.getStringLiteral (runtime[0].mInteger); - runtime.pop(); - - Interpreter::Type_Float volume = runtime[0].mFloat; - runtime.pop(); - - Interpreter::Type_Float pitch = runtime[0].mFloat; - runtime.pop(); - - context.getSoundManager().playSound3D ( - context.getWorld().getPtr (id, true), sound, volume, pitch, mLoop); - - } - }; - - class OpStopSoundExplicit : public Interpreter::Opcode0 - { - public: - - virtual void execute (Interpreter::Runtime& runtime) - { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - - std::string id = runtime.getStringLiteral (runtime[0].mInteger); - runtime.pop(); - - std::string sound = runtime.getStringLiteral (runtime[0].mInteger); - runtime.pop(); - - context.getSoundManager().stopSound3D ( - context.getWorld().getPtr (id, true), sound); - } - }; - - class OpGetSoundPlayingExplicit : public Interpreter::Opcode0 - { - public: - - virtual void execute (Interpreter::Runtime& runtime) - { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - - std::string id = runtime.getStringLiteral (runtime[0].mInteger); - runtime.pop(); - - int index = runtime[0].mInteger; - runtime.pop(); - - runtime.push (context.getSoundManager().getSoundPlaying ( - context.getWorld().getPtr (id, true), - runtime.getStringLiteral (index))); - } - }; - const int opcodeSay = 0x2000001; const int opcodeSayDone = 0x2000002; const int opcodeStreamMusic = 0x2000003; @@ -342,7 +223,7 @@ namespace MWScript const int opcodePlayLoopSound3DVPExplicit = 0x200001e; const int opcodeStopSoundExplicit = 0x200001f; const int opcodeGetSoundPlayingExplicit = 0x2000020; - + void registerExtensions (Compiler::Extensions& extensions) { extensions.registerInstruction ("say", "SS", opcodeSay, opcodeSayExplicit); @@ -361,37 +242,37 @@ namespace MWScript extensions.registerInstruction ("stopsound", "c", opcodeStopSound, opcodeStopSoundExplicit); extensions.registerFunction ("getsoundplaying", 'l', "c", opcodeGetSoundPlaying, - opcodeGetSoundPlayingExplicit); + opcodeGetSoundPlayingExplicit); } - + void installOpcodes (Interpreter::Interpreter& interpreter) { - interpreter.installSegment5 (opcodeSay, new OpSay); - interpreter.installSegment5 (opcodeSayDone, new OpSayDone); + interpreter.installSegment5 (opcodeSay, new OpSay); + interpreter.installSegment5 (opcodeSayDone, new OpSayDone); interpreter.installSegment5 (opcodeStreamMusic, new OpStreamMusic); interpreter.installSegment5 (opcodePlaySound, new OpPlaySound); interpreter.installSegment5 (opcodePlaySoundVP, new OpPlaySoundVP); - interpreter.installSegment5 (opcodePlaySound3D, new OpPlaySound3D (false)); - interpreter.installSegment5 (opcodePlaySound3DVP, new OpPlaySoundVP3D (false)); - interpreter.installSegment5 (opcodePlayLoopSound3D, new OpPlaySound3D (true)); - interpreter.installSegment5 (opcodePlayLoopSound3DVP, new OpPlaySoundVP3D (true)); - interpreter.installSegment5 (opcodeStopSound, new OpStopSound); - interpreter.installSegment5 (opcodeGetSoundPlaying, new OpGetSoundPlaying); - - interpreter.installSegment5 (opcodeSayExplicit, new OpSayExplicit); - interpreter.installSegment5 (opcodeSayDoneExplicit, new OpSayDoneExplicit); - interpreter.installSegment5 (opcodePlaySound3DExplicit, - new OpPlaySound3DExplicit (false)); - interpreter.installSegment5 (opcodePlaySound3DVPExplicit, - new OpPlaySoundVP3DExplicit (false)); - interpreter.installSegment5 (opcodePlayLoopSound3DExplicit, - new OpPlaySound3DExplicit (true)); - interpreter.installSegment5 (opcodePlayLoopSound3DVPExplicit, - new OpPlaySoundVP3DExplicit (true)); - interpreter.installSegment5 (opcodeStopSoundExplicit, new OpStopSoundExplicit); - interpreter.installSegment5 (opcodeGetSoundPlayingExplicit, - new OpGetSoundPlayingExplicit); - } - } -} + interpreter.installSegment5 (opcodePlaySound3D, new OpPlaySound3D (false)); + interpreter.installSegment5 (opcodePlaySound3DVP, new OpPlaySoundVP3D (false)); + interpreter.installSegment5 (opcodePlayLoopSound3D, new OpPlaySound3D (true)); + interpreter.installSegment5 (opcodePlayLoopSound3DVP, + new OpPlaySoundVP3D (true)); + interpreter.installSegment5 (opcodeStopSound, new OpStopSound); + interpreter.installSegment5 (opcodeGetSoundPlaying, new OpGetSoundPlaying); + interpreter.installSegment5 (opcodeSayExplicit, new OpSay); + interpreter.installSegment5 (opcodeSayDoneExplicit, new OpSayDone); + interpreter.installSegment5 (opcodePlaySound3DExplicit, + new OpPlaySound3D (false)); + interpreter.installSegment5 (opcodePlaySound3DVPExplicit, + new OpPlaySoundVP3D (false)); + interpreter.installSegment5 (opcodePlayLoopSound3DExplicit, + new OpPlaySound3D (true)); + interpreter.installSegment5 (opcodePlayLoopSound3DVPExplicit, + new OpPlaySoundVP3D (true)); + interpreter.installSegment5 (opcodeStopSoundExplicit, new OpStopSound); + interpreter.installSegment5 (opcodeGetSoundPlayingExplicit, + new OpGetSoundPlaying); + } + } +} diff --git a/apps/openmw/mwscript/statsextensions.cpp b/apps/openmw/mwscript/statsextensions.cpp index 17635667c4..ca82830d93 100644 --- a/apps/openmw/mwscript/statsextensions.cpp +++ b/apps/openmw/mwscript/statsextensions.cpp @@ -12,11 +12,13 @@ #include "../mwmechanics/creaturestats.hpp" #include "interpretercontext.hpp" +#include "ref.hpp" namespace MWScript { namespace Stats { + template class OpGetAttribute : public Interpreter::Opcode0 { int mIndex; @@ -27,36 +29,7 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - - MWWorld::Ptr ptr = context.getReference(); - - Interpreter::Type_Integer value = - MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex]. - getModified(); - - runtime.push (value); - } - }; - - class OpGetAttributeExplicit : public Interpreter::Opcode0 - { - int mIndex; - - public: - - OpGetAttributeExplicit (int index) : mIndex (index) {} - - virtual void execute (Interpreter::Runtime& runtime) - { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - - std::string id = runtime.getStringLiteral (runtime[0].mInteger); - runtime.pop(); - - MWWorld::Ptr ptr = context.getWorld().getPtr (id, false); + MWWorld::Ptr ptr = R()(runtime); Interpreter::Type_Integer value = MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex]. @@ -66,6 +39,7 @@ namespace MWScript } }; + template class OpSetAttribute : public Interpreter::Opcode0 { int mIndex; @@ -76,45 +50,17 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); + MWWorld::Ptr ptr = R()(runtime); Interpreter::Type_Integer value = runtime[0].mInteger; runtime.pop(); - MWWorld::Ptr ptr = context.getReference(); - - MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex]. - setModified (value, 0); - } - }; - - class OpSetAttributeExplicit : public Interpreter::Opcode0 - { - int mIndex; - - public: - - OpSetAttributeExplicit (int index) : mIndex (index) {} - - virtual void execute (Interpreter::Runtime& runtime) - { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - - std::string id = runtime.getStringLiteral (runtime[0].mInteger); - runtime.pop(); - - Interpreter::Type_Integer value = runtime[0].mInteger; - runtime.pop(); - - MWWorld::Ptr ptr = context.getWorld().getPtr (id, false); - MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex]. setModified (value, 0); } }; + template class OpModAttribute : public Interpreter::Opcode0 { int mIndex; @@ -125,14 +71,11 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); + MWWorld::Ptr ptr = R()(runtime); Interpreter::Type_Integer value = runtime[0].mInteger; runtime.pop(); - MWWorld::Ptr ptr = context.getReference(); - value += MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex]. getModified(); @@ -141,36 +84,7 @@ namespace MWScript } }; - class OpModAttributeExplicit : public Interpreter::Opcode0 - { - int mIndex; - - public: - - OpModAttributeExplicit (int index) : mIndex (index) {} - - virtual void execute (Interpreter::Runtime& runtime) - { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - - std::string id = runtime.getStringLiteral (runtime[0].mInteger); - runtime.pop(); - - Interpreter::Type_Integer value = runtime[0].mInteger; - runtime.pop(); - - MWWorld::Ptr ptr = context.getWorld().getPtr (id, false); - - value += - MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex]. - getModified(); - - MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex]. - setModified (value, 0, 100); - } - }; - + template class OpGetDynamic : public Interpreter::Opcode0 { int mIndex; @@ -181,46 +95,7 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - - MWWorld::Ptr ptr = context.getReference(); - - if (mIndex==0 && MWWorld::Class::get (ptr).hasItemHealth (ptr)) - { - // health is a special case - Interpreter::Type_Integer value = - MWWorld::Class::get (ptr).getItemMaxHealth (ptr); - runtime.push (value); - - return; - } - - Interpreter::Type_Integer value = - MWWorld::Class::get (ptr).getCreatureStats (ptr).mDynamic[mIndex]. - getCurrent(); - - runtime.push (value); - } - }; - - class OpGetDynamicExplicit : public Interpreter::Opcode0 - { - int mIndex; - - public: - - OpGetDynamicExplicit (int index) : mIndex (index) {} - - virtual void execute (Interpreter::Runtime& runtime) - { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - - std::string id = runtime.getStringLiteral (runtime[0].mInteger); - runtime.pop(); - - MWWorld::Ptr ptr = context.getWorld().getPtr (id, false); + MWWorld::Ptr ptr = R()(runtime); if (mIndex==0 && MWWorld::Class::get (ptr).hasItemHealth (ptr)) { @@ -240,6 +115,7 @@ namespace MWScript } }; + template class OpSetDynamic : public Interpreter::Opcode0 { int mIndex; @@ -250,45 +126,17 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); + MWWorld::Ptr ptr = R()(runtime); Interpreter::Type_Integer value = runtime[0].mInteger; runtime.pop(); - MWWorld::Ptr ptr = context.getReference(); - - MWWorld::Class::get (ptr).getCreatureStats (ptr).mDynamic[mIndex]. - setModified (value, 0); - } - }; - - class OpSetDynamicExplicit : public Interpreter::Opcode0 - { - int mIndex; - - public: - - OpSetDynamicExplicit (int index) : mIndex (index) {} - - virtual void execute (Interpreter::Runtime& runtime) - { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - - std::string id = runtime.getStringLiteral (runtime[0].mInteger); - runtime.pop(); - - Interpreter::Type_Integer value = runtime[0].mInteger; - runtime.pop(); - - MWWorld::Ptr ptr = context.getWorld().getPtr (id, false); - MWWorld::Class::get (ptr).getCreatureStats (ptr).mDynamic[mIndex]. setModified (value, 0); } }; + template class OpModDynamic : public Interpreter::Opcode0 { int mIndex; @@ -299,14 +147,11 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); + MWWorld::Ptr ptr = R()(runtime); Interpreter::Type_Integer diff = runtime[0].mInteger; runtime.pop(); - MWWorld::Ptr ptr = context.getReference(); - MWMechanics::CreatureStats& stats = MWWorld::Class::get (ptr).getCreatureStats (ptr); Interpreter::Type_Integer current = stats.mDynamic[mIndex].getCurrent(); @@ -318,40 +163,7 @@ namespace MWScript } }; - class OpModDynamicExplicit : public Interpreter::Opcode0 - { - int mIndex; - - public: - - OpModDynamicExplicit (int index) : mIndex (index) {} - - virtual void execute (Interpreter::Runtime& runtime) - { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - - std::string id = runtime.getStringLiteral (runtime[0].mInteger); - runtime.pop(); - - Interpreter::Type_Integer diff = runtime[0].mInteger; - runtime.pop(); - - MWWorld::Ptr ptr = context.getWorld().getPtr (id, false); - - MWMechanics::CreatureStats& stats = - MWWorld::Class::get (ptr).getCreatureStats (ptr); - - Interpreter::Type_Integer current = stats.mDynamic[mIndex].getCurrent(); - - stats.mDynamic[mIndex].setModified ( - diff + stats.mDynamic[mIndex].getModified(), 0); - - stats.mDynamic[mIndex].setCurrent (diff + current); - } - }; - - + template class OpModCurrentDynamic : public Interpreter::Opcode0 { int mIndex; @@ -362,14 +174,11 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); + MWWorld::Ptr ptr = R()(runtime); Interpreter::Type_Integer diff = runtime[0].mInteger; runtime.pop(); - MWWorld::Ptr ptr = context.getReference(); - MWMechanics::CreatureStats& stats = MWWorld::Class::get (ptr).getCreatureStats (ptr); Interpreter::Type_Integer current = stats.mDynamic[mIndex].getCurrent(); @@ -378,36 +187,7 @@ namespace MWScript } }; - class OpModCurrentDynamicExplicit : public Interpreter::Opcode0 - { - int mIndex; - - public: - - OpModCurrentDynamicExplicit (int index) : mIndex (index) {} - - virtual void execute (Interpreter::Runtime& runtime) - { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - - std::string id = runtime.getStringLiteral (runtime[0].mInteger); - runtime.pop(); - - Interpreter::Type_Integer diff = runtime[0].mInteger; - runtime.pop(); - - MWWorld::Ptr ptr = context.getWorld().getPtr (id, false); - - MWMechanics::CreatureStats& stats = - MWWorld::Class::get (ptr).getCreatureStats (ptr); - - Interpreter::Type_Integer current = stats.mDynamic[mIndex].getCurrent(); - - stats.mDynamic[mIndex].setCurrent (diff + current); - } - }; - + template class OpGetDynamicGetRatio : public Interpreter::Opcode0 { int mIndex; @@ -418,10 +198,7 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - - MWWorld::Ptr ptr = context.getReference(); + MWWorld::Ptr ptr = R()(runtime); MWMechanics::CreatureStats& stats = MWWorld::Class::get (ptr).getCreatureStats (ptr); @@ -436,38 +213,7 @@ namespace MWScript } }; - class OpGetDynamicGetRatioExplicit : public Interpreter::Opcode0 - { - int mIndex; - - public: - - OpGetDynamicGetRatioExplicit (int index) : mIndex (index) {} - - virtual void execute (Interpreter::Runtime& runtime) - { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - - std::string id = runtime.getStringLiteral (runtime[0].mInteger); - runtime.pop(); - - MWWorld::Ptr ptr = context.getWorld().getPtr (id, false); - - MWMechanics::CreatureStats& stats = - MWWorld::Class::get (ptr).getCreatureStats (ptr); - - Interpreter::Type_Float value = 0; - - Interpreter::Type_Float max = stats.mDynamic[mIndex].getModified(); - - if (max>0) - value = stats.mDynamic[mIndex].getCurrent() / max; - - runtime.push (value); - } - }; - + template class OpGetSkill : public Interpreter::Opcode0 { int mIndex; @@ -478,36 +224,7 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - - MWWorld::Ptr ptr = context.getReference(); - - Interpreter::Type_Integer value = - MWWorld::Class::get (ptr).getNpcStats (ptr).mSkill[mIndex]. - getModified(); - - runtime.push (value); - } - }; - - class OpGetSkillExplicit : public Interpreter::Opcode0 - { - int mIndex; - - public: - - OpGetSkillExplicit (int index) : mIndex (index) {} - - virtual void execute (Interpreter::Runtime& runtime) - { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - - std::string id = runtime.getStringLiteral (runtime[0].mInteger); - runtime.pop(); - - MWWorld::Ptr ptr = context.getWorld().getPtr (id, false); + MWWorld::Ptr ptr = R()(runtime); Interpreter::Type_Integer value = MWWorld::Class::get (ptr).getNpcStats (ptr).mSkill[mIndex]. @@ -517,6 +234,7 @@ namespace MWScript } }; + template class OpSetSkill : public Interpreter::Opcode0 { int mIndex; @@ -527,45 +245,17 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); + MWWorld::Ptr ptr = R()(runtime); Interpreter::Type_Integer value = runtime[0].mInteger; runtime.pop(); - MWWorld::Ptr ptr = context.getReference(); - - MWWorld::Class::get (ptr).getNpcStats (ptr).mSkill[mIndex]. - setModified (value, 0); - } - }; - - class OpSetSkillExplicit : public Interpreter::Opcode0 - { - int mIndex; - - public: - - OpSetSkillExplicit (int index) : mIndex (index) {} - - virtual void execute (Interpreter::Runtime& runtime) - { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - - std::string id = runtime.getStringLiteral (runtime[0].mInteger); - runtime.pop(); - - Interpreter::Type_Integer value = runtime[0].mInteger; - runtime.pop(); - - MWWorld::Ptr ptr = context.getWorld().getPtr (id, false); - MWWorld::Class::get (ptr).getNpcStats (ptr).mSkill[mIndex]. setModified (value, 0); } }; + template class OpModSkill : public Interpreter::Opcode0 { int mIndex; @@ -576,14 +266,11 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); + MWWorld::Ptr ptr = R()(runtime); Interpreter::Type_Integer value = runtime[0].mInteger; runtime.pop(); - MWWorld::Ptr ptr = context.getReference(); - value += MWWorld::Class::get (ptr).getNpcStats (ptr).mSkill[mIndex]. getModified(); @@ -592,36 +279,6 @@ namespace MWScript } }; - class OpModSkillExplicit : public Interpreter::Opcode0 - { - int mIndex; - - public: - - OpModSkillExplicit (int index) : mIndex (index) {} - - virtual void execute (Interpreter::Runtime& runtime) - { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - - std::string id = runtime.getStringLiteral (runtime[0].mInteger); - runtime.pop(); - - Interpreter::Type_Integer value = runtime[0].mInteger; - runtime.pop(); - - MWWorld::Ptr ptr = context.getWorld().getPtr (id, false); - - value += - MWWorld::Class::get (ptr).getNpcStats (ptr).mSkill[mIndex]. - getModified(); - - MWWorld::Class::get (ptr).getNpcStats (ptr).mSkill[mIndex]. - setModified (value, 0, 100); - } - }; - const int numberOfAttributes = 8; const int opcodeGetAttribute = 0x2000027; @@ -729,53 +386,54 @@ namespace MWScript { for (int i=0; i (i)); interpreter.installSegment5 (opcodeGetAttributeExplicit+i, - new OpGetAttributeExplicit (i)); + new OpGetAttribute (i)); - interpreter.installSegment5 (opcodeSetAttribute+i, new OpSetAttribute (i)); + interpreter.installSegment5 (opcodeSetAttribute+i, new OpSetAttribute (i)); interpreter.installSegment5 (opcodeSetAttributeExplicit+i, - new OpSetAttributeExplicit (i)); + new OpSetAttribute (i)); - interpreter.installSegment5 (opcodeModAttribute+i, new OpModAttribute (i)); + interpreter.installSegment5 (opcodeModAttribute+i, new OpModAttribute (i)); interpreter.installSegment5 (opcodeModAttributeExplicit+i, - new OpModAttributeExplicit (i)); + new OpModAttribute (i)); } for (int i=0; i (i)); interpreter.installSegment5 (opcodeGetDynamicExplicit+i, - new OpGetDynamicExplicit (i)); + new OpGetDynamic (i)); - interpreter.installSegment5 (opcodeSetDynamic+i, new OpSetDynamic (i)); + interpreter.installSegment5 (opcodeSetDynamic+i, new OpSetDynamic (i)); interpreter.installSegment5 (opcodeSetDynamicExplicit+i, - new OpSetDynamicExplicit (i)); + new OpSetDynamic (i)); - interpreter.installSegment5 (opcodeModDynamic+i, new OpModDynamic (i)); + interpreter.installSegment5 (opcodeModDynamic+i, new OpModDynamic (i)); interpreter.installSegment5 (opcodeModDynamicExplicit+i, - new OpModDynamicExplicit (i)); + new OpModDynamic (i)); - interpreter.installSegment5 (opcodeModCurrentDynamic+i, new OpModCurrentDynamic (i)); + interpreter.installSegment5 (opcodeModCurrentDynamic+i, + new OpModCurrentDynamic (i)); interpreter.installSegment5 (opcodeModCurrentDynamicExplicit+i, - new OpModCurrentDynamicExplicit (i)); + new OpModCurrentDynamic (i)); interpreter.installSegment5 (opcodeGetDynamicGetRatio+i, - new OpGetDynamicGetRatio (i)); + new OpGetDynamicGetRatio (i)); interpreter.installSegment5 (opcodeGetDynamicGetRatioExplicit+i, - new OpGetDynamicGetRatioExplicit (i)); + new OpGetDynamicGetRatio (i)); } for (int i=0; i (i)); + interpreter.installSegment5 (opcodeGetSkillExplicit+i, new OpGetSkill (i)); - interpreter.installSegment5 (opcodeSetSkill+i, new OpSetSkill (i)); - interpreter.installSegment5 (opcodeSetSkillExplicit+i, new OpSetSkillExplicit (i)); + interpreter.installSegment5 (opcodeSetSkill+i, new OpSetSkill (i)); + interpreter.installSegment5 (opcodeSetSkillExplicit+i, new OpSetSkill (i)); - interpreter.installSegment5 (opcodeModSkill+i, new OpModSkill (i)); - interpreter.installSegment5 (opcodeModSkillExplicit+i, new OpModSkillExplicit (i)); + interpreter.installSegment5 (opcodeModSkill+i, new OpModSkill (i)); + interpreter.installSegment5 (opcodeModSkillExplicit+i, new OpModSkill (i)); } } } From 11406ae6f37beddf0a237240c9e653ca93875ccc Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Sat, 1 Jan 2011 11:45:11 -0500 Subject: [PATCH 02/18] cleanupandupdate --- apps/openmw/mwclass/npc.cpp | 2 +- apps/openmw/mwclass/npc.hpp | 2 - components/nifogre/oldnpccode.txt | 256 ------------------------------ 3 files changed, 1 insertion(+), 259 deletions(-) delete mode 100644 components/nifogre/oldnpccode.txt diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index de8b6ffff5..c6dfa19a38 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -41,7 +41,7 @@ namespace MWClass std::string hairID = ref->base->hair; std::string headID = ref->base->head; std::string npcName = ref->base->name; - std::cout << "NPC: " << npcName << "\n"; + //std::cout << "NPC: " << npcName << "\n"; //get the part of the bodypart id which describes the race and the gender std::string bodyRaceID = headID.substr(0, headID.find_last_of("head_") - 4); diff --git a/apps/openmw/mwclass/npc.hpp b/apps/openmw/mwclass/npc.hpp index d030da20a3..946c307334 100644 --- a/apps/openmw/mwclass/npc.hpp +++ b/apps/openmw/mwclass/npc.hpp @@ -5,8 +5,6 @@ namespace MWClass { - static bool isChest; - //static ;bool isChest = false; class Npc : public MWWorld::Class { public: diff --git a/components/nifogre/oldnpccode.txt b/components/nifogre/oldnpccode.txt deleted file mode 100644 index eec9ef11e7..0000000000 --- a/components/nifogre/oldnpccode.txt +++ /dev/null @@ -1,256 +0,0 @@ -/* //This is old - if (pieces > 1){ //pieces > 1 - MeshPtr justChest = MeshManager::getSingleton().createManual("justchest", group, NIFLoader::getSingletonPtr()); - Ogre::AxisAlignedBox bounds = resize->getBounds(); - Ogre::Vector3 width2 = bounds.getCorner(bounds.NEAR_RIGHT_BOTTOM) - bounds.getCorner(bounds.NEAR_LEFT_BOTTOM); - Ogre::Vector3 depth2 = (bounds.getCorner(bounds.FAR_LEFT_BOTTOM) - bounds.getCorner(bounds.NEAR_LEFT_BOTTOM)); - Ogre::Vector3 height2 = bounds.getCorner(bounds.NEAR_LEFT_TOP) - bounds.getCorner(bounds.NEAR_LEFT_BOTTOM); - cout << "Width:" << width2; cout << "Height:" << height2; cout << "Depth:" << depth2; - /*int width = bounds.getMaximum().x - bounds.getMinimum().x; - int height = bounds.getMaximum().y - bounds.getMinimum().y; - int depth = bounds.getMaximum().z - bounds.getMinimum().z; - int xinc = width / pieces; - int yinc = height / pieces; - int zinc = depth / pieces; - int xmincorner = bounds.getMinimum().x + xinc*pieceIndex; - int ymincorner = bounds.getMinimum().y + yinc*pieceIndex; - int zmincorner = bounds.getMinimum().z + xinc*pieceIndex;*/ - //Ogre::Vector3 bottom_left = bounds.getCorner(bounds.NEAR_LEFT_BOTTOM) + (width2 / pieces) * pieceIndex; //width2 - //Ogre::Vector3 top_right = bottom_left + (width2 / pieces) + height2 + depth2; - //Ogre::AxisAlignedBox set = AxisAlignedBox ( Ogre::Vector3(xmincorner, bounds.getMinimum().y, bounds.getMinimum().z), Ogre::Vector3(xmincorner + xinc, bounds.getMaximum().y, bounds.getMaximum().z)); - //Ogre::AxisAlignedBox set = bounds;//AxisAlignedBox(bottom_left, top_right); - //bounds.setMinimumX(xmincorner); - //bounds.setMaximumX(xmincorner + xinc); - //bounds.setMinimumY(ymincorner); - //bounds.setMaximumY(ymincorner + yinc); - //bounds.setMinimumZ(zmincorner); - //bounds.setMaximumZ(zmincorner + zinc); - //bounds.setMinimumY(bounds.getMinimum().y); - //bounds.setMaximumY( bounds.getMaximum().y; - //resize->_setBounds(set, true); - //resize->reload(); - - //Ogre::Mesh::SubMeshIterator subMeshIterator = resize->getSubMeshIterator(); - /*Ogre::Vector3* point; - Ogre::SubMesh* subMesh; - - - - size_t vertex_count = 0; - Vector3* vertices; - size_t index_count = 0; - unsigned* indices; - Vector3 position = Vector3::ZERO; - Quaternion orient = Quaternion::IDENTITY; - Vector3 scale = Vector3::UNIT_SCALE; - - - // int vertex_count = 0; - //int index_count = 0; - - bool added_shared = false; - size_t current_offset = vertex_count; - size_t shared_offset = vertex_count; - size_t next_offset = vertex_count; - size_t index_offset = index_count; - size_t prev_vert = vertex_count; - size_t prev_ind = index_count; - // Calculate how many vertices and indices we're going to need - /* - std::cout <<"FIRST CYCLE\n"; - for(int i = 0;i < resize->getNumSubMeshes();i++) - { - std::cout<< "WEHAVEMESHES\n"; - SubMesh* submesh = resize->getSubMesh(i); - - // We only need to add the shared vertices once - if(submesh->useSharedVertices) - { - if(!added_shared) - { - VertexData* vertex_data = resize->sharedVertexData; - vertex_count += vertex_data->vertexCount; - added_shared = true; - } - } - else - { - VertexData* vertex_data = submesh->vertexData; - vertex_count += vertex_data->vertexCount; - } - - // Add the indices - Ogre::IndexData* index_data = submesh->indexData; - index_count += index_data->indexCount; - } - - */ -// Vector3* vertices; - // Allocate space for the vertices and indices - /*vertices = new Vector3[vertex_count]; - indices = new unsigned[index_count]; - - int meshcounter = 0; - added_shared = false; - std::cout <<"SECOND CYCLE: " << resize->getNumSubMeshes() << "\n"; - // Run through the submeshes again, adding the data into the arrays - int i; - for(i = 0;i < resize->getNumSubMeshes();i++) - { - - SubMesh* submesh = resize->getSubMesh(i); - - Ogre::VertexData* vertex_data = submesh->useSharedVertices ? resize->sharedVertexData : submesh->vertexData; - /* - if((!submesh->useSharedVertices)||(submesh->useSharedVertices && !added_shared)) - { - if(submesh->useSharedVertices) - { - added_shared = true; - shared_offset = current_offset; - } - - const Ogre::VertexElement* posElem = vertex_data->vertexDeclaration->findElementBySemantic(Ogre::VES_POSITION); - Ogre::HardwareVertexBufferSharedPtr vbuf = vertex_data->vertexBufferBinding->getBuffer(posElem->getSource()); - unsigned char* vertex = static_cast(vbuf->lock(Ogre::HardwareBuffer::HBL_NORMAL)); - Ogre::Real* pReal; - - bool onepointexists = true; - Vector3 lastpoint; - for(size_t j = 0; j < vertex_data->vertexCount; ++j, vertex += vbuf->getVertexSize()) - { - posElem->baseVertexPointerToElement(vertex, &pReal); - - Vector3 pt; - pt.x = (*(pReal++)); - pt.y = (*(pReal++)); - pt.z = (*(pReal++)); - //cout << "X:" << pt.x << "Y:" <getMaterialName() << "\n"; - - if(meshcounter <= 2) - resize->destroySubMesh(i); - else if(meshcounter > 3 && meshcounter < 7) - resize->destroySubMesh(i); - //submesh->setMaterialName("BaseWhiteNoLighting"); //red - //submesh->updateMaterialUsingTextureAliases(); - //resize-> - meshcounter++; - //delete submesh; - //reakb; - }*/ - /* - vbuf->unlock(); - next_offset += vertex_data->vertexCount; - } - - Ogre::IndexData* index_data = submesh->indexData; - - size_t numTris = index_data->indexCount / 3; - unsigned short* pShort; - unsigned int* pInt; - Ogre::HardwareIndexBufferSharedPtr ibuf = index_data->indexBuffer; - bool use32bitindexes = (ibuf->getType() == Ogre::HardwareIndexBuffer::IT_32BIT); - if (use32bitindexes) pInt = static_cast(ibuf->lock(Ogre::HardwareBuffer::HBL_READ_ONLY)); - else pShort = static_cast(ibuf->lock(Ogre::HardwareBuffer::HBL_READ_ONLY)); - - for(size_t k = 0; k < numTris; ++k) - { - size_t offset = (submesh->useSharedVertices)?shared_offset:current_offset; - - unsigned int vindex = use32bitindexes? *pInt++ : *pShort++; - indices[index_offset + 0] = vindex + offset; - vindex = use32bitindexes? *pInt++ : *pShort++; - indices[index_offset + 1] = vindex + offset; - vindex = use32bitindexes? *pInt++ : *pShort++; - indices[index_offset + 2] = vindex + offset; - - index_offset += 3; - } - ibuf->unlock(); - current_offset = next_offset;*/ - //if (i == 3) //i!=3 i!=5 - //{ - //cout << "RETURNINGJUST\n"; - //SubMesh* test = - //test = resize->getSubMesh(i); - // cout << "s:" << shape << "\n"; - //NiTriShapeData *data = shape->data.getPtr(); - // SubMesh *sub = justChest->createSubMesh(name + "2"); - //sub = resize->getSubMesh(i); - - // int nextBuf = 0; - - // This function is just one long stream of Ogre-barf, but it works - // great. - - // Add vertices - //int numVerts = data->vertices.length / 3; - //sub->vertexData = new VertexData(); - //sub->vertexData->vertexCount = numVerts; - - //justChest->load(); - //return resize; - //} - // 0 hand thumb - // 1 hand thumb no chest on dunmer - //} - //resize->destroySubMesh(1); - /* while (subMeshIterator.hasMoreElements()) - { - resize->getNum - //resize->d - std::cout << "CHEST"; - subMesh = subMeshIterator.getNext();*/ - //std::vector::type test = - //std::vector::iterator fileIter = subMesh->extremityPoints.begin(); - - //std::vector::type test = subMesh->extremityPoints; - //void* pData = subMesh->vertexData->vertexBufferBinding->getBuffer(1)->lock(0, 1000, HardwareBuffer::HBL_DISCARD); - - - // if(set.contains( subMesh->vertexData->vertexStart)) - //delete subMesh; - //subMeshIterator.getNext(); - //delete[] subMesh; - //subMesh->extremityPoints.clear(); - //subMesh->mLodFaceList.clear(); - //resize->destroySubMesh(subMesh->indexData->indexStart); - //resize->destroySubMesh(subMesh->indexData->); - //subMesh-> - //std::cout << "THIS" << subMesh; - ///} - //subMesh->vertexData->vertexBufferBinding->getBuffer(0)->readData(subMesh->vertexData->vertexStart, sizeof Ogre::Vector3, point); - - - - //boost::filesystem::directory_iterator dir_iter(dir), dir_end; - - //return resize; From ba168b22e924261c749c950cf16fa7d5da410e7f Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Sat, 1 Jan 2011 11:47:12 -0500 Subject: [PATCH 03/18] cleanupandupdate --- apps/openmw/mwclass/npc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index c6dfa19a38..ad668f3c96 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -101,7 +101,7 @@ namespace MWClass const ESM::BodyPart *hands = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "hands.1st"); - std::cout << "RACE" << bodyRaceID << "\n"; + //std::cout << "RACE" << bodyRaceID << "\n"; Ogre::Vector3 pos2 = Ogre::Vector3( 0, .5, 75); std::string upperarmpath[2] = {npcName + "chest", npcName + "upper arm"}; From f3ae1ea7373ead3af07fca21ab0d46eb1d84f58c Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Sat, 1 Jan 2011 13:00:58 -0500 Subject: [PATCH 04/18] NPC leg appearance changed --- apps/openmw/mwclass/npc.cpp | 12 ++++++------ apps/openmw/mwrender/exterior.cpp | 7 +++++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index ad668f3c96..c277832ab8 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -118,25 +118,25 @@ namespace MWClass //addresses[1] = npcName + "groin"; if(upperleg){ - cellRender.insertMesh ("meshes\\" + upperleg->model, Ogre::Vector3( 6, 0, -14), axis, Ogre::Radian(3.14), npcName + "upper leg", addresses, numbers); //-18 - cellRender.insertMesh ("meshes\\" + upperleg->model, Ogre::Vector3( -6, 0, -14), axis, Ogre::Radian(0), npcName + "upper leg2", addresses2, numbers); + cellRender.insertMesh ("meshes\\" + upperleg->model, Ogre::Vector3( 6, 0, -16), axis, Ogre::Radian(3.14), npcName + "upper leg", addresses, numbers); //-18 + cellRender.insertMesh ("meshes\\" + upperleg->model, Ogre::Vector3( -6, 0, -16), axis, Ogre::Radian(0), npcName + "upper leg2", addresses2, numbers); addresses2[numbers] = npcName + "upper leg2"; addresses[numbers++] = npcName + "upper leg"; cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), addresses, numbers); } if(knee) { - cellRender.insertMesh ("meshes\\" + knee->model, Ogre::Vector3( 0, -2, -18), axis, Ogre::Radian(0), npcName + "knee", addresses, numbers); + cellRender.insertMesh ("meshes\\" + knee->model, Ogre::Vector3( 0, -1, -23), axis, Ogre::Radian(0), npcName + "knee", addresses, numbers); //cellRender.rotateMesh(Ogre::Vector3(0, 1, 0), Ogre::Radian (1), npcName + "upper arm"); - cellRender.insertMesh ("meshes\\" + knee->model, Ogre::Vector3( 0, -2, -18), axis, Ogre::Radian(0), npcName + "knee2", addresses2, numbers); + cellRender.insertMesh ("meshes\\" + knee->model, Ogre::Vector3( 0, -1, -23), axis, Ogre::Radian(0), npcName + "knee2", addresses2, numbers); addresses2[numbers] = npcName + "knee2"; addresses[numbers++] = npcName + "knee"; } if(ankle){ - cellRender.insertMesh ("meshes\\" + ankle->model, Ogre::Vector3( 0, -1, -18), axis, Ogre::Radian(0), npcName + "ankle", addresses, numbers); //-1 - cellRender.insertMesh ("meshes\\" + ankle->model, Ogre::Vector3( 0, -1, -18), axis, Ogre::Radian(0), npcName + "ankle2", addresses2, numbers); //-1 + cellRender.insertMesh ("meshes\\" + ankle->model, Ogre::Vector3( 0, 0, -20), axis, Ogre::Radian(0), npcName + "ankle", addresses, numbers); //-1 + cellRender.insertMesh ("meshes\\" + ankle->model, Ogre::Vector3( 0,0, -20), axis, Ogre::Radian(0), npcName + "ankle2", addresses2, numbers); //-1 addresses2[numbers] = npcName + "ankle2"; addresses[numbers++] = npcName + "ankle"; diff --git a/apps/openmw/mwrender/exterior.cpp b/apps/openmw/mwrender/exterior.cpp index 28986d6d7f..d3bc680bf7 100644 --- a/apps/openmw/mwrender/exterior.cpp +++ b/apps/openmw/mwrender/exterior.cpp @@ -115,8 +115,15 @@ void ExteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec, MovableObject *ent = scene.getMgr()->createEntity(mesh); + if(translateFirst){ npcPart->translate(vec); npcPart->rotate(axis, angle); + } + else{ + + npcPart->rotate(axis, angle); + npcPart->translate(vec); + } npcPart->attachObject(ent); Ogre::MeshManager *m = MeshManager::getSingletonPtr(); From 6b6ee5440e76c8d3b2af37f194974f9b946b996e Mon Sep 17 00:00:00 2001 From: Yuri Krupenin Date: Mon, 3 Jan 2011 17:00:53 +0300 Subject: [PATCH 05/18] Minimal set of fixes to build with MinGW. --- components/esm/esm_reader.hpp | 2 ++ libs/platform/string.h | 4 ++-- libs/platform/strings.h | 23 ++++++++++++++--------- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/components/esm/esm_reader.hpp b/components/esm/esm_reader.hpp index 64e0861b58..3b9f241f12 100644 --- a/components/esm/esm_reader.hpp +++ b/components/esm/esm_reader.hpp @@ -1,6 +1,8 @@ #ifndef _ESM_READER_H #define _ESM_READER_H +#include + #include #include #include diff --git a/libs/platform/string.h b/libs/platform/string.h index dc25279fe9..d4302ae783 100644 --- a/libs/platform/string.h +++ b/libs/platform/string.h @@ -1,9 +1,9 @@ -// Wrapper for string.h on Mac +// Wrapper for string.h on Mac and MinGW #ifndef _STRING_WRAPPER_H #define _STRING_WRAPPER_H #include -#ifdef __APPLE__ +#if defined(__APPLE__) || defined(__MINGW32__) // need our own implementation of strnlen static size_t strnlen(const char *s, size_t n) { diff --git a/libs/platform/strings.h b/libs/platform/strings.h index 0879ed87bb..fd917065dd 100644 --- a/libs/platform/strings.h +++ b/libs/platform/strings.h @@ -1,13 +1,18 @@ -// Wrapper for MSVC +// Wrapper for MSVC/GCC #ifndef _STRINGS_WRAPPER_H #define _STRINGS_WRAPPER_H -#ifdef WIN32 -#pragma warning(disable: 4996) -#define strcasecmp stricmp -#define snprintf _snprintf -#else -#include -#endif -#endif +// For GCC, just use strings.h (this applies to mingw too) +#if defined(__GNUC__) +# include +#elif defined(MSVC) +# pragma warning(disable: 4996) +# define strcasecmp stricmp +# define snprintf _snprintf +#else +# warning "Unable to determine your compiler, you should probably take a look here." +# include // Just take a guess +#endif + +#endif /* _STRINGS_WRAPPER_H */ From 15a7cc06740ae53d5a5db89a6c1591038c63c9c8 Mon Sep 17 00:00:00 2001 From: Yuri Krupenin Date: Tue, 4 Jan 2011 14:40:28 +0300 Subject: [PATCH 06/18] That should solve link-time problems when building with mingw. Not supplying "SUBSYSTEM:" flags to mingw linker. Linking mygui with libwinmm - should resolve reference to timeGetTime(). --- CMakeLists.txt | 24 ++++++++++--------- extern/mygui_3.0.1/MyGUIEngine/CMakeLists.txt | 4 ++++ 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0ad1c5a9ef..abfea1ebd9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -308,22 +308,24 @@ if (BUILD_ESMTOOL) endif() if (WIN32) + if (MSVC) if (USE_DEBUG_CONSOLE) - set_target_properties(openmw PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE") - set_target_properties(openmw PROPERTIES LINK_FLAGS_RELWITHDEBINFO "/SUBSYSTEM:CONSOLE") - set_target_properties(openmw PROPERTIES COMPILE_DEFINITIONS_DEBUG "_CONSOLE") + set_target_properties(openmw PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE") + set_target_properties(openmw PROPERTIES LINK_FLAGS_RELWITHDEBINFO "/SUBSYSTEM:CONSOLE") + set_target_properties(openmw PROPERTIES COMPILE_DEFINITIONS_DEBUG "_CONSOLE") else() - # Turn off debug console, debug output will be written to visual studio output instead - set_target_properties(openmw PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:WINDOWS") - set_target_properties(openmw PROPERTIES LINK_FLAGS_RELWITHDEBINFO "/SUBSYSTEM:WINDOWS") + # Turn off debug console, debug output will be written to visual studio output instead + set_target_properties(openmw PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:WINDOWS") + set_target_properties(openmw PROPERTIES LINK_FLAGS_RELWITHDEBINFO "/SUBSYSTEM:WINDOWS") endif() - + # Release builds use the debug console set_target_properties(openmw PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:CONSOLE") set_target_properties(openmw PROPERTIES COMPILE_DEFINITIONS_RELEASE "_CONSOLE") set_target_properties(openmw PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:CONSOLE") - - # TODO: At some point release builds should not use the console but rather write to a log file - #set_target_properties(openmw PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS") - #set_target_properties(openmw PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:WINDOWS") + endif(MSVC) + + # TODO: At some point release builds should not use the console but rather write to a log file + #set_target_properties(openmw PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS") + #set_target_properties(openmw PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:WINDOWS") endif() diff --git a/extern/mygui_3.0.1/MyGUIEngine/CMakeLists.txt b/extern/mygui_3.0.1/MyGUIEngine/CMakeLists.txt index 2089470b4d..5e1b24e62b 100644 --- a/extern/mygui_3.0.1/MyGUIEngine/CMakeLists.txt +++ b/extern/mygui_3.0.1/MyGUIEngine/CMakeLists.txt @@ -26,3 +26,7 @@ if (MYGUI_USE_FREETYPE) endif() target_link_libraries(${PROJECT_NAME} ${CMAKE_DL_LIBS} uuid) + +if (MINGW) + target_link_libraries(${PROJECT_NAME} libwinmm.a) +endif (MINGW) From 4a12be11bf3a6960092bceffc2559d5b9c09f379 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 4 Jan 2011 15:58:22 +0100 Subject: [PATCH 07/18] moved PlayerPos class from MWRender to MWWorld and renamed it to Player --- apps/openmw/CMakeLists.txt | 4 +-- apps/openmw/engine.cpp | 7 ++-- apps/openmw/mwclass/door.cpp | 5 ++- apps/openmw/mwdialogue/dialoguemanager.cpp | 3 +- apps/openmw/mwgui/layouts.cpp | 1 + apps/openmw/mwgui/review.cpp | 2 ++ apps/openmw/mwinput/inputmanager.cpp | 11 +++--- apps/openmw/mwinput/inputmanager.hpp | 6 ++-- apps/openmw/mwmechanics/mechanicsmanager.cpp | 35 ++++++++++--------- .../playerpos.cpp => mwworld/player.cpp} | 14 ++++---- .../playerpos.hpp => mwworld/player.hpp} | 15 ++++---- apps/openmw/mwworld/world.cpp | 28 +++++++-------- apps/openmw/mwworld/world.hpp | 8 ++--- 13 files changed, 71 insertions(+), 68 deletions(-) rename apps/openmw/{mwrender/playerpos.cpp => mwworld/player.cpp} (71%) rename apps/openmw/{mwrender/playerpos.hpp => mwworld/player.hpp} (87%) diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 88aaaecd48..b9fd3f4979 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -14,7 +14,6 @@ set(GAMEREND mwrender/cellimp.cpp mwrender/interior.cpp mwrender/exterior.cpp - mwrender/playerpos.cpp mwrender/sky.cpp) set(GAMEREND_HEADER mwrender/cell.hpp @@ -22,7 +21,6 @@ set(GAMEREND_HEADER mwrender/mwscene.hpp mwrender/interior.hpp mwrender/exterior.hpp - mwrender/playerpos.hpp mwrender/sky.hpp) source_group(apps\\openmw\\mwrender FILES ${GAMEREND} ${GAMEREND_HEADER}) @@ -120,6 +118,7 @@ set(GAMEWORLD mwworld/actiontalk.cpp mwworld/actiontake.cpp mwworld/containerutil.cpp + mwworld/player.cpp ) set(GAMEWORLD_HEADER mwworld/refdata.hpp @@ -137,6 +136,7 @@ set(GAMEWORLD_HEADER mwworld/containerstore.hpp mwworld/manualref.hpp mwworld/containerutil.hpp + mwworld/player.hpp ) source_group(apps\\openmw\\mwworld FILES ${GAMEWORLD} ${GAMEWORLD_HEADER}) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 9e14c119b1..e6aed692a1 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -29,6 +29,7 @@ #include "mwworld/ptr.hpp" #include "mwworld/environment.hpp" #include "mwworld/class.hpp" +#include "mwworld/player.hpp" #include "mwclass/classes.hpp" @@ -77,7 +78,7 @@ bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt) - MWWorld::Ptr::CellStore *current = mEnvironment.mWorld->getPlayerPos().getPlayer().getCell(); + MWWorld::Ptr::CellStore *current = mEnvironment.mWorld->getPlayer().getPlayer().getCell(); //If the region has changed if(!(current->cell->data.flags & current->cell->Interior) && timer.elapsed() >= 10){ timer.restart(); @@ -377,7 +378,7 @@ void OMW::Engine::go() } // Sets up the input system - MWInput::MWInputManager input(mOgre, mEnvironment.mWorld->getPlayerPos(), + MWInput::MWInputManager input(mOgre, mEnvironment.mWorld->getPlayer(), *mEnvironment.mWindowManager, mDebug, *this); mEnvironment.mInputManager = &input; @@ -439,7 +440,7 @@ void OMW::Engine::activate() &ptr.getRefData().getLocals(), ptr); boost::shared_ptr action = - MWWorld::Class::get (ptr).activate (ptr, mEnvironment.mWorld->getPlayerPos().getPlayer(), + MWWorld::Class::get (ptr).activate (ptr, mEnvironment.mWorld->getPlayer().getPlayer(), mEnvironment); interpreterContext.activate (ptr, action); diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index 32b33e95a4..4f294ce872 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -5,8 +5,7 @@ #include -#include "../mwrender/playerpos.hpp" - +#include "../mwworld/player.hpp" #include "../mwworld/ptr.hpp" #include "../mwworld/nullaction.hpp" #include "../mwworld/actionteleport.hpp" @@ -65,7 +64,7 @@ namespace MWClass if (ref->ref.teleport) { // teleport door - if (environment.mWorld->getPlayerPos().getPlayer()==actor) + if (environment.mWorld->getPlayer().getPlayer()==actor) { // the player is using the door return boost::shared_ptr ( diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index 0f6e732763..f78160cd78 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -13,6 +13,7 @@ #include "../mwworld/environment.hpp" #include "../mwworld/world.hpp" #include "../mwworld/refdata.hpp" +#include "../mwworld/player.hpp" #include "../mwinput/inputmanager.hpp" @@ -225,7 +226,7 @@ namespace MWDialogue // check cell if (!info.cell.empty()) - if (mEnvironment.mWorld->getPlayerPos().getPlayer().getCell()->cell->name != info.cell) + if (mEnvironment.mWorld->getPlayer().getPlayer().getCell()->cell->name != info.cell) return false; // TODO check DATAstruct diff --git a/apps/openmw/mwgui/layouts.cpp b/apps/openmw/mwgui/layouts.cpp index 501b234d1f..581a5a576e 100644 --- a/apps/openmw/mwgui/layouts.cpp +++ b/apps/openmw/mwgui/layouts.cpp @@ -4,6 +4,7 @@ #include "../mwmechanics/mechanicsmanager.hpp" #include "../mwgui/window_manager.hpp" +#include #include #include #include diff --git a/apps/openmw/mwgui/review.cpp b/apps/openmw/mwgui/review.cpp index 9eb6092ced..456849ed37 100644 --- a/apps/openmw/mwgui/review.cpp +++ b/apps/openmw/mwgui/review.cpp @@ -8,6 +8,8 @@ #include #include +#include + using namespace MWGui; using namespace Widgets; diff --git a/apps/openmw/mwinput/inputmanager.cpp b/apps/openmw/mwinput/inputmanager.cpp index 0544df6f0f..11e6cb6170 100644 --- a/apps/openmw/mwinput/inputmanager.cpp +++ b/apps/openmw/mwinput/inputmanager.cpp @@ -15,10 +15,11 @@ #include #include -#include "../mwrender/playerpos.hpp" #include "../engine.hpp" +#include "../mwworld/player.hpp" + #include #include #include @@ -58,7 +59,7 @@ namespace MWInput OEngine::Input::Poller poller; OEngine::Render::MouseLookEventPtr mouse; OEngine::GUI::EventInjectorPtr guiEvents; - MWRender::PlayerPos &player; + MWWorld::Player &player; MWGui::WindowManager &windows; OMW::Engine& mEngine; @@ -124,7 +125,7 @@ namespace MWInput public: InputImpl(OEngine::Render::OgreRenderer &_ogre, - MWRender::PlayerPos &_player, + MWWorld::Player &_player, MWGui::WindowManager &_windows, bool debug, OMW::Engine& engine) @@ -286,7 +287,7 @@ namespace MWInput }; MWInputManager::MWInputManager(OEngine::Render::OgreRenderer &ogre, - MWRender::PlayerPos &player, + MWWorld::Player &player, MWGui::WindowManager &windows, bool debug, OMW::Engine& engine) @@ -300,7 +301,7 @@ namespace MWInput } void MWInputManager::setGuiMode(MWGui::GuiMode mode) - { + { impl->setGuiMode(mode); } } diff --git a/apps/openmw/mwinput/inputmanager.hpp b/apps/openmw/mwinput/inputmanager.hpp index 0e0c4650f0..6b8034c8b4 100644 --- a/apps/openmw/mwinput/inputmanager.hpp +++ b/apps/openmw/mwinput/inputmanager.hpp @@ -11,9 +11,9 @@ namespace OEngine } } -namespace MWRender +namespace MWWorld { - class PlayerPos; + class Player; } namespace MWGui @@ -42,7 +42,7 @@ namespace MWInput public: MWInputManager(OEngine::Render::OgreRenderer &_ogre, - MWRender::PlayerPos &_player, + MWWorld::Player&_player, MWGui::WindowManager &_windows, bool debug, OMW::Engine& engine); diff --git a/apps/openmw/mwmechanics/mechanicsmanager.cpp b/apps/openmw/mwmechanics/mechanicsmanager.cpp index 23c0fe3b44..05219d6aaf 100644 --- a/apps/openmw/mwmechanics/mechanicsmanager.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanager.cpp @@ -8,12 +8,13 @@ #include "../mwworld/class.hpp" #include "../mwworld/environment.hpp" #include "../mwworld/world.hpp" +#include "../mwworld/player.hpp" namespace MWMechanics { void MechanicsManager::buildPlayer() { - MWWorld::Ptr ptr = mEnvironment.mWorld->getPlayerPos().getPlayer(); + MWWorld::Ptr ptr = mEnvironment.mWorld->getPlayer().getPlayer(); MWMechanics::CreatureStats& creatureStats = MWWorld::Class::get (ptr).getCreatureStats (ptr); MWMechanics::NpcStats& npcStats = MWWorld::Class::get (ptr).getNpcStats (ptr); @@ -33,9 +34,9 @@ namespace MWMechanics { const ESM::Race *race = mEnvironment.mWorld->getStore().races.find ( - mEnvironment.mWorld->getPlayerPos().getRace()); + mEnvironment.mWorld->getPlayer().getRace()); - bool male = mEnvironment.mWorld->getPlayerPos().isMale(); + bool male = mEnvironment.mWorld->getPlayer().isMale(); for (int i=0; i<8; ++i) { @@ -75,11 +76,11 @@ namespace MWMechanics } // birthsign - if (!mEnvironment.mWorld->getPlayerPos().getBirthsign().empty()) + if (!mEnvironment.mWorld->getPlayer().getBirthsign().empty()) { const ESM::BirthSign *sign = mEnvironment.mWorld->getStore().birthSigns.find ( - mEnvironment.mWorld->getPlayerPos().getBirthsign()); + mEnvironment.mWorld->getPlayer().getBirthsign()); for (std::vector::const_iterator iter (sign->powers.list.begin()); iter!=sign->powers.list.end(); ++iter) @@ -91,7 +92,7 @@ namespace MWMechanics // class if (mClassSelected) { - const ESM::Class& class_ = mEnvironment.mWorld->getPlayerPos().getClass(); + const ESM::Class& class_ = mEnvironment.mWorld->getPlayer().getClass(); for (int i=0; i<2; ++i) { @@ -330,12 +331,12 @@ namespace MWMechanics if (mUpdatePlayer) { // basic player profile; should not change anymore after the creation phase is finished. - mEnvironment.mWindowManager->setValue ("name", mEnvironment.mWorld->getPlayerPos().getName()); + mEnvironment.mWindowManager->setValue ("name", mEnvironment.mWorld->getPlayer().getName()); mEnvironment.mWindowManager->setValue ("race", - mEnvironment.mWorld->getStore().races.find (mEnvironment.mWorld->getPlayerPos(). + mEnvironment.mWorld->getStore().races.find (mEnvironment.mWorld->getPlayer(). getRace())->name); mEnvironment.mWindowManager->setValue ("class", - mEnvironment.mWorld->getPlayerPos().getClass().name); + mEnvironment.mWorld->getPlayer().getClass().name); mUpdatePlayer = false; MWGui::WindowManager::SkillList majorSkills (5); @@ -343,8 +344,8 @@ namespace MWMechanics for (int i=0; i<5; ++i) { - minorSkills[i] = mEnvironment.mWorld->getPlayerPos().getClass().data.skills[i][0]; - majorSkills[i] = mEnvironment.mWorld->getPlayerPos().getClass().data.skills[i][1]; + minorSkills[i] = mEnvironment.mWorld->getPlayer().getClass().data.skills[i][0]; + majorSkills[i] = mEnvironment.mWorld->getPlayer().getClass().data.skills[i][1]; } mEnvironment.mWindowManager->configureSkills (majorSkills, minorSkills); @@ -353,14 +354,14 @@ namespace MWMechanics void MechanicsManager::setPlayerName (const std::string& name) { - mEnvironment.mWorld->getPlayerPos().setName (name); + mEnvironment.mWorld->getPlayer().setName (name); mUpdatePlayer = true; } void MechanicsManager::setPlayerRace (const std::string& race, bool male) { - mEnvironment.mWorld->getPlayerPos().setGender (male); - mEnvironment.mWorld->getPlayerPos().setRace (race); + mEnvironment.mWorld->getPlayer().setGender (male); + mEnvironment.mWorld->getPlayer().setRace (race); mRaceSelected = true; buildPlayer(); mUpdatePlayer = true; @@ -368,14 +369,14 @@ namespace MWMechanics void MechanicsManager::setPlayerBirthsign (const std::string& id) { - mEnvironment.mWorld->getPlayerPos().setBirthsign (id); + mEnvironment.mWorld->getPlayer().setBirthsign (id); buildPlayer(); mUpdatePlayer = true; } void MechanicsManager::setPlayerClass (const std::string& id) { - mEnvironment.mWorld->getPlayerPos().setClass (*mEnvironment.mWorld->getStore().classes.find (id)); + mEnvironment.mWorld->getPlayer().setClass (*mEnvironment.mWorld->getStore().classes.find (id)); mClassSelected = true; buildPlayer(); mUpdatePlayer = true; @@ -383,7 +384,7 @@ namespace MWMechanics void MechanicsManager::setPlayerClass (const ESM::Class& class_) { - mEnvironment.mWorld->getPlayerPos().setClass (class_); + mEnvironment.mWorld->getPlayer().setClass (class_); mClassSelected = true; buildPlayer(); mUpdatePlayer = true; diff --git a/apps/openmw/mwrender/playerpos.cpp b/apps/openmw/mwworld/player.cpp similarity index 71% rename from apps/openmw/mwrender/playerpos.cpp rename to apps/openmw/mwworld/player.cpp index a1410e57b3..33b29a99a5 100644 --- a/apps/openmw/mwrender/playerpos.cpp +++ b/apps/openmw/mwworld/player.cpp @@ -1,11 +1,11 @@ -#include "playerpos.hpp" +#include "player.hpp" -#include "../mwworld/world.hpp" +#include "world.hpp" -namespace MWRender +namespace MWWorld { - PlayerPos::PlayerPos (Ogre::Camera *cam, const ESM::NPC *player, MWWorld::World& world) : + Player::Player (Ogre::Camera *cam, const ESM::NPC *player, MWWorld::World& world) : mCellStore (0), camera(cam), mWorld (world), mClass (0) { mPlayer.base = player; @@ -16,12 +16,12 @@ namespace MWRender mClass = new ESM::Class (*world.getStore().classes.find (player->cls)); } - PlayerPos::~PlayerPos() + Player::~Player() { delete mClass; } - void PlayerPos::setPos(float x, float y, float z, bool updateCamera) + void Player::setPos(float x, float y, float z, bool updateCamera) { mWorld.moveObject (getPlayer(), x, y, z); @@ -32,7 +32,7 @@ namespace MWRender -mPlayer.ref.pos.pos[1])); } - void PlayerPos::setClass (const ESM::Class& class_) + void Player::setClass (const ESM::Class& class_) { ESM::Class *new_class = new ESM::Class (class_); delete mClass; diff --git a/apps/openmw/mwrender/playerpos.hpp b/apps/openmw/mwworld/player.hpp similarity index 87% rename from apps/openmw/mwrender/playerpos.hpp rename to apps/openmw/mwworld/player.hpp index b694a72c3f..84a0dfef4c 100644 --- a/apps/openmw/mwrender/playerpos.hpp +++ b/apps/openmw/mwworld/player.hpp @@ -1,5 +1,5 @@ -#ifndef _MWRENDER_PLAYERPOS_H -#define _MWRENDER_PLAYERPOS_H +#ifndef GAME_MWWORLD_PLAYER_H +#define GAME_MWWORLD_PLAYER_H #include "OgreCamera.h" @@ -13,12 +13,9 @@ namespace MWWorld class World; } -namespace MWRender +namespace MWWorld { - // This class keeps track of the player position. It takes care of - // camera movement, sound listener updates, and collision handling - // (to be done). - class PlayerPos + class Player { ESMS::LiveCellRef mPlayer; MWWorld::Ptr::CellStore *mCellStore; @@ -32,9 +29,9 @@ namespace MWRender public: - PlayerPos(Ogre::Camera *cam, const ESM::NPC *player, MWWorld::World& world); + Player(Ogre::Camera *cam, const ESM::NPC *player, MWWorld::World& world); - ~PlayerPos(); + ~Player(); // Set the player position. Uses Morrowind coordinates. void setPos(float _x, float _y, float _z, bool updateCamera = false); diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index 317dc23615..7ad8afba85 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -17,7 +17,7 @@ #include "ptr.hpp" #include "environment.hpp" #include "class.hpp" - +#include "player.hpp" #include "refdata.hpp" #include "globals.hpp" @@ -296,12 +296,12 @@ namespace MWWorld void World::playerCellChange (Ptr::CellStore *cell, const ESM::Position& position) { - mPlayerPos->setPos (position.pos[0], position.pos[1], position.pos[2], true); - mPlayerPos->setCell (cell); + mPlayer->setPos (position.pos[0], position.pos[1], position.pos[2], true); + mPlayer->setCell (cell); // TODO orientation - mEnvironment.mMechanicsManager->addActor (mPlayerPos->getPlayer()); - mEnvironment.mMechanicsManager->watchActor (mPlayerPos->getPlayer()); + mEnvironment.mMechanicsManager->addActor (mPlayer->getPlayer()); + mEnvironment.mMechanicsManager->watchActor (mPlayer->getPlayer()); } @@ -317,7 +317,7 @@ namespace MWWorld World::World (OEngine::Render::OgreRenderer& renderer, const boost::filesystem::path& dataDir, const std::string& master, bool newGame, Environment& environment) - : mSkyManager (0), mScene (renderer), mPlayerPos (0), mCurrentCell (0), mGlobalVariables (0), + : mSkyManager (0), mScene (renderer), mPlayer (0), mCurrentCell (0), mGlobalVariables (0), mSky (false), mCellChanged (false), mEnvironment (environment) { boost::filesystem::path masterPath (dataDir); @@ -329,7 +329,7 @@ namespace MWWorld mEsm.open (masterPath.file_string()); mStore.load (mEsm); - mPlayerPos = new MWRender::PlayerPos (mScene.getCamera(), mStore.npcs.find ("player"), *this); + mPlayer = new MWWorld::Player (mScene.getCamera(), mStore.npcs.find ("player"), *this); // global variables mGlobalVariables = new Globals (mStore); @@ -354,14 +354,14 @@ namespace MWWorld iter!=mBufferedCells.end(); ++iter) delete iter->second; - delete mPlayerPos; + delete mPlayer; delete mSkyManager; delete mGlobalVariables; } - MWRender::PlayerPos& World::getPlayerPos() + MWWorld::Player& World::getPlayer() { - return *mPlayerPos; + return *mPlayer; } ESMS::ESMStore& World::getStore() @@ -394,7 +394,7 @@ namespace MWWorld // the player is always in an active cell. if (name=="player") { - return mPlayerPos->getPlayer(); + return mPlayer->getPlayer(); } // active cells @@ -763,7 +763,7 @@ namespace MWWorld ptr.getCellRef().pos.pos[1] = y; ptr.getCellRef().pos.pos[2] = z; - if (ptr==mPlayerPos->getPlayer()) + if (ptr==mPlayer->getPlayer()) { if (mCurrentCell) { @@ -777,7 +777,7 @@ namespace MWWorld if (mCurrentCell->cell->data.gridX!=cellX || mCurrentCell->cell->data.gridY!=cellY) { - changeCell (cellX, cellY, mPlayerPos->getPlayer().getCellRef().pos); + changeCell (cellX, cellY, mPlayer->getPlayer().getCellRef().pos); } } } @@ -800,7 +800,7 @@ namespace MWWorld } } - + void World::positionToIndex (float x, float y, int &cellX, int &cellY) const { diff --git a/apps/openmw/mwworld/world.hpp b/apps/openmw/mwworld/world.hpp index f774cd68e5..b2b80a8477 100644 --- a/apps/openmw/mwworld/world.hpp +++ b/apps/openmw/mwworld/world.hpp @@ -8,7 +8,6 @@ #include -#include "../mwrender/playerpos.hpp" #include "../mwrender/mwscene.hpp" #include "refdata.hpp" @@ -34,12 +33,13 @@ namespace MWRender namespace MWWorld { class Environment; + class Player; /// \brief The game world and its visual representation class World { - + public: typedef std::list > ScriptList; @@ -49,7 +49,7 @@ namespace MWWorld MWRender::SkyManager* mSkyManager; MWRender::MWScene mScene; - MWRender::PlayerPos *mPlayerPos; + MWWorld::Player *mPlayer; Ptr::CellStore *mCurrentCell; // the cell, the player is in CellRenderCollection mActiveCells; CellRenderCollection mBufferedCells; // loaded, but not active (buffering not implementd yet) @@ -94,7 +94,7 @@ namespace MWWorld ~World(); - MWRender::PlayerPos& getPlayerPos(); + MWWorld::Player& getPlayer(); ESMS::ESMStore& getStore(); From d38f2f0a00cd54833c38d382fb1d183309cfb662 Mon Sep 17 00:00:00 2001 From: Jan-Peter Nilsson Date: Sat, 1 Jan 2011 22:33:08 +0100 Subject: [PATCH 08/18] See if we have an instance of mData before trying to use it otherwise we get a crash when starting with --nosound --- apps/openmw/mwsound/soundmanager.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwsound/soundmanager.cpp b/apps/openmw/mwsound/soundmanager.cpp index 8bdd8e2b98..28bb08479f 100644 --- a/apps/openmw/mwsound/soundmanager.cpp +++ b/apps/openmw/mwsound/soundmanager.cpp @@ -364,10 +364,14 @@ namespace MWSound bool SoundManager::isMusicPlaying() - { - bool test = mData->music->isPlaying(); - return test; - } + { + bool test = false; + if(mData && mData->music) + { + test = mData->music->isPlaying(); + } + return test; + } SoundManager::SoundImpl SoundManager::getMData() { From ba18dc46ef0219c158b668a4616fff520f195213 Mon Sep 17 00:00:00 2001 From: Jan-Peter Nilsson Date: Thu, 30 Dec 2010 20:24:39 +0100 Subject: [PATCH 09/18] Don't try to play random tunes when sound is disabled --- apps/openmw/engine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 9e14c119b1..2840b41295 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -67,7 +67,7 @@ void OMW::Engine::executeLocalScripts() bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt) { - if(! (mEnvironment.mSoundManager->isMusicPlaying())) + if(mUseSound && !(mEnvironment.mSoundManager->isMusicPlaying())) { // Play some good 'ol tunes mEnvironment.mSoundManager->startRandomTitle(); From dd4d0223010b4c1dc8d6d3c30555b8f4b5af1b4d Mon Sep 17 00:00:00 2001 From: Pieter van der Kloet Date: Wed, 5 Jan 2011 22:18:21 +0100 Subject: [PATCH 10/18] Converted all tabs to four spaces --- apps/esmtool/esmtool_cmd.c | 726 +++++++++--------- apps/esmtool/esmtool_cmd.h | 10 +- apps/openmw/engine.cpp | 120 +-- apps/openmw/engine.hpp | 6 +- apps/openmw/main.cpp | 6 +- apps/openmw/mwclass/creature.cpp | 4 +- apps/openmw/mwclass/npc.cpp | 376 ++++----- apps/openmw/mwclass/npc.hpp | 2 +- apps/openmw/mwgui/widgets.cpp | 166 ++-- apps/openmw/mwgui/widgets.hpp | 52 +- apps/openmw/mwrender/cellimp.hpp | 10 +- apps/openmw/mwrender/exterior.cpp | 166 ++-- apps/openmw/mwrender/exterior.hpp | 14 +- apps/openmw/mwrender/interior.cpp | 156 ++-- apps/openmw/mwrender/interior.hpp | 14 +- apps/openmw/mwsound/soundmanager.cpp | 76 +- apps/openmw/mwsound/soundmanager.hpp | 18 +- apps/openmw/mwworld/world.cpp | 4 +- apps/openmw/mwworld/world.hpp | 6 +- components/bsa/tests/bsatool_cmd.c | 722 ++++++++--------- components/bsa/tests/bsatool_cmd.h | 12 +- components/compiler/errorhandler.hpp | 4 +- components/compiler/scanner.hpp | 2 +- components/compiler/streamerrorhandler.hpp | 2 +- components/esm/esm_reader.hpp | 22 +- components/esm/load_impl.cpp | 34 +- components/esm/loadappa.hpp | 8 +- components/esm/loadarmo.hpp | 24 +- components/esm/loadclas.hpp | 38 +- components/esm/loadclot.hpp | 20 +- components/esm/loadcont.hpp | 8 +- components/esm/loadcrea.hpp | 26 +- components/esm/loaddial.hpp | 22 +- components/esm/loadench.hpp | 10 +- components/esm/loadfact.hpp | 12 +- components/esm/loadgmst.hpp | 28 +- components/esm/loadligh.hpp | 18 +- components/esm/loadmisc.hpp | 4 +- components/esm/loadnpc.hpp | 46 +- components/esm/loadpgrd.hpp | 16 +- components/esm/loadrace.hpp | 4 +- components/esm/loadskil.cpp | 54 +- components/esm/loadskil.hpp | 4 +- components/esm/loadsndg.hpp | 12 +- components/esm/loadspel.hpp | 2 +- components/esm/loadweap.hpp | 32 +- components/esm_store/reclists.hpp | 6 +- components/misc/fileops.cpp | 2 +- components/nifogre/ogre_nif_loader.cpp | 452 +++++------ components/nifogre/ogre_nif_loader.hpp | 24 +- components/nifogre/tests/ogre_mesh_common.cpp | 2 +- 51 files changed, 1802 insertions(+), 1802 deletions(-) diff --git a/apps/esmtool/esmtool_cmd.c b/apps/esmtool/esmtool_cmd.c index f7e4d2d32f..d6556d9e71 100644 --- a/apps/esmtool/esmtool_cmd.c +++ b/apps/esmtool/esmtool_cmd.c @@ -354,45 +354,45 @@ struct option /* Names for the values of the `has_arg' field of `struct option'. */ #ifndef no_argument -#define no_argument 0 +#define no_argument 0 #endif #ifndef required_argument -#define required_argument 1 +#define required_argument 1 #endif #ifndef optional_argument -#define optional_argument 2 +#define optional_argument 2 #endif struct custom_getopt_data { - /* - * These have exactly the same meaning as the corresponding global variables, - * except that they are used for the reentrant versions of getopt. - */ - int custom_optind; - int custom_opterr; - int custom_optopt; - char *custom_optarg; + /* + * These have exactly the same meaning as the corresponding global variables, + * except that they are used for the reentrant versions of getopt. + */ + int custom_optind; + int custom_opterr; + int custom_optopt; + char *custom_optarg; - /* True if the internal members have been initialized. */ - int initialized; + /* True if the internal members have been initialized. */ + int initialized; - /* - * The next char to be scanned in the option-element in which the last option - * character we returned was found. This allows us to pick up the scan where - * we left off. If this is zero, or a null string, it means resume the scan by - * advancing to the next ARGV-element. - */ - char *nextchar; + /* + * The next char to be scanned in the option-element in which the last option + * character we returned was found. This allows us to pick up the scan where + * we left off. If this is zero, or a null string, it means resume the scan by + * advancing to the next ARGV-element. + */ + char *nextchar; - /* - * Describe the part of ARGV that contains non-options that have been skipped. - * `first_nonopt' is the index in ARGV of the first of them; `last_nonopt' is - * the index after the last of them. - */ - int first_nonopt; - int last_nonopt; + /* + * Describe the part of ARGV that contains non-options that have been skipped. + * `first_nonopt' is the index in ARGV of the first of them; `last_nonopt' is + * the index after the last of them. + */ + int first_nonopt; + int last_nonopt; }; /* @@ -448,137 +448,137 @@ static int custom_optopt = '?'; */ static void exchange(char **argv, struct custom_getopt_data *d) { - int bottom = d->first_nonopt; - int middle = d->last_nonopt; - int top = d->custom_optind; - char *tem; + int bottom = d->first_nonopt; + int middle = d->last_nonopt; + int top = d->custom_optind; + char *tem; - /* - * Exchange the shorter segment with the far end of the longer segment. - * That puts the shorter segment into the right place. It leaves the - * longer segment in the right place overall, but it consists of two - * parts that need to be swapped next. - */ - while (top > middle && middle > bottom) { - if (top - middle > middle - bottom) { - /* Bottom segment is the short one. */ - int len = middle - bottom; - int i; + /* + * Exchange the shorter segment with the far end of the longer segment. + * That puts the shorter segment into the right place. It leaves the + * longer segment in the right place overall, but it consists of two + * parts that need to be swapped next. + */ + while (top > middle && middle > bottom) { + if (top - middle > middle - bottom) { + /* Bottom segment is the short one. */ + int len = middle - bottom; + int i; - /* Swap it with the top part of the top segment. */ - for (i = 0; i < len; i++) { - tem = argv[bottom + i]; - argv[bottom + i] = - argv[top - (middle - bottom) + i]; - argv[top - (middle - bottom) + i] = tem; - } - /* Exclude the moved bottom segment from further swapping. */ - top -= len; - } else { - /* Top segment is the short one. */ - int len = top - middle; - int i; + /* Swap it with the top part of the top segment. */ + for (i = 0; i < len; i++) { + tem = argv[bottom + i]; + argv[bottom + i] = + argv[top - (middle - bottom) + i]; + argv[top - (middle - bottom) + i] = tem; + } + /* Exclude the moved bottom segment from further swapping. */ + top -= len; + } else { + /* Top segment is the short one. */ + int len = top - middle; + int i; - /* Swap it with the bottom part of the bottom segment. */ - for (i = 0; i < len; i++) { - tem = argv[bottom + i]; - argv[bottom + i] = argv[middle + i]; - argv[middle + i] = tem; - } - /* Exclude the moved top segment from further swapping. */ - bottom += len; - } - } - /* Update records for the slots the non-options now occupy. */ - d->first_nonopt += (d->custom_optind - d->last_nonopt); - d->last_nonopt = d->custom_optind; + /* Swap it with the bottom part of the bottom segment. */ + for (i = 0; i < len; i++) { + tem = argv[bottom + i]; + argv[bottom + i] = argv[middle + i]; + argv[middle + i] = tem; + } + /* Exclude the moved top segment from further swapping. */ + bottom += len; + } + } + /* Update records for the slots the non-options now occupy. */ + d->first_nonopt += (d->custom_optind - d->last_nonopt); + d->last_nonopt = d->custom_optind; } /* Initialize the internal data when the first call is made. */ static void custom_getopt_initialize(struct custom_getopt_data *d) { - /* - * Start processing options with ARGV-element 1 (since ARGV-element 0 - * is the program name); the sequence of previously skipped non-option - * ARGV-elements is empty. - */ - d->first_nonopt = d->last_nonopt = d->custom_optind; - d->nextchar = NULL; - d->initialized = 1; + /* + * Start processing options with ARGV-element 1 (since ARGV-element 0 + * is the program name); the sequence of previously skipped non-option + * ARGV-elements is empty. + */ + d->first_nonopt = d->last_nonopt = d->custom_optind; + d->nextchar = NULL; + d->initialized = 1; } #define NONOPTION_P (argv[d->custom_optind][0] != '-' || argv[d->custom_optind][1] == '\0') /* return: zero: continue, nonzero: return given value to user */ static int shuffle_argv(int argc, char *const *argv,const struct option *longopts, - struct custom_getopt_data *d) + struct custom_getopt_data *d) { - /* - * Give FIRST_NONOPT & LAST_NONOPT rational values if CUSTOM_OPTIND has been - * moved back by the user (who may also have changed the arguments). - */ - if (d->last_nonopt > d->custom_optind) - d->last_nonopt = d->custom_optind; - if (d->first_nonopt > d->custom_optind) - d->first_nonopt = d->custom_optind; - /* - * If we have just processed some options following some - * non-options, exchange them so that the options come first. - */ - if (d->first_nonopt != d->last_nonopt && - d->last_nonopt != d->custom_optind) - exchange((char **) argv, d); - else if (d->last_nonopt != d->custom_optind) - d->first_nonopt = d->custom_optind; - /* - * Skip any additional non-options and extend the range of - * non-options previously skipped. - */ - while (d->custom_optind < argc && NONOPTION_P) - d->custom_optind++; - d->last_nonopt = d->custom_optind; - /* - * The special ARGV-element `--' means premature end of options. Skip - * it like a null option, then exchange with previous non-options as if - * it were an option, then skip everything else like a non-option. - */ - if (d->custom_optind != argc && !strcmp(argv[d->custom_optind], "--")) { - d->custom_optind++; - if (d->first_nonopt != d->last_nonopt - && d->last_nonopt != d->custom_optind) - exchange((char **) argv, d); - else if (d->first_nonopt == d->last_nonopt) - d->first_nonopt = d->custom_optind; - d->last_nonopt = argc; - d->custom_optind = argc; - } - /* - * If we have done all the ARGV-elements, stop the scan and back over - * any non-options that we skipped and permuted. - */ - if (d->custom_optind == argc) { - /* - * Set the next-arg-index to point at the non-options that we - * previously skipped, so the caller will digest them. - */ - if (d->first_nonopt != d->last_nonopt) - d->custom_optind = d->first_nonopt; - return -1; - } - /* - * If we have come to a non-option and did not permute it, either stop - * the scan or describe it to the caller and pass it by. - */ - if (NONOPTION_P) { - d->custom_optarg = argv[d->custom_optind++]; - return 1; - } - /* - * We have found another option-ARGV-element. Skip the initial - * punctuation. - */ - d->nextchar = (argv[d->custom_optind] + 1 + (longopts != NULL && argv[d->custom_optind][1] == '-')); - return 0; + /* + * Give FIRST_NONOPT & LAST_NONOPT rational values if CUSTOM_OPTIND has been + * moved back by the user (who may also have changed the arguments). + */ + if (d->last_nonopt > d->custom_optind) + d->last_nonopt = d->custom_optind; + if (d->first_nonopt > d->custom_optind) + d->first_nonopt = d->custom_optind; + /* + * If we have just processed some options following some + * non-options, exchange them so that the options come first. + */ + if (d->first_nonopt != d->last_nonopt && + d->last_nonopt != d->custom_optind) + exchange((char **) argv, d); + else if (d->last_nonopt != d->custom_optind) + d->first_nonopt = d->custom_optind; + /* + * Skip any additional non-options and extend the range of + * non-options previously skipped. + */ + while (d->custom_optind < argc && NONOPTION_P) + d->custom_optind++; + d->last_nonopt = d->custom_optind; + /* + * The special ARGV-element `--' means premature end of options. Skip + * it like a null option, then exchange with previous non-options as if + * it were an option, then skip everything else like a non-option. + */ + if (d->custom_optind != argc && !strcmp(argv[d->custom_optind], "--")) { + d->custom_optind++; + if (d->first_nonopt != d->last_nonopt + && d->last_nonopt != d->custom_optind) + exchange((char **) argv, d); + else if (d->first_nonopt == d->last_nonopt) + d->first_nonopt = d->custom_optind; + d->last_nonopt = argc; + d->custom_optind = argc; + } + /* + * If we have done all the ARGV-elements, stop the scan and back over + * any non-options that we skipped and permuted. + */ + if (d->custom_optind == argc) { + /* + * Set the next-arg-index to point at the non-options that we + * previously skipped, so the caller will digest them. + */ + if (d->first_nonopt != d->last_nonopt) + d->custom_optind = d->first_nonopt; + return -1; + } + /* + * If we have come to a non-option and did not permute it, either stop + * the scan or describe it to the caller and pass it by. + */ + if (NONOPTION_P) { + d->custom_optarg = argv[d->custom_optind++]; + return 1; + } + /* + * We have found another option-ARGV-element. Skip the initial + * punctuation. + */ + d->nextchar = (argv[d->custom_optind] + 1 + (longopts != NULL && argv[d->custom_optind][1] == '-')); + return 0; } /* @@ -592,180 +592,180 @@ static int shuffle_argv(int argc, char *const *argv,const struct option *longopt * */ static int check_long_opt(int argc, char *const *argv, const char *optstring, - const struct option *longopts, int *longind, - int print_errors, struct custom_getopt_data *d) + const struct option *longopts, int *longind, + int print_errors, struct custom_getopt_data *d) { - char *nameend; - const struct option *p; - const struct option *pfound = NULL; - int exact = 0; - int ambig = 0; - int indfound = -1; - int option_index; + char *nameend; + const struct option *p; + const struct option *pfound = NULL; + int exact = 0; + int ambig = 0; + int indfound = -1; + int option_index; - for (nameend = d->nextchar; *nameend && *nameend != '='; nameend++) - /* Do nothing. */ ; + for (nameend = d->nextchar; *nameend && *nameend != '='; nameend++) + /* Do nothing. */ ; - /* Test all long options for either exact match or abbreviated matches */ - for (p = longopts, option_index = 0; p->name; p++, option_index++) - if (!strncmp(p->name, d->nextchar, nameend - d->nextchar)) { - if ((unsigned int) (nameend - d->nextchar) - == (unsigned int) strlen(p->name)) { - /* Exact match found. */ - pfound = p; - indfound = option_index; - exact = 1; - break; - } else if (pfound == NULL) { - /* First nonexact match found. */ - pfound = p; - indfound = option_index; - } else if (pfound->has_arg != p->has_arg - || pfound->flag != p->flag - || pfound->val != p->val) - /* Second or later nonexact match found. */ - ambig = 1; - } - if (ambig && !exact) { - if (print_errors) { - fprintf(stderr, - "%s: option `%s' is ambiguous\n", - argv[0], argv[d->custom_optind]); - } - d->nextchar += strlen(d->nextchar); - d->custom_optind++; - d->custom_optopt = 0; - return '?'; - } - if (pfound) { - option_index = indfound; - d->custom_optind++; - if (*nameend) { - if (pfound->has_arg != no_argument) - d->custom_optarg = nameend + 1; - else { - if (print_errors) { - if (argv[d->custom_optind - 1][1] == '-') { - /* --option */ - fprintf(stderr, "%s: option `--%s' doesn't allow an argument\n", - argv[0], pfound->name); - } else { - /* +option or -option */ - fprintf(stderr, "%s: option `%c%s' doesn't allow an argument\n", - argv[0], argv[d->custom_optind - 1][0], pfound->name); - } + /* Test all long options for either exact match or abbreviated matches */ + for (p = longopts, option_index = 0; p->name; p++, option_index++) + if (!strncmp(p->name, d->nextchar, nameend - d->nextchar)) { + if ((unsigned int) (nameend - d->nextchar) + == (unsigned int) strlen(p->name)) { + /* Exact match found. */ + pfound = p; + indfound = option_index; + exact = 1; + break; + } else if (pfound == NULL) { + /* First nonexact match found. */ + pfound = p; + indfound = option_index; + } else if (pfound->has_arg != p->has_arg + || pfound->flag != p->flag + || pfound->val != p->val) + /* Second or later nonexact match found. */ + ambig = 1; + } + if (ambig && !exact) { + if (print_errors) { + fprintf(stderr, + "%s: option `%s' is ambiguous\n", + argv[0], argv[d->custom_optind]); + } + d->nextchar += strlen(d->nextchar); + d->custom_optind++; + d->custom_optopt = 0; + return '?'; + } + if (pfound) { + option_index = indfound; + d->custom_optind++; + if (*nameend) { + if (pfound->has_arg != no_argument) + d->custom_optarg = nameend + 1; + else { + if (print_errors) { + if (argv[d->custom_optind - 1][1] == '-') { + /* --option */ + fprintf(stderr, "%s: option `--%s' doesn't allow an argument\n", + argv[0], pfound->name); + } else { + /* +option or -option */ + fprintf(stderr, "%s: option `%c%s' doesn't allow an argument\n", + argv[0], argv[d->custom_optind - 1][0], pfound->name); + } - } - d->nextchar += strlen(d->nextchar); - d->custom_optopt = pfound->val; - return '?'; - } - } else if (pfound->has_arg == required_argument) { - if (d->custom_optind < argc) - d->custom_optarg = argv[d->custom_optind++]; - else { - if (print_errors) { - fprintf(stderr, - "%s: option `%s' requires an argument\n", - argv[0], - argv[d->custom_optind - 1]); - } - d->nextchar += strlen(d->nextchar); - d->custom_optopt = pfound->val; - return optstring[0] == ':' ? ':' : '?'; - } - } - d->nextchar += strlen(d->nextchar); - if (longind != NULL) - *longind = option_index; - if (pfound->flag) { - *(pfound->flag) = pfound->val; - return 0; - } - return pfound->val; - } - /* - * Can't find it as a long option. If this is not getopt_long_only, or - * the option starts with '--' or is not a valid short option, then - * it's an error. Otherwise interpret it as a short option. - */ - if (print_errors) { - if (argv[d->custom_optind][1] == '-') { - /* --option */ - fprintf(stderr, - "%s: unrecognized option `--%s'\n", - argv[0], d->nextchar); - } else { - /* +option or -option */ - fprintf(stderr, - "%s: unrecognized option `%c%s'\n", - argv[0], argv[d->custom_optind][0], - d->nextchar); - } - } - d->nextchar = (char *) ""; - d->custom_optind++; - d->custom_optopt = 0; - return '?'; + } + d->nextchar += strlen(d->nextchar); + d->custom_optopt = pfound->val; + return '?'; + } + } else if (pfound->has_arg == required_argument) { + if (d->custom_optind < argc) + d->custom_optarg = argv[d->custom_optind++]; + else { + if (print_errors) { + fprintf(stderr, + "%s: option `%s' requires an argument\n", + argv[0], + argv[d->custom_optind - 1]); + } + d->nextchar += strlen(d->nextchar); + d->custom_optopt = pfound->val; + return optstring[0] == ':' ? ':' : '?'; + } + } + d->nextchar += strlen(d->nextchar); + if (longind != NULL) + *longind = option_index; + if (pfound->flag) { + *(pfound->flag) = pfound->val; + return 0; + } + return pfound->val; + } + /* + * Can't find it as a long option. If this is not getopt_long_only, or + * the option starts with '--' or is not a valid short option, then + * it's an error. Otherwise interpret it as a short option. + */ + if (print_errors) { + if (argv[d->custom_optind][1] == '-') { + /* --option */ + fprintf(stderr, + "%s: unrecognized option `--%s'\n", + argv[0], d->nextchar); + } else { + /* +option or -option */ + fprintf(stderr, + "%s: unrecognized option `%c%s'\n", + argv[0], argv[d->custom_optind][0], + d->nextchar); + } + } + d->nextchar = (char *) ""; + d->custom_optind++; + d->custom_optopt = 0; + return '?'; } static int check_short_opt(int argc, char *const *argv, const char *optstring, - int print_errors, struct custom_getopt_data *d) + int print_errors, struct custom_getopt_data *d) { - char c = *d->nextchar++; - const char *temp = strchr(optstring, c); + char c = *d->nextchar++; + const char *temp = strchr(optstring, c); - /* Increment `custom_optind' when we start to process its last character. */ - if (*d->nextchar == '\0') - ++d->custom_optind; - if (!temp || c == ':') { - if (print_errors) - fprintf(stderr, "%s: invalid option -- %c\n", argv[0], c); + /* Increment `custom_optind' when we start to process its last character. */ + if (*d->nextchar == '\0') + ++d->custom_optind; + if (!temp || c == ':') { + if (print_errors) + fprintf(stderr, "%s: invalid option -- %c\n", argv[0], c); - d->custom_optopt = c; - return '?'; - } - if (temp[1] == ':') { - if (temp[2] == ':') { - /* This is an option that accepts an argument optionally. */ - if (*d->nextchar != '\0') { - d->custom_optarg = d->nextchar; - d->custom_optind++; - } else - d->custom_optarg = NULL; - d->nextchar = NULL; - } else { - /* This is an option that requires an argument. */ - if (*d->nextchar != '\0') { - d->custom_optarg = d->nextchar; - /* - * If we end this ARGV-element by taking the - * rest as an arg, we must advance to the next - * element now. - */ - d->custom_optind++; - } else if (d->custom_optind == argc) { - if (print_errors) { - fprintf(stderr, - "%s: option requires an argument -- %c\n", - argv[0], c); - } - d->custom_optopt = c; - if (optstring[0] == ':') - c = ':'; - else - c = '?'; - } else - /* - * We already incremented `custom_optind' once; - * increment it again when taking next ARGV-elt - * as argument. - */ - d->custom_optarg = argv[d->custom_optind++]; - d->nextchar = NULL; - } - } - return c; + d->custom_optopt = c; + return '?'; + } + if (temp[1] == ':') { + if (temp[2] == ':') { + /* This is an option that accepts an argument optionally. */ + if (*d->nextchar != '\0') { + d->custom_optarg = d->nextchar; + d->custom_optind++; + } else + d->custom_optarg = NULL; + d->nextchar = NULL; + } else { + /* This is an option that requires an argument. */ + if (*d->nextchar != '\0') { + d->custom_optarg = d->nextchar; + /* + * If we end this ARGV-element by taking the + * rest as an arg, we must advance to the next + * element now. + */ + d->custom_optind++; + } else if (d->custom_optind == argc) { + if (print_errors) { + fprintf(stderr, + "%s: option requires an argument -- %c\n", + argv[0], c); + } + d->custom_optopt = c; + if (optstring[0] == ':') + c = ':'; + else + c = '?'; + } else + /* + * We already incremented `custom_optind' once; + * increment it again when taking next ARGV-elt + * as argument. + */ + d->custom_optarg = argv[d->custom_optind++]; + d->nextchar = NULL; + } + } + return c; } /* @@ -839,59 +839,59 @@ static int check_short_opt(int argc, char *const *argv, const char *optstring, */ static int getopt_internal_r(int argc, char *const *argv, const char *optstring, - const struct option *longopts, int *longind, - struct custom_getopt_data *d) + const struct option *longopts, int *longind, + struct custom_getopt_data *d) { - int ret, print_errors = d->custom_opterr; + int ret, print_errors = d->custom_opterr; - if (optstring[0] == ':') - print_errors = 0; - if (argc < 1) - return -1; - d->custom_optarg = NULL; + if (optstring[0] == ':') + print_errors = 0; + if (argc < 1) + return -1; + d->custom_optarg = NULL; - /* - * This is a big difference with GNU getopt, since optind == 0 - * means initialization while here 1 means first call. - */ - if (d->custom_optind == 0 || !d->initialized) { - if (d->custom_optind == 0) - d->custom_optind = 1; /* Don't scan ARGV[0], the program name. */ - custom_getopt_initialize(d); - } - if (d->nextchar == NULL || *d->nextchar == '\0') { - ret = shuffle_argv(argc, argv, longopts, d); - if (ret) - return ret; - } - if (longopts && (argv[d->custom_optind][1] == '-' )) - return check_long_opt(argc, argv, optstring, longopts, - longind, print_errors, d); - return check_short_opt(argc, argv, optstring, print_errors, d); + /* + * This is a big difference with GNU getopt, since optind == 0 + * means initialization while here 1 means first call. + */ + if (d->custom_optind == 0 || !d->initialized) { + if (d->custom_optind == 0) + d->custom_optind = 1; /* Don't scan ARGV[0], the program name. */ + custom_getopt_initialize(d); + } + if (d->nextchar == NULL || *d->nextchar == '\0') { + ret = shuffle_argv(argc, argv, longopts, d); + if (ret) + return ret; + } + if (longopts && (argv[d->custom_optind][1] == '-' )) + return check_long_opt(argc, argv, optstring, longopts, + longind, print_errors, d); + return check_short_opt(argc, argv, optstring, print_errors, d); } static int custom_getopt_internal(int argc, char *const *argv, const char *optstring, - const struct option *longopts, int *longind) + const struct option *longopts, int *longind) { - int result; - /* Keep a global copy of all internal members of d */ - static struct custom_getopt_data d; + int result; + /* Keep a global copy of all internal members of d */ + static struct custom_getopt_data d; - d.custom_optind = custom_optind; - d.custom_opterr = custom_opterr; - result = getopt_internal_r(argc, argv, optstring, longopts, - longind, &d); - custom_optind = d.custom_optind; - custom_optarg = d.custom_optarg; - custom_optopt = d.custom_optopt; - return result; + d.custom_optind = custom_optind; + d.custom_opterr = custom_opterr; + result = getopt_internal_r(argc, argv, optstring, longopts, + longind, &d); + custom_optind = d.custom_optind; + custom_optarg = d.custom_optarg; + custom_optopt = d.custom_optopt; + return result; } static int custom_getopt_long (int argc, char *const *argv, const char *options, - const struct option *long_options, int *opt_index) + const struct option *long_options, int *opt_index) { - return custom_getopt_internal(argc, argv, options, long_options, - opt_index); + return custom_getopt_internal(argc, argv, options, long_options, + opt_index); } @@ -989,7 +989,7 @@ cmdline_parser_internal ( int argc, char * const *argv, struct gengetopt_args_info *args_info, struct cmdline_parser_params *params, const char *additional_error) { - int c; /* Character of the parsed option. */ + int c; /* Character of the parsed option. */ int error = 0; struct gengetopt_args_info local_args_info; @@ -1026,11 +1026,11 @@ cmdline_parser_internal ( int option_index = 0; static struct option long_options[] = { - { "help", 0, NULL, 'h' }, - { "version", 0, NULL, 'V' }, - { "raw", 0, NULL, 'r' }, - { "quiet", 0, NULL, 'q' }, - { "loadcells", 0, NULL, 'C' }, + { "help", 0, NULL, 'h' }, + { "version", 0, NULL, 'V' }, + { "raw", 0, NULL, 'r' }, + { "quiet", 0, NULL, 'q' }, + { "loadcells", 0, NULL, 'C' }, { 0, 0, 0, 0 } }; @@ -1046,21 +1046,21 @@ cmdline_parser_internal ( opterr = custom_opterr; optopt = custom_optopt; - if (c == -1) break; /* Exit from `while (1)' loop. */ + if (c == -1) break; /* Exit from `while (1)' loop. */ switch (c) { - case 'h': /* Print help and exit. */ + case 'h': /* Print help and exit. */ cmdline_parser_print_help (); cmdline_parser_free (&local_args_info); exit (EXIT_SUCCESS); - case 'V': /* Print version and exit. */ + case 'V': /* Print version and exit. */ cmdline_parser_print_version (); cmdline_parser_free (&local_args_info); exit (EXIT_SUCCESS); - case 'r': /* Show an unformattet list of all records and subrecords. */ + case 'r': /* Show an unformattet list of all records and subrecords. */ if (update_arg( 0 , @@ -1072,7 +1072,7 @@ cmdline_parser_internal ( goto failure; break; - case 'q': /* Supress all record information. Useful for speed tests.. */ + case 'q': /* Supress all record information. Useful for speed tests.. */ if (update_arg( 0 , @@ -1084,7 +1084,7 @@ cmdline_parser_internal ( goto failure; break; - case 'C': /* Browse through contents of all cells.. */ + case 'C': /* Browse through contents of all cells.. */ if (update_arg( 0 , @@ -1097,12 +1097,12 @@ cmdline_parser_internal ( break; - case 0: /* Long option with no short option */ - case '?': /* Invalid option. */ + case 0: /* Long option with no short option */ + case '?': /* Invalid option. */ /* `getopt_long' already printed an error message. */ goto failure; - default: /* bug: option not considered. */ + default: /* bug: option not considered. */ fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : "")); abort (); } /* switch */ diff --git a/apps/esmtool/esmtool_cmd.h b/apps/esmtool/esmtool_cmd.h index c2561c00a0..8c420c189e 100644 --- a/apps/esmtool/esmtool_cmd.h +++ b/apps/esmtool/esmtool_cmd.h @@ -43,11 +43,11 @@ struct gengetopt_args_info const char *quiet_help; /**< @brief Supress all record information. Useful for speed tests. help description. */ const char *loadcells_help; /**< @brief Browse through contents of all cells. help description. */ - unsigned int help_given ; /**< @brief Whether help was given. */ - unsigned int version_given ; /**< @brief Whether version was given. */ - unsigned int raw_given ; /**< @brief Whether raw was given. */ - unsigned int quiet_given ; /**< @brief Whether quiet was given. */ - unsigned int loadcells_given ; /**< @brief Whether loadcells was given. */ + unsigned int help_given ; /**< @brief Whether help was given. */ + unsigned int version_given ; /**< @brief Whether version was given. */ + unsigned int raw_given ; /**< @brief Whether raw was given. */ + unsigned int quiet_given ; /**< @brief Whether quiet was given. */ + unsigned int loadcells_given ; /**< @brief Whether loadcells was given. */ char **inputs ; /**< @brief unamed options (options without names) */ unsigned inputs_num ; /**< @brief unamed options number */ diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 9e14c119b1..61482279ee 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -67,73 +67,73 @@ void OMW::Engine::executeLocalScripts() bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt) { - if(! (mEnvironment.mSoundManager->isMusicPlaying())) - { - // Play some good 'ol tunes - mEnvironment.mSoundManager->startRandomTitle(); - } + if(! (mEnvironment.mSoundManager->isMusicPlaying())) + { + // Play some good 'ol tunes + mEnvironment.mSoundManager->startRandomTitle(); + } - std::string effect; + std::string effect; - MWWorld::Ptr::CellStore *current = mEnvironment.mWorld->getPlayerPos().getPlayer().getCell(); - //If the region has changed - if(!(current->cell->data.flags & current->cell->Interior) && timer.elapsed() >= 10){ - timer.restart(); - if (test.name != current->cell->region) - { - total = 0; - test = (ESM::Region) *(mEnvironment.mWorld->getStore().regions.find(current->cell->region)); - } + MWWorld::Ptr::CellStore *current = mEnvironment.mWorld->getPlayerPos().getPlayer().getCell(); + //If the region has changed + if(!(current->cell->data.flags & current->cell->Interior) && timer.elapsed() >= 10){ + timer.restart(); + if (test.name != current->cell->region) + { + total = 0; + test = (ESM::Region) *(mEnvironment.mWorld->getStore().regions.find(current->cell->region)); + } - if(test.soundList.size() > 0) - { - std::vector::iterator soundIter = test.soundList.begin(); - //mEnvironment.mSoundManager - if(total == 0){ - while (!(soundIter == test.soundList.end())) - { - ESM::NAME32 go = soundIter->sound; - int chance = (int) soundIter->chance; - //std::cout << "Sound: " << go.name <<" Chance:" << chance << "\n"; - soundIter++; - total += chance; - } - } + if(test.soundList.size() > 0) + { + std::vector::iterator soundIter = test.soundList.begin(); + //mEnvironment.mSoundManager + if(total == 0){ + while (!(soundIter == test.soundList.end())) + { + ESM::NAME32 go = soundIter->sound; + int chance = (int) soundIter->chance; + //std::cout << "Sound: " << go.name <<" Chance:" << chance << "\n"; + soundIter++; + total += chance; + } + } - srand ( time(NULL) ); - int r = rand() % total; //old random code - int pos = 0; - soundIter = test.soundList.begin(); - while (!(soundIter == test.soundList.end())) - { - const ESM::NAME32 go = soundIter->sound; - int chance = (int) soundIter->chance; - //std::cout << "Sound: " << go.name <<" Chance:" << chance << "\n"; - soundIter++; - if( r - pos < chance) - { - effect = go.name; - //play sound - std::cout << "Sound: " << go.name <<" Chance:" << chance << "\n"; - mEnvironment.mSoundManager->playSound(effect, 20.0, 1.0); + srand ( time(NULL) ); + int r = rand() % total; //old random code + int pos = 0; + soundIter = test.soundList.begin(); + while (!(soundIter == test.soundList.end())) + { + const ESM::NAME32 go = soundIter->sound; + int chance = (int) soundIter->chance; + //std::cout << "Sound: " << go.name <<" Chance:" << chance << "\n"; + soundIter++; + if( r - pos < chance) + { + effect = go.name; + //play sound + std::cout << "Sound: " << go.name <<" Chance:" << chance << "\n"; + mEnvironment.mSoundManager->playSound(effect, 20.0, 1.0); - break; + break; - } - pos += chance; - } - } + } + pos += chance; + } + } - //mEnvironment.mSoundManager->playSound(effect, 1.0, 1.0); - //printf("REGION: %s\n", test.name); + //mEnvironment.mSoundManager->playSound(effect, 1.0, 1.0); + //printf("REGION: %s\n", test.name); - } - else if(current->cell->data.flags & current->cell->Interior) - { - test.name = ""; - } + } + else if(current->cell->data.flags & current->cell->Interior) + { + test.name = ""; + } try { @@ -184,7 +184,7 @@ bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt) { std::cerr << "Error in framelistener: " << e.what() << std::endl; } - //std::cout << "TESTING2"; + //std::cout << "TESTING2"; return true; } @@ -294,8 +294,8 @@ void OMW::Engine::go() assert (!mCellName.empty()); assert (!mMaster.empty()); - test.name = ""; - total = 0; + test.name = ""; + total = 0; diff --git a/apps/openmw/engine.hpp b/apps/openmw/engine.hpp index 4f8f5af9c1..eeefbc65df 100644 --- a/apps/openmw/engine.hpp +++ b/apps/openmw/engine.hpp @@ -55,7 +55,7 @@ namespace OMW class Engine : private Ogre::FrameListener { - //int nFiles; + //int nFiles; boost::filesystem::path mDataDir; OEngine::Render::OgreRenderer mOgre; std::string mCellName; @@ -72,8 +72,8 @@ namespace OMW Compiler::Extensions mExtensions; Compiler::Context *mScriptContext; OEngine::GUI::MyGUIManager *mGuiManager; - ESM::Region test; - boost::timer timer; + ESM::Region test; + boost::timer timer; int focusFrameCounter; static const int focusUpdateFrame = 10; diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index 74508d77f8..3932287771 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -56,10 +56,10 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine) bpo::variables_map variables; #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE - std::string configFilePath(macBundlePath() + "/Contents/MacOS/openmw.cfg"); - std::ifstream configFile (configFilePath.c_str()); + std::string configFilePath(macBundlePath() + "/Contents/MacOS/openmw.cfg"); + std::ifstream configFile (configFilePath.c_str()); #else - std::ifstream configFile ("openmw.cfg"); + std::ifstream configFile ("openmw.cfg"); #endif bpo::parsed_options valid_opts = bpo::command_line_parser(argc, argv).options(desc).allow_unregistered().run(); diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index 7a50fcb2a6..0d358441a0 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -90,7 +90,7 @@ namespace MWClass const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const { return boost::shared_ptr (new MWWorld::ActionTalk (ptr)); - } + } MWWorld::ContainerStore& Creature::getContainerStore (const MWWorld::Ptr& ptr) const @@ -106,7 +106,7 @@ namespace MWClass } return *ptr.getRefData().getContainerStore(); - } + } std::string Creature::getScript (const MWWorld::Ptr& ptr) const { diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index c277832ab8..6802659322 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -29,26 +29,26 @@ namespace MWClass void Npc::insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender, MWWorld::Environment& environment) const { - //Ogre::SceneNode *chest; + //Ogre::SceneNode *chest; ESMS::LiveCellRef *ref = ptr.get(); - - //Store scenenodes by npc's name + bodypart [0] , npc's name + bodypart [1] - //Ex. Fargothchest , Fargothneck + + //Store scenenodes by npc's name + bodypart [0] , npc's name + bodypart [1] + //Ex. Fargothchest , Fargothneck assert (ref->base != NULL); - std::string hairID = ref->base->hair; + std::string hairID = ref->base->hair; std::string headID = ref->base->head; - std::string npcName = ref->base->name; - //std::cout << "NPC: " << npcName << "\n"; + std::string npcName = ref->base->name; + //std::cout << "NPC: " << npcName << "\n"; //get the part of the bodypart id which describes the race and the gender std::string bodyRaceID = headID.substr(0, headID.find_last_of("head_") - 4); std::string headModel = "meshes\\" + environment.mWorld->getStore().bodyParts.find(headID)->model; - std::string hairModel = "meshes\\" + + std::string hairModel = "meshes\\" + environment.mWorld->getStore().bodyParts.find(hairID)->model; MWRender::Rendering rendering (cellRender, ref->ref); @@ -59,200 +59,200 @@ namespace MWClass const ESM::BodyPart *bodyPart = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "chest"); - //bodyPart->model-> - Ogre::Vector3 pos = Ogre::Vector3( 20, 20, 20); - Ogre::Vector3 axis = Ogre::Vector3( 0, 0, 1); - Ogre::Radian angle = Ogre::Radian(0); - - std::string addresses[6] = {"", "", "", "","", ""}; - std::string addresses2[6] = {"", "", "", "", "", ""}; - std::string upperleft[5] = {"", "", "", "", ""}; - std::string upperright[5] = {"", "", "", "", ""}; - std::string neckandup[5] = {"", "", "","",""}; - std::string empty[6] = {"", "", "", "","", ""}; - int numbers = 0; - int uppernumbers = 0; - int neckNumbers = 0; - + //bodyPart->model-> + Ogre::Vector3 pos = Ogre::Vector3( 20, 20, 20); + Ogre::Vector3 axis = Ogre::Vector3( 0, 0, 1); + Ogre::Radian angle = Ogre::Radian(0); + + std::string addresses[6] = {"", "", "", "","", ""}; + std::string addresses2[6] = {"", "", "", "", "", ""}; + std::string upperleft[5] = {"", "", "", "", ""}; + std::string upperright[5] = {"", "", "", "", ""}; + std::string neckandup[5] = {"", "", "","",""}; + std::string empty[6] = {"", "", "", "","", ""}; + int numbers = 0; + int uppernumbers = 0; + int neckNumbers = 0; + if (bodyPart){ - + cellRender.insertMesh("meshes\\" + bodyPart->model, pos, axis, angle, npcName + "chest", addresses, numbers, true); //2 0 - addresses2[numbers] = npcName + "chest"; - addresses[numbers++] = npcName + "chest"; - upperleft[uppernumbers] = npcName + "chest"; - upperright[uppernumbers++] = npcName + "chest"; - neckandup[neckNumbers++] = npcName + "chest"; - } - //std::cout << "GETTING NPC PART"; - //Orgre::SceneNode test = cellRender.getNpcPart(); + addresses2[numbers] = npcName + "chest"; + addresses[numbers++] = npcName + "chest"; + upperleft[uppernumbers] = npcName + "chest"; + upperright[uppernumbers++] = npcName + "chest"; + neckandup[neckNumbers++] = npcName + "chest"; + } + //std::cout << "GETTING NPC PART"; + //Orgre::SceneNode test = cellRender.getNpcPart(); - const ESM::BodyPart *upperleg = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "upper leg"); - const ESM::BodyPart *groin = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "groin"); - const ESM::BodyPart *arm = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "upper arm"); - const ESM::BodyPart *neck = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "neck"); - const ESM::BodyPart *knee = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "knee"); - const ESM::BodyPart *ankle = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "ankle"); - const ESM::BodyPart *foot = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "foot"); - const ESM::BodyPart *feet = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "feet"); - const ESM::BodyPart *tail = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "tail"); - const ESM::BodyPart *wrist = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "wrist"); - const ESM::BodyPart *forearm = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "forearm"); - const ESM::BodyPart *hand = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "hand.1st"); - const ESM::BodyPart *hands = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "hands.1st"); + const ESM::BodyPart *upperleg = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "upper leg"); + const ESM::BodyPart *groin = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "groin"); + const ESM::BodyPart *arm = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "upper arm"); + const ESM::BodyPart *neck = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "neck"); + const ESM::BodyPart *knee = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "knee"); + const ESM::BodyPart *ankle = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "ankle"); + const ESM::BodyPart *foot = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "foot"); + const ESM::BodyPart *feet = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "feet"); + const ESM::BodyPart *tail = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "tail"); + const ESM::BodyPart *wrist = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "wrist"); + const ESM::BodyPart *forearm = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "forearm"); + const ESM::BodyPart *hand = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "hand.1st"); + const ESM::BodyPart *hands = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "hands.1st"); - //std::cout << "RACE" << bodyRaceID << "\n"; + //std::cout << "RACE" << bodyRaceID << "\n"; - Ogre::Vector3 pos2 = Ogre::Vector3( 0, .5, 75); - std::string upperarmpath[2] = {npcName + "chest", npcName + "upper arm"}; - + Ogre::Vector3 pos2 = Ogre::Vector3( 0, .5, 75); + std::string upperarmpath[2] = {npcName + "chest", npcName + "upper arm"}; + if (groin){ cellRender.insertMesh("meshes\\" + groin->model, pos2, axis, Ogre::Radian(3.14), npcName + "groin", addresses, numbers); - addresses2[numbers] = npcName + "groin"; - addresses[numbers++] = npcName + "groin"; - } - if (tail) { - cellRender.insertMesh("tail\\" + tail->model, Ogre::Vector3(0 , 0, -76), axis, Ogre::Radian(3.14), npcName + "tail", addresses, numbers, "tail"); - //std::cout << "TAIL\n"; - } - - //addresses[1] = npcName + "groin"; - if(upperleg){ - cellRender.insertMesh ("meshes\\" + upperleg->model, Ogre::Vector3( 6, 0, -16), axis, Ogre::Radian(3.14), npcName + "upper leg", addresses, numbers); //-18 - cellRender.insertMesh ("meshes\\" + upperleg->model, Ogre::Vector3( -6, 0, -16), axis, Ogre::Radian(0), npcName + "upper leg2", addresses2, numbers); - addresses2[numbers] = npcName + "upper leg2"; - addresses[numbers++] = npcName + "upper leg"; - cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), addresses, numbers); - } - if(knee) - { - cellRender.insertMesh ("meshes\\" + knee->model, Ogre::Vector3( 0, -1, -23), axis, Ogre::Radian(0), npcName + "knee", addresses, numbers); - //cellRender.rotateMesh(Ogre::Vector3(0, 1, 0), Ogre::Radian (1), npcName + "upper arm"); - cellRender.insertMesh ("meshes\\" + knee->model, Ogre::Vector3( 0, -1, -23), axis, Ogre::Radian(0), npcName + "knee2", addresses2, numbers); - - addresses2[numbers] = npcName + "knee2"; - addresses[numbers++] = npcName + "knee"; - } - if(ankle){ - - cellRender.insertMesh ("meshes\\" + ankle->model, Ogre::Vector3( 0, 0, -20), axis, Ogre::Radian(0), npcName + "ankle", addresses, numbers); //-1 - cellRender.insertMesh ("meshes\\" + ankle->model, Ogre::Vector3( 0,0, -20), axis, Ogre::Radian(0), npcName + "ankle2", addresses2, numbers); //-1 - - addresses2[numbers] = npcName + "ankle2"; - addresses[numbers++] = npcName + "ankle"; - } - if(foot){ - if(bodyRaceID.compare("b_n_khajiit_m_") == 0) - { - feet = foot; - } - else - { - cellRender.insertMesh ("meshes\\" + foot->model, Ogre::Vector3( 0, -4, -15), axis, Ogre::Radian(0), npcName + "foot", addresses, numbers); + addresses2[numbers] = npcName + "groin"; + addresses[numbers++] = npcName + "groin"; + } + if (tail) { + cellRender.insertMesh("tail\\" + tail->model, Ogre::Vector3(0 , 0, -76), axis, Ogre::Radian(3.14), npcName + "tail", addresses, numbers, "tail"); + //std::cout << "TAIL\n"; + } + + //addresses[1] = npcName + "groin"; + if(upperleg){ + cellRender.insertMesh ("meshes\\" + upperleg->model, Ogre::Vector3( 6, 0, -16), axis, Ogre::Radian(3.14), npcName + "upper leg", addresses, numbers); //-18 + cellRender.insertMesh ("meshes\\" + upperleg->model, Ogre::Vector3( -6, 0, -16), axis, Ogre::Radian(0), npcName + "upper leg2", addresses2, numbers); + addresses2[numbers] = npcName + "upper leg2"; + addresses[numbers++] = npcName + "upper leg"; + cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), addresses, numbers); + } + if(knee) + { + cellRender.insertMesh ("meshes\\" + knee->model, Ogre::Vector3( 0, -1, -23), axis, Ogre::Radian(0), npcName + "knee", addresses, numbers); + //cellRender.rotateMesh(Ogre::Vector3(0, 1, 0), Ogre::Radian (1), npcName + "upper arm"); + cellRender.insertMesh ("meshes\\" + knee->model, Ogre::Vector3( 0, -1, -23), axis, Ogre::Radian(0), npcName + "knee2", addresses2, numbers); + + addresses2[numbers] = npcName + "knee2"; + addresses[numbers++] = npcName + "knee"; + } + if(ankle){ + + cellRender.insertMesh ("meshes\\" + ankle->model, Ogre::Vector3( 0, 0, -20), axis, Ogre::Radian(0), npcName + "ankle", addresses, numbers); //-1 + cellRender.insertMesh ("meshes\\" + ankle->model, Ogre::Vector3( 0,0, -20), axis, Ogre::Radian(0), npcName + "ankle2", addresses2, numbers); //-1 + + addresses2[numbers] = npcName + "ankle2"; + addresses[numbers++] = npcName + "ankle"; + } + if(foot){ + if(bodyRaceID.compare("b_n_khajiit_m_") == 0) + { + feet = foot; + } + else + { + cellRender.insertMesh ("meshes\\" + foot->model, Ogre::Vector3( 0, -4, -15), axis, Ogre::Radian(0), npcName + "foot", addresses, numbers); - cellRender.insertMesh ("meshes\\" + foot->model, Ogre::Vector3( 0, -4, -15), axis, Ogre::Radian(0), npcName + "foot2", addresses2, numbers); - addresses2[numbers] = npcName + "foot2"; - addresses[numbers++] = npcName + "foot"; - } - //cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), addresses, numbers); - } - if(feet){ - - cellRender.insertMesh ("foot\\" + feet->model, Ogre::Vector3( 7, 4, -16), axis, Ogre::Radian(3.14), npcName + "foot", addresses, numbers); //9, 0, -14 + cellRender.insertMesh ("meshes\\" + foot->model, Ogre::Vector3( 0, -4, -15), axis, Ogre::Radian(0), npcName + "foot2", addresses2, numbers); + addresses2[numbers] = npcName + "foot2"; + addresses[numbers++] = npcName + "foot"; + } + //cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), addresses, numbers); + } + if(feet){ + + cellRender.insertMesh ("foot\\" + feet->model, Ogre::Vector3( 7, 4, -16), axis, Ogre::Radian(3.14), npcName + "foot", addresses, numbers); //9, 0, -14 - cellRender.insertMesh ("foot\\" + feet->model, Ogre::Vector3( 7, 4, -16), axis, Ogre::Radian(3.14), npcName + "foot2", addresses2, numbers); - addresses2[numbers] = npcName + "foot2"; - addresses[numbers++] = npcName + "foot"; - //cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), addresses, numbers); - } - - - if (arm){ - //010 - cellRender.insertMesh("meshes\\" + arm->model, Ogre::Vector3(-12.5, 0, 104), Ogre::Vector3(0, 1, 0), Ogre::Radian(-3.14 / 2), npcName + "upper arm", upperleft, uppernumbers); //1, 0,.75 - //cellRender.rotateMesh(Ogre::Vector3(1, 0, 0), Ogre::Radian (.45), upperarmpath, 2); //-.5, 0, -.75 - cellRender.insertMesh("meshes\\" + arm->model, Ogre::Vector3(12.5, 0, 105), Ogre::Vector3(-.5, 0, -.75), Ogre::Radian(3.14), npcName + "upper arm2", upperright, uppernumbers); - upperleft[uppernumbers] = npcName + "upper arm"; - upperright[uppernumbers++] = npcName + "upper arm2"; - cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperleft, uppernumbers); //1 -1 1 - cellRender.rotateMesh(Ogre::Vector3(0, .1, 0), Ogre::Radian(3.14/2), upperleft, uppernumbers); - } + cellRender.insertMesh ("foot\\" + feet->model, Ogre::Vector3( 7, 4, -16), axis, Ogre::Radian(3.14), npcName + "foot2", addresses2, numbers); + addresses2[numbers] = npcName + "foot2"; + addresses[numbers++] = npcName + "foot"; + //cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), addresses, numbers); + } + + + if (arm){ + //010 + cellRender.insertMesh("meshes\\" + arm->model, Ogre::Vector3(-12.5, 0, 104), Ogre::Vector3(0, 1, 0), Ogre::Radian(-3.14 / 2), npcName + "upper arm", upperleft, uppernumbers); //1, 0,.75 + //cellRender.rotateMesh(Ogre::Vector3(1, 0, 0), Ogre::Radian (.45), upperarmpath, 2); //-.5, 0, -.75 + cellRender.insertMesh("meshes\\" + arm->model, Ogre::Vector3(12.5, 0, 105), Ogre::Vector3(-.5, 0, -.75), Ogre::Radian(3.14), npcName + "upper arm2", upperright, uppernumbers); + upperleft[uppernumbers] = npcName + "upper arm"; + upperright[uppernumbers++] = npcName + "upper arm2"; + cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperleft, uppernumbers); //1 -1 1 + cellRender.rotateMesh(Ogre::Vector3(0, .1, 0), Ogre::Radian(3.14/2), upperleft, uppernumbers); + } - if (forearm) - { - //addresses[1] = npcName + "upper arm"; - cellRender.insertMesh("meshes\\" + forearm->model, Ogre::Vector3(-12.5, 0, 0), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "forearm", upperleft, uppernumbers); - cellRender.insertMesh("meshes\\" + forearm->model, Ogre::Vector3(-12.5, 0, 0), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "forearm2", upperright, uppernumbers); - upperleft[uppernumbers] = npcName + "forearm"; - upperright[uppernumbers++] = npcName + "forearm2"; - } - //else - // std::cout << npcName << "has no forearm"; - if (wrist) - { - if(upperleft[uppernumbers - 1].compare(npcName + "upper arm") == 0) - { - cellRender.insertMesh("meshes\\b\\B_N_Argonian_M_Forearm.nif", Ogre::Vector3(-12.5, 0, 0), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "forearm", upperleft, uppernumbers); - cellRender.insertMesh("meshes\\b\\B_N_Argonian_M_Forearm.nif", Ogre::Vector3(-12.5, 0, 0), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "forearm2", upperright, uppernumbers); - upperleft[uppernumbers] = npcName + "forearm"; - upperright[uppernumbers++] = npcName + "forearm2"; + if (forearm) + { + //addresses[1] = npcName + "upper arm"; + cellRender.insertMesh("meshes\\" + forearm->model, Ogre::Vector3(-12.5, 0, 0), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "forearm", upperleft, uppernumbers); + cellRender.insertMesh("meshes\\" + forearm->model, Ogre::Vector3(-12.5, 0, 0), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "forearm2", upperright, uppernumbers); + upperleft[uppernumbers] = npcName + "forearm"; + upperright[uppernumbers++] = npcName + "forearm2"; + } + //else + // std::cout << npcName << "has no forearm"; + if (wrist) + { + if(upperleft[uppernumbers - 1].compare(npcName + "upper arm") == 0) + { + cellRender.insertMesh("meshes\\b\\B_N_Argonian_M_Forearm.nif", Ogre::Vector3(-12.5, 0, 0), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "forearm", upperleft, uppernumbers); + cellRender.insertMesh("meshes\\b\\B_N_Argonian_M_Forearm.nif", Ogre::Vector3(-12.5, 0, 0), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "forearm2", upperright, uppernumbers); + upperleft[uppernumbers] = npcName + "forearm"; + upperright[uppernumbers++] = npcName + "forearm2"; - } - cellRender.insertMesh("meshes\\" + wrist->model, Ogre::Vector3(-9.5, 0, 0), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "wrist", upperleft, uppernumbers); - cellRender.insertMesh("meshes\\" + wrist->model, Ogre::Vector3(-9.5, 0, 0), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "wrist2", upperright, uppernumbers); - upperleft[uppernumbers] = npcName + "wrist"; - upperright[uppernumbers++] = npcName + "wrist2"; - } - + } + cellRender.insertMesh("meshes\\" + wrist->model, Ogre::Vector3(-9.5, 0, 0), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "wrist", upperleft, uppernumbers); + cellRender.insertMesh("meshes\\" + wrist->model, Ogre::Vector3(-9.5, 0, 0), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "wrist2", upperright, uppernumbers); + upperleft[uppernumbers] = npcName + "wrist"; + upperright[uppernumbers++] = npcName + "wrist2"; + } + - if(hand) - { - //std::cout << "WE FOUND A HAND\n"; - //-50, 0, -120 - //std::cout << "WE FOUND HANDS\n"; - std::string pass; - if(hand->model.compare("b\\B_N_Dark Elf_F_Hands.1st.NIF")==0 && bodyRaceID.compare("b_n_dark elf_m_") == 0) - pass = "b\\B_N_Dark Elf_M_Hands.1st.NIF"; - else - pass = hand->model; - cellRender.insertMesh("meshes\\" + pass, Ogre::Vector3(42, 1, -110), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "hand", upperleft, uppernumbers,false); //0, 100, -100 0,0,120 - cellRender.insertMesh("meshes\\" + pass, Ogre::Vector3(42, 1, -110), Ogre::Vector3(0, 0,0), Ogre::Radian(3.14), npcName + "hand2", upperright, uppernumbers, false); //0, 100, -100 0,0,120 - upperleft[uppernumbers] = npcName + "hand"; - upperright[uppernumbers++] = npcName + "hand2"; - //cellRender.rotateMesh(Ogre::Vector3(0, 0,0), Ogre::Radian(3.14), upperleft, uppernumbers); - cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperleft, uppernumbers); - cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperright, uppernumbers); - } - if(hands) - { - std::string pass; - if(hands->model.compare("b\\B_N_Redguard_F_Hands.1st.nif")==0 && bodyRaceID.compare("b_n_redguard_m_") == 0) - pass = "b\\B_N_Redguard_M_Hands.1st.nif"; - else if(hands->model.compare("b\\B_N_Imperial_M_Hands.1st.nif") == 0 && bodyRaceID.compare("b_n_nord_m_") == 0) - pass = "b\\B_N_Nord_M_Hands.1st.nif"; - else - pass =hands->model; //-50, 0, -120 - cellRender.insertMesh("meshes\\" + pass, Ogre::Vector3(42, 1,-110), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "hand", upperleft, uppernumbers, false); //0, 100, -100 42, 0, -110 - //cellRender.insertMesh("meshes\\" + hands->model, Ogre::Vector3(42, 0,110), Ogre::Vector3(1, 0, 0), Ogre::Radian(3.14), npcName + "hand", upperleft, uppernumbers, false); //0, 100, -100 42, 0, -110 - cellRender.insertMesh("meshes\\" + pass, Ogre::Vector3(42, 1, -110), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "hand2", upperright, uppernumbers, false); //0, 100, -100 0,0,120 - upperleft[uppernumbers] = npcName + "hand"; - upperright[uppernumbers++] = npcName + "hand2"; - cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperleft, uppernumbers); - cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperright, uppernumbers); - } + if(hand) + { + //std::cout << "WE FOUND A HAND\n"; + //-50, 0, -120 + //std::cout << "WE FOUND HANDS\n"; + std::string pass; + if(hand->model.compare("b\\B_N_Dark Elf_F_Hands.1st.NIF")==0 && bodyRaceID.compare("b_n_dark elf_m_") == 0) + pass = "b\\B_N_Dark Elf_M_Hands.1st.NIF"; + else + pass = hand->model; + cellRender.insertMesh("meshes\\" + pass, Ogre::Vector3(42, 1, -110), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "hand", upperleft, uppernumbers,false); //0, 100, -100 0,0,120 + cellRender.insertMesh("meshes\\" + pass, Ogre::Vector3(42, 1, -110), Ogre::Vector3(0, 0,0), Ogre::Radian(3.14), npcName + "hand2", upperright, uppernumbers, false); //0, 100, -100 0,0,120 + upperleft[uppernumbers] = npcName + "hand"; + upperright[uppernumbers++] = npcName + "hand2"; + //cellRender.rotateMesh(Ogre::Vector3(0, 0,0), Ogre::Radian(3.14), upperleft, uppernumbers); + cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperleft, uppernumbers); + cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperright, uppernumbers); + } + if(hands) + { + std::string pass; + if(hands->model.compare("b\\B_N_Redguard_F_Hands.1st.nif")==0 && bodyRaceID.compare("b_n_redguard_m_") == 0) + pass = "b\\B_N_Redguard_M_Hands.1st.nif"; + else if(hands->model.compare("b\\B_N_Imperial_M_Hands.1st.nif") == 0 && bodyRaceID.compare("b_n_nord_m_") == 0) + pass = "b\\B_N_Nord_M_Hands.1st.nif"; + else + pass =hands->model; //-50, 0, -120 + cellRender.insertMesh("meshes\\" + pass, Ogre::Vector3(42, 1,-110), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "hand", upperleft, uppernumbers, false); //0, 100, -100 42, 0, -110 + //cellRender.insertMesh("meshes\\" + hands->model, Ogre::Vector3(42, 0,110), Ogre::Vector3(1, 0, 0), Ogre::Radian(3.14), npcName + "hand", upperleft, uppernumbers, false); //0, 100, -100 42, 0, -110 + cellRender.insertMesh("meshes\\" + pass, Ogre::Vector3(42, 1, -110), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "hand2", upperright, uppernumbers, false); //0, 100, -100 0,0,120 + upperleft[uppernumbers] = npcName + "hand"; + upperright[uppernumbers++] = npcName + "hand2"; + cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperleft, uppernumbers); + cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperright, uppernumbers); + } - //neck will reset chest counter - if(neck) - { - cellRender.insertMesh ("meshes\\" + neck->model, Ogre::Vector3( 0, 0, 120), axis, Ogre::Radian(3.14), npcName + "neck", neckandup, neckNumbers); - neckandup[neckNumbers++] = npcName + "neck"; - } - cellRender.insertMesh (headModel, Ogre::Vector3( 0, 0, 5), axis, Ogre::Radian(0), npcName + "head", neckandup, neckNumbers); - neckandup[neckNumbers++] = npcName + "head"; - cellRender.insertMesh (hairModel, Ogre::Vector3( 0, -1, 0), axis, Ogre::Radian(0), npcName + "hair", neckandup, neckNumbers); - ref->mData.setHandle (rendering.end (ref->mData.isEnabled())); - - } + //neck will reset chest counter + if(neck) + { + cellRender.insertMesh ("meshes\\" + neck->model, Ogre::Vector3( 0, 0, 120), axis, Ogre::Radian(3.14), npcName + "neck", neckandup, neckNumbers); + neckandup[neckNumbers++] = npcName + "neck"; + } + cellRender.insertMesh (headModel, Ogre::Vector3( 0, 0, 5), axis, Ogre::Radian(0), npcName + "head", neckandup, neckNumbers); + neckandup[neckNumbers++] = npcName + "head"; + cellRender.insertMesh (hairModel, Ogre::Vector3( 0, -1, 0), axis, Ogre::Radian(0), npcName + "hair", neckandup, neckNumbers); + ref->mData.setHandle (rendering.end (ref->mData.isEnabled())); + + } void Npc::enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const { diff --git a/apps/openmw/mwclass/npc.hpp b/apps/openmw/mwclass/npc.hpp index 946c307334..e54c35ad88 100644 --- a/apps/openmw/mwclass/npc.hpp +++ b/apps/openmw/mwclass/npc.hpp @@ -8,7 +8,7 @@ namespace MWClass class Npc : public MWWorld::Class { public: - + virtual std::string getId (const MWWorld::Ptr& ptr) const; ///< Return ID of \a ptr diff --git a/apps/openmw/mwgui/widgets.cpp b/apps/openmw/mwgui/widgets.cpp index e4819c80c1..7f23ff34e2 100644 --- a/apps/openmw/mwgui/widgets.cpp +++ b/apps/openmw/mwgui/widgets.cpp @@ -89,53 +89,53 @@ void MWSkill::onClicked(MyGUI::Widget* _sender) void MWSkill::_initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, Widget* _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string& _name) { - Base::_initialise(_style, _coord, _align, _info, _parent, _croppedParent, _creator, _name); + Base::_initialise(_style, _coord, _align, _info, _parent, _croppedParent, _creator, _name); - initialiseWidgetSkin(_info); + initialiseWidgetSkin(_info); } MWSkill::~MWSkill() { - shutdownWidgetSkin(); + shutdownWidgetSkin(); } void MWSkill::baseChangeWidgetSkin(ResourceSkin* _info) { - shutdownWidgetSkin(); - Base::baseChangeWidgetSkin(_info); - initialiseWidgetSkin(_info); + shutdownWidgetSkin(); + Base::baseChangeWidgetSkin(_info); + initialiseWidgetSkin(_info); } void MWSkill::initialiseWidgetSkin(ResourceSkin* _info) { for (VectorWidgetPtr::iterator iter=mWidgetChildSkin.begin(); iter!=mWidgetChildSkin.end(); ++iter) - { + { const std::string &name = *(*iter)->_getInternalData(); - if (name == "StatName") - { - MYGUI_DEBUG_ASSERT( ! skillNameWidget, "widget already assigned"); - skillNameWidget = (*iter)->castType(); - } - else if (name == "StatValue") - { - MYGUI_DEBUG_ASSERT( ! skillValueWidget, "widget already assigned"); - skillValueWidget = (*iter)->castType(); - } - else if (name == "StatNameButton") - { - MYGUI_DEBUG_ASSERT( ! skillNameWidget, "widget already assigned"); + if (name == "StatName") + { + MYGUI_DEBUG_ASSERT( ! skillNameWidget, "widget already assigned"); + skillNameWidget = (*iter)->castType(); + } + else if (name == "StatValue") + { + MYGUI_DEBUG_ASSERT( ! skillValueWidget, "widget already assigned"); + skillValueWidget = (*iter)->castType(); + } + else if (name == "StatNameButton") + { + MYGUI_DEBUG_ASSERT( ! skillNameWidget, "widget already assigned"); MyGUI::ButtonPtr button = (*iter)->castType