? RC ? a ? a.c ? ai_utype_check.patch ? auto.rc ? autoconf252.patch ? b.c ? bad ? city_sorting2.diff ? conndlg13.patch ? diff ? embass.gz ? gmon.out ? good ? log ? misc1.patch ? popdown1.diff ? sound_fix1.diff ? stats ? test.c ? timeoutincrement7.diff ? client/agents/goto_agent.c ? client/agents/goto_agent.h ? common/bad.c ? common/good.c ? common/goto_agent.h ? common/path_finding.c ? common/path_finding.h ? data/stdsounds ? data/stdsounds.spec ? data/engels/Makefile ? data/engels/Makefile.in ? data/hires/Makefile ? data/hires/Makefile.in Index: common/Makefile.am =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/Makefile.am,v retrieving revision 1.39 diff -u -r1.39 Makefile.am --- common/Makefile.am 2002/01/09 21:48:08 1.39 +++ common/Makefile.am 2002/06/06 16:14:21 @@ -54,6 +54,8 @@ packets.h \ packets_lsend.c \ packets_lsend.h \ + path_finding.h \ + path_finding.c \ player.c \ player.h \ mem.c \ Index: common/map.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/map.c,v retrieving revision 1.119 diff -u -r1.119 map.c --- common/map.c 2002/02/27 08:19:02 1.119 +++ common/map.c 2002/06/06 16:14:22 @@ -1429,7 +1429,7 @@ case DIR8_NORTHWEST: return "NW"; default: - assert(0); + //assert(0); return "[Bad Direction]"; } } Index: common/map.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/map.h,v retrieving revision 1.125 diff -u -r1.125 map.h --- common/map.h 2002/02/27 10:33:08 1.125 +++ common/map.h 2002/06/06 16:14:22 @@ -202,7 +202,9 @@ void initialize_move_costs(void); void reset_move_costs(int x, int y); -#define CHECK_MAP_POS(x,y) assert(is_normal_map_pos((x),(y))) +#define CHECK_MAP_POS(x,y) ((void)0) + +//assert(is_normal_map_pos((x),(y))) #define map_adjust_x(X) \ ((X) < 0 \ Index: common/unit.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/unit.c,v retrieving revision 1.158 diff -u -r1.158 unit.c --- common/unit.c 2002/04/05 05:25:38 1.158 +++ common/unit.c 2002/06/06 16:14:23 @@ -1197,6 +1197,20 @@ } /************************************************************************** + Wrapper. +**************************************************************************/ +bool can_step_taken_wrt_to_zoc(Unit_Type_id type, + struct player *unit_owner, int src_x, + int src_y, int dest_x, int dest_y) +{ + struct unit_type *ptype = get_unit_type(type); + + return base_can_step_taken_wrt_to_zoc(ptype->move_type, ptype->flags, + unit_owner, src_x, src_y, dest_x, + dest_y); +} + +/************************************************************************** Returns whether the unit is allowed (by ZOC) to move from (src_x,src_y) to (dest_x,dest_y) (assumed adjacent). You CAN move if: @@ -1207,12 +1221,14 @@ 5. You're moving from an ocean square (from a boat) 6. The spot you're moving from or to is in your ZOC **************************************************************************/ -bool can_step_taken_wrt_to_zoc(Unit_Type_id type, - struct player *unit_owner, int src_x, - int src_y, int dest_x, int dest_y) +bool base_can_step_taken_wrt_to_zoc(enum unit_move_type move_type, + unsigned int flags, + struct player *unit_owner, int src_x, + int src_y, int dest_x, int dest_y) { - if (unit_type_really_ignores_zoc(type)) + if (move_type != LAND_MOVING || TEST_BIT(flags, F_IGZOC)) { return TRUE; + } if (is_allied_unit_tile(map_get_tile(dest_x, dest_y), unit_owner)) return TRUE; if (map_get_city(src_x, src_y) || map_get_city(dest_x, dest_y)) @@ -1255,6 +1271,23 @@ } /************************************************************************** + Wrapper. +**************************************************************************/ +enum unit_move_result test_unit_move_to_tile(Unit_Type_id type, + struct player *unit_owner, + enum unit_activity activity, + bool connecting, int src_x, + int src_y, int dest_x, + int dest_y, bool igzoc) +{ + struct unit_type *ptype = get_unit_type(type); + + return base_test_unit_move_to_tile(ptype->move_type, ptype->flags, + unit_owner, activity, connecting, + src_x, src_y, dest_x, dest_y, igzoc); +} + +/************************************************************************** unit can be moved if: 1) the unit is idle or on goto or connecting. 2) the target location is on the map @@ -1268,12 +1301,15 @@ 9) there is not a peaceful but un-allied city on the target tile 10) there is no non-allied unit blocking (zoc) [or igzoc is true] **************************************************************************/ -enum unit_move_result test_unit_move_to_tile(Unit_Type_id type, - struct player *unit_owner, - enum unit_activity activity, - bool connecting, int src_x, - int src_y, int dest_x, - int dest_y, bool igzoc) +enum unit_move_result base_test_unit_move_to_tile(enum unit_move_type + move_type, + unsigned int flags, + struct player *unit_owner, + enum unit_activity + activity, bool connecting, + int src_x, int src_y, + int dest_x, int dest_y, + bool igzoc) { struct tile *pfromtile, *ptotile; bool zoc; @@ -1304,7 +1340,7 @@ return MR_DESTINATION_OCCUPIED_BY_NON_ALLIED_UNIT; } - if (unit_types[type].move_type == LAND_MOVING) { + if (move_type == LAND_MOVING) { /* 5) */ if (ptotile->terrain == T_OCEAN && ground_unit_transporter_capacity(dest_x, dest_y, unit_owner) <= 0) { @@ -1314,12 +1350,12 @@ /* Moving from ocean */ if (pfromtile->terrain == T_OCEAN) { /* 6) */ - if (!unit_type_flag(type, F_MARINES) + if (!TEST_BIT(flags, F_MARINES) && is_enemy_city_tile(ptotile, unit_owner)) { return MR_BAD_TYPE_FOR_CITY_TAKE_OVER; } } - } else if (unit_types[type].move_type == SEA_MOVING) { + } else if (move_type == SEA_MOVING) { /* 7) */ if (ptotile->terrain != T_OCEAN && ptotile->terrain != T_UNKNOWN @@ -1341,8 +1377,8 @@ /* 10) */ zoc = igzoc - || can_step_taken_wrt_to_zoc(type, unit_owner, src_x, - src_y, dest_x, dest_y); + || base_can_step_taken_wrt_to_zoc(move_type, flags, unit_owner, src_x, + src_y, dest_x, dest_y); if (!zoc) { return MR_ZOC; } Index: common/unit.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/unit.h,v retrieving revision 1.88 diff -u -r1.88 unit.h --- common/unit.h 2002/04/12 13:50:57 1.88 +++ common/unit.h 2002/06/06 16:14:24 @@ -251,6 +251,10 @@ bool can_step_taken_wrt_to_zoc(Unit_Type_id type, struct player *unit_owner, int src_x, int src_y, int dest_x, int dest_y); +bool base_can_step_taken_wrt_to_zoc(enum unit_move_type move_type, + unsigned int flags, + struct player *unit_owner, int src_x, + int src_y, int dest_x, int dest_y); bool can_unit_move_to_tile(struct unit *punit, int dest_x, int dest_y, bool igzoc); enum unit_move_result test_unit_move_to_tile(Unit_Type_id type, @@ -259,6 +263,15 @@ bool connecting, int src_x, int src_y, int dest_x, int dest_y, bool igzoc); +enum unit_move_result base_test_unit_move_to_tile(enum unit_move_type + move_type, + unsigned int flags, + struct player *unit_owner, + enum unit_activity + activity, bool connecting, + int src_x, int src_y, + int dest_x, int dest_y, + bool igzoc); bool unit_type_really_ignores_zoc(Unit_Type_id type); bool zoc_ok_move_gen(struct unit *punit, int x1, int y1, int x2, int y2); bool zoc_ok_move(struct unit *punit, int x, int y); Index: server/gotohand.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/gotohand.c,v retrieving revision 1.143 diff -u -r1.143 gotohand.c --- server/gotohand.c 2002/03/13 11:49:20 1.143 +++ server/gotohand.c 2002/06/06 16:14:25 @@ -26,9 +26,12 @@ #include "settlers.h" #include "unithand.h" #include "unittools.h" +#include "path_finding.h" #include "gotohand.h" +static bool log_this = FALSE; + struct move_cost_map warmap; struct stack_element { @@ -316,6 +319,10 @@ /* (?) was punit->type == U_SETTLERS -- dwp */ while (get_from_mapqueue(&x, &y)) { + if (log_this) { + freelog(LOG_NORMAL, "%d mark: (%d, %d) cost=%d/%d", x*1000+y,x, y, + warmap.cost[x][y], warmap.seacost[x][y]); + } ptile = map_get_tile(x, y); adjc_dir_iterate(x, y, x1, y1, dir) { switch (move_type) { @@ -377,6 +384,95 @@ orig_x, orig_y); } +static enum known_type my_get_known(int x, int y, struct player *pplayer) +{ + if (map_get_known(x, y, pplayer)) { + if (map_get_own_seen(x, y, pplayer) > 0) { + return TILE_KNOWN; + } else { + return TILE_KNOWN_FOGGED; + } + } else { + return TILE_UNKNOWN; + } +} + +static int my_extra_cost1(int x, int y, enum known_type known, + void *user_data) +{ + if (known == TILE_UNKNOWN) { + return PF_IGNORE_COST; + } + return 0;//(x + y) * PF_BMC_FACTOR; +} + +static void stimulate_pf(struct unit *punit) +{ + struct pf_parameter parameter; + pf_map_t pf_map; + pf_location_t location; + + if(!log_this) return; + + parameter.start_x = punit->x; + parameter.start_y = punit->y; + parameter.moves_left_initially = punit->moves_left; + parameter.owner = unit_owner(punit); + parameter.move_type = unit_type(punit)->move_type; + parameter.flags = unit_type(punit)->flags; + parameter.move_rate = unit_type(punit)->move_rate; + parameter.move_backward = FALSE; + parameter.turn_mode = TC_NONE; + parameter.turn_cost_factor = 0;//100 * PF_BMC_FACTOR; + parameter.move_cost_factor = 0;//10 * PF_BMC_FACTOR; + parameter.get_known = my_get_known; + parameter.restriction = GOTO_MOVE_ANY; + parameter.user_data1 = NULL; + parameter.extra_cost1 = my_extra_cost1; + parameter.is_position_safe = NULL; + + freelog(LOG_NORMAL, "stimulate_pf: create map for %s at (%d,%d)", + unit_name(punit->type), punit->x, punit->y); + + pf_map = pf_get_map(¶meter); + + while(pf_get_next_location(pf_map, &location)) { +#if 0 + struct pf_path path; + + freelog(LOG_NORMAL, "stimulate_pf: now calling construct_path"); + + pf_construct_path(pf_map, &path, location); + freelog(LOG_NORMAL, "stimulate_pf: now calling print_path"); + pf_print_path(&path); + freelog(LOG_NORMAL, + "%d MARK: (%d, %d) BMC=%d, min=(%d/%d) ave=(%d/%d) max=(%d/%d)", + pf_get_location_x(pf_map, location)*1000+ + pf_get_location_y(pf_map, location), + pf_get_location_x(pf_map, location), + pf_get_location_y(pf_map, location), + last_position_on_path(&path)->total_BMC, + + last_position_on_path(&path)->turn[MINIMAL_TURN], + last_position_on_path(&path)-> + remaining_move_points[MINIMAL_TURN], + + last_position_on_path(&path)->turn[AVERAGE_TURN], + last_position_on_path(&path)-> + remaining_move_points[AVERAGE_TURN], + last_position_on_path(&path)->turn[MAXIMAL_TURN], + last_position_on_path(&path)-> + remaining_move_points[MAXIMAL_TURN]); +#else + freelog(LOG_NORMAL, "(%d, %d)", + pf_get_location_x(pf_map, location), + pf_get_location_y(pf_map, location)); +#endif + } + + pf_destroy_map(pf_map); +} + /************************************************************************** This is a wrapper for really_generate_warmap that checks if the warmap we want is allready in existence. Also calls correctly depending on whether @@ -389,6 +485,18 @@ freelog(LOG_DEBUG, "Generating warmap, pcity = %s, punit = %s", (pcity ? pcity->name : "NULL"), (punit ? unit_type(punit)->name : "NULL")); + + if (game.turn > 10) { + int i; + + log_this = TRUE; + for (i = 0; i < 400; i++) { + stimulate_pf(punit); + really_generate_warmap(pcity, punit, LAND_MOVING); + } + exit(EXIT_SUCCESS); + assert(0); + } if (punit) { /* Index: server/srv_main.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/srv_main.c,v retrieving revision 1.80 diff -u -r1.80 srv_main.c --- server/srv_main.c 2002/05/17 03:13:08 1.80 +++ server/srv_main.c 2002/06/06 16:14:27 @@ -55,6 +55,7 @@ #include "nation.h" #include "netintf.h" #include "packets.h" +#include "path_finding.h" #include "player.h" #include "rand.h" #include "registry.h" @@ -1757,6 +1758,8 @@ gamelog_init(srvarg.gamelog_filename); gamelog_set_level(GAMELOG_FULL); gamelog(GAMELOG_NORMAL, _("Starting new log")); + + pf_init(); #ifdef GENERATING_MAC /* mac beta notice */ con_puts(C_COMMENT, ""); @@ -1942,6 +1945,13 @@ initialize_move_costs(); /* this may be the wrong place to do this */ generate_minimap(); /* for city_desire; saves a lot of calculations */ + + players_iterate(pplayer) { + unit_list_iterate(pplayer->units, punit) { + if (is_ground_unit(punit)) + generate_warmap(NULL, punit); + } unit_list_iterate_end; + } players_iterate_end; if (!game.is_new_game) { players_iterate(pplayer) {