Freeciv-3.3
Loading...
Searching...
No Matches
calendar.c
Go to the documentation of this file.
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)
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 "game.h"
20#include "victory.h"
21
22#include "calendar.h"
23
24/************************************************************************/
31{
36
37 if (info->year_0_hack) {
38 /* Hack it to get rid of year 0 */
39 info->year = 0;
40 info->year_0_hack = FALSE;
41 }
42
43 /* !McFred:
44 - want year += 1 for spaceship.
45 */
46
47 /* Test game with 7 normal AI's, gen 4 map, foodbox 10, foodbase 0:
48 * Gunpowder about 0 AD
49 * Railroad about 500 AD
50 * Electricity about 1000 AD
51 * Refining about 1500 AD (212 active units)
52 * about 1750 AD
53 * about 1900 AD
54 */
55
56 /* Note the slowdown operates even if Enable_Space is not active.
57 * See README.effects for specifics. */
58 if (slowdown >= 3) {
59 if (increase > 1) {
60 increase = 1;
61 }
62 } else if (slowdown >= 2) {
63 if (increase > 2) {
64 increase = 2;
65 }
66 } else if (slowdown >= 1) {
67 if (increase > 5) {
68 increase = 5;
69 }
70 }
71
75
78 }
79
80 info->year += increase;
81
82 if (info->year == 0 && game.calendar.calendar_skip_0) {
83 info->year = 1;
84 info->year_0_hack = TRUE;
85 }
86}
87
88/************************************************************************/
92{
94 game.info.turn++;
95}
96
97/************************************************************************/
101const char *textcalfrag(int frag)
102{
103 static char buf[MAX_LEN_NAME];
104
106 if (game.calendar.calendar_fragment_name[frag][0] != '\0') {
107 fc_snprintf(buf, sizeof(buf), "%s",
109 } else {
110 /* Human readable fragment count starts from 1, not 0 */
111 fc_snprintf(buf, sizeof(buf), "%d", frag + 1);
112 }
113
114 return buf;
115}
116
117/************************************************************************/
121const char *textyear(int year)
122{
123 static char y[32];
124
125 if (year < 0) {
126 /* TRANS: <year> <label> -> "1000 BC" */
127 fc_snprintf(y, sizeof(y), _("%d %s"), -year,
129 } else {
130 /* TRANS: <year> <label> -> "1000 AD" */
131 fc_snprintf(y, sizeof(y), _("%d %s"), year,
133 }
134
135 return y;
136}
137
138/************************************************************************/
142const char *calendar_text(void)
143{
145 static char buffer[128];
146
147 fc_snprintf(buffer, sizeof(buffer), "%s/%s", textyear(game.info.year),
149 return buffer;
150 } else {
151 return textyear(game.info.year);
152 }
153}
void game_advance_year(void)
Definition calendar.c:91
const char * textcalfrag(int frag)
Definition calendar.c:101
const char * calendar_text(void)
Definition calendar.c:142
void game_next_year(struct packet_game_info *info)
Definition calendar.c:30
const char * textyear(int year)
Definition calendar.c:121
char * incite_cost
Definition comments.c:76
int get_world_bonus(enum effect_type effect_type)
Definition effects.c:812
#define MAX_LEN_NAME
Definition fc_types.h:66
@ VC_SPACERACE
Definition fc_types.h:979
#define _(String)
Definition fcintl.h:67
struct civ_game game
Definition game.c:61
#define fc_assert_ret_val(condition, val)
Definition log.h:195
struct sprite int int y
Definition sprite_g.h:31
struct packet_game_info info
Definition game.h:89
struct packet_calendar_info calendar
Definition game.h:90
char positive_year_label[MAX_LEN_NAME]
char negative_year_label[MAX_LEN_NAME]
char calendar_fragment_name[MAX_CALENDAR_FRAGMENTS][MAX_LEN_NAME]
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:960
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
bool victory_enabled(enum victory_condition_type victory)
Definition victory.c:26