/*
	example how it works
	
	=== ./ezquake -game testmod -config testcfg
	homedir/testmod/testcfg.cfg (fullname)
	homedir/testcfg.cfg (fullname_moddefault)
	quakedir/testmod/configs/testcfg.cfg
	quakedir/ezquake/configs/testcfg.cfg
	built-in ezquake config
*/
void LoadConfig_f(void)
{
	FILE	*f = NULL;
	char	filename[MAX_PATH] = {0},
			fullname[MAX_PATH] = {0},
			fullname_moddefault[MAX_PATH] = {0},
			*arg1;
	int		use_home;

	arg1 = COM_SkipPathWritable(Cmd_Argv(1));

	snprintf(filename, sizeof(filename) - 4, "%s", arg1[0] ? arg1 : MAIN_CONFIG_FILENAME); // use config.cfg if no params was specified

	COM_ForceExtensionEx (filename, ".cfg", sizeof (filename));
	use_home = cfg_use_home.integer || !host_everything_loaded;

	// home
	snprintf(fullname, sizeof(fullname), "%s/%s%s", com_homedir, (strcmp(com_gamedirfile, "qw") == 0) ? "" : va("%s/", com_gamedirfile), filename);
	snprintf(fullname_moddefault, sizeof(fullname_moddefault), "%s/%s", com_homedir, filename);

	if(use_home && !((f = fopen(fullname, "rb")) && cfg_use_gamedir.integer) && !(f = fopen(fullname_moddefault, "rb")))
	{
		use_home = false;
	}

	// basedir
	snprintf(fullname, sizeof(fullname), "%s/%s/configs/%s", com_basedir, (strcmp(com_gamedirfile, "qw") == 0) ? "ezquake" : com_gamedirfile, filename);
	snprintf(fullname_moddefault, sizeof(fullname_moddefault), "%s/ezquake/configs/%s", com_basedir, filename);

	if(!use_home && !((f = fopen(fullname, "rb")) && cfg_use_gamedir.integer) && !(f = fopen(fullname_moddefault, "rb")))
	{
		Com_Printf("Couldn't load %s %s\n", filename, (cfg_use_gamedir.integer) ? "(using gamedir search)": "(not using gamedir search)");
		return;
	}

	con_suppress = true;
	ResetConfigs(false, true);
	con_suppress = false;

	if(use_home)
		Com_Printf("Loading %s%s (Using Home Directory) ...\n", (strcmp(com_gamedirfile, "qw") == 0) ? "" : va("%s/",com_gamedirfile), filename);
	else
		Com_Printf("Loading %s/configs/%s ...\n", (strcmp(com_gamedirfile, "qw") == 0) ? "ezquake" : com_gamedirfile, filename);
	
	Cbuf_AddText ("cl_warncmd 0\n");

	LoadCfg(f);
	fclose(f);

	/* johnnycz:
	  This should be called with TP_ExecTrigger("f_cfgload"); but definition
	  of f_cfgload alias is stored in config which is waiting to be executed
	  in command queue so nothing would happen. We have to add f_cfgload as
	  a standard command to the queue. Since warnings are off this is OK but
	  regarding to other f_triggers non-standard.
	*/
	Cbuf_AddText ("f_cfgload\n");

	Cbuf_AddText ("cl_warncmd 1\n");
}
Example #2
0
int main(int argc, char *argv[])
{
   LoadCfg(); // load the configuration file

   // Initialize defaults, video and audio
   if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER | SDL_INIT_NOPARACHUTE) == -1) {
      fprintf(stderr, "FATAL ERROR: Could not initialize SDL: %s.\n", SDL_GetError());
      exit(1);
   }

   // Initialize the display in a 640x480 24-bit mode
   int f = (atoi(cfg.Get("OPTIONS", "FullScreen", "0")) > 0);
   if (f) {
      f = SDL_FULLSCREEN;
   }

   gpScreen = SDL_SetVideoMode(640, 480, 24, SDL_HWSURFACE | f);

   if (gpScreen == NULL) {
      gpScreen = SDL_SetVideoMode(640, 480, 24, SDL_SWSURFACE | f);
   }

   if (gpScreen == NULL) {
      fprintf(stderr, "FATAL ERROR: Could not set video mode: %s\n", SDL_GetError());
      exit(1);
   }

   SDL_WM_SetCaption("Dou Di Zhu", NULL);

   g_fNoSound = (atoi(cfg.Get("OPTIONS", "NoSound", "0")) > 0);

   // Open the audio device
   if (SOUND_OpenAudio(22050, AUDIO_S16, 1, 1024) < 0) {
      fprintf(stderr, "WARNING: Couldn't open audio device: %s\n", SDL_GetError());
      g_fNoSound = true;
   }

   InitTextMessage();
   SDL_SetEventFilter(EventFilter);

   gpGeneral = new CGeneral;
   gpGame = new CGame;

   g_UI.OpeningUI();

   UserQuit();

   return 255;
}
Example #3
0
    /*
     *  ウインドウ作成
     */
void OnCreate(AG_Widget *parent)
{
        BOOL        flag;
/*
 * ワークエリア初期化
 */
        nErrorCode = 0;
        bMenuLoop = FALSE;
        bCloseReq = FALSE;
        bSync = TRUE;
        bSyncDisasm[0] = TRUE;
        bSyncDisasm[1] = TRUE;
        bActivate = FALSE;
        AG_MutexInit(&VMMutex);
/*
 * コンポーネント初期化
 */
        LoadCfg();
        InitDraw();
#ifdef _USE_OPENCL
        if(AG_UsingGL(NULL) != 0) {
	   do {
	       SDL_Delay(1);
	   } while(bInitCL);
	}
#endif   
        InitSnd();
        InitKbd();
        InitJoy();
        InitSch();
//        CreateStatus();

/*
 * 仮想マシン初期化
 */
        if (!system_init()) {
                nErrorCode = 1;
                return;
        }
/*
 * 直後、リセット
 */
        ApplyCfg();
        system_reset();

/*
 * コンポーネントセレクト
 */
        flag = TRUE;
        if (!SelectDraw()) {
                flag = FALSE;
        }
        if (!SelectSnd()) {
                flag = FALSE;
        }
        if (!SelectKbd()) {
                flag = FALSE;
        }
        if (!SelectSch()) {
                flag = FALSE;
        }
        PaintStatus();

/*
 * エラーコードをセットさせ、スタート
 */
        if (!flag) {
                nErrorCode = 2;
        }
}