mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-24 00:03:11 +01:00
Fix Linux build
This commit is contained in:
@@ -21,16 +21,16 @@ template<typename T> DukValue GetObjectAsDukValue(duk_context* ctx, const std::s
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
const T AsOrDefault(const DukValue& value, const T& defaultValue = {}) = delete;
|
T AsOrDefault(const DukValue& value, const T& defaultValue = {}) = delete;
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline const std::string AsOrDefault(const DukValue& value, const std::string& defaultValue)
|
inline std::string AsOrDefault(const DukValue& value, const std::string& defaultValue)
|
||||||
{
|
{
|
||||||
return value.type() == DukValue::STRING ? value.as_string() : defaultValue;
|
return value.type() == DukValue::STRING ? value.as_string() : defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline const int32_t AsOrDefault(const DukValue& value, const int32_t& defaultValue)
|
inline int32_t AsOrDefault(const DukValue& value, const int32_t& defaultValue)
|
||||||
{
|
{
|
||||||
return value.type() == DukValue::NUMBER ? value.as_int() : defaultValue;
|
return value.type() == DukValue::NUMBER ? value.as_int() : defaultValue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -313,11 +313,13 @@ namespace OpenRCT2::Scripting
|
|||||||
{
|
{
|
||||||
auto el = _element->AsTrack();
|
auto el = _element->AsTrack();
|
||||||
el->SetSequenceIndex(value);
|
el->SetSequenceIndex(value);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case TILE_ELEMENT_TYPE_ENTRANCE:
|
case TILE_ELEMENT_TYPE_ENTRANCE:
|
||||||
{
|
{
|
||||||
auto el = _element->AsEntrance();
|
auto el = _element->AsEntrance();
|
||||||
el->SetSequenceIndex(value);
|
el->SetSequenceIndex(value);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -348,11 +350,13 @@ namespace OpenRCT2::Scripting
|
|||||||
{
|
{
|
||||||
auto el = _element->AsTrack();
|
auto el = _element->AsTrack();
|
||||||
el->SetRideIndex(value);
|
el->SetRideIndex(value);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case TILE_ELEMENT_TYPE_ENTRANCE:
|
case TILE_ELEMENT_TYPE_ENTRANCE:
|
||||||
{
|
{
|
||||||
auto el = _element->AsEntrance();
|
auto el = _element->AsEntrance();
|
||||||
el->SetRideIndex(value);
|
el->SetRideIndex(value);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -383,11 +387,13 @@ namespace OpenRCT2::Scripting
|
|||||||
{
|
{
|
||||||
auto el = _element->AsTrack();
|
auto el = _element->AsTrack();
|
||||||
el->SetStationIndex(value);
|
el->SetStationIndex(value);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case TILE_ELEMENT_TYPE_ENTRANCE:
|
case TILE_ELEMENT_TYPE_ENTRANCE:
|
||||||
{
|
{
|
||||||
auto el = _element->AsEntrance();
|
auto el = _element->AsEntrance();
|
||||||
el->SetStationIndex(value);
|
el->SetStationIndex(value);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -450,26 +456,31 @@ namespace OpenRCT2::Scripting
|
|||||||
{
|
{
|
||||||
auto el = _element->AsPath();
|
auto el = _element->AsPath();
|
||||||
el->SetPathEntryIndex(value & 0xFF);
|
el->SetPathEntryIndex(value & 0xFF);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case TILE_ELEMENT_TYPE_SMALL_SCENERY:
|
case TILE_ELEMENT_TYPE_SMALL_SCENERY:
|
||||||
{
|
{
|
||||||
auto el = _element->AsSmallScenery();
|
auto el = _element->AsSmallScenery();
|
||||||
el->SetEntryIndex(value & 0xFF);
|
el->SetEntryIndex(value & 0xFF);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case TILE_ELEMENT_TYPE_LARGE_SCENERY:
|
case TILE_ELEMENT_TYPE_LARGE_SCENERY:
|
||||||
{
|
{
|
||||||
auto el = _element->AsLargeScenery();
|
auto el = _element->AsLargeScenery();
|
||||||
el->SetEntryIndex(value);
|
el->SetEntryIndex(value);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case TILE_ELEMENT_TYPE_WALL:
|
case TILE_ELEMENT_TYPE_WALL:
|
||||||
{
|
{
|
||||||
auto el = _element->AsWall();
|
auto el = _element->AsWall();
|
||||||
el->SetEntryIndex(value & 0xFFFF);
|
el->SetEntryIndex(value & 0xFFFF);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case TILE_ELEMENT_TYPE_ENTRANCE:
|
case TILE_ELEMENT_TYPE_ENTRANCE:
|
||||||
{
|
{
|
||||||
auto el = _element->AsEntrance();
|
auto el = _element->AsEntrance();
|
||||||
el->SetEntranceType(value & 0xFF);
|
el->SetEntranceType(value & 0xFF);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -517,11 +528,13 @@ namespace OpenRCT2::Scripting
|
|||||||
{
|
{
|
||||||
auto el = _element->AsSmallScenery();
|
auto el = _element->AsSmallScenery();
|
||||||
el->SetPrimaryColour(value);
|
el->SetPrimaryColour(value);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case TILE_ELEMENT_TYPE_LARGE_SCENERY:
|
case TILE_ELEMENT_TYPE_LARGE_SCENERY:
|
||||||
{
|
{
|
||||||
auto el = _element->AsLargeScenery();
|
auto el = _element->AsLargeScenery();
|
||||||
el->SetPrimaryColour(value);
|
el->SetPrimaryColour(value);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -552,11 +565,13 @@ namespace OpenRCT2::Scripting
|
|||||||
{
|
{
|
||||||
auto el = _element->AsSmallScenery();
|
auto el = _element->AsSmallScenery();
|
||||||
el->SetSecondaryColour(value);
|
el->SetSecondaryColour(value);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case TILE_ELEMENT_TYPE_LARGE_SCENERY:
|
case TILE_ELEMENT_TYPE_LARGE_SCENERY:
|
||||||
{
|
{
|
||||||
auto el = _element->AsLargeScenery();
|
auto el = _element->AsLargeScenery();
|
||||||
el->SetSecondaryColour(value);
|
el->SetSecondaryColour(value);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -747,9 +762,10 @@ namespace OpenRCT2::Scripting
|
|||||||
std::shared_ptr<ScTileElement> insertElement(size_t index)
|
std::shared_ptr<ScTileElement> insertElement(size_t index)
|
||||||
{
|
{
|
||||||
ThrowIfGameStateNotMutable();
|
ThrowIfGameStateNotMutable();
|
||||||
|
std::shared_ptr<ScTileElement> result;
|
||||||
auto first = GetFirstElement();
|
auto first = GetFirstElement();
|
||||||
auto origNumElements = GetNumElements(first);
|
auto origNumElements = GetNumElements(first);
|
||||||
if (index >= 0 && index <= origNumElements)
|
if (index <= origNumElements)
|
||||||
{
|
{
|
||||||
std::vector<TileElement> data(first, first + origNumElements);
|
std::vector<TileElement> data(first, first + origNumElements);
|
||||||
|
|
||||||
@@ -782,7 +798,7 @@ namespace OpenRCT2::Scripting
|
|||||||
}
|
}
|
||||||
first[origNumElements].SetLastForTile(true);
|
first[origNumElements].SetLastForTile(true);
|
||||||
map_invalidate_tile_full(_coords);
|
map_invalidate_tile_full(_coords);
|
||||||
return std::make_shared<ScTileElement>(_coords, &first[index]);
|
result = std::make_shared<ScTileElement>(_coords, &first[index]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -790,6 +806,7 @@ namespace OpenRCT2::Scripting
|
|||||||
auto ctx = GetDukContext();
|
auto ctx = GetDukContext();
|
||||||
duk_error(ctx, DUK_ERR_RANGE_ERROR, "Index must be between zero and the number of elements on the tile.");
|
duk_error(ctx, DUK_ERR_RANGE_ERROR, "Index must be between zero and the number of elements on the tile.");
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeElement(size_t index)
|
void removeElement(size_t index)
|
||||||
|
|||||||
@@ -712,11 +712,11 @@ std::unique_ptr<GameActionResult> ScriptEngine::QueryOrExecuteCustomGameAction(
|
|||||||
DukValue dukResult;
|
DukValue dukResult;
|
||||||
if (!isExecute)
|
if (!isExecute)
|
||||||
{
|
{
|
||||||
dukResult = ExecutePluginCall(customAction.Plugin, customAction.Query, { dukArgs }, false);
|
dukResult = ExecutePluginCall(customAction.Owner, customAction.Query, { dukArgs }, false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dukResult = ExecutePluginCall(customAction.Plugin, customAction.Execute, { dukArgs }, true);
|
dukResult = ExecutePluginCall(customAction.Owner, customAction.Execute, { dukArgs }, true);
|
||||||
}
|
}
|
||||||
return DukToGameActionResult(dukResult);
|
return DukToGameActionResult(dukResult);
|
||||||
}
|
}
|
||||||
@@ -749,7 +749,7 @@ bool ScriptEngine::RegisterCustomAction(
|
|||||||
}
|
}
|
||||||
|
|
||||||
CustomAction customAction;
|
CustomAction customAction;
|
||||||
customAction.Plugin = plugin;
|
customAction.Owner = plugin;
|
||||||
customAction.Name = std::move(actionz);
|
customAction.Name = std::move(actionz);
|
||||||
customAction.Query = query;
|
customAction.Query = query;
|
||||||
customAction.Execute = execute;
|
customAction.Execute = execute;
|
||||||
@@ -761,7 +761,7 @@ void ScriptEngine::RemoveCustomGameActions(const std::shared_ptr<Plugin>& plugin
|
|||||||
{
|
{
|
||||||
for (auto it = _customActions.begin(); it != _customActions.end();)
|
for (auto it = _customActions.begin(); it != _customActions.end();)
|
||||||
{
|
{
|
||||||
if (it->second.Plugin == plugin)
|
if (it->second.Owner == plugin)
|
||||||
{
|
{
|
||||||
it = _customActions.erase(it);
|
it = _customActions.erase(it);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ namespace OpenRCT2::Scripting
|
|||||||
|
|
||||||
struct CustomAction
|
struct CustomAction
|
||||||
{
|
{
|
||||||
std::shared_ptr<Plugin> Plugin;
|
std::shared_ptr<Plugin> Owner;
|
||||||
std::string Name;
|
std::string Name;
|
||||||
DukValue Query;
|
DukValue Query;
|
||||||
DukValue Execute;
|
DukValue Execute;
|
||||||
|
|||||||
Reference in New Issue
Block a user