Fixed the way Qt-client popup_terrain_info() checks for empty string.
[freeciv.git] / server / actiontools.c
bloba2652c3f818bdbc45ea14522a306d85418bb398c
1 /**********************************************************************
2 Freeciv - Copyright (C) 1996-2015 - Freeciv Development Team
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.
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 ***********************************************************************/
14 #ifdef HAVE_CONFIG_H
15 #include <fc_config.h>
16 #endif
18 /* common */
19 #include "actions.h"
21 /* server */
22 #include "aiiface.h"
23 #include "actiontools.h"
24 #include "notify.h"
25 #include "plrhand.h"
27 /**************************************************************************
28 After an action of a diplomat, maybe it will cause a diplomatic incident
29 with the victim.
30 **************************************************************************/
31 static void maybe_cause_incident(const enum gen_action action,
32 struct player *offender,
33 struct player *victim_player,
34 const struct tile *victim_tile,
35 const char *victim_link)
37 if (offender == victim_player) {
38 /* The player is more than willing to forgive him self. */
39 return;
42 if (!pplayers_at_war(offender, victim_player)) {
43 switch (action) {
44 case ACTION_SPY_BRIBE_UNIT:
45 notify_player(offender, victim_tile,
46 E_DIPLOMATIC_INCIDENT, ftc_server,
47 _("You have caused an incident while bribing "
48 "the %s %s."),
49 nation_adjective_for_player(victim_player),
50 victim_link);
51 notify_player(victim_player, victim_tile,
52 E_DIPLOMATIC_INCIDENT, ftc_server,
53 _("%s has caused an incident while bribing your %s."),
54 player_name(offender), victim_link);
55 break;
56 case ACTION_SPY_SABOTAGE_UNIT:
57 notify_player(offender, victim_tile,
58 E_DIPLOMATIC_INCIDENT, ftc_server,
59 _("You have caused an incident while"
60 " sabotaging the %s %s."),
61 nation_adjective_for_player(victim_player),
62 victim_link);
63 notify_player(victim_player, victim_tile,
64 E_DIPLOMATIC_INCIDENT, ftc_server,
65 _("The %s have caused an incident while"
66 " sabotaging your %s."),
67 nation_plural_for_player(offender),
68 victim_link);
69 break;
70 case ACTION_SPY_STEAL_TECH:
71 case ACTION_SPY_TARGETED_STEAL_TECH:
72 notify_player(offender, victim_tile,
73 E_DIPLOMATIC_INCIDENT, ftc_server,
74 _("You have caused an incident while attempting "
75 "to steal tech from %s."),
76 player_name(victim_player));
77 notify_player(victim_player, victim_tile,
78 E_DIPLOMATIC_INCIDENT, ftc_server,
79 _("%s has caused an incident while attempting "
80 "to steal tech from you."), player_name(offender));
81 break;
82 case ACTION_SPY_INCITE_CITY:
83 notify_player(offender, victim_tile,
84 E_DIPLOMATIC_INCIDENT, ftc_server,
85 _("You have caused an incident while inciting a "
86 "revolt in %s."), victim_link);
87 notify_player(victim_player, victim_tile,
88 E_DIPLOMATIC_INCIDENT, ftc_server,
89 _("The %s have caused an incident while inciting a "
90 "revolt in %s."),
91 nation_plural_for_player(offender), victim_link);
92 break;
93 case ACTION_SPY_POISON:
94 notify_player(offender, victim_tile,
95 E_DIPLOMATIC_INCIDENT, ftc_server,
96 _("You have caused an incident while poisoning %s."),
97 victim_link);
98 notify_player(victim_player, victim_tile,
99 E_DIPLOMATIC_INCIDENT, ftc_server,
100 _("The %s have caused an incident while poisoning %s."),
101 nation_plural_for_player(offender), victim_link);
102 break;
103 case ACTION_SPY_SABOTAGE_CITY:
104 case ACTION_SPY_TARGETED_SABOTAGE_CITY:
105 notify_player(offender, victim_tile,
106 E_DIPLOMATIC_INCIDENT, ftc_server,
107 _("You have caused an incident while sabotaging %s."),
108 victim_link);
109 notify_player(victim_player, victim_tile,
110 E_DIPLOMATIC_INCIDENT, ftc_server,
111 _("The %s have caused an incident while sabotaging %s."),
112 nation_plural_for_player(offender), victim_link);
113 break;
114 case ACTION_SPY_STEAL_GOLD:
115 notify_player(offender, victim_tile,
116 E_DIPLOMATIC_INCIDENT, ftc_server,
117 _("You have caused an incident while"
118 " stealing gold from %s."),
119 victim_link);
120 notify_player(victim_player, victim_tile,
121 E_DIPLOMATIC_INCIDENT, ftc_server,
122 _("The %s have caused an incident while"
123 " stealing gold from %s."),
124 nation_plural_for_player(offender), victim_link);
125 break;
126 case ACTION_COUNT:
127 case ACTION_ESTABLISH_EMBASSY:
128 case ACTION_SPY_INVESTIGATE_CITY:
129 case ACTION_TRADE_ROUTE:
130 case ACTION_MARKETPLACE:
131 case ACTION_HELP_WONDER:
132 return; /* These are not considered offences */
134 player_diplstate_get(victim_player, offender)->has_reason_to_cancel = 2;
135 call_incident(INCIDENT_DIPLOMAT, offender, victim_player);
136 send_player_all_c(offender, NULL);
137 send_player_all_c(victim_player, NULL);
140 return;
143 /**************************************************************************
144 Take care of any consequences (like casus belli) of getting caught while
145 trying to perform the given action.
146 **************************************************************************/
147 void action_consequence_caught(const int action_id,
148 struct player *offender,
149 struct player *victim_player,
150 const struct tile *victim_tile,
151 const char *victim_link)
153 maybe_cause_incident(action_id, offender,
154 victim_player, victim_tile, victim_link);
157 /**************************************************************************
158 Take care of any consequences (like casus belli) of successfully
159 performing the given action.
160 **************************************************************************/
161 void action_consequence_success(const int action_id,
162 struct player *offender,
163 struct player *victim_player,
164 const struct tile *victim_tile,
165 const char *victim_link)
167 maybe_cause_incident(action_id, offender,
168 victim_player, victim_tile, victim_link);