Esempio n. 1
0
/******************************************************************************\
 Selects a terrain index for a tile depending on its region.
\******************************************************************************/
static int tile_terrain(int tile)
{
        int i, j, base, base_num, trans, terrain, vert_terrain[3], offset;

        base = R_terrain_base(r_tiles[tile].terrain);
        if (base >= R_T_BASES - 1)
                return r_tiles[tile].terrain;

        /* If we are not using transition tiles, just return the base */
        if (!r_globe_transitions.value.n)
                return base;

        /* Each tile vertex can only have up to two base terrains on it, we
           need to find out if the dominant one is present */
        base_num = 0;
        for (i = 0; i < 3; i++) {
                j = r_globe_verts[3 * tile + i].next;
                vert_terrain[i] = base;
                while (j != 3 * tile + i) {
                        terrain = R_terrain_base(r_tiles[j / 3].terrain);
                        if (terrain > vert_terrain[i])
                                trans = vert_terrain[i] = terrain;
                        j = r_globe_verts[j].next;
                }
                if (vert_terrain[i] == base)
                        base_num++;
        }
        if (base_num > 2)
                return r_tiles[tile].terrain;

        /* Swap the base and single terrain if the base only appears once */
        offset = 2 * base;
        if (base_num == 1) {
                trans = base;
                offset++;
        }

        /* Find the lone terrain and assign the transition tile */
        for (i = 0; i < 3; i++)
                if (vert_terrain[i] == trans)
                        break;

        /* Flipped tiles need reversing */
        if (tile < flip_limit) {
                if (i == 1)
                        i = 2;
                else if (i == 2)
                        i = 1;
        }

        return R_T_TRANSITION + offset * 3 + i;
}
Esempio n. 2
0
/******************************************************************************\
 Place starter buildings.
\******************************************************************************/
static void initial_buildings(void)
{
        int i;

        for (i = 0; i < r_tiles_max; i++) {
                if (R_terrain_base(r_tiles[i].terrain) != R_T_GROUND)
                        continue;
                if (C_rand_real() < g_forest.value.f)
                        G_tile_build(i, G_BT_TREE, G_NN_NONE);
        }
}