forked from Atlantis-PBEM/Atlantis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
168 lines (151 loc) · 3.87 KB
/
main.cpp
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
// START A3HEADER
//
// This source file is part of the Atlantis PBM game program.
// Copyright (C) 1995-1999 Geoff Dunbar
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program, in the file license.txt. If not, write
// to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
//
// See the Atlantis Project web page for details:
// http://www.prankster.com/project
//
// END A3HEADER
// MODIFICATIONS
// Date Person Comments
// ---- ------ --------
// 2000/MAR/14 Larry Stanbery Added a unit:faction map capability.
#include "gamedefs.h"
#include "game.h"
#include "items.h"
#include "skills.h"
#include "gamedata.h"
void usage()
{
Awrite("atlantis new");
Awrite("atlantis run");
Awrite("atlantis edit");
Awrite("");
Awrite("atlantis map <geo|wmon|lair|gate> <mapfile>");
Awrite("atlantis mapunits");
Awrite("atlantis genrules <introfile> <cssfile> <rules-outputfile>");
Awrite("");
Awrite("atlantis check <orderfile> <checkfile>");
}
int main(int argc, char *argv[])
{
Game game;
int retval = 1;
initIO();
Awrite(AString("Atlantis Engine Version: ") +
ATL_VER_STRING(CURRENT_ATL_VER));
Awrite(AString(Globals->RULESET_NAME) + ", Version: " +
ATL_VER_STRING(Globals->RULESET_VERSION));
Awrite("");
if (argc == 1) {
usage();
doneIO();
return 0;
}
game.ModifyTablesPerRuleset();
do {
if (AString(argv[1]) == "new") {
if (!game.NewGame()) {
Awrite( "Couldn't make the new game!" );
break;
}
if ( !game.SaveGame() ) {
Awrite( "Couldn't save the game!" );
break;
}
if ( !game.WritePlayers() ) {
Awrite( "Couldn't write the players file!" );
break;
}
} else if (AString(argv[1]) == "map") {
if (argc != 4) {
usage();
break;
}
if ( !game.OpenGame() ) {
Awrite( "Couldn't open the game file!" );
break;
}
if ( !game.ViewMap( argv[2], argv[3] )) {
Awrite( "Couldn't write the map file!" );
break;
}
} else if (AString(argv[1]) == "run") {
if ( !game.OpenGame() ) {
Awrite( "Couldn't open the game file!" );
break;
}
if ( !game.RunGame() ) {
Awrite( "Couldn't run the game!" );
break;
}
if ( !game.SaveGame() ) {
Awrite( "Couldn't save the game!" );
break;
}
} else if (AString(argv[1]) == "edit") {
if ( !game.OpenGame() ) {
Awrite( "Couldn't open the game file!" );
break;
}
int saveGame = 0;
if ( !game.EditGame( &saveGame ) ) {
Awrite( "Couldn't edit the game!" );
break;
}
if ( saveGame ) {
if ( !game.SaveGame() ) {
Awrite( "Couldn't save the game!" );
break;
}
}
} else if ( AString( argv[1] ) == "check" ) {
if (argc != 4) {
usage();
break;
}
game.DummyGame();
if ( !game.DoOrdersCheck( argv[ 2 ], argv[ 3 ] )) {
Awrite( "Couldn't check the orders!" );
break;
}
} else if ( AString( argv[1] ) == "mapunits" ) {
if ( !game.OpenGame() ) {
Awrite( "Couldn't open the game file!" );
break;
}
game.UnitFactionMap();
} else if (AString(argv[1])== "genrules") {
if (argc != 5) {
usage();
break;
}
if (!game.GenRules(argv[4], argv[3], argv[2])) {
Awrite("Unable to generate rules!");
break;
}
} else {
Awrite(AString("Unknown option: ") + argv[1]);
break;
}
retval = 0;
} while( 0 );
doneIO();
return retval;
}