Freeciv-3.2
Loading...
Searching...
No Matches
server
infrapts.c
Go to the documentation of this file.
1
/***********************************************************************
2
Freeciv - Copyright (C) 1996 - 2004 The Freeciv Project Team
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
#ifdef HAVE_CONFIG_H
14
#include <fc_config.h>
15
#endif
16
17
/* common */
18
#include "
map.h
"
19
20
/* server */
21
#include <
hand_gen.h
>
/* <> so looked from the build directory first. */
22
#include "
maphand.h
"
23
#include "
notify.h
"
24
#include "
plrhand.h
"
25
26
/************************************************************************/
29
void
handle_player_place_infra
(
struct
player
*pplayer,
int
tile
,
int
extra)
30
{
31
struct
tile
*ptile;
32
struct
extra_type
*pextra;
33
34
if
(!
terrain_control
.infrapoints) {
35
return
;
36
}
37
38
ptile =
index_to_tile
(&(
wld
.
map
),
tile
);
39
pextra =
extra_by_number
(extra);
40
41
if
(ptile ==
NULL
|| pextra ==
NULL
) {
42
return
;
43
}
44
45
if
(!
map_is_known_and_seen
(ptile, pplayer,
V_MAIN
)) {
46
notify_player
(pplayer,
NULL
,
E_INFRAPOINTS
,
ftc_server
,
47
_
(
"Cannot place %s to unseen tile."
),
48
extra_name_translation
(pextra));
49
return
;
50
}
51
52
if
(pplayer->
economic
.
infra_points
< pextra->
infracost
) {
53
notify_player
(pplayer,
NULL
,
E_INFRAPOINTS
,
ftc_server
,
54
_
(
"Cannot place %s for lack of infrapoints."
),
55
extra_name_translation
(pextra));
56
return
;
57
}
58
59
if
(!
player_can_place_extra
(pextra, pplayer, ptile)) {
60
notify_player
(pplayer,
NULL
,
E_INFRAPOINTS
,
ftc_server
,
61
_
(
"Cannot place unbuildable %s."
),
62
extra_name_translation
(pextra));
63
return
;
64
}
65
66
pplayer->
economic
.
infra_points
-= pextra->
infracost
;
67
send_player_info_c
(pplayer, pplayer->
connections
);
68
69
ptile->
placing
= pextra;
70
71
if
(pextra->
build_time
> 0) {
72
ptile->
infra_turns
= pextra->
build_time
;
73
}
else
{
74
ptile->
infra_turns
=
tile_terrain
(ptile)->placing_time * pextra->
build_time_factor
;
75
}
76
77
/* update_tile_knowledge() would not know to send the tile
78
* when only placing has changed, so send it explicitly. */
79
send_tile_info
(pplayer->
connections
, ptile,
FALSE
);
80
}
incite_cost
char * incite_cost
Definition
comments.c:75
player_can_place_extra
bool player_can_place_extra(const struct extra_type *pextra, const struct player *pplayer, const struct tile *ptile)
Definition
extras.c:488
extra_by_number
struct extra_type * extra_by_number(int id)
Definition
extras.c:183
extra_name_translation
const char * extra_name_translation(const struct extra_type *pextra)
Definition
extras.c:194
_
#define _(String)
Definition
fcintl.h:67
ftc_server
const struct ft_color ftc_server
Definition
featured_text.c:77
wld
struct world wld
Definition
game.c:63
hand_gen.h
handle_player_place_infra
void handle_player_place_infra(struct player *pplayer, int tile, int extra)
Definition
infrapts.c:29
index_to_tile
struct tile * index_to_tile(const struct civ_map *imap, int mindex)
Definition
map.c:456
terrain_control
struct terrain_misc terrain_control
Definition
map.c:69
map.h
send_tile_info
void send_tile_info(struct conn_list *dest, struct tile *ptile, bool send_unknown)
Definition
maphand.c:491
map_is_known_and_seen
bool map_is_known_and_seen(const struct tile *ptile, const struct player *pplayer, enum vision_layer vlayer)
Definition
maphand.c:920
maphand.h
notify_player
void notify_player(const struct player *pplayer, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
Definition
notify.c:291
notify.h
send_player_info_c
void send_player_info_c(struct player *src, struct conn_list *dest)
Definition
plrhand.c:1146
plrhand.h
extra_type
Definition
extras.h:88
extra_type::build_time_factor
int build_time_factor
Definition
extras.h:119
extra_type::build_time
int build_time
Definition
extras.h:118
extra_type::infracost
int infracost
Definition
extras.h:122
player_economic::infra_points
int infra_points
Definition
player.h:65
player
Definition
player.h:247
player::connections
struct conn_list * connections
Definition
player.h:296
player::economic
struct player_economic economic
Definition
player.h:282
tile
Definition
tile.h:50
tile::infra_turns
int infra_turns
Definition
tile.h:62
tile::placing
struct extra_type * placing
Definition
tile.h:61
world::map
struct civ_map map
Definition
world_object.h:38
FALSE
#define FALSE
Definition
support.h:47
tile_terrain
#define tile_terrain(_tile)
Definition
tile.h:110
Generated on Sun Dec 22 2024 23:00:34 for Freeciv-3.2 by
1.9.8