Freeciv-3.3
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 "fcintl.h"
24#include "log.h"
25#include "support.h"
26
27/* common */
28#include "game.h"
29#include "map.h"
30#include "movement.h"
31#include "packets.h"
32
33/* client */
34#include "client_main.h"
35#include "climap.h"
36#include "control.h"
37#include "editor.h"
38#include "mapctrl_common.h"
39#include "tilespec.h"
40#include "zoom.h"
41
42/* client/include */
43#include "editgui_g.h"
44#include "mapview_g.h"
45
46
52
61
65 const struct tile *origin;
66};
67
69 int flags;
71 int size;
72 int count;
74 const char *name;
75 int value;
76 const char *tooltip;
77};
78
99
100static struct editor_state *editor = NULL;
101
102/************************************************************************/
106{
107 struct editor_tool *tool = editor->tools + ett;
108
110 || ett == ETT_ROAD
113 struct extra_type *first = NULL;
114
115 extra_type_iterate(pextra) {
116 if (ett == ETT_ROAD) {
117 if (is_extra_caused_by(pextra, EC_ROAD)) {
118 first = pextra;
119 break;
120 }
121 } else if (ett == ETT_MILITARY_BASE) {
122 if (is_extra_caused_by(pextra, EC_BASE)) {
123 first = pextra;
124 break;
125 }
126 } else if (ett == ETT_TERRAIN_RESOURCE) {
127 if (is_extra_caused_by(pextra, EC_RESOURCE)) {
128 first = pextra;
129 break;
130 }
131 } else {
132 /* Considers extras that are neither bases or roads, specials */
133 first = pextra;
134 break;
135 }
137
138 if (first != NULL) {
139 tool->value = extra_index(first);
140 } else {
141 tool->value = 0;
142 }
143 } else {
144 tool->value = 0;
145 }
146}
147
148/************************************************************************/
151static void tool_init(enum editor_tool_type ett, const char *name,
152 int flags, const char *tooltip)
153{
154 struct editor_tool *tool;
155
156 if (!editor || !(ett < NUM_EDITOR_TOOL_TYPES)) {
157 return;
158 }
159
160 tool = editor->tools + ett;
161
162 if (ett == ETT_COPYPASTE) {
163 tool->mode = ETM_COPY;
164 } else {
165 tool->mode = ETM_PAINT;
166 }
167 tool->name = name;
168 tool->flags = flags;
169 tool->tooltip = tooltip;
170 tool->size = 1;
171 tool->count = 1;
172 tool->applied_player_no = 0;
173
175}
176
177/************************************************************************/
181{
182 int t;
183
184 for (t = 0; t < NUM_EDITOR_TOOL_TYPES; t++) {
186 }
187}
188
189/************************************************************************/
193void editor_init(void)
194{
196
197 editor = fc_calloc(1, sizeof(struct editor_state));
198
199 tool_init(ETT_TERRAIN, _("Terrain"),
201 _("Change tile terrain.\nShortcut: t\n"
202 "Select terrain type: shift+t or right-click here."));
203 tool_init(ETT_TERRAIN_RESOURCE, _("Terrain Resource"),
205 _("Change tile terrain resources.\nShortcut: r\n"
206 "Select resource type: shift+r or right-click here."));
207 tool_init(ETT_TERRAIN_SPECIAL, _("Terrain Special"), ETF_HAS_VALUE
209 _("Modify tile specials.\nShortcut: s\n"
210 "Select special type: shift+s or right-click here."));
213 _("Modify roads on tile.\nShortcut: p\n"
214 "Select road type: shift+p or right-click here."));
215 tool_init(ETT_MILITARY_BASE, _("Military Base"), ETF_HAS_VALUE
217 _("Create a military base.\nShortcut: m\n"
218 "Select base type: shift+m or right-click here."));
221 _("Create unit.\nShortcut: u\nSelect unit "
222 "type: shift+u or right-click here."));
224 _("Create city.\nShortcut: c"));
226 _("Modify player's tile knowledge.\nShortcut: v"));
227 tool_init(ETT_STARTPOS, _("Start Position"), ETF_NO_FLAGS,
228 _("Place a start position which allows any nation to "
229 "start at the tile. To allow only certain nations to "
230 "start there, middle click on the start position on "
231 "the map and use the property editor.\nShortcut: b"));
232
233 tool_init(ETT_COPYPASTE, _("Copy/Paste"), ETF_HAS_SIZE,
234 _("Copy and paste tiles.\n"
235 "Shortcut for copy mode: shift-c\n"
236 "Shoftcut for paste mode: shift-v"));
238
241}
242
243/************************************************************************/
253
254/************************************************************************/
257void editor_free(void)
258{
259 if (editor != NULL) {
262 free(editor);
263 editor = NULL;
264 }
265}
266
267/************************************************************************/
271{
272 if (editor == NULL) {
273 return;
274 }
275
276 if (!(ett < NUM_EDITOR_TOOL_TYPES)) {
277 return;
278 }
279
280 editor->tool = ett;
281}
282
283/************************************************************************/
287{
288 if (editor == NULL) {
290 }
291
292 return editor->tool;
293}
294
295/************************************************************************/
300{
301 if (editor == NULL || !(ett < NUM_EDITOR_TOOL_TYPES)
304 return;
305 }
306
307 editor->tools[ett].mode = etm;
308}
309
310/************************************************************************/
315{
316 if (editor == NULL || !(ett < NUM_EDITOR_TOOL_TYPES)
317 || !(etm < NUM_EDITOR_TOOL_MODES)) {
318 return FALSE;
319 }
320
321 if (etm == ETM_COPY || etm == ETM_PASTE) {
322 return ett == ETT_COPYPASTE;
323 }
324
325 if (ett == ETT_COPYPASTE) {
326 return etm == ETM_COPY || etm == ETM_PASTE;
327 }
328
329 return TRUE;
330}
331
332/************************************************************************/
336{
337 if (editor == NULL || !(ett < NUM_EDITOR_TOOL_TYPES)) {
339 }
340 return editor->tools[ett].mode;
341}
342
343/************************************************************************/
347{
348 return can_conn_edit(&client.conn);
349}
350
351/************************************************************************/
360{
361 if (!editor || !(ett < NUM_EDITOR_TOOL_TYPES)) {
362 return FALSE;
363 }
364
365 switch (ett) {
367 return base_count() > 0;
368 case ETT_ROAD:
369 return road_count() > 0;
372 case ETT_UNIT:
373 return utype_count() > 0;
374 default:
375 break;
376 }
377
378 return TRUE;
379}
380
381/************************************************************************/
386{
387 if (!editor || !(ett < NUM_EDITOR_TOOL_TYPES)) {
388 return FALSE;
389 }
391}
392
393/************************************************************************/
398{
399 if (!editor || !(ett < NUM_EDITOR_TOOL_TYPES)
401 return;
402 }
404}
405
406/************************************************************************/
410{
411 if (!editor || !(ett < NUM_EDITOR_TOOL_TYPES)
413 return 0;
414 }
415
416 return editor->tools[ett].value;
417}
418
419/************************************************************************/
440
441/************************************************************************/
446static inline bool tile_really_has_any_specials(const struct tile *ptile)
447{
448 if (!ptile) {
449 return FALSE;
450 }
451
453 if (tile_has_extra(ptile, pextra)) {
454 return TRUE;
455 }
457
458 return FALSE;
459}
460
461/************************************************************************/
465static void editor_grab_applied_player(const struct tile *ptile)
466{
467 int apno = -1;
468
469 if (!editor || !ptile) {
470 return;
471 }
472
474 && tile_get_known(ptile, client_player()) == TILE_UNKNOWN) {
475 return;
476 }
477
478 if (tile_city(ptile) != NULL) {
480 } else if (unit_list_size(ptile->units) > 0) {
481 struct unit *punit = unit_list_get(ptile->units, 0);
482
484 } else if (tile_owner(ptile) != NULL) {
485 apno = player_number(tile_owner(ptile));
486 }
487
488 if (player_by_number(apno) != NULL) {
491 }
492}
493
494/************************************************************************/
497static void editor_grab_tool(const struct tile *ptile)
498{
499 int ett = -1, value = 0;
500 struct extra_type *first_base = NULL;
501 struct extra_type *first_road = NULL;
503
504 if (!editor) {
505 return;
506 }
507
508 if (!ptile) {
509 return;
510 }
511
513 if (tile_has_extra(ptile, pextra)) {
514 first_base = pextra;
515 break;
516 }
518
520 if (tile_has_extra(ptile, pextra)) {
521 first_road = pextra;
522 break;
523 }
525
527 if (tile_has_extra(ptile, pextra)) {
528 first_resource = pextra;
529 break;
530 }
532
534 && tile_get_known(ptile, client_player()) == TILE_UNKNOWN) {
535 ett = ETT_VISION;
536
537 } else if (tile_city(ptile)) {
538 ett = ETT_CITY;
539
540 } else if (unit_list_size(ptile->units) > 0) {
541 int max_score = 0, score;
542 struct unit *grabbed_punit = NULL;
543
544 unit_list_iterate(ptile->units, punit) {
546 score = 5;
548 score = 4;
549 } else if (utype_move_type(unit_type_get(punit)) == UMT_SEA) {
550 score = 3;
551 } else {
552 score = 2;
553 }
554 if (unit_transported(punit)) {
555 score = 1;
556 }
557
558 if (score > max_score) {
559 max_score = score;
561 }
563
564 if (grabbed_punit) {
565 ett = ETT_UNIT;
567 }
568 } else if (first_base != NULL) {
570 value = extra_index(first_base);
571
572 } else if (first_road != NULL) {
573 ett = ETT_ROAD;
574 value = extra_index(first_road);
575
576 } else if (tile_really_has_any_specials(ptile)) {
578 int count = 0, i;
579 struct extra_type *special = NULL;
580
582 specials_array[count++] = s;
584
585 /* Grab specials in reverse order of enum tile_special_type. */
586
587 for (i = count - 1; i >= 0; i--) {
588 if (tile_has_extra(ptile, specials_array[i])) {
589 special = specials_array[i];
590 break;
591 }
592 }
593
594 if (special != NULL) {
596 value = extra_index(special);
597 }
598 } else if (first_resource != NULL) {
601
602 } else if (tile_terrain(ptile) != NULL) {
604 value = terrain_number(tile_terrain(ptile));
605 }
606
607 if (ett < 0) {
608 return;
609 }
610
614 }
616}
617
618/************************************************************************/
621static inline bool can_edit_tile_properties(struct tile *ptile)
622{
623 return ptile != NULL;
624}
625
626/************************************************************************/
631static void popup_properties(struct tile *ptile)
632{
633 struct tile_list *tiles;
634
635 if (!ptile) {
636 return;
637 }
638
639 tiles = tile_list_new();
640
641 if (editor_tile_is_selected(ptile)) {
645 }
647 } else {
648 if (can_edit_tile_properties(ptile)) {
649 tile_list_append(tiles, ptile);
650 }
651 }
652
654
655 tile_list_destroy(tiles);
656}
657
658/************************************************************************/
662 int button, int modifiers)
663{
664 struct tile *ptile;
665
666 if (editor == NULL) {
667 return;
668 }
669
671 if (ptile == NULL) {
672 return;
673 }
674
675 switch (button) {
676
678 if (modifiers == EKM_SHIFT) {
679 editor_grab_tool(ptile);
680 } else if (modifiers == EKM_CTRL) {
682 } else if (modifiers == EKM_NONE) {
684 editor_apply_tool(ptile, FALSE);
687 }
688 break;
689
691 if (modifiers == (EKM_ALT | EKM_CTRL)) {
692 popup_properties(ptile);
693 break;
694 }
695
696 if (modifiers == EKM_SHIFT) {
698 } else if (modifiers == EKM_ALT) {
700 } else if (modifiers == EKM_NONE) {
702 } else {
703 break;
704 }
706 break;
707
709 if (modifiers == EKM_NONE) {
710 popup_properties(ptile);
711 }
712 break;
713
714 default:
715 break;
716 }
717}
718
719/************************************************************************/
723{
724 int w, h;
725
726 if (!editor) {
727 return;
728 }
729
731
732 if (editor->selrect_width <= 0 || editor->selrect_height <= 0) {
733 struct tile *ptile;
734
736 if (ptile && editor->selection_mode == SELECTION_MODE_ADD) {
738 } else if (ptile && editor->selection_mode == SELECTION_MODE_REMOVE) {
740 } else {
742 return;
743 }
744
745 if (ptile) {
747 }
748
749 return;
750 }
751
755 ptile, pedge, pcorner, map_zoom) {
756 if (ptile == NULL) {
757 continue;
758 }
764 }
766
769
771 editor->selrect_y - h,
772 editor->selrect_width + 2 * w,
773 editor->selrect_height + 2 * h);
774 flush_dirty();
775}
776
777/************************************************************************/
780static void editor_draw_selrect(void)
781{
782 if (!editor) {
783 return;
784 }
785
787 && editor->selrect_height > 0) {
792 }
793}
794
795/************************************************************************/
799 int button, int modifiers)
800{
801 switch (button) {
802
806 break;
807
809 if (editor->selrect_active) {
811 }
812 break;
813
815 break;
816
817 default:
818 break;
819 }
820}
821
822/************************************************************************/
827{
828 int xl, yt, xr, yb;
829
832 xr = canvas_x;
833 } else {
834 xl = canvas_x;
836 }
837
840 yb = canvas_y;
841 } else {
842 yt = canvas_y;
844 }
845
846 /* Erase the previously drawn rectangle. */
848
849 if (xl == xr || yt == yb) {
852 return;
853 }
854
859
861}
862
863/************************************************************************/
867{
868 const struct tile *ptile, *old;
869
870 if (!editor) {
871 return;
872 }
873
876
877 if (!ptile) {
878 return;
879 }
880
881 if (editor->tool_active && old != NULL && old != ptile) {
882 editor_apply_tool(ptile, FALSE);
885 }
886
887 if (editor->selrect_active) {
889 }
890}
891
892/************************************************************************/
901
902/************************************************************************/
909void editor_apply_tool(const struct tile *ptile,
911{
914 int value, size, count, apno, tile, id;
915 bool erase;
916 struct connection *my_conn = &client.conn;
917
918 if (editor == NULL || ptile == NULL) {
919 return;
920 }
921
925 count = editor_tool_get_count(ett);
926 value = editor_tool_get_value(ett);
928
931 && tile_get_known(ptile, client_player()) == TILE_UNKNOWN) {
932 return;
933 }
934
936 && player_by_number(apno) == NULL) {
937 return;
938 }
939
940 if (ett == ETT_COPYPASTE) {
941 struct edit_buffer *ebuf;
943 if (etm == ETM_COPY) {
944 if (part_of_selection) {
945 edit_buffer_copy(ebuf, ptile);
946 } else {
950 }
951 } else if (etm == ETM_PAINT || etm == ETM_PASTE) {
952 edit_buffer_paste(ebuf, ptile);
953 }
954 return;
955 }
956
957 if (part_of_selection && ett != ETT_CITY) {
958 size = 1;
959 }
960
961 erase = (etm == ETM_ERASE);
962 tile = tile_index(ptile);
963
964 switch (ett) {
965
966 case ETT_TERRAIN:
967 dsend_packet_edit_tile_terrain(my_conn, tile, erase ? 0 : value, size);
968 break;
969
972 case ETT_ROAD:
975 break;
976
977 case ETT_UNIT:
978 if (erase) {
980 } else {
982 }
983 break;
984
985 case ETT_CITY:
986 if (erase) {
987 struct city *pcity = tile_city(ptile);
988 if (pcity != NULL) {
989 id = pcity->id;
991 }
992 } else {
994 }
995 break;
996
997 case ETT_VISION:
998 if (client_has_player()) {
1001 }
1002 break;
1003
1004 case ETT_STARTPOS:
1006 break;
1007
1008 default:
1009 break;
1010 }
1011}
1012
1013/************************************************************************/
1016void editor_set_current_tile(const struct tile *ptile)
1017{
1018 if (editor == NULL) {
1019 return;
1020 }
1021
1022 editor->current_tile = ptile;
1023}
1024
1025/************************************************************************/
1029{
1030 if (editor == NULL) {
1031 return NULL;
1032 }
1033
1034 return editor->current_tile;
1035}
1036
1037/************************************************************************/
1042 enum editor_tool_mode etm)
1043{
1044 if (!editor_tool_has_mode(ett, etm)) {
1045 return;
1046 }
1047 if (editor_tool_get_mode(ett) == etm) {
1049 ? ETM_COPY : ETM_PAINT);
1050 } else {
1052 }
1053}
1054
1055/************************************************************************/
1059{
1060 int mode, count;
1061 bool found = FALSE;
1062
1063 mode = editor_tool_get_mode(ett);
1064 if (!(0 <= mode && mode < NUM_EDITOR_TOOL_MODES)) {
1065 return;
1066 }
1067
1068 for (count = 0; count < NUM_EDITOR_TOOL_MODES; count++) {
1069 mode = (mode + 1) % NUM_EDITOR_TOOL_MODES;
1070 if (editor_tool_has_mode(ett, mode)) {
1071 found = TRUE;
1072 break;
1073 }
1074 }
1075
1076 if (found) {
1078 }
1079}
1080
1081/************************************************************************/
1085{
1086 if (!editor) {
1087 return;
1088 }
1090}
1091
1092/************************************************************************/
1095void editor_selection_add(const struct tile *ptile)
1096{
1097 if (!editor || !ptile) {
1098 return;
1099 }
1101}
1102
1103/************************************************************************/
1106void editor_selection_remove(const struct tile *ptile)
1107{
1108 if (!editor || !ptile) {
1109 return;
1110 }
1112}
1113
1114/************************************************************************/
1117bool editor_tile_is_selected(const struct tile *ptile)
1118{
1119 if (!editor || !ptile) {
1120 return FALSE;
1121 }
1123}
1124
1125/************************************************************************/
1155
1156/************************************************************************/
1160{
1161 if (!editor || !(ett < NUM_EDITOR_TOOL_TYPES)) {
1162 return "";
1163 }
1164
1165 return editor->tools[ett].name;
1166}
1167
1168/************************************************************************/
1173{
1174 struct terrain *pterrain;
1175 struct unit_type *putype;
1176 struct extra_type *pextra;
1177
1178 if (!editor) {
1179 return "";
1180 }
1181
1182 switch (emt) {
1183 case ETT_TERRAIN:
1184 pterrain = terrain_by_number(value);
1185 return pterrain ? terrain_name_translation(pterrain) : "";
1186 break;
1189 case ETT_ROAD:
1190 case ETT_MILITARY_BASE:
1191 pextra = extra_by_number(value);
1192 return pextra != NULL ? extra_name_translation(pextra) : "";
1193 break;
1194 case ETT_UNIT:
1195 putype = utype_by_number(value);
1196 return putype ? utype_name_translation(putype) : "";
1197 break;
1198 default:
1199 break;
1200 }
1201 return "";
1202}
1203
1204/************************************************************************/
1208{
1209 if (!editor || !(ett < NUM_EDITOR_TOOL_TYPES)) {
1210 return FALSE;
1211 }
1212 return editor->tools[ett].flags & ETF_HAS_SIZE;
1213}
1214
1215/************************************************************************/
1219{
1220 if (!editor || !(ett < NUM_EDITOR_TOOL_TYPES)) {
1221 return 1;
1222 }
1223 return editor->tools[ett].size;
1224}
1225
1226/************************************************************************/
1230{
1231 if (!editor || !(ett < NUM_EDITOR_TOOL_TYPES)) {
1232 return;
1233 }
1234 editor->tools[ett].size = MAX(1, size);
1235}
1236
1237/************************************************************************/
1242{
1243 if (!editor || !(ett < NUM_EDITOR_TOOL_TYPES)) {
1244 return FALSE;
1245 }
1246 return editor->tools[ett].flags & ETF_HAS_COUNT;
1247}
1248
1249/************************************************************************/
1253{
1254 if (!editor || !(ett < NUM_EDITOR_TOOL_TYPES)) {
1255 return 1;
1256 }
1257 return editor->tools[ett].count;
1258}
1259
1260/************************************************************************/
1264{
1265 if (!editor || !(ett < NUM_EDITOR_TOOL_TYPES)) {
1266 return;
1267 }
1268 editor->tools[ett].count = MAX(1, count);
1269}
1270
1271/************************************************************************/
1276{
1277 const struct editor_sprites *sprites;
1278
1279 if (!tileset || !(ett < NUM_EDITOR_TOOL_TYPES)) {
1280 return NULL;
1281 }
1282
1283 sprites = get_editor_sprites(tileset);
1284 if (!sprites) {
1285 return NULL;
1286 }
1287
1288 switch (ett) {
1289 case ETT_COPYPASTE:
1290 return sprites->copypaste;
1291 break;
1292 case ETT_TERRAIN:
1293 return sprites->terrain;
1294 break;
1296 return sprites->terrain_resource;
1297 break;
1299 return sprites->terrain_special;
1300 break;
1301 case ETT_ROAD:
1302 return sprites->road;
1303 case ETT_MILITARY_BASE:
1304 return sprites->military_base;
1305 case ETT_UNIT:
1306 return sprites->unit;
1307 break;
1308 case ETT_CITY:
1309 return sprites->city;
1310 break;
1311 case ETT_VISION:
1312 return sprites->vision;
1313 break;
1314 case ETT_STARTPOS:
1315 return sprites->startpos;
1316 break;
1317 default:
1318 break;
1319 }
1320
1321 return NULL;
1322}
1323
1324/************************************************************************/
1328{
1329 if (!editor || !(ett < NUM_EDITOR_TOOL_TYPES)
1330 || !editor->tools[ett].tooltip) {
1331 return "";
1332 }
1333 return editor->tools[ett].tooltip;
1334}
1335
1336/************************************************************************/
1342{
1343 if (!editor || !(ett < NUM_EDITOR_TOOL_TYPES)) {
1344 return -1;
1345 }
1347}
1348
1349/************************************************************************/
1353 int player_no)
1354{
1355 if (!editor || !(ett < NUM_EDITOR_TOOL_TYPES)) {
1356 return;
1357 }
1358 editor->tools[ett].applied_player_no = player_no;
1359}
1360
1361/************************************************************************/
1366{
1367 if (!editor || !(ett < NUM_EDITOR_TOOL_TYPES)) {
1368 return FALSE;
1369 }
1371}
1372
1373/************************************************************************/
1378{
1379 if (!editor || !(ett < NUM_EDITOR_TOOL_TYPES)) {
1380 return FALSE;
1381 }
1383}
1384
1385/************************************************************************/
1389{
1390 if (!editor) {
1391 return 0;
1392 }
1394}
1395
1396/************************************************************************/
1406{
1407 struct unit *vunit;
1408 struct player *pplayer;
1409 struct unit_type *putype;
1410 int apno, value;
1411
1413 putype = utype_by_number(value);
1414
1415 if (!putype) {
1416 return NULL;
1417 }
1418
1420 pplayer = player_by_number(apno);
1421 if (!pplayer) {
1422 return NULL;
1423 }
1424
1425 vunit = unit_virtual_create(pplayer, NULL, putype, 0);
1426
1427 return vunit;
1428}
1429
1430/************************************************************************/
1434{
1435 struct edit_buffer *ebuf;
1436
1437 if (!(0 <= type_flags && type_flags <= EBT_ALL)) {
1438 return NULL;
1439 }
1440
1441 ebuf = fc_calloc(1, sizeof(*ebuf));
1442 ebuf->type_flags = type_flags;
1443 ebuf->vtiles = tile_list_new();
1444
1445 return ebuf;
1446}
1447
1448/************************************************************************/
1452{
1453 if (!ebuf) {
1454 return;
1455 }
1456
1457 if (ebuf->vtiles) {
1458 tile_list_iterate(ebuf->vtiles, vtile) {
1461 tile_list_destroy(ebuf->vtiles);
1462 ebuf->vtiles = NULL;
1463 }
1464 free(ebuf);
1465}
1466
1467/************************************************************************/
1471{
1472 if (!ebuf || !ebuf->vtiles) {
1473 return;
1474 }
1475
1476 tile_list_iterate(ebuf->vtiles, vtile) {
1479 tile_list_clear(ebuf->vtiles);
1480
1482}
1483
1484/************************************************************************/
1489 const struct tile *center,
1490 int radius)
1491{
1492 if (!ebuf || !center || radius < 1) {
1493 return;
1494 }
1495
1497 square_iterate(&(wld.map), center, radius - 1, ptile) {
1498 edit_buffer_copy(ebuf, ptile);
1500}
1501
1502/************************************************************************/
1505void edit_buffer_copy(struct edit_buffer *ebuf, const struct tile *ptile)
1506{
1507 struct tile *vtile;
1508 struct unit *vunit;
1509 bool copied = FALSE;
1510
1511 if (!ebuf || !ptile) {
1512 return;
1513 }
1514
1516 vtile->index = tile_index(ptile);
1517
1519 switch (type) {
1520 case EBT_TERRAIN:
1521 if (tile_terrain(ptile)) {
1523 copied = TRUE;
1524 }
1525 break;
1526 case EBT_RESOURCE:
1527 if (tile_resource(ptile)) {
1529 copied = TRUE;
1530 }
1531 break;
1532 case EBT_SPECIAL:
1534 if (tile_has_extra(ptile, pextra)) {
1535 tile_add_extra(vtile, pextra);
1536 copied = TRUE;
1537 }
1539 break;
1540 case EBT_BASE:
1541 extra_type_iterate(pextra) {
1542 if (tile_has_extra(ptile, pextra)
1543 && is_extra_caused_by(pextra, EC_BASE)) {
1544 tile_add_extra(vtile, pextra);
1545 copied = TRUE;
1546 }
1548 break;
1549 case EBT_ROAD:
1550 extra_type_iterate(pextra) {
1551 if (tile_has_extra(ptile, pextra)
1552 && is_extra_caused_by(pextra, EC_ROAD)) {
1553 tile_add_extra(vtile, pextra);
1554 copied = TRUE;
1555 }
1557 break;
1558 case EBT_UNIT:
1559 unit_list_iterate(ptile->units, punit) {
1560 if (!punit) {
1561 continue;
1562 }
1565 vunit->homecity = punit->homecity;
1566 vunit->hp = punit->hp;
1567 unit_list_append(vtile->units, vunit);
1568 copied = TRUE;
1570 break;
1571 case EBT_CITY:
1572 if (tile_city(ptile)) {
1573 struct city *pcity, *vcity;
1574 char name[MAX_LEN_NAME];
1575
1576 pcity = tile_city(ptile);
1577 fc_snprintf(name, sizeof(name), "Copy of %s",
1581 improvement_iterate(pimprove) {
1582 if (!is_improvement(pimprove)
1583 || !city_has_building(pcity, pimprove)) {
1584 continue;
1585 }
1586 city_add_improvement(vcity, pimprove);
1589 copied = TRUE;
1590 }
1591 break;
1592 default:
1593 break;
1594 }
1596
1597 if (copied) {
1598 tile_list_append(ebuf->vtiles, vtile);
1599 } else {
1601 }
1602}
1603
1604/************************************************************************/
1607static void fill_tile_edit_packet(struct packet_edit_tile *packet,
1608 const struct tile *ptile)
1609{
1610 const struct extra_type *presource;
1611 const struct terrain *pterrain;
1612
1613 if (!packet || !ptile) {
1614 return;
1615 }
1616 packet->tile = tile_index(ptile);
1617 packet->extras = *tile_extras(ptile);
1618
1619 presource = tile_resource(ptile);
1620 packet->resource = presource
1621 ? extra_number(presource)
1622 : extra_count();
1623
1624 pterrain = tile_terrain(ptile);
1625 packet->terrain = pterrain
1626 ? terrain_number(pterrain)
1627 : terrain_count();
1628 if (ptile->extras_owner != NULL) {
1629 packet->eowner = player_number(ptile->extras_owner);
1630 } else {
1631 packet->eowner = MAP_TILE_OWNER_NULL;
1632 }
1633
1634 if (ptile->label == NULL) {
1635 packet->label[0] = '\0';
1636 } else {
1637 sz_strlcpy(packet->label, ptile->label);
1638 }
1639}
1640
1641/************************************************************************/
1645static void paste_tile(struct edit_buffer *ebuf,
1646 const struct tile *vtile,
1647 const struct tile *ptile_dest)
1648{
1649 struct connection *my_conn = &client.conn;
1651 struct city *vcity;
1652 int value, owner, tile;
1653 bool send_edit_tile = FALSE;
1654
1655 if (!ebuf || !vtile || !ptile_dest) {
1656 return;
1657 }
1658
1660
1662
1664 switch (type) {
1665 case EBT_TERRAIN:
1666 if (!tile_terrain(vtile)) {
1667 continue;
1668 }
1671 break;
1672 case EBT_RESOURCE:
1674 if (tile_has_extra(vtile, pextra)) {
1675 BV_SET(tile_packet.extras, extra_index(pextra));
1677 }
1679 break;
1680 case EBT_SPECIAL:
1682 if (tile_has_extra(vtile, pextra)) {
1683 BV_SET(tile_packet.extras, extra_index(pextra));
1685 }
1687 break;
1688 case EBT_BASE:
1689 extra_type_iterate(pextra) {
1690 if (tile_has_extra(vtile, pextra)
1691 && is_extra_caused_by(pextra, EC_BASE)) {
1692 BV_SET(tile_packet.extras, extra_index(pextra));
1694 }
1696 break;
1697 case EBT_ROAD:
1698 extra_type_iterate(pextra) {
1699 if (tile_has_extra(vtile, pextra)
1700 && is_extra_caused_by(pextra, EC_ROAD)) {
1701 BV_SET(tile_packet.extras, extra_index(pextra));
1703 }
1705 break;
1706 case EBT_UNIT:
1707 unit_list_iterate(vtile->units, vunit) {
1712 break;
1713 case EBT_CITY:
1715 if (!vcity) {
1716 continue;
1717 }
1719 value = city_size_get(vcity);
1721 break;
1722 default:
1723 break;
1724 }
1726
1727 if (send_edit_tile) {
1729 }
1730}
1731
1732/************************************************************************/
1735void edit_buffer_paste(struct edit_buffer *ebuf, const struct tile *dest)
1736{
1737 struct connection *my_conn = &client.conn;
1738 const struct tile *origin, *ptile;
1739 int dx, dy;
1740
1741 if (!ebuf || !dest) {
1742 return;
1743 }
1744
1745 /* Calculate vector. */
1746 origin = edit_buffer_get_origin(ebuf);
1747 fc_assert_ret(origin != NULL);
1748 map_distance_vector(&dx, &dy, origin, dest);
1749
1751 tile_list_iterate(ebuf->vtiles, vtile) {
1752 int virt_x, virt_y;
1753
1755 ptile = map_pos_to_tile(&(wld.map), virt_x + dx, virt_y + dy);
1756 if (!ptile) {
1757 continue;
1758 }
1759 paste_tile(ebuf, vtile, ptile);
1762}
1763
1764/************************************************************************/
1768{
1769 if (!editor) {
1770 return NULL;
1771 }
1772 return editor->copybuf;
1773}
1774
1775/************************************************************************/
1779 enum editor_tool_mode etm)
1780{
1781 bool value_erase;
1782
1784
1785 switch (etm) {
1786 case ETM_PAINT:
1787 return _("Paint");
1788 break;
1789 case ETM_ERASE:
1790 if (value_erase) {
1791 return _("Erase Value");
1792 } else {
1793 return _("Erase");
1794 }
1795 break;
1796 case ETM_COPY:
1797 return _("Copy");
1798 break;
1799 case ETM_PASTE:
1800 return _("Paste");
1801 break;
1802 default:
1803 log_error("Unrecognized editor tool mode %d "
1804 "in editor_tool_get_mode_name().", etm);
1805 break;
1806 }
1807
1808 return "";
1809}
1810
1811/************************************************************************/
1816{
1817 switch (etm) {
1818 case ETM_ERASE:
1819 return _("Toggle erase mode.\nShortcut: shift-d");
1820 break;
1821 case ETM_COPY:
1822 return _("Toggle copy mode.\nShortcut: shift-c");
1823 break;
1824 case ETM_PASTE:
1825 return _("Toggle paste mode.\nShortcut: shift-v");
1826 break;
1827 default:
1828 break;
1829 }
1830
1831 return NULL;
1832}
1833
1834/************************************************************************/
1838{
1839 const struct editor_sprites *sprites;
1840
1841 sprites = get_editor_sprites(tileset);
1842 if (!sprites) {
1843 return NULL;
1844 }
1845
1846 switch (etm) {
1847 case ETM_PAINT:
1848 return sprites->brush;
1849 break;
1850 case ETM_ERASE:
1851 return sprites->erase;
1852 break;
1853 case ETM_COPY:
1854 return sprites->copy;
1855 break;
1856 case ETM_PASTE:
1857 return sprites->paste;
1858 break;
1859 default:
1860 break;
1861 }
1862
1863 return NULL;
1864}
1865
1866/************************************************************************/
1871 char *buf, int buflen)
1872{
1873 int ret, total;
1874 const char *fmt;
1875
1876 if (!buf || buflen < 1) {
1877 return 0;
1878 }
1879
1880 ret = fc_strlcpy(buf, _("Buffer empty."), buflen);
1881 if (!ebuf || !ebuf->vtiles) {
1882 return ret;
1883 }
1884
1885 total = tile_list_size(ebuf->vtiles);
1886 if (total > 0) {
1887 fmt = PL_("%d tile copied.", "%d tiles copied.", total);
1888 ret = fc_snprintf(buf, buflen, fmt, total);
1889 }
1890
1891 return ret;
1892}
1893
1894/************************************************************************/
1899 const struct tile *ptile)
1900{
1901 if (!ebuf) {
1902 return;
1903 }
1904 ebuf->origin = ptile;
1905}
1906
1907/************************************************************************/
1910const struct tile *edit_buffer_get_origin(const struct edit_buffer *ebuf)
1911{
1912 if (!ebuf) {
1913 return NULL;
1914 }
1915 return ebuf->origin;
1916}
1917
1918/************************************************************************/
1922{
1923 if (!ebuf) {
1924 return FALSE;
1925 }
1926 return ebuf->type_flags & type;
1927}
1928
1929/************************************************************************/
1935{
1936 int count;
1937 const struct tile *origin, *center;
1938 int dx, dy, cx, cy;
1939 int xsum = 0, ysum = 0;
1940
1941 if (!editor || !editor->selected_tile_table) {
1942 return NULL;
1943 }
1944
1946 if (count < 1) {
1947 return NULL;
1948 }
1949
1950 origin = map_pos_to_tile(&(wld.map), 0, 0);
1952 map_distance_vector(&dx, &dy, origin, ptile);
1953 xsum += dx;
1954 ysum += dy;
1956
1957 cx = xsum / count;
1958 cy = ysum / count;
1959 center = map_pos_to_tile(&(wld.map), cx, cy);
1960
1961 return center;
1962}
Base_type_id base_count(void)
Definition base.c:113
#define BV_SET(bv, bit)
Definition bitvector.h:89
struct canvas int int canvas_y
Definition canvas_g.h:43
struct canvas int canvas_x
Definition canvas_g.h:43
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:3455
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:3382
static citizens city_size_get(const struct city *pcity)
Definition city.h:566
#define city_owner(_pcity_)
Definition city.h:560
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:76
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
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 int const struct action *paction struct unit struct city * pcity
Definition dialogs_g.h:78
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:1870
bool editor_is_active(void)
Definition editor.c:346
void editor_selection_remove(const struct tile *ptile)
Definition editor.c:1106
bool edit_buffer_has_type(const struct edit_buffer *ebuf, int type)
Definition editor.c:1921
int editor_tool_get_size(enum editor_tool_type ett)
Definition editor.c:1218
static void paste_tile(struct edit_buffer *ebuf, const struct tile *vtile, const struct tile *ptile_dest)
Definition editor.c:1645
void editor_set_tool(enum editor_tool_type ett)
Definition editor.c:270
void editor_mouse_button_press(int canvas_x, int canvas_y, int button, int modifiers)
Definition editor.c:661
void editor_set_current_tile(const struct tile *ptile)
Definition editor.c:1016
void editor_mouse_move(int canvas_x, int canvas_y, int modifiers)
Definition editor.c:866
enum editor_tool_mode editor_tool_get_mode(enum editor_tool_type ett)
Definition editor.c:335
bool editor_tool_has_value_erase(enum editor_tool_type ett)
Definition editor.c:1377
void editor_tool_set_count(enum editor_tool_type ett, int count)
Definition editor.c:1263
void editor_tool_toggle_mode(enum editor_tool_type ett, enum editor_tool_mode etm)
Definition editor.c:1041
static void tool_init(enum editor_tool_type ett, const char *name, int flags, const char *tooltip)
Definition editor.c:151
void editor_selection_add(const struct tile *ptile)
Definition editor.c:1095
const char * editor_tool_get_value_name(enum editor_tool_type emt, int value)
Definition editor.c:1172
void editor_notify_edit_finished(void)
Definition editor.c:897
void editor_init(void)
Definition editor.c:193
int editor_tool_get_value(enum editor_tool_type ett)
Definition editor.c:409
static void editor_end_selection_rectangle(int canvas_x, int canvas_y)
Definition editor.c:722
struct edit_buffer * edit_buffer_new(int type_flags)
Definition editor.c:1433
struct edit_buffer * editor_get_copy_buffer(void)
Definition editor.c:1767
void editor_tool_set_applied_player(enum editor_tool_type ett, int player_no)
Definition editor.c:1352
const char * editor_tool_get_mode_name(enum editor_tool_type ett, enum editor_tool_mode etm)
Definition editor.c:1778
void editor_clear(void)
Definition editor.c:246
void editor_tool_cycle_mode(enum editor_tool_type ett)
Definition editor.c:1058
static void editor_grab_applied_player(const struct tile *ptile)
Definition editor.c:465
int editor_tool_get_count(enum editor_tool_type ett)
Definition editor.c:1252
const struct tile * edit_buffer_get_origin(const struct edit_buffer *ebuf)
Definition editor.c:1910
void edit_buffer_copy(struct edit_buffer *ebuf, const struct tile *ptile)
Definition editor.c:1505
int editor_selection_count(void)
Definition editor.c:1388
void editor_tool_set_size(enum editor_tool_type ett, int size)
Definition editor.c:1229
const char * editor_get_mode_tooltip(enum editor_tool_mode etm)
Definition editor.c:1815
bool editor_tool_is_usable(enum editor_tool_type ett)
Definition editor.c:359
enum editor_tool_type editor_get_tool(void)
Definition editor.c:286
bool editor_tool_has_applied_player(enum editor_tool_type ett)
Definition editor.c:1365
bool editor_tool_has_size(enum editor_tool_type ett)
Definition editor.c:1207
void edit_buffer_clear(struct edit_buffer *ebuf)
Definition editor.c:1470
selection_modes
Definition editor.c:47
@ SELECTION_MODE_ADD
Definition editor.c:49
@ SELECTION_MODE_REMOVE
Definition editor.c:50
@ SELECTION_MODE_NEW
Definition editor.c:48
void editor_tool_set_value(enum editor_tool_type ett, int value)
Definition editor.c:397
bool editor_tool_has_value(enum editor_tool_type ett)
Definition editor.c:385
static void popup_properties(struct tile *ptile)
Definition editor.c:631
const char * editor_tool_get_tooltip(enum editor_tool_type ett)
Definition editor.c:1327
void editor_selection_clear(void)
Definition editor.c:1084
void editor_mouse_button_release(int canvas_x, int canvas_y, int button, int modifiers)
Definition editor.c:798
static void editor_grab_tool(const struct tile *ptile)
Definition editor.c:497
static bool tile_really_has_any_specials(const struct tile *ptile)
Definition editor.c:446
void edit_buffer_copy_square(struct edit_buffer *ebuf, const struct tile *center, int radius)
Definition editor.c:1488
static void editor_start_selection_rectangle(int canvas_x, int canvas_y)
Definition editor.c:422
struct sprite * editor_tool_get_sprite(enum editor_tool_type ett)
Definition editor.c:1275
const struct tile * editor_get_current_tile(void)
Definition editor.c:1028
void editor_apply_tool_to_selection(void)
Definition editor.c:1128
void editor_apply_tool(const struct tile *ptile, bool part_of_selection)
Definition editor.c:909
bool editor_tile_is_selected(const struct tile *ptile)
Definition editor.c:1117
void edit_buffer_set_origin(struct edit_buffer *ebuf, const struct tile *ptile)
Definition editor.c:1898
void editor_free(void)
Definition editor.c:257
static bool can_edit_tile_properties(struct tile *ptile)
Definition editor.c:621
void edit_buffer_paste(struct edit_buffer *ebuf, const struct tile *dest)
Definition editor.c:1735
const struct tile * editor_get_selection_center(void)
Definition editor.c:1934
editor_tool_flags
Definition editor.c:53
@ ETF_NO_FLAGS
Definition editor.c:54
@ ETF_HAS_APPLIED_PLAYER
Definition editor.c:58
@ ETF_HAS_SIZE
Definition editor.c:56
@ ETF_HAS_VALUE_ERASE
Definition editor.c:59
@ ETF_HAS_COUNT
Definition editor.c:57
@ ETF_HAS_VALUE
Definition editor.c:55
bool editor_tool_has_mode(enum editor_tool_type ett, enum editor_tool_mode etm)
Definition editor.c:313
struct unit * editor_unit_virtual_create(void)
Definition editor.c:1405
static void editor_draw_selrect(void)
Definition editor.c:780
void editor_ruleset_changed(void)
Definition editor.c:180
int editor_tool_get_applied_player(enum editor_tool_type ett)
Definition editor.c:1341
bool editor_tool_has_count(enum editor_tool_type ett)
Definition editor.c:1241
struct sprite * editor_get_mode_sprite(enum editor_tool_mode etm)
Definition editor.c:1837
static void editor_resize_selection_rectangle(int canvas_x, int canvas_y)
Definition editor.c:826
static void fill_tile_edit_packet(struct packet_edit_tile *packet, const struct tile *ptile)
Definition editor.c:1607
const char * editor_tool_get_name(enum editor_tool_type ett)
Definition editor.c:1159
static void tool_set_init_value(enum editor_tool_type ett)
Definition editor.c:105
static struct editor_state * editor
Definition editor.c:100
void edit_buffer_free(struct edit_buffer *ebuf)
Definition editor.c:1451
void editor_tool_set_mode(enum editor_tool_type ett, enum editor_tool_mode etm)
Definition editor.c:298
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:822
#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:61
struct world wld
Definition game.c:62
struct city * owner
Definition citydlg.c:226
void editgui_popup_properties(const struct tile_list *tiles, int objtype)
Definition editgui.c:1875
void editgui_refresh(void)
Definition editgui.c:1796
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:192
#define fc_assert(condition)
Definition log.h:177
#define log_error(message,...)
Definition log.h:104
struct tile * map_pos_to_tile(const struct civ_map *nmap, int map_x, int map_y)
Definition map.c:434
void map_distance_vector(int *dx, int *dy, const struct tile *tile0, const struct tile *tile1)
Definition map.c:1213
#define square_iterate(nmap, center_tile, radius, tile_itr)
Definition map.h:388
#define square_iterate_end
Definition map.h:391
#define MAP_TILE_OWNER_NULL
Definition map.h:630
#define index_to_map_pos(pmap_x, pmap_y, mindex)
Definition map.h:229
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(x, y)
Definition shared.h:54
size_t size
Definition specvec.h:72
Definition city.h:317
struct tile * tile
Definition city.h:319
struct packet_ruleset_control control
Definition game.h:83
struct connection conn
Definition client_main.h:96
const struct tile * origin
Definition editor.c:65
struct tile_list * vtiles
Definition editor.c:64
int type_flags
Definition editor.c:63
struct sprite * terrain
Definition tilespec.h:349
struct sprite * road
Definition tilespec.h:357
struct sprite * city
Definition tilespec.h:353
struct sprite * terrain_special
Definition tilespec.h:351
struct sprite * vision
Definition tilespec.h:354
struct sprite * terrain_resource
Definition tilespec.h:350
struct sprite * copypaste
Definition tilespec.h:347
struct sprite * brush
Definition tilespec.h:344
struct sprite * startpos
Definition tilespec.h:348
struct sprite * military_base
Definition tilespec.h:358
struct sprite * copy
Definition tilespec.h:345
struct sprite * erase
Definition tilespec.h:342
struct sprite * paste
Definition tilespec.h:346
struct sprite * unit
Definition tilespec.h:352
struct tile_hash * selected_tile_table
Definition editor.c:96
bool selrect_active
Definition editor.c:86
int selrect_x
Definition editor.c:89
enum selection_modes selection_mode
Definition editor.c:94
struct editor_tool tools[NUM_EDITOR_TOOL_TYPES]
Definition editor.c:81
struct edit_buffer * copybuf
Definition editor.c:97
bool tool_active
Definition editor.c:84
int selrect_start_y
Definition editor.c:88
int selrect_width
Definition editor.c:91
int selrect_height
Definition editor.c:92
int selrect_start_x
Definition editor.c:87
enum editor_tool_type tool
Definition editor.c:80
int selrect_y
Definition editor.c:90
const struct tile * current_tile
Definition editor.c:83
int size
Definition editor.c:71
int flags
Definition editor.c:69
int count
Definition editor.c:72
enum editor_tool_mode mode
Definition editor.c:70
const char * tooltip
Definition editor.c:76
const char * name
Definition editor.c:74
int applied_player_no
Definition editor.c:73
int value
Definition editor.c:75
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:66
struct unit_list * units
Definition tile.h:58
struct player * extras_owner
Definition tile.h:63
Definition unit.h:140
int id
Definition unit.h:147
int hp
Definition unit.h:153
int homecity
Definition unit.h:148
int veteran
Definition unit.h:154
float gui_x0
float gui_y0
struct civ_map map
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:960
size_t fc_strlcpy(char *dest, const char *src, size_t n)
Definition support.c:777
#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:1035
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:89
#define tile_hash_iterate(hash, ptile)
Definition tile.h:83
#define tile_resource(_tile)
Definition tile.h:103
@ TILE_UNKNOWN
Definition tile.h:36
#define tile_list_iterate(tile_list, ptile)
Definition tile.h:74
#define tile_terrain(_tile)
Definition tile.h:111
#define tile_hash_iterate_end
Definition tile.h:85
#define tile_list_iterate_end
Definition tile.h:76
static const bv_extras * tile_extras(const struct tile *ptile)
Definition tile.h:121
#define tile_has_extra(ptile, pextra)
Definition tile.h:148
#define tile_owner(_tile)
Definition tile.h:97
int tileset_tile_height(const struct tileset *t)
Definition tilespec.c:791
int tileset_tile_width(const struct tileset *t)
Definition tilespec.c:779
const struct editor_sprites * get_editor_sprites(const struct tileset *t)
Definition tilespec.c:7173
struct unit * unit_virtual_create(struct player *pplayer, struct city *pcity, const struct unit_type *punittype, int veteran_level)
Definition unit.c:1661
bool unit_transported(const struct unit *pcargo)
Definition unit.c:2502
#define unit_owner(_pu)
Definition unit.h:403
#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:1557
Unit_type_id utype_count(void)
Definition unittype.c:80
struct unit_class * unit_class_get(const struct unit *punit)
Definition unittype.c:2505
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:1566
static bool uclass_has_flag(const struct unit_class *punitclass, enum unit_class_flag_id flag)
Definition unittype.h:773
float mouse_zoom
Definition zoom.c:28
float map_zoom
Definition zoom.c:25