? dipls.gz ? ideee ? ping.diff ? ping2.diff ? ping3-broken.diff ? reaction-time.diff ? reaction-time2.diff ? schnelldipl ? unter.diff Index: common/unit.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/unit.h,v retrieving revision 1.89 diff -u -r1.89 unit.h --- common/unit.h 2002/08/07 11:21:49 1.89 +++ common/unit.h 2002/10/27 22:52:25 @@ -133,6 +133,7 @@ bool paradropped; bool connecting; int transported_by; + struct timeval begin,end; struct goto_route *pgr; }; Index: server/unithand.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/unithand.c,v retrieving revision 1.234 diff -u -r1.234 unithand.c --- server/unithand.c 2002/09/27 12:32:48 1.234 +++ server/unithand.c 2002/10/27 22:52:31 @@ -273,6 +273,10 @@ if (!pdiplomat || !unit_flag(pdiplomat, F_DIPLOMAT)) { return; } + + /* command to time the diplomat action */ + if(!unit_owner(pdiplomat)->ai.control) + action_end_time(pdiplomat); if(pdiplomat->moves_left > 0) { switch(packet->action_type) { @@ -932,6 +936,9 @@ } packet.diplomat_id = punit->id; packet.action_type = DIPLOMAT_CLIENT_POPUP_DIALOG; + /* start the diplomat_action-timer */ + if (!pplayer->ai.control) + set_action_begin_time(punit); lsend_packet_diplomat_action(player_reply_dest(pplayer), &packet); return FALSE; } else if (!can_unit_move_to_tile(punit, dest_x, dest_y, igzoc)) { Index: server/unittools.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/unittools.c,v retrieving revision 1.185 diff -u -r1.185 unittools.c --- server/unittools.c 2002/09/28 23:00:51 1.185 +++ server/unittools.c 2002/10/27 22:52:34 @@ -53,6 +53,7 @@ #include "unittools.h" +#define REACTION_STASTISTICS 1 static void unit_restore_hitpoints(struct player *pplayer, struct unit *punit); static void unit_restore_movepoints(struct player *pplayer, struct unit *punit); @@ -1664,6 +1666,9 @@ punit->veteran=make_veteran; punit->homecity=homecity_id; + if (!pplayer->ai.control) + set_action_begin_time(punit); + if(hp_left == -1) punit->hp=unit_type(punit)->hp; else @@ -1775,8 +1780,12 @@ if (normalize_map_pos(&punit->goto_dest_x, &punit->goto_dest_y)) { remove_city_from_minimap(punit->goto_dest_x, punit->goto_dest_y); } - } - + } + + /* for non AI-units we look how long the lived at that position */ + if (!unit_owner(punit)->ai.control) + action_end_time(punit); + remove_unit_sight_points(punit); if (punit->pgr) { @@ -2957,6 +2966,12 @@ punit->ai.ferryboat = 0; } } + + /* This is to measure the time a unit lived on a specific field */ + + if (!pplayer->ai.control) + set_action_begin_time(punit); + /* A transporter should not take units with it when on an attack goto -- fisch */ if ((punit->activity == ACTIVITY_GOTO) && get_defender(punit, punit->goto_dest_x, punit->goto_dest_y) && @@ -3216,4 +3231,45 @@ return (is_ground_unit(punit) && player_knows_techs_with_flag(unit_owner(punit), TF_WATCHTOWER)); +} + +/************************************************************************** + get the time to measure actions +**************************************************************************/ +void set_action_begin_time(struct unit *punit) +{ +#if REACTION_STASTISTICS + if (gettimeofday(&punit->begin,(struct timezone *)0)) { + freelog(LOG_ERROR, "can not get time\n"); + } + freelog(LOG_VERBOSE,"Time start: %d sec %d usec\n", + (int)punit->begin.tv_sec,(int)punit->begin.tv_usec); +#endif +} + +/************************************************************************** +This measures the time between the time was set and "end action" +**************************************************************************/ +void action_end_time(struct unit *punit) +{ +#if REACTION_STASTISTICS + long sec,usec; + + if (gettimeofday(&punit->end,(struct timezone *)0)) { + freelog(LOG_ERROR, "can not get time\n"); + } + freelog(LOG_VERBOSE,"Starting time was : %d sec %d usec\n", + (int)punit->begin.tv_sec, (int)punit->begin.tv_usec); + freelog(LOG_VERBOSE,"End time of action: %d sec %d usec\n", + (int)punit->end.tv_sec, (int)punit->end.tv_usec); + /*freelog (LOG_NORMAL, "Diplomat Action performed.");*/ + sec = punit->end.tv_sec - punit->begin.tv_sec; + usec = punit->end.tv_usec - punit->begin.tv_usec; + if(usec < 0) { + usec += 1000000; + sec--; + } + freelog(LOG_NORMAL,"time for unit(%d) %d from %d on field was: %d sec %d usec\n", + punit->id, punit->type ,punit->owner, (int)sec, (int)usec); +#endif } Index: server/unittools.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/unittools.h,v retrieving revision 1.43 diff -u -r1.43 unittools.h --- server/unittools.h 2002/03/13 09:56:27 1.43 +++ server/unittools.h 2002/10/27 22:52:35 @@ -81,4 +81,9 @@ bool transport_units, bool take_from_land, int move_cost); enum goto_result goto_route_execute(struct unit *punit); +/* some time function ... */ +void set_action_begin_time(struct unit *punit); +void action_end_time(struct unit *punit); + + #endif /* FC__UNITTOOLS_H */