From e8f4c08400a233839ef0fa1266db0933e275c057 Mon Sep 17 00:00:00 2001 From: Bas Date: Wed, 5 Jul 2023 21:57:26 +0200 Subject: [PATCH] Update OpenRCT2 to v0.4.5 --- .clang-format | 2 + openrct2.sln | 27 ++++++---- src/openrct2-bindings/Bindings/Game.cpp | 13 ++--- src/openrct2-bindings/Bindings/Graphics.cpp | 19 +++---- src/openrct2-bindings/Bindings/Map.cpp | 10 ++-- src/openrct2-bindings/Bindings/Peeps.cpp | 35 ++++++------- src/openrct2-bindings/Bindings/Sprites.cpp | 5 +- .../Bindings/TileElements/Path.cpp | 7 +-- .../Bindings/TileElements/SmallScenery.cpp | 26 ++++++---- .../Bindings/TileElements/Surface.cpp | 33 ++++++------ .../Bindings/TileElements/Wall.cpp | 50 +++++++++---------- src/openrct2-bindings/Bindings/Tracks.cpp | 27 ++++------ src/openrct2-bindings/Bindings/Vehicles.cpp | 12 ++--- .../{Bindings => }/openrct2-bindings.cpp | 5 +- .../{Bindings => }/openrct2-bindings.h | 2 - .../openrct2-bindings.vcxproj | 8 +-- 16 files changed, 126 insertions(+), 155 deletions(-) rename src/openrct2-bindings/{Bindings => }/openrct2-bindings.cpp (99%) rename src/openrct2-bindings/{Bindings => }/openrct2-bindings.h (99%) diff --git a/.clang-format b/.clang-format index b81be7ebba..392af73e94 100644 --- a/.clang-format +++ b/.clang-format @@ -24,6 +24,7 @@ BraceWrapping: AfterClass: true AfterControlStatement: true AfterEnum: true + AfterExternBlock: true AfterFunction: true AfterNamespace: true AfterStruct: true @@ -62,6 +63,7 @@ IncludeCategories: - Regex: '^<' Priority: 2 IndentCaseLabels: true +IndentExternBlock: true IndentPPDirectives: AfterHash IndentWidth: 4 IndentWrappedFunctionNames: true diff --git a/openrct2.sln b/openrct2.sln index 4f8d65e5e2..01868c3eb3 100644 --- a/openrct2.sln +++ b/openrct2.sln @@ -1,7 +1,6 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 -VisualStudioVersion = 17.1.32421.90 VisualStudioVersion = 17.4.33213.308 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libopenrct2", "src\openrct2\libopenrct2.vcxproj", "{D24D94F6-2A74-480C-B512-629C306CE92F}" @@ -131,20 +130,30 @@ Global {B6808F71-30B4-4499-8FF6-0B1C86391842}.Release|Win32.Build.0 = Release|Win32 {B6808F71-30B4-4499-8FF6-0B1C86391842}.Release|x64.ActiveCfg = Release|x64 {B6808F71-30B4-4499-8FF6-0B1C86391842}.Release|x64.Build.0 = Release|x64 - {449AD0FF-15AA-42E3-B51B-B6E9BC0AB1ED}.Debug|Win32.ActiveCfg = Debug|Win32 - {449AD0FF-15AA-42E3-B51B-B6E9BC0AB1ED}.Debug|Win32.Build.0 = Debug|Win32 - {449AD0FF-15AA-42E3-B51B-B6E9BC0AB1ED}.Debug|x64.ActiveCfg = Debug|x64 - {449AD0FF-15AA-42E3-B51B-B6E9BC0AB1ED}.Debug|x64.Build.0 = Debug|x64 - {449AD0FF-15AA-42E3-B51B-B6E9BC0AB1ED}.Release|Win32.ActiveCfg = Release|Win32 - {449AD0FF-15AA-42E3-B51B-B6E9BC0AB1ED}.Release|Win32.Build.0 = Release|Win32 - {449AD0FF-15AA-42E3-B51B-B6E9BC0AB1ED}.Release|x64.ActiveCfg = Release|x64 - {449AD0FF-15AA-42E3-B51B-B6E9BC0AB1ED}.Release|x64.Build.0 = Release|x64 {B6808F71-30B4-4499-8FF6-0B1C86391842}.ReleaseLTCG|arm64.ActiveCfg = ReleaseLTCG|arm64 {B6808F71-30B4-4499-8FF6-0B1C86391842}.ReleaseLTCG|arm64.Build.0 = ReleaseLTCG|arm64 {B6808F71-30B4-4499-8FF6-0B1C86391842}.ReleaseLTCG|Win32.ActiveCfg = ReleaseLTCG|Win32 {B6808F71-30B4-4499-8FF6-0B1C86391842}.ReleaseLTCG|Win32.Build.0 = ReleaseLTCG|Win32 {B6808F71-30B4-4499-8FF6-0B1C86391842}.ReleaseLTCG|x64.ActiveCfg = ReleaseLTCG|x64 {B6808F71-30B4-4499-8FF6-0B1C86391842}.ReleaseLTCG|x64.Build.0 = ReleaseLTCG|x64 + {449AD0FF-15AA-42E3-B51B-B6E9BC0AB1ED}.Debug|arm64.ActiveCfg = Debug|x64 + {449AD0FF-15AA-42E3-B51B-B6E9BC0AB1ED}.Debug|arm64.Build.0 = Debug|x64 + {449AD0FF-15AA-42E3-B51B-B6E9BC0AB1ED}.Debug|Win32.ActiveCfg = Debug|Win32 + {449AD0FF-15AA-42E3-B51B-B6E9BC0AB1ED}.Debug|Win32.Build.0 = Debug|Win32 + {449AD0FF-15AA-42E3-B51B-B6E9BC0AB1ED}.Debug|x64.ActiveCfg = Debug|x64 + {449AD0FF-15AA-42E3-B51B-B6E9BC0AB1ED}.Debug|x64.Build.0 = Debug|x64 + {449AD0FF-15AA-42E3-B51B-B6E9BC0AB1ED}.Release|arm64.ActiveCfg = Release|x64 + {449AD0FF-15AA-42E3-B51B-B6E9BC0AB1ED}.Release|arm64.Build.0 = Release|x64 + {449AD0FF-15AA-42E3-B51B-B6E9BC0AB1ED}.Release|Win32.ActiveCfg = Release|Win32 + {449AD0FF-15AA-42E3-B51B-B6E9BC0AB1ED}.Release|Win32.Build.0 = Release|Win32 + {449AD0FF-15AA-42E3-B51B-B6E9BC0AB1ED}.Release|x64.ActiveCfg = Release|x64 + {449AD0FF-15AA-42E3-B51B-B6E9BC0AB1ED}.Release|x64.Build.0 = Release|x64 + {449AD0FF-15AA-42E3-B51B-B6E9BC0AB1ED}.ReleaseLTCG|arm64.ActiveCfg = Release|x64 + {449AD0FF-15AA-42E3-B51B-B6E9BC0AB1ED}.ReleaseLTCG|arm64.Build.0 = Release|x64 + {449AD0FF-15AA-42E3-B51B-B6E9BC0AB1ED}.ReleaseLTCG|Win32.ActiveCfg = Release|Win32 + {449AD0FF-15AA-42E3-B51B-B6E9BC0AB1ED}.ReleaseLTCG|Win32.Build.0 = Release|Win32 + {449AD0FF-15AA-42E3-B51B-B6E9BC0AB1ED}.ReleaseLTCG|x64.ActiveCfg = Release|x64 + {449AD0FF-15AA-42E3-B51B-B6E9BC0AB1ED}.ReleaseLTCG|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/openrct2-bindings/Bindings/Game.cpp b/src/openrct2-bindings/Bindings/Game.cpp index 390af82453..8750b737a6 100644 --- a/src/openrct2-bindings/Bindings/Game.cpp +++ b/src/openrct2-bindings/Bindings/Game.cpp @@ -1,4 +1,5 @@ #include "../../openrct2/core/Path.hpp" +#include "../openrct2-bindings.h" #include #include @@ -7,9 +8,6 @@ #include #include -#include "openrct2-bindings.h" - - std::unique_ptr unityContext; extern "C" @@ -35,9 +33,8 @@ extern "C" } dll_log( - "gCustomOpenrctDataPath = %s\n(me) gCustomRCT1DataPath = %s\n(me) gCustomRCT2DataPath = %s", - datapath, rct1path, rct2path - ); + "gCustomOpenrctDataPath = %s\n(me) gCustomRCT1DataPath = %s\n(me) gCustomRCT2DataPath = %s", datapath, rct1path, + rct2path); // Create a plain context Platform::CoreInit(); @@ -47,13 +44,11 @@ extern "C" dll_log("Initialise = %i", result); } - EXPORT void PerformGameUpdate() { unityContext->GetGameState()->Tick(); } - EXPORT void StopGame() { dll_log("StopGame()"); @@ -62,7 +57,6 @@ extern "C" unityContext = nullptr; } - EXPORT void LoadPark(const char* filepath) { dll_log("LoadPark( %s )", filepath); @@ -75,7 +69,6 @@ extern "C" dll_log("LoadPark() = %s", name); } - EXPORT const char* GetParkNamePtr() { Park& park = unityContext->GetGameState()->GetPark(); diff --git a/src/openrct2-bindings/Bindings/Graphics.cpp b/src/openrct2-bindings/Bindings/Graphics.cpp index 016ff51cd0..53ad13537b 100644 --- a/src/openrct2-bindings/Bindings/Graphics.cpp +++ b/src/openrct2-bindings/Bindings/Graphics.cpp @@ -1,10 +1,9 @@ +#include "../openrct2-bindings.h" + +#include #include #include -#include "openrct2-bindings.h" -#include - - extern "C" { // Gets the full colour palette currently in use. @@ -17,14 +16,12 @@ extern "C" } } - // Converts any of the colour ids (0-31) to the corresponding palette index (0-255). EXPORT uint8_t GetPaletteIndexForColourId(uint8_t colourId) { return ColourMapA[colourId].mid_light; } - // Struct containing information about the sprite. struct sprite_data { @@ -34,12 +31,11 @@ extern "C" int16_t y_offset; }; - // Returns the image index of the tile element and its texture size. EXPORT void GetTextureData(uint32_t imageIndex, sprite_data* data) { const int32_t maskedImageId = imageIndex & 0x7FFFF; - const rct_g1_element* g1 = gfx_get_g1_element(maskedImageId); + const G1Element* g1 = GfxGetG1Element(maskedImageId); if (g1 == nullptr) { @@ -53,12 +49,11 @@ extern "C" data->y_offset = g1->y_offset; } - // Returns the actual texture data based on the image index. EXPORT void GetTexturePixels(uint32_t imageIndex, uint8_t* pixels, int arraySize) { const int32_t maskedImageId = imageIndex & 0x7FFFF; - const rct_g1_element* g1 = gfx_get_g1_element(maskedImageId); + const G1Element* g1 = GfxGetG1Element(maskedImageId); if (g1 == nullptr) { @@ -73,7 +68,7 @@ extern "C" auto bits = new uint8_t[numPixels]; std::fill_n(bits, numPixels, 0); - rct_drawpixelinfo dpi; + DrawPixelInfo dpi; dpi.bits = bits; dpi.x = g1->x_offset; dpi.y = g1->y_offset; @@ -82,7 +77,7 @@ extern "C" dpi.pitch = 0; dpi.zoom_level = ZoomLevel(0); - gfx_draw_sprite_software(&dpi, ImageId::FromUInt32(imageIndex), { 0, 0 }); + GfxDrawSpriteSoftware(dpi, ImageId::FromUInt32(imageIndex), { 0, 0 }); for (int i = 0; i < numPixels; i++) { diff --git a/src/openrct2-bindings/Bindings/Map.cpp b/src/openrct2-bindings/Bindings/Map.cpp index 06aec1c40f..e9699d7c43 100644 --- a/src/openrct2-bindings/Bindings/Map.cpp +++ b/src/openrct2-bindings/Bindings/Map.cpp @@ -1,9 +1,7 @@ +#include "../openrct2-bindings.h" #include -#include "openrct2-bindings.h" - - extern "C" { // Gets the amount of tiles on a single edge of the map. @@ -12,22 +10,20 @@ extern "C" return gMapSize.x; // TODO: make it work with a different y as well. } - // Gets the first tile-element at the the specified coordinates. EXPORT void GetMapElementAt(int x, int y, TileElement* element) { CoordsXY coords = CoordsXY(x * COORDS_XY_STEP, y * COORDS_XY_STEP).ToTileStart(); - *element = *map_get_first_element_at(coords); + *element = *MapGetFirstElementAt(coords); } - // Writes all tile-elements at the the specified coordinates to the specified buffer. EXPORT int GetMapElementsAt(int x, int y, TileElement* elements, int arraySize) { int elementCount = 0; CoordsXY coords = CoordsXY(x * COORDS_XY_STEP, y * COORDS_XY_STEP).ToTileStart(); - TileElement* element = map_get_first_element_at(coords); + TileElement* element = MapGetFirstElementAt(coords); for (int i = 0; i < arraySize; i++) { diff --git a/src/openrct2-bindings/Bindings/Peeps.cpp b/src/openrct2-bindings/Bindings/Peeps.cpp index cefb5de0db..191d01236d 100644 --- a/src/openrct2-bindings/Bindings/Peeps.cpp +++ b/src/openrct2-bindings/Bindings/Peeps.cpp @@ -1,10 +1,10 @@ +#include "../openrct2-bindings.h" + #include #include #include #include -#include "openrct2-bindings.h" - extern "C" { struct PeepEntity @@ -17,47 +17,47 @@ extern "C" uint8_t direction; uint32_t imageId; - //uint8_t tshirt_colour; - //uint8_t trousers_colour; + // uint8_t tshirt_colour; + // uint8_t trousers_colour; }; - // Gets the current sprite image id of this peep, excluding rotation. uint32_t GetCurrentImageId(Peep* peep) { // Borrowed from Paint.Peep.cpp/peep_paint() - rct_peep_animation_entry sprite = g_peep_animation_entries[EnumValue(peep->SpriteType)]; + PeepAnimationEntry sprite = g_peep_animation_entries[EnumValue(peep->SpriteType)]; - PeepActionSpriteType spriteType = peep->ActionSpriteType; + PeepSpriteType spriteType = peep->SpriteType; + PeepActionSpriteType actionSpriteType = peep->ActionSpriteType; uint8_t imageOffset = peep->ActionSpriteImageOffset; if (peep->Action == PeepActionType::Idle) { - spriteType = peep->NextActionSpriteType; + actionSpriteType = peep->NextActionSpriteType; imageOffset = 0; } - uint32_t baseImageId = (sprite.sprite_animation[EnumValue(spriteType)].base_image + imageOffset * 4); - /* + (imageDirection >> 3)*/ - uint32_t imageId = baseImageId | peep->TshirtColour << 19 | peep->TrousersColour << 24 | IMAGE_TYPE_REMAP | IMAGE_TYPE_REMAP_2_PLUS; - return imageId; - } + uint32_t baseImageId = (GetPeepAnimation(spriteType, actionSpriteType).base_image + imageOffset * 4); // + + // (imageDirection + // >> 3) + ImageId imageId = ImageId(baseImageId, peep->TshirtColour, peep->TrousersColour); + return imageId.ToUInt32(); + } void SetPeepInfo(PeepEntity* entity, Peep* peep) { - entity->idx = peep->sprite_index.ToUnderlying(); + entity->idx = peep->Id.ToUnderlying(); entity->x = peep->x; entity->y = peep->y; entity->z = peep->z; - entity->direction = peep->sprite_direction; + entity->direction = peep->PeepDirection; entity->imageId = GetCurrentImageId(peep); // entity->tshirt_colour = peep->TshirtColour; // entity->trousers_colour = peep->TrousersColour; } - // Loads all the peeps into the specified buffer, returns the total amount of peeps loaded. EXPORT int32_t GetAllPeeps(PeepEntity* peeps, int32_t arraySize) { @@ -78,12 +78,10 @@ extern "C" SetPeepInfo(&peeps[peepCount], staff); peepCount++; - } return peepCount; } - struct PeepStats { public: @@ -96,7 +94,6 @@ extern "C" uint8_t intensity; }; - // Writes statistics about the specified peep to the specified struct, returns true // or false depending on whether the peep existed or not. EXPORT bool GetPeepStats(uint16_t spriteIndex, PeepStats* peepStats) diff --git a/src/openrct2-bindings/Bindings/Sprites.cpp b/src/openrct2-bindings/Bindings/Sprites.cpp index 04a3d161b2..6619f6cbcc 100644 --- a/src/openrct2-bindings/Bindings/Sprites.cpp +++ b/src/openrct2-bindings/Bindings/Sprites.cpp @@ -1,8 +1,7 @@ +#include "../openrct2-bindings.h" + #include -#include "openrct2-bindings.h" - - extern "C" { // Gets the amount of sprites currently active for the given type. diff --git a/src/openrct2-bindings/Bindings/TileElements/Path.cpp b/src/openrct2-bindings/Bindings/TileElements/Path.cpp index 33d36c6d72..eff32758e6 100644 --- a/src/openrct2-bindings/Bindings/TileElements/Path.cpp +++ b/src/openrct2-bindings/Bindings/TileElements/Path.cpp @@ -1,9 +1,8 @@ +#include "../../openrct2-bindings.h" + #include #include -#include "..\openrct2-bindings.h" - - extern "C" { // Flat path table, from Paint.Path.cpp @@ -18,7 +17,6 @@ extern "C" 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 49, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 50 }; - // Returns the sprite image index for a small scenery tile element. // Inspired by: path_paint() EXPORT uint32_t GetPathSurfaceImageIndex(const TileElement* tileElement) @@ -40,7 +38,6 @@ extern "C" return (imageId + footpathEntry->BaseImageId); } - // Returns the sprite image index for a small scenery tile element. // Inspired by: path_paint() EXPORT uint32_t GetPathRailingImageIndex(const TileElement* tileElement) diff --git a/src/openrct2-bindings/Bindings/TileElements/SmallScenery.cpp b/src/openrct2-bindings/Bindings/TileElements/SmallScenery.cpp index 99c195a772..7ee653ca14 100644 --- a/src/openrct2-bindings/Bindings/TileElements/SmallScenery.cpp +++ b/src/openrct2-bindings/Bindings/TileElements/SmallScenery.cpp @@ -1,9 +1,11 @@ +#include #include +#include #include +#include #include -#include "..\openrct2-bindings.h" -#include +#include "../../openrct2-bindings.h" extern "C" @@ -27,19 +29,21 @@ extern "C" } // Scenery colours + ImageId imageId = ImageId(imageIndex); if (entry->HasFlag(SMALL_SCENERY_FLAG_HAS_PRIMARY_COLOUR)) { + imageId = imageId.WithPrimary(sceneryElement->GetPrimaryColour()); + if (entry->HasFlag(SMALL_SCENERY_FLAG_HAS_SECONDARY_COLOUR)) { - imageIndex |= SPRITE_ID_PALETTE_COLOUR_2( - sceneryElement->GetPrimaryColour(), sceneryElement->GetSecondaryColour()); - } - else - { - imageIndex |= SPRITE_ID_PALETTE_COLOUR_1(sceneryElement->GetPrimaryColour()); + imageId = imageId.WithSecondary(sceneryElement->GetSecondaryColour()); } } - return imageIndex; + if (entry->HasFlag(SMALL_SCENERY_FLAG_HAS_TERTIARY_COLOUR)) + { + imageId = imageId.WithTertiary(sceneryElement->GetTertiaryColour()); + } + return imageId.ToUInt32(); } @@ -117,7 +121,7 @@ extern "C" } - const uint8_t IdentifierSize = sizeof(rct_object_entry::name); + const uint8_t IdentifierSize = sizeof(RCTObjectEntry::name); struct SmallSceneryEntryInfo { @@ -147,7 +151,7 @@ extern "C" entry->animationDelay = sceneryEntry->animation_delay; entry->animationFrameCount = sceneryEntry->num_frames; - const rct_object_entry objectEntry = obj->GetObjectEntry(); + const RCTObjectEntry objectEntry = obj->GetObjectEntry(); std::memcpy(entry->identifier, objectEntry.name, IdentifierSize); } } diff --git a/src/openrct2-bindings/Bindings/TileElements/Surface.cpp b/src/openrct2-bindings/Bindings/TileElements/Surface.cpp index 2d87e1d4f1..bfb1459a71 100644 --- a/src/openrct2-bindings/Bindings/TileElements/Surface.cpp +++ b/src/openrct2-bindings/Bindings/TileElements/Surface.cpp @@ -1,23 +1,21 @@ -#include -#include +#include "../../openrct2-bindings.h" + #include +#include +#include #include #include -#include "..\openrct2-bindings.h" - - extern "C" -{ +{ // Returns the sprite image index for a surface sprite. - // Inspired by: get_surface_object(), get_surface_image() + // Inspired by: GetSurfaceObject(), GetSurfaceImage() EXPORT uint32_t GetSurfaceImageIndex(const TileElement* tileElement, int32_t tileX, int32_t tileY, uint8_t direction) { const SurfaceElement* surface = tileElement->AsSurface(); uint32_t surfaceIndex = surface->GetSurfaceStyle(); uint8_t grassLength = surface->GetGrassLength(); - - uint32_t imageId = (uint32_t)SPR_NONE; + ImageId imageId; IObjectManager& objMgr = OpenRCT2::GetContext()->GetObjectManager(); Object* obj = objMgr.GetLoadedObject(ObjectType::TerrainSurface, surfaceIndex); @@ -30,18 +28,17 @@ extern "C" { TerrainSurfaceObject* result = static_cast(obj); - imageId = result->GetImageId({ tileX, tileY }, grassLength, direction, 0, false, false); + imageId = ImageId(result->GetImageId({ tileX, tileY }, grassLength, direction, 0, false, false)); if (result->Colour != 255) { - imageId |= SPRITE_ID_PALETTE_COLOUR_1(result->Colour); + imageId = imageId.WithPrimary(result->Colour); } } - return imageId; + return imageId.ToUInt32(); } - // Returns the sprite image for a surface edge sprite. - // Inspired by: get_edge_image_with_offset() + // Inspired by: GetEdgeImageWithOffset() EXPORT uint32_t GetSurfaceEdgeImageIndex(const TileElement* tileElement) { const SurfaceElement* surface = tileElement->AsSurface(); @@ -62,14 +59,12 @@ extern "C" return 0; } - // Returns the sprite image for a regular water tile. - // Inspired by: surface_paint() + // Inspired by: PaintSurface() EXPORT uint32_t GetWaterImageIndex() { // SPR_WATER_OVERLAY = overlay for water - const int32_t imageId - = (SPR_WATER_MASK | IMAGE_TYPE_REMAP | IMAGE_TYPE_TRANSPARENT | EnumValue(FilterPaletteID::PaletteWater) << 19); - return imageId; + const auto imageId = ImageId(SPR_WATER_MASK, FilterPaletteID::PaletteWater).WithBlended(true); + return imageId.ToUInt32(); } } diff --git a/src/openrct2-bindings/Bindings/TileElements/Wall.cpp b/src/openrct2-bindings/Bindings/TileElements/Wall.cpp index 7abcc4d9cb..560706b695 100644 --- a/src/openrct2-bindings/Bindings/TileElements/Wall.cpp +++ b/src/openrct2-bindings/Bindings/TileElements/Wall.cpp @@ -1,40 +1,38 @@ -#include +#include "../../openrct2-bindings.h" + +#include #include - -#include "..\openrct2-bindings.h" - +#include extern "C" { // Returns the sprite image index for a small scenery tile element. - // Inspired by: fence_paint + // Inspired by: PaintWall(), PaintWallWall() EXPORT uint32_t GetWallImageIndex(const TileElement* tileElement, uint8_t direction) { const WallElement* wallElement = tileElement->AsWall(); - const WallSceneryEntry* sceneryEntry = wallElement->GetEntry(); + const WallSceneryEntry* wallEntry = wallElement->GetEntry(); - if (sceneryEntry == nullptr) + if (wallEntry == nullptr) { dll_log("Wall sprite entry = null"); return 0; } // Colours - int32_t primaryColour = wallElement->GetPrimaryColour(); - uint32_t imageColourFlags = SPRITE_ID_PALETTE_COLOUR_1(primaryColour); - //uint32_t dword_141F718 = imageColourFlags + 0x23800006; - - if (sceneryEntry->flags & WALL_SCENERY_HAS_SECONDARY_COLOUR) + uint8_t wallFlags = wallEntry->flags; + ImageId imageId; + if (wallFlags & WALL_SCENERY_HAS_PRIMARY_COLOUR) { - uint8_t secondaryColour = wallElement->GetSecondaryColour(); - imageColourFlags |= secondaryColour << 24 | IMAGE_TYPE_REMAP_2_PLUS; + imageId = imageId.WithPrimary(wallElement->GetPrimaryColour()); } - - uint32_t tertiaryColour = 0; - if (sceneryEntry->flags & WALL_SCENERY_HAS_TERTIARY_COLOUR) + if (wallFlags & WALL_SCENERY_HAS_SECONDARY_COLOUR) { - tertiaryColour = wallElement->GetTertiaryColour(); - imageColourFlags &= 0x0DFFFFFFF; + imageId = imageId.WithSecondary(wallElement->GetSecondaryColour()); + } + if (wallFlags & WALL_SCENERY_HAS_TERTIARY_COLOUR) + { + imageId = imageId.WithTertiary(wallElement->GetTertiaryColour()); } // Slopes @@ -54,22 +52,20 @@ extern "C" imageOffset = 0; } - uint32_t imageId = sceneryEntry->image + imageOffset; - - if (sceneryEntry->flags & WALL_SCENERY_HAS_GLASS) + if (wallFlags & WALL_SCENERY_HAS_GLASS) { - if (sceneryEntry->flags & WALL_SCENERY_HAS_PRIMARY_COLOUR) + if (wallFlags & WALL_SCENERY_IS_DOUBLE_SIDED) { - imageId |= imageColourFlags; + imageOffset += 12; } } else { - if (sceneryEntry->flags & WALL_SCENERY_HAS_PRIMARY_COLOUR) + if (wallFlags & WALL_SCENERY_IS_DOUBLE_SIDED) { - imageId |= imageColourFlags; + imageOffset += 6; } } - return imageId; + return imageId.WithIndex(wallEntry->image + imageOffset).ToUInt32(); } } diff --git a/src/openrct2-bindings/Bindings/Tracks.cpp b/src/openrct2-bindings/Bindings/Tracks.cpp index f4aabca53c..6be5b773ca 100644 --- a/src/openrct2-bindings/Bindings/Tracks.cpp +++ b/src/openrct2-bindings/Bindings/Tracks.cpp @@ -1,12 +1,11 @@ +#include "../openrct2-bindings.h" + #include #include #include #include #include -#include "openrct2-bindings.h" - - // Rounds a number to the nearest multiple of 'multiple'. int RoundToMultiple(int value, int multiple) { @@ -16,10 +15,9 @@ int RoundToMultiple(int value, int multiple) return (retval) / multiple * multiple; } - -// Hack: manually fix the gaps. +// Hack: manually fix the gaps. // (please tell me if you know a better way to fix there gaps, without any bumps!) -void FixTrackPiecePosition(rct_vehicle_info* target, uint32_t trackType, uint8_t slope) +void FixTrackPiecePosition(VehicleInfo* target, uint32_t trackType, uint8_t slope) { switch (slope) { @@ -45,7 +43,6 @@ void FixTrackPiecePosition(rct_vehicle_info* target, uint32_t trackType, uint8_t } } - extern "C" { // Returns the amount of path nodes in the pathing route for the specified track type. @@ -54,33 +51,30 @@ extern "C" return gTrackVehicleInfo[trackVariant][typeAndDirection]->size; } - // Returns the pathing route for the specified track element. - EXPORT void GetTrackElementRoute(uint8_t trackVariant, int32_t typeAndDirection, rct_vehicle_info* nodes, int32_t arraySize) + EXPORT void GetTrackElementRoute(uint8_t trackVariant, int32_t typeAndDirection, VehicleInfo* nodes, int32_t arraySize) { - const rct_vehicle_info_list* list = gTrackVehicleInfo[trackVariant][typeAndDirection]; + const VehicleInfoList* list = gTrackVehicleInfo[trackVariant][typeAndDirection]; - std::memcpy(nodes, list->info, sizeof(rct_vehicle_info) * arraySize); + std::memcpy(nodes, list->info, sizeof(VehicleInfo) * arraySize); const int32_t trackType = (typeAndDirection >> 2); - const rct_trackdefinition definition = TrackMetaData::GetTrackElementDescriptor(trackType).Definition; + const TrackDefinition definition = TrackMetaData::GetTrackElementDescriptor(trackType).Definition; FixTrackPiecePosition(&nodes[0], trackType, definition.vangle_start); FixTrackPiecePosition(&nodes[arraySize - 1], trackType, definition.vangle_end); } - // (Temporary?) Returns the flags for the specified track type. EXPORT uint16_t GetTrackTypeFlags(int32_t trackType) { return TrackMetaData::GetTrackElementDescriptor(trackType).Flags; } - // (Temporary?) Returns the track height offset for this ride index. EXPORT int8_t GetTrackHeightOffset(uint16_t rideIndex) { - auto ride = get_ride(RideId::FromUnderlying(rideIndex)); + auto ride = GetRide(RideId::FromUnderlying(rideIndex)); if (ride == nullptr) { dll_log("GetTrackHeightOffset: ride %i not found.", rideIndex); @@ -90,11 +84,10 @@ extern "C" return RideTypeDescriptors[ride->type].Heights.VehicleZOffset; } - // (Temporary?) Returns the ride colours for this ride. EXPORT void GetRideTrackColours(uint16_t rideIndex, TrackColour* colours) { - auto ride = get_ride(RideId::FromUnderlying(rideIndex)); + auto ride = GetRide(RideId::FromUnderlying(rideIndex)); if (ride == nullptr) { dll_log("GetRideTrackColours: ride %i not found.", rideIndex); diff --git a/src/openrct2-bindings/Bindings/Vehicles.cpp b/src/openrct2-bindings/Bindings/Vehicles.cpp index 78f41dd7b3..1c8d9bcca3 100644 --- a/src/openrct2-bindings/Bindings/Vehicles.cpp +++ b/src/openrct2-bindings/Bindings/Vehicles.cpp @@ -1,8 +1,7 @@ -#include +#include "../openrct2-bindings.h" + #include - -#include "openrct2-bindings.h" - +#include extern "C" { @@ -21,7 +20,6 @@ extern "C" uint16_t trackProgress; }; - // Loads all the vehicles into the specified buffer, returns the total amount of vehicles loaded. EXPORT int32_t GetAllVehicles(VehicleEntity* vehicles, int32_t arraySize) { @@ -30,13 +28,13 @@ extern "C" for (Vehicle* vehicle : EntityList()) { VehicleEntity* target = &vehicles[vehicleCount]; - target->idx = vehicle->sprite_index.ToUnderlying(); + target->idx = vehicle->Id.ToUnderlying(); target->x = vehicle->x; target->y = vehicle->y; target->z = vehicle->z; - target->direction = vehicle->sprite_direction; + target->direction = vehicle->Orientation; target->bankRotation = vehicle->bank_rotation; target->pitchRotation = vehicle->Pitch; diff --git a/src/openrct2-bindings/Bindings/openrct2-bindings.cpp b/src/openrct2-bindings/openrct2-bindings.cpp similarity index 99% rename from src/openrct2-bindings/Bindings/openrct2-bindings.cpp rename to src/openrct2-bindings/openrct2-bindings.cpp index 0824c97995..86dd44f1de 100644 --- a/src/openrct2-bindings/Bindings/openrct2-bindings.cpp +++ b/src/openrct2-bindings/openrct2-bindings.cpp @@ -1,8 +1,7 @@ -#include -#include - #include "openrct2-bindings.h" +#include +#include // Write to output log with a custom prefix and line ending. void dll_log(const char* format, ...) diff --git a/src/openrct2-bindings/Bindings/openrct2-bindings.h b/src/openrct2-bindings/openrct2-bindings.h similarity index 99% rename from src/openrct2-bindings/Bindings/openrct2-bindings.h rename to src/openrct2-bindings/openrct2-bindings.h index b885c0fc6c..c88b948733 100644 --- a/src/openrct2-bindings/Bindings/openrct2-bindings.h +++ b/src/openrct2-bindings/openrct2-bindings.h @@ -3,9 +3,7 @@ #include using namespace OpenRCT2; - #define EXPORT __declspec(dllexport) - // Write to output log with a custom prefix and line ending. void dll_log(const char* format, ...); diff --git a/src/openrct2-bindings/openrct2-bindings.vcxproj b/src/openrct2-bindings/openrct2-bindings.vcxproj index 272dffe810..b6fe0c39ae 100644 --- a/src/openrct2-bindings/openrct2-bindings.vcxproj +++ b/src/openrct2-bindings/openrct2-bindings.vcxproj @@ -1,7 +1,7 @@ - ..\..\ + ..\..\ @@ -62,7 +62,7 @@ xcopy /i /y /f "$(SolutionDir)bin\bindings\*" "$(SolutionDir)src\openrct2-unity\ - + @@ -76,7 +76,7 @@ xcopy /i /y /f "$(SolutionDir)bin\bindings\*" "$(SolutionDir)src\openrct2-unity\ - + - + \ No newline at end of file