Freeciv-3.3
Loading...
Searching...
No Matches
rallypointdlg.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 "city.h"
25#include "game.h"
26#include "tile.h"
27
28/* client */
29#include "client_main.h"
30#include "goto.h"
31
32/* client/gui-gtk-5.0 */
33#include "gui_main.h"
34#include "gui_stuff.h"
35
36#include "rallypointdlg.h"
37
41
42static int rally_city_id = -1;
43
44/************************************************************************/
47static bool rally_dialog_open(void)
48{
49 return rally_dialog;
50}
51
52/************************************************************************/
62
63/************************************************************************/
113
114/************************************************************************/
118{
119 if (!rally_dialog) {
120 return RALLY_NONE;
121 }
122
123 if (rally_city_id > 0) {
124 return RALLY_TILE;
125 }
126
127 return RALLY_CITY;
128}
129
130/************************************************************************/
134bool rally_set_tile(struct tile *ptile)
135{
136 struct city *pcity = NULL;
137 enum rally_phase phase = rally_placement_phase();
138
139 if (phase == RALLY_NONE) {
140 return FALSE;
141 }
142
143 if (ptile == NULL) {
144 return TRUE;
145 }
146
147 if (rally_city_id > 0) {
149
150 if (pcity == NULL || city_owner(pcity) != client_player()) {
151 /* City destroyed or captured while we've
152 * been setting the rally point? */
153 rally_city_id = -1;
154 phase = RALLY_CITY;
155
157 _("Select another city."));
158 }
159 }
160
161 if (phase == RALLY_CITY) {
162 char buffer[100];
163
164 pcity = tile_city(ptile);
165
166 if (pcity == NULL || city_owner(pcity) != client_player()) {
167 return TRUE;
168 }
169
171
172 fc_snprintf(buffer, sizeof(buffer), _("Now select rally point for %s"),
175 } else {
176 char buffer[100];
178
179 fc_assert(pcity != NULL);
180
181 rally_city_id = -1;
182
183 if (send_rally_tile(pcity, ptile, psist)) {
184 fc_snprintf(buffer, sizeof(buffer),
185 _("%s rally point set. Select another city."),
187 } else {
188 fc_snprintf(buffer, sizeof(buffer),
189 _("%s rally point setting failed. Select next city."),
191 }
192
194 }
195
196 return TRUE;
197}
const char * city_name_get(const struct city *pcity)
Definition city.c:1137
#define city_owner(_pcity_)
Definition city.h:560
#define client_player()
char * incite_cost
Definition comments.c:76
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction struct unit struct city * pcity
Definition dialogs_g.h:78
#define _(String)
Definition fcintl.h:67
struct city * game_city_by_number(int id)
Definition game.c:106
bool send_rally_tile(struct city *pcity, struct tile *ptile, bool persistent)
Definition goto.c:1593
GtkWidget * toplevel
Definition gui_main.c:126
void setup_dialog(GtkWidget *shell, GtkWidget *parent)
Definition gui_stuff.c:287
static GtkWidget * instruction_label
bool rally_set_tile(struct tile *ptile)
static GtkWidget * persistent
void rally_dialog_popup(void)
static void rally_response_callback(GtkWidget *dlg, gint arg)
static bool rally_dialog_open(void)
enum rally_phase rally_placement_phase(void)
static int rally_city_id
bool rally_dialog
rally_phase
@ RALLY_TILE
@ RALLY_CITY
@ RALLY_NONE
#define fc_assert(condition)
Definition log.h:177
Definition city.h:317
Definition tile.h:50
int id
Definition unit.h:147
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:960
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83