mirror of https://github.com/OpenRCT2/OpenRCT2.git
Implemented map_reorganise_elements.
Fixed a potential issue that would cause cursors to become stuck.
This commit is contained in:
parent
8167c24526
commit
33c4698e06
|
@ -646,6 +646,7 @@ void platform_set_fullscreen_mode(int mode)
|
|||
*/
|
||||
void platform_set_cursor(char cursor)
|
||||
{
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CURENT_CURSOR, uint8) = cursor;
|
||||
SDL_SetCursor(_cursors[cursor]);
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "scenery.h"
|
||||
#include "../cheats.h"
|
||||
#include "../config.h"
|
||||
#include "../cursors.h"
|
||||
|
||||
const rct_xy16 TileDirectionDelta[] = {
|
||||
{ -32, 0 },
|
||||
|
@ -2735,7 +2736,36 @@ void map_invalidate_selection_rect()
|
|||
*/
|
||||
void map_reorganise_elements()
|
||||
{
|
||||
RCT2_CALLPROC_EBPSAFE(0x0068B111);
|
||||
platform_set_cursor(CURSOR_ZZZ);
|
||||
|
||||
rct_map_element* new_map_elements = rct2_malloc(0x30000 * sizeof(rct_map_element));
|
||||
rct_map_element* new_elements_pointer = new_map_elements;
|
||||
|
||||
if (new_map_elements == NULL || new_map_elements == (rct_map_element*)-1){
|
||||
error_string_quit(4370, 0xFFFF);
|
||||
return;
|
||||
}
|
||||
|
||||
rct_map_element **tile = RCT2_ADDRESS(RCT2_ADDRESS_TILE_MAP_ELEMENT_POINTERS, rct_map_element*);
|
||||
for (int i = 0; i < 0x10000;){
|
||||
for (int j = 0; j < 256; ++j, ++i){
|
||||
rct_map_element* startElement = tile[i];
|
||||
rct_map_element* endElement = startElement;
|
||||
while (!map_element_is_last_for_tile(endElement++));
|
||||
|
||||
uint8 num_bytes = endElement - startElement;
|
||||
memcpy(new_elements_pointer, startElement, num_bytes);
|
||||
new_elements_pointer += num_bytes / sizeof(rct_map_element);
|
||||
}
|
||||
}
|
||||
|
||||
uint32 num_elements = (new_elements_pointer - new_map_elements) / sizeof(rct_map_element);
|
||||
memcpy(RCT2_ADDRESS(RCT2_ADDRESS_MAP_ELEMENTS, rct_map_element), new_map_elements, num_elements * sizeof(rct_map_element));
|
||||
memset(new_map_elements + num_elements, 0, (0x30000 - num_elements) * sizeof(rct_map_element));
|
||||
|
||||
rct2_free(new_map_elements);
|
||||
|
||||
map_update_tile_pointers();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue