/* * LoadSettings: Load all user's settings from INI file. */ void LoadSettings(void) { FontsCreate(False); ColorsCreate(False); CommLoadSettings(); ConfigLoad(); LoadProfaneTerms(); // Restore defaults if they've changed from previous version if (config.ini_version != INI_VERSION) { ColorsRestoreDefaults(); FontsRestoreDefaults(); config.ini_version = INI_VERSION; } }
CShellExt::CShellExt() { AFX_MANAGE_STATE(AfxGetStaticModuleState()); #ifdef _DEBUG TCHAR szProcessName[MAX_PATH]; HANDLE hProcess = GetCurrentProcess(); GetModuleBaseName(hProcess,NULL,szProcessName,sizeof_array(szProcessName)); TRACE(_T("[%s]CShellExt::CShellExt(%d->%d) process=%s\n"),APP_NAME,g_cRefThisDll,g_cRefThisDll+1,szProcessName); #endif m_cRef = 1L; //Inside DCOM参照 m_pDataObj = NULL; g_cRefThisDll++; //オプションを取得 ConfigLoad(); m_fileType = UNKNOWN; m_bMultiSelect = FALSE; m_timestamp.Clear(); }
void Sound_init(UI * ui, bool recording) { // init devices NutLoadConfig(); if (ConfigInit()) { /* No configuration memory, run with factory defaults. */ ConfigResetFactory(); } else { if (ConfigLoad()) { /* No configuration info, use factory defaults. */ ConfigResetFactory(); ConfigSave(); } } ResetDevice(); int i; SoundStruct *ss = malloc( sizeof(SoundStruct) ); ss->buffer = malloc( WIN_SIZE * CEPS_COUNT * sizeof(short) ); ss->ui = ui; ss->recording = recording; ss->ceps_count = 0; ss->dtwTable = malloc( (CEPS_COUNT+1)*sizeof(short*) ); for( i = 0; i< CEPS_COUNT+1; i++) ss->dtwTable[i] = malloc((CEPS_COUNT+1) * sizeof(short)); printf("Create Thread\n"); fflush(stdout); NutThreadCreate("SoundRecord", SoundRecord, (void *)(ss), 2048); NutThreadCreate("SoundFFT", SoundFFT, (void *)(ss), 1024); }
int main(int argc, char *argv[]) { int i; int loaded = 0; printf("C-Dogs SDL Editor\n"); debug(D_NORMAL, "Initialising SDL...\n"); if (SDL_Init(SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO) != 0) { printf("Failed to start SDL!\n"); return -1; } SDL_EnableUNICODE(SDL_ENABLE); printf("Data directory:\t\t%s\n", GetDataFilePath("")); printf("Config directory:\t%s\n\n", GetConfigFilePath("")); EditorBrushInit(&brush); ConfigLoadDefault(&gConfig); ConfigLoad(&gConfig, GetConfigFilePath(CONFIG_FILE)); gConfig.Graphics.IsEditor = 1; if (!PicManagerTryInit( &gPicManager, "graphics/cdogs.px", "graphics/cdogs2.px")) { exit(0); } memcpy(origPalette, gPicManager.palette, sizeof origPalette); BuildTranslationTables(gPicManager.palette); TextManagerInit(&gTextManager, GetDataFilePath("graphics/font.px")); GraphicsInit(&gGraphicsDevice); // Hardcode config settings gConfig.Graphics.ScaleMode = SCALE_MODE_NN; gConfig.Graphics.ScaleFactor = 2; gConfig.Graphics.Res.x = 400; gConfig.Graphics.Res.y = 300; GraphicsInitialize( &gGraphicsDevice, &gConfig.Graphics, gPicManager.palette, 0); if (!gGraphicsDevice.IsInitialized) { printf("Video didn't init!\n"); exit(EXIT_FAILURE); } TextManagerGenerateOldPics(&gTextManager, &gGraphicsDevice); PicManagerLoadDir(&gPicManager, GetDataFilePath("graphics")); BulletInitialize(); WeaponInitialize(&gGunDescriptions, GetDataFilePath("guns.json")); CampaignInit(&gCampaign); MissionInit(&lastMission); MissionInit(¤tMission); PlayerDataInitialize(); MapInit(&gMap); // initialise UI collections // Note: must do this after text init since positions depend on text height sObjs = CreateMainObjs(&gCampaign, &brush, Vec2iNew(320, 240)); memset(&sDrawObjs, 0, sizeof sDrawObjs); DrawBufferInit(&sDrawBuffer, Vec2iNew(X_TILES, Y_TILES), &gGraphicsDevice); // Reset campaign (graphics init may have created dummy campaigns) CampaignSettingTerminate(&gCampaign.Setting); CampaignSettingInit(&gCampaign.Setting); EventInit(&gEventHandlers, NULL, false); for (i = 1; i < argc; i++) { if (!loaded) { debug(D_NORMAL, "Loading map %s\n", argv[i]); memset(lastFile, 0, sizeof(lastFile)); strncpy(lastFile, argv[i], sizeof(lastFile) - 1); if (strchr(lastFile, '.') == NULL && sizeof lastFile - strlen(lastFile) > 3) { strcat(lastFile, ".CPN"); } if (MapNewLoad(lastFile, &gCampaign.Setting) == 0) { loaded = 1; } debug(D_NORMAL, "Loaded map %s\n", argv[i]); } } debug(D_NORMAL, "Starting editor\n"); EditCampaign(); MapTerminate(&gMap); WeaponTerminate(&gGunDescriptions); CampaignTerminate(&gCampaign); MissionTerminate(&lastMission); MissionTerminate(¤tMission); DrawBufferTerminate(&sDrawBuffer); GraphicsTerminate(&gGraphicsDevice); PicManagerTerminate(&gPicManager); TextManagerTerminate(&gTextManager); UIObjectDestroy(sObjs); CArrayTerminate(&sDrawObjs); EditorBrushTerminate(&brush); SDL_Quit(); exit(EXIT_SUCCESS); }
int main(int argc, char *argv[]) { UNUSED(argc); UNUSED(argv); if (SDL_Init(SDL_INIT_TIMER | SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) != 0) { fprintf(stderr, "Could not initialise SDL: %s\n", SDL_GetError()); return -1; } if (SDLNet_Init() == -1) { fprintf(stderr, "SDLNet_Init: %s\n", SDLNet_GetError()); exit(EXIT_FAILURE); } if (!SDL_SetVideoMode(320, 200, 0, 0)) { fprintf(stderr, "Could not set video mode: %s\n", SDL_GetError()); SDL_Quit(); exit(-1); } ConfigLoadDefault(&gConfig); ConfigLoad(&gConfig, GetConfigFilePath(CONFIG_FILE)); EventInit(&gEventHandlers, NULL, false); NetInputClient client; NetInputClientInit(&client); NetInputClientConnect(&client, 0x7F000001); // localhost printf("Press esc to exit\n"); Uint32 ticksNow = SDL_GetTicks(); Uint32 ticksElapsed = 0; for (;;) { Uint32 ticksThen = ticksNow; ticksNow = SDL_GetTicks(); ticksElapsed += ticksNow - ticksThen; if (ticksElapsed < 1000 / FPS_FRAMELIMIT) { SDL_Delay(1); debug(D_VERBOSE, "Delaying 1 ticksNow %u elapsed %u\n", ticksNow, ticksElapsed); continue; } EventPoll(&gEventHandlers, SDL_GetTicks()); int cmd = GetOnePlayerCmd( &gEventHandlers, &gConfig.Input.PlayerKeys[0], false, INPUT_DEVICE_KEYBOARD, 0); if (cmd) { printf("Sending %s + %s\n", CmdStr(cmd & (CMD_LEFT | CMD_RIGHT | CMD_UP | CMD_DOWN)), CmdStr(cmd & (CMD_BUTTON1 | CMD_BUTTON2 | CMD_BUTTON3 | CMD_BUTTON4 | CMD_ESC))); NetInputClientSend(&client, cmd); } // Check keyboard escape if (KeyIsPressed(&gEventHandlers.keyboard, SDLK_ESCAPE)) { break; } ticksElapsed -= 1000 / FPS_FRAMELIMIT; } NetInputClientTerminate(&client); EventTerminate(&gEventHandlers); SDLNet_Quit(); SDL_Quit(); return 0; }
int main(int argc, char *argv[]) { int wait = 0; int controllerFlag = SDL_INIT_GAMECONTROLLER; credits_displayer_t creditsDisplayer; memset(&creditsDisplayer, 0, sizeof creditsDisplayer); custom_campaigns_t campaigns; memset(&campaigns, 0, sizeof campaigns); int forceResolution = 0; int err = 0; const char *loadCampaign = NULL; ENetAddress connectAddr; memset(&connectAddr, 0, sizeof connectAddr); srand((unsigned int)time(NULL)); LogInit(); PrintTitle(); if (getenv("DEBUG") != NULL) { debug = true; char *dbg; if ((dbg = getenv("DEBUG_LEVEL")) != NULL) { debug_level = CLAMP(atoi(dbg), D_NORMAL, D_MAX); } } SetupConfigDir(); gConfig = ConfigLoad(GetConfigFilePath(CONFIG_FILE)); LoadCredits(&creditsDisplayer, colorPurple, colorDarker); AutosaveInit(&gAutosave); AutosaveLoad(&gAutosave, GetConfigFilePath(AUTOSAVE_FILE)); if (enet_initialize() != 0) { LOG(LM_MAIN, LL_ERROR, "An error occurred while initializing ENet."); err = EXIT_FAILURE; goto bail; } NetClientInit(&gNetClient); // Print command line char buf[CDOGS_PATH_MAX]; buf[0] = '\0'; for (int i = 0; i < argc; i++) { strcat(buf, " "); // HACK: for OS X, blank out the -psn_XXXX argument so that it doesn't // break arg parsing #ifdef __APPLE__ if (strncmp(argv[i], "-psn", strlen("-psn")) == 0) { argv[i] = ""; } #endif strcat(buf, argv[i]); } LOG(LM_MAIN, LL_INFO, "Command line (%d args):%s", argc, buf); { struct option longopts[] = { {"fullscreen", no_argument, NULL, 'f'}, {"scale", required_argument, NULL, 's'}, {"screen", required_argument, NULL, 'c'}, {"forcemode", no_argument, NULL, 'o'}, {"nosound", no_argument, NULL, 'n'}, {"nojoystick", no_argument, NULL, 'j'}, {"wait", no_argument, NULL, 'w'}, {"shakemult", required_argument, NULL, 'm'}, {"connect", required_argument, NULL, 'x'}, {"debug", required_argument, NULL, 'd'}, {"log", required_argument, NULL, 1000}, {"help", no_argument, NULL, 'h'}, {0, 0, NULL, 0} }; int opt = 0; int idx = 0; while ((opt = getopt_long(argc, argv, "fs:c:onjwm:xd\0h", longopts, &idx)) != -1) { switch (opt) { case 'f': ConfigGet(&gConfig, "Graphics.Fullscreen")->u.Bool.Value = true; break; case 's': ConfigSetInt(&gConfig, "Graphics.ScaleFactor", atoi(optarg)); break; case 'c': sscanf(optarg, "%dx%d", &ConfigGet(&gConfig, "Graphics.ResolutionWidth")->u.Int.Value, &ConfigGet(&gConfig, "Graphics.ResolutionHeight")->u.Int.Value); LOG(LM_MAIN, LL_DEBUG, "Video mode %dx%d set...", ConfigGetInt(&gConfig, "Graphics.ResolutionWidth"), ConfigGetInt(&gConfig, "Graphics.ResolutionHeight")); break; case 'o': forceResolution = 1; break; case 'n': LOG(LM_MAIN, LL_INFO, "Sound to 0 volume"); ConfigGet(&gConfig, "Sound.SoundVolume")->u.Int.Value = 0; ConfigGet(&gConfig, "Sound.MusicVolume")->u.Int.Value = 0; break; case 'j': debug(D_NORMAL, "nojoystick\n"); controllerFlag = 0; break; case 'w': wait = 1; break; case 'm': { ConfigGet(&gConfig, "Graphics.ShakeMultiplier")->u.Int.Value = MAX(atoi(optarg), 0); printf("Shake multiplier: %d\n", ConfigGetInt(&gConfig, "Graphics.ShakeMultiplier")); } break; case 'h': PrintHelp(); goto bail; case 'd': // Set debug level debug = true; debug_level = CLAMP(atoi(optarg), D_NORMAL, D_MAX); break; case 1000: { char *comma = strchr(optarg, ','); if (comma) { // Set logging level for a single module // The module and level are comma separated *comma = '\0'; const LogLevel ll = StrLogLevel(comma + 1); LogModuleSetLevel(StrLogModule(optarg), ll); printf("Logging %s at %s\n", optarg, LogLevelName(ll)); } else { // Set logging level for all modules const LogLevel ll = StrLogLevel(optarg); for (int i = 0; i < (int)LM_COUNT; i++) { LogModuleSetLevel((LogModule)i, ll); } printf("Logging everything at %s\n", LogLevelName(ll)); } } break; case 'x': if (enet_address_set_host(&connectAddr, optarg) != 0) { printf("Error: unknown host %s\n", optarg); } break; default: PrintHelp(); // Ignore unknown arguments break; } } if (optind < argc) { // non-option ARGV-elements for (; optind < argc; optind++) { // Load campaign loadCampaign = argv[optind]; } } } debug(D_NORMAL, "Initialising SDL...\n"); const int sdlFlags = SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_HAPTIC; if (SDL_Init(sdlFlags | controllerFlag) != 0) { LOG(LM_MAIN, LL_ERROR, "Could not initialise SDL: %s", SDL_GetError()); err = EXIT_FAILURE; goto bail; } if (SDLJBN_Init() != 0) { LOG(LM_MAIN, LL_ERROR, "Could not initialise SDLJBN: %s", SDLJBN_GetError()); err = EXIT_FAILURE; goto bail; } SDL_EventState(SDL_DROPFILE, SDL_DISABLE); GetDataFilePath(buf, ""); LOG(LM_MAIN, LL_INFO, "data dir(%s)", buf); LOG(LM_MAIN, LL_INFO, "config dir(%s)", GetConfigFilePath("")); SoundInitialize(&gSoundDevice, "sounds"); if (!gSoundDevice.isInitialised) { LOG(LM_MAIN, LL_ERROR, "Sound initialization failed!"); } LoadHighScores(); debug(D_NORMAL, "Loading song lists...\n"); LoadSongs(); MusicPlayMenu(&gSoundDevice); EventInit(&gEventHandlers, NULL, NULL, true); NetServerInit(&gNetServer); if (wait) { printf("Press the enter key to continue...\n"); getchar(); } if (!PicManagerTryInit( &gPicManager, "graphics/cdogs.px", "graphics/cdogs2.px")) { LOG(LM_MAIN, LL_ERROR, "Failed to initialize graphics"); err = EXIT_FAILURE; goto bail; } memcpy(origPalette, gPicManager.palette, sizeof(origPalette)); GraphicsInit(&gGraphicsDevice, &gConfig); GraphicsInitialize(&gGraphicsDevice, forceResolution); if (!gGraphicsDevice.IsInitialized) { LOG(LM_MAIN, LL_WARN, "Cannot initialise video; trying default config"); ConfigResetDefault(ConfigGet(&gConfig, "Graphics")); GraphicsInit(&gGraphicsDevice, &gConfig); GraphicsInitialize(&gGraphicsDevice, forceResolution); } if (!gGraphicsDevice.IsInitialized) { LOG(LM_MAIN, LL_ERROR, "Video didn't init!"); err = EXIT_FAILURE; goto bail; } FontLoadFromJSON(&gFont, "graphics/font.png", "graphics/font.json"); PicManagerLoadDir(&gPicManager, "graphics"); ParticleClassesInit(&gParticleClasses, "data/particles.json"); AmmoInitialize(&gAmmo, "data/ammo.json"); BulletAndWeaponInitialize( &gBulletClasses, &gGunDescriptions, "data/bullets.json", "data/guns.json"); CharacterClassesInitialize(&gCharacterClasses, "data/character_classes.json"); LoadPlayerTemplates( &gPlayerTemplates, &gCharacterClasses, PLAYER_TEMPLATE_FILE); PickupClassesInit( &gPickupClasses, "data/pickups.json", &gAmmo, &gGunDescriptions); MapObjectsInit(&gMapObjects, "data/map_objects.json"); CollisionSystemInit(&gCollisionSystem); CampaignInit(&gCampaign); LoadAllCampaigns(&campaigns); PlayerDataInit(&gPlayerDatas); GrafxMakeRandomBackground( &gGraphicsDevice, &gCampaign, &gMission, &gMap); debug(D_NORMAL, ">> Entering main loop\n"); // Attempt to pre-load campaign if requested if (loadCampaign != NULL) { LOG(LM_MAIN, LL_INFO, "Loading campaign %s...", loadCampaign); gCampaign.Entry.Mode = strstr(loadCampaign, "/" CDOGS_DOGFIGHT_DIR "/") != NULL ? GAME_MODE_DOGFIGHT : GAME_MODE_NORMAL; CampaignEntry entry; if (!CampaignEntryTryLoad(&entry, loadCampaign, GAME_MODE_NORMAL) || !CampaignLoad(&gCampaign, &entry)) { LOG(LM_MAIN, LL_ERROR, "Failed to load campaign %s", loadCampaign); } } else if (connectAddr.host != 0) { if (NetClientTryScanAndConnect(&gNetClient, connectAddr.host)) { ScreenWaitForCampaignDef(); } else { printf("Failed to connect\n"); } } LOG(LM_MAIN, LL_INFO, "Starting game"); MainLoop(&creditsDisplayer, &campaigns); bail: debug(D_NORMAL, ">> Shutting down...\n"); MapTerminate(&gMap); PlayerDataTerminate(&gPlayerDatas); MapObjectsTerminate(&gMapObjects); PickupClassesTerminate(&gPickupClasses); ParticleClassesTerminate(&gParticleClasses); AmmoTerminate(&gAmmo); WeaponTerminate(&gGunDescriptions); BulletTerminate(&gBulletClasses); CharacterClassesTerminate(&gCharacterClasses); MissionOptionsTerminate(&gMission); NetClientTerminate(&gNetClient); atexit(enet_deinitialize); EventTerminate(&gEventHandlers); GraphicsTerminate(&gGraphicsDevice); PicManagerTerminate(&gPicManager); FontTerminate(&gFont); AutosaveSave(&gAutosave, GetConfigFilePath(AUTOSAVE_FILE)); AutosaveTerminate(&gAutosave); ConfigSave(&gConfig, GetConfigFilePath(CONFIG_FILE)); SavePlayerTemplates(&gPlayerTemplates, PLAYER_TEMPLATE_FILE); CArrayTerminate(&gPlayerTemplates); FreeSongs(&gMenuSongs); FreeSongs(&gGameSongs); SaveHighScores(); UnloadCredits(&creditsDisplayer); UnloadAllCampaigns(&campaigns); CampaignTerminate(&gCampaign); SoundTerminate(&gSoundDevice, true); ConfigDestroy(&gConfig); SDLJBN_Quit(); SDL_Quit(); return err; }
BOOL ASENSOR::Open( BOOL reset ) { BOOL ok; STRING file; char *path; int step,i; if( STR_null(ObjectName) ) { ASENSOR_errorf("ASENSOR::Open() Sensor name not set.\n"); return(FALSE); } for( ok=TRUE,step=ASENSOR_OPEN_CONFIGURATION; ((step <= ASENSOR_OPEN_VARIABLES) && ok); step++ ) { switch( step ) { case ASENSOR_OPEN_CONFIGURATION : strncpy(file,STR_stringf("%s.CFG",ObjectName),STRLEN); if( (path=FILE_Calibration(file)) == NULL ) { ASENSOR_errorf("ASENSOR::Open() Cannot find configuration file: %s\n",file); ok = FALSE; break; } strncpy(file,path,STRLEN); ok = ConfigLoad(file); break; case ASENSOR_OPEN_CALIBRATION : // Default identity calibration matrix for sensor. Calibration = I(DAQ_ChannelCount); if( !CalibrationFlags[ASENSOR_CALIBRATION_MTX] ) { break; } strncpy(file,STR_stringf("%s.MTX",ObjectName),STRLEN); if( (path=FILE_Calibration(file)) == NULL ) { ASENSOR_errorf("ASENSOR::Open() Cannot find calibration file: %s\n",file); ok = FALSE; break; } strncpy(file,path,STRLEN); if( !matrix_read(file,Calibration) ) { ASENSOR_errorf("ASENSOR::Open() Cannot load calibration file: %s\n",file); ok = FALSE; break; } // For some reason the ATI DAQ F/T sensor calibration matrix must be transposed. if( DeviceType == ASENSOR_DEVICE_DAQFT ) { Calibration.transpose(); } break; case ASENSOR_OPEN_GAIN : Gain.dim(1,DAQ_ChannelCount); Gain.ones(); if( !CalibrationFlags[ASENSOR_CALIBRATION_GAIN] ) { break; } strncpy(file,STR_stringf("%s.K",ObjectName),STRLEN); if( (path=FILE_Calibration(file)) == NULL ) { ASENSOR_errorf("ASENSOR::Open() Cannot find gain file: %s\n",file); ok = FALSE; break; } strncpy(file,path,STRLEN); if( !matrix_read(file,Gain) ) { ASENSOR_errorf("ASENSOR::Open() Cannot load gain file: %s\n",file); ok = FALSE; break; } MakeColumnVector(Gain); // For some reason the ATI DAQ F/T sensor gains must be inverted. if( DeviceType == ASENSOR_DEVICE_DAQFT ) { for( i=1; (i <= DAQ_ChannelCount); i++ ) { if( Gain(1,i) != 0.0 ) { Gain(1,i) = 1.0 / Gain(1,i); } } } break; case ASENSOR_OPEN_BIAS : BiasVolts.dim(1,DAQ_ChannelCount); BiasVolts.zeros(); if( !CalibrationFlags[ASENSOR_CALIBRATION_BIAS] ) { break; } strncpy(file,STR_stringf("%s.B",ObjectName),STRLEN); if( (path=FILE_Calibration(file)) == NULL ) { ASENSOR_errorf("ASENSOR::Open() Cannot find bias file: %s\n",file); ok = FALSE; break; } strncpy(file,path,STRLEN); if( !matrix_read(file,BiasVolts) ) { ASENSOR_errorf("ASENSOR::Open() Cannot load bias file: %s\n",file); ok = FALSE; break; } strncpy(BiasFile,file,STRLEN); strncpy(BiasHistoryFile,STR_stringf("%sH",file),STRLEN); MakeColumnVector(BiasVolts); //disp(BiasVolts); break; case ASENSOR_OPEN_VARIABLES : SensorVolts.dim(1,DAQ_ChannelCount); SensorValues.dim(1,DAQ_ChannelCount); for( i=0; (i < DAQ_ChannelCount); i++ ) { BiasData[i] = new DATAPROC(STR_stringf("%s[%i]",ObjectName,i),BiasPoints,DATAPROC_FLAG_CIRCULAR); if( VoltPoints > 0 ) { VoltData[i] = new DATAPROC(STR_stringf("%s[%i]",ObjectName,i),VoltPoints,DATAPROC_FLAG_CIRCULAR); } } if( WindowSize > 0 ) { Window = new WINFIT(ObjectName,WindowSize,DAQ_ChannelCount); } break; } STR_printf(ok,ASENSOR_debugf,ASENSOR_errorf,"ASENSOR::Open() %s[%d] %s.\n",ASENSOR_OpenText[step],step,STR_OkFailed(ok)); } if( ok ) { OpenFlag = TRUE; if( reset ) { BiasResetAnterograde(); } } return(ok); }
/*++ DbInit Initializes the procedure table and database connection pool. Arguments: getProc - Pointer to ioFTPD's GetProc function. Return Values: If the function succeeds, the return value is nonzero (true). If the function fails, the return value is zero (false). --*/ BOOL FCALL DbInit(Io_GetProc *getProc) { DWORD result; #if 0 // Wait for debugger to be attached before proceeding WaitForDebugger(); #endif TRACE("refCount=%d", refCount); // Only initialize the database pool once if (InterlockedIncrement(&refCount) > 1) { TRACE("Already initialized, returning."); return TRUE; } // Initialize procedure table result = ProcTableInit(getProc); if (result != ERROR_SUCCESS) { TRACE("Unable to initialize procedure table (error %lu).", result); return FALSE; } // Initialize configuration structures result = ConfigInit(); if (result != ERROR_SUCCESS) { TRACE("Unable to initialize configuration system (error %lu).", result); return FALSE; } // Initialize logging system result = LogInit(); if (result != ERROR_SUCCESS) { TRACE("Unable to initialize logging system (error %lu).", result); return FALSE; } // // Now that the logging system has been initialized, the LOG_* macros are // available for use. Prior to this point, the TRACE macro must be used. // // Load configuration options result = ConfigLoad(); if (result != ERROR_SUCCESS) { TRACE("Unable to load configuration (error %lu).", result); DbFinalize(); return FALSE; } // Create connection pool result = PoolCreate(&dbPool, dbConfigPool.minimum, dbConfigPool.average, dbConfigPool.maximum, dbConfigPool.timeoutMili, ConnectionOpen, ConnectionCheck, ConnectionClose, NULL); if (result != ERROR_SUCCESS) { LOG_ERROR("Unable to initialize connection pool (error %lu).", result); DbFinalize(); return FALSE; } LOG_INFO("nxMyDB v%s loaded, using MySQL Client Library v%s.", STRINGIFY(VERSION), mysql_get_client_info()); return TRUE; }
UNUSED(deviceIndex); return NULL; } PicManager gPicManager; FEATURE(1, "Load default config") SCENARIO("Load a default config") { Config config1, config2; GIVEN("two configs") GIVEN_END WHEN("I load them both with defaults") // Note: default loaded before loading from file config1 = ConfigLoad(NULL); config2 = ConfigLoad(NULL); WHEN_END THEN("the two configs should have the same values") SHOULD_INT_EQUAL( ConfigGetBool(&config1, "Game.FriendlyFire"), ConfigGetBool(&config2, "Game.FriendlyFire")); SHOULD_INT_EQUAL( ConfigGetInt(&config1, "Graphics.Brightness"), ConfigGetInt(&config2, "Graphics.Brightness")); THEN_END } SCENARIO_END FEATURE_END
void main(int argc, char *argv[]) { // Process command-line parameteres. if (!Parameters(argc, argv)) { exit(0); } // Check disk space and file's existence. if (!DATAFILE_Check(DataFile)) { exit(0); } // Initialize configuration file variables once. ConfigInit(); // Load the first (and possibly the only) configuration file. if (!ConfigLoad(ConfigFile[0])) { exit(0); } printf("--------------------configload finished\n"); // Initialize variables, etc. Initialize(); // Create list of trials to run. TrialList(); // Position of sphere in simulation. SpherePosition.zeros(); SpherePosition(3, 1) = -20.0; SpherePosition(2, 1) -= 20; SpherePosition_Goal.zeros(); //RobotFakePosition.zeros(); SpherePosition_Goal(3, 1) = -20.0; SpherePosition_Goal(1, 1) += 20.0; //printf("================%f, %f, %f", SpherePosition(1, 1), SpherePosition(2, 1), SpherePosition(3, 1)); // Start robot. //if (RobotStart()) if (DeviceStart()) { // Start graphics. if (GraphicsStart()) { GraphicsMainLoop(); } /* // from DynamicLearning.cpp // Start the graphics system. if (GraphicsStart(argc, argv)) { // The experiment is run as part of graphics processing. GraphicsMainLoop(); } */ } }
BOOL TrialList(void) { int item, i; BOOL ok = TRUE; TotalTrials = 0; // Single or multiple configuration file paradigm? if (ConfigFiles == 1) { TotalTrials = Trials; ConfigIndex = 0; } else { // Loop over configuration files, counting the number of trials. for (ok = TRUE, ConfigIndex = 1; (ok && (ConfigIndex < ConfigFiles)); ConfigIndex++) { if (!ConfigLoad(ConfigFile[ConfigIndex])) { ok = FALSE; continue; } TotalTrials += Trials; printf("%d %s Trials=%d TotalTrials=%d\n", ConfigIndex, ConfigFile[ConfigIndex], Trials, TotalTrials); } ConfigIndex = 1; } if ((TotalTrials == 0) || !ok) { return(FALSE); } // Set rows of TrialData to the number of trials. TrialData.SetRows(TotalTrials); printf("Making list of %d trials (ESCape to abort)...\n", TotalTrials); TotalTrials = 0; TotalNullTrials = 0; TotalExposureTrials = 0; TotalCatchTrials = 0; // Loop over configuration files, appending each to growing trial list. for (ok = TRUE; (ok && (ConfigIndex < ConfigFiles)); ConfigIndex++) { if (ConfigIndex > 0) { if (!ConfigLoad(ConfigFile[ConfigIndex])) { ok = FALSE; continue; } } // Create subset of trials for this configuration file. if (!TrialListSubset()) { ok = FALSE; continue; } TotalTrials += Trials; TotalNullTrials += NullTrial; TotalExposureTrials += ExposureTrial; TotalCatchTrials += CatchTrial; printf("%d %s Trials=%d TotalTrials=%d\n", ConfigIndex, ConfigFile[ConfigIndex], Trials, TotalTrials); } if (!ok) { return(FALSE); } printf("%d Total Trials, %d Null, %d Exposure, %d Catch.\n", TotalTrials, TotalNullTrials, TotalExposureTrials, TotalCatchTrials); // Total number of trails. Trials = TotalTrials; // Save trial list to file. ok = DATAFILE_Save(TrialListFile, TrialData); printf("%s %s Trials=%d.\n", TrialListFile, STR_OkFailed(ok), TrialData.GetRows()); // Reset trial number, etc. Trial = 1; TrialSetup(); ExperimentTimer.Reset(); StateNext(STATE_INITIALIZE); return(TRUE); }