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

View File

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