-
Notifications
You must be signed in to change notification settings - Fork 0
/
time.c
47 lines (43 loc) · 927 Bytes
/
time.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <stdio.h>
#include <stdlib.h>
#include "time.h"
#include "character.h"
#include "world.h"
const char *months[] = {
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
};
void init_gametime()
{
// if (world->current_time != NULL) return;
// world->current_time = malloc(sizeof(gametime_t));
world->current_time.tm_year = 0;
world->current_time.tm_mon = 0;
}
void set_gametime(uint16_t year, unsigned char mon)
{
// if (world->current_time == NULL) init_gametime();
if (mon < 1 || mon > 12)
return;
world->current_time.tm_year = year;
world->current_time.tm_mon = mon;
}
void increment_gametime()
{
// if (world->current_time == NULL) init_gametime();
if (world->current_time.tm_mon == 11) {
world->current_time.tm_year += 1;
world->current_time.tm_mon = 0;
} else
world->current_time.tm_mon += 1;
}