feat: Initial commit for 2.0.0 release
This commit is contained in:
@@ -1,37 +0,0 @@
|
||||
|
||||
add_library(${PYG2O_MODULE_NAME} SHARED
|
||||
bind.cpp
|
||||
)
|
||||
|
||||
add_subdirectory(dependencies)
|
||||
add_subdirectory(NoNut)
|
||||
add_subdirectory(classes)
|
||||
add_subdirectory(constants)
|
||||
add_subdirectory(events)
|
||||
add_subdirectory(functions)
|
||||
add_subdirectory(types)
|
||||
|
||||
# pybind11 requires to declare all modules before interpretor initializes, so we have to load main.cpp last
|
||||
target_sources(${PYG2O_MODULE_NAME}
|
||||
PRIVATE
|
||||
main.cpp
|
||||
)
|
||||
|
||||
if(DEFINED OUT_FILE_SUFFIX)
|
||||
set_target_properties(${PYG2O_MODULE_NAME}
|
||||
PROPERTIES
|
||||
PREFIX ""
|
||||
SUFFIX ".${OUT_FILE_SUFFIX}${CMAKE_SHARED_LIBRARY_SUFFIX}"
|
||||
)
|
||||
endif()
|
||||
|
||||
# Use this code to auto copy module to your server folder for quick testing
|
||||
# Change paths to your actual paths
|
||||
|
||||
# add_custom_command(TARGET ${PYG2O_MODULE_NAME} POST_BUILD
|
||||
# COMMAND ${CMAKE_COMMAND} -E copy
|
||||
# ${CMAKE_BINARY_DIR}/source/${PYG2O_MODULE_NAME}.${OUT_FILE_SUFFIX}${CMAKE_SHARED_LIBRARY_SUFFIX}
|
||||
# C:\\server-windows-x64
|
||||
# COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||
# ${CMAKE_SOURCE_DIR}/python/g2o
|
||||
# C:\\server-windows-x64\\g2o)
|
||||
@@ -1,14 +0,0 @@
|
||||
|
||||
target_sources(${PYG2O_MODULE_NAME}
|
||||
PRIVATE
|
||||
source/Array.cpp
|
||||
source/Class.cpp
|
||||
source/Constant.cpp
|
||||
source/CustomTypes.cpp
|
||||
source/StaticClass.cpp
|
||||
)
|
||||
|
||||
target_include_directories(${PYG2O_MODULE_NAME}
|
||||
PRIVATE
|
||||
"include/"
|
||||
)
|
||||
@@ -1,21 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Martis
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -1,2 +0,0 @@
|
||||
Modified version of a C++ wrapper for the Gothic 2 Online API
|
||||
Original: https://gitlab.com/g2o/modules/dependencies/nonut
|
||||
@@ -1,51 +0,0 @@
|
||||
#ifndef NONUT_CORE_ARRAY_H
|
||||
#define NONUT_CORE_ARRAY_H
|
||||
#include "CommonHeader.h"
|
||||
|
||||
#include "Utils.h"
|
||||
#include <sqapi.h>
|
||||
|
||||
namespace nonut
|
||||
{
|
||||
class Array
|
||||
{
|
||||
public:
|
||||
explicit Array(SQObject object);
|
||||
~Array();
|
||||
|
||||
[[nodiscard]] size_t size() const;
|
||||
|
||||
template <typename T>
|
||||
T get(const String index)
|
||||
{
|
||||
HSQUIRRELVM vm = Sqrat::DefaultVM::Get();
|
||||
T result{};
|
||||
sq_pushobject(vm, object);
|
||||
sq_pushstring(vm, index.c_str(), index.length());
|
||||
|
||||
if (SQ_FAILED(sq_get(vm, -2)))
|
||||
{
|
||||
sq_pop(vm, 1);
|
||||
return result;
|
||||
}
|
||||
if constexpr (std::is_same_v<T, String>)
|
||||
{
|
||||
const SQChar* intermediateResult = nullptr;
|
||||
sq_getstring(vm, -1, &intermediateResult);
|
||||
result = intermediateResult;
|
||||
}
|
||||
else
|
||||
{
|
||||
sqGetValue(vm, -1, &result);
|
||||
}
|
||||
|
||||
sq_pop(vm, 2);
|
||||
return result;
|
||||
}
|
||||
|
||||
private:
|
||||
SQObject object;
|
||||
size_t cachedSize;
|
||||
};
|
||||
}
|
||||
#endif // NONUT_CORE_ARRAY_H
|
||||
@@ -1,32 +0,0 @@
|
||||
#ifndef NONUT_CORE_BIND_H
|
||||
#define NONUT_CORE_BIND_H
|
||||
|
||||
#include "CommonHeader.h"
|
||||
#include <vector>
|
||||
|
||||
namespace nonut
|
||||
{
|
||||
//TODO: Finish Bind and remove placeholder
|
||||
|
||||
class Bind
|
||||
{
|
||||
public:
|
||||
static void registerFunction(String funcName, const SQFUNCTION func, size_t funcSize)
|
||||
{
|
||||
HSQUIRRELVM vm = Sqrat::DefaultVM::Get();
|
||||
const auto top = sq_gettop(vm);
|
||||
sq_pushroottable(vm);
|
||||
sq_pushstring(vm, funcName.c_str(), funcName.length());
|
||||
sq_newclosure(vm, func, 0); //create a new function
|
||||
sq_newslot(vm, -3, SQFalse);
|
||||
sq_settop(vm, top);
|
||||
}
|
||||
|
||||
//template<typename F>
|
||||
//static void Function(String functionName, F& function)
|
||||
//{
|
||||
//
|
||||
//}
|
||||
};
|
||||
}
|
||||
#endif // NONUT_CORE_BIND_H
|
||||
@@ -1,45 +0,0 @@
|
||||
#ifndef NONUT_CORE_CLASS_H
|
||||
#define NONUT_CORE_CLASS_H
|
||||
#include "CommonHeader.h"
|
||||
#include <string>
|
||||
|
||||
#include "Function.h"
|
||||
// ReSharper disable once CppUnusedIncludeDirective
|
||||
#include "Property.h"
|
||||
#include "Instance.h"
|
||||
|
||||
#define METHOD_CTOR(methodName) methodName(#methodName, this->classObjectInstance, this->classObject)
|
||||
#define PROPERTY_CTOR(propertyName) propertyName(#propertyName, this->classObjectInstance)
|
||||
#define COPY_CTOR(type) type(const type& other) : type(other.getInstance()){} \
|
||||
type& operator=(const type& other) = delete
|
||||
|
||||
namespace nonut
|
||||
{
|
||||
static constexpr auto CONSTRUCTOR_NAME = "constructor";
|
||||
|
||||
class Class : public Instance
|
||||
{
|
||||
public:
|
||||
Class(const String& className, SQObject classObjectInstance = SQ_NULL);
|
||||
virtual ~Class();
|
||||
|
||||
[[nodiscard]] SQObject getInstance() const override;
|
||||
bool isNull() const;
|
||||
|
||||
protected:
|
||||
// Object holding information about class
|
||||
SQObject classObject{};
|
||||
// Class object instance
|
||||
SQObject classObjectInstance{};
|
||||
|
||||
template <typename... Args>
|
||||
void classCtor(Args ... args)
|
||||
{
|
||||
Function<void, Args...> ctor(CONSTRUCTOR_NAME, classObjectInstance, classObject);
|
||||
ctor(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
bool bIsNull = false;
|
||||
};
|
||||
}
|
||||
#endif // NONUT_CORE_CLASS_H
|
||||
@@ -1,18 +0,0 @@
|
||||
#ifndef CORE_COMMONHEADER_H_
|
||||
#define CORE_COMMONHEADER_H_
|
||||
|
||||
#include "sqrat.h"
|
||||
|
||||
namespace nonut
|
||||
{
|
||||
using Int = SQInteger;
|
||||
using UInt = SQUnsignedInteger;
|
||||
using UInt32 = SQUnsignedInteger32;
|
||||
using Float = SQFloat;
|
||||
using Bool = SQBool;
|
||||
using String = std::string;
|
||||
|
||||
constexpr SQObject SQ_NULL{ OT_NULL };
|
||||
}
|
||||
|
||||
#endif // CORE_COMMONHEADER_H_
|
||||
@@ -1,10 +0,0 @@
|
||||
#ifndef NONUT_CORE_CONSTANT_H
|
||||
#define NONUT_CORE_CONSTANT_H
|
||||
#include "CommonHeader.h"
|
||||
#include <sqapi.h>
|
||||
|
||||
namespace nonut
|
||||
{
|
||||
SQObject getConstTable();
|
||||
};
|
||||
#endif // NONUT_CORE_CONSTANT_H
|
||||
@@ -1,182 +0,0 @@
|
||||
#ifndef NONUT_G2O_SHARED_CUSTOM_TYPES_H
|
||||
#define NONUT_G2O_SHARED_CUSTOM_TYPES_H
|
||||
|
||||
#include <string>
|
||||
#include <pybind11/embed.h>
|
||||
#include "Utils.h"
|
||||
|
||||
namespace py = pybind11;
|
||||
|
||||
namespace nonut
|
||||
{
|
||||
struct GameTime : CustomType
|
||||
{
|
||||
void convert(SQObject object) override;
|
||||
Int day{};
|
||||
Int hour{};
|
||||
Int min{};
|
||||
|
||||
auto toTuple()
|
||||
{
|
||||
return std::make_tuple(day, hour, min);
|
||||
}
|
||||
};
|
||||
|
||||
struct Position2d : CustomType
|
||||
{
|
||||
void convert(SQObject object) override;
|
||||
Int x{};
|
||||
Int y{};
|
||||
auto toTuple()
|
||||
{
|
||||
return std::make_tuple(x, y);
|
||||
}
|
||||
};
|
||||
|
||||
struct Position3d : CustomType
|
||||
{
|
||||
void convert(SQObject object) override;
|
||||
Float x{};
|
||||
Float y{};
|
||||
Float z{};
|
||||
auto toTuple()
|
||||
{
|
||||
return std::make_tuple(x, y, z);
|
||||
}
|
||||
};
|
||||
|
||||
struct Size2d : CustomType
|
||||
{
|
||||
void convert(SQObject object) override;
|
||||
Int width{};
|
||||
Int height{};
|
||||
auto toTuple()
|
||||
{
|
||||
return std::make_tuple(width, height);
|
||||
}
|
||||
};
|
||||
|
||||
struct Rect : CustomType
|
||||
{
|
||||
void convert(SQObject object) override;
|
||||
Int x;
|
||||
Int y;
|
||||
Int width;
|
||||
Int height;
|
||||
auto toTuple()
|
||||
{
|
||||
return std::make_tuple(x, y, width, height);
|
||||
}
|
||||
};
|
||||
|
||||
struct UV : CustomType
|
||||
{
|
||||
void convert(SQObject object) override;
|
||||
Float x;
|
||||
Float y;
|
||||
Float width;
|
||||
Float height;
|
||||
auto toTuple()
|
||||
{
|
||||
return std::make_tuple(x, y, width, height);
|
||||
}
|
||||
};
|
||||
|
||||
struct Resolution : CustomType
|
||||
{
|
||||
void convert(SQObject object) override;
|
||||
Int x{};
|
||||
Int y{};
|
||||
Int bpp{};
|
||||
auto toTuple()
|
||||
{
|
||||
return std::make_tuple(x, y, bpp);
|
||||
}
|
||||
};
|
||||
|
||||
struct Item : CustomType
|
||||
{
|
||||
void convert(SQObject object) override;
|
||||
Int instance{};
|
||||
Int amount{};
|
||||
String name{};
|
||||
auto toTuple()
|
||||
{
|
||||
return std::make_tuple(instance, amount, name);
|
||||
}
|
||||
};
|
||||
|
||||
struct Color : CustomType
|
||||
{
|
||||
void convert(SQObject object) override;
|
||||
Int r{};
|
||||
Int g{};
|
||||
Int b{};
|
||||
auto toTuple()
|
||||
{
|
||||
return std::make_tuple(r, g, b);
|
||||
}
|
||||
};
|
||||
|
||||
struct BodyVisual : CustomType
|
||||
{
|
||||
void convert(SQObject object) override;
|
||||
String bodyModel{};
|
||||
Int bodyTxt{};
|
||||
String headModel{};
|
||||
Int headTxt{};
|
||||
auto toTuple()
|
||||
{
|
||||
return std::make_tuple(bodyModel, bodyTxt, headModel, headTxt);
|
||||
}
|
||||
};
|
||||
|
||||
struct NetworkStats : CustomType
|
||||
{
|
||||
void convert(SQObject object) override;
|
||||
Int packetReceived{};
|
||||
Int packetlossTotal{};
|
||||
Int packetlossLastSecond{};
|
||||
Int messagesInResendBuffer{};
|
||||
Int messageInSendBuffer{};
|
||||
Int bytesInResendBuffer{};
|
||||
Int bytesInSendBuffer{};
|
||||
auto toTuple()
|
||||
{
|
||||
return std::make_tuple(
|
||||
packetReceived,
|
||||
packetlossTotal,
|
||||
packetlossLastSecond,
|
||||
messagesInResendBuffer,
|
||||
messageInSendBuffer,
|
||||
bytesInResendBuffer,
|
||||
bytesInSendBuffer);
|
||||
}
|
||||
};
|
||||
|
||||
struct Position3dWithName : CustomType
|
||||
{
|
||||
void convert(SQObject object) override;
|
||||
String name{};
|
||||
Float x{};
|
||||
Float y{};
|
||||
Float z{};
|
||||
auto toTuple()
|
||||
{
|
||||
return std::make_tuple(name, x, y, z);
|
||||
}
|
||||
};
|
||||
|
||||
struct SqDict : CustomType
|
||||
{
|
||||
void convert(SQObject object) override;
|
||||
py::dict data{};
|
||||
};
|
||||
|
||||
struct SqList : CustomType
|
||||
{
|
||||
void convert(SQObject object) override;
|
||||
py::list data{};
|
||||
};
|
||||
}
|
||||
#endif // NONUT_G2O_SHARED_CUSTOM_TYPES_H
|
||||
@@ -1,166 +0,0 @@
|
||||
#ifndef NONUT_CORE_FUNCTION_H
|
||||
#define NONUT_CORE_FUNCTION_H
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
#include <sqapi.h>
|
||||
#include "Utils.h"
|
||||
|
||||
#define FUNCTION_CTOR(function) function(#function)
|
||||
|
||||
namespace nonut
|
||||
{
|
||||
class Class;
|
||||
|
||||
template <typename ReturnType, typename... Args>
|
||||
class Function
|
||||
{
|
||||
public:
|
||||
// Ctor for functions
|
||||
Function(const String& functionName, const SQObject env = getRootTable()) : envObj(env)
|
||||
{
|
||||
HSQUIRRELVM vm = Sqrat::DefaultVM::Get();
|
||||
sq_pushobject(vm, envObj);
|
||||
sq_pushstring(vm, functionName.c_str(), functionName.length());
|
||||
|
||||
// get the function from the root table
|
||||
if (SQ_FAILED(sq_get(vm, -2)))
|
||||
{
|
||||
sq_pop(vm, 1);
|
||||
throw;
|
||||
}
|
||||
|
||||
// check the type
|
||||
if (const SQObjectType value_type = sq_gettype(vm, -1); value_type != OT_CLOSURE && value_type !=
|
||||
OT_NATIVECLOSURE)
|
||||
{
|
||||
sq_pop(vm, 2);
|
||||
throw;
|
||||
}
|
||||
|
||||
// get function and add ref
|
||||
sq_getstackobj(vm, -1, &funcObj);
|
||||
sq_addref(vm, &funcObj);
|
||||
|
||||
sq_pop(vm, 2);
|
||||
}
|
||||
|
||||
// Ctor for class methods
|
||||
Function(const String& functionName, const SQObject classObjectInstance,
|
||||
const SQObject classObject) : envObj(classObjectInstance)
|
||||
{
|
||||
HSQUIRRELVM vm = Sqrat::DefaultVM::Get();
|
||||
isClassMethod = true; // Prevent release of the resources cause we don't own them
|
||||
sq_pushobject(vm, classObject);
|
||||
sq_pushstring(vm, functionName.c_str(), functionName.length());
|
||||
|
||||
// get the function from the root table
|
||||
if (SQ_FAILED(sq_get(vm, -2)))
|
||||
{
|
||||
sq_pop(vm, 1);
|
||||
throw;
|
||||
}
|
||||
|
||||
// check the type
|
||||
if (const SQObjectType value_type = sq_gettype(vm, -1); value_type != OT_CLOSURE && value_type !=
|
||||
OT_NATIVECLOSURE)
|
||||
{
|
||||
sq_pop(vm, 2);
|
||||
throw;
|
||||
}
|
||||
|
||||
// get function and add ref
|
||||
sq_getstackobj(vm, -1, &funcObj);
|
||||
sq_addref(vm, &funcObj);
|
||||
|
||||
sq_pop(vm, 2);
|
||||
}
|
||||
|
||||
~Function()
|
||||
{
|
||||
if (!isClassMethod)
|
||||
{
|
||||
HSQUIRRELVM vm = Sqrat::DefaultVM::Get();
|
||||
sq_release(vm, &funcObj);
|
||||
sq_release(vm, &envObj);
|
||||
sq_resetobject(&funcObj);
|
||||
sq_resetobject(&envObj);
|
||||
}
|
||||
}
|
||||
|
||||
ReturnType operator()(Args ... args)
|
||||
{
|
||||
HSQUIRRELVM vm = Sqrat::DefaultVM::Get();
|
||||
const auto top = sq_gettop(vm);
|
||||
sq_pushobject(vm, funcObj);
|
||||
sq_pushobject(vm, envObj);
|
||||
auto debug = sq_gettop(vm);
|
||||
(sqPushValue(vm, args), ...);
|
||||
|
||||
if constexpr (std::is_same_v<ReturnType, void>)
|
||||
{
|
||||
debug = sq_gettop(vm);
|
||||
auto returnCode = sq_call(vm, ARG_COUNT + 1, SQFalse, SQFalse); // TODO: HANDLE ERROR RETURN CODE
|
||||
sq_pop(vm, 2);
|
||||
sq_settop(vm, top);
|
||||
return void();
|
||||
}
|
||||
else
|
||||
{
|
||||
auto returnCode = sq_call(vm, ARG_COUNT + 1, SQTrue, SQFalse); // TODO: HANDLE ERROR RETURN CODE
|
||||
|
||||
std::optional<ReturnType> result;
|
||||
|
||||
if constexpr (std::derived_from<ReturnType, CustomType>)
|
||||
{
|
||||
result = std::make_optional<ReturnType>();
|
||||
auto intermediateResult = returnVar<SQObject>();
|
||||
result.value().convert(intermediateResult);
|
||||
sq_release(vm, &intermediateResult);
|
||||
sq_resetobject(&intermediateResult);
|
||||
}
|
||||
else if constexpr (std::derived_from<ReturnType, Class>)
|
||||
{
|
||||
auto intermediateResult = returnVar<SQObject>();
|
||||
//result = std::make_optional<ReturnType>(ReturnType(intermediateResult));
|
||||
result.emplace(ReturnType(intermediateResult));
|
||||
|
||||
sq_release(vm, &intermediateResult);
|
||||
sq_resetobject(&intermediateResult);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = std::make_optional<ReturnType>(returnVar<ReturnType>());
|
||||
}
|
||||
|
||||
sq_pop(vm, 2);
|
||||
sq_settop(vm, top);
|
||||
return result.value();
|
||||
}
|
||||
}
|
||||
|
||||
[[nodiscard]] SQObject getObject() const
|
||||
{
|
||||
return funcObj;
|
||||
}
|
||||
|
||||
private:
|
||||
SQObject funcObj{};
|
||||
SQObject envObj{};
|
||||
bool isClassMethod = false;
|
||||
static constexpr auto ARG_COUNT{sizeof...(Args)};
|
||||
|
||||
static SQObject getRootTable()
|
||||
{
|
||||
HSQUIRRELVM vm = Sqrat::DefaultVM::Get();
|
||||
SQObject rootTable{};
|
||||
sq_pushroottable(vm);
|
||||
sq_getstackobj(vm, -1, &rootTable);
|
||||
sq_addref(vm, &rootTable);
|
||||
sq_pop(vm, 1); // pop root table
|
||||
return rootTable;
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif // NONUT_CORE_FUNCTION_H
|
||||
@@ -1,13 +0,0 @@
|
||||
#ifndef NONUT_CORE_INSTANCE_H
|
||||
#define NONUT_CORE_INSTANCE_H
|
||||
#include <sqapi.h>
|
||||
|
||||
namespace nonut
|
||||
{
|
||||
class Instance
|
||||
{
|
||||
public:
|
||||
[[nodiscard]] virtual SQObject getInstance() const = 0;
|
||||
};
|
||||
}
|
||||
#endif //NONUT_CORE_INSTANCE_H
|
||||
@@ -1,135 +0,0 @@
|
||||
#ifndef NONUT_CORE_PROPERTY_H
|
||||
#define NONUT_CORE_PROPERTY_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <sqapi.h>
|
||||
#include "Utils.h"
|
||||
#include "Class.h"
|
||||
|
||||
namespace nonut
|
||||
{
|
||||
template <typename T>
|
||||
T getProperty(const SQObject& object, const String& name)
|
||||
{
|
||||
HSQUIRRELVM vm = Sqrat::DefaultVM::Get();
|
||||
const auto top = sq_gettop(vm);
|
||||
|
||||
sq_pushobject(vm, object);
|
||||
sq_pushstring(vm, name.c_str(), name.length());
|
||||
|
||||
if constexpr (std::derived_from<T, Class>)
|
||||
{
|
||||
SQObject intermediateResult{};
|
||||
if (SQ_SUCCEEDED(sq_get(vm, -2))) // pops property
|
||||
{
|
||||
sqGetValue(vm, -1, &intermediateResult);
|
||||
sq_pop(vm, 1); // pops result
|
||||
}
|
||||
|
||||
sq_pop(vm, 1); // pops object
|
||||
sq_settop(vm, top);
|
||||
return T(intermediateResult);
|
||||
}
|
||||
else
|
||||
{
|
||||
T result{};
|
||||
|
||||
if (SQ_SUCCEEDED(sq_get(vm, -2))) // pops property
|
||||
{
|
||||
sqGetValue(vm, -1, &result);
|
||||
sq_pop(vm, 1); // pops result
|
||||
}
|
||||
|
||||
sq_pop(vm, 1); // pops object
|
||||
sq_settop(vm, top);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
inline bool getProperty<bool>(const SQObject& object, const String& name)
|
||||
{
|
||||
return getProperty<Bool>(object, name);
|
||||
}
|
||||
|
||||
template <>
|
||||
inline String getProperty<String>(const SQObject& object, const String& name)
|
||||
{
|
||||
HSQUIRRELVM vm = Sqrat::DefaultVM::Get();
|
||||
const Int top = sq_gettop(vm);
|
||||
const SQChar* result{};
|
||||
|
||||
sq_pushobject(vm, object);
|
||||
sq_pushstring(vm, name.c_str(), name.length());
|
||||
|
||||
if (SQ_SUCCEEDED(sq_get(vm, -2))) // pops property
|
||||
{
|
||||
sq_getstring(vm, -1, &result);
|
||||
sq_pop(vm, 1); // pops result
|
||||
}
|
||||
|
||||
sq_pop(vm, 1); // pops object
|
||||
sq_settop(vm, top);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
void setProperty(SQObject& object, String& name, T value)
|
||||
{
|
||||
HSQUIRRELVM vm = Sqrat::DefaultVM::Get();
|
||||
sq_pushobject(vm, object);
|
||||
sq_pushstring(vm, name.c_str(), name.length());
|
||||
if constexpr (std::derived_from<T, Class>)
|
||||
{
|
||||
sqPushValue(vm, value.getInstance());
|
||||
}
|
||||
else
|
||||
{
|
||||
sqPushValue(vm, value);
|
||||
}
|
||||
|
||||
|
||||
auto result = sq_set(vm, -3); // pops name and value
|
||||
|
||||
sq_pop(vm, 1); // pops object
|
||||
}
|
||||
|
||||
template <typename T, bool IsReadOnly = false>
|
||||
class Property
|
||||
{
|
||||
public:
|
||||
Property(String propertyName, const SQObject object) : object(object),
|
||||
propertyName(std::move(propertyName))
|
||||
{
|
||||
}
|
||||
|
||||
Property<T>& operator=(const T& other) noexcept
|
||||
{
|
||||
set(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
operator T()
|
||||
{
|
||||
return this->get();
|
||||
}
|
||||
|
||||
[[nodiscard]] T get() const
|
||||
{
|
||||
return getProperty<T>(object, propertyName);
|
||||
}
|
||||
|
||||
void set(T value)
|
||||
{
|
||||
static_assert(!IsReadOnly, "Cannot set read-only property.");
|
||||
setProperty<T>(object, propertyName, value);
|
||||
}
|
||||
|
||||
private:
|
||||
SQObject object;
|
||||
String propertyName;
|
||||
};
|
||||
}
|
||||
#endif // NONUT_CORE_PROPERTY_H
|
||||
@@ -1,25 +0,0 @@
|
||||
#ifndef NONUT_CORE_STATIC_CLASS_H
|
||||
#define NONUT_CORE_STATIC_CLASS_H
|
||||
|
||||
#include "Function.h"
|
||||
#include "Property.h"
|
||||
|
||||
#define METHOD_CTOR(methodName) methodName(#methodName, this->classObjectInstance, this->classObject)
|
||||
#define PROPERTY_CTOR(propertyName) propertyName(#propertyName, this->classObjectInstance)
|
||||
|
||||
namespace nonut
|
||||
{
|
||||
class StaticClass
|
||||
{
|
||||
public:
|
||||
explicit StaticClass(const String& className);
|
||||
~StaticClass();
|
||||
|
||||
protected:
|
||||
// Object holding information about class
|
||||
SQObject classObject{};
|
||||
// Class object instance
|
||||
SQObject classObjectInstance{};
|
||||
};
|
||||
}
|
||||
#endif // NONUT_CORE_STATIC_CLASS_H
|
||||
@@ -1,347 +0,0 @@
|
||||
#ifndef NONUT_CORE_STRING_HELPERS_H
|
||||
#define NONUT_CORE_STRING_HELPERS_H
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace nonut
|
||||
{
|
||||
const std::unordered_map<unsigned char, std::string_view> WINDOWS1250_UTF8_MAP
|
||||
{
|
||||
{'\x80', "\xe2\x82\xac"}, // euro sign
|
||||
{'\x82', "\xe2\x80\x9a"}, // lower quotation mark
|
||||
{'\x84', "\xe2\x80\x9e"}, // lower quotation marks
|
||||
{'\x85', "\xe2\x80\xa6"}, // ellipsis
|
||||
{'\x86', "\xe2\x80\xa0"}, // dagger
|
||||
{'\x87', "\xe2\x80\xa1"}, // double dagger
|
||||
{'\x89', "\xe2\x80\xb0"}, // per mille
|
||||
{'\x8a', "\xc5\xa0"}, // S with caron
|
||||
{'\x8b', "\xe2\x80\xb9"}, // left guillemet
|
||||
{'\x8c', "\xc5\x9a"}, // S with acute
|
||||
{'\x8d', "\xc5\xa4"}, // T with caron
|
||||
{'\x8e', "\xc5\xbd"}, // Z with caron
|
||||
{'\x8f', "\xc5\xb9"}, // Z with acute
|
||||
|
||||
{'\x91', "\xe2\x80\x98"}, // upper quotation mark (opening)
|
||||
{'\x92', "\xe2\x80\x99"}, // upper quotation mark (closing)
|
||||
{'\x93', "\xe2\x80\x9c"}, // upper quotation marks (opening)
|
||||
{'\x94', "\xe2\x80\x9d"}, // upper quotation marks (closing)
|
||||
{'\x95', "\xe2\x80\xa2"}, // bullet sign
|
||||
{'\x96', "\xe2\x80\x93"}, // en dash
|
||||
{'\x97', "\xe2\x80\x94"}, // em dash
|
||||
{'\x99', "\xe2\x84\xa2"}, // trademark sign
|
||||
{'\x9a', "\xc5\xa1"}, // s with caron
|
||||
{'\x9b', "\xe2\x80\xba"}, // right guillemet
|
||||
{'\x9c', "\xc5\x9b"}, // s with acute
|
||||
{'\x9d', "\xc5\xa5"}, // t with caron
|
||||
{'\x9e', "\xc5\xbe"}, // z with caron
|
||||
{'\x9f', "\xc5\xba"}, // z with acute
|
||||
|
||||
{'\xa0', "\x20"}, // NBSP
|
||||
{'\xa1', "\xcb\x87"}, // caron
|
||||
{'\xa2', "\xcb\x98"}, // breve
|
||||
{'\xa3', "\xc5\x81"}, // L with stroke
|
||||
{'\xa4', "\xc2\xa4"}, // currency sign
|
||||
{'\xa5', "\xc4\x84"}, // A with ogonek
|
||||
{'\xa6', "\xc2\xa6"}, // vertical bar
|
||||
{'\xa7', "\xc2\xa7"}, // section sign
|
||||
{'\xa8', "\xc2\xa8"}, // diaeresis
|
||||
{'\xa9', "\xc2\xa9"}, // copyright sign
|
||||
{'\xaa', "\xc5\x9e"}, // S-cedilla
|
||||
{'\xab', "\xc2\xab"}, // left guillemets
|
||||
{'\xac', "\xc2\xac"}, // negation
|
||||
{'\xad', "\xc2\xad"}, // soft hyphen
|
||||
{'\xae', "\xc2\xae"}, // registered trademark sign
|
||||
{'\xaf', "\xc5\xbb"}, // Z with dot above
|
||||
|
||||
{'\xb0', "\xc2\xb0"}, // degree sign
|
||||
{'\xb1', "\xc2\xb1"}, // plus-minus sign
|
||||
{'\xb2', "\xcb\x9b"}, // ogonek
|
||||
{'\xb3', "\xc5\x82"}, // l with stroke
|
||||
{'\xb4', "\xc2\xb4"}, // acute accent
|
||||
{'\xb5', "\xc2\xb5"}, // Mu letter
|
||||
{'\xb6', "\xc2\xb6"}, // pilcrow
|
||||
{'\xb7', "\xc2\xb7"}, // middle dot
|
||||
{'\xb8', "\xc2\xb8"}, // cedilla
|
||||
{'\xb9', "\xc4\x85"}, // a with ogonek
|
||||
{'\xba', "\xc5\x9f"}, // s-cedilla
|
||||
{'\xbb', "\xc2\xbb"}, // right guillemets
|
||||
{'\xbc', "\xc4\xbd"}, // Lj-
|
||||
{'\xbd', "\xcb\x9d"}, // double acute accent
|
||||
{'\xbe', "\xc4\xbe"}, // lj-
|
||||
{'\xbf', "\xc5\xbc"}, // z with dot above
|
||||
|
||||
{'\xc0', "\xc5\x94"}, // R with acute
|
||||
{'\xc1', "\xc3\x81"}, // A with acute
|
||||
{'\xc2', "\xc3\x82"}, // A-circumflex
|
||||
{'\xc3', "\xc4\x82"}, // A-breve
|
||||
{'\xc4', "\xc3\x84"}, // A with diaeresis
|
||||
{'\xc5', "\xc4\xb9"}, // L with acute
|
||||
{'\xc6', "\xc4\x86"}, // C with acute
|
||||
{'\xc7', "\xc3\x87"}, // C-cedilla
|
||||
{'\xc8', "\xc4\x8c"}, // C with caron
|
||||
{'\xc9', "\xc3\x89"}, // C with acute
|
||||
{'\xca', "\xc4\x98"}, // E with ogonek
|
||||
{'\xcb', "\xc3\x8b"}, // E with diaeresis
|
||||
{'\xcc', "\xc3\x8b"}, // E with caron
|
||||
{'\xcd', "\xc3\x8d"}, // I with acute
|
||||
{'\xce', "\xc3\x8e"}, // I-circumflex
|
||||
{'\xcf', "\xc4\x8e"}, // D with caron
|
||||
|
||||
{'\xd0', "\xc4\x90"}, // crossed D
|
||||
{'\xd1', "\xc5\x83"}, // N with acute
|
||||
{'\xd2', "\xc5\x87"}, // N with caron
|
||||
{'\xd3', "\xc3\x93"}, // O with acute
|
||||
{'\xd4', "\xc3\x94"}, // O-circumflex
|
||||
{'\xd5', "\xc5\x90"}, // O with dobule accute
|
||||
{'\xd6', "\xc3\x96"}, // O with diaeresis
|
||||
{'\xd7', "\xc3\x97"}, // multiplication sign
|
||||
{'\xd8', "\xc5\x98"}, // R with caron
|
||||
{'\xd9', "\xc5\xae"}, // U with diacritic
|
||||
{'\xda', "\xc3\x9a"}, // U with acute
|
||||
{'\xdb', "\xc5\xb0"}, // U with double accent
|
||||
{'\xdc', "\xc3\x9c"}, // U with diaeresis
|
||||
{'\xdd', "\xc3\x9d"}, // Y with acute
|
||||
{'\xdf', "\xc5\xa2"}, // T-cedilla
|
||||
|
||||
{'\xe0', "\xc5\x95"}, // r with acute
|
||||
{'\xe1', "\xc3\xa1"}, // a with acute
|
||||
{'\xe2', "\xc3\xa2"}, // a-circumflex
|
||||
{'\xe3', "\xc4\x83"}, // a-breve
|
||||
{'\xe4', "\xc3\xa4"}, // a with diaeresis
|
||||
{'\xe5', "\xc4\xba"}, // l with acute
|
||||
{'\xe6', "\xc4\x87"}, // c with acute
|
||||
{'\xe7', "\xc3\xa7"}, // c-cedilla
|
||||
{'\xe8', "\xc4\x8d"}, // c with caron
|
||||
{'\xe9', "\xc3\xa9"}, // c with acute
|
||||
{'\xea', "\xc4\x99"}, // e with ogonek
|
||||
{'\xeb', "\xc3\xab"}, // e with diaeresis
|
||||
{'\xec', "\xc4\x9b"}, // e with caron
|
||||
{'\xed', "\xc3\xad"}, // i with acute
|
||||
{'\xee', "\xc3\xae"}, // i-circumflex
|
||||
{'\xef', "\xc4\x8f"}, // d with caron
|
||||
|
||||
{'\xf0', "\xc4\x91"}, // crossed d
|
||||
{'\xf1', "\xc5\x84"}, // n with acute
|
||||
{'\xf2', "\xc5\x88"}, // n with caron
|
||||
{'\xf3', "\xc3\xb3"}, // o with acute
|
||||
{'\xf4', "\xc3\xb4"}, // o-circumflex
|
||||
{'\xf5', "\xc5\x91"}, // o with double accent
|
||||
{'\xf6', "\xc3\xb6"}, // o with diaeresis
|
||||
{'\xf7', "\xc3\xb7"}, // division sign
|
||||
{'\xf8', "\xc5\x99"}, // r with caron
|
||||
{'\xf9', "\xc5\xaf"}, // u with diacritic
|
||||
{'\xfa', "\xc3\xba"}, // u with acute
|
||||
{'\xfb', "\xc5\xb1"}, // u with double accent
|
||||
{'\xfc', "\xc3\xbc"}, // u with diaeresis
|
||||
{'\xfd', "\xc3\xbd"}, // y with acute
|
||||
{'\xfe', "\xc5\xa3"}, // t-cedilla
|
||||
{'\xff', "\xcb\x99"}, // diactric dot
|
||||
};
|
||||
|
||||
const std::unordered_map<std::string_view, unsigned char> UTF8_WINDOWS1250_MAP
|
||||
{
|
||||
{"\xe2\x82\xac", '\x80'}, // euro sign
|
||||
{"\xe2\x80\x9a", '\x82'}, // lower quotation mark
|
||||
{"\xe2\x80\x9e", '\x84'}, // lower quotation marks
|
||||
{"\xe2\x80\xa6", '\x85'}, // ellipsis
|
||||
{"\xe2\x80\xa0", '\x86'}, // dagger
|
||||
{"\xe2\x80\xa1", '\x87'}, // double dagger
|
||||
{"\xe2\x80\xb0", '\x89'}, // per mille
|
||||
{"\xc5\xa0", '\x8a'}, // S with caron
|
||||
{"\xe2\x80\xb9", '\x8b'}, // left guillemet
|
||||
{"\xc5\x9a", '\x8c'}, // S with acute
|
||||
{"\xc5\xa4", '\x8d'}, // T with caron
|
||||
{"\xc5\xbd", '\x8e'}, // Z with caron
|
||||
{"\xc5\xb9", '\x8f'}, // Z with acute
|
||||
|
||||
{"\xe2\x80\x98", '\x91'}, // upper quotation mark (opening)
|
||||
{"\xe2\x80\x99", '\x92'}, // upper quotation mark (closing)
|
||||
{"\xe2\x80\x9c", '\x93'}, // upper quotation marks (opening)
|
||||
{"\xe2\x80\x9d", '\x94'}, // upper quotation marks (closing)
|
||||
{"\xe2\x80\xa2", '\x95'}, // bullet sign
|
||||
{"\xe2\x80\x93", '\x96'}, // en dash
|
||||
{"\xe2\x80\x94", '\x97'}, // em dash
|
||||
{"\xe2\x84\xa2", '\x99'}, // trademark sign
|
||||
{"\xc5\xa1", '\x9a'}, // s with caron
|
||||
{"\xe2\x80\xba", '\x9b'}, // right guillemet
|
||||
{"\xc5\x9b", '\x9c'}, // s with acute
|
||||
{"\xc5\xa5", '\x9d'}, // t with caron
|
||||
{"\xc5\xbe", '\x9e'}, // z with caron
|
||||
{"\xc5\xba", '\x9f'}, // z with acute
|
||||
|
||||
{"\x20", '\xa0'}, // NBSP
|
||||
{"\xcb\x87", '\xa1'}, // caron
|
||||
{"\xcb\x98", '\xa2'}, // breve
|
||||
{"\xc5\x81", '\xa3'}, // L with stroke
|
||||
{"\xc2\xa4", '\xa4'}, // currency sign
|
||||
{"\xc4\x84", '\xa5'}, // A with ogonek
|
||||
{"\xc2\xa6", '\xa6'}, // vertical bar
|
||||
{"\xc2\xa7", '\xa7'}, // section sign
|
||||
{"\xc2\xa8", '\xa8'}, // diaeresis
|
||||
{"\xc2\xa9", '\xa9'}, // copyright sign
|
||||
{"\xc5\x9e", '\xaa'}, // S-cedilla
|
||||
{"\xc2\xab", '\xab'}, // left guillemets
|
||||
{"\xc2\xac", '\xac'}, // negation
|
||||
{"\xc2\xad", '\xad'}, // soft hyphen
|
||||
{"\xc2\xae", '\xae'}, // registered trademark sign
|
||||
{"\xc5\xbb", '\xaf'}, // Z with dot above
|
||||
|
||||
{"\xc2\xb0", '\xb0'}, // degree sign
|
||||
{"\xc2\xb1", '\xb1'}, // plus-minus sign
|
||||
{"\xcb\x9b", '\xb2'}, // ogonek
|
||||
{"\xc5\x82", '\xb3'}, // l with stroke
|
||||
{"\xc2\xb4", '\xb4'}, // acute accent
|
||||
{"\xc2\xb5", '\xb5'}, // Mu letter
|
||||
{"\xc2\xb6", '\xb6'}, // pilcrow
|
||||
{"\xc2\xb7", '\xb7'}, // middle dot
|
||||
{"\xc2\xb8", '\xb8'}, // cedilla
|
||||
{"\xc4\x85", '\xb9'}, // a with ogonek
|
||||
{"\xc5\x9f", '\xba'}, // s-cedilla
|
||||
{"\xc2\xbb", '\xbb'}, // right guillemets
|
||||
{"\xc4\xbd", '\xbc'}, // Lj-
|
||||
{"\xcb\x9d", '\xbd'}, // double acute accent
|
||||
{"\xc4\xbe", '\xbe'}, // lj-
|
||||
{"\xc5\xbc", '\xbf'}, // z with dot above
|
||||
|
||||
{"\xc5\x94", '\xc0'}, // R with acute
|
||||
{"\xc3\x81", '\xc1'}, // A with acute
|
||||
{"\xc3\x82", '\xc2'}, // A-circumflex
|
||||
{"\xc4\x82", '\xc3'}, // A-breve
|
||||
{"\xc3\x84", '\xc4'}, // A with diaeresis
|
||||
{"\xc4\xb9", '\xc5'}, // L with acute
|
||||
{"\xc4\x86", '\xc6'}, // C with acute
|
||||
{"\xc3\x87", '\xc7'}, // C-cedilla
|
||||
{"\xc4\x8c", '\xc8'}, // C with caron
|
||||
{"\xc3\x89", '\xc9'}, // C with acute
|
||||
{"\xc4\x98", '\xca'}, // E with ogonek
|
||||
{"\xc3\x8b", '\xcb'}, // E with diaeresis
|
||||
{"\xc3\x8b", '\xcc'}, // E with caron
|
||||
{"\xc3\x8d", '\xcd'}, // I with acute
|
||||
{"\xc3\x8e", '\xce'}, // I-circumflex
|
||||
{"\xc4\x8e", '\xcf'}, // D with caron
|
||||
|
||||
{"\xc4\x90", '\xd0'}, // crossed D
|
||||
{"\xc5\x83", '\xd1'}, // N with acute
|
||||
{"\xc5\x87", '\xd2'}, // N with caron
|
||||
{"\xc3\x93", '\xd3'}, // O with acute
|
||||
{"\xc3\x94", '\xd4'}, // O-circumflex
|
||||
{"\xc5\x90", '\xd5'}, // O with dobule accute
|
||||
{"\xc3\x96", '\xd6'}, // O with diaeresis
|
||||
{"\xc3\x97", '\xd7'}, // multiplication sign
|
||||
{"\xc5\x98", '\xd8'}, // R with caron
|
||||
{"\xc5\xae", '\xd9'}, // U with diacritic
|
||||
{"\xc3\x9a", '\xda'}, // U with acute
|
||||
{"\xc5\xb0", '\xdb'}, // U with double accent
|
||||
{"\xc3\x9c", '\xdc'}, // U with diaeresis
|
||||
{"\xc3\x9d", '\xdd'}, // Y with acute
|
||||
{"\xc5\xa2", '\xdf'}, // T-cedilla
|
||||
|
||||
{"\xc5\x95", '\xe0'}, // r with acute
|
||||
{"\xc3\xa1", '\xe1'}, // a with acute
|
||||
{"\xc3\xa2", '\xe2'}, // a-circumflex
|
||||
{"\xc4\x83", '\xe3'}, // a-breve
|
||||
{"\xc3\xa4", '\xe4'}, // a with diaeresis
|
||||
{"\xc4\xba", '\xe5'}, // l with acute
|
||||
{"\xc4\x87", '\xe6'}, // c with acute
|
||||
{"\xc3\xa7", '\xe7'}, // c-cedilla
|
||||
{"\xc4\x8d", '\xe8'}, // c with caron
|
||||
{"\xc3\xa9", '\xe9'}, // c with acute
|
||||
{"\xc4\x99", '\xea'}, // e with ogonek
|
||||
{"\xc3\xab", '\xeb'}, // e with diaeresis
|
||||
{"\xc4\x9b", '\xec'}, // e with caron
|
||||
{"\xc3\xad", '\xed'}, // i with acute
|
||||
{"\xc3\xae", '\xee'}, // i-circumflex
|
||||
{"\xc4\x8f", '\xef'}, // d with caron
|
||||
|
||||
{"\xc4\x91", '\xf0'}, // crossed d
|
||||
{"\xc5\x84", '\xf1'}, // n with acute
|
||||
{"\xc5\x88", '\xf2'}, // n with caron
|
||||
{"\xc3\xb3", '\xf3'}, // o with acute
|
||||
{"\xc3\xb4", '\xf4'}, // o-circumflex
|
||||
{"\xc5\x91", '\xf5'}, // o with double accent
|
||||
{"\xc3\xb6", '\xf6'}, // o with diaeresis
|
||||
{"\xc3\xb7", '\xf7'}, // division sign
|
||||
{"\xc5\x99", '\xf8'}, // r with caron
|
||||
{"\xc5\xaf", '\xf9'}, // u with diacritic
|
||||
{"\xc3\xba", '\xfa'}, // u with acute
|
||||
{"\xc5\xb1", '\xfb'}, // u with double accent
|
||||
{"\xc3\xbc", '\xfc'}, // u with diaeresis
|
||||
{"\xc3\xbd", '\xfd'}, // y with acute
|
||||
{"\xc5\xa3", '\xfe'}, // t-cedilla
|
||||
{"\xcb\x99", '\xff'}, // diactric dot
|
||||
};
|
||||
|
||||
inline std::string win1250ToUTF8(const std::string& strRef)
|
||||
{
|
||||
std::string result;
|
||||
result.reserve(strRef.size() * 2);
|
||||
|
||||
for (auto&& c : strRef)
|
||||
{
|
||||
if (WINDOWS1250_UTF8_MAP.contains(static_cast<unsigned char>(c)))
|
||||
result += WINDOWS1250_UTF8_MAP.at(static_cast<unsigned char>(c));
|
||||
else
|
||||
result += c;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
inline std::string UTF8ToWin1250(const std::string& strRef)
|
||||
{
|
||||
std::string result;
|
||||
result.reserve(strRef.size());
|
||||
size_t charSize = 1;
|
||||
|
||||
for (size_t i = 0; i < strRef.length(); ++i)
|
||||
{
|
||||
if (const int c = static_cast<unsigned char>(strRef[i]); c >= 128)
|
||||
{
|
||||
if (c < 224)
|
||||
charSize = 2;
|
||||
else if (c < 240)
|
||||
charSize = 3;
|
||||
else if (c < 248)
|
||||
charSize = 4;
|
||||
else if (c == 252)
|
||||
charSize = 5;
|
||||
else
|
||||
charSize = 6;
|
||||
}
|
||||
// Update loop index according to UTF8 charSize;
|
||||
i += charSize - 1;
|
||||
|
||||
if (charSize == 1)
|
||||
{
|
||||
result += strRef[i];
|
||||
continue;
|
||||
}
|
||||
|
||||
if (i + charSize > strRef.length())
|
||||
{
|
||||
result += '?';
|
||||
return result;
|
||||
}
|
||||
|
||||
String utfChar;
|
||||
utfChar.reserve(charSize);
|
||||
|
||||
for (size_t j = 0; j < charSize; ++j)
|
||||
{
|
||||
utfChar += strRef[i + j];
|
||||
}
|
||||
|
||||
if (UTF8_WINDOWS1250_MAP.contains(utfChar))
|
||||
{
|
||||
result += static_cast<char>(UTF8_WINDOWS1250_MAP.at(utfChar));
|
||||
}
|
||||
else
|
||||
{
|
||||
result += '?';
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
#endif // NONUT_CORE_STRING_HELPERS_H
|
||||
@@ -1,22 +0,0 @@
|
||||
#ifndef NONUT_CORE_STRINGIFY_H
|
||||
#define NONUT_CORE_STRINGIFY_H
|
||||
|
||||
#include "CommonHeader.h"
|
||||
#define QUOTIFY(arg) #arg
|
||||
#define STRINGIFY(arg) QUOTIFY(arg)
|
||||
|
||||
namespace nonut
|
||||
{
|
||||
template <typename T>
|
||||
class Stringify
|
||||
{
|
||||
public:
|
||||
virtual ~Stringify() = default;
|
||||
|
||||
[[nodiscard]] virtual String toString() const
|
||||
{
|
||||
return STRINGIFY(T);
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif //NONUT_CORE_STRINGIFY_H
|
||||
@@ -1,15 +0,0 @@
|
||||
#ifndef NONUT_CORE_USER_DATA_H
|
||||
#define NONUT_CORE_USER_DATA_H
|
||||
|
||||
#include <sqapi.h>
|
||||
|
||||
namespace nonut
|
||||
{
|
||||
class UserData
|
||||
{
|
||||
public:
|
||||
SQUserPointer userPtr = nullptr;
|
||||
SQUserPointer tagPtr = nullptr;
|
||||
};
|
||||
}
|
||||
#endif //NONUT_CORE_INSTANCE_H
|
||||
@@ -1,108 +0,0 @@
|
||||
#ifndef NONUT_CORE_UTILS_H
|
||||
#define NONUT_CORE_UTILS_H
|
||||
|
||||
#include "Instance.h"
|
||||
#include "CommonHeader.h"
|
||||
|
||||
namespace nonut
|
||||
{
|
||||
struct CustomType
|
||||
{
|
||||
virtual void convert(HSQOBJECT object) = 0;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
void sqGetValue(SQVM* vm, SQInteger idx, T outPtr)
|
||||
{
|
||||
static_assert(
|
||||
std::is_same_v<T, Bool*> ||
|
||||
std::is_same_v<T, Int*> ||
|
||||
std::is_same_v<T, Float*> ||
|
||||
std::is_same_v<T, const SQChar**> ||
|
||||
std::is_same_v<T, HSQOBJECT*> ||
|
||||
std::is_same_v<T, SQUserPointer*>,
|
||||
"Not supported return type");
|
||||
|
||||
if constexpr (std::is_same_v<T, Bool*>)
|
||||
sq_getbool(vm, idx, outPtr);
|
||||
if constexpr (std::is_same_v<T, Int*>)
|
||||
sq_getinteger(vm, idx, outPtr);
|
||||
if constexpr (std::is_same_v<T, Float*>)
|
||||
sq_getfloat(vm, idx, outPtr);
|
||||
if constexpr (std::is_same_v<T, const SQChar**>)
|
||||
sq_getstring(vm, idx, outPtr);
|
||||
if constexpr (std::is_same_v<T, HSQOBJECT*>)
|
||||
{
|
||||
sq_getstackobj(vm, idx, outPtr);
|
||||
sq_addref(vm, outPtr);
|
||||
}
|
||||
if constexpr (std::is_same_v<T, SQUserPointer*>)
|
||||
{
|
||||
sq_getuserpointer(vm, idx, outPtr);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void sqPushValue(SQVM* vm, T value)
|
||||
{
|
||||
static_assert(
|
||||
std::is_same_v<T, bool> ||
|
||||
std::is_same_v<T, Bool> ||
|
||||
std::is_same_v<T, Int> ||
|
||||
std::is_same_v<T, Float> ||
|
||||
std::is_same_v<T, const SQChar*> ||
|
||||
std::is_same_v<T, SQObject> ||
|
||||
std::is_same_v<T, String> ||
|
||||
std::is_same_v<T, String&> ||
|
||||
std::is_same_v<T, SQUserPointer> ||
|
||||
std::derived_from<T, Instance>,
|
||||
"Not supported return type");
|
||||
|
||||
if constexpr (std::is_same_v<T, bool>)
|
||||
sq_pushbool(vm, value);
|
||||
if constexpr (std::is_same_v<T, Bool>)
|
||||
sq_pushbool(vm, value);
|
||||
if constexpr (std::is_same_v<T, Int>)
|
||||
sq_pushinteger(vm, value);
|
||||
if constexpr (std::is_same_v<T, Float>)
|
||||
sq_pushfloat(vm, value);
|
||||
if constexpr (std::is_same_v<T, SQChar*>)
|
||||
sq_pushstring(vm, value, -1);
|
||||
if constexpr (std::is_same_v<T, SQObject>)
|
||||
sq_pushobject(vm, value);
|
||||
if constexpr (std::is_same_v<T, String> || std::is_same_v<T, String&>)
|
||||
sq_pushstring(vm, value.c_str(), value.length());
|
||||
if constexpr (std::is_same_v<T, SQUserPointer>)
|
||||
sq_pushuserpointer(vm, value);
|
||||
if constexpr (std::derived_from<T, Instance>)
|
||||
sq_pushobject(vm, value.getInstance());
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T returnVar()
|
||||
{
|
||||
HSQUIRRELVM vm = Sqrat::DefaultVM::Get();
|
||||
static_assert(
|
||||
std::is_same_v<T, SQObject> ||
|
||||
std::is_same_v<T, Bool> ||
|
||||
std::is_same_v<T, Float> ||
|
||||
std::is_same_v<T, Int> ||
|
||||
std::is_same_v<T, String>,
|
||||
"Not supported return type");
|
||||
|
||||
T result{};
|
||||
sqGetValue(vm, -1, &result);
|
||||
sq_pop(vm, 1); // pops result
|
||||
return result;
|
||||
}
|
||||
|
||||
template <>
|
||||
inline String returnVar<String>()
|
||||
{
|
||||
const SQChar* result = "";
|
||||
sq_getstring(Sqrat::DefaultVM::Get(), -1, &result);
|
||||
sq_pop(Sqrat::DefaultVM::Get(), 1); // pops result
|
||||
return result;
|
||||
}
|
||||
}
|
||||
#endif // NONUT_CORE_UTILS_H
|
||||
@@ -1,20 +0,0 @@
|
||||
#include "CommonHeader.h"
|
||||
#include "Array.h"
|
||||
|
||||
namespace nonut
|
||||
{
|
||||
Array::Array(const SQObject object) : object(object), cachedSize(size())
|
||||
{
|
||||
}
|
||||
|
||||
Array::~Array() = default;
|
||||
|
||||
size_t Array::size() const
|
||||
{
|
||||
HSQUIRRELVM vm = Sqrat::DefaultVM::Get();
|
||||
sq_pushobject(vm, object);
|
||||
const auto result = sq_getsize(vm, -1);
|
||||
sq_pop(vm, 1);
|
||||
return static_cast<size_t>(result);
|
||||
}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
#include "CommonHeader.h"
|
||||
#include "Class.h"
|
||||
|
||||
namespace nonut
|
||||
{
|
||||
Class::Class(const String& className, const SQObject classObjectInstance)
|
||||
{
|
||||
HSQUIRRELVM vm = Sqrat::DefaultVM::Get();
|
||||
if (classObjectInstance._type == OT_NULL)
|
||||
{
|
||||
bIsNull = true;
|
||||
const auto top = sq_gettop(vm);
|
||||
|
||||
sq_pushroottable(vm); //push root table
|
||||
sq_pushstring(vm, className.c_str(), className.length()); //push class name
|
||||
|
||||
if (sq_get(vm, -2) == SQ_OK) //retrieve class
|
||||
{
|
||||
sq_getstackobj(vm, -1, &classObject);
|
||||
sq_addref(vm, &classObject);
|
||||
if (sq_createinstance(vm, -1) == SQ_OK) //create class instance
|
||||
{
|
||||
//1. Get object ptr
|
||||
sq_getstackobj(vm, -1, &this->classObjectInstance); //retrieve object
|
||||
sq_addref(vm, &this->classObjectInstance);
|
||||
//Add ref thanks to which object will not be immediately deleted
|
||||
sq_pop(vm, 1); // pop class instance
|
||||
}
|
||||
}
|
||||
sq_settop(vm, top); // TODO: FIX LEAK PROPERLY
|
||||
}
|
||||
else
|
||||
{
|
||||
this->classObjectInstance = classObjectInstance;
|
||||
const auto top = sq_gettop(vm);
|
||||
sq_addref(vm, &this->classObjectInstance);
|
||||
|
||||
sq_pushroottable(vm); //push root table
|
||||
sq_pushstring(vm, className.c_str(), className.length()); //push class name
|
||||
|
||||
if (sq_get(vm, -2) == SQ_OK) //retrieve class
|
||||
{
|
||||
sq_getstackobj(vm, -1, &classObject);
|
||||
sq_addref(vm, &classObject);
|
||||
}
|
||||
|
||||
sq_settop(vm, top);
|
||||
}
|
||||
}
|
||||
|
||||
Class::~Class()
|
||||
{
|
||||
HSQUIRRELVM vm = Sqrat::DefaultVM::Get();
|
||||
sq_release(vm, &classObject);
|
||||
sq_release(vm, &classObjectInstance);
|
||||
sq_resetobject(&classObject);
|
||||
sq_resetobject(&classObjectInstance);
|
||||
}
|
||||
|
||||
SQObject Class::getInstance() const
|
||||
{
|
||||
return classObjectInstance;
|
||||
}
|
||||
|
||||
bool Class::isNull() const
|
||||
{
|
||||
return bIsNull;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
#include "Constant.h"
|
||||
|
||||
namespace nonut
|
||||
{
|
||||
SQObject getConstTable()
|
||||
{
|
||||
SQObject obj;
|
||||
HSQUIRRELVM vm = Sqrat::DefaultVM::Get();
|
||||
sq_pushconsttable(vm);
|
||||
sq_getstackobj(vm, -1, &obj);
|
||||
sq_pop(vm, 1); // No addref needed, since the consttable is always around
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
@@ -1,181 +0,0 @@
|
||||
#include "CustomTypes.h"
|
||||
|
||||
#include "Array.h"
|
||||
#include "Property.h"
|
||||
|
||||
namespace nonut
|
||||
{
|
||||
#define GET_SLOT(slot, type) slot = arrayWrapper.get<type>(#slot)
|
||||
|
||||
void GameTime::convert(SQObject object)
|
||||
{
|
||||
Array arrayWrapper(object);
|
||||
GET_SLOT(day, Int);
|
||||
GET_SLOT(hour, Int);
|
||||
GET_SLOT(min, Int);
|
||||
}
|
||||
|
||||
void Position2d::convert(SQObject object)
|
||||
{
|
||||
Array arrayWrapper(object);
|
||||
GET_SLOT(x, Int);
|
||||
GET_SLOT(y, Int);
|
||||
}
|
||||
|
||||
void Position3d::convert(SQObject object)
|
||||
{
|
||||
Array arrayWrapper(object);
|
||||
GET_SLOT(x, Float);
|
||||
GET_SLOT(y, Float);
|
||||
GET_SLOT(z, Float);
|
||||
}
|
||||
|
||||
void Size2d::convert(SQObject object)
|
||||
{
|
||||
Array arrayWrapper(object);
|
||||
GET_SLOT(width, Int);
|
||||
GET_SLOT(height, Int);
|
||||
}
|
||||
|
||||
void Rect::convert(SQObject object)
|
||||
{
|
||||
Array arrayWrapper(object);
|
||||
GET_SLOT(x, Int);
|
||||
GET_SLOT(y, Int);
|
||||
GET_SLOT(width, Int);
|
||||
GET_SLOT(height, Int);
|
||||
}
|
||||
|
||||
void UV::convert(SQObject object)
|
||||
{
|
||||
Array arrayWrapper(object);
|
||||
GET_SLOT(x, Float);
|
||||
GET_SLOT(y, Float);
|
||||
GET_SLOT(width, Float);
|
||||
GET_SLOT(height, Float);
|
||||
}
|
||||
|
||||
void Resolution::convert(SQObject object)
|
||||
{
|
||||
Array arrayWrapper(object);
|
||||
GET_SLOT(x, Int);
|
||||
GET_SLOT(y, Int);
|
||||
GET_SLOT(bpp, Int);
|
||||
}
|
||||
|
||||
void Item::convert(SQObject object)
|
||||
{
|
||||
Array arrayWrapper(object);
|
||||
GET_SLOT(instance, Int);
|
||||
GET_SLOT(amount, Int);
|
||||
GET_SLOT(name, String);
|
||||
}
|
||||
|
||||
void Color::convert(SQObject object)
|
||||
{
|
||||
Array arrayWrapper(object);
|
||||
GET_SLOT(r, Int);
|
||||
GET_SLOT(g, Int);
|
||||
GET_SLOT(b, Int);
|
||||
}
|
||||
|
||||
void BodyVisual::convert(SQObject object)
|
||||
{
|
||||
Array arrayWrapper(object);
|
||||
GET_SLOT(bodyModel, String);
|
||||
GET_SLOT(bodyTxt, Int);
|
||||
GET_SLOT(headModel, String);
|
||||
GET_SLOT(headTxt, Int);
|
||||
}
|
||||
|
||||
void NetworkStats::convert(SQObject object)
|
||||
{
|
||||
Array arrayWrapper(object);
|
||||
GET_SLOT(packetReceived, Int);
|
||||
GET_SLOT(packetlossTotal, Int);
|
||||
GET_SLOT(packetlossLastSecond, Int);
|
||||
GET_SLOT(messagesInResendBuffer, Int);
|
||||
GET_SLOT(messageInSendBuffer, Int);
|
||||
GET_SLOT(bytesInResendBuffer, Int);
|
||||
GET_SLOT(bytesInSendBuffer, Int);
|
||||
}
|
||||
|
||||
void Position3dWithName::convert(SQObject object)
|
||||
{
|
||||
Array arrayWrapper(object);
|
||||
GET_SLOT(name, String);
|
||||
GET_SLOT(x, Float);
|
||||
GET_SLOT(y, Float);
|
||||
GET_SLOT(z, Float);
|
||||
}
|
||||
|
||||
void SqDict::convert(SQObject object)
|
||||
{
|
||||
Sqrat::Table tab = Sqrat::Table(object);
|
||||
Sqrat::Object::iterator tabIterator;
|
||||
int i = 0;
|
||||
|
||||
while (tab.Next(tabIterator))
|
||||
{
|
||||
HSQOBJECT key = tabIterator.getKey();
|
||||
HSQOBJECT value = tabIterator.getValue();
|
||||
|
||||
if (key._type != OT_STRING)
|
||||
continue;
|
||||
|
||||
if (value._type == OT_STRING)
|
||||
data[sq_objtostring(&key)] = sq_objtostring(&value);
|
||||
else if (value._type == OT_INTEGER)
|
||||
data[sq_objtostring(&key)] = sq_objtointeger(&value);
|
||||
else if (value._type == OT_FLOAT)
|
||||
data[sq_objtostring(&key)] = sq_objtofloat(&value);
|
||||
else if (value._type == OT_TABLE)
|
||||
{
|
||||
SqDict result = SqDict();
|
||||
result.convert(value);
|
||||
data[sq_objtostring(&key)] = result.data;
|
||||
}
|
||||
else if (value._type == OT_ARRAY)
|
||||
{
|
||||
SqList result = SqList();
|
||||
result.convert(value);
|
||||
data[sq_objtostring(&key)] = result.data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SqList::convert(SQObject object)
|
||||
{
|
||||
Sqrat::Array tab = Sqrat::Array(object);
|
||||
Sqrat::Object::iterator arrIterator;
|
||||
int i = 0;
|
||||
|
||||
while (tab.Next(arrIterator))
|
||||
{
|
||||
HSQOBJECT key = arrIterator.getKey();
|
||||
HSQOBJECT value = arrIterator.getValue();
|
||||
|
||||
if (key._type != OT_INTEGER)
|
||||
continue;
|
||||
|
||||
if (value._type == OT_STRING)
|
||||
data.insert(sq_objtointeger(&key), sq_objtofloat(&value));
|
||||
else if (value._type == OT_INTEGER)
|
||||
data.insert(sq_objtointeger(&key), sq_objtointeger(&value));
|
||||
else if (value._type == OT_FLOAT)
|
||||
data.insert(sq_objtointeger(&key), sq_objtofloat(&value));
|
||||
else if (value._type == OT_TABLE)
|
||||
{
|
||||
SqDict result = SqDict();
|
||||
result.convert(value);
|
||||
data.insert(sq_objtointeger(&key), result.data);
|
||||
}
|
||||
else if (value._type == OT_ARRAY)
|
||||
{
|
||||
SqList result = SqList();
|
||||
result.convert(value);
|
||||
data.insert(sq_objtointeger(&key), result.data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
#include "StaticClass.h"
|
||||
|
||||
namespace nonut
|
||||
{
|
||||
StaticClass::StaticClass(const String& className)
|
||||
{
|
||||
HSQUIRRELVM vm = Sqrat::DefaultVM::Get();
|
||||
const auto top = sq_gettop(vm);
|
||||
|
||||
sq_pushroottable(vm); //push root table
|
||||
sq_pushstring(vm, className.c_str(), className.length()); //push class instance name
|
||||
|
||||
if (sq_get(vm, -2) == SQ_OK) //retrieve class instance
|
||||
{
|
||||
sq_getstackobj(vm, -1, &classObjectInstance);
|
||||
sq_addref(vm, &classObjectInstance);
|
||||
sq_getclass(vm, -1);
|
||||
sq_getstackobj(vm, -1, &classObject);
|
||||
sq_addref(vm, &classObject);
|
||||
}
|
||||
sq_settop(vm, top); // TODO: FIX LEAK PROPERLY
|
||||
}
|
||||
|
||||
StaticClass::~StaticClass()
|
||||
{
|
||||
HSQUIRRELVM vm = Sqrat::DefaultVM::Get();
|
||||
sq_release(vm, &classObject);
|
||||
sq_release(vm, &classObjectInstance);
|
||||
sq_resetobject(&classObject);
|
||||
sq_resetobject(&classObjectInstance);
|
||||
}
|
||||
}
|
||||
264
source/bind.cpp
264
source/bind.cpp
@@ -1,264 +0,0 @@
|
||||
#include <pybind11/embed.h>
|
||||
|
||||
#include "python/Packet.h"
|
||||
#include "python/DamageDescription.h"
|
||||
#include "python/ItemGround.h"
|
||||
#include "python/Daedalus.h"
|
||||
#include "python/Sky.h"
|
||||
#include "python/ItemsGround.h"
|
||||
#include "python/Mds.h"
|
||||
#include "python/Way.h"
|
||||
|
||||
#include "python/functions.h"
|
||||
|
||||
#include <Constant.h>
|
||||
|
||||
namespace py = pybind11;
|
||||
|
||||
PYBIND11_EMBEDDED_MODULE(sqg2o, m) {
|
||||
|
||||
py::class_<PyPacket>(m, "Packet")
|
||||
.def(py::init<>())
|
||||
.def("reset", &PyPacket::reset)
|
||||
.def("send", &PyPacket::send)
|
||||
.def("sendToAll", &PyPacket::sendToAll)
|
||||
.def("writeInt8", &PyPacket::writeInt8)
|
||||
.def("writeUInt8", &PyPacket::writeUInt8)
|
||||
.def("writeInt16", &PyPacket::writeInt16)
|
||||
.def("writeUInt16", &PyPacket::writeUInt16)
|
||||
.def("writeInt32", &PyPacket::writeInt32)
|
||||
.def("writeUInt32", &PyPacket::writeUInt32)
|
||||
.def("writeFloat", &PyPacket::writeFloat)
|
||||
.def("writeBool", &PyPacket::writeBool)
|
||||
.def("writeString", &PyPacket::writeString)
|
||||
.def("readInt8", &PyPacket::readInt8)
|
||||
.def("readUInt8", &PyPacket::readUInt8)
|
||||
.def("readInt16", &PyPacket::readInt16)
|
||||
.def("readUInt16", &PyPacket::readUInt16)
|
||||
.def("readInt32", &PyPacket::readInt32)
|
||||
.def("readUInt32", &PyPacket::readUInt32)
|
||||
.def("readFloat", &PyPacket::readFloat)
|
||||
.def("readBool", &PyPacket::readBool)
|
||||
.def("readString", &PyPacket::readString)
|
||||
.def("__del__", &PyPacket::del)
|
||||
|
||||
.def_property_readonly("bitsUsed", &PyPacket::getBitsUsed)
|
||||
.def_property_readonly("bytesUsed", &PyPacket::getBytesUsed);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
py::class_<PyDamageDescription>(m, "DamageDescription")
|
||||
|
||||
.def_property_readonly("item_instance", &PyDamageDescription::getItemInstance)
|
||||
|
||||
.def_property("flags", &PyDamageDescription::getFlags, &PyDamageDescription::setFlags, py::return_value_policy::reference_internal)
|
||||
.def_property("damage", &PyDamageDescription::getDamage, &PyDamageDescription::setDamage, py::return_value_policy::reference_internal)
|
||||
.def_property("distance", &PyDamageDescription::getDistance, &PyDamageDescription::setDistance, py::return_value_policy::reference_internal)
|
||||
.def_property("spell_id", &PyDamageDescription::getSpellId, &PyDamageDescription::setSpellId, py::return_value_policy::reference_internal)
|
||||
.def_property("spell_level", &PyDamageDescription::getSpellLevel, &PyDamageDescription::setSpellLevel, py::return_value_policy::reference_internal)
|
||||
.def_property("node", &PyDamageDescription::getNode, &PyDamageDescription::setNode, py::return_value_policy::reference_internal);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
py::class_<PyItemGround>(m, "ItemGround")
|
||||
.def("__del__", &PyItemGround::del)
|
||||
|
||||
.def("getPosition", &PyItemGround::getPosition)
|
||||
.def("getRotation", &PyItemGround::getRotation)
|
||||
|
||||
.def_property_readonly("id", &PyItemGround::getId)
|
||||
.def_property_readonly("instance", &PyItemGround::getInstance)
|
||||
.def_property_readonly("amount", &PyItemGround::getAmount)
|
||||
.def_property_readonly("world", &PyItemGround::getWorld)
|
||||
|
||||
.def_property("virtualWorld", &PyItemGround::getVirtualWorld, &PyItemGround::setVirtualWorld, py::return_value_policy::reference_internal);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
py::class_<PyDaedalus>(m, "Daedalus")
|
||||
.def_static("index", [](std::string value){ return PyDaedalus::index(value); })
|
||||
.def_static("symbol", [](std::string value){ return PyDaedalus::symbol(value); })
|
||||
.def_static("instance", [](std::string value){ return PyDaedalus::instance(value); });
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
py::class_<PySky>(m, "Sky")
|
||||
.def_property_static("weather", [](py::object){ return PySky::getWeather(); }, [](py::object, int value) { PySky::setWeather(value); })
|
||||
.def_property_static("raining", [](py::object){ return PySky::getRaining(); }, [](py::object, int value) { PySky::setRaining(value); })
|
||||
.def_property_static("renderLightning", [](py::object){ return PySky::getRenderLightning(); }, [](py::object, int value) { PySky::setRenderLightning(value); })
|
||||
.def_property_static("windScale", [](py::object){ return PySky::getWindScale(); }, [](py::object, int value) { PySky::setWindScale(value); })
|
||||
.def_property_static("dontRain", [](py::object){ return PySky::getDontRain(); }, [](py::object, int value) { PySky::setDontRain(value); })
|
||||
|
||||
.def_static("setRainStartTime", [](int hour, int min){ return PySky::setRainStartTime(hour, min); })
|
||||
.def_static("setRainStopTime", [](int hour, int min){ return PySky::setRainStopTime(hour, min); })
|
||||
.def_static("getRainStartTime", [](){ return PySky::getRainStartTime(); })
|
||||
.def_static("getRainStopTime", [](){ return PySky::getRainStopTime(); });
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
py::class_<PyItemsGround>(m, "ItemsGround")
|
||||
|
||||
.def_static("getById", [](int value){ return PyItemsGround::getById(value); })
|
||||
.def_static("create", [](py::dict value){ return PyItemsGround::create(value); })
|
||||
.def_static("destroy", [](int value){ return PyItemsGround::destroy(value); });
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
py::class_<PyMds>(m, "Mds")
|
||||
|
||||
.def_static("id", [](std::string value){ return PyMds::id(value); })
|
||||
.def_static("name", [](int value){ return PyMds::name(value); });
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
py::class_<PyWay>(m, "Way")
|
||||
|
||||
.def(py::init<std::string, std::string, std::string>())
|
||||
.def("getWaypoints", &PyWay::getWaypoints)
|
||||
.def("getCountWaypoints", &PyWay::getCountWaypoints)
|
||||
.def("__del__", &PyWay::del)
|
||||
|
||||
.def_property_readonly("start", &PyWay::getStart)
|
||||
.def_property_readonly("end", &PyWay::getEnd);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
m.def("getHostname", &py_getHostname);
|
||||
m.def("getMaxSlots", &py_getMaxSlots);
|
||||
m.def("getPlayersCount", &py_getPlayersCount);
|
||||
|
||||
m.def("getDistance2d", &py_getDistance2d);
|
||||
m.def("getDistance3d", &py_getDistance3d);
|
||||
m.def("getVectorAngle", &py_getVectorAngle);
|
||||
|
||||
m.def("exit", &py_exit, py::arg() = 0);
|
||||
m.def("getDayLength", &py_getDayLength);
|
||||
m.def("getServerDescription", &py_getServerDescription);
|
||||
m.def("getServerWorld", &py_getServerWorld);
|
||||
m.def("getTime", &py_getTime);
|
||||
m.def("serverLog", &py_serverLog);
|
||||
m.def("setDayLength", &py_setDayLength);
|
||||
m.def("setServerDescription", &py_setServerDescription);
|
||||
m.def("setServerWorld", &py_setServerWorld);
|
||||
m.def("setTime", &py_setTime, py::arg(), py::arg(), py::arg() = 0);
|
||||
|
||||
m.def("clearNpcActions", &py_clearNpcActions);
|
||||
m.def("createNpc", &py_createNpc, py::arg(), py::arg() = "PC_HERO");
|
||||
m.def("destroyNpc", &py_destroyNpc);
|
||||
m.def("getNpcAction", &py_getNpcAction);
|
||||
// m.def("getNpcActionType", &py_getNpcActionType);
|
||||
m.def("getNpcActtions", &py_getNpcActions);
|
||||
m.def("getNpcActtionsCount", &py_getNpcActionsCount);
|
||||
m.def("getNpcHostPlayer", &py_getNpcHostPlayer);
|
||||
m.def("getNpcLastActionId", &py_getNpcLastActionId);
|
||||
m.def("isNpc", &py_isNpc);
|
||||
m.def("isNpcActionFinished", &py_isNpcActionFinished);
|
||||
m.def("npcAttackMelee", &py_npcAttackMelee);
|
||||
m.def("npcAttackRanged", &py_npcAttackRanged);
|
||||
m.def("npcSpellCast", &py_npcSpellCast);
|
||||
m.def("npcUseClosestMob", &py_npcUseClosestMob);
|
||||
// m.def("pushNpcAction", &py_pushNpcAction);
|
||||
m.def("setNpcHostPlayer", &py_setNpcHostPlayer);
|
||||
|
||||
m.def("sendMessageToAll", &py_sendMessageToAll);
|
||||
m.def("sendMessageToPlayer", &py_sendMessageToPlayer);
|
||||
m.def("sendPlayerMessageToAll", &py_sendPlayerMessageToAll);
|
||||
m.def("sendPlayerMessageToPlayer", &py_sendPlayerMessageToPlayer);
|
||||
|
||||
m.def("addBan", &py_addBan);
|
||||
m.def("applyPlayerOverlay", &py_applyPlayerOverlay);
|
||||
m.def("ban", &py_ban, py::arg(), py::arg() = 0, py::arg());
|
||||
m.def("drawWeapon", &py_drawWeapon);
|
||||
m.def("equipItem", &py_equipItem, py::arg(), py::arg(), py::arg() = -1);
|
||||
m.def("getPlayerAmulet", &py_getPlayerAmulet);
|
||||
m.def("getPlayerAngle", &py_getPlayerAngle);
|
||||
m.def("getPlayerAni", &py_getPlayerAni);
|
||||
m.def("getPlayerArmor", &py_getPlayerArmor);
|
||||
m.def("getPlayerAtVector", &py_getPlayerAtVector);
|
||||
m.def("getPlayerBelt", &py_getPlayerBelt);
|
||||
m.def("getPlayerCameraPosition",&py_getPlayerCameraPosition);
|
||||
m.def("getPlayerCollision", &py_getPlayerCollision);
|
||||
m.def("getPlayerColor", &py_getPlayerColor);
|
||||
m.def("getPlayerContext", &py_getPlayerContext);
|
||||
m.def("getPlayerDexterity", &py_getPlayerDexterity);
|
||||
m.def("getPlayerFaceAnis", &py_getPlayerFaceAnis);
|
||||
m.def("getPlayerFatness", &py_getPlayerFatness);
|
||||
m.def("getPlayerFocus", &py_getPlayerFocus);
|
||||
m.def("getPlayerHealth", &py_getPlayerHealth);
|
||||
m.def("getPlayerHelmet", &py_getPlayerHelmet);
|
||||
m.def("getPlayerIP", &py_getPlayerIP);
|
||||
m.def("getPlayerInstance", &py_getPlayerInstance);
|
||||
m.def("getPlayerMacAddr", &py_getPlayerMacAddr);
|
||||
m.def("getPlayerMana", &py_getPlayerMana);
|
||||
m.def("getPlayerMaxHealth", &py_getPlayerMaxHealth);
|
||||
m.def("getPlayerMaxMana", &py_getPlayerMaxMana);
|
||||
m.def("getPlayerMeleeWeapon", &py_getPlayerMeleeWeapon);
|
||||
m.def("getPlayerName", &py_getPlayerName);
|
||||
m.def("getPlayerPing", &py_getPlayerPing);
|
||||
m.def("getPlayerPosition", &py_getPlayerPosition);
|
||||
m.def("getPlayerRangedWeapon", &py_getPlayerRangedWeapon);
|
||||
m.def("getPlayerRespawnTime", &py_getPlayerRespawnTime);
|
||||
m.def("getPlayerRing", &py_getPlayerRing);
|
||||
m.def("getPlayerScale", &py_getPlayerScale);
|
||||
m.def("getPlayerSerial", &py_getPlayerSerial);
|
||||
m.def("getPlayerShield", &py_getPlayerShield);
|
||||
m.def("getPlayerSkillWeapon", &py_getPlayerSkillWeapon);
|
||||
m.def("getPlayerSpell", &py_getPlayerSpell);
|
||||
m.def("getPlayerStrength", &py_getPlayerStrength);
|
||||
m.def("getPlayerTalent", &py_getPlayerTalent);
|
||||
m.def("getPlayerVirtualWorld", &py_getPlayerVirtualWorld);
|
||||
m.def("getPlayerVisual", &py_getPlayerVisual);
|
||||
m.def("getPlayerWeaponMode", &py_getPlayerWeaponMode);
|
||||
m.def("getPlayerWorld", &py_getPlayerWorld);
|
||||
m.def("giveItem", &py_giveItem);
|
||||
m.def("hitPlayer", &py_hitPlayer);
|
||||
m.def("isPlayerConnected", &py_isPlayerConnected);
|
||||
m.def("isPlayerDead", &py_isPlayerDead);
|
||||
m.def("isPlayerUnconscious", &py_isPlayerUnconscious);
|
||||
m.def("kick", &py_kick);
|
||||
m.def("playAni", &py_playAni);
|
||||
m.def("playFaceAni", &py_playFaceAni);
|
||||
m.def("readySpell", &py_readySpell);
|
||||
m.def("removeItem", &py_removeItem);
|
||||
m.def("removePlayerOverlay", &py_removePlayerOverlay);
|
||||
m.def("removeWeapon", &py_removeWeapon);
|
||||
m.def("respawnPlayer", &py_respawnPlayer);
|
||||
m.def("setPlayerAngle", &py_setPlayerAngle);
|
||||
m.def("setPlayerCollision", &py_setPlayerCollision);
|
||||
m.def("setPlayerColor", &py_setPlayerColor);
|
||||
m.def("setPlayerContext", &py_setPlayerContext);
|
||||
m.def("setPlayerDexterity", &py_setPlayerDexterity);
|
||||
m.def("setPlayerFatness", &py_setPlayerFatness);
|
||||
m.def("setPlayerHealth", &py_setPlayerHealth);
|
||||
m.def("setPlayerInstance", &py_setPlayerInstance);
|
||||
m.def("setPlayerInvisible", &py_setPlayerInvisible);
|
||||
m.def("setPlayerMana", &py_setPlayerMana);
|
||||
m.def("setPlayerMaxHealth", &py_setPlayerMaxHealth);
|
||||
m.def("setPlayerMaxMana", &py_setPlayerMaxMana);
|
||||
m.def("setPlayerName", &py_setPlayerName);
|
||||
m.def("setPlayerPosition", &py_setPlayerPosition);
|
||||
m.def("setPlayerRespawnTime", &py_setPlayerRespawnTime);
|
||||
m.def("setPlayerScale", &py_setPlayerScale);
|
||||
m.def("setPlayerSkillWeapon", &py_setPlayerSkillWeapon);
|
||||
m.def("setPlayerStrength", &py_setPlayerStrength);
|
||||
m.def("setPlayerTalent", &py_setPlayerTalent);
|
||||
m.def("setPlayerVirtualWorld", &py_setPlayerVirtualWorld);
|
||||
m.def("setPlayerVisual", &py_setPlayerVisual);
|
||||
m.def("setPlayerWeaponMode", &py_setPlayerWeaponMode);
|
||||
m.def("setPlayerWorld", &py_setPlayerWorld);
|
||||
m.def("spawnPlayer", &py_spawnPlayer);
|
||||
m.def("stopAni", &py_stopAni, py::arg(), py::arg() = "");
|
||||
m.def("stopFaceAni", &py_stopFaceAni, py::arg(), py::arg() = "");
|
||||
m.def("unequipItem", &py_unequipItem);
|
||||
m.def("unreadySpell", &py_unreadySpell);
|
||||
m.def("unspawnPlayer", &py_unspawnPlayer);
|
||||
m.def("useItem", &py_useItem);
|
||||
m.def("useItemToState", &py_useItemToState);
|
||||
|
||||
m.def("findNearbyPlayers", &py_findNearbyPlayers);
|
||||
m.def("getSpawnedPlayersForPlayer", &py_getSpawnedPlayersForPlayer);
|
||||
m.def("getStreamedPlayersByPlayer", &py_getStreamedPlayersByPlayer);
|
||||
|
||||
m.def("getNearestWaypoint", &py_getNearestWaypoint);
|
||||
m.def("getWaypoint", &py_getWaypoint);
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
|
||||
target_sources(${PYG2O_MODULE_NAME}
|
||||
PRIVATE
|
||||
squirrel/Daedalus.cpp
|
||||
squirrel/DamageDescription.cpp
|
||||
squirrel/ItemGround.cpp
|
||||
squirrel/ItemsGround.cpp
|
||||
squirrel/Mds.cpp
|
||||
squirrel/Packet.cpp
|
||||
squirrel/Sky.cpp
|
||||
squirrel/Way.cpp
|
||||
)
|
||||
|
||||
target_include_directories(${PYG2O_MODULE_NAME}
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_LIST_DIR}/
|
||||
)
|
||||
@@ -1,19 +0,0 @@
|
||||
#ifndef _PYDAEDALUS_H_
|
||||
#define _PYDAEDALUS_H_
|
||||
|
||||
#include <pybind11/embed.h>
|
||||
#include "squirrel/Daedalus.h"
|
||||
|
||||
namespace py = pybind11;
|
||||
|
||||
class PyDaedalus
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
static nonut::Int index(nonut::String value) { return nonut::Daedalus::get()->index(value); }
|
||||
static py::dict symbol(nonut::String value) { return nonut::Daedalus::get()->symbol(value).data; }
|
||||
static py::dict instance(nonut::String value) { return nonut::Daedalus::get()->instance(value).data; }
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,32 +0,0 @@
|
||||
#ifndef _PYDAMAGEDESCRIPTION_H
|
||||
#define _PYDAMAGEDESCRIPTION_H
|
||||
|
||||
#include "squirrel/DamageDescription.h"
|
||||
|
||||
class PyDamageDescription
|
||||
{
|
||||
private:
|
||||
nonut::DamageDescription *sqobj;
|
||||
|
||||
public:
|
||||
PyDamageDescription(SQObject obj) { if (obj._type == OT_NULL) throw py::type_error("Presented Squirrel Object doesn't exist (type: null)"); sqobj = new nonut::DamageDescription(obj); }
|
||||
|
||||
nonut::Int getFlags() { return sqobj->flags; }
|
||||
nonut::Int getDamage() { return sqobj->damage; }
|
||||
nonut::String getItemInstance() { return sqobj->item_instance; }
|
||||
nonut::Int getDistance() { return sqobj->distance; }
|
||||
nonut::Int getSpellId() { return sqobj->spell_id; }
|
||||
nonut::Int getSpellLevel() { return sqobj->spell_level; }
|
||||
nonut::String getNode() { return sqobj->node; }
|
||||
|
||||
void setFlags(nonut::Int value) { sqobj->flags = value; }
|
||||
void setDamage(nonut::Int value) { sqobj->damage = value; }
|
||||
void setDistance(nonut::Int value) { sqobj->distance = value; }
|
||||
void setSpellId(nonut::Int value) { sqobj->spell_id = value; }
|
||||
void setSpellLevel(nonut::Int value) { sqobj->spell_level = value; }
|
||||
void setNode(nonut::String value) { sqobj->node = value; }
|
||||
|
||||
void del() { delete sqobj; }
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,32 +0,0 @@
|
||||
#ifndef _PY_ITEMGROUND_H_
|
||||
#define _PY_ITEMGROUND_H_
|
||||
|
||||
#include <pybind11/embed.h>
|
||||
#include "squirrel/ItemGround.h"
|
||||
|
||||
namespace py = pybind11;
|
||||
|
||||
class PyItemGround
|
||||
{
|
||||
private:
|
||||
nonut::ItemGround *sqobj;
|
||||
|
||||
public:
|
||||
PyItemGround(SQObject obj) { if (obj._type == OT_NULL) throw py::type_error("Presented Squirrel Object doesn't exist (type: null)"); sqobj = new nonut::ItemGround(obj); }
|
||||
PyItemGround(nonut::ItemGround obj) { if (obj.isNull()) throw py::type_error("Presented ItemGround doesn't exist (type: null)"); sqobj = &obj; }
|
||||
|
||||
py::tuple getPosition() { return py::make_tuple(sqobj->getPosition().toTuple()); }
|
||||
py::tuple getRotation() { return py::make_tuple(sqobj->getRotation().toTuple()); }
|
||||
|
||||
nonut::Int getId() { return sqobj->id; }
|
||||
nonut::String getInstance() { return sqobj->instance; }
|
||||
nonut::Int getAmount() { return sqobj->amount; }
|
||||
nonut::String getWorld() { return sqobj->world; }
|
||||
nonut::Int getVirtualWorld() { return sqobj->virtualWorld; }
|
||||
|
||||
void setVirtualWorld(nonut::Int value) { sqobj->virtualWorld = value; }
|
||||
|
||||
void del() { delete sqobj; }
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,24 +0,0 @@
|
||||
#ifndef _PYITEMSGROUND_H_
|
||||
#define _PYITEMSGROUND_H_
|
||||
|
||||
#include "squirrel/ItemsGround.h"
|
||||
#include "squirrel/ItemGround.h"
|
||||
#include "Dictionary.h"
|
||||
|
||||
class PyItemsGround
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
static PyItemGround getById(nonut::Int value) { return PyItemGround(nonut::ItemsGround::get()->getById(value)); }
|
||||
static nonut::Int create(py::dict value)
|
||||
{
|
||||
Sqrat::Table* pTable = PyDictionary::toSqObject(value);
|
||||
nonut::Int result = nonut::ItemsGround::get()->create(pTable->GetObject());
|
||||
delete pTable;
|
||||
return result;
|
||||
}
|
||||
static void destroy(nonut::Int value) { nonut::ItemsGround::get()->destroy(value); }
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,17 +0,0 @@
|
||||
#ifndef _PYMDS_H
|
||||
#define _PYMDS_H
|
||||
|
||||
#include <pybind11/embed.h>
|
||||
#include "squirrel/Mds.h"
|
||||
namespace py = pybind11;
|
||||
|
||||
class PyMds
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
static int id(std::string mdsName) { return nonut::Mds::get()->id(mdsName); }
|
||||
static std::string name(int mdsId) { return nonut::Mds::get()->name(mdsId); }
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,47 +0,0 @@
|
||||
#ifndef _PYPACKET_H_
|
||||
#define _PYPACKET_H_
|
||||
|
||||
#include "squirrel/Packet.h"
|
||||
|
||||
class PyPacket
|
||||
{
|
||||
private:
|
||||
nonut::Packet *sqpacket;
|
||||
|
||||
public:
|
||||
PyPacket() { sqpacket = new nonut::Packet(); };
|
||||
PyPacket(SQObject obj) { if (obj._type == OT_NULL) throw py::type_error("Presented Squirrel Object doesn't exist (type: null)"); sqpacket = new nonut::Packet(obj); }
|
||||
|
||||
void reset() { sqpacket->reset(); }
|
||||
void send(nonut::Int id, nonut::Int value) { sqpacket->send(id, value); }
|
||||
void sendToAll(nonut::Int value) { sqpacket->sendToAll(value); };
|
||||
|
||||
void writeInt8(nonut::Int value) { sqpacket->writeInt8(value); }
|
||||
void writeUInt8(nonut::Int value) { sqpacket->writeUInt8(value); }
|
||||
void writeInt16(nonut::Int value) { sqpacket->writeInt16(value); }
|
||||
void writeUInt16(nonut::Int value) { sqpacket->writeUInt16(value); }
|
||||
void writeInt32(nonut::Int value) { sqpacket->writeInt32(value); }
|
||||
void writeUInt32(nonut::Int value) { sqpacket->writeUInt32(value); }
|
||||
|
||||
void writeBool(nonut::Bool value) { sqpacket->writeBool(value); }
|
||||
void writeFloat(nonut::Float value) { sqpacket->writeFloat(value); }
|
||||
void writeString(nonut::String value) { sqpacket->writeString(value); }
|
||||
|
||||
nonut::Int readInt8() { return sqpacket->readInt8(); }
|
||||
nonut::Int readUInt8() { return sqpacket->readUInt8(); }
|
||||
nonut::Int readInt16() { return sqpacket->readInt16(); }
|
||||
nonut::Int readUInt16() { return sqpacket->readUInt16(); }
|
||||
nonut::Int readInt32() { return sqpacket->readInt32(); }
|
||||
nonut::Int readUInt32() { return sqpacket->readUInt32(); }
|
||||
|
||||
nonut::Bool readBool() { return sqpacket->readBool(); }
|
||||
nonut::Float readFloat() { return sqpacket->readFloat(); }
|
||||
nonut::String readString() { return sqpacket->readString(); }
|
||||
|
||||
nonut::Int getBitsUsed() { return sqpacket->bitsUsed; }
|
||||
nonut::Int getBytesUsed() { return sqpacket->bytesUsed; }
|
||||
|
||||
void del() { delete sqpacket; }
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,31 +0,0 @@
|
||||
#ifndef _PYSKY_H_
|
||||
#define _PYSKY_H_
|
||||
|
||||
#include <pybind11/embed.h>
|
||||
#include "squirrel/Sky.h"
|
||||
|
||||
namespace py = pybind11;
|
||||
|
||||
class PySky
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
static void setWeather(nonut::Int value) { nonut::Sky::get()->weather = value; }
|
||||
static nonut::Int getWeather() { return nonut::Sky::get()->weather; }
|
||||
static void setRaining(nonut::Bool value) { nonut::Sky::get()->raining = value; }
|
||||
static nonut::Bool getRaining() { return nonut::Sky::get()->raining; }
|
||||
static void setRenderLightning(nonut::Bool value) { nonut::Sky::get()->renderLightning = value; }
|
||||
static nonut::Bool getRenderLightning() { return nonut::Sky::get()->renderLightning; }
|
||||
static void setWindScale(nonut::Float value) { nonut::Sky::get()->windScale = value; }
|
||||
static nonut::Float getWindScale() { return nonut::Sky::get()->windScale; }
|
||||
static void setDontRain(nonut::Bool value) { nonut::Sky::get()->dontRain = value; }
|
||||
static nonut::Bool getDontRain() { return nonut::Sky::get()->dontRain; }
|
||||
|
||||
static void setRainStartTime(nonut::Int h, nonut::Int m) { nonut::Sky::get()->setRainStartTime(h, m); }
|
||||
static void setRainStopTime(nonut::Int h, nonut::Int m) { nonut::Sky::get()->setRainStopTime(h, m); }
|
||||
static py::dict getRainStartTime() { return nonut::Sky::get()->getRainStartTime().data; }
|
||||
static py::dict getRainStopTime() { return nonut::Sky::get()->getRainStopTime().data; }
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,24 +0,0 @@
|
||||
#ifndef _PYWAY_H_
|
||||
#define _PYWAY_H_
|
||||
|
||||
#include "squirrel/Way.h"
|
||||
|
||||
class PyWay
|
||||
{
|
||||
private:
|
||||
nonut::Way *sqway;
|
||||
|
||||
public:
|
||||
PyWay(std::string world, std::string start, std::string end) { sqway = new nonut::Way(world, start, end); };
|
||||
PyWay(SQObject obj) { if (obj._type == OT_NULL) throw py::type_error("Presented Squirrel Object doesn't exist (type: null)"); sqway = new nonut::Way(obj); }
|
||||
|
||||
py::list getWaypoints() { return sqway->getWaypoints().data; }
|
||||
int getCountWaypoints() { return sqway->getCountWaypoints(); }
|
||||
|
||||
std::string getStart() { return sqway->start; }
|
||||
std::string getEnd() { return sqway->end; }
|
||||
|
||||
void del() { delete sqway; }
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,23 +0,0 @@
|
||||
#include <CommonHeader.h>
|
||||
#include "Daedalus.h"
|
||||
|
||||
namespace nonut
|
||||
{
|
||||
Daedalus* Daedalus::get()
|
||||
{
|
||||
if (inst == nullptr)
|
||||
{
|
||||
inst = new Daedalus();
|
||||
}
|
||||
return inst;
|
||||
}
|
||||
|
||||
Daedalus::Daedalus() :
|
||||
StaticClass("Daedalus"),
|
||||
|
||||
METHOD_CTOR(index),
|
||||
METHOD_CTOR(symbol),
|
||||
METHOD_CTOR(instance)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
#ifndef _DAEDALUS_H_
|
||||
#define _DAEDALUS_H_
|
||||
#include <string>
|
||||
|
||||
#include <StaticClass.h>
|
||||
#include <CustomTypes.h>
|
||||
|
||||
namespace nonut
|
||||
{
|
||||
class Daedalus : public StaticClass
|
||||
{
|
||||
public:
|
||||
static Daedalus* get();
|
||||
|
||||
Function<Int, String> index;
|
||||
Function<SqDict, String> symbol;
|
||||
Function<SqDict, String> instance;
|
||||
|
||||
private:
|
||||
|
||||
static inline Daedalus* inst = nullptr;
|
||||
|
||||
Daedalus();
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
#include "CommonHeader.h"
|
||||
#include "DamageDescription.h"
|
||||
|
||||
namespace nonut
|
||||
{
|
||||
DamageDescription::DamageDescription(SQObject object) :
|
||||
Class("DamageDescription", object),
|
||||
|
||||
PROPERTY_CTOR(flags),
|
||||
PROPERTY_CTOR(damage),
|
||||
PROPERTY_CTOR(item_instance),
|
||||
PROPERTY_CTOR(distance),
|
||||
PROPERTY_CTOR(spell_id),
|
||||
PROPERTY_CTOR(spell_level),
|
||||
PROPERTY_CTOR(node)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
#ifndef _DAMAGEDESCRIPTION_H_
|
||||
#define _DAMAGEDESCRIPTION_H_
|
||||
#include <string>
|
||||
|
||||
#include <Class.h>
|
||||
#include <CustomTypes.h>
|
||||
|
||||
namespace nonut
|
||||
{
|
||||
class DamageDescription : public Class
|
||||
{
|
||||
public:
|
||||
DamageDescription(SQObject object);
|
||||
|
||||
Property<Int> flags;
|
||||
Property<Int> damage;
|
||||
Property<String> item_instance;
|
||||
Property<Int> distance;
|
||||
Property<Int> spell_id;
|
||||
Property<Int> spell_level;
|
||||
Property<String> node;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
#include <CommonHeader.h>
|
||||
#include "ItemGround.h"
|
||||
|
||||
namespace nonut
|
||||
{
|
||||
ItemGround::ItemGround(SQObject object) :
|
||||
Class("ItemGround", object),
|
||||
|
||||
METHOD_CTOR(getPosition),
|
||||
METHOD_CTOR(getRotation),
|
||||
|
||||
PROPERTY_CTOR(id),
|
||||
PROPERTY_CTOR(instance),
|
||||
PROPERTY_CTOR(amount),
|
||||
PROPERTY_CTOR(world),
|
||||
PROPERTY_CTOR(virtualWorld)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
#ifndef _ITEMGROUND_H
|
||||
#define _ITEMGROUND_H
|
||||
#include <string>
|
||||
|
||||
#include <Class.h>
|
||||
#include <CustomTypes.h>
|
||||
|
||||
namespace nonut
|
||||
{
|
||||
class ItemGround : public Class
|
||||
{
|
||||
public:
|
||||
ItemGround(SQObject object);
|
||||
|
||||
Function<nonut::Position3d> getPosition;
|
||||
Function<nonut::Position3d> getRotation;
|
||||
|
||||
// Properties
|
||||
Property<Int> id;
|
||||
Property<String> instance;
|
||||
Property<Int> amount;
|
||||
Property<String> world;
|
||||
Property<Int> virtualWorld;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
#include <CommonHeader.h>
|
||||
#include "ItemsGround.h"
|
||||
|
||||
namespace nonut
|
||||
{
|
||||
ItemsGround* ItemsGround::get()
|
||||
{
|
||||
if (inst == nullptr)
|
||||
{
|
||||
inst = new ItemsGround();
|
||||
}
|
||||
return inst;
|
||||
}
|
||||
|
||||
ItemsGround::ItemsGround() :
|
||||
StaticClass("ItemsGround"),
|
||||
|
||||
METHOD_CTOR(getById),
|
||||
METHOD_CTOR(create),
|
||||
METHOD_CTOR(destroy)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
#ifndef _ITEMSGROUND_H_
|
||||
#define _ITEMSGROUND_H_
|
||||
#include <string>
|
||||
|
||||
#include <StaticClass.h>
|
||||
#include <CustomTypes.h>
|
||||
#include "ItemGround.h"
|
||||
#include <pybind11/embed.h>
|
||||
namespace py = pybind11;
|
||||
|
||||
namespace nonut
|
||||
{
|
||||
class ItemsGround : public StaticClass
|
||||
{
|
||||
public:
|
||||
static ItemsGround* get();
|
||||
|
||||
Function<ItemGround, Int> getById;
|
||||
Function<Int, SQObject> create;
|
||||
Function<void, Int> destroy;
|
||||
|
||||
private:
|
||||
|
||||
static inline ItemsGround* inst = nullptr;
|
||||
|
||||
ItemsGround();
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
#include <CommonHeader.h>
|
||||
#include "Mds.h"
|
||||
|
||||
namespace nonut
|
||||
{
|
||||
Mds* Mds::get()
|
||||
{
|
||||
if (inst == nullptr)
|
||||
{
|
||||
inst = new Mds();
|
||||
}
|
||||
return inst;
|
||||
}
|
||||
|
||||
Mds::Mds() :
|
||||
StaticClass("Mds"),
|
||||
|
||||
METHOD_CTOR(id),
|
||||
METHOD_CTOR(name)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
#ifndef _MDS_H
|
||||
#define _MDS_H
|
||||
#include <string>
|
||||
|
||||
#include <StaticClass.h>
|
||||
#include <CustomTypes.h>
|
||||
|
||||
namespace nonut
|
||||
{
|
||||
class Mds : public StaticClass
|
||||
{
|
||||
public:
|
||||
static Mds* get();
|
||||
|
||||
Function<Int, String> id;
|
||||
Function<String, Int> name;
|
||||
|
||||
private:
|
||||
|
||||
static inline Mds* inst = nullptr;
|
||||
|
||||
Mds();
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
#include <CommonHeader.h>
|
||||
#include "Packet.h"
|
||||
|
||||
namespace nonut
|
||||
{
|
||||
Packet::Packet() :
|
||||
Class("Packet"),
|
||||
METHOD_CTOR(reset),
|
||||
METHOD_CTOR(send),
|
||||
METHOD_CTOR(sendToAll),
|
||||
METHOD_CTOR(writeBool),
|
||||
METHOD_CTOR(writeInt8),
|
||||
METHOD_CTOR(writeUInt8),
|
||||
METHOD_CTOR(writeInt16),
|
||||
METHOD_CTOR(writeUInt16),
|
||||
METHOD_CTOR(writeInt32),
|
||||
METHOD_CTOR(writeUInt32),
|
||||
METHOD_CTOR(writeFloat),
|
||||
METHOD_CTOR(writeString),
|
||||
METHOD_CTOR(readBool),
|
||||
METHOD_CTOR(readInt8),
|
||||
METHOD_CTOR(readUInt8),
|
||||
METHOD_CTOR(readInt16),
|
||||
METHOD_CTOR(readUInt16),
|
||||
METHOD_CTOR(readInt32),
|
||||
METHOD_CTOR(readUInt32),
|
||||
METHOD_CTOR(readFloat),
|
||||
METHOD_CTOR(readString),
|
||||
|
||||
PROPERTY_CTOR(bitsUsed),
|
||||
PROPERTY_CTOR(bytesUsed)
|
||||
{
|
||||
classCtor();
|
||||
}
|
||||
|
||||
Packet::Packet(SQObject object) :
|
||||
Class("Packet", object),
|
||||
METHOD_CTOR(reset),
|
||||
METHOD_CTOR(send),
|
||||
METHOD_CTOR(sendToAll),
|
||||
METHOD_CTOR(writeBool),
|
||||
METHOD_CTOR(writeInt8),
|
||||
METHOD_CTOR(writeUInt8),
|
||||
METHOD_CTOR(writeInt16),
|
||||
METHOD_CTOR(writeUInt16),
|
||||
METHOD_CTOR(writeInt32),
|
||||
METHOD_CTOR(writeUInt32),
|
||||
METHOD_CTOR(writeFloat),
|
||||
METHOD_CTOR(writeString),
|
||||
METHOD_CTOR(readBool),
|
||||
METHOD_CTOR(readInt8),
|
||||
METHOD_CTOR(readUInt8),
|
||||
METHOD_CTOR(readInt16),
|
||||
METHOD_CTOR(readUInt16),
|
||||
METHOD_CTOR(readInt32),
|
||||
METHOD_CTOR(readUInt32),
|
||||
METHOD_CTOR(readFloat),
|
||||
METHOD_CTOR(readString),
|
||||
|
||||
PROPERTY_CTOR(bitsUsed),
|
||||
PROPERTY_CTOR(bytesUsed)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
#ifndef _PACKET_H_
|
||||
#define _PACKET_H_
|
||||
#include <string>
|
||||
|
||||
#include <Class.h>
|
||||
#include <CustomTypes.h>
|
||||
|
||||
namespace nonut
|
||||
{
|
||||
class Packet : public Class
|
||||
{
|
||||
public:
|
||||
Packet();
|
||||
explicit Packet(SQObject object);
|
||||
|
||||
Function<void> reset;
|
||||
Function<void, Int, Int> send;
|
||||
Function<void, Int> sendToAll;
|
||||
Function<void, Bool> writeBool;
|
||||
Function<void, Int> writeInt8;
|
||||
Function<void, Int> writeUInt8;
|
||||
Function<void, Int> writeInt16;
|
||||
Function<void, Int> writeUInt16;
|
||||
Function<void, Int> writeInt32;
|
||||
Function<void, Int> writeUInt32;
|
||||
Function<void, Float> writeFloat;
|
||||
Function<void, String&> writeString;
|
||||
Function<Bool> readBool;
|
||||
Function<Int> readInt8;
|
||||
Function<Int> readUInt8;
|
||||
Function<Int> readInt16;
|
||||
Function<Int> readUInt16;
|
||||
Function<Int> readInt32;
|
||||
Function<Int> readUInt32;
|
||||
Function<Float> readFloat;
|
||||
Function<String> readString;
|
||||
|
||||
Property<Int> bitsUsed;
|
||||
Property<Int> bytesUsed;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
#include <CommonHeader.h>
|
||||
#include "Sky.h"
|
||||
|
||||
namespace nonut
|
||||
{
|
||||
Sky* Sky::get()
|
||||
{
|
||||
if (inst == nullptr)
|
||||
{
|
||||
inst = new Sky();
|
||||
}
|
||||
return inst;
|
||||
}
|
||||
|
||||
Sky::Sky() :
|
||||
StaticClass("Sky"),
|
||||
|
||||
PROPERTY_CTOR(weather),
|
||||
PROPERTY_CTOR(raining),
|
||||
PROPERTY_CTOR(renderLightning),
|
||||
PROPERTY_CTOR(windScale),
|
||||
PROPERTY_CTOR(dontRain),
|
||||
|
||||
METHOD_CTOR(getRainStartTime),
|
||||
METHOD_CTOR(getRainStopTime),
|
||||
METHOD_CTOR(setRainStartTime),
|
||||
METHOD_CTOR(setRainStopTime)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
#ifndef _SKY_H_
|
||||
#define _SKY_H_
|
||||
#include <string>
|
||||
|
||||
#include <StaticClass.h>
|
||||
#include <CustomTypes.h>
|
||||
|
||||
namespace nonut
|
||||
{
|
||||
class Sky : public StaticClass
|
||||
{
|
||||
public:
|
||||
static Sky* get();
|
||||
|
||||
Function<void, Int, Int> setRainStartTime;
|
||||
Function<SqDict> getRainStartTime;
|
||||
Function<void, Int, Int> setRainStopTime;
|
||||
Function<SqDict> getRainStopTime;
|
||||
|
||||
Property<Int> weather;
|
||||
Property<Bool> raining;
|
||||
Property<Bool> renderLightning;
|
||||
Property<Float> windScale;
|
||||
Property<Bool> dontRain;
|
||||
|
||||
private:
|
||||
|
||||
static inline Sky* inst = nullptr;
|
||||
|
||||
Sky();
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
#include <CommonHeader.h>
|
||||
#include "Way.h"
|
||||
|
||||
namespace nonut
|
||||
{
|
||||
Way::Way(String world, String startWp, String endWp) :
|
||||
Class("Way"),
|
||||
METHOD_CTOR(getWaypoints),
|
||||
METHOD_CTOR(getCountWaypoints),
|
||||
|
||||
PROPERTY_CTOR(start),
|
||||
PROPERTY_CTOR(end)
|
||||
{
|
||||
classCtor(world, startWp, endWp);
|
||||
}
|
||||
|
||||
Way::Way(SQObject object) :
|
||||
Class("Way", object),
|
||||
METHOD_CTOR(getWaypoints),
|
||||
METHOD_CTOR(getCountWaypoints),
|
||||
|
||||
PROPERTY_CTOR(start),
|
||||
PROPERTY_CTOR(end)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
#ifndef _WAY_H
|
||||
#define _WAY_H
|
||||
#include <string>
|
||||
|
||||
#include <Class.h>
|
||||
#include <CustomTypes.h>
|
||||
|
||||
namespace nonut
|
||||
{
|
||||
class Way : public Class
|
||||
{
|
||||
public:
|
||||
Way(String, String, String);
|
||||
explicit Way(SQObject object);
|
||||
|
||||
Property<String> start;
|
||||
Property<String> end;
|
||||
|
||||
Function<SqList> getWaypoints;
|
||||
Function<Int> getCountWaypoints;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
|
||||
target_sources(${PYG2O_MODULE_NAME}
|
||||
PRIVATE
|
||||
sqconstants.cpp
|
||||
)
|
||||
|
||||
target_include_directories(${PYG2O_MODULE_NAME}
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_LIST_DIR}/
|
||||
)
|
||||
@@ -1,297 +0,0 @@
|
||||
#include <sqapi.h>
|
||||
#include <pybind11/embed.h>
|
||||
#include "sqevents.h"
|
||||
#include "sqconstants.h"
|
||||
|
||||
namespace py = pybind11;
|
||||
extern py::module_ g2o;
|
||||
|
||||
#define GET_CONST(constName, constType) Sqrat::ConstTable().GetSlot(constName).Cast<constType>()
|
||||
|
||||
// Sadly, I have to split definition and declaration of constants, because pybind doesn't allow embeding modules inside functions
|
||||
// And in the global scope, Squirrel VM and const table is not yet exist
|
||||
|
||||
PYBIND11_EMBEDDED_MODULE(sqg2oconst, m) {
|
||||
m.attr("DAMAGE_CTX") = 0;
|
||||
m.attr("EQUIPMENT_CTX") = 0;
|
||||
|
||||
m.attr("DAMAGE_UNKNOW") = 0;
|
||||
m.attr("DAMAGE_BARRIER") = 0;
|
||||
m.attr("DAMAGE_BLUNT") = 0;
|
||||
m.attr("DAMAGE_EDGE") = 0;
|
||||
m.attr("DAMAGE_FIRE") = 0;
|
||||
m.attr("DAMAGE_FLY") = 0;
|
||||
m.attr("DAMAGE_MAGIC") = 0;
|
||||
m.attr("DAMAGE_POINT") = 0;
|
||||
m.attr("DAMAGE_FALL") = 0;
|
||||
|
||||
m.attr("DEBUG_MODE") = false;
|
||||
m.attr("SERVER_SIDE") = false;
|
||||
m.attr("CLIENT_SIDE") = false;
|
||||
|
||||
m.attr("HAND_LEFT") = 0;
|
||||
m.attr("HAND_RIGHT") = 0;
|
||||
|
||||
m.attr("ITEM_CAT_NONE") = 0;
|
||||
m.attr("ITEM_CAT_NF") = 0;
|
||||
m.attr("ITEM_CAT_FF") = 0;
|
||||
m.attr("ITEM_CAT_MUN") = 0;
|
||||
m.attr("ITEM_CAT_ARMOR") = 0;
|
||||
m.attr("ITEM_CAT_FOOD") = 0;
|
||||
m.attr("ITEM_CAT_DOCS") = 0;
|
||||
m.attr("ITEM_CAT_POTION") = 0;
|
||||
m.attr("ITEM_CAT_LIGHT") = 0;
|
||||
m.attr("ITEM_CAT_RUNE") = 0;
|
||||
m.attr("ITEM_CAT_MAGIC") = 0;
|
||||
|
||||
m.attr("ITEM_FLAG_DAG") = 0;
|
||||
m.attr("ITEM_FLAG_SWD") = 0;
|
||||
m.attr("ITEM_FLAG_AXE") = 0;
|
||||
m.attr("ITEM_FLAG_2HD_SWD") = 0;
|
||||
m.attr("ITEM_FLAG_2HD_AXE") = 0;
|
||||
m.attr("ITEM_FLAG_SHIELD") = 0;
|
||||
m.attr("ITEM_FLAG_BOW") = 0;
|
||||
m.attr("ITEM_FLAG_CROSSBOW") = 0;
|
||||
m.attr("ITEM_FLAG_RING") = 0;
|
||||
m.attr("ITEM_FLAG_AMULET") = 0;
|
||||
m.attr("ITEM_FLAG_BELT") = 0;
|
||||
m.attr("ITEM_FLAG_DROPPED") = 0;
|
||||
m.attr("ITEM_FLAG_MI") = 0;
|
||||
m.attr("ITEM_FLAG_MULTI") = 0;
|
||||
m.attr("ITEM_FLAG_NFOCUS") = 0;
|
||||
m.attr("ITEM_FLAG_CREATEAMMO") = 0;
|
||||
m.attr("ITEM_FLAG_NSPLIT") = 0;
|
||||
m.attr("ITEM_FLAG_DRINK") = 0;
|
||||
m.attr("ITEM_FLAG_TORCH") = 0;
|
||||
m.attr("ITEM_FLAG_THROW") = 0;
|
||||
m.attr("ITEM_FLAG_ACTIVE") = 0;
|
||||
|
||||
m.attr("ITEM_WEAR_NO") = 0;
|
||||
m.attr("ITEM_WEAR_TORSO") = 0;
|
||||
m.attr("ITEM_WEAR_HEAD") = 0;
|
||||
m.attr("ITEM_WEAR_LIGHT") = 0;
|
||||
|
||||
m.attr("ATTACK_RUN") = 0;
|
||||
m.attr("ATTACK_FORWARD") = 0;
|
||||
m.attr("ATTACK_LEFT") = 0;
|
||||
m.attr("ATTACK_RIGHT") = 0;
|
||||
m.attr("ACTION_CLEAR_QUEUE") = 0;
|
||||
m.attr("ACTION_APPLY_OVERLAY") = 0;
|
||||
m.attr("ACTION_REMOVE_OVERLAY") = 0;
|
||||
m.attr("ACTION_PLAY_ANI") = 0;
|
||||
m.attr("ACTION_STOP_ANI") = 0;
|
||||
m.attr("ACTION_EQUIP_ITEM") = 0;
|
||||
m.attr("ACTION_UNEQUIP_ITEM") = 0;
|
||||
m.attr("ACTION_WEAPON_MODE") = 0;
|
||||
m.attr("ACTION_DRAW_WEAPON") = 0;
|
||||
m.attr("ACTION_REMOVE_WEAPON") = 0;
|
||||
m.attr("ACTION_USE_ITEM") = 0;
|
||||
m.attr("ACTION_USE_ITEM_TO_STATE") = 0;
|
||||
m.attr("ACTION_READY_SPELL") = 0;
|
||||
m.attr("ACTION_UNREADY_SPELL") = 0;
|
||||
m.attr("ACTION_ATTACK_MELEE_WEAPON") = 0;
|
||||
m.attr("ACTION_ATTACK_RANGED_WEAPON") = 0;
|
||||
m.attr("ACTION_SPELL_CAST") = 0;
|
||||
m.attr("ACTION_USE_MOB_SCHEME") = 0;
|
||||
m.attr("ACTION_SHOOT_AT") = 0;
|
||||
m.attr("ACTION_START_AIM_AT") = 0;
|
||||
m.attr("ACTION_STOP_AIM_AT") = 0;
|
||||
m.attr("ACTION_SCRIPT") = 0;
|
||||
|
||||
m.attr("UNRELIABLE") = 0;
|
||||
m.attr("UNRELIABLE_SEQUENCED") = 0;
|
||||
m.attr("RELIABLE") = 0;
|
||||
m.attr("RELIABLE_ORDERED") = 0;
|
||||
m.attr("RELIABLE_SEQUENCED") = 0;
|
||||
|
||||
m.attr("WEAPON_1H") = 0;
|
||||
m.attr("WEAPON_2H") = 0;
|
||||
m.attr("WEAPON_BOW") = 0;
|
||||
m.attr("WEAPON_CBOW") = 0;
|
||||
|
||||
m.attr("TALENT_1H") = 0;
|
||||
m.attr("TALENT_2H") = 0;
|
||||
m.attr("TALENT_BOW") = 0;
|
||||
m.attr("TALENT_CROSSBOW") = 0;
|
||||
m.attr("TALENT_PICK_LOCKS") = 0;
|
||||
m.attr("TALENT_PICKPOCKET") = 0;
|
||||
m.attr("TALENT_MAGE") = 0;
|
||||
m.attr("TALENT_SNEAK") = 0;
|
||||
m.attr("TALENT_REGENERATE") = 0;
|
||||
m.attr("TALENT_FIREMASTER") = 0;
|
||||
m.attr("TALENT_ACROBATIC") = 0;
|
||||
m.attr("TALENT_PICKPOCKET_UNUSED") = 0;
|
||||
m.attr("TALENT_SMITH") = 0;
|
||||
m.attr("TALENT_RUNES") = 0;
|
||||
m.attr("TALENT_ALCHEMY") = 0;
|
||||
m.attr("TALENT_THROPHY") = 0;
|
||||
m.attr("TALENT_A") = 0;
|
||||
m.attr("TALENT_B") = 0;
|
||||
m.attr("TALENT_C") = 0;
|
||||
m.attr("TALENT_D") = 0;
|
||||
m.attr("TALENT_E") = 0;
|
||||
m.attr("TALENT_MAX") = 0;
|
||||
|
||||
m.attr("WEAPONMODE_NONE") = 0;
|
||||
m.attr("WEAPONMODE_FIST") = 0;
|
||||
m.attr("WEAPONMODE_DAG") = 0;
|
||||
m.attr("WEAPONMODE_1HS") = 0;
|
||||
m.attr("WEAPONMODE_2HS") = 0;
|
||||
m.attr("WEAPONMODE_BOW") = 0;
|
||||
m.attr("WEAPONMODE_CBOW") = 0;
|
||||
m.attr("WEAPONMODE_MAG") = 0;
|
||||
m.attr("WEAPONMODE_MAX") = 0;
|
||||
|
||||
m.attr("WEATHER_SNOW") = 0;
|
||||
m.attr("WEATHER_RAIN") = 0;
|
||||
|
||||
m.attr("AC_SPEED_HACK") = 0;
|
||||
|
||||
m.attr("DISCONNECTED") = 0;
|
||||
m.attr("LOST_CONNECTION") = 0;
|
||||
m.attr("HAS_CRASHED") = 0;
|
||||
}
|
||||
|
||||
void registerSquirrelConstants()
|
||||
{
|
||||
py::module_ cts = py::module_::import("sqg2oconst");
|
||||
|
||||
cts.attr("DAMAGE_CTX") = GET_CONST("DAMAGE_CTX", int);
|
||||
cts.attr("EQUIPMENT_CTX") = GET_CONST("EQUIPMENT_CTX", int);
|
||||
|
||||
cts.attr("DAMAGE_UNKNOWN") = GET_CONST("DAMAGE_UNKNOWN", int);
|
||||
cts.attr("DAMAGE_BARRIER") = GET_CONST("DAMAGE_BARRIER", int);
|
||||
cts.attr("DAMAGE_BLUNT") = GET_CONST("DAMAGE_BLUNT", int);
|
||||
cts.attr("DAMAGE_EDGE") = GET_CONST("DAMAGE_EDGE", int);
|
||||
cts.attr("DAMAGE_FIRE") = GET_CONST("DAMAGE_FIRE", int);
|
||||
cts.attr("DAMAGE_FLY") = GET_CONST("DAMAGE_FLY", int);
|
||||
cts.attr("DAMAGE_MAGIC") = GET_CONST("DAMAGE_MAGIC", int);
|
||||
cts.attr("DAMAGE_POINT") = GET_CONST("DAMAGE_POINT", int);
|
||||
cts.attr("DAMAGE_FALL") = GET_CONST("DAMAGE_FALL", int);
|
||||
|
||||
cts.attr("DEBUG_MODE") = GET_CONST("DEBUG_MODE", bool);
|
||||
cts.attr("SERVER_SIDE") = GET_CONST("SERVER_SIDE", bool);
|
||||
cts.attr("CLIENT_SIDE") = GET_CONST("CLIENT_SIDE", bool);
|
||||
|
||||
cts.attr("HAND_LEFT") = GET_CONST("HAND_LEFT", int);
|
||||
cts.attr("HAND_RIGHT") = GET_CONST("HAND_RIGHT", int);
|
||||
|
||||
cts.attr("ITEM_CAT_NONE") = GET_CONST("ITEM_CAT_NONE", int);
|
||||
cts.attr("ITEM_CAT_NF") = GET_CONST("ITEM_CAT_NF", int);
|
||||
cts.attr("ITEM_CAT_FF") = GET_CONST("ITEM_CAT_FF", int);
|
||||
cts.attr("ITEM_CAT_MUN") = GET_CONST("ITEM_CAT_MUN", int);
|
||||
cts.attr("ITEM_CAT_ARMOR") = GET_CONST("ITEM_CAT_ARMOR", int);
|
||||
cts.attr("ITEM_CAT_FOOD") = GET_CONST("ITEM_CAT_FOOD", int);
|
||||
cts.attr("ITEM_CAT_DOCS") = GET_CONST("ITEM_CAT_DOCS", int);
|
||||
cts.attr("ITEM_CAT_POTION") = GET_CONST("ITEM_CAT_POTION", int);
|
||||
cts.attr("ITEM_CAT_LIGHT") = GET_CONST("ITEM_CAT_LIGHT", int);
|
||||
cts.attr("ITEM_CAT_RUNE") = GET_CONST("ITEM_CAT_RUNE", int);
|
||||
cts.attr("ITEM_CAT_MAGIC") = GET_CONST("ITEM_CAT_MAGIC", int);
|
||||
|
||||
cts.attr("ITEM_FLAG_DAG") = GET_CONST("ITEM_FLAG_DAG", int);
|
||||
cts.attr("ITEM_FLAG_SWD") = GET_CONST("ITEM_FLAG_SWD", int);
|
||||
cts.attr("ITEM_FLAG_AXE") = GET_CONST("ITEM_FLAG_AXE", int);
|
||||
cts.attr("ITEM_FLAG_2HD_SWD") = GET_CONST("ITEM_FLAG_2HD_SWD", int);
|
||||
cts.attr("ITEM_FLAG_2HD_AXE") = GET_CONST("ITEM_FLAG_2HD_AXE", int);
|
||||
cts.attr("ITEM_FLAG_SHIELD") = GET_CONST("ITEM_FLAG_SHIELD", int);
|
||||
cts.attr("ITEM_FLAG_BOW") = GET_CONST("ITEM_FLAG_BOW", int);
|
||||
cts.attr("ITEM_FLAG_CROSSBOW") = GET_CONST("ITEM_FLAG_CROSSBOW", int);
|
||||
cts.attr("ITEM_FLAG_RING") = GET_CONST("ITEM_FLAG_RING", int);
|
||||
cts.attr("ITEM_FLAG_AMULET") = GET_CONST("ITEM_FLAG_AMULET", int);
|
||||
cts.attr("ITEM_FLAG_BELT") = GET_CONST("ITEM_FLAG_BELT", int);
|
||||
cts.attr("ITEM_FLAG_DROPPED") = GET_CONST("ITEM_FLAG_DROPPED", int);
|
||||
cts.attr("ITEM_FLAG_MI") = GET_CONST("ITEM_FLAG_MI", int);
|
||||
cts.attr("ITEM_FLAG_MULTI") = GET_CONST("ITEM_FLAG_MULTI", int);
|
||||
cts.attr("ITEM_FLAG_NFOCUS") = GET_CONST("ITEM_FLAG_NFOCUS", int);
|
||||
cts.attr("ITEM_FLAG_CREATEAMMO") = GET_CONST("ITEM_FLAG_CREATEAMMO", int);
|
||||
cts.attr("ITEM_FLAG_NSPLIT") = GET_CONST("ITEM_FLAG_NSPLIT", int);
|
||||
cts.attr("ITEM_FLAG_DRINK") = GET_CONST("ITEM_FLAG_DRINK", int);
|
||||
cts.attr("ITEM_FLAG_TORCH") = GET_CONST("ITEM_FLAG_TORCH", int);
|
||||
cts.attr("ITEM_FLAG_THROW") = GET_CONST("ITEM_FLAG_THROW", int);
|
||||
cts.attr("ITEM_FLAG_ACTIVE") = GET_CONST("ITEM_FLAG_ACTIVE", int);
|
||||
|
||||
cts.attr("ITEM_WEAR_NO") = GET_CONST("ITEM_WEAR_NO", int);
|
||||
cts.attr("ITEM_WEAR_TORSO") = GET_CONST("ITEM_WEAR_TORSO", int);
|
||||
cts.attr("ITEM_WEAR_HEAD") = GET_CONST("ITEM_WEAR_HEAD", int);
|
||||
cts.attr("ITEM_WEAR_LIGHT") = GET_CONST("ITEM_WEAR_LIGHT", int);
|
||||
|
||||
cts.attr("ATTACK_RUN") = GET_CONST("ATTACK_RUN", int);
|
||||
cts.attr("ATTACK_FORWARD") = GET_CONST("ATTACK_FORWARD", int);
|
||||
cts.attr("ATTACK_LEFT") = GET_CONST("ATTACK_LEFT", int);
|
||||
cts.attr("ATTACK_RIGHT") = GET_CONST("ATTACK_RIGHT", int);
|
||||
cts.attr("ACTION_CLEAR_QUEUE") = GET_CONST("ACTION_CLEAR_QUEUE", int);
|
||||
cts.attr("ACTION_APPLY_OVERLAY") = GET_CONST("ACTION_APPLY_OVERLAY", int);
|
||||
cts.attr("ACTION_REMOVE_OVERLAY") = GET_CONST("ACTION_REMOVE_OVERLAY", int);
|
||||
cts.attr("ACTION_PLAY_ANI") = GET_CONST("ACTION_PLAY_ANI", int);
|
||||
cts.attr("ACTION_STOP_ANI") = GET_CONST("ACTION_STOP_ANI", int);
|
||||
cts.attr("ACTION_EQUIP_ITEM") = GET_CONST("ACTION_EQUIP_ITEM", int);
|
||||
cts.attr("ACTION_UNEQUIP_ITEM") = GET_CONST("ACTION_UNEQUIP_ITEM", int);
|
||||
cts.attr("ACTION_WEAPON_MODE") = GET_CONST("ACTION_WEAPON_MODE", int);
|
||||
cts.attr("ACTION_DRAW_WEAPON") = GET_CONST("ACTION_DRAW_WEAPON", int);
|
||||
cts.attr("ACTION_REMOVE_WEAPON") = GET_CONST("ACTION_REMOVE_WEAPON", int);
|
||||
cts.attr("ACTION_USE_ITEM") = GET_CONST("ACTION_USE_ITEM", int);
|
||||
cts.attr("ACTION_USE_ITEM_TO_STATE") = GET_CONST("ACTION_USE_ITEM_TO_STATE", int);
|
||||
cts.attr("ACTION_READY_SPELL") = GET_CONST("ACTION_READY_SPELL", int);
|
||||
cts.attr("ACTION_UNREADY_SPELL") = GET_CONST("ACTION_UNREADY_SPELL", int);
|
||||
cts.attr("ACTION_ATTACK_MELEE_WEAPON") = GET_CONST("ACTION_ATTACK_MELEE_WEAPON", int);
|
||||
cts.attr("ACTION_ATTACK_RANGED_WEAPON") = GET_CONST("ACTION_ATTACK_RANGED_WEAPON", int);
|
||||
cts.attr("ACTION_SPELL_CAST") = GET_CONST("ACTION_SPELL_CAST", int);
|
||||
cts.attr("ACTION_USE_MOB_SCHEME") = GET_CONST("ACTION_USE_MOB_SCHEME", int);
|
||||
cts.attr("ACTION_SHOOT_AT") = GET_CONST("ACTION_SHOOT_AT", int);
|
||||
cts.attr("ACTION_START_AIM_AT") = GET_CONST("ACTION_START_AIM_AT", int);
|
||||
cts.attr("ACTION_STOP_AIM_AT") = GET_CONST("ACTION_STOP_AIM_AT", int);
|
||||
cts.attr("ACTION_SCRIPT") = GET_CONST("ACTION_SCRIPT", int);
|
||||
|
||||
cts.attr("UNRELIABLE") = GET_CONST("UNRELIABLE", int);
|
||||
cts.attr("UNRELIABLE_SEQUENCED") = GET_CONST("UNRELIABLE_SEQUENCED", int);
|
||||
cts.attr("RELIABLE") = GET_CONST("RELIABLE", int);
|
||||
cts.attr("RELIABLE_ORDERED") = GET_CONST("RELIABLE_ORDERED", int);
|
||||
cts.attr("RELIABLE_SEQUENCED") = GET_CONST("RELIABLE_SEQUENCED", int);
|
||||
|
||||
cts.attr("WEAPON_1H") = GET_CONST("WEAPON_1H", int);
|
||||
cts.attr("WEAPON_2H") = GET_CONST("WEAPON_2H", int);
|
||||
cts.attr("WEAPON_BOW") = GET_CONST("WEAPON_BOW", int);
|
||||
cts.attr("WEAPON_CBOW") = GET_CONST("WEAPON_CBOW", int);
|
||||
|
||||
cts.attr("TALENT_1H") = GET_CONST("TALENT_1H", int);
|
||||
cts.attr("TALENT_2H") = GET_CONST("TALENT_2H", int);
|
||||
cts.attr("TALENT_BOW") = GET_CONST("TALENT_BOW", int);
|
||||
cts.attr("TALENT_CROSSBOW") = GET_CONST("TALENT_CROSSBOW", int);
|
||||
cts.attr("TALENT_PICK_LOCKS") = GET_CONST("TALENT_PICK_LOCKS", int);
|
||||
cts.attr("TALENT_PICKPOCKET") = GET_CONST("TALENT_PICKPOCKET", int);
|
||||
cts.attr("TALENT_MAGE") = GET_CONST("TALENT_MAGE", int);
|
||||
cts.attr("TALENT_SNEAK") = GET_CONST("TALENT_SNEAK", int);
|
||||
cts.attr("TALENT_REGENERATE") = GET_CONST("TALENT_REGENERATE", int);
|
||||
cts.attr("TALENT_FIREMASTER") = GET_CONST("TALENT_FIREMASTER", int);
|
||||
cts.attr("TALENT_ACROBATIC") = GET_CONST("TALENT_ACROBATIC", int);
|
||||
cts.attr("TALENT_PICKPOCKET_UNUSED") = GET_CONST("TALENT_PICKPOCKET_UNUSED", int);
|
||||
cts.attr("TALENT_SMITH") = GET_CONST("TALENT_SMITH", int);
|
||||
cts.attr("TALENT_RUNES") = GET_CONST("TALENT_RUNES", int);
|
||||
cts.attr("TALENT_ALCHEMY") = GET_CONST("TALENT_ALCHEMY", int);
|
||||
cts.attr("TALENT_THROPHY") = GET_CONST("TALENT_THROPHY", int);
|
||||
cts.attr("TALENT_A") = GET_CONST("TALENT_A", int);
|
||||
cts.attr("TALENT_B") = GET_CONST("TALENT_B", int);
|
||||
cts.attr("TALENT_C") = GET_CONST("TALENT_C", int);
|
||||
cts.attr("TALENT_D") = GET_CONST("TALENT_D", int);
|
||||
cts.attr("TALENT_E") = GET_CONST("TALENT_E", int);
|
||||
cts.attr("TALENT_MAX") = GET_CONST("TALENT_MAX", int);
|
||||
|
||||
cts.attr("WEAPONMODE_NONE") = GET_CONST("WEAPONMODE_NONE", int);
|
||||
cts.attr("WEAPONMODE_FIST") = GET_CONST("WEAPONMODE_FIST", int);
|
||||
cts.attr("WEAPONMODE_DAG") = GET_CONST("WEAPONMODE_DAG", int);
|
||||
cts.attr("WEAPONMODE_1HS") = GET_CONST("WEAPONMODE_1HS", int);
|
||||
cts.attr("WEAPONMODE_2HS") = GET_CONST("WEAPONMODE_2HS", int);
|
||||
cts.attr("WEAPONMODE_BOW") = GET_CONST("WEAPONMODE_BOW", int);
|
||||
cts.attr("WEAPONMODE_CBOW") = GET_CONST("WEAPONMODE_CBOW", int);
|
||||
cts.attr("WEAPONMODE_MAG") = GET_CONST("WEAPONMODE_MAG", int);
|
||||
cts.attr("WEAPONMODE_MAX") = GET_CONST("WEAPONMODE_MAX", int);
|
||||
|
||||
cts.attr("WEATHER_SNOW") = GET_CONST("WEATHER_SNOW", int);
|
||||
cts.attr("WEATHER_RAIN") = GET_CONST("WEATHER_RAIN", int);
|
||||
|
||||
cts.attr("AC_SPEED_HACK") = GET_CONST("AC_SPEED_HACK", int);
|
||||
|
||||
cts.attr("DISCONNECTED") = GET_CONST("DISCONNECTED", int);
|
||||
cts.attr("LOST_CONNECTION") = GET_CONST("LOST_CONNECTION", int);
|
||||
cts.attr("HAS_CRASHED") = GET_CONST("HAS_CRASHED", int);
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
#ifndef _SQCONSTANTS_H_
|
||||
#define _SQCONSTANTS_H_
|
||||
|
||||
void registerSquirrelConstants();
|
||||
|
||||
#endif
|
||||
@@ -1,13 +0,0 @@
|
||||
add_subdirectory(sqapi)
|
||||
add_subdirectory(pybind11)
|
||||
|
||||
target_link_libraries(${PYG2O_MODULE_NAME}
|
||||
PRIVATE
|
||||
sqapi
|
||||
pybind11::embed
|
||||
)
|
||||
|
||||
target_compile_definitions(${PYG2O_MODULE_NAME}
|
||||
PRIVATE
|
||||
SCRAT_EXPORT
|
||||
)
|
||||
Submodule source/dependencies/pybind11 deleted from 15d9dae14b
Submodule source/dependencies/sqapi deleted from 2ae81b0f2b
@@ -1,16 +0,0 @@
|
||||
|
||||
|
||||
target_sources(${PYG2O_MODULE_NAME}
|
||||
PRIVATE
|
||||
sqevents.cpp
|
||||
sqevents_anticheat.cpp
|
||||
sqevents_general.cpp
|
||||
sqevents_network.cpp
|
||||
sqevents_npc.cpp
|
||||
sqevents_player.cpp
|
||||
)
|
||||
|
||||
target_include_directories(${PYG2O_MODULE_NAME}
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_LIST_DIR}/
|
||||
)
|
||||
@@ -1,101 +0,0 @@
|
||||
#include <sqapi.h>
|
||||
#include <pybind11/embed.h>
|
||||
#include "sqevents.h"
|
||||
|
||||
namespace py = pybind11;
|
||||
using namespace pybind11::literals;
|
||||
|
||||
extern py::module_ g2o;
|
||||
|
||||
void addEventHandler(const char* eventName, SQFUNCTION closure, unsigned int priority = 9999)
|
||||
{
|
||||
using namespace SqModule;
|
||||
|
||||
Sqrat::Function sq_addEventHandler = Sqrat::RootTable().GetFunction("addEventHandler");
|
||||
|
||||
if (sq_addEventHandler.IsNull())
|
||||
return;
|
||||
|
||||
HSQOBJECT closureHandle;
|
||||
|
||||
sq_newclosure(vm, closure, 0);
|
||||
sq_getstackobj(vm, -1, &closureHandle);
|
||||
|
||||
Sqrat::Function func(vm, Sqrat::RootTable().GetObject(), closureHandle);
|
||||
sq_addEventHandler(eventName, func, priority);
|
||||
|
||||
sq_pop(vm, 1);
|
||||
}
|
||||
|
||||
void callEvent(const char* eventName, py::dict kwargs)
|
||||
{
|
||||
try
|
||||
{
|
||||
bool result = g2o.attr("callEvent")(eventName, **kwargs).cast<bool>();
|
||||
if (result)
|
||||
{
|
||||
Sqrat::RootTable().GetFunction("cancelEvent").Execute();
|
||||
}
|
||||
}
|
||||
catch (py::error_already_set &e)
|
||||
{
|
||||
py::print(e.what());
|
||||
}
|
||||
}
|
||||
|
||||
void registerSquirrelEvents()
|
||||
{
|
||||
addEventHandler("onInit", sq_onInit, 0);
|
||||
addEventHandler("onExit", sq_onExit, 0);
|
||||
addEventHandler("onTick", sq_onTick, 0);
|
||||
addEventHandler("onTime", sq_onTime, 0);
|
||||
addEventHandler("onBan", sq_onBan, 0);
|
||||
addEventHandler("onUnban", sq_onUnban, 0);
|
||||
|
||||
addEventHandler("onPlayerChangeColor", sq_onPlayerChangeColor, 0);
|
||||
addEventHandler("onPlayerChangeFocus", sq_onPlayerChangeFocus, 0);
|
||||
addEventHandler("onPlayerChangeHealth", sq_onPlayerChangeHealth, 0);
|
||||
addEventHandler("onPlayerChangeMana", sq_onPlayerChangeMana, 0);
|
||||
addEventHandler("onPlayerChangeMaxHealth", sq_onPlayerChangeMaxHealth, 0);
|
||||
addEventHandler("onPlayerChangeMaxMana", sq_onPlayerChangeMaxMana, 0);
|
||||
addEventHandler("onPlayerChangeWeaponMode", sq_onPlayerChangeWeaponMode, 0);
|
||||
addEventHandler("onPlayerChangeWorld", sq_onPlayerChangeWorld, 0);
|
||||
|
||||
addEventHandler("onPlayerCommand", sq_onPlayerCommand, 0);
|
||||
addEventHandler("onPlayerDamage", sq_onPlayerDamage, 0);
|
||||
addEventHandler("onPlayerDead", sq_onPlayerDead, 0);
|
||||
addEventHandler("onPlayerDisconnect", sq_onPlayerDisconnect, 0);
|
||||
addEventHandler("onPlayerDropItem", sq_onPlayerDropItem, 0);
|
||||
addEventHandler("onPlayerEnterWorld", sq_onPlayerEnterWorld, 0);
|
||||
addEventHandler("onPlayerJoin", sq_onPlayerJoin, 0);
|
||||
addEventHandler("onPlayerMessage", sq_onPlayerMessage, 0);
|
||||
addEventHandler("onPlayerMobInteract", sq_onPlayerMobInteract, 0);
|
||||
addEventHandler("onPlayerRespawn", sq_onPlayerRespawn, 0);
|
||||
addEventHandler("onPlayerShoot", sq_onPlayerShoot, 0);
|
||||
addEventHandler("onPlayerSpellCast", sq_onPlayerSpellCast, 0);
|
||||
addEventHandler("onPlayerSpellSetup", sq_onPlayerSpellSetup, 0);
|
||||
addEventHandler("onPlayerTakeItem", sq_onPlayerTakeItem, 0);
|
||||
addEventHandler("onPlayerTeleport", sq_onPlayerTeleport, 0);
|
||||
addEventHandler("onPlayerToggleFaceAni", sq_onPlayerToggleFaceAni, 0);
|
||||
|
||||
addEventHandler("onPlayerEquipAmulet", sq_onPlayerEquipAmulet, 0);
|
||||
addEventHandler("onPlayerEquipArmor", sq_onPlayerEquipArmor, 0);
|
||||
addEventHandler("onPlayerEquipBelt", sq_onPlayerEquipBelt, 0);
|
||||
addEventHandler("onPlayerEquipHandItem", sq_onPlayerEquipHandItem, 0);
|
||||
addEventHandler("onPlayerEquipHelmet", sq_onPlayerEquipHelmet, 0);
|
||||
addEventHandler("onPlayerEquipMeleeWeapon", sq_onPlayerEquipMeleeWeapon, 0);
|
||||
addEventHandler("onPlayerEquipRangedWeapon", sq_onPlayerEquipRangedWeapon, 0);
|
||||
addEventHandler("onPlayerEquipRing", sq_onPlayerEquipRing, 0);
|
||||
addEventHandler("onPlayerEquipShield", sq_onPlayerEquipShield, 0);
|
||||
addEventHandler("onPlayerEquipSpell", sq_onPlayerEquipSpell, 0);
|
||||
|
||||
addEventHandler("onPacket", sq_onPacket, 0);
|
||||
|
||||
addEventHandler("onPlayerUseCheat", sq_onPlayerUseCheat, 0);
|
||||
|
||||
addEventHandler("onNpcActionFinished", sq_onNpcActionFinished, 0);
|
||||
addEventHandler("onNpcActionSent", sq_onNpcActionSent, 0);
|
||||
addEventHandler("onNpcChangeHostPlayer", sq_onNpcChangeHostPlayer, 0);
|
||||
addEventHandler("onNpcCreated", sq_onNpcCreated, 0);
|
||||
addEventHandler("onNpcDestroyed", sq_onNpcDestroyed, 0);
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
#ifndef _SQEVENTS_H_
|
||||
#define _SQEVENTS_H
|
||||
|
||||
namespace py = pybind11;
|
||||
using namespace pybind11::literals;
|
||||
|
||||
void callEvent(const char*, py::dict);
|
||||
|
||||
SQInteger sq_onInit(HSQUIRRELVM);
|
||||
SQInteger sq_onExit(HSQUIRRELVM);
|
||||
SQInteger sq_onTick(HSQUIRRELVM);
|
||||
SQInteger sq_onTime(HSQUIRRELVM);
|
||||
SQInteger sq_onBan(HSQUIRRELVM);
|
||||
SQInteger sq_onUnban(HSQUIRRELVM);
|
||||
|
||||
SQInteger sq_onPlayerChangeColor(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerChangeFocus(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerChangeHealth(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerChangeMana(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerChangeMaxHealth(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerChangeMaxMana(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerChangeWeaponMode(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerChangeWorld(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerCommand(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerDamage(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerDead(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerDisconnect(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerDropItem(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerEnterWorld(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerEquipAmulet(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerEquipArmor(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerEquipBelt(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerEquipHandItem(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerEquipHelmet(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerEquipMeleeWeapon(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerEquipRangedWeapon(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerEquipRing(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerEquipShield(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerEquipSpell(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerJoin(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerMessage(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerMobInteract(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerRespawn(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerShoot(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerSpellCast(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerSpellSetup(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerTakeItem(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerTeleport(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerToggleFaceAni(HSQUIRRELVM);
|
||||
|
||||
SQInteger sq_onPacket(HSQUIRRELVM);
|
||||
|
||||
SQInteger sq_onPlayerUseCheat(HSQUIRRELVM);
|
||||
|
||||
SQInteger sq_onNpcActionFinished(HSQUIRRELVM);
|
||||
SQInteger sq_onNpcActionSent(HSQUIRRELVM);
|
||||
SQInteger sq_onNpcChangeHostPlayer(HSQUIRRELVM);
|
||||
SQInteger sq_onNpcCreated(HSQUIRRELVM);
|
||||
SQInteger sq_onNpcDestroyed(HSQUIRRELVM);
|
||||
|
||||
void registerSquirrelEvents();
|
||||
|
||||
#endif
|
||||
@@ -1,17 +0,0 @@
|
||||
#include <sqapi.h>
|
||||
#include <pybind11/embed.h>
|
||||
#include <Utils.h>
|
||||
#include "sqevents.h"
|
||||
|
||||
SQInteger sq_onPlayerUseCheat(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid, type;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &type);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "type"_a=type);
|
||||
callEvent("onPlayerUseCheat", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
#include <sqapi.h>
|
||||
#include <pybind11/embed.h>
|
||||
#include <Utils.h>
|
||||
#include <CustomTypes.h>
|
||||
#include "sqevents.h"
|
||||
|
||||
namespace py = pybind11;
|
||||
using namespace pybind11::literals;
|
||||
|
||||
extern py::module_ g2o;
|
||||
|
||||
SQInteger sq_onInit(HSQUIRRELVM vm)
|
||||
{
|
||||
py::object result = g2o.attr("callEvent")("onInit");
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onExit(HSQUIRRELVM vm)
|
||||
{
|
||||
py::object result = g2o.attr("callEvent")("onExit");
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onTick(HSQUIRRELVM vm)
|
||||
{
|
||||
py::object result = g2o.attr("callEvent")("onTick");
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onTime(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger day, hour, min;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &day);
|
||||
nonut::sqGetValue(vm, 3, &hour);
|
||||
nonut::sqGetValue(vm, 4, &min);
|
||||
|
||||
py::dict kwargs = py::dict("day"_a=day, "hour"_a=hour, "min"_a=min);
|
||||
callEvent("onTime", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onBan(HSQUIRRELVM vm)
|
||||
{
|
||||
HSQOBJECT obj;
|
||||
nonut::sqGetValue(vm, 2, &obj);
|
||||
|
||||
nonut::SqDict dictData;
|
||||
dictData.convert(obj);
|
||||
callEvent("onBan", dictData.data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onUnban(HSQUIRRELVM vm)
|
||||
{
|
||||
HSQOBJECT obj;
|
||||
nonut::sqGetValue(vm, 2, &obj);
|
||||
|
||||
nonut::SqDict dictData;
|
||||
dictData.convert(obj);
|
||||
callEvent("onUnban", dictData.data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
#include <sqapi.h>
|
||||
#include <pybind11/embed.h>
|
||||
#include <Utils.h>
|
||||
#include "python/Packet.h"
|
||||
#include "sqevents.h"
|
||||
|
||||
namespace py = pybind11;
|
||||
using namespace pybind11::literals;
|
||||
|
||||
extern py::module_ g2o;
|
||||
|
||||
SQInteger sq_onPacket(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid;
|
||||
HSQOBJECT data;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &data);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "data"_a=PyPacket(data));
|
||||
callEvent("onPacket", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
#include <sqapi.h>
|
||||
#include <pybind11/embed.h>
|
||||
#include <Utils.h>
|
||||
#include "sqevents.h"
|
||||
|
||||
SQInteger sq_onNpcActionFinished(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger npc_id, action_type, action_id;
|
||||
SQBool result;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &npc_id);
|
||||
nonut::sqGetValue(vm, 3, &action_type);
|
||||
nonut::sqGetValue(vm, 4, &action_id);
|
||||
nonut::sqGetValue(vm, 5, &result);
|
||||
|
||||
py::dict kwargs = py::dict("npc_id"_a=npc_id, "action_type"_a=action_type, "action_id"_a=action_id, "result"_a=result);
|
||||
callEvent("onNpcActionFinished", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onNpcActionSent(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger npc_id, action_type, action_id;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &npc_id);
|
||||
nonut::sqGetValue(vm, 3, &action_type);
|
||||
nonut::sqGetValue(vm, 4, &action_id);
|
||||
|
||||
py::dict kwargs = py::dict("npc_id"_a=npc_id, "action_type"_a=action_type, "action_id"_a=action_id);
|
||||
callEvent("onNpcActionSent", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onNpcChangeHostPlayer(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger npc_id, current_id, previous_id;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &npc_id);
|
||||
nonut::sqGetValue(vm, 3, ¤t_id);
|
||||
nonut::sqGetValue(vm, 4, &previous_id);
|
||||
|
||||
py::dict kwargs = py::dict("npc_id"_a=npc_id, "current_id"_a=current_id, "previous_id"_a=previous_id);
|
||||
callEvent("onNpcChangeHostPlayer", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onNpcCreated(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger npc_id;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &npc_id);
|
||||
|
||||
py::dict kwargs = py::dict("npc_id"_a=npc_id);
|
||||
callEvent("onNpcCreated", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onNpcDestroyed(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger npc_id;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &npc_id);
|
||||
|
||||
py::dict kwargs = py::dict("npc_id"_a=npc_id);
|
||||
callEvent("onNpcDestroyed", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,512 +0,0 @@
|
||||
#include <sqapi.h>
|
||||
#include <pybind11/embed.h>
|
||||
#include <Utils.h>
|
||||
#include "python/DamageDescription.h"
|
||||
#include "python/ItemGround.h"
|
||||
#include "sqevents.h"
|
||||
|
||||
namespace py = pybind11;
|
||||
using namespace pybind11::literals;
|
||||
|
||||
extern py::module_ g2o;
|
||||
|
||||
SQInteger sq_onPlayerChangeColor(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid, r, g, b;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &r);
|
||||
nonut::sqGetValue(vm, 4, &g);
|
||||
nonut::sqGetValue(vm, 5, &b);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "r"_a=r, "g"_a=g, "b"_a=b);
|
||||
callEvent("onPlayerChangeColor", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerChangeFocus(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid, oldFocusId, newFocusId;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &oldFocusId);
|
||||
nonut::sqGetValue(vm, 4, &newFocusId);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "oldFocusId"_a=oldFocusId, "newFocusId"_a=newFocusId);
|
||||
callEvent("onPlayerChangeFocus", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerChangeHealth(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid, oldHP, newHP;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &oldHP);
|
||||
nonut::sqGetValue(vm, 4, &newHP);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "oldHP"_a=oldHP, "newHP"_a=newHP);
|
||||
callEvent("onPlayerChangeHealth", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerChangeMana(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid, oldMP, newMP;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &oldMP);
|
||||
nonut::sqGetValue(vm, 4, &newMP);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "oldMP"_a=oldMP, "newMP"_a=newMP);
|
||||
callEvent("onPlayerChangeMana", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerChangeMaxHealth(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid, oldMaxHP, newMaxHP;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &oldMaxHP);
|
||||
nonut::sqGetValue(vm, 4, &newMaxHP);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "oldMaxHP"_a=oldMaxHP, "newMaxHP"_a=newMaxHP);
|
||||
callEvent("onPlayerChangeMaxHealth", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerChangeMaxMana(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid, oldMaxMP, newMaxMP;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &oldMaxMP);
|
||||
nonut::sqGetValue(vm, 4, &newMaxMP);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "oldMaxMP"_a=oldMaxMP, "newMaxMP"_a=newMaxMP);
|
||||
callEvent("onPlayerChangeMaxMana", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerChangeWeaponMode(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid, oldWeaponMode, newWeaponMode;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &oldWeaponMode);
|
||||
nonut::sqGetValue(vm, 4, &newWeaponMode);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "oldWeaponMode"_a=oldWeaponMode, "newWeaponMode"_a=newWeaponMode);
|
||||
callEvent("onPlayerChangeWeaponMode", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerChangeWorld(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid;
|
||||
const SQChar* world = nullptr;
|
||||
const SQChar* waypoint = nullptr;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &world);
|
||||
nonut::sqGetValue(vm, 4, &waypoint);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "world"_a=world, "waypoint"_a=waypoint);
|
||||
callEvent("onPlayerChangeWorld", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------
|
||||
|
||||
SQInteger sq_onPlayerCommand(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid;
|
||||
const SQChar* command;
|
||||
const SQChar* params;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &command);
|
||||
nonut::sqGetValue(vm, 4, ¶ms);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "command"_a=command, "params"_a=params);
|
||||
callEvent("onPlayerCommand", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerDamage(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid, killerid;
|
||||
HSQOBJECT sqobj;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &killerid);
|
||||
nonut::sqGetValue(vm, 4, &sqobj);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "killerid"_a=killerid, "description"_a=PyDamageDescription(sqobj));
|
||||
callEvent("onPlayerDamage", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerDead(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid, killerid;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &killerid);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "killerid"_a=killerid);
|
||||
callEvent("onPlayerDead", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerDisconnect(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid, reason;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &reason);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "reason"_a=reason);
|
||||
callEvent("onPlayerDisconnect", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerDropItem(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid;
|
||||
HSQOBJECT sqobj;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &sqobj);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "itemGround"_a=PyItemGround(sqobj));
|
||||
callEvent("onPlayerDropItem", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerEnterWorld(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid;
|
||||
const SQChar* world;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &world);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "world"_a=world);
|
||||
callEvent("onPlayerEnterWorld", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerJoin(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid);
|
||||
callEvent("onPlayerJoin", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerMessage(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid;
|
||||
const SQChar* message;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &message);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "message"_a=message);
|
||||
callEvent("onPlayerMessage", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerMobInteract(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid, from, to;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &from);
|
||||
nonut::sqGetValue(vm, 3, &to);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "from"_a=from, "to"_a = to);
|
||||
callEvent("onPlayerMobInteract", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerRespawn(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid);
|
||||
callEvent("onPlayerRespawn", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerShoot(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid;
|
||||
const SQChar* munition;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
if (sq_gettype(vm, 3) != OT_NULL)
|
||||
nonut::sqGetValue(vm, 3, &munition);
|
||||
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "munition"_a=munition);
|
||||
callEvent("onPlayerShoot", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerSpellCast(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid;
|
||||
const SQChar* instance;
|
||||
SQInteger spellLevel;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
if (sq_gettype(vm, 3) != OT_NULL)
|
||||
nonut::sqGetValue(vm, 3, &instance);
|
||||
nonut::sqGetValue(vm, 4, &spellLevel);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "instance"_a=instance, "spellLevel"_a=spellLevel);
|
||||
callEvent("onPlayerSpellCast", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerSpellSetup(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid;
|
||||
const SQChar* instance;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
if (sq_gettype(vm, 3) != OT_NULL)
|
||||
nonut::sqGetValue(vm, 3, &instance);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "instance"_a=instance);
|
||||
callEvent("onPlayerSpellSetup", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerTakeItem(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid;
|
||||
HSQOBJECT sqobj;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &sqobj);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "itemGround"_a=PyItemGround(sqobj));
|
||||
callEvent("onPlayerTakeItem", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerTeleport(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid;
|
||||
const SQChar* vobName;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &vobName);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "vobName"_a=vobName);
|
||||
callEvent("onPlayerTeleport", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerToggleFaceAni(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid;
|
||||
const SQChar* aniName;
|
||||
SQBool toggle;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &aniName);
|
||||
nonut::sqGetValue(vm, 4, &toggle);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "vobName"_a=aniName, "toggle"_a = toggle);
|
||||
callEvent("onPlayerToggleFaceAni", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------
|
||||
|
||||
SQInteger sq_onPlayerEquipAmulet(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid;
|
||||
const SQChar* instance = "";
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
if (sq_gettype(vm, 3) != OT_NULL)
|
||||
nonut::sqGetValue(vm, 3, &instance);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "instance"_a=instance);
|
||||
callEvent("onPlayerEquipAmulet", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerEquipArmor(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid;
|
||||
const SQChar* instance = "";
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
if (sq_gettype(vm, 3) != OT_NULL)
|
||||
nonut::sqGetValue(vm, 3, &instance);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "instance"_a=instance);
|
||||
callEvent("onPlayerEquipArmor", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerEquipBelt(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid;
|
||||
const SQChar* instance = "";
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
if (sq_gettype(vm, 3) != OT_NULL)
|
||||
nonut::sqGetValue(vm, 3, &instance);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "instance"_a=instance);
|
||||
callEvent("onPlayerEquipBelt", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerEquipHandItem(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid, hand;
|
||||
const SQChar* instance = "";
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &hand);
|
||||
if (sq_gettype(vm, 4) != OT_NULL)
|
||||
nonut::sqGetValue(vm, 4, &instance);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "hand"_a = hand, "instance"_a=instance);
|
||||
callEvent("onPlayerEquipHandItem", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerEquipHelmet(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid;
|
||||
const SQChar* instance = "";
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
if (sq_gettype(vm, 3) != OT_NULL)
|
||||
nonut::sqGetValue(vm, 3, &instance);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "instance"_a=instance);
|
||||
callEvent("onPlayerEquipHelmet", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerEquipMeleeWeapon(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid;
|
||||
const SQChar* instance = "";
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
if (sq_gettype(vm, 3) != OT_NULL)
|
||||
nonut::sqGetValue(vm, 3, &instance);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "instance"_a=instance);
|
||||
callEvent("onPlayerEquipMeleeWeapon", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerEquipRangedWeapon(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid;
|
||||
const SQChar* instance = "";
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
if (sq_gettype(vm, 3) != OT_NULL)
|
||||
nonut::sqGetValue(vm, 3, &instance);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "instance"_a=instance);
|
||||
callEvent("onPlayerEquipRangedWeapon", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerEquipRing(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid, hand;
|
||||
const SQChar* instance = "";
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &hand);
|
||||
if (sq_gettype(vm, 4) != OT_NULL)
|
||||
nonut::sqGetValue(vm, 4, &instance);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "hand"_a = hand, "instance"_a=instance);
|
||||
callEvent("onPlayerEquipRing", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerEquipShield(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid;
|
||||
const SQChar* instance = "";
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
if (sq_gettype(vm, 3) != OT_NULL)
|
||||
nonut::sqGetValue(vm, 3, &instance);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "instance"_a=instance);
|
||||
callEvent("onPlayerEquipShield", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerEquipSpell(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid, slotId;
|
||||
const SQChar* instance = "";
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &slotId);
|
||||
if (sq_gettype(vm, 4) != OT_NULL)
|
||||
nonut::sqGetValue(vm, 4, &instance);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "slotId"_a = slotId, "instance"_a=instance);
|
||||
callEvent("onPlayerEquipSpell", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
|
||||
target_sources(${PYG2O_MODULE_NAME}
|
||||
PRIVATE
|
||||
python/functions.cpp
|
||||
squirrel/functions.cpp
|
||||
)
|
||||
|
||||
target_include_directories(${PYG2O_MODULE_NAME}
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_LIST_DIR}/
|
||||
)
|
||||
@@ -1,198 +0,0 @@
|
||||
#include <sqapi.h>
|
||||
#include <pybind11/embed.h>
|
||||
#include <CustomTypes.h>
|
||||
|
||||
#include "python/functions.h"
|
||||
#include "squirrel/functions.h"
|
||||
#include "Dictionary.h"
|
||||
|
||||
namespace py = pybind11;
|
||||
#define SERVERFUNC nonut::ServerFunctions::getInstance()
|
||||
|
||||
std::string py_getHostname() { return SERVERFUNC->getHostname(); }
|
||||
int py_getMaxSlots() { return SERVERFUNC->getMaxSlots(); }
|
||||
int py_getPlayersCount() { return SERVERFUNC->getPlayersCount(); }
|
||||
|
||||
float py_getDistance2d(float x1, float y1, float x2, float y2) { return SERVERFUNC->getDistance2d(x1, y1, x2, y2); }
|
||||
float py_getDistance3d(float x1, float y1, float z1, float x2, float y2, float z2) { return SERVERFUNC->getDistance3d(x1, y1, z1, x2, y2, z2); }
|
||||
float py_getVectorAngle(float x1, float y1, float x2, float y2) { return SERVERFUNC->getVectorAngle(x1, y1, x2, y2); }
|
||||
|
||||
void py_sendMessageToAll(int r, int g, int b, std::string text) { return SERVERFUNC->sendMessageToAll(r, g, b, text); }
|
||||
void py_sendMessageToPlayer(int id, int r, int g, int b, std::string text) { return SERVERFUNC->sendMessageToPlayer(id, r, g, b, text); }
|
||||
void py_sendPlayerMessageToAll(int id, int r, int g, int b, std::string text) { return SERVERFUNC->sendPlayerMessageToAll(id, r, g, b, text); }
|
||||
void py_sendPlayerMessageToPlayer(int id, int to, int r, int g, int b, std::string text) { return SERVERFUNC->sendPlayerMessageToPlayer(id, to, r, g, b, text); }
|
||||
|
||||
void py_exit(int code) { return SERVERFUNC->exit(code); }
|
||||
float py_getDayLength() { return SERVERFUNC->getDayLength(); }
|
||||
std::string py_getServerDescription() { return SERVERFUNC->getServerDescription(); }
|
||||
std::string py_getServerWorld() { return SERVERFUNC->getServerWorld(); }
|
||||
py::dict py_getTime() { return SERVERFUNC->getTime().data; }
|
||||
void py_serverLog(std::string text) { return SERVERFUNC->serverLog(text); }
|
||||
void py_setDayLength(float ms) { return SERVERFUNC->setDayLength(ms); }
|
||||
bool py_setServerDescription(std::string text) { return SERVERFUNC->setServerDescription(text); }
|
||||
void py_setServerWorld(std::string text) { return SERVERFUNC->setServerWorld(text); }
|
||||
void py_setTime(int h, int m, int d) { return SERVERFUNC->setTime(h, m, d); }
|
||||
|
||||
void py_clearNpcActions(int npc_id) { return SERVERFUNC->clearNpcActions(npc_id); }
|
||||
int py_createNpc(std::string name, std::string instance) { return SERVERFUNC->createNpc(name, instance); }
|
||||
bool py_destroyNpc(int npc_id) { return SERVERFUNC->destroyNpc(npc_id); }
|
||||
py::dict py_getNpcAction(int npc_id, int index) { return SERVERFUNC->getNpcAction(npc_id, index).data; }
|
||||
// ??? py_getNpcActionType
|
||||
py::list py_getNpcActions(int npc_id) { return SERVERFUNC->getNpcActions(npc_id).data; }
|
||||
int py_getNpcActionsCount(int npc_id) { return SERVERFUNC->getNpcActionsCount(npc_id); }
|
||||
int py_getNpcHostPlayer(int npc_id) { return SERVERFUNC->getNpcHostPlayer(npc_id); }
|
||||
int py_getNpcLastActionId(int npc_id) { return SERVERFUNC->getNpcLastActionId(npc_id); }
|
||||
bool py_isNpc(int npc_id) { return SERVERFUNC->isNpc(npc_id); }
|
||||
bool py_isNpcActionFinished(int npc_id, int action_id) { return SERVERFUNC->isNpcActionFinished(npc_id, action_id); }
|
||||
void py_npcAttackMelee(int a_id, int e_id, int a_type, int combo) { return SERVERFUNC->npcAttackMelee(a_id, e_id, a_type, combo); }
|
||||
void py_npcAttackRanged(int a_id, int e_id) { return SERVERFUNC->npcAttackRanged(a_id, e_id); }
|
||||
void py_npcSpellCast(int a_id, int e_id) { return SERVERFUNC->npcSpellCast(a_id, e_id); }
|
||||
void py_npcUseClosestMob(int npc_id, std::string sceme, int target_state) { return SERVERFUNC->npcUseClosestMob(npc_id, sceme, target_state); }
|
||||
//??? py_pushNpcAction
|
||||
bool py_setNpcHostPlayer(int npc_id, int host_id) { return SERVERFUNC->setNpcHostPlayer(npc_id, host_id); }
|
||||
|
||||
bool py_addBan(py::dict info)
|
||||
{
|
||||
Sqrat::Table* pTable = PyDictionary::toSqObject(info);
|
||||
nonut::Int result = SERVERFUNC->addBan(pTable->GetObject());
|
||||
delete pTable;
|
||||
return result;
|
||||
}
|
||||
bool py_applyPlayerOverlay(int id, int overlayId) { return SERVERFUNC->applyPlayerOverlay(id, overlayId); }
|
||||
void py_ban(int id, int minutes, std::string reason) { return SERVERFUNC->ban(id, minutes, reason); }
|
||||
void py_drawWeapon(int id, int weaponMode) { return SERVERFUNC->drawWeapon(id, weaponMode); }
|
||||
void py_equipItem(int id, std::string instance, int slotId) { return SERVERFUNC->equipItem(id, instance, slotId); }
|
||||
std::string py_getPlayerAmulet(int id) { return SERVERFUNC->getPlayerAmulet(id); }
|
||||
float py_getPlayerAngle(int id) { return SERVERFUNC->getPlayerAngle(id); }
|
||||
std::string py_getPlayerAni(int id) { return SERVERFUNC->getPlayerAni(id); }
|
||||
std::string py_getPlayerArmor(int id) { return SERVERFUNC->getPlayerArmor(id); }
|
||||
py::dict py_getPlayerAtVector(int id)
|
||||
{
|
||||
py::dict result;
|
||||
nonut::Position3d pos = SERVERFUNC->getPlayerAtVector(id);
|
||||
|
||||
result["x"] = pos.x;
|
||||
result["y"] = pos.y;
|
||||
result["z"] = pos.z;
|
||||
return result;
|
||||
}
|
||||
std::string py_getPlayerBelt(int id) { return SERVERFUNC->getPlayerBelt(id); }
|
||||
py::dict py_getPlayerCameraPosition(int id)
|
||||
{
|
||||
py::dict result;
|
||||
nonut::Position3d pos = SERVERFUNC->getPlayerCameraPosition(id);
|
||||
|
||||
result["x"] = pos.x;
|
||||
result["y"] = pos.y;
|
||||
result["z"] = pos.z;
|
||||
return result;
|
||||
}
|
||||
bool py_getPlayerCollision(int id) { return SERVERFUNC->getPlayerCollision(id); }
|
||||
py::dict py_getPlayerColor(int id)
|
||||
{
|
||||
py::dict result;
|
||||
nonut::Color color = SERVERFUNC->getPlayerColor(id);
|
||||
|
||||
result["r"] = color.r;
|
||||
result["g"] = color.g;
|
||||
result["b"] = color.b;
|
||||
return result;
|
||||
}
|
||||
int py_getPlayerContext(int id, int type) { return SERVERFUNC->getPlayerContext(id, type); }
|
||||
int py_getPlayerDexterity(int id) { return SERVERFUNC->getPlayerDexterity(id); }
|
||||
py::list py_getPlayerFaceAnis(int id) { return SERVERFUNC->getPlayerFaceAnis(id).data; }
|
||||
float py_getPlayerFatness(int id) { return SERVERFUNC->getPlayerFatness(id); }
|
||||
int py_getPlayerFocus(int id) { return SERVERFUNC->getPlayerFocus(id); }
|
||||
int py_getPlayerHealth(int id) { return SERVERFUNC->getPlayerHealth(id); }
|
||||
std::string py_getPlayerHelmet(int id) { return SERVERFUNC->getPlayerHelmet(id); }
|
||||
std::string py_getPlayerIP(int id) { return SERVERFUNC->getPlayerIP(id); }
|
||||
std::string py_getPlayerInstance(int id) { return SERVERFUNC->getPlayerInstance(id); }
|
||||
std::string py_getPlayerMacAddr(int id) { return SERVERFUNC->getPlayerMacAddr(id); }
|
||||
int py_getPlayerMana(int id) { return SERVERFUNC->getPlayerMana(id); }
|
||||
int py_getPlayerMaxHealth(int id) { return SERVERFUNC->getPlayerMaxHealth(id); }
|
||||
int py_getPlayerMaxMana(int id) { return SERVERFUNC->getPlayerMaxMana(id); }
|
||||
std::string py_getPlayerMeleeWeapon(int id) { return SERVERFUNC->getPlayerMeleeWeapon(id); }
|
||||
std::string py_getPlayerName(int id) { return SERVERFUNC->getPlayerName(id); }
|
||||
int py_getPlayerPing(int id) { return SERVERFUNC->getPlayerPing(id); }
|
||||
py::dict py_getPlayerPosition(int id)
|
||||
{
|
||||
py::dict result;
|
||||
|
||||
nonut::Position3d pos = SERVERFUNC->getPlayerPosition(id);
|
||||
|
||||
result["x"] = pos.x;
|
||||
result["y"] = pos.y;
|
||||
result["z"] = pos.z;
|
||||
return result;
|
||||
}
|
||||
std::string py_getPlayerRangedWeapon(int id) { return SERVERFUNC->getPlayerRangedWeapon(id); }
|
||||
int py_getPlayerRespawnTime(int id) { return SERVERFUNC->getPlayerRespawnTime(id); }
|
||||
std::string py_getPlayerRing(int id, int handId) { return SERVERFUNC->getPlayerRing(id, handId); }
|
||||
py::dict py_getPlayerScale(int id) { return SERVERFUNC->getPlayerScale(id).data; }
|
||||
std::string py_getPlayerSerial(int id) { return SERVERFUNC->getPlayerSerial(id); }
|
||||
std::string py_getPlayerShield(int id) { return SERVERFUNC->getPlayerShield(id); }
|
||||
int py_getPlayerSkillWeapon(int id, int skillId) { return SERVERFUNC->getPlayerSkillWeapon(id, skillId); }
|
||||
std::string py_getPlayerSpell(int id, int slotId) { return SERVERFUNC->getPlayerSpell(id, slotId); }
|
||||
int py_getPlayerStrength(int id) { return SERVERFUNC->getPlayerStrength(id); }
|
||||
int py_getPlayerTalent(int id, int talentId) { return SERVERFUNC->getPlayerTalent(id, talentId); }
|
||||
std::string py_getPlayerUID(int id) { return SERVERFUNC->getPlayerUID(id); }
|
||||
int py_getPlayerVirtualWorld(int id) { return SERVERFUNC->getPlayerVirtualWorld(id); }
|
||||
py::dict py_getPlayerVisual(int id) { return SERVERFUNC->getPlayerVisual(id).data; }
|
||||
int py_getPlayerWeaponMode(int id) { return SERVERFUNC->getPlayerWeaponMode(id); }
|
||||
std::string py_getPlayerWorld(int id) { return SERVERFUNC->getPlayerWorld(id); }
|
||||
void py_giveItem(int id, std::string instance, int amount) { return SERVERFUNC->giveItem(id, instance, amount); }
|
||||
bool py_hitPlayer(int id, int targetid) { return SERVERFUNC->hitPlayer(id, targetid); }
|
||||
bool py_isPlayerConnected(int id) { return SERVERFUNC->isPlayerConnected(id); }
|
||||
bool py_isPlayerDead(int id) { return SERVERFUNC->isPlayerDead(id); }
|
||||
bool py_isPlayerUnconscious(int id) { return SERVERFUNC->isPlayerUnconscious(id); }
|
||||
void py_kick(int id, std::string reason) { return SERVERFUNC->kick(id, reason); }
|
||||
void py_playAni(int id, std::string aniName) { return SERVERFUNC->playAni(id, aniName); }
|
||||
void py_playFaceAni(int id, std::string aniName) { return SERVERFUNC->playFaceAni(id, aniName); }
|
||||
void py_readySpell(int id, int slotId, int manaInvested) { return SERVERFUNC->readySpell(id, slotId, manaInvested); }
|
||||
void py_removeItem(int id, std::string instance, int amount) { return SERVERFUNC->removeItem(id, instance, amount); }
|
||||
bool py_removePlayerOverlay(int id, int overlayId) { return SERVERFUNC->removePlayerOverlay(id, overlayId); }
|
||||
void py_removeWeapon(int id) { return SERVERFUNC->removeWeapon(id); }
|
||||
void py_respawnPlayer(int id) { return SERVERFUNC->respawnPlayer(id); }
|
||||
void py_setPlayerAngle(int id, float angle) { return SERVERFUNC->setPlayerAngle(id, angle); }
|
||||
void py_setPlayerCollision(int id, bool collision) { return SERVERFUNC->setPlayerCollision(id, collision); }
|
||||
void py_setPlayerColor(int id, int r, int g, int b) { return SERVERFUNC->setPlayerColor(id, r, g, b); }
|
||||
void py_setPlayerContext(int id, int type, int value) { return SERVERFUNC->setPlayerContext(id, type, value); }
|
||||
void py_setPlayerDexterity(int id, int dexterity) { return SERVERFUNC->setPlayerDexterity(id, dexterity); }
|
||||
void py_setPlayerFatness(int id, float fatness) { return SERVERFUNC->setPlayerFatness(id, fatness); }
|
||||
void py_setPlayerHealth(int id, int health) { return SERVERFUNC->setPlayerHealth(id, health); }
|
||||
void py_setPlayerInstance(int id, std::string instance) { return SERVERFUNC->setPlayerInstance(id, instance); }
|
||||
void py_setPlayerInvisible(int id, bool toggle) { return SERVERFUNC->setPlayerInvisible(id, toggle); }
|
||||
void py_setPlayerMana(int id, int mana) { return SERVERFUNC->setPlayerMana(id, mana); }
|
||||
void py_setPlayerMaxHealth(int id, int maxHealth) { return SERVERFUNC->setPlayerMaxHealth(id, maxHealth); }
|
||||
void py_setPlayerMaxMana(int id, int maxMana) { return SERVERFUNC->setPlayerMaxMana(id, maxMana); }
|
||||
void py_setPlayerName(int id, std::string name) { return SERVERFUNC->setPlayerName(id, name); }
|
||||
void py_setPlayerPosition(int id, float x, float y, float z) { return SERVERFUNC->setPlayerPosition(id, x, y, z); }
|
||||
void py_setPlayerRespawnTime(int id, int respawnTime) { return SERVERFUNC->setPlayerRespawnTime(id, respawnTime); }
|
||||
void py_setPlayerScale(int id, float x, float y, float z) { return SERVERFUNC->setPlayerScale(id, x, y, z); }
|
||||
void py_setPlayerSkillWeapon(int id, int skillId, int percentage) { return SERVERFUNC->setPlayerSkillWeapon(id, skillId, percentage); }
|
||||
void py_setPlayerStrength(int id, int strength) { return SERVERFUNC->setPlayerStrength(id, strength); }
|
||||
void py_setPlayerTalent(int id, int talentId, int talentValue) { return SERVERFUNC->setPlayerTalent(id, talentId, talentValue); }
|
||||
void py_setPlayerVirtualWorld(int id, int virtualWorld) { return SERVERFUNC->setPlayerVirtualWorld(id, virtualWorld); }
|
||||
void py_setPlayerVisual(int id, std::string bMdl, int bTxt, std::string hMdl, int hTxt) { return SERVERFUNC->setPlayerVisual(id, bMdl, bTxt, hMdl, hTxt); }
|
||||
void py_setPlayerWeaponMode(int id, int weaponMode) { return SERVERFUNC->setPlayerWeaponMode(id, weaponMode); }
|
||||
void py_setPlayerWorld(int id, std::string world, std::string startPointName) { return SERVERFUNC->setPlayerWorld(id, world, startPointName); }
|
||||
void py_spawnPlayer(int id) { return SERVERFUNC->spawnPlayer(id); }
|
||||
void py_stopAni(int id, std::string aniName) { return SERVERFUNC->stopAni(id, aniName); }
|
||||
void py_stopFaceAni(int id, std::string aniName) { return SERVERFUNC->stopFaceAni(id, aniName); }
|
||||
void py_unequipItem(int id, std::string instance) { return SERVERFUNC->unequipItem(id, instance); }
|
||||
void py_unreadySpell(int id) { return SERVERFUNC->unreadySpell(id); }
|
||||
void py_unspawnPlayer(int id) { return SERVERFUNC->unspawnPlayer(id); }
|
||||
void py_useItem(int id, std::string instance) { return SERVERFUNC->useItem(id, instance); }
|
||||
void py_useItemToState(int id, std::string instance, int state) { return SERVERFUNC->useItemToState(id, instance, state); }
|
||||
|
||||
py::list py_findNearbyPlayers(py::dict position, int radius, std::string world, int vWorld)
|
||||
{
|
||||
Sqrat::Table* pTable = PyDictionary::toSqObject(position);
|
||||
py::list result = SERVERFUNC->findNearbyPlayers(pTable->GetObject(), radius, world, vWorld).data;
|
||||
delete pTable;
|
||||
return result;
|
||||
}
|
||||
py::list py_getSpawnedPlayersForPlayer(int id) { return SERVERFUNC->getSpawnedPlayersForPlayer(id).data; }
|
||||
py::list py_getStreamedPlayersByPlayer(int id) { return SERVERFUNC->getStreamedPlayersByPlayer(id).data; }
|
||||
py::dict py_getNearestWaypoint(std::string world, int x, int y, int z) { return SERVERFUNC->getNearestWaypoint(world, x, y, z).data; }
|
||||
py::dict py_getWaypoint(std::string world, std::string name) { return SERVERFUNC->getWaypoint(world, name).data; }
|
||||
@@ -1,147 +0,0 @@
|
||||
#ifndef _PYFUNCTIONS_
|
||||
#define _PYFUNCTIONS_
|
||||
|
||||
#include <pybind11/embed.h>
|
||||
namespace py = pybind11;
|
||||
|
||||
// Shared functions
|
||||
std::string py_getHostname();
|
||||
int py_getMaxSlots();
|
||||
int py_getPlayersCount();
|
||||
|
||||
float py_getDistance2d(float, float, float, float);
|
||||
float py_getDistance3d(float, float, float, float, float, float);
|
||||
float py_getVectorAngle(float, float, float, float);
|
||||
|
||||
void py_sendMessageToAll(int, int, int, std::string);
|
||||
void py_sendMessageToPlayer(int, int, int, int, std::string);
|
||||
void py_sendPlayerMessageToAll(int, int, int, int, std::string);
|
||||
void py_sendPlayerMessageToPlayer(int, int, int, int, int, std::string);
|
||||
|
||||
void py_exit(int);
|
||||
float py_getDayLength();
|
||||
std::string py_getServerDescription();
|
||||
std::string py_getServerWorld();
|
||||
py::dict py_getTime();
|
||||
void py_serverLog(std::string);
|
||||
void py_setDayLength(float);
|
||||
bool py_setServerDescription(std::string);
|
||||
void py_setServerWorld(std::string);
|
||||
void py_setTime(int, int, int);
|
||||
|
||||
void py_clearNpcActions(int);
|
||||
int py_createNpc(std::string, std::string);
|
||||
bool py_destroyNpc(int);
|
||||
py::dict py_getNpcAction(int, int);
|
||||
// ??? py_getNpcActionType
|
||||
py::list py_getNpcActions(int);
|
||||
int py_getNpcActionsCount(int);
|
||||
int py_getNpcHostPlayer(int);
|
||||
int py_getNpcLastActionId(int);
|
||||
bool py_isNpc(int);
|
||||
bool py_isNpcActionFinished(int, int);
|
||||
void py_npcAttackMelee(int, int, int, int);
|
||||
void py_npcAttackRanged(int, int);
|
||||
void py_npcSpellCast(int, int);
|
||||
void py_npcUseClosestMob(int, std::string, int);
|
||||
//??? py_pushNpcAction
|
||||
bool py_setNpcHostPlayer(int, int);
|
||||
|
||||
bool py_addBan(py::dict);
|
||||
bool py_applyPlayerOverlay(int, int);
|
||||
void py_ban(int, int, std::string);
|
||||
void py_drawWeapon(int, int);
|
||||
void py_equipItem(int, std::string, int);
|
||||
std::string py_getPlayerAmulet(int);
|
||||
float py_getPlayerAngle(int);
|
||||
std::string py_getPlayerAni(int);
|
||||
std::string py_getPlayerArmor(int);
|
||||
py::dict py_getPlayerAtVector(int);
|
||||
std::string py_getPlayerBelt(int);
|
||||
py::dict py_getPlayerCameraPosition(int);
|
||||
bool py_getPlayerCollision(int);
|
||||
py::dict py_getPlayerColor(int);
|
||||
int py_getPlayerContext(int, int);
|
||||
int py_getPlayerDexterity(int);
|
||||
py::list py_getPlayerFaceAnis(int);
|
||||
float py_getPlayerFatness(int);
|
||||
int py_getPlayerFocus(int);
|
||||
int py_getPlayerHealth(int);
|
||||
std::string py_getPlayerHelmet(int);
|
||||
std::string py_getPlayerIP(int);
|
||||
std::string py_getPlayerInstance(int);
|
||||
std::string py_getPlayerMacAddr(int);
|
||||
int py_getPlayerMana(int);
|
||||
int py_getPlayerMaxHealth(int);
|
||||
int py_getPlayerMaxMana(int);
|
||||
std::string py_getPlayerMeleeWeapon(int);
|
||||
std::string py_getPlayerName(int);
|
||||
int py_getPlayerPing(int);
|
||||
py::dict py_getPlayerPosition(int);
|
||||
std::string py_getPlayerRangedWeapon(int);
|
||||
int py_getPlayerRespawnTime(int);
|
||||
std::string py_getPlayerRing(int, int);
|
||||
py::dict py_getPlayerScale(int);
|
||||
std::string py_getPlayerSerial(int);
|
||||
std::string py_getPlayerShield(int);
|
||||
int py_getPlayerSkillWeapon(int, int);
|
||||
std::string py_getPlayerSpell(int, int);
|
||||
int py_getPlayerStrength(int);
|
||||
int py_getPlayerTalent(int, int);
|
||||
std::string py_getPlayerUID(int);
|
||||
int py_getPlayerVirtualWorld(int);
|
||||
py::dict py_getPlayerVisual(int);
|
||||
int py_getPlayerWeaponMode(int);
|
||||
std::string py_getPlayerWorld(int);
|
||||
void py_giveItem(int, std::string, int);
|
||||
bool py_hitPlayer(int, int);
|
||||
bool py_isPlayerConnected(int);
|
||||
bool py_isPlayerDead(int);
|
||||
bool py_isPlayerUnconscious(int);
|
||||
void py_kick(int, std::string);
|
||||
void py_playAni(int, std::string);
|
||||
void py_playFaceAni(int, std::string);
|
||||
void py_readySpell(int, int, int);
|
||||
void py_removeItem(int, std::string, int);
|
||||
bool py_removePlayerOverlay(int, int);
|
||||
void py_removeWeapon(int);
|
||||
void py_respawnPlayer(int);
|
||||
void py_setPlayerAngle(int, float);
|
||||
void py_setPlayerCollision(int, bool);
|
||||
void py_setPlayerColor(int, int, int, int);
|
||||
void py_setPlayerContext(int, int, int);
|
||||
void py_setPlayerDexterity(int, int);
|
||||
void py_setPlayerFatness(int, float);
|
||||
void py_setPlayerHealth(int, int);
|
||||
void py_setPlayerInstance(int, std::string);
|
||||
void py_setPlayerInvisible(int, bool);
|
||||
void py_setPlayerMana(int, int);
|
||||
void py_setPlayerMaxHealth(int, int);
|
||||
void py_setPlayerMaxMana(int, int);
|
||||
void py_setPlayerName(int, std::string);
|
||||
void py_setPlayerPosition(int, float, float, float);
|
||||
void py_setPlayerRespawnTime(int, int);
|
||||
void py_setPlayerScale(int, float, float, float);
|
||||
void py_setPlayerSkillWeapon(int, int, int);
|
||||
void py_setPlayerStrength(int, int);
|
||||
void py_setPlayerTalent(int, int, int);
|
||||
void py_setPlayerVirtualWorld(int, int);
|
||||
void py_setPlayerVisual(int, std::string, int, std::string, int);
|
||||
void py_setPlayerWeaponMode(int, int);
|
||||
void py_setPlayerWorld(int, std::string, std::string);
|
||||
void py_spawnPlayer(int);
|
||||
void py_stopAni(int, std::string);
|
||||
void py_stopFaceAni(int, std::string);
|
||||
void py_unequipItem(int, std::string);
|
||||
void py_unreadySpell(int);
|
||||
void py_unspawnPlayer(int);
|
||||
void py_useItem(int, std::string);
|
||||
void py_useItemToState(int, std::string, int);
|
||||
|
||||
py::list py_findNearbyPlayers(py::dict, int, std::string, int);
|
||||
py::list py_getSpawnedPlayersForPlayer(int);
|
||||
py::list py_getStreamedPlayersByPlayer(int);
|
||||
py::dict py_getNearestWaypoint(std::string, int, int, int);
|
||||
py::dict py_getWaypoint(std::string, std::string);
|
||||
|
||||
#endif
|
||||
@@ -1,155 +0,0 @@
|
||||
#include <sqapi.h>
|
||||
#include "squirrel/functions.h"
|
||||
|
||||
namespace nonut
|
||||
{
|
||||
ServerFunctions::ServerFunctions() :
|
||||
FUNCTION_CTOR(getMaxSlots),
|
||||
FUNCTION_CTOR(getHostname),
|
||||
FUNCTION_CTOR(getPlayersCount),
|
||||
|
||||
FUNCTION_CTOR(getDistance2d),
|
||||
FUNCTION_CTOR(getDistance3d),
|
||||
FUNCTION_CTOR(getVectorAngle),
|
||||
|
||||
FUNCTION_CTOR(sendMessageToAll),
|
||||
FUNCTION_CTOR(sendMessageToPlayer),
|
||||
FUNCTION_CTOR(sendPlayerMessageToAll),
|
||||
FUNCTION_CTOR(sendPlayerMessageToPlayer),
|
||||
|
||||
FUNCTION_CTOR(exit),
|
||||
FUNCTION_CTOR(getDayLength),
|
||||
FUNCTION_CTOR(getServerDescription),
|
||||
FUNCTION_CTOR(getServerWorld),
|
||||
FUNCTION_CTOR(getTime),
|
||||
FUNCTION_CTOR(serverLog),
|
||||
FUNCTION_CTOR(setDayLength),
|
||||
FUNCTION_CTOR(setServerDescription),
|
||||
FUNCTION_CTOR(setServerWorld),
|
||||
FUNCTION_CTOR(setTime),
|
||||
|
||||
FUNCTION_CTOR(clearNpcActions),
|
||||
FUNCTION_CTOR(createNpc),
|
||||
FUNCTION_CTOR(destroyNpc),
|
||||
FUNCTION_CTOR(getNpcAction),
|
||||
//FUNCTION_CTOR(getNpcActionType),
|
||||
FUNCTION_CTOR(getNpcActions),
|
||||
FUNCTION_CTOR(getNpcActionsCount),
|
||||
FUNCTION_CTOR(getNpcHostPlayer),
|
||||
FUNCTION_CTOR(getNpcLastActionId),
|
||||
FUNCTION_CTOR(isNpc),
|
||||
FUNCTION_CTOR(isNpcActionFinished),
|
||||
FUNCTION_CTOR(npcAttackMelee),
|
||||
FUNCTION_CTOR(npcAttackRanged),
|
||||
FUNCTION_CTOR(npcSpellCast),
|
||||
FUNCTION_CTOR(npcUseClosestMob),
|
||||
//FUNCTION_CTOR(pushNpcAction),
|
||||
FUNCTION_CTOR(setNpcHostPlayer),
|
||||
FUNCTION_CTOR(addBan),
|
||||
FUNCTION_CTOR(applyPlayerOverlay),
|
||||
FUNCTION_CTOR(ban),
|
||||
FUNCTION_CTOR(drawWeapon),
|
||||
FUNCTION_CTOR(equipItem),
|
||||
FUNCTION_CTOR(getPlayerAmulet),
|
||||
FUNCTION_CTOR(getPlayerAngle),
|
||||
FUNCTION_CTOR(getPlayerAni),
|
||||
FUNCTION_CTOR(getPlayerArmor),
|
||||
FUNCTION_CTOR(getPlayerAtVector),
|
||||
FUNCTION_CTOR(getPlayerBelt),
|
||||
FUNCTION_CTOR(getPlayerCameraPosition),
|
||||
FUNCTION_CTOR(getPlayerCollision),
|
||||
FUNCTION_CTOR(getPlayerColor),
|
||||
FUNCTION_CTOR(getPlayerContext),
|
||||
FUNCTION_CTOR(getPlayerDexterity),
|
||||
FUNCTION_CTOR(getPlayerFaceAnis),
|
||||
FUNCTION_CTOR(getPlayerFatness),
|
||||
FUNCTION_CTOR(getPlayerFocus),
|
||||
FUNCTION_CTOR(getPlayerHealth),
|
||||
FUNCTION_CTOR(getPlayerHelmet),
|
||||
FUNCTION_CTOR(getPlayerIP),
|
||||
FUNCTION_CTOR(getPlayerInstance),
|
||||
FUNCTION_CTOR(getPlayerMacAddr),
|
||||
FUNCTION_CTOR(getPlayerMana),
|
||||
FUNCTION_CTOR(getPlayerMaxHealth),
|
||||
FUNCTION_CTOR(getPlayerMaxMana),
|
||||
FUNCTION_CTOR(getPlayerMeleeWeapon),
|
||||
FUNCTION_CTOR(getPlayerName),
|
||||
FUNCTION_CTOR(getPlayerPing),
|
||||
FUNCTION_CTOR(getPlayerPosition),
|
||||
FUNCTION_CTOR(getPlayerRangedWeapon),
|
||||
FUNCTION_CTOR(getPlayerRespawnTime),
|
||||
FUNCTION_CTOR(getPlayerRing),
|
||||
FUNCTION_CTOR(getPlayerScale),
|
||||
FUNCTION_CTOR(getPlayerSerial),
|
||||
FUNCTION_CTOR(getPlayerShield),
|
||||
FUNCTION_CTOR(getPlayerSkillWeapon),
|
||||
FUNCTION_CTOR(getPlayerSpell),
|
||||
FUNCTION_CTOR(getPlayerStrength),
|
||||
FUNCTION_CTOR(getPlayerTalent),
|
||||
FUNCTION_CTOR(getPlayerUID),
|
||||
FUNCTION_CTOR(getPlayerVirtualWorld),
|
||||
FUNCTION_CTOR(getPlayerVisual),
|
||||
FUNCTION_CTOR(getPlayerWeaponMode),
|
||||
FUNCTION_CTOR(getPlayerWorld),
|
||||
FUNCTION_CTOR(giveItem),
|
||||
FUNCTION_CTOR(hitPlayer),
|
||||
FUNCTION_CTOR(isPlayerConnected),
|
||||
FUNCTION_CTOR(isPlayerDead),
|
||||
FUNCTION_CTOR(isPlayerUnconscious),
|
||||
FUNCTION_CTOR(kick),
|
||||
FUNCTION_CTOR(playAni),
|
||||
FUNCTION_CTOR(playFaceAni),
|
||||
FUNCTION_CTOR(readySpell),
|
||||
FUNCTION_CTOR(removeItem),
|
||||
FUNCTION_CTOR(removePlayerOverlay),
|
||||
FUNCTION_CTOR(removeWeapon),
|
||||
FUNCTION_CTOR(respawnPlayer),
|
||||
FUNCTION_CTOR(setPlayerAngle),
|
||||
FUNCTION_CTOR(setPlayerCollision),
|
||||
FUNCTION_CTOR(setPlayerColor),
|
||||
FUNCTION_CTOR(setPlayerContext),
|
||||
FUNCTION_CTOR(setPlayerDexterity),
|
||||
FUNCTION_CTOR(setPlayerFatness),
|
||||
FUNCTION_CTOR(setPlayerHealth),
|
||||
FUNCTION_CTOR(setPlayerInstance),
|
||||
FUNCTION_CTOR(setPlayerInvisible),
|
||||
FUNCTION_CTOR(setPlayerMana),
|
||||
FUNCTION_CTOR(setPlayerMaxHealth),
|
||||
FUNCTION_CTOR(setPlayerMaxMana),
|
||||
FUNCTION_CTOR(setPlayerName),
|
||||
FUNCTION_CTOR(setPlayerPosition),
|
||||
FUNCTION_CTOR(setPlayerRespawnTime),
|
||||
FUNCTION_CTOR(setPlayerScale),
|
||||
FUNCTION_CTOR(setPlayerSkillWeapon),
|
||||
FUNCTION_CTOR(setPlayerStrength),
|
||||
FUNCTION_CTOR(setPlayerTalent),
|
||||
FUNCTION_CTOR(setPlayerVirtualWorld),
|
||||
FUNCTION_CTOR(setPlayerVisual),
|
||||
FUNCTION_CTOR(setPlayerWeaponMode),
|
||||
FUNCTION_CTOR(setPlayerWorld),
|
||||
FUNCTION_CTOR(spawnPlayer),
|
||||
FUNCTION_CTOR(stopAni),
|
||||
FUNCTION_CTOR(stopFaceAni),
|
||||
FUNCTION_CTOR(unequipItem),
|
||||
FUNCTION_CTOR(unreadySpell),
|
||||
FUNCTION_CTOR(unspawnPlayer),
|
||||
FUNCTION_CTOR(useItem),
|
||||
FUNCTION_CTOR(useItemToState),
|
||||
|
||||
FUNCTION_CTOR(findNearbyPlayers),
|
||||
FUNCTION_CTOR(getSpawnedPlayersForPlayer),
|
||||
FUNCTION_CTOR(getStreamedPlayersByPlayer),
|
||||
FUNCTION_CTOR(getNearestWaypoint),
|
||||
FUNCTION_CTOR(getWaypoint)
|
||||
{}
|
||||
|
||||
ServerFunctions* ServerFunctions::getInstance()
|
||||
{
|
||||
if (instance == nullptr)
|
||||
{
|
||||
instance = new ServerFunctions();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,161 +0,0 @@
|
||||
#ifndef _SQFUNCTIONS_
|
||||
#define _SQFUNCTIONS_
|
||||
|
||||
#include <Function.h>
|
||||
#include <CustomTypes.h>
|
||||
|
||||
namespace nonut
|
||||
{
|
||||
class ServerFunctions
|
||||
{
|
||||
protected:
|
||||
ServerFunctions();
|
||||
static inline ServerFunctions* instance = nullptr;
|
||||
public:
|
||||
ServerFunctions(ServerFunctions& other) = delete;
|
||||
void operator=(const ServerFunctions&) = delete;
|
||||
static ServerFunctions* getInstance();
|
||||
|
||||
Function<String> getHostname;
|
||||
Function<Int> getMaxSlots;
|
||||
Function<Int> getPlayersCount;
|
||||
|
||||
Function<Float, Float, Float, Float, Float> getDistance2d;
|
||||
Function<Float, Float, Float, Float, Float, Float, Float> getDistance3d;
|
||||
Function<Float, Float, Float, Float, Float> getVectorAngle;
|
||||
|
||||
Function<void, Int, Int, Int, String> sendMessageToAll;
|
||||
Function<void, Int, Int, Int, Int, String> sendMessageToPlayer;
|
||||
Function<void, Int, Int, Int, Int, String> sendPlayerMessageToAll;
|
||||
Function<void, Int, Int, Int, Int, Int, String> sendPlayerMessageToPlayer;
|
||||
|
||||
Function<void, Int> exit;
|
||||
Function<Float> getDayLength;
|
||||
Function<String> getServerDescription;
|
||||
Function<String> getServerWorld;
|
||||
Function<SqDict> getTime;
|
||||
Function<void, String> serverLog;
|
||||
Function<void, Float> setDayLength;
|
||||
Function<Bool, String> setServerDescription;
|
||||
Function<void, String> setServerWorld;
|
||||
Function<void, Int, Int, Int> setTime;
|
||||
|
||||
Function<void, Int> clearNpcActions;
|
||||
Function<Int, String, String> createNpc;
|
||||
Function<Bool, Int> destroyNpc;
|
||||
Function<SqDict, Int, Int> getNpcAction;
|
||||
//Function<???> getNpcActionType;
|
||||
Function<SqList, Int> getNpcActions;
|
||||
Function<Int, Int> getNpcActionsCount;
|
||||
Function<Int, Int> getNpcHostPlayer;
|
||||
Function<Int, Int> getNpcLastActionId;
|
||||
Function<Bool, Int> isNpc;
|
||||
Function<Bool, Int, Int> isNpcActionFinished;
|
||||
Function<void, Int, Int, Int, Int> npcAttackMelee;
|
||||
Function<void, Int, Int> npcAttackRanged;
|
||||
Function<void, Int, Int> npcSpellCast;
|
||||
Function<void, Int, String, Int> npcUseClosestMob;
|
||||
//Function<???> pushNpcAction;
|
||||
Function<Bool, Int, Int> setNpcHostPlayer;
|
||||
|
||||
Function<Bool, SQObject> addBan;
|
||||
Function<Bool, Int, Int> applyPlayerOverlay;
|
||||
Function<void, Int, Int, String> ban;
|
||||
Function<void, Int, Int> drawWeapon;
|
||||
Function<void, Int, String, Int> equipItem;
|
||||
Function<String, Int> getPlayerAmulet;
|
||||
Function<Float, Int> getPlayerAngle;
|
||||
Function<String, Int> getPlayerAni;
|
||||
Function<String, Int> getPlayerArmor;
|
||||
Function<Position3d, Int> getPlayerAtVector;
|
||||
Function<String, Int> getPlayerBelt;
|
||||
Function<Position3d, Int> getPlayerCameraPosition;
|
||||
Function<Bool, Int> getPlayerCollision;
|
||||
Function<Color, Int> getPlayerColor;
|
||||
Function<Int, Int, Int> getPlayerContext;
|
||||
Function<Int, Int> getPlayerDexterity;
|
||||
Function<SqList, Int> getPlayerFaceAnis;
|
||||
Function<Float, Int> getPlayerFatness;
|
||||
Function<Int, Int> getPlayerFocus;
|
||||
Function<Int, Int> getPlayerHealth;
|
||||
Function<String, Int> getPlayerHelmet;
|
||||
Function<String, Int> getPlayerIP;
|
||||
Function<String, Int> getPlayerInstance;
|
||||
Function<String, Int> getPlayerMacAddr;
|
||||
Function<Int, Int> getPlayerMana;
|
||||
Function<Int, Int> getPlayerMaxHealth;
|
||||
Function<Int, Int> getPlayerMaxMana;
|
||||
Function<String, Int> getPlayerMeleeWeapon;
|
||||
Function<String, Int> getPlayerName;
|
||||
Function<Int, Int> getPlayerPing;
|
||||
Function<Position3d, Int> getPlayerPosition;
|
||||
Function<String, Int> getPlayerRangedWeapon;
|
||||
Function<Int, Int> getPlayerRespawnTime;
|
||||
Function<String, Int, Int> getPlayerRing;
|
||||
Function<SqDict, Int> getPlayerScale;
|
||||
Function<String, Int> getPlayerSerial;
|
||||
Function<String, Int> getPlayerShield;
|
||||
Function<Int, Int, Int> getPlayerSkillWeapon;
|
||||
Function<String, Int, Int> getPlayerSpell;
|
||||
Function<Int, Int> getPlayerStrength;
|
||||
Function<Int, Int, Int> getPlayerTalent;
|
||||
Function<String, Int> getPlayerUID;
|
||||
Function<Int, Int> getPlayerVirtualWorld;
|
||||
Function<SqDict, Int> getPlayerVisual;
|
||||
Function<Int, Int> getPlayerWeaponMode;
|
||||
Function<String, Int> getPlayerWorld;
|
||||
Function<void, Int, String, Int> giveItem;
|
||||
Function<Bool, Int, Int> hitPlayer;
|
||||
Function<Bool, Int> isPlayerConnected;
|
||||
Function<Bool, Int> isPlayerDead;
|
||||
Function<Bool, Int> isPlayerUnconscious;
|
||||
Function<void, Int, String> kick;
|
||||
Function<void, Int, String> playAni;
|
||||
Function<void, Int, String> playFaceAni;
|
||||
Function<void, Int, Int, Int> readySpell;
|
||||
Function<void, Int, String, Int> removeItem;
|
||||
Function<Bool, Int, Int> removePlayerOverlay;
|
||||
Function<void, Int> removeWeapon;
|
||||
Function<void, Int> respawnPlayer;
|
||||
Function<void, Int, Float> setPlayerAngle;
|
||||
Function<void, Int, Bool> setPlayerCollision;
|
||||
Function<void, Int, Int, Int, Int> setPlayerColor;
|
||||
Function<void, Int, Int, Int> setPlayerContext;
|
||||
Function<void, Int, Int> setPlayerDexterity;
|
||||
Function<void, Int, Float> setPlayerFatness;
|
||||
Function<void, Int, Int> setPlayerHealth;
|
||||
Function<void, Int, String> setPlayerInstance;
|
||||
Function<void, Int, Bool> setPlayerInvisible;
|
||||
Function<void, Int, Int> setPlayerMana;
|
||||
Function<void, Int, Int> setPlayerMaxHealth;
|
||||
Function<void, Int, Int> setPlayerMaxMana;
|
||||
Function<void, Int, String> setPlayerName;
|
||||
Function<void, Int, Float, Float, Float> setPlayerPosition;
|
||||
Function<void, Int, Int> setPlayerRespawnTime;
|
||||
Function<void, Int, Float, Float, Float> setPlayerScale;
|
||||
Function<void, Int, Int, Int> setPlayerSkillWeapon;
|
||||
Function<void, Int, Int> setPlayerStrength;
|
||||
Function<void, Int, Int, Int> setPlayerTalent;
|
||||
Function<void, Int, Int> setPlayerVirtualWorld;
|
||||
Function<void, Int, String, Int, String, Int> setPlayerVisual;
|
||||
Function<void, Int, Int> setPlayerWeaponMode;
|
||||
Function<void, Int, String, String> setPlayerWorld;
|
||||
Function<void, Int> spawnPlayer;
|
||||
Function<void, Int, String> stopAni;
|
||||
Function<void, Int, String> stopFaceAni;
|
||||
Function<void, Int, String> unequipItem;
|
||||
Function<void, Int> unreadySpell;
|
||||
Function<void, Int> unspawnPlayer;
|
||||
Function<void, Int, String> useItem;
|
||||
Function<void, Int, String, Int> useItemToState;
|
||||
|
||||
Function<SqList, SQObject, Int, String, Int> findNearbyPlayers;
|
||||
Function<SqList, Int> getSpawnedPlayersForPlayer;
|
||||
Function<SqList, Int> getStreamedPlayersByPlayer;
|
||||
|
||||
Function<SqDict, String, Int, Int, Int> getNearestWaypoint;
|
||||
Function<SqDict, String, String> getWaypoint;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,54 +0,0 @@
|
||||
#include <sqapi.h>
|
||||
#include <pybind11/embed.h>
|
||||
#include "sqevents.h"
|
||||
#include "sqconstants.h"
|
||||
#include "squirrel/functions.h"
|
||||
|
||||
namespace py = pybind11;
|
||||
py::scoped_interpreter guard{};
|
||||
|
||||
py::module_ g2o;
|
||||
|
||||
extern "C" SQRESULT SQRAT_API sqmodule_load(HSQUIRRELVM vm, HSQAPI api)
|
||||
{
|
||||
SqModule::Initialize(vm, api);
|
||||
Sqrat::DefaultVM::Set(vm);
|
||||
|
||||
try
|
||||
{
|
||||
registerSquirrelConstants();
|
||||
|
||||
py::exec(R"(
|
||||
import site
|
||||
import json
|
||||
import importlib
|
||||
|
||||
venv_path = 'test_venv/Lib/site-packages'
|
||||
site.addsitedir('.')
|
||||
|
||||
entry_point = 'pyg2o_entry'
|
||||
|
||||
try:
|
||||
with open('pyg2o.json', 'r') as f:
|
||||
json = json.loads(f.read())
|
||||
entry_point = json['entry']
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
try:
|
||||
importlib.import_module(entry_point)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
)");
|
||||
|
||||
g2o = py::module_::import("g2o");
|
||||
}
|
||||
catch (py::error_already_set &e)
|
||||
{
|
||||
py::print(e.what());
|
||||
return SQ_ERROR;
|
||||
}
|
||||
|
||||
registerSquirrelEvents();
|
||||
return SQ_OK;
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
|
||||
target_sources(${PYG2O_MODULE_NAME}
|
||||
PRIVATE
|
||||
Dictionary.cpp
|
||||
)
|
||||
|
||||
target_include_directories(${PYG2O_MODULE_NAME}
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_LIST_DIR}/
|
||||
)
|
||||
@@ -1,41 +0,0 @@
|
||||
|
||||
#include <sqapi.h>
|
||||
#include <pybind11/embed.h>
|
||||
#include <CustomTypes.h>
|
||||
#include "Dictionary.h"
|
||||
|
||||
namespace py = pybind11;
|
||||
|
||||
Sqrat::Table* PyDictionary::toSqObject(py::dict value)
|
||||
{
|
||||
Sqrat::Table* result = new Sqrat::Table(Sqrat::DefaultVM::Get());
|
||||
HSQUIRRELVM vm = Sqrat::DefaultVM::Get();
|
||||
|
||||
for(auto item : value)
|
||||
{
|
||||
std::string key = item.first.cast<std::string>();
|
||||
|
||||
if (py::isinstance<py::str>(item.second))
|
||||
result->SetValue(key.c_str(), item.second.cast<std::string>().c_str());
|
||||
else if (py::isinstance<py::int_>(item.second))
|
||||
result->SetValue(key.c_str(), item.second.cast<int>());
|
||||
else if (py::isinstance<py::float_>(item.second))
|
||||
result->SetValue(key.c_str(), item.second.cast<float>());
|
||||
else if (py::isinstance<py::bool_>(item.second))
|
||||
result->SetValue(key.c_str(), item.second.cast<bool>());
|
||||
else if (py::isinstance<py::dict>(item.second))
|
||||
{
|
||||
Sqrat::Table *pTable = PyDictionary::toSqObject(item.second.cast<py::dict>());
|
||||
|
||||
sq_pushobject(vm, result->GetObject());
|
||||
sq_pushstring(vm, key.c_str(), -1);
|
||||
sq_pushobject(vm, pTable->GetObject());
|
||||
sq_newslot(vm, -3, false);
|
||||
sq_pop(vm,1);
|
||||
|
||||
delete pTable;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
@@ -1,15 +0,0 @@
|
||||
#ifndef _PYDICTIONARY_H_
|
||||
#define _PYDICTIONARY_H_
|
||||
|
||||
#include <pybind11/embed.h>
|
||||
#include <string>
|
||||
namespace py = pybind11;
|
||||
|
||||
class PyDictionary
|
||||
{
|
||||
public:
|
||||
|
||||
static Sqrat::Table* toSqObject(py::dict value);
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user