]> git.mxchange.org Git - quix0rs-blobwars.git/blob - src/main.cpp
Use DEBUG instead of USEPAK to enable debugging code.
[quix0rs-blobwars.git] / src / main.cpp
1 /*
2 Copyright (C) 2004 Parallel Realities
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13 See the GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18
19 */
20
21 #include "main.h"
22
23 #include <locale.h>
24
25 void showHelp()
26 {
27         printf("\n");
28         printf("Blob Wars, Episode I - Metal Blob Solid (Version %.2f, Release %d)\n", VERSION, RELEASE);
29         printf("Copyright (C) 2004 Parallel Realities\n");
30         printf("Licensed under the GNU General Public License (GPL)\n\n");
31
32         printf("The Metal Blob Solid gameplay manual can be found in,\n");
33         printf("\t%s\n\n", GAMEPLAYMANUAL);
34         
35         printf("Replay Commands\n");
36         printf("\t-map <filename>       Play the specified map (use -listmaps to see maps)\n");
37         printf("\t-record <filename>    Record a game and output to the specified file\n");
38         printf("\t-playback <filename>  Playback the specified recording\n");
39         printf("\t-listmaps             List the available maps for playing\n\n");
40         
41         printf("Replay Examples\n");
42         printf("\tblobwars -map data/grasslands1 -record replay.dat\n");
43         printf("\tblobwars -playback replay.dat\n\n");
44
45         printf("Additional Commands\n");
46         printf("\t-fullscreen         Start the game in Full Screen mode\n");
47         printf("\t-mono               Use mono sound output instead of stereo\n");
48         printf("\t-noaudio            Disables audio\n");
49         printf("\t-version            Display version number\n");
50         printf("\t--help              This help\n\n");
51
52         exit(0);
53 }
54
55 void listMaps()
56 {
57         printf("\n");
58         printf("Blob Wars, Episode I - Metal Blob Solid (Version %.2f, Release %d)\n", VERSION, RELEASE);
59         printf("Copyright (C) 2004 Parallel Realities\n");
60         printf("Licensed under the GNU General Public License (GPL)\n\n");
61         
62         printf("Available Maps\n");
63         printf("\tdata/arcticWastes\n");
64         printf("\tdata/assimilator\n");
65         printf("\tdata/caves1\n");
66         printf("\tdata/caves2\n");
67         printf("\tdata/caves3\n");
68         printf("\tdata/caves4\n");
69         printf("\tdata/comm\n");
70         printf("\tdata/finalBattle\n");
71         printf("\tdata/floodedTunnel1\n");
72         printf("\tdata/floodedTunnel2\n");
73         printf("\tdata/floodedTunnel3\n");
74         printf("\tdata/floodedTunnel4\n");
75         printf("\tdata/grasslands1\n");
76         printf("\tdata/grasslands2\n");
77         printf("\tdata/grasslands3\n");
78         printf("\tdata/hq\n");
79         printf("\tdata/icecave1\n");
80         printf("\tdata/icecave2\n");
81         printf("\tdata/spaceStation\n");
82         printf("\tdata/supply\n");
83         printf("\tdata/tomb1\n");
84         printf("\tdata/tomb2\n");
85         printf("\tdata/tomb3\n");
86         printf("\tdata/tomb4\n\n");
87         
88         exit(0);
89 }
90
91 void showVersion()
92 {
93         printf("\n");
94         printf("Blob Wars, Episode I - Metal Blob Solid (Version %.2f, Release %d)\n", VERSION, RELEASE);
95         printf("Copyright (C) 2004 Parallel Realities\n");
96         printf("Licensed under the GNU General Public License (GPL)\n\n");
97 //      exit(0);
98 }
99
100 int main(int argc, char *argv[])
101 {
102         #if !USEPAK
103         debug(("Not Using PAK...\n"));
104         #endif
105         
106         config.engine = &engine;
107         
108         replayData.reset();
109
110         bindtextdomain("blobwars", LOCALEDIR);
111         setlocale(LC_ALL, "");
112         textdomain("blobwars");
113
114         atexit(cleanup);
115
116         bool showSprites = false;
117         bool hub = false;
118         
119         int recordMode = REPLAY_MODE::NONE;
120         int requiredSection = SECTION_INTRO;
121
122         for (int i = 1 ; i < argc ; i++)
123         {
124                 if (strcmp(argv[i], "-fullscreen") == 0) engine.fullScreen = true;
125                 else if (strcmp(argv[i], "-noaudio") == 0) engine.useAudio = 0;
126                 else if (strcmp(argv[i], "-mono") == 0) engine.useAudio = 1;
127                 else if (strcmp(argv[i], "-version") == 0) showVersion();
128                 else if (strcmp(argv[i], "--help") == 0) showHelp();
129                 else if (strcmp(argv[i], "-record") == 0) {recordMode = REPLAY_MODE::RECORD; strncpy(replayData.filename, argv[++i], sizeof replayData.filename);}
130                 else if (strcmp(argv[i], "-playback") == 0) {recordMode = REPLAY_MODE::PLAYBACK; strncpy(replayData.filename, argv[++i], sizeof replayData.filename);}
131                 else if (strcmp(argv[i], "-map") == 0) {game.setMapName(argv[++i]); requiredSection = SECTION_GAME;}
132                 else if (strcmp(argv[i], "-listmaps") == 0) listMaps();
133                 
134                 #if DEBUG
135                 else if (strcmp(argv[i], "-showsprites") == 0) showSprites = true;
136                 else if (strcmp(argv[i], "-hub") == 0) hub = true;
137                 else if (strcmp(argv[i], "-randomscreens") == 0) graphics.takeRandomScreenShots = true;
138                 else if (strcmp(argv[i], "-nomonsters") == 0) engine.devNoMonsters = true;
139                 else if (strcmp(argv[i], "-credits") == 0) requiredSection = SECTION_CREDITS;
140                 #endif
141         }
142         
143         switch (recordMode)
144         {
145                 case REPLAY_MODE::NONE:
146                         // nothing to do...
147                         break;
148                         
149                 case REPLAY_MODE::RECORD:
150                         requiredSection = SECTION_GAME;
151                         strncpy(replayData.header.map, game.mapName, sizeof replayData.header.map);
152                         replayData.header.skill = game.skill = 3;
153                         replayData.setMode(REPLAY_MODE::RECORD);
154                         break;
155                         
156                 case REPLAY_MODE::PLAYBACK:
157                         requiredSection = SECTION_GAME;
158                         replayData.setMode(REPLAY_MODE::PLAYBACK);
159                         replayData.header.time = 0;
160                         game.setMapName(replayData.header.map);
161                         game.skill = replayData.header.skill;
162                         break;
163         }
164
165         initSystem();
166         
167         // seed the random using the one generated
168         // via the replay data
169         Math::pSeed = replayData.header.randomSeed;
170         
171         player.setName("Player");
172
173         engine.flushInput();
174         
175         engine.allowQuit = true;
176
177         if (hub)
178         {
179                 requiredSection = SECTION_HUB;
180                 loadGame(0);
181                 loadResources();
182         }
183         
184         if (game.skill == 3)
185         {
186                 game.hasAquaLung = game.hasJetPack = true;
187         }
188
189         if (showSprites)
190         {
191                 showAllSprites();
192         }
193
194         while (true)
195         {
196                 switch (requiredSection)
197                 {
198                         case SECTION_INTRO:
199                                 requiredSection = doIntro();
200                                 break;
201
202                         case SECTION_TITLE:
203                                 requiredSection = title();
204                                 break;
205
206                         case SECTION_HUB:
207                                 requiredSection = doHub();
208                                 break;
209
210                         case SECTION_GAME:
211                                 if (!game.continueFromCheckPoint)
212                                 {
213                                         checkStartCutscene();
214                                         loadResources();
215                                 }
216                                 requiredSection = doGame();
217                                 break;
218
219                         case SECTION_GAMEOVER:
220                                 requiredSection = gameover();
221                                 break;
222                                 
223                         case SECTION_EASYOVER:
224                                 map.clear();
225                                 game.clear();
226                                 easyGameFinished();
227                                 requiredSection = SECTION_TITLE;
228                                 break;
229                                 
230                         case SECTION_CREDITS:
231                                 doCredits();
232                                 requiredSection = SECTION_TITLE;
233                                 break;
234                 }
235         }
236
237         return 0;
238 }