Lines Matching refs:ptile

439 static inline bool tile_really_has_any_specials(const struct tile *ptile)  in tile_really_has_any_specials()  argument
441 if (!ptile) { in tile_really_has_any_specials()
446 if (tile_has_extra(ptile, pextra)) { in tile_really_has_any_specials()
458 static void editor_grab_applied_player(const struct tile *ptile) in editor_grab_applied_player() argument
462 if (!editor || !ptile) { in editor_grab_applied_player()
467 && tile_get_known(ptile, client_player()) == TILE_UNKNOWN) { in editor_grab_applied_player()
471 if (tile_city(ptile) != NULL) { in editor_grab_applied_player()
472 apno = player_number(city_owner(tile_city(ptile))); in editor_grab_applied_player()
473 } else if (unit_list_size(ptile->units) > 0) { in editor_grab_applied_player()
474 struct unit *punit = unit_list_get(ptile->units, 0); in editor_grab_applied_player()
476 } else if (tile_owner(ptile) != NULL) { in editor_grab_applied_player()
477 apno = player_number(tile_owner(ptile)); in editor_grab_applied_player()
489 static void editor_grab_tool(const struct tile *ptile) in editor_grab_tool() argument
499 if (!ptile) { in editor_grab_tool()
504 if (tile_has_extra(ptile, pextra)) { in editor_grab_tool()
511 if (tile_has_extra(ptile, pextra)) { in editor_grab_tool()
518 && tile_get_known(ptile, client_player()) == TILE_UNKNOWN) { in editor_grab_tool()
521 } else if (tile_city(ptile)) { in editor_grab_tool()
524 } else if (unit_list_size(ptile->units) > 0) { in editor_grab_tool()
528 unit_list_iterate(ptile->units, punit) { in editor_grab_tool()
560 } else if (tile_really_has_any_specials(ptile)) { in editor_grab_tool()
572 if (tile_has_extra(ptile, specials_array[i])) { in editor_grab_tool()
582 } else if (tile_resource(ptile) != NULL) { in editor_grab_tool()
584 value = resource_number(tile_resource(ptile)); in editor_grab_tool()
586 } else if (tile_terrain(ptile) != NULL) { in editor_grab_tool()
588 value = terrain_number(tile_terrain(ptile)); in editor_grab_tool()
605 static inline bool can_edit_tile_properties(struct tile *ptile) in can_edit_tile_properties() argument
607 return ptile != NULL; in can_edit_tile_properties()
615 static void popup_properties(struct tile *ptile) in popup_properties() argument
619 if (!ptile) { in popup_properties()
625 if (editor_tile_is_selected(ptile)) { in popup_properties()
632 if (can_edit_tile_properties(ptile)) { in popup_properties()
633 tile_list_append(tiles, ptile); in popup_properties()
648 struct tile *ptile; in editor_mouse_button_press() local
654 ptile = canvas_pos_to_tile(canvas_x, canvas_y); in editor_mouse_button_press()
655 if (ptile == NULL) { in editor_mouse_button_press()
663 editor_grab_tool(ptile); in editor_mouse_button_press()
665 editor_grab_applied_player(ptile); in editor_mouse_button_press()
668 editor_apply_tool(ptile, FALSE); in editor_mouse_button_press()
670 editor_set_current_tile(ptile); in editor_mouse_button_press()
676 popup_properties(ptile); in editor_mouse_button_press()
694 popup_properties(ptile); in editor_mouse_button_press()
717 struct tile *ptile; in editor_end_selection_rectangle() local
719 ptile = canvas_pos_to_tile(canvas_x, canvas_y); in editor_end_selection_rectangle()
720 if (ptile && editor->selection_mode == SELECTION_MODE_ADD) { in editor_end_selection_rectangle()
721 editor_selection_add(ptile); in editor_end_selection_rectangle()
722 } else if (ptile && editor->selection_mode == SELECTION_MODE_REMOVE) { in editor_end_selection_rectangle()
723 editor_selection_remove(ptile); in editor_end_selection_rectangle()
729 if (ptile) { in editor_end_selection_rectangle()
730 refresh_tile_mapcanvas(ptile, TRUE, TRUE); in editor_end_selection_rectangle()
739 ptile, pedge, pcorner, map_zoom) { in editor_end_selection_rectangle()
740 if (ptile == NULL) { in editor_end_selection_rectangle()
745 editor_selection_add(ptile); in editor_end_selection_rectangle()
747 editor_selection_remove(ptile); in editor_end_selection_rectangle()
852 const struct tile *ptile, *old; in editor_mouse_move() local
859 ptile = canvas_pos_to_tile(canvas_x, canvas_y); in editor_mouse_move()
861 if (!ptile) { in editor_mouse_move()
865 if (editor->tool_active && old != NULL && old != ptile) { in editor_mouse_move()
866 editor_apply_tool(ptile, FALSE); in editor_mouse_move()
868 editor_set_current_tile(ptile); in editor_mouse_move()
893 void editor_apply_tool(const struct tile *ptile, in editor_apply_tool() argument
902 if (editor == NULL || ptile == NULL) { in editor_apply_tool()
915 && tile_get_known(ptile, client_player()) == TILE_UNKNOWN) { in editor_apply_tool()
929 edit_buffer_copy(ebuf, ptile); in editor_apply_tool()
932 edit_buffer_copy_square(ebuf, ptile, size); in editor_apply_tool()
936 edit_buffer_paste(ebuf, ptile); in editor_apply_tool()
946 tile = tile_index(ptile); in editor_apply_tool()
976 struct city *pcity = tile_city(ptile); in editor_apply_tool()
1005 void editor_set_current_tile(const struct tile *ptile) in editor_set_current_tile() argument
1011 editor->current_tile = ptile; in editor_set_current_tile()
1084 void editor_selection_add(const struct tile *ptile) in editor_selection_add() argument
1086 if (!editor || !ptile) { in editor_selection_add()
1089 tile_hash_insert(editor->selected_tile_table, ptile, NULL); in editor_selection_add()
1095 void editor_selection_remove(const struct tile *ptile) in editor_selection_remove() argument
1097 if (!editor || !ptile) { in editor_selection_remove()
1100 tile_hash_remove(editor->selected_tile_table, ptile); in editor_selection_remove()
1106 bool editor_tile_is_selected(const struct tile *ptile) in editor_tile_is_selected() argument
1108 if (!editor || !ptile) { in editor_tile_is_selected()
1111 return tile_hash_lookup(editor->selected_tile_table, ptile, NULL); in editor_tile_is_selected()
1134 tile_hash_iterate(editor->selected_tile_table, ptile) { in editor_apply_tool_to_selection()
1135 editor_apply_tool(ptile, TRUE); in editor_apply_tool_to_selection()
1490 square_iterate(center, radius - 1, ptile) { in edit_buffer_copy_square()
1491 edit_buffer_copy(ebuf, ptile); in edit_buffer_copy_square()
1498 void edit_buffer_copy(struct edit_buffer *ebuf, const struct tile *ptile) in edit_buffer_copy() argument
1504 if (!ebuf || !ptile) { in edit_buffer_copy()
1509 vtile->index = tile_index(ptile); in edit_buffer_copy()
1514 if (tile_terrain(ptile)) { in edit_buffer_copy()
1515 tile_set_terrain(vtile, tile_terrain(ptile)); in edit_buffer_copy()
1520 if (tile_resource(ptile)) { in edit_buffer_copy()
1521 tile_set_resource(vtile, tile_resource(ptile)); in edit_buffer_copy()
1527 if (tile_has_extra(ptile, pextra)) { in edit_buffer_copy()
1535 if (tile_has_extra(ptile, pextra) in edit_buffer_copy()
1544 if (tile_has_extra(ptile, pextra) in edit_buffer_copy()
1552 unit_list_iterate(ptile->units, punit) { in edit_buffer_copy()
1565 if (tile_city(ptile)) { in edit_buffer_copy()
1569 pcity = tile_city(ptile); in edit_buffer_copy()
1601 const struct tile *ptile) in fill_tile_edit_packet() argument
1606 if (!packet || !ptile) { in fill_tile_edit_packet()
1609 packet->tile = tile_index(ptile); in fill_tile_edit_packet()
1610 packet->extras = *tile_extras(ptile); in fill_tile_edit_packet()
1612 presource = tile_resource(ptile); in fill_tile_edit_packet()
1617 pterrain = tile_terrain(ptile); in fill_tile_edit_packet()
1622 if (ptile->label == NULL) { in fill_tile_edit_packet()
1625 sz_strlcpy(packet->label, ptile->label); in fill_tile_edit_packet()
1725 const struct tile *origin, *ptile; in edit_buffer_paste() local
1742 ptile = map_pos_to_tile(virt_x + dx, virt_y + dy); in edit_buffer_paste()
1743 if (!ptile) { in edit_buffer_paste()
1746 paste_tile(ebuf, vtile, ptile); in edit_buffer_paste()
1886 const struct tile *ptile) in edit_buffer_set_origin() argument
1891 ebuf->origin = ptile; in edit_buffer_set_origin()
1938 tile_hash_iterate(editor->selected_tile_table, ptile) { in editor_get_selection_center()
1939 map_distance_vector(&dx, &dy, origin, ptile); in editor_get_selection_center()