1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-18 20:43:04 +01:00

add global macro: gNextFreeMapElement

This commit is contained in:
Ted John
2016-04-24 14:30:21 +01:00
parent 0f6e64ac76
commit d18ea8570d
5 changed files with 27 additions and 19 deletions

View File

@@ -433,7 +433,6 @@
#define RCT2_ADDRESS_CURRENT_FONT_FLAGS 0x013CE9A2
#define RCT2_ADDRESS_TILE_MAP_ELEMENT_POINTERS 0x013CE9A4
#define RCT2_ADDRESS_NEXT_FREE_MAP_ELEMENT 0x0140E9A4
#define RCT2_ADDRESS_CURRENT_ROTATION 0x0141E9E0
@@ -611,6 +610,8 @@
#define RCT2_ADDRESS_CONSTRUCT_PATH_VALID_DIRECTIONS 0x00F3EF9E
#define RCT2_ADDRESS_TRACK_PREVIEW_ROTATION 0x00F440AE
#define RCT2_ADDRESS_NEXT_FREE_MAP_ELEMENT 0x0140E9A4
#define RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT 0x0141E9AC
#define RCT2_ADDRESS_GAME_COMMAND_ERROR_TITLE 0x0141E9AE

View File

@@ -1095,7 +1095,7 @@ void S4Importer::ClearExtraTileEntries()
*tilePointer++ = nextFreeMapElement++;
}
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_FREE_MAP_ELEMENT, rct_map_element*) = nextFreeMapElement;
gNextFreeMapElement = nextFreeMapElement;
}
void S4Importer::FixColours()
@@ -1128,7 +1128,7 @@ void S4Importer::FixColours()
// }
rct_map_element * mapElement = gMapElements;
while (mapElement < RCT2_GLOBAL(RCT2_ADDRESS_NEXT_FREE_MAP_ELEMENT, rct_map_element*))
while (mapElement < gNextFreeMapElement)
{
if (mapElement->base_height != 255)
{
@@ -1188,7 +1188,7 @@ void S4Importer::FixZ()
// }
rct_map_element * mapElement = gMapElements;
while (mapElement < RCT2_GLOBAL(RCT2_ADDRESS_NEXT_FREE_MAP_ELEMENT, rct_map_element*))
while (mapElement < gNextFreeMapElement)
{
if (mapElement->base_height != 255)
{
@@ -1203,7 +1203,7 @@ void S4Importer::FixZ()
void S4Importer::FixPaths()
{
rct_map_element * mapElement = gMapElements;
while (mapElement < RCT2_GLOBAL(RCT2_ADDRESS_NEXT_FREE_MAP_ELEMENT, rct_map_element*))
while (mapElement < gNextFreeMapElement)
{
switch (map_element_get_type(mapElement)) {
case MAP_ELEMENT_TYPE_PATH:

View File

@@ -694,7 +694,8 @@ void reset_track_list_cache(){
*
* rct2: 0x006D1C68
*/
int backup_map(){
int backup_map()
{
RCT2_GLOBAL(0xF440ED, uint8*) = malloc(0xED600);
if (RCT2_GLOBAL(0xF440ED, uint32) == 0) return 0;
@@ -718,7 +719,7 @@ int backup_map(){
memcpy(RCT2_GLOBAL(0xF440F1, uint32*), tile_map_pointers, 0x40000);
uint8* backup_info = RCT2_GLOBAL(0xF440F5, uint8*);
*(uint32*)backup_info = RCT2_GLOBAL(RCT2_ADDRESS_NEXT_FREE_MAP_ELEMENT, uint32);
*(uint32*)backup_info = (uint32)gNextFreeMapElement;
*(uint16*)(backup_info + 4) = gMapSizeUnits;
*(uint16*)(backup_info + 6) = gMapSizeMinus2;
*(uint16*)(backup_info + 8) = gMapSize;
@@ -730,7 +731,8 @@ int backup_map(){
*
* rct2: 0x006D2378
*/
void reload_map_backup(){
void reload_map_backup()
{
uint32* map_elements = RCT2_ADDRESS(RCT2_ADDRESS_MAP_ELEMENTS, uint32);
memcpy(map_elements, RCT2_GLOBAL(0xF440ED, uint32*), 0xED600);
@@ -738,7 +740,7 @@ void reload_map_backup(){
memcpy(tile_map_pointers, RCT2_GLOBAL(0xF440F1, uint32*), 0x40000);
uint8* backup_info = RCT2_GLOBAL(0xF440F5, uint8*);
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_FREE_MAP_ELEMENT, uint32) = *(uint32*)backup_info;
gNextFreeMapElement = (rct_map_element*)backup_info;
gMapSizeUnits = *(uint16*)(backup_info + 4);
gMapSizeMinus2 = *(uint16*)(backup_info + 6);
gMapSize = *(uint16*)(backup_info + 8);

View File

@@ -61,6 +61,8 @@ rct_map_element **gMapElementTilePointers = (rct_map_element**)RCT2_ADDRESS_TILE
rct_xy16 *gMapSelectionTiles = (rct_xy16*)0x009DE596;
rct2_peep_spawn *gPeepSpawns = (rct2_peep_spawn*)RCT2_ADDRESS_PEEP_SPAWNS;
rct_map_element *gNextFreeMapElement;
bool gLandMountainMode;
bool gLandPaintMode;
bool LandRightsMode;
@@ -357,7 +359,7 @@ void map_update_tile_pointers()
}
}
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_FREE_MAP_ELEMENT, rct_map_element*) = mapElement;
gNextFreeMapElement = mapElement;
}
/**
@@ -543,12 +545,12 @@ void sub_68B089()
mapElementFirst++;
} while (!map_element_is_last_for_tile(mapElement++));
mapElement = RCT2_GLOBAL(RCT2_ADDRESS_NEXT_FREE_MAP_ELEMENT, rct_map_element*);
mapElement = gNextFreeMapElement;
do {
mapElement--;
} while (mapElement->base_height == 255);
mapElement++;
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_FREE_MAP_ELEMENT, rct_map_element*) = mapElement;
gNextFreeMapElement = mapElement;
}
@@ -3776,8 +3778,8 @@ void map_element_remove(rct_map_element *mapElement)
(mapElement - 1)->flags |= MAP_ELEMENT_FLAG_LAST_TILE;
mapElement->base_height = 0xFF;
if ((mapElement + 1) == RCT2_GLOBAL(RCT2_ADDRESS_NEXT_FREE_MAP_ELEMENT, rct_map_element*)){
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_FREE_MAP_ELEMENT, rct_map_element*)--;
if ((mapElement + 1) == gNextFreeMapElement){
gNextFreeMapElement--;
}
}
@@ -3935,18 +3937,18 @@ void map_reorganise_elements()
*/
int sub_68B044()
{
if (RCT2_GLOBAL(RCT2_ADDRESS_NEXT_FREE_MAP_ELEMENT, rct_map_element*) <= RCT2_ADDRESS(RCT2_ADDRESS_MAP_ELEMENTS_END, rct_map_element))
if (gNextFreeMapElement <= RCT2_ADDRESS(RCT2_ADDRESS_MAP_ELEMENTS_END, rct_map_element))
return 1;
for (int i = 1000; i != 0; --i)
sub_68B089();
if (RCT2_GLOBAL(RCT2_ADDRESS_NEXT_FREE_MAP_ELEMENT, rct_map_element*) <= RCT2_ADDRESS(RCT2_ADDRESS_MAP_ELEMENTS_END, rct_map_element))
if (gNextFreeMapElement <= RCT2_ADDRESS(RCT2_ADDRESS_MAP_ELEMENTS_END, rct_map_element))
return 1;
map_reorganise_elements();
if (RCT2_GLOBAL(RCT2_ADDRESS_NEXT_FREE_MAP_ELEMENT, rct_map_element*) <= RCT2_ADDRESS(RCT2_ADDRESS_MAP_ELEMENTS_END, rct_map_element))
if (gNextFreeMapElement <= RCT2_ADDRESS(RCT2_ADDRESS_MAP_ELEMENTS_END, rct_map_element))
return 1;
else{
gGameCommandErrorText = 894;
@@ -3967,7 +3969,7 @@ rct_map_element *map_element_insert(int x, int y, int z, int flags)
return NULL;
}
newMapElement = RCT2_GLOBAL(RCT2_ADDRESS_NEXT_FREE_MAP_ELEMENT, rct_map_element*);
newMapElement = gNextFreeMapElement;
originalMapElement = TILE_MAP_ELEMENT_POINTER(y * 256 + x);
// Set tile index pointer to point to new element block
@@ -4008,7 +4010,7 @@ rct_map_element *map_element_insert(int x, int y, int z, int flags)
} while (!((newMapElement - 1)->flags & MAP_ELEMENT_FLAG_LAST_TILE));
}
RCT2_GLOBAL(RCT2_ADDRESS_NEXT_FREE_MAP_ELEMENT, rct_map_element*) = newMapElement;
gNextFreeMapElement = newMapElement;
return insertedElement;
}

View File

@@ -280,6 +280,9 @@ extern rct_map_element **gMapElementTilePointers;
extern rct_xy16 *gMapSelectionTiles;
extern rct2_peep_spawn *gPeepSpawns;
extern rct_map_element *gNextFreeMapElement;
// Used in the land tool window to enable mountain tool / land smoothing
extern bool gLandMountainMode;
// Used in the land tool window to allow dragging and changing land styles