Fixed a desync that would happen when having the guests list open. (#5632)

* Fixed a desync that would happen when having the guests list open.
* Refactored the flashing state of peeps to not affect the flags.
* Added deprecation info for SPRITE_FLAGS_PEEP_FLASHING.
* Removed unused line that used the old flag.
* Update network version
This commit is contained in:
ZehM4tt 2017-06-17 12:55:41 +02:00 committed by Michał Janiszewski
parent 7094bbf74a
commit f05e94c1c6
7 changed files with 31 additions and 11 deletions

View File

@ -56,7 +56,7 @@ extern "C" {
// This define specifies which version of network stream current build uses.
// It is used for making sure only compatible builds get connected, even within
// single OpenRCT2 version.
#define NETWORK_STREAM_VERSION "14"
#define NETWORK_STREAM_VERSION "15"
#define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION
#ifdef __cplusplus

View File

@ -36,7 +36,6 @@ void sprite_paint_setup(const uint16 eax, const uint16 ecx) {
if (gTrackDesignSaveMode) return;
if (gCurrentViewportFlags & VIEWPORT_FLAG_INVISIBLE_SPRITES) return;
dpi = unk_140E9A8;

View File

@ -706,14 +706,14 @@ static void window_guest_list_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi,
// For each guest
FOR_ALL_GUESTS(spriteIndex, peep) {
peep->flags &= ~(SPRITE_FLAGS_PEEP_FLASHING);
sprite_set_flashing((rct_sprite*)peep, false);
if (peep->outside_of_park != 0)
continue;
if (_window_guest_list_selected_filter != -1) {
if (window_guest_list_is_peep_in_filter(peep))
continue;
gWindowMapFlashingFlags |= (1 << 0);
peep->flags |= SPRITE_FLAGS_PEEP_FLASHING;
sprite_set_flashing((rct_sprite*)peep, true);
}
if (_window_guest_list_tracking_only && !(peep->peep_flags & PEEP_FLAGS_TRACKING))
continue;

View File

@ -1077,9 +1077,9 @@ static void window_map_paint_peep_overlay(rct_drawpixelinfo *dpi)
right = left;
bottom = top;
colour = PALETTE_INDEX_20;
colour = PALETTE_INDEX_20;
if ((peep->flags & SPRITE_FLAGS_PEEP_FLASHING) != 0) {
if (sprite_get_flashing((rct_sprite*)peep)) {
if (peep->type == PEEP_TYPE_STAFF) {
if ((gWindowMapFlashingFlags & (1 << 3)) != 0) {
colour = PALETTE_INDEX_138;

View File

@ -323,12 +323,10 @@ void window_staff_list_update(rct_window *w)
rct_peep * peep;
gWindowMapFlashingFlags |= (1 << 2);
FOR_ALL_STAFF(spriteIndex, peep) {
// TODO When possible, do not modify the peep state as it shows up as a
// multiplayer desynchronisation
peep->flags &= ~(SPRITE_FLAGS_PEEP_FLASHING);
sprite_set_flashing((rct_sprite*)peep, false);
if (peep->staff_type == _windowStaffListSelectedTab) {
peep->flags |= SPRITE_FLAGS_PEEP_FLASHING;
sprite_set_flashing((rct_sprite*)peep, true);
}
}
}

View File

@ -36,6 +36,8 @@ uint16 *gSpriteListCount = RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LISTS_COUNT, uint16)
static rct_sprite *_spriteList = RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite);
#endif
static bool _spriteFlashingList[MAX_SPRITES];
#define SPATIAL_INDEX_LOCATION_NULL 0x10000
uint16 gSpriteSpatialIndex[0x10001];
@ -126,6 +128,7 @@ void reset_sprite_list()
for (sint32 i = 0; i < NUM_SPRITE_LISTS; i++) {
gSpriteListHead[i] = SPRITE_INDEX_NULL;
gSpriteListCount[i] = 0;
_spriteFlashingList[i] = false;
}
rct_sprite* previous_spr = (rct_sprite*)SPRITE_INDEX_NULL;
@ -145,6 +148,7 @@ void reset_sprite_list()
spr->unknown.previous = SPRITE_INDEX_NULL;
gSpriteListHead[SPRITE_LIST_NULL] = i;
}
_spriteFlashingList[i] = false;
previous_spr = spr;
spr++;
}
@ -207,6 +211,7 @@ const char * sprite_checksum()
{
rct_sprite copy = *sprite;
copy.unknown.sprite_left = copy.unknown.sprite_right = copy.unknown.sprite_top = copy.unknown.sprite_bottom = 0;
if (EVP_DigestUpdate(gHashCTX, &copy, sizeof(rct_sprite)) <= 0)
{
openrct2_assert(false, "Failed to update digest");
@ -256,6 +261,7 @@ void sprite_clear_all_unused()
sprite->previous = previousSpriteIndex;
sprite->linked_list_type_offset = SPRITE_LIST_NULL * 2;
sprite->sprite_index = spriteIndex;
_spriteFlashingList[spriteIndex] = false;
spriteIndex = nextSpriteIndex;
}
}
@ -267,6 +273,7 @@ static void sprite_reset(rct_unk_sprite *sprite)
uint16 next = sprite->next;
uint16 prev = sprite->previous;
uint16 sprite_index = sprite->sprite_index;
_spriteFlashingList[sprite_index] = false;
memset(sprite, 0, sizeof(rct_sprite));
@ -589,6 +596,7 @@ void sprite_remove(rct_sprite *sprite)
move_sprite_to_list(sprite, SPRITE_LIST_NULL * 2);
user_string_free(sprite->unknown.name_string_idx);
sprite->unknown.sprite_identifier = SPRITE_IDENTIFIER_NULL;
_spriteFlashingList[sprite->unknown.sprite_index] = false;
size_t quadrantIndex = GetSpatialIndexOffset(sprite->unknown.x, sprite->unknown.y);
uint16 *spriteIndex = &gSpriteSpatialIndex[quadrantIndex];
@ -779,3 +787,15 @@ void sprite_position_tween_reset()
_spritelocations2[i].z = sprite->unknown.z;
}
}
void sprite_set_flashing(rct_sprite *sprite, bool flashing)
{
assert(sprite->unknown.sprite_index < MAX_SPRITES);
_spriteFlashingList[sprite->unknown.sprite_index] = flashing;
}
bool sprite_get_flashing(rct_sprite *sprite)
{
assert(sprite->unknown.sprite_index < MAX_SPRITES);
return _spriteFlashingList[sprite->unknown.sprite_index];
}

View File

@ -387,7 +387,7 @@ enum {
enum {
SPRITE_FLAGS_IS_CRASHED_VEHICLE_SPRITE = 1 << 7,
SPRITE_FLAGS_PEEP_VISIBLE = 1 << 8, // Peep is eligible to show in summarized guest list window (is inside park?)
SPRITE_FLAGS_PEEP_FLASHING = 1 << 9, // Peep belongs to highlighted group (flashes red on map)
SPRITE_FLAGS_PEEP_FLASHING = 1 << 9, // Deprecated: Use sprite_set_flashing/sprite_get_flashing instead.
};
enum {
@ -475,5 +475,8 @@ void crash_splash_update(rct_crash_splash *splash);
const char *sprite_checksum();
void sprite_set_flashing(rct_sprite *sprite, bool flashing);
bool sprite_get_flashing(rct_sprite *sprite);
#endif