std::string NeuralNetworkRepresentation::insertNeuron(ioPair identification, unsigned int layer, unsigned int type) { boost::shared_ptr<NeuronRepresentation> neuron = boost::shared_ptr< NeuronRepresentation>( new NeuronRepresentation(identification, layer, type)); // insert into map if (neurons_.count(identification)) { std::cout << "ATTENTION: attempting to insert a neuron with id " << identification.first << "-" << identification.second << ", which already exists" << std::endl; } neurons_[identification] = neuron; // generate weights for (NeuronMap::iterator it = neurons_.begin(); it != neurons_.end(); ++it) { // generate incoming if (!neuron->isInput() && (neuron->getType() != NeuronRepresentation::OSCILLATOR)) { weights_[StringPair(it->second->getId(), neuron->getId())] = 0.; } // generate outgoing (no need to worry about double declaration of the // recursion, as we deal with a map!) if (!it->second->isInput()) weights_[StringPair(neuron->getId(), it->second->getId())] = 0.; } return neuron->getId(); }
void GameDatabase::LoadGame(const size_t index, Game &game, const GameObjectEnginePtr &engine, ISerialize& stats) { wxASSERT(mOffsets.size() > index); wxFileInputStream x(FilePath::Data(DataFileGames)); wxDataInputStream games(x); // Seek to this position in the game file. x.SeekI(mOffsets[index]); // Read in the rulesets this game was using. wxUint32 size; games >> size; StringPairArray rulesets; rulesets.reserve(size); for(wxUint32 i = 0; i < size; ++i) { wxString module, ruleset; games >> module; games >> ruleset; rulesets.push_back(StringPair(module, ruleset)); } games >> size; StringPairArray options; options.reserve(size); for(wxUint32 i = 0; i < size; ++i) { wxString module, ruleset; games >> module; games >> ruleset; options.push_back(StringPair(module, ruleset)); } // Fire off the load event for any listeners to deal with it. if(engine) { Controller::get().Transmit(shEventLoadRulesets, rulesets); Controller::get().Transmit(shEventLoadOptions, options); // Immediately start up the game, too. Controller::get().Transmit(shEventStartGame, false); } game.load(games, engine); // Stats must always go at the end so we can ignore them while loading if // desired. stats.load(games); }
TGen::Engine::CommandTokenizer::CommandTokenizer() { autoAddTilNextIgnore = true; ignores.push_back(" "); ignores.push_back("\t"); ignores.push_back("\r"); quotes.push_back(StringPair("\"", "\"")); comments.push_back(StringPair("//", "\n")); comments.push_back(StringPair("/*", "*/")); tokens["\n"] = TGen::Engine::CommandTokenEOL; tokens[";"] = TGen::Engine::CommandTokenEOL; }
Model::Model(const QString& hashTableFilename, QTextStream& out) { countTagsPair.clear(); dict.clear(); endsAndTags.clear(); countEndsTags.clear(); QFile fin(hashTableFilename); if (!fin.open(QIODevice::ReadOnly)) { out << "ERROR: hash table file not found" << endl; } QByteArray rawInput = fin.readAll(); rawInput = qUncompress(rawInput); QTextStream htFile(rawInput, QIODevice::ReadOnly); htFile.setCodec("CP1251"); QString tmp1, tmp2, tmp3; ulong longtmp; QString curTags; while (true) { htFile >> tmp1; if (tmp1 == "&") { htFile >> curTags; continue; } if (tmp1 == "----------") { break; } htFile >> tmp2; dict.insert(tmp2, StringPair(tmp1, curTags)); }
void AlsaDeviceListModel::init( const char * _iface, const char * _filter) { void **hints, **n; char *name, *descr, *io; if (snd_device_name_hint(-1, _iface, &hints) < 0) return; n = hints; while (*n != NULL) { name = snd_device_name_get_hint(*n, "NAME"); descr = snd_device_name_get_hint(*n, "DESC"); io = snd_device_name_get_hint(*n, "IOID"); // Filter out non-null or filtered items if (io == NULL || _filter == NULL || strcmp(io, _filter) == 0) m_devices.append(StringPair(name, descr)); if (name != NULL) free(name); if (descr != NULL) free(descr); if (io != NULL) free(io); n++; } snd_device_name_free_hint(hints); }
TGen::PropertyTreeTokenizer::PropertyTreeTokenizer() { autoAddTilNextIgnore = true; ignores.push_back(" "); ignores.push_back("\t"); ignores.push_back("\r"); //ignores.push_back("\n"); quotes.push_back(StringPair("\"", "\"")); comments.push_back(StringPair("//", "\n")); comments.push_back(StringPair("/*", "*/")); tokens["{"] = TGen::PropertyTokenBlockStart; tokens["}"] = TGen::PropertyTokenBlockEnd; tokens["\n"] = TGen::PropertyTokenEOL; tokens[";"] = TGen::PropertyTokenNodeEnd; }
int ads_MyDialog() { // sample from brxtemplate //++-- See StdAfx for these types StringPairs LayerList; AcDbDatabase *pDb = acdbHostApplicationServices()->workingDatabase(); pDb->layerTableId(); LayerTablePointer pLayerTable(pDb->layerTableId(),AcDb::kForRead); if(pLayerTable.openStatus() != eOk) { ads_retnil(); return( RSRSLT); } AcDbLayerTableIterator *pLayerTableIterator; pLayerTable->newIterator(pLayerTableIterator); //++-- iterate though and get our stuff for (pLayerTableIterator->start(); !pLayerTableIterator->done(); pLayerTableIterator->step()) { AcDbObjectId LayerId; TCHAR *LayerName; CString LayerColor; pLayerTableIterator->getRecordId(LayerId); LayerTableRecordPointer pLayerTableRecord(LayerId,AcDb::kForRead); pLayerTableRecord->getName(LayerName); AcCmColor clr = pLayerTableRecord->color(); LayerColor = clr.bookName(); LayerColor.Format(_T("Red = %03d Green = %03d Blue = %03d "), clr.red(), clr.green() , clr.blue()); LayerList.push_back(StringPair(String(LayerName), String(LayerColor))); } delete pLayerTableIterator; { // you should always call this before your diaog; CAcModuleResourceOverride resOverride; //show our dialog MyDialog dlg(LayerList,CWnd::FromHandle(adsw_acadMainWnd())); dlg.DoModal(); } ads_retnil(); return( RSRSLT); }
SBAPI SBRetarget* SBRetargetManager::getRetarget( std::string sourceSk, std::string targetSk ) { StringPair skNamePair = StringPair(sourceSk,targetSk); SmartBody::SBRetarget* retarget = NULL; if (_retargets.find(skNamePair) != _retargets.end()) { retarget = _retargets[skNamePair]; } return retarget; }
MapTokenizer::MapTokenizer() { autoAddTilNextIgnore = true; ignores.push_back(" "); ignores.push_back("\t"); ignores.push_back("\r"); // ignores.push_back("\n"); quotes.push_back(StringPair("\"", "\"")); comments.push_back(StringPair("//", "\n")); comments.push_back(StringPair("/*", "*/")); tokens["{"] = MapTokenBlockStart; tokens["}"] = MapTokenBlockEnd; tokens["mesh"] = MapTokenMesh; tokens["vertices"] = MapTokenVertices; tokens["indices"] = MapTokenIndices; tokens["\n"] = MapTokenEndOfLine; }
SBAPI SBRetarget* SBRetargetManager::createRetarget( std::string sourceSk, std::string targetSk ) { if (getRetarget(sourceSk, targetSk)) { LOG("Retarget for skeleton pair (%s,%s) already exist.", sourceSk.c_str(), targetSk.c_str()); return NULL; } SmartBody::SBRetarget* retarget = new SmartBody::SBRetarget(sourceSk,targetSk); StringPair skNamePair = StringPair(sourceSk,targetSk); _retargets[skNamePair] = retarget; return retarget; }
void NeuralNetworkRepresentation::generateCloneWeights( std::map<std::string, std::string> &oldNew) { typedef std::map<std::string, std::string> MyMap; // for every neuron in the cloned tree for (MyMap::iterator itNeuron = oldNew.begin(); itNeuron != oldNew.end(); ++itNeuron) { std::string oldRon = itNeuron->first; std::string newRon = itNeuron->second; // for every weight for (WeightMap::iterator it = weights_.begin(); it != weights_.end(); ++it) { // if outgoing if (it->first.first.compare(oldRon) == 0) { // if destination neuron was in original subtree if (oldNew.find(it->first.second) != oldNew.end()) { weights_[StringPair(newRon, oldNew.find(it->first.second)->second)] = it->second; } else { weights_[StringPair(newRon, it->first.second)] = it->second; } } // if incoming if (it->first.second.compare(oldRon) == 0) { // if destination neuron was in original subtree if (oldNew.find(it->first.first) != oldNew.end()) { weights_[StringPair(oldNew.find(it->first.first)->second, newRon)] = it->second; } else { weights_[StringPair(it->first.first, newRon)] = it->second; } } } } }
long AliasDialog::onModify(FXObject*, FXSelector, void*) { FXint row = m_table->getCurrentItem(); FXString oldkey = m_table->getItemText(row).before('\t'); FXDialogBox aliasEdit(this, _("Alias edit"), DECOR_TITLE|DECOR_BORDER, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); FXVerticalFrame *contents = new FXVerticalFrame(&aliasEdit, LAYOUT_SIDE_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_Y, 0, 0, 0, 0, 10, 10, 10, 10, 0, 0); FXMatrix *matrix = new FXMatrix(contents, 2, MATRIX_BY_COLUMNS|LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y); new FXLabel(matrix, _("Alias:"), NULL, JUSTIFY_LEFT|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW); FXTextField *alias = new FXTextField(matrix, 25, NULL, 0, FRAME_THICK|FRAME_SUNKEN|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW); alias->setText(oldkey); new FXLabel(matrix, _("Command:"), NULL, JUSTIFY_LEFT|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW); FXTextField *command = new FXTextField(matrix, 25, NULL, 0, FRAME_THICK|FRAME_SUNKEN|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW); command->setText(m_table->getItemText(row).after('\t')); FXHorizontalFrame *buttonframe = new FXHorizontalFrame(contents, LAYOUT_FILL_X|LAYOUT_FILL_Y|PACK_UNIFORM_WIDTH); new dxEXButton(buttonframe, _("&Cancel"), NULL, &aliasEdit, FXDialogBox::ID_CANCEL, FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT, 0, 0, 0, 0, 10, 10, 2, 2); new dxEXButton(buttonframe, _("&OK"), NULL, &aliasEdit, FXDialogBox::ID_ACCEPT, BUTTON_INITIAL|BUTTON_DEFAULT|FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT, 0, 0, 0, 0, 10, 10, 2, 2); if(aliasEdit.execute(PLACEMENT_OWNER)) { if(alias->getText().empty() || command->getText().empty()) return 1; if(alias->getText()[0] != '/') { dxEXMessageBox::information(this, MBOX_OK, _("Information"), _("Alias command has to start with '/'")); return 1; } if(alias->getText().contains(' ')) { dxEXMessageBox::information(this, MBOX_OK, _("Information"), _("Alias command cann't contain space")); return 1; } if(commandExist(alias->getText()) && comparecase(alias->getText(), oldkey)) { dxEXMessageBox::information(this, MBOX_OK, _("Information"), _("Command '%s' already exist"), alias->getText().text()); return 1; } m_aliases.erase(oldkey); m_aliases.insert(StringPair(alias->getText(), command->getText())); updateTable(); } return 1; }
//------------------------------------------------------------------------------ // Method: ExtendBridge // // Description: Constructor. // // Return: // none // //------------------------------------------------------------------------------ ExtendBridge::ExtendBridge() { // initialize the OLE OleInitialize(NULL); pExtendDisp = NULL; extendPath = NULL; // // Standard libraries (libraries usually required by SEI models) // libraries.insert(StringPair(SEI_LIB, "SEI-2.lix")); libraries.insert(StringPair(BPR_LIB, "BPR.lix")); libraries.insert(StringPair(UTILITIES_LIB, "Utilities.lix")); libraries.insert(StringPair(DISCRETE_LIB, "Discrete Event.lix")); libraries.insert(StringPair(GENERIC_LIB, "Generic.lix")); libraries.insert(StringPair(PLOTTER_LIB, "Plotter.lix")); }
bool GraphFile::IsDimacsFile(std::string filename) const { std::ifstream file_stream; file_stream.open(filename); AssertOrDie(static_cast<bool>(file_stream), "Error: can't open " + filename); bool problem_line_seen = false; size_t vertices = 0, edges = 0; std::set< StringPair > edges_seen; std::set< std::string > vertices_seen; std::string line; while (std::getline(file_stream, line)) { StringTokens line_tokens = Split(line, " \t"); if (line_tokens.empty() || line_tokens[0].length() != 1) { return false; } switch (line_tokens[0][0]) { case 'c': { break; } case 'e' : { if (!problem_line_seen || line_tokens.size() != 3 || !IsNum(line_tokens[1]) || !IsNum(line_tokens[2])) { return false; } std::string u = line_tokens[1], v = line_tokens[2]; if (edges_seen.find(StringPair(u, v)) != edges_seen.end()) { return false; } vertices_seen.insert(u); vertices_seen.insert(v); edges_seen.insert(StringPair(u, v)); edges_seen.insert(StringPair(v, u)); break; } case 'p' : { if (problem_line_seen || line_tokens.size() != 4 || !IsNum(line_tokens[2]) || !IsNum(line_tokens[3]) ) { return false; } problem_line_seen = true; vertices = std::stoi(line_tokens[2]); edges = std::stoi(line_tokens[3]); break; } default: { return false; } } } if (2*edges != edges_seen.size() || vertices > vertices_seen.size() || !problem_line_seen) { return false; } file_stream.close(); return true; }
bool processStateMachineNode(AnimNode::Pointer node, const QJsonObject& jsonObj, const QString& nodeId, const QUrl& jsonUrl) { auto smNode = std::static_pointer_cast<AnimStateMachine>(node); assert(smNode); READ_STRING(currentState, jsonObj, nodeId, jsonUrl, false); auto statesValue = jsonObj.value("states"); if (!statesValue.isArray()) { qCCritical(animation) << "AnimNodeLoader, bad array \"states\" in stateMachine node, id =" << nodeId; return false; } // build a map for all children by name. std::map<QString, int> childMap; buildChildMap(childMap, node); // first pass parse all the states and build up the state and transition map. using StringPair = std::pair<QString, QString>; using TransitionMap = std::multimap<AnimStateMachine::State::Pointer, StringPair>; TransitionMap transitionMap; using StateMap = std::map<QString, AnimStateMachine::State::Pointer>; StateMap stateMap; auto statesArray = statesValue.toArray(); for (const auto& stateValue : statesArray) { if (!stateValue.isObject()) { qCCritical(animation) << "AnimNodeLoader, bad state object in \"states\", id =" << nodeId; return false; } auto stateObj = stateValue.toObject(); READ_STRING(id, stateObj, nodeId, jsonUrl, false); READ_FLOAT(interpTarget, stateObj, nodeId, jsonUrl, false); READ_FLOAT(interpDuration, stateObj, nodeId, jsonUrl, false); READ_OPTIONAL_STRING(interpType, stateObj); READ_OPTIONAL_STRING(interpTargetVar, stateObj); READ_OPTIONAL_STRING(interpDurationVar, stateObj); READ_OPTIONAL_STRING(interpTypeVar, stateObj); auto iter = childMap.find(id); if (iter == childMap.end()) { qCCritical(animation) << "AnimNodeLoader, could not find stateMachine child (state) with nodeId =" << nodeId << "stateId =" << id; return false; } AnimStateMachine::InterpType interpTypeEnum = AnimStateMachine::InterpType::SnapshotPrev; // default value if (!interpType.isEmpty()) { interpTypeEnum = stringToInterpType(interpType); if (interpTypeEnum == AnimStateMachine::InterpType::NumTypes) { qCCritical(animation) << "AnimNodeLoader, bad interpType on stateMachine state, nodeId = " << nodeId << "stateId =" << id; return false; } } auto statePtr = std::make_shared<AnimStateMachine::State>(id, iter->second, interpTarget, interpDuration, interpTypeEnum); assert(statePtr); if (!interpTargetVar.isEmpty()) { statePtr->setInterpTargetVar(interpTargetVar); } if (!interpDurationVar.isEmpty()) { statePtr->setInterpDurationVar(interpDurationVar); } if (!interpTypeVar.isEmpty()) { statePtr->setInterpTypeVar(interpTypeVar); } smNode->addState(statePtr); stateMap.insert(StateMap::value_type(statePtr->getID(), statePtr)); auto transitionsValue = stateObj.value("transitions"); if (!transitionsValue.isArray()) { qCritical(animation) << "AnimNodeLoader, bad array \"transitions\" in stateMachine node, stateId =" << id << "nodeId =" << nodeId; return false; } auto transitionsArray = transitionsValue.toArray(); for (const auto& transitionValue : transitionsArray) { if (!transitionValue.isObject()) { qCritical(animation) << "AnimNodeLoader, bad transition object in \"transtions\", stateId =" << id << "nodeId =" << nodeId; return false; } auto transitionObj = transitionValue.toObject(); READ_STRING(var, transitionObj, nodeId, jsonUrl, false); READ_STRING(state, transitionObj, nodeId, jsonUrl, false); transitionMap.insert(TransitionMap::value_type(statePtr, StringPair(var, state))); } } // second pass: now iterate thru all transitions and add them to the appropriate states. for (auto& transition : transitionMap) { AnimStateMachine::State::Pointer srcState = transition.first; auto iter = stateMap.find(transition.second.second); if (iter != stateMap.end()) { srcState->addTransition(AnimStateMachine::State::Transition(transition.second.first, iter->second)); } else { qCCritical(animation) << "AnimNodeLoader, bad state machine transtion from srcState =" << srcState->_id << "dstState =" << transition.second.second << "nodeId =" << nodeId; return false; } } auto iter = stateMap.find(currentState); if (iter == stateMap.end()) { qCCritical(animation) << "AnimNodeLoader, bad currentState =" << currentState << "could not find child node" << "id =" << nodeId; } smNode->setCurrentState(iter->second); return true; }
bool GoogleTranslate::parseReply(const QByteArray &reply) { #if QT_VERSION >= QT_VERSION_CHECK(5,0,0) // JSON coming from Google is invalid due to sequences // like ",,". Replacing all ",," with ",null," allows // us to parse JSON with QJsonDocument. QString json = QString::fromUtf8(reply); if (json.isEmpty()) { m_error = commonString(EmptyResultCommonString).arg(displayName()); return true; } int i = 1; bool skip = json.at(0) == '"'; while (i < json.length()) { const QStringRef mid = json.midRef(i - 1, 2); if (mid.at(1) == '"' && mid.compare(QLatin1String("\\\"")) != 0) { skip = !skip; ++i; } if (!skip && (mid.compare(QLatin1String(",,")) == 0 || mid.compare(QLatin1String("[,")) == 0 || mid.compare(QLatin1String(",]")) == 0)) { json.insert(i, "null"); i += 4; } ++i; } const QVariant data = parseJson(json.toUtf8()); #else const QVariant data = parseJson(reply); #endif if (!data.isValid() || data.type() != QVariant::List) return false; const QVariantList dl = data.toList(); if (dl.isEmpty()) { m_error = commonString(EmptyResultCommonString).arg(displayName()); return true; } const QString detected = dl.value(2).toString(); m_detectedLanguage = Language(detected, getLanguageName(detected)); m_translation.clear(); m_translit = StringPair(); foreach (const QVariant &ti, dl.value(0).toList()) { const QVariantList tr = ti.toList(); if (!tr.value(0).isNull()) m_translation.append(tr.value(0).toString()); if (!tr.value(2).isNull()) m_translit.second.append(tr.value(2).toString()); if (!tr.value(3).isNull()) m_translit.first.append(tr.value(3).toString()); } m_dict->clear(); if (dl.value(1).type() == QVariant::List) { foreach (const QVariant &di, dl.value(1).toList()) { const QVariantList dil = di.toList(); // Translations const QStringList trans = dil.value(1).toStringList(); // Part of speech DictionaryPos pos(dil.value(0).toString(), trans); // Reverse translations foreach (const QVariant &ei, dil.value(2).toList()) { const QVariantList eil = ei.toList(); // Word from translations for which reverse translations are provided QString word = eil.value(0).toString(); // Reverse translations for the aforementioned word const QStringList rtrans = eil.value(1).toStringList(); // Article for the aforementioned word (if provided) if (!eil.value(4).toString().isEmpty()) word.prepend(eil.value(4).toString() + " "); pos.reverseTranslations()->append(word, QStringList(), rtrans); } m_dict->append(pos); } }
bool NeuralNetworkRepresentation::connectionExists(std::string from, std::string to) { return (weights_.count(StringPair(from, to)) > 0); }
/////////////////////////////////////////////////////////////// // // CPerfStatServerInfoImpl::GetStats // // // /////////////////////////////////////////////////////////////// void CPerfStatServerInfoImpl::GetStats ( CPerfStatResult* pResult, const std::map < SString, int >& strOptionMap, const SString& strFilter ) { // // Set option flags // bool bHelp = MapContains ( strOptionMap, "h" ); bool bIncludeDebugInfo = MapContains ( strOptionMap, "d" ); // // Process help // if ( bHelp ) { pResult->AddColumn ( "Server info help" ); pResult->AddRow ()[0] ="Option h - This help"; pResult->AddRow ()[0] ="Option d - Include debug info"; return; } // Calculate current rates long long llIncomingBytesPS = CPerfStatManager::GetPerSecond ( m_llDeltaGameBytesRecv, m_DeltaTickCount.ToLongLong () ); long long llIncomingBytesPSBlocked = CPerfStatManager::GetPerSecond ( m_llDeltaGameBytesRecvBlocked, m_DeltaTickCount.ToLongLong () ); long long llOutgoingBytesPS = CPerfStatManager::GetPerSecond ( m_llDeltaGameBytesSent, m_DeltaTickCount.ToLongLong () ); long long llOutgoingBytesResentPS = CPerfStatManager::GetPerSecond ( m_llDeltaGameBytesResent, m_DeltaTickCount.ToLongLong () ); SString strIncomingPacketsPS = CPerfStatManager::GetPerSecondString ( m_llDeltaGamePacketsRecv, m_DeltaTickCount.ToDouble () ); SString strIncomingPacketsPSBlocked = CPerfStatManager::GetPerSecondString ( m_llDeltaGamePacketsRecvBlocked, m_DeltaTickCount.ToDouble () ); SString strOutgoingPacketsPS = CPerfStatManager::GetPerSecondString ( m_llDeltaGamePacketsSent, m_DeltaTickCount.ToDouble () ); SString strOutgoingMessagesResentPS = CPerfStatManager::GetPerSecondString ( m_llDeltaGameMessagesResent, m_DeltaTickCount.ToDouble () ); // Estimate total network usage long long llIncomingPacketsPS = CPerfStatManager::GetPerSecond ( m_llDeltaGamePacketsRecv, m_DeltaTickCount.ToLongLong () ); long long llIncomingPacketsPSBlocked = CPerfStatManager::GetPerSecond ( m_llDeltaGamePacketsRecvBlocked, m_DeltaTickCount.ToLongLong () ); long long llOutgoingPacketsPS = CPerfStatManager::GetPerSecond ( m_llDeltaGamePacketsSent, m_DeltaTickCount.ToLongLong () ); long long llNetworkUsageBytesPS = ( llIncomingPacketsPS + llOutgoingPacketsPS ) * UDP_PACKET_OVERHEAD + llIncomingBytesPS + llOutgoingBytesPS; long long llNetworkUsageBytesPSInclBlocked = ( llIncomingPacketsPS + llIncomingPacketsPSBlocked + llOutgoingPacketsPS ) * UDP_PACKET_OVERHEAD + llIncomingBytesPS + llIncomingBytesPSBlocked + llOutgoingBytesPS; // Calculate uptime time_t tUptime = time ( NULL ) - m_tStartTime; time_t tDays = tUptime / ( 60 * 60 * 24 ); tUptime = tUptime % ( 60 * 60 * 24 ); time_t tHours = tUptime / ( 60 * 60 ); tUptime = tUptime % ( 60 * 60 ); time_t tMinutes = tUptime / ( 60 ); SString strNone; CMainConfig* pConfig = g_pGame->GetConfig (); m_InfoList.clear (); m_StatusList.clear (); m_OptionsList.clear (); // Fill info lists m_InfoList.push_back ( StringPair ( "Platform", CStaticFunctionDefinitions::GetOperatingSystemName () ) ); m_InfoList.push_back ( StringPair ( "Version", CStaticFunctionDefinitions::GetVersionSortable () ) ); m_InfoList.push_back ( StringPair ( "Date", GetLocalTimeString ( true ) ) ); m_InfoList.push_back ( StringPair ( "Uptime", SString ( "%d Days %d Hours %02d Mins", (int)tDays, (int)tHours, (int)tMinutes ) ) ); m_InfoList.push_back ( StringPair ( "Memory", GetProcessMemoryUsage() ) ); if ( !pConfig->GetThreadNetEnabled () ) m_StatusList.push_back ( StringPair ( "Server FPS", SString ( "%d", g_pGame->GetServerFPS () ) ) ); else m_StatusList.push_back ( StringPair ( "Server FPS sync (logic)", SString ( "%3d (%d)", g_pGame->GetSyncFPS (), g_pGame->GetServerFPS () ) ) ); m_StatusList.push_back ( StringPair ( "Players", SString ( "%d / %d", g_pGame->GetPlayerManager ()->Count (), pConfig->GetMaxPlayers () ) ) ); m_StatusList.push_back ( StringPair ( "Bytes/sec incoming", CPerfStatManager::GetScaledByteString ( llIncomingBytesPS ) ) ); m_StatusList.push_back ( StringPair ( "Bytes/sec outgoing", CPerfStatManager::GetScaledByteString ( llOutgoingBytesPS ) ) ); m_StatusList.push_back ( StringPair ( "Packets/sec incoming", strIncomingPacketsPS ) ); m_StatusList.push_back ( StringPair ( "Packets/sec outgoing", strOutgoingPacketsPS ) ); m_StatusList.push_back ( StringPair ( "Packet loss outgoing", CPerfStatManager::GetPercentString ( llOutgoingBytesResentPS, llOutgoingBytesPS ) ) ); m_StatusList.push_back ( StringPair ( "Approx network usage", CPerfStatManager::GetScaledBitString ( llNetworkUsageBytesPS * 8LL ) + "/s" ) ); if ( pConfig->GetThreadNetEnabled () ) { m_StatusList.push_back ( StringPair ( "Msg queue incoming", SString ( "%d", CNetBufferWatchDog::ms_uiInResultQueueSize ) ) ); if ( bIncludeDebugInfo ) m_StatusList.push_back ( StringPair ( " finished incoming", SString ( "%d", CNetBufferWatchDog::ms_uiFinishedListSize ) ) ); m_StatusList.push_back ( StringPair ( "Msg queue outgoing", SString ( "%d", CNetBufferWatchDog::ms_uiOutCommandQueueSize ) ) ); if ( bIncludeDebugInfo ) m_StatusList.push_back ( StringPair ( " finished outgoing", SString ( "%d", CNetBufferWatchDog::ms_uiOutResultQueueSize ) ) ); } if ( ASE* pAse = ASE::GetInstance() ) m_StatusList.push_back ( StringPair ( "ASE queries", SString ( "%d (%d/min)", pAse->GetTotalQueryCount (), pAse->GetQueriesPerMinute () ) ) ); m_OptionsList.push_back ( StringPair ( "MinClientVersion", g_pGame->CalculateMinClientRequirement () ) ); m_OptionsList.push_back ( StringPair ( "RecommendedClientVersion", pConfig->GetRecommendedClientVersion () ) ); m_OptionsList.push_back ( StringPair ( "NetworkEncryptionEnabled", SString ( "%d", pConfig->GetNetworkEncryptionEnabled () ) ) ); m_OptionsList.push_back ( StringPair ( "VoiceEnabled", SString ( "%d", pConfig->IsVoiceEnabled () ) ) ); m_OptionsList.push_back ( StringPair ( "Busy sleep time", SString ( "%d ms", pConfig->GetPendingWorkToDoSleepTime () ) ) ); m_OptionsList.push_back ( StringPair ( "Idle sleep time", SString ( "%d ms", pConfig->GetNoWorkToDoSleepTime () ) ) ); m_OptionsList.push_back ( StringPair ( "BandwidthReductionMode", pConfig->GetSetting ( "bandwidth_reduction" ) ) ); m_OptionsList.push_back ( StringPair ( "LightSyncEnabled", SString ( "%d", g_pBandwidthSettings->bLightSyncEnabled ) ) ); m_OptionsList.push_back ( StringPair ( "ThreadNetEnabled", SString ( "%d", pConfig->GetThreadNetEnabled () ) ) ); const static CTickRateSettings defaultRates; if ( defaultRates.iPureSync != g_TickRateSettings.iPureSync ) m_OptionsList.push_back ( StringPair ( "Player sync interval", SString ( "%d", g_TickRateSettings.iPureSync ) ) ); if ( defaultRates.iLightSync != g_TickRateSettings.iLightSync ) m_OptionsList.push_back ( StringPair ( "Lightweight sync interval", SString ( "%d", g_TickRateSettings.iLightSync ) ) ); if ( defaultRates.iCamSync != g_TickRateSettings.iCamSync ) m_OptionsList.push_back ( StringPair ( "Camera sync interval", SString ( "%d", g_TickRateSettings.iCamSync ) ) ); if ( defaultRates.iPedSync != g_TickRateSettings.iPedSync ) m_OptionsList.push_back ( StringPair ( "Ped sync interval", SString ( "%d", g_TickRateSettings.iPedSync ) ) ); if ( defaultRates.iUnoccupiedVehicle != g_TickRateSettings.iUnoccupiedVehicle ) m_OptionsList.push_back ( StringPair ( "Unocc. veh. sync interval", SString ( "%d", g_TickRateSettings.iUnoccupiedVehicle ) ) ); if ( defaultRates.iKeySyncRotation != g_TickRateSettings.iKeySyncRotation ) m_OptionsList.push_back ( StringPair ( "Keysync mouse sync interval", SString ( "%d", g_TickRateSettings.iKeySyncRotation ) ) ); if ( defaultRates.iKeySyncAnalogMove != g_TickRateSettings.iKeySyncAnalogMove ) m_OptionsList.push_back ( StringPair ( "Keysync analog sync interval", SString ( "%d", g_TickRateSettings.iKeySyncAnalogMove ) ) ); if ( defaultRates.iKeySyncAnalogMove != g_TickRateSettings.iNearListUpdate ) m_OptionsList.push_back ( StringPair ( "Update near interval", SString ( "%d", g_TickRateSettings.iNearListUpdate ) ) ); if ( bIncludeDebugInfo ) { m_StatusList.push_back ( StringPair ( "Bytes/sec outgoing resent", CPerfStatManager::GetScaledByteString ( llOutgoingBytesResentPS ) ) ); m_StatusList.push_back ( StringPair ( "Msgs/sec outgoing resent", strOutgoingMessagesResentPS ) ); m_StatusList.push_back ( StringPair ( "Bytes/sec blocked", CPerfStatManager::GetScaledByteString ( llIncomingBytesPSBlocked ) ) ); m_StatusList.push_back ( StringPair ( "Packets/sec blocked", strIncomingPacketsPSBlocked ) ); m_StatusList.push_back ( StringPair ( "Usage incl. blocked", CPerfStatManager::GetScaledBitString ( llNetworkUsageBytesPSInclBlocked * 8LL ) + "/s" ) ); m_OptionsList.push_back ( StringPair ( "Main (Logic) core #", SString ( "%d", _GetCurrentProcessorNumber () ) ) ); m_OptionsList.push_back ( StringPair ( "Threadnet (Sync) core #", SString ( "%d", g_uiThreadnetProcessorNumber ) ) ); m_OptionsList.push_back ( StringPair ( "Raknet thread core #", SString ( "%d", m_PrevLiveStats.uiNetworkUpdateLoopProcessorNumber ) ) ); m_OptionsList.push_back ( StringPair ( "DB thread core #", SString ( "%d", g_uiDatabaseThreadProcessorNumber ) ) ); // Get net performance stats if ( m_NetPerformanceStatsUpdateTimer.Get() > 2000 ) { m_NetPerformanceStatsUpdateTimer.Reset(); g_pNetServer->GetNetPerformanceStatistics ( &m_NetPerformanceStats, true ); } m_OptionsList.push_back ( StringPair ( "Update cycle prep time max", SString ( "%s ms (Avg %s ms)", *CPerfStatManager::GetScaledFloatString( m_NetPerformanceStats.uiUpdateCyclePrepTimeMaxUs / 1000.f ), *CPerfStatManager::GetScaledFloatString( m_NetPerformanceStats.uiUpdateCyclePrepTimeAvgUs / 1000.f ) ) ) ); m_OptionsList.push_back ( StringPair ( "Update cycle process time max", SString ( "%s ms (Avg %s ms)", *CPerfStatManager::GetScaledFloatString( m_NetPerformanceStats.uiUpdateCycleProcessTimeMaxUs / 1000.f ), *CPerfStatManager::GetScaledFloatString( m_NetPerformanceStats.uiUpdateCycleProcessTimeAvgUs / 1000.f ) ) ) ); m_OptionsList.push_back ( StringPair ( "Update cycle datagrams max", SString ( "%d (Avg %s)", m_NetPerformanceStats.uiUpdateCycleDatagramsMax, *CPerfStatManager::GetScaledFloatString( m_NetPerformanceStats.fUpdateCycleDatagramsAvg ) ) ) ); m_OptionsList.push_back ( StringPair ( "Update cycle datagrams limit", SString ( "%d", m_NetPerformanceStats.uiUpdateCycleDatagramsLimit ) ) ); m_OptionsList.push_back ( StringPair ( "Update cycle sends limited", SString ( "%d (%s %%)", m_NetPerformanceStats.uiUpdateCycleSendsLimitedTotal, *CPerfStatManager::GetScaledFloatString( m_NetPerformanceStats.fUpdateCycleSendsLimitedPercent ) ) ) ); } // Add columns pResult->AddColumn ( "Info.Name" ); pResult->AddColumn ( "Info.Value" ); pResult->AddColumn ( "Status.Name" ); pResult->AddColumn ( "Status.Value" ); pResult->AddColumn ( "Settings.Name" ); pResult->AddColumn ( "Settings.Value" ); // Output rows std::vector < StringPair >* columnList[] = { &m_InfoList, &m_StatusList, &m_OptionsList }; uint uiMaxRows = Max ( Max ( m_InfoList.size (), m_StatusList.size () ), m_OptionsList.size () ); for ( uint i = 0 ; i < uiMaxRows ; i++ ) { SString* row = pResult->AddRow (); int c = 0; for ( uint a = 0 ; a < NUMELMS( columnList ) ; a++ ) { const std::vector < StringPair >& column = *columnList[a]; if ( i < column.size () ) { row[c++] = column[i].strName; row[c++] = column[i].strValue; } else { row[c++] = ""; row[c++] = ""; } } } }
void TextRangeRegExp::addRange(QString from, QString to) { _ranges.append( StringPair( from, to ) ); }