From 6a2878820c6790520e6cfd08acb42bba182f21d2 Mon Sep 17 00:00:00 2001 From: Koncord Date: Sun, 9 Dec 2018 14:36:33 +0800 Subject: [PATCH] [Server] Trait all API functions as "extern C" Move Timer & Public functions to Script/Functions --- apps/openmw-mp/CMakeLists.txt | 2 + apps/openmw-mp/Script/Functions/Actors.cpp | 161 ++++++------ apps/openmw-mp/Script/Functions/Actors.hpp | 166 ++++++------- apps/openmw-mp/Script/Functions/Books.cpp | 12 +- apps/openmw-mp/Script/Functions/Books.hpp | 18 +- apps/openmw-mp/Script/Functions/Cells.cpp | 24 +- apps/openmw-mp/Script/Functions/Cells.hpp | 31 ++- apps/openmw-mp/Script/Functions/CharClass.cpp | 38 +-- apps/openmw-mp/Script/Functions/CharClass.hpp | 38 ++- apps/openmw-mp/Script/Functions/Chat.cpp | 6 +- apps/openmw-mp/Script/Functions/Chat.hpp | 12 +- apps/openmw-mp/Script/Functions/Dialogue.cpp | 16 +- apps/openmw-mp/Script/Functions/Dialogue.hpp | 23 +- apps/openmw-mp/Script/Functions/Factions.cpp | 30 +-- apps/openmw-mp/Script/Functions/Factions.hpp | 37 ++- apps/openmw-mp/Script/Functions/GUI.cpp | 30 +-- apps/openmw-mp/Script/Functions/GUI.hpp | 37 ++- apps/openmw-mp/Script/Functions/Items.cpp | 56 ++--- apps/openmw-mp/Script/Functions/Items.hpp | 65 +++-- apps/openmw-mp/Script/Functions/Mechanics.cpp | 52 ++-- apps/openmw-mp/Script/Functions/Mechanics.hpp | 59 +++-- .../Script/Functions/Miscellaneous.cpp | 14 +- .../Script/Functions/Miscellaneous.hpp | 20 +- apps/openmw-mp/Script/Functions/Objects.cpp | 226 ++++++++--------- apps/openmw-mp/Script/Functions/Objects.hpp | 233 +++++++++--------- apps/openmw-mp/Script/Functions/Positions.cpp | 22 +- apps/openmw-mp/Script/Functions/Positions.hpp | 32 ++- apps/openmw-mp/Script/Functions/Public.cpp | 29 +++ apps/openmw-mp/Script/Functions/Public.hpp | 16 ++ apps/openmw-mp/Script/Functions/Quests.cpp | 42 ++-- apps/openmw-mp/Script/Functions/Quests.hpp | 51 ++-- .../Script/Functions/RecordsDynamic.cpp | 172 ++++++------- .../Script/Functions/RecordsDynamic.hpp | 177 +++++++------ apps/openmw-mp/Script/Functions/Server.cpp | 48 ++-- apps/openmw-mp/Script/Functions/Server.hpp | 50 ++-- apps/openmw-mp/Script/Functions/Settings.cpp | 16 +- apps/openmw-mp/Script/Functions/Settings.hpp | 22 +- .../openmw-mp/Script/Functions/Shapeshift.cpp | 18 +- .../openmw-mp/Script/Functions/Shapeshift.hpp | 24 +- apps/openmw-mp/Script/Functions/Spells.cpp | 16 +- apps/openmw-mp/Script/Functions/Spells.hpp | 25 +- apps/openmw-mp/Script/Functions/Stats.cpp | 112 ++++----- apps/openmw-mp/Script/Functions/Stats.hpp | 118 +++++---- apps/openmw-mp/Script/Functions/Timer.cpp | 16 +- apps/openmw-mp/Script/Functions/Timer.hpp | 79 ++++++ .../openmw-mp/Script/Functions/Worldstate.cpp | 78 +++--- .../openmw-mp/Script/Functions/Worldstate.hpp | 89 ++++--- apps/openmw-mp/Script/ScriptFunctions.cpp | 21 -- apps/openmw-mp/Script/ScriptFunctions.hpp | 92 +------ 49 files changed, 1377 insertions(+), 1394 deletions(-) create mode 100644 apps/openmw-mp/Script/Functions/Public.cpp create mode 100644 apps/openmw-mp/Script/Functions/Public.hpp create mode 100644 apps/openmw-mp/Script/Functions/Timer.hpp diff --git a/apps/openmw-mp/CMakeLists.txt b/apps/openmw-mp/CMakeLists.txt index f134f5da7..30762ac9e 100644 --- a/apps/openmw-mp/CMakeLists.txt +++ b/apps/openmw-mp/CMakeLists.txt @@ -60,6 +60,7 @@ 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} @@ -184,6 +185,7 @@ 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} -rdynamic") # TODO: use -Wl,--dynamic-list=list.txt instead target_link_libraries(tes3mp-server ${CMAKE_THREAD_LIBS_INIT}) endif(NOT APPLE) endif(UNIX) diff --git a/apps/openmw-mp/Script/Functions/Actors.cpp b/apps/openmw-mp/Script/Functions/Actors.cpp index 909d8a3e6..08c014542 100644 --- a/apps/openmw-mp/Script/Functions/Actors.cpp +++ b/apps/openmw-mp/Script/Functions/Actors.cpp @@ -20,25 +20,25 @@ const BaseActor emptyActor = {}; static std::string tempCellDescription; -void ActorFunctions::ReadReceivedActorList() noexcept +extern "C" void ActorFunctions::ReadReceivedActorList() noexcept { readActorList = mwmp::Networking::getPtr()->getReceivedActorList(); } -void ActorFunctions::ReadCellActorList(const char* cellDescription) noexcept +extern "C" void ActorFunctions::ReadCellActorList(const char* cellDescription) noexcept { ESM::Cell esmCell = Utils::getCellFromDescription(cellDescription); Cell *serverCell = CellController::get()->getCell(&esmCell); readActorList = serverCell->getActorList(); } -void ActorFunctions::ClearActorList() noexcept +extern "C" void ActorFunctions::ClearActorList() noexcept { writeActorList.cell.blank(); writeActorList.baseActors.clear(); } -void ActorFunctions::SetActorListPid(unsigned short pid) noexcept +extern "C" void ActorFunctions::SetActorListPid(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, ); @@ -46,143 +46,143 @@ void ActorFunctions::SetActorListPid(unsigned short pid) noexcept writeActorList.guid = player->guid; } -void ActorFunctions::CopyReceivedActorListToStore() noexcept +extern "C" void ActorFunctions::CopyReceivedActorListToStore() noexcept { writeActorList = *readActorList; } -unsigned int ActorFunctions::GetActorListSize() noexcept +extern "C" unsigned int ActorFunctions::GetActorListSize() noexcept { return readActorList->count; } -unsigned char ActorFunctions::GetActorListAction() noexcept +extern "C" unsigned char ActorFunctions::GetActorListAction() noexcept { return readActorList->action; } -const char *ActorFunctions::GetActorCell(unsigned int index) noexcept +extern "C" const char *ActorFunctions::GetActorCell(unsigned int index) noexcept { tempCellDescription = readActorList->baseActors.at(index).cell.getDescription(); return tempCellDescription.c_str(); } -const char *ActorFunctions::GetActorRefId(unsigned int index) noexcept +extern "C" const char *ActorFunctions::GetActorRefId(unsigned int index) noexcept { return readActorList->baseActors.at(index).refId.c_str(); } -unsigned int ActorFunctions::GetActorRefNum(unsigned int index) noexcept +extern "C" unsigned int ActorFunctions::GetActorRefNum(unsigned int index) noexcept { return readActorList->baseActors.at(index).refNum; } -unsigned int ActorFunctions::GetActorMpNum(unsigned int index) noexcept +extern "C" unsigned int ActorFunctions::GetActorMpNum(unsigned int index) noexcept { return readActorList->baseActors.at(index).mpNum; } -double ActorFunctions::GetActorPosX(unsigned int index) noexcept +extern "C" double ActorFunctions::GetActorPosX(unsigned int index) noexcept { return readActorList->baseActors.at(index).position.pos[0]; } -double ActorFunctions::GetActorPosY(unsigned int index) noexcept +extern "C" double ActorFunctions::GetActorPosY(unsigned int index) noexcept { return readActorList->baseActors.at(index).position.pos[1]; } -double ActorFunctions::GetActorPosZ(unsigned int index) noexcept +extern "C" double ActorFunctions::GetActorPosZ(unsigned int index) noexcept { return readActorList->baseActors.at(index).position.pos[2]; } -double ActorFunctions::GetActorRotX(unsigned int index) noexcept +extern "C" double ActorFunctions::GetActorRotX(unsigned int index) noexcept { return readActorList->baseActors.at(index).position.rot[0]; } -double ActorFunctions::GetActorRotY(unsigned int index) noexcept +extern "C" double ActorFunctions::GetActorRotY(unsigned int index) noexcept { return readActorList->baseActors.at(index).position.rot[1]; } -double ActorFunctions::GetActorRotZ(unsigned int index) noexcept +extern "C" double ActorFunctions::GetActorRotZ(unsigned int index) noexcept { return readActorList->baseActors.at(index).position.rot[2]; } -double ActorFunctions::GetActorHealthBase(unsigned int index) noexcept +extern "C" double ActorFunctions::GetActorHealthBase(unsigned int index) noexcept { return readActorList->baseActors.at(index).creatureStats.mDynamic[0].mBase; } -double ActorFunctions::GetActorHealthCurrent(unsigned int index) noexcept +extern "C" double ActorFunctions::GetActorHealthCurrent(unsigned int index) noexcept { return readActorList->baseActors.at(index).creatureStats.mDynamic[0].mCurrent; } -double ActorFunctions::GetActorHealthModified(unsigned int index) noexcept +extern "C" double ActorFunctions::GetActorHealthModified(unsigned int index) noexcept { return readActorList->baseActors.at(index).creatureStats.mDynamic[0].mMod; } -double ActorFunctions::GetActorMagickaBase(unsigned int index) noexcept +extern "C" double ActorFunctions::GetActorMagickaBase(unsigned int index) noexcept { return readActorList->baseActors.at(index).creatureStats.mDynamic[1].mBase; } -double ActorFunctions::GetActorMagickaCurrent(unsigned int index) noexcept +extern "C" double ActorFunctions::GetActorMagickaCurrent(unsigned int index) noexcept { return readActorList->baseActors.at(index).creatureStats.mDynamic[1].mCurrent; } -double ActorFunctions::GetActorMagickaModified(unsigned int index) noexcept +extern "C" double ActorFunctions::GetActorMagickaModified(unsigned int index) noexcept { return readActorList->baseActors.at(index).creatureStats.mDynamic[1].mMod; } -double ActorFunctions::GetActorFatigueBase(unsigned int index) noexcept +extern "C" double ActorFunctions::GetActorFatigueBase(unsigned int index) noexcept { return readActorList->baseActors.at(index).creatureStats.mDynamic[2].mBase; } -double ActorFunctions::GetActorFatigueCurrent(unsigned int index) noexcept +extern "C" double ActorFunctions::GetActorFatigueCurrent(unsigned int index) noexcept { return readActorList->baseActors.at(index).creatureStats.mDynamic[2].mCurrent; } -double ActorFunctions::GetActorFatigueModified(unsigned int index) noexcept +extern "C" double ActorFunctions::GetActorFatigueModified(unsigned int index) noexcept { return readActorList->baseActors.at(index).creatureStats.mDynamic[2].mMod; } -const char *ActorFunctions::GetActorEquipmentItemRefId(unsigned int index, unsigned short slot) noexcept +extern "C" const char *ActorFunctions::GetActorEquipmentItemRefId(unsigned int index, unsigned short slot) noexcept { return readActorList->baseActors.at(index).equipmentItems[slot].refId.c_str(); } -int ActorFunctions::GetActorEquipmentItemCount(unsigned int index, unsigned short slot) noexcept +extern "C" int ActorFunctions::GetActorEquipmentItemCount(unsigned int index, unsigned short slot) noexcept { return readActorList->baseActors.at(index).equipmentItems[slot].count; } -int ActorFunctions::GetActorEquipmentItemCharge(unsigned int index, unsigned short slot) noexcept +extern "C" int ActorFunctions::GetActorEquipmentItemCharge(unsigned int index, unsigned short slot) noexcept { return readActorList->baseActors.at(index).equipmentItems[slot].charge; } -double ActorFunctions::GetActorEquipmentItemEnchantmentCharge(unsigned int index, unsigned short slot) noexcept +extern "C" double ActorFunctions::GetActorEquipmentItemEnchantmentCharge(unsigned int index, unsigned short slot) noexcept { return readActorList->baseActors.at(index).equipmentItems[slot].enchantmentCharge; } -bool ActorFunctions::DoesActorHavePlayerKiller(unsigned int index) noexcept +extern "C" bool ActorFunctions::DoesActorHavePlayerKiller(unsigned int index) noexcept { return readActorList->baseActors.at(index).killer.isPlayer; } -int ActorFunctions::GetActorKillerPid(unsigned int index) noexcept +extern "C" int ActorFunctions::GetActorKillerPid(unsigned int index) noexcept { Player *player = Players::getPlayer(readActorList->baseActors.at(index).killer.guid); @@ -192,136 +192,136 @@ int ActorFunctions::GetActorKillerPid(unsigned int index) noexcept return -1; } -const char *ActorFunctions::GetActorKillerRefId(unsigned int index) noexcept +extern "C" const char *ActorFunctions::GetActorKillerRefId(unsigned int index) noexcept { return readActorList->baseActors.at(index).killer.refId.c_str(); } -unsigned int ActorFunctions::GetActorKillerRefNum(unsigned int index) noexcept +extern "C" unsigned int ActorFunctions::GetActorKillerRefNum(unsigned int index) noexcept { return readActorList->baseActors.at(index).killer.refNum; } -unsigned int ActorFunctions::GetActorKillerMpNum(unsigned int index) noexcept +extern "C" unsigned int ActorFunctions::GetActorKillerMpNum(unsigned int index) noexcept { return readActorList->baseActors.at(index).killer.mpNum; } -const char *ActorFunctions::GetActorKillerName(unsigned int index) noexcept +extern "C" const char *ActorFunctions::GetActorKillerName(unsigned int index) noexcept { return readActorList->baseActors.at(index).killer.name.c_str(); } -bool ActorFunctions::DoesActorHavePosition(unsigned int index) noexcept +extern "C" bool ActorFunctions::DoesActorHavePosition(unsigned int index) noexcept { return readActorList->baseActors.at(index).hasPositionData; } -bool ActorFunctions::DoesActorHaveStatsDynamic(unsigned int index) noexcept +extern "C" bool ActorFunctions::DoesActorHaveStatsDynamic(unsigned int index) noexcept { return readActorList->baseActors.at(index).hasStatsDynamicData; } -void ActorFunctions::SetActorListCell(const char* cellDescription) noexcept +extern "C" void ActorFunctions::SetActorListCell(const char* cellDescription) noexcept { writeActorList.cell = Utils::getCellFromDescription(cellDescription); } -void ActorFunctions::SetActorListAction(unsigned char action) noexcept +extern "C" void ActorFunctions::SetActorListAction(unsigned char action) noexcept { writeActorList.action = action; } -void ActorFunctions::SetActorCell(const char* cellDescription) noexcept +extern "C" void ActorFunctions::SetActorCell(const char* cellDescription) noexcept { tempActor.cell = Utils::getCellFromDescription(cellDescription); } -void ActorFunctions::SetActorRefId(const char* refId) noexcept +extern "C" void ActorFunctions::SetActorRefId(const char* refId) noexcept { tempActor.refId = refId; } -void ActorFunctions::SetActorRefNum(int refNum) noexcept +extern "C" void ActorFunctions::SetActorRefNum(int refNum) noexcept { tempActor.refNum = refNum; } -void ActorFunctions::SetActorMpNum(int mpNum) noexcept +extern "C" void ActorFunctions::SetActorMpNum(int mpNum) noexcept { tempActor.mpNum = mpNum; } -void ActorFunctions::SetActorPosition(double x, double y, double z) noexcept +extern "C" void ActorFunctions::SetActorPosition(double x, double y, double z) noexcept { tempActor.position.pos[0] = x; tempActor.position.pos[1] = y; tempActor.position.pos[2] = z; } -void ActorFunctions::SetActorRotation(double x, double y, double z) noexcept +extern "C" void ActorFunctions::SetActorRotation(double x, double y, double z) noexcept { tempActor.position.rot[0] = x; tempActor.position.rot[1] = y; tempActor.position.rot[2] = z; } -void ActorFunctions::SetActorHealthBase(double value) noexcept +extern "C" void ActorFunctions::SetActorHealthBase(double value) noexcept { tempActor.creatureStats.mDynamic[0].mBase = value; } -void ActorFunctions::SetActorHealthCurrent(double value) noexcept +extern "C" void ActorFunctions::SetActorHealthCurrent(double value) noexcept { tempActor.creatureStats.mDynamic[0].mCurrent = value; } -void ActorFunctions::SetActorHealthModified(double value) noexcept +extern "C" void ActorFunctions::SetActorHealthModified(double value) noexcept { tempActor.creatureStats.mDynamic[0].mMod = value; } -void ActorFunctions::SetActorMagickaBase(double value) noexcept +extern "C" void ActorFunctions::SetActorMagickaBase(double value) noexcept { tempActor.creatureStats.mDynamic[1].mBase = value; } -void ActorFunctions::SetActorMagickaCurrent(double value) noexcept +extern "C" void ActorFunctions::SetActorMagickaCurrent(double value) noexcept { tempActor.creatureStats.mDynamic[1].mCurrent = value; } -void ActorFunctions::SetActorMagickaModified(double value) noexcept +extern "C" void ActorFunctions::SetActorMagickaModified(double value) noexcept { tempActor.creatureStats.mDynamic[1].mMod = value; } -void ActorFunctions::SetActorFatigueBase(double value) noexcept +extern "C" void ActorFunctions::SetActorFatigueBase(double value) noexcept { tempActor.creatureStats.mDynamic[2].mBase = value; } -void ActorFunctions::SetActorFatigueCurrent(double value) noexcept +extern "C" void ActorFunctions::SetActorFatigueCurrent(double value) noexcept { tempActor.creatureStats.mDynamic[2].mCurrent = value; } -void ActorFunctions::SetActorFatigueModified(double value) noexcept +extern "C" void ActorFunctions::SetActorFatigueModified(double value) noexcept { tempActor.creatureStats.mDynamic[2].mMod = value; } -void ActorFunctions::SetActorSound(const char* sound) noexcept +extern "C" void ActorFunctions::SetActorSound(const char* sound) noexcept { tempActor.sound = sound; } -void ActorFunctions::SetActorAIAction(unsigned int action) noexcept +extern "C" void ActorFunctions::SetActorAIAction(unsigned int action) noexcept { tempActor.aiAction = action; } -void ActorFunctions::SetActorAITargetToPlayer(unsigned short pid) noexcept +extern "C" void ActorFunctions::SetActorAITargetToPlayer(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, ); @@ -332,7 +332,7 @@ void ActorFunctions::SetActorAITargetToPlayer(unsigned short pid) noexcept tempActor.aiTarget.guid = player->guid; } -void ActorFunctions::SetActorAITargetToObject(int refNum, int mpNum) noexcept +extern "C" void ActorFunctions::SetActorAITargetToObject(int refNum, int mpNum) noexcept { tempActor.hasAiTarget = true; tempActor.aiTarget.isPlayer = false; @@ -341,29 +341,29 @@ void ActorFunctions::SetActorAITargetToObject(int refNum, int mpNum) noexcept tempActor.aiTarget.mpNum = mpNum; } -void ActorFunctions::SetActorAICoordinates(double x, double y, double z) noexcept +extern "C" void ActorFunctions::SetActorAICoordinates(double x, double y, double z) noexcept { tempActor.aiCoordinates.pos[0] = x; tempActor.aiCoordinates.pos[1] = y; tempActor.aiCoordinates.pos[2] = z; } -void ActorFunctions::SetActorAIDistance(unsigned int distance) noexcept +extern "C" void ActorFunctions::SetActorAIDistance(unsigned int distance) noexcept { tempActor.aiDistance = distance; } -void ActorFunctions::SetActorAIDuration(unsigned int duration) noexcept +extern "C" void ActorFunctions::SetActorAIDuration(unsigned int duration) noexcept { tempActor.aiDuration = duration; } -void ActorFunctions::SetActorAIRepetition(bool shouldRepeat) noexcept +extern "C" void ActorFunctions::SetActorAIRepetition(bool shouldRepeat) noexcept { tempActor.aiShouldRepeat = shouldRepeat; } -void ActorFunctions::EquipActorItem(unsigned short slot, const char *refId, unsigned int count, int charge, double enchantmentCharge) noexcept +extern "C" void ActorFunctions::EquipActorItem(unsigned short slot, const char *refId, unsigned int count, int charge, double enchantmentCharge) noexcept { tempActor.equipmentItems[slot].refId = refId; tempActor.equipmentItems[slot].count = count; @@ -371,26 +371,26 @@ void ActorFunctions::EquipActorItem(unsigned short slot, const char *refId, unsi tempActor.equipmentItems[slot].enchantmentCharge = enchantmentCharge; } -void ActorFunctions::UnequipActorItem(unsigned short slot) noexcept +extern "C" void ActorFunctions::UnequipActorItem(unsigned short slot) noexcept { ActorFunctions::EquipActorItem(slot, "", 0, -1, -1); } -void ActorFunctions::AddActor() noexcept +extern "C" void ActorFunctions::AddActor() noexcept { writeActorList.baseActors.push_back(tempActor); tempActor = emptyActor; } -void ActorFunctions::SendActorList() noexcept +extern "C" void ActorFunctions::SendActorList() noexcept { mwmp::ActorPacket *actorPacket = mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_LIST); actorPacket->setActorList(&writeActorList); actorPacket->Send(writeActorList.guid); } -void ActorFunctions::SendActorAuthority() noexcept +extern "C" void ActorFunctions::SendActorAuthority() noexcept { Cell *serverCell = CellController::get()->getCell(&writeActorList.cell); @@ -407,7 +407,7 @@ void ActorFunctions::SendActorAuthority() noexcept } } -void ActorFunctions::SendActorPosition(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept +extern "C" void ActorFunctions::SendActorPosition(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept { mwmp::ActorPacket *actorPacket = mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_POSITION); actorPacket->setActorList(&writeActorList); @@ -426,7 +426,7 @@ void ActorFunctions::SendActorPosition(bool sendToOtherVisitors, bool skipAttach } } -void ActorFunctions::SendActorStatsDynamic(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept +extern "C" void ActorFunctions::SendActorStatsDynamic(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept { mwmp::ActorPacket *actorPacket = mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_STATS_DYNAMIC); actorPacket->setActorList(&writeActorList); @@ -445,7 +445,7 @@ void ActorFunctions::SendActorStatsDynamic(bool sendToOtherVisitors, bool skipAt } } -void ActorFunctions::SendActorEquipment(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept +extern "C" void ActorFunctions::SendActorEquipment(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept { mwmp::ActorPacket *actorPacket = mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_EQUIPMENT); actorPacket->setActorList(&writeActorList); @@ -464,7 +464,7 @@ void ActorFunctions::SendActorEquipment(bool sendToOtherVisitors, bool skipAttac } } -void ActorFunctions::SendActorSpeech(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept +extern "C" void ActorFunctions::SendActorSpeech(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept { mwmp::ActorPacket *actorPacket = mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_SPEECH); actorPacket->setActorList(&writeActorList); @@ -483,7 +483,7 @@ void ActorFunctions::SendActorSpeech(bool sendToOtherVisitors, bool skipAttached } } -void ActorFunctions::SendActorAI(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept +extern "C" void ActorFunctions::SendActorAI(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept { mwmp::ActorPacket *actorPacket = mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_AI); actorPacket->setActorList(&writeActorList); @@ -502,7 +502,7 @@ void ActorFunctions::SendActorAI(bool sendToOtherVisitors, bool skipAttachedPlay } } -void ActorFunctions::SendActorCellChange(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept +extern "C" void ActorFunctions::SendActorCellChange(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept { mwmp::ActorPacket *actorPacket = mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_CELL_CHANGE); actorPacket->setActorList(&writeActorList); @@ -521,36 +521,35 @@ void ActorFunctions::SendActorCellChange(bool sendToOtherVisitors, bool skipAtta } } - -// All methods below are deprecated versions of methods from above +extern "C" // All methods below are deprecated versions of methods from above void ActorFunctions::ReadLastActorList() noexcept { ReadReceivedActorList(); } -void ActorFunctions::InitializeActorList(unsigned short pid) noexcept +extern "C" void ActorFunctions::InitializeActorList(unsigned short pid) noexcept { ClearActorList(); SetActorListPid(pid); } -void ActorFunctions::CopyLastActorListToStore() noexcept +extern "C" void ActorFunctions::CopyLastActorListToStore() noexcept { CopyLastActorListToStore(); } -unsigned int ActorFunctions::GetActorRefNumIndex(unsigned int index) noexcept +extern "C" unsigned int ActorFunctions::GetActorRefNumIndex(unsigned int index) noexcept { return GetActorRefNum(index); } -unsigned int ActorFunctions::GetActorKillerRefNumIndex(unsigned int index) noexcept +extern "C" unsigned int ActorFunctions::GetActorKillerRefNumIndex(unsigned int index) noexcept { return GetActorKillerRefNum(index); } -void ActorFunctions::SetActorRefNumIndex(int refNum) noexcept +extern "C" void ActorFunctions::SetActorRefNumIndex(int refNum) noexcept { tempActor.refNum = refNum; } diff --git a/apps/openmw-mp/Script/Functions/Actors.hpp b/apps/openmw-mp/Script/Functions/Actors.hpp index a6035e9da..df2d3dcc4 100644 --- a/apps/openmw-mp/Script/Functions/Actors.hpp +++ b/apps/openmw-mp/Script/Functions/Actors.hpp @@ -102,16 +102,14 @@ {"GetActorKillerRefNumIndex", ActorFunctions::GetActorKillerRefNumIndex},\ {"SetActorRefNumIndex", ActorFunctions::SetActorRefNumIndex} -class ActorFunctions +namespace ActorFunctions { -public: - /** * \brief Use the last actor list received by the server as the one being read. * * \return void */ - static void ReadReceivedActorList() noexcept; + extern "C" void ReadReceivedActorList() noexcept; /** * \brief Use the temporary actor list stored for a cell as the one being read. @@ -122,14 +120,14 @@ public: * \param cellDescription The description of the cell whose actor list should be read. * \return void */ - static void ReadCellActorList(const char* cellDescription) noexcept; + extern "C" void ReadCellActorList(const char* cellDescription) noexcept; /** * \brief Clear the data from the actor list stored on the server. * * \return void */ - static void ClearActorList() noexcept; + extern "C" void ClearActorList() noexcept; /** * \brief Set the pid attached to the ActorList. @@ -137,7 +135,7 @@ public: * \param pid The player ID to whom the actor list should be attached. * \return void */ - static void SetActorListPid(unsigned short pid) noexcept; + extern "C" void SetActorListPid(unsigned short pid) noexcept; /** * \brief Take the contents of the read-only actor list last received by the @@ -146,21 +144,21 @@ public: * * \return void */ - static void CopyReceivedActorListToStore() noexcept; + extern "C" void CopyReceivedActorListToStore() noexcept; /** * \brief Get the number of indexes in the read actor list. * * \return The number of indexes. */ - static unsigned int GetActorListSize() noexcept; + extern "C" 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). */ - static unsigned char GetActorListAction() noexcept; + extern "C" unsigned char GetActorListAction() noexcept; /** * \brief Get the cell description of the actor at a certain index in the read actor list. @@ -168,7 +166,7 @@ public: * \param index The index of the actor. * \return The cell description. */ - static const char *GetActorCell(unsigned int index) noexcept; + extern "C" 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 +174,7 @@ public: * \param index The index of the actor. * \return The refId. */ - static const char *GetActorRefId(unsigned int index) noexcept; + extern "C" 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 +182,7 @@ public: * \param index The index of the actor. * \return The refNum. */ - static unsigned int GetActorRefNum(unsigned int index) noexcept; + extern "C" 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 +190,7 @@ public: * \param index The index of the actor. * \return The mpNum. */ - static unsigned int GetActorMpNum(unsigned int index) noexcept; + extern "C" 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 +198,7 @@ public: * \param index The index of the actor. * \return The X position. */ - static double GetActorPosX(unsigned int index) noexcept; + extern "C" 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 +206,7 @@ public: * \param index The index of the actor. * \return The Y position. */ - static double GetActorPosY(unsigned int index) noexcept; + extern "C" 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 +214,7 @@ public: * \param index The index of the actor. * \return The Z position. */ - static double GetActorPosZ(unsigned int index) noexcept; + extern "C" 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 +222,7 @@ public: * \param index The index of the actor. * \return The X rotation. */ - static double GetActorRotX(unsigned int index) noexcept; + extern "C" 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 +230,7 @@ public: * \param index The index of the actor. * \return The Y rotation. */ - static double GetActorRotY(unsigned int index) noexcept; + extern "C" 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 +238,7 @@ public: * \param index The index of the actor. * \return The Z rotation. */ - static double GetActorRotZ(unsigned int index) noexcept; + extern "C" 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 +246,7 @@ public: * \param index The index of the actor. * \return The base health. */ - static double GetActorHealthBase(unsigned int index) noexcept; + extern "C" 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 +254,7 @@ public: * \param index The index of the actor. * \return The current health. */ - static double GetActorHealthCurrent(unsigned int index) noexcept; + extern "C" 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 +262,7 @@ public: * \param index The index of the actor. * \return The modified health. */ - static double GetActorHealthModified(unsigned int index) noexcept; + extern "C" 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 +270,7 @@ public: * \param index The index of the actor. * \return The base magicka. */ - static double GetActorMagickaBase(unsigned int index) noexcept; + extern "C" 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 +278,7 @@ public: * \param index The index of the actor. * \return The current magicka. */ - static double GetActorMagickaCurrent(unsigned int index) noexcept; + extern "C" 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 +286,7 @@ public: * \param index The index of the actor. * \return The modified magicka. */ - static double GetActorMagickaModified(unsigned int index) noexcept; + extern "C" 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 +294,7 @@ public: * \param index The index of the actor. * \return The base fatigue. */ - static double GetActorFatigueBase(unsigned int index) noexcept; + extern "C" 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 +302,7 @@ public: * \param index The index of the actor. * \return The current fatigue. */ - static double GetActorFatigueCurrent(unsigned int index) noexcept; + extern "C" 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 +310,7 @@ public: * \param index The index of the actor. * \return The modified fatigue. */ - static double GetActorFatigueModified(unsigned int index) noexcept; + extern "C" 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 +320,7 @@ public: * \param slot The slot of the equipment item. * \return The refId. */ - static const char *GetActorEquipmentItemRefId(unsigned int index, unsigned short slot) noexcept; + extern "C" 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 +330,7 @@ public: * \param slot The slot of the equipment item. * \return The item count. */ - static int GetActorEquipmentItemCount(unsigned int index, unsigned short slot) noexcept; + extern "C" 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 +340,7 @@ public: * \param slot The slot of the equipment item. * \return The charge. */ - static int GetActorEquipmentItemCharge(unsigned int index, unsigned short slot) noexcept; + extern "C" 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 +350,7 @@ public: * \param slot The slot of the equipment item. * \return The enchantment charge. */ - static double GetActorEquipmentItemEnchantmentCharge(unsigned int index, unsigned short slot) noexcept; + extern "C" 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 +358,7 @@ public: * \param index The index of the actor. * \return Whether the actor was killed by a player. */ - static bool DoesActorHavePlayerKiller(unsigned int index) noexcept; + extern "C" 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 +366,7 @@ public: * \param index The index of the actor. * \return The player ID of the killer. */ - static int GetActorKillerPid(unsigned int index) noexcept; + extern "C" 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 +374,7 @@ public: * \param index The index of the actor. * \return The refId of the killer. */ - static const char *GetActorKillerRefId(unsigned int index) noexcept; + extern "C" 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 +382,7 @@ public: * \param index The index of the actor. * \return The refNum of the killer. */ - static unsigned int GetActorKillerRefNum(unsigned int index) noexcept; + extern "C" 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 +390,7 @@ public: * \param index The index of the actor. * \return The mpNum of the killer. */ - static unsigned int GetActorKillerMpNum(unsigned int index) noexcept; + extern "C" 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 +398,7 @@ public: * \param index The index of the actor. * \return The name of the killer. */ - static const char *GetActorKillerName(unsigned int index) noexcept; + extern "C" 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 +409,7 @@ public: * \param index The index of the actor. * \return Whether the read actor list contains positional data. */ - static bool DoesActorHavePosition(unsigned int index) noexcept; + extern "C" 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 +420,7 @@ public: * \param index The index of the actor. * \return Whether the read actor list contains dynamic stats data. */ - static bool DoesActorHaveStatsDynamic(unsigned int index) noexcept; + extern "C" bool DoesActorHaveStatsDynamic(unsigned int index) noexcept; /** * \brief Set the cell of the temporary actor list stored on the server. @@ -433,7 +431,7 @@ public: * \param cellDescription The description of the cell. * \return void */ - static void SetActorListCell(const char* cellDescription) noexcept; + extern "C" void SetActorListCell(const char* cellDescription) noexcept; /** * \brief Set the action type of the temporary actor list stored on the server. @@ -441,7 +439,7 @@ public: * \param action The action type (0 for SET, 1 for ADD, 2 for REMOVE, 3 for REQUEST). * \return void */ - static void SetActorListAction(unsigned char action) noexcept; + extern "C" void SetActorListAction(unsigned char action) noexcept; /** * \brief Set the cell of the temporary actor stored on the server. @@ -455,7 +453,7 @@ public: * \param cellDescription The description of the cell. * \return void */ - static void SetActorCell(const char* cellDescription) noexcept; + extern "C" void SetActorCell(const char* cellDescription) noexcept; /** * \brief Set the refId of the temporary actor stored on the server. @@ -463,7 +461,7 @@ public: * \param refId The refId. * \return void */ - static void SetActorRefId(const char* refId) noexcept; + extern "C" void SetActorRefId(const char* refId) noexcept; /** * \brief Set the refNum of the temporary actor stored on the server. @@ -471,7 +469,7 @@ public: * \param refNum The refNum. * \return void */ - static void SetActorRefNum(int refNum) noexcept; + extern "C" void SetActorRefNum(int refNum) noexcept; /** * \brief Set the mpNum of the temporary actor stored on the server. @@ -479,7 +477,7 @@ public: * \param mpNum The mpNum. * \return void */ - static void SetActorMpNum(int mpNum) noexcept; + extern "C" void SetActorMpNum(int mpNum) noexcept; /** * \brief Set the position of the temporary actor stored on the server. @@ -489,7 +487,7 @@ public: * \param z The Z position. * \return void */ - static void SetActorPosition(double x, double y, double z) noexcept; + extern "C" void SetActorPosition(double x, double y, double z) noexcept; /** * \brief Set the rotation of the temporary actor stored on the server. @@ -499,7 +497,7 @@ public: * \param z The Z rotation. * \return void */ - static void SetActorRotation(double x, double y, double z) noexcept; + extern "C" void SetActorRotation(double x, double y, double z) noexcept; /** * \brief Set the base health of the temporary actor stored on the server. @@ -507,7 +505,7 @@ public: * \param value The new value. * \return void */ - static void SetActorHealthBase(double value) noexcept; + extern "C" void SetActorHealthBase(double value) noexcept; /** * \brief Set the current health of the temporary actor stored on the server. @@ -515,7 +513,7 @@ public: * \param value The new value. * \return void */ - static void SetActorHealthCurrent(double value) noexcept; + extern "C" void SetActorHealthCurrent(double value) noexcept; /** * \brief Set the modified health of the temporary actor stored on the server. @@ -523,7 +521,7 @@ public: * \param value The new value. * \return void */ - static void SetActorHealthModified(double value) noexcept; + extern "C" void SetActorHealthModified(double value) noexcept; /** * \brief Set the base magicka of the temporary actor stored on the server. @@ -531,7 +529,7 @@ public: * \param value The new value. * \return void */ - static void SetActorMagickaBase(double value) noexcept; + extern "C" void SetActorMagickaBase(double value) noexcept; /** * \brief Set the current magicka of the temporary actor stored on the server. @@ -539,7 +537,7 @@ public: * \param value The new value. * \return void */ - static void SetActorMagickaCurrent(double value) noexcept; + extern "C" void SetActorMagickaCurrent(double value) noexcept; /** * \brief Set the modified magicka of the temporary actor stored on the server. @@ -547,7 +545,7 @@ public: * \param value The new value. * \return void */ - static void SetActorMagickaModified(double value) noexcept; + extern "C" void SetActorMagickaModified(double value) noexcept; /** * \brief Set the base fatigue of the temporary actor stored on the server. @@ -555,7 +553,7 @@ public: * \param value The new value. * \return void */ - static void SetActorFatigueBase(double value) noexcept; + extern "C" void SetActorFatigueBase(double value) noexcept; /** * \brief Set the current fatigue of the temporary actor stored on the server. @@ -563,7 +561,7 @@ public: * \param value The new value. * \return void */ - static void SetActorFatigueCurrent(double value) noexcept; + extern "C" void SetActorFatigueCurrent(double value) noexcept; /** * \brief Set the modified fatigue of the temporary actor stored on the server. @@ -571,7 +569,7 @@ public: * \param value The new value. * \return void */ - static void SetActorFatigueModified(double value) noexcept; + extern "C" void SetActorFatigueModified(double value) noexcept; /** * \brief Set the sound of the temporary actor stored on the server. @@ -579,7 +577,7 @@ public: * \param sound The sound. * \return void */ - static void SetActorSound(const char* sound) noexcept; + extern "C" void SetActorSound(const char* sound) noexcept; /** * \brief Set the AI action of the temporary actor stored on the server. @@ -587,7 +585,7 @@ public: * \param action The new action. * \return void */ - static void SetActorAIAction(unsigned int action) noexcept; + extern "C" void SetActorAIAction(unsigned int action) noexcept; /** * \brief Set a player as the AI target of the temporary actor stored on the server. @@ -595,7 +593,7 @@ public: * \param pid The player ID. * \return void */ - static void SetActorAITargetToPlayer(unsigned short pid) noexcept; + extern "C" void SetActorAITargetToPlayer(unsigned short pid) noexcept; /** * \brief Set another object as the AI target of the temporary actor stored on the server. @@ -604,7 +602,7 @@ public: * \param mpNum The mpNum of the target object. * \return void */ - static void SetActorAITargetToObject(int refNum, int mpNum) noexcept; + extern "C" void SetActorAITargetToObject(int refNum, int mpNum) noexcept; /** * \brief Set the coordinates for the AI package associated with the current AI action. @@ -614,7 +612,7 @@ public: * \param z The Z coordinate. * \return void */ - static void SetActorAICoordinates(double x, double y, double z) noexcept; + extern "C" 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 +620,7 @@ public: * \param duration The distance of the package. * \return void */ - static void SetActorAIDistance(unsigned int distance) noexcept; + extern "C" void SetActorAIDistance(unsigned int distance) noexcept; /** * \brief Set the duration of the AI package associated with the current AI action. @@ -630,7 +628,7 @@ public: * \param duration The duration of the package. * \return void */ - static void SetActorAIDuration(unsigned int duration) noexcept; + extern "C" void SetActorAIDuration(unsigned int duration) noexcept; /** * \brief Set whether the current AI package should be repeated. @@ -640,7 +638,7 @@ public: * \param shouldRepeat Whether the package should be repeated. * \return void */ - static void SetActorAIRepetition(bool shouldRepeat) noexcept; + extern "C" void SetActorAIRepetition(bool shouldRepeat) noexcept; /** * \brief Equip an item in a certain slot of the equipment of the temporary actor stored @@ -653,7 +651,7 @@ public: * \param enchantmentCharge The enchantment charge of the item. * \return void */ - static void EquipActorItem(unsigned short slot, const char* refId, unsigned int count, int charge, double enchantmentCharge = -1) noexcept; + extern "C" 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 +660,7 @@ public: * \param slot The equipment slot. * \return void */ - static void UnequipActorItem(unsigned short slot) noexcept; + extern "C" 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 +670,7 @@ public: * * \return void */ - static void AddActor() noexcept; + extern "C" void AddActor() noexcept; /** * \brief Send an ActorList packet. @@ -681,7 +679,7 @@ public: * * \return void */ - static void SendActorList() noexcept; + extern "C" void SendActorList() noexcept; /** * \brief Send an ActorAuthority packet. @@ -693,7 +691,7 @@ public: * * \return void */ - static void SendActorAuthority() noexcept; + extern "C" void SendActorAuthority() noexcept; /** * \brief Send an ActorPosition packet. @@ -705,7 +703,7 @@ public: * * \return void */ - static void SendActorPosition(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept; + extern "C" void SendActorPosition(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept; /** * \brief Send an ActorStatsDynamic packet. @@ -717,7 +715,7 @@ public: * * \return void */ - static void SendActorStatsDynamic(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept; + extern "C" void SendActorStatsDynamic(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept; /** * \brief Send an ActorEquipment packet. @@ -729,7 +727,7 @@ public: * * \return void */ - static void SendActorEquipment(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept; + extern "C" void SendActorEquipment(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept; /** * \brief Send an ActorSpeech packet. @@ -740,7 +738,7 @@ public: * to the packet (false by default). * \return void */ - static void SendActorSpeech(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept; + extern "C" void SendActorSpeech(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept; /** * \brief Send an ActorAI packet. @@ -751,7 +749,7 @@ public: * to the packet (false by default). * \return void */ - static void SendActorAI(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept; + extern "C" void SendActorAI(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept; /** * \brief Send an ActorCellChange packet. @@ -763,18 +761,18 @@ public: * * \return void */ - static void SendActorCellChange(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept; + extern "C" void SendActorCellChange(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept; // All methods below are deprecated versions of methods from above - static void ReadLastActorList() noexcept; - static void InitializeActorList(unsigned short pid) noexcept; - static void CopyLastActorListToStore() noexcept; - static unsigned int GetActorRefNumIndex(unsigned int index) noexcept; - static unsigned int GetActorKillerRefNumIndex(unsigned int index) noexcept; - static void SetActorRefNumIndex(int refNum) noexcept; -}; + extern "C" void ReadLastActorList() noexcept; + extern "C" void InitializeActorList(unsigned short pid) noexcept; + extern "C" void CopyLastActorListToStore() noexcept; + extern "C" unsigned int GetActorRefNumIndex(unsigned int index) noexcept; + extern "C" unsigned int GetActorKillerRefNumIndex(unsigned int index) noexcept; + extern "C" void SetActorRefNumIndex(int refNum) noexcept; +} #endif //OPENMW_ACTORAPI_HPP diff --git a/apps/openmw-mp/Script/Functions/Books.cpp b/apps/openmw-mp/Script/Functions/Books.cpp index 49556f32f..b7fcb506f 100644 --- a/apps/openmw-mp/Script/Functions/Books.cpp +++ b/apps/openmw-mp/Script/Functions/Books.cpp @@ -7,7 +7,7 @@ using namespace mwmp; -void BookFunctions::ClearBookChanges(unsigned short pid) noexcept +extern "C" void BookFunctions::ClearBookChanges(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, ); @@ -15,7 +15,7 @@ void BookFunctions::ClearBookChanges(unsigned short pid) noexcept player->bookChanges.books.clear(); } -unsigned int BookFunctions::GetBookChangesSize(unsigned short pid) noexcept +extern "C" unsigned int BookFunctions::GetBookChangesSize(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -23,7 +23,7 @@ unsigned int BookFunctions::GetBookChangesSize(unsigned short pid) noexcept return player->bookChanges.count; } -void BookFunctions::AddBook(unsigned short pid, const char* bookId) noexcept +extern "C" void BookFunctions::AddBook(unsigned short pid, const char* bookId) noexcept { Player *player; GET_PLAYER(pid, player, ); @@ -34,7 +34,7 @@ void BookFunctions::AddBook(unsigned short pid, const char* bookId) noexcept player->bookChanges.books.push_back(book); } -const char *BookFunctions::GetBookId(unsigned short pid, unsigned int index) noexcept +extern "C" const char *BookFunctions::GetBookId(unsigned short pid, unsigned int index) noexcept { Player *player; GET_PLAYER(pid, player, ""); @@ -45,7 +45,7 @@ const char *BookFunctions::GetBookId(unsigned short pid, unsigned int index) noe return player->bookChanges.books.at(index).bookId.c_str(); } -void BookFunctions::SendBookChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept +extern "C" void BookFunctions::SendBookChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept { Player *player; GET_PLAYER(pid, player, ); @@ -62,7 +62,7 @@ void BookFunctions::SendBookChanges(unsigned short pid, bool sendToOtherPlayers, // All methods below are deprecated versions of methods from above -void BookFunctions::InitializeBookChanges(unsigned short pid) noexcept +extern "C" void BookFunctions::InitializeBookChanges(unsigned short pid) noexcept { ClearBookChanges(pid); } diff --git a/apps/openmw-mp/Script/Functions/Books.hpp b/apps/openmw-mp/Script/Functions/Books.hpp index b01f26b0f..c28148947 100644 --- a/apps/openmw-mp/Script/Functions/Books.hpp +++ b/apps/openmw-mp/Script/Functions/Books.hpp @@ -14,9 +14,8 @@ \ {"InitializeBookChanges", BookFunctions::InitializeBookChanges} -class BookFunctions +namespace BookFunctions { -public: /** * \brief Clear the last recorded book changes for a player. @@ -26,7 +25,7 @@ public: * \param pid The player ID whose book changes should be used. * \return void */ - static void ClearBookChanges(unsigned short pid) noexcept; + extern "C" void ClearBookChanges(unsigned short pid) noexcept; /** * \brief Get the number of indexes in a player's latest book changes. @@ -34,7 +33,7 @@ public: * \param pid The player ID whose book changes should be used. * \return The number of indexes. */ - static unsigned int GetBookChangesSize(unsigned short pid) noexcept; + extern "C" unsigned int GetBookChangesSize(unsigned short pid) noexcept; /** * \brief Add a new book to the book changes for a player. @@ -43,7 +42,7 @@ public: * \param bookId The bookId of the book. * \return void */ - static void AddBook(unsigned short pid, const char* bookId) noexcept; + extern "C" void AddBook(unsigned short pid, const char* bookId) noexcept; /** * \brief Get the bookId at a certain index in a player's latest book changes. @@ -52,7 +51,7 @@ public: * \param index The index of the book. * \return The bookId. */ - static const char *GetBookId(unsigned short pid, unsigned int index) noexcept; + extern "C" const char *GetBookId(unsigned short pid, unsigned int index) noexcept; /** * \brief Send a PlayerBook packet with a player's recorded book changes. @@ -64,12 +63,11 @@ public: * to the packet (false by default). * \return void */ - static void SendBookChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept; + extern "C" void SendBookChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept; // All methods below are deprecated versions of methods from above - static void InitializeBookChanges(unsigned short pid) noexcept; - -}; + extern "C" void InitializeBookChanges(unsigned short pid) noexcept; +} #endif //OPENMW_BOOKAPI_HPP diff --git a/apps/openmw-mp/Script/Functions/Cells.cpp b/apps/openmw-mp/Script/Functions/Cells.cpp index 2431094d5..c78198fba 100644 --- a/apps/openmw-mp/Script/Functions/Cells.cpp +++ b/apps/openmw-mp/Script/Functions/Cells.cpp @@ -12,7 +12,7 @@ using namespace std; static std::string tempCellDescription; -unsigned int CellFunctions::GetCellStateChangesSize(unsigned short pid) noexcept +extern "C" unsigned int CellFunctions::GetCellStateChangesSize(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -20,7 +20,7 @@ unsigned int CellFunctions::GetCellStateChangesSize(unsigned short pid) noexcept return player->cellStateChanges.count; } -unsigned int CellFunctions::GetCellStateType(unsigned short pid, unsigned int index) noexcept +extern "C" unsigned int CellFunctions::GetCellStateType(unsigned short pid, unsigned int index) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -28,7 +28,7 @@ unsigned int CellFunctions::GetCellStateType(unsigned short pid, unsigned int in return player->cellStateChanges.cellStates.at(index).type; } -const char *CellFunctions::GetCellStateDescription(unsigned short pid, unsigned int index) noexcept +extern "C" const char *CellFunctions::GetCellStateDescription(unsigned short pid, unsigned int index) noexcept { Player *player; GET_PLAYER(pid, player, ""); @@ -40,7 +40,7 @@ const char *CellFunctions::GetCellStateDescription(unsigned short pid, unsigned return tempCellDescription.c_str(); } -const char *CellFunctions::GetCell(unsigned short pid) noexcept +extern "C" const char *CellFunctions::GetCell(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -49,21 +49,21 @@ const char *CellFunctions::GetCell(unsigned short pid) noexcept return tempCellDescription.c_str(); } -int CellFunctions::GetExteriorX(unsigned short pid) noexcept +extern "C" int CellFunctions::GetExteriorX(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0); return player->cell.mData.mX; } -int CellFunctions::GetExteriorY(unsigned short pid) noexcept +extern "C" int CellFunctions::GetExteriorY(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0); return player->cell.mData.mY; } -bool CellFunctions::IsInExterior(unsigned short pid) noexcept +extern "C" bool CellFunctions::IsInExterior(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, false); @@ -71,7 +71,7 @@ bool CellFunctions::IsInExterior(unsigned short pid) noexcept return player->cell.isExterior(); } -const char *CellFunctions::GetRegion(unsigned short pid) noexcept +extern "C" const char *CellFunctions::GetRegion(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -79,7 +79,7 @@ const char *CellFunctions::GetRegion(unsigned short pid) noexcept return player->cell.mRegion.c_str(); } -bool CellFunctions::IsChangingRegion(unsigned short pid) noexcept +extern "C" bool CellFunctions::IsChangingRegion(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, false); @@ -87,7 +87,7 @@ bool CellFunctions::IsChangingRegion(unsigned short pid) noexcept return player->isChangingRegion; } -void CellFunctions::SetCell(unsigned short pid, const char *cellDescription) noexcept +extern "C" void CellFunctions::SetCell(unsigned short pid, const char *cellDescription) noexcept { Player *player; GET_PLAYER(pid, player,); @@ -98,7 +98,7 @@ void CellFunctions::SetCell(unsigned short pid, const char *cellDescription) noe player->cell = Utils::getCellFromDescription(cellDescription); } -void CellFunctions::SetExteriorCell(unsigned short pid, int x, int y) noexcept +extern "C" void CellFunctions::SetExteriorCell(unsigned short pid, int x, int y) noexcept { Player *player; GET_PLAYER(pid, player,); @@ -115,7 +115,7 @@ void CellFunctions::SetExteriorCell(unsigned short pid, int x, int y) noexcept player->cell.mData.mY = y; } -void CellFunctions::SendCell(unsigned short pid) noexcept +extern "C" void CellFunctions::SendCell(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, ); diff --git a/apps/openmw-mp/Script/Functions/Cells.hpp b/apps/openmw-mp/Script/Functions/Cells.hpp index 5adf2a48e..0726c7cd3 100644 --- a/apps/openmw-mp/Script/Functions/Cells.hpp +++ b/apps/openmw-mp/Script/Functions/Cells.hpp @@ -23,17 +23,15 @@ {"SendCell", CellFunctions::SendCell} -class CellFunctions +namespace 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. */ - static unsigned int GetCellStateChangesSize(unsigned short pid) noexcept; + extern "C" 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 +40,7 @@ public: * \param index The index of the cell state. * \return The cell state type (0 for LOAD, 1 for UNLOAD). */ - static unsigned int GetCellStateType(unsigned short pid, unsigned int index) noexcept; + extern "C" 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 +49,7 @@ public: * \param index The index of the cell state. * \return The cell description. */ - static const char *GetCellStateDescription(unsigned short pid, unsigned int index) noexcept; + extern "C" const char *GetCellStateDescription(unsigned short pid, unsigned int index) noexcept; /** * \brief Get the cell description of a player's cell. @@ -59,7 +57,7 @@ public: * \param pid The player ID. * \return The cell description. */ - static const char *GetCell(unsigned short pid) noexcept; + extern "C" const char *GetCell(unsigned short pid) noexcept; /** * \brief Get the X coordinate of the player's exterior cell. @@ -67,7 +65,7 @@ public: * \param pid The player ID. * \return The X coordinate of the cell. */ - static int GetExteriorX(unsigned short pid) noexcept; + extern "C" int GetExteriorX(unsigned short pid) noexcept; /** * \brief Get the Y coordinate of the player's exterior cell. @@ -75,7 +73,7 @@ public: * \param pid The player ID. * \return The Y coordinate of the cell. */ - static int GetExteriorY(unsigned short pid) noexcept; + extern "C" int GetExteriorY(unsigned short pid) noexcept; /** * \brief Check whether the player is in an exterior cell or not. @@ -83,7 +81,7 @@ public: * \param pid The player ID. * \return Whether the player is in an exterior cell. */ - static bool IsInExterior(unsigned short pid) noexcept; + extern "C" bool IsInExterior(unsigned short pid) noexcept; /** * \brief Get the region of the player's exterior cell. @@ -93,7 +91,7 @@ public: * \param pid The player ID. * \return The region. */ - static const char *GetRegion(unsigned short pid) noexcept; + extern "C" const char *GetRegion(unsigned short pid) noexcept; /** * \brief Check whether the player's last cell change has involved a region change. @@ -101,7 +99,7 @@ public: * \param pid The player ID. * \return Whether the player has changed their region. */ - static bool IsChangingRegion(unsigned short pid) noexcept; + extern "C" bool IsChangingRegion(unsigned short pid) noexcept; /** * \brief Set the cell of a player. @@ -116,7 +114,7 @@ public: * \param cellDescription The cell description. * \return void */ - static void SetCell(unsigned short pid, const char *cellDescription) noexcept; + extern "C" void SetCell(unsigned short pid, const char *cellDescription) noexcept; /** * \brief Set the cell of a player to an exterior cell. @@ -129,7 +127,7 @@ public: * \param y The Y coordinate of the cell. * \return void */ - static void SetExteriorCell(unsigned short pid, int x, int y) noexcept; + extern "C" void SetExteriorCell(unsigned short pid, int x, int y) noexcept; /** * \brief Send a PlayerCellChange packet about a player. @@ -139,8 +137,7 @@ public: * \param pid The player ID. * \return void */ - static void SendCell(unsigned short pid) noexcept; - -}; + extern "C" void SendCell(unsigned short pid) noexcept; +} #endif //OPENMW_CELLAPI_HPP diff --git a/apps/openmw-mp/Script/Functions/CharClass.cpp b/apps/openmw-mp/Script/Functions/CharClass.cpp index f981d1c8b..f5243b94b 100644 --- a/apps/openmw-mp/Script/Functions/CharClass.cpp +++ b/apps/openmw-mp/Script/Functions/CharClass.cpp @@ -12,7 +12,7 @@ using namespace std; using namespace ESM; -const char *CharClassFunctions::GetDefaultClass(unsigned short pid) noexcept +extern "C" const char *CharClassFunctions::GetDefaultClass(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, ""); @@ -20,7 +20,7 @@ const char *CharClassFunctions::GetDefaultClass(unsigned short pid) noexcept return player->charClass.mId.c_str(); } -const char *CharClassFunctions::GetClassName(unsigned short pid) noexcept +extern "C" const char *CharClassFunctions::GetClassName(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, ""); @@ -28,7 +28,7 @@ const char *CharClassFunctions::GetClassName(unsigned short pid) noexcept return player->charClass.mName.c_str(); } -const char *CharClassFunctions::GetClassDesc(unsigned short pid) noexcept +extern "C" const char *CharClassFunctions::GetClassDesc(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, ""); @@ -36,7 +36,7 @@ const char *CharClassFunctions::GetClassDesc(unsigned short pid) noexcept return player->charClass.mDescription.c_str(); } -int CharClassFunctions::GetClassMajorAttribute(unsigned short pid, unsigned char slot) noexcept +extern "C" int CharClassFunctions::GetClassMajorAttribute(unsigned short pid, unsigned char slot) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -47,7 +47,7 @@ int CharClassFunctions::GetClassMajorAttribute(unsigned short pid, unsigned char return player->charClass.mData.mAttribute[slot]; } -int CharClassFunctions::GetClassSpecialization(unsigned short pid) noexcept +extern "C" int CharClassFunctions::GetClassSpecialization(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -55,7 +55,7 @@ int CharClassFunctions::GetClassSpecialization(unsigned short pid) noexcept return player->charClass.mData.mSpecialization; } -int CharClassFunctions::GetClassMajorSkill(unsigned short pid, unsigned char slot) noexcept +extern "C" int CharClassFunctions::GetClassMajorSkill(unsigned short pid, unsigned char slot) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -66,7 +66,7 @@ int CharClassFunctions::GetClassMajorSkill(unsigned short pid, unsigned char slo return player->charClass.mData.mSkills[slot][1]; } -int CharClassFunctions::GetClassMinorSkill(unsigned short pid, unsigned char slot) noexcept +extern "C" int CharClassFunctions::GetClassMinorSkill(unsigned short pid, unsigned char slot) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -77,7 +77,7 @@ int CharClassFunctions::GetClassMinorSkill(unsigned short pid, unsigned char slo return player->charClass.mData.mSkills[slot][0]; } -int CharClassFunctions::IsClassDefault(unsigned short pid) noexcept +extern "C" int CharClassFunctions::IsClassDefault(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -85,14 +85,15 @@ int CharClassFunctions::IsClassDefault(unsigned short pid) noexcept return !player->charClass.mId.empty(); // true if default } -void CharClassFunctions::SetDefaultClass(unsigned short pid, const char *id) noexcept +extern "C" void CharClassFunctions::SetDefaultClass(unsigned short pid, const char *id) noexcept { Player *player; GET_PLAYER(pid, player,); player->charClass.mId = id; } -void CharClassFunctions::SetClassName(unsigned short pid, const char *name) noexcept + +extern "C" void CharClassFunctions::SetClassName(unsigned short pid, const char *name) noexcept { Player *player; GET_PLAYER(pid, player,); @@ -100,14 +101,16 @@ void CharClassFunctions::SetClassName(unsigned short pid, const char *name) noex player->charClass.mName = name; player->charClass.mId = ""; } -void CharClassFunctions::SetClassDesc(unsigned short pid, const char *desc) noexcept + +extern "C" void CharClassFunctions::SetClassDesc(unsigned short pid, const char *desc) noexcept { Player *player; GET_PLAYER(pid, player,); player->charClass.mDescription = desc; } -void CharClassFunctions::SetClassMajorAttribute(unsigned short pid, unsigned char slot, int attrId) noexcept + +extern "C" void CharClassFunctions::SetClassMajorAttribute(unsigned short pid, unsigned char slot, int attrId) noexcept { Player *player; GET_PLAYER(pid, player,); @@ -118,14 +121,16 @@ void CharClassFunctions::SetClassMajorAttribute(unsigned short pid, unsigned cha player->charClass.mData.mAttribute[slot] = attrId; } -void CharClassFunctions::SetClassSpecialization(unsigned short pid, int spec) noexcept + +extern "C" void CharClassFunctions::SetClassSpecialization(unsigned short pid, int spec) noexcept { Player *player; GET_PLAYER(pid, player,); player->charClass.mData.mSpecialization = spec; } -void CharClassFunctions::SetClassMajorSkill(unsigned short pid, unsigned char slot, int skillId) noexcept + +extern "C" void CharClassFunctions::SetClassMajorSkill(unsigned short pid, unsigned char slot, int skillId) noexcept { Player *player; GET_PLAYER(pid, player,); @@ -135,7 +140,8 @@ void CharClassFunctions::SetClassMajorSkill(unsigned short pid, unsigned char sl player->charClass.mData.mSkills[slot][1] = skillId; } -void CharClassFunctions::SetClassMinorSkill(unsigned short pid, unsigned char slot, int skillId) noexcept + +extern "C" void CharClassFunctions::SetClassMinorSkill(unsigned short pid, unsigned char slot, int skillId) noexcept { Player *player; GET_PLAYER(pid, player,); @@ -146,7 +152,7 @@ void CharClassFunctions::SetClassMinorSkill(unsigned short pid, unsigned char sl player->charClass.mData.mSkills[slot][0] = skillId; } -void CharClassFunctions::SendClass(unsigned short pid) noexcept +extern "C" void CharClassFunctions::SendClass(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, ); diff --git a/apps/openmw-mp/Script/Functions/CharClass.hpp b/apps/openmw-mp/Script/Functions/CharClass.hpp index b6cb9e9dd..d11203dd1 100644 --- a/apps/openmw-mp/Script/Functions/CharClass.hpp +++ b/apps/openmw-mp/Script/Functions/CharClass.hpp @@ -28,17 +28,15 @@ {"SendClass", CharClassFunctions::SendClass} -class CharClassFunctions +namespace CharClassFunctions { -public: - /** * \brief Get the default class used by a player. * * \param pid The player ID. * \return The ID of the default class. */ - static const char *GetDefaultClass(unsigned short pid) noexcept; + extern "C" const char *GetDefaultClass(unsigned short pid) noexcept; /** * \brief Get the name of the custom class used by a player. @@ -46,7 +44,7 @@ public: * \param pid The player ID. * \return The name of the custom class. */ - static const char *GetClassName(unsigned short pid) noexcept; + extern "C" const char *GetClassName(unsigned short pid) noexcept; /** * \brief Get the description of the custom class used by a player. @@ -54,7 +52,7 @@ public: * \param pid The player ID. * \return The description of the custom class. */ - static const char *GetClassDesc(unsigned short pid) noexcept; + extern "C" 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 +61,7 @@ public: * \param slot The slot of the major attribute (0 or 1). * \return The ID of the major attribute. */ - static int GetClassMajorAttribute(unsigned short pid, unsigned char slot) noexcept; + extern "C" int GetClassMajorAttribute(unsigned short pid, unsigned char slot) noexcept; /** * \brief Get the specialization ID of the custom class used by a player. @@ -71,7 +69,7 @@ public: * \param pid The player ID. * \return The specialization ID of the custom class (0 for Combat, 1 for Magic, 2 for Stealth). */ - static int GetClassSpecialization(unsigned short pid) noexcept; + extern "C" 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 +78,7 @@ public: * \param slot The slot of the major skill (0 to 4). * \return The ID of the major skill. */ - static int GetClassMajorSkill(unsigned short pid, unsigned char slot) noexcept; + extern "C" 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 +87,7 @@ public: * \param slot The slot of the minor skill (0 to 4). * \return The ID of the minor skill. */ - static int GetClassMinorSkill(unsigned short pid, unsigned char slot) noexcept; + extern "C" 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 +95,7 @@ public: * \param pid The player ID. * \return Whether the player is using a default class. */ - static int IsClassDefault(unsigned short pid) noexcept; + extern "C" int IsClassDefault(unsigned short pid) noexcept; /** * \brief Set the default class used by a player. @@ -108,7 +106,7 @@ public: * \param id The ID of the default class. * \return void */ - static void SetDefaultClass(unsigned short pid, const char *id) noexcept; + extern "C" void SetDefaultClass(unsigned short pid, const char *id) noexcept; /** * \brief Set the name of the custom class used by a player. @@ -117,7 +115,7 @@ public: * \param name The name of the custom class. * \return void */ - static void SetClassName(unsigned short pid, const char *name) noexcept; + extern "C" void SetClassName(unsigned short pid, const char *name) noexcept; /** * \brief Set the description of the custom class used by a player. @@ -126,7 +124,7 @@ public: * \param desc The description of the custom class. * \return void */ - static void SetClassDesc(unsigned short pid, const char *desc) noexcept; + extern "C" 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 +134,7 @@ public: * \param attrId The ID to use for the attribute. * \return void */ - static void SetClassMajorAttribute(unsigned short pid, unsigned char slot, int attrId) noexcept; + extern "C" 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 +143,7 @@ public: * \param spec The specialization ID to use (0 for Combat, 1 for Magic, 2 for Stealth). * \return void */ - static void SetClassSpecialization(unsigned short pid, int spec) noexcept; + extern "C" 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 +153,7 @@ public: * \param skillId The ID to use for the skill. * \return void */ - static void SetClassMajorSkill(unsigned short pid, unsigned char slot, int skillId) noexcept; + extern "C" 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 +163,7 @@ public: * \param skillId The ID to use for the skill. * \return void */ - static void SetClassMinorSkill(unsigned short pid, unsigned char slot, int skillId) noexcept; + extern "C" void SetClassMinorSkill(unsigned short pid, unsigned char slot, int skillId) noexcept; /** * \brief Send a PlayerCharClass packet about a player. @@ -175,7 +173,7 @@ public: * \param pid The player ID. * \return void */ - static void SendClass(unsigned short pid) noexcept; -}; + extern "C" void SendClass(unsigned short pid) noexcept; +} #endif //OPENMW_CHARCLASSAPI_HPP diff --git a/apps/openmw-mp/Script/Functions/Chat.cpp b/apps/openmw-mp/Script/Functions/Chat.cpp index 477cc1b17..d0809ba50 100644 --- a/apps/openmw-mp/Script/Functions/Chat.cpp +++ b/apps/openmw-mp/Script/Functions/Chat.cpp @@ -6,7 +6,7 @@ #include #include -void ChatFunctions::SendMessage(unsigned short pid, const char *message, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept +extern "C" void ChatFunctions::SendMessage(unsigned short pid, const char *message, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept { Player *player; GET_PLAYER(pid, player,); @@ -24,7 +24,7 @@ void ChatFunctions::SendMessage(unsigned short pid, const char *message, bool se packet->Send(true); } -void ChatFunctions::CleanChatForPid(unsigned short pid) +extern "C" void ChatFunctions::CleanChatForPid(unsigned short pid) { Player *player; GET_PLAYER(pid, player,); @@ -37,7 +37,7 @@ void ChatFunctions::CleanChatForPid(unsigned short pid) packet->Send(false); } -void ChatFunctions::CleanChat() +extern "C" void ChatFunctions::CleanChat() { for (auto player : *Players::getPlayers()) { diff --git a/apps/openmw-mp/Script/Functions/Chat.hpp b/apps/openmw-mp/Script/Functions/Chat.hpp index cdf1e1f05..d4c059879 100644 --- a/apps/openmw-mp/Script/Functions/Chat.hpp +++ b/apps/openmw-mp/Script/Functions/Chat.hpp @@ -8,10 +8,8 @@ {"CleanChatForPid", ChatFunctions::CleanChat},\ {"CleanChat", ChatFunctions::CleanChatForPid} -class ChatFunctions +namespace ChatFunctions { -public: - /** * \brief Send a message to a certain player. * @@ -23,7 +21,7 @@ public: * to the packet (false by default). * \return void */ - static void SendMessage(unsigned short pid, const char *message, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept; + extern "C" 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 +29,14 @@ public: * \param pid The player ID. * \return void */ - static void CleanChatForPid(unsigned short pid); + extern "C" void CleanChatForPid(unsigned short pid); /** * \brief Remove all messages from chat for everyone on the server. * * \return void */ - static void CleanChat(); -}; + extern "C" void CleanChat(); +} #endif //OPENMW_CHATAPI_HPP diff --git a/apps/openmw-mp/Script/Functions/Dialogue.cpp b/apps/openmw-mp/Script/Functions/Dialogue.cpp index 0659bcfa2..18ec5418f 100644 --- a/apps/openmw-mp/Script/Functions/Dialogue.cpp +++ b/apps/openmw-mp/Script/Functions/Dialogue.cpp @@ -7,7 +7,7 @@ using namespace mwmp; -void DialogueFunctions::ClearTopicChanges(unsigned short pid) noexcept +extern "C" void DialogueFunctions::ClearTopicChanges(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, ); @@ -15,7 +15,7 @@ void DialogueFunctions::ClearTopicChanges(unsigned short pid) noexcept player->topicChanges.topics.clear(); } -unsigned int DialogueFunctions::GetTopicChangesSize(unsigned short pid) noexcept +extern "C" unsigned int DialogueFunctions::GetTopicChangesSize(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -23,7 +23,7 @@ unsigned int DialogueFunctions::GetTopicChangesSize(unsigned short pid) noexcept return player->topicChanges.count; } -void DialogueFunctions::AddTopic(unsigned short pid, const char* topicId) noexcept +extern "C" void DialogueFunctions::AddTopic(unsigned short pid, const char* topicId) noexcept { Player *player; GET_PLAYER(pid, player, ); @@ -34,7 +34,7 @@ void DialogueFunctions::AddTopic(unsigned short pid, const char* topicId) noexce player->topicChanges.topics.push_back(topic); } -const char *DialogueFunctions::GetTopicId(unsigned short pid, unsigned int index) noexcept +extern "C" const char *DialogueFunctions::GetTopicId(unsigned short pid, unsigned int index) noexcept { Player *player; GET_PLAYER(pid, player, ""); @@ -45,7 +45,7 @@ const char *DialogueFunctions::GetTopicId(unsigned short pid, unsigned int index return player->topicChanges.topics.at(index).topicId.c_str(); } -void DialogueFunctions::SendTopicChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept +extern "C" void DialogueFunctions::SendTopicChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept { Player *player; GET_PLAYER(pid, player, ); @@ -59,7 +59,7 @@ void DialogueFunctions::SendTopicChanges(unsigned short pid, bool sendToOtherPla packet->Send(true); } -void DialogueFunctions::PlayAnimation(unsigned short pid, const char* groupname, int mode, int count, bool persist) noexcept +extern "C" void DialogueFunctions::PlayAnimation(unsigned short pid, const char* groupname, int mode, int count, bool persist) noexcept { Player *player; GET_PLAYER(pid, player, ); @@ -76,7 +76,7 @@ void DialogueFunctions::PlayAnimation(unsigned short pid, const char* groupname, player->sendToLoaded(packet); } -void DialogueFunctions::PlaySpeech(unsigned short pid, const char* sound) noexcept +extern "C" void DialogueFunctions::PlaySpeech(unsigned short pid, const char* sound) noexcept { Player *player; GET_PLAYER(pid, player, ); @@ -90,7 +90,7 @@ void DialogueFunctions::PlaySpeech(unsigned short pid, const char* sound) noexce player->sendToLoaded(packet); } -// All methods below are deprecated versions of methods from above +extern "C" // All methods below are deprecated versions of methods from above void DialogueFunctions::InitializeTopicChanges(unsigned short pid) noexcept { diff --git a/apps/openmw-mp/Script/Functions/Dialogue.hpp b/apps/openmw-mp/Script/Functions/Dialogue.hpp index a79ad1040..ace52e7ca 100644 --- a/apps/openmw-mp/Script/Functions/Dialogue.hpp +++ b/apps/openmw-mp/Script/Functions/Dialogue.hpp @@ -17,10 +17,8 @@ \ {"InitializeTopicChanges", DialogueFunctions::InitializeTopicChanges} -class DialogueFunctions +namespace DialogueFunctions { -public: - /** * \brief Clear the last recorded topic changes for a player. * @@ -29,7 +27,7 @@ public: * \param pid The player ID whose topic changes should be used. * \return void */ - static void ClearTopicChanges(unsigned short pid) noexcept; + extern "C" void ClearTopicChanges(unsigned short pid) noexcept; /** * \brief Get the number of indexes in a player's latest topic changes. @@ -37,7 +35,7 @@ public: * \param pid The player ID whose topic changes should be used. * \return The number of indexes. */ - static unsigned int GetTopicChangesSize(unsigned short pid) noexcept; + extern "C" unsigned int GetTopicChangesSize(unsigned short pid) noexcept; /** * \brief Add a new topic to the topic changes for a player. @@ -46,7 +44,7 @@ public: * \param topicId The topicId of the topic. * \return void */ - static void AddTopic(unsigned short pid, const char* topicId) noexcept; + extern "C" 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 +53,7 @@ public: * \param index The index of the topic. * \return The topicId. */ - static const char *GetTopicId(unsigned short pid, unsigned int index) noexcept; + extern "C" const char *GetTopicId(unsigned short pid, unsigned int index) noexcept; /** * \brief Send a PlayerTopic packet with a player's recorded topic changes. @@ -67,7 +65,7 @@ public: * to the packet (false by default). * \return void */ - static void SendTopicChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept; + extern "C" 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 +78,7 @@ public: * \param bool Whether the animation should persist or not. * \return void */ - static void PlayAnimation(unsigned short pid, const char* groupname, int mode, int count, bool persist) noexcept; + extern "C" 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,12 +88,11 @@ public: * \param sound The path of the sound file. * \return void */ - static void PlaySpeech(unsigned short pid, const char* sound) noexcept; + extern "C" void PlaySpeech(unsigned short pid, const char* sound) noexcept; // All methods below are deprecated versions of methods from above - static void InitializeTopicChanges(unsigned short pid) noexcept; - -}; + extern "C" void InitializeTopicChanges(unsigned short pid) noexcept; +} #endif //OPENMW_DIALOGUEAPI_HPP diff --git a/apps/openmw-mp/Script/Functions/Factions.cpp b/apps/openmw-mp/Script/Functions/Factions.cpp index 668b1a786..14b95e275 100644 --- a/apps/openmw-mp/Script/Functions/Factions.cpp +++ b/apps/openmw-mp/Script/Functions/Factions.cpp @@ -11,7 +11,7 @@ using namespace mwmp; Faction tempFaction; const Faction emptyFaction = {}; -void FactionFunctions::ClearFactionChanges(unsigned short pid) noexcept +extern "C" void FactionFunctions::ClearFactionChanges(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, ); @@ -19,7 +19,7 @@ void FactionFunctions::ClearFactionChanges(unsigned short pid) noexcept player->factionChanges.factions.clear(); } -unsigned int FactionFunctions::GetFactionChangesSize(unsigned short pid) noexcept +extern "C" unsigned int FactionFunctions::GetFactionChangesSize(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -27,7 +27,7 @@ unsigned int FactionFunctions::GetFactionChangesSize(unsigned short pid) noexcep return player->factionChanges.count; } -unsigned char FactionFunctions::GetFactionChangesAction(unsigned short pid) noexcept +extern "C" unsigned char FactionFunctions::GetFactionChangesAction(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -35,7 +35,7 @@ unsigned char FactionFunctions::GetFactionChangesAction(unsigned short pid) noex return player->factionChanges.action; } -const char *FactionFunctions::GetFactionId(unsigned short pid, unsigned int index) noexcept +extern "C" const char *FactionFunctions::GetFactionId(unsigned short pid, unsigned int index) noexcept { Player *player; GET_PLAYER(pid, player, ""); @@ -46,7 +46,7 @@ const char *FactionFunctions::GetFactionId(unsigned short pid, unsigned int inde return player->factionChanges.factions.at(index).factionId.c_str(); } -int FactionFunctions::GetFactionRank(unsigned short pid, unsigned int index) noexcept +extern "C" int FactionFunctions::GetFactionRank(unsigned short pid, unsigned int index) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -54,7 +54,7 @@ int FactionFunctions::GetFactionRank(unsigned short pid, unsigned int index) noe return player->factionChanges.factions.at(index).rank; } -bool FactionFunctions::GetFactionExpulsionState(unsigned short pid, unsigned int index) noexcept +extern "C" bool FactionFunctions::GetFactionExpulsionState(unsigned short pid, unsigned int index) noexcept { Player *player; GET_PLAYER(pid, player, false); @@ -62,7 +62,7 @@ bool FactionFunctions::GetFactionExpulsionState(unsigned short pid, unsigned int return player->factionChanges.factions.at(index).isExpelled; } -int FactionFunctions::GetFactionReputation(unsigned short pid, unsigned int index) noexcept +extern "C" int FactionFunctions::GetFactionReputation(unsigned short pid, unsigned int index) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -70,7 +70,7 @@ int FactionFunctions::GetFactionReputation(unsigned short pid, unsigned int inde return player->factionChanges.factions.at(index).reputation; } -void FactionFunctions::SetFactionChangesAction(unsigned short pid, unsigned char action) noexcept +extern "C" void FactionFunctions::SetFactionChangesAction(unsigned short pid, unsigned char action) noexcept { Player *player; GET_PLAYER(pid, player, ); @@ -78,27 +78,27 @@ void FactionFunctions::SetFactionChangesAction(unsigned short pid, unsigned char player->factionChanges.action = action; } -void FactionFunctions::SetFactionId(const char* factionId) noexcept +extern "C" void FactionFunctions::SetFactionId(const char* factionId) noexcept { tempFaction.factionId = factionId; } -void FactionFunctions::SetFactionRank(unsigned int rank) noexcept +extern "C" void FactionFunctions::SetFactionRank(unsigned int rank) noexcept { tempFaction.rank = rank; } -void FactionFunctions::SetFactionExpulsionState(bool expulsionState) noexcept +extern "C" void FactionFunctions::SetFactionExpulsionState(bool expulsionState) noexcept { tempFaction.isExpelled = expulsionState; } -void FactionFunctions::SetFactionReputation(int reputation) noexcept +extern "C" void FactionFunctions::SetFactionReputation(int reputation) noexcept { tempFaction.reputation = reputation; } -void FactionFunctions::AddFaction(unsigned short pid) noexcept +extern "C" void FactionFunctions::AddFaction(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, ); @@ -108,7 +108,7 @@ void FactionFunctions::AddFaction(unsigned short pid) noexcept tempFaction = emptyFaction; } -void FactionFunctions::SendFactionChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept +extern "C" void FactionFunctions::SendFactionChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept { Player *player; GET_PLAYER(pid, player, ); @@ -122,7 +122,7 @@ void FactionFunctions::SendFactionChanges(unsigned short pid, bool sendToOtherPl packet->Send(true); } -// All methods below are deprecated versions of methods from above +extern "C" // All methods below are deprecated versions of methods from above void FactionFunctions::InitializeFactionChanges(unsigned short pid) noexcept { diff --git a/apps/openmw-mp/Script/Functions/Factions.hpp b/apps/openmw-mp/Script/Functions/Factions.hpp index 6caf604d2..2b0815918 100644 --- a/apps/openmw-mp/Script/Functions/Factions.hpp +++ b/apps/openmw-mp/Script/Functions/Factions.hpp @@ -24,10 +24,8 @@ \ {"InitializeFactionChanges", FactionFunctions::InitializeFactionChanges} -class FactionFunctions +namespace FactionFunctions { -public: - /** * \brief Clear the last recorded faction changes for a player. * @@ -36,7 +34,7 @@ public: * \param pid The player ID whose faction changes should be used. * \return void */ - static void ClearFactionChanges(unsigned short pid) noexcept; + extern "C" void ClearFactionChanges(unsigned short pid) noexcept; /** * \brief Get the number of indexes in a player's latest faction changes. @@ -44,7 +42,7 @@ public: * \param pid The player ID whose faction changes should be used. * \return The number of indexes. */ - static unsigned int GetFactionChangesSize(unsigned short pid) noexcept; + extern "C" unsigned int GetFactionChangesSize(unsigned short pid) noexcept; /** * \brief Get the action type used in a player's latest faction changes. @@ -52,7 +50,7 @@ public: * \param pid The player ID whose faction changes should be used. * \return The action type (0 for RANK, 1 for EXPULSION, 2 for REPUTATION). */ - static unsigned char GetFactionChangesAction(unsigned short pid) noexcept; + extern "C" unsigned char GetFactionChangesAction(unsigned short pid) noexcept; /** * \brief Get the factionId at a certain index in a player's latest faction changes. @@ -61,7 +59,7 @@ public: * \param index The index of the faction. * \return The factionId. */ - static const char *GetFactionId(unsigned short pid, unsigned int index) noexcept; + extern "C" 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 +68,7 @@ public: * \param index The index of the faction. * \return The rank. */ - static int GetFactionRank(unsigned short pid, unsigned int index) noexcept; + extern "C" 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 +77,7 @@ public: * \param index The index of the faction. * \return The expulsion state. */ - static bool GetFactionExpulsionState(unsigned short pid, unsigned int index) noexcept; + extern "C" 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 +86,7 @@ public: * \param index The index of the faction. * \return The reputation. */ - static int GetFactionReputation(unsigned short pid, unsigned int index) noexcept; + extern "C" int GetFactionReputation(unsigned short pid, unsigned int index) noexcept; /** * \brief Set the action type in a player's faction changes. @@ -97,7 +95,7 @@ public: * \param action The action (0 for RANK, 1 for EXPULSION, 2 for REPUTATION). * \return void */ - static void SetFactionChangesAction(unsigned short pid, unsigned char action) noexcept; + extern "C" void SetFactionChangesAction(unsigned short pid, unsigned char action) noexcept; /** * \brief Set the factionId of the temporary faction stored on the server. @@ -105,7 +103,7 @@ public: * \param factionId The factionId. * \return void */ - static void SetFactionId(const char* factionId) noexcept; + extern "C" void SetFactionId(const char* factionId) noexcept; /** * \brief Set the rank of the temporary faction stored on the server. @@ -113,7 +111,7 @@ public: * \param rank The rank. * \return void */ - static void SetFactionRank(unsigned int rank) noexcept; + extern "C" void SetFactionRank(unsigned int rank) noexcept; /** * \brief Set the expulsion state of the temporary faction stored on the server. @@ -121,7 +119,7 @@ public: * \param expulsionState The expulsion state. * \return void */ - static void SetFactionExpulsionState(bool expulsionState) noexcept; + extern "C" void SetFactionExpulsionState(bool expulsionState) noexcept; /** * \brief Set the reputation of the temporary faction stored on the server. @@ -129,7 +127,7 @@ public: * \param reputation The reputation. * \return void */ - static void SetFactionReputation(int reputation) noexcept; + extern "C" void SetFactionReputation(int reputation) noexcept; /** * \brief Add the server's temporary faction to the faction changes for a player. @@ -140,7 +138,7 @@ public: * \param pid The player ID whose faction changes should be used. * \return void */ - static void AddFaction(unsigned short pid) noexcept; + extern "C" void AddFaction(unsigned short pid) noexcept; /** * \brief Send a PlayerFaction packet with a player's recorded faction changes. @@ -152,12 +150,11 @@ public: * to the packet (false by default). * \return void */ - static void SendFactionChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept; + extern "C" void SendFactionChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept; // All methods below are deprecated versions of methods from above - static void InitializeFactionChanges(unsigned short pid) noexcept; - -}; + extern "C" void InitializeFactionChanges(unsigned short pid) noexcept; +} #endif //OPENMW_FACTIONAPI_HPP diff --git a/apps/openmw-mp/Script/Functions/GUI.cpp b/apps/openmw-mp/Script/Functions/GUI.cpp index 9ce4c10bf..b2b7bf0e5 100644 --- a/apps/openmw-mp/Script/Functions/GUI.cpp +++ b/apps/openmw-mp/Script/Functions/GUI.cpp @@ -5,7 +5,7 @@ #include #include -void GUIFunctions::_MessageBox(unsigned short pid, int id, const char *label) noexcept +extern "C" void GUIFunctions::_MessageBox(unsigned short pid, int id, const char *label) noexcept { Player *player; GET_PLAYER(pid, player,); @@ -20,7 +20,7 @@ void GUIFunctions::_MessageBox(unsigned short pid, int id, const char *label) no packet->Send(false); } -void GUIFunctions::CustomMessageBox(unsigned short pid, int id, const char *label, const char *buttons) noexcept +extern "C" void GUIFunctions::CustomMessageBox(unsigned short pid, int id, const char *label, const char *buttons) noexcept { Player *player; GET_PLAYER(pid, player,); @@ -36,7 +36,7 @@ void GUIFunctions::CustomMessageBox(unsigned short pid, int id, const char *labe packet->Send(false); } -void GUIFunctions::InputDialog(unsigned short pid, int id, const char *label, const char *note) noexcept +extern "C" void GUIFunctions::InputDialog(unsigned short pid, int id, const char *label, const char *note) noexcept { Player *player; GET_PLAYER(pid, player,); @@ -52,7 +52,7 @@ void GUIFunctions::InputDialog(unsigned short pid, int id, const char *label, co packet->Send(false); } -void GUIFunctions::PasswordDialog(unsigned short pid, int id, const char *label, const char *note) noexcept +extern "C" void GUIFunctions::PasswordDialog(unsigned short pid, int id, const char *label, const char *note) noexcept { Player *player; GET_PLAYER(pid, player,); @@ -68,7 +68,7 @@ void GUIFunctions::PasswordDialog(unsigned short pid, int id, const char *label, packet->Send(false); } -void GUIFunctions::ListBox(unsigned short pid, int id, const char *label, const char *items) +extern "C" void GUIFunctions::ListBox(unsigned short pid, int id, const char *label, const char *items) { Player *player; GET_PLAYER(pid, player,); @@ -84,7 +84,7 @@ void GUIFunctions::ListBox(unsigned short pid, int id, const char *label, const packet->Send(false); } -void GUIFunctions::ClearQuickKeyChanges(unsigned short pid) noexcept +extern "C" void GUIFunctions::ClearQuickKeyChanges(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, ); @@ -92,7 +92,7 @@ void GUIFunctions::ClearQuickKeyChanges(unsigned short pid) noexcept player->quickKeyChanges.quickKeys.clear(); } -unsigned int GUIFunctions::GetQuickKeyChangesSize(unsigned short pid) noexcept +extern "C" unsigned int GUIFunctions::GetQuickKeyChangesSize(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -100,7 +100,7 @@ unsigned int GUIFunctions::GetQuickKeyChangesSize(unsigned short pid) noexcept return player->quickKeyChanges.count; } -int GUIFunctions::GetQuickKeySlot(unsigned short pid, unsigned int index) noexcept +extern "C" int GUIFunctions::GetQuickKeySlot(unsigned short pid, unsigned int index) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -111,7 +111,7 @@ int GUIFunctions::GetQuickKeySlot(unsigned short pid, unsigned int index) noexce return player->quickKeyChanges.quickKeys.at(index).slot; } -int GUIFunctions::GetQuickKeyType(unsigned short pid, unsigned int index) noexcept +extern "C" int GUIFunctions::GetQuickKeyType(unsigned short pid, unsigned int index) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -122,7 +122,7 @@ int GUIFunctions::GetQuickKeyType(unsigned short pid, unsigned int index) noexce return player->quickKeyChanges.quickKeys.at(index).type; } -const char *GUIFunctions::GetQuickKeyItemId(unsigned short pid, unsigned int index) noexcept +extern "C" const char *GUIFunctions::GetQuickKeyItemId(unsigned short pid, unsigned int index) noexcept { Player *player; GET_PLAYER(pid, player, ""); @@ -133,7 +133,7 @@ const char *GUIFunctions::GetQuickKeyItemId(unsigned short pid, unsigned int ind return player->quickKeyChanges.quickKeys.at(index).itemId.c_str(); } -void GUIFunctions::AddQuickKey(unsigned short pid, unsigned short slot, int type, const char* itemId) noexcept +extern "C" void GUIFunctions::AddQuickKey(unsigned short pid, unsigned short slot, int type, const char* itemId) noexcept { Player *player; GET_PLAYER(pid, player, ); @@ -146,7 +146,7 @@ void GUIFunctions::AddQuickKey(unsigned short pid, unsigned short slot, int type player->quickKeyChanges.quickKeys.push_back(quickKey); } -void GUIFunctions::SendQuickKeyChanges(unsigned short pid) noexcept +extern "C" void GUIFunctions::SendQuickKeyChanges(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, ); @@ -155,17 +155,17 @@ void GUIFunctions::SendQuickKeyChanges(unsigned short pid) noexcept mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_QUICKKEYS)->Send(false); } -void GUIFunctions::SetMapVisibility(unsigned short targetPid, unsigned short affectedPid, unsigned short state) noexcept +extern "C" void GUIFunctions::SetMapVisibility(unsigned short targetPid, unsigned short affectedPid, unsigned short state) noexcept { LOG_MESSAGE(Log::LOG_WARN, "stub"); } -void GUIFunctions::SetMapVisibilityAll(unsigned short targetPid, unsigned short state) noexcept +extern "C" void GUIFunctions::SetMapVisibilityAll(unsigned short targetPid, unsigned short state) noexcept { LOG_MESSAGE(Log::LOG_WARN, "stub"); } -// All methods below are deprecated versions of methods from above +extern "C" // All methods below are deprecated versions of methods from above void GUIFunctions::InitializeQuickKeyChanges(unsigned short pid) noexcept { diff --git a/apps/openmw-mp/Script/Functions/GUI.hpp b/apps/openmw-mp/Script/Functions/GUI.hpp index d2df31727..eec1da96f 100644 --- a/apps/openmw-mp/Script/Functions/GUI.hpp +++ b/apps/openmw-mp/Script/Functions/GUI.hpp @@ -25,10 +25,8 @@ \ {"InitializeQuickKeyChanges", GUIFunctions::InitializeQuickKeyChanges} -class GUIFunctions +namespace GUIFunctions { -public: - /** * \brief Display a simple messagebox at the bottom of the screen that vanishes * after a few seconds. @@ -41,7 +39,7 @@ public: * \param label The text in the messagebox. * \return void */ - static void _MessageBox(unsigned short pid, int id, const char *label) noexcept; + extern "C" 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 +51,7 @@ public: * \parm buttons The captions of the buttons, separated by semicolons (e.g. "Yes;No;Maybe"). * \return void */ - static void CustomMessageBox(unsigned short pid, int id, const char *label, const char *buttons) noexcept; + extern "C" 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 +62,7 @@ public: * \parm note The text at the bottom of the input dialog. * \return void */ - static void InputDialog(unsigned short pid, int id, const char *label, const char *note) noexcept; + extern "C" 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 +76,7 @@ public: * \parm note The text at the bottom of the password dialog. * \return void */ - static void PasswordDialog(unsigned short pid, int id, const char *label, const char *note) noexcept; + extern "C" 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 +89,7 @@ public: * \parm items The items in the listbox, separated by newlines (e.g. "Item 1\nItem 2"). * \return void */ - static void ListBox(unsigned short pid, int id, const char *label, const char *items); + extern "C" 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 +99,7 @@ public: * \param pid The player ID whose quick key changes should be used. * \return void */ - static void ClearQuickKeyChanges(unsigned short pid) noexcept; + extern "C" void ClearQuickKeyChanges(unsigned short pid) noexcept; /** * \brief Get the number of indexes in a player's latest quick key changes. @@ -109,7 +107,7 @@ public: * \param pid The player ID whose quick key changes should be used. * \return The number of indexes. */ - static unsigned int GetQuickKeyChangesSize(unsigned short pid) noexcept; + extern "C" unsigned int GetQuickKeyChangesSize(unsigned short pid) noexcept; /** * \brief Add a new quick key to the quick key changes for a player. @@ -120,7 +118,7 @@ public: * \param itemId The itemId of the item. * \return void */ - static void AddQuickKey(unsigned short pid, unsigned short slot, int type, const char* itemId = "") noexcept; + extern "C" 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 +127,7 @@ public: * \param index The index of the quick key in the quick key changes vector. * \return The slot. */ - static int GetQuickKeySlot(unsigned short pid, unsigned int index) noexcept; + extern "C" 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 +136,7 @@ public: * \param index The index of the quick key in the quick key changes vector. * \return The quick key type. */ - static int GetQuickKeyType(unsigned short pid, unsigned int index) noexcept; + extern "C" 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 +145,7 @@ public: * \param index The index of the quick key in the quick key changes vector. * \return The itemId. */ - static const char *GetQuickKeyItemId(unsigned short pid, unsigned int index) noexcept; + extern "C" 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 +153,7 @@ public: * \param pid The player ID whose quick key changes should be used. * \return void */ - static void SendQuickKeyChanges(unsigned short pid) noexcept; + extern "C" void SendQuickKeyChanges(unsigned short pid) noexcept; //state 0 - disallow, 1 - allow @@ -169,7 +167,7 @@ public: * \param state The state of the map marker (false to hide, true to reveal). * \return void */ - static void SetMapVisibility(unsigned short targetPid, unsigned short affectedPid, unsigned short state) noexcept; + extern "C" 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,12 +178,11 @@ public: * \param state The state of the map marker (false to hide, true to reveal). * \return void */ - static void SetMapVisibilityAll(unsigned short targetPid, unsigned short state) noexcept; + extern "C" void SetMapVisibilityAll(unsigned short targetPid, unsigned short state) noexcept; // All methods below are deprecated versions of methods from above - static void InitializeQuickKeyChanges(unsigned short pid) noexcept; - -}; + extern "C" void InitializeQuickKeyChanges(unsigned short pid) noexcept; +} #endif //OPENMW_GUIAPI_HPP diff --git a/apps/openmw-mp/Script/Functions/Items.cpp b/apps/openmw-mp/Script/Functions/Items.cpp index ba9bf7d88..0c38bfd1c 100644 --- a/apps/openmw-mp/Script/Functions/Items.cpp +++ b/apps/openmw-mp/Script/Functions/Items.cpp @@ -9,7 +9,7 @@ using namespace mwmp; -void ItemFunctions::ClearInventoryChanges(unsigned short pid) noexcept +extern "C" void ItemFunctions::ClearInventoryChanges(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, ); @@ -17,12 +17,12 @@ void ItemFunctions::ClearInventoryChanges(unsigned short pid) noexcept player->inventoryChanges.items.clear(); } -int ItemFunctions::GetEquipmentSize() noexcept +extern "C" int ItemFunctions::GetEquipmentSize() noexcept { return MWWorld::InventoryStore::Slots; } -unsigned int ItemFunctions::GetInventoryChangesSize(unsigned short pid) noexcept +extern "C" unsigned int ItemFunctions::GetInventoryChangesSize(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -30,7 +30,7 @@ unsigned int ItemFunctions::GetInventoryChangesSize(unsigned short pid) noexcept return player->inventoryChanges.count; } -unsigned int ItemFunctions::GetInventoryChangesAction(unsigned short pid) noexcept +extern "C" unsigned int ItemFunctions::GetInventoryChangesAction(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -38,7 +38,7 @@ unsigned int ItemFunctions::GetInventoryChangesAction(unsigned short pid) noexce return player->inventoryChanges.action; } -void ItemFunctions::SetInventoryChangesAction(unsigned short pid, unsigned char action) noexcept +extern "C" void ItemFunctions::SetInventoryChangesAction(unsigned short pid, unsigned char action) noexcept { Player *player; GET_PLAYER(pid, player, ); @@ -46,7 +46,7 @@ void ItemFunctions::SetInventoryChangesAction(unsigned short pid, unsigned char player->inventoryChanges.action = action; } -void ItemFunctions::EquipItem(unsigned short pid, unsigned short slot, const char *refId, unsigned int count, +extern "C" void ItemFunctions::EquipItem(unsigned short pid, unsigned short slot, const char *refId, unsigned int count, int charge, double enchantmentCharge) noexcept { Player *player; @@ -61,7 +61,7 @@ void ItemFunctions::EquipItem(unsigned short pid, unsigned short slot, const cha player->equipmentIndexChanges.push_back(slot); } -void ItemFunctions::UnequipItem(unsigned short pid, unsigned short slot) noexcept +extern "C" void ItemFunctions::UnequipItem(unsigned short pid, unsigned short slot) noexcept { Player *player; GET_PLAYER(pid, player, ); @@ -69,7 +69,7 @@ void ItemFunctions::UnequipItem(unsigned short pid, unsigned short slot) noexcep ItemFunctions::EquipItem(pid, slot, "", 0, -1, -1); } -void ItemFunctions::AddItemChange(unsigned short pid, const char* refId, unsigned int count, int charge, +extern "C" void ItemFunctions::AddItemChange(unsigned short pid, const char* refId, unsigned int count, int charge, double enchantmentCharge, const char* soul) noexcept { Player *player; @@ -85,7 +85,7 @@ void ItemFunctions::AddItemChange(unsigned short pid, const char* refId, unsigne player->inventoryChanges.items.push_back(item); } -bool ItemFunctions::HasItemEquipped(unsigned short pid, const char* refId) +extern "C" bool ItemFunctions::HasItemEquipped(unsigned short pid, const char* refId) { Player *player; GET_PLAYER(pid, player, false); @@ -96,7 +96,7 @@ bool ItemFunctions::HasItemEquipped(unsigned short pid, const char* refId) return false; } -const char *ItemFunctions::GetEquipmentItemRefId(unsigned short pid, unsigned short slot) noexcept +extern "C" const char *ItemFunctions::GetEquipmentItemRefId(unsigned short pid, unsigned short slot) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -104,7 +104,7 @@ const char *ItemFunctions::GetEquipmentItemRefId(unsigned short pid, unsigned sh return player->equipmentItems[slot].refId.c_str(); } -int ItemFunctions::GetEquipmentItemCount(unsigned short pid, unsigned short slot) noexcept +extern "C" int ItemFunctions::GetEquipmentItemCount(unsigned short pid, unsigned short slot) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -112,7 +112,7 @@ int ItemFunctions::GetEquipmentItemCount(unsigned short pid, unsigned short slot return player->equipmentItems[slot].count; } -int ItemFunctions::GetEquipmentItemCharge(unsigned short pid, unsigned short slot) noexcept +extern "C" int ItemFunctions::GetEquipmentItemCharge(unsigned short pid, unsigned short slot) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -120,7 +120,7 @@ int ItemFunctions::GetEquipmentItemCharge(unsigned short pid, unsigned short slo return player->equipmentItems[slot].charge; } -double ItemFunctions::GetEquipmentItemEnchantmentCharge(unsigned short pid, unsigned short slot) noexcept +extern "C" double ItemFunctions::GetEquipmentItemEnchantmentCharge(unsigned short pid, unsigned short slot) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -128,7 +128,7 @@ double ItemFunctions::GetEquipmentItemEnchantmentCharge(unsigned short pid, unsi return player->equipmentItems[slot].enchantmentCharge; } -const char *ItemFunctions::GetInventoryItemRefId(unsigned short pid, unsigned int index) noexcept +extern "C" const char *ItemFunctions::GetInventoryItemRefId(unsigned short pid, unsigned int index) noexcept { Player *player; GET_PLAYER(pid, player, ""); @@ -139,7 +139,7 @@ const char *ItemFunctions::GetInventoryItemRefId(unsigned short pid, unsigned in return player->inventoryChanges.items.at(index).refId.c_str(); } -int ItemFunctions::GetInventoryItemCount(unsigned short pid, unsigned int index) noexcept +extern "C" int ItemFunctions::GetInventoryItemCount(unsigned short pid, unsigned int index) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -147,7 +147,7 @@ int ItemFunctions::GetInventoryItemCount(unsigned short pid, unsigned int index) return player->inventoryChanges.items.at(index).count; } -int ItemFunctions::GetInventoryItemCharge(unsigned short pid, unsigned int index) noexcept +extern "C" int ItemFunctions::GetInventoryItemCharge(unsigned short pid, unsigned int index) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -155,7 +155,7 @@ int ItemFunctions::GetInventoryItemCharge(unsigned short pid, unsigned int index return player->inventoryChanges.items.at(index).charge; } -double ItemFunctions::GetInventoryItemEnchantmentCharge(unsigned short pid, unsigned int index) noexcept +extern "C" double ItemFunctions::GetInventoryItemEnchantmentCharge(unsigned short pid, unsigned int index) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -163,7 +163,7 @@ double ItemFunctions::GetInventoryItemEnchantmentCharge(unsigned short pid, unsi return player->inventoryChanges.items.at(index).enchantmentCharge; } -const char *ItemFunctions::GetInventoryItemSoul(unsigned short pid, unsigned int index) noexcept +extern "C" const char *ItemFunctions::GetInventoryItemSoul(unsigned short pid, unsigned int index) noexcept { Player *player; GET_PLAYER(pid, player, ""); @@ -174,7 +174,7 @@ const char *ItemFunctions::GetInventoryItemSoul(unsigned short pid, unsigned int return player->inventoryChanges.items.at(index).soul.c_str(); } -const char *ItemFunctions::GetUsedItemRefId(unsigned short pid) noexcept +extern "C" const char *ItemFunctions::GetUsedItemRefId(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, ""); @@ -182,7 +182,7 @@ const char *ItemFunctions::GetUsedItemRefId(unsigned short pid) noexcept return player->usedItem.refId.c_str(); } -int ItemFunctions::GetUsedItemCount(unsigned short pid) noexcept +extern "C" int ItemFunctions::GetUsedItemCount(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -190,7 +190,7 @@ int ItemFunctions::GetUsedItemCount(unsigned short pid) noexcept return player->usedItem.count; } -int ItemFunctions::GetUsedItemCharge(unsigned short pid) noexcept +extern "C" int ItemFunctions::GetUsedItemCharge(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -198,7 +198,7 @@ int ItemFunctions::GetUsedItemCharge(unsigned short pid) noexcept return player->usedItem.charge; } -double ItemFunctions::GetUsedItemEnchantmentCharge(unsigned short pid) noexcept +extern "C" double ItemFunctions::GetUsedItemEnchantmentCharge(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -206,7 +206,7 @@ double ItemFunctions::GetUsedItemEnchantmentCharge(unsigned short pid) noexcept return player->usedItem.enchantmentCharge; } -const char *ItemFunctions::GetUsedItemSoul(unsigned short pid) noexcept +extern "C" const char *ItemFunctions::GetUsedItemSoul(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, ""); @@ -214,7 +214,7 @@ const char *ItemFunctions::GetUsedItemSoul(unsigned short pid) noexcept return player->usedItem.soul.c_str(); } -void ItemFunctions::SendEquipment(unsigned short pid) noexcept +extern "C" void ItemFunctions::SendEquipment(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, ); @@ -228,7 +228,7 @@ void ItemFunctions::SendEquipment(unsigned short pid) noexcept player->equipmentIndexChanges.clear(); } -void ItemFunctions::SendInventoryChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept +extern "C" void ItemFunctions::SendInventoryChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept { Player *player; GET_PLAYER(pid, player, ); @@ -242,7 +242,7 @@ void ItemFunctions::SendInventoryChanges(unsigned short pid, bool sendToOtherPla packet->Send(true); } -void ItemFunctions::SendItemUse(unsigned short pid) noexcept +extern "C" void ItemFunctions::SendItemUse(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, ); @@ -253,14 +253,14 @@ void ItemFunctions::SendItemUse(unsigned short pid) noexcept packet->Send(false); } -// All methods below are deprecated versions of methods from above +extern "C" // All methods below are deprecated versions of methods from above void ItemFunctions::InitializeInventoryChanges(unsigned short pid) noexcept { ClearInventoryChanges(pid); } -void ItemFunctions::AddItem(unsigned short pid, const char* refId, unsigned int count, int charge, +extern "C" 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); diff --git a/apps/openmw-mp/Script/Functions/Items.hpp b/apps/openmw-mp/Script/Functions/Items.hpp index 041b07f33..042d1c2c7 100644 --- a/apps/openmw-mp/Script/Functions/Items.hpp +++ b/apps/openmw-mp/Script/Functions/Items.hpp @@ -41,10 +41,8 @@ {"InitializeInventoryChanges", ItemFunctions::InitializeInventoryChanges},\ {"AddItem", ItemFunctions::AddItem} -class ItemFunctions +namespace ItemFunctions { -public: - /** * \brief Clear the last recorded inventory changes for a player. * @@ -53,7 +51,7 @@ public: * \param pid The player ID whose inventory changes should be used. * \return void */ - static void ClearInventoryChanges(unsigned short pid) noexcept; + extern "C" void ClearInventoryChanges(unsigned short pid) noexcept; /** * \brief Get the number of slots used for equipment. @@ -62,7 +60,7 @@ public: * * \return The number of slots. */ - static int GetEquipmentSize() noexcept; + extern "C" int GetEquipmentSize() noexcept; /** * \brief Get the number of indexes in a player's latest inventory changes. @@ -70,7 +68,7 @@ public: * \param pid The player ID whose inventory changes should be used. * \return The number of indexes. */ - static unsigned int GetInventoryChangesSize(unsigned short pid) noexcept; + extern "C" unsigned int GetInventoryChangesSize(unsigned short pid) noexcept; /** * \brief Get the action type used in a player's latest inventory changes. @@ -78,7 +76,7 @@ public: * \param pid The player ID whose inventory changes should be used. * \return The action type (0 for SET, 1 for ADD, 2 for REMOVE). */ - static unsigned int GetInventoryChangesAction(unsigned short pid) noexcept; + extern "C" unsigned int GetInventoryChangesAction(unsigned short pid) noexcept; /** * \brief Set the action type in a player's inventory changes. @@ -87,7 +85,7 @@ public: * \param action The action (0 for SET, 1 for ADD, 2 for REMOVE). * \return void */ - static void SetInventoryChangesAction(unsigned short pid, unsigned char action) noexcept; + extern "C" 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 +98,7 @@ public: * \param enchantmentCharge The enchantment charge of the item. * \return void */ - static void EquipItem(unsigned short pid, unsigned short slot, const char* refId, unsigned int count, int charge, + extern "C" void EquipItem(unsigned short pid, unsigned short slot, const char* refId, unsigned int count, int charge, double enchantmentCharge = -1) noexcept; /** @@ -110,7 +108,7 @@ public: * \param slot The equipment slot. * \return void */ - static void UnequipItem(unsigned short pid, unsigned short slot) noexcept; + extern "C" void UnequipItem(unsigned short pid, unsigned short slot) noexcept; /** * \brief Add an item change to a player's inventory changes. @@ -123,7 +121,7 @@ public: * \param soul The soul of the item. * \return void */ - static void AddItemChange(unsigned short pid, const char* refId, unsigned int count, int charge, + extern "C" void AddItemChange(unsigned short pid, const char* refId, unsigned int count, int charge, double enchantmentCharge, const char* soul) noexcept; /** @@ -133,7 +131,7 @@ public: * \param refId The refId of the item. * \return Whether the player has the item equipped. */ - static bool HasItemEquipped(unsigned short pid, const char* refId); + extern "C" 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 +140,7 @@ public: * \param slot The slot of the equipment item. * \return The refId. */ - static const char *GetEquipmentItemRefId(unsigned short pid, unsigned short slot) noexcept; + extern "C" 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 +149,7 @@ public: * \param slot The slot of the equipment item. * \return The item count. */ - static int GetEquipmentItemCount(unsigned short pid, unsigned short slot) noexcept; + extern "C" 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 +158,7 @@ public: * \param slot The slot of the equipment item. * \return The charge. */ - static int GetEquipmentItemCharge(unsigned short pid, unsigned short slot) noexcept; + extern "C" 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 +168,7 @@ public: * \param slot The slot of the equipment item. * \return The enchantment charge. */ - static double GetEquipmentItemEnchantmentCharge(unsigned short pid, unsigned short slot) noexcept; + extern "C" 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 +178,7 @@ public: * \param index The index of the inventory item. * \return The refId. */ - static const char *GetInventoryItemRefId(unsigned short pid, unsigned int index) noexcept; + extern "C" 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 +188,7 @@ public: * \param index The index of the inventory item. * \return The item count. */ - static int GetInventoryItemCount(unsigned short pid, unsigned int index) noexcept; + extern "C" 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 +198,7 @@ public: * \param index The index of the inventory item. * \return The charge. */ - static int GetInventoryItemCharge(unsigned short pid, unsigned int index) noexcept; + extern "C" 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 +208,7 @@ public: * \param index The index of the inventory item. * \return The enchantment charge. */ - static double GetInventoryItemEnchantmentCharge(unsigned short pid, unsigned int index) noexcept; + extern "C" 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 +218,7 @@ public: * \param index The index of the inventory item. * \return The soul. */ - static const char *GetInventoryItemSoul(unsigned short pid, unsigned int index) noexcept; + extern "C" const char *GetInventoryItemSoul(unsigned short pid, unsigned int index) noexcept; /** * \brief Get the refId of the item last used by a player. @@ -228,7 +226,7 @@ public: * \param pid The player ID. * \return The refId. */ - static const char *GetUsedItemRefId(unsigned short pid) noexcept; + extern "C" const char *GetUsedItemRefId(unsigned short pid) noexcept; /** * \brief Get the count of the item last used by a player. @@ -236,7 +234,7 @@ public: * \param pid The player ID. * \return The item count. */ - static int GetUsedItemCount(unsigned short pid) noexcept; + extern "C" int GetUsedItemCount(unsigned short pid) noexcept; /** * \brief Get the charge of the item last used by a player. @@ -244,7 +242,7 @@ public: * \param pid The player ID. * \return The charge. */ - static int GetUsedItemCharge(unsigned short pid) noexcept; + extern "C" int GetUsedItemCharge(unsigned short pid) noexcept; /** * \brief Get the enchantment charge of the item last used by a player. @@ -252,7 +250,7 @@ public: * \param pid The player ID. * \return The enchantment charge. */ - static double GetUsedItemEnchantmentCharge(unsigned short pid) noexcept; + extern "C" double GetUsedItemEnchantmentCharge(unsigned short pid) noexcept; /** * \brief Get the soul of the item last used by a player. @@ -260,7 +258,7 @@ public: * \param pid The player ID. * \return The soul. */ - static const char *GetUsedItemSoul(unsigned short pid) noexcept; + extern "C" const char *GetUsedItemSoul(unsigned short pid) noexcept; /** * \brief Send a PlayerEquipment packet with a player's equipment. @@ -270,7 +268,7 @@ public: * \param pid The player ID whose equipment should be sent. * \return void */ - static void SendEquipment(unsigned short pid) noexcept; + extern "C" void SendEquipment(unsigned short pid) noexcept; /** * \brief Send a PlayerInventory packet with a player's recorded inventory changes. @@ -282,7 +280,7 @@ public: * to the packet (false by default). * \return void */ - static void SendInventoryChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept; + extern "C" void SendInventoryChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept; /** * \brief Send a PlayerItemUse causing a player to use their recorded usedItem. @@ -290,17 +288,14 @@ public: * \param pid The player ID affected. * \return void */ - static void SendItemUse(unsigned short pid) noexcept; + extern "C" void SendItemUse(unsigned short pid) noexcept; // All methods below are deprecated versions of methods from above - static void InitializeInventoryChanges(unsigned short pid) noexcept; + extern "C" void InitializeInventoryChanges(unsigned short pid) noexcept; - static void AddItem(unsigned short pid, const char* refId, unsigned int count, int charge, + extern "C" void AddItem(unsigned short pid, const char* refId, unsigned int count, int charge, double enchantmentCharge, const char* soul) noexcept; - -private: - -}; +} #endif //OPENMW_ITEMAPI_HPP diff --git a/apps/openmw-mp/Script/Functions/Mechanics.cpp b/apps/openmw-mp/Script/Functions/Mechanics.cpp index c4349b990..f10ed0dd7 100644 --- a/apps/openmw-mp/Script/Functions/Mechanics.cpp +++ b/apps/openmw-mp/Script/Functions/Mechanics.cpp @@ -11,7 +11,7 @@ using namespace std; static std::string tempCellDescription; -unsigned char MechanicsFunctions::GetMiscellaneousChangeType(unsigned short pid) noexcept +extern "C" unsigned char MechanicsFunctions::GetMiscellaneousChangeType(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -19,7 +19,7 @@ unsigned char MechanicsFunctions::GetMiscellaneousChangeType(unsigned short pid) return player->miscellaneousChangeType; } -const char *MechanicsFunctions::GetMarkCell(unsigned short pid) noexcept +extern "C" const char *MechanicsFunctions::GetMarkCell(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -28,7 +28,7 @@ const char *MechanicsFunctions::GetMarkCell(unsigned short pid) noexcept return tempCellDescription.c_str(); } -double MechanicsFunctions::GetMarkPosX(unsigned short pid) noexcept +extern "C" double MechanicsFunctions::GetMarkPosX(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0.0f); @@ -36,7 +36,7 @@ double MechanicsFunctions::GetMarkPosX(unsigned short pid) noexcept return player->markPosition.pos[0]; } -double MechanicsFunctions::GetMarkPosY(unsigned short pid) noexcept +extern "C" double MechanicsFunctions::GetMarkPosY(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0.0f); @@ -44,7 +44,7 @@ double MechanicsFunctions::GetMarkPosY(unsigned short pid) noexcept return player->markPosition.pos[1]; } -double MechanicsFunctions::GetMarkPosZ(unsigned short pid) noexcept +extern "C" double MechanicsFunctions::GetMarkPosZ(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0.0f); @@ -52,7 +52,7 @@ double MechanicsFunctions::GetMarkPosZ(unsigned short pid) noexcept return player->markPosition.pos[2]; } -double MechanicsFunctions::GetMarkRotX(unsigned short pid) noexcept +extern "C" double MechanicsFunctions::GetMarkRotX(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0.0f); @@ -60,7 +60,7 @@ double MechanicsFunctions::GetMarkRotX(unsigned short pid) noexcept return player->markPosition.rot[0]; } -double MechanicsFunctions::GetMarkRotZ(unsigned short pid) noexcept +extern "C" double MechanicsFunctions::GetMarkRotZ(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0.0f); @@ -68,7 +68,7 @@ double MechanicsFunctions::GetMarkRotZ(unsigned short pid) noexcept return player->markPosition.rot[2]; } -bool MechanicsFunctions::DoesPlayerHavePlayerKiller(unsigned short pid) noexcept +extern "C" bool MechanicsFunctions::DoesPlayerHavePlayerKiller(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, false); @@ -76,7 +76,7 @@ bool MechanicsFunctions::DoesPlayerHavePlayerKiller(unsigned short pid) noexcept return player->killer.isPlayer; } -int MechanicsFunctions::GetPlayerKillerPid(unsigned short pid) noexcept +extern "C" int MechanicsFunctions::GetPlayerKillerPid(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -89,7 +89,7 @@ int MechanicsFunctions::GetPlayerKillerPid(unsigned short pid) noexcept return -1; } -const char *MechanicsFunctions::GetPlayerKillerRefId(unsigned short pid) noexcept +extern "C" const char *MechanicsFunctions::GetPlayerKillerRefId(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, ""); @@ -97,7 +97,7 @@ const char *MechanicsFunctions::GetPlayerKillerRefId(unsigned short pid) noexcep return player->killer.refId.c_str(); } -unsigned int MechanicsFunctions::GetPlayerKillerRefNum(unsigned short pid) noexcept +extern "C" unsigned int MechanicsFunctions::GetPlayerKillerRefNum(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -105,7 +105,7 @@ unsigned int MechanicsFunctions::GetPlayerKillerRefNum(unsigned short pid) noexc return player->killer.refNum; } -unsigned int MechanicsFunctions::GetPlayerKillerMpNum(unsigned short pid) noexcept +extern "C" unsigned int MechanicsFunctions::GetPlayerKillerMpNum(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -113,7 +113,7 @@ unsigned int MechanicsFunctions::GetPlayerKillerMpNum(unsigned short pid) noexce return player->killer.mpNum; } -const char *MechanicsFunctions::GetPlayerKillerName(unsigned short pid) noexcept +extern "C" const char *MechanicsFunctions::GetPlayerKillerName(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, ""); @@ -121,7 +121,7 @@ const char *MechanicsFunctions::GetPlayerKillerName(unsigned short pid) noexcept return player->killer.name.c_str(); } -const char *MechanicsFunctions::GetSelectedSpellId(unsigned short pid) noexcept +extern "C" const char *MechanicsFunctions::GetSelectedSpellId(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -129,7 +129,7 @@ const char *MechanicsFunctions::GetSelectedSpellId(unsigned short pid) noexcept return player->selectedSpellId.c_str(); } -unsigned int MechanicsFunctions::GetDrawState(unsigned short pid) noexcept +extern "C" unsigned int MechanicsFunctions::GetDrawState(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, false); @@ -137,7 +137,7 @@ unsigned int MechanicsFunctions::GetDrawState(unsigned short pid) noexcept return player->drawState; } -bool MechanicsFunctions::GetSneakState(unsigned short pid) noexcept +extern "C" bool MechanicsFunctions::GetSneakState(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, false); @@ -146,7 +146,7 @@ bool MechanicsFunctions::GetSneakState(unsigned short pid) noexcept return (player->movementFlags & 8) != 0; } -void MechanicsFunctions::SetMarkCell(unsigned short pid, const char *cellDescription) noexcept +extern "C" void MechanicsFunctions::SetMarkCell(unsigned short pid, const char *cellDescription) noexcept { Player *player; GET_PLAYER(pid, player, ); @@ -154,7 +154,7 @@ void MechanicsFunctions::SetMarkCell(unsigned short pid, const char *cellDescrip player->markCell = Utils::getCellFromDescription(cellDescription); } -void MechanicsFunctions::SetMarkPos(unsigned short pid, double x, double y, double z) noexcept +extern "C" void MechanicsFunctions::SetMarkPos(unsigned short pid, double x, double y, double z) noexcept { Player *player; GET_PLAYER(pid, player, ); @@ -164,7 +164,7 @@ void MechanicsFunctions::SetMarkPos(unsigned short pid, double x, double y, doub player->markPosition.pos[2] = z; } -void MechanicsFunctions::SetMarkRot(unsigned short pid, double x, double z) noexcept +extern "C" void MechanicsFunctions::SetMarkRot(unsigned short pid, double x, double z) noexcept { Player *player; GET_PLAYER(pid, player, ); @@ -173,7 +173,7 @@ void MechanicsFunctions::SetMarkRot(unsigned short pid, double x, double z) noex player->markPosition.rot[2] = z; } -void MechanicsFunctions::SetSelectedSpellId(unsigned short pid, const char *spellId) noexcept +extern "C" void MechanicsFunctions::SetSelectedSpellId(unsigned short pid, const char *spellId) noexcept { Player *player; GET_PLAYER(pid, player, ); @@ -181,7 +181,7 @@ void MechanicsFunctions::SetSelectedSpellId(unsigned short pid, const char *spel player->selectedSpellId = spellId; } -void MechanicsFunctions::SendMarkLocation(unsigned short pid) +extern "C" void MechanicsFunctions::SendMarkLocation(unsigned short pid) { Player *player; GET_PLAYER(pid, player, ); @@ -194,7 +194,7 @@ void MechanicsFunctions::SendMarkLocation(unsigned short pid) packet->Send(false); } -void MechanicsFunctions::SendSelectedSpell(unsigned short pid) +extern "C" void MechanicsFunctions::SendSelectedSpell(unsigned short pid) { Player *player; GET_PLAYER(pid, player, ); @@ -207,7 +207,7 @@ void MechanicsFunctions::SendSelectedSpell(unsigned short pid) packet->Send(false); } -void MechanicsFunctions::Jail(unsigned short pid, int jailDays, bool ignoreJailTeleportation, bool ignoreJailSkillIncreases, +extern "C" void MechanicsFunctions::Jail(unsigned short pid, int jailDays, bool ignoreJailTeleportation, bool ignoreJailSkillIncreases, const char* jailProgressText, const char* jailEndText) noexcept { Player *player; @@ -225,7 +225,7 @@ void MechanicsFunctions::Jail(unsigned short pid, int jailDays, bool ignoreJailT packet->Send(false); } -void MechanicsFunctions::Resurrect(unsigned short pid, unsigned int type) noexcept +extern "C" void MechanicsFunctions::Resurrect(unsigned short pid, unsigned int type) noexcept { Player *player; GET_PLAYER(pid, player, ); @@ -241,7 +241,7 @@ void MechanicsFunctions::Resurrect(unsigned short pid, unsigned int type) noexce // All methods below are deprecated versions of methods from above -const char *MechanicsFunctions::GetDeathReason(unsigned short pid) noexcept +extern "C" const char *MechanicsFunctions::GetDeathReason(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0); @@ -259,7 +259,7 @@ const char *MechanicsFunctions::GetDeathReason(unsigned short pid) noexcept return "suicide"; } -unsigned int MechanicsFunctions::GetPlayerKillerRefNumIndex(unsigned short pid) noexcept +extern "C" unsigned int MechanicsFunctions::GetPlayerKillerRefNumIndex(unsigned short pid) noexcept { return GetPlayerKillerRefNum(pid); } diff --git a/apps/openmw-mp/Script/Functions/Mechanics.hpp b/apps/openmw-mp/Script/Functions/Mechanics.hpp index edc5d8133..1a95765f3 100644 --- a/apps/openmw-mp/Script/Functions/Mechanics.hpp +++ b/apps/openmw-mp/Script/Functions/Mechanics.hpp @@ -38,17 +38,15 @@ {"GetDeathReason", MechanicsFunctions::GetDeathReason},\ {"GetPlayerKillerRefNumIndex", MechanicsFunctions::GetPlayerKillerRefNumIndex} -class MechanicsFunctions +namespace MechanicsFunctions { -public: - /** * \brief Get the type of a PlayerMiscellaneous packet. * * \param pid The player ID. * \return The type. */ - static unsigned char GetMiscellaneousChangeType(unsigned short pid) noexcept; + extern "C" unsigned char GetMiscellaneousChangeType(unsigned short pid) noexcept; /** * \brief Get the cell description of a player's Mark cell. @@ -56,7 +54,7 @@ public: * \param pid The player ID. * \return The cell description. */ - static const char *GetMarkCell(unsigned short pid) noexcept; + extern "C" const char *GetMarkCell(unsigned short pid) noexcept; /** * \brief Get the X position of a player's Mark. @@ -64,7 +62,7 @@ public: * \param pid The player ID. * \return The X position. */ - static double GetMarkPosX(unsigned short pid) noexcept; + extern "C" double GetMarkPosX(unsigned short pid) noexcept; /** * \brief Get the Y position of a player's Mark. @@ -72,7 +70,7 @@ public: * \param pid The player ID. * \return The Y position. */ - static double GetMarkPosY(unsigned short pid) noexcept; + extern "C" double GetMarkPosY(unsigned short pid) noexcept; /** * \brief Get the Z position of a player's Mark. @@ -80,7 +78,7 @@ public: * \param pid The player ID. * \return The Z position. */ - static double GetMarkPosZ(unsigned short pid) noexcept; + extern "C" double GetMarkPosZ(unsigned short pid) noexcept; /** * \brief Get the X rotation of a player's Mark. @@ -88,7 +86,7 @@ public: * \param pid The player ID. * \return The X rotation. */ - static double GetMarkRotX(unsigned short pid) noexcept; + extern "C" double GetMarkRotX(unsigned short pid) noexcept; /** * \brief Get the Z rotation of a player's Mark. @@ -96,7 +94,7 @@ public: * \param pid The player ID. * \return The X rotation. */ - static double GetMarkRotZ(unsigned short pid) noexcept; + extern "C" double GetMarkRotZ(unsigned short pid) noexcept; /** * \brief Get the ID of a player's selected spell. @@ -104,7 +102,7 @@ public: * \param pid The player ID. * \return The spell ID. */ - static const char *GetSelectedSpellId(unsigned short pid) noexcept; + extern "C" const char *GetSelectedSpellId(unsigned short pid) noexcept; /** * \brief Check whether the killer of a certain player is also a player. @@ -112,7 +110,7 @@ public: * \param pid The player ID of the killed player. * \return Whether the player was killed by another player. */ - static bool DoesPlayerHavePlayerKiller(unsigned short pid) noexcept; + extern "C" bool DoesPlayerHavePlayerKiller(unsigned short pid) noexcept; /** * \brief Get the player ID of the killer of a certain player. @@ -120,7 +118,7 @@ public: * \param pid The player ID of the killed player. * \return The player ID of the killer. */ - static int GetPlayerKillerPid(unsigned short pid) noexcept; + extern "C" int GetPlayerKillerPid(unsigned short pid) noexcept; /** * \brief Get the refId of the actor killer of a certain player. @@ -128,7 +126,7 @@ public: * \param pid The player ID of the killed player. * \return The refId of the killer. */ - static const char *GetPlayerKillerRefId(unsigned short pid) noexcept; + extern "C" const char *GetPlayerKillerRefId(unsigned short pid) noexcept; /** * \brief Get the refNum of the actor killer of a certain player. @@ -136,7 +134,7 @@ public: * \param pid The player ID of the killed player. * \return The refNum of the killer. */ - static unsigned int GetPlayerKillerRefNum(unsigned short pid) noexcept; + extern "C" unsigned int GetPlayerKillerRefNum(unsigned short pid) noexcept; /** * \brief Get the mpNum of the actor killer of a certain player. @@ -144,7 +142,7 @@ public: * \param pid The player ID of the killed player. * \return The mpNum of the killer. */ - static unsigned int GetPlayerKillerMpNum(unsigned short pid) noexcept; + extern "C" unsigned int GetPlayerKillerMpNum(unsigned short pid) noexcept; /** * \brief Get the name of the actor killer of a certain player. @@ -152,7 +150,7 @@ public: * \param pid The player ID of the killed player. * \return The name of the killer. */ - static const char *GetPlayerKillerName(unsigned short pid) noexcept; + extern "C" const char *GetPlayerKillerName(unsigned short pid) noexcept; /** * \brief Get the draw state of a player (0 for nothing, 1 for drawn weapon, @@ -161,7 +159,7 @@ public: * \param pid The player ID. * \return The draw state. */ - static unsigned int GetDrawState(unsigned short pid) noexcept; + extern "C" unsigned int GetDrawState(unsigned short pid) noexcept; /** * \brief Get the sneak state of a player. @@ -169,7 +167,7 @@ public: * \param pid The player ID. * \return Whether the player is sneaking. */ - static bool GetSneakState(unsigned short pid) noexcept; + extern "C" bool GetSneakState(unsigned short pid) noexcept; /** * \brief Set the Mark cell of a player. @@ -184,7 +182,7 @@ public: * \param cellDescription The cell description. * \return void */ - static void SetMarkCell(unsigned short pid, const char *cellDescription) noexcept; + extern "C" void SetMarkCell(unsigned short pid, const char *cellDescription) noexcept; /** * \brief Set the Mark position of a player. @@ -198,7 +196,7 @@ public: * \param z The Z position. * \return void */ - static void SetMarkPos(unsigned short pid, double x, double y, double z) noexcept; + extern "C" void SetMarkPos(unsigned short pid, double x, double y, double z) noexcept; /** * \brief Set the Mark rotation of a player. @@ -211,7 +209,7 @@ public: * \param z The Z rotation. * \return void */ - static void SetMarkRot(unsigned short pid, double x, double z) noexcept; + extern "C" void SetMarkRot(unsigned short pid, double x, double z) noexcept; /** * \brief Set the ID of a player's selected spell. @@ -223,7 +221,7 @@ public: * \param spellId The spell ID. * \return void */ - static void SetSelectedSpellId(unsigned short pid, const char *spellId) noexcept; + extern "C" void SetSelectedSpellId(unsigned short pid, const char *spellId) noexcept; /** * \brief Send a PlayerMiscellaneous packet with a Mark location to a player. @@ -231,7 +229,7 @@ public: * \param pid The player ID. * \return void */ - static void SendMarkLocation(unsigned short pid); + extern "C" void SendMarkLocation(unsigned short pid); /** * \brief Send a PlayerMiscellaneous packet with a selected spell ID to a player. @@ -239,7 +237,7 @@ public: * \param pid The player ID. * \return void */ - static void SendSelectedSpell(unsigned short pid); + extern "C" void SendSelectedSpell(unsigned short pid); /** * \brief Send a PlayerJail packet about a player. @@ -261,7 +259,7 @@ public: * \param jailEndText The text that should be displayed once the jailing period is over. * \return void */ - static void Jail(unsigned short pid, int jailDays, bool ignoreJailTeleportation, bool ignoreJailSkillIncreases, + extern "C" void Jail(unsigned short pid, int jailDays, bool ignoreJailTeleportation, bool ignoreJailSkillIncreases, const char* jailProgressText, const char* jailEndText) noexcept; /** @@ -274,13 +272,12 @@ public: * 2 for TRIBUNAL_TEMPLE). * \return void */ - static void Resurrect(unsigned short pid, unsigned int type) noexcept; + extern "C" void Resurrect(unsigned short pid, unsigned int type) noexcept; // All methods below are deprecated versions of methods from above - static const char *GetDeathReason(unsigned short pid) noexcept; - static unsigned int GetPlayerKillerRefNumIndex(unsigned short pid) noexcept; - -}; + extern "C" const char *GetDeathReason(unsigned short pid) noexcept; + extern "C" unsigned int GetPlayerKillerRefNumIndex(unsigned short pid) noexcept; +} #endif //OPENMW_MECHANICSAPI_HPP diff --git a/apps/openmw-mp/Script/Functions/Miscellaneous.cpp b/apps/openmw-mp/Script/Functions/Miscellaneous.cpp index d9e55e4c8..fa11e0cb8 100644 --- a/apps/openmw-mp/Script/Functions/Miscellaneous.cpp +++ b/apps/openmw-mp/Script/Functions/Miscellaneous.cpp @@ -11,12 +11,12 @@ using namespace std; static std::string tempFilename; -bool MiscellaneousFunctions::DoesFileExist(const char *filePath) noexcept +extern "C" bool MiscellaneousFunctions::DoesFileExist(const char *filePath) noexcept { return boost::filesystem::exists(filePath); } -const char *MiscellaneousFunctions::GetCaseInsensitiveFilename(const char *folderPath, const char *filename) noexcept +extern "C" const char *MiscellaneousFunctions::GetCaseInsensitiveFilename(const char *folderPath, const char *filename) noexcept { if (!boost::filesystem::exists(folderPath)) return "invalid"; @@ -33,27 +33,27 @@ const char *MiscellaneousFunctions::GetCaseInsensitiveFilename(const char *folde return "invalid"; } -unsigned int MiscellaneousFunctions::GetLastPlayerId() noexcept +extern "C" unsigned int MiscellaneousFunctions::GetLastPlayerId() noexcept { return Players::getLastPlayerId(); } -int MiscellaneousFunctions::GetCurrentMpNum() noexcept +extern "C" int MiscellaneousFunctions::GetCurrentMpNum() noexcept { return mwmp::Networking::getPtr()->getCurrentMpNum(); } -void MiscellaneousFunctions::SetCurrentMpNum(int mpNum) noexcept +extern "C" void MiscellaneousFunctions::SetCurrentMpNum(int mpNum) noexcept { mwmp::Networking::getPtr()->setCurrentMpNum(mpNum); } -void MiscellaneousFunctions::LogMessage(unsigned short level, const char *message) noexcept +extern "C" void MiscellaneousFunctions::LogMessage(unsigned short level, const char *message) noexcept { LOG_MESSAGE_SIMPLE(level, "[Script]: %s", message); } -void MiscellaneousFunctions::LogAppend(unsigned short level, const char *message) noexcept +extern "C" void MiscellaneousFunctions::LogAppend(unsigned short level, const char *message) noexcept { LOG_APPEND(level, "[Script]: %s", message); } diff --git a/apps/openmw-mp/Script/Functions/Miscellaneous.hpp b/apps/openmw-mp/Script/Functions/Miscellaneous.hpp index bd3f211c7..aec83d810 100644 --- a/apps/openmw-mp/Script/Functions/Miscellaneous.hpp +++ b/apps/openmw-mp/Script/Functions/Miscellaneous.hpp @@ -15,10 +15,8 @@ {"LogMessage", MiscellaneousFunctions::LogMessage},\ {"LogAppend", MiscellaneousFunctions::LogAppend} -class MiscellaneousFunctions +namespace MiscellaneousFunctions { -public: - /** * \brief Check whether a certain file exists. * @@ -28,7 +26,7 @@ public: * * \return Whether the file exists or not. */ - static bool DoesFileExist(const char *filePath) noexcept; + extern "C" bool DoesFileExist(const char *filePath) noexcept; /** * \brief Get the first filename in a folder that has a case insensitive match with the filename @@ -38,7 +36,7 @@ public: * * \return The filename that matches. */ - static const char *GetCaseInsensitiveFilename(const char *folderPath, const char *filename) noexcept; + extern "C" const char *GetCaseInsensitiveFilename(const char *folderPath, const char *filename) noexcept; /** * \brief Get the last player ID currently connected to the server. @@ -48,7 +46,7 @@ public: * * \return The player ID. */ - static unsigned int GetLastPlayerId() noexcept; + extern "C" unsigned int GetLastPlayerId() noexcept; /** * \brief Get the current (latest) mpNum generated by the server. @@ -62,7 +60,7 @@ public: * * \return The mpNum. */ - static int GetCurrentMpNum() noexcept; + extern "C" int GetCurrentMpNum() noexcept; /** * \brief Set the current (latest) mpNum generated by the server. @@ -74,7 +72,7 @@ public: * \param mpNum The number that should be used as the new current mpNum. * \return void */ - static void SetCurrentMpNum(int mpNum) noexcept; + extern "C" void SetCurrentMpNum(int mpNum) noexcept; /** * \brief Write a log message with its own timestamp. @@ -86,7 +84,7 @@ public: * \param message The message logged. * \return void */ - static void LogMessage(unsigned short level, const char *message) noexcept; + extern "C" void LogMessage(unsigned short level, const char *message) noexcept; /** * \brief Write a log message without its own timestamp. @@ -98,7 +96,7 @@ public: * \param message The message logged. * \return void */ - static void LogAppend(unsigned short level, const char *message) noexcept; -}; + extern "C" void LogAppend(unsigned short level, const char *message) noexcept; +} #endif //OPENMW_MISCELLANEOUSAPI_HPP diff --git a/apps/openmw-mp/Script/Functions/Objects.cpp b/apps/openmw-mp/Script/Functions/Objects.cpp index 4e8528a6b..ca1e659ee 100644 --- a/apps/openmw-mp/Script/Functions/Objects.cpp +++ b/apps/openmw-mp/Script/Functions/Objects.cpp @@ -19,19 +19,19 @@ const BaseObject emptyObject = {}; ContainerItem tempContainerItem; const ContainerItem emptyContainerItem = {}; -void ObjectFunctions::ReadReceivedObjectList() noexcept +extern "C" void ObjectFunctions::ReadReceivedObjectList() noexcept { readObjectList = mwmp::Networking::getPtr()->getReceivedObjectList(); } -void ObjectFunctions::ClearObjectList() noexcept +extern "C" void ObjectFunctions::ClearObjectList() noexcept { writeObjectList.cell.blank(); writeObjectList.baseObjects.clear(); writeObjectList.packetOrigin = mwmp::PACKET_ORIGIN::SERVER_SCRIPT; } -void ObjectFunctions::SetObjectListPid(unsigned short pid) noexcept +extern "C" void ObjectFunctions::SetObjectListPid(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, ); @@ -39,42 +39,42 @@ void ObjectFunctions::SetObjectListPid(unsigned short pid) noexcept writeObjectList.guid = player->guid; } -void ObjectFunctions::CopyReceivedObjectListToStore() noexcept +extern "C" void ObjectFunctions::CopyReceivedObjectListToStore() noexcept { writeObjectList = *readObjectList; } -unsigned int ObjectFunctions::GetObjectListSize() noexcept +extern "C" unsigned int ObjectFunctions::GetObjectListSize() noexcept { return readObjectList->baseObjectCount; } -unsigned char ObjectFunctions::GetObjectListOrigin() noexcept +extern "C" unsigned char ObjectFunctions::GetObjectListOrigin() noexcept { return readObjectList->packetOrigin; } -const char *ObjectFunctions::GetObjectListClientScript() noexcept +extern "C" const char *ObjectFunctions::GetObjectListClientScript() noexcept { return readObjectList->originClientScript.c_str(); } -unsigned char ObjectFunctions::GetObjectListAction() noexcept +extern "C" unsigned char ObjectFunctions::GetObjectListAction() noexcept { return readObjectList->action; } -unsigned char ObjectFunctions::GetObjectListContainerSubAction() noexcept +extern "C" unsigned char ObjectFunctions::GetObjectListContainerSubAction() noexcept { return readObjectList->containerSubAction; } -bool ObjectFunctions::IsObjectPlayer(unsigned int index) noexcept +extern "C" bool ObjectFunctions::IsObjectPlayer(unsigned int index) noexcept { return readObjectList->baseObjects.at(index).isPlayer; } -int ObjectFunctions::GetObjectPid(unsigned int index) noexcept +extern "C" int ObjectFunctions::GetObjectPid(unsigned int index) noexcept { Player *player = Players::getPlayer(readObjectList->baseObjects.at(index).guid); @@ -84,72 +84,72 @@ int ObjectFunctions::GetObjectPid(unsigned int index) noexcept return -1; } -const char *ObjectFunctions::GetObjectRefId(unsigned int index) noexcept +extern "C" const char *ObjectFunctions::GetObjectRefId(unsigned int index) noexcept { return readObjectList->baseObjects.at(index).refId.c_str(); } -unsigned int ObjectFunctions::GetObjectRefNum(unsigned int index) noexcept +extern "C" unsigned int ObjectFunctions::GetObjectRefNum(unsigned int index) noexcept { return readObjectList->baseObjects.at(index).refNum; } -unsigned int ObjectFunctions::GetObjectMpNum(unsigned int index) noexcept +extern "C" unsigned int ObjectFunctions::GetObjectMpNum(unsigned int index) noexcept { return readObjectList->baseObjects.at(index).mpNum; } -int ObjectFunctions::GetObjectCount(unsigned int index) noexcept +extern "C" int ObjectFunctions::GetObjectCount(unsigned int index) noexcept { return readObjectList->baseObjects.at(index).count; } -int ObjectFunctions::GetObjectCharge(unsigned int index) noexcept +extern "C" int ObjectFunctions::GetObjectCharge(unsigned int index) noexcept { return readObjectList->baseObjects.at(index).charge; } -double ObjectFunctions::GetObjectEnchantmentCharge(unsigned int index) noexcept +extern "C" double ObjectFunctions::GetObjectEnchantmentCharge(unsigned int index) noexcept { return readObjectList->baseObjects.at(index).enchantmentCharge; } -const char *ObjectFunctions::GetObjectSoul(unsigned int index) noexcept +extern "C" const char *ObjectFunctions::GetObjectSoul(unsigned int index) noexcept { return readObjectList->baseObjects.at(index).soul.c_str(); } -int ObjectFunctions::GetObjectGoldValue(unsigned int index) noexcept +extern "C" int ObjectFunctions::GetObjectGoldValue(unsigned int index) noexcept { return readObjectList->baseObjects.at(index).goldValue; } -double ObjectFunctions::GetObjectScale(unsigned int index) noexcept +extern "C" double ObjectFunctions::GetObjectScale(unsigned int index) noexcept { return readObjectList->baseObjects.at(index).scale; } -bool ObjectFunctions::GetObjectState(unsigned int index) noexcept +extern "C" bool ObjectFunctions::GetObjectState(unsigned int index) noexcept { return readObjectList->baseObjects.at(index).objectState; } -int ObjectFunctions::GetObjectDoorState(unsigned int index) noexcept +extern "C" int ObjectFunctions::GetObjectDoorState(unsigned int index) noexcept { return readObjectList->baseObjects.at(index).doorState; } -int ObjectFunctions::GetObjectLockLevel(unsigned int index) noexcept +extern "C" int ObjectFunctions::GetObjectLockLevel(unsigned int index) noexcept { return readObjectList->baseObjects.at(index).lockLevel; } -bool ObjectFunctions::DoesObjectHavePlayerActivating(unsigned int index) noexcept +extern "C" bool ObjectFunctions::DoesObjectHavePlayerActivating(unsigned int index) noexcept { return readObjectList->baseObjects.at(index).activatingActor.isPlayer; } -int ObjectFunctions::GetObjectActivatingPid(unsigned int index) noexcept +extern "C" int ObjectFunctions::GetObjectActivatingPid(unsigned int index) noexcept { Player *player = Players::getPlayer(readObjectList->baseObjects.at(index).activatingActor.guid); @@ -159,42 +159,42 @@ int ObjectFunctions::GetObjectActivatingPid(unsigned int index) noexcept return -1; } -const char *ObjectFunctions::GetObjectActivatingRefId(unsigned int index) noexcept +extern "C" const char *ObjectFunctions::GetObjectActivatingRefId(unsigned int index) noexcept { return readObjectList->baseObjects.at(index).activatingActor.refId.c_str(); } -unsigned int ObjectFunctions::GetObjectActivatingRefNum(unsigned int index) noexcept +extern "C" unsigned int ObjectFunctions::GetObjectActivatingRefNum(unsigned int index) noexcept { return readObjectList->baseObjects.at(index).activatingActor.refNum; } -unsigned int ObjectFunctions::GetObjectActivatingMpNum(unsigned int index) noexcept +extern "C" unsigned int ObjectFunctions::GetObjectActivatingMpNum(unsigned int index) noexcept { return readObjectList->baseObjects.at(index).activatingActor.mpNum; } -const char *ObjectFunctions::GetObjectActivatingName(unsigned int index) noexcept +extern "C" const char *ObjectFunctions::GetObjectActivatingName(unsigned int index) noexcept { return readObjectList->baseObjects.at(index).activatingActor.name.c_str(); } -bool ObjectFunctions::GetObjectSummonState(unsigned int index) noexcept +extern "C" bool ObjectFunctions::GetObjectSummonState(unsigned int index) noexcept { return readObjectList->baseObjects.at(index).isSummon; } -double ObjectFunctions::GetObjectSummonDuration(unsigned int index) noexcept +extern "C" double ObjectFunctions::GetObjectSummonDuration(unsigned int index) noexcept { return readObjectList->baseObjects.at(index).summonDuration; } -bool ObjectFunctions::DoesObjectHavePlayerSummoner(unsigned int index) noexcept +extern "C" bool ObjectFunctions::DoesObjectHavePlayerSummoner(unsigned int index) noexcept { return readObjectList->baseObjects.at(index).master.isPlayer; } -int ObjectFunctions::GetObjectSummonerPid(unsigned int index) noexcept +extern "C" int ObjectFunctions::GetObjectSummonerPid(unsigned int index) noexcept { Player *player = Players::getPlayer(readObjectList->baseObjects.at(index).master.guid); @@ -204,202 +204,202 @@ int ObjectFunctions::GetObjectSummonerPid(unsigned int index) noexcept return -1; } -const char *ObjectFunctions::GetObjectSummonerRefId(unsigned int index) noexcept +extern "C" const char *ObjectFunctions::GetObjectSummonerRefId(unsigned int index) noexcept { return readObjectList->baseObjects.at(index).master.refId.c_str(); } -unsigned int ObjectFunctions::GetObjectSummonerRefNum(unsigned int index) noexcept +extern "C" unsigned int ObjectFunctions::GetObjectSummonerRefNum(unsigned int index) noexcept { return readObjectList->baseObjects.at(index).master.refNum; } -unsigned int ObjectFunctions::GetObjectSummonerMpNum(unsigned int index) noexcept +extern "C" unsigned int ObjectFunctions::GetObjectSummonerMpNum(unsigned int index) noexcept { return readObjectList->baseObjects.at(index).master.mpNum; } -double ObjectFunctions::GetObjectPosX(unsigned int index) noexcept +extern "C" double ObjectFunctions::GetObjectPosX(unsigned int index) noexcept { return readObjectList->baseObjects.at(index).position.pos[0]; } -double ObjectFunctions::GetObjectPosY(unsigned int index) noexcept +extern "C" double ObjectFunctions::GetObjectPosY(unsigned int index) noexcept { return readObjectList->baseObjects.at(index).position.pos[1]; } -double ObjectFunctions::GetObjectPosZ(unsigned int index) noexcept +extern "C" double ObjectFunctions::GetObjectPosZ(unsigned int index) noexcept { return readObjectList->baseObjects.at(index).position.pos[2]; } -double ObjectFunctions::GetObjectRotX(unsigned int index) noexcept +extern "C" double ObjectFunctions::GetObjectRotX(unsigned int index) noexcept { return readObjectList->baseObjects.at(index).position.rot[0]; } -double ObjectFunctions::GetObjectRotY(unsigned int index) noexcept +extern "C" double ObjectFunctions::GetObjectRotY(unsigned int index) noexcept { return readObjectList->baseObjects.at(index).position.rot[1]; } -double ObjectFunctions::GetObjectRotZ(unsigned int index) noexcept +extern "C" double ObjectFunctions::GetObjectRotZ(unsigned int index) noexcept { return readObjectList->baseObjects.at(index).position.rot[2]; } -const char *ObjectFunctions::GetVideoFilename(unsigned int index) noexcept +extern "C" const char *ObjectFunctions::GetVideoFilename(unsigned int index) noexcept { return readObjectList->baseObjects.at(index).videoFilename.c_str(); } -unsigned int ObjectFunctions::GetContainerChangesSize(unsigned int objectIndex) noexcept +extern "C" unsigned int ObjectFunctions::GetContainerChangesSize(unsigned int objectIndex) noexcept { return readObjectList->baseObjects.at(objectIndex).containerItemCount; } -const char *ObjectFunctions::GetContainerItemRefId(unsigned int objectIndex, unsigned int itemIndex) noexcept +extern "C" const char *ObjectFunctions::GetContainerItemRefId(unsigned int objectIndex, unsigned int itemIndex) noexcept { return readObjectList->baseObjects.at(objectIndex) .containerItems.at(itemIndex).refId.c_str(); } -int ObjectFunctions::GetContainerItemCount(unsigned int objectIndex, unsigned int itemIndex) noexcept +extern "C" int ObjectFunctions::GetContainerItemCount(unsigned int objectIndex, unsigned int itemIndex) noexcept { return readObjectList->baseObjects.at(objectIndex) .containerItems.at(itemIndex).count; } -int ObjectFunctions::GetContainerItemCharge(unsigned int objectIndex, unsigned int itemIndex) noexcept +extern "C" int ObjectFunctions::GetContainerItemCharge(unsigned int objectIndex, unsigned int itemIndex) noexcept { return readObjectList->baseObjects.at(objectIndex) .containerItems.at(itemIndex).charge; } -double ObjectFunctions::GetContainerItemEnchantmentCharge(unsigned int objectIndex, unsigned int itemIndex) noexcept +extern "C" double ObjectFunctions::GetContainerItemEnchantmentCharge(unsigned int objectIndex, unsigned int itemIndex) noexcept { return readObjectList->baseObjects.at(objectIndex) .containerItems.at(itemIndex).enchantmentCharge; } -const char *ObjectFunctions::GetContainerItemSoul(unsigned int objectIndex, unsigned int itemIndex) noexcept +extern "C" const char *ObjectFunctions::GetContainerItemSoul(unsigned int objectIndex, unsigned int itemIndex) noexcept { return readObjectList->baseObjects.at(objectIndex) .containerItems.at(itemIndex).soul.c_str(); } -int ObjectFunctions::GetContainerItemActionCount(unsigned int objectIndex, unsigned int itemIndex) noexcept +extern "C" int ObjectFunctions::GetContainerItemActionCount(unsigned int objectIndex, unsigned int itemIndex) noexcept { return readObjectList->baseObjects.at(objectIndex) .containerItems.at(itemIndex).actionCount; } -bool ObjectFunctions::DoesObjectHaveContainer(unsigned int index) noexcept +extern "C" bool ObjectFunctions::DoesObjectHaveContainer(unsigned int index) noexcept { return readObjectList->baseObjects.at(index).hasContainer; } -void ObjectFunctions::SetObjectListCell(const char* cellDescription) noexcept +extern "C" void ObjectFunctions::SetObjectListCell(const char* cellDescription) noexcept { writeObjectList.cell = Utils::getCellFromDescription(cellDescription); } -void ObjectFunctions::SetObjectListAction(unsigned char action) noexcept +extern "C" void ObjectFunctions::SetObjectListAction(unsigned char action) noexcept { writeObjectList.action = action; } -void ObjectFunctions::SetObjectListConsoleCommand(const char* consoleCommand) noexcept +extern "C" void ObjectFunctions::SetObjectListConsoleCommand(const char* consoleCommand) noexcept { writeObjectList.consoleCommand = consoleCommand; } -void ObjectFunctions::SetObjectRefId(const char* refId) noexcept +extern "C" void ObjectFunctions::SetObjectRefId(const char* refId) noexcept { tempObject.refId = refId; } -void ObjectFunctions::SetObjectRefNum(int refNum) noexcept +extern "C" void ObjectFunctions::SetObjectRefNum(int refNum) noexcept { tempObject.refNum = refNum; } -void ObjectFunctions::SetObjectMpNum(int mpNum) noexcept +extern "C" void ObjectFunctions::SetObjectMpNum(int mpNum) noexcept { tempObject.mpNum = mpNum; } -void ObjectFunctions::SetObjectCount(int count) noexcept +extern "C" void ObjectFunctions::SetObjectCount(int count) noexcept { tempObject.count = count; } -void ObjectFunctions::SetObjectCharge(int charge) noexcept +extern "C" void ObjectFunctions::SetObjectCharge(int charge) noexcept { tempObject.charge = charge; } -void ObjectFunctions::SetObjectEnchantmentCharge(double enchantmentCharge) noexcept +extern "C" void ObjectFunctions::SetObjectEnchantmentCharge(double enchantmentCharge) noexcept { tempObject.enchantmentCharge = enchantmentCharge; } -void ObjectFunctions::SetObjectSoul(const char* soul) noexcept +extern "C" void ObjectFunctions::SetObjectSoul(const char* soul) noexcept { tempObject.soul = soul; } -void ObjectFunctions::SetObjectGoldValue(int goldValue) noexcept +extern "C" void ObjectFunctions::SetObjectGoldValue(int goldValue) noexcept { tempObject.goldValue = goldValue; } -void ObjectFunctions::SetObjectScale(double scale) noexcept +extern "C" void ObjectFunctions::SetObjectScale(double scale) noexcept { tempObject.scale = scale; } -void ObjectFunctions::SetObjectState(bool objectState) noexcept +extern "C" void ObjectFunctions::SetObjectState(bool objectState) noexcept { tempObject.objectState = objectState; } -void ObjectFunctions::SetObjectLockLevel(int lockLevel) noexcept +extern "C" void ObjectFunctions::SetObjectLockLevel(int lockLevel) noexcept { tempObject.lockLevel = lockLevel; } -void ObjectFunctions::SetObjectSummonDuration(float summonDuration) noexcept +extern "C" void ObjectFunctions::SetObjectSummonDuration(float summonDuration) noexcept { tempObject.summonDuration = summonDuration; } -void ObjectFunctions::SetObjectDisarmState(bool disarmState) noexcept +extern "C" void ObjectFunctions::SetObjectDisarmState(bool disarmState) noexcept { tempObject.isDisarmed = disarmState; } -void ObjectFunctions::SetObjectSummonState(bool summonState) noexcept +extern "C" void ObjectFunctions::SetObjectSummonState(bool summonState) noexcept { tempObject.isSummon = summonState; } -void ObjectFunctions::SetObjectPosition(double x, double y, double z) noexcept +extern "C" void ObjectFunctions::SetObjectPosition(double x, double y, double z) noexcept { tempObject.position.pos[0] = x; tempObject.position.pos[1] = y; tempObject.position.pos[2] = z; } -void ObjectFunctions::SetObjectRotation(double x, double y, double z) noexcept +extern "C" void ObjectFunctions::SetObjectRotation(double x, double y, double z) noexcept { tempObject.position.rot[0] = x; tempObject.position.rot[1] = y; tempObject.position.rot[2] = z; } -void ObjectFunctions::SetObjectActivatingPid(unsigned short pid) noexcept +extern "C" void ObjectFunctions::SetObjectActivatingPid(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, ); @@ -408,35 +408,35 @@ void ObjectFunctions::SetObjectActivatingPid(unsigned short pid) noexcept tempObject.activatingActor.isPlayer = true; } -void ObjectFunctions::SetObjectDoorState(int doorState) noexcept +extern "C" void ObjectFunctions::SetObjectDoorState(int doorState) noexcept { tempObject.doorState = doorState; } -void ObjectFunctions::SetObjectDoorTeleportState(bool teleportState) noexcept +extern "C" void ObjectFunctions::SetObjectDoorTeleportState(bool teleportState) noexcept { tempObject.teleportState = teleportState; } -void ObjectFunctions::SetObjectDoorDestinationCell(const char* cellDescription) noexcept +extern "C" void ObjectFunctions::SetObjectDoorDestinationCell(const char* cellDescription) noexcept { tempObject.destinationCell = Utils::getCellFromDescription(cellDescription); } -void ObjectFunctions::SetObjectDoorDestinationPosition(double x, double y, double z) noexcept +extern "C" void ObjectFunctions::SetObjectDoorDestinationPosition(double x, double y, double z) noexcept { tempObject.destinationPosition.pos[0] = x; tempObject.destinationPosition.pos[1] = y; tempObject.destinationPosition.pos[2] = z; } -void ObjectFunctions::SetObjectDoorDestinationRotation(double x, double z) noexcept +extern "C" void ObjectFunctions::SetObjectDoorDestinationRotation(double x, double z) noexcept { tempObject.destinationPosition.rot[0] = x; tempObject.destinationPosition.rot[2] = z; } -void ObjectFunctions::SetPlayerAsObject(unsigned short pid) noexcept +extern "C" void ObjectFunctions::SetPlayerAsObject(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, ); @@ -445,37 +445,37 @@ void ObjectFunctions::SetPlayerAsObject(unsigned short pid) noexcept tempObject.isPlayer = true; } -void ObjectFunctions::SetContainerItemRefId(const char* refId) noexcept +extern "C" void ObjectFunctions::SetContainerItemRefId(const char* refId) noexcept { tempContainerItem.refId = refId; } -void ObjectFunctions::SetContainerItemCount(int count) noexcept +extern "C" void ObjectFunctions::SetContainerItemCount(int count) noexcept { tempContainerItem.count = count; } -void ObjectFunctions::SetContainerItemCharge(int charge) noexcept +extern "C" void ObjectFunctions::SetContainerItemCharge(int charge) noexcept { tempContainerItem.charge = charge; } -void ObjectFunctions::SetContainerItemEnchantmentCharge(double enchantmentCharge) noexcept +extern "C" void ObjectFunctions::SetContainerItemEnchantmentCharge(double enchantmentCharge) noexcept { tempContainerItem.enchantmentCharge = enchantmentCharge; } -void ObjectFunctions::SetContainerItemSoul(const char* soul) noexcept +extern "C" void ObjectFunctions::SetContainerItemSoul(const char* soul) noexcept { tempContainerItem.soul = soul; } -void ObjectFunctions::SetContainerItemActionCountByIndex(unsigned int objectIndex, unsigned int itemIndex, int actionCount) noexcept +extern "C" void ObjectFunctions::SetContainerItemActionCountByIndex(unsigned int objectIndex, unsigned int itemIndex, int actionCount) noexcept { writeObjectList.baseObjects.at(objectIndex).containerItems.at(itemIndex).actionCount = actionCount; } -void ObjectFunctions::AddObject() noexcept +extern "C" void ObjectFunctions::AddObject() noexcept { tempObject.droppedByPlayer = false; writeObjectList.baseObjects.push_back(tempObject); @@ -483,14 +483,14 @@ void ObjectFunctions::AddObject() noexcept tempObject = emptyObject; } -void ObjectFunctions::AddContainerItem() noexcept +extern "C" void ObjectFunctions::AddContainerItem() noexcept { tempObject.containerItems.push_back(tempContainerItem); tempContainerItem = emptyContainerItem; } -void ObjectFunctions::SendObjectActivate(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept +extern "C" void ObjectFunctions::SendObjectActivate(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept { mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_OBJECT_ACTIVATE); packet->setObjectList(&writeObjectList); @@ -501,7 +501,7 @@ void ObjectFunctions::SendObjectActivate(bool sendToOtherPlayers, bool skipAttac packet->Send(true); } -void ObjectFunctions::SendObjectPlace(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept +extern "C" void ObjectFunctions::SendObjectPlace(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept { mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_OBJECT_PLACE); packet->setObjectList(&writeObjectList); @@ -512,7 +512,7 @@ void ObjectFunctions::SendObjectPlace(bool sendToOtherPlayers, bool skipAttached packet->Send(true); } -void ObjectFunctions::SendObjectSpawn(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept +extern "C" void ObjectFunctions::SendObjectSpawn(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept { mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_OBJECT_SPAWN); packet->setObjectList(&writeObjectList); @@ -523,7 +523,7 @@ void ObjectFunctions::SendObjectSpawn(bool sendToOtherPlayers, bool skipAttached packet->Send(true); } -void ObjectFunctions::SendObjectDelete(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept +extern "C" void ObjectFunctions::SendObjectDelete(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept { mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_OBJECT_DELETE); packet->setObjectList(&writeObjectList); @@ -534,7 +534,7 @@ void ObjectFunctions::SendObjectDelete(bool sendToOtherPlayers, bool skipAttache packet->Send(true); } -void ObjectFunctions::SendObjectLock(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept +extern "C" void ObjectFunctions::SendObjectLock(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept { mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_OBJECT_LOCK); packet->setObjectList(&writeObjectList); @@ -545,7 +545,7 @@ void ObjectFunctions::SendObjectLock(bool sendToOtherPlayers, bool skipAttachedP packet->Send(true); } -void ObjectFunctions::SendObjectTrap(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept +extern "C" void ObjectFunctions::SendObjectTrap(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept { mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_OBJECT_TRAP); packet->setObjectList(&writeObjectList); @@ -556,7 +556,7 @@ void ObjectFunctions::SendObjectTrap(bool sendToOtherPlayers, bool skipAttachedP packet->Send(true); } -void ObjectFunctions::SendObjectScale(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept +extern "C" void ObjectFunctions::SendObjectScale(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept { mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_OBJECT_SCALE); packet->setObjectList(&writeObjectList); @@ -567,7 +567,7 @@ void ObjectFunctions::SendObjectScale(bool sendToOtherPlayers, bool skipAttached packet->Send(true); } -void ObjectFunctions::SendObjectState(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept +extern "C" void ObjectFunctions::SendObjectState(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept { mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_OBJECT_STATE); packet->setObjectList(&writeObjectList); @@ -578,7 +578,7 @@ void ObjectFunctions::SendObjectState(bool sendToOtherPlayers, bool skipAttached packet->Send(true); } -void ObjectFunctions::SendDoorState(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept +extern "C" void ObjectFunctions::SendDoorState(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept { mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_DOOR_STATE); packet->setObjectList(&writeObjectList); @@ -589,7 +589,7 @@ void ObjectFunctions::SendDoorState(bool sendToOtherPlayers, bool skipAttachedPl packet->Send(true); } -void ObjectFunctions::SendDoorDestination(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept +extern "C" void ObjectFunctions::SendDoorDestination(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept { mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_DOOR_DESTINATION); packet->setObjectList(&writeObjectList); @@ -600,7 +600,7 @@ void ObjectFunctions::SendDoorDestination(bool sendToOtherPlayers, bool skipAtta packet->Send(true); } -void ObjectFunctions::SendContainer(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept +extern "C" void ObjectFunctions::SendContainer(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept { mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_CONTAINER); packet->setObjectList(&writeObjectList); @@ -611,7 +611,7 @@ void ObjectFunctions::SendContainer(bool sendToOtherPlayers, bool skipAttachedPl packet->Send(true); } -void ObjectFunctions::SendVideoPlay(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept +extern "C" void ObjectFunctions::SendVideoPlay(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept { mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_VIDEO_PLAY); packet->setObjectList(&writeObjectList); @@ -622,7 +622,7 @@ void ObjectFunctions::SendVideoPlay(bool sendToOtherPlayers, bool skipAttachedPl packet->Send(true); } -void ObjectFunctions::SendConsoleCommand(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept +extern "C" void ObjectFunctions::SendConsoleCommand(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept { mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_CONSOLE_COMMAND); packet->setObjectList(&writeObjectList); @@ -633,7 +633,7 @@ void ObjectFunctions::SendConsoleCommand(bool sendToOtherPlayers, bool skipAttac packet->Send(true); } - +extern "C" // All methods below are deprecated versions of methods from above void ObjectFunctions::ReadLastObjectList() noexcept @@ -641,73 +641,73 @@ void ObjectFunctions::ReadLastObjectList() noexcept ReadReceivedObjectList(); } -void ObjectFunctions::ReadLastEvent() noexcept +extern "C" void ObjectFunctions::ReadLastEvent() noexcept { ReadReceivedObjectList(); } -void ObjectFunctions::InitializeObjectList(unsigned short pid) noexcept +extern "C" void ObjectFunctions::InitializeObjectList(unsigned short pid) noexcept { ClearObjectList(); SetObjectListPid(pid); } -void ObjectFunctions::InitializeEvent(unsigned short pid) noexcept +extern "C" void ObjectFunctions::InitializeEvent(unsigned short pid) noexcept { InitializeObjectList(pid); } -void ObjectFunctions::CopyLastObjectListToStore() noexcept +extern "C" void ObjectFunctions::CopyLastObjectListToStore() noexcept { CopyReceivedObjectListToStore(); } -unsigned int ObjectFunctions::GetObjectChangesSize() noexcept +extern "C" unsigned int ObjectFunctions::GetObjectChangesSize() noexcept { return GetObjectListSize(); } -unsigned char ObjectFunctions::GetEventAction() noexcept +extern "C" unsigned char ObjectFunctions::GetEventAction() noexcept { return GetObjectListAction(); } -unsigned char ObjectFunctions::GetEventContainerSubAction() noexcept +extern "C" unsigned char ObjectFunctions::GetEventContainerSubAction() noexcept { return GetObjectListContainerSubAction(); } -unsigned int ObjectFunctions::GetObjectRefNumIndex(unsigned int index) noexcept +extern "C" unsigned int ObjectFunctions::GetObjectRefNumIndex(unsigned int index) noexcept { return GetObjectRefNum(index); } -unsigned int ObjectFunctions::GetObjectSummonerRefNumIndex(unsigned int index) noexcept +extern "C" unsigned int ObjectFunctions::GetObjectSummonerRefNumIndex(unsigned int index) noexcept { return GetObjectSummonerRefNum(index); } -void ObjectFunctions::SetEventCell(const char* cellDescription) noexcept +extern "C" void ObjectFunctions::SetEventCell(const char* cellDescription) noexcept { SetObjectListCell(cellDescription); } -void ObjectFunctions::SetEventAction(unsigned char action) noexcept +extern "C" void ObjectFunctions::SetEventAction(unsigned char action) noexcept { SetObjectListAction(action); } -void ObjectFunctions::SetEventConsoleCommand(const char* consoleCommand) noexcept +extern "C" void ObjectFunctions::SetEventConsoleCommand(const char* consoleCommand) noexcept { SetObjectListConsoleCommand(consoleCommand); } -void ObjectFunctions::SetObjectRefNumIndex(int refNum) noexcept +extern "C" void ObjectFunctions::SetObjectRefNumIndex(int refNum) noexcept { SetObjectRefNum(refNum); } -void ObjectFunctions::AddWorldObject() noexcept +extern "C" void ObjectFunctions::AddWorldObject() noexcept { AddObject(); } diff --git a/apps/openmw-mp/Script/Functions/Objects.hpp b/apps/openmw-mp/Script/Functions/Objects.hpp index bed37e903..a49e2f28b 100644 --- a/apps/openmw-mp/Script/Functions/Objects.hpp +++ b/apps/openmw-mp/Script/Functions/Objects.hpp @@ -136,23 +136,21 @@ {"SetObjectRefNumIndex", ObjectFunctions::SetObjectRefNumIndex},\ {"AddWorldObject", ObjectFunctions::AddWorldObject} -class ObjectFunctions +namespace ObjectFunctions { -public: - /** * \brief Use the last object list received by the server as the one being read. * * \return void */ - static void ReadReceivedObjectList() noexcept; + extern "C" void ReadReceivedObjectList() noexcept; /** * \brief Clear the data from the object list stored on the server. * * \return void */ - static void ClearObjectList() noexcept; + extern "C" void ClearObjectList() noexcept; /** * \brief Set the pid attached to the ObjectList. @@ -160,7 +158,7 @@ public: * \param pid The player ID to whom the object list should be attached. * \return void */ - static void SetObjectListPid(unsigned short pid) noexcept; + extern "C" void SetObjectListPid(unsigned short pid) noexcept; /** * \brief Take the contents of the read-only object list last received by the @@ -169,14 +167,14 @@ public: * * \return void */ - static void CopyReceivedObjectListToStore() noexcept; + extern "C" void CopyReceivedObjectListToStore() noexcept; /** * \brief Get the number of indexes in the read object list. * * \return The number of indexes. */ - static unsigned int GetObjectListSize() noexcept; + extern "C" unsigned int GetObjectListSize() noexcept; /** * \brief Get the origin of the read object list. @@ -185,7 +183,7 @@ public: * CLIENT_DIALOGUE, 3 for CLIENT_SCRIPT_LOCAL, 4 for CLIENT_SCRIPT_GLOBAL, * 5 for SERVER_SCRIPT). */ - static unsigned char GetObjectListOrigin() noexcept; + extern "C" unsigned char GetObjectListOrigin() noexcept; /** * \brief Get the client script that the read object list originated from. @@ -194,21 +192,21 @@ public: * * \return The ID of the client script. */ - static const char *GetObjectListClientScript() noexcept; + extern "C" 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). */ - static unsigned char GetObjectListAction() noexcept; + extern "C" 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). */ - static unsigned char GetObjectListContainerSubAction() noexcept; + extern "C" unsigned char GetObjectListContainerSubAction() noexcept; /** * \brief Check whether the object at a certain index in the read object list is a @@ -221,7 +219,7 @@ public: * \param index The index of the object. * \return Whether the object is a player. */ - static bool IsObjectPlayer(unsigned int index) noexcept; + extern "C" 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 +231,7 @@ public: * \param index The index of the object. * \return The player ID of the object. */ - static int GetObjectPid(unsigned int index) noexcept; + extern "C" int GetObjectPid(unsigned int index) noexcept; /** * \brief Get the refId of the object at a certain index in the read object list. @@ -241,7 +239,7 @@ public: * \param index The index of the object. * \return The refId. */ - static const char *GetObjectRefId(unsigned int index) noexcept; + extern "C" 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 +247,7 @@ public: * \param index The index of the object. * \return The refNum. */ - static unsigned int GetObjectRefNum(unsigned int index) noexcept; + extern "C" 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 +255,7 @@ public: * \param index The index of the object. * \return The mpNum. */ - static unsigned int GetObjectMpNum(unsigned int index) noexcept; + extern "C" 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 +263,7 @@ public: * \param index The index of the object. * \return The object count. */ - static int GetObjectCount(unsigned int index) noexcept; + extern "C" int GetObjectCount(unsigned int index) noexcept; /** * \brief Get the charge of the object at a certain index in the read object list. @@ -273,7 +271,7 @@ public: * \param index The index of the object. * \return The charge. */ - static int GetObjectCharge(unsigned int index) noexcept; + extern "C" 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 +279,7 @@ public: * \param index The index of the object. * \return The enchantment charge. */ - static double GetObjectEnchantmentCharge(unsigned int index) noexcept; + extern "C" double GetObjectEnchantmentCharge(unsigned int index) noexcept; /** * \brief Get the soul of the object at a certain index in the read object list. @@ -289,7 +287,7 @@ public: * \param index The index of the object. * \return The soul. */ - static const char *GetObjectSoul(unsigned int index) noexcept; + extern "C" 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 +297,7 @@ public: * \param index The index of the object. * \return The gold value. */ - static int GetObjectGoldValue(unsigned int index) noexcept; + extern "C" 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 +305,7 @@ public: * \param index The index of the object. * \return The object scale. */ - static double GetObjectScale(unsigned int index) noexcept; + extern "C" 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 +313,7 @@ public: * \param index The index of the object. * \return The object state. */ - static bool GetObjectState(unsigned int index) noexcept; + extern "C" 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 +321,7 @@ public: * \param index The index of the object. * \return The door state. */ - static int GetObjectDoorState(unsigned int index) noexcept; + extern "C" 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 +329,7 @@ public: * \param index The index of the object. * \return The lock level. */ - static int GetObjectLockLevel(unsigned int index) noexcept; + extern "C" int GetObjectLockLevel(unsigned int index) noexcept; /** * \brief Check whether the object at a certain index in the read object list has been @@ -340,7 +338,7 @@ public: * \param index The index of the object. * \return Whether the object has been activated by a player. */ - static bool DoesObjectHavePlayerActivating(unsigned int index) noexcept; + extern "C" 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 +347,7 @@ public: * \param index The index of the object. * \return The player ID of the activating player. */ - static int GetObjectActivatingPid(unsigned int index) noexcept; + extern "C" 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 +356,7 @@ public: * \param index The index of the object. * \return The refId of the activating actor. */ - static const char *GetObjectActivatingRefId(unsigned int index) noexcept; + extern "C" 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 +365,7 @@ public: * \param index The index of the object. * \return The refNum of the activating actor. */ - static unsigned int GetObjectActivatingRefNum(unsigned int index) noexcept; + extern "C" 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 +374,7 @@ public: * \param index The index of the object. * \return The mpNum of the activating actor. */ - static unsigned int GetObjectActivatingMpNum(unsigned int index) noexcept; + extern "C" 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 +383,7 @@ public: * \param index The index of the object. * \return The name of the activating actor. */ - static const char *GetObjectActivatingName(unsigned int index) noexcept; + extern "C" 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 +393,7 @@ public: * * \return The summon state. */ - static bool GetObjectSummonState(unsigned int index) noexcept; + extern "C" 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 +403,7 @@ public: * \param index The index of the object. * \return The summon duration. */ - static double GetObjectSummonDuration(unsigned int index) noexcept; + extern "C" 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 +414,7 @@ public: * \param index The index of the object. * \return Whether a player is the summoner of the object. */ - static bool DoesObjectHavePlayerSummoner(unsigned int index) noexcept; + extern "C" 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 +423,7 @@ public: * \param index The index of the object. * \return The player ID of the summoner. */ - static int GetObjectSummonerPid(unsigned int index) noexcept; + extern "C" 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 +432,7 @@ public: * \param index The index of the object. * \return The refId of the summoner. */ - static const char *GetObjectSummonerRefId(unsigned int index) noexcept; + extern "C" 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 +441,7 @@ public: * \param index The index of the object. * \return The refNum of the summoner. */ - static unsigned int GetObjectSummonerRefNum(unsigned int index) noexcept; + extern "C" 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 +449,7 @@ public: * \param index The index of the object. * \return The mpNum of the summoner. */ - static unsigned int GetObjectSummonerMpNum(unsigned int index) noexcept; + extern "C" 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 +457,7 @@ public: * \param index The index of the object. * \return The X position. */ - static double GetObjectPosX(unsigned int index) noexcept; + extern "C" 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 +465,7 @@ public: * \param index The index of the object. * \return The Y position. */ - static double GetObjectPosY(unsigned int index) noexcept; + extern "C" double GetObjectPosY(unsigned int index) noexcept; /** * \brief Get the Z position at a certain index in the read object list. @@ -475,7 +473,7 @@ public: * \param index The index of the object. * \return The Z position. */ - static double GetObjectPosZ(unsigned int index) noexcept; + extern "C" 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 +481,7 @@ public: * \param index The index of the object. * \return The X rotation. */ - static double GetObjectRotX(unsigned int index) noexcept; + extern "C" 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 +489,7 @@ public: * \param index The index of the object. * \return The Y rotation. */ - static double GetObjectRotY(unsigned int index) noexcept; + extern "C" 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 +497,14 @@ public: * \param index The index of the object. * \return The Z rotation. */ - static double GetObjectRotZ(unsigned int index) noexcept; + extern "C" 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. */ - static const char *GetVideoFilename(unsigned int index) noexcept; + extern "C" 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 +513,7 @@ public: * \param index The index of the object. * \return The number of container item indexes. */ - static unsigned int GetContainerChangesSize(unsigned int objectIndex) noexcept; + extern "C" 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 +523,7 @@ public: * \param itemIndex The index of the container item. * \return The refId. */ - static const char *GetContainerItemRefId(unsigned int objectIndex, unsigned int itemIndex) noexcept; + extern "C" 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 +533,7 @@ public: * \param itemIndex The index of the container item. * \return The item count. */ - static int GetContainerItemCount(unsigned int objectIndex, unsigned int itemIndex) noexcept; + extern "C" 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 +543,7 @@ public: * \param itemIndex The index of the container item. * \return The charge. */ - static int GetContainerItemCharge(unsigned int objectIndex, unsigned int itemIndex) noexcept; + extern "C" 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 +553,7 @@ public: * \param itemIndex The index of the container item. * \return The enchantment charge. */ - static double GetContainerItemEnchantmentCharge(unsigned int objectIndex, unsigned int itemIndex) noexcept; + extern "C" 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 +563,7 @@ public: * \param itemIndex The index of the container item. * \return The soul. */ - static const char *GetContainerItemSoul(unsigned int objectIndex, unsigned int itemIndex) noexcept; + extern "C" 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 +573,7 @@ public: * \param itemIndex The index of the container item. * \return The action count. */ - static int GetContainerItemActionCount(unsigned int objectIndex, unsigned int itemIndex) noexcept; + extern "C" 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 +584,7 @@ public: * \param index The index of the object. * \return Whether the object has a container. */ - static bool DoesObjectHaveContainer(unsigned int index) noexcept; + extern "C" bool DoesObjectHaveContainer(unsigned int index) noexcept; /** * \brief Set the cell of the temporary object list stored on the server. @@ -597,7 +595,7 @@ public: * \param cellDescription The description of the cell. * \return void */ - static void SetObjectListCell(const char* cellDescription) noexcept; + extern "C" void SetObjectListCell(const char* cellDescription) noexcept; /** * \brief Set the action type of the temporary object list stored on the server. @@ -605,7 +603,7 @@ public: * \param action The action type (0 for SET, 1 for ADD, 2 for REMOVE, 3 for REQUEST). * \return void */ - static void SetObjectListAction(unsigned char action) noexcept; + extern "C" void SetObjectListAction(unsigned char action) noexcept; /** * \brief Set the console command of the temporary object list stored on the server. @@ -616,7 +614,7 @@ public: * \param consoleCommand The console command. * \return void */ - static void SetObjectListConsoleCommand(const char* consoleCommand) noexcept; + extern "C" void SetObjectListConsoleCommand(const char* consoleCommand) noexcept; /** * \brief Set the refId of the temporary object stored on the server. @@ -624,7 +622,7 @@ public: * \param refId The refId. * \return void */ - static void SetObjectRefId(const char* refId) noexcept; + extern "C" void SetObjectRefId(const char* refId) noexcept; /** * \brief Set the refNum of the temporary object stored on the server. @@ -638,7 +636,7 @@ public: * \param refNum The refNum. * \return void */ - static void SetObjectRefNum(int refNum) noexcept; + extern "C" void SetObjectRefNum(int refNum) noexcept; /** * \brief Set the mpNum of the temporary object stored on the server. @@ -653,7 +651,7 @@ public: * \param mpNum The mpNum. * \return void */ - static void SetObjectMpNum(int mpNum) noexcept; + extern "C" void SetObjectMpNum(int mpNum) noexcept; /** * \brief Set the object count of the temporary object stored on the server. @@ -663,7 +661,7 @@ public: * \param count The object count. * \return void */ - static void SetObjectCount(int count) noexcept; + extern "C" void SetObjectCount(int count) noexcept; /** * \brief Set the charge of the temporary object stored on the server. @@ -673,7 +671,7 @@ public: * \param charge The charge. * \return void */ - static void SetObjectCharge(int charge) noexcept; + extern "C" void SetObjectCharge(int charge) noexcept; /** * \brief Set the enchantment charge of the temporary object stored on the server. @@ -683,7 +681,7 @@ public: * \param charge The enchantment charge. * \return void */ - static void SetObjectEnchantmentCharge(double enchantmentCharge) noexcept; + extern "C" void SetObjectEnchantmentCharge(double enchantmentCharge) noexcept; /** * \brief Set the soul of the temporary object stored on the server. @@ -691,7 +689,7 @@ public: * \param refId The soul. * \return void */ - static void SetObjectSoul(const char* soul) noexcept; + extern "C" void SetObjectSoul(const char* soul) noexcept; /** * \brief Set the gold value of the temporary object stored on the server. @@ -701,7 +699,7 @@ public: * \param goldValue The gold value. * \return void */ - static void SetObjectGoldValue(int goldValue) noexcept; + extern "C" void SetObjectGoldValue(int goldValue) noexcept; /** * \brief Set the scale of the temporary object stored on the server. @@ -711,7 +709,7 @@ public: * \param scale The scale. * \return void */ - static void SetObjectScale(double scale) noexcept; + extern "C" void SetObjectScale(double scale) noexcept; /** * \brief Set the object state of the temporary object stored on the server. @@ -721,7 +719,7 @@ public: * \param objectState The object state. * \return void */ - static void SetObjectState(bool objectState) noexcept; + extern "C" void SetObjectState(bool objectState) noexcept; /** * \brief Set the lock level of the temporary object stored on the server. @@ -729,7 +727,7 @@ public: * \param lockLevel The lock level. * \return void */ - static void SetObjectLockLevel(int lockLevel) noexcept; + extern "C" void SetObjectLockLevel(int lockLevel) noexcept; /** * \brief Set the summon duration of the temporary object stored on the server. @@ -737,7 +735,7 @@ public: * \param summonDuration The summon duration. * \return void */ - static void SetObjectSummonDuration(float summonDuration) noexcept; + extern "C" void SetObjectSummonDuration(float summonDuration) noexcept; /** * \brief Set the disarm state of the temporary object stored on the server. @@ -745,7 +743,7 @@ public: * \param disarmState The disarmState. * \return void */ - static void SetObjectDisarmState(bool disarmState) noexcept; + extern "C" void SetObjectDisarmState(bool disarmState) noexcept; /** * \brief Set the summon state of the temporary object stored on the server. @@ -756,7 +754,7 @@ public: * \param summonState The summon state. * \return void */ - static void SetObjectSummonState(bool summonState) noexcept; + extern "C" void SetObjectSummonState(bool summonState) noexcept; /** * \brief Set the position of the temporary object stored on the server. @@ -766,7 +764,7 @@ public: * \param z The Z position. * \return void */ - static void SetObjectPosition(double x, double y, double z) noexcept; + extern "C" void SetObjectPosition(double x, double y, double z) noexcept; /** * \brief Set the rotation of the temporary object stored on the server. @@ -776,7 +774,7 @@ public: * \param z The Z rotation. * \return void */ - static void SetObjectRotation(double x, double y, double z) noexcept; + extern "C" 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 +783,7 @@ public: * \param pid The pid of the player. * \return void */ - static void SetObjectActivatingPid(unsigned short pid) noexcept; + extern "C" void SetObjectActivatingPid(unsigned short pid) noexcept; /** * \brief Set the door state of the temporary object stored on the server. @@ -795,7 +793,7 @@ public: * \param doorState The door state. * \return void */ - static void SetObjectDoorState(int doorState) noexcept; + extern "C" void SetObjectDoorState(int doorState) noexcept; /** * \brief Set the teleport state of the temporary object stored on the server. @@ -806,7 +804,7 @@ public: * \param teleportState The teleport state. * \return void */ - static void SetObjectDoorTeleportState(bool teleportState) noexcept; + extern "C" void SetObjectDoorTeleportState(bool teleportState) noexcept; /** * \brief Set the door destination cell of the temporary object stored on the server. @@ -817,7 +815,7 @@ public: * \param cellDescription The description of the cell. * \return void */ - static void SetObjectDoorDestinationCell(const char* cellDescription) noexcept; + extern "C" void SetObjectDoorDestinationCell(const char* cellDescription) noexcept; /** * \brief Set the door destination position of the temporary object stored on the server. @@ -827,7 +825,7 @@ public: * \param z The Z position. * \return void */ - static void SetObjectDoorDestinationPosition(double x, double y, double z) noexcept; + extern "C" 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 +837,7 @@ public: * \param z The Z rotation. * \return void */ - static void SetObjectDoorDestinationRotation(double x, double z) noexcept; + extern "C" void SetObjectDoorDestinationRotation(double x, double z) noexcept; /** * \brief Set a player as the object in the temporary object stored on the server. @@ -848,7 +846,7 @@ public: * \param pid The pid of the player. * \return void */ - static void SetPlayerAsObject(unsigned short pid) noexcept; + extern "C" void SetPlayerAsObject(unsigned short pid) noexcept; /** * \brief Set the refId of the temporary container item stored on the server. @@ -856,7 +854,7 @@ public: * \param refId The refId. * \return void */ - static void SetContainerItemRefId(const char* refId) noexcept; + extern "C" void SetContainerItemRefId(const char* refId) noexcept; /** * \brief Set the item count of the temporary container item stored on the server. @@ -864,7 +862,7 @@ public: * \param count The item count. * \return void */ - static void SetContainerItemCount(int count) noexcept; + extern "C" void SetContainerItemCount(int count) noexcept; /** * \brief Set the charge of the temporary container item stored on the server. @@ -872,7 +870,7 @@ public: * \param charge The charge. * \return void */ - static void SetContainerItemCharge(int charge) noexcept; + extern "C" void SetContainerItemCharge(int charge) noexcept; /** * \brief Set the enchantment charge of the temporary container item stored on the server. @@ -880,7 +878,7 @@ public: * \param charge The enchantment charge. * \return void */ - static void SetContainerItemEnchantmentCharge(double enchantmentCharge) noexcept; + extern "C" void SetContainerItemEnchantmentCharge(double enchantmentCharge) noexcept; /** * \brief Set the soul of the temporary container item stored on the server. @@ -888,7 +886,7 @@ public: * \param refId The soul. * \return void */ - static void SetContainerItemSoul(const char* soul) noexcept; + extern "C" void SetContainerItemSoul(const char* soul) noexcept; /** * \brief Set the action count of the container item at a certain itemIndex in the container @@ -903,7 +901,7 @@ public: * \param actionCount The action count. * \return void */ - static void SetContainerItemActionCountByIndex(unsigned int objectIndex, unsigned int itemIndex, int actionCount) noexcept; + extern "C" 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 +912,7 @@ public: * * \return void */ - static void AddObject() noexcept; + extern "C" void AddObject() noexcept; /** * \brief Add a copy of the server's temporary container item to the container changes of the @@ -925,7 +923,7 @@ public: * * \return void */ - static void AddContainerItem() noexcept; + extern "C" void AddContainerItem() noexcept; /** * \brief Send an ObjectActivate packet. @@ -936,7 +934,7 @@ public: * to the packet (false by default). * \return void */ - static void SendObjectActivate(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept; + extern "C" void SendObjectActivate(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept; /** * \brief Send an ObjectPlace packet. @@ -947,7 +945,7 @@ public: * to the packet (false by default). * \return void */ - static void SendObjectPlace(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept; + extern "C" void SendObjectPlace(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept; /** * \brief Send an ObjectSpawn packet. @@ -958,7 +956,7 @@ public: * to the packet (false by default). * \return void */ - static void SendObjectSpawn(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept; + extern "C" void SendObjectSpawn(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept; /** * \brief Send an ObjectDelete packet. @@ -968,7 +966,7 @@ public: * * \return void */ - static void SendObjectDelete(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept; + extern "C" void SendObjectDelete(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept; /** * \brief Send an ObjectLock packet. @@ -979,7 +977,7 @@ public: * to the packet (false by default). * \return void */ - static void SendObjectLock(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept; + extern "C" void SendObjectLock(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept; /** * \brief Send an ObjectTrap packet. @@ -989,7 +987,7 @@ public: * * \return void */ - static void SendObjectTrap(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept; + extern "C" void SendObjectTrap(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept; /** * \brief Send an ObjectScale packet. @@ -1000,7 +998,7 @@ public: * to the packet (false by default). * \return void */ - static void SendObjectScale(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept; + extern "C" void SendObjectScale(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept; /** * \brief Send an ObjectState packet. @@ -1011,7 +1009,7 @@ public: * to the packet (false by default). * \return void */ - static void SendObjectState(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept; + extern "C" void SendObjectState(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept; /** * \brief Send a DoorState packet. @@ -1022,7 +1020,7 @@ public: * to the packet (false by default). * \return void */ - static void SendDoorState(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept; + extern "C" void SendDoorState(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept; /** * \brief Send a DoorDestination packet. @@ -1033,7 +1031,7 @@ public: * to the packet (false by default). * \return void */ - static void SendDoorDestination(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept; + extern "C" void SendDoorDestination(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept; /** * \brief Send a Container packet. @@ -1044,7 +1042,7 @@ public: * to the packet (false by default). * \return void */ - static void SendContainer(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept; + extern "C" void SendContainer(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept; /** * \brief Send a VideoPlay packet. @@ -1055,7 +1053,7 @@ public: * to the packet (false by default). * \return void */ - static void SendVideoPlay(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept; + extern "C" void SendVideoPlay(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept; /** * \brief Send a ConsoleCommand packet. @@ -1066,28 +1064,27 @@ public: * to the packet (false by default). * \return void */ - static void SendConsoleCommand(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept; + extern "C" void SendConsoleCommand(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept; // All methods below are deprecated versions of methods from above - static void ReadLastObjectList() noexcept; - static void ReadLastEvent() noexcept; - static void InitializeObjectList(unsigned short pid) noexcept; - static void InitializeEvent(unsigned short pid) noexcept; - static void CopyLastObjectListToStore() noexcept; - static unsigned int GetObjectChangesSize() noexcept; - static unsigned char GetEventAction() noexcept; - static unsigned char GetEventContainerSubAction() noexcept; - static unsigned int GetObjectRefNumIndex(unsigned int index) noexcept; - static unsigned int GetObjectSummonerRefNumIndex(unsigned int index) noexcept; - static void SetEventCell(const char* cellDescription) noexcept; - static void SetEventAction(unsigned char action) noexcept; - static void SetEventConsoleCommand(const char* consoleCommand) noexcept; - static void SetObjectRefNumIndex(int refNum) noexcept; - static void AddWorldObject() noexcept; - -}; + extern "C" void ReadLastObjectList() noexcept; + extern "C" void ReadLastEvent() noexcept; + extern "C" void InitializeObjectList(unsigned short pid) noexcept; + extern "C" void InitializeEvent(unsigned short pid) noexcept; + extern "C" void CopyLastObjectListToStore() noexcept; + extern "C" unsigned int GetObjectChangesSize() noexcept; + extern "C" unsigned char GetEventAction() noexcept; + extern "C" unsigned char GetEventContainerSubAction() noexcept; + extern "C" unsigned int GetObjectRefNumIndex(unsigned int index) noexcept; + extern "C" unsigned int GetObjectSummonerRefNumIndex(unsigned int index) noexcept; + extern "C" void SetEventCell(const char* cellDescription) noexcept; + extern "C" void SetEventAction(unsigned char action) noexcept; + extern "C" void SetEventConsoleCommand(const char* consoleCommand) noexcept; + extern "C" void SetObjectRefNumIndex(int refNum) noexcept; + extern "C" void AddWorldObject() noexcept; +} #endif //OPENMW_OBJECTAPI_HPP diff --git a/apps/openmw-mp/Script/Functions/Positions.cpp b/apps/openmw-mp/Script/Functions/Positions.cpp index 291f1c618..fb90120b9 100644 --- a/apps/openmw-mp/Script/Functions/Positions.cpp +++ b/apps/openmw-mp/Script/Functions/Positions.cpp @@ -15,7 +15,7 @@ double PositionFunctions::GetPosX(unsigned short pid) noexcept return player->position.pos[0]; } -double PositionFunctions::GetPosY(unsigned short pid) noexcept +extern "C" double PositionFunctions::GetPosY(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0.0f); @@ -23,7 +23,7 @@ double PositionFunctions::GetPosY(unsigned short pid) noexcept return player->position.pos[1]; } -double PositionFunctions::GetPosZ(unsigned short pid) noexcept +extern "C" double PositionFunctions::GetPosZ(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0.0f); @@ -31,7 +31,7 @@ double PositionFunctions::GetPosZ(unsigned short pid) noexcept return player->position.pos[2]; } -double PositionFunctions::GetPreviousCellPosX(unsigned short pid) noexcept +extern "C" double PositionFunctions::GetPreviousCellPosX(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0.0f); @@ -39,7 +39,7 @@ double PositionFunctions::GetPreviousCellPosX(unsigned short pid) noexcept return player->previousCellPosition.pos[0]; } -double PositionFunctions::GetPreviousCellPosY(unsigned short pid) noexcept +extern "C" double PositionFunctions::GetPreviousCellPosY(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0.0f); @@ -47,7 +47,7 @@ double PositionFunctions::GetPreviousCellPosY(unsigned short pid) noexcept return player->previousCellPosition.pos[1]; } -double PositionFunctions::GetPreviousCellPosZ(unsigned short pid) noexcept +extern "C" double PositionFunctions::GetPreviousCellPosZ(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0.0f); @@ -63,7 +63,7 @@ double PositionFunctions::GetRotX(unsigned short pid) noexcept return player->position.rot[0]; } -double PositionFunctions::GetRotZ(unsigned short pid) noexcept +extern "C" double PositionFunctions::GetRotZ(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, 0.0f); @@ -71,7 +71,7 @@ double PositionFunctions::GetRotZ(unsigned short pid) noexcept return player->position.rot[2]; } -void PositionFunctions::SetPos(unsigned short pid, double x, double y, double z) noexcept +extern "C" void PositionFunctions::SetPos(unsigned short pid, double x, double y, double z) noexcept { Player *player; GET_PLAYER(pid, player,); @@ -81,7 +81,7 @@ void PositionFunctions::SetPos(unsigned short pid, double x, double y, double z) player->position.pos[2] = z; } -void PositionFunctions::SetRot(unsigned short pid, double x, double z) noexcept +extern "C" void PositionFunctions::SetRot(unsigned short pid, double x, double z) noexcept { Player *player; GET_PLAYER(pid, player, ); @@ -90,7 +90,7 @@ void PositionFunctions::SetRot(unsigned short pid, double x, double z) noexcept player->position.rot[2] = z; } -void PositionFunctions::SetMomentum(unsigned short pid, double x, double y, double z) noexcept +extern "C" void PositionFunctions::SetMomentum(unsigned short pid, double x, double y, double z) noexcept { Player *player; GET_PLAYER(pid, player, ); @@ -100,7 +100,7 @@ void PositionFunctions::SetMomentum(unsigned short pid, double x, double y, doub player->momentum.pos[2] = z; } -void PositionFunctions::SendPos(unsigned short pid) noexcept +extern "C" void PositionFunctions::SendPos(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, ); @@ -111,7 +111,7 @@ void PositionFunctions::SendPos(unsigned short pid) noexcept packet->Send(false); } -void PositionFunctions::SendMomentum(unsigned short pid) noexcept +extern "C" void PositionFunctions::SendMomentum(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, ); diff --git a/apps/openmw-mp/Script/Functions/Positions.hpp b/apps/openmw-mp/Script/Functions/Positions.hpp index 283fe2505..f637a3ad0 100644 --- a/apps/openmw-mp/Script/Functions/Positions.hpp +++ b/apps/openmw-mp/Script/Functions/Positions.hpp @@ -23,17 +23,15 @@ {"SendMomentum", PositionFunctions::SendMomentum} -class PositionFunctions +namespace PositionFunctions { -public: - /** * \brief Get the X position of a player. * * \param pid The player ID. * \return The X position. */ - static double GetPosX(unsigned short pid) noexcept; + extern "C" double GetPosX(unsigned short pid) noexcept; /** * \brief Get the Y position of a player. @@ -41,7 +39,7 @@ public: * \param pid The player ID. * \return The Y position. */ - static double GetPosY(unsigned short pid) noexcept; + extern "C" double GetPosY(unsigned short pid) noexcept; /** * \brief Get the Z position of a player. @@ -49,7 +47,7 @@ public: * \param pid The player ID. * \return The Z position. */ - static double GetPosZ(unsigned short pid) noexcept; + extern "C" double GetPosZ(unsigned short pid) noexcept; /** * \brief Get the X position of a player from before their latest cell change. @@ -57,7 +55,7 @@ public: * \param pid The player ID. * \return The X position. */ - static double GetPreviousCellPosX(unsigned short pid) noexcept; + extern "C" double GetPreviousCellPosX(unsigned short pid) noexcept; /** * \brief Get the Y position of a player from before their latest cell change. @@ -65,7 +63,7 @@ public: * \param pid The player ID. * \return The Y position. */ - static double GetPreviousCellPosY(unsigned short pid) noexcept; + extern "C" double GetPreviousCellPosY(unsigned short pid) noexcept; /** * \brief Get the Z position of a player from before their latest cell change. @@ -73,7 +71,7 @@ public: * \param pid The player ID. * \return The Z position. */ - static double GetPreviousCellPosZ(unsigned short pid) noexcept; + extern "C" double GetPreviousCellPosZ(unsigned short pid) noexcept; /** * \brief Get the X rotation of a player. @@ -81,7 +79,7 @@ public: * \param pid The player ID. * \return The X rotation. */ - static double GetRotX(unsigned short pid) noexcept; + extern "C" double GetRotX(unsigned short pid) noexcept; /** * \brief Get the Z rotation of a player. @@ -89,7 +87,7 @@ public: * \param pid The player ID. * \return The Z rotation. */ - static double GetRotZ(unsigned short pid) noexcept; + extern "C" double GetRotZ(unsigned short pid) noexcept; /** * \brief Set the position of a player. @@ -103,7 +101,7 @@ public: * \param z The Z position. * \return void */ - static void SetPos(unsigned short pid, double x, double y, double z) noexcept; + extern "C" void SetPos(unsigned short pid, double x, double y, double z) noexcept; /** * \brief Set the rotation of a player. @@ -118,7 +116,7 @@ public: * \param z The Z position. * \return void */ - static void SetRot(unsigned short pid, double x, double z) noexcept; + extern "C" void SetRot(unsigned short pid, double x, double z) noexcept; /** * \brief Set the momentum of a player. @@ -132,7 +130,7 @@ public: * \param z The Z momentum. * \return void */ - static void SetMomentum(unsigned short pid, double x, double y, double z) noexcept; + extern "C" void SetMomentum(unsigned short pid, double x, double y, double z) noexcept; /** * \brief Send a PlayerPosition packet about a player. @@ -142,7 +140,7 @@ public: * \param pid The player ID. * \return void */ - static void SendPos(unsigned short pid) noexcept; + extern "C" void SendPos(unsigned short pid) noexcept; /** * \brief Send a PlayerMomentum packet about a player. @@ -152,7 +150,7 @@ public: * \param pid The player ID. * \return void */ - static void SendMomentum(unsigned short pid) noexcept; -}; + extern "C" void SendMomentum(unsigned short pid) noexcept; +} #endif //OPENMW_POSITIONAPI_HPP diff --git a/apps/openmw-mp/Script/Functions/Public.cpp b/apps/openmw-mp/Script/Functions/Public.cpp new file mode 100644 index 000000000..235d3f864 --- /dev/null +++ b/apps/openmw-mp/Script/Functions/Public.cpp @@ -0,0 +1,29 @@ +// +// Created by koncord on 09.12.18. +// + +#include "Public.hpp" + +#include