diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json
index 148ce9879b..ede5d8c31e 100644
--- a/.vscode/c_cpp_properties.json
+++ b/.vscode/c_cpp_properties.json
@@ -56,6 +56,7 @@
"includePath": [
"${workspaceRoot}",
"${workspaceRoot}/src",
+ "${workspaceRoot}/src/thirdparty",
"${workspaceRoot}/lib/Win32/include",
"${workspaceRoot}/lib/x64/include",
"${workspaceRoot}/lib/googletest/googletest/include"
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 33107734dd..99c2549ed2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -49,6 +49,7 @@ option(DISABLE_HTTP_TWITCH "Disable HTTP and Twitch support.")
option(DISABLE_NETWORK "Disable multiplayer functionality. Mainly for testing.")
option(DISABLE_TTF "Disable support for TTF provided by freetype2.")
option(ENABLE_LIGHTFX "Enable lighting effects." ON)
+option(ENABLE_SCRIPTING "Enable script / plugin support." ON)
option(DISABLE_GUI "Don't build GUI. (Headless only.)")
@@ -121,6 +122,9 @@ endif ()
if (ENABLE_LIGHTFX)
add_definitions(-D__ENABLE_LIGHTFX__)
endif ()
+if (ENABLE_SCRIPTING)
+ add_definitions(-D__ENABLE_SCRIPTING__)
+endif ()
if (NOT DISABLE_DISCORD_RPC)
if(EXISTS "${ROOT_DIR}/discord-rpc")
diff --git a/openrct2.common.props b/openrct2.common.props
index f8228d5e25..49b68916f3 100644
--- a/openrct2.common.props
+++ b/openrct2.common.props
@@ -102,7 +102,7 @@
- $(SolutionDir)src;$(SolutionDir)src\openrct2\thirdparty;$(SolutionDir)lib\$(Platform)\include;$(SolutionDir)lib\$(Platform)\include\SDL2;$(IncludePath)
+ $(SolutionDir)src;$(SolutionDir)src\thirdparty;$(SolutionDir)lib\$(Platform)\include;$(SolutionDir)lib\$(Platform)\include\SDL2;$(IncludePath)
$(SolutionDir)lib\$(Platform)\debug\lib;$(LibraryPath)
$(SolutionDir)lib\$(Platform)\lib;$(LibraryPath)
diff --git a/scripts/check-code-formatting b/scripts/check-code-formatting
index 491d21742b..51f8498328 100755
--- a/scripts/check-code-formatting
+++ b/scripts/check-code-formatting
@@ -5,4 +5,4 @@ set -e
basedir="$(readlink -f `dirname $0`/..)"
cd $basedir
-scripts/run-clang-format.py -r src test --exclude src/openrct2/thirdparty
+scripts/run-clang-format.py -r src test --exclude src/thirdparty
diff --git a/src/openrct2-android/app/src/main/CMakeLists.txt b/src/openrct2-android/app/src/main/CMakeLists.txt
index ba367e5adf..8b865d9deb 100644
--- a/src/openrct2-android/app/src/main/CMakeLists.txt
+++ b/src/openrct2-android/app/src/main/CMakeLists.txt
@@ -183,5 +183,7 @@ target_link_libraries(openrct2-ui openrct2 android stdc++ GLESv1_CM GLESv2 SDL2m
add_executable(openrct2-cli ${OPENRCT2_CLI_SOURCES})
target_link_libraries(openrct2-cli openrct2 android stdc++ GLESv1_CM GLESv2)
+target_include_directories(openrct2 SYSTEM PRIVATE "${ORCT2_ROOT}/src/thirdparty")
target_include_directories(openrct2-ui PRIVATE "${ORCT2_ROOT}/src")
+target_include_directories(openrct2-ui SYSTEM PRIVATE "${ORCT2_ROOT}/src/thirdparty")
target_include_directories(openrct2-cli PRIVATE "${ORCT2_ROOT}/src")
diff --git a/src/openrct2-ui/CMakeLists.txt b/src/openrct2-ui/CMakeLists.txt
index 0ff4920417..d4978b2ffa 100644
--- a/src/openrct2-ui/CMakeLists.txt
+++ b/src/openrct2-ui/CMakeLists.txt
@@ -65,7 +65,7 @@ endif ()
target_include_directories(${PROJECT} PRIVATE "${CMAKE_CURRENT_LIST_DIR}/.."
${SPEEX_INCLUDE_DIRS})
target_include_directories(${PROJECT} SYSTEM PRIVATE ${SDL2_INCLUDE_DIRS}
- "${CMAKE_CURRENT_LIST_DIR}/../openrct2/thirdparty")
+ "${CMAKE_CURRENT_LIST_DIR}/../thirdparty")
# Compiler flags
if (WIN32)
diff --git a/src/openrct2-ui/scripting/CustomWindow.cpp b/src/openrct2-ui/scripting/CustomWindow.cpp
index 28c5af6a66..27525ed3e2 100644
--- a/src/openrct2-ui/scripting/CustomWindow.cpp
+++ b/src/openrct2-ui/scripting/CustomWindow.cpp
@@ -229,21 +229,14 @@ namespace OpenRCT2::Ui::Windows
class CustomWindowInfo
{
- private:
- rct_windowclass _class;
- rct_windownumber _number;
-
public:
std::shared_ptr Owner;
CustomWindowDesc Desc;
std::vector Widgets;
std::vector WidgetIndexMap;
- CustomWindowInfo(
- rct_windowclass cls, rct_windownumber number, std::shared_ptr owner, const CustomWindowDesc& desc)
- : _class(cls)
- , _number(number)
- , Owner(owner)
+ CustomWindowInfo(std::shared_ptr owner, const CustomWindowDesc& desc)
+ : Owner(owner)
, Desc(desc)
{
}
@@ -300,7 +293,7 @@ namespace OpenRCT2::Ui::Windows
}
window->number = GetNewWindowNumber();
- window->custom_info = new CustomWindowInfo(window->classification, window->number, owner, desc);
+ window->custom_info = new CustomWindowInfo(owner, desc);
window->enabled_widgets = (1 << WIDX_CLOSE);
window->colours[0] = COLOUR_GREY;
window->colours[1] = COLOUR_GREY;
diff --git a/src/openrct2-ui/scripting/CustomWindow.h b/src/openrct2-ui/scripting/CustomWindow.h
index 130340375c..f63ecfcfec 100644
--- a/src/openrct2-ui/scripting/CustomWindow.h
+++ b/src/openrct2-ui/scripting/CustomWindow.h
@@ -7,10 +7,14 @@
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
-#include "../interface/Window.h"
+#pragma once
-#include
-#include
+#ifdef __ENABLE_SCRIPTING__
+
+# include "../interface/Window.h"
+
+# include
+# include
namespace OpenRCT2::Ui::Windows
{
@@ -18,3 +22,5 @@ namespace OpenRCT2::Ui::Windows
rct_window* FindCustomWindowByClassification(const std::string_view& classification);
std::optional FindWidgetIndexByName(rct_window* w, const std::string_view& name);
} // namespace OpenRCT2::Ui::Windows
+
+#endif
diff --git a/src/openrct2-ui/scripting/ScUi.hpp b/src/openrct2-ui/scripting/ScUi.hpp
index 3eaefe15a6..68c397c128 100644
--- a/src/openrct2-ui/scripting/ScUi.hpp
+++ b/src/openrct2-ui/scripting/ScUi.hpp
@@ -9,16 +9,18 @@
#pragma once
-#include "CustomMenu.h"
-#include "ScViewport.hpp"
-#include "ScWindow.hpp"
+#ifdef __ENABLE_SCRIPTING__
-#include
-#include
-#include
-#include
-#include
-#include
+# include "CustomMenu.h"
+# include "ScViewport.hpp"
+# include "ScWindow.hpp"
+
+# include
+# include
+# include
+# include
+# include
+# include
namespace OpenRCT2::Scripting
{
@@ -154,3 +156,5 @@ namespace OpenRCT2::Scripting
}
};
} // namespace OpenRCT2::Scripting
+
+#endif
diff --git a/src/openrct2-ui/scripting/ScViewport.hpp b/src/openrct2-ui/scripting/ScViewport.hpp
index c56cfccec5..012205e12a 100644
--- a/src/openrct2-ui/scripting/ScViewport.hpp
+++ b/src/openrct2-ui/scripting/ScViewport.hpp
@@ -9,15 +9,17 @@
#pragma once
-#include "../interface/Window.h"
+#ifdef __ENABLE_SCRIPTING__
-#include
-#include
-#include
-#include
-#include
-#include
-#include
+# include "../interface/Window.h"
+
+# include
+# include
+# include
+# include
+# include
+# include
+# include
namespace OpenRCT2::Scripting
{
@@ -301,3 +303,5 @@ namespace OpenRCT2::Scripting
}
};
} // namespace OpenRCT2::Scripting
+
+#endif
diff --git a/src/openrct2-ui/scripting/ScWidget.hpp b/src/openrct2-ui/scripting/ScWidget.hpp
index cca75554fb..3a43538db2 100644
--- a/src/openrct2-ui/scripting/ScWidget.hpp
+++ b/src/openrct2-ui/scripting/ScWidget.hpp
@@ -9,16 +9,18 @@
#pragma once
-#include "../interface/Widget.h"
-#include "../interface/Window.h"
-#include "CustomWindow.h"
-#include "ScViewport.hpp"
+#ifdef __ENABLE_SCRIPTING__
-#include
-#include
-#include
-#include
-#include
+# include "../interface/Widget.h"
+# include "../interface/Window.h"
+# include "CustomWindow.h"
+# include "ScViewport.hpp"
+
+# include
+# include
+# include
+# include
+# include
namespace OpenRCT2::Scripting
{
@@ -291,3 +293,5 @@ namespace OpenRCT2::Scripting
}
};
} // namespace OpenRCT2::Scripting
+
+#endif
diff --git a/src/openrct2-ui/scripting/ScWindow.hpp b/src/openrct2-ui/scripting/ScWindow.hpp
index 3969e73d2a..0c41b3a8a3 100644
--- a/src/openrct2-ui/scripting/ScWindow.hpp
+++ b/src/openrct2-ui/scripting/ScWindow.hpp
@@ -9,12 +9,14 @@
#pragma once
-#include "ScWidget.hpp"
+#ifdef __ENABLE_SCRIPTING__
-#include
-#include
-#include
-#include
+# include "ScWidget.hpp"
+
+# include
+# include
+# include
+# include
namespace OpenRCT2::Scripting
{
@@ -140,3 +142,5 @@ namespace OpenRCT2::Scripting
}
};
} // namespace OpenRCT2::Scripting
+
+#endif
diff --git a/src/openrct2-ui/scripting/UiExtensions.h b/src/openrct2-ui/scripting/UiExtensions.h
index 4f9fbfcd45..3e9af4ed22 100644
--- a/src/openrct2-ui/scripting/UiExtensions.h
+++ b/src/openrct2-ui/scripting/UiExtensions.h
@@ -9,6 +9,8 @@
#pragma once
+#ifdef __ENABLE_SCRIPTING__
+
namespace OpenRCT2::Scripting
{
class ScriptEngine;
@@ -19,3 +21,5 @@ namespace OpenRCT2::Scripting
static void Extend(ScriptEngine& scriptEngine);
};
} // namespace OpenRCT2::Scripting
+
+#endif
diff --git a/src/openrct2/CMakeLists.txt b/src/openrct2/CMakeLists.txt
index cc9e4cc142..7bedc0006c 100644
--- a/src/openrct2/CMakeLists.txt
+++ b/src/openrct2/CMakeLists.txt
@@ -202,7 +202,7 @@ target_include_directories(${PROJECT_NAME} PUBLIC ${JANSSON_INCLUDE_DIRS})
target_include_directories(${PROJECT_NAME} PRIVATE ${PNG_INCLUDE_DIRS}
${DUKTAPE_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIRS})
-include_directories(${PROJECT_NAME} SYSTEM ${CMAKE_CURRENT_LIST_DIR}/thirdparty)
+include_directories(${PROJECT_NAME} SYSTEM ${CMAKE_CURRENT_LIST_DIR}/../thirdparty)
# To avoid unnecessary rebuilds set the current branch and
# short sha1 only for the two files that use these
diff --git a/src/openrct2/core/FileSystem.hpp b/src/openrct2/core/FileSystem.hpp
index fa09497388..e33f6fc4cf 100644
--- a/src/openrct2/core/FileSystem.hpp
+++ b/src/openrct2/core/FileSystem.hpp
@@ -35,7 +35,7 @@
# include
namespace fs = std::filesystem;
#else
-# include "../thirdparty/filesystem.hpp"
+# include
namespace fs = ghc::filesystem;
#endif
diff --git a/src/openrct2/interface/StdInOutConsole.cpp b/src/openrct2/interface/StdInOutConsole.cpp
index 9fc0ac896a..92ed0970c1 100644
--- a/src/openrct2/interface/StdInOutConsole.cpp
+++ b/src/openrct2/interface/StdInOutConsole.cpp
@@ -11,9 +11,10 @@
#include "../OpenRCT2.h"
#include "../platform/Platform2.h"
#include "../scripting/ScriptEngine.h"
-#include "../thirdparty/linenoise.hpp"
#include "InteractiveConsole.h"
+#include
+
using namespace OpenRCT2;
void StdInOutConsole::Start()
diff --git a/src/openrct2/scripting/Duktape.hpp b/src/openrct2/scripting/Duktape.hpp
index 27573a8d50..2c150d9d5a 100644
--- a/src/openrct2/scripting/Duktape.hpp
+++ b/src/openrct2/scripting/Duktape.hpp
@@ -1,4 +1,17 @@
+/*****************************************************************************
+ * Copyright (c) 2014-2020 OpenRCT2 developers
+ *
+ * For a complete list of all authors, please refer to contributors.md
+ * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
+ *
+ * OpenRCT2 is licensed under the GNU General Public License version 3.
+ *****************************************************************************/
+
#pragma once
-#include
-#include
+#ifdef __ENABLE_SCRIPTING__
+
+# include
+# include
+
+#endif
diff --git a/src/openrct2/scripting/HookEngine.h b/src/openrct2/scripting/HookEngine.h
index 042bcbe52a..cfaeaf9474 100644
--- a/src/openrct2/scripting/HookEngine.h
+++ b/src/openrct2/scripting/HookEngine.h
@@ -9,14 +9,16 @@
#pragma once
-#include "../common.h"
-#include "Duktape.hpp"
+#ifdef __ENABLE_SCRIPTING__
-#include
-#include
-#include
-#include
-#include
+# include "../common.h"
+# include "Duktape.hpp"
+
+# include
+# include
+# include
+# include
+# include
namespace OpenRCT2::Scripting
{
@@ -70,7 +72,6 @@ namespace OpenRCT2::Scripting
private:
ScriptExecutionInfo& _execInfo;
std::vector _hookMap;
- size_t _numHooks{};
uint32_t _nextCookie = 1;
public:
@@ -91,3 +92,5 @@ namespace OpenRCT2::Scripting
const HookList& GetHookList(HOOK_TYPE type) const;
};
} // namespace OpenRCT2::Scripting
+
+#endif
diff --git a/src/openrct2/scripting/Plugin.cpp b/src/openrct2/scripting/Plugin.cpp
index cc9ea3ce62..cb3fecd37f 100644
--- a/src/openrct2/scripting/Plugin.cpp
+++ b/src/openrct2/scripting/Plugin.cpp
@@ -7,14 +7,16 @@
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
-#include "Plugin.h"
+#ifdef __ENABLE_SCRIPTING__
-#include "../OpenRCT2.h"
-#include "Duktape.hpp"
+# include "Plugin.h"
-#include
-#include
-#include
+# include "../OpenRCT2.h"
+# include "Duktape.hpp"
+
+# include
+# include
+# include
using namespace OpenRCT2::Scripting;
@@ -164,3 +166,5 @@ PluginType Plugin::ParsePluginType(const std::string_view& type)
return PluginType::ServerClient;
throw std::invalid_argument("Unknown plugin type.");
}
+
+#endif
diff --git a/src/openrct2/scripting/Plugin.h b/src/openrct2/scripting/Plugin.h
index 956840d55a..f584c26560 100644
--- a/src/openrct2/scripting/Plugin.h
+++ b/src/openrct2/scripting/Plugin.h
@@ -9,12 +9,14 @@
#pragma once
-#include "Duktape.hpp"
+#ifdef __ENABLE_SCRIPTING__
-#include
-#include
-#include
-#include
+# include "Duktape.hpp"
+
+# include
+# include
+# include
+# include
namespace OpenRCT2::Scripting
{
@@ -103,3 +105,5 @@ namespace OpenRCT2::Scripting
static PluginType ParsePluginType(const std::string_view& type);
};
} // namespace OpenRCT2::Scripting
+
+#endif
diff --git a/src/openrct2/scripting/ScConsole.hpp b/src/openrct2/scripting/ScConsole.hpp
index a53a9b8b82..c3ccacbf65 100644
--- a/src/openrct2/scripting/ScConsole.hpp
+++ b/src/openrct2/scripting/ScConsole.hpp
@@ -9,8 +9,10 @@
#pragma once
-#include "../interface/InteractiveConsole.h"
-#include "Duktape.hpp"
+#ifdef __ENABLE_SCRIPTING__
+
+# include "../interface/InteractiveConsole.h"
+# include "Duktape.hpp"
namespace OpenRCT2::Scripting
{
@@ -97,3 +99,5 @@ namespace OpenRCT2::Scripting
}
};
} // namespace OpenRCT2::Scripting
+
+#endif
diff --git a/src/openrct2/scripting/ScContext.hpp b/src/openrct2/scripting/ScContext.hpp
index b53770a9fe..e5528ac443 100644
--- a/src/openrct2/scripting/ScContext.hpp
+++ b/src/openrct2/scripting/ScContext.hpp
@@ -9,13 +9,15 @@
#pragma once
-#include "Duktape.hpp"
-#include "HookEngine.h"
-#include "ScDisposable.hpp"
-#include "ScriptEngine.h"
+#ifdef __ENABLE_SCRIPTING__
-#include
-#include
+# include "Duktape.hpp"
+# include "HookEngine.h"
+# include "ScDisposable.hpp"
+# include "ScriptEngine.h"
+
+# include
+# include
namespace OpenRCT2::Scripting
{
@@ -66,3 +68,5 @@ namespace OpenRCT2::Scripting
}
};
} // namespace OpenRCT2::Scripting
+
+#endif
diff --git a/src/openrct2/scripting/ScDate.hpp b/src/openrct2/scripting/ScDate.hpp
index 96838e5c90..76c664364b 100644
--- a/src/openrct2/scripting/ScDate.hpp
+++ b/src/openrct2/scripting/ScDate.hpp
@@ -9,13 +9,16 @@
#pragma once
-#include "../Context.h"
-#include "../Date.h"
-#include "../Game.h"
-#include "../GameState.h"
-#include "../common.h"
-#include "../localisation/Date.h"
-#include "Duktape.hpp"
+#ifdef __ENABLE_SCRIPTING__
+
+# include "../Context.h"
+# include "../Date.h"
+# include "../Game.h"
+# include "../GameState.h"
+# include "../common.h"
+# include "../localisation/Date.h"
+# include "Duktape.hpp"
+# include "ScriptEngine.h"
namespace OpenRCT2::Scripting
{
@@ -95,3 +98,5 @@ namespace OpenRCT2::Scripting
}
};
} // namespace OpenRCT2::Scripting
+
+#endif
diff --git a/src/openrct2/scripting/ScDisposable.hpp b/src/openrct2/scripting/ScDisposable.hpp
index 13219b0ed4..5b591e35c3 100644
--- a/src/openrct2/scripting/ScDisposable.hpp
+++ b/src/openrct2/scripting/ScDisposable.hpp
@@ -9,9 +9,11 @@
#pragma once
-#include "Duktape.hpp"
+#ifdef __ENABLE_SCRIPTING__
-#include
+# include "Duktape.hpp"
+
+# include
namespace OpenRCT2::Scripting
{
@@ -40,3 +42,5 @@ namespace OpenRCT2::Scripting
}
};
} // namespace OpenRCT2::Scripting
+
+#endif
diff --git a/src/openrct2/scripting/ScMap.hpp b/src/openrct2/scripting/ScMap.hpp
index 1b90ea0a8a..94f4749a3b 100644
--- a/src/openrct2/scripting/ScMap.hpp
+++ b/src/openrct2/scripting/ScMap.hpp
@@ -9,13 +9,15 @@
#pragma once
-#include "../common.h"
-#include "../ride/Ride.h"
-#include "../world/Map.h"
-#include "Duktape.hpp"
-#include "ScRide.hpp"
-#include "ScThing.hpp"
-#include "ScTile.hpp"
+#ifdef __ENABLE_SCRIPTING__
+
+# include "../common.h"
+# include "../ride/Ride.h"
+# include "../world/Map.h"
+# include "Duktape.hpp"
+# include "ScRide.hpp"
+# include "ScThing.hpp"
+# include "ScTile.hpp"
namespace OpenRCT2::Scripting
{
@@ -96,3 +98,5 @@ namespace OpenRCT2::Scripting
}
};
} // namespace OpenRCT2::Scripting
+
+#endif
diff --git a/src/openrct2/scripting/ScNetwork.hpp b/src/openrct2/scripting/ScNetwork.hpp
index 0d52b9efa4..b09fae62db 100644
--- a/src/openrct2/scripting/ScNetwork.hpp
+++ b/src/openrct2/scripting/ScNetwork.hpp
@@ -9,12 +9,14 @@
#pragma once
-#include "../actions/NetworkModifyGroupAction.hpp"
-#include "../actions/PlayerKickAction.hpp"
-#include "../actions/PlayerSetGroupAction.hpp"
-#include "../network/NetworkAction.h"
-#include "../network/network.h"
-#include "Duktape.hpp"
+#ifdef __ENABLE_SCRIPTING__
+
+# include "../actions/NetworkModifyGroupAction.hpp"
+# include "../actions/PlayerKickAction.hpp"
+# include "../actions/PlayerSetGroupAction.hpp"
+# include "../network/NetworkAction.h"
+# include "../network/network.h"
+# include "Duktape.hpp"
namespace OpenRCT2::Scripting
{
@@ -36,19 +38,26 @@ namespace OpenRCT2::Scripting
std::string name_get()
{
+# ifndef DISABLE_NETWORK
auto index = network_get_group_index(_id);
if (index == -1)
return {};
return network_get_group_name(index);
+# else
+ return {};
+# endif
}
void name_set(std::string value)
{
+# ifndef DISABLE_NETWORK
auto action = NetworkModifyGroupAction(ModifyGroupType::SetName, _id, value);
GameActions::Execute(&action);
+# endif
}
std::vector permissions_get()
{
+# ifndef DISABLE_NETWORK
auto index = network_get_group_index(_id);
if (index == -1)
return {};
@@ -66,9 +75,13 @@ namespace OpenRCT2::Scripting
permissionIndex++;
}
return result;
+# else
+ return {};
+# endif
}
void permissions_set(std::vector value)
{
+# ifndef DISABLE_NETWORK
auto groupIndex = network_get_group_index(_id);
if (groupIndex == -1)
return;
@@ -105,6 +118,7 @@ namespace OpenRCT2::Scripting
GameActions::Execute(&networkAction2);
}
}
+# endif
}
static void Register(duk_context* ctx)
@@ -154,47 +168,69 @@ namespace OpenRCT2::Scripting
std::string name_get()
{
+# ifndef DISABLE_NETWORK
auto index = network_get_player_index(_id);
if (index == -1)
return {};
return network_get_player_name(index);
+# else
+ return {};
+# endif
}
int32_t group_get()
{
+# ifndef DISABLE_NETWORK
auto index = network_get_player_index(_id);
if (index == -1)
return {};
return network_get_player_group(index);
+# else
+ return 0;
+# endif
}
void group_set(int32_t value)
{
+# ifndef DISABLE_NETWORK
auto playerSetGroupAction = PlayerSetGroupAction(_id, value);
GameActions::Execute(&playerSetGroupAction);
+# endif
}
int32_t ping_get()
{
+# ifndef DISABLE_NETWORK
auto index = network_get_player_index(_id);
if (index == -1)
return {};
return network_get_player_ping(index);
+# else
+ return 0;
+# endif
}
int32_t commandsRan_get()
{
+# ifndef DISABLE_NETWORK
auto index = network_get_player_index(_id);
if (index == -1)
return {};
return network_get_player_commands_ran(index);
+# else
+ return 0;
+# endif
}
int32_t moneySpent_get()
{
+# ifndef DISABLE_NETWORK
auto index = network_get_player_index(_id);
if (index == -1)
return {};
return network_get_player_money_spent(index);
+# else
+ return 0;
+# endif
}
static void Register(duk_context* ctx)
@@ -211,6 +247,9 @@ namespace OpenRCT2::Scripting
class ScNetwork
{
private:
+# ifdef __clang__
+ [[maybe_unused]]
+# endif
duk_context* _context;
public:
@@ -221,6 +260,7 @@ namespace OpenRCT2::Scripting
std::string mode_get()
{
+# ifndef DISABLE_NETWORK
switch (network_get_mode())
{
default:
@@ -231,49 +271,71 @@ namespace OpenRCT2::Scripting
case NETWORK_MODE_CLIENT:
return "client";
}
+# else
+ return "none";
+# endif
}
int32_t players_get()
{
+# ifndef DISABLE_NETWORK
return network_get_num_players();
+# else
+ return 0;
+# endif
}
int32_t groups_get()
{
+# ifndef DISABLE_NETWORK
return network_get_num_groups();
+# else
+ return 0;
+# endif
}
int32_t defaultGroup_get()
{
+# ifndef DISABLE_NETWORK
return network_get_default_group();
+# else
+ return 0;
+# endif
}
void defaultGroup_set(int32_t value)
{
+# ifndef DISABLE_NETWORK
auto action = NetworkModifyGroupAction(ModifyGroupType::SetDefault, value);
GameActions::Execute(&action);
+# endif
}
std::shared_ptr getPlayer(int32_t index)
{
+# ifndef DISABLE_NETWORK
auto numPlayers = network_get_num_players();
if (index < numPlayers)
{
auto playerId = network_get_player_id(index);
return std::make_shared(playerId);
}
+# endif
return nullptr;
}
std::shared_ptr getGroup(int32_t index)
{
+# ifndef DISABLE_NETWORK
auto numGroups = network_get_num_groups();
if (index < numGroups)
{
auto groupId = network_get_group_id(index);
return std::make_shared(groupId);
}
+# endif
return nullptr;
}
void kickPlayer(int32_t index)
{
+# ifndef DISABLE_NETWORK
auto numPlayers = network_get_num_players();
if (index < numPlayers)
{
@@ -281,10 +343,12 @@ namespace OpenRCT2::Scripting
auto kickPlayerAction = PlayerKickAction(playerId);
GameActions::Execute(&kickPlayerAction);
}
+# endif
}
void sendMessage(std::string message, DukValue players)
{
+# ifndef DISABLE_NETWORK
if (players.is_array())
{
duk_error(players.context(), DUK_ERR_ERROR, "Not yet supported");
@@ -293,6 +357,7 @@ namespace OpenRCT2::Scripting
{
network_send_chat(message.c_str());
}
+# endif
}
static void Register(duk_context* ctx)
@@ -308,3 +373,5 @@ namespace OpenRCT2::Scripting
}
};
} // namespace OpenRCT2::Scripting
+
+#endif
diff --git a/src/openrct2/scripting/ScPark.hpp b/src/openrct2/scripting/ScPark.hpp
index 6d073df32c..7b908b8cd4 100644
--- a/src/openrct2/scripting/ScPark.hpp
+++ b/src/openrct2/scripting/ScPark.hpp
@@ -9,16 +9,18 @@
#pragma once
-#include "../Context.h"
-#include "../common.h"
-#include "../management/Finance.h"
-#include "../management/NewsItem.h"
-#include "../windows/Intent.h"
-#include "../world/Park.h"
-#include "Duktape.hpp"
-#include "ScriptEngine.h"
+#ifdef __ENABLE_SCRIPTING__
-#include
+# include "../Context.h"
+# include "../common.h"
+# include "../management/Finance.h"
+# include "../management/NewsItem.h"
+# include "../windows/Intent.h"
+# include "../world/Park.h"
+# include "Duktape.hpp"
+# include "ScriptEngine.h"
+
+# include
namespace OpenRCT2::Scripting
{
@@ -123,3 +125,5 @@ namespace OpenRCT2::Scripting
}
};
} // namespace OpenRCT2::Scripting
+
+#endif
diff --git a/src/openrct2/scripting/ScRide.hpp b/src/openrct2/scripting/ScRide.hpp
index 1e75fb7d3b..71fc3c8ad1 100644
--- a/src/openrct2/scripting/ScRide.hpp
+++ b/src/openrct2/scripting/ScRide.hpp
@@ -9,10 +9,13 @@
#pragma once
-#include "../common.h"
-#include "../object/RideObject.h"
-#include "../ride/Ride.h"
-#include "Duktape.hpp"
+#ifdef __ENABLE_SCRIPTING__
+
+# include "../common.h"
+# include "../object/RideObject.h"
+# include "../ride/Ride.h"
+# include "Duktape.hpp"
+# include "ScriptEngine.h"
namespace OpenRCT2::Scripting
{
@@ -171,3 +174,5 @@ namespace OpenRCT2::Scripting
}
};
} // namespace OpenRCT2::Scripting
+
+#endif
diff --git a/src/openrct2/scripting/ScThing.hpp b/src/openrct2/scripting/ScThing.hpp
index e67aa60b24..d741a0e811 100644
--- a/src/openrct2/scripting/ScThing.hpp
+++ b/src/openrct2/scripting/ScThing.hpp
@@ -9,9 +9,12 @@
#pragma once
-#include "../common.h"
-#include "../world/Sprite.h"
-#include "Duktape.hpp"
+#ifdef __ENABLE_SCRIPTING__
+
+# include "../common.h"
+# include "../world/Sprite.h"
+# include "Duktape.hpp"
+# include "ScriptEngine.h"
namespace OpenRCT2::Scripting
{
@@ -99,3 +102,5 @@ namespace OpenRCT2::Scripting
}
};
} // namespace OpenRCT2::Scripting
+
+#endif
diff --git a/src/openrct2/scripting/ScTile.hpp b/src/openrct2/scripting/ScTile.hpp
index d65e9ed3ac..e8d4fd6315 100644
--- a/src/openrct2/scripting/ScTile.hpp
+++ b/src/openrct2/scripting/ScTile.hpp
@@ -9,14 +9,17 @@
#pragma once
-#include "../common.h"
-#include "../world/Footpath.h"
-#include "../world/Scenery.h"
-#include "../world/Sprite.h"
-#include "../world/Surface.h"
-#include "Duktape.hpp"
+#ifdef __ENABLE_SCRIPTING__
-#include
+# include "../common.h"
+# include "../world/Footpath.h"
+# include "../world/Scenery.h"
+# include "../world/Sprite.h"
+# include "../world/Surface.h"
+# include "Duktape.hpp"
+# include "ScriptEngine.h"
+
+# include
namespace OpenRCT2::Scripting
{
@@ -193,3 +196,5 @@ namespace OpenRCT2::Scripting
}
};
} // namespace OpenRCT2::Scripting
+
+#endif
diff --git a/src/openrct2/thirdparty/dukglue/detail_class_proto.h b/src/thirdparty/dukglue/detail_class_proto.h
similarity index 100%
rename from src/openrct2/thirdparty/dukglue/detail_class_proto.h
rename to src/thirdparty/dukglue/detail_class_proto.h
diff --git a/src/openrct2/thirdparty/dukglue/detail_constructor.h b/src/thirdparty/dukglue/detail_constructor.h
similarity index 100%
rename from src/openrct2/thirdparty/dukglue/detail_constructor.h
rename to src/thirdparty/dukglue/detail_constructor.h
diff --git a/src/openrct2/thirdparty/dukglue/detail_function.h b/src/thirdparty/dukglue/detail_function.h
similarity index 100%
rename from src/openrct2/thirdparty/dukglue/detail_function.h
rename to src/thirdparty/dukglue/detail_function.h
diff --git a/src/openrct2/thirdparty/dukglue/detail_method.h b/src/thirdparty/dukglue/detail_method.h
similarity index 100%
rename from src/openrct2/thirdparty/dukglue/detail_method.h
rename to src/thirdparty/dukglue/detail_method.h
diff --git a/src/openrct2/thirdparty/dukglue/detail_primitive_types.h b/src/thirdparty/dukglue/detail_primitive_types.h
similarity index 100%
rename from src/openrct2/thirdparty/dukglue/detail_primitive_types.h
rename to src/thirdparty/dukglue/detail_primitive_types.h
diff --git a/src/openrct2/thirdparty/dukglue/detail_refs.h b/src/thirdparty/dukglue/detail_refs.h
similarity index 100%
rename from src/openrct2/thirdparty/dukglue/detail_refs.h
rename to src/thirdparty/dukglue/detail_refs.h
diff --git a/src/openrct2/thirdparty/dukglue/detail_stack.h b/src/thirdparty/dukglue/detail_stack.h
similarity index 100%
rename from src/openrct2/thirdparty/dukglue/detail_stack.h
rename to src/thirdparty/dukglue/detail_stack.h
diff --git a/src/openrct2/thirdparty/dukglue/detail_traits.h b/src/thirdparty/dukglue/detail_traits.h
similarity index 100%
rename from src/openrct2/thirdparty/dukglue/detail_traits.h
rename to src/thirdparty/dukglue/detail_traits.h
diff --git a/src/openrct2/thirdparty/dukglue/detail_typeinfo.h b/src/thirdparty/dukglue/detail_typeinfo.h
similarity index 100%
rename from src/openrct2/thirdparty/dukglue/detail_typeinfo.h
rename to src/thirdparty/dukglue/detail_typeinfo.h
diff --git a/src/openrct2/thirdparty/dukglue/detail_types.h b/src/thirdparty/dukglue/detail_types.h
similarity index 100%
rename from src/openrct2/thirdparty/dukglue/detail_types.h
rename to src/thirdparty/dukglue/detail_types.h
diff --git a/src/openrct2/thirdparty/dukglue/dukexception.h b/src/thirdparty/dukglue/dukexception.h
similarity index 100%
rename from src/openrct2/thirdparty/dukglue/dukexception.h
rename to src/thirdparty/dukglue/dukexception.h
diff --git a/src/openrct2/thirdparty/dukglue/dukglue.h b/src/thirdparty/dukglue/dukglue.h
similarity index 100%
rename from src/openrct2/thirdparty/dukglue/dukglue.h
rename to src/thirdparty/dukglue/dukglue.h
diff --git a/src/openrct2/thirdparty/dukglue/dukvalue.h b/src/thirdparty/dukglue/dukvalue.h
similarity index 100%
rename from src/openrct2/thirdparty/dukglue/dukvalue.h
rename to src/thirdparty/dukglue/dukvalue.h
diff --git a/src/openrct2/thirdparty/dukglue/public_util.h b/src/thirdparty/dukglue/public_util.h
similarity index 100%
rename from src/openrct2/thirdparty/dukglue/public_util.h
rename to src/thirdparty/dukglue/public_util.h
diff --git a/src/openrct2/thirdparty/dukglue/register_class.h b/src/thirdparty/dukglue/register_class.h
similarity index 100%
rename from src/openrct2/thirdparty/dukglue/register_class.h
rename to src/thirdparty/dukglue/register_class.h
diff --git a/src/openrct2/thirdparty/dukglue/register_function.h b/src/thirdparty/dukglue/register_function.h
similarity index 100%
rename from src/openrct2/thirdparty/dukglue/register_function.h
rename to src/thirdparty/dukglue/register_function.h
diff --git a/src/openrct2/thirdparty/dukglue/register_property.h b/src/thirdparty/dukglue/register_property.h
similarity index 100%
rename from src/openrct2/thirdparty/dukglue/register_property.h
rename to src/thirdparty/dukglue/register_property.h
diff --git a/src/openrct2/thirdparty/filesystem.hpp b/src/thirdparty/filesystem.hpp
similarity index 100%
rename from src/openrct2/thirdparty/filesystem.hpp
rename to src/thirdparty/filesystem.hpp
diff --git a/src/openrct2/thirdparty/linenoise.hpp b/src/thirdparty/linenoise.hpp
similarity index 100%
rename from src/openrct2/thirdparty/linenoise.hpp
rename to src/thirdparty/linenoise.hpp