diff -X freeciv_st/diff_ignore -Nur freeciv_st/common/path_finding_gb.c freeciv_x/common/path_finding_gb.c --- freeciv_st/common/path_finding_gb.c Mon Sep 16 16:05:16 2002 +++ freeciv_x/common/path_finding_gb.c Mon Sep 16 15:38:17 2002 @@ -25,8 +25,8 @@ */ #define PF_COST_FACTOR 1000 -/* MAXCOST is (uchar_t)(-1) - some initializations depend on this */ -#define PF_MAXCOST 255 +/* Large enough */ +#define PF_MAXCOST 2000 /*======================================================================*/ /*===================== Hidden structures ==============================*/ @@ -34,7 +34,7 @@ typedef short xy_t; struct pf_node { - u_char cost; /* total cost up to now */ + int cost; /* total cost up to now */ int extra_cost; /* total extra cost up to now */ enum direction8 dir_to_here; enum pf_node_status { @@ -224,6 +224,8 @@ { return SINGLE_MOVE; } +#endif + /* SINGLE_MOVE cost function for SEA_MOVING */ static int single_seamove(pf_map_t the_map, int x, int y, int dir) @@ -234,7 +236,6 @@ else return PF_MAXCOST; } -#endif /* LAND_MOVE cost function for a unit */ static int normal_move_unit(pf_map_t the_map, int x1, int y1, int dir) @@ -257,8 +258,6 @@ return move_cost; } -#if 0 -/* NOT TESTED */ /* IGTER_MOVE cost function for a unit */ static int igter_move_unit(pf_map_t the_map, int x1, int y1, int dir) { @@ -268,19 +267,18 @@ if (map_get_terrain(x1, y1) == T_OCEAN) { if (ground_unit_transporter_capacity(x1, y1, the_map->params->owner) > 0) - move_cost = SINGLE_MOVE; + move_cost = MOVE_COST_ROAD; else move_cost = PF_MAXCOST; } else if (ptile->terrain == T_OCEAN) { move_cost = MOVE_COST_ROAD; } else { - /* Why is it SINGLE_MOVE below? */ - /* Or why is it MOVE_COST_ROAD above? */ - move_cost = (ptile->move_cost[dir] ? SINGLE_MOVE : 0); + move_cost = (ptile->move_cost[dir] ? MOVE_COST_ROAD : 0); } return move_cost; } +#if 0 /* NOT TESTED */ /* LAND_MOVE cost function for a city ?? */ static int normal_move_city(pf_map_t the_map, int x1, int y1, int dir) @@ -487,7 +485,7 @@ cost = (*(the_map->get_cost))(the_map, x1, y1, dir); adjust_cost(the_map, cost); - assert( cost > 0 ); /* No special cases yet */ + assert( cost >= 0 ); /* No special cases yet */ /* Total cost at xy1 */ cost += node_xy->cost; @@ -565,9 +563,20 @@ the_map->y = the_map->params->start_y; the_map->xy = get_xy_from_x_and_y(the_map->x, the_map->y); - the_map->get_cost = normal_move_unit; - //the_map->get_cost = single_seamove; - //the_map->params->get_TB = strict_trireme; + switch (the_map->params->move_type) { + case LAND_MOVING: + if (BV_ISSET(the_map->params->flags, F_IGTER)) { + the_map->get_cost = igter_move_unit; + } else { + the_map->get_cost = normal_move_unit; + } + break; + case SEA_MOVING: + the_map->get_cost = single_seamove; + //the_map->params->get_TB = strict_trireme; + default: + assert(0); + } pf_init_node(the_map, &the_map->lattice[the_map->xy], the_map->x, the_map->y); diff -X freeciv_st/diff_ignore -Nur freeciv_st/common/path_finding_plain.c freeciv_x/common/path_finding_plain.c --- freeciv_st/common/path_finding_plain.c Mon Sep 16 16:04:37 2002 +++ freeciv_x/common/path_finding_plain.c Mon Sep 16 15:49:36 2002 @@ -225,7 +225,7 @@ } if (BV_ISSET(flags, F_IGTER)) { - return SINGLE_MOVE / 3; + return (src->tile->move_cost2[dir] ? MOVE_COST_ROAD : 0); } return src->tile->move_cost2[dir]; diff -X freeciv_st/diff_ignore -Nur freeciv_st/common/test_path_finding.c freeciv_x/common/test_path_finding.c --- freeciv_st/common/test_path_finding.c Mon Sep 16 16:05:16 2002 +++ freeciv_x/common/test_path_finding.c Mon Sep 16 15:54:34 2002 @@ -31,7 +31,7 @@ parameter.turn_mode = TM_NONE; parameter.get_ECOT=my_get_ECOT; - freelog(LOG_NORMAL, "compare_pf: create map for %s at (%d,%d)", + freelog(LOG_DEBUG, "compare_pf: create map for %s at (%d,%d)", unit_name(punit->type), punit->x, punit->y); RF_pf_map = RF_pf_get_map(¶meter); @@ -45,7 +45,9 @@ bool GB_has_one = GB_pf_next(GB_pf_map); if (RF_has_one != GB_has_one) { - freelog(LOG_NORMAL, "problem"); + freelog(LOG_NORMAL, + "problem in compare_pf: create map for %s at (%d,%d)", + unit_name(punit->type), punit->x, punit->y); // return; assert(0); } @@ -54,32 +56,24 @@ break; } -#if 0 - { - struct pf_position RF_pos, GB_pos; - RF_pf_next_get_position(RF_pf_map, &RF_pos); - GB_pf_next_get_position(GB_pf_map, &GB_pos); - - if (!same_pos(RF_pos.x, RF_pos.y, GB_pos.x, GB_pos.y)) { - freelog(LOG_NORMAL, "problem"); - assert(0); - } - } -#endif - #if 1 { struct pf_path RF_path, GB_path; RF_pf_next_get_path(RF_pf_map, &RF_path); GB_pf_next_get_path(GB_pf_map, &GB_path); - pf_print_path(&RF_path); - pf_print_path(&GB_path); - freelog(LOG_NORMAL, " -"); + // pf_print_path(&RF_path); + // pf_print_path(&GB_path); + // freelog(LOG_NORMAL, " -"); if (pf_last_position(&RF_path)->total_BMC != pf_last_position(&GB_path)->total_BMC) { + freelog(LOG_NORMAL, + "problem in compare_pf: create map for %s at (%d,%d)", + unit_name(punit->type), punit->x, punit->y); freelog(LOG_NORMAL, "different BMCs"); + pf_print_path(&RF_path); + pf_print_path(&GB_path); assert(0); } } @@ -93,17 +87,25 @@ int GB_y = GB_pf_next_get_y(GB_pf_map); if (!same_pos(RF_x, RF_y, GB_x, GB_y)) { + struct pf_path RF_path, GB_path; + freelog(LOG_NORMAL, + "problem in compare_pf: create map for %s at (%d,%d)", + unit_name(punit->type), punit->x, punit->y); freelog(LOG_NORMAL, "problem: (%d,%d) vs (%d,%d)", RF_x, RF_y, GB_x, GB_y); + RF_pf_next_get_path(RF_pf_map, &RF_path); + GB_pf_next_get_path(GB_pf_map, &GB_path); + pf_print_path(&RF_path); + pf_print_path(&GB_path); // return; - assert(0); + // assert(0); } } } RF_pf_destroy_map(RF_pf_map); GB_pf_destroy_map(GB_pf_map); - freelog(LOG_NORMAL, "produced same output"); + freelog(LOG_DEBUG, "produced same output"); } /********************************************************************* Binary files freeciv_st/t6.gz and freeciv_x/t6.gz differ Binary files freeciv_st/t7.gz and freeciv_x/t7.gz differ Binary files freeciv_st/testcase.gz and freeciv_x/testcase.gz differ