00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <client/ClientParams.h>
00022 #include <client/ScorchedClient.h>
00023 #include <client/ClientMain.h>
00024 #include <server/ScorchedServer.h>
00025 #include <engine/ModDirs.h>
00026 #include <common/OptionsScorched.h>
00027 #include <common/ARGParser.h>
00028 #include <common/Defines.h>
00029 #include <common/OptionsTransient.h>
00030 #include <graph/OptionsDisplay.h>
00031 #include <locale.h>
00032 #include <math.h>
00033 #include <signal.h>
00034 #include <float.h>
00035 #include <time.h>
00036 #include <common/main.h>
00037 #include <SDL/SDL.h>
00038
00039 void checkLaunchFile(char *progPath)
00040 {
00041 if (!ClientParams::instance()->getNonParam()[0]) return;
00042
00043
00044 FILE *in = fopen(ClientParams::instance()->getNonParam(), "r");
00045 if (!in)
00046 {
00047 S3D::dialogExit(scorched3dAppName, "Failed to open launchfile");
00048 }
00049 char buffer[2048];
00050 if (!fgets(buffer, 2048, in))
00051 {
00052 S3D::dialogExit(scorched3dAppName, "Failed to read launchfile");
00053 }
00054 fclose(in);
00055
00056
00057 ClientParams::instance()->setConnect(buffer);
00058 }
00059
00060 int main(int argc, char *argv[])
00061 {
00062 setlocale(LC_ALL, "C");
00063
00064
00065 run_main(argc, argv, *ClientParams::instance());
00066 checkLaunchFile(argv[0]);
00067
00068
00069
00070 if (!OptionsDisplay::instance()->readOptionsFromFile())
00071 {
00072 return 0;
00073 }
00074
00075
00076 if (ClientParams::instance()->getExitTime() > 0)
00077 {
00078 ClientParams::instance()->setExitTime(
00079 int(ClientParams::instance()->getExitTime() + time(0)));
00080 }
00081
00082
00083 if (!OptionsDisplay::instance()->getHostDescription()[0])
00084 {
00085 OptionsDisplay::instance()->getHostDescriptionEntry().setValue(S3D::getOSDesc());
00086 OptionsDisplay::instance()->getOnlineUserNameEntry().setValue("Player");
00087 }
00088
00089
00090 OptionsDisplay::instance()->writeOptionsToFile();
00091
00092
00093 unsigned int initFlags = SDL_INIT_VIDEO;
00094 if (ClientParams::instance()->getAllowExceptions()) initFlags |= SDL_INIT_NOPARACHUTE;
00095 if (SDL_Init(initFlags) < 0)
00096 {
00097 S3D::dialogExit(
00098 scorched3dAppName,
00099 "This game uses the SDL library to provide graphics.\n"
00100 "The graphics section of this library failed to initialize.");
00101 }
00102
00103 if (!ClientMain::clientMain()) exit(64);
00104
00105
00106
00107 OptionsDisplay::instance()->writeOptionsToFile();
00108
00109 SDL_Quit();
00110 return 0;
00111 }