[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
0.8.0-dev
Koncord 6 years ago
parent a9701028a2
commit 4ca5da5666

@ -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
Script/LangLua/LangLua.hpp)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_LUA")
include_directories(SYSTEM ${LuaJit_INCLUDE_DIRS} SYSTEM ${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,20 +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/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.h 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})
@ -154,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)
@ -161,7 +133,7 @@ if (OPENMW_MP_BUILD)
endif()
set_target_properties(tes3mp-server PROPERTIES
CXX_STANDARD 14
CXX_STANDARD 17
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS YES
)
@ -203,6 +175,11 @@ if (MSVC)
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

@ -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,9 +49,12 @@ 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)
@ -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;

@ -3,7 +3,7 @@
#include <iostream>
#include "Cell.hpp"
#include "Player.hpp"
#include "Script/Script.hpp"
#include "Script/Plugin.hpp"
using namespace std;
@ -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;

@ -105,7 +105,7 @@ void MasterClient::SetRuleValue(const std::string &key, double value)
mutexData.unlock();
}
void MasterClient::PushPlugin(const Plugin &plugin)
void MasterClient::PushPlugin(const _Plugin &plugin)
{
mutexData.lock();
queryData.plugins.push_back(plugin);

@ -26,7 +26,7 @@ public:
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);
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();
@ -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
{
@ -368,7 +368,7 @@ 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;
}
@ -585,8 +585,8 @@ void Networking::InitQuery(const std::string &queryAddr, unsigned short queryPor
void Networking::postInit()
{
Script::Call<Script::CallbackIdentity("OnServerPostInit")>();
Script::Call<Script::CallbackIdentity("OnRequestPluginList")>();
Plugin::Call<CallbackIndex("OnServerPostInit")>();
Plugin::Call<CallbackIndex("OnRequestPluginList")>();
}
PacketPreInit::PluginContainer &Networking::getSamples()

@ -70,7 +70,7 @@ unsigned short Players::getLastPlayerId()
return slots.rbegin()->first;
}
Player::Player(const RakNet::RakNetGUID &guid) : BasePlayer(guid), id(InvalidID)
Player::Player(const RakNet::RakNetGUID &guid) : BasePlayer(guid), id(InvalidPID)
{
handshakeCounter = 0;
loadState = NOTLOADED;
@ -81,7 +81,7 @@ Player::~Player()
}
unsigned int Player::getId()
PlayerId Player::getId()
{
return id;
}

@ -20,6 +20,7 @@
#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;
@ -45,7 +46,6 @@ class Player : public mwmp::BasePlayer
{
friend class Cell;
public:
const unsigned int InvalidID = (unsigned int) -1;
enum
{
NOTLOADED=0,
@ -55,7 +55,7 @@ public:
};
Player(const RakNet::RakNetGUID &guid);
unsigned int getId();
PlayerId getId();
void setId(unsigned short id);
bool isHandshaked();

@ -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,18 +61,14 @@ 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()

@ -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), args(args)
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;
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), args(args)
Timer::~Timer()
{
startTime = 0;
targetMsec = msec;
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, const 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;
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, const 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,28 @@
//
// 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 __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
#define bool uint8_t
#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,7 +4,7 @@
#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>
@ -38,7 +38,7 @@ extern "C" void ActorFunctions::ClearActorList() noexcept
writeActorList.baseActors.clear();
}
extern "C" void ActorFunctions::SetActorListPid(unsigned short pid) noexcept
extern "C" void ActorFunctions::SetActorListPid(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -321,7 +321,7 @@ extern "C" void ActorFunctions::SetActorAIAction(unsigned int action) noexcept
tempActor.aiAction = action;
}
extern "C" void ActorFunctions::SetActorAITargetToPlayer(unsigned short pid) noexcept
extern "C" void ActorFunctions::SetActorAITargetToPlayer(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -528,7 +528,7 @@ void ActorFunctions::ReadLastActorList() noexcept
ReadReceivedActorList();
}
extern "C" void ActorFunctions::InitializeActorList(unsigned short pid) noexcept
extern "C" void ActorFunctions::InitializeActorList(PlayerId pid) noexcept
{
ClearActorList();
SetActorListPid(pid);

@ -3,114 +3,13 @@
#include "../api.h"
#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}
NAMESPACE_BEGIN(ActorFunctions)
/**
* \brief Use the last actor list received by the server as the one being read.
*
* \return void
*/
API_FUNCTION void CDECL ReadReceivedActorList() noexcept;
API_FUNCTION void CDECL ReadReceivedActorList() NOEXCEPT;
/**
* \brief Use the temporary actor list stored for a cell as the one being read.
@ -121,14 +20,14 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param cellDescription The description of the cell whose actor list should be read.
* \return void
*/
API_FUNCTION void CDECL 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
*/
API_FUNCTION void CDECL ClearActorList() noexcept;
API_FUNCTION void CDECL ClearActorList() NOEXCEPT;
/**
* \brief Set the pid attached to the ActorList.
@ -136,7 +35,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param pid The player ID to whom the actor list should be attached.
* \return void
*/
API_FUNCTION void CDECL 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
@ -145,21 +44,21 @@ NAMESPACE_BEGIN(ActorFunctions)
*
* \return void
*/
API_FUNCTION void CDECL CopyReceivedActorListToStore() noexcept;
API_FUNCTION void CDECL CopyReceivedActorListToStore() NOEXCEPT;
/**
* \brief Get the number of indexes in the read actor list.
*
* \return The number of indexes.
*/
API_FUNCTION unsigned int CDECL 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).
*/
API_FUNCTION unsigned char CDECL 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.
@ -167,7 +66,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param index The index of the actor.
* \return The cell description.
*/
API_FUNCTION const char *CDECL 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.
@ -175,7 +74,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param index The index of the actor.
* \return The refId.
*/
API_FUNCTION const char *CDECL 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.
@ -183,7 +82,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param index The index of the actor.
* \return The refNum.
*/
API_FUNCTION unsigned int CDECL 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.
@ -191,7 +90,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param index The index of the actor.
* \return The mpNum.
*/
API_FUNCTION unsigned int CDECL 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.
@ -199,7 +98,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param index The index of the actor.
* \return The X position.
*/
API_FUNCTION double CDECL 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.
@ -207,7 +106,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param index The index of the actor.
* \return The Y position.
*/
API_FUNCTION double CDECL 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.
@ -215,7 +114,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param index The index of the actor.
* \return The Z position.
*/
API_FUNCTION double CDECL 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.
@ -223,7 +122,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param index The index of the actor.
* \return The X rotation.
*/
API_FUNCTION double CDECL 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.
@ -231,7 +130,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param index The index of the actor.
* \return The Y rotation.
*/
API_FUNCTION double CDECL 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.
@ -239,7 +138,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param index The index of the actor.
* \return The Z rotation.
*/
API_FUNCTION double CDECL 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.
@ -247,7 +146,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param index The index of the actor.
* \return The base health.
*/
API_FUNCTION double CDECL 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.
@ -255,7 +154,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param index The index of the actor.
* \return The current health.
*/
API_FUNCTION double CDECL 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.
@ -263,7 +162,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param index The index of the actor.
* \return The modified health.
*/
API_FUNCTION double CDECL 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.
@ -271,7 +170,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param index The index of the actor.
* \return The base magicka.
*/
API_FUNCTION double CDECL 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.
@ -279,7 +178,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param index The index of the actor.
* \return The current magicka.
*/
API_FUNCTION double CDECL 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.
@ -287,7 +186,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param index The index of the actor.
* \return The modified magicka.
*/
API_FUNCTION double CDECL 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.
@ -295,7 +194,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param index The index of the actor.
* \return The base fatigue.
*/
API_FUNCTION double CDECL 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.
@ -303,7 +202,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param index The index of the actor.
* \return The current fatigue.
*/
API_FUNCTION double CDECL 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.
@ -311,7 +210,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param index The index of the actor.
* \return The modified fatigue.
*/
API_FUNCTION double CDECL 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
@ -321,7 +220,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param slot The slot of the equipment item.
* \return The refId.
*/
API_FUNCTION const char *CDECL 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
@ -331,7 +230,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param slot The slot of the equipment item.
* \return The item count.
*/
API_FUNCTION int CDECL 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
@ -341,7 +240,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param slot The slot of the equipment item.
* \return The charge.
*/
API_FUNCTION int CDECL 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
@ -351,7 +250,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param slot The slot of the equipment item.
* \return The enchantment charge.
*/
API_FUNCTION double CDECL 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.
@ -359,7 +258,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param index The index of the actor.
* \return Whether the actor was killed by a player.
*/
API_FUNCTION bool CDECL 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.
@ -367,7 +266,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param index The index of the actor.
* \return The player ID of the killer.
*/
API_FUNCTION int CDECL 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.
@ -375,7 +274,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param index The index of the actor.
* \return The refId of the killer.
*/
API_FUNCTION const char *CDECL 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.
@ -383,7 +282,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param index The index of the actor.
* \return The refNum of the killer.
*/
API_FUNCTION unsigned int CDECL 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.
@ -391,7 +290,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param index The index of the actor.
* \return The mpNum of the killer.
*/
API_FUNCTION unsigned int CDECL 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.
@ -399,7 +298,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param index The index of the actor.
* \return The name of the killer.
*/
API_FUNCTION const char *CDECL 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
@ -410,7 +309,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param index The index of the actor.
* \return Whether the read actor list contains positional data.
*/
API_FUNCTION bool CDECL 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
@ -421,7 +320,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param index The index of the actor.
* \return Whether the read actor list contains dynamic stats data.
*/
API_FUNCTION bool CDECL 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.
@ -432,7 +331,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param cellDescription The description of the cell.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -440,7 +339,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param action The action type (0 for SET, 1 for ADD, 2 for REMOVE, 3 for REQUEST).
* \return void
*/
API_FUNCTION void CDECL 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.
@ -454,7 +353,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param cellDescription The description of the cell.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -462,7 +361,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param refId The refId.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -470,7 +369,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param refNum The refNum.
* \return void
*/
API_FUNCTION void CDECL SetActorRefNum(int refNum) noexcept;
API_FUNCTION void CDECL SetActorRefNum(int refNum) NOEXCEPT;
/**
* \brief Set the mpNum of the temporary actor stored on the server.
@ -478,7 +377,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param mpNum The mpNum.
* \return void
*/
API_FUNCTION void CDECL SetActorMpNum(int mpNum) noexcept;
API_FUNCTION void CDECL SetActorMpNum(int mpNum) NOEXCEPT;
/**
* \brief Set the position of the temporary actor stored on the server.
@ -488,7 +387,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param z The Z position.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -498,7 +397,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param z The Z rotation.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -506,7 +405,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param value The new value.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -514,7 +413,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param value The new value.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -522,7 +421,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param value The new value.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -530,7 +429,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param value The new value.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -538,7 +437,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param value The new value.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -546,7 +445,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param value The new value.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -554,7 +453,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param value The new value.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -562,7 +461,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param value The new value.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -570,7 +469,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param value The new value.
* \return void
*/
API_FUNCTION void CDECL SetActorFatigueModified(double value) noexcept;
API_FUNCTION void CDECL SetActorFatigueModified(double value) NOEXCEPT;
/**
* \brief Set the sound of the temporary actor stored on the server.
@ -578,7 +477,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param sound The sound.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -586,7 +485,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param action The new action.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -594,7 +493,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param pid The player ID.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -603,7 +502,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param mpNum The mpNum of the target object.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -613,7 +512,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param z The Z coordinate.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -621,7 +520,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param duration The distance of the package.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -629,7 +528,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param duration The duration of the package.
* \return void
*/
API_FUNCTION void CDECL SetActorAIDuration(unsigned int duration) noexcept;
API_FUNCTION void CDECL SetActorAIDuration(unsigned int duration) NOEXCEPT;
/**
* \brief Set whether the current AI package should be repeated.
@ -639,7 +538,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param shouldRepeat Whether the package should be repeated.
* \return void
*/
API_FUNCTION void CDECL 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
@ -652,7 +551,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param enchantmentCharge The enchantment charge of the item.
* \return void
*/
API_FUNCTION void CDECL 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
@ -661,7 +560,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* \param slot The equipment slot.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -671,7 +570,7 @@ NAMESPACE_BEGIN(ActorFunctions)
*
* \return void
*/
API_FUNCTION void CDECL AddActor() noexcept;
API_FUNCTION void CDECL AddActor() NOEXCEPT;
/**
* \brief Send an ActorList packet.
@ -680,7 +579,7 @@ NAMESPACE_BEGIN(ActorFunctions)
*
* \return void
*/
API_FUNCTION void CDECL SendActorList() noexcept;
API_FUNCTION void CDECL SendActorList() NOEXCEPT;
/**
* \brief Send an ActorAuthority packet.
@ -692,7 +591,7 @@ NAMESPACE_BEGIN(ActorFunctions)
*
* \return void
*/
API_FUNCTION void CDECL SendActorAuthority() noexcept;
API_FUNCTION void CDECL SendActorAuthority() NOEXCEPT;
/**
* \brief Send an ActorPosition packet.
@ -704,7 +603,7 @@ NAMESPACE_BEGIN(ActorFunctions)
*
* \return void
*/
API_FUNCTION void CDECL SendActorPosition(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendActorPosition(bool sendToOtherVisitors, bool skipAttachedPlayer) NOEXCEPT;
/**
* \brief Send an ActorStatsDynamic packet.
@ -716,7 +615,7 @@ NAMESPACE_BEGIN(ActorFunctions)
*
* \return void
*/
API_FUNCTION void CDECL SendActorStatsDynamic(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendActorStatsDynamic(bool sendToOtherVisitors, bool skipAttachedPlayer) NOEXCEPT;
/**
* \brief Send an ActorEquipment packet.
@ -728,7 +627,7 @@ NAMESPACE_BEGIN(ActorFunctions)
*
* \return void
*/
API_FUNCTION void CDECL SendActorEquipment(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendActorEquipment(bool sendToOtherVisitors, bool skipAttachedPlayer) NOEXCEPT;
/**
* \brief Send an ActorSpeech packet.
@ -739,7 +638,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* to the packet (false by default).
* \return void
*/
API_FUNCTION void CDECL SendActorSpeech(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendActorSpeech(bool sendToOtherVisitors, bool skipAttachedPlayer) NOEXCEPT;
/**
* \brief Send an ActorAI packet.
@ -750,7 +649,7 @@ NAMESPACE_BEGIN(ActorFunctions)
* to the packet (false by default).
* \return void
*/
API_FUNCTION void CDECL SendActorAI(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendActorAI(bool sendToOtherVisitors, bool skipAttachedPlayer) NOEXCEPT;
/**
* \brief Send an ActorCellChange packet.
@ -762,17 +661,17 @@ NAMESPACE_BEGIN(ActorFunctions)
*
* \return void
*/
API_FUNCTION void CDECL 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
API_FUNCTION void CDECL ReadLastActorList() noexcept;
API_FUNCTION void CDECL InitializeActorList(unsigned short 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;
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()

@ -2,12 +2,12 @@
#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;
extern "C" 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 @@ extern "C" void BookFunctions::ClearBookChanges(unsigned short pid) noexcept
player->bookChanges.books.clear();
}
extern "C" 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 @@ extern "C" unsigned int BookFunctions::GetBookChangesSize(unsigned short pid) no
return player->bookChanges.count;
}
extern "C" 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 @@ extern "C" void BookFunctions::AddBook(unsigned short pid, const char* bookId) n
player->bookChanges.books.push_back(book);
}
extern "C" 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 @@ extern "C" const char *BookFunctions::GetBookId(unsigned short pid, unsigned int
return player->bookChanges.books.at(index).bookId.c_str();
}
extern "C" 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 @@ extern "C" void BookFunctions::SendBookChanges(unsigned short pid, bool sendToOt
// All methods below are deprecated versions of methods from above
extern "C" void BookFunctions::InitializeBookChanges(unsigned short pid) noexcept
extern "C" void BookFunctions::InitializeBookChanges(PlayerId pid) noexcept
{
ClearBookChanges(pid);
}

@ -3,19 +3,6 @@
#include "../api.h"
#define BOOKAPI \
{"ClearBookChanges", BookFunctions::ClearBookChanges},\
\
{"GetBookChangesSize", BookFunctions::GetBookChangesSize},\
\
{"AddBook", BookFunctions::AddBook},\
\
{"GetBookId", BookFunctions::GetBookId},\
\
{"SendBookChanges", BookFunctions::SendBookChanges},\
\
{"InitializeBookChanges", BookFunctions::InitializeBookChanges}
NAMESPACE_BEGIN(BookFunctions)
/**
@ -26,7 +13,7 @@ NAMESPACE_BEGIN(BookFunctions)
* \param pid The player ID whose book changes should be used.
* \return void
*/
API_FUNCTION void CDECL 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 @@ NAMESPACE_BEGIN(BookFunctions)
* \param pid The player ID whose book changes should be used.
* \return The number of indexes.
*/
API_FUNCTION unsigned int CDECL 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 @@ NAMESPACE_BEGIN(BookFunctions)
* \param bookId The bookId of the book.
* \return void
*/
API_FUNCTION void CDECL 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 @@ NAMESPACE_BEGIN(BookFunctions)
* \param index The index of the book.
* \return The bookId.
*/
API_FUNCTION const char *CDECL 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,11 +51,11 @@ NAMESPACE_BEGIN(BookFunctions)
* to the packet (false by default).
* \return void
*/
API_FUNCTION void CDECL 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
API_FUNCTION void CDECL InitializeBookChanges(unsigned short pid) noexcept;
API_FUNCTION void CDECL InitializeBookChanges(PlayerId pid) NOEXCEPT;
NAMESPACE_END()
#endif //OPENMW_BOOKAPI_HPP

@ -3,7 +3,7 @@
#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;
extern "C" 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 @@ extern "C" unsigned int CellFunctions::GetCellStateChangesSize(unsigned short pi
return player->cellStateChanges.count;
}
extern "C" 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 @@ extern "C" unsigned int CellFunctions::GetCellStateType(unsigned short pid, unsi
return player->cellStateChanges.cellStates.at(index).type;
}
extern "C" 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,7 +40,7 @@ extern "C" const char *CellFunctions::GetCellStateDescription(unsigned short pid
return tempCellDescription.c_str();
}
extern "C" const char *CellFunctions::GetCell(unsigned short pid) noexcept
extern "C" const char *CellFunctions::GetCell(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -49,21 +49,21 @@ extern "C" const char *CellFunctions::GetCell(unsigned short pid) noexcept
return tempCellDescription.c_str();
}
extern "C" 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;
}
extern "C" 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;
}
extern "C" 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 @@ extern "C" bool CellFunctions::IsInExterior(unsigned short pid) noexcept
return player->cell.isExterior();
}
extern "C" 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 @@ extern "C" const char *CellFunctions::GetRegion(unsigned short pid) noexcept
return player->cell.mRegion.c_str();
}
extern "C" 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 @@ extern "C" bool CellFunctions::IsChangingRegion(unsigned short pid) noexcept
return player->isChangingRegion;
}
extern "C" 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 @@ extern "C" void CellFunctions::SetCell(unsigned short pid, const char *cellDescr
player->cell = Utils::getCellFromDescription(cellDescription);
}
extern "C" 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 @@ extern "C" void CellFunctions::SetExteriorCell(unsigned short pid, int x, int y)
player->cell.mData.mY = y;
}
extern "C" void CellFunctions::SendCell(unsigned short pid) noexcept
extern "C" void CellFunctions::SendCell(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );

@ -1,30 +1,8 @@
#ifndef OPENMW_CELLAPI_HPP
#define OPENMW_CELLAPI_HPP
#include "../Types.hpp"
#include "../api.h"
#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}
NAMESPACE_BEGIN(CellFunctions)
/**
* \brief Get the number of indexes in a player's latest cell state changes.
@ -32,7 +10,7 @@ NAMESPACE_BEGIN(CellFunctions)
* \param pid The player ID whose cell state changes should be used.
* \return The number of indexes.
*/
API_FUNCTION unsigned int CDECL 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.
@ -41,7 +19,7 @@ NAMESPACE_BEGIN(CellFunctions)
* \param index The index of the cell state.
* \return The cell state type (0 for LOAD, 1 for UNLOAD).
*/
API_FUNCTION unsigned int CDECL 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.
@ -50,7 +28,7 @@ NAMESPACE_BEGIN(CellFunctions)
* \param index The index of the cell state.
* \return The cell description.
*/
API_FUNCTION const char *CDECL 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.
@ -58,7 +36,7 @@ NAMESPACE_BEGIN(CellFunctions)
* \param pid The player ID.
* \return The cell description.
*/
API_FUNCTION const char *CDECL 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.
@ -66,7 +44,7 @@ NAMESPACE_BEGIN(CellFunctions)
* \param pid The player ID.
* \return The X coordinate of the cell.
*/
API_FUNCTION int CDECL GetExteriorX(unsigned short pid) noexcept;
API_FUNCTION int CDECL GetExteriorX(PlayerId pid) NOEXCEPT;
/**
* \brief Get the Y coordinate of the player's exterior cell.
@ -74,7 +52,7 @@ NAMESPACE_BEGIN(CellFunctions)
* \param pid The player ID.
* \return The Y coordinate of the cell.
*/
API_FUNCTION int CDECL 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.
@ -82,7 +60,7 @@ NAMESPACE_BEGIN(CellFunctions)
* \param pid The player ID.
* \return Whether the player is in an exterior cell.
*/
API_FUNCTION bool CDECL IsInExterior(unsigned short pid) noexcept;
API_FUNCTION bool CDECL IsInExterior(PlayerId pid) NOEXCEPT;
/**
* \brief Get the region of the player's exterior cell.
@ -92,7 +70,7 @@ NAMESPACE_BEGIN(CellFunctions)
* \param pid The player ID.
* \return The region.
*/
API_FUNCTION const char *CDECL 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.
@ -100,7 +78,7 @@ NAMESPACE_BEGIN(CellFunctions)
* \param pid The player ID.
* \return Whether the player has changed their region.
*/
API_FUNCTION bool CDECL IsChangingRegion(unsigned short pid) noexcept;
API_FUNCTION bool CDECL IsChangingRegion(PlayerId pid) NOEXCEPT;
/**
* \brief Set the cell of a player.
@ -115,7 +93,7 @@ NAMESPACE_BEGIN(CellFunctions)
* \param cellDescription The cell description.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -128,7 +106,7 @@ NAMESPACE_BEGIN(CellFunctions)
* \param y The Y coordinate of the cell.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -138,7 +116,7 @@ NAMESPACE_BEGIN(CellFunctions)
* \param pid The player ID.
* \return void
*/
API_FUNCTION void CDECL SendCell(unsigned short pid) noexcept;
API_FUNCTION void CDECL SendCell(PlayerId pid) NOEXCEPT;
NAMESPACE_END()
#endif //OPENMW_CELLAPI_HPP

@ -7,12 +7,12 @@
#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;
extern "C" 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 @@ extern "C" const char *CharClassFunctions::GetDefaultClass(unsigned short pid) n
return player->charClass.mId.c_str();
}
extern "C" 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 @@ extern "C" const char *CharClassFunctions::GetClassName(unsigned short pid) noex
return player->charClass.mName.c_str();
}
extern "C" 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 @@ extern "C" const char *CharClassFunctions::GetClassDesc(unsigned short pid) noex
return player->charClass.mDescription.c_str();
}
extern "C" 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 @@ extern "C" int CharClassFunctions::GetClassMajorAttribute(unsigned short pid, un
return player->charClass.mData.mAttribute[slot];
}
extern "C" 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 @@ extern "C" int CharClassFunctions::GetClassSpecialization(unsigned short pid) no
return player->charClass.mData.mSpecialization;
}
extern "C" 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 @@ extern "C" int CharClassFunctions::GetClassMajorSkill(unsigned short pid, unsign
return player->charClass.mData.mSkills[slot][1];
}
extern "C" 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 @@ extern "C" int CharClassFunctions::GetClassMinorSkill(unsigned short pid, unsign
return player->charClass.mData.mSkills[slot][0];
}
extern "C" int CharClassFunctions::IsClassDefault(unsigned short pid) noexcept
extern "C" int CharClassFunctions::IsClassDefault(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -85,7 +85,7 @@ extern "C" int CharClassFunctions::IsClassDefault(unsigned short pid) noexcept
return !player->charClass.mId.empty(); // true if default
}
extern "C" 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,);
@ -93,7 +93,7 @@ extern "C" void CharClassFunctions::SetDefaultClass(unsigned short pid, const ch
player->charClass.mId = id;
}
extern "C" 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,);
@ -102,7 +102,7 @@ extern "C" void CharClassFunctions::SetClassName(unsigned short pid, const char
player->charClass.mId.clear();
}
extern "C" 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,);
@ -110,7 +110,7 @@ extern "C" void CharClassFunctions::SetClassDesc(unsigned short pid, const char
player->charClass.mDescription = desc;
}
extern "C" 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,);
@ -122,7 +122,7 @@ extern "C" void CharClassFunctions::SetClassMajorAttribute(unsigned short pid, u
}
extern "C" 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,);
@ -130,7 +130,7 @@ extern "C" void CharClassFunctions::SetClassSpecialization(unsigned short pid, i
player->charClass.mData.mSpecialization = spec;
}
extern "C" 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,);
@ -141,7 +141,7 @@ extern "C" void CharClassFunctions::SetClassMajorSkill(unsigned short pid, unsig
player->charClass.mData.mSkills[slot][1] = skillId;
}
extern "C" 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,);
@ -152,7 +152,7 @@ extern "C" void CharClassFunctions::SetClassMinorSkill(unsigned short pid, unsig
player->charClass.mData.mSkills[slot][0] = skillId;
}
extern "C" void CharClassFunctions::SendClass(unsigned short pid) noexcept
extern "C" void CharClassFunctions::SendClass(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );

@ -5,31 +5,8 @@
#ifndef OPENMW_CHARCLASSAPI_HPP
#define OPENMW_CHARCLASSAPI_HPP
#include "../Types.hpp"
#include "../api.h"
#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}
NAMESPACE_BEGIN(CharClassFunctions)
/**
* \brief Get the default class used by a player.
@ -37,7 +14,7 @@ NAMESPACE_BEGIN(CharClassFunctions)
* \param pid The player ID.
* \return The ID of the default class.
*/
API_FUNCTION const char *CDECL 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.
@ -45,7 +22,7 @@ NAMESPACE_BEGIN(CharClassFunctions)
* \param pid The player ID.
* \return The name of the custom class.
*/
API_FUNCTION const char *CDECL 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.
@ -53,7 +30,7 @@ NAMESPACE_BEGIN(CharClassFunctions)
* \param pid The player ID.
* \return The description of the custom class.
*/
API_FUNCTION const char *CDECL 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.
@ -62,7 +39,7 @@ NAMESPACE_BEGIN(CharClassFunctions)
* \param slot The slot of the major attribute (0 or 1).
* \return The ID of the major attribute.
*/
API_FUNCTION int CDECL 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.
@ -70,7 +47,7 @@ NAMESPACE_BEGIN(CharClassFunctions)
* \param pid The player ID.
* \return The specialization ID of the custom class (0 for Combat, 1 for Magic, 2 for Stealth).
*/
API_FUNCTION int CDECL 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.
@ -79,7 +56,7 @@ NAMESPACE_BEGIN(CharClassFunctions)
* \param slot The slot of the major skill (0 to 4).
* \return The ID of the major skill.
*/
API_FUNCTION int CDECL 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.
@ -88,7 +65,7 @@ NAMESPACE_BEGIN(CharClassFunctions)
* \param slot The slot of the minor skill (0 to 4).
* \return The ID of the minor skill.
*/
API_FUNCTION int CDECL 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.
@ -96,7 +73,7 @@ NAMESPACE_BEGIN(CharClassFunctions)
* \param pid The player ID.
* \return Whether the player is using a default class.
*/
API_FUNCTION int CDECL IsClassDefault(unsigned short pid) noexcept;
API_FUNCTION int CDECL IsClassDefault(PlayerId pid) NOEXCEPT;
/**
* \brief Set the default class used by a player.
@ -107,7 +84,7 @@ NAMESPACE_BEGIN(CharClassFunctions)
* \param id The ID of the default class.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -116,7 +93,7 @@ NAMESPACE_BEGIN(CharClassFunctions)
* \param name The name of the custom class.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -125,7 +102,7 @@ NAMESPACE_BEGIN(CharClassFunctions)
* \param desc The description of the custom class.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -135,7 +112,7 @@ NAMESPACE_BEGIN(CharClassFunctions)
* \param attrId The ID to use for the attribute.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -144,7 +121,7 @@ NAMESPACE_BEGIN(CharClassFunctions)
* \param spec The specialization ID to use (0 for Combat, 1 for Magic, 2 for Stealth).
* \return void
*/
API_FUNCTION void CDECL 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.
@ -154,7 +131,7 @@ NAMESPACE_BEGIN(CharClassFunctions)
* \param skillId The ID to use for the skill.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -164,7 +141,7 @@ NAMESPACE_BEGIN(CharClassFunctions)
* \param skillId The ID to use for the skill.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -174,7 +151,7 @@ NAMESPACE_BEGIN(CharClassFunctions)
* \param pid The player ID.
* \return void
*/
API_FUNCTION void CDECL SendClass(unsigned short pid) noexcept;
API_FUNCTION void CDECL SendClass(PlayerId pid) NOEXCEPT;
NAMESPACE_END()
#endif //OPENMW_CHARCLASSAPI_HPP

@ -3,10 +3,10 @@
#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>
extern "C" 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 @@ extern "C" void ChatFunctions::SendMessage(unsigned short pid, const char *messa
packet->Send(true);
}
extern "C" void ChatFunctions::CleanChatForPid(unsigned short pid)
extern "C" void ChatFunctions::CleanChatForPid(PlayerId pid)
{
Player *player;
GET_PLAYER(pid, player,);

@ -1,15 +1,8 @@
#ifndef OPENMW_CHATAPI_HPP
#define OPENMW_CHATAPI_HPP
#include "../Types.hpp"
#include "../api.h"
#define CHATAPI \
{"SendMessage", ChatFunctions::SendMessage},\
{"CleanChatForPid", ChatFunctions::CleanChat},\
{"CleanChat", ChatFunctions::CleanChatForPid}
NAMESPACE_BEGIN(ChatFunctions)
/**
* \brief Send a message to a certain player.
@ -22,7 +15,7 @@ NAMESPACE_BEGIN(ChatFunctions)
* to the packet (false by default).
* \return void
*/
API_FUNCTION void CDECL 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.
@ -30,7 +23,7 @@ NAMESPACE_BEGIN(ChatFunctions)
* \param pid The player ID.
* \return void
*/
API_FUNCTION void CDECL CleanChatForPid(unsigned short pid);
API_FUNCTION void CDECL CleanChatForPid(PlayerId pid);
/**
* \brief Remove all messages from chat for everyone on the server.

@ -2,12 +2,12 @@
#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;
extern "C" 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 @@ extern "C" void DialogueFunctions::ClearTopicChanges(unsigned short pid) noexcep
player->topicChanges.topics.clear();
}
extern "C" 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 @@ extern "C" unsigned int DialogueFunctions::GetTopicChangesSize(unsigned short pi
return player->topicChanges.count;
}
extern "C" 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 @@ extern "C" void DialogueFunctions::AddTopic(unsigned short pid, const char* topi
player->topicChanges.topics.push_back(topic);
}
extern "C" 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 @@ extern "C" const char *DialogueFunctions::GetTopicId(unsigned short pid, unsigne
return player->topicChanges.topics.at(index).topicId.c_str();
}
extern "C" 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 @@ extern "C" void DialogueFunctions::SendTopicChanges(unsigned short pid, bool sen
packet->Send(true);
}
extern "C" 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 @@ extern "C" void DialogueFunctions::PlayAnimation(unsigned short pid, const char*
player->sendToLoaded(packet);
}
extern "C" 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, );
@ -92,7 +92,7 @@ extern "C" void DialogueFunctions::PlaySpeech(unsigned short pid, const char* so
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);
}

@ -3,22 +3,6 @@
#include "../api.h"
#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}
NAMESPACE_BEGIN(DialogueFunctions)
/**
* \brief Clear the last recorded topic changes for a player.
@ -28,7 +12,7 @@ NAMESPACE_BEGIN(DialogueFunctions)
* \param pid The player ID whose topic changes should be used.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -36,7 +20,7 @@ NAMESPACE_BEGIN(DialogueFunctions)
* \param pid The player ID whose topic changes should be used.
* \return The number of indexes.
*/
API_FUNCTION unsigned int CDECL 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.
@ -45,7 +29,7 @@ NAMESPACE_BEGIN(DialogueFunctions)
* \param topicId The topicId of the topic.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -54,7 +38,7 @@ NAMESPACE_BEGIN(DialogueFunctions)
* \param index The index of the topic.
* \return The topicId.
*/
API_FUNCTION const char *CDECL 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.
@ -66,7 +50,7 @@ NAMESPACE_BEGIN(DialogueFunctions)
* to the packet (false by default).
* \return void
*/
API_FUNCTION void CDECL 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
@ -79,7 +63,7 @@ NAMESPACE_BEGIN(DialogueFunctions)
* \param bool Whether the animation should persist or not.
* \return void
*/
API_FUNCTION void CDECL 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
@ -89,11 +73,11 @@ NAMESPACE_BEGIN(DialogueFunctions)
* \param sound The path of the sound file.
* \return void
*/
API_FUNCTION void CDECL 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
API_FUNCTION void CDECL InitializeTopicChanges(unsigned short pid) noexcept;
API_FUNCTION void CDECL InitializeTopicChanges(PlayerId pid) NOEXCEPT;
NAMESPACE_END()
#endif //OPENMW_DIALOGUEAPI_HPP

@ -3,7 +3,7 @@
#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 = {};
extern "C" 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 @@ extern "C" void FactionFunctions::ClearFactionChanges(unsigned short pid) noexce
player->factionChanges.factions.clear();
}
extern "C" 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 @@ extern "C" unsigned int FactionFunctions::GetFactionChangesSize(unsigned short p
return player->factionChanges.count;
}
extern "C" 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 @@ extern "C" unsigned char FactionFunctions::GetFactionChangesAction(unsigned shor
return player->factionChanges.action;
}
extern "C" 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 @@ extern "C" const char *FactionFunctions::GetFactionId(unsigned short pid, unsign
return player->factionChanges.factions.at(index).factionId.c_str();
}
extern "C" 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 @@ extern "C" int FactionFunctions::GetFactionRank(unsigned short pid, unsigned int
return player->factionChanges.factions.at(index).rank;
}
extern "C" 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 @@ extern "C" bool FactionFunctions::GetFactionExpulsionState(unsigned short pid, u
return player->factionChanges.factions.at(index).isExpelled;
}
extern "C" 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 @@ extern "C" int FactionFunctions::GetFactionReputation(unsigned short pid, unsign
return player->factionChanges.factions.at(index).reputation;
}
extern "C" 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, );
@ -98,7 +98,7 @@ extern "C" void FactionFunctions::SetFactionReputation(int reputation) noexcept
tempFaction.reputation = reputation;
}
extern "C" 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 @@ extern "C" void FactionFunctions::AddFaction(unsigned short pid) noexcept
tempFaction = emptyFaction;
}
extern "C" 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, );
@ -124,7 +124,7 @@ extern "C" void FactionFunctions::SendFactionChanges(unsigned short pid, bool se
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);
}

@ -3,29 +3,6 @@
#include "../api.h"
#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}
NAMESPACE_BEGIN(FactionFunctions)
/**
* \brief Clear the last recorded faction changes for a player.
@ -35,7 +12,7 @@ NAMESPACE_BEGIN(FactionFunctions)
* \param pid The player ID whose faction changes should be used.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -43,7 +20,7 @@ NAMESPACE_BEGIN(FactionFunctions)
* \param pid The player ID whose faction changes should be used.
* \return The number of indexes.
*/
API_FUNCTION unsigned int CDECL 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.
@ -51,7 +28,7 @@ NAMESPACE_BEGIN(FactionFunctions)
* \param pid The player ID whose faction changes should be used.
* \return The action type (0 for RANK, 1 for EXPULSION, 2 for REPUTATION).
*/
API_FUNCTION unsigned char CDECL 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.
@ -60,7 +37,7 @@ NAMESPACE_BEGIN(FactionFunctions)
* \param index The index of the faction.
* \return The factionId.
*/
API_FUNCTION const char *CDECL 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.
@ -69,7 +46,7 @@ NAMESPACE_BEGIN(FactionFunctions)
* \param index The index of the faction.
* \return The rank.
*/
API_FUNCTION int CDECL 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.
@ -78,7 +55,7 @@ NAMESPACE_BEGIN(FactionFunctions)
* \param index The index of the faction.
* \return The expulsion state.
*/
API_FUNCTION bool CDECL 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.
@ -87,7 +64,7 @@ NAMESPACE_BEGIN(FactionFunctions)
* \param index The index of the faction.
* \return The reputation.
*/
API_FUNCTION int CDECL 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.
@ -96,7 +73,7 @@ NAMESPACE_BEGIN(FactionFunctions)
* \param action The action (0 for RANK, 1 for EXPULSION, 2 for REPUTATION).
* \return void
*/
API_FUNCTION void CDECL 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.
@ -104,7 +81,7 @@ NAMESPACE_BEGIN(FactionFunctions)
* \param factionId The factionId.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -112,7 +89,7 @@ NAMESPACE_BEGIN(FactionFunctions)
* \param rank The rank.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -120,7 +97,7 @@ NAMESPACE_BEGIN(FactionFunctions)
* \param expulsionState The expulsion state.
* \return void
*/
API_FUNCTION void CDECL SetFactionExpulsionState(bool expulsionState) noexcept;
API_FUNCTION void CDECL SetFactionExpulsionState(bool expulsionState) NOEXCEPT;
/**
* \brief Set the reputation of the temporary faction stored on the server.
@ -128,7 +105,7 @@ NAMESPACE_BEGIN(FactionFunctions)
* \param reputation The reputation.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -139,7 +116,7 @@ NAMESPACE_BEGIN(FactionFunctions)
* \param pid The player ID whose faction changes should be used.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -151,11 +128,11 @@ NAMESPACE_BEGIN(FactionFunctions)
* to the packet (false by default).
* \return void
*/
API_FUNCTION void CDECL 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
API_FUNCTION void CDECL InitializeFactionChanges(unsigned short pid) noexcept;
API_FUNCTION void CDECL InitializeFactionChanges(PlayerId pid) NOEXCEPT;
NAMESPACE_END()
#endif //OPENMW_FACTIONAPI_HPP

@ -2,10 +2,10 @@
#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>
extern "C" 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 @@ extern "C" void GUIFunctions::_MessageBox(unsigned short pid, int id, const char
packet->Send(false);
}
extern "C" 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 @@ extern "C" void GUIFunctions::CustomMessageBox(unsigned short pid, int id, const
packet->Send(false);
}
extern "C" 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 @@ extern "C" void GUIFunctions::InputDialog(unsigned short pid, int id, const char
packet->Send(false);
}
extern "C" 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 @@ extern "C" void GUIFunctions::PasswordDialog(unsigned short pid, int id, const c
packet->Send(false);
}
extern "C" 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 @@ extern "C" void GUIFunctions::ListBox(unsigned short pid, int id, const char *la
packet->Send(false);
}
extern "C" 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 @@ extern "C" void GUIFunctions::ClearQuickKeyChanges(unsigned short pid) noexcept
player->quickKeyChanges.quickKeys.clear();
}
extern "C" 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 @@ extern "C" unsigned int GUIFunctions::GetQuickKeyChangesSize(unsigned short pid)
return player->quickKeyChanges.count;
}
extern "C" 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 @@ extern "C" int GUIFunctions::GetQuickKeySlot(unsigned short pid, unsigned int in
return player->quickKeyChanges.quickKeys.at(index).slot;
}
extern "C" 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 @@ extern "C" int GUIFunctions::GetQuickKeyType(unsigned short pid, unsigned int in
return player->quickKeyChanges.quickKeys.at(index).type;
}
extern "C" 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 @@ extern "C" const char *GUIFunctions::GetQuickKeyItemId(unsigned short pid, unsig
return player->quickKeyChanges.quickKeys.at(index).itemId.c_str();
}
extern "C" 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 @@ extern "C" void GUIFunctions::AddQuickKey(unsigned short pid, unsigned short slo
player->quickKeyChanges.quickKeys.push_back(quickKey);
}
extern "C" void GUIFunctions::SendQuickKeyChanges(unsigned short pid) noexcept
extern "C" void GUIFunctions::SendQuickKeyChanges(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -167,7 +167,7 @@ extern "C" void GUIFunctions::SetMapVisibilityAll(unsigned short targetPid, unsi
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);
}

@ -3,30 +3,6 @@
#include "../api.h"
#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}
NAMESPACE_BEGIN(GUIFunctions)
/**
* \brief Display a simple messagebox at the bottom of the screen that vanishes
@ -40,7 +16,7 @@ NAMESPACE_BEGIN(GUIFunctions)
* \param label The text in the messagebox.
* \return void
*/
API_FUNCTION void CDECL _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
@ -52,7 +28,7 @@ NAMESPACE_BEGIN(GUIFunctions)
* \parm buttons The captions of the buttons, separated by semicolons (e.g. "Yes;No;Maybe").
* \return void
*/
API_FUNCTION void CDECL 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.
@ -63,7 +39,7 @@ NAMESPACE_BEGIN(GUIFunctions)
* \parm note The text at the bottom of the input dialog.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -77,7 +53,7 @@ NAMESPACE_BEGIN(GUIFunctions)
* \parm note The text at the bottom of the password dialog.
* \return void
*/
API_FUNCTION void CDECL 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
@ -90,7 +66,7 @@ NAMESPACE_BEGIN(GUIFunctions)
* \parm items The items in the listbox, separated by newlines (e.g. "Item 1\nItem 2").
* \return void
*/
API_FUNCTION void CDECL 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.
@ -100,7 +76,7 @@ NAMESPACE_BEGIN(GUIFunctions)
* \param pid The player ID whose quick key changes should be used.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -108,7 +84,7 @@ NAMESPACE_BEGIN(GUIFunctions)
* \param pid The player ID whose quick key changes should be used.
* \return The number of indexes.
*/
API_FUNCTION unsigned int CDECL 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.
@ -119,7 +95,7 @@ NAMESPACE_BEGIN(GUIFunctions)
* \param itemId The itemId of the item.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -128,7 +104,7 @@ NAMESPACE_BEGIN(GUIFunctions)
* \param index The index of the quick key in the quick key changes vector.
* \return The slot.
*/
API_FUNCTION int CDECL 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.
@ -137,7 +113,7 @@ NAMESPACE_BEGIN(GUIFunctions)
* \param index The index of the quick key in the quick key changes vector.
* \return The quick key type.
*/
API_FUNCTION int CDECL 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.
@ -146,7 +122,7 @@ NAMESPACE_BEGIN(GUIFunctions)
* \param index The index of the quick key in the quick key changes vector.
* \return The itemId.
*/
API_FUNCTION const char *CDECL 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.
@ -154,7 +130,7 @@ NAMESPACE_BEGIN(GUIFunctions)
* \param pid The player ID whose quick key changes should be used.
* \return void
*/
API_FUNCTION void CDECL SendQuickKeyChanges(unsigned short pid) noexcept;
API_FUNCTION void CDECL SendQuickKeyChanges(PlayerId pid) NOEXCEPT;
//state 0 - disallow, 1 - allow
@ -168,7 +144,7 @@ NAMESPACE_BEGIN(GUIFunctions)
* \param state The state of the map marker (false to hide, true to reveal).
* \return void
*/
API_FUNCTION void CDECL 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.
@ -179,11 +155,11 @@ NAMESPACE_BEGIN(GUIFunctions)
* \param state The state of the map marker (false to hide, true to reveal).
* \return void
*/
API_FUNCTION void CDECL 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
API_FUNCTION void CDECL InitializeQuickKeyChanges(unsigned short pid) noexcept;
API_FUNCTION void CDECL InitializeQuickKeyChanges(PlayerId pid) NOEXCEPT;
NAMESPACE_END()
#endif //OPENMW_GUIAPI_HPP

@ -3,13 +3,13 @@
#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;
extern "C" void ItemFunctions::ClearInventoryChanges(unsigned short pid) noexcept
extern "C" void ItemFunctions::ClearInventoryChanges(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -22,7 +22,7 @@ extern "C" int ItemFunctions::GetEquipmentSize() noexcept
return MWWorld::InventoryStore::Slots;
}
extern "C" 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 @@ extern "C" unsigned int ItemFunctions::GetInventoryChangesSize(unsigned short pi
return player->inventoryChanges.count;
}
extern "C" 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 @@ extern "C" unsigned int ItemFunctions::GetInventoryChangesAction(unsigned short
return player->inventoryChanges.action;
}
extern "C" 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 @@ extern "C" void ItemFunctions::SetInventoryChangesAction(unsigned short pid, uns
player->inventoryChanges.action = action;
}
extern "C" 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 @@ extern "C" void ItemFunctions::EquipItem(unsigned short pid, unsigned short slot
player->equipmentIndexChanges.push_back(slot);
}
extern "C" 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 @@ extern "C" void ItemFunctions::UnequipItem(unsigned short pid, unsigned short sl
ItemFunctions::EquipItem(pid, slot, "", 0, -1, -1);
}
extern "C" 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 @@ extern "C" void ItemFunctions::AddItemChange(unsigned short pid, const char* ref
player->inventoryChanges.items.push_back(item);
}
extern "C" 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 @@ extern "C" bool ItemFunctions::HasItemEquipped(unsigned short pid, const char* r
return false;
}
extern "C" 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 @@ extern "C" const char *ItemFunctions::GetEquipmentItemRefId(unsigned short pid,
return player->equipmentItems[slot].refId.c_str();
}
extern "C" 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 @@ extern "C" int ItemFunctions::GetEquipmentItemCount(unsigned short pid, unsigned
return player->equipmentItems[slot].count;
}
extern "C" 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 @@ extern "C" int ItemFunctions::GetEquipmentItemCharge(unsigned short pid, unsigne
return player->equipmentItems[slot].charge;
}
extern "C" 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 @@ extern "C" double ItemFunctions::GetEquipmentItemEnchantmentCharge(unsigned shor
return player->equipmentItems[slot].enchantmentCharge;
}
extern "C" 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 @@ extern "C" const char *ItemFunctions::GetInventoryItemRefId(unsigned short pid,
return player->inventoryChanges.items.at(index).refId.c_str();
}
extern "C" 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 @@ extern "C" int ItemFunctions::GetInventoryItemCount(unsigned short pid, unsigned
return player->inventoryChanges.items.at(index).count;
}
extern "C" 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 @@ extern "C" int ItemFunctions::GetInventoryItemCharge(unsigned short pid, unsigne
return player->inventoryChanges.items.at(index).charge;
}
extern "C" 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 @@ extern "C" double ItemFunctions::GetInventoryItemEnchantmentCharge(unsigned shor
return player->inventoryChanges.items.at(index).enchantmentCharge;
}
extern "C" 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 @@ extern "C" const char *ItemFunctions::GetInventoryItemSoul(unsigned short pid, u
return player->inventoryChanges.items.at(index).soul.c_str();
}
extern "C" 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 @@ extern "C" const char *ItemFunctions::GetUsedItemRefId(unsigned short pid) noexc
return player->usedItem.refId.c_str();
}
extern "C" 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 @@ extern "C" int ItemFunctions::GetUsedItemCount(unsigned short pid) noexcept
return player->usedItem.count;
}
extern "C" 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 @@ extern "C" int ItemFunctions::GetUsedItemCharge(unsigned short pid) noexcept
return player->usedItem.charge;
}
extern "C" 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 @@ extern "C" double ItemFunctions::GetUsedItemEnchantmentCharge(unsigned short pid
return player->usedItem.enchantmentCharge;
}
extern "C" 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 @@ extern "C" const char *ItemFunctions::GetUsedItemSoul(unsigned short pid) noexce
return player->usedItem.soul.c_str();
}
extern "C" 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 @@ extern "C" void ItemFunctions::SendEquipment(unsigned short pid) noexcept
player->equipmentIndexChanges.clear();
}
extern "C" 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 @@ extern "C" void ItemFunctions::SendInventoryChanges(unsigned short pid, bool sen
packet->Send(true);
}
extern "C" void ItemFunctions::SendItemUse(unsigned short pid) noexcept
extern "C" void ItemFunctions::SendItemUse(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -255,12 +255,12 @@ extern "C" void ItemFunctions::SendItemUse(unsigned short pid) noexcept
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);
}
extern "C" 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);

@ -3,46 +3,6 @@
#include "../api.h"
#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}
NAMESPACE_BEGIN(ItemFunctions)
/**
* \brief Clear the last recorded inventory changes for a player.
@ -52,7 +12,7 @@ NAMESPACE_BEGIN(ItemFunctions)
* \param pid The player ID whose inventory changes should be used.
* \return void
*/
API_FUNCTION void CDECL ClearInventoryChanges(unsigned short pid) noexcept;
API_FUNCTION void CDECL ClearInventoryChanges(PlayerId pid) NOEXCEPT;
/**
* \brief Get the number of slots used for equipment.
@ -61,7 +21,7 @@ NAMESPACE_BEGIN(ItemFunctions)
*
* \return The number of slots.
*/
API_FUNCTION int CDECL GetEquipmentSize() noexcept;
API_FUNCTION int CDECL GetEquipmentSize() NOEXCEPT;
/**
* \brief Get the number of indexes in a player's latest inventory changes.
@ -69,7 +29,7 @@ NAMESPACE_BEGIN(ItemFunctions)
* \param pid The player ID whose inventory changes should be used.
* \return The number of indexes.
*/
API_FUNCTION unsigned int CDECL 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.
@ -77,7 +37,7 @@ NAMESPACE_BEGIN(ItemFunctions)
* \param pid The player ID whose inventory changes should be used.
* \return The action type (0 for SET, 1 for ADD, 2 for REMOVE).
*/
API_FUNCTION unsigned int CDECL 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.
@ -86,7 +46,7 @@ NAMESPACE_BEGIN(ItemFunctions)
* \param action The action (0 for SET, 1 for ADD, 2 for REMOVE).
* \return void
*/
API_FUNCTION void CDECL 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.
@ -99,8 +59,8 @@ NAMESPACE_BEGIN(ItemFunctions)
* \param enchantmentCharge The enchantment charge of the item.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -109,7 +69,7 @@ NAMESPACE_BEGIN(ItemFunctions)
* \param slot The equipment slot.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -122,8 +82,8 @@ NAMESPACE_BEGIN(ItemFunctions)
* \param soul The soul of the item.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -132,7 +92,7 @@ NAMESPACE_BEGIN(ItemFunctions)
* \param refId The refId of the item.
* \return Whether the player has the item equipped.
*/
API_FUNCTION bool CDECL 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.
@ -141,7 +101,7 @@ NAMESPACE_BEGIN(ItemFunctions)
* \param slot The slot of the equipment item.
* \return The refId.
*/
API_FUNCTION const char *CDECL 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.
@ -150,7 +110,7 @@ NAMESPACE_BEGIN(ItemFunctions)
* \param slot The slot of the equipment item.
* \return The item count.
*/
API_FUNCTION int CDECL 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.
@ -159,7 +119,7 @@ NAMESPACE_BEGIN(ItemFunctions)
* \param slot The slot of the equipment item.
* \return The charge.
*/
API_FUNCTION int CDECL 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
@ -169,7 +129,7 @@ NAMESPACE_BEGIN(ItemFunctions)
* \param slot The slot of the equipment item.
* \return The enchantment charge.
*/
API_FUNCTION double CDECL 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
@ -179,7 +139,7 @@ NAMESPACE_BEGIN(ItemFunctions)
* \param index The index of the inventory item.
* \return The refId.
*/
API_FUNCTION const char *CDECL 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
@ -189,7 +149,7 @@ NAMESPACE_BEGIN(ItemFunctions)
* \param index The index of the inventory item.
* \return The item count.
*/
API_FUNCTION int CDECL 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
@ -199,7 +159,7 @@ NAMESPACE_BEGIN(ItemFunctions)
* \param index The index of the inventory item.
* \return The charge.
*/
API_FUNCTION int CDECL 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
@ -209,7 +169,7 @@ NAMESPACE_BEGIN(ItemFunctions)
* \param index The index of the inventory item.
* \return The enchantment charge.
*/
API_FUNCTION double CDECL 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
@ -219,7 +179,7 @@ NAMESPACE_BEGIN(ItemFunctions)
* \param index The index of the inventory item.
* \return The soul.
*/
API_FUNCTION const char *CDECL 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.
@ -227,7 +187,7 @@ NAMESPACE_BEGIN(ItemFunctions)
* \param pid The player ID.
* \return The refId.
*/
API_FUNCTION const char *CDECL 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.
@ -235,7 +195,7 @@ NAMESPACE_BEGIN(ItemFunctions)
* \param pid The player ID.
* \return The item count.
*/
API_FUNCTION int CDECL 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.
@ -243,7 +203,7 @@ NAMESPACE_BEGIN(ItemFunctions)
* \param pid The player ID.
* \return The charge.
*/
API_FUNCTION int CDECL 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.
@ -251,7 +211,7 @@ NAMESPACE_BEGIN(ItemFunctions)
* \param pid The player ID.
* \return The enchantment charge.
*/
API_FUNCTION double CDECL 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.
@ -259,7 +219,7 @@ NAMESPACE_BEGIN(ItemFunctions)
* \param pid The player ID.
* \return The soul.
*/
API_FUNCTION const char *CDECL GetUsedItemSoul(unsigned short pid) noexcept;
API_FUNCTION const char *CDECL GetUsedItemSoul(PlayerId pid) NOEXCEPT;
/**
* \brief Send a PlayerEquipment packet with a player's equipment.
@ -269,7 +229,7 @@ NAMESPACE_BEGIN(ItemFunctions)
* \param pid The player ID whose equipment should be sent.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -281,7 +241,7 @@ NAMESPACE_BEGIN(ItemFunctions)
* to the packet (false by default).
* \return void
*/
API_FUNCTION void CDECL 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.
@ -289,14 +249,14 @@ NAMESPACE_BEGIN(ItemFunctions)
* \param pid The player ID affected.
* \return void
*/
API_FUNCTION void CDECL SendItemUse(unsigned short pid) noexcept;
API_FUNCTION void CDECL SendItemUse(PlayerId pid) NOEXCEPT;
// All methods below are deprecated versions of methods from above
API_FUNCTION void CDECL InitializeInventoryChanges(unsigned short pid) noexcept;
API_FUNCTION void CDECL InitializeInventoryChanges(PlayerId pid) NOEXCEPT;
API_FUNCTION void CDECL AddItem(unsigned short pid, const char* refId, unsigned int count, int charge,
double enchantmentCharge, const char* soul) 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

@ -3,7 +3,7 @@
#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;
extern "C" 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,7 +19,7 @@ extern "C" unsigned char MechanicsFunctions::GetMiscellaneousChangeType(unsigned
return player->miscellaneousChangeType;
}
extern "C" const char *MechanicsFunctions::GetMarkCell(unsigned short pid) noexcept
extern "C" const char *MechanicsFunctions::GetMarkCell(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -28,7 +28,7 @@ extern "C" const char *MechanicsFunctions::GetMarkCell(unsigned short pid) noexc
return tempCellDescription.c_str();
}
extern "C" 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 @@ extern "C" double MechanicsFunctions::GetMarkPosX(unsigned short pid) noexcept
return player->markPosition.pos[0];
}
extern "C" 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 @@ extern "C" double MechanicsFunctions::GetMarkPosY(unsigned short pid) noexcept
return player->markPosition.pos[1];
}
extern "C" 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 @@ extern "C" double MechanicsFunctions::GetMarkPosZ(unsigned short pid) noexcept
return player->markPosition.pos[2];
}
extern "C" 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 @@ extern "C" double MechanicsFunctions::GetMarkRotX(unsigned short pid) noexcept
return player->markPosition.rot[0];
}
extern "C" 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 @@ extern "C" double MechanicsFunctions::GetMarkRotZ(unsigned short pid) noexcept
return player->markPosition.rot[2];
}
extern "C" 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 @@ extern "C" bool MechanicsFunctions::DoesPlayerHavePlayerKiller(unsigned short pi
return player->killer.isPlayer;
}
extern "C" 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 @@ extern "C" int MechanicsFunctions::GetPlayerKillerPid(unsigned short pid) noexce
return -1;
}
extern "C" 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 @@ extern "C" const char *MechanicsFunctions::GetPlayerKillerRefId(unsigned short p
return player->killer.refId.c_str();
}
extern "C" 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 @@ extern "C" unsigned int MechanicsFunctions::GetPlayerKillerRefNum(unsigned short
return player->killer.refNum;
}
extern "C" 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 @@ extern "C" unsigned int MechanicsFunctions::GetPlayerKillerMpNum(unsigned short
return player->killer.mpNum;
}
extern "C" 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 @@ extern "C" const char *MechanicsFunctions::GetPlayerKillerName(unsigned short pi
return player->killer.name.c_str();
}
extern "C" 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 @@ extern "C" const char *MechanicsFunctions::GetSelectedSpellId(unsigned short pid
return player->selectedSpellId.c_str();
}
extern "C" 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 @@ extern "C" unsigned int MechanicsFunctions::GetDrawState(unsigned short pid) noe
return player->drawState;
}
extern "C" 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 @@ extern "C" bool MechanicsFunctions::GetSneakState(unsigned short pid) noexcept
return (player->movementFlags & 8) != 0;
}
extern "C" 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 @@ extern "C" void MechanicsFunctions::SetMarkCell(unsigned short pid, const char *
player->markCell = Utils::getCellFromDescription(cellDescription);
}
extern "C" 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 @@ extern "C" void MechanicsFunctions::SetMarkPos(unsigned short pid, double x, dou
player->markPosition.pos[2] = z;
}
extern "C" 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 @@ extern "C" void MechanicsFunctions::SetMarkRot(unsigned short pid, double x, dou
player->markPosition.rot[2] = z;
}
extern "C" 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 @@ extern "C" void MechanicsFunctions::SetSelectedSpellId(unsigned short pid, const
player->selectedSpellId = spellId;
}
extern "C" void MechanicsFunctions::SendMarkLocation(unsigned short pid)
extern "C" void MechanicsFunctions::SendMarkLocation(PlayerId pid)
{
Player *player;
GET_PLAYER(pid, player, );
@ -194,7 +194,7 @@ extern "C" void MechanicsFunctions::SendMarkLocation(unsigned short pid)
packet->Send(false);
}
extern "C" void MechanicsFunctions::SendSelectedSpell(unsigned short pid)
extern "C" void MechanicsFunctions::SendSelectedSpell(PlayerId pid)
{
Player *player;
GET_PLAYER(pid, player, );
@ -207,7 +207,7 @@ extern "C" void MechanicsFunctions::SendSelectedSpell(unsigned short pid)
packet->Send(false);
}
extern "C" 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 @@ extern "C" void MechanicsFunctions::Jail(unsigned short pid, int jailDays, bool
packet->Send(false);
}
extern "C" 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 @@ extern "C" void MechanicsFunctions::Resurrect(unsigned short pid, unsigned int t
// All methods below are deprecated versions of methods from above
extern "C" 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 @@ extern "C" const char *MechanicsFunctions::GetDeathReason(unsigned short pid) no
return "suicide";
}
extern "C" unsigned int MechanicsFunctions::GetPlayerKillerRefNumIndex(unsigned short pid) noexcept
extern "C" unsigned int MechanicsFunctions::GetPlayerKillerRefNumIndex(PlayerId pid) noexcept
{
return GetPlayerKillerRefNum(pid);
}

@ -1,45 +1,8 @@
#ifndef OPENMW_MECHANICSAPI_HPP
#define OPENMW_MECHANICSAPI_HPP
#include "../Types.hpp"
#include "../api.h"
#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}
NAMESPACE_BEGIN(MechanicsFunctions)
/**
* \brief Get the type of a PlayerMiscellaneous packet.
@ -47,7 +10,7 @@ NAMESPACE_BEGIN(MechanicsFunctions)
* \param pid The player ID.
* \return The type.
*/
API_FUNCTION unsigned char CDECL 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.
@ -55,7 +18,7 @@ NAMESPACE_BEGIN(MechanicsFunctions)
* \param pid The player ID.
* \return The cell description.
*/
API_FUNCTION const char *CDECL GetMarkCell(unsigned short pid) noexcept;
API_FUNCTION const char *CDECL GetMarkCell(PlayerId pid) NOEXCEPT;
/**
* \brief Get the X position of a player's Mark.
@ -63,7 +26,7 @@ NAMESPACE_BEGIN(MechanicsFunctions)
* \param pid The player ID.
* \return The X position.
*/
API_FUNCTION double CDECL GetMarkPosX(unsigned short pid) noexcept;
API_FUNCTION double CDECL GetMarkPosX(PlayerId pid) NOEXCEPT;
/**
* \brief Get the Y position of a player's Mark.
@ -71,7 +34,7 @@ NAMESPACE_BEGIN(MechanicsFunctions)
* \param pid The player ID.
* \return The Y position.
*/
API_FUNCTION double CDECL GetMarkPosY(unsigned short pid) noexcept;
API_FUNCTION double CDECL GetMarkPosY(PlayerId pid) NOEXCEPT;
/**
* \brief Get the Z position of a player's Mark.
@ -79,7 +42,7 @@ NAMESPACE_BEGIN(MechanicsFunctions)
* \param pid The player ID.
* \return The Z position.
*/
API_FUNCTION double CDECL GetMarkPosZ(unsigned short pid) noexcept;
API_FUNCTION double CDECL GetMarkPosZ(PlayerId pid) NOEXCEPT;
/**
* \brief Get the X rotation of a player's Mark.
@ -87,7 +50,7 @@ NAMESPACE_BEGIN(MechanicsFunctions)
* \param pid The player ID.
* \return The X rotation.
*/
API_FUNCTION double CDECL GetMarkRotX(unsigned short pid) noexcept;
API_FUNCTION double CDECL GetMarkRotX(PlayerId pid) NOEXCEPT;
/**
* \brief Get the Z rotation of a player's Mark.
@ -95,7 +58,7 @@ NAMESPACE_BEGIN(MechanicsFunctions)
* \param pid The player ID.
* \return The X rotation.
*/
API_FUNCTION double CDECL GetMarkRotZ(unsigned short pid) noexcept;
API_FUNCTION double CDECL GetMarkRotZ(PlayerId pid) NOEXCEPT;
/**
* \brief Get the ID of a player's selected spell.
@ -103,7 +66,7 @@ NAMESPACE_BEGIN(MechanicsFunctions)
* \param pid The player ID.
* \return The spell ID.
*/
API_FUNCTION const char *CDECL 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.
@ -111,7 +74,7 @@ NAMESPACE_BEGIN(MechanicsFunctions)
* \param pid The player ID of the killed player.
* \return Whether the player was killed by another player.
*/
API_FUNCTION bool CDECL 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.
@ -119,7 +82,7 @@ NAMESPACE_BEGIN(MechanicsFunctions)
* \param pid The player ID of the killed player.
* \return The player ID of the killer.
*/
API_FUNCTION int CDECL 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.
@ -127,7 +90,7 @@ NAMESPACE_BEGIN(MechanicsFunctions)
* \param pid The player ID of the killed player.
* \return The refId of the killer.
*/
API_FUNCTION const char *CDECL 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.
@ -135,7 +98,7 @@ NAMESPACE_BEGIN(MechanicsFunctions)
* \param pid The player ID of the killed player.
* \return The refNum of the killer.
*/
API_FUNCTION unsigned int CDECL 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.
@ -143,7 +106,7 @@ NAMESPACE_BEGIN(MechanicsFunctions)
* \param pid The player ID of the killed player.
* \return The mpNum of the killer.
*/
API_FUNCTION unsigned int CDECL 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.
@ -151,7 +114,7 @@ NAMESPACE_BEGIN(MechanicsFunctions)
* \param pid The player ID of the killed player.
* \return The name of the killer.
*/
API_FUNCTION const char *CDECL 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,
@ -160,7 +123,7 @@ NAMESPACE_BEGIN(MechanicsFunctions)
* \param pid The player ID.
* \return The draw state.
*/
API_FUNCTION unsigned int CDECL GetDrawState(unsigned short pid) noexcept;
API_FUNCTION unsigned int CDECL GetDrawState(PlayerId pid) NOEXCEPT;
/**
* \brief Get the sneak state of a player.
@ -168,7 +131,7 @@ NAMESPACE_BEGIN(MechanicsFunctions)
* \param pid The player ID.
* \return Whether the player is sneaking.
*/
API_FUNCTION bool CDECL GetSneakState(unsigned short pid) noexcept;
API_FUNCTION bool CDECL GetSneakState(PlayerId pid) NOEXCEPT;
/**
* \brief Set the Mark cell of a player.
@ -183,7 +146,7 @@ NAMESPACE_BEGIN(MechanicsFunctions)
* \param cellDescription The cell description.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -197,7 +160,7 @@ NAMESPACE_BEGIN(MechanicsFunctions)
* \param z The Z position.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -210,7 +173,7 @@ NAMESPACE_BEGIN(MechanicsFunctions)
* \param z The Z rotation.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -222,7 +185,7 @@ NAMESPACE_BEGIN(MechanicsFunctions)
* \param spellId The spell ID.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -230,7 +193,7 @@ NAMESPACE_BEGIN(MechanicsFunctions)
* \param pid The player ID.
* \return void
*/
API_FUNCTION void CDECL SendMarkLocation(unsigned short pid);
API_FUNCTION void CDECL SendMarkLocation(PlayerId pid);
/**
* \brief Send a PlayerMiscellaneous packet with a selected spell ID to a player.
@ -238,7 +201,7 @@ NAMESPACE_BEGIN(MechanicsFunctions)
* \param pid The player ID.
* \return void
*/
API_FUNCTION void CDECL SendSelectedSpell(unsigned short pid);
API_FUNCTION void CDECL SendSelectedSpell(PlayerId pid);
/**
* \brief Send a PlayerJail packet about a player.
@ -260,8 +223,8 @@ NAMESPACE_BEGIN(MechanicsFunctions)
* \param jailEndText The text that should be displayed once the jailing period is over.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -273,12 +236,12 @@ NAMESPACE_BEGIN(MechanicsFunctions)
* 2 for TRIBUNAL_TEMPLE).
* \return void
*/
API_FUNCTION void CDECL 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
API_FUNCTION const char *CDECL GetDeathReason(unsigned short pid) noexcept;
API_FUNCTION unsigned int CDECL 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

@ -3,7 +3,7 @@
#include <components/misc/stringops.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>

@ -1,22 +1,8 @@
#ifndef OPENMW_MISCELLANEOUSAPI_HPP
#define OPENMW_MISCELLANEOUSAPI_HPP
#include "../Types.hpp"
#include "../api.h"
#define MISCELLANEOUSAPI \
{"DoesFileExist", MiscellaneousFunctions::DoesFileExist},\
{"GetCaseInsensitiveFilename", MiscellaneousFunctions::GetCaseInsensitiveFilename},\
\
{"GetLastPlayerId", MiscellaneousFunctions::GetLastPlayerId},\
\
{"GetCurrentMpNum", MiscellaneousFunctions::GetCurrentMpNum},\
{"SetCurrentMpNum", MiscellaneousFunctions::SetCurrentMpNum},\
\
{"LogMessage", MiscellaneousFunctions::LogMessage},\
{"LogAppend", MiscellaneousFunctions::LogAppend}
NAMESPACE_BEGIN(MiscellaneousFunctions)
/**
* \brief Check whether a certain file exists.
@ -27,7 +13,7 @@ NAMESPACE_BEGIN(MiscellaneousFunctions)
*
* \return Whether the file exists or not.
*/
API_FUNCTION bool CDECL DoesFileExist(const char *filePath) noexcept;
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
@ -37,7 +23,7 @@ NAMESPACE_BEGIN(MiscellaneousFunctions)
*
* \return The filename that matches.
*/
API_FUNCTION const char *CDECL GetCaseInsensitiveFilename(const char *folderPath, const char *filename) noexcept;
API_FUNCTION const char *CDECL GetCaseInsensitiveFilename(const char *folderPath, const char *filename) NOEXCEPT;
/**
* \brief Get the last player ID currently connected to the server.
@ -47,7 +33,7 @@ NAMESPACE_BEGIN(MiscellaneousFunctions)
*
* \return The player ID.
*/
API_FUNCTION unsigned int CDECL GetLastPlayerId() noexcept;
API_FUNCTION unsigned int CDECL GetLastPlayerId() NOEXCEPT;
/**
* \brief Get the current (latest) mpNum generated by the server.
@ -61,7 +47,7 @@ NAMESPACE_BEGIN(MiscellaneousFunctions)
*
* \return The mpNum.
*/
API_FUNCTION int CDECL GetCurrentMpNum() noexcept;
API_FUNCTION int CDECL GetCurrentMpNum() NOEXCEPT;
/**
* \brief Set the current (latest) mpNum generated by the server.
@ -73,7 +59,7 @@ NAMESPACE_BEGIN(MiscellaneousFunctions)
* \param mpNum The number that should be used as the new current mpNum.
* \return void
*/
API_FUNCTION void CDECL SetCurrentMpNum(int mpNum) noexcept;
API_FUNCTION void CDECL SetCurrentMpNum(int mpNum) NOEXCEPT;
/**
* \brief Write a log message with its own timestamp.
@ -85,7 +71,7 @@ NAMESPACE_BEGIN(MiscellaneousFunctions)
* \param message The message logged.
* \return void
*/
API_FUNCTION void CDECL LogMessage(unsigned short level, const char *message) noexcept;
API_FUNCTION void CDECL LogMessage(unsigned short level, const char *message) NOEXCEPT;
/**
* \brief Write a log message without its own timestamp.
@ -97,7 +83,7 @@ NAMESPACE_BEGIN(MiscellaneousFunctions)
* \param message The message logged.
* \return void
*/
API_FUNCTION void CDECL LogAppend(unsigned short level, const char *message) noexcept;
API_FUNCTION void CDECL LogAppend(unsigned short level, const char *message) NOEXCEPT;
NAMESPACE_END()
#endif //OPENMW_MISCELLANEOUSAPI_HPP

@ -4,7 +4,7 @@
#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.h"
@ -31,7 +31,7 @@ extern "C" void ObjectFunctions::ClearObjectList() noexcept
writeObjectList.packetOrigin = mwmp::PACKET_ORIGIN::SERVER_SCRIPT;
}
extern "C" void ObjectFunctions::SetObjectListPid(unsigned short pid) noexcept
extern "C" void ObjectFunctions::SetObjectListPid(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -399,7 +399,7 @@ extern "C" void ObjectFunctions::SetObjectRotation(double x, double y, double z)
tempObject.position.rot[2] = z;
}
extern "C" void ObjectFunctions::SetObjectActivatingPid(unsigned short pid) noexcept
extern "C" void ObjectFunctions::SetObjectActivatingPid(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -436,7 +436,7 @@ extern "C" void ObjectFunctions::SetObjectDoorDestinationRotation(double x, doub
tempObject.destinationPosition.rot[2] = z;
}
extern "C" void ObjectFunctions::SetPlayerAsObject(unsigned short pid) noexcept
extern "C" void ObjectFunctions::SetPlayerAsObject(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -646,13 +646,13 @@ extern "C" void ObjectFunctions::ReadLastEvent() noexcept
ReadReceivedObjectList();
}
extern "C" void ObjectFunctions::InitializeObjectList(unsigned short pid) noexcept
extern "C" void ObjectFunctions::InitializeObjectList(PlayerId pid) noexcept
{
ClearObjectList();
SetObjectListPid(pid);
}
extern "C" void ObjectFunctions::InitializeEvent(unsigned short pid) noexcept
extern "C" void ObjectFunctions::InitializeEvent(PlayerId pid) noexcept
{
InitializeObjectList(pid);
}

@ -144,14 +144,14 @@ NAMESPACE_BEGIN(ObjectFunctions)
*
* \return void
*/
API_FUNCTION void CDECL ReadReceivedObjectList() noexcept;
API_FUNCTION void CDECL ReadReceivedObjectList() NOEXCEPT;
/**
* \brief Clear the data from the object list stored on the server.
*
* \return void
*/
API_FUNCTION void CDECL ClearObjectList() noexcept;
API_FUNCTION void CDECL ClearObjectList() NOEXCEPT;
/**
* \brief Set the pid attached to the ObjectList.
@ -159,7 +159,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param pid The player ID to whom the object list should be attached.
* \return void
*/
API_FUNCTION void CDECL 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
@ -168,14 +168,14 @@ NAMESPACE_BEGIN(ObjectFunctions)
*
* \return void
*/
API_FUNCTION void CDECL CopyReceivedObjectListToStore() noexcept;
API_FUNCTION void CDECL CopyReceivedObjectListToStore() NOEXCEPT;
/**
* \brief Get the number of indexes in the read object list.
*
* \return The number of indexes.
*/
API_FUNCTION unsigned int CDECL GetObjectListSize() noexcept;
API_FUNCTION unsigned int CDECL GetObjectListSize() NOEXCEPT;
/**
* \brief Get the origin of the read object list.
@ -184,7 +184,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* CLIENT_DIALOGUE, 3 for CLIENT_SCRIPT_LOCAL, 4 for CLIENT_SCRIPT_GLOBAL,
* 5 for SERVER_SCRIPT).
*/
API_FUNCTION unsigned char CDECL GetObjectListOrigin() noexcept;
API_FUNCTION unsigned char CDECL GetObjectListOrigin() NOEXCEPT;
/**
* \brief Get the client script that the read object list originated from.
@ -193,21 +193,21 @@ NAMESPACE_BEGIN(ObjectFunctions)
*
* \return The ID of the client script.
*/
API_FUNCTION const char *CDECL 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).
*/
API_FUNCTION unsigned char CDECL 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).
*/
API_FUNCTION unsigned char CDECL 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
@ -220,7 +220,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param index The index of the object.
* \return Whether the object is a player.
*/
API_FUNCTION bool CDECL 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,
@ -232,7 +232,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param index The index of the object.
* \return The player ID of the object.
*/
API_FUNCTION int CDECL 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.
@ -240,7 +240,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param index The index of the object.
* \return The refId.
*/
API_FUNCTION const char *CDECL 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.
@ -248,7 +248,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param index The index of the object.
* \return The refNum.
*/
API_FUNCTION unsigned int CDECL 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.
@ -256,7 +256,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param index The index of the object.
* \return The mpNum.
*/
API_FUNCTION unsigned int CDECL 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.
@ -264,7 +264,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param index The index of the object.
* \return The object count.
*/
API_FUNCTION int CDECL 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.
@ -272,7 +272,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param index The index of the object.
* \return The charge.
*/
API_FUNCTION int CDECL 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.
@ -280,7 +280,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param index The index of the object.
* \return The enchantment charge.
*/
API_FUNCTION double CDECL 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.
@ -288,7 +288,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param index The index of the object.
* \return The soul.
*/
API_FUNCTION const char *CDECL 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.
@ -298,7 +298,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param index The index of the object.
* \return The gold value.
*/
API_FUNCTION int CDECL 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.
@ -306,7 +306,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param index The index of the object.
* \return The object scale.
*/
API_FUNCTION double CDECL 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.
@ -314,7 +314,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param index The index of the object.
* \return The object state.
*/
API_FUNCTION bool CDECL 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.
@ -322,7 +322,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param index The index of the object.
* \return The door state.
*/
API_FUNCTION int CDECL 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.
@ -330,7 +330,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param index The index of the object.
* \return The lock level.
*/
API_FUNCTION int CDECL 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
@ -339,7 +339,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param index The index of the object.
* \return Whether the object has been activated by a player.
*/
API_FUNCTION bool CDECL 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
@ -348,7 +348,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param index The index of the object.
* \return The player ID of the activating player.
*/
API_FUNCTION int CDECL 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
@ -357,7 +357,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param index The index of the object.
* \return The refId of the activating actor.
*/
API_FUNCTION const char *CDECL 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
@ -366,7 +366,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param index The index of the object.
* \return The refNum of the activating actor.
*/
API_FUNCTION unsigned int CDECL 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
@ -375,7 +375,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param index The index of the object.
* \return The mpNum of the activating actor.
*/
API_FUNCTION unsigned int CDECL 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
@ -384,7 +384,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param index The index of the object.
* \return The name of the activating actor.
*/
API_FUNCTION const char *CDECL 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
@ -394,7 +394,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
*
* \return The summon state.
*/
API_FUNCTION bool CDECL 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.
@ -404,7 +404,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param index The index of the object.
* \return The summon duration.
*/
API_FUNCTION double CDECL 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
@ -415,7 +415,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param index The index of the object.
* \return Whether a player is the summoner of the object.
*/
API_FUNCTION bool CDECL 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
@ -424,7 +424,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param index The index of the object.
* \return The player ID of the summoner.
*/
API_FUNCTION int CDECL 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
@ -433,7 +433,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param index The index of the object.
* \return The refId of the summoner.
*/
API_FUNCTION const char *CDECL 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
@ -442,7 +442,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param index The index of the object.
* \return The refNum of the summoner.
*/
API_FUNCTION unsigned int CDECL 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.
@ -450,7 +450,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param index The index of the object.
* \return The mpNum of the summoner.
*/
API_FUNCTION unsigned int CDECL 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.
@ -458,7 +458,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param index The index of the object.
* \return The X position.
*/
API_FUNCTION double CDECL 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.
@ -466,7 +466,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param index The index of the object.
* \return The Y position.
*/
API_FUNCTION double CDECL 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.
@ -474,7 +474,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param index The index of the object.
* \return The Z position.
*/
API_FUNCTION double CDECL 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.
@ -482,7 +482,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param index The index of the object.
* \return The X rotation.
*/
API_FUNCTION double CDECL 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.
@ -490,7 +490,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param index The index of the object.
* \return The Y rotation.
*/
API_FUNCTION double CDECL 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.
@ -498,14 +498,14 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param index The index of the object.
* \return The Z rotation.
*/
API_FUNCTION double CDECL 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.
*/
API_FUNCTION const char *CDECL 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
@ -514,7 +514,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param index The index of the object.
* \return The number of container item indexes.
*/
API_FUNCTION unsigned int CDECL 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
@ -524,7 +524,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param itemIndex The index of the container item.
* \return The refId.
*/
API_FUNCTION const char *CDECL 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
@ -534,7 +534,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param itemIndex The index of the container item.
* \return The item count.
*/
API_FUNCTION int CDECL 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
@ -544,7 +544,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param itemIndex The index of the container item.
* \return The charge.
*/
API_FUNCTION int CDECL 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
@ -554,7 +554,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param itemIndex The index of the container item.
* \return The enchantment charge.
*/
API_FUNCTION double CDECL 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
@ -564,7 +564,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param itemIndex The index of the container item.
* \return The soul.
*/
API_FUNCTION const char *CDECL 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
@ -574,7 +574,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param itemIndex The index of the container item.
* \return The action count.
*/
API_FUNCTION int CDECL 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.
@ -585,7 +585,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param index The index of the object.
* \return Whether the object has a container.
*/
API_FUNCTION bool CDECL 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.
@ -596,7 +596,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param cellDescription The description of the cell.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -604,7 +604,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param action The action type (0 for SET, 1 for ADD, 2 for REMOVE, 3 for REQUEST).
* \return void
*/
API_FUNCTION void CDECL 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.
@ -615,7 +615,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param consoleCommand The console command.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -623,7 +623,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param refId The refId.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -637,7 +637,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param refNum The refNum.
* \return void
*/
API_FUNCTION void CDECL SetObjectRefNum(int refNum) noexcept;
API_FUNCTION void CDECL SetObjectRefNum(int refNum) NOEXCEPT;
/**
* \brief Set the mpNum of the temporary object stored on the server.
@ -652,7 +652,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param mpNum The mpNum.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -662,7 +662,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param count The object count.
* \return void
*/
API_FUNCTION void CDECL SetObjectCount(int count) noexcept;
API_FUNCTION void CDECL SetObjectCount(int count) NOEXCEPT;
/**
* \brief Set the charge of the temporary object stored on the server.
@ -672,7 +672,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param charge The charge.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -682,7 +682,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param charge The enchantment charge.
* \return void
*/
API_FUNCTION void CDECL SetObjectEnchantmentCharge(double enchantmentCharge) noexcept;
API_FUNCTION void CDECL SetObjectEnchantmentCharge(double enchantmentCharge) NOEXCEPT;
/**
* \brief Set the soul of the temporary object stored on the server.
@ -690,7 +690,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param refId The soul.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -700,7 +700,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param goldValue The gold value.
* \return void
*/
API_FUNCTION void CDECL SetObjectGoldValue(int goldValue) noexcept;
API_FUNCTION void CDECL SetObjectGoldValue(int goldValue) NOEXCEPT;
/**
* \brief Set the scale of the temporary object stored on the server.
@ -710,7 +710,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param scale The scale.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -720,7 +720,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param objectState The object state.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -728,7 +728,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param lockLevel The lock level.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -736,7 +736,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param summonDuration The summon duration.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -744,7 +744,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param disarmState The disarmState.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -755,7 +755,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param summonState The summon state.
* \return void
*/
API_FUNCTION void CDECL SetObjectSummonState(bool summonState) noexcept;
API_FUNCTION void CDECL SetObjectSummonState(bool summonState) NOEXCEPT;
/**
* \brief Set the position of the temporary object stored on the server.
@ -765,7 +765,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param z The Z position.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -775,7 +775,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param z The Z rotation.
* \return void
*/
API_FUNCTION void CDECL 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
@ -784,7 +784,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param pid The pid of the player.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -794,7 +794,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param doorState The door state.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -805,7 +805,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param teleportState The teleport state.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -816,7 +816,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param cellDescription The description of the cell.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -826,7 +826,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param z The Z position.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -838,7 +838,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param z The Z rotation.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -847,7 +847,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param pid The pid of the player.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -855,7 +855,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param refId The refId.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -863,7 +863,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param count The item count.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -871,7 +871,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param charge The charge.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -879,7 +879,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param charge The enchantment charge.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -887,7 +887,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param refId The soul.
* \return void
*/
API_FUNCTION void CDECL 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
@ -902,7 +902,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* \param actionCount The action count.
* \return void
*/
API_FUNCTION void CDECL 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
@ -913,7 +913,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
*
* \return void
*/
API_FUNCTION void CDECL 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
@ -924,7 +924,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
*
* \return void
*/
API_FUNCTION void CDECL AddContainerItem() noexcept;
API_FUNCTION void CDECL AddContainerItem() NOEXCEPT;
/**
* \brief Send an ObjectActivate packet.
@ -935,7 +935,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* to the packet (false by default).
* \return void
*/
API_FUNCTION void CDECL SendObjectActivate(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendObjectActivate(bool sendToOtherPlayers, bool skipAttachedPlayer) NOEXCEPT;
/**
* \brief Send an ObjectPlace packet.
@ -946,7 +946,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* to the packet (false by default).
* \return void
*/
API_FUNCTION void CDECL SendObjectPlace(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendObjectPlace(bool sendToOtherPlayers, bool skipAttachedPlayer) NOEXCEPT;
/**
* \brief Send an ObjectSpawn packet.
@ -957,7 +957,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* to the packet (false by default).
* \return void
*/
API_FUNCTION void CDECL SendObjectSpawn(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendObjectSpawn(bool sendToOtherPlayers, bool skipAttachedPlayer) NOEXCEPT;
/**
* \brief Send an ObjectDelete packet.
@ -967,7 +967,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
*
* \return void
*/
API_FUNCTION void CDECL SendObjectDelete(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendObjectDelete(bool sendToOtherPlayers, bool skipAttachedPlayer) NOEXCEPT;
/**
* \brief Send an ObjectLock packet.
@ -978,7 +978,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* to the packet (false by default).
* \return void
*/
API_FUNCTION void CDECL SendObjectLock(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendObjectLock(bool sendToOtherPlayers, bool skipAttachedPlayer) NOEXCEPT;
/**
* \brief Send an ObjectTrap packet.
@ -988,7 +988,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
*
* \return void
*/
API_FUNCTION void CDECL SendObjectTrap(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendObjectTrap(bool sendToOtherPlayers, bool skipAttachedPlayer) NOEXCEPT;
/**
* \brief Send an ObjectScale packet.
@ -999,7 +999,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* to the packet (false by default).
* \return void
*/
API_FUNCTION void CDECL SendObjectScale(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendObjectScale(bool sendToOtherPlayers, bool skipAttachedPlayer) NOEXCEPT;
/**
* \brief Send an ObjectState packet.
@ -1010,7 +1010,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* to the packet (false by default).
* \return void
*/
API_FUNCTION void CDECL SendObjectState(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendObjectState(bool sendToOtherPlayers, bool skipAttachedPlayer) NOEXCEPT;
/**
* \brief Send a DoorState packet.
@ -1021,7 +1021,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* to the packet (false by default).
* \return void
*/
API_FUNCTION void CDECL SendDoorState(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendDoorState(bool sendToOtherPlayers, bool skipAttachedPlayer) NOEXCEPT;
/**
* \brief Send a DoorDestination packet.
@ -1032,7 +1032,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* to the packet (false by default).
* \return void
*/
API_FUNCTION void CDECL SendDoorDestination(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendDoorDestination(bool sendToOtherPlayers, bool skipAttachedPlayer) NOEXCEPT;
/**
* \brief Send a Container packet.
@ -1043,7 +1043,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* to the packet (false by default).
* \return void
*/
API_FUNCTION void CDECL SendContainer(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendContainer(bool sendToOtherPlayers, bool skipAttachedPlayer) NOEXCEPT;
/**
* \brief Send a VideoPlay packet.
@ -1054,7 +1054,7 @@ NAMESPACE_BEGIN(ObjectFunctions)
* to the packet (false by default).
* \return void
*/
API_FUNCTION void CDECL SendVideoPlay(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
API_FUNCTION void CDECL SendVideoPlay(bool sendToOtherPlayers, bool skipAttachedPlayer) NOEXCEPT;
/**
* \brief Send a ConsoleCommand packet.
@ -1065,26 +1065,26 @@ NAMESPACE_BEGIN(ObjectFunctions)
* to the packet (false by default).
* \return void
*/
API_FUNCTION void CDECL 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
API_FUNCTION void CDECL ReadLastObjectList() noexcept;
API_FUNCTION void CDECL ReadLastEvent() noexcept;
API_FUNCTION void CDECL InitializeObjectList(unsigned short pid) noexcept;
API_FUNCTION void CDECL InitializeEvent(unsigned short 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;
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()

@ -1,5 +1,5 @@
#include "Positions.h"
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
#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];
}
extern "C" 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 @@ extern "C" double PositionFunctions::GetPosY(unsigned short pid) noexcept
return player->position.pos[1];
}
extern "C" 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 @@ extern "C" double PositionFunctions::GetPosZ(unsigned short pid) noexcept
return player->position.pos[2];
}
extern "C" 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 @@ extern "C" double PositionFunctions::GetPreviousCellPosX(unsigned short pid) noe
return player->previousCellPosition.pos[0];
}
extern "C" 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 @@ extern "C" double PositionFunctions::GetPreviousCellPosY(unsigned short pid) noe
return player->previousCellPosition.pos[1];
}
extern "C" 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 @@ extern "C" double PositionFunctions::GetPreviousCellPosZ(unsigned short pid) noe
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];
}
extern "C" 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 @@ extern "C" double PositionFunctions::GetRotZ(unsigned short pid) noexcept
return player->position.rot[2];
}
extern "C" 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 @@ extern "C" void PositionFunctions::SetPos(unsigned short pid, double x, double y
player->position.pos[2] = z;
}
extern "C" 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 @@ extern "C" void PositionFunctions::SetRot(unsigned short pid, double x, double z
player->position.rot[2] = z;
}
extern "C" 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 @@ extern "C" void PositionFunctions::SetMomentum(unsigned short pid, double x, dou
player->momentum.pos[2] = z;
}
extern "C" 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 @@ extern "C" void PositionFunctions::SendPos(unsigned short pid) noexcept
packet->Send(false);
}
extern "C" void PositionFunctions::SendMomentum(unsigned short pid) noexcept
extern "C" void PositionFunctions::SendMomentum(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );

@ -1,30 +1,8 @@
#ifndef OPENMW_POSITIONAPI_HPP
#define OPENMW_POSITIONAPI_HPP
#include "../Types.hpp"
#include "../api.h"
#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}
NAMESPACE_BEGIN(PositionFunctions)
/**
* \brief Get the X position of a player.
@ -32,7 +10,7 @@ NAMESPACE_BEGIN(PositionFunctions)
* \param pid The player ID.
* \return The X position.
*/
API_FUNCTION double CDECL GetPosX(unsigned short pid) noexcept;
API_FUNCTION double CDECL GetPosX(PlayerId pid) NOEXCEPT;
/**
* \brief Get the Y position of a player.
@ -40,7 +18,7 @@ NAMESPACE_BEGIN(PositionFunctions)
* \param pid The player ID.
* \return The Y position.
*/
API_FUNCTION double CDECL GetPosY(unsigned short pid) noexcept;
API_FUNCTION double CDECL GetPosY(PlayerId pid) NOEXCEPT;
/**
* \brief Get the Z position of a player.
@ -48,7 +26,7 @@ NAMESPACE_BEGIN(PositionFunctions)
* \param pid The player ID.
* \return The Z position.
*/
API_FUNCTION double CDECL 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.
@ -56,7 +34,7 @@ NAMESPACE_BEGIN(PositionFunctions)
* \param pid The player ID.
* \return The X position.
*/
API_FUNCTION double CDECL 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.
@ -64,7 +42,7 @@ NAMESPACE_BEGIN(PositionFunctions)
* \param pid The player ID.
* \return The Y position.
*/
API_FUNCTION double CDECL 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.
@ -72,7 +50,7 @@ NAMESPACE_BEGIN(PositionFunctions)
* \param pid The player ID.
* \return The Z position.
*/
API_FUNCTION double CDECL GetPreviousCellPosZ(unsigned short pid) noexcept;
API_FUNCTION double CDECL GetPreviousCellPosZ(PlayerId pid) NOEXCEPT;
/**
* \brief Get the X rotation of a player.
@ -80,7 +58,7 @@ NAMESPACE_BEGIN(PositionFunctions)
* \param pid The player ID.
* \return The X rotation.
*/
API_FUNCTION double CDECL GetRotX(unsigned short pid) noexcept;
API_FUNCTION double CDECL GetRotX(PlayerId pid) NOEXCEPT;
/**
* \brief Get the Z rotation of a player.
@ -88,7 +66,7 @@ NAMESPACE_BEGIN(PositionFunctions)
* \param pid The player ID.
* \return The Z rotation.
*/
API_FUNCTION double CDECL GetRotZ(unsigned short pid) noexcept;
API_FUNCTION double CDECL GetRotZ(PlayerId pid) NOEXCEPT;
/**
* \brief Set the position of a player.
@ -102,7 +80,7 @@ NAMESPACE_BEGIN(PositionFunctions)
* \param z The Z position.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -117,7 +95,7 @@ NAMESPACE_BEGIN(PositionFunctions)
* \param z The Z position.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -131,7 +109,7 @@ NAMESPACE_BEGIN(PositionFunctions)
* \param z The Z momentum.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -141,7 +119,7 @@ NAMESPACE_BEGIN(PositionFunctions)
* \param pid The player ID.
* \return void
*/
API_FUNCTION void CDECL SendPos(unsigned short pid) noexcept;
API_FUNCTION void CDECL SendPos(PlayerId pid) NOEXCEPT;
/**
* \brief Send a PlayerMomentum packet about a player.
@ -151,7 +129,7 @@ NAMESPACE_BEGIN(PositionFunctions)
* \param pid The player ID.
* \return void
*/
API_FUNCTION void CDECL SendMomentum(unsigned short pid) noexcept;
API_FUNCTION void CDECL SendMomentum(PlayerId pid) NOEXCEPT;
NAMESPACE_END()
#endif //OPENMW_POSITIONAPI_HPP

@ -4,7 +4,7 @@
#include "Public.h"
#include <Script/ScriptFunctions.hpp>
#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
@ -12,18 +12,36 @@ extern "C" void PublicFunctions::MakePublic(ScriptFunc _public, const char *name
Public::MakePublic(_public, name, ret_type, def);
}
extern "C" boost::any PublicFunctions::CallPublic(const char *name, va_list args) noexcept
extern "C" RetType PublicFunctions::CallPublic(const char *name, ...) noexcept
{
std::vector<boost::any> params;
try
{
std::string def = Public::GetDefinition(name);
ScriptFunctions::GetArguments(params, args, def);
return Public::Call(name, params);
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);
}

@ -5,12 +5,16 @@
#ifndef OPENMW_PUBLIC_HPP
#define OPENMW_PUBLIC_HPP
#include <apps/openmw-mp/Script/ScriptFunction.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 boost::any CDECL CallPublic(const char *name, va_list args) noexcept;
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

@ -3,12 +3,12 @@
#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;
extern "C" 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 @@ extern "C" void QuestFunctions::ClearJournalChanges(unsigned short pid) noexcept
player->journalChanges.journalItems.clear();
}
extern "C" 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 @@ extern "C" void QuestFunctions::ClearKillChanges(unsigned short pid) noexcept
player->killChanges.kills.clear();
}
extern "C" 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 @@ extern "C" unsigned int QuestFunctions::GetJournalChangesSize(unsigned short pid
return player->journalChanges.count;
}
extern "C" 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 @@ extern "C" unsigned int QuestFunctions::GetKillChangesSize(unsigned short pid) n
return player->killChanges.count;
}
extern "C" 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 @@ extern "C" void QuestFunctions::AddJournalEntry(unsigned short pid, const char*
player->journalChanges.journalItems.push_back(journalItem);
}
extern "C" 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 @@ extern "C" void QuestFunctions::AddJournalEntryWithTimestamp(unsigned short pid,
player->journalChanges.journalItems.push_back(journalItem);
}
extern "C" 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 @@ extern "C" void QuestFunctions::AddJournalIndex(unsigned short pid, const char*
player->journalChanges.journalItems.push_back(journalItem);
}
extern "C" 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 @@ extern "C" void QuestFunctions::AddKill(unsigned short pid, const char* refId, i
player->killChanges.kills.push_back(kill);
}
extern "C" 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 @@ extern "C" void QuestFunctions::SetReputation(unsigned short pid, int value) noe
player->npcStats.mReputation = value;
}
extern "C" 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 @@ extern "C" const char *QuestFunctions::GetJournalItemQuest(unsigned short pid, u
return player->journalChanges.journalItems.at(index).quest.c_str();
}
extern "C" 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 @@ extern "C" int QuestFunctions::GetJournalItemIndex(unsigned short pid, unsigned
return player->journalChanges.journalItems.at(index).index;
}
extern "C" 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 @@ extern "C" int QuestFunctions::GetJournalItemType(unsigned short pid, unsigned i
return player->journalChanges.journalItems.at(index).type;
}
extern "C" 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 @@ extern "C" const char *QuestFunctions::GetJournalItemActorRefId(unsigned short p
return player->journalChanges.journalItems.at(index).actorRefId.c_str();
}
extern "C" 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 @@ extern "C" const char *QuestFunctions::GetKillRefId(unsigned short pid, unsigned
return player->killChanges.kills.at(index).refId.c_str();
}
extern "C" 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 @@ extern "C" int QuestFunctions::GetKillNumber(unsigned short pid, unsigned int in
return player->killChanges.kills.at(index).number;
}
extern "C" 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 @@ extern "C" int QuestFunctions::GetReputation(unsigned short pid) noexcept
return player->npcStats.mReputation;
}
extern "C" 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 @@ extern "C" void QuestFunctions::SendJournalChanges(unsigned short pid, bool send
packet->Send(true);
}
extern "C" 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 @@ extern "C" void QuestFunctions::SendKillChanges(unsigned short pid, bool sendToO
packet->Send(true);
}
extern "C" 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, );
@ -214,12 +214,12 @@ extern "C" void QuestFunctions::SendReputation(unsigned short pid, bool sendToOt
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);
}
extern "C" void QuestFunctions::InitializeKillChanges(unsigned short pid) noexcept
extern "C" void QuestFunctions::InitializeKillChanges(PlayerId pid) noexcept
{
ClearKillChanges(pid);
}

@ -42,7 +42,7 @@ NAMESPACE_BEGIN(QuestFunctions)
* \param pid The player ID whose journal changes should be used.
* \return void
*/
API_FUNCTION void CDECL ClearJournalChanges(unsigned short pid) noexcept;
API_FUNCTION void CDECL ClearJournalChanges(PlayerId pid) NOEXCEPT;
/**
* \brief Clear the last recorded kill count changes for a player.
@ -52,7 +52,7 @@ NAMESPACE_BEGIN(QuestFunctions)
* \param pid The player ID whose kill count changes should be used.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -60,7 +60,7 @@ NAMESPACE_BEGIN(QuestFunctions)
* \param pid The player ID whose journal changes should be used.
* \return The number of indexes.
*/
API_FUNCTION unsigned int CDECL 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.
@ -68,7 +68,7 @@ NAMESPACE_BEGIN(QuestFunctions)
* \param pid The player ID whose kill count changes should be used.
* \return The number of indexes.
*/
API_FUNCTION unsigned int CDECL 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,
@ -80,7 +80,7 @@ NAMESPACE_BEGIN(QuestFunctions)
* \param actorRefId The actor refId of the journal item.
* \return void
*/
API_FUNCTION void CDECL 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,
@ -95,8 +95,8 @@ NAMESPACE_BEGIN(QuestFunctions)
* \param The day of the month for the journal item.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -106,7 +106,7 @@ NAMESPACE_BEGIN(QuestFunctions)
* \param index The quest index of the journal item.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -116,7 +116,7 @@ NAMESPACE_BEGIN(QuestFunctions)
* \param number The number of kills in the kill count.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -125,7 +125,7 @@ NAMESPACE_BEGIN(QuestFunctions)
* \param value The reputation.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -134,7 +134,7 @@ NAMESPACE_BEGIN(QuestFunctions)
* \param index The index of the journalItem.
* \return The quest.
*/
API_FUNCTION const char *CDECL 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.
@ -143,7 +143,7 @@ NAMESPACE_BEGIN(QuestFunctions)
* \param index The index of the journalItem.
* \return The quest index.
*/
API_FUNCTION int CDECL 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.
@ -152,7 +152,7 @@ NAMESPACE_BEGIN(QuestFunctions)
* \param index The index of the journalItem.
* \return The type (0 for ENTRY, 1 for INDEX).
*/
API_FUNCTION int CDECL 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.
@ -163,7 +163,7 @@ NAMESPACE_BEGIN(QuestFunctions)
* \param index The index of the journalItem.
* \return The actor refId.
*/
API_FUNCTION const char *CDECL 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.
@ -172,7 +172,7 @@ NAMESPACE_BEGIN(QuestFunctions)
* \param index The index of the kill count.
* \return The refId.
*/
API_FUNCTION const char *CDECL 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.
@ -181,7 +181,7 @@ NAMESPACE_BEGIN(QuestFunctions)
* \param index The index of the kill count.
* \return The number of kills.
*/
API_FUNCTION int CDECL 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.
@ -189,7 +189,7 @@ NAMESPACE_BEGIN(QuestFunctions)
* \param pid The player ID.
* \return The reputation.
*/
API_FUNCTION int CDECL 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.
@ -201,7 +201,7 @@ NAMESPACE_BEGIN(QuestFunctions)
* to the packet (false by default).
* \return void
*/
API_FUNCTION void CDECL 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.
@ -213,7 +213,7 @@ NAMESPACE_BEGIN(QuestFunctions)
* to the packet (false by default).
* \return void
*/
API_FUNCTION void CDECL 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.
@ -225,12 +225,12 @@ NAMESPACE_BEGIN(QuestFunctions)
* to the packet (false by default).
* \return void
*/
API_FUNCTION void CDECL 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
API_FUNCTION void CDECL InitializeJournalChanges(unsigned short pid) noexcept;
API_FUNCTION void CDECL InitializeKillChanges(unsigned short pid) noexcept;
API_FUNCTION void CDECL InitializeJournalChanges(PlayerId pid) NOEXCEPT;
API_FUNCTION void CDECL InitializeKillChanges(PlayerId pid) NOEXCEPT;
NAMESPACE_END()
#endif //OPENMW_QUESTAPI_HPP

@ -3,7 +3,7 @@
#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.h"
@ -1238,7 +1238,7 @@ extern "C" void RecordsDynamicFunctions::AddRecordInventoryItem() noexcept
tempInventoryItem = {};
}
extern "C" 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,124 +1,15 @@
#ifndef OPENMW_RECORDSDYNAMICAPI_HPP
#define OPENMW_RECORDSDYNAMICAPI_HPP
#include "../Types.hpp"
#include "../api.h"
#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}
NAMESPACE_BEGIN(RecordsDynamicFunctions)
/**
* \brief Clear the data from the records stored on the server.
*
* \return void
*/
API_FUNCTION void CDECL ClearRecords() noexcept;
API_FUNCTION void CDECL ClearRecords() NOEXCEPT;
/**
* \brief Get the type of records in the read worldstate's dynamic records.
@ -126,14 +17,14 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \return The type of records (0 for SPELL, 1 for POTION, 2 for ENCHANTMENT,
* 3 for NPC).
*/
API_FUNCTION unsigned short CDECL 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.
*/
API_FUNCTION unsigned int CDECL 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
@ -142,7 +33,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param recordIndex The index of the record.
* \return The number of effects.
*/
API_FUNCTION unsigned int CDECL 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
@ -151,7 +42,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param index The index of the record.
* \return The id of the record.
*/
API_FUNCTION const char *CDECL 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
@ -161,7 +52,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param index The index of the record.
* \return The base id of the record.
*/
API_FUNCTION const char *CDECL 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
@ -170,7 +61,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param index The index of the record.
* \return The type of the record.
*/
API_FUNCTION int CDECL 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
@ -179,7 +70,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param index The index of the record.
* \return The name of the record.
*/
API_FUNCTION const char *CDECL 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
@ -188,7 +79,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param index The index of the record.
* \return The model of the record.
*/
API_FUNCTION const char *CDECL 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
@ -197,7 +88,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param index The index of the record.
* \return The icon of the record.
*/
API_FUNCTION const char *CDECL 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
@ -206,7 +97,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param index The index of the record.
* \return The script of the record.
*/
API_FUNCTION const char *CDECL 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
@ -215,7 +106,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param index The index of the record.
* \return The enchantment id of the record.
*/
API_FUNCTION const char *CDECL 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
@ -224,7 +115,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param index The index of the record.
* \return The enchantment charge of the record.
*/
API_FUNCTION int CDECL 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
@ -233,7 +124,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param index The index of the record.
* \return The auto-calculation flag value of the record.
*/
API_FUNCTION int CDECL 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
@ -242,7 +133,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param index The index of the record.
* \return The charge of the record.
*/
API_FUNCTION int CDECL 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
@ -251,7 +142,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param index The index of the record.
* \return The cost of the record.
*/
API_FUNCTION int CDECL 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
@ -260,7 +151,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param index The index of the record.
* \return The flags of the spell as an integer.
*/
API_FUNCTION int CDECL 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
@ -269,7 +160,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param index The index of the record.
* \return The value of the record.
*/
API_FUNCTION int CDECL 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
@ -278,7 +169,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param index The index of the record.
* \return The weight of the record.
*/
API_FUNCTION double CDECL 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
@ -288,7 +179,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param effectIndex The index of the effect.
* \return The ID of the effect.
*/
API_FUNCTION unsigned int CDECL 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
@ -298,7 +189,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param effectIndex The index of the effect.
* \return The attribute ID for the effect.
*/
API_FUNCTION int CDECL 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
@ -308,7 +199,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param effectIndex The index of the effect.
* \return The skill ID for the effect.
*/
API_FUNCTION int CDECL 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
@ -318,7 +209,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param effectIndex The index of the effect.
* \return The range of the effect.
*/
API_FUNCTION unsigned int CDECL 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
@ -328,7 +219,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param effectIndex The index of the effect.
* \return The area of the effect.
*/
API_FUNCTION int CDECL 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
@ -338,7 +229,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param effectIndex The index of the effect.
* \return The duration of the effect.
*/
API_FUNCTION int CDECL 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
@ -348,7 +239,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param effectIndex The index of the effect.
* \return The maximum magnitude of the effect.
*/
API_FUNCTION int CDECL 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
@ -358,7 +249,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param effectIndex The index of the effect.
* \return The minimum magnitude of the effect.
*/
API_FUNCTION int CDECL 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
@ -367,7 +258,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param type The type of records.
* \return void
*/
API_FUNCTION void CDECL 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
@ -376,7 +267,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param id The id of the record.
* \return void
*/
API_FUNCTION void CDECL 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
@ -386,7 +277,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param baseId The baseId of the record.
* \return void
*/
API_FUNCTION void CDECL 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
@ -396,7 +287,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param inventoryBaseId The inventoryBaseId of the record.
* \return void
*/
API_FUNCTION void CDECL 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
@ -405,7 +296,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param type The spell type.
* \return void
*/
API_FUNCTION void CDECL 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
@ -414,7 +305,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param name The name of the record.
* \return void
*/
API_FUNCTION void CDECL 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
@ -423,7 +314,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param model The model of the record.
* \return void
*/
API_FUNCTION void CDECL 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
@ -432,7 +323,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param icon The icon of the record.
* \return void
*/
API_FUNCTION void CDECL 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
@ -441,7 +332,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param script The script of the record.
* \return void
*/
API_FUNCTION void CDECL 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
@ -450,7 +341,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param enchantmentId The enchantment id of the record.
* \return void
*/
API_FUNCTION void CDECL 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
@ -459,7 +350,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param enchantmentCharge The enchantmentCharge of the record.
* \return void
*/
API_FUNCTION void CDECL SetRecordEnchantmentCharge(int enchantmentCharge) noexcept;
API_FUNCTION void CDECL SetRecordEnchantmentCharge(int enchantmentCharge) NOEXCEPT;
/**
* \brief Set the auto-calculation flag value of the temporary record stored
@ -468,7 +359,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param autoCalc The auto-calculation flag value of the record.
* \return void
*/
API_FUNCTION void CDECL 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
@ -477,7 +368,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param charge The charge of the record.
* \return void
*/
API_FUNCTION void CDECL 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
@ -486,7 +377,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param cost The cost of the record.
* \return void
*/
API_FUNCTION void CDECL 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
@ -495,7 +386,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param flags The flags of the record.
* \return void
*/
API_FUNCTION void CDECL 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
@ -504,7 +395,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param value The value of the record.
* \return void
*/
API_FUNCTION void CDECL 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
@ -513,7 +404,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param weight The weight of the record.
* \return void
*/
API_FUNCTION void CDECL 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
@ -522,7 +413,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param armorRating The armor rating of the record.
* \return void
*/
API_FUNCTION void CDECL 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
@ -531,7 +422,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param health The health of the record.
* \return void
*/
API_FUNCTION void CDECL 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
@ -541,7 +432,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param maxDamage The maximum damage of the record.
* \return void
*/
API_FUNCTION void CDECL 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
@ -551,7 +442,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param maxDamage The maximum damage of the record.
* \return void
*/
API_FUNCTION void CDECL 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
@ -561,7 +452,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param maxDamage The maximum damage of the record.
* \return void
*/
API_FUNCTION void CDECL 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
@ -570,7 +461,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param reach The reach of the record.
* \return void
*/
API_FUNCTION void CDECL 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
@ -579,7 +470,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param speed The speed of the record.
* \return void
*/
API_FUNCTION void CDECL SetRecordSpeed(double speed) noexcept;
API_FUNCTION void CDECL SetRecordSpeed(double speed) NOEXCEPT;
/**
* \brief Set whether the temporary record stored on the server for the
@ -590,7 +481,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param keyState Whether the record is a key.
* \return void
*/
API_FUNCTION void CDECL SetRecordKeyState(bool keyState) noexcept;
API_FUNCTION void CDECL SetRecordKeyState(bool keyState) NOEXCEPT;
/**
* \brief Set whether the temporary record stored on the server for the
@ -601,7 +492,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param scrollState Whether the record is a scroll.
* \return void
*/
API_FUNCTION void CDECL 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
@ -610,7 +501,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param skillId The skill ID of the record.
* \return void
*/
API_FUNCTION void CDECL 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
@ -619,7 +510,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param text The text of the record.
* \return void
*/
API_FUNCTION void CDECL 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
@ -628,7 +519,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param hair The hair of the record.
* \return void
*/
API_FUNCTION void CDECL 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
@ -637,7 +528,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param hair The head of the record.
* \return void
*/
API_FUNCTION void CDECL 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
@ -646,7 +537,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param hair The race of the record.
* \return void
*/
API_FUNCTION void CDECL 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
@ -655,7 +546,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param hair The race of the record.
* \return void
*/
API_FUNCTION void CDECL 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
@ -664,7 +555,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param hair The character class of the record.
* \return void
*/
API_FUNCTION void CDECL 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
@ -673,7 +564,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param faction The faction of the record.
* \return void
*/
API_FUNCTION void CDECL 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
@ -682,7 +573,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param level The level of the record.
* \return void
*/
API_FUNCTION void CDECL 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
@ -691,7 +582,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param magicka The magicka of the record.
* \return void
*/
API_FUNCTION void CDECL 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
@ -700,7 +591,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param fatigue The fatigue of the record.
* \return void
*/
API_FUNCTION void CDECL 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
@ -709,7 +600,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param aiFight The AI fight value of the record.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -721,7 +612,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param id The id of the record.
* \return void
*/
API_FUNCTION void CDECL 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
@ -734,7 +625,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param enchantmentId The enchantment id of the record.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -742,7 +633,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param effectId The ID of the effect.
* \return void
*/
API_FUNCTION void CDECL 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
@ -751,7 +642,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param attributeId The ID of the attribute.
* \return void
*/
API_FUNCTION void CDECL 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
@ -760,7 +651,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param skillId The ID of the skill.
* \return void
*/
API_FUNCTION void CDECL 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
@ -769,7 +660,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param rangeType The range type of the effect.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -777,7 +668,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param area The area of the effect.
* \return void
*/
API_FUNCTION void CDECL SetRecordEffectArea(int area) noexcept;
API_FUNCTION void CDECL SetRecordEffectArea(int area) NOEXCEPT;
/**
* \brief Set the duration of the temporary effect stored on the server.
@ -785,7 +676,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param duration The duration of the effect.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -793,7 +684,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param magnitudeMax The maximum magnitude of the effect.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -801,7 +692,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param magnitudeMin The minimum magnitude of the effect.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -809,7 +700,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param partType The type of the body part.
* \return void
*/
API_FUNCTION void CDECL 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
@ -818,7 +709,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param partId The id of the body part.
* \return void
*/
API_FUNCTION void CDECL 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
@ -827,7 +718,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param partId The id of the body part.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -835,7 +726,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param partId The id of the inventory item.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -843,7 +734,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* \param count The count of the inventory item.
* \return void
*/
API_FUNCTION void CDECL 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
@ -854,7 +745,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
*
* \return void
*/
API_FUNCTION void CDECL AddRecord() noexcept;
API_FUNCTION void CDECL AddRecord() NOEXCEPT;
/**
* \brief Add a copy of the server's temporary effect to the temporary record
@ -865,7 +756,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
*
* \return void
*/
API_FUNCTION void CDECL AddRecordEffect() noexcept;
API_FUNCTION void CDECL AddRecordEffect() NOEXCEPT;
/**
* \brief Add a copy of the server's temporary body part to the temporary record
@ -876,7 +767,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
*
* \return void
*/
API_FUNCTION void CDECL AddRecordBodyPart() noexcept;
API_FUNCTION void CDECL AddRecordBodyPart() NOEXCEPT;
/**
* \brief Add a copy of the server's temporary inventory item to the temporary record
@ -890,7 +781,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
*
* \return void
*/
API_FUNCTION void CDECL AddRecordInventoryItem() noexcept;
API_FUNCTION void CDECL AddRecordInventoryItem() NOEXCEPT;
/**
* \brief Send a RecordDynamic packet with the current specified record type.
@ -902,7 +793,7 @@ NAMESPACE_BEGIN(RecordsDynamicFunctions)
* to the packet (false by default).
* \return void
*/
API_FUNCTION void CDECL 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

@ -4,10 +4,10 @@
#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>
extern "C" void ServerFunctions::StopServer(int code) noexcept
@ -15,7 +15,7 @@ extern "C" void ServerFunctions::StopServer(int code) noexcept
mwmp::Networking::getPtr()->stopServer(code);
}
extern "C" void ServerFunctions::Kick(unsigned short pid) noexcept
extern "C" void ServerFunctions::Kick(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -56,14 +56,14 @@ extern "C" const char *ServerFunctions::GetProtocolVersion() noexcept
return version.c_str();
}
extern "C" 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);
}
extern "C" const char *ServerFunctions::GetIP(unsigned short pid) noexcept
extern "C" const char *ServerFunctions::GetIP(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, "");
@ -166,5 +166,10 @@ extern "C" void ServerFunctions::AddPluginHash(const char *pluginName, const cha
extern "C" const char* ServerFunctions::GetModDir() noexcept
{
return Script::GetModDir();
return Plugin::GetModDir();
}
const char *ServerFunctions::GetPluginDir() noexcept
{
return Plugin::GetPluginDir();
}

@ -1,41 +1,8 @@
#ifndef OPENMW_SERVERAPI_HPP
#define OPENMW_SERVERAPI_HPP
#include "../Types.hpp"
#include "../api.h"
#include "../api.h"
#define SERVERAPI \
{"StopServer", ServerFunctions::StopServer},\
\
{"Kick", ServerFunctions::Kick},\
{"BanAddress", ServerFunctions::BanAddress},\
{"UnbanAddress", ServerFunctions::UnbanAddress},\
\
{"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},\
{"AddPluginHash", ServerFunctions::AddPluginHash},\
{"GetModDir", ServerFunctions::GetModDir}
NAMESPACE_BEGIN(ServerFunctions)
/**
* \brief Shut down the server.
@ -43,7 +10,7 @@ NAMESPACE_BEGIN(ServerFunctions)
* \param code The shutdown code.
* \return void
*/
API_FUNCTION void CDECL StopServer(int code) noexcept;
API_FUNCTION void CDECL StopServer(int code) NOEXCEPT;
/**
* \brief Kick a certain player from the server.
@ -51,7 +18,7 @@ NAMESPACE_BEGIN(ServerFunctions)
* \param pid The player ID.
* \return void
*/
API_FUNCTION void CDECL Kick(unsigned short pid) noexcept;
API_FUNCTION void CDECL Kick(PlayerId pid) NOEXCEPT;
/**
* \brief Ban a certain IP address from the server.
@ -59,7 +26,7 @@ NAMESPACE_BEGIN(ServerFunctions)
* \param ipAddress The IP address.
* \return void
*/
API_FUNCTION void CDECL BanAddress(const char *ipAddress) noexcept;
API_FUNCTION void CDECL BanAddress(const char *ipAddress) NOEXCEPT;
/**
* \brief Unban a certain IP address from the server.
@ -67,7 +34,7 @@ NAMESPACE_BEGIN(ServerFunctions)
* \param ipAddress The IP address.
* \return void
*/
API_FUNCTION void CDECL UnbanAddress(const char *ipAddress) noexcept;
API_FUNCTION void CDECL UnbanAddress(const char *ipAddress) NOEXCEPT;
/**
* \brief Get the type of the operating system used by the server.
@ -76,7 +43,7 @@ NAMESPACE_BEGIN(ServerFunctions)
*
* \return The type of the operating system.
*/
API_FUNCTION const char *CDECL GetOperatingSystemType() noexcept;
API_FUNCTION const char *CDECL GetOperatingSystemType() NOEXCEPT;
/**
* \brief Get the architecture type used by the server.
@ -85,21 +52,21 @@ NAMESPACE_BEGIN(ServerFunctions)
*
* \return The architecture type.
*/
API_FUNCTION const char *CDECL GetArchitectureType() noexcept;
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;
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;
API_FUNCTION const char *CDECL GetProtocolVersion() NOEXCEPT;
/**
* \brief Get the average ping of a certain player.
@ -107,7 +74,7 @@ NAMESPACE_BEGIN(ServerFunctions)
* \param pid The player ID.
* \return The average ping.
*/
API_FUNCTION int CDECL GetAvgPing(unsigned short pid) noexcept;
API_FUNCTION int CDECL GetAvgPing(PlayerId pid) NOEXCEPT;
/**
* \brief Get the IP address of a certain player.
@ -115,28 +82,28 @@ NAMESPACE_BEGIN(ServerFunctions)
* \param pid The player ID.
* \return The IP address.
*/
API_FUNCTION const CDECL char* GetIP(unsigned short pid) noexcept;
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;
API_FUNCTION unsigned short CDECL GetPort() NOEXCEPT;
/**
* \brief Get the maximum number of players.
*
* \return Max players
*/
API_FUNCTION unsigned int CDECL GetMaxPlayers() noexcept;
API_FUNCTION unsigned int CDECL GetMaxPlayers() NOEXCEPT;
/**
* \brief Checking if the server requires a password to connect.
*
* @return
*/
API_FUNCTION bool CDECL HasPassword() noexcept;
API_FUNCTION bool CDECL HasPassword() NOEXCEPT;
/**
* \brief Get the plugin enforcement state of the server.
@ -145,7 +112,7 @@ NAMESPACE_BEGIN(ServerFunctions)
*
* \return The enforcement state.
*/
API_FUNCTION bool CDECL GetPluginEnforcementState() noexcept;
API_FUNCTION bool CDECL GetPluginEnforcementState() NOEXCEPT;
/**
* \brief Get the script error ignoring state of the server.
@ -154,7 +121,7 @@ NAMESPACE_BEGIN(ServerFunctions)
*
* \return The script error ignoring state.
*/
API_FUNCTION bool CDECL GetScriptErrorIgnoringState() noexcept;
API_FUNCTION bool CDECL GetScriptErrorIgnoringState() NOEXCEPT;
/**
* \brief Set the game mode of the server, as displayed in the server browser.
@ -162,7 +129,7 @@ NAMESPACE_BEGIN(ServerFunctions)
* \param name The new game mode.
* \return void
*/
API_FUNCTION void CDECL SetGameMode(const char* gameMode) noexcept;
API_FUNCTION void CDECL SetGameMode(const char* gameMode) NOEXCEPT;
/**
* \brief Set the name of the server, as displayed in the server browser.
@ -170,7 +137,7 @@ NAMESPACE_BEGIN(ServerFunctions)
* \param name The new name.
* \return void
*/
API_FUNCTION void CDECL SetHostname(const char* name) noexcept;
API_FUNCTION void CDECL SetHostname(const char* name) NOEXCEPT;
/**
* \brief Set the password required to join the server.
@ -178,7 +145,7 @@ NAMESPACE_BEGIN(ServerFunctions)
* \param password The password.
* \return void
*/
API_FUNCTION void CDECL SetServerPassword(const char *password) noexcept;
API_FUNCTION void CDECL SetServerPassword(const char *password) NOEXCEPT;
/**
* \brief Set the plugin enforcement state of the server.
@ -188,7 +155,7 @@ NAMESPACE_BEGIN(ServerFunctions)
* \param state The new enforcement state.
* \return void
*/
API_FUNCTION void CDECL SetPluginEnforcementState(bool state) noexcept;
API_FUNCTION void CDECL SetPluginEnforcementState(bool state) NOEXCEPT;
/**
* \brief Set whether script errors should be ignored or not.
@ -200,7 +167,7 @@ NAMESPACE_BEGIN(ServerFunctions)
* \param state The new script error ignoring state.
* \return void
*/
API_FUNCTION void CDECL SetScriptErrorIgnoringState(bool state) noexcept;
API_FUNCTION void CDECL SetScriptErrorIgnoringState(bool state) NOEXCEPT;
/**
* \brief Set a rule string for the server details displayed in the server browser.
@ -209,7 +176,7 @@ NAMESPACE_BEGIN(ServerFunctions)
* \param value The string value of the rule.
* \return void
*/
API_FUNCTION void CDECL SetRuleString(const char *key, const char *value) noexcept;
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.
@ -218,16 +185,17 @@ NAMESPACE_BEGIN(ServerFunctions)
* \param value The numerical value of the rule.
* \return void
*/
API_FUNCTION void CDECL SetRuleValue(const char *key, double value) noexcept;
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 void CDECL AddPluginHash(const char *pluginName, const char *hash) NOEXCEPT;
API_FUNCTION const char *CDECL GetModDir() noexcept;
API_FUNCTION const char *CDECL GetModDir() NOEXCEPT;
API_FUNCTION const char *CDECL GetPluginDir() NOEXCEPT;
NAMESPACE_END()
#endif //OPENMW_SERVERAPI_HPP

@ -3,13 +3,13 @@
#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;
extern "C" 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 @@ extern "C" void SettingFunctions::SetDifficulty(unsigned short pid, int difficul
player->difficulty = difficulty;
}
extern "C" 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 @@ extern "C" void SettingFunctions::SetEnforcedLogLevel(unsigned short pid, int en
player->enforcedLogLevel = enforcedLogLevel;
}
extern "C" 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 @@ extern "C" void SettingFunctions::SetPhysicsFramerate(unsigned short pid, double
player->physicsFramerate = physicsFramerate;
}
extern "C" 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 @@ extern "C" void SettingFunctions::SetConsoleAllowed(unsigned short pid, bool sta
player->consoleAllowed = state;
}
extern "C" 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 @@ extern "C" void SettingFunctions::SetBedRestAllowed(unsigned short pid, bool sta
player->bedRestAllowed = state;
}
extern "C" 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 @@ extern "C" void SettingFunctions::SetWildernessRestAllowed(unsigned short pid, b
player->wildernessRestAllowed = state;
}
extern "C" 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 @@ extern "C" void SettingFunctions::SetWaitAllowed(unsigned short pid, bool state)
player->waitAllowed = state;
}
extern "C" void SettingFunctions::SendSettings(unsigned short pid) noexcept
extern "C" void SettingFunctions::SendSettings(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player,);

@ -1,22 +1,8 @@
#ifndef OPENMW_SETTINGSAPI_HPP
#define OPENMW_SETTINGSAPI_HPP
#include "../Types.hpp"
#include "../api.h"
#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}
NAMESPACE_BEGIN(SettingFunctions)
/**
* \brief Set the difficulty for a player.
@ -28,7 +14,7 @@ NAMESPACE_BEGIN(SettingFunctions)
* \param difficulty The difficulty.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -46,7 +32,7 @@ NAMESPACE_BEGIN(SettingFunctions)
* \param enforcedLogLevel The enforced log level.
* \return void
*/
API_FUNCTION void CDECL SetEnforcedLogLevel(unsigned short pid, int enforcedLogLevel);
API_FUNCTION void CDECL SetEnforcedLogLevel(PlayerId pid, int enforcedLogLevel);
/**
* \brief Set the physics framerate for a player.
@ -58,7 +44,7 @@ NAMESPACE_BEGIN(SettingFunctions)
* \param physicsFramerate The physics framerate.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -70,7 +56,7 @@ NAMESPACE_BEGIN(SettingFunctions)
* \param state The console permission state.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -82,7 +68,7 @@ NAMESPACE_BEGIN(SettingFunctions)
* \param state The resting permission state.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -94,7 +80,7 @@ NAMESPACE_BEGIN(SettingFunctions)
* \param state The resting permission state.
* \return void
*/
API_FUNCTION void CDECL SetWildernessRestAllowed(unsigned short pid, bool state);
API_FUNCTION void CDECL SetWildernessRestAllowed(PlayerId pid, bool state);
/**
* \brief Set whether waiting is allowed for a player.
@ -106,7 +92,7 @@ NAMESPACE_BEGIN(SettingFunctions)
* \param state The waiting permission state.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -114,7 +100,7 @@ NAMESPACE_BEGIN(SettingFunctions)
* \param pid The player ID to send it to.
* \return void
*/
API_FUNCTION void CDECL SendSettings(unsigned short pid) noexcept;
API_FUNCTION void CDECL SendSettings(PlayerId pid) NOEXCEPT;
NAMESPACE_END()
#endif //OPENMW_SETTINGSAPI_HPP

@ -3,13 +3,13 @@
#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;
extern "C" 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 @@ extern "C" double ShapeshiftFunctions::GetScale(unsigned short pid) noexcept
return player->scale;
}
extern "C" 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 @@ extern "C" bool ShapeshiftFunctions::IsWerewolf(unsigned short pid) noexcept
return player->isWerewolf;
}
extern "C" 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 @@ extern "C" const char *ShapeshiftFunctions::GetCreatureRefId(unsigned short pid)
return player->creatureRefId.c_str();
}
extern "C" 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 @@ extern "C" bool ShapeshiftFunctions::GetCreatureNameDisplayState(unsigned short
return player->displayCreatureName;
}
extern "C" 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 @@ extern "C" void ShapeshiftFunctions::SetScale(unsigned short pid, double scale)
player->scale = scale;
}
extern "C" 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 @@ extern "C" void ShapeshiftFunctions::SetWerewolfState(unsigned short pid, bool i
player->isWerewolf = isWerewolf;
}
extern "C" 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 @@ extern "C" void ShapeshiftFunctions::SetCreatureRefId(unsigned short pid, const
player->creatureRefId = refId;
}
extern "C" 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 @@ extern "C" void ShapeshiftFunctions::SetCreatureNameDisplayState(unsigned short
player->displayCreatureName = displayState;
}
extern "C" void ShapeshiftFunctions::SendShapeshift(unsigned short pid)
extern "C" void ShapeshiftFunctions::SendShapeshift(PlayerId pid)
{
Player *player;
GET_PLAYER(pid, player, );

@ -1,23 +1,8 @@
#ifndef OPENMW_SHAPESHIFTAPI_HPP
#define OPENMW_SHAPESHIFTAPI_HPP
#include "../Types.hpp"
#include "../api.h"
#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}
NAMESPACE_BEGIN(ShapeshiftFunctions)
/**
* \brief Get the scale of a player.
@ -25,7 +10,7 @@ NAMESPACE_BEGIN(ShapeshiftFunctions)
* \param pid The player ID.
* \return The scale.
*/
API_FUNCTION double CDECL GetScale(unsigned short pid) noexcept;
API_FUNCTION double CDECL GetScale(PlayerId pid) NOEXCEPT;
/**
* \brief Check whether a player is a werewolf.
@ -35,7 +20,7 @@ NAMESPACE_BEGIN(ShapeshiftFunctions)
* \param pid The player ID.
* \return The werewolf state.
*/
API_FUNCTION bool CDECL 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.
@ -43,7 +28,7 @@ NAMESPACE_BEGIN(ShapeshiftFunctions)
* \param pid The player ID.
* \return The creature refId.
*/
API_FUNCTION const char *CDECL 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
@ -54,7 +39,7 @@ NAMESPACE_BEGIN(ShapeshiftFunctions)
* \param pid The player ID.
* \return The creature name display state.
*/
API_FUNCTION bool CDECL GetCreatureNameDisplayState(unsigned short pid) noexcept;
API_FUNCTION bool CDECL GetCreatureNameDisplayState(PlayerId pid) NOEXCEPT;
/**
* \brief Set the scale of a player.
@ -66,7 +51,7 @@ NAMESPACE_BEGIN(ShapeshiftFunctions)
* \param scale The new scale.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -78,7 +63,7 @@ NAMESPACE_BEGIN(ShapeshiftFunctions)
* \param isWerewolf The new werewolf state.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -92,7 +77,7 @@ NAMESPACE_BEGIN(ShapeshiftFunctions)
* when hovered over by others.
* \return void
*/
API_FUNCTION void CDECL 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
@ -102,7 +87,7 @@ NAMESPACE_BEGIN(ShapeshiftFunctions)
* \param displayState The creature name display state.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -113,7 +98,7 @@ NAMESPACE_BEGIN(ShapeshiftFunctions)
* \param pid The player ID.
* \return void
*/
API_FUNCTION void CDECL SendShapeshift(unsigned short pid);
API_FUNCTION void CDECL SendShapeshift(PlayerId pid);
NAMESPACE_END()
#endif //OPENMW_SHAPESHIFTAPI_HPP

@ -3,12 +3,12 @@
#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;
extern "C" 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 @@ extern "C" void SpellFunctions::ClearSpellbookChanges(unsigned short pid) noexce
player->spellbookChanges.spells.clear();
}
extern "C" 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 @@ extern "C" unsigned int SpellFunctions::GetSpellbookChangesSize(unsigned short p
return player->spellbookChanges.count;
}
extern "C" 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 @@ extern "C" unsigned int SpellFunctions::GetSpellbookChangesAction(unsigned short
return player->spellbookChanges.action;
}
extern "C" 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 @@ extern "C" void SpellFunctions::SetSpellbookChangesAction(unsigned short pid, un
player->spellbookChanges.action = action;
}
extern "C" 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 @@ extern "C" void SpellFunctions::AddSpell(unsigned short pid, const char* spellId
player->spellbookChanges.spells.push_back(spell);
}
extern "C" 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 @@ extern "C" const char *SpellFunctions::GetSpellId(unsigned short pid, unsigned i
return player->spellbookChanges.spells.at(index).mId.c_str();
}
extern "C" 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, );
@ -78,7 +78,7 @@ extern "C" void SpellFunctions::SendSpellbookChanges(unsigned short pid, bool se
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);
}

@ -27,7 +27,7 @@ NAMESPACE_BEGIN(SpellFunctions)
* \param pid The player ID whose spellbook changes should be used.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -35,7 +35,7 @@ NAMESPACE_BEGIN(SpellFunctions)
* \param pid The player ID whose spellbook changes should be used.
* \return The number of indexes.
*/
API_FUNCTION unsigned int CDECL 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.
@ -43,7 +43,7 @@ NAMESPACE_BEGIN(SpellFunctions)
* \param pid The player ID whose spellbook changes should be used.
* \return The action type (0 for SET, 1 for ADD, 2 for REMOVE).
*/
API_FUNCTION unsigned int CDECL 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.
@ -52,7 +52,7 @@ NAMESPACE_BEGIN(SpellFunctions)
* \param action The action (0 for SET, 1 for ADD, 2 for REMOVE).
* \return void
*/
API_FUNCTION void CDECL 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.
@ -61,7 +61,7 @@ NAMESPACE_BEGIN(SpellFunctions)
* \param spellId The spellId of the spell.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -70,7 +70,7 @@ NAMESPACE_BEGIN(SpellFunctions)
* \param index The index of the spell.
* \return The spellId.
*/
API_FUNCTION const char *CDECL 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.
@ -82,11 +82,11 @@ NAMESPACE_BEGIN(SpellFunctions)
* to the packet (false by default).
* \return void
*/
API_FUNCTION void CDECL 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
API_FUNCTION void CDECL InitializeSpellbookChanges(unsigned short pid) noexcept;
API_FUNCTION void CDECL InitializeSpellbookChanges(PlayerId pid) NOEXCEPT;
NAMESPACE_END()
#endif //OPENMW_SPELLAPI_HPP

@ -9,7 +9,7 @@
#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;
@ -66,7 +66,7 @@ extern "C" const char *StatsFunctions::GetSkillName(unsigned short skillId) noex
return Skill::sSkillNames[skillId].c_str();
}
extern "C" const char *StatsFunctions::GetName(unsigned short pid) noexcept
extern "C" const char *StatsFunctions::GetName(PlayerId pid) noexcept
{
Player *player;
@ -75,7 +75,7 @@ extern "C" const char *StatsFunctions::GetName(unsigned short pid) noexcept
return player->npc.mName.c_str();
}
extern "C" 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 @@ extern "C" const char *StatsFunctions::GetRace(unsigned short pid) noexcept
return player->npc.mRace.c_str();
}
extern "C" 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 @@ extern "C" const char *StatsFunctions::GetHead(unsigned short pid) noexcept
return player->npc.mHead.c_str();
}
extern "C" 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 @@ extern "C" const char *StatsFunctions::GetHairstyle(unsigned short pid) noexcept
return player->npc.mHair.c_str();
}
extern "C" 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 @@ extern "C" int StatsFunctions::GetIsMale(unsigned short pid) noexcept
return player->npc.isMale();
}
extern "C" 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 @@ extern "C" const char *StatsFunctions::GetBirthsign(unsigned short pid) noexcept
return player->birthsign.c_str();
}
extern "C" 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 @@ extern "C" int StatsFunctions::GetLevel(unsigned short pid) noexcept
return player->creatureStats.mLevel;
}
extern "C" 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 @@ extern "C" int StatsFunctions::GetLevelProgress(unsigned short pid) noexcept
return player->npcStats.mLevelProgress;
}
extern "C" 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 @@ extern "C" double StatsFunctions::GetHealthBase(unsigned short pid) noexcept
return player->creatureStats.mDynamic[0].mBase;
}
extern "C" 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 @@ extern "C" double StatsFunctions::GetHealthCurrent(unsigned short pid) noexcept
return player->creatureStats.mDynamic[0].mCurrent;
}
extern "C" 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 @@ extern "C" double StatsFunctions::GetMagickaBase(unsigned short pid) noexcept
return player->creatureStats.mDynamic[1].mBase;
}
extern "C" 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 @@ extern "C" double StatsFunctions::GetMagickaCurrent(unsigned short pid) noexcept
return player->creatureStats.mDynamic[1].mCurrent;
}
extern "C" 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 @@ extern "C" double StatsFunctions::GetFatigueBase(unsigned short pid) noexcept
return player->creatureStats.mDynamic[2].mBase;
}
extern "C" 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 @@ extern "C" double StatsFunctions::GetFatigueCurrent(unsigned short pid) noexcept
return player->creatureStats.mDynamic[2].mCurrent;
}
extern "C" 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 @@ extern "C" int StatsFunctions::GetAttributeBase(unsigned short pid, unsigned sho
return player->creatureStats.mAttributes[attributeId].mBase;
}
extern "C" 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,7 +201,7 @@ extern "C" int StatsFunctions::GetAttributeModifier(unsigned short pid, unsigned
return player->creatureStats.mAttributes[attributeId].mMod;
}
extern "C" 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);
@ -212,7 +212,7 @@ extern "C" int StatsFunctions::GetSkillBase(unsigned short pid, unsigned short s
return player->npcStats.mSkills[skillId].mBase;
}
extern "C" 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);
@ -223,7 +223,7 @@ extern "C" int StatsFunctions::GetSkillModifier(unsigned short pid, unsigned sho
return player->npcStats.mSkills[skillId].mMod;
}
extern "C" 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);
@ -234,7 +234,7 @@ extern "C" double StatsFunctions::GetSkillProgress(unsigned short pid, unsigned
return player->npcStats.mSkills[skillId].mProgress;
}
extern "C" 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);
@ -245,7 +245,7 @@ extern "C" int StatsFunctions::GetSkillIncrease(unsigned short pid, unsigned int
return player->npcStats.mSkillIncrease[attributeId];
}
extern "C" int StatsFunctions::GetBounty(unsigned short pid) noexcept
extern "C" int StatsFunctions::GetBounty(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -253,7 +253,7 @@ extern "C" int StatsFunctions::GetBounty(unsigned short pid) noexcept
return player->npcStats.mBounty;
}
extern "C" 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,);
@ -264,7 +264,7 @@ extern "C" void StatsFunctions::SetName(unsigned short pid, const char *name) no
player->npc.mName = name;
}
extern "C" 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,);
@ -278,7 +278,7 @@ extern "C" void StatsFunctions::SetRace(unsigned short pid, const char *race) no
player->npc.mRace = race;
}
extern "C" 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,);
@ -289,7 +289,7 @@ extern "C" void StatsFunctions::SetHead(unsigned short pid, const char *head) no
player->npc.mHead = head;
}
extern "C" 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,);
@ -300,7 +300,7 @@ extern "C" void StatsFunctions::SetHairstyle(unsigned short pid, const char *hai
player->npc.mHair = hairstyle;
}
extern "C" 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,);
@ -308,7 +308,7 @@ extern "C" void StatsFunctions::SetIsMale(unsigned short pid, int state) noexcep
player->npc.setIsMale(state == true);
}
extern "C" 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, );
@ -319,7 +319,7 @@ extern "C" void StatsFunctions::SetBirthsign(unsigned short pid, const char *sig
player->birthsign = sign;
}
extern "C" 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, );
@ -327,7 +327,7 @@ extern "C" void StatsFunctions::SetResetStats(unsigned short pid, bool resetStat
player->resetStats = resetStats;
}
extern "C" 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, );
@ -335,7 +335,7 @@ extern "C" void StatsFunctions::SetLevel(unsigned short pid, int value) noexcept
player->creatureStats.mLevel = value;
}
extern "C" 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, );
@ -343,7 +343,7 @@ extern "C" void StatsFunctions::SetLevelProgress(unsigned short pid, int value)
player->npcStats.mLevelProgress = value;
}
extern "C" 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,);
@ -354,7 +354,7 @@ extern "C" void StatsFunctions::SetHealthBase(unsigned short pid, double value)
player->statsDynamicIndexChanges.push_back(0);
}
extern "C" 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,);
@ -365,7 +365,7 @@ extern "C" void StatsFunctions::SetHealthCurrent(unsigned short pid, double valu
player->statsDynamicIndexChanges.push_back(0);
}
extern "C" 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,);
@ -376,7 +376,7 @@ extern "C" void StatsFunctions::SetMagickaBase(unsigned short pid, double value)
player->statsDynamicIndexChanges.push_back(1);
}
extern "C" 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,);
@ -387,7 +387,7 @@ extern "C" void StatsFunctions::SetMagickaCurrent(unsigned short pid, double val
player->statsDynamicIndexChanges.push_back(1);
}
extern "C" 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,);
@ -398,7 +398,7 @@ extern "C" void StatsFunctions::SetFatigueBase(unsigned short pid, double value)
player->statsDynamicIndexChanges.push_back(2);
}
extern "C" 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,);
@ -409,7 +409,7 @@ extern "C" void StatsFunctions::SetFatigueCurrent(unsigned short pid, double val
player->statsDynamicIndexChanges.push_back(2);
}
extern "C" 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,);
@ -423,7 +423,7 @@ extern "C" void StatsFunctions::SetAttributeBase(unsigned short pid, unsigned sh
player->attributeIndexChanges.push_back(attributeId);
}
extern "C" 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,);
@ -437,7 +437,7 @@ extern "C" void StatsFunctions::ClearAttributeModifier(unsigned short pid, unsig
player->attributeIndexChanges.push_back(attributeId);
}
extern "C" 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,);
@ -451,7 +451,7 @@ extern "C" void StatsFunctions::SetSkillBase(unsigned short pid, unsigned short
player->skillIndexChanges.push_back(skillId);
}
extern "C" 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,);
@ -465,7 +465,7 @@ extern "C" void StatsFunctions::ClearSkillModifier(unsigned short pid, unsigned
player->skillIndexChanges.push_back(skillId);
}
extern "C" 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, );
@ -479,7 +479,7 @@ extern "C" void StatsFunctions::SetSkillProgress(unsigned short pid, unsigned sh
player->skillIndexChanges.push_back(skillId);
}
extern "C" 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,);
@ -493,7 +493,7 @@ extern "C" void StatsFunctions::SetSkillIncrease(unsigned short pid, unsigned in
player->attributeIndexChanges.push_back(attributeId);
}
extern "C" 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, );
@ -501,7 +501,7 @@ extern "C" void StatsFunctions::SetBounty(unsigned short pid, int value) noexcep
player->npcStats.mBounty = value;
}
extern "C" 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,);
@ -516,7 +516,7 @@ extern "C" void StatsFunctions::SetCharGenStage(unsigned short pid, int currentS
packet->Send(false);
}
extern "C" void StatsFunctions::SendBaseInfo(unsigned short pid) noexcept
extern "C" void StatsFunctions::SendBaseInfo(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -528,7 +528,7 @@ extern "C" void StatsFunctions::SendBaseInfo(unsigned short pid) noexcept
packet->Send(true);
}
extern "C" void StatsFunctions::SendStatsDynamic(unsigned short pid) noexcept
extern "C" void StatsFunctions::SendStatsDynamic(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -542,7 +542,7 @@ extern "C" void StatsFunctions::SendStatsDynamic(unsigned short pid) noexcept
player->statsDynamicIndexChanges.clear();
}
extern "C" void StatsFunctions::SendAttributes(unsigned short pid) noexcept
extern "C" void StatsFunctions::SendAttributes(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -556,7 +556,7 @@ extern "C" void StatsFunctions::SendAttributes(unsigned short pid) noexcept
player->attributeIndexChanges.clear();
}
extern "C" void StatsFunctions::SendSkills(unsigned short pid) noexcept
extern "C" void StatsFunctions::SendSkills(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -570,7 +570,7 @@ extern "C" void StatsFunctions::SendSkills(unsigned short pid) noexcept
player->skillIndexChanges.clear();
}
extern "C" void StatsFunctions::SendLevel(unsigned short pid) noexcept
extern "C" void StatsFunctions::SendLevel(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -582,7 +582,7 @@ extern "C" void StatsFunctions::SendLevel(unsigned short pid) noexcept
packet->Send(true);
}
extern "C" void StatsFunctions::SendBounty(unsigned short pid) noexcept
extern "C" void StatsFunctions::SendBounty(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );

@ -85,7 +85,7 @@ NAMESPACE_BEGIN(StatsFunctions)
*
* \return The number of attributes.
*/
API_FUNCTION int CDECL GetAttributeCount() noexcept;
API_FUNCTION int CDECL GetAttributeCount() NOEXCEPT;
/**
* \brief Get the number of skills.
@ -94,7 +94,7 @@ NAMESPACE_BEGIN(StatsFunctions)
*
* \return The number of skills.
*/
API_FUNCTION int CDECL GetSkillCount() noexcept;
API_FUNCTION int CDECL GetSkillCount() NOEXCEPT;
/**
* \brief Get the numerical ID of an attribute with a certain name.
@ -104,7 +104,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param name The name of the attribute.
* \return The ID of the attribute.
*/
API_FUNCTION int CDECL 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.
@ -114,7 +114,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param name The name of the skill.
* \return The ID of the skill.
*/
API_FUNCTION int CDECL 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.
@ -124,7 +124,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param attributeId The ID of the attribute.
* \return The name of the attribute.
*/
API_FUNCTION const char *CDECL 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.
@ -134,7 +134,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param skillId The ID of the skill.
* \return The name of the skill.
*/
API_FUNCTION const char *CDECL GetSkillName(unsigned short skillId) noexcept;
API_FUNCTION const char *CDECL GetSkillName(unsigned short skillId) NOEXCEPT;
/**
* \brief Get the name of a player.
@ -142,7 +142,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param pid The player ID.
* \return The name of the player.
*/
API_FUNCTION const char *CDECL GetName(unsigned short pid) noexcept;
API_FUNCTION const char *CDECL GetName(PlayerId pid) NOEXCEPT;
/**
* \brief Get the race of a player.
@ -150,7 +150,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param pid The player ID.
* \return The race of the player.
*/
API_FUNCTION const char *CDECL GetRace(unsigned short pid) noexcept;
API_FUNCTION const char *CDECL GetRace(PlayerId pid) NOEXCEPT;
/**
* \brief Get the head mesh used by a player.
@ -158,7 +158,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param pid The player ID.
* \return The head mesh of the player.
*/
API_FUNCTION const char *CDECL GetHead(unsigned short pid) noexcept;
API_FUNCTION const char *CDECL GetHead(PlayerId pid) NOEXCEPT;
/**
* \brief Get the hairstyle mesh used by a player.
@ -166,7 +166,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param pid The player ID.
* \return The hairstyle mesh of the player.
*/
API_FUNCTION const char *CDECL GetHairstyle(unsigned short pid) noexcept;
API_FUNCTION const char *CDECL GetHairstyle(PlayerId pid) NOEXCEPT;
/**
* \brief Check whether a player is male or not.
@ -174,7 +174,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param pid The player ID.
* \return Whether the player is male.
*/
API_FUNCTION int CDECL GetIsMale(unsigned short pid) noexcept;
API_FUNCTION int CDECL GetIsMale(PlayerId pid) NOEXCEPT;
/**
* \brief Get the birthsign of a player.
@ -182,7 +182,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param pid The player ID.
* \return The birthsign of the player.
*/
API_FUNCTION const char *CDECL GetBirthsign(unsigned short pid) noexcept;
API_FUNCTION const char *CDECL GetBirthsign(PlayerId pid) NOEXCEPT;
/**
* \brief Get the character level of a player.
@ -190,7 +190,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param pid The player ID.
* \return The level of the player.
*/
API_FUNCTION int CDECL GetLevel(unsigned short pid) noexcept;
API_FUNCTION int CDECL GetLevel(PlayerId pid) NOEXCEPT;
/**
* \brief Get the player's progress to their next character level.
@ -198,7 +198,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param pid The player ID.
* \return The level progress.
*/
API_FUNCTION int CDECL GetLevelProgress(unsigned short pid) noexcept;
API_FUNCTION int CDECL GetLevelProgress(PlayerId pid) NOEXCEPT;
/**
* \brief Get the base health of the player.
@ -206,7 +206,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param pid The player ID.
* \return The base health.
*/
API_FUNCTION double CDECL GetHealthBase(unsigned short pid) noexcept;
API_FUNCTION double CDECL GetHealthBase(PlayerId pid) NOEXCEPT;
/**
* \brief Get the current health of the player.
@ -214,7 +214,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param pid The player ID.
* \return The current health.
*/
API_FUNCTION double CDECL GetHealthCurrent(unsigned short pid) noexcept;
API_FUNCTION double CDECL GetHealthCurrent(PlayerId pid) NOEXCEPT;
/**
* \brief Get the base magicka of the player.
@ -222,7 +222,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param pid The player ID.
* \return The base magicka.
*/
API_FUNCTION double CDECL GetMagickaBase(unsigned short pid) noexcept;
API_FUNCTION double CDECL GetMagickaBase(PlayerId pid) NOEXCEPT;
/**
* \brief Get the current magicka of the player.
@ -230,7 +230,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param pid The player ID.
* \return The current magicka.
*/
API_FUNCTION double CDECL GetMagickaCurrent(unsigned short pid) noexcept;
API_FUNCTION double CDECL GetMagickaCurrent(PlayerId pid) NOEXCEPT;
/**
* \brief Get the base fatigue of the player.
@ -238,7 +238,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param pid The player ID.
* \return The base fatigue.
*/
API_FUNCTION double CDECL GetFatigueBase(unsigned short pid) noexcept;
API_FUNCTION double CDECL GetFatigueBase(PlayerId pid) NOEXCEPT;
/**
* \brief Get the current fatigue of the player.
@ -246,7 +246,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param pid The player ID.
* \return The current fatigue.
*/
API_FUNCTION double CDECL GetFatigueCurrent(unsigned short pid) noexcept;
API_FUNCTION double CDECL GetFatigueCurrent(PlayerId pid) NOEXCEPT;
/**
* \brief Get the base value of a player's attribute.
@ -255,7 +255,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param attributeId The attribute ID.
* \return The base value of the attribute.
*/
API_FUNCTION int CDECL 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.
@ -264,7 +264,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param attributeId The attribute ID.
* \return The modifier value of the attribute.
*/
API_FUNCTION int CDECL GetAttributeModifier(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.
@ -273,7 +273,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param skillId The skill ID.
* \return The base value of the skill.
*/
API_FUNCTION int CDECL 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.
@ -282,7 +282,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param skillId The skill ID.
* \return The modifier value of the skill.
*/
API_FUNCTION int CDECL GetSkillModifier(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.
@ -291,7 +291,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param skillId The skill ID.
* \return The skill progress.
*/
API_FUNCTION double CDECL 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
@ -303,7 +303,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param skillId The attribute ID.
* \return The increase in the attribute caused by skills.
*/
API_FUNCTION int CDECL 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.
@ -311,7 +311,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param pid The player ID.
* \return The bounty.
*/
API_FUNCTION int CDECL GetBounty(unsigned short pid) noexcept;
API_FUNCTION int CDECL GetBounty(PlayerId pid) NOEXCEPT;
/**
* \brief Set the name of a player.
@ -320,7 +320,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param name The new name of the player.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -329,7 +329,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param race The new race of the player.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -338,7 +338,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param head The new head mesh of the player.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -347,7 +347,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param hairstyle The new hairstyle mesh of the player.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -356,7 +356,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param state Whether the player is male.
* \return void
*/
API_FUNCTION void CDECL SetIsMale(unsigned short pid, int state) noexcept;
API_FUNCTION void CDECL SetIsMale(PlayerId pid, int state) NOEXCEPT;
/**
* \brief Set the birthsign of a player.
@ -365,7 +365,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param name The new birthsign of the player.
* \return void
*/
API_FUNCTION void CDECL 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
@ -378,7 +378,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param resetStats The stat reset state.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -387,7 +387,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param value The new level of the player.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -396,7 +396,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param value The new level progress of the player.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -405,7 +405,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param name The new base health of the player.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -414,7 +414,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param name The new current health of the player.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -423,7 +423,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param name The new base magicka of the player.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -432,7 +432,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param name The new current magicka of the player.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -441,7 +441,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param name The new base fatigue of the player.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -450,7 +450,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param name The new current fatigue of the player.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -460,7 +460,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param value The new base value of the player's attribute.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -474,7 +474,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param attributeId The attribute ID.
* \return void
*/
API_FUNCTION void CDECL ClearAttributeModifier(unsigned short pid, unsigned short attributeId) noexcept;
API_FUNCTION void CDECL ClearAttributeModifier(PlayerId pid, unsigned short attributeId) NOEXCEPT;
/**
* \brief Set the base value of a player's skill.
@ -484,7 +484,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param value The new base value of the player's skill.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -498,7 +498,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param skillId The skill ID.
* \return void
*/
API_FUNCTION void CDECL ClearSkillModifier(unsigned short pid, unsigned short skillId) 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.
@ -508,7 +508,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param value The progress value.
* \return void
*/
API_FUNCTION void CDECL 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
@ -521,7 +521,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param value The increase in the attribute caused by skills.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -530,7 +530,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param value The new bounty.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -542,7 +542,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param endStage The new ending stage.
* \return void
*/
API_FUNCTION void CDECL 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,
@ -553,7 +553,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param pid The player ID.
* \return void
*/
API_FUNCTION void CDECL 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,
@ -564,7 +564,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param pid The player ID.
* \return void
*/
API_FUNCTION void CDECL 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
@ -576,7 +576,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param pid The player ID.
* \return void
*/
API_FUNCTION void CDECL SendAttributes(unsigned short pid) noexcept;
API_FUNCTION void CDECL SendAttributes(PlayerId pid) NOEXCEPT;
/**
* \brief Send a PlayerSkill packet with a player's skills.
@ -586,7 +586,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param pid The player ID.
* \return void
*/
API_FUNCTION void CDECL 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
@ -597,7 +597,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param pid The player ID.
* \return void
*/
API_FUNCTION void CDECL SendLevel(unsigned short pid) noexcept;
API_FUNCTION void CDECL SendLevel(PlayerId pid) NOEXCEPT;
/**
* \brief Send a PlayerBounty packet with a player's bounty.
@ -607,7 +607,7 @@ NAMESPACE_BEGIN(StatsFunctions)
* \param pid The player ID.
* \return void
*/
API_FUNCTION void CDECL SendBounty(unsigned short pid) noexcept;
API_FUNCTION void CDECL SendBounty(PlayerId pid) NOEXCEPT;
NAMESPACE_END()
#endif //OPENMW_STATAPI_HPP

@ -2,7 +2,7 @@
// 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>
@ -15,23 +15,24 @@ using namespace mwmp;
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);
}
extern "C" int TimerFunctions::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;
ScriptFunctions::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;
}
}
extern "C" void TimerFunctions::StartTimer(int timerId) noexcept
@ -58,3 +59,13 @@ 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);
}

@ -5,8 +5,8 @@
#ifndef OPENMW_TIMER_HPP
#define OPENMW_TIMER_HPP
#include <Script/ScriptFunction.hpp>
#include "../api.h"
#include <stdarg.h>
NAMESPACE_BEGIN(TimerFunctions)
/**
@ -16,7 +16,7 @@ NAMESPACE_BEGIN(TimerFunctions)
* \param msec The interval in miliseconds.
* \return The ID of the timer thus created.
*/
API_FUNCTION int CDECL CreateTimer(ScriptFunc callback, int msec) noexcept;
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
@ -32,7 +32,7 @@ NAMESPACE_BEGIN(TimerFunctions)
* \param args The arguments.
* \return The ID of the timer thus created.
*/
API_FUNCTION int CDECL CreateTimerEx(ScriptFunc callback, int msec, const char *types, va_list args) noexcept;
API_FUNCTION int CDECL CreateTimerEx(ScriptFunc callback, int msec, const char *types, ...) NOEXCEPT;
/**
* \brief Start the timer with a certain ID.
@ -40,7 +40,7 @@ NAMESPACE_BEGIN(TimerFunctions)
* \param timerId The timer ID.
* \return void
*/
API_FUNCTION void CDECL StartTimer(int timerId) noexcept;
API_FUNCTION void CDECL StartTimer(int timerId) NOEXCEPT;
/**
* \brief Stop the timer with a certain ID.
@ -48,7 +48,7 @@ NAMESPACE_BEGIN(TimerFunctions)
* \param timerId The timer ID.
* \return void
*/
API_FUNCTION void CDECL StopTimer(int timerId) noexcept;
API_FUNCTION void CDECL StopTimer(int timerId) NOEXCEPT;
/**
* \brief Restart the timer with a certain ID for a certain interval.
@ -57,7 +57,7 @@ NAMESPACE_BEGIN(TimerFunctions)
* \param msec The interval in miliseconds.
* \return void
*/
API_FUNCTION void CDECL RestartTimer(int timerId, int msec) noexcept;
API_FUNCTION void CDECL RestartTimer(int timerId, int msec) NOEXCEPT;
/**
* \brief Free the timer with a certain ID.
@ -65,7 +65,7 @@ NAMESPACE_BEGIN(TimerFunctions)
* \param timerId The timer ID.
* \return void
*/
API_FUNCTION void CDECL FreeTimer(int timerId) noexcept;
API_FUNCTION void CDECL FreeTimer(int timerId) NOEXCEPT;
/**
* \brief Check whether a timer is elapsed.
@ -73,7 +73,22 @@ NAMESPACE_BEGIN(TimerFunctions)
* \param timerId The timer ID.
* \return Whether the timer is elapsed.
*/
API_FUNCTION bool CDECL IsTimerElapsed(int timerId) noexcept;
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,7 +2,7 @@
#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.h"
@ -196,7 +196,7 @@ extern "C" void WorldstateFunctions::LoadMapTileImageFile(int cellX, int cellY,
}
}
extern "C" 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 @@ extern "C" void WorldstateFunctions::SendWorldMap(unsigned short pid, bool sendT
packet->Send(true);
}
extern "C" 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 @@ extern "C" void WorldstateFunctions::SendWorldTime(unsigned short pid, bool send
packet->Send(true);
}
extern "C" 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 @@ extern "C" void WorldstateFunctions::SendWorldWeather(unsigned short pid, bool s
packet->Send(true);
}
extern "C" 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 @@ extern "C" void WorldstateFunctions::SendWorldCollisionOverride(unsigned short p
packet->Send(true);
}
extern "C" void WorldstateFunctions::SendWorldRegionAuthority(unsigned short pid) noexcept
extern "C" void WorldstateFunctions::SendWorldRegionAuthority(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );

@ -1,74 +1,22 @@
#ifndef OPENMW_WORLDSTATEAPI_HPP
#define OPENMW_WORLDSTATEAPI_HPP
#ifdef _HOST
#include <components/openmw-mp/Base/BaseWorldstate.hpp>
#include "../Types.hpp"
#endif
#include "../api.h"
#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}
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
*/
API_FUNCTION void CDECL ReadReceivedWorldstate() noexcept;
API_FUNCTION void CDECL ReadReceivedWorldstate() NOEXCEPT;
/**
* \brief Take the contents of the read-only worldstate last received by the
@ -77,7 +25,7 @@ NAMESPACE_BEGIN(WorldstateFunctions)
*
* \return void
*/
API_FUNCTION void CDECL CopyReceivedWorldstateToStore() noexcept;
API_FUNCTION void CDECL CopyReceivedWorldstateToStore() NOEXCEPT;
/**
* \brief Clear the map changes for the write-only worldstate.
@ -86,49 +34,49 @@ NAMESPACE_BEGIN(WorldstateFunctions)
*
* \return void
*/
API_FUNCTION void CDECL 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.
*/
API_FUNCTION unsigned int CDECL GetMapChangesSize() noexcept;
API_FUNCTION unsigned int CDECL GetMapChangesSize() NOEXCEPT;
/**
* \brief Get the weather region in the read worldstate.
*
* \return The weather region.
*/
API_FUNCTION const char *CDECL GetWeatherRegion() noexcept;
API_FUNCTION const char *CDECL GetWeatherRegion() NOEXCEPT;
/**
* \brief Get the current weather in the read worldstate.
*
* \return The current weather.
*/
API_FUNCTION int CDECL GetWeatherCurrent() noexcept;
API_FUNCTION int CDECL GetWeatherCurrent() NOEXCEPT;
/**
* \brief Get the next weather in the read worldstate.
*
* \return The next weather.
*/
API_FUNCTION int CDECL GetWeatherNext() noexcept;
API_FUNCTION int CDECL GetWeatherNext() NOEXCEPT;
/**
* \brief Get the queued weather in the read worldstate.
*
* \return The queued weather.
*/
API_FUNCTION int CDECL 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.
*/
API_FUNCTION double CDECL 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
@ -137,7 +85,7 @@ NAMESPACE_BEGIN(WorldstateFunctions)
* \param index The index of the map tile.
* \return The X coordinate of the cell.
*/
API_FUNCTION int CDECL 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
@ -146,7 +94,7 @@ NAMESPACE_BEGIN(WorldstateFunctions)
* \param index The index of the map tile.
* \return The Y coordinate of the cell.
*/
API_FUNCTION int CDECL 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.
@ -154,7 +102,7 @@ NAMESPACE_BEGIN(WorldstateFunctions)
* \param region The region.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -162,7 +110,7 @@ NAMESPACE_BEGIN(WorldstateFunctions)
* \param region The region.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -172,7 +120,7 @@ NAMESPACE_BEGIN(WorldstateFunctions)
* \param forceState The weather forcing state.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -180,7 +128,7 @@ NAMESPACE_BEGIN(WorldstateFunctions)
* \param currentWeather The current weather.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -188,7 +136,7 @@ NAMESPACE_BEGIN(WorldstateFunctions)
* \param nextWeather The next weather.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -196,7 +144,7 @@ NAMESPACE_BEGIN(WorldstateFunctions)
* \param queuedWeather The queued weather.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -204,7 +152,7 @@ NAMESPACE_BEGIN(WorldstateFunctions)
* \param transitionFactor The transition factor.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -212,7 +160,7 @@ NAMESPACE_BEGIN(WorldstateFunctions)
* \param hour The hour.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -220,7 +168,7 @@ NAMESPACE_BEGIN(WorldstateFunctions)
* \param day The day.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -228,7 +176,7 @@ NAMESPACE_BEGIN(WorldstateFunctions)
* \param month The month.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -236,7 +184,7 @@ NAMESPACE_BEGIN(WorldstateFunctions)
* \param year The year.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -244,7 +192,7 @@ NAMESPACE_BEGIN(WorldstateFunctions)
* \param daysPassed The days passed.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -253,7 +201,7 @@ NAMESPACE_BEGIN(WorldstateFunctions)
* \param timeScale The time scale.
* \return void
*/
API_FUNCTION void CDECL 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
@ -262,7 +210,7 @@ NAMESPACE_BEGIN(WorldstateFunctions)
* \param state The collision state.
* \return void
*/
API_FUNCTION void CDECL 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
@ -271,7 +219,7 @@ NAMESPACE_BEGIN(WorldstateFunctions)
* \param state The collision state.
* \return void
*/
API_FUNCTION void CDECL 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
@ -280,7 +228,7 @@ NAMESPACE_BEGIN(WorldstateFunctions)
* \param state The collision state.
* \return void
*/
API_FUNCTION void CDECL 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.
@ -289,7 +237,7 @@ NAMESPACE_BEGIN(WorldstateFunctions)
* \param useActorCollision Whether to use actor collision.
* \return void
*/
API_FUNCTION void CDECL 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
@ -298,7 +246,7 @@ NAMESPACE_BEGIN(WorldstateFunctions)
* \param refId The refId.
* \return void
*/
API_FUNCTION void CDECL 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
@ -306,7 +254,7 @@ NAMESPACE_BEGIN(WorldstateFunctions)
*
* \return void
*/
API_FUNCTION void CDECL 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
@ -316,7 +264,7 @@ NAMESPACE_BEGIN(WorldstateFunctions)
* \param filePath The file path of the resulting file.
* \return void
*/
API_FUNCTION void CDECL 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
@ -327,7 +275,7 @@ NAMESPACE_BEGIN(WorldstateFunctions)
* \param filePath The file path of the loaded file.
* \return void
*/
API_FUNCTION void CDECL 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
@ -338,7 +286,7 @@ NAMESPACE_BEGIN(WorldstateFunctions)
* \param pid The player ID attached to the packet.
* \return void
*/
API_FUNCTION void CDECL 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
@ -349,7 +297,7 @@ NAMESPACE_BEGIN(WorldstateFunctions)
* or to all players on the server.
* \return void
*/
API_FUNCTION void CDECL 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
@ -362,7 +310,7 @@ NAMESPACE_BEGIN(WorldstateFunctions)
* to the packet (false by default).
* \return void
*/
API_FUNCTION void CDECL 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.
@ -374,7 +322,7 @@ NAMESPACE_BEGIN(WorldstateFunctions)
* to the packet (false by default).
* \return void
*/
API_FUNCTION void CDECL 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
@ -387,13 +335,13 @@ NAMESPACE_BEGIN(WorldstateFunctions)
* to the packet (false by default).
* \return void
*/
API_FUNCTION void CDECL 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
API_FUNCTION void CDECL ReadLastWorldstate() noexcept;
API_FUNCTION void CDECL 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(std::string("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(std::string("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,184 +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, const 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;
auto retTypeHash = result.type().hash_code();
if (retTypeHash == typeid(signed int).hash_code())
luabridge::Stack<signed int>::push(lua, boost::any_cast<signed int>(result));
else if (retTypeHash == typeid(unsigned int).hash_code())
luabridge::Stack<unsigned int>::push(lua, boost::any_cast<unsigned int>(result));
else if (retTypeHash == typeid(double).hash_code())
luabridge::Stack<double>::push(lua, boost::any_cast<double>(result));
else if (retTypeHash == 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(): lib(nullptr)
{
}
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

@ -50,9 +50,11 @@
#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

@ -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,121 +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());
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,70 +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::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(std::string("C++ call: Unknown argument identifier ") + c);
}
}
}
catch (...)
{
va_end(args);
throw;
}
va_end(args);
}

@ -1,148 +0,0 @@
#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 <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 GetArguments(std::vector<boost::any> &params, va_list args, const std::string &def);
static constexpr ScriptFunctionData functions[]{
{"CreateTimer", TimerFunctions::CreateTimer},
{"CreateTimerEx", TimerFunctions::CreateTimerEx},
{"MakePublic", PublicFunctions::MakePublic},
{"CallPublic", PublicFunctions::CallPublic},
{"StartTimer", TimerFunctions::StartTimer},
{"StopTimer", TimerFunctions::StopTimer},
{"RestartTimer", TimerFunctions::RestartTimer},
{"FreeTimer", TimerFunctions::FreeTimer},
{"IsTimerElapsed", TimerFunctions::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>()},
{"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>()},
{"OnRequestPluginList", 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,128 +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; };
template<> struct CharType<'h'> { typedef int16_t type; };
template<> struct CharType<'H'> { typedef uint16_t type; };
struct ScriptFunctionPointer : public ScriptIdentity
{
void *addr;
template<> struct CharType<'i'> { typedef int32_t type; };
template<> struct CharType<'I'> { typedef uint32_t type; };
template<typename R, typename... Types>
constexpr ScriptFunctionPointer(Function<R, Types...> addr) : ScriptIdentity(addr), addr((void*)(addr)) {}
};
template<> struct CharType<'l'> { typedef int64_t type; };
template<> struct CharType<'L'> { typedef uint64_t type; };
struct ScriptFunctionData
{
const char* name;
const ScriptFunctionPointer func;
constexpr ScriptFunctionData(const char* name, ScriptFunctionPointer func) : name(name), func(func) {}
};
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

@ -13,26 +13,12 @@
#include "Platform.h"
#endif
/** @addtogroup APIFunctions API Functions
* @brief API provided by the server.
* @{
**/
#include "CTypes.h"
NAMESPACE_BEGIN(Event)
/**
* @param event
* @param addr
*/
API_FUNCTION void CDECL RegisterEvent(const char *event, void *addr);
NAMESPACE_END()
/** @}*/
#if !(defined _HOST || defined _LUAJIT_PREPROCESS)
/** @addtogroup PluginFunctions Plugin Functions
* @brief Those functions must be implemented by plugin.
/** @addtogroup PluginCallbacks Plugin Callbacks
* @brief Those callbacks can be implemented by plugin.
* @{
*/
@ -50,6 +36,70 @@ EXPORT_FUNCTION int CDECL PluginInit();
* 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

@ -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,7 +196,6 @@ 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"), ','));
@ -221,19 +220,9 @@ int main(int argc, char *argv[])
LOG_APPEND(Log::LOG_FATAL, "- %s", TES3MP_CREDITS_ERROR);
return 1;
}
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
#endif
Plugin::SetModDir(Utils::convertPath(pluginHome + "/data"));
Plugin::SetPluginDir(Utils::convertPath(pluginHome + "/scripts"));
int code;
@ -256,8 +245,13 @@ int main(int argc, char *argv[])
try
{
<<<<<<< 0.7.0
for (auto plugin : plugins)
Script::LoadScript(plugin.c_str(), pluginHome.c_str());
=======
for (const auto &plugin : plugins)
Plugin::LoadPlugin(Utils::convertPath(plugin_home + "/scripts/" + plugin));
>>>>>>> [Server] Rework Plugin API, move Lua system to external library
switch (peer->Startup((unsigned) players, &sd, 1))
{

@ -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

@ -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"

@ -19,7 +19,7 @@ namespace mwmp
if (serverCell != nullptr)
{
Script::Call<Script::CallbackIdentity("OnActorAI")>(player.getId(), actorList.cell.getDescription().c_str());
Plugin::Call<CallbackIndex("OnActorAI")>(player.getId(), actorList.cell.getDescription().c_str());
}
}
};

@ -37,7 +37,7 @@ namespace mwmp
{
serverCell->removeActors(&actorList);
Script::Call<Script::CallbackIdentity("OnActorCellChange")>(player.getId(), actorList.cell.getDescription().c_str());
Plugin::Call<CallbackIndex("OnActorCellChange")>(player.getId(), actorList.cell.getDescription().c_str());
// Send this to everyone
packet.Send(true);

@ -20,7 +20,7 @@ namespace mwmp
if (serverCell != nullptr && *serverCell->getAuthority() == actorList.guid)
{
Script::Call<Script::CallbackIdentity("OnActorDeath")>(player.getId(), actorList.cell.getDescription().c_str());
Plugin::Call<CallbackIndex("OnActorDeath")>(player.getId(), actorList.cell.getDescription().c_str());
serverCell->sendToLoaded(&packet, &actorList);
}

@ -20,7 +20,7 @@ namespace mwmp
if (serverCell != nullptr)
{
Script::Call<Script::CallbackIdentity("OnActorEquipment")>(player.getId(), actorList.cell.getDescription().c_str());
Plugin::Call<CallbackIndex("OnActorEquipment")>(player.getId(), actorList.cell.getDescription().c_str());
serverCell->sendToLoaded(&packet, &actorList);
}

@ -23,7 +23,7 @@ namespace mwmp
if (serverCell != nullptr)
serverCell->sendToLoaded(&packet, &actorList);
Script::Call<Script::CallbackIdentity("OnActorList")>(player.getId(), actorList.cell.getDescription().c_str());
Plugin::Call<CallbackIndex("OnActorList")>(player.getId(), actorList.cell.getDescription().c_str());
}
};
}

@ -21,7 +21,7 @@ namespace mwmp
if (serverCell != nullptr)
serverCell->sendToLoaded(&packet, &actorList);
Script::Call<Script::CallbackIdentity("OnActorTest")>(player.getId(), actorList.cell.getDescription().c_str());
Plugin::Call<CallbackIndex("OnActorTest")>(player.getId(), actorList.cell.getDescription().c_str());
}
};
}

@ -22,7 +22,7 @@ namespace mwmp
// container packets to ensure their integrity based on what exists in the
// server data
Script::Call<Script::CallbackIdentity("OnContainer")>(player.getId(), objectList.cell.getDescription().c_str());
Plugin::Call<CallbackIndex("OnContainer")>(player.getId(), objectList.cell.getDescription().c_str());
LOG_APPEND(Log::LOG_INFO, "- Finished processing ID_CONTAINER");
}

@ -17,7 +17,7 @@ namespace mwmp
{
packet.Send(true);
Script::Call<Script::CallbackIdentity("OnDoorState")>(player.getId(), objectList.cell.getDescription().c_str());
Plugin::Call<CallbackIndex("OnDoorState")>(player.getId(), objectList.cell.getDescription().c_str());
}
};
}

@ -18,7 +18,7 @@ namespace mwmp
{
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received %s from %s", strPacketID.c_str(), player.npc.mName.c_str());
Script::Call<Script::CallbackIdentity("OnObjectActivate")>(player.getId(), objectList.cell.getDescription().c_str());
Plugin::Call<CallbackIndex("OnObjectActivate")>(player.getId(), objectList.cell.getDescription().c_str());
}
};
}

@ -17,7 +17,7 @@ namespace mwmp
{
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received %s from %s", strPacketID.c_str(), player.npc.mName.c_str());
Script::Call<Script::CallbackIdentity("OnObjectDelete")>(player.getId(), objectList.cell.getDescription().c_str());
Plugin::Call<CallbackIndex("OnObjectDelete")>(player.getId(), objectList.cell.getDescription().c_str());
}
};
}

@ -17,7 +17,7 @@ namespace mwmp
{
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received %s from %s", strPacketID.c_str(), player.npc.mName.c_str());
Script::Call<Script::CallbackIdentity("OnObjectLock")>(player.getId(), objectList.cell.getDescription().c_str());
Plugin::Call<CallbackIndex("OnObjectLock")>(player.getId(), objectList.cell.getDescription().c_str());
}
};
}

@ -23,7 +23,7 @@ namespace mwmp
objectList.baseObjects.at(i).mpNum = mwmp::Networking::getPtr()->incrementMpNum();
}
Script::Call<Script::CallbackIdentity("OnObjectPlace")>(player.getId(), objectList.cell.getDescription().c_str());
Plugin::Call<CallbackIndex("OnObjectPlace")>(player.getId(), objectList.cell.getDescription().c_str());
}
};
}

@ -17,7 +17,7 @@ namespace mwmp
{
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received %s from %s", strPacketID.c_str(), player.npc.mName.c_str());
Script::Call<Script::CallbackIdentity("OnObjectScale")>(player.getId(), objectList.cell.getDescription().c_str());
Plugin::Call<CallbackIndex("OnObjectScale")>(player.getId(), objectList.cell.getDescription().c_str());
}
};
}

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

Loading…
Cancel
Save