mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-19 21:13:05 +01:00
Move CarEntrySetImageMaxSizes() to CarEntry.cpp
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
#include "../localisation/Language.h"
|
||||
#include "../rct2/DATLimits.h"
|
||||
#include "../rct2/RCT2.h"
|
||||
#include "../ride/CarEntry.h"
|
||||
#include "../ride/Ride.h"
|
||||
#include "../ride/RideData.h"
|
||||
#include "../ride/ShopItem.h"
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "CarEntry.h"
|
||||
|
||||
#include "../drawing/Drawing.h"
|
||||
#include "../entity/Yaw.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
@@ -38,3 +39,102 @@ uint32_t CarEntry::SpriteOffset(SpriteGroupType spriteGroup, int32_t imageDirect
|
||||
return ((SpriteByYaw(imageDirection, spriteGroup) + NumRotationSprites(spriteGroup) * rankIndex) * base_num_frames)
|
||||
+ GroupImageId(spriteGroup);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006847BA
|
||||
*/
|
||||
void CarEntrySetImageMaxSizes(CarEntry& carEntry, int32_t numImages)
|
||||
{
|
||||
uint8_t bitmap[200][200] = { 0 };
|
||||
|
||||
rct_drawpixelinfo dpi = {
|
||||
/*.bits = */ reinterpret_cast<uint8_t*>(bitmap),
|
||||
/*.x = */ -100,
|
||||
/*.y = */ -100,
|
||||
/*.width = */ 200,
|
||||
/*.height = */ 200,
|
||||
/*.pitch = */ 0,
|
||||
/*.zoom_level = */ ZoomLevel{ 0 },
|
||||
};
|
||||
|
||||
for (int32_t i = 0; i < numImages; ++i)
|
||||
{
|
||||
gfx_draw_sprite_software(&dpi, ImageId(carEntry.base_image_id + i), { 0, 0 });
|
||||
}
|
||||
int32_t spriteWidth = -1;
|
||||
for (int32_t i = 99; i != 0; --i)
|
||||
{
|
||||
for (int32_t j = 0; j < 200; j++)
|
||||
{
|
||||
if (bitmap[j][100 - i] != 0)
|
||||
{
|
||||
spriteWidth = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (spriteWidth != -1)
|
||||
break;
|
||||
|
||||
for (int32_t j = 0; j < 200; j++)
|
||||
{
|
||||
if (bitmap[j][100 + i] != 0)
|
||||
{
|
||||
spriteWidth = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (spriteWidth != -1)
|
||||
break;
|
||||
}
|
||||
|
||||
spriteWidth++;
|
||||
int32_t spriteHeightNegative = -1;
|
||||
|
||||
for (int32_t i = 99; i != 0; --i)
|
||||
{
|
||||
for (int32_t j = 0; j < 200; j++)
|
||||
{
|
||||
if (bitmap[100 - i][j] != 0)
|
||||
{
|
||||
spriteHeightNegative = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (spriteHeightNegative != -1)
|
||||
break;
|
||||
}
|
||||
spriteHeightNegative++;
|
||||
|
||||
int32_t spriteHeightPositive = -1;
|
||||
|
||||
for (int32_t i = 99; i != 0; --i)
|
||||
{
|
||||
for (int32_t j = 0; j < 200; j++)
|
||||
{
|
||||
if (bitmap[100 + i][j] != 0)
|
||||
{
|
||||
spriteHeightPositive = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (spriteHeightPositive != -1)
|
||||
break;
|
||||
}
|
||||
spriteHeightPositive++;
|
||||
|
||||
// Moved from object paint
|
||||
|
||||
if (carEntry.flags & CAR_ENTRY_FLAG_SPRITE_BOUNDS_INCLUDE_INVERTED_SET)
|
||||
{
|
||||
spriteHeightNegative += 16;
|
||||
}
|
||||
|
||||
carEntry.sprite_width = spriteWidth;
|
||||
carEntry.sprite_height_negative = spriteHeightNegative;
|
||||
carEntry.sprite_height_positive = spriteHeightPositive;
|
||||
}
|
||||
|
||||
@@ -196,3 +196,5 @@ struct CarEntry
|
||||
uint32_t GroupImageId(SpriteGroupType spriteGroup) const;
|
||||
uint32_t SpriteOffset(SpriteGroupType spriteGroup, int32_t imageDirection, uint8_t rankIndex) const;
|
||||
};
|
||||
|
||||
void CarEntrySetImageMaxSizes(CarEntry& carEntry, int32_t numImages);
|
||||
|
||||
@@ -4485,105 +4485,6 @@ bool ride_has_any_track_elements(const Ride& ride)
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006847BA
|
||||
*/
|
||||
void CarEntrySetImageMaxSizes(CarEntry& carEntry, int32_t numImages)
|
||||
{
|
||||
uint8_t bitmap[200][200] = { 0 };
|
||||
|
||||
rct_drawpixelinfo dpi = {
|
||||
/*.bits = */ reinterpret_cast<uint8_t*>(bitmap),
|
||||
/*.x = */ -100,
|
||||
/*.y = */ -100,
|
||||
/*.width = */ 200,
|
||||
/*.height = */ 200,
|
||||
/*.pitch = */ 0,
|
||||
/*.zoom_level = */ ZoomLevel{ 0 },
|
||||
};
|
||||
|
||||
for (int32_t i = 0; i < numImages; ++i)
|
||||
{
|
||||
gfx_draw_sprite_software(&dpi, ImageId(carEntry.base_image_id + i), { 0, 0 });
|
||||
}
|
||||
int32_t al = -1;
|
||||
for (int32_t i = 99; i != 0; --i)
|
||||
{
|
||||
for (int32_t j = 0; j < 200; j++)
|
||||
{
|
||||
if (bitmap[j][100 - i] != 0)
|
||||
{
|
||||
al = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (al != -1)
|
||||
break;
|
||||
|
||||
for (int32_t j = 0; j < 200; j++)
|
||||
{
|
||||
if (bitmap[j][100 + i] != 0)
|
||||
{
|
||||
al = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (al != -1)
|
||||
break;
|
||||
}
|
||||
|
||||
al++;
|
||||
int32_t bl = -1;
|
||||
|
||||
for (int32_t i = 99; i != 0; --i)
|
||||
{
|
||||
for (int32_t j = 0; j < 200; j++)
|
||||
{
|
||||
if (bitmap[100 - i][j] != 0)
|
||||
{
|
||||
bl = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (bl != -1)
|
||||
break;
|
||||
}
|
||||
bl++;
|
||||
|
||||
int32_t bh = -1;
|
||||
|
||||
for (int32_t i = 99; i != 0; --i)
|
||||
{
|
||||
for (int32_t j = 0; j < 200; j++)
|
||||
{
|
||||
if (bitmap[100 + i][j] != 0)
|
||||
{
|
||||
bh = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (bh != -1)
|
||||
break;
|
||||
}
|
||||
bh++;
|
||||
|
||||
// Moved from object paint
|
||||
|
||||
if (carEntry.flags & CAR_ENTRY_FLAG_SPRITE_BOUNDS_INCLUDE_INVERTED_SET)
|
||||
{
|
||||
bl += 16;
|
||||
}
|
||||
|
||||
carEntry.sprite_width = al;
|
||||
carEntry.sprite_height_negative = bl;
|
||||
carEntry.sprite_height_positive = bh;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006B59C6
|
||||
|
||||
@@ -100,5 +100,4 @@ struct rct_ride_entry
|
||||
}
|
||||
};
|
||||
|
||||
void CarEntrySetImageMaxSizes(CarEntry& carEntry, int32_t numImages);
|
||||
RideNaming get_ride_naming(const ride_type_t rideType, const rct_ride_entry& rideEntry);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "../entity/Yaw.hpp"
|
||||
#include "../interface/Viewport.h"
|
||||
#include "../paint/Paint.h"
|
||||
#include "../ride/CarEntry.h"
|
||||
#include "../ride/RideData.h"
|
||||
#include "../ride/Vehicle.h"
|
||||
#include "Track.h"
|
||||
|
||||
Reference in New Issue
Block a user