Exemple #1
0
void scenery_increase_age(int x, int y, rct_map_element *mapElement)
{
	if (mapElement->flags & SMALL_SCENERY_FLAG_ANIMATED)
		return;

	if (mapElement->properties.scenery.age < 255) {
		mapElement->properties.scenery.age++;
		map_invalidate_tile(x, y, mapElement->base_height * 8, mapElement->clearance_height * 8);
	}
}
Exemple #2
0
/**
 *
 *  rct2: 0x006E33D9
 */
void scenery_update_age(int x, int y, rct_map_element *mapElement)
{
	rct_map_element *mapElementAbove;
	rct_scenery_entry *sceneryEntry;

	sceneryEntry = g_smallSceneryEntries[mapElement->properties.scenery.type];
	if (
		!(sceneryEntry->small_scenery.flags & SMALL_SCENERY_FLAG_CAN_BE_WATERED) ||
		(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_WEATHER, uint8) < WEATHER_RAIN) ||
		(mapElement->properties.scenery.age < 5)
	) {
		scenery_increase_age(x, y, mapElement);
		return;
	}

	// Check map elements above, presumebly to see if map element is blocked from rain
	mapElementAbove = mapElement;
	while (!(mapElementAbove->flags & 7)) {
		mapElementAbove++;

		switch (map_element_get_type(mapElementAbove)) {
		case MAP_ELEMENT_TYPE_SCENERY_MULTIPLE:
		case MAP_ELEMENT_TYPE_ENTRANCE:
		case MAP_ELEMENT_TYPE_PATH:
			map_invalidate_tile(x, y, mapElementAbove->base_height * 8, mapElementAbove->clearance_height * 8);
			scenery_increase_age(x, y, mapElement);
			return;
		case MAP_ELEMENT_TYPE_SCENERY:
			sceneryEntry = g_smallSceneryEntries[mapElementAbove->properties.scenery.type];
			if (sceneryEntry->small_scenery.flags & SMALL_SCENERY_FLAG_VOFFSET_CENTRE) {
				scenery_increase_age(x, y, mapElement);
				return;
			}
			break;
		}
	}
	
	// Reset age / water plant
	mapElement->properties.scenery.age = 0;
	map_invalidate_tile(x, y, mapElement->base_height * 8, mapElement->clearance_height * 8);
}
Exemple #3
0
static void ParkEntranceRemoveSegment(sint32 x, sint32 y, sint32 z)
{
    rct_map_element *mapElement;

    mapElement = map_get_park_entrance_element_at(x, y, z, true);
    if (mapElement == NULL)
    {
        return;
    }

    map_invalidate_tile(x, y, mapElement->base_height * 8, mapElement->clearance_height * 8);
    map_element_remove(mapElement);
    update_park_fences(x, y);
}
Exemple #4
0
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;
}