Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checking abi #710

Closed
wants to merge 11 commits into from
22 changes: 16 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,24 @@

| Path | Content |
| ---- | ------- |
| `SDK/` | Core SDK headers (stable between versions) |
| `SDK/Server/Components/*/` | Components/plug-in SDK headers (stable between versions) |
| `SDK/include` | Core SDK headers (stable between versions) |
| `SDK/include/Server/Components/*/` | Components/plug-in SDK headers (stable between versions) |
| `Shared/NetCode/` | Netcode headers (RPC and packet read/write structures, NOT stable between versions) |
| `lib/` | Various submodules and CMake helpers for Conan |
| `Shared/Network/` | Network utility headers (NOT stable between versions) |
| `lib/` | Various submodules and third-party libraries |
| `Server/Source/` | Core server implementation (NOT stable between versions, do NOT use headers outside the Source folder) |
| `Server/Components/*/` | Components/plug-in implementation (NOT stable between versions, do NOT use headers outside the component's folder) |

## Concepts

| Name | Description |
| ---- | ------- |
| Entity | Something that can appear in the 3D world of the game |
| Pool | Container of something with limited amount of IDs |
| Component | Something that's conceptually different enough it can be separated into its own module |
| Extensible | Something to which extensions can be added to preserve ABI compatibility |
| Extension | Something which adds additional functionality to an extensible and preserves ABI compatibility |

## Tools

* [CMake 3.19+](https://cmake.org/)
Expand All @@ -22,7 +33,7 @@

* [Visual Studio 2019+](https://www.visualstudio.com/)

Visual Studio needs the `Desktop development with C++` workload with the `MSVC v142`, `Windows 10 SDK` and `C++ Clang tools for Windows` components.
Visual Studio needs the `Desktop development with C++` workload with the `C++ Clang tools for Windows` component.

## Sources

Expand All @@ -42,6 +53,5 @@ cd open.mp
mkdir build
cd build
cmake .. -A Win32 -T ClangCL
cmake --build . --config RelWithDebInfo
```

Open Visual Studio and build the solution.
2 changes: 2 additions & 0 deletions SDK/include/Server/Components/Pawn/pawn.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <Server/Components/Objects/objects.hpp>
#include <Server/Components/Pawn/pawn.hpp>
#include <Server/Components/Pickups/pickups.hpp>
#include <Server/Components/Recordings/recordings.hpp>
#include <Server/Components/TextDraws/textdraws.hpp>
#include <Server/Components/TextLabels/textlabels.hpp>
#include <Server/Components/Timers/timers.hpp>
Expand Down Expand Up @@ -57,6 +58,7 @@ struct PawnLookup
IMenusComponent* menus = nullptr;
IObjectsComponent* objects = nullptr;
IPickupsComponent* pickups = nullptr;
IRecordingsComponent* recordings = nullptr;
ITextDrawsComponent* textdraws = nullptr;
ITextLabelsComponent* textlabels = nullptr;
ITimersComponent* timers = nullptr;
Expand Down
1 change: 1 addition & 0 deletions SDK/include/Server/Components/Pawn/pawn_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ void setAmxLookups()
lookups_.menus = components_->queryComponent<IMenusComponent>();
lookups_.objects = components_->queryComponent<IObjectsComponent>();
lookups_.pickups = components_->queryComponent<IPickupsComponent>();
lookups_.recordings = components_->queryComponent<IRecordingsComponent>();
lookups_.textdraws = components_->queryComponent<ITextDrawsComponent>();
lookups_.textlabels = components_->queryComponent<ITextLabelsComponent>();
lookups_.timers = components_->queryComponent<ITimersComponent>();
Expand Down
29 changes: 29 additions & 0 deletions SDK/include/Server/Components/Recordings/recordings.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#pragma once

#include <component.hpp>

/// The type of the recording: https://open.mp/docs/scripting/resources/recordtypes
enum PlayerRecordingType
{
PlayerRecordingType_None,
PlayerRecordingType_Driver,
PlayerRecordingType_OnFoot
};

static const UID RecordingData_UID = UID(0x34DB532857286482);
struct IPlayerRecordingData : public IExtension
{
PROVIDE_EXT_UID(RecordingData_UID);

/// Start recording the player's data to a file
virtual void start(PlayerRecordingType type, StringView file) = 0;

/// Stop recording the player's data to a file
virtual void stop() = 0;
};

static const UID RecordingsComponent_UID = UID(0x871144D399F5F613);
struct IRecordingsComponent : public IComponent
{
PROVIDE_UID(RecordingsComponent_UID);
};
2 changes: 1 addition & 1 deletion SDK/include/gtaquat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// WARNING: Do not use glm::quat or glm::vec4 for quaternions instead of this class!
// The game uses a weird implementation of Euler angles and/or quaternions than almost everything you'd find.
// Special thanks to IllidanS4 and his i_quat include for the formulas used in this class.
// See this issue for more information: https://github.com/openmultiplayer/open.mp/issues/143
// See this issue for more information: https://github.com/openmultiplayer/old.open.mp/issues/143
// See this link for an explanation of the formulas: https://math.stackexchange.com/questions/1477926/quaternion-to-euler-with-some-properties

class GTAQuat
Expand Down
1 change: 1 addition & 0 deletions Server/Components/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ add_subdirectory(GangZones)
add_subdirectory(Menus)
add_subdirectory(Objects)
add_subdirectory(Pickups)
add_subdirectory(Recordings)
add_subdirectory(TextDraws)
add_subdirectory(TextLabels)
add_subdirectory(Timers)
Expand Down
9 changes: 8 additions & 1 deletion Server/Components/CustomModels/models.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ class CustomModelsComponent final : public ICustomModelsComponent, public Player
FlatHashMap<uint32_t, std::pair<ModelDownloadType, ModelInfo*>> checksums;

bool enabled = true;
uint16_t modelsPort = 7777;
String modelsPath = "models";
String cdn = "";
bool usingCdn = false;
Expand Down Expand Up @@ -412,6 +413,7 @@ class CustomModelsComponent final : public ICustomModelsComponent, public Player
config.setString("artwork.cdn", cdn);
config.setString("artwork.models_path", modelsPath);
config.setInt("network.http_threads", httpThreads);
config.setInt("artwork.port", modelsPort);
}
else
{
Expand All @@ -433,6 +435,11 @@ class CustomModelsComponent final : public ICustomModelsComponent, public Player
{
config.setInt("network.http_threads", httpThreads);
}
// Add the web server port to support some old TCP plugin like Incognito's audio plugin
if (config.getType("artwork.port") == ConfigOptionType_None)
{
config.setInt("artwork.port", modelsPort);
}
}
}

Expand Down Expand Up @@ -514,7 +521,7 @@ class CustomModelsComponent final : public ICustomModelsComponent, public Player
return;
}

webServer = new WebServer(core, modelsPath, core->getConfig().getString("network.bind"), *core->getConfig().getInt("network.port"), core->getConfig().getString("network.public_addr"), httpThreads);
webServer = new WebServer(core, modelsPath, core->getConfig().getString("network.bind"), *core->getConfig().getInt("artwork.port"), core->getConfig().getString("network.public_addr"), httpThreads);

if (webServer->is_running())
{
Expand Down
1 change: 1 addition & 0 deletions Server/Components/Pawn/Manager/Manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <Server/Components/Objects/objects.hpp>
#include <Server/Components/Pawn/pawn.hpp>
#include <Server/Components/Pickups/pickups.hpp>
#include <Server/Components/Recordings/recordings.hpp>
#include <Server/Components/TextDraws/textdraws.hpp>
#include <Server/Components/TextLabels/textlabels.hpp>
#include <Server/Components/Timers/timers.hpp>
Expand Down
10 changes: 0 additions & 10 deletions Server/Components/Pawn/Scripting/Player/Natives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -925,16 +925,6 @@ SCRIPT_API(SpawnPlayer, bool(IPlayer& player))
return true;
}

SCRIPT_API(StartRecordingPlayerData, bool(IPlayer& player, int recordType, std::string const& recordFile))
{
throw pawn_natives::NotImplemented();
}

SCRIPT_API(StopRecordingPlayerData, bool(IPlayer& player))
{
throw pawn_natives::NotImplemented();
}

SCRIPT_API(gpci, int(IPlayer& player, OutputOnlyString& output))
{
output = player.getSerial();
Expand Down
32 changes: 32 additions & 0 deletions Server/Components/Pawn/Scripting/Recording/Natives.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at http://mozilla.org/MPL/2.0/.
*
* The original code is copyright (c) 2022, open.mp team and contributors.
*/

#include "../Types.hpp"
#include "Server/Components/Recordings/recordings.hpp"

SCRIPT_API(StartRecordingPlayerData, bool(IPlayer& player, int type, std::string const& file))
{
IPlayerRecordingData* recording = queryExtension<IPlayerRecordingData>(player);
if (recording)
{
recording->start(PlayerRecordingType(type), file);
return true;
}
return false;
}

SCRIPT_API(StopRecordingPlayerData, bool(IPlayer& player))
{
IPlayerRecordingData* recording = queryExtension<IPlayerRecordingData>(player);
if (recording)
{
recording->stop();
return true;
}
return false;
}
2 changes: 2 additions & 0 deletions Server/Components/Pawn/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ class PawnComponent final : public IPawnComponent, public CoreEventHandler, publ
mgr->menus = components->queryComponent<IMenusComponent>();
mgr->objects = components->queryComponent<IObjectsComponent>();
mgr->pickups = components->queryComponent<IPickupsComponent>();
mgr->recordings = components->queryComponent<IRecordingsComponent>();
mgr->textdraws = components->queryComponent<ITextDrawsComponent>();
mgr->textlabels = components->queryComponent<ITextLabelsComponent>();
mgr->timers = components->queryComponent<ITimersComponent>();
Expand Down Expand Up @@ -276,6 +277,7 @@ class PawnComponent final : public IPawnComponent, public CoreEventHandler, publ
COMPONENT_UNLOADED(mgr->menus)
COMPONENT_UNLOADED(mgr->objects)
COMPONENT_UNLOADED(mgr->pickups)
COMPONENT_UNLOADED(mgr->recordings)
COMPONENT_UNLOADED(mgr->textdraws)
COMPONENT_UNLOADED(mgr->textlabels)
COMPONENT_UNLOADED(mgr->timers)
Expand Down
6 changes: 6 additions & 0 deletions Server/Components/Recordings/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME)
add_server_component(${ProjectId})

target_link_libraries(${ProjectId} PRIVATE
CONAN_PKG::ghc-filesystem
)
Loading
Loading