Compare commits

..

54 commits

Author SHA1 Message Date
David Cernat
8aad93b904
Merge pull request #519 from TES3MP/0.7.0-alpha
[General] Update positions for dead players on other clients
2019-03-24 03:54:43 +02:00
David Cernat
3effd5f1ff [General] Update positions for dead players on other clients
Dead players will now show up at the correct cell and position for living players, making server scripts that allow players to revive each other much more functional.
2019-03-24 03:52:05 +02:00
David Cernat
4692f29b9d
Merge pull request #517 from uramer/0.7.0markers
update player map markers when client changes cell
2019-03-22 21:39:06 +02:00
David Cernat
03d377ec54
Merge pull request #518 from TES3MP/0.7.0-alpha
[General] Rename CellReplace packet into CellReset
2019-03-22 21:36:07 +02:00
David Cernat
8ff2d1b829 [General] Rename CellReplace packet into CellReset 2019-03-22 21:33:34 +02:00
David Cernat
cb82318c36 [General] Fix problems with Utils::getArchitectureType() 2019-03-22 03:09:11 +02:00
uramer
3b2098382b update player map markers when client changes cell 2019-03-21 16:27:15 +01:00
David Cernat
cb5e24e6c5
Merge pull request #516 from TES3MP/0.7.0-alpha
[Server] Add GetMillisecondsSinceServerStart() server function
2019-03-20 20:05:30 +02:00
David Cernat
91f82d845c [Server] Add GetMillisecondsSinceServerStart() server function 2019-03-20 20:02:31 +02:00
David Cernat
d35026bbf5
Merge pull request #515 from TES3MP/0.7.0-alpha
0.7.0 alpha
2019-03-20 18:58:31 +02:00
David Cernat
bd677726bf [Server] Add StatsFunctions that get/set damage to attributes/skills 2019-03-20 18:54:35 +02:00
David Cernat
9fc4c83858 [Client] Send skill/attribute packets when skills/attributes are damaged 2019-03-20 18:40:46 +02:00
David Cernat
ece39748de [Server] Fix typo causing recursion in deprecated actor list function 2019-03-20 17:01:21 +02:00
David Cernat
5c4d3df551 [Server] Deprecate DoesFileExist(), add DoesFilePathExist() 2019-03-19 04:52:58 +02:00
David Cernat
2cdabddc0e [Server] Move most MiscellaneousFunctions to ServerFunctions 2019-03-19 04:25:33 +02:00
David Cernat
b46767de6e [Server] Clean up recent additions to ServerFunctions 2019-03-19 03:57:16 +02:00
David Cernat
911079e0bc
Merge pull request #512 from TES3MP/0.7.0-alpha
0.7.0 alpha
2019-03-12 05:38:36 +02:00
David Cernat
331fa86844 [Server] Call OnServerPostInit after OnRequestDataFileList
This allows different actions to be taken in OnServerPostInit based on what the data files being used are.
2019-03-12 05:36:33 +02:00
David Cernat
a0ec9dfd2e [Server] Rename OnRequestPluginList into OnRequestDataFileList 2019-03-12 03:18:57 +02:00
David Cernat
986528c67d [Server] Add error message as argument to OnServerScriptCrash 2019-03-12 02:15:20 +02:00
David Cernat
552a94a0ca [Server] Add OnServerScriptCrash script event 2019-03-10 00:46:40 +02:00
David Cernat
a508a0faf8 [Server] Turn GetArguments() from ScriptFunctions into Utils function 2019-02-24 01:43:04 +02:00
David Cernat
dcbc9d1831 [Client] Print cells for actor deaths 2019-02-21 21:51:02 +02:00
David Cernat
828c52138f [Documentation] Update readme and credits
According to some legal advice I've received, the "TES3MP Team" is too ambiguous of a legal entity, so – with Koncord's agreement – the copyright is now assigned specifically to us, the project's developers.
2019-02-19 17:29:29 +02:00
David Cernat
69e7d3f2a7 [Documentation] Update credits 2019-02-14 13:07:54 +02:00
David Cernat
f3b8a5b909 [General] Check integrity of credits only on Windows clients
This avoids the problems that were encountered in Linux and macOS builds regarding this check while also still addressing the scenario where official Windows builds had their credits modified by people unrelated to the project.
2019-02-14 00:29:55 +02:00
David Cernat
a0ad0b29bc Merge branch '0.7.0' of https://github.com/TES3MP/openmw-tes3mp into 0.7.0 2019-02-13 21:57:24 +02:00
David Cernat
222837976c [Server] Fix type name warning for Player
The warning in Visual Studio was: "'Player': type name first seen using 'class' now seen using 'struct'"
2019-02-13 21:56:47 +02:00
Koncord
77386525f2 [General] Update Travis CI 2019-02-14 01:56:10 +08:00
David Cernat
c058dce346 [General] Clarify meaning of commit hash displayed on start 2019-01-31 13:39:06 +02:00
David Cernat
1df1515c7e [Client] Add logging for invalid enchantmentIds in RecordHelper 2019-01-23 01:04:59 +02:00
David Cernat
999ce857c7 [Client] Add logging for records ignored due to their invalid baseIds 2019-01-23 00:48:06 +02:00
David Cernat
db7e09f441 [Client] Use more consistent logging when reading dynamic record packets 2019-01-23 00:38:05 +02:00
David Cernat
0fa116b47d [Client] Remove useless lines in RecordHelper 2019-01-23 00:20:51 +02:00
Koncord
0df32accca [Server] Fix ARM build 2019-01-21 12:02:02 +08:00
David Cernat
fd40e8c971 [Client] Prevent ObjectState spam by not resending an already sent state 2019-01-15 14:26:00 +02:00
David Cernat
6e47b65205 [Client] Set attribute increases & level progress after correct packets
Originally, the PlayerSkill packet contained skills, attribute increases and level progress. In 78441c769a, the attribute increases were moved to the PlayerAttribute packet and the level progress was moved to the PlayerLevel packet, but – due to an oversight – attribute increases and level progress were still being applied to the local player only when a PlayerSkill packet was received, based on whatever values were stored from the last PlayerAttribute and PlayerLevel packets.
2019-01-11 14:26:13 +02:00
David Cernat
f481c85e07 [Client] Use ADD before REMOVE for PlayerInventory in repair/recharge
Previously, when recharging or repairing an item, the client sent a PlayerInventory packet to the server with the old version of the item that was supposed to be removed and then it sent a PlayerInventory packet with the new version of the item that was supposed to be added.

Unfortunately, the current CoreScripts make it so custom items using generated IDs have their records deleted when they are completely removed from the world, however briefly, even if they are added back immediately afterwards. In practice, this meant that – before this commit – recharging or repairing a custom item led to its removal from the player inventory stored on the server, followed by the deletion of its record, followed by its readdition to the inventory (but with the record staying deleted). Logging out and logging back in immediately prevented the player from receiving the item anymore because of its now non-existent record.
2019-01-11 13:08:26 +02:00
David Cernat
8a99f215f6 [Client] Add LocalPlayer::sendItemChange() variant with mwmp::Item arg 2019-01-11 12:54:47 +02:00
David Cernat
db9c1b9882 [Client] Add MechanicsHelper::getItem() for getting mwmp::Item from Ptr 2019-01-11 12:53:26 +02:00
David Cernat
799241e8c6 [Client] Use informative error message for RefData::setCount() issue 2019-01-11 08:16:29 +02:00
David Cernat
43f195f0c7 [Client] Use clearer debug for actor initializations 2019-01-05 23:27:35 +02:00
David Cernat
2e1d4a9449 [Server] Fix non-Windows builds 2019-01-05 22:11:58 +02:00
David Cernat
81e2e48561 [Client] Fix item magic casting synchronization for spell scrolls
Previously, spell scrolls were used up before their IDs could be included in attacks packets supposed to be sent for them.
2018-12-31 13:24:32 +02:00
David Cernat
d83160523f [Client] Add items required for item magic casting when they are missing 2018-12-31 06:55:35 +02:00
David Cernat
433a69a588 [Client] Send all data for newly initialized LocalActors at least once 2018-12-31 04:36:59 +02:00
David Cernat
e70fd2cf3a [Server] Accept clients with wrong password on servers with no password 2018-12-31 03:52:25 +02:00
David Cernat
eb52babf29 [Server] Print IP instead of name or PID for players unable to connect
The player name was always blank in such situations, providing no useful information. The PID was not useful in any way either.
2018-12-30 18:02:26 +02:00
David Cernat
e96091fd6b [General] Use more consistent variable names for password, address, etc. 2018-12-30 17:23:12 +02:00
David Cernat
906d2a837d [Client] Send PlayerInventory packets when recharging items w/ soulgems 2018-12-30 11:58:33 +02:00
David Cernat
71679934a1 [Client] Send PlayerInventory packets when repairing items 2018-12-30 09:39:46 +02:00
David Cernat
5d9893ee92 [Client] Set actor killer correctly for spells that do damage over time
Additionally, clean up comments related to other code that sets actor killers.
2018-12-30 07:40:11 +02:00
David Cernat
6e1504f0a1 [Server] Use clearer variable & function names in TimerAPI 2018-12-30 04:15:53 +02:00
David Cernat
42b5a8054f [Server] Remove unusable position functions for players 2018-12-30 03:17:37 +02:00
172 changed files with 5357 additions and 4942 deletions

View file

@ -4,7 +4,7 @@ os:
osx_image: xcode9.4
language: cpp
sudo: required
dist: trusty
dist: xenial
branches:
only:
- master
@ -15,18 +15,18 @@ env:
global:
# The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
# via the "travis encrypt" command using the project repo's public key
- secure: NZmvVuA0O9NJXVQ12tXQZHDJC2mbFgYNFcsicw0DgW1It2Nk5hxIkF0pfu4/Z59mhQuOPgRVjl5b0FKy2Axh0gkWc1DJEXGwNaiW5lpTMNWR1LJG5rxa8LrDUpFkycpbzfAFuTUZu5z3iYVv64XzELvBuqNGhPMu1LeBnrlech0jFNjkR9p5qtJGWb8zYcPMCC57rig8a9g1ABoVYS6UXjrKpx0946ZLRsE5ukc9pXsypGwPmOMyfzZkxxzIqFaxoE5JIEdaJTWba/6Za315ozYYIi/N35ROI1YAv5GHRe/Iw9XAa4vQpbDzjM7ZSsZdTvvQsSU598gD2xC6jFUKSrpW6GZKwM2x236fZLGnOk5Uw7DUbG+AwpcEmxBwoy9PjBl9ZF3tJykI0gROewCy8MODhdsVMKr1HGIMVBIJySm/RnNqtoDbYV8mYnSl5b8rwJiCajoiR8Zuv4CIfGneeH1a3DOQDPH/qkDsU6ilzF4ANsBlMUUpgY653KBMBmTlNuVZSH527tnD7Fg6JgHVuSQkTbRa1vSkR7Zcre604RZcAoaEdbX3bhVDasPPghU/I742L0RH3oQNlR09pPBDZ8kG7ydl4aPHwpCWnvXNM1vgxtGvnYLztwrse7IoaRXRYiMFmrso78WhMWUDKgvY4wV9aeUu0DtnMezZVIQwCKg=
- secure: 1QK0yVyoOB+gf2I7XzvhXu9w/5lq4stBXIwJbVCTjz4Q4XVHCosURaW1MAgKzMrPnbFEwjyn5uQ8BwsvvfkuN1AZD0YXITgc7gyI+J1wQ/p/ljxRxglakU6WEgsTs2J5z9UmGac4YTXg+quK7YP3rv+zuGim2I2rhzImejyzp0Ym3kRCnNcy+SGBsiRaevRJMe00Ch8zGAbEhduQGeSoS6W0rcu02DNlQKiq5NktWsXR+TWWWVfIeIlQR/lbPsCd0pdxMaMv2QCY0rVbwrYxWJwr/Qe45dAdWp+8/C3PbXpeMSGxlLa33nJNX4Lf/djxbjm8KWk6edaXPajrjR/0iwcpwq0jg2Jt6XfEdnJt35F1gpXlc04sxStjG45uloOKCFYT0wdhIO1Lq+hDP54wypQl+JInd5qC001O7pwhVxO36EgKWqo8HD+BqGDBwsNj2engy9Qcp3wO6G0rLBPB3CrZsk9wrHVv5cSiQSLMhId3Xviu3ZI2qEDA+kgTvxrKrsnMj4bILVCyG5Ka2Mj22wIDW9e8oIab9oTdujax3DTN1GkD6QuOAGzwDsNwGASsgfoeZ+FUhgM75RlBWGMilgkmnF7EJ0oAXLEpjtABnEr2d4qHv+y08kOuTDBLB9ExzCIj024dYYYNLZrqPKx0ncHuCMG2QNj2aJAJEZtj1rQ=
addons:
apt:
sources:
- sourceline: 'ppa:openmw/openmw'
- sourceline: 'ppa:rakhimov/boost'
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.8
packages: [
# Dev
cmake, clang-3.8, libunshield-dev, libtinyxml-dev,
g++-6,
cmake, clang-6.0, libunshield-dev, libtinyxml-dev,
g++-8,
# Tests
libgtest-dev, google-mock,
# Boost
@ -45,7 +45,7 @@ addons:
project:
name: "TES3MP/openmw-tes3mp"
description: "<Your project description here>"
notification_email: stas5978@gmail.com
notification_email: koncord@tes3mp.com
build_command_prepend: "cmake . -DBUILD_UNITTESTS=FALSE -DBUILD_OPENCS=FALSE -DBUILD_BSATOOL=FALSE -DBUILD_ESMTOOL=FALSE -DBUILD_MWINIIMPORTER=FALSE -DBUILD_LAUNCHER=FALSE"
build_command: "make -j3"
branch_pattern: coverity_scan
@ -53,21 +53,21 @@ matrix:
include:
- os: linux
env:
- ANALYZE="scan-build-3.8 --use-cc clang-3.8 --use-c++ clang++-3.8 "
- MATRIX_CC="CC=clang-3.8 && CXX=clang++-3.8"
- ANALYZE="scan-build-6.0 --use-cc clang-6.0 --use-c++ clang++-6.0 "
- MATRIX_CC="CC=clang-6.0 && CXX=clang++-6.0"
compiler: clang
- os: linux
env:
- MATRIX_CC="CC=gcc-6 && CXX=g++-6"
- MATRIX_CC="CC=gcc-8 && CXX=g++-8"
- os: linux
env:
- MATRIX_CC="CC=clang-3.8 && CXX=clang++-3.8"
- MATRIX_CC="CC=clang-6.0 && CXX=clang++-6.0"
allow_failures:
- env:
- MATRIX_CC="CC=clang-3.8 && CXX=clang++-3.8"
- MATRIX_CC="CC=clang-6.0 && CXX=clang++-6.0"
- env:
- ANALYZE="scan-build-3.8 --use-cc clang-3.8 --use-c++ clang++-3.8 "
- MATRIX_CC="CC=clang-3.8 && CXX=clang++-3.8"
- ANALYZE="scan-build-6.0 --use-cc clang-6.0 --use-c++ clang++-6.0 "
- MATRIX_CC="CC=clang-6.0 && CXX=clang++-6.0"
before_install:
- ./CI/before_install.${TRAVIS_OS_NAME}.sh

View file

@ -15,19 +15,8 @@ sudo ln -s /usr/src/gtest/build/libgtest.so /usr/lib/libgtest.so
sudo ln -s /usr/src/gtest/build/libgtest_main.so /usr/lib/libgtest_main.so
cd ~/
git clone https://github.com/TES3MP/RakNet
cd RakNet
cmake . -DRAKNET_ENABLE_DLL=OFF -DRAKNET_ENABLE_SAMPLES=OFF -DCMAKE_BUILD_TYPE=Release
git clone https://github.com/TES3MP/CrabNet
cd CrabNet
cmake . -DCRABNET_ENABLE_DLL=OFF -DCRABNET_ENABLE_SAMPLES=OFF -DCMAKE_BUILD_TYPE=Release
make -j3
cd ~/
git clone https://github.com/Koncord/CallFF
cd CallFF
mkdir build
cd build
cmake ../
make -j3
cd ~/
wget https://github.com/zdevito/terra/releases/download/release-2016-03-25/terra-Linux-x86_64-332a506.zip
unzip terra-Linux-x86_64-332a506.zip

View file

@ -9,8 +9,7 @@ if [ ! -z "${MATRIX_CC}" ]; then
eval "${MATRIX_CC}"
fi
export RAKNET_ROOT=~/RakNet
export Terra_ROOT=~/terra-Linux-x86_64-332a506
export RAKNET_ROOT=~/CrabNet
export CODE_COVERAGE=0
if [ ! -z "${ANALYZE}" ]; then
@ -36,7 +35,5 @@ ${ANALYZE}cmake .. \
-DBINDIR=/usr/games \
-DCMAKE_BUILD_TYPE="None" \
-DUSE_SYSTEM_TINYXML=TRUE \
-DRakNet_LIBRARY_RELEASE=~/RakNet/lib/libRakNetLibStatic.a \
-DRakNet_LIBRARY_DEBUG=~/RakNet/lib/libRakNetLibStatic.a \
-DCallFF_INCLUDES=~/CallFF/include \
-DCallFF_LIBRARY=~/CallFF/build/src/libcallff.a
-DRakNet_LIBRARY_RELEASE=~/CrabNet/lib/libRakNetLibStatic.a \
-DRakNet_LIBRARY_DEBUG=~/CrabNet/lib/libRakNetLibStatic.a

View file

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

View file

@ -1,545 +0,0 @@
# 2006-2008 (c) Viva64.com Team
# 2008-2018 (c) OOO "Program Verification Systems"
#
# Version 12
cmake_minimum_required(VERSION 2.8.12)
cmake_policy(SET CMP0054 NEW)
if (PVS_STUDIO_AS_SCRIPT)
# This code runs at build time.
# It executes pvs-studio-analyzer and propagates its return value.
set(in_cl_params FALSE)
set(additional_args)
foreach (arg ${PVS_STUDIO_COMMAND})
if (NOT in_cl_params)
if ("${arg}" STREQUAL "--cl-params")
set(in_cl_params TRUE)
endif ()
else ()
# A workaround for macOS frameworks (e.g. QtWidgets.framework)
# You can test this workaround on this project: https://github.com/easyaspi314/MidiEditor/tree/gba
if (APPLE AND "${arg}" MATCHES "^-I(.*)\\.framework$")
STRING(REGEX REPLACE "^-I(.*)\\.framework$" "\\1.framework" framework "${arg}")
if (IS_ABSOLUTE "${framework}")
get_filename_component(framework "${framework}" DIRECTORY)
list(APPEND additional_args "-iframework")
list(APPEND additional_args "${framework}")
endif ()
endif ()
endif ()
endforeach ()
execute_process(COMMAND ${PVS_STUDIO_COMMAND} ${additional_args}
ERROR_VARIABLE error
RESULT_VARIABLE result)
set(stderr_type "")
if (result)
set(stderr_type FATAL_ERROR)
endif ()
if (result OR error)
message(${stderr_type} "${error}")
endif ()
return()
endif ()
if (__PVS_STUDIO_INCLUDED)
return()
endif ()
set(__PVS_STUDIO_INCLUDED TRUE)
set(PVS_STUDIO_SCRIPT "${CMAKE_CURRENT_LIST_FILE}")
function(pvs_studio_log TEXT)
if (PVS_STUDIO_DEBUG)
message("PVS-Studio: ${TEXT}")
endif ()
endfunction()
function(pvs_studio_relative_path VAR ROOT FILEPATH)
set("${VAR}" "${FILEPATH}" PARENT_SCOPE)
if ("${FILEPATH}" MATCHES "^/.*$" OR "${FILEPATH}" MATCHES "^.:/.*$")
file(RELATIVE_PATH RPATH "${ROOT}" "${FILEPATH}")
if (NOT "${RPATH}" MATCHES "^\\.\\..*$")
set("${VAR}" "${RPATH}" PARENT_SCOPE)
endif ()
endif ()
endfunction()
function(pvs_studio_join_path VAR DIR1 DIR2)
if ("${DIR2}" MATCHES "^(/|~|.:/).*$" OR "${DIR1}" STREQUAL "")
set("${VAR}" "${DIR2}" PARENT_SCOPE)
else ()
set("${VAR}" "${DIR1}/${DIR2}" PARENT_SCOPE)
endif ()
endfunction()
macro(pvs_studio_append_flags_from_property CXX C DIR PREFIX)
if (NOT "${PROPERTY}" STREQUAL "NOTFOUND" AND NOT "${PROPERTY}" STREQUAL "PROPERTY-NOTFOUND")
foreach (PROP ${PROPERTY})
pvs_studio_join_path(PROP "${DIR}" "${PROP}")
if (APPLE AND "${PREFIX}" STREQUAL "-I" AND IS_ABSOLUTE "${PROP}" AND "${PROP}" MATCHES "\\.framework$")
get_filename_component(FRAMEWORK "${PROP}" DIRECTORY)
list(APPEND "${CXX}" "-iframework")
list(APPEND "${CXX}" "${FRAMEWORK}")
list(APPEND "${C}" "-iframework")
list(APPEND "${C}" "${FRAMEWORK}")
pvs_studio_log("framework: ${FRAMEWORK}")
elseif (NOT "${PROP}" STREQUAL "")
list(APPEND "${CXX}" "${PREFIX}${PROP}")
list(APPEND "${C}" "${PREFIX}${PROP}")
endif ()
endforeach ()
endif ()
endmacro()
macro(pvs_studio_append_standard_flag FLAGS STANDARD)
if ("${STANDARD}" MATCHES "^(99|11|14|17)$")
if ("${PVS_STUDIO_PREPROCESSOR}" MATCHES "gcc|clang")
list(APPEND "${FLAGS}" "-std=c++${STANDARD}")
endif ()
endif ()
endmacro()
function(pvs_studio_set_directory_flags DIRECTORY CXX C)
set(CXX_FLAGS "${${CXX}}")
set(C_FLAGS "${${C}}")
get_directory_property(PROPERTY DIRECTORY "${DIRECTORY}" INCLUDE_DIRECTORIES)
pvs_studio_append_flags_from_property(CXX_FLAGS C_FLAGS "${DIRECTORY}" "-I")
get_directory_property(PROPERTY DIRECTORY "${DIRECTORY}" COMPILE_DEFINITIONS)
pvs_studio_append_flags_from_property(CXX_FLAGS C_FLAGS "" "-D")
set("${CXX}" "${CXX_FLAGS}" PARENT_SCOPE)
set("${C}" "${C_FLAGS}" PARENT_SCOPE)
endfunction()
function(pvs_studio_set_target_flags TARGET CXX C)
set(CXX_FLAGS "${${CXX}}")
set(C_FLAGS "${${C}}")
set(prop_incdirs "$<TARGET_PROPERTY:${TARGET},INCLUDE_DIRECTORIES>")
list(APPEND CXX_FLAGS "$<$<BOOL:${prop_incdirs}>:-I$<JOIN:${prop_incdirs},$<SEMICOLON>-I>>")
list(APPEND C_FLAGS "$<$<BOOL:${prop_incdirs}>:-I$<JOIN:${prop_incdirs},$<SEMICOLON>-I>>")
set(prop_compdefs "$<TARGET_PROPERTY:${TARGET},COMPILE_DEFINITIONS>")
list(APPEND CXX_FLAGS "$<$<BOOL:${prop_compdefs}>:-D$<JOIN:${prop_compdefs},$<SEMICOLON>-D>>")
list(APPEND C_FLAGS "$<$<BOOL:${prop_compdefs}>:-D$<JOIN:${prop_compdefs},$<SEMICOLON>-D>>")
set("${CXX}" "${CXX_FLAGS}" PARENT_SCOPE)
set("${C}" "${C_FLAGS}" PARENT_SCOPE)
endfunction()
function(pvs_studio_set_source_file_flags SOURCE)
set(LANGUAGE "")
string(TOLOWER "${SOURCE}" SOURCE_LOWER)
if ("${LANGUAGE}" STREQUAL "" AND "${SOURCE_LOWER}" MATCHES "^.*\\.(c|cpp|cc|cx|cxx|cp|c\\+\\+)$")
if ("${SOURCE}" MATCHES "^.*\\.c$")
set(LANGUAGE C)
else ()
set(LANGUAGE CXX)
endif ()
endif ()
if ("${LANGUAGE}" STREQUAL "C")
set(CL_PARAMS ${PVS_STUDIO_C_FLAGS} ${PVS_STUDIO_TARGET_C_FLAGS} -DPVS_STUDIO)
elseif ("${LANGUAGE}" STREQUAL "CXX")
set(CL_PARAMS ${PVS_STUDIO_CXX_FLAGS} ${PVS_STUDIO_TARGET_CXX_FLAGS} -DPVS_STUDIO)
endif ()
set(PVS_STUDIO_LANGUAGE "${LANGUAGE}" PARENT_SCOPE)
set(PVS_STUDIO_CL_PARAMS "${CL_PARAMS}" PARENT_SCOPE)
endfunction()
function(pvs_studio_analyze_file SOURCE SOURCE_DIR BINARY_DIR)
set(PLOGS ${PVS_STUDIO_PLOGS})
pvs_studio_set_source_file_flags("${SOURCE}")
get_filename_component(SOURCE "${SOURCE}" REALPATH)
get_source_file_property(PROPERTY "${SOURCE}" HEADER_FILE_ONLY)
if (PROPERTY)
return()
endif ()
pvs_studio_relative_path(SOURCE_RELATIVE "${SOURCE_DIR}" "${SOURCE}")
pvs_studio_join_path(SOURCE "${SOURCE_DIR}" "${SOURCE}")
set(LOG "${BINARY_DIR}/PVS-Studio/${SOURCE_RELATIVE}.plog")
get_filename_component(LOG "${LOG}" REALPATH)
get_filename_component(PARENT_DIR "${LOG}" DIRECTORY)
if (EXISTS "${SOURCE}" AND NOT TARGET "${LOG}" AND NOT "${PVS_STUDIO_LANGUAGE}" STREQUAL "")
# A workaround to support implicit dependencies for ninja generators.
set(depPvsArg)
set(depCommandArg)
if (CMAKE_VERSION VERSION_GREATER 3.6 AND "${CMAKE_GENERATOR}" STREQUAL "Ninja")
pvs_studio_relative_path(relLog "${CMAKE_BINARY_DIR}" "${LOG}")
set(depPvsArg --dep-file "${LOG}.d" --dep-file-target "${relLog}")
set(depCommandArg DEPFILE "${LOG}.d")
endif ()
# https://public.kitware.com/Bug/print_bug_page.php?bug_id=14353
# https://public.kitware.com/Bug/file/5436/expand_command.cmake
#
# It is a workaround to expand generator expressions.
set(cmdline "${PVS_STUDIO_BIN}" analyze
--output-file "${LOG}"
--source-file "${SOURCE}"
${depPvsArg}
${PVS_STUDIO_ARGS}
--cl-params "${PVS_STUDIO_CL_PARAMS}" "${SOURCE}")
string(REPLACE ";" "$<SEMICOLON>" cmdline "${cmdline}")
set(pvscmd "${CMAKE_COMMAND}"
-D PVS_STUDIO_AS_SCRIPT=TRUE
-D "PVS_STUDIO_COMMAND=${cmdline}"
-P "${PVS_STUDIO_SCRIPT}"
)
add_custom_command(OUTPUT "${LOG}"
COMMAND "${CMAKE_COMMAND}" -E make_directory "${PARENT_DIR}"
COMMAND "${CMAKE_COMMAND}" -E remove_directory "${LOG}"
COMMAND ${pvscmd}
WORKING_DIRECTORY "${BINARY_DIR}"
DEPENDS "${SOURCE}" "${PVS_STUDIO_CONFIG}"
IMPLICIT_DEPENDS "${PVS_STUDIO_LANGUAGE}" "${SOURCE}"
${depCommandArg}
VERBATIM
COMMENT "Analyzing ${PVS_STUDIO_LANGUAGE} file ${SOURCE_RELATIVE}")
list(APPEND PLOGS "${LOG}")
endif ()
set(PVS_STUDIO_PLOGS "${PLOGS}" PARENT_SCOPE)
endfunction()
function(pvs_studio_analyze_target TARGET DIR)
set(PVS_STUDIO_PLOGS "${PVS_STUDIO_PLOGS}")
set(PVS_STUDIO_TARGET_CXX_FLAGS "")
set(PVS_STUDIO_TARGET_C_FLAGS "")
get_target_property(PROPERTY "${TARGET}" SOURCES)
pvs_studio_relative_path(BINARY_DIR "${CMAKE_SOURCE_DIR}" "${DIR}")
if ("${BINARY_DIR}" MATCHES "^/.*$")
pvs_studio_join_path(BINARY_DIR "${CMAKE_BINARY_DIR}" "PVS-Studio/__${BINARY_DIR}")
else ()
pvs_studio_join_path(BINARY_DIR "${CMAKE_BINARY_DIR}" "${BINARY_DIR}")
endif ()
file(MAKE_DIRECTORY "${BINARY_DIR}")
pvs_studio_set_directory_flags("${DIR}" PVS_STUDIO_TARGET_CXX_FLAGS PVS_STUDIO_TARGET_C_FLAGS)
pvs_studio_set_target_flags("${TARGET}" PVS_STUDIO_TARGET_CXX_FLAGS PVS_STUDIO_TARGET_C_FLAGS)
if (NOT "${PROPERTY}" STREQUAL "NOTFOUND" AND NOT "${PROPERTY}" STREQUAL "PROPERTY-NOTFOUND")
foreach (SOURCE ${PROPERTY})
pvs_studio_join_path(SOURCE "${DIR}" "${SOURCE}")
pvs_studio_analyze_file("${SOURCE}" "${DIR}" "${BINARY_DIR}")
endforeach ()
endif ()
set(PVS_STUDIO_PLOGS "${PVS_STUDIO_PLOGS}" PARENT_SCOPE)
endfunction()
set(PVS_STUDIO_RECURSIVE_TARGETS)
set(PVS_STUDIO_RECURSIVE_TARGETS_NEW)
macro(pvs_studio_get_recursive_targets TARGET)
get_target_property(libs "${TARGET}" LINK_LIBRARIES)
foreach (lib IN LISTS libs)
list(FIND PVS_STUDIO_RECURSIVE_TARGETS "${lib}" index)
if (TARGET "${lib}" AND "${index}" STREQUAL -1)
get_target_property(target_type "${lib}" TYPE)
if (NOT "${target_type}" STREQUAL "INTERFACE_LIBRARY")
list(APPEND PVS_STUDIO_RECURSIVE_TARGETS "${lib}")
list(APPEND PVS_STUDIO_RECURSIVE_TARGETS_NEW "${lib}")
pvs_studio_get_recursive_targets("${lib}")
endif ()
endif ()
endforeach ()
endmacro()
option(PVS_STUDIO_DISABLE OFF "Disable PVS-Studio targets")
option(PVS_STUDIO_DEBUG OFF "Add debug info")
# pvs_studio_add_target
# Target options:
# ALL add this target to default build (default: off)
# TARGET target name of analysis target (default: pvs)
# ANALYZE targets... targets to analyze
# RECURSIVE analyze target's dependencies (requires CMake 3.5+)
# COMPILE_COMMANDS use compile_commands.json mode
#
# Output options:
# OUTPUT prints report to stdout
# LOG path path to report (default: ${CMAKE_CURRENT_BINARY_DIR}/PVS-Studio.log)
# FORMAT format format of report
# MODE mode analyzers/levels filter (default: GA:1,2)
# HIDE_HELP do not print help message
#
# Analyzer options:
# PLATFORM name linux32/linux64 (default: linux64)
# PREPROCESSOR name preprocessor type: gcc/clang (default: auto detected)
# LICENSE path path to PVS-Studio.lic (default: ~/.config/PVS-Studio/PVS-Studio.lic)
# CONFIG path path to PVS-Studio.cfg
# CFG_TEXT text embedded PVS-Studio.cfg
# KEEP_COMBINED_PLOG do not delete combined plog file *.pvs.raw for further processing with plog-converter
#
# Misc options:
# DEPENDS targets.. additional target dependencies
# SOURCES path... list of source files to analyze
# BIN path path to pvs-studio-analyzer (Unix) or CompilerCommandsAnalyzer.exe (Windows)
# CONVERTER path path to plog-converter (Unix) or HtmlGenerator.exe (Windows)
# C_FLAGS flags... additional C_FLAGS
# CXX_FLAGS flags... additional CXX_FLAGS
# ARGS args... additional pvs-studio-analyzer/CompilerCommandsAnalyzer.exe flags
function(pvs_studio_add_target)
macro(default VAR VALUE)
if ("${${VAR}}" STREQUAL "")
set("${VAR}" "${VALUE}")
endif ()
endmacro()
set(PVS_STUDIO_SUPPORTED_PREPROCESSORS "gcc|clang|visualcpp")
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set(DEFAULT_PREPROCESSOR "clang")
elseif (MSVC)
set(DEFAULT_PREPROCESSOR "visualcpp")
else ()
set(DEFAULT_PREPROCESSOR "gcc")
endif ()
set(OPTIONAL OUTPUT ALL RECURSIVE HIDE_HELP KEEP_COMBINED_PLOG COMPILE_COMMANDS)
set(SINGLE LICENSE CONFIG TARGET LOG FORMAT BIN CONVERTER PLATFORM PREPROCESSOR CFG_TEXT)
set(MULTI SOURCES C_FLAGS CXX_FLAGS ARGS DEPENDS ANALYZE MODE)
cmake_parse_arguments(PVS_STUDIO "${OPTIONAL}" "${SINGLE}" "${MULTI}" ${ARGN})
if ("${PVS_STUDIO_CONFIG}" STREQUAL "" OR NOT "${PVS_STUDIO_CFG_TEXT}" STREQUAL "")
set(PVS_STUDIO_EMPTY_CONFIG ON)
else ()
set(PVS_STUDIO_EMPTY_CONFIG OFF)
endif ()
default(PVS_STUDIO_CFG_TEXT "analysis-mode=31")
default(PVS_STUDIO_CONFIG "${CMAKE_BINARY_DIR}/PVS-Studio.cfg")
default(PVS_STUDIO_C_FLAGS "")
default(PVS_STUDIO_CXX_FLAGS "")
default(PVS_STUDIO_TARGET "pvs")
default(PVS_STUDIO_LOG "PVS-Studio.log")
set(PATHS)
if (WIN32)
set(ROOT "PROGRAMFILES(X86)")
set(ROOT "$ENV{${ROOT}}/PVS-Studio")
string(REPLACE \\ / ROOT "${ROOT}")
if (EXISTS "${ROOT}")
set(PATHS "${ROOT}")
endif ()
default(PVS_STUDIO_BIN "CompilerCommandsAnalyzer.exe")
default(PVS_STUDIO_CONVERTER "HtmlGenerator.exe")
else ()
default(PVS_STUDIO_BIN "pvs-studio-analyzer")
default(PVS_STUDIO_CONVERTER "plog-converter")
endif ()
find_program(PVS_STUDIO_BIN_PATH "${PVS_STUDIO_BIN}" ${PATHS})
set(PVS_STUDIO_BIN "${PVS_STUDIO_BIN_PATH}")
if (NOT EXISTS "${PVS_STUDIO_BIN}")
message(FATAL_ERROR "pvs-studio-analyzer is not found")
endif ()
find_program(PVS_STUDIO_CONVERTER_PATH "${PVS_STUDIO_CONVERTER}" ${PATHS})
set(PVS_STUDIO_CONVERTER "${PVS_STUDIO_CONVERTER_PATH}")
if (NOT EXISTS "${PVS_STUDIO_CONVERTER}")
message(FATAL_ERROR "plog-converter is not found")
endif ()
default(PVS_STUDIO_MODE "GA:1,2")
default(PVS_STUDIO_PREPROCESSOR "${DEFAULT_PREPROCESSOR}")
if (WIN32)
default(PVS_STUDIO_PLATFORM "x64")
else ()
default(PVS_STUDIO_PLATFORM "linux64")
endif ()
string(REPLACE ";" "+" PVS_STUDIO_MODE "${PVS_STUDIO_MODE}")
if (PVS_STUDIO_EMPTY_CONFIG)
set(PVS_STUDIO_CONFIG_COMMAND "${CMAKE_COMMAND}" -E echo "${PVS_STUDIO_CFG_TEXT}" > "${PVS_STUDIO_CONFIG}")
else ()
set(PVS_STUDIO_CONFIG_COMMAND "${CMAKE_COMMAND}" -E touch "${PVS_STUDIO_CONFIG}")
endif ()
add_custom_command(OUTPUT "${PVS_STUDIO_CONFIG}"
COMMAND ${PVS_STUDIO_CONFIG_COMMAND}
WORKING_DIRECTORY "${BINARY_DIR}"
COMMENT "Generating PVS-Studio.cfg")
if (NOT "${PVS_STUDIO_PREPROCESSOR}" MATCHES "^${PVS_STUDIO_SUPPORTED_PREPROCESSORS}$")
message(FATAL_ERROR "Preprocessor ${PVS_STUDIO_PREPROCESSOR} isn't supported. Available options: ${PVS_STUDIO_SUPPORTED_PREPROCESSORS}.")
endif ()
pvs_studio_append_standard_flag(PVS_STUDIO_CXX_FLAGS "${CMAKE_CXX_STANDARD}")
pvs_studio_set_directory_flags("${CMAKE_CURRENT_SOURCE_DIR}" PVS_STUDIO_CXX_FLAGS PVS_STUDIO_C_FLAGS)
if (NOT "${PVS_STUDIO_LICENSE}" STREQUAL "")
pvs_studio_join_path(PVS_STUDIO_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}" "${PVS_STUDIO_LICENSE}")
list(APPEND PVS_STUDIO_ARGS --lic-file "${PVS_STUDIO_LICENSE}")
endif ()
list(APPEND PVS_STUDIO_ARGS --cfg "${PVS_STUDIO_CONFIG}"
--platform "${PVS_STUDIO_PLATFORM}"
--preprocessor "${PVS_STUDIO_PREPROCESSOR}")
if (NOT "${CMAKE_CXX_COMPILER}" STREQUAL "")
list(APPEND PVS_STUDIO_ARGS --cxx "${CMAKE_CXX_COMPILER}")
endif ()
if (NOT "${CMAKE_C_COMPILER}" STREQUAL "")
list(APPEND PVS_STUDIO_ARGS --cc "${CMAKE_C_COMPILER}")
endif ()
set(PVS_STUDIO_PLOGS "")
set(PVS_STUDIO_RECURSIVE_TARGETS_NEW)
if (${PVS_STUDIO_RECURSIVE})
foreach (TARGET IN LISTS PVS_STUDIO_ANALYZE)
list(APPEND PVS_STUDIO_RECURSIVE_TARGETS_NEW "${TARGET}")
pvs_studio_get_recursive_targets("${TARGET}")
endforeach ()
endif ()
set(inc_path)
foreach (TARGET ${PVS_STUDIO_ANALYZE})
set(DIR "${CMAKE_CURRENT_SOURCE_DIR}")
string(FIND "${TARGET}" ":" DELIM)
if ("${DELIM}" GREATER "-1")
math(EXPR DELIMI "${DELIM}+1")
string(SUBSTRING "${TARGET}" "${DELIMI}" "-1" DIR)
string(SUBSTRING "${TARGET}" "0" "${DELIM}" TARGET)
pvs_studio_join_path(DIR "${CMAKE_CURRENT_SOURCE_DIR}" "${DIR}")
else ()
get_target_property(TARGET_SOURCE_DIR "${TARGET}" SOURCE_DIR)
if (EXISTS "${TARGET_SOURCE_DIR}")
set(DIR "${TARGET_SOURCE_DIR}")
endif ()
endif ()
pvs_studio_analyze_target("${TARGET}" "${DIR}")
list(APPEND PVS_STUDIO_DEPENDS "${TARGET}")
if ("${inc_path}" STREQUAL "")
set(inc_path "$<TARGET_PROPERTY:${TARGET},INCLUDE_DIRECTORIES>")
else ()
set(inc_path "${inc_path}$<SEMICOLON>$<TARGET_PROPERTY:${TARGET},INCLUDE_DIRECTORIES>")
endif ()
endforeach ()
foreach (TARGET ${PVS_STUDIO_RECURSIVE_TARGETS_NEW})
set(DIR "${CMAKE_CURRENT_SOURCE_DIR}")
get_target_property(TARGET_SOURCE_DIR "${TARGET}" SOURCE_DIR)
if (EXISTS "${TARGET_SOURCE_DIR}")
set(DIR "${TARGET_SOURCE_DIR}")
endif ()
pvs_studio_analyze_target("${TARGET}" "${DIR}")
list(APPEND PVS_STUDIO_DEPENDS "${TARGET}")
endforeach ()
set(PVS_STUDIO_TARGET_CXX_FLAGS "")
set(PVS_STUDIO_TARGET_C_FLAGS "")
foreach (SOURCE ${PVS_STUDIO_SOURCES})
pvs_studio_analyze_file("${SOURCE}" "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}")
endforeach ()
if (PVS_STUDIO_COMPILE_COMMANDS)
set(COMPILE_COMMANDS_LOG "${PVS_STUDIO_LOG}.pvs.analyzer.raw")
if (NOT CMAKE_EXPORT_COMPILE_COMMANDS)
message(FATAL_ERROR "You should set CMAKE_EXPORT_COMPILE_COMMANDS to TRUE")
endif ()
add_custom_command(
OUTPUT "${COMPILE_COMMANDS_LOG}"
COMMAND "${PVS_STUDIO_BIN}" analyze -i
--output-file "${COMPILE_COMMANDS_LOG}.always"
${PVS_STUDIO_ARGS}
COMMENT "Analyzing with PVS-Studio"
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
DEPENDS "${PVS_STUDIO_CONFIG}"
)
list(APPEND PVS_STUDIO_PLOGS_LOGS "${COMPILE_COMMANDS_LOG}.always")
list(APPEND PVS_STUDIO_PLOGS_DEPENDENCIES "${COMPILE_COMMANDS_LOG}")
endif ()
pvs_studio_relative_path(LOG_RELATIVE "${CMAKE_BINARY_DIR}" "${PVS_STUDIO_LOG}")
if (PVS_STUDIO_PLOGS OR PVS_STUDIO_COMPILE_COMMANDS)
if (WIN32)
string(REPLACE / \\ PVS_STUDIO_PLOGS "${PVS_STUDIO_PLOGS}")
endif ()
if (WIN32)
set(COMMANDS COMMAND type ${PVS_STUDIO_PLOGS} ${PVS_STUDIO_PLOGS_LOGS} > "${PVS_STUDIO_LOG}")
else ()
set(COMMANDS COMMAND cat ${PVS_STUDIO_PLOGS} ${PVS_STUDIO_PLOGS_LOGS} > "${PVS_STUDIO_LOG}")
endif ()
set(COMMENT "Generating ${LOG_RELATIVE}")
if (NOT "${PVS_STUDIO_FORMAT}" STREQUAL "" OR PVS_STUDIO_OUTPUT)
if ("${PVS_STUDIO_FORMAT}" STREQUAL "")
set(PVS_STUDIO_FORMAT "errorfile")
endif ()
list(APPEND COMMANDS
COMMAND "${CMAKE_COMMAND}" -E remove -f "${PVS_STUDIO_LOG}.pvs.raw"
COMMAND "${CMAKE_COMMAND}" -E rename "${PVS_STUDIO_LOG}" "${PVS_STUDIO_LOG}.pvs.raw"
COMMAND "${PVS_STUDIO_CONVERTER}" -t "${PVS_STUDIO_FORMAT}" "${PVS_STUDIO_LOG}.pvs.raw" -o "${PVS_STUDIO_LOG}" -a "${PVS_STUDIO_MODE}"
)
if (NOT PVS_STUDIO_KEEP_COMBINED_PLOG)
list(APPEND COMMANDS COMMAND "${CMAKE_COMMAND}" -E remove -f "${PVS_STUDIO_LOG}.pvs.raw")
endif ()
endif ()
else ()
set(COMMANDS COMMAND "${CMAKE_COMMAND}" -E touch "${PVS_STUDIO_LOG}")
set(COMMENT "Generating ${LOG_RELATIVE}: no sources found")
endif ()
if (WIN32)
string(REPLACE / \\ PVS_STUDIO_LOG "${PVS_STUDIO_LOG}")
endif ()
add_custom_command(OUTPUT "${PVS_STUDIO_LOG}"
${COMMANDS}
COMMENT "${COMMENT}"
DEPENDS ${PVS_STUDIO_PLOGS} ${PVS_STUDIO_PLOGS_DEPENDENCIES}
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}")
if (PVS_STUDIO_ALL)
set(ALL "ALL")
else ()
set(ALL "")
endif ()
if (PVS_STUDIO_OUTPUT)
if (PVS_STUDIO_HIDE_HELP AND NOT WIN32)
set(COMMANDS COMMAND grep -v " error: Help:" ${PVS_STUDIO_LOG} 1>&2 || exit 0)
elseif (WIN32)
set(COMMANDS COMMAND type "${PVS_STUDIO_LOG}" 1>&2)
else ()
set(COMMANDS COMMAND cat "${PVS_STUDIO_LOG}" 1>&2)
endif ()
else ()
set(COMMANDS "")
endif ()
add_custom_target("${PVS_STUDIO_TARGET}" ${ALL} ${COMMANDS} WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" DEPENDS ${PVS_STUDIO_DEPENDS} "${PVS_STUDIO_LOG}")
# A workaround to add implicit dependencies of source files from include directories
set_target_properties("${PVS_STUDIO_TARGET}" PROPERTIES INCLUDE_DIRECTORIES "${inc_path}")
endfunction()

View file

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

View file

@ -25,28 +25,13 @@ if(BUILD_WITH_LUA)
set(LuaScript_Sources
Script/LangLua/LangLua.cpp
Script/LangLua/LuaFunc.cpp)
set(LuaScript_Headers
set(LuaScript_Headers ${LUA_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/extern/LuaBridge ${CMAKE_SOURCE_DIR}/extern/LuaBridge/detail
Script/LangLua/LangLua.hpp)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_LUA")
include_directories(SYSTEM ${LuaJit_INCLUDE_DIRS} SYSTEM ${CMAKE_SOURCE_DIR}/extern/LuaBridge)
include_directories(SYSTEM ${LuaJit_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/extern/LuaBridge)
endif(BUILD_WITH_LUA)
option(BUILD_WITH_MONO "Enable Mono languages" ON)
if(BUILD_WITH_MONO)
message(STATUS "Mono enabled")
find_package(Mono REQUIRED)
include_directories(SYSTEM ${MONO_INCLUDE_DIR})
set(MonoScript_Sources
Script/LangMono/LangMono.cpp
)
set(MonoScript_Headers
Script/LangMono/LangMono.hpp
)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_MONO")
endif(BUILD_WITH_MONO)
set(NativeScript_Sources
Script/LangNative/LangNative.cpp
)
@ -75,12 +60,11 @@ 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/API/TimerAPI.cpp Script/API/PublicFnAPI.cpp
${LuaScript_Sources}
${NativeScript_Sources}
${MonoScript_Sources}
)
set(SERVER_HEADER
@ -89,7 +73,6 @@ set(SERVER_HEADER
Script/ScriptFunctions.hpp Script/API/TimerAPI.hpp Script/API/PublicFnAPI.hpp
${LuaScript_Headers}
${NativeScript_Headers}
${MonoScript_Headers}
)
source_group(tes3mp-server FILES ${SERVER} ${SERVER_HEADER})
@ -182,6 +165,10 @@ set_target_properties(tes3mp-server PROPERTIES
CXX_EXTENSIONS YES
)
if (UNIX)
target_compile_options(tes3mp-server PRIVATE -Wno-ignored-qualifiers)
endif()
target_link_libraries(tes3mp-server
#${Boost_SYSTEM_LIBRARY}
#${Boost_THREAD_LIBRARY}
@ -190,19 +177,13 @@ target_link_libraries(tes3mp-server
${RakNet_LIBRARY}
components
${LuaJit_LIBRARIES}
${MONO_LIBRARY}
${Breakpad_Library}
)
if (BUILD_WITH_LUA)
target_link_libraries(tes3mp-server LuaBridge)
endif()
if (UNIX)
target_link_libraries(tes3mp-server dl)
# Fix for not visible pthreads functions for linker with glibc 2.15
if(NOT APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--exclude-libs,ALL -rdynamic -fvisibility=hidden")
target_link_libraries(tes3mp-server ${CMAKE_THREAD_LIBS_INIT})
endif(NOT APPLE)
endif(UNIX)
@ -219,10 +200,3 @@ if (MSVC)
endif (CMAKE_CL_64)
add_definitions("-D_USE_MATH_DEFINES")
endif (MSVC)
if (ENABLE_PVS)
pvs_studio_add_target(TARGET tes3mp-server.analyze ALL
OUTPUT FORMAT errorfile
ANALYZE tes3mp-server
LOG target_tes3mp-server.err)
endif()

View file

@ -55,7 +55,7 @@ void Cell::addPlayer(Player *player)
void Cell::removePlayer(Player *player, bool cleanPlayer)
{
for (auto it = begin(); it != end(); ++it)
for (Iterator it = begin(); it != end(); it++)
{
if (*it == player)
{
@ -161,7 +161,7 @@ void Cell::removeActors(const mwmp::BaseActorList *newActorList)
}
if (!foundActor)
++it;
it++;
}
cellActorList.count = cellActorList.baseActors.size();

View file

@ -64,7 +64,7 @@ Cell *CellController::getCellByXY(int x, int y)
return *it;
}
Cell *CellController::getCellByName(const std::string &cellName)
Cell *CellController::getCellByName(std::string cellName)
{
auto it = find_if(cells.begin(), cells.end(), [cellName](const Cell *c)
{
@ -80,7 +80,7 @@ Cell *CellController::getCellByName(const std::string &cellName)
return *it;
}
Cell *CellController::addCell(const ESM::Cell &cellData)
Cell *CellController::addCell(ESM::Cell cellData)
{
LOG_APPEND(Log::LOG_INFO, "- Loaded cells: %d", cells.size());
auto it = find_if(cells.begin(), cells.end(), [cellData](const Cell *c) {

View file

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

View file

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

View file

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

View file

@ -75,9 +75,9 @@ Networking::~Networking()
delete worldstatePacketController;
}
void Networking::setServerPassword(const std::string &passw) noexcept
void Networking::setServerPassword(std::string password) noexcept
{
serverPassword = passw.empty() ? TES3MP_DEFAULT_PASSW : passw;
serverPassword = password.empty() ? TES3MP_DEFAULT_PASSW : password;
}
bool Networking::isPassworded() const
@ -98,26 +98,33 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
if (!myPacket->isPacketValid())
{
LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, "Invalid handshake packet from %d", player->getId());
LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, "Invalid handshake packet from client at %s", packet->systemAddress.ToString());
kickPlayer(player->guid);
return;
}
if (player->isHandshaked())
{
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Wrong handshake with player %d, name: %s", player->getId(),
player->npc.mName.c_str());
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Wrong handshake with client at %s", packet->systemAddress.ToString());
kickPlayer(player->guid);
return;
}
if (player->passw != serverPassword)
if (player->serverPassword != serverPassword)
{
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Wrong server password for player %d, name: %s (pass: %s)",
player->getId(), player->npc.mName.c_str(), player->passw.c_str());
if (isPassworded())
{
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Wrong server password %s used by client at %s",
player->serverPassword.c_str(), packet->systemAddress.ToString());
kickPlayer(player->guid);
return;
}
else
{
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Client at %s tried to join using password, despite the server not being passworded",
packet->systemAddress.ToString());
}
}
player->setHandshake();
return;
}
@ -125,9 +132,8 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
if (!player->isHandshaked())
{
player->incrementHandshakeAttempts();
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Have not completed handshake with player %d", player->getId());
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Attempts so far: %i", player->getHandshakeAttempts());
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Have not completed handshake with client at %s", packet->systemAddress.ToString());
LOG_APPEND(Log::LOG_WARN, "- Attempts so far: %i", player->getHandshakeAttempts());
if (player->getHandshakeAttempts() > 20)
kickPlayer(player->guid, false);
@ -239,7 +245,7 @@ bool Networking::preInit(RakNet::Packet *packet, RakNet::BitStream &bsIn)
auto plugin = plugins.begin();
if (samples.size() == plugins.size())
{
for (int i = 0; plugin != plugins.end(); ++plugin, i++)
for (int i = 0; plugin != plugins.end(); plugin++, i++)
{
LOG_APPEND(Log::LOG_VERBOSE, "- %X\t%s", plugin->second[0], plugin->first.c_str());
// Check if the filenames match, ignoring case
@ -311,7 +317,7 @@ void Networking::update(RakNet::Packet *packet, RakNet::BitStream &bsIn)
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Unhandled RakNet packet with identifier %i has arrived", packet->data[0]);
}
void Networking::newPlayer(const RakNet::RakNetGUID &guid)
void Networking::newPlayer(RakNet::RakNetGUID guid)
{
playerPacketController->GetPacket(ID_PLAYER_BASEINFO)->RequestData(guid);
playerPacketController->GetPacket(ID_PLAYER_STATS_DYNAMIC)->RequestData(guid);
@ -321,27 +327,27 @@ void Networking::newPlayer(const RakNet::RakNetGUID &guid)
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Sending info about other players to %lu", guid.g);
for (auto &player : *players) //sending other players to new player
for (TPlayers::iterator pl = players->begin(); pl != players->end(); pl++) //sending other players to new player
{
// If we are iterating over the new player, don't send the packets below
if (player.first == guid) continue;
if (pl->first == guid) continue;
// If an invalid key makes it into the Players map, ignore it
else if (player.first == RakNet::UNASSIGNED_CRABNET_GUID) continue;
else if (pl->first == RakNet::UNASSIGNED_CRABNET_GUID) continue;
// if player not fully connected
else if (player.second == nullptr) continue;
else if (pl->second == nullptr) continue;
// If we are iterating over a player who has inputted their name, proceed
else if (player.second->getLoadState() == Player::POSTLOADED)
else if (pl->second->getLoadState() == Player::POSTLOADED)
{
playerPacketController->GetPacket(ID_PLAYER_BASEINFO)->setPlayer(player.second);
playerPacketController->GetPacket(ID_PLAYER_STATS_DYNAMIC)->setPlayer(player.second);
playerPacketController->GetPacket(ID_PLAYER_ATTRIBUTE)->setPlayer(player.second);
playerPacketController->GetPacket(ID_PLAYER_SKILL)->setPlayer(player.second);
playerPacketController->GetPacket(ID_PLAYER_POSITION)->setPlayer(player.second);
playerPacketController->GetPacket(ID_PLAYER_CELL_CHANGE)->setPlayer(player.second);
playerPacketController->GetPacket(ID_PLAYER_EQUIPMENT)->setPlayer(player.second);
playerPacketController->GetPacket(ID_PLAYER_BASEINFO)->setPlayer(pl->second);
playerPacketController->GetPacket(ID_PLAYER_STATS_DYNAMIC)->setPlayer(pl->second);
playerPacketController->GetPacket(ID_PLAYER_ATTRIBUTE)->setPlayer(pl->second);
playerPacketController->GetPacket(ID_PLAYER_SKILL)->setPlayer(pl->second);
playerPacketController->GetPacket(ID_PLAYER_POSITION)->setPlayer(pl->second);
playerPacketController->GetPacket(ID_PLAYER_CELL_CHANGE)->setPlayer(pl->second);
playerPacketController->GetPacket(ID_PLAYER_EQUIPMENT)->setPlayer(pl->second);
playerPacketController->GetPacket(ID_PLAYER_BASEINFO)->Send(guid);
playerPacketController->GetPacket(ID_PLAYER_STATS_DYNAMIC)->Send(guid);
@ -357,7 +363,7 @@ void Networking::newPlayer(const RakNet::RakNetGUID &guid)
}
void Networking::disconnectPlayer(const RakNet::RakNetGUID &guid)
void Networking::disconnectPlayer(RakNet::RakNetGUID guid)
{
Player *player = Players::getPlayer(guid);
if (!player)
@ -452,7 +458,7 @@ Networking *Networking::getPtr()
return sThis;
}
RakNet::SystemAddress Networking::getSystemAddress(const RakNet::RakNetGUID &guid)
RakNet::SystemAddress Networking::getSystemAddress(RakNet::RakNetGUID guid)
{
return peer->GetSystemAddressFromGuid(guid);
}
@ -532,7 +538,7 @@ int Networking::mainLoop()
return exitCode;
}
void Networking::kickPlayer(const RakNet::RakNetGUID &guid, bool sendNotification)
void Networking::kickPlayer(RakNet::RakNetGUID guid, bool sendNotification)
{
peer->CloseConnection(guid, sendNotification);
}
@ -557,7 +563,7 @@ unsigned int Networking::maxConnections() const
return peer->GetMaximumIncomingConnections();
}
int Networking::getAvgPing(const RakNet::AddressOrGUID &addr) const
int Networking::getAvgPing(RakNet::AddressOrGUID addr) const
{
return peer->GetAveragePing(addr);
}
@ -572,15 +578,15 @@ MasterClient *Networking::getMasterClient()
return mclient;
}
void Networking::InitQuery(const std::string &queryAddr, unsigned short queryPort)
void Networking::InitQuery(std::string queryAddr, unsigned short queryPort)
{
mclient = new MasterClient(peer, queryAddr, queryPort);
}
void Networking::postInit()
{
Script::Call<Script::CallbackIdentity("OnRequestDataFileList")>();
Script::Call<Script::CallbackIdentity("OnServerPostInit")>();
Script::Call<Script::CallbackIdentity("OnRequestPluginList")>();
}
PacketPreInit::PluginContainer &Networking::getSamples()

View file

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

View file

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

View file

@ -21,20 +21,19 @@
#include "Cell.hpp"
#include "CellController.hpp"
struct Player;
typedef std::map<RakNet::RakNetGUID, Player*> TPlayers;
typedef std::map<unsigned short, Player*> TSlots;
class Players
{
public:
static void newPlayer(const RakNet::RakNetGUID &guid);
static void deletePlayer(const RakNet::RakNetGUID &guid);
static Player *getPlayer(const RakNet::RakNetGUID &guid);
static void newPlayer(RakNet::RakNetGUID guid);
static void deletePlayer(RakNet::RakNetGUID guid);
static Player *getPlayer(RakNet::RakNetGUID guid);
static Player *getPlayer(unsigned short id);
static TPlayers *getPlayers();
static unsigned short getLastPlayerId();
static bool doesPlayerExist(const RakNet::RakNetGUID &guid);
static bool doesPlayerExist(RakNet::RakNetGUID guid);
private:
static TPlayers players;
@ -44,8 +43,9 @@ private:
class Player : public mwmp::BasePlayer
{
friend class Cell;
unsigned short id;
public:
const unsigned int InvalidID = (unsigned int) -1;
enum
{
NOTLOADED=0,
@ -53,9 +53,9 @@ public:
POSTLOADED,
KICKED
};
Player(const RakNet::RakNetGUID &guid);
Player(RakNet::RakNetGUID guid);
unsigned int getId();
unsigned short getId();
void setId(unsigned short id);
bool isHandshaked();
@ -77,7 +77,6 @@ private:
CellController::TContainer cells;
int loadState;
int handshakeCounter;
unsigned int id;
};

View file

@ -19,21 +19,11 @@ Public::Public(ScriptFunc _public, const std::string &name, char ret_type, const
publics.emplace(name, this);
}
#ifdef ENABLE_LUA
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);
}
#endif
#ifdef ENABLE_MONO
Public::Public(MonoObject *delegate, const std::string &name, char ret_type, const std::string &def) :
ScriptFunction(delegate, ret_type, def)
{
publics.emplace(name, this);
}
#endif
boost::any Public::Call(const std::string &name, const std::vector<boost::any> &args)
{
@ -55,15 +45,6 @@ const std::string &Public::GetDefinition(const std::string &name)
return it->second->def;
}
Public *Public::GetPublic(const std::string &name)
{
auto it = publics.find(name);
if (it == publics.end())
throw runtime_error("Public with name \"" + name + "\" does not exist");
return it->second;
}
bool Public::IsLua(const std::string &name)
{
@ -80,7 +61,7 @@ bool Public::IsLua(const std::string &name)
void Public::DeleteAll()
{
for (auto it = publics.begin(); it != publics.end(); ++it)
for (auto it = publics.begin(); it != publics.end(); it++)
{
Public *_public = it->second;
delete _public;

View file

@ -20,9 +20,6 @@ private:
#if defined(ENABLE_LUA)
Public(ScriptFuncLua _public, lua_State *lua, const std::string &name, char ret_type, const std::string &def);
#endif
#if defined(ENABLE_MONO)
Public(MonoObject *delegate, const std::string &name, char ret_type, const std::string &def);
#endif
public:
template<typename... Args>
@ -33,8 +30,6 @@ public:
static const std::string& GetDefinition(const std::string& name);
static Public * GetPublic(const std::string& name);
static bool IsLua(const std::string &name);
static void DeleteAll();

View file

@ -1,7 +1,3 @@
//
// Created by koncord on 15.03.16.
//
#include "TimerAPI.hpp"
#include <chrono>
@ -10,34 +6,25 @@
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)
Timer::Timer(ScriptFunc callback, long msec, const std::string& def, std::vector<boost::any> args) : ScriptFunction(callback, 'v', def)
{
startTime = 0;
targetMsec = msec;
end = true;
this->args = args;
isEnded = true;
}
#if defined(ENABLE_LUA)
Timer::Timer(lua_State *lua, ScriptFuncLua callback, long msec, const std::string& def, std::vector<boost::any> args): ScriptFunction(callback, lua, 'v', def), args(args)
Timer::Timer(lua_State *lua, ScriptFuncLua callback, long msec, const std::string& def, std::vector<boost::any> args): ScriptFunction(callback, lua, 'v', def)
{
startTime = 0;
targetMsec = msec;
end = true;
}
#endif
#ifdef ENABLE_MONO
Timer::Timer(MonoObject *callback, long msec, const std::string &def, std::vector<boost::any> args) : ScriptFunction(callback, 'v', def), args(args)
{
startTime = 0;
targetMsec = msec;
end = true;
this->args = args;
isEnded = true;
}
#endif
void Timer::Tick()
{
if (end)
if (isEnded)
return;
const auto duration = chrono::system_clock::now().time_since_epoch();
@ -45,19 +32,19 @@ void Timer::Tick()
if (time - startTime >= targetMsec)
{
end = true;
isEnded = true;
Call(args);
}
}
bool Timer::IsEnd()
bool Timer::IsEnded()
{
return end;
return isEnded;
}
void Timer::Stop()
{
end = true;
isEnded = true;
}
void Timer::Restart(int msec)
@ -68,7 +55,7 @@ void Timer::Restart(int msec)
void Timer::Start()
{
end = false;
isEnded = false;
const auto duration = chrono::system_clock::now().time_since_epoch();
const auto msec = chrono::duration_cast<chrono::milliseconds>(duration).count();
@ -102,30 +89,8 @@ int TimerAPI::CreateTimerLua(lua_State *lua, ScriptFuncLua callback, long msec,
}
#endif
#if defined(ENABLE_MONO)
int TimerAPI::CreateTimerMono(MonoObject *callback, long msec, const std::string& def, std::vector<boost::any> args)
{
int id = -1;
for (auto timer : timers)
{
if (timer.second != nullptr)
continue;
timer.second = new Timer(callback, msec, def, args);
id = timer.first;
}
if (id == -1)
{
timers[pointer] = new Timer(callback, msec, def, args);
id = pointer;
pointer++;
}
return id;
}
#endif
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, std::vector<boost::any> args)
{
int id = -1;
@ -203,12 +168,12 @@ void TimerAPI::StopTimer(int timerid)
}
}
bool TimerAPI::IsEndTimer(int timerid)
bool TimerAPI::IsTimerElapsed(int timerid)
{
bool ret = false;
try
{
ret = timers.at(timerid)->IsEnd();
ret = timers.at(timerid)->IsEnded();
}
catch(...)
{

View file

@ -1,7 +1,3 @@
//
// Created by koncord on 15.03.16.
//
#ifndef OPENMW_TIMERAPI_HPP
#define OPENMW_TIMERAPI_HPP
@ -10,10 +6,6 @@
#include <Script/Script.hpp>
#include <Script/ScriptFunction.hpp>
#ifdef ENABLE_MONO
#include <mono/metadata/object.h>
#endif
namespace mwmp
{
@ -28,22 +20,19 @@ namespace mwmp
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
#ifdef ENABLE_MONO
Timer(MonoObject *callback, long msec, const std::string& def, std::vector<boost::any> args);
#endif
void Tick();
bool IsEnd();
bool IsEnded();
void Stop();
void Start();
void Restart(int msec);
private:
double startTime, targetMsec;
//std::string publ, arg_types;
std::string publ, arg_types;
std::vector<boost::any> args;
//Script *scr;
bool end;
Script *scr;
bool isEnded;
};
class TimerAPI
@ -52,15 +41,12 @@ namespace mwmp
#if defined(ENABLE_LUA)
static int CreateTimerLua(lua_State *lua, ScriptFuncLua callback, long msec, const std::string& def, std::vector<boost::any> args);
#endif
#if defined(ENABLE_MONO)
static int CreateTimerMono(MonoObject *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, std::vector<boost::any> 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 IsEndTimer(int timerid);
static bool IsTimerElapsed(int timerid);
static void Terminate();

View file

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

View file

@ -1,8 +1,6 @@
#ifndef OPENMW_ACTORAPI_HPP
#define OPENMW_ACTORAPI_HPP
#include <Script/Platform.hpp>
#define ACTORAPI \
{"ReadReceivedActorList", ActorFunctions::ReadReceivedActorList},\
{"ReadCellActorList", ActorFunctions::ReadCellActorList},\
@ -104,14 +102,16 @@
{"GetActorKillerRefNumIndex", ActorFunctions::GetActorKillerRefNumIndex},\
{"SetActorRefNumIndex", ActorFunctions::SetActorRefNumIndex}
namespace ActorFunctions
class ActorFunctions
{
public:
/**
* \brief Use the last actor list received by the server as the one being read.
*
* \return void
*/
EXPORT_APIFUNCTION void CDECL ReadReceivedActorList() noexcept;
static void ReadReceivedActorList() noexcept;
/**
* \brief Use the temporary actor list stored for a cell as the one being read.
@ -122,14 +122,14 @@ namespace ActorFunctions
* \param cellDescription The description of the cell whose actor list should be read.
* \return void
*/
EXPORT_APIFUNCTION void CDECL ReadCellActorList(const char* cellDescription) noexcept;
static void ReadCellActorList(const char* cellDescription) noexcept;
/**
* \brief Clear the data from the actor list stored on the server.
*
* \return void
*/
EXPORT_APIFUNCTION void CDECL ClearActorList() noexcept;
static void ClearActorList() noexcept;
/**
* \brief Set the pid attached to the ActorList.
@ -137,7 +137,7 @@ namespace ActorFunctions
* \param pid The player ID to whom the actor list should be attached.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetActorListPid(unsigned short pid) noexcept;
static void SetActorListPid(unsigned short pid) noexcept;
/**
* \brief Take the contents of the read-only actor list last received by the
@ -146,21 +146,21 @@ namespace ActorFunctions
*
* \return void
*/
EXPORT_APIFUNCTION void CDECL CopyReceivedActorListToStore() noexcept;
static void CopyReceivedActorListToStore() noexcept;
/**
* \brief Get the number of indexes in the read actor list.
*
* \return The number of indexes.
*/
EXPORT_APIFUNCTION unsigned int CDECL GetActorListSize() noexcept;
static unsigned int 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).
*/
EXPORT_APIFUNCTION unsigned char CDECL GetActorListAction() noexcept;
static unsigned char GetActorListAction() noexcept;
/**
* \brief Get the cell description of the actor at a certain index in the read actor list.
@ -168,7 +168,7 @@ namespace ActorFunctions
* \param index The index of the actor.
* \return The cell description.
*/
EXPORT_APIFUNCTION const char *CDECL GetActorCell(unsigned int index) noexcept;
static const char *GetActorCell(unsigned int index) noexcept;
/**
* \brief Get the refId of the actor at a certain index in the read actor list.
@ -176,7 +176,7 @@ namespace ActorFunctions
* \param index The index of the actor.
* \return The refId.
*/
EXPORT_APIFUNCTION const char *CDECL GetActorRefId(unsigned int index) noexcept;
static const char *GetActorRefId(unsigned int index) noexcept;
/**
* \brief Get the refNum of the actor at a certain index in the read actor list.
@ -184,7 +184,7 @@ namespace ActorFunctions
* \param index The index of the actor.
* \return The refNum.
*/
EXPORT_APIFUNCTION unsigned int CDECL GetActorRefNum(unsigned int index) noexcept;
static unsigned int GetActorRefNum(unsigned int index) noexcept;
/**
* \brief Get the mpNum of the actor at a certain index in the read actor list.
@ -192,7 +192,7 @@ namespace ActorFunctions
* \param index The index of the actor.
* \return The mpNum.
*/
EXPORT_APIFUNCTION unsigned int CDECL GetActorMpNum(unsigned int index) noexcept;
static unsigned int GetActorMpNum(unsigned int index) noexcept;
/**
* \brief Get the X position of the actor at a certain index in the read actor list.
@ -200,7 +200,7 @@ namespace ActorFunctions
* \param index The index of the actor.
* \return The X position.
*/
EXPORT_APIFUNCTION double CDECL GetActorPosX(unsigned int index) noexcept;
static double GetActorPosX(unsigned int index) noexcept;
/**
* \brief Get the Y position of the actor at a certain index in the read actor list.
@ -208,7 +208,7 @@ namespace ActorFunctions
* \param index The index of the actor.
* \return The Y position.
*/
EXPORT_APIFUNCTION double CDECL GetActorPosY(unsigned int index) noexcept;
static double GetActorPosY(unsigned int index) noexcept;
/**
* \brief Get the Z position of the actor at a certain index in the read actor list.
@ -216,7 +216,7 @@ namespace ActorFunctions
* \param index The index of the actor.
* \return The Z position.
*/
EXPORT_APIFUNCTION double CDECL GetActorPosZ(unsigned int index) noexcept;
static double GetActorPosZ(unsigned int index) noexcept;
/**
* \brief Get the X rotation of the actor at a certain index in the read actor list.
@ -224,7 +224,7 @@ namespace ActorFunctions
* \param index The index of the actor.
* \return The X rotation.
*/
EXPORT_APIFUNCTION double CDECL GetActorRotX(unsigned int index) noexcept;
static double GetActorRotX(unsigned int index) noexcept;
/**
* \brief Get the Y rotation of the actor at a certain index in the read actor list.
@ -232,7 +232,7 @@ namespace ActorFunctions
* \param index The index of the actor.
* \return The Y rotation.
*/
EXPORT_APIFUNCTION double CDECL GetActorRotY(unsigned int index) noexcept;
static double GetActorRotY(unsigned int index) noexcept;
/**
* \brief Get the Z rotation of the actor at a certain index in the read actor list.
@ -240,7 +240,7 @@ namespace ActorFunctions
* \param index The index of the actor.
* \return The Z rotation.
*/
EXPORT_APIFUNCTION double CDECL GetActorRotZ(unsigned int index) noexcept;
static double GetActorRotZ(unsigned int index) noexcept;
/**
* \brief Get the base health of the actor at a certain index in the read actor list.
@ -248,7 +248,7 @@ namespace ActorFunctions
* \param index The index of the actor.
* \return The base health.
*/
EXPORT_APIFUNCTION double CDECL GetActorHealthBase(unsigned int index) noexcept;
static double GetActorHealthBase(unsigned int index) noexcept;
/**
* \brief Get the current health of the actor at a certain index in the read actor list.
@ -256,7 +256,7 @@ namespace ActorFunctions
* \param index The index of the actor.
* \return The current health.
*/
EXPORT_APIFUNCTION double CDECL GetActorHealthCurrent(unsigned int index) noexcept;
static double GetActorHealthCurrent(unsigned int index) noexcept;
/**
* \brief Get the modified health of the actor at a certain index in the read actor list.
@ -264,7 +264,7 @@ namespace ActorFunctions
* \param index The index of the actor.
* \return The modified health.
*/
EXPORT_APIFUNCTION double CDECL GetActorHealthModified(unsigned int index) noexcept;
static double GetActorHealthModified(unsigned int index) noexcept;
/**
* \brief Get the base magicka of the actor at a certain index in the read actor list.
@ -272,7 +272,7 @@ namespace ActorFunctions
* \param index The index of the actor.
* \return The base magicka.
*/
EXPORT_APIFUNCTION double CDECL GetActorMagickaBase(unsigned int index) noexcept;
static double GetActorMagickaBase(unsigned int index) noexcept;
/**
* \brief Get the current magicka of the actor at a certain index in the read actor list.
@ -280,7 +280,7 @@ namespace ActorFunctions
* \param index The index of the actor.
* \return The current magicka.
*/
EXPORT_APIFUNCTION double CDECL GetActorMagickaCurrent(unsigned int index) noexcept;
static double GetActorMagickaCurrent(unsigned int index) noexcept;
/**
* \brief Get the modified magicka of the actor at a certain index in the read actor list.
@ -288,7 +288,7 @@ namespace ActorFunctions
* \param index The index of the actor.
* \return The modified magicka.
*/
EXPORT_APIFUNCTION double CDECL GetActorMagickaModified(unsigned int index) noexcept;
static double GetActorMagickaModified(unsigned int index) noexcept;
/**
* \brief Get the base fatigue of the actor at a certain index in the read actor list.
@ -296,7 +296,7 @@ namespace ActorFunctions
* \param index The index of the actor.
* \return The base fatigue.
*/
EXPORT_APIFUNCTION double CDECL GetActorFatigueBase(unsigned int index) noexcept;
static double GetActorFatigueBase(unsigned int index) noexcept;
/**
* \brief Get the current fatigue of the actor at a certain index in the read actor list.
@ -304,7 +304,7 @@ namespace ActorFunctions
* \param index The index of the actor.
* \return The current fatigue.
*/
EXPORT_APIFUNCTION double CDECL GetActorFatigueCurrent(unsigned int index) noexcept;
static double GetActorFatigueCurrent(unsigned int index) noexcept;
/**
* \brief Get the modified fatigue of the actor at a certain index in the read actor list.
@ -312,7 +312,7 @@ namespace ActorFunctions
* \param index The index of the actor.
* \return The modified fatigue.
*/
EXPORT_APIFUNCTION double CDECL GetActorFatigueModified(unsigned int index) noexcept;
static double GetActorFatigueModified(unsigned int index) noexcept;
/**
* \brief Get the refId of the item in a certain slot of the equipment of the actor at a
@ -322,7 +322,7 @@ namespace ActorFunctions
* \param slot The slot of the equipment item.
* \return The refId.
*/
EXPORT_APIFUNCTION const char *CDECL GetActorEquipmentItemRefId(unsigned int index, unsigned short slot) noexcept;
static const char *GetActorEquipmentItemRefId(unsigned int index, unsigned short slot) noexcept;
/**
* \brief Get the count of the item in a certain slot of the equipment of the actor at a
@ -332,7 +332,7 @@ namespace ActorFunctions
* \param slot The slot of the equipment item.
* \return The item count.
*/
EXPORT_APIFUNCTION int CDECL GetActorEquipmentItemCount(unsigned int index, unsigned short slot) noexcept;
static int GetActorEquipmentItemCount(unsigned int index, unsigned short slot) noexcept;
/**
* \brief Get the charge of the item in a certain slot of the equipment of the actor at a
@ -342,7 +342,7 @@ namespace ActorFunctions
* \param slot The slot of the equipment item.
* \return The charge.
*/
EXPORT_APIFUNCTION int CDECL GetActorEquipmentItemCharge(unsigned int index, unsigned short slot) noexcept;
static int GetActorEquipmentItemCharge(unsigned int index, unsigned short slot) noexcept;
/**
* \brief Get the enchantment charge of the item in a certain slot of the equipment of the actor at a
@ -352,7 +352,7 @@ namespace ActorFunctions
* \param slot The slot of the equipment item.
* \return The enchantment charge.
*/
EXPORT_APIFUNCTION double CDECL GetActorEquipmentItemEnchantmentCharge(unsigned int index, unsigned short slot) noexcept;
static double GetActorEquipmentItemEnchantmentCharge(unsigned int index, unsigned short slot) noexcept;
/**
* \brief Check whether the killer of the actor at a certain index in the read actor list is a player.
@ -360,7 +360,7 @@ namespace ActorFunctions
* \param index The index of the actor.
* \return Whether the actor was killed by a player.
*/
EXPORT_APIFUNCTION bool CDECL DoesActorHavePlayerKiller(unsigned int index) noexcept;
static bool DoesActorHavePlayerKiller(unsigned int index) noexcept;
/**
* \brief Get the player ID of the killer of the actor at a certain index in the read actor list.
@ -368,7 +368,7 @@ namespace ActorFunctions
* \param index The index of the actor.
* \return The player ID of the killer.
*/
EXPORT_APIFUNCTION int CDECL GetActorKillerPid(unsigned int index) noexcept;
static int GetActorKillerPid(unsigned int index) noexcept;
/**
* \brief Get the refId of the actor killer of the actor at a certain index in the read actor list.
@ -376,7 +376,7 @@ namespace ActorFunctions
* \param index The index of the actor.
* \return The refId of the killer.
*/
EXPORT_APIFUNCTION const char *CDECL GetActorKillerRefId(unsigned int index) noexcept;
static const char *GetActorKillerRefId(unsigned int index) noexcept;
/**
* \brief Get the refNum of the actor killer of the actor at a certain index in the read actor list.
@ -384,7 +384,7 @@ namespace ActorFunctions
* \param index The index of the actor.
* \return The refNum of the killer.
*/
EXPORT_APIFUNCTION unsigned int CDECL GetActorKillerRefNum(unsigned int index) noexcept;
static unsigned int GetActorKillerRefNum(unsigned int index) noexcept;
/**
* \brief Get the mpNum of the actor killer of the actor at a certain index in the read actor list.
@ -392,7 +392,7 @@ namespace ActorFunctions
* \param index The index of the actor.
* \return The mpNum of the killer.
*/
EXPORT_APIFUNCTION unsigned int CDECL GetActorKillerMpNum(unsigned int index) noexcept;
static unsigned int GetActorKillerMpNum(unsigned int index) noexcept;
/**
* \brief Get the name of the actor killer of the actor at a certain index in the read actor list.
@ -400,7 +400,7 @@ namespace ActorFunctions
* \param index The index of the actor.
* \return The name of the killer.
*/
EXPORT_APIFUNCTION const char *CDECL GetActorKillerName(unsigned int index) noexcept;
static const char *GetActorKillerName(unsigned int index) noexcept;
/**
* \brief Check whether there is any positional data for the actor at a certain index in
@ -411,7 +411,7 @@ namespace ActorFunctions
* \param index The index of the actor.
* \return Whether the read actor list contains positional data.
*/
EXPORT_APIFUNCTION bool CDECL DoesActorHavePosition(unsigned int index) noexcept;
static bool DoesActorHavePosition(unsigned int index) noexcept;
/**
* \brief Check whether there is any dynamic stats data for the actor at a certain index in
@ -422,7 +422,7 @@ namespace ActorFunctions
* \param index The index of the actor.
* \return Whether the read actor list contains dynamic stats data.
*/
EXPORT_APIFUNCTION bool CDECL DoesActorHaveStatsDynamic(unsigned int index) noexcept;
static bool DoesActorHaveStatsDynamic(unsigned int index) noexcept;
/**
* \brief Set the cell of the temporary actor list stored on the server.
@ -433,7 +433,7 @@ namespace ActorFunctions
* \param cellDescription The description of the cell.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetActorListCell(const char* cellDescription) noexcept;
static void SetActorListCell(const char* cellDescription) noexcept;
/**
* \brief Set the action type of the temporary actor list stored on the server.
@ -441,7 +441,7 @@ namespace ActorFunctions
* \param action The action type (0 for SET, 1 for ADD, 2 for REMOVE, 3 for REQUEST).
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetActorListAction(unsigned char action) noexcept;
static void SetActorListAction(unsigned char action) noexcept;
/**
* \brief Set the cell of the temporary actor stored on the server.
@ -455,7 +455,7 @@ namespace ActorFunctions
* \param cellDescription The description of the cell.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetActorCell(const char* cellDescription) noexcept;
static void SetActorCell(const char* cellDescription) noexcept;
/**
* \brief Set the refId of the temporary actor stored on the server.
@ -463,7 +463,7 @@ namespace ActorFunctions
* \param refId The refId.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetActorRefId(const char* refId) noexcept;
static void SetActorRefId(const char* refId) noexcept;
/**
* \brief Set the refNum of the temporary actor stored on the server.
@ -471,7 +471,7 @@ namespace ActorFunctions
* \param refNum The refNum.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetActorRefNum(int refNum) noexcept;
static void SetActorRefNum(int refNum) noexcept;
/**
* \brief Set the mpNum of the temporary actor stored on the server.
@ -479,7 +479,7 @@ namespace ActorFunctions
* \param mpNum The mpNum.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetActorMpNum(int mpNum) noexcept;
static void SetActorMpNum(int mpNum) noexcept;
/**
* \brief Set the position of the temporary actor stored on the server.
@ -489,7 +489,7 @@ namespace ActorFunctions
* \param z The Z position.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetActorPosition(double x, double y, double z) noexcept;
static void SetActorPosition(double x, double y, double z) noexcept;
/**
* \brief Set the rotation of the temporary actor stored on the server.
@ -499,7 +499,7 @@ namespace ActorFunctions
* \param z The Z rotation.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetActorRotation(double x, double y, double z) noexcept;
static void SetActorRotation(double x, double y, double z) noexcept;
/**
* \brief Set the base health of the temporary actor stored on the server.
@ -507,7 +507,7 @@ namespace ActorFunctions
* \param value The new value.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetActorHealthBase(double value) noexcept;
static void SetActorHealthBase(double value) noexcept;
/**
* \brief Set the current health of the temporary actor stored on the server.
@ -515,7 +515,7 @@ namespace ActorFunctions
* \param value The new value.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetActorHealthCurrent(double value) noexcept;
static void SetActorHealthCurrent(double value) noexcept;
/**
* \brief Set the modified health of the temporary actor stored on the server.
@ -523,7 +523,7 @@ namespace ActorFunctions
* \param value The new value.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetActorHealthModified(double value) noexcept;
static void SetActorHealthModified(double value) noexcept;
/**
* \brief Set the base magicka of the temporary actor stored on the server.
@ -531,7 +531,7 @@ namespace ActorFunctions
* \param value The new value.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetActorMagickaBase(double value) noexcept;
static void SetActorMagickaBase(double value) noexcept;
/**
* \brief Set the current magicka of the temporary actor stored on the server.
@ -539,7 +539,7 @@ namespace ActorFunctions
* \param value The new value.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetActorMagickaCurrent(double value) noexcept;
static void SetActorMagickaCurrent(double value) noexcept;
/**
* \brief Set the modified magicka of the temporary actor stored on the server.
@ -547,7 +547,7 @@ namespace ActorFunctions
* \param value The new value.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetActorMagickaModified(double value) noexcept;
static void SetActorMagickaModified(double value) noexcept;
/**
* \brief Set the base fatigue of the temporary actor stored on the server.
@ -555,7 +555,7 @@ namespace ActorFunctions
* \param value The new value.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetActorFatigueBase(double value) noexcept;
static void SetActorFatigueBase(double value) noexcept;
/**
* \brief Set the current fatigue of the temporary actor stored on the server.
@ -563,7 +563,7 @@ namespace ActorFunctions
* \param value The new value.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetActorFatigueCurrent(double value) noexcept;
static void SetActorFatigueCurrent(double value) noexcept;
/**
* \brief Set the modified fatigue of the temporary actor stored on the server.
@ -571,7 +571,7 @@ namespace ActorFunctions
* \param value The new value.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetActorFatigueModified(double value) noexcept;
static void SetActorFatigueModified(double value) noexcept;
/**
* \brief Set the sound of the temporary actor stored on the server.
@ -579,7 +579,7 @@ namespace ActorFunctions
* \param sound The sound.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetActorSound(const char* sound) noexcept;
static void SetActorSound(const char* sound) noexcept;
/**
* \brief Set the AI action of the temporary actor stored on the server.
@ -587,7 +587,7 @@ namespace ActorFunctions
* \param action The new action.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetActorAIAction(unsigned int action) noexcept;
static void SetActorAIAction(unsigned int action) noexcept;
/**
* \brief Set a player as the AI target of the temporary actor stored on the server.
@ -595,7 +595,7 @@ namespace ActorFunctions
* \param pid The player ID.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetActorAITargetToPlayer(unsigned short pid) noexcept;
static void SetActorAITargetToPlayer(unsigned short pid) noexcept;
/**
* \brief Set another object as the AI target of the temporary actor stored on the server.
@ -604,7 +604,7 @@ namespace ActorFunctions
* \param mpNum The mpNum of the target object.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetActorAITargetToObject(int refNum, int mpNum) noexcept;
static void SetActorAITargetToObject(int refNum, int mpNum) noexcept;
/**
* \brief Set the coordinates for the AI package associated with the current AI action.
@ -614,7 +614,7 @@ namespace ActorFunctions
* \param z The Z coordinate.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetActorAICoordinates(double x, double y, double z) noexcept;
static void SetActorAICoordinates(double x, double y, double z) noexcept;
/**
* \brief Set the distance of the AI package associated with the current AI action.
@ -622,7 +622,7 @@ namespace ActorFunctions
* \param duration The distance of the package.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetActorAIDistance(unsigned int distance) noexcept;
static void SetActorAIDistance(unsigned int distance) noexcept;
/**
* \brief Set the duration of the AI package associated with the current AI action.
@ -630,7 +630,7 @@ namespace ActorFunctions
* \param duration The duration of the package.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetActorAIDuration(unsigned int duration) noexcept;
static void SetActorAIDuration(unsigned int duration) noexcept;
/**
* \brief Set whether the current AI package should be repeated.
@ -640,7 +640,7 @@ namespace ActorFunctions
* \param shouldRepeat Whether the package should be repeated.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetActorAIRepetition(bool shouldRepeat) noexcept;
static void SetActorAIRepetition(bool shouldRepeat) noexcept;
/**
* \brief Equip an item in a certain slot of the equipment of the temporary actor stored
@ -653,7 +653,7 @@ namespace ActorFunctions
* \param enchantmentCharge The enchantment charge of the item.
* \return void
*/
EXPORT_APIFUNCTION void CDECL EquipActorItem(unsigned short slot, const char* refId, unsigned int count, int charge, double enchantmentCharge = -1) noexcept;
static void EquipActorItem(unsigned short slot, const char* refId, unsigned int count, int charge, double enchantmentCharge = -1) noexcept;
/**
* \brief Unequip the item in a certain slot of the equipment of the temporary actor stored
@ -662,7 +662,7 @@ namespace ActorFunctions
* \param slot The equipment slot.
* \return void
*/
EXPORT_APIFUNCTION void CDECL UnequipActorItem(unsigned short slot) noexcept;
static void UnequipActorItem(unsigned short slot) noexcept;
/**
* \brief Add a copy of the server's temporary actor to the server's temporary actor list.
@ -672,7 +672,7 @@ namespace ActorFunctions
*
* \return void
*/
EXPORT_APIFUNCTION void CDECL AddActor() noexcept;
static void AddActor() noexcept;
/**
* \brief Send an ActorList packet.
@ -681,7 +681,7 @@ namespace ActorFunctions
*
* \return void
*/
EXPORT_APIFUNCTION void CDECL SendActorList() noexcept;
static void SendActorList() noexcept;
/**
* \brief Send an ActorAuthority packet.
@ -693,7 +693,7 @@ namespace ActorFunctions
*
* \return void
*/
EXPORT_APIFUNCTION void CDECL SendActorAuthority() noexcept;
static void SendActorAuthority() noexcept;
/**
* \brief Send an ActorPosition packet.
@ -705,7 +705,7 @@ namespace ActorFunctions
*
* \return void
*/
EXPORT_APIFUNCTION void CDECL SendActorPosition(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept;
static void SendActorPosition(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept;
/**
* \brief Send an ActorStatsDynamic packet.
@ -717,7 +717,7 @@ namespace ActorFunctions
*
* \return void
*/
EXPORT_APIFUNCTION void CDECL SendActorStatsDynamic(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept;
static void SendActorStatsDynamic(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept;
/**
* \brief Send an ActorEquipment packet.
@ -729,7 +729,7 @@ namespace ActorFunctions
*
* \return void
*/
EXPORT_APIFUNCTION void CDECL SendActorEquipment(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept;
static void SendActorEquipment(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept;
/**
* \brief Send an ActorSpeech packet.
@ -740,7 +740,7 @@ namespace ActorFunctions
* to the packet (false by default).
* \return void
*/
EXPORT_APIFUNCTION void CDECL SendActorSpeech(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept;
static void SendActorSpeech(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept;
/**
* \brief Send an ActorAI packet.
@ -751,7 +751,7 @@ namespace ActorFunctions
* to the packet (false by default).
* \return void
*/
EXPORT_APIFUNCTION void CDECL SendActorAI(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept;
static void SendActorAI(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept;
/**
* \brief Send an ActorCellChange packet.
@ -763,18 +763,18 @@ namespace ActorFunctions
*
* \return void
*/
EXPORT_APIFUNCTION void CDECL SendActorCellChange(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept;
static void SendActorCellChange(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept;
// All methods below are deprecated versions of methods from above
EXPORT_APIFUNCTION void CDECL ReadLastActorList() noexcept;
EXPORT_APIFUNCTION void CDECL InitializeActorList(unsigned short pid) noexcept;
EXPORT_APIFUNCTION void CDECL CopyLastActorListToStore() noexcept;
EXPORT_APIFUNCTION unsigned int CDECL GetActorRefNumIndex(unsigned int index) noexcept;
EXPORT_APIFUNCTION unsigned int CDECL GetActorKillerRefNumIndex(unsigned int index) noexcept;
EXPORT_APIFUNCTION void CDECL SetActorRefNumIndex(int refNum) noexcept;
}
static void ReadLastActorList() noexcept;
static void InitializeActorList(unsigned short pid) noexcept;
static void CopyLastActorListToStore() noexcept;
static unsigned int GetActorRefNumIndex(unsigned int index) noexcept;
static unsigned int GetActorKillerRefNumIndex(unsigned int index) noexcept;
static void SetActorRefNumIndex(int refNum) noexcept;
};
#endif //OPENMW_ACTORAPI_HPP

View file

@ -7,7 +7,7 @@
using namespace mwmp;
extern "C" void BookFunctions::ClearBookChanges(unsigned short pid) noexcept
void BookFunctions::ClearBookChanges(unsigned short 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
unsigned int BookFunctions::GetBookChangesSize(unsigned short 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
void BookFunctions::AddBook(unsigned short 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
const char *BookFunctions::GetBookId(unsigned short 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
void BookFunctions::SendBookChanges(unsigned short 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
void BookFunctions::InitializeBookChanges(unsigned short pid) noexcept
{
ClearBookChanges(pid);
}

View file

@ -1,8 +1,6 @@
#ifndef OPENMW_BOOKAPI_HPP
#define OPENMW_BOOKAPI_HPP
#include <Script/Platform.hpp>
#define BOOKAPI \
{"ClearBookChanges", BookFunctions::ClearBookChanges},\
\
@ -16,8 +14,9 @@
\
{"InitializeBookChanges", BookFunctions::InitializeBookChanges}
namespace BookFunctions
class BookFunctions
{
public:
/**
* \brief Clear the last recorded book changes for a player.
@ -27,7 +26,7 @@ namespace BookFunctions
* \param pid The player ID whose book changes should be used.
* \return void
*/
EXPORT_APIFUNCTION void CDECL ClearBookChanges(unsigned short pid) noexcept;
static void ClearBookChanges(unsigned short pid) noexcept;
/**
* \brief Get the number of indexes in a player's latest book changes.
@ -35,7 +34,7 @@ namespace BookFunctions
* \param pid The player ID whose book changes should be used.
* \return The number of indexes.
*/
EXPORT_APIFUNCTION unsigned int CDECL GetBookChangesSize(unsigned short pid) noexcept;
static unsigned int GetBookChangesSize(unsigned short pid) noexcept;
/**
* \brief Add a new book to the book changes for a player.
@ -44,7 +43,7 @@ namespace BookFunctions
* \param bookId The bookId of the book.
* \return void
*/
EXPORT_APIFUNCTION void CDECL AddBook(unsigned short pid, const char* bookId) noexcept;
static void AddBook(unsigned short pid, const char* bookId) noexcept;
/**
* \brief Get the bookId at a certain index in a player's latest book changes.
@ -53,7 +52,7 @@ namespace BookFunctions
* \param index The index of the book.
* \return The bookId.
*/
EXPORT_APIFUNCTION const char *CDECL GetBookId(unsigned short pid, unsigned int index) noexcept;
static const char *GetBookId(unsigned short pid, unsigned int index) noexcept;
/**
* \brief Send a PlayerBook packet with a player's recorded book changes.
@ -65,11 +64,12 @@ namespace BookFunctions
* to the packet (false by default).
* \return void
*/
EXPORT_APIFUNCTION void CDECL SendBookChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
static void SendBookChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
// All methods below are deprecated versions of methods from above
EXPORT_APIFUNCTION void CDECL InitializeBookChanges(unsigned short pid) noexcept;
}
static void InitializeBookChanges(unsigned short pid) noexcept;
};
#endif //OPENMW_BOOKAPI_HPP

View file

@ -12,7 +12,7 @@ using namespace std;
static std::string tempCellDescription;
extern "C" unsigned int CellFunctions::GetCellStateChangesSize(unsigned short pid) noexcept
unsigned int CellFunctions::GetCellStateChangesSize(unsigned short 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
unsigned int CellFunctions::GetCellStateType(unsigned short 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
const char *CellFunctions::GetCellStateDescription(unsigned short pid, unsigned int index) noexcept
{
Player *player;
GET_PLAYER(pid, player, "");
@ -40,30 +40,30 @@ extern "C" const char *CellFunctions::GetCellStateDescription(unsigned short pid
return tempCellDescription.c_str();
}
extern "C" const char *CellFunctions::GetCell(unsigned short pid) noexcept
const char *CellFunctions::GetCell(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
tempCellDescription = player->cell.getDescription();
tempCellDescription = player->cell.getDescription().c_str();
return tempCellDescription.c_str();
}
extern "C" int CellFunctions::GetExteriorX(unsigned short pid) noexcept
int CellFunctions::GetExteriorX(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
return player->cell.mData.mX;
}
extern "C" int CellFunctions::GetExteriorY(unsigned short pid) noexcept
int CellFunctions::GetExteriorY(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
return player->cell.mData.mY;
}
extern "C" bool CellFunctions::IsInExterior(unsigned short pid) noexcept
bool CellFunctions::IsInExterior(unsigned short 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
const char *CellFunctions::GetRegion(unsigned short 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
bool CellFunctions::IsChangingRegion(unsigned short 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
void CellFunctions::SetCell(unsigned short 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
void CellFunctions::SetExteriorCell(unsigned short 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
void CellFunctions::SendCell(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );

View file

@ -3,8 +3,6 @@
#include "../Types.hpp"
#include <Script/Platform.hpp>
#define CELLAPI \
{"GetCellStateChangesSize", CellFunctions::GetCellStateChangesSize},\
\
@ -25,15 +23,17 @@
{"SendCell", CellFunctions::SendCell}
namespace CellFunctions
class CellFunctions
{
public:
/**
* \brief Get the number of indexes in a player's latest cell state changes.
*
* \param pid The player ID whose cell state changes should be used.
* \return The number of indexes.
*/
EXPORT_APIFUNCTION unsigned int CDECL GetCellStateChangesSize(unsigned short pid) noexcept;
static unsigned int GetCellStateChangesSize(unsigned short pid) noexcept;
/**
* \brief Get the cell state type at a certain index in a player's latest cell state changes.
@ -42,7 +42,7 @@ namespace CellFunctions
* \param index The index of the cell state.
* \return The cell state type (0 for LOAD, 1 for UNLOAD).
*/
EXPORT_APIFUNCTION unsigned int CDECL GetCellStateType(unsigned short pid, unsigned int index) noexcept;
static unsigned int GetCellStateType(unsigned short pid, unsigned int index) noexcept;
/**
* \brief Get the cell description at a certain index in a player's latest cell state changes.
@ -51,7 +51,7 @@ namespace CellFunctions
* \param index The index of the cell state.
* \return The cell description.
*/
EXPORT_APIFUNCTION const char *CDECL GetCellStateDescription(unsigned short pid, unsigned int index) noexcept;
static const char *GetCellStateDescription(unsigned short pid, unsigned int index) noexcept;
/**
* \brief Get the cell description of a player's cell.
@ -59,7 +59,7 @@ namespace CellFunctions
* \param pid The player ID.
* \return The cell description.
*/
EXPORT_APIFUNCTION const char *CDECL GetCell(unsigned short pid) noexcept;
static const char *GetCell(unsigned short pid) noexcept;
/**
* \brief Get the X coordinate of the player's exterior cell.
@ -67,7 +67,7 @@ namespace CellFunctions
* \param pid The player ID.
* \return The X coordinate of the cell.
*/
EXPORT_APIFUNCTION int CDECL GetExteriorX(unsigned short pid) noexcept;
static int GetExteriorX(unsigned short pid) noexcept;
/**
* \brief Get the Y coordinate of the player's exterior cell.
@ -75,7 +75,7 @@ namespace CellFunctions
* \param pid The player ID.
* \return The Y coordinate of the cell.
*/
EXPORT_APIFUNCTION int CDECL GetExteriorY(unsigned short pid) noexcept;
static int GetExteriorY(unsigned short pid) noexcept;
/**
* \brief Check whether the player is in an exterior cell or not.
@ -83,7 +83,7 @@ namespace CellFunctions
* \param pid The player ID.
* \return Whether the player is in an exterior cell.
*/
EXPORT_APIFUNCTION bool CDECL IsInExterior(unsigned short pid) noexcept;
static bool IsInExterior(unsigned short pid) noexcept;
/**
* \brief Get the region of the player's exterior cell.
@ -93,7 +93,7 @@ namespace CellFunctions
* \param pid The player ID.
* \return The region.
*/
EXPORT_APIFUNCTION const char *CDECL GetRegion(unsigned short pid) noexcept;
static const char *GetRegion(unsigned short pid) noexcept;
/**
* \brief Check whether the player's last cell change has involved a region change.
@ -101,7 +101,7 @@ namespace CellFunctions
* \param pid The player ID.
* \return Whether the player has changed their region.
*/
EXPORT_APIFUNCTION bool CDECL IsChangingRegion(unsigned short pid) noexcept;
static bool IsChangingRegion(unsigned short pid) noexcept;
/**
* \brief Set the cell of a player.
@ -116,7 +116,7 @@ namespace CellFunctions
* \param cellDescription The cell description.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetCell(unsigned short pid, const char *cellDescription) noexcept;
static void SetCell(unsigned short pid, const char *cellDescription) noexcept;
/**
* \brief Set the cell of a player to an exterior cell.
@ -129,7 +129,7 @@ namespace CellFunctions
* \param y The Y coordinate of the cell.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetExteriorCell(unsigned short pid, int x, int y) noexcept;
static void SetExteriorCell(unsigned short pid, int x, int y) noexcept;
/**
* \brief Send a PlayerCellChange packet about a player.
@ -139,7 +139,8 @@ namespace CellFunctions
* \param pid The player ID.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SendCell(unsigned short pid) noexcept;
}
static void SendCell(unsigned short pid) noexcept;
};
#endif //OPENMW_CELLAPI_HPP

View file

@ -12,7 +12,7 @@
using namespace std;
using namespace ESM;
extern "C" const char *CharClassFunctions::GetDefaultClass(unsigned short pid) noexcept
const char *CharClassFunctions::GetDefaultClass(unsigned short 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
const char *CharClassFunctions::GetClassName(unsigned short 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
const char *CharClassFunctions::GetClassDesc(unsigned short 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
int CharClassFunctions::GetClassMajorAttribute(unsigned short 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
int CharClassFunctions::GetClassSpecialization(unsigned short 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
int CharClassFunctions::GetClassMajorSkill(unsigned short 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
int CharClassFunctions::GetClassMinorSkill(unsigned short 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
int CharClassFunctions::IsClassDefault(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -85,32 +85,29 @@ 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
void CharClassFunctions::SetDefaultClass(unsigned short pid, const char *id) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
player->charClass.mId = id;
}
extern "C" void CharClassFunctions::SetClassName(unsigned short pid, const char *name) noexcept
void CharClassFunctions::SetClassName(unsigned short pid, const char *name) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
player->charClass.mName = name;
player->charClass.mId.clear();
player->charClass.mId = "";
}
extern "C" void CharClassFunctions::SetClassDesc(unsigned short pid, const char *desc) noexcept
void CharClassFunctions::SetClassDesc(unsigned short pid, const char *desc) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
player->charClass.mDescription = desc;
}
extern "C" void CharClassFunctions::SetClassMajorAttribute(unsigned short pid, unsigned char slot, int attrId) noexcept
void CharClassFunctions::SetClassMajorAttribute(unsigned short pid, unsigned char slot, int attrId) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -121,16 +118,14 @@ extern "C" void CharClassFunctions::SetClassMajorAttribute(unsigned short pid, u
player->charClass.mData.mAttribute[slot] = attrId;
}
extern "C" void CharClassFunctions::SetClassSpecialization(unsigned short pid, int spec) noexcept
void CharClassFunctions::SetClassSpecialization(unsigned short pid, int spec) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
player->charClass.mData.mSpecialization = spec;
}
extern "C" void CharClassFunctions::SetClassMajorSkill(unsigned short pid, unsigned char slot, int skillId) noexcept
void CharClassFunctions::SetClassMajorSkill(unsigned short pid, unsigned char slot, int skillId) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -140,8 +135,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
void CharClassFunctions::SetClassMinorSkill(unsigned short pid, unsigned char slot, int skillId) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -152,7 +146,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
void CharClassFunctions::SendClass(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );

View file

@ -7,8 +7,6 @@
#include "../Types.hpp"
#include <Script/Platform.hpp>
#define CHARCLASSAPI \
{"GetDefaultClass", CharClassFunctions::GetDefaultClass},\
{"GetClassName", CharClassFunctions::GetClassName},\
@ -30,15 +28,17 @@
{"SendClass", CharClassFunctions::SendClass}
namespace CharClassFunctions
class CharClassFunctions
{
public:
/**
* \brief Get the default class used by a player.
*
* \param pid The player ID.
* \return The ID of the default class.
*/
EXPORT_APIFUNCTION const char *CDECL GetDefaultClass(unsigned short pid) noexcept;
static const char *GetDefaultClass(unsigned short pid) noexcept;
/**
* \brief Get the name of the custom class used by a player.
@ -46,7 +46,7 @@ namespace CharClassFunctions
* \param pid The player ID.
* \return The name of the custom class.
*/
EXPORT_APIFUNCTION const char *CDECL GetClassName(unsigned short pid) noexcept;
static const char *GetClassName(unsigned short pid) noexcept;
/**
* \brief Get the description of the custom class used by a player.
@ -54,7 +54,7 @@ namespace CharClassFunctions
* \param pid The player ID.
* \return The description of the custom class.
*/
EXPORT_APIFUNCTION const char *CDECL GetClassDesc(unsigned short pid) noexcept;
static const char *GetClassDesc(unsigned short pid) noexcept;
/**
* \brief Get the ID of one of the two major attributes of a custom class used by a player.
@ -63,7 +63,7 @@ namespace CharClassFunctions
* \param slot The slot of the major attribute (0 or 1).
* \return The ID of the major attribute.
*/
EXPORT_APIFUNCTION int CDECL GetClassMajorAttribute(unsigned short pid, unsigned char slot) noexcept;
static int GetClassMajorAttribute(unsigned short pid, unsigned char slot) noexcept;
/**
* \brief Get the specialization ID of the custom class used by a player.
@ -71,7 +71,7 @@ namespace CharClassFunctions
* \param pid The player ID.
* \return The specialization ID of the custom class (0 for Combat, 1 for Magic, 2 for Stealth).
*/
EXPORT_APIFUNCTION int CDECL GetClassSpecialization(unsigned short pid) noexcept;
static int GetClassSpecialization(unsigned short pid) noexcept;
/**
* \brief Get the ID of one of the five major skills of a custom class used by a player.
@ -80,7 +80,7 @@ namespace CharClassFunctions
* \param slot The slot of the major skill (0 to 4).
* \return The ID of the major skill.
*/
EXPORT_APIFUNCTION int CDECL GetClassMajorSkill(unsigned short pid, unsigned char slot) noexcept;
static int GetClassMajorSkill(unsigned short pid, unsigned char slot) noexcept;
/**
* \brief Get the ID of one of the five minor skills of a custom class used by a player.
@ -89,7 +89,7 @@ namespace CharClassFunctions
* \param slot The slot of the minor skill (0 to 4).
* \return The ID of the minor skill.
*/
EXPORT_APIFUNCTION int CDECL GetClassMinorSkill(unsigned short pid, unsigned char slot) noexcept;
static int GetClassMinorSkill(unsigned short pid, unsigned char slot) noexcept;
/**
* \brief Check whether the player is using a default class instead of a custom one.
@ -97,7 +97,7 @@ namespace CharClassFunctions
* \param pid The player ID.
* \return Whether the player is using a default class.
*/
EXPORT_APIFUNCTION int CDECL IsClassDefault(unsigned short pid) noexcept;
static int IsClassDefault(unsigned short pid) noexcept;
/**
* \brief Set the default class used by a player.
@ -108,7 +108,7 @@ namespace CharClassFunctions
* \param id The ID of the default class.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetDefaultClass(unsigned short pid, const char *id) noexcept;
static void SetDefaultClass(unsigned short pid, const char *id) noexcept;
/**
* \brief Set the name of the custom class used by a player.
@ -117,7 +117,7 @@ namespace CharClassFunctions
* \param name The name of the custom class.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetClassName(unsigned short pid, const char *name) noexcept;
static void SetClassName(unsigned short pid, const char *name) noexcept;
/**
* \brief Set the description of the custom class used by a player.
@ -126,7 +126,7 @@ namespace CharClassFunctions
* \param desc The description of the custom class.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetClassDesc(unsigned short pid, const char *desc) noexcept;
static void SetClassDesc(unsigned short pid, const char *desc) noexcept;
/**
* \brief Set the ID of one of the two major attributes of the custom class used by a player.
@ -136,7 +136,7 @@ namespace CharClassFunctions
* \param attrId The ID to use for the attribute.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetClassMajorAttribute(unsigned short pid, unsigned char slot, int attrId) noexcept;
static void SetClassMajorAttribute(unsigned short pid, unsigned char slot, int attrId) noexcept;
/**
* \brief Set the specialization of the custom class used by a player.
@ -145,7 +145,7 @@ namespace CharClassFunctions
* \param spec The specialization ID to use (0 for Combat, 1 for Magic, 2 for Stealth).
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetClassSpecialization(unsigned short pid, int spec) noexcept;
static void SetClassSpecialization(unsigned short pid, int spec) noexcept;
/**
* \brief Set the ID of one of the five major skills of the custom class used by a player.
@ -155,7 +155,7 @@ namespace CharClassFunctions
* \param skillId The ID to use for the skill.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetClassMajorSkill(unsigned short pid, unsigned char slot, int skillId) noexcept;
static void SetClassMajorSkill(unsigned short pid, unsigned char slot, int skillId) noexcept;
/**
* \brief Set the ID of one of the five minor skills of the custom class used by a player.
@ -165,7 +165,7 @@ namespace CharClassFunctions
* \param skillId The ID to use for the skill.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetClassMinorSkill(unsigned short pid, unsigned char slot, int skillId) noexcept;
static void SetClassMinorSkill(unsigned short pid, unsigned char slot, int skillId) noexcept;
/**
* \brief Send a PlayerCharClass packet about a player.
@ -175,7 +175,7 @@ namespace CharClassFunctions
* \param pid The player ID.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SendClass(unsigned short pid) noexcept;
}
static void SendClass(unsigned short pid) noexcept;
};
#endif //OPENMW_CHARCLASSAPI_HPP

View file

@ -6,7 +6,7 @@
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
#include <apps/openmw-mp/Networking.hpp>
extern "C" void ChatFunctions::SendMessage(unsigned short pid, const char *message, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
void ChatFunctions::SendMessage(unsigned short 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)
void ChatFunctions::CleanChatForPid(unsigned short pid)
{
Player *player;
GET_PLAYER(pid, player,);
@ -37,7 +37,7 @@ extern "C" void ChatFunctions::CleanChatForPid(unsigned short pid)
packet->Send(false);
}
extern "C" void ChatFunctions::CleanChat()
void ChatFunctions::CleanChat()
{
for (auto player : *Players::getPlayers())
{

View file

@ -3,15 +3,15 @@
#include "../Types.hpp"
#include <Script/Platform.hpp>
#define CHATAPI \
{"SendMessage", ChatFunctions::SendMessage},\
{"CleanChatForPid", ChatFunctions::CleanChat},\
{"CleanChat", ChatFunctions::CleanChatForPid}
namespace ChatFunctions
class ChatFunctions
{
public:
/**
* \brief Send a message to a certain player.
*
@ -23,7 +23,7 @@ namespace ChatFunctions
* to the packet (false by default).
* \return void
*/
EXPORT_APIFUNCTION void CDECL SendMessage(unsigned short pid, const char *message, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
static void SendMessage(unsigned short pid, const char *message, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
/**
* \brief Remove all messages from chat for a certain player.
@ -31,14 +31,14 @@ namespace ChatFunctions
* \param pid The player ID.
* \return void
*/
EXPORT_APIFUNCTION void CDECL CleanChatForPid(unsigned short pid);
static void CleanChatForPid(unsigned short pid);
/**
* \brief Remove all messages from chat for everyone on the server.
*
* \return void
*/
EXPORT_APIFUNCTION void CDECL CleanChat();
}
static void CleanChat();
};
#endif //OPENMW_CHATAPI_HPP

View file

@ -7,7 +7,7 @@
using namespace mwmp;
extern "C" void DialogueFunctions::ClearTopicChanges(unsigned short pid) noexcept
void DialogueFunctions::ClearTopicChanges(unsigned short 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
unsigned int DialogueFunctions::GetTopicChangesSize(unsigned short 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
void DialogueFunctions::AddTopic(unsigned short 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
const char *DialogueFunctions::GetTopicId(unsigned short 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
void DialogueFunctions::SendTopicChanges(unsigned short 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
void DialogueFunctions::PlayAnimation(unsigned short 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
void DialogueFunctions::PlaySpeech(unsigned short pid, const char* sound) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -90,7 +90,7 @@ extern "C" void DialogueFunctions::PlaySpeech(unsigned short pid, const char* so
player->sendToLoaded(packet);
}
extern "C" // All methods below are deprecated versions of methods from above
// All methods below are deprecated versions of methods from above
void DialogueFunctions::InitializeTopicChanges(unsigned short pid) noexcept
{

View file

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

View file

@ -11,7 +11,7 @@ using namespace mwmp;
Faction tempFaction;
const Faction emptyFaction = {};
extern "C" void FactionFunctions::ClearFactionChanges(unsigned short pid) noexcept
void FactionFunctions::ClearFactionChanges(unsigned short 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
unsigned int FactionFunctions::GetFactionChangesSize(unsigned short 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
unsigned char FactionFunctions::GetFactionChangesAction(unsigned short 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
const char *FactionFunctions::GetFactionId(unsigned short 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
int FactionFunctions::GetFactionRank(unsigned short 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
bool FactionFunctions::GetFactionExpulsionState(unsigned short 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
int FactionFunctions::GetFactionReputation(unsigned short 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
void FactionFunctions::SetFactionChangesAction(unsigned short pid, unsigned char action) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -78,27 +78,27 @@ extern "C" void FactionFunctions::SetFactionChangesAction(unsigned short pid, un
player->factionChanges.action = action;
}
extern "C" void FactionFunctions::SetFactionId(const char* factionId) noexcept
void FactionFunctions::SetFactionId(const char* factionId) noexcept
{
tempFaction.factionId = factionId;
}
extern "C" void FactionFunctions::SetFactionRank(unsigned int rank) noexcept
void FactionFunctions::SetFactionRank(unsigned int rank) noexcept
{
tempFaction.rank = rank;
}
extern "C" void FactionFunctions::SetFactionExpulsionState(bool expulsionState) noexcept
void FactionFunctions::SetFactionExpulsionState(bool expulsionState) noexcept
{
tempFaction.isExpelled = expulsionState;
}
extern "C" void FactionFunctions::SetFactionReputation(int reputation) noexcept
void FactionFunctions::SetFactionReputation(int reputation) noexcept
{
tempFaction.reputation = reputation;
}
extern "C" void FactionFunctions::AddFaction(unsigned short pid) noexcept
void FactionFunctions::AddFaction(unsigned short 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
void FactionFunctions::SendFactionChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -122,7 +122,7 @@ extern "C" void FactionFunctions::SendFactionChanges(unsigned short pid, bool se
packet->Send(true);
}
extern "C" // All methods below are deprecated versions of methods from above
// All methods below are deprecated versions of methods from above
void FactionFunctions::InitializeFactionChanges(unsigned short pid) noexcept
{

View file

@ -1,8 +1,6 @@
#ifndef OPENMW_FACTIONAPI_HPP
#define OPENMW_FACTIONAPI_HPP
#include <Script/Platform.hpp>
#define FACTIONAPI \
{"ClearFactionChanges", FactionFunctions::ClearFactionChanges},\
\
@ -26,8 +24,10 @@
\
{"InitializeFactionChanges", FactionFunctions::InitializeFactionChanges}
namespace FactionFunctions
class FactionFunctions
{
public:
/**
* \brief Clear the last recorded faction changes for a player.
*
@ -36,7 +36,7 @@ namespace FactionFunctions
* \param pid The player ID whose faction changes should be used.
* \return void
*/
EXPORT_APIFUNCTION void CDECL ClearFactionChanges(unsigned short pid) noexcept;
static void ClearFactionChanges(unsigned short pid) noexcept;
/**
* \brief Get the number of indexes in a player's latest faction changes.
@ -44,7 +44,7 @@ namespace FactionFunctions
* \param pid The player ID whose faction changes should be used.
* \return The number of indexes.
*/
EXPORT_APIFUNCTION unsigned int CDECL GetFactionChangesSize(unsigned short pid) noexcept;
static unsigned int GetFactionChangesSize(unsigned short pid) noexcept;
/**
* \brief Get the action type used in a player's latest faction changes.
@ -52,7 +52,7 @@ namespace 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).
*/
EXPORT_APIFUNCTION unsigned char CDECL GetFactionChangesAction(unsigned short pid) noexcept;
static unsigned char GetFactionChangesAction(unsigned short pid) noexcept;
/**
* \brief Get the factionId at a certain index in a player's latest faction changes.
@ -61,7 +61,7 @@ namespace FactionFunctions
* \param index The index of the faction.
* \return The factionId.
*/
EXPORT_APIFUNCTION const char *CDECL GetFactionId(unsigned short pid, unsigned int index) noexcept;
static const char *GetFactionId(unsigned short pid, unsigned int index) noexcept;
/**
* \brief Get the rank at a certain index in a player's latest faction changes.
@ -70,7 +70,7 @@ namespace FactionFunctions
* \param index The index of the faction.
* \return The rank.
*/
EXPORT_APIFUNCTION int CDECL GetFactionRank(unsigned short pid, unsigned int index) noexcept;
static int GetFactionRank(unsigned short pid, unsigned int index) noexcept;
/**
* \brief Get the expulsion state at a certain index in a player's latest faction changes.
@ -79,7 +79,7 @@ namespace FactionFunctions
* \param index The index of the faction.
* \return The expulsion state.
*/
EXPORT_APIFUNCTION bool CDECL GetFactionExpulsionState(unsigned short pid, unsigned int index) noexcept;
static bool GetFactionExpulsionState(unsigned short pid, unsigned int index) noexcept;
/**
* \brief Get the reputation at a certain index in a player's latest faction changes.
@ -88,7 +88,7 @@ namespace FactionFunctions
* \param index The index of the faction.
* \return The reputation.
*/
EXPORT_APIFUNCTION int CDECL GetFactionReputation(unsigned short pid, unsigned int index) noexcept;
static int GetFactionReputation(unsigned short pid, unsigned int index) noexcept;
/**
* \brief Set the action type in a player's faction changes.
@ -97,7 +97,7 @@ namespace FactionFunctions
* \param action The action (0 for RANK, 1 for EXPULSION, 2 for REPUTATION).
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetFactionChangesAction(unsigned short pid, unsigned char action) noexcept;
static void SetFactionChangesAction(unsigned short pid, unsigned char action) noexcept;
/**
* \brief Set the factionId of the temporary faction stored on the server.
@ -105,7 +105,7 @@ namespace FactionFunctions
* \param factionId The factionId.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetFactionId(const char* factionId) noexcept;
static void SetFactionId(const char* factionId) noexcept;
/**
* \brief Set the rank of the temporary faction stored on the server.
@ -113,7 +113,7 @@ namespace FactionFunctions
* \param rank The rank.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetFactionRank(unsigned int rank) noexcept;
static void SetFactionRank(unsigned int rank) noexcept;
/**
* \brief Set the expulsion state of the temporary faction stored on the server.
@ -121,7 +121,7 @@ namespace FactionFunctions
* \param expulsionState The expulsion state.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetFactionExpulsionState(bool expulsionState) noexcept;
static void SetFactionExpulsionState(bool expulsionState) noexcept;
/**
* \brief Set the reputation of the temporary faction stored on the server.
@ -129,7 +129,7 @@ namespace FactionFunctions
* \param reputation The reputation.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetFactionReputation(int reputation) noexcept;
static void SetFactionReputation(int reputation) noexcept;
/**
* \brief Add the server's temporary faction to the faction changes for a player.
@ -140,7 +140,7 @@ namespace FactionFunctions
* \param pid The player ID whose faction changes should be used.
* \return void
*/
EXPORT_APIFUNCTION void CDECL AddFaction(unsigned short pid) noexcept;
static void AddFaction(unsigned short pid) noexcept;
/**
* \brief Send a PlayerFaction packet with a player's recorded faction changes.
@ -152,11 +152,12 @@ namespace FactionFunctions
* to the packet (false by default).
* \return void
*/
EXPORT_APIFUNCTION void CDECL SendFactionChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
static void SendFactionChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
// All methods below are deprecated versions of methods from above
EXPORT_APIFUNCTION void CDECL InitializeFactionChanges(unsigned short pid) noexcept;
}
static void InitializeFactionChanges(unsigned short pid) noexcept;
};
#endif //OPENMW_FACTIONAPI_HPP

View file

@ -5,7 +5,7 @@
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
#include <apps/openmw-mp/Networking.hpp>
extern "C" void GUIFunctions::_MessageBox(unsigned short pid, int id, const char *label) noexcept
void GUIFunctions::_MessageBox(unsigned short 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
void GUIFunctions::CustomMessageBox(unsigned short 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
void GUIFunctions::InputDialog(unsigned short 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
void GUIFunctions::PasswordDialog(unsigned short 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)
void GUIFunctions::ListBox(unsigned short 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
void GUIFunctions::ClearQuickKeyChanges(unsigned short 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
unsigned int GUIFunctions::GetQuickKeyChangesSize(unsigned short 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
int GUIFunctions::GetQuickKeySlot(unsigned short 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
int GUIFunctions::GetQuickKeyType(unsigned short 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
const char *GUIFunctions::GetQuickKeyItemId(unsigned short 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
void GUIFunctions::AddQuickKey(unsigned short 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
void GUIFunctions::SendQuickKeyChanges(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -155,17 +155,17 @@ extern "C" void GUIFunctions::SendQuickKeyChanges(unsigned short pid) noexcept
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_QUICKKEYS)->Send(false);
}
extern "C" void GUIFunctions::SetMapVisibility(unsigned short targetPid, unsigned short affectedPid, unsigned short state) noexcept
void GUIFunctions::SetMapVisibility(unsigned short targetPid, unsigned short affectedPid, unsigned short state) noexcept
{
LOG_MESSAGE(Log::LOG_WARN, "stub");
}
extern "C" void GUIFunctions::SetMapVisibilityAll(unsigned short targetPid, unsigned short state) noexcept
void GUIFunctions::SetMapVisibilityAll(unsigned short targetPid, unsigned short state) noexcept
{
LOG_MESSAGE(Log::LOG_WARN, "stub");
}
extern "C" // All methods below are deprecated versions of methods from above
// All methods below are deprecated versions of methods from above
void GUIFunctions::InitializeQuickKeyChanges(unsigned short pid) noexcept
{

View file

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

View file

@ -9,7 +9,7 @@
using namespace mwmp;
extern "C" void ItemFunctions::ClearInventoryChanges(unsigned short pid) noexcept
void ItemFunctions::ClearInventoryChanges(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -17,12 +17,12 @@ extern "C" void ItemFunctions::ClearInventoryChanges(unsigned short pid) noexcep
player->inventoryChanges.items.clear();
}
extern "C" int ItemFunctions::GetEquipmentSize() noexcept
int ItemFunctions::GetEquipmentSize() noexcept
{
return MWWorld::InventoryStore::Slots;
}
extern "C" unsigned int ItemFunctions::GetInventoryChangesSize(unsigned short pid) noexcept
unsigned int ItemFunctions::GetInventoryChangesSize(unsigned short 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
unsigned int ItemFunctions::GetInventoryChangesAction(unsigned short 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
void ItemFunctions::SetInventoryChangesAction(unsigned short 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,
void ItemFunctions::EquipItem(unsigned short 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
void ItemFunctions::UnequipItem(unsigned short 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,
void ItemFunctions::AddItemChange(unsigned short 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)
bool ItemFunctions::HasItemEquipped(unsigned short 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
const char *ItemFunctions::GetEquipmentItemRefId(unsigned short 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
int ItemFunctions::GetEquipmentItemCount(unsigned short 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
int ItemFunctions::GetEquipmentItemCharge(unsigned short 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
double ItemFunctions::GetEquipmentItemEnchantmentCharge(unsigned short 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
const char *ItemFunctions::GetInventoryItemRefId(unsigned short 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
int ItemFunctions::GetInventoryItemCount(unsigned short 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
int ItemFunctions::GetInventoryItemCharge(unsigned short 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
double ItemFunctions::GetInventoryItemEnchantmentCharge(unsigned short 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
const char *ItemFunctions::GetInventoryItemSoul(unsigned short 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
const char *ItemFunctions::GetUsedItemRefId(unsigned short 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
int ItemFunctions::GetUsedItemCount(unsigned short 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
int ItemFunctions::GetUsedItemCharge(unsigned short 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
double ItemFunctions::GetUsedItemEnchantmentCharge(unsigned short 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
const char *ItemFunctions::GetUsedItemSoul(unsigned short 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
void ItemFunctions::SendEquipment(unsigned short 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
void ItemFunctions::SendInventoryChanges(unsigned short 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
void ItemFunctions::SendItemUse(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -253,14 +253,14 @@ extern "C" void ItemFunctions::SendItemUse(unsigned short pid) noexcept
packet->Send(false);
}
extern "C" // All methods below are deprecated versions of methods from above
// All methods below are deprecated versions of methods from above
void ItemFunctions::InitializeInventoryChanges(unsigned short pid) noexcept
{
ClearInventoryChanges(pid);
}
extern "C" void ItemFunctions::AddItem(unsigned short pid, const char* refId, unsigned int count, int charge,
void ItemFunctions::AddItem(unsigned short pid, const char* refId, unsigned int count, int charge,
double enchantmentCharge, const char* soul) noexcept
{
AddItemChange(pid, refId, count, charge, enchantmentCharge, soul);

View file

@ -1,8 +1,6 @@
#ifndef OPENMW_ITEMAPI_HPP
#define OPENMW_ITEMAPI_HPP
#include <Script/Platform.hpp>
#define ITEMAPI \
{"ClearInventoryChanges", ItemFunctions::ClearInventoryChanges},\
\
@ -43,8 +41,10 @@
{"InitializeInventoryChanges", ItemFunctions::InitializeInventoryChanges},\
{"AddItem", ItemFunctions::AddItem}
namespace ItemFunctions
class ItemFunctions
{
public:
/**
* \brief Clear the last recorded inventory changes for a player.
*
@ -53,7 +53,7 @@ namespace ItemFunctions
* \param pid The player ID whose inventory changes should be used.
* \return void
*/
EXPORT_APIFUNCTION void CDECL ClearInventoryChanges(unsigned short pid) noexcept;
static void ClearInventoryChanges(unsigned short pid) noexcept;
/**
* \brief Get the number of slots used for equipment.
@ -62,7 +62,7 @@ namespace ItemFunctions
*
* \return The number of slots.
*/
EXPORT_APIFUNCTION int CDECL GetEquipmentSize() noexcept;
static int GetEquipmentSize() noexcept;
/**
* \brief Get the number of indexes in a player's latest inventory changes.
@ -70,7 +70,7 @@ namespace ItemFunctions
* \param pid The player ID whose inventory changes should be used.
* \return The number of indexes.
*/
EXPORT_APIFUNCTION unsigned int CDECL GetInventoryChangesSize(unsigned short pid) noexcept;
static unsigned int GetInventoryChangesSize(unsigned short pid) noexcept;
/**
* \brief Get the action type used in a player's latest inventory changes.
@ -78,7 +78,7 @@ namespace 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).
*/
EXPORT_APIFUNCTION unsigned int CDECL GetInventoryChangesAction(unsigned short pid) noexcept;
static unsigned int GetInventoryChangesAction(unsigned short pid) noexcept;
/**
* \brief Set the action type in a player's inventory changes.
@ -87,7 +87,7 @@ namespace ItemFunctions
* \param action The action (0 for SET, 1 for ADD, 2 for REMOVE).
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetInventoryChangesAction(unsigned short pid, unsigned char action) noexcept;
static void SetInventoryChangesAction(unsigned short pid, unsigned char action) noexcept;
/**
* \brief Equip an item in a certain slot of the equipment of a player.
@ -100,7 +100,7 @@ namespace ItemFunctions
* \param enchantmentCharge The enchantment charge of the item.
* \return void
*/
EXPORT_APIFUNCTION void CDECL EquipItem(unsigned short pid, unsigned short slot, const char* refId, unsigned int count, int charge,
static void EquipItem(unsigned short pid, unsigned short slot, const char* refId, unsigned int count, int charge,
double enchantmentCharge = -1) noexcept;
/**
@ -110,7 +110,7 @@ namespace ItemFunctions
* \param slot The equipment slot.
* \return void
*/
EXPORT_APIFUNCTION void CDECL UnequipItem(unsigned short pid, unsigned short slot) noexcept;
static void UnequipItem(unsigned short pid, unsigned short slot) noexcept;
/**
* \brief Add an item change to a player's inventory changes.
@ -123,7 +123,7 @@ namespace ItemFunctions
* \param soul The soul of the item.
* \return void
*/
EXPORT_APIFUNCTION void CDECL AddItemChange(unsigned short pid, const char* refId, unsigned int count, int charge,
static void AddItemChange(unsigned short pid, const char* refId, unsigned int count, int charge,
double enchantmentCharge, const char* soul) noexcept;
/**
@ -133,7 +133,7 @@ namespace ItemFunctions
* \param refId The refId of the item.
* \return Whether the player has the item equipped.
*/
EXPORT_APIFUNCTION bool CDECL HasItemEquipped(unsigned short pid, const char* refId);
static bool HasItemEquipped(unsigned short pid, const char* refId);
/**
* \brief Get the refId of the item in a certain slot of the equipment of a player.
@ -142,7 +142,7 @@ namespace ItemFunctions
* \param slot The slot of the equipment item.
* \return The refId.
*/
EXPORT_APIFUNCTION const char *CDECL GetEquipmentItemRefId(unsigned short pid, unsigned short slot) noexcept;
static const char *GetEquipmentItemRefId(unsigned short pid, unsigned short slot) noexcept;
/**
* \brief Get the count of the item in a certain slot of the equipment of a player.
@ -151,7 +151,7 @@ namespace ItemFunctions
* \param slot The slot of the equipment item.
* \return The item count.
*/
EXPORT_APIFUNCTION int CDECL GetEquipmentItemCount(unsigned short pid, unsigned short slot) noexcept;
static int GetEquipmentItemCount(unsigned short pid, unsigned short slot) noexcept;
/**
* \brief Get the charge of the item in a certain slot of the equipment of a player.
@ -160,7 +160,7 @@ namespace ItemFunctions
* \param slot The slot of the equipment item.
* \return The charge.
*/
EXPORT_APIFUNCTION int CDECL GetEquipmentItemCharge(unsigned short pid, unsigned short slot) noexcept;
static int GetEquipmentItemCharge(unsigned short pid, unsigned short slot) noexcept;
/**
* \brief Get the enchantment charge of the item in a certain slot of the equipment of
@ -170,7 +170,7 @@ namespace ItemFunctions
* \param slot The slot of the equipment item.
* \return The enchantment charge.
*/
EXPORT_APIFUNCTION double CDECL GetEquipmentItemEnchantmentCharge(unsigned short pid, unsigned short slot) noexcept;
static double GetEquipmentItemEnchantmentCharge(unsigned short pid, unsigned short slot) noexcept;
/**
* \brief Get the refId of the item at a certain index in a player's latest inventory
@ -180,7 +180,7 @@ namespace ItemFunctions
* \param index The index of the inventory item.
* \return The refId.
*/
EXPORT_APIFUNCTION const char *CDECL GetInventoryItemRefId(unsigned short pid, unsigned int index) noexcept;
static const char *GetInventoryItemRefId(unsigned short pid, unsigned int index) noexcept;
/**
* \brief Get the count of the item at a certain index in a player's latest inventory
@ -190,7 +190,7 @@ namespace ItemFunctions
* \param index The index of the inventory item.
* \return The item count.
*/
EXPORT_APIFUNCTION int CDECL GetInventoryItemCount(unsigned short pid, unsigned int index) noexcept;
static int GetInventoryItemCount(unsigned short pid, unsigned int index) noexcept;
/**
* \brief Get the charge of the item at a certain index in a player's latest inventory
@ -200,7 +200,7 @@ namespace ItemFunctions
* \param index The index of the inventory item.
* \return The charge.
*/
EXPORT_APIFUNCTION int CDECL GetInventoryItemCharge(unsigned short pid, unsigned int index) noexcept;
static int GetInventoryItemCharge(unsigned short pid, unsigned int index) noexcept;
/**
* \brief Get the enchantment charge of the item at a certain index in a player's
@ -210,7 +210,7 @@ namespace ItemFunctions
* \param index The index of the inventory item.
* \return The enchantment charge.
*/
EXPORT_APIFUNCTION double CDECL GetInventoryItemEnchantmentCharge(unsigned short pid, unsigned int index) noexcept;
static double GetInventoryItemEnchantmentCharge(unsigned short pid, unsigned int index) noexcept;
/**
* \brief Get the soul of the item at a certain index in a player's latest inventory
@ -220,7 +220,7 @@ namespace ItemFunctions
* \param index The index of the inventory item.
* \return The soul.
*/
EXPORT_APIFUNCTION const char *CDECL GetInventoryItemSoul(unsigned short pid, unsigned int index) noexcept;
static const char *GetInventoryItemSoul(unsigned short pid, unsigned int index) noexcept;
/**
* \brief Get the refId of the item last used by a player.
@ -228,7 +228,7 @@ namespace ItemFunctions
* \param pid The player ID.
* \return The refId.
*/
EXPORT_APIFUNCTION const char *CDECL GetUsedItemRefId(unsigned short pid) noexcept;
static const char *GetUsedItemRefId(unsigned short pid) noexcept;
/**
* \brief Get the count of the item last used by a player.
@ -236,7 +236,7 @@ namespace ItemFunctions
* \param pid The player ID.
* \return The item count.
*/
EXPORT_APIFUNCTION int CDECL GetUsedItemCount(unsigned short pid) noexcept;
static int GetUsedItemCount(unsigned short pid) noexcept;
/**
* \brief Get the charge of the item last used by a player.
@ -244,7 +244,7 @@ namespace ItemFunctions
* \param pid The player ID.
* \return The charge.
*/
EXPORT_APIFUNCTION int CDECL GetUsedItemCharge(unsigned short pid) noexcept;
static int GetUsedItemCharge(unsigned short pid) noexcept;
/**
* \brief Get the enchantment charge of the item last used by a player.
@ -252,7 +252,7 @@ namespace ItemFunctions
* \param pid The player ID.
* \return The enchantment charge.
*/
EXPORT_APIFUNCTION double CDECL GetUsedItemEnchantmentCharge(unsigned short pid) noexcept;
static double GetUsedItemEnchantmentCharge(unsigned short pid) noexcept;
/**
* \brief Get the soul of the item last used by a player.
@ -260,7 +260,7 @@ namespace ItemFunctions
* \param pid The player ID.
* \return The soul.
*/
EXPORT_APIFUNCTION const char *CDECL GetUsedItemSoul(unsigned short pid) noexcept;
static const char *GetUsedItemSoul(unsigned short pid) noexcept;
/**
* \brief Send a PlayerEquipment packet with a player's equipment.
@ -270,7 +270,7 @@ namespace ItemFunctions
* \param pid The player ID whose equipment should be sent.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SendEquipment(unsigned short pid) noexcept;
static void SendEquipment(unsigned short pid) noexcept;
/**
* \brief Send a PlayerInventory packet with a player's recorded inventory changes.
@ -282,7 +282,7 @@ namespace ItemFunctions
* to the packet (false by default).
* \return void
*/
EXPORT_APIFUNCTION void CDECL SendInventoryChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
static void SendInventoryChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
/**
* \brief Send a PlayerItemUse causing a player to use their recorded usedItem.
@ -290,14 +290,17 @@ namespace ItemFunctions
* \param pid The player ID affected.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SendItemUse(unsigned short pid) noexcept;
static void SendItemUse(unsigned short pid) noexcept;
// All methods below are deprecated versions of methods from above
EXPORT_APIFUNCTION void CDECL InitializeInventoryChanges(unsigned short pid) noexcept;
static void InitializeInventoryChanges(unsigned short pid) noexcept;
EXPORT_APIFUNCTION void CDECL AddItem(unsigned short pid, const char* refId, unsigned int count, int charge,
static void AddItem(unsigned short pid, const char* refId, unsigned int count, int charge,
double enchantmentCharge, const char* soul) noexcept;
}
private:
};
#endif //OPENMW_ITEMAPI_HPP

View file

@ -11,7 +11,7 @@ using namespace std;
static std::string tempCellDescription;
extern "C" unsigned char MechanicsFunctions::GetMiscellaneousChangeType(unsigned short pid) noexcept
unsigned char MechanicsFunctions::GetMiscellaneousChangeType(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -19,16 +19,16 @@ extern "C" unsigned char MechanicsFunctions::GetMiscellaneousChangeType(unsigned
return player->miscellaneousChangeType;
}
extern "C" const char *MechanicsFunctions::GetMarkCell(unsigned short pid) noexcept
const char *MechanicsFunctions::GetMarkCell(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
tempCellDescription = player->cell.getDescription();
tempCellDescription = player->cell.getDescription().c_str();
return tempCellDescription.c_str();
}
extern "C" double MechanicsFunctions::GetMarkPosX(unsigned short pid) noexcept
double MechanicsFunctions::GetMarkPosX(unsigned short 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
double MechanicsFunctions::GetMarkPosY(unsigned short 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
double MechanicsFunctions::GetMarkPosZ(unsigned short 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
double MechanicsFunctions::GetMarkRotX(unsigned short 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
double MechanicsFunctions::GetMarkRotZ(unsigned short 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
bool MechanicsFunctions::DoesPlayerHavePlayerKiller(unsigned short 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
int MechanicsFunctions::GetPlayerKillerPid(unsigned short 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
const char *MechanicsFunctions::GetPlayerKillerRefId(unsigned short 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
unsigned int MechanicsFunctions::GetPlayerKillerRefNum(unsigned short 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
unsigned int MechanicsFunctions::GetPlayerKillerMpNum(unsigned short 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
const char *MechanicsFunctions::GetPlayerKillerName(unsigned short 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
const char *MechanicsFunctions::GetSelectedSpellId(unsigned short 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
unsigned int MechanicsFunctions::GetDrawState(unsigned short 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
bool MechanicsFunctions::GetSneakState(unsigned short 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
void MechanicsFunctions::SetMarkCell(unsigned short 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
void MechanicsFunctions::SetMarkPos(unsigned short 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
void MechanicsFunctions::SetMarkRot(unsigned short 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
void MechanicsFunctions::SetSelectedSpellId(unsigned short 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)
void MechanicsFunctions::SendMarkLocation(unsigned short 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)
void MechanicsFunctions::SendSelectedSpell(unsigned short 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,
void MechanicsFunctions::Jail(unsigned short 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
void MechanicsFunctions::Resurrect(unsigned short 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
const char *MechanicsFunctions::GetDeathReason(unsigned short 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
unsigned int MechanicsFunctions::GetPlayerKillerRefNumIndex(unsigned short pid) noexcept
{
return GetPlayerKillerRefNum(pid);
}

View file

@ -3,8 +3,6 @@
#include "../Types.hpp"
#include <Script/Platform.hpp>
#define MECHANICSAPI \
{"GetMiscellaneousChangeType", MechanicsFunctions::GetMiscellaneousChangeType},\
\
@ -40,15 +38,17 @@
{"GetDeathReason", MechanicsFunctions::GetDeathReason},\
{"GetPlayerKillerRefNumIndex", MechanicsFunctions::GetPlayerKillerRefNumIndex}
namespace MechanicsFunctions
class MechanicsFunctions
{
public:
/**
* \brief Get the type of a PlayerMiscellaneous packet.
*
* \param pid The player ID.
* \return The type.
*/
EXPORT_APIFUNCTION unsigned char CDECL GetMiscellaneousChangeType(unsigned short pid) noexcept;
static unsigned char GetMiscellaneousChangeType(unsigned short pid) noexcept;
/**
* \brief Get the cell description of a player's Mark cell.
@ -56,7 +56,7 @@ namespace MechanicsFunctions
* \param pid The player ID.
* \return The cell description.
*/
EXPORT_APIFUNCTION const char *CDECL GetMarkCell(unsigned short pid) noexcept;
static const char *GetMarkCell(unsigned short pid) noexcept;
/**
* \brief Get the X position of a player's Mark.
@ -64,7 +64,7 @@ namespace MechanicsFunctions
* \param pid The player ID.
* \return The X position.
*/
EXPORT_APIFUNCTION double CDECL GetMarkPosX(unsigned short pid) noexcept;
static double GetMarkPosX(unsigned short pid) noexcept;
/**
* \brief Get the Y position of a player's Mark.
@ -72,7 +72,7 @@ namespace MechanicsFunctions
* \param pid The player ID.
* \return The Y position.
*/
EXPORT_APIFUNCTION double CDECL GetMarkPosY(unsigned short pid) noexcept;
static double GetMarkPosY(unsigned short pid) noexcept;
/**
* \brief Get the Z position of a player's Mark.
@ -80,7 +80,7 @@ namespace MechanicsFunctions
* \param pid The player ID.
* \return The Z position.
*/
EXPORT_APIFUNCTION double CDECL GetMarkPosZ(unsigned short pid) noexcept;
static double GetMarkPosZ(unsigned short pid) noexcept;
/**
* \brief Get the X rotation of a player's Mark.
@ -88,7 +88,7 @@ namespace MechanicsFunctions
* \param pid The player ID.
* \return The X rotation.
*/
EXPORT_APIFUNCTION double CDECL GetMarkRotX(unsigned short pid) noexcept;
static double GetMarkRotX(unsigned short pid) noexcept;
/**
* \brief Get the Z rotation of a player's Mark.
@ -96,7 +96,7 @@ namespace MechanicsFunctions
* \param pid The player ID.
* \return The X rotation.
*/
EXPORT_APIFUNCTION double CDECL GetMarkRotZ(unsigned short pid) noexcept;
static double GetMarkRotZ(unsigned short pid) noexcept;
/**
* \brief Get the ID of a player's selected spell.
@ -104,7 +104,7 @@ namespace MechanicsFunctions
* \param pid The player ID.
* \return The spell ID.
*/
EXPORT_APIFUNCTION const char *CDECL GetSelectedSpellId(unsigned short pid) noexcept;
static const char *GetSelectedSpellId(unsigned short pid) noexcept;
/**
* \brief Check whether the killer of a certain player is also a player.
@ -112,7 +112,7 @@ namespace MechanicsFunctions
* \param pid The player ID of the killed player.
* \return Whether the player was killed by another player.
*/
EXPORT_APIFUNCTION bool CDECL DoesPlayerHavePlayerKiller(unsigned short pid) noexcept;
static bool DoesPlayerHavePlayerKiller(unsigned short pid) noexcept;
/**
* \brief Get the player ID of the killer of a certain player.
@ -120,7 +120,7 @@ namespace MechanicsFunctions
* \param pid The player ID of the killed player.
* \return The player ID of the killer.
*/
EXPORT_APIFUNCTION int CDECL GetPlayerKillerPid(unsigned short pid) noexcept;
static int GetPlayerKillerPid(unsigned short pid) noexcept;
/**
* \brief Get the refId of the actor killer of a certain player.
@ -128,7 +128,7 @@ namespace MechanicsFunctions
* \param pid The player ID of the killed player.
* \return The refId of the killer.
*/
EXPORT_APIFUNCTION const char *CDECL GetPlayerKillerRefId(unsigned short pid) noexcept;
static const char *GetPlayerKillerRefId(unsigned short pid) noexcept;
/**
* \brief Get the refNum of the actor killer of a certain player.
@ -136,7 +136,7 @@ namespace MechanicsFunctions
* \param pid The player ID of the killed player.
* \return The refNum of the killer.
*/
EXPORT_APIFUNCTION unsigned int CDECL GetPlayerKillerRefNum(unsigned short pid) noexcept;
static unsigned int GetPlayerKillerRefNum(unsigned short pid) noexcept;
/**
* \brief Get the mpNum of the actor killer of a certain player.
@ -144,7 +144,7 @@ namespace MechanicsFunctions
* \param pid The player ID of the killed player.
* \return The mpNum of the killer.
*/
EXPORT_APIFUNCTION unsigned int CDECL GetPlayerKillerMpNum(unsigned short pid) noexcept;
static unsigned int GetPlayerKillerMpNum(unsigned short pid) noexcept;
/**
* \brief Get the name of the actor killer of a certain player.
@ -152,7 +152,7 @@ namespace MechanicsFunctions
* \param pid The player ID of the killed player.
* \return The name of the killer.
*/
EXPORT_APIFUNCTION const char *CDECL GetPlayerKillerName(unsigned short pid) noexcept;
static const char *GetPlayerKillerName(unsigned short pid) noexcept;
/**
* \brief Get the draw state of a player (0 for nothing, 1 for drawn weapon,
@ -161,7 +161,7 @@ namespace MechanicsFunctions
* \param pid The player ID.
* \return The draw state.
*/
EXPORT_APIFUNCTION unsigned int CDECL GetDrawState(unsigned short pid) noexcept;
static unsigned int GetDrawState(unsigned short pid) noexcept;
/**
* \brief Get the sneak state of a player.
@ -169,7 +169,7 @@ namespace MechanicsFunctions
* \param pid The player ID.
* \return Whether the player is sneaking.
*/
EXPORT_APIFUNCTION bool CDECL GetSneakState(unsigned short pid) noexcept;
static bool GetSneakState(unsigned short pid) noexcept;
/**
* \brief Set the Mark cell of a player.
@ -184,7 +184,7 @@ namespace MechanicsFunctions
* \param cellDescription The cell description.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetMarkCell(unsigned short pid, const char *cellDescription) noexcept;
static void SetMarkCell(unsigned short pid, const char *cellDescription) noexcept;
/**
* \brief Set the Mark position of a player.
@ -198,7 +198,7 @@ namespace MechanicsFunctions
* \param z The Z position.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetMarkPos(unsigned short pid, double x, double y, double z) noexcept;
static void SetMarkPos(unsigned short pid, double x, double y, double z) noexcept;
/**
* \brief Set the Mark rotation of a player.
@ -211,7 +211,7 @@ namespace MechanicsFunctions
* \param z The Z rotation.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetMarkRot(unsigned short pid, double x, double z) noexcept;
static void SetMarkRot(unsigned short pid, double x, double z) noexcept;
/**
* \brief Set the ID of a player's selected spell.
@ -223,7 +223,7 @@ namespace MechanicsFunctions
* \param spellId The spell ID.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetSelectedSpellId(unsigned short pid, const char *spellId) noexcept;
static void SetSelectedSpellId(unsigned short pid, const char *spellId) noexcept;
/**
* \brief Send a PlayerMiscellaneous packet with a Mark location to a player.
@ -231,7 +231,7 @@ namespace MechanicsFunctions
* \param pid The player ID.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SendMarkLocation(unsigned short pid);
static void SendMarkLocation(unsigned short pid);
/**
* \brief Send a PlayerMiscellaneous packet with a selected spell ID to a player.
@ -239,7 +239,7 @@ namespace MechanicsFunctions
* \param pid The player ID.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SendSelectedSpell(unsigned short pid);
static void SendSelectedSpell(unsigned short pid);
/**
* \brief Send a PlayerJail packet about a player.
@ -261,7 +261,7 @@ namespace MechanicsFunctions
* \param jailEndText The text that should be displayed once the jailing period is over.
* \return void
*/
EXPORT_APIFUNCTION void CDECL Jail(unsigned short pid, int jailDays, bool ignoreJailTeleportation, bool ignoreJailSkillIncreases,
static void Jail(unsigned short pid, int jailDays, bool ignoreJailTeleportation, bool ignoreJailSkillIncreases,
const char* jailProgressText, const char* jailEndText) noexcept;
/**
@ -274,12 +274,13 @@ namespace MechanicsFunctions
* 2 for TRIBUNAL_TEMPLE).
* \return void
*/
EXPORT_APIFUNCTION void CDECL Resurrect(unsigned short pid, unsigned int type) noexcept;
static void Resurrect(unsigned short pid, unsigned int type) noexcept;
// All methods below are deprecated versions of methods from above
EXPORT_APIFUNCTION const char *CDECL GetDeathReason(unsigned short pid) noexcept;
EXPORT_APIFUNCTION unsigned int CDECL GetPlayerKillerRefNumIndex(unsigned short pid) noexcept;
}
static const char *GetDeathReason(unsigned short pid) noexcept;
static unsigned int GetPlayerKillerRefNumIndex(unsigned short pid) noexcept;
};
#endif //OPENMW_MECHANICSAPI_HPP

View file

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

View file

@ -3,42 +3,15 @@
#include "../Types.hpp"
#include <Script/Platform.hpp>
#define MISCELLANEOUSAPI \
{"DoesFileExist", MiscellaneousFunctions::DoesFileExist},\
{"GetCaseInsensitiveFilename", MiscellaneousFunctions::GetCaseInsensitiveFilename},\
\
{"GetLastPlayerId", MiscellaneousFunctions::GetLastPlayerId},\
\
{"GetCurrentMpNum", MiscellaneousFunctions::GetCurrentMpNum},\
{"SetCurrentMpNum", MiscellaneousFunctions::SetCurrentMpNum},\
\
{"LogMessage", MiscellaneousFunctions::LogMessage},\
{"LogAppend", MiscellaneousFunctions::LogAppend}
{"SetCurrentMpNum", MiscellaneousFunctions::SetCurrentMpNum}
namespace MiscellaneousFunctions
class MiscellaneousFunctions
{
/**
* \brief Check whether a certain file exists.
*
* This will be a case sensitive check on case sensitive filesystems.
*
* Whenever you want to enforce case insensitivity, use GetCaseInsensitiveFilename() instead.
*
* \return Whether the file exists or not.
*/
EXPORT_APIFUNCTION bool CDECL DoesFileExist(const char *filePath) noexcept;
/**
* \brief Get the first filename in a folder that has a case insensitive match with the filename
* argument.
*
* This is used to retain case insensitivity when opening data files on Linux.
*
* \return The filename that matches.
*/
EXPORT_APIFUNCTION const char *CDECL GetCaseInsensitiveFilename(const char *folderPath, const char *filename) noexcept;
public:
/**
* \brief Get the last player ID currently connected to the server.
@ -48,7 +21,7 @@ namespace MiscellaneousFunctions
*
* \return The player ID.
*/
EXPORT_APIFUNCTION unsigned int CDECL GetLastPlayerId() noexcept;
static unsigned int GetLastPlayerId() noexcept;
/**
* \brief Get the current (latest) mpNum generated by the server.
@ -62,7 +35,7 @@ namespace MiscellaneousFunctions
*
* \return The mpNum.
*/
EXPORT_APIFUNCTION int CDECL GetCurrentMpNum() noexcept;
static int GetCurrentMpNum() noexcept;
/**
* \brief Set the current (latest) mpNum generated by the server.
@ -74,31 +47,7 @@ namespace MiscellaneousFunctions
* \param mpNum The number that should be used as the new current mpNum.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetCurrentMpNum(int mpNum) noexcept;
/**
* \brief Write a log message with its own timestamp.
*
* It will have "[Script]:" prepended to it so as to mark it as a script-generated log message.
*
* \param level The logging level used (0 for LOG_VERBOSE, 1 for LOG_INFO, 2 for LOG_WARN,
* 3 for LOG_ERROR, 4 for LOG_FATAL).
* \param message The message logged.
* \return void
*/
EXPORT_APIFUNCTION void CDECL LogMessage(unsigned short level, const char *message) noexcept;
/**
* \brief Write a log message without its own timestamp.
*
* It will have "[Script]:" prepended to it so as to mark it as a script-generated log message.
*
* \param level The logging level used (0 for LOG_VERBOSE, 1 for LOG_INFO, 2 for LOG_WARN,
* 3 for LOG_ERROR, 4 for LOG_FATAL).
* \param message The message logged.
* \return void
*/
EXPORT_APIFUNCTION void CDECL LogAppend(unsigned short level, const char *message) noexcept;
}
static void SetCurrentMpNum(int mpNum) noexcept;
};
#endif //OPENMW_MISCELLANEOUSAPI_HPP

View file

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

View file

@ -1,8 +1,6 @@
#ifndef OPENMW_OBJECTAPI_HPP
#define OPENMW_OBJECTAPI_HPP
#include <Script/Platform.hpp>
#define OBJECTAPI \
{"ReadReceivedObjectList", ObjectFunctions::ReadReceivedObjectList},\
\
@ -138,21 +136,23 @@
{"SetObjectRefNumIndex", ObjectFunctions::SetObjectRefNumIndex},\
{"AddWorldObject", ObjectFunctions::AddWorldObject}
namespace ObjectFunctions
class ObjectFunctions
{
public:
/**
* \brief Use the last object list received by the server as the one being read.
*
* \return void
*/
EXPORT_APIFUNCTION void CDECL ReadReceivedObjectList() noexcept;
static void ReadReceivedObjectList() noexcept;
/**
* \brief Clear the data from the object list stored on the server.
*
* \return void
*/
EXPORT_APIFUNCTION void CDECL ClearObjectList() noexcept;
static void ClearObjectList() noexcept;
/**
* \brief Set the pid attached to the ObjectList.
@ -160,7 +160,7 @@ namespace ObjectFunctions
* \param pid The player ID to whom the object list should be attached.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetObjectListPid(unsigned short pid) noexcept;
static void SetObjectListPid(unsigned short pid) noexcept;
/**
* \brief Take the contents of the read-only object list last received by the
@ -169,14 +169,14 @@ namespace ObjectFunctions
*
* \return void
*/
EXPORT_APIFUNCTION void CDECL CopyReceivedObjectListToStore() noexcept;
static void CopyReceivedObjectListToStore() noexcept;
/**
* \brief Get the number of indexes in the read object list.
*
* \return The number of indexes.
*/
EXPORT_APIFUNCTION unsigned int CDECL GetObjectListSize() noexcept;
static unsigned int GetObjectListSize() noexcept;
/**
* \brief Get the origin of the read object list.
@ -185,7 +185,7 @@ namespace ObjectFunctions
* CLIENT_DIALOGUE, 3 for CLIENT_SCRIPT_LOCAL, 4 for CLIENT_SCRIPT_GLOBAL,
* 5 for SERVER_SCRIPT).
*/
EXPORT_APIFUNCTION unsigned char CDECL GetObjectListOrigin() noexcept;
static unsigned char GetObjectListOrigin() noexcept;
/**
* \brief Get the client script that the read object list originated from.
@ -194,21 +194,21 @@ namespace ObjectFunctions
*
* \return The ID of the client script.
*/
EXPORT_APIFUNCTION const char *CDECL GetObjectListClientScript() noexcept;
static const char *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).
*/
EXPORT_APIFUNCTION unsigned char CDECL GetObjectListAction() noexcept;
static unsigned char 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).
*/
EXPORT_APIFUNCTION unsigned char CDECL GetObjectListContainerSubAction() noexcept;
static unsigned char GetObjectListContainerSubAction() noexcept;
/**
* \brief Check whether the object at a certain index in the read object list is a
@ -221,7 +221,7 @@ namespace ObjectFunctions
* \param index The index of the object.
* \return Whether the object is a player.
*/
EXPORT_APIFUNCTION bool CDECL IsObjectPlayer(unsigned int index) noexcept;
static bool IsObjectPlayer(unsigned int index) noexcept;
/**
* \brief Get the player ID of the object at a certain index in the read object list,
@ -233,7 +233,7 @@ namespace ObjectFunctions
* \param index The index of the object.
* \return The player ID of the object.
*/
EXPORT_APIFUNCTION int CDECL GetObjectPid(unsigned int index) noexcept;
static int GetObjectPid(unsigned int index) noexcept;
/**
* \brief Get the refId of the object at a certain index in the read object list.
@ -241,7 +241,7 @@ namespace ObjectFunctions
* \param index The index of the object.
* \return The refId.
*/
EXPORT_APIFUNCTION const char *CDECL GetObjectRefId(unsigned int index) noexcept;
static const char *GetObjectRefId(unsigned int index) noexcept;
/**
* \brief Get the refNum of the object at a certain index in the read object list.
@ -249,7 +249,7 @@ namespace ObjectFunctions
* \param index The index of the object.
* \return The refNum.
*/
EXPORT_APIFUNCTION unsigned int CDECL GetObjectRefNum(unsigned int index) noexcept;
static unsigned int GetObjectRefNum(unsigned int index) noexcept;
/**
* \brief Get the mpNum of the object at a certain index in the read object list.
@ -257,7 +257,7 @@ namespace ObjectFunctions
* \param index The index of the object.
* \return The mpNum.
*/
EXPORT_APIFUNCTION unsigned int CDECL GetObjectMpNum(unsigned int index) noexcept;
static unsigned int GetObjectMpNum(unsigned int index) noexcept;
/**
* \brief Get the count of the object at a certain index in the read object list.
@ -265,7 +265,7 @@ namespace ObjectFunctions
* \param index The index of the object.
* \return The object count.
*/
EXPORT_APIFUNCTION int CDECL GetObjectCount(unsigned int index) noexcept;
static int GetObjectCount(unsigned int index) noexcept;
/**
* \brief Get the charge of the object at a certain index in the read object list.
@ -273,7 +273,7 @@ namespace ObjectFunctions
* \param index The index of the object.
* \return The charge.
*/
EXPORT_APIFUNCTION int CDECL GetObjectCharge(unsigned int index) noexcept;
static int GetObjectCharge(unsigned int index) noexcept;
/**
* \brief Get the enchantment charge of the object at a certain index in the read object list.
@ -281,7 +281,7 @@ namespace ObjectFunctions
* \param index The index of the object.
* \return The enchantment charge.
*/
EXPORT_APIFUNCTION double CDECL GetObjectEnchantmentCharge(unsigned int index) noexcept;
static double GetObjectEnchantmentCharge(unsigned int index) noexcept;
/**
* \brief Get the soul of the object at a certain index in the read object list.
@ -289,7 +289,7 @@ namespace ObjectFunctions
* \param index The index of the object.
* \return The soul.
*/
EXPORT_APIFUNCTION const char *CDECL GetObjectSoul(unsigned int index) noexcept;
static const char *GetObjectSoul(unsigned int index) noexcept;
/**
* \brief Get the gold value of the object at a certain index in the read object list.
@ -299,7 +299,7 @@ namespace ObjectFunctions
* \param index The index of the object.
* \return The gold value.
*/
EXPORT_APIFUNCTION int CDECL GetObjectGoldValue(unsigned int index) noexcept;
static int GetObjectGoldValue(unsigned int index) noexcept;
/**
* \brief Get the object scale of the object at a certain index in the read object list.
@ -307,7 +307,7 @@ namespace ObjectFunctions
* \param index The index of the object.
* \return The object scale.
*/
EXPORT_APIFUNCTION double CDECL GetObjectScale(unsigned int index) noexcept;
static double GetObjectScale(unsigned int index) noexcept;
/**
* \brief Get the object state of the object at a certain index in the read object list.
@ -315,7 +315,7 @@ namespace ObjectFunctions
* \param index The index of the object.
* \return The object state.
*/
EXPORT_APIFUNCTION bool CDECL GetObjectState(unsigned int index) noexcept;
static bool GetObjectState(unsigned int index) noexcept;
/**
* \brief Get the door state of the object at a certain index in the read object list.
@ -323,7 +323,7 @@ namespace ObjectFunctions
* \param index The index of the object.
* \return The door state.
*/
EXPORT_APIFUNCTION int CDECL GetObjectDoorState(unsigned int index) noexcept;
static int GetObjectDoorState(unsigned int index) noexcept;
/**
* \brief Get the lock level of the object at a certain index in the read object list.
@ -331,7 +331,7 @@ namespace ObjectFunctions
* \param index The index of the object.
* \return The lock level.
*/
EXPORT_APIFUNCTION int CDECL GetObjectLockLevel(unsigned int index) noexcept;
static int GetObjectLockLevel(unsigned int index) noexcept;
/**
* \brief Check whether the object at a certain index in the read object list has been
@ -340,7 +340,7 @@ namespace ObjectFunctions
* \param index The index of the object.
* \return Whether the object has been activated by a player.
*/
EXPORT_APIFUNCTION bool CDECL DoesObjectHavePlayerActivating(unsigned int index) noexcept;
static bool DoesObjectHavePlayerActivating(unsigned int index) noexcept;
/**
* \brief Get the player ID of the player activating the object at a certain index in the
@ -349,7 +349,7 @@ namespace ObjectFunctions
* \param index The index of the object.
* \return The player ID of the activating player.
*/
EXPORT_APIFUNCTION int CDECL GetObjectActivatingPid(unsigned int index) noexcept;
static int GetObjectActivatingPid(unsigned int index) noexcept;
/**
* \brief Get the refId of the actor activating the object at a certain index in the read
@ -358,7 +358,7 @@ namespace ObjectFunctions
* \param index The index of the object.
* \return The refId of the activating actor.
*/
EXPORT_APIFUNCTION const char *CDECL GetObjectActivatingRefId(unsigned int index) noexcept;
static const char *GetObjectActivatingRefId(unsigned int index) noexcept;
/**
* \brief Get the refNum of the actor activating the object at a certain index in the read
@ -367,7 +367,7 @@ namespace ObjectFunctions
* \param index The index of the object.
* \return The refNum of the activating actor.
*/
EXPORT_APIFUNCTION unsigned int CDECL GetObjectActivatingRefNum(unsigned int index) noexcept;
static unsigned int GetObjectActivatingRefNum(unsigned int index) noexcept;
/**
* \brief Get the mpNum of the actor activating the object at a certain index in the read
@ -376,7 +376,7 @@ namespace ObjectFunctions
* \param index The index of the object.
* \return The mpNum of the activating actor.
*/
EXPORT_APIFUNCTION unsigned int CDECL GetObjectActivatingMpNum(unsigned int index) noexcept;
static unsigned int GetObjectActivatingMpNum(unsigned int index) noexcept;
/**
* \brief Get the name of the actor activating the object at a certain index in the read
@ -385,7 +385,7 @@ namespace ObjectFunctions
* \param index The index of the object.
* \return The name of the activating actor.
*/
EXPORT_APIFUNCTION const char *CDECL GetObjectActivatingName(unsigned int index) noexcept;
static const char *GetObjectActivatingName(unsigned int index) noexcept;
/**
* \brief Check whether the object at a certain index in the read object list is a
@ -395,7 +395,7 @@ namespace ObjectFunctions
*
* \return The summon state.
*/
EXPORT_APIFUNCTION bool CDECL GetObjectSummonState(unsigned int index) noexcept;
static bool GetObjectSummonState(unsigned int index) noexcept;
/**
* \brief Get the summon duration of the object at a certain index in the read object list.
@ -405,7 +405,7 @@ namespace ObjectFunctions
* \param index The index of the object.
* \return The summon duration.
*/
EXPORT_APIFUNCTION double CDECL GetObjectSummonDuration(unsigned int index) noexcept;
static double GetObjectSummonDuration(unsigned int index) noexcept;
/**
* \brief Check whether the object at a certain index in the read object list has a player
@ -416,7 +416,7 @@ namespace ObjectFunctions
* \param index The index of the object.
* \return Whether a player is the summoner of the object.
*/
EXPORT_APIFUNCTION bool CDECL DoesObjectHavePlayerSummoner(unsigned int index) noexcept;
static bool DoesObjectHavePlayerSummoner(unsigned int index) noexcept;
/**
* \brief Get the player ID of the summoner of the object at a certain index in the read object
@ -425,7 +425,7 @@ namespace ObjectFunctions
* \param index The index of the object.
* \return The player ID of the summoner.
*/
EXPORT_APIFUNCTION int CDECL GetObjectSummonerPid(unsigned int index) noexcept;
static int GetObjectSummonerPid(unsigned int index) noexcept;
/**
* \brief Get the refId of the actor summoner of the object at a certain index in the read object
@ -434,7 +434,7 @@ namespace ObjectFunctions
* \param index The index of the object.
* \return The refId of the summoner.
*/
EXPORT_APIFUNCTION const char *CDECL GetObjectSummonerRefId(unsigned int index) noexcept;
static const char *GetObjectSummonerRefId(unsigned int index) noexcept;
/**
* \brief Get the refNum of the actor summoner of the object at a certain index in the read object
@ -443,7 +443,7 @@ namespace ObjectFunctions
* \param index The index of the object.
* \return The refNum of the summoner.
*/
EXPORT_APIFUNCTION unsigned int CDECL GetObjectSummonerRefNum(unsigned int index) noexcept;
static unsigned int GetObjectSummonerRefNum(unsigned int index) noexcept;
/**
* \brief Get the mpNum of the actor summoner of the object at a certain index in the read object list.
@ -451,7 +451,7 @@ namespace ObjectFunctions
* \param index The index of the object.
* \return The mpNum of the summoner.
*/
EXPORT_APIFUNCTION unsigned int CDECL GetObjectSummonerMpNum(unsigned int index) noexcept;
static unsigned int GetObjectSummonerMpNum(unsigned int index) noexcept;
/**
* \brief Get the X position of the object at a certain index in the read object list.
@ -459,7 +459,7 @@ namespace ObjectFunctions
* \param index The index of the object.
* \return The X position.
*/
EXPORT_APIFUNCTION double CDECL GetObjectPosX(unsigned int index) noexcept;
static double GetObjectPosX(unsigned int index) noexcept;
/**
* \brief Get the Y position of the object at a certain index in the read object list.
@ -467,7 +467,7 @@ namespace ObjectFunctions
* \param index The index of the object.
* \return The Y position.
*/
EXPORT_APIFUNCTION double CDECL GetObjectPosY(unsigned int index) noexcept;
static double GetObjectPosY(unsigned int index) noexcept;
/**
* \brief Get the Z position at a certain index in the read object list.
@ -475,7 +475,7 @@ namespace ObjectFunctions
* \param index The index of the object.
* \return The Z position.
*/
EXPORT_APIFUNCTION double CDECL GetObjectPosZ(unsigned int index) noexcept;
static double GetObjectPosZ(unsigned int index) noexcept;
/**
* \brief Get the X rotation of the object at a certain index in the read object list.
@ -483,7 +483,7 @@ namespace ObjectFunctions
* \param index The index of the object.
* \return The X rotation.
*/
EXPORT_APIFUNCTION double CDECL GetObjectRotX(unsigned int index) noexcept;
static double GetObjectRotX(unsigned int index) noexcept;
/**
* \brief Get the Y rotation of the object at a certain index in the read object list.
@ -491,7 +491,7 @@ namespace ObjectFunctions
* \param index The index of the object.
* \return The Y rotation.
*/
EXPORT_APIFUNCTION double CDECL GetObjectRotY(unsigned int index) noexcept;
static double GetObjectRotY(unsigned int index) noexcept;
/**
* \brief Get the Z rotation of the object at a certain index in the read object list.
@ -499,14 +499,14 @@ namespace ObjectFunctions
* \param index The index of the object.
* \return The Z rotation.
*/
EXPORT_APIFUNCTION double CDECL GetObjectRotZ(unsigned int index) noexcept;
static double GetObjectRotZ(unsigned int index) noexcept;
/**
* \brief Get the videoFilename of the object at a certain index in the read object list.
*
* \return The videoFilename.
*/
EXPORT_APIFUNCTION const char *CDECL GetVideoFilename(unsigned int index) noexcept;
static const char *GetVideoFilename(unsigned int index) noexcept;
/**
* \brief Get the number of container item indexes of the object at a certain index in the
@ -515,7 +515,7 @@ namespace ObjectFunctions
* \param index The index of the object.
* \return The number of container item indexes.
*/
EXPORT_APIFUNCTION unsigned int CDECL GetContainerChangesSize(unsigned int objectIndex) noexcept;
static unsigned int GetContainerChangesSize(unsigned int objectIndex) noexcept;
/**
* \brief Get the refId of the container item at a certain itemIndex in the container changes
@ -525,7 +525,7 @@ namespace ObjectFunctions
* \param itemIndex The index of the container item.
* \return The refId.
*/
EXPORT_APIFUNCTION const char *CDECL GetContainerItemRefId(unsigned int objectIndex, unsigned int itemIndex) noexcept;
static const char *GetContainerItemRefId(unsigned int objectIndex, unsigned int itemIndex) noexcept;
/**
* \brief Get the item count of the container item at a certain itemIndex in the container
@ -535,7 +535,7 @@ namespace ObjectFunctions
* \param itemIndex The index of the container item.
* \return The item count.
*/
EXPORT_APIFUNCTION int CDECL GetContainerItemCount(unsigned int objectIndex, unsigned int itemIndex) noexcept;
static int GetContainerItemCount(unsigned int objectIndex, unsigned int itemIndex) noexcept;
/**
* \brief Get the charge of the container item at a certain itemIndex in the container changes
@ -545,7 +545,7 @@ namespace ObjectFunctions
* \param itemIndex The index of the container item.
* \return The charge.
*/
EXPORT_APIFUNCTION int CDECL GetContainerItemCharge(unsigned int objectIndex, unsigned int itemIndex) noexcept;
static int GetContainerItemCharge(unsigned int objectIndex, unsigned int itemIndex) noexcept;
/**
* \brief Get the enchantment charge of the container item at a certain itemIndex in the container changes
@ -555,7 +555,7 @@ namespace ObjectFunctions
* \param itemIndex The index of the container item.
* \return The enchantment charge.
*/
EXPORT_APIFUNCTION double CDECL GetContainerItemEnchantmentCharge(unsigned int objectIndex, unsigned int itemIndex) noexcept;
static double GetContainerItemEnchantmentCharge(unsigned int objectIndex, unsigned int itemIndex) noexcept;
/**
* \brief Get the soul of the container item at a certain itemIndex in the container changes
@ -565,7 +565,7 @@ namespace ObjectFunctions
* \param itemIndex The index of the container item.
* \return The soul.
*/
EXPORT_APIFUNCTION const char *CDECL GetContainerItemSoul(unsigned int objectIndex, unsigned int itemIndex) noexcept;
static const char *GetContainerItemSoul(unsigned int objectIndex, unsigned int itemIndex) noexcept;
/**
* \brief Get the action count of the container item at a certain itemIndex in the container
@ -575,7 +575,7 @@ namespace ObjectFunctions
* \param itemIndex The index of the container item.
* \return The action count.
*/
EXPORT_APIFUNCTION int CDECL GetContainerItemActionCount(unsigned int objectIndex, unsigned int itemIndex) noexcept;
static int GetContainerItemActionCount(unsigned int objectIndex, unsigned int itemIndex) noexcept;
/**
* \brief Check whether the object at a certain index in the read object list has a container.
@ -586,7 +586,7 @@ namespace ObjectFunctions
* \param index The index of the object.
* \return Whether the object has a container.
*/
EXPORT_APIFUNCTION bool CDECL DoesObjectHaveContainer(unsigned int index) noexcept;
static bool DoesObjectHaveContainer(unsigned int index) noexcept;
/**
* \brief Set the cell of the temporary object list stored on the server.
@ -597,7 +597,7 @@ namespace ObjectFunctions
* \param cellDescription The description of the cell.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetObjectListCell(const char* cellDescription) noexcept;
static void SetObjectListCell(const char* cellDescription) noexcept;
/**
* \brief Set the action type of the temporary object list stored on the server.
@ -605,7 +605,7 @@ namespace ObjectFunctions
* \param action The action type (0 for SET, 1 for ADD, 2 for REMOVE, 3 for REQUEST).
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetObjectListAction(unsigned char action) noexcept;
static void SetObjectListAction(unsigned char action) noexcept;
/**
* \brief Set the console command of the temporary object list stored on the server.
@ -616,7 +616,7 @@ namespace ObjectFunctions
* \param consoleCommand The console command.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetObjectListConsoleCommand(const char* consoleCommand) noexcept;
static void SetObjectListConsoleCommand(const char* consoleCommand) noexcept;
/**
* \brief Set the refId of the temporary object stored on the server.
@ -624,7 +624,7 @@ namespace ObjectFunctions
* \param refId The refId.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetObjectRefId(const char* refId) noexcept;
static void SetObjectRefId(const char* refId) noexcept;
/**
* \brief Set the refNum of the temporary object stored on the server.
@ -638,7 +638,7 @@ namespace ObjectFunctions
* \param refNum The refNum.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetObjectRefNum(int refNum) noexcept;
static void SetObjectRefNum(int refNum) noexcept;
/**
* \brief Set the mpNum of the temporary object stored on the server.
@ -653,7 +653,7 @@ namespace ObjectFunctions
* \param mpNum The mpNum.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetObjectMpNum(int mpNum) noexcept;
static void SetObjectMpNum(int mpNum) noexcept;
/**
* \brief Set the object count of the temporary object stored on the server.
@ -663,7 +663,7 @@ namespace ObjectFunctions
* \param count The object count.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetObjectCount(int count) noexcept;
static void SetObjectCount(int count) noexcept;
/**
* \brief Set the charge of the temporary object stored on the server.
@ -673,7 +673,7 @@ namespace ObjectFunctions
* \param charge The charge.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetObjectCharge(int charge) noexcept;
static void SetObjectCharge(int charge) noexcept;
/**
* \brief Set the enchantment charge of the temporary object stored on the server.
@ -683,7 +683,7 @@ namespace ObjectFunctions
* \param charge The enchantment charge.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetObjectEnchantmentCharge(double enchantmentCharge) noexcept;
static void SetObjectEnchantmentCharge(double enchantmentCharge) noexcept;
/**
* \brief Set the soul of the temporary object stored on the server.
@ -691,7 +691,7 @@ namespace ObjectFunctions
* \param refId The soul.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetObjectSoul(const char* soul) noexcept;
static void SetObjectSoul(const char* soul) noexcept;
/**
* \brief Set the gold value of the temporary object stored on the server.
@ -701,7 +701,7 @@ namespace ObjectFunctions
* \param goldValue The gold value.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetObjectGoldValue(int goldValue) noexcept;
static void SetObjectGoldValue(int goldValue) noexcept;
/**
* \brief Set the scale of the temporary object stored on the server.
@ -711,7 +711,7 @@ namespace ObjectFunctions
* \param scale The scale.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetObjectScale(double scale) noexcept;
static void SetObjectScale(double scale) noexcept;
/**
* \brief Set the object state of the temporary object stored on the server.
@ -721,7 +721,7 @@ namespace ObjectFunctions
* \param objectState The object state.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetObjectState(bool objectState) noexcept;
static void SetObjectState(bool objectState) noexcept;
/**
* \brief Set the lock level of the temporary object stored on the server.
@ -729,7 +729,7 @@ namespace ObjectFunctions
* \param lockLevel The lock level.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetObjectLockLevel(int lockLevel) noexcept;
static void SetObjectLockLevel(int lockLevel) noexcept;
/**
* \brief Set the summon duration of the temporary object stored on the server.
@ -737,7 +737,7 @@ namespace ObjectFunctions
* \param summonDuration The summon duration.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetObjectSummonDuration(float summonDuration) noexcept;
static void SetObjectSummonDuration(float summonDuration) noexcept;
/**
* \brief Set the disarm state of the temporary object stored on the server.
@ -745,7 +745,7 @@ namespace ObjectFunctions
* \param disarmState The disarmState.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetObjectDisarmState(bool disarmState) noexcept;
static void SetObjectDisarmState(bool disarmState) noexcept;
/**
* \brief Set the summon state of the temporary object stored on the server.
@ -756,7 +756,7 @@ namespace ObjectFunctions
* \param summonState The summon state.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetObjectSummonState(bool summonState) noexcept;
static void SetObjectSummonState(bool summonState) noexcept;
/**
* \brief Set the position of the temporary object stored on the server.
@ -766,7 +766,7 @@ namespace ObjectFunctions
* \param z The Z position.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetObjectPosition(double x, double y, double z) noexcept;
static void SetObjectPosition(double x, double y, double z) noexcept;
/**
* \brief Set the rotation of the temporary object stored on the server.
@ -776,7 +776,7 @@ namespace ObjectFunctions
* \param z The Z rotation.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetObjectRotation(double x, double y, double z) noexcept;
static void SetObjectRotation(double x, double y, double z) noexcept;
/**
* \brief Set the player ID of the player activating the temporary object stored on the
@ -785,7 +785,7 @@ namespace ObjectFunctions
* \param pid The pid of the player.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetObjectActivatingPid(unsigned short pid) noexcept;
static void SetObjectActivatingPid(unsigned short pid) noexcept;
/**
* \brief Set the door state of the temporary object stored on the server.
@ -795,7 +795,7 @@ namespace ObjectFunctions
* \param doorState The door state.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetObjectDoorState(int doorState) noexcept;
static void SetObjectDoorState(int doorState) noexcept;
/**
* \brief Set the teleport state of the temporary object stored on the server.
@ -806,7 +806,7 @@ namespace ObjectFunctions
* \param teleportState The teleport state.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetObjectDoorTeleportState(bool teleportState) noexcept;
static void SetObjectDoorTeleportState(bool teleportState) noexcept;
/**
* \brief Set the door destination cell of the temporary object stored on the server.
@ -817,7 +817,7 @@ namespace ObjectFunctions
* \param cellDescription The description of the cell.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetObjectDoorDestinationCell(const char* cellDescription) noexcept;
static void SetObjectDoorDestinationCell(const char* cellDescription) noexcept;
/**
* \brief Set the door destination position of the temporary object stored on the server.
@ -827,7 +827,7 @@ namespace ObjectFunctions
* \param z The Z position.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetObjectDoorDestinationPosition(double x, double y, double z) noexcept;
static void SetObjectDoorDestinationPosition(double x, double y, double z) noexcept;
/**
* \brief Set the door destination rotation of the temporary object stored on the server.
@ -839,7 +839,7 @@ namespace ObjectFunctions
* \param z The Z rotation.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetObjectDoorDestinationRotation(double x, double z) noexcept;
static void SetObjectDoorDestinationRotation(double x, double z) noexcept;
/**
* \brief Set a player as the object in the temporary object stored on the server.
@ -848,7 +848,7 @@ namespace ObjectFunctions
* \param pid The pid of the player.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetPlayerAsObject(unsigned short pid) noexcept;
static void SetPlayerAsObject(unsigned short pid) noexcept;
/**
* \brief Set the refId of the temporary container item stored on the server.
@ -856,7 +856,7 @@ namespace ObjectFunctions
* \param refId The refId.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetContainerItemRefId(const char* refId) noexcept;
static void SetContainerItemRefId(const char* refId) noexcept;
/**
* \brief Set the item count of the temporary container item stored on the server.
@ -864,7 +864,7 @@ namespace ObjectFunctions
* \param count The item count.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetContainerItemCount(int count) noexcept;
static void SetContainerItemCount(int count) noexcept;
/**
* \brief Set the charge of the temporary container item stored on the server.
@ -872,7 +872,7 @@ namespace ObjectFunctions
* \param charge The charge.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetContainerItemCharge(int charge) noexcept;
static void SetContainerItemCharge(int charge) noexcept;
/**
* \brief Set the enchantment charge of the temporary container item stored on the server.
@ -880,7 +880,7 @@ namespace ObjectFunctions
* \param charge The enchantment charge.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetContainerItemEnchantmentCharge(double enchantmentCharge) noexcept;
static void SetContainerItemEnchantmentCharge(double enchantmentCharge) noexcept;
/**
* \brief Set the soul of the temporary container item stored on the server.
@ -888,7 +888,7 @@ namespace ObjectFunctions
* \param refId The soul.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetContainerItemSoul(const char* soul) noexcept;
static void SetContainerItemSoul(const char* soul) noexcept;
/**
* \brief Set the action count of the container item at a certain itemIndex in the container
@ -903,7 +903,7 @@ namespace ObjectFunctions
* \param actionCount The action count.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetContainerItemActionCountByIndex(unsigned int objectIndex, unsigned int itemIndex, int actionCount) noexcept;
static void SetContainerItemActionCountByIndex(unsigned int objectIndex, unsigned int itemIndex, int actionCount) noexcept;
/**
* \brief Add a copy of the server's temporary object to the server's currently stored object
@ -914,7 +914,7 @@ namespace ObjectFunctions
*
* \return void
*/
EXPORT_APIFUNCTION void CDECL AddObject() noexcept;
static void AddObject() noexcept;
/**
* \brief Add a copy of the server's temporary container item to the container changes of the
@ -925,7 +925,7 @@ namespace ObjectFunctions
*
* \return void
*/
EXPORT_APIFUNCTION void CDECL AddContainerItem() noexcept;
static void AddContainerItem() noexcept;
/**
* \brief Send an ObjectActivate packet.
@ -936,7 +936,7 @@ namespace ObjectFunctions
* to the packet (false by default).
* \return void
*/
EXPORT_APIFUNCTION void CDECL SendObjectActivate(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
static void SendObjectActivate(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
/**
* \brief Send an ObjectPlace packet.
@ -947,7 +947,7 @@ namespace ObjectFunctions
* to the packet (false by default).
* \return void
*/
EXPORT_APIFUNCTION void CDECL SendObjectPlace(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
static void SendObjectPlace(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
/**
* \brief Send an ObjectSpawn packet.
@ -958,7 +958,7 @@ namespace ObjectFunctions
* to the packet (false by default).
* \return void
*/
EXPORT_APIFUNCTION void CDECL SendObjectSpawn(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
static void SendObjectSpawn(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
/**
* \brief Send an ObjectDelete packet.
@ -968,7 +968,7 @@ namespace ObjectFunctions
*
* \return void
*/
EXPORT_APIFUNCTION void CDECL SendObjectDelete(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
static void SendObjectDelete(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
/**
* \brief Send an ObjectLock packet.
@ -979,7 +979,7 @@ namespace ObjectFunctions
* to the packet (false by default).
* \return void
*/
EXPORT_APIFUNCTION void CDECL SendObjectLock(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
static void SendObjectLock(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
/**
* \brief Send an ObjectTrap packet.
@ -989,7 +989,7 @@ namespace ObjectFunctions
*
* \return void
*/
EXPORT_APIFUNCTION void CDECL SendObjectTrap(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
static void SendObjectTrap(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
/**
* \brief Send an ObjectScale packet.
@ -1000,7 +1000,7 @@ namespace ObjectFunctions
* to the packet (false by default).
* \return void
*/
EXPORT_APIFUNCTION void CDECL SendObjectScale(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
static void SendObjectScale(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
/**
* \brief Send an ObjectState packet.
@ -1011,7 +1011,7 @@ namespace ObjectFunctions
* to the packet (false by default).
* \return void
*/
EXPORT_APIFUNCTION void CDECL SendObjectState(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
static void SendObjectState(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
/**
* \brief Send a DoorState packet.
@ -1022,7 +1022,7 @@ namespace ObjectFunctions
* to the packet (false by default).
* \return void
*/
EXPORT_APIFUNCTION void CDECL SendDoorState(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
static void SendDoorState(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
/**
* \brief Send a DoorDestination packet.
@ -1033,7 +1033,7 @@ namespace ObjectFunctions
* to the packet (false by default).
* \return void
*/
EXPORT_APIFUNCTION void CDECL SendDoorDestination(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
static void SendDoorDestination(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
/**
* \brief Send a Container packet.
@ -1044,7 +1044,7 @@ namespace ObjectFunctions
* to the packet (false by default).
* \return void
*/
EXPORT_APIFUNCTION void CDECL SendContainer(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
static void SendContainer(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
/**
* \brief Send a VideoPlay packet.
@ -1055,7 +1055,7 @@ namespace ObjectFunctions
* to the packet (false by default).
* \return void
*/
EXPORT_APIFUNCTION void CDECL SendVideoPlay(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
static void SendVideoPlay(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
/**
* \brief Send a ConsoleCommand packet.
@ -1066,27 +1066,28 @@ namespace ObjectFunctions
* to the packet (false by default).
* \return void
*/
EXPORT_APIFUNCTION void CDECL SendConsoleCommand(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
static void SendConsoleCommand(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
// All methods below are deprecated versions of methods from above
EXPORT_APIFUNCTION void CDECL ReadLastObjectList() noexcept;
EXPORT_APIFUNCTION void CDECL ReadLastEvent() noexcept;
EXPORT_APIFUNCTION void CDECL InitializeObjectList(unsigned short pid) noexcept;
EXPORT_APIFUNCTION void CDECL InitializeEvent(unsigned short pid) noexcept;
EXPORT_APIFUNCTION void CDECL CopyLastObjectListToStore() noexcept;
EXPORT_APIFUNCTION unsigned int CDECL GetObjectChangesSize() noexcept;
EXPORT_APIFUNCTION unsigned char CDECL GetEventAction() noexcept;
EXPORT_APIFUNCTION unsigned char CDECL GetEventContainerSubAction() noexcept;
EXPORT_APIFUNCTION unsigned int CDECL GetObjectRefNumIndex(unsigned int index) noexcept;
EXPORT_APIFUNCTION unsigned int CDECL GetObjectSummonerRefNumIndex(unsigned int index) noexcept;
EXPORT_APIFUNCTION void CDECL SetEventCell(const char* cellDescription) noexcept;
EXPORT_APIFUNCTION void CDECL SetEventAction(unsigned char action) noexcept;
EXPORT_APIFUNCTION void CDECL SetEventConsoleCommand(const char* consoleCommand) noexcept;
EXPORT_APIFUNCTION void CDECL SetObjectRefNumIndex(int refNum) noexcept;
EXPORT_APIFUNCTION void CDECL AddWorldObject() noexcept;
}
static void ReadLastObjectList() noexcept;
static void ReadLastEvent() noexcept;
static void InitializeObjectList(unsigned short pid) noexcept;
static void InitializeEvent(unsigned short pid) noexcept;
static void CopyLastObjectListToStore() noexcept;
static unsigned int GetObjectChangesSize() noexcept;
static unsigned char GetEventAction() noexcept;
static unsigned char GetEventContainerSubAction() noexcept;
static unsigned int GetObjectRefNumIndex(unsigned int index) noexcept;
static unsigned int GetObjectSummonerRefNumIndex(unsigned int index) noexcept;
static void SetEventCell(const char* cellDescription) noexcept;
static void SetEventAction(unsigned char action) noexcept;
static void SetEventConsoleCommand(const char* consoleCommand) noexcept;
static void SetObjectRefNumIndex(int refNum) noexcept;
static void AddWorldObject() noexcept;
};
#endif //OPENMW_OBJECTAPI_HPP

View file

@ -7,21 +7,7 @@
#include <iostream>
using namespace std;
extern "C" void PositionFunctions::GetPos(unsigned short pid, float *x, float *y, float *z) noexcept
{
*x = 0.00;
*y = 0.00;
*z = 0.00;
Player *player;
GET_PLAYER(pid, player,);
*x = player->position.pos[0];
*y = player->position.pos[1];
*z = player->position.pos[2];
}
extern "C" double PositionFunctions::GetPosX(unsigned short pid) noexcept
double PositionFunctions::GetPosX(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0.0f);
@ -29,7 +15,7 @@ extern "C" double PositionFunctions::GetPosX(unsigned short pid) noexcept
return player->position.pos[0];
}
extern "C" double PositionFunctions::GetPosY(unsigned short pid) noexcept
double PositionFunctions::GetPosY(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0.0f);
@ -37,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
double PositionFunctions::GetPosZ(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0.0f);
@ -45,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
double PositionFunctions::GetPreviousCellPosX(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0.0f);
@ -53,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
double PositionFunctions::GetPreviousCellPosY(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0.0f);
@ -61,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
double PositionFunctions::GetPreviousCellPosZ(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0.0f);
@ -69,21 +55,7 @@ extern "C" double PositionFunctions::GetPreviousCellPosZ(unsigned short pid) noe
return player->previousCellPosition.pos[2];
}
extern "C" void PositionFunctions::GetRot(unsigned short pid, float *x, float *y, float *z) noexcept
{
*x = 0.00;
*y = 0.00;
*z = 0.00;
Player *player;
GET_PLAYER(pid, player, );
*x = player->position.rot[0];
*y = player->position.rot[1];
*z = player->position.rot[2];
}
extern "C" double PositionFunctions::GetRotX(unsigned short pid) noexcept
double PositionFunctions::GetRotX(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0.0f);
@ -91,7 +63,7 @@ extern "C" double PositionFunctions::GetRotX(unsigned short pid) noexcept
return player->position.rot[0];
}
extern "C" double PositionFunctions::GetRotZ(unsigned short pid) noexcept
double PositionFunctions::GetRotZ(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0.0f);
@ -99,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
void PositionFunctions::SetPos(unsigned short pid, double x, double y, double z) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -109,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
void PositionFunctions::SetRot(unsigned short pid, double x, double z) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -118,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
void PositionFunctions::SetMomentum(unsigned short pid, double x, double y, double z) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -128,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
void PositionFunctions::SendPos(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -139,7 +111,7 @@ extern "C" void PositionFunctions::SendPos(unsigned short pid) noexcept
packet->Send(false);
}
extern "C" void PositionFunctions::SendMomentum(unsigned short pid) noexcept
void PositionFunctions::SendMomentum(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );

View file

@ -3,10 +3,7 @@
#include "../Types.hpp"
#include <Script/Platform.hpp>
#define POSITIONAPI \
{"GetPos", PositionFunctions::GetPos},\
{"GetPosX", PositionFunctions::GetPosX},\
{"GetPosY", PositionFunctions::GetPosY},\
{"GetPosZ", PositionFunctions::GetPosZ},\
@ -15,7 +12,6 @@
{"GetPreviousCellPosY", PositionFunctions::GetPreviousCellPosY},\
{"GetPreviousCellPosZ", PositionFunctions::GetPreviousCellPosZ},\
\
{"GetRot", PositionFunctions::GetRot},\
{"GetRotX", PositionFunctions::GetRotX},\
{"GetRotZ", PositionFunctions::GetRotZ},\
\
@ -27,19 +23,9 @@
{"SendMomentum", PositionFunctions::SendMomentum}
namespace PositionFunctions
class PositionFunctions
{
/**
* \brief Assign the player's positional coordinate values to the variables passed as
* parameters.
*
* \param pid The player ID.
* \param x The variable for the X position.
* \param y The variable for the Y position.
* \param z The variable for the Z position.
* \return void
*/
EXPORT_APIFUNCTION void CDECL GetPos(unsigned short pid, float *x, float *y, float *z) noexcept;
public:
/**
* \brief Get the X position of a player.
@ -47,7 +33,7 @@ namespace PositionFunctions
* \param pid The player ID.
* \return The X position.
*/
EXPORT_APIFUNCTION double CDECL GetPosX(unsigned short pid) noexcept;
static double GetPosX(unsigned short pid) noexcept;
/**
* \brief Get the Y position of a player.
@ -55,7 +41,7 @@ namespace PositionFunctions
* \param pid The player ID.
* \return The Y position.
*/
EXPORT_APIFUNCTION double CDECL GetPosY(unsigned short pid) noexcept;
static double GetPosY(unsigned short pid) noexcept;
/**
* \brief Get the Z position of a player.
@ -63,7 +49,7 @@ namespace PositionFunctions
* \param pid The player ID.
* \return The Z position.
*/
EXPORT_APIFUNCTION double CDECL GetPosZ(unsigned short pid) noexcept;
static double GetPosZ(unsigned short pid) noexcept;
/**
* \brief Get the X position of a player from before their latest cell change.
@ -71,7 +57,7 @@ namespace PositionFunctions
* \param pid The player ID.
* \return The X position.
*/
EXPORT_APIFUNCTION double CDECL GetPreviousCellPosX(unsigned short pid) noexcept;
static double GetPreviousCellPosX(unsigned short pid) noexcept;
/**
* \brief Get the Y position of a player from before their latest cell change.
@ -79,7 +65,7 @@ namespace PositionFunctions
* \param pid The player ID.
* \return The Y position.
*/
EXPORT_APIFUNCTION double CDECL GetPreviousCellPosY(unsigned short pid) noexcept;
static double GetPreviousCellPosY(unsigned short pid) noexcept;
/**
* \brief Get the Z position of a player from before their latest cell change.
@ -87,19 +73,7 @@ namespace PositionFunctions
* \param pid The player ID.
* \return The Z position.
*/
EXPORT_APIFUNCTION double CDECL GetPreviousCellPosZ(unsigned short pid) noexcept;
/**
* \brief Assign the player's rotational coordinate values to the variables passed as
* parameters.
*
* \param pid The player ID.
* \param x The variable for the X rotation.
* \param y The variable for the Y rotation.
* \param z The variable for the Z rotation.
* \return void
*/
EXPORT_APIFUNCTION void CDECL GetRot(unsigned short pid, float *x, float *y, float *z) noexcept;
static double GetPreviousCellPosZ(unsigned short pid) noexcept;
/**
* \brief Get the X rotation of a player.
@ -107,7 +81,7 @@ namespace PositionFunctions
* \param pid The player ID.
* \return The X rotation.
*/
EXPORT_APIFUNCTION double CDECL GetRotX(unsigned short pid) noexcept;
static double GetRotX(unsigned short pid) noexcept;
/**
* \brief Get the Z rotation of a player.
@ -115,7 +89,7 @@ namespace PositionFunctions
* \param pid The player ID.
* \return The Z rotation.
*/
EXPORT_APIFUNCTION double CDECL GetRotZ(unsigned short pid) noexcept;
static double GetRotZ(unsigned short pid) noexcept;
/**
* \brief Set the position of a player.
@ -129,7 +103,7 @@ namespace PositionFunctions
* \param z The Z position.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetPos(unsigned short pid, double x, double y, double z) noexcept;
static void SetPos(unsigned short pid, double x, double y, double z) noexcept;
/**
* \brief Set the rotation of a player.
@ -144,7 +118,7 @@ namespace PositionFunctions
* \param z The Z position.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRot(unsigned short pid, double x, double z) noexcept;
static void SetRot(unsigned short pid, double x, double z) noexcept;
/**
* \brief Set the momentum of a player.
@ -158,7 +132,7 @@ namespace PositionFunctions
* \param z The Z momentum.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetMomentum(unsigned short pid, double x, double y, double z) noexcept;
static void SetMomentum(unsigned short pid, double x, double y, double z) noexcept;
/**
* \brief Send a PlayerPosition packet about a player.
@ -168,7 +142,7 @@ namespace PositionFunctions
* \param pid The player ID.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SendPos(unsigned short pid) noexcept;
static void SendPos(unsigned short pid) noexcept;
/**
* \brief Send a PlayerMomentum packet about a player.
@ -178,7 +152,7 @@ namespace PositionFunctions
* \param pid The player ID.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SendMomentum(unsigned short pid) noexcept;
}
static void SendMomentum(unsigned short pid) noexcept;
};
#endif //OPENMW_POSITIONAPI_HPP

View file

@ -1,29 +0,0 @@
//
// Created by koncord on 09.12.18.
//
#include "Public.hpp"
#include <Script/ScriptFunctions.hpp>
#include <Script/API/PublicFnAPI.hpp>
extern "C" void PublicFunctions::MakePublic(ScriptFunc _public, const char *name, char ret_type, const char *def) noexcept
{
Public::MakePublic(_public, name, ret_type, def);
}
extern "C" boost::any PublicFunctions::CallPublic(const char *name, va_list args) noexcept
{
std::vector<boost::any> params;
try
{
std::string def = Public::GetDefinition(name);
ScriptFunctions::GetArguments(params, args, def);
return Public::Call(name, params);
}
catch (...) {}
return 0;
}

View file

@ -1,16 +0,0 @@
//
// Created by koncord on 09.12.18.
//
#ifndef OPENMW_PUBLIC_HPP
#define OPENMW_PUBLIC_HPP
#include <apps/openmw-mp/Script/ScriptFunction.hpp>
namespace PublicFunctions
{
extern "C" void MakePublic(ScriptFunc _public, const char *name, char ret_type, const char *def) noexcept;
extern "C" boost::any CallPublic(const char *name, va_list args) noexcept;
}
#endif

View file

@ -8,7 +8,7 @@
using namespace mwmp;
extern "C" void QuestFunctions::ClearJournalChanges(unsigned short pid) noexcept
void QuestFunctions::ClearJournalChanges(unsigned short 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
void QuestFunctions::ClearKillChanges(unsigned short 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
unsigned int QuestFunctions::GetJournalChangesSize(unsigned short 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
unsigned int QuestFunctions::GetKillChangesSize(unsigned short 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
void QuestFunctions::AddJournalEntry(unsigned short 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,
void QuestFunctions::AddJournalEntryWithTimestamp(unsigned short 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
void QuestFunctions::AddJournalIndex(unsigned short 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
void QuestFunctions::AddKill(unsigned short 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
void QuestFunctions::SetReputation(unsigned short 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
const char *QuestFunctions::GetJournalItemQuest(unsigned short 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
int QuestFunctions::GetJournalItemIndex(unsigned short 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
int QuestFunctions::GetJournalItemType(unsigned short 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
const char *QuestFunctions::GetJournalItemActorRefId(unsigned short 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
const char *QuestFunctions::GetKillRefId(unsigned short 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
int QuestFunctions::GetKillNumber(unsigned short 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
int QuestFunctions::GetReputation(unsigned short 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
void QuestFunctions::SendJournalChanges(unsigned short 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
void QuestFunctions::SendKillChanges(unsigned short 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
void QuestFunctions::SendReputation(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -212,14 +212,14 @@ extern "C" void QuestFunctions::SendReputation(unsigned short pid, bool sendToOt
packet->Send(true);
}
extern "C" // All methods below are deprecated versions of methods from above
// All methods below are deprecated versions of methods from above
void QuestFunctions::InitializeJournalChanges(unsigned short pid) noexcept
{
ClearJournalChanges(pid);
}
extern "C" void QuestFunctions::InitializeKillChanges(unsigned short pid) noexcept
void QuestFunctions::InitializeKillChanges(unsigned short pid) noexcept
{
ClearKillChanges(pid);
}

View file

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

View file

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

View file

@ -3,8 +3,6 @@
#include "../Types.hpp"
#include <Script/Platform.hpp>
#define RECORDSDYNAMICAPI \
{"ClearRecords", RecordsDynamicFunctions::ClearRecords},\
\
@ -112,14 +110,16 @@
\
{"SendRecordDynamic", RecordsDynamicFunctions::SendRecordDynamic}
namespace RecordsDynamicFunctions
class RecordsDynamicFunctions
{
public:
/**
* \brief Clear the data from the records stored on the server.
*
* \return void
*/
EXPORT_APIFUNCTION void CDECL ClearRecords() noexcept;
static void ClearRecords() noexcept;
/**
* \brief Get the type of records in the read worldstate's dynamic records.
@ -127,14 +127,14 @@ namespace RecordsDynamicFunctions
* \return The type of records (0 for SPELL, 1 for POTION, 2 for ENCHANTMENT,
* 3 for NPC).
*/
EXPORT_APIFUNCTION unsigned short CDECL GetRecordType() noexcept;
static unsigned short GetRecordType() noexcept;
/**
* \brief Get the number of records in the read worldstate's dynamic records.
*
* \return The number of records.
*/
EXPORT_APIFUNCTION unsigned int CDECL GetRecordCount() noexcept;
static unsigned int GetRecordCount() noexcept;
/**
* \brief Get the number of effects for the record at a certain index in the read
@ -143,7 +143,7 @@ namespace RecordsDynamicFunctions
* \param recordIndex The index of the record.
* \return The number of effects.
*/
EXPORT_APIFUNCTION unsigned int CDECL GetRecordEffectCount(unsigned int recordIndex) noexcept;
static unsigned int GetRecordEffectCount(unsigned int recordIndex) noexcept;
/**
* \brief Get the id of the record at a certain index in the read worldstate's
@ -152,7 +152,7 @@ namespace RecordsDynamicFunctions
* \param index The index of the record.
* \return The id of the record.
*/
EXPORT_APIFUNCTION const char *CDECL GetRecordId(unsigned int index) noexcept;
static const char *GetRecordId(unsigned int index) noexcept;
/**
* \brief Get the base id (i.e. the id this record should inherit default
@ -162,7 +162,7 @@ namespace RecordsDynamicFunctions
* \param index The index of the record.
* \return The base id of the record.
*/
EXPORT_APIFUNCTION const char *CDECL GetRecordBaseId(unsigned int index) noexcept;
static const char *GetRecordBaseId(unsigned int index) noexcept;
/**
* \brief Get the subtype of the record at a certain index in the read worldstate's
@ -171,7 +171,7 @@ namespace RecordsDynamicFunctions
* \param index The index of the record.
* \return The type of the record.
*/
EXPORT_APIFUNCTION int CDECL GetRecordSubtype(unsigned int index) noexcept;
static int GetRecordSubtype(unsigned int index) noexcept;
/**
* \brief Get the name of the record at a certain index in the read worldstate's
@ -180,7 +180,7 @@ namespace RecordsDynamicFunctions
* \param index The index of the record.
* \return The name of the record.
*/
EXPORT_APIFUNCTION const char *CDECL GetRecordName(unsigned int index) noexcept;
static const char *GetRecordName(unsigned int index) noexcept;
/**
* \brief Get the model of the record at a certain index in the read worldstate's
@ -189,7 +189,7 @@ namespace RecordsDynamicFunctions
* \param index The index of the record.
* \return The model of the record.
*/
EXPORT_APIFUNCTION const char *CDECL GetRecordModel(unsigned int index) noexcept;
static const char *GetRecordModel(unsigned int index) noexcept;
/**
* \brief Get the icon of the record at a certain index in the read worldstate's
@ -198,7 +198,7 @@ namespace RecordsDynamicFunctions
* \param index The index of the record.
* \return The icon of the record.
*/
EXPORT_APIFUNCTION const char *CDECL GetRecordIcon(unsigned int index) noexcept;
static const char *GetRecordIcon(unsigned int index) noexcept;
/**
* \brief Get the script of the record at a certain index in the read worldstate's
@ -207,7 +207,7 @@ namespace RecordsDynamicFunctions
* \param index The index of the record.
* \return The script of the record.
*/
EXPORT_APIFUNCTION const char *CDECL GetRecordScript(unsigned int index) noexcept;
static const char *GetRecordScript(unsigned int index) noexcept;
/**
* \brief Get the enchantment id of the record at a certain index in the read
@ -216,7 +216,7 @@ namespace RecordsDynamicFunctions
* \param index The index of the record.
* \return The enchantment id of the record.
*/
EXPORT_APIFUNCTION const char *CDECL GetRecordEnchantmentId(unsigned int index) noexcept;
static const char *GetRecordEnchantmentId(unsigned int index) noexcept;
/**
* \brief Get the enchantment charge of the record at a certain index in
@ -225,7 +225,7 @@ namespace RecordsDynamicFunctions
* \param index The index of the record.
* \return The enchantment charge of the record.
*/
EXPORT_APIFUNCTION int CDECL GetRecordEnchantmentCharge(unsigned int index) noexcept;
static int GetRecordEnchantmentCharge(unsigned int index) noexcept;
/**
* \brief Get the auto-calculation flag value of the record at a certain index in
@ -234,7 +234,7 @@ namespace RecordsDynamicFunctions
* \param index The index of the record.
* \return The auto-calculation flag value of the record.
*/
EXPORT_APIFUNCTION int CDECL GetRecordAutoCalc(unsigned int index) noexcept;
static int GetRecordAutoCalc(unsigned int index) noexcept;
/**
* \brief Get the charge of the record at a certain index in the read worldstate's
@ -243,7 +243,7 @@ namespace RecordsDynamicFunctions
* \param index The index of the record.
* \return The charge of the record.
*/
EXPORT_APIFUNCTION int CDECL GetRecordCharge(unsigned int index) noexcept;
static int GetRecordCharge(unsigned int index) noexcept;
/**
* \brief Get the cost of the record at a certain index in the read worldstate's
@ -252,7 +252,7 @@ namespace RecordsDynamicFunctions
* \param index The index of the record.
* \return The cost of the record.
*/
EXPORT_APIFUNCTION int CDECL GetRecordCost(unsigned int index) noexcept;
static int GetRecordCost(unsigned int index) noexcept;
/**
* \brief Get the flags of the record at a certain index in the read worldstate's
@ -261,7 +261,7 @@ namespace RecordsDynamicFunctions
* \param index The index of the record.
* \return The flags of the spell as an integer.
*/
EXPORT_APIFUNCTION int CDECL GetRecordFlags(unsigned int index) noexcept;
static int GetRecordFlags(unsigned int index) noexcept;
/**
* \brief Get the value of the record at a certain index in the read worldstate's
@ -270,7 +270,7 @@ namespace RecordsDynamicFunctions
* \param index The index of the record.
* \return The value of the record.
*/
EXPORT_APIFUNCTION int CDECL GetRecordValue(unsigned int index) noexcept;
static int GetRecordValue(unsigned int index) noexcept;
/**
* \brief Get the weight of the record at a certain index in the read worldstate's
@ -279,7 +279,7 @@ namespace RecordsDynamicFunctions
* \param index The index of the record.
* \return The weight of the record.
*/
EXPORT_APIFUNCTION double CDECL GetRecordWeight(unsigned int index) noexcept;
static double GetRecordWeight(unsigned int index) noexcept;
/**
* \brief Get the ID of the effect at a certain index in the read worldstate's
@ -289,7 +289,7 @@ namespace RecordsDynamicFunctions
* \param effectIndex The index of the effect.
* \return The ID of the effect.
*/
EXPORT_APIFUNCTION unsigned int CDECL GetRecordEffectId(unsigned int recordIndex, unsigned int effectIndex) noexcept;
static unsigned int GetRecordEffectId(unsigned int recordIndex, unsigned int effectIndex) noexcept;
/**
* \brief Get the ID of the attribute modified by the effect at a certain index in the
@ -299,7 +299,7 @@ namespace RecordsDynamicFunctions
* \param effectIndex The index of the effect.
* \return The attribute ID for the effect.
*/
EXPORT_APIFUNCTION int CDECL GetRecordEffectAttribute(unsigned int recordIndex, unsigned int effectIndex) noexcept;
static int GetRecordEffectAttribute(unsigned int recordIndex, unsigned int effectIndex) noexcept;
/**
* \brief Get the ID of the skill modified by the effect at a certain index in the
@ -309,7 +309,7 @@ namespace RecordsDynamicFunctions
* \param effectIndex The index of the effect.
* \return The skill ID for the effect.
*/
EXPORT_APIFUNCTION int CDECL GetRecordEffectSkill(unsigned int recordIndex, unsigned int effectIndex) noexcept;
static int GetRecordEffectSkill(unsigned int recordIndex, unsigned int effectIndex) noexcept;
/**
* \brief Get the range type of the effect at a certain index in the read worldstate's
@ -319,7 +319,7 @@ namespace RecordsDynamicFunctions
* \param effectIndex The index of the effect.
* \return The range of the effect.
*/
EXPORT_APIFUNCTION unsigned int CDECL GetRecordEffectRangeType(unsigned int recordIndex, unsigned int effectIndex) noexcept;
static unsigned int GetRecordEffectRangeType(unsigned int recordIndex, unsigned int effectIndex) noexcept;
/**
* \brief Get the area of the effect at a certain index in the read worldstate's current
@ -329,7 +329,7 @@ namespace RecordsDynamicFunctions
* \param effectIndex The index of the effect.
* \return The area of the effect.
*/
EXPORT_APIFUNCTION int CDECL GetRecordEffectArea(unsigned int recordIndex, unsigned int effectIndex) noexcept;
static int GetRecordEffectArea(unsigned int recordIndex, unsigned int effectIndex) noexcept;
/**
* \brief Get the duration of the effect at a certain index in the read worldstate's current
@ -339,7 +339,7 @@ namespace RecordsDynamicFunctions
* \param effectIndex The index of the effect.
* \return The duration of the effect.
*/
EXPORT_APIFUNCTION int CDECL GetRecordEffectDuration(unsigned int recordIndex, unsigned int effectIndex) noexcept;
static int GetRecordEffectDuration(unsigned int recordIndex, unsigned int effectIndex) noexcept;
/**
* \brief Get the maximum magnitude of the effect at a certain index in the read
@ -349,7 +349,7 @@ namespace RecordsDynamicFunctions
* \param effectIndex The index of the effect.
* \return The maximum magnitude of the effect.
*/
EXPORT_APIFUNCTION int CDECL GetRecordEffectMagnitudeMax(unsigned int recordIndex, unsigned int effectIndex) noexcept;
static int GetRecordEffectMagnitudeMax(unsigned int recordIndex, unsigned int effectIndex) noexcept;
/**
* \brief Get the minimum magnitude of the effect at a certain index in the read
@ -359,7 +359,7 @@ namespace RecordsDynamicFunctions
* \param effectIndex The index of the effect.
* \return The minimum magnitude of the effect.
*/
EXPORT_APIFUNCTION int CDECL GetRecordEffectMagnitudeMin(unsigned int recordIndex, unsigned int effectIndex) noexcept;
static int GetRecordEffectMagnitudeMin(unsigned int recordIndex, unsigned int effectIndex) noexcept;
/**
* \brief Set which type of temporary records stored on the server should have
@ -368,7 +368,7 @@ namespace RecordsDynamicFunctions
* \param type The type of records.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordType(unsigned int type) noexcept;
static void SetRecordType(unsigned int type) noexcept;
/**
* \brief Set the id of the temporary record stored on the server for the
@ -377,7 +377,7 @@ namespace RecordsDynamicFunctions
* \param id The id of the record.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordId(const char* id) noexcept;
static void SetRecordId(const char* id) noexcept;
/**
* \brief Set the base id (i.e. the id this record should inherit default
@ -387,7 +387,7 @@ namespace RecordsDynamicFunctions
* \param baseId The baseId of the record.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordBaseId(const char* baseId) noexcept;
static void SetRecordBaseId(const char* baseId) noexcept;
/**
* \brief Set the inventory base id (i.e. the id this record should inherit
@ -397,7 +397,7 @@ namespace RecordsDynamicFunctions
* \param inventoryBaseId The inventoryBaseId of the record.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordInventoryBaseId(const char* inventoryBaseId) noexcept;
static void SetRecordInventoryBaseId(const char* inventoryBaseId) noexcept;
/**
* \brief Set the subtype of the temporary record stored on the server for
@ -406,7 +406,7 @@ namespace RecordsDynamicFunctions
* \param type The spell type.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordSubtype(unsigned int subtype) noexcept;
static void SetRecordSubtype(unsigned int subtype) noexcept;
/**
* \brief Set the name of the temporary record stored on the server for the
@ -415,7 +415,7 @@ namespace RecordsDynamicFunctions
* \param name The name of the record.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordName(const char* name) noexcept;
static void SetRecordName(const char* name) noexcept;
/**
* \brief Set the model of the temporary record stored on the server for the
@ -424,7 +424,7 @@ namespace RecordsDynamicFunctions
* \param model The model of the record.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordModel(const char* model) noexcept;
static void SetRecordModel(const char* model) noexcept;
/**
* \brief Set the icon of the temporary record stored on the server for the
@ -433,7 +433,7 @@ namespace RecordsDynamicFunctions
* \param icon The icon of the record.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordIcon(const char* icon) noexcept;
static void SetRecordIcon(const char* icon) noexcept;
/**
* \brief Set the script of the temporary record stored on the server for the
@ -442,7 +442,7 @@ namespace RecordsDynamicFunctions
* \param script The script of the record.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordScript(const char* script) noexcept;
static void SetRecordScript(const char* script) noexcept;
/**
* \brief Set the enchantment id of the temporary record stored on the server
@ -451,7 +451,7 @@ namespace RecordsDynamicFunctions
* \param enchantmentId The enchantment id of the record.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordEnchantmentId(const char* enchantmentId) noexcept;
static void SetRecordEnchantmentId(const char* enchantmentId) noexcept;
/**
* \brief Set the enchantment charge of the temporary record stored on the server
@ -460,7 +460,7 @@ namespace RecordsDynamicFunctions
* \param enchantmentCharge The enchantmentCharge of the record.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordEnchantmentCharge(int enchantmentCharge) noexcept;
static void SetRecordEnchantmentCharge(int enchantmentCharge) noexcept;
/**
* \brief Set the auto-calculation flag value of the temporary record stored
@ -469,7 +469,7 @@ namespace RecordsDynamicFunctions
* \param autoCalc The auto-calculation flag value of the record.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordAutoCalc(int autoCalc) noexcept;
static void SetRecordAutoCalc(int autoCalc) noexcept;
/**
* \brief Set the charge of the temporary record stored on the server for the
@ -478,7 +478,7 @@ namespace RecordsDynamicFunctions
* \param charge The charge of the record.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordCharge(int charge) noexcept;
static void SetRecordCharge(int charge) noexcept;
/**
* \brief Set the cost of the temporary record stored on the server for the
@ -487,7 +487,7 @@ namespace RecordsDynamicFunctions
* \param cost The cost of the record.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordCost(int cost) noexcept;
static void SetRecordCost(int cost) noexcept;
/**
* \brief Set the flags of the temporary record stored on the server for the
@ -496,7 +496,7 @@ namespace RecordsDynamicFunctions
* \param flags The flags of the record.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordFlags(int flags) noexcept;
static void SetRecordFlags(int flags) noexcept;
/**
* \brief Set the value of the temporary record stored on the server for the
@ -505,7 +505,7 @@ namespace RecordsDynamicFunctions
* \param value The value of the record.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordValue(int value) noexcept;
static void SetRecordValue(int value) noexcept;
/**
* \brief Set the weight of the temporary record stored on the server for the
@ -514,7 +514,7 @@ namespace RecordsDynamicFunctions
* \param weight The weight of the record.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordWeight(double weight) noexcept;
static void SetRecordWeight(double weight) noexcept;
/**
* \brief Set the armor rating of the temporary record stored on the server
@ -523,7 +523,7 @@ namespace RecordsDynamicFunctions
* \param armorRating The armor rating of the record.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordArmorRating(int armorRating) noexcept;
static void SetRecordArmorRating(int armorRating) noexcept;
/**
* \brief Set the health of the temporary record stored on the server for the
@ -532,7 +532,7 @@ namespace RecordsDynamicFunctions
* \param health The health of the record.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordHealth(int health) noexcept;
static void SetRecordHealth(int health) noexcept;
/**
* \brief Set the chop damage of the temporary record stored on the server for the
@ -542,7 +542,7 @@ namespace RecordsDynamicFunctions
* \param maxDamage The maximum damage of the record.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordDamageChop(unsigned int minDamage, unsigned int maxDamage) noexcept;
static void SetRecordDamageChop(unsigned int minDamage, unsigned int maxDamage) noexcept;
/**
* \brief Set the slash damage of the temporary record stored on the server for the
@ -552,7 +552,7 @@ namespace RecordsDynamicFunctions
* \param maxDamage The maximum damage of the record.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordDamageSlash(unsigned int minDamage, unsigned int maxDamage) noexcept;
static void SetRecordDamageSlash(unsigned int minDamage, unsigned int maxDamage) noexcept;
/**
* \brief Set the thrust damage of the temporary record stored on the server for the
@ -562,7 +562,7 @@ namespace RecordsDynamicFunctions
* \param maxDamage The maximum damage of the record.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordDamageThrust(unsigned int minDamage, unsigned int maxDamage) noexcept;
static void SetRecordDamageThrust(unsigned int minDamage, unsigned int maxDamage) noexcept;
/**
* \brief Set the reach of the temporary record stored on the server for the
@ -571,7 +571,7 @@ namespace RecordsDynamicFunctions
* \param reach The reach of the record.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordReach(double reach) noexcept;
static void SetRecordReach(double reach) noexcept;
/**
* \brief Set the speed of the temporary record stored on the server for the
@ -580,7 +580,7 @@ namespace RecordsDynamicFunctions
* \param speed The speed of the record.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordSpeed(double speed) noexcept;
static void SetRecordSpeed(double speed) noexcept;
/**
* \brief Set whether the temporary record stored on the server for the
@ -591,7 +591,7 @@ namespace RecordsDynamicFunctions
* \param keyState Whether the record is a key.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordKeyState(bool keyState) noexcept;
static void SetRecordKeyState(bool keyState) noexcept;
/**
* \brief Set whether the temporary record stored on the server for the
@ -602,7 +602,7 @@ namespace RecordsDynamicFunctions
* \param scrollState Whether the record is a scroll.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordScrollState(bool scrollState) noexcept;
static void SetRecordScrollState(bool scrollState) noexcept;
/**
* \brief Set the skill ID of the temporary record stored on the server for the
@ -611,7 +611,7 @@ namespace RecordsDynamicFunctions
* \param skillId The skill ID of the record.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordSkillId(int skillId) noexcept;
static void SetRecordSkillId(int skillId) noexcept;
/**
* \brief Set the text of the temporary record stored on the server for the
@ -620,7 +620,7 @@ namespace RecordsDynamicFunctions
* \param text The text of the record.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordText(const char* text) noexcept;
static void SetRecordText(const char* text) noexcept;
/**
* \brief Set the hair of the temporary record stored on the server for the
@ -629,7 +629,7 @@ namespace RecordsDynamicFunctions
* \param hair The hair of the record.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordHair(const char* hair) noexcept;
static void SetRecordHair(const char* hair) noexcept;
/**
* \brief Set the head of the temporary record stored on the server for the
@ -638,7 +638,7 @@ namespace RecordsDynamicFunctions
* \param hair The head of the record.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordHead(const char* head) noexcept;
static void SetRecordHead(const char* head) noexcept;
/**
* \brief Set the gender of the temporary record stored on the server for the
@ -647,7 +647,7 @@ namespace RecordsDynamicFunctions
* \param hair The race of the record.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordGender(unsigned int gender) noexcept;
static void SetRecordGender(unsigned int gender) noexcept;
/**
* \brief Set the race of the temporary record stored on the server for the
@ -656,7 +656,7 @@ namespace RecordsDynamicFunctions
* \param hair The race of the record.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordRace(const char* race) noexcept;
static void SetRecordRace(const char* race) noexcept;
/**
* \brief Set the character class of the temporary record stored on the server
@ -665,7 +665,7 @@ namespace RecordsDynamicFunctions
* \param hair The character class of the record.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordClass(const char* charClass) noexcept;
static void SetRecordClass(const char* charClass) noexcept;
/**
* \brief Set the faction of the temporary record stored on the server for the
@ -674,7 +674,7 @@ namespace RecordsDynamicFunctions
* \param faction The faction of the record.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordFaction(const char* faction) noexcept;
static void SetRecordFaction(const char* faction) noexcept;
/**
* \brief Set the level of the temporary record stored on the server for the
@ -683,7 +683,7 @@ namespace RecordsDynamicFunctions
* \param level The level of the record.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordLevel(int level) noexcept;
static void SetRecordLevel(int level) noexcept;
/**
* \brief Set the magicka of the temporary record stored on the server for the
@ -692,7 +692,7 @@ namespace RecordsDynamicFunctions
* \param magicka The magicka of the record.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordMagicka(int magicka) noexcept;
static void SetRecordMagicka(int magicka) noexcept;
/**
* \brief Set the fatigue of the temporary record stored on the server for the
@ -701,7 +701,7 @@ namespace RecordsDynamicFunctions
* \param fatigue The fatigue of the record.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordFatigue(int fatigue) noexcept;
static void SetRecordFatigue(int fatigue) noexcept;
/**
* \brief Set the AI fight value of the temporary record stored on the server for the
@ -710,7 +710,7 @@ namespace RecordsDynamicFunctions
* \param aiFight The AI fight value of the record.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordAIFight(int aiFight) noexcept;
static void SetRecordAIFight(int aiFight) noexcept;
/**
* \brief Set the id of the record at a certain index in the records stored on the server.
@ -722,7 +722,7 @@ namespace RecordsDynamicFunctions
* \param id The id of the record.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordIdByIndex(unsigned int index, const char* id) noexcept;
static void SetRecordIdByIndex(unsigned int index, const char* id) noexcept;
/**
* \brief Set the enchantment id of the record at a certain index in the records stored on
@ -735,7 +735,7 @@ namespace RecordsDynamicFunctions
* \param enchantmentId The enchantment id of the record.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordEnchantmentIdByIndex(unsigned int index, const char* enchantmentId) noexcept;
static void SetRecordEnchantmentIdByIndex(unsigned int index, const char* enchantmentId) noexcept;
/**
* \brief Set the ID of the temporary effect stored on the server.
@ -743,7 +743,7 @@ namespace RecordsDynamicFunctions
* \param effectId The ID of the effect.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordEffectId(unsigned int effectId) noexcept;
static void SetRecordEffectId(unsigned int effectId) noexcept;
/**
* \brief Set the ID of the attribute modified by the temporary effect stored on
@ -752,7 +752,7 @@ namespace RecordsDynamicFunctions
* \param attributeId The ID of the attribute.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordEffectAttribute(int attributeId) noexcept;
static void SetRecordEffectAttribute(int attributeId) noexcept;
/**
* \brief Set the ID of the skill modified by the temporary effect stored on the
@ -761,7 +761,7 @@ namespace RecordsDynamicFunctions
* \param skillId The ID of the skill.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordEffectSkill(int skillId) noexcept;
static void SetRecordEffectSkill(int skillId) noexcept;
/**
* \brief Set the range type of the temporary effect stored on the server (0 for
@ -770,7 +770,7 @@ namespace RecordsDynamicFunctions
* \param rangeType The range type of the effect.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordEffectRangeType(unsigned int rangeType) noexcept;
static void SetRecordEffectRangeType(unsigned int rangeType) noexcept;
/**
* \brief Set the area of the temporary effect stored on the server.
@ -778,7 +778,7 @@ namespace RecordsDynamicFunctions
* \param area The area of the effect.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordEffectArea(int area) noexcept;
static void SetRecordEffectArea(int area) noexcept;
/**
* \brief Set the duration of the temporary effect stored on the server.
@ -786,7 +786,7 @@ namespace RecordsDynamicFunctions
* \param duration The duration of the effect.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordEffectDuration(int duration) noexcept;
static void SetRecordEffectDuration(int duration) noexcept;
/**
* \brief Set the maximum magnitude of the temporary effect stored on the server.
@ -794,7 +794,7 @@ namespace RecordsDynamicFunctions
* \param magnitudeMax The maximum magnitude of the effect.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordEffectMagnitudeMax(int magnitudeMax) noexcept;
static void SetRecordEffectMagnitudeMax(int magnitudeMax) noexcept;
/**
* \brief Set the minimum magnitude of the temporary effect stored on the server.
@ -802,7 +802,7 @@ namespace RecordsDynamicFunctions
* \param magnitudeMin The minimum magnitude of the effect.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordEffectMagnitudeMin(int magnitudeMin) noexcept;
static void SetRecordEffectMagnitudeMin(int magnitudeMin) noexcept;
/**
* \brief Set the type of the temporary body part stored on the server.
@ -810,7 +810,7 @@ namespace RecordsDynamicFunctions
* \param partType The type of the body part.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordBodyPartType(unsigned int partType) noexcept;
static void SetRecordBodyPartType(unsigned int partType) noexcept;
/**
* \brief Set the id of the male version of the temporary body part stored on the
@ -819,7 +819,7 @@ namespace RecordsDynamicFunctions
* \param partId The id of the body part.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordBodyPartIdForMale(const char* partId) noexcept;
static void SetRecordBodyPartIdForMale(const char* partId) noexcept;
/**
* \brief Set the id of the female version of the temporary body part stored on the
@ -828,7 +828,7 @@ namespace RecordsDynamicFunctions
* \param partId The id of the body part.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordBodyPartIdForFemale(const char* partId) noexcept;
static void SetRecordBodyPartIdForFemale(const char* partId) noexcept;
/**
* \brief Set the id of the of the temporary inventory item stored on the server.
@ -836,7 +836,7 @@ namespace RecordsDynamicFunctions
* \param partId The id of the inventory item.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordInventoryItemId(const char* itemId) noexcept;
static void SetRecordInventoryItemId(const char* itemId) noexcept;
/**
* \brief Set the count of the of the temporary inventory item stored on the server.
@ -844,7 +844,7 @@ namespace RecordsDynamicFunctions
* \param count The count of the inventory item.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRecordInventoryItemCount(unsigned int count) noexcept;
static void SetRecordInventoryItemCount(unsigned int count) noexcept;
/**
* \brief Add a copy of the server's temporary record of the current specified
@ -855,7 +855,7 @@ namespace RecordsDynamicFunctions
*
* \return void
*/
EXPORT_APIFUNCTION void CDECL AddRecord() noexcept;
static void AddRecord() noexcept;
/**
* \brief Add a copy of the server's temporary effect to the temporary record
@ -866,7 +866,7 @@ namespace RecordsDynamicFunctions
*
* \return void
*/
EXPORT_APIFUNCTION void CDECL AddRecordEffect() noexcept;
static void AddRecordEffect() noexcept;
/**
* \brief Add a copy of the server's temporary body part to the temporary record
@ -877,7 +877,7 @@ namespace RecordsDynamicFunctions
*
* \return void
*/
EXPORT_APIFUNCTION void CDECL AddRecordBodyPart() noexcept;
static void AddRecordBodyPart() noexcept;
/**
* \brief Add a copy of the server's temporary inventory item to the temporary record
@ -891,7 +891,7 @@ namespace RecordsDynamicFunctions
*
* \return void
*/
EXPORT_APIFUNCTION void CDECL AddRecordInventoryItem() noexcept;
static void AddRecordInventoryItem() noexcept;
/**
* \brief Send a RecordDynamic packet with the current specified record type.
@ -903,7 +903,8 @@ namespace RecordsDynamicFunctions
* to the packet (false by default).
* \return void
*/
EXPORT_APIFUNCTION void CDECL SendRecordDynamic(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
}
static void SendRecordDynamic(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept;
};
#endif //OPENMW_RECORDSDYNAMICAPI_HPP

View file

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

View file

@ -3,17 +3,20 @@
#include "../Types.hpp"
#include <Script/Platform.hpp>
#include <Script/Platform.hpp>
#define SERVERAPI \
{"LogMessage", ServerFunctions::LogMessage},\
{"LogAppend", ServerFunctions::LogAppend},\
\
{"StopServer", ServerFunctions::StopServer},\
\
{"Kick", ServerFunctions::Kick},\
{"BanAddress", ServerFunctions::BanAddress},\
{"UnbanAddress", ServerFunctions::UnbanAddress},\
\
{"DoesFilePathExist", ServerFunctions::DoesFilePathExist},\
{"GetCaseInsensitiveFilename", ServerFunctions::GetCaseInsensitiveFilename},\
{"GetDataPath", ServerFunctions::GetDataPath},\
{"GetMillisecondsSinceServerStart", ServerFunctions::GetMillisecondsSinceServerStart},\
{"GetOperatingSystemType", ServerFunctions::GetOperatingSystemType},\
{"GetArchitectureType", ServerFunctions::GetArchitectureType},\
{"GetServerVersion", ServerFunctions::GetServerVersion},\
@ -33,18 +36,48 @@
{"SetScriptErrorIgnoringState", ServerFunctions::SetScriptErrorIgnoringState},\
{"SetRuleString", ServerFunctions::SetRuleString},\
{"SetRuleValue", ServerFunctions::SetRuleValue},\
{"AddPluginHash", ServerFunctions::AddPluginHash},\
{"GetModDir", ServerFunctions::GetModDir}
\
{"AddDataFileRequirement", ServerFunctions::AddDataFileRequirement},\
\
{"DoesFileExist", ServerFunctions::DoesFileExist},\
{"GetModDir", ServerFunctions::GetModDir},\
{"AddPluginHash", ServerFunctions::AddPluginHash}
namespace ServerFunctions
class ServerFunctions
{
public:
/**
* \brief Write a log message with its own timestamp.
*
* It will have "[Script]:" prepended to it so as to mark it as a script-generated log message.
*
* \param level The logging level used (0 for LOG_VERBOSE, 1 for LOG_INFO, 2 for LOG_WARN,
* 3 for LOG_ERROR, 4 for LOG_FATAL).
* \param message The message logged.
* \return void
*/
static void LogMessage(unsigned short level, const char *message) noexcept;
/**
* \brief Write a log message without its own timestamp.
*
* It will have "[Script]:" prepended to it so as to mark it as a script-generated log message.
*
* \param level The logging level used (0 for LOG_VERBOSE, 1 for LOG_INFO, 2 for LOG_WARN,
* 3 for LOG_ERROR, 4 for LOG_FATAL).
* \param message The message logged.
* \return void
*/
static void LogAppend(unsigned short level, const char *message) noexcept;
/**
* \brief Shut down the server.
*
* \param code The shutdown code.
* \return void
*/
EXPORT_APIFUNCTION void CDECL StopServer(int code) noexcept;
static void StopServer(int code) noexcept;
/**
* \brief Kick a certain player from the server.
@ -52,7 +85,7 @@ namespace ServerFunctions
* \param pid The player ID.
* \return void
*/
EXPORT_APIFUNCTION void CDECL Kick(unsigned short pid) noexcept;
static void Kick(unsigned short pid) noexcept;
/**
* \brief Ban a certain IP address from the server.
@ -60,7 +93,7 @@ namespace ServerFunctions
* \param ipAddress The IP address.
* \return void
*/
EXPORT_APIFUNCTION void CDECL BanAddress(const char *ipAddress) noexcept;
static void BanAddress(const char *ipAddress) noexcept;
/**
* \brief Unban a certain IP address from the server.
@ -68,7 +101,42 @@ namespace ServerFunctions
* \param ipAddress The IP address.
* \return void
*/
EXPORT_APIFUNCTION void CDECL UnbanAddress(const char *ipAddress) noexcept;
static void UnbanAddress(const char *ipAddress) noexcept;
/**
* \brief Check whether a certain file path exists.
*
* This will be a case sensitive check on case sensitive filesystems.
*
* Whenever you want to enforce case insensitivity, use GetCaseInsensitiveFilename() instead.
*
* \return Whether the file exists or not.
*/
static bool DoesFilePathExist(const char *filePath) noexcept;
/**
* \brief Get the first filename in a folder that has a case insensitive match with the filename
* argument.
*
* This is used to retain case insensitivity when opening data files on Linux.
*
* \return The filename that matches.
*/
static const char *GetCaseInsensitiveFilename(const char *folderPath, const char *filename) noexcept;
/**
* \brief Get the path of the server's data folder.
*
* \return The data path.
*/
static const char *GetDataPath() noexcept;
/**
* \brief Get the milliseconds elapsed since the server was started.
*
* \return The time since the server's startup in milliseconds.
*/
static unsigned int GetMillisecondsSinceServerStart() noexcept;
/**
* \brief Get the type of the operating system used by the server.
@ -77,7 +145,7 @@ namespace ServerFunctions
*
* \return The type of the operating system.
*/
EXPORT_APIFUNCTION const char *CDECL GetOperatingSystemType() noexcept;
static const char *GetOperatingSystemType() noexcept;
/**
* \brief Get the architecture type used by the server.
@ -86,21 +154,21 @@ namespace ServerFunctions
*
* \return The architecture type.
*/
EXPORT_APIFUNCTION const char *CDECL GetArchitectureType() noexcept;
static const char *GetArchitectureType() noexcept;
/**
* \brief Get the TES3MP version of the server.
*
* \return The server version.
*/
EXPORT_APIFUNCTION const char *CDECL GetServerVersion() noexcept;
static const char *GetServerVersion() noexcept;
/**
* \brief Get the protocol version of the server.
*
* \return The protocol version.
*/
EXPORT_APIFUNCTION const char *CDECL GetProtocolVersion() noexcept;
static const char *GetProtocolVersion() noexcept;
/**
* \brief Get the average ping of a certain player.
@ -108,7 +176,7 @@ namespace ServerFunctions
* \param pid The player ID.
* \return The average ping.
*/
EXPORT_APIFUNCTION int CDECL GetAvgPing(unsigned short pid) noexcept;
static int GetAvgPing(unsigned short pid) noexcept;
/**
* \brief Get the IP address of a certain player.
@ -116,28 +184,28 @@ namespace ServerFunctions
* \param pid The player ID.
* \return The IP address.
*/
EXPORT_APIFUNCTION const CDECL char* GetIP(unsigned short pid) noexcept;
static const char* GetIP(unsigned short pid) noexcept;
/**
* \brief Get the port used by the server.
*
* \return Port
* \return The port.
*/
EXPORT_APIFUNCTION unsigned short CDECL GetPort() noexcept;
static unsigned short GetPort() noexcept;
/**
* \brief Get the maximum number of players.
*
* \return Max players
*/
EXPORT_APIFUNCTION unsigned int CDECL GetMaxPlayers() noexcept;
static unsigned int GetMaxPlayers() noexcept;
/**
* \brief Checking if the server requires a password to connect.
*
* @return
*/
EXPORT_APIFUNCTION bool CDECL HasPassword() noexcept;
static bool HasPassword() noexcept;
/**
* \brief Get the plugin enforcement state of the server.
@ -146,7 +214,7 @@ namespace ServerFunctions
*
* \return The enforcement state.
*/
EXPORT_APIFUNCTION bool CDECL GetPluginEnforcementState() noexcept;
static bool GetPluginEnforcementState() noexcept;
/**
* \brief Get the script error ignoring state of the server.
@ -155,7 +223,7 @@ namespace ServerFunctions
*
* \return The script error ignoring state.
*/
EXPORT_APIFUNCTION bool CDECL GetScriptErrorIgnoringState() noexcept;
static bool GetScriptErrorIgnoringState() noexcept;
/**
* \brief Set the game mode of the server, as displayed in the server browser.
@ -163,7 +231,7 @@ namespace ServerFunctions
* \param name The new game mode.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetGameMode(const char* gameMode) noexcept;
static void SetGameMode(const char* gameMode) noexcept;
/**
* \brief Set the name of the server, as displayed in the server browser.
@ -171,7 +239,7 @@ namespace ServerFunctions
* \param name The new name.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetHostname(const char* name) noexcept;
static void SetHostname(const char* name) noexcept;
/**
* \brief Set the password required to join the server.
@ -179,7 +247,7 @@ namespace ServerFunctions
* \param password The password.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetServerPassword(const char *password) noexcept;
static void SetServerPassword(const char *password) noexcept;
/**
* \brief Set the plugin enforcement state of the server.
@ -189,7 +257,7 @@ namespace ServerFunctions
* \param state The new enforcement state.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetPluginEnforcementState(bool state) noexcept;
static void SetPluginEnforcementState(bool state) noexcept;
/**
* \brief Set whether script errors should be ignored or not.
@ -201,7 +269,7 @@ namespace ServerFunctions
* \param state The new script error ignoring state.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetScriptErrorIgnoringState(bool state) noexcept;
static void SetScriptErrorIgnoringState(bool state) noexcept;
/**
* \brief Set a rule string for the server details displayed in the server browser.
@ -210,7 +278,7 @@ namespace ServerFunctions
* \param value The string value of the rule.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRuleString(const char *key, const char *value) noexcept;
static void SetRuleString(const char *key, const char *value) noexcept;
/**
* \brief Set a rule value for the server details displayed in the server browser.
@ -219,16 +287,27 @@ namespace ServerFunctions
* \param value The numerical value of the rule.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRuleValue(const char *key, double value) noexcept;
static void 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
* \brief Add a data file and a corresponding CRC32 checksum to the data file loadout
* that connecting clients need to match.
*
* It can be used multiple times to set multiple checksums for the same data file.
*
* Note: If an empty string is provided for the checksum, a checksum will not be
* required for that data file.
*
* @param dataFilename The filename of the data file.
* @param checksumString A string with the CRC32 checksum required.
*/
EXPORT_APIFUNCTION void CDECL AddPluginHash(const char *pluginName, const char *hash) noexcept;
static void AddDataFileRequirement(const char *dataFilename, const char *checksumString) noexcept;
EXPORT_APIFUNCTION const char *CDECL GetModDir() noexcept;
}
// All methods below are deprecated versions of methods from above
static bool DoesFileExist(const char *filePath) noexcept;
static const char *GetModDir() noexcept;
static void AddPluginHash(const char *pluginName, const char *checksumString) noexcept;
};
#endif //OPENMW_SERVERAPI_HPP

View file

@ -9,7 +9,7 @@
#include <iostream>
using namespace std;
extern "C" void SettingFunctions::SetDifficulty(unsigned short pid, int difficulty)
void SettingFunctions::SetDifficulty(unsigned short 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)
void SettingFunctions::SetEnforcedLogLevel(unsigned short 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)
void SettingFunctions::SetPhysicsFramerate(unsigned short 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)
void SettingFunctions::SetConsoleAllowed(unsigned short 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)
void SettingFunctions::SetBedRestAllowed(unsigned short 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)
void SettingFunctions::SetWildernessRestAllowed(unsigned short 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)
void SettingFunctions::SetWaitAllowed(unsigned short 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
void SettingFunctions::SendSettings(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player,);

View file

@ -3,8 +3,6 @@
#include "../Types.hpp"
#include <Script/Platform.hpp>
#define SETTINGSAPI \
{"SetDifficulty", SettingFunctions::SetDifficulty},\
{"SetEnforcedLogLevel", SettingFunctions::SetEnforcedLogLevel},\
@ -17,8 +15,10 @@
\
{"SendSettings", SettingFunctions::SendSettings}
namespace SettingFunctions
class SettingFunctions
{
public:
/**
* \brief Set the difficulty for a player.
*
@ -29,7 +29,7 @@ namespace SettingFunctions
* \param difficulty The difficulty.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetDifficulty(unsigned short pid, int difficulty);
static void SetDifficulty(unsigned short pid, int difficulty);
/**
* \brief Set the client log level enforced for a player.
@ -47,7 +47,7 @@ namespace SettingFunctions
* \param enforcedLogLevel The enforced log level.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetEnforcedLogLevel(unsigned short pid, int enforcedLogLevel);
static void SetEnforcedLogLevel(unsigned short pid, int enforcedLogLevel);
/**
* \brief Set the physics framerate for a player.
@ -59,7 +59,7 @@ namespace SettingFunctions
* \param physicsFramerate The physics framerate.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetPhysicsFramerate(unsigned short pid, double physicsFramerate);
static void SetPhysicsFramerate(unsigned short pid, double physicsFramerate);
/**
* \brief Set whether the console is allowed for a player.
@ -71,7 +71,7 @@ namespace SettingFunctions
* \param state The console permission state.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetConsoleAllowed(unsigned short pid, bool state);
static void SetConsoleAllowed(unsigned short pid, bool state);
/**
* \brief Set whether resting in beds is allowed for a player.
@ -83,7 +83,7 @@ namespace SettingFunctions
* \param state The resting permission state.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetBedRestAllowed(unsigned short pid, bool state);
static void SetBedRestAllowed(unsigned short pid, bool state);
/**
* \brief Set whether resting in the wilderness is allowed for a player.
@ -95,7 +95,7 @@ namespace SettingFunctions
* \param state The resting permission state.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetWildernessRestAllowed(unsigned short pid, bool state);
static void SetWildernessRestAllowed(unsigned short pid, bool state);
/**
* \brief Set whether waiting is allowed for a player.
@ -107,7 +107,7 @@ namespace SettingFunctions
* \param state The waiting permission state.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetWaitAllowed(unsigned short pid, bool state);
static void SetWaitAllowed(unsigned short pid, bool state);
/**
* \brief Send a PlayerSettings packet to the player affected by it.
@ -115,7 +115,7 @@ namespace SettingFunctions
* \param pid The player ID to send it to.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SendSettings(unsigned short pid) noexcept;
}
static void SendSettings(unsigned short pid) noexcept;
};
#endif //OPENMW_SETTINGSAPI_HPP

View file

@ -9,7 +9,7 @@
#include <iostream>
using namespace std;
extern "C" double ShapeshiftFunctions::GetScale(unsigned short pid) noexcept
double ShapeshiftFunctions::GetScale(unsigned short 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
bool ShapeshiftFunctions::IsWerewolf(unsigned short 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
const char *ShapeshiftFunctions::GetCreatureRefId(unsigned short 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
bool ShapeshiftFunctions::GetCreatureNameDisplayState(unsigned short 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
void ShapeshiftFunctions::SetScale(unsigned short 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
void ShapeshiftFunctions::SetWerewolfState(unsigned short 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
void ShapeshiftFunctions::SetCreatureRefId(unsigned short 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
void ShapeshiftFunctions::SetCreatureNameDisplayState(unsigned short 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)
void ShapeshiftFunctions::SendShapeshift(unsigned short pid)
{
Player *player;
GET_PLAYER(pid, player, );

View file

@ -3,8 +3,6 @@
#include "../Types.hpp"
#include <Script/Platform.hpp>
#define SHAPESHIFTAPI \
{"GetScale", ShapeshiftFunctions::GetScale},\
{"IsWerewolf", ShapeshiftFunctions::IsWerewolf},\
@ -18,15 +16,17 @@
\
{"SendShapeshift", ShapeshiftFunctions::SendShapeshift}
namespace ShapeshiftFunctions
class ShapeshiftFunctions
{
public:
/**
* \brief Get the scale of a player.
*
* \param pid The player ID.
* \return The scale.
*/
EXPORT_APIFUNCTION double CDECL GetScale(unsigned short pid) noexcept;
static double GetScale(unsigned short pid) noexcept;
/**
* \brief Check whether a player is a werewolf.
@ -36,7 +36,7 @@ namespace ShapeshiftFunctions
* \param pid The player ID.
* \return The werewolf state.
*/
EXPORT_APIFUNCTION bool CDECL IsWerewolf(unsigned short pid) noexcept;
static bool IsWerewolf(unsigned short pid) noexcept;
/**
* \brief Get the refId of the creature the player is disguised as.
@ -44,7 +44,7 @@ namespace ShapeshiftFunctions
* \param pid The player ID.
* \return The creature refId.
*/
EXPORT_APIFUNCTION const char *CDECL GetCreatureRefId(unsigned short pid) noexcept;
static const char *GetCreatureRefId(unsigned short pid) noexcept;
/**
* \brief Check whether a player's name is replaced by that of the creature they are
@ -55,7 +55,7 @@ namespace ShapeshiftFunctions
* \param pid The player ID.
* \return The creature name display state.
*/
EXPORT_APIFUNCTION bool CDECL GetCreatureNameDisplayState(unsigned short pid) noexcept;
static bool GetCreatureNameDisplayState(unsigned short pid) noexcept;
/**
* \brief Set the scale of a player.
@ -67,7 +67,7 @@ namespace ShapeshiftFunctions
* \param scale The new scale.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetScale(unsigned short pid, double scale) noexcept;
static void SetScale(unsigned short pid, double scale) noexcept;
/**
* \brief Set the werewolf state of a player.
@ -79,7 +79,7 @@ namespace ShapeshiftFunctions
* \param isWerewolf The new werewolf state.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetWerewolfState(unsigned short pid, bool isWerewolf) noexcept;
static void SetWerewolfState(unsigned short pid, bool isWerewolf) noexcept;
/**
* \brief Set the refId of the creature a player is disguised as.
@ -93,7 +93,7 @@ namespace ShapeshiftFunctions
* when hovered over by others.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetCreatureRefId(unsigned short pid, const char *refId) noexcept;
static void SetCreatureRefId(unsigned short pid, const char *refId) noexcept;
/**
* \brief Set whether a player's name is replaced by that of the creature they are
@ -103,7 +103,7 @@ namespace ShapeshiftFunctions
* \param displayState The creature name display state.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetCreatureNameDisplayState(unsigned short pid, bool displayState) noexcept;
static void SetCreatureNameDisplayState(unsigned short pid, bool displayState) noexcept;
/**
* \brief Send a PlayerShapeshift packet about a player.
@ -114,7 +114,7 @@ namespace ShapeshiftFunctions
* \param pid The player ID.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SendShapeshift(unsigned short pid);
}
static void SendShapeshift(unsigned short pid);
};
#endif //OPENMW_SHAPESHIFTAPI_HPP

View file

@ -8,7 +8,7 @@
using namespace mwmp;
extern "C" void SpellFunctions::ClearSpellbookChanges(unsigned short pid) noexcept
void SpellFunctions::ClearSpellbookChanges(unsigned short 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
unsigned int SpellFunctions::GetSpellbookChangesSize(unsigned short 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
unsigned int SpellFunctions::GetSpellbookChangesAction(unsigned short 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
void SpellFunctions::SetSpellbookChangesAction(unsigned short 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
void SpellFunctions::AddSpell(unsigned short 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
const char *SpellFunctions::GetSpellId(unsigned short 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
void SpellFunctions::SendSpellbookChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -76,7 +76,7 @@ extern "C" void SpellFunctions::SendSpellbookChanges(unsigned short pid, bool se
packet->Send(true);
}
extern "C" // All methods below are deprecated versions of methods from above
// All methods below are deprecated versions of methods from above
void SpellFunctions::InitializeSpellbookChanges(unsigned short pid) noexcept
{

View file

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

View file

@ -14,17 +14,17 @@
using namespace std;
using namespace ESM;
extern "C" int StatsFunctions::GetAttributeCount() noexcept
int StatsFunctions::GetAttributeCount() noexcept
{
return Attribute::Length;
}
extern "C" int StatsFunctions::GetSkillCount() noexcept
int StatsFunctions::GetSkillCount() noexcept
{
return Skill::Length;
}
extern "C" int StatsFunctions::GetAttributeId(const char *name) noexcept
int StatsFunctions::GetAttributeId(const char *name) noexcept
{
for (int x = 0; x < Attribute::Length; x++)
{
@ -37,7 +37,7 @@ extern "C" int StatsFunctions::GetAttributeId(const char *name) noexcept
return -1;
}
extern "C" int StatsFunctions::GetSkillId(const char *name) noexcept
int StatsFunctions::GetSkillId(const char *name) noexcept
{
for (int x = 0; x < Skill::Length; x++)
{
@ -50,7 +50,7 @@ extern "C" int StatsFunctions::GetSkillId(const char *name) noexcept
return -1;
}
extern "C" const char *StatsFunctions::GetAttributeName(unsigned short attributeId) noexcept
const char *StatsFunctions::GetAttributeName(unsigned short attributeId) noexcept
{
if (attributeId >= Attribute::Length)
return "invalid";
@ -58,7 +58,7 @@ extern "C" const char *StatsFunctions::GetAttributeName(unsigned short attribute
return Attribute::sAttributeNames[attributeId].c_str();
}
extern "C" const char *StatsFunctions::GetSkillName(unsigned short skillId) noexcept
const char *StatsFunctions::GetSkillName(unsigned short skillId) noexcept
{
if (skillId >= Skill::Length)
return "invalid";
@ -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
const char *StatsFunctions::GetName(unsigned short 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
const char *StatsFunctions::GetRace(unsigned short 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
const char *StatsFunctions::GetHead(unsigned short 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
const char *StatsFunctions::GetHairstyle(unsigned short 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
int StatsFunctions::GetIsMale(unsigned short 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
const char *StatsFunctions::GetBirthsign(unsigned short 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
int StatsFunctions::GetLevel(unsigned short 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
int StatsFunctions::GetLevelProgress(unsigned short 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
double StatsFunctions::GetHealthBase(unsigned short 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
double StatsFunctions::GetHealthCurrent(unsigned short 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
double StatsFunctions::GetMagickaBase(unsigned short 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
double StatsFunctions::GetMagickaCurrent(unsigned short 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
double StatsFunctions::GetFatigueBase(unsigned short 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
double StatsFunctions::GetFatigueCurrent(unsigned short 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
int StatsFunctions::GetAttributeBase(unsigned short 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
int StatsFunctions::GetAttributeModifier(unsigned short pid, unsigned short attributeId) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -201,7 +201,18 @@ 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
double StatsFunctions::GetAttributeDamage(unsigned short pid, unsigned short attributeId) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
if (attributeId >= Attribute::Length)
return 0;
return player->creatureStats.mAttributes[attributeId].mDamage;
}
int StatsFunctions::GetSkillBase(unsigned short pid, unsigned short skillId) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -212,7 +223,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
int StatsFunctions::GetSkillModifier(unsigned short pid, unsigned short skillId) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -223,7 +234,18 @@ 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
double StatsFunctions::GetSkillDamage(unsigned short pid, unsigned short skillId) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
if (skillId >= Skill::Length)
return 0;
return player->npcStats.mSkills[skillId].mDamage;
}
double StatsFunctions::GetSkillProgress(unsigned short pid, unsigned short skillId) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0.0f);
@ -234,18 +256,18 @@ 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
int StatsFunctions::GetSkillIncrease(unsigned short pid, unsigned int attributeId) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
if (attributeId >= Attribute::Length)
if (attributeId > Attribute::Length)
return 0;
return player->npcStats.mSkillIncrease[attributeId];
}
extern "C" int StatsFunctions::GetBounty(unsigned short pid) noexcept
int StatsFunctions::GetBounty(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
@ -253,7 +275,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
void StatsFunctions::SetName(unsigned short pid, const char *name) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -264,7 +286,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
void StatsFunctions::SetRace(unsigned short pid, const char *race) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -278,7 +300,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
void StatsFunctions::SetHead(unsigned short pid, const char *head) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -289,7 +311,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
void StatsFunctions::SetHairstyle(unsigned short pid, const char *hairstyle) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -300,7 +322,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
void StatsFunctions::SetIsMale(unsigned short pid, int state) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -308,7 +330,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
void StatsFunctions::SetBirthsign(unsigned short pid, const char *sign) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -319,7 +341,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
void StatsFunctions::SetResetStats(unsigned short pid, bool resetStats) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -327,7 +349,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
void StatsFunctions::SetLevel(unsigned short pid, int value) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -335,7 +357,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
void StatsFunctions::SetLevelProgress(unsigned short pid, int value) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -343,7 +365,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
void StatsFunctions::SetHealthBase(unsigned short pid, double value) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -354,7 +376,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
void StatsFunctions::SetHealthCurrent(unsigned short pid, double value) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -365,7 +387,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
void StatsFunctions::SetMagickaBase(unsigned short pid, double value) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -376,7 +398,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
void StatsFunctions::SetMagickaCurrent(unsigned short pid, double value) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -387,7 +409,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
void StatsFunctions::SetFatigueBase(unsigned short pid, double value) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -398,7 +420,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
void StatsFunctions::SetFatigueCurrent(unsigned short pid, double value) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -409,7 +431,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
void StatsFunctions::SetAttributeBase(unsigned short pid, unsigned short attributeId, int value) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -423,7 +445,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
void StatsFunctions::ClearAttributeModifier(unsigned short pid, unsigned short attributeId) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -437,7 +459,21 @@ 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
void StatsFunctions::SetAttributeDamage(unsigned short pid, unsigned short attributeId, double value) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
if (attributeId >= Attribute::Length)
return;
player->creatureStats.mAttributes[attributeId].mDamage = value;
if (!Utils::vectorContains(player->attributeIndexChanges, attributeId))
player->attributeIndexChanges.push_back(attributeId);
}
void StatsFunctions::SetSkillBase(unsigned short pid, unsigned short skillId, int value) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -451,7 +487,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
void StatsFunctions::ClearSkillModifier(unsigned short pid, unsigned short skillId) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -465,7 +501,21 @@ 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
void StatsFunctions::SetSkillDamage(unsigned short pid, unsigned short skillId, double value) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
if (skillId >= Skill::Length)
return;
player->npcStats.mSkills[skillId].mDamage = value;
if (!Utils::vectorContains(player->skillIndexChanges, skillId))
player->skillIndexChanges.push_back(skillId);
}
void StatsFunctions::SetSkillProgress(unsigned short pid, unsigned short skillId, double value) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -479,12 +529,12 @@ 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
void StatsFunctions::SetSkillIncrease(unsigned short pid, unsigned int attributeId, int value) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
if (attributeId >= Attribute::Length)
if (attributeId > Attribute::Length)
return;
player->npcStats.mSkillIncrease[attributeId] = value;
@ -493,7 +543,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
void StatsFunctions::SetBounty(unsigned short pid, int value) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -501,7 +551,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
void StatsFunctions::SetCharGenStage(unsigned short pid, int currentStage, int endStage) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -516,7 +566,7 @@ extern "C" void StatsFunctions::SetCharGenStage(unsigned short pid, int currentS
packet->Send(false);
}
extern "C" void StatsFunctions::SendBaseInfo(unsigned short pid) noexcept
void StatsFunctions::SendBaseInfo(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -528,7 +578,7 @@ extern "C" void StatsFunctions::SendBaseInfo(unsigned short pid) noexcept
packet->Send(true);
}
extern "C" void StatsFunctions::SendStatsDynamic(unsigned short pid) noexcept
void StatsFunctions::SendStatsDynamic(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -542,7 +592,7 @@ extern "C" void StatsFunctions::SendStatsDynamic(unsigned short pid) noexcept
player->statsDynamicIndexChanges.clear();
}
extern "C" void StatsFunctions::SendAttributes(unsigned short pid) noexcept
void StatsFunctions::SendAttributes(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -556,7 +606,7 @@ extern "C" void StatsFunctions::SendAttributes(unsigned short pid) noexcept
player->attributeIndexChanges.clear();
}
extern "C" void StatsFunctions::SendSkills(unsigned short pid) noexcept
void StatsFunctions::SendSkills(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -570,7 +620,7 @@ extern "C" void StatsFunctions::SendSkills(unsigned short pid) noexcept
player->skillIndexChanges.clear();
}
extern "C" void StatsFunctions::SendLevel(unsigned short pid) noexcept
void StatsFunctions::SendLevel(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
@ -582,7 +632,7 @@ extern "C" void StatsFunctions::SendLevel(unsigned short pid) noexcept
packet->Send(true);
}
extern "C" void StatsFunctions::SendBounty(unsigned short pid) noexcept
void StatsFunctions::SendBounty(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );

View file

@ -1,8 +1,6 @@
#ifndef OPENMW_STATAPI_HPP
#define OPENMW_STATAPI_HPP
#include <Script/Platform.hpp>
#define STATAPI \
{"GetAttributeCount", StatsFunctions::GetAttributeCount},\
{"GetSkillCount", StatsFunctions::GetSkillCount},\
@ -32,9 +30,11 @@
\
{"GetAttributeBase", StatsFunctions::GetAttributeBase},\
{"GetAttributeModifier", StatsFunctions::GetAttributeModifier},\
{"GetAttributeDamage", StatsFunctions::GetAttributeDamage},\
\
{"GetSkillBase", StatsFunctions::GetSkillBase},\
{"GetSkillModifier", StatsFunctions::GetSkillModifier},\
{"GetSkillDamage", StatsFunctions::GetSkillDamage},\
{"GetSkillProgress", StatsFunctions::GetSkillProgress},\
{"GetSkillIncrease", StatsFunctions::GetSkillIncrease},\
\
@ -60,9 +60,11 @@
\
{"SetAttributeBase", StatsFunctions::SetAttributeBase},\
{"ClearAttributeModifier", StatsFunctions::ClearAttributeModifier},\
{"SetAttributeDamage", StatsFunctions::SetAttributeDamage},\
\
{"SetSkillBase", StatsFunctions::SetSkillBase},\
{"ClearSkillModifier", StatsFunctions::ClearSkillModifier},\
{"SetSkillDamage", StatsFunctions::SetSkillDamage},\
{"SetSkillProgress", StatsFunctions::SetSkillProgress},\
{"SetSkillIncrease", StatsFunctions::SetSkillIncrease},\
\
@ -77,8 +79,10 @@
{"SendLevel", StatsFunctions::SendLevel},\
{"SendBounty", StatsFunctions::SendBounty}
namespace StatsFunctions
class StatsFunctions
{
public:
/**
* \brief Get the number of attributes.
*
@ -86,7 +90,7 @@ namespace StatsFunctions
*
* \return The number of attributes.
*/
EXPORT_APIFUNCTION int CDECL GetAttributeCount() noexcept;
static int GetAttributeCount() noexcept;
/**
* \brief Get the number of skills.
@ -95,7 +99,7 @@ namespace StatsFunctions
*
* \return The number of skills.
*/
EXPORT_APIFUNCTION int CDECL GetSkillCount() noexcept;
static int GetSkillCount() noexcept;
/**
* \brief Get the numerical ID of an attribute with a certain name.
@ -105,7 +109,7 @@ namespace StatsFunctions
* \param name The name of the attribute.
* \return The ID of the attribute.
*/
EXPORT_APIFUNCTION int CDECL GetAttributeId(const char *name) noexcept;
static int GetAttributeId(const char *name) noexcept;
/**
* \brief Get the numerical ID of a skill with a certain name.
@ -115,7 +119,7 @@ namespace StatsFunctions
* \param name The name of the skill.
* \return The ID of the skill.
*/
EXPORT_APIFUNCTION int CDECL GetSkillId(const char *name) noexcept;
static int GetSkillId(const char *name) noexcept;
/**
* \brief Get the name of the attribute with a certain numerical ID.
@ -125,7 +129,7 @@ namespace StatsFunctions
* \param attributeId The ID of the attribute.
* \return The name of the attribute.
*/
EXPORT_APIFUNCTION const char *CDECL GetAttributeName(unsigned short attributeId) noexcept;
static const char *GetAttributeName(unsigned short attributeId) noexcept;
/**
* \brief Get the name of the skill with a certain numerical ID.
@ -135,7 +139,7 @@ namespace StatsFunctions
* \param skillId The ID of the skill.
* \return The name of the skill.
*/
EXPORT_APIFUNCTION const char *CDECL GetSkillName(unsigned short skillId) noexcept;
static const char *GetSkillName(unsigned short skillId) noexcept;
/**
* \brief Get the name of a player.
@ -143,7 +147,7 @@ namespace StatsFunctions
* \param pid The player ID.
* \return The name of the player.
*/
EXPORT_APIFUNCTION const char *CDECL GetName(unsigned short pid) noexcept;
static const char *GetName(unsigned short pid) noexcept;
/**
* \brief Get the race of a player.
@ -151,7 +155,7 @@ namespace StatsFunctions
* \param pid The player ID.
* \return The race of the player.
*/
EXPORT_APIFUNCTION const char *CDECL GetRace(unsigned short pid) noexcept;
static const char *GetRace(unsigned short pid) noexcept;
/**
* \brief Get the head mesh used by a player.
@ -159,7 +163,7 @@ namespace StatsFunctions
* \param pid The player ID.
* \return The head mesh of the player.
*/
EXPORT_APIFUNCTION const char *CDECL GetHead(unsigned short pid) noexcept;
static const char *GetHead(unsigned short pid) noexcept;
/**
* \brief Get the hairstyle mesh used by a player.
@ -167,7 +171,7 @@ namespace StatsFunctions
* \param pid The player ID.
* \return The hairstyle mesh of the player.
*/
EXPORT_APIFUNCTION const char *CDECL GetHairstyle(unsigned short pid) noexcept;
static const char *GetHairstyle(unsigned short pid) noexcept;
/**
* \brief Check whether a player is male or not.
@ -175,7 +179,7 @@ namespace StatsFunctions
* \param pid The player ID.
* \return Whether the player is male.
*/
EXPORT_APIFUNCTION int CDECL GetIsMale(unsigned short pid) noexcept;
static int GetIsMale(unsigned short pid) noexcept;
/**
* \brief Get the birthsign of a player.
@ -183,7 +187,7 @@ namespace StatsFunctions
* \param pid The player ID.
* \return The birthsign of the player.
*/
EXPORT_APIFUNCTION const char *CDECL GetBirthsign(unsigned short pid) noexcept;
static const char *GetBirthsign(unsigned short pid) noexcept;
/**
* \brief Get the character level of a player.
@ -191,7 +195,7 @@ namespace StatsFunctions
* \param pid The player ID.
* \return The level of the player.
*/
EXPORT_APIFUNCTION int CDECL GetLevel(unsigned short pid) noexcept;
static int GetLevel(unsigned short pid) noexcept;
/**
* \brief Get the player's progress to their next character level.
@ -199,7 +203,7 @@ namespace StatsFunctions
* \param pid The player ID.
* \return The level progress.
*/
EXPORT_APIFUNCTION int CDECL GetLevelProgress(unsigned short pid) noexcept;
static int GetLevelProgress(unsigned short pid) noexcept;
/**
* \brief Get the base health of the player.
@ -207,7 +211,7 @@ namespace StatsFunctions
* \param pid The player ID.
* \return The base health.
*/
EXPORT_APIFUNCTION double CDECL GetHealthBase(unsigned short pid) noexcept;
static double GetHealthBase(unsigned short pid) noexcept;
/**
* \brief Get the current health of the player.
@ -215,7 +219,7 @@ namespace StatsFunctions
* \param pid The player ID.
* \return The current health.
*/
EXPORT_APIFUNCTION double CDECL GetHealthCurrent(unsigned short pid) noexcept;
static double GetHealthCurrent(unsigned short pid) noexcept;
/**
* \brief Get the base magicka of the player.
@ -223,7 +227,7 @@ namespace StatsFunctions
* \param pid The player ID.
* \return The base magicka.
*/
EXPORT_APIFUNCTION double CDECL GetMagickaBase(unsigned short pid) noexcept;
static double GetMagickaBase(unsigned short pid) noexcept;
/**
* \brief Get the current magicka of the player.
@ -231,7 +235,7 @@ namespace StatsFunctions
* \param pid The player ID.
* \return The current magicka.
*/
EXPORT_APIFUNCTION double CDECL GetMagickaCurrent(unsigned short pid) noexcept;
static double GetMagickaCurrent(unsigned short pid) noexcept;
/**
* \brief Get the base fatigue of the player.
@ -239,7 +243,7 @@ namespace StatsFunctions
* \param pid The player ID.
* \return The base fatigue.
*/
EXPORT_APIFUNCTION double CDECL GetFatigueBase(unsigned short pid) noexcept;
static double GetFatigueBase(unsigned short pid) noexcept;
/**
* \brief Get the current fatigue of the player.
@ -247,7 +251,7 @@ namespace StatsFunctions
* \param pid The player ID.
* \return The current fatigue.
*/
EXPORT_APIFUNCTION double CDECL GetFatigueCurrent(unsigned short pid) noexcept;
static double GetFatigueCurrent(unsigned short pid) noexcept;
/**
* \brief Get the base value of a player's attribute.
@ -256,7 +260,7 @@ namespace StatsFunctions
* \param attributeId The attribute ID.
* \return The base value of the attribute.
*/
EXPORT_APIFUNCTION int CDECL GetAttributeBase(unsigned short pid, unsigned short attributeId) noexcept;
static int GetAttributeBase(unsigned short pid, unsigned short attributeId) noexcept;
/**
* \brief Get the modifier value of a player's attribute.
@ -265,7 +269,17 @@ namespace StatsFunctions
* \param attributeId The attribute ID.
* \return The modifier value of the attribute.
*/
EXPORT_APIFUNCTION int CDECL GetAttributeModifier(unsigned short pid, unsigned short attributeId) noexcept;
static int GetAttributeModifier(unsigned short pid, unsigned short attributeId) noexcept;
/**
* \brief Get the amount of damage (as caused through the Damage Attribute effect)
* to a player's attribute.
*
* \param pid The player ID.
* \param attributeId The attribute ID.
* \return The amount of damage to the attribute.
*/
static double GetAttributeDamage(unsigned short pid, unsigned short attributeId) noexcept;
/**
* \brief Get the base value of a player's skill.
@ -274,7 +288,7 @@ namespace StatsFunctions
* \param skillId The skill ID.
* \return The base value of the skill.
*/
EXPORT_APIFUNCTION int CDECL GetSkillBase(unsigned short pid, unsigned short skillId) noexcept;
static int GetSkillBase(unsigned short pid, unsigned short skillId) noexcept;
/**
* \brief Get the modifier value of a player's skill.
@ -283,7 +297,17 @@ namespace StatsFunctions
* \param skillId The skill ID.
* \return The modifier value of the skill.
*/
EXPORT_APIFUNCTION int CDECL GetSkillModifier(unsigned short pid, unsigned short skillId) noexcept;
static int GetSkillModifier(unsigned short pid, unsigned short skillId) noexcept;
/**
* \brief Get the amount of damage (as caused through the Damage Skill effect)
* to a player's skill.
*
* \param pid The player ID.
* \param skillId The skill ID.
* \return The amount of damage to the skill.
*/
static double GetSkillDamage(unsigned short pid, unsigned short skillId) noexcept;
/**
* \brief Get the progress the player has made towards increasing a certain skill by 1.
@ -292,7 +316,7 @@ namespace StatsFunctions
* \param skillId The skill ID.
* \return The skill progress.
*/
EXPORT_APIFUNCTION double CDECL GetSkillProgress(unsigned short pid, unsigned short skillId) noexcept;
static double GetSkillProgress(unsigned short pid, unsigned short skillId) noexcept;
/**
* \brief Get the bonus applied to a certain attribute at the next level up as a result
@ -304,7 +328,7 @@ namespace StatsFunctions
* \param skillId The attribute ID.
* \return The increase in the attribute caused by skills.
*/
EXPORT_APIFUNCTION int CDECL GetSkillIncrease(unsigned short pid, unsigned int attributeId) noexcept;
static int GetSkillIncrease(unsigned short pid, unsigned int attributeId) noexcept;
/**
* \brief Get the bounty of the player.
@ -312,7 +336,7 @@ namespace StatsFunctions
* \param pid The player ID.
* \return The bounty.
*/
EXPORT_APIFUNCTION int CDECL GetBounty(unsigned short pid) noexcept;
static int GetBounty(unsigned short pid) noexcept;
/**
* \brief Set the name of a player.
@ -321,7 +345,7 @@ namespace StatsFunctions
* \param name The new name of the player.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetName(unsigned short pid, const char *name) noexcept;
static void SetName(unsigned short pid, const char *name) noexcept;
/**
* \brief Set the race of a player.
@ -330,7 +354,7 @@ namespace StatsFunctions
* \param race The new race of the player.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetRace(unsigned short pid, const char *race) noexcept;
static void SetRace(unsigned short pid, const char *race) noexcept;
/**
* \brief Set the head mesh used by a player.
@ -339,7 +363,7 @@ namespace StatsFunctions
* \param head The new head mesh of the player.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetHead(unsigned short pid, const char *head) noexcept;
static void SetHead(unsigned short pid, const char *head) noexcept;
/**
* \brief Set the hairstyle mesh used by a player.
@ -348,7 +372,7 @@ namespace StatsFunctions
* \param hairstyle The new hairstyle mesh of the player.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetHairstyle(unsigned short pid, const char *hairstyle) noexcept;
static void SetHairstyle(unsigned short pid, const char *hairstyle) noexcept;
/**
* \brief Set whether a player is male or not.
@ -357,7 +381,7 @@ namespace StatsFunctions
* \param state Whether the player is male.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetIsMale(unsigned short pid, int state) noexcept;
static void SetIsMale(unsigned short pid, int state) noexcept;
/**
* \brief Set the birthsign of a player.
@ -366,7 +390,7 @@ namespace StatsFunctions
* \param name The new birthsign of the player.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetBirthsign(unsigned short pid, const char *name) noexcept;
static void SetBirthsign(unsigned short pid, const char *name) noexcept;
/**
* \brief Set whether the player's stats should be reset based on their
@ -379,7 +403,7 @@ namespace StatsFunctions
* \param resetStats The stat reset state.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetResetStats(unsigned short pid, bool resetStats) noexcept;
static void SetResetStats(unsigned short pid, bool resetStats) noexcept;
/**
* \brief Set the character level of a player.
@ -388,7 +412,7 @@ namespace StatsFunctions
* \param value The new level of the player.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetLevel(unsigned short pid, int value) noexcept;
static void SetLevel(unsigned short pid, int value) noexcept;
/**
* \brief Set the player's progress to their next character level.
@ -397,7 +421,7 @@ namespace StatsFunctions
* \param value The new level progress of the player.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetLevelProgress(unsigned short pid, int value) noexcept;
static void SetLevelProgress(unsigned short pid, int value) noexcept;
/**
* \brief Set the base health of a player.
@ -406,7 +430,7 @@ namespace StatsFunctions
* \param name The new base health of the player.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetHealthBase(unsigned short pid, double value) noexcept;
static void SetHealthBase(unsigned short pid, double value) noexcept;
/**
* \brief Set the current health of a player.
@ -415,7 +439,7 @@ namespace StatsFunctions
* \param name The new current health of the player.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetHealthCurrent(unsigned short pid, double value) noexcept;
static void SetHealthCurrent(unsigned short pid, double value) noexcept;
/**
* \brief Set the base magicka of a player.
@ -424,7 +448,7 @@ namespace StatsFunctions
* \param name The new base magicka of the player.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetMagickaBase(unsigned short pid, double value) noexcept;
static void SetMagickaBase(unsigned short pid, double value) noexcept;
/**
* \brief Set the current magicka of a player.
@ -433,7 +457,7 @@ namespace StatsFunctions
* \param name The new current magicka of the player.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetMagickaCurrent(unsigned short pid, double value) noexcept;
static void SetMagickaCurrent(unsigned short pid, double value) noexcept;
/**
* \brief Set the base fatigue of a player.
@ -442,7 +466,7 @@ namespace StatsFunctions
* \param name The new base fatigue of the player.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetFatigueBase(unsigned short pid, double value) noexcept;
static void SetFatigueBase(unsigned short pid, double value) noexcept;
/**
* \brief Set the current fatigue of a player.
@ -451,7 +475,7 @@ namespace StatsFunctions
* \param name The new current fatigue of the player.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetFatigueCurrent(unsigned short pid, double value) noexcept;
static void SetFatigueCurrent(unsigned short pid, double value) noexcept;
/**
* \brief Set the base value of a player's attribute.
@ -461,7 +485,7 @@ namespace StatsFunctions
* \param value The new base value of the player's attribute.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetAttributeBase(unsigned short pid, unsigned short attributeId, int value) noexcept;
static void SetAttributeBase(unsigned short pid, unsigned short attributeId, int value) noexcept;
/**
* \brief Clear the modifier value of a player's attribute.
@ -475,7 +499,18 @@ namespace StatsFunctions
* \param attributeId The attribute ID.
* \return void
*/
EXPORT_APIFUNCTION void CDECL ClearAttributeModifier(unsigned short pid, unsigned short attributeId) noexcept;
static void ClearAttributeModifier(unsigned short pid, unsigned short attributeId) noexcept;
/**
* \brief Set the amount of damage (as caused through the Damage Attribute effect) to
* a player's attribute.
*
* \param pid The player ID.
* \param attributeId The attribute ID.
* \param value The amount of damage to the player's attribute.
* \return void
*/
static void SetAttributeDamage(unsigned short pid, unsigned short attributeId, double value) noexcept;
/**
* \brief Set the base value of a player's skill.
@ -485,7 +520,7 @@ namespace StatsFunctions
* \param value The new base value of the player's skill.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetSkillBase(unsigned short pid, unsigned short skillId, int value) noexcept;
static void SetSkillBase(unsigned short pid, unsigned short skillId, int value) noexcept;
/**
* \brief Clear the modifier value of a player's skill.
@ -499,7 +534,18 @@ namespace StatsFunctions
* \param skillId The skill ID.
* \return void
*/
EXPORT_APIFUNCTION void CDECL ClearSkillModifier(unsigned short pid, unsigned short skillId) noexcept;
static void ClearSkillModifier(unsigned short pid, unsigned short skillId) noexcept;
/**
* \brief Set the amount of damage (as caused through the Damage Skill effect) to
* a player's skill.
*
* \param pid The player ID.
* \param skillId The skill ID.
* \param value The amount of damage to the player's skill.
* \return void
*/
static void SetSkillDamage(unsigned short pid, unsigned short skillId, double value) noexcept;
/**
* \brief Set the progress the player has made towards increasing a certain skill by 1.
@ -509,7 +555,7 @@ namespace StatsFunctions
* \param value The progress value.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetSkillProgress(unsigned short pid, unsigned short skillId, double value) noexcept;
static void SetSkillProgress(unsigned short pid, unsigned short skillId, double value) noexcept;
/**
* \brief Set the bonus applied to a certain attribute at the next level up as a result
@ -522,7 +568,7 @@ namespace StatsFunctions
* \param value The increase in the attribute caused by skills.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetSkillIncrease(unsigned short pid, unsigned int attributeId, int value) noexcept;
static void SetSkillIncrease(unsigned short pid, unsigned int attributeId, int value) noexcept;
/**
* \brief Set the bounty of a player.
@ -531,7 +577,7 @@ namespace StatsFunctions
* \param value The new bounty.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetBounty(unsigned short pid, int value) noexcept;
static void SetBounty(unsigned short pid, int value) noexcept;
/**
* \brief Set the current and ending stages of character generation for a player.
@ -543,7 +589,7 @@ namespace StatsFunctions
* \param endStage The new ending stage.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SetCharGenStage(unsigned short pid, int currentStage, int endStage) noexcept;
static void SetCharGenStage(unsigned short pid, int currentStage, int endStage) noexcept;
/**
* \brief Send a PlayerBaseInfo packet with a player's name, race, head mesh,
@ -554,7 +600,7 @@ namespace StatsFunctions
* \param pid The player ID.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SendBaseInfo(unsigned short pid) noexcept;
static void SendBaseInfo(unsigned short pid) noexcept;
/**
* \brief Send a PlayerStatsDynamic packet with a player's dynamic stats (health,
@ -565,7 +611,7 @@ namespace StatsFunctions
* \param pid The player ID.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SendStatsDynamic(unsigned short pid) noexcept;
static void SendStatsDynamic(unsigned short pid) noexcept;
/**
* \brief Send a PlayerAttribute packet with a player's attributes and bonuses
@ -577,7 +623,7 @@ namespace StatsFunctions
* \param pid The player ID.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SendAttributes(unsigned short pid) noexcept;
static void SendAttributes(unsigned short pid) noexcept;
/**
* \brief Send a PlayerSkill packet with a player's skills.
@ -587,7 +633,7 @@ namespace StatsFunctions
* \param pid The player ID.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SendSkills(unsigned short pid) noexcept;
static void SendSkills(unsigned short pid) noexcept;
/**
* \brief Send a PlayerLevel packet with a player's character level and
@ -598,7 +644,7 @@ namespace StatsFunctions
* \param pid The player ID.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SendLevel(unsigned short pid) noexcept;
static void SendLevel(unsigned short pid) noexcept;
/**
* \brief Send a PlayerBounty packet with a player's bounty.
@ -608,7 +654,7 @@ namespace StatsFunctions
* \param pid The player ID.
* \return void
*/
EXPORT_APIFUNCTION void CDECL SendBounty(unsigned short pid) noexcept;
}
static void SendBounty(unsigned short pid) noexcept;
};
#endif //OPENMW_STATAPI_HPP

View file

@ -11,17 +11,17 @@
using namespace std;
using namespace mwmp;
extern "C" int TimerFunctions::CreateTimer(ScriptFunc callback, int msec) noexcept
int ScriptFunctions::CreateTimer(ScriptFunc callback, int msec) noexcept
{
return mwmp::TimerAPI::CreateTimer(callback, msec, "", vector<boost::any>());
}
extern "C" int TimerFunctions::CreateTimerEx(ScriptFunc callback, int msec, const char *types, va_list args) noexcept
int ScriptFunctions::CreateTimerEx(ScriptFunc callback, int msec, const char *types, va_list args) noexcept
{
try
{
vector<boost::any> params;
ScriptFunctions::GetArguments(params, args, types);
Utils::getArguments(params, args, types);
return mwmp::TimerAPI::CreateTimer(callback, msec, types, params);
}
@ -32,27 +32,27 @@ extern "C" int TimerFunctions::CreateTimerEx(ScriptFunc callback, int msec, cons
}
extern "C" void TimerFunctions::StartTimer(int timerId) noexcept
void ScriptFunctions::StartTimer(int timerId) noexcept
{
TimerAPI::StartTimer(timerId);
}
extern "C" void TimerFunctions::StopTimer(int timerId) noexcept
void ScriptFunctions::StopTimer(int timerId) noexcept
{
TimerAPI::StopTimer(timerId);
}
extern "C" void TimerFunctions::RestartTimer(int timerId, int msec) noexcept
void ScriptFunctions::RestartTimer(int timerId, int msec) noexcept
{
TimerAPI::ResetTimer(timerId, msec);
}
extern "C" void TimerFunctions::FreeTimer(int timerId) noexcept
void ScriptFunctions::FreeTimer(int timerId) noexcept
{
TimerAPI::FreeTimer(timerId);
}
extern "C" bool TimerFunctions::IsTimerElapsed(int timerId) noexcept
bool ScriptFunctions::IsTimerElapsed(int timerId) noexcept
{
return TimerAPI::IsEndTimer(timerId);
return TimerAPI::IsTimerElapsed(timerId);
}

View file

@ -1,80 +0,0 @@
//
// Created by koncord on 09.12.18.
//
#ifndef OPENMW_TIMER_HPP
#define OPENMW_TIMER_HPP
#include <Script/ScriptFunction.hpp>
#include <Script/Platform.hpp>
namespace TimerFunctions
{
/**
* \brief Create a timer that will run a script function after a certain interval.
*
* \param callback The Lua script function.
* \param msec The interval in miliseconds.
* \return The ID of the timer thus created.
*/
EXPORT_APIFUNCTION int CDECL CreateTimer(ScriptFunc callback, int msec) noexcept;
/**
* \brief Create a timer that will run a script function after a certain interval and pass
* certain arguments to it.
*
* Example usage:
* - tes3mp.CreateTimerEx("OnTimerTest1", 250, "i", 90)
* - tes3mp.CreateTimerEx("OnTimerTest2", 500, "sif", "Test string", 60, 77.321)
*
* \param callback The Lua script function.
* \param msec The interval in miliseconds.
* \param types The argument types.
* \param args The arguments.
* \return The ID of the timer thus created.
*/
EXPORT_APIFUNCTION int CDECL CreateTimerEx(ScriptFunc callback, int msec, const char *types, va_list args) noexcept;
/**
* \brief Start the timer with a certain ID.
*
* \param timerId The timer ID.
* \return void
*/
EXPORT_APIFUNCTION void CDECL StartTimer(int timerId) noexcept;
/**
* \brief Stop the timer with a certain ID.
*
* \param timerId The timer ID.
* \return void
*/
EXPORT_APIFUNCTION void CDECL StopTimer(int timerId) noexcept;
/**
* \brief Restart the timer with a certain ID for a certain interval.
*
* \param timerId The timer ID.
* \param msec The interval in miliseconds.
* \return void
*/
EXPORT_APIFUNCTION void CDECL RestartTimer(int timerId, int msec) noexcept;
/**
* \brief Free the timer with a certain ID.
*
* \param timerId The timer ID.
* \return void
*/
EXPORT_APIFUNCTION void CDECL FreeTimer(int timerId) noexcept;
/**
* \brief Check whether a timer is elapsed.
*
* \param timerId The timer ID.
* \return Whether the timer is elapsed.
*/
EXPORT_APIFUNCTION bool CDECL IsTimerElapsed(int timerId) noexcept;
}
#endif //OPENMW_TIMER_HPP

View file

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

View file

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

View file

@ -107,6 +107,32 @@ template<> struct F_<1> { static constexpr LuaFuctionData F{"CreateTimerEx", Lan
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
{
@ -117,7 +143,6 @@ struct C
}
};
template<>
struct C<0>
{
@ -141,6 +166,7 @@ LuaFuctionData *functions()
return functions_;
}
#endif
void LangLua::LoadProgram(const char *filename)
{
@ -152,8 +178,11 @@ void LangLua::LoadProgram(const char *filename)
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++)
@ -223,7 +252,7 @@ boost::any LangLua::Call(const char *name, const char *argl, int buf, ...)
break;
default:
throw runtime_error(std::string("C++ call: Unknown argument identifier ") + argl[index]);
throw runtime_error("C++ call: Unknown argument identifier " + argl[index]);
}
}
@ -275,7 +304,7 @@ boost::any LangLua::Call(const char *name, const char *argl, const std::vector<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]);
throw runtime_error("Lua call: Unknown argument identifier " + argl[index]);
}
}
@ -292,13 +321,3 @@ void LangLua::AddPackageCPath(const std::string& path)
{
packageCPath.emplace(path);
}
void LangLua::Init()
{
}
void LangLua::Free()
{
}

View file

@ -45,9 +45,6 @@ public:
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;
static void Init();
static void Free();
private:
static std::set<std::string> packageCPath;
static std::set<std::string> packagePath;

View file

@ -9,7 +9,7 @@
using namespace std;
inline vector<boost::any> DefToVec(lua_State *lua, const string &types, int args_begin, int args_n)
inline vector<boost::any> DefToVec(lua_State *lua, string types, int args_begin, int args_n)
{
vector<boost::any> args;
@ -93,15 +93,13 @@ int LangLua::CallPublic(lua_State *lua)
if (result.empty())
return 0;
auto retTypeHash = result.type().hash_code();
if (retTypeHash == typeid(signed int).hash_code())
if (result.type().hash_code() == 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())
else if (result.type().hash_code() == typeid(unsigned int).hash_code())
luabridge::Stack<unsigned int>::push(lua, boost::any_cast<unsigned int>(result));
else if (retTypeHash == typeid(double).hash_code())
else if (result.type().hash_code() == typeid(double).hash_code())
luabridge::Stack<double>::push(lua, boost::any_cast<double>(result));
else if (retTypeHash == typeid(const char*).hash_code())
else if (result.type().hash_code() == typeid(const char*).hash_code())
luabridge::Stack<const char*>::push(lua, boost::any_cast<const char*>(result));
return 1;
}

View file

@ -1,519 +0,0 @@
//
// Created by koncord on 08.12.18.
//
#include <cstdarg>
#include <mono/metadata/appdomain.h>
#include <mono/metadata/object-forward.h>
#include <mono/jit/jit.h>
#include <mono/metadata/assembly.h>
#include <mono/metadata/mono-config.h>
#include <mono/metadata/mono-debug.h>
#include <Script/ScriptFunctions.hpp>
#include <Script/API/TimerAPI.hpp>
#include <Script/API/PublicFnAPI.hpp>
#include "LangMono.hpp"
static MonoDomain *domain = nullptr; // shared domain
std::string monoStringToStdString(MonoString *monoString)
{
char *utf8 = mono_string_to_utf8(monoString);
std::string str = utf8;
mono_free(utf8);
return str;
}
boost::any LangMono::ObjectToAny(MonoObject *obj)
{
MonoClass *klass = mono_object_get_class(obj);
MonoType *rawType = mono_class_get_type(klass);
switch ((MonoTypeEnum) mono_type_get_type(rawType))
{
case MONO_TYPE_END:
case MONO_TYPE_VOID:
break;
case MONO_TYPE_BOOLEAN:
return (bool) Unbox<MonoBoolean>(obj);
case MONO_TYPE_CHAR:
return Unbox<uint16_t>(obj);
case MONO_TYPE_I1:
return Unbox<int8_t>(obj);
case MONO_TYPE_U1:
return Unbox<uint8_t>(obj);
case MONO_TYPE_I2:
return Unbox<int16_t>(obj);
case MONO_TYPE_U2:
return Unbox<uint16_t>(obj);
case MONO_TYPE_I4:
return Unbox<int32_t>(obj);
case MONO_TYPE_U4:
return Unbox<uint32_t>(obj);
case MONO_TYPE_I8:
return Unbox<int64_t>(obj);
case MONO_TYPE_U8:
return Unbox<uint64_t>(obj);
case MONO_TYPE_R4:
return Unbox<float>(obj);
case MONO_TYPE_R8:
return Unbox<double>(obj);
case MONO_TYPE_STRING:
return monoStringToStdString((MonoString *) obj);
case MONO_TYPE_ARRAY:
case MONO_TYPE_SZARRAY:
{
//MonoArrayType *arrayType = mono_type_get_array_type(rawType);
break;
}
default:
return boost::any();
}
return boost::any();
}
int LangMono::CreateTimerEx(MonoObject *delegate, long msec, MonoString *monoStr, MonoArray *monoArgs)
{
size_t argsLength = mono_array_length(monoArgs);
std::vector<boost::any> params (argsLength);
try
{
for (size_t i = 0; i < argsLength; ++i)
params[i] = ObjectToAny(mono_array_get(monoArgs, MonoObject*, i));
char *types = mono_string_to_utf8(monoStr);
int id = mwmp::TimerAPI::CreateTimerMono(delegate, msec, types, params);
mono_free(types);
return id;
}
catch (...)
{
return -1;
}
}
char GetTes3mpType(MonoType *type)
{
int typeId = mono_type_get_type(type);
switch (typeId)
{
case MONO_TYPE_VOID:
return 'v';
case MONO_TYPE_BOOLEAN:
return 'b';
case MONO_TYPE_CHAR:
return 'q';
case MONO_TYPE_I1:
return 'q';
case MONO_TYPE_U1:
return 'i';
case MONO_TYPE_I2:
return 'q';
case MONO_TYPE_U2:
return 'i';
case MONO_TYPE_I4:
return 'q';
case MONO_TYPE_U4:
return 'i';
case MONO_TYPE_I8:
return 'w';
case MONO_TYPE_U8:
return 'l';
case MONO_TYPE_R4:
return 'f';
case MONO_TYPE_R8:
return 'f';
case MONO_TYPE_STRING:
return 's';
}
throw std::invalid_argument("Mono: invalid type of argument");
}
MonoObject *LangMono::AnyToObject(boost::any any, char ret_type)
{
MonoObject *object;
switch (ret_type)
{
case 'i':
{
auto val = boost::any_cast<unsigned int>(any);
object = mono_object_new(mono_get_root_domain(), mono_get_uint32_class());
ObjectSetValue(object, val);
break;
}
case 'q':
{
auto val = boost::any_cast<signed int>(any);
object = mono_object_new(mono_get_root_domain(), mono_get_int32_class());
ObjectSetValue(object, val);
break;
}
case 'l':
{
auto val = boost::any_cast<unsigned long long>(any);
object = mono_object_new(mono_get_root_domain(), mono_get_uint64_class());
ObjectSetValue(object, val);
break;
}
case 'w':
{
auto val = boost::any_cast<signed long long>(any);
object = mono_object_new(mono_get_root_domain(), mono_get_int64_class());
ObjectSetValue(object, val);
break;
}
case 'f':
{
auto val = boost::any_cast<double>(any);
object = mono_object_new(mono_get_root_domain(), mono_get_double_class());
ObjectSetValue(object, val);
break;
}
case 'p':
{
auto val = boost::any_cast<void *>(any);
object = mono_object_new(mono_get_root_domain(), mono_get_intptr_class());
ObjectSetValue(object, (intptr_t) val);
break;
}
case 's':
{
auto val = mono_string_new(mono_domain_get(), boost::any_cast<const char *>(any));
object = (MonoObject*) val;
break;
}
case 'b':
{
auto val = boost::any_cast<int>(any);
object = mono_object_new(mono_get_root_domain(), mono_get_boolean_class());
ObjectSetValue(object, (bool) val);
break;
}
default:
throw std::runtime_error(std::string("Mono call: Unknown argument identifier ") + ret_type);
}
return object;
}
void LangMono::MakePublic(MonoObject *delegate, MonoString *monoName) noexcept
{
MonoClass *klass = mono_object_get_class(delegate);
MonoMethod *method = mono_get_delegate_invoke(klass);
MonoMethodSignature *signature = mono_method_signature(method);
MonoType *retType = mono_signature_get_return_type(signature);
size_t argsCnt = mono_signature_get_param_count(signature);
void *iter = nullptr;
std::vector<char> def(argsCnt + 1);
for (size_t i = 0; i < argsCnt; ++i)
def[i] = GetTes3mpType(mono_signature_get_params(signature, &iter));
char ret_type = GetTes3mpType(retType);
char *name = mono_string_to_utf8(monoName);
Public::MakePublic(delegate, name, ret_type, def.data());
mono_free(name);
}
MonoObject *LangMono::CallPublic(MonoString *monoFnName, MonoArray *monoArgs)
{
size_t argsLength = mono_array_length(monoArgs);
char *fnName = mono_string_to_utf8(monoFnName);
auto pPublic = Public::GetPublic(fnName);
mono_free(fnName);
if (argsLength != pPublic->def.size())
throw std::invalid_argument("Mono call: Number of arguments does not match definition");
std::vector<boost::any> params(argsLength);
for (size_t i = 0; i < argsLength; ++i)
params[i] = ObjectToAny(mono_array_get(monoArgs, MonoObject*, i));
boost::any ret = pPublic->ScriptFunction::Call(params);
return AnyToObject(ret, pPublic->ret_type);
}
lib_t LangMono::GetInterface()
{
return nullptr;
}
LangMono::LangMono()
{
instance = new MonoInstance;
}
LangMono::LangMono(MonoInstance *instance) : instance(instance)
{
}
LangMono::~LangMono()
{
delete instance;
}
void LangMono::Init()
{
if (domain != nullptr)
return;
if (Script::IsDebugMode())
{
std::string debugServerAddress = "127.0.0.1:10000";
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Waiting for debugger on %s...", debugServerAddress.c_str());
std::string connectionString = "--debugger-agent=transport=dt_socket,server=y,address=" + debugServerAddress;
std::vector<const char*> options {
"--soft-breakpoints",
connectionString.c_str()
};
mono_jit_parse_options(options.size(), (char**) options.data());
mono_debug_init(MONO_DEBUG_FORMAT_MONO);
}
domain = mono_jit_init("TES3MP Mono VM");
if (Script::IsDebugMode())
{
mono_debug_domain_create(domain);
}
mono_add_internal_call("TES3MPSharp.TES3MP::CreateTimerEx", (void*) &LangMono::CreateTimerEx);
mono_add_internal_call("TES3MPSharp.TES3MP::MakePublic", (void*) &LangMono::MakePublic);
mono_add_internal_call("TES3MPSharp.TES3MP::CallPublic", (void*) &LangMono::CallPublic);
}
void LangMono::Free()
{
mono_domain_free(domain, 0);
}
std::vector<MonoClass *> getInstanceClassList(MonoImage *image, const std::string &parentName)
{
std::vector<MonoClass *> classes;
const MonoTableInfo *tableInfo = mono_image_get_table_info(image, MONO_TABLE_TYPEDEF);
int rows = mono_table_info_get_rows(tableInfo);
for (int i = 0; i < rows; i++)
{
MonoClass *klass = nullptr;
uint32_t cols[MONO_TYPEDEF_SIZE];
mono_metadata_decode_row(tableInfo, i, cols, MONO_TYPEDEF_SIZE);
const char *name = mono_metadata_string_heap(image, cols[MONO_TYPEDEF_NAME]);
const char *nameSpace = mono_metadata_string_heap(image, cols[MONO_TYPEDEF_NAMESPACE]);
klass = mono_class_from_name(image, nameSpace, name);
if (klass == nullptr)
continue;
MonoClass *parent = mono_class_get_parent(klass);
if (parent != nullptr && parentName == mono_class_get_name(parent))
classes.push_back(klass);
}
return classes;
}
void LangMono::LoadProgram(const char *filename)
{
MonoAssembly *assembly = mono_domain_assembly_open(domain, filename);
if(!assembly)
throw std::runtime_error("Cannot load: " + std::string(filename));
instance->assembly = assembly;
instance->image = mono_assembly_get_image(instance->assembly);
std::vector<MonoClass *> list = getInstanceClassList(instance->image, "Instance");
for (auto &&klass : list)
{
instance->object = mono_object_new(domain, klass);
mono_runtime_object_init(instance->object); // call default ctor
instance->klass = klass;
}
}
int LangMono::FreeProgram()
{
for(auto &&method : methodsCache)
{
if(method.second != nullptr)
mono_free_method(method.second);
}
return 0;
}
bool LangMono::IsCallbackPresent(const char *name)
{
return true;
}
boost::any LangMono::Call(const char *name, const char *argl, int buf, ...)
{
va_list vargs;
va_start(vargs, buf);
int n_args = (int) (strlen(argl));
std::vector<void *> vec(n_args);
TMonoArgsStore argsStore(n_args);
for (int index = 0; index < n_args; index++)
{
switch (argl[index])
{
case 'i':
{
vec[index] = MonoStoreAndGetPtr<unsigned int>(argsStore, vargs, index);
break;
}
case 'q':
{
vec[index] = MonoStoreAndGetPtr<signed int>(argsStore, vargs, index);
break;
}
case 'l':
{
vec[index] = MonoStoreAndGetPtr<unsigned long long>(argsStore, vargs, index);
break;
}
case 'w':
{
vec[index] = MonoStoreAndGetPtr<signed long long>(argsStore, vargs, index);
break;
}
case 'f':
{
vec[index] = MonoStoreAndGetPtr<double>(argsStore, vargs, index);
break;
}
case 'p':
{
vec[index] = MonoStoreAndGetPtr<void *>(argsStore, vargs, index);
break;
}
case 's':
{
vec[index] = (mono_string_new(mono_domain_get(), va_arg(vargs, const char*)));
break;
}
case 'b':
{
vec[index] = MonoStoreAndGetPtr<int>(argsStore, vargs, index);
break;
}
default:
throw std::runtime_error(std::string("Mono call: Unknown argument identifier ") + argl[index]);
}
}
va_end(vargs);
MonoMethod *method;
auto it = methodsCache.find({name, n_args});
if (it != methodsCache.end())
{
method = it->second;
} else
{
method = mono_class_get_method_from_name(instance->klass, name, n_args);
methodsCache[{name, n_args}] = method;
}
if (method == nullptr)
return boost::any();
MonoObject *ret = mono_runtime_invoke(method, instance->object, vec.data(), nullptr);
if (ret)
return boost::any(mono_object_unbox(ret));
else
return boost::any();
}
boost::any LangMono::Call(const char *name, const char *argl, const std::vector<boost::any> &args)
{
int n_args = args.size();
std::vector<void *> vec(n_args);
TMonoArgsStore argsStore(n_args);
for (int index = 0; index < n_args; index++)
{
switch (argl[index])
{
case 'i':
{
vec[index] = MonoStoreAndGetPtr<unsigned int>(argsStore, args, index);
break;
}
case 'q':
{
vec[index] = MonoStoreAndGetPtr<signed int>(argsStore, args, index);
break;
}
case 'l':
{
vec[index] = MonoStoreAndGetPtr<unsigned long long>(argsStore, args, index);
break;
}
case 'w':
{
vec[index] = MonoStoreAndGetPtr<signed long long>(argsStore, args, index);
break;
}
case 'f':
{
vec[index] = MonoStoreAndGetPtr<double>(argsStore, args, index);
break;
}
case 'p':
{
vec[index] = MonoStoreAndGetPtr<void *>(argsStore, args, index);
break;
}
case 's':
{
auto val = mono_string_new(mono_domain_get(), boost::any_cast<const char *>(args.at(index)));
vec[index] = (val);
break;
}
case 'b':
{
vec[index] = MonoStoreAndGetPtr<int>(argsStore, args, index);
break;
}
default:
throw std::runtime_error(std::string("Mono call: Unknown argument identifier ") + argl[index]);
}
}
MonoMethod *method;
auto it = methodsCache.find({name, n_args});
if (it != methodsCache.end())
{
method = it->second;
}
else
{
method = mono_class_get_method_from_name(instance->klass, name, n_args);
methodsCache[{name, n_args}] = method;
}
MonoObject *ret = mono_runtime_invoke(method, instance->object, vec.data(), nullptr);
if (ret)
return boost::any(mono_object_unbox(ret));
else
return boost::any();
}

View file

@ -1,104 +0,0 @@
//
// Created by koncord on 08.12.18.
//
#pragma once
#include <Script/Language.hpp>
#include <Script/SystemInterface.hpp>
#include <unordered_map>
#include <mono/metadata/object.h>
#include <boost/variant.hpp>
typedef boost::variant<unsigned int, signed int, unsigned long long, signed long long, double, void*> TMonoArgVariant;
typedef std::vector<TMonoArgVariant> TMonoArgsStore;
template<typename T>
void *MonoStoreAndGetPtr(TMonoArgsStore &argsStore, va_list &vargs, size_t index)
{
argsStore[index] = va_arg(vargs, T);
return (void *) &boost::get<T&>(argsStore[index]);
}
template<typename T>
void *MonoStoreAndGetPtr(TMonoArgsStore &argsStore, const std::vector<boost::any> &args, size_t index)
{
argsStore[index] = boost::any_cast<T>(args.at(index));
return (void *) &boost::get<T&>(argsStore[index]);
}
struct MethodKey
{
inline bool operator==(const MethodKey &other) const
{
return other.paramsCnt == paramsCnt && other.name == name;
}
MethodKey(const std::string &name, int paramsCnt): name(name), paramsCnt(paramsCnt)
{
}
std::string name;
int paramsCnt;
};
namespace std
{
template<>
struct hash<MethodKey>
{
std::size_t operator()(const MethodKey &key) const
{
return hash<string>()(key.name)
^ (hash<uint32_t>()(key.paramsCnt) >> 1);
}
};
}
struct MonoInstance
{
MonoObject *object;
MonoClass *klass;
MonoAssembly *assembly;
MonoImage *image;
};
class LangMono: public Language
{
MonoInstance *instance;
std::unordered_map<MethodKey, MonoMethod *> methodsCache;
public:
virtual lib_t GetInterface() override;
LangMono();
LangMono(MonoInstance *instance);
~LangMono();
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;
static int CreateTimerEx(MonoObject *delegate, long msec, MonoString *monoStr, MonoArray *args);
static void MakePublic(MonoObject *delegate, MonoString *name) noexcept;
static MonoObject *CallPublic(MonoString *name, MonoArray *args);
static void Init();
static void Free();
template<typename T>
static T Unbox(MonoObject *obj)
{
return *(T *) mono_object_unbox(obj);
}
template<typename T>
static void ObjectSetValue(MonoObject *obj, T value)
{
*(T*) mono_object_unbox(obj) = value;
}
static boost::any ObjectToAny(MonoObject *obj);
static MonoObject *AnyToObject(boost::any any, char ret_type);
};

View file

@ -91,7 +91,7 @@ lib_t LangNative::GetInterface()
}
LangNative::LangNative(): lib(nullptr)
LangNative::LangNative()
{
}
@ -100,13 +100,3 @@ LangNative::~LangNative()
{
}
void LangNative::Init()
{
}
void LangNative::Free()
{
}

View file

@ -22,8 +22,6 @@ public:
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;
static void Init();
static void Free();
};

View file

@ -13,7 +13,7 @@
class Language
{
public:
virtual ~Language() = default;
virtual ~Language(){}
virtual void LoadProgram(const char* filename) = 0;
virtual int FreeProgram() = 0;
virtual bool IsCallbackPresent(const char* name) = 0;

View file

@ -5,24 +5,16 @@
#ifndef PLATFORM_HPP
#define PLATFORM_HPP
#ifdef _MSC_VER
#if _MSC_VER
#ifdef _M_X86
#define ARCH_X86
#endif
#endif
#ifdef __GNUC__
#if __GNUC__
#ifdef __i386__
#define ARCH_X86
#endif
#endif
#ifdef _WIN32
#define EXPORT_APIFUNCTION extern "C" __declspec(dllexport)
#define CDECL __cdecl
#else
#define EXPORT_APIFUNCTION extern "C" __attribute__ ((visibility ("default")))
#define CDECL
#endif
#endif //PLATFORM_HPP

View file

@ -9,28 +9,10 @@
#include "LangLua/LangLua.hpp"
#endif
#ifdef ENABLE_MONO
#include "LangMono/LangMono.hpp"
#endif
using namespace std;
Script::ScriptList Script::scripts;
std::string Script::moddir;
bool Script::debugMode = false;
inline void Load(Language *lang, const std::string &path)
{
try
{
lang->LoadProgram(path.c_str());
}
catch (...)
{
lang->FreeProgram();
throw std::runtime_error("Failed to load: " + path);
}
}
Script::Script(const char *path)
{
@ -41,45 +23,35 @@ Script::Script(const char *path)
fclose(file);
if (strstr(path, ".dll"))
{
#ifdef ENABLE_MONO
script_type = SCRIPT_MONO;
try
{
lang = new LangMono();
Load(lang, path);
}
catch(...)
{
#endif
#ifdef _WIN32
script_type = SCRIPT_CPP;
lang = new LangNative();
Load(lang, path);
if (strstr(path, ".dll"))
#else
if (strstr(path, ".so"))
#endif
#ifdef ENABLE_MONO
}
#endif
}
#ifndef _WIN32
else if (strstr(path, ".so"))
{
script_type = SCRIPT_CPP;
lang = new LangNative();
Load(lang, path);
}
#endif
#if defined (ENABLE_LUA)
else if (strstr(path, ".lua") || strstr(path, ".t"))
{
script_type = SCRIPT_LUA;
lang = new LangLua();
Load(lang, path);
script_type = SCRIPT_LUA;
}
#endif
else
throw runtime_error("Script type not recognized: " + string(path));
try
{
lang->LoadProgram(path);
}
catch (...)
{
lang->FreeProgram();
throw;
}
}
@ -134,35 +106,3 @@ const char* Script::GetModDir()
{
return moddir.c_str();
}
bool Script::IsDebugMode()
{
return debugMode;
}
void Script::EnableDebugMode()
{
debugMode = true;
}
void Script::Init()
{
#ifdef ENABLE_MONO
LangMono::Init();
#endif
#ifdef ENABLE_LUA
LangLua::Init();
#endif
LangNative::Init();
}
void Script::Free()
{
#ifdef ENABLE_MONO
LangMono::Free();
#endif
#ifdef ENABLE_LUA
LangLua::Free();
#endif
LangNative::Free();
}

View file

@ -27,8 +27,7 @@ private:
enum
{
SCRIPT_CPP,
SCRIPT_LUA,
SCRIPT_MONO
SCRIPT_LUA
};
template<typename R>
@ -57,14 +56,9 @@ private:
protected:
static std::string moddir;
static bool debugMode;
public:
~Script();
static void Init();
static void Free();
static bool IsDebugMode();
static void EnableDebugMode();
static void LoadScript(const char *script, const char* base);
static void LoadScripts(char* scripts, const char* base);
static void UnloadScripts();
@ -101,7 +95,8 @@ public:
if (script->script_type == SCRIPT_CPP)
(callback)(std::forward<Args>(args)...);
else
#if defined (ENABLE_LUA)
else if (script->script_type == SCRIPT_LUA)
{
try
{
@ -110,11 +105,13 @@ public:
catch (std::exception &e)
{
LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, e.what());
Script::Call<Script::CallbackIdentity("OnServerScriptCrash")>(e.what());
if (!mwmp::Networking::getPtr()->getScriptErrorIgnoringState())
throw;
}
}
#endif
++count;
}

View file

@ -9,9 +9,6 @@
#if defined (ENABLE_LUA)
#include "LangLua/LangLua.hpp"
#endif
#if defined(ENABLE_MONO)
#include "LangMono/LangMono.hpp"
#endif
using namespace std;
@ -27,12 +24,7 @@ ScriptFunction::ScriptFunction(const ScriptFuncLua &fLua, lua_State *lua, char r
}
#endif
#if defined (ENABLE_MONO)
ScriptFunction::ScriptFunction(MonoObject *delegate, char ret_type, const std::string &def) :
fMono({delegate}), ret_type(ret_type), def(def), script_type(SCRIPT_MONO)
{
}
#endif
ScriptFunction::~ScriptFunction()
{
@ -44,7 +36,7 @@ ScriptFunction::~ScriptFunction()
boost::any ScriptFunction::Call(const vector<boost::any> &args)
{
boost::any result = boost::any();
boost::any result;
if (def.length() != args.size())
throw runtime_error("Script call: Number of arguments does not match definition");
@ -69,78 +61,13 @@ boost::any ScriptFunction::Call(const vector<boost::any> &args)
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
#if defined (ENABLE_MONO)
else if (script_type == SCRIPT_MONO)
{
std::vector<void *> argList(args.size());
TMonoArgsStore argsStore(args.size());
for (size_t index = 0; index < args.size(); index++)
{
switch (def[index])
{
case 'i':
{
argList[index] = MonoStoreAndGetPtr<unsigned int>(argsStore, args, index);
break;
}
case 'q':
{
argList[index] = MonoStoreAndGetPtr<signed int>(argsStore, args, index);
break;
}
case 'l':
{
argList[index] = MonoStoreAndGetPtr<unsigned long long>(argsStore, args, index);
break;
}
case 'w':
{
argList[index] = MonoStoreAndGetPtr<signed long long>(argsStore, args, index);
break;
}
case 'f':
{
argList[index] = MonoStoreAndGetPtr<double>(argsStore, args, index);
break;
}
case 'p':
{
argList[index] = MonoStoreAndGetPtr<void *>(argsStore, args, index);
break;
}
case 's':
{
if (args.at(index).type() == typeid(std::string)) // mono to mono call
argList[index] = mono_string_new(mono_domain_get(),
boost::any_cast<std::string>(args.at(index)).c_str());
else // lua to mono
argList[index] = mono_string_new(mono_domain_get(),
boost::any_cast<const char *>(args.at(index)));
break;
}
case 'b':
{
argList[index] = MonoStoreAndGetPtr<int>(argsStore, args, index);
break;
}
default:
throw std::runtime_error("Call: Unknown argument identifier " + def[index]);
}
}
MonoObject *monoRet = mono_runtime_delegate_invoke(fMono.delegate, argList.data(), NULL);
if (monoRet != nullptr)
result = LangMono::ObjectToAny(monoRet);
}
#endif
return result;
}

View file

@ -12,11 +12,6 @@
#include "LangLua/LangLua.hpp"
#endif
#if defined (ENABLE_MONO)
#include <mono/metadata/object.h>
#include <mono/metadata/appdomain.h>
#endif
typedef unsigned long long(*ScriptFunc)();
#if defined (ENABLE_LUA)
typedef std::string ScriptFuncLua;
@ -34,37 +29,26 @@ protected:
lua_State *lua;
ScriptFuncLua name;
} fLua;
#endif
#ifdef ENABLE_MONO
struct
{
MonoObject *delegate;
} fMono;
#endif
};
public:
protected:
char ret_type;
std::string def;
int script_type;
enum
{
SCRIPT_CPP,
SCRIPT_LUA,
SCRIPT_MONO
SCRIPT_LUA
};
boost::any Call(const std::vector<boost::any> &args);
protected:
ScriptFunction(ScriptFunc fCpp, char ret_type, const std::string &def);
#if defined (ENABLE_LUA)
ScriptFunction(const ScriptFuncLua &fPawn, lua_State *lua, char ret_type, const std::string &def);
#endif
#if defined (ENABLE_MONO)
ScriptFunction(MonoObject *delegate, char ret_type, const std::string &def);
#endif
virtual ~ScriptFunction();
boost::any Call(const std::vector<boost::any> &args);
};
#endif //SCRIPTFUNCTION_HPP

View file

@ -13,58 +13,23 @@ constexpr ScriptCallbackData ScriptFunctions::callbacks[];
using namespace std;
void ScriptFunctions::GetArguments(std::vector<boost::any> &params, va_list args, const std::string &def)
void ScriptFunctions::MakePublic(ScriptFunc _public, const char *name, char ret_type, const char *def) noexcept
{
params.reserve(def.length());
Public::MakePublic(_public, name, ret_type, def);
}
boost::any ScriptFunctions::CallPublic(const char *name, va_list args) noexcept
{
vector<boost::any> params;
try
{
for (char c : def)
{
switch (c)
{
case 'i':
params.emplace_back(va_arg(args, unsigned int));
break;
string def = Public::GetDefinition(name);
Utils::getArguments(params, args, def);
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);
}
}
return Public::Call(name, params);
}
catch (...) {}
catch (...)
{
va_end(args);
throw;
}
va_end(args);
return 0;
}

View file

@ -14,7 +14,6 @@
#include <Script/Functions/Miscellaneous.hpp>
#include <Script/Functions/Objects.hpp>
#include <Script/Functions/Positions.hpp>
#include <Script/Functions/Public.hpp>
#include <Script/Functions/Quests.hpp>
#include <Script/Functions/RecordsDynamic.hpp>
#include <Script/Functions/Shapeshift.hpp>
@ -22,7 +21,6 @@
#include <Script/Functions/Settings.hpp>
#include <Script/Functions/Spells.hpp>
#include <Script/Functions/Stats.hpp>
#include <Script/Functions/Timer.hpp>
#include <Script/Functions/Worldstate.hpp>
#include <RakNetTypes.h>
#include <tuple>
@ -48,19 +46,88 @@
class ScriptFunctions
{
public:
static void GetArguments(std::vector<boost::any> &params, va_list args, const std::string &def);
static void MakePublic(ScriptFunc _public, const char *name, char ret_type, const char *def) noexcept;
static boost::any CallPublic(const char *name, va_list args) noexcept;
/**
* \brief Create a timer that will run a script function after a certain interval.
*
* \param callback The Lua script function.
* \param msec The interval in miliseconds.
* \return The ID of the timer thus created.
*/
static int CreateTimer(ScriptFunc callback, int msec) noexcept;
/**
* \brief Create a timer that will run a script function after a certain interval and pass
* certain arguments to it.
*
* Example usage:
* - tes3mp.CreateTimerEx("OnTimerTest1", 250, "i", 90)
* - tes3mp.CreateTimerEx("OnTimerTest2", 500, "sif", "Test string", 60, 77.321)
*
* \param callback The Lua script function.
* \param msec The interval in miliseconds.
* \param types The argument types.
* \param args The arguments.
* \return The ID of the timer thus created.
*/
static int CreateTimerEx(ScriptFunc callback, int msec, const char *types, va_list args) noexcept;
/**
* \brief Start the timer with a certain ID.
*
* \param timerId The timer ID.
* \return void
*/
static void StartTimer(int timerId) noexcept;
/**
* \brief Stop the timer with a certain ID.
*
* \param timerId The timer ID.
* \return void
*/
static void StopTimer(int timerId) noexcept;
/**
* \brief Restart the timer with a certain ID for a certain interval.
*
* \param timerId The timer ID.
* \param msec The interval in miliseconds.
* \return void
*/
static void RestartTimer(int timerId, int msec) noexcept;
/**
* \brief Free the timer with a certain ID.
*
* \param timerId The timer ID.
* \return void
*/
static void FreeTimer(int timerId) noexcept;
/**
* \brief Check whether a timer is elapsed.
*
* \param timerId The timer ID.
* \return Whether the timer is elapsed.
*/
static bool IsTimerElapsed(int timerId) noexcept;
static constexpr ScriptFunctionData functions[]{
{"CreateTimer", TimerFunctions::CreateTimer},
{"CreateTimerEx", TimerFunctions::CreateTimerEx},
{"MakePublic", PublicFunctions::MakePublic},
{"CallPublic", PublicFunctions::CallPublic},
{"CreateTimer", ScriptFunctions::CreateTimer},
{"CreateTimerEx", ScriptFunctions::CreateTimerEx},
{"MakePublic", ScriptFunctions::MakePublic},
{"CallPublic", ScriptFunctions::CallPublic},
{"StartTimer", TimerFunctions::StartTimer},
{"StopTimer", TimerFunctions::StopTimer},
{"RestartTimer", TimerFunctions::RestartTimer},
{"FreeTimer", TimerFunctions::FreeTimer},
{"IsTimerElapsed", TimerFunctions::IsTimerElapsed},
{"StartTimer", ScriptFunctions::StartTimer},
{"StopTimer", ScriptFunctions::StopTimer},
{"RestartTimer", ScriptFunctions::RestartTimer},
{"FreeTimer", ScriptFunctions::FreeTimer},
{"IsTimerElapsed", ScriptFunctions::IsTimerElapsed},
ACTORAPI,
BOOKAPI,
@ -89,6 +156,7 @@ public:
{"OnServerInit", Callback<>()},
{"OnServerPostInit", Callback<>()},
{"OnServerExit", Callback<bool>()},
{"OnServerScriptCrash", Callback<const char*>()},
{"OnPlayerConnect", Callback<unsigned short>()},
{"OnPlayerDisconnect", Callback<unsigned short>()},
{"OnPlayerDeath", Callback<unsigned short>()},
@ -141,7 +209,7 @@ public:
{"OnWorldMap", Callback<unsigned short>()},
{"OnWorldWeather", Callback<unsigned short>() },
{"OnMpNumIncrement", Callback<int>()},
{"OnRequestPluginList", Callback<>()}
{"OnRequestDataFileList", Callback<>()}
};
};

View file

@ -103,9 +103,13 @@ struct CallbackIdentity
struct ScriptFunctionPointer : public ScriptIdentity
{
void *addr;
#if (!defined(__clang__) && defined(__GNUC__))
template<typename R, typename... Types>
constexpr ScriptFunctionPointer(Function<R, Types...> addr) : ScriptIdentity(addr), addr((void*)(addr)) {}
#else
template<typename R, typename... Types>
constexpr ScriptFunctionPointer(Function<R, Types...> addr) : ScriptIdentity(addr), addr(addr) {}
#endif
};
struct ScriptFunctionData

View file

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

View file

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

View file

@ -27,10 +27,6 @@
#include <apps/openmw-mp/Script/Script.hpp>
#ifdef ENABLE_MONO
#include <mono/metadata/assembly.h>
#endif
#ifdef ENABLE_BREAKPAD
#include <handler/exception_handler.h>
#endif
@ -134,7 +130,6 @@ boost::program_options::variables_map launchOptions(int argc, char *argv[], File
desc.add_options()
("resources", bpo::value<Files::EscapeHashString>()->default_value("resources"), "set resources directory")
("debug", bpo::value<bool>()->implicit_value(true)->default_value(false), "Enable debug mode for scripts (if supported)")
("no-logs", bpo::value<bool>()->implicit_value(true)->default_value(false),
"Do not write logs. Useful for daemonizing.");
@ -195,53 +190,29 @@ int main(int argc, char *argv[])
LOG_INIT(logLevel);
int players = mgr.getInt("maximumPlayers", "General");
string addr = mgr.getString("localAddress", "General");
string address = mgr.getString("localAddress", "General");
int port = mgr.getInt("port", "General");
string passw = mgr.getString("password", "General");
string password = mgr.getString("password", "General");
string plugin_home = mgr.getString("home", "Plugins");
string moddir = Utils::convertPath(plugin_home + "/data");
string pluginHome = mgr.getString("home", "Plugins");
string dataDirectory = Utils::convertPath(pluginHome + "/data");
vector<string> plugins (Utils::split(mgr.getString("plugins", "Plugins"), ','));
vector<string> plugins(Utils::split(mgr.getString("plugins", "Plugins"), ','));
Utils::printVersion("TES3MP dedicated server", TES3MP_VERSION, version.mCommitHash, TES3MP_PROTO_VERSION);
// Check for unmodified tes3mp-credits file; this makes it so people can't repackage official releases with
// their own made-up credits, though it obviously has no bearing on unofficial releases that change
// the checksum below
boost::filesystem::path folderPath(boost::filesystem::initial_path<boost::filesystem::path>());
folderPath = boost::filesystem::system_complete(boost::filesystem::path(argv[0])).remove_filename();
std::string creditsPath = folderPath.string() + "/tes3mp-credits";
unsigned int expectedChecksumInt = Utils::hexStrToInt(TES3MP_CREDITS_CHECKSUM);
bool hasValidCredits = Utils::doesFileHaveChecksum(creditsPath + ".md", expectedChecksumInt);
if (!hasValidCredits)
hasValidCredits = Utils::doesFileHaveChecksum(creditsPath + ".txt", expectedChecksumInt);
if (!hasValidCredits)
{
LOG_MESSAGE_SIMPLE(Log::LOG_FATAL, "The server is shutting down");
LOG_APPEND(Log::LOG_FATAL, "- %s", TES3MP_CREDITS_ERROR);
return 1;
}
Script::SetModDir(moddir);
Script::SetModDir(dataDirectory);
#ifdef ENABLE_LUA
LangLua::AddPackagePath(Utils::convertPath(plugin_home + "/scripts/?.lua" + ";"
+ plugin_home + "/lib/lua/?.lua" + ";"));
LangLua::AddPackagePath(Utils::convertPath(pluginHome + "/scripts/?.lua" + ";"
+ pluginHome + "/lib/lua/?.lua" + ";"));
#ifdef _WIN32
LangLua::AddPackageCPath(Utils::convertPath(plugin_home + "/lib/?.dll"));
LangLua::AddPackageCPath(Utils::convertPath(pluginHome + "/lib/?.dll"));
#else
LangLua::AddPackageCPath(Utils::convertPath(plugin_home + "/lib/?.so"));
LangLua::AddPackageCPath(Utils::convertPath(pluginHome + "/lib/?.so"));
#endif
#endif
#ifdef ENABLE_MONO
mono_set_dirs(Utils::convertPath(plugin_home + "/mono").c_str(), Utils::convertPath(plugin_home + "/mono/etc").c_str());
#endif
int code;
@ -255,21 +226,18 @@ int main(int argc, char *argv[])
peer->SetIncomingPassword(sstr.str().c_str(), (int) sstr.str().size());
if (RakNet::NonNumericHostString(addr.c_str()))
if (RakNet::NonNumericHostString(address.c_str()))
{
LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, "You cannot use non-numeric addresses for the server.");
return 1;
}
RakNet::SocketDescriptor sd((unsigned short) port, addr.c_str());
RakNet::SocketDescriptor sd((unsigned short) port, address.c_str());
try
{
if (variables["debug"].as<bool>())
Script::EnableDebugMode();
Script::Init();
for (auto plugin : plugins)
Script::LoadScript(plugin.c_str(), plugin_home.c_str());
Script::LoadScript(plugin.c_str(), pluginHome.c_str());
switch (peer->Startup((unsigned) players, &sd, 1))
{
@ -296,7 +264,7 @@ int main(int argc, char *argv[])
peer->SetMaximumIncomingConnections((unsigned short) (players));
Networking networking(peer);
networking.setServerPassword(passw);
networking.setServerPassword(password);
if (mgr.getBool("enabled", "MasterServer"))
{
@ -321,15 +289,13 @@ int main(int argc, char *argv[])
}
networking.InitQuery(masterAddr, (unsigned short) masterPort);
auto masterClient = networking.getMasterClient();
masterClient->SetMaxPlayers((unsigned) players);
masterClient->SetUpdateRate((unsigned) updateRate);
networking.getMasterClient()->SetMaxPlayers((unsigned) players);
networking.getMasterClient()->SetUpdateRate((unsigned) updateRate);
string hostname = mgr.getString("hostname", "General");
masterClient->SetHostname(hostname);
masterClient->SetRuleString("CommitHash", version.mCommitHash.substr(0, 10));
networking.getMasterClient()->SetHostname(hostname);
networking.getMasterClient()->SetRuleString("CommitHash", version.mCommitHash.substr(0, 10));
masterClient->Start();
networking.getMasterClient()->Start();
}
networking.postInit();
@ -337,11 +303,11 @@ int main(int argc, char *argv[])
code = networking.mainLoop();
networking.getMasterClient()->Stop();
Script::Free();
}
catch (std::exception &e)
{
LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, e.what());
Script::Call<Script::CallbackIdentity("OnServerScriptCrash")>(e.what());
throw; //fall through
}

View file

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

View file

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

View file

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

View file

@ -1,7 +1,3 @@
//
// Created by koncord on 31.03.17.
//
#ifndef OPENMW_PROCESSORPLAYERPOSITION_HPP
#define OPENMW_PROCESSORPLAYERPOSITION_HPP
@ -18,13 +14,9 @@ namespace mwmp
}
void Do(PlayerPacket &packet, Player &player) override
{
//DEBUG_PRINTF(strPacketID);
if (!player.creatureStats.mDead)
{
player.sendToLoaded(&packet);
}
}
};
}

View file

@ -134,7 +134,7 @@ add_openmw_dir (mwmp/processors/object BaseObjectProcessor
ProcessorScriptGlobalFloat
)
add_openmw_dir (mwmp/processors/worldstate ProcessorCellCreate ProcessorCellReplace ProcessorRecordDynamic
add_openmw_dir (mwmp/processors/worldstate ProcessorCellCreate ProcessorCellReset ProcessorRecordDynamic
ProcessorWorldCollisionOverride ProcessorWorldMap ProcessorWorldRegionAuthority ProcessorWorldTime
ProcessorWorldWeather
)
@ -265,10 +265,3 @@ endif (MSVC)
if (WIN32)
INSTALL(TARGETS tes3mp RUNTIME DESTINATION ".")
endif (WIN32)
if (ENABLE_PVS)
pvs_studio_add_target(TARGET tes3mp.analyze ALL
OUTPUT FORMAT errorfile
ANALYZE tes3mp
LOG target_tes3mp.err)
endif()

View file

@ -221,10 +221,11 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
/*
Start of tes3mp addition
Check for unmodified tes3mp-credits file; this makes it so people can't repackage official releases with
their own made-up credits, though it obviously has no bearing on unofficial releases that change
the checksum below
Check for unmodified tes3mp-credits file on Windows; this makes it so people can't repackage official
releases with their own made-up credits, though it obviously has no bearing on unofficial releases that
change the checksum below
*/
#ifdef _WIN32
boost::filesystem::path folderPath(boost::filesystem::initial_path<boost::filesystem::path>());
folderPath = boost::filesystem::system_complete(boost::filesystem::path(argv[0])).remove_filename();
std::string creditsPath = folderPath.string() + "/tes3mp-credits";
@ -242,6 +243,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "tes3mp", TES3MP_CREDITS_ERROR, 0);
return false;
}
#endif
/*
End of tes3mp addition
*/

View file

@ -553,9 +553,10 @@ namespace MWClass
/*
Start of tes3mp addition
If the attacker was the LocalPlayer or LocalActor, record their target and send a packet with it
If the attacker was the LocalPlayer or LocalActor, record their target and send a
packet with it
If the victim was a LocalActor who died, record their attacker as the deathReason
If the victim was a LocalActor who died, record their attacker as the killer
*/
mwmp::Attack *localAttack = MechanicsHelper::getLocalAttack(attacker);

View file

@ -966,12 +966,13 @@ namespace MWClass
/*
Start of tes3mp addition
If the attacker was the LocalPlayer or LocalActor, record their target and send a packet with it
If the attacker was the LocalPlayer or LocalActor, record their target and send a
packet with it
If the victim was the LocalPlayer, check whether packets should be sent about
their new dynamic stats and position
If the victim was a LocalActor who died, record their attacker as the deathReason
If the victim was a LocalActor who died, record their attacker as the killer
*/
mwmp::Attack *localAttack = MechanicsHelper::getLocalAttack(attacker);

View file

@ -458,6 +458,15 @@ namespace MWGui
updateMagicMarkers();
updateCustomMarkers();
/*
Start of tes3mp addition
Update player markers when cell changes to fix their locations
*/
updatePlayerMarkers();
/*
End of tes3mp addition
*/
}
void LocalMapBase::requestMapRender(const MWWorld::CellStore *cell)

View file

@ -9,6 +9,19 @@
#include <components/misc/rng.hpp>
/*
Start of tes3mp addition
Include additional headers for multiplayer purposes
*/
#include "../mwmp/Main.hpp"
#include "../mwmp/Networking.hpp"
#include "../mwmp/LocalPlayer.hpp"
#include "../mwmp/MechanicsHelper.hpp"
/*
End of tes3mp addition
*/
#include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/windowmanager.hpp"
@ -163,9 +176,26 @@ void Recharge::onItemClicked(MyGUI::Widget *sender, const MWWorld::Ptr& item)
const ESM::Enchantment* enchantment = MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>().find(
item.getClass().getEnchantment(item));
/*
Start of tes3mp change (minor)
Send PlayerInventory packets that replace the original item with the new one
*/
mwmp::LocalPlayer *localPlayer = mwmp::Main::get().getLocalPlayer();
mwmp::Item removedItem = MechanicsHelper::getItem(item, 1);
item.getCellRef().setEnchantmentCharge(
std::min(item.getCellRef().getEnchantmentCharge() + restored, static_cast<float>(enchantment->mData.mCharge)));
mwmp::Item addedItem = MechanicsHelper::getItem(item, 1);
localPlayer->sendItemChange(addedItem, mwmp::InventoryChanges::ADD);
localPlayer->sendItemChange(removedItem, mwmp::InventoryChanges::REMOVE);
/*
End of tes3mp change (minor)
*/
MWBase::Environment::get().getWindowManager()->playSound("Enchant Success");
player.getClass().getContainerStore(player).restack(item);

View file

@ -842,6 +842,22 @@ namespace MWMechanics
if (isDamageEffect)
{
/*
Start of tes3mp addition
If the victim was a LocalActor who died, record the caster as the killer
*/
if (mwmp::Main::get().getCellController()->isLocalActor(ptr))
{
bool isSuicide = ptr == caster || caster.isEmpty();
mwmp::Main::get().getCellController()->getLocalActor(ptr)->killer = isSuicide ?
MechanicsHelper::getTarget(ptr) : MechanicsHelper::getTarget(caster);
}
/*
End of tes3mp addition
*/
if (caster == player || playerFollowers.find(caster) != playerFollowers.end())
{
if (caster.getClass().getNpcStats(caster).isWerewolf())

View file

@ -4,6 +4,19 @@
#include <components/misc/rng.hpp>
/*
Start of tes3mp addition
Include additional headers for multiplayer purposes
*/
#include "../mwmp/Main.hpp"
#include "../mwmp/Networking.hpp"
#include "../mwmp/LocalPlayer.hpp"
#include "../mwmp/MechanicsHelper.hpp"
/*
End of tes3mp addition
*/
#include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/mechanicsmanager.hpp"
@ -57,8 +70,25 @@ void Repair::repair(const MWWorld::Ptr &itemToRepair)
// repair by 'y' points
int charge = itemToRepair.getClass().getItemHealth(itemToRepair);
charge = std::min(charge + y, itemToRepair.getClass().getItemMaxHealth(itemToRepair));
/*
Start of tes3mp change (minor)
Send PlayerInventory packets that replace the original item with the new one
*/
mwmp::LocalPlayer *localPlayer = mwmp::Main::get().getLocalPlayer();
mwmp::Item removedItem = MechanicsHelper::getItem(itemToRepair, 1);
itemToRepair.getCellRef().setCharge(charge);
mwmp::Item addedItem = MechanicsHelper::getItem(itemToRepair, 1);
localPlayer->sendItemChange(addedItem, mwmp::InventoryChanges::ADD);
localPlayer->sendItemChange(removedItem, mwmp::InventoryChanges::REMOVE);
/*
End of tes3mp change (minor)
*/
// attempt to re-stack item, in case it was fully repaired
MWWorld::ContainerStoreIterator stacked = player.getClass().getContainerStore(player).restack(itemToRepair);

View file

@ -537,7 +537,7 @@ namespace MWMechanics
/*
Start of tes3mp addition
If the victim was a LocalPlayer or LocalActor who died, record their attacker as the deathReason
If the victim was a LocalPlayer or LocalActor who died, record the caster as the killer
*/
if (!wasDead && isDead)
{

View file

@ -82,8 +82,10 @@ void Cell::updateLocal(bool forceUpdate)
}
else
{
// Forcibly update this local actor if its data has never been sent before;
// otherwise, use the current forceUpdate value
if (actor->getPtr().getRefData().isEnabled())
actor->update(forceUpdate);
actor->update(actor->hasSentData ? forceUpdate : true);
++it;
}
@ -397,6 +399,9 @@ void Cell::readCellChange(ActorList& actorList)
void Cell::initializeLocalActor(const MWWorld::Ptr& ptr)
{
std::string mapIndex = Main::get().getCellController()->generateMapIndex(ptr);
LOG_APPEND(Log::LOG_VERBOSE, "- Initializing LocalActor %s in %s", mapIndex.c_str(), getDescription().c_str());
LocalActor *actor = new LocalActor();
actor->cell = *store->getCell();
actor->setPtr(ptr);
@ -406,16 +411,17 @@ void Cell::initializeLocalActor(const MWWorld::Ptr& ptr)
if (ptr.getClass().getCreatureStats(ptr).isDead())
actor->wasDead = true;
std::string mapIndex = Main::get().getCellController()->generateMapIndex(ptr);
localActors[mapIndex] = actor;
Main::get().getCellController()->setLocalActorRecord(mapIndex, getDescription());
LOG_APPEND(Log::LOG_VERBOSE, "- Initialized LocalActor %s in %s", mapIndex.c_str(), getDescription().c_str());
LOG_APPEND(Log::LOG_VERBOSE, "- Successfully initialized LocalActor %s in %s", mapIndex.c_str(), getDescription().c_str());
}
void Cell::initializeLocalActors()
{
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Initializing LocalActors in %s", getDescription().c_str());
for (const auto &mergedRef : store->getMergedRefs())
{
if (mergedRef->mClass->isActor())
@ -432,20 +438,24 @@ void Cell::initializeLocalActors()
initializeLocalActor(ptr);
}
}
LOG_APPEND(Log::LOG_VERBOSE, "- Successfully initialized LocalActors in %s", getDescription().c_str());
}
void Cell::initializeDedicatedActor(const MWWorld::Ptr& ptr)
{
std::string mapIndex = Main::get().getCellController()->generateMapIndex(ptr);
LOG_APPEND(Log::LOG_VERBOSE, "- Initializing DedicatedActor %s in %s", mapIndex.c_str(), getDescription().c_str());
DedicatedActor *actor = new DedicatedActor();
actor->cell = *store->getCell();
actor->setPtr(ptr);
std::string mapIndex = Main::get().getCellController()->generateMapIndex(ptr);
dedicatedActors[mapIndex] = actor;
Main::get().getCellController()->setDedicatedActorRecord(mapIndex, getDescription());
LOG_APPEND(Log::LOG_VERBOSE, "- Initialized DedicatedActor %s in %s", mapIndex.c_str(), getDescription().c_str());
LOG_APPEND(Log::LOG_VERBOSE, "- Successfully initialized DedicatedActor %s in %s", mapIndex.c_str(), getDescription().c_str());
}
void Cell::initializeDedicatedActors(ActorList& actorList)

View file

@ -77,6 +77,8 @@ void CellController::initializeCell(const ESM::Cell& cell)
// If this key doesn't exist, create it
if (cellsInitialized.count(mapIndex) == 0)
{
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Initializing mwmp::Cell %s", cell.getDescription().c_str());
MWWorld::CellStore *cellStore = getCellStore(cell);
if (!cellStore) return;
@ -84,7 +86,7 @@ void CellController::initializeCell(const ESM::Cell& cell)
mwmp::Cell *mpCell = new mwmp::Cell(cellStore);
cellsInitialized[mapIndex] = mpCell;
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "- Initialized mwmp::Cell %s", mpCell->getDescription().c_str());
LOG_APPEND(Log::LOG_VERBOSE, "- Successfully initialized mwmp::Cell %s", cell.getDescription().c_str());
}
}

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