1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-19 13:03:11 +01:00

More scenery_place.

There is a bug in the path code
This commit is contained in:
Duncan Frost
2015-05-04 18:08:22 +01:00
parent 49e02fdab8
commit ed685688e2
5 changed files with 139 additions and 5 deletions

View File

@@ -788,8 +788,7 @@ int track_place_scenery(rct_track_scenery* scenery_start, uint8 rideIndex, int o
if (RCT2_GLOBAL(0x00F4414E, uint8) & (1 << 7))
continue;
for (rct_track_scenery* scenery = scenery_start; scenery->scenery_object.flags & 0xFF != 0xFF; scenery++){
continue;
for (rct_track_scenery* scenery = scenery_start; (scenery->scenery_object.flags & 0xFF) != 0xFF; scenery++){
uint8 rotation = RCT2_GLOBAL(RCT2_ADDRESS_TRACK_PREVIEW_ROTATION, uint8);
@@ -945,7 +944,124 @@ int track_place_scenery(rct_track_scenery* scenery_start, uint8 rideIndex, int o
RCT2_GLOBAL(0x00F44129, sint16) = z;
}
}
// 6d0c23
if (RCT2_GLOBAL(0x00F440D4, uint8) == 1 ||
RCT2_GLOBAL(0x00F440D4, uint8) == 2 ||
RCT2_GLOBAL(0x00F440D4, uint8) == 3 ||
RCT2_GLOBAL(0x00F440D4, uint8) == 4 ||
RCT2_GLOBAL(0x00F440D4, uint8) == 5){
uint8 entry_type, entry_index;
if (!find_object_in_entry_group(&scenery->scenery_object, &entry_type, &entry_index)){
entry_type = scenery->scenery_object.flags & 0xF;
if (entry_type != OBJECT_TYPE_PATHS){
RCT2_GLOBAL(0x00F4414E, uint8) |= 1 << 1;
continue;
}
if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8)&SCREEN_FLAGS_TRACK_DESIGNER){
RCT2_GLOBAL(0x00F4414E, uint8) |= 1 << 1;
continue;
}
entry_index = 0;
for (rct_path_type* path = g_pathTypeEntries;
entry_index < object_entry_group_counts[OBJECT_TYPE_PATHS];
path = g_pathTypeEntries[entry_index], entry_index++){
if (path == (rct_path_type*)-1)
continue;
if (path->flags & (1 << 2))
continue;
}
if (entry_index == object_entry_group_counts[OBJECT_TYPE_PATHS]){
RCT2_GLOBAL(0x00F4414E, uint8) |= 1 << 1;
continue;
}
}
money32 cost;
switch (entry_type){
case OBJECT_TYPE_SMALL_SCENERY:
//6d0e74
break;
case OBJECT_TYPE_LARGE_SCENERY:
//6d0f0f
break;
case OBJECT_TYPE_WALLS:
//6d0ddf
break;
case OBJECT_TYPE_PATHS:
if (RCT2_GLOBAL(0x00F440D4, uint8) == 3)
continue;
sint16 z = (scenery->z * 8 + originZ) / 8;
if (mode == 0){
if (scenery->flags & (1 << 7)){
//dh
entry_index |= (1 << 7);
}
uint8 bh = ((scenery->flags & 0xF) << rotation);
uint8 bl = bh >> 4;
bh = (bh | bl) & 0xF;
bl = (((scenery->flags >> 5) + rotation) & 3) << 5;
bh |= bl;
bh |= scenery->flags & 0x90;
bl = 1;
if (RCT2_GLOBAL(0x00F440D4, uint8) == 5)bl = 41;
if (RCT2_GLOBAL(0x00F440D4, uint8) == 4)bl = 105;
if (RCT2_GLOBAL(0x00F440D4, uint8) == 1)bl = 0;
RCT2_GLOBAL(0x00141E9AE, rct_string_id) = 927;
cost = game_do_command(mapCoord.x, bl | (bh << 8), mapCoord.y, z, GAME_COMMAND_18, 0, 0);
}
else{
if (RCT2_GLOBAL(0x00F440D4, uint8) == 1)
continue;
rct_map_element* map_element = map_get_path_element_at(mapCoord.x / 32, mapCoord.y / 32, z);
if (map_element == NULL)
continue;
RCT2_CALLPROC_EBPSAFE(0x006A7594);
sub_6A6AA7(mapCoord.x, mapCoord.y, map_element);
uint8 bl = 1;
if (RCT2_GLOBAL(0x00F440D4, uint8) == 5)bl = 41;
if (RCT2_GLOBAL(0x00F440D4, uint8) == 4)bl = 105;
sub_6A6C66(mapCoord.x, mapCoord.y, map_element, bl);
sub_6A759F();
continue;
}
break;
default:
RCT2_GLOBAL(0x00F4414E, uint8) |= 1 << 1;
continue;
break;
}
RCT2_GLOBAL(0x00F440D5, money32) += cost;
if (RCT2_GLOBAL(0x00F440D4, uint8) != 2){
if (cost == MONEY32_UNDEFINED){
RCT2_GLOBAL(0x00F440D5, money32) = MONEY32_UNDEFINED;
}
}
if (RCT2_GLOBAL(0x00F440D5, money32) != MONEY32_UNDEFINED)
continue;
if (RCT2_GLOBAL(0x00F440D4, uint8) == 2)
continue;
return;
}
}
}
}

View File

@@ -28,8 +28,7 @@
void sub_673883(int x, int y, int z);
void sub_69A48B(int x, int y, int z);
void sub_6A6C66(int x, int y, rct_map_element *mapElement, int flags);
void sub_6A759F();
enum {
FOOTPATH_CONSTRUCTION_FLAG_ALLOW_DURING_PAUSED = 1 << 3

View File

@@ -49,5 +49,7 @@ void footpath_provisional_update();
void footpath_get_coordinates_from_pos(int screenX, int screenY, int *x, int *y, int *direction, rct_map_element **mapElement);
void footpath_bridge_get_info_from_pos(int screenX, int screenY, int *x, int *y, int *direction, rct_map_element **mapElement);
void sub_673883(int x, int y, int z);
void sub_6A6C66(int x, int y, rct_map_element *mapElement, int flags);
void sub_6A759F();
#endif

View File

@@ -174,6 +174,22 @@ rct_map_element *map_get_surface_element_at(int x, int y)
return mapElement;
}
rct_map_element* map_get_path_element_at(int x, int y, int z){
rct_map_element *mapElement = map_get_first_element_at(x, y);
uint8 mapFound = 0;
// Find the path element at known z
do {
if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_PATH)
continue;
if (mapElement->base_height != z)
continue;
return mapElement;
} while (!map_element_is_last_for_tile(mapElement++));
return NULL;
}
/**
*
* rct2: 0x0068AB4C

View File

@@ -256,6 +256,7 @@ void map_element_set_terrain(rct_map_element *element, int terrain);
void map_element_set_terrain_edge(rct_map_element *element, int terrain);
int map_height_from_slope(int x, int y, int slope);
rct_map_element *map_get_surface_element_at(int x, int y);
rct_map_element* map_get_path_element_at(int x, int y, int z);
int map_element_height(int x, int y);
void sub_68B089();
int map_coord_is_connected(int x, int y, int z, uint8 faceDirection);