1 /****************************************************************************
2 Freeciv - Copyright (C) 2004 - The Freeciv 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)
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 ****************************************************************************/
15 #include <fc_config.h>
24 /***************************************************************
25 Returns the next year in the game.
26 ***************************************************************/
27 int game_next_year(int year
)
29 int increase
= get_world_bonus(EFT_TURN_YEARS
);
30 const int slowdown
= (victory_enabled(VC_SPACERACE
)
31 ? get_world_bonus(EFT_SLOW_DOWN_TIMELINE
) : 0);
34 if (game
.info
.year_0_hack
) {
35 /* hacked it to get rid of year 0 */
37 game
.info
.year_0_hack
= FALSE
;
41 - want year += 1 for spaceship.
44 /* test game with 7 normal AI's, gen 4 map, foodbox 10, foodbase 0:
45 * Gunpowder about 0 AD
46 * Railroad about 500 AD
47 * Electricity about 1000 AD
48 * Refining about 1500 AD (212 active units)
53 /* Note the slowdown operates even if Enable_Space is not active. See
54 * README.effects for specifics. */
59 } else if (slowdown
>= 2) {
63 } else if (slowdown
>= 1) {
69 if (game
.info
.calendar_fragments
) {
70 game
.info
.fragment_count
+= get_world_bonus(EFT_TURN_FRAGMENTS
);
71 fragment_years
= game
.info
.fragment_count
/ game
.info
.calendar_fragments
;
73 increase
+= fragment_years
;
74 game
.info
.fragment_count
-= fragment_years
* game
.info
.calendar_fragments
;
79 if (year
== 0 && game
.info
.calendar_skip_0
) {
81 game
.info
.year_0_hack
= TRUE
;
87 /***************************************************************
88 Advance the game year.
89 ***************************************************************/
90 void game_advance_year(void)
92 game
.info
.year
= game_next_year(game
.info
.year
);
96 /****************************************************************************
97 Produce a statically allocated textual representation of the given
99 ****************************************************************************/
100 const char *textyear(int year
)
105 /* TRANS: <year> <label> -> "1000 BC" */
106 fc_snprintf(y
, sizeof(y
), _("%d %s"), -year
,
107 _(game
.info
.negative_year_label
));
109 /* TRANS: <year> <label> -> "1000 AD" */
110 fc_snprintf(y
, sizeof(y
), _("%d %s"), year
,
111 _(game
.info
.positive_year_label
));
117 /****************************************************************************
118 Produce a statically allocated textual representation of the current
120 ****************************************************************************/
121 const char *calendar_text(void)
123 if (game
.info
.calendar_fragments
) {
124 static char buffer
[128];
126 if (game
.info
.calendar_fragment_name
[game
.info
.fragment_count
][0] != '\0') {
127 fc_snprintf(buffer
, sizeof(buffer
), "%s/%s", textyear(game
.info
.year
),
128 _(game
.info
.calendar_fragment_name
[game
.info
.fragment_count
]));
130 /* Human readable fragment count starts from 1, not 0 */
131 fc_snprintf(buffer
, sizeof(buffer
), "%s/%d", textyear(game
.info
.year
),
132 game
.info
.fragment_count
+ 1);
137 return textyear(game
.info
.year
);