forked from teamnwah/openmw-tes3coop
Merge branch 'master' into exterior
Conflicts: apps/openmw/mwscript/docs/vmformat.txtactorid
commit
1dc805d0d4
@ -1,2 +1,4 @@
|
||||
build
|
||||
*~
|
||||
Doxygen
|
||||
prebuilt
|
@ -0,0 +1,215 @@
|
||||
|
||||
#include "aiextensions.hpp"
|
||||
|
||||
#include <components/compiler/extensions.hpp>
|
||||
|
||||
#include <components/interpreter/interpreter.hpp>
|
||||
#include <components/interpreter/runtime.hpp>
|
||||
#include <components/interpreter/opcodes.hpp>
|
||||
|
||||
#include "interpretercontext.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace MWScript
|
||||
{
|
||||
namespace Ai
|
||||
{
|
||||
class OpAiTravel : public Interpreter::Opcode1
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
|
||||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (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<arg0; ++i) runtime.pop();
|
||||
|
||||
std::cout << "AiTravel: " << x << ", " << y << ", " << z << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
class OpAiTravelExplicit : public Interpreter::Opcode1
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
|
||||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
||||
|
||||
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<arg0; ++i) runtime.pop();
|
||||
|
||||
std::cout << "AiTravel: " << x << ", " << y << ", " << z << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
class OpAiEscort : public Interpreter::Opcode1
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
|
||||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (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<arg0; ++i) runtime.pop();
|
||||
|
||||
std::cout << "AiEscort: " << x << ", " << y << ", " << z << ", " << duration
|
||||
<< std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
class OpAiEscortExplicit : public Interpreter::Opcode1
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
|
||||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
||||
|
||||
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<arg0; ++i) runtime.pop();
|
||||
|
||||
std::cout << "AiEscort: " << x << ", " << y << ", " << z << ", " << duration
|
||||
<< std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
class OpGetAiPackageDone : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
MWWorld::Ptr ptr = context.getReference();
|
||||
|
||||
Interpreter::Type_Integer value = 0;
|
||||
|
||||
runtime.push (value);
|
||||
}
|
||||
};
|
||||
|
||||
class OpGetAiPackageDoneExplicit : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (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;
|
||||
const int opcodeAiTravelExplicit = 0x20001;
|
||||
const int opcodeAiEscort = 0x20002;
|
||||
const int opcodeAiEscortExplicit = 0x20003;
|
||||
const int opcodeGetAiPackageDone = 0x200007c;
|
||||
const int opcodeGetAiPackageDoneExplicit = 0x200007d;
|
||||
|
||||
void registerExtensions (Compiler::Extensions& extensions)
|
||||
{
|
||||
extensions.registerInstruction ("aitravel", "lll/l", opcodeAiTravel,
|
||||
opcodeAiTravelExplicit);
|
||||
extensions.registerInstruction ("aiescort", "cllll/l", opcodeAiEscort,
|
||||
opcodeAiEscortExplicit);
|
||||
|
||||
extensions.registerFunction ("getaipackagedone", 'l', "", opcodeGetAiPackageDone,
|
||||
opcodeGetAiPackageDoneExplicit);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
#ifndef GAME_SCRIPT_AIEXTENSIONS_H
|
||||
#define GAME_SCRIPT_AIEXTENSIONS_H
|
||||
|
||||
namespace Compiler
|
||||
{
|
||||
class Extensions;
|
||||
}
|
||||
|
||||
namespace Interpreter
|
||||
{
|
||||
class Interpreter;
|
||||
}
|
||||
|
||||
namespace MWScript
|
||||
{
|
||||
/// \brief AI-related script functionality
|
||||
namespace Ai
|
||||
{
|
||||
void registerExtensions (Compiler::Extensions& extensions);
|
||||
|
||||
void installOpcodes (Interpreter::Interpreter& interpreter);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,70 @@
|
||||
|
||||
#include "statsextensions.hpp"
|
||||
|
||||
#include <components/compiler/extensions.hpp>
|
||||
|
||||
#include <components/interpreter/interpreter.hpp>
|
||||
#include <components/interpreter/runtime.hpp>
|
||||
#include <components/interpreter/opcodes.hpp>
|
||||
|
||||
#include "interpretercontext.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace MWScript
|
||||
{
|
||||
namespace Control
|
||||
{
|
||||
class OpSetControl : public Interpreter::Opcode0
|
||||
{
|
||||
std::string mControl;
|
||||
bool mEnable;
|
||||
|
||||
public:
|
||||
|
||||
OpSetControl (const std::string& control, bool enable)
|
||||
: mControl (control), mEnable (enable)
|
||||
{}
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
if (mEnable)
|
||||
std::cout << "enable: " << mControl << std::endl;
|
||||
else
|
||||
std::cout << "disable: " << mControl << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
const int numberOfControls = 7;
|
||||
|
||||
const int opcodeEnable = 0x200007e;
|
||||
const int opcodeDisable = 0x2000085;
|
||||
|
||||
const char *controls[numberOfControls] =
|
||||
{
|
||||
"playercontrols", "playerfighting", "playerjumping", "playerlooking", "playermagic",
|
||||
"playerviewswitch", "vanitymode"
|
||||
};
|
||||
|
||||
void registerExtensions (Compiler::Extensions& extensions)
|
||||
{
|
||||
std::string enable ("enable");
|
||||
std::string disable ("disable");
|
||||
|
||||
for (int i=0; i<numberOfControls; ++i)
|
||||
{
|
||||
extensions.registerInstruction (enable + controls[i], "", opcodeEnable+i);
|
||||
extensions.registerInstruction (disable + controls[i], "", opcodeDisable+i);
|
||||
}
|
||||
}
|
||||
|
||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||
{
|
||||
for (int i=0; i<numberOfControls; ++i)
|
||||
{
|
||||
interpreter.installSegment5 (opcodeEnable+i, new OpSetControl (controls[i], true));
|
||||
interpreter.installSegment5 (opcodeDisable+i, new OpSetControl (controls[i], false));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
#ifndef GAME_SCRIPT_CONTROLEXTENSIONS_H
|
||||
#define GAME_SCRIPT_CONTROLEXTENSIONS_H
|
||||
|
||||
namespace Compiler
|
||||
{
|
||||
class Extensions;
|
||||
}
|
||||
|
||||
namespace Interpreter
|
||||
{
|
||||
class Interpreter;
|
||||
}
|
||||
|
||||
namespace MWScript
|
||||
{
|
||||
/// \brief player controls-related script functionality
|
||||
namespace Control
|
||||
{
|
||||
void registerExtensions (Compiler::Extensions& extensions);
|
||||
|
||||
void installOpcodes (Interpreter::Interpreter& interpreter);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -1 +1 @@
|
||||
Subproject commit 3324f6494c021e3dc69cd76ace5ff25a52e4bcce
|
||||
Subproject commit b08c2f78dc24f05f67a998114880200518602690
|
@ -1 +1 @@
|
||||
Subproject commit 2e2f8e9725fd1a27a82d0ad5c6c0e296e715eb60
|
||||
Subproject commit 377e7d71ceea5a1ca166b8df9a03a5b68df83bc5
|
@ -0,0 +1,14 @@
|
||||
// Wrapper for string.h on Mac
|
||||
#ifndef _STRING_WRAPPER_H
|
||||
#define _STRING_WRAPPER_H
|
||||
|
||||
#include <string.h>
|
||||
#ifdef __APPLE__
|
||||
// need our own implementation of strnlen
|
||||
static size_t strnlen(const char *s, size_t n)
|
||||
{
|
||||
const char *p = (const char *)memchr(s, 0, n);
|
||||
return(p ? p-s : n);
|
||||
}
|
||||
#endif
|
||||
#endif
|
Loading…
Reference in New Issue