mirror of https://github.com/OpenRCT2/OpenRCT2.git
Fix compilation and refactor GetFrameImage
This commit is contained in:
parent
cd54503bdb
commit
481f5d706f
|
@ -181,18 +181,14 @@ void misc_paint(rct_sprite *misc, sint32 imageDirection)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case SPRITE_MISC_DUCK: // 8
|
case SPRITE_MISC_DUCK:
|
||||||
{
|
if (dpi->zoom_level == 0) {
|
||||||
if (dpi->zoom_level != 0) {
|
rct_duck * duck = &misc->duck;
|
||||||
return;
|
uint32 imageId = duck_get_frame_image(&misc->duck, imageDirection);
|
||||||
|
if (imageId != 0) {
|
||||||
|
sub_98196C(imageId, 0, 0, 1, 1, 0, duck->z, get_current_rotation());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rct_duck duck = misc->duck;
|
|
||||||
|
|
||||||
uint8 imageOffset = DuckAnimations[duck.state][duck.frame];
|
|
||||||
uint32 imageId = 23133 + (imageOffset * 4) + (imageDirection / 8);
|
|
||||||
sub_98196C(imageId, 0, 0, 1, 1, 0, duck.z, get_current_rotation());
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -535,6 +535,13 @@ static const sint32 Unk9A39C4[] = {
|
||||||
1946281152,
|
1946281152,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const rct_xy16 AvoidCollisionMoveOffset[] = {
|
||||||
|
{ -1, 0 },
|
||||||
|
{ 0, 1 },
|
||||||
|
{ 1, 0 },
|
||||||
|
{ 0, -1 },
|
||||||
|
};
|
||||||
|
|
||||||
static bool vehicle_move_info_valid(sint32 cd, sint32 typeAndDirection, sint32 offset)
|
static bool vehicle_move_info_valid(sint32 cd, sint32 typeAndDirection, sint32 offset)
|
||||||
{
|
{
|
||||||
if (cd >= countof(gTrackVehicleInfo)) {
|
if (cd >= countof(gTrackVehicleInfo)) {
|
||||||
|
@ -7123,8 +7130,8 @@ static bool vehicle_update_motion_collision_detection(
|
||||||
|
|
||||||
uint32 offsetSpriteDirection = (vehicle->sprite_direction + 4) & 31;
|
uint32 offsetSpriteDirection = (vehicle->sprite_direction + 4) & 31;
|
||||||
uint32 offsetDirection = offsetSpriteDirection >> 3;
|
uint32 offsetDirection = offsetSpriteDirection >> 3;
|
||||||
uint32 next_x_diff = abs(x + DuckMoveOffset[offsetDirection].x - collideVehicle->x);
|
uint32 next_x_diff = abs(x + AvoidCollisionMoveOffset[offsetDirection].x - collideVehicle->x);
|
||||||
uint32 next_y_diff = abs(y + DuckMoveOffset[offsetDirection].y - collideVehicle->y);
|
uint32 next_y_diff = abs(y + AvoidCollisionMoveOffset[offsetDirection].y - collideVehicle->y);
|
||||||
|
|
||||||
if (next_x_diff + next_y_diff < x_diff + y_diff){
|
if (next_x_diff + next_y_diff < x_diff + y_diff){
|
||||||
mayCollide = true;
|
mayCollide = true;
|
||||||
|
|
|
@ -659,6 +659,8 @@ enum {
|
||||||
SPR_RIDE_DESIGN_PREVIEW_MAZE_ICE_BLOCKS = 21992,
|
SPR_RIDE_DESIGN_PREVIEW_MAZE_ICE_BLOCKS = 21992,
|
||||||
SPR_RIDE_DESIGN_PREVIEW_MAZE_WOODEN_FENCES = 21993,
|
SPR_RIDE_DESIGN_PREVIEW_MAZE_WOODEN_FENCES = 21993,
|
||||||
|
|
||||||
|
SPR_DUCK = 23133,
|
||||||
|
|
||||||
SPR_NEXT_WEATHER = 23189,
|
SPR_NEXT_WEATHER = 23189,
|
||||||
SPR_WEATHER_SUN = 23190,
|
SPR_WEATHER_SUN = 23190,
|
||||||
SPR_WEATHER_SUN_CLOUD = 23191,
|
SPR_WEATHER_SUN_CLOUD = 23191,
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
#include "../core/Math.hpp"
|
#include "../core/Math.hpp"
|
||||||
#include "../core/Util.hpp"
|
#include "../core/Util.hpp"
|
||||||
|
#include "../sprites.h"
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
|
@ -32,10 +33,11 @@ enum DUCK_STATE
|
||||||
SWIM,
|
SWIM,
|
||||||
DRINK,
|
DRINK,
|
||||||
DOUBLE_DRINK,
|
DOUBLE_DRINK,
|
||||||
FLY_AWAY
|
FLY_AWAY,
|
||||||
};
|
};
|
||||||
|
constexpr sint32 DUCK_MAX_STATES = 5;
|
||||||
|
|
||||||
static const rct_xy16 DuckMoveOffset[4] =
|
static const rct_xy16 DuckMoveOffset[] =
|
||||||
{
|
{
|
||||||
{ -1, 0 },
|
{ -1, 0 },
|
||||||
{ 0, 1 },
|
{ 0, 1 },
|
||||||
|
@ -298,6 +300,18 @@ void rct_duck::UpdateFlyAway()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32 rct_duck::GetFrameImage(sint32 direction) const
|
||||||
|
{
|
||||||
|
uint32 imageId = 0;
|
||||||
|
if (state < DUCK_MAX_STATES)
|
||||||
|
{
|
||||||
|
// TODO check frame is in range
|
||||||
|
uint8 imageOffset = DuckAnimations[state][frame];
|
||||||
|
imageId = SPR_DUCK + (imageOffset * 4) + (direction / 8);
|
||||||
|
}
|
||||||
|
return imageId;
|
||||||
|
}
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
void create_duck(sint32 targetX, sint32 targetY)
|
void create_duck(sint32 targetX, sint32 targetY)
|
||||||
|
@ -376,4 +390,9 @@ extern "C"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32 duck_get_frame_image(const rct_duck * duck, sint32 direction)
|
||||||
|
{
|
||||||
|
return duck->GetFrameImage(direction);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,6 +168,7 @@ typedef struct rct_duck {
|
||||||
void UpdateDrink();
|
void UpdateDrink();
|
||||||
void UpdateDoubleDrink();
|
void UpdateDoubleDrink();
|
||||||
void UpdateFlyAway();
|
void UpdateFlyAway();
|
||||||
|
uint32 GetFrameImage(sint32 direction) const;
|
||||||
void Invalidate();
|
void Invalidate();
|
||||||
void Remove();
|
void Remove();
|
||||||
void MoveTo(sint16 x, sint16 y, sint16 z);
|
void MoveTo(sint16 x, sint16 y, sint16 z);
|
||||||
|
@ -453,6 +454,7 @@ void create_duck(sint32 targetX, sint32 targetY);
|
||||||
void duck_update(rct_duck *duck);
|
void duck_update(rct_duck *duck);
|
||||||
void duck_press(rct_duck *duck);
|
void duck_press(rct_duck *duck);
|
||||||
void duck_remove_all();
|
void duck_remove_all();
|
||||||
|
uint32 duck_get_frame_image(const rct_duck * duck, sint32 direction);
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Money effect
|
// Money effect
|
||||||
|
@ -471,3 +473,4 @@ void crash_splash_update(rct_crash_splash *splash);
|
||||||
const char *sprite_checksum();
|
const char *sprite_checksum();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue