Freeciv-3.2
Loading...
Searching...
No Matches
transportdlg.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18#include <gtk/gtk.h>
19
20/* utility */
21#include "fcintl.h"
22
23/* common */
24#include "game.h"
25#include "movement.h"
26#include "unit.h"
27
28/* client */
29#include "control.h"
30#include "tilespec.h"
31
32/* client/gui-gtk-3.22 */
33#include "gui_main.h"
34#include "gui_stuff.h"
35#include "sprite.h"
36#include "unitselunitdlg.h"
37
38#include "transportdlg.h"
39
44
45/************************************************************************/
49{
50 if (arg == GTK_RESPONSE_YES) {
51 struct unit *pcargo =
54 "actor")));
55
56 if (pcargo != NULL) {
58 "target"));
59 struct tile *ptile = g_object_get_data(G_OBJECT(dlg), "tile");
60
61 if (tp_id == 0) {
62 /* Load to any */
64 } else {
65 struct unit *ptransport = game_unit_by_number(tp_id);
66
67 if (ptransport != NULL) {
68 /* Still exist */
70 }
71 }
72 }
73 }
74
76}
77
78/************************************************************************/
82bool request_transport(struct unit *cargo, struct tile *ptile)
83{
84 int tcount;
85 struct unit_list *potential_transports = unit_list_new();
86 struct unit *best_transport = transporter_for_unit_at(cargo, ptile);
87
89 if (could_unit_load(cargo, ptransport)) {
91 }
93
95
96 if (tcount == 0) {
99
100 return FALSE; /* Unit was not handled here. */
101 } else if (tcount == 1) {
102 /* There's exactly one potential transport - use it automatically */
105
107
108 return TRUE;
109 }
110
112 _("Transport selection"),
113 _("Looking for transport:"),
114 _("Transports available:"),
115 _("Load"),
117}
char * incite_cost
Definition comments.c:75
void request_unit_load(struct unit *pcargo, struct unit *ptrans, struct tile *ptile)
Definition control.c:2156
#define _(String)
Definition fcintl.h:67
struct unit * game_unit_by_number(int id)
Definition game.c:116
static void transport_response_callback(GtkWidget *dlg, gint arg)
bool request_transport(struct unit *cargo, struct tile *ptile)
bool select_tgt_unit(struct unit *actor, struct tile *ptile, struct unit_list *potential_tgt_units, struct unit *suggested_tgt_unit, const gchar *dlg_title, const gchar *actor_label, const gchar *tgt_label, const gchar *do_label, GCallback do_callback)
#define fc_assert(condition)
Definition log.h:176
Definition tile.h:50
struct unit_list * units
Definition tile.h:58
Definition unit.h:138
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
struct unit * transporter_for_unit_at(const struct unit *pcargo, const struct tile *ptile)
Definition unit.c:1922
bool could_unit_load(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:700
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_end
Definition unitlist.h:33