Freeciv-3.3: /fast/freeciv/nightly/main/client/clitreaty.c Source File

Freeciv-3.3

Loading...
Searching...
No Matches
clitreaty.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 2005 - The Freeciv 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.
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/* utility */
19#include "shared.h"
20
21/* common */
22#include "diptreaty.h"
23
24/* client */
25#include "client_main.h"
26#include "diplodlg_g.h"
27
28#include "clitreaty.h"
29
30/**********************************************************************/
33 void client_init_meeting(int counterpart, int initiated_from)
34{
35 struct Treaty *ptreaty;
36 struct player *we;
37 struct player *they;
38
39 if (!can_client_issue_orders()) {
40 return;
41 }
42
43 we = client_player();
44 they = player_by_number(counterpart);
45 ptreaty = find_treaty(we, they);
46
47 if (ptreaty == NULL) {
48 ptreaty = fc_malloc(sizeof(*ptreaty));
49 init_treaty(ptreaty, we, they);
50 treaty_add(ptreaty);
51 }
52
53 gui_init_meeting(ptreaty, they, player_by_number(initiated_from));
54}
55
56/**********************************************************************/
59 void client_recv_accept_treaty(int counterpart, bool I_accepted,
60 bool other_accepted)
61{
62 struct Treaty *ptreaty;
63 struct player *we;
64 struct player *they;
65
66 we = client_player();
67 they = player_by_number(counterpart);
68 ptreaty = find_treaty(we, they);
69
70 if (ptreaty == NULL) {
71 return;
72 }
73
74 ptreaty->accept0 = I_accepted;
75 ptreaty->accept1 = other_accepted;
76
77 gui_recv_accept_treaty(ptreaty, they);
78}
79
80/**********************************************************************/
83 void client_recv_cancel_meeting(int counterpart, int initiated_from)
84{
85 struct Treaty *ptreaty;
86 struct player *we;
87 struct player *they;
88
89 we = client_player();
90 they = player_by_number(counterpart);
91 ptreaty = find_treaty(we, they);
92
93 if (ptreaty == NULL) {
94 return;
95 }
96
97 gui_recv_cancel_meeting(ptreaty, they, player_by_number(initiated_from));
98
99 treaty_remove(ptreaty);
100}
101
102/**********************************************************************/
105 void client_recv_create_clause(int counterpart, int giver,
106 enum clause_type type, int value)
107{
108 struct Treaty *ptreaty;
109 struct player *we;
110 struct player *they;
111
112 we = client_player();
113 they = player_by_number(counterpart);
114 ptreaty = find_treaty(we, they);
115
116 if (ptreaty == NULL) {
117 return;
118 }
119
120 gui_prepare_clause_updt(ptreaty, they);
121
122 add_clause(ptreaty, player_by_number(giver), type, value,
123 client_player());
124
125 gui_recv_create_clause(ptreaty, they);
126}
127
128/**********************************************************************/
131 void client_recv_remove_clause(int counterpart, int giver,
132 enum clause_type type, int value)
133{
134 struct Treaty *ptreaty;
135 struct player *we;
136 struct player *they;
137
138 we = client_player();
139 they = player_by_number(counterpart);
140 ptreaty = find_treaty(we, they);
141
142 if (ptreaty == NULL) {
143 return;
144 }
145
146 gui_prepare_clause_updt(ptreaty, they);
147
148 remove_clause(ptreaty, player_by_number(giver), type, value);
149
150 gui_recv_remove_clause(ptreaty, they);
151}
can_client_issue_orders
bool can_client_issue_orders(void)
Definition client_main.c:1264
client_main.h
client_player
#define client_player()
Definition client_main.h:106
client_recv_remove_clause
void client_recv_remove_clause(int counterpart, int giver, enum clause_type type, int value)
Definition clitreaty.c:131
client_recv_create_clause
void client_recv_create_clause(int counterpart, int giver, enum clause_type type, int value)
Definition clitreaty.c:105
client_recv_accept_treaty
void client_recv_accept_treaty(int counterpart, bool I_accepted, bool other_accepted)
Definition clitreaty.c:59
client_recv_cancel_meeting
void client_recv_cancel_meeting(int counterpart, int initiated_from)
Definition clitreaty.c:83
client_init_meeting
void client_init_meeting(int counterpart, int initiated_from)
Definition clitreaty.c:33
clitreaty.h
incite_cost
char * incite_cost
Definition comments.c:74
diplodlg_g.h
gui_recv_create_clause
struct Treaty struct player struct player *initiator gui_recv_create_clause
Definition diplodlg_g.h:32
ptreaty
struct Treaty * ptreaty
Definition diplodlg_g.h:28
gui_recv_accept_treaty
struct Treaty struct player struct player *initiator struct Treaty struct player *they gui_recv_accept_treaty
Definition diplodlg_g.h:36
they
struct Treaty struct player * they
Definition diplodlg_g.h:28
gui_recv_cancel_meeting
gui_recv_cancel_meeting
Definition diplodlg_g.h:27
init_treaty
void init_treaty(struct Treaty *ptreaty, struct player *plr0, struct player *plr1)
Definition diptreaty.c:99
add_clause
bool add_clause(struct Treaty *ptreaty, struct player *pfrom, enum clause_type type, int val, struct player *client_player)
Definition diptreaty.c:145
treaty_add
void treaty_add(struct Treaty *ptreaty)
Definition diptreaty.c:373
remove_clause
bool remove_clause(struct Treaty *ptreaty, struct player *pfrom, enum clause_type type, int val)
Definition diptreaty.c:123
treaty_remove
void treaty_remove(struct Treaty *ptreaty)
Definition diptreaty.c:381
find_treaty
struct Treaty * find_treaty(struct player *plr0, struct player *plr1)
Definition diptreaty.c:358
diptreaty.h
gui_init_meeting
void gui_init_meeting(struct Treaty *ptreaty, struct player *they, struct player *initiator)
Definition diplodlg.c:137
gui_recv_remove_clause
void gui_recv_remove_clause(struct Treaty *ptreaty, struct player *they)
Definition diplodlg.c:188
gui_prepare_clause_updt
void gui_prepare_clause_updt(struct Treaty *ptreaty, struct player *they)
Definition diplodlg.c:163
type
GType type
Definition repodlgs.c:1313
fc_malloc
#define fc_malloc(sz)
Definition mem.h:34
player_by_number
struct player * player_by_number(const int player_id)
Definition player.c:849
shared.h
Treaty
Definition diptreaty.h:79
Treaty::accept0
bool accept0
Definition diptreaty.h:81
Treaty::accept1
bool accept1
Definition diptreaty.h:81
player
Definition player.h:249