예제 #1
0
static void cheat_set_grass_length(int length)
{
	int x, y;
	rct_map_element *mapElement;

	for (y = 0; y < 256; y++) {
		for (x = 0; x < 256; x++) {
			mapElement = map_get_surface_element_at(x, y);
			if (!(mapElement->properties.surface.ownership & OWNERSHIP_OWNED))
				continue;

			if (map_element_get_terrain(mapElement) != TERRAIN_GRASS)
				continue;

			if ((mapElement->properties.surface.terrain & 0x1F) > 0)
				continue;

			mapElement->properties.surface.grass_length = length;
		}
	}

	gfx_invalidate_screen();
}
예제 #2
0
/**
 * Randomly places a selection of preset trees on the map. Picks the right tree for the terrain it is placing it on.
 */
static void mapgen_place_trees()
{
	sint32 numGrassTreeIds = 0, numDesertTreeIds = 0, numSnowTreeIds = 0;
	sint32 *grassTreeIds = (sint32*)malloc(countof(GrassTrees) * sizeof(sint32));
	sint32 *desertTreeIds = (sint32*)malloc(countof(DesertTrees) * sizeof(sint32));
	sint32 *snowTreeIds = (sint32*)malloc(countof(SnowTrees) * sizeof(sint32));

	for (sint32 i = 0; i < object_entry_group_counts[OBJECT_TYPE_SMALL_SCENERY]; i++) {
		rct_scenery_entry *sceneryEntry = get_small_scenery_entry(i);
		rct_object_entry_extended *entry = &object_entry_groups[OBJECT_TYPE_SMALL_SCENERY].entries[i];

		if (sceneryEntry == (rct_scenery_entry*)-1 || sceneryEntry == NULL)
			continue;

		sint32 j;
		for (j = 0; j < countof(GrassTrees); j++)
			if (strncmp(GrassTrees[j], entry->name, 8) == 0)
				break;
		if (j != countof(GrassTrees)) {
			grassTreeIds[numGrassTreeIds++] = i;
			continue;
		}

		for (j = 0; j < countof(DesertTrees); j++)
			if (strncmp(DesertTrees[j], entry->name, 8) == 0)
				break;
		if (j != countof(DesertTrees)) {
			desertTreeIds[numDesertTreeIds++] = i;
			continue;
		}

		for (j = 0; j < countof(SnowTrees); j++)
			if (strncmp(SnowTrees[j], entry->name, 8) == 0)
				break;
		if (j != countof(SnowTrees)) {
			snowTreeIds[numSnowTreeIds++] = i;
			continue;
		}
	}

	sint32 availablePositionsCount = 0;
	struct { sint32 x; sint32 y; } tmp, *pos, *availablePositions;
	availablePositions = malloc(256 * 256 * sizeof(tmp));

	// Create list of available tiles
	for (sint32 y = 1; y < gMapSize - 1; y++) {
		for (sint32 x = 1; x < gMapSize - 1; x++) {
			rct_map_element *mapElement = map_get_surface_element_at(x, y);

			// Exclude water tiles
			if ((mapElement->properties.surface.terrain & 0x1F) != 0)
				continue;

			pos = &availablePositions[availablePositionsCount++];
			pos->x = x;
			pos->y = y;
		}
	}

	// Shuffle list
	for (sint32 i = 0; i < availablePositionsCount; i++) {
		sint32 rindex = util_rand() % availablePositionsCount;
		if (rindex == i)
			continue;

		tmp = availablePositions[i];
		availablePositions[i] = availablePositions[rindex];
		availablePositions[rindex] = tmp;
	}

	// Place trees
	float treeToLandRatio = (10 + (util_rand() % 30)) / 100.0f;
	sint32 numTrees = max(4, (sint32)(availablePositionsCount * treeToLandRatio));

	for (sint32 i = 0; i < numTrees; i++) {
		pos = &availablePositions[i];

		sint32 type = -1;
		rct_map_element *mapElement = map_get_surface_element_at(pos->x, pos->y);
		switch (map_element_get_terrain(mapElement)) {
		case TERRAIN_GRASS:
		case TERRAIN_DIRT:
		case TERRAIN_GRASS_CLUMPS:
			if (numGrassTreeIds == 0)
				break;

			type = grassTreeIds[util_rand() % numGrassTreeIds];
			break;

		case TERRAIN_SAND:
		case TERRAIN_SAND_DARK:
		case TERRAIN_SAND_LIGHT:
			if (numDesertTreeIds == 0)
				break;

			if (util_rand() % 4 == 0)
				type = desertTreeIds[util_rand() % numDesertTreeIds];
			break;

		case TERRAIN_ICE:
			if (numSnowTreeIds == 0)
				break;

			type = snowTreeIds[util_rand() % numSnowTreeIds];
			break;
		}

		if (type != -1)
			mapgen_place_tree(type, pos->x, pos->y);
	}

	free(availablePositions);
	free(grassTreeIds);
	free(desertTreeIds);
	free(snowTreeIds);
}
예제 #3
0
static void window_tile_inspector_scrollpaint()
{
	int x = 15, y = 11 * (window_tile_inspector_item_count - 1), i = 0;
	rct_window *w;
	rct_drawpixelinfo *dpi;
	char buffer[256];

	window_paint_get_registers(w, dpi);

	if (window_tile_inspector_tile_x == -1)
		return;

	rct_map_element *element = map_get_first_element_at(window_tile_inspector_tile_x, window_tile_inspector_tile_y);

	do {

		int type = map_element_get_type(element);
		char *type_name;
		int base_height = element->base_height;
		int clearance_height = element->clearance_height;

		if ((i & 1) != 0)
			gfx_fill_rect(dpi, x - 15, y, x + WW - 20, y + 11, RCT2_GLOBAL(0x0141FC4A + (w->colours[1] * 8), uint8) | 0x1000000);

		switch (type) {
			case MAP_ELEMENT_TYPE_SURFACE:
				sprintf(
					buffer,
					"Surface (%s, %s)",
					language_get_string(STR_TILE_INSPECTOR_TERRAIN_START + map_element_get_terrain(element)),
					language_get_string(STR_TILE_INSPECTOR_TERRAIN_EDGE_START + map_element_get_terrain_edge(element))
				);
				type_name = buffer;
				break;
			case MAP_ELEMENT_TYPE_PATH:
			{
				// TODO: use these
				uint8 pathType, pathDirection;
				pathType = element->properties.path.type >> 2;
				pathDirection = element->properties.path.type & 3;
			}
			sprintf(
				buffer,
				"Path (%s)",
				"" // TODO: queue? has bins? has benches? e.t.c.
			);
			type_name = buffer;
			break;
			case MAP_ELEMENT_TYPE_TRACK:
				type_name = "Track"; // TODO: show type?
				break;
			case MAP_ELEMENT_TYPE_SCENERY:
				sprintf(
					buffer,
					"Scenery (%s)",
					language_get_string(g_smallSceneryEntries[element->properties.scenery.type]->name)
				);
				type_name = buffer;
				break;
			case MAP_ELEMENT_TYPE_ENTRANCE:
				sprintf(
					buffer,
					"Entrance (%s)",
					language_get_string(STR_TILE_INSPECTOR_ENTRANCE_START + element->properties.entrance.type)
					);
				type_name = buffer;
				break;
			case MAP_ELEMENT_TYPE_FENCE:
				sprintf(
					buffer,
					"Fence (%s)",
					language_get_string(g_wallSceneryEntries[element->properties.scenery.type]->name)
					);
				type_name = buffer;
				break;
			case MAP_ELEMENT_TYPE_SCENERY_MULTIPLE:
				type_name = "Scenery multiple";
				break;
			case MAP_ELEMENT_TYPE_BANNER:
				sprintf(
					buffer,
					"Banner (%d)",
					element->properties.banner.index
				);
				type_name = buffer;
				break;
		}

		gfx_draw_string(dpi, type_name, 12, x, y);
		gfx_draw_string_left(dpi, 5182, &base_height, 12, x + 200, y);
		gfx_draw_string_left(dpi, 5182, &clearance_height, 12, x + 280, y);

		uint8 flags = element->flags;
		char j;

		buffer[8] = '\0';

		for (j = 7; j >= 0; j--, flags >>= 1) {
			buffer[j] = flags & 1 ? '1' : '0';
		}

		gfx_draw_string(dpi, buffer, 12, x + 390, y);

		y -= 11;
		i++;

	} while (!map_element_is_last_for_tile(element++));

}