-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathmain.cpp
More file actions
144 lines (126 loc) · 4 KB
/
main.cpp
File metadata and controls
144 lines (126 loc) · 4 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#include "gamedefs.h"
#include "game.h"
#include "items.h"
#include "skills.h"
#include "gamedata.h"
#include "strings_util.hpp"
void usage()
{
logger::write("atlantis new");
logger::write("atlantis run");
logger::write("atlantis edit");
logger::write("");
logger::write("atlantis map <geo|wmon|lair|gate|hex> <mapfile>");
logger::write("atlantis mapunits");
logger::write("atlantis genrules <introfile> <cssfile> <rules-outputfile>");
logger::write("");
logger::write("atlantis check <orderfile> <checkfile>");
}
int main(int argc, char *argv[])
{
Game game;
int retval = 1;
// Give the rng an initial see.
rng::seed_random(1783); // this is the historical seed.. it gets reseeded in NewGame() to a random value.
logger::write("Atlantis Engine Version: " + ATL_VER_STRING(CURRENT_ATL_VER));
logger::write(Globals->RULESET_NAME + ", Version: " + ATL_VER_STRING(Globals->RULESET_VERSION));
logger::write("");
if (argc == 1) {
usage();
return 0;
}
// For simplicity, convert all arguments to strings
std::vector<std::string> args;
for (int i = 0; i < argc; i++) {
args.push_back(argv[i]);
}
game.ModifyTablesPerRuleset();
do {
if (args[1] == "new") {
if (!game.NewGame()) {
logger::write("Couldn't make the new game!");
break;
}
if ( !game.SaveGame() ) {
logger::write("Couldn't save the game!");
break;
}
if ( !game.WritePlayers() ) {
logger::write("Couldn't write the players file!");
break;
}
} else if (args[1] == "map") {
if (argc != 4) {
usage();
break;
}
if (!game.OpenGame() ) {
logger::write("Couldn't open the game file!");
break;
}
if (!game.view_map(args[2], args[3])) {
logger::write("Couldn't write the map file!");
break;
}
} else if (args[1] == "run") {
if (!game.OpenGame()) {
logger::write("Couldn't open the game file!");
break;
}
if (!game.RunGame()) {
logger::write("Couldn't run the game!");
break;
}
if (!game.SaveGame()) {
logger::write("Couldn't save the game!");
break;
}
} else if (args[1] == "edit") {
if (!game.OpenGame()) {
logger::write("Couldn't open the game file!");
break;
}
int saveGame = 0;
if (!game.EditGame(&saveGame)) {
logger::write("Couldn't edit the game!");
break;
}
if (saveGame) {
if (!game.SaveGame()) {
logger::write("Couldn't save the game!");
break;
}
}
} else if (args[1] == "check") {
if (argc != 4) {
usage();
break;
}
game.DummyGame();
if (!game.do_orders_check(args[2], args[3])) {
logger::write("Couldn't check the orders!");
break;
}
} else if (args[1] == "mapunits") {
if (!game.OpenGame()) {
logger::write("Couldn't open the game file!");
break;
}
game.UnitFactionMap();
} else if (args[1] == "genrules") {
if (argc != 5) {
usage();
break;
}
if (!game.generate_rules(args[4], args[3], args[2])) {
logger::write("Unable to generate rules!");
break;
}
} else {
logger::write("Unknown option: " + args[1]);
break;
}
retval = 0;
} while( 0 );
return retval;
}