Author: cazfi Date: Thu Apr 21 14:41:24 2016 New Revision: 32454 URL: http://svn.gna.org/viewcvs/freeciv?rev=32454&view=rev Log: Added gtk3- and gtk3x-client support for multiple worker tasks for each city, nne for each tile on range.
See patch #6031 Modified: trunk/ai/threaded/taicity.c trunk/client/gui-gtk-3.0/citydlg.c trunk/client/gui-gtk-3.x/citydlg.c trunk/client/packhand.c trunk/client/tilespec.c trunk/fc_version trunk/server/citytools.c trunk/server/citytools.h trunk/server/srv_main.c trunk/server/unithand.c Modified: trunk/ai/threaded/taicity.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/ai/threaded/taicity.c?rev=32454&r1=32453&r2=32454&view=diff ============================================================================== --- trunk/ai/threaded/taicity.c (original) +++ trunk/ai/threaded/taicity.c Thu Apr 21 14:41:24 2016 @@ -394,7 +394,7 @@ ptask->want = data->task.want; /* Send info to observers */ - package_and_send_worker_task(pcity); + package_and_send_worker_tasks(pcity); } free(data); Modified: trunk/client/gui-gtk-3.0/citydlg.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.0/citydlg.c?rev=32454&r1=32453&r2=32454&view=diff ============================================================================== --- trunk/client/gui-gtk-3.0/citydlg.c (original) +++ trunk/client/gui-gtk-3.0/citydlg.c Thu Apr 21 14:41:24 2016 @@ -1,4 +1,4 @@ -/********************************************************************** +/*********************************************************************** Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -2799,9 +2799,7 @@ task.city_id = pcity->id; - if (act == ACTIVITY_IDLE) { - task.tile_id = -1; - task.activity = ACTIVITY_IDLE; + if (act == ACTIVITY_LAST) { task.tgt = -1; task.want = 0; } else { @@ -2834,10 +2832,11 @@ task.tgt = extra_index(tgt); } - task.tile_id = ptile->index; - task.activity = act; task.want = 100; } + + task.tile_id = ptile->index; + task.activity = act; send_packet_worker_task(&client.conn, &task); } @@ -2874,7 +2873,7 @@ if (ptask != NULL) { choice_dialog_add(shl, _("Clear request"), G_CALLBACK(set_city_workertask), - GINT_TO_POINTER(ACTIVITY_IDLE), FALSE, NULL); + GINT_TO_POINTER(ACTIVITY_LAST), FALSE, NULL); } if ((pterr->mining_result == pterr Modified: trunk/client/gui-gtk-3.x/citydlg.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.x/citydlg.c?rev=32454&r1=32453&r2=32454&view=diff ============================================================================== --- trunk/client/gui-gtk-3.x/citydlg.c (original) +++ trunk/client/gui-gtk-3.x/citydlg.c Thu Apr 21 14:41:24 2016 @@ -1,4 +1,4 @@ -/********************************************************************** +/*********************************************************************** Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -2829,9 +2829,7 @@ task.city_id = pcity->id; - if (act == ACTIVITY_IDLE) { - task.tile_id = -1; - task.activity = ACTIVITY_IDLE; + if (act == ACTIVITY_LAST) { task.tgt = -1; task.want = 0; } else { @@ -2864,10 +2862,11 @@ task.tgt = extra_index(tgt); } - task.tile_id = ptile->index; - task.activity = act; task.want = 100; } + + task.tile_id = ptile->index; + task.activity = act; send_packet_worker_task(&client.conn, &task); } @@ -2904,7 +2903,7 @@ if (ptask != NULL) { choice_dialog_add(shl, _("Clear request"), G_CALLBACK(set_city_workertask), - GINT_TO_POINTER(ACTIVITY_IDLE), FALSE, NULL); + GINT_TO_POINTER(ACTIVITY_LAST), FALSE, NULL); } if ((pterr->mining_result == pterr Modified: trunk/client/packhand.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/client/packhand.c?rev=32454&r1=32453&r2=32454&view=diff ============================================================================== --- trunk/client/packhand.c (original) +++ trunk/client/packhand.c Thu Apr 21 14:41:24 2016 @@ -1157,22 +1157,33 @@ void handle_worker_task(const struct packet_worker_task *packet) { struct city *pcity = game_city_by_number(packet->city_id); - struct worker_task *ptask; + struct worker_task *ptask = NULL; if (pcity == NULL || (pcity->owner != client.conn.playing && !client_is_global_observer())) { return; } - ptask = worker_task_list_get(pcity->task_reqs, 0); - - if (ptask == NULL && packet->tile_id >= 0) { - ptask = fc_malloc(sizeof(struct worker_task)); - worker_task_list_append(pcity->task_reqs, ptask); - } else if (ptask != NULL && packet->tile_id < 0) { - worker_task_list_remove(pcity->task_reqs, ptask); - free(ptask); - ptask = NULL; + worker_task_list_iterate(pcity->task_reqs, ptask_old) { + if (tile_index(ptask_old->ptile) == packet->tile_id) { + ptask = ptask_old; + break; + } + } worker_task_list_iterate_end; + + if (ptask == NULL) { + if (packet->activity == ACTIVITY_LAST) { + return; + } else { + ptask = fc_malloc(sizeof(struct worker_task)); + worker_task_list_append(pcity->task_reqs, ptask); + } + } else { + if (packet->activity == ACTIVITY_LAST) { + worker_task_list_remove(pcity->task_reqs, ptask); + free(ptask); + ptask = NULL; + } } if (ptask != NULL) { Modified: trunk/client/tilespec.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/client/tilespec.c?rev=32454&r1=32453&r2=32454&view=diff ============================================================================== --- trunk/client/tilespec.c (original) +++ trunk/client/tilespec.c Thu Apr 21 14:41:24 2016 @@ -1,4 +1,4 @@ -/********************************************************************** +/*********************************************************************** Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -11,7 +11,7 @@ GNU General Public License for more details. ***********************************************************************/ -/********************************************************************** +/*********************************************************************** Functions for handling the tilespec files which describe the files and contents of tilesets. original author: David Pfitzner <d...@mso.anu.edu.au> @@ -5641,34 +5641,34 @@ case LAYER_WORKERTASK: if (citymode != NULL && ptile != NULL) { - struct worker_task *ptask = worker_task_list_get(citymode->task_reqs, 0); - - if (ptask != NULL && ptask->ptile == ptile) { - switch (ptask->act) { - case ACTIVITY_MINE: - if (ptask->tgt == NULL) { - ADD_SPRITE_SIMPLE(t->sprites.unit.plant); - } else { + worker_task_list_iterate(citymode->task_reqs, ptask) { + if (ptask->ptile == ptile) { + switch (ptask->act) { + case ACTIVITY_MINE: + if (ptask->tgt == NULL) { + ADD_SPRITE_SIMPLE(t->sprites.unit.plant); + } else { + ADD_SPRITE_SIMPLE(t->sprites.extras[extra_index(ptask->tgt)].activity); + } + break; + case ACTIVITY_IRRIGATE: + if (ptask->tgt == NULL) { + ADD_SPRITE_SIMPLE(t->sprites.unit.irrigate); + } else { + ADD_SPRITE_SIMPLE(t->sprites.extras[extra_index(ptask->tgt)].activity); + } + break; + case ACTIVITY_GEN_ROAD: ADD_SPRITE_SIMPLE(t->sprites.extras[extra_index(ptask->tgt)].activity); + break; + case ACTIVITY_TRANSFORM: + ADD_SPRITE_SIMPLE(t->sprites.unit.transform); + break; + default: + break; } - break; - case ACTIVITY_IRRIGATE: - if (ptask->tgt == NULL) { - ADD_SPRITE_SIMPLE(t->sprites.unit.irrigate); - } else { - ADD_SPRITE_SIMPLE(t->sprites.extras[extra_index(ptask->tgt)].activity); - } - break; - case ACTIVITY_GEN_ROAD: - ADD_SPRITE_SIMPLE(t->sprites.extras[extra_index(ptask->tgt)].activity); - break; - case ACTIVITY_TRANSFORM: - ADD_SPRITE_SIMPLE(t->sprites.unit.transform); - break; - default: - break; } - } + } worker_task_list_iterate_end; } break; Modified: trunk/fc_version URL: http://svn.gna.org/viewcvs/freeciv/trunk/fc_version?rev=32454&r1=32453&r2=32454&view=diff ============================================================================== --- trunk/fc_version (original) +++ trunk/fc_version Thu Apr 21 14:41:24 2016 @@ -55,7 +55,7 @@ # - Avoid adding a new mandatory capability to the development branch for # as long as possible. We want to maintain network compatibility with # the stable branch for as long as possible. -NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-3.0-2016.Apr.19b" +NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-3.0-2016.Apr.21" NETWORK_CAPSTRING_OPTIONAL="" FREECIV_DISTRIBUTOR="" Modified: trunk/server/citytools.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/server/citytools.c?rev=32454&r1=32453&r2=32454&view=diff ============================================================================== --- trunk/server/citytools.c (original) +++ trunk/server/citytools.c Thu Apr 21 14:41:24 2016 @@ -3199,17 +3199,20 @@ { struct packet_worker_task packet; - if (ptask != NULL) { - worker_task_list_remove(pcity->task_reqs, ptask); - free(ptask); - } + if (ptask == NULL) { + return; + } + + worker_task_list_remove(pcity->task_reqs, ptask); packet.city_id = pcity->id; - packet.tile_id = -1; - packet.activity = ACTIVITY_IDLE; + packet.tile_id = tile_index(ptask->ptile); + packet.activity = ACTIVITY_LAST; packet.tgt = 0; packet.want = 0; + free(ptask); + lsend_packet_worker_task(city_owner(pcity)->connections, &packet); lsend_packet_worker_task(game.glob_observers, &packet); } @@ -3219,19 +3222,21 @@ **************************************************************************/ void clear_worker_tasks(struct city *pcity) { - clear_worker_task(pcity, worker_task_list_get(pcity->task_reqs, 0)); + while (worker_task_list_size(pcity->task_reqs) > 0) { + clear_worker_task(pcity, worker_task_list_get(pcity->task_reqs, 0)); + } } /************************************************************************** Send city worker task to owner **************************************************************************/ -void package_and_send_worker_task(struct city *pcity) +void package_and_send_worker_tasks(struct city *pcity) { struct packet_worker_task packet; - struct worker_task *ptask = worker_task_list_get(pcity->task_reqs, 0); packet.city_id = pcity->id; - if (ptask != NULL) { + + worker_task_list_iterate(pcity->task_reqs, ptask) { packet.tile_id = tile_index(ptask->ptile); packet.activity = ptask->act; if (ptask->tgt == NULL) { @@ -3240,13 +3245,8 @@ packet.tgt = extra_number(ptask->tgt); } packet.want = ptask->want; - } else { - packet.tile_id = -1; - packet.activity = ACTIVITY_IDLE; - packet.tgt = 0; - packet.want = 0; - } - - lsend_packet_worker_task(city_owner(pcity)->connections, &packet); - lsend_packet_worker_task(game.glob_observers, &packet); -} + + lsend_packet_worker_task(city_owner(pcity)->connections, &packet); + lsend_packet_worker_task(game.glob_observers, &packet); + } worker_task_list_iterate_end; +} Modified: trunk/server/citytools.h URL: http://svn.gna.org/viewcvs/freeciv/trunk/server/citytools.h?rev=32454&r1=32453&r2=32454&view=diff ============================================================================== --- trunk/server/citytools.h (original) +++ trunk/server/citytools.h Thu Apr 21 14:41:24 2016 @@ -109,6 +109,6 @@ void clear_worker_task(struct city *pcity, struct worker_task *ptask); void clear_worker_tasks(struct city *pcity); -void package_and_send_worker_task(struct city *pcity); +void package_and_send_worker_tasks(struct city *pcity); #endif /* FC__CITYTOOLS_H */ Modified: trunk/server/srv_main.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/server/srv_main.c?rev=32454&r1=32453&r2=32454&view=diff ============================================================================== --- trunk/server/srv_main.c (original) +++ trunk/server/srv_main.c Thu Apr 21 14:41:24 2016 @@ -633,7 +633,7 @@ send_spaceship_info(NULL, dest); cities_iterate(pcity) { - package_and_send_worker_task(pcity); + package_and_send_worker_tasks(pcity); } cities_iterate_end; } Modified: trunk/server/unithand.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/server/unithand.c?rev=32454&r1=32453&r2=32454&view=diff ============================================================================== --- trunk/server/unithand.c (original) +++ trunk/server/unithand.c Thu Apr 21 14:41:24 2016 @@ -4464,26 +4464,37 @@ const struct packet_worker_task *packet) { struct city *pcity = game_city_by_number(packet->city_id); - struct worker_task *ptask; - - if (pcity == NULL || pcity->owner != pplayer) { + struct worker_task *ptask = NULL; + struct tile *ptile = index_to_tile(packet->tile_id); + + if (pcity == NULL || pcity->owner != pplayer || ptile == NULL) { return; } - ptask = worker_task_list_get(pcity->task_reqs, 0); - - if (ptask == NULL && packet->tile_id >= 0) { + worker_task_list_iterate(pcity->task_reqs, ptask_old) { + if (tile_index(ptask_old->ptile) == packet->tile_id) { + ptask = ptask_old; + } + } worker_task_list_iterate_end; + + if (ptask == NULL) { + if (packet->activity == ACTIVITY_LAST) { + return; + } + ptask = fc_malloc(sizeof(struct worker_task)); worker_task_init(ptask); worker_task_list_append(pcity->task_reqs, ptask); - } else if (ptask != NULL && packet->tile_id < 0) { - worker_task_list_remove(pcity->task_reqs, ptask); - free(ptask); - ptask = NULL; + } else { + if (packet->activity == ACTIVITY_LAST) { + worker_task_list_remove(pcity->task_reqs, ptask); + free(ptask); + ptask = NULL; + } } if (ptask != NULL) { - ptask->ptile = index_to_tile(packet->tile_id); + ptask->ptile = ptile; ptask->act = packet->activity; if (packet->tgt >= 0) { ptask->tgt = extra_by_number(packet->tgt); _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits