mirror of https://github.com/OpenRCT2/OpenRCT2.git
Get scripting compiling on clang
This commit is contained in:
parent
bac91cd563
commit
e6341f0a42
|
@ -56,6 +56,7 @@
|
||||||
"includePath": [
|
"includePath": [
|
||||||
"${workspaceRoot}",
|
"${workspaceRoot}",
|
||||||
"${workspaceRoot}/src",
|
"${workspaceRoot}/src",
|
||||||
|
"${workspaceRoot}/src/thirdparty",
|
||||||
"${workspaceRoot}/lib/Win32/include",
|
"${workspaceRoot}/lib/Win32/include",
|
||||||
"${workspaceRoot}/lib/x64/include",
|
"${workspaceRoot}/lib/x64/include",
|
||||||
"${workspaceRoot}/lib/googletest/googletest/include"
|
"${workspaceRoot}/lib/googletest/googletest/include"
|
||||||
|
|
|
@ -49,6 +49,7 @@ option(DISABLE_HTTP_TWITCH "Disable HTTP and Twitch support.")
|
||||||
option(DISABLE_NETWORK "Disable multiplayer functionality. Mainly for testing.")
|
option(DISABLE_NETWORK "Disable multiplayer functionality. Mainly for testing.")
|
||||||
option(DISABLE_TTF "Disable support for TTF provided by freetype2.")
|
option(DISABLE_TTF "Disable support for TTF provided by freetype2.")
|
||||||
option(ENABLE_LIGHTFX "Enable lighting effects." ON)
|
option(ENABLE_LIGHTFX "Enable lighting effects." ON)
|
||||||
|
option(ENABLE_SCRIPTING "Enable script / plugin support." ON)
|
||||||
|
|
||||||
option(DISABLE_GUI "Don't build GUI. (Headless only.)")
|
option(DISABLE_GUI "Don't build GUI. (Headless only.)")
|
||||||
|
|
||||||
|
@ -121,6 +122,9 @@ endif ()
|
||||||
if (ENABLE_LIGHTFX)
|
if (ENABLE_LIGHTFX)
|
||||||
add_definitions(-D__ENABLE_LIGHTFX__)
|
add_definitions(-D__ENABLE_LIGHTFX__)
|
||||||
endif ()
|
endif ()
|
||||||
|
if (ENABLE_SCRIPTING)
|
||||||
|
add_definitions(-D__ENABLE_SCRIPTING__)
|
||||||
|
endif ()
|
||||||
|
|
||||||
if (NOT DISABLE_DISCORD_RPC)
|
if (NOT DISABLE_DISCORD_RPC)
|
||||||
if(EXISTS "${ROOT_DIR}/discord-rpc")
|
if(EXISTS "${ROOT_DIR}/discord-rpc")
|
||||||
|
|
|
@ -102,7 +102,7 @@
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<IncludePath>$(SolutionDir)src;$(SolutionDir)src\openrct2\thirdparty;$(SolutionDir)lib\$(Platform)\include;$(SolutionDir)lib\$(Platform)\include\SDL2;$(IncludePath)</IncludePath>
|
<IncludePath>$(SolutionDir)src;$(SolutionDir)src\thirdparty;$(SolutionDir)lib\$(Platform)\include;$(SolutionDir)lib\$(Platform)\include\SDL2;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath Condition="'$(Configuration)'=='Debug'">$(SolutionDir)lib\$(Platform)\debug\lib;$(LibraryPath)</LibraryPath>
|
<LibraryPath Condition="'$(Configuration)'=='Debug'">$(SolutionDir)lib\$(Platform)\debug\lib;$(LibraryPath)</LibraryPath>
|
||||||
<LibraryPath Condition="'$(Configuration)'!='Debug'">$(SolutionDir)lib\$(Platform)\lib;$(LibraryPath)</LibraryPath>
|
<LibraryPath Condition="'$(Configuration)'!='Debug'">$(SolutionDir)lib\$(Platform)\lib;$(LibraryPath)</LibraryPath>
|
||||||
<LinkIncremental />
|
<LinkIncremental />
|
||||||
|
|
|
@ -5,4 +5,4 @@ set -e
|
||||||
basedir="$(readlink -f `dirname $0`/..)"
|
basedir="$(readlink -f `dirname $0`/..)"
|
||||||
cd $basedir
|
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
|
||||||
|
|
|
@ -183,5 +183,7 @@ target_link_libraries(openrct2-ui openrct2 android stdc++ GLESv1_CM GLESv2 SDL2m
|
||||||
add_executable(openrct2-cli ${OPENRCT2_CLI_SOURCES})
|
add_executable(openrct2-cli ${OPENRCT2_CLI_SOURCES})
|
||||||
target_link_libraries(openrct2-cli openrct2 android stdc++ GLESv1_CM GLESv2)
|
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 PRIVATE "${ORCT2_ROOT}/src")
|
||||||
|
target_include_directories(openrct2-ui SYSTEM PRIVATE "${ORCT2_ROOT}/src/thirdparty")
|
||||||
target_include_directories(openrct2-cli PRIVATE "${ORCT2_ROOT}/src")
|
target_include_directories(openrct2-cli PRIVATE "${ORCT2_ROOT}/src")
|
||||||
|
|
|
@ -65,7 +65,7 @@ endif ()
|
||||||
target_include_directories(${PROJECT} PRIVATE "${CMAKE_CURRENT_LIST_DIR}/.."
|
target_include_directories(${PROJECT} PRIVATE "${CMAKE_CURRENT_LIST_DIR}/.."
|
||||||
${SPEEX_INCLUDE_DIRS})
|
${SPEEX_INCLUDE_DIRS})
|
||||||
target_include_directories(${PROJECT} SYSTEM PRIVATE ${SDL2_INCLUDE_DIRS}
|
target_include_directories(${PROJECT} SYSTEM PRIVATE ${SDL2_INCLUDE_DIRS}
|
||||||
"${CMAKE_CURRENT_LIST_DIR}/../openrct2/thirdparty")
|
"${CMAKE_CURRENT_LIST_DIR}/../thirdparty")
|
||||||
|
|
||||||
# Compiler flags
|
# Compiler flags
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
|
|
|
@ -229,21 +229,14 @@ namespace OpenRCT2::Ui::Windows
|
||||||
|
|
||||||
class CustomWindowInfo
|
class CustomWindowInfo
|
||||||
{
|
{
|
||||||
private:
|
|
||||||
rct_windowclass _class;
|
|
||||||
rct_windownumber _number;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::shared_ptr<Plugin> Owner;
|
std::shared_ptr<Plugin> Owner;
|
||||||
CustomWindowDesc Desc;
|
CustomWindowDesc Desc;
|
||||||
std::vector<rct_widget> Widgets;
|
std::vector<rct_widget> Widgets;
|
||||||
std::vector<size_t> WidgetIndexMap;
|
std::vector<size_t> WidgetIndexMap;
|
||||||
|
|
||||||
CustomWindowInfo(
|
CustomWindowInfo(std::shared_ptr<Plugin> owner, const CustomWindowDesc& desc)
|
||||||
rct_windowclass cls, rct_windownumber number, std::shared_ptr<Plugin> owner, const CustomWindowDesc& desc)
|
: Owner(owner)
|
||||||
: _class(cls)
|
|
||||||
, _number(number)
|
|
||||||
, Owner(owner)
|
|
||||||
, Desc(desc)
|
, Desc(desc)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -300,7 +293,7 @@ namespace OpenRCT2::Ui::Windows
|
||||||
}
|
}
|
||||||
|
|
||||||
window->number = GetNewWindowNumber();
|
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->enabled_widgets = (1 << WIDX_CLOSE);
|
||||||
window->colours[0] = COLOUR_GREY;
|
window->colours[0] = COLOUR_GREY;
|
||||||
window->colours[1] = COLOUR_GREY;
|
window->colours[1] = COLOUR_GREY;
|
||||||
|
|
|
@ -7,6 +7,10 @@
|
||||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __ENABLE_SCRIPTING__
|
||||||
|
|
||||||
# include "../interface/Window.h"
|
# include "../interface/Window.h"
|
||||||
|
|
||||||
# include <optional>
|
# include <optional>
|
||||||
|
@ -18,3 +22,5 @@ namespace OpenRCT2::Ui::Windows
|
||||||
rct_window* FindCustomWindowByClassification(const std::string_view& classification);
|
rct_window* FindCustomWindowByClassification(const std::string_view& classification);
|
||||||
std::optional<rct_widgetindex> FindWidgetIndexByName(rct_window* w, const std::string_view& name);
|
std::optional<rct_widgetindex> FindWidgetIndexByName(rct_window* w, const std::string_view& name);
|
||||||
} // namespace OpenRCT2::Ui::Windows
|
} // namespace OpenRCT2::Ui::Windows
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __ENABLE_SCRIPTING__
|
||||||
|
|
||||||
# include "CustomMenu.h"
|
# include "CustomMenu.h"
|
||||||
# include "ScViewport.hpp"
|
# include "ScViewport.hpp"
|
||||||
# include "ScWindow.hpp"
|
# include "ScWindow.hpp"
|
||||||
|
@ -154,3 +156,5 @@ namespace OpenRCT2::Scripting
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace OpenRCT2::Scripting
|
} // namespace OpenRCT2::Scripting
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __ENABLE_SCRIPTING__
|
||||||
|
|
||||||
# include "../interface/Window.h"
|
# include "../interface/Window.h"
|
||||||
|
|
||||||
# include <memory>
|
# include <memory>
|
||||||
|
@ -301,3 +303,5 @@ namespace OpenRCT2::Scripting
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace OpenRCT2::Scripting
|
} // namespace OpenRCT2::Scripting
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __ENABLE_SCRIPTING__
|
||||||
|
|
||||||
# include "../interface/Widget.h"
|
# include "../interface/Widget.h"
|
||||||
# include "../interface/Window.h"
|
# include "../interface/Window.h"
|
||||||
# include "CustomWindow.h"
|
# include "CustomWindow.h"
|
||||||
|
@ -291,3 +293,5 @@ namespace OpenRCT2::Scripting
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace OpenRCT2::Scripting
|
} // namespace OpenRCT2::Scripting
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __ENABLE_SCRIPTING__
|
||||||
|
|
||||||
# include "ScWidget.hpp"
|
# include "ScWidget.hpp"
|
||||||
|
|
||||||
# include <openrct2/common.h>
|
# include <openrct2/common.h>
|
||||||
|
@ -140,3 +142,5 @@ namespace OpenRCT2::Scripting
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace OpenRCT2::Scripting
|
} // namespace OpenRCT2::Scripting
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __ENABLE_SCRIPTING__
|
||||||
|
|
||||||
namespace OpenRCT2::Scripting
|
namespace OpenRCT2::Scripting
|
||||||
{
|
{
|
||||||
class ScriptEngine;
|
class ScriptEngine;
|
||||||
|
@ -19,3 +21,5 @@ namespace OpenRCT2::Scripting
|
||||||
static void Extend(ScriptEngine& scriptEngine);
|
static void Extend(ScriptEngine& scriptEngine);
|
||||||
};
|
};
|
||||||
} // namespace OpenRCT2::Scripting
|
} // namespace OpenRCT2::Scripting
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -202,7 +202,7 @@ target_include_directories(${PROJECT_NAME} PUBLIC ${JANSSON_INCLUDE_DIRS})
|
||||||
target_include_directories(${PROJECT_NAME} PRIVATE ${PNG_INCLUDE_DIRS}
|
target_include_directories(${PROJECT_NAME} PRIVATE ${PNG_INCLUDE_DIRS}
|
||||||
${DUKTAPE_INCLUDE_DIRS}
|
${DUKTAPE_INCLUDE_DIRS}
|
||||||
${ZLIB_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
|
# To avoid unnecessary rebuilds set the current branch and
|
||||||
# short sha1 only for the two files that use these
|
# short sha1 only for the two files that use these
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
# include <filesystem>
|
# include <filesystem>
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
#else
|
#else
|
||||||
# include "../thirdparty/filesystem.hpp"
|
# include <filesystem.hpp>
|
||||||
namespace fs = ghc::filesystem;
|
namespace fs = ghc::filesystem;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -11,9 +11,10 @@
|
||||||
#include "../OpenRCT2.h"
|
#include "../OpenRCT2.h"
|
||||||
#include "../platform/Platform2.h"
|
#include "../platform/Platform2.h"
|
||||||
#include "../scripting/ScriptEngine.h"
|
#include "../scripting/ScriptEngine.h"
|
||||||
#include "../thirdparty/linenoise.hpp"
|
|
||||||
#include "InteractiveConsole.h"
|
#include "InteractiveConsole.h"
|
||||||
|
|
||||||
|
#include <linenoise.hpp>
|
||||||
|
|
||||||
using namespace OpenRCT2;
|
using namespace OpenRCT2;
|
||||||
|
|
||||||
void StdInOutConsole::Start()
|
void StdInOutConsole::Start()
|
||||||
|
|
|
@ -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
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __ENABLE_SCRIPTING__
|
||||||
|
|
||||||
# include <dukglue/dukglue.h>
|
# include <dukglue/dukglue.h>
|
||||||
# include <duktape.h>
|
# include <duktape.h>
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __ENABLE_SCRIPTING__
|
||||||
|
|
||||||
# include "../common.h"
|
# include "../common.h"
|
||||||
# include "Duktape.hpp"
|
# include "Duktape.hpp"
|
||||||
|
|
||||||
|
@ -70,7 +72,6 @@ namespace OpenRCT2::Scripting
|
||||||
private:
|
private:
|
||||||
ScriptExecutionInfo& _execInfo;
|
ScriptExecutionInfo& _execInfo;
|
||||||
std::vector<HookList> _hookMap;
|
std::vector<HookList> _hookMap;
|
||||||
size_t _numHooks{};
|
|
||||||
uint32_t _nextCookie = 1;
|
uint32_t _nextCookie = 1;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -91,3 +92,5 @@ namespace OpenRCT2::Scripting
|
||||||
const HookList& GetHookList(HOOK_TYPE type) const;
|
const HookList& GetHookList(HOOK_TYPE type) const;
|
||||||
};
|
};
|
||||||
} // namespace OpenRCT2::Scripting
|
} // namespace OpenRCT2::Scripting
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef __ENABLE_SCRIPTING__
|
||||||
|
|
||||||
# include "Plugin.h"
|
# include "Plugin.h"
|
||||||
|
|
||||||
# include "../OpenRCT2.h"
|
# include "../OpenRCT2.h"
|
||||||
|
@ -164,3 +166,5 @@ PluginType Plugin::ParsePluginType(const std::string_view& type)
|
||||||
return PluginType::ServerClient;
|
return PluginType::ServerClient;
|
||||||
throw std::invalid_argument("Unknown plugin type.");
|
throw std::invalid_argument("Unknown plugin type.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __ENABLE_SCRIPTING__
|
||||||
|
|
||||||
# include "Duktape.hpp"
|
# include "Duktape.hpp"
|
||||||
|
|
||||||
# include <memory>
|
# include <memory>
|
||||||
|
@ -103,3 +105,5 @@ namespace OpenRCT2::Scripting
|
||||||
static PluginType ParsePluginType(const std::string_view& type);
|
static PluginType ParsePluginType(const std::string_view& type);
|
||||||
};
|
};
|
||||||
} // namespace OpenRCT2::Scripting
|
} // namespace OpenRCT2::Scripting
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __ENABLE_SCRIPTING__
|
||||||
|
|
||||||
# include "../interface/InteractiveConsole.h"
|
# include "../interface/InteractiveConsole.h"
|
||||||
# include "Duktape.hpp"
|
# include "Duktape.hpp"
|
||||||
|
|
||||||
|
@ -97,3 +99,5 @@ namespace OpenRCT2::Scripting
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace OpenRCT2::Scripting
|
} // namespace OpenRCT2::Scripting
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __ENABLE_SCRIPTING__
|
||||||
|
|
||||||
# include "Duktape.hpp"
|
# include "Duktape.hpp"
|
||||||
# include "HookEngine.h"
|
# include "HookEngine.h"
|
||||||
# include "ScDisposable.hpp"
|
# include "ScDisposable.hpp"
|
||||||
|
@ -66,3 +68,5 @@ namespace OpenRCT2::Scripting
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace OpenRCT2::Scripting
|
} // namespace OpenRCT2::Scripting
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __ENABLE_SCRIPTING__
|
||||||
|
|
||||||
# include "../Context.h"
|
# include "../Context.h"
|
||||||
# include "../Date.h"
|
# include "../Date.h"
|
||||||
# include "../Game.h"
|
# include "../Game.h"
|
||||||
|
@ -16,6 +18,7 @@
|
||||||
# include "../common.h"
|
# include "../common.h"
|
||||||
# include "../localisation/Date.h"
|
# include "../localisation/Date.h"
|
||||||
# include "Duktape.hpp"
|
# include "Duktape.hpp"
|
||||||
|
# include "ScriptEngine.h"
|
||||||
|
|
||||||
namespace OpenRCT2::Scripting
|
namespace OpenRCT2::Scripting
|
||||||
{
|
{
|
||||||
|
@ -95,3 +98,5 @@ namespace OpenRCT2::Scripting
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace OpenRCT2::Scripting
|
} // namespace OpenRCT2::Scripting
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __ENABLE_SCRIPTING__
|
||||||
|
|
||||||
# include "Duktape.hpp"
|
# include "Duktape.hpp"
|
||||||
|
|
||||||
# include <functional>
|
# include <functional>
|
||||||
|
@ -40,3 +42,5 @@ namespace OpenRCT2::Scripting
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace OpenRCT2::Scripting
|
} // namespace OpenRCT2::Scripting
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __ENABLE_SCRIPTING__
|
||||||
|
|
||||||
# include "../common.h"
|
# include "../common.h"
|
||||||
# include "../ride/Ride.h"
|
# include "../ride/Ride.h"
|
||||||
# include "../world/Map.h"
|
# include "../world/Map.h"
|
||||||
|
@ -96,3 +98,5 @@ namespace OpenRCT2::Scripting
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace OpenRCT2::Scripting
|
} // namespace OpenRCT2::Scripting
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __ENABLE_SCRIPTING__
|
||||||
|
|
||||||
# include "../actions/NetworkModifyGroupAction.hpp"
|
# include "../actions/NetworkModifyGroupAction.hpp"
|
||||||
# include "../actions/PlayerKickAction.hpp"
|
# include "../actions/PlayerKickAction.hpp"
|
||||||
# include "../actions/PlayerSetGroupAction.hpp"
|
# include "../actions/PlayerSetGroupAction.hpp"
|
||||||
|
@ -36,19 +38,26 @@ namespace OpenRCT2::Scripting
|
||||||
|
|
||||||
std::string name_get()
|
std::string name_get()
|
||||||
{
|
{
|
||||||
|
# ifndef DISABLE_NETWORK
|
||||||
auto index = network_get_group_index(_id);
|
auto index = network_get_group_index(_id);
|
||||||
if (index == -1)
|
if (index == -1)
|
||||||
return {};
|
return {};
|
||||||
return network_get_group_name(index);
|
return network_get_group_name(index);
|
||||||
|
# else
|
||||||
|
return {};
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
void name_set(std::string value)
|
void name_set(std::string value)
|
||||||
{
|
{
|
||||||
|
# ifndef DISABLE_NETWORK
|
||||||
auto action = NetworkModifyGroupAction(ModifyGroupType::SetName, _id, value);
|
auto action = NetworkModifyGroupAction(ModifyGroupType::SetName, _id, value);
|
||||||
GameActions::Execute(&action);
|
GameActions::Execute(&action);
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> permissions_get()
|
std::vector<std::string> permissions_get()
|
||||||
{
|
{
|
||||||
|
# ifndef DISABLE_NETWORK
|
||||||
auto index = network_get_group_index(_id);
|
auto index = network_get_group_index(_id);
|
||||||
if (index == -1)
|
if (index == -1)
|
||||||
return {};
|
return {};
|
||||||
|
@ -66,9 +75,13 @@ namespace OpenRCT2::Scripting
|
||||||
permissionIndex++;
|
permissionIndex++;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
# else
|
||||||
|
return {};
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
void permissions_set(std::vector<std::string> value)
|
void permissions_set(std::vector<std::string> value)
|
||||||
{
|
{
|
||||||
|
# ifndef DISABLE_NETWORK
|
||||||
auto groupIndex = network_get_group_index(_id);
|
auto groupIndex = network_get_group_index(_id);
|
||||||
if (groupIndex == -1)
|
if (groupIndex == -1)
|
||||||
return;
|
return;
|
||||||
|
@ -105,6 +118,7 @@ namespace OpenRCT2::Scripting
|
||||||
GameActions::Execute(&networkAction2);
|
GameActions::Execute(&networkAction2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Register(duk_context* ctx)
|
static void Register(duk_context* ctx)
|
||||||
|
@ -154,47 +168,69 @@ namespace OpenRCT2::Scripting
|
||||||
|
|
||||||
std::string name_get()
|
std::string name_get()
|
||||||
{
|
{
|
||||||
|
# ifndef DISABLE_NETWORK
|
||||||
auto index = network_get_player_index(_id);
|
auto index = network_get_player_index(_id);
|
||||||
if (index == -1)
|
if (index == -1)
|
||||||
return {};
|
return {};
|
||||||
return network_get_player_name(index);
|
return network_get_player_name(index);
|
||||||
|
# else
|
||||||
|
return {};
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t group_get()
|
int32_t group_get()
|
||||||
{
|
{
|
||||||
|
# ifndef DISABLE_NETWORK
|
||||||
auto index = network_get_player_index(_id);
|
auto index = network_get_player_index(_id);
|
||||||
if (index == -1)
|
if (index == -1)
|
||||||
return {};
|
return {};
|
||||||
return network_get_player_group(index);
|
return network_get_player_group(index);
|
||||||
|
# else
|
||||||
|
return 0;
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
void group_set(int32_t value)
|
void group_set(int32_t value)
|
||||||
{
|
{
|
||||||
|
# ifndef DISABLE_NETWORK
|
||||||
auto playerSetGroupAction = PlayerSetGroupAction(_id, value);
|
auto playerSetGroupAction = PlayerSetGroupAction(_id, value);
|
||||||
GameActions::Execute(&playerSetGroupAction);
|
GameActions::Execute(&playerSetGroupAction);
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ping_get()
|
int32_t ping_get()
|
||||||
{
|
{
|
||||||
|
# ifndef DISABLE_NETWORK
|
||||||
auto index = network_get_player_index(_id);
|
auto index = network_get_player_index(_id);
|
||||||
if (index == -1)
|
if (index == -1)
|
||||||
return {};
|
return {};
|
||||||
return network_get_player_ping(index);
|
return network_get_player_ping(index);
|
||||||
|
# else
|
||||||
|
return 0;
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t commandsRan_get()
|
int32_t commandsRan_get()
|
||||||
{
|
{
|
||||||
|
# ifndef DISABLE_NETWORK
|
||||||
auto index = network_get_player_index(_id);
|
auto index = network_get_player_index(_id);
|
||||||
if (index == -1)
|
if (index == -1)
|
||||||
return {};
|
return {};
|
||||||
return network_get_player_commands_ran(index);
|
return network_get_player_commands_ran(index);
|
||||||
|
# else
|
||||||
|
return 0;
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t moneySpent_get()
|
int32_t moneySpent_get()
|
||||||
{
|
{
|
||||||
|
# ifndef DISABLE_NETWORK
|
||||||
auto index = network_get_player_index(_id);
|
auto index = network_get_player_index(_id);
|
||||||
if (index == -1)
|
if (index == -1)
|
||||||
return {};
|
return {};
|
||||||
return network_get_player_money_spent(index);
|
return network_get_player_money_spent(index);
|
||||||
|
# else
|
||||||
|
return 0;
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Register(duk_context* ctx)
|
static void Register(duk_context* ctx)
|
||||||
|
@ -211,6 +247,9 @@ namespace OpenRCT2::Scripting
|
||||||
class ScNetwork
|
class ScNetwork
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
# ifdef __clang__
|
||||||
|
[[maybe_unused]]
|
||||||
|
# endif
|
||||||
duk_context* _context;
|
duk_context* _context;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -221,6 +260,7 @@ namespace OpenRCT2::Scripting
|
||||||
|
|
||||||
std::string mode_get()
|
std::string mode_get()
|
||||||
{
|
{
|
||||||
|
# ifndef DISABLE_NETWORK
|
||||||
switch (network_get_mode())
|
switch (network_get_mode())
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
|
@ -231,49 +271,71 @@ namespace OpenRCT2::Scripting
|
||||||
case NETWORK_MODE_CLIENT:
|
case NETWORK_MODE_CLIENT:
|
||||||
return "client";
|
return "client";
|
||||||
}
|
}
|
||||||
|
# else
|
||||||
|
return "none";
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
int32_t players_get()
|
int32_t players_get()
|
||||||
{
|
{
|
||||||
|
# ifndef DISABLE_NETWORK
|
||||||
return network_get_num_players();
|
return network_get_num_players();
|
||||||
|
# else
|
||||||
|
return 0;
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
int32_t groups_get()
|
int32_t groups_get()
|
||||||
{
|
{
|
||||||
|
# ifndef DISABLE_NETWORK
|
||||||
return network_get_num_groups();
|
return network_get_num_groups();
|
||||||
|
# else
|
||||||
|
return 0;
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
int32_t defaultGroup_get()
|
int32_t defaultGroup_get()
|
||||||
{
|
{
|
||||||
|
# ifndef DISABLE_NETWORK
|
||||||
return network_get_default_group();
|
return network_get_default_group();
|
||||||
|
# else
|
||||||
|
return 0;
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
void defaultGroup_set(int32_t value)
|
void defaultGroup_set(int32_t value)
|
||||||
{
|
{
|
||||||
|
# ifndef DISABLE_NETWORK
|
||||||
auto action = NetworkModifyGroupAction(ModifyGroupType::SetDefault, value);
|
auto action = NetworkModifyGroupAction(ModifyGroupType::SetDefault, value);
|
||||||
GameActions::Execute(&action);
|
GameActions::Execute(&action);
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<ScPlayer> getPlayer(int32_t index)
|
std::shared_ptr<ScPlayer> getPlayer(int32_t index)
|
||||||
{
|
{
|
||||||
|
# ifndef DISABLE_NETWORK
|
||||||
auto numPlayers = network_get_num_players();
|
auto numPlayers = network_get_num_players();
|
||||||
if (index < numPlayers)
|
if (index < numPlayers)
|
||||||
{
|
{
|
||||||
auto playerId = network_get_player_id(index);
|
auto playerId = network_get_player_id(index);
|
||||||
return std::make_shared<ScPlayer>(playerId);
|
return std::make_shared<ScPlayer>(playerId);
|
||||||
}
|
}
|
||||||
|
# endif
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<ScPlayerGroup> getGroup(int32_t index)
|
std::shared_ptr<ScPlayerGroup> getGroup(int32_t index)
|
||||||
{
|
{
|
||||||
|
# ifndef DISABLE_NETWORK
|
||||||
auto numGroups = network_get_num_groups();
|
auto numGroups = network_get_num_groups();
|
||||||
if (index < numGroups)
|
if (index < numGroups)
|
||||||
{
|
{
|
||||||
auto groupId = network_get_group_id(index);
|
auto groupId = network_get_group_id(index);
|
||||||
return std::make_shared<ScPlayerGroup>(groupId);
|
return std::make_shared<ScPlayerGroup>(groupId);
|
||||||
}
|
}
|
||||||
|
# endif
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void kickPlayer(int32_t index)
|
void kickPlayer(int32_t index)
|
||||||
{
|
{
|
||||||
|
# ifndef DISABLE_NETWORK
|
||||||
auto numPlayers = network_get_num_players();
|
auto numPlayers = network_get_num_players();
|
||||||
if (index < numPlayers)
|
if (index < numPlayers)
|
||||||
{
|
{
|
||||||
|
@ -281,10 +343,12 @@ namespace OpenRCT2::Scripting
|
||||||
auto kickPlayerAction = PlayerKickAction(playerId);
|
auto kickPlayerAction = PlayerKickAction(playerId);
|
||||||
GameActions::Execute(&kickPlayerAction);
|
GameActions::Execute(&kickPlayerAction);
|
||||||
}
|
}
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendMessage(std::string message, DukValue players)
|
void sendMessage(std::string message, DukValue players)
|
||||||
{
|
{
|
||||||
|
# ifndef DISABLE_NETWORK
|
||||||
if (players.is_array())
|
if (players.is_array())
|
||||||
{
|
{
|
||||||
duk_error(players.context(), DUK_ERR_ERROR, "Not yet supported");
|
duk_error(players.context(), DUK_ERR_ERROR, "Not yet supported");
|
||||||
|
@ -293,6 +357,7 @@ namespace OpenRCT2::Scripting
|
||||||
{
|
{
|
||||||
network_send_chat(message.c_str());
|
network_send_chat(message.c_str());
|
||||||
}
|
}
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Register(duk_context* ctx)
|
static void Register(duk_context* ctx)
|
||||||
|
@ -308,3 +373,5 @@ namespace OpenRCT2::Scripting
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace OpenRCT2::Scripting
|
} // namespace OpenRCT2::Scripting
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __ENABLE_SCRIPTING__
|
||||||
|
|
||||||
# include "../Context.h"
|
# include "../Context.h"
|
||||||
# include "../common.h"
|
# include "../common.h"
|
||||||
# include "../management/Finance.h"
|
# include "../management/Finance.h"
|
||||||
|
@ -123,3 +125,5 @@ namespace OpenRCT2::Scripting
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace OpenRCT2::Scripting
|
} // namespace OpenRCT2::Scripting
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -9,10 +9,13 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __ENABLE_SCRIPTING__
|
||||||
|
|
||||||
# include "../common.h"
|
# include "../common.h"
|
||||||
# include "../object/RideObject.h"
|
# include "../object/RideObject.h"
|
||||||
# include "../ride/Ride.h"
|
# include "../ride/Ride.h"
|
||||||
# include "Duktape.hpp"
|
# include "Duktape.hpp"
|
||||||
|
# include "ScriptEngine.h"
|
||||||
|
|
||||||
namespace OpenRCT2::Scripting
|
namespace OpenRCT2::Scripting
|
||||||
{
|
{
|
||||||
|
@ -171,3 +174,5 @@ namespace OpenRCT2::Scripting
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace OpenRCT2::Scripting
|
} // namespace OpenRCT2::Scripting
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -9,9 +9,12 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __ENABLE_SCRIPTING__
|
||||||
|
|
||||||
# include "../common.h"
|
# include "../common.h"
|
||||||
# include "../world/Sprite.h"
|
# include "../world/Sprite.h"
|
||||||
# include "Duktape.hpp"
|
# include "Duktape.hpp"
|
||||||
|
# include "ScriptEngine.h"
|
||||||
|
|
||||||
namespace OpenRCT2::Scripting
|
namespace OpenRCT2::Scripting
|
||||||
{
|
{
|
||||||
|
@ -99,3 +102,5 @@ namespace OpenRCT2::Scripting
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace OpenRCT2::Scripting
|
} // namespace OpenRCT2::Scripting
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -9,12 +9,15 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __ENABLE_SCRIPTING__
|
||||||
|
|
||||||
# include "../common.h"
|
# include "../common.h"
|
||||||
# include "../world/Footpath.h"
|
# include "../world/Footpath.h"
|
||||||
# include "../world/Scenery.h"
|
# include "../world/Scenery.h"
|
||||||
# include "../world/Sprite.h"
|
# include "../world/Sprite.h"
|
||||||
# include "../world/Surface.h"
|
# include "../world/Surface.h"
|
||||||
# include "Duktape.hpp"
|
# include "Duktape.hpp"
|
||||||
|
# include "ScriptEngine.h"
|
||||||
|
|
||||||
# include <cstdio>
|
# include <cstdio>
|
||||||
|
|
||||||
|
@ -193,3 +196,5 @@ namespace OpenRCT2::Scripting
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace OpenRCT2::Scripting
|
} // namespace OpenRCT2::Scripting
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue