X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2Fmain.cpp;h=9282a1e23a764f703ef04405f927274f077d0031;hb=0e7253d9244ce174a12fbed7bf907a916f0d68dc;hp=020724c19f668bed51fbe42af6cb7f2a254cfe6a;hpb=6d93c744add4c06b85cf6c6d7e6317536a5c8ec1;p=quix0rs-blobwars.git diff --git a/src/main.cpp b/src/main.cpp old mode 100755 new mode 100644 index 020724c..9282a1e --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,7 @@ /* -Copyright (C) 2004 Parallel Realities +Copyright (C) 2004-2011 Parallel Realities +Copyright (C) 2011-2015 Perpendicular Dimensions +Copyright (C) 2011-2015 Perpendicular Dimensions This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -22,86 +24,112 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include -void showHelp() +Audio audio; +Config config; +Engine engine; +Game game; +GameData gameData; +Graphics graphics; +Map map; +ReplayData replayData; +MedalServer medalServer; + +Entity defEnemy[MAX_ENEMIES]; +Entity defItem[MAX_ITEMS]; +Entity player; +Weapon weapon[MAX_WEAPONS]; + +void showVersion() { - printf("\n"); - printf("Blob Wars, Episode I - Metal Blob Solid (Version %.2f, Release %d)\n", VERSION, RELEASE); - printf("Copyright (C) 2004 Parallel Realities\n"); - printf("Licensed under the GNU General Public License (GPL)\n\n"); + printf(_( + "\n" + "Blob Wars, Episode I - Metal Blob Solid (Version %.2f, Release %d)\n" + "Copyright (C) 2004-2011 Parallel Realities\n" + "Copyright (C) 2011-2015 Perpendicular Dimensions\n" + "Licensed under the GNU General Public License (GPL)\n" + "\n"), + VERSION, RELEASE); +} - printf("The Metal Blob Solid gameplay manual can be found in,\n"); - printf("\t%s\n\n", GAMEPLAYMANUAL); - - printf("Replay Commands\n"); - printf("\t-map Play the specified map (use -listmaps to see maps)\n"); - printf("\t-record Record a game and output to the specified file\n"); - printf("\t-playback Playback the specified recording\n"); - printf("\t-listmaps List the available maps for playing\n\n"); - - printf("Replay Examples\n"); - printf("\tblobwars -map data/grasslands1 -record replay.dat\n"); - printf("\tblobwars -playback replay.dat\n\n"); +void showHelp() +{ + showVersion(); - printf("Additional Commands\n"); - printf("\t-fullscreen Start the game in Full Screen mode\n"); - printf("\t-mono Use mono sound output instead of stereo\n"); - printf("\t-noaudio Disables audio\n"); - printf("\t-version Display version number\n"); - printf("\t--help This help\n\n"); + printf(_( + "The Metal Blob Solid gameplay manual can be found in,\n" + "\t%s\n" + "\n" + "Replay Commands\n" + "\t-map Play the specified map (use -listmaps to see maps)\n" + "\t-record Record a game and output to the specified file\n" + "\t-playback Playback the specified recording\n" + "\t-listmaps List the available maps for playing\n" + "\n" + "Replay Examples\n" + "\tblobwars -map data/grasslands1 -record replay.dat\n" + "\tblobwars -playback replay.dat\n" + "\n" + "Additional Commands\n" + "\t-fullscreen Start the game in Full Screen mode\n" + "\t-window Start the game in Window mode\n" + "\t-mono Use mono sound output instead of stereo\n" + "\t-noaudio Disables audio\n" + "\t-version Display version number\n" + "\t--help This help\n" + "\n"), + GAMEPLAYMANUAL); exit(0); } void listMaps() { - printf("\n"); - printf("Blob Wars, Episode I - Metal Blob Solid (Version %.2f, Release %d)\n", VERSION, RELEASE); - printf("Copyright (C) 2004 Parallel Realities\n"); - printf("Licensed under the GNU General Public License (GPL)\n\n"); + showVersion(); - printf("Available Maps\n"); - printf("\tdata/arcticWastes\n"); - printf("\tdata/assimilator\n"); - printf("\tdata/caves1\n"); - printf("\tdata/caves2\n"); - printf("\tdata/caves3\n"); - printf("\tdata/caves4\n"); - printf("\tdata/comm\n"); - printf("\tdata/finalBattle\n"); - printf("\tdata/floodedTunnel1\n"); - printf("\tdata/floodedTunnel2\n"); - printf("\tdata/floodedTunnel3\n"); - printf("\tdata/floodedTunnel4\n"); - printf("\tdata/grasslands1\n"); - printf("\tdata/grasslands2\n"); - printf("\tdata/grasslands3\n"); - printf("\tdata/hq\n"); - printf("\tdata/icecave1\n"); - printf("\tdata/icecave2\n"); - printf("\tdata/spaceStation\n"); - printf("\tdata/supply\n"); - printf("\tdata/tomb1\n"); - printf("\tdata/tomb2\n"); - printf("\tdata/tomb3\n"); - printf("\tdata/tomb4\n\n"); + printf(_( + "Available Maps\n" + "\tdata/arcticWastes\n" + "\tdata/assimilator\n" + "\tdata/caves1\n" + "\tdata/caves2\n" + "\tdata/caves3\n" + "\tdata/caves4\n" + "\tdata/comm\n" + "\tdata/finalBattle\n" + "\tdata/floodedTunnel1\n" + "\tdata/floodedTunnel2\n" + "\tdata/floodedTunnel3\n" + "\tdata/floodedTunnel4\n" + "\tdata/grasslands1\n" + "\tdata/grasslands2\n" + "\tdata/grasslands3\n" + "\tdata/hq\n" + "\tdata/icecave1\n" + "\tdata/icecave2\n" + "\tdata/spaceStation\n" + "\tdata/supply\n" + "\tdata/tomb1\n" + "\tdata/tomb2\n" + "\tdata/tomb3\n" + "\tdata/tomb4\n" + "\n")); exit(0); } -void showVersion() -{ - printf("\n"); - printf("Blob Wars, Episode I - Metal Blob Solid (Version %.2f, Release %d)\n", VERSION, RELEASE); - printf("Copyright (C) 2004 Parallel Realities\n"); - printf("Licensed under the GNU General Public License (GPL)\n\n"); -// exit(0); -} - int main(int argc, char *argv[]) { #if !USEPAK debug(("Not Using PAK...\n")); #endif + + #if RELEASE + if (chdir(PAKLOCATION)) + { + perror("Could not chdir to " PAKLOCATION ":"); + return 1; + } + #endif config.engine = &engine; @@ -109,6 +137,7 @@ int main(int argc, char *argv[]) bindtextdomain("blobwars", LOCALEDIR); setlocale(LC_ALL, ""); + setlocale(LC_NUMERIC, "C"); textdomain("blobwars"); atexit(cleanup); @@ -119,25 +148,30 @@ int main(int argc, char *argv[]) int recordMode = REPLAY_MODE::NONE; int requiredSection = SECTION_INTRO; + initConfig(); + for (int i = 1 ; i < argc ; i++) { if (strcmp(argv[i], "-fullscreen") == 0) engine.fullScreen = true; + else if (strcmp(argv[i], "-window") == 0) engine.fullScreen = false; else if (strcmp(argv[i], "-noaudio") == 0) engine.useAudio = 0; else if (strcmp(argv[i], "-mono") == 0) engine.useAudio = 1; - else if (strcmp(argv[i], "-version") == 0) showVersion(); + else if (strcmp(argv[i], "-version") == 0) {showVersion(); exit(0);} else if (strcmp(argv[i], "--help") == 0) showHelp(); - else if (strcmp(argv[i], "-record") == 0) {recordMode = REPLAY_MODE::RECORD; strcpy(replayData.filename, argv[++i]);} - else if (strcmp(argv[i], "-playback") == 0) {recordMode = REPLAY_MODE::PLAYBACK; strcpy(replayData.filename, argv[++i]);} - else if (strcmp(argv[i], "-map") == 0) {game.setMapName(argv[++i]); requiredSection = SECTION_GAME;} + else if (strcmp(argv[i], "-record") == 0) {recordMode = REPLAY_MODE::RECORD; strlcpy(replayData.filename, argv[++i], sizeof replayData.filename);} + else if (strcmp(argv[i], "-playback") == 0) {recordMode = REPLAY_MODE::PLAYBACK; strlcpy(replayData.filename, argv[++i], sizeof replayData.filename);} + else if (strcmp(argv[i], "-map") == 0) {if (argc > i + 1) {game.setMapName(argv[++i]); requiredSection = SECTION_GAME;}} else if (strcmp(argv[i], "-listmaps") == 0) listMaps(); + else if (strcmp(argv[i], "-credits") == 0) requiredSection = SECTION_CREDITS; - #if !USEPAK + #if DEBUG else if (strcmp(argv[i], "-showsprites") == 0) showSprites = true; else if (strcmp(argv[i], "-hub") == 0) hub = true; else if (strcmp(argv[i], "-randomscreens") == 0) graphics.takeRandomScreenShots = true; else if (strcmp(argv[i], "-nomonsters") == 0) engine.devNoMonsters = true; - else if (strcmp(argv[i], "-credits") == 0) requiredSection = SECTION_CREDITS; #endif + + else {fprintf(stderr, "Unknown argument '%s'\n", argv[i]); showHelp();} } switch (recordMode) @@ -148,7 +182,7 @@ int main(int argc, char *argv[]) case REPLAY_MODE::RECORD: requiredSection = SECTION_GAME; - strcpy(replayData.header.map, game.mapName); + strlcpy(replayData.header.map, game.mapName, sizeof replayData.header.map); replayData.header.skill = game.skill = 3; replayData.setMode(REPLAY_MODE::RECORD); break;