bool FileLoadTest(const char * a_pszFile1, const char * a_pszFile2) { // ensure that the two files load into simpleini the same CSimpleIniA ini(true, true, true); bool b; try { ini.Reset(); if (ini.LoadFile(a_pszFile1) < 0) throw "Load failed for file 1"; if (ini.SaveFile("test1.ini") < 0) throw "Save failed for file 1"; ini.Reset(); if (ini.LoadFile(a_pszFile2) < 0) throw "Load failed for file 2"; if (ini.SaveFile("test2.ini") < 0) throw "Save failed for file 2"; b = FileComparisonTest("test1.ini", "test2.ini"); DELETE_FILE("test1.ini"); DELETE_FILE("test2.ini"); if (!b) throw "File comparison failed in FileLoadTest"; } catch (...) { return false; } return true; }
void CScheduler::SaveToFile(){ CString temp; Schedule_Struct* schedule; CIni ini(thePrefs.GetConfigFile(), _T("Scheduler")); ini.WriteInt(_T("Count"), GetCount()); for (uint8 i=0; i<GetCount();i++) { schedule=theApp.scheduler->GetSchedule(i); temp.Format(_T("Schedule#%i"),i); ini.WriteString(_T("Title"),schedule->title,temp); ini.WriteInt(_T("Day"),schedule->day); ini.WriteInt(_T("StartTime"),schedule->time); ini.WriteInt(_T("EndTime"),schedule->time2); ini.WriteBool(_T("Enabled"),schedule->enabled); ini.SerGet(false, schedule->actions, ARRSIZE(schedule->actions), _T("Actions")); ini.SerGet(false, schedule->values, ARRSIZE(schedule->values), _T("Values")); } }
/// PUBLIC SLOTS void UFindReplaceTextDialog::setLanguage(QString pathToTheFileLanguage) { emit languageIsChange(pathToTheFileLanguage); pButtonSelectColor->setLanguage(pathToTheFileLanguage); QSettings ini(pathToTheFileLanguage, QSettings::IniFormat); ini.setIniCodec(QTextCodec::codecForName(textCodec.toUtf8())); ini.beginGroup("FindReplaceTextDialog"); labelFind->setText(ini.value("Find").toString()); labelReplaceTo->setText(ini.value("ReplaceTo").toString()); groupBoxDirection->setTitle(ini.value("DirectionFind").toString()); rButtonUp->setText(ini.value("Up").toString()); rButtonDown->setText(ini.value("Down").toString()); groupBoxSettings->setTitle(ini.value("Settings").toString()); checkBoxWholeWords->setText(ini.value("WholeWords").toString()); checkBoxCaseSensitive->setText(ini.value("CaseSensitive").toString()); checkBoxRegExp->setText(ini.value("RegExp").toString()); pButtonFind->setText(ini.value("ButtonFind").toString()); pButtonReplace->setText(ini.value("Replace").toString()); pButtonReplaceAll->setText(ini.value("ReplaceAll").toString()); pButtonClose->setText(ini.value("Close").toString()); pButtonSelectColor->setText(ini.value("SelectColor").toString()); strNoMatchFound = ini.value("NoMatchFound").toString(); strReplaced = ini.value("Replaced").toString(); ini.endGroup(); }
int main() { int ppl,i,j,u,v,w,mn,sum,indx,cs=1,e; char data[22][30]; while(scanf("%d %d",&ppl,&e)==2) { if(ppl==0 && e==0)break; ini(ppl); for(i=1; i<=ppl; i++) scanf("%s",data[i]); for(i=1; i<=e; i++) { scanf("%d %d %d",&u,&v,&w); mat[u][v]=w; mat[v][u]=w; } floyd(ppl); mn=inf; for(i=1; i<=ppl; i++) { sum=0; for(j=1; j<=ppl; j++) sum+=mat[j][i]; if(mn>sum) { mn=sum; indx=i; } } printf("Case #%d : %s\n",cs++,data[indx]); } return 0; }
// ---------------------------------------------------------------------------- // void IniFile::write( LPCSTR filename ) { JsonFileWriter ini( filename ); JsonBuilder json( ini, true ); json.startObject(); json.add( "dmx_required", m_dmx_required ); json.add( "debug", m_debug ); json.add( "venue_filename", m_venue_filename ); json.add( "venue_container", m_venue_container ); json.add( "google_api_key", m_google_api_key ); json.startObject( "videos" ); json.add( "videos_per_track", m_videos_per_track ); json.add( "video_palette_size", m_video_palette_size ); json.endObject( "videos" ); json.startObject( "remote" ); json.add( "enable", m_http_enabled ); json.add( "http_port", m_http_port ); json.endObject( "remote" ); json.startObject( "whiteout_slow" ); json.add( "on_ms", m_whiteout_strobe_slow.getOnMS() ); json.add( "off_ms", m_whiteout_strobe_slow.getOffMS() ); json.add( "fade_in_ms", m_whiteout_strobe_slow.getFadeInMS() ); json.add( "fade_out_ms", m_whiteout_strobe_slow.getFadeOutMS() ); json.endObject( "whiteout_slow" ); json.startObject( "whiteout_fast" ); json.add( "on_ms", m_whiteout_strobe_fast.getOnMS() ); json.add( "off_ms", m_whiteout_strobe_fast.getOffMS() ); json.add( "fade_in_ms", m_whiteout_strobe_fast.getFadeInMS() ); json.add( "fade_out_ms", m_whiteout_strobe_fast.getFadeOutMS() ); json.endObject( "whiteout_fast" ); json.startObject( "music_player" ); json.add( "library", m_music_player_ddl ); json.add( "username", m_music_player_username ); json.endObject( "music_player" ); json.startObject( "hue" ); json.add( "bridge_ip", m_hue_bridge_ip ); json.add( "auto_setup", m_hue_auto_setup ); json.startArray( "ignored_lights" ); for ( UINT id : m_hue_ignored_lights ) json.add( id ); json.endArray( "ignored_lights" ); json.startArray( "allowed_groups" ); for ( CString group : m_hue_allowed_groups ) json.add( group ); json.endArray( "allowed_groups" ); json.endObject( "hue" ); json.endObject(); }
// Service Server // This server will receive its request via req. // req is of type forceController/forceControl: // --------------------------------------------------------------------------- // int32 num_ctrls // string[] type // "force" or "moment" // geometry_msgs/Vector3[] desired // i.e. desired force or moment values. // float64 x // float64 y // float64 z // geometry_msgs/Vector3[] gains // if you want to change the default gains. // float64 x // float64 y // float64 z // --------------------------------------------------------------------------- // And the result is of type res: // --------------------------------------------------------------------------- // float64[] error // sensor_msgs/JointState update_angles // std_msgs/Header header // uint32 seq // time stamp // string frame_id // string[] name // holds baxter joint names: elbow, should, wrist. // float64[] position // holds a delta joint angle update // float64[] velocity // not used // float64[] effort // not used // --------------------------------------------------------------------------- bool controller::execute(forceControl::Request &req, forceControl::Response &res) { ROS_INFO("Received service call"); bool ok = false; std::vector<double> error, js; std::vector<Eigen::VectorXd> dqs; // Initialize vectors dqs.clear(); error.clear(); ini(); js.resize(7); // Check for gain update if(req.gains.size() !=0) updateGains(req.gains, req.type); // Wait for the first joint angles readings while(!ok) { if(jo_ready_) ok = true; } // Check for errors in required number of controller and type size. if(req.desired.size() != req.num_ctrls || req.type.size() != req.num_ctrls) { ROS_ERROR("The type of controller and/or the desired values does not match the number of controllers!"); return false; } // A. Only 1 controller: call primitive controller. Store the delta joint angle update in dqs. for(unsigned int i=0; i<req.num_ctrls; i++) { ROS_INFO("Calling primitive controller %d", i); if(!ComputePrimitiveController(dqs, req.type[i], req.desired[i], error)) { ROS_ERROR("Could not compute angle update for type: %s", req.type[i].c_str()); return false; } } // B. 2 Controllers: call compound controllers if(req.num_ctrls > 1) { // Compute a NullSpaceProjection if(!NullSpaceProjection(dqs, res.update_angles)) { ROS_ERROR("Could not get null space projection"); return false; } } // Add delta joint angles to current joint angles through fill. else res.update_angles = fill(dqs[0]); res.error = error; return true; }
// Saves and loads the relevant part of the config files for MP games // Ensures that others' games don't change our own configuration settings bool reloadMPConfig(void) { QSettings ini(PHYSFS_getWriteDir() + QString("/") + fileName, QSettings::IniFormat); if (ini.status() != QSettings::NoError) { debug(LOG_ERROR, "Could not open configuration file \"%s\"", fileName); return false; } debug(LOG_WZ, "Reloading prefs prefs to registry"); // If we're in-game, we already have our own configuration set, so no need to reload it. if (NetPlay.isHost && !ingame.localJoiningInProgress) { if (bMultiPlayer && !NetPlay.bComms) { // one-player skirmish mode sets game name to "One Player Skirmish", so // reset the name if (ini.contains("gameName")) { sstrcpy(game.name, ini.value("gameName").toString().toUtf8().constData()); } } return true; } // If we're host and not in-game, we can safely save our settings and return. if (NetPlay.isHost && ingame.localJoiningInProgress) { if (bMultiPlayer && NetPlay.bComms) { ini.setValue("gameName", game.name); // last hosted game } else { // One-player skirmish mode sets game name to "One Player Skirmish", so // reset the name if (ini.contains("gameName")) { sstrcpy(game.name, ini.value("gameName").toString().toUtf8().constData()); } } // Set a default map to prevent hosting games without a map. sstrcpy(game.map, "Sk-Rush"); game.hash.setZero(); game.maxPlayers = 4; ini.setValue("power", game.power); // power ini.setValue("base", game.base); // size of base ini.setValue("alliance", game.alliance); // allow alliances return true; } // We're not host, so let's get rid of the host's game settings and restore our own. // game name if (ini.contains("gameName")) { sstrcpy(game.name, ini.value("gameName").toString().toUtf8().constData()); } // Set a default map to prevent hosting games without a map. sstrcpy(game.map, "Sk-Rush"); game.hash.setZero(); game.maxPlayers = 4; game.power = ini.value("power", LEV_MED).toInt(); game.base = ini.value("base", CAMP_BASE).toInt(); game.alliance = ini.value("alliance", NO_ALLIANCES).toInt(); return true; }
void VirtualMachine::RunMain() { IniReader ini(RESOURCE_PATH("common/ini/main.ini")); int debugMode = 1; int runGmLibs = 0; #ifdef FNK_FINAL debugMode = 0; runGmLibs = 1; #endif int fps = ini.GetInt("Window", "FPS"); int gcWorkPerIncrement = ini.GetInt("VirtualMachine", "GC_WorkPerIncrement"); int gcDestructsPerIncrement = ini.GetInt("VirtualMachine", "GC_DestructPerIncrement"); int memUsageSoft = ini.GetInt("VirtualMachine", "MemUsageSoft"); int memUsageHard = ini.GetInt("VirtualMachine", "MemUsageHard"); m_vm->GetGC()->SetWorkPerIncrement(gcWorkPerIncrement); m_vm->GetGC()->SetDestructPerIncrement(gcDestructsPerIncrement); m_vm->SetDesiredByteMemoryUsageSoft(memUsageSoft); m_vm->SetDesiredByteMemoryUsageHard(memUsageHard); m_vm->SetDebugMode(debugMode == 1); m_bUseGmByteCode = runGmLibs == 1; m_dt = 1.0f/fps; // print current setting char buffer[128]; sprintf_s(buffer, "Running at %d hz, VM Debug Mode: %d, VM Run Byte-Code: %d", fps, debugMode, runGmLibs ); m_console.Log(buffer); sprintf_s(buffer, "GC Works Per Increment: %d, GC Destructs Per Increment: %d", gcWorkPerIncrement, gcDestructsPerIncrement ); m_console.Log(buffer); sprintf_s(buffer, "Mem Usage Soft: %d bytes, Mem Usage Hard: %d bytes", memUsageSoft, memUsageHard ); m_console.Log(buffer); // attach debugger if ( m_vm->GetDebugMode() ) m_debugger.Open(m_vm); RegisterLibs(m_vm); // set dt m_vm->GetGlobals()->Set( m_vm, "g_dt", gmVariable(m_dt) ); m_vm->GetGlobals()->Set( m_vm, "g_rendering", gmVariable(0) ); m_vm->GetGlobals()->Set( m_vm, "g_resourcePathPrefix", gmVariable(m_vm->AllocStringObject(RESOURCE_PATH(""))) ); m_threadId = gmCompileStr(m_vm, kEntryFile); printf("'%s' Main thread: %d\n", kEntryFile, m_threadId ); // get draw manager gmVariable drawManagerKey = gmVariable(m_vm->AllocStringObject("g_drawManager")); gmTableObject* drawManager = m_vm->GetGlobals()->Get(drawManagerKey).GetTableObjectSafe(); m_drawManager.Nullify(); if ( drawManager ) { m_drawManager = gmVariable(gmVariable(drawManager)); // grab draw functions gmVariable drawKey = gmVariable(m_vm->AllocStringObject("Draw")); m_drawFunc = drawManager->Get(drawKey).GetFunctionObjectSafe(); gmVariable clearKey = gmVariable(m_vm->AllocStringObject("Clear")); m_clearFunc = drawManager->Get(clearKey).GetFunctionObjectSafe(); } }
/* load the Droid stats for the components from the Access database */ bool loadDroidTemplates(const char *filename) { WzConfig ini(filename, WzConfig::ReadOnlyAndRequired); QStringList list = ini.childGroups(); for (int i = 0; i < list.size(); ++i) { ini.beginGroup(list[i]); DROID_TEMPLATE design; QString droidType = ini.value("type").toString(); design.id = list[i]; design.name = ini.value("name").toString(); if (droidType == "PERSON") design.droidType = DROID_PERSON; else if (droidType == "CYBORG") design.droidType = DROID_CYBORG; else if (droidType == "CYBORG_SUPER") design.droidType = DROID_CYBORG_SUPER; else if (droidType == "CYBORG_CONSTRUCT") design.droidType = DROID_CYBORG_CONSTRUCT; else if (droidType == "CYBORG_REPAIR") design.droidType = DROID_CYBORG_REPAIR; else if (droidType == "TRANSPORTER") design.droidType = DROID_TRANSPORTER; else if (droidType == "SUPERTRANSPORTER") design.droidType = DROID_SUPERTRANSPORTER; else if (droidType == "DROID") design.droidType = DROID_DEFAULT; else ASSERT(false, "No such droid type \"%s\" for %s", droidType.toUtf8().constData(), getID(&design)); design.multiPlayerID = generateNewObjectId(); design.asParts[COMP_BODY] = getCompFromName(COMP_BODY, ini.value("compBody", "ZNULLBODY").toString()); design.asParts[COMP_BRAIN] = getCompFromName(COMP_BRAIN, ini.value("compBrain", "ZNULLBRAIN").toString()); design.asParts[COMP_REPAIRUNIT] = getCompFromName(COMP_REPAIRUNIT, ini.value("compRepair", "ZNULLREPAIR").toString()); design.asParts[COMP_CONSTRUCT] = getCompFromName(COMP_CONSTRUCT, ini.value("compConstruct", "ZNULLCONSTRUCT").toString()); design.asParts[COMP_ECM] = getCompFromName(COMP_ECM, ini.value("compECM", "ZNULLECM").toString()); design.asParts[COMP_SENSOR] = getCompFromName(COMP_SENSOR, ini.value("compSensor", "ZNULLSENSOR").toString()); design.asParts[COMP_PROPULSION] = getCompFromName(COMP_PROPULSION, ini.value("compPropulsion", "ZNULLPROP").toString()); QStringList weapons = ini.value("weapons").toStringList(); for (int j = 0; j < weapons.size(); j++) { design.asWeaps[j] = getCompFromName(COMP_WEAPON, weapons[j]); } design.numWeaps = weapons.size(); design.prefab = true; design.stored = false; design.enabled = true; bool available = ini.value("available", false).toBool(); char const *droidResourceName = getDroidResourceName(list[i].toUtf8().constData()); design.name = droidResourceName != NULL? droidResourceName : GetDefaultTemplateName(&design); ini.endGroup(); for (int i = 0; i < MAX_PLAYERS; ++i) { // Give those meant for humans to all human players. if (NetPlay.players[i].allocated && available) { design.prefab = false; addTemplateToList(&design, &apsDroidTemplates[i]); // This sets up the UI templates for display purposes ONLY--we still only use apsDroidTemplates for making them. // FIXME: Why are we doing this here, and not on demand ? // Only add unique designs to the UI list (Note, perhaps better to use std::map instead?) std::list<DROID_TEMPLATE>::iterator it; for (it = localTemplates.begin(); it != localTemplates.end(); ++it) { DROID_TEMPLATE *psCurr = &*it; if (psCurr->multiPlayerID == design.multiPlayerID) { debug(LOG_ERROR, "Design id:%d (%s) *NOT* added to UI list (duplicate), player= %d", design.multiPlayerID, getName(&design), i); break; } } if (it == localTemplates.end()) { debug(LOG_NEVER, "Design id:%d (%s) added to UI list, player =%d", design.multiPlayerID, getName(&design), i); localTemplates.push_front(design); } } else if (!NetPlay.players[i].allocated) // AI template { design.prefab = true; // prefabricated templates referenced from VLOs addTemplateToList(&design, &apsDroidTemplates[i]); } } debug(LOG_NEVER, "Droid template found, Name: %s, MP ID: %d, ref: %u, ID: %s, prefab: %s, type:%d (loading)", getName(&design), design.multiPlayerID, design.ref, getID(&design), design.prefab ? "yes":"no", design.droidType); } return true; }
int main() { std::vector<int> pulseData; std::vector<int>::iterator pulseBegin; std::vector<int>::iterator pulsePair; INI ini("./gage2scope.ini"); if (!ini.INI_Status()) { std::cout << "Invalid values in INI" << std::endl; } std::cout << "VT value " << ini.vt << std::endl; std::cout << "width value " << ini.width << std::endl; std::cout << "pulse delta value " << ini.pulse_delta << std::endl; std::cout << "drop_ratio value " << ini.drop_ratio << std::endl; std::cout << "below_drop_ratio value " << ini.below_drop_ratio << std::endl; /* int vtvalue=GetProfileInt("CONFIG", "vt", -1,"./tony.ini"); if (vtvalue == -1) { std::cout << "Couldnt get VT" << std::endl; exit(0); } */ /* double dropratio=GetProfileLong("CONFIG", "drop_ratio", -1,"./tony.ini"); if (dropratio == -1) { std::cout << "Couldnt get VT" << std::endl; exit(0); } char *endptr; int base=0; errno=0; int dropratio=strtol("aa",&endptr, base); if ((errno == ERANGE && (dropratio == LONG_MAX || dropratio == LONG_MIN)) || (errno != 0 && dropratio == 0)) { if (errno != 0) { std::cout << "errno " << errno << "Couldnt convert" << std::endl; exit(0); } std::cout << "errno " << errno << "dropratio value " << dropratio << std::endl; */ pulseData.push_back(1); pulseData.push_back(2); pulseData.push_back(2); pulseData.push_back(2); pulseData.push_back(5); pulseData.push_back(5); pulseData.push_back(3); pulseData.push_back(20); pulseData.push_back(26); pulseData.push_back(50); pulseData.push_back(50); pulseData.push_back(100); pulseData.push_back(100); pulseData.push_back(400); pulseData.push_back(200); pulseData.push_back(40); pulseData.push_back(1); pulseData.push_back(1); std::cout << "===== data check ================" << std::endl; std::cout << "size is " << pulseData.size() << std::endl; for (int i=0;i<pulseData.size();i++) std::cout << "element" << i << " " << pulseData[i] << std::endl; std::cout << "===== end data check ================" << std::endl; }
int main() { char c[200],a[200],temp[50],home[50],*args[50]; stk S; pid_t p; int j,i,fd,n,flag=0,pid,num_arg,status,block; sigset(SIGCHLD, sig_handler); ini(&S); getCurrentDirectory(home); while(1) { if(!flag){ getCurrentDirectory(temp); printf("myshell[%s]:- ", temp); gets(a); num_arg = parse_cmd(a,args);} flag=0; if(a[0]== '\0'); else if(feof(stdin)) {printf("\n"); exit(0);} else if(num_arg>1&&strstr(args[1],"&")){ pid = fork(); if(pid==0) {signal(SIGALRM,times_up); alarm (10); execvp(args[0], args); //execlp(arg[0], "/usr", (char *) 0); while(1); exit(0); } else{ printf("Waiting for child, pid = %d\n",pid); waitpid(pid, &status, 0); printf("child process finished of pid = %d\n",pid); } } else if(!strcmp(a,"ls")){ j=strlen(a); push(a,&S,j); system("ls"); } else if(!strcmp(args[0],"history")) { i=0;n=0; if(num_arg==1) pop(&S); else{ strcpy(c,args[1]); while(c[i]!='\0') { n=n*10+c[i++]-48;} pop1(&S,n);} j=strlen(a);push(a,&S,j); } else if(!strcmp(args[0],"issue")) { n=0;push(a,&S,j);strcpy(c,args[1]); while(c[i]!='\0') { n=n*10+c[i++]-48;} j=strlen(a); strcpy(a,S.a[n-1]); flag=1; } else if(!strcmp(args[0],"cd")) {j=strlen(a);push(a,&S,j); if(num_arg==1) changeDirectory1(home); else{ changeDirectory(args[1]); }} else if (!strcmp(args[0],"rm")){ push(a,&S,j); fd=unlink(args[1]); printf("File deleted\n"); if(fd==-1) printf("Can't delete file\n"); } else if(!strcmp(a,"quit")) exit(0); else printf("not a recognized command\n"); } printf("\n"); return 0; }
void Program::loadSettings() { std::wstring filePath = boost::str(boost::wformat(L"%1%\\audio.ini") % savePath); if (!boost::filesystem::exists(filePath)) { std::fstream fileOut(filePath.c_str(), std::ios_base::out); fileOut.close(); } CSimpleIniW ini(true, false, true); SI_Error error = ini.LoadFile(filePath.c_str()); if (!error) { bool modified = false; const wchar_t *value[8]; value[0] = ini.GetValue(L"settings", L"allow_radio_station_adjustment"); value[1] = ini.GetValue(L"settings", L"connect_attempts"); value[2] = ini.GetValue(L"settings", L"connect_delay"); value[3] = ini.GetValue(L"settings", L"connect_timeout"); value[4] = ini.GetValue(L"settings", L"enable_logging"); value[5] = ini.GetValue(L"settings", L"network_timeout"); value[6] = ini.GetValue(L"settings", L"stream_files_from_internet"); value[7] = ini.GetValue(L"settings", L"transfer_files_from_server"); if (value[0]) { try { settings->allowRadioStationAdjustment = boost::lexical_cast<bool>(value[0]); } catch (boost::bad_lexical_cast &) {} } else { ini.SetValue(L"settings", L"allow_radio_station_adjustment", boost::lexical_cast<std::wstring>(settings->allowRadioStationAdjustment).c_str()); modified = true; } if (value[1]) { try { settings->connectAttempts = boost::lexical_cast<unsigned int>(value[1]); } catch (boost::bad_lexical_cast &) {} } else { ini.SetValue(L"settings", L"connect_attempts", boost::lexical_cast<std::wstring>(settings->connectAttempts).c_str()); modified = true; } if (value[2]) { try { settings->connectDelay = boost::lexical_cast<unsigned int>(value[2]) * 1000; } catch (boost::bad_lexical_cast &) {} } else { ini.SetValue(L"settings", L"connect_delay", boost::lexical_cast<std::wstring>(settings->connectDelay / 1000).c_str()); modified = true; } if (value[3]) { try { settings->connectTimeout = boost::lexical_cast<unsigned int>(value[3]) * 1000; } catch (boost::bad_lexical_cast &) {} } else { ini.SetValue(L"settings", L"connect_timeout", boost::lexical_cast<std::wstring>(settings->connectTimeout / 1000).c_str()); modified = true; } if (value[4]) { try { settings->enableLogging = boost::lexical_cast<bool>(value[4]); } catch (boost::bad_lexical_cast &) {} } else { ini.SetValue(L"settings", L"enable_logging", boost::lexical_cast<std::wstring>(settings->enableLogging).c_str()); modified = true; } if (value[5]) { try { settings->networkTimeout = boost::lexical_cast<unsigned int>(value[5]) * 1000; } catch (boost::bad_lexical_cast &) {} if (settings->networkTimeout < 20000) { settings->networkTimeout = 20000; } } else { ini.SetValue(L"settings", L"network_timeout", boost::lexical_cast<std::wstring>(settings->networkTimeout / 1000).c_str()); modified = true; } if (value[6]) { try { settings->streamFiles = boost::lexical_cast<bool>(value[6]); } catch (boost::bad_lexical_cast &) {} } else { ini.SetValue(L"settings", L"stream_files_from_internet", boost::lexical_cast<std::wstring>(settings->streamFiles).c_str()); modified = true; } if (value[7]) { try { settings->transferFiles = boost::lexical_cast<bool>(value[7]); } catch (boost::bad_lexical_cast &) {} } else { ini.SetValue(L"settings", L"transfer_files_from_server", boost::lexical_cast<std::wstring>(settings->transferFiles).c_str()); modified = true; } if (modified) { ini.SaveFile(filePath.c_str()); } } if (settings->enableLogging) { createLogFile(); } }
bool initTemplates() { WzConfig ini("userdata/" + QString(rulesettag) + "/templates.json", WzConfig::ReadOnly); if (!ini.status()) { debug(LOG_WZ, "Could not open %s", ini.fileName().toUtf8().constData()); return false; } int version = ini.value("version", 0).toInt(); if (version == 0) { return true; // too old version } ini.beginArray("templates"); while (ini.remainingArrayItems()) { DROID_TEMPLATE design = loadTemplateCommon(ini); design.multiPlayerID = generateNewObjectId(); design.prefab = false; // not AI template design.stored = true; if (!(asBodyStats + design.asParts[COMP_BODY])->designable || !(asPropulsionStats + design.asParts[COMP_PROPULSION])->designable || (design.asParts[COMP_BRAIN] > 0 && !(asBrainStats + design.asParts[COMP_BRAIN])->designable) || (design.asParts[COMP_REPAIRUNIT] > 0 && !(asRepairStats + design.asParts[COMP_REPAIRUNIT])->designable) || (design.asParts[COMP_ECM] > 0 && !(asECMStats + design.asParts[COMP_ECM])->designable) || (design.asParts[COMP_SENSOR] > 0 && !(asSensorStats + design.asParts[COMP_SENSOR])->designable) || (design.asParts[COMP_CONSTRUCT] > 0 && !(asConstructStats + design.asParts[COMP_CONSTRUCT])->designable) || (design.numWeaps > 0 && !(asWeaponStats + design.asWeaps[0])->designable) || (design.numWeaps > 1 && !(asWeaponStats + design.asWeaps[1])->designable) || (design.numWeaps > 2 && !(asWeaponStats + design.asWeaps[2])->designable)) { debug(LOG_ERROR, "Template %s from stored templates cannot be designed", design.name.toUtf8().constData()); ini.nextArrayItem(); continue; } bool valid = intValidTemplate(&design, ini.value("name").toString().toUtf8().constData(), false, selectedPlayer); if (!valid) { debug(LOG_ERROR, "Invalid template %s from stored templates", design.name.toUtf8().constData()); ini.nextArrayItem(); continue; } DROID_TEMPLATE *psDestTemplate = NULL; for (auto &keyvaluepair : droidTemplates[selectedPlayer]) { psDestTemplate = keyvaluepair.second; // Check if template is identical to a loaded template if (psDestTemplate->droidType == design.droidType && psDestTemplate->name.compare(design.name) == 0 && psDestTemplate->numWeaps == design.numWeaps && psDestTemplate->asWeaps[0] == design.asWeaps[0] && psDestTemplate->asWeaps[1] == design.asWeaps[1] && psDestTemplate->asWeaps[2] == design.asWeaps[2] && psDestTemplate->asParts[COMP_BODY] == design.asParts[COMP_BODY] && psDestTemplate->asParts[COMP_PROPULSION] == design.asParts[COMP_PROPULSION] && psDestTemplate->asParts[COMP_REPAIRUNIT] == design.asParts[COMP_REPAIRUNIT] && psDestTemplate->asParts[COMP_ECM] == design.asParts[COMP_ECM] && psDestTemplate->asParts[COMP_SENSOR] == design.asParts[COMP_SENSOR] && psDestTemplate->asParts[COMP_CONSTRUCT] == design.asParts[COMP_CONSTRUCT] && psDestTemplate->asParts[COMP_BRAIN] == design.asParts[COMP_BRAIN]) { break; } psDestTemplate = NULL; } if (psDestTemplate) { psDestTemplate->stored = true; // assimilate it ini.nextArrayItem(); continue; // next! } design.enabled = allowDesign; copyTemplate(selectedPlayer, &design); localTemplates.push_back(design); ini.nextArrayItem(); } ini.endArray(); return true; }
void main() { int keyLemmy = 0x4C; int keyHooker = 0x48; int keyBike = 0x42; int keySmoke = 0x4F; int keyDrink = 0x4B; int keyGuitar = 0x49; int keyShirt = 0x4A; int keyStop = 0x51; char iniPath[260]; GetFullPathName("LemmyKilmister.ini", 261, iniPath, NULL); IniReader ini(iniPath); if (ini.fileExists()) { ini.readInt("Controls", "Lemmy", 0x4C, 16, keyLemmy); ini.readInt("Controls", "Hooker", 0x48, 16, keyHooker); ini.readInt("Controls", "Bike", 0x42, 16, keyBike); ini.readInt("Controls", "Smoke", 0x4F, 16, keySmoke); ini.readInt("Controls", "Drink", 0x4B, 16, keyDrink); ini.readInt("Controls", "Guitar", 0x49, 16, keyGuitar); ini.readInt("Controls", "Shirt", 0x4A, 16, keyShirt); ini.readInt("Controls", "Stop", 0x51, 16, keyStop); } Ped playerPed; Player playerID; Vector3 position; bool widescreen = GRAPHICS::GET_IS_WIDESCREEN(); while (true) { // INIT playerID = PLAYER::PLAYER_ID(); playerPed = PLAYER::PLAYER_PED_ID(); position = ENTITY::GET_ENTITY_COORDS(playerPed, 1); // reset to normal skin if dies or get arrested Hash model = ENTITY::GET_ENTITY_MODEL(playerPed); if (ENTITY::IS_ENTITY_DEAD(playerPed) || PLAYER::IS_PLAYER_BEING_ARRESTED(playerID, TRUE)) { if (model != GAMEPLAY::GET_HASH_KEY("player_zero") && model != GAMEPLAY::GET_HASH_KEY("player_one") && model != GAMEPLAY::GET_HASH_KEY("player_two")) { WAIT(1000); model = GAMEPLAY::GET_HASH_KEY("player_zero"); STREAMING::REQUEST_MODEL(model); while (!STREAMING::HAS_MODEL_LOADED(model)) WAIT(0); PLAYER::SET_PLAYER_MODEL(PLAYER::PLAYER_ID(), model); PED::SET_PED_DEFAULT_COMPONENT_VARIATION(PLAYER::PLAYER_PED_ID()); STREAMING::SET_MODEL_AS_NO_LONGER_NEEDED(model); while (ENTITY::IS_ENTITY_DEAD(PLAYER::PLAYER_PED_ID()) || PLAYER::IS_PLAYER_BEING_ARRESTED(playerID, TRUE)) WAIT(0); } } // CHANGE SKIN if (IsKeyDown(VK_SHIFT) && IsKeyJustUp(keyLemmy)) { DWORD freemodeMale = GAMEPLAY::GET_HASH_KEY((char *)"mp_m_freemode_01"); if (STREAMING::IS_MODEL_IN_CDIMAGE(freemodeMale) && STREAMING::IS_MODEL_VALID(freemodeMale)) { STREAMING::REQUEST_MODEL(freemodeMale); while (!STREAMING::HAS_MODEL_LOADED(freemodeMale)) WAIT(0); PLAYER::SET_PLAYER_MODEL(PLAYER::PLAYER_ID(), freemodeMale); playerPed = PLAYER::PLAYER_PED_ID(); PED::SET_PED_DEFAULT_COMPONENT_VARIATION(playerPed); // CLOTHES and FACE PED::SET_PED_HEAD_BLEND_DATA(playerPed, 0, 0, 0, 0, 0, 0, 1.0, 1.0, 1.0, true); PED::SET_PED_HEAD_OVERLAY(playerPed, 1, 27, 1.0); // bread PED::_0x497BF74A7B9CB952(playerPed, 1, 1, 0, 0); // beard color PED::SET_PED_HEAD_OVERLAY(playerPed, 2, 19, 1.0); // eyebrow PED::_0x497BF74A7B9CB952(playerPed, 2, 1, 0, 0); // eyebrow color PED::SET_PED_HEAD_OVERLAY(playerPed, 3, 14, 1.0); // ageing PED::SET_PED_HEAD_OVERLAY(playerPed, 10, 0, 1.0); // peli PED::_0x497BF74A7B9CB952(playerPed, 10, 1, 0, 0); // peli color PED::SET_PED_COMPONENT_VARIATION(playerPed, 2, 22, 0, 2); // hair PED::_0x4CFFC65454C93A49(playerPed, 0, 0); // hair color PED::SET_PED_COMPONENT_VARIATION(playerPed, 3, 11, 0, 2); // torso PED::SET_PED_COMPONENT_VARIATION(playerPed, 4, 4, 0, 2); // pants PED::SET_PED_COMPONENT_VARIATION(playerPed, 8, 15, 0, 2); // acc //PED::SET_PED_COMPONENT_VARIATION(playerPed, 6, 15, 0, 2); // shoes //PED::SET_PED_COMPONENT_VARIATION(playerPed, 11, 13, 2, 2); // t2 PED::IS_PED_COMPONENT_VARIATION_VALID(playerPed, 6, 37, 0) ? PED::SET_PED_COMPONENT_VARIATION(playerPed, 6, 37, 0, 2) : PED::SET_PED_COMPONENT_VARIATION(playerPed, 6, 15, 0, 2); PED::IS_PED_COMPONENT_VARIATION_VALID(playerPed, 11, 95, 2) ? PED::SET_PED_COMPONENT_VARIATION(playerPed, 11, 95, 1, 2) : PED::SET_PED_COMPONENT_VARIATION(playerPed, 11, 13, 2, 2); // TATTOOS DWORD coll1 = GAMEPLAY::GET_HASH_KEY("multiplayer_overlays"); DWORD tattoo1 = GAMEPLAY::GET_HASH_KEY("FM_Tat_Award_F_001"); PED::_0x5F5D1665E352A839(playerPed, coll1, tattoo1); DWORD coll2 = GAMEPLAY::GET_HASH_KEY("multiplayer_overlays"); DWORD tattoo2 = GAMEPLAY::GET_HASH_KEY("FM_Tat_M_038"); PED::_0x5F5D1665E352A839(playerPed, coll2, tattoo2); // PROPS PED::SET_PED_PROP_INDEX(playerPed, 0, 13, 0, true); // hat PED::SET_PED_PROP_INDEX(playerPed, 1, 5, 0, true); // glasses STREAMING::SET_MODEL_AS_NO_LONGER_NEEDED(freemodeMale); } } // WEAR MOTORHEAD SHIRT if (IsKeyDown(VK_SHIFT) && IsKeyJustUp(keyShirt)) { PED::SET_PED_COMPONENT_VARIATION(PLAYER::PLAYER_PED_ID(), 3, 0, 0, 2); // torso PED::SET_PED_COMPONENT_VARIATION(PLAYER::PLAYER_PED_ID(), 11, 0, 2, 2); // t2 } // SPAWN HEXER MOTORBIKE if (IsKeyDown(VK_SHIFT) && IsKeyJustUp(keyBike)) { // from Alexander Blade native trainer code DWORD model = GAMEPLAY::GET_HASH_KEY((char *)"HEXER"); if (STREAMING::IS_MODEL_IN_CDIMAGE(model) && STREAMING::IS_MODEL_A_VEHICLE(model)) { STREAMING::REQUEST_MODEL(model); while (!STREAMING::HAS_MODEL_LOADED(model)) WAIT(0); Vector3 coords = ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(playerPed, 0.0, 5.0, 0.0); Vehicle veh = VEHICLE::CREATE_VEHICLE(model, coords.x, coords.y, coords.z, 0.0, 1, 1); VEHICLE::SET_VEHICLE_COLOURS(veh, 0, 0); VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(veh); WAIT(0); STREAMING::SET_MODEL_AS_NO_LONGER_NEEDED(model); ENTITY::SET_VEHICLE_AS_NO_LONGER_NEEDED(&veh); } } // SPAWN HOOKERS if (IsKeyDown(VK_SHIFT) && IsKeyJustUp(keyHooker)) { DWORD hooker = GAMEPLAY::GET_HASH_KEY((char *)"s_f_y_hooker_01"); if (STREAMING::IS_MODEL_IN_CDIMAGE(hooker) && STREAMING::IS_MODEL_VALID(hooker)) { STREAMING::REQUEST_MODEL(hooker); while (!STREAMING::HAS_MODEL_LOADED(hooker)) WAIT(0); playerPed = PLAYER::PLAYER_PED_ID(); Vector3 pos = ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(playerPed, 0.0, 3.0, 0.0); Ped ped = PED::CREATE_PED(5, hooker, pos.x, pos.y, pos.z, 1, false, true); // the hooker is YOUR hooker int groupIndex = PED::GET_PED_GROUP_INDEX(playerPed); PED::SET_PED_AS_GROUP_LEADER(playerPed, groupIndex); PED::SET_PED_AS_GROUP_MEMBER(ped, groupIndex); PED::SET_PED_NEVER_LEAVES_GROUP(ped, true); WAIT(100); STREAMING::SET_MODEL_AS_NO_LONGER_NEEDED(hooker); } } // ANIMATIONS // SMOKING if (IsKeyDown(VK_SHIFT) && IsKeyJustUp(keySmoke)) { playerPed = PLAYER::PLAYER_PED_ID(); AI::TASK_START_SCENARIO_IN_PLACE(playerPed, "WORLD_HUMAN_SMOKING", 0, 1); } // DRINKING if (IsKeyDown(VK_SHIFT) && IsKeyJustUp(keyDrink)) { playerPed = PLAYER::PLAYER_PED_ID(); AI::TASK_START_SCENARIO_IN_PLACE(playerPed, "WORLD_HUMAN_DRINKING", 0, 1); } // GUITAR if (IsKeyDown(VK_SHIFT) && IsKeyJustUp(keyGuitar)) { playerPed = PLAYER::PLAYER_PED_ID(); AI::TASK_START_SCENARIO_IN_PLACE(playerPed, "WORLD_HUMAN_MUSICIAN", 0, 1); } // STOP ANIMATIONS if (IsKeyDown(VK_SHIFT) && IsKeyJustUp(keyStop)) { playerPed = PLAYER::PLAYER_PED_ID(); AI::CLEAR_PED_TASKS_IMMEDIATELY(playerPed); } // DEBUGGING /* if (IsKeyDown(0x31)) { playerPed = PLAYER::PLAYER_PED_ID(); int numVar = PED::GET_NUMBER_OF_PED_DRAWABLE_VARIATIONS(playerPed, 0); int face = PED::GET_PED_DRAWABLE_VARIATION(playerPed, 0); int head = PED::GET_PED_DRAWABLE_VARIATION(playerPed, 1); int hair = PED::GET_PED_DRAWABLE_VARIATION(playerPed, 2); int tors = PED::GET_PED_DRAWABLE_VARIATION(playerPed, 3); int leg = PED::GET_PED_DRAWABLE_VARIATION(playerPed, 4); int hand = PED::GET_PED_DRAWABLE_VARIATION(playerPed, 5); int feet = PED::GET_PED_DRAWABLE_VARIATION(playerPed, 6); int eye = PED::GET_PED_DRAWABLE_VARIATION(playerPed, 7); int acc = PED::GET_PED_DRAWABLE_VARIATION(playerPed, 8); int task = PED::GET_PED_DRAWABLE_VARIATION(playerPed, 9); int tex = PED::GET_PED_DRAWABLE_VARIATION(playerPed, 10); int t2 = PED::GET_PED_DRAWABLE_VARIATION(playerPed, 11); int hat = PED::GET_PED_PROP_INDEX(playerPed, 0); int glasses = PED::GET_PED_PROP_INDEX(playerPed, 1); int ov0 = PED::_0xA60EF3B6461A4D43(playerPed, 0); int ov1 = PED::_0xA60EF3B6461A4D43(playerPed, 1); int ov2 = PED::_0xA60EF3B6461A4D43(playerPed, 2); int ov3 = PED::_0xA60EF3B6461A4D43(playerPed, 3); int ov4 = PED::_0xA60EF3B6461A4D43(playerPed, 4); int ov5 = PED::_0xA60EF3B6461A4D43(playerPed, 5); int ov6 = PED::_0xA60EF3B6461A4D43(playerPed, 6); int ov7 = PED::_0xA60EF3B6461A4D43(playerPed, 7); int ov8 = PED::_0xA60EF3B6461A4D43(playerPed, 8); int ov9 = PED::_0xA60EF3B6461A4D43(playerPed, 9); int ov10 = PED::_0xA60EF3B6461A4D43(playerPed, 10); int ov11 = PED::_0xA60EF3B6461A4D43(playerPed, 11); DWORD coll1 = GAMEPLAY::GET_HASH_KEY("mpchristmas2_overlays"); DWORD tattoo1 = GAMEPLAY::GET_HASH_KEY("MP_Xmas2_M_Tat_000"); int zone = PED::_0x9FD452BFBE7A7A8B(coll1, tattoo1); char text1[300], text2[300]; sprintf_s(text1, "FAC:%d HED:%d HAIR:%d TOR:%d LEG:%d HAND:%d FEET:%d EYE:%d ACC:%d TASK:%d TEX:%d TORSO2:%d", face, head, hair, tors, leg, hand, feet, eye, acc, task, tex, t2); draw_text(text1, 0.5, 0, 0.3); sprintf_s(text1, "HAT:%d GLASSES:%d", hat, glasses); draw_text(text1, 0.6, 0, 0.3); sprintf_s(text2, "ov0:%d ov1:%d ov2:%d ov3:%d ov4:%d ov5:%d ov6:%d ov7:%d ov8:%d ov9:%d ov10:%d ov11:%d", ov0, ov1, ov2, ov3, ov4, ov5, ov6, ov7, ov8, ov9, ov10, ov11); draw_text(text2, 0.7, 0, 0.3); } */ WAIT(0); } }
EvaluateObservablePsiBarPsiCorrChiralLeftHandedGauged::EvaluateObservablePsiBarPsiCorrChiralLeftHandedGauged(AnalyzerIOControl* aIOcon, StateDescriptorReader* sdr, EvaluateObservable* obsWeight, EvaluateObservable* obsDetSign, double relStart, double relEnd) : EvaluateObservablePsiBarPsiCorrBase(aIOcon, sdr, obsWeight, obsDetSign, "PsiBarPsiCorrChiralLeftHandedGauged", "pbpcxlg", relStart, relEnd) { int LargestL = getLargestL(SDReader); massAnalyzer = new MassCorrelationMatrixAnalyzer(1, LargestL, true, false, true, false, false, 1, 100000, "Top"); ini(getAnalyzerResultsCount(), obsWeight, obsDetSign); }
EvaluateObservableMultipleTimeScaleIntegration3::EvaluateObservableMultipleTimeScaleIntegration3(AnalyzerIOControl* aIOcon, StateDescriptorReader* sdr, EvaluateObservable* obsWeight, EvaluateObservable* obsDetSign, double relStart, double relEnd) : EvaluateObservable(aIOcon, sdr, "MultipleTimeScaleIntegration3", "msint3", relStart, relEnd) { MultiplePolynomFlag = false; if (SDReader->getSubPolynomCount()>0) MultiplePolynomFlag = true; ini(getAnalyzerResultsCount(), obsWeight, obsDetSign); trajectoryLength = NaN; }
BOOL CTaskbarNotifier::LoadConfiguration(LPCTSTR szFileName) { TCHAR szConfigDir[MAX_PATH]; int nRed, nGreen, nBlue, sRed, sGreen, sBlue; int rcLeft, rcTop, rcRight, rcBottom; int bmpTrasparentRed, bmpTrasparentGreen, bmpTrasparentBlue; int fontSize; CString fontType, bmpFullPath, strBmpFileName; Hide(); m_strConfigFilePath = szFileName; CIni ini(szFileName, _T("CONFIG")); _tcsncpy(szConfigDir, szFileName, _countof(szConfigDir)); szConfigDir[_countof(szConfigDir)-1] = _T('\0'); LPTSTR pszFileName = _tcsrchr(szConfigDir, _T('\\')); if (pszFileName == NULL) return FALSE; *(pszFileName + 1) = _T('\0'); nRed = ini.GetInt(_T("TextNormalRed"),255); nGreen = ini.GetInt(_T("TextNormalGreen"),255); nBlue = ini.GetInt(_T("TextNormalBlue"),255); sRed = ini.GetInt(_T("TextSelectedRed"),255); sGreen = ini.GetInt(_T("TextSelectedGreen"),255); sBlue = ini.GetInt(_T("TextSelectedBlue"),255); bmpTrasparentRed = ini.GetInt(_T("bmpTrasparentRed"),255); bmpTrasparentGreen = ini.GetInt(_T("bmpTrasparentGreen"),0); bmpTrasparentBlue = ini.GetInt(_T("bmpTrasparentBlue"),255); fontType = ini.GetString(_T("FontType"), _T("MS Shell Dlg")); fontSize = ini.GetInt(_T("FontSize"), 8) * 10; m_dwTimeToStay = ini.GetInt(_T("TimeToStay"), 4000); m_dwTimeToShow = ini.GetInt(_T("TimeToShow"), 500); m_dwTimeToHide = ini.GetInt(_T("TimeToHide"), 200); strBmpFileName = ini.GetString(_T("bmpFileName"), _T("")); if (!strBmpFileName.IsEmpty()) { if (PathIsRelative(strBmpFileName)) bmpFullPath.Format(_T("%s%s"), szConfigDir, strBmpFileName); else bmpFullPath = strBmpFileName; } // get text rectangle coordinates rcLeft = ini.GetInt(_T("rcTextLeft"),5); rcTop = ini.GetInt(_T("rcTextTop"),45); rcRight = ini.GetInt(_T("rcTextRight"),220 ); rcBottom = ini.GetInt(_T("rcTextBottom"), 85); if (rcLeft<=0) rcLeft=1; if (rcTop<=0) rcTop=1; if (rcRight<=0) rcRight=1; if (rcBottom<=0) rcBottom=1; SetTextRect(CRect(rcLeft,rcTop,rcRight,rcBottom)); // get close button rectangle coordinates rcLeft = ini.GetInt(_T("rcCloseBtnLeft"),286); rcTop = ini.GetInt(_T("rcCloseBtnTop"),40); rcRight = ini.GetInt(_T("rcCloseBtnRight"), 300); rcBottom = ini.GetInt(_T("rcCloseBtnBottom"), 54); if (rcLeft<=0) rcLeft=1; if (rcTop<=0) rcTop=1; if (rcRight<=0) rcRight=1; if (rcBottom<=0) rcBottom=1; SetCloseBtnRect(CRect(rcLeft,rcTop,rcRight,rcBottom)); // get history button rectangle coordinates rcLeft = ini.GetInt(_T("rcHistoryBtnLeft"),283); rcTop = ini.GetInt(_T("rcHistoryBtnTop"),14); rcRight = ini.GetInt(_T("rcHistoryBtnRight"), 299); rcBottom = ini.GetInt(_T("rcHistoryBtnBottom"), 39); if (rcLeft<=0) rcLeft=1; if (rcTop<=0) rcTop=1; if (rcRight<=0) rcRight=1; if (rcBottom<=0) rcBottom=1; SetHistoryBtnRect(CRect(rcLeft,rcTop,rcRight,rcBottom)); if (bmpFullPath.IsEmpty() || !SetBitmap(bmpFullPath, bmpTrasparentRed, bmpTrasparentGreen, bmpTrasparentBlue)) { CEnBitmap imgTaskbar; if (imgTaskbar.LoadImage(IDR_TASKBAR, _T("GIF"))) { if (!SetBitmap(&imgTaskbar, bmpTrasparentRed, bmpTrasparentGreen, bmpTrasparentBlue)) return FALSE; } } SetTextFont(fontType, fontSize, TN_TEXT_NORMAL,TN_TEXT_UNDERLINE); SetTextColor(RGB(nRed, nGreen, nBlue), RGB(sRed, sGreen, sBlue)); return TRUE; }
int main(int argc, char **argv) { char c, *infn; ifstream ini("\\win3\\win.ini"); ofstream fout("t.sty"); int ln= 0; SPString w; SPStringList l; SPStringList ttfonts; Assoc<SPString> repfnts("", ""); // saves font replacement names if(argc < 2) infn= "test.sty"; else infn= argv[1]; ifstream fin(infn); if(!ini){ cerr << "Can't open \\win3\\win.ini" << endl; exit(1); } if(!fin){ cerr << "Can't open " << infn << endl; exit(1); } if(!fout){ cerr << "Can't open t.sty for write" << endl; exit(1); } cout << "Reading in truetype fonts" << endl; while(ini >> w){ // find the [fonts] section if(w.m("\\[fonts\\]")) break; } // cout << buf << endl; if(!ini.good()){ // checks all file state cerr << "Couldn't find [fonts] section in win.ini" << endl; exit(1); } // make a list of truetype fonts Regexp r1("^([a-zA-Z ]+) \\(([a-zA-Z ]+)\\)="); Regexp r2("^TrueType$"); Regexp r3("\\[.*\\]"); while(ini >> w){ if(w.m(r3)) break; // found the start of another section if(w.m(r1, l) != 3) continue; // ignore this line // cout << "Font match:" << l[1] << ", " << l[2] << endl; if(l[2].m(r2)){ ttfonts.push(l[1]); } } cout << "ttfonts: " << endl << ttfonts << endl; ini.close(); cout << "Looking for non-truetype fonts" << endl; SPString s, fnt, newfnt; SPStringList sl; while(fin >> s){ ln++; // cout << "line " << ln << ": <" << s << ">" << endl; if(s.m("\\[fnt\\]")){ fout << s << endl; // write out [fnt] line // read next line which should have font in it if(!(fin >> s)){ cerr << "Error reading font line " << ln << endl; exit(1); } ln++; fnt= s.split("' '").join(" "); // This trims whitespace // cout << "font name: <" << fnt << ">" << endl; if(!ttfonts.grep("^" + fnt + "$", "i")){ // not a truetype font int pos= s.index(fnt); // get position in string of font if(pos < 0){ cerr << "Couldn't find <" << fnt << "> in string <" << s << "> line " << ln << endl; exit(1); } // See if we already know what to exchange it with if(repfnts.isin(fnt)) // just replace it s.substr(pos, strlen(fnt)) = repfnts(fnt); else{ // need to ask what the new font name will be do{ cout << "Replace font <" << fnt << "> with:"; cout.flush(); cin >> newfnt; if(!(sl=ttfonts.grep("^" + newfnt + "$", "i"))){ cerr << "<" << newfnt << "> is not a valid font" << endl; continue; } break; }while(1); s.substr(pos, strlen(fnt)) = sl[0]; // replace it repfnts(fnt) = sl[0]; // remember for next time } fout << s << endl; }else{
bool T3kSoftlogicDlg::loadModel( QString lpszPathName ) { m_strLoadedModelPathName.clear(); if( !QFile::exists( lpszPathName ) ) return false; QIniFormat ini("hsk"); if( !ini.open( lpszPathName ) ) return false; T3kCommonData::KeyDataMode eMode = T3kCommonData::instance()->getKeyDataMode(); T3kCommonData::instance()->setKeyDataMode( T3kCommonData::KeyDataModeNormal ); double x, y; int nSP; QString strData, strExtra; // load panel info. strData.clear(), strExtra.clear(); QString strPanelName( lpszPathName ); int nR = strPanelName.lastIndexOf( '.' ); int nL = strPanelName.lastIndexOf( '/' ); if( nL < 0 ) nL = strPanelName.lastIndexOf( '\\' ); if( nR >= 0 && nL >= 0 ) { strPanelName = strPanelName.mid( nL+1, nR-nL-1 ); T3kCommonData::instance()->getKeys().setPanelName( strPanelName ); } strData = ini.getValue( "panel_dimension" ); nSP = strData.indexOf( ',' ); if( nSP >= 0 ) { x = strData.left(nSP).toDouble(); y = strData.right(strData.length() - nSP - 1).toDouble(); T3kCommonData::instance()->getKeys().setPanelDimension( x, y ); } strData = ini.getValue( "screen_dimension" ); nSP = strData.indexOf( ',' ); if( nSP >= 0 ) { x = strData.left(nSP).toDouble(); y = strData.right(strData.length() - nSP - 1).toDouble(); T3kCommonData::instance()->getKeys().setScreenDimension( x, y ); } strData = ini.getValue( "screen_offset" ); nSP = strData.indexOf( ',' ); if( nSP >= 0 ) { x = strData.left(nSP).toDouble(); y = strData.right(strData.length() - nSP - 1).toDouble(); T3kCommonData::instance()->getKeys().setScreenOffset( x, y ); } // load softkey strData.clear(), strExtra.clear(); strData = ini.getValue( "softkey" ); strExtra = ini.getValue( "softkey_ext" ); ini.beginGroup( "softlogic_ext" ); T3kCommonData::instance()->getKeys().load(strData, strExtra, &ini); ini.endGroup(); strData.clear(); strData = ini.getValue( "softkey_bind_info" ); T3kCommonData::instance()->getKeys().loadBindInfo(strData); strData.clear(); strData = ini.getValue( "softkey_gpio_info" ); T3kCommonData::instance()->getKeys().loadGPIOInfo(strData); T3kCommonData::instance()->resetCalibrationData(); strData.clear(), strExtra.clear(); strData = ini.getValue( "softlogic" ); ini.beginGroup( "softlogic_ext" ); T3kCommonData::instance()->getLogics().load(strData, &ini); ini.endGroup(); m_pTabKeyDesignWidget->updateDesignWidget(); m_strLoadedModelPathName = lpszPathName; T3kCommonData::instance()->setLoadedModelPathName( m_strLoadedModelPathName ); T3kCommonData::instance()->setKeyDataMode( eMode ); return true; }
void EScene::SaveLTX(LPCSTR map_name, bool bForUndo, bool bForceSaveAll) { VERIFY (map_name); R_ASSERT (!bForUndo); CTimer T; T.Start (); xr_string full_name; full_name = map_name; xr_string part_prefix; bool bSaveMain = true; if (!bForUndo) { if (bSaveMain) { EFS.MarkFile (full_name.c_str(),true); } part_prefix = LevelPartPath(full_name.c_str()); } CInifile ini(full_name.c_str(),FALSE,FALSE,TRUE); if (bSaveMain) { ini.w_u32 ("version","value",CURRENT_FILE_VERSION); m_LevelOp.SaveLTX (ini); m_GUID.SaveLTX (ini,"guid","guid"); ini.w_string ("level_tag","owner",m_OwnerName.c_str()); ini.w_u32 ("level_tag","create_time",m_CreateTime); ini.w_fvector3 ("camera","hpb",EDevice.m_Camera.GetHPB()); ini.w_fvector3 ("camera","pos",EDevice.m_Camera.GetPosition()); for(ObjectIt SO=m_ESO_SnapObjects.begin(); SO!=m_ESO_SnapObjects.end(); ++SO) { ini.w_string ("snap_objects",(*SO)->Name,NULL); } } m_SaveCache.clear (); SceneToolsMapPairIt _I = m_SceneTools.begin(); SceneToolsMapPairIt _E = m_SceneTools.end(); for (; _I!=_E; ++_I) { if ( (_I->first!=OBJCLASS_DUMMY) && _I->second && _I->second->IsEnabled() && _I->second->IsEditable() ) { if (bForUndo) { if (_I->second->IsNeedSave()) _I->second->SaveStream (m_SaveCache); }else { // !ForUndo xr_string part_name = part_prefix + _I->second->ClassName() + ".part"; if(_I->second->can_use_inifile()) { EFS.MarkFile (part_name.c_str(),true); SaveToolLTX (_I->second->ClassID, part_name.c_str()); } //can_use_ini_file else { _I->second->SaveStream (m_SaveCache); EFS.MarkFile (part_name.c_str(),true); IWriter* FF = FS.w_open (part_name.c_str()); R_ASSERT (FF); FF->open_chunk (CHUNK_TOOLS_GUID); FF->w (&m_GUID,sizeof(m_GUID)); FF->close_chunk (); FF->open_chunk (CHUNK_TOOLS_DATA+_I->first); FF->w (m_SaveCache.pointer(),m_SaveCache.size()); FF->close_chunk (); FS.w_close (FF); }// ! can_use_ini_file } m_SaveCache.clear (); } } if (!bForUndo) { m_RTFlags.set (flRT_Unsaved,FALSE); Msg ("Saving time: %3.2f sec",T.GetElapsed_sec()); } }
bool initTemplates() { WzConfig ini("userdata/" + QString(rulesettag) + "/templates.ini"); if (ini.status() != QSettings::NoError) { debug(LOG_FATAL, "Could not open templates.ini"); return false; } QStringList list = ini.childGroups(); for (int i = 0; i < list.size(); ++i) { ini.beginGroup(list[i]); DROID_TEMPLATE design; design.droidType = (DROID_TYPE)ini.value("droidType").toInt(); design.multiPlayerID = generateNewObjectId(); design.asParts[COMP_BODY] = getCompFromName(COMP_BODY, ini.value("body", QString("ZNULLBODY")).toString()); design.asParts[COMP_BRAIN] = getCompFromName(COMP_BRAIN, ini.value("brain", QString("ZNULLBRAIN")).toString()); design.asParts[COMP_PROPULSION] = getCompFromName(COMP_PROPULSION, ini.value("propulsion", QString("ZNULLPROP")).toString()); design.asParts[COMP_REPAIRUNIT] = getCompFromName(COMP_REPAIRUNIT, ini.value("repair", QString("ZNULLREPAIR")).toString()); design.asParts[COMP_ECM] = getCompFromName(COMP_ECM, ini.value("ecm", QString("ZNULLECM")).toString()); design.asParts[COMP_SENSOR] = getCompFromName(COMP_SENSOR, ini.value("sensor", QString("ZNULLSENSOR")).toString()); design.asParts[COMP_CONSTRUCT] = getCompFromName(COMP_CONSTRUCT, ini.value("construct", QString("ZNULLCONSTRUCT")).toString()); design.asWeaps[0] = getCompFromName(COMP_WEAPON, ini.value("weapon/1", QString("ZNULLWEAPON")).toString()); design.asWeaps[1] = getCompFromName(COMP_WEAPON, ini.value("weapon/2", QString("ZNULLWEAPON")).toString()); design.asWeaps[2] = getCompFromName(COMP_WEAPON, ini.value("weapon/3", QString("ZNULLWEAPON")).toString()); design.numWeaps = ini.value("weapons").toInt(); design.prefab = false; // not AI template design.stored = true; if (!(asBodyStats + design.asParts[COMP_BODY])->designable || !(asPropulsionStats + design.asParts[COMP_PROPULSION])->designable || (design.asParts[COMP_BRAIN] > 0 && !(asBrainStats + design.asParts[COMP_BRAIN])->designable) || (design.asParts[COMP_REPAIRUNIT] > 0 && !(asRepairStats + design.asParts[COMP_REPAIRUNIT])->designable) || (design.asParts[COMP_ECM] > 0 && !(asECMStats + design.asParts[COMP_ECM])->designable) || (design.asParts[COMP_SENSOR] > 0 && !(asSensorStats + design.asParts[COMP_SENSOR])->designable) || (design.asParts[COMP_CONSTRUCT] > 0 && !(asConstructStats + design.asParts[COMP_CONSTRUCT])->designable) || (design.numWeaps > 0 && !(asWeaponStats + design.asWeaps[0])->designable) || (design.numWeaps > 1 && !(asWeaponStats + design.asWeaps[1])->designable) || (design.numWeaps > 2 && !(asWeaponStats + design.asWeaps[2])->designable)) { debug(LOG_ERROR, "Template %d / %s from stored templates cannot be designed", i, list[i].toUtf8().constData()); continue; } bool valid = intValidTemplate(&design, ini.value("name").toString().toUtf8().constData(), false, selectedPlayer); if (!valid) { debug(LOG_ERROR, "Invalid template %d / %s from stored templates", i, list[i].toUtf8().constData()); continue; } DROID_TEMPLATE *psDestTemplate = apsDroidTemplates[selectedPlayer]; while (psDestTemplate != NULL) { // Check if template is identical to a loaded template if (psDestTemplate->droidType == design.droidType && psDestTemplate->name.compare(design.name) == 0 && psDestTemplate->numWeaps == design.numWeaps && psDestTemplate->asWeaps[0] == design.asWeaps[0] && psDestTemplate->asWeaps[1] == design.asWeaps[1] && psDestTemplate->asWeaps[2] == design.asWeaps[2] && psDestTemplate->asParts[COMP_BODY] == design.asParts[COMP_BODY] && psDestTemplate->asParts[COMP_PROPULSION] == design.asParts[COMP_PROPULSION] && psDestTemplate->asParts[COMP_REPAIRUNIT] == design.asParts[COMP_REPAIRUNIT] && psDestTemplate->asParts[COMP_ECM] == design.asParts[COMP_ECM] && psDestTemplate->asParts[COMP_SENSOR] == design.asParts[COMP_SENSOR] && psDestTemplate->asParts[COMP_CONSTRUCT] == design.asParts[COMP_CONSTRUCT] && psDestTemplate->asParts[COMP_BRAIN] == design.asParts[COMP_BRAIN]) { break; } psDestTemplate = psDestTemplate->psNext; } if (psDestTemplate) { psDestTemplate->stored = true; // assimilate it ini.endGroup(); continue; // next! } design.enabled = allowDesign; addTemplateToList(&design, &apsDroidTemplates[selectedPlayer]); sendTemplate(selectedPlayer, &design); localTemplates.push_back(design); ini.endGroup(); } return true; }
//---------------------------------------------------- bool EScene::LoadLTX(LPCSTR map_name, bool bUndo) { DWORD version = 0; if (!map_name||(0==map_name[0])) return false; xr_string full_name; full_name = map_name; ELog.Msg( mtInformation, "EScene: loading '%s'", map_name); if (FS.exist(full_name.c_str())) { CTimer T; T.Start(); // lock main level CInifile ini(full_name.c_str()); version = ini.r_u32("version","value"); if (version!=CURRENT_FILE_VERSION) { ELog.DlgMsg( mtError, "EScene: unsupported file version. Can't load Level."); UI->UpdateScene(); return false; } m_LevelOp.ReadLTX (ini); Fvector hpb, pos; pos = ini.r_fvector3("camera","pos"); hpb = ini.r_fvector3("camera","hpb"); EDevice.m_Camera.Set(hpb,pos); EDevice.m_Camera.SetStyle(EDevice.m_Camera.GetStyle()); EDevice.m_Camera.SetStyle(EDevice.m_Camera.GetStyle()); m_GUID.LoadLTX (ini,"guid","guid"); m_OwnerName = ini.r_string("level_tag","owner"); m_CreateTime = ini.r_u32("level_tag","create_time"); SceneToolsMapPairIt _I = m_SceneTools.begin(); SceneToolsMapPairIt _E = m_SceneTools.end(); for (; _I!=_E; ++_I) { if (_I->second) { { if (!bUndo && _I->second->IsEnabled() && (_I->first!=OBJCLASS_DUMMY)) { xr_string fn = LevelPartName(map_name, _I->first).c_str(); LoadLevelPartLTX (_I->second, fn.c_str()); } } } } if(ini.section_exist("snap_objects")) { CInifile::Sect& S = ini.r_section("snap_objects"); CInifile::SectCIt Si = S.Data.begin(); CInifile::SectCIt Se = S.Data.end(); for(;Si!=Se; ++Si) { CCustomObject* O = FindObjectByName(Si->first.c_str(),OBJCLASS_SCENEOBJECT); if (!O) ELog.Msg(mtError,"EScene: Can't find snap object '%s'.",Si->second.c_str()); else m_ESO_SnapObjects.push_back(O); } UpdateSnapList(); } Msg("EScene: %d objects loaded, %3.2f sec", ObjCount(), T.GetElapsed_sec() ); UI->UpdateScene(true); SynchronizeObjects(); if (!bUndo) m_RTFlags.set(flRT_Unsaved|flRT_Modified,FALSE); return true; }else { ELog.Msg(mtError,"Can't find file: '%s'",map_name); } return false; }
// //////////////////////////////////////////////////////////////////////////// bool saveConfig() { QSettings ini(PHYSFS_getWriteDir() + QString("/") + fileName, QSettings::IniFormat); if (ini.status() != QSettings::NoError) { debug(LOG_ERROR, "Could not open configuration file \"%s\"", fileName); return false; } debug(LOG_WZ, "Writing prefs to registry \"%s\"", ini.fileName().toUtf8().constData()); // ////////////////////////// // voicevol, fxvol and cdvol ini.setValue("voicevol", (int)(sound_GetUIVolume() * 100.0)); ini.setValue("fxvol", (int)(sound_GetEffectsVolume() * 100.0)); ini.setValue("cdvol", (int)(sound_GetMusicVolume() * 100.0)); ini.setValue("music_enabled", war_GetMusicEnabled()); ini.setValue("width", war_GetWidth()); ini.setValue("height", war_GetHeight()); ini.setValue("bpp", pie_GetVideoBufferDepth()); ini.setValue("fullscreen", war_getFullscreen()); ini.setValue("language", getLanguage()); // dont save out the cheat mode. if (getDifficultyLevel() != DL_KILLER && getDifficultyLevel() != DL_TOUGH) { ini.setValue("difficulty", getDifficultyLevel()); // level } ini.setValue("showFPS", (SDWORD)showFPS); ini.setValue("scroll",(SDWORD)scroll_speed_accel); // scroll ini.setValue("shake",(SDWORD)(getShakeStatus())); // screenshake ini.setValue("mouseflip",(SDWORD)(getInvertMouseStatus())); // flipmouse ini.setValue("nomousewarp", (SDWORD)getMouseWarp()); // mouse warp ini.setValue("RightClickOrders",(SDWORD)(getRightClickOrders())); ini.setValue("MiddleClickRotate",(SDWORD)(getMiddleClickRotate())); ini.setValue("showFPS", (SDWORD)showFPS); ini.setValue("shadows",(SDWORD)(getDrawShadows())); // shadows ini.setValue("sound", (SDWORD)war_getSoundEnabled()); ini.setValue("FMVmode",(SDWORD)(war_GetFMVmode())); // sequences ini.setValue("scanlines", (SDWORD)war_getScanlineMode()); ini.setValue("subtitles",(SDWORD)(seq_GetSubtitles())); // subtitles ini.setValue("radarObjectMode",(SDWORD)bEnemyAllyRadarColor); // enemy/allies radar view ini.setValue("radarTerrainMode",(SDWORD)radarDrawMode); ini.setValue("trapCursor", war_GetTrapCursor()); ini.setValue("vsync", war_GetVsync()); ini.setValue("textureSize", getTextureSize()); ini.setValue("FSAA", war_getFSAA()); ini.setValue("UPnP", (SDWORD)NetPlay.isUPNP); ini.setValue("rotateRadar", rotateRadar); ini.setValue("PauseOnFocusLoss", war_GetPauseOnFocusLoss()); ini.setValue("masterserver_name", NETgetMasterserverName()); ini.setValue("masterserver_port", NETgetMasterserverPort()); ini.setValue("gameserver_port", NETgetGameserverPort()); if (!bMultiPlayer) { ini.setValue("colour", getPlayerColour(0)); // favourite colour. } else { if (NetPlay.isHost && ingame.localJoiningInProgress) { if (bMultiPlayer && NetPlay.bComms) { ini.setValue("gameName", game.name); // last hosted game } ini.setValue("mapName", game.map); // map name ini.setValue("mapHash", game.hash.toString().c_str()); // map hash ini.setValue("maxPlayers", game.maxPlayers); // maxPlayers ini.setValue("power", game.power); // power ini.setValue("base", game.base); // size of base ini.setValue("alliance", game.alliance); // allow alliances ini.setValue("scavengers", game.scavengers); } ini.setValue("playerName", (char*)sPlayer); // player name } ini.setValue("colourMP", war_getMPcolour()); ini.sync(); return true; }
int main() { CLI cli; FileFormatter fileFormatter; //Get INI filename std::vector<std::string> inis = cli.command("ls *.ini"); if(inis.size() > 1) exitWithError("Multiple INI files found; exiting.\n\n"); //create INI object from INI name INI ini((char*)inis[0].c_str()); if(ini.INI_Status() == false) exitWithError("INI misconfigured.\n\n"); FILE* fp; //iterate through .dat files std::vector<std::string> datFiles = cli.command("ls *.dat"); if(datFiles.size() < 1) exitWithError("No .dat files found.\n\n"); for(int i = 0; i < datFiles.size(); i++) { fp = fopen(datFiles[i].c_str(),"r"); if(fp == NULL) exitWithError("Failed to open file.\n\n"); std::vector<int> readings; char str[10]; while(fgets(str,10,fp)) { try { readings.push_back(std::stoi(str)); } catch(const std::invalid_argument& ia) { break; } } fileFormatter.negate(readings); std::vector<int> smooth_readings = fileFormatter.smooth(readings); DataHandler dataHandler(ini); std::vector<int>::iterator cur_pos = smooth_readings.begin(); std::cout << datFiles[i] << std::endl; while(cur_pos != smooth_readings.end()) { std::vector<int>::iterator* pulse = dataHandler.nextPulse(cur_pos,smooth_readings.end()); if(pulse[0] == smooth_readings.end() && pulse[1] == smooth_readings.end()) break; // std::cout << *(pulse[0]) << "\t" << *(pulse[1]) << std::endl; int begin_idx = pulse[0] - smooth_readings.begin(); int end_idx = pulse[1] - smooth_readings.begin(); std::vector<int>::iterator alpha = readings.begin(); alpha = alpha + begin_idx; std::vector<int>::iterator omega = readings.begin(); omega = omega + end_idx; std::cout << "pulse begin: " << begin_idx << std::endl; std::cout << "area under pulse: " << dataHandler.calcArea(alpha,omega) <<std::endl; cur_pos = pulse[1]; } std::cout << std::endl; } return 0; }
// //////////////////////////////////////////////////////////////////////////// bool loadConfig() { QSettings ini(PHYSFS_getWriteDir() + QString("/") + fileName, QSettings::IniFormat); if (ini.status() != QSettings::NoError) { debug(LOG_ERROR, "Could not open configuration file \"%s\"", fileName); return false; } debug(LOG_WZ, "Reading configuration from %s", ini.fileName().toUtf8().constData()); if (ini.contains("voicevol")) sound_SetUIVolume(ini.value("voicevol").toDouble() / 100.0); if (ini.contains("fxvol")) sound_SetEffectsVolume(ini.value("fxvol").toDouble() / 100.0); if (ini.contains("cdvol")) sound_SetMusicVolume(ini.value("cdvol").toDouble() / 100.0); if (ini.contains("music_enabled")) war_SetMusicEnabled(ini.value("music_enabled").toBool()); if (ini.contains("language")) setLanguage(ini.value("language").toString().toUtf8().constData()); if (ini.contains("nomousewarp")) setMouseWarp(ini.value("nomousewarp").toBool()); if (ini.contains("notexturecompression")) wz_texture_compression = GL_RGBA; showFPS = ini.value("showFPS", false).toBool(); scroll_speed_accel = ini.value("scroll", DEFAULTSCROLL).toInt(); setShakeStatus(ini.value("shake", false).toBool()); setDrawShadows(ini.value("shadows", true).toBool()); war_setSoundEnabled(ini.value("sound", true).toBool()); setInvertMouseStatus(ini.value("mouseflip", true).toBool()); setRightClickOrders(ini.value("RightClickOrders", false).toBool()); setMiddleClickRotate(ini.value("MiddleClickRotate", false).toBool()); rotateRadar = ini.value("rotateRadar", true).toBool(); war_SetPauseOnFocusLoss(ini.value("PauseOnFocusLoss", false).toBool()); NETsetMasterserverName(ini.value("masterserver_name", "lobby.wz2100.net").toString().toUtf8().constData()); iV_font(ini.value("fontname", "DejaVu Sans").toString().toUtf8().constData(), ini.value("fontface", "Book").toString().toUtf8().constData(), ini.value("fontfacebold", "Bold").toString().toUtf8().constData()); NETsetMasterserverPort(ini.value("masterserver_port", MASTERSERVERPORT).toInt()); NETsetGameserverPort(ini.value("gameserver_port", GAMESERVERPORT).toInt()); war_SetFMVmode((FMV_MODE)ini.value("FMVmode", FMV_FULLSCREEN).toInt()); war_setScanlineMode((SCANLINE_MODE)ini.value("scanlines", SCANLINES_OFF).toInt()); seq_SetSubtitles(ini.value("subtitles", true).toBool()); setDifficultyLevel((DIFFICULTY_LEVEL)ini.value("difficulty", DL_NORMAL).toInt()); war_SetSPcolor(ini.value("colour", 0).toInt()); // default is green (0) war_setMPcolour(ini.value("colourMP", -1).toInt()); // default is random (-1) sstrcpy(game.name, ini.value("gameName", _("My Game")).toString().toUtf8().constData()); sstrcpy(sPlayer, ini.value("playerName", _("Player")).toString().toUtf8().constData()); // Set a default map to prevent hosting games without a map. sstrcpy(game.map, "Sk-Rush"); game.hash.setZero(); game.maxPlayers = 4; game.power = ini.value("power", LEV_MED).toInt(); game.base = ini.value("base", CAMP_BASE).toInt(); game.alliance = ini.value("alliance", NO_ALLIANCES).toInt(); game.scavengers = ini.value("scavengers", false).toBool(); memset(&ingame.phrases, 0, sizeof(ingame.phrases)); for (int i = 1; i < 5; i++) { QString key("phrase" + QString::number(i)); if (ini.contains(key)) sstrcpy(ingame.phrases[i], ini.value(key).toString().toUtf8().constData()); } bEnemyAllyRadarColor = ini.value("radarObjectMode").toBool(); radarDrawMode = (RADAR_DRAW_MODE)ini.value("radarTerrainMode", RADAR_MODE_DEFAULT).toInt(); radarDrawMode = (RADAR_DRAW_MODE)MIN(NUM_RADAR_MODES - 1, radarDrawMode); // restrict to allowed values if (ini.contains("textureSize")) setTextureSize(ini.value("textureSize").toInt()); NetPlay.isUPNP = ini.value("UPnP", true).toBool(); if (ini.contains("FSAA")) war_setFSAA(ini.value("FSAA").toInt()); // Leave this to false, some system will fail and they can't see the system popup dialog! war_setFullscreen(ini.value("fullscreen", false).toBool()); war_SetTrapCursor(ini.value("trapCursor", false).toBool()); // this should be enabled on all systems by default war_SetVsync(ini.value("vsync", true).toBool()); // 640x480 is minimum that we will support int width = ini.value("width", 640).toInt(); int height = ini.value("height", 480).toInt(); if (width < 640 || height < 480) // sanity check { width = 640; height = 480; } pie_SetVideoBufferWidth(width); pie_SetVideoBufferHeight(height); war_SetWidth(width); war_SetHeight(height); if (ini.contains("bpp")) pie_SetVideoBufferDepth(ini.value("bpp").toInt()); return true; }
// 读取配置文件 int InitConfig(char * ini_file_name) { char file_name_key[10] = "FILE"; char des_file_name_key[10] = "DES_FILE"; char file_name_value[50] = ""; char date[15] = ""; char *ini_value = NULL; char *post = NULL; int count = 1; int length = 0; char msg[11] = ""; CIni ini(ini_file_name); // 读取文件后缀名 if (NULL == (ini_value = ini.ReadText("TRANSFILE", "SUFFIX"))) { return ERR_READ_INIVALUE; } strncpy(g_ini_file.file_suffix, ini_value, sizeof(g_ini_file.file_suffix) - 1); // 读取drtp的IP地址 if (NULL == (ini_value = ini.ReadText("TRANSFILE", "DRTP_IP"))) { return ERR_READ_INIVALUE; } strncpy(g_ini_file.drtp_ip, ini_value, sizeof(g_ini_file.drtp_ip) - 1); // 读取drtp的端口号 if (NULL == (ini_value = ini.ReadText("TRANSFILE", "DRTP_PORT"))) { return ERR_READ_INIVALUE; } g_ini_file.drtp_port = atoi(ini_value); // 读取BCC功能号 if (NULL == (ini_value = ini.ReadText("TRANSFILE", "BCC_NO"))) { return ERR_READ_INIVALUE; } g_ini_file.bcc_func_no = atoi(ini_value); // 读取传输标志 if (NULL == (ini_value = ini.ReadText("TRANSFILE", "TRANS_FLAG"))) { return ERR_READ_INIVALUE; } strncpy(g_ini_file.transfer_type, ini_value, sizeof(g_ini_file.transfer_type) - 1); // 读取回调标志 if (NULL == (ini_value = ini.ReadText("TRANSFILE", "CALL_BACK_FLAG"))) { return ERR_READ_INIVALUE; } strncpy(g_ini_file.call_back, ini_value, sizeof(g_ini_file.call_back) - 1); // 读取目标文件路径 if (NULL == (ini_value = ini.ReadText("TRANSFILE", "WINDIR"))) { return ERR_READ_INIVALUE; } strncpy(g_ini_file.win_dir, ini_value, sizeof(g_ini_file.win_dir) - 1); // 读取时间标志 if (NULL == (ini_value = ini.ReadText("TRANSFILE", "TIME_FLAG"))) { return ERR_READ_INIVALUE; } g_ini_file.time_flag = atoi(ini_value); // 读取目标目录 if (NULL == (ini_value = ini.ReadText("TRANSFILE", "DEST_DIR"))) { return ERR_READ_INIVALUE; } strncpy(g_ini_file.dest_dir, ini_value, sizeof(g_ini_file.dest_dir) - 1); // 获取当前日期 SYSTEMTIME tm; GetLocalTime(&tm); sprintf(date, "%04d", tm.wYear); sprintf(date + 4, "%02d", tm.wMonth); sprintf(date + 6, "%02d", tm.wDay); if (1 == g_ini_file.time_flag) { sprintf(date + 8, "%02d", tm.wHour); sprintf(date + 10, "%02d", tm.wMinute); sprintf(date + 12, "%02d", tm.wSecond); } while(1) { strncpy(msg, des_file_name_key, sizeof(des_file_name_key) - 1); sprintf(msg + strlen(des_file_name_key), "%d", count); // 从配置文件读取目标文件(windows)名称 ini_value = ini.ReadText("TRANSFILE", msg); if (NULL != (post = strstr(ini_value, "date"))) { strncpy(g_ini_file.des_file[count - 1], ini_value, 99); post = strstr(g_ini_file.des_file[count - 1], "date"); strncpy(post, date, sizeof(date) - 1); } else { strncpy(g_ini_file.des_file[count - 1], ini_value, 99); } strncpy(msg, file_name_key, sizeof(file_name_key) - 1); sprintf(msg + strlen(file_name_key), "%d", count); // 从配置文件读取后台文件名称 ini_value = ini.ReadText("TRANSFILE", msg); if (0 == strlen(ini_value)) { break; } // 寻找不到FILE + N的文件就退出循环 if (NULL != (post = strstr(ini_value, "date"))) { strncpy(g_ini_file.src_file[count - 1], ini_value, 99); post = strstr(g_ini_file.src_file[count - 1], "date"); strncpy(post, date, sizeof(date) - 1); } else // 手动输入日期 { strncpy(g_ini_file.src_file[count - 1], ini_value, 99); } g_ini_file.file_count = count++; memset(msg, 0, sizeof(msg)); } ini.Close(); return 0; }
void setValue(QString key, QVariant value) { QSettings ini("info.ini", QSettings::IniFormat); ini.setValue(key, value); }
int main(int argc,char **argv) { loadCommandLineParameters(argc,argv); ini(); loadDataFromEvaluateConfsToDoList(); SDReader = new StateDescriptorReader(Parameter_SD_FileName); int threadCountPerNode = 1; int ParaOpMode = 0; char* fftPlanDescriptor = NULL; bool usexFFT = false; readOptimalFermionVectorEmbeddingAndFFTPlanFromTuningDB(SDReader->getL0(), SDReader->getL1(), SDReader->getL2(), SDReader->getL3(), threadCountPerNode, ParaOpMode, usexFFT, SDReader->getUseP(), SDReader->getUseQ(), SDReader->getUseR(), SDReader->getUseQHM(), fftPlanDescriptor); delete[] fftPlanDescriptor; char* fileNameExtension = SDReader->getFileNameExtension(); ioControl = new AnalyzerIOControl(fileNameExtension, -1); delete[] fileNameExtension; SimParaSet = new SimulationParameterSet(SDReader, SimulationParameterSet_NfNotation); iniEvaluateObs(); createAndPrepareFolders(); if (LogLevel>1) printf("\nEntering main Evaluate-Loop.\n"); bool* evalSuccess = new bool[evaluateObsCount]; for (int I=0; I<evaluateObsCount; I++) { evalSuccess[I] = false; bool activeObs = false; for (int I2=0; I2<Parameter_tagCount; I2++) { if (evaluateObs[I]->isNick(Parameter_tags[I2])) activeObs = true; } if (activeObs) { if (LogLevel>1) printf("Evaluating Observable %s...\n",evaluateObs[I]->getObsName()); evaluateObs[I]->setPhysicalScale(physicalScale, physicalScaleError, GoldstoneRenormFactorDetermined); evalSuccess[I] = evaluateObs[I]->evaluateWrapper(); afterEvaluateControl(evaluateObs[I]); if (evalSuccess[I]) { evaluateObs[I]->generateLatexAndPlotsAndXMLWrapper(); evaluateObs[I]->writeXmlOutput(); } else { if (LogLevel>1) printf(" *** Could not evaluate observable %s. Continue with next observable.\n",evaluateObs[I]->getObsName()); } } } if (LogLevel>1) printf("\nLeaving main Evaluate-Loop.\n"); composeGeneralSummaryInfo(); writeSummaryXmlFile(); if (LogLevel>1) { printf("\n\n *** Evaluation Status Summary: ***\n\n"); for (int I=0; I<evaluateObsCount; I++) { if (evalSuccess[I]) { bool activeObs = false; for (int I2=0; I2<Parameter_tagCount; I2++) { if (evaluateObs[I]->isNick(Parameter_tags[I2])) activeObs = true; } if (activeObs) { evaluateObs[I]->printStatusSummaryToScreen(); } } } } delete[] evalSuccess; desini(); desiniTools(); fftw_cleanup_threads(); if (LogLevel>1) printf("\n *** EvaluateConfs terminated correctly. ***\n\n"); }
void GFont::makeFont(int charsetSize, const String& infileBase, String outfile) { debugAssert(FileSystem::exists(infileBase + ".tga")); debugAssert(FileSystem::exists(infileBase + ".ini")); debugAssert(charsetSize == 128 || charsetSize == 256); if (outfile == "") { outfile = infileBase + ".fnt"; } TextInput ini(infileBase + ".ini"); BinaryOutput out(outfile, G3D_LITTLE_ENDIAN); ini.readSymbol("["); ini.readSymbol("Char"); ini.readSymbol("Widths"); ini.readSymbol("]"); // Version out.writeInt32(2); // Number of characters out.writeInt32(charsetSize); // Character widths for (int i = 0; i < charsetSize; ++i) { int n = (int)ini.readNumber(); (void)n; debugAssert(n == i); ini.readSymbol("="); int cw = (int)ini.readNumber(); out.writeInt16(cw); } // Load provided source image shared_ptr<Image> image = Image::fromFile(infileBase + ".tga"); debugAssert(isPow2(image->width())); debugAssert(isPow2(image->height())); image->convertToR8(); // Convert to image buffer so can access bytes directly shared_ptr<PixelTransferBuffer> imageBuffer = image->toPixelTransferBuffer(); debugAssert(imageBuffer->format() == ImageFormat::R8()); // Autodetect baseline from capital E const uint8* p = static_cast<const uint8*>(imageBuffer->mapRead()); { // Size of a character, in texels int w = imageBuffer->width() / 16; int x0 = ('E' % 16) * w; int y0 = ('E' / 16) * w; int baseline = w * 2 / 3; bool done = false; // Search up from the bottom for the first pixel for (int y = y0 + w - 1; (y >= y0) && ! done; --y) { for (int x = x0; (x < x0 + w) && ! done; ++x) { if (p[x + y * w * 16] != 0) { baseline = y - y0 + 1; done = true; } } } out.writeUInt16(baseline); } // Texture width out.writeUInt16(imageBuffer->width()); out.writeBytes(p, square(imageBuffer->width()) * 256 / charsetSize); imageBuffer->unmap(); out.compress(); out.commit(false); }
void login2::sLogin() { QSqlDatabase db; QString databaseURL; databaseURL = _databaseURL; if (_demoOption->isChecked()) databaseURL = _evalDatabaseURL.arg(_username->text().trimmed()); QString protocol; QString hostName; QString dbName; QString port; parseDatabaseURL(databaseURL, protocol, hostName, dbName, port); if (_splash) { _splash->show(); _splash->raise(); _splash->showMessage(tr("Initializing the Database Connector"), SplashTextAlignment, SplashTextColor); qApp->processEvents(); } // Open the Database Driver if (_multipleConnections) db = QSqlDatabase::addDatabase("QPSQL7", dbName); else db = QSqlDatabase::addDatabase("QPSQL7"); if (!db.isValid()) { if (_splash) _splash->hide(); QMessageBox::warning( this, tr("No Database Driver"), tr("<p>A connection could not be established with " "the specified Database as the Proper Database " "Drivers have not been installed. Contact your " "Systems Administator.")); return; } if(hostName.isEmpty() || dbName.isEmpty()) { if (_splash) _splash->hide(); QMessageBox::warning(this, tr("Incomplete Connection Options"), tr("<p>One or more connection options are missing. " "Please check that you have specified the host " "name, database name, and any other required " "options.") ); return; } db.setDatabaseName(dbName); db.setHostName(hostName); db.setPort(port.toInt()); _cUsername = _username->text().trimmed(); _cPassword = _password->text().trimmed(); db.setUserName(_cUsername); if(_demoOption->isChecked()) { QString passwd = QMd5(QString(_cPassword + "private" + _cUsername)); db.setPassword(passwd); } else { if(_enhancedAuth) { QString passwd = QMd5(QString(_cPassword + "OpenMFG" + _cUsername)); db.setPassword(passwd); } else db.setPassword(_cPassword); if(_requireSSL) db.setConnectOptions("requiressl=1"); } setCursor(QCursor(Qt::waitCursor)); if (_splash) { _splash->showMessage(tr("Connecting to the Database"), SplashTextAlignment, SplashTextColor); qApp->processEvents(); } // Try to connect to the Database bool result = db.open(); if (!result) { if(_requireSSL) db.setConnectOptions(); if (_splash) _splash->hide(); setCursor(QCursor(Qt::arrowCursor)); QMessageBox::critical(this, tr("Cannot Connect to xTuple ERP Server"), tr("<p>A connection to the specified xTuple ERP " "Server cannot be made. This may be due to an " "incorrect Username and/or Password or the " "server in question cannot support any more " "connections.<p>Please verify your Username and " "Password and try again or wait until the " "specified xTuple ERP Server is less busy.<br>" "System Error<pre>%1" ) .arg(db.lastError().driverText() )); if (!_captive) { _username->setText(""); _username->setFocus(); } else _password->setFocus(); _password->setText(""); return; } QSettings ini(QSettings::IniFormat, QSettings::UserScope, "xTuple.com", "xTuple"); QSettings settings(QSettings::UserScope, "OpenMFG.com", "OpenMFG"); ini.writeEntry("/xTuple/_demoOption", (bool)_demoOption->isChecked()); settings.writeEntry("/OpenMFG/_demoOption", (bool)_demoOption->isChecked()); if (_splash) { _splash->showMessage(tr("Logging into the Database"), SplashTextAlignment, SplashTextColor); qApp->processEvents(); } if(!_nonxTupleDB) { XSqlQuery login( "SELECT login() AS usr_id," " CURRENT_USER AS user;" ); setCursor(QCursor(Qt::arrowCursor)); if (login.first()) { int result = login.value("usr_id").toInt(); if (result < 0) { if (_splash) _splash->hide(); QMessageBox::critical(this, tr("Error Logging In"), storedProcErrorLookup("login", result)); return; } _user = login.value("user").toString(); _userid = login.value("usr_id").toInt(); _databaseURL = databaseURL; accept(); } else if (login.lastError().type() != QSqlError::NoError) { if (_splash) _splash->hide(); QMessageBox::critical(this, tr("System Error"), tr("A System Error occurred at %1::%2:\n%1") .arg(__FILE__).arg(__LINE__) .arg(login.lastError().databaseText())); } else { if (_splash) _splash->hide(); QMessageBox::critical(this, tr("System Error"), tr("<p>An unknown error occurred at %1::%2. You may" " not log in to the specified xTuple ERP Server " "at this time.") .arg(__FILE__).arg(__LINE__)); } } else { setCursor(QCursor(Qt::arrowCursor)); _databaseURL = databaseURL; accept(); } }