static void mapgen_place_tree(sint32 type, sint32 x, sint32 y) { sint32 surfaceZ; rct_map_element *mapElement; rct_scenery_entry *sceneryEntry = get_small_scenery_entry(type); surfaceZ = map_element_height(x * 32 + 16, y * 32 + 16) / 8; mapElement = map_element_insert(x, y, surfaceZ, (1 | 2 | 4 | 8)); assert(mapElement != NULL); mapElement->clearance_height = surfaceZ + (sceneryEntry->small_scenery.height >> 3); mapElement->type = MAP_ELEMENT_TYPE_SCENERY | (util_rand() & 3); mapElement->properties.scenery.type = type; mapElement->properties.scenery.age = 0; mapElement->properties.scenery.colour_1 = COLOUR_YELLOW; }
static void mapgen_place_tree(int type, int x, int y) { int surfaceZ; rct_map_element *mapElement; rct_scenery_entry *sceneryEntry = g_smallSceneryEntries[type]; surfaceZ = map_element_height(x * 32 + 16, y * 32 + 16) / 8; mapElement = map_element_insert(x, y, surfaceZ, (1 | 2 | 4 | 8)); mapElement->clearance_height = surfaceZ + (sceneryEntry->small_scenery.height >> 3); mapElement->type = MAP_ELEMENT_TYPE_SCENERY | (util_rand() % 3); mapElement->properties.scenery.type = type; mapElement->properties.scenery.age = 0; mapElement->properties.scenery.colour_1 = 26; mapElement->properties.scenery.colour_1 = 18; }
static money32 ParkEntrancePlace(sint32 flags, sint16 x, sint16 y, uint8 z, uint8 direction) { if (!(gScreenFlags & SCREEN_FLAGS_EDITOR) && !gCheatsSandboxMode) { return MONEY32_UNDEFINED; } gCommandExpenditureType = RCT_EXPENDITURE_TYPE_LAND_PURCHASE; gCommandPosition.x = x; gCommandPosition.y = y; gCommandPosition.z = z * 16; if (!map_check_free_elements_and_reorganise(3)) { return MONEY32_UNDEFINED; } if (x <= 32 || y <= 32 || x >= (gMapSizeUnits - 32) || y >= (gMapSizeUnits - 32)) { gGameCommandErrorText = STR_TOO_CLOSE_TO_EDGE_OF_MAP; return MONEY32_UNDEFINED; } sint8 entranceNum = -1; for (uint8 i = 0; i < MAX_PARK_ENTRANCES; ++i) { if (gParkEntrances[i].x == MAP_LOCATION_NULL) { entranceNum = i; break; } } if (entranceNum == -1) { gGameCommandErrorText = STR_ERR_TOO_MANY_PARK_ENTRANCES; return MONEY32_UNDEFINED; } if (flags & GAME_COMMAND_FLAG_APPLY) { gParkEntrances[entranceNum].x = x; gParkEntrances[entranceNum].y = y; gParkEntrances[entranceNum].z = z * 16; gParkEntrances[entranceNum].direction = direction; } sint8 zLow = z * 2; sint8 zHigh = zLow + 12; for (uint8 index = 0; index < 3; index++) { if (index == 1) { x += TileDirectionDelta[(direction - 1) & 0x3].x; y += TileDirectionDelta[(direction - 1) & 0x3].y; } else if (index == 2) { x += TileDirectionDelta[(direction + 1) & 0x3].x * 2; y += TileDirectionDelta[(direction + 1) & 0x3].y * 2; } if (!gCheatsDisableClearanceChecks) { if (!map_can_construct_at(x, y, zLow, zHigh, 0xF)) { return MONEY32_UNDEFINED; } } // Check that entrance element does not already exist at this location rct_map_element* entranceElement = map_get_park_entrance_element_at(x, y, zLow, false); if (entranceElement != NULL) { return MONEY32_UNDEFINED; } if (!(flags & GAME_COMMAND_FLAG_APPLY)) { continue; } if (!(flags & GAME_COMMAND_FLAG_GHOST)) { rct_map_element* surfaceElement = map_get_surface_element_at(x / 32, y / 32); surfaceElement->properties.surface.ownership = 0; } rct_map_element* newElement = map_element_insert(x / 32, y / 32, zLow, 0xF); assert(newElement != NULL); newElement->clearance_height = zHigh; if (flags & GAME_COMMAND_FLAG_GHOST) { newElement->flags |= MAP_ELEMENT_FLAG_GHOST; } newElement->type = MAP_ELEMENT_TYPE_ENTRANCE; newElement->type |= direction; newElement->properties.entrance.index = index; newElement->properties.entrance.type = ENTRANCE_TYPE_PARK_ENTRANCE; newElement->properties.entrance.path_type = gFootpathSelectedId; if (!(flags & GAME_COMMAND_FLAG_GHOST)) { footpath_connect_edges(x, y, newElement, 1); } update_park_fences(x, y); update_park_fences(x - 32, y); update_park_fences(x + 32, y); update_park_fences(x, y - 32); update_park_fences(x, y + 32); map_invalidate_tile(x, y, newElement->base_height * 8, newElement->clearance_height * 8); if (index == 0) { map_animation_create(MAP_ANIMATION_TYPE_PARK_ENTRANCE, x, y, zLow); } } return 0; }
static money32 RideEntranceExitPlace(sint16 x, sint16 y, sint16 z, uint8 direction, uint8 flags, uint8 rideIndex, uint8 stationNum, bool isExit) { // Remember when in Unknown station num mode rideIndex is unknown and z is set // When in known station num mode rideIndex is known and z is unknown money32 cost = 0; gCommandPosition.x = x; gCommandPosition.y = y; if (!map_check_free_elements_and_reorganise(1)) { return MONEY32_UNDEFINED; } if (!(flags & GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED) && game_is_paused() && !gCheatsBuildInPauseMode) { gGameCommandErrorText = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED; return MONEY32_UNDEFINED; } if (stationNum == 0xFF) { z *= 16; if (flags & GAME_COMMAND_FLAG_APPLY) { return MONEY32_UNDEFINED; } if (!gCheatsSandboxMode && !map_is_location_owned(x, y, z)) { return MONEY32_UNDEFINED; } sint16 clear_z = z / 8 + (isExit ? 5 : 7); if (!gCheatsDisableClearanceChecks && !map_can_construct_with_clear_at(x, y, z / 8, clear_z, &map_place_non_scenery_clear_func, 0xF, flags, &cost)) { return MONEY32_UNDEFINED; } if (gMapGroundFlags & ELEMENT_IS_UNDERWATER) { gGameCommandErrorText = STR_RIDE_CANT_BUILD_THIS_UNDERWATER; return MONEY32_UNDEFINED; } if (z / 8 > 244) { gGameCommandErrorText = STR_TOO_HIGH; return MONEY32_UNDEFINED; } } else { if (rideIndex >= MAX_RIDES) { log_warning("Invalid game command for ride %u", rideIndex); return MONEY32_UNDEFINED; } rct_ride* ride = get_ride(rideIndex); if (ride->type == RIDE_TYPE_NULL) { log_warning("Invalid game command for ride %u", rideIndex); return MONEY32_UNDEFINED; } if (ride->status != RIDE_STATUS_CLOSED) { gGameCommandErrorText = STR_MUST_BE_CLOSED_FIRST; return MONEY32_UNDEFINED; } if (ride->lifecycle_flags & RIDE_LIFECYCLE_INDESTRUCTIBLE_TRACK) { gGameCommandErrorText = STR_NOT_ALLOWED_TO_MODIFY_STATION; return MONEY32_UNDEFINED; } ride_clear_for_construction(rideIndex); ride_remove_peeps(rideIndex); bool requiresRemove = false; rct_xy16 removeCoord = { 0, 0 }; if (isExit) { if (ride->exits[stationNum] != 0xFFFF) { if (flags & GAME_COMMAND_FLAG_GHOST) { gGameCommandErrorText = 0; return MONEY32_UNDEFINED; } removeCoord.x = (ride->exits[stationNum] & 0xFF) * 32; removeCoord.y = ((ride->exits[stationNum] >> 8) & 0xFF) * 32; requiresRemove = true; } } else if (ride->entrances[stationNum] != 0xFFFF) { if (flags & GAME_COMMAND_FLAG_GHOST) { gGameCommandErrorText = 0; return MONEY32_UNDEFINED; } removeCoord.x = (ride->entrances[stationNum] & 0xFF) * 32; removeCoord.y = ((ride->entrances[stationNum] >> 8) & 0xFF) * 32; requiresRemove = true; } if (requiresRemove) { money32 success = game_do_command( removeCoord.x, flags, removeCoord.y, rideIndex, GAME_COMMAND_REMOVE_RIDE_ENTRANCE_OR_EXIT, stationNum, 0 ); if (success == MONEY32_UNDEFINED) { return MONEY32_UNDEFINED; } } z = ride->station_heights[stationNum] * 8; gCommandPosition.z = z; if ((flags & GAME_COMMAND_FLAG_APPLY) && !(flags & GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED) && !(flags & GAME_COMMAND_FLAG_GHOST)) { footpath_remove_litter(x, y, z); wall_remove_at_z(x, y, z); } if (!gCheatsSandboxMode && !map_is_location_owned(x, y, z)) { return MONEY32_UNDEFINED; } sint8 clear_z = (z / 8) + (isExit ? 5 : 7); if (!gCheatsDisableClearanceChecks && !map_can_construct_with_clear_at(x, y, z / 8, clear_z, &map_place_non_scenery_clear_func, 0xF, flags, &cost)) { return MONEY32_UNDEFINED; } if (gMapGroundFlags & ELEMENT_IS_UNDERWATER) { gGameCommandErrorText = STR_RIDE_CANT_BUILD_THIS_UNDERWATER; return MONEY32_UNDEFINED; } if (z / 8 > 244) { gGameCommandErrorText = STR_TOO_HIGH; return MONEY32_UNDEFINED; } if (flags & GAME_COMMAND_FLAG_APPLY) { rct_xyz16 coord; coord.x = x + 16; coord.y = y + 16; coord.z = map_element_height(coord.x, coord.y); network_set_player_last_action_coord(network_get_player_index(game_command_playerid), coord); rct_map_element* mapElement = map_element_insert(x / 32, y / 32, z / 8, 0xF); assert(mapElement != NULL); mapElement->clearance_height = clear_z; mapElement->properties.entrance.type = isExit; mapElement->properties.entrance.index = stationNum << 4; mapElement->properties.entrance.ride_index = rideIndex; mapElement->type = MAP_ELEMENT_TYPE_ENTRANCE | direction; if (flags & GAME_COMMAND_FLAG_GHOST) { mapElement->flags |= MAP_ELEMENT_FLAG_GHOST; } if (isExit) { ride->exits[stationNum] = (x / 32) | (y / 32 << 8); } else { ride->entrances[stationNum] = (x / 32) | (y / 32 << 8); ride->last_peep_in_queue[stationNum] = SPRITE_INDEX_NULL; ride->queue_length[stationNum] = 0; map_animation_create(MAP_ANIMATION_TYPE_RIDE_ENTRANCE, x, y, z / 8); } footpath_queue_chain_reset(); if (!(flags & GAME_COMMAND_FLAG_GHOST)) { maze_entrance_hedge_removal(x, y, mapElement); } footpath_connect_edges(x, y, mapElement, flags); sub_6A759F(); map_invalidate_tile_full(x, y); } }