mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-23 23:04:36 +01:00
implement format_string_toupper and litter_create
This commit is contained in:
@@ -3095,3 +3095,13 @@ int map_get_highest_z(int tileX, int tileY)
|
||||
z = max(z, (mapElement->properties.surface.terrain & 0x1F) * 16);
|
||||
return z;
|
||||
}
|
||||
|
||||
bool map_element_is_underground(rct_map_element *mapElement)
|
||||
{
|
||||
do {
|
||||
mapElement++;
|
||||
if (map_element_is_last_for_tile(mapElement - 1))
|
||||
return false;
|
||||
} while (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_SURFACE);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -334,4 +334,6 @@ void sub_6A7594();
|
||||
int map_element_get_banner_index(rct_map_element *mapElement);
|
||||
void map_element_remove_banner_entry(rct_map_element *mapElement);
|
||||
|
||||
bool map_element_is_underground(rct_map_element *mapElement);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -267,8 +267,8 @@ int calculate_park_rating()
|
||||
for (sprite_idx = RCT2_GLOBAL(RCT2_ADDRESS_SPRITES_START_LITTER, uint16); sprite_idx != SPRITE_INDEX_NULL; sprite_idx = litter->next) {
|
||||
litter = &(g_sprite_list[sprite_idx].litter);
|
||||
|
||||
// Guessing this eliminates recently dropped litter
|
||||
if (litter->var_24 - RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_TICKS, uint32) >= 7680)
|
||||
// Ignore recently dropped litter
|
||||
if (litter->creationTick - RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_TICKS, uint32) >= 7680)
|
||||
num_litter++;
|
||||
}
|
||||
result -= 600 - (4 * (150 - min(150, num_litter)));
|
||||
|
||||
@@ -901,4 +901,78 @@ void sprite_move(sint16 x, sint16 y, sint16 z, rct_sprite* sprite){
|
||||
void sprite_remove(rct_sprite *sprite)
|
||||
{
|
||||
RCT2_CALLPROC_X(0x0069EDB6, 0, 0, 0, 0, (int)sprite, 0, 0);
|
||||
}
|
||||
|
||||
static bool litter_can_be_at(int x, int y, int z)
|
||||
{
|
||||
rct_map_element *mapElement;
|
||||
|
||||
if (!map_is_location_owned(x & 0xFFE0, y & 0xFFE0, z))
|
||||
return false;
|
||||
|
||||
mapElement = map_get_first_element_at(x >> 5, y >> 5);
|
||||
do {
|
||||
if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_PATH)
|
||||
continue;
|
||||
|
||||
int pathZ = mapElement->base_height * 8;
|
||||
if (pathZ < z || pathZ >= z + 32)
|
||||
continue;
|
||||
|
||||
if (map_element_is_underground(mapElement))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
} while (!map_element_is_last_for_tile(mapElement++));
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x0067375D
|
||||
*/
|
||||
void litter_create(int x, int y, int z, int direction, int type)
|
||||
{
|
||||
rct_litter *litter, *newestLitter;
|
||||
uint16 spriteIndex, nextSpriteIndex;
|
||||
uint32 newestLitterCreationTick;
|
||||
|
||||
x += TileDirectionDelta[direction].x / 8;
|
||||
y += TileDirectionDelta[direction].y / 8;
|
||||
|
||||
if (!litter_can_be_at(x, y, z))
|
||||
return;
|
||||
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_SPRITES_COUNT_LITTER, uint16) >= 500) {
|
||||
newestLitter = NULL;
|
||||
newestLitterCreationTick = 0;
|
||||
for (spriteIndex = RCT2_GLOBAL(RCT2_ADDRESS_SPRITES_START_LITTER, uint16); spriteIndex != SPRITE_INDEX_NULL; spriteIndex = nextSpriteIndex) {
|
||||
litter = &(g_sprite_list[spriteIndex].litter);
|
||||
nextSpriteIndex = litter->next;
|
||||
if (newestLitterCreationTick <= litter->creationTick) {
|
||||
newestLitterCreationTick = litter->creationTick;
|
||||
newestLitter = litter;
|
||||
}
|
||||
}
|
||||
|
||||
if (newestLitter != NULL) {
|
||||
sub_6EC60B((rct_sprite*)newestLitter);
|
||||
sprite_remove((rct_sprite*)newestLitter);
|
||||
}
|
||||
}
|
||||
|
||||
litter = (rct_litter*)create_sprite(1);
|
||||
if (litter == NULL)
|
||||
return;
|
||||
|
||||
move_sprite_to_list((rct_sprite*)litter, SPRITE_LINKEDLIST_OFFSET_LITTER);
|
||||
litter->sprite_direction = direction;
|
||||
litter->sprite_width = 6;
|
||||
litter->sprite_height_negative = 6;
|
||||
litter->sprite_height_positive = 3;
|
||||
litter->sprite_identifier = SPRITE_IDENTIFIER_LITTER;
|
||||
litter->type = type;
|
||||
sprite_move(x, y, z, (rct_sprite*)litter);
|
||||
sub_6EC60B((rct_sprite*)litter);
|
||||
litter->creationTick = RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_TICKS, uint32);
|
||||
}
|
||||
@@ -84,14 +84,18 @@ typedef struct {
|
||||
uint16 next; // 0x04
|
||||
uint16 previous; // 0x06
|
||||
uint8 linked_list_type_offset; // 0x08 Valid values are SPRITE_LINKEDLIST_OFFSET_...
|
||||
uint8 pad_09;
|
||||
uint8 sprite_height_negative; // 0x09
|
||||
uint16 sprite_index; // 0x0A
|
||||
uint16 pad_0C;
|
||||
sint16 x; // 0x0E
|
||||
sint16 y; // 0x10
|
||||
sint16 z; // 0x12
|
||||
uint8 pad_14[0x10];
|
||||
uint32 var_24;
|
||||
uint8 sprite_width; // 0x14
|
||||
uint8 sprite_height_positive; // 0x15
|
||||
uint8 pad_16[8];
|
||||
uint8 sprite_direction; // 0x1E
|
||||
uint8 pad_1F[5];
|
||||
uint32 creationTick; // 0x24
|
||||
} rct_litter;
|
||||
|
||||
typedef struct {
|
||||
@@ -252,5 +256,6 @@ void sprite_move(sint16 x, sint16 y, sint16 z, rct_sprite* sprite);
|
||||
void invalidate_sprite(rct_sprite *sprite);
|
||||
void sub_6EC60B(rct_sprite* sprite);
|
||||
void sprite_remove(rct_sprite *sprite);
|
||||
void litter_create(int x, int y, int z, int direction, int type);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user