Freeciv-3.2
Loading...
Searching...
No Matches
editor.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 2005 - The Freeciv Project
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 <stdarg.h>
19#include <string.h>
20
21/* utility */
22#include "bitvector.h"
23#include "capability.h"
24#include "fcintl.h"
25#include "log.h"
26#include "support.h"
27
28/* common */
29#include "game.h"
30#include "map.h"
31#include "movement.h"
32#include "packets.h"
33
34/* client */
35#include "client_main.h"
36#include "climap.h"
37#include "control.h"
38#include "editor.h"
39#include "mapctrl_common.h"
40#include "tilespec.h"
41#include "zoom.h"
42
43/* client/include */
44#include "editgui_g.h"
45#include "mapview_g.h"
46
47
53
62
66 const struct tile *origin;
67};
68
70 int flags;
72 int size;
73 int count;
75 const char *name;
76 int value;
77 const char *tooltip;
78};
79
100
101static struct editor_state *editor = NULL;
102
103/************************************************************************/
107{
108 struct editor_tool *tool = editor->tools + ett;
109
111 || ett == ETT_ROAD
114 struct extra_type *first = NULL;
115
116 extra_type_iterate(pextra) {
117 if (ett == ETT_ROAD) {
118 if (is_extra_caused_by(pextra, EC_ROAD)) {
119 first = pextra;
120 break;
121 }
122 } else if (ett == ETT_MILITARY_BASE) {
123 if (is_extra_caused_by(pextra, EC_BASE)) {
124 first = pextra;
125 break;
126 }
127 } else if (ett == ETT_TERRAIN_RESOURCE) {
128 if (is_extra_caused_by(pextra, EC_RESOURCE)) {
129 first = pextra;
130 break;
131 }
132 } else {
133 /* Considers extras that are neither bases or roads, specials */
134 first = pextra;
135 break;
136 }
138
139 if (first != NULL) {
140 tool->value = extra_index(first);
141 } else {
142 tool->value = 0;
143 }
144 } else {
145 tool->value = 0;
146 }
147}
148
149/************************************************************************/
152static void tool_init(enum editor_tool_type ett, const char *name,
153 int flags, const char *tooltip)
154{
155 struct editor_tool *tool;
156
157 if (!editor || !(ett < NUM_EDITOR_TOOL_TYPES)) {
158 return;
159 }
160
161 tool = editor->tools + ett;
162
163 if (ett == ETT_COPYPASTE) {
164 tool->mode = ETM_COPY;
165 } else {
166 tool->mode = ETM_PAINT;
167 }
168 tool->name = name;
169 tool->flags = flags;
170 tool->tooltip = tooltip;
171 tool->size = 1;
172 tool->count = 1;
173 tool->applied_player_no = 0;
174
176}
177
178/************************************************************************/
182{
183 int t;
184
185 for (t = 0; t < NUM_EDITOR_TOOL_TYPES; t++) {
187 }
188}
189
190/************************************************************************/
194void editor_init(void)
195{
197
198 editor = fc_calloc(1, sizeof(struct editor_state));
199
200 tool_init(ETT_TERRAIN, _("Terrain"),
202 _("Change tile terrain.\nShortcut: t\n"
203 "Select terrain type: shift+t or right-click here."));
204 tool_init(ETT_TERRAIN_RESOURCE, _("Terrain Resource"),
206 _("Change tile terrain resources.\nShortcut: r\n"
207 "Select resource type: shift+r or right-click here."));
208 tool_init(ETT_TERRAIN_SPECIAL, _("Terrain Special"), ETF_HAS_VALUE
210 _("Modify tile specials.\nShortcut: s\n"
211 "Select special type: shift+s or right-click here."));
214 _("Modify roads on tile.\nShortcut: p\n"
215 "Select road type: shift+p or right-click here."));
216 tool_init(ETT_MILITARY_BASE, _("Military Base"), ETF_HAS_VALUE
218 _("Create a military base.\nShortcut: m\n"
219 "Select base type: shift+m or right-click here."));
222 _("Create unit.\nShortcut: u\nSelect unit "
223 "type: shift+u or right-click here."));
225 _("Create city.\nShortcut: c"));
227 _("Modify player's tile knowledge.\nShortcut: v"));
228 tool_init(ETT_STARTPOS, _("Start Position"), ETF_NO_FLAGS,
229 _("Place a start position which allows any nation to "
230 "start at the tile. To allow only certain nations to "
231 "start there, middle click on the start position on "
232 "the map and use the property editor.\nShortcut: b"));
233
234 tool_init(ETT_COPYPASTE, _("Copy/Paste"), ETF_HAS_SIZE,
235 _("Copy and paste tiles.\n"
236 "Shortcut for copy mode: shift-c\n"
237 "Shoftcut for paste mode: shift-v"));
239
242}
243
244/************************************************************************/
254
255/************************************************************************/
258void editor_free(void)
259{
260 if (editor != NULL) {
263 free(editor);
264 editor = NULL;
265 }
266}
267
268/************************************************************************/
272{
273 if (editor == NULL) {
274 return;
275 }
276
277 if (!(ett < NUM_EDITOR_TOOL_TYPES)) {
278 return;
279 }
280
281 editor->tool = ett;
282}
283
284/************************************************************************/
288{
289 if (editor == NULL) {
291 }
292
293 return editor->tool;
294}
295
296/************************************************************************/
301{
302 if (editor == NULL || !(ett < NUM_EDITOR_TOOL_TYPES)
305 return;
306 }
307
308 editor->tools[ett].mode = etm;
309}
310
311/************************************************************************/
316{
317 if (editor == NULL || !(ett < NUM_EDITOR_TOOL_TYPES)
318 || !(etm < NUM_EDITOR_TOOL_MODES)) {
319 return FALSE;
320 }
321
322 if (etm == ETM_COPY || etm == ETM_PASTE) {
323 return ett == ETT_COPYPASTE;
324 }
325
326 if (ett == ETT_COPYPASTE) {
327 return etm == ETM_COPY || etm == ETM_PASTE;
328 }
329
330 return TRUE;
331}
332
333/************************************************************************/
337{
338 if (editor == NULL || !(ett < NUM_EDITOR_TOOL_TYPES)) {
340 }
341 return editor->tools[ett].mode;
342}
343
344/************************************************************************/
348{
349 return can_conn_edit(&client.conn);
350}
351
352/************************************************************************/
361{
362 if (!editor || !(ett < NUM_EDITOR_TOOL_TYPES)) {
363 return FALSE;
364 }
365
366 switch (ett) {
368 return base_count() > 0;
369 case ETT_ROAD:
370 return road_count() > 0;
373 case ETT_UNIT:
374 return utype_count() > 0;
375 default:
376 break;
377 }
378
379 return TRUE;
380}
381
382/************************************************************************/
387{
388 if (!editor || !(ett < NUM_EDITOR_TOOL_TYPES)) {
389 return FALSE;
390 }
392}
393
394/************************************************************************/
399{
400 if (!editor || !(ett < NUM_EDITOR_TOOL_TYPES)
402 return;
403 }
405}
406
407/************************************************************************/
411{
412 if (!editor || !(ett < NUM_EDITOR_TOOL_TYPES)
414 return 0;
415 }
416
417 return editor->tools[ett].value;
418}
419
420/************************************************************************/
441
442/************************************************************************/
447static inline bool tile_really_has_any_specials(const struct tile *ptile)
448{
449 if (!ptile) {
450 return FALSE;
451 }
452
454 if (tile_has_extra(ptile, pextra)) {
455 return TRUE;
456 }
458
459 return FALSE;
460}
461
462/************************************************************************/
466static void editor_grab_applied_player(const struct tile *ptile)
467{
468 int apno = -1;
469
470 if (!editor || !ptile) {
471 return;
472 }
473
475 && tile_get_known(ptile, client_player()) == TILE_UNKNOWN) {
476 return;
477 }
478
479 if (tile_city(ptile) != NULL) {
481 } else if (unit_list_size(ptile->units) > 0) {
482 struct unit *punit = unit_list_get(ptile->units, 0);
483
485 } else if (tile_owner(ptile) != NULL) {
486 apno = player_number(tile_owner(ptile));
487 }
488
489 if (player_by_number(apno) != NULL) {
492 }
493}
494
495/************************************************************************/
498static void editor_grab_tool(const struct tile *ptile)
499{
500 int ett = -1, value = 0;
501 struct extra_type *first_base = NULL;
502 struct extra_type *first_road = NULL;
504
505 if (!editor) {
506 return;
507 }
508
509 if (!ptile) {
510 return;
511 }
512
514 if (tile_has_extra(ptile, pextra)) {
515 first_base = pextra;
516 break;
517 }
519
521 if (tile_has_extra(ptile, pextra)) {
522 first_road = pextra;
523 break;
524 }
526
528 if (tile_has_extra(ptile, pextra)) {
529 first_resource = pextra;
530 break;
531 }
533
535 && tile_get_known(ptile, client_player()) == TILE_UNKNOWN) {
536 ett = ETT_VISION;
537
538 } else if (tile_city(ptile)) {
539 ett = ETT_CITY;
540
541 } else if (unit_list_size(ptile->units) > 0) {
542 int max_score = 0, score;
543 struct unit *grabbed_punit = NULL;
544
545 unit_list_iterate(ptile->units, punit) {
547 score = 5;
549 score = 4;
550 } else if (utype_move_type(unit_type_get(punit)) == UMT_SEA) {
551 score = 3;
552 } else {
553 score = 2;
554 }
555 if (unit_transported(punit)) {
556 score = 1;
557 }
558
559 if (score > max_score) {
560 max_score = score;
562 }
564
565 if (grabbed_punit) {
566 ett = ETT_UNIT;
568 }
569 } else if (first_base != NULL) {
571 value = extra_index(first_base);
572
573 } else if (first_road != NULL) {
574 ett = ETT_ROAD;
575 value = extra_index(first_road);
576
577 } else if (tile_really_has_any_specials(ptile)) {
579 int count = 0, i;
580 struct extra_type *special = NULL;
581
583 specials_array[count++] = s;
585
586 /* Grab specials in reverse order of enum tile_special_type. */
587
588 for (i = count - 1; i >= 0; i--) {
589 if (tile_has_extra(ptile, specials_array[i])) {
590 special = specials_array[i];
591 break;
592 }
593 }
594
595 if (special != NULL) {
597 value = extra_index(special);
598 }
599 } else if (first_resource != NULL) {
602
603 } else if (tile_terrain(ptile) != NULL) {
605 value = terrain_number(tile_terrain(ptile));
606 }
607
608 if (ett < 0) {
609 return;
610 }
611
615 }
617}
618
619/************************************************************************/
622static inline bool can_edit_tile_properties(struct tile *ptile)
623{
624 return ptile != NULL;
625}
626
627/************************************************************************/
632static void popup_properties(struct tile *ptile)
633{
634 struct tile_list *tiles;
635
636 if (!ptile) {
637 return;
638 }
639
640 tiles = tile_list_new();
641
642 if (editor_tile_is_selected(ptile)) {
646 }
648 } else {
649 if (can_edit_tile_properties(ptile)) {
650 tile_list_append(tiles, ptile);
651 }
652 }
653
655
656 tile_list_destroy(tiles);
657}
658
659/************************************************************************/
663 int button, int modifiers)
664{
665 struct tile *ptile;
666
667 if (editor == NULL) {
668 return;
669 }
670
672 if (ptile == NULL) {
673 return;
674 }
675
676 switch (button) {
677
679 if (modifiers == EKM_SHIFT) {
680 editor_grab_tool(ptile);
681 } else if (modifiers == EKM_CTRL) {
683 } else if (modifiers == EKM_NONE) {
685 editor_apply_tool(ptile, FALSE);
688 }
689 break;
690
692 if (modifiers == (EKM_ALT | EKM_CTRL)) {
693 popup_properties(ptile);
694 break;
695 }
696
697 if (modifiers == EKM_SHIFT) {
699 } else if (modifiers == EKM_ALT) {
701 } else if (modifiers == EKM_NONE) {
703 } else {
704 break;
705 }
707 break;
708
710 if (modifiers == EKM_NONE) {
711 popup_properties(ptile);
712 }
713 break;
714
715 default:
716 break;
717 }
718}
719
720/************************************************************************/
724{
725 int w, h;
726
727 if (!editor) {
728 return;
729 }
730
732
733 if (editor->selrect_width <= 0 || editor->selrect_height <= 0) {
734 struct tile *ptile;
735
737 if (ptile && editor->selection_mode == SELECTION_MODE_ADD) {
739 } else if (ptile && editor->selection_mode == SELECTION_MODE_REMOVE) {
741 } else {
743 return;
744 }
745
746 if (ptile) {
748 }
749
750 return;
751 }
752
756 ptile, pedge, pcorner, map_zoom) {
757 if (ptile == NULL) {
758 continue;
759 }
765 }
767
770
772 editor->selrect_y - h,
773 editor->selrect_width + 2 * w,
774 editor->selrect_height + 2 * h);
775 flush_dirty();
776}
777
778/************************************************************************/
781static void editor_draw_selrect(void)
782{
783 if (!editor) {
784 return;
785 }
786
788 && editor->selrect_height > 0) {
793 }
794}
795
796/************************************************************************/
800 int button, int modifiers)
801{
802 switch (button) {
803
807 break;
808
810 if (editor->selrect_active) {
812 }
813 break;
814
816 break;
817
818 default:
819 break;
820 }
821}
822
823/************************************************************************/
828{
829 int xl, yt, xr, yb;
830
833 xr = canvas_x;
834 } else {
835 xl = canvas_x;
837 }
838
841 yb = canvas_y;
842 } else {
843 yt = canvas_y;
845 }
846
847 /* Erase the previously drawn rectangle. */
849
850 if (xl == xr || yt == yb) {
853 return;
854 }
855
860
862}
863
864/************************************************************************/
868{
869 const struct tile *ptile, *old;
870
871 if (!editor) {
872 return;
873 }
874
877
878 if (!ptile) {
879 return;
880 }
881
882 if (editor->tool_active && old != NULL && old != ptile) {
883 editor_apply_tool(ptile, FALSE);
886 }
887
888 if (editor->selrect_active) {
890 }
891}
892
893/************************************************************************/
902
903/************************************************************************/
910void editor_apply_tool(const struct tile *ptile,
912{
915 int value, size, count, apno, tile, id;
916 bool erase;
917 struct connection *my_conn = &client.conn;
918
919 if (editor == NULL || ptile == NULL) {
920 return;
921 }
922
926 count = editor_tool_get_count(ett);
927 value = editor_tool_get_value(ett);
929
932 && tile_get_known(ptile, client_player()) == TILE_UNKNOWN) {
933 return;
934 }
935
937 && player_by_number(apno) == NULL) {
938 return;
939 }
940
941 if (ett == ETT_COPYPASTE) {
942 struct edit_buffer *ebuf;
944 if (etm == ETM_COPY) {
945 if (part_of_selection) {
946 edit_buffer_copy(ebuf, ptile);
947 } else {
951 }
952 } else if (etm == ETM_PAINT || etm == ETM_PASTE) {
953 edit_buffer_paste(ebuf, ptile);
954 }
955 return;
956 }
957
958 if (part_of_selection && ett != ETT_CITY) {
959 size = 1;
960 }
961
962 erase = (etm == ETM_ERASE);
963 tile = tile_index(ptile);
964
965 switch (ett) {
966
967 case ETT_TERRAIN:
968 dsend_packet_edit_tile_terrain(my_conn, tile, erase ? 0 : value, size);
969 break;
970
973 case ETT_ROAD:
976 break;
977
978 case ETT_UNIT:
979 if (erase) {
981 } else {
983 }
984 break;
985
986 case ETT_CITY:
987 if (erase) {
988 struct city *pcity = tile_city(ptile);
989 if (pcity != NULL) {
990 id = pcity->id;
992 }
993 } else {
995 }
996 break;
997
998 case ETT_VISION:
999 if (client_has_player()) {
1000 id = client_player_number();
1002 }
1003 break;
1004
1005 case ETT_STARTPOS:
1007 break;
1008
1009 default:
1010 break;
1011 }
1012}
1013
1014/************************************************************************/
1017void editor_set_current_tile(const struct tile *ptile)
1018{
1019 if (editor == NULL) {
1020 return;
1021 }
1022
1023 editor->current_tile = ptile;
1024}
1025
1026/************************************************************************/
1030{
1031 if (editor == NULL) {
1032 return NULL;
1033 }
1034
1035 return editor->current_tile;
1036}
1037
1038/************************************************************************/
1043 enum editor_tool_mode etm)
1044{
1045 if (!editor_tool_has_mode(ett, etm)) {
1046 return;
1047 }
1048 if (editor_tool_get_mode(ett) == etm) {
1050 ? ETM_COPY : ETM_PAINT);
1051 } else {
1053 }
1054}
1055
1056/************************************************************************/
1060{
1061 int mode, count;
1062 bool found = FALSE;
1063
1064 mode = editor_tool_get_mode(ett);
1065 if (!(0 <= mode && mode < NUM_EDITOR_TOOL_MODES)) {
1066 return;
1067 }
1068
1069 for (count = 0; count < NUM_EDITOR_TOOL_MODES; count++) {
1070 mode = (mode + 1) % NUM_EDITOR_TOOL_MODES;
1071 if (editor_tool_has_mode(ett, mode)) {
1072 found = TRUE;
1073 break;
1074 }
1075 }
1076
1077 if (found) {
1079 }
1080}
1081
1082/************************************************************************/
1086{
1087 if (!editor) {
1088 return;
1089 }
1091}
1092
1093/************************************************************************/
1096void editor_selection_add(const struct tile *ptile)
1097{
1098 if (!editor || !ptile) {
1099 return;
1100 }
1102}
1103
1104/************************************************************************/
1107void editor_selection_remove(const struct tile *ptile)
1108{
1109 if (!editor || !ptile) {
1110 return;
1111 }
1113}
1114
1115/************************************************************************/
1118bool editor_tile_is_selected(const struct tile *ptile)
1119{
1120 if (!editor || !ptile) {
1121 return FALSE;
1122 }
1124}
1125
1126/************************************************************************/
1156
1157/************************************************************************/
1161{
1162 if (!editor || !(ett < NUM_EDITOR_TOOL_TYPES)) {
1163 return "";
1164 }
1165
1166 return editor->tools[ett].name;
1167}
1168
1169/************************************************************************/
1174{
1175 struct terrain *pterrain;
1176 struct unit_type *putype;
1177 struct extra_type *pextra;
1178
1179 if (!editor) {
1180 return "";
1181 }
1182
1183 switch (emt) {
1184 case ETT_TERRAIN:
1185 pterrain = terrain_by_number(value);
1186 return pterrain ? terrain_name_translation(pterrain) : "";
1187 break;
1190 case ETT_ROAD:
1191 case ETT_MILITARY_BASE:
1192 pextra = extra_by_number(value);
1193 return pextra != NULL ? extra_name_translation(pextra) : "";
1194 break;
1195 case ETT_UNIT:
1196 putype = utype_by_number(value);
1197 return putype ? utype_name_translation(putype) : "";
1198 break;
1199 default:
1200 break;
1201 }
1202 return "";
1203}
1204
1205/************************************************************************/
1209{
1210 if (!editor || !(ett < NUM_EDITOR_TOOL_TYPES)) {
1211 return FALSE;
1212 }
1213 return editor->tools[ett].flags & ETF_HAS_SIZE;
1214}
1215
1216/************************************************************************/
1220{
1221 if (!editor || !(ett < NUM_EDITOR_TOOL_TYPES)) {
1222 return 1;
1223 }
1224 return editor->tools[ett].size;
1225}
1226
1227/************************************************************************/
1231{
1232 if (!editor || !(ett < NUM_EDITOR_TOOL_TYPES)) {
1233 return;
1234 }
1235 editor->tools[ett].size = MAX(1, size);
1236}
1237
1238/************************************************************************/
1243{
1244 if (!editor || !(ett < NUM_EDITOR_TOOL_TYPES)) {
1245 return FALSE;
1246 }
1247 return editor->tools[ett].flags & ETF_HAS_COUNT;
1248}
1249
1250/************************************************************************/
1254{
1255 if (!editor || !(ett < NUM_EDITOR_TOOL_TYPES)) {
1256 return 1;
1257 }
1258 return editor->tools[ett].count;
1259}
1260
1261/************************************************************************/
1265{
1266 if (!editor || !(ett < NUM_EDITOR_TOOL_TYPES)) {
1267 return;
1268 }
1269 editor->tools[ett].count = MAX(1, count);
1270}
1271
1272/************************************************************************/
1277{
1278 const struct editor_sprites *sprites;
1279
1280 if (!tileset || !(ett < NUM_EDITOR_TOOL_TYPES)) {
1281 return NULL;
1282 }
1283
1284 sprites = get_editor_sprites(tileset);
1285 if (!sprites) {
1286 return NULL;
1287 }
1288
1289 switch (ett) {
1290 case ETT_COPYPASTE:
1291 return sprites->copypaste;
1292 break;
1293 case ETT_TERRAIN:
1294 return sprites->terrain;
1295 break;
1297 return sprites->terrain_resource;
1298 break;
1300 return sprites->terrain_special;
1301 break;
1302 case ETT_ROAD:
1303 return sprites->road;
1304 case ETT_MILITARY_BASE:
1305 return sprites->military_base;
1306 case ETT_UNIT:
1307 return sprites->unit;
1308 break;
1309 case ETT_CITY:
1310 return sprites->city;
1311 break;
1312 case ETT_VISION:
1313 return sprites->vision;
1314 break;
1315 case ETT_STARTPOS:
1316 return sprites->startpos;
1317 break;
1318 default:
1319 break;
1320 }
1321
1322 return NULL;
1323}
1324
1325/************************************************************************/
1329{
1330 if (!editor || !(ett < NUM_EDITOR_TOOL_TYPES)
1331 || !editor->tools[ett].tooltip) {
1332 return "";
1333 }
1334 return editor->tools[ett].tooltip;
1335}
1336
1337/************************************************************************/
1343{
1344 if (!editor || !(ett < NUM_EDITOR_TOOL_TYPES)) {
1345 return -1;
1346 }
1348}
1349
1350/************************************************************************/
1354 int player_no)
1355{
1356 if (!editor || !(ett < NUM_EDITOR_TOOL_TYPES)) {
1357 return;
1358 }
1359 editor->tools[ett].applied_player_no = player_no;
1360}
1361
1362/************************************************************************/
1367{
1368 if (!editor || !(ett < NUM_EDITOR_TOOL_TYPES)) {
1369 return FALSE;
1370 }
1372}
1373
1374/************************************************************************/
1379{
1380 if (!editor || !(ett < NUM_EDITOR_TOOL_TYPES)) {
1381 return FALSE;
1382 }
1384}
1385
1386/************************************************************************/
1390{
1391 if (!editor) {
1392 return 0;
1393 }
1395}
1396
1397/************************************************************************/
1407{
1408 struct unit *vunit;
1409 struct player *pplayer;
1410 struct unit_type *putype;
1411 int apno, value;
1412
1414 putype = utype_by_number(value);
1415
1416 if (!putype) {
1417 return NULL;
1418 }
1419
1421 pplayer = player_by_number(apno);
1422 if (!pplayer) {
1423 return NULL;
1424 }
1425
1426 vunit = unit_virtual_create(pplayer, NULL, putype, 0);
1427
1428 return vunit;
1429}
1430
1431/************************************************************************/
1435{
1436 struct edit_buffer *ebuf;
1437
1438 if (!(0 <= type_flags && type_flags <= EBT_ALL)) {
1439 return NULL;
1440 }
1441
1442 ebuf = fc_calloc(1, sizeof(*ebuf));
1443 ebuf->type_flags = type_flags;
1444 ebuf->vtiles = tile_list_new();
1445
1446 return ebuf;
1447}
1448
1449/************************************************************************/
1453{
1454 if (!ebuf) {
1455 return;
1456 }
1457
1458 if (ebuf->vtiles) {
1459 tile_list_iterate(ebuf->vtiles, vtile) {
1462 tile_list_destroy(ebuf->vtiles);
1463 ebuf->vtiles = NULL;
1464 }
1465 free(ebuf);
1466}
1467
1468/************************************************************************/
1472{
1473 if (!ebuf || !ebuf->vtiles) {
1474 return;
1475 }
1476
1477 tile_list_iterate(ebuf->vtiles, vtile) {
1480 tile_list_clear(ebuf->vtiles);
1481
1483}
1484
1485/************************************************************************/
1490 const struct tile *center,
1491 int radius)
1492{
1493 if (!ebuf || !center || radius < 1) {
1494 return;
1495 }
1496
1498 square_iterate(&(wld.map), center, radius - 1, ptile) {
1499 edit_buffer_copy(ebuf, ptile);
1501}
1502
1503/************************************************************************/
1506void edit_buffer_copy(struct edit_buffer *ebuf, const struct tile *ptile)
1507{
1508 struct tile *vtile;
1509 struct unit *vunit;
1510 bool copied = FALSE;
1511
1512 if (!ebuf || !ptile) {
1513 return;
1514 }
1515
1517 vtile->index = tile_index(ptile);
1518
1520 switch (type) {
1521 case EBT_TERRAIN:
1522 if (tile_terrain(ptile)) {
1524 copied = TRUE;
1525 }
1526 break;
1527 case EBT_RESOURCE:
1528 if (tile_resource(ptile)) {
1530 copied = TRUE;
1531 }
1532 break;
1533 case EBT_SPECIAL:
1535 if (tile_has_extra(ptile, pextra)) {
1536 tile_add_extra(vtile, pextra);
1537 copied = TRUE;
1538 }
1540 break;
1541 case EBT_BASE:
1542 extra_type_iterate(pextra) {
1543 if (tile_has_extra(ptile, pextra)
1544 && is_extra_caused_by(pextra, EC_BASE)) {
1545 tile_add_extra(vtile, pextra);
1546 copied = TRUE;
1547 }
1549 break;
1550 case EBT_ROAD:
1551 extra_type_iterate(pextra) {
1552 if (tile_has_extra(ptile, pextra)
1553 && is_extra_caused_by(pextra, EC_ROAD)) {
1554 tile_add_extra(vtile, pextra);
1555 copied = TRUE;
1556 }
1558 break;
1559 case EBT_UNIT:
1560 unit_list_iterate(ptile->units, punit) {
1561 if (!punit) {
1562 continue;
1563 }
1566 vunit->homecity = punit->homecity;
1567 vunit->hp = punit->hp;
1568 unit_list_append(vtile->units, vunit);
1569 copied = TRUE;
1571 break;
1572 case EBT_CITY:
1573 if (tile_city(ptile)) {
1574 struct city *pcity, *vcity;
1575 char name[MAX_LEN_NAME];
1576
1577 pcity = tile_city(ptile);
1578 fc_snprintf(name, sizeof(name), "Copy of %s",
1579 city_name_get(pcity));
1582 improvement_iterate(pimprove) {
1583 if (!is_improvement(pimprove)
1584 || !city_has_building(pcity, pimprove)) {
1585 continue;
1586 }
1587 city_add_improvement(vcity, pimprove);
1590 copied = TRUE;
1591 }
1592 break;
1593 default:
1594 break;
1595 }
1597
1598 if (copied) {
1599 tile_list_append(ebuf->vtiles, vtile);
1600 } else {
1602 }
1603}
1604
1605/************************************************************************/
1608static void fill_tile_edit_packet(struct packet_edit_tile *packet,
1609 const struct tile *ptile)
1610{
1611 const struct extra_type *presource;
1612 const struct terrain *pterrain;
1613
1614 if (!packet || !ptile) {
1615 return;
1616 }
1617 packet->tile = tile_index(ptile);
1618 packet->extras = *tile_extras(ptile);
1619
1620 presource = tile_resource(ptile);
1621 packet->resource = presource
1622 ? extra_number(presource)
1623 : extra_count();
1624
1625 pterrain = tile_terrain(ptile);
1626 packet->terrain = pterrain
1627 ? terrain_number(pterrain)
1628 : terrain_count();
1629 if (ptile->extras_owner != NULL) {
1630 packet->eowner = player_number(ptile->extras_owner);
1631 } else {
1632 packet->eowner
1633 = has_capability("ownernull16", client.conn.capability)
1635 }
1636
1637 if (ptile->label == NULL) {
1638 packet->label[0] = '\0';
1639 } else {
1640 sz_strlcpy(packet->label, ptile->label);
1641 }
1642}
1643
1644/************************************************************************/
1648static void paste_tile(struct edit_buffer *ebuf,
1649 const struct tile *vtile,
1650 const struct tile *ptile_dest)
1651{
1652 struct connection *my_conn = &client.conn;
1654 struct city *vcity;
1655 int value, owner, tile;
1656 bool send_edit_tile = FALSE;
1657
1658 if (!ebuf || !vtile || !ptile_dest) {
1659 return;
1660 }
1661
1663
1665
1667 switch (type) {
1668 case EBT_TERRAIN:
1669 if (!tile_terrain(vtile)) {
1670 continue;
1671 }
1674 break;
1675 case EBT_RESOURCE:
1677 if (tile_has_extra(vtile, pextra)) {
1678 BV_SET(tile_packet.extras, extra_index(pextra));
1680 }
1682 break;
1683 case EBT_SPECIAL:
1685 if (tile_has_extra(vtile, pextra)) {
1686 BV_SET(tile_packet.extras, extra_index(pextra));
1688 }
1690 break;
1691 case EBT_BASE:
1692 extra_type_iterate(pextra) {
1693 if (tile_has_extra(vtile, pextra)
1694 && is_extra_caused_by(pextra, EC_BASE)) {
1695 BV_SET(tile_packet.extras, extra_index(pextra));
1697 }
1699 break;
1700 case EBT_ROAD:
1701 extra_type_iterate(pextra) {
1702 if (tile_has_extra(vtile, pextra)
1703 && is_extra_caused_by(pextra, EC_ROAD)) {
1704 BV_SET(tile_packet.extras, extra_index(pextra));
1706 }
1708 break;
1709 case EBT_UNIT:
1710 unit_list_iterate(vtile->units, vunit) {
1715 break;
1716 case EBT_CITY:
1718 if (!vcity) {
1719 continue;
1720 }
1722 value = city_size_get(vcity);
1724 break;
1725 default:
1726 break;
1727 }
1729
1730 if (send_edit_tile) {
1732 }
1733}
1734
1735/************************************************************************/
1738void edit_buffer_paste(struct edit_buffer *ebuf, const struct tile *dest)
1739{
1740 struct connection *my_conn = &client.conn;
1741 const struct tile *origin, *ptile;
1742 int dx, dy;
1743
1744 if (!ebuf || !dest) {
1745 return;
1746 }
1747
1748 /* Calculate vector. */
1749 origin = edit_buffer_get_origin(ebuf);
1750 fc_assert_ret(origin != NULL);
1751 map_distance_vector(&dx, &dy, origin, dest);
1752
1754 tile_list_iterate(ebuf->vtiles, vtile) {
1755 int virt_x, virt_y;
1756
1758 ptile = map_pos_to_tile(&(wld.map), virt_x + dx, virt_y + dy);
1759 if (!ptile) {
1760 continue;
1761 }
1762 paste_tile(ebuf, vtile, ptile);
1765}
1766
1767/************************************************************************/
1771{
1772 if (!editor) {
1773 return NULL;
1774 }
1775 return editor->copybuf;
1776}
1777
1778/************************************************************************/
1782 enum editor_tool_mode etm)
1783{
1784 bool value_erase;
1785
1787
1788 switch (etm) {
1789 case ETM_PAINT:
1790 return _("Paint");
1791 break;
1792 case ETM_ERASE:
1793 if (value_erase) {
1794 return _("Erase Value");
1795 } else {
1796 return _("Erase");
1797 }
1798 break;
1799 case ETM_COPY:
1800 return _("Copy");
1801 break;
1802 case ETM_PASTE:
1803 return _("Paste");
1804 break;
1805 default:
1806 log_error("Unrecognized editor tool mode %d "
1807 "in editor_tool_get_mode_name().", etm);
1808 break;
1809 }
1810
1811 return "";
1812}
1813
1814/************************************************************************/
1819{
1820 switch (etm) {
1821 case ETM_ERASE:
1822 return _("Toggle erase mode.\nShortcut: shift-d");
1823 break;
1824 case ETM_COPY:
1825 return _("Toggle copy mode.\nShortcut: shift-c");
1826 break;
1827 case ETM_PASTE:
1828 return _("Toggle paste mode.\nShortcut: shift-v");
1829 break;
1830 default:
1831 break;
1832 }
1833
1834 return NULL;
1835}
1836
1837/************************************************************************/
1841{
1842 const struct editor_sprites *sprites;
1843
1844 sprites = get_editor_sprites(tileset);
1845 if (!sprites) {
1846 return NULL;
1847 }
1848
1849 switch (etm) {
1850 case ETM_PAINT:
1851 return sprites->brush;
1852 break;
1853 case ETM_ERASE:
1854 return sprites->erase;
1855 break;
1856 case ETM_COPY:
1857 return sprites->copy;
1858 break;
1859 case ETM_PASTE:
1860 return sprites->paste;
1861 break;
1862 default:
1863 break;
1864 }
1865
1866 return NULL;
1867}
1868
1869/************************************************************************/
1874 char *buf, int buflen)
1875{
1876 int ret, total;
1877 const char *fmt;
1878
1879 if (!buf || buflen < 1) {
1880 return 0;
1881 }
1882
1883 ret = fc_strlcpy(buf, _("Buffer empty."), buflen);
1884 if (!ebuf || !ebuf->vtiles) {
1885 return ret;
1886 }
1887
1888 total = tile_list_size(ebuf->vtiles);
1889 if (total > 0) {
1890 fmt = PL_("%d tile copied.", "%d tiles copied.", total);
1891 ret = fc_snprintf(buf, buflen, fmt, total);
1892 }
1893
1894 return ret;
1895}
1896
1897/************************************************************************/
1902 const struct tile *ptile)
1903{
1904 if (!ebuf) {
1905 return;
1906 }
1907 ebuf->origin = ptile;
1908}
1909
1910/************************************************************************/
1913const struct tile *edit_buffer_get_origin(const struct edit_buffer *ebuf)
1914{
1915 if (!ebuf) {
1916 return NULL;
1917 }
1918 return ebuf->origin;
1919}
1920
1921/************************************************************************/
1925{
1926 if (!ebuf) {
1927 return FALSE;
1928 }
1929 return ebuf->type_flags & type;
1930}
1931
1932/************************************************************************/
1938{
1939 int count;
1940 const struct tile *origin, *center;
1941 int dx, dy, cx, cy;
1942 int xsum = 0, ysum = 0;
1943
1944 if (!editor || !editor->selected_tile_table) {
1945 return NULL;
1946 }
1947
1949 if (count < 1) {
1950 return NULL;
1951 }
1952
1953 origin = map_pos_to_tile(&(wld.map), 0, 0);
1955 map_distance_vector(&dx, &dy, origin, ptile);
1956 xsum += dx;
1957 ysum += dy;
1959
1960 cx = xsum / count;
1961 cy = ysum / count;
1962 center = map_pos_to_tile(&(wld.map), cx, cy);
1963
1964 return center;
1965}
Base_type_id base_count(void)
Definition base.c:109
#define BV_SET(bv, bit)
Definition bitvector.h:81
struct canvas int int canvas_y
Definition canvas_g.h:43
struct canvas int canvas_x
Definition canvas_g.h:43
bool has_capability(const char *cap, const char *capstr)
Definition capability.c:77
bool city_has_building(const struct city *pcity, const struct impr_type *pimprove)
Definition city.c:1240
const char * city_name_get(const struct city *pcity)
Definition city.c:1137
struct city * create_city_virtual(struct player *pplayer, struct tile *ptile, const char *name)
Definition city.c:3430
void city_size_set(struct city *pcity, citizens size)
Definition city.c:1180
void city_add_improvement(struct city *pcity, const struct impr_type *pimprove)
Definition city.c:3357
static citizens city_size_get(const struct city *pcity)
Definition city.h:569
#define city_owner(_pcity_)
Definition city.h:563
bool client_is_global_observer(void)
int client_player_number(void)
struct civclient client
bool client_has_player(void)
#define client_player()
char * incite_cost
Definition comments.c:75
bool can_conn_edit(const struct connection *pconn)
Definition connection.c:511
void connection_do_buffer(struct connection *pc)
Definition connection.c:324
void connection_do_unbuffer(struct connection *pc)
Definition connection.c:336
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 * punit
Definition dialogs_g.h:74
int int id
Definition editgui_g.h:28
int edit_buffer_get_status_string(const struct edit_buffer *ebuf, char *buf, int buflen)
Definition editor.c:1873
bool editor_is_active(void)
Definition editor.c:347
void editor_selection_remove(const struct tile *ptile)
Definition editor.c:1107
bool edit_buffer_has_type(const struct edit_buffer *ebuf, int type)
Definition editor.c:1924
int editor_tool_get_size(enum editor_tool_type ett)
Definition editor.c:1219
static void paste_tile(struct edit_buffer *ebuf, const struct tile *vtile, const struct tile *ptile_dest)
Definition editor.c:1648
void editor_set_tool(enum editor_tool_type ett)
Definition editor.c:271
void editor_mouse_button_press(int canvas_x, int canvas_y, int button, int modifiers)
Definition editor.c:662
void editor_set_current_tile(const struct tile *ptile)
Definition editor.c:1017
void editor_mouse_move(int canvas_x, int canvas_y, int modifiers)
Definition editor.c:867
enum editor_tool_mode editor_tool_get_mode(enum editor_tool_type ett)
Definition editor.c:336
bool editor_tool_has_value_erase(enum editor_tool_type ett)
Definition editor.c:1378
void editor_tool_set_count(enum editor_tool_type ett, int count)
Definition editor.c:1264
void editor_tool_toggle_mode(enum editor_tool_type ett, enum editor_tool_mode etm)
Definition editor.c:1042
static void tool_init(enum editor_tool_type ett, const char *name, int flags, const char *tooltip)
Definition editor.c:152
void editor_selection_add(const struct tile *ptile)
Definition editor.c:1096
const char * editor_tool_get_value_name(enum editor_tool_type emt, int value)
Definition editor.c:1173
void editor_notify_edit_finished(void)
Definition editor.c:898
void editor_init(void)
Definition editor.c:194
int editor_tool_get_value(enum editor_tool_type ett)
Definition editor.c:410
static void editor_end_selection_rectangle(int canvas_x, int canvas_y)
Definition editor.c:723
struct edit_buffer * edit_buffer_new(int type_flags)
Definition editor.c:1434
struct edit_buffer * editor_get_copy_buffer(void)
Definition editor.c:1770
void editor_tool_set_applied_player(enum editor_tool_type ett, int player_no)
Definition editor.c:1353
const char * editor_tool_get_mode_name(enum editor_tool_type ett, enum editor_tool_mode etm)
Definition editor.c:1781
void editor_clear(void)
Definition editor.c:247
void editor_tool_cycle_mode(enum editor_tool_type ett)
Definition editor.c:1059
static void editor_grab_applied_player(const struct tile *ptile)
Definition editor.c:466
int editor_tool_get_count(enum editor_tool_type ett)
Definition editor.c:1253
const struct tile * edit_buffer_get_origin(const struct edit_buffer *ebuf)
Definition editor.c:1913
void edit_buffer_copy(struct edit_buffer *ebuf, const struct tile *ptile)
Definition editor.c:1506
int editor_selection_count(void)
Definition editor.c:1389
void editor_tool_set_size(enum editor_tool_type ett, int size)
Definition editor.c:1230
const char * editor_get_mode_tooltip(enum editor_tool_mode etm)
Definition editor.c:1818
bool editor_tool_is_usable(enum editor_tool_type ett)
Definition editor.c:360
enum editor_tool_type editor_get_tool(void)
Definition editor.c:287
bool editor_tool_has_applied_player(enum editor_tool_type ett)
Definition editor.c:1366
bool editor_tool_has_size(enum editor_tool_type ett)
Definition editor.c:1208
void edit_buffer_clear(struct edit_buffer *ebuf)
Definition editor.c:1471
selection_modes
Definition editor.c:48
@ SELECTION_MODE_ADD
Definition editor.c:50
@ SELECTION_MODE_REMOVE
Definition editor.c:51
@ SELECTION_MODE_NEW
Definition editor.c:49
void editor_tool_set_value(enum editor_tool_type ett, int value)
Definition editor.c:398
bool editor_tool_has_value(enum editor_tool_type ett)
Definition editor.c:386
static void popup_properties(struct tile *ptile)
Definition editor.c:632
const char * editor_tool_get_tooltip(enum editor_tool_type ett)
Definition editor.c:1328
void editor_selection_clear(void)
Definition editor.c:1085
void editor_mouse_button_release(int canvas_x, int canvas_y, int button, int modifiers)
Definition editor.c:799
static void editor_grab_tool(const struct tile *ptile)
Definition editor.c:498
static bool tile_really_has_any_specials(const struct tile *ptile)
Definition editor.c:447
void edit_buffer_copy_square(struct edit_buffer *ebuf, const struct tile *center, int radius)
Definition editor.c:1489
static void editor_start_selection_rectangle(int canvas_x, int canvas_y)
Definition editor.c:423
struct sprite * editor_tool_get_sprite(enum editor_tool_type ett)
Definition editor.c:1276
const struct tile * editor_get_current_tile(void)
Definition editor.c:1029
void editor_apply_tool_to_selection(void)
Definition editor.c:1129
void editor_apply_tool(const struct tile *ptile, bool part_of_selection)
Definition editor.c:910
bool editor_tile_is_selected(const struct tile *ptile)
Definition editor.c:1118
void edit_buffer_set_origin(struct edit_buffer *ebuf, const struct tile *ptile)
Definition editor.c:1901
void editor_free(void)
Definition editor.c:258
static bool can_edit_tile_properties(struct tile *ptile)
Definition editor.c:622
void edit_buffer_paste(struct edit_buffer *ebuf, const struct tile *dest)
Definition editor.c:1738
const struct tile * editor_get_selection_center(void)
Definition editor.c:1937
editor_tool_flags
Definition editor.c:54
@ ETF_NO_FLAGS
Definition editor.c:55
@ ETF_HAS_APPLIED_PLAYER
Definition editor.c:59
@ ETF_HAS_SIZE
Definition editor.c:57
@ ETF_HAS_VALUE_ERASE
Definition editor.c:60
@ ETF_HAS_COUNT
Definition editor.c:58
@ ETF_HAS_VALUE
Definition editor.c:56
bool editor_tool_has_mode(enum editor_tool_type ett, enum editor_tool_mode etm)
Definition editor.c:314
struct unit * editor_unit_virtual_create(void)
Definition editor.c:1406
static void editor_draw_selrect(void)
Definition editor.c:781
void editor_ruleset_changed(void)
Definition editor.c:181
int editor_tool_get_applied_player(enum editor_tool_type ett)
Definition editor.c:1342
bool editor_tool_has_count(enum editor_tool_type ett)
Definition editor.c:1242
struct sprite * editor_get_mode_sprite(enum editor_tool_mode etm)
Definition editor.c:1840
static void editor_resize_selection_rectangle(int canvas_x, int canvas_y)
Definition editor.c:827
static void fill_tile_edit_packet(struct packet_edit_tile *packet, const struct tile *ptile)
Definition editor.c:1608
const char * editor_tool_get_name(enum editor_tool_type ett)
Definition editor.c:1160
static void tool_set_init_value(enum editor_tool_type ett)
Definition editor.c:106
static struct editor_state * editor
Definition editor.c:101
void edit_buffer_free(struct edit_buffer *ebuf)
Definition editor.c:1452
void editor_tool_set_mode(enum editor_tool_type ett, enum editor_tool_mode etm)
Definition editor.c:299
editor_tool_mode
Definition editor.h:52
@ ETM_PASTE
Definition editor.h:56
@ NUM_EDITOR_TOOL_MODES
Definition editor.h:58
@ ETM_ERASE
Definition editor.h:54
@ ETM_PAINT
Definition editor.h:53
@ ETM_COPY
Definition editor.h:55
@ EBT_RESOURCE
Definition editor.h:157
@ EBT_CITY
Definition editor.h:162
@ EBT_UNIT
Definition editor.h:161
@ EBT_BASE
Definition editor.h:159
@ EBT_ALL
Definition editor.h:165
@ EBT_ROAD
Definition editor.h:160
@ EBT_TERRAIN
Definition editor.h:156
@ EBT_SPECIAL
Definition editor.h:158
#define edit_buffer_type_iterate_end
Definition editor.h:195
#define edit_buffer_type_iterate(ARG_ebuf, NAME_type)
Definition editor.h:184
@ MOUSE_BUTTON_LEFT
Definition editor.h:126
@ MOUSE_BUTTON_RIGHT
Definition editor.h:128
@ MOUSE_BUTTON_MIDDLE
Definition editor.h:127
@ NUM_OBJTYPES
Definition editor.h:33
@ EKM_CTRL
Definition editor.h:120
@ EKM_SHIFT
Definition editor.h:118
@ EKM_ALT
Definition editor.h:119
@ EKM_NONE
Definition editor.h:117
editor_tool_type
Definition editor.h:36
@ ETT_ROAD
Definition editor.h:40
@ ETT_TERRAIN_SPECIAL
Definition editor.h:39
@ ETT_UNIT
Definition editor.h:42
@ ETT_VISION
Definition editor.h:44
@ ETT_STARTPOS
Definition editor.h:46
@ NUM_EDITOR_TOOL_TYPES
Definition editor.h:49
@ ETT_CITY
Definition editor.h:43
@ ETT_COPYPASTE
Definition editor.h:47
@ ETT_TERRAIN_RESOURCE
Definition editor.h:38
@ ETT_MILITARY_BASE
Definition editor.h:41
@ ETT_TERRAIN
Definition editor.h:37
int extra_number(const struct extra_type *pextra)
Definition extras.c:161
struct extra_type * extra_by_number(int id)
Definition extras.c:183
int extra_count(void)
Definition extras.c:153
const char * extra_name_translation(const struct extra_type *pextra)
Definition extras.c:194
#define extra_type_iterate(_p)
Definition extras.h:315
#define extra_type_iterate_end
Definition extras.h:321
#define is_extra_caused_by(e, c)
Definition extras.h:203
#define extra_index(_e_)
Definition extras.h:183
#define extra_type_by_cause_iterate_end
Definition extras.h:339
#define extra_type_by_cause_iterate(_cause, _extra)
Definition extras.h:333
#define EC_SPECIAL
Definition fc_types.h:1114
#define MAX_EXTRA_TYPES
Definition fc_types.h:50
#define MAX_LEN_NAME
Definition fc_types.h:66
#define PL_(String1, String2, n)
Definition fcintl.h:71
#define _(String)
Definition fcintl.h:67
struct civ_game game
Definition game.c:62
struct world wld
Definition game.c:63
struct city * owner
Definition citydlg.c:226
void editgui_popup_properties(const struct tile_list *tiles, int objtype)
Definition editgui.c:1877
void editgui_refresh(void)
Definition editgui.c:1798
void flush_dirty(void)
Definition mapview.c:468
void draw_selection_rectangle(int canvas_x, int canvas_y, int w, int h)
Definition mapview.c:749
const char * tooltip
Definition repodlgs.c:1315
GType type
Definition repodlgs.c:1313
bool is_improvement(const struct impr_type *pimprove)
#define improvement_iterate_end
#define improvement_iterate(_p)
const char * name
Definition inputfile.c:127
#define fc_assert_ret(condition)
Definition log.h:191
#define fc_assert(condition)
Definition log.h:176
#define log_error(message,...)
Definition log.h:103
struct tile * map_pos_to_tile(const struct civ_map *nmap, int map_x, int map_y)
Definition map.c:419
void map_distance_vector(int *dx, int *dy, const struct tile *tile0, const struct tile *tile1)
Definition map.c:1073
#define square_iterate(nmap, center_tile, radius, tile_itr)
Definition map.h:391
#define square_iterate_end
Definition map.h:394
#define MAP_TILE_OWNER_NULL
Definition map.h:602
#define index_to_map_pos(pmap_x, pmap_y, mindex)
Definition map.h:233
void recenter_button_pressed(int canvas_x, int canvas_y)
void update_map_canvas_visible(void)
struct view mapview
struct tile * canvas_pos_to_tile(float canvas_x, float canvas_y, float zoom)
void update_map_canvas(int canvas_x, int canvas_y, int width, int height)
void refresh_tile_mapcanvas(struct tile *ptile, bool full_refresh, bool write_to_screen)
#define gui_rect_iterate_end
#define gui_rect_iterate(GRI_x0, GRI_y0, GRI_width, GRI_height, _t, _e, _c, _zoom)
#define fc_calloc(n, esz)
Definition mem.h:38
int dsend_packet_edit_city_create(struct connection *pc, int owner, int tile, int size, int tag)
int dsend_packet_edit_startpos(struct connection *pc, int id, bool removal, int tag)
int dsend_packet_edit_unit_remove(struct connection *pc, int owner, int tile, Unit_type_id type, int count)
int dsend_packet_edit_unit_create(struct connection *pc, int owner, int tile, Unit_type_id type, int count, int tag)
int dsend_packet_edit_tile_extra(struct connection *pc, int tile, int extra_type_id, bool removal, int eowner, int size)
int send_packet_edit_tile(struct connection *pc, const struct packet_edit_tile *packet)
int send_packet_edit_check_tiles(struct connection *pc)
int dsend_packet_edit_tile_terrain(struct connection *pc, int tile, Terrain_type_id terrain, int size)
int dsend_packet_edit_city_remove(struct connection *pc, int id)
int dsend_packet_edit_player_vision(struct connection *pc, int player, int tile, bool known, int size)
struct player * player_by_number(const int player_id)
Definition player.c:849
int player_number(const struct player *pplayer)
Definition player.c:837
Road_type_id road_count(void)
Definition road.c:50
#define MAX_UINT8
Definition shared.h:83
#define MAX(x, y)
Definition shared.h:54
size_t size
Definition specvec.h:72
Definition city.h:320
int id
Definition city.h:326
struct tile * tile
Definition city.h:322
struct packet_ruleset_control control
Definition game.h:83
struct connection conn
Definition client_main.h:96
char capability[MAX_LEN_CAPSTR]
Definition connection.h:171
const struct tile * origin
Definition editor.c:66
struct tile_list * vtiles
Definition editor.c:65
int type_flags
Definition editor.c:64
struct sprite * terrain
Definition tilespec.h:347
struct sprite * road
Definition tilespec.h:355
struct sprite * city
Definition tilespec.h:351
struct sprite * terrain_special
Definition tilespec.h:349
struct sprite * vision
Definition tilespec.h:352
struct sprite * terrain_resource
Definition tilespec.h:348
struct sprite * copypaste
Definition tilespec.h:345
struct sprite * brush
Definition tilespec.h:342
struct sprite * startpos
Definition tilespec.h:346
struct sprite * military_base
Definition tilespec.h:356
struct sprite * copy
Definition tilespec.h:343
struct sprite * erase
Definition tilespec.h:340
struct sprite * paste
Definition tilespec.h:344
struct sprite * unit
Definition tilespec.h:350
struct tile_hash * selected_tile_table
Definition editor.c:97
bool selrect_active
Definition editor.c:87
int selrect_x
Definition editor.c:90
enum selection_modes selection_mode
Definition editor.c:95
struct editor_tool tools[NUM_EDITOR_TOOL_TYPES]
Definition editor.c:82
struct edit_buffer * copybuf
Definition editor.c:98
bool tool_active
Definition editor.c:85
int selrect_start_y
Definition editor.c:89
int selrect_width
Definition editor.c:92
int selrect_height
Definition editor.c:93
int selrect_start_x
Definition editor.c:88
enum editor_tool_type tool
Definition editor.c:81
int selrect_y
Definition editor.c:91
const struct tile * current_tile
Definition editor.c:84
int size
Definition editor.c:72
int flags
Definition editor.c:70
int count
Definition editor.c:73
enum editor_tool_mode mode
Definition editor.c:71
const char * tooltip
Definition editor.c:77
const char * name
Definition editor.c:75
int applied_player_no
Definition editor.c:74
int value
Definition editor.c:76
bv_extra_flags flags
Definition extras.h:132
Resource_type_id resource
char label[MAX_LEN_NAME]
Terrain_type_id terrain
Definition tile.h:50
char * label
Definition tile.h:65
struct unit_list * units
Definition tile.h:58
struct player * extras_owner
Definition tile.h:63
Definition unit.h:138
int hp
Definition unit.h:151
int homecity
Definition unit.h:146
int veteran
Definition unit.h:152
float gui_x0
float gui_y0
struct civ_map map
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:974
size_t fc_strlcpy(char *dest, const char *src, size_t n)
Definition support.c:791
#define sz_strlcpy(dest, src)
Definition support.h:195
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
Terrain_type_id terrain_count(void)
Definition terrain.c:118
const char * terrain_name_translation(const struct terrain *pterrain)
Definition terrain.c:238
struct terrain * terrain_by_number(const Terrain_type_id type)
Definition terrain.c:156
Terrain_type_id terrain_number(const struct terrain *pterrain)
Definition terrain.c:147
void tile_add_extra(struct tile *ptile, const struct extra_type *pextra)
Definition tile.c:955
void tile_set_terrain(struct tile *ptile, struct terrain *pterrain)
Definition tile.c:124
void tile_virtual_destroy(struct tile *vtile)
Definition tile.c:1033
struct tile * tile_virtual_new(const struct tile *ptile)
Definition tile.c:981
void tile_set_resource(struct tile *ptile, struct extra_type *presource)
Definition tile.c:349
enum known_type tile_get_known(const struct tile *ptile, const struct player *pplayer)
Definition tile.c:392
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
void tile_set_worked(struct tile *ptile, struct city *pcity)
Definition tile.c:106
#define tile_index(_pt_)
Definition tile.h:88
#define tile_hash_iterate(hash, ptile)
Definition tile.h:82
#define tile_resource(_tile)
Definition tile.h:102
@ TILE_UNKNOWN
Definition tile.h:36
#define tile_list_iterate(tile_list, ptile)
Definition tile.h:73
#define tile_terrain(_tile)
Definition tile.h:114
#define tile_hash_iterate_end
Definition tile.h:84
#define tile_list_iterate_end
Definition tile.h:75
static const bv_extras * tile_extras(const struct tile *ptile)
Definition tile.h:124
#define tile_has_extra(ptile, pextra)
Definition tile.h:151
#define tile_owner(_tile)
Definition tile.h:96
int tileset_tile_height(const struct tileset *t)
Definition tilespec.c:765
int tileset_tile_width(const struct tileset *t)
Definition tilespec.c:753
const struct editor_sprites * get_editor_sprites(const struct tileset *t)
Definition tilespec.c:6950
struct unit * unit_virtual_create(struct player *pplayer, struct city *pcity, const struct unit_type *punittype, int veteran_level)
Definition unit.c:1632
bool unit_transported(const struct unit *pcargo)
Definition unit.c:2433
#define unit_owner(_pu)
Definition unit.h:396
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_end
Definition unitlist.h:33
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
enum unit_move_type utype_move_type(const struct unit_type *punittype)
Definition unittype.c:1551
Unit_type_id utype_count(void)
Definition unittype.c:80
struct unit_class * unit_class_get(const struct unit *punit)
Definition unittype.c:2499
struct unit_type * utype_by_number(const Unit_type_id id)
Definition unittype.c:112
Unit_type_id utype_number(const struct unit_type *punittype)
Definition unittype.c:100
const char * utype_name_translation(const struct unit_type *punittype)
Definition unittype.c:1560
static bool uclass_has_flag(const struct unit_class *punitclass, enum unit_class_flag_id flag)
Definition unittype.h:766
float mouse_zoom
Definition zoom.c:28
float map_zoom
Definition zoom.c:25