Refactored some code into functions for enabling/disabling pathfinding debugging for a specific peep.
Some new log messages for improved clarity when debugging pathfinding.
Added a #define to independently enable/disable pathfinding debugging to be friendly to others using debugging builds.
Currently pathfinding falls back to aimless movement in this case.
Resetting the pathfind_goal (which in turn will cause the pathfind_history to be reset) makes the pathfinding try again afresh the next time around.
Potentially useful for adjusting to path changes by the player and recovering from a stuck position due to earlier bad pathfinding.
In the existing version, returning to a junction in the pathfind history is considered a loop. This is not useful as it prevents the pathfinding from backtracking, which is what the pathfind_history is intended to allow.
Updated to consider it a loop only when returning to a junction with no more edges left to try.
When choosing a direction at a junction in pathfind_history (with no untried directions) the existing path finding falls back to aimless movement.
This change makes the pathfinding try again.
Useful for adjusting to path changes by the player and recovering from a stuck position in a savegame due to earlier bad pathfinding.
Now that the heuristic search uses the pathfind_history for loop detection it is important that when the pathfind_goal is reset the pathfind_history gets reset before calling the heuristic search.
This is applicable for overlaid paths placed with zero clearance.
Previously the pathfinding only used the first path element.
Notes:
1. Logic related to path slope still only uses the the first path element. Overlaying path elements with the same base height but different slopes may cause pathfinding glitches.
2. The heuristic search already uses a similar approach - the inconsistency could have caused pathfinding glitches.
Issue was caused by placing two ghost scenery items when using the scenery placement tool. The ghost clean up code would only remove the first ghost and leave the second ghost. Mistake caused when refactoring. Incorrect use of NOT and AND.
Due to a mistake during implementation the vehicle colour of the motion simulator was the wrong way around. The trim colour was applied to the body and vice versa. Issue noticed by reddit user.
Issue was caused by an incorrect read (only 1 byte instead of 2) of the legacy banner data during object loading. Note this would have caused the scenery_tab_id and string table to possibly have corrupted data.
The feature of disabling the land rights buying buttons depends on the
land rights being accounted for, but the function that calculates these
was not called when loading saved games. Therefore it would often make
it impossible to buy land after loading a saved game.
Previously multi tiled placements would only check for one free element before placing. This would cause a crash when it failed to allocate the next element on maps that were close to reaching their full capacity. Renamed sub_68B044 to map_check_free_elements_and_organise and gave it an argument value to check for enough free elements.
When a golf ride is closed it will remove the peep from the vehicle (the ball). Due to the way vehicles leave stations the vehicle would still travel to the next hole but when it tried to update the peeps action it would crash. This skips updating the peeps action but lets the ball still continue. This will cause a phantom ball to go around the golf course until all the vehicles are back in their closed state.
The buffer overflow protection in format_string was not working correctly for several reasons. For windows builds this just so happened to write over gMapTooltipFormatArgs causing the assertion. Extra asserts have been added to check overflows in format_string.
When audio_init_ride_sounds is called, it calls audio_stop_title_music, but never calls audio_start_title_music. if you do an assert for gTitleMusicChannel it shows it is null. this fixes that. i will say though this is most definitely a band-aid fix, because if run audio_start_title_music in the audio_init_ride_sounds, it still doesn't play out loud. at least on my setup it doesn't.
From documentation on `void* malloc( size_t size );`:
> If size is zero, the behavior is implementation defined (null pointer
may be returned, or some non-null pointer may be returned that may not
be used to access storage).
Both `free()` and `realloc()` understand `NULL`, so use that to avoid
implementation-defined behaviour
Such case can happen with following function call chain in stack trace:
* `game_command_create_ride` ride.c:6234
* `ride_create` ride.c:6070
* `rideTypeShouldLoseSeparateFlag` rct1.c:88
This commit fixes the game command set_land_ownership missing a land
rights recount call. This would cause problems when the user changes
land ownership with the sandbox mode tools.
Issue is being caused by deleting the station track without removing the station track entry in the ride struct. This will prevent the crash but this should not happen in practice.
Issue caused by switching between tabs when half way through tab animation. The frame number would not be reset until the next frame and this would cause a split second glitch when moving from a long animation tab to a short animation tab. Issue fixed by reseting the frame number when switching tabs.
The bins were incorrectly displaying their filled status on some
rotations. This was caused by two mistakes. The first mistake was only
rotating the status by 1 place when it was 2 bit the second was due to
rotating it the wrong direction. This was likely caused by the implementor
not realising that there were two 'rol' commands but due to the inverted
nature of this it would end up being two 'ror's.
Use Intel-standardized _mm_popcnt_u32 instead of Microsoft-specific
__popcnt, replace assert with openrct2_assert, replace bitcount's argument
with uint32.
This commit changes the land rights button in the park window to be
disabled if there are no more land rights and construction rights for
sale. It also disables the individual land rights and construction
rights buttons in the land rights window itself if that specific type of
tile is no longer for sale.
This is implemented by introducing two new global variables called
gLandRemainingOwnershipSales and gLandRemainingConstructionSales. These
are updated by map_count_remaining_land_rights() to contain the number
of land rights and construction rights that remain for sale. This
function is called when a scenario is loaded and whenever the game
command to buy land rights or construction rights is invoked.
It also introduces three new tooltip strings that explain why the
buttons are disabled.
In order to avoid the overhead of checking whether the function pointer
to bitcount's actual implementation has been initialised every time
bitcount is called, initialise it at application startup.
Replace the current implementation of bitcount() with a one that uses the
POPCNT instruction available in most newer CPUs. Also, replace the basic
implementation with a one based on a lookup table, which has much better
performance than the old one.
The light effects mod branch #3798 by @JeroenDStout has become quite out of date. I plan to properly implement it, but first I want to merge in what we have already, so that I can branch off develop again and rebase (currently rebasing this branch is too difficult, far too many commits).
Most code that this is merging is protected by the __ENABLE_LIGHTFX__ directive, so it should not make any difference until its time to enable it via a new pull request.
I have isolated it as much as possible to lightfx.c.
The heuristic search currently only inludes detection of loops in the current search path - i.e. from where the peep is now.
The peep->pathfind_history includes (limited) junctions that the peep has already passed through for the current search goal to get to their current location. Consider search paths through these junctions as loops as well.
This will prevent peeps getting stuck in some path layouts where looping back through a junction they already walked through and then proceeding via an alternative path (such that there is no loop in the current search path) hits the search limits on a continuing path that is closer to the goal than simply continuing on along the path which then turns (temporarily) away from the goal.
This prevents _some_ cases of alternate, longer routes to nearer tiles being returned as a better result than a route that goes through that same tile (with less steps) and then continues on to end overall further from the goal though closer to getting to the goal (as was previously documented in PR #4527).
The network version is incremented in this PR.
Fixes#4572: Don't create .sv6 autosaves in track designs manager, roller coaster designer and scenario editor
Fixes#4573: "Save this before quitting?" in scenario editor saves to .sv6, not .sc6
Windows subsystem does not work like console subsystem which makes it almost impossible to obtain `stdout` until the application has finished. This adds a `--console` switch to make the game either attach to an existing console or show a new one and redirect the C streams to it.