Freeciv-3.3
Loading...
Searching...
No Matches
climap.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 2002 - 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/* common */
19#include "map.h"
20#include "shared.h"
21
22/* client */
23#include "client_main.h"
24#include "climap.h"
25#include "tilespec.h" /* tileset_is_isometric(tileset) */
26
27/**********************************************************************/
36enum known_type client_tile_get_known(const struct tile *ptile)
37{
38 if (NULL == client.conn.playing) {
39 if (client_is_observer()) {
40 return TILE_KNOWN_SEEN;
41 } else {
42 return TILE_UNKNOWN;
43 }
44 }
45 return tile_get_known(ptile, client.conn.playing);
46}
47
48/**********************************************************************/
60{
62 return dir_ccw(gui_dir);
63 } else {
64 return gui_dir;
65 }
66}
67
68/**********************************************************************/
74{
76 return dir_cw(map_dir);
77 } else {
78 return map_dir;
79 }
80}
81
82/**********************************************************************/
87struct tile *client_city_tile(const struct city *pcity)
88{
89 int dx, dy;
90 double x = 0, y = 0;
91 size_t num = 0;
92
93 if (NULL == pcity) {
94 return NULL;
95 }
96
97 if (NULL != city_tile(pcity)) {
98 /* Normal city case. */
99 return city_tile(pcity);
100 }
101
102 whole_map_iterate(&(wld.map), ptile) {
103 int tile_x, tile_y;
104
106 if (pcity == tile_worked(ptile)) {
107 if (0 == num) {
108 x = tile_x;
109 y = tile_y;
110 num = 1;
111 } else {
112 num++;
113 base_map_distance_vector(&dx, &dy, (int)x, (int)y, tile_x, tile_y);
114 x += (double) dx / num;
115 y += (double) dy / num;
116 }
117 }
119
120 if (0 < num) {
121 return map_pos_to_tile(&(wld.map), (int) x, (int) y);
122 } else {
123 return NULL;
124 }
125}
126
127/**********************************************************************/
134 const struct tile *ptile)
135{
137}
bool base_city_can_work_tile(const struct player *restriction, const struct city *pcity, const struct tile *ptile)
Definition city.c:1401
#define city_tile(_pcity_)
Definition city.h:561
bool client_is_observer(void)
struct civclient client
#define client_player()
enum known_type client_tile_get_known(const struct tile *ptile)
Definition climap.c:36
struct tile * client_city_tile(const struct city *pcity)
Definition climap.c:87
enum direction8 gui_to_map_dir(enum direction8 gui_dir)
Definition climap.c:59
enum direction8 map_to_gui_dir(enum direction8 map_dir)
Definition climap.c:73
bool client_city_can_work_tile(const struct city *pcity, const struct tile *ptile)
Definition climap.c:133
char * incite_cost
Definition comments.c:76
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
struct world wld
Definition game.c:62
enum direction8 dir_ccw(enum direction8 dir)
Definition map.c:1344
struct tile * map_pos_to_tile(const struct civ_map *nmap, int map_x, int map_y)
Definition map.c:434
void base_map_distance_vector(int *dx, int *dy, int x0dv, int y0dv, int x1dv, int y1dv)
Definition map.c:1162
enum direction8 dir_cw(enum direction8 dir)
Definition map.c:1315
#define whole_map_iterate(_map, _tile)
Definition map.h:573
#define whole_map_iterate_end
Definition map.h:582
#define index_to_map_pos(pmap_x, pmap_y, mindex)
Definition map.h:229
struct sprite int int y
Definition sprite_g.h:31
struct sprite int x
Definition sprite_g.h:31
Definition city.h:317
struct connection conn
Definition client_main.h:96
struct player * playing
Definition connection.h:151
Definition tile.h:50
struct civ_map map
enum known_type tile_get_known(const struct tile *ptile, const struct player *pplayer)
Definition tile.c:392
#define tile_index(_pt_)
Definition tile.h:89
#define tile_worked(_tile)
Definition tile.h:115
known_type
Definition tile.h:35
@ TILE_UNKNOWN
Definition tile.h:36
@ TILE_KNOWN_SEEN
Definition tile.h:38
bool tileset_is_isometric(const struct tileset *t)
Definition tilespec.c:738