? mmm.gz Index: server/gotohand.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/gotohand.c,v retrieving revision 1.169 diff -u -r1.169 gotohand.c --- server/gotohand.c 2003/03/07 05:08:42 1.169 +++ server/gotohand.c 2003/03/13 16:54:36 @@ -30,8 +30,12 @@ #include "airgoto.h" #include "maphand.h" #include "settlers.h" +#include "stdinhand.h" #include "unithand.h" #include "unittools.h" +#include "path_finding.h" +#include "pf_tools.h" +#include "srv_main.h" #include "aitools.h" @@ -355,6 +359,28 @@ orig_x, orig_y); } +static void stimulate_pf(struct unit *punit) +{ + struct pf_parameter parameter; + struct pf_map *pf_map; + + pft_fill_default_parameter(¶meter); + pft_fill_unit_parameter(¶meter, punit); + + parameter.omniscience = TRUE; + parameter.zoc_used = FALSE; + parameter.get_TB = NULL; + + freelog(LOG_DEBUG, "stimulate_pf: create map for %s at (%d,%d)", + unit_name(punit->type), punit->x, punit->y); + + pf_map = pf_create_map(¶meter); + + while (pf_next(pf_map)) { + } + 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 @@ -364,9 +390,59 @@ **************************************************************************/ void generate_warmap(struct city *pcity, struct unit *punit) { + static int report_counter = 0, next_turn = 0; + static double gotohand = 0.0; + static double path_finding = 0.0; + freelog(LOG_DEBUG, "Generating warmap, pcity = %s, punit = %s", (pcity ? pcity->name : "NULL"), (punit ? unit_type(punit)->name : "NULL")); + if (TRUE || game.turn == next_turn) { + clock_t start, finish; + int i; + const int N = 100; + + next_turn++; + + freelog(LOG_DEBUG, "starting test loop"); + + for (i = 0; i < N; i++) { + start = clock(); + players_iterate(pplayer) { + unit_list_iterate(pplayer->units, punit) { + if (is_ground_unit(punit)) { + really_generate_warmap(pcity, punit, LAND_MOVING); + } + } unit_list_iterate_end; + } players_iterate_end; + finish = clock(); + gotohand += (float) (finish - start) / CLOCKS_PER_SEC; + + start = clock(); + players_iterate(pplayer) { + unit_list_iterate(pplayer->units, punit) { + if (is_ground_unit(punit)) { + stimulate_pf(punit); + } + } unit_list_iterate_end; + } players_iterate_end; + finish = clock(); + path_finding += (float) (finish - start) / CLOCKS_PER_SEC; + } + + report_counter++; + if (report_counter > 0) { + freelog(LOG_NORMAL, "gotohand=%fs path_finding=%fs factor=%f", + gotohand, path_finding, path_finding / gotohand); + report_counter = 0; + } + + if (1) { + server_quit(); + exit(EXIT_SUCCESS); + assert(0); + } + } if (punit) { /*