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
.calendar
.calendar_fragments
) {
70 game
.info
.fragment_count
+= get_world_bonus(EFT_TURN_FRAGMENTS
);
71 fragment_years
= game
.info
.fragment_count
/ game
.calendar
.calendar_fragments
;
73 increase
+= fragment_years
;
74 game
.info
.fragment_count
-= fragment_years
* game
.calendar
.calendar_fragments
;
79 if (year
== 0 && game
.calendar
.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 *textcalfrag(int frag
)
102 static char buf
[MAX_LEN_NAME
];
104 fc_assert_ret_val(game
.calendar
.calendar_fragments
> 0, "");
105 if (game
.calendar
.calendar_fragment_name
[frag
][0] != '\0') {
106 fc_snprintf(buf
, sizeof(buf
), "%s",
107 _(game
.calendar
.calendar_fragment_name
[frag
]));
109 /* Human readable fragment count starts from 1, not 0 */
110 fc_snprintf(buf
, sizeof(buf
), "%d", frag
+ 1);
115 /****************************************************************************
116 Produce a statically allocated textual representation of the given
118 ****************************************************************************/
119 const char *textyear(int year
)
124 /* TRANS: <year> <label> -> "1000 BC" */
125 fc_snprintf(y
, sizeof(y
), _("%d %s"), -year
,
126 _(game
.calendar
.negative_year_label
));
128 /* TRANS: <year> <label> -> "1000 AD" */
129 fc_snprintf(y
, sizeof(y
), _("%d %s"), year
,
130 _(game
.calendar
.positive_year_label
));
136 /****************************************************************************
137 Produce a statically allocated textual representation of the current
139 ****************************************************************************/
140 const char *calendar_text(void)
142 if (game
.calendar
.calendar_fragments
) {
143 static char buffer
[128];
145 fc_snprintf(buffer
, sizeof(buffer
), "%s/%s", textyear(game
.info
.year
),
146 textcalfrag(game
.info
.fragment_count
));
149 return textyear(game
.info
.year
);