Index: bauer/brueckenbauer.cc =================================================================== --- bauer/brueckenbauer.cc (revision 9114) +++ bauer/brueckenbauer.cc (working copy) @@ -930,7 +930,7 @@ void bridge_builder_t::build_ramp(player_t* player, koord3d end, ribi_t::ribi ribi_neu, slope_t::type weg_hang, const bridge_desc_t* desc) { - assert(weg_hang < 81); + assert(weg_hang <= slope_t::raised); grund_t *alter_boden = welt->lookup(end); brueckenboden_t *bruecke; Index: bauer/wegbauer.cc =================================================================== --- bauer/wegbauer.cc (revision 9114) +++ bauer/wegbauer.cc (working copy) @@ -941,20 +941,20 @@ // write middle heights if( dir == koord::north ) { - *new_from_slope = corner_sw(from_slope) + corner_se(from_slope) * 3 + m_from * 9 + m_from * 27; - *new_to_slope = m_to + m_to * 3 + corner_ne(to_slope) * 9 + corner_nw(to_slope) * 27; + *new_from_slope = corner_sw(from_slope) + corner_se(from_slope) * slope_t::southeast + m_from * slope_t::northeast + m_from * slope_t::northwest; + *new_to_slope = m_to + m_to * slope_t::southeast + corner_ne(to_slope) * slope_t::northeast + corner_nw(to_slope) * slope_t::northwest; } else if( dir == koord::east ) { - *new_from_slope = corner_sw(from_slope) + m_from * 3 + m_from * 9 + corner_nw(from_slope) * 27; - *new_to_slope = m_to + corner_se(to_slope) * 3 + corner_ne(to_slope) * 9 + m_to * 27; + *new_from_slope = corner_sw(from_slope) + m_from * slope_t::southeast + m_from * slope_t::northeast + corner_nw(from_slope) * slope_t::northwest; + *new_to_slope = m_to + corner_se(to_slope) * slope_t::southeast + corner_ne(to_slope) * slope_t::northeast + m_to * slope_t::northwest; } else if( dir == koord::south ) { - *new_from_slope = m_from + m_from * 3 + corner_ne(from_slope) * 9 + corner_nw(from_slope) * 27; - *new_to_slope = corner_sw(to_slope) + corner_se(to_slope) * 3 + m_to * 9 + m_to * 27; + *new_from_slope = m_from + m_from * slope_t::southeast + corner_ne(from_slope) * slope_t::northeast + corner_nw(from_slope) * slope_t::northwest; + *new_to_slope = corner_sw(to_slope) + corner_se(to_slope) * slope_t::southeast + m_to * slope_t::northeast + m_to * slope_t::northwest; } else if( dir == koord::west ) { - *new_from_slope = m_from + corner_se(from_slope) * 3 + corner_ne(from_slope) * 9 + m_from * 27; - *new_to_slope = corner_sw(to_slope) + m_to * 3 + m_to * 9 + corner_nw(to_slope) * 27; + *new_from_slope = m_from + corner_se(from_slope) * slope_t::southeast + corner_ne(from_slope) * slope_t::northeast + m_from * slope_t::northwest; + *new_to_slope = corner_sw(to_slope) + m_to * slope_t::southeast + m_to * slope_t::northeast + corner_nw(to_slope) * slope_t::northwest; } return true; } Index: boden/grund.cc =================================================================== --- boden/grund.cc (revision 9114) +++ boden/grund.cc (working copy) @@ -789,7 +789,7 @@ const uint8 back_height = min(corner_nw(slope_this),(i==0?corner_sw(slope_this):corner_ne(slope_this))); const sint16 left_hgt=gr->get_disp_height()-back_height; - const sint8 slope=gr->get_disp_slope(); + const slope_t::type slope=gr->get_disp_slope(); const uint8 corner_a = (i==0?corner_sw(slope_this):corner_nw(slope_this))-back_height; const uint8 corner_b = (i==0?corner_nw(slope_this):corner_ne(slope_this))-back_height; @@ -875,7 +875,7 @@ for(uint i=0; ilookup_kartenboden(k + testdir[i] - koord(step,step)) ) { sint16 h = gr->get_disp_height()*scale_z_step; - sint8 s = gr->get_disp_slope(); + slope_t::type s = gr->get_disp_slope(); // tile should hide anything in tunnel portal behind (tile not in direction of tunnel) if (step == 0 && ((i&1)==0) && s && gr->ist_tunnel()) { if ( ribi_t::reverse_single(ribi_type(s)) != ribi_type(testdir[i])) { @@ -955,7 +955,7 @@ // choose foundation or natural slopes const ground_desc_t *sl_draw = artificial ? ground_desc_t::fundament : ground_desc_t::slopes; - const sint8 disp_slope = get_disp_slope(); + const slope_t::type disp_slope = get_disp_slope(); // first draw left, then back slopes for( size_t i=0; ilookup_kartenboden( k + koord::nsew[(i-1)&3] ); if( gr ) { // for left we test corners 2 and 3 (east), for back we use 1 and 2 (south) - const sint8 gr_slope = gr->get_disp_slope(); + const slope_t::type gr_slope = gr->get_disp_slope(); uint8 corner_a = corner_se(gr_slope); uint8 corner_b = i==0?corner_ne(gr_slope):corner_sw(gr_slope); @@ -1045,7 +1045,7 @@ // get transition climate - look for each corner in turn for( int i = 0; i < 4; i++ ) { - sint8 corner_height = get_hoehe() + (slope_corner % 3); + sint8 corner_height = get_hoehe() + (slope_corner % slope_t::southeast); climate transition_climate = climate0; climate min_climate = arctic_climate; @@ -1068,7 +1068,7 @@ uint8 overlay_corners = 1 << i; slope_t::type slope_corner_se = slope_corner; for( int j = i + 1; j < 4; j++ ) { - slope_corner_se /= 3; + slope_corner_se /= slope_t::southeast; // now we check to see if any of remaining corners have same climate transition (also using highest of course) // if so we combine into this overlay layer @@ -1075,7 +1075,7 @@ if( (climate_corners >> j) & 1 ) { climate compare = climate0; for( int k = 1; k < 4; k++ ) { - corner_height = get_hoehe() + (slope_corner_se % 3); + corner_height = get_hoehe() + (slope_corner_se % slope_t::southeast); if( corner_height == neighbour_height[(j * 2 + k) & 7][(j + k) & 3]) { climate climatej = neighbour_climate[(j * 2 + k) & 7]; climatej > compare ? compare = climatej : 0; @@ -1092,7 +1092,7 @@ display_alpha( ground_desc_t::get_climate_tile( transition_climate, slope ), ground_desc_t::get_alpha_tile( slope, overlay_corners ), ALPHA_GREEN | ALPHA_BLUE, xpos, ypos, 0, 0, true, dirty CLIP_NUM_PAR ); } } - slope_corner /= 3; + slope_corner /= slope_t::southeast; } // finally overlay any water transition if( water_corners ) { Index: boden/grund.h =================================================================== --- boden/grund.h (revision 9114) +++ boden/grund.h (working copy) @@ -198,7 +198,7 @@ /** * Slope (now saved locally), because different grounds need different slopes */ - uint8 slope; + slope_t::type slope; /** * Image of the walls @@ -229,7 +229,7 @@ static karte_ptr_t welt; // calculates the slope image and sets the draw_as_obj flag correctly - void calc_back_image(const sint8 hgt,const sint8 slope_this); + void calc_back_image(const sint8 hgt,const slope_t::type slope_this); // this is the real image calculation, called for the actual ground image virtual void calc_image_internal(const bool calc_only_snowline_change) = 0; Index: descriptor/way_desc.h =================================================================== --- descriptor/way_desc.h (revision 9114) +++ descriptor/way_desc.h (working copy) @@ -136,28 +136,28 @@ const uint16 n = image_list_base_index(season, front) + 1; uint16 nr; switch(slope) { - case 4: + case slope_t::north: nr = 0; break; - case 12: + case slope_t::west: nr = 1; break; - case 28: + case slope_t::east: nr = 2; break; - case 36: + case slope_t::south: nr = 3; break; - case 8: + case slope_t::north*2: nr = 4; break; - case 24: + case slope_t::west*2: nr = 5; break; - case 56: + case slope_t::east*2: nr = 6; break; - case 72: + case slope_t::south*2: nr = 7; break; default: Index: simworld.cc =================================================================== --- simworld.cc (revision 9114) +++ simworld.cc (working copy) @@ -368,7 +368,7 @@ const sint8 disp_hn_ne = max( height + corner_ne(slope), water_hgt ); const sint8 disp_hn_nw = max( height + corner_nw(slope), water_hgt ); height = water_hgt; - slope = (disp_hn_sw - height) + ((disp_hn_se - height) * 3) + ((disp_hn_ne - height) * 9) + ((disp_hn_nw - height) * 27); + slope = (disp_hn_sw - height) + ((disp_hn_se - height) * slope_t::southeast) + ((disp_hn_ne - height) * slope_t::northeast) + ((disp_hn_nw - height) * slope_t::northwest); } gr->set_pos( koord3d( k, height) ); @@ -2403,7 +2403,7 @@ const sint8 disp_hn_se = max( hn_se, water_hgt ); const sint8 disp_hn_ne = max( hn_ne, water_hgt ); const sint8 disp_hn_nw = max( hn_nw, water_hgt ); - const uint8 sneu = (disp_hn_sw - disp_hneu) + ((disp_hn_se - disp_hneu) * 3) + ((disp_hn_ne - disp_hneu) * 9) + ((disp_hn_nw - disp_hneu) * 27); + const uint8 sneu = (disp_hn_sw - disp_hneu) + ((disp_hn_se - disp_hneu) * slope_t::southeast) + ((disp_hn_ne - disp_hneu) * slope_t::northeast) + ((disp_hn_nw - disp_hneu) * slope_t::northwest); bool ok = (hmaxneu - hneu <= max_hdiff); // may fail on water tiles since lookup_hgt might be modified from previous raise_to calls if (!ok && !gr->is_water()) { @@ -2706,7 +2706,7 @@ const sint8 disp_hn_se = max( hn_se, water_hgt ); const sint8 disp_hn_ne = max( hn_ne, water_hgt ); const sint8 disp_hn_nw = max( hn_nw, water_hgt ); - const uint8 sneu = (disp_hn_sw - disp_hneu) + ((disp_hn_se - disp_hneu) * 3) + ((disp_hn_ne - disp_hneu) * 9) + ((disp_hn_nw - disp_hneu) * 27); + const uint8 sneu = (disp_hn_sw - disp_hneu) + ((disp_hn_se - disp_hneu) * slope_t::southeast) + ((disp_hn_ne - disp_hneu) * slope_t::northeast) + ((disp_hn_nw - disp_hneu) * slope_t::northwest); // change height and slope for land tiles only if( !gr->is_water() || (hmaxneu > water_hgt) ) { @@ -4453,7 +4453,7 @@ const sint16 d2 = min( corner_height[1] - new_height, max_hdiff ); const sint16 d3 = min( corner_height[2] - new_height, max_hdiff ); const sint16 d4 = min( corner_height[3] - new_height, max_hdiff ); - return d4 * 27 + d3 * 9 + d2 * 3 + d1; + return d4 * slope_t::northwest + d3 * slope_t::northeast + d2 * slope_t::southeast + d1; } return 0; } @@ -4477,7 +4477,7 @@ const int d3=h3-mini; const int d4=h4-mini; - return d1 * 27 + d2 * 9 + d3 * 3 + d4; + return d1 * slope_t::northwest + d2 * slope_t::northeast + d3 * slope_t::southeast + d4; } return 0; } @@ -5417,7 +5417,10 @@ sint8 slope; file->rdwr_byte(slope); // convert slopes from old single height saved game - slope = (scorner_sw(slope) + scorner_se(slope) * 3 + scorner_ne(slope) * 9 + scorner_nw(slope) * 27) * env_t::pak_height_conversion_factor; + slope = (scorner_sw(slope) + + scorner_se(slope) * slope_t::southeast + + scorner_ne(slope) * slope_t::northeast + + scorner_nw(slope) * slope_t::northwest) * env_t::pak_height_conversion_factor; access_nocheck(x, y)->get_kartenboden()->set_grund_hang(slope); } } @@ -5898,8 +5901,8 @@ grund_t *gr2 = pl2->get_kartenboden(); slope_t::type slope_corner = gr2->get_grund_hang(); for( int j = 0; j < 4; j++ ) { - neighbour_height[i][j] = gr2->get_hoehe() + slope_corner % 3; - slope_corner /= 3; + neighbour_height[i][j] = gr2->get_hoehe() + slope_corner % slope_t::southeast; + slope_corner /= slope_t::southeast; } } else { @@ -6020,7 +6023,7 @@ // corner_se (i=1): tests vs neighbour 3:s (corner 3 j=2),4:se (corner 4) and 5:e (corner 1) // corner_ne (i=2): tests vs neighbour 5:e (corner 4 j=3),6:ne (corner 1) and 7:n (corner 2) // corner_nw (i=3): tests vs neighbour 7:n (corner 1 j=0),0:nw (corner 2) and 1:w (corner 3) - sint8 corner_height = gr->get_hoehe() + slope_corner % 3; + sint8 corner_height = gr->get_hoehe() + slope_corner % slope_t::southeast; climate transition_climate = water_climate; climate min_climate = arctic_climate; @@ -6036,7 +6039,7 @@ if( min_climate == water_climate || transition_climate > climate0 ) { climate_corners |= 1 << i; } - slope_corner /= 3; + slope_corner /= slope_t::southeast; } pl->set_climate_transition_flag( climate_corners != 0 ); pl->set_climate_corners( climate_corners );