Fix GCC issues

This commit is contained in:
Ted John 2020-02-22 18:04:27 +00:00
parent facd557355
commit 639faa2085
15 changed files with 45 additions and 51 deletions

View File

@ -101,7 +101,7 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<PropertyGroup>
<IncludePath>$(SolutionDir)src;$(SolutionDir)lib\$(Platform)\include;$(SolutionDir)lib\$(Platform)\include\SDL2;$(IncludePath)</IncludePath>
<IncludePath>$(SolutionDir)src;$(SolutionDir)src\openrct2\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 />

View File

@ -216,7 +216,7 @@ namespace OpenRCT2::Ui::Windows
});
}
return std::move(result);
return result;
}
static std::optional<int32_t> GetOptionalInt(DukValue input)
@ -695,7 +695,7 @@ namespace OpenRCT2::Ui::Windows
if (w->custom_info != nullptr)
{
auto& customInfo = GetInfo(w);
for (rct_widgetindex i = 0; i < customInfo.Widgets.size(); i++)
for (size_t i = 0; i < customInfo.Widgets.size(); i++)
{
auto customWidgetInfo = customInfo.GetCustomWidgetDesc(i);
if (customWidgetInfo != nullptr)

View File

@ -226,16 +226,16 @@ namespace OpenRCT2::Scripting
public:
static void Register(duk_context* ctx)
{
dukglue_register_property(ctx, &left_get, &left_set, "left");
dukglue_register_property(ctx, &top_get, &top_set, "top");
dukglue_register_property(ctx, &right_get, &right_set, "right");
dukglue_register_property(ctx, &bottom_get, &bottom_set, "bottom");
dukglue_register_property(ctx, &rotation_get, &rotation_set, "rotation");
dukglue_register_property(ctx, &zoom_get, &zoom_set, "zoom");
dukglue_register_property(ctx, &visibilityFlags_get, &visibilityFlags_set, "visibilityFlags");
dukglue_register_method(ctx, &getCentrePosition, "getCentrePosition");
dukglue_register_method(ctx, &moveTo, "moveTo");
dukglue_register_method(ctx, &scrollTo, "scrollTo");
dukglue_register_property(ctx, &ScViewport::left_get, &ScViewport::left_set, "left");
dukglue_register_property(ctx, &ScViewport::top_get, &ScViewport::top_set, "top");
dukglue_register_property(ctx, &ScViewport::right_get, &ScViewport::right_set, "right");
dukglue_register_property(ctx, &ScViewport::bottom_get, &ScViewport::bottom_set, "bottom");
dukglue_register_property(ctx, &ScViewport::rotation_get, &ScViewport::rotation_set, "rotation");
dukglue_register_property(ctx, &ScViewport::zoom_get, &ScViewport::zoom_set, "zoom");
dukglue_register_property(ctx, &ScViewport::visibilityFlags_get, &ScViewport::visibilityFlags_set, "visibilityFlags");
dukglue_register_method(ctx, &ScViewport::getCentrePosition, "getCentrePosition");
dukglue_register_method(ctx, &ScViewport::moveTo, "moveTo");
dukglue_register_method(ctx, &ScViewport::scrollTo, "scrollTo");
}
private:

View File

@ -243,17 +243,17 @@ namespace OpenRCT2::Scripting
static void Register(duk_context* ctx)
{
// Common
dukglue_register_property(ctx, &type_get, nullptr, "type");
dukglue_register_property(ctx, &x_get, &x_set, "x");
dukglue_register_property(ctx, &y_get, &y_set, "y");
dukglue_register_property(ctx, &width_get, &width_set, "width");
dukglue_register_property(ctx, &height_get, &height_set, "height");
dukglue_register_property(ctx, &isDisabled_get, &isDisabled_set, "isDisabled");
dukglue_register_property(ctx, &ScWidget::type_get, nullptr, "type");
dukglue_register_property(ctx, &ScWidget::x_get, &ScWidget::x_set, "x");
dukglue_register_property(ctx, &ScWidget::y_get, &ScWidget::y_set, "y");
dukglue_register_property(ctx, &ScWidget::width_get, &ScWidget::width_set, "width");
dukglue_register_property(ctx, &ScWidget::height_get, &ScWidget::height_set, "height");
dukglue_register_property(ctx, &ScWidget::isDisabled_get, &ScWidget::isDisabled_set, "isDisabled");
// No so common
dukglue_register_property(ctx, &text_get, &text_set, "text");
dukglue_register_property(ctx, &isChecked_get, &isChecked_set, "isChecked");
dukglue_register_property(ctx, &viewport_get, nullptr, "viewport");
dukglue_register_property(ctx, &ScWidget::text_get, &ScWidget::text_set, "text");
dukglue_register_property(ctx, &ScWidget::isChecked_get, &ScWidget::isChecked_set, "isChecked");
dukglue_register_property(ctx, &ScWidget::viewport_get, nullptr, "viewport");
}
private:

View File

@ -128,9 +128,9 @@ namespace OpenRCT2::Scripting
dukglue_register_property(ctx, &ScWindow::isSticky_get, nullptr, "isSticky");
dukglue_register_property(ctx, &ScWindow::widgets_get, nullptr, "widgets");
dukglue_register_method(ctx, &close, "close");
dukglue_register_method(ctx, &findWidget, "findWidget");
dukglue_register_method(ctx, &bringToFront, "bringToFront");
dukglue_register_method(ctx, &ScWindow::close, "close");
dukglue_register_method(ctx, &ScWindow::findWidget, "findWidget");
dukglue_register_method(ctx, &ScWindow::bringToFront, "bringToFront");
}
private:

View File

@ -3326,7 +3326,7 @@ static void top_toolbar_map_menu_dropdown(int16_t dropdownIndex)
else
{
const auto& customMenuItems = OpenRCT2::Scripting::CustomMenuItems;
auto customIndex = dropdownIndex - customStartIndex;
auto customIndex = static_cast<size_t>(dropdownIndex - customStartIndex);
if (customMenuItems.size() > customIndex)
{
customMenuItems[customIndex].Invoke();

View File

@ -200,8 +200,9 @@ endif()
target_include_directories(${PROJECT_NAME} PRIVATE ${LIBZIP_INCLUDE_DIRS})
target_include_directories(${PROJECT_NAME} PUBLIC ${JANSSON_INCLUDE_DIRS})
target_include_directories(${PROJECT_NAME} PRIVATE ${PNG_INCLUDE_DIRS}
${DUKTAPE_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIRS})
${DUKTAPE_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIRS})
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

View File

@ -138,8 +138,8 @@ namespace OpenRCT2
, _audioContext(audioContext)
, _uiContext(uiContext)
, _localisationService(std::make_unique<LocalisationService>(env))
, _painter(std::make_unique<Painter>(uiContext))
, _scriptEngine(_stdInOutConsole, *env)
, _painter(std::make_unique<Painter>(uiContext))
{
// Can't have more than one context currently.
Guard::Assert(Instance == nullptr);

View File

@ -156,6 +156,7 @@ void update_palette_effects();
void game_load_or_quit_no_save_prompt();
void load_from_sv6(const char* path);
void game_load_init();
void game_finish();
void pause_toggle();
bool game_is_paused();
bool game_is_not_paused();

View File

@ -95,7 +95,7 @@ struct rct_widget
rct_string_id tooltip; // 0x0E
// New properties
WidgetFlags flags;
WidgetFlags flags{};
};
/**

View File

@ -1,5 +1,4 @@
#pragma once
#include "../thirdparty/dukglue/dukglue.h"
#include <dukglue/dukglue.h>
#include <duktape.h>

View File

@ -9,7 +9,7 @@
#include "Plugin.h"
#include "..\OpenRCT2.h"
#include "../OpenRCT2.h"
#include "Duktape.hpp"
#include <algorithm>

View File

@ -24,13 +24,13 @@ namespace OpenRCT2::Scripting
public:
static void Register(duk_context* ctx)
{
dukglue_register_property(ctx, &monthsElapsed_get, &monthsElapsed_set, "monthsElapsed");
dukglue_register_property(ctx, &monthProgress_get, &monthProgress_set, "monthProgress");
dukglue_register_property(ctx, &yearsElapsed_get, nullptr, "yearsElapsed");
dukglue_register_property(ctx, &ticksElapsed_get, nullptr, "ticksElapsed");
dukglue_register_property(ctx, &day_get, nullptr, "day");
dukglue_register_property(ctx, &month_get, nullptr, "month");
dukglue_register_property(ctx, &year_get, nullptr, "year");
dukglue_register_property(ctx, &ScDate::monthsElapsed_get, &ScDate::monthsElapsed_set, "monthsElapsed");
dukglue_register_property(ctx, &ScDate::monthProgress_get, &ScDate::monthProgress_set, "monthProgress");
dukglue_register_property(ctx, &ScDate::yearsElapsed_get, nullptr, "yearsElapsed");
dukglue_register_property(ctx, &ScDate::ticksElapsed_get, nullptr, "ticksElapsed");
dukglue_register_property(ctx, &ScDate::day_get, nullptr, "day");
dukglue_register_property(ctx, &ScDate::month_get, nullptr, "month");
dukglue_register_property(ctx, &ScDate::year_get, nullptr, "year");
}
private:

View File

@ -29,10 +29,10 @@ namespace OpenRCT2::Scripting
static void Register(duk_context* ctx)
{
dukglue_register_property(ctx, &id_get, nullptr, "identifier");
dukglue_register_property(ctx, &name_get, nullptr, "name");
dukglue_register_property(ctx, &description_get, nullptr, "description");
dukglue_register_property(ctx, &capacity_get, nullptr, "capacity");
dukglue_register_property(ctx, &ScRideObject::id_get, nullptr, "identifier");
dukglue_register_property(ctx, &ScRideObject::name_get, nullptr, "name");
dukglue_register_property(ctx, &ScRideObject::description_get, nullptr, "description");
dukglue_register_property(ctx, &ScRideObject::capacity_get, nullptr, "capacity");
}
private:

View File

@ -82,13 +82,6 @@ namespace OpenRCT2::Scripting
_sprite->peep.trousers_colour = value;
}
template<typename T> static void dukglue_property_helper(duk_context* ctx, T& var, const char* name)
{
auto getter = []() -> const T { return var; };
auto setter = [&var](T& value) -> void { var = value; };
dukglue_register_property(ctx, getter, setter, name);
}
static void Register(duk_context* ctx)
{
dukglue_register_constructor<ScThing, rct_sprite*>(ctx, "Thing");