bool LZ77_Compress( LPCWSTR inFileText, LPCWSTR outFileText, UINT8* prefix, size_t prefixLength ) { LZ77_Compressor::Buffer inBuf; LZ77_Compressor::Buffer outBuf; bool fRes = false; if(LZ77_Compressor::LoadFile( inFileText, inBuf ) == false) { wprintf( L"%s does not exist\n", inFileText ); } else { LZ77_Compressor hlp( inBuf, outBuf ); hlp.LeaveSpaceForHeader(); fRes = hlp.Execute(); hlp.EmitHeader(); if(fRes) { if(LZ77_Compressor::SaveFile( outFileText, outBuf, prefix, prefixLength ) == false) { wprintf( L"%s cannot be created\n", outFileText ); } else { UINT8* ptr = &outBuf[0]; int len = (int ) outBuf.size(); int lenIn = *(int*)ptr; ptr += sizeof(int); int lenOut = *(int*)ptr; ptr += sizeof(int); if(lenIn != (len - sizeof(LZ77_Compressor::Header)) || lenOut != inBuf.size()) { wprintf( L"Invalid header!\n" ); } else { LZ77_Compressor::Buffer verBuf; verBuf.resize( lenOut ); if(LZ77_Decompress( ptr, lenIn, &verBuf[ 0 ], lenOut ) == false) { wprintf( L"Decompression failed!\n" ); } else if(memcmp( &verBuf[ 0 ], &inBuf[ 0 ], (int)verBuf.size() ) != 0) { wprintf( L"Verification failed!\n" ); } else { fRes = true; } } } } } return fRes; }
void RubySupportPart::slotRunTestUnderCursor() { // if we can't save all parts, then the user canceled if ( partController()->saveAllFiles() == false ) return; KParts::ReadOnlyPart *ro_part = dynamic_cast<KParts::ReadOnlyPart*>(partController()->activePart()); QString prog; if (ro_part != 0) { prog = ro_part->url().path(); } else return; KTextEditor::ViewCursorInterface* activeViewCursor = dynamic_cast<KTextEditor::ViewCursorInterface*>( ro_part->widget() ); if (!activeViewCursor) return; unsigned int line, column; activeViewCursor->cursorPositionReal(&line, &column); CodeModelUtils::CodeModelHelper hlp(codeModel(), codeModel()->fileByName(prog)); FunctionDom fun = hlp.functionAt(line, column); if (fun == 0) return; QFileInfo program(prog); QString cmd = QString("%1 -K%2 -C\"%3\" -I\"%4\" \"%5\" %6") .arg(interpreter()) .arg(characterCoding()) .arg(runDirectory()) .arg(program.dirPath()) .arg(program.fileName()) .arg(" -n " + fun->name()); startApplication(cmd); }
GammaDouble GammaDoubleMLE (double M, double G) { GammaDoubleMleHelper hlp(G/M); std::pair<double,double> pair = boost::math::tools::bisect(hlp, ABS_ERROR, MAX_SHAPE, GammaDoubleMleTol); double k = (pair.first + pair.second) / 2.0; return GammaDouble(k, M/k); }
/** * @brief This is the public way to access HLIndex instances. * * This function first searches for an existing HIndex with the same type. * If an existing index is not found, it will try to open and parse a * highlighting file with the type name followed by `.hl`. * * If the highlighting file has been found, this function will return the * HLIndex of the file. Otherwise, nullptr will be returned. * * Internally, the first request for a highlighting file will always * create a HLIndex branch, but for unavailable extensions, it will * be empty. This will prevent FencedFilter from repeated attempts to * find a missing file. When HLIndex finds an empty index, it will * return nullptr to revert to default doxygen processing. * * @param type Typical extension of the file type * @return A pointer to an HLIndex if found, nullptr otherwise. */ const HLIndex* HLIndex::get_index(const char *type) { const HLIndex *rval = seek_index(type); if (!rval) { // Make an HLNode and attempt to populate it // with the contents of a highlight file: HLNode *root = new HLNode(type); FILE *f = find_and_open_file(type); if (f) { HLParser hlp(f, root); // Regardless of highlight file success, add a new // HLIndex to the chain with the new HLNode: HLIndex *last = get_last(); rval = last->m_next = new HLIndex(root, hlp.hyphenated_tags(), hlp.case_insensitive()); } } if (rval && !rval->is_empty()) return rval; else return nullptr; }
void CGameStats::SubmitServerStats() { SStatsTrackHelper hlp(this); string mode; if(IEntity* pGRE = gEnv->pGame->GetIGameFramework()->GetIGameRulesSystem()->GetCurrentGameRulesEntity()) { mode = pGRE->GetClass()->GetName(); } else mode = gEnv->pConsole->GetCVar("sv_gamerules")->GetString(); char strProductVersion[256]; gEnv->pSystem->GetProductVersion().ToString(strProductVersion); string name; ICVar* pName = gEnv->pConsole->GetCVar("sv_servername"); if(pName) name = pName->GetString(); if(name.empty()) name = gEnv->pNetwork->GetHostName(); string levelname; GetLevelName(levelname); hlp.ServerValue("mapname",levelname); hlp.ServerValue("gametype",mode); hlp.ServerValue("hostname",name); hlp.ServerValue("gamever",strProductVersion); }
void PMXMLParser::parseChildObjects( QDomElement& e, PMObject* parent ) { QDomNode c = e.firstChild( ); while( !c.isNull( ) ) { if( c.isElement( ) ) { QDomElement ce = c.toElement( ); PMPrototypeManager* m = m_pPart->prototypeManager( ); PMObject* obj = m->newObject( m->className( ce.tagName( ) ) ); if( obj ) { PMXMLHelper hlp( ce, m_pPart, this, m_majorDocumentFormat, m_minorDocumentFormat ); obj->readAttributes( hlp ); if( insertChild( obj, parent ) ) { parseChildObjects( ce, obj ); if( obj->isA( "Declare" ) ) checkID( ( PMDeclare* ) obj ); } else delete obj; } else if( ce.tagName( ) != "extra_data" ) printError( i18n( "Unknown object %1" ).arg( ce.tagName( ) ) ); } c = c.nextSibling( ); } }
GammaDouble GammaDoubleMLE (double M, double G) { GammaDoubleMleHelper hlp(G/M); // Conversion to double is due to an Intel's bug with __builtin_signbit being undefined for float std::pair<double,double> pair = boost::math::tools::bisect(hlp, (double)ABS_ERROR, (double)MAX_SHAPE, GammaDoubleMleTol); double k = (pair.first + pair.second) / 2.0; return GammaDouble(k, M/k); }
FunctionDom Navigator::currentFunction() { if (!m_part->m_activeViewCursor) return FunctionDom(); unsigned int line, column; m_part->m_activeViewCursor->cursorPositionReal(&line, &column); CodeModelUtils::CodeModelHelper hlp( m_part->codeModel(), m_part->codeModel()->fileByName( m_part->m_activeFileName) ); return hlp.functionAt( line, column ); }
double Gamma2Distribution::cumulativeInv(const double p, const bool fast, const long bins) { if(fast) { if(!fastCalculated_ || bins!=fastBins_) { fastBins_=bins; preCalculateCumulativeInv(); } return fastCumulativeInv(p); } G2InvHelper hlp(this,p); Brent b; return b.solve(hlp,INVG2ACC,1.0,0.1); }
void BlobPart::update(float time, float deltaTime, SyncPoints::Part* syncPoints) { static float cameraTime = ((60.0f / 172.0f) * 1.0f); static int camera = 1; m_renderer.setClearColor(0, 0, 0); Model::resetCollectedModelCount(); m_scene->rootNode()->update(time); m_renderer.renderScene(m_scene); if (cameraTime >= ((60.0f / 172.0f) * 3.0f)) { ++camera; if (camera > 3) camera = 1; m_scene->switchToCamera(camera); cameraTime = ((60.0f / 172.0f) * 1.0f); } cameraTime += deltaTime; // Blur glow parts { PostEffectHelper hlp(m_renderer, m_dmaChain); hlp.glareOffScreen(336, 0.0f, 1, 0.8f, 1.6f); } //if (!m_padCamera) m_renderer.setSceneCamera(m_scene->primaryCamera()); //else // m_renderer.setSceneCamera(&m_padCamera->sceneCamera()); PostEffectHelper hlp(m_renderer, m_dmaChain); hlp.motionBlur(0x40); }
void SaPart6::update(float time, float deltaTime, SyncPoints::Part* syncPoints) { static float testTime = 0.0f; static int camera = 1; ZENIC_ASSERT(m_scene); m_renderer.setClearColor(40, 40, 40); /* if (testTime >= ((60.0f / 172.0f) * 2.0f)) { static bool cameraSwitch = false; if (cameraSwitch) m_scene->switchToCamera(1); else m_scene->switchToCamera(2); cameraSwitch = !cameraSwitch; testTime = 0.0f; } */ testTime += deltaTime; //if (!m_padCamera) m_renderer.setSceneCamera(m_scene->primaryCamera()); //else // m_renderer.setSceneCamera(&m_padCamera->sceneCamera()); GS_WRITE(BGCOLOR,GS_BGCOLOR(255,0,0)); Model::resetCollectedModelCount(); m_scene->rootNode()->update(time); float angle = time * 0.1f; Matrix4 my; Matrix4 mx; my = my.makeYrotation(angle); mx = mx.makeXrotation(angle); FftStream& stream = FftStream::instance(); addDisolveObject(stream.hihatData(), 0, my); addDisolveObject(stream.bassData(), 1, mx); m_renderer.renderScene(m_scene, true); PostEffectHelper hlp(m_renderer, m_dmaChain); hlp.motionBlur(0x40); }
int main(int argc, char **argv) { if (arguments_parse(argc, argv) < 0) return EXIT_FAILURE; if (arguments.help) { arguments_usage(argv[0]); return EXIT_SUCCESS; } helper hlp(arguments); return EXIT_SUCCESS; }
boost::shared_ptr<SmileSection> Gaussian1dSwaptionVolatility::smileSectionImpl(Time optionTime, Time swapLength) const { DateHelper hlp(*this, optionTime); NewtonSafe newton; Date d(static_cast<BigInteger>(newton.solve( hlp, 0.1, 365.25 * optionTime + static_cast<Real>(referenceDate().serialNumber()), 1.0))); Period tenor( static_cast<Integer>(Rounding(0).operator()(swapLength * 12.0)), Months); d = indexBase_->fixingCalendar().adjust(d); return smileSectionImpl(d, tenor); }
void LoadingPart::showImage() { ZENIC_ASSERT(m_loading); TextureSystem& textureSystem = m_renderer.textureSystem(); textureSystem.setTexture(0, m_loading); textureSystem.sync(); textureSystem.activateTexture(m_dmaChain, m_loading); PostEffectHelper hlp(m_renderer, m_dmaChain); hlp.setRgba(0, 0, 0, 0); hlp.setTex0Pal((450*32) + 32, (450*32), 2, 20, 7, 7, 0, 1); hlp.blit(0, 0, 512, 448); hlp.blit(192, 200, 192 + 128, 200 + 64, 0.0f, 0.0f, 128.0f, 64.0f, false, true); }
void PMXMLParser::topParse( ) { if( initDocument( ) ) { QDomElement e = m_pDoc->documentElement( ); // read the format number // assume 1.0 on error QString fstring = e.attribute( "majorFormat", "1" ); bool ok = true; int format = fstring.toInt( &ok ); if( !ok || ( format < 1 ) ) format = 1; m_majorDocumentFormat = format; fstring = e.attribute( "minorFormat", "0" ); ok = true; format = fstring.toInt( &ok ); if( !ok || ( format < 0 ) ) format = 0; m_minorDocumentFormat = format; if( ( m_majorDocumentFormat > c_majorDocumentFormat ) || ( m_majorDocumentFormat == c_majorDocumentFormat ) && ( m_minorDocumentFormat > c_minorDocumentFormat ) ) printWarning( i18n( "This document was created with a newer version of KPovModeler. " "The whole document may not be loaded correctly." ) ); if( e.tagName( ) == "objects" ) { parseChildObjects( e, 0 ); } else if( e.tagName( ) == "scene" ) { PMScene* scene = new PMScene( m_pPart ); insertChild( scene, 0 ); PMXMLHelper hlp( e, m_pPart, this, m_majorDocumentFormat, m_minorDocumentFormat ); scene->readAttributes( hlp ); parseChildObjects( e, scene ); } else { printError( i18n( "Wrong top level tag" ) ); setFatalError( ); } } }
void LoadingPart::update(float progress, float time, SyncPoints::Part* syncPoints) { if (time > 0.0f) { showImage(); PostEffectHelper hlp(m_renderer, m_dmaChain); hlp.fadeDownFrame(0, 0, 0, 0.99f - time); } else { showImage(); m_renderer.flip(); showImage(); m_renderer.flip(); showImage(); } }
int main(int argc, char**argv) { FrobObject obj; NMPropertyHelper hlp(&obj); QPair<char*,char*> spec; spec.first = "frobozz"; spec.second = "frobozzChanged"; hlp.registerProperty("frobozz", spec); hlp.registerProperty("othername", QPair<char*,char*>("myname", 0)); QVariantMap map; map.insert(QString("frobozz"), QVariant(42.0)); map.insert(QString("othername"), QVariant("pas")); hlp.deserializeProperties(map); qDebug("Hello mom"); qDebug() << "map keys: " << map.keys(); qDebug() << "qobj frobozz property (names match): " << obj.property("frobozz"); qDebug() << "qobj myname property (mapped from othername): " << obj.property("myname"); return 0; }
boost::shared_ptr<SmileSection> SingleSabrSwaptionVolatility::smileSectionImpl(Time optionTime, Time swapLength) const { std::vector<Real> params(4); params[0] = alpha_; params[1] = beta_; params[2] = nu_; params[3] = rho_; DateHelper hlp(*this,optionTime); NewtonSafe newton; Date d(static_cast<BigInteger>(newton.solve( hlp, 0.1, 365.25 * optionTime + static_cast<Real>(referenceDate().serialNumber()), 1.0))); Period tenor(static_cast<Integer>(Rounding(0).operator()(swapLength*12.0)), Months); d = indexBase_->fixingCalendar().adjust(d); Real forward = indexBase_->clone(tenor)->fixing(d); boost::shared_ptr<SmileSection> raw(new SabrSmileSection(optionTime,forward,params,shift_)); // make it arbitrage free //boost::shared_ptr<SmileSection> af(new KahaleSmileSection(raw)); //return af; return raw; }
/******************************************************************** * Parse command-line option (global) * * Parameters: * cfg_file: TRUE if called from a configuration file * FALSE if command-line option * * Returns: * -1: parameter was found (opt doesn't start with -+) * 0: option was found * 1: option was NOT found * 2: an error ********************************************************************/ static int parse_cmd_opt(char *opt, BOOL cfg_file) { option_item *op; int opt_off; char *p_err; if(opt == NULL) { /* internal error */ DM_ERR_ASSERT("opt == NULL\n"); return 0; } /* Process the options */ /* Parameters */ if (!(*opt == '-' || *opt == '+')) return -1; if (OPL("-0") || OPL("--e0-file")) { /* before-execution log messages filename */ if(opt_off > 2 && *(opt + opt_off) == '=') /* long option, ignore '=' */ opt_off++; f_close(opts.e0_fname, &opts.e0_file); opts.e0_fname = opt + opt_off; if(strcmp(opts.e0_fname, "-") == 0) /* standard output */ opts.e0_fname = NULL; f_open(opts.e0_fname, &opts.e0_file); return 0; } if (OPL("-1") || OPL("--e1-file")) { /* after-execution log messages filename */ if(opt_off > 2 && *(opt + opt_off) == '=') /* long option, ignore '=' */ opt_off++; f_close(opts.e1_fname, &opts.e1_file); opts.e1_fname = opt + opt_off; if(strcmp(opts.e1_fname, "-") == 0) /* standard output */ opts.e1_fname = NULL; f_open(opts.e1_fname, &opts.e1_file); return 0; } if (OPL("-2") || OPL("--e2-file")) { /* after-evaluation log messages filename */ if(opt_off > 2 && *(opt + opt_off) == '=') /* long option, ignore '=' */ opt_off++; f_close(opts.e2_fname, &opts.e2_file); opts.e2_fname = opt + opt_off; if(strcmp(opts.e2_fname, "-") == 0) /* standard output */ opts.e2_fname = NULL; f_open(opts.e2_fname, &opts.e2_file); return 0; } if (OPL("-a") || OPL("--ansi")) { /* ANSI colors */ if(opt_off > 2 && *(opt + opt_off) == '=') /* long option, ignore '=' */ opt_off++; opts.ansi = strtol(opt + opt_off, &p_err, 0); if (p_err == opt + opt_off || *p_err) { /* no option value given || value contains invalid/non-digit char */ opts.ansi = TRUE; } DM_ANSI_SET(opts.ansi); return 0; } if (OPL("-b") || OPL("--verbose")) { /* verbose/quiet execution */ if(opt_off > 2 && *(opt + opt_off) == '=') /* long option, ignore '=' */ opt_off++; opts.verbose = strtol(opt + opt_off, &p_err, 0); if (p_err == opt + opt_off || *p_err) /* no option value given || value contains invalid/non-digit char */ opts.verbose = 1; /* limit verbosity */ if(opts.verbose > VERBOSE_MAX) opts.verbose = VERBOSE_MAX; else if(opts.verbose < VERBOSE_MIN) opts.verbose = VERBOSE_MIN; if(opts.verbose > 0) DM_LOG_SET_L((1 << opts.verbose) - 1); if(opts.verbose <= -1) /* disable warning messages */ DM_WARN_SET_L(0); if(opts.verbose <= -2) /* disable error messages */ DM_ERR_SET_L(0); return 0; } if (OPL("-h") || OPL("-?") || OPL("--help")) { /* help */ if(opt_off > 2 && *(opt + opt_off) == '=') /* long option, ignore '=' */ opt_off++; opts.help = strtol(opt + opt_off, &p_err, 0); if (p_err == opt + opt_off || *p_err) { /* no option value given || value contains invalid/non-digit char */ opts.help = 0; } // hlp(opts.help); exit(0); hlp(0); /* only level 0 help so far */ exit(0); return 0; } if (OPL("-d") || OPL("--dbg-file")) { /* debug messages output filename */ if(opt_off > 2 && *(opt + opt_off) == '=') /* long option, ignore '=' */ opt_off++; opts.dbg_fname = opt + opt_off; DM_DBG_OPEN(opts.dbg_fname); /* old stream is automatically closed */ return 0; } if (OPL("-e") || OPL("--eval")) { /* default evaluation threshold for branches */ if(opt_off > 2 && *(opt + opt_off) == '=') /* long option, ignore '=' */ opt_off++; opts.s2_eval = strtol(opt + opt_off, &p_err, 0); if (p_err == opt + opt_off || *p_err) /* no option value given || value contains invalid/non-digit char */ opts.s2_eval = S2_EVAL; return 0; } if (OPL("-f") || OPL("--file")) { /* script filename */ if(opt_off > 2 && *(opt + opt_off) == '=') /* long option, ignore '=' */ opt_off++; opts.scr_fname = opt + opt_off; if(strcmp(opts.scr_fname, "-") == 0) /* standard input */ opts.scr_fname = NULL; return 0; } if (OPL("-g") || OPL("--progress")) { /* progress bar */ if(opt_off > 2 && *(opt + opt_off) == '=') /* long option, ignore '=' */ opt_off++; opts.progress_bar = strtol(opt + opt_off, &p_err, 0); if (p_err == opt + opt_off || *p_err) /* no option value given || value contains invalid/non-digit char */ opts.progress_bar = TRUE; return 0; } if (OPL("-i") || OPL("--pp-indent")) { /* pretty-printer indentation value */ BOOL vrb_msg = FALSE; if(opt_off > 2 && *(opt + opt_off) == '=') /* long option, ignore '=' */ opt_off++; opts.pp_indent = strtol(opt + opt_off, &p_err, 0); /* limit pretty-printer indentation */ if (opts.pp_indent > PP_INDENT_MAX) { opts.pp_indent = PP_INDENT_MAX; vrb_msg = TRUE; } else if (opts.pp_indent < PP_INDENT_MIN) { opts.pp_indent = PP_INDENT_MIN; vrb_msg = TRUE; } if (p_err == opt + opt_off || *p_err || opts.pp_indent < PP_INDENT_MIN || opts.pp_indent > PP_INDENT_MAX) { /* no option value given || value contains invalid/non-digit char */ opts.pp_indent = PP_INDENT; vrb_msg = TRUE; } if(vrb_msg) DM_DBG(DM_N(1),_("pretty-printer indentation set to %d spaces\n"), opts.pp_indent); return 0; } if (OPL("-l") || OPL("--log-file")) { /* default log filename */ if(opt_off > 2 && *(opt + opt_off) == '=') /* long option, ignore '=' */ opt_off++; opts.log_fname = opt + opt_off; DM_LOG_OPEN(opts.log_fname); /* old stream is automatically closed */ return 0; } if (OPL("-p") || OPL("--pp-out-file")) { /* pretty-printer output file */ if(opt_off > 2 && *(opt + opt_off) == '=') /* long option, ignore '=' */ opt_off++; f_close(opts.pp_fname, &opts.pp_file); opts.pp_fname = opt + opt_off; if(strcmp(opts.pp_fname, "-") == 0) /* standard output */ opts.pp_fname = NULL; f_open(opts.pp_fname, &opts.pp_file); return 0; } if (OPL("-r") || OPL("--err-file")) { /* error messages output filename */ if(opt_off > 2 && *(opt + opt_off) == '=') /* long option, ignore '=' */ opt_off++; opts.err_fname = opt + opt_off; DM_ERR_OPEN(opts.err_fname); /* old stream is automatically closed */ return 0; } if (OPL("-s") || OPL("--show-defaults")) { /* show default values (pretty-printer, evaluator) ON/OFF */ if(opt_off > 2 && *(opt + opt_off) == '=') /* long option, ignore '=' */ opt_off++; opts.show_defaults = strtol(opt + opt_off, &p_err, 0); if (p_err == opt + opt_off || *p_err) { /* no option value given || value contains invalid/non-digit char */ opts.show_defaults = TRUE; } return 0; } if (OPL("-S") || OPL("--simple-name")) { opts.simple_name = TRUE; } if (OPL("-T") || OPL("--threads")) { /* threads in the thread pool */ if(opt_off > 2 && *(opt + opt_off) == '=') /* long option, ignore '=' */ opt_off++; opts.tp_size = strtol(opt + opt_off, &p_err, 0); if (p_err == opt + opt_off || *p_err) /* no option value given || value contains invalid/non-digit char */ opts.tp_size = TP_THREADS_DEF; /* limit verbosity */ if(opts.tp_size > TP_THREADS_MAX) opts.tp_size = TP_THREADS_MAX; else if(opts.tp_size < TP_THREADS_MIN) opts.tp_size = TP_THREADS_MIN; return 0; } if (OPL("-t") || OPL("--timeout")) { /* default timeout for branches */ if(opt_off > 2 && *(opt + opt_off) == '=') /* long option, ignore '=' */ opt_off++; opts.s2_timeout = strtol(opt + opt_off, &p_err, 0); if (p_err == opt + opt_off || *p_err) /* no option value given || value contains invalid/non-digit char */ opts.s2_timeout = S2_TIMEOUT; return 0; } if (OPL("-V") || OPL("--version")) { /* print the version and exit */ fprintf(stderr,_("%s version %s\n"), PNAME(), VERSION); exit(ERR_OK); } if (OPL("-w") || OPL("--warn-file")) { /* warning messages output filename */ if(opt_off > 2 && *(opt + opt_off) == '=') /* long option, ignore '=' */ opt_off++; opts.warn_fname = opt + opt_off; DM_WARN_OPEN(opts.warn_fname); /* old stream is automatically closed */ return 0; } /* default option handling */ if (opt[1] == '-' || opt[1] == '+') { int ret_val = 1; /* try long options */ for (op = optionlist; op->short_name; op++) { if (op->long_name && strcmp(opt+2, op->long_name) == 0) { ret_val = 0; handle_option(op->short_name); break; } } return ret_val; } else /* try short options */ return handle_option(opt+1); return 1; }
void CGameStats::SubmitPlayerStats(const SPlayerInfo& plr, bool server, bool client) { if(!m_statsTrack) return; SStatsTrackHelper hlp(this); //server stats const SPlayerStats& stats = *(plr.stats.back()); if(server) { hlp.PlayerValue(plr.id, "name", plr.name.c_str()); hlp.PlayerValue(plr.id, "rank", plr.rank); hlp.PlayerValue(plr.id, "kills", stats.m_kills); hlp.PlayerValue(plr.id, "deaths", stats.m_deaths); hlp.PlayerValue(plr.id, "shots", stats.m_shots); hlp.PlayerValue(plr.id, "hits", stats.m_hits); hlp.PlayerValue(plr.id, "melee", stats.m_melee); } //here are some client-only stats - mainly times if(client) { CTimeValue time = SGetTime(m_roundStart); plr.stats.back()->End(time); int played = int((time - plr.stats.back()->m_started).GetSeconds()+0.5f); int played_minutes = played/60; hlp.PlayerValue(plr.id,"played",played_minutes); static string keyName; keyName.Format("Played%s",m_gameMode.c_str()); hlp.PlayerCatValue(plr.id, "mode", keyName, played); keyName.Format("PlayedMap%s",m_mapName.c_str()); hlp.PlayerCatValue(plr.id, "map", keyName, played); for(int i=0; i<4; ++i) { int used = int(stats.m_suit.m_used[i].GetSeconds()+0.5f); if(!used) continue; keyName.Format("UsedSuit%d",i); hlp.PlayerCatValue(plr.id, "suit_mode", keyName, used); } for(int i=0; i<stats.m_vehicles.m_vehicles.size(); ++i) { const SPlayerStats::SVehicles::SVehicle& veh = stats.m_vehicles.m_vehicles[i]; int used = int(veh.m_used.GetSeconds() + 0.5f); keyName.Format("UsedVehicle%s",veh.m_name.c_str()); hlp.PlayerCatValue(plr.id, "vehicle", keyName, used); } for(int i=0; i<stats.m_weapons.m_weapons.size(); ++i) { const SPlayerStats::SWeapons::SWeapon& wep= stats.m_weapons.m_weapons[i]; if(!wep.m_kills) continue; keyName.Format("WeaponKills%s", wep.m_name.c_str()); hlp.PlayerCatValue(plr.id, "weapon", keyName, wep.m_kills); } } //Debugging stuff if(!hlp.m_errors.empty()) { GameWarning("Stats tracking : SubmitPlayerStats tried to use %d missing key(s)", (int)hlp.m_errors.size()); for(int i=0; i<hlp.m_errors.size(); ++i) { GameWarning(" Key %s not found",hlp.m_errors[i].c_str()); } } }
BOOL DataRecordsXmlSerializer::Import(LPCTSTR fileName, FullTrackRecordCollection& col) { HRESULT hr; CComPtr<IStream> pInFileStream; CComPtr<IXmlReader> pReader; //Open writeable output stream if (FAILED(hr = FileStream::OpenFile(fileName, &pInFileStream, FALSE))) { TRACE(_T("@1 DataRecordsXmlSerializer::Import. Error creating file reader, error is %08.8lx"), hr); return FALSE; } if (FAILED(hr = CreateXmlReader(__uuidof(IXmlReader),(void**) &pReader, NULL))) { TRACE(_T("@1 DataRecordsXmlSerializer::Import. Error creating IXmlReader, error is %08.8lx"), hr); return FALSE; } if (FAILED(hr = pReader->SetInput(pInFileStream))) { TRACE(_T("@1 DataRecordsXmlSerializer::Import. Error setting Input for reader, error is %08.8lx"), hr); return FALSE; } XmlLiteReaderHelper hlp(*pReader); if (hlp.FindElement(_T("fulltrackcollection"), 0)) { while (hlp.FindElement(_T("fulltrackrecord"), 1)) { FullTrackRecord* pRec = new FullTrackRecord; XmlNodeType nodeType; const WCHAR* pwszLocalName = NULL; while (pReader->Read(&nodeType) == S_OK) { if (nodeType == XmlNodeType_Element) { if (pReader->GetLocalName(&pwszLocalName, NULL) == S_OK) { if (_tcsicmp(pwszLocalName, _T("trackname")) == 0) pRec->track.name = hlp.GetElementText(); //else if (_tcsicmp(pwszLocalName, _T("trackdateadded")) == 0) // pRec->track.dateAdded = hlp.GetElementText(); else if (_tcsicmp(pwszLocalName, _T("tracklocation")) == 0) pRec->track.location = hlp.GetElementText(); else if (_tcsicmp(pwszLocalName, _T("trackbitrate")) == 0) pRec->track.bitrate = _ttoi(hlp.GetElementText()); else if (_tcsicmp(pwszLocalName, _T("trackduration")) == 0) pRec->track.duration = _ttoi(hlp.GetElementText()); else if (_tcsicmp(pwszLocalName, _T("tracksize")) == 0) pRec->track.size = _ttoi(hlp.GetElementText()); else if (_tcsicmp(pwszLocalName, _T("tracktrackNo")) == 0) pRec->track.trackNo = _ttoi(hlp.GetElementText()); else if (_tcsicmp(pwszLocalName, _T("trackyear")) == 0) pRec->track.year = _ttoi(hlp.GetElementText()); else if (_tcsicmp(pwszLocalName, _T("trackrating")) == 0) pRec->track.rating = _ttoi(hlp.GetElementText()); else if (_tcsicmp(pwszLocalName, _T("albumname")) == 0) pRec->album.name = hlp.GetElementText(); else if (_tcsicmp(pwszLocalName, _T("albumrating")) == 0) pRec->album.rating = _ttoi(hlp.GetElementText()); else if (_tcsicmp(pwszLocalName, _T("albumyear")) == 0) pRec->album.year = _ttoi(hlp.GetElementText()); else if (_tcsicmp(pwszLocalName, _T("artistname")) == 0) pRec->artist.name = hlp.GetElementText(); else if (_tcsicmp(pwszLocalName, _T("artistrating")) == 0) pRec->artist.rating = _ttoi(hlp.GetElementText()); else if (_tcsicmp(pwszLocalName, _T("genrename")) == 0) pRec->genre.name = hlp.GetElementText(); } } else if (nodeType == XmlNodeType_EndElement) { UINT depth = 0; pReader->GetDepth(&depth); if (depth < 3) break; } } col.push_back(FullTrackRecordSP(pRec)); } } pReader.Release(); pInFileStream.Release(); return TRUE; }