int interface_tester_main(int argc, char *argv[]) { driver_t *cons = getDriver(CONS_DRIVER); cons->ioctl_driver(CONS_CLEAR,0); int option; while((option = showMenu())!=EXIT){ switch(option){ case IDE: cons->ioctl_driver(CONS_CLEAR,0); cprintk(MAGENTA, BLACK,"\n ** TEST DISCO RIGIDO **\n\n\n"); ide_tester(); break; case CONS: cons->ioctl_driver(CONS_CLEAR,0); cprintk(MAGENTA, BLACK,"\n ** TEST CONSOLA **\n\n\n"); cons_tester(); break; default: cons->ioctl_driver(CONS_CLEAR,0); cprintk(RED, BLACK,"Opcion incorrecta.\n\n"); break; } } cons->ioctl_driver(CONS_CLEAR,0); return 0; }
int CSObject::loadFromPreFab(stringc filename) { int id = 0; stringc dir(getLevel()->getApplication()->getDirectory("PrefabDirectory")); dir += filename; CS_LOG(CSLOGTYPE::CSL_DEBUG, "Loading from prefab directory %s", dir.c_str()); IXMLReader* reader = getDevice()->getFileSystem()->createXMLReader(dir); CS_CHECK_BOOL(reader, CSLOGTYPE::CSL_DEBUG, "Warning! unable to open prefab file"); // read file while (reader->read()) { switch (reader->getNodeType()) { case io::EXN_ELEMENT: { stringw name = reader->getNodeName(); if (stringw("CSOBJECT") == name) { stringw type = reader->getAttributeValueSafe(L"TYPE"); IAttributes* attr = getDevice()->getFileSystem()->createEmptyAttributes(getDriver()); attr->read(reader, false); deserializeAttributes(attr); setId(getLevel()->getObjectFactory()->getObjectManager()->getUniqueId()); attr->drop(); } } } } reader->drop(); return id; }
static void cons_tester(){ driver_t *cons = getDriver(CONS_DRIVER); int color,opcion; show_test_cons(WHITE); while((opcion = getch()) !='q'){ switch(opcion-48){ case TURQUESA: color=CYAN; break; case VIOLETA: color=MAGENTA; break; case AMARILLO: color=YELLOW; break; case AZUL: color=BLUE; break; case ROJO: color=RED; break; } show_test_cons(color); } cons->ioctl_driver(CONS_CLEAR,0); }
bool CSLevel::savePrefab(CSObject* obj, stringc filename) { CS_LOG(CSLOGTYPE::CSL_DEBUG, "Saving prefab to file %s", filename.c_str()); CS_CHECK_BOOL(obj, CSLOGTYPE::CSL_WARNING, "Warning unable to save prefab. obj is not valid"); _chdir(getApplication()->getDirectory("PrefabDirectory").c_str()); IXMLWriter* writer = getDevice()->getFileSystem()->createXMLWriter(filename); if (!writer) { CS_LOG(CSLOGTYPE::CSL_WARNING, "Warning! unable to create prefab file %s", filename.c_str()); return false; } writer->writeXMLHeader(); stringw name("CSOBJECT"); writer->writeElement(name.c_str(), false, L"TYPE", stringw(obj->getInfo()->getName()).c_str()); writer->writeLineBreak(); IAttributes* attr = getDevice()->getFileSystem()->createEmptyAttributes(getDriver()); SAttributeReadWriteOptions options; obj->serializeAttributes(attr, &options); if (attr->getAttributeCount() != 0) { attr->write(writer); writer->writeLineBreak(); } attr->drop(); writer->writeClosingTag(name.c_str()); writer->writeLineBreak(); writer->writeLineBreak(); writer->drop(); return true; }
ClientWorld::ClientWorld(){ setType("ClientWorld"); phantom::Console::log("Initializing ClientWorld..."); fixedlayer = new Layer(); gameobjects = new BSPTree(Services::settings()->bsp_width, Services::settings()->bsp_height, Services::settings()->bsp_smallestsize, Services::settings()->bsp_maxcollisionperspace); selector = new Selector(); hud = new HUD(); while(!getDriver()->getActiveCameras()->empty()) getDriver()->disableCamera(getDriver()->getActiveCameras()->at(0)); mission = new Mission("first"); obj = new ObjDestroy("kill tank!"); gameobjects->addComponent(mission); #ifdef _DEBUG _procedural = new Procedural(); #endif camera = getDriver()->createCamera(); getDriver()->enableCamera(camera); camera->addComponent(hud); addComponent(gameobjects); addComponent(fixedlayer); addComponent(selector); // Dependency injection :( selector->setTrackingLayer(gameobjects); selector->setCamera(camera); // For "screen to world" coordinates. fixedlayer->addComponent(camera); getDriver()->getAudio()->playMusic("audio/Soundtrack/In-game.ogg"); phantom::Console::log("Initialization complete."); camera->addComponent(new UsageGraph()); }
static void GUINewMode(void) { int Max, Sel; sprintf(modetext,"0x%08lx", getAudioMode()); infoargs[0] = modetext; infoargs[1] = getRecord(); infoargs[2] = getAuthor(); infoargs[3] = getCopyright(); sprintf(drivertext, "Devs:AHI/%s.audio", getDriver()); infoargs[4] = drivertext; infoargs[5] = getVersion(); MySetGadgetAttrs(Window_Objs[SHOWID_MODE], LISTBROWSER_Labels, ~0, TAG_DONE); if(infolist) FreeBrowserNodes2(infolist); infolist = BrowserNodes2(infotexts, infoargs); MySetGadgetAttrs(Window_Objs[SHOWID_MODE], LISTBROWSER_Labels, infolist, TAG_DONE); Max = max(state.Frequencies -1, 0); Sel = min(Max, state.FreqSelected); MySetGadgetAttrs(Window_Objs[ACTID_FREQ], SLIDER_Min, 0, SLIDER_Max, Max, SLIDER_Level, Sel, GA_Disabled, (Max == 0), TAG_DONE ); Max = max(state.Channels, 1); Sel = min(Max, state.ChannelsSelected); MySetGadgetAttrs(Window_Objs[ACTID_CHANNELS], SLIDER_Min, 1, SLIDER_Max, Max, SLIDER_Level, Sel, GA_Disabled, (Max == 1) || state.ChannelsDisabled, TAG_DONE ); Max = max(state.OutVols -1, 0); Sel = min(Max, state.OutVolSelected); MySetGadgetAttrs(Window_Objs[ACTID_OUTVOL], SLIDER_Min, 0, SLIDER_Max, Max, SLIDER_Level, Sel, GA_Disabled, (Max == 0), TAG_DONE ); Max = max(state.MonVols -1, 0); Sel = min(Max, state.MonVolSelected); MySetGadgetAttrs(Window_Objs[ACTID_MONVOL], SLIDER_Min, 0, SLIDER_Max, Max, SLIDER_Level, Sel, GA_Disabled, (Max == 0), TAG_DONE ); Max = max(state.Gains -1, 0); Sel = min(Max, state.GainSelected); MySetGadgetAttrs(Window_Objs[ACTID_GAIN], SLIDER_Min, 0, SLIDER_Max, Max, SLIDER_Level, Sel, GA_Disabled, (Max == 0), TAG_DONE ); Max = max(state.Inputs -1, 0); Sel = min(Max, state.InputSelected); MySetGadgetAttrs(Window_Objs[ACTID_INPUT], SLIDER_Min, 0, SLIDER_Max, Max, SLIDER_Level, Sel, GA_Disabled, (Max == 0), TAG_DONE ); Max = max(state.Outputs -1, 0); Sel = min(Max, state.OutputSelected); MySetGadgetAttrs(Window_Objs[ACTID_OUTPUT], SLIDER_Min, 0, SLIDER_Max, Max, SLIDER_Level, Sel, GA_Disabled, (Max == 0), TAG_DONE ); // Update indicators.. MySetGadgetAttrs(Window_Objs[SHOWID_FREQ], GA_Text, getFreq(), TAG_DONE ); MySetGadgetAttrs(Window_Objs[SHOWID_CHANNELS], GA_Text, getChannels(), TAG_DONE ); MySetGadgetAttrs(Window_Objs[SHOWID_OUTVOL], GA_Text, getOutVol(), TAG_DONE ); MySetGadgetAttrs(Window_Objs[SHOWID_MONVOL], GA_Text, getMonVol(), TAG_DONE ); MySetGadgetAttrs(Window_Objs[SHOWID_GAIN], GA_Text, getGain(), TAG_DONE ); MySetGadgetAttrs(Window_Objs[SHOWID_INPUT], GA_Text, getInput(), TAG_DONE ); MySetGadgetAttrs(Window_Objs[SHOWID_OUTPUT], GA_Text, getOutput(), TAG_DONE ); }
String Connection::preAnalyze(const String &sql) { static boost::recursive_mutex cs; OS_LOCK(cs); // Per vedere le sql nel charts: // RealtimeStatsManager::signal(sql, 1, RealtimeStatsCounter::ctAbsolute, _S("status")); // Da notare che vengono archiviate nella os_monitor solo le query analizzate dalla "explain". // Una "insert", non usando indici, non viene catalogata, a meno che non abbia sotto-query. if(sql.find(_S("explain query plan ")) != String::npos) return _S(""); if(sql.find(_S("os_monitor")) != String::npos) return _S(""); static shared_ptr<Connection> connectionAnalyze = nullptr; if(connectionAnalyze == nullptr) { shared_ptr<Driver> driver = boost::dynamic_pointer_cast<Driver>(getDriver()); String path = driver->getDatabasePath(_S("monitor.db")); if(FileSystem::instance()->exists(path) == false) { // Crea il database se non esiste File file; String msg = _S("Cannot create file '") + path + _S("'"); OS_EXCEPT_IF(file.open(path, File::ofWrite) == false, msg.to_ascii()); } connectionAnalyze.reset(OS_NEW Connection(path, getDriver()->createOptions(), getDriver())); int32 res = _tsqlite3_open(path.c_str(), &connectionAnalyze->m_connection); OS_EXCEPT_IF(res != SQLITE_OK, sqlite_last_error(connectionAnalyze->m_connection, res)); // Creazione tabella String sqlCreate = _S("CREATE TABLE IF NOT EXISTS os_monitor (filename text,sql text,thread integer,conn integer,trans integer, qorder integer,qfrom integer,detail text,indexUsed text)"); doExecute(connectionAnalyze->m_connection, sqlCreate); } // I valori dei campi li setto a ?, per poter fare delle distinct sui risultati String keySql = sql; keySql.trim(); keySql = regex_replace(keySql, RegexManager::instance()->getRegex(_S("'(.*?)'")), _S("<s>")); // Valori dei campi keySql = regex_replace(keySql, RegexManager::instance()->getRegex(_S("[-+]?[0-9]*\\.?[0-9]+")), _S("<n>")); // Numeri keySql = keySql.replace_all(_S("\n"),_S("")); keySql = keySql.replace_all(_S("\r"),_S("")); keySql = keySql.replace_all(_S("\t"),_S("")); keySql = keySql.replace_all(_S("'"),_S("")); // Futile, per evitare errori nella insert nella os_monitor for(;;) // Comprimo gli spazi { String x = keySql; keySql = keySql.replace_all(_S(" "),_S(" ")); if(x == keySql) break; } uint32 conn = uint32(reinterpret_cast<uint64>(this)); boost::any threadID = PlatformManager::instance()->getCurrentThreadID(); // Tenta un cast a uint32 uint32 *thread = boost::any_cast<uint32>(&threadID); int32 trans = m_transactionId; DataTable result; doQuery(m_connection, _S("explain query plan ") + sql,result); for(uint32 r=0;r<result.rows();r++) { int32 order = *result.get(r,_S("order")); int32 from = *result.get(r,_S("from")); String detail = *result.get(r,_S("detail")); String indexUsed; String::size_type posWithIndex = detail.find(_S("WITH INDEX")); if(posWithIndex != String::npos) { indexUsed = detail.substr(posWithIndex+10); indexUsed = indexUsed.replace_all(_S("ORDER BY"),String::EMPTY); indexUsed.trim(); } String sqlInsert = String::format(_S("insert into os_monitor values ('%S','%S',%u,%u,%u,%d,%d,'%S','%S')").c_str(), m_filename.c_str(), keySql.c_str(), conn, thread != nullptr ? *thread : 0, trans, order, from, detail.c_str(), indexUsed.c_str()); doExecute(connectionAnalyze->m_connection, sqlInsert); } String trace = String::format(_S("Sqlite monitor: sql='%S',conn=%u,thread=%u,trans=%u\n").c_str(), sql.c_str(), conn, thread != nullptr ? *thread : 0, trans); //OS_TRACE(trace); //RealtimeStatsManager::signal(_S("Sqlite ") + keySql.mid(0,6), 1, RealtimeStatsCounter::ctRelative, _S("items")); return keySql; }
Camera::~Camera() { if(_isActive) { vector<Camera*> *cams = getDriver()->getActiveCameras(); cams->erase(find(cams->begin(), cams->end(), this)); } }
static void GUINewMode(void) { int Max, Sel; infoargs[0] = (char *) getAudioMode(); infoargs[1] = getRecord(); infoargs[2] = getAuthor(); infoargs[3] = getCopyright(); infoargs[4] = getDriver(); infoargs[5] = getVersion(); SetGadgetAttrs((struct Gadget *) Window_Objs[SHOWID_MODE], window, NULL, INFO_TextFormat, (ULONG) "0x%08lx\n" "%s\n" "%s\n" "%s\n" "Devs:AHI/%s.audio\n" "%s", INFO_Args, (ULONG) &infoargs, TAG_DONE ); Max = max(state.Frequencies -1, 0); Sel = min(Max, state.FreqSelected); SetGadgetAttrs((struct Gadget *) Window_Objs[ACTID_FREQ], window, NULL, SLIDER_Min, 0, SLIDER_Max, Max, SLIDER_Level, Sel, GA_Disabled, (Max == 0), TAG_DONE ); Max = max(state.Channels, 0); Sel = min(Max, state.ChannelsSelected); SetGadgetAttrs((struct Gadget *) Window_Objs[ACTID_CHANNELS], window, NULL, SLIDER_Min, 1, SLIDER_Max, Max, SLIDER_Level, Sel, GA_Disabled, (Max == 1) || state.ChannelsDisabled, TAG_DONE ); Max = max(state.OutVols -1, 0); Sel = min(Max, state.OutVolSelected); SetGadgetAttrs((struct Gadget *) Window_Objs[ACTID_OUTVOL], window, NULL, SLIDER_Min, 0, SLIDER_Max, Max, SLIDER_Level, Sel, GA_Disabled, (Max == 0), TAG_DONE ); Max = max(state.MonVols -1, 0); Sel = min(Max, state.MonVolSelected); SetGadgetAttrs((struct Gadget *) Window_Objs[ACTID_MONVOL], window, NULL, SLIDER_Min, 0, SLIDER_Max, Max, SLIDER_Level, Sel, GA_Disabled, (Max == 0), TAG_DONE ); Max = max(state.Gains -1, 0); Sel = min(Max, state.GainSelected); SetGadgetAttrs((struct Gadget *) Window_Objs[ACTID_GAIN], window, NULL, SLIDER_Min, 0, SLIDER_Max, Max, SLIDER_Level, Sel, GA_Disabled, (Max == 0), TAG_DONE ); Max = max(state.Inputs -1, 0); Sel = min(Max, state.InputSelected); SetGadgetAttrs((struct Gadget *) Window_Objs[ACTID_INPUT], window, NULL, SLIDER_Min, 0, SLIDER_Max, Max, SLIDER_Level, Sel, GA_Disabled, (Max == 0), TAG_DONE ); Max = max(state.Outputs -1, 0); Sel = min(Max, state.OutputSelected); SetGadgetAttrs((struct Gadget *) Window_Objs[ACTID_OUTPUT], window, NULL, SLIDER_Min, 0, SLIDER_Max, Max, SLIDER_Level, Sel, GA_Disabled, (Max == 0), TAG_DONE ); // Update indicators.. SetGadgetAttrs((struct Gadget *) Window_Objs[SHOWID_FREQ], window, NULL, INFO_TextFormat, (ULONG) getFreq(), TAG_DONE ); SetGadgetAttrs((struct Gadget *) Window_Objs[SHOWID_CHANNELS], window, NULL, INFO_TextFormat, (ULONG) getChannels(), TAG_DONE ); SetGadgetAttrs((struct Gadget *) Window_Objs[SHOWID_OUTVOL], window, NULL, INFO_TextFormat, (ULONG) getOutVol(), TAG_DONE ); SetGadgetAttrs((struct Gadget *) Window_Objs[SHOWID_MONVOL], window, NULL, INFO_TextFormat, (ULONG) getMonVol(), TAG_DONE ); SetGadgetAttrs((struct Gadget *) Window_Objs[SHOWID_GAIN], window, NULL, INFO_TextFormat, (ULONG) getGain(), TAG_DONE ); SetGadgetAttrs((struct Gadget *) Window_Objs[SHOWID_INPUT], window, NULL, INFO_TextFormat, (ULONG) getInput(), TAG_DONE ); SetGadgetAttrs((struct Gadget *) Window_Objs[SHOWID_OUTPUT], window, NULL, INFO_TextFormat, (ULONG) getOutput(), TAG_DONE ); }
static void GUINewMode(void) { int Max, Sel, Dis; char* buffer; char* arg1 = getRecord(); char* arg2 = getAuthor(); char* arg3 = getCopyright(); char* arg4 = getDriver(); char* arg5 = getVersion(); char* arg6 = getAnnotation(); buffer = AllocVec( strlen( arg1 ) + strlen( arg2 ) + strlen( arg3 ) + strlen( arg4 ) + strlen( arg5 ) + strlen( arg6 ) + 128, MEMF_ANY); if( buffer != NULL ) { sprintf( buffer,"0x%08lx\n%s\n%s\n%s\nDevs:AHI/%s.audio\n%s\n%s", getAudioMode(), arg1, arg2, arg3, arg4, arg5, arg6 ); set(MUIInfos, MUIA_Text_Contents, (ULONG) buffer); FreeVec(buffer); } Max = max(state.Frequencies -1, 0); Sel = min(Max, state.FreqSelected); Dis = Max==0; set(MUIFreq, MUIA_Disabled, Dis); if( !Dis ) { set(MUIFreq, MUIA_Numeric_Max, Max); set(MUIFreq, MUIA_Numeric_Value, Sel); } set(MUILFreq, MUIA_Text_Contents, (ULONG) getFreq()); Max = max(state.Channels, 0); Sel = min(Max, state.ChannelsSelected); Dis = (Max == 0 || Max == 1) || state.ChannelsDisabled; set(MUIChannels, MUIA_Disabled, Dis); if( !Dis ) { set(MUIChannels, MUIA_Numeric_Max, Max); set(MUIChannels, MUIA_Numeric_Value, Sel); } set(MUILChannels, MUIA_Text_Contents, (ULONG) getChannels()); Max = max(state.OutVols -1, 0); Sel = min(Max, state.OutVolSelected); Dis = Max==0; set(MUIOutvol, MUIA_Disabled, Dis); if( !Dis ) { set(MUIOutvol, MUIA_Numeric_Max, Max); set(MUIOutvol, MUIA_Numeric_Value, Sel); } set(MUILOutvol, MUIA_Text_Contents, (ULONG) getOutVol()); Max = max(state.MonVols -1, 0); Sel = min(Max, state.MonVolSelected); Dis = Max==0; set(MUIMonvol, MUIA_Disabled, Dis); if( !Dis ) { set(MUIMonvol, MUIA_Numeric_Max, Max); set(MUIMonvol, MUIA_Numeric_Value, Sel); } set(MUILMonvol, MUIA_Text_Contents, (ULONG) getMonVol()); Max = max(state.Gains -1, 0); Sel = min(Max, state.GainSelected); Dis = Max==0; set(MUIGain, MUIA_Disabled, Dis); if( !Dis ) { set(MUIGain, MUIA_Numeric_Max, Max); set(MUIGain, MUIA_Numeric_Value, Sel); } set(MUILGain, MUIA_Text_Contents, (ULONG) getGain()); Max = max(state.Inputs -1, 0); Sel = min(Max, state.InputSelected); Dis = Max==0; set(MUIInput, MUIA_Disabled, Dis); if( !Dis ) { set(MUIInput, MUIA_Numeric_Max, Max); set(MUIInput, MUIA_Numeric_Value, Sel); } set(MUILInput, MUIA_Text_Contents, (ULONG) getInput()); Max = max(state.Outputs -1, 0); Sel = min(Max, state.OutputSelected); Dis = Max==0; set(MUIOutput, MUIA_Disabled, Dis); if( !Dis ) { set(MUIOutput, MUIA_Numeric_Max, Max); set(MUIOutput, MUIA_Numeric_Value, Sel); } set(MUILOutput, MUIA_Text_Contents, (ULONG) getOutput()); set(MUIPlay, MUIA_Disabled, getAudioMode() == AHI_INVALID_ID); }
// load the level objects from disk file bool CSLevel::loadFromDisk(stringc filename, bool destroyOld) { CS_LOG(CSLOGTYPE::CSL_DEBUG, "*************************** Loading level from file %s ***************************", filename.c_str()); if (destroyOld) clear(); // attempt to open the file IXMLReader* reader = getDevice()->getFileSystem()->createXMLReader(filename); if (!reader) { CS_LOG(CSLOGTYPE::CSL_WARNING, "Warning! unable to open file %s", filename.c_str()); return false; } // read file while (reader->read()) { // based on the node type switch (reader->getNodeType()) { case io::EXN_ELEMENT: { // get the node name stringw name = reader->getNodeName(); // if this is an object definition if (stringw("CAMERA") == name) { stringw pos = reader->getAttributeValueSafe(L"POSITION"); stringw tar = reader->getAttributeValueSafe(L"TARGET"); if (getCamera()) { getCamera()->setPosition(stringcToVector3df(stringc(pos))); getCamera()->setTarget(stringcToVector3df(stringc(tar))); } else CS_LOG(CSLOGTYPE::CSL_WARNING, "no camera in game save file"); } // if this is an object definition if (stringw("CSOBJECT") == name) { // get the object type stringw type = reader->getAttributeValueSafe(L"TYPE"); // attempt to create the object CSObject* obj = getObjectFactory()->createObjectByType(stringc(type)); if (obj) { // load the attributes from the file IAttributes* attr = getDevice()->getFileSystem()->createEmptyAttributes(getDriver()); attr->read(reader, false); // let the object deserialize from the attributes obj->deserializeAttributes(attr); // recreate the object using the new attribtues obj->reCreate(); // drop the pointer attr->drop(); } } } } } // drop the reader reader->drop(); CS_LOG(CSLOGTYPE::CSL_DEBUG, "*************************** finished Loading level from file %s ***************************", filename.c_str()); // everything went fine return true; }
// save the level objects to disk file bool CSLevel::saveToDisk(stringc filename) { // log this event CS_LOG(CSLOGTYPE::CSL_DEBUG, "Saving game data - %s", filename.c_str()); // creat ethe xml writer IXMLWriter* writer = getDevice()->getFileSystem()->createXMLWriter(filename); if (!writer) { CS_LOG(CSLOGTYPE::CSL_WARNING, "Warning! unable to create save file %s", filename.c_str()); return false; } // write the xml header writer->writeXMLHeader(); vector3df pos(0, 0, 0); vector3df tar(0, 0, 0); if (getCamera()) { pos = getCamera()->getPosition(); tar = getCamera()->getTarget(); } // write the camera position and target writer->writeLineBreak(); writer->writeElement(L"CAMERA", false, L"POSITION", stringw(vector3dfToStringc(pos)).c_str(), L"TARGET", stringw(vector3dfToStringc(tar)).c_str() ); writer->writeLineBreak(); writer->writeLineBreak(); // run through thte list of objects CSObject* obj = getObjectFactory()->getObjectManager()->getNextObject(true); while (obj) { // if this is not a debug object, then save it to disk if (!obj->getDebugObject()) { // write the node type stringw name("CSOBJECT"); writer->writeElement(name.c_str(), false, L"TYPE", stringw(obj->getInfo()->getName()).c_str()); writer->writeLineBreak(); // let the object serialize itself into our attributes structure IAttributes* attr = getDevice()->getFileSystem()->createEmptyAttributes(getDriver()); SAttributeReadWriteOptions options; obj->serializeAttributes(attr, &options); // if there are attributes if (attr->getAttributeCount() != 0) { // write the attributes to the xml file attr->write(writer); // make the file pretty writer->writeLineBreak(); } // drop the pointer attr->drop(); // finish writing the xml header / footer writer->writeClosingTag(name.c_str()); writer->writeLineBreak(); writer->writeLineBreak(); } // get the next object obj = getObjectFactory()->getObjectManager()->getNextObject(false); } // drop the pointer writer->drop(); // everything went fine return true; }
/** * This is called once by main() to interpret the command line: * It sets m_iNumLap, m_iNumCar, real_speed and trackfile[], and options. * RARS command line options: ( - or / signifies an option) * -h or -H or -? shows this help screen (/ may be used in place of -) * -d meaning drivers (followed by space and then list of driver's names) * -D meaning ignore drivers (followed by space and list of names to not use) * -f meaning fastest that computer can compute (default is realistic) * -l meaning followed by race length in miles. * -mp meaning playback movie (can be followed by filename, eg. -mpmovie) * -mr meaning record movie (can be followed by filename, eg. -mrmovie) * -nd meaning no display (there is a results report written to RAC.OUT) * -ni meaning keystrokes supplied by computer, no waiting. * -nr meaning no randomization of r.v.g. (same initial seed every time) * (-nr may be followed by a seed value, without a space) * -nR meaning car motion is deterministic, and also r.v.g. not randomized * -o meaning order (starting order as given in driver list or as compiled) * -p meaning practice, followed by the number of practice laps. * -q meaning qualifying mode (1-fastest lap, 2-avg speed) * -ql meaning qualifying laps, how many * -qr meaning qualifying sessions, how many * -r meaning races, how many * -s meaning surface type, s0 = loose surface, s1 = harder surface, default 0 * -sr meaning starting rows. Default is given in track file. * -v meaning Just show the version and exit. * -z meaning disable "side vision" for all drivers * * @param argc (in) from maim() * @param argv (in) from maim() */ void Args::GetArgs(int argc, char* argv[]) { int cur_arg, i; char c; char *ptr; // will point to current argument being processed char *tmp_ptr; // Used for track names int num_count = 0; // how many numerical arguments have been seen char option; // holds the option code char lastext[81]; // the last text argument processed lastext[0] = 0; int car_param_idx = 0; // номер первого аргумента описывающего машину(id) в массиве аргументов Driver * temp_drv; int n, k; // process each argument in turn: for(cur_arg=1; cur_arg<argc; cur_arg++) // once for each argument { ptr = argv[cur_arg]; c = *ptr; if(cur_arg == 1) // первый аргумент - интервал логгирования { log_interval = atoi(ptr); if(log_interval == 0) log_interval = -1; continue; } else if(cur_arg == 2) // второй аргумент - путь к логу { if(log_interval > 0) log_file = ptr; continue; } if(c == '-' || c == '/') // is this an option request? { ++ptr; option = *ptr; // grab the option code ++ptr; // point to char after code switch(option) // which one? { case '?': case 'h': case 'H': // H for Help PrintHelpFile(); exit(0); case 'd': // d for drivers // re-arrange drivers[] array according to names in command line car_param_idx = cur_arg; for( n=0; n<MAX_CARS; n++ ) { car_param_idx = ++car_param_idx; if (car_param_idx == argc) { break; } char* car_id = argv[car_param_idx++]; ptr = argv[car_param_idx++]; if((i = find_name(ptr)) < 0) { //TODO: it must be possible to replay with unknown drivers. if( m_iMovieMode != MOVIE_PLAYBACK ) exitOnError("Driver %s was not found.", ptr); /* strcpy(lastext, ptr); --cur_arg; break; */ } int idx = find_name_from_idx(ptr, n); double pm = atof(argv[car_param_idx]); car_param_idx++; unsigned long init_damage = strtol(argv[car_param_idx], NULL, 10); if (idx > 0) { temp_drv = drivers[n]; drivers[n] = drivers[idx]; drivers[idx] = temp_drv; } else drivers[n] = getDriver(ptr); drivers[n]->id = car_id; drivers[n]->init_damage = init_damage; drivers[n]->pm = pm; } cur_arg = car_param_idx; break; case 'D': // D for drivers to eliminate // re-arrange drivers[] array according to names in command line for(n=0; n<MAX_CARS; n++) { ++cur_arg; if (cur_arg == argc) { break; } ptr = argv[cur_arg]; if((i = find_name(ptr)) < 0) { strcpy(lastext, ptr); --cur_arg; break; } temp_drv = drivers[i]; for(k=i; k<MAX_CARS-1; k++) { drivers[k] = drivers[k+1]; } drivers[MAX_CARS-1] = temp_drv; } break; case 'f': // f for fast if (isdigit(*ptr)) { draw.m_iFastDisplay = atoi(ptr); } else { draw.m_iFastDisplay = -1; } break; case 'l': // l for race length (in miles) if (isdigit(*ptr)) { m_iRaceLength = atol(ptr); } break; case 'm': if ((*ptr == 'p') || (*ptr == 'r')) { // get movie filename if (*(ptr+1)) { strcpy( m_sMovieName, ptr+1 ); char *p = strchr( m_sMovieName,'.' ); if( p ) { *p = 0; } } m_iMovieMode = (*ptr == 'r'? MOVIE_RECORD : MOVIE_PLAYBACK); } break; case 'n': // n for no or non if(*ptr == 'r') // nr for non-random { m_bRndmiz = false; if(*(ptr+1) != ' ') // this when -nr has a seed given { m_iSeed = (long)atol(ptr+1); } } else if(*ptr == 'R') // nR for even more non-random { m_bRndmiz = false; m_bRandomMotion = false; } else if(*ptr == 'd') // nd for no display { draw.m_bDisplay = false; } break; case 'o': // o for order m_bKeepOrder = true; break; case 'p': // p for practice m_bPractice = 1; // practice mode if(isdigit(*ptr)) { m_iNumPracticeLap = atol(ptr); // lap count entered without space } break; case 'q': { // Do ugly adjustment to new structure int qualifying = 1; if (isdigit(*ptr)) { qualifying = atoi(ptr);// set another mode by 0, 1 or 2 } else if(*ptr == '\0') { if(!qualifying) { qualifying = 1; // set default if only -q } } else if (*ptr == 'l') // ql for qual lap count { if(*(ptr+1) != ' ') { m_iNumQualLap = atol(ptr+1); if(!qualifying) { qualifying = 1;// set default } } } else if (*ptr == 'r') // qr for qual sessions or { if(*(ptr+1) != ' ') // qual Rounds { m_iNumQualSession = atoi(ptr+1); if(!qualifying) { qualifying = 1;// set default } } } // Adjust to new structure if (qualifying == 0) { m_bQual = false; } else if (qualifying == 1) { m_bQual = true; } else if (qualifying == 2) { m_bQual = true; m_iQualMode = QUAL_AVERAGE_SPEED; } break; } case 'r': // r for races if(*ptr == '\0') // a space after the - causes a new argument { ++cur_arg; // this is because spaces increase the arg count ptr = argv[cur_arg]; } m_iNumRace = atol(ptr); // number of races entered without space break; case 's': if(*ptr == 'r') // sr for starting rows { m_iStartRows = atoi(ptr+1); } else { m_iSurface = atoi(ptr); } break; case 'v': // v for version VersionReport(); exit(0); case 'z': // side vision m_bGlobalSideVision = false; break; } // end switch() } // end if( c == '-') else if(c >= '0' && c <= '9') // is it a numerical argument? { if(!num_count) // is this the first such? { m_iNumCar = atoi(ptr); } else { m_iNumLap = atol(ptr); // if lap_count is explicitly defined, m_iRaceLength = 0; // don't use race_length value } ++num_count; } else // then its a text argument { if( m_iNumTrack<MAX_TRACKS ) { // tmp_ptr=new char[16]; // strcpy(tmp_ptr,argv[cur_arg]); // m_aTracks[m_iNumTrack++]=tmp_ptr; m_aTracks[m_iNumTrack++]=argv[cur_arg]; } else { cout<<"Max "<<MAX_TRACKS<<" tracks per series.."<<endl; } } } // end big for(;;) loop. // handle goofy command line input: if( m_iNumCar>MAX_CARS ) { m_iNumCar = MAX_CARS; } if( m_iNumCar<0 ) { m_iNumCar = 0; } if( m_iNumLap<0 ) { m_iNumLap = 0; // use race_length for finding lap_count } if(!m_iNumLap && m_iRaceLength<=0 ) { m_iRaceLength = 200; // negative lap_count was entered? } if( m_iNumQualLap<=0 ) { m_iNumQualLap=1; } if(m_iNumPracticeLap <= 0) { m_iNumPracticeLap = 1; } if( m_iNumTrack<=0 ) { tmp_ptr=new char[16]; strcpy(tmp_ptr,"rars.trk"); //the default trackfile m_aTracks[0]=tmp_ptr; m_iNumTrack = 1; } /* if(qualifying > 2 || qualifying < 0) { qualifying = 1; // only 0,1,2 allowed (not necessary anymore) } */ if( m_iStartRows<0 || m_iStartRows>8 ) // starting rows { m_iStartRows = 1; } if(draw.m_iFastDisplay < -1 ) { draw.m_iFastDisplay = 1; } if(!strcmp(m_aTracks[0], "season")) // read tracks from file { Track::readTrackNamesFromFile(); } // check to see if a bogus driver name was entered under the -d option: if(!lastext[0]) { return; // OK if nothing was captured } for(i=0; lastext[i]; i++) // OK if a number was captured { c = lastext[i]; if(c < '0' || c > '9') // is it a number? { break; // leave loop if not a number } } if(i == (int)strlen(lastext)) { return; // This when lastext contains only numbers } }
Connection* DriverManager::connect(const std::string& driverName, const std::string& url) { Driver* d = getDriver(driverName); Connection* c = d->connect(url); return c; }
// *************************************************************************** void CScene::renderPart(UScene::TRenderPart rp, bool doHrcPass, bool doTrav, bool keepTrav) { nlassert(_IsRendering); // if nothing (????), abort if(rp==UScene::RenderNothing) return; // If part asked already rendered, abort nlassert((rp & _RenderedPart) == 0); // cannot render the same part twice during a render // if first part to be rendered, do the start stuff if (_RenderedPart == UScene::RenderNothing) { RenderTrav.clearWaterModelList(); if (doTrav) { // update water envmap //updateWaterEnvmap(); _FirstFlare = NULL; double fNewGlobalSystemTime = NLMISC::CTime::ticksToSecond(NLMISC::CTime::getPerformanceTime()); if(_GlobalSystemTime==0) _DeltaSystemTimeBetweenRender= 0.020; else _DeltaSystemTimeBetweenRender= fNewGlobalSystemTime - _GlobalSystemTime; _GlobalSystemTime = fNewGlobalSystemTime; } // ++ _NumRender; // nlassert(CurrentCamera); // update models. updateModels(); // Use the camera to setup Clip / Render pass. float left, right, bottom, top, znear, zfar; CurrentCamera->getFrustum(left, right, bottom, top, znear, zfar); // setup basic camera. ClipTrav.setFrustum(left, right, bottom, top, znear, zfar, CurrentCamera->isPerspective()); RenderTrav.setFrustum (left, right, bottom, top, znear, zfar, CurrentCamera->isPerspective()); RenderTrav.setViewport (_Viewport); LoadBalancingTrav.setFrustum (left, right, bottom, top, znear, zfar, CurrentCamera->isPerspective()); // Set Infos for cliptrav. ClipTrav.Camera = CurrentCamera; ClipTrav.setQuadGridClipManager (_QuadGridClipManager); // **** For all render traversals, traverse them (except the Hrc one), in ascending order. if( doHrcPass ) HrcTrav.traverse(); else HrcTrav._MovingObjects.clear(); // Set Cam World Matrix for all trav that need it ClipTrav.setCamMatrix(CurrentCamera->getWorldMatrix()); RenderTrav.setCamMatrix (CurrentCamera->getWorldMatrix()); LoadBalancingTrav.setCamMatrix (CurrentCamera->getWorldMatrix()); // clip ClipTrav.traverse(); // animDetail AnimDetailTrav.traverse(); // loadBalance LoadBalancingTrav.traverse(); if (doTrav) { // if (_RequestParticlesAnimate) { _ParticleSystemManager.processAnimate(_EllapsedTime); // deals with permanently animated particle systems _RequestParticlesAnimate = false; } } // Light LightTrav.traverse(); } // render RenderTrav.traverse(rp, (_RenderedPart == UScene::RenderNothing), doTrav); if (!keepTrav) { // Always must clear shadow caster (if render did not work because of IDriver::isLost()) RenderTrav.getShadowMapManager().clearAllShadowCasters(); } // render flare if (rp & UScene::RenderFlare) { if (doTrav) { if (_FirstFlare) { IDriver *drv = getDriver(); CFlareModel::updateOcclusionQueryBegin(drv); CFlareModel *currFlare = _FirstFlare; do { currFlare->updateOcclusionQuery(drv); currFlare = currFlare->Next; } while(currFlare); CFlareModel::updateOcclusionQueryEnd(drv); } } else { _FirstFlare = NULL; } } _RenderedPart = (UScene::TRenderPart) (_RenderedPart | rp); }
// *************************************************************************** void CScene::endPartRender(bool keepTrav) { nlassert(_IsRendering); _IsRendering = false; if (!keepTrav) { // Delete model deleted during the rendering uint i; for (i=0; i<_ToDelete.size(); i++) deleteModel (_ToDelete[i]); _ToDelete.clear (); // Special for SkeletonSpawnScript animation. create models spawned now flushSSSModelRequests(); // Particle system handling (remove the resources of those which are too far, as their clusters may not have been parsed). // Note that only a few of them are tested at each call _ParticleSystemManager.refreshModels(ClipTrav.WorldFrustumPyramid, ClipTrav.CamPos); // Waiting Instance handling double deltaT = _DeltaSystemTimeBetweenRender; clamp (deltaT, 0.01, 0.1); updateWaitingInstances(deltaT); } // Reset profiling _NextRenderProfile= false; IDriver *drv = getDriver(); drv->activeVertexProgram(NULL); drv->activePixelProgram(NULL); drv->activeGeometryProgram(NULL); // Ensure nothing animates on subsequent renders _EllapsedTime = 0.f; /* uint64 total = PSStatsRegisterPSModelObserver + PSStatsRemovePSModelObserver + PSStatsUpdateOpacityInfos + PSStatsUpdateLightingInfos + PSStatsGetAABBox + PSStatsReallocRsc + PSStatsReleasePSPointer + PSStatsRefreshRscDeletion + PSStatsReleaseRsc + PSStatsReleaseRscAndInvalidate + PSStatsGetNumTriangles + PSStatsCheckAgainstPyramid + PSStatsTraverseAnimDetail + PSStatsDoAnimate + PSStatsTraverseRender + PSStatsTraverseClip + PSStatsCheckDestroyCondition + PSStatsForceInstanciate + PSStatsDoAnimatePart1 + PSStatsDoAnimatePart2 + PSStatsDoAnimatePart3 + PSStatsTraverseAnimDetailPart1 + PSStatsTraverseAnimDetailPart2 + PSStatsTraverseAnimDetailPart3 + PSStatsTraverseAnimDetailPart4 + PSAnim1 + PSAnim2+ PSAnim3+ PSAnim4+ PSAnim5+ PSAnim6+ PSAnim7+ PSAnim8+ PSAnim9+ PSAnim10+ PSAnim11; if (((double) total / (double) NLMISC::CSystemInfo::getProcessorFrequency()) > 0.01) { nlinfo("***** PS STATS ****"); #define PS_STATS(var) \ nlinfo("time for " #var " = %.2f", (float) (1000 * ((double) var / (double) CSystemInfo::getProcessorFrequency()))); PS_STATS(PSStatsRegisterPSModelObserver) PS_STATS(PSStatsRemovePSModelObserver) PS_STATS(PSStatsUpdateOpacityInfos) PS_STATS(PSStatsUpdateLightingInfos) PS_STATS(PSStatsGetAABBox) PS_STATS(PSStatsReallocRsc) PS_STATS(PSStatsReleasePSPointer) PS_STATS(PSStatsRefreshRscDeletion) PS_STATS(PSStatsReleaseRsc) PS_STATS(PSStatsReleaseRscAndInvalidate) PS_STATS(PSStatsGetNumTriangles) PS_STATS(PSStatsCheckAgainstPyramid) PS_STATS(PSStatsTraverseAnimDetail) PS_STATS(PSStatsDoAnimate) PS_STATS(PSStatsTraverseRender) PS_STATS(PSStatsTraverseClip) PS_STATS(PSStatsClipSystemInstanciated); PS_STATS(PSStatsClipSystemNotInstanciated); PS_STATS(PSStatsClipSystemCheckAgainstPyramid); PS_STATS(PSStatsInsertInVisibleList); PS_STATS(PSStatsCheckDestroyCondition) PS_STATS(PSStatsForceInstanciate) PS_STATS(PSStatsDoAnimatePart1) PS_STATS(PSStatsDoAnimatePart2) PS_STATS(PSStatsDoAnimatePart3) PS_STATS(PSStatsTraverseAnimDetailPart1) PS_STATS(PSStatsTraverseAnimDetailPart2) PS_STATS(PSStatsTraverseAnimDetailPart3) PS_STATS(PSStatsTraverseAnimDetailPart4) PS_STATS(PSAnim1) PS_STATS(PSAnim2) PS_STATS(PSAnim3) PS_STATS(PSAnim4) PS_STATS(PSAnim5) PS_STATS(PSAnim6) PS_STATS(PSAnim7) PS_STATS(PSAnim8) PS_STATS(PSAnim9) PS_STATS(PSAnim10) PS_STATS(PSAnim11) PS_STATS(PSStatsZonePlane) PS_STATS(PSStatsZoneSphere) PS_STATS(PSStatsZoneDisc) PS_STATS(PSStatsZoneRectangle) PS_STATS(PSStatsZoneCylinder) PS_STATS(PSMotion1) PS_STATS(PSMotion2) PS_STATS(PSMotion3) PS_STATS(PSMotion4) PS_STATS(PSStatCollision) PS_STATS(PSStatEmit) PS_STATS(PSStatRender) nlinfo("num do animate = %d", (int) PSStatsNumDoAnimateCalls); nlinfo("Max et = %.2f", PSMaxET); nlinfo("Max ps nb pass = %d", (int) PSMaxNBPass); PS_STATS(total) } PSStatsRegisterPSModelObserver = 0; PSStatsRemovePSModelObserver = 0; PSStatsUpdateOpacityInfos = 0; PSStatsUpdateLightingInfos = 0; PSStatsGetAABBox = 0; PSStatsReallocRsc = 0; PSStatsReleasePSPointer = 0; PSStatsRefreshRscDeletion = 0; PSStatsReleaseRsc = 0; PSStatsReleaseRscAndInvalidate = 0; PSStatsGetNumTriangles = 0; PSStatsCheckAgainstPyramid = 0; PSStatsTraverseAnimDetail = 0; PSStatsDoAnimate = 0; PSStatsTraverseRender = 0; PSStatsTraverseClip = 0; PSStatsCheckDestroyCondition = 0; PSStatsForceInstanciate = 0; PSStatsClipSystemInstanciated = 0; PSStatsClipSystemNotInstanciated = 0; PSStatsClipSystemCheckAgainstPyramid = 0; PSStatsInsertInVisibleList = 0; PSStatsDoAnimatePart1 = 0; PSStatsDoAnimatePart2 = 0; PSStatsDoAnimatePart3 = 0; PSStatsTraverseAnimDetailPart1 = 0; PSStatsTraverseAnimDetailPart2 = 0; PSStatsTraverseAnimDetailPart3 = 0; PSStatsTraverseAnimDetailPart4 = 0; PSStatsNumDoAnimateCalls = 0; PSAnim1 = 0; PSAnim2 = 0; PSAnim3 = 0; PSAnim4 = 0; PSAnim5 = 0; PSAnim6 = 0; PSAnim7 = 0; PSAnim8 = 0; PSAnim9 = 0; PSAnim10 = 0; PSAnim11 = 0; PSMaxET = 0.f; PSMaxNBPass = 0; PSStatsZonePlane = 0; PSStatsZoneSphere = 0; PSStatsZoneDisc = 0; PSStatsZoneRectangle = 0; PSStatsZoneCylinder = 0; PSMotion1 = 0; PSMotion2 = 0; PSMotion3 = 0; PSMotion4 = 0; PSStatCollision = 0; PSStatEmit = 0; PSStatRender = 0; */ }