Add Paint function to Vehicle entity

This commit is contained in:
ζeh Matt 2021-11-27 16:00:35 +02:00
parent fd2f3edbf2
commit 5fce6d340d
No known key found for this signature in database
GPG Key ID: 18CE582C71A225B0
2 changed files with 22 additions and 27 deletions

View File

@ -29,6 +29,7 @@ struct Ride;
struct rct_ride_entry;
struct rct_ride_entry_vehicle;
class DataSerialiser;
struct paint_session;
struct GForces
{
@ -269,6 +270,7 @@ struct Vehicle : EntityBase
}
void ApplyMass(int16_t appliedMass);
void Serialise(DataSerialiser& stream);
void Paint(paint_session* session, int32_t imageDirection) const;
private:
bool SoundCanPlay() const;

View File

@ -3171,42 +3171,35 @@ void vehicle_visual_default(
}
}
/**
*
* rct2: 0x006D4244
*/
template<> void PaintEntity(paint_session* session, const Vehicle* vehicle, int32_t imageDirection)
void Vehicle::Paint(paint_session* session, int32_t imageDirection) const
{
const rct_ride_entry_vehicle* vehicleEntry;
int32_t x = vehicle->x;
int32_t y = vehicle->y;
int32_t z = vehicle->z;
if (vehicle->IsCrashedVehicle)
if (IsCrashedVehicle)
{
uint32_t ebx = 22965 + vehicle->animation_frame;
uint32_t ebx = 22965 + animation_frame;
PaintAddImageAsParent(session, ebx, { 0, 0, z }, { 1, 1, 0 }, { 0, 0, z + 2 });
return;
}
if (vehicle->ride_subtype == OBJECT_ENTRY_INDEX_NULL)
int32_t zOffset = 0;
if (ride_subtype == OBJECT_ENTRY_INDEX_NULL)
{
vehicleEntry = &CableLiftVehicle;
}
else
{
auto rideEntry = vehicle->GetRideEntry();
auto rideEntry = GetRideEntry();
if (rideEntry == nullptr)
{
return;
}
auto vehicleEntryIndex = vehicle->vehicle_type;
if (vehicle->HasUpdateFlag(VEHICLE_UPDATE_FLAG_USE_INVERTED_SPRITES))
auto vehicleEntryIndex = vehicle_type;
if (HasUpdateFlag(VEHICLE_UPDATE_FLAG_USE_INVERTED_SPRITES))
{
vehicleEntryIndex++;
z += 16;
zOffset += 16;
}
if (vehicleEntryIndex >= std::size(rideEntry->vehicles))
@ -3219,37 +3212,37 @@ template<> void PaintEntity(paint_session* session, const Vehicle* vehicle, int3
switch (vehicleEntry->car_visual)
{
case VEHICLE_VISUAL_DEFAULT:
vehicle_visual_default(session, imageDirection, z, vehicle, vehicleEntry);
vehicle_visual_default(session, imageDirection, z + zOffset, this, vehicleEntry);
break;
case VEHICLE_VISUAL_LAUNCHED_FREEFALL:
vehicle_visual_launched_freefall(session, x, imageDirection, y, z, vehicle, vehicleEntry);
vehicle_visual_launched_freefall(session, x, imageDirection, y, z + zOffset, this, vehicleEntry);
break;
case VEHICLE_VISUAL_OBSERVATION_TOWER:
vehicle_visual_observation_tower(session, x, imageDirection, y, z, vehicle, vehicleEntry);
vehicle_visual_observation_tower(session, x, imageDirection, y, z + zOffset, this, vehicleEntry);
break;
case VEHICLE_VISUAL_RIVER_RAPIDS:
vehicle_visual_river_rapids(session, x, imageDirection, y, z, vehicle, vehicleEntry);
vehicle_visual_river_rapids(session, x, imageDirection, y, z + zOffset, this, vehicleEntry);
break;
case VEHICLE_VISUAL_MINI_GOLF_PLAYER:
vehicle_visual_mini_golf_player(session, x, imageDirection, y, z, vehicle);
vehicle_visual_mini_golf_player(session, x, imageDirection, y, z + zOffset, this);
break;
case VEHICLE_VISUAL_MINI_GOLF_BALL:
vehicle_visual_mini_golf_ball(session, x, imageDirection, y, z, vehicle);
vehicle_visual_mini_golf_ball(session, x, imageDirection, y, z + zOffset, this);
break;
case VEHICLE_VISUAL_REVERSER:
vehicle_visual_reverser(session, x, imageDirection, y, z, vehicle, vehicleEntry);
vehicle_visual_reverser(session, x, imageDirection, y, z + zOffset, this, vehicleEntry);
break;
case VEHICLE_VISUAL_SPLASH_BOATS_OR_WATER_COASTER:
vehicle_visual_splash_boats_or_water_coaster(session, x, imageDirection, y, z, vehicle, vehicleEntry);
vehicle_visual_splash_boats_or_water_coaster(session, x, imageDirection, y, z + zOffset, this, vehicleEntry);
break;
case VEHICLE_VISUAL_ROTO_DROP:
vehicle_visual_roto_drop(session, x, imageDirection, y, z, vehicle, vehicleEntry);
vehicle_visual_roto_drop(session, x, imageDirection, y, z + zOffset, this, vehicleEntry);
break;
case VEHICLE_VISUAL_VIRGINIA_REEL:
vehicle_visual_virginia_reel(session, x, imageDirection, y, z, vehicle, vehicleEntry);
vehicle_visual_virginia_reel(session, x, imageDirection, y, z + zOffset, this, vehicleEntry);
break;
case VEHICLE_VISUAL_SUBMARINE:
vehicle_visual_submarine(session, x, imageDirection, y, z, vehicle, vehicleEntry);
vehicle_visual_submarine(session, x, imageDirection, y, z + zOffset, this, vehicleEntry);
break;
}
}