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": [
|
||||
"${workspaceRoot}",
|
||||
"${workspaceRoot}/src",
|
||||
"${workspaceRoot}/src/thirdparty",
|
||||
"${workspaceRoot}/lib/Win32/include",
|
||||
"${workspaceRoot}/lib/x64/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_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")
|
||||
|
|
|
@ -102,7 +102,7 @@
|
|||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
|
||||
<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)\lib;$(LibraryPath)</LibraryPath>
|
||||
<LinkIncremental />
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -229,21 +229,14 @@ namespace OpenRCT2::Ui::Windows
|
|||
|
||||
class CustomWindowInfo
|
||||
{
|
||||
private:
|
||||
rct_windowclass _class;
|
||||
rct_windownumber _number;
|
||||
|
||||
public:
|
||||
std::shared_ptr<Plugin> Owner;
|
||||
CustomWindowDesc Desc;
|
||||
std::vector<rct_widget> Widgets;
|
||||
std::vector<size_t> WidgetIndexMap;
|
||||
|
||||
CustomWindowInfo(
|
||||
rct_windowclass cls, rct_windownumber number, std::shared_ptr<Plugin> owner, const CustomWindowDesc& desc)
|
||||
: _class(cls)
|
||||
, _number(number)
|
||||
, Owner(owner)
|
||||
CustomWindowInfo(std::shared_ptr<Plugin> 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;
|
||||
|
|
|
@ -7,10 +7,14 @@
|
|||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||
*****************************************************************************/
|
||||
|
||||
#include "../interface/Window.h"
|
||||
#pragma once
|
||||
|
||||
#include <optional>
|
||||
#include <string_view>
|
||||
#ifdef __ENABLE_SCRIPTING__
|
||||
|
||||
# include "../interface/Window.h"
|
||||
|
||||
# include <optional>
|
||||
# include <string_view>
|
||||
|
||||
namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
|
@ -18,3 +22,5 @@ namespace OpenRCT2::Ui::Windows
|
|||
rct_window* FindCustomWindowByClassification(const std::string_view& classification);
|
||||
std::optional<rct_widgetindex> FindWidgetIndexByName(rct_window* w, const std::string_view& name);
|
||||
} // namespace OpenRCT2::Ui::Windows
|
||||
|
||||
#endif
|
||||
|
|
|
@ -9,16 +9,18 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "CustomMenu.h"
|
||||
#include "ScViewport.hpp"
|
||||
#include "ScWindow.hpp"
|
||||
#ifdef __ENABLE_SCRIPTING__
|
||||
|
||||
#include <memory>
|
||||
#include <openrct2/Context.h>
|
||||
#include <openrct2/common.h>
|
||||
#include <openrct2/scripting/Duktape.hpp>
|
||||
#include <openrct2/scripting/ScriptEngine.h>
|
||||
#include <string>
|
||||
# include "CustomMenu.h"
|
||||
# include "ScViewport.hpp"
|
||||
# include "ScWindow.hpp"
|
||||
|
||||
# include <memory>
|
||||
# include <openrct2/Context.h>
|
||||
# include <openrct2/common.h>
|
||||
# include <openrct2/scripting/Duktape.hpp>
|
||||
# include <openrct2/scripting/ScriptEngine.h>
|
||||
# include <string>
|
||||
|
||||
namespace OpenRCT2::Scripting
|
||||
{
|
||||
|
@ -154,3 +156,5 @@ namespace OpenRCT2::Scripting
|
|||
}
|
||||
};
|
||||
} // namespace OpenRCT2::Scripting
|
||||
|
||||
#endif
|
||||
|
|
|
@ -9,15 +9,17 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "../interface/Window.h"
|
||||
#ifdef __ENABLE_SCRIPTING__
|
||||
|
||||
#include <memory>
|
||||
#include <openrct2/Context.h>
|
||||
#include <openrct2/common.h>
|
||||
#include <openrct2/interface/Viewport.h>
|
||||
#include <openrct2/scripting/Duktape.hpp>
|
||||
#include <openrct2/scripting/ScriptEngine.h>
|
||||
#include <openrct2/world/Map.h>
|
||||
# include "../interface/Window.h"
|
||||
|
||||
# include <memory>
|
||||
# include <openrct2/Context.h>
|
||||
# include <openrct2/common.h>
|
||||
# include <openrct2/interface/Viewport.h>
|
||||
# include <openrct2/scripting/Duktape.hpp>
|
||||
# include <openrct2/scripting/ScriptEngine.h>
|
||||
# include <openrct2/world/Map.h>
|
||||
|
||||
namespace OpenRCT2::Scripting
|
||||
{
|
||||
|
@ -301,3 +303,5 @@ namespace OpenRCT2::Scripting
|
|||
}
|
||||
};
|
||||
} // namespace OpenRCT2::Scripting
|
||||
|
||||
#endif
|
||||
|
|
|
@ -9,16 +9,18 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "../interface/Widget.h"
|
||||
#include "../interface/Window.h"
|
||||
#include "CustomWindow.h"
|
||||
#include "ScViewport.hpp"
|
||||
#ifdef __ENABLE_SCRIPTING__
|
||||
|
||||
#include <memory>
|
||||
#include <openrct2/Context.h>
|
||||
#include <openrct2/common.h>
|
||||
#include <openrct2/scripting/Duktape.hpp>
|
||||
#include <openrct2/scripting/ScriptEngine.h>
|
||||
# include "../interface/Widget.h"
|
||||
# include "../interface/Window.h"
|
||||
# include "CustomWindow.h"
|
||||
# include "ScViewport.hpp"
|
||||
|
||||
# include <memory>
|
||||
# include <openrct2/Context.h>
|
||||
# include <openrct2/common.h>
|
||||
# include <openrct2/scripting/Duktape.hpp>
|
||||
# include <openrct2/scripting/ScriptEngine.h>
|
||||
|
||||
namespace OpenRCT2::Scripting
|
||||
{
|
||||
|
@ -291,3 +293,5 @@ namespace OpenRCT2::Scripting
|
|||
}
|
||||
};
|
||||
} // namespace OpenRCT2::Scripting
|
||||
|
||||
#endif
|
||||
|
|
|
@ -9,12 +9,14 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "ScWidget.hpp"
|
||||
#ifdef __ENABLE_SCRIPTING__
|
||||
|
||||
#include <openrct2/common.h>
|
||||
#include <openrct2/interface/Window.h>
|
||||
#include <openrct2/interface/Window_internal.h>
|
||||
#include <openrct2/scripting/Duktape.hpp>
|
||||
# include "ScWidget.hpp"
|
||||
|
||||
# include <openrct2/common.h>
|
||||
# include <openrct2/interface/Window.h>
|
||||
# include <openrct2/interface/Window_internal.h>
|
||||
# include <openrct2/scripting/Duktape.hpp>
|
||||
|
||||
namespace OpenRCT2::Scripting
|
||||
{
|
||||
|
@ -140,3 +142,5 @@ namespace OpenRCT2::Scripting
|
|||
}
|
||||
};
|
||||
} // namespace OpenRCT2::Scripting
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
# include <filesystem>
|
||||
namespace fs = std::filesystem;
|
||||
#else
|
||||
# include "../thirdparty/filesystem.hpp"
|
||||
# include <filesystem.hpp>
|
||||
namespace fs = ghc::filesystem;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -11,9 +11,10 @@
|
|||
#include "../OpenRCT2.h"
|
||||
#include "../platform/Platform2.h"
|
||||
#include "../scripting/ScriptEngine.h"
|
||||
#include "../thirdparty/linenoise.hpp"
|
||||
#include "InteractiveConsole.h"
|
||||
|
||||
#include <linenoise.hpp>
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
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
|
||||
|
||||
#include <dukglue/dukglue.h>
|
||||
#include <duktape.h>
|
||||
#ifdef __ENABLE_SCRIPTING__
|
||||
|
||||
# include <dukglue/dukglue.h>
|
||||
# include <duktape.h>
|
||||
|
||||
#endif
|
||||
|
|
|
@ -9,14 +9,16 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "../common.h"
|
||||
#include "Duktape.hpp"
|
||||
#ifdef __ENABLE_SCRIPTING__
|
||||
|
||||
#include <any>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
# include "../common.h"
|
||||
# include "Duktape.hpp"
|
||||
|
||||
# include <any>
|
||||
# include <memory>
|
||||
# include <string>
|
||||
# include <tuple>
|
||||
# include <vector>
|
||||
|
||||
namespace OpenRCT2::Scripting
|
||||
{
|
||||
|
@ -70,7 +72,6 @@ namespace OpenRCT2::Scripting
|
|||
private:
|
||||
ScriptExecutionInfo& _execInfo;
|
||||
std::vector<HookList> _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
|
||||
|
|
|
@ -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 <algorithm>
|
||||
#include <fstream>
|
||||
#include <memory>
|
||||
# include "../OpenRCT2.h"
|
||||
# include "Duktape.hpp"
|
||||
|
||||
# include <algorithm>
|
||||
# include <fstream>
|
||||
# include <memory>
|
||||
|
||||
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
|
||||
|
|
|
@ -9,12 +9,14 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "Duktape.hpp"
|
||||
#ifdef __ENABLE_SCRIPTING__
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
# include "Duktape.hpp"
|
||||
|
||||
# include <memory>
|
||||
# include <string>
|
||||
# include <string_view>
|
||||
# include <vector>
|
||||
|
||||
namespace OpenRCT2::Scripting
|
||||
{
|
||||
|
@ -103,3 +105,5 @@ namespace OpenRCT2::Scripting
|
|||
static PluginType ParsePluginType(const std::string_view& type);
|
||||
};
|
||||
} // namespace OpenRCT2::Scripting
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -9,13 +9,15 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "Duktape.hpp"
|
||||
#include "HookEngine.h"
|
||||
#include "ScDisposable.hpp"
|
||||
#include "ScriptEngine.h"
|
||||
#ifdef __ENABLE_SCRIPTING__
|
||||
|
||||
#include <cstdio>
|
||||
#include <memory>
|
||||
# include "Duktape.hpp"
|
||||
# include "HookEngine.h"
|
||||
# include "ScDisposable.hpp"
|
||||
# include "ScriptEngine.h"
|
||||
|
||||
# include <cstdio>
|
||||
# include <memory>
|
||||
|
||||
namespace OpenRCT2::Scripting
|
||||
{
|
||||
|
@ -66,3 +68,5 @@ namespace OpenRCT2::Scripting
|
|||
}
|
||||
};
|
||||
} // namespace OpenRCT2::Scripting
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -9,9 +9,11 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "Duktape.hpp"
|
||||
#ifdef __ENABLE_SCRIPTING__
|
||||
|
||||
#include <functional>
|
||||
# include "Duktape.hpp"
|
||||
|
||||
# include <functional>
|
||||
|
||||
namespace OpenRCT2::Scripting
|
||||
{
|
||||
|
@ -40,3 +42,5 @@ namespace OpenRCT2::Scripting
|
|||
}
|
||||
};
|
||||
} // namespace OpenRCT2::Scripting
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<std::string> 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<std::string> 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<ScPlayer> 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<ScPlayer>(playerId);
|
||||
}
|
||||
# endif
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<ScPlayerGroup> 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<ScPlayerGroup>(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
|
||||
|
|
|
@ -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 <algorithm>
|
||||
# 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 <algorithm>
|
||||
|
||||
namespace OpenRCT2::Scripting
|
||||
{
|
||||
|
@ -123,3 +125,5 @@ namespace OpenRCT2::Scripting
|
|||
}
|
||||
};
|
||||
} // namespace OpenRCT2::Scripting
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 <cstdio>
|
||||
# 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 <cstdio>
|
||||
|
||||
namespace OpenRCT2::Scripting
|
||||
{
|
||||
|
@ -193,3 +196,5 @@ namespace OpenRCT2::Scripting
|
|||
}
|
||||
};
|
||||
} // namespace OpenRCT2::Scripting
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue