From dfcf695f24e059b1b1e8c412d4905d677142802d Mon Sep 17 00:00:00 2001 From: AURUMVORXX Date: Sat, 12 Apr 2025 12:01:03 +0300 Subject: [PATCH 1/3] feat: Initial commit for 2.0.0 release --- .gitmodules | 6 - CMakeLists.txt | 8 - CMakePresets.json | 85 --- main.py | 0 pyproject.toml | 15 + ruff.toml | 77 +++ source/CMakeLists.txt | 37 -- source/NoNut/CMakeLists.txt | 14 - source/NoNut/LICENSE | 21 - source/NoNut/README.md | 2 - source/NoNut/include/Array.h | 51 -- source/NoNut/include/Bind.h | 32 -- source/NoNut/include/Class.h | 45 -- source/NoNut/include/CommonHeader.h | 18 - source/NoNut/include/Constant.h | 10 - source/NoNut/include/CustomTypes.h | 182 ------- source/NoNut/include/Function.h | 166 ------ source/NoNut/include/Instance.h | 13 - source/NoNut/include/Property.h | 135 ----- source/NoNut/include/StaticClass.h | 25 - source/NoNut/include/StringHelpers.h | 347 ------------ source/NoNut/include/Stringify.h | 22 - source/NoNut/include/UserData.h | 15 - source/NoNut/include/Utils.h | 108 ---- source/NoNut/source/Array.cpp | 20 - source/NoNut/source/Class.cpp | 69 --- source/NoNut/source/Constant.cpp | 14 - source/NoNut/source/CustomTypes.cpp | 181 ------- source/NoNut/source/StaticClass.cpp | 32 -- source/bind.cpp | 264 --------- source/classes/CMakeLists.txt | 17 - source/classes/python/Daedalus.h | 19 - source/classes/python/DamageDescription.h | 32 -- source/classes/python/ItemGround.h | 32 -- source/classes/python/ItemsGround.h | 24 - source/classes/python/Mds.h | 17 - source/classes/python/Packet.h | 47 -- source/classes/python/Sky.h | 31 -- source/classes/python/Way.h | 24 - source/classes/squirrel/Daedalus.cpp | 23 - source/classes/squirrel/Daedalus.h | 27 - source/classes/squirrel/DamageDescription.cpp | 18 - source/classes/squirrel/DamageDescription.h | 25 - source/classes/squirrel/ItemGround.cpp | 19 - source/classes/squirrel/ItemGround.h | 27 - source/classes/squirrel/ItemsGround.cpp | 23 - source/classes/squirrel/ItemsGround.h | 30 - source/classes/squirrel/Mds.cpp | 22 - source/classes/squirrel/Mds.h | 26 - source/classes/squirrel/Packet.cpp | 64 --- source/classes/squirrel/Packet.h | 43 -- source/classes/squirrel/Sky.cpp | 30 - source/classes/squirrel/Sky.h | 34 -- source/classes/squirrel/Way.cpp | 26 - source/classes/squirrel/Way.h | 24 - source/constants/CMakeLists.txt | 10 - source/constants/sqconstants.cpp | 297 ---------- source/constants/sqconstants.h | 6 - source/dependencies/CMakeLists.txt | 13 - source/dependencies/pybind11 | 1 - source/dependencies/sqapi | 1 - source/events/CMakeLists.txt | 16 - source/events/sqevents.cpp | 101 ---- source/events/sqevents.h | 63 --- source/events/sqevents_anticheat.cpp | 17 - source/events/sqevents_general.cpp | 66 --- source/events/sqevents_network.cpp | 24 - source/events/sqevents_npc.cpp | 72 --- source/events/sqevents_player.cpp | 512 ------------------ source/functions/CMakeLists.txt | 11 - source/functions/python/functions.cpp | 198 ------- source/functions/python/functions.h | 147 ----- source/functions/squirrel/functions.cpp | 155 ------ source/functions/squirrel/functions.h | 161 ------ source/main.cpp | 54 -- source/types/CMakeLists.txt | 10 - source/types/Dictionary.cpp | 41 -- source/types/Dictionary.h | 15 - src/pyg2o/__init__.py | 1 + 79 files changed, 93 insertions(+), 4617 deletions(-) delete mode 100644 .gitmodules delete mode 100644 CMakeLists.txt delete mode 100644 CMakePresets.json create mode 100644 main.py create mode 100644 pyproject.toml create mode 100644 ruff.toml delete mode 100644 source/CMakeLists.txt delete mode 100644 source/NoNut/CMakeLists.txt delete mode 100644 source/NoNut/LICENSE delete mode 100644 source/NoNut/README.md delete mode 100644 source/NoNut/include/Array.h delete mode 100644 source/NoNut/include/Bind.h delete mode 100644 source/NoNut/include/Class.h delete mode 100644 source/NoNut/include/CommonHeader.h delete mode 100644 source/NoNut/include/Constant.h delete mode 100644 source/NoNut/include/CustomTypes.h delete mode 100644 source/NoNut/include/Function.h delete mode 100644 source/NoNut/include/Instance.h delete mode 100644 source/NoNut/include/Property.h delete mode 100644 source/NoNut/include/StaticClass.h delete mode 100644 source/NoNut/include/StringHelpers.h delete mode 100644 source/NoNut/include/Stringify.h delete mode 100644 source/NoNut/include/UserData.h delete mode 100644 source/NoNut/include/Utils.h delete mode 100644 source/NoNut/source/Array.cpp delete mode 100644 source/NoNut/source/Class.cpp delete mode 100644 source/NoNut/source/Constant.cpp delete mode 100644 source/NoNut/source/CustomTypes.cpp delete mode 100644 source/NoNut/source/StaticClass.cpp delete mode 100644 source/bind.cpp delete mode 100644 source/classes/CMakeLists.txt delete mode 100644 source/classes/python/Daedalus.h delete mode 100644 source/classes/python/DamageDescription.h delete mode 100644 source/classes/python/ItemGround.h delete mode 100644 source/classes/python/ItemsGround.h delete mode 100644 source/classes/python/Mds.h delete mode 100644 source/classes/python/Packet.h delete mode 100644 source/classes/python/Sky.h delete mode 100644 source/classes/python/Way.h delete mode 100644 source/classes/squirrel/Daedalus.cpp delete mode 100644 source/classes/squirrel/Daedalus.h delete mode 100644 source/classes/squirrel/DamageDescription.cpp delete mode 100644 source/classes/squirrel/DamageDescription.h delete mode 100644 source/classes/squirrel/ItemGround.cpp delete mode 100644 source/classes/squirrel/ItemGround.h delete mode 100644 source/classes/squirrel/ItemsGround.cpp delete mode 100644 source/classes/squirrel/ItemsGround.h delete mode 100644 source/classes/squirrel/Mds.cpp delete mode 100644 source/classes/squirrel/Mds.h delete mode 100644 source/classes/squirrel/Packet.cpp delete mode 100644 source/classes/squirrel/Packet.h delete mode 100644 source/classes/squirrel/Sky.cpp delete mode 100644 source/classes/squirrel/Sky.h delete mode 100644 source/classes/squirrel/Way.cpp delete mode 100644 source/classes/squirrel/Way.h delete mode 100644 source/constants/CMakeLists.txt delete mode 100644 source/constants/sqconstants.cpp delete mode 100644 source/constants/sqconstants.h delete mode 100644 source/dependencies/CMakeLists.txt delete mode 160000 source/dependencies/pybind11 delete mode 160000 source/dependencies/sqapi delete mode 100644 source/events/CMakeLists.txt delete mode 100644 source/events/sqevents.cpp delete mode 100644 source/events/sqevents.h delete mode 100644 source/events/sqevents_anticheat.cpp delete mode 100644 source/events/sqevents_general.cpp delete mode 100644 source/events/sqevents_network.cpp delete mode 100644 source/events/sqevents_npc.cpp delete mode 100644 source/events/sqevents_player.cpp delete mode 100644 source/functions/CMakeLists.txt delete mode 100644 source/functions/python/functions.cpp delete mode 100644 source/functions/python/functions.h delete mode 100644 source/functions/squirrel/functions.cpp delete mode 100644 source/functions/squirrel/functions.h delete mode 100644 source/main.cpp delete mode 100644 source/types/CMakeLists.txt delete mode 100644 source/types/Dictionary.cpp delete mode 100644 source/types/Dictionary.h create mode 100644 src/pyg2o/__init__.py diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index f6f44fd..0000000 --- a/.gitmodules +++ /dev/null @@ -1,6 +0,0 @@ -[submodule "source/dependencies/sqapi"] - path = source/dependencies/sqapi - url = https://gitlab.com/GothicMultiplayerTeam/dependencies/sqapi.git -[submodule "source/dependencies/pybind11"] - path = source/dependencies/pybind11 - url = https://github.com/pybind/pybind11.git diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index f848768..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -cmake_minimum_required(VERSION 3.21) -set(CMAKE_CXX_STANDARD 20) -set(CMAKE_CXX_STANDARD_REQUIRED TRUE) - -project(PyG2O VERSION 1.3.1.0) -set(PYG2O_MODULE_NAME PyG2O) - -add_subdirectory(source) \ No newline at end of file diff --git a/CMakePresets.json b/CMakePresets.json deleted file mode 100644 index ebb9832..0000000 --- a/CMakePresets.json +++ /dev/null @@ -1,85 +0,0 @@ -{ - "version": 3, - "configurePresets": [ - { - "name": "windows", - "hidden": true, - "generator": "Ninja", - "binaryDir": "${sourceDir}/build/${presetName}", - "condition": { - "type": "equals", - "lhs": "${hostSystemName}", - "rhs": "Windows" - }, - "cacheVariables": { - "CMAKE_C_COMPILER": "cl.exe", - "CMAKE_CXX_COMPILER": "cl.exe" - } - }, - { - "name": "linux", - "hidden": true, - "generator": "Unix Makefiles", - "binaryDir": "${sourceDir}/build/${presetName}", - "condition": { - "type": "equals", - "lhs": "${hostSystemName}", - "rhs": "Linux" - }, - "cacheVariables": { - "CMAKE_CXX_FLAGS": "-static-libgcc -static-libstdc++" - } - }, - { - "name": "x64", - "hidden": true, - "architecture": { - "value": "x64", - "strategy": "external" - }, - "cacheVariables": { - "OUT_FILE_SUFFIX": "x64" - } - }, - { - "name": "arm64", - "hidden": true, - "architecture": { - "value": "arm64", - "strategy": "external" - }, - "cacheVariables": { - "OUT_FILE_SUFFIX": "arm64" - } - }, - { - "name": "debug", - "hidden": true, - "cacheVariables": { - "CMAKE_BUILD_TYPE": "Debug" - } - }, - { - "name": "release", - "hidden": true, - "cacheVariables": { - "CMAKE_BUILD_TYPE": "Release" - } - }, - - { "name": "Windows-x64-Debug", "inherits": ["windows", "x64", "debug"] }, - { "name": "Windows-x64-Release", "inherits": ["windows", "x64", "release"] }, - { "name": "Linux-x64-Debug", "inherits": ["linux", "x64", "debug"] }, - { "name": "Linux-x64-Release", "inherits": ["linux", "x64", "release"] }, - { "name": "Linux-arm64-Debug", "inherits": ["linux", "arm64", "debug"] }, - { "name": "Linux-arm64-Release", "inherits": ["linux", "arm64", "release"] } - ], - "buildPresets": [ - { "name": "Windows-x64-Debug", "configurePreset": "Windows-x64-Debug" }, - { "name": "Windows-x64-Release", "configurePreset": "Windows-x64-Release" }, - { "name": "Linux-x64-Debug", "configurePreset": "Linux-x64-Debug" }, - { "name": "Linux-x64-Release", "configurePreset": "Linux-x64-Release" }, - { "name": "Linux-arm64-Debug", "configurePreset": "Linux-arm64-Debug" }, - { "name": "Linux-arm64-Release", "configurePreset": "Linux-arm64-Release" } - ] -} \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..e69de29 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..8927fca --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,15 @@ +[build-systems] +requires = ["setuptools>=42"] +build-backend = "setuptools.build_meta" + +[project] +name = "PyG2O" +version = "2.0.0" +description = "Python support for Gothic 2 Online" +authors = [{name = "AURUMVORAX", email = "aurumvorax.enthroned@gmail.com"}] +readme = "README.md" +requires-python = ">=3.13" +license = {text = "MIT"} + +[project.urls] +Homepage = "https://github.com/AURUMVORXX/PyG2O" \ No newline at end of file diff --git a/ruff.toml b/ruff.toml new file mode 100644 index 0000000..5b14ed6 --- /dev/null +++ b/ruff.toml @@ -0,0 +1,77 @@ +# Exclude a variety of commonly ignored directories. +exclude = [ + ".bzr", + ".direnv", + ".eggs", + ".git", + ".git-rewrite", + ".hg", + ".ipynb_checkpoints", + ".mypy_cache", + ".nox", + ".pants.d", + ".pyenv", + ".pytest_cache", + ".pytype", + ".ruff_cache", + ".svn", + ".tox", + ".venv", + ".vscode", + "__pypackages__", + "_build", + "buck-out", + "build", + "dist", + "node_modules", + "site-packages", + "venv", +] + +# Same as Black. +line-length = 88 +indent-width = 4 + +# Assume Python 3.9 +target-version = "py39" + +[lint] +# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default. +# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or +# McCabe complexity (`C901`) by default. +select = ["E4", "E7", "E9", "F"] +ignore = [] + +# Allow fix for all enabled rules (when `--fix`) is provided. +fixable = ["ALL"] +unfixable = [] + +# Allow unused variables when underscore-prefixed. +dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" + +[format] +# Like Black, use double quotes for strings. +quote-style = "double" + +# Like Black, indent with spaces, rather than tabs. +indent-style = "space" + +# Like Black, respect magic trailing commas. +skip-magic-trailing-comma = false + +# Like Black, automatically detect the appropriate line ending. +line-ending = "auto" + +# Enable auto-formatting of code examples in docstrings. Markdown, +# reStructuredText code/literal blocks and doctests are all supported. +# +# This is currently disabled by default, but it is planned for this +# to be opt-out in the future. +docstring-code-format = false + +# Set the line length limit used when formatting code snippets in +# docstrings. +# +# This only has an effect when the `docstring-code-format` setting is +# enabled. +docstring-code-line-length = "dynamic" \ No newline at end of file diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt deleted file mode 100644 index 3558bf9..0000000 --- a/source/CMakeLists.txt +++ /dev/null @@ -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) \ No newline at end of file diff --git a/source/NoNut/CMakeLists.txt b/source/NoNut/CMakeLists.txt deleted file mode 100644 index d14b014..0000000 --- a/source/NoNut/CMakeLists.txt +++ /dev/null @@ -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/" -) \ No newline at end of file diff --git a/source/NoNut/LICENSE b/source/NoNut/LICENSE deleted file mode 100644 index 9c6472f..0000000 --- a/source/NoNut/LICENSE +++ /dev/null @@ -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. \ No newline at end of file diff --git a/source/NoNut/README.md b/source/NoNut/README.md deleted file mode 100644 index d346c15..0000000 --- a/source/NoNut/README.md +++ /dev/null @@ -1,2 +0,0 @@ -Modified version of a C++ wrapper for the Gothic 2 Online API -Original: https://gitlab.com/g2o/modules/dependencies/nonut \ No newline at end of file diff --git a/source/NoNut/include/Array.h b/source/NoNut/include/Array.h deleted file mode 100644 index ac4496c..0000000 --- a/source/NoNut/include/Array.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef NONUT_CORE_ARRAY_H -#define NONUT_CORE_ARRAY_H -#include "CommonHeader.h" - -#include "Utils.h" -#include - -namespace nonut -{ - class Array - { - public: - explicit Array(SQObject object); - ~Array(); - - [[nodiscard]] size_t size() const; - - template - 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) - { - 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 diff --git a/source/NoNut/include/Bind.h b/source/NoNut/include/Bind.h deleted file mode 100644 index 3ab66d1..0000000 --- a/source/NoNut/include/Bind.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef NONUT_CORE_BIND_H -#define NONUT_CORE_BIND_H - -#include "CommonHeader.h" -#include - -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 - //static void Function(String functionName, F& function) - //{ - // - //} - }; -} -#endif // NONUT_CORE_BIND_H diff --git a/source/NoNut/include/Class.h b/source/NoNut/include/Class.h deleted file mode 100644 index 5a41b28..0000000 --- a/source/NoNut/include/Class.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef NONUT_CORE_CLASS_H -#define NONUT_CORE_CLASS_H -#include "CommonHeader.h" -#include - -#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 - void classCtor(Args ... args) - { - Function ctor(CONSTRUCTOR_NAME, classObjectInstance, classObject); - ctor(std::forward(args)...); - } - - bool bIsNull = false; - }; -} -#endif // NONUT_CORE_CLASS_H diff --git a/source/NoNut/include/CommonHeader.h b/source/NoNut/include/CommonHeader.h deleted file mode 100644 index 53a6e49..0000000 --- a/source/NoNut/include/CommonHeader.h +++ /dev/null @@ -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_ diff --git a/source/NoNut/include/Constant.h b/source/NoNut/include/Constant.h deleted file mode 100644 index db10fc1..0000000 --- a/source/NoNut/include/Constant.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef NONUT_CORE_CONSTANT_H -#define NONUT_CORE_CONSTANT_H -#include "CommonHeader.h" -#include - -namespace nonut -{ - SQObject getConstTable(); -}; -#endif // NONUT_CORE_CONSTANT_H diff --git a/source/NoNut/include/CustomTypes.h b/source/NoNut/include/CustomTypes.h deleted file mode 100644 index 5756f05..0000000 --- a/source/NoNut/include/CustomTypes.h +++ /dev/null @@ -1,182 +0,0 @@ -#ifndef NONUT_G2O_SHARED_CUSTOM_TYPES_H -#define NONUT_G2O_SHARED_CUSTOM_TYPES_H - -#include -#include -#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 diff --git a/source/NoNut/include/Function.h b/source/NoNut/include/Function.h deleted file mode 100644 index a40e5b2..0000000 --- a/source/NoNut/include/Function.h +++ /dev/null @@ -1,166 +0,0 @@ -#ifndef NONUT_CORE_FUNCTION_H -#define NONUT_CORE_FUNCTION_H - -#include -#include - -#include -#include "Utils.h" - -#define FUNCTION_CTOR(function) function(#function) - -namespace nonut -{ - class Class; - - template - 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) - { - 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 result; - - if constexpr (std::derived_from) - { - result = std::make_optional(); - auto intermediateResult = returnVar(); - result.value().convert(intermediateResult); - sq_release(vm, &intermediateResult); - sq_resetobject(&intermediateResult); - } - else if constexpr (std::derived_from) - { - auto intermediateResult = returnVar(); - //result = std::make_optional(ReturnType(intermediateResult)); - result.emplace(ReturnType(intermediateResult)); - - sq_release(vm, &intermediateResult); - sq_resetobject(&intermediateResult); - } - else - { - result = std::make_optional(returnVar()); - } - - 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 diff --git a/source/NoNut/include/Instance.h b/source/NoNut/include/Instance.h deleted file mode 100644 index fd68a80..0000000 --- a/source/NoNut/include/Instance.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef NONUT_CORE_INSTANCE_H -#define NONUT_CORE_INSTANCE_H -#include - -namespace nonut -{ - class Instance - { - public: - [[nodiscard]] virtual SQObject getInstance() const = 0; - }; -} -#endif //NONUT_CORE_INSTANCE_H diff --git a/source/NoNut/include/Property.h b/source/NoNut/include/Property.h deleted file mode 100644 index 6bd2d29..0000000 --- a/source/NoNut/include/Property.h +++ /dev/null @@ -1,135 +0,0 @@ -#ifndef NONUT_CORE_PROPERTY_H -#define NONUT_CORE_PROPERTY_H - -#include - -#include -#include "Utils.h" -#include "Class.h" - -namespace nonut -{ - template - 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) - { - 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(const SQObject& object, const String& name) - { - return getProperty(object, name); - } - - template <> - inline String getProperty(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 - 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) - { - 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 - class Property - { - public: - Property(String propertyName, const SQObject object) : object(object), - propertyName(std::move(propertyName)) - { - } - - Property& operator=(const T& other) noexcept - { - set(other); - return *this; - } - - operator T() - { - return this->get(); - } - - [[nodiscard]] T get() const - { - return getProperty(object, propertyName); - } - - void set(T value) - { - static_assert(!IsReadOnly, "Cannot set read-only property."); - setProperty(object, propertyName, value); - } - - private: - SQObject object; - String propertyName; - }; -} -#endif // NONUT_CORE_PROPERTY_H diff --git a/source/NoNut/include/StaticClass.h b/source/NoNut/include/StaticClass.h deleted file mode 100644 index 3df68a6..0000000 --- a/source/NoNut/include/StaticClass.h +++ /dev/null @@ -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 diff --git a/source/NoNut/include/StringHelpers.h b/source/NoNut/include/StringHelpers.h deleted file mode 100644 index 27366c9..0000000 --- a/source/NoNut/include/StringHelpers.h +++ /dev/null @@ -1,347 +0,0 @@ -#ifndef NONUT_CORE_STRING_HELPERS_H -#define NONUT_CORE_STRING_HELPERS_H -#include -#include - -namespace nonut -{ - const std::unordered_map 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 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(c))) - result += WINDOWS1250_UTF8_MAP.at(static_cast(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(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(UTF8_WINDOWS1250_MAP.at(utfChar)); - } - else - { - result += '?'; - } - } - - return result; - } -} -#endif // NONUT_CORE_STRING_HELPERS_H diff --git a/source/NoNut/include/Stringify.h b/source/NoNut/include/Stringify.h deleted file mode 100644 index 9b4e3dc..0000000 --- a/source/NoNut/include/Stringify.h +++ /dev/null @@ -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 - class Stringify - { - public: - virtual ~Stringify() = default; - - [[nodiscard]] virtual String toString() const - { - return STRINGIFY(T); - } - }; -} -#endif //NONUT_CORE_STRINGIFY_H diff --git a/source/NoNut/include/UserData.h b/source/NoNut/include/UserData.h deleted file mode 100644 index 238c1bb..0000000 --- a/source/NoNut/include/UserData.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef NONUT_CORE_USER_DATA_H -#define NONUT_CORE_USER_DATA_H - -#include - -namespace nonut -{ - class UserData - { - public: - SQUserPointer userPtr = nullptr; - SQUserPointer tagPtr = nullptr; - }; -} -#endif //NONUT_CORE_INSTANCE_H diff --git a/source/NoNut/include/Utils.h b/source/NoNut/include/Utils.h deleted file mode 100644 index 504615f..0000000 --- a/source/NoNut/include/Utils.h +++ /dev/null @@ -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 - void sqGetValue(SQVM* vm, SQInteger idx, T outPtr) - { - static_assert( - std::is_same_v || - std::is_same_v || - std::is_same_v || - std::is_same_v || - std::is_same_v || - std::is_same_v, - "Not supported return type"); - - if constexpr (std::is_same_v) - sq_getbool(vm, idx, outPtr); - if constexpr (std::is_same_v) - sq_getinteger(vm, idx, outPtr); - if constexpr (std::is_same_v) - sq_getfloat(vm, idx, outPtr); - if constexpr (std::is_same_v) - sq_getstring(vm, idx, outPtr); - if constexpr (std::is_same_v) - { - sq_getstackobj(vm, idx, outPtr); - sq_addref(vm, outPtr); - } - if constexpr (std::is_same_v) - { - sq_getuserpointer(vm, idx, outPtr); - } - } - - template - void sqPushValue(SQVM* vm, T value) - { - static_assert( - std::is_same_v || - std::is_same_v || - std::is_same_v || - std::is_same_v || - std::is_same_v || - std::is_same_v || - std::is_same_v || - std::is_same_v || - std::is_same_v || - std::derived_from, - "Not supported return type"); - - if constexpr (std::is_same_v) - sq_pushbool(vm, value); - if constexpr (std::is_same_v) - sq_pushbool(vm, value); - if constexpr (std::is_same_v) - sq_pushinteger(vm, value); - if constexpr (std::is_same_v) - sq_pushfloat(vm, value); - if constexpr (std::is_same_v) - sq_pushstring(vm, value, -1); - if constexpr (std::is_same_v) - sq_pushobject(vm, value); - if constexpr (std::is_same_v || std::is_same_v) - sq_pushstring(vm, value.c_str(), value.length()); - if constexpr (std::is_same_v) - sq_pushuserpointer(vm, value); - if constexpr (std::derived_from) - sq_pushobject(vm, value.getInstance()); - } - - template - T returnVar() - { - HSQUIRRELVM vm = Sqrat::DefaultVM::Get(); - static_assert( - std::is_same_v || - std::is_same_v || - std::is_same_v || - std::is_same_v || - std::is_same_v, - "Not supported return type"); - - T result{}; - sqGetValue(vm, -1, &result); - sq_pop(vm, 1); // pops result - return result; - } - - template <> - inline String returnVar() - { - 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 diff --git a/source/NoNut/source/Array.cpp b/source/NoNut/source/Array.cpp deleted file mode 100644 index 7caa582..0000000 --- a/source/NoNut/source/Array.cpp +++ /dev/null @@ -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(result); - } -} diff --git a/source/NoNut/source/Class.cpp b/source/NoNut/source/Class.cpp deleted file mode 100644 index b631bcb..0000000 --- a/source/NoNut/source/Class.cpp +++ /dev/null @@ -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; - } -} diff --git a/source/NoNut/source/Constant.cpp b/source/NoNut/source/Constant.cpp deleted file mode 100644 index 75707b3..0000000 --- a/source/NoNut/source/Constant.cpp +++ /dev/null @@ -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; - } -} diff --git a/source/NoNut/source/CustomTypes.cpp b/source/NoNut/source/CustomTypes.cpp deleted file mode 100644 index 1c34372..0000000 --- a/source/NoNut/source/CustomTypes.cpp +++ /dev/null @@ -1,181 +0,0 @@ -#include "CustomTypes.h" - -#include "Array.h" -#include "Property.h" - -namespace nonut -{ -#define GET_SLOT(slot, type) slot = arrayWrapper.get(#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); - } - } - } -} diff --git a/source/NoNut/source/StaticClass.cpp b/source/NoNut/source/StaticClass.cpp deleted file mode 100644 index e790a75..0000000 --- a/source/NoNut/source/StaticClass.cpp +++ /dev/null @@ -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); - } -} diff --git a/source/bind.cpp b/source/bind.cpp deleted file mode 100644 index 4a2ded5..0000000 --- a/source/bind.cpp +++ /dev/null @@ -1,264 +0,0 @@ -#include - -#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 - -namespace py = pybind11; - -PYBIND11_EMBEDDED_MODULE(sqg2o, m) { - - py::class_(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_(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_(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_(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_(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_(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_(m, "Mds") - - .def_static("id", [](std::string value){ return PyMds::id(value); }) - .def_static("name", [](int value){ return PyMds::name(value); }); - -// ------------------------------------------------------------------------- - - py::class_(m, "Way") - - .def(py::init()) - .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); -} \ No newline at end of file diff --git a/source/classes/CMakeLists.txt b/source/classes/CMakeLists.txt deleted file mode 100644 index 986c236..0000000 --- a/source/classes/CMakeLists.txt +++ /dev/null @@ -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}/ -) \ No newline at end of file diff --git a/source/classes/python/Daedalus.h b/source/classes/python/Daedalus.h deleted file mode 100644 index 8b2d58a..0000000 --- a/source/classes/python/Daedalus.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef _PYDAEDALUS_H_ -#define _PYDAEDALUS_H_ - -#include -#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 \ No newline at end of file diff --git a/source/classes/python/DamageDescription.h b/source/classes/python/DamageDescription.h deleted file mode 100644 index 6050342..0000000 --- a/source/classes/python/DamageDescription.h +++ /dev/null @@ -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 \ No newline at end of file diff --git a/source/classes/python/ItemGround.h b/source/classes/python/ItemGround.h deleted file mode 100644 index b4c9325..0000000 --- a/source/classes/python/ItemGround.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef _PY_ITEMGROUND_H_ -#define _PY_ITEMGROUND_H_ - -#include -#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 \ No newline at end of file diff --git a/source/classes/python/ItemsGround.h b/source/classes/python/ItemsGround.h deleted file mode 100644 index 7f97990..0000000 --- a/source/classes/python/ItemsGround.h +++ /dev/null @@ -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 \ No newline at end of file diff --git a/source/classes/python/Mds.h b/source/classes/python/Mds.h deleted file mode 100644 index 4408536..0000000 --- a/source/classes/python/Mds.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef _PYMDS_H -#define _PYMDS_H - -#include -#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 \ No newline at end of file diff --git a/source/classes/python/Packet.h b/source/classes/python/Packet.h deleted file mode 100644 index aec9487..0000000 --- a/source/classes/python/Packet.h +++ /dev/null @@ -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 \ No newline at end of file diff --git a/source/classes/python/Sky.h b/source/classes/python/Sky.h deleted file mode 100644 index 82fdaad..0000000 --- a/source/classes/python/Sky.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef _PYSKY_H_ -#define _PYSKY_H_ - -#include -#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 \ No newline at end of file diff --git a/source/classes/python/Way.h b/source/classes/python/Way.h deleted file mode 100644 index 427be81..0000000 --- a/source/classes/python/Way.h +++ /dev/null @@ -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 \ No newline at end of file diff --git a/source/classes/squirrel/Daedalus.cpp b/source/classes/squirrel/Daedalus.cpp deleted file mode 100644 index a75d0f6..0000000 --- a/source/classes/squirrel/Daedalus.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include -#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) - { - } -} diff --git a/source/classes/squirrel/Daedalus.h b/source/classes/squirrel/Daedalus.h deleted file mode 100644 index 45bab05..0000000 --- a/source/classes/squirrel/Daedalus.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef _DAEDALUS_H_ -#define _DAEDALUS_H_ -#include - -#include -#include - -namespace nonut -{ - class Daedalus : public StaticClass - { - public: - static Daedalus* get(); - - Function index; - Function symbol; - Function instance; - - private: - - static inline Daedalus* inst = nullptr; - - Daedalus(); - }; -} -#endif - diff --git a/source/classes/squirrel/DamageDescription.cpp b/source/classes/squirrel/DamageDescription.cpp deleted file mode 100644 index 4c6cf7f..0000000 --- a/source/classes/squirrel/DamageDescription.cpp +++ /dev/null @@ -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) - { - } -} diff --git a/source/classes/squirrel/DamageDescription.h b/source/classes/squirrel/DamageDescription.h deleted file mode 100644 index 763a02d..0000000 --- a/source/classes/squirrel/DamageDescription.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef _DAMAGEDESCRIPTION_H_ -#define _DAMAGEDESCRIPTION_H_ -#include - -#include -#include - -namespace nonut -{ - class DamageDescription : public Class - { - public: - DamageDescription(SQObject object); - - Property flags; - Property damage; - Property item_instance; - Property distance; - Property spell_id; - Property spell_level; - Property node; - }; -} -#endif - diff --git a/source/classes/squirrel/ItemGround.cpp b/source/classes/squirrel/ItemGround.cpp deleted file mode 100644 index 5f8fcc9..0000000 --- a/source/classes/squirrel/ItemGround.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include -#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) - { - } -} diff --git a/source/classes/squirrel/ItemGround.h b/source/classes/squirrel/ItemGround.h deleted file mode 100644 index 1f4e406..0000000 --- a/source/classes/squirrel/ItemGround.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef _ITEMGROUND_H -#define _ITEMGROUND_H -#include - -#include -#include - -namespace nonut -{ - class ItemGround : public Class - { - public: - ItemGround(SQObject object); - - Function getPosition; - Function getRotation; - - // Properties - Property id; - Property instance; - Property amount; - Property world; - Property virtualWorld; - }; -} -#endif - diff --git a/source/classes/squirrel/ItemsGround.cpp b/source/classes/squirrel/ItemsGround.cpp deleted file mode 100644 index d80f33e..0000000 --- a/source/classes/squirrel/ItemsGround.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include -#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) - { - } -} diff --git a/source/classes/squirrel/ItemsGround.h b/source/classes/squirrel/ItemsGround.h deleted file mode 100644 index c8dd665..0000000 --- a/source/classes/squirrel/ItemsGround.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef _ITEMSGROUND_H_ -#define _ITEMSGROUND_H_ -#include - -#include -#include -#include "ItemGround.h" -#include -namespace py = pybind11; - -namespace nonut -{ - class ItemsGround : public StaticClass - { - public: - static ItemsGround* get(); - - Function getById; - Function create; - Function destroy; - - private: - - static inline ItemsGround* inst = nullptr; - - ItemsGround(); - }; -} -#endif - diff --git a/source/classes/squirrel/Mds.cpp b/source/classes/squirrel/Mds.cpp deleted file mode 100644 index e409d64..0000000 --- a/source/classes/squirrel/Mds.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include -#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) - { - } -} diff --git a/source/classes/squirrel/Mds.h b/source/classes/squirrel/Mds.h deleted file mode 100644 index 93fbb49..0000000 --- a/source/classes/squirrel/Mds.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef _MDS_H -#define _MDS_H -#include - -#include -#include - -namespace nonut -{ - class Mds : public StaticClass - { - public: - static Mds* get(); - - Function id; - Function name; - - private: - - static inline Mds* inst = nullptr; - - Mds(); - }; -} -#endif - diff --git a/source/classes/squirrel/Packet.cpp b/source/classes/squirrel/Packet.cpp deleted file mode 100644 index 3229606..0000000 --- a/source/classes/squirrel/Packet.cpp +++ /dev/null @@ -1,64 +0,0 @@ -#include -#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) - { - } -} diff --git a/source/classes/squirrel/Packet.h b/source/classes/squirrel/Packet.h deleted file mode 100644 index 0cf0f74..0000000 --- a/source/classes/squirrel/Packet.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef _PACKET_H_ -#define _PACKET_H_ -#include - -#include -#include - -namespace nonut -{ - class Packet : public Class - { - public: - Packet(); - explicit Packet(SQObject object); - - Function reset; - Function send; - Function sendToAll; - Function writeBool; - Function writeInt8; - Function writeUInt8; - Function writeInt16; - Function writeUInt16; - Function writeInt32; - Function writeUInt32; - Function writeFloat; - Function writeString; - Function readBool; - Function readInt8; - Function readUInt8; - Function readInt16; - Function readUInt16; - Function readInt32; - Function readUInt32; - Function readFloat; - Function readString; - - Property bitsUsed; - Property bytesUsed; - }; -} -#endif - diff --git a/source/classes/squirrel/Sky.cpp b/source/classes/squirrel/Sky.cpp deleted file mode 100644 index 0729bea..0000000 --- a/source/classes/squirrel/Sky.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include -#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) - { - } -} diff --git a/source/classes/squirrel/Sky.h b/source/classes/squirrel/Sky.h deleted file mode 100644 index 542cfee..0000000 --- a/source/classes/squirrel/Sky.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef _SKY_H_ -#define _SKY_H_ -#include - -#include -#include - -namespace nonut -{ - class Sky : public StaticClass - { - public: - static Sky* get(); - - Function setRainStartTime; - Function getRainStartTime; - Function setRainStopTime; - Function getRainStopTime; - - Property weather; - Property raining; - Property renderLightning; - Property windScale; - Property dontRain; - - private: - - static inline Sky* inst = nullptr; - - Sky(); - }; -} -#endif - diff --git a/source/classes/squirrel/Way.cpp b/source/classes/squirrel/Way.cpp deleted file mode 100644 index 8541a3e..0000000 --- a/source/classes/squirrel/Way.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include -#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) - { - } -} diff --git a/source/classes/squirrel/Way.h b/source/classes/squirrel/Way.h deleted file mode 100644 index 1a790d8..0000000 --- a/source/classes/squirrel/Way.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef _WAY_H -#define _WAY_H -#include - -#include -#include - -namespace nonut -{ - class Way : public Class - { - public: - Way(String, String, String); - explicit Way(SQObject object); - - Property start; - Property end; - - Function getWaypoints; - Function getCountWaypoints; - }; -} -#endif - diff --git a/source/constants/CMakeLists.txt b/source/constants/CMakeLists.txt deleted file mode 100644 index 8272207..0000000 --- a/source/constants/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ - -target_sources(${PYG2O_MODULE_NAME} - PRIVATE - sqconstants.cpp -) - -target_include_directories(${PYG2O_MODULE_NAME} - PRIVATE - ${CMAKE_CURRENT_LIST_DIR}/ -) \ No newline at end of file diff --git a/source/constants/sqconstants.cpp b/source/constants/sqconstants.cpp deleted file mode 100644 index ba3a4a0..0000000 --- a/source/constants/sqconstants.cpp +++ /dev/null @@ -1,297 +0,0 @@ -#include -#include -#include "sqevents.h" -#include "sqconstants.h" - -namespace py = pybind11; -extern py::module_ g2o; - -#define GET_CONST(constName, constType) Sqrat::ConstTable().GetSlot(constName).Cast() - -// 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); -} \ No newline at end of file diff --git a/source/constants/sqconstants.h b/source/constants/sqconstants.h deleted file mode 100644 index 1a62b6d..0000000 --- a/source/constants/sqconstants.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _SQCONSTANTS_H_ -#define _SQCONSTANTS_H_ - -void registerSquirrelConstants(); - -#endif \ No newline at end of file diff --git a/source/dependencies/CMakeLists.txt b/source/dependencies/CMakeLists.txt deleted file mode 100644 index 045efab..0000000 --- a/source/dependencies/CMakeLists.txt +++ /dev/null @@ -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 -) \ No newline at end of file diff --git a/source/dependencies/pybind11 b/source/dependencies/pybind11 deleted file mode 160000 index 15d9dae..0000000 --- a/source/dependencies/pybind11 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 15d9dae14b148509f3e1e7a42d5b1260fffff3ad diff --git a/source/dependencies/sqapi b/source/dependencies/sqapi deleted file mode 160000 index 2ae81b0..0000000 --- a/source/dependencies/sqapi +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2ae81b0f2b78834172a3af9986d8cc2b0c0c1617 diff --git a/source/events/CMakeLists.txt b/source/events/CMakeLists.txt deleted file mode 100644 index abb9fc3..0000000 --- a/source/events/CMakeLists.txt +++ /dev/null @@ -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}/ -) \ No newline at end of file diff --git a/source/events/sqevents.cpp b/source/events/sqevents.cpp deleted file mode 100644 index f8f9632..0000000 --- a/source/events/sqevents.cpp +++ /dev/null @@ -1,101 +0,0 @@ -#include -#include -#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(); - 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); -} \ No newline at end of file diff --git a/source/events/sqevents.h b/source/events/sqevents.h deleted file mode 100644 index bd23f75..0000000 --- a/source/events/sqevents.h +++ /dev/null @@ -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 \ No newline at end of file diff --git a/source/events/sqevents_anticheat.cpp b/source/events/sqevents_anticheat.cpp deleted file mode 100644 index 18323ba..0000000 --- a/source/events/sqevents_anticheat.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include -#include -#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; -} \ No newline at end of file diff --git a/source/events/sqevents_general.cpp b/source/events/sqevents_general.cpp deleted file mode 100644 index 8e75b07..0000000 --- a/source/events/sqevents_general.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include -#include -#include -#include -#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; -} \ No newline at end of file diff --git a/source/events/sqevents_network.cpp b/source/events/sqevents_network.cpp deleted file mode 100644 index f6316c1..0000000 --- a/source/events/sqevents_network.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include -#include -#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; -} \ No newline at end of file diff --git a/source/events/sqevents_npc.cpp b/source/events/sqevents_npc.cpp deleted file mode 100644 index 1dad12e..0000000 --- a/source/events/sqevents_npc.cpp +++ /dev/null @@ -1,72 +0,0 @@ -#include -#include -#include -#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; -} \ No newline at end of file diff --git a/source/events/sqevents_player.cpp b/source/events/sqevents_player.cpp deleted file mode 100644 index a0dc26e..0000000 --- a/source/events/sqevents_player.cpp +++ /dev/null @@ -1,512 +0,0 @@ -#include -#include -#include -#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; -} \ No newline at end of file diff --git a/source/functions/CMakeLists.txt b/source/functions/CMakeLists.txt deleted file mode 100644 index 6c28ba2..0000000 --- a/source/functions/CMakeLists.txt +++ /dev/null @@ -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}/ -) \ No newline at end of file diff --git a/source/functions/python/functions.cpp b/source/functions/python/functions.cpp deleted file mode 100644 index f2f5363..0000000 --- a/source/functions/python/functions.cpp +++ /dev/null @@ -1,198 +0,0 @@ -#include -#include -#include - -#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; } \ No newline at end of file diff --git a/source/functions/python/functions.h b/source/functions/python/functions.h deleted file mode 100644 index e2bfd8b..0000000 --- a/source/functions/python/functions.h +++ /dev/null @@ -1,147 +0,0 @@ -#ifndef _PYFUNCTIONS_ -#define _PYFUNCTIONS_ - -#include -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 \ No newline at end of file diff --git a/source/functions/squirrel/functions.cpp b/source/functions/squirrel/functions.cpp deleted file mode 100644 index a71e13b..0000000 --- a/source/functions/squirrel/functions.cpp +++ /dev/null @@ -1,155 +0,0 @@ -#include -#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; - } - -} \ No newline at end of file diff --git a/source/functions/squirrel/functions.h b/source/functions/squirrel/functions.h deleted file mode 100644 index c92d231..0000000 --- a/source/functions/squirrel/functions.h +++ /dev/null @@ -1,161 +0,0 @@ -#ifndef _SQFUNCTIONS_ -#define _SQFUNCTIONS_ - -#include -#include - -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 getHostname; - Function getMaxSlots; - Function getPlayersCount; - - Function getDistance2d; - Function getDistance3d; - Function getVectorAngle; - - Function sendMessageToAll; - Function sendMessageToPlayer; - Function sendPlayerMessageToAll; - Function sendPlayerMessageToPlayer; - - Function exit; - Function getDayLength; - Function getServerDescription; - Function getServerWorld; - Function getTime; - Function serverLog; - Function setDayLength; - Function setServerDescription; - Function setServerWorld; - Function setTime; - - Function clearNpcActions; - Function createNpc; - Function destroyNpc; - Function getNpcAction; - //Function getNpcActionType; - Function getNpcActions; - Function getNpcActionsCount; - Function getNpcHostPlayer; - Function getNpcLastActionId; - Function isNpc; - Function isNpcActionFinished; - Function npcAttackMelee; - Function npcAttackRanged; - Function npcSpellCast; - Function npcUseClosestMob; - //Function pushNpcAction; - Function setNpcHostPlayer; - - Function addBan; - Function applyPlayerOverlay; - Function ban; - Function drawWeapon; - Function equipItem; - Function getPlayerAmulet; - Function getPlayerAngle; - Function getPlayerAni; - Function getPlayerArmor; - Function getPlayerAtVector; - Function getPlayerBelt; - Function getPlayerCameraPosition; - Function getPlayerCollision; - Function getPlayerColor; - Function getPlayerContext; - Function getPlayerDexterity; - Function getPlayerFaceAnis; - Function getPlayerFatness; - Function getPlayerFocus; - Function getPlayerHealth; - Function getPlayerHelmet; - Function getPlayerIP; - Function getPlayerInstance; - Function getPlayerMacAddr; - Function getPlayerMana; - Function getPlayerMaxHealth; - Function getPlayerMaxMana; - Function getPlayerMeleeWeapon; - Function getPlayerName; - Function getPlayerPing; - Function getPlayerPosition; - Function getPlayerRangedWeapon; - Function getPlayerRespawnTime; - Function getPlayerRing; - Function getPlayerScale; - Function getPlayerSerial; - Function getPlayerShield; - Function getPlayerSkillWeapon; - Function getPlayerSpell; - Function getPlayerStrength; - Function getPlayerTalent; - Function getPlayerUID; - Function getPlayerVirtualWorld; - Function getPlayerVisual; - Function getPlayerWeaponMode; - Function getPlayerWorld; - Function giveItem; - Function hitPlayer; - Function isPlayerConnected; - Function isPlayerDead; - Function isPlayerUnconscious; - Function kick; - Function playAni; - Function playFaceAni; - Function readySpell; - Function removeItem; - Function removePlayerOverlay; - Function removeWeapon; - Function respawnPlayer; - Function setPlayerAngle; - Function setPlayerCollision; - Function setPlayerColor; - Function setPlayerContext; - Function setPlayerDexterity; - Function setPlayerFatness; - Function setPlayerHealth; - Function setPlayerInstance; - Function setPlayerInvisible; - Function setPlayerMana; - Function setPlayerMaxHealth; - Function setPlayerMaxMana; - Function setPlayerName; - Function setPlayerPosition; - Function setPlayerRespawnTime; - Function setPlayerScale; - Function setPlayerSkillWeapon; - Function setPlayerStrength; - Function setPlayerTalent; - Function setPlayerVirtualWorld; - Function setPlayerVisual; - Function setPlayerWeaponMode; - Function setPlayerWorld; - Function spawnPlayer; - Function stopAni; - Function stopFaceAni; - Function unequipItem; - Function unreadySpell; - Function unspawnPlayer; - Function useItem; - Function useItemToState; - - Function findNearbyPlayers; - Function getSpawnedPlayersForPlayer; - Function getStreamedPlayersByPlayer; - - Function getNearestWaypoint; - Function getWaypoint; - }; -} - -#endif \ No newline at end of file diff --git a/source/main.cpp b/source/main.cpp deleted file mode 100644 index 97f727d..0000000 --- a/source/main.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include -#include -#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; -} \ No newline at end of file diff --git a/source/types/CMakeLists.txt b/source/types/CMakeLists.txt deleted file mode 100644 index e6305f6..0000000 --- a/source/types/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ - -target_sources(${PYG2O_MODULE_NAME} - PRIVATE - Dictionary.cpp -) - -target_include_directories(${PYG2O_MODULE_NAME} - PRIVATE - ${CMAKE_CURRENT_LIST_DIR}/ -) \ No newline at end of file diff --git a/source/types/Dictionary.cpp b/source/types/Dictionary.cpp deleted file mode 100644 index 268cb92..0000000 --- a/source/types/Dictionary.cpp +++ /dev/null @@ -1,41 +0,0 @@ - -#include -#include -#include -#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(); - - if (py::isinstance(item.second)) - result->SetValue(key.c_str(), item.second.cast().c_str()); - else if (py::isinstance(item.second)) - result->SetValue(key.c_str(), item.second.cast()); - else if (py::isinstance(item.second)) - result->SetValue(key.c_str(), item.second.cast()); - else if (py::isinstance(item.second)) - result->SetValue(key.c_str(), item.second.cast()); - else if (py::isinstance(item.second)) - { - Sqrat::Table *pTable = PyDictionary::toSqObject(item.second.cast()); - - 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; -}; \ No newline at end of file diff --git a/source/types/Dictionary.h b/source/types/Dictionary.h deleted file mode 100644 index 7ed5c18..0000000 --- a/source/types/Dictionary.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef _PYDICTIONARY_H_ -#define _PYDICTIONARY_H_ - -#include -#include -namespace py = pybind11; - -class PyDictionary -{ -public: - - static Sqrat::Table* toSqObject(py::dict value); -}; - -#endif \ No newline at end of file diff --git a/src/pyg2o/__init__.py b/src/pyg2o/__init__.py new file mode 100644 index 0000000..93a11b2 --- /dev/null +++ b/src/pyg2o/__init__.py @@ -0,0 +1 @@ +print('Hello') \ No newline at end of file From 988f901dc8ca7168383b1de83f2afbf7044f6df5 Mon Sep 17 00:00:00 2001 From: AURUMVORXX Date: Tue, 15 Apr 2025 12:20:31 +0300 Subject: [PATCH 2/3] feat: version 2.0.0 --- include/events.nut | 626 ++++++++++++ include/main.nut | 128 +++ include/pyg2o.xml | 4 + main.py | 0 pyproject.toml | 2 +- python/g2o/__init__.py | 155 --- python/g2o/classes/packets.py | 196 ---- python/g2o/classes/sky.py | 106 -- python/g2o/classes/way.py | 48 - python/g2o/constants/__init__.py | 13 - python/g2o/constants/anticheat.py | 3 - python/g2o/constants/context.py | 4 - python/g2o/constants/damage.py | 11 - python/g2o/constants/general.py | 5 - python/g2o/constants/hand.py | 4 - python/g2o/constants/item.py | 38 - python/g2o/constants/network.py | 5 - python/g2o/constants/npc.py | 28 - python/g2o/constants/reliability.py | 7 - python/g2o/constants/skillweapon.py | 6 - python/g2o/constants/talent.py | 24 - python/g2o/constants/weaponmode.py | 11 - python/g2o/constants/weather.py | 4 - python/g2o/functions/event.py | 248 ----- src/pyg2o/__init__.py | 160 ++- src/pyg2o/call_repr.py | 14 + {python/g2o => src/pyg2o}/classes/__init__.py | 0 {python/g2o => src/pyg2o}/classes/daedalus.py | 26 +- {python/g2o => src/pyg2o}/classes/damage.py | 58 +- {python/g2o => src/pyg2o}/classes/items.py | 70 +- {python/g2o => src/pyg2o}/classes/mds.py | 18 +- src/pyg2o/classes/sky.py | 161 ++++ src/pyg2o/constants/__init__.py | 129 +++ .../g2o => src/pyg2o}/functions/__init__.py | 0 {python/g2o => src/pyg2o}/functions/chat.py | 43 +- src/pyg2o/functions/event.py | 737 ++++++++++++++ {python/g2o => src/pyg2o}/functions/game.py | 137 ++- {python/g2o => src/pyg2o}/functions/math.py | 33 +- {python/g2o => src/pyg2o}/functions/npc.py | 153 ++- {python/g2o => src/pyg2o}/functions/player.py | 910 ++++++++++++------ .../g2o => src/pyg2o}/functions/streamer.py | 33 +- .../g2o => src/pyg2o}/functions/waypoint.py | 23 +- src/pyg2o/serialize.py | 14 + src/pyg2o/server.py | 126 +++ 44 files changed, 3143 insertions(+), 1378 deletions(-) create mode 100644 include/events.nut create mode 100644 include/main.nut create mode 100644 include/pyg2o.xml delete mode 100644 main.py delete mode 100644 python/g2o/__init__.py delete mode 100644 python/g2o/classes/packets.py delete mode 100644 python/g2o/classes/sky.py delete mode 100644 python/g2o/classes/way.py delete mode 100644 python/g2o/constants/__init__.py delete mode 100644 python/g2o/constants/anticheat.py delete mode 100644 python/g2o/constants/context.py delete mode 100644 python/g2o/constants/damage.py delete mode 100644 python/g2o/constants/general.py delete mode 100644 python/g2o/constants/hand.py delete mode 100644 python/g2o/constants/item.py delete mode 100644 python/g2o/constants/network.py delete mode 100644 python/g2o/constants/npc.py delete mode 100644 python/g2o/constants/reliability.py delete mode 100644 python/g2o/constants/skillweapon.py delete mode 100644 python/g2o/constants/talent.py delete mode 100644 python/g2o/constants/weaponmode.py delete mode 100644 python/g2o/constants/weather.py delete mode 100644 python/g2o/functions/event.py create mode 100644 src/pyg2o/call_repr.py rename {python/g2o => src/pyg2o}/classes/__init__.py (100%) rename {python/g2o => src/pyg2o}/classes/daedalus.py (60%) rename {python/g2o => src/pyg2o}/classes/damage.py (59%) rename {python/g2o => src/pyg2o}/classes/items.py (64%) rename {python/g2o => src/pyg2o}/classes/mds.py (62%) create mode 100644 src/pyg2o/classes/sky.py create mode 100644 src/pyg2o/constants/__init__.py rename {python/g2o => src/pyg2o}/functions/__init__.py (100%) rename {python/g2o => src/pyg2o}/functions/chat.py (67%) create mode 100644 src/pyg2o/functions/event.py rename {python/g2o => src/pyg2o}/functions/game.py (62%) rename {python/g2o => src/pyg2o}/functions/math.py (65%) rename {python/g2o => src/pyg2o}/functions/npc.py (61%) rename {python/g2o => src/pyg2o}/functions/player.py (62%) rename {python/g2o => src/pyg2o}/functions/streamer.py (64%) rename {python/g2o => src/pyg2o}/functions/waypoint.py (62%) create mode 100644 src/pyg2o/serialize.py create mode 100644 src/pyg2o/server.py diff --git a/include/events.nut b/include/events.nut new file mode 100644 index 0000000..24e8c6d --- /dev/null +++ b/include/events.nut @@ -0,0 +1,626 @@ + +addEventHandler("onPlayerUseCheat", function(playerid, type) +{ + local data = { + event = "onPlayerUseCheat", + args = { + playerid = playerid, + type = type + } + } + + _PyG2O_Send(data); +}); + +addEventHandler("onBan", function(banInfo) +{ + local data = { + event = "onBan", + args = { + ban = { + mac = "mac" in banInfo ? banInfo["mac"] : "-1", + ip = "ip" in banInfo ? banInfo["ip"] : "-1", + serial = "serial" in banInfo ? banInfo["serial"] : "-1", + name = "name" in banInfo ? banInfo["name"] : "-1", + timestamp = "timestamp" in banInfo ? banInfo["timestamp"] : -1 + } + } + } + + _PyG2O_Send(data); +}); + +addEventHandler("onInit", function() +{ + local data = { + event = "onInit", + args = {} + } + + _PyG2O_Send(data); +}); + +addEventHandler("onExit", function() +{ + local data = { + event = "onExit", + args = {} + } + + _PyG2O_Send(data); +}); + +addEventHandler("onTick", function() +{ + local data = { + event = "onTick", + args = {} + } + + _PyG2O_Send(data); +}); + +addEventHandler("onTime", function(day, hour, min) +{ + local data = { + event = "onTime", + args = { + day = day, + hour = hour, + min = min, + } + } + + _PyG2O_Send(data); +}); + +addEventHandler("onUnban", function(banInfo) +{ + local data = { + event = "onUnban", + args = { + ban = { + mac = "mac" in banInfo ? banInfo["mac"] : "-1", + ip = "ip" in banInfo ? banInfo["ip"] : "-1", + serial = "serial" in banInfo ? banInfo["serial"] : "-1", + name = "name" in banInfo ? banInfo["name"] : "-1", + timestamp = "timestamp" in banInfo ? banInfo["timestamp"] : -1 + } + } + } + + _PyG2O_Send(data); +}); + +addEventHandler("onNpcActionFinished", function(npc_id, action_type, action_id, result) +{ + local data = { + event = "onNpcActionFinished", + args = { + npc_id = npc_id, + action_type = action_type, + action_id = action_id, + result = result + } + } + + _PyG2O_Send(data); +}); + +addEventHandler("onNpcActionSent", function(npc_id, action_type, action_id) +{ + local data = { + event = "onNpcActionSent", + args = { + npc_id = npc_id, + action_type = action_type, + action_id = action_id, + } + } + + _PyG2O_Send(data); +}); + +addEventHandler("onNpcChangeHostPlayer", function(npc_id, current_id, previous_id) +{ + local data = { + event = "onNpcChangeHostPlayer", + args = { + npc_id = npc_id, + current_id = current_id, + previous_id = previous_id + } + } + + _PyG2O_Send(data); +}); + +addEventHandler("onNpcCreated", function(npc_id) +{ + local data = { + event = "onNpcCreated", + args = { + npc_id = npc_id + } + } + + _PyG2O_Send(data); +}); + +addEventHandler("onNpcDestroyed", function(npc_id) +{ + local data = { + event = "onNpcDestroyed", + args = { + npc_id = npc_id + } + } + + _PyG2O_Send(data); +}); + +addEventHandler("onPlayerChangeColor", function(playerid, r, g, b) +{ + local data = { + event = "onPlayerChangeColor", + args = { + playerid = playerid, + r = r, + g = g, + b = b + } + } + + _PyG2O_Send(data); +}); + +addEventHandler("onPlayerChangeFocus", function(playerid, oldFocusId, newFocusId) +{ + local data = { + event = "onPlayerChangeFocus", + args = { + playerid = playerid, + oldFocusId = oldFocusId, + newFocusId = newFocusId + } + } + + _PyG2O_Send(data); +}); + +addEventHandler("onPlayerChangeHealth", function(playerid, previous, current) +{ + local data = { + event = "onPlayerChangeHealth", + args = { + playerid = playerid, + previous = previous, + current = current + } + } + + _PyG2O_Send(data); +}); + +addEventHandler("onPlayerChangeMana", function(playerid, previous, current) +{ + local data = { + event = "onPlayerChangeMana", + args = { + playerid = playerid, + previous = previous, + current = current + } + } + + _PyG2O_Send(data); +}); + +addEventHandler("onPlayerChangeMaxHealth", function(playerid, previous, current) +{ + local data = { + event = "onPlayerChangeMaxHealth", + args = { + playerid = playerid, + previous = previous, + current = current + } + } + + _PyG2O_Send(data); +}); + +addEventHandler("onPlayerChangeMaxMana", function(playerid, previous, current) +{ + local data = { + event = "onPlayerChangeMaxMana", + args = { + playerid = playerid, + previous = previous, + current = current + } + } + + _PyG2O_Send(data); +}); + +addEventHandler("onPlayerChangeWeaponMode", function(playerid, previous, current) +{ + local data = { + event = "onPlayerChangeWeaponMode", + args = { + playerid = playerid, + previous = previous, + current = current + } + } + + _PyG2O_Send(data); +}); + +addEventHandler("onPlayerChangeWorld", function(playerid, previous, current) +{ + local data = { + event = "onPlayerChangeWorld", + args = { + playerid = playerid, + previous = previous, + current = current + } + } + + _PyG2O_Send(data); +}); + +addEventHandler("onPlayerCommand", function(playerid, command, params) +{ + local data = { + event = "onPlayerCommand", + args = { + playerid = playerid, + command = command, + params = params + } + } + + _PyG2O_Send(data); +}); + +addEventHandler("onPlayerDamage", function(playerid, killerid, description) +{ + local data = { + event = "onPlayerDamage", + args = { + playerid = playerid, + killerid = killerid, + obj_DamageDescription = { + name = "desc", + data = _PyG2O_Serialize(description) + } + } + } + + _PyG2O_Send(data); +}); + +addEventHandler("onPlayerDead", function(playerid, killerid) +{ + local data = { + event = "onPlayerDead", + args = { + playerid = playerid, + killerid = killerid + } + } + + _PyG2O_Send(data); +}); + +addEventHandler("onPlayerDisconnect", function(playerid, reason) +{ + local data = { + event = "onPlayerDisconnect", + args = { + playerid = playerid, + reason = reason + } + } + + _PyG2O_Send(data); +}); + +addEventHandler("onPlayerDropItem", function(playerid, itemGround) +{ + local data = { + event = "onPlayerDropItem", + args = { + playerid = playerid, + obj_ItemGround = { + name = "itemGround", + data = _PyG2O_Serialize(itemGround) + } + } + } + + _PyG2O_Send(data); +}); + +addEventHandler("onPlayerEnterWorld", function(playerid, world) +{ + local data = { + event = "onPlayerEnterWorld", + args = { + playerid = playerid, + world = world + } + } + + _PyG2O_Send(data); +}); + +addEventHandler("onPlayerEquipAmulet", function(playerid, instance) +{ + local data = { + event = "onPlayerEquipAmulet", + args = { + playerid = playerid, + instance = instance + } + } + + _PyG2O_Send(data); +}); + +addEventHandler("onPlayerEquipArmor", function(playerid, instance) +{ + local data = { + event = "onPlayerEquipArmor", + args = { + playerid = playerid, + instance = instance + } + } + + _PyG2O_Send(data); +}); + +addEventHandler("onPlayerEquipBelt", function(playerid, instance) +{ + local data = { + event = "onPlayerEquipBelt", + args = { + playerid = playerid, + instance = instance + } + } + + _PyG2O_Send(data); +}); + +addEventHandler("onPlayerEquipHandItem", function(playerid, hand, instance) +{ + local data = { + event = "onPlayerEquipHandItem", + args = { + playerid = playerid, + hand = hand, + instance = instance + } + } + + _PyG2O_Send(data); +}); + +addEventHandler("onPlayerEquipHelmet", function(playerid, instance) +{ + local data = { + event = "onPlayerEquipHelmet", + args = { + playerid = playerid, + instance = instance + } + } + + _PyG2O_Send(data); +}); + +addEventHandler("onPlayerEquipMeleeWeapon", function(playerid, instance) +{ + local data = { + event = "onPlayerEquipMeleeWeapon", + args = { + playerid = playerid, + instance = instance + } + } + + _PyG2O_Send(data); +}); + +addEventHandler("onPlayerEquipRangedWeapon", function(playerid, instance) +{ + local data = { + event = "onPlayerEquipRangedWeapon", + args = { + playerid = playerid, + instance = instance + } + } + + _PyG2O_Send(data); +}); + +addEventHandler("onPlayerEquipRing", function(playerid, handId, instance) +{ + local data = { + event = "onPlayerEquipRing", + args = { + playerid = playerid, + handId = handId, + instance = instance + } + } + + _PyG2O_Send(data); +}); + +addEventHandler("onPlayerEquipShield", function(playerid, instance) +{ + local data = { + event = "onPlayerEquipShield", + args = { + playerid = playerid, + instance = instance + } + } + + _PyG2O_Send(data); +}); + +addEventHandler("onPlayerEquipSpell", function(playerid, slotId, instance) +{ + local data = { + event = "onPlayerEquipSpell", + args = { + playerid = playerid, + slotId = slotId, + instance = instance + } + } + + _PyG2O_Send(data); +}); + +addEventHandler("onPlayerJoin", function(playerid) +{ + local data = { + event = "onPlayerJoin", + args = { + playerid = playerid + } + } + + _PyG2O_Send(data); +}); + +addEventHandler("onPlayerMessage", function(playerid, message) +{ + local data = { + event = "onPlayerMessage", + args = { + playerid = playerid, + message = message + } + } + + _PyG2O_Send(data); +}); + +addEventHandler("onPlayerMobInteract", function(playerid, from, to) +{ + local data = { + event = "onPlayerMobInteract", + args = { + playerid = playerid, + from = from, + to = to + } + } + + _PyG2O_Send(data); +}); + +addEventHandler("onPlayerRespawn", function(playerid) +{ + local data = { + event = "onPlayerRespawn", + args = { + playerid = playerid + } + } + + _PyG2O_Send(data); +}); + +addEventHandler("onPlayerShoot", function(playerid, munition) +{ + local data = { + event = "onPlayerShoot", + args = { + playerid = playerid, + munition = munition + } + } + + _PyG2O_Send(data); +}); + +addEventHandler("onPlayerSpellCast", function(playerid, instance, spellLevel) +{ + local data = { + event = "onPlayerSpellCast", + args = { + playerid = playerid, + instance = instance, + spellLevel = spellLevel + } + } + + _PyG2O_Send(data); +}); + +addEventHandler("onPlayerSpellSetup", function(playerid, instance) +{ + local data = { + event = "onPlayerSpellSetup", + args = { + playerid = playerid, + instance = instance + } + } + + _PyG2O_Send(data); +}); + +addEventHandler("onPlayerTakeItem", function(playerid, itemGround) +{ + local data = { + event = "onPlayerTakeItem", + args = { + playerid = playerid, + obj_ItemGround = { + name = "itemGround", + data = _PyG2O_Serialize(itemGround) + } + } + } + + _PyG2O_Send(data); +}); + +addEventHandler("onPlayerTeleport", function(playerid, vobName) +{ + local data = { + event = "onPlayerTeleport", + args = { + playerid = playerid, + vobName = vobName + } + } + + _PyG2O_Send(data); +}); + +addEventHandler("onPlayerToggleFaceAni", function(playerid, aniName, toggle) +{ + local data = { + event = "onPlayerToggleFaceAni", + args = { + playerid = playerid, + aniName = aniName, + toggle = toggle + } + } + + _PyG2O_Send(data); +}); \ No newline at end of file diff --git a/include/main.nut b/include/main.nut new file mode 100644 index 0000000..d6178d9 --- /dev/null +++ b/include/main.nut @@ -0,0 +1,128 @@ + +local _pyg2o_server_connection = -1; +local _silent = false; +local _url = -1 +local _reconnect = false; + +function PyG2O_Start(url, reconnect = false, silent = false) +{ + _silent = silent; + _url = url; + _reconnect = reconnect; + + _pyg2o_server_connection = WebsocketClient(); + _pyg2o_server_connection.silent = true; + _pyg2o_server_connection.setUrl("ws://localhost:8080"); + _pyg2o_server_connection.start(); + + if (!_silent) + print("[PyG2O] Initializing connection on " + url) +} + +function _PyG2O_Send(data) +{ + if (_pyg2o_server_connection == -1) + return; + + _pyg2o_server_connection.send(JSON.dump_ansi(data)); +} + +function _PyG2O_InitializeConstants() +{ + local const_data = { + "type": "const_init", + "args": getconsttable() + }; + + _PyG2O_Send(const_data); +} + +function _PyG2O_GetClassName(object) +{ + if (object instanceof DamageDescription) + return "DamageDescription"; + else if (object instanceof ItemGround) + return "ItemGround"; + + return null; +} + +function _PyG2O_Serialize(object) +{ + local cls = object.getclass(); + local tab = {}; + + if (object instanceof DamageDescription) + { + tab["_flags"] <- object.flags; + tab["_damage"] <- object.damage; + tab["_item_instance"] <- object.item_instance; + tab["_distance"] <- object.distance; + tab["_spell_id"] <- object.spell_id; + tab["_spell_level"] <- object.spell_level; + tab["_node"] <- object.node; + } + else if (object instanceof ItemGround) + { + tab["_id"] <- object.id; + tab["_instance"] <- object.instance; + tab["_amount"] <- object.amount; + tab["_world"] <- object.world; + tab["_virtualWorld"] <- object.virtualWorld; + tab["_position"] <- object.getPosition(); + tab["_rotation"] <- object.getRotation(); + } + + return tab; +} + +addEventHandler("onWebsocketConnect", function(socket, url) +{ + if (socket != _pyg2o_server_connection) + return; + + if (!_silent) + { + print("[PyG2O] Successfully connected to " + url); + _PyG2O_InitializeConstants(); + } +}); + +addEventHandler("onWebsocketDisconnect", function(socket, url) +{ + if (socket != _pyg2o_server_connection || _reconnect) + return; + + _pyg2o_server_connection = -1; +}); + +addEventHandler("onWebsocketMessage", function(socket, url, message) +{ + if (socket != _pyg2o_server_connection) + return; + + local request = JSON.parse_ansi(message); + if ("uuid" in request) + { + local result = compilestring(request["args"])(); + local className = _PyG2O_GetClassName(result); + if (className != null) + { + className = format("obj_%s", className) + + request["args"] = {}; + request["args"].rawset(className, {}); + local objTab = request["args"].rawget(className); + objTab["name"] <- "result"; + objTab["data"] <- _PyG2O_Serialize(result); + } + else + { + request["args"] = + { + "result": result + }; + } + _pyg2o_server_connection.send(JSON.dump_ansi(request, 2)); + } +}); diff --git a/include/pyg2o.xml b/include/pyg2o.xml new file mode 100644 index 0000000..37df48a --- /dev/null +++ b/include/pyg2o.xml @@ -0,0 +1,4 @@ + +