diff --git a/apps/openmw-mp/CMakeLists.txt b/apps/openmw-mp/CMakeLists.txt index 75389e2b8..9a90bd744 100644 --- a/apps/openmw-mp/CMakeLists.txt +++ b/apps/openmw-mp/CMakeLists.txt @@ -7,7 +7,6 @@ if(UNIX) #temporarily disabled for non-unix endif(NOT (${CMAKE_CXX_COMPILER} MATCHES "aarch64" OR ${CMAKE_CXX_COMPILER} MATCHES "arm")) endif(UNIX) -option(BUILD_WITH_PAWN "Enable Pawn language" OFF) option(ENABLE_BREAKPAD "Enable Google Breakpad for Crash reporting" OFF) if(ENABLE_BREAKPAD) @@ -22,25 +21,6 @@ if(ENABLE_BREAKPAD) include_directories(${CMAKE_SOURCE_DIR}/extern/breakpad/src ${Breakpad_Headers}) endif(ENABLE_BREAKPAD) -if(BUILD_WITH_PAWN) - - add_subdirectory(amx) - - #set(Pawn_ROOT ${CMAKE_SOURCE_DIR}/external/pawn/) - set(Pawn_INCLUDES ${Pawn_ROOT}/include) - set(Pawn_LIBRARY ${Pawn_ROOT}/lib/libamx.a) - set(PawnScript_Sources - Script/LangPawn/LangPAWN.cpp - Script/LangPawn/PawnFunc.cpp) - set(PawnScript_Headers ${Pawn_INCLUDES} - Script/LangPawn/LangPAWN.hpp - ) - - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_PAWN -DPAWN_CELL_SIZE=64") - #include_directories(${Pawn_INCLUDES}) - include_directories("./amx/linux") -endif(BUILD_WITH_PAWN) - option(BUILD_WITH_LUA "Enable Terra/Lua language" ON) option(FORCE_LUA "Use Lua instead Terra" OFF) if(BUILD_WITH_LUA) @@ -93,7 +73,6 @@ set(SERVER Script/Functions/Timer.cpp Script/API/TimerAPI.cpp Script/API/PublicFnAPI.cpp - ${PawnScript_Sources} ${LuaScript_Sources} ${NativeScript_Sources} @@ -103,7 +82,6 @@ set(SERVER_HEADER Script/Types.hpp Script/Script.hpp Script/SystemInterface.hpp Script/ScriptFunction.hpp Script/Platform.hpp Script/Language.hpp Script/ScriptFunctions.hpp Script/API/TimerAPI.hpp Script/API/PublicFnAPI.hpp - ${PawnScript_Headers} ${LuaScript_Headers} ${NativeScript_Headers} ${CallFF_INCLUDES} @@ -194,7 +172,6 @@ target_link_libraries(tes3mp-server components ${Terra_LIBRARY} ${LUA_LIBRARIES} - ${Pawn_LIBRARY} ${Breakpad_Library} ${CallFF_LIBRARY} ) diff --git a/apps/openmw-mp/Script/API/PublicFnAPI.cpp b/apps/openmw-mp/Script/API/PublicFnAPI.cpp index 471d49e2f..c0bc713d8 100644 --- a/apps/openmw-mp/Script/API/PublicFnAPI.cpp +++ b/apps/openmw-mp/Script/API/PublicFnAPI.cpp @@ -25,14 +25,6 @@ Public::Public(ScriptFuncLua _public, lua_State *lua, const std::string &name, c publics.emplace(name, this); } -#if defined(ENABLE_PAWN) -Public::Public(ScriptFuncPAWN _public, AMX* amx, const std::string& name, char ret_type, const std::string& def): ScriptFunction(_public, amx, ret_type, def) -{ - publics.emplace(name, this); -} -#endif - - boost::any Public::Call(const std::string &name, const std::vector &args) { auto it = publics.find(name); @@ -67,21 +59,6 @@ bool Public::IsLua(const std::string &name) #endif } -bool Public::IsPAWN(const std::string &name) -{ -#if !defined(ENABLE_PAWN) - return false; -#else - auto it = publics.find(name); - - if (it == publics.end()) - throw runtime_error("Public with name \"" + name + "\" does not exist"); - - return it->second->script_type == SCRIPT_PAWN; -#endif -} - - void Public::DeleteAll() { for (auto it = publics.begin(); it != publics.end(); it++) diff --git a/apps/openmw-mp/Script/API/PublicFnAPI.hpp b/apps/openmw-mp/Script/API/PublicFnAPI.hpp index cd49185cf..84ceb1dae 100644 --- a/apps/openmw-mp/Script/API/PublicFnAPI.hpp +++ b/apps/openmw-mp/Script/API/PublicFnAPI.hpp @@ -17,9 +17,6 @@ private: static std::unordered_map publics; Public(ScriptFunc _public, const std::string &name, char ret_type, const std::string &def); -#if defined(ENABLE_PAWN) - Public(ScriptFuncPAWN _public, AMX* amx, const std::string& name, char ret_type, const std::string& def); -#endif #if defined(ENABLE_LUA) Public(ScriptFuncLua _public, lua_State *lua, const std::string &name, char ret_type, const std::string &def); #endif @@ -33,7 +30,6 @@ public: static const std::string& GetDefinition(const std::string& name); - static bool IsPAWN(const std::string &name); static bool IsLua(const std::string &name); static void DeleteAll(); diff --git a/apps/openmw-mp/Script/API/TimerAPI.cpp b/apps/openmw-mp/Script/API/TimerAPI.cpp index bdaf91f74..7489497d9 100644 --- a/apps/openmw-mp/Script/API/TimerAPI.cpp +++ b/apps/openmw-mp/Script/API/TimerAPI.cpp @@ -17,14 +17,6 @@ Timer::Timer(ScriptFunc callback, long msec, const std::string& def, std::vector end = true; } -#if defined(ENABLE_PAWN) -Timer::Timer(AMX *amx, ScriptFuncPAWN callback, long msec, const std::string &def, std::vector args): ScriptFunction(callback, amx, 'v', def) -{ - targetMsec = msec; - this->args = args; - end = true; -} -#endif #if defined(ENABLE_LUA) Timer::Timer(lua_State *lua, ScriptFuncLua callback, long msec, const std::string& def, std::vector args): ScriptFunction(callback, lua, 'v', def) { @@ -77,30 +69,6 @@ void Timer::Start() int TimerAPI::pointer = 0; std::unordered_map TimerAPI::timers; -#if defined(ENABLE_PAWN) -int TimerAPI::CreateTimerPAWN(AMX *amx, ScriptFuncPAWN callback, long msec, const string& def, std::vector args) -{ - int id = -1; - - for (auto timer : timers) - { - if (timer.second != nullptr) - continue; - timer.second = new Timer(amx, callback, msec, def, args); - id = timer.first; - } - - if (id == -1) - { - timers[pointer] = new Timer(amx, callback, msec, def, args); - id = pointer; - pointer++; - } - - return id; -} -#endif - #if defined(ENABLE_LUA) int TimerAPI::CreateTimerLua(lua_State *lua, ScriptFuncLua callback, long msec, const std::string& def, std::vector args) { diff --git a/apps/openmw-mp/Script/API/TimerAPI.hpp b/apps/openmw-mp/Script/API/TimerAPI.hpp index eec896f6e..b20be12d6 100644 --- a/apps/openmw-mp/Script/API/TimerAPI.hpp +++ b/apps/openmw-mp/Script/API/TimerAPI.hpp @@ -22,9 +22,6 @@ namespace mwmp public: Timer(ScriptFunc callback, long msec, const std::string& def, std::vector args); -#if defined(ENABLE_PAWN) - Timer(AMX *amx, ScriptFuncPAWN callback, long msec, const std::string& def, std::vector args); -#endif #if defined(ENABLE_LUA) Timer(lua_State *lua, ScriptFuncLua callback, long msec, const std::string& def, std::vector args); #endif @@ -45,9 +42,6 @@ namespace mwmp class TimerAPI { public: -#if defined(ENABLE_PAWN) - static int CreateTimerPAWN(AMX *amx, ScriptFuncPAWN callback, long msec, const std::string& def, std::vector args); -#endif #if defined(ENABLE_LUA) static int CreateTimerLua(lua_State *lua, ScriptFuncLua callback, long msec, const std::string& def, std::vector args); #endif diff --git a/apps/openmw-mp/Script/Functions/Worldstate.cpp b/apps/openmw-mp/Script/Functions/Worldstate.cpp index 2379263e2..7204c07df 100644 --- a/apps/openmw-mp/Script/Functions/Worldstate.cpp +++ b/apps/openmw-mp/Script/Functions/Worldstate.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include "Worldstate.hpp" diff --git a/apps/openmw-mp/Script/LangPawn/LangPAWN.cpp b/apps/openmw-mp/Script/LangPawn/LangPAWN.cpp deleted file mode 100644 index f80d72532..000000000 --- a/apps/openmw-mp/Script/LangPawn/LangPAWN.cpp +++ /dev/null @@ -1,458 +0,0 @@ -// -// Created by koncord on 08.05.16. -// - -#include "LangPAWN.hpp" - - -#include -#include -#include "Script.hpp" - -using namespace std; - -typedef long NetworkID; - -static vector> strings; -static vector> floats; -static pair data = {nullptr, nullptr}; - -void free_strings() noexcept { - strings.clear(); -} - -void free_floats() noexcept { - for (const auto& value : floats) - *value.first = amx_ftoc(value.second); - - floats.clear(); -} - -void free_data(unsigned int size) noexcept { - if (data.first && data.second) - for (unsigned int i = 0; i < size; ++i) - data.first[i] = data.second[i]; - - data.first = nullptr; - data.second = nullptr; -} - -void after_call() noexcept { - free_strings(); - free_floats(); -} - -template -void after_call(const R&) noexcept { - free_strings(); - free_floats(); -} - -template<> -void after_call(const unsigned int& result) noexcept { - free_strings(); - free_floats(); - free_data(result); -} - -template -struct PAWN_extract_ { - inline static R PAWN_extract(AMX*&&, const cell*&& params) noexcept { - return static_cast(forward(params)[I]); - } -}; - -template -struct PAWN_extract_ -{ - inline static void* PAWN_extract(AMX *&&amx, const cell *&¶ms) noexcept - { - return amx_Address(amx, forward(params)[I]); // fixme: I'm not sure in this fix - } -}; - -template -struct PAWN_extract_ { - inline static double PAWN_extract(AMX*&&, const cell*&& params) noexcept { - return amx_ctof(forward(params)[I]); - } -}; - -template -struct PAWN_extract_ { - inline static const char* PAWN_extract(AMX*&& amx, const cell*&& params) noexcept { - int len; - cell* source; - - source = amx_Address(amx, params[I]); - amx_StrLen(source, &len); - - strings.emplace_back(len + 1); - char* value = &strings.back()[0]; - amx_GetString(value, source, 0, UNLIMITED); - - return value; - } -}; - -template -struct PAWN_extract_ { - inline static double* PAWN_extract(AMX*&& amx, const cell*&& params) noexcept { - floats.emplace_back(amx_Address(amx, params[I]), 0.00); - return &floats.back().second; - } -}; - -template -struct PAWN_extract_ { - inline static NetworkID** PAWN_extract(AMX*&& amx, const cell*&& params) noexcept { - constexpr ScriptFunctionData const& F_ = ScriptFunctions::functions[F]; - static_assert(F_.func.numargs == I, "NetworkID** must be the last parameter"); - data.first = amx_Address(amx, params[I]); - return &data.second; - } -}; - -template -struct PAWN_dispatch_ { - template - inline static R PAWN_dispatch(AMX*&& amx, const cell*&& params, Args&&... args) noexcept { - constexpr ScriptFunctionData const& F_ = ScriptFunctions::functions[F]; - auto arg = PAWN_extract_::type, I, F>::PAWN_extract(forward(amx), forward(params)); - return PAWN_dispatch_::template PAWN_dispatch( - forward(amx), - forward(params), - arg, - forward(args)...); - } -}; - -template -struct PAWN_dispatch_<0, F> { - template - inline static R PAWN_dispatch(AMX*&&, const cell*&&, Args&&... args) noexcept { - constexpr ScriptFunctionData const& F_ = ScriptFunctions::functions[F]; - return reinterpret_cast>(F_.func.addr)(forward(args)...); - } -}; - -template -static typename enable_if::type wrapper(AMX* amx, const cell* params) noexcept { - PAWN_dispatch_::template PAWN_dispatch(forward(amx), forward(params)); - after_call(); - return 1; -} - -template -static typename enable_if::type wrapper(AMX* amx, const cell* params) noexcept { - double value = PAWN_dispatch_::template PAWN_dispatch(forward(amx), forward(params)); - after_call(); - return amx_ftoc(value); -} - -template -static typename enable_if::type wrapper(AMX* amx, const cell* params) noexcept { - const char* value = PAWN_dispatch_::template PAWN_dispatch(forward(amx), forward(params)); - after_call(); - - if (value) { - cell* dest = amx_Address(amx, params[ScriptFunctions::functions[I].func.numargs + 1]); - amx_SetString(dest, value, 1, 0, strlen(value) + 1); - return 1; - } - - return 0; -} - -template -static typename enable_if::type wrapper(AMX* amx, const cell* params) noexcept { - auto result = PAWN_dispatch_::template PAWN_dispatch::type>(forward(amx), forward(params)); - after_call(result); - return result; -} - -template struct F_ { static constexpr AMX_NATIVE_INFO F{ScriptFunctions::functions[I].name, wrapper}; }; -template<> struct F_<0> { static constexpr AMX_NATIVE_INFO F{"CreateTimer", LangPAWN::CreateTimer}; }; -template<> struct F_<1> { static constexpr AMX_NATIVE_INFO F{"CreateTimerEx", LangPAWN::CreateTimerEx}; }; -template<> struct F_<2> { static constexpr AMX_NATIVE_INFO F{"MakePublic", LangPAWN::MakePublic}; }; -template<> struct F_<3> { static constexpr AMX_NATIVE_INFO F{"CallPublic", LangPAWN::CallPublic}; }; - -void LangPAWN::LoadProgram(const char *filename) -{ - int err = aux_LoadProgram(amx, filename, 0); - if (err != AMX_ERR_NONE) - throw runtime_error("PAWN script " + string(filename) + " error (" + to_string(err) + "): \"" + string(aux_StrError(err)) + "\""); - - amx_CoreInit(amx); - amx_ConsoleInit(amx); - amx_FloatInit(amx); - amx_TimeInit(amx); - amx_StringInit(amx); - amx_FileInit(amx); - - constexpr auto functions_n = sizeof(ScriptFunctions::functions) / sizeof(ScriptFunctions::functions[0]); - - amx_Register(amx, functions(IndicesFor{}), functions_n); // TODO: throw if error - -} - -int LangPAWN::FreeProgram() -{ - int err = aux_FreeProgram(amx); - delete amx; - return err; -} - -bool LangPAWN::IsCallbackPresent(const char *name) -{ - int idx; - return (amx_FindPublic(amx, name, &idx) == AMX_ERR_NONE); -} - -boost::any LangPAWN::Call(const char *name, const char *argl, int buf, ...) -{ - va_list args; - va_start(args, buf); - cell ret = 0; - vector> strings; - - try - { - int idx = 0; - int err = 0; - - err = amx_FindPublic(amx, name, &idx); - - if (err != AMX_ERR_NONE) - throw runtime_error("PAWN runtime error (" + to_string(err) + "): \"" + string(aux_StrError(err)) + "\"."); - - unsigned int len = strlen(argl); - vector args_amx; - - for (unsigned int i = 0; i < len; ++i) - { - switch (argl[i]) - { - case 'i': - args_amx.emplace_back(va_arg(args, unsigned - int)); - break; - - case 'q': - args_amx.emplace_back(va_arg(args, signed - int)); - break; - - case 'l': - args_amx.emplace_back(va_arg(args, unsigned - long - long)); - break; - - case 'w': - args_amx.emplace_back(va_arg(args, signed - long - long)); - break; - - case 'f': - { - double value = va_arg(args, double); - args_amx.emplace_back(amx_ftoc(value)); - break; - } - - case 'p': - args_amx.emplace_back(reinterpret_cast(va_arg(args, void*))); - break; - - case 's': - args_amx.emplace_back(reinterpret_cast(va_arg(args, char*))); - break; - - default: - throw runtime_error("PAWN call: Unknown argument identifier " + argl[i]); - } - } - - for (unsigned int i = len; i; --i) - { - switch (argl[i - 1]) - { - case 's': - { - char *string = reinterpret_cast(static_cast(args_amx[i - 1])); - cell *store; - amx_PushString(amx, &store, string, 1, 0); - strings.emplace_back(store, string); - break; - } - - default: - amx_Push(amx, args_amx[i - 1]); - break; - } - } - - err = amx_Exec(amx, &ret, idx); - - if (err != AMX_ERR_NONE) - throw runtime_error("PAWN runtime error (" + to_string(err) + "): \"" + string(aux_StrError(err)) + "\"."); - - if (buf != 0) - for (const auto &str : strings) - amx_GetString(str.second, str.first, 0, strlen(str.second) + 1); - - if (!strings.empty()) - amx_Release(amx, strings[0].first); - } - - catch (...) - { - va_end(args); - - if (!strings.empty()) - amx_Release(amx, strings[0].first); - - throw; - } - - return boost::any(ret); -} - -boost::any LangPAWN::Call(const char *name, const char *argl, const std::vector &args) -{ - cell ret = 0; - cell *str = nullptr; - - try - { - int idx = 0; - int err = 0; - - err = amx_FindPublic(amx, name, &idx); - - if (err != AMX_ERR_NONE) - throw runtime_error("PAWN runtime error (" + to_string(err) + "): \"" + string(aux_StrError(err)) + "\"."); - - for (intptr_t i = strlen(argl) - 1; i >= 0; i--) - { - switch (argl[i]) - { - case 'i': - { - cell value = (cell) boost::any_cast(args.at(i)); - amx_Push(amx, value); - break; - } - - case 'q': - { - cell value = (cell) boost::any_cast(args.at(i)); - amx_Push(amx, value); - break; - } - - case 'l': - { - cell value = (cell) boost::any_cast(args.at(i)); - amx_Push(amx, value); - break; - } - - case 'w': - { - cell value = (cell) boost::any_cast(args.at(i)); - amx_Push(amx, value); - break; - } - - case 'f': - { - double value = boost::any_cast(args.at(i)); - amx_Push(amx, amx_ftoc(value)); - break; - } - - case 'p': - { - cell value = (cell) boost::any_cast(args.at(i)); - amx_Push(amx, value); - break; - } - - case 's': - { - string string_ = boost::any_cast(args.at(i)); - cell *store; - amx_PushString(amx, &store, string_.c_str(), 1, 0); - - if (!str) - str = store; - - break; - } - - default: - throw runtime_error("PAWN call: Unknown argument identifier " + argl[i]); - } - } - - err = amx_Exec(amx, &ret, idx); - - if (err != AMX_ERR_NONE) - throw runtime_error("PAWN runtime error (" + to_string(err) + "): \"" + string(aux_StrError(err)) + "\"."); - - if (str) - amx_Release(amx, str); - } - - catch (...) - { - if (str) - amx_Release(amx, str); - - throw; - } - - return ret; -} - -template -inline AMX_NATIVE_INFO *LangPAWN::functions(indices) -{ - - static AMX_NATIVE_INFO functions_[sizeof...(Indices)]{ - F_::F... - }; - - static_assert( - sizeof(functions_) / sizeof(functions_[0]) == sizeof(ScriptFunctions::functions) / sizeof(ScriptFunctions::functions[0]), - "Not all functions have been mapped to PAWN"); - - return functions_; -} - - -lib_t LangPAWN::GetInterface() -{ - return reinterpret_cast(amx); -} - -LangPAWN::LangPAWN() -{ - //throw std::runtime_error("Pawn is no longer supported, use Terra/Lua!"); - amx = new AMX(); -} - - -LangPAWN::LangPAWN(AMX *amx) -{ - this->amx = amx; -} - - -LangPAWN::~LangPAWN() -{ - -} diff --git a/apps/openmw-mp/Script/LangPawn/LangPAWN.hpp b/apps/openmw-mp/Script/LangPawn/LangPAWN.hpp deleted file mode 100644 index 396970ad1..000000000 --- a/apps/openmw-mp/Script/LangPawn/LangPAWN.hpp +++ /dev/null @@ -1,46 +0,0 @@ -// -// Created by koncord on 08.05.16. -// - -#ifndef PLUGINSYSTEM3_LANGPAWN_HPP -#define PLUGINSYSTEM3_LANGPAWN_HPP - -#include "Language.hpp" -#include - -class LangPAWN: public Language -{ -private: - template - struct indices {}; - template - struct build_indices : build_indices {}; - template - struct build_indices<0, Is...> : indices {}; - template - using IndicesFor = build_indices; - -public: - virtual lib_t GetInterface() override; - template - static AMX_NATIVE_INFO* functions(indices); - - AMX *amx; -public: - LangPAWN(); - LangPAWN(AMX *amx); - ~LangPAWN(); - static cell MakePublic(AMX *amx, const cell *params) noexcept; - static cell CallPublic(AMX *amx, const cell *params) noexcept; - static cell CreateTimer(AMX *amx, const cell *params) noexcept; - static cell CreateTimerEx(AMX *amx, const cell *params) noexcept; - - virtual void LoadProgram(const char *filename) override; - virtual int FreeProgram() override; - virtual bool IsCallbackPresent(const char *name) override; - virtual boost::any Call(const char *name, const char *argl, int buf, ...) override; - virtual boost::any Call(const char *name, const char *argl, const std::vector &args) override; -}; - - -#endif //PLUGINSYSTEM3_LANGPAWN_HPP diff --git a/apps/openmw-mp/Script/LangPawn/PawnFunc.cpp b/apps/openmw-mp/Script/LangPawn/PawnFunc.cpp deleted file mode 100644 index 3d20fdd32..000000000 --- a/apps/openmw-mp/Script/LangPawn/PawnFunc.cpp +++ /dev/null @@ -1,154 +0,0 @@ -// -// Created by koncord on 09.05.16. -// - -#include -#include "LangPAWN.hpp" -#include "API/TimerAPI.hpp" - -using namespace std; - -cell LangPAWN::MakePublic(AMX *amx, const cell *params) noexcept -{ - int len; - cell* source; - - source = amx_Address(amx, params[1]); - amx_StrLen(source, &len); - vector real; - real.reserve(len + 1); - - amx_GetString(&real[0], source, 0, UNLIMITED); - - source = amx_Address(amx, params[2]); - amx_StrLen(source, &len); - vector name; - name.reserve(len + 1); - - amx_GetString(&name[0], source, 0, UNLIMITED); - - cell *ret_addr = amx_Address(amx, params[3]); - char ret_type = static_cast(*reinterpret_cast(&ret_addr)); - - source = amx_Address(amx, params[4]); - amx_StrLen(source, &len); - vector def; - def.reserve(len + 1); - - amx_GetString(&def[0], source, 0, UNLIMITED); - - - - Public::MakePublic(&real[0], amx, &name[0], ret_type, &def[0]); - - return 1; -} - -cell LangPAWN::CallPublic(AMX *amx, const cell *params) noexcept -{ - int len; - cell* source; - - source = amx_Address(amx, params[1]); - amx_StrLen(source, &len); - vector name; - name.reserve(len + 1); - - amx_GetString(&name[0], source, 0, UNLIMITED); - - string def; - - try - { - def = Public::GetDefinition(&name[0]); - } - catch (...) { return 0; } - - vector args; - unsigned int count = (params[0] / sizeof(cell)) - 1; - - if (count != def.length()) - throw runtime_error("Script call: Number of arguments does not match definition"); - - for (unsigned int i = 0; i < count; ++i) - { - cell* data = amx_Address(amx, params[i + 2]); - - switch (def[i]) - { - case 'i': - { - args.emplace_back((unsigned int) *data); - break; - } - - case 'q': - { - args.emplace_back((signed int) *data); - break; - } - - case 'l': - { - args.emplace_back((unsigned long long) *data); - break; - } - - case 'w': - { - args.emplace_back((signed long long) *data); - break; - } - - case 'f': - { - args.emplace_back((double) amx_ctof(*data)); - break; - } - - case 'p': - { - args.emplace_back((void*) data); - break; - } - - case 's': - { - amx_StrLen(data, &len); - vector str; - str.reserve(len + 1); - amx_GetString(&str[0], data, 0, UNLIMITED); - args.emplace_back(string(&str[0]).c_str()); - break; - } - - default: - throw runtime_error("PAWN call: Unknown argument identifier " + def[i]); - } - } - - boost::any result = Public::Call(&name[0], args); - if (result.empty()) - return 0; - - cell ret = 0; - - if (result.type().hash_code() == typeid(signed int).hash_code()) - ret = boost::any_cast(result); - else if (result.type().hash_code() == typeid(unsigned int).hash_code()) - ret = boost::any_cast(result); - else if (result.type().hash_code() == typeid(double).hash_code()) - ret = amx_ftoc(result); - - return ret; -} - -cell LangPAWN::CreateTimer(AMX *amx, const cell *params) noexcept -{ - -} - -cell LangPAWN::CreateTimerEx(AMX *amx, const cell *params) noexcept -{ - -} diff --git a/apps/openmw-mp/Script/Script.cpp b/apps/openmw-mp/Script/Script.cpp index e17588022..3740487b0 100644 --- a/apps/openmw-mp/Script/Script.cpp +++ b/apps/openmw-mp/Script/Script.cpp @@ -5,9 +5,6 @@ #include "Script.hpp" #include "LangNative/LangNative.hpp" -#if defined (ENABLE_PAWN) -#include "LangPawn/LangPAWN.hpp" -#endif #if defined (ENABLE_LUA) #include "LangLua/LangLua.hpp" #endif @@ -34,13 +31,6 @@ Script::Script(const char *path) script_type = SCRIPT_CPP; lang = new LangNative(); } -#if defined (ENABLE_PAWN) - else if (strstr(path, ".amx")) - { - lang = new LangPAWN(); - script_type = SCRIPT_PAWN; - } -#endif #if defined (ENABLE_LUA) else if (strstr(path, ".lua") || strstr(path, ".t")) { diff --git a/apps/openmw-mp/Script/Script.hpp b/apps/openmw-mp/Script/Script.hpp index 9076baea6..6e80c4c47 100644 --- a/apps/openmw-mp/Script/Script.hpp +++ b/apps/openmw-mp/Script/Script.hpp @@ -24,7 +24,6 @@ private: enum { SCRIPT_CPP, - SCRIPT_PAWN, SCRIPT_LUA }; @@ -93,13 +92,6 @@ public: if (script->script_type == SCRIPT_CPP) result = reinterpret_cast>>(callback)(std::forward(args)...); -#if defined (ENABLE_PAWN) - else if (script->script_type == SCRIPT_PAWN) - { - boost::any any = script->lang->Call(data.name, data.callback.types, B, std::forward(args)...); - result = reinterpret_cast> ((int)boost::any_cast(any)); // TODO: WTF?! int?! - } -#endif #if defined (ENABLE_LUA) else if (script->script_type == SCRIPT_LUA) { @@ -133,10 +125,6 @@ public: if (script->script_type == SCRIPT_CPP) reinterpret_cast>>(callback)(std::forward(args)...); -#if defined (ENABLE_PAWN) - else if (script->script_type == SCRIPT_PAWN) - script->lang->Call(data.name, data.callback.types, B, std::forward(args)...); -#endif #if defined (ENABLE_LUA) else if (script->script_type == SCRIPT_LUA) script->lang->Call(data.name, data.callback.types, B, std::forward(args)...); diff --git a/apps/openmw-mp/Script/ScriptFunction.cpp b/apps/openmw-mp/Script/ScriptFunction.cpp index c30aae462..5ccd32dbf 100644 --- a/apps/openmw-mp/Script/ScriptFunction.cpp +++ b/apps/openmw-mp/Script/ScriptFunction.cpp @@ -14,10 +14,6 @@ #include "LangLua/LangLua.hpp" #endif -#if defined (ENABLE_PAWN) -#include "LangPawn/LangPAWN.hpp" -#endif - using namespace std; ScriptFunction::ScriptFunction(ScriptFunc fCpp,char ret_type, const string &def) : @@ -33,24 +29,9 @@ ScriptFunction::ScriptFunction(const ScriptFuncLua &fLua, lua_State *lua, char r } #endif -#if defined (ENABLE_PAWN) -ScriptFunction::ScriptFunction(const ScriptFuncPAWN &fPawn, AMX *amx, char ret_type, const string &def) : - fPawn({amx, fPawn}), def(def), ret_type(ret_type), script_type(SCRIPT_PAWN) -{ - -} -#endif - ScriptFunction::~ScriptFunction() { -#if defined (ENABLE_PAWN) - if (script_type == SCRIPT_PAWN) - fPawn.name.~ScriptFuncPAWN(); -#if defined (ENABLE_LUA) - else -#endif -#endif #if defined (ENABLE_LUA) if (script_type == SCRIPT_LUA) fLua.name.~ScriptFuncLua(); @@ -63,37 +44,6 @@ boost::any ScriptFunction::Call(const vector &args) if (def.length() != args.size()) throw runtime_error("Script call: Number of arguments does not match definition"); -#if defined (ENABLE_PAWN) - if (script_type == SCRIPT_PAWN) - { - LangPAWN langPawn(fPawn.amx); - boost::any any = langPawn.Call(fPawn.name.c_str(), def.c_str(), args); - result = boost::any(); - - cell ret = boost::any_cast(any); - - switch (ret_type) - { - case 'i': - result = static_cast(ret); - break; - case 'q': - result = static_cast(ret); - break; - case 's': - throw runtime_error("Pawn call: the Pawn does not supported strings in public functions"); - case 'f': - - result = static_cast(amx_ctof(ret)); - break; - case 'v': - result = boost::any(); - break; - default: - throw runtime_error("Pawn call: Unknown return type" + ret_type); - } - } -#endif #if defined (ENABLE_LUA) else if (script_type == SCRIPT_LUA) { diff --git a/apps/openmw-mp/Script/ScriptFunction.hpp b/apps/openmw-mp/Script/ScriptFunction.hpp index 1884ab8dd..6659d8098 100644 --- a/apps/openmw-mp/Script/ScriptFunction.hpp +++ b/apps/openmw-mp/Script/ScriptFunction.hpp @@ -12,14 +12,7 @@ #include "LangLua/LangLua.hpp" #endif -#if defined (ENABLE_PAWN) -#include -#endif - typedef unsigned long long(*ScriptFunc)(); -#if defined (ENABLE_PAWN) -typedef std::string ScriptFuncPAWN; -#endif #if defined (ENABLE_LUA) typedef std::string ScriptFuncLua; #endif @@ -30,13 +23,6 @@ protected: union { ScriptFunc fCpp; -#if defined (ENABLE_PAWN) - struct - { - AMX *amx; - ScriptFuncPAWN name; - } fPawn; -#endif #if defined (ENABLE_LUA) struct { @@ -53,16 +39,12 @@ protected: enum { SCRIPT_CPP, - SCRIPT_PAWN, SCRIPT_LUA }; ScriptFunction(ScriptFunc fCpp, char ret_type, const std::string &def); #if defined (ENABLE_LUA) ScriptFunction(const ScriptFuncLua &fPawn, lua_State *lua, char ret_type, const std::string &def); -#endif -#if defined (ENABLE_PAWN) - ScriptFunction(const ScriptFuncPAWN &fPawn, AMX *amx, char ret_type, const std::string &def); #endif virtual ~ScriptFunction(); diff --git a/apps/openmw-mp/Script/ScriptFunctions.hpp b/apps/openmw-mp/Script/ScriptFunctions.hpp index 495dfa2e4..b52271e00 100644 --- a/apps/openmw-mp/Script/ScriptFunctions.hpp +++ b/apps/openmw-mp/Script/ScriptFunctions.hpp @@ -24,7 +24,6 @@ #include