diff --git a/src/openrct2-bindings/Bindings/Game.cpp b/src/openrct2-bindings/Bindings/Game.cpp index 37b5c817a1b1..74cd04fb81e4 100644 --- a/src/openrct2-bindings/Bindings/Game.cpp +++ b/src/openrct2-bindings/Bindings/Game.cpp @@ -37,7 +37,6 @@ extern "C" rct2path); // Create a plain context - Platform::CoreInit(); unityContext = CreateContext(); // OpenRCT2::CreateContext() bool result = unityContext->Initialise(); diff --git a/src/openrct2-bindings/Map/Surface.cpp b/src/openrct2-bindings/Map/Surface.cpp index 7d4f45352b91..580c3fb27cd3 100644 --- a/src/openrct2-bindings/Map/Surface.cpp +++ b/src/openrct2-bindings/Map/Surface.cpp @@ -12,57 +12,42 @@ extern "C" { struct SurfaceInfo { - uint32_t surfaceIndex; - uint32_t edgeIndex; + uint32_t surfaceImageIndex; + uint32_t edgeImageIndex; int32_t waterHeight; uint8_t slope; }; // Returns the sprite image index for a surface sprite. // Inspired by: GetSurfaceObject(), GetSurfaceImage() - uint32_t GetSurfaceImageIndex(const TileElement* element, const SurfaceElement* surface, int32_t x, int32_t y) + static uint32_t GetSurfaceImageIndex(const TileElement* element, const SurfaceElement* surface, int32_t x, int32_t y) { - uint32_t surfaceIndex = surface->GetSurfaceStyle(); - uint8_t grassLength = surface->GetGrassLength(); - ImageId imageId; - - IObjectManager& objMgr = OpenRCT2::GetContext()->GetObjectManager(); - Object* obj = objMgr.GetLoadedObject(ObjectType::TerrainSurface, surfaceIndex); - - if (obj == nullptr) + const TerrainSurfaceObject* surfaceObject = surface->GetSurfaceObject(); + if (surfaceObject == nullptr) { - dll_log("Could not find surface object: %i", surfaceIndex); + return 0; } - else - { - const TerrainSurfaceObject* result = static_cast(obj); - imageId = ImageId(result->GetImageId({ x, y }, grassLength, element->GetDirection(), 0, false, false)); - if (result->Colour != 255) + uint8_t grassLength = surface->GetGrassLength(); + auto imageId = ImageId(surfaceObject->GetImageId({ x, y }, grassLength, element->GetDirection(), 0, false, false)); + if (surfaceObject->Colour != 255) { - imageId = imageId.WithPrimary(result->Colour); + imageId = imageId.WithPrimary(surfaceObject->Colour); } - } return imageId.ToUInt32(); } // Returns the sprite image for a surface edge sprite. // Inspired by: GetEdgeImageWithOffset() - uint32_t GetSurfaceEdgeImageIndex(const SurfaceElement* surface) - { - uint32_t edgeIndex = surface->GetEdgeStyle(); - - IObjectManager& objMgr = OpenRCT2::GetContext()->GetObjectManager(); - Object* obj = objMgr.GetLoadedObject(ObjectType::TerrainEdge, edgeIndex); - - if (obj == nullptr) + static uint32_t GetSurfaceEdgeImageIndex(const SurfaceElement* surface) + { + const TerrainEdgeObject* edgeObject = surface->GetEdgeObject(); + if (edgeObject == nullptr) { - dll_log("Could not find surface edge object: %i", edgeIndex); return 0; } - auto tobj = static_cast(obj); - return tobj->BaseImageId + 5; // EDGE_BOTTOMRIGHT = +5 + return edgeObject->BaseImageId + 5; // EDGE_BOTTOMRIGHT = +5 } // Writes the surface element details to the specified buffer. @@ -77,8 +62,8 @@ extern "C" return; } - element->surfaceIndex = GetSurfaceImageIndex(source, surface, x, y); - element->edgeIndex = GetSurfaceEdgeImageIndex(surface); + element->surfaceImageIndex = GetSurfaceImageIndex(source, surface, x, y); + element->edgeImageIndex = GetSurfaceEdgeImageIndex(surface); element->slope = surface->GetSlope(); element->waterHeight = surface->GetWaterHeight(); } diff --git a/src/openrct2-bindings/Map/TileElement.cpp b/src/openrct2-bindings/Map/TileElement.cpp index cce74cb0da11..6e4e747c0f15 100644 --- a/src/openrct2-bindings/Map/TileElement.cpp +++ b/src/openrct2-bindings/Map/TileElement.cpp @@ -32,8 +32,6 @@ extern "C" // Writes all tile-elements at the the specified coordinates to the specified buffer. EXPORT int GetMapElementsAt(int x, int y, TileElementInfo* elements, int arraySize) { - dll_log("Cpp TileElementInfo size: %li", sizeof(TileElementInfo)); - const TileElement* source = GetTileElementAt(x, y, 0); int elementCount = 0; @@ -42,9 +40,6 @@ extern "C" SetTileElementInfo(&elements[i], source); elementCount++; - const uint32_t* ptr = (uint32_t*)&elements[i]; - dll_log("%i -> %08x %08x\n", 1, ptr[1], ptr[0]); - if (source->IsLastForTile()) break; diff --git a/src/openrct2-unity/Assets/Scripts/Behaviours/Editor/GameEditor.cs b/src/openrct2-unity/Assets/Scripts/Behaviours/Editor/GameEditor.cs index 86cbf5843af1..1e10e81ac83a 100644 --- a/src/openrct2-unity/Assets/Scripts/Behaviours/Editor/GameEditor.cs +++ b/src/openrct2-unity/Assets/Scripts/Behaviours/Editor/GameEditor.cs @@ -18,7 +18,7 @@ public class GameEditor : UnityEditor.Editor const string _defaultOpenRCT2Path = @"bin\data"; // from repo root const string _defaultParkPath = @"Parks"; // from unity project/executable root - static readonly string[] _validParkExtensions = { ".sv6", ".sc6", ".sv4", ".sc4" }; + static readonly string[] _validParkExtensions = { ".park", ".sv6", ".sc6", ".sv4", ".sc4" }; bool _groupToggleDataPaths = true; diff --git a/src/openrct2-unity/Assets/Scripts/Bindings/TileElements/SurfaceInfo.cs b/src/openrct2-unity/Assets/Scripts/Bindings/TileElements/SurfaceInfo.cs index f2a096b426c7..c69a0fda9e85 100644 --- a/src/openrct2-unity/Assets/Scripts/Bindings/TileElements/SurfaceInfo.cs +++ b/src/openrct2-unity/Assets/Scripts/Bindings/TileElements/SurfaceInfo.cs @@ -4,8 +4,8 @@ namespace OpenRCT2.Bindings.TileElements { public readonly struct SurfaceInfo { - public readonly uint surfaceIndex; - public readonly uint edgeIndex; + public readonly uint surfaceImageIndex; + public readonly uint edgeImageIndex; public readonly int waterHeight; public readonly SurfaceSlope slope; diff --git a/src/openrct2-unity/Assets/Scripts/Generators/Map/Retro/SurfaceGenerator.cs b/src/openrct2-unity/Assets/Scripts/Generators/Map/Retro/SurfaceGenerator.cs index 527faebef88f..c0a1263dcb09 100644 --- a/src/openrct2-unity/Assets/Scripts/Generators/Map/Retro/SurfaceGenerator.cs +++ b/src/openrct2-unity/Assets/Scripts/Generators/Map/Retro/SurfaceGenerator.cs @@ -180,7 +180,7 @@ void CreateSurfaceElement(MeshBuilder builder, List materialIndices, int x, */ SurfaceInfo surface = tile.surface; - int surfaceSubmesh = AddMaterialIndex(materialIndices, PushImageIndex(surface.surfaceIndex, TextureType.Surface)); + int surfaceSubmesh = AddMaterialIndex(materialIndices, PushImageIndex(surface.surfaceImageIndex, TextureType.Surface)); SurfaceSlope slope = surface.slope; int baseHeight = tile.baseHeight; @@ -218,7 +218,7 @@ void CreateSurfaceElement(MeshBuilder builder, List materialIndices, int x, } // Edges - uint edgeImage = surface.edgeIndex; + uint edgeImage = surface.edgeImageIndex; // HACK: only add the material stack index when any of the add-edges succeed. // Otherwise it will create inconsistency in materials, because some may not be used. int materialStackIndex = PushImageIndex(edgeImage, TextureType.Edge); diff --git a/src/openrct2-unity/Assets/Scripts/Generators/Map/Retro/TrackGenerator.cs b/src/openrct2-unity/Assets/Scripts/Generators/Map/Retro/TrackGenerator.cs index f0727f3c1cac..e115490f901f 100644 --- a/src/openrct2-unity/Assets/Scripts/Generators/Map/Retro/TrackGenerator.cs +++ b/src/openrct2-unity/Assets/Scripts/Generators/Map/Retro/TrackGenerator.cs @@ -55,7 +55,7 @@ public void CreateElement(in MapData map, int x, int y, int index, in TileElemen position.y += trackOffset; GameObject obj = UnityEngine.Object.Instantiate(_prefab, position, Quaternion.Euler(0, element.rotation * 90f, 0), map.transform); - obj.name = $"Track [{x}, {y}] type: {trackType}, key: {meshKey:x}, colours: ({track.mainColour}, {track.additionalColour}, {track.supportsColour}), rot: {element.rotation}, inv: {track.inverted}"; + obj.name = $"Track [{x}, {y}, {element.baseHeight}] type: {trackType}, key: {meshKey:x}, colours: ({track.mainColour}, {track.additionalColour}, {track.supportsColour}), rot: {element.rotation}, inv: {track.inverted}"; obj.isStatic = true; MeshFilter filter = obj.GetComponent();