2011-08-24 14:14:44 +02:00
|
|
|
/*
|
|
|
|
Project: Starfighter
|
|
|
|
Copyright (C) 2003 Parallel Realities
|
2015-03-01 21:37:32 +01:00
|
|
|
Copyright (C) 2011, 2012 Guus Sliepen
|
|
|
|
Copyright (C) 2015 Julian Marchant
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
2015-02-26 17:20:36 +01:00
|
|
|
as published by the Free Software Foundation; either version 3
|
2011-08-24 14:14:44 +02:00
|
|
|
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
|
2015-02-26 17:20:36 +01:00
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2015-02-26 17:20:36 +01:00
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2011-08-24 14:14:44 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "Starfighter.h"
|
|
|
|
|
2015-03-05 03:30:23 +01:00
|
|
|
int main(int argc, char **argv)
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
2015-03-05 03:30:23 +01:00
|
|
|
bool cheatAttempt;
|
|
|
|
int cheatCount;
|
|
|
|
int section;
|
|
|
|
|
2015-02-27 20:53:23 +01:00
|
|
|
if (chdir(DATADIR) == -1)
|
|
|
|
printf("Warning: failed to change directory to \"%s\"\n", DATADIR);
|
2012-02-27 15:33:58 +01:00
|
|
|
|
2011-08-24 14:14:44 +02:00
|
|
|
defineGlobals(); // Must do this first!
|
|
|
|
|
2015-03-05 03:30:23 +01:00
|
|
|
cheatAttempt = false;
|
|
|
|
cheatCount = 0;
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
if (argc > 1)
|
|
|
|
{
|
|
|
|
if (strcmp("--help", argv[1]) == 0)
|
|
|
|
{
|
|
|
|
printf("\nProject: Starfighter %s\n", VERSION);
|
2012-02-26 22:25:57 +01:00
|
|
|
printf("Copyright Parallel Realities 2003\n");
|
|
|
|
printf("Copyright Guus Sliepen, Astrid S. de Wijn and others 2012\n");
|
2011-08-24 14:14:44 +02:00
|
|
|
printf("Additional Commands\n");
|
|
|
|
printf("\t-noaudio Disables sound and music\n");
|
|
|
|
printf("\t-mono Mono sound output (best for headphones)\n\n");
|
2012-02-26 22:25:57 +01:00
|
|
|
printf("http://sourceforge.net/projects/pr-starfighter/\n");
|
2011-08-24 14:14:44 +02:00
|
|
|
printf("\n");
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 1 ; i < argc ; i++)
|
|
|
|
{
|
|
|
|
if (strcmp(argv[i], "-nomove") == 0)
|
2015-03-05 03:30:23 +01:00
|
|
|
{
|
|
|
|
printf("Enemy movement disabled\n");
|
|
|
|
dev.moveAliens = 0;
|
|
|
|
}
|
2011-08-24 14:14:44 +02:00
|
|
|
if (strcmp(argv[i], "-nofire") == 0)
|
2015-03-05 03:30:23 +01:00
|
|
|
{
|
|
|
|
printf("Enemy firing disabled\n");
|
|
|
|
dev.fireAliens = 0;
|
|
|
|
}
|
2011-08-24 14:14:44 +02:00
|
|
|
if (strcmp(argv[i], "-cheat") == 0)
|
2011-08-26 16:14:58 +02:00
|
|
|
cheatAttempt = true;
|
2011-08-24 14:14:44 +02:00
|
|
|
if (strcmp(argv[i], "-noaudio") == 0)
|
2015-03-05 03:30:23 +01:00
|
|
|
{
|
|
|
|
printf("No Audio\n");
|
|
|
|
engine.useAudio = false;
|
|
|
|
}
|
2011-08-24 14:14:44 +02:00
|
|
|
if (strcmp(argv[i], "-mono") == 0)
|
2015-03-05 03:30:23 +01:00
|
|
|
{
|
|
|
|
printf("Mono sound output\n");
|
|
|
|
engine.useAudio = true;
|
|
|
|
}
|
2015-02-27 04:16:45 +01:00
|
|
|
if ((strcmp(argv[i], "humans") == 0) && (cheatCount == 0))
|
|
|
|
cheatCount = 1;
|
|
|
|
if ((strcmp(argv[i], "do") == 0) && (cheatCount == 1))
|
|
|
|
cheatCount = 2;
|
|
|
|
if ((strcmp(argv[i], "it") == 0) && (cheatCount == 2))
|
|
|
|
cheatCount = 3;
|
2015-02-27 19:35:47 +01:00
|
|
|
if (((strcmp(argv[i], "better") == 0) && (cheatCount == 3)) ||
|
2015-03-05 03:30:23 +01:00
|
|
|
(strcmp(argv[i], "humansdoitbetter") == 0))
|
|
|
|
{
|
|
|
|
printf("Humans do it better! Cheats enabled.\n");
|
|
|
|
engine.cheat = true;
|
|
|
|
}
|
2011-08-24 14:14:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
atexit(cleanUp);
|
|
|
|
|
2011-08-26 23:53:46 +02:00
|
|
|
initGraphics();
|
2011-08-24 14:14:44 +02:00
|
|
|
initSystem(); // Opens video mode and sound
|
|
|
|
loadFont();
|
|
|
|
|
2015-02-27 19:35:47 +01:00
|
|
|
if (cheatAttempt && !engine.cheat)
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
2011-08-26 23:53:46 +02:00
|
|
|
clearScreen(black);
|
|
|
|
drawString("That doesn't work anymore", -1, 285, FONT_WHITE);
|
|
|
|
drawString("Try harder...", -1, 315, FONT_WHITE);
|
|
|
|
updateScreen();
|
2011-08-24 14:14:44 +02:00
|
|
|
SDL_Delay(2000);
|
2011-08-26 23:53:46 +02:00
|
|
|
clearScreen(black);
|
|
|
|
updateScreen();
|
2011-08-24 14:14:44 +02:00
|
|
|
SDL_Delay(500);
|
|
|
|
}
|
|
|
|
|
2011-08-26 23:53:46 +02:00
|
|
|
freeGraphics();
|
2015-03-08 15:38:58 +01:00
|
|
|
audio_loadSounds();
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
initWeapons();
|
|
|
|
initVars();
|
2015-03-09 01:59:33 +01:00
|
|
|
alien_defs_init();
|
2011-08-24 14:14:44 +02:00
|
|
|
|
2011-08-26 23:53:46 +02:00
|
|
|
setColorIndexes();
|
2011-08-24 14:14:44 +02:00
|
|
|
|
|
|
|
showStory();
|
|
|
|
|
|
|
|
// Determine which part of the game we will go to...
|
2015-03-05 03:30:23 +01:00
|
|
|
section = 0;
|
2011-08-24 14:14:44 +02:00
|
|
|
|
2015-02-28 01:52:55 +01:00
|
|
|
currentGame.difficulty = DIFFICULTY_NORMAL;
|
2011-08-24 14:14:44 +02:00
|
|
|
newGame();
|
|
|
|
|
|
|
|
while (true)
|
|
|
|
{
|
2015-03-05 03:30:23 +01:00
|
|
|
switch (section)
|
2011-08-24 14:14:44 +02:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
section = doTitle();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
section = galaxyMap();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
2015-03-05 03:30:23 +01:00
|
|
|
if (currentGame.stationedPlanet == -1)
|
|
|
|
doCutscene(0);
|
2011-08-24 14:14:44 +02:00
|
|
|
section = mainGameLoop();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
}
|