Update OpenRCT2 to v0.4.5

This commit is contained in:
Bas
2023-07-05 21:57:26 +02:00
parent f0cfc11fac
commit e8f4c08400
16 changed files with 126 additions and 155 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -1,4 +1,5 @@
#include "../../openrct2/core/Path.hpp"
#include "../openrct2-bindings.h"
#include <openrct2/Context.h>
#include <openrct2/Game.h>
@@ -7,9 +8,6 @@
#include <openrct2/platform/platform.h>
#include <openrct2/world/Park.h>
#include "openrct2-bindings.h"
std::unique_ptr<IContext> 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();

View File

@@ -1,10 +1,9 @@
#include "../openrct2-bindings.h"
#include <openrct2/drawing/Drawing.h>
#include <openrct2/sprites.h>
#include <openrct2/world/SmallScenery.h>
#include "openrct2-bindings.h"
#include <openrct2/drawing/Drawing.h>
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++)
{

View File

@@ -1,9 +1,7 @@
#include "../openrct2-bindings.h"
#include <openrct2/world/Park.h>
#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++)
{

View File

@@ -1,10 +1,10 @@
#include "../openrct2-bindings.h"
#include <openrct2/entity/EntityList.h>
#include <openrct2/entity/Guest.h>
#include <openrct2/entity/Peep.h>
#include <openrct2/entity/Staff.h>
#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)

View File

@@ -1,8 +1,7 @@
#include "../openrct2-bindings.h"
#include <openrct2/entity/EntityList.h>
#include "openrct2-bindings.h"
extern "C"
{
// Gets the amount of sprites currently active for the given type.

View File

@@ -1,9 +1,8 @@
#include "../../openrct2-bindings.h"
#include <openrct2/object/FootpathSurfaceObject.h>
#include <openrct2/world/TileElement.h>
#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)

View File

@@ -1,9 +1,11 @@
#include <iostream>
#include <openrct2/object/ObjectManager.h>
#include <openrct2/object/SmallSceneryEntry.h>
#include <openrct2/world/TileElement.h>
#include <openrct2/world/Scenery.h>
#include <openrct2/world/SmallScenery.h>
#include "..\openrct2-bindings.h"
#include <iostream>
#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);
}
}

View File

@@ -1,23 +1,21 @@
#include <openrct2/object/TerrainSurfaceObject.h>
#include <openrct2/object/TerrainEdgeObject.h>
#include "../../openrct2-bindings.h"
#include <openrct2/object/ObjectManager.h>
#include <openrct2/object/TerrainEdgeObject.h>
#include <openrct2/object/TerrainSurfaceObject.h>
#include <openrct2/paint/tile_element/Paint.Surface.h>
#include <openrct2/world/TileElement.h>
#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<TerrainSurfaceObject*>(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();
}
}

View File

@@ -1,40 +1,38 @@
#include <openrct2/world/TileElement.h>
#include "../../openrct2-bindings.h"
#include <openrct2/object/WallSceneryEntry.h>
#include <openrct2/world/SmallScenery.h>
#include "..\openrct2-bindings.h"
#include <openrct2/world/TileElement.h>
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();
}
}

View File

@@ -1,12 +1,11 @@
#include "../openrct2-bindings.h"
#include <openrct2/ride/RideData.h>
#include <openrct2/ride/Track.h>
#include <openrct2/ride/TrackData.h>
#include <openrct2/ride/Vehicle.h>
#include <openrct2/ride/VehicleSubpositionData.h>
#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);

View File

@@ -1,8 +1,7 @@
#include <openrct2/ride/Vehicle.h>
#include "../openrct2-bindings.h"
#include <openrct2/entity/EntityList.h>
#include "openrct2-bindings.h"
#include <openrct2/ride/Vehicle.h>
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<Vehicle>())
{
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;

View File

@@ -1,8 +1,7 @@
#include <stdio.h>
#include <cstdarg>
#include "openrct2-bindings.h"
#include <cstdarg>
#include <stdio.h>
// Write to output log with a custom prefix and line ending.
void dll_log(const char* format, ...)

View File

@@ -3,9 +3,7 @@
#include <openrct2/Context.h>
using namespace OpenRCT2;
#define EXPORT __declspec(dllexport)
// Write to output log with a custom prefix and line ending.
void dll_log(const char* format, ...);

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SolutionDir Condition="'$(SolutionDir)'==''">..\..\</SolutionDir>
<SolutionDir Condition="'$(SolutionDir)'==''">..\..\</SolutionDir>
</PropertyGroup>
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
@@ -62,7 +62,7 @@ xcopy /i /y /f "$(SolutionDir)bin\bindings\*" "$(SolutionDir)src\openrct2-unity\
<ResourceCompile Include="..\..\resources\OpenRCT2.rc" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="Bindings\openrct2-bindings.cpp" />
<ClCompile Include="openrct2-bindings.cpp" />
<ClCompile Include="Bindings\Graphics.cpp" />
<ClCompile Include="Bindings\Game.cpp" />
<ClCompile Include="Bindings\Map.cpp" />
@@ -76,7 +76,7 @@ xcopy /i /y /f "$(SolutionDir)bin\bindings\*" "$(SolutionDir)src\openrct2-unity\
<ClCompile Include="Bindings\Vehicles.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Bindings\openrct2-bindings.h" />
<ClInclude Include="openrct2-bindings.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>
</Project>