Fix unable to read litter information in plugin api

This commit is contained in:
Bas 2021-10-15 21:39:58 +02:00
parent 0b6c6bb22a
commit 8682a8677e
6 changed files with 14 additions and 7 deletions

View File

@ -40,6 +40,7 @@
- Fix: [#15514] Two different “quit to menu” menu items are available in track designer and track design manager.
- Fix: [#15560] Memory leak due to OpenGL Renderer not releasing a texture.
- Fix: [#15567] Litter not being counted correctly during Park rating calculation (original bug).
- Fix: [#15582] [Plugin] Litter properties return incorrect values.
- Improved: [#3417] Crash dumps are now placed in their own folder.
- Improved: [#13524] macOS arm64 native (universal) app
- Improved: [#15538] Software rendering can now draw in parallel when Multithreading is enabled.

View File

@ -1504,7 +1504,7 @@ declare global {
/**
* The tick number this entity was created.
*/
creationTime: number;
creationTick: number;
}
type LitterType = "vomit" |

View File

@ -409,6 +409,7 @@ void ScriptEngine::Initialise()
ScTile::Register(ctx);
ScTileElement::Register(ctx);
ScEntity::Register(ctx);
ScLitter::Register(ctx);
ScVehicle::Register(ctx);
ScPeep::Register(ctx);
ScGuest::Register(ctx);

View File

@ -46,7 +46,7 @@ namespace OpenRCT2
namespace OpenRCT2::Scripting
{
static constexpr int32_t OPENRCT2_PLUGIN_API_VERSION = 37;
static constexpr int32_t OPENRCT2_PLUGIN_API_VERSION = 38;
// Versions marking breaking changes.
static constexpr int32_t API_VERSION_33_PEEP_DEPRECATION = 33;

View File

@ -48,10 +48,15 @@ namespace OpenRCT2::Scripting
std::string ScLitter::litterType_get() const
{
auto* litter = GetLitter();
auto it = LitterTypeMap.find(litter->SubType);
if (it == LitterTypeMap.end())
return "";
return std::string{ it->first };
if (litter != nullptr)
{
auto it = LitterTypeMap.find(litter->SubType);
if (it != LitterTypeMap.end())
{
return std::string{ it->first };
}
}
return "";
}
void ScLitter::litterType_set(const std::string& litterType)

View File

@ -122,7 +122,7 @@ namespace OpenRCT2::Scripting
{
for (auto sprite : EntityList<Litter>())
{
result.push_back(GetObjectAsDukValue(_context, std::make_shared<ScEntity>(sprite->sprite_index)));
result.push_back(GetObjectAsDukValue(_context, std::make_shared<ScLitter>(sprite->sprite_index)));
}
}
else if (type == "duck")