File: hand_gen.c

package info (click to toggle)
freeciv 2.1.5-2
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 95,924 kB
  • ctags: 20,829
  • sloc: ansic: 231,256; sh: 4,872; makefile: 2,867; python: 1,259; yacc: 318
file content (320 lines) | stat: -rw-r--r-- 10,722 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320

 /****************************************************************************
 *                       THIS FILE WAS GENERATED                             *
 * Script: common/generate_packets.py                                        *
 * Input:  common/packets.def                                                *
 *                       DO NOT CHANGE THIS FILE                             *
 ****************************************************************************/



#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include "packets.h"

#include "hand_gen.h"
    
bool server_handle_packet(enum packet_type type, void *packet,
			  struct player *pplayer, struct connection *pconn)
{
  switch(type) {
  case PACKET_NATION_SELECT_REQ:
    handle_nation_select_req(pplayer,
      ((struct packet_nation_select_req *)packet)->player_no,
      ((struct packet_nation_select_req *)packet)->nation_no,
      ((struct packet_nation_select_req *)packet)->is_male,
      ((struct packet_nation_select_req *)packet)->name,
      ((struct packet_nation_select_req *)packet)->city_style);
    return TRUE;

  case PACKET_PLAYER_READY:
    handle_player_ready(pplayer,
      ((struct packet_player_ready *)packet)->player_no,
      ((struct packet_player_ready *)packet)->is_ready);
    return TRUE;

  case PACKET_CHAT_MSG_REQ:
    handle_chat_msg_req(pconn,
      ((struct packet_chat_msg_req *)packet)->message);
    return TRUE;

  case PACKET_CITY_SELL:
    handle_city_sell(pplayer,
      ((struct packet_city_sell *)packet)->city_id,
      ((struct packet_city_sell *)packet)->build_id);
    return TRUE;

  case PACKET_CITY_BUY:
    handle_city_buy(pplayer,
      ((struct packet_city_buy *)packet)->city_id);
    return TRUE;

  case PACKET_CITY_CHANGE:
    handle_city_change(pplayer,
      ((struct packet_city_change *)packet)->city_id,
      ((struct packet_city_change *)packet)->build_id,
      ((struct packet_city_change *)packet)->is_build_id_unit_id);
    return TRUE;

  case PACKET_CITY_WORKLIST:
    handle_city_worklist(pplayer,
      ((struct packet_city_worklist *)packet)->city_id,
      &((struct packet_city_worklist *)packet)->worklist);
    return TRUE;

  case PACKET_CITY_MAKE_SPECIALIST:
    handle_city_make_specialist(pplayer,
      ((struct packet_city_make_specialist *)packet)->city_id,
      ((struct packet_city_make_specialist *)packet)->worker_x,
      ((struct packet_city_make_specialist *)packet)->worker_y);
    return TRUE;

  case PACKET_CITY_MAKE_WORKER:
    handle_city_make_worker(pplayer,
      ((struct packet_city_make_worker *)packet)->city_id,
      ((struct packet_city_make_worker *)packet)->worker_x,
      ((struct packet_city_make_worker *)packet)->worker_y);
    return TRUE;

  case PACKET_CITY_CHANGE_SPECIALIST:
    handle_city_change_specialist(pplayer,
      ((struct packet_city_change_specialist *)packet)->city_id,
      ((struct packet_city_change_specialist *)packet)->from,
      ((struct packet_city_change_specialist *)packet)->to);
    return TRUE;

  case PACKET_CITY_RENAME:
    handle_city_rename(pplayer,
      ((struct packet_city_rename *)packet)->city_id,
      ((struct packet_city_rename *)packet)->name);
    return TRUE;

  case PACKET_CITY_OPTIONS_REQ:
    handle_city_options_req(pplayer,
      ((struct packet_city_options_req *)packet)->city_id,
      ((struct packet_city_options_req *)packet)->options);
    return TRUE;

  case PACKET_CITY_REFRESH:
    handle_city_refresh(pplayer,
      ((struct packet_city_refresh *)packet)->city_id);
    return TRUE;

  case PACKET_CITY_NAME_SUGGESTION_REQ:
    handle_city_name_suggestion_req(pplayer,
      ((struct packet_city_name_suggestion_req *)packet)->unit_id);
    return TRUE;

  case PACKET_PLAYER_PHASE_DONE:
    handle_player_phase_done(pplayer,
      ((struct packet_player_phase_done *)packet)->turn);
    return TRUE;

  case PACKET_PLAYER_RATES:
    handle_player_rates(pplayer,
      ((struct packet_player_rates *)packet)->tax,
      ((struct packet_player_rates *)packet)->luxury,
      ((struct packet_player_rates *)packet)->science);
    return TRUE;

  case PACKET_PLAYER_CHANGE_GOVERNMENT:
    handle_player_change_government(pplayer,
      ((struct packet_player_change_government *)packet)->government);
    return TRUE;

  case PACKET_PLAYER_RESEARCH:
    handle_player_research(pplayer,
      ((struct packet_player_research *)packet)->tech);
    return TRUE;

  case PACKET_PLAYER_TECH_GOAL:
    handle_player_tech_goal(pplayer,
      ((struct packet_player_tech_goal *)packet)->tech);
    return TRUE;

  case PACKET_PLAYER_ATTRIBUTE_BLOCK:
    handle_player_attribute_block(pplayer);
    return TRUE;

  case PACKET_PLAYER_ATTRIBUTE_CHUNK:
    handle_player_attribute_chunk(pplayer, packet);
    return TRUE;

  case PACKET_UNIT_MOVE:
    handle_unit_move(pplayer,
      ((struct packet_unit_move *)packet)->unit_id,
      ((struct packet_unit_move *)packet)->x,
      ((struct packet_unit_move *)packet)->y);
    return TRUE;

  case PACKET_UNIT_BUILD_CITY:
    handle_unit_build_city(pplayer,
      ((struct packet_unit_build_city *)packet)->unit_id,
      ((struct packet_unit_build_city *)packet)->name);
    return TRUE;

  case PACKET_UNIT_DISBAND:
    handle_unit_disband(pplayer,
      ((struct packet_unit_disband *)packet)->unit_id);
    return TRUE;

  case PACKET_UNIT_CHANGE_HOMECITY:
    handle_unit_change_homecity(pplayer,
      ((struct packet_unit_change_homecity *)packet)->unit_id,
      ((struct packet_unit_change_homecity *)packet)->city_id);
    return TRUE;

  case PACKET_UNIT_ESTABLISH_TRADE:
    handle_unit_establish_trade(pplayer,
      ((struct packet_unit_establish_trade *)packet)->unit_id);
    return TRUE;

  case PACKET_UNIT_BATTLEGROUP:
    handle_unit_battlegroup(pplayer,
      ((struct packet_unit_battlegroup *)packet)->unit_id,
      ((struct packet_unit_battlegroup *)packet)->battlegroup);
    return TRUE;

  case PACKET_UNIT_HELP_BUILD_WONDER:
    handle_unit_help_build_wonder(pplayer,
      ((struct packet_unit_help_build_wonder *)packet)->unit_id);
    return TRUE;

  case PACKET_UNIT_ORDERS:
    handle_unit_orders(pplayer, packet);
    return TRUE;

  case PACKET_UNIT_AUTOSETTLERS:
    handle_unit_autosettlers(pplayer,
      ((struct packet_unit_autosettlers *)packet)->unit_id);
    return TRUE;

  case PACKET_UNIT_LOAD:
    handle_unit_load(pplayer,
      ((struct packet_unit_load *)packet)->cargo_id,
      ((struct packet_unit_load *)packet)->transporter_id);
    return TRUE;

  case PACKET_UNIT_UNLOAD:
    handle_unit_unload(pplayer,
      ((struct packet_unit_unload *)packet)->cargo_id,
      ((struct packet_unit_unload *)packet)->transporter_id);
    return TRUE;

  case PACKET_UNIT_UPGRADE:
    handle_unit_upgrade(pplayer,
      ((struct packet_unit_upgrade *)packet)->unit_id);
    return TRUE;

  case PACKET_UNIT_NUKE:
    handle_unit_nuke(pplayer,
      ((struct packet_unit_nuke *)packet)->unit_id);
    return TRUE;

  case PACKET_UNIT_PARADROP_TO:
    handle_unit_paradrop_to(pplayer,
      ((struct packet_unit_paradrop_to *)packet)->unit_id,
      ((struct packet_unit_paradrop_to *)packet)->x,
      ((struct packet_unit_paradrop_to *)packet)->y);
    return TRUE;

  case PACKET_UNIT_AIRLIFT:
    handle_unit_airlift(pplayer,
      ((struct packet_unit_airlift *)packet)->unit_id,
      ((struct packet_unit_airlift *)packet)->city_id);
    return TRUE;

  case PACKET_UNIT_DIPLOMAT_QUERY:
    handle_unit_diplomat_query(pconn,
      ((struct packet_unit_diplomat_query *)packet)->diplomat_id,
      ((struct packet_unit_diplomat_query *)packet)->target_id,
      ((struct packet_unit_diplomat_query *)packet)->value,
      ((struct packet_unit_diplomat_query *)packet)->action_type);
    return TRUE;

  case PACKET_UNIT_TYPE_UPGRADE:
    handle_unit_type_upgrade(pplayer,
      ((struct packet_unit_type_upgrade *)packet)->type);
    return TRUE;

  case PACKET_UNIT_DIPLOMAT_ACTION:
    handle_unit_diplomat_action(pplayer,
      ((struct packet_unit_diplomat_action *)packet)->diplomat_id,
      ((struct packet_unit_diplomat_action *)packet)->target_id,
      ((struct packet_unit_diplomat_action *)packet)->value,
      ((struct packet_unit_diplomat_action *)packet)->action_type);
    return TRUE;

  case PACKET_UNIT_CHANGE_ACTIVITY:
    handle_unit_change_activity(pplayer,
      ((struct packet_unit_change_activity *)packet)->unit_id,
      ((struct packet_unit_change_activity *)packet)->activity,
      ((struct packet_unit_change_activity *)packet)->activity_target);
    return TRUE;

  case PACKET_DIPLOMACY_INIT_MEETING_REQ:
    handle_diplomacy_init_meeting_req(pplayer,
      ((struct packet_diplomacy_init_meeting_req *)packet)->counterpart);
    return TRUE;

  case PACKET_DIPLOMACY_CANCEL_MEETING_REQ:
    handle_diplomacy_cancel_meeting_req(pplayer,
      ((struct packet_diplomacy_cancel_meeting_req *)packet)->counterpart);
    return TRUE;

  case PACKET_DIPLOMACY_CREATE_CLAUSE_REQ:
    handle_diplomacy_create_clause_req(pplayer,
      ((struct packet_diplomacy_create_clause_req *)packet)->counterpart,
      ((struct packet_diplomacy_create_clause_req *)packet)->giver,
      ((struct packet_diplomacy_create_clause_req *)packet)->type,
      ((struct packet_diplomacy_create_clause_req *)packet)->value);
    return TRUE;

  case PACKET_DIPLOMACY_REMOVE_CLAUSE_REQ:
    handle_diplomacy_remove_clause_req(pplayer,
      ((struct packet_diplomacy_remove_clause_req *)packet)->counterpart,
      ((struct packet_diplomacy_remove_clause_req *)packet)->giver,
      ((struct packet_diplomacy_remove_clause_req *)packet)->type,
      ((struct packet_diplomacy_remove_clause_req *)packet)->value);
    return TRUE;

  case PACKET_DIPLOMACY_ACCEPT_TREATY_REQ:
    handle_diplomacy_accept_treaty_req(pplayer,
      ((struct packet_diplomacy_accept_treaty_req *)packet)->counterpart);
    return TRUE;

  case PACKET_DIPLOMACY_CANCEL_PACT:
    handle_diplomacy_cancel_pact(pplayer,
      ((struct packet_diplomacy_cancel_pact *)packet)->other_player_id,
      ((struct packet_diplomacy_cancel_pact *)packet)->clause);
    return TRUE;

  case PACKET_REPORT_REQ:
    handle_report_req(pconn,
      ((struct packet_report_req *)packet)->type);
    return TRUE;

  case PACKET_CONN_PONG:
    handle_conn_pong(pconn);
    return TRUE;

  case PACKET_SPACESHIP_LAUNCH:
    handle_spaceship_launch(pplayer);
    return TRUE;

  case PACKET_SPACESHIP_PLACE:
    handle_spaceship_place(pplayer,
      ((struct packet_spaceship_place *)packet)->type,
      ((struct packet_spaceship_place *)packet)->num);
    return TRUE;

  case PACKET_SINGLE_WANT_HACK_REQ:
    handle_single_want_hack_req(pconn, packet);
    return TRUE;

  default:
    return FALSE;
  }
}