-
Notifications
You must be signed in to change notification settings - Fork 4
/
game.c
38 lines (33 loc) · 828 Bytes
/
game.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
#include "game.h"
#include "faction.h"
#include "region.h"
#include "ship.h"
#include <quicklist.h>
#include <string.h>
#include <stdlib.h>
int nextunitid = 1;
int turn;
void cleargame(bool clearconfig)
{
nextunitid = 1;
free_regions();
ql_foreach(factions, (ql_cb)free_faction);
ql_free(factions);
factions = 0;
turn = 0;
if (clearconfig) {
int d;
for (d = 0; d != MAXDIRECTIONS; ++d) {
int k;
for (k = 0; config.directions[d] && config.directions[d][k]; ++k) {
free(config.directions[d][k]);
}
free(config.directions[d]);
}
memset(&config, 0, sizeof(config));
ql_foreach(shiptypes, (ql_cb)free_shiptype);
ql_free(shiptypes);
shiptypes = 0;
free_terrains();
}
}