12
12
#include <config.h>
15
16
#include "packets.h"
17
18
#include "hand_gen.h"
19
bool server_handle_packet(enum packet_type type, void *packet,
20
struct player *pplayer, struct connection *pconn)
20
bool server_handle_packet(enum packet_type type, const void *packet,
21
struct player *pplayer, struct connection *pconn)
23
24
case PACKET_NATION_SELECT_REQ:
24
25
handle_nation_select_req(pconn,
25
((struct packet_nation_select_req *)packet)->player_no,
26
((struct packet_nation_select_req *)packet)->nation_no,
27
((struct packet_nation_select_req *)packet)->is_male,
28
((struct packet_nation_select_req *)packet)->name,
29
((struct packet_nation_select_req *)packet)->city_style);
26
((const struct packet_nation_select_req *)packet)->player_no,
27
((const struct packet_nation_select_req *)packet)->nation_no,
28
((const struct packet_nation_select_req *)packet)->is_male,
29
((const struct packet_nation_select_req *)packet)->name,
30
((const struct packet_nation_select_req *)packet)->city_style);
32
33
case PACKET_PLAYER_READY:
33
34
handle_player_ready(pplayer,
34
((struct packet_player_ready *)packet)->player_no,
35
((struct packet_player_ready *)packet)->is_ready);
35
((const struct packet_player_ready *)packet)->player_no,
36
((const struct packet_player_ready *)packet)->is_ready);
38
39
case PACKET_CHAT_MSG_REQ:
39
40
handle_chat_msg_req(pconn,
40
((struct packet_chat_msg_req *)packet)->message);
41
((const struct packet_chat_msg_req *)packet)->message);
43
44
case PACKET_CITY_SELL:
44
45
handle_city_sell(pplayer,
45
((struct packet_city_sell *)packet)->city_id,
46
((struct packet_city_sell *)packet)->build_id);
46
((const struct packet_city_sell *)packet)->city_id,
47
((const struct packet_city_sell *)packet)->build_id);
49
50
case PACKET_CITY_BUY:
50
51
handle_city_buy(pplayer,
51
((struct packet_city_buy *)packet)->city_id);
52
((const struct packet_city_buy *)packet)->city_id);
54
55
case PACKET_CITY_CHANGE:
55
56
handle_city_change(pplayer,
56
((struct packet_city_change *)packet)->city_id,
57
((struct packet_city_change *)packet)->production_kind,
58
((struct packet_city_change *)packet)->production_value);
57
((const struct packet_city_change *)packet)->city_id,
58
((const struct packet_city_change *)packet)->production_kind,
59
((const struct packet_city_change *)packet)->production_value);
61
62
case PACKET_CITY_WORKLIST:
62
63
handle_city_worklist(pplayer,
63
((struct packet_city_worklist *)packet)->city_id,
64
&((struct packet_city_worklist *)packet)->worklist);
64
((const struct packet_city_worklist *)packet)->city_id,
65
&((const struct packet_city_worklist *)packet)->worklist);
67
68
case PACKET_CITY_MAKE_SPECIALIST:
68
69
handle_city_make_specialist(pplayer,
69
((struct packet_city_make_specialist *)packet)->city_id,
70
((struct packet_city_make_specialist *)packet)->worker_x,
71
((struct packet_city_make_specialist *)packet)->worker_y);
70
((const struct packet_city_make_specialist *)packet)->city_id,
71
((const struct packet_city_make_specialist *)packet)->worker_x,
72
((const struct packet_city_make_specialist *)packet)->worker_y);
74
75
case PACKET_CITY_MAKE_WORKER:
75
76
handle_city_make_worker(pplayer,
76
((struct packet_city_make_worker *)packet)->city_id,
77
((struct packet_city_make_worker *)packet)->worker_x,
78
((struct packet_city_make_worker *)packet)->worker_y);
77
((const struct packet_city_make_worker *)packet)->city_id,
78
((const struct packet_city_make_worker *)packet)->worker_x,
79
((const struct packet_city_make_worker *)packet)->worker_y);
81
82
case PACKET_CITY_CHANGE_SPECIALIST:
82
83
handle_city_change_specialist(pplayer,
83
((struct packet_city_change_specialist *)packet)->city_id,
84
((struct packet_city_change_specialist *)packet)->from,
85
((struct packet_city_change_specialist *)packet)->to);
84
((const struct packet_city_change_specialist *)packet)->city_id,
85
((const struct packet_city_change_specialist *)packet)->from,
86
((const struct packet_city_change_specialist *)packet)->to);
88
89
case PACKET_CITY_RENAME:
89
90
handle_city_rename(pplayer,
90
((struct packet_city_rename *)packet)->city_id,
91
((struct packet_city_rename *)packet)->name);
91
((const struct packet_city_rename *)packet)->city_id,
92
((const struct packet_city_rename *)packet)->name);
94
95
case PACKET_CITY_OPTIONS_REQ:
95
96
handle_city_options_req(pplayer,
96
((struct packet_city_options_req *)packet)->city_id,
97
((struct packet_city_options_req *)packet)->options);
97
((const struct packet_city_options_req *)packet)->city_id,
98
((const struct packet_city_options_req *)packet)->options);
100
101
case PACKET_CITY_REFRESH:
101
102
handle_city_refresh(pplayer,
102
((struct packet_city_refresh *)packet)->city_id);
103
((const struct packet_city_refresh *)packet)->city_id);
105
106
case PACKET_CITY_NAME_SUGGESTION_REQ:
106
107
handle_city_name_suggestion_req(pplayer,
107
((struct packet_city_name_suggestion_req *)packet)->unit_id);
108
((const struct packet_city_name_suggestion_req *)packet)->unit_id);
110
111
case PACKET_PLAYER_PHASE_DONE:
111
112
handle_player_phase_done(pplayer,
112
((struct packet_player_phase_done *)packet)->turn);
113
((const struct packet_player_phase_done *)packet)->turn);
115
116
case PACKET_PLAYER_RATES:
116
117
handle_player_rates(pplayer,
117
((struct packet_player_rates *)packet)->tax,
118
((struct packet_player_rates *)packet)->luxury,
119
((struct packet_player_rates *)packet)->science);
118
((const struct packet_player_rates *)packet)->tax,
119
((const struct packet_player_rates *)packet)->luxury,
120
((const struct packet_player_rates *)packet)->science);
122
123
case PACKET_PLAYER_CHANGE_GOVERNMENT:
123
124
handle_player_change_government(pplayer,
124
((struct packet_player_change_government *)packet)->government);
125
((const struct packet_player_change_government *)packet)->government);
127
128
case PACKET_PLAYER_RESEARCH:
128
129
handle_player_research(pplayer,
129
((struct packet_player_research *)packet)->tech);
130
((const struct packet_player_research *)packet)->tech);
132
133
case PACKET_PLAYER_TECH_GOAL:
133
134
handle_player_tech_goal(pplayer,
134
((struct packet_player_tech_goal *)packet)->tech);
135
((const struct packet_player_tech_goal *)packet)->tech);
137
138
case PACKET_PLAYER_ATTRIBUTE_BLOCK:
145
146
case PACKET_UNIT_MOVE:
146
147
handle_unit_move(pplayer,
147
((struct packet_unit_move *)packet)->unit_id,
148
((struct packet_unit_move *)packet)->x,
149
((struct packet_unit_move *)packet)->y);
148
((const struct packet_unit_move *)packet)->unit_id,
149
((const struct packet_unit_move *)packet)->tile);
152
152
case PACKET_UNIT_BUILD_CITY:
153
153
handle_unit_build_city(pplayer,
154
((struct packet_unit_build_city *)packet)->unit_id,
155
((struct packet_unit_build_city *)packet)->name);
154
((const struct packet_unit_build_city *)packet)->unit_id,
155
((const struct packet_unit_build_city *)packet)->name);
158
158
case PACKET_UNIT_DISBAND:
159
159
handle_unit_disband(pplayer,
160
((struct packet_unit_disband *)packet)->unit_id);
160
((const struct packet_unit_disband *)packet)->unit_id);
163
163
case PACKET_UNIT_CHANGE_HOMECITY:
164
164
handle_unit_change_homecity(pplayer,
165
((struct packet_unit_change_homecity *)packet)->unit_id,
166
((struct packet_unit_change_homecity *)packet)->city_id);
165
((const struct packet_unit_change_homecity *)packet)->unit_id,
166
((const struct packet_unit_change_homecity *)packet)->city_id);
169
169
case PACKET_UNIT_ESTABLISH_TRADE:
170
170
handle_unit_establish_trade(pplayer,
171
((struct packet_unit_establish_trade *)packet)->unit_id);
171
((const struct packet_unit_establish_trade *)packet)->unit_id);
174
174
case PACKET_UNIT_BATTLEGROUP:
175
175
handle_unit_battlegroup(pplayer,
176
((struct packet_unit_battlegroup *)packet)->unit_id,
177
((struct packet_unit_battlegroup *)packet)->battlegroup);
176
((const struct packet_unit_battlegroup *)packet)->unit_id,
177
((const struct packet_unit_battlegroup *)packet)->battlegroup);
180
180
case PACKET_UNIT_HELP_BUILD_WONDER:
181
181
handle_unit_help_build_wonder(pplayer,
182
((struct packet_unit_help_build_wonder *)packet)->unit_id);
182
((const struct packet_unit_help_build_wonder *)packet)->unit_id);
185
185
case PACKET_UNIT_ORDERS:
189
189
case PACKET_UNIT_AUTOSETTLERS:
190
190
handle_unit_autosettlers(pplayer,
191
((struct packet_unit_autosettlers *)packet)->unit_id);
191
((const struct packet_unit_autosettlers *)packet)->unit_id);
194
194
case PACKET_UNIT_LOAD:
195
195
handle_unit_load(pplayer,
196
((struct packet_unit_load *)packet)->cargo_id,
197
((struct packet_unit_load *)packet)->transporter_id);
196
((const struct packet_unit_load *)packet)->cargo_id,
197
((const struct packet_unit_load *)packet)->transporter_id);
200
200
case PACKET_UNIT_UNLOAD:
201
201
handle_unit_unload(pplayer,
202
((struct packet_unit_unload *)packet)->cargo_id,
203
((struct packet_unit_unload *)packet)->transporter_id);
202
((const struct packet_unit_unload *)packet)->cargo_id,
203
((const struct packet_unit_unload *)packet)->transporter_id);
206
206
case PACKET_UNIT_UPGRADE:
207
207
handle_unit_upgrade(pplayer,
208
((struct packet_unit_upgrade *)packet)->unit_id);
208
((const struct packet_unit_upgrade *)packet)->unit_id);
211
case PACKET_UNIT_CONVERT:
212
handle_unit_convert(pplayer,
213
((const struct packet_unit_convert *)packet)->unit_id);
211
216
case PACKET_UNIT_NUKE:
212
217
handle_unit_nuke(pplayer,
213
((struct packet_unit_nuke *)packet)->unit_id);
218
((const struct packet_unit_nuke *)packet)->unit_id);
216
221
case PACKET_UNIT_PARADROP_TO:
217
222
handle_unit_paradrop_to(pplayer,
218
((struct packet_unit_paradrop_to *)packet)->unit_id,
219
((struct packet_unit_paradrop_to *)packet)->x,
220
((struct packet_unit_paradrop_to *)packet)->y);
223
((const struct packet_unit_paradrop_to *)packet)->unit_id,
224
((const struct packet_unit_paradrop_to *)packet)->tile);
223
227
case PACKET_UNIT_AIRLIFT:
224
228
handle_unit_airlift(pplayer,
225
((struct packet_unit_airlift *)packet)->unit_id,
226
((struct packet_unit_airlift *)packet)->city_id);
229
((const struct packet_unit_airlift *)packet)->unit_id,
230
((const struct packet_unit_airlift *)packet)->city_id);
229
233
case PACKET_UNIT_DIPLOMAT_QUERY:
230
234
handle_unit_diplomat_query(pconn,
231
((struct packet_unit_diplomat_query *)packet)->diplomat_id,
232
((struct packet_unit_diplomat_query *)packet)->target_id,
233
((struct packet_unit_diplomat_query *)packet)->value,
234
((struct packet_unit_diplomat_query *)packet)->action_type);
235
((const struct packet_unit_diplomat_query *)packet)->diplomat_id,
236
((const struct packet_unit_diplomat_query *)packet)->target_id,
237
((const struct packet_unit_diplomat_query *)packet)->value,
238
((const struct packet_unit_diplomat_query *)packet)->action_type);
237
241
case PACKET_UNIT_TYPE_UPGRADE:
238
242
handle_unit_type_upgrade(pplayer,
239
((struct packet_unit_type_upgrade *)packet)->type);
243
((const struct packet_unit_type_upgrade *)packet)->type);
242
246
case PACKET_UNIT_DIPLOMAT_ACTION:
243
247
handle_unit_diplomat_action(pplayer,
244
((struct packet_unit_diplomat_action *)packet)->diplomat_id,
245
((struct packet_unit_diplomat_action *)packet)->target_id,
246
((struct packet_unit_diplomat_action *)packet)->value,
247
((struct packet_unit_diplomat_action *)packet)->action_type);
248
((const struct packet_unit_diplomat_action *)packet)->diplomat_id,
249
((const struct packet_unit_diplomat_action *)packet)->target_id,
250
((const struct packet_unit_diplomat_action *)packet)->value,
251
((const struct packet_unit_diplomat_action *)packet)->action_type);
250
254
case PACKET_UNIT_CHANGE_ACTIVITY:
251
255
handle_unit_change_activity(pplayer,
252
((struct packet_unit_change_activity *)packet)->unit_id,
253
((struct packet_unit_change_activity *)packet)->activity,
254
((struct packet_unit_change_activity *)packet)->activity_target,
255
((struct packet_unit_change_activity *)packet)->activity_base);
256
((const struct packet_unit_change_activity *)packet)->unit_id,
257
((const struct packet_unit_change_activity *)packet)->activity,
258
((const struct packet_unit_change_activity *)packet)->activity_target,
259
((const struct packet_unit_change_activity *)packet)->activity_base);
258
262
case PACKET_DIPLOMACY_INIT_MEETING_REQ:
259
263
handle_diplomacy_init_meeting_req(pplayer,
260
((struct packet_diplomacy_init_meeting_req *)packet)->counterpart);
264
((const struct packet_diplomacy_init_meeting_req *)packet)->counterpart);
263
267
case PACKET_DIPLOMACY_CANCEL_MEETING_REQ:
264
268
handle_diplomacy_cancel_meeting_req(pplayer,
265
((struct packet_diplomacy_cancel_meeting_req *)packet)->counterpart);
269
((const struct packet_diplomacy_cancel_meeting_req *)packet)->counterpart);
268
272
case PACKET_DIPLOMACY_CREATE_CLAUSE_REQ:
269
273
handle_diplomacy_create_clause_req(pplayer,
270
((struct packet_diplomacy_create_clause_req *)packet)->counterpart,
271
((struct packet_diplomacy_create_clause_req *)packet)->giver,
272
((struct packet_diplomacy_create_clause_req *)packet)->type,
273
((struct packet_diplomacy_create_clause_req *)packet)->value);
274
((const struct packet_diplomacy_create_clause_req *)packet)->counterpart,
275
((const struct packet_diplomacy_create_clause_req *)packet)->giver,
276
((const struct packet_diplomacy_create_clause_req *)packet)->type,
277
((const struct packet_diplomacy_create_clause_req *)packet)->value);
276
280
case PACKET_DIPLOMACY_REMOVE_CLAUSE_REQ:
277
281
handle_diplomacy_remove_clause_req(pplayer,
278
((struct packet_diplomacy_remove_clause_req *)packet)->counterpart,
279
((struct packet_diplomacy_remove_clause_req *)packet)->giver,
280
((struct packet_diplomacy_remove_clause_req *)packet)->type,
281
((struct packet_diplomacy_remove_clause_req *)packet)->value);
282
((const struct packet_diplomacy_remove_clause_req *)packet)->counterpart,
283
((const struct packet_diplomacy_remove_clause_req *)packet)->giver,
284
((const struct packet_diplomacy_remove_clause_req *)packet)->type,
285
((const struct packet_diplomacy_remove_clause_req *)packet)->value);
284
288
case PACKET_DIPLOMACY_ACCEPT_TREATY_REQ:
285
289
handle_diplomacy_accept_treaty_req(pplayer,
286
((struct packet_diplomacy_accept_treaty_req *)packet)->counterpart);
290
((const struct packet_diplomacy_accept_treaty_req *)packet)->counterpart);
289
293
case PACKET_DIPLOMACY_CANCEL_PACT:
290
294
handle_diplomacy_cancel_pact(pplayer,
291
((struct packet_diplomacy_cancel_pact *)packet)->other_player_id,
292
((struct packet_diplomacy_cancel_pact *)packet)->clause);
295
((const struct packet_diplomacy_cancel_pact *)packet)->other_player_id,
296
((const struct packet_diplomacy_cancel_pact *)packet)->clause);
295
299
case PACKET_REPORT_REQ:
296
300
handle_report_req(pconn,
297
((struct packet_report_req *)packet)->type);
301
((const struct packet_report_req *)packet)->type);
300
304
case PACKET_CONN_PONG:
351
355
case PACKET_EDIT_TOGGLE_FOGOFWAR:
352
356
handle_edit_toggle_fogofwar(pconn,
353
((struct packet_edit_toggle_fogofwar *)packet)->player);
357
((const struct packet_edit_toggle_fogofwar *)packet)->player);
356
360
case PACKET_EDIT_TILE_TERRAIN:
357
361
handle_edit_tile_terrain(pconn,
358
((struct packet_edit_tile_terrain *)packet)->x,
359
((struct packet_edit_tile_terrain *)packet)->y,
360
((struct packet_edit_tile_terrain *)packet)->terrain,
361
((struct packet_edit_tile_terrain *)packet)->size);
362
((const struct packet_edit_tile_terrain *)packet)->tile,
363
((const struct packet_edit_tile_terrain *)packet)->terrain,
364
((const struct packet_edit_tile_terrain *)packet)->size);
364
367
case PACKET_EDIT_TILE_RESOURCE:
365
368
handle_edit_tile_resource(pconn,
366
((struct packet_edit_tile_resource *)packet)->x,
367
((struct packet_edit_tile_resource *)packet)->y,
368
((struct packet_edit_tile_resource *)packet)->resource,
369
((struct packet_edit_tile_resource *)packet)->size);
369
((const struct packet_edit_tile_resource *)packet)->tile,
370
((const struct packet_edit_tile_resource *)packet)->resource,
371
((const struct packet_edit_tile_resource *)packet)->size);
372
374
case PACKET_EDIT_TILE_SPECIAL:
373
375
handle_edit_tile_special(pconn,
374
((struct packet_edit_tile_special *)packet)->x,
375
((struct packet_edit_tile_special *)packet)->y,
376
((struct packet_edit_tile_special *)packet)->special,
377
((struct packet_edit_tile_special *)packet)->remove,
378
((struct packet_edit_tile_special *)packet)->size);
376
((const struct packet_edit_tile_special *)packet)->tile,
377
((const struct packet_edit_tile_special *)packet)->special,
378
((const struct packet_edit_tile_special *)packet)->remove,
379
((const struct packet_edit_tile_special *)packet)->size);
381
382
case PACKET_EDIT_TILE_BASE:
382
383
handle_edit_tile_base(pconn,
383
((struct packet_edit_tile_base *)packet)->x,
384
((struct packet_edit_tile_base *)packet)->y,
385
((struct packet_edit_tile_base *)packet)->base_type_id,
386
((struct packet_edit_tile_base *)packet)->remove,
387
((struct packet_edit_tile_base *)packet)->size);
384
((const struct packet_edit_tile_base *)packet)->tile,
385
((const struct packet_edit_tile_base *)packet)->base_type_id,
386
((const struct packet_edit_tile_base *)packet)->remove,
387
((const struct packet_edit_tile_base *)packet)->size);
390
390
case PACKET_EDIT_STARTPOS:
391
handle_edit_startpos(pconn,
392
((struct packet_edit_startpos *)packet)->x,
393
((struct packet_edit_startpos *)packet)->y,
394
((struct packet_edit_startpos *)packet)->nation);
391
handle_edit_startpos(pconn, packet);
394
case PACKET_EDIT_STARTPOS_FULL:
395
handle_edit_startpos_full(pconn, packet);
397
398
case PACKET_EDIT_TILE:
401
402
case PACKET_EDIT_UNIT_CREATE:
402
handle_edit_unit_create(pconn, packet);
403
handle_edit_unit_create(pconn,
404
((const struct packet_edit_unit_create *)packet)->owner,
405
((const struct packet_edit_unit_create *)packet)->tile,
406
((const struct packet_edit_unit_create *)packet)->type,
407
((const struct packet_edit_unit_create *)packet)->count,
408
((const struct packet_edit_unit_create *)packet)->tag);
405
411
case PACKET_EDIT_UNIT_REMOVE:
406
412
handle_edit_unit_remove(pconn,
407
((struct packet_edit_unit_remove *)packet)->owner,
408
((struct packet_edit_unit_remove *)packet)->x,
409
((struct packet_edit_unit_remove *)packet)->y,
410
((struct packet_edit_unit_remove *)packet)->type,
411
((struct packet_edit_unit_remove *)packet)->count);
413
((const struct packet_edit_unit_remove *)packet)->owner,
414
((const struct packet_edit_unit_remove *)packet)->tile,
415
((const struct packet_edit_unit_remove *)packet)->type,
416
((const struct packet_edit_unit_remove *)packet)->count);
414
419
case PACKET_EDIT_UNIT_REMOVE_BY_ID:
415
420
handle_edit_unit_remove_by_id(pconn,
416
((struct packet_edit_unit_remove_by_id *)packet)->id);
421
((const struct packet_edit_unit_remove_by_id *)packet)->id);
419
424
case PACKET_EDIT_UNIT: