Compare commits

..

22 Commits

Author SHA1 Message Date
Koncord 7a4082d09f [General] Remove CallFF find module 5 years ago
Koncord bc2cc07d67 [General] Make Send and RequestData functions non virtual
Move PVS-Studio cmake file to cmake directory
5 years ago
Koncord f271a65d93 [General] Update Travis CI 5 years ago
Koncord 860897fbd7 [Server] Fix issues after rebase 5 years ago
Koncord c550697443 [Server] Add true/false defines 5 years ago
Koncord 042a7fa51b [Server] Use __genffi__ predefined macro
Fix aarch64 RetType size
5 years ago
Koncord eee9fc1ad1 Use typedef instead define for bool 5 years ago
Koncord 4ca5da5666 [Server] Rework Plugin API, move Lua system to external library
Use LibFFI for Public & Timer APIs
Use "PlayerId" type instead "unsigned short"
Add GetPluginDir() function
5 years ago
Koncord a9701028a2 Make API headers C compatible 5 years ago
Koncord bd3c974ea1 [Server] Trait all API functions as "extern C" 5 years ago
Koncord a9aecd09d2 [Server] Fix wrong class tagging 5 years ago
Koncord 6caed5d47e [General] Add comments to false-positive PVS messages 5 years ago
Koncord ddd370b61b [General] Add ENABLE_PVS option to CMake 5 years ago
Koncord 34be44f012 [General] Fix minor warnings found by PVS 5 years ago
Koncord 5519572b22 [General] Fix warnings and errors found by PVS Studio in Server 5 years ago
Koncord 7ab7c4c9c2 [General] Add PVS Studio macros 5 years ago
Koncord 2f75ecabcb [General] Update LuaBridge to 3154e94487dedc84f038c5787985ddc01a95d126 5 years ago
Koncord dca7e1ec45 [Server] Fix GCC 8 build 5 years ago
Koncord add6b02b79 [Server] Do not export all symbols 5 years ago
Koncord e7e374f7c5 [Server] Fix order of CDECL 5 years ago
Koncord f24b8b8738 [Server] Fix rebase conflicts 5 years ago
Koncord 6a2878820c [Server] Trait all API functions as "extern C"
Move Timer & Public functions to Script/Functions
5 years ago

@ -38,13 +38,13 @@ addons:
# The other ones from OpenMW ppa
libbullet-dev, libswresample-dev, libopenscenegraph-3.4-dev, libmygui-dev,
# tes3mp stuff
libboost1.61-dev, libqt5opengl5-dev, libluajit-5.1-dev
libboost1.61-dev, libqt5opengl5-dev, libluajit-5.1-dev libffi-dev
]
coverity_scan:
project:
name: "TES3MP/openmw-tes3mp"
description: "<Your project description here>"
name: TES3MP/openmw-tes3mp
description: <Your project description here>
notification_email: koncord@tes3mp.com
build_command_prepend: "cmake . -DBUILD_UNITTESTS=FALSE -DBUILD_OPENCS=FALSE -DBUILD_BSATOOL=FALSE -DBUILD_ESMTOOL=FALSE -DBUILD_MWINIIMPORTER=FALSE -DBUILD_LAUNCHER=FALSE"
build_command: "make -j3"

@ -36,4 +36,5 @@ ${ANALYZE}cmake .. \
-DCMAKE_BUILD_TYPE="None" \
-DUSE_SYSTEM_TINYXML=TRUE \
-DRakNet_LIBRARY_RELEASE=~/CrabNet/lib/libRakNetLibStatic.a \
-DRakNet_LIBRARY_DEBUG=~/CrabNet/lib/libRakNetLibStatic.a
-DRakNet_LIBRARY_DEBUG=~/CrabNet/lib/libRakNetLibStatic.a \

@ -16,6 +16,8 @@ option(BUILD_NIFTEST "build nif file tester" OFF)
option(BUILD_MYGUI_PLUGIN "build MyGUI plugin for OpenMW resources, to use with MyGUI tools" ON)
option(BUILD_DOCS "build documentation." OFF )
option(ENABLE_PVS "Enable PVS Studio Analyzer" FALSE)
if (NOT BUILD_LAUNCHER AND NOT BUILD_BROWSER AND NOT BUILD_OPENCS AND NOT BUILD_WIZARD)
set(USE_QT FALSE)
else()
@ -79,6 +81,8 @@ endif(EXISTS ${PROJECT_SOURCE_DIR}/.git)
# Macros
include(OpenMWMacros)
include(PVS-Studio)
# doxygen main page
configure_file ("${OpenMW_SOURCE_DIR}/docs/mainpage.hpp.cmake" "${OpenMW_BINARY_DIR}/docs/mainpage.hpp")
@ -591,6 +595,7 @@ add_subdirectory (components)
# Apps and tools
if (BUILD_OPENMW_MP)
add_subdirectory (extern/LuaBridge)
add_subdirectory( apps/openmw-mp )
endif()

@ -2,7 +2,7 @@ TES3MP
======
Copyright (c) 2008-2015, OpenMW Team
Copyright (c) 2016-2019, Stanislav Zhukov & David Cernat
Copyright (c) 2016-2018, TES3MP Team
[![Build Status](https://travis-ci.org/TES3MP/openmw-tes3mp.svg?branch=0.7.0)](https://travis-ci.org/TES3MP/openmw-tes3mp)
@ -15,7 +15,7 @@ TES3MP is a project adding multiplayer functionality to [OpenMW](https://github.
Font Licenses:
* DejaVuLGCSansMono.ttf: custom (see [files/mygui/DejaVu Font License.txt](https://github.com/TES3MP/openmw-tes3mp/blob/master/files/mygui/DejaVu%20Font%20License.txt) for more information)
Project status
Project Status
--------------
[Version changelog](https://github.com/TES3MP/openmw-tes3mp/blob/master/tes3mp-changelog.md)
@ -24,26 +24,25 @@ As of version 0.7.0, TES3MP is fully playable, providing very extensive player,
Remaining gameplay problems mostly relate to AI and the synchronization of clientside script variables.
Donations
---------------
You can benefit the project by donating on Patreon to our two developers, [David Cernat](https://www.patreon.com/davidcernat) and [Koncord](https://www.patreon.com/Koncord), as well as by supporting [OpenMW](https://openmw.org).
Contributing
---------------
--------------
Helping us with documentation, bug hunting and video showcases is always greatly appreciated.
Development has been relatively fast, but any contribution regarding [code](https://github.com/TES3MP/openmw-tes3mp/blob/master/CONTRIBUTING.md), documentation, bug hunting or video showcases is greatly appreciated.
For code contributions, it's best to start out with modestly sized fixes and features and work your way up. There are so many different possible implementations of more major features many of which would cause undesirable code or vision conflicts with OpenMW that those should be talked over in advance with the existing developers before effort is spent on them.
Test sessions are often advertised on [our Discord server](https://discord.gg/ECJk293) or in [our Steam group](https://steamcommunity.com/groups/mwmulti).
Feel free to contact the [team members](https://github.com/TES3MP/openmw-tes3mp/blob/master/tes3mp-credits.md) for any questions you might have.
Getting started
Getting Started
---------------
* [Quickstart guide](https://github.com/TES3MP/openmw-tes3mp/wiki/Quickstart-guide)
* [Steam group](https://steamcommunity.com/groups/mwmulti) and its [detailed FAQ](https://steamcommunity.com/groups/mwmulti/discussions/1/353916184342480541/)
* [TES3MP section on OpenMW forums](https://forum.openmw.org/viewforum.php?f=45)
* [Discord server](https://discord.gg/ECJk293)
* [Subreddit](https://www.reddit.com/r/tes3mp)
* [Known issues and bug reports](https://github.com/TES3MP/openmw-tes3mp/issues)
Donations
---------------
You can benefit the project by contributing to the Patreon pages of our two developers, [David Cernat](https://www.patreon.com/davidcernat) and [Koncord](https://www.patreon.com/Koncord), as well as by supporting [OpenMW](https://openmw.org).

@ -14,31 +14,6 @@ if(ENABLE_BREAKPAD)
include_directories(${CMAKE_SOURCE_DIR}/extern/breakpad/src ${Breakpad_Headers})
endif(ENABLE_BREAKPAD)
option(BUILD_WITH_LUA "Enable Lua language" ON)
if(BUILD_WITH_LUA)
find_package(LuaJit REQUIRED)
MESSAGE(STATUS "Found LuaJit_LIBRARIES: ${LuaJit_LIBRARIES}")
MESSAGE(STATUS "Found LuaJit_INCLUDE_DIRS: ${LuaJit_INCLUDE_DIRS}")
set(LuaScript_Sources
Script/LangLua/LangLua.cpp
Script/LangLua/LuaFunc.cpp)
set(LuaScript_Headers ${LUA_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/extern/LuaBridge ${CMAKE_SOURCE_DIR}/extern/LuaBridge/detail
Script/LangLua/LangLua.hpp)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_LUA")
include_directories(SYSTEM ${LuaJit_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/extern/LuaBridge)
endif(BUILD_WITH_LUA)
set(NativeScript_Sources
Script/LangNative/LangNative.cpp
)
set(NativeScript_Headers
Script/LangNative/LangNative.hpp
)
# local files
set(SERVER
main.cpp
@ -48,8 +23,8 @@ set(SERVER
Cell.cpp
CellController.cpp
Utils.cpp
Script/Script.cpp Script/ScriptFunction.cpp
Script/ScriptFunctions.cpp
Script/Plugin.cpp
Script/Callbacks.cpp
Script/Functions/Actors.cpp Script/Functions/Objects.cpp Script/Functions/Miscellaneous.cpp
Script/Functions/Worldstate.cpp
@ -60,19 +35,15 @@ set(SERVER
Script/Functions/Positions.cpp Script/Functions/Quests.cpp Script/Functions/RecordsDynamic.cpp
Script/Functions/Server.cpp Script/Functions/Settings.cpp Script/Functions/Shapeshift.cpp
Script/Functions/Spells.cpp Script/Functions/Stats.cpp Script/Functions/Timer.cpp
Script/Functions/Public.cpp Script/FFI.cpp
Script/API/TimerAPI.cpp Script/API/PublicFnAPI.cpp
${LuaScript_Sources}
${NativeScript_Sources}
)
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
${LuaScript_Headers}
${NativeScript_Headers}
Script/Types.hpp Script/Plugin.hpp Script/SystemInterface.hpp
Script/Platform.h
Script/Callbacks.hpp Script/API/TimerAPI.hpp Script/API/PublicFnAPI.hpp Script/FFI.hpp
)
source_group(tes3mp-server FILES ${SERVER} ${SERVER_HEADER})
@ -153,6 +124,8 @@ add_executable(tes3mp-server
${APPLE_BUNDLE_RESOURCES}
)
target_compile_definitions(tes3mp-server PRIVATE _HOST)
target_compile_options(tes3mp-server PRIVATE $<$<CXX_COMPILER_ID:MSVC>:/permissive->)
if (OPENMW_MP_BUILD)
@ -160,15 +133,11 @@ if (OPENMW_MP_BUILD)
endif()
set_target_properties(tes3mp-server PROPERTIES
CXX_STANDARD 14
CXX_STANDARD 17
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS YES
)
if (UNIX)
target_compile_options(tes3mp-server PRIVATE -Wno-ignored-qualifiers)
endif()
target_link_libraries(tes3mp-server
#${Boost_SYSTEM_LIBRARY}
#${Boost_THREAD_LIBRARY}
@ -180,10 +149,15 @@ target_link_libraries(tes3mp-server
${Breakpad_Library}
)
if (BUILD_WITH_LUA)
target_link_libraries(tes3mp-server LuaBridge)
endif()
if (UNIX)
target_link_libraries(tes3mp-server dl)
# Fix for not visible pthreads functions for linker with glibc 2.15
if(NOT APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--exclude-libs,ALL -rdynamic -fvisibility=hidden")
target_link_libraries(tes3mp-server ${CMAKE_THREAD_LIBS_INIT})
endif(NOT APPLE)
endif(UNIX)
@ -200,3 +174,15 @@ if (MSVC)
endif (CMAKE_CL_64)
add_definitions("-D_USE_MATH_DEFINES")
endif (MSVC)
find_package(LibFFI REQUIRED)
include_directories(SYSTEM ${LIBFFI_INCLUDE_DIR})
target_link_libraries(tes3mp-server ${LIBFFI_LIBRARIES})
if (ENABLE_PVS)
pvs_studio_add_target(TARGET tes3mp-server.analyze ALL
OUTPUT FORMAT errorfile
ANALYZE tes3mp-server
LOG target_tes3mp-server.err)
endif()

@ -8,7 +8,7 @@
#include <iostream>
#include "Player.hpp"
#include "Script/Script.hpp"
#include "Script/Plugin.hpp"
using namespace std;
@ -34,7 +34,8 @@ void Cell::addPlayer(Player *player)
if (it != end())
{
LOG_APPEND(Log::LOG_INFO, "- Attempt to add %s to Cell %s again was ignored", player->npc.mName.c_str(), getDescription().c_str());
LOG_APPEND(Log::LOG_INFO, "- Attempt to add %s to Cell %s again was ignored", player->npc.mName.c_str(),
getDescription().c_str());
return;
}
@ -48,14 +49,17 @@ void Cell::addPlayer(Player *player)
LOG_APPEND(Log::LOG_INFO, "- Adding %s to Cell %s", player->npc.mName.c_str(), getDescription().c_str());
Script::Call<Script::CallbackIdentity("OnCellLoad")>(player->getId(), getDescription().c_str());
players.push_back(player);
PlayerId id = player->getId();
if (id != InvalidPID)
{
Plugin::Call<CallbackIndex("OnCellLoad")>(id, getDescription().c_str());
players.push_back(player);
}
}
void Cell::removePlayer(Player *player, bool cleanPlayer)
{
for (Iterator it = begin(); it != end(); it++)
for (auto it = begin(); it != end(); ++it)
{
if (*it == player)
{
@ -72,7 +76,7 @@ void Cell::removePlayer(Player *player, bool cleanPlayer)
LOG_APPEND(Log::LOG_INFO, "- Removing %s from Cell %s", player->npc.mName.c_str(), getDescription().c_str());
Script::Call<Script::CallbackIdentity("OnCellUnload")>(player->getId(), getDescription().c_str());
Plugin::Call<CallbackIndex("OnCellUnload")>(player->getId(), getDescription().c_str());
players.erase(it);
return;
@ -161,7 +165,7 @@ void Cell::removeActors(const mwmp::BaseActorList *newActorList)
}
if (!foundActor)
it++;
++it;
}
cellActorList.count = cellActorList.baseActors.size();

@ -3,7 +3,7 @@
#include <iostream>
#include "Cell.hpp"
#include "Player.hpp"
#include "Script/Script.hpp"
#include "Script/Plugin.hpp"
using namespace std;
@ -64,7 +64,7 @@ Cell *CellController::getCellByXY(int x, int y)
return *it;
}
Cell *CellController::getCellByName(std::string cellName)
Cell *CellController::getCellByName(const std::string &cellName)
{
auto it = find_if(cells.begin(), cells.end(), [cellName](const Cell *c)
{
@ -80,7 +80,7 @@ Cell *CellController::getCellByName(std::string cellName)
return *it;
}
Cell *CellController::addCell(ESM::Cell cellData)
Cell *CellController::addCell(const ESM::Cell &cellData)
{
LOG_APPEND(Log::LOG_INFO, "- Loaded cells: %d", cells.size());
auto it = find_if(cells.begin(), cells.end(), [cellData](const Cell *c) {
@ -123,7 +123,7 @@ void CellController::removeCell(Cell *cell)
{
if (*it != nullptr && *it == cell)
{
Script::Call<Script::CallbackIdentity("OnCellDeletion")>(cell->getDescription().c_str());
Plugin::Call<CallbackIndex("OnCellDeletion")>(cell->getDescription().c_str());
LOG_APPEND(Log::LOG_INFO, "- Removing %s from CellController", cell->getDescription().c_str());
delete *it;

@ -27,14 +27,14 @@ public:
typedef std::deque<Cell*> TContainer;
typedef TContainer::iterator TIter;
Cell * addCell(ESM::Cell cell);
Cell * addCell(const ESM::Cell &cell);
void removeCell(Cell *);
void deletePlayer(Player *player);
Cell *getCell(ESM::Cell *esmCell);
Cell *getCellByXY(int x, int y);
Cell *getCellByName(std::string cellName);
Cell *getCellByName(const std::string &cellName);
void update(Player *player);

@ -51,7 +51,7 @@ void MasterClient::SetMaxPlayers(unsigned pl)
mutexData.unlock();
}
void MasterClient::SetHostname(std::string hostname)
void MasterClient::SetHostname(const std::string &hostname)
{
mutexData.lock();
string substr = hostname.substr(0, 200);
@ -63,7 +63,7 @@ void MasterClient::SetHostname(std::string hostname)
mutexData.unlock();
}
void MasterClient::SetModname(std::string modname)
void MasterClient::SetModname(const std::string &modname)
{
mutexData.lock();
string substr = modname.substr(0, 200);
@ -75,7 +75,7 @@ void MasterClient::SetModname(std::string modname)
mutexData.unlock();
}
void MasterClient::SetRuleString(std::string key, std::string value)
void MasterClient::SetRuleString(const std::string &key, std::string value)
{
mutexData.lock();
if (queryData.rules.find(key) == queryData.rules.end() || queryData.rules[key].type != 's'
@ -90,7 +90,7 @@ void MasterClient::SetRuleString(std::string key, std::string value)
mutexData.unlock();
}
void MasterClient::SetRuleValue(std::string key, double value)
void MasterClient::SetRuleValue(const std::string &key, double value)
{
mutexData.lock();
if (queryData.rules.find(key) == queryData.rules.end() || queryData.rules[key].type != 'v'
@ -105,7 +105,7 @@ void MasterClient::SetRuleValue(std::string key, double value)
mutexData.unlock();
}
void MasterClient::PushPlugin(Plugin plugin)
void MasterClient::PushPlugin(const _Plugin &plugin)
{
mutexData.lock();
queryData.plugins.push_back(plugin);
@ -208,7 +208,7 @@ void MasterClient::Thread()
}
else
{
for (int i = 0; pIt != players->end(); i++, pIt++)
for (int i = 0; pIt != players->end(); i++, ++pIt)
{
if (queryData.players[i] != pIt->second->npc.mName)
{
@ -258,5 +258,6 @@ void MasterClient::SetUpdateRate(unsigned int rate)
timeout = min_rate;
else if (timeout > max_rate)
timeout = max_rate;
timeout = rate;
else
timeout = rate;
}

@ -22,11 +22,11 @@ public:
MasterClient(RakNet::RakPeerInterface *peer, std::string queryAddr, unsigned short queryPort);
void SetPlayers(unsigned pl);
void SetMaxPlayers(unsigned pl);
void SetHostname(std::string hostname);
void SetModname(std::string hostname);
void SetRuleString(std::string key, std::string value);
void SetRuleValue(std::string key, double value);
void PushPlugin(Plugin plugin);
void SetHostname(const std::string &hostname);
void SetModname(const std::string &hostname);
void SetRuleString(const std::string &key, std::string value);
void SetRuleValue(const std::string &key, double value);
void PushPlugin(const _Plugin &plugin);
bool Process(RakNet::Packet *packet);
void Start();

@ -10,7 +10,7 @@
#include <components/openmw-mp/Packets/PacketPreInit.hpp>
#include <iostream>
#include <Script/Script.hpp>
#include <Script/Plugin.hpp>
#include <Script/API/TimerAPI.hpp>
#include <chrono>
#include <thread>
@ -55,7 +55,7 @@ Networking::Networking(RakNet::RakPeerInterface *peer) : mclient(nullptr)
running = true;
exitCode = 0;
Script::Call<Script::CallbackIdentity("OnServerInit")>();
Plugin::Call<CallbackIndex("OnServerInit")>();
serverPassword = TES3MP_DEFAULT_PASSW;
@ -64,7 +64,7 @@ Networking::Networking(RakNet::RakPeerInterface *peer) : mclient(nullptr)
Networking::~Networking()
{
Script::Call<Script::CallbackIdentity("OnServerExit")>(false);
Plugin::Call<CallbackIndex("OnServerExit")>(false);
CellController::destroy();
@ -75,9 +75,9 @@ Networking::~Networking()
delete worldstatePacketController;
}
void Networking::setServerPassword(std::string password) noexcept
void Networking::setServerPassword(const std::string &passw) noexcept
{
serverPassword = password.empty() ? TES3MP_DEFAULT_PASSW : password;
serverPassword = passw.empty() ? TES3MP_DEFAULT_PASSW : passw;
}
bool Networking::isPassworded() const
@ -147,8 +147,8 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
{
player->setLoadState(Player::LOADED);
unsigned short pid = Players::getPlayer(packet->guid)->getId();
Script::Call<Script::CallbackIdentity("OnPlayerConnect")>(pid);
PlayerId pid = Players::getPlayer(packet->guid)->getId();
Plugin::Call<CallbackIndex("OnPlayerConnect")>(pid);
if (player->getLoadState() == Player::KICKED) // kicked inside in OnPlayerConnect
{
@ -245,7 +245,7 @@ bool Networking::preInit(RakNet::Packet *packet, RakNet::BitStream &bsIn)
auto plugin = plugins.begin();
if (samples.size() == plugins.size())
{
for (int i = 0; plugin != plugins.end(); plugin++, i++)
for (int i = 0; plugin != plugins.end(); ++plugin, i++)
{
LOG_APPEND(Log::LOG_VERBOSE, "- %X\t%s", plugin->second[0], plugin->first.c_str());
// Check if the filenames match, ignoring case
@ -317,7 +317,7 @@ void Networking::update(RakNet::Packet *packet, RakNet::BitStream &bsIn)
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Unhandled RakNet packet with identifier %i has arrived", packet->data[0]);
}
void Networking::newPlayer(RakNet::RakNetGUID guid)
void Networking::newPlayer(const RakNet::RakNetGUID &guid)
{
playerPacketController->GetPacket(ID_PLAYER_BASEINFO)->RequestData(guid);
playerPacketController->GetPacket(ID_PLAYER_STATS_DYNAMIC)->RequestData(guid);
@ -327,27 +327,27 @@ void Networking::newPlayer(RakNet::RakNetGUID guid)
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Sending info about other players to %lu", guid.g);
for (TPlayers::iterator pl = players->begin(); pl != players->end(); pl++) //sending other players to new player
for (auto &player : *players) //sending other players to new player
{
// If we are iterating over the new player, don't send the packets below
if (pl->first == guid) continue;
if (player.first == guid) continue;
// If an invalid key makes it into the Players map, ignore it
else if (pl->first == RakNet::UNASSIGNED_CRABNET_GUID) continue;
else if (player.first == RakNet::UNASSIGNED_CRABNET_GUID) continue;
// if player not fully connected
else if (pl->second == nullptr) continue;
else if (player.second == nullptr) continue;
// If we are iterating over a player who has inputted their name, proceed
else if (pl->second->getLoadState() == Player::POSTLOADED)
else if (player.second->getLoadState() == Player::POSTLOADED)
{
playerPacketController->GetPacket(ID_PLAYER_BASEINFO)->setPlayer(pl->second);
playerPacketController->GetPacket(ID_PLAYER_STATS_DYNAMIC)->setPlayer(pl->second);
playerPacketController->GetPacket(ID_PLAYER_ATTRIBUTE)->setPlayer(pl->second);
playerPacketController->GetPacket(ID_PLAYER_SKILL)->setPlayer(pl->second);
playerPacketController->GetPacket(ID_PLAYER_POSITION)->setPlayer(pl->second);
playerPacketController->GetPacket(ID_PLAYER_CELL_CHANGE)->setPlayer(pl->second);
playerPacketController->GetPacket(ID_PLAYER_EQUIPMENT)->setPlayer(pl->second);
playerPacketController->GetPacket(ID_PLAYER_BASEINFO)->setPlayer(player.second);
playerPacketController->GetPacket(ID_PLAYER_STATS_DYNAMIC)->setPlayer(player.second);
playerPacketController->GetPacket(ID_PLAYER_ATTRIBUTE)->setPlayer(player.second);
playerPacketController->GetPacket(ID_PLAYER_SKILL)->setPlayer(player.second);
playerPacketController->GetPacket(ID_PLAYER_POSITION)->setPlayer(player.second);
playerPacketController->GetPacket(ID_PLAYER_CELL_CHANGE)->setPlayer(player.second);
playerPacketController->GetPacket(ID_PLAYER_EQUIPMENT)->setPlayer(player.second);
playerPacketController->GetPacket(ID_PLAYER_BASEINFO)->Send(guid);
playerPacketController->GetPacket(ID_PLAYER_STATS_DYNAMIC)->Send(guid);
@ -363,12 +363,12 @@ void Networking::newPlayer(RakNet::RakNetGUID guid)
}
void Networking::disconnectPlayer(RakNet::RakNetGUID guid)
void Networking::disconnectPlayer(const RakNet::RakNetGUID &guid)
{
Player *player = Players::getPlayer(guid);
if (!player)
return;
Script::Call<Script::CallbackIdentity("OnPlayerDisconnect")>(player->getId());
Plugin::Call<CallbackIndex("OnPlayerDisconnect")>(player->getId());
playerPacketController->GetPacket(ID_USER_DISCONNECTED)->setPlayer(player);
playerPacketController->GetPacket(ID_USER_DISCONNECTED)->Send(true);
@ -423,7 +423,7 @@ void Networking::setCurrentMpNum(int value)
int Networking::incrementMpNum()
{
currentMpNum++;
Script::Call<Script::CallbackIdentity("OnMpNumIncrement")>(currentMpNum);
Plugin::Call<CallbackIndex("OnMpNumIncrement")>(currentMpNum);
return currentMpNum;
}
@ -458,7 +458,7 @@ Networking *Networking::getPtr()
return sThis;
}
RakNet::SystemAddress Networking::getSystemAddress(RakNet::RakNetGUID guid)
RakNet::SystemAddress Networking::getSystemAddress(const RakNet::RakNetGUID &guid)
{
return peer->GetSystemAddressFromGuid(guid);
}
@ -538,7 +538,7 @@ int Networking::mainLoop()
return exitCode;
}
void Networking::kickPlayer(RakNet::RakNetGUID guid, bool sendNotification)
void Networking::kickPlayer(const RakNet::RakNetGUID &guid, bool sendNotification)
{
peer->CloseConnection(guid, sendNotification);
}
@ -563,7 +563,7 @@ unsigned int Networking::maxConnections() const
return peer->GetMaximumIncomingConnections();
}
int Networking::getAvgPing(RakNet::AddressOrGUID addr) const
int Networking::getAvgPing(const RakNet::AddressOrGUID &addr) const
{
return peer->GetAveragePing(addr);
}
@ -578,15 +578,15 @@ MasterClient *Networking::getMasterClient()
return mclient;
}
void Networking::InitQuery(std::string queryAddr, unsigned short queryPort)
void Networking::InitQuery(const std::string &queryAddr, unsigned short queryPort)
{
mclient = new MasterClient(peer, queryAddr, queryPort);
}
void Networking::postInit()
{
Script::Call<Script::CallbackIdentity("OnRequestDataFileList")>();
Script::Call<Script::CallbackIdentity("OnServerPostInit")>();
Plugin::Call<CallbackIndex("OnServerPostInit")>();
Plugin::Call<CallbackIndex("OnRequestPluginList")>();
}
PacketPreInit::PluginContainer &Networking::getSamples()

@ -17,13 +17,13 @@ namespace mwmp
Networking(RakNet::RakPeerInterface *peer);
~Networking();
void newPlayer(RakNet::RakNetGUID guid);
void disconnectPlayer(RakNet::RakNetGUID guid);
void kickPlayer(RakNet::RakNetGUID guid, bool sendNotification = true);
void newPlayer(const RakNet::RakNetGUID &guid);
void disconnectPlayer(const RakNet::RakNetGUID &guid);
void kickPlayer(const RakNet::RakNetGUID &guid, bool sendNotification = true);
void banAddress(const char *ipAddress);
void unbanAddress(const char *ipAddress);
RakNet::SystemAddress getSystemAddress(RakNet::RakNetGUID guid);
RakNet::SystemAddress getSystemAddress(const RakNet::RakNetGUID &guid);
void processPlayerPacket(RakNet::Packet *packet);
void processActorPacket(RakNet::Packet *packet);
@ -33,7 +33,7 @@ namespace mwmp
unsigned short numberOfConnections() const;
unsigned int maxConnections() const;
int getAvgPing(RakNet::AddressOrGUID) const;
int getAvgPing(const RakNet::AddressOrGUID &) const;
unsigned short getPort() const;
int mainLoop();
@ -60,8 +60,8 @@ namespace mwmp
void setScriptErrorIgnoringState(bool state);
MasterClient *getMasterClient();
void InitQuery(std::string queryAddr, unsigned short queryPort);
void setServerPassword(std::string passw) noexcept;
void InitQuery(const std::string &queryAddr, unsigned short queryPort);
void setServerPassword(const std::string &passw) noexcept;
bool isPassworded() const;
static const Networking &get();

@ -10,7 +10,7 @@ TSlots Players::slots;
using namespace std;
void Players::deletePlayer(RakNet::RakNetGUID guid)
void Players::deletePlayer(const RakNet::RakNetGUID &guid)
{
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Deleting player with guid %lu", guid.g);
@ -26,7 +26,7 @@ void Players::deletePlayer(RakNet::RakNetGUID guid)
}
}
void Players::newPlayer(RakNet::RakNetGUID guid)
void Players::newPlayer(const RakNet::RakNetGUID &guid)
{
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Creating new player with guid %lu", guid.g);
@ -41,7 +41,7 @@ void Players::newPlayer(RakNet::RakNetGUID guid)
for (unsigned int i = 0; i < mwmp::Networking::get().maxConnections(); i++)
{
if (slots[i] == 0)
if (slots[i] == nullptr)
{
LOG_APPEND(Log::LOG_INFO, "- Storing in slot %i", i);
@ -52,7 +52,7 @@ void Players::newPlayer(RakNet::RakNetGUID guid)
}
}
Player *Players::getPlayer(RakNet::RakNetGUID guid)
Player *Players::getPlayer(const RakNet::RakNetGUID &guid)
{
auto it = players.find(guid);
if (it == players.end())
@ -70,7 +70,7 @@ unsigned short Players::getLastPlayerId()
return slots.rbegin()->first;
}
Player::Player(RakNet::RakNetGUID guid) : BasePlayer(guid)
Player::Player(const RakNet::RakNetGUID &guid) : BasePlayer(guid), id(InvalidPID)
{
handshakeCounter = 0;
loadState = NOTLOADED;
@ -81,7 +81,7 @@ Player::~Player()
}
unsigned short Player::getId()
PlayerId Player::getId()
{
return id;
}
@ -177,7 +177,7 @@ void Player::forEachLoaded(std::function<void(Player *pl, Player *other)> func)
}
}
bool Players::doesPlayerExist(RakNet::RakNetGUID guid)
bool Players::doesPlayerExist(const RakNet::RakNetGUID &guid)
{
return players.find(guid) != players.end();
}

@ -20,20 +20,22 @@
#include <components/openmw-mp/Packets/Player/PlayerPacket.hpp>
#include "Cell.hpp"
#include "CellController.hpp"
#include "Script/CTypes.h"
class Player;
typedef std::map<RakNet::RakNetGUID, Player*> TPlayers;
typedef std::map<unsigned short, Player*> TSlots;
class Players
{
public:
static void newPlayer(RakNet::RakNetGUID guid);
static void deletePlayer(RakNet::RakNetGUID guid);
static Player *getPlayer(RakNet::RakNetGUID guid);
static void newPlayer(const RakNet::RakNetGUID &guid);
static void deletePlayer(const RakNet::RakNetGUID &guid);
static Player *getPlayer(const RakNet::RakNetGUID &guid);
static Player *getPlayer(unsigned short id);
static TPlayers *getPlayers();
static unsigned short getLastPlayerId();
static bool doesPlayerExist(RakNet::RakNetGUID guid);
static bool doesPlayerExist(const RakNet::RakNetGUID &guid);
private:
static TPlayers players;
@ -43,9 +45,7 @@ private:
class Player : public mwmp::BasePlayer
{
friend class Cell;
unsigned short id;
public:
enum
{
NOTLOADED=0,
@ -53,9 +53,9 @@ public:
POSTLOADED,
KICKED
};
Player(RakNet::RakNetGUID guid);
Player(const RakNet::RakNetGUID &guid);
unsigned short getId();
PlayerId getId();
void setId(unsigned short id);
bool isHandshaked();
@ -77,6 +77,7 @@ private:
CellController::TContainer cells;
int loadState;
int handshakeCounter;
unsigned int id;
};

@ -2,36 +2,52 @@
// Created by koncord on 14.05.16.
//
#include <Script/ScriptFunction.hpp>
#include "PublicFnAPI.hpp"
#include <stack>
using namespace std;
unordered_map<string, Public *> Public::publics;
static std::stack<std::string> publicsStack;
Public::~Public()
{
}
Public::Public(ScriptFunc _public, const std::string &name, char ret_type, const std::string &def) : ScriptFunction(_public, ret_type, def)
Public::Public(ScriptFunc _public, const std::string &name, char ret_type, const std::string &def): def(def), retType(ret_type)
{
setRetType(ret_type);
setFunctionPtr(_public);
publics.emplace(name, this);
}
Public::Public(ScriptFuncLua _public, lua_State *lua, const std::string &name, char ret_type, const std::string &def) : ScriptFunction(
_public, lua, ret_type, def)
{
publics.emplace(name, this);
}
boost::any Public::Call(const std::string &name, const std::vector<boost::any> &args)
ffi_arg Public::Call(const std::string &name, va_list args)
{
auto it = publics.find(name);
if (it == publics.end())
throw runtime_error("Public with name \"" + name + "\" does not exist");
return it->second->ScriptFunction::Call(args);
Public *_pub = it->second;
publicsStack.push(it->first);
_pub->setArguments(_pub->def, args);
ffi_arg res = _pub->call();
publicsStack.pop();
return res;
}
const std::string &Public::GetName()
{
static std::string name;
if (!publicsStack.empty())
name = publicsStack.top();
else
name.clear();
return name;
}
@ -45,23 +61,19 @@ const std::string &Public::GetDefinition(const std::string &name)
return it->second->def;
}
bool Public::IsLua(const std::string &name)
char Public::GetReturnType(const std::string &name)
{
#if !defined(ENABLE_LUA)
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_LUA;
#endif
return it->second->retType;
}
void Public::DeleteAll()
{
for (auto it = publics.begin(); it != publics.end(); it++)
for (auto it = publics.begin(); it != publics.end(); ++it)
{
Public *_public = it->second;
delete _public;

@ -6,10 +6,10 @@
#define PLUGINSYSTEM3_PUBLICFNAPI_HPP
#include <unordered_map>
#include <Script/ScriptFunction.hpp>
#include <Script/FFI.hpp>
class Public : public ScriptFunction
class Public : public FFI
{
private:
~Public();
@ -17,20 +17,19 @@ private:
static std::unordered_map<std::string, Public *> publics;
Public(ScriptFunc _public, const std::string &name, char ret_type, const std::string &def);
#if defined(ENABLE_LUA)
Public(ScriptFuncLua _public, lua_State *lua, const std::string &name, char ret_type, const std::string &def);
#endif
std::string def;
char retType;
public:
template<typename... Args>
static void MakePublic(Args &&... args)
{ new Public(std::forward<Args>(args)...); }
static void MakePublic(Args &&... args) { new Public(std::forward<Args>(args)...); }
static boost::any Call(const std::string &name, const std::vector<boost::any> &args);
static ffi_arg Call(const std::string &name, va_list args);
static const std::string& GetDefinition(const std::string& name);
static const std::string &GetName();
static bool IsLua(const std::string &name);
static const std::string &GetDefinition(const std::string &name);
static char GetReturnType(const std::string &name);
static void DeleteAll();
};

@ -1,28 +1,32 @@
#include "TimerAPI.hpp"
#include <chrono>
#include <cstdarg>
#include <cstring>
#include <iostream>
using namespace mwmp;
using namespace std;
Timer::Timer(ScriptFunc callback, long msec, const std::string& def, std::vector<boost::any> args) : ScriptFunction(callback, 'v', def)
static int timerId = -1;
Timer::Timer(ScriptFunc callback, long msec, const std::string& def, va_list args)
{
this->def = strdup(def.c_str());
setRetType('v');
setFunctionPtr(callback);
setArguments(def, args);
startTime = 0;
targetMsec = msec;
this->args = args;
isEnded = true;
}
#if defined(ENABLE_LUA)
Timer::Timer(lua_State *lua, ScriptFuncLua callback, long msec, const std::string& def, std::vector<boost::any> args): ScriptFunction(callback, lua, 'v', def)
Timer::~Timer()
{
targetMsec = msec;
this->args = args;
isEnded = true;
free(def);
}
#endif
void Timer::Tick()
void Timer::Tick(int timerid)
{
if (isEnded)
return;
@ -33,7 +37,9 @@ void Timer::Tick()
if (time - startTime >= targetMsec)
{
isEnded = true;
Call(args);
timerId = timerid;
call();
timerId = -1;
}
}
@ -62,35 +68,16 @@ void Timer::Start()
startTime = msec;
}
int TimerAPI::pointer = 0;
std::unordered_map<int, Timer* > TimerAPI::timers;
#if defined(ENABLE_LUA)
int TimerAPI::CreateTimerLua(lua_State *lua, ScriptFuncLua callback, long msec, const std::string& def, std::vector<boost::any> args)
const char *Timer::GetDefinition()
{
int id = -1;
for (auto timer : timers)
{
if (timer.second != nullptr)
continue;
timer.second = new Timer(lua, callback, msec, def, args);
id = timer.first;
}
if (id == -1)
{
timers[pointer] = new Timer(lua, callback, msec, def, args);
id = pointer;
pointer++;
}
return id;
return def;
}
#endif
int TimerAPI::pointer = 0;
std::unordered_map<int, Timer* > TimerAPI::timers;
int TimerAPI::CreateTimer(ScriptFunc callback, long msec, const std::string &def, std::vector<boost::any> args)
int TimerAPI::CreateTimer(ScriptFunc callback, long msec, const std::string &def, va_list args)
{
int id = -1;
@ -114,7 +101,6 @@ int TimerAPI::CreateTimer(ScriptFunc callback, long msec, const std::string &def
void TimerAPI::FreeTimer(int timerid)
{
try
{
if (timers.at(timerid) != nullptr)
@ -182,6 +168,25 @@ bool TimerAPI::IsTimerElapsed(int timerid)
return ret;
}
int TimerAPI::GetTimerId()
{
return timerId;
}
const char *TimerAPI::GetDefinition(int timerid)
{
const char *ret = nullptr;
try
{
ret = timers.at(timerid)->GetDefinition();
}
catch(...)
{
std::cerr << "Timer " << timerid << " not found!" << endl;
}
return ret;
}
void TimerAPI::Terminate()
{
for (auto timer : timers)
@ -197,6 +202,6 @@ void TimerAPI::Tick()
for (auto timer : timers)
{
if (timer.second != nullptr)
timer.second->Tick();
timer.second->Tick(timer.first);
}
}

@ -3,50 +3,49 @@
#include <string>
#include <Script/Script.hpp>
#include <Script/ScriptFunction.hpp>
#include <Script/FFI.hpp>
#include <unordered_map>
namespace mwmp
{
class TimerAPI;
class Timer: public ScriptFunction
class Timer: public FFI
{
friend class TimerAPI;
public:
Timer(ScriptFunc callback, long msec, const std::string& def, std::vector<boost::any> args);
#if defined(ENABLE_LUA)
Timer(lua_State *lua, ScriptFuncLua callback, long msec, const std::string& def, std::vector<boost::any> args);
#endif
void Tick();
Timer(ScriptFunc callback, long msec, const std::string& def, va_list args);
~Timer();
void Tick(int timerId);
bool IsEnded();
void Stop();
void Start();
void Restart(int msec);
const char *GetDefinition();
private:
double startTime, targetMsec;
std::string publ, arg_types;
std::vector<boost::any> args;
Script *scr;
//std::string publ, arg_types;
//Script *scr;
bool isEnded;
char *def;
};
class TimerAPI
{
public:
#if defined(ENABLE_LUA)
static int CreateTimerLua(lua_State *lua, ScriptFuncLua callback, long msec, const std::string& def, std::vector<boost::any> args);
#endif
static int CreateTimer(ScriptFunc callback, long msec, const std::string& def, std::vector<boost::any> args);
static int CreateTimer(ScriptFunc callback, long msec, const std::string& def, va_list args);
static void FreeTimer(int timerid);
static void ResetTimer(int timerid, long msec);
static void StartTimer(int timerid);
static void StopTimer(int timerid);
static bool IsTimerElapsed(int timerid);
static int GetTimerId();
static const char *GetDefinition(int timerid);
static void Terminate();
@ -54,6 +53,7 @@ namespace mwmp
private:
static std::unordered_map<int, Timer* > timers;
static int pointer;
static int lastTimerId;
};
}

@ -0,0 +1,25 @@
//
// Created by koncord on 09.01.19.
//
#pragma once
#include <cstdint>
#include <variant>
#include <vector>
typedef std::variant<uint8_t,
int8_t,
uint16_t,
int16_t,
uint32_t,
int32_t,
uint64_t,
int64_t,
const char *,
void *,
float,
double,
bool> TArgVariant;
typedef std::vector<TArgVariant> TArgsStore;

@ -0,0 +1,30 @@
//
// Created by koncord on 15.01.19.
//
#pragma once
#include <stdint.h>
#ifdef X86_WIN64
#ifdef _MSC_VER
typedef unsigned __int64 RetType;
#else
typedef unsigned long long RetType;
#endif
#elif (defined __x86_64__ || defined __aarch64__) && defined __ILP32__
typedef unsigned long long RetType;
#else
typedef unsigned long RetType;
#endif
typedef unsigned long long(*ScriptFunc)();
typedef unsigned int PlayerId;
#define InvalidPID ((unsigned int) -1)
#if !(defined __cplusplus || defined __genffi__)
typedef uint8_t bool;
#define true 1
#define false 0
#endif

@ -0,0 +1,44 @@
//
// Created by koncord on 12.01.19.
//
#pragma once
#include "Utils.hpp"
#include "Types.hpp"
template<typename... Types>
using Callback = void (*)(Types...);
template<typename R>
using FunctionEllipsis = R(*)(...);
template<size_t N>
static constexpr unsigned int CallbackIndex(const char(&str)[N])
{
return Utils::hash(str);
}
struct CallbackIdentity
{
const char* types;
const unsigned int numargs;
constexpr bool matches(const char* types, const unsigned int N = 0) const
{
return N < numargs ? this->types[N] == types[N] && matches(types, N + 1) : this->types[N] == types[N];
}
template<typename... Types>
constexpr CallbackIdentity(Callback<Types...>) : types(TypeString<Types...>::value), numargs(sizeof(TypeString<Types...>::value) - 1) {}
};
struct ScriptCallbackData
{
const char* name;
const unsigned long long index;
const CallbackIdentity callback;
template<size_t N>
constexpr ScriptCallbackData(const char(&name)[N], CallbackIdentity _callback) : name(name), index(CallbackIndex(name)), callback(_callback) {}
};

@ -0,0 +1,13 @@
#include "Callbacks.hpp"
#include "API/PublicFnAPI.hpp"
#include <cstdarg>
#include <iostream>
#include <apps/openmw-mp/Player.hpp>
#include <apps/openmw-mp/Networking.hpp>
#include <components/openmw-mp/NetworkMessages.hpp>
template<typename... Types>
constexpr char TypeString<Types...>::value[];
constexpr ScriptCallbackData Callbacks::callbacks[];
using namespace std;

@ -0,0 +1,105 @@
#ifndef SCRIPTFUNCTIONS_HPP
#define SCRIPTFUNCTIONS_HPP
#include <Script/Functions/Actors.h>
#include <Script/Functions/Books.h>
#include <Script/Functions/Cells.h>
#include <Script/Functions/CharClass.h>
#include <Script/Functions/Chat.h>
#include <Script/Functions/Dialogue.h>
#include <Script/Functions/Factions.h>
#include <Script/Functions/GUI.h>
#include <Script/Functions/Items.h>
#include <Script/Functions/Mechanics.h>
#include <Script/Functions/Miscellaneous.h>
#include <Script/Functions/Objects.h>
#include <Script/Functions/Positions.h>
#include <Script/Functions/Public.h>
#include <Script/Functions/Quests.h>
#include <Script/Functions/RecordsDynamic.h>
#include <Script/Functions/Shapeshift.h>
#include <Script/Functions/Server.h>
#include <Script/Functions/Settings.h>
#include <Script/Functions/Spells.h>
#include <Script/Functions/Stats.h>
#include <Script/Functions/Timer.h>
#include <Script/Functions/Worldstate.h>
#include "Callback.hpp"
#include <components/openmw-mp/Log.hpp>
#ifndef __PRETTY_FUNCTION__
#define __PRETTY_FUNCTION__ __FUNCTION__
#endif
#define GET_PLAYER(pid, pl, retvalue) \
pl = Players::getPlayer(pid); \
if (player == 0) {\
LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, "%s: Player with pid \'%d\' not found\n", __PRETTY_FUNCTION__, pid);\
/*ScriptFunctions::StopServer(1);*/ \
return retvalue;\
}
struct Callbacks
{
static constexpr ScriptCallbackData callbacks[]{
{"OnServerInit", Callback<>()},
{"OnServerPostInit", Callback<>()},
{"OnServerExit", Callback<bool>()},
{"OnPlayerConnect", Callback<PlayerId>()},
{"OnPlayerDisconnect", Callback<PlayerId>()},
{"OnPlayerDeath", Callback<PlayerId>()},
{"OnPlayerResurrect", Callback<PlayerId>()},
{"OnPlayerCellChange", Callback<PlayerId>()},
{"OnPlayerAttribute", Callback<PlayerId>()},
{"OnPlayerSkill", Callback<PlayerId>()},
{"OnPlayerLevel", Callback<PlayerId>()},
{"OnPlayerBounty", Callback<PlayerId>()},
{"OnPlayerReputation", Callback<PlayerId>()},
{"OnPlayerEquipment", Callback<PlayerId>()},
{"OnPlayerInventory", Callback<PlayerId>()},
{"OnPlayerJournal", Callback<PlayerId>()},
{"OnPlayerFaction", Callback<PlayerId>()},
{"OnPlayerShapeshift", Callback<PlayerId>()},
{"OnPlayerSpellbook", Callback<PlayerId>()},
{"OnPlayerQuickKeys", Callback<PlayerId>()},
{"OnPlayerTopic", Callback<PlayerId>()},
{"OnPlayerDisposition", Callback<PlayerId>()},
{"OnPlayerBook", Callback<PlayerId>()},
{"OnPlayerItemUse", Callback<PlayerId>()},
{"OnPlayerMiscellaneous", Callback<PlayerId>()},
{"OnPlayerInput", Callback<PlayerId>()},
{"OnPlayerRest", Callback<PlayerId>()},
{"OnRecordDynamic", Callback<PlayerId>()},
{"OnCellLoad", Callback<PlayerId, const char*>()},
{"OnCellUnload", Callback<PlayerId, const char*>()},
{"OnCellDeletion", Callback<const char*>()},
{"OnContainer", Callback<PlayerId, const char*>()},
{"OnDoorState", Callback<PlayerId, const char*>()},
{"OnObjectActivate", Callback<PlayerId, const char*>()},
{"OnObjectPlace", Callback<PlayerId, const char*>()},
{"OnObjectState", Callback<PlayerId, const char*>()},
{"OnObjectSpawn", Callback<PlayerId, const char*>()},
{"OnObjectDelete", Callback<PlayerId, const char*>()},
{"OnObjectLock", Callback<PlayerId, const char*>()},
{"OnObjectScale", Callback<PlayerId, const char*>()},
{"OnObjectTrap", Callback<PlayerId, const char*>()},
{"OnVideoPlay", Callback<PlayerId, const char*>()},
{"OnActorList", Callback<PlayerId, const char*>()},
{"OnActorEquipment", Callback<PlayerId, const char*>()},
{"OnActorAI", Callback<PlayerId, const char*>()},
{"OnActorDeath", Callback<PlayerId, const char*>()},
{"OnActorCellChange", Callback<PlayerId, const char*>()},
{"OnActorTest", Callback<PlayerId, const char*>()},
{"OnPlayerSendMessage", Callback<PlayerId, const char*>()},
{"OnPlayerEndCharGen", Callback<PlayerId>()},
{"OnGUIAction", Callback<PlayerId, int, const char*>()},
{"OnWorldKillCount", Callback<PlayerId>()},
{"OnWorldMap", Callback<PlayerId>()},
{"OnWorldWeather", Callback<PlayerId>() },
{"OnMpNumIncrement", Callback<int>()},
{"OnRequestPluginList", Callback<>()}
};
};
#endif //SCRIPTFUNCTIONS_HPP

@ -0,0 +1,149 @@
//
// Created by koncord on 09.01.19.
//
#include <cstring>
#include <cstdarg>
#include "FFI.hpp"
FFI::FFI(ScriptFunc func, char retFormat, const char *argFormat, ...)
{
std::va_list argList;
va_start(argList, argFormat);
fnPtr = func;
setArguments(argFormat, argList);
setRetType(retFormat);
va_end(argList);
}
void FFI::setArguments(const std::string &format, va_list argList)
{
cifInitialized = false;
va_list vaList;
va_copy(vaList, argList);
resize(format.size());
for (size_t i = 0; i < format.size(); ++i)
{
switch (format[i])
{
case 'v':
break;
case 's': // const char*
setArgument(i, (const char*) va_arg(vaList, const char*));
break;
case 'c':
setArgument(i, (int8_t) va_arg(vaList, int));
break;
case 'C':
setArgument(i, (uint8_t) va_arg(vaList, int));
break;
case 'h':
setArgument(i, (int16_t) va_arg(vaList, int));
break;
case 'H':
setArgument(i, (uint16_t) va_arg(vaList, int));
break;
case 'i':
setArgument(i, va_arg(vaList, int32_t));
break;
case 'I':
setArgument(i, va_arg(vaList, uint32_t));
break;
case 'l':
setArgument(i, va_arg(vaList, int64_t));
break;
case 'L':
setArgument(i, va_arg(vaList, uint64_t));
break;
case 'd':
case 'f':
setArgument(i, va_arg(vaList, double));
break;
case 'p':
setArgument(i, va_arg(vaList, void*));
break;
case 'b': // bool
setArgument(i, (bool) (va_arg(vaList, int) == 1));
break;
default:
break;
}
}
va_end(vaList);
}
void FFI::setRetType(char type)
{
cifInitialized = false;
retType = formatToFFIType(type);
}
void FFI::setFunctionPtr(ScriptFunc func)
{
cifInitialized = false;
fnPtr = func;
}
#include "Types.hpp"
ffi_type *FFI::formatToFFIType(char type)
{
switch (type)
{
case 'v':
return CToFFIType<void>();
case 's':
return CToFFIType<const char *>();
case 'c':
return CToFFIType<int8_t>();
case 'C':
return CToFFIType<uint8_t>();
case 'h':
return CToFFIType<int16_t>();
case 'H':
return CToFFIType<uint16_t>();
case 'i':
return CToFFIType<int32_t>();
case 'I':
return CToFFIType<uint32_t>();
case 'l':
return CToFFIType<int64_t>();
case 'L':
return CToFFIType<uint64_t>();
case 'f':
case 'd':
return CToFFIType<double>();
case 'p':
return CToFFIType<void *>();
case 'b': // bool
return CToFFIType<bool>();
default:
throw std::invalid_argument(std::string("unknown argument type \'") + type + '\'');
}
}
void FFI::resize(size_t size)
{
types.resize(size);
ptrs.resize(size);
argsStore.resize(size);
}
RetType FFI::call()
{
if (!cifInitialized)
{
cifInitialized = true;
if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, (unsigned int) types.size(), retType, types.data()) != FFI_OK)
throw std::runtime_error("Whoops! Cannot prepare CIF!");
}
ffi_arg retVal;
ffi_call(&cif, FFI_FN(fnPtr), &retVal, ptrs.data());
return retVal;
}

@ -0,0 +1,77 @@
//
// Created by koncord on 09.01.19.
//
#pragma once
extern "C"
{
#include <ffi.h>
}
#include <stdexcept>
#include "ArgsStore.hpp"
#include <Script/CTypes.h>
class FFI
{
private:
std::vector<ffi_type *> types;
std::vector<void *> ptrs;
TArgsStore argsStore;
ffi_type *retType;
bool cifInitialized;
ffi_cif cif;
ScriptFunc fnPtr;
void resize(size_t size);
template<typename T>
constexpr ffi_type *CToFFIType()
{
if (std::is_same<T, bool>::value)
return &ffi_type_sint8;
if (std::is_same<T, void>::value)
return &ffi_type_void;
if (std::is_same<T, uint8_t>::value)
return &ffi_type_uint8;
if (std::is_same<T, int8_t>::value)
return &ffi_type_sint8;
if (std::is_same<T, uint16_t>::value)
return &ffi_type_uint16;
if (std::is_same<T, int16_t>::value)
return &ffi_type_sint16;
if (std::is_same<T, uint32_t>::value)
return &ffi_type_uint32;
if (std::is_same<T, int32_t>::value)
return &ffi_type_sint32;
if (std::is_same<T, uint64_t>::value)
return &ffi_type_uint64;
if (std::is_same<T, int64_t>::value)
return &ffi_type_sint64;
if (std::is_same<T, float>::value)
return &ffi_type_float;
if (std::is_same<T, double>::value)
return &ffi_type_double;
if (std::is_pointer<T>::value)
return &ffi_type_pointer;
}
template<typename T>
void setArgument(size_t index, const T &v)
{
types[index] = CToFFIType<T>();
argsStore[index] = v;
ptrs[index] = (void *) &std::get<T>(argsStore[index]);
}
ffi_type *formatToFFIType(char type);
protected:
FFI() = default;
public:
explicit FFI(ScriptFunc func, char retFormat, const char *argFormat, ...);
void setArguments(const std::string &format, va_list argList);
void setRetType(char type);
void setFunctionPtr(ScriptFunc func);
RetType call();
};

@ -4,11 +4,11 @@
#include <apps/openmw-mp/Networking.hpp>
#include <apps/openmw-mp/Player.hpp>
#include <apps/openmw-mp/Utils.hpp>
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
#include <apps/openmw-mp/Script/Callbacks.hpp>
#include <components/esm/creaturestats.hpp>
#include "Actors.hpp"
#include "Actors.h"
using namespace mwmp;
@ -20,25 +20,25 @@ const BaseActor emptyActor = {};
static std::string tempCellDescription;
void ActorFunctions::ReadReceivedActorList() noexcept
extern "C" void ActorFunctions::ReadReceivedActorList() noexcept
{
readActorList = mwmp::Networking::getPtr()->getReceivedActorList();
}
void ActorFunctions::ReadCellActorList(const char* cellDescription) noexcept
extern "C" void ActorFunctions::ReadCellActorList(const char* cellDescription) noexcept
{
ESM::Cell esmCell = Utils::getCellFromDescription(cellDescription);
Cell *serverCell = CellController::get()->getCell(&esmCell);
readActorList = serverCell->getActorList();
}
void ActorFunctions::ClearActorList() noexcept
extern "C" void ActorFunctions::ClearActorList() noexcept
{
writeActorList.cell.blank();
writeActorList.baseActors.clear();
}
void ActorFunctions::SetActorListPid(unsigned short pid) noexcept
extern "C" void ActorFunctions::SetActorListPid(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -46,143 +46,143 @@ void ActorFunctions::SetActorListPid(unsigned short pid) noexcept
writeActorList.guid = player->guid;
}
void ActorFunctions::CopyReceivedActorListToStore() noexcept
extern "C" void ActorFunctions::CopyReceivedActorListToStore() noexcept
{
writeActorList = *readActorList;
}
unsigned int ActorFunctions::GetActorListSize() noexcept
extern "C" unsigned int ActorFunctions::GetActorListSize() noexcept
{
return readActorList->count;
}
unsigned char ActorFunctions::GetActorListAction() noexcept
extern "C" unsigned char ActorFunctions::GetActorListAction() noexcept
{
return readActorList->action;
}
const char *ActorFunctions::GetActorCell(unsigned int index) noexcept
extern "C" const char *ActorFunctions::GetActorCell(unsigned int index) noexcept
{
tempCellDescription = readActorList->baseActors.at(index).cell.getDescription();
return tempCellDescription.c_str();
}
const char *ActorFunctions::GetActorRefId(unsigned int index) noexcept
extern "C" const char *ActorFunctions::GetActorRefId(unsigned int index) noexcept
{
return readActorList->baseActors.at(index).refId.c_str();
}
unsigned int ActorFunctions::GetActorRefNum(unsigned int index) noexcept
extern "C" unsigned int ActorFunctions::GetActorRefNum(unsigned int index) noexcept
{
return readActorList->baseActors.at(index).refNum;
}
unsigned int ActorFunctions::GetActorMpNum(unsigned int index) noexcept
extern "C" unsigned int ActorFunctions::GetActorMpNum(unsigned int index) noexcept
{
return readActorList->baseActors.at(index).mpNum;
}
double ActorFunctions::GetActorPosX(unsigned int index) noexcept
extern "C" double ActorFunctions::GetActorPosX(unsigned int index) noexcept
{
return readActorList->baseActors.at(index).position.pos[0];
}
double ActorFunctions::GetActorPosY(unsigned int index) noexcept
extern "C" double ActorFunctions::GetActorPosY(unsigned int index) noexcept
{
return readActorList->baseActors.at(index).position.pos[1];
}
double ActorFunctions::GetActorPosZ(unsigned int index) noexcept
extern "C" double ActorFunctions::GetActorPosZ(unsigned int index) noexcept
{
return readActorList->baseActors.at(index).position.pos[2];
}
double ActorFunctions::GetActorRotX(unsigned int index) noexcept
extern "C" double ActorFunctions::GetActorRotX(unsigned int index) noexcept
{
return readActorList->baseActors.at(index).position.rot[0];
}
double ActorFunctions::GetActorRotY(unsigned int index) noexcept
extern "C" double ActorFunctions::GetActorRotY(unsigned int index) noexcept
{
return readActorList->baseActors.at(index).position.rot[1];
}
double ActorFunctions::GetActorRotZ(unsigned int index) noexcept
extern "C" double ActorFunctions::GetActorRotZ(unsigned int index) noexcept
{
return readActorList->baseActors.at(index).position.rot[2];
}
double ActorFunctions::GetActorHealthBase(unsigned int index) noexcept
extern "C" double ActorFunctions::GetActorHealthBase(unsigned int index) noexcept
{
return readActorList->baseActors.at(index).creatureStats.mDynamic[0].mBase;
}
double ActorFunctions::GetActorHealthCurrent(unsigned int index) noexcept
extern "C" double ActorFunctions::GetActorHealthCurrent(unsigned int index) noexcept
{
return readActorList->baseActors.at(index).creatureStats.mDynamic[0].mCurrent;
}
double ActorFunctions::GetActorHealthModified(unsigned int index) noexcept
extern "C" double ActorFunctions::GetActorHealthModified(unsigned int index) noexcept
{
return readActorList->baseActors.at(index).creatureStats.mDynamic[0].mMod;
}
double ActorFunctions::GetActorMagickaBase(unsigned int index) noexcept
extern "C" double ActorFunctions::GetActorMagickaBase(unsigned int index) noexcept
{
return readActorList->baseActors.at(index).creatureStats.mDynamic[1].mBase;
}
double ActorFunctions::GetActorMagickaCurrent(unsigned int index) noexcept
extern "C" double ActorFunctions::GetActorMagickaCurrent(unsigned int index) noexcept
{
return readActorList->baseActors.at(index).creatureStats.mDynamic[1].mCurrent;
}
double ActorFunctions::GetActorMagickaModified(unsigned int index) noexcept
extern "C" double ActorFunctions::GetActorMagickaModified(unsigned int index) noexcept
{
return readActorList->baseActors.at(index).creatureStats.mDynamic[1].mMod;
}
double ActorFunctions::GetActorFatigueBase(unsigned int index) noexcept
extern "C" double ActorFunctions::GetActorFatigueBase(unsigned int index) noexcept
{
return readActorList->baseActors.at(index).creatureStats.mDynamic[2].mBase;
}
double ActorFunctions::GetActorFatigueCurrent(unsigned int index) noexcept
extern "C" double ActorFunctions::GetActorFatigueCurrent(unsigned int index) noexcept
{
return readActorList->baseActors.at(index).creatureStats.mDynamic[2].mCurrent;
}
double ActorFunctions::GetActorFatigueModified(unsigned int index) noexcept
extern "C" double ActorFunctions::GetActorFatigueModified(unsigned int index) noexcept
{
return readActorList->baseActors.at(index).creatureStats.mDynamic[2].mMod;
}
const char *ActorFunctions::GetActorEquipmentItemRefId(unsigned int index, unsigned short slot) noexcept
extern "C" const char *ActorFunctions::GetActorEquipmentItemRefId(unsigned int index, unsigned short slot) noexcept
{
return readActorList->baseActors.at(index).equipmentItems[slot].refId.c_str();
}
int ActorFunctions::GetActorEquipmentItemCount(unsigned int index, unsigned short slot) noexcept
extern "C" int ActorFunctions::GetActorEquipmentItemCount(unsigned int index, unsigned short slot) noexcept
{
return readActorList->baseActors.at(index).equipmentItems[slot].count;
}
int ActorFunctions::GetActorEquipmentItemCharge(unsigned int index, unsigned short slot) noexcept
extern "C" int ActorFunctions::GetActorEquipmentItemCharge(unsigned int index, unsigned short slot) noexcept
{
return readActorList->baseActors.at(index).equipmentItems[slot].charge;
}
double ActorFunctions::GetActorEquipmentItemEnchantmentCharge(unsigned int index, unsigned short slot) noexcept
extern "C" double ActorFunctions::GetActorEquipmentItemEnchantmentCharge(unsigned int index, unsigned short slot) noexcept
{
return readActorList->baseActors.at(index).equipmentItems[slot].enchantmentCharge;
}
bool ActorFunctions::DoesActorHavePlayerKiller(unsigned int index) noexcept
extern "C" bool ActorFunctions::DoesActorHavePlayerKiller(unsigned int index) noexcept
{
return readActorList->baseActors.at(index).killer.isPlayer;
}
int ActorFunctions::GetActorKillerPid(unsigned int index) noexcept
extern "C" int ActorFunctions::GetActorKillerPid(unsigned int index) noexcept
{
Player *player = Players::getPlayer(readActorList->baseActors.at(index).killer.guid);
@ -192,136 +192,136 @@ int ActorFunctions::GetActorKillerPid(unsigned int index) noexcept
return -1;
}
const char *ActorFunctions::GetActorKillerRefId(unsigned int index) noexcept
extern "C" const char *ActorFunctions::GetActorKillerRefId(unsigned int index) noexcept
{
return readActorList->baseActors.at(index).killer.refId.c_str();
}
unsigned int ActorFunctions::GetActorKillerRefNum(unsigned int index) noexcept
extern "C" unsigned int ActorFunctions::GetActorKillerRefNum(unsigned int index) noexcept
{
return readActorList->baseActors.at(index).killer.refNum;
}
unsigned int ActorFunctions::GetActorKillerMpNum(unsigned int index) noexcept
extern "C" unsigned int ActorFunctions::GetActorKillerMpNum(unsigned int index) noexcept
{
return readActorList->baseActors.at(index).killer.mpNum;
}
const char *ActorFunctions::GetActorKillerName(unsigned int index) noexcept
extern "C" const char *ActorFunctions::GetActorKillerName(unsigned int index) noexcept
{
return readActorList->baseActors.at(index).killer.name.c_str();
}
bool ActorFunctions::DoesActorHavePosition(unsigned int index) noexcept
extern "C" bool ActorFunctions::DoesActorHavePosition(unsigned int index) noexcept
{
return readActorList->baseActors.at(index).hasPositionData;
}
bool ActorFunctions::DoesActorHaveStatsDynamic(unsigned int index) noexcept
extern "C" bool ActorFunctions::DoesActorHaveStatsDynamic(unsigned int index) noexcept
{
return readActorList->baseActors.at(index).hasStatsDynamicData;
}
void ActorFunctions::SetActorListCell(const char* cellDescription) noexcept
extern "C" void ActorFunctions::SetActorListCell(const char* cellDescription) noexcept
{
writeActorList.cell = Utils::getCellFromDescription(cellDescription);
}
void ActorFunctions::SetActorListAction(unsigned char action) noexcept
extern "C" void ActorFunctions::SetActorListAction(unsigned char action) noexcept
{
writeActorList.action = action;
}
void ActorFunctions::SetActorCell(const char* cellDescription) noexcept
extern "C" void ActorFunctions::SetActorCell(const char* cellDescription) noexcept
{
tempActor.cell = Utils::getCellFromDescription(cellDescription);
}
void ActorFunctions::SetActorRefId(const char* refId) noexcept
extern "C" void ActorFunctions::SetActorRefId(const char* refId) noexcept
{
tempActor.refId = refId;
}
void ActorFunctions::SetActorRefNum(int refNum) noexcept
extern "C" void ActorFunctions::SetActorRefNum(int refNum) noexcept
{
tempActor.refNum = refNum;
}
void ActorFunctions::SetActorMpNum(int mpNum) noexcept
extern "C" void ActorFunctions::SetActorMpNum(int mpNum) noexcept
{
tempActor.mpNum = mpNum;
}
void ActorFunctions::SetActorPosition(double x, double y, double z) noexcept
extern "C" void ActorFunctions::SetActorPosition(double x, double y, double z) noexcept
{
tempActor.position.pos[0] = x;
tempActor.position.pos[1] = y;
tempActor.position.pos[2] = z;
}
void ActorFunctions::SetActorRotation(double x, double y, double z) noexcept
extern "C" void ActorFunctions::SetActorRotation(double x, double y, double z) noexcept
{
tempActor.position.rot[0] = x;
tempActor.position.rot[1] = y;
tempActor.position.rot[2] = z;
}
void ActorFunctions::SetActorHealthBase(double value) noexcept
extern "C" void ActorFunctions::SetActorHealthBase(double value) noexcept
{
tempActor.creatureStats.mDynamic[0].mBase = value;
}
void ActorFunctions::SetActorHealthCurrent(double value) noexcept
extern "C" void ActorFunctions::SetActorHealthCurrent(double value) noexcept
{
tempActor.creatureStats.mDynamic[0].mCurrent = value;
}
void ActorFunctions::SetActorHealthModified(double value) noexcept
extern "C" void ActorFunctions::SetActorHealthModified(double value) noexcept
{
tempActor.creatureStats.mDynamic[0].mMod = value;
}
void ActorFunctions::SetActorMagickaBase(double value) noexcept
extern "C" void ActorFunctions::SetActorMagickaBase(double value) noexcept
{
tempActor.creatureStats.mDynamic[1].mBase = value;
}
void ActorFunctions::SetActorMagickaCurrent(double value) noexcept
extern "C" void ActorFunctions::SetActorMagickaCurrent(double value) noexcept
{
tempActor.creatureStats.mDynamic[1].mCurrent = value;
}
void ActorFunctions::SetActorMagickaModified(double value) noexcept
extern "C" void ActorFunctions::SetActorMagickaModified(double value) noexcept
{
tempActor.creatureStats.mDynamic[1].mMod = value;
}
void ActorFunctions::SetActorFatigueBase(double value) noexcept
extern "C" void ActorFunctions::SetActorFatigueBase(double value) noexcept
{
tempActor.creatureStats.mDynamic[2].mBase = value;
}
void ActorFunctions::SetActorFatigueCurrent(double value) noexcept
extern "C" void ActorFunctions::SetActorFatigueCurrent(double value) noexcept
{
tempActor.creatureStats.mDynamic[2].mCurrent = value;
}
void ActorFunctions::SetActorFatigueModified(double value) noexcept
extern "C" void ActorFunctions::SetActorFatigueModified(double value) noexcept
{
tempActor.creatureStats.mDynamic[2].mMod = value;
}
void ActorFunctions::SetActorSound(const char* sound) noexcept
extern "C" void ActorFunctions::SetActorSound(const char* sound) noexcept
{
tempActor.sound = sound;
}
void ActorFunctions::SetActorAIAction(unsigned int action) noexcept
extern "C" void ActorFunctions::SetActorAIAction(unsigned int action) noexcept
{
tempActor.aiAction = action;
}
void ActorFunctions::SetActorAITargetToPlayer(unsigned short pid) noexcept
extern "C" void ActorFunctions::SetActorAITargetToPlayer(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -332,7 +332,7 @@ void ActorFunctions::SetActorAITargetToPlayer(unsigned short pid) noexcept
tempActor.aiTarget.guid = player->guid;
}
void ActorFunctions::SetActorAITargetToObject(int refNum, int mpNum) noexcept
extern "C" void ActorFunctions::SetActorAITargetToObject(int refNum, int mpNum) noexcept
{
tempActor.hasAiTarget = true;
tempActor.aiTarget.isPlayer = false;
@ -341,29 +341,29 @@ void ActorFunctions::SetActorAITargetToObject(int refNum, int mpNum) noexcept
tempActor.aiTarget.mpNum = mpNum;
}
void ActorFunctions::SetActorAICoordinates(double x, double y, double z) noexcept
extern "C" void ActorFunctions::SetActorAICoordinates(double x, double y, double z) noexcept
{
tempActor.aiCoordinates.pos[0] = x;
tempActor.aiCoordinates.pos[1] = y;
tempActor.aiCoordinates.pos[2] = z;
}
void ActorFunctions::SetActorAIDistance(unsigned int distance) noexcept
extern "C" void ActorFunctions::SetActorAIDistance(unsigned int distance) noexcept
{
tempActor.aiDistance = distance;
}
void ActorFunctions::SetActorAIDuration(unsigned int duration) noexcept
extern "C" void ActorFunctions::SetActorAIDuration(unsigned int duration) noexcept
{
tempActor.aiDuration = duration;
}
void ActorFunctions::SetActorAIRepetition(bool shouldRepeat) noexcept
extern "C" void ActorFunctions::SetActorAIRepetition(bool shouldRepeat) noexcept
{
tempActor.aiShouldRepeat = shouldRepeat;
}
void ActorFunctions::EquipActorItem(unsigned short slot, const char *refId, unsigned int count, int charge, double enchantmentCharge) noexcept
extern "C" void ActorFunctions::EquipActorItem(unsigned short slot, const char *refId, unsigned int count, int charge, double enchantmentCharge) noexcept
{
tempActor.equipmentItems[slot].refId = refId;
tempActor.equipmentItems[slot].count = count;
@ -371,26 +371,26 @@ void ActorFunctions::EquipActorItem(unsigned short slot, const char *refId, unsi
tempActor.equipmentItems[slot].enchantmentCharge = enchantmentCharge;
}
void ActorFunctions::UnequipActorItem(unsigned short slot) noexcept
extern "C" void ActorFunctions::UnequipActorItem(unsigned short slot) noexcept
{
ActorFunctions::EquipActorItem(slot, "", 0, -1, -1);
}
void ActorFunctions::AddActor() noexcept
extern "C" void ActorFunctions::AddActor() noexcept
{
writeActorList.baseActors.push_back(tempActor);
tempActor = emptyActor;
}
void ActorFunctions::SendActorList() noexcept
extern "C" void ActorFunctions::SendActorList() noexcept
{
mwmp::ActorPacket *actorPacket = mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_LIST);
actorPacket->setActorList(&writeActorList);
actorPacket->Send(writeActorList.guid);
}
void ActorFunctions::SendActorAuthority() noexcept
extern "C" void ActorFunctions::SendActorAuthority() noexcept
{
Cell *serverCell = CellController::get()->getCell(&writeActorList.cell);
@ -407,7 +407,7 @@ void ActorFunctions::SendActorAuthority() noexcept
}
}
void ActorFunctions::SendActorPosition(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept
extern "C" void ActorFunctions::SendActorPosition(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept
{
mwmp::ActorPacket *actorPacket = mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_POSITION);
actorPacket->setActorList(&writeActorList);
@ -426,7 +426,7 @@ void ActorFunctions::SendActorPosition(bool sendToOtherVisitors, bool skipAttach
}
}
void ActorFunctions::SendActorStatsDynamic(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept
extern "C" void ActorFunctions::SendActorStatsDynamic(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept
{
mwmp::ActorPacket *actorPacket = mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_STATS_DYNAMIC);
actorPacket->setActorList(&writeActorList);
@ -445,7 +445,7 @@ void ActorFunctions::SendActorStatsDynamic(bool sendToOtherVisitors, bool skipAt
}
}
void ActorFunctions::SendActorEquipment(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept
extern "C" void ActorFunctions::SendActorEquipment(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept
{
mwmp::ActorPacket *actorPacket = mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_EQUIPMENT);
actorPacket->setActorList(&writeActorList);
@ -464,7 +464,7 @@ void ActorFunctions::SendActorEquipment(bool sendToOtherVisitors, bool skipAttac
}
}
void ActorFunctions::SendActorSpeech(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept
extern "C" void ActorFunctions::SendActorSpeech(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept
{
mwmp::ActorPacket *actorPacket = mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_SPEECH);
actorPacket->setActorList(&writeActorList);
@ -483,7 +483,7 @@ void ActorFunctions::SendActorSpeech(bool sendToOtherVisitors, bool skipAttached
}
}
void ActorFunctions::SendActorAI(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept
extern "C" void ActorFunctions::SendActorAI(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept
{
mwmp::ActorPacket *actorPacket = mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_AI);
actorPacket->setActorList(&writeActorList);
@ -502,7 +502,7 @@ void ActorFunctions::SendActorAI(bool sendToOtherVisitors, bool skipAttachedPlay
}
}
void ActorFunctions::SendActorCellChange(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept
extern "C" void ActorFunctions::SendActorCellChange(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept
{
mwmp::ActorPacket *actorPacket = mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_CELL_CHANGE);
actorPacket->setActorList(&writeActorList);
@ -521,36 +521,35 @@ void ActorFunctions::SendActorCellChange(bool sendToOtherVisitors, bool skipAtta
}
}
// All methods below are deprecated versions of methods from above
extern "C" // All methods below are deprecated versions of methods from above
void ActorFunctions::ReadLastActorList() noexcept
{
ReadReceivedActorList();
}
void ActorFunctions::InitializeActorList(unsigned short pid) noexcept
extern "C" void ActorFunctions::InitializeActorList(PlayerId pid) noexcept
{
ClearActorList();
SetActorListPid(pid);
}
void ActorFunctions::CopyLastActorListToStore() noexcept
extern "C" void ActorFunctions::CopyLastActorListToStore() noexcept
{
CopyReceivedActorListToStore();
CopyLastActorListToStore();
}
unsigned int ActorFunctions::GetActorRefNumIndex(unsigned int index) noexcept
extern "C" unsigned int ActorFunctions::GetActorRefNumIndex(unsigned int index) noexcept
{
return GetActorRefNum(index);
}
unsigned int ActorFunctions::GetActorKillerRefNumIndex(unsigned int index) noexcept
extern "C" unsigned int ActorFunctions::GetActorKillerRefNumIndex(unsigned int index) noexcept
{
return GetActorKillerRefNum(index);
}
void ActorFunctions::SetActorRefNumIndex(int refNum) noexcept
extern "C" void ActorFunctions::SetActorRefNumIndex(int refNum) noexcept
{
tempActor.refNum = refNum;
}

@ -1,117 +1,15 @@
#ifndef OPENMW_ACTORAPI_HPP
#define OPENMW_ACTORAPI_HPP
#define ACTORAPI \
{"ReadReceivedActorList", ActorFunctions::ReadReceivedActorList},\
{"ReadCellActorList", ActorFunctions::ReadCellActorList},\
\
{"ClearActorList", ActorFunctions::ClearActorList},\
{"SetActorListPid", ActorFunctions::SetActorListPid},\
\
{"CopyReceivedActorListToStore", ActorFunctions::CopyReceivedActorListToStore},\
\
{"GetActorListSize", ActorFunctions::GetActorListSize},\
{"GetActorListAction", ActorFunctions::GetActorListAction},\
\
{"GetActorCell", ActorFunctions::GetActorCell},\
{"GetActorRefId", ActorFunctions::GetActorRefId},\
{"GetActorRefNum", ActorFunctions::GetActorRefNum},\
{"GetActorMpNum", ActorFunctions::GetActorMpNum},\
\
{"GetActorPosX", ActorFunctions::GetActorPosX},\
{"GetActorPosY", ActorFunctions::GetActorPosY},\
{"GetActorPosZ", ActorFunctions::GetActorPosZ},\
{"GetActorRotX", ActorFunctions::GetActorRotX},\
{"GetActorRotY", ActorFunctions::GetActorRotY},\
{"GetActorRotZ", ActorFunctions::GetActorRotZ},\
\
{"GetActorHealthBase", ActorFunctions::GetActorHealthBase},\
{"GetActorHealthCurrent", ActorFunctions::GetActorHealthCurrent},\
{"GetActorHealthModified", ActorFunctions::GetActorHealthModified},\
{"GetActorMagickaBase", ActorFunctions::GetActorMagickaBase},\
{"GetActorMagickaCurrent", ActorFunctions::GetActorMagickaCurrent},\
{"GetActorMagickaModified", ActorFunctions::GetActorMagickaModified},\
{"GetActorFatigueBase", ActorFunctions::GetActorFatigueBase},\
{"GetActorFatigueCurrent", ActorFunctions::GetActorFatigueCurrent},\
{"GetActorFatigueModified", ActorFunctions::GetActorFatigueModified},\
\
{"GetActorEquipmentItemRefId", ActorFunctions::GetActorEquipmentItemRefId},\
{"GetActorEquipmentItemCount", ActorFunctions::GetActorEquipmentItemCount},\
{"GetActorEquipmentItemCharge", ActorFunctions::GetActorEquipmentItemCharge},\
{"GetActorEquipmentItemEnchantmentCharge", ActorFunctions::GetActorEquipmentItemEnchantmentCharge},\
\
{"DoesActorHavePlayerKiller", ActorFunctions::DoesActorHavePlayerKiller},\
{"GetActorKillerPid", ActorFunctions::GetActorKillerPid},\
{"GetActorKillerRefId", ActorFunctions::GetActorKillerRefId},\
{"GetActorKillerRefNum", ActorFunctions::GetActorKillerRefNum},\
{"GetActorKillerMpNum", ActorFunctions::GetActorKillerMpNum},\
{"GetActorKillerName", ActorFunctions::GetActorKillerName},\
\
{"DoesActorHavePosition", ActorFunctions::DoesActorHavePosition},\
{"DoesActorHaveStatsDynamic", ActorFunctions::DoesActorHaveStatsDynamic},\
\
{"SetActorListCell", ActorFunctions::SetActorListCell},\
{"SetActorListAction", ActorFunctions::SetActorListAction},\
\
{"SetActorCell", ActorFunctions::SetActorCell},\
{"SetActorRefId", ActorFunctions::SetActorRefId},\
{"SetActorRefNum", ActorFunctions::SetActorRefNum},\
{"SetActorMpNum", ActorFunctions::SetActorMpNum},\
\
{"SetActorPosition", ActorFunctions::SetActorPosition},\
{"SetActorRotation", ActorFunctions::SetActorRotation},\
\
{"SetActorHealthBase", ActorFunctions::SetActorHealthBase},\
{"SetActorHealthCurrent", ActorFunctions::SetActorHealthCurrent},\
{"SetActorHealthModified", ActorFunctions::SetActorHealthModified},\
{"SetActorMagickaBase", ActorFunctions::SetActorMagickaBase},\
{"SetActorMagickaCurrent", ActorFunctions::SetActorMagickaCurrent},\
{"SetActorMagickaModified", ActorFunctions::SetActorMagickaModified},\
{"SetActorFatigueBase", ActorFunctions::SetActorFatigueBase},\
{"SetActorFatigueCurrent", ActorFunctions::SetActorFatigueCurrent},\
{"SetActorFatigueModified", ActorFunctions::SetActorFatigueModified},\
\
{"SetActorSound", ActorFunctions::SetActorSound},\
\
{"SetActorAIAction", ActorFunctions::SetActorAIAction},\
{"SetActorAITargetToPlayer", ActorFunctions::SetActorAITargetToPlayer},\
{"SetActorAITargetToObject", ActorFunctions::SetActorAITargetToObject},\
{"SetActorAICoordinates", ActorFunctions::SetActorAICoordinates},\
{"SetActorAIDistance", ActorFunctions::SetActorAIDistance},\
{"SetActorAIDuration", ActorFunctions::SetActorAIDuration},\
{"SetActorAIRepetition", ActorFunctions::SetActorAIRepetition},\
\
{"EquipActorItem", ActorFunctions::EquipActorItem},\
{"UnequipActorItem", ActorFunctions::UnequipActorItem},\
\
{"AddActor", ActorFunctions::AddActor},\
\
{"SendActorList", ActorFunctions::SendActorList},\
{"SendActorAuthority", ActorFunctions::SendActorAuthority},\
{"SendActorPosition", ActorFunctions::SendActorPosition},\
{"SendActorStatsDynamic", ActorFunctions::SendActorStatsDynamic},\
{"SendActorEquipment", ActorFunctions::SendActorEquipment},\
{"SendActorSpeech", ActorFunctions::SendActorSpeech},\
{"SendActorAI", ActorFunctions::SendActorAI},\
{"SendActorCellChange", ActorFunctions::SendActorCellChange},\
\
{"ReadLastActorList", ActorFunctions::ReadLastActorList},\
{"InitializeActorList", ActorFunctions::InitializeActorList},\
{"CopyLastActorListToStore", ActorFunctions::CopyLastActorListToStore},\
{"GetActorRefNumIndex", ActorFunctions::GetActorRefNumIndex},\
{"GetActorKillerRefNumIndex", ActorFunctions::GetActorKillerRefNumIndex},\
{"SetActorRefNumIndex", ActorFunctions::SetActorRefNumIndex}
class ActorFunctions
{
public:
#include "../api.h"
NAMESPACE_BEGIN(ActorFunctions)
/**
* \brief Use the last actor list received by the server as the one being read.
*
* \return void
*/
static void ReadReceivedActorList() noexcept;
API_FUNCTION void CDECL ReadReceivedActorList() NOEXCEPT;
/**
* \brief Use the temporary actor list stored for a cell as the one being read.
@ -122,14 +20,14 @@ public:
* \param cellDescription The description of the cell whose actor list should be read.
* \return void
*/
static void ReadCellActorList(const char* cellDescription) noexcept;
API_FUNCTION void CDECL ReadCellActorList(const char* cellDescription) NOEXCEPT;
/**
* \brief Clear the data from the actor list stored on the server.
*
* \return void
*/
static void ClearActorList() noexcept;
API_FUNCTION void CDECL ClearActorList() NOEXCEPT;
/**
* \brief Set the pid attached to the ActorList.
@ -137,7 +35,7 @@ public:
* \param pid The player ID to whom the actor list should be attached.
* \return void
*/
static void SetActorListPid(unsigned short pid) noexcept;
API_FUNCTION void CDECL SetActorListPid(PlayerId pid) NOEXCEPT;
/**
* \brief Take the contents of the read-only actor list last received by the
@ -146,21 +44,21 @@ public:
*
* \return void
*/
static void CopyReceivedActorListToStore() noexcept;
API_FUNCTION void CDECL CopyReceivedActorListToStore() NOEXCEPT;
/**
* \brief Get the number of indexes in the read actor list.
*
* \return The number of indexes.
*/
static unsigned int GetActorListSize() noexcept;
API_FUNCTION unsigned int CDECL GetActorListSize() NOEXCEPT;
/**
* \brief Get the action type used in the read actor list.
*
* \return The action type (0 for SET, 1 for ADD, 2 for REMOVE, 3 for REQUEST).
*/
static unsigned char GetActorListAction() noexcept;
API_FUNCTION unsigned char CDECL GetActorListAction() NOEXCEPT;
/**
* \brief Get the cell description of the actor at a certain index in the read actor list.
@ -168,7 +66,7 @@ public:
* \param index The index of the actor.
* \return The cell description.
*/
static const char *GetActorCell(unsigned int index) noexcept;
API_FUNCTION const char *CDECL GetActorCell(unsigned int index) NOEXCEPT;
/**
* \brief Get the refId of the actor at a certain index in the read actor list.
@ -176,7 +74,7 @@ public:
* \param index The index of the actor.
* \return The refId.
*/
static const char *GetActorRefId(unsigned int index) noexcept;
API_FUNCTION const char *CDECL GetActorRefId(unsigned int index) NOEXCEPT;
/**
* \brief Get the refNum of the actor at a certain index in the read actor list.
@ -184,7 +82,7 @@ public:
* \param index The index of the actor.
* \return The refNum.
*/
static unsigned int GetActorRefNum(unsigned int index) noexcept;
API_FUNCTION unsigned int CDECL GetActorRefNum(unsigned int index) NOEXCEPT;
/**
* \brief Get the mpNum of the actor at a certain index in the read actor list.
@ -192,7 +90,7 @@ public:
* \param index The index of the actor.
* \return The mpNum.
*/
static unsigned int GetActorMpNum(unsigned int index) noexcept;
API_FUNCTION unsigned int CDECL GetActorMpNum(unsigned int index) NOEXCEPT;
/**
* \brief Get the X position of the actor at a certain index in the read actor list.
@ -200,7 +98,7 @@ public:
* \param index The index of the actor.
* \return The X position.
*/
static double GetActorPosX(unsigned int index) noexcept;
API_FUNCTION double CDECL GetActorPosX(unsigned int index) NOEXCEPT;
/**
* \brief Get the Y position of the actor at a certain index in the read actor list.
@ -208,7 +106,7 @@ public:
* \param index The index of the actor.
* \return The Y position.
*/
static double GetActorPosY(unsigned int index) noexcept;
API_FUNCTION double CDECL GetActorPosY(unsigned int index) NOEXCEPT;
/**
* \brief Get the Z position of the actor at a certain index in the read actor list.
@ -216,7 +114,7 @@ public:
* \param index The index of the actor.
* \return The Z position.
*/
static double GetActorPosZ(unsigned int index) noexcept;
API_FUNCTION double CDECL GetActorPosZ(unsigned int index) NOEXCEPT;
/**
* \brief Get the X rotation of the actor at a certain index in the read actor list.
@ -224,7 +122,7 @@ public:
* \param index The index of the actor.
* \return The X rotation.
*/
static double GetActorRotX(unsigned int index) noexcept;
API_FUNCTION double CDECL GetActorRotX(unsigned int index) NOEXCEPT;
/**
* \brief Get the Y rotation of the actor at a certain index in the read actor list.
@ -232,7 +130,7 @@ public:
* \param index The index of the actor.
* \return The Y rotation.
*/
static double GetActorRotY(unsigned int index) noexcept;
API_FUNCTION double CDECL GetActorRotY(unsigned int index) NOEXCEPT;
/**
* \brief Get the Z rotation of the actor at a certain index in the read actor list.
@ -240,7 +138,7 @@ public:
* \param index The index of the actor.
* \return The Z rotation.
*/
static double GetActorRotZ(unsigned int index) noexcept;
API_FUNCTION double CDECL GetActorRotZ(unsigned int index) NOEXCEPT;
/**
* \brief Get the base health of the actor at a certain index in the read actor list.
@ -248,7 +146,7 @@ public:
* \param index The index of the actor.
* \return The base health.
*/
static double GetActorHealthBase(unsigned int index) noexcept;
API_FUNCTION double CDECL GetActorHealthBase(unsigned int index) NOEXCEPT;
/**
* \brief Get the current health of the actor at a certain index in the read actor list.
@ -256,7 +154,7 @@ public:
* \param index The index of the actor.
* \return The current health.
*/
static double GetActorHealthCurrent(unsigned int index) noexcept;
API_FUNCTION double CDECL GetActorHealthCurrent(unsigned int index) NOEXCEPT;
/**
* \brief Get the modified health of the actor at a certain index in the read actor list.
@ -264,7 +162,7 @@ public:
* \param index The index of the actor.
* \return The modified health.
*/
static double GetActorHealthModified(unsigned int index) noexcept;
API_FUNCTION double CDECL GetActorHealthModified(unsigned int index) NOEXCEPT;
/**
* \brief Get the base magicka of the actor at a certain index in the read actor list.
@ -272,7 +170,7 @@ public:
* \param index The index of the actor.
* \return The base magicka.
*/
static double GetActorMagickaBase(unsigned int index) noexcept;
API_FUNCTION double CDECL GetActorMagickaBase(unsigned int index) NOEXCEPT;
/**
* \brief Get the current magicka of the actor at a certain index in the read actor list.
@ -280,7 +178,7 @@ public:
* \param index The index of the actor.
* \return The current magicka.
*/
static double GetActorMagickaCurrent(unsigned int index) noexcept;
API_FUNCTION double CDECL GetActorMagickaCurrent(unsigned int index) NOEXCEPT;
/**
* \brief Get the modified magicka of the actor at a certain index in the read actor list.
@ -288,7 +186,7 @@ public:
* \param index The index of the actor.
* \return The modified magicka.
*/
static double GetActorMagickaModified(unsigned int index) noexcept;
API_FUNCTION double CDECL GetActorMagickaModified(unsigned int index) NOEXCEPT;
/**
* \brief Get the base fatigue of the actor at a certain index in the read actor list.
@ -296,7 +194,7 @@ public:
* \param index The index of the actor.
* \return The base fatigue.
*/
static double GetActorFatigueBase(unsigned int index) noexcept;
API_FUNCTION double CDECL GetActorFatigueBase(unsigned int index) NOEXCEPT;
/**
* \brief Get the current fatigue of the actor at a certain index in the read actor list.
@ -304,7 +202,7 @@ public:
* \param index The index of the actor.
* \return The current fatigue.
*/
static double GetActorFatigueCurrent(unsigned int index) noexcept;
API_FUNCTION double CDECL GetActorFatigueCurrent(unsigned int index) NOEXCEPT;
/**
* \brief Get the modified fatigue of the actor at a certain index in the read actor list.
@ -312,7 +210,7 @@ public:
* \param index The index of the actor.
* \return The modified fatigue.
*/
static double GetActorFatigueModified(unsigned int index) noexcept;
API_FUNCTION double CDECL GetActorFatigueModified(unsigned int index) NOEXCEPT;
/**
* \brief Get the refId of the item in a certain slot of the equipment of the actor at a
@ -322,7 +220,7 @@ public:
* \param slot The slot of the equipment item.
* \return The refId.
*/
static const char *GetActorEquipmentItemRefId(unsigned int index, unsigned short slot) noexcept;
API_FUNCTION const char *CDECL GetActorEquipmentItemRefId(unsigned int index, unsigned short slot) NOEXCEPT;
/**
* \brief Get the count of the item in a certain slot of the equipment of the actor at a
@ -332,7 +230,7 @@ public:
* \param slot The slot of the equipment item.
* \return The item count.
*/
static int GetActorEquipmentItemCount(unsigned int index, unsigned short slot) noexcept;
API_FUNCTION int CDECL GetActorEquipmentItemCount(unsigned int index, unsigned short slot) NOEXCEPT;
/**
* \brief Get the charge of the item in a certain slot of the equipment of the actor at a
@ -342,7 +240,7 @@ public:
* \param slot The slot of the equipment item.
* \return The charge.
*/
static int GetActorEquipmentItemCharge(unsigned int index, unsigned short slot) noexcept;
API_FUNCTION int CDECL GetActorEquipmentItemCharge(unsigned int index, unsigned short slot) NOEXCEPT;
/**
* \brief Get the enchantment charge of the item in a certain slot of the equipment of the actor at a
@ -352,7 +250,7 @@ public:
* \param slot The slot of the equipment item.
* \return The enchantment charge.
*/
static double GetActorEquipmentItemEnchantmentCharge(unsigned int index, unsigned short slot) noexcept;
API_FUNCTION double CDECL GetActorEquipmentItemEnchantmentCharge(unsigned int index, unsigned short slot) NOEXCEPT;
/**
* \brief Check whether the killer of the actor at a certain index in the read actor list is a player.
@ -360,7 +258,7 @@ public:
* \param index The index of the actor.
* \return Whether the actor was killed by a player.
*/
static bool DoesActorHavePlayerKiller(unsigned int index) noexcept;
API_FUNCTION bool CDECL DoesActorHavePlayerKiller(unsigned int index) NOEXCEPT;
/**
* \brief Get the player ID of the killer of the actor at a certain index in the read actor list.
@ -368,7 +266,7 @@ public:
* \param index The index of the actor.
* \return The player ID of the killer.
*/
static int GetActorKillerPid(unsigned int index) noexcept;
API_FUNCTION int CDECL GetActorKillerPid(unsigned int index) NOEXCEPT;
/**
* \brief Get the refId of the actor killer of the actor at a certain index in the read actor list.
@ -376,7 +274,7 @@ public:
* \param index The index of the actor.
* \return The refId of the killer.
*/
static const char *GetActorKillerRefId(unsigned int index) noexcept;
API_FUNCTION const char *CDECL GetActorKillerRefId(unsigned int index) NOEXCEPT;
/**
* \brief Get the refNum of the actor killer of the actor at a certain index in the read actor list.
@ -384,7 +282,7 @@ public:
* \param index The index of the actor.
* \return The refNum of the killer.
*/
static unsigned int GetActorKillerRefNum(unsigned int index) noexcept;
API_FUNCTION unsigned int CDECL GetActorKillerRefNum(unsigned int index) NOEXCEPT;
/**
* \brief Get the mpNum of the actor killer of the actor at a certain index in the read actor list.
@ -392,7 +290,7 @@ public:
* \param index The index of the actor.
* \return The mpNum of the killer.
*/
static unsigned int GetActorKillerMpNum(unsigned int index) noexcept;
API_FUNCTION unsigned int CDECL GetActorKillerMpNum(unsigned int index) NOEXCEPT;
/**
* \brief Get the name of the actor killer of the actor at a certain index in the read actor list.
@ -400,7 +298,7 @@ public:
* \param index The index of the actor.
* \return The name of the killer.
*/
static const char *GetActorKillerName(unsigned int index) noexcept;
API_FUNCTION const char *CDECL GetActorKillerName(unsigned int index) NOEXCEPT;
/**
* \brief Check whether there is any positional data for the actor at a certain index in
@ -411,7 +309,7 @@ public:
* \param index The index of the actor.
* \return Whether the read actor list contains positional data.
*/
static bool DoesActorHavePosition(unsigned int index) noexcept;
API_FUNCTION bool CDECL DoesActorHavePosition(unsigned int index) NOEXCEPT;
/**
* \brief Check whether there is any dynamic stats data for the actor at a certain index in
@ -422,7 +320,7 @@ public:
* \param index The index of the actor.
* \return Whether the read actor list contains dynamic stats data.
*/
static bool DoesActorHaveStatsDynamic(unsigned int index) noexcept;
API_FUNCTION bool CDECL DoesActorHaveStatsDynamic(unsigned int index) NOEXCEPT;
/**
* \brief Set the cell of the temporary actor list stored on the server.
@ -433,7 +331,7 @@ public:
* \param cellDescription The description of the cell.
* \return void
*/
static void SetActorListCell(const char* cellDescription) noexcept;
API_FUNCTION void CDECL SetActorListCell(const char* cellDescription) NOEXCEPT;
/**
* \brief Set the action type of the temporary actor list stored on the server.
@ -441,7 +339,7 @@ public:
* \param action The action type (0 for SET, 1 for ADD, 2 for REMOVE, 3 for REQUEST).
* \return void
*/
static void SetActorListAction(unsigned char action) noexcept;
API_FUNCTION void CDECL SetActorListAction(unsigned char action) NOEXCEPT;
/**
* \brief Set the cell of the temporary actor stored on the server.
@ -455,7 +353,7 @@ public:
* \param cellDescription The description of the cell.
* \return void
*/
static void SetActorCell(const char* cellDescription) noexcept;
API_FUNCTION void CDECL SetActorCell(const char* cellDescription) NOEXCEPT;
/**
* \brief Set the refId of the temporary actor stored on the server.
@ -463,7 +361,7 @@ public:
* \param refId The refId.
* \return void
*/
static void SetActorRefId(const char* refId) noexcept;
API_FUNCTION void CDECL SetActorRefId(const char* refId) NOEXCEPT;
/**
* \brief Set the refNum of the temporary actor stored on the server.
@ -471,7 +369,7 @@ public:
* \param refNum The refNum.
* \return void
*/
static void SetActorRefNum(int refNum) noexcept;
API_FUNCTION void CDECL SetActorRefNum(int refNum) NOEXCEPT;
/**
* \brief Set the mpNum of the temporary actor stored on the server.
@ -479,7 +377,7 @@ public:
* \param mpNum The mpNum.
* \return void
*/
static void SetActorMpNum(int mpNum) noexcept;
API_FUNCTION void CDECL SetActorMpNum(int mpNum) NOEXCEPT;
/**
* \brief Set the position of the temporary actor stored on the server.
@ -489,7 +387,7 @@ public:
* \param z The Z position.
* \return void
*/
static void SetActorPosition(double x, double y, double z) noexcept;
API_FUNCTION void CDECL SetActorPosition(double x, double y, double z) NOEXCEPT;
/**
* \brief Set the rotation of the temporary actor stored on the server.
@ -499,7 +397,7 @@ public:
* \param z The Z rotation.
* \return void
*/
static void SetActorRotation(double x, double y, double z) noexcept;
API_FUNCTION void CDECL SetActorRotation(double x, double y, double z) NOEXCEPT;
/**
* \brief Set the base health of the temporary actor stored on the server.
@ -507,7 +405,7 @@ public:
* \param value The new value.
* \return void
*/
static void SetActorHealthBase(double value) noexcept;
API_FUNCTION void CDECL SetActorHealthBase(double value) NOEXCEPT;
/**
* \brief Set the current health of the temporary actor stored on the server.
@ -515,7 +413,7 @@ public:
* \param value The new value.
* \return void
*/
static void SetActorHealthCurrent(double value) noexcept;
API_FUNCTION void CDECL SetActorHealthCurrent(double value) NOEXCEPT;
/**
* \brief Set the modified health of the temporary actor stored on the server.
@ -523,7 +421,7 @@ public:
* \param value The new value.
* \return void
*/
static void SetActorHealthModified(double value) noexcept;
API_FUNCTION void CDECL SetActorHealthModified(double value) NOEXCEPT;
/**
* \brief Set the base magicka of the temporary actor stored on the server.
@ -531,7 +429,7 @@ public:
* \param value The new value.
* \return void
*/
static void SetActorMagickaBase(double value) noexcept;
API_FUNCTION void CDECL SetActorMagickaBase(double value) NOEXCEPT;
/**
* \brief Set the current magicka of the temporary actor stored on the server.
@ -539,7 +437,7 @@ public:
* \param value The new value.
* \return void
*/
static void SetActorMagickaCurrent(double value) noexcept;
API_FUNCTION void CDECL SetActorMagickaCurrent(double value) NOEXCEPT;
/**
* \brief Set the modified magicka of the temporary actor stored on the server.
@ -547,7 +445,7 @@ public:
* \param value The new value.
* \return void
*/
static void SetActorMagickaModified(double value) noexcept;
API_FUNCTION void CDECL SetActorMagickaModified(double value) NOEXCEPT;
/**
* \brief Set the base fatigue of the temporary actor stored on the server.
@ -555,7 +453,7 @@ public:
* \param value The new value.
* \return void
*/
static void SetActorFatigueBase(double value) noexcept;
API_FUNCTION void CDECL SetActorFatigueBase(double value) NOEXCEPT;
/**
* \brief Set the current fatigue of the temporary actor stored on the server.
@ -563,7 +461,7 @@ public:
* \param value The new value.
* \return void
*/
static void SetActorFatigueCurrent(double value) noexcept;
API_FUNCTION void CDECL SetActorFatigueCurrent(double value) NOEXCEPT;
/**
* \brief Set the modified fatigue of the temporary actor stored on the server.
@ -571,7 +469,7 @@ public:
* \param value The new value.
* \return void
*/
static void SetActorFatigueModified(double value) noexcept;
API_FUNCTION void CDECL SetActorFatigueModified(double value) NOEXCEPT;
/**
* \brief Set the sound of the temporary actor stored on the server.
@ -579,7 +477,7 @@ public:
* \param sound The sound.
* \return void
*/
static void SetActorSound(const char* sound) noexcept;
API_FUNCTION void CDECL SetActorSound(const char* sound) NOEXCEPT;
/**
* \brief Set the AI action of the temporary actor stored on the server.
@ -587,7 +485,7 @@ public:
* \param action The new action.
* \return void
*/
static void SetActorAIAction(unsigned int action) noexcept;
API_FUNCTION void CDECL SetActorAIAction(unsigned int action) NOEXCEPT;
/**
* \brief Set a player as the AI target of the temporary actor stored on the server.
@ -595,7 +493,7 @@ public:
* \param pid The player ID.
* \return void
*/
static void SetActorAITargetToPlayer(unsigned short pid) noexcept;
API_FUNCTION void CDECL SetActorAITargetToPlayer(PlayerId pid) NOEXCEPT;
/**
* \brief Set another object as the AI target of the temporary actor stored on the server.
@ -604,7 +502,7 @@ public:
* \param mpNum The mpNum of the target object.
* \return void
*/
static void SetActorAITargetToObject(int refNum, int mpNum) noexcept;
API_FUNCTION void CDECL SetActorAITargetToObject(int refNum, int mpNum) NOEXCEPT;
/**
* \brief Set the coordinates for the AI package associated with the current AI action.
@ -614,7 +512,7 @@ public:
* \param z The Z coordinate.
* \return void
*/
static void SetActorAICoordinates(double x, double y, double z) noexcept;
API_FUNCTION void CDECL SetActorAICoordinates(double x, double y, double z) NOEXCEPT;
/**
* \brief Set the distance of the AI package associated with the current AI action.
@ -622,7 +520,7 @@ public:
* \param duration The distance of the package.
* \return void
*/
static void SetActorAIDistance(unsigned int distance) noexcept;
API_FUNCTION void CDECL SetActorAIDistance(unsigned int distance) NOEXCEPT;
/**
* \brief Set the duration of the AI package associated with the current AI action.
@ -630,7 +528,7 @@ public:
* \param duration The duration of the package.
* \return void
*/
static void SetActorAIDuration(unsigned int duration) noexcept;
API_FUNCTION void CDECL SetActorAIDuration(unsigned int duration) NOEXCEPT;
/**
* \brief Set whether the current AI package should be repeated.
@ -640,7 +538,7 @@ public:
* \param shouldRepeat Whether the package should be repeated.
* \return void
*/
static void SetActorAIRepetition(bool shouldRepeat) noexcept;
API_FUNCTION void CDECL SetActorAIRepetition(bool shouldRepeat) NOEXCEPT;
/**
* \brief Equip an item in a certain slot of the equipment of the temporary actor stored
@ -653,7 +551,7 @@ public:
* \param enchantmentCharge The enchantment charge of the item.
* \return void
*/
static void EquipActorItem(unsigned short slot, const char* refId, unsigned int count, int charge, double enchantmentCharge = -1) noexcept;
API_FUNCTION void CDECL EquipActorItem(unsigned short slot, const char* refId, unsigned int count, int charge, double enchantmentCharge = -1) NOEXCEPT;
/**
* \brief Unequip the item in a certain slot of the equipment of the temporary actor stored
@ -662,7 +560,7 @@ public:
* \param slot The equipment slot.
* \return void
*/
static void UnequipActorItem(unsigned short slot) noexcept;
API_FUNCTION void CDECL UnequipActorItem(unsigned short slot) NOEXCEPT;
/**
* \brief Add a copy of the server's temporary actor to the server's temporary actor list.
@ -672,7 +570,7 @@ public:
*
* \return void
*/
static void AddActor() noexcept;
API_FUNCTION void CDECL AddActor() NOEXCEPT;
/**
* \brief Send an ActorList packet.
@ -681,7 +579,7 @@ public:
*
* \return void
*/
static void SendActorList() noexcept;
API_FUNCTION void CDECL SendActorList() NOEXCEPT;
/**
* \brief Send an ActorAuthority packet.
@ -693,7 +591,7 @@ public:
*
* \return void
*/
static void SendActorAuthority() noexcept;
API_FUNCTION void CDECL SendActorAuthority() NOEXCEPT;
/**
* \brief Send an ActorPosition packet.
@ -705,7 +603,7 @@ public:
*
* \return void
*/
static void SendActorPosition(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendActorPosition(bool sendToOtherVisitors, bool skipAttachedPlayer) NOEXCEPT;
/**
* \brief Send an ActorStatsDynamic packet.
@ -717,7 +615,7 @@ public:
*
* \return void
*/
static void SendActorStatsDynamic(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendActorStatsDynamic(bool sendToOtherVisitors, bool skipAttachedPlayer) NOEXCEPT;
/**
* \brief Send an ActorEquipment packet.
@ -729,7 +627,7 @@ public:
*
* \return void
*/
static void SendActorEquipment(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendActorEquipment(bool sendToOtherVisitors, bool skipAttachedPlayer) NOEXCEPT;
/**
* \brief Send an ActorSpeech packet.
@ -740,7 +638,7 @@ public:
* to the packet (false by default).
* \return void
*/
static void SendActorSpeech(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendActorSpeech(bool sendToOtherVisitors, bool skipAttachedPlayer) NOEXCEPT;
/**
* \brief Send an ActorAI packet.
@ -751,7 +649,7 @@ public:
* to the packet (false by default).
* \return void
*/
static void SendActorAI(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendActorAI(bool sendToOtherVisitors, bool skipAttachedPlayer) NOEXCEPT;
/**
* \brief Send an ActorCellChange packet.
@ -763,18 +661,18 @@ public:
*
* \return void
*/
static void SendActorCellChange(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendActorCellChange(bool sendToOtherVisitors, bool skipAttachedPlayer) NOEXCEPT;
// All methods below are deprecated versions of methods from above
static void ReadLastActorList() noexcept;
static void InitializeActorList(unsigned short pid) noexcept;
static void CopyLastActorListToStore() noexcept;
static unsigned int GetActorRefNumIndex(unsigned int index) noexcept;
static unsigned int GetActorKillerRefNumIndex(unsigned int index) noexcept;
static void SetActorRefNumIndex(int refNum) noexcept;
};
API_FUNCTION void CDECL ReadLastActorList() NOEXCEPT;
API_FUNCTION void CDECL InitializeActorList(PlayerId pid) NOEXCEPT;
API_FUNCTION void CDECL CopyLastActorListToStore() NOEXCEPT;
API_FUNCTION unsigned int CDECL GetActorRefNumIndex(unsigned int index) NOEXCEPT;
API_FUNCTION unsigned int CDECL GetActorKillerRefNumIndex(unsigned int index) NOEXCEPT;
API_FUNCTION void CDECL SetActorRefNumIndex(int refNum) NOEXCEPT;
NAMESPACE_END()
#endif //OPENMW_ACTORAPI_HPP

@ -1,13 +1,13 @@
#include "Books.hpp"
#include "Books.h"
#include <components/openmw-mp/NetworkMessages.hpp>
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
#include <apps/openmw-mp/Script/Callbacks.hpp>
#include <apps/openmw-mp/Networking.hpp>
using namespace mwmp;
void BookFunctions::ClearBookChanges(unsigned short pid) noexcept
extern "C" void BookFunctions::ClearBookChanges(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -15,7 +15,7 @@ void BookFunctions::ClearBookChanges(unsigned short pid) noexcept
player->bookChanges.books.clear();
}
unsigned int BookFunctions::GetBookChangesSize(unsigned short pid) noexcept
extern "C" unsigned int BookFunctions::GetBookChangesSize(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -23,7 +23,7 @@ unsigned int BookFunctions::GetBookChangesSize(unsigned short pid) noexcept
return player->bookChanges.count;
}
void BookFunctions::AddBook(unsigned short pid, const char* bookId) noexcept
extern "C" void BookFunctions::AddBook(PlayerId pid, const char* bookId) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -34,7 +34,7 @@ void BookFunctions::AddBook(unsigned short pid, const char* bookId) noexcept
player->bookChanges.books.push_back(book);
}
const char *BookFunctions::GetBookId(unsigned short pid, unsigned int index) noexcept
extern "C" const char *BookFunctions::GetBookId(PlayerId pid, unsigned int index) noexcept
{
Player *player;
GET_PLAYER(pid, player, "");
@ -45,7 +45,7 @@ const char *BookFunctions::GetBookId(unsigned short pid, unsigned int index) noe
return player->bookChanges.books.at(index).bookId.c_str();
}
void BookFunctions::SendBookChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
extern "C" void BookFunctions::SendBookChanges(PlayerId pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -62,7 +62,7 @@ void BookFunctions::SendBookChanges(unsigned short pid, bool sendToOtherPlayers,
// All methods below are deprecated versions of methods from above
void BookFunctions::InitializeBookChanges(unsigned short pid) noexcept
extern "C" void BookFunctions::InitializeBookChanges(PlayerId pid) noexcept
{
ClearBookChanges(pid);
}

@ -1,22 +1,9 @@
#ifndef OPENMW_BOOKAPI_HPP
#define OPENMW_BOOKAPI_HPP
#define BOOKAPI \
{"ClearBookChanges", BookFunctions::ClearBookChanges},\
\
{"GetBookChangesSize", BookFunctions::GetBookChangesSize},\
\
{"AddBook", BookFunctions::AddBook},\
\
{"GetBookId", BookFunctions::GetBookId},\
\
{"SendBookChanges", BookFunctions::SendBookChanges},\
\
{"InitializeBookChanges", BookFunctions::InitializeBookChanges}
#include "../api.h"
class BookFunctions
{
public:
NAMESPACE_BEGIN(BookFunctions)
/**
* \brief Clear the last recorded book changes for a player.
@ -26,7 +13,7 @@ public:
* \param pid The player ID whose book changes should be used.
* \return void
*/
static void ClearBookChanges(unsigned short pid) noexcept;
API_FUNCTION void CDECL ClearBookChanges(PlayerId pid) NOEXCEPT;
/**
* \brief Get the number of indexes in a player's latest book changes.
@ -34,7 +21,7 @@ public:
* \param pid The player ID whose book changes should be used.
* \return The number of indexes.
*/
static unsigned int GetBookChangesSize(unsigned short pid) noexcept;
API_FUNCTION unsigned int CDECL GetBookChangesSize(PlayerId pid) NOEXCEPT;
/**
* \brief Add a new book to the book changes for a player.
@ -43,7 +30,7 @@ public:
* \param bookId The bookId of the book.
* \return void
*/
static void AddBook(unsigned short pid, const char* bookId) noexcept;
API_FUNCTION void CDECL AddBook(PlayerId pid, const char* bookId) NOEXCEPT;
/**
* \brief Get the bookId at a certain index in a player's latest book changes.
@ -52,7 +39,7 @@ public:
* \param index The index of the book.
* \return The bookId.
*/
static const char *GetBookId(unsigned short pid, unsigned int index) noexcept;
API_FUNCTION const char *CDECL GetBookId(PlayerId pid, unsigned int index) NOEXCEPT;
/**
* \brief Send a PlayerBook packet with a player's recorded book changes.
@ -64,12 +51,11 @@ public:
* to the packet (false by default).
* \return void
*/
static void SendBookChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendBookChanges(PlayerId pid, bool sendToOtherPlayers, bool skipAttachedPlayer) NOEXCEPT;
// All methods below are deprecated versions of methods from above
static void InitializeBookChanges(unsigned short pid) noexcept;
};
API_FUNCTION void CDECL InitializeBookChanges(PlayerId pid) NOEXCEPT;
NAMESPACE_END()
#endif //OPENMW_BOOKAPI_HPP

@ -1,9 +1,9 @@
#include "Cells.hpp"
#include "Cells.h"
#include <components/openmw-mp/Log.hpp>
#include <components/openmw-mp/NetworkMessages.hpp>
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
#include <apps/openmw-mp/Script/Callbacks.hpp>
#include <apps/openmw-mp/Player.hpp>
#include <apps/openmw-mp/Networking.hpp>
@ -12,7 +12,7 @@ using namespace std;
static std::string tempCellDescription;
unsigned int CellFunctions::GetCellStateChangesSize(unsigned short pid) noexcept
extern "C" unsigned int CellFunctions::GetCellStateChangesSize(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -20,7 +20,7 @@ unsigned int CellFunctions::GetCellStateChangesSize(unsigned short pid) noexcept
return player->cellStateChanges.count;
}
unsigned int CellFunctions::GetCellStateType(unsigned short pid, unsigned int index) noexcept
extern "C" unsigned int CellFunctions::GetCellStateType(PlayerId pid, unsigned int index) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -28,7 +28,7 @@ unsigned int CellFunctions::GetCellStateType(unsigned short pid, unsigned int in
return player->cellStateChanges.cellStates.at(index).type;
}
const char *CellFunctions::GetCellStateDescription(unsigned short pid, unsigned int index) noexcept
extern "C" const char *CellFunctions::GetCellStateDescription(PlayerId pid, unsigned int index) noexcept
{
Player *player;
GET_PLAYER(pid, player, "");
@ -40,30 +40,30 @@ const char *CellFunctions::GetCellStateDescription(unsigned short pid, unsigned
return tempCellDescription.c_str();
}
const char *CellFunctions::GetCell(unsigned short pid) noexcept
extern "C" const char *CellFunctions::GetCell(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
tempCellDescription = player->cell.getDescription().c_str();
tempCellDescription = player->cell.getDescription();
return tempCellDescription.c_str();
}
int CellFunctions::GetExteriorX(unsigned short pid) noexcept
extern "C" int CellFunctions::GetExteriorX(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
return player->cell.mData.mX;
}
int CellFunctions::GetExteriorY(unsigned short pid) noexcept
extern "C" int CellFunctions::GetExteriorY(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
return player->cell.mData.mY;
}
bool CellFunctions::IsInExterior(unsigned short pid) noexcept
extern "C" bool CellFunctions::IsInExterior(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, false);
@ -71,7 +71,7 @@ bool CellFunctions::IsInExterior(unsigned short pid) noexcept
return player->cell.isExterior();
}
const char *CellFunctions::GetRegion(unsigned short pid) noexcept
extern "C" const char *CellFunctions::GetRegion(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -79,7 +79,7 @@ const char *CellFunctions::GetRegion(unsigned short pid) noexcept
return player->cell.mRegion.c_str();
}
bool CellFunctions::IsChangingRegion(unsigned short pid) noexcept
extern "C" bool CellFunctions::IsChangingRegion(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, false);
@ -87,7 +87,7 @@ bool CellFunctions::IsChangingRegion(unsigned short pid) noexcept
return player->isChangingRegion;
}
void CellFunctions::SetCell(unsigned short pid, const char *cellDescription) noexcept
extern "C" void CellFunctions::SetCell(PlayerId pid, const char *cellDescription) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -98,7 +98,7 @@ void CellFunctions::SetCell(unsigned short pid, const char *cellDescription) noe
player->cell = Utils::getCellFromDescription(cellDescription);
}
void CellFunctions::SetExteriorCell(unsigned short pid, int x, int y) noexcept
extern "C" void CellFunctions::SetExteriorCell(PlayerId pid, int x, int y) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -115,7 +115,7 @@ void CellFunctions::SetExteriorCell(unsigned short pid, int x, int y) noexcept
player->cell.mData.mY = y;
}
void CellFunctions::SendCell(unsigned short pid) noexcept
extern "C" void CellFunctions::SendCell(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );

@ -1,39 +1,16 @@
#ifndef OPENMW_CELLAPI_HPP
#define OPENMW_CELLAPI_HPP
#include "../Types.hpp"
#define CELLAPI \
{"GetCellStateChangesSize", CellFunctions::GetCellStateChangesSize},\
\
{"GetCellStateType", CellFunctions::GetCellStateType},\
{"GetCellStateDescription", CellFunctions::GetCellStateDescription},\
\
{"GetCell", CellFunctions::GetCell},\
{"GetExteriorX", CellFunctions::GetExteriorX},\
{"GetExteriorY", CellFunctions::GetExteriorY},\
{"IsInExterior", CellFunctions::IsInExterior},\
\
{"GetRegion", CellFunctions::GetRegion},\
{"IsChangingRegion", CellFunctions::IsChangingRegion},\
\
{"SetCell", CellFunctions::SetCell},\
{"SetExteriorCell", CellFunctions::SetExteriorCell},\
\
{"SendCell", CellFunctions::SendCell}
class CellFunctions
{
public:
#include "../api.h"
NAMESPACE_BEGIN(CellFunctions)
/**
* \brief Get the number of indexes in a player's latest cell state changes.
*
* \param pid The player ID whose cell state changes should be used.
* \return The number of indexes.
*/
static unsigned int GetCellStateChangesSize(unsigned short pid) noexcept;
API_FUNCTION unsigned int CDECL GetCellStateChangesSize(PlayerId pid) NOEXCEPT;
/**
* \brief Get the cell state type at a certain index in a player's latest cell state changes.
@ -42,7 +19,7 @@ public:
* \param index The index of the cell state.
* \return The cell state type (0 for LOAD, 1 for UNLOAD).
*/
static unsigned int GetCellStateType(unsigned short pid, unsigned int index) noexcept;
API_FUNCTION unsigned int CDECL GetCellStateType(PlayerId pid, unsigned int index) NOEXCEPT;
/**
* \brief Get the cell description at a certain index in a player's latest cell state changes.
@ -51,7 +28,7 @@ public:
* \param index The index of the cell state.
* \return The cell description.
*/
static const char *GetCellStateDescription(unsigned short pid, unsigned int index) noexcept;
API_FUNCTION const char *CDECL GetCellStateDescription(PlayerId pid, unsigned int index) NOEXCEPT;
/**
* \brief Get the cell description of a player's cell.
@ -59,7 +36,7 @@ public:
* \param pid The player ID.
* \return The cell description.
*/
static const char *GetCell(unsigned short pid) noexcept;
API_FUNCTION const char *CDECL GetCell(PlayerId pid) NOEXCEPT;
/**
* \brief Get the X coordinate of the player's exterior cell.
@ -67,7 +44,7 @@ public:
* \param pid The player ID.
* \return The X coordinate of the cell.
*/
static int GetExteriorX(unsigned short pid) noexcept;
API_FUNCTION int CDECL GetExteriorX(PlayerId pid) NOEXCEPT;
/**
* \brief Get the Y coordinate of the player's exterior cell.
@ -75,7 +52,7 @@ public:
* \param pid The player ID.
* \return The Y coordinate of the cell.
*/
static int GetExteriorY(unsigned short pid) noexcept;
API_FUNCTION int CDECL GetExteriorY(PlayerId pid) NOEXCEPT;
/**
* \brief Check whether the player is in an exterior cell or not.
@ -83,7 +60,7 @@ public:
* \param pid The player ID.
* \return Whether the player is in an exterior cell.
*/
static bool IsInExterior(unsigned short pid) noexcept;
API_FUNCTION bool CDECL IsInExterior(PlayerId pid) NOEXCEPT;
/**
* \brief Get the region of the player's exterior cell.
@ -93,7 +70,7 @@ public:
* \param pid The player ID.
* \return The region.
*/
static const char *GetRegion(unsigned short pid) noexcept;
API_FUNCTION const char *CDECL GetRegion(PlayerId pid) NOEXCEPT;
/**
* \brief Check whether the player's last cell change has involved a region change.
@ -101,7 +78,7 @@ public:
* \param pid The player ID.
* \return Whether the player has changed their region.
*/
static bool IsChangingRegion(unsigned short pid) noexcept;
API_FUNCTION bool CDECL IsChangingRegion(PlayerId pid) NOEXCEPT;
/**
* \brief Set the cell of a player.
@ -116,7 +93,7 @@ public:
* \param cellDescription The cell description.
* \return void
*/
static void SetCell(unsigned short pid, const char *cellDescription) noexcept;
API_FUNCTION void CDECL SetCell(PlayerId pid, const char *cellDescription) NOEXCEPT;
/**
* \brief Set the cell of a player to an exterior cell.
@ -129,7 +106,7 @@ public:
* \param y The Y coordinate of the cell.
* \return void
*/
static void SetExteriorCell(unsigned short pid, int x, int y) noexcept;
API_FUNCTION void CDECL SetExteriorCell(PlayerId pid, int x, int y) NOEXCEPT;
/**
* \brief Send a PlayerCellChange packet about a player.
@ -139,8 +116,7 @@ public:
* \param pid The player ID.
* \return void
*/
static void SendCell(unsigned short pid) noexcept;
};
API_FUNCTION void CDECL SendCell(PlayerId pid) NOEXCEPT;
NAMESPACE_END()
#endif //OPENMW_CELLAPI_HPP

@ -2,17 +2,17 @@
// Created by koncord on 29.08.16.
//
#include "CharClass.hpp"
#include "CharClass.h"
#include <components/openmw-mp/NetworkMessages.hpp>
#include <apps/openmw-mp/Networking.hpp>
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
#include <apps/openmw-mp/Script/Callbacks.hpp>
using namespace std;
using namespace ESM;
const char *CharClassFunctions::GetDefaultClass(unsigned short pid) noexcept
extern "C" const char *CharClassFunctions::GetDefaultClass(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, "");
@ -20,7 +20,7 @@ const char *CharClassFunctions::GetDefaultClass(unsigned short pid) noexcept
return player->charClass.mId.c_str();
}
const char *CharClassFunctions::GetClassName(unsigned short pid) noexcept
extern "C" const char *CharClassFunctions::GetClassName(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, "");
@ -28,7 +28,7 @@ const char *CharClassFunctions::GetClassName(unsigned short pid) noexcept
return player->charClass.mName.c_str();
}
const char *CharClassFunctions::GetClassDesc(unsigned short pid) noexcept
extern "C" const char *CharClassFunctions::GetClassDesc(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, "");
@ -36,7 +36,7 @@ const char *CharClassFunctions::GetClassDesc(unsigned short pid) noexcept
return player->charClass.mDescription.c_str();
}
int CharClassFunctions::GetClassMajorAttribute(unsigned short pid, unsigned char slot) noexcept
extern "C" int CharClassFunctions::GetClassMajorAttribute(PlayerId pid, unsigned char slot) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -47,7 +47,7 @@ int CharClassFunctions::GetClassMajorAttribute(unsigned short pid, unsigned char
return player->charClass.mData.mAttribute[slot];
}
int CharClassFunctions::GetClassSpecialization(unsigned short pid) noexcept
extern "C" int CharClassFunctions::GetClassSpecialization(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -55,7 +55,7 @@ int CharClassFunctions::GetClassSpecialization(unsigned short pid) noexcept
return player->charClass.mData.mSpecialization;
}
int CharClassFunctions::GetClassMajorSkill(unsigned short pid, unsigned char slot) noexcept
extern "C" int CharClassFunctions::GetClassMajorSkill(PlayerId pid, unsigned char slot) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -66,7 +66,7 @@ int CharClassFunctions::GetClassMajorSkill(unsigned short pid, unsigned char slo
return player->charClass.mData.mSkills[slot][1];
}
int CharClassFunctions::GetClassMinorSkill(unsigned short pid, unsigned char slot) noexcept
extern "C" int CharClassFunctions::GetClassMinorSkill(PlayerId pid, unsigned char slot) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -77,7 +77,7 @@ int CharClassFunctions::GetClassMinorSkill(unsigned short pid, unsigned char slo
return player->charClass.mData.mSkills[slot][0];
}
int CharClassFunctions::IsClassDefault(unsigned short pid) noexcept
extern "C" int CharClassFunctions::IsClassDefault(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -85,29 +85,32 @@ int CharClassFunctions::IsClassDefault(unsigned short pid) noexcept
return !player->charClass.mId.empty(); // true if default
}
void CharClassFunctions::SetDefaultClass(unsigned short pid, const char *id) noexcept
extern "C" void CharClassFunctions::SetDefaultClass(PlayerId pid, const char *id) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
player->charClass.mId = id;
}
void CharClassFunctions::SetClassName(unsigned short pid, const char *name) noexcept
extern "C" void CharClassFunctions::SetClassName(PlayerId pid, const char *name) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
player->charClass.mName = name;
player->charClass.mId = "";
player->charClass.mId.clear();
}
void CharClassFunctions::SetClassDesc(unsigned short pid, const char *desc) noexcept
extern "C" void CharClassFunctions::SetClassDesc(PlayerId pid, const char *desc) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
player->charClass.mDescription = desc;
}
void CharClassFunctions::SetClassMajorAttribute(unsigned short pid, unsigned char slot, int attrId) noexcept
extern "C" void CharClassFunctions::SetClassMajorAttribute(PlayerId pid, unsigned char slot, int attrId) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -118,14 +121,16 @@ void CharClassFunctions::SetClassMajorAttribute(unsigned short pid, unsigned cha
player->charClass.mData.mAttribute[slot] = attrId;
}
void CharClassFunctions::SetClassSpecialization(unsigned short pid, int spec) noexcept
extern "C" void CharClassFunctions::SetClassSpecialization(PlayerId pid, int spec) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
player->charClass.mData.mSpecialization = spec;
}
void CharClassFunctions::SetClassMajorSkill(unsigned short pid, unsigned char slot, int skillId) noexcept
extern "C" void CharClassFunctions::SetClassMajorSkill(PlayerId pid, unsigned char slot, int skillId) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -135,7 +140,8 @@ void CharClassFunctions::SetClassMajorSkill(unsigned short pid, unsigned char sl
player->charClass.mData.mSkills[slot][1] = skillId;
}
void CharClassFunctions::SetClassMinorSkill(unsigned short pid, unsigned char slot, int skillId) noexcept
extern "C" void CharClassFunctions::SetClassMinorSkill(PlayerId pid, unsigned char slot, int skillId) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -146,7 +152,7 @@ void CharClassFunctions::SetClassMinorSkill(unsigned short pid, unsigned char sl
player->charClass.mData.mSkills[slot][0] = skillId;
}
void CharClassFunctions::SendClass(unsigned short pid) noexcept
extern "C" void CharClassFunctions::SendClass(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );

@ -5,40 +5,16 @@
#ifndef OPENMW_CHARCLASSAPI_HPP
#define OPENMW_CHARCLASSAPI_HPP
#include "../Types.hpp"
#define CHARCLASSAPI \
{"GetDefaultClass", CharClassFunctions::GetDefaultClass},\
{"GetClassName", CharClassFunctions::GetClassName},\
{"GetClassDesc", CharClassFunctions::GetClassDesc},\
{"GetClassMajorAttribute", CharClassFunctions::GetClassMajorAttribute},\
{"GetClassSpecialization", CharClassFunctions::GetClassSpecialization},\
{"GetClassMajorSkill", CharClassFunctions::GetClassMajorSkill},\
{"GetClassMinorSkill", CharClassFunctions::GetClassMinorSkill},\
{"IsClassDefault", CharClassFunctions::IsClassDefault},\
\
{"SetDefaultClass", CharClassFunctions::SetDefaultClass},\
{"SetClassName", CharClassFunctions::SetClassName},\
{"SetClassDesc", CharClassFunctions::SetClassDesc},\
{"SetClassMajorAttribute", CharClassFunctions::SetClassMajorAttribute},\
{"SetClassSpecialization", CharClassFunctions::SetClassSpecialization},\
{"SetClassMajorSkill", CharClassFunctions::SetClassMajorSkill},\
{"SetClassMinorSkill", CharClassFunctions::SetClassMinorSkill},\
\
{"SendClass", CharClassFunctions::SendClass}
class CharClassFunctions
{
public:
#include "../api.h"
NAMESPACE_BEGIN(CharClassFunctions)
/**
* \brief Get the default class used by a player.
*
* \param pid The player ID.
* \return The ID of the default class.
*/
static const char *GetDefaultClass(unsigned short pid) noexcept;
API_FUNCTION const char *CDECL GetDefaultClass(PlayerId pid) NOEXCEPT;
/**
* \brief Get the name of the custom class used by a player.
@ -46,7 +22,7 @@ public:
* \param pid The player ID.
* \return The name of the custom class.
*/
static const char *GetClassName(unsigned short pid) noexcept;
API_FUNCTION const char *CDECL GetClassName(PlayerId pid) NOEXCEPT;
/**
* \brief Get the description of the custom class used by a player.
@ -54,7 +30,7 @@ public:
* \param pid The player ID.
* \return The description of the custom class.
*/
static const char *GetClassDesc(unsigned short pid) noexcept;
API_FUNCTION const char *CDECL GetClassDesc(PlayerId pid) NOEXCEPT;
/**
* \brief Get the ID of one of the two major attributes of a custom class used by a player.
@ -63,7 +39,7 @@ public:
* \param slot The slot of the major attribute (0 or 1).
* \return The ID of the major attribute.
*/
static int GetClassMajorAttribute(unsigned short pid, unsigned char slot) noexcept;
API_FUNCTION int CDECL GetClassMajorAttribute(PlayerId pid, unsigned char slot) NOEXCEPT;
/**
* \brief Get the specialization ID of the custom class used by a player.
@ -71,7 +47,7 @@ public:
* \param pid The player ID.
* \return The specialization ID of the custom class (0 for Combat, 1 for Magic, 2 for Stealth).
*/
static int GetClassSpecialization(unsigned short pid) noexcept;
API_FUNCTION int CDECL GetClassSpecialization(PlayerId pid) NOEXCEPT;
/**
* \brief Get the ID of one of the five major skills of a custom class used by a player.
@ -80,7 +56,7 @@ public:
* \param slot The slot of the major skill (0 to 4).
* \return The ID of the major skill.
*/
static int GetClassMajorSkill(unsigned short pid, unsigned char slot) noexcept;
API_FUNCTION int CDECL GetClassMajorSkill(PlayerId pid, unsigned char slot) NOEXCEPT;
/**
* \brief Get the ID of one of the five minor skills of a custom class used by a player.
@ -89,7 +65,7 @@ public:
* \param slot The slot of the minor skill (0 to 4).
* \return The ID of the minor skill.
*/
static int GetClassMinorSkill(unsigned short pid, unsigned char slot) noexcept;
API_FUNCTION int CDECL GetClassMinorSkill(PlayerId pid, unsigned char slot) NOEXCEPT;
/**
* \brief Check whether the player is using a default class instead of a custom one.
@ -97,7 +73,7 @@ public:
* \param pid The player ID.
* \return Whether the player is using a default class.
*/
static int IsClassDefault(unsigned short pid) noexcept;
API_FUNCTION int CDECL IsClassDefault(PlayerId pid) NOEXCEPT;
/**
* \brief Set the default class used by a player.
@ -108,7 +84,7 @@ public:
* \param id The ID of the default class.
* \return void
*/
static void SetDefaultClass(unsigned short pid, const char *id) noexcept;
API_FUNCTION void CDECL SetDefaultClass(PlayerId pid, const char *id) NOEXCEPT;
/**
* \brief Set the name of the custom class used by a player.
@ -117,7 +93,7 @@ public:
* \param name The name of the custom class.
* \return void
*/
static void SetClassName(unsigned short pid, const char *name) noexcept;
API_FUNCTION void CDECL SetClassName(PlayerId pid, const char *name) NOEXCEPT;
/**
* \brief Set the description of the custom class used by a player.
@ -126,7 +102,7 @@ public:
* \param desc The description of the custom class.
* \return void
*/
static void SetClassDesc(unsigned short pid, const char *desc) noexcept;
API_FUNCTION void CDECL SetClassDesc(PlayerId pid, const char *desc) NOEXCEPT;
/**
* \brief Set the ID of one of the two major attributes of the custom class used by a player.
@ -136,7 +112,7 @@ public:
* \param attrId The ID to use for the attribute.
* \return void
*/
static void SetClassMajorAttribute(unsigned short pid, unsigned char slot, int attrId) noexcept;
API_FUNCTION void CDECL SetClassMajorAttribute(PlayerId pid, unsigned char slot, int attrId) NOEXCEPT;
/**
* \brief Set the specialization of the custom class used by a player.
@ -145,7 +121,7 @@ public:
* \param spec The specialization ID to use (0 for Combat, 1 for Magic, 2 for Stealth).
* \return void
*/
static void SetClassSpecialization(unsigned short pid, int spec) noexcept;
API_FUNCTION void CDECL SetClassSpecialization(PlayerId pid, int spec) NOEXCEPT;
/**
* \brief Set the ID of one of the five major skills of the custom class used by a player.
@ -155,7 +131,7 @@ public:
* \param skillId The ID to use for the skill.
* \return void
*/
static void SetClassMajorSkill(unsigned short pid, unsigned char slot, int skillId) noexcept;
API_FUNCTION void CDECL SetClassMajorSkill(PlayerId pid, unsigned char slot, int skillId) NOEXCEPT;
/**
* \brief Set the ID of one of the five minor skills of the custom class used by a player.
@ -165,7 +141,7 @@ public:
* \param skillId The ID to use for the skill.
* \return void
*/
static void SetClassMinorSkill(unsigned short pid, unsigned char slot, int skillId) noexcept;
API_FUNCTION void CDECL SetClassMinorSkill(PlayerId pid, unsigned char slot, int skillId) NOEXCEPT;
/**
* \brief Send a PlayerCharClass packet about a player.
@ -175,7 +151,7 @@ public:
* \param pid The player ID.
* \return void
*/
static void SendClass(unsigned short pid) noexcept;
};
API_FUNCTION void CDECL SendClass(PlayerId pid) NOEXCEPT;
NAMESPACE_END()
#endif //OPENMW_CHARCLASSAPI_HPP

@ -1,12 +1,12 @@
#include "Chat.hpp"
#include "Chat.h"
#include <components/openmw-mp/NetworkMessages.hpp>
#include <components/openmw-mp/Log.hpp>
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
#include <apps/openmw-mp/Script/Callbacks.hpp>
#include <apps/openmw-mp/Networking.hpp>
void ChatFunctions::SendMessage(unsigned short pid, const char *message, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
extern "C" void ChatFunctions::SendMessage(PlayerId pid, const char *message, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -24,7 +24,7 @@ void ChatFunctions::SendMessage(unsigned short pid, const char *message, bool se
packet->Send(true);
}
void ChatFunctions::CleanChatForPid(unsigned short pid)
extern "C" void ChatFunctions::CleanChatForPid(PlayerId pid)
{
Player *player;
GET_PLAYER(pid, player,);
@ -37,7 +37,7 @@ void ChatFunctions::CleanChatForPid(unsigned short pid)
packet->Send(false);
}
void ChatFunctions::CleanChat()
extern "C" void ChatFunctions::CleanChat()
{
for (auto player : *Players::getPlayers())
{

@ -1,17 +1,9 @@
#ifndef OPENMW_CHATAPI_HPP
#define OPENMW_CHATAPI_HPP
#include "../Types.hpp"
#define CHATAPI \
{"SendMessage", ChatFunctions::SendMessage},\
{"CleanChatForPid", ChatFunctions::CleanChat},\
{"CleanChat", ChatFunctions::CleanChatForPid}
class ChatFunctions
{
public:
#include "../api.h"
NAMESPACE_BEGIN(ChatFunctions)
/**
* \brief Send a message to a certain player.
*
@ -23,7 +15,7 @@ public:
* to the packet (false by default).
* \return void
*/
static void SendMessage(unsigned short pid, const char *message, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendMessage(PlayerId pid, const char *message, bool sendToOtherPlayers, bool skipAttachedPlayer) NOEXCEPT;
/**
* \brief Remove all messages from chat for a certain player.
@ -31,14 +23,14 @@ public:
* \param pid The player ID.
* \return void
*/
static void CleanChatForPid(unsigned short pid);
API_FUNCTION void CDECL CleanChatForPid(PlayerId pid);
/**
* \brief Remove all messages from chat for everyone on the server.
*
* \return void
*/
static void CleanChat();
};
API_FUNCTION void CDECL CleanChat();
NAMESPACE_END()
#endif //OPENMW_CHATAPI_HPP

@ -1,13 +1,13 @@
#include "Dialogue.hpp"
#include "Dialogue.h"
#include <components/openmw-mp/NetworkMessages.hpp>
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
#include <apps/openmw-mp/Script/Callbacks.hpp>
#include <apps/openmw-mp/Networking.hpp>
using namespace mwmp;
void DialogueFunctions::ClearTopicChanges(unsigned short pid) noexcept
extern "C" void DialogueFunctions::ClearTopicChanges(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -15,7 +15,7 @@ void DialogueFunctions::ClearTopicChanges(unsigned short pid) noexcept
player->topicChanges.topics.clear();
}
unsigned int DialogueFunctions::GetTopicChangesSize(unsigned short pid) noexcept
extern "C" unsigned int DialogueFunctions::GetTopicChangesSize(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -23,7 +23,7 @@ unsigned int DialogueFunctions::GetTopicChangesSize(unsigned short pid) noexcept
return player->topicChanges.count;
}
void DialogueFunctions::AddTopic(unsigned short pid, const char* topicId) noexcept
extern "C" void DialogueFunctions::AddTopic(PlayerId pid, const char* topicId) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -34,7 +34,7 @@ void DialogueFunctions::AddTopic(unsigned short pid, const char* topicId) noexce
player->topicChanges.topics.push_back(topic);
}
const char *DialogueFunctions::GetTopicId(unsigned short pid, unsigned int index) noexcept
extern "C" const char *DialogueFunctions::GetTopicId(PlayerId pid, unsigned int index) noexcept
{
Player *player;
GET_PLAYER(pid, player, "");
@ -45,7 +45,7 @@ const char *DialogueFunctions::GetTopicId(unsigned short pid, unsigned int index
return player->topicChanges.topics.at(index).topicId.c_str();
}
void DialogueFunctions::SendTopicChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
extern "C" void DialogueFunctions::SendTopicChanges(PlayerId pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -59,7 +59,7 @@ void DialogueFunctions::SendTopicChanges(unsigned short pid, bool sendToOtherPla
packet->Send(true);
}
void DialogueFunctions::PlayAnimation(unsigned short pid, const char* groupname, int mode, int count, bool persist) noexcept
extern "C" void DialogueFunctions::PlayAnimation(PlayerId pid, const char* groupname, int mode, int count, bool persist) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -76,7 +76,7 @@ void DialogueFunctions::PlayAnimation(unsigned short pid, const char* groupname,
player->sendToLoaded(packet);
}
void DialogueFunctions::PlaySpeech(unsigned short pid, const char* sound) noexcept
extern "C" void DialogueFunctions::PlaySpeech(PlayerId pid, const char* sound) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -90,9 +90,9 @@ void DialogueFunctions::PlaySpeech(unsigned short pid, const char* sound) noexce
player->sendToLoaded(packet);
}
// All methods below are deprecated versions of methods from above
extern "C" // All methods below are deprecated versions of methods from above
void DialogueFunctions::InitializeTopicChanges(unsigned short pid) noexcept
void DialogueFunctions::InitializeTopicChanges(PlayerId pid) noexcept
{
ClearTopicChanges(pid);
}

@ -1,26 +1,9 @@
#ifndef OPENMW_DIALOGUEAPI_HPP
#define OPENMW_DIALOGUEAPI_HPP
#define DIALOGUEAPI \
{"ClearTopicChanges", DialogueFunctions::ClearTopicChanges},\
\
{"GetTopicChangesSize", DialogueFunctions::GetTopicChangesSize},\
\
{"AddTopic", DialogueFunctions::AddTopic},\
\
{"GetTopicId", DialogueFunctions::GetTopicId},\
\
{"SendTopicChanges", DialogueFunctions::SendTopicChanges},\
\
{"PlayAnimation", DialogueFunctions::PlayAnimation},\
{"PlaySpeech", DialogueFunctions::PlaySpeech},\
\
{"InitializeTopicChanges", DialogueFunctions::InitializeTopicChanges}
class DialogueFunctions
{
public:
#include "../api.h"
NAMESPACE_BEGIN(DialogueFunctions)
/**
* \brief Clear the last recorded topic changes for a player.
*
@ -29,7 +12,7 @@ public:
* \param pid The player ID whose topic changes should be used.
* \return void
*/
static void ClearTopicChanges(unsigned short pid) noexcept;
API_FUNCTION void CDECL ClearTopicChanges(PlayerId pid) NOEXCEPT;
/**
* \brief Get the number of indexes in a player's latest topic changes.
@ -37,7 +20,7 @@ public:
* \param pid The player ID whose topic changes should be used.
* \return The number of indexes.
*/
static unsigned int GetTopicChangesSize(unsigned short pid) noexcept;
API_FUNCTION unsigned int CDECL GetTopicChangesSize(PlayerId pid) NOEXCEPT;
/**
* \brief Add a new topic to the topic changes for a player.
@ -46,7 +29,7 @@ public:
* \param topicId The topicId of the topic.
* \return void
*/
static void AddTopic(unsigned short pid, const char* topicId) noexcept;
API_FUNCTION void CDECL AddTopic(PlayerId pid, const char* topicId) NOEXCEPT;
/**
* \brief Get the topicId at a certain index in a player's latest topic changes.
@ -55,7 +38,7 @@ public:
* \param index The index of the topic.
* \return The topicId.
*/
static const char *GetTopicId(unsigned short pid, unsigned int index) noexcept;
API_FUNCTION const char *CDECL GetTopicId(PlayerId pid, unsigned int index) NOEXCEPT;
/**
* \brief Send a PlayerTopic packet with a player's recorded topic changes.
@ -67,7 +50,7 @@ public:
* to the packet (false by default).
* \return void
*/
static void SendTopicChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendTopicChanges(PlayerId pid, bool sendToOtherPlayers, bool skipAttachedPlayer) NOEXCEPT;
/**
* \brief Play a certain animation on a player's character by sending a PlayerAnimation
@ -80,7 +63,7 @@ public:
* \param bool Whether the animation should persist or not.
* \return void
*/
static void PlayAnimation(unsigned short pid, const char* groupname, int mode, int count, bool persist) noexcept;
API_FUNCTION void CDECL PlayAnimation(PlayerId pid, const char* groupname, int mode, int count, bool persist) NOEXCEPT;
/**
* \brief Play a certain sound for a player as spoken by their character by sending
@ -90,12 +73,11 @@ public:
* \param sound The path of the sound file.
* \return void
*/
static void PlaySpeech(unsigned short pid, const char* sound) noexcept;
API_FUNCTION void CDECL PlaySpeech(PlayerId pid, const char* sound) NOEXCEPT;
// All methods below are deprecated versions of methods from above
static void InitializeTopicChanges(unsigned short pid) noexcept;
};
API_FUNCTION void CDECL InitializeTopicChanges(PlayerId pid) NOEXCEPT;
NAMESPACE_END()
#endif //OPENMW_DIALOGUEAPI_HPP

@ -1,9 +1,9 @@
#include "Factions.hpp"
#include "Factions.h"
#include <components/misc/stringops.hpp>
#include <components/openmw-mp/NetworkMessages.hpp>
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
#include <apps/openmw-mp/Script/Callbacks.hpp>
#include <apps/openmw-mp/Networking.hpp>
using namespace mwmp;
@ -11,7 +11,7 @@ using namespace mwmp;
Faction tempFaction;
const Faction emptyFaction = {};
void FactionFunctions::ClearFactionChanges(unsigned short pid) noexcept
extern "C" void FactionFunctions::ClearFactionChanges(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -19,7 +19,7 @@ void FactionFunctions::ClearFactionChanges(unsigned short pid) noexcept
player->factionChanges.factions.clear();
}
unsigned int FactionFunctions::GetFactionChangesSize(unsigned short pid) noexcept
extern "C" unsigned int FactionFunctions::GetFactionChangesSize(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -27,7 +27,7 @@ unsigned int FactionFunctions::GetFactionChangesSize(unsigned short pid) noexcep
return player->factionChanges.count;
}
unsigned char FactionFunctions::GetFactionChangesAction(unsigned short pid) noexcept
extern "C" unsigned char FactionFunctions::GetFactionChangesAction(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -35,7 +35,7 @@ unsigned char FactionFunctions::GetFactionChangesAction(unsigned short pid) noex
return player->factionChanges.action;
}
const char *FactionFunctions::GetFactionId(unsigned short pid, unsigned int index) noexcept
extern "C" const char *FactionFunctions::GetFactionId(PlayerId pid, unsigned int index) noexcept
{
Player *player;
GET_PLAYER(pid, player, "");
@ -46,7 +46,7 @@ const char *FactionFunctions::GetFactionId(unsigned short pid, unsigned int inde
return player->factionChanges.factions.at(index).factionId.c_str();
}
int FactionFunctions::GetFactionRank(unsigned short pid, unsigned int index) noexcept
extern "C" int FactionFunctions::GetFactionRank(PlayerId pid, unsigned int index) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -54,7 +54,7 @@ int FactionFunctions::GetFactionRank(unsigned short pid, unsigned int index) noe
return player->factionChanges.factions.at(index).rank;
}
bool FactionFunctions::GetFactionExpulsionState(unsigned short pid, unsigned int index) noexcept
extern "C" bool FactionFunctions::GetFactionExpulsionState(PlayerId pid, unsigned int index) noexcept
{
Player *player;
GET_PLAYER(pid, player, false);
@ -62,7 +62,7 @@ bool FactionFunctions::GetFactionExpulsionState(unsigned short pid, unsigned int
return player->factionChanges.factions.at(index).isExpelled;
}
int FactionFunctions::GetFactionReputation(unsigned short pid, unsigned int index) noexcept
extern "C" int FactionFunctions::GetFactionReputation(PlayerId pid, unsigned int index) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -70,7 +70,7 @@ int FactionFunctions::GetFactionReputation(unsigned short pid, unsigned int inde
return player->factionChanges.factions.at(index).reputation;
}
void FactionFunctions::SetFactionChangesAction(unsigned short pid, unsigned char action) noexcept
extern "C" void FactionFunctions::SetFactionChangesAction(PlayerId pid, unsigned char action) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -78,27 +78,27 @@ void FactionFunctions::SetFactionChangesAction(unsigned short pid, unsigned char
player->factionChanges.action = action;
}
void FactionFunctions::SetFactionId(const char* factionId) noexcept
extern "C" void FactionFunctions::SetFactionId(const char* factionId) noexcept
{
tempFaction.factionId = factionId;
}
void FactionFunctions::SetFactionRank(unsigned int rank) noexcept
extern "C" void FactionFunctions::SetFactionRank(unsigned int rank) noexcept
{
tempFaction.rank = rank;
}
void FactionFunctions::SetFactionExpulsionState(bool expulsionState) noexcept
extern "C" void FactionFunctions::SetFactionExpulsionState(bool expulsionState) noexcept
{
tempFaction.isExpelled = expulsionState;
}
void FactionFunctions::SetFactionReputation(int reputation) noexcept
extern "C" void FactionFunctions::SetFactionReputation(int reputation) noexcept
{
tempFaction.reputation = reputation;
}
void FactionFunctions::AddFaction(unsigned short pid) noexcept
extern "C" void FactionFunctions::AddFaction(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -108,7 +108,7 @@ void FactionFunctions::AddFaction(unsigned short pid) noexcept
tempFaction = emptyFaction;
}
void FactionFunctions::SendFactionChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
extern "C" void FactionFunctions::SendFactionChanges(PlayerId pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -122,9 +122,9 @@ void FactionFunctions::SendFactionChanges(unsigned short pid, bool sendToOtherPl
packet->Send(true);
}
// All methods below are deprecated versions of methods from above
extern "C" // All methods below are deprecated versions of methods from above
void FactionFunctions::InitializeFactionChanges(unsigned short pid) noexcept
void FactionFunctions::InitializeFactionChanges(PlayerId pid) noexcept
{
ClearFactionChanges(pid);
}

@ -1,33 +1,9 @@
#ifndef OPENMW_FACTIONAPI_HPP
#define OPENMW_FACTIONAPI_HPP
#define FACTIONAPI \
{"ClearFactionChanges", FactionFunctions::ClearFactionChanges},\
\
{"GetFactionChangesSize", FactionFunctions::GetFactionChangesSize},\
{"GetFactionChangesAction", FactionFunctions::GetFactionChangesAction},\
\
{"GetFactionId", FactionFunctions::GetFactionId},\
{"GetFactionRank", FactionFunctions::GetFactionRank},\
{"GetFactionExpulsionState", FactionFunctions::GetFactionExpulsionState},\
{"GetFactionReputation", FactionFunctions::GetFactionReputation},\
\
{"SetFactionChangesAction", FactionFunctions::SetFactionChangesAction},\
{"SetFactionId", FactionFunctions::SetFactionId},\
{"SetFactionRank", FactionFunctions::SetFactionRank},\
{"SetFactionExpulsionState", FactionFunctions::SetFactionExpulsionState},\
{"SetFactionReputation", FactionFunctions::SetFactionReputation},\
\
{"AddFaction", FactionFunctions::AddFaction},\
\
{"SendFactionChanges", FactionFunctions::SendFactionChanges},\
\
{"InitializeFactionChanges", FactionFunctions::InitializeFactionChanges}
class FactionFunctions
{
public:
#include "../api.h"
NAMESPACE_BEGIN(FactionFunctions)
/**
* \brief Clear the last recorded faction changes for a player.
*
@ -36,7 +12,7 @@ public:
* \param pid The player ID whose faction changes should be used.
* \return void
*/
static void ClearFactionChanges(unsigned short pid) noexcept;
API_FUNCTION void CDECL ClearFactionChanges(PlayerId pid) NOEXCEPT;
/**
* \brief Get the number of indexes in a player's latest faction changes.
@ -44,7 +20,7 @@ public:
* \param pid The player ID whose faction changes should be used.
* \return The number of indexes.
*/
static unsigned int GetFactionChangesSize(unsigned short pid) noexcept;
API_FUNCTION unsigned int CDECL GetFactionChangesSize(PlayerId pid) NOEXCEPT;
/**
* \brief Get the action type used in a player's latest faction changes.
@ -52,7 +28,7 @@ public:
* \param pid The player ID whose faction changes should be used.
* \return The action type (0 for RANK, 1 for EXPULSION, 2 for REPUTATION).
*/
static unsigned char GetFactionChangesAction(unsigned short pid) noexcept;
API_FUNCTION unsigned char CDECL GetFactionChangesAction(PlayerId pid) NOEXCEPT;
/**
* \brief Get the factionId at a certain index in a player's latest faction changes.
@ -61,7 +37,7 @@ public:
* \param index The index of the faction.
* \return The factionId.
*/
static const char *GetFactionId(unsigned short pid, unsigned int index) noexcept;
API_FUNCTION const char *CDECL GetFactionId(PlayerId pid, unsigned int index) NOEXCEPT;
/**
* \brief Get the rank at a certain index in a player's latest faction changes.
@ -70,7 +46,7 @@ public:
* \param index The index of the faction.
* \return The rank.
*/
static int GetFactionRank(unsigned short pid, unsigned int index) noexcept;
API_FUNCTION int CDECL GetFactionRank(PlayerId pid, unsigned int index) NOEXCEPT;
/**
* \brief Get the expulsion state at a certain index in a player's latest faction changes.
@ -79,7 +55,7 @@ public:
* \param index The index of the faction.
* \return The expulsion state.
*/
static bool GetFactionExpulsionState(unsigned short pid, unsigned int index) noexcept;
API_FUNCTION bool CDECL GetFactionExpulsionState(PlayerId pid, unsigned int index) NOEXCEPT;
/**
* \brief Get the reputation at a certain index in a player's latest faction changes.
@ -88,7 +64,7 @@ public:
* \param index The index of the faction.
* \return The reputation.
*/
static int GetFactionReputation(unsigned short pid, unsigned int index) noexcept;
API_FUNCTION int CDECL GetFactionReputation(PlayerId pid, unsigned int index) NOEXCEPT;
/**
* \brief Set the action type in a player's faction changes.
@ -97,7 +73,7 @@ public:
* \param action The action (0 for RANK, 1 for EXPULSION, 2 for REPUTATION).
* \return void
*/
static void SetFactionChangesAction(unsigned short pid, unsigned char action) noexcept;
API_FUNCTION void CDECL SetFactionChangesAction(PlayerId pid, unsigned char action) NOEXCEPT;
/**
* \brief Set the factionId of the temporary faction stored on the server.
@ -105,7 +81,7 @@ public:
* \param factionId The factionId.
* \return void
*/
static void SetFactionId(const char* factionId) noexcept;
API_FUNCTION void CDECL SetFactionId(const char* factionId) NOEXCEPT;
/**
* \brief Set the rank of the temporary faction stored on the server.
@ -113,7 +89,7 @@ public:
* \param rank The rank.
* \return void
*/
static void SetFactionRank(unsigned int rank) noexcept;
API_FUNCTION void CDECL SetFactionRank(unsigned int rank) NOEXCEPT;
/**
* \brief Set the expulsion state of the temporary faction stored on the server.
@ -121,7 +97,7 @@ public:
* \param expulsionState The expulsion state.
* \return void
*/
static void SetFactionExpulsionState(bool expulsionState) noexcept;
API_FUNCTION void CDECL SetFactionExpulsionState(bool expulsionState) NOEXCEPT;
/**
* \brief Set the reputation of the temporary faction stored on the server.
@ -129,7 +105,7 @@ public:
* \param reputation The reputation.
* \return void
*/
static void SetFactionReputation(int reputation) noexcept;
API_FUNCTION void CDECL SetFactionReputation(int reputation) NOEXCEPT;
/**
* \brief Add the server's temporary faction to the faction changes for a player.
@ -140,7 +116,7 @@ public:
* \param pid The player ID whose faction changes should be used.
* \return void
*/
static void AddFaction(unsigned short pid) noexcept;
API_FUNCTION void CDECL AddFaction(PlayerId pid) NOEXCEPT;
/**
* \brief Send a PlayerFaction packet with a player's recorded faction changes.
@ -152,12 +128,11 @@ public:
* to the packet (false by default).
* \return void
*/
static void SendFactionChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendFactionChanges(PlayerId pid, bool sendToOtherPlayers, bool skipAttachedPlayer) NOEXCEPT;
// All methods below are deprecated versions of methods from above
static void InitializeFactionChanges(unsigned short pid) noexcept;
};
API_FUNCTION void CDECL InitializeFactionChanges(PlayerId pid) NOEXCEPT;
NAMESPACE_END()
#endif //OPENMW_FACTIONAPI_HPP

@ -1,11 +1,11 @@
#include "GUI.hpp"
#include "GUI.h"
#include <components/openmw-mp/NetworkMessages.hpp>
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
#include <apps/openmw-mp/Script/Callbacks.hpp>
#include <apps/openmw-mp/Networking.hpp>
void GUIFunctions::_MessageBox(unsigned short pid, int id, const char *label) noexcept
extern "C" void GUIFunctions::_MessageBox(PlayerId pid, int id, const char *label) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -20,7 +20,7 @@ void GUIFunctions::_MessageBox(unsigned short pid, int id, const char *label) no
packet->Send(false);
}
void GUIFunctions::CustomMessageBox(unsigned short pid, int id, const char *label, const char *buttons) noexcept
extern "C" void GUIFunctions::CustomMessageBox(PlayerId pid, int id, const char *label, const char *buttons) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -36,7 +36,7 @@ void GUIFunctions::CustomMessageBox(unsigned short pid, int id, const char *labe
packet->Send(false);
}
void GUIFunctions::InputDialog(unsigned short pid, int id, const char *label, const char *note) noexcept
extern "C" void GUIFunctions::InputDialog(PlayerId pid, int id, const char *label, const char *note) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -52,7 +52,7 @@ void GUIFunctions::InputDialog(unsigned short pid, int id, const char *label, co
packet->Send(false);
}
void GUIFunctions::PasswordDialog(unsigned short pid, int id, const char *label, const char *note) noexcept
extern "C" void GUIFunctions::PasswordDialog(PlayerId pid, int id, const char *label, const char *note) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -68,7 +68,7 @@ void GUIFunctions::PasswordDialog(unsigned short pid, int id, const char *label,
packet->Send(false);
}
void GUIFunctions::ListBox(unsigned short pid, int id, const char *label, const char *items)
extern "C" void GUIFunctions::ListBox(PlayerId pid, int id, const char *label, const char *items)
{
Player *player;
GET_PLAYER(pid, player,);
@ -84,7 +84,7 @@ void GUIFunctions::ListBox(unsigned short pid, int id, const char *label, const
packet->Send(false);
}
void GUIFunctions::ClearQuickKeyChanges(unsigned short pid) noexcept
extern "C" void GUIFunctions::ClearQuickKeyChanges(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -92,7 +92,7 @@ void GUIFunctions::ClearQuickKeyChanges(unsigned short pid) noexcept
player->quickKeyChanges.quickKeys.clear();
}
unsigned int GUIFunctions::GetQuickKeyChangesSize(unsigned short pid) noexcept
extern "C" unsigned int GUIFunctions::GetQuickKeyChangesSize(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -100,7 +100,7 @@ unsigned int GUIFunctions::GetQuickKeyChangesSize(unsigned short pid) noexcept
return player->quickKeyChanges.count;
}
int GUIFunctions::GetQuickKeySlot(unsigned short pid, unsigned int index) noexcept
extern "C" int GUIFunctions::GetQuickKeySlot(PlayerId pid, unsigned int index) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -111,7 +111,7 @@ int GUIFunctions::GetQuickKeySlot(unsigned short pid, unsigned int index) noexce
return player->quickKeyChanges.quickKeys.at(index).slot;
}
int GUIFunctions::GetQuickKeyType(unsigned short pid, unsigned int index) noexcept
extern "C" int GUIFunctions::GetQuickKeyType(PlayerId pid, unsigned int index) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -122,7 +122,7 @@ int GUIFunctions::GetQuickKeyType(unsigned short pid, unsigned int index) noexce
return player->quickKeyChanges.quickKeys.at(index).type;
}
const char *GUIFunctions::GetQuickKeyItemId(unsigned short pid, unsigned int index) noexcept
extern "C" const char *GUIFunctions::GetQuickKeyItemId(PlayerId pid, unsigned int index) noexcept
{
Player *player;
GET_PLAYER(pid, player, "");
@ -133,7 +133,7 @@ const char *GUIFunctions::GetQuickKeyItemId(unsigned short pid, unsigned int ind
return player->quickKeyChanges.quickKeys.at(index).itemId.c_str();
}
void GUIFunctions::AddQuickKey(unsigned short pid, unsigned short slot, int type, const char* itemId) noexcept
extern "C" void GUIFunctions::AddQuickKey(PlayerId pid, unsigned short slot, int type, const char* itemId) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -146,7 +146,7 @@ void GUIFunctions::AddQuickKey(unsigned short pid, unsigned short slot, int type
player->quickKeyChanges.quickKeys.push_back(quickKey);
}
void GUIFunctions::SendQuickKeyChanges(unsigned short pid) noexcept
extern "C" void GUIFunctions::SendQuickKeyChanges(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -155,19 +155,19 @@ void GUIFunctions::SendQuickKeyChanges(unsigned short pid) noexcept
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_QUICKKEYS)->Send(false);
}
void GUIFunctions::SetMapVisibility(unsigned short targetPid, unsigned short affectedPid, unsigned short state) noexcept
extern "C" void GUIFunctions::SetMapVisibility(unsigned short targetPid, unsigned short affectedPid, unsigned short state) noexcept
{
LOG_MESSAGE(Log::LOG_WARN, "stub");
}
void GUIFunctions::SetMapVisibilityAll(unsigned short targetPid, unsigned short state) noexcept
extern "C" void GUIFunctions::SetMapVisibilityAll(unsigned short targetPid, unsigned short state) noexcept
{
LOG_MESSAGE(Log::LOG_WARN, "stub");
}
// All methods below are deprecated versions of methods from above
extern "C" // All methods below are deprecated versions of methods from above
void GUIFunctions::InitializeQuickKeyChanges(unsigned short pid) noexcept
void GUIFunctions::InitializeQuickKeyChanges(PlayerId pid) noexcept
{
ClearQuickKeyChanges(pid);
}

@ -1,34 +1,9 @@
#ifndef OPENMW_GUIAPI_HPP
#define OPENMW_GUIAPI_HPP
#define GUIAPI \
{"MessageBox", GUIFunctions::_MessageBox},\
{"CustomMessageBox", GUIFunctions::CustomMessageBox},\
{"InputDialog", GUIFunctions::InputDialog},\
{"PasswordDialog", GUIFunctions::PasswordDialog},\
{"ListBox", GUIFunctions::ListBox},\
\
{"ClearQuickKeyChanges", GUIFunctions::ClearQuickKeyChanges},\
\
{"GetQuickKeyChangesSize", GUIFunctions::GetQuickKeyChangesSize},\
\
{"GetQuickKeySlot", GUIFunctions::GetQuickKeySlot},\
{"GetQuickKeyType", GUIFunctions::GetQuickKeyType},\
{"GetQuickKeyItemId", GUIFunctions::GetQuickKeyItemId},\
\
{"AddQuickKey", GUIFunctions::AddQuickKey},\
\
{"SendQuickKeyChanges", GUIFunctions::SendQuickKeyChanges},\
\
{"SetMapVisibility", GUIFunctions::SetMapVisibility},\
{"SetMapVisibilityAll", GUIFunctions::SetMapVisibilityAll},\
\
{"InitializeQuickKeyChanges", GUIFunctions::InitializeQuickKeyChanges}
class GUIFunctions
{
public:
#include "../api.h"
NAMESPACE_BEGIN(GUIFunctions)
/**
* \brief Display a simple messagebox at the bottom of the screen that vanishes
* after a few seconds.
@ -41,7 +16,7 @@ public:
* \param label The text in the messagebox.
* \return void
*/
static void _MessageBox(unsigned short pid, int id, const char *label) noexcept;
API_FUNCTION void CDECL _MessageBox(PlayerId pid, int id, const char *label) NOEXCEPT;
/**
* \brief Display an interactive messagebox at the center of the screen that
@ -53,7 +28,7 @@ public:
* \parm buttons The captions of the buttons, separated by semicolons (e.g. "Yes;No;Maybe").
* \return void
*/
static void CustomMessageBox(unsigned short pid, int id, const char *label, const char *buttons) noexcept;
API_FUNCTION void CDECL CustomMessageBox(PlayerId pid, int id, const char *label, const char *buttons) NOEXCEPT;
/**
* \brief Display an input dialog at the center of the screen.
@ -64,7 +39,7 @@ public:
* \parm note The text at the bottom of the input dialog.
* \return void
*/
static void InputDialog(unsigned short pid, int id, const char *label, const char *note) noexcept;
API_FUNCTION void CDECL InputDialog(PlayerId pid, int id, const char *label, const char *note) NOEXCEPT;
/**
* \brief Display a password dialog at the center of the screen.
@ -78,7 +53,7 @@ public:
* \parm note The text at the bottom of the password dialog.
* \return void
*/
static void PasswordDialog(unsigned short pid, int id, const char *label, const char *note) noexcept;
API_FUNCTION void CDECL PasswordDialog(PlayerId pid, int id, const char *label, const char *note) NOEXCEPT;
/**
* \brief Display a listbox at the center of the screen where each item takes up
@ -91,7 +66,7 @@ public:
* \parm items The items in the listbox, separated by newlines (e.g. "Item 1\nItem 2").
* \return void
*/
static void ListBox(unsigned short pid, int id, const char *label, const char *items);
API_FUNCTION void CDECL ListBox(PlayerId pid, int id, const char *label, const char *items);
/**
* \brief Clear the last recorded quick key changes for a player.
@ -101,7 +76,7 @@ public:
* \param pid The player ID whose quick key changes should be used.
* \return void
*/
static void ClearQuickKeyChanges(unsigned short pid) noexcept;
API_FUNCTION void CDECL ClearQuickKeyChanges(PlayerId pid) NOEXCEPT;
/**
* \brief Get the number of indexes in a player's latest quick key changes.
@ -109,7 +84,7 @@ public:
* \param pid The player ID whose quick key changes should be used.
* \return The number of indexes.
*/
static unsigned int GetQuickKeyChangesSize(unsigned short pid) noexcept;
API_FUNCTION unsigned int CDECL GetQuickKeyChangesSize(PlayerId pid) NOEXCEPT;
/**
* \brief Add a new quick key to the quick key changes for a player.
@ -120,7 +95,7 @@ public:
* \param itemId The itemId of the item.
* \return void
*/
static void AddQuickKey(unsigned short pid, unsigned short slot, int type, const char* itemId = "") noexcept;
API_FUNCTION void CDECL AddQuickKey(PlayerId pid, unsigned short slot, int type, const char* itemId = "") NOEXCEPT;
/**
* \brief Get the slot of the quick key at a certain index in a player's latest quick key changes.
@ -129,7 +104,7 @@ public:
* \param index The index of the quick key in the quick key changes vector.
* \return The slot.
*/
static int GetQuickKeySlot(unsigned short pid, unsigned int index) noexcept;
API_FUNCTION int CDECL GetQuickKeySlot(PlayerId pid, unsigned int index) NOEXCEPT;
/**
* \brief Get the type of the quick key at a certain index in a player's latest quick key changes.
@ -138,7 +113,7 @@ public:
* \param index The index of the quick key in the quick key changes vector.
* \return The quick key type.
*/
static int GetQuickKeyType(unsigned short pid, unsigned int index) noexcept;
API_FUNCTION int CDECL GetQuickKeyType(PlayerId pid, unsigned int index) NOEXCEPT;
/**
* \brief Get the itemId at a certain index in a player's latest quick key changes.
@ -147,7 +122,7 @@ public:
* \param index The index of the quick key in the quick key changes vector.
* \return The itemId.
*/
static const char *GetQuickKeyItemId(unsigned short pid, unsigned int index) noexcept;
API_FUNCTION const char *CDECL GetQuickKeyItemId(PlayerId pid, unsigned int index) NOEXCEPT;
/**
* \brief Send a PlayerQuickKeys packet with a player's recorded quick key changes.
@ -155,7 +130,7 @@ public:
* \param pid The player ID whose quick key changes should be used.
* \return void
*/
static void SendQuickKeyChanges(unsigned short pid) noexcept;
API_FUNCTION void CDECL SendQuickKeyChanges(PlayerId pid) NOEXCEPT;
//state 0 - disallow, 1 - allow
@ -169,7 +144,7 @@ public:
* \param state The state of the map marker (false to hide, true to reveal).
* \return void
*/
static void SetMapVisibility(unsigned short targetPid, unsigned short affectedPid, unsigned short state) noexcept;
API_FUNCTION void CDECL SetMapVisibility(unsigned short targetPid, unsigned short affectedPid, unsigned short state) NOEXCEPT;
/**
* \brief Determine whether a player's map marker can be seen by all other players.
@ -180,12 +155,11 @@ public:
* \param state The state of the map marker (false to hide, true to reveal).
* \return void
*/
static void SetMapVisibilityAll(unsigned short targetPid, unsigned short state) noexcept;
API_FUNCTION void CDECL SetMapVisibilityAll(unsigned short targetPid, unsigned short state) NOEXCEPT;
// All methods below are deprecated versions of methods from above
static void InitializeQuickKeyChanges(unsigned short pid) noexcept;
};
API_FUNCTION void CDECL InitializeQuickKeyChanges(PlayerId pid) NOEXCEPT;
NAMESPACE_END()
#endif //OPENMW_GUIAPI_HPP

@ -1,15 +1,15 @@
#include "Items.hpp"
#include "Items.h"
#include <components/misc/stringops.hpp>
#include <components/openmw-mp/NetworkMessages.hpp>
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
#include <apps/openmw-mp/Script/Callbacks.hpp>
#include <apps/openmw-mp/Networking.hpp>
#include <apps/openmw/mwworld/inventorystore.hpp>
using namespace mwmp;
void ItemFunctions::ClearInventoryChanges(unsigned short pid) noexcept
extern "C" void ItemFunctions::ClearInventoryChanges(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -17,12 +17,12 @@ void ItemFunctions::ClearInventoryChanges(unsigned short pid) noexcept
player->inventoryChanges.items.clear();
}
int ItemFunctions::GetEquipmentSize() noexcept
extern "C" int ItemFunctions::GetEquipmentSize() noexcept
{
return MWWorld::InventoryStore::Slots;
}
unsigned int ItemFunctions::GetInventoryChangesSize(unsigned short pid) noexcept
extern "C" unsigned int ItemFunctions::GetInventoryChangesSize(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -30,7 +30,7 @@ unsigned int ItemFunctions::GetInventoryChangesSize(unsigned short pid) noexcept
return player->inventoryChanges.count;
}
unsigned int ItemFunctions::GetInventoryChangesAction(unsigned short pid) noexcept
extern "C" unsigned int ItemFunctions::GetInventoryChangesAction(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -38,7 +38,7 @@ unsigned int ItemFunctions::GetInventoryChangesAction(unsigned short pid) noexce
return player->inventoryChanges.action;
}
void ItemFunctions::SetInventoryChangesAction(unsigned short pid, unsigned char action) noexcept
extern "C" void ItemFunctions::SetInventoryChangesAction(PlayerId pid, unsigned char action) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -46,7 +46,7 @@ void ItemFunctions::SetInventoryChangesAction(unsigned short pid, unsigned char
player->inventoryChanges.action = action;
}
void ItemFunctions::EquipItem(unsigned short pid, unsigned short slot, const char *refId, unsigned int count,
extern "C" void ItemFunctions::EquipItem(PlayerId pid, unsigned short slot, const char *refId, unsigned int count,
int charge, double enchantmentCharge) noexcept
{
Player *player;
@ -61,7 +61,7 @@ void ItemFunctions::EquipItem(unsigned short pid, unsigned short slot, const cha
player->equipmentIndexChanges.push_back(slot);
}
void ItemFunctions::UnequipItem(unsigned short pid, unsigned short slot) noexcept
extern "C" void ItemFunctions::UnequipItem(PlayerId pid, unsigned short slot) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -69,7 +69,7 @@ void ItemFunctions::UnequipItem(unsigned short pid, unsigned short slot) noexcep
ItemFunctions::EquipItem(pid, slot, "", 0, -1, -1);
}
void ItemFunctions::AddItemChange(unsigned short pid, const char* refId, unsigned int count, int charge,
extern "C" void ItemFunctions::AddItemChange(PlayerId pid, const char* refId, unsigned int count, int charge,
double enchantmentCharge, const char* soul) noexcept
{
Player *player;
@ -85,7 +85,7 @@ void ItemFunctions::AddItemChange(unsigned short pid, const char* refId, unsigne
player->inventoryChanges.items.push_back(item);
}
bool ItemFunctions::HasItemEquipped(unsigned short pid, const char* refId)
extern "C" bool ItemFunctions::HasItemEquipped(PlayerId pid, const char* refId)
{
Player *player;
GET_PLAYER(pid, player, false);
@ -96,7 +96,7 @@ bool ItemFunctions::HasItemEquipped(unsigned short pid, const char* refId)
return false;
}
const char *ItemFunctions::GetEquipmentItemRefId(unsigned short pid, unsigned short slot) noexcept
extern "C" const char *ItemFunctions::GetEquipmentItemRefId(PlayerId pid, unsigned short slot) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -104,7 +104,7 @@ const char *ItemFunctions::GetEquipmentItemRefId(unsigned short pid, unsigned sh
return player->equipmentItems[slot].refId.c_str();
}
int ItemFunctions::GetEquipmentItemCount(unsigned short pid, unsigned short slot) noexcept
extern "C" int ItemFunctions::GetEquipmentItemCount(PlayerId pid, unsigned short slot) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -112,7 +112,7 @@ int ItemFunctions::GetEquipmentItemCount(unsigned short pid, unsigned short slot
return player->equipmentItems[slot].count;
}
int ItemFunctions::GetEquipmentItemCharge(unsigned short pid, unsigned short slot) noexcept
extern "C" int ItemFunctions::GetEquipmentItemCharge(PlayerId pid, unsigned short slot) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -120,7 +120,7 @@ int ItemFunctions::GetEquipmentItemCharge(unsigned short pid, unsigned short slo
return player->equipmentItems[slot].charge;
}
double ItemFunctions::GetEquipmentItemEnchantmentCharge(unsigned short pid, unsigned short slot) noexcept
extern "C" double ItemFunctions::GetEquipmentItemEnchantmentCharge(PlayerId pid, unsigned short slot) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -128,7 +128,7 @@ double ItemFunctions::GetEquipmentItemEnchantmentCharge(unsigned short pid, unsi
return player->equipmentItems[slot].enchantmentCharge;
}
const char *ItemFunctions::GetInventoryItemRefId(unsigned short pid, unsigned int index) noexcept
extern "C" const char *ItemFunctions::GetInventoryItemRefId(PlayerId pid, unsigned int index) noexcept
{
Player *player;
GET_PLAYER(pid, player, "");
@ -139,7 +139,7 @@ const char *ItemFunctions::GetInventoryItemRefId(unsigned short pid, unsigned in
return player->inventoryChanges.items.at(index).refId.c_str();
}
int ItemFunctions::GetInventoryItemCount(unsigned short pid, unsigned int index) noexcept
extern "C" int ItemFunctions::GetInventoryItemCount(PlayerId pid, unsigned int index) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -147,7 +147,7 @@ int ItemFunctions::GetInventoryItemCount(unsigned short pid, unsigned int index)
return player->inventoryChanges.items.at(index).count;
}
int ItemFunctions::GetInventoryItemCharge(unsigned short pid, unsigned int index) noexcept
extern "C" int ItemFunctions::GetInventoryItemCharge(PlayerId pid, unsigned int index) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -155,7 +155,7 @@ int ItemFunctions::GetInventoryItemCharge(unsigned short pid, unsigned int index
return player->inventoryChanges.items.at(index).charge;
}
double ItemFunctions::GetInventoryItemEnchantmentCharge(unsigned short pid, unsigned int index) noexcept
extern "C" double ItemFunctions::GetInventoryItemEnchantmentCharge(PlayerId pid, unsigned int index) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -163,7 +163,7 @@ double ItemFunctions::GetInventoryItemEnchantmentCharge(unsigned short pid, unsi
return player->inventoryChanges.items.at(index).enchantmentCharge;
}
const char *ItemFunctions::GetInventoryItemSoul(unsigned short pid, unsigned int index) noexcept
extern "C" const char *ItemFunctions::GetInventoryItemSoul(PlayerId pid, unsigned int index) noexcept
{
Player *player;
GET_PLAYER(pid, player, "");
@ -174,7 +174,7 @@ const char *ItemFunctions::GetInventoryItemSoul(unsigned short pid, unsigned int
return player->inventoryChanges.items.at(index).soul.c_str();
}
const char *ItemFunctions::GetUsedItemRefId(unsigned short pid) noexcept
extern "C" const char *ItemFunctions::GetUsedItemRefId(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, "");
@ -182,7 +182,7 @@ const char *ItemFunctions::GetUsedItemRefId(unsigned short pid) noexcept
return player->usedItem.refId.c_str();
}
int ItemFunctions::GetUsedItemCount(unsigned short pid) noexcept
extern "C" int ItemFunctions::GetUsedItemCount(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -190,7 +190,7 @@ int ItemFunctions::GetUsedItemCount(unsigned short pid) noexcept
return player->usedItem.count;
}
int ItemFunctions::GetUsedItemCharge(unsigned short pid) noexcept
extern "C" int ItemFunctions::GetUsedItemCharge(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -198,7 +198,7 @@ int ItemFunctions::GetUsedItemCharge(unsigned short pid) noexcept
return player->usedItem.charge;
}
double ItemFunctions::GetUsedItemEnchantmentCharge(unsigned short pid) noexcept
extern "C" double ItemFunctions::GetUsedItemEnchantmentCharge(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -206,7 +206,7 @@ double ItemFunctions::GetUsedItemEnchantmentCharge(unsigned short pid) noexcept
return player->usedItem.enchantmentCharge;
}
const char *ItemFunctions::GetUsedItemSoul(unsigned short pid) noexcept
extern "C" const char *ItemFunctions::GetUsedItemSoul(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, "");
@ -214,7 +214,7 @@ const char *ItemFunctions::GetUsedItemSoul(unsigned short pid) noexcept
return player->usedItem.soul.c_str();
}
void ItemFunctions::SendEquipment(unsigned short pid) noexcept
extern "C" void ItemFunctions::SendEquipment(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -228,7 +228,7 @@ void ItemFunctions::SendEquipment(unsigned short pid) noexcept
player->equipmentIndexChanges.clear();
}
void ItemFunctions::SendInventoryChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
extern "C" void ItemFunctions::SendInventoryChanges(PlayerId pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -242,7 +242,7 @@ void ItemFunctions::SendInventoryChanges(unsigned short pid, bool sendToOtherPla
packet->Send(true);
}
void ItemFunctions::SendItemUse(unsigned short pid) noexcept
extern "C" void ItemFunctions::SendItemUse(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -253,14 +253,14 @@ void ItemFunctions::SendItemUse(unsigned short pid) noexcept
packet->Send(false);
}
// All methods below are deprecated versions of methods from above
extern "C" // All methods below are deprecated versions of methods from above
void ItemFunctions::InitializeInventoryChanges(unsigned short pid) noexcept
void ItemFunctions::InitializeInventoryChanges(PlayerId pid) noexcept
{
ClearInventoryChanges(pid);
}
void ItemFunctions::AddItem(unsigned short pid, const char* refId, unsigned int count, int charge,
extern "C" void ItemFunctions::AddItem(PlayerId pid, const char* refId, unsigned int count, int charge,
double enchantmentCharge, const char* soul) noexcept
{
AddItemChange(pid, refId, count, charge, enchantmentCharge, soul);

@ -1,50 +1,9 @@
#ifndef OPENMW_ITEMAPI_HPP
#define OPENMW_ITEMAPI_HPP
#define ITEMAPI \
{"ClearInventoryChanges", ItemFunctions::ClearInventoryChanges},\
\
{"GetEquipmentSize", ItemFunctions::GetEquipmentSize},\
{"GetInventoryChangesSize", ItemFunctions::GetInventoryChangesSize},\
{"GetInventoryChangesAction", ItemFunctions::GetInventoryChangesAction},\
\
{"SetInventoryChangesAction", ItemFunctions::SetInventoryChangesAction},\
\
{"EquipItem", ItemFunctions::EquipItem},\
{"UnequipItem", ItemFunctions::UnequipItem},\
\
{"AddItemChange", ItemFunctions::AddItemChange},\
\
{"HasItemEquipped", ItemFunctions::HasItemEquipped},\
\
{"GetEquipmentItemRefId", ItemFunctions::GetEquipmentItemRefId},\
{"GetEquipmentItemCount", ItemFunctions::GetEquipmentItemCount},\
{"GetEquipmentItemCharge", ItemFunctions::GetEquipmentItemCharge},\
{"GetEquipmentItemEnchantmentCharge", ItemFunctions::GetEquipmentItemEnchantmentCharge},\
\
{"GetInventoryItemRefId", ItemFunctions::GetInventoryItemRefId},\
{"GetInventoryItemCount", ItemFunctions::GetInventoryItemCount},\
{"GetInventoryItemCharge", ItemFunctions::GetInventoryItemCharge},\
{"GetInventoryItemEnchantmentCharge", ItemFunctions::GetInventoryItemEnchantmentCharge},\
{"GetInventoryItemSoul", ItemFunctions::GetInventoryItemSoul},\
\
{"GetUsedItemRefId", ItemFunctions::GetUsedItemRefId},\
{"GetUsedItemCount", ItemFunctions::GetUsedItemCount},\
{"GetUsedItemCharge", ItemFunctions::GetUsedItemCharge},\
{"GetUsedItemEnchantmentCharge", ItemFunctions::GetUsedItemEnchantmentCharge},\
{"GetUsedItemSoul", ItemFunctions::GetUsedItemSoul},\
\
{"SendEquipment", ItemFunctions::SendEquipment},\
{"SendInventoryChanges", ItemFunctions::SendInventoryChanges},\
{"SendItemUse", ItemFunctions::SendItemUse},\
\
{"InitializeInventoryChanges", ItemFunctions::InitializeInventoryChanges},\
{"AddItem", ItemFunctions::AddItem}
class ItemFunctions
{
public:
#include "../api.h"
NAMESPACE_BEGIN(ItemFunctions)
/**
* \brief Clear the last recorded inventory changes for a player.
*
@ -53,7 +12,7 @@ public:
* \param pid The player ID whose inventory changes should be used.
* \return void
*/
static void ClearInventoryChanges(unsigned short pid) noexcept;
API_FUNCTION void CDECL ClearInventoryChanges(PlayerId pid) NOEXCEPT;
/**
* \brief Get the number of slots used for equipment.
@ -62,7 +21,7 @@ public:
*
* \return The number of slots.
*/
static int GetEquipmentSize() noexcept;
API_FUNCTION int CDECL GetEquipmentSize() NOEXCEPT;
/**
* \brief Get the number of indexes in a player's latest inventory changes.
@ -70,7 +29,7 @@ public:
* \param pid The player ID whose inventory changes should be used.
* \return The number of indexes.
*/
static unsigned int GetInventoryChangesSize(unsigned short pid) noexcept;
API_FUNCTION unsigned int CDECL GetInventoryChangesSize(PlayerId pid) NOEXCEPT;
/**
* \brief Get the action type used in a player's latest inventory changes.
@ -78,7 +37,7 @@ public:
* \param pid The player ID whose inventory changes should be used.
* \return The action type (0 for SET, 1 for ADD, 2 for REMOVE).
*/
static unsigned int GetInventoryChangesAction(unsigned short pid) noexcept;
API_FUNCTION unsigned int CDECL GetInventoryChangesAction(PlayerId pid) NOEXCEPT;
/**
* \brief Set the action type in a player's inventory changes.
@ -87,7 +46,7 @@ public:
* \param action The action (0 for SET, 1 for ADD, 2 for REMOVE).
* \return void
*/
static void SetInventoryChangesAction(unsigned short pid, unsigned char action) noexcept;
API_FUNCTION void CDECL SetInventoryChangesAction(PlayerId pid, unsigned char action) NOEXCEPT;
/**
* \brief Equip an item in a certain slot of the equipment of a player.
@ -100,8 +59,8 @@ public:
* \param enchantmentCharge The enchantment charge of the item.
* \return void
*/
static void EquipItem(unsigned short pid, unsigned short slot, const char* refId, unsigned int count, int charge,
double enchantmentCharge = -1) noexcept;
API_FUNCTION void CDECL EquipItem(PlayerId pid, unsigned short slot, const char* refId, unsigned int count, int charge,
double enchantmentCharge = -1) NOEXCEPT;
/**
* \brief Unequip the item in a certain slot of the equipment of a player.
@ -110,7 +69,7 @@ public:
* \param slot The equipment slot.
* \return void
*/
static void UnequipItem(unsigned short pid, unsigned short slot) noexcept;
API_FUNCTION void CDECL UnequipItem(PlayerId pid, unsigned short slot) NOEXCEPT;
/**
* \brief Add an item change to a player's inventory changes.
@ -123,8 +82,8 @@ public:
* \param soul The soul of the item.
* \return void
*/
static void AddItemChange(unsigned short pid, const char* refId, unsigned int count, int charge,
double enchantmentCharge, const char* soul) noexcept;
API_FUNCTION void CDECL AddItemChange(PlayerId pid, const char* refId, unsigned int count, int charge,
double enchantmentCharge, const char* soul) NOEXCEPT;
/**
* \brief Check whether a player has equipped an item with a certain refId in any slot.
@ -133,7 +92,7 @@ public:
* \param refId The refId of the item.
* \return Whether the player has the item equipped.
*/
static bool HasItemEquipped(unsigned short pid, const char* refId);
API_FUNCTION bool CDECL HasItemEquipped(PlayerId pid, const char* refId);
/**
* \brief Get the refId of the item in a certain slot of the equipment of a player.
@ -142,7 +101,7 @@ public:
* \param slot The slot of the equipment item.
* \return The refId.
*/
static const char *GetEquipmentItemRefId(unsigned short pid, unsigned short slot) noexcept;
API_FUNCTION const char *CDECL GetEquipmentItemRefId(PlayerId pid, unsigned short slot) NOEXCEPT;
/**
* \brief Get the count of the item in a certain slot of the equipment of a player.
@ -151,7 +110,7 @@ public:
* \param slot The slot of the equipment item.
* \return The item count.
*/
static int GetEquipmentItemCount(unsigned short pid, unsigned short slot) noexcept;
API_FUNCTION int CDECL GetEquipmentItemCount(PlayerId pid, unsigned short slot) NOEXCEPT;
/**
* \brief Get the charge of the item in a certain slot of the equipment of a player.
@ -160,7 +119,7 @@ public:
* \param slot The slot of the equipment item.
* \return The charge.
*/
static int GetEquipmentItemCharge(unsigned short pid, unsigned short slot) noexcept;
API_FUNCTION int CDECL GetEquipmentItemCharge(PlayerId pid, unsigned short slot) NOEXCEPT;
/**
* \brief Get the enchantment charge of the item in a certain slot of the equipment of
@ -170,7 +129,7 @@ public:
* \param slot The slot of the equipment item.
* \return The enchantment charge.
*/
static double GetEquipmentItemEnchantmentCharge(unsigned short pid, unsigned short slot) noexcept;
API_FUNCTION double CDECL GetEquipmentItemEnchantmentCharge(PlayerId pid, unsigned short slot) NOEXCEPT;
/**
* \brief Get the refId of the item at a certain index in a player's latest inventory
@ -180,7 +139,7 @@ public:
* \param index The index of the inventory item.
* \return The refId.
*/
static const char *GetInventoryItemRefId(unsigned short pid, unsigned int index) noexcept;
API_FUNCTION const char *CDECL GetInventoryItemRefId(PlayerId pid, unsigned int index) NOEXCEPT;
/**
* \brief Get the count of the item at a certain index in a player's latest inventory
@ -190,7 +149,7 @@ public:
* \param index The index of the inventory item.
* \return The item count.
*/
static int GetInventoryItemCount(unsigned short pid, unsigned int index) noexcept;
API_FUNCTION int CDECL GetInventoryItemCount(PlayerId pid, unsigned int index) NOEXCEPT;
/**
* \brief Get the charge of the item at a certain index in a player's latest inventory
@ -200,7 +159,7 @@ public:
* \param index The index of the inventory item.
* \return The charge.
*/
static int GetInventoryItemCharge(unsigned short pid, unsigned int index) noexcept;
API_FUNCTION int CDECL GetInventoryItemCharge(PlayerId pid, unsigned int index) NOEXCEPT;
/**
* \brief Get the enchantment charge of the item at a certain index in a player's
@ -210,7 +169,7 @@ public:
* \param index The index of the inventory item.
* \return The enchantment charge.
*/
static double GetInventoryItemEnchantmentCharge(unsigned short pid, unsigned int index) noexcept;
API_FUNCTION double CDECL GetInventoryItemEnchantmentCharge(PlayerId pid, unsigned int index) NOEXCEPT;
/**
* \brief Get the soul of the item at a certain index in a player's latest inventory
@ -220,7 +179,7 @@ public:
* \param index The index of the inventory item.
* \return The soul.
*/
static const char *GetInventoryItemSoul(unsigned short pid, unsigned int index) noexcept;
API_FUNCTION const char *CDECL GetInventoryItemSoul(PlayerId pid, unsigned int index) NOEXCEPT;
/**
* \brief Get the refId of the item last used by a player.
@ -228,7 +187,7 @@ public:
* \param pid The player ID.
* \return The refId.
*/
static const char *GetUsedItemRefId(unsigned short pid) noexcept;
API_FUNCTION const char *CDECL GetUsedItemRefId(PlayerId pid) NOEXCEPT;
/**
* \brief Get the count of the item last used by a player.
@ -236,7 +195,7 @@ public:
* \param pid The player ID.
* \return The item count.
*/
static int GetUsedItemCount(unsigned short pid) noexcept;
API_FUNCTION int CDECL GetUsedItemCount(PlayerId pid) NOEXCEPT;
/**
* \brief Get the charge of the item last used by a player.
@ -244,7 +203,7 @@ public:
* \param pid The player ID.
* \return The charge.
*/
static int GetUsedItemCharge(unsigned short pid) noexcept;
API_FUNCTION int CDECL GetUsedItemCharge(PlayerId pid) NOEXCEPT;
/**
* \brief Get the enchantment charge of the item last used by a player.
@ -252,7 +211,7 @@ public:
* \param pid The player ID.
* \return The enchantment charge.
*/
static double GetUsedItemEnchantmentCharge(unsigned short pid) noexcept;
API_FUNCTION double CDECL GetUsedItemEnchantmentCharge(PlayerId pid) NOEXCEPT;
/**
* \brief Get the soul of the item last used by a player.
@ -260,7 +219,7 @@ public:
* \param pid The player ID.
* \return The soul.
*/
static const char *GetUsedItemSoul(unsigned short pid) noexcept;
API_FUNCTION const char *CDECL GetUsedItemSoul(PlayerId pid) NOEXCEPT;
/**
* \brief Send a PlayerEquipment packet with a player's equipment.
@ -270,7 +229,7 @@ public:
* \param pid The player ID whose equipment should be sent.
* \return void
*/
static void SendEquipment(unsigned short pid) noexcept;
API_FUNCTION void CDECL SendEquipment(PlayerId pid) NOEXCEPT;
/**
* \brief Send a PlayerInventory packet with a player's recorded inventory changes.
@ -282,7 +241,7 @@ public:
* to the packet (false by default).
* \return void
*/
static void SendInventoryChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendInventoryChanges(PlayerId pid, bool sendToOtherPlayers, bool skipAttachedPlayer) NOEXCEPT;
/**
* \brief Send a PlayerItemUse causing a player to use their recorded usedItem.
@ -290,17 +249,14 @@ public:
* \param pid The player ID affected.
* \return void
*/
static void SendItemUse(unsigned short pid) noexcept;
API_FUNCTION void CDECL SendItemUse(PlayerId pid) NOEXCEPT;
// All methods below are deprecated versions of methods from above
static void InitializeInventoryChanges(unsigned short pid) noexcept;
static void AddItem(unsigned short pid, const char* refId, unsigned int count, int charge,
double enchantmentCharge, const char* soul) noexcept;
private:
API_FUNCTION void CDECL InitializeInventoryChanges(PlayerId pid) NOEXCEPT;
};
API_FUNCTION void CDECL AddItem(PlayerId pid, const char* refId, unsigned int count, int charge,
double enchantmentCharge, const char* soul) NOEXCEPT;
NAMESPACE_END()
#endif //OPENMW_ITEMAPI_HPP

@ -1,9 +1,9 @@
#include "Mechanics.hpp"
#include "Mechanics.h"
#include <components/openmw-mp/NetworkMessages.hpp>
#include <components/openmw-mp/Log.hpp>
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
#include <apps/openmw-mp/Script/Callbacks.hpp>
#include <apps/openmw-mp/Networking.hpp>
#include <iostream>
@ -11,7 +11,7 @@ using namespace std;
static std::string tempCellDescription;
unsigned char MechanicsFunctions::GetMiscellaneousChangeType(unsigned short pid) noexcept
extern "C" unsigned char MechanicsFunctions::GetMiscellaneousChangeType(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -19,16 +19,16 @@ unsigned char MechanicsFunctions::GetMiscellaneousChangeType(unsigned short pid)
return player->miscellaneousChangeType;
}
const char *MechanicsFunctions::GetMarkCell(unsigned short pid) noexcept
extern "C" const char *MechanicsFunctions::GetMarkCell(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
tempCellDescription = player->cell.getDescription().c_str();
tempCellDescription = player->cell.getDescription();
return tempCellDescription.c_str();
}
double MechanicsFunctions::GetMarkPosX(unsigned short pid) noexcept
extern "C" double MechanicsFunctions::GetMarkPosX(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0.0f);
@ -36,7 +36,7 @@ double MechanicsFunctions::GetMarkPosX(unsigned short pid) noexcept
return player->markPosition.pos[0];
}
double MechanicsFunctions::GetMarkPosY(unsigned short pid) noexcept
extern "C" double MechanicsFunctions::GetMarkPosY(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0.0f);
@ -44,7 +44,7 @@ double MechanicsFunctions::GetMarkPosY(unsigned short pid) noexcept
return player->markPosition.pos[1];
}
double MechanicsFunctions::GetMarkPosZ(unsigned short pid) noexcept
extern "C" double MechanicsFunctions::GetMarkPosZ(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0.0f);
@ -52,7 +52,7 @@ double MechanicsFunctions::GetMarkPosZ(unsigned short pid) noexcept
return player->markPosition.pos[2];
}
double MechanicsFunctions::GetMarkRotX(unsigned short pid) noexcept
extern "C" double MechanicsFunctions::GetMarkRotX(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0.0f);
@ -60,7 +60,7 @@ double MechanicsFunctions::GetMarkRotX(unsigned short pid) noexcept
return player->markPosition.rot[0];
}
double MechanicsFunctions::GetMarkRotZ(unsigned short pid) noexcept
extern "C" double MechanicsFunctions::GetMarkRotZ(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0.0f);
@ -68,7 +68,7 @@ double MechanicsFunctions::GetMarkRotZ(unsigned short pid) noexcept
return player->markPosition.rot[2];
}
bool MechanicsFunctions::DoesPlayerHavePlayerKiller(unsigned short pid) noexcept
extern "C" bool MechanicsFunctions::DoesPlayerHavePlayerKiller(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, false);
@ -76,7 +76,7 @@ bool MechanicsFunctions::DoesPlayerHavePlayerKiller(unsigned short pid) noexcept
return player->killer.isPlayer;
}
int MechanicsFunctions::GetPlayerKillerPid(unsigned short pid) noexcept
extern "C" int MechanicsFunctions::GetPlayerKillerPid(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -89,7 +89,7 @@ int MechanicsFunctions::GetPlayerKillerPid(unsigned short pid) noexcept
return -1;
}
const char *MechanicsFunctions::GetPlayerKillerRefId(unsigned short pid) noexcept
extern "C" const char *MechanicsFunctions::GetPlayerKillerRefId(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, "");
@ -97,7 +97,7 @@ const char *MechanicsFunctions::GetPlayerKillerRefId(unsigned short pid) noexcep
return player->killer.refId.c_str();
}
unsigned int MechanicsFunctions::GetPlayerKillerRefNum(unsigned short pid) noexcept
extern "C" unsigned int MechanicsFunctions::GetPlayerKillerRefNum(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -105,7 +105,7 @@ unsigned int MechanicsFunctions::GetPlayerKillerRefNum(unsigned short pid) noexc
return player->killer.refNum;
}
unsigned int MechanicsFunctions::GetPlayerKillerMpNum(unsigned short pid) noexcept
extern "C" unsigned int MechanicsFunctions::GetPlayerKillerMpNum(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -113,7 +113,7 @@ unsigned int MechanicsFunctions::GetPlayerKillerMpNum(unsigned short pid) noexce
return player->killer.mpNum;
}
const char *MechanicsFunctions::GetPlayerKillerName(unsigned short pid) noexcept
extern "C" const char *MechanicsFunctions::GetPlayerKillerName(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, "");
@ -121,7 +121,7 @@ const char *MechanicsFunctions::GetPlayerKillerName(unsigned short pid) noexcept
return player->killer.name.c_str();
}
const char *MechanicsFunctions::GetSelectedSpellId(unsigned short pid) noexcept
extern "C" const char *MechanicsFunctions::GetSelectedSpellId(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -129,7 +129,7 @@ const char *MechanicsFunctions::GetSelectedSpellId(unsigned short pid) noexcept
return player->selectedSpellId.c_str();
}
unsigned int MechanicsFunctions::GetDrawState(unsigned short pid) noexcept
extern "C" unsigned int MechanicsFunctions::GetDrawState(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, false);
@ -137,7 +137,7 @@ unsigned int MechanicsFunctions::GetDrawState(unsigned short pid) noexcept
return player->drawState;
}
bool MechanicsFunctions::GetSneakState(unsigned short pid) noexcept
extern "C" bool MechanicsFunctions::GetSneakState(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, false);
@ -146,7 +146,7 @@ bool MechanicsFunctions::GetSneakState(unsigned short pid) noexcept
return (player->movementFlags & 8) != 0;
}
void MechanicsFunctions::SetMarkCell(unsigned short pid, const char *cellDescription) noexcept
extern "C" void MechanicsFunctions::SetMarkCell(PlayerId pid, const char *cellDescription) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -154,7 +154,7 @@ void MechanicsFunctions::SetMarkCell(unsigned short pid, const char *cellDescrip
player->markCell = Utils::getCellFromDescription(cellDescription);
}
void MechanicsFunctions::SetMarkPos(unsigned short pid, double x, double y, double z) noexcept
extern "C" void MechanicsFunctions::SetMarkPos(PlayerId pid, double x, double y, double z) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -164,7 +164,7 @@ void MechanicsFunctions::SetMarkPos(unsigned short pid, double x, double y, doub
player->markPosition.pos[2] = z;
}
void MechanicsFunctions::SetMarkRot(unsigned short pid, double x, double z) noexcept
extern "C" void MechanicsFunctions::SetMarkRot(PlayerId pid, double x, double z) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -173,7 +173,7 @@ void MechanicsFunctions::SetMarkRot(unsigned short pid, double x, double z) noex
player->markPosition.rot[2] = z;
}
void MechanicsFunctions::SetSelectedSpellId(unsigned short pid, const char *spellId) noexcept
extern "C" void MechanicsFunctions::SetSelectedSpellId(PlayerId pid, const char *spellId) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -181,7 +181,7 @@ void MechanicsFunctions::SetSelectedSpellId(unsigned short pid, const char *spel
player->selectedSpellId = spellId;
}
void MechanicsFunctions::SendMarkLocation(unsigned short pid)
extern "C" void MechanicsFunctions::SendMarkLocation(PlayerId pid)
{
Player *player;
GET_PLAYER(pid, player, );
@ -194,7 +194,7 @@ void MechanicsFunctions::SendMarkLocation(unsigned short pid)
packet->Send(false);
}
void MechanicsFunctions::SendSelectedSpell(unsigned short pid)
extern "C" void MechanicsFunctions::SendSelectedSpell(PlayerId pid)
{
Player *player;
GET_PLAYER(pid, player, );
@ -207,7 +207,7 @@ void MechanicsFunctions::SendSelectedSpell(unsigned short pid)
packet->Send(false);
}
void MechanicsFunctions::Jail(unsigned short pid, int jailDays, bool ignoreJailTeleportation, bool ignoreJailSkillIncreases,
extern "C" void MechanicsFunctions::Jail(PlayerId pid, int jailDays, bool ignoreJailTeleportation, bool ignoreJailSkillIncreases,
const char* jailProgressText, const char* jailEndText) noexcept
{
Player *player;
@ -225,7 +225,7 @@ void MechanicsFunctions::Jail(unsigned short pid, int jailDays, bool ignoreJailT
packet->Send(false);
}
void MechanicsFunctions::Resurrect(unsigned short pid, unsigned int type) noexcept
extern "C" void MechanicsFunctions::Resurrect(PlayerId pid, unsigned int type) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -241,7 +241,7 @@ void MechanicsFunctions::Resurrect(unsigned short pid, unsigned int type) noexce
// All methods below are deprecated versions of methods from above
const char *MechanicsFunctions::GetDeathReason(unsigned short pid) noexcept
extern "C" const char *MechanicsFunctions::GetDeathReason(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -259,7 +259,7 @@ const char *MechanicsFunctions::GetDeathReason(unsigned short pid) noexcept
return "suicide";
}
unsigned int MechanicsFunctions::GetPlayerKillerRefNumIndex(unsigned short pid) noexcept
extern "C" unsigned int MechanicsFunctions::GetPlayerKillerRefNumIndex(PlayerId pid) noexcept
{
return GetPlayerKillerRefNum(pid);
}

@ -1,54 +1,16 @@
#ifndef OPENMW_MECHANICSAPI_HPP
#define OPENMW_MECHANICSAPI_HPP
#include "../Types.hpp"
#define MECHANICSAPI \
{"GetMiscellaneousChangeType", MechanicsFunctions::GetMiscellaneousChangeType},\
\
{"GetMarkCell", MechanicsFunctions::GetMarkCell},\
{"GetMarkPosX", MechanicsFunctions::GetMarkPosX},\
{"GetMarkPosY", MechanicsFunctions::GetMarkPosY},\
{"GetMarkPosZ", MechanicsFunctions::GetMarkPosZ},\
{"GetMarkRotX", MechanicsFunctions::GetMarkRotX},\
{"GetMarkRotZ", MechanicsFunctions::GetMarkRotZ},\
{"GetSelectedSpellId", MechanicsFunctions::GetSelectedSpellId},\
\
{"DoesPlayerHavePlayerKiller", MechanicsFunctions::DoesPlayerHavePlayerKiller},\
{"GetPlayerKillerPid", MechanicsFunctions::GetPlayerKillerPid},\
{"GetPlayerKillerRefId", MechanicsFunctions::GetPlayerKillerRefId},\
{"GetPlayerKillerRefNum", MechanicsFunctions::GetPlayerKillerRefNum},\
{"GetPlayerKillerMpNum", MechanicsFunctions::GetPlayerKillerMpNum},\
{"GetPlayerKillerName", MechanicsFunctions::GetPlayerKillerName},\
\
{"GetDrawState", MechanicsFunctions::GetDrawState},\
{"GetSneakState", MechanicsFunctions::GetSneakState},\
\
{"SetMarkCell", MechanicsFunctions::SetMarkCell},\
{"SetMarkPos", MechanicsFunctions::SetMarkPos},\
{"SetMarkRot", MechanicsFunctions::SetMarkRot},\
{"SetSelectedSpellId", MechanicsFunctions::SetSelectedSpellId},\
\
{"SendMarkLocation", MechanicsFunctions::SendMarkLocation},\
{"SendSelectedSpell", MechanicsFunctions::SendSelectedSpell},\
\
{"Jail", MechanicsFunctions::Jail},\
{"Resurrect", MechanicsFunctions::Resurrect},\
\
{"GetDeathReason", MechanicsFunctions::GetDeathReason},\
{"GetPlayerKillerRefNumIndex", MechanicsFunctions::GetPlayerKillerRefNumIndex}
class MechanicsFunctions
{
public:
#include "../api.h"
NAMESPACE_BEGIN(MechanicsFunctions)
/**
* \brief Get the type of a PlayerMiscellaneous packet.
*
* \param pid The player ID.
* \return The type.
*/
static unsigned char GetMiscellaneousChangeType(unsigned short pid) noexcept;
API_FUNCTION unsigned char CDECL GetMiscellaneousChangeType(PlayerId pid) NOEXCEPT;
/**
* \brief Get the cell description of a player's Mark cell.
@ -56,7 +18,7 @@ public:
* \param pid The player ID.
* \return The cell description.
*/
static const char *GetMarkCell(unsigned short pid) noexcept;
API_FUNCTION const char *CDECL GetMarkCell(PlayerId pid) NOEXCEPT;
/**
* \brief Get the X position of a player's Mark.
@ -64,7 +26,7 @@ public:
* \param pid The player ID.
* \return The X position.
*/
static double GetMarkPosX(unsigned short pid) noexcept;
API_FUNCTION double CDECL GetMarkPosX(PlayerId pid) NOEXCEPT;
/**
* \brief Get the Y position of a player's Mark.
@ -72,7 +34,7 @@ public:
* \param pid The player ID.
* \return The Y position.
*/
static double GetMarkPosY(unsigned short pid) noexcept;
API_FUNCTION double CDECL GetMarkPosY(PlayerId pid) NOEXCEPT;
/**
* \brief Get the Z position of a player's Mark.
@ -80,7 +42,7 @@ public:
* \param pid The player ID.
* \return The Z position.
*/
static double GetMarkPosZ(unsigned short pid) noexcept;
API_FUNCTION double CDECL GetMarkPosZ(PlayerId pid) NOEXCEPT;
/**
* \brief Get the X rotation of a player's Mark.
@ -88,7 +50,7 @@ public:
* \param pid The player ID.
* \return The X rotation.
*/
static double GetMarkRotX(unsigned short pid) noexcept;
API_FUNCTION double CDECL GetMarkRotX(PlayerId pid) NOEXCEPT;
/**
* \brief Get the Z rotation of a player's Mark.
@ -96,7 +58,7 @@ public:
* \param pid The player ID.
* \return The X rotation.
*/
static double GetMarkRotZ(unsigned short pid) noexcept;
API_FUNCTION double CDECL GetMarkRotZ(PlayerId pid) NOEXCEPT;
/**
* \brief Get the ID of a player's selected spell.
@ -104,7 +66,7 @@ public:
* \param pid The player ID.
* \return The spell ID.
*/
static const char *GetSelectedSpellId(unsigned short pid) noexcept;
API_FUNCTION const char *CDECL GetSelectedSpellId(PlayerId pid) NOEXCEPT;
/**
* \brief Check whether the killer of a certain player is also a player.
@ -112,7 +74,7 @@ public:
* \param pid The player ID of the killed player.
* \return Whether the player was killed by another player.
*/
static bool DoesPlayerHavePlayerKiller(unsigned short pid) noexcept;
API_FUNCTION bool CDECL DoesPlayerHavePlayerKiller(PlayerId pid) NOEXCEPT;
/**
* \brief Get the player ID of the killer of a certain player.
@ -120,7 +82,7 @@ public:
* \param pid The player ID of the killed player.
* \return The player ID of the killer.
*/
static int GetPlayerKillerPid(unsigned short pid) noexcept;
API_FUNCTION int CDECL GetPlayerKillerPid(PlayerId pid) NOEXCEPT;
/**
* \brief Get the refId of the actor killer of a certain player.
@ -128,7 +90,7 @@ public:
* \param pid The player ID of the killed player.
* \return The refId of the killer.
*/
static const char *GetPlayerKillerRefId(unsigned short pid) noexcept;
API_FUNCTION const char *CDECL GetPlayerKillerRefId(PlayerId pid) NOEXCEPT;
/**
* \brief Get the refNum of the actor killer of a certain player.
@ -136,7 +98,7 @@ public:
* \param pid The player ID of the killed player.
* \return The refNum of the killer.
*/
static unsigned int GetPlayerKillerRefNum(unsigned short pid) noexcept;
API_FUNCTION unsigned int CDECL GetPlayerKillerRefNum(PlayerId pid) NOEXCEPT;
/**
* \brief Get the mpNum of the actor killer of a certain player.
@ -144,7 +106,7 @@ public:
* \param pid The player ID of the killed player.
* \return The mpNum of the killer.
*/
static unsigned int GetPlayerKillerMpNum(unsigned short pid) noexcept;
API_FUNCTION unsigned int CDECL GetPlayerKillerMpNum(PlayerId pid) NOEXCEPT;
/**
* \brief Get the name of the actor killer of a certain player.
@ -152,7 +114,7 @@ public:
* \param pid The player ID of the killed player.
* \return The name of the killer.
*/
static const char *GetPlayerKillerName(unsigned short pid) noexcept;
API_FUNCTION const char *CDECL GetPlayerKillerName(PlayerId pid) NOEXCEPT;
/**
* \brief Get the draw state of a player (0 for nothing, 1 for drawn weapon,
@ -161,7 +123,7 @@ public:
* \param pid The player ID.
* \return The draw state.
*/
static unsigned int GetDrawState(unsigned short pid) noexcept;
API_FUNCTION unsigned int CDECL GetDrawState(PlayerId pid) NOEXCEPT;
/**
* \brief Get the sneak state of a player.
@ -169,7 +131,7 @@ public:
* \param pid The player ID.
* \return Whether the player is sneaking.
*/
static bool GetSneakState(unsigned short pid) noexcept;
API_FUNCTION bool CDECL GetSneakState(PlayerId pid) NOEXCEPT;
/**
* \brief Set the Mark cell of a player.
@ -184,7 +146,7 @@ public:
* \param cellDescription The cell description.
* \return void
*/
static void SetMarkCell(unsigned short pid, const char *cellDescription) noexcept;
API_FUNCTION void CDECL SetMarkCell(PlayerId pid, const char *cellDescription) NOEXCEPT;
/**
* \brief Set the Mark position of a player.
@ -198,7 +160,7 @@ public:
* \param z The Z position.
* \return void
*/
static void SetMarkPos(unsigned short pid, double x, double y, double z) noexcept;
API_FUNCTION void CDECL SetMarkPos(PlayerId pid, double x, double y, double z) NOEXCEPT;
/**
* \brief Set the Mark rotation of a player.
@ -211,7 +173,7 @@ public:
* \param z The Z rotation.
* \return void
*/
static void SetMarkRot(unsigned short pid, double x, double z) noexcept;
API_FUNCTION void CDECL SetMarkRot(PlayerId pid, double x, double z) NOEXCEPT;
/**
* \brief Set the ID of a player's selected spell.
@ -223,7 +185,7 @@ public:
* \param spellId The spell ID.
* \return void
*/
static void SetSelectedSpellId(unsigned short pid, const char *spellId) noexcept;
API_FUNCTION void CDECL SetSelectedSpellId(PlayerId pid, const char *spellId) NOEXCEPT;
/**
* \brief Send a PlayerMiscellaneous packet with a Mark location to a player.
@ -231,7 +193,7 @@ public:
* \param pid The player ID.
* \return void
*/
static void SendMarkLocation(unsigned short pid);
API_FUNCTION void CDECL SendMarkLocation(PlayerId pid);
/**
* \brief Send a PlayerMiscellaneous packet with a selected spell ID to a player.
@ -239,7 +201,7 @@ public:
* \param pid The player ID.
* \return void
*/
static void SendSelectedSpell(unsigned short pid);
API_FUNCTION void CDECL SendSelectedSpell(PlayerId pid);
/**
* \brief Send a PlayerJail packet about a player.
@ -261,8 +223,8 @@ public:
* \param jailEndText The text that should be displayed once the jailing period is over.
* \return void
*/
static void Jail(unsigned short pid, int jailDays, bool ignoreJailTeleportation, bool ignoreJailSkillIncreases,
const char* jailProgressText, const char* jailEndText) noexcept;
API_FUNCTION void CDECL Jail(PlayerId pid, int jailDays, bool ignoreJailTeleportation, bool ignoreJailSkillIncreases,
const char* jailProgressText, const char* jailEndText) NOEXCEPT;
/**
* \brief Send a PlayerResurrect packet about a player.
@ -274,13 +236,12 @@ public:
* 2 for TRIBUNAL_TEMPLE).
* \return void
*/
static void Resurrect(unsigned short pid, unsigned int type) noexcept;
API_FUNCTION void CDECL Resurrect(PlayerId pid, unsigned int type) NOEXCEPT;
// All methods below are deprecated versions of methods from above
static const char *GetDeathReason(unsigned short pid) noexcept;
static unsigned int GetPlayerKillerRefNumIndex(unsigned short pid) noexcept;
};
API_FUNCTION const char *CDECL GetDeathReason(PlayerId pid) NOEXCEPT;
API_FUNCTION unsigned int CDECL GetPlayerKillerRefNumIndex(PlayerId pid) NOEXCEPT;
NAMESPACE_END()
#endif //OPENMW_MECHANICSAPI_HPP

@ -1,23 +1,59 @@
#include "Miscellaneous.hpp"
#include "Miscellaneous.h"
#include <components/misc/stringops.hpp>
#include <components/openmw-mp/Log.hpp>
#include <apps/openmw-mp/Script/Callbacks.hpp>
#include <apps/openmw-mp/Networking.hpp>
#include <iostream>
using namespace std;
unsigned int MiscellaneousFunctions::GetLastPlayerId() noexcept
static std::string tempFilename;
extern "C" bool MiscellaneousFunctions::DoesFileExist(const char *filePath) noexcept
{
return boost::filesystem::exists(filePath);
}
extern "C" const char *MiscellaneousFunctions::GetCaseInsensitiveFilename(const char *folderPath, const char *filename) noexcept
{
if (!boost::filesystem::exists(folderPath)) return "invalid";
boost::filesystem::directory_iterator end_itr; // default construction yields past-the-end
for (boost::filesystem::directory_iterator itr(folderPath); itr != end_itr; ++itr)
{
if (Misc::StringUtils::ciEqual(itr->path().filename().string(), filename))
{
tempFilename = itr->path().filename().string();
return tempFilename.c_str();
}
}
return "invalid";
}
extern "C" unsigned int MiscellaneousFunctions::GetLastPlayerId() noexcept
{
return Players::getLastPlayerId();
}
int MiscellaneousFunctions::GetCurrentMpNum() noexcept
extern "C" int MiscellaneousFunctions::GetCurrentMpNum() noexcept
{
return mwmp::Networking::getPtr()->getCurrentMpNum();
}
void MiscellaneousFunctions::SetCurrentMpNum(int mpNum) noexcept
extern "C" void MiscellaneousFunctions::SetCurrentMpNum(int mpNum) noexcept
{
mwmp::Networking::getPtr()->setCurrentMpNum(mpNum);
}
extern "C" void MiscellaneousFunctions::LogMessage(unsigned short level, const char *message) noexcept
{
LOG_MESSAGE_SIMPLE(level, "[Script]: %s", message);
}
extern "C" void MiscellaneousFunctions::LogAppend(unsigned short level, const char *message) noexcept
{
LOG_APPEND(level, "[Script]: %s", message);
}

@ -0,0 +1,89 @@
#ifndef OPENMW_MISCELLANEOUSAPI_HPP
#define OPENMW_MISCELLANEOUSAPI_HPP
#include "../api.h"
NAMESPACE_BEGIN(MiscellaneousFunctions)
/**
* \brief Check whether a certain file exists.
*
* This will be a case sensitive check on case sensitive filesystems.
*
* Whenever you want to enforce case insensitivity, use GetCaseInsensitiveFilename() instead.
*
* \return Whether the file exists or not.
*/
API_FUNCTION bool CDECL DoesFileExist(const char *filePath) NOEXCEPT;
/**
* \brief Get the first filename in a folder that has a case insensitive match with the filename
* argument.
*
* This is used to retain case insensitivity when opening data files on Linux.
*
* \return The filename that matches.
*/
API_FUNCTION const char *CDECL GetCaseInsensitiveFilename(const char *folderPath, const char *filename) NOEXCEPT;
/**
* \brief Get the last player ID currently connected to the server.
*
* Every player receives a unique numerical index known as their player ID upon joining the
* server.
*
* \return The player ID.
*/
API_FUNCTION unsigned int CDECL GetLastPlayerId() NOEXCEPT;
/**
* \brief Get the current (latest) mpNum generated by the server.
*
* Every object that did not exist in an .ESM or .ESP data file and has instead been placed or
* spawned through a server-sent packet has a numerical index known as its mpNum.
*
* When ObjectPlace and ObjectSpawn packets are received from players, their objects lack mpNums,
* so the server assigns them some based on incrementing the server's current mpNum, with the
* operation's final mpNum becoming the server's new current mpNum.
*
* \return The mpNum.
*/
API_FUNCTION int CDECL GetCurrentMpNum() NOEXCEPT;
/**
* \brief Set the current (latest) mpNum generated by the server.
*
* When restarting a server, it is important to revert to the previous current (latest) mpNum
* as stored in the server's data, so as to avoid starting over from 0 and ending up assigning
* duplicate mpNums to objects.
*
* \param mpNum The number that should be used as the new current mpNum.
* \return void
*/
API_FUNCTION void CDECL SetCurrentMpNum(int mpNum) NOEXCEPT;
/**
* \brief Write a log message with its own timestamp.
*
* It will have "[Script]:" prepended to it so as to mark it as a script-generated log message.
*
* \param level The logging level used (0 for LOG_VERBOSE, 1 for LOG_INFO, 2 for LOG_WARN,
* 3 for LOG_ERROR, 4 for LOG_FATAL).
* \param message The message logged.
* \return void
*/
API_FUNCTION void CDECL LogMessage(unsigned short level, const char *message) NOEXCEPT;
/**
* \brief Write a log message without its own timestamp.
*
* It will have "[Script]:" prepended to it so as to mark it as a script-generated log message.
*
* \param level The logging level used (0 for LOG_VERBOSE, 1 for LOG_INFO, 2 for LOG_WARN,
* 3 for LOG_ERROR, 4 for LOG_FATAL).
* \param message The message logged.
* \return void
*/
API_FUNCTION void CDECL LogAppend(unsigned short level, const char *message) NOEXCEPT;
NAMESPACE_END()
#endif //OPENMW_MISCELLANEOUSAPI_HPP

@ -1,53 +0,0 @@
#ifndef OPENMW_MISCELLANEOUSAPI_HPP
#define OPENMW_MISCELLANEOUSAPI_HPP
#include "../Types.hpp"
#define MISCELLANEOUSAPI \
{"GetLastPlayerId", MiscellaneousFunctions::GetLastPlayerId},\
\
{"GetCurrentMpNum", MiscellaneousFunctions::GetCurrentMpNum},\
{"SetCurrentMpNum", MiscellaneousFunctions::SetCurrentMpNum}
class MiscellaneousFunctions
{
public:
/**
* \brief Get the last player ID currently connected to the server.
*
* Every player receives a unique numerical index known as their player ID upon joining the
* server.
*
* \return The player ID.
*/
static unsigned int GetLastPlayerId() noexcept;
/**
* \brief Get the current (latest) mpNum generated by the server.
*
* Every object that did not exist in an .ESM or .ESP data file and has instead been placed or
* spawned through a server-sent packet has a numerical index known as its mpNum.
*
* When ObjectPlace and ObjectSpawn packets are received from players, their objects lack mpNums,
* so the server assigns them some based on incrementing the server's current mpNum, with the
* operation's final mpNum becoming the server's new current mpNum.
*
* \return The mpNum.
*/
static int GetCurrentMpNum() noexcept;
/**
* \brief Set the current (latest) mpNum generated by the server.
*
* When restarting a server, it is important to revert to the previous current (latest) mpNum
* as stored in the server's data, so as to avoid starting over from 0 and ending up assigning
* duplicate mpNums to objects.
*
* \param mpNum The number that should be used as the new current mpNum.
* \return void
*/
static void SetCurrentMpNum(int mpNum) noexcept;
};
#endif //OPENMW_MISCELLANEOUSAPI_HPP

@ -4,9 +4,9 @@
#include <apps/openmw-mp/Networking.hpp>
#include <apps/openmw-mp/Player.hpp>
#include <apps/openmw-mp/Utils.hpp>
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
#include <apps/openmw-mp/Script/Callbacks.hpp>
#include "Objects.hpp"
#include "Objects.h"
using namespace mwmp;
@ -19,19 +19,19 @@ const BaseObject emptyObject = {};
ContainerItem tempContainerItem;
const ContainerItem emptyContainerItem = {};
void ObjectFunctions::ReadReceivedObjectList() noexcept
extern "C" void ObjectFunctions::ReadReceivedObjectList() noexcept
{
readObjectList = mwmp::Networking::getPtr()->getReceivedObjectList();
}
void ObjectFunctions::ClearObjectList() noexcept
extern "C" void ObjectFunctions::ClearObjectList() noexcept
{
writeObjectList.cell.blank();
writeObjectList.baseObjects.clear();
writeObjectList.packetOrigin = mwmp::PACKET_ORIGIN::SERVER_SCRIPT;
}
void ObjectFunctions::SetObjectListPid(unsigned short pid) noexcept
extern "C" void ObjectFunctions::SetObjectListPid(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -39,42 +39,42 @@ void ObjectFunctions::SetObjectListPid(unsigned short pid) noexcept
writeObjectList.guid = player->guid;
}
void ObjectFunctions::CopyReceivedObjectListToStore() noexcept
extern "C" void ObjectFunctions::CopyReceivedObjectListToStore() noexcept
{
writeObjectList = *readObjectList;
}
unsigned int ObjectFunctions::GetObjectListSize() noexcept
extern "C" unsigned int ObjectFunctions::GetObjectListSize() noexcept
{
return readObjectList->baseObjectCount;
}
unsigned char ObjectFunctions::GetObjectListOrigin() noexcept
extern "C" unsigned char ObjectFunctions::GetObjectListOrigin() noexcept
{
return readObjectList->packetOrigin;
}
const char *ObjectFunctions::GetObjectListClientScript() noexcept
extern "C" const char *ObjectFunctions::GetObjectListClientScript() noexcept
{
return readObjectList->originClientScript.c_str();
}
unsigned char ObjectFunctions::GetObjectListAction() noexcept
extern "C" unsigned char ObjectFunctions::GetObjectListAction() noexcept
{
return readObjectList->action;
}
unsigned char ObjectFunctions::GetObjectListContainerSubAction() noexcept
extern "C" unsigned char ObjectFunctions::GetObjectListContainerSubAction() noexcept
{
return readObjectList->containerSubAction;
}
bool ObjectFunctions::IsObjectPlayer(unsigned int index) noexcept
extern "C" bool ObjectFunctions::IsObjectPlayer(unsigned int index) noexcept
{
return readObjectList->baseObjects.at(index).isPlayer;
}
int ObjectFunctions::GetObjectPid(unsigned int index) noexcept
extern "C" int ObjectFunctions::GetObjectPid(unsigned int index) noexcept
{
Player *player = Players::getPlayer(readObjectList->baseObjects.at(index).guid);
@ -84,72 +84,72 @@ int ObjectFunctions::GetObjectPid(unsigned int index) noexcept
return -1;
}
const char *ObjectFunctions::GetObjectRefId(unsigned int index) noexcept
extern "C" const char *ObjectFunctions::GetObjectRefId(unsigned int index) noexcept
{
return readObjectList->baseObjects.at(index).refId.c_str();
}
unsigned int ObjectFunctions::GetObjectRefNum(unsigned int index) noexcept
extern "C" unsigned int ObjectFunctions::GetObjectRefNum(unsigned int index) noexcept
{
return readObjectList->baseObjects.at(index).refNum;
}
unsigned int ObjectFunctions::GetObjectMpNum(unsigned int index) noexcept
extern "C" unsigned int ObjectFunctions::GetObjectMpNum(unsigned int index) noexcept
{
return readObjectList->baseObjects.at(index).mpNum;
}
int ObjectFunctions::GetObjectCount(unsigned int index) noexcept
extern "C" int ObjectFunctions::GetObjectCount(unsigned int index) noexcept
{
return readObjectList->baseObjects.at(index).count;
}
int ObjectFunctions::GetObjectCharge(unsigned int index) noexcept
extern "C" int ObjectFunctions::GetObjectCharge(unsigned int index) noexcept
{
return readObjectList->baseObjects.at(index).charge;
}
double ObjectFunctions::GetObjectEnchantmentCharge(unsigned int index) noexcept
extern "C" double ObjectFunctions::GetObjectEnchantmentCharge(unsigned int index) noexcept
{
return readObjectList->baseObjects.at(index).enchantmentCharge;
}
const char *ObjectFunctions::GetObjectSoul(unsigned int index) noexcept
extern "C" const char *ObjectFunctions::GetObjectSoul(unsigned int index) noexcept
{
return readObjectList->baseObjects.at(index).soul.c_str();
}
int ObjectFunctions::GetObjectGoldValue(unsigned int index) noexcept
extern "C" int ObjectFunctions::GetObjectGoldValue(unsigned int index) noexcept
{
return readObjectList->baseObjects.at(index).goldValue;
}
double ObjectFunctions::GetObjectScale(unsigned int index) noexcept
extern "C" double ObjectFunctions::GetObjectScale(unsigned int index) noexcept
{
return readObjectList->baseObjects.at(index).scale;
}
bool ObjectFunctions::GetObjectState(unsigned int index) noexcept
extern "C" bool ObjectFunctions::GetObjectState(unsigned int index) noexcept
{
return readObjectList->baseObjects.at(index).objectState;
}
int ObjectFunctions::GetObjectDoorState(unsigned int index) noexcept
extern "C" int ObjectFunctions::GetObjectDoorState(unsigned int index) noexcept
{
return readObjectList->baseObjects.at(index).doorState;
}
int ObjectFunctions::GetObjectLockLevel(unsigned int index) noexcept
extern "C" int ObjectFunctions::GetObjectLockLevel(unsigned int index) noexcept
{
return readObjectList->baseObjects.at(index).lockLevel;
}
bool ObjectFunctions::DoesObjectHavePlayerActivating(unsigned int index) noexcept
extern "C" bool ObjectFunctions::DoesObjectHavePlayerActivating(unsigned int index) noexcept
{
return readObjectList->baseObjects.at(index).activatingActor.isPlayer;
}
int ObjectFunctions::GetObjectActivatingPid(unsigned int index) noexcept
extern "C" int ObjectFunctions::GetObjectActivatingPid(unsigned int index) noexcept
{
Player *player = Players::getPlayer(readObjectList->baseObjects.at(index).activatingActor.guid);
@ -159,42 +159,42 @@ int ObjectFunctions::GetObjectActivatingPid(unsigned int index) noexcept
return -1;
}
const char *ObjectFunctions::GetObjectActivatingRefId(unsigned int index) noexcept
extern "C" const char *ObjectFunctions::GetObjectActivatingRefId(unsigned int index) noexcept
{
return readObjectList->baseObjects.at(index).activatingActor.refId.c_str();
}
unsigned int ObjectFunctions::GetObjectActivatingRefNum(unsigned int index) noexcept
extern "C" unsigned int ObjectFunctions::GetObjectActivatingRefNum(unsigned int index) noexcept
{
return readObjectList->baseObjects.at(index).activatingActor.refNum;
}
unsigned int ObjectFunctions::GetObjectActivatingMpNum(unsigned int index) noexcept
extern "C" unsigned int ObjectFunctions::GetObjectActivatingMpNum(unsigned int index) noexcept
{
return readObjectList->baseObjects.at(index).activatingActor.mpNum;
}
const char *ObjectFunctions::GetObjectActivatingName(unsigned int index) noexcept
extern "C" const char *ObjectFunctions::GetObjectActivatingName(unsigned int index) noexcept
{
return readObjectList->baseObjects.at(index).activatingActor.name.c_str();
}
bool ObjectFunctions::GetObjectSummonState(unsigned int index) noexcept
extern "C" bool ObjectFunctions::GetObjectSummonState(unsigned int index) noexcept
{
return readObjectList->baseObjects.at(index).isSummon;
}
double ObjectFunctions::GetObjectSummonDuration(unsigned int index) noexcept
extern "C" double ObjectFunctions::GetObjectSummonDuration(unsigned int index) noexcept
{
return readObjectList->baseObjects.at(index).summonDuration;
}
bool ObjectFunctions::DoesObjectHavePlayerSummoner(unsigned int index) noexcept
extern "C" bool ObjectFunctions::DoesObjectHavePlayerSummoner(unsigned int index) noexcept
{
return readObjectList->baseObjects.at(index).master.isPlayer;
}
int ObjectFunctions::GetObjectSummonerPid(unsigned int index) noexcept
extern "C" int ObjectFunctions::GetObjectSummonerPid(unsigned int index) noexcept
{
Player *player = Players::getPlayer(readObjectList->baseObjects.at(index).master.guid);
@ -204,202 +204,202 @@ int ObjectFunctions::GetObjectSummonerPid(unsigned int index) noexcept
return -1;
}
const char *ObjectFunctions::GetObjectSummonerRefId(unsigned int index) noexcept
extern "C" const char *ObjectFunctions::GetObjectSummonerRefId(unsigned int index) noexcept
{
return readObjectList->baseObjects.at(index).master.refId.c_str();
}
unsigned int ObjectFunctions::GetObjectSummonerRefNum(unsigned int index) noexcept
extern "C" unsigned int ObjectFunctions::GetObjectSummonerRefNum(unsigned int index) noexcept
{
return readObjectList->baseObjects.at(index).master.refNum;
}
unsigned int ObjectFunctions::GetObjectSummonerMpNum(unsigned int index) noexcept
extern "C" unsigned int ObjectFunctions::GetObjectSummonerMpNum(unsigned int index) noexcept
{
return readObjectList->baseObjects.at(index).master.mpNum;
}
double ObjectFunctions::GetObjectPosX(unsigned int index) noexcept
extern "C" double ObjectFunctions::GetObjectPosX(unsigned int index) noexcept
{
return readObjectList->baseObjects.at(index).position.pos[0];
}
double ObjectFunctions::GetObjectPosY(unsigned int index) noexcept
extern "C" double ObjectFunctions::GetObjectPosY(unsigned int index) noexcept
{
return readObjectList->baseObjects.at(index).position.pos[1];
}
double ObjectFunctions::GetObjectPosZ(unsigned int index) noexcept
extern "C" double ObjectFunctions::GetObjectPosZ(unsigned int index) noexcept
{
return readObjectList->baseObjects.at(index).position.pos[2];
}
double ObjectFunctions::GetObjectRotX(unsigned int index) noexcept
extern "C" double ObjectFunctions::GetObjectRotX(unsigned int index) noexcept
{
return readObjectList->baseObjects.at(index).position.rot[0];
}
double ObjectFunctions::GetObjectRotY(unsigned int index) noexcept
extern "C" double ObjectFunctions::GetObjectRotY(unsigned int index) noexcept
{
return readObjectList->baseObjects.at(index).position.rot[1];
}
double ObjectFunctions::GetObjectRotZ(unsigned int index) noexcept
extern "C" double ObjectFunctions::GetObjectRotZ(unsigned int index) noexcept
{
return readObjectList->baseObjects.at(index).position.rot[2];
}
const char *ObjectFunctions::GetVideoFilename(unsigned int index) noexcept
extern "C" const char *ObjectFunctions::GetVideoFilename(unsigned int index) noexcept
{
return readObjectList->baseObjects.at(index).videoFilename.c_str();
}
unsigned int ObjectFunctions::GetContainerChangesSize(unsigned int objectIndex) noexcept
extern "C" unsigned int ObjectFunctions::GetContainerChangesSize(unsigned int objectIndex) noexcept
{
return readObjectList->baseObjects.at(objectIndex).containerItemCount;
}
const char *ObjectFunctions::GetContainerItemRefId(unsigned int objectIndex, unsigned int itemIndex) noexcept
extern "C" const char *ObjectFunctions::GetContainerItemRefId(unsigned int objectIndex, unsigned int itemIndex) noexcept
{
return readObjectList->baseObjects.at(objectIndex)
.containerItems.at(itemIndex).refId.c_str();
}
int ObjectFunctions::GetContainerItemCount(unsigned int objectIndex, unsigned int itemIndex) noexcept
extern "C" int ObjectFunctions::GetContainerItemCount(unsigned int objectIndex, unsigned int itemIndex) noexcept
{
return readObjectList->baseObjects.at(objectIndex)
.containerItems.at(itemIndex).count;
}
int ObjectFunctions::GetContainerItemCharge(unsigned int objectIndex, unsigned int itemIndex) noexcept
extern "C" int ObjectFunctions::GetContainerItemCharge(unsigned int objectIndex, unsigned int itemIndex) noexcept
{
return readObjectList->baseObjects.at(objectIndex)
.containerItems.at(itemIndex).charge;
}
double ObjectFunctions::GetContainerItemEnchantmentCharge(unsigned int objectIndex, unsigned int itemIndex) noexcept
extern "C" double ObjectFunctions::GetContainerItemEnchantmentCharge(unsigned int objectIndex, unsigned int itemIndex) noexcept
{
return readObjectList->baseObjects.at(objectIndex)
.containerItems.at(itemIndex).enchantmentCharge;
}
const char *ObjectFunctions::GetContainerItemSoul(unsigned int objectIndex, unsigned int itemIndex) noexcept
extern "C" const char *ObjectFunctions::GetContainerItemSoul(unsigned int objectIndex, unsigned int itemIndex) noexcept
{
return readObjectList->baseObjects.at(objectIndex)
.containerItems.at(itemIndex).soul.c_str();
}
int ObjectFunctions::GetContainerItemActionCount(unsigned int objectIndex, unsigned int itemIndex) noexcept
extern "C" int ObjectFunctions::GetContainerItemActionCount(unsigned int objectIndex, unsigned int itemIndex) noexcept
{
return readObjectList->baseObjects.at(objectIndex)
.containerItems.at(itemIndex).actionCount;
}
bool ObjectFunctions::DoesObjectHaveContainer(unsigned int index) noexcept
extern "C" bool ObjectFunctions::DoesObjectHaveContainer(unsigned int index) noexcept
{
return readObjectList->baseObjects.at(index).hasContainer;
}
void ObjectFunctions::SetObjectListCell(const char* cellDescription) noexcept
extern "C" void ObjectFunctions::SetObjectListCell(const char* cellDescription) noexcept
{
writeObjectList.cell = Utils::getCellFromDescription(cellDescription);
}
void ObjectFunctions::SetObjectListAction(unsigned char action) noexcept
extern "C" void ObjectFunctions::SetObjectListAction(unsigned char action) noexcept
{
writeObjectList.action = action;
}
void ObjectFunctions::SetObjectListConsoleCommand(const char* consoleCommand) noexcept
extern "C" void ObjectFunctions::SetObjectListConsoleCommand(const char* consoleCommand) noexcept
{
writeObjectList.consoleCommand = consoleCommand;
}
void ObjectFunctions::SetObjectRefId(const char* refId) noexcept
extern "C" void ObjectFunctions::SetObjectRefId(const char* refId) noexcept
{
tempObject.refId = refId;
}
void ObjectFunctions::SetObjectRefNum(int refNum) noexcept
extern "C" void ObjectFunctions::SetObjectRefNum(int refNum) noexcept
{
tempObject.refNum = refNum;
}
void ObjectFunctions::SetObjectMpNum(int mpNum) noexcept
extern "C" void ObjectFunctions::SetObjectMpNum(int mpNum) noexcept
{
tempObject.mpNum = mpNum;
}
void ObjectFunctions::SetObjectCount(int count) noexcept
extern "C" void ObjectFunctions::SetObjectCount(int count) noexcept
{
tempObject.count = count;
}
void ObjectFunctions::SetObjectCharge(int charge) noexcept
extern "C" void ObjectFunctions::SetObjectCharge(int charge) noexcept
{
tempObject.charge = charge;
}
void ObjectFunctions::SetObjectEnchantmentCharge(double enchantmentCharge) noexcept
extern "C" void ObjectFunctions::SetObjectEnchantmentCharge(double enchantmentCharge) noexcept
{
tempObject.enchantmentCharge = enchantmentCharge;
}
void ObjectFunctions::SetObjectSoul(const char* soul) noexcept
extern "C" void ObjectFunctions::SetObjectSoul(const char* soul) noexcept
{
tempObject.soul = soul;
}
void ObjectFunctions::SetObjectGoldValue(int goldValue) noexcept
extern "C" void ObjectFunctions::SetObjectGoldValue(int goldValue) noexcept
{
tempObject.goldValue = goldValue;
}
void ObjectFunctions::SetObjectScale(double scale) noexcept
extern "C" void ObjectFunctions::SetObjectScale(double scale) noexcept
{
tempObject.scale = scale;
}
void ObjectFunctions::SetObjectState(bool objectState) noexcept
extern "C" void ObjectFunctions::SetObjectState(bool objectState) noexcept
{
tempObject.objectState = objectState;
}
void ObjectFunctions::SetObjectLockLevel(int lockLevel) noexcept
extern "C" void ObjectFunctions::SetObjectLockLevel(int lockLevel) noexcept
{
tempObject.lockLevel = lockLevel;
}
void ObjectFunctions::SetObjectSummonDuration(float summonDuration) noexcept
extern "C" void ObjectFunctions::SetObjectSummonDuration(float summonDuration) noexcept
{
tempObject.summonDuration = summonDuration;
}
void ObjectFunctions::SetObjectDisarmState(bool disarmState) noexcept
extern "C" void ObjectFunctions::SetObjectDisarmState(bool disarmState) noexcept
{
tempObject.isDisarmed = disarmState;
}
void ObjectFunctions::SetObjectSummonState(bool summonState) noexcept
extern "C" void ObjectFunctions::SetObjectSummonState(bool summonState) noexcept
{
tempObject.isSummon = summonState;
}
void ObjectFunctions::SetObjectPosition(double x, double y, double z) noexcept
extern "C" void ObjectFunctions::SetObjectPosition(double x, double y, double z) noexcept
{
tempObject.position.pos[0] = x;
tempObject.position.pos[1] = y;
tempObject.position.pos[2] = z;
}
void ObjectFunctions::SetObjectRotation(double x, double y, double z) noexcept
extern "C" void ObjectFunctions::SetObjectRotation(double x, double y, double z) noexcept
{
tempObject.position.rot[0] = x;
tempObject.position.rot[1] = y;
tempObject.position.rot[2] = z;
}
void ObjectFunctions::SetObjectActivatingPid(unsigned short pid) noexcept
extern "C" void ObjectFunctions::SetObjectActivatingPid(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -408,35 +408,35 @@ void ObjectFunctions::SetObjectActivatingPid(unsigned short pid) noexcept
tempObject.activatingActor.isPlayer = true;
}
void ObjectFunctions::SetObjectDoorState(int doorState) noexcept
extern "C" void ObjectFunctions::SetObjectDoorState(int doorState) noexcept
{
tempObject.doorState = doorState;
}
void ObjectFunctions::SetObjectDoorTeleportState(bool teleportState) noexcept
extern "C" void ObjectFunctions::SetObjectDoorTeleportState(bool teleportState) noexcept
{
tempObject.teleportState = teleportState;
}
void ObjectFunctions::SetObjectDoorDestinationCell(const char* cellDescription) noexcept
extern "C" void ObjectFunctions::SetObjectDoorDestinationCell(const char* cellDescription) noexcept
{
tempObject.destinationCell = Utils::getCellFromDescription(cellDescription);
}
void ObjectFunctions::SetObjectDoorDestinationPosition(double x, double y, double z) noexcept
extern "C" void ObjectFunctions::SetObjectDoorDestinationPosition(double x, double y, double z) noexcept
{
tempObject.destinationPosition.pos[0] = x;
tempObject.destinationPosition.pos[1] = y;
tempObject.destinationPosition.pos[2] = z;
}
void ObjectFunctions::SetObjectDoorDestinationRotation(double x, double z) noexcept
extern "C" void ObjectFunctions::SetObjectDoorDestinationRotation(double x, double z) noexcept
{
tempObject.destinationPosition.rot[0] = x;
tempObject.destinationPosition.rot[2] = z;
}
void ObjectFunctions::SetPlayerAsObject(unsigned short pid) noexcept
extern "C" void ObjectFunctions::SetPlayerAsObject(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -445,37 +445,37 @@ void ObjectFunctions::SetPlayerAsObject(unsigned short pid) noexcept
tempObject.isPlayer = true;
}
void ObjectFunctions::SetContainerItemRefId(const char* refId) noexcept
extern "C" void ObjectFunctions::SetContainerItemRefId(const char* refId) noexcept
{
tempContainerItem.refId = refId;
}
void ObjectFunctions::SetContainerItemCount(int count) noexcept
extern "C" void ObjectFunctions::SetContainerItemCount(int count) noexcept
{
tempContainerItem.count = count;
}
void ObjectFunctions::SetContainerItemCharge(int charge) noexcept
extern "C" void ObjectFunctions::SetContainerItemCharge(int charge) noexcept
{
tempContainerItem.charge = charge;
}
void ObjectFunctions::SetContainerItemEnchantmentCharge(double enchantmentCharge) noexcept
extern "C" void ObjectFunctions::SetContainerItemEnchantmentCharge(double enchantmentCharge) noexcept
{
tempContainerItem.enchantmentCharge = enchantmentCharge;
}
void ObjectFunctions::SetContainerItemSoul(const char* soul) noexcept
extern "C" void ObjectFunctions::SetContainerItemSoul(const char* soul) noexcept
{
tempContainerItem.soul = soul;
}
void ObjectFunctions::SetContainerItemActionCountByIndex(unsigned int objectIndex, unsigned int itemIndex, int actionCount) noexcept
extern "C" void ObjectFunctions::SetContainerItemActionCountByIndex(unsigned int objectIndex, unsigned int itemIndex, int actionCount) noexcept
{
writeObjectList.baseObjects.at(objectIndex).containerItems.at(itemIndex).actionCount = actionCount;
}
void ObjectFunctions::AddObject() noexcept
extern "C" void ObjectFunctions::AddObject() noexcept
{
tempObject.droppedByPlayer = false;
writeObjectList.baseObjects.push_back(tempObject);
@ -483,14 +483,14 @@ void ObjectFunctions::AddObject() noexcept
tempObject = emptyObject;
}
void ObjectFunctions::AddContainerItem() noexcept
extern "C" void ObjectFunctions::AddContainerItem() noexcept
{
tempObject.containerItems.push_back(tempContainerItem);
tempContainerItem = emptyContainerItem;
}
void ObjectFunctions::SendObjectActivate(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
extern "C" void ObjectFunctions::SendObjectActivate(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
{
mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_OBJECT_ACTIVATE);
packet->setObjectList(&writeObjectList);
@ -501,7 +501,7 @@ void ObjectFunctions::SendObjectActivate(bool sendToOtherPlayers, bool skipAttac
packet->Send(true);
}
void ObjectFunctions::SendObjectPlace(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
extern "C" void ObjectFunctions::SendObjectPlace(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
{
mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_OBJECT_PLACE);
packet->setObjectList(&writeObjectList);
@ -512,7 +512,7 @@ void ObjectFunctions::SendObjectPlace(bool sendToOtherPlayers, bool skipAttached
packet->Send(true);
}
void ObjectFunctions::SendObjectSpawn(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
extern "C" void ObjectFunctions::SendObjectSpawn(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
{
mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_OBJECT_SPAWN);
packet->setObjectList(&writeObjectList);
@ -523,7 +523,7 @@ void ObjectFunctions::SendObjectSpawn(bool sendToOtherPlayers, bool skipAttached
packet->Send(true);
}
void ObjectFunctions::SendObjectDelete(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
extern "C" void ObjectFunctions::SendObjectDelete(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
{
mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_OBJECT_DELETE);
packet->setObjectList(&writeObjectList);
@ -534,7 +534,7 @@ void ObjectFunctions::SendObjectDelete(bool sendToOtherPlayers, bool skipAttache
packet->Send(true);
}
void ObjectFunctions::SendObjectLock(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
extern "C" void ObjectFunctions::SendObjectLock(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
{
mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_OBJECT_LOCK);
packet->setObjectList(&writeObjectList);
@ -545,7 +545,7 @@ void ObjectFunctions::SendObjectLock(bool sendToOtherPlayers, bool skipAttachedP
packet->Send(true);
}
void ObjectFunctions::SendObjectTrap(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
extern "C" void ObjectFunctions::SendObjectTrap(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
{
mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_OBJECT_TRAP);
packet->setObjectList(&writeObjectList);
@ -556,7 +556,7 @@ void ObjectFunctions::SendObjectTrap(bool sendToOtherPlayers, bool skipAttachedP
packet->Send(true);
}
void ObjectFunctions::SendObjectScale(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
extern "C" void ObjectFunctions::SendObjectScale(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
{
mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_OBJECT_SCALE);
packet->setObjectList(&writeObjectList);
@ -567,7 +567,7 @@ void ObjectFunctions::SendObjectScale(bool sendToOtherPlayers, bool skipAttached
packet->Send(true);
}
void ObjectFunctions::SendObjectState(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
extern "C" void ObjectFunctions::SendObjectState(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
{
mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_OBJECT_STATE);
packet->setObjectList(&writeObjectList);
@ -578,7 +578,7 @@ void ObjectFunctions::SendObjectState(bool sendToOtherPlayers, bool skipAttached
packet->Send(true);
}
void ObjectFunctions::SendDoorState(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
extern "C" void ObjectFunctions::SendDoorState(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
{
mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_DOOR_STATE);
packet->setObjectList(&writeObjectList);
@ -589,7 +589,7 @@ void ObjectFunctions::SendDoorState(bool sendToOtherPlayers, bool skipAttachedPl
packet->Send(true);
}
void ObjectFunctions::SendDoorDestination(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
extern "C" void ObjectFunctions::SendDoorDestination(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
{
mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_DOOR_DESTINATION);
packet->setObjectList(&writeObjectList);
@ -600,7 +600,7 @@ void ObjectFunctions::SendDoorDestination(bool sendToOtherPlayers, bool skipAtta
packet->Send(true);
}
void ObjectFunctions::SendContainer(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
extern "C" void ObjectFunctions::SendContainer(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
{
mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_CONTAINER);
packet->setObjectList(&writeObjectList);
@ -611,7 +611,7 @@ void ObjectFunctions::SendContainer(bool sendToOtherPlayers, bool skipAttachedPl
packet->Send(true);
}
void ObjectFunctions::SendVideoPlay(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
extern "C" void ObjectFunctions::SendVideoPlay(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
{
mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_VIDEO_PLAY);
packet->setObjectList(&writeObjectList);
@ -622,7 +622,7 @@ void ObjectFunctions::SendVideoPlay(bool sendToOtherPlayers, bool skipAttachedPl
packet->Send(true);
}
void ObjectFunctions::SendConsoleCommand(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
extern "C" void ObjectFunctions::SendConsoleCommand(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
{
mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_CONSOLE_COMMAND);
packet->setObjectList(&writeObjectList);
@ -633,7 +633,7 @@ void ObjectFunctions::SendConsoleCommand(bool sendToOtherPlayers, bool skipAttac
packet->Send(true);
}
extern "C"
// All methods below are deprecated versions of methods from above
void ObjectFunctions::ReadLastObjectList() noexcept
@ -641,73 +641,73 @@ void ObjectFunctions::ReadLastObjectList() noexcept
ReadReceivedObjectList();
}
void ObjectFunctions::ReadLastEvent() noexcept
extern "C" void ObjectFunctions::ReadLastEvent() noexcept
{
ReadReceivedObjectList();
}
void ObjectFunctions::InitializeObjectList(unsigned short pid) noexcept
extern "C" void ObjectFunctions::InitializeObjectList(PlayerId pid) noexcept
{
ClearObjectList();
SetObjectListPid(pid);
}
void ObjectFunctions::InitializeEvent(unsigned short pid) noexcept
extern "C" void ObjectFunctions::InitializeEvent(PlayerId pid) noexcept
{
InitializeObjectList(pid);
}
void ObjectFunctions::CopyLastObjectListToStore() noexcept
extern "C" void ObjectFunctions::CopyLastObjectListToStore() noexcept
{
CopyReceivedObjectListToStore();
}
unsigned int ObjectFunctions::GetObjectChangesSize() noexcept
extern "C" unsigned int ObjectFunctions::GetObjectChangesSize() noexcept
{
return GetObjectListSize();
}
unsigned char ObjectFunctions::GetEventAction() noexcept
extern "C" unsigned char ObjectFunctions::GetEventAction() noexcept
{
return GetObjectListAction();
}
unsigned char ObjectFunctions::GetEventContainerSubAction() noexcept
extern "C" unsigned char ObjectFunctions::GetEventContainerSubAction() noexcept
{
return GetObjectListContainerSubAction();
}
unsigned int ObjectFunctions::GetObjectRefNumIndex(unsigned int index) noexcept
extern "C" unsigned int ObjectFunctions::GetObjectRefNumIndex(unsigned int index) noexcept
{
return GetObjectRefNum(index);
}
unsigned int ObjectFunctions::GetObjectSummonerRefNumIndex(unsigned int index) noexcept
extern "C" unsigned int ObjectFunctions::GetObjectSummonerRefNumIndex(unsigned int index) noexcept
{
return GetObjectSummonerRefNum(index);
}
void ObjectFunctions::SetEventCell(const char* cellDescription) noexcept
extern "C" void ObjectFunctions::SetEventCell(const char* cellDescription) noexcept
{
SetObjectListCell(cellDescription);
}
void ObjectFunctions::SetEventAction(unsigned char action) noexcept
extern "C" void ObjectFunctions::SetEventAction(unsigned char action) noexcept
{
SetObjectListAction(action);
}
void ObjectFunctions::SetEventConsoleCommand(const char* consoleCommand) noexcept
extern "C" void ObjectFunctions::SetEventConsoleCommand(const char* consoleCommand) noexcept
{
SetObjectListConsoleCommand(consoleCommand);
}
void ObjectFunctions::SetObjectRefNumIndex(int refNum) noexcept
extern "C" void ObjectFunctions::SetObjectRefNumIndex(int refNum) noexcept
{
SetObjectRefNum(refNum);
}
void ObjectFunctions::AddWorldObject() noexcept
extern "C" void ObjectFunctions::AddWorldObject() noexcept
{
AddObject();
}

@ -1,6 +1,8 @@
#ifndef OPENMW_OBJECTAPI_HPP
#define OPENMW_OBJECTAPI_HPP
#include "../api.h"
#define OBJECTAPI \
{"ReadReceivedObjectList", ObjectFunctions::ReadReceivedObjectList},\
\
@ -136,23 +138,20 @@
{"SetObjectRefNumIndex", ObjectFunctions::SetObjectRefNumIndex},\
{"AddWorldObject", ObjectFunctions::AddWorldObject}
class ObjectFunctions
{
public:
NAMESPACE_BEGIN(ObjectFunctions)
/**
* \brief Use the last object list received by the server as the one being read.
*
* \return void
*/
static void ReadReceivedObjectList() noexcept;
API_FUNCTION void CDECL ReadReceivedObjectList() NOEXCEPT;
/**
* \brief Clear the data from the object list stored on the server.
*
* \return void
*/
static void ClearObjectList() noexcept;
API_FUNCTION void CDECL ClearObjectList() NOEXCEPT;
/**
* \brief Set the pid attached to the ObjectList.
@ -160,7 +159,7 @@ public:
* \param pid The player ID to whom the object list should be attached.
* \return void
*/
static void SetObjectListPid(unsigned short pid) noexcept;
API_FUNCTION void CDECL SetObjectListPid(PlayerId pid) NOEXCEPT;
/**
* \brief Take the contents of the read-only object list last received by the
@ -169,14 +168,14 @@ public:
*
* \return void
*/
static void CopyReceivedObjectListToStore() noexcept;
API_FUNCTION void CDECL CopyReceivedObjectListToStore() NOEXCEPT;
/**
* \brief Get the number of indexes in the read object list.
*
* \return The number of indexes.
*/
static unsigned int GetObjectListSize() noexcept;
API_FUNCTION unsigned int CDECL GetObjectListSize() NOEXCEPT;
/**
* \brief Get the origin of the read object list.
@ -185,7 +184,7 @@ public:
* CLIENT_DIALOGUE, 3 for CLIENT_SCRIPT_LOCAL, 4 for CLIENT_SCRIPT_GLOBAL,
* 5 for SERVER_SCRIPT).
*/
static unsigned char GetObjectListOrigin() noexcept;
API_FUNCTION unsigned char CDECL GetObjectListOrigin() NOEXCEPT;
/**
* \brief Get the client script that the read object list originated from.
@ -194,21 +193,21 @@ public:
*
* \return The ID of the client script.
*/
static const char *GetObjectListClientScript() noexcept;
API_FUNCTION const char *CDECL GetObjectListClientScript() NOEXCEPT;
/**
* \brief Get the action type used in the read object list.
*
* \return The action type (0 for SET, 1 for ADD, 2 for REMOVE, 3 for REQUEST).
*/
static unsigned char GetObjectListAction() noexcept;
API_FUNCTION unsigned char CDECL GetObjectListAction() NOEXCEPT;
/**
* \brief Get the container subaction type used in the read object list.
*
* \return The action type (0 for NONE, 1 for DRAG, 2 for DROP, 3 for TAKE_ALL).
*/
static unsigned char GetObjectListContainerSubAction() noexcept;
API_FUNCTION unsigned char CDECL GetObjectListContainerSubAction() NOEXCEPT;
/**
* \brief Check whether the object at a certain index in the read object list is a
@ -221,7 +220,7 @@ public:
* \param index The index of the object.
* \return Whether the object is a player.
*/
static bool IsObjectPlayer(unsigned int index) noexcept;
API_FUNCTION bool CDECL IsObjectPlayer(unsigned int index) NOEXCEPT;
/**
* \brief Get the player ID of the object at a certain index in the read object list,
@ -233,7 +232,7 @@ public:
* \param index The index of the object.
* \return The player ID of the object.
*/
static int GetObjectPid(unsigned int index) noexcept;
API_FUNCTION int CDECL GetObjectPid(unsigned int index) NOEXCEPT;
/**
* \brief Get the refId of the object at a certain index in the read object list.
@ -241,7 +240,7 @@ public:
* \param index The index of the object.
* \return The refId.
*/
static const char *GetObjectRefId(unsigned int index) noexcept;
API_FUNCTION const char *CDECL GetObjectRefId(unsigned int index) NOEXCEPT;
/**
* \brief Get the refNum of the object at a certain index in the read object list.
@ -249,7 +248,7 @@ public:
* \param index The index of the object.
* \return The refNum.
*/
static unsigned int GetObjectRefNum(unsigned int index) noexcept;
API_FUNCTION unsigned int CDECL GetObjectRefNum(unsigned int index) NOEXCEPT;
/**
* \brief Get the mpNum of the object at a certain index in the read object list.
@ -257,7 +256,7 @@ public:
* \param index The index of the object.
* \return The mpNum.
*/
static unsigned int GetObjectMpNum(unsigned int index) noexcept;
API_FUNCTION unsigned int CDECL GetObjectMpNum(unsigned int index) NOEXCEPT;
/**
* \brief Get the count of the object at a certain index in the read object list.
@ -265,7 +264,7 @@ public:
* \param index The index of the object.
* \return The object count.
*/
static int GetObjectCount(unsigned int index) noexcept;
API_FUNCTION int CDECL GetObjectCount(unsigned int index) NOEXCEPT;
/**
* \brief Get the charge of the object at a certain index in the read object list.
@ -273,7 +272,7 @@ public:
* \param index The index of the object.
* \return The charge.
*/
static int GetObjectCharge(unsigned int index) noexcept;
API_FUNCTION int CDECL GetObjectCharge(unsigned int index) NOEXCEPT;
/**
* \brief Get the enchantment charge of the object at a certain index in the read object list.
@ -281,7 +280,7 @@ public:
* \param index The index of the object.
* \return The enchantment charge.
*/
static double GetObjectEnchantmentCharge(unsigned int index) noexcept;
API_FUNCTION double CDECL GetObjectEnchantmentCharge(unsigned int index) NOEXCEPT;
/**
* \brief Get the soul of the object at a certain index in the read object list.
@ -289,7 +288,7 @@ public:
* \param index The index of the object.
* \return The soul.
*/
static const char *GetObjectSoul(unsigned int index) noexcept;
API_FUNCTION const char *CDECL GetObjectSoul(unsigned int index) NOEXCEPT;
/**
* \brief Get the gold value of the object at a certain index in the read object list.
@ -299,7 +298,7 @@ public:
* \param index The index of the object.
* \return The gold value.
*/
static int GetObjectGoldValue(unsigned int index) noexcept;
API_FUNCTION int CDECL GetObjectGoldValue(unsigned int index) NOEXCEPT;
/**
* \brief Get the object scale of the object at a certain index in the read object list.
@ -307,7 +306,7 @@ public:
* \param index The index of the object.
* \return The object scale.
*/
static double GetObjectScale(unsigned int index) noexcept;
API_FUNCTION double CDECL GetObjectScale(unsigned int index) NOEXCEPT;
/**
* \brief Get the object state of the object at a certain index in the read object list.
@ -315,7 +314,7 @@ public:
* \param index The index of the object.
* \return The object state.
*/
static bool GetObjectState(unsigned int index) noexcept;
API_FUNCTION bool CDECL GetObjectState(unsigned int index) NOEXCEPT;
/**
* \brief Get the door state of the object at a certain index in the read object list.
@ -323,7 +322,7 @@ public:
* \param index The index of the object.
* \return The door state.
*/
static int GetObjectDoorState(unsigned int index) noexcept;
API_FUNCTION int CDECL GetObjectDoorState(unsigned int index) NOEXCEPT;
/**
* \brief Get the lock level of the object at a certain index in the read object list.
@ -331,7 +330,7 @@ public:
* \param index The index of the object.
* \return The lock level.
*/
static int GetObjectLockLevel(unsigned int index) noexcept;
API_FUNCTION int CDECL GetObjectLockLevel(unsigned int index) NOEXCEPT;
/**
* \brief Check whether the object at a certain index in the read object list has been
@ -340,7 +339,7 @@ public:
* \param index The index of the object.
* \return Whether the object has been activated by a player.
*/
static bool DoesObjectHavePlayerActivating(unsigned int index) noexcept;
API_FUNCTION bool CDECL DoesObjectHavePlayerActivating(unsigned int index) NOEXCEPT;
/**
* \brief Get the player ID of the player activating the object at a certain index in the
@ -349,7 +348,7 @@ public:
* \param index The index of the object.
* \return The player ID of the activating player.
*/
static int GetObjectActivatingPid(unsigned int index) noexcept;
API_FUNCTION int CDECL GetObjectActivatingPid(unsigned int index) NOEXCEPT;
/**
* \brief Get the refId of the actor activating the object at a certain index in the read
@ -358,7 +357,7 @@ public:
* \param index The index of the object.
* \return The refId of the activating actor.
*/
static const char *GetObjectActivatingRefId(unsigned int index) noexcept;
API_FUNCTION const char *CDECL GetObjectActivatingRefId(unsigned int index) NOEXCEPT;
/**
* \brief Get the refNum of the actor activating the object at a certain index in the read
@ -367,7 +366,7 @@ public:
* \param index The index of the object.
* \return The refNum of the activating actor.
*/
static unsigned int GetObjectActivatingRefNum(unsigned int index) noexcept;
API_FUNCTION unsigned int CDECL GetObjectActivatingRefNum(unsigned int index) NOEXCEPT;
/**
* \brief Get the mpNum of the actor activating the object at a certain index in the read
@ -376,7 +375,7 @@ public:
* \param index The index of the object.
* \return The mpNum of the activating actor.
*/
static unsigned int GetObjectActivatingMpNum(unsigned int index) noexcept;
API_FUNCTION unsigned int CDECL GetObjectActivatingMpNum(unsigned int index) NOEXCEPT;
/**
* \brief Get the name of the actor activating the object at a certain index in the read
@ -385,7 +384,7 @@ public:
* \param index The index of the object.
* \return The name of the activating actor.
*/
static const char *GetObjectActivatingName(unsigned int index) noexcept;
API_FUNCTION const char *CDECL GetObjectActivatingName(unsigned int index) NOEXCEPT;
/**
* \brief Check whether the object at a certain index in the read object list is a
@ -395,7 +394,7 @@ public:
*
* \return The summon state.
*/
static bool GetObjectSummonState(unsigned int index) noexcept;
API_FUNCTION bool CDECL GetObjectSummonState(unsigned int index) NOEXCEPT;
/**
* \brief Get the summon duration of the object at a certain index in the read object list.
@ -405,7 +404,7 @@ public:
* \param index The index of the object.
* \return The summon duration.
*/
static double GetObjectSummonDuration(unsigned int index) noexcept;
API_FUNCTION double CDECL GetObjectSummonDuration(unsigned int index) NOEXCEPT;
/**
* \brief Check whether the object at a certain index in the read object list has a player
@ -416,7 +415,7 @@ public:
* \param index The index of the object.
* \return Whether a player is the summoner of the object.
*/
static bool DoesObjectHavePlayerSummoner(unsigned int index) noexcept;
API_FUNCTION bool CDECL DoesObjectHavePlayerSummoner(unsigned int index) NOEXCEPT;
/**
* \brief Get the player ID of the summoner of the object at a certain index in the read object
@ -425,7 +424,7 @@ public:
* \param index The index of the object.
* \return The player ID of the summoner.
*/
static int GetObjectSummonerPid(unsigned int index) noexcept;
API_FUNCTION int CDECL GetObjectSummonerPid(unsigned int index) NOEXCEPT;
/**
* \brief Get the refId of the actor summoner of the object at a certain index in the read object
@ -434,7 +433,7 @@ public:
* \param index The index of the object.
* \return The refId of the summoner.
*/
static const char *GetObjectSummonerRefId(unsigned int index) noexcept;
API_FUNCTION const char *CDECL GetObjectSummonerRefId(unsigned int index) NOEXCEPT;
/**
* \brief Get the refNum of the actor summoner of the object at a certain index in the read object
@ -443,7 +442,7 @@ public:
* \param index The index of the object.
* \return The refNum of the summoner.
*/
static unsigned int GetObjectSummonerRefNum(unsigned int index) noexcept;
API_FUNCTION unsigned int CDECL GetObjectSummonerRefNum(unsigned int index) NOEXCEPT;
/**
* \brief Get the mpNum of the actor summoner of the object at a certain index in the read object list.
@ -451,7 +450,7 @@ public:
* \param index The index of the object.
* \return The mpNum of the summoner.
*/
static unsigned int GetObjectSummonerMpNum(unsigned int index) noexcept;
API_FUNCTION unsigned int CDECL GetObjectSummonerMpNum(unsigned int index) NOEXCEPT;
/**
* \brief Get the X position of the object at a certain index in the read object list.
@ -459,7 +458,7 @@ public:
* \param index The index of the object.
* \return The X position.
*/
static double GetObjectPosX(unsigned int index) noexcept;
API_FUNCTION double CDECL GetObjectPosX(unsigned int index) NOEXCEPT;
/**
* \brief Get the Y position of the object at a certain index in the read object list.
@ -467,7 +466,7 @@ public:
* \param index The index of the object.
* \return The Y position.
*/
static double GetObjectPosY(unsigned int index) noexcept;
API_FUNCTION double CDECL GetObjectPosY(unsigned int index) NOEXCEPT;
/**
* \brief Get the Z position at a certain index in the read object list.
@ -475,7 +474,7 @@ public:
* \param index The index of the object.
* \return The Z position.
*/
static double GetObjectPosZ(unsigned int index) noexcept;
API_FUNCTION double CDECL GetObjectPosZ(unsigned int index) NOEXCEPT;
/**
* \brief Get the X rotation of the object at a certain index in the read object list.
@ -483,7 +482,7 @@ public:
* \param index The index of the object.
* \return The X rotation.
*/
static double GetObjectRotX(unsigned int index) noexcept;
API_FUNCTION double CDECL GetObjectRotX(unsigned int index) NOEXCEPT;
/**
* \brief Get the Y rotation of the object at a certain index in the read object list.
@ -491,7 +490,7 @@ public:
* \param index The index of the object.
* \return The Y rotation.
*/
static double GetObjectRotY(unsigned int index) noexcept;
API_FUNCTION double CDECL GetObjectRotY(unsigned int index) NOEXCEPT;
/**
* \brief Get the Z rotation of the object at a certain index in the read object list.
@ -499,14 +498,14 @@ public:
* \param index The index of the object.
* \return The Z rotation.
*/
static double GetObjectRotZ(unsigned int index) noexcept;
API_FUNCTION double CDECL GetObjectRotZ(unsigned int index) NOEXCEPT;
/**
* \brief Get the videoFilename of the object at a certain index in the read object list.
*
* \return The videoFilename.
*/
static const char *GetVideoFilename(unsigned int index) noexcept;
API_FUNCTION const char *CDECL GetVideoFilename(unsigned int index) NOEXCEPT;
/**
* \brief Get the number of container item indexes of the object at a certain index in the
@ -515,7 +514,7 @@ public:
* \param index The index of the object.
* \return The number of container item indexes.
*/
static unsigned int GetContainerChangesSize(unsigned int objectIndex) noexcept;
API_FUNCTION unsigned int CDECL GetContainerChangesSize(unsigned int objectIndex) NOEXCEPT;
/**
* \brief Get the refId of the container item at a certain itemIndex in the container changes
@ -525,7 +524,7 @@ public:
* \param itemIndex The index of the container item.
* \return The refId.
*/
static const char *GetContainerItemRefId(unsigned int objectIndex, unsigned int itemIndex) noexcept;
API_FUNCTION const char *CDECL GetContainerItemRefId(unsigned int objectIndex, unsigned int itemIndex) NOEXCEPT;
/**
* \brief Get the item count of the container item at a certain itemIndex in the container
@ -535,7 +534,7 @@ public:
* \param itemIndex The index of the container item.
* \return The item count.
*/
static int GetContainerItemCount(unsigned int objectIndex, unsigned int itemIndex) noexcept;
API_FUNCTION int CDECL GetContainerItemCount(unsigned int objectIndex, unsigned int itemIndex) NOEXCEPT;
/**
* \brief Get the charge of the container item at a certain itemIndex in the container changes
@ -545,7 +544,7 @@ public:
* \param itemIndex The index of the container item.
* \return The charge.
*/
static int GetContainerItemCharge(unsigned int objectIndex, unsigned int itemIndex) noexcept;
API_FUNCTION int CDECL GetContainerItemCharge(unsigned int objectIndex, unsigned int itemIndex) NOEXCEPT;
/**
* \brief Get the enchantment charge of the container item at a certain itemIndex in the container changes
@ -555,7 +554,7 @@ public:
* \param itemIndex The index of the container item.
* \return The enchantment charge.
*/
static double GetContainerItemEnchantmentCharge(unsigned int objectIndex, unsigned int itemIndex) noexcept;
API_FUNCTION double CDECL GetContainerItemEnchantmentCharge(unsigned int objectIndex, unsigned int itemIndex) NOEXCEPT;
/**
* \brief Get the soul of the container item at a certain itemIndex in the container changes
@ -565,7 +564,7 @@ public:
* \param itemIndex The index of the container item.
* \return The soul.
*/
static const char *GetContainerItemSoul(unsigned int objectIndex, unsigned int itemIndex) noexcept;
API_FUNCTION const char *CDECL GetContainerItemSoul(unsigned int objectIndex, unsigned int itemIndex) NOEXCEPT;
/**
* \brief Get the action count of the container item at a certain itemIndex in the container
@ -575,7 +574,7 @@ public:
* \param itemIndex The index of the container item.
* \return The action count.
*/
static int GetContainerItemActionCount(unsigned int objectIndex, unsigned int itemIndex) noexcept;
API_FUNCTION int CDECL GetContainerItemActionCount(unsigned int objectIndex, unsigned int itemIndex) NOEXCEPT;
/**
* \brief Check whether the object at a certain index in the read object list has a container.
@ -586,7 +585,7 @@ public:
* \param index The index of the object.
* \return Whether the object has a container.
*/
static bool DoesObjectHaveContainer(unsigned int index) noexcept;
API_FUNCTION bool CDECL DoesObjectHaveContainer(unsigned int index) NOEXCEPT;
/**
* \brief Set the cell of the temporary object list stored on the server.
@ -597,7 +596,7 @@ public:
* \param cellDescription The description of the cell.
* \return void
*/
static void SetObjectListCell(const char* cellDescription) noexcept;
API_FUNCTION void CDECL SetObjectListCell(const char* cellDescription) NOEXCEPT;
/**
* \brief Set the action type of the temporary object list stored on the server.
@ -605,7 +604,7 @@ public:
* \param action The action type (0 for SET, 1 for ADD, 2 for REMOVE, 3 for REQUEST).
* \return void
*/
static void SetObjectListAction(unsigned char action) noexcept;
API_FUNCTION void CDECL SetObjectListAction(unsigned char action) NOEXCEPT;
/**
* \brief Set the console command of the temporary object list stored on the server.
@ -616,7 +615,7 @@ public:
* \param consoleCommand The console command.
* \return void
*/
static void SetObjectListConsoleCommand(const char* consoleCommand) noexcept;
API_FUNCTION void CDECL SetObjectListConsoleCommand(const char* consoleCommand) NOEXCEPT;
/**
* \brief Set the refId of the temporary object stored on the server.
@ -624,7 +623,7 @@ public:
* \param refId The refId.
* \return void
*/
static void SetObjectRefId(const char* refId) noexcept;
API_FUNCTION void CDECL SetObjectRefId(const char* refId) NOEXCEPT;
/**
* \brief Set the refNum of the temporary object stored on the server.
@ -638,7 +637,7 @@ public:
* \param refNum The refNum.
* \return void
*/
static void SetObjectRefNum(int refNum) noexcept;
API_FUNCTION void CDECL SetObjectRefNum(int refNum) NOEXCEPT;
/**
* \brief Set the mpNum of the temporary object stored on the server.
@ -653,7 +652,7 @@ public:
* \param mpNum The mpNum.
* \return void
*/
static void SetObjectMpNum(int mpNum) noexcept;
API_FUNCTION void CDECL SetObjectMpNum(int mpNum) NOEXCEPT;
/**
* \brief Set the object count of the temporary object stored on the server.
@ -663,7 +662,7 @@ public:
* \param count The object count.
* \return void
*/
static void SetObjectCount(int count) noexcept;
API_FUNCTION void CDECL SetObjectCount(int count) NOEXCEPT;
/**
* \brief Set the charge of the temporary object stored on the server.
@ -673,7 +672,7 @@ public:
* \param charge The charge.
* \return void
*/
static void SetObjectCharge(int charge) noexcept;
API_FUNCTION void CDECL SetObjectCharge(int charge) NOEXCEPT;
/**
* \brief Set the enchantment charge of the temporary object stored on the server.
@ -683,7 +682,7 @@ public:
* \param charge The enchantment charge.
* \return void
*/
static void SetObjectEnchantmentCharge(double enchantmentCharge) noexcept;
API_FUNCTION void CDECL SetObjectEnchantmentCharge(double enchantmentCharge) NOEXCEPT;
/**
* \brief Set the soul of the temporary object stored on the server.
@ -691,7 +690,7 @@ public:
* \param refId The soul.
* \return void
*/
static void SetObjectSoul(const char* soul) noexcept;
API_FUNCTION void CDECL SetObjectSoul(const char* soul) NOEXCEPT;
/**
* \brief Set the gold value of the temporary object stored on the server.
@ -701,7 +700,7 @@ public:
* \param goldValue The gold value.
* \return void
*/
static void SetObjectGoldValue(int goldValue) noexcept;
API_FUNCTION void CDECL SetObjectGoldValue(int goldValue) NOEXCEPT;
/**
* \brief Set the scale of the temporary object stored on the server.
@ -711,7 +710,7 @@ public:
* \param scale The scale.
* \return void
*/
static void SetObjectScale(double scale) noexcept;
API_FUNCTION void CDECL SetObjectScale(double scale) NOEXCEPT;
/**
* \brief Set the object state of the temporary object stored on the server.
@ -721,7 +720,7 @@ public:
* \param objectState The object state.
* \return void
*/
static void SetObjectState(bool objectState) noexcept;
API_FUNCTION void CDECL SetObjectState(bool objectState) NOEXCEPT;
/**
* \brief Set the lock level of the temporary object stored on the server.
@ -729,7 +728,7 @@ public:
* \param lockLevel The lock level.
* \return void
*/
static void SetObjectLockLevel(int lockLevel) noexcept;
API_FUNCTION void CDECL SetObjectLockLevel(int lockLevel) NOEXCEPT;
/**
* \brief Set the summon duration of the temporary object stored on the server.
@ -737,7 +736,7 @@ public:
* \param summonDuration The summon duration.
* \return void
*/
static void SetObjectSummonDuration(float summonDuration) noexcept;
API_FUNCTION void CDECL SetObjectSummonDuration(float summonDuration) NOEXCEPT;
/**
* \brief Set the disarm state of the temporary object stored on the server.
@ -745,7 +744,7 @@ public:
* \param disarmState The disarmState.
* \return void
*/
static void SetObjectDisarmState(bool disarmState) noexcept;
API_FUNCTION void CDECL SetObjectDisarmState(bool disarmState) NOEXCEPT;
/**
* \brief Set the summon state of the temporary object stored on the server.
@ -756,7 +755,7 @@ public:
* \param summonState The summon state.
* \return void
*/
static void SetObjectSummonState(bool summonState) noexcept;
API_FUNCTION void CDECL SetObjectSummonState(bool summonState) NOEXCEPT;
/**
* \brief Set the position of the temporary object stored on the server.
@ -766,7 +765,7 @@ public:
* \param z The Z position.
* \return void
*/
static void SetObjectPosition(double x, double y, double z) noexcept;
API_FUNCTION void CDECL SetObjectPosition(double x, double y, double z) NOEXCEPT;
/**
* \brief Set the rotation of the temporary object stored on the server.
@ -776,7 +775,7 @@ public:
* \param z The Z rotation.
* \return void
*/
static void SetObjectRotation(double x, double y, double z) noexcept;
API_FUNCTION void CDECL SetObjectRotation(double x, double y, double z) NOEXCEPT;
/**
* \brief Set the player ID of the player activating the temporary object stored on the
@ -785,7 +784,7 @@ public:
* \param pid The pid of the player.
* \return void
*/
static void SetObjectActivatingPid(unsigned short pid) noexcept;
API_FUNCTION void CDECL SetObjectActivatingPid(PlayerId pid) NOEXCEPT;
/**
* \brief Set the door state of the temporary object stored on the server.
@ -795,7 +794,7 @@ public:
* \param doorState The door state.
* \return void
*/
static void SetObjectDoorState(int doorState) noexcept;
API_FUNCTION void CDECL SetObjectDoorState(int doorState) NOEXCEPT;
/**
* \brief Set the teleport state of the temporary object stored on the server.
@ -806,7 +805,7 @@ public:
* \param teleportState The teleport state.
* \return void
*/
static void SetObjectDoorTeleportState(bool teleportState) noexcept;
API_FUNCTION void CDECL SetObjectDoorTeleportState(bool teleportState) NOEXCEPT;
/**
* \brief Set the door destination cell of the temporary object stored on the server.
@ -817,7 +816,7 @@ public:
* \param cellDescription The description of the cell.
* \return void
*/
static void SetObjectDoorDestinationCell(const char* cellDescription) noexcept;
API_FUNCTION void CDECL SetObjectDoorDestinationCell(const char* cellDescription) NOEXCEPT;
/**
* \brief Set the door destination position of the temporary object stored on the server.
@ -827,7 +826,7 @@ public:
* \param z The Z position.
* \return void
*/
static void SetObjectDoorDestinationPosition(double x, double y, double z) noexcept;
API_FUNCTION void CDECL SetObjectDoorDestinationPosition(double x, double y, double z) NOEXCEPT;
/**
* \brief Set the door destination rotation of the temporary object stored on the server.
@ -839,7 +838,7 @@ public:
* \param z The Z rotation.
* \return void
*/
static void SetObjectDoorDestinationRotation(double x, double z) noexcept;
API_FUNCTION void CDECL SetObjectDoorDestinationRotation(double x, double z) NOEXCEPT;
/**
* \brief Set a player as the object in the temporary object stored on the server.
@ -848,7 +847,7 @@ public:
* \param pid The pid of the player.
* \return void
*/
static void SetPlayerAsObject(unsigned short pid) noexcept;
API_FUNCTION void CDECL SetPlayerAsObject(PlayerId pid) NOEXCEPT;
/**
* \brief Set the refId of the temporary container item stored on the server.
@ -856,7 +855,7 @@ public:
* \param refId The refId.
* \return void
*/
static void SetContainerItemRefId(const char* refId) noexcept;
API_FUNCTION void CDECL SetContainerItemRefId(const char* refId) NOEXCEPT;
/**
* \brief Set the item count of the temporary container item stored on the server.
@ -864,7 +863,7 @@ public:
* \param count The item count.
* \return void
*/
static void SetContainerItemCount(int count) noexcept;
API_FUNCTION void CDECL SetContainerItemCount(int count) NOEXCEPT;
/**
* \brief Set the charge of the temporary container item stored on the server.
@ -872,7 +871,7 @@ public:
* \param charge The charge.
* \return void
*/
static void SetContainerItemCharge(int charge) noexcept;
API_FUNCTION void CDECL SetContainerItemCharge(int charge) NOEXCEPT;
/**
* \brief Set the enchantment charge of the temporary container item stored on the server.
@ -880,7 +879,7 @@ public:
* \param charge The enchantment charge.
* \return void
*/
static void SetContainerItemEnchantmentCharge(double enchantmentCharge) noexcept;
API_FUNCTION void CDECL SetContainerItemEnchantmentCharge(double enchantmentCharge) NOEXCEPT;
/**
* \brief Set the soul of the temporary container item stored on the server.
@ -888,7 +887,7 @@ public:
* \param refId The soul.
* \return void
*/
static void SetContainerItemSoul(const char* soul) noexcept;
API_FUNCTION void CDECL SetContainerItemSoul(const char* soul) NOEXCEPT;
/**
* \brief Set the action count of the container item at a certain itemIndex in the container
@ -903,7 +902,7 @@ public:
* \param actionCount The action count.
* \return void
*/
static void SetContainerItemActionCountByIndex(unsigned int objectIndex, unsigned int itemIndex, int actionCount) noexcept;
API_FUNCTION void CDECL SetContainerItemActionCountByIndex(unsigned int objectIndex, unsigned int itemIndex, int actionCount) NOEXCEPT;
/**
* \brief Add a copy of the server's temporary object to the server's currently stored object
@ -914,7 +913,7 @@ public:
*
* \return void
*/
static void AddObject() noexcept;
API_FUNCTION void CDECL AddObject() NOEXCEPT;
/**
* \brief Add a copy of the server's temporary container item to the container changes of the
@ -925,7 +924,7 @@ public:
*
* \return void
*/
static void AddContainerItem() noexcept;
API_FUNCTION void CDECL AddContainerItem() NOEXCEPT;
/**
* \brief Send an ObjectActivate packet.
@ -936,7 +935,7 @@ public:
* to the packet (false by default).
* \return void
*/
static void SendObjectActivate(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendObjectActivate(bool sendToOtherPlayers, bool skipAttachedPlayer) NOEXCEPT;
/**
* \brief Send an ObjectPlace packet.
@ -947,7 +946,7 @@ public:
* to the packet (false by default).
* \return void
*/
static void SendObjectPlace(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendObjectPlace(bool sendToOtherPlayers, bool skipAttachedPlayer) NOEXCEPT;
/**
* \brief Send an ObjectSpawn packet.
@ -958,7 +957,7 @@ public:
* to the packet (false by default).
* \return void
*/
static void SendObjectSpawn(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendObjectSpawn(bool sendToOtherPlayers, bool skipAttachedPlayer) NOEXCEPT;
/**
* \brief Send an ObjectDelete packet.
@ -968,7 +967,7 @@ public:
*
* \return void
*/
static void SendObjectDelete(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendObjectDelete(bool sendToOtherPlayers, bool skipAttachedPlayer) NOEXCEPT;
/**
* \brief Send an ObjectLock packet.
@ -979,7 +978,7 @@ public:
* to the packet (false by default).
* \return void
*/
static void SendObjectLock(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendObjectLock(bool sendToOtherPlayers, bool skipAttachedPlayer) NOEXCEPT;
/**
* \brief Send an ObjectTrap packet.
@ -989,7 +988,7 @@ public:
*
* \return void
*/
static void SendObjectTrap(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendObjectTrap(bool sendToOtherPlayers, bool skipAttachedPlayer) NOEXCEPT;
/**
* \brief Send an ObjectScale packet.
@ -1000,7 +999,7 @@ public:
* to the packet (false by default).
* \return void
*/
static void SendObjectScale(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendObjectScale(bool sendToOtherPlayers, bool skipAttachedPlayer) NOEXCEPT;
/**
* \brief Send an ObjectState packet.
@ -1011,7 +1010,7 @@ public:
* to the packet (false by default).
* \return void
*/
static void SendObjectState(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendObjectState(bool sendToOtherPlayers, bool skipAttachedPlayer) NOEXCEPT;
/**
* \brief Send a DoorState packet.
@ -1022,7 +1021,7 @@ public:
* to the packet (false by default).
* \return void
*/
static void SendDoorState(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendDoorState(bool sendToOtherPlayers, bool skipAttachedPlayer) NOEXCEPT;
/**
* \brief Send a DoorDestination packet.
@ -1033,7 +1032,7 @@ public:
* to the packet (false by default).
* \return void
*/
static void SendDoorDestination(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendDoorDestination(bool sendToOtherPlayers, bool skipAttachedPlayer) NOEXCEPT;
/**
* \brief Send a Container packet.
@ -1044,7 +1043,7 @@ public:
* to the packet (false by default).
* \return void
*/
static void SendContainer(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendContainer(bool sendToOtherPlayers, bool skipAttachedPlayer) NOEXCEPT;
/**
* \brief Send a VideoPlay packet.
@ -1055,7 +1054,7 @@ public:
* to the packet (false by default).
* \return void
*/
static void SendVideoPlay(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendVideoPlay(bool sendToOtherPlayers, bool skipAttachedPlayer) NOEXCEPT;
/**
* \brief Send a ConsoleCommand packet.
@ -1066,28 +1065,27 @@ public:
* to the packet (false by default).
* \return void
*/
static void SendConsoleCommand(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendConsoleCommand(bool sendToOtherPlayers, bool skipAttachedPlayer) NOEXCEPT;
// All methods below are deprecated versions of methods from above
static void ReadLastObjectList() noexcept;
static void ReadLastEvent() noexcept;
static void InitializeObjectList(unsigned short pid) noexcept;
static void InitializeEvent(unsigned short pid) noexcept;
static void CopyLastObjectListToStore() noexcept;
static unsigned int GetObjectChangesSize() noexcept;
static unsigned char GetEventAction() noexcept;
static unsigned char GetEventContainerSubAction() noexcept;
static unsigned int GetObjectRefNumIndex(unsigned int index) noexcept;
static unsigned int GetObjectSummonerRefNumIndex(unsigned int index) noexcept;
static void SetEventCell(const char* cellDescription) noexcept;
static void SetEventAction(unsigned char action) noexcept;
static void SetEventConsoleCommand(const char* consoleCommand) noexcept;
static void SetObjectRefNumIndex(int refNum) noexcept;
static void AddWorldObject() noexcept;
};
API_FUNCTION void CDECL ReadLastObjectList() NOEXCEPT;
API_FUNCTION void CDECL ReadLastEvent() NOEXCEPT;
API_FUNCTION void CDECL InitializeObjectList(PlayerId pid) NOEXCEPT;
API_FUNCTION void CDECL InitializeEvent(PlayerId pid) NOEXCEPT;
API_FUNCTION void CDECL CopyLastObjectListToStore() NOEXCEPT;
API_FUNCTION unsigned int CDECL GetObjectChangesSize() NOEXCEPT;
API_FUNCTION unsigned char CDECL GetEventAction() NOEXCEPT;
API_FUNCTION unsigned char CDECL GetEventContainerSubAction() NOEXCEPT;
API_FUNCTION unsigned int CDECL GetObjectRefNumIndex(unsigned int index) NOEXCEPT;
API_FUNCTION unsigned int CDECL GetObjectSummonerRefNumIndex(unsigned int index) NOEXCEPT;
API_FUNCTION void CDECL SetEventCell(const char* cellDescription) NOEXCEPT;
API_FUNCTION void CDECL SetEventAction(unsigned char action) NOEXCEPT;
API_FUNCTION void CDECL SetEventConsoleCommand(const char* consoleCommand) NOEXCEPT;
API_FUNCTION void CDECL SetObjectRefNumIndex(int refNum) NOEXCEPT;
API_FUNCTION void CDECL AddWorldObject() NOEXCEPT;
NAMESPACE_END()
#endif //OPENMW_OBJECTAPI_HPP

@ -1,5 +1,5 @@
#include "Positions.hpp"
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
#include "Positions.h"
#include <apps/openmw-mp/Script/Callbacks.hpp>
#include <components/openmw-mp/NetworkMessages.hpp>
#include <apps/openmw-mp/Player.hpp>
#include <apps/openmw-mp/Networking.hpp>
@ -7,7 +7,7 @@
#include <iostream>
using namespace std;
double PositionFunctions::GetPosX(unsigned short pid) noexcept
extern "C" double PositionFunctions::GetPosX(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0.0f);
@ -15,7 +15,7 @@ double PositionFunctions::GetPosX(unsigned short pid) noexcept
return player->position.pos[0];
}
double PositionFunctions::GetPosY(unsigned short pid) noexcept
extern "C" double PositionFunctions::GetPosY(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0.0f);
@ -23,7 +23,7 @@ double PositionFunctions::GetPosY(unsigned short pid) noexcept
return player->position.pos[1];
}
double PositionFunctions::GetPosZ(unsigned short pid) noexcept
extern "C" double PositionFunctions::GetPosZ(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0.0f);
@ -31,7 +31,7 @@ double PositionFunctions::GetPosZ(unsigned short pid) noexcept
return player->position.pos[2];
}
double PositionFunctions::GetPreviousCellPosX(unsigned short pid) noexcept
extern "C" double PositionFunctions::GetPreviousCellPosX(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0.0f);
@ -39,7 +39,7 @@ double PositionFunctions::GetPreviousCellPosX(unsigned short pid) noexcept
return player->previousCellPosition.pos[0];
}
double PositionFunctions::GetPreviousCellPosY(unsigned short pid) noexcept
extern "C" double PositionFunctions::GetPreviousCellPosY(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0.0f);
@ -47,7 +47,7 @@ double PositionFunctions::GetPreviousCellPosY(unsigned short pid) noexcept
return player->previousCellPosition.pos[1];
}
double PositionFunctions::GetPreviousCellPosZ(unsigned short pid) noexcept
extern "C" double PositionFunctions::GetPreviousCellPosZ(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0.0f);
@ -55,7 +55,7 @@ double PositionFunctions::GetPreviousCellPosZ(unsigned short pid) noexcept
return player->previousCellPosition.pos[2];
}
double PositionFunctions::GetRotX(unsigned short pid) noexcept
extern "C" double PositionFunctions::GetRotX(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0.0f);
@ -63,7 +63,7 @@ double PositionFunctions::GetRotX(unsigned short pid) noexcept
return player->position.rot[0];
}
double PositionFunctions::GetRotZ(unsigned short pid) noexcept
extern "C" double PositionFunctions::GetRotZ(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0.0f);
@ -71,7 +71,7 @@ double PositionFunctions::GetRotZ(unsigned short pid) noexcept
return player->position.rot[2];
}
void PositionFunctions::SetPos(unsigned short pid, double x, double y, double z) noexcept
extern "C" void PositionFunctions::SetPos(PlayerId pid, double x, double y, double z) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -81,7 +81,7 @@ void PositionFunctions::SetPos(unsigned short pid, double x, double y, double z)
player->position.pos[2] = z;
}
void PositionFunctions::SetRot(unsigned short pid, double x, double z) noexcept
extern "C" void PositionFunctions::SetRot(PlayerId pid, double x, double z) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -90,7 +90,7 @@ void PositionFunctions::SetRot(unsigned short pid, double x, double z) noexcept
player->position.rot[2] = z;
}
void PositionFunctions::SetMomentum(unsigned short pid, double x, double y, double z) noexcept
extern "C" void PositionFunctions::SetMomentum(PlayerId pid, double x, double y, double z) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -100,7 +100,7 @@ void PositionFunctions::SetMomentum(unsigned short pid, double x, double y, doub
player->momentum.pos[2] = z;
}
void PositionFunctions::SendPos(unsigned short pid) noexcept
extern "C" void PositionFunctions::SendPos(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -111,7 +111,7 @@ void PositionFunctions::SendPos(unsigned short pid) noexcept
packet->Send(false);
}
void PositionFunctions::SendMomentum(unsigned short pid) noexcept
extern "C" void PositionFunctions::SendMomentum(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );

@ -1,39 +1,16 @@
#ifndef OPENMW_POSITIONAPI_HPP
#define OPENMW_POSITIONAPI_HPP
#include "../Types.hpp"
#define POSITIONAPI \
{"GetPosX", PositionFunctions::GetPosX},\
{"GetPosY", PositionFunctions::GetPosY},\
{"GetPosZ", PositionFunctions::GetPosZ},\
\
{"GetPreviousCellPosX", PositionFunctions::GetPreviousCellPosX},\
{"GetPreviousCellPosY", PositionFunctions::GetPreviousCellPosY},\
{"GetPreviousCellPosZ", PositionFunctions::GetPreviousCellPosZ},\
\
{"GetRotX", PositionFunctions::GetRotX},\
{"GetRotZ", PositionFunctions::GetRotZ},\
\
{"SetPos", PositionFunctions::SetPos},\
{"SetRot", PositionFunctions::SetRot},\
{"SetMomentum", PositionFunctions::SetMomentum},\
\
{"SendPos", PositionFunctions::SendPos},\
{"SendMomentum", PositionFunctions::SendMomentum}
class PositionFunctions
{
public:
#include "../api.h"
NAMESPACE_BEGIN(PositionFunctions)
/**
* \brief Get the X position of a player.
*
* \param pid The player ID.
* \return The X position.
*/
static double GetPosX(unsigned short pid) noexcept;
API_FUNCTION double CDECL GetPosX(PlayerId pid) NOEXCEPT;
/**
* \brief Get the Y position of a player.
@ -41,7 +18,7 @@ public:
* \param pid The player ID.
* \return The Y position.
*/
static double GetPosY(unsigned short pid) noexcept;
API_FUNCTION double CDECL GetPosY(PlayerId pid) NOEXCEPT;
/**
* \brief Get the Z position of a player.
@ -49,7 +26,7 @@ public:
* \param pid The player ID.
* \return The Z position.
*/
static double GetPosZ(unsigned short pid) noexcept;
API_FUNCTION double CDECL GetPosZ(PlayerId pid) NOEXCEPT;
/**
* \brief Get the X position of a player from before their latest cell change.
@ -57,7 +34,7 @@ public:
* \param pid The player ID.
* \return The X position.
*/
static double GetPreviousCellPosX(unsigned short pid) noexcept;
API_FUNCTION double CDECL GetPreviousCellPosX(PlayerId pid) NOEXCEPT;
/**
* \brief Get the Y position of a player from before their latest cell change.
@ -65,7 +42,7 @@ public:
* \param pid The player ID.
* \return The Y position.
*/
static double GetPreviousCellPosY(unsigned short pid) noexcept;
API_FUNCTION double CDECL GetPreviousCellPosY(PlayerId pid) NOEXCEPT;
/**
* \brief Get the Z position of a player from before their latest cell change.
@ -73,7 +50,7 @@ public:
* \param pid The player ID.
* \return The Z position.
*/
static double GetPreviousCellPosZ(unsigned short pid) noexcept;
API_FUNCTION double CDECL GetPreviousCellPosZ(PlayerId pid) NOEXCEPT;
/**
* \brief Get the X rotation of a player.
@ -81,7 +58,7 @@ public:
* \param pid The player ID.
* \return The X rotation.
*/
static double GetRotX(unsigned short pid) noexcept;
API_FUNCTION double CDECL GetRotX(PlayerId pid) NOEXCEPT;
/**
* \brief Get the Z rotation of a player.
@ -89,7 +66,7 @@ public:
* \param pid The player ID.
* \return The Z rotation.
*/
static double GetRotZ(unsigned short pid) noexcept;
API_FUNCTION double CDECL GetRotZ(PlayerId pid) NOEXCEPT;
/**
* \brief Set the position of a player.
@ -103,7 +80,7 @@ public:
* \param z The Z position.
* \return void
*/
static void SetPos(unsigned short pid, double x, double y, double z) noexcept;
API_FUNCTION void CDECL SetPos(PlayerId pid, double x, double y, double z) NOEXCEPT;
/**
* \brief Set the rotation of a player.
@ -118,7 +95,7 @@ public:
* \param z The Z position.
* \return void
*/
static void SetRot(unsigned short pid, double x, double z) noexcept;
API_FUNCTION void CDECL SetRot(PlayerId pid, double x, double z) NOEXCEPT;
/**
* \brief Set the momentum of a player.
@ -132,7 +109,7 @@ public:
* \param z The Z momentum.
* \return void
*/
static void SetMomentum(unsigned short pid, double x, double y, double z) noexcept;
API_FUNCTION void CDECL SetMomentum(PlayerId pid, double x, double y, double z) NOEXCEPT;
/**
* \brief Send a PlayerPosition packet about a player.
@ -142,7 +119,7 @@ public:
* \param pid The player ID.
* \return void
*/
static void SendPos(unsigned short pid) noexcept;
API_FUNCTION void CDECL SendPos(PlayerId pid) NOEXCEPT;
/**
* \brief Send a PlayerMomentum packet about a player.
@ -152,7 +129,7 @@ public:
* \param pid The player ID.
* \return void
*/
static void SendMomentum(unsigned short pid) noexcept;
};
API_FUNCTION void CDECL SendMomentum(PlayerId pid) NOEXCEPT;
NAMESPACE_END()
#endif //OPENMW_POSITIONAPI_HPP

@ -0,0 +1,47 @@
//
// Created by koncord on 09.12.18.
//
#include "Public.h"
#include <Script/Callbacks.hpp>
#include <Script/API/PublicFnAPI.hpp>
extern "C" void PublicFunctions::MakePublic(ScriptFunc _public, const char *name, char ret_type, const char *def) noexcept
{
Public::MakePublic(_public, name, ret_type, def);
}
extern "C" RetType PublicFunctions::CallPublic(const char *name, ...) noexcept
{
try
{
va_list args;
va_start(args, name);
RetType ret = Public::Call(name, args);
va_end(args);
return ret;
}
catch (...) {}
return 0;
}
const char *PublicFunctions::GetPublicName() NOEXCEPT
{
const std::string &str = Public::GetName();
if(str.empty())
return nullptr;
else
return str.c_str();
}
const char *PublicFunctions::GetPublicDefinition(const char *_public)
{
return Public::GetDefinition(_public).c_str();
}
char PublicFunctions::GetPublicReturnType(const char *_public)
{
return Public::GetReturnType(_public);
}

@ -0,0 +1,20 @@
//
// Created by koncord on 09.12.18.
//
#ifndef OPENMW_PUBLIC_HPP
#define OPENMW_PUBLIC_HPP
#include "../api.h"
#include <stdarg.h>
NAMESPACE_BEGIN(PublicFunctions)
API_FUNCTION void CDECL MakePublic(ScriptFunc _public, const char *name, char ret_type, const char *def) NOEXCEPT;
API_FUNCTION RetType CDECL CallPublic(const char *name, ...) NOEXCEPT;
API_FUNCTION const char *CDECL GetPublicName() NOEXCEPT;
API_FUNCTION const char *GetPublicDefinition(const char *_public);
API_FUNCTION char GetPublicReturnType(const char *_public);
NAMESPACE_END()
#endif

@ -1,14 +1,14 @@
#include "Quests.hpp"
#include "Quests.h"
#include <components/misc/stringops.hpp>
#include <components/openmw-mp/NetworkMessages.hpp>
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
#include <apps/openmw-mp/Script/Callbacks.hpp>
#include <apps/openmw-mp/Networking.hpp>
using namespace mwmp;
void QuestFunctions::ClearJournalChanges(unsigned short pid) noexcept
extern "C" void QuestFunctions::ClearJournalChanges(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -16,7 +16,7 @@ void QuestFunctions::ClearJournalChanges(unsigned short pid) noexcept
player->journalChanges.journalItems.clear();
}
void QuestFunctions::ClearKillChanges(unsigned short pid) noexcept
extern "C" void QuestFunctions::ClearKillChanges(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -24,7 +24,7 @@ void QuestFunctions::ClearKillChanges(unsigned short pid) noexcept
player->killChanges.kills.clear();
}
unsigned int QuestFunctions::GetJournalChangesSize(unsigned short pid) noexcept
extern "C" unsigned int QuestFunctions::GetJournalChangesSize(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -32,7 +32,7 @@ unsigned int QuestFunctions::GetJournalChangesSize(unsigned short pid) noexcept
return player->journalChanges.count;
}
unsigned int QuestFunctions::GetKillChangesSize(unsigned short pid) noexcept
extern "C" unsigned int QuestFunctions::GetKillChangesSize(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -40,7 +40,7 @@ unsigned int QuestFunctions::GetKillChangesSize(unsigned short pid) noexcept
return player->killChanges.count;
}
void QuestFunctions::AddJournalEntry(unsigned short pid, const char* quest, unsigned int index, const char* actorRefId) noexcept
extern "C" void QuestFunctions::AddJournalEntry(PlayerId pid, const char* quest, unsigned int index, const char* actorRefId) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -55,7 +55,7 @@ void QuestFunctions::AddJournalEntry(unsigned short pid, const char* quest, unsi
player->journalChanges.journalItems.push_back(journalItem);
}
void QuestFunctions::AddJournalEntryWithTimestamp(unsigned short pid, const char* quest, unsigned int index, const char* actorRefId,
extern "C" void QuestFunctions::AddJournalEntryWithTimestamp(PlayerId pid, const char* quest, unsigned int index, const char* actorRefId,
unsigned int daysPassed, unsigned int month, unsigned int day) noexcept
{
Player *player;
@ -75,7 +75,7 @@ void QuestFunctions::AddJournalEntryWithTimestamp(unsigned short pid, const char
player->journalChanges.journalItems.push_back(journalItem);
}
void QuestFunctions::AddJournalIndex(unsigned short pid, const char* quest, unsigned int index) noexcept
extern "C" void QuestFunctions::AddJournalIndex(PlayerId pid, const char* quest, unsigned int index) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -88,7 +88,7 @@ void QuestFunctions::AddJournalIndex(unsigned short pid, const char* quest, unsi
player->journalChanges.journalItems.push_back(journalItem);
}
void QuestFunctions::AddKill(unsigned short pid, const char* refId, int number) noexcept
extern "C" void QuestFunctions::AddKill(PlayerId pid, const char* refId, int number) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -100,7 +100,7 @@ void QuestFunctions::AddKill(unsigned short pid, const char* refId, int number)
player->killChanges.kills.push_back(kill);
}
void QuestFunctions::SetReputation(unsigned short pid, int value) noexcept
extern "C" void QuestFunctions::SetReputation(PlayerId pid, int value) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -108,7 +108,7 @@ void QuestFunctions::SetReputation(unsigned short pid, int value) noexcept
player->npcStats.mReputation = value;
}
const char *QuestFunctions::GetJournalItemQuest(unsigned short pid, unsigned int index) noexcept
extern "C" const char *QuestFunctions::GetJournalItemQuest(PlayerId pid, unsigned int index) noexcept
{
Player *player;
GET_PLAYER(pid, player, "");
@ -119,7 +119,7 @@ const char *QuestFunctions::GetJournalItemQuest(unsigned short pid, unsigned int
return player->journalChanges.journalItems.at(index).quest.c_str();
}
int QuestFunctions::GetJournalItemIndex(unsigned short pid, unsigned int index) noexcept
extern "C" int QuestFunctions::GetJournalItemIndex(PlayerId pid, unsigned int index) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -127,7 +127,7 @@ int QuestFunctions::GetJournalItemIndex(unsigned short pid, unsigned int index)
return player->journalChanges.journalItems.at(index).index;
}
int QuestFunctions::GetJournalItemType(unsigned short pid, unsigned int index) noexcept
extern "C" int QuestFunctions::GetJournalItemType(PlayerId pid, unsigned int index) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -135,7 +135,7 @@ int QuestFunctions::GetJournalItemType(unsigned short pid, unsigned int index) n
return player->journalChanges.journalItems.at(index).type;
}
const char *QuestFunctions::GetJournalItemActorRefId(unsigned short pid, unsigned int index) noexcept
extern "C" const char *QuestFunctions::GetJournalItemActorRefId(PlayerId pid, unsigned int index) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -143,7 +143,7 @@ const char *QuestFunctions::GetJournalItemActorRefId(unsigned short pid, unsigne
return player->journalChanges.journalItems.at(index).actorRefId.c_str();
}
const char *QuestFunctions::GetKillRefId(unsigned short pid, unsigned int index) noexcept
extern "C" const char *QuestFunctions::GetKillRefId(PlayerId pid, unsigned int index) noexcept
{
Player *player;
GET_PLAYER(pid, player, "");
@ -154,7 +154,7 @@ const char *QuestFunctions::GetKillRefId(unsigned short pid, unsigned int index)
return player->killChanges.kills.at(index).refId.c_str();
}
int QuestFunctions::GetKillNumber(unsigned short pid, unsigned int index) noexcept
extern "C" int QuestFunctions::GetKillNumber(PlayerId pid, unsigned int index) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -162,7 +162,7 @@ int QuestFunctions::GetKillNumber(unsigned short pid, unsigned int index) noexce
return player->killChanges.kills.at(index).number;
}
int QuestFunctions::GetReputation(unsigned short pid) noexcept
extern "C" int QuestFunctions::GetReputation(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -170,7 +170,7 @@ int QuestFunctions::GetReputation(unsigned short pid) noexcept
return player->npcStats.mReputation;
}
void QuestFunctions::SendJournalChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
extern "C" void QuestFunctions::SendJournalChanges(PlayerId pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -184,7 +184,7 @@ void QuestFunctions::SendJournalChanges(unsigned short pid, bool sendToOtherPlay
packet->Send(true);
}
void QuestFunctions::SendKillChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
extern "C" void QuestFunctions::SendKillChanges(PlayerId pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -198,7 +198,7 @@ void QuestFunctions::SendKillChanges(unsigned short pid, bool sendToOtherPlayers
packet->Send(true);
}
void QuestFunctions::SendReputation(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
extern "C" void QuestFunctions::SendReputation(PlayerId pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -212,14 +212,14 @@ void QuestFunctions::SendReputation(unsigned short pid, bool sendToOtherPlayers,
packet->Send(true);
}
// All methods below are deprecated versions of methods from above
extern "C" // All methods below are deprecated versions of methods from above
void QuestFunctions::InitializeJournalChanges(unsigned short pid) noexcept
void QuestFunctions::InitializeJournalChanges(PlayerId pid) noexcept
{
ClearJournalChanges(pid);
}
void QuestFunctions::InitializeKillChanges(unsigned short pid) noexcept
extern "C" void QuestFunctions::InitializeKillChanges(PlayerId pid) noexcept
{
ClearKillChanges(pid);
}

@ -1,6 +1,8 @@
#ifndef OPENMW_QUESTAPI_HPP
#define OPENMW_QUESTAPI_HPP
#include "../api.h"
#define QUESTAPI \
{"ClearJournalChanges", QuestFunctions::ClearJournalChanges},\
{"ClearKillChanges", QuestFunctions::ClearKillChanges},\
@ -31,10 +33,7 @@
{"InitializeJournalChanges", QuestFunctions::InitializeJournalChanges},\
{"InitializeKillChanges", QuestFunctions::InitializeKillChanges}
class QuestFunctions
{
public:
NAMESPACE_BEGIN(QuestFunctions)
/**
* \brief Clear the last recorded journal changes for a player.
*
@ -43,7 +42,7 @@ public:
* \param pid The player ID whose journal changes should be used.
* \return void
*/
static void ClearJournalChanges(unsigned short pid) noexcept;
API_FUNCTION void CDECL ClearJournalChanges(PlayerId pid) NOEXCEPT;
/**
* \brief Clear the last recorded kill count changes for a player.
@ -53,7 +52,7 @@ public:
* \param pid The player ID whose kill count changes should be used.
* \return void
*/
static void ClearKillChanges(unsigned short pid) noexcept;
API_FUNCTION void CDECL ClearKillChanges(PlayerId pid) NOEXCEPT;
/**
* \brief Get the number of indexes in a player's latest journal changes.
@ -61,7 +60,7 @@ public:
* \param pid The player ID whose journal changes should be used.
* \return The number of indexes.
*/
static unsigned int GetJournalChangesSize(unsigned short pid) noexcept;
API_FUNCTION unsigned int CDECL GetJournalChangesSize(PlayerId pid) NOEXCEPT;
/**
* \brief Get the number of indexes in a player's latest kill count changes.
@ -69,7 +68,7 @@ public:
* \param pid The player ID whose kill count changes should be used.
* \return The number of indexes.
*/
static unsigned int GetKillChangesSize(unsigned short pid) noexcept;
API_FUNCTION unsigned int CDECL GetKillChangesSize(PlayerId pid) NOEXCEPT;
/**
* \brief Add a new journal item of type ENTRY to the journal changes for a player,
@ -81,7 +80,7 @@ public:
* \param actorRefId The actor refId of the journal item.
* \return void
*/
static void AddJournalEntry(unsigned short pid, const char* quest, unsigned int index, const char* actorRefId) noexcept;
API_FUNCTION void CDECL AddJournalEntry(PlayerId pid, const char* quest, unsigned int index, const char* actorRefId) NOEXCEPT;
/**
* \brief Add a new journal item of type ENTRY to the journal changes for a player,
@ -96,8 +95,8 @@ public:
* \param The day of the month for the journal item.
* \return void
*/
static void AddJournalEntryWithTimestamp(unsigned short pid, const char* quest, unsigned int index, const char* actorRefId,
unsigned int daysPassed, unsigned int month, unsigned int day) noexcept;
API_FUNCTION void CDECL AddJournalEntryWithTimestamp(PlayerId pid, const char* quest, unsigned int index, const char* actorRefId,
unsigned int daysPassed, unsigned int month, unsigned int day) NOEXCEPT;
/**
* \brief Add a new journal item of type INDEX to the journal changes for a player.
@ -107,7 +106,7 @@ public:
* \param index The quest index of the journal item.
* \return void
*/
static void AddJournalIndex(unsigned short pid, const char* quest, unsigned int index) noexcept;
API_FUNCTION void CDECL AddJournalIndex(PlayerId pid, const char* quest, unsigned int index) NOEXCEPT;
/**
* \brief Add a new kill count to the kill count changes for a player.
@ -117,7 +116,7 @@ public:
* \param number The number of kills in the kill count.
* \return void
*/
static void AddKill(unsigned short pid, const char* refId, int number) noexcept;
API_FUNCTION void CDECL AddKill(PlayerId pid, const char* refId, int number) NOEXCEPT;
/**
* \brief Set the reputation of a certain player.
@ -126,7 +125,7 @@ public:
* \param value The reputation.
* \return void
*/
static void SetReputation(unsigned short pid, int value) noexcept;
API_FUNCTION void CDECL SetReputation(PlayerId pid, int value) NOEXCEPT;
/**
* \brief Get the quest at a certain index in a player's latest journal changes.
@ -135,7 +134,7 @@ public:
* \param index The index of the journalItem.
* \return The quest.
*/
static const char *GetJournalItemQuest(unsigned short pid, unsigned int index) noexcept;
API_FUNCTION const char *CDECL GetJournalItemQuest(PlayerId pid, unsigned int index) NOEXCEPT;
/**
* \brief Get the quest index at a certain index in a player's latest journal changes.
@ -144,7 +143,7 @@ public:
* \param index The index of the journalItem.
* \return The quest index.
*/
static int GetJournalItemIndex(unsigned short pid, unsigned int index) noexcept;
API_FUNCTION int CDECL GetJournalItemIndex(PlayerId pid, unsigned int index) NOEXCEPT;
/**
* \brief Get the journal item type at a certain index in a player's latest journal changes.
@ -153,7 +152,7 @@ public:
* \param index The index of the journalItem.
* \return The type (0 for ENTRY, 1 for INDEX).
*/
static int GetJournalItemType(unsigned short pid, unsigned int index) noexcept;
API_FUNCTION int CDECL GetJournalItemType(PlayerId pid, unsigned int index) NOEXCEPT;
/**
* \brief Get the actor refId at a certain index in a player's latest journal changes.
@ -164,7 +163,7 @@ public:
* \param index The index of the journalItem.
* \return The actor refId.
*/
static const char *GetJournalItemActorRefId(unsigned short pid, unsigned int index) noexcept;
API_FUNCTION const char *CDECL GetJournalItemActorRefId(PlayerId pid, unsigned int index) NOEXCEPT;
/**
* \brief Get the refId at a certain index in a player's latest kill count changes.
@ -173,7 +172,7 @@ public:
* \param index The index of the kill count.
* \return The refId.
*/
static const char *GetKillRefId(unsigned short pid, unsigned int index) noexcept;
API_FUNCTION const char *CDECL GetKillRefId(PlayerId pid, unsigned int index) NOEXCEPT;
/**
* \brief Get the number of kills at a certain index in a player's latest kill count changes.
@ -182,7 +181,7 @@ public:
* \param index The index of the kill count.
* \return The number of kills.
*/
static int GetKillNumber(unsigned short pid, unsigned int index) noexcept;
API_FUNCTION int CDECL GetKillNumber(PlayerId pid, unsigned int index) NOEXCEPT;
/**
* \brief Get the a certain player's reputation.
@ -190,7 +189,7 @@ public:
* \param pid The player ID.
* \return The reputation.
*/
static int GetReputation(unsigned short pid) noexcept;
API_FUNCTION int CDECL GetReputation(PlayerId pid) NOEXCEPT;
/**
* \brief Send a PlayerJournal packet with a player's recorded journal changes.
@ -202,7 +201,7 @@ public:
* to the packet (false by default).
* \return void
*/
static void SendJournalChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendJournalChanges(PlayerId pid, bool sendToOtherPlayers, bool skipAttachedPlayer) NOEXCEPT;
/**
* \brief Send a WorldKillCount packet with a player's recorded kill count changes.
@ -214,7 +213,7 @@ public:
* to the packet (false by default).
* \return void
*/
static void SendKillChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendKillChanges(PlayerId pid, bool sendToOtherPlayers, bool skipAttachedPlayer) NOEXCEPT;
/**
* \brief Send a PlayerReputation packet with a player's recorded reputation.
@ -226,15 +225,12 @@ public:
* to the packet (false by default).
* \return void
*/
static void SendReputation(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendReputation(PlayerId pid, bool sendToOtherPlayers, bool skipAttachedPlayer) NOEXCEPT;
// All methods below are deprecated versions of methods from above
static void InitializeJournalChanges(unsigned short pid) noexcept;
static void InitializeKillChanges(unsigned short pid) noexcept;
private:
};
API_FUNCTION void CDECL InitializeJournalChanges(PlayerId pid) NOEXCEPT;
API_FUNCTION void CDECL InitializeKillChanges(PlayerId pid) NOEXCEPT;
NAMESPACE_END()
#endif //OPENMW_QUESTAPI_HPP

@ -3,11 +3,11 @@
#include <apps/openmw-mp/Networking.hpp>
#include <apps/openmw-mp/Player.hpp>
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
#include <apps/openmw-mp/Script/Functions/Worldstate.hpp>
#include <apps/openmw-mp/Script/Callbacks.hpp>
#include <fstream>
#include "RecordsDynamic.hpp"
#include "Worldstate.h"
#include "RecordsDynamic.h"
using namespace std;
using namespace mwmp;
@ -31,7 +31,7 @@ mwmp::Item tempInventoryItem;
const ESM::EffectList emptyEffectList = {};
const ESM::EffectList& GetRecordEffects(unsigned int recordIndex)
extern "C" const ESM::EffectList& GetRecordEffects(unsigned int recordIndex)
{
unsigned short recordsType = RecordsDynamicFunctions::GetRecordType();
@ -45,7 +45,7 @@ const ESM::EffectList& GetRecordEffects(unsigned int recordIndex)
return emptyEffectList;
}
void RecordsDynamicFunctions::ClearRecords() noexcept
extern "C" void RecordsDynamicFunctions::ClearRecords() noexcept
{
WorldstateFunctions::writeWorldstate.spellRecords.clear();
WorldstateFunctions::writeWorldstate.potionRecords.clear();
@ -59,22 +59,22 @@ void RecordsDynamicFunctions::ClearRecords() noexcept
WorldstateFunctions::writeWorldstate.weaponRecords.clear();
}
unsigned short RecordsDynamicFunctions::GetRecordType() noexcept
extern "C" unsigned short RecordsDynamicFunctions::GetRecordType() noexcept
{
return WorldstateFunctions::readWorldstate->recordsType;
}
unsigned int RecordsDynamicFunctions::GetRecordCount() noexcept
extern "C" unsigned int RecordsDynamicFunctions::GetRecordCount() noexcept
{
return WorldstateFunctions::readWorldstate->recordsCount;
}
unsigned int RecordsDynamicFunctions::GetRecordEffectCount(unsigned int recordIndex) noexcept
extern "C" unsigned int RecordsDynamicFunctions::GetRecordEffectCount(unsigned int recordIndex) noexcept
{
return GetRecordEffects(recordIndex).mList.size();
}
int RecordsDynamicFunctions::GetRecordSubtype(unsigned int index) noexcept
extern "C" int RecordsDynamicFunctions::GetRecordSubtype(unsigned int index) noexcept
{
unsigned short readRecordsType = RecordsDynamicFunctions::GetRecordType();
@ -86,7 +86,7 @@ int RecordsDynamicFunctions::GetRecordSubtype(unsigned int index) noexcept
return -1;
}
const char *RecordsDynamicFunctions::GetRecordId(unsigned int index) noexcept
extern "C" const char *RecordsDynamicFunctions::GetRecordId(unsigned int index) noexcept
{
unsigned short readRecordsType = RecordsDynamicFunctions::GetRecordType();
@ -100,7 +100,7 @@ const char *RecordsDynamicFunctions::GetRecordId(unsigned int index) noexcept
return "invalid";
}
const char *RecordsDynamicFunctions::GetRecordBaseId(unsigned int index) noexcept
extern "C" const char *RecordsDynamicFunctions::GetRecordBaseId(unsigned int index) noexcept
{
unsigned short readRecordsType = RecordsDynamicFunctions::GetRecordType();
@ -122,7 +122,7 @@ const char *RecordsDynamicFunctions::GetRecordBaseId(unsigned int index) noexcep
return "invalid";
}
const char *RecordsDynamicFunctions::GetRecordName(unsigned int index) noexcept
extern "C" const char *RecordsDynamicFunctions::GetRecordName(unsigned int index) noexcept
{
unsigned short readRecordsType = RecordsDynamicFunctions::GetRecordType();
@ -142,7 +142,7 @@ const char *RecordsDynamicFunctions::GetRecordName(unsigned int index) noexcept
return "invalid";
}
const char *RecordsDynamicFunctions::GetRecordModel(unsigned int index) noexcept
extern "C" const char *RecordsDynamicFunctions::GetRecordModel(unsigned int index) noexcept
{
unsigned short readRecordsType = RecordsDynamicFunctions::GetRecordType();
@ -152,7 +152,7 @@ const char *RecordsDynamicFunctions::GetRecordModel(unsigned int index) noexcept
return "invalid";
}
const char *RecordsDynamicFunctions::GetRecordIcon(unsigned int index) noexcept
extern "C" const char *RecordsDynamicFunctions::GetRecordIcon(unsigned int index) noexcept
{
unsigned short readRecordsType = RecordsDynamicFunctions::GetRecordType();
@ -162,7 +162,7 @@ const char *RecordsDynamicFunctions::GetRecordIcon(unsigned int index) noexcept
return "invalid";
}
const char *RecordsDynamicFunctions::GetRecordScript(unsigned int index) noexcept
extern "C" const char *RecordsDynamicFunctions::GetRecordScript(unsigned int index) noexcept
{
unsigned short readRecordsType = RecordsDynamicFunctions::GetRecordType();
@ -172,7 +172,7 @@ const char *RecordsDynamicFunctions::GetRecordScript(unsigned int index) noexcep
return "invalid";
}
const char *RecordsDynamicFunctions::GetRecordEnchantmentId(unsigned int index) noexcept
extern "C" const char *RecordsDynamicFunctions::GetRecordEnchantmentId(unsigned int index) noexcept
{
unsigned short readRecordsType = RecordsDynamicFunctions::GetRecordType();
@ -188,7 +188,7 @@ const char *RecordsDynamicFunctions::GetRecordEnchantmentId(unsigned int index)
return "invalid";
}
int RecordsDynamicFunctions::GetRecordEnchantmentCharge(unsigned int index) noexcept
extern "C" int RecordsDynamicFunctions::GetRecordEnchantmentCharge(unsigned int index) noexcept
{
unsigned short readRecordsType = RecordsDynamicFunctions::GetRecordType();
@ -204,7 +204,7 @@ int RecordsDynamicFunctions::GetRecordEnchantmentCharge(unsigned int index) noex
return -1;
}
int RecordsDynamicFunctions::GetRecordAutoCalc(unsigned int index) noexcept
extern "C" int RecordsDynamicFunctions::GetRecordAutoCalc(unsigned int index) noexcept
{
unsigned short readRecordsType = RecordsDynamicFunctions::GetRecordType();
@ -216,7 +216,7 @@ int RecordsDynamicFunctions::GetRecordAutoCalc(unsigned int index) noexcept
return -1;
}
int RecordsDynamicFunctions::GetRecordCharge(unsigned int index) noexcept
extern "C" int RecordsDynamicFunctions::GetRecordCharge(unsigned int index) noexcept
{
unsigned short readRecordsType = RecordsDynamicFunctions::GetRecordType();
@ -226,7 +226,7 @@ int RecordsDynamicFunctions::GetRecordCharge(unsigned int index) noexcept
return -1;
}
int RecordsDynamicFunctions::GetRecordCost(unsigned int index) noexcept
extern "C" int RecordsDynamicFunctions::GetRecordCost(unsigned int index) noexcept
{
unsigned short readRecordsType = RecordsDynamicFunctions::GetRecordType();
@ -238,7 +238,7 @@ int RecordsDynamicFunctions::GetRecordCost(unsigned int index) noexcept
return -1;
}
int RecordsDynamicFunctions::GetRecordFlags(unsigned int index) noexcept
extern "C" int RecordsDynamicFunctions::GetRecordFlags(unsigned int index) noexcept
{
unsigned short readRecordsType = RecordsDynamicFunctions::GetRecordType();
@ -248,7 +248,7 @@ int RecordsDynamicFunctions::GetRecordFlags(unsigned int index) noexcept
return -1;
}
int RecordsDynamicFunctions::GetRecordValue(unsigned int index) noexcept
extern "C" int RecordsDynamicFunctions::GetRecordValue(unsigned int index) noexcept
{
unsigned short readRecordsType = RecordsDynamicFunctions::GetRecordType();
@ -258,7 +258,7 @@ int RecordsDynamicFunctions::GetRecordValue(unsigned int index) noexcept
return -1;
}
double RecordsDynamicFunctions::GetRecordWeight(unsigned int index) noexcept
extern "C" double RecordsDynamicFunctions::GetRecordWeight(unsigned int index) noexcept
{
unsigned short readRecordsType = RecordsDynamicFunctions::GetRecordType();
@ -268,52 +268,52 @@ double RecordsDynamicFunctions::GetRecordWeight(unsigned int index) noexcept
return -1;
}
unsigned int RecordsDynamicFunctions::GetRecordEffectId(unsigned int recordIndex, unsigned int effectIndex) noexcept
extern "C" unsigned int RecordsDynamicFunctions::GetRecordEffectId(unsigned int recordIndex, unsigned int effectIndex) noexcept
{
return GetRecordEffects(recordIndex).mList.at(effectIndex).mEffectID;
}
int RecordsDynamicFunctions::GetRecordEffectAttribute(unsigned int recordIndex, unsigned int effectIndex) noexcept
extern "C" int RecordsDynamicFunctions::GetRecordEffectAttribute(unsigned int recordIndex, unsigned int effectIndex) noexcept
{
return GetRecordEffects(recordIndex).mList.at(effectIndex).mAttribute;
}
int RecordsDynamicFunctions::GetRecordEffectSkill(unsigned int recordIndex, unsigned int effectIndex) noexcept
extern "C" int RecordsDynamicFunctions::GetRecordEffectSkill(unsigned int recordIndex, unsigned int effectIndex) noexcept
{
return GetRecordEffects(recordIndex).mList.at(effectIndex).mSkill;
}
unsigned int RecordsDynamicFunctions::GetRecordEffectRangeType(unsigned int recordIndex, unsigned int effectIndex) noexcept
extern "C" unsigned int RecordsDynamicFunctions::GetRecordEffectRangeType(unsigned int recordIndex, unsigned int effectIndex) noexcept
{
return GetRecordEffects(recordIndex).mList.at(effectIndex).mRange;
}
int RecordsDynamicFunctions::GetRecordEffectArea(unsigned int recordIndex, unsigned int effectIndex) noexcept
extern "C" int RecordsDynamicFunctions::GetRecordEffectArea(unsigned int recordIndex, unsigned int effectIndex) noexcept
{
return GetRecordEffects(recordIndex).mList.at(effectIndex).mArea;
}
int RecordsDynamicFunctions::GetRecordEffectDuration(unsigned int recordIndex, unsigned int effectIndex) noexcept
extern "C" int RecordsDynamicFunctions::GetRecordEffectDuration(unsigned int recordIndex, unsigned int effectIndex) noexcept
{
return GetRecordEffects(recordIndex).mList.at(effectIndex).mDuration;
}
int RecordsDynamicFunctions::GetRecordEffectMagnitudeMax(unsigned int recordIndex, unsigned int effectIndex) noexcept
extern "C" int RecordsDynamicFunctions::GetRecordEffectMagnitudeMax(unsigned int recordIndex, unsigned int effectIndex) noexcept
{
return GetRecordEffects(recordIndex).mList.at(effectIndex).mMagnMax;
}
int RecordsDynamicFunctions::GetRecordEffectMagnitudeMin(unsigned int recordIndex, unsigned int effectIndex) noexcept
extern "C" int RecordsDynamicFunctions::GetRecordEffectMagnitudeMin(unsigned int recordIndex, unsigned int effectIndex) noexcept
{
return GetRecordEffects(recordIndex).mList.at(effectIndex).mMagnMin;
}
void RecordsDynamicFunctions::SetRecordType(unsigned int type) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordType(unsigned int type) noexcept
{
WorldstateFunctions::writeWorldstate.recordsType = type;
}
void RecordsDynamicFunctions::SetRecordId(const char* id) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordId(const char* id) noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;
@ -342,7 +342,7 @@ void RecordsDynamicFunctions::SetRecordId(const char* id) noexcept
LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, "Tried to set id for record type %i which lacks that property", writeRecordsType);
}
void RecordsDynamicFunctions::SetRecordBaseId(const char* baseId) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordBaseId(const char* baseId) noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;
@ -370,7 +370,7 @@ void RecordsDynamicFunctions::SetRecordBaseId(const char* baseId) noexcept
LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, "Tried to set baseId for record type %i which lacks that property", writeRecordsType);
}
void RecordsDynamicFunctions::SetRecordInventoryBaseId(const char* inventoryBaseId) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordInventoryBaseId(const char* inventoryBaseId) noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;
@ -382,7 +382,7 @@ void RecordsDynamicFunctions::SetRecordInventoryBaseId(const char* inventoryBase
LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, "Tried to set inventoryBaseId for record type %i which lacks that property", writeRecordsType);
}
void RecordsDynamicFunctions::SetRecordSubtype(unsigned int subtype) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordSubtype(unsigned int subtype) noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;
@ -407,7 +407,7 @@ void RecordsDynamicFunctions::SetRecordSubtype(unsigned int subtype) noexcept
tempOverrides.hasSubtype = true;
}
void RecordsDynamicFunctions::SetRecordName(const char* name) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordName(const char* name) noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;
@ -438,7 +438,7 @@ void RecordsDynamicFunctions::SetRecordName(const char* name) noexcept
tempOverrides.hasName = true;
}
void RecordsDynamicFunctions::SetRecordModel(const char* model) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordModel(const char* model) noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;
@ -467,7 +467,7 @@ void RecordsDynamicFunctions::SetRecordModel(const char* model) noexcept
tempOverrides.hasModel = true;
}
void RecordsDynamicFunctions::SetRecordIcon(const char* icon) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordIcon(const char* icon) noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;
@ -492,7 +492,7 @@ void RecordsDynamicFunctions::SetRecordIcon(const char* icon) noexcept
tempOverrides.hasIcon = true;
}
void RecordsDynamicFunctions::SetRecordScript(const char* script) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordScript(const char* script) noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;
@ -521,7 +521,7 @@ void RecordsDynamicFunctions::SetRecordScript(const char* script) noexcept
tempOverrides.hasScript = true;
}
void RecordsDynamicFunctions::SetRecordEnchantmentId(const char* enchantmentId) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordEnchantmentId(const char* enchantmentId) noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;
@ -542,7 +542,7 @@ void RecordsDynamicFunctions::SetRecordEnchantmentId(const char* enchantmentId)
tempOverrides.hasEnchantmentId = true;
}
void RecordsDynamicFunctions::SetRecordEnchantmentCharge(int enchantmentCharge) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordEnchantmentCharge(int enchantmentCharge) noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;
@ -563,7 +563,7 @@ void RecordsDynamicFunctions::SetRecordEnchantmentCharge(int enchantmentCharge)
tempOverrides.hasEnchantmentCharge = true;
}
void RecordsDynamicFunctions::SetRecordAutoCalc(int autoCalc) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordAutoCalc(int autoCalc) noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;
@ -593,7 +593,7 @@ void RecordsDynamicFunctions::SetRecordAutoCalc(int autoCalc) noexcept
tempOverrides.hasAutoCalc = true;
}
void RecordsDynamicFunctions::SetRecordCharge(int charge) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordCharge(int charge) noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;
@ -608,7 +608,7 @@ void RecordsDynamicFunctions::SetRecordCharge(int charge) noexcept
tempOverrides.hasCharge = true;
}
void RecordsDynamicFunctions::SetRecordCost(int cost) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordCost(int cost) noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;
@ -625,7 +625,7 @@ void RecordsDynamicFunctions::SetRecordCost(int cost) noexcept
tempOverrides.hasCost = true;
}
void RecordsDynamicFunctions::SetRecordFlags(int flags) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordFlags(int flags) noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;
@ -646,7 +646,7 @@ void RecordsDynamicFunctions::SetRecordFlags(int flags) noexcept
tempOverrides.hasFlags = true;
}
void RecordsDynamicFunctions::SetRecordValue(int value) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordValue(int value) noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;
@ -671,7 +671,7 @@ void RecordsDynamicFunctions::SetRecordValue(int value) noexcept
tempOverrides.hasValue = true;
}
void RecordsDynamicFunctions::SetRecordWeight(double weight) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordWeight(double weight) noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;
@ -696,7 +696,7 @@ void RecordsDynamicFunctions::SetRecordWeight(double weight) noexcept
tempOverrides.hasWeight = true;
}
void RecordsDynamicFunctions::SetRecordArmorRating(int armorRating) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordArmorRating(int armorRating) noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;
@ -711,7 +711,7 @@ void RecordsDynamicFunctions::SetRecordArmorRating(int armorRating) noexcept
tempOverrides.hasArmorRating = true;
}
void RecordsDynamicFunctions::SetRecordHealth(int health) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordHealth(int health) noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;
@ -732,7 +732,7 @@ void RecordsDynamicFunctions::SetRecordHealth(int health) noexcept
tempOverrides.hasHealth = true;
}
void RecordsDynamicFunctions::SetRecordDamageChop(unsigned int minDamage, unsigned int maxDamage) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordDamageChop(unsigned int minDamage, unsigned int maxDamage) noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;
@ -750,7 +750,7 @@ void RecordsDynamicFunctions::SetRecordDamageChop(unsigned int minDamage, unsign
tempOverrides.hasDamageChop = true;
}
void RecordsDynamicFunctions::SetRecordDamageSlash(unsigned int minDamage, unsigned int maxDamage) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordDamageSlash(unsigned int minDamage, unsigned int maxDamage) noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;
@ -768,7 +768,7 @@ void RecordsDynamicFunctions::SetRecordDamageSlash(unsigned int minDamage, unsig
tempOverrides.hasDamageSlash = true;
}
void RecordsDynamicFunctions::SetRecordDamageThrust(unsigned int minDamage, unsigned int maxDamage) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordDamageThrust(unsigned int minDamage, unsigned int maxDamage) noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;
@ -786,7 +786,7 @@ void RecordsDynamicFunctions::SetRecordDamageThrust(unsigned int minDamage, unsi
tempOverrides.hasDamageThrust = true;
}
void RecordsDynamicFunctions::SetRecordReach(double reach) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordReach(double reach) noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;
@ -801,7 +801,7 @@ void RecordsDynamicFunctions::SetRecordReach(double reach) noexcept
tempOverrides.hasReach = true;
}
void RecordsDynamicFunctions::SetRecordSpeed(double speed) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordSpeed(double speed) noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;
@ -816,7 +816,7 @@ void RecordsDynamicFunctions::SetRecordSpeed(double speed) noexcept
tempOverrides.hasSpeed = true;
}
void RecordsDynamicFunctions::SetRecordKeyState(bool keyState) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordKeyState(bool keyState) noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;
@ -831,7 +831,7 @@ void RecordsDynamicFunctions::SetRecordKeyState(bool keyState) noexcept
tempOverrides.hasKeyState = true;
}
void RecordsDynamicFunctions::SetRecordScrollState(bool scrollState) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordScrollState(bool scrollState) noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;
@ -846,7 +846,7 @@ void RecordsDynamicFunctions::SetRecordScrollState(bool scrollState) noexcept
tempOverrides.hasScrollState = true;
}
void RecordsDynamicFunctions::SetRecordSkillId(int skillId) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordSkillId(int skillId) noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;
@ -861,7 +861,7 @@ void RecordsDynamicFunctions::SetRecordSkillId(int skillId) noexcept
tempOverrides.hasSkillId = true;
}
void RecordsDynamicFunctions::SetRecordText(const char* text) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordText(const char* text) noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;
@ -876,7 +876,7 @@ void RecordsDynamicFunctions::SetRecordText(const char* text) noexcept
tempOverrides.hasText = true;
}
void RecordsDynamicFunctions::SetRecordHair(const char* hair) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordHair(const char* hair) noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;
@ -891,7 +891,7 @@ void RecordsDynamicFunctions::SetRecordHair(const char* hair) noexcept
tempOverrides.hasHair = true;
}
void RecordsDynamicFunctions::SetRecordHead(const char* head) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordHead(const char* head) noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;
@ -906,7 +906,7 @@ void RecordsDynamicFunctions::SetRecordHead(const char* head) noexcept
tempOverrides.hasHead = true;
}
void RecordsDynamicFunctions::SetRecordGender(unsigned int gender) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordGender(unsigned int gender) noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;
@ -923,7 +923,7 @@ void RecordsDynamicFunctions::SetRecordGender(unsigned int gender) noexcept
tempOverrides.hasGender = true;
}
void RecordsDynamicFunctions::SetRecordRace(const char* race) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordRace(const char* race) noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;
@ -933,7 +933,7 @@ void RecordsDynamicFunctions::SetRecordRace(const char* race) noexcept
LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, "Tried to set race for record type %i which lacks that property", writeRecordsType);
}
void RecordsDynamicFunctions::SetRecordClass(const char* charClass) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordClass(const char* charClass) noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;
@ -943,7 +943,7 @@ void RecordsDynamicFunctions::SetRecordClass(const char* charClass) noexcept
LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, "Tried to set character class for record type %i which lacks that property", writeRecordsType);
}
void RecordsDynamicFunctions::SetRecordFaction(const char* faction) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordFaction(const char* faction) noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;
@ -958,7 +958,7 @@ void RecordsDynamicFunctions::SetRecordFaction(const char* faction) noexcept
tempOverrides.hasFaction = true;
}
void RecordsDynamicFunctions::SetRecordLevel(int level) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordLevel(int level) noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;
@ -975,7 +975,7 @@ void RecordsDynamicFunctions::SetRecordLevel(int level) noexcept
tempOverrides.hasLevel = true;
}
void RecordsDynamicFunctions::SetRecordMagicka(int magicka) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordMagicka(int magicka) noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;
@ -992,7 +992,7 @@ void RecordsDynamicFunctions::SetRecordMagicka(int magicka) noexcept
tempOverrides.hasMagicka = true;
}
void RecordsDynamicFunctions::SetRecordFatigue(int fatigue) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordFatigue(int fatigue) noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;
@ -1009,7 +1009,7 @@ void RecordsDynamicFunctions::SetRecordFatigue(int fatigue) noexcept
tempOverrides.hasFatigue = true;
}
void RecordsDynamicFunctions::SetRecordAIFight(int aiFight) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordAIFight(int aiFight) noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;
@ -1026,7 +1026,7 @@ void RecordsDynamicFunctions::SetRecordAIFight(int aiFight) noexcept
tempOverrides.hasAiFight = true;
}
void RecordsDynamicFunctions::SetRecordIdByIndex(unsigned int index, const char* id) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordIdByIndex(unsigned int index, const char* id) noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;
@ -1048,7 +1048,7 @@ void RecordsDynamicFunctions::SetRecordIdByIndex(unsigned int index, const char*
LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, "Tried to set id for record type %i which lacks that property", writeRecordsType);
}
void RecordsDynamicFunctions::SetRecordEnchantmentIdByIndex(unsigned int index, const char* enchantmentId) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordEnchantmentIdByIndex(unsigned int index, const char* enchantmentId) noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;
@ -1064,72 +1064,72 @@ void RecordsDynamicFunctions::SetRecordEnchantmentIdByIndex(unsigned int index,
LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, "Tried to set enchantmentId for record type %i which lacks that property", writeRecordsType);
}
void RecordsDynamicFunctions::SetRecordEffectId(unsigned int effectId) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordEffectId(unsigned int effectId) noexcept
{
tempEffect.mEffectID = effectId;
}
void RecordsDynamicFunctions::SetRecordEffectAttribute(int attributeId) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordEffectAttribute(int attributeId) noexcept
{
tempEffect.mAttribute = attributeId;
}
void RecordsDynamicFunctions::SetRecordEffectSkill(int skillId) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordEffectSkill(int skillId) noexcept
{
tempEffect.mSkill = skillId;
}
void RecordsDynamicFunctions::SetRecordEffectRangeType(unsigned int rangeType) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordEffectRangeType(unsigned int rangeType) noexcept
{
tempEffect.mRange = rangeType;
}
void RecordsDynamicFunctions::SetRecordEffectArea(int area) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordEffectArea(int area) noexcept
{
tempEffect.mArea = area;
}
void RecordsDynamicFunctions::SetRecordEffectDuration(int duration) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordEffectDuration(int duration) noexcept
{
tempEffect.mDuration = duration;
}
void RecordsDynamicFunctions::SetRecordEffectMagnitudeMax(int magnitudeMax) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordEffectMagnitudeMax(int magnitudeMax) noexcept
{
tempEffect.mMagnMax = magnitudeMax;
}
void RecordsDynamicFunctions::SetRecordEffectMagnitudeMin(int magnitudeMin) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordEffectMagnitudeMin(int magnitudeMin) noexcept
{
tempEffect.mMagnMin = magnitudeMin;
}
void RecordsDynamicFunctions::SetRecordBodyPartType(unsigned int partType) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordBodyPartType(unsigned int partType) noexcept
{
tempBodyPart.mPart = partType;
}
void RecordsDynamicFunctions::SetRecordBodyPartIdForMale(const char* partId) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordBodyPartIdForMale(const char* partId) noexcept
{
tempBodyPart.mMale = partId;
}
void RecordsDynamicFunctions::SetRecordBodyPartIdForFemale(const char* partId) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordBodyPartIdForFemale(const char* partId) noexcept
{
tempBodyPart.mFemale = partId;
}
void RecordsDynamicFunctions::SetRecordInventoryItemId(const char* itemId) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordInventoryItemId(const char* itemId) noexcept
{
tempInventoryItem.refId = itemId;
}
void RecordsDynamicFunctions::SetRecordInventoryItemCount(unsigned int count) noexcept
extern "C" void RecordsDynamicFunctions::SetRecordInventoryItemCount(unsigned int count) noexcept
{
tempInventoryItem.count = count;
}
void RecordsDynamicFunctions::AddRecord() noexcept
extern "C" void RecordsDynamicFunctions::AddRecord() noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;
@ -1197,7 +1197,7 @@ void RecordsDynamicFunctions::AddRecord() noexcept
tempOverrides = {};
}
void RecordsDynamicFunctions::AddRecordEffect() noexcept
extern "C" void RecordsDynamicFunctions::AddRecordEffect() noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;
@ -1212,7 +1212,7 @@ void RecordsDynamicFunctions::AddRecordEffect() noexcept
tempEffect = {};
}
void RecordsDynamicFunctions::AddRecordBodyPart() noexcept
extern "C" void RecordsDynamicFunctions::AddRecordBodyPart() noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;
@ -1225,7 +1225,7 @@ void RecordsDynamicFunctions::AddRecordBodyPart() noexcept
tempBodyPart = {};
}
void RecordsDynamicFunctions::AddRecordInventoryItem() noexcept
extern "C" void RecordsDynamicFunctions::AddRecordInventoryItem() noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;
@ -1238,7 +1238,7 @@ void RecordsDynamicFunctions::AddRecordInventoryItem() noexcept
tempInventoryItem = {};
}
void RecordsDynamicFunctions::SendRecordDynamic(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
extern "C" void RecordsDynamicFunctions::SendRecordDynamic(PlayerId pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
{
Player *player;
GET_PLAYER(pid, player, );

@ -1,125 +1,15 @@
#ifndef OPENMW_RECORDSDYNAMICAPI_HPP
#define OPENMW_RECORDSDYNAMICAPI_HPP
#include "../Types.hpp"
#define RECORDSDYNAMICAPI \
{"ClearRecords", RecordsDynamicFunctions::ClearRecords},\
\
{"GetRecordType", RecordsDynamicFunctions::GetRecordType},\
{"GetRecordCount", RecordsDynamicFunctions::GetRecordCount},\
{"GetRecordEffectCount", RecordsDynamicFunctions::GetRecordEffectCount},\
\
{"GetRecordId", RecordsDynamicFunctions::GetRecordId},\
{"GetRecordBaseId", RecordsDynamicFunctions::GetRecordBaseId},\
\
{"GetRecordSubtype", RecordsDynamicFunctions::GetRecordSubtype},\
{"GetRecordName", RecordsDynamicFunctions::GetRecordName},\
{"GetRecordModel", RecordsDynamicFunctions::GetRecordModel},\
{"GetRecordIcon", RecordsDynamicFunctions::GetRecordIcon},\
{"GetRecordScript", RecordsDynamicFunctions::GetRecordScript},\
{"GetRecordEnchantmentId", RecordsDynamicFunctions::GetRecordEnchantmentId},\
{"GetRecordEnchantmentCharge", RecordsDynamicFunctions::GetRecordEnchantmentCharge},\
\
{"GetRecordAutoCalc", RecordsDynamicFunctions::GetRecordAutoCalc},\
{"GetRecordCharge", RecordsDynamicFunctions::GetRecordCharge},\
{"GetRecordCost", RecordsDynamicFunctions::GetRecordCost},\
{"GetRecordFlags", RecordsDynamicFunctions::GetRecordFlags},\
{"GetRecordValue", RecordsDynamicFunctions::GetRecordValue},\
{"GetRecordWeight", RecordsDynamicFunctions::GetRecordWeight},\
\
{"GetRecordEffectId", RecordsDynamicFunctions::GetRecordEffectId},\
{"GetRecordEffectAttribute", RecordsDynamicFunctions::GetRecordEffectAttribute},\
{"GetRecordEffectSkill", RecordsDynamicFunctions::GetRecordEffectSkill},\
{"GetRecordEffectRangeType", RecordsDynamicFunctions::GetRecordEffectRangeType},\
{"GetRecordEffectArea", RecordsDynamicFunctions::GetRecordEffectArea},\
{"GetRecordEffectDuration", RecordsDynamicFunctions::GetRecordEffectDuration},\
{"GetRecordEffectMagnitudeMax", RecordsDynamicFunctions::GetRecordEffectMagnitudeMax},\
{"GetRecordEffectMagnitudeMin", RecordsDynamicFunctions::GetRecordEffectMagnitudeMin},\
\
{"SetRecordType", RecordsDynamicFunctions::SetRecordType},\
\
{"SetRecordId", RecordsDynamicFunctions::SetRecordId},\
{"SetRecordBaseId", RecordsDynamicFunctions::SetRecordBaseId},\
{"SetRecordInventoryBaseId", RecordsDynamicFunctions::SetRecordInventoryBaseId},\
\
{"SetRecordSubtype", RecordsDynamicFunctions::SetRecordSubtype},\
{"SetRecordName", RecordsDynamicFunctions::SetRecordName},\
{"SetRecordModel", RecordsDynamicFunctions::SetRecordModel},\
{"SetRecordIcon", RecordsDynamicFunctions::SetRecordIcon},\
{"SetRecordScript", RecordsDynamicFunctions::SetRecordScript},\
{"SetRecordEnchantmentId", RecordsDynamicFunctions::SetRecordEnchantmentId},\
{"SetRecordEnchantmentCharge", RecordsDynamicFunctions::SetRecordEnchantmentCharge},\
\
{"SetRecordAutoCalc", RecordsDynamicFunctions::SetRecordAutoCalc},\
{"SetRecordCharge", RecordsDynamicFunctions::SetRecordCharge},\
{"SetRecordCost", RecordsDynamicFunctions::SetRecordCost},\
{"SetRecordFlags", RecordsDynamicFunctions::SetRecordFlags},\
{"SetRecordValue", RecordsDynamicFunctions::SetRecordValue},\
{"SetRecordWeight", RecordsDynamicFunctions::SetRecordWeight},\
\
{"SetRecordArmorRating", RecordsDynamicFunctions::SetRecordArmorRating},\
{"SetRecordHealth", RecordsDynamicFunctions::SetRecordHealth},\
\
{"SetRecordDamageChop", RecordsDynamicFunctions::SetRecordDamageChop},\
{"SetRecordDamageSlash", RecordsDynamicFunctions::SetRecordDamageSlash},\
{"SetRecordDamageThrust", RecordsDynamicFunctions::SetRecordDamageThrust},\
{"SetRecordReach", RecordsDynamicFunctions::SetRecordReach},\
{"SetRecordSpeed", RecordsDynamicFunctions::SetRecordSpeed},\
\
{"SetRecordKeyState", RecordsDynamicFunctions::SetRecordKeyState},\
{"SetRecordScrollState", RecordsDynamicFunctions::SetRecordScrollState},\
{"SetRecordSkillId", RecordsDynamicFunctions::SetRecordSkillId},\
{"SetRecordText", RecordsDynamicFunctions::SetRecordText},\
\
{"SetRecordHair", RecordsDynamicFunctions::SetRecordHair},\
{"SetRecordHead", RecordsDynamicFunctions::SetRecordHead},\
{"SetRecordGender", RecordsDynamicFunctions::SetRecordGender},\
{"SetRecordRace", RecordsDynamicFunctions::SetRecordRace},\
{"SetRecordClass", RecordsDynamicFunctions::SetRecordClass},\
{"SetRecordFaction", RecordsDynamicFunctions::SetRecordFaction},\
\
{"SetRecordLevel", RecordsDynamicFunctions::SetRecordLevel},\
{"SetRecordMagicka", RecordsDynamicFunctions::SetRecordMagicka},\
{"SetRecordFatigue", RecordsDynamicFunctions::SetRecordFatigue},\
{"SetRecordAIFight", RecordsDynamicFunctions::SetRecordAIFight},\
\
{"SetRecordIdByIndex", RecordsDynamicFunctions::SetRecordIdByIndex},\
{"SetRecordEnchantmentIdByIndex", RecordsDynamicFunctions::SetRecordEnchantmentIdByIndex},\
\
{"SetRecordEffectId", RecordsDynamicFunctions::SetRecordEffectId},\
{"SetRecordEffectAttribute", RecordsDynamicFunctions::SetRecordEffectAttribute},\
{"SetRecordEffectSkill", RecordsDynamicFunctions::SetRecordEffectSkill},\
{"SetRecordEffectRangeType", RecordsDynamicFunctions::SetRecordEffectRangeType},\
{"SetRecordEffectArea", RecordsDynamicFunctions::SetRecordEffectArea},\
{"SetRecordEffectDuration", RecordsDynamicFunctions::SetRecordEffectDuration},\
{"SetRecordEffectMagnitudeMax", RecordsDynamicFunctions::SetRecordEffectMagnitudeMax},\
{"SetRecordEffectMagnitudeMin", RecordsDynamicFunctions::SetRecordEffectMagnitudeMin},\
\
{"SetRecordBodyPartType", RecordsDynamicFunctions::SetRecordBodyPartType},\
{"SetRecordBodyPartIdForMale", RecordsDynamicFunctions::SetRecordBodyPartIdForMale},\
{"SetRecordBodyPartIdForFemale", RecordsDynamicFunctions::SetRecordBodyPartIdForFemale},\
\
{"SetRecordInventoryItemId", RecordsDynamicFunctions::SetRecordInventoryItemId},\
{"SetRecordInventoryItemCount", RecordsDynamicFunctions::SetRecordInventoryItemCount},\
\
{"AddRecord", RecordsDynamicFunctions::AddRecord},\
{"AddRecordEffect", RecordsDynamicFunctions::AddRecordEffect},\
{"AddRecordBodyPart", RecordsDynamicFunctions::AddRecordBodyPart},\
{"AddRecordInventoryItem", RecordsDynamicFunctions::AddRecordInventoryItem},\
\
{"SendRecordDynamic", RecordsDynamicFunctions::SendRecordDynamic}
class RecordsDynamicFunctions
{
public:
#include "../api.h"
NAMESPACE_BEGIN(RecordsDynamicFunctions)
/**
* \brief Clear the data from the records stored on the server.
*
* \return void
*/
static void ClearRecords() noexcept;
API_FUNCTION void CDECL ClearRecords() NOEXCEPT;
/**
* \brief Get the type of records in the read worldstate's dynamic records.
@ -127,14 +17,14 @@ public:
* \return The type of records (0 for SPELL, 1 for POTION, 2 for ENCHANTMENT,
* 3 for NPC).
*/
static unsigned short GetRecordType() noexcept;
API_FUNCTION unsigned short CDECL GetRecordType() NOEXCEPT;
/**
* \brief Get the number of records in the read worldstate's dynamic records.
*
* \return The number of records.
*/
static unsigned int GetRecordCount() noexcept;
API_FUNCTION unsigned int CDECL GetRecordCount() NOEXCEPT;
/**
* \brief Get the number of effects for the record at a certain index in the read
@ -143,7 +33,7 @@ public:
* \param recordIndex The index of the record.
* \return The number of effects.
*/
static unsigned int GetRecordEffectCount(unsigned int recordIndex) noexcept;
API_FUNCTION unsigned int CDECL GetRecordEffectCount(unsigned int recordIndex) NOEXCEPT;
/**
* \brief Get the id of the record at a certain index in the read worldstate's
@ -152,7 +42,7 @@ public:
* \param index The index of the record.
* \return The id of the record.
*/
static const char *GetRecordId(unsigned int index) noexcept;
API_FUNCTION const char *CDECL GetRecordId(unsigned int index) NOEXCEPT;
/**
* \brief Get the base id (i.e. the id this record should inherit default
@ -162,7 +52,7 @@ public:
* \param index The index of the record.
* \return The base id of the record.
*/
static const char *GetRecordBaseId(unsigned int index) noexcept;
API_FUNCTION const char *CDECL GetRecordBaseId(unsigned int index) NOEXCEPT;
/**
* \brief Get the subtype of the record at a certain index in the read worldstate's
@ -171,7 +61,7 @@ public:
* \param index The index of the record.
* \return The type of the record.
*/
static int GetRecordSubtype(unsigned int index) noexcept;
API_FUNCTION int CDECL GetRecordSubtype(unsigned int index) NOEXCEPT;
/**
* \brief Get the name of the record at a certain index in the read worldstate's
@ -180,7 +70,7 @@ public:
* \param index The index of the record.
* \return The name of the record.
*/
static const char *GetRecordName(unsigned int index) noexcept;
API_FUNCTION const char *CDECL GetRecordName(unsigned int index) NOEXCEPT;
/**
* \brief Get the model of the record at a certain index in the read worldstate's
@ -189,7 +79,7 @@ public:
* \param index The index of the record.
* \return The model of the record.
*/
static const char *GetRecordModel(unsigned int index) noexcept;
API_FUNCTION const char *CDECL GetRecordModel(unsigned int index) NOEXCEPT;
/**
* \brief Get the icon of the record at a certain index in the read worldstate's
@ -198,7 +88,7 @@ public:
* \param index The index of the record.
* \return The icon of the record.
*/
static const char *GetRecordIcon(unsigned int index) noexcept;
API_FUNCTION const char *CDECL GetRecordIcon(unsigned int index) NOEXCEPT;
/**
* \brief Get the script of the record at a certain index in the read worldstate's
@ -207,7 +97,7 @@ public:
* \param index The index of the record.
* \return The script of the record.
*/
static const char *GetRecordScript(unsigned int index) noexcept;
API_FUNCTION const char *CDECL GetRecordScript(unsigned int index) NOEXCEPT;
/**
* \brief Get the enchantment id of the record at a certain index in the read
@ -216,7 +106,7 @@ public:
* \param index The index of the record.
* \return The enchantment id of the record.
*/
static const char *GetRecordEnchantmentId(unsigned int index) noexcept;
API_FUNCTION const char *CDECL GetRecordEnchantmentId(unsigned int index) NOEXCEPT;
/**
* \brief Get the enchantment charge of the record at a certain index in
@ -225,7 +115,7 @@ public:
* \param index The index of the record.
* \return The enchantment charge of the record.
*/
static int GetRecordEnchantmentCharge(unsigned int index) noexcept;
API_FUNCTION int CDECL GetRecordEnchantmentCharge(unsigned int index) NOEXCEPT;
/**
* \brief Get the auto-calculation flag value of the record at a certain index in
@ -234,7 +124,7 @@ public:
* \param index The index of the record.
* \return The auto-calculation flag value of the record.
*/
static int GetRecordAutoCalc(unsigned int index) noexcept;
API_FUNCTION int CDECL GetRecordAutoCalc(unsigned int index) NOEXCEPT;
/**
* \brief Get the charge of the record at a certain index in the read worldstate's
@ -243,7 +133,7 @@ public:
* \param index The index of the record.
* \return The charge of the record.
*/
static int GetRecordCharge(unsigned int index) noexcept;
API_FUNCTION int CDECL GetRecordCharge(unsigned int index) NOEXCEPT;
/**
* \brief Get the cost of the record at a certain index in the read worldstate's
@ -252,7 +142,7 @@ public:
* \param index The index of the record.
* \return The cost of the record.
*/
static int GetRecordCost(unsigned int index) noexcept;
API_FUNCTION int CDECL GetRecordCost(unsigned int index) NOEXCEPT;
/**
* \brief Get the flags of the record at a certain index in the read worldstate's
@ -261,7 +151,7 @@ public:
* \param index The index of the record.
* \return The flags of the spell as an integer.
*/
static int GetRecordFlags(unsigned int index) noexcept;
API_FUNCTION int CDECL GetRecordFlags(unsigned int index) NOEXCEPT;
/**
* \brief Get the value of the record at a certain index in the read worldstate's
@ -270,7 +160,7 @@ public:
* \param index The index of the record.
* \return The value of the record.
*/
static int GetRecordValue(unsigned int index) noexcept;
API_FUNCTION int CDECL GetRecordValue(unsigned int index) NOEXCEPT;
/**
* \brief Get the weight of the record at a certain index in the read worldstate's
@ -279,7 +169,7 @@ public:
* \param index The index of the record.
* \return The weight of the record.
*/
static double GetRecordWeight(unsigned int index) noexcept;
API_FUNCTION double CDECL GetRecordWeight(unsigned int index) NOEXCEPT;
/**
* \brief Get the ID of the effect at a certain index in the read worldstate's
@ -289,7 +179,7 @@ public:
* \param effectIndex The index of the effect.
* \return The ID of the effect.
*/
static unsigned int GetRecordEffectId(unsigned int recordIndex, unsigned int effectIndex) noexcept;
API_FUNCTION unsigned int CDECL GetRecordEffectId(unsigned int recordIndex, unsigned int effectIndex) NOEXCEPT;
/**
* \brief Get the ID of the attribute modified by the effect at a certain index in the
@ -299,7 +189,7 @@ public:
* \param effectIndex The index of the effect.
* \return The attribute ID for the effect.
*/
static int GetRecordEffectAttribute(unsigned int recordIndex, unsigned int effectIndex) noexcept;
API_FUNCTION int CDECL GetRecordEffectAttribute(unsigned int recordIndex, unsigned int effectIndex) NOEXCEPT;
/**
* \brief Get the ID of the skill modified by the effect at a certain index in the
@ -309,7 +199,7 @@ public:
* \param effectIndex The index of the effect.
* \return The skill ID for the effect.
*/
static int GetRecordEffectSkill(unsigned int recordIndex, unsigned int effectIndex) noexcept;
API_FUNCTION int CDECL GetRecordEffectSkill(unsigned int recordIndex, unsigned int effectIndex) NOEXCEPT;
/**
* \brief Get the range type of the effect at a certain index in the read worldstate's
@ -319,7 +209,7 @@ public:
* \param effectIndex The index of the effect.
* \return The range of the effect.
*/
static unsigned int GetRecordEffectRangeType(unsigned int recordIndex, unsigned int effectIndex) noexcept;
API_FUNCTION unsigned int CDECL GetRecordEffectRangeType(unsigned int recordIndex, unsigned int effectIndex) NOEXCEPT;
/**
* \brief Get the area of the effect at a certain index in the read worldstate's current
@ -329,7 +219,7 @@ public:
* \param effectIndex The index of the effect.
* \return The area of the effect.
*/
static int GetRecordEffectArea(unsigned int recordIndex, unsigned int effectIndex) noexcept;
API_FUNCTION int CDECL GetRecordEffectArea(unsigned int recordIndex, unsigned int effectIndex) NOEXCEPT;
/**
* \brief Get the duration of the effect at a certain index in the read worldstate's current
@ -339,7 +229,7 @@ public:
* \param effectIndex The index of the effect.
* \return The duration of the effect.
*/
static int GetRecordEffectDuration(unsigned int recordIndex, unsigned int effectIndex) noexcept;
API_FUNCTION int CDECL GetRecordEffectDuration(unsigned int recordIndex, unsigned int effectIndex) NOEXCEPT;
/**
* \brief Get the maximum magnitude of the effect at a certain index in the read
@ -349,7 +239,7 @@ public:
* \param effectIndex The index of the effect.
* \return The maximum magnitude of the effect.
*/
static int GetRecordEffectMagnitudeMax(unsigned int recordIndex, unsigned int effectIndex) noexcept;
API_FUNCTION int CDECL GetRecordEffectMagnitudeMax(unsigned int recordIndex, unsigned int effectIndex) NOEXCEPT;
/**
* \brief Get the minimum magnitude of the effect at a certain index in the read
@ -359,7 +249,7 @@ public:
* \param effectIndex The index of the effect.
* \return The minimum magnitude of the effect.
*/
static int GetRecordEffectMagnitudeMin(unsigned int recordIndex, unsigned int effectIndex) noexcept;
API_FUNCTION int CDECL GetRecordEffectMagnitudeMin(unsigned int recordIndex, unsigned int effectIndex) NOEXCEPT;
/**
* \brief Set which type of temporary records stored on the server should have
@ -368,7 +258,7 @@ public:
* \param type The type of records.
* \return void
*/
static void SetRecordType(unsigned int type) noexcept;
API_FUNCTION void CDECL SetRecordType(unsigned int type) NOEXCEPT;
/**
* \brief Set the id of the temporary record stored on the server for the
@ -377,7 +267,7 @@ public:
* \param id The id of the record.
* \return void
*/
static void SetRecordId(const char* id) noexcept;
API_FUNCTION void CDECL SetRecordId(const char* id) NOEXCEPT;
/**
* \brief Set the base id (i.e. the id this record should inherit default
@ -387,7 +277,7 @@ public:
* \param baseId The baseId of the record.
* \return void
*/
static void SetRecordBaseId(const char* baseId) noexcept;
API_FUNCTION void CDECL SetRecordBaseId(const char* baseId) NOEXCEPT;
/**
* \brief Set the inventory base id (i.e. the id this record should inherit
@ -397,7 +287,7 @@ public:
* \param inventoryBaseId The inventoryBaseId of the record.
* \return void
*/
static void SetRecordInventoryBaseId(const char* inventoryBaseId) noexcept;
API_FUNCTION void CDECL SetRecordInventoryBaseId(const char* inventoryBaseId) NOEXCEPT;
/**
* \brief Set the subtype of the temporary record stored on the server for
@ -406,7 +296,7 @@ public:
* \param type The spell type.
* \return void
*/
static void SetRecordSubtype(unsigned int subtype) noexcept;
API_FUNCTION void CDECL SetRecordSubtype(unsigned int subtype) NOEXCEPT;
/**
* \brief Set the name of the temporary record stored on the server for the
@ -415,7 +305,7 @@ public:
* \param name The name of the record.
* \return void
*/
static void SetRecordName(const char* name) noexcept;
API_FUNCTION void CDECL SetRecordName(const char* name) NOEXCEPT;
/**
* \brief Set the model of the temporary record stored on the server for the
@ -424,7 +314,7 @@ public:
* \param model The model of the record.
* \return void
*/
static void SetRecordModel(const char* model) noexcept;
API_FUNCTION void CDECL SetRecordModel(const char* model) NOEXCEPT;
/**
* \brief Set the icon of the temporary record stored on the server for the
@ -433,7 +323,7 @@ public:
* \param icon The icon of the record.
* \return void
*/
static void SetRecordIcon(const char* icon) noexcept;
API_FUNCTION void CDECL SetRecordIcon(const char* icon) NOEXCEPT;
/**
* \brief Set the script of the temporary record stored on the server for the
@ -442,7 +332,7 @@ public:
* \param script The script of the record.
* \return void
*/
static void SetRecordScript(const char* script) noexcept;
API_FUNCTION void CDECL SetRecordScript(const char* script) NOEXCEPT;
/**
* \brief Set the enchantment id of the temporary record stored on the server
@ -451,7 +341,7 @@ public:
* \param enchantmentId The enchantment id of the record.
* \return void
*/
static void SetRecordEnchantmentId(const char* enchantmentId) noexcept;
API_FUNCTION void CDECL SetRecordEnchantmentId(const char* enchantmentId) NOEXCEPT;
/**
* \brief Set the enchantment charge of the temporary record stored on the server
@ -460,7 +350,7 @@ public:
* \param enchantmentCharge The enchantmentCharge of the record.
* \return void
*/
static void SetRecordEnchantmentCharge(int enchantmentCharge) noexcept;
API_FUNCTION void CDECL SetRecordEnchantmentCharge(int enchantmentCharge) NOEXCEPT;
/**
* \brief Set the auto-calculation flag value of the temporary record stored
@ -469,7 +359,7 @@ public:
* \param autoCalc The auto-calculation flag value of the record.
* \return void
*/
static void SetRecordAutoCalc(int autoCalc) noexcept;
API_FUNCTION void CDECL SetRecordAutoCalc(int autoCalc) NOEXCEPT;
/**
* \brief Set the charge of the temporary record stored on the server for the
@ -478,7 +368,7 @@ public:
* \param charge The charge of the record.
* \return void
*/
static void SetRecordCharge(int charge) noexcept;
API_FUNCTION void CDECL SetRecordCharge(int charge) NOEXCEPT;
/**
* \brief Set the cost of the temporary record stored on the server for the
@ -487,7 +377,7 @@ public:
* \param cost The cost of the record.
* \return void
*/
static void SetRecordCost(int cost) noexcept;
API_FUNCTION void CDECL SetRecordCost(int cost) NOEXCEPT;
/**
* \brief Set the flags of the temporary record stored on the server for the
@ -496,7 +386,7 @@ public:
* \param flags The flags of the record.
* \return void
*/
static void SetRecordFlags(int flags) noexcept;
API_FUNCTION void CDECL SetRecordFlags(int flags) NOEXCEPT;
/**
* \brief Set the value of the temporary record stored on the server for the
@ -505,7 +395,7 @@ public:
* \param value The value of the record.
* \return void
*/
static void SetRecordValue(int value) noexcept;
API_FUNCTION void CDECL SetRecordValue(int value) NOEXCEPT;
/**
* \brief Set the weight of the temporary record stored on the server for the
@ -514,7 +404,7 @@ public:
* \param weight The weight of the record.
* \return void
*/
static void SetRecordWeight(double weight) noexcept;
API_FUNCTION void CDECL SetRecordWeight(double weight) NOEXCEPT;
/**
* \brief Set the armor rating of the temporary record stored on the server
@ -523,7 +413,7 @@ public:
* \param armorRating The armor rating of the record.
* \return void
*/
static void SetRecordArmorRating(int armorRating) noexcept;
API_FUNCTION void CDECL SetRecordArmorRating(int armorRating) NOEXCEPT;
/**
* \brief Set the health of the temporary record stored on the server for the
@ -532,7 +422,7 @@ public:
* \param health The health of the record.
* \return void
*/
static void SetRecordHealth(int health) noexcept;
API_FUNCTION void CDECL SetRecordHealth(int health) NOEXCEPT;
/**
* \brief Set the chop damage of the temporary record stored on the server for the
@ -542,7 +432,7 @@ public:
* \param maxDamage The maximum damage of the record.
* \return void
*/
static void SetRecordDamageChop(unsigned int minDamage, unsigned int maxDamage) noexcept;
API_FUNCTION void CDECL SetRecordDamageChop(unsigned int minDamage, unsigned int maxDamage) NOEXCEPT;
/**
* \brief Set the slash damage of the temporary record stored on the server for the
@ -552,7 +442,7 @@ public:
* \param maxDamage The maximum damage of the record.
* \return void
*/
static void SetRecordDamageSlash(unsigned int minDamage, unsigned int maxDamage) noexcept;
API_FUNCTION void CDECL SetRecordDamageSlash(unsigned int minDamage, unsigned int maxDamage) NOEXCEPT;
/**
* \brief Set the thrust damage of the temporary record stored on the server for the
@ -562,7 +452,7 @@ public:
* \param maxDamage The maximum damage of the record.
* \return void
*/
static void SetRecordDamageThrust(unsigned int minDamage, unsigned int maxDamage) noexcept;
API_FUNCTION void CDECL SetRecordDamageThrust(unsigned int minDamage, unsigned int maxDamage) NOEXCEPT;
/**
* \brief Set the reach of the temporary record stored on the server for the
@ -571,7 +461,7 @@ public:
* \param reach The reach of the record.
* \return void
*/
static void SetRecordReach(double reach) noexcept;
API_FUNCTION void CDECL SetRecordReach(double reach) NOEXCEPT;
/**
* \brief Set the speed of the temporary record stored on the server for the
@ -580,7 +470,7 @@ public:
* \param speed The speed of the record.
* \return void
*/
static void SetRecordSpeed(double speed) noexcept;
API_FUNCTION void CDECL SetRecordSpeed(double speed) NOEXCEPT;
/**
* \brief Set whether the temporary record stored on the server for the
@ -591,7 +481,7 @@ public:
* \param keyState Whether the record is a key.
* \return void
*/
static void SetRecordKeyState(bool keyState) noexcept;
API_FUNCTION void CDECL SetRecordKeyState(bool keyState) NOEXCEPT;
/**
* \brief Set whether the temporary record stored on the server for the
@ -602,7 +492,7 @@ public:
* \param scrollState Whether the record is a scroll.
* \return void
*/
static void SetRecordScrollState(bool scrollState) noexcept;
API_FUNCTION void CDECL SetRecordScrollState(bool scrollState) NOEXCEPT;
/**
* \brief Set the skill ID of the temporary record stored on the server for the
@ -611,7 +501,7 @@ public:
* \param skillId The skill ID of the record.
* \return void
*/
static void SetRecordSkillId(int skillId) noexcept;
API_FUNCTION void CDECL SetRecordSkillId(int skillId) NOEXCEPT;
/**
* \brief Set the text of the temporary record stored on the server for the
@ -620,7 +510,7 @@ public:
* \param text The text of the record.
* \return void
*/
static void SetRecordText(const char* text) noexcept;
API_FUNCTION void CDECL SetRecordText(const char* text) NOEXCEPT;
/**
* \brief Set the hair of the temporary record stored on the server for the
@ -629,7 +519,7 @@ public:
* \param hair The hair of the record.
* \return void
*/
static void SetRecordHair(const char* hair) noexcept;
API_FUNCTION void CDECL SetRecordHair(const char* hair) NOEXCEPT;
/**
* \brief Set the head of the temporary record stored on the server for the
@ -638,7 +528,7 @@ public:
* \param hair The head of the record.
* \return void
*/
static void SetRecordHead(const char* head) noexcept;
API_FUNCTION void CDECL SetRecordHead(const char* head) NOEXCEPT;
/**
* \brief Set the gender of the temporary record stored on the server for the
@ -647,7 +537,7 @@ public:
* \param hair The race of the record.
* \return void
*/
static void SetRecordGender(unsigned int gender) noexcept;
API_FUNCTION void CDECL SetRecordGender(unsigned int gender) NOEXCEPT;
/**
* \brief Set the race of the temporary record stored on the server for the
@ -656,7 +546,7 @@ public:
* \param hair The race of the record.
* \return void
*/
static void SetRecordRace(const char* race) noexcept;
API_FUNCTION void CDECL SetRecordRace(const char* race) NOEXCEPT;
/**
* \brief Set the character class of the temporary record stored on the server
@ -665,7 +555,7 @@ public:
* \param hair The character class of the record.
* \return void
*/
static void SetRecordClass(const char* charClass) noexcept;
API_FUNCTION void CDECL SetRecordClass(const char* charClass) NOEXCEPT;
/**
* \brief Set the faction of the temporary record stored on the server for the
@ -674,7 +564,7 @@ public:
* \param faction The faction of the record.
* \return void
*/
static void SetRecordFaction(const char* faction) noexcept;
API_FUNCTION void CDECL SetRecordFaction(const char* faction) NOEXCEPT;
/**
* \brief Set the level of the temporary record stored on the server for the
@ -683,7 +573,7 @@ public:
* \param level The level of the record.
* \return void
*/
static void SetRecordLevel(int level) noexcept;
API_FUNCTION void CDECL SetRecordLevel(int level) NOEXCEPT;
/**
* \brief Set the magicka of the temporary record stored on the server for the
@ -692,7 +582,7 @@ public:
* \param magicka The magicka of the record.
* \return void
*/
static void SetRecordMagicka(int magicka) noexcept;
API_FUNCTION void CDECL SetRecordMagicka(int magicka) NOEXCEPT;
/**
* \brief Set the fatigue of the temporary record stored on the server for the
@ -701,7 +591,7 @@ public:
* \param fatigue The fatigue of the record.
* \return void
*/
static void SetRecordFatigue(int fatigue) noexcept;
API_FUNCTION void CDECL SetRecordFatigue(int fatigue) NOEXCEPT;
/**
* \brief Set the AI fight value of the temporary record stored on the server for the
@ -710,7 +600,7 @@ public:
* \param aiFight The AI fight value of the record.
* \return void
*/
static void SetRecordAIFight(int aiFight) noexcept;
API_FUNCTION void CDECL SetRecordAIFight(int aiFight) NOEXCEPT;
/**
* \brief Set the id of the record at a certain index in the records stored on the server.
@ -722,7 +612,7 @@ public:
* \param id The id of the record.
* \return void
*/
static void SetRecordIdByIndex(unsigned int index, const char* id) noexcept;
API_FUNCTION void CDECL SetRecordIdByIndex(unsigned int index, const char* id) NOEXCEPT;
/**
* \brief Set the enchantment id of the record at a certain index in the records stored on
@ -735,7 +625,7 @@ public:
* \param enchantmentId The enchantment id of the record.
* \return void
*/
static void SetRecordEnchantmentIdByIndex(unsigned int index, const char* enchantmentId) noexcept;
API_FUNCTION void CDECL SetRecordEnchantmentIdByIndex(unsigned int index, const char* enchantmentId) NOEXCEPT;
/**
* \brief Set the ID of the temporary effect stored on the server.
@ -743,7 +633,7 @@ public:
* \param effectId The ID of the effect.
* \return void
*/
static void SetRecordEffectId(unsigned int effectId) noexcept;
API_FUNCTION void CDECL SetRecordEffectId(unsigned int effectId) NOEXCEPT;
/**
* \brief Set the ID of the attribute modified by the temporary effect stored on
@ -752,7 +642,7 @@ public:
* \param attributeId The ID of the attribute.
* \return void
*/
static void SetRecordEffectAttribute(int attributeId) noexcept;
API_FUNCTION void CDECL SetRecordEffectAttribute(int attributeId) NOEXCEPT;
/**
* \brief Set the ID of the skill modified by the temporary effect stored on the
@ -761,7 +651,7 @@ public:
* \param skillId The ID of the skill.
* \return void
*/
static void SetRecordEffectSkill(int skillId) noexcept;
API_FUNCTION void CDECL SetRecordEffectSkill(int skillId) NOEXCEPT;
/**
* \brief Set the range type of the temporary effect stored on the server (0 for
@ -770,7 +660,7 @@ public:
* \param rangeType The range type of the effect.
* \return void
*/
static void SetRecordEffectRangeType(unsigned int rangeType) noexcept;
API_FUNCTION void CDECL SetRecordEffectRangeType(unsigned int rangeType) NOEXCEPT;
/**
* \brief Set the area of the temporary effect stored on the server.
@ -778,7 +668,7 @@ public:
* \param area The area of the effect.
* \return void
*/
static void SetRecordEffectArea(int area) noexcept;
API_FUNCTION void CDECL SetRecordEffectArea(int area) NOEXCEPT;
/**
* \brief Set the duration of the temporary effect stored on the server.
@ -786,7 +676,7 @@ public:
* \param duration The duration of the effect.
* \return void
*/
static void SetRecordEffectDuration(int duration) noexcept;
API_FUNCTION void CDECL SetRecordEffectDuration(int duration) NOEXCEPT;
/**
* \brief Set the maximum magnitude of the temporary effect stored on the server.
@ -794,7 +684,7 @@ public:
* \param magnitudeMax The maximum magnitude of the effect.
* \return void
*/
static void SetRecordEffectMagnitudeMax(int magnitudeMax) noexcept;
API_FUNCTION void CDECL SetRecordEffectMagnitudeMax(int magnitudeMax) NOEXCEPT;
/**
* \brief Set the minimum magnitude of the temporary effect stored on the server.
@ -802,7 +692,7 @@ public:
* \param magnitudeMin The minimum magnitude of the effect.
* \return void
*/
static void SetRecordEffectMagnitudeMin(int magnitudeMin) noexcept;
API_FUNCTION void CDECL SetRecordEffectMagnitudeMin(int magnitudeMin) NOEXCEPT;
/**
* \brief Set the type of the temporary body part stored on the server.
@ -810,7 +700,7 @@ public:
* \param partType The type of the body part.
* \return void
*/
static void SetRecordBodyPartType(unsigned int partType) noexcept;
API_FUNCTION void CDECL SetRecordBodyPartType(unsigned int partType) NOEXCEPT;
/**
* \brief Set the id of the male version of the temporary body part stored on the
@ -819,7 +709,7 @@ public:
* \param partId The id of the body part.
* \return void
*/
static void SetRecordBodyPartIdForMale(const char* partId) noexcept;
API_FUNCTION void CDECL SetRecordBodyPartIdForMale(const char* partId) NOEXCEPT;
/**
* \brief Set the id of the female version of the temporary body part stored on the
@ -828,7 +718,7 @@ public:
* \param partId The id of the body part.
* \return void
*/
static void SetRecordBodyPartIdForFemale(const char* partId) noexcept;
API_FUNCTION void CDECL SetRecordBodyPartIdForFemale(const char* partId) NOEXCEPT;
/**
* \brief Set the id of the of the temporary inventory item stored on the server.
@ -836,7 +726,7 @@ public:
* \param partId The id of the inventory item.
* \return void
*/
static void SetRecordInventoryItemId(const char* itemId) noexcept;
API_FUNCTION void CDECL SetRecordInventoryItemId(const char* itemId) NOEXCEPT;
/**
* \brief Set the count of the of the temporary inventory item stored on the server.
@ -844,7 +734,7 @@ public:
* \param count The count of the inventory item.
* \return void
*/
static void SetRecordInventoryItemCount(unsigned int count) noexcept;
API_FUNCTION void CDECL SetRecordInventoryItemCount(unsigned int count) NOEXCEPT;
/**
* \brief Add a copy of the server's temporary record of the current specified
@ -855,7 +745,7 @@ public:
*
* \return void
*/
static void AddRecord() noexcept;
API_FUNCTION void CDECL AddRecord() NOEXCEPT;
/**
* \brief Add a copy of the server's temporary effect to the temporary record
@ -866,7 +756,7 @@ public:
*
* \return void
*/
static void AddRecordEffect() noexcept;
API_FUNCTION void CDECL AddRecordEffect() NOEXCEPT;
/**
* \brief Add a copy of the server's temporary body part to the temporary record
@ -877,7 +767,7 @@ public:
*
* \return void
*/
static void AddRecordBodyPart() noexcept;
API_FUNCTION void CDECL AddRecordBodyPart() NOEXCEPT;
/**
* \brief Add a copy of the server's temporary inventory item to the temporary record
@ -891,7 +781,7 @@ public:
*
* \return void
*/
static void AddRecordInventoryItem() noexcept;
API_FUNCTION void CDECL AddRecordInventoryItem() NOEXCEPT;
/**
* \brief Send a RecordDynamic packet with the current specified record type.
@ -903,8 +793,7 @@ public:
* to the packet (false by default).
* \return void
*/
static void SendRecordDynamic(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
};
API_FUNCTION void CDECL SendRecordDynamic(PlayerId pid, bool sendToOtherPlayers, bool skipAttachedPlayer) NOEXCEPT;
NAMESPACE_END()
#endif //OPENMW_RECORDSDYNAMICAPI_HPP

@ -1,34 +1,21 @@
#include "Server.hpp"
#include "Server.h"
#include <components/misc/stringops.hpp>
#include <components/openmw-mp/NetworkMessages.hpp>
#include <components/openmw-mp/Log.hpp>
#include <components/openmw-mp/Version.hpp>
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
#include <apps/openmw-mp/Script/Callbacks.hpp>
#include <apps/openmw-mp/Networking.hpp>
#include <apps/openmw-mp/MasterClient.hpp>
#include <Script/Script.hpp>
#include <Script/Plugin.hpp>
static std::string tempFilename;
static std::chrono::high_resolution_clock::time_point startupTime = std::chrono::high_resolution_clock::now();
void ServerFunctions::LogMessage(unsigned short level, const char *message) noexcept
{
LOG_MESSAGE_SIMPLE(level, "[Script]: %s", message);
}
void ServerFunctions::LogAppend(unsigned short level, const char *message) noexcept
{
LOG_APPEND(level, "[Script]: %s", message);
}
void ServerFunctions::StopServer(int code) noexcept
extern "C" void ServerFunctions::StopServer(int code) noexcept
{
mwmp::Networking::getPtr()->stopServer(code);
}
void ServerFunctions::Kick(unsigned short pid) noexcept
extern "C" void ServerFunctions::Kick(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -38,79 +25,45 @@ void ServerFunctions::Kick(unsigned short pid) noexcept
player->setLoadState(Player::KICKED);
}
void ServerFunctions::BanAddress(const char *ipAddress) noexcept
extern "C" void ServerFunctions::BanAddress(const char *ipAddress) noexcept
{
mwmp::Networking::getPtr()->banAddress(ipAddress);
}
void ServerFunctions::UnbanAddress(const char *ipAddress) noexcept
extern "C" void ServerFunctions::UnbanAddress(const char *ipAddress) noexcept
{
mwmp::Networking::getPtr()->unbanAddress(ipAddress);
}
bool ServerFunctions::DoesFilePathExist(const char *filePath) noexcept
{
return boost::filesystem::exists(filePath);
}
const char *ServerFunctions::GetCaseInsensitiveFilename(const char *folderPath, const char *filename) noexcept
{
if (!boost::filesystem::exists(folderPath)) return "invalid";
boost::filesystem::directory_iterator end_itr; // default construction yields past-the-end
for (boost::filesystem::directory_iterator itr(folderPath); itr != end_itr; ++itr)
{
if (Misc::StringUtils::ciEqual(itr->path().filename().string(), filename))
{
tempFilename = itr->path().filename().string();
return tempFilename.c_str();
}
}
return "invalid";
}
const char* ServerFunctions::GetDataPath() noexcept
{
return Script::GetModDir();
}
unsigned int ServerFunctions::GetMillisecondsSinceServerStart() noexcept
{
std::chrono::high_resolution_clock::time_point currentTime = std::chrono::high_resolution_clock::now();
std::chrono::milliseconds milliseconds = std::chrono::duration_cast<std::chrono::milliseconds>(currentTime - startupTime);
return milliseconds.count();
}
const char *ServerFunctions::GetOperatingSystemType() noexcept
extern "C" const char *ServerFunctions::GetOperatingSystemType() noexcept
{
return Utils::getOperatingSystemType().c_str();
}
const char *ServerFunctions::GetArchitectureType() noexcept
extern "C" const char *ServerFunctions::GetArchitectureType() noexcept
{
return Utils::getArchitectureType().c_str();
}
const char *ServerFunctions::GetServerVersion() noexcept
extern "C" const char *ServerFunctions::GetServerVersion() noexcept
{
return TES3MP_VERSION;
}
const char *ServerFunctions::GetProtocolVersion() noexcept
extern "C" const char *ServerFunctions::GetProtocolVersion() noexcept
{
static std::string version = std::to_string(TES3MP_PROTO_VERSION);
return version.c_str();
}
int ServerFunctions::GetAvgPing(unsigned short pid) noexcept
extern "C" int ServerFunctions::GetAvgPing(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, -1);
return mwmp::Networking::get().getAvgPing(player->guid);
}
const char *ServerFunctions::GetIP(unsigned short pid) noexcept
extern "C" const char *ServerFunctions::GetIP(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, "");
@ -118,112 +71,105 @@ const char *ServerFunctions::GetIP(unsigned short pid) noexcept
return addr.ToString(false);
}
unsigned short ServerFunctions::GetPort() noexcept
extern "C" unsigned short ServerFunctions::GetPort() noexcept
{
return mwmp::Networking::get().getPort();
}
unsigned int ServerFunctions::GetMaxPlayers() noexcept
extern "C" unsigned int ServerFunctions::GetMaxPlayers() noexcept
{
return mwmp::Networking::get().maxConnections();
}
bool ServerFunctions::HasPassword() noexcept
extern "C" bool ServerFunctions::HasPassword() noexcept
{
return mwmp::Networking::get().isPassworded();
}
bool ServerFunctions::GetPluginEnforcementState() noexcept
extern "C" bool ServerFunctions::GetPluginEnforcementState() noexcept
{
return mwmp::Networking::getPtr()->getPluginEnforcementState();
}
bool ServerFunctions::GetScriptErrorIgnoringState() noexcept
extern "C" bool ServerFunctions::GetScriptErrorIgnoringState() noexcept
{
return mwmp::Networking::getPtr()->getScriptErrorIgnoringState();
}
void ServerFunctions::SetGameMode(const char *gameMode) noexcept
extern "C" void ServerFunctions::SetGameMode(const char *gameMode) noexcept
{
if (mwmp::Networking::getPtr()->getMasterClient())
mwmp::Networking::getPtr()->getMasterClient()->SetModname(gameMode);
}
void ServerFunctions::SetHostname(const char *name) noexcept
extern "C" void ServerFunctions::SetHostname(const char *name) noexcept
{
if (mwmp::Networking::getPtr()->getMasterClient())
mwmp::Networking::getPtr()->getMasterClient()->SetHostname(name);
}
void ServerFunctions::SetServerPassword(const char *password) noexcept
extern "C" void ServerFunctions::SetServerPassword(const char *password) noexcept
{
mwmp::Networking::getPtr()->setServerPassword(password);
}
void ServerFunctions::SetPluginEnforcementState(bool state) noexcept
extern "C" void ServerFunctions::SetPluginEnforcementState(bool state) noexcept
{
mwmp::Networking::getPtr()->setPluginEnforcementState(state);
}
void ServerFunctions::SetScriptErrorIgnoringState(bool state) noexcept
extern "C" void ServerFunctions::SetScriptErrorIgnoringState(bool state) noexcept
{
mwmp::Networking::getPtr()->setScriptErrorIgnoringState(state);
}
void ServerFunctions::SetRuleString(const char *key, const char *value) noexcept
extern "C" void ServerFunctions::SetRuleString(const char *key, const char *value) noexcept
{
auto mc = mwmp::Networking::getPtr()->getMasterClient();
if (mc)
mc->SetRuleString(key, value);
}
void ServerFunctions::SetRuleValue(const char *key, double value) noexcept
extern "C" void ServerFunctions::SetRuleValue(const char *key, double value) noexcept
{
auto mc = mwmp::Networking::getPtr()->getMasterClient();
if (mc)
mc->SetRuleValue(key, value);
}
void ServerFunctions::AddDataFileRequirement(const char *dataFilename, const char *checksumString) noexcept
extern "C" void ServerFunctions::AddPluginHash(const char *pluginName, const char *hashStr) noexcept
{
auto &samples = mwmp::Networking::getPtr()->getSamples();
auto it = std::find_if(samples.begin(), samples.end(), [&dataFilename](mwmp::PacketPreInit::PluginPair &item) {
return item.first == dataFilename;
auto it = std::find_if(samples.begin(), samples.end(), [&pluginName](mwmp::PacketPreInit::PluginPair &item) {
return item.first == pluginName;
});
if (it != samples.end())
it->second.push_back((unsigned) std::stoul(checksumString));
it->second.push_back((unsigned) std::stoul(hashStr));
else
{
mwmp::PacketPreInit::HashList checksumList;
mwmp::PacketPreInit::HashList hashList;
unsigned checksum = 0;
unsigned hash = 0;
if (strlen(checksumString) != 0)
if (hashStr[0] != '\0')
{
checksum = (unsigned) std::stoul(checksumString);
checksumList.push_back(checksum);
hash = (unsigned) std::stoul(hashStr);
hashList.push_back(hash);
}
samples.emplace_back(dataFilename, checksumList);
samples.emplace_back(pluginName, hashList);
auto mclient = mwmp::Networking::getPtr()->getMasterClient();
if (mclient)
mclient->PushPlugin({dataFilename, checksum});
mclient->PushPlugin({pluginName, hash});
}
}
// All methods below are deprecated versions of methods from above
bool ServerFunctions::DoesFileExist(const char *filePath) noexcept
{
return DoesFilePathExist(filePath);
}
const char* ServerFunctions::GetModDir() noexcept
extern "C" const char* ServerFunctions::GetModDir() noexcept
{
return GetDataPath();
return Plugin::GetModDir();
}
void ServerFunctions::AddPluginHash(const char *pluginName, const char *checksumString) noexcept
const char *ServerFunctions::GetPluginDir() noexcept
{
AddDataFileRequirement(pluginName, checksumString);
return Plugin::GetPluginDir();
}

@ -0,0 +1,201 @@
#ifndef OPENMW_SERVERAPI_HPP
#define OPENMW_SERVERAPI_HPP
#include "../api.h"
NAMESPACE_BEGIN(ServerFunctions)
/**
* \brief Shut down the server.
*
* \param code The shutdown code.
* \return void
*/
API_FUNCTION void CDECL StopServer(int code) NOEXCEPT;
/**
* \brief Kick a certain player from the server.
*
* \param pid The player ID.
* \return void
*/
API_FUNCTION void CDECL Kick(PlayerId pid) NOEXCEPT;
/**
* \brief Ban a certain IP address from the server.
*
* \param ipAddress The IP address.
* \return void
*/
API_FUNCTION void CDECL BanAddress(const char *ipAddress) NOEXCEPT;
/**
* \brief Unban a certain IP address from the server.
*
* \param ipAddress The IP address.
* \return void
*/
API_FUNCTION void CDECL UnbanAddress(const char *ipAddress) NOEXCEPT;
/**
* \brief Get the type of the operating system used by the server.
*
* Note: Currently, the type can be "Windows", "Linux", "OS X" or "Unknown OS".
*
* \return The type of the operating system.
*/
API_FUNCTION const char *CDECL GetOperatingSystemType() NOEXCEPT;
/**
* \brief Get the architecture type used by the server.
*
* Note: Currently, the type can be "64-bit", "32-bit", "ARMv#" or "Unknown architecture".
*
* \return The architecture type.
*/
API_FUNCTION const char *CDECL GetArchitectureType() NOEXCEPT;
/**
* \brief Get the TES3MP version of the server.
*
* \return The server version.
*/
API_FUNCTION const char *CDECL GetServerVersion() NOEXCEPT;
/**
* \brief Get the protocol version of the server.
*
* \return The protocol version.
*/
API_FUNCTION const char *CDECL GetProtocolVersion() NOEXCEPT;
/**
* \brief Get the average ping of a certain player.
*
* \param pid The player ID.
* \return The average ping.
*/
API_FUNCTION int CDECL GetAvgPing(PlayerId pid) NOEXCEPT;
/**
* \brief Get the IP address of a certain player.
*
* \param pid The player ID.
* \return The IP address.
*/
API_FUNCTION const CDECL char* GetIP(PlayerId pid) NOEXCEPT;
/**
* \brief Get the port used by the server.
*
* \return Port
*/
API_FUNCTION unsigned short CDECL GetPort() NOEXCEPT;
/**
* \brief Get the maximum number of players.
*
* \return Max players
*/
API_FUNCTION unsigned int CDECL GetMaxPlayers() NOEXCEPT;
/**
* \brief Checking if the server requires a password to connect.
*
* @return
*/
API_FUNCTION bool CDECL HasPassword() NOEXCEPT;
/**
* \brief Get the plugin enforcement state of the server.
*
* If true, clients are required to use the same plugins as set for the server.
*
* \return The enforcement state.
*/
API_FUNCTION bool CDECL GetPluginEnforcementState() NOEXCEPT;
/**
* \brief Get the script error ignoring state of the server.
*
* If true, script errors will not crash the server.
*
* \return The script error ignoring state.
*/
API_FUNCTION bool CDECL GetScriptErrorIgnoringState() NOEXCEPT;
/**
* \brief Set the game mode of the server, as displayed in the server browser.
*
* \param name The new game mode.
* \return void
*/
API_FUNCTION void CDECL SetGameMode(const char* gameMode) NOEXCEPT;
/**
* \brief Set the name of the server, as displayed in the server browser.
*
* \param name The new name.
* \return void
*/
API_FUNCTION void CDECL SetHostname(const char* name) NOEXCEPT;
/**
* \brief Set the password required to join the server.
*
* \param password The password.
* \return void
*/
API_FUNCTION void CDECL SetServerPassword(const char *password) NOEXCEPT;
/**
* \brief Set the plugin enforcement state of the server.
*
* If true, clients are required to use the same plugins as set for the server.
*
* \param state The new enforcement state.
* \return void
*/
API_FUNCTION void CDECL SetPluginEnforcementState(bool state) NOEXCEPT;
/**
* \brief Set whether script errors should be ignored or not.
*
* If true, script errors will not crash the server, but could have any number
* of unforeseen consequences, which is why this is a highly experimental
* setting.
*
* \param state The new script error ignoring state.
* \return void
*/
API_FUNCTION void CDECL SetScriptErrorIgnoringState(bool state) NOEXCEPT;
/**
* \brief Set a rule string for the server details displayed in the server browser.
*
* \param key The name of the rule.
* \param value The string value of the rule.
* \return void
*/
API_FUNCTION void CDECL SetRuleString(const char *key, const char *value) NOEXCEPT;
/**
* \brief Set a rule value for the server details displayed in the server browser.
*
* \param key The name of the rule.
* \param value The numerical value of the rule.
* \return void
*/
API_FUNCTION void CDECL SetRuleValue(const char *key, double value) NOEXCEPT;
/**
* \brief Adds plugins to the internal server structure to validate players.
* @param pluginName Name with extension of the plugin or master file.
* @param hash Hash string
*/
API_FUNCTION void CDECL AddPluginHash(const char *pluginName, const char *hash) NOEXCEPT;
API_FUNCTION const char *CDECL GetModDir() NOEXCEPT;
API_FUNCTION const char *CDECL GetPluginDir() NOEXCEPT;
NAMESPACE_END()
#endif //OPENMW_SERVERAPI_HPP

@ -1,313 +0,0 @@
#ifndef OPENMW_SERVERAPI_HPP
#define OPENMW_SERVERAPI_HPP
#include "../Types.hpp"
#define SERVERAPI \
{"LogMessage", ServerFunctions::LogMessage},\
{"LogAppend", ServerFunctions::LogAppend},\
\
{"StopServer", ServerFunctions::StopServer},\
\
{"Kick", ServerFunctions::Kick},\
{"BanAddress", ServerFunctions::BanAddress},\
{"UnbanAddress", ServerFunctions::UnbanAddress},\
\
{"DoesFilePathExist", ServerFunctions::DoesFilePathExist},\
{"GetCaseInsensitiveFilename", ServerFunctions::GetCaseInsensitiveFilename},\
{"GetDataPath", ServerFunctions::GetDataPath},\
{"GetMillisecondsSinceServerStart", ServerFunctions::GetMillisecondsSinceServerStart},\
{"GetOperatingSystemType", ServerFunctions::GetOperatingSystemType},\
{"GetArchitectureType", ServerFunctions::GetArchitectureType},\
{"GetServerVersion", ServerFunctions::GetServerVersion},\
{"GetProtocolVersion", ServerFunctions::GetProtocolVersion},\
{"GetAvgPing", ServerFunctions::GetAvgPing},\
{"GetIP", ServerFunctions::GetIP},\
{"GetMaxPlayers", ServerFunctions::GetMaxPlayers},\
{"GetPort", ServerFunctions::GetPort},\
{"HasPassword", ServerFunctions::HasPassword},\
{"GetPluginEnforcementState", ServerFunctions::GetPluginEnforcementState},\
{"GetScriptErrorIgnoringState", ServerFunctions::GetScriptErrorIgnoringState},\
\
{"SetGameMode", ServerFunctions::SetGameMode},\
{"SetHostname", ServerFunctions::SetHostname},\
{"SetServerPassword", ServerFunctions::SetServerPassword},\
{"SetPluginEnforcementState", ServerFunctions::SetPluginEnforcementState},\
{"SetScriptErrorIgnoringState", ServerFunctions::SetScriptErrorIgnoringState},\
{"SetRuleString", ServerFunctions::SetRuleString},\
{"SetRuleValue", ServerFunctions::SetRuleValue},\
\
{"AddDataFileRequirement", ServerFunctions::AddDataFileRequirement},\
\
{"DoesFileExist", ServerFunctions::DoesFileExist},\
{"GetModDir", ServerFunctions::GetModDir},\
{"AddPluginHash", ServerFunctions::AddPluginHash}
class ServerFunctions
{
public:
/**
* \brief Write a log message with its own timestamp.
*
* It will have "[Script]:" prepended to it so as to mark it as a script-generated log message.
*
* \param level The logging level used (0 for LOG_VERBOSE, 1 for LOG_INFO, 2 for LOG_WARN,
* 3 for LOG_ERROR, 4 for LOG_FATAL).
* \param message The message logged.
* \return void
*/
static void LogMessage(unsigned short level, const char *message) noexcept;
/**
* \brief Write a log message without its own timestamp.
*
* It will have "[Script]:" prepended to it so as to mark it as a script-generated log message.
*
* \param level The logging level used (0 for LOG_VERBOSE, 1 for LOG_INFO, 2 for LOG_WARN,
* 3 for LOG_ERROR, 4 for LOG_FATAL).
* \param message The message logged.
* \return void
*/
static void LogAppend(unsigned short level, const char *message) noexcept;
/**
* \brief Shut down the server.
*
* \param code The shutdown code.
* \return void
*/
static void StopServer(int code) noexcept;
/**
* \brief Kick a certain player from the server.
*
* \param pid The player ID.
* \return void
*/
static void Kick(unsigned short pid) noexcept;
/**
* \brief Ban a certain IP address from the server.
*
* \param ipAddress The IP address.
* \return void
*/
static void BanAddress(const char *ipAddress) noexcept;
/**
* \brief Unban a certain IP address from the server.
*
* \param ipAddress The IP address.
* \return void
*/
static void UnbanAddress(const char *ipAddress) noexcept;
/**
* \brief Check whether a certain file path exists.
*
* This will be a case sensitive check on case sensitive filesystems.
*
* Whenever you want to enforce case insensitivity, use GetCaseInsensitiveFilename() instead.
*
* \return Whether the file exists or not.
*/
static bool DoesFilePathExist(const char *filePath) noexcept;
/**
* \brief Get the first filename in a folder that has a case insensitive match with the filename
* argument.
*
* This is used to retain case insensitivity when opening data files on Linux.
*
* \return The filename that matches.
*/
static const char *GetCaseInsensitiveFilename(const char *folderPath, const char *filename) noexcept;
/**
* \brief Get the path of the server's data folder.
*
* \return The data path.
*/
static const char *GetDataPath() noexcept;
/**
* \brief Get the milliseconds elapsed since the server was started.
*
* \return The time since the server's startup in milliseconds.
*/
static unsigned int GetMillisecondsSinceServerStart() noexcept;
/**
* \brief Get the type of the operating system used by the server.
*
* Note: Currently, the type can be "Windows", "Linux", "OS X" or "Unknown OS".
*
* \return The type of the operating system.
*/
static const char *GetOperatingSystemType() noexcept;
/**
* \brief Get the architecture type used by the server.
*
* Note: Currently, the type can be "64-bit", "32-bit", "ARMv#" or "Unknown architecture".
*
* \return The architecture type.
*/
static const char *GetArchitectureType() noexcept;
/**
* \brief Get the TES3MP version of the server.
*
* \return The server version.
*/
static const char *GetServerVersion() noexcept;
/**
* \brief Get the protocol version of the server.
*
* \return The protocol version.
*/
static const char *GetProtocolVersion() noexcept;
/**
* \brief Get the average ping of a certain player.
*
* \param pid The player ID.
* \return The average ping.
*/
static int GetAvgPing(unsigned short pid) noexcept;
/**
* \brief Get the IP address of a certain player.
*
* \param pid The player ID.
* \return The IP address.
*/
static const char* GetIP(unsigned short pid) noexcept;
/**
* \brief Get the port used by the server.
*
* \return The port.
*/
static unsigned short GetPort() noexcept;
/**
* \brief Get the maximum number of players.
*
* \return Max players
*/
static unsigned int GetMaxPlayers() noexcept;
/**
* \brief Checking if the server requires a password to connect.
*
* @return
*/
static bool HasPassword() noexcept;
/**
* \brief Get the plugin enforcement state of the server.
*
* If true, clients are required to use the same plugins as set for the server.
*
* \return The enforcement state.
*/
static bool GetPluginEnforcementState() noexcept;
/**
* \brief Get the script error ignoring state of the server.
*
* If true, script errors will not crash the server.
*
* \return The script error ignoring state.
*/
static bool GetScriptErrorIgnoringState() noexcept;
/**
* \brief Set the game mode of the server, as displayed in the server browser.
*
* \param name The new game mode.
* \return void
*/
static void SetGameMode(const char* gameMode) noexcept;
/**
* \brief Set the name of the server, as displayed in the server browser.
*
* \param name The new name.
* \return void
*/
static void SetHostname(const char* name) noexcept;
/**
* \brief Set the password required to join the server.
*
* \param password The password.
* \return void
*/
static void SetServerPassword(const char *password) noexcept;
/**
* \brief Set the plugin enforcement state of the server.
*
* If true, clients are required to use the same plugins as set for the server.
*
* \param state The new enforcement state.
* \return void
*/
static void SetPluginEnforcementState(bool state) noexcept;
/**
* \brief Set whether script errors should be ignored or not.
*
* If true, script errors will not crash the server, but could have any number
* of unforeseen consequences, which is why this is a highly experimental
* setting.
*
* \param state The new script error ignoring state.
* \return void
*/
static void SetScriptErrorIgnoringState(bool state) noexcept;
/**
* \brief Set a rule string for the server details displayed in the server browser.
*
* \param key The name of the rule.
* \param value The string value of the rule.
* \return void
*/
static void SetRuleString(const char *key, const char *value) noexcept;
/**
* \brief Set a rule value for the server details displayed in the server browser.
*
* \param key The name of the rule.
* \param value The numerical value of the rule.
* \return void
*/
static void SetRuleValue(const char *key, double value) noexcept;
/**
* \brief Add a data file and a corresponding CRC32 checksum to the data file loadout
* that connecting clients need to match.
*
* It can be used multiple times to set multiple checksums for the same data file.
*
* Note: If an empty string is provided for the checksum, a checksum will not be
* required for that data file.
*
* @param dataFilename The filename of the data file.
* @param checksumString A string with the CRC32 checksum required.
*/
static void AddDataFileRequirement(const char *dataFilename, const char *checksumString) noexcept;
// All methods below are deprecated versions of methods from above
static bool DoesFileExist(const char *filePath) noexcept;
static const char *GetModDir() noexcept;
static void AddPluginHash(const char *pluginName, const char *checksumString) noexcept;
};
#endif //OPENMW_SERVERAPI_HPP

@ -1,15 +1,15 @@
#include "Settings.hpp"
#include "Settings.h"
#include <components/openmw-mp/NetworkMessages.hpp>
#include <components/openmw-mp/Log.hpp>
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
#include <apps/openmw-mp/Script/Callbacks.hpp>
#include <apps/openmw-mp/Networking.hpp>
#include <iostream>
using namespace std;
void SettingFunctions::SetDifficulty(unsigned short pid, int difficulty)
extern "C" void SettingFunctions::SetDifficulty(PlayerId pid, int difficulty)
{
Player *player;
GET_PLAYER(pid, player, );
@ -17,7 +17,7 @@ void SettingFunctions::SetDifficulty(unsigned short pid, int difficulty)
player->difficulty = difficulty;
}
void SettingFunctions::SetEnforcedLogLevel(unsigned short pid, int enforcedLogLevel)
extern "C" void SettingFunctions::SetEnforcedLogLevel(PlayerId pid, int enforcedLogLevel)
{
Player *player;
GET_PLAYER(pid, player, );
@ -25,7 +25,7 @@ void SettingFunctions::SetEnforcedLogLevel(unsigned short pid, int enforcedLogLe
player->enforcedLogLevel = enforcedLogLevel;
}
void SettingFunctions::SetPhysicsFramerate(unsigned short pid, double physicsFramerate)
extern "C" void SettingFunctions::SetPhysicsFramerate(PlayerId pid, double physicsFramerate)
{
Player *player;
GET_PLAYER(pid, player, );
@ -33,7 +33,7 @@ void SettingFunctions::SetPhysicsFramerate(unsigned short pid, double physicsFra
player->physicsFramerate = physicsFramerate;
}
void SettingFunctions::SetConsoleAllowed(unsigned short pid, bool state)
extern "C" void SettingFunctions::SetConsoleAllowed(PlayerId pid, bool state)
{
Player *player;
GET_PLAYER(pid, player,);
@ -41,7 +41,7 @@ void SettingFunctions::SetConsoleAllowed(unsigned short pid, bool state)
player->consoleAllowed = state;
}
void SettingFunctions::SetBedRestAllowed(unsigned short pid, bool state)
extern "C" void SettingFunctions::SetBedRestAllowed(PlayerId pid, bool state)
{
Player *player;
GET_PLAYER(pid, player, );
@ -49,7 +49,7 @@ void SettingFunctions::SetBedRestAllowed(unsigned short pid, bool state)
player->bedRestAllowed = state;
}
void SettingFunctions::SetWildernessRestAllowed(unsigned short pid, bool state)
extern "C" void SettingFunctions::SetWildernessRestAllowed(PlayerId pid, bool state)
{
Player *player;
GET_PLAYER(pid, player, );
@ -57,7 +57,7 @@ void SettingFunctions::SetWildernessRestAllowed(unsigned short pid, bool state)
player->wildernessRestAllowed = state;
}
void SettingFunctions::SetWaitAllowed(unsigned short pid, bool state)
extern "C" void SettingFunctions::SetWaitAllowed(PlayerId pid, bool state)
{
Player *player;
GET_PLAYER(pid, player, );
@ -65,7 +65,7 @@ void SettingFunctions::SetWaitAllowed(unsigned short pid, bool state)
player->waitAllowed = state;
}
void SettingFunctions::SendSettings(unsigned short pid) noexcept
extern "C" void SettingFunctions::SendSettings(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player,);

@ -1,24 +1,9 @@
#ifndef OPENMW_SETTINGSAPI_HPP
#define OPENMW_SETTINGSAPI_HPP
#include "../Types.hpp"
#define SETTINGSAPI \
{"SetDifficulty", SettingFunctions::SetDifficulty},\
{"SetEnforcedLogLevel", SettingFunctions::SetEnforcedLogLevel},\
{"SetPhysicsFramerate", SettingFunctions::SetPhysicsFramerate},\
\
{"SetConsoleAllowed", SettingFunctions::SetConsoleAllowed},\
{"SetBedRestAllowed", SettingFunctions::SetBedRestAllowed},\
{"SetWildernessRestAllowed", SettingFunctions::SetWildernessRestAllowed},\
{"SetWaitAllowed", SettingFunctions::SetWaitAllowed},\
\
{"SendSettings", SettingFunctions::SendSettings}
class SettingFunctions
{
public:
#include "../api.h"
NAMESPACE_BEGIN(SettingFunctions)
/**
* \brief Set the difficulty for a player.
*
@ -29,7 +14,7 @@ public:
* \param difficulty The difficulty.
* \return void
*/
static void SetDifficulty(unsigned short pid, int difficulty);
API_FUNCTION void CDECL SetDifficulty(PlayerId pid, int difficulty);
/**
* \brief Set the client log level enforced for a player.
@ -47,7 +32,7 @@ public:
* \param enforcedLogLevel The enforced log level.
* \return void
*/
static void SetEnforcedLogLevel(unsigned short pid, int enforcedLogLevel);
API_FUNCTION void CDECL SetEnforcedLogLevel(PlayerId pid, int enforcedLogLevel);
/**
* \brief Set the physics framerate for a player.
@ -59,7 +44,7 @@ public:
* \param physicsFramerate The physics framerate.
* \return void
*/
static void SetPhysicsFramerate(unsigned short pid, double physicsFramerate);
API_FUNCTION void CDECL SetPhysicsFramerate(PlayerId pid, double physicsFramerate);
/**
* \brief Set whether the console is allowed for a player.
@ -71,7 +56,7 @@ public:
* \param state The console permission state.
* \return void
*/
static void SetConsoleAllowed(unsigned short pid, bool state);
API_FUNCTION void CDECL SetConsoleAllowed(PlayerId pid, bool state);
/**
* \brief Set whether resting in beds is allowed for a player.
@ -83,7 +68,7 @@ public:
* \param state The resting permission state.
* \return void
*/
static void SetBedRestAllowed(unsigned short pid, bool state);
API_FUNCTION void CDECL SetBedRestAllowed(PlayerId pid, bool state);
/**
* \brief Set whether resting in the wilderness is allowed for a player.
@ -95,7 +80,7 @@ public:
* \param state The resting permission state.
* \return void
*/
static void SetWildernessRestAllowed(unsigned short pid, bool state);
API_FUNCTION void CDECL SetWildernessRestAllowed(PlayerId pid, bool state);
/**
* \brief Set whether waiting is allowed for a player.
@ -107,7 +92,7 @@ public:
* \param state The waiting permission state.
* \return void
*/
static void SetWaitAllowed(unsigned short pid, bool state);
API_FUNCTION void CDECL SetWaitAllowed(PlayerId pid, bool state);
/**
* \brief Send a PlayerSettings packet to the player affected by it.
@ -115,7 +100,7 @@ public:
* \param pid The player ID to send it to.
* \return void
*/
static void SendSettings(unsigned short pid) noexcept;
};
API_FUNCTION void CDECL SendSettings(PlayerId pid) NOEXCEPT;
NAMESPACE_END()
#endif //OPENMW_SETTINGSAPI_HPP

@ -1,15 +1,15 @@
#include "Shapeshift.hpp"
#include "Shapeshift.h"
#include <components/openmw-mp/NetworkMessages.hpp>
#include <components/openmw-mp/Log.hpp>
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
#include <apps/openmw-mp/Script/Callbacks.hpp>
#include <apps/openmw-mp/Networking.hpp>
#include <iostream>
using namespace std;
double ShapeshiftFunctions::GetScale(unsigned short pid) noexcept
extern "C" double ShapeshiftFunctions::GetScale(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0.0f);
@ -17,7 +17,7 @@ double ShapeshiftFunctions::GetScale(unsigned short pid) noexcept
return player->scale;
}
bool ShapeshiftFunctions::IsWerewolf(unsigned short pid) noexcept
extern "C" bool ShapeshiftFunctions::IsWerewolf(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -25,7 +25,7 @@ bool ShapeshiftFunctions::IsWerewolf(unsigned short pid) noexcept
return player->isWerewolf;
}
const char *ShapeshiftFunctions::GetCreatureRefId(unsigned short pid) noexcept
extern "C" const char *ShapeshiftFunctions::GetCreatureRefId(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -33,7 +33,7 @@ const char *ShapeshiftFunctions::GetCreatureRefId(unsigned short pid) noexcept
return player->creatureRefId.c_str();
}
bool ShapeshiftFunctions::GetCreatureNameDisplayState(unsigned short pid) noexcept
extern "C" bool ShapeshiftFunctions::GetCreatureNameDisplayState(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -41,7 +41,7 @@ bool ShapeshiftFunctions::GetCreatureNameDisplayState(unsigned short pid) noexce
return player->displayCreatureName;
}
void ShapeshiftFunctions::SetScale(unsigned short pid, double scale) noexcept
extern "C" void ShapeshiftFunctions::SetScale(PlayerId pid, double scale) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -49,7 +49,7 @@ void ShapeshiftFunctions::SetScale(unsigned short pid, double scale) noexcept
player->scale = scale;
}
void ShapeshiftFunctions::SetWerewolfState(unsigned short pid, bool isWerewolf) noexcept
extern "C" void ShapeshiftFunctions::SetWerewolfState(PlayerId pid, bool isWerewolf) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -57,7 +57,7 @@ void ShapeshiftFunctions::SetWerewolfState(unsigned short pid, bool isWerewolf)
player->isWerewolf = isWerewolf;
}
void ShapeshiftFunctions::SetCreatureRefId(unsigned short pid, const char *refId) noexcept
extern "C" void ShapeshiftFunctions::SetCreatureRefId(PlayerId pid, const char *refId) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -65,7 +65,7 @@ void ShapeshiftFunctions::SetCreatureRefId(unsigned short pid, const char *refId
player->creatureRefId = refId;
}
void ShapeshiftFunctions::SetCreatureNameDisplayState(unsigned short pid, bool displayState) noexcept
extern "C" void ShapeshiftFunctions::SetCreatureNameDisplayState(PlayerId pid, bool displayState) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -73,7 +73,7 @@ void ShapeshiftFunctions::SetCreatureNameDisplayState(unsigned short pid, bool d
player->displayCreatureName = displayState;
}
void ShapeshiftFunctions::SendShapeshift(unsigned short pid)
extern "C" void ShapeshiftFunctions::SendShapeshift(PlayerId pid)
{
Player *player;
GET_PLAYER(pid, player, );

@ -1,32 +1,16 @@
#ifndef OPENMW_SHAPESHIFTAPI_HPP
#define OPENMW_SHAPESHIFTAPI_HPP
#include "../Types.hpp"
#define SHAPESHIFTAPI \
{"GetScale", ShapeshiftFunctions::GetScale},\
{"IsWerewolf", ShapeshiftFunctions::IsWerewolf},\
{"GetCreatureRefId", ShapeshiftFunctions::GetCreatureRefId},\
{"GetCreatureNameDisplayState", ShapeshiftFunctions::GetCreatureNameDisplayState},\
\
{"SetScale", ShapeshiftFunctions::SetScale},\
{"SetWerewolfState", ShapeshiftFunctions::SetWerewolfState},\
{"SetCreatureRefId", ShapeshiftFunctions::SetCreatureRefId},\
{"SetCreatureNameDisplayState", ShapeshiftFunctions::SetCreatureNameDisplayState},\
\
{"SendShapeshift", ShapeshiftFunctions::SendShapeshift}
class ShapeshiftFunctions
{
public:
#include "../api.h"
NAMESPACE_BEGIN(ShapeshiftFunctions)
/**
* \brief Get the scale of a player.
*
* \param pid The player ID.
* \return The scale.
*/
static double GetScale(unsigned short pid) noexcept;
API_FUNCTION double CDECL GetScale(PlayerId pid) NOEXCEPT;
/**
* \brief Check whether a player is a werewolf.
@ -36,7 +20,7 @@ public:
* \param pid The player ID.
* \return The werewolf state.
*/
static bool IsWerewolf(unsigned short pid) noexcept;
API_FUNCTION bool CDECL IsWerewolf(PlayerId pid) NOEXCEPT;
/**
* \brief Get the refId of the creature the player is disguised as.
@ -44,7 +28,7 @@ public:
* \param pid The player ID.
* \return The creature refId.
*/
static const char *GetCreatureRefId(unsigned short pid) noexcept;
API_FUNCTION const char *CDECL GetCreatureRefId(PlayerId pid) NOEXCEPT;
/**
* \brief Check whether a player's name is replaced by that of the creature they are
@ -55,7 +39,7 @@ public:
* \param pid The player ID.
* \return The creature name display state.
*/
static bool GetCreatureNameDisplayState(unsigned short pid) noexcept;
API_FUNCTION bool CDECL GetCreatureNameDisplayState(PlayerId pid) NOEXCEPT;
/**
* \brief Set the scale of a player.
@ -67,7 +51,7 @@ public:
* \param scale The new scale.
* \return void
*/
static void SetScale(unsigned short pid, double scale) noexcept;
API_FUNCTION void CDECL SetScale(PlayerId pid, double scale) NOEXCEPT;
/**
* \brief Set the werewolf state of a player.
@ -79,7 +63,7 @@ public:
* \param isWerewolf The new werewolf state.
* \return void
*/
static void SetWerewolfState(unsigned short pid, bool isWerewolf) noexcept;
API_FUNCTION void CDECL SetWerewolfState(PlayerId pid, bool isWerewolf) NOEXCEPT;
/**
* \brief Set the refId of the creature a player is disguised as.
@ -93,7 +77,7 @@ public:
* when hovered over by others.
* \return void
*/
static void SetCreatureRefId(unsigned short pid, const char *refId) noexcept;
API_FUNCTION void CDECL SetCreatureRefId(PlayerId pid, const char *refId) NOEXCEPT;
/**
* \brief Set whether a player's name is replaced by that of the creature they are
@ -103,7 +87,7 @@ public:
* \param displayState The creature name display state.
* \return void
*/
static void SetCreatureNameDisplayState(unsigned short pid, bool displayState) noexcept;
API_FUNCTION void CDECL SetCreatureNameDisplayState(PlayerId pid, bool displayState) NOEXCEPT;
/**
* \brief Send a PlayerShapeshift packet about a player.
@ -114,7 +98,7 @@ public:
* \param pid The player ID.
* \return void
*/
static void SendShapeshift(unsigned short pid);
};
API_FUNCTION void CDECL SendShapeshift(PlayerId pid);
NAMESPACE_END()
#endif //OPENMW_SHAPESHIFTAPI_HPP

@ -1,14 +1,14 @@
#include "Spells.hpp"
#include "Spells.h"
#include <components/misc/stringops.hpp>
#include <components/openmw-mp/NetworkMessages.hpp>
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
#include <apps/openmw-mp/Script/Callbacks.hpp>
#include <apps/openmw-mp/Networking.hpp>
using namespace mwmp;
void SpellFunctions::ClearSpellbookChanges(unsigned short pid) noexcept
extern "C" void SpellFunctions::ClearSpellbookChanges(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -16,7 +16,7 @@ void SpellFunctions::ClearSpellbookChanges(unsigned short pid) noexcept
player->spellbookChanges.spells.clear();
}
unsigned int SpellFunctions::GetSpellbookChangesSize(unsigned short pid) noexcept
extern "C" unsigned int SpellFunctions::GetSpellbookChangesSize(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -24,7 +24,7 @@ unsigned int SpellFunctions::GetSpellbookChangesSize(unsigned short pid) noexcep
return player->spellbookChanges.count;
}
unsigned int SpellFunctions::GetSpellbookChangesAction(unsigned short pid) noexcept
extern "C" unsigned int SpellFunctions::GetSpellbookChangesAction(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -32,7 +32,7 @@ unsigned int SpellFunctions::GetSpellbookChangesAction(unsigned short pid) noexc
return player->spellbookChanges.action;
}
void SpellFunctions::SetSpellbookChangesAction(unsigned short pid, unsigned char action) noexcept
extern "C" void SpellFunctions::SetSpellbookChangesAction(PlayerId pid, unsigned char action) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -40,7 +40,7 @@ void SpellFunctions::SetSpellbookChangesAction(unsigned short pid, unsigned char
player->spellbookChanges.action = action;
}
void SpellFunctions::AddSpell(unsigned short pid, const char* spellId) noexcept
extern "C" void SpellFunctions::AddSpell(PlayerId pid, const char* spellId) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -51,7 +51,7 @@ void SpellFunctions::AddSpell(unsigned short pid, const char* spellId) noexcept
player->spellbookChanges.spells.push_back(spell);
}
const char *SpellFunctions::GetSpellId(unsigned short pid, unsigned int index) noexcept
extern "C" const char *SpellFunctions::GetSpellId(PlayerId pid, unsigned int index) noexcept
{
Player *player;
GET_PLAYER(pid, player, "");
@ -62,7 +62,7 @@ const char *SpellFunctions::GetSpellId(unsigned short pid, unsigned int index) n
return player->spellbookChanges.spells.at(index).mId.c_str();
}
void SpellFunctions::SendSpellbookChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
extern "C" void SpellFunctions::SendSpellbookChanges(PlayerId pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -76,9 +76,9 @@ void SpellFunctions::SendSpellbookChanges(unsigned short pid, bool sendToOtherPl
packet->Send(true);
}
// All methods below are deprecated versions of methods from above
extern "C" // All methods below are deprecated versions of methods from above
void SpellFunctions::InitializeSpellbookChanges(unsigned short pid) noexcept
void SpellFunctions::InitializeSpellbookChanges(PlayerId pid) noexcept
{
ClearSpellbookChanges(pid);
}

@ -1,6 +1,8 @@
#ifndef OPENMW_SPELLAPI_HPP
#define OPENMW_SPELLAPI_HPP
#include "../api.h"
#define SPELLAPI \
{"ClearSpellbookChanges", SpellFunctions::ClearSpellbookChanges},\
\
@ -16,10 +18,7 @@
\
{"InitializeSpellbookChanges", SpellFunctions::InitializeSpellbookChanges}
class SpellFunctions
{
public:
NAMESPACE_BEGIN(SpellFunctions)
/**
* \brief Clear the last recorded spellbook changes for a player.
*
@ -28,7 +27,7 @@ public:
* \param pid The player ID whose spellbook changes should be used.
* \return void
*/
static void ClearSpellbookChanges(unsigned short pid) noexcept;
API_FUNCTION void CDECL ClearSpellbookChanges(PlayerId pid) NOEXCEPT;
/**
* \brief Get the number of indexes in a player's latest spellbook changes.
@ -36,7 +35,7 @@ public:
* \param pid The player ID whose spellbook changes should be used.
* \return The number of indexes.
*/
static unsigned int GetSpellbookChangesSize(unsigned short pid) noexcept;
API_FUNCTION unsigned int CDECL GetSpellbookChangesSize(PlayerId pid) NOEXCEPT;
/**
* \brief Get the action type used in a player's latest spellbook changes.
@ -44,7 +43,7 @@ public:
* \param pid The player ID whose spellbook changes should be used.
* \return The action type (0 for SET, 1 for ADD, 2 for REMOVE).
*/
static unsigned int GetSpellbookChangesAction(unsigned short pid) noexcept;
API_FUNCTION unsigned int CDECL GetSpellbookChangesAction(PlayerId pid) NOEXCEPT;
/**
* \brief Set the action type in a player's spellbook changes.
@ -53,7 +52,7 @@ public:
* \param action The action (0 for SET, 1 for ADD, 2 for REMOVE).
* \return void
*/
static void SetSpellbookChangesAction(unsigned short pid, unsigned char action) noexcept;
API_FUNCTION void CDECL SetSpellbookChangesAction(PlayerId pid, unsigned char action) NOEXCEPT;
/**
* \brief Add a new spell to the spellbook changes for a player.
@ -62,7 +61,7 @@ public:
* \param spellId The spellId of the spell.
* \return void
*/
static void AddSpell(unsigned short pid, const char* spellId) noexcept;
API_FUNCTION void CDECL AddSpell(PlayerId pid, const char* spellId) NOEXCEPT;
/**
* \brief Get the spellId at a certain index in a player's latest spellbook changes.
@ -71,7 +70,7 @@ public:
* \param index The index of the spell.
* \return The spellId.
*/
static const char *GetSpellId(unsigned short pid, unsigned int index) noexcept;
API_FUNCTION const char *CDECL GetSpellId(PlayerId pid, unsigned int index) NOEXCEPT;
/**
* \brief Send a PlayerSpellbook packet with a player's recorded spellbook changes.
@ -83,14 +82,11 @@ public:
* to the packet (false by default).
* \return void
*/
static void SendSpellbookChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendSpellbookChanges(PlayerId pid, bool sendToOtherPlayers, bool skipAttachedPlayer) NOEXCEPT;
// All methods below are deprecated versions of methods from above
static void InitializeSpellbookChanges(unsigned short pid) noexcept;
private:
};
API_FUNCTION void CDECL InitializeSpellbookChanges(PlayerId pid) NOEXCEPT;
NAMESPACE_END()
#endif //OPENMW_SPELLAPI_HPP

@ -1,4 +1,4 @@
#include "Stats.hpp"
#include "Stats.h"
#include <iostream>
@ -9,22 +9,22 @@
#include <components/openmw-mp/NetworkMessages.hpp>
#include <apps/openmw-mp/Networking.hpp>
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
#include <apps/openmw-mp/Script/Callbacks.hpp>
using namespace std;
using namespace ESM;
int StatsFunctions::GetAttributeCount() noexcept
extern "C" int StatsFunctions::GetAttributeCount() noexcept
{
return Attribute::Length;
}
int StatsFunctions::GetSkillCount() noexcept
extern "C" int StatsFunctions::GetSkillCount() noexcept
{
return Skill::Length;
}
int StatsFunctions::GetAttributeId(const char *name) noexcept
extern "C" int StatsFunctions::GetAttributeId(const char *name) noexcept
{
for (int x = 0; x < Attribute::Length; x++)
{
@ -37,7 +37,7 @@ int StatsFunctions::GetAttributeId(const char *name) noexcept
return -1;
}
int StatsFunctions::GetSkillId(const char *name) noexcept
extern "C" int StatsFunctions::GetSkillId(const char *name) noexcept
{
for (int x = 0; x < Skill::Length; x++)
{
@ -50,7 +50,7 @@ int StatsFunctions::GetSkillId(const char *name) noexcept
return -1;
}
const char *StatsFunctions::GetAttributeName(unsigned short attributeId) noexcept
extern "C" const char *StatsFunctions::GetAttributeName(unsigned short attributeId) noexcept
{
if (attributeId >= Attribute::Length)
return "invalid";
@ -58,7 +58,7 @@ const char *StatsFunctions::GetAttributeName(unsigned short attributeId) noexcep
return Attribute::sAttributeNames[attributeId].c_str();
}
const char *StatsFunctions::GetSkillName(unsigned short skillId) noexcept
extern "C" const char *StatsFunctions::GetSkillName(unsigned short skillId) noexcept
{
if (skillId >= Skill::Length)
return "invalid";
@ -66,7 +66,7 @@ const char *StatsFunctions::GetSkillName(unsigned short skillId) noexcept
return Skill::sSkillNames[skillId].c_str();
}
const char *StatsFunctions::GetName(unsigned short pid) noexcept
extern "C" const char *StatsFunctions::GetName(PlayerId pid) noexcept
{
Player *player;
@ -75,7 +75,7 @@ const char *StatsFunctions::GetName(unsigned short pid) noexcept
return player->npc.mName.c_str();
}
const char *StatsFunctions::GetRace(unsigned short pid) noexcept
extern "C" const char *StatsFunctions::GetRace(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -83,7 +83,7 @@ const char *StatsFunctions::GetRace(unsigned short pid) noexcept
return player->npc.mRace.c_str();
}
const char *StatsFunctions::GetHead(unsigned short pid) noexcept
extern "C" const char *StatsFunctions::GetHead(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -91,7 +91,7 @@ const char *StatsFunctions::GetHead(unsigned short pid) noexcept
return player->npc.mHead.c_str();
}
const char *StatsFunctions::GetHairstyle(unsigned short pid) noexcept
extern "C" const char *StatsFunctions::GetHairstyle(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -99,7 +99,7 @@ const char *StatsFunctions::GetHairstyle(unsigned short pid) noexcept
return player->npc.mHair.c_str();
}
int StatsFunctions::GetIsMale(unsigned short pid) noexcept
extern "C" int StatsFunctions::GetIsMale(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, false);
@ -107,7 +107,7 @@ int StatsFunctions::GetIsMale(unsigned short pid) noexcept
return player->npc.isMale();
}
const char *StatsFunctions::GetBirthsign(unsigned short pid) noexcept
extern "C" const char *StatsFunctions::GetBirthsign(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -115,7 +115,7 @@ const char *StatsFunctions::GetBirthsign(unsigned short pid) noexcept
return player->birthsign.c_str();
}
int StatsFunctions::GetLevel(unsigned short pid) noexcept
extern "C" int StatsFunctions::GetLevel(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -123,7 +123,7 @@ int StatsFunctions::GetLevel(unsigned short pid) noexcept
return player->creatureStats.mLevel;
}
int StatsFunctions::GetLevelProgress(unsigned short pid) noexcept
extern "C" int StatsFunctions::GetLevelProgress(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -131,7 +131,7 @@ int StatsFunctions::GetLevelProgress(unsigned short pid) noexcept
return player->npcStats.mLevelProgress;
}
double StatsFunctions::GetHealthBase(unsigned short pid) noexcept
extern "C" double StatsFunctions::GetHealthBase(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0.0f);
@ -139,7 +139,7 @@ double StatsFunctions::GetHealthBase(unsigned short pid) noexcept
return player->creatureStats.mDynamic[0].mBase;
}
double StatsFunctions::GetHealthCurrent(unsigned short pid) noexcept
extern "C" double StatsFunctions::GetHealthCurrent(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0.0f);
@ -147,7 +147,7 @@ double StatsFunctions::GetHealthCurrent(unsigned short pid) noexcept
return player->creatureStats.mDynamic[0].mCurrent;
}
double StatsFunctions::GetMagickaBase(unsigned short pid) noexcept
extern "C" double StatsFunctions::GetMagickaBase(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0.0f);
@ -155,7 +155,7 @@ double StatsFunctions::GetMagickaBase(unsigned short pid) noexcept
return player->creatureStats.mDynamic[1].mBase;
}
double StatsFunctions::GetMagickaCurrent(unsigned short pid) noexcept
extern "C" double StatsFunctions::GetMagickaCurrent(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0.0f);
@ -163,7 +163,7 @@ double StatsFunctions::GetMagickaCurrent(unsigned short pid) noexcept
return player->creatureStats.mDynamic[1].mCurrent;
}
double StatsFunctions::GetFatigueBase(unsigned short pid) noexcept
extern "C" double StatsFunctions::GetFatigueBase(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0.0f);
@ -171,7 +171,7 @@ double StatsFunctions::GetFatigueBase(unsigned short pid) noexcept
return player->creatureStats.mDynamic[2].mBase;
}
double StatsFunctions::GetFatigueCurrent(unsigned short pid) noexcept
extern "C" double StatsFunctions::GetFatigueCurrent(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0.0f);
@ -179,7 +179,7 @@ double StatsFunctions::GetFatigueCurrent(unsigned short pid) noexcept
return player->creatureStats.mDynamic[2].mCurrent;
}
int StatsFunctions::GetAttributeBase(unsigned short pid, unsigned short attributeId) noexcept
extern "C" int StatsFunctions::GetAttributeBase(PlayerId pid, unsigned short attributeId) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -190,7 +190,7 @@ int StatsFunctions::GetAttributeBase(unsigned short pid, unsigned short attribut
return player->creatureStats.mAttributes[attributeId].mBase;
}
int StatsFunctions::GetAttributeModifier(unsigned short pid, unsigned short attributeId) noexcept
extern "C" int StatsFunctions::GetAttributeModifier(PlayerId pid, unsigned short attributeId) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -201,18 +201,7 @@ int StatsFunctions::GetAttributeModifier(unsigned short pid, unsigned short attr
return player->creatureStats.mAttributes[attributeId].mMod;
}
double StatsFunctions::GetAttributeDamage(unsigned short pid, unsigned short attributeId) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
if (attributeId >= Attribute::Length)
return 0;
return player->creatureStats.mAttributes[attributeId].mDamage;
}
int StatsFunctions::GetSkillBase(unsigned short pid, unsigned short skillId) noexcept
extern "C" int StatsFunctions::GetSkillBase(PlayerId pid, unsigned short skillId) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -223,7 +212,7 @@ int StatsFunctions::GetSkillBase(unsigned short pid, unsigned short skillId) noe
return player->npcStats.mSkills[skillId].mBase;
}
int StatsFunctions::GetSkillModifier(unsigned short pid, unsigned short skillId) noexcept
extern "C" int StatsFunctions::GetSkillModifier(PlayerId pid, unsigned short skillId) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -234,18 +223,7 @@ int StatsFunctions::GetSkillModifier(unsigned short pid, unsigned short skillId)
return player->npcStats.mSkills[skillId].mMod;
}
double StatsFunctions::GetSkillDamage(unsigned short pid, unsigned short skillId) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
if (skillId >= Skill::Length)
return 0;
return player->npcStats.mSkills[skillId].mDamage;
}
double StatsFunctions::GetSkillProgress(unsigned short pid, unsigned short skillId) noexcept
extern "C" double StatsFunctions::GetSkillProgress(PlayerId pid, unsigned short skillId) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0.0f);
@ -256,18 +234,18 @@ double StatsFunctions::GetSkillProgress(unsigned short pid, unsigned short skill
return player->npcStats.mSkills[skillId].mProgress;
}
int StatsFunctions::GetSkillIncrease(unsigned short pid, unsigned int attributeId) noexcept
extern "C" int StatsFunctions::GetSkillIncrease(PlayerId pid, unsigned int attributeId) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
if (attributeId > Attribute::Length)
if (attributeId >= Attribute::Length)
return 0;
return player->npcStats.mSkillIncrease[attributeId];
}
int StatsFunctions::GetBounty(unsigned short pid) noexcept
extern "C" int StatsFunctions::GetBounty(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -275,7 +253,7 @@ int StatsFunctions::GetBounty(unsigned short pid) noexcept
return player->npcStats.mBounty;
}
void StatsFunctions::SetName(unsigned short pid, const char *name) noexcept
extern "C" void StatsFunctions::SetName(PlayerId pid, const char *name) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -286,7 +264,7 @@ void StatsFunctions::SetName(unsigned short pid, const char *name) noexcept
player->npc.mName = name;
}
void StatsFunctions::SetRace(unsigned short pid, const char *race) noexcept
extern "C" void StatsFunctions::SetRace(PlayerId pid, const char *race) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -300,7 +278,7 @@ void StatsFunctions::SetRace(unsigned short pid, const char *race) noexcept
player->npc.mRace = race;
}
void StatsFunctions::SetHead(unsigned short pid, const char *head) noexcept
extern "C" void StatsFunctions::SetHead(PlayerId pid, const char *head) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -311,7 +289,7 @@ void StatsFunctions::SetHead(unsigned short pid, const char *head) noexcept
player->npc.mHead = head;
}
void StatsFunctions::SetHairstyle(unsigned short pid, const char *hairstyle) noexcept
extern "C" void StatsFunctions::SetHairstyle(PlayerId pid, const char *hairstyle) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -322,7 +300,7 @@ void StatsFunctions::SetHairstyle(unsigned short pid, const char *hairstyle) noe
player->npc.mHair = hairstyle;
}
void StatsFunctions::SetIsMale(unsigned short pid, int state) noexcept
extern "C" void StatsFunctions::SetIsMale(PlayerId pid, int state) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -330,7 +308,7 @@ void StatsFunctions::SetIsMale(unsigned short pid, int state) noexcept
player->npc.setIsMale(state == true);
}
void StatsFunctions::SetBirthsign(unsigned short pid, const char *sign) noexcept
extern "C" void StatsFunctions::SetBirthsign(PlayerId pid, const char *sign) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -341,7 +319,7 @@ void StatsFunctions::SetBirthsign(unsigned short pid, const char *sign) noexcept
player->birthsign = sign;
}
void StatsFunctions::SetResetStats(unsigned short pid, bool resetStats) noexcept
extern "C" void StatsFunctions::SetResetStats(PlayerId pid, bool resetStats) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -349,7 +327,7 @@ void StatsFunctions::SetResetStats(unsigned short pid, bool resetStats) noexcept
player->resetStats = resetStats;
}
void StatsFunctions::SetLevel(unsigned short pid, int value) noexcept
extern "C" void StatsFunctions::SetLevel(PlayerId pid, int value) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -357,7 +335,7 @@ void StatsFunctions::SetLevel(unsigned short pid, int value) noexcept
player->creatureStats.mLevel = value;
}
void StatsFunctions::SetLevelProgress(unsigned short pid, int value) noexcept
extern "C" void StatsFunctions::SetLevelProgress(PlayerId pid, int value) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -365,7 +343,7 @@ void StatsFunctions::SetLevelProgress(unsigned short pid, int value) noexcept
player->npcStats.mLevelProgress = value;
}
void StatsFunctions::SetHealthBase(unsigned short pid, double value) noexcept
extern "C" void StatsFunctions::SetHealthBase(PlayerId pid, double value) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -376,7 +354,7 @@ void StatsFunctions::SetHealthBase(unsigned short pid, double value) noexcept
player->statsDynamicIndexChanges.push_back(0);
}
void StatsFunctions::SetHealthCurrent(unsigned short pid, double value) noexcept
extern "C" void StatsFunctions::SetHealthCurrent(PlayerId pid, double value) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -387,7 +365,7 @@ void StatsFunctions::SetHealthCurrent(unsigned short pid, double value) noexcept
player->statsDynamicIndexChanges.push_back(0);
}
void StatsFunctions::SetMagickaBase(unsigned short pid, double value) noexcept
extern "C" void StatsFunctions::SetMagickaBase(PlayerId pid, double value) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -398,7 +376,7 @@ void StatsFunctions::SetMagickaBase(unsigned short pid, double value) noexcept
player->statsDynamicIndexChanges.push_back(1);
}
void StatsFunctions::SetMagickaCurrent(unsigned short pid, double value) noexcept
extern "C" void StatsFunctions::SetMagickaCurrent(PlayerId pid, double value) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -409,7 +387,7 @@ void StatsFunctions::SetMagickaCurrent(unsigned short pid, double value) noexcep
player->statsDynamicIndexChanges.push_back(1);
}
void StatsFunctions::SetFatigueBase(unsigned short pid, double value) noexcept
extern "C" void StatsFunctions::SetFatigueBase(PlayerId pid, double value) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -420,7 +398,7 @@ void StatsFunctions::SetFatigueBase(unsigned short pid, double value) noexcept
player->statsDynamicIndexChanges.push_back(2);
}
void StatsFunctions::SetFatigueCurrent(unsigned short pid, double value) noexcept
extern "C" void StatsFunctions::SetFatigueCurrent(PlayerId pid, double value) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -431,7 +409,7 @@ void StatsFunctions::SetFatigueCurrent(unsigned short pid, double value) noexcep
player->statsDynamicIndexChanges.push_back(2);
}
void StatsFunctions::SetAttributeBase(unsigned short pid, unsigned short attributeId, int value) noexcept
extern "C" void StatsFunctions::SetAttributeBase(PlayerId pid, unsigned short attributeId, int value) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -445,7 +423,7 @@ void StatsFunctions::SetAttributeBase(unsigned short pid, unsigned short attribu
player->attributeIndexChanges.push_back(attributeId);
}
void StatsFunctions::ClearAttributeModifier(unsigned short pid, unsigned short attributeId) noexcept
extern "C" void StatsFunctions::ClearAttributeModifier(PlayerId pid, unsigned short attributeId) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -459,21 +437,7 @@ void StatsFunctions::ClearAttributeModifier(unsigned short pid, unsigned short a
player->attributeIndexChanges.push_back(attributeId);
}
void StatsFunctions::SetAttributeDamage(unsigned short pid, unsigned short attributeId, double value) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
if (attributeId >= Attribute::Length)
return;
player->creatureStats.mAttributes[attributeId].mDamage = value;
if (!Utils::vectorContains(player->attributeIndexChanges, attributeId))
player->attributeIndexChanges.push_back(attributeId);
}
void StatsFunctions::SetSkillBase(unsigned short pid, unsigned short skillId, int value) noexcept
extern "C" void StatsFunctions::SetSkillBase(PlayerId pid, unsigned short skillId, int value) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -487,7 +451,7 @@ void StatsFunctions::SetSkillBase(unsigned short pid, unsigned short skillId, in
player->skillIndexChanges.push_back(skillId);
}
void StatsFunctions::ClearSkillModifier(unsigned short pid, unsigned short skillId) noexcept
extern "C" void StatsFunctions::ClearSkillModifier(PlayerId pid, unsigned short skillId) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -501,21 +465,7 @@ void StatsFunctions::ClearSkillModifier(unsigned short pid, unsigned short skill
player->skillIndexChanges.push_back(skillId);
}
void StatsFunctions::SetSkillDamage(unsigned short pid, unsigned short skillId, double value) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
if (skillId >= Skill::Length)
return;
player->npcStats.mSkills[skillId].mDamage = value;
if (!Utils::vectorContains(player->skillIndexChanges, skillId))
player->skillIndexChanges.push_back(skillId);
}
void StatsFunctions::SetSkillProgress(unsigned short pid, unsigned short skillId, double value) noexcept
extern "C" void StatsFunctions::SetSkillProgress(PlayerId pid, unsigned short skillId, double value) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -529,12 +479,12 @@ void StatsFunctions::SetSkillProgress(unsigned short pid, unsigned short skillId
player->skillIndexChanges.push_back(skillId);
}
void StatsFunctions::SetSkillIncrease(unsigned short pid, unsigned int attributeId, int value) noexcept
extern "C" void StatsFunctions::SetSkillIncrease(PlayerId pid, unsigned int attributeId, int value) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
if (attributeId > Attribute::Length)
if (attributeId >= Attribute::Length)
return;
player->npcStats.mSkillIncrease[attributeId] = value;
@ -543,7 +493,7 @@ void StatsFunctions::SetSkillIncrease(unsigned short pid, unsigned int attribute
player->attributeIndexChanges.push_back(attributeId);
}
void StatsFunctions::SetBounty(unsigned short pid, int value) noexcept
extern "C" void StatsFunctions::SetBounty(PlayerId pid, int value) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -551,7 +501,7 @@ void StatsFunctions::SetBounty(unsigned short pid, int value) noexcept
player->npcStats.mBounty = value;
}
void StatsFunctions::SetCharGenStage(unsigned short pid, int currentStage, int endStage) noexcept
extern "C" void StatsFunctions::SetCharGenStage(PlayerId pid, int currentStage, int endStage) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -566,7 +516,7 @@ void StatsFunctions::SetCharGenStage(unsigned short pid, int currentStage, int e
packet->Send(false);
}
void StatsFunctions::SendBaseInfo(unsigned short pid) noexcept
extern "C" void StatsFunctions::SendBaseInfo(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -578,7 +528,7 @@ void StatsFunctions::SendBaseInfo(unsigned short pid) noexcept
packet->Send(true);
}
void StatsFunctions::SendStatsDynamic(unsigned short pid) noexcept
extern "C" void StatsFunctions::SendStatsDynamic(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -592,7 +542,7 @@ void StatsFunctions::SendStatsDynamic(unsigned short pid) noexcept
player->statsDynamicIndexChanges.clear();
}
void StatsFunctions::SendAttributes(unsigned short pid) noexcept
extern "C" void StatsFunctions::SendAttributes(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -606,7 +556,7 @@ void StatsFunctions::SendAttributes(unsigned short pid) noexcept
player->attributeIndexChanges.clear();
}
void StatsFunctions::SendSkills(unsigned short pid) noexcept
extern "C" void StatsFunctions::SendSkills(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -620,7 +570,7 @@ void StatsFunctions::SendSkills(unsigned short pid) noexcept
player->skillIndexChanges.clear();
}
void StatsFunctions::SendLevel(unsigned short pid) noexcept
extern "C" void StatsFunctions::SendLevel(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -632,7 +582,7 @@ void StatsFunctions::SendLevel(unsigned short pid) noexcept
packet->Send(true);
}
void StatsFunctions::SendBounty(unsigned short pid) noexcept
extern "C" void StatsFunctions::SendBounty(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );

@ -1,6 +1,8 @@
#ifndef OPENMW_STATAPI_HPP
#define OPENMW_STATAPI_HPP
#include "../api.h"
#define STATAPI \
{"GetAttributeCount", StatsFunctions::GetAttributeCount},\
{"GetSkillCount", StatsFunctions::GetSkillCount},\
@ -30,11 +32,9 @@
\
{"GetAttributeBase", StatsFunctions::GetAttributeBase},\
{"GetAttributeModifier", StatsFunctions::GetAttributeModifier},\
{"GetAttributeDamage", StatsFunctions::GetAttributeDamage},\
\
{"GetSkillBase", StatsFunctions::GetSkillBase},\
{"GetSkillModifier", StatsFunctions::GetSkillModifier},\
{"GetSkillDamage", StatsFunctions::GetSkillDamage},\
{"GetSkillProgress", StatsFunctions::GetSkillProgress},\
{"GetSkillIncrease", StatsFunctions::GetSkillIncrease},\
\
@ -60,11 +60,9 @@
\
{"SetAttributeBase", StatsFunctions::SetAttributeBase},\
{"ClearAttributeModifier", StatsFunctions::ClearAttributeModifier},\
{"SetAttributeDamage", StatsFunctions::SetAttributeDamage},\
\
{"SetSkillBase", StatsFunctions::SetSkillBase},\
{"ClearSkillModifier", StatsFunctions::ClearSkillModifier},\
{"SetSkillDamage", StatsFunctions::SetSkillDamage},\
{"SetSkillProgress", StatsFunctions::SetSkillProgress},\
{"SetSkillIncrease", StatsFunctions::SetSkillIncrease},\
\
@ -79,10 +77,7 @@
{"SendLevel", StatsFunctions::SendLevel},\
{"SendBounty", StatsFunctions::SendBounty}
class StatsFunctions
{
public:
NAMESPACE_BEGIN(StatsFunctions)
/**
* \brief Get the number of attributes.
*
@ -90,7 +85,7 @@ public:
*
* \return The number of attributes.
*/
static int GetAttributeCount() noexcept;
API_FUNCTION int CDECL GetAttributeCount() NOEXCEPT;
/**
* \brief Get the number of skills.
@ -99,7 +94,7 @@ public:
*
* \return The number of skills.
*/
static int GetSkillCount() noexcept;
API_FUNCTION int CDECL GetSkillCount() NOEXCEPT;
/**
* \brief Get the numerical ID of an attribute with a certain name.
@ -109,7 +104,7 @@ public:
* \param name The name of the attribute.
* \return The ID of the attribute.
*/
static int GetAttributeId(const char *name) noexcept;
API_FUNCTION int CDECL GetAttributeId(const char *name) NOEXCEPT;
/**
* \brief Get the numerical ID of a skill with a certain name.
@ -119,7 +114,7 @@ public:
* \param name The name of the skill.
* \return The ID of the skill.
*/
static int GetSkillId(const char *name) noexcept;
API_FUNCTION int CDECL GetSkillId(const char *name) NOEXCEPT;
/**
* \brief Get the name of the attribute with a certain numerical ID.
@ -129,7 +124,7 @@ public:
* \param attributeId The ID of the attribute.
* \return The name of the attribute.
*/
static const char *GetAttributeName(unsigned short attributeId) noexcept;
API_FUNCTION const char *CDECL GetAttributeName(unsigned short attributeId) NOEXCEPT;
/**
* \brief Get the name of the skill with a certain numerical ID.
@ -139,7 +134,7 @@ public:
* \param skillId The ID of the skill.
* \return The name of the skill.
*/
static const char *GetSkillName(unsigned short skillId) noexcept;
API_FUNCTION const char *CDECL GetSkillName(unsigned short skillId) NOEXCEPT;
/**
* \brief Get the name of a player.
@ -147,7 +142,7 @@ public:
* \param pid The player ID.
* \return The name of the player.
*/
static const char *GetName(unsigned short pid) noexcept;
API_FUNCTION const char *CDECL GetName(PlayerId pid) NOEXCEPT;
/**
* \brief Get the race of a player.
@ -155,7 +150,7 @@ public:
* \param pid The player ID.
* \return The race of the player.
*/
static const char *GetRace(unsigned short pid) noexcept;
API_FUNCTION const char *CDECL GetRace(PlayerId pid) NOEXCEPT;
/**
* \brief Get the head mesh used by a player.
@ -163,7 +158,7 @@ public:
* \param pid The player ID.
* \return The head mesh of the player.
*/
static const char *GetHead(unsigned short pid) noexcept;
API_FUNCTION const char *CDECL GetHead(PlayerId pid) NOEXCEPT;
/**
* \brief Get the hairstyle mesh used by a player.
@ -171,7 +166,7 @@ public:
* \param pid The player ID.
* \return The hairstyle mesh of the player.
*/
static const char *GetHairstyle(unsigned short pid) noexcept;
API_FUNCTION const char *CDECL GetHairstyle(PlayerId pid) NOEXCEPT;
/**
* \brief Check whether a player is male or not.
@ -179,7 +174,7 @@ public:
* \param pid The player ID.
* \return Whether the player is male.
*/
static int GetIsMale(unsigned short pid) noexcept;
API_FUNCTION int CDECL GetIsMale(PlayerId pid) NOEXCEPT;
/**
* \brief Get the birthsign of a player.
@ -187,7 +182,7 @@ public:
* \param pid The player ID.
* \return The birthsign of the player.
*/
static const char *GetBirthsign(unsigned short pid) noexcept;
API_FUNCTION const char *CDECL GetBirthsign(PlayerId pid) NOEXCEPT;
/**
* \brief Get the character level of a player.
@ -195,7 +190,7 @@ public:
* \param pid The player ID.
* \return The level of the player.
*/
static int GetLevel(unsigned short pid) noexcept;
API_FUNCTION int CDECL GetLevel(PlayerId pid) NOEXCEPT;
/**
* \brief Get the player's progress to their next character level.
@ -203,7 +198,7 @@ public:
* \param pid The player ID.
* \return The level progress.
*/
static int GetLevelProgress(unsigned short pid) noexcept;
API_FUNCTION int CDECL GetLevelProgress(PlayerId pid) NOEXCEPT;
/**
* \brief Get the base health of the player.
@ -211,7 +206,7 @@ public:
* \param pid The player ID.
* \return The base health.
*/
static double GetHealthBase(unsigned short pid) noexcept;
API_FUNCTION double CDECL GetHealthBase(PlayerId pid) NOEXCEPT;
/**
* \brief Get the current health of the player.
@ -219,7 +214,7 @@ public:
* \param pid The player ID.
* \return The current health.
*/
static double GetHealthCurrent(unsigned short pid) noexcept;
API_FUNCTION double CDECL GetHealthCurrent(PlayerId pid) NOEXCEPT;
/**
* \brief Get the base magicka of the player.
@ -227,7 +222,7 @@ public:
* \param pid The player ID.
* \return The base magicka.
*/
static double GetMagickaBase(unsigned short pid) noexcept;
API_FUNCTION double CDECL GetMagickaBase(PlayerId pid) NOEXCEPT;
/**
* \brief Get the current magicka of the player.
@ -235,7 +230,7 @@ public:
* \param pid The player ID.
* \return The current magicka.
*/
static double GetMagickaCurrent(unsigned short pid) noexcept;
API_FUNCTION double CDECL GetMagickaCurrent(PlayerId pid) NOEXCEPT;
/**
* \brief Get the base fatigue of the player.
@ -243,7 +238,7 @@ public:
* \param pid The player ID.
* \return The base fatigue.
*/
static double GetFatigueBase(unsigned short pid) noexcept;
API_FUNCTION double CDECL GetFatigueBase(PlayerId pid) NOEXCEPT;
/**
* \brief Get the current fatigue of the player.
@ -251,7 +246,7 @@ public:
* \param pid The player ID.
* \return The current fatigue.
*/
static double GetFatigueCurrent(unsigned short pid) noexcept;
API_FUNCTION double CDECL GetFatigueCurrent(PlayerId pid) NOEXCEPT;
/**
* \brief Get the base value of a player's attribute.
@ -260,7 +255,7 @@ public:
* \param attributeId The attribute ID.
* \return The base value of the attribute.
*/
static int GetAttributeBase(unsigned short pid, unsigned short attributeId) noexcept;
API_FUNCTION int CDECL GetAttributeBase(PlayerId pid, unsigned short attributeId) NOEXCEPT;
/**
* \brief Get the modifier value of a player's attribute.
@ -269,17 +264,7 @@ public:
* \param attributeId The attribute ID.
* \return The modifier value of the attribute.
*/
static int GetAttributeModifier(unsigned short pid, unsigned short attributeId) noexcept;
/**
* \brief Get the amount of damage (as caused through the Damage Attribute effect)
* to a player's attribute.
*
* \param pid The player ID.
* \param attributeId The attribute ID.
* \return The amount of damage to the attribute.
*/
static double GetAttributeDamage(unsigned short pid, unsigned short attributeId) noexcept;
API_FUNCTION int CDECL GetAttributeModifier(PlayerId pid, unsigned short attributeId) NOEXCEPT;
/**
* \brief Get the base value of a player's skill.
@ -288,7 +273,7 @@ public:
* \param skillId The skill ID.
* \return The base value of the skill.
*/
static int GetSkillBase(unsigned short pid, unsigned short skillId) noexcept;
API_FUNCTION int CDECL GetSkillBase(PlayerId pid, unsigned short skillId) NOEXCEPT;
/**
* \brief Get the modifier value of a player's skill.
@ -297,17 +282,7 @@ public:
* \param skillId The skill ID.
* \return The modifier value of the skill.
*/
static int GetSkillModifier(unsigned short pid, unsigned short skillId) noexcept;
/**
* \brief Get the amount of damage (as caused through the Damage Skill effect)
* to a player's skill.
*
* \param pid The player ID.
* \param skillId The skill ID.
* \return The amount of damage to the skill.
*/
static double GetSkillDamage(unsigned short pid, unsigned short skillId) noexcept;
API_FUNCTION int CDECL GetSkillModifier(PlayerId pid, unsigned short skillId) NOEXCEPT;
/**
* \brief Get the progress the player has made towards increasing a certain skill by 1.
@ -316,7 +291,7 @@ public:
* \param skillId The skill ID.
* \return The skill progress.
*/
static double GetSkillProgress(unsigned short pid, unsigned short skillId) noexcept;
API_FUNCTION double CDECL GetSkillProgress(PlayerId pid, unsigned short skillId) NOEXCEPT;
/**
* \brief Get the bonus applied to a certain attribute at the next level up as a result
@ -328,7 +303,7 @@ public:
* \param skillId The attribute ID.
* \return The increase in the attribute caused by skills.
*/
static int GetSkillIncrease(unsigned short pid, unsigned int attributeId) noexcept;
API_FUNCTION int CDECL GetSkillIncrease(PlayerId pid, unsigned int attributeId) NOEXCEPT;
/**
* \brief Get the bounty of the player.
@ -336,7 +311,7 @@ public:
* \param pid The player ID.
* \return The bounty.
*/
static int GetBounty(unsigned short pid) noexcept;
API_FUNCTION int CDECL GetBounty(PlayerId pid) NOEXCEPT;
/**
* \brief Set the name of a player.
@ -345,7 +320,7 @@ public:
* \param name The new name of the player.
* \return void
*/
static void SetName(unsigned short pid, const char *name) noexcept;
API_FUNCTION void CDECL SetName(PlayerId pid, const char *name) NOEXCEPT;
/**
* \brief Set the race of a player.
@ -354,7 +329,7 @@ public:
* \param race The new race of the player.
* \return void
*/
static void SetRace(unsigned short pid, const char *race) noexcept;
API_FUNCTION void CDECL SetRace(PlayerId pid, const char *race) NOEXCEPT;
/**
* \brief Set the head mesh used by a player.
@ -363,7 +338,7 @@ public:
* \param head The new head mesh of the player.
* \return void
*/
static void SetHead(unsigned short pid, const char *head) noexcept;
API_FUNCTION void CDECL SetHead(PlayerId pid, const char *head) NOEXCEPT;
/**
* \brief Set the hairstyle mesh used by a player.
@ -372,7 +347,7 @@ public:
* \param hairstyle The new hairstyle mesh of the player.
* \return void
*/
static void SetHairstyle(unsigned short pid, const char *hairstyle) noexcept;
API_FUNCTION void CDECL SetHairstyle(PlayerId pid, const char *hairstyle) NOEXCEPT;
/**
* \brief Set whether a player is male or not.
@ -381,7 +356,7 @@ public:
* \param state Whether the player is male.
* \return void
*/
static void SetIsMale(unsigned short pid, int state) noexcept;
API_FUNCTION void CDECL SetIsMale(PlayerId pid, int state) NOEXCEPT;
/**
* \brief Set the birthsign of a player.
@ -390,7 +365,7 @@ public:
* \param name The new birthsign of the player.
* \return void
*/
static void SetBirthsign(unsigned short pid, const char *name) noexcept;
API_FUNCTION void CDECL SetBirthsign(PlayerId pid, const char *name) NOEXCEPT;
/**
* \brief Set whether the player's stats should be reset based on their
@ -403,7 +378,7 @@ public:
* \param resetStats The stat reset state.
* \return void
*/
static void SetResetStats(unsigned short pid, bool resetStats) noexcept;
API_FUNCTION void CDECL SetResetStats(PlayerId pid, bool resetStats) NOEXCEPT;
/**
* \brief Set the character level of a player.
@ -412,7 +387,7 @@ public:
* \param value The new level of the player.
* \return void
*/
static void SetLevel(unsigned short pid, int value) noexcept;
API_FUNCTION void CDECL SetLevel(PlayerId pid, int value) NOEXCEPT;
/**
* \brief Set the player's progress to their next character level.
@ -421,7 +396,7 @@ public:
* \param value The new level progress of the player.
* \return void
*/
static void SetLevelProgress(unsigned short pid, int value) noexcept;
API_FUNCTION void CDECL SetLevelProgress(PlayerId pid, int value) NOEXCEPT;
/**
* \brief Set the base health of a player.
@ -430,7 +405,7 @@ public:
* \param name The new base health of the player.
* \return void
*/
static void SetHealthBase(unsigned short pid, double value) noexcept;
API_FUNCTION void CDECL SetHealthBase(PlayerId pid, double value) NOEXCEPT;
/**
* \brief Set the current health of a player.
@ -439,7 +414,7 @@ public:
* \param name The new current health of the player.
* \return void
*/
static void SetHealthCurrent(unsigned short pid, double value) noexcept;
API_FUNCTION void CDECL SetHealthCurrent(PlayerId pid, double value) NOEXCEPT;
/**
* \brief Set the base magicka of a player.
@ -448,7 +423,7 @@ public:
* \param name The new base magicka of the player.
* \return void
*/
static void SetMagickaBase(unsigned short pid, double value) noexcept;
API_FUNCTION void CDECL SetMagickaBase(PlayerId pid, double value) NOEXCEPT;
/**
* \brief Set the current magicka of a player.
@ -457,7 +432,7 @@ public:
* \param name The new current magicka of the player.
* \return void
*/
static void SetMagickaCurrent(unsigned short pid, double value) noexcept;
API_FUNCTION void CDECL SetMagickaCurrent(PlayerId pid, double value) NOEXCEPT;
/**
* \brief Set the base fatigue of a player.
@ -466,7 +441,7 @@ public:
* \param name The new base fatigue of the player.
* \return void
*/
static void SetFatigueBase(unsigned short pid, double value) noexcept;
API_FUNCTION void CDECL SetFatigueBase(PlayerId pid, double value) NOEXCEPT;
/**
* \brief Set the current fatigue of a player.
@ -475,7 +450,7 @@ public:
* \param name The new current fatigue of the player.
* \return void
*/
static void SetFatigueCurrent(unsigned short pid, double value) noexcept;
API_FUNCTION void CDECL SetFatigueCurrent(PlayerId pid, double value) NOEXCEPT;
/**
* \brief Set the base value of a player's attribute.
@ -485,7 +460,7 @@ public:
* \param value The new base value of the player's attribute.
* \return void
*/
static void SetAttributeBase(unsigned short pid, unsigned short attributeId, int value) noexcept;
API_FUNCTION void CDECL SetAttributeBase(PlayerId pid, unsigned short attributeId, int value) NOEXCEPT;
/**
* \brief Clear the modifier value of a player's attribute.
@ -499,18 +474,7 @@ public:
* \param attributeId The attribute ID.
* \return void
*/
static void ClearAttributeModifier(unsigned short pid, unsigned short attributeId) noexcept;
/**
* \brief Set the amount of damage (as caused through the Damage Attribute effect) to
* a player's attribute.
*
* \param pid The player ID.
* \param attributeId The attribute ID.
* \param value The amount of damage to the player's attribute.
* \return void
*/
static void SetAttributeDamage(unsigned short pid, unsigned short attributeId, double value) noexcept;
API_FUNCTION void CDECL ClearAttributeModifier(PlayerId pid, unsigned short attributeId) NOEXCEPT;
/**
* \brief Set the base value of a player's skill.
@ -520,7 +484,7 @@ public:
* \param value The new base value of the player's skill.
* \return void
*/
static void SetSkillBase(unsigned short pid, unsigned short skillId, int value) noexcept;
API_FUNCTION void CDECL SetSkillBase(PlayerId pid, unsigned short skillId, int value) NOEXCEPT;
/**
* \brief Clear the modifier value of a player's skill.
@ -534,18 +498,7 @@ public:
* \param skillId The skill ID.
* \return void
*/
static void ClearSkillModifier(unsigned short pid, unsigned short skillId) noexcept;
/**
* \brief Set the amount of damage (as caused through the Damage Skill effect) to
* a player's skill.
*
* \param pid The player ID.
* \param skillId The skill ID.
* \param value The amount of damage to the player's skill.
* \return void
*/
static void SetSkillDamage(unsigned short pid, unsigned short skillId, double value) noexcept;
API_FUNCTION void CDECL ClearSkillModifier(PlayerId pid, unsigned short skillId) NOEXCEPT;
/**
* \brief Set the progress the player has made towards increasing a certain skill by 1.
@ -555,7 +508,7 @@ public:
* \param value The progress value.
* \return void
*/
static void SetSkillProgress(unsigned short pid, unsigned short skillId, double value) noexcept;
API_FUNCTION void CDECL SetSkillProgress(PlayerId pid, unsigned short skillId, double value) NOEXCEPT;
/**
* \brief Set the bonus applied to a certain attribute at the next level up as a result
@ -568,7 +521,7 @@ public:
* \param value The increase in the attribute caused by skills.
* \return void
*/
static void SetSkillIncrease(unsigned short pid, unsigned int attributeId, int value) noexcept;
API_FUNCTION void CDECL SetSkillIncrease(PlayerId pid, unsigned int attributeId, int value) NOEXCEPT;
/**
* \brief Set the bounty of a player.
@ -577,7 +530,7 @@ public:
* \param value The new bounty.
* \return void
*/
static void SetBounty(unsigned short pid, int value) noexcept;
API_FUNCTION void CDECL SetBounty(PlayerId pid, int value) NOEXCEPT;
/**
* \brief Set the current and ending stages of character generation for a player.
@ -589,7 +542,7 @@ public:
* \param endStage The new ending stage.
* \return void
*/
static void SetCharGenStage(unsigned short pid, int currentStage, int endStage) noexcept;
API_FUNCTION void CDECL SetCharGenStage(PlayerId pid, int currentStage, int endStage) NOEXCEPT;
/**
* \brief Send a PlayerBaseInfo packet with a player's name, race, head mesh,
@ -600,7 +553,7 @@ public:
* \param pid The player ID.
* \return void
*/
static void SendBaseInfo(unsigned short pid) noexcept;
API_FUNCTION void CDECL SendBaseInfo(PlayerId pid) NOEXCEPT;
/**
* \brief Send a PlayerStatsDynamic packet with a player's dynamic stats (health,
@ -611,7 +564,7 @@ public:
* \param pid The player ID.
* \return void
*/
static void SendStatsDynamic(unsigned short pid) noexcept;
API_FUNCTION void CDECL SendStatsDynamic(PlayerId pid) NOEXCEPT;
/**
* \brief Send a PlayerAttribute packet with a player's attributes and bonuses
@ -623,7 +576,7 @@ public:
* \param pid The player ID.
* \return void
*/
static void SendAttributes(unsigned short pid) noexcept;
API_FUNCTION void CDECL SendAttributes(PlayerId pid) NOEXCEPT;
/**
* \brief Send a PlayerSkill packet with a player's skills.
@ -633,7 +586,7 @@ public:
* \param pid The player ID.
* \return void
*/
static void SendSkills(unsigned short pid) noexcept;
API_FUNCTION void CDECL SendSkills(PlayerId pid) NOEXCEPT;
/**
* \brief Send a PlayerLevel packet with a player's character level and
@ -644,7 +597,7 @@ public:
* \param pid The player ID.
* \return void
*/
static void SendLevel(unsigned short pid) noexcept;
API_FUNCTION void CDECL SendLevel(PlayerId pid) NOEXCEPT;
/**
* \brief Send a PlayerBounty packet with a player's bounty.
@ -654,7 +607,7 @@ public:
* \param pid The player ID.
* \return void
*/
static void SendBounty(unsigned short pid) noexcept;
};
API_FUNCTION void CDECL SendBounty(PlayerId pid) NOEXCEPT;
NAMESPACE_END()
#endif //OPENMW_STATAPI_HPP

@ -2,57 +2,70 @@
// Created by koncord on 15.03.16.
//
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
#include <apps/openmw-mp/Script/Callbacks.hpp>
#include <components/openmw-mp/NetworkMessages.hpp>
#include <Player.hpp>
#include <Networking.hpp>
#include <Script/API/TimerAPI.hpp>
#include "Timer.h"
using namespace std;
using namespace mwmp;
int ScriptFunctions::CreateTimer(ScriptFunc callback, int msec) noexcept
extern "C" int TimerFunctions::CreateTimer(ScriptFunc callback, int msec) noexcept
{
return mwmp::TimerAPI::CreateTimer(callback, msec, "", vector<boost::any>());
va_list list;
return mwmp::TimerAPI::CreateTimer(callback, msec, "", list);
}
int ScriptFunctions::CreateTimerEx(ScriptFunc callback, int msec, const char *types, va_list args) noexcept
extern "C" int TimerFunctions::CreateTimerEx(ScriptFunc callback, int msec, const char *types, ...) noexcept
{
try
{
vector<boost::any> params;
Utils::getArguments(params, args, types);
return mwmp::TimerAPI::CreateTimer(callback, msec, types, params);
va_list args;
va_start(args, types);
int tid = mwmp::TimerAPI::CreateTimer(callback, msec, types, args);
va_end(args);
return tid;
}
catch (...)
{
return -1;
}
}
void ScriptFunctions::StartTimer(int timerId) noexcept
extern "C" void TimerFunctions::StartTimer(int timerId) noexcept
{
TimerAPI::StartTimer(timerId);
}
void ScriptFunctions::StopTimer(int timerId) noexcept
extern "C" void TimerFunctions::StopTimer(int timerId) noexcept
{
TimerAPI::StopTimer(timerId);
}
void ScriptFunctions::RestartTimer(int timerId, int msec) noexcept
extern "C" void TimerFunctions::RestartTimer(int timerId, int msec) noexcept
{
TimerAPI::ResetTimer(timerId, msec);
}
void ScriptFunctions::FreeTimer(int timerId) noexcept
extern "C" void TimerFunctions::FreeTimer(int timerId) noexcept
{
TimerAPI::FreeTimer(timerId);
}
bool ScriptFunctions::IsTimerElapsed(int timerId) noexcept
extern "C" bool TimerFunctions::IsTimerElapsed(int timerId) noexcept
{
return TimerAPI::IsTimerElapsed(timerId);
}
extern "C" int TimerFunctions::GetTimerId() noexcept
{
return TimerAPI::GetTimerId();
}
const char *TimerFunctions::GetTimerDefinition(int timerId)
{
return TimerAPI::GetDefinition(timerId);
}

@ -0,0 +1,94 @@
//
// Created by koncord on 09.12.18.
//
#ifndef OPENMW_TIMER_HPP
#define OPENMW_TIMER_HPP
#include "../api.h"
#include <stdarg.h>
NAMESPACE_BEGIN(TimerFunctions)
/**
* \brief Create a timer that will run a script function after a certain interval.
*
* \param callback The Lua script function.
* \param msec The interval in miliseconds.
* \return The ID of the timer thus created.
*/
API_FUNCTION int CDECL CreateTimer(ScriptFunc callback, int msec) NOEXCEPT;
/**
* \brief Create a timer that will run a script function after a certain interval and pass
* certain arguments to it.
*
* Example usage:
* - tes3mp.CreateTimerEx("OnTimerTest1", 250, "i", 90)
* - tes3mp.CreateTimerEx("OnTimerTest2", 500, "sif", "Test string", 60, 77.321)
*
* \param callback The Lua script function.
* \param msec The interval in miliseconds.
* \param types The argument types.
* \param args The arguments.
* \return The ID of the timer thus created.
*/
API_FUNCTION int CDECL CreateTimerEx(ScriptFunc callback, int msec, const char *types, ...) NOEXCEPT;
/**
* \brief Start the timer with a certain ID.
*
* \param timerId The timer ID.
* \return void
*/
API_FUNCTION void CDECL StartTimer(int timerId) NOEXCEPT;
/**
* \brief Stop the timer with a certain ID.
*
* \param timerId The timer ID.
* \return void
*/
API_FUNCTION void CDECL StopTimer(int timerId) NOEXCEPT;
/**
* \brief Restart the timer with a certain ID for a certain interval.
*
* \param timerId The timer ID.
* \param msec The interval in miliseconds.
* \return void
*/
API_FUNCTION void CDECL RestartTimer(int timerId, int msec) NOEXCEPT;
/**
* \brief Free the timer with a certain ID.
*
* \param timerId The timer ID.
* \return void
*/
API_FUNCTION void CDECL FreeTimer(int timerId) NOEXCEPT;
/**
* \brief Check whether a timer is elapsed.
*
* \param timerId The timer ID.
* \return Whether the timer is elapsed.
*/
API_FUNCTION bool CDECL IsTimerElapsed(int timerId) NOEXCEPT;
/**
* \brief Return timer id if called from timer, otherwise -1
*
* \return TimerId
*/
API_FUNCTION int CDECL GetTimerId() NOEXCEPT;
/**
* \brief Return timer id if called from timer, otherwise -1
*
* \param timerId The timer ID.
* \return types of timer
*/
API_FUNCTION const char *GetTimerDefinition(int timerId);
NAMESPACE_END()
#endif //OPENMW_TIMER_HPP

@ -2,10 +2,10 @@
#include <apps/openmw-mp/Networking.hpp>
#include <apps/openmw-mp/Player.hpp>
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
#include <apps/openmw-mp/Script/Callbacks.hpp>
#include <fstream>
#include "Worldstate.hpp"
#include "Worldstate.h"
using namespace std;
using namespace mwmp;
@ -13,157 +13,157 @@ using namespace mwmp;
BaseWorldstate *WorldstateFunctions::readWorldstate;
BaseWorldstate WorldstateFunctions::writeWorldstate;
void WorldstateFunctions::ReadReceivedWorldstate() noexcept
extern "C" void WorldstateFunctions::ReadReceivedWorldstate() noexcept
{
readWorldstate = mwmp::Networking::getPtr()->getReceivedWorldstate();
}
void WorldstateFunctions::CopyReceivedWorldstateToStore() noexcept
extern "C" void WorldstateFunctions::CopyReceivedWorldstateToStore() noexcept
{
writeWorldstate = *readWorldstate;
}
void WorldstateFunctions::ClearMapChanges() noexcept
extern "C" void WorldstateFunctions::ClearMapChanges() noexcept
{
writeWorldstate.mapTiles.clear();
}
unsigned int WorldstateFunctions::GetMapChangesSize() noexcept
extern "C" unsigned int WorldstateFunctions::GetMapChangesSize() noexcept
{
return readWorldstate->mapTiles.size();
}
const char *WorldstateFunctions::GetWeatherRegion() noexcept
extern "C" const char *WorldstateFunctions::GetWeatherRegion() noexcept
{
return readWorldstate->weather.region.c_str();
}
int WorldstateFunctions::GetWeatherCurrent() noexcept
extern "C" int WorldstateFunctions::GetWeatherCurrent() noexcept
{
return readWorldstate->weather.currentWeather;
}
int WorldstateFunctions::GetWeatherNext() noexcept
extern "C" int WorldstateFunctions::GetWeatherNext() noexcept
{
return readWorldstate->weather.nextWeather;
}
int WorldstateFunctions::GetWeatherQueued() noexcept
extern "C" int WorldstateFunctions::GetWeatherQueued() noexcept
{
return readWorldstate->weather.queuedWeather;
}
double WorldstateFunctions::GetWeatherTransitionFactor() noexcept
extern "C" double WorldstateFunctions::GetWeatherTransitionFactor() noexcept
{
return readWorldstate->weather.transitionFactor;
}
int WorldstateFunctions::GetMapTileCellX(unsigned int index) noexcept
extern "C" int WorldstateFunctions::GetMapTileCellX(unsigned int index) noexcept
{
return readWorldstate->mapTiles.at(index).x;
}
int WorldstateFunctions::GetMapTileCellY(unsigned int index) noexcept
extern "C" int WorldstateFunctions::GetMapTileCellY(unsigned int index) noexcept
{
return readWorldstate->mapTiles.at(index).y;
}
void WorldstateFunctions::SetAuthorityRegion(const char* authorityRegion) noexcept
extern "C" void WorldstateFunctions::SetAuthorityRegion(const char* authorityRegion) noexcept
{
writeWorldstate.authorityRegion = authorityRegion;
}
void WorldstateFunctions::SetWeatherRegion(const char* region) noexcept
extern "C" void WorldstateFunctions::SetWeatherRegion(const char* region) noexcept
{
writeWorldstate.weather.region = region;
}
void WorldstateFunctions::SetWeatherForceState(bool forceState) noexcept
extern "C" void WorldstateFunctions::SetWeatherForceState(bool forceState) noexcept
{
writeWorldstate.forceWeather = forceState;
}
void WorldstateFunctions::SetWeatherCurrent(int currentWeather) noexcept
extern "C" void WorldstateFunctions::SetWeatherCurrent(int currentWeather) noexcept
{
writeWorldstate.weather.currentWeather = currentWeather;
}
void WorldstateFunctions::SetWeatherNext(int nextWeather) noexcept
extern "C" void WorldstateFunctions::SetWeatherNext(int nextWeather) noexcept
{
writeWorldstate.weather.nextWeather = nextWeather;
}
void WorldstateFunctions::SetWeatherQueued(int queuedWeather) noexcept
extern "C" void WorldstateFunctions::SetWeatherQueued(int queuedWeather) noexcept
{
writeWorldstate.weather.queuedWeather = queuedWeather;
}
void WorldstateFunctions::SetWeatherTransitionFactor(double transitionFactor) noexcept
extern "C" void WorldstateFunctions::SetWeatherTransitionFactor(double transitionFactor) noexcept
{
writeWorldstate.weather.transitionFactor = transitionFactor;
}
void WorldstateFunctions::SetHour(double hour) noexcept
extern "C" void WorldstateFunctions::SetHour(double hour) noexcept
{
writeWorldstate.time.hour = hour;
}
void WorldstateFunctions::SetDay(int day) noexcept
extern "C" void WorldstateFunctions::SetDay(int day) noexcept
{
writeWorldstate.time.day = day;
}
void WorldstateFunctions::SetMonth(int month) noexcept
extern "C" void WorldstateFunctions::SetMonth(int month) noexcept
{
writeWorldstate.time.month = month;
}
void WorldstateFunctions::SetYear(int year) noexcept
extern "C" void WorldstateFunctions::SetYear(int year) noexcept
{
writeWorldstate.time.year = year;
}
void WorldstateFunctions::SetDaysPassed(int daysPassed) noexcept
extern "C" void WorldstateFunctions::SetDaysPassed(int daysPassed) noexcept
{
writeWorldstate.time.daysPassed = daysPassed;
}
void WorldstateFunctions::SetTimeScale(double timeScale) noexcept
extern "C" void WorldstateFunctions::SetTimeScale(double timeScale) noexcept
{
writeWorldstate.time.timeScale = timeScale;
}
void WorldstateFunctions::SetPlayerCollisionState(bool state) noexcept
extern "C" void WorldstateFunctions::SetPlayerCollisionState(bool state) noexcept
{
writeWorldstate.hasPlayerCollision = state;
}
void WorldstateFunctions::SetActorCollisionState(bool state) noexcept
extern "C" void WorldstateFunctions::SetActorCollisionState(bool state) noexcept
{
writeWorldstate.hasActorCollision = state;
}
void WorldstateFunctions::SetPlacedObjectCollisionState(bool state) noexcept
extern "C" void WorldstateFunctions::SetPlacedObjectCollisionState(bool state) noexcept
{
writeWorldstate.hasPlacedObjectCollision = state;
}
void WorldstateFunctions::UseActorCollisionForPlacedObjects(bool useActorCollision) noexcept
extern "C" void WorldstateFunctions::UseActorCollisionForPlacedObjects(bool useActorCollision) noexcept
{
writeWorldstate.useActorCollisionForPlacedObjects = useActorCollision;
}
void WorldstateFunctions::AddEnforcedCollisionRefId(const char *refId) noexcept
extern "C" void WorldstateFunctions::AddEnforcedCollisionRefId(const char *refId) noexcept
{
writeWorldstate.enforcedCollisionRefIds.push_back(refId);
}
void WorldstateFunctions::ClearEnforcedCollisionRefIds() noexcept
extern "C" void WorldstateFunctions::ClearEnforcedCollisionRefIds() noexcept
{
writeWorldstate.enforcedCollisionRefIds.clear();
}
void WorldstateFunctions::SaveMapTileImageFile(unsigned int index, const char *filePath) noexcept
extern "C" void WorldstateFunctions::SaveMapTileImageFile(unsigned int index, const char *filePath) noexcept
{
if (index >= readWorldstate->mapTiles.size())
return;
@ -175,7 +175,7 @@ void WorldstateFunctions::SaveMapTileImageFile(unsigned int index, const char *f
std::copy(imageData.begin(), imageData.end(), outputIterator);
}
void WorldstateFunctions::LoadMapTileImageFile(int cellX, int cellY, const char* filePath) noexcept
extern "C" void WorldstateFunctions::LoadMapTileImageFile(int cellX, int cellY, const char* filePath) noexcept
{
mwmp::MapTile mapTile;
mapTile.x = cellX;
@ -196,7 +196,7 @@ void WorldstateFunctions::LoadMapTileImageFile(int cellX, int cellY, const char*
}
}
void WorldstateFunctions::SendWorldMap(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
extern "C" void WorldstateFunctions::SendWorldMap(PlayerId pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -212,7 +212,7 @@ void WorldstateFunctions::SendWorldMap(unsigned short pid, bool sendToOtherPlaye
packet->Send(true);
}
void WorldstateFunctions::SendWorldTime(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
extern "C" void WorldstateFunctions::SendWorldTime(PlayerId pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -228,7 +228,7 @@ void WorldstateFunctions::SendWorldTime(unsigned short pid, bool sendToOtherPlay
packet->Send(true);
}
void WorldstateFunctions::SendWorldWeather(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
extern "C" void WorldstateFunctions::SendWorldWeather(PlayerId pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -244,7 +244,7 @@ void WorldstateFunctions::SendWorldWeather(unsigned short pid, bool sendToOtherP
packet->Send(true);
}
void WorldstateFunctions::SendWorldCollisionOverride(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
extern "C" void WorldstateFunctions::SendWorldCollisionOverride(PlayerId pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -260,7 +260,7 @@ void WorldstateFunctions::SendWorldCollisionOverride(unsigned short pid, bool se
packet->Send(true);
}
void WorldstateFunctions::SendWorldRegionAuthority(unsigned short pid) noexcept
extern "C" void WorldstateFunctions::SendWorldRegionAuthority(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -276,7 +276,7 @@ void WorldstateFunctions::SendWorldRegionAuthority(unsigned short pid) noexcept
packet->Send(true);
}
extern "C"
// All methods below are deprecated versions of methods from above
void WorldstateFunctions::ReadLastWorldstate() noexcept
@ -284,7 +284,7 @@ void WorldstateFunctions::ReadLastWorldstate() noexcept
ReadReceivedWorldstate();
}
void WorldstateFunctions::CopyLastWorldstateToStore() noexcept
extern "C" void WorldstateFunctions::CopyLastWorldstateToStore() noexcept
{
CopyReceivedWorldstateToStore();
}

@ -1,76 +1,22 @@
#ifndef OPENMW_WORLDSTATEAPI_HPP
#define OPENMW_WORLDSTATEAPI_HPP
#ifdef _HOST
#include <components/openmw-mp/Base/BaseWorldstate.hpp>
#include "../Types.hpp"
#define WORLDSTATEAPI \
{"ReadReceivedWorldstate", WorldstateFunctions::ReadReceivedWorldstate},\
\
{"CopyReceivedWorldstateToStore", WorldstateFunctions::CopyReceivedWorldstateToStore},\
\
{"ClearMapChanges", WorldstateFunctions::ClearMapChanges},\
\
{"GetMapChangesSize", WorldstateFunctions::GetMapChangesSize},\
\
{"GetWeatherRegion", WorldstateFunctions::GetWeatherRegion},\
{"GetWeatherCurrent", WorldstateFunctions::GetWeatherCurrent},\
{"GetWeatherNext", WorldstateFunctions::GetWeatherNext},\
{"GetWeatherQueued", WorldstateFunctions::GetWeatherQueued},\
{"GetWeatherTransitionFactor", WorldstateFunctions::GetWeatherTransitionFactor},\
\
{"GetMapTileCellX", WorldstateFunctions::GetMapTileCellX},\
{"GetMapTileCellY", WorldstateFunctions::GetMapTileCellY},\
\
{"SetAuthorityRegion", WorldstateFunctions::SetAuthorityRegion},\
\
{"SetWeatherRegion", WorldstateFunctions::SetWeatherRegion},\
{"SetWeatherForceState", WorldstateFunctions::SetWeatherForceState},\
{"SetWeatherCurrent", WorldstateFunctions::SetWeatherCurrent},\
{"SetWeatherNext", WorldstateFunctions::SetWeatherNext},\
{"SetWeatherQueued", WorldstateFunctions::SetWeatherQueued},\
{"SetWeatherTransitionFactor", WorldstateFunctions::SetWeatherTransitionFactor},\
\
{"SetHour", WorldstateFunctions::SetHour},\
{"SetDay", WorldstateFunctions::SetDay},\
{"SetMonth", WorldstateFunctions::SetMonth},\
{"SetYear", WorldstateFunctions::SetYear},\
{"SetDaysPassed", WorldstateFunctions::SetDaysPassed},\
{"SetTimeScale", WorldstateFunctions::SetTimeScale},\
\
{"SetPlayerCollisionState", WorldstateFunctions::SetPlayerCollisionState},\
{"SetActorCollisionState", WorldstateFunctions::SetActorCollisionState},\
{"SetPlacedObjectCollisionState", WorldstateFunctions::SetPlacedObjectCollisionState},\
{"UseActorCollisionForPlacedObjects", WorldstateFunctions::UseActorCollisionForPlacedObjects},\
\
{"AddEnforcedCollisionRefId", WorldstateFunctions::AddEnforcedCollisionRefId},\
{"ClearEnforcedCollisionRefIds", WorldstateFunctions::ClearEnforcedCollisionRefIds},\
\
{"SaveMapTileImageFile", WorldstateFunctions::SaveMapTileImageFile},\
{"LoadMapTileImageFile", WorldstateFunctions::LoadMapTileImageFile},\
\
{"SendWorldMap", WorldstateFunctions::SendWorldMap},\
{"SendWorldTime", WorldstateFunctions::SendWorldTime},\
{"SendWorldWeather", WorldstateFunctions::SendWorldWeather},\
{"SendWorldCollisionOverride", WorldstateFunctions::SendWorldCollisionOverride},\
{"SendWorldRegionAuthority", WorldstateFunctions::SendWorldRegionAuthority},\
\
{"ReadLastWorldstate", WorldstateFunctions::ReadLastWorldstate},\
{"CopyLastWorldstateToStore", WorldstateFunctions::CopyLastWorldstateToStore}
class WorldstateFunctions
{
public:
static mwmp::BaseWorldstate *readWorldstate;
static mwmp::BaseWorldstate writeWorldstate;
#endif
#include "../api.h"
NAMESPACE_BEGIN(WorldstateFunctions)
#ifdef _HOST
API_FUNCTION mwmp::BaseWorldstate CDECL *readWorldstate;
API_FUNCTION mwmp::BaseWorldstate CDECL writeWorldstate;
#endif
/**
* \brief Use the last worldstate received by the server as the one being read.
*
* \return void
*/
static void ReadReceivedWorldstate() noexcept;
API_FUNCTION void CDECL ReadReceivedWorldstate() NOEXCEPT;
/**
* \brief Take the contents of the read-only worldstate last received by the
@ -79,7 +25,7 @@ public:
*
* \return void
*/
static void CopyReceivedWorldstateToStore() noexcept;
API_FUNCTION void CDECL CopyReceivedWorldstateToStore() NOEXCEPT;
/**
* \brief Clear the map changes for the write-only worldstate.
@ -88,49 +34,49 @@ public:
*
* \return void
*/
static void ClearMapChanges() noexcept;
API_FUNCTION void CDECL ClearMapChanges() NOEXCEPT;
/**
* \brief Get the number of indexes in the read worldstate's map changes.
*
* \return The number of indexes.
*/
static unsigned int GetMapChangesSize() noexcept;
API_FUNCTION unsigned int CDECL GetMapChangesSize() NOEXCEPT;
/**
* \brief Get the weather region in the read worldstate.
*
* \return The weather region.
*/
static const char *GetWeatherRegion() noexcept;
API_FUNCTION const char *CDECL GetWeatherRegion() NOEXCEPT;
/**
* \brief Get the current weather in the read worldstate.
*
* \return The current weather.
*/
static int GetWeatherCurrent() noexcept;
API_FUNCTION int CDECL GetWeatherCurrent() NOEXCEPT;
/**
* \brief Get the next weather in the read worldstate.
*
* \return The next weather.
*/
static int GetWeatherNext() noexcept;
API_FUNCTION int CDECL GetWeatherNext() NOEXCEPT;
/**
* \brief Get the queued weather in the read worldstate.
*
* \return The queued weather.
*/
static int GetWeatherQueued() noexcept;
API_FUNCTION int CDECL GetWeatherQueued() NOEXCEPT;
/**
* \brief Get the transition factor of the weather in the read worldstate.
*
* \return The transition factor of the weather.
*/
static double GetWeatherTransitionFactor() noexcept;
API_FUNCTION double CDECL GetWeatherTransitionFactor() NOEXCEPT;
/**
* \brief Get the X coordinate of the cell corresponding to the map tile at a certain index in
@ -139,7 +85,7 @@ public:
* \param index The index of the map tile.
* \return The X coordinate of the cell.
*/
static int GetMapTileCellX(unsigned int index) noexcept;
API_FUNCTION int CDECL GetMapTileCellX(unsigned int index) NOEXCEPT;
/**
* \brief Get the Y coordinate of the cell corresponding to the map tile at a certain index in
@ -148,7 +94,7 @@ public:
* \param index The index of the map tile.
* \return The Y coordinate of the cell.
*/
static int GetMapTileCellY(unsigned int index) noexcept;
API_FUNCTION int CDECL GetMapTileCellY(unsigned int index) NOEXCEPT;
/**
* \brief Set the region affected by the next WorldRegionAuthority packet sent.
@ -156,7 +102,7 @@ public:
* \param region The region.
* \return void
*/
static void SetAuthorityRegion(const char* authorityRegion) noexcept;
API_FUNCTION void CDECL SetAuthorityRegion(const char* authorityRegion) NOEXCEPT;
/**
* \brief Set the weather region in the write-only worldstate stored on the server.
@ -164,7 +110,7 @@ public:
* \param region The region.
* \return void
*/
static void SetWeatherRegion(const char* region) noexcept;
API_FUNCTION void CDECL SetWeatherRegion(const char* region) NOEXCEPT;
/**
* \brief Set the weather forcing state in the write-only worldstate stored on the server.
@ -174,7 +120,7 @@ public:
* \param forceState The weather forcing state.
* \return void
*/
static void SetWeatherForceState(bool forceState) noexcept;
API_FUNCTION void CDECL SetWeatherForceState(bool forceState) NOEXCEPT;
/**
* \brief Set the current weather in the write-only worldstate stored on the server.
@ -182,7 +128,7 @@ public:
* \param currentWeather The current weather.
* \return void
*/
static void SetWeatherCurrent(int currentWeather) noexcept;
API_FUNCTION void CDECL SetWeatherCurrent(int currentWeather) NOEXCEPT;
/**
* \brief Set the next weather in the write-only worldstate stored on the server.
@ -190,7 +136,7 @@ public:
* \param nextWeather The next weather.
* \return void
*/
static void SetWeatherNext(int nextWeather) noexcept;
API_FUNCTION void CDECL SetWeatherNext(int nextWeather) NOEXCEPT;
/**
* \brief Set the queued weather in the write-only worldstate stored on the server.
@ -198,7 +144,7 @@ public:
* \param queuedWeather The queued weather.
* \return void
*/
static void SetWeatherQueued(int queuedWeather) noexcept;
API_FUNCTION void CDECL SetWeatherQueued(int queuedWeather) NOEXCEPT;
/**
* \brief Set the transition factor for the weather in the write-only worldstate stored on the server.
@ -206,7 +152,7 @@ public:
* \param transitionFactor The transition factor.
* \return void
*/
static void SetWeatherTransitionFactor(double transitionFactor) noexcept;
API_FUNCTION void CDECL SetWeatherTransitionFactor(double transitionFactor) NOEXCEPT;
/**
* \brief Set the world's hour in the write-only worldstate stored on the server.
@ -214,7 +160,7 @@ public:
* \param hour The hour.
* \return void
*/
static void SetHour(double hour) noexcept;
API_FUNCTION void CDECL SetHour(double hour) NOEXCEPT;
/**
* \brief Set the world's day in the write-only worldstate stored on the server.
@ -222,7 +168,7 @@ public:
* \param day The day.
* \return void
*/
static void SetDay(int day) noexcept;
API_FUNCTION void CDECL SetDay(int day) NOEXCEPT;
/**
* \brief Set the world's month in the write-only worldstate stored on the server.
@ -230,7 +176,7 @@ public:
* \param month The month.
* \return void
*/
static void SetMonth(int month) noexcept;
API_FUNCTION void CDECL SetMonth(int month) NOEXCEPT;
/**
* \brief Set the world's year in the write-only worldstate stored on the server.
@ -238,7 +184,7 @@ public:
* \param year The year.
* \return void
*/
static void SetYear(int year) noexcept;
API_FUNCTION void CDECL SetYear(int year) NOEXCEPT;
/**
* \brief Set the world's days passed in the write-only worldstate stored on the server.
@ -246,7 +192,7 @@ public:
* \param daysPassed The days passed.
* \return void
*/
static void SetDaysPassed(int daysPassed) noexcept;
API_FUNCTION void CDECL SetDaysPassed(int daysPassed) NOEXCEPT;
/**
* \brief Set the world's time scale in the write-only worldstate stored on the server.
@ -255,7 +201,7 @@ public:
* \param timeScale The time scale.
* \return void
*/
static void SetTimeScale(double timeScale) noexcept;
API_FUNCTION void CDECL SetTimeScale(double timeScale) NOEXCEPT;
/**
* \brief Set the collision state for other players in the write-only worldstate stored
@ -264,7 +210,7 @@ public:
* \param state The collision state.
* \return void
*/
static void SetPlayerCollisionState(bool state) noexcept;
API_FUNCTION void CDECL SetPlayerCollisionState(bool state) NOEXCEPT;
/**
* \brief Set the collision state for actors in the write-only worldstate stored on the
@ -273,7 +219,7 @@ public:
* \param state The collision state.
* \return void
*/
static void SetActorCollisionState(bool state) noexcept;
API_FUNCTION void CDECL SetActorCollisionState(bool state) NOEXCEPT;
/**
* \brief Set the collision state for placed objects in the write-only worldstate stored
@ -282,7 +228,7 @@ public:
* \param state The collision state.
* \return void
*/
static void SetPlacedObjectCollisionState(bool state) noexcept;
API_FUNCTION void CDECL SetPlacedObjectCollisionState(bool state) NOEXCEPT;
/**
* \brief Whether placed objects with collision turned on should use actor collision, i.e.
@ -291,7 +237,7 @@ public:
* \param useActorCollision Whether to use actor collision.
* \return void
*/
static void UseActorCollisionForPlacedObjects(bool useActorCollision) noexcept;
API_FUNCTION void CDECL UseActorCollisionForPlacedObjects(bool useActorCollision) NOEXCEPT;
/**
* \brief Add a refId to the list of refIds for which collision should be enforced
@ -300,7 +246,7 @@ public:
* \param refId The refId.
* \return void
*/
static void AddEnforcedCollisionRefId(const char* refId) noexcept;
API_FUNCTION void CDECL AddEnforcedCollisionRefId(const char* refId) NOEXCEPT;
/**
* \brief Clear the list of refIdsd for which collision should be enforced irrespective
@ -308,7 +254,7 @@ public:
*
* \return void
*/
static void ClearEnforcedCollisionRefIds() noexcept;
API_FUNCTION void CDECL ClearEnforcedCollisionRefIds() NOEXCEPT;
/**
* \brief Save the .png image data of the map tile at a certain index in the read worldstate's
@ -318,7 +264,7 @@ public:
* \param filePath The file path of the resulting file.
* \return void
*/
static void SaveMapTileImageFile(unsigned int index, const char *filePath) noexcept;
API_FUNCTION void CDECL SaveMapTileImageFile(unsigned int index, const char *filePath) NOEXCEPT;
/**
* \brief Load a .png file as the image data for a map tile and add it to the write-only worldstate
@ -329,7 +275,7 @@ public:
* \param filePath The file path of the loaded file.
* \return void
*/
static void LoadMapTileImageFile(int cellX, int cellY, const char* filePath) noexcept;
API_FUNCTION void CDECL LoadMapTileImageFile(int cellX, int cellY, const char* filePath) NOEXCEPT;
/**
* \brief Send a WorldRegionAuthority packet establishing a certain player as the only one who
@ -340,7 +286,7 @@ public:
* \param pid The player ID attached to the packet.
* \return void
*/
static void SendWorldRegionAuthority(unsigned short pid) noexcept;
API_FUNCTION void CDECL SendWorldRegionAuthority(PlayerId pid) NOEXCEPT;
/**
* \brief Send a WorldMap packet with the current set of map changes in the write-only
@ -351,7 +297,7 @@ public:
* or to all players on the server.
* \return void
*/
static void SendWorldMap(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendWorldMap(PlayerId pid, bool sendToOtherPlayers, bool skipAttachedPlayer) NOEXCEPT;
/**
* \brief Send a WorldTime packet with the current time and time scale in the write-only
@ -364,7 +310,7 @@ public:
* to the packet (false by default).
* \return void
*/
static void SendWorldTime(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendWorldTime(PlayerId pid, bool sendToOtherPlayers, bool skipAttachedPlayer) NOEXCEPT;
/**
* \brief Send a WorldWeather packet with the current weather in the write-only worldstate.
@ -376,7 +322,7 @@ public:
* to the packet (false by default).
* \return void
*/
static void SendWorldWeather(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendWorldWeather(PlayerId pid, bool sendToOtherPlayers, bool skipAttachedPlayer) NOEXCEPT;
/**
* \brief Send a WorldCollisionOverride packet with the current collision overrides in
@ -389,14 +335,13 @@ public:
* to the packet (false by default).
* \return void
*/
static void SendWorldCollisionOverride(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendWorldCollisionOverride(PlayerId pid, bool sendToOtherPlayers, bool skipAttachedPlayer) NOEXCEPT;
// All methods below are deprecated versions of methods from above
static void ReadLastWorldstate() noexcept;
static void CopyLastWorldstateToStore() noexcept;
};
API_FUNCTION void CDECL ReadLastWorldstate() NOEXCEPT;
API_FUNCTION void CDECL CopyLastWorldstateToStore() NOEXCEPT;
NAMESPACE_END()
#endif //OPENMW_WORLDSTATEAPI_HPP

@ -1,323 +0,0 @@
//
// Created by koncord on 08.05.16.
//
#include <iostream>
#include "LangLua.hpp"
#include <Script/Script.hpp>
#include <Script/Types.hpp>
using namespace std;
std::set<std::string> LangLua::packagePath;
std::set<std::string> LangLua::packageCPath;
void setLuaPath(lua_State* L, const char* path, bool cpath = false)
{
string field = cpath ? "cpath" : "path";
lua_getglobal(L, "package");
lua_getfield(L, -1, field.c_str());
std::string cur_path = lua_tostring(L, -1);
cur_path.append(";");
cur_path.append(path);
lua_pop(L, 1);
lua_pushstring(L, cur_path.c_str());
lua_setfield(L, -2, field.c_str());
lua_pop(L, 1);
}
lib_t LangLua::GetInterface()
{
return reinterpret_cast<lib_t>(lua);
}
LangLua::LangLua(lua_State *lua)
{
this->lua = lua;
}
LangLua::LangLua()
{
lua = luaL_newstate();
luaL_openlibs(lua); // load all lua std libs
std::string p, cp;
for (auto& path : packagePath)
p += path + ';';
for (auto& path : packageCPath)
cp += path + ';';
setLuaPath(lua, p.c_str());
setLuaPath(lua, cp.c_str(), true);
}
LangLua::~LangLua()
{
}
template<unsigned int I, unsigned int F>
struct Lua_dispatch_ {
template<typename R, typename... Args>
inline static R Lua_dispatch(lua_State*&& lua, Args&&... args) noexcept {
constexpr ScriptFunctionData const& F_ = ScriptFunctions::functions[F];
auto arg = luabridge::Stack<typename CharType<F_.func.types[I - 1]>::type>::get(lua, I);
return Lua_dispatch_<I - 1, F>::template Lua_dispatch<R>(
forward<lua_State*>(lua),
arg,
forward<Args>(args)...);
}
};
template<unsigned int F>
struct Lua_dispatch_<0, F> {
template<typename R, typename... Args>
inline static R Lua_dispatch(lua_State*&&, Args&&... args) noexcept {
constexpr ScriptFunctionData const& F_ = ScriptFunctions::functions[F];
return reinterpret_cast<FunctionEllipsis<R>>(F_.func.addr)(forward<Args>(args)...);
}
};
template<unsigned int I>
static typename enable_if<ScriptFunctions::functions[I].func.ret == 'v', int>::type wrapper(lua_State* lua) noexcept {
Lua_dispatch_<ScriptFunctions::functions[I].func.numargs, I>::template Lua_dispatch<void>(forward<lua_State*>(lua));
return 0;
}
template<unsigned int I>
static typename enable_if<ScriptFunctions::functions[I].func.ret != 'v', int>::type wrapper(lua_State* lua) noexcept {
auto ret = Lua_dispatch_<ScriptFunctions::functions[I].func.numargs, I>::template Lua_dispatch<
typename CharType<ScriptFunctions::functions[I].func.ret>::type>(forward<lua_State*>(lua));
luabridge::Stack <typename CharType<ScriptFunctions::functions[I].func.ret>::type>::push (lua, ret);
return 1;
}
template<unsigned int I>
struct F_
{
static constexpr LuaFuctionData F{ScriptFunctions::functions[I].name, wrapper<I>};
};
template<> struct F_<0> { static constexpr LuaFuctionData F{"CreateTimer", LangLua::CreateTimer}; };
template<> struct F_<1> { static constexpr LuaFuctionData F{"CreateTimerEx", LangLua::CreateTimerEx}; };
template<> struct F_<2> { static constexpr LuaFuctionData F{"MakePublic", LangLua::MakePublic}; };
template<> struct F_<3> { static constexpr LuaFuctionData F{"CallPublic", LangLua::CallPublic}; };
#ifdef __arm__
template<std::size_t... Is>
struct indices {};
template<std::size_t N, std::size_t... Is>
struct build_indices : build_indices<N-1, N-1, Is...> {};
template<std::size_t... Is>
struct build_indices<0, Is...> : indices<Is...> {};
template<std::size_t N>
using IndicesFor = build_indices<N>;
template<size_t... Indices>
LuaFuctionData *functions(indices<Indices...>)
{
static LuaFuctionData functions_[sizeof...(Indices)]{
F_<Indices>::F...
};
static_assert(
sizeof(functions_) / sizeof(functions_[0]) ==
sizeof(ScriptFunctions::functions) / sizeof(ScriptFunctions::functions[0]),
"Not all functions have been mapped to Lua");
return functions_;
}
#else
template<unsigned int I>
struct C
{
constexpr static void Fn(LuaFuctionData *functions_)
{
functions_[I] = F_<I>::F;
C<I - 1>::Fn(functions_);
}
};
template<>
struct C<0>
{
constexpr static void Fn(LuaFuctionData *functions_)
{
functions_[0] = F_<0>::F;
}
};
template<size_t LastI>
LuaFuctionData *functions()
{
static LuaFuctionData functions_[LastI];
C<LastI - 1>::Fn(functions_);
static_assert(
sizeof(functions_) / sizeof(functions_[0]) ==
sizeof(ScriptFunctions::functions) / sizeof(ScriptFunctions::functions[0]),
"Not all functions have been mapped to Lua");
return functions_;
}
#endif
void LangLua::LoadProgram(const char *filename)
{
int err = 0;
if ((err =luaL_loadfile(lua, filename)) != 0)
throw runtime_error("Lua script " + string(filename) + " error (" + to_string(err) + "): \"" +
string(lua_tostring(lua, -1)) + "\"");
constexpr auto functions_n = sizeof(ScriptFunctions::functions) / sizeof(ScriptFunctions::functions[0]);
#if __arm__
LuaFuctionData *functions_ = functions(IndicesFor<functions_n>{});
#else
LuaFuctionData *functions_ = functions<sizeof(ScriptFunctions::functions) / sizeof(ScriptFunctions::functions[0])>();
#endif
luabridge::Namespace tes3mp = luabridge::getGlobalNamespace(lua).beginNamespace("tes3mp");
for (unsigned i = 0; i < functions_n; i++)
tes3mp.addCFunction(functions_[i].name, functions_[i].func);
tes3mp.endNamespace();
if ((err = lua_pcall(lua, 0, 0, 0)) != 0) // Run once script for load in memory.
throw runtime_error("Lua script " + string(filename) + " error (" + to_string(err) + "): \"" +
string(lua_tostring(lua, -1)) + "\"");
}
int LangLua::FreeProgram()
{
lua_close(lua);
return 0;
}
bool LangLua::IsCallbackPresent(const char *name)
{
return luabridge::getGlobal(lua, name).isFunction();
}
boost::any LangLua::Call(const char *name, const char *argl, int buf, ...)
{
va_list vargs;
va_start(vargs, buf);
int n_args = (int)(strlen(argl));
lua_getglobal(lua, name);
for (int index = 0; index < n_args; index++)
{
switch (argl[index])
{
case 'i':
luabridge::Stack<unsigned int>::push(lua,va_arg(vargs, unsigned int));
break;
case 'q':
luabridge::Stack<signed int>::push(lua,va_arg(vargs, signed int));
break;
case 'l':
luabridge::Stack<unsigned long long>::push(lua, va_arg(vargs, unsigned long long));
break;
case 'w':
luabridge::Stack<signed long long>::push(lua, va_arg(vargs, signed long long));
break;
case 'f':
luabridge::Stack<double>::push(lua, va_arg(vargs, double));
break;
case 'p':
luabridge::Stack<void*>::push(lua, va_arg(vargs, void*));
break;
case 's':
luabridge::Stack<const char*>::push(lua, va_arg(vargs, const char*));
break;
case 'b':
luabridge::Stack<bool>::push(lua, (bool) va_arg(vargs, int));
break;
default:
throw runtime_error("C++ call: Unknown argument identifier " + argl[index]);
}
}
va_end(vargs);
luabridge::LuaException::pcall(lua, n_args, 1);
return boost::any(luabridge::LuaRef::fromStack(lua, -1));
}
boost::any LangLua::Call(const char *name, const char *argl, const std::vector<boost::any> &args)
{
int n_args = (int)(strlen(argl));
lua_getglobal(lua, name);
for (int index = 0; index < n_args; index++)
{
switch (argl[index])
{
case 'i':
luabridge::Stack<unsigned int>::push(lua, boost::any_cast<unsigned int>(args.at(index)));
break;
case 'q':
luabridge::Stack<signed int>::push(lua, boost::any_cast<signed int>(args.at(index)));
break;
case 'l':
luabridge::Stack<unsigned long long>::push(lua, boost::any_cast<unsigned long long>(args.at(index)));
break;
case 'w':
luabridge::Stack<signed long long>::push(lua, boost::any_cast<signed long long>(args.at(index)));
break;
case 'f':
luabridge::Stack<double>::push(lua, boost::any_cast<double>(args.at(index)));
break;
case 'p':
luabridge::Stack<void *>::push(lua, boost::any_cast<void *>(args.at(index)));
break;
case 's':
luabridge::Stack<const char *>::push(lua, boost::any_cast<const char *>(args.at(index)));
break;
case 'b':
luabridge::Stack<bool>::push(lua, boost::any_cast<int>(args.at(index)));
break;
default:
throw runtime_error("Lua call: Unknown argument identifier " + argl[index]);
}
}
luabridge::LuaException::pcall(lua, n_args, 1);
return boost::any(luabridge::LuaRef::fromStack(lua, -1));
}
void LangLua::AddPackagePath(const std::string& path)
{
packagePath.emplace(path);
}
void LangLua::AddPackageCPath(const std::string& path)
{
packageCPath.emplace(path);
}

@ -1,54 +0,0 @@
//
// Created by koncord on 08.05.16.
//
#ifndef PLUGINSYSTEM3_LANGLUA_HPP
#define PLUGINSYSTEM3_LANGLUA_HPP
#include "lua.hpp"
#include <extern/LuaBridge/LuaBridge.h>
#include <LuaBridge.h>
#include <set>
#include <boost/any.hpp>
#include "../ScriptFunction.hpp"
#include "../Language.hpp"
struct LuaFuctionData
{
const char* name;
lua_CFunction func;
};
class LangLua: public Language
{
public:
virtual lib_t GetInterface() override;
lua_State *lua;
public:
LangLua();
LangLua(lua_State *lua);
~LangLua();
static void AddPackagePath(const std::string &path);
static void AddPackageCPath(const std::string &path);
static int MakePublic(lua_State *lua) noexcept;
static int CallPublic(lua_State *lua);
static int CreateTimer(lua_State *lua) noexcept;
static int CreateTimerEx(lua_State *lua);
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<boost::any> &args) override;
private:
static std::set<std::string> packageCPath;
static std::set<std::string> packagePath;
};
#endif //PLUGINSYSTEM3_LANGLUA_HPP

@ -1,182 +0,0 @@
//
// Created by koncord on 09.05.16.
//
#include <iostream>
#include "LangLua.hpp"
#include <Script/API/TimerAPI.hpp>
#include <Script/API/PublicFnAPI.hpp>
using namespace std;
inline vector<boost::any> DefToVec(lua_State *lua, string types, int args_begin, int args_n)
{
vector<boost::any> args;
for (int i = args_begin; i < args_n + args_begin; i++)
{
switch (types[i - args_begin])
{
case 'i':
{
args.emplace_back(luabridge::Stack<unsigned int>::get(lua, i));
break;
}
case 'q':
{
args.emplace_back(luabridge::Stack<signed int>::get(lua, i));
break;
}
/*case 'l':
{
args.emplace_back(luabridge::Stack<unsigned long long>::get(lua, i));
break;
}
case 'w':
{
args.emplace_back(luabridge::Stack<signed long long>::get(lua, i));
break;
}*/
case 'f':
{
args.emplace_back(luabridge::Stack<double>::get(lua, i));
break;
}
case 's':
{
args.emplace_back(luabridge::Stack<const char*>::get(lua, i));
break;
}
default:
{
stringstream ssErr;
ssErr << "Lua: Unknown argument identifier" << "\"" << types[i] << "\"" << endl;
throw std::runtime_error(ssErr.str());
}
}
}
return args;
}
int LangLua::MakePublic(lua_State *lua) noexcept
{
const char * callback = luabridge::Stack<const char*>::get(lua, 1);
const char * name = luabridge::Stack<const char*>::get(lua, 2);
char ret_type = luabridge::Stack<char>::get(lua, 3);
const char * def = luabridge::Stack<const char*>::get(lua, 4);
Public::MakePublic(callback, lua, name, ret_type, def);
return 0;
}
int LangLua::CallPublic(lua_State *lua)
{
const char * name = luabridge::Stack<const char*>::get(lua, 1);
int args_n = lua_gettop(lua) - 1;
string types = Public::GetDefinition(name);
if (args_n != (long)types.size())
throw invalid_argument("Script call: Number of arguments does not match definition");
vector<boost::any> args = DefToVec(lua, types, 2, args_n);
boost::any result = Public::Call(&name[0], args);
if (result.empty())
return 0;
if (result.type().hash_code() == typeid(signed int).hash_code())
luabridge::Stack<signed int>::push(lua, boost::any_cast<signed int>(result));
else if (result.type().hash_code() == typeid(unsigned int).hash_code())
luabridge::Stack<unsigned int>::push(lua, boost::any_cast<unsigned int>(result));
else if (result.type().hash_code() == typeid(double).hash_code())
luabridge::Stack<double>::push(lua, boost::any_cast<double>(result));
else if (result.type().hash_code() == typeid(const char*).hash_code())
luabridge::Stack<const char*>::push(lua, boost::any_cast<const char*>(result));
return 1;
}
int LangLua::CreateTimer(lua_State *lua) noexcept
{
const char * callback= luabridge::Stack<const char*>::get(lua, 1);
int msec = luabridge::Stack<int>::get(lua, 2);
int id = mwmp::TimerAPI::CreateTimerLua(lua, callback, msec, "", vector<boost::any>());
luabridge::push(lua, id);
return 1;
}
int LangLua::CreateTimerEx(lua_State *lua)
{
const char * callback = luabridge::Stack<const char*>::get(lua, 1);
int msec = luabridge::Stack<int>::get(lua, 2);
const char * types = luabridge::Stack<const char*>::get(lua, 3);
int args_n = (int)lua_strlen(lua, 3);
vector<boost::any> args;
for (int i = 4; i < args_n + 4; i++)
{
switch (types[i - 4])
{
case 'i':
{
args.emplace_back(luabridge::Stack<unsigned int>::get(lua, i));
break;
}
case 'q':
{
args.emplace_back(luabridge::Stack<signed int>::get(lua, i));
break;
}
/*case 'l':
{
args.emplace_back(luabridge::Stack<unsigned long long>::get(lua, i));
break;
}
case 'w':
{
args.emplace_back(luabridge::Stack<signed long long>::get(lua, i));
break;
}*/
case 'f':
{
args.emplace_back(luabridge::Stack<double>::get(lua, i));
break;
}
case 's':
{
args.emplace_back(luabridge::Stack<const char*>::get(lua, i));
break;
}
default:
{
stringstream ssErr;
ssErr << "Lua: Unknown argument identifier" << "\"" << types[i] << "\"" << endl;
throw std::runtime_error(ssErr.str());
}
}
}
int id = mwmp::TimerAPI::CreateTimerLua(lua, callback, msec, types, args);
luabridge::push(lua, id);
return 1;
}

@ -1,102 +0,0 @@
//
// Created by koncord on 09.05.16.
//
#ifndef _WIN32
#include <dlfcn.h>
#endif
#include <stdexcept>
#include "LangNative.hpp"
#include <Script/SystemInterface.hpp>
#include <Script/Script.hpp>
using namespace std;
template<typename R>
bool SetScript(lib_t lib, const char *name, R value)
{
SystemInterface<R *> result(lib, name);
if (result)
*result.result = value;
return result.operator bool();
}
void LangNative::LoadProgram(const char *filename)
{
FILE *file = fopen(filename, "rb");
if (!file)
throw runtime_error("Script not found: " + string(filename));
fclose(file);
#ifdef _WIN32
lib = LoadLibrary(filename);
#else
lib = dlopen(filename, RTLD_LAZY);
#endif
if (!lib)
throw runtime_error("Was not able to load C++ script: " + string(filename));
try
{
const char *prefix = SystemInterface<const char *>(lib, "prefix").result;
string pf(prefix);
for (const auto &function : ScriptFunctions::functions)
if (!SetScript(lib, string(pf + function.name).c_str(), function.func.addr))
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Script function pointer not found: %s", function.name);
}
catch (...)
{
FreeProgram();
throw;
}
}
int LangNative::FreeProgram()
{
#ifdef _WIN32
FreeLibrary(lib);
#else
dlclose(lib);
#endif
return 0;
}
bool LangNative::IsCallbackPresent(const char *name)
{
return true;
}
boost::any LangNative::Call(const char *name, const char *argl, int buf, ...)
{
return nullptr;
}
boost::any LangNative::Call(const char *name, const char *argl, const std::vector<boost::any> &args)
{
return nullptr;
}
lib_t LangNative::GetInterface()
{
return lib;
}
LangNative::LangNative()
{
}
LangNative::~LangNative()
{
}

@ -1,28 +0,0 @@
//
// Created by koncord on 09.05.16.
//
#ifndef PLUGINSYSTEM3_LANGNATIVE_HPP
#define PLUGINSYSTEM3_LANGNATIVE_HPP
#include <Script/Language.hpp>
#include <Script/SystemInterface.hpp>
class LangNative : public Language
{
lib_t lib;
public:
virtual lib_t GetInterface() override;
LangNative();
~LangNative();
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<boost::any> &args) override;
};
#endif //PLUGINSYSTEM3_LANGNATIVE_HPP

@ -1,28 +0,0 @@
//
// Created by koncord on 19.03.16.
//
#ifndef PLUGINSYSTEM3_LANGUAGE_HPP
#define PLUGINSYSTEM3_LANGUAGE_HPP
#include "Types.hpp"
#include <boost/any.hpp>
#include <vector>
class Language
{
public:
virtual ~Language(){}
virtual void LoadProgram(const char* filename) = 0;
virtual int FreeProgram() = 0;
virtual bool IsCallbackPresent(const char* name) = 0;
virtual boost::any Call(const char* name, const char* argl, int buf, ...) = 0;
virtual boost::any Call(const char* name, const char* argl, const std::vector<boost::any>& args) = 0;
virtual lib_t GetInterface() = 0;
};
#endif //PLUGINSYSTEM3_LANGUAGE_HPP

@ -0,0 +1,60 @@
//
// Created by koncord on 23.01.16.
//
#ifndef PLATFORM_HPP
#define PLATFORM_HPP
#ifdef _MSC_VER
#ifdef _M_X86
#define ARCH_X86
#endif
#endif
#ifdef __GNUC__
#ifdef __i386__
#define ARCH_X86
#endif
#endif
#if defined _WIN32 && !defined __genffi__
#ifndef CDECL
#define CDECL __cdecl
#endif
#else
#define CDECL
#endif
#if defined __cplusplus
#define EXTERN extern "C"
#else
#define EXTERN extern
#endif
#if defined _WIN32
#define IMPORT_FUNCTION EXTERN __declspec(dllimport)
#define EXPORT_FUNCTION EXTERN __declspec(dllexport)
#else
#define EXPORT_FUNCTION EXTERN __attribute__ ((visibility ("default")))
#define IMPORT_FUNCTION EXTERN
#endif
#if defined __genffi__
#define API_FUNCTION
#elif !defined _HOST
#define API_FUNCTION IMPORT_FUNCTION
#else
#define API_FUNCTION EXPORT_FUNCTION
#endif // __genffi__
#if defined __cplusplus
#define NAMESPACE_BEGIN(name) namespace name {
#define NAMESPACE_END() }
#define NOEXCEPT noexcept
#else
#define NAMESPACE_BEGIN(name)
#define NAMESPACE_END()
#define NOEXCEPT
#endif
#endif //PLATFORM_HPP

@ -1,20 +0,0 @@
//
// Created by koncord on 23.01.16.
//
#ifndef PLATFORM_HPP
#define PLATFORM_HPP
#if _MSC_VER
#ifdef _M_X86
#define ARCH_X86
#endif
#endif
#if __GNUC__
#ifdef __i386__
#define ARCH_X86
#endif
#endif
#endif //PLATFORM_HPP

@ -0,0 +1,85 @@
//
// Created by koncord on 12.01.19.
//
#include "Plugin.hpp"
#include <cstdarg>
#include <algorithm>
#include <mutex>
Plugin::PluginList Plugin::plugins;
//constexpr ScriptCallbackData Plugin::callbacks[];
static Plugin* scriptTmpPtr; // hack for RegisterEvent
Plugin::Plugin(const std::string &pluginName)
{
lib = OpenLibrary(pluginName.c_str());
if (!lib)
throw std::invalid_argument(std::string("Plugin ") + pluginName + " not found.");
PluginInit = SystemInterface<decltype(PluginInit)>(lib, "PluginInit").result;
if (!PluginInit)
throw std::runtime_error("\"void PluginInit(int pluginId)\" not implemented by plugin");
PluginFree = SystemInterface<decltype(PluginFree)>(lib, "PluginFree").result;
if (!PluginFree)
throw std::runtime_error("\"void PluginFree()\" not implemented");
}
Plugin::~Plugin()
{
PluginFree();
CloseLibrary(lib);
}
bool Plugin::LoadPlugin(const std::string &plugin)
{
auto script = std::make_unique<Plugin>(plugin);
scriptTmpPtr = script.get(); // needs for RegisterEvent
bool result = script->PluginInit() == 1;
scriptTmpPtr = nullptr; // reset value for safety
if (result)
{
plugins.push_back(std::move(script));
return true;
}
return false;
}
void Plugin::LoadPlugins(const std::vector<std::string> &pluginsList)
{
for(const auto &plugin : pluginsList)
LoadPlugin(plugin);
}
static std::string moddir;
void Plugin::SetModDir(const std::string &_moddir)
{
if (moddir.empty()) // do not allow to change in runtime
moddir = _moddir;
}
const char* Plugin::GetModDir()
{
return moddir.c_str();
}
static std::string plugindir;
void Plugin::SetPluginDir(const std::string &pluginDir)
{
if (plugindir.empty()) // do not allow to change in runtime
plugindir = pluginDir;
}
const char *Plugin::GetPluginDir()
{
return plugindir.c_str();
}

@ -0,0 +1,69 @@
//
// Created by koncord on 12.01.19.
//
#pragma once
#include "SystemInterface.hpp"
#include "Callbacks.hpp"
#include <unordered_map>
#include <memory>
#include <vector>
class Plugin: Callbacks
{
private:
lib_t lib;
void (*PluginFree)();
int (*PluginInit)();
typedef std::vector<std::unique_ptr<Plugin>> PluginList;
std::unordered_map<unsigned int, FunctionEllipsis<void>> callbacks_;
static PluginList plugins;
public:
explicit Plugin(const std::string &pluginName);
~Plugin();
Plugin(const Plugin&) = delete;
Plugin& operator=(const Plugin&) = delete;
static bool LoadPlugin(const std::string &plugin);
static void LoadPlugins(const std::vector<std::string> &pluginsList);
static void SetModDir(const std::string &moddir);
static const char* GetModDir();
static void SetPluginDir(const std::string &pluginDir);
static const char* GetPluginDir();
static constexpr ScriptCallbackData const& CallBackData(const unsigned int I, const unsigned int N = 0)
{
return callbacks[N].index == I ? callbacks[N] : CallBackData(I, N + 1);
}
template<unsigned int I, bool B = false, typename... Args>
static unsigned int Call(Args&&... args)
{
constexpr ScriptCallbackData const& data = CallBackData(I);
static_assert(data.callback.matches(TypeString<typename std::remove_reference<Args>::type...>::value),
"Wrong number or types of arguments");
unsigned int count = 0;
for (auto& plugin : plugins)
{
if (!plugin->callbacks_.count(I))
plugin->callbacks_.emplace(I, SystemInterface<FunctionEllipsis<void>>(plugin->lib, data.name).result);
auto callback = plugin->callbacks_[I];
if (!callback)
continue;
(callback)(std::forward<Args>(args)...);
++count;
}
return count;
}
};

@ -1,108 +0,0 @@
//
// Created by koncord on 19.03.16.
//
#include "Script.hpp"
#include "LangNative/LangNative.hpp"
#if defined (ENABLE_LUA)
#include "LangLua/LangLua.hpp"
#endif
using namespace std;
Script::ScriptList Script::scripts;
std::string Script::moddir;
Script::Script(const char *path)
{
FILE *file = fopen(path, "rb");
if (!file)
throw runtime_error("Script not found: " + string(path));
fclose(file);
#ifdef _WIN32
if (strstr(path, ".dll"))
#else
if (strstr(path, ".so"))
#endif
{
script_type = SCRIPT_CPP;
lang = new LangNative();
}
#if defined (ENABLE_LUA)
else if (strstr(path, ".lua") || strstr(path, ".t"))
{
lang = new LangLua();
script_type = SCRIPT_LUA;
}
#endif
else
throw runtime_error("Script type not recognized: " + string(path));
try
{
lang->LoadProgram(path);
}
catch (...)
{
lang->FreeProgram();
throw;
}
}
Script::~Script()
{
lang->FreeProgram();
delete lang;
}
void Script::LoadScripts(char *scripts, const char *base)
{
char *token = strtok(scripts, ",");
try
{
while (token)
{
char path[4096];
snprintf(path, sizeof(path), Utils::convertPath("%s/%s/%s").c_str(), base, "scripts", token);
Script::scripts.emplace_back(new Script(path));
token = strtok(nullptr, ",");
}
}
catch (...)
{
UnloadScripts();
throw;
}
}
void Script::UnloadScripts()
{
//Public::DeleteAll();
scripts.clear();
}
void Script::LoadScript(const char *script, const char *base)
{
char path[4096];
snprintf(path, sizeof(path), Utils::convertPath("%s/%s/%s").c_str(), base, "scripts", script);
Script::scripts.emplace_back(new Script(path));
}
void Script::SetModDir(const std::string &moddir)
{
if (Script::moddir.empty()) // do not allow to change in runtime
Script::moddir = moddir;
}
const char* Script::GetModDir()
{
return moddir.c_str();
}

@ -1,122 +0,0 @@
//
// Created by koncord on 19.03.16.
//
#ifndef PLUGINSYSTEM3_SCRIPT_HPP
#define PLUGINSYSTEM3_SCRIPT_HPP
#include <boost/any.hpp>
#include <unordered_map>
#include <memory>
#include "Types.hpp"
#include "SystemInterface.hpp"
#include "ScriptFunction.hpp"
#include "ScriptFunctions.hpp"
#include "Language.hpp"
#include "Networking.hpp"
class Script : private ScriptFunctions
{
// http://imgur.com/hU0N4EH
private:
Language *lang;
enum
{
SCRIPT_CPP,
SCRIPT_LUA
};
template<typename R>
R GetScript(const char *name)
{
if (script_type == SCRIPT_CPP)
{
return SystemInterface<R>(lang->GetInterface(), name).result;
}
else
{
return reinterpret_cast<R>(lang->IsCallbackPresent(name));
}
}
int script_type;
std::unordered_map<unsigned int, FunctionEllipsis<void>> callbacks_;
typedef std::vector<std::unique_ptr<Script>> ScriptList;
static ScriptList scripts;
Script(const char *path);
Script(const Script&) = delete;
Script& operator=(const Script&) = delete;
protected:
static std::string moddir;
public:
~Script();
static void LoadScript(const char *script, const char* base);
static void LoadScripts(char* scripts, const char* base);
static void UnloadScripts();
static void SetModDir(const std::string &moddir);
static const char* GetModDir();
static constexpr ScriptCallbackData const& CallBackData(const unsigned int I, const unsigned int N = 0) {
return callbacks[N].index == I ? callbacks[N] : CallBackData(I, N + 1);
}
template<size_t N>
static constexpr unsigned int CallbackIdentity(const char(&str)[N])
{
return Utils::hash(str);
}
template<unsigned int I, bool B = false, typename... Args>
static unsigned int Call(Args&&... args) {
constexpr ScriptCallbackData const& data = CallBackData(I);
static_assert(data.callback.matches(TypeString<typename std::remove_reference<Args>::type...>::value),
"Wrong number or types of arguments");
unsigned int count = 0;
for (auto& script : scripts)
{
if (!script->callbacks_.count(I))
script->callbacks_.emplace(I, script->GetScript<FunctionEllipsis<void>>(data.name));
auto callback = script->callbacks_[I];
if (!callback)
continue;
if (script->script_type == SCRIPT_CPP)
(callback)(std::forward<Args>(args)...);
#if defined (ENABLE_LUA)
else if (script->script_type == SCRIPT_LUA)
{
try
{
script->lang->Call(data.name, data.callback.types, B, std::forward<Args>(args)...);
}
catch (std::exception &e)
{
LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, e.what());
Script::Call<Script::CallbackIdentity("OnServerScriptCrash")>(e.what());
if (!mwmp::Networking::getPtr()->getScriptErrorIgnoringState())
throw;
}
}
#endif
++count;
}
return count;
}
};
#endif //PLUGINSYSTEM3_SCRIPT_HPP

@ -1,73 +0,0 @@
//
// Created by koncord on 23.01.16.
//
#include<iostream>
#include <stdexcept>
#include "ScriptFunction.hpp"
#if defined (ENABLE_LUA)
#include "LangLua/LangLua.hpp"
#endif
using namespace std;
ScriptFunction::ScriptFunction(ScriptFunc fCpp,char ret_type, const string &def) :
fCpp(fCpp), ret_type(ret_type), def(def), script_type(SCRIPT_CPP)
{
}
#if defined (ENABLE_LUA)
ScriptFunction::ScriptFunction(const ScriptFuncLua &fLua, lua_State *lua, char ret_type, const std::string &def) :
fLua({lua, fLua}), ret_type(ret_type), def(def), script_type(SCRIPT_LUA)
{
}
#endif
ScriptFunction::~ScriptFunction()
{
#if defined (ENABLE_LUA)
if (script_type == SCRIPT_LUA)
fLua.name.~ScriptFuncLua();
#endif
}
boost::any ScriptFunction::Call(const vector<boost::any> &args)
{
boost::any result;
if (def.length() != args.size())
throw runtime_error("Script call: Number of arguments does not match definition");
#if defined (ENABLE_LUA)
else if (script_type == SCRIPT_LUA)
{
LangLua langLua(fLua.lua);
boost::any any = langLua.Call(fLua.name.c_str(), def.c_str(), args);
switch (ret_type)
{
case 'i':
result = boost::any_cast<luabridge::LuaRef>(any).cast<unsigned int>();
break;
case 'q':
result = boost::any_cast<luabridge::LuaRef>(any).cast<signed int>();
break;
case 'f':
result = boost::any_cast<luabridge::LuaRef>(any).cast<double>();
break;
case 's':
result = boost::any_cast<luabridge::LuaRef>(any).cast<const char*>();
break;
case 'v':
result = boost::any();
break;
default:
throw runtime_error("Lua call: Unknown return type" + ret_type);
}
}
#endif
return result;
}

@ -1,54 +0,0 @@
//
// Created by koncord on 23.01.16.
//
#ifndef SCRIPTFUNCTION_HPP
#define SCRIPTFUNCTION_HPP
#include <boost/any.hpp>
#include <string>
#include <vector>
#if defined (ENABLE_LUA)
#include "LangLua/LangLua.hpp"
#endif
typedef unsigned long long(*ScriptFunc)();
#if defined (ENABLE_LUA)
typedef std::string ScriptFuncLua;
#endif
class ScriptFunction
{
protected:
union
{
ScriptFunc fCpp;
#if defined (ENABLE_LUA)
struct
{
lua_State *lua;
ScriptFuncLua name;
} fLua;
#endif
};
protected:
char ret_type;
std::string def;
int script_type;
enum
{
SCRIPT_CPP,
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
virtual ~ScriptFunction();
boost::any Call(const std::vector<boost::any> &args);
};
#endif //SCRIPTFUNCTION_HPP

@ -1,35 +0,0 @@
#include "ScriptFunctions.hpp"
#include "API/PublicFnAPI.hpp"
#include <cstdarg>
#include <iostream>
#include <apps/openmw-mp/Player.hpp>
#include <apps/openmw-mp/Networking.hpp>
#include <components/openmw-mp/NetworkMessages.hpp>
template<typename... Types>
constexpr char TypeString<Types...>::value[];
constexpr ScriptFunctionData ScriptFunctions::functions[];
constexpr ScriptCallbackData ScriptFunctions::callbacks[];
using namespace std;
void ScriptFunctions::MakePublic(ScriptFunc _public, const char *name, char ret_type, const char *def) noexcept
{
Public::MakePublic(_public, name, ret_type, def);
}
boost::any ScriptFunctions::CallPublic(const char *name, va_list args) noexcept
{
vector<boost::any> params;
try
{
string def = Public::GetDefinition(name);
Utils::getArguments(params, args, def);
return Public::Call(name, params);
}
catch (...) {}
return 0;
}

@ -1,216 +0,0 @@
#ifndef SCRIPTFUNCTIONS_HPP
#define SCRIPTFUNCTIONS_HPP
#include <Script/Functions/Actors.hpp>
#include <Script/Functions/Books.hpp>
#include <Script/Functions/Cells.hpp>
#include <Script/Functions/CharClass.hpp>
#include <Script/Functions/Chat.hpp>
#include <Script/Functions/Dialogue.hpp>
#include <Script/Functions/Factions.hpp>
#include <Script/Functions/GUI.hpp>
#include <Script/Functions/Items.hpp>
#include <Script/Functions/Mechanics.hpp>
#include <Script/Functions/Miscellaneous.hpp>
#include <Script/Functions/Objects.hpp>
#include <Script/Functions/Positions.hpp>
#include <Script/Functions/Quests.hpp>
#include <Script/Functions/RecordsDynamic.hpp>
#include <Script/Functions/Shapeshift.hpp>
#include <Script/Functions/Server.hpp>
#include <Script/Functions/Settings.hpp>
#include <Script/Functions/Spells.hpp>
#include <Script/Functions/Stats.hpp>
#include <Script/Functions/Worldstate.hpp>
#include <RakNetTypes.h>
#include <tuple>
#include <apps/openmw-mp/Player.hpp>
#include "ScriptFunction.hpp"
#include "Types.hpp"
#include <components/openmw-mp/Log.hpp>
#ifndef __PRETTY_FUNCTION__
#define __PRETTY_FUNCTION__ __FUNCTION__
#endif
#define GET_PLAYER(pid, pl, retvalue) \
pl = Players::getPlayer(pid); \
if (player == 0) {\
LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, "%s: Player with pid \'%d\' not found\n", __PRETTY_FUNCTION__, pid);\
/*ScriptFunctions::StopServer(1);*/ \
return retvalue;\
}
class ScriptFunctions
{
public:
static void MakePublic(ScriptFunc _public, const char *name, char ret_type, const char *def) noexcept;
static boost::any CallPublic(const char *name, va_list args) noexcept;
/**
* \brief Create a timer that will run a script function after a certain interval.
*
* \param callback The Lua script function.
* \param msec The interval in miliseconds.
* \return The ID of the timer thus created.
*/
static int CreateTimer(ScriptFunc callback, int msec) noexcept;
/**
* \brief Create a timer that will run a script function after a certain interval and pass
* certain arguments to it.
*
* Example usage:
* - tes3mp.CreateTimerEx("OnTimerTest1", 250, "i", 90)
* - tes3mp.CreateTimerEx("OnTimerTest2", 500, "sif", "Test string", 60, 77.321)
*
* \param callback The Lua script function.
* \param msec The interval in miliseconds.
* \param types The argument types.
* \param args The arguments.
* \return The ID of the timer thus created.
*/
static int CreateTimerEx(ScriptFunc callback, int msec, const char *types, va_list args) noexcept;
/**
* \brief Start the timer with a certain ID.
*
* \param timerId The timer ID.
* \return void
*/
static void StartTimer(int timerId) noexcept;
/**
* \brief Stop the timer with a certain ID.
*
* \param timerId The timer ID.
* \return void
*/
static void StopTimer(int timerId) noexcept;
/**
* \brief Restart the timer with a certain ID for a certain interval.
*
* \param timerId The timer ID.
* \param msec The interval in miliseconds.
* \return void
*/
static void RestartTimer(int timerId, int msec) noexcept;
/**
* \brief Free the timer with a certain ID.
*
* \param timerId The timer ID.
* \return void
*/
static void FreeTimer(int timerId) noexcept;
/**
* \brief Check whether a timer is elapsed.
*
* \param timerId The timer ID.
* \return Whether the timer is elapsed.
*/
static bool IsTimerElapsed(int timerId) noexcept;
static constexpr ScriptFunctionData functions[]{
{"CreateTimer", ScriptFunctions::CreateTimer},
{"CreateTimerEx", ScriptFunctions::CreateTimerEx},
{"MakePublic", ScriptFunctions::MakePublic},
{"CallPublic", ScriptFunctions::CallPublic},
{"StartTimer", ScriptFunctions::StartTimer},
{"StopTimer", ScriptFunctions::StopTimer},
{"RestartTimer", ScriptFunctions::RestartTimer},
{"FreeTimer", ScriptFunctions::FreeTimer},
{"IsTimerElapsed", ScriptFunctions::IsTimerElapsed},
ACTORAPI,
BOOKAPI,
CELLAPI,
CHARCLASSAPI,
CHATAPI,
DIALOGUEAPI,
FACTIONAPI,
GUIAPI,
ITEMAPI,
MECHANICSAPI,
MISCELLANEOUSAPI,
POSITIONAPI,
QUESTAPI,
RECORDSDYNAMICAPI,
SHAPESHIFTAPI,
SERVERAPI,
SETTINGSAPI,
SPELLAPI,
STATAPI,
OBJECTAPI,
WORLDSTATEAPI
};
static constexpr ScriptCallbackData callbacks[]{
{"OnServerInit", Callback<>()},
{"OnServerPostInit", Callback<>()},
{"OnServerExit", Callback<bool>()},
{"OnServerScriptCrash", Callback<const char*>()},
{"OnPlayerConnect", Callback<unsigned short>()},
{"OnPlayerDisconnect", Callback<unsigned short>()},
{"OnPlayerDeath", Callback<unsigned short>()},
{"OnPlayerResurrect", Callback<unsigned short>()},
{"OnPlayerCellChange", Callback<unsigned short>()},
{"OnPlayerAttribute", Callback<unsigned short>()},
{"OnPlayerSkill", Callback<unsigned short>()},
{"OnPlayerLevel", Callback<unsigned short>()},
{"OnPlayerBounty", Callback<unsigned short>()},
{"OnPlayerReputation", Callback<unsigned short>()},
{"OnPlayerEquipment", Callback<unsigned short>()},
{"OnPlayerInventory", Callback<unsigned short>()},
{"OnPlayerJournal", Callback<unsigned short>()},
{"OnPlayerFaction", Callback<unsigned short>()},
{"OnPlayerShapeshift", Callback<unsigned short>()},
{"OnPlayerSpellbook", Callback<unsigned short>()},
{"OnPlayerQuickKeys", Callback<unsigned short>()},
{"OnPlayerTopic", Callback<unsigned short>()},
{"OnPlayerDisposition", Callback<unsigned short>()},
{"OnPlayerBook", Callback<unsigned short>()},
{"OnPlayerItemUse", Callback<unsigned short>()},
{"OnPlayerMiscellaneous", Callback<unsigned short>()},
{"OnPlayerInput", Callback<unsigned short>()},
{"OnPlayerRest", Callback<unsigned short>()},
{"OnRecordDynamic", Callback<unsigned short>()},
{"OnCellLoad", Callback<unsigned short, const char*>()},
{"OnCellUnload", Callback<unsigned short, const char*>()},
{"OnCellDeletion", Callback<const char*>()},
{"OnContainer", Callback<unsigned short, const char*>()},
{"OnDoorState", Callback<unsigned short, const char*>()},
{"OnObjectActivate", Callback<unsigned short, const char*>()},
{"OnObjectPlace", Callback<unsigned short, const char*>()},
{"OnObjectState", Callback<unsigned short, const char*>()},
{"OnObjectSpawn", Callback<unsigned short, const char*>()},
{"OnObjectDelete", Callback<unsigned short, const char*>()},
{"OnObjectLock", Callback<unsigned short, const char*>()},
{"OnObjectScale", Callback<unsigned short, const char*>()},
{"OnObjectTrap", Callback<unsigned short, const char*>()},
{"OnVideoPlay", Callback<unsigned short, const char*>()},
{"OnActorList", Callback<unsigned short, const char*>()},
{"OnActorEquipment", Callback<unsigned short, const char*>()},
{"OnActorAI", Callback<unsigned short, const char*>()},
{"OnActorDeath", Callback<unsigned short, const char*>()},
{"OnActorCellChange", Callback<unsigned short, const char*>()},
{"OnActorTest", Callback<unsigned short, const char*>()},
{"OnPlayerSendMessage", Callback<unsigned short, const char*>()},
{"OnPlayerEndCharGen", Callback<unsigned short>()},
{"OnGUIAction", Callback<unsigned short, int, const char*>()},
{"OnWorldKillCount", Callback<unsigned short>()},
{"OnWorldMap", Callback<unsigned short>()},
{"OnWorldWeather", Callback<unsigned short>() },
{"OnMpNumIncrement", Callback<int>()},
{"OnRequestDataFileList", Callback<>()}
};
};
#endif //SCRIPTFUNCTIONS_HPP

@ -2,18 +2,17 @@
// Created by koncord on 19.03.16.
//
#ifndef PLUGINSYSTEM3_SYSTEMINTERFACE_HPP
#define PLUGINSYSTEM3_SYSTEMINTERFACE_HPP
#pragma once
#ifdef _WIN32
#include <winsock2.h>
typedef HMODULE lib_t;
#else
#include <dlfcn.h>
typedef void *lib_t;
#endif
#include "Types.hpp"
template<typename R = void*>
template<typename R = void *>
struct SystemInterface
{
@ -37,7 +36,14 @@ struct SystemInterface
#ifdef _WIN32
SystemInterface(lib_t handle, const char* name) : data(GetProcAddress(handle, name)) {}
#else
SystemInterface(lib_t handle, const char* name) : data(dlsym(handle, name)) {}
SystemInterface(lib_t handle, const char *name) : data(dlsym(handle, name)) {}
#endif
};
#endif //PLUGINSYSTEM3_SYSTEMINTERFACE_HPP
#ifdef _WIN32
#define OpenLibrary(pluginName) LoadLibrary(pluginName)
#define CloseLibrary(lib) FreeLibrary(lib)
#else
#define OpenLibrary(pluginName) dlopen(pluginName, RTLD_LAZY | RTLD_LOCAL)
#define CloseLibrary(lib) dlclose(lib)
#endif

@ -2,132 +2,56 @@
// Created by koncord on 23.01.16.
//
#ifndef TMPTYPES_HPP
#define TMPTYPES_HPP
#pragma once
#include <cstddef>
#include <cstdint>
#include <cstddef>
#include <type_traits>
#include <RakNetTypes.h>
#include "Utils.hpp"
#ifdef _WIN32
#include <winsock2.h>
#endif
#ifdef _WIN32
typedef HMODULE lib_t;
#else
typedef void* lib_t;
#endif
template<typename T> struct sizeof_void { enum { value = sizeof(T) }; };
template<> struct sizeof_void<void> { enum { value = 0 }; };
template<typename T, size_t t> struct TypeChar { static_assert(!t, "Unsupported type in variadic type list"); };
template<> struct TypeChar<bool, sizeof(bool)> { enum { value = 'b' }; };
template<typename T> struct TypeChar<T*, sizeof(void*)> { enum { value = 'p' }; };
template<> struct TypeChar<double*, sizeof(double*)> { enum { value = 'd' }; };
template<> struct TypeChar<RakNet::NetworkID**, sizeof(RakNet::NetworkID**)> { enum { value = 'n' }; };
template<typename T> struct TypeChar<T, sizeof(uint8_t)> { enum { value = std::is_signed<T>::value ? 'q' : 'i' }; };
template<typename T> struct TypeChar<T, sizeof(uint16_t)> { enum { value = std::is_signed<T>::value ? 'q' : 'i' }; };
template<typename T> struct TypeChar<T, sizeof(uint32_t)> { enum { value = std::is_signed<T>::value ? 'q' : 'i' }; };
template<typename T> struct TypeChar<T, sizeof(uint64_t)> { enum { value = std::is_signed<T>::value ? 'w' : 'l' }; };
template<> struct TypeChar<double, sizeof(double)> { enum { value = 'f' }; };
template<> struct TypeChar<char*, sizeof(char*)> { enum { value = 's' }; };
template<> struct TypeChar<const char*, sizeof(const char*)> { enum { value = 's' }; };
template<typename T> struct TypeChar<T *, sizeof(void *)> { enum { value = 'p' }; };
template<typename T> struct TypeChar<T, sizeof(uint8_t)> { enum { value = std::is_signed<T>::value ? 'c' : 'C' }; };
template<typename T> struct TypeChar<T, sizeof(uint16_t)> { enum { value = std::is_signed<T>::value ? 'h' : 'H' }; };
template<typename T> struct TypeChar<T, sizeof(uint32_t)> { enum { value = std::is_signed<T>::value ? 'i' : 'I' }; };
template<typename T> struct TypeChar<T, sizeof(uint64_t)> { enum { value = std::is_signed<T>::value ? 'l' : 'L' }; };
template<> struct TypeChar<float, sizeof(float)> { enum { value = 'd' }; };
template<> struct TypeChar<double, sizeof(double)> { enum { value = 'd' }; };
template<> struct TypeChar<char *, sizeof(char *)> { enum { value = 's' }; };
template<> struct TypeChar<const char *, sizeof(const char *)> { enum { value = 's' }; };
template<> struct TypeChar<void, sizeof_void<void>::value> { enum { value = 'v' }; };
template<const char t> struct CharType { static_assert(!t, "Unsupported type in variadic type list"); };
template<> struct CharType<'b'> { typedef bool type; };
template<> struct CharType<'p'> { typedef void* type; };
template<> struct CharType<'d'> { typedef double* type; };
template<> struct CharType<'n'> { typedef RakNet::NetworkID** type; };
template<> struct CharType<'q'> { typedef signed int type; };
template<> struct CharType<'i'> { typedef unsigned int type; };
template<> struct CharType<'w'> { typedef signed long long type; };
template<> struct CharType<'l'> { typedef unsigned long long type; };
template<> struct CharType<'f'> { typedef double type; };
template<> struct CharType<'s'> { typedef const char* type; };
template<> struct CharType<'v'> { typedef void type; };
template<typename... Types>
struct TypeString {
struct TypeString
{
static constexpr char value[sizeof...(Types) + 1] = {
TypeChar<Types, sizeof(Types)>::value...
};
};
template<char t> struct CharType { static_assert(!t, "Unsupported type in variadic type list"); };
template<> struct CharType<'b'> { typedef bool type; };
template<> struct CharType<'p'> { typedef void* type; };
template<typename R, typename... Types>
using Function = R(*)(Types...);
template<typename R>
using FunctionEllipsis = R(*)(...);
struct ScriptIdentity
{
const char* types;
const char ret;
const unsigned int numargs;
constexpr bool matches(const char* types, const unsigned int N = 0) const
{
return N < numargs ? this->types[N] == types[N] && matches(types, N + 1) : this->types[N] == types[N];
}
template<typename R, typename... Types>
constexpr ScriptIdentity(Function<R, Types...>) : types(TypeString<Types...>::value), ret(TypeChar<R, sizeof_void<R>::value>::value), numargs(sizeof(TypeString<Types...>::value) - 1) {}
};
template<typename... Types>
using Callback = void (*)(Types...);
struct CallbackIdentity
{
const char* types;
const unsigned int numargs;
constexpr bool matches(const char* types, const unsigned int N = 0) const
{
return N < numargs ? this->types[N] == types[N] && matches(types, N + 1) : this->types[N] == types[N];
}
template<typename... Types>
constexpr CallbackIdentity(Callback<Types...>) : types(TypeString<Types...>::value), numargs(sizeof(TypeString<Types...>::value) - 1) {}
};
template<> struct CharType<'c'> { typedef int8_t type; };
template<> struct CharType<'C'> { typedef uint8_t type; };
struct ScriptFunctionPointer : public ScriptIdentity
{
void *addr;
#if (!defined(__clang__) && defined(__GNUC__))
template<typename R, typename... Types>
constexpr ScriptFunctionPointer(Function<R, Types...> addr) : ScriptIdentity(addr), addr((void*)(addr)) {}
#else
template<typename R, typename... Types>
constexpr ScriptFunctionPointer(Function<R, Types...> addr) : ScriptIdentity(addr), addr(addr) {}
#endif
};
template<> struct CharType<'h'> { typedef int16_t type; };
template<> struct CharType<'H'> { typedef uint16_t type; };
struct ScriptFunctionData
{
const char* name;
const ScriptFunctionPointer func;
template<> struct CharType<'i'> { typedef int32_t type; };
template<> struct CharType<'I'> { typedef uint32_t type; };
constexpr ScriptFunctionData(const char* name, ScriptFunctionPointer func) : name(name), func(func) {}
};
template<> struct CharType<'l'> { typedef int64_t type; };
template<> struct CharType<'L'> { typedef uint64_t type; };
struct ScriptCallbackData
{
const char* name;
const unsigned int index;
const CallbackIdentity callback;
template<> struct CharType<'f'> { typedef double type; };
template<> struct CharType<'d'> { typedef double type; };
template<size_t N>
constexpr ScriptCallbackData(const char(&name)[N], CallbackIdentity _callback) : name(name), index(Utils::hash(name)), callback(_callback) {}
};
template<> struct CharType<'s'> { typedef const char* type; };
template<> struct CharType<'v'> { typedef void type; };
#endif //TMPTYPES_HPP

@ -0,0 +1,106 @@
/**
* @file api.h
* @brief External API for plugins.
* @authors koncord
* @date 08.01.19
*/
#ifndef NEWNATIVE_API_H
#define NEWNATIVE_API_H
#ifndef DOXYGEN_SHOULD_SKIP_THIS
#include "Platform.h"
#endif
#include "CTypes.h"
#if !(defined _HOST || defined __genffi__)
/** @addtogroup PluginCallbacks Plugin Callbacks
* @brief Those callbacks can be implemented by plugin.
* @{
*/
/*! @brief This function must be implemented by every plugin.
*
* Called by the server on initialization process, there is no possible to call any API functions in this function.
* If this function returns 0, PluginFree() will be called
*
* @return 1 on success 0 on fail
*/
EXPORT_FUNCTION int CDECL PluginInit();
/*! @brief This function must be implemented by every plugin.
*
* Called by the server on qutitting or failing to initialize plugin by PluginInit()
*/
EXPORT_FUNCTION void CDECL PluginFree();
EXPORT_FUNCTION void CDECL OnServerInit();
EXPORT_FUNCTION void CDECL OnServerPostInit();
EXPORT_FUNCTION void CDECL OnServerExit(bool code);
EXPORT_FUNCTION void CDECL OnPlayerConnect(PlayerId pid);
EXPORT_FUNCTION void CDECL OnPlayerDisconnect(PlayerId pid);
EXPORT_FUNCTION void CDECL OnPlayerDeath(PlayerId pid);
EXPORT_FUNCTION void CDECL OnPlayerResurrect(PlayerId pid);
EXPORT_FUNCTION void CDECL OnPlayerCellChange(PlayerId pid);
EXPORT_FUNCTION void CDECL OnPlayerAttribute(PlayerId pid);
EXPORT_FUNCTION void CDECL OnPlayerSkill(PlayerId pid);
EXPORT_FUNCTION void CDECL OnPlayerLevel(PlayerId pid);
EXPORT_FUNCTION void CDECL OnPlayerBounty(PlayerId pid);
EXPORT_FUNCTION void CDECL OnPlayerReputation(PlayerId pid);
EXPORT_FUNCTION void CDECL OnPlayerEquipment(PlayerId pid);
EXPORT_FUNCTION void CDECL OnPlayerInventory(PlayerId pid);
EXPORT_FUNCTION void CDECL OnPlayerJournal(PlayerId pid);
EXPORT_FUNCTION void CDECL OnPlayerFaction(PlayerId pid);
EXPORT_FUNCTION void CDECL OnPlayerShapeshift(PlayerId pid);
EXPORT_FUNCTION void CDECL OnPlayerQuickKeys(PlayerId pid);
EXPORT_FUNCTION void CDECL OnPlayerTopic(PlayerId pid);
EXPORT_FUNCTION void CDECL OnPlayerDisposition(PlayerId pid);
EXPORT_FUNCTION void CDECL OnPlayerBook(PlayerId pid);
EXPORT_FUNCTION void CDECL OnPlayerItemUse(PlayerId pid);
EXPORT_FUNCTION void CDECL OnPlayerMiscellaneous(PlayerId pid);
EXPORT_FUNCTION void CDECL OnPlayerInput(PlayerId pid);
EXPORT_FUNCTION void CDECL OnPlayerRest(PlayerId pid);
EXPORT_FUNCTION void CDECL OnRecordDynamic(PlayerId pid);
EXPORT_FUNCTION void CDECL OnCellLoad(PlayerId pid, const char *cellDescription);
EXPORT_FUNCTION void CDECL OnCellUnload(PlayerId pid, const char *cellDescription);
EXPORT_FUNCTION void CDECL OnCellDeletion(const char *cellDescription);
EXPORT_FUNCTION void CDECL OnContainer(PlayerId pid, const char *cellDescription);
EXPORT_FUNCTION void CDECL OnDoorState(PlayerId pid, const char *cellDescription);
EXPORT_FUNCTION void CDECL OnObjectActivate(PlayerId pid, const char *cellDescription);
EXPORT_FUNCTION void CDECL OnObjectPlace(PlayerId pid, const char *cellDescription);
EXPORT_FUNCTION void CDECL OnObjectState(PlayerId pid, const char *cellDescription);
EXPORT_FUNCTION void CDECL OnObjectSpawn(PlayerId pid, const char *cellDescription);
EXPORT_FUNCTION void CDECL OnObjectDelete(PlayerId pid, const char *cellDescription);
EXPORT_FUNCTION void CDECL OnObjectLock(PlayerId pid, const char *cellDescription);
EXPORT_FUNCTION void CDECL OnObjectScale(PlayerId pid, const char *cellDescription);
EXPORT_FUNCTION void CDECL OnObjectTrap(PlayerId pid, const char *cellDescription);
EXPORT_FUNCTION void CDECL OnVideoPlay(PlayerId pid, const char *cellDescription);
EXPORT_FUNCTION void CDECL OnActorList(PlayerId pid, const char *cellDescription);
EXPORT_FUNCTION void CDECL OnActorEquipment(PlayerId pid, const char *cellDescription);
EXPORT_FUNCTION void CDECL OnActorAI(PlayerId pid, const char *cellDescription);
EXPORT_FUNCTION void CDECL OnActorDeath(PlayerId pid, const char *cellDescription);
EXPORT_FUNCTION void CDECL OnActorCellChange(PlayerId pid, const char *cellDescription);
EXPORT_FUNCTION void CDECL OnActorTest(PlayerId pid, const char *cellDescription);
EXPORT_FUNCTION void CDECL OnPlayerSendMessage(PlayerId pid, const char *message);
EXPORT_FUNCTION void CDECL OnPlayerEndCharGen(PlayerId pid);
EXPORT_FUNCTION void CDECL OnGUIAction(PlayerId pid, const char *data);
EXPORT_FUNCTION void CDECL OnWorldKillCount(PlayerId pid);
EXPORT_FUNCTION void CDECL OnWorldMap(PlayerId pid);
EXPORT_FUNCTION void CDECL OnWorldWeather(PlayerId pid);
EXPORT_FUNCTION void CDECL OnMpNumIncrement(int mpNum);
EXPORT_FUNCTION void CDECL OnRequestPluginList();
/** @}*/
#endif
#endif //NEWNATIVE_API_H

@ -1,6 +1,8 @@
#include "Utils.hpp"
//
// Created by koncord on 04.03.17.
//
#include <cstdarg>
#include "Utils.hpp"
using namespace std;
@ -15,7 +17,6 @@ const vector<string> Utils::split(const string &str, int delimiter)
else if (!buffer.empty())
{
result.push_back(move(buffer));
buffer.clear();
}
if (!buffer.empty())
result.push_back(move(buffer));
@ -23,7 +24,7 @@ const vector<string> Utils::split(const string &str, int delimiter)
return result;
}
ESM::Cell Utils::getCellFromDescription(std::string cellDescription)
ESM::Cell Utils::getCellFromDescription(const std::string &cellDescription)
{
ESM::Cell cell;
cell.blank();
@ -50,59 +51,3 @@ ESM::Cell Utils::getCellFromDescription(std::string cellDescription)
return cell;
}
void Utils::getArguments(std::vector<boost::any> &params, va_list args, const std::string &def)
{
params.reserve(def.length());
try
{
for (char c : def)
{
switch (c)
{
case 'i':
params.emplace_back(va_arg(args, unsigned int));
break;
case 'q':
params.emplace_back(va_arg(args, signed int));
break;
case 'l':
params.emplace_back(va_arg(args, unsigned long long));
break;
case 'w':
params.emplace_back(va_arg(args, signed long long));
break;
case 'f':
params.emplace_back(va_arg(args, double));
break;
case 'p':
params.emplace_back(va_arg(args, void*));
break;
case 's':
params.emplace_back(va_arg(args, const char*));
break;
case 'b':
params.emplace_back(va_arg(args, int));
break;
default:
throw runtime_error("C++ call: Unknown argument identifier " + c);
}
}
}
catch (...)
{
va_end(args);
throw;
}
va_end(args);
}

@ -1,3 +1,7 @@
//
// Created by koncord on 04.03.17.
//
#ifndef OPENMW_UTILS_HPP
#define OPENMW_UTILS_HPP
@ -5,8 +9,6 @@
#include <regex>
#include <vector>
#include <boost/any.hpp>
#include <components/esm/loadcell.hpp>
#include <components/openmw-mp/Utils.hpp>
@ -23,9 +25,7 @@ namespace Utils
{
const std::vector<std::string> split(const std::string &str, int delimiter);
ESM::Cell getCellFromDescription(std::string cellDescription);
void getArguments(std::vector<boost::any> &params, va_list args, const std::string &def);
ESM::Cell getCellFromDescription(const std::string &cellDescription);
template<size_t N>
constexpr unsigned int hash(const char(&str)[N], size_t I = N)

@ -25,7 +25,7 @@
#include "MasterClient.hpp"
#include "Utils.hpp"
#include <apps/openmw-mp/Script/Script.hpp>
#include <apps/openmw-mp/Script/Plugin.hpp>
#ifdef ENABLE_BREAKPAD
#include <handler/exception_handler.h>
@ -196,24 +196,33 @@ int main(int argc, char *argv[])
string password = mgr.getString("password", "General");
string pluginHome = mgr.getString("home", "Plugins");
string dataDirectory = Utils::convertPath(pluginHome + "/data");
vector<string> plugins(Utils::split(mgr.getString("plugins", "Plugins"), ','));
Utils::printVersion("TES3MP dedicated server", TES3MP_VERSION, version.mCommitHash, TES3MP_PROTO_VERSION);
Script::SetModDir(dataDirectory);
#ifdef ENABLE_LUA
LangLua::AddPackagePath(Utils::convertPath(pluginHome + "/scripts/?.lua" + ";"
+ pluginHome + "/lib/lua/?.lua" + ";"));
#ifdef _WIN32
LangLua::AddPackageCPath(Utils::convertPath(pluginHome + "/lib/?.dll"));
#else
LangLua::AddPackageCPath(Utils::convertPath(pluginHome + "/lib/?.so"));
#endif
// Check for unmodified tes3mp-credits file; this makes it so people can't repackage official releases with
// their own made-up credits, though it obviously has no bearing on unofficial releases that change
// the checksum below
boost::filesystem::path folderPath(boost::filesystem::initial_path<boost::filesystem::path>());
folderPath = boost::filesystem::system_complete(boost::filesystem::path(argv[0])).remove_filename();
std::string creditsPath = folderPath.string() + "/tes3mp-credits";
#endif
unsigned int expectedChecksumInt = Utils::hexStrToInt(TES3MP_CREDITS_CHECKSUM);
bool hasValidCredits = Utils::doesFileHaveChecksum(creditsPath + ".md", expectedChecksumInt);
if (!hasValidCredits)
hasValidCredits = Utils::doesFileHaveChecksum(creditsPath + ".txt", expectedChecksumInt);
if (!hasValidCredits)
{
LOG_MESSAGE_SIMPLE(Log::LOG_FATAL, "The server is shutting down");
LOG_APPEND(Log::LOG_FATAL, "- %s", TES3MP_CREDITS_ERROR);
return 1;
}
Plugin::SetModDir(Utils::convertPath(pluginHome + "/data"));
Plugin::SetPluginDir(Utils::convertPath(pluginHome + "/scripts"));
int code;
@ -236,8 +245,8 @@ int main(int argc, char *argv[])
try
{
for (auto plugin : plugins)
Script::LoadScript(plugin.c_str(), pluginHome.c_str());
for (const auto &plugin : plugins)
Plugin::LoadPlugin(Utils::convertPath(pluginHome + "/scripts/" + plugin));
switch (peer->Startup((unsigned) players, &sd, 1))
{
@ -289,13 +298,15 @@ int main(int argc, char *argv[])
}
networking.InitQuery(masterAddr, (unsigned short) masterPort);
networking.getMasterClient()->SetMaxPlayers((unsigned) players);
networking.getMasterClient()->SetUpdateRate((unsigned) updateRate);
auto masterClient = networking.getMasterClient();
masterClient->SetMaxPlayers((unsigned) players);
masterClient->SetUpdateRate((unsigned) updateRate);
string hostname = mgr.getString("hostname", "General");
networking.getMasterClient()->SetHostname(hostname);
networking.getMasterClient()->SetRuleString("CommitHash", version.mCommitHash.substr(0, 10));
masterClient->SetHostname(hostname);
masterClient->SetRuleString("CommitHash", version.mCommitHash.substr(0, 10));
networking.getMasterClient()->Start();
masterClient->Start();
}
networking.postInit();
@ -307,7 +318,6 @@ int main(int argc, char *argv[])
catch (std::exception &e)
{
LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, e.what());
Script::Call<Script::CallbackIdentity("OnServerScriptCrash")>(e.what());
throw; //fall through
}

@ -31,7 +31,7 @@ bool ActorProcessor::Process(RakNet::Packet &packet, BaseActorList &actorList) n
if (!processor.second->avoidReading)
myPacket->Read();
if (actorList.isValid)
if (actorList.isValid) // -V547
processor.second->Do(*myPacket, *player, actorList);
else
LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, "Received %s that failed integrity check and was ignored!", processor.second->strPacketID.c_str());

@ -6,7 +6,6 @@
#include <components/openmw-mp/Packets/BasePacket.hpp>
#include <components/openmw-mp/Packets/Actor/ActorPacket.hpp>
#include <components/openmw-mp/NetworkMessages.hpp>
#include "Script/Script.hpp"
#include "Player.hpp"
namespace mwmp

@ -31,7 +31,7 @@ bool ObjectProcessor::Process(RakNet::Packet &packet, BaseObjectList &objectList
if (!processor.second->avoidReading)
myPacket->Read();
if (objectList.isValid)
if (objectList.isValid) // -V547 (PVS Studio false-positive warning)
processor.second->Do(*myPacket, *player, objectList);
else
LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, "Received %s that failed integrity check and was ignored!", processor.second->strPacketID.c_str());

@ -6,7 +6,6 @@
#include <components/openmw-mp/Packets/BasePacket.hpp>
#include <components/openmw-mp/Packets/Object/ObjectPacket.hpp>
#include <components/openmw-mp/NetworkMessages.hpp>
#include "Script/Script.hpp"
#include "Player.hpp"
namespace mwmp

@ -1,7 +1,6 @@
#include "ProcessorInitializer.hpp"
#include "Networking.hpp"
#include "Script/Script.hpp"
#include "PlayerProcessor.hpp"
#include "player/ProcessorChatMsg.hpp"

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save