コード例 #1
0
ファイル: System.cpp プロジェクト: J-d-H/freeorion
std::string System::Dump() const {
    std::stringstream os;
    os << UniverseObject::Dump();
    os << " star type: " << UserString(EnumToString(m_star))
       << "  last combat on turn: " << m_last_turn_battle_here
       << "  starlanes: ";

    for (std::map<int, bool>::const_iterator it = m_starlanes_wormholes.begin();
         it != m_starlanes_wormholes.end();)
    {
        int lane_end_id = it->first;
        ++it;
        os << lane_end_id << (it == m_starlanes_wormholes.end() ? "" : ", ");
    }

    os << "  objects: ";
    for (std::set<int>::const_iterator it = m_objects.begin(); it != m_objects.end();) {
        int obj_id = *it;
        ++it;
        if (obj_id == INVALID_OBJECT_ID)
            continue;
        os << obj_id << (it == m_objects.end() ? "" : ", ");
    }
    return os.str();
}
コード例 #2
0
//
// Get best guess at name of userdata type
//
SString GetUserDataClassName(void* ptr, lua_State* luaVM, bool bFindElementType)
{
    // Try element
    if (CClientEntity* pClientElement = UserDataCast<CClientEntity>((CClientEntity*)NULL, ptr, NULL))
    {
        if (bFindElementType)
            // Try gui element first
            if (CClientGUIElement* pGuiElement = DynamicCast<CClientGUIElement>(pClientElement))
                return EnumToString(pGuiElement->GetCGUIElement()->GetType());
            else
                return pClientElement->GetTypeName();
        else
            return GetClassTypeName(pClientElement);
    }

    if (auto* pVar = UserDataCast<CResource>((CResource*)NULL, ptr, luaVM))            // Try resource
        return GetClassTypeName(pVar);
    if (auto* pVar = UserDataCast<CXMLNode>((CXMLNode*)NULL, ptr, luaVM))            // Try xml node
        return GetClassTypeName(pVar);
    if (auto* pVar = UserDataCast<CLuaTimer>((CLuaTimer*)NULL, ptr, luaVM))            // Try timer
        return GetClassTypeName(pVar);
    if (auto* pVar = UserDataCast<CLuaVector2D>((CLuaVector2D*)NULL, ptr, luaVM))            // Try 2D Vector
        return GetClassTypeName(pVar);
    if (auto* pVar = UserDataCast<CLuaVector3D>((CLuaVector3D*)NULL, ptr, luaVM))            // Try 3D Vector
        return GetClassTypeName(pVar);
    if (auto* pVar = UserDataCast<CLuaVector4D>((CLuaVector4D*)NULL, ptr, luaVM))
        return GetClassTypeName(pVar);

    return "";
}
コード例 #3
0
ファイル: Ship.cpp プロジェクト: fatman2021/FreeOrion
std::string Ship::Dump() const {
    std::stringstream os;
    os << UniverseObject::Dump();
    os << " design id: " << m_design_id
       << " fleet id: " << m_fleet_id
       << " species name: " << m_species_name
       << " produced by empire id: " << m_produced_by_empire_id
       << " fighters: ";
    //typedef std::map<std::string, std::pair<std::size_t, std::size_t> > ConsumablesMap;
    for (ConsumablesMap::const_iterator it = m_fighters.begin(); it != m_fighters.end();) {
        const std::string& part_name = it->first;
        int num_consumables_available = it->second.second;
        ++it;
        os << part_name << ": " << num_consumables_available << (it == m_fighters.end() ? "" : ", ");
    }
    os << " missiles: ";
    for (ConsumablesMap::const_iterator it = m_missiles.begin(); it != m_missiles.end();) {
        const std::string& part_name = it->first;
        int num_consumables_available = it->second.second;
        ++it;
        os << part_name << ": " << num_consumables_available << (it == m_missiles.end() ? "" : ", ");
    }
    //typedef std::map<std::pair<MeterType, std::string>, Meter> PartMeters;
    os << " part meters: ";
    for (PartMeterMap::const_iterator it = m_part_meters.begin(); it != m_part_meters.end();) {
        const std::string part_name = it->first.second;
        MeterType meter_type = it->first.first;
        const Meter& meter = it->second;
        ++it;
        os << UserString(part_name) << " "
           << UserString(EnumToString(meter_type))
           << ": " << meter.Current() << "  ";
    }
    return os.str();
}
コード例 #4
0
/*virtual*/ ECommandResult CGeneralHeaderCommand::OnCommandImplementation(IN int ContextLine, std::string CommandWord, std::vector<std::string> CommandArguments, void *&Element, EElementType &ElementType)
{
	Assert(CommandWord == GeneralHeaderCommand);

	std::map<std::string, std::string> ParsedArguments;
	if (!InterperetArguments(ContextLine, CommandArguments, ParsedArguments))
	{
		LogEvent(LE_ERROR, __FUNCTION__ ": [Line #%d]: Failed to parse arguments.", ContextLine);
		return CommandFailed;
	}

	Int32Bit SignatureValue;
	if (!ExtractAndInterperetArgumentValue(ContextLine, GeneralHeaderCommand, Signature, ParsedArguments, SignatureValue))
		return CommandFailed;

	Int4Bit VersionValue;
	if (!ExtractAndInterperetArgumentValue(ContextLine, GeneralHeaderCommand, Version, ParsedArguments, VersionValue))
		return CommandFailed;

	EBarcodeType BarcodeTypeValue;
	if (!ExtractAndInterperetArgumentValue(ContextLine, GeneralHeaderCommand, BarcodeType, ParsedArguments, BarcodeTypeValue))
		return CommandFailed;

	
	CGeneralHeader *GeneralHeader = new CGeneralHeader;
	GeneralHeader->Encode(SignatureValue, VersionValue, BarcodeTypeValue);

	LogEvent(LE_INFO, __FUNCTION__ ": %s Command Parsed Successfully: Signature = %d, Version = %d, BarcodeType = %s)", 
		GeneralHeaderCommand, SignatureValue, VersionValue, EnumToString(BarcodeTypeValue).c_str());

	Element = (void *)GeneralHeader;
	ElementType = AddHeaderCommand;
	return CommandSucceeded;
}
コード例 #5
0
//
// Get best guess at name of userdata type
//
SString GetUserDataClassName ( void* ptr, lua_State* luaVM )
{
    // Try element
    if ( CClientEntity* pClientElement = UserDataCast < CClientEntity > ( (CClientEntity*)NULL, ptr, NULL ) )
    {
        // Try gui element
        if ( CClientGUIElement* pGuiElement = DynamicCast < CClientGUIElement > ( pClientElement ) )
        {
            return EnumToString ( pGuiElement->GetCGUIElement ()->GetType () );
        }
        return pClientElement->GetTypeName ();
    }

    // Try xml node
    if ( CXMLNode* pXMLNode = UserDataCast < CXMLNode > ( (CXMLNode*)NULL, ptr, NULL ) )
    {
        return GetClassTypeName ( pXMLNode );
    }

    // Try timer
    if ( CLuaTimer* pLuaTimer = UserDataCast < CLuaTimer > ( (CLuaTimer*)NULL, ptr, luaVM ) )
    {
        return GetClassTypeName ( pLuaTimer );
    }

    // Try resource
    if ( CResource* pResource = UserDataCast < CResource > ( (CResource*)NULL, ptr, NULL ) )
    {
        return GetClassTypeName ( pResource );
    }

    return "";
}
コード例 #6
0
ファイル: MainWindow.cpp プロジェクト: obiwankennedy/ssr
void MainWindow::SaveSettings() {

	QSettings settings(GetApplicationUserDir() + "/settings.conf", QSettings::IniFormat);
	settings.clear();

	settings.setValue("global/nvidia_disable_flipping", EnumToString(GetNVidiaDisableFlipping()));

	m_page_input->SaveSettings(&settings);
	m_page_output->SaveSettings(&settings);
	m_page_record->SaveSettings(&settings);

}
コード例 #7
0
ファイル: PageOutput.cpp プロジェクト: Yhonay/ssr
void PageOutput::SaveProfileSettings(QSettings* settings) {

	settings->setValue("output/file", GetFile());
	settings->setValue("output/separate_files", GetSeparateFiles());
	settings->setValue("output/container", EnumToString(GetContainer()));
	settings->setValue("output/container_av", m_containers_av[GetContainerAV()].avname);

	settings->setValue("output/video_codec", EnumToString(GetVideoCodec()));
	settings->setValue("output/video_codec_av", m_video_codecs_av[GetVideoCodecAV()].avname);
	settings->setValue("output/video_kbit_rate", GetVideoKBitRate());
	settings->setValue("output/video_h264_crf", GetH264CRF());
	settings->setValue("output/video_h264_preset", GetH264Preset());
	settings->setValue("output/video_vp8_cpu_used", GetVP8CPUUsed());
	settings->setValue("output/video_options", GetVideoOptions());
	settings->setValue("output/video_allow_frame_skipping", GetVideoAllowFrameSkipping());

	settings->setValue("output/audio_codec", EnumToString(GetAudioCodec()));
	settings->setValue("output/audio_codec_av", m_audio_codecs_av[GetAudioCodecAV()].avname);
	settings->setValue("output/audio_kbit_rate", GetAudioKBitRate());
	settings->setValue("output/audio_options", GetAudioOptions());

}
コード例 #8
0
/*virtual*/ ECommandResult CAbsoluteJumpCommand::OnCommandImplementation(IN int ContextLine, std::string CommandWord, std::vector<std::string> CommandArguments, void *&Element, EElementType &ElementType)
{
	Assert(CommandWord == AbsoluteJumpCommand);

	std::map<std::string, std::string> ParsedArguments;
	if (!InterperetArguments(ContextLine, CommandArguments, ParsedArguments))
	{
		LogEvent(LE_ERROR, __FUNCTION__ ": [Line #%d]: Failed to parse arguments.", ContextLine);
		return CommandFailed;
	}

	EAbsoluteJumpItemType AbsoluteJumpItemTypeValue;
	if (!ExtractAndInterperetArgumentValue(ContextLine, AbsoluteJumpCommand, AbsoluteJumpItemType, ParsedArguments, AbsoluteJumpItemTypeValue))
		return CommandFailed;

	bool IsHorizontal = (AbsoluteJumpItemTypeValue == AbsoluteHorizontalJump || AbsoluteJumpItemTypeValue == AbsoluteDiagonalJump);
	bool IsVertical = (AbsoluteJumpItemTypeValue == AbsoluteVerticalJump || AbsoluteJumpItemTypeValue == AbsoluteDiagonalJump);

	Int16Bit XValue = ConvertIntToInt16Bit(0);	
	CString XStr;
	if (IsHorizontal) 
	{
		if (!ExtractAndInterperetArgumentValue(ContextLine, AbsoluteJumpCommand, Abs_X, ParsedArguments, XValue))
			return CommandFailed;
		XStr.Format(", dX = %d", XValue);
	}

	Int16Bit YValue = ConvertIntToInt16Bit(0);
	CString YStr;
	if (IsVertical) 
	{
		if (!ExtractAndInterperetArgumentValue(ContextLine, AbsoluteJumpCommand, Abs_Y, ParsedArguments, YValue))
			return CommandFailed;
		YStr.Format(", dY = %d", YValue);
	}


	CAbsoluteJumpExtendedItem *AbsoluteJumpExtendedItem = new CAbsoluteJumpExtendedItem;
	AbsoluteJumpExtendedItem->Encode(AbsoluteJumpItemTypeValue, XValue, YValue);


	LogEvent(LE_INFO, __FUNCTION__ ": %s Command Parsed Successfully: SignedJumpItemType = %s%s%s)", 
		AbsoluteJumpCommand, EnumToString(AbsoluteJumpItemTypeValue).c_str(), XStr, YStr);

	Element = (void *)AbsoluteJumpExtendedItem;
	ElementType = AddItemCommand;
	return CommandSucceeded;
}
コード例 #9
0
/*******************************************************************************
 ***  FUNCTION match()
 *******************************************************************************
 ***  DESCRIPTION  :  Matches a token from the lexer to an expected token from RDP
 ******************************************************************************/
void RecursiveParser::match(Global::Symbol match)
{
   if (match == global->Token)
      lex->GetNextToken();

   else
   {
      cout << "ERROR - Token mismatch at line " << lex->line_num << ". Expected: " << EnumToString(match)
           << " Received: " << EnumToString(global->Token) << endl;
      raise(SIGINT);
   }

   if (global->Token == Global::commentt)
      lex->GetNextToken();

}
コード例 #10
0
ファイル: Pcsx2Config.cpp プロジェクト: Blackbird88/pcsx2
// Enables a full list of gamefixes.  The list can be either comma or pipe-delimited.
//   Example:  "XGKick,IpuWait"  or  "EEtiming,FpuCompare"
// If an unrecognized tag is encountered, a warning is printed to the console, but no error
// is generated.  This allows the system to function in the event that future versions of
// PCSX2 remove old hacks once they become obsolete.
void Pcsx2Config::GamefixOptions::Set( const wxString& list, bool enabled )
{
	wxStringTokenizer izer( list, L",|", wxTOKEN_STRTOK );
	
	while( izer.HasMoreTokens() )
	{
		wxString token( izer.GetNextToken() );

		GamefixId i;
		for (i=GamefixId_FIRST; i < pxEnumEnd; ++i)
		{
			if( token.CmpNoCase( EnumToString(i) ) == 0 ) break;
		}
		if( i < pxEnumEnd ) Set( i );
	}
}
コード例 #11
0
ファイル: UniverseObject.cpp プロジェクト: adesst/freeorion-1
std::string UniverseObject::Dump() const {
    TemporaryPtr<const System> system = GetSystem(this->SystemID());

    std::stringstream os;

    os << boost::lexical_cast<std::string>(this->ObjectType()) << " "
       << this->ID() << ": "
       << this->Name();
    if (system) {
        const std::string& sys_name = system->Name();
        if (sys_name.empty())
            os << "  at: (System " << system->ID() << ")";
        else
            os << "  at: " << sys_name;
    } else {
        os << "  at: (" << this->X() << ", " << this->Y() << ")";
        int near_id = GetUniverse().NearestSystemTo(this->X(), this->Y());
        TemporaryPtr<const System> system = GetSystem(near_id);
        if (system) {
            const std::string& sys_name = system->Name();
            if (sys_name.empty())
                os << " nearest (System " << system->ID() << ")";
            else
                os << " nearest " << system->Name();
        }
    }
    if (Unowned()) {
        os << " owner: (Unowned) ";
    } else {
        std::string empire_name = Empires().GetEmpireName(m_owner_empire_id);
        if (!empire_name.empty())
            os << " owner: " << empire_name;
        else
            os << " owner: (Unknown Empire)";
    }
    os << " created on turn: " << m_created_on_turn
       << " specials: ";
    for (std::map<std::string, std::pair<int, float> >::const_iterator it = m_specials.begin(); it != m_specials.end(); ++it)
        os << "(" << it->first << ", " << it->second.first << ", " << it->second.second << ") ";
    os << "  Meters: ";
    for (std::map<MeterType, Meter>::const_iterator it = m_meters.begin(); it != m_meters.end(); ++it)
        os << UserString(EnumToString(it->first))
           << ": " << it->second.Dump() << "  ";
    return os.str();
}
コード例 #12
0
int CLuaFunctionDefs::GetWeaponState ( lua_State* luaVM )
{
    CClientWeapon * pWeapon;
    eWeaponState weaponState;
    CScriptArgReader argStream ( luaVM );
    argStream.ReadUserData ( pWeapon );

    if ( !argStream.HasErrors () )
    {
        weaponState = pWeapon->GetWeaponState ( );
        SString strValue = EnumToString ( weaponState );
        lua_pushstring ( luaVM, strValue );
        return 1;
    }
    else
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() );

    lua_pushboolean ( luaVM, false );
    return 1;
}
コード例 #13
0
ファイル: Ship.cpp プロジェクト: Ouaz/freeorion
std::string Ship::Dump() const {
    std::stringstream os;
    os << UniverseObject::Dump();
    os << " design id: " << m_design_id
       << " fleet id: " << m_fleet_id
       << " species name: " << m_species_name
       << " produced by empire id: " << m_produced_by_empire_id
       << " arrived on turn: " << m_arrived_on_turn;
    if (!m_part_meters.empty()) {
        os << " part meters: ";
        for (PartMeterMap::const_iterator it = m_part_meters.begin(); it != m_part_meters.end();) {
        const std::string part_name = it->first.second;
        MeterType meter_type = it->first.first;
        const Meter& meter = it->second;
        ++it;
        os << UserString(part_name) << " "
           << UserString(EnumToString(meter_type))
           << ": " << meter.Current() << "  ";
    }
    }
    return os.str();
}
コード例 #14
0
void PageRecord::StartPage() {

	if(m_page_started)
		return;

	assert(!m_input_started);
	assert(!m_output_started);

	// save the settings in case libav/ffmpeg decides to kill the process
	m_main_window->SaveSettings();

	// clear the log
	m_textedit_log->clear();

	// clear the preview
	if(m_previewing) {
		m_video_previewer->Reset();
		m_audio_previewer->Reset();
	}

	PageInput *page_input = m_main_window->GetPageInput();
	PageOutput *page_output = m_main_window->GetPageOutput();

	// get the video input settings
	m_video_area = page_input->GetVideoArea();
	m_video_x = page_input->GetVideoX();
	m_video_y = page_input->GetVideoY();
	if(m_video_area == PageInput::VIDEO_AREA_GLINJECT) {
		m_video_in_width = 0;
		m_video_in_height = 0;
	} else {
		m_video_in_width = page_input->GetVideoW();
		m_video_in_height = page_input->GetVideoH();
	}
	m_video_frame_rate = page_input->GetVideoFrameRate();
	m_video_scaling = page_input->GetVideoScalingEnabled();
	m_video_scaled_width = page_input->GetVideoScaledW();
	m_video_scaled_height = page_input->GetVideoScaledH();
	m_video_record_cursor = page_input->GetVideoRecordCursor();

	// get the audio input settings
	m_audio_enabled = page_input->GetAudioEnabled();
	m_audio_channels = 2;
	m_audio_sample_rate = 44100;
	m_audio_backend = page_input->GetAudioBackend();
	m_alsa_source = page_input->GetALSASourceName();
#if SSR_USE_PULSEAUDIO
	m_pulseaudio_source = page_input->GetPulseAudioSourceName();
#endif
#if SSR_USE_JACK
	bool jack_connect_system_capture = page_input->GetJackConnectSystemCapture();
	bool jack_connect_system_playback = page_input->GetJackConnectSystemPlayback();
#endif

	// get the glinject settings
	QString glinject_channel = page_input->GetGLInjectChannel();
	bool glinject_relax_permissions = page_input->GetGLInjectRelaxPermissions();
	QString glinject_command = page_input->GetGLInjectCommand();
	QString glinject_working_directory = page_input->GetGLInjectWorkingDirectory();
	bool glinject_auto_launch = page_input->GetGLInjectAutoLaunch();
	bool glinject_limit_fps = page_input->GetGLInjectLimitFPS();

	// get file settings
	m_file_base = page_output->GetFile();
	m_file_protocol = page_output->GetFileProtocol();
	m_separate_files = page_output->GetSeparateFiles();

	// get the output settings
	if(m_separate_files)
		m_output_settings.file = QString(); // will be set later
	else
		m_output_settings.file = m_file_base;
	m_output_settings.container_avname = page_output->GetContainerAVName();

	m_output_settings.video_codec_avname = page_output->GetVideoCodecAVName();
	m_output_settings.video_kbit_rate = page_output->GetVideoKBitRate();
	m_output_settings.video_options.clear();
	m_output_settings.video_width = 0;
	m_output_settings.video_height = 0;
	m_output_settings.video_frame_rate = m_video_frame_rate;
	m_output_settings.video_allow_frame_skipping = page_output->GetVideoAllowFrameSkipping();

	m_output_settings.audio_codec_avname = (m_audio_enabled)? page_output->GetAudioCodecAVName() : QString();
	m_output_settings.audio_kbit_rate = page_output->GetAudioKBitRate();
	m_output_settings.audio_options.clear();
	m_output_settings.audio_channels = m_audio_channels;
	m_output_settings.audio_sample_rate = m_audio_sample_rate;

	// some codec-specific things
	// you can get more information about all these options by running 'ffmpeg -h' or 'avconv -h' from a terminal
	switch(page_output->GetVideoCodec()) {
		case PageOutput::VIDEO_CODEC_H264: {
			// x264 has a 'constant quality' mode, where the bit rate is simply set to whatever is needed to keep a certain quality. The quality is set
			// with the 'crf' option. 'preset' changes the encoding speed (and hence the efficiency of the compression) but doesn't really influence the quality,
			// which is great because it means you don't have to experiment with different bit rates and different speeds to get good results.
			m_output_settings.video_options.push_back(std::make_pair(QString("crf"), QString::number(page_output->GetH264CRF())));
			m_output_settings.video_options.push_back(std::make_pair(QString("preset"), EnumToString(page_output->GetH264Preset())));
			break;
		}
		case PageOutput::VIDEO_CODEC_VP8: {
			// The names of there parameters are very unintuitive. The two options we care about (because they change the speed) are 'deadline' and 'cpu-used'.
			// 'deadline=best' is unusably slow. 'deadline=good' is the normal setting, it tells the encoder to use the speed set with 'cpu-used'. Higher
			// numbers will use *less* CPU, confusingly, so a higher number is faster. I haven't done much testing with 'realtime' so I'm not sure if it's a good idea here.
			// It sounds useful, but I think it will use so much CPU that it will slow down the program that is being recorded.
			m_output_settings.video_options.push_back(std::make_pair(QString("deadline"), QString("good")));
			m_output_settings.video_options.push_back(std::make_pair(QString("cpu-used"), QString::number(page_output->GetVP8CPUUsed())));
			break;
		}
		case PageOutput::VIDEO_CODEC_OTHER: {
			m_output_settings.video_options = GetOptionsFromString(page_output->GetVideoOptions());
			break;
		}
		default: break; // to keep GCC happy
	}
	switch(page_output->GetAudioCodec()) {
		case PageOutput::AUDIO_CODEC_OTHER: {
			m_output_settings.audio_options = GetOptionsFromString(page_output->GetAudioOptions());
			break;
		}
		default: break; // to keep GCC happy
	}

	// hide the audio previewer if there is no audio
	GroupVisible({m_label_mic_icon, m_audio_previewer}, m_audio_enabled);

	Logger::LogInfo("[PageRecord::StartPage] " + tr("Starting page ..."));


	try {

		// for OpenGL recording, create the input now
		if(m_video_area == PageInput::VIDEO_AREA_GLINJECT) {
			if(glinject_auto_launch)
				GLInjectInput::LaunchApplication(glinject_channel, glinject_relax_permissions, glinject_command, glinject_working_directory);
			m_gl_inject_input.reset(new GLInjectInput(glinject_channel, glinject_relax_permissions, m_video_record_cursor, glinject_limit_fps, m_video_frame_rate));
		}

#if SSR_USE_JACK
		if(m_audio_enabled) {
			// for JACK, start the input now
			if(m_audio_backend == PageInput::AUDIO_BACKEND_JACK)
				m_jack_input.reset(new JACKInput(jack_connect_system_capture, jack_connect_system_playback));
		}
#endif

	} catch(...) {
		Logger::LogError("[PageRecord::StartPage] " + tr("Error: Something went wrong during initialization."));
		m_gl_inject_input.reset();
#if SSR_USE_JACK
		m_jack_input.reset();
#endif
	}

	Logger::LogInfo("[PageRecord::StartPage] " + tr("Started page."));

	m_page_started = true;
	m_recorded_something = false;
	m_wait_saving = false;
	UpdateSysTray();
	OnUpdateHotkey();
	OnUpdateSoundNotifications();

	UpdateInput();

	OnUpdateInformation();
	m_timer_update_info->start(1000);

}
コード例 #15
0
ファイル: PageOutput.cpp プロジェクト: Yhonay/ssr
PageOutput::PageOutput(MainWindow* main_window)
	: QWidget(main_window->centralWidget()) {

	m_main_window = main_window;

	m_old_container = (enum_container) 0;
	m_old_container_av = 0;

	// main codecs
	// (initializer lists should use explicit types for Clang)
	m_containers = {
		ContainerData({"Matroska (MKV)", "matroska", QStringList({"mkv"}), tr("%1 files", "This appears in the file dialog, e.g. 'MP4 files'").arg("Matroska") + " (*.mkv)",
			{VIDEO_CODEC_H264, VIDEO_CODEC_VP8, VIDEO_CODEC_THEORA},
			{AUDIO_CODEC_VORBIS, AUDIO_CODEC_MP3, AUDIO_CODEC_AAC, AUDIO_CODEC_UNCOMPRESSED}}),
		ContainerData({"MP4", "mp4", QStringList({"mp4"}), tr("%1 files", "This appears in the file dialog, e.g. 'MP4 files'").arg("MP4") + " (*.mp4)",
			{VIDEO_CODEC_H264},
			{AUDIO_CODEC_VORBIS, AUDIO_CODEC_MP3, AUDIO_CODEC_AAC}}),
		ContainerData({"WebM", "webm", QStringList({"webm"}), tr("%1 files", "This appears in the file dialog, e.g. 'MP4 files'").arg("WebM") + " (*.webm)",
			{VIDEO_CODEC_VP8},
			{AUDIO_CODEC_VORBIS}}),
		ContainerData({"OGG", "ogg", QStringList({"ogg"}), tr("%1 files", "This appears in the file dialog, e.g. 'MP4 files'").arg("OGG") + " (*.ogg)",
			{VIDEO_CODEC_THEORA},
			{AUDIO_CODEC_VORBIS}}),
		ContainerData({tr("Other..."), "other", QStringList(), "", std::set<enum_video_codec>({}), std::set<enum_audio_codec>({})}),
	};
	m_video_codecs = {
		{"H.264"       , "libx264"  },
		{"VP8"         , "libvpx"   },
		{"Theora"      , "libtheora"},
		{tr("Other..."), "other"    },
	};
	m_audio_codecs = {
		{"Vorbis"          , "libvorbis"   },
		{"MP3"             , "libmp3lame"  },
		{"AAC"             , "libvo_aacenc"},
		{tr("Uncompressed"), "pcm_s16le"   },
		{tr("Other...")    , "other"       },
	};

	// alternative aac codec
	if(!AVCodecIsInstalled(m_audio_codecs[AUDIO_CODEC_AAC].avname)) {
		m_audio_codecs[AUDIO_CODEC_AAC].avname = "aac";
	}

	// load AV container list
	m_containers_av.clear();
	for(AVOutputFormat *format = av_oformat_next(NULL); format != NULL; format = av_oformat_next(format)) {
		if(format->video_codec == AV_CODEC_ID_NONE)
			continue;
		ContainerData c;
		c.name = format->long_name;
		c.avname = format->name;
		c.suffixes = QString(format->extensions).split(',', QString::SkipEmptyParts);
		if(c.suffixes.isEmpty()) {
			c.filter = "";
		} else {
			c.filter = tr("%1 files", "This appears in the file dialog, e.g. 'MP4 files'").arg(c.avname) + " (*." + c.suffixes[0];
			for(int i = 1; i < c.suffixes.size(); ++i) {
				c.suffixes[i] = c.suffixes[i].trimmed(); // needed because libav/ffmpeg isn't very consistent when they say 'comma-separated'
				c.filter += " *." + c.suffixes[i];
			}
			c.filter += ")";
		}
		m_containers_av.push_back(c);
	}
	std::sort(m_containers_av.begin(), m_containers_av.end());

	// load AV codec list
	m_video_codecs_av.clear();
	m_audio_codecs_av.clear();
	for(AVCodec *codec = av_codec_next(NULL); codec != NULL; codec = av_codec_next(codec)) {
		if(!av_codec_is_encoder(codec))
			continue;
		if(codec->type == AVMEDIA_TYPE_VIDEO && VideoEncoder::AVCodecIsSupported(codec->name)) {
			VideoCodecData c;
			c.name = codec->long_name;
			c.avname = codec->name;
			m_video_codecs_av.push_back(c);
		}
		if(codec->type == AVMEDIA_TYPE_AUDIO && AudioEncoder::AVCodecIsSupported(codec->name)) {
			AudioCodecData c;
			c.name = codec->long_name;
			c.avname = codec->name;
			m_audio_codecs_av.push_back(c);
		}
	}
	std::sort(m_video_codecs_av.begin(), m_video_codecs_av.end());
	std::sort(m_audio_codecs_av.begin(), m_audio_codecs_av.end());

	if(m_containers_av.empty()) {
		Logger::LogError("[PageOutput::PageOutput] " + tr("Error: Could not find any suitable container in libavformat!"));
		throw LibavException();
	}
	if(m_video_codecs_av.empty()) {
		Logger::LogError("[PageOutput::PageOutput] " + tr("Error: Could not find any suitable video codec in libavcodec!"));
		throw LibavException();
	}
	if(m_audio_codecs_av.empty()) {
		Logger::LogError("[PageOutput::PageOutput] " + tr("Error: Could not find any suitable audio codec in libavcodec!"));
		throw LibavException();
	}

	m_profile_box = new ProfileBox(this, "output-profiles", &LoadProfileSettingsCallback, &SaveProfileSettingsCallback, this);

	QGroupBox *groupbox_file = new QGroupBox(tr("File"), this);
	{
		QLabel *label_file = new QLabel(tr("Save as:"), groupbox_file);
		m_lineedit_file = new QLineEdit(groupbox_file);
		m_lineedit_file->setToolTip(tr("The recording will be saved to this location."));
		QPushButton *button_browse = new QPushButton(tr("Browse..."), groupbox_file);
		m_checkbox_separate_files = new QCheckBox(tr("Separate file per segment"), groupbox_file);
		m_checkbox_separate_files->setToolTip(tr("If checked, a separate video file will be created every time you pause and resume the recording.\n"
												 "If the original file name is 'test.mkv', the segments will be saved as 'test-YYYY-MM-DD_HH.MM.SS.mkv'."));
		QLabel *label_container = new QLabel(tr("Container:"), groupbox_file);
		m_combobox_container = new QComboBox(groupbox_file);
		for(unsigned int i = 0; i < CONTAINER_COUNT; ++i) {
			QString name = "\u200e" + m_containers[i].name + "\u200e";
			if(i != CONTAINER_OTHER && !AVFormatIsInstalled(m_containers[i].avname))
				name += " \u200e" + tr("(not installed)") + "\u200e";
			m_combobox_container->addItem(name);
		}
		m_combobox_container->setToolTip(tr("The container (file format) that will be used to save the recording.\n"
											"Note that not all codecs are supported by all containers, and that not all media players can read all file formats.\n"
											"- Matroska (MKV) supports all the codecs, but is less well-known.\n"
											"- MP4 is the most well-known format and will play on almost any modern media player, but supports only H.264 video\n"
											"   (and many media players only support AAC audio).\n"
											"- WebM is intended for embedding video into websites (with the HTML5 <video> tag). The format was created by Google.\n"
											"   WebM is supported by default in Firefox, Chrome and Opera, and plugins are available for Internet Explorer and Safari.\n"
											"   It supports only VP8 and Vorbis.\n"
											"- OGG supports only Theora and Vorbis."));
		m_label_container_av = new QLabel(tr("Container name:"), groupbox_file);
		m_combobox_container_av = new QComboBox(groupbox_file);
		for(unsigned int i = 0; i < m_containers_av.size(); ++i) {
			ContainerData &c = m_containers_av[i];
			m_combobox_container_av->addItem(c.avname);
		}
		m_combobox_container_av->setToolTip(tr("For advanced users. You can use any libav/ffmpeg format, but many of them are not useful or may not work."));

		connect(m_combobox_container, SIGNAL(activated(int)), this, SLOT(OnUpdateSuffixAndContainerFields()));
		connect(m_combobox_container_av, SIGNAL(activated(int)), this, SLOT(OnUpdateSuffixAndContainerFields()));
		connect(button_browse, SIGNAL(clicked()), this, SLOT(OnBrowse()));

		QGridLayout *layout = new QGridLayout(groupbox_file);
		layout->addWidget(label_file, 0, 0);
		layout->addWidget(m_lineedit_file, 0, 1);
		layout->addWidget(button_browse, 0, 2);
		layout->addWidget(m_checkbox_separate_files, 1, 0, 1, 3);
		layout->addWidget(label_container, 2, 0);
		layout->addWidget(m_combobox_container, 2, 1, 1, 2);
		layout->addWidget(m_label_container_av, 3, 0);
		layout->addWidget(m_combobox_container_av, 3, 1, 1, 2);
	}
	QGroupBox *groupbox_video = new QGroupBox(tr("Video"), this);
	{
		QLabel *label_video_codec = new QLabel(tr("Codec:"), groupbox_video);
		m_combobox_video_codec = new QComboBox(groupbox_video);
		for(unsigned int i = 0; i < VIDEO_CODEC_COUNT; ++i) {
			m_combobox_video_codec->addItem(m_video_codecs[i].name);
		}
		m_combobox_video_codec->setToolTip(tr("The codec that will be used to compress the video stream.\n"
											  "- H.264 (libx264) is by far the best codec - high quality and very fast.\n"
											  "- VP8 (libvpx) is quite good but also quite slow.\n"
											  "- Theora (libtheora) isn't really recommended because the quality isn't very good."));
		m_label_video_codec_av = new QLabel(tr("Codec name:"), groupbox_video);
		m_combobox_video_codec_av = new QComboBox(groupbox_video);
		for(unsigned int i = 0; i < m_video_codecs_av.size(); ++i) {
			VideoCodecData &c = m_video_codecs_av[i];
			m_combobox_video_codec_av->addItem(c.avname);
		}
		m_combobox_video_codec_av->setToolTip(tr("For advanced users. You can use any libav/ffmpeg video codec, but many of them are not useful or may not work."));
		m_label_video_kbit_rate = new QLabel(tr("Bit rate (in kbps):"), groupbox_video);
		m_lineedit_video_kbit_rate = new QLineEdit(groupbox_video);
		m_lineedit_video_kbit_rate->setToolTip(tr("The video bit rate (in kilobit per second). A higher value means a higher quality."
												  "\nIf you have no idea where to start, try 5000 and change it if needed."));
		m_label_h264_crf = new QLabel(tr("Constant rate factor:", "libx264 setting: don't translate this unless you can come up with something sensible"), groupbox_video);
		m_slider_h264_crf = new QSlider(Qt::Horizontal, groupbox_video);
		m_slider_h264_crf->setRange(0, 51);
		m_slider_h264_crf->setSingleStep(1);
		m_slider_h264_crf->setPageStep(5);
		m_slider_h264_crf->setToolTip(tr("This setting changes the video quality. A lower value means a higher quality.\n"
										 "The allowed range is 0-51 (0 means lossless, the default is 23)."));
		m_label_h264_crf_value = new QLabel(groupbox_video);
		m_label_h264_crf_value->setNum(m_slider_h264_crf->value());
		m_label_h264_crf_value->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
		m_label_h264_crf_value->setMinimumWidth(QFontMetrics(m_label_h264_crf_value->font()).width("99") + 2);
		m_label_h264_preset = new QLabel(tr("Preset:", "libx264 setting: don't translate this unless you can come up with something sensible"), groupbox_video);
		m_combobox_h264_preset = new QComboBox(groupbox_video);
		for(unsigned int i = 0; i < H264_PRESET_COUNT; ++i) {
			m_combobox_h264_preset->addItem(EnumToString((enum_h264_preset) i));
		}
		m_combobox_h264_preset->setToolTip(tr("The encoding speed. A higher speed uses less CPU (making higher recording frame rates possible),\n"
											  "but results in larger files. The quality shouldn't be affected too much."));
		m_label_vp8_cpu_used = new QLabel(tr("CPU used:", "libvpx setting: don't translate this unless you can come up with something sensible"), groupbox_video);
		m_combobox_vp8_cpu_used = new QComboBox(groupbox_video);
		m_combobox_vp8_cpu_used->addItem("5 (" + tr("fastest") + ")");
		m_combobox_vp8_cpu_used->addItem("4");
		m_combobox_vp8_cpu_used->addItem("3");
		m_combobox_vp8_cpu_used->addItem("2");
		m_combobox_vp8_cpu_used->addItem("1");
		m_combobox_vp8_cpu_used->addItem("0 (" + tr("slowest") + ")");
		m_combobox_vp8_cpu_used->setToolTip(tr("The encoding speed. A higher value uses *less* CPU time. (I didn't choose the name, this is the name\n"
											   "used by the VP8 encoder). Higher values result in lower quality video, unless you increase the bit rate too."));
		m_label_video_options = new QLabel(tr("Custom options:"), groupbox_video);
		m_lineedit_video_options = new QLineEdit(groupbox_video);
		m_lineedit_video_options->setToolTip(tr("Custom codec options separated by commas (e.g. option1=value1,option2=value2,option3=value3)"));
		m_checkbox_video_allow_frame_skipping = new QCheckBox(tr("Allow frame skipping"), groupbox_video);
		m_checkbox_video_allow_frame_skipping->setToolTip(tr("If checked, the video encoder will be allowed to skip frames if the input frame rate is\n"
															 "lower than the output frame rate. If not checked, input frames will be duplicated to fill the holes.\n"
															 "This increases the file size and CPU usage, but reduces the latency for live streams in some cases.\n"
															 "It shouldn't affect the appearance of the video."));

		connect(m_combobox_video_codec, SIGNAL(activated(int)), this, SLOT(OnUpdateVideoCodecFields()));
		connect(m_slider_h264_crf, SIGNAL(valueChanged(int)), m_label_h264_crf_value, SLOT(setNum(int)));

		QGridLayout *layout = new QGridLayout(groupbox_video);
		layout->addWidget(label_video_codec, 0, 0);
		layout->addWidget(m_combobox_video_codec, 0, 1, 1, 2);
		layout->addWidget(m_label_video_codec_av, 1, 0);
		layout->addWidget(m_combobox_video_codec_av, 1, 1, 1, 2);
		layout->addWidget(m_label_video_kbit_rate, 2, 0);
		layout->addWidget(m_lineedit_video_kbit_rate, 2, 1, 1, 2);
		layout->addWidget(m_label_h264_crf, 3, 0);
		layout->addWidget(m_slider_h264_crf, 3, 1);
		layout->addWidget(m_label_h264_crf_value, 3, 2);
		layout->addWidget(m_label_h264_preset, 4, 0);
		layout->addWidget(m_combobox_h264_preset, 4, 1, 1, 2);
		layout->addWidget(m_label_vp8_cpu_used, 5, 0);
		layout->addWidget(m_combobox_vp8_cpu_used, 5, 1, 1, 2);
		layout->addWidget(m_label_video_options, 6, 0);
		layout->addWidget(m_lineedit_video_options, 6, 1, 1, 2);
		layout->addWidget(m_checkbox_video_allow_frame_skipping, 7, 0, 1, 3);
	}
	m_groupbox_audio = new QGroupBox(tr("Audio"));
	{
		QLabel *label_audio_codec = new QLabel(tr("Codec:"), m_groupbox_audio);
		m_combobox_audio_codec = new QComboBox(m_groupbox_audio);
		for(unsigned int i = 0; i < AUDIO_CODEC_COUNT; ++i) {
			m_combobox_audio_codec->addItem(m_audio_codecs[i].name);
		}
		m_combobox_audio_codec->setToolTip(tr("The codec that will be used to compress the audio stream. You shouldn't worry too much about\n"
											  "this, because the size of the audio data is usually negligible compared to the size of the video data.\n"
											  "And if you're only recording your own voice (i.e. no music), the quality won't matter that much anyway.\n"
											  "- Vorbis (libvorbis) is great, this is the recommended codec.\n"
											  "- MP3 (libmp3lame) is reasonably good.\n"
											  "- AAC is a good codec, but the implementations used here (libvo_aacenc or the experimental ffmpeg aac encoder)\n"
											  "   are pretty bad. Only use it if you have no other choice.\n"
											  "- Uncompressed will simply store the sound data without compressing it. The file will be quite large, but it's very fast."));
		m_label_audio_codec_av = new QLabel(tr("Codec name:"), m_groupbox_audio);
		m_combobox_audio_codec_av = new QComboBox(m_groupbox_audio);
		for(unsigned int i = 0; i < m_audio_codecs_av.size(); ++i) {
			AudioCodecData &c = m_audio_codecs_av[i];
			m_combobox_audio_codec_av->addItem(c.avname);
		}
		m_combobox_audio_codec_av->setToolTip(tr("For advanced users. You can use any libav/ffmpeg audio codec, but many of them are not useful or may not work."));
		m_label_audio_kbit_rate = new QLabel(tr("Bit rate (in kbps):"), m_groupbox_audio);
		m_lineedit_audio_kbit_rate = new QLineEdit(m_groupbox_audio);
		m_lineedit_audio_kbit_rate->setToolTip(tr("The audio bit rate (in kilobit per second). A higher value means a higher quality. The typical value is 128."));
		m_label_audio_options = new QLabel(tr("Custom options:"), m_groupbox_audio);
		m_lineedit_audio_options = new QLineEdit(m_groupbox_audio);
		m_lineedit_audio_options->setToolTip(tr("Custom codec options separated by commas (e.g. option1=value1,option2=value2,option3=value3)"));

		connect(m_combobox_audio_codec, SIGNAL(activated(int)), this, SLOT(OnUpdateAudioCodecFields()));

		QGridLayout *layout = new QGridLayout(m_groupbox_audio);
		layout->addWidget(label_audio_codec, 0, 0);
		layout->addWidget(m_combobox_audio_codec, 0, 1);
		layout->addWidget(m_label_audio_codec_av, 1, 0);
		layout->addWidget(m_combobox_audio_codec_av, 1, 1);
		layout->addWidget(m_label_audio_kbit_rate, 2, 0);
		layout->addWidget(m_lineedit_audio_kbit_rate, 2, 1);
		layout->addWidget(m_label_audio_options, 3, 0);
		layout->addWidget(m_lineedit_audio_options, 3, 1);
	}
	QPushButton *button_back = new QPushButton(g_icon_go_previous, tr("Back"), this);
	QPushButton *button_continue = new QPushButton(g_icon_go_next, tr("Continue"), this);

	connect(button_back, SIGNAL(clicked()), m_main_window, SLOT(GoPageInput()));
	connect(button_continue, SIGNAL(clicked()), this, SLOT(OnContinue()));

	QVBoxLayout *layout = new QVBoxLayout(this);
	layout->addWidget(m_profile_box);
	layout->addWidget(groupbox_file);
	layout->addWidget(groupbox_video);
	layout->addWidget(m_groupbox_audio);
	layout->addStretch();
	{
		QHBoxLayout *layout2 = new QHBoxLayout();
		layout->addLayout(layout2);
		layout2->addWidget(button_back);
		layout2->addWidget(button_continue);
	}

	OnUpdateContainerFields();
	OnUpdateVideoCodecFields();
	OnUpdateAudioCodecFields();

}
コード例 #16
0
ファイル: TNode.cpp プロジェクト: darrenbkl/SPA
TNode TNode::ConstructProgramTNode(string name) {
	return TNode(TNode::PROGRAM, ":" + EnumToString(TNode::PROGRAM));
}
コード例 #17
0
ファイル: TNode.cpp プロジェクト: darrenbkl/SPA
TNode TNode::ConstructStmtTNode(Type type, int lineNumber) {
	TNode result(type, ":" + EnumToString(type));
	result.lineNumber = lineNumber;
	return result;
}
コード例 #18
0
ファイル: TNode.cpp プロジェクト: darrenbkl/SPA
TNode TNode::ConstructStmtListTNode(string name) {
	return TNode(TNode::STMT_LIST, name +":" + EnumToString(TNode::STMT_LIST));
}
コード例 #19
0
ファイル: TNode.cpp プロジェクト: darrenbkl/SPA
TNode TNode::ConstructProcedureTNode(string name) {
	TNode result(TNode::PROCEDURE, ":" + EnumToString(TNode::PROCEDURE));
	result.content = name;
	return result;
}
コード例 #20
0
ファイル: TNode.cpp プロジェクト: darrenbkl/SPA
TNode TNode::ConstructVarTNode(string symbol) {
	TNode result(TNode::VARIABLE, symbol + ":" + EnumToString(TNode::VARIABLE));
	result.content = symbol;
	return result;
}
コード例 #21
0
///////////////////////////////////////////////////////////////
//
// CPerfStatRPCPacketUsageImpl::GetStats
//
//
//
///////////////////////////////////////////////////////////////
void CPerfStatRPCPacketUsageImpl::GetStats(CPerfStatResult* pResult, const std::map<SString, int>& strOptionMap, const SString& strFilter)
{
    m_TimeSinceGetStats.Reset();
    MaybeRecordStats();

    //
    // Set option flags
    //
    bool bHelp = MapContains(strOptionMap, "h");

    //
    // Process help
    //
    if (bHelp)
    {
        pResult->AddColumn("RPC Packet usage help");
        pResult->AddRow()[0] = "Option h - This help";
        return;
    }

    // Add columns
    pResult->AddColumn("Packet type");
    pResult->AddColumn("Incoming.msgs/sec");
    pResult->AddColumn("Incoming.bytes/sec");
    pResult->AddColumn("Incoming.cpu");
    pResult->AddColumn("Outgoing.msgs/sec");
    pResult->AddColumn("Outgoing.bytes/sec");
    pResult->AddColumn("Outgoing.cpu");

    if (m_iStatsCleared)
    {
        pResult->AddRow()[0] = "Sampling... Please wait";
    }

    long long llTickCountNow = CTickCount::Now().ToLongLong();

    // Fill rows
    for (uint i = 0; i < 256; i++)
    {
        // Calc incoming delta values
        SPacketStat statInDelta;
        {
            const SRPCPacketStat& statInPrev = m_PrevPacketStatsIn[i];
            const SRPCPacketStat& statInNow = m_PacketStatsIn[i];
            statInDelta.iCount = statInNow.iCount - statInPrev.iCount;
            statInDelta.iTotalBytes = statInNow.iTotalBytes - statInPrev.iTotalBytes;
            // statInDelta.totalTime   = statInNow.totalTime - statInPrev.totalTime;
        }

        if (!statInDelta.iCount)
        {
            // Once displayed, keep a row displayed for at least 20 seconds
            if (llTickCountNow - m_ShownPacketStatsIn[i] > 20000)
                continue;
        }
        else
        {
            m_ShownPacketStatsIn[i] = llTickCountNow;
        }

        // Add row
        SString* row = pResult->AddRow();

        int c = 0;
        // Turn "CRPCFunctions::PLAYER_WEAPON" into "64_Player_weapon"
        SString strPacketDesc = EnumToString((CRPCFunctions::eRPCFunctions)i).SplitRight("CRPCFunctions::", NULL, -1).ToLower();
        row[c++] = SString("%d_", i) + strPacketDesc.Left(1).ToUpper() + strPacketDesc.SubStr(1);

        if (statInDelta.iCount)
        {
            row[c++] = SString("%d", (statInDelta.iCount + 4) / 5);
            row[c++] = CPerfStatManager::GetScaledByteString((statInDelta.iTotalBytes + 4) / 5);
            row[c++] = "n/a";
        }
        else
        {
            row[c++] = "-";
            row[c++] = "-";
            row[c++] = "-";
        }

        row[c++] = "-";
        row[c++] = "-";
        row[c++] = "-";
    }

    // Fill rows
    for (uint i = 0; i < 256; i++)
    {
        // Calc outgoing delta values
        SRPCPacketStat statOutDelta;
        {
            const SRPCPacketStat& statOutPrev = m_PrevPacketStatsOut[i];
            const SRPCPacketStat& statOutNow = m_PacketStatsOut[i];
            statOutDelta.iCount = statOutNow.iCount - statOutPrev.iCount;
            statOutDelta.iTotalBytes = statOutNow.iTotalBytes - statOutPrev.iTotalBytes;
        }

        if (!statOutDelta.iCount)
        {
            // Once displayed, keep a row displayed for at least 20 seconds
            if (llTickCountNow - m_ShownPacketStatsOut[i] > 20000)
                continue;
        }
        else
        {
            m_ShownPacketStatsOut[i] = llTickCountNow;
        }

        // Add row
        SString* row = pResult->AddRow();

        int c = 0;
        // Turn "SET_WEAPON_OWNER" into "64_Set_weapon_owner"
        SString strPacketDesc = EnumToString((eElementRPCFunctions)i).ToLower();
        row[c++] = SString("%d_", i) + strPacketDesc.Left(1).ToUpper() + strPacketDesc.SubStr(1);

        row[c++] = "-";
        row[c++] = "-";
        row[c++] = "-";

        if (statOutDelta.iCount)
        {
            row[c++] = SString("%d", (statOutDelta.iCount + 4) / 5);
            row[c++] = CPerfStatManager::GetScaledByteString((statOutDelta.iTotalBytes + 4) / 5);
            row[c++] = "n/a";
        }
        else
        {
            row[c++] = "-";
            row[c++] = "-";
            row[c++] = "-";
        }
    }
}
コード例 #22
0
///////////////////////////////////////////////////////////////
//
// CPerfStatPacketUsageImpl::GetStats
//
//
//
///////////////////////////////////////////////////////////////
void CPerfStatPacketUsageImpl::GetStats(CPerfStatResult* pResult, const std::map<SString, int>& strOptionMap, const SString& strFilter)
{
    m_TimeSinceGetStats.Reset();
    MaybeRecordStats();

    //
    // Set option flags
    //
    bool bHelp = MapContains(strOptionMap, "h");

    //
    // Process help
    //
    if (bHelp)
    {
        pResult->AddColumn("Packet usage help");
        pResult->AddRow()[0] = "Option h - This help";
        return;
    }

    // Add columns
    pResult->AddColumn("Packet type");
    pResult->AddColumn("Incoming.msgs/sec");
    pResult->AddColumn("Incoming.bytes/sec");
    pResult->AddColumn("Incoming.logic cpu");
    pResult->AddColumn("Outgoing.msgs/sec");
    pResult->AddColumn("Outgoing.bytes/sec");
    pResult->AddColumn("Outgoing.msgs share");

    if (m_iStatsCleared)
    {
        pResult->AddRow()[0] = "Sampling... Please wait";
    }

    // Calc msgs grand total for percent calculation
    int iOutDeltaCountTotal = 0;
    for (uint i = 0; i < 256; i++)
    {
        const SPacketStat& statOutPrev = m_PrevPacketStats[CNetServer::STATS_OUTGOING_TRAFFIC][i];
        const SPacketStat& statOutNow = m_PacketStats[CNetServer::STATS_OUTGOING_TRAFFIC][i];
        iOutDeltaCountTotal += statOutNow.iCount - statOutPrev.iCount;
    }

    long long llTickCountNow = CTickCount::Now().ToLongLong();
    // Fill rows
    for (uint i = 0; i < 256; i++)
    {
        // Calc incoming delta values
        SPacketStat statInDelta;
        {
            const SPacketStat& statInPrev = m_PrevPacketStats[CNetServer::STATS_INCOMING_TRAFFIC][i];
            const SPacketStat& statInNow = m_PacketStats[CNetServer::STATS_INCOMING_TRAFFIC][i];
            statInDelta.iCount = statInNow.iCount - statInPrev.iCount;
            statInDelta.iTotalBytes = statInNow.iTotalBytes - statInPrev.iTotalBytes;
            statInDelta.totalTime = statInNow.totalTime - statInPrev.totalTime;
        }

        // Calc outgoing delta values
        SPacketStat statOutDelta;
        {
            const SPacketStat& statOutPrev = m_PrevPacketStats[CNetServer::STATS_OUTGOING_TRAFFIC][i];
            const SPacketStat& statOutNow = m_PacketStats[CNetServer::STATS_OUTGOING_TRAFFIC][i];
            statOutDelta.iCount = statOutNow.iCount - statOutPrev.iCount;
            statOutDelta.iTotalBytes = statOutNow.iTotalBytes - statOutPrev.iTotalBytes;
            statOutDelta.totalTime = statOutNow.totalTime - statOutPrev.totalTime;
        }

        if (!statInDelta.iCount && !statOutDelta.iCount)
        {
            // Once displayed, keep a row displayed for at least 20 seconds
            if (llTickCountNow - m_ShownPacketStats[i] > 20000)
                continue;
        }
        else
        {
            m_ShownPacketStats[i] = llTickCountNow;
        }

        // Add row
        SString* row = pResult->AddRow();

        int c = 0;
        // Turn "PACKET_ID_PED_SYNC" into "64_Ped_sync"
        SString strPacketDesc = EnumToString((ePacketID)i).SplitRight("PACKET_ID", NULL, -1).ToLower();
        row[c++] = SString("%d", i) + strPacketDesc.Left(2).ToUpper() + strPacketDesc.SubStr(2);
        if (statInDelta.iCount)
        {
            row[c++] = SString("%d", (statInDelta.iCount + 4) / 5);
            row[c++] = CPerfStatManager::GetScaledByteString((statInDelta.iTotalBytes + 4) / 5);
            row[c++] = SString("%2.2f%%",
                               statInDelta.totalTime / 50000.f);            // Number of microseconds in sample period ( 5sec * 1000000 ) into percent ( * 100 )
        }
        else
        {
            row[c++] = "-";
            row[c++] = "-";
            row[c++] = "-";
        }

        if (statOutDelta.iCount)
        {
            row[c++] = SString("%d", (statOutDelta.iCount + 4) / 5);
            row[c++] = CPerfStatManager::GetScaledByteString((statOutDelta.iTotalBytes + 4) / 5);
            row[c++] = SString("%d%%", (int)(statOutDelta.iCount * 100 / iOutDeltaCountTotal));
        }
        else
        {
            row[c++] = "-";
            row[c++] = "-";
            row[c++] = "-";
        }
    }
}
コード例 #23
0
ファイル: TNode.cpp プロジェクト: darrenbkl/SPA
TNode TNode::ConstructConstTNode(string value) {
	TNode result(TNode::CONSTANT, value + ":" + EnumToString(TNode::CONSTANT));
	result.content = value;
	return result;
}
コード例 #24
0
void HumanClientApp::RequestSavePreviews(const std::string& directory, PreviewInformation& previews){
    std::string  generic_directory = fs::path(directory).generic_string();
    if(!m_networking.Connected()){
        DebugLogger() << "HumanClientApp::RequestSavePreviews: No game running. Start a server for savegame queries.";
        StartServer();

        DebugLogger() << "HumanClientApp::RequestSavePreviews Connecting to server";
        unsigned int start_time = Ticks();
        while (!m_networking.ConnectToLocalHostServer()) {
            if (SERVER_CONNECT_TIMEOUT < Ticks() - start_time) {
                ErrorLogger() << "HumanClientApp::LoadSinglePlayerGame() server connecting timed out";
                ClientUI::MessageBox(UserString("ERR_CONNECT_TIMED_OUT"), true);
                KillServer();
                return;
            }
        }
        m_connected = true;
    }
    DebugLogger() << "HumanClientApp::RequestSavePreviews Requesting previews for " << generic_directory;
    Message response;
    m_networking.SendSynchronousMessage(RequestSavePreviewsMessage(PlayerID(), generic_directory), response);
    if (response.Type() == Message::DISPATCH_SAVE_PREVIEWS){
        ExtractMessageData(response, previews);
        DebugLogger() << "HumanClientApp::RequestSavePreviews Got " << previews.previews.size() << " previews.";
    }else{
        ErrorLogger() << "HumanClientApp::RequestSavePreviews: Wrong response type from server: " << EnumToString(response.Type());
    }
}
コード例 #25
0
ファイル: CEasingCurve.cpp プロジェクト: 0x688/gtasa_crashfix
std::string CEasingCurve::GetStringFromEasingType ( CEasingCurve::eType a_eType )
{
    return EnumToString ( a_eType );
}
コード例 #26
0
ファイル: MainFunctions.cpp プロジェクト: AdiBoy/mtasa-blue
//////////////////////////////////////////////////////////
//
// CheckAntiVirusStatus
//
// Maybe warn user if no anti-virus running
//
//////////////////////////////////////////////////////////
void CheckAntiVirusStatus( void )
{
    // Get data from WMI
    std::vector < SString > enabledList;
    std::vector < SString > disabledList;
    GetWMIAntiVirusStatus( enabledList, disabledList );

    // Get status from WSC
    WSC_SECURITY_PROVIDER_HEALTH health = (WSC_SECURITY_PROVIDER_HEALTH)-1;
    if ( _WscGetSecurityProviderHealth )
    {
        _WscGetSecurityProviderHealth( WSC_SECURITY_PROVIDER_ANTIVIRUS, &health );
    }

    // Dump results
    SString strStatus( "AV health: %s (%d)", *EnumToString( health ), health );
    for ( uint i = 0 ; i < enabledList.size() ; i++ )
        strStatus += SString( " [Ena%d:%s]", i, *enabledList[i] );
    for ( uint i = 0 ; i < disabledList.size() ; i++ )
        strStatus += SString( " [Dis%d:%s]", i, *disabledList[i] );
    WriteDebugEvent( strStatus ); 

    // Maybe show dialog if av not found
    if ( enabledList.empty() && health != WSC_SECURITY_PROVIDER_HEALTH_GOOD )
    {
        bool bEnableScaremongering = ( health != WSC_SECURITY_PROVIDER_HEALTH_NOTMONITORED );

        if ( bEnableScaremongering )
        {
            const char* avProducts[] = { "antivirus", "anti-virus", "Avast", "AVG", "Avira", 
                                         "NOD32", "ESET", "F-Secure", "Faronics", "Kaspersky",
                                         "McAfee", "Norton", "Symantec", "Panda", "Trend Micro", };

            // Check for anti-virus helper dlls before actual scaremongering
            HMODULE aModules[1024];
            DWORD cbNeeded;
            if ( EnumProcessModules( GetCurrentProcess(), aModules, sizeof(aModules), &cbNeeded) )
            {
                DWORD cModules = cbNeeded / sizeof(HMODULE);
                for ( uint i = 0 ; i < cModules ; i++ )
                {
                    if( aModules[i] != 0 )
                    {
                        WCHAR szModulePathFileName[1024] = L"";
                        GetModuleFileNameExW ( GetCurrentProcess(), aModules[i], szModulePathFileName, NUMELMS(szModulePathFileName) );
                        SLibVersionInfo libVersionInfo;
                        GetLibVersionInfo ( ToUTF8( szModulePathFileName ), &libVersionInfo );

                        for( uint i = 0 ; i < NUMELMS( avProducts ) ; i++ )
                        {
                            if ( libVersionInfo.strCompanyName.ContainsI( avProducts[i] )
                                 || libVersionInfo.strProductName.ContainsI( avProducts[i] ) )
                            {
                                bEnableScaremongering = false;
                                WriteDebugEvent( SString( "AV (module) maybe found %s [%d](%s,%s)", *WStringX( szModulePathFileName ).ToAnsi(), i, *libVersionInfo.strCompanyName, *libVersionInfo.strProductName ) );
                            }
                        }
                    }
                }

                if ( bEnableScaremongering )
                    WriteDebugEvent( SString( "AV Searched %d dlls, but could not find av helper", cModules ) );
            }

            if ( bEnableScaremongering )
            {
                std::vector < DWORD > processIdList = MyEnumProcesses();
                for ( uint i = 0; i < processIdList.size (); i++ )
                {
                    DWORD processId = processIdList[i];
                    // Skip 64 bit processes to avoid errors
                    if ( !Is32bitProcess ( processId ) )
                        continue;

                    std::vector < SString > filenameList = GetPossibleProcessPathFilenames ( processId );
                    for ( uint i = 0; i < filenameList.size (); i++ )
                    {
                        const SString& strProcessPathFileName = filenameList[i];
                        SLibVersionInfo libVersionInfo;
                        if ( GetLibVersionInfo ( strProcessPathFileName, &libVersionInfo ) )
                        {
                            for( uint i = 0 ; i < NUMELMS( avProducts ) ; i++ )
                            {
                                if ( libVersionInfo.strCompanyName.ContainsI( avProducts[i] )
                                     || libVersionInfo.strProductName.ContainsI( avProducts[i] ) )
                                {
                                    bEnableScaremongering = false;
                                    WriteDebugEvent( SString( "AV (process) maybe found %s [%d](%s,%s)", *strProcessPathFileName, i, *libVersionInfo.strCompanyName, *libVersionInfo.strProductName ) );
                                }
                            }
                        }
                    }
                }
                if ( bEnableScaremongering )
                    WriteDebugEvent( SString( "AV Searched %d processes, but could not find av helper", processIdList.size() ) );
            }
        }

        ShowNoAvDialog( g_hInstance, bEnableScaremongering );
        HideNoAvDialog ();
    }
}
コード例 #27
0
ファイル: AppCoreThread.cpp プロジェクト: Alchemistxxd/pcsx2
// Load Game Settings found in database
// (game fixes, round modes, clamp modes, etc...)
// Returns number of gamefixes set
static int loadGameSettings(Pcsx2Config& dest, const Game_Data& game) {
	if( !game.IsOk() ) return 0;

	int  gf  = 0;

	if (game.keyExists("eeRoundMode"))
	{
		SSE_RoundMode eeRM = (SSE_RoundMode)game.getInt("eeRoundMode");
		if (EnumIsValid(eeRM))
		{
			PatchesCon->WriteLn("(GameDB) Changing EE/FPU roundmode to %d [%s]", eeRM, EnumToString(eeRM));
			dest.Cpu.sseMXCSR.SetRoundMode(eeRM);
			++gf;
		}
	}

	if (game.keyExists("vuRoundMode"))
	{
		SSE_RoundMode vuRM = (SSE_RoundMode)game.getInt("vuRoundMode");
		if (EnumIsValid(vuRM))
		{
			PatchesCon->WriteLn("(GameDB) Changing VU0/VU1 roundmode to %d [%s]", vuRM, EnumToString(vuRM));
			dest.Cpu.sseVUMXCSR.SetRoundMode(vuRM);
			++gf;
		}
	}

	if (game.keyExists("eeClampMode")) {
		int clampMode = game.getInt("eeClampMode");
		PatchesCon->WriteLn("(GameDB) Changing EE/FPU clamp mode [mode=%d]", clampMode);
		dest.Cpu.Recompiler.fpuOverflow			= (clampMode >= 1);
		dest.Cpu.Recompiler.fpuExtraOverflow	= (clampMode >= 2);
		dest.Cpu.Recompiler.fpuFullMode			= (clampMode >= 3);
		gf++;
	}

	if (game.keyExists("vuClampMode")) {
		int clampMode = game.getInt("vuClampMode");
		PatchesCon->WriteLn("(GameDB) Changing VU0/VU1 clamp mode [mode=%d]", clampMode);
		dest.Cpu.Recompiler.vuOverflow			= (clampMode >= 1);
		dest.Cpu.Recompiler.vuExtraOverflow		= (clampMode >= 2);
		dest.Cpu.Recompiler.vuSignOverflow		= (clampMode >= 3);
		gf++;
	}


	if (game.keyExists("mvuFlagSpeedHack")) {
		bool vuFlagHack = game.getInt("mvuFlagSpeedHack") ? 1 : 0;
		PatchesCon->WriteLn("(GameDB) Changing mVU flag speed hack [mode=%d]", vuFlagHack);
		dest.Speedhacks.vuFlagHack = vuFlagHack;
		gf++;
	}

	for( GamefixId id=GamefixId_FIRST; id<pxEnumEnd; ++id )
	{
		wxString key( EnumToString(id) );
		key += L"Hack";

		if (game.keyExists(key))
		{
			bool enableIt = game.getBool(key);
			dest.Gamefixes.Set(id, enableIt);
			PatchesCon->WriteLn(L"(GameDB) %s Gamefix: " + key, enableIt ? L"Enabled" : L"Disabled");
			gf++;

			// The LUT is only used for 1 game so we allocate it only when the gamefix is enabled (save 4MB)
			if (id == Fix_GoemonTlbMiss && enableIt)
				vtlb_Alloc_Ppmap();
		}
	}

	return gf;
}
コード例 #28
0
ファイル: TNode.cpp プロジェクト: darrenbkl/SPA
TNode TNode::ConstructOperatorTNode(string symbol) {
	TNode result(TNode::OPERATOR, symbol + ":" + EnumToString(TNode::OPERATOR));
	result.content = symbol;
	return result;
}
コード例 #29
0
ファイル: CMemStats.cpp プロジェクト: ljnx86/mtasa-blue
///////////////////////////////////////////////////////////////
//
// CMemStats::CreateTables
//
// Create formatted tables for drawing with
//
///////////////////////////////////////////////////////////////
void CMemStats::CreateTables ( void )
{
    m_TableList.clear ();

    //
    // Color setups
    //
    #define YELLOW "#FFFF00"
    #define RED "#FF0000"
    #define BLUE "#0000FF"
    #define WHITE "#FFFFFF"

    #define LT_RED "#FF5050"
    #define DK_RED "#CF0000"
    #define GREY "#808080"
    #define LT_GREY "#C0C0C0"
    #define INVIS "#000000"
    #define DK_GREEN "#00CF00"
    #define LT_GREEN "#30FF30"
    #define PURPLE "#FF00FF"
    #define CYAN "#00FFFF"
    #define LT_CYAN "#00C0F0"

    // Table header
    #define HEADER1(text) LT_CYAN text WHITE

    // Cell colour depending upon the value
    SString strNumberColorsCreat =
                        GREY "0,"
                        CYAN "999999,"
                        ;

    SString strNumberColorsDstry =
                        GREY "0,"
                        PURPLE "999999,"
                        ;

    SString strNumberColorsLockStatic =
                        GREY "0,"
                        YELLOW "999999,"
                        ;

    SString strNumberColorsLockDynamic =
                        WHITE "0,"
                        WHITE "999999,"
                        ;

    SString strNumberColorsMtaVidMem =
                        LT_GREEN "-999999,"
                        GREY "0,"
                        LT_RED "999999,"
                        ;

    SString strNumberColorsModels =
                        LT_GREEN "-99999,"
                        GREY "0,"
                        LT_RED "999999,"
                        ;

    SString strNumberColorsWhite =
                        WHITE "0,"
                        WHITE "999999,"
                        ;

    SString strNumberColorsGrey =
                        GREY "0,"
                        GREY "999999,"
                        ;

    //
    // Key for weird codes in table.AddRow string:
    //
    //      |  is usually the cell delimiter character
    //      ~X means replace any following zero with character X
    //      ^2 means use number color ^2 for the following value
    //

    {
/*
    GTA vidmemory         Lock Create Destroy Total TotalKB
    StaticVertexBuffer      1     1      1      10     1000
    DynamicVertexBuffer     1     1      1      10     1000
    StaticIndexBuffer       1     1      1      10     1000
    DynamicIndexBuffer      1     1      1      10     1000
    StaticTexture           1     1      1      10     1000
    DynamicTexture          1     1      1      10     1000
    Effect                  1     1      1      10     1000
*/
        static const char* const nameList[] = {  "Vertices", "Vertices dynamic", "Indices", "Indices dynamic", "Textures", "Textures dynamic", "Effects" };

        static const CProxyDirect3DDevice9::SResourceMemory* const nowList[] = {    &m_MemStatsNow.d3dMemory.StaticVertexBuffer, &m_MemStatsNow.d3dMemory.DynamicVertexBuffer,
                                                                                    &m_MemStatsNow.d3dMemory.StaticIndexBuffer, &m_MemStatsNow.d3dMemory.DynamicIndexBuffer,
                                                                                    &m_MemStatsNow.d3dMemory.StaticTexture, &m_MemStatsNow.d3dMemory.DynamicTexture,
                                                                                    &m_MemStatsNow.d3dMemory.Effect };

        static const CProxyDirect3DDevice9::SResourceMemory* const deltaList[] = {  &m_MemStatsDelta.d3dMemory.StaticVertexBuffer, &m_MemStatsDelta.d3dMemory.DynamicVertexBuffer,
                                                                                    &m_MemStatsDelta.d3dMemory.StaticIndexBuffer, &m_MemStatsDelta.d3dMemory.DynamicIndexBuffer,
                                                                                    &m_MemStatsDelta.d3dMemory.StaticTexture, &m_MemStatsDelta.d3dMemory.DynamicTexture,
                                                                                    &m_MemStatsDelta.d3dMemory.Effect };

        m_TableList.push_back ( CDxTable ( "|" ) );
        CDxTable& table = m_TableList.back ();
        table.SetColumnWidths( "100,45:R,40:R,40:R,50:R,60:R" );
        table.SetNumberColors ( "^1", strNumberColorsLockStatic );
        table.SetNumberColors ( "^2", strNumberColorsLockDynamic );
        table.SetNumberColors ( "^3", strNumberColorsCreat );
        table.SetNumberColors ( "^4", strNumberColorsDstry );
        table.AddRow ( HEADER1( "GTA vid memory" ) "|" HEADER1( "Lock" ) "|" HEADER1( "Creat" ) BLUE "|" HEADER1( "Dstry" ) "|" HEADER1( "Count" ) "|" HEADER1( "Using KB" ) );
        for ( uint i = 0 ; i < NUMELMS( nameList ) ; i++ )
        {
            if ( i & 1 )
                table.AddRow( SString ( "%s|^2~ %d|^3~.%d|^4~.%d|%d|%s"
                                            ,nameList[i]
                                            ,deltaList[i]->iLockedCount
                                            ,deltaList[i]->iCreatedCount
                                            ,deltaList[i]->iDestroyedCount
                                            ,nowList[i]->iCurrentCount
                                            ,*FormatNumberWithCommas ( nowList[i]->iCurrentBytes / 1024  )
                                      ) );
            else
                table.AddRow( SString ( "%s|^1~ %d|^3~.%d|^4~.%d|%d|%s"
                                            ,nameList[i]
                                            ,deltaList[i]->iLockedCount
                                            ,deltaList[i]->iCreatedCount
                                            ,deltaList[i]->iDestroyedCount
                                            ,nowList[i]->iCurrentCount
                                            ,*FormatNumberWithCommas ( nowList[i]->iCurrentBytes / 1024  )
                                      ) );
        }
    }

    {
/*
    MTA videoMemory           ChangeKB        TotalKB
    FreeForMTA                  -100            1000
    UsedByFonts                 -100            1000
    UsedByTextures              -100            1000
    UsedByRenderTargets         -100            1000
*/
        m_TableList.push_back ( CDxTable ( "|" ) );
        CDxTable& table = m_TableList.back ();
        table.SetColumnWidths( "110,80:R,80:R" );
        table.SetNumberColors ( "^1", strNumberColorsMtaVidMem );
        table.AddRow ( HEADER1( "MTA vid memory" ) "|" HEADER1( "Change KB" ) "|" HEADER1( "Using KB" ) );
        table.AddRow ( SString ( "FreeForMTA|^1~.%s|%s", *FormatNumberWithCommas ( m_MemStatsDelta.dxStatus.videoMemoryKB.iFreeForMTA ), *FormatNumberWithCommas ( m_MemStatsNow.dxStatus.videoMemoryKB.iFreeForMTA ) ) );
        table.AddRow ( SString ( "Fonts|^1~.%s|%s", *FormatNumberWithCommas ( m_MemStatsDelta.dxStatus.videoMemoryKB.iUsedByFonts ), *FormatNumberWithCommas ( m_MemStatsNow.dxStatus.videoMemoryKB.iUsedByFonts ) ) );
        table.AddRow ( SString ( "Textures|^1~.%s|%s", *FormatNumberWithCommas ( m_MemStatsDelta.dxStatus.videoMemoryKB.iUsedByTextures ), *FormatNumberWithCommas ( m_MemStatsNow.dxStatus.videoMemoryKB.iUsedByTextures ) ) );
        table.AddRow ( SString ( "RenderTargets|^1~.%s|%s", *FormatNumberWithCommas ( m_MemStatsDelta.dxStatus.videoMemoryKB.iUsedByRenderTargets ), *FormatNumberWithCommas ( m_MemStatsNow.dxStatus.videoMemoryKB.iUsedByRenderTargets ) ) );
    }

    {
/*
    GTA memory                ChangeKB        TotalKB
    iProcessMemSizeKB            -100            1000
    streamMemSizeKB             -100            1000
*/
        m_TableList.push_back ( CDxTable ( "|" ) );
        CDxTable& table = m_TableList.back ();
        table.SetColumnWidths( "110,30:R,50:R,80:R" );
        table.SetNumberColors ( "^1", strNumberColorsMtaVidMem );
        table.AddRow ( HEADER1( "GTA memory" ) "| |" HEADER1( "Change KB" ) "|" HEADER1( "Using KB" ) );
        table.AddRow ( SString ( "Process memory| | |%s", *FormatNumberWithCommas ( m_MemStatsNow.iProcessMemSizeKB - m_MemStatsNow.iStreamingMemoryUsed / 1024 ) ) );
        table.AddRow ( SString ( "Streaming memory| |^1~.%s|%s", *FormatNumberWithCommas ( m_MemStatsDelta.iStreamingMemoryUsed / 1024 ), *FormatNumberWithCommas ( m_MemStatsNow.iStreamingMemoryUsed / 1024 ) ) );
        table.AddRow ( SString ( "|Total:|^1~.%s|%s", *FormatNumberWithCommas ( m_MemStatsDelta.iProcessMemSizeKB ), *FormatNumberWithCommas ( m_MemStatsNow.iProcessMemSizeKB ) ) );
    }

    {
/*
    Settings                                AmountKB
    videoCardInstalledMemoryKB                 2000
    streamMemSettingKB                         2000
*/
        m_TableList.push_back ( CDxTable ( "|" ) );
        CDxTable& table = m_TableList.back ();
        table.SetColumnWidths( "140,130:R" );
        table.AddRow ( HEADER1( "GTA settings" ) "|" HEADER1( "Setting KB" ) );
        table.AddRow ( SString ( "Video card installed memory|%s", *FormatNumberWithCommas ( m_MemStatsNow.dxStatus.videoCard.iInstalledMemoryKB ) ) );
        table.AddRow ( SString ( "Streaming memory limit|%s", *FormatNumberWithCommas ( m_MemStatsNow.iStreamingMemoryAvailable / 1024 ) ) );
        table.AddRow ( SString ( "Process memory limit|%s", *FormatNumberWithCommas ( m_MemStatsNow.iProcessTotalVirtualKB ) ) );
    }

    {
/*
    RW resources            Change    Count
    Textures                            0
    Rasters                             0
    Geometries                          0
*/
        m_TableList.push_back ( CDxTable ( "|" ) );
        CDxTable& table = m_TableList.back ();
        table.SetColumnWidths( "140,50:R,60:R" );
        table.SetNumberColors ( "^1", strNumberColorsModels );
        table.AddRow ( HEADER1( "RW resources" ) "|" HEADER1( "Change" ) "|" HEADER1( "Count" ) );
        table.AddRow ( SString ( "Textures|^1~.%d|%d", m_MemStatsDelta.rwResourceStats.uiTextures, m_MemStatsNow.rwResourceStats.uiTextures ) );
        table.AddRow ( SString ( "Rasters|^1~.%d|%d", m_MemStatsDelta.rwResourceStats.uiRasters, m_MemStatsNow.rwResourceStats.uiRasters ) );
        table.AddRow ( SString ( "Geometries|^1~.%d|%d", m_MemStatsDelta.rwResourceStats.uiGeometries, m_MemStatsNow.rwResourceStats.uiGeometries ) );
    }

    {
/*
    Clothes cache           Change    Count
    Cache hit                           0
    Cache miss                          0
    Clothes in use                      0
    Clothes ready for use               0
    Old removed                         0
*/
        m_TableList.push_back ( CDxTable ( "|" ) );
        CDxTable& table = m_TableList.back ();
        table.SetColumnWidths( "140,50:R,60:R" );
        table.SetNumberColors ( "^0", strNumberColorsWhite );
        table.SetNumberColors ( "^1", strNumberColorsModels );
        table.SetNumberColors ( "^3", strNumberColorsCreat );
        table.SetNumberColors ( "^4", strNumberColorsLockStatic );
        table.SetNumberColors ( "^5", strNumberColorsGrey );
        table.AddRow ( HEADER1( "Clothes cache" ) "|" HEADER1( "Change" ) "|" HEADER1( "Count" ) );
        table.AddRow ( SString ( "Cache hit|^3~ %d|^5~.%d", m_MemStatsDelta.clothesCacheStats.uiCacheHit, m_MemStatsNow.clothesCacheStats.uiCacheHit ) );
        table.AddRow ( SString ( "Cache miss|^4~ %d|^5~.%d", m_MemStatsDelta.clothesCacheStats.uiCacheMiss, m_MemStatsNow.clothesCacheStats.uiCacheMiss ) );
        table.AddRow ( SString ( "Clothes in use|^1~.%d|^0%d", m_MemStatsDelta.clothesCacheStats.uiNumTotal - m_MemStatsDelta.clothesCacheStats.uiNumUnused, m_MemStatsNow.clothesCacheStats.uiNumTotal - m_MemStatsNow.clothesCacheStats.uiNumUnused ) );
        table.AddRow ( SString ( "Clothes ready for use|^1~.%d|%d", m_MemStatsDelta.clothesCacheStats.uiNumUnused, m_MemStatsNow.clothesCacheStats.uiNumUnused ) );
        table.AddRow ( SString ( "Old removed|^1~.%d|^5%d", m_MemStatsDelta.clothesCacheStats.uiNumRemoved, m_MemStatsNow.clothesCacheStats.uiNumRemoved ) );
    }

    {
        m_TableList.push_back ( CDxTable ( "|" ) );
        CDxTable& table = m_TableList.back ();
        table.SetColumnWidths( "110,50:R,60:R,60:R" );
        table.SetNumberColors ( "^0", strNumberColorsWhite );
        table.SetNumberColors ( "^1", strNumberColorsModels );
        table.SetNumberColors ( "^3", strNumberColorsCreat );
        table.SetNumberColors ( "^4", strNumberColorsLockStatic );
        table.SetNumberColors ( "^5", strNumberColorsGrey );
        table.AddRow ( HEADER1( "Model cache" ) "|" HEADER1( "Max" ) "|" HEADER1( "Change" ) "|" HEADER1( "Count" ) );
        table.AddRow ( SString ( "Players|^3~ %d|^5~.%d|^1~.%d", m_MemStatsNow.modelCacheStats.uiMaxNumPedModels, m_MemStatsDelta.modelCacheStats.uiNumPedModels, m_MemStatsNow.modelCacheStats.uiNumPedModels ) );
        table.AddRow ( SString ( "Vehicles|^3~ %d|^5~.%d|^1~.%d", m_MemStatsNow.modelCacheStats.uiMaxNumVehicleModels, m_MemStatsDelta.modelCacheStats.uiNumVehicleModels, m_MemStatsNow.modelCacheStats.uiNumVehicleModels ) );
    }


    {
/*
    Model usage                 Change   Amount
    0-288           Players         1       10
    289-399         Other1          1       10
    400-611         Vehicles        1       10
    612-999         Other2          1       10
    1000-1193       Upgrades        1       10
    1194-19999      Other3          1       10
    20000-24999     Textures        1       10
    24999-27000     Other4          1       10
                    Total           1       10
*/
        m_TableList.push_back ( CDxTable ( "|" ) );
        CDxTable& table = m_TableList.back ();
        table.SetColumnWidths( "90,50,50:R,60:R" );
        table.SetNumberColors ( "^1", strNumberColorsModels );
        table.AddRow ( HEADER1( "Models in memory" ) "| |" HEADER1( "Change" ) "|" HEADER1( "Count" ) );
        table.AddRow ( SString ( "0-312|(Players)|^1~.%d|%d", m_MemStatsDelta.modelInfo.uiPlayerModels_0_312, m_MemStatsNow.modelInfo.uiPlayerModels_0_312 ) );
        table.AddRow ( SString ( "313-317| |^1~.%d|%d", m_MemStatsDelta.modelInfo.uiUnknown_313_317, m_MemStatsNow.modelInfo.uiUnknown_313_317 ) );
        table.AddRow ( SString ( "318-372|(Weapons)|^1~.%d|%d", m_MemStatsDelta.modelInfo.uiWeaponModels_318_372, m_MemStatsNow.modelInfo.uiWeaponModels_318_372 ) );
        table.AddRow ( SString ( "373-399| |^1~.%d|%d", m_MemStatsDelta.modelInfo.uiUnknown_373_399, m_MemStatsNow.modelInfo.uiUnknown_373_399 ) );
        table.AddRow ( SString ( "400-611|(Vehicles)|^1~.%d|%d", m_MemStatsDelta.modelInfo.uiVehicles_400_611, m_MemStatsNow.modelInfo.uiVehicles_400_611 ) );
        table.AddRow ( SString ( "612-999| |^1~.%d|%d", m_MemStatsDelta.modelInfo.uiUnknown_612_999, m_MemStatsNow.modelInfo.uiUnknown_612_999 ) );
        table.AddRow ( SString ( "1000-1193|(Upgrades)|^1~.%d|%d", m_MemStatsDelta.modelInfo.uiUpgrades_1000_1193, m_MemStatsNow.modelInfo.uiUpgrades_1000_1193 ) );
        table.AddRow ( SString ( "1194-19999|(World)|^1~.%d|%d", m_MemStatsDelta.modelInfo.uiUnknown_1194_19999, m_MemStatsNow.modelInfo.uiUnknown_1194_19999 ) );
        table.AddRow ( SString ( "20000-24999|(Textures)|^1~.%d|%d", m_MemStatsDelta.modelInfo.uiTextures_20000_24999, m_MemStatsNow.modelInfo.uiTextures_20000_24999 ) );
        table.AddRow ( SString ( "25000-25254|(Collisions)|^1~.%d|%d", m_MemStatsDelta.modelInfo.uiCollisions_25000_25254, m_MemStatsNow.modelInfo.uiCollisions_25000_25254 ) );
        table.AddRow ( SString ( "25255-25510|(Ipls)|^1~.%d|%d", m_MemStatsDelta.modelInfo.uiIpls_25255_25510, m_MemStatsNow.modelInfo.uiIpls_25255_25510 ) );
        table.AddRow ( SString ( "25511-25574|(Paths)|^1~.%d|%d", m_MemStatsDelta.modelInfo.uiPaths_25511_25574, m_MemStatsNow.modelInfo.uiPaths_25511_25574 ) );
        table.AddRow ( SString ( "25575-25754|(Anims)|^1~.%d|%d", m_MemStatsDelta.modelInfo.uiAnims_25575_25754, m_MemStatsNow.modelInfo.uiAnims_25575_25754 ) );
        table.AddRow ( SString ( "|Total:|^1~.%d|%d", m_MemStatsDelta.modelInfo.uiTotal, m_MemStatsNow.modelInfo.uiTotal ) );
    }

    {
/*
    World shader replacements       Change    Count
    World texture draws                         0
    World shader draws                          0
    World texture total                         0             
    World shader total                          0             
    Entites explicitly shadered                 0    
*/
        m_TableList.push_back ( CDxTable ( "|" ) );
        CDxTable& table = m_TableList.back ();
        table.SetColumnWidths( "160,50:R,60:R" );
        table.AddRow ( HEADER1( "World shader replacements" ) "|" HEADER1( "Change" ) "|" HEADER1( "Count" ) );
        table.AddRow ( SString ( "World texture draws|^1~ %d|%d", m_MemStatsDelta.shaderReplacementStats.uiNumReplacementRequests, m_MemStatsNow.shaderReplacementStats.uiNumReplacementRequests ) );
        table.AddRow ( SString ( "World shader draws|^1~ %d|%d", m_MemStatsDelta.shaderReplacementStats.uiNumReplacementMatches, m_MemStatsNow.shaderReplacementStats.uiNumReplacementMatches ) );
        table.AddRow ( SString ( "World shader full setup|^1~ %d|%d", m_MemStatsDelta.frameStats.iNumShadersFullSetup, m_MemStatsNow.frameStats.iNumShadersFullSetup ) );
        table.AddRow ( SString ( "World shader reuse setup|^1~ %d|%d", m_MemStatsDelta.frameStats.iNumShadersReuseSetup, m_MemStatsNow.frameStats.iNumShadersReuseSetup ) );
        table.AddRow ( SString ( "World texture total|^1~ %d|%d", m_MemStatsDelta.shaderReplacementStats.uiTotalTextures, m_MemStatsNow.shaderReplacementStats.uiTotalTextures ) );
        table.AddRow ( SString ( "World shader total|^1~ %d|%d", m_MemStatsDelta.shaderReplacementStats.uiTotalShaders, m_MemStatsNow.shaderReplacementStats.uiTotalShaders ) );
        table.AddRow ( SString ( "Known entities|^1~ %d|%d", m_MemStatsDelta.shaderReplacementStats.uiTotalEntitesRefed, m_MemStatsNow.shaderReplacementStats.uiTotalEntitesRefed ) );
    }

    {
/*
    World shader channels       NumTex     Shader+Entites
    *blah                       .   0          .   0
*/
        SShaderReplacementStats& now   = m_MemStatsNow.shaderReplacementStats;
        SShaderReplacementStats& delta = m_MemStatsDelta.shaderReplacementStats;

        m_TableList.push_back ( CDxTable ( "|" ) );
        CDxTable& table = m_TableList.back ();
        table.SetNumberColors ( "^1", strNumberColorsModels );
        table.SetColumnWidths( "180,40:R,35:R,40:R,35:R" );
        table.AddRow ( HEADER1( "World shader channels" ) "|" HEADER1( " " ) "|" HEADER1( "NumTex" ) "|" HEADER1( " " ) "|" HEADER1( "Shad&Ent" ) );
        for ( std::map < uint, SMatchChannelStats >::iterator iter = now.channelStatsList.begin () ; iter != now.channelStatsList.end () ; ++iter )
        {
            uint uiId = iter->first;
            const SMatchChannelStats& channelStatsNow = iter->second;
            SMatchChannelStats* pChannelStatsDelta = MapFind ( delta.channelStatsList, uiId );
            assert ( pChannelStatsDelta );
            table.AddRow( SString ( "%s|^1~.%d|%d|^1~.%d|%d"
                                        ,*channelStatsNow.strTag
                                        ,pChannelStatsDelta->uiNumMatchedTextures
                                        ,channelStatsNow.uiNumMatchedTextures
                                        ,pChannelStatsDelta->uiNumShaderAndEntities
                                        ,channelStatsNow.uiNumShaderAndEntities
                                  ) );
        }
    }

    {
/*
    Pool sizes       Capacity   Used
    NAME                100       10   10%
*/
        m_TableList.push_back ( CDxTable ( "|" ) );
        CDxTable& table = m_TableList.back ();
        table.SetColumnWidths( "170,50:R,50:R,40:R" );
        table.SetNumberColors ( "^1", strNumberColorsModels );
        table.AddRow ( HEADER1( "Pool sizes" ) "|" HEADER1( "Capacity" ) "|" HEADER1( "Used" ) "|" HEADER1( "" ) );
        for ( int i = 0; i < MAX_POOLS ; i++ )
        {
            SString strName = EnumToString( (ePools)i );
            int iDefCapacity = g_pCore->GetGame()->GetPools()->GetPoolDefaultCapacity ( (ePools)i );
            int iCapacity = g_pCore->GetGame()->GetPools()->GetPoolCapacity ( (ePools)i );
            int iUsedSpaces = g_pCore->GetGame()->GetPools()->GetNumberOfUsedSpaces ( (ePools)i );
            int iUsedPercent = iUsedSpaces * 100 / iCapacity;
            table.AddRow ( SString ( "%s|%d|%d|%d%%", *strName, iCapacity, iUsedSpaces, iUsedPercent ) );
        }
    }
}
コード例 #30
0
///////////////////////////////////////////////////////////////
//
// CPerfStatPacketUsageImpl::GetStats
//
//
//
///////////////////////////////////////////////////////////////
void CPerfStatPacketUsageImpl::GetStats ( CPerfStatResult* pResult, const std::map < SString, int >& strOptionMap, const SString& strFilter )
{
    //
    // Set option flags
    //
    bool bHelp = MapContains ( strOptionMap, "h" );

    //
    // Process help
    //
    if ( bHelp )
    {
        pResult->AddColumn ( "Packet usage help" );
        pResult->AddRow ()[0] ="Option h - This help";
        return;
    }

    // Add columns
    pResult->AddColumn ( "Packet type" );
    pResult->AddColumn ( "Incoming.pkt/sec" );
    pResult->AddColumn ( "Incoming.bytes/sec" );
    pResult->AddColumn ( "Incoming.cpu" );
    pResult->AddColumn ( "Outgoing.pkt/sec" );
    pResult->AddColumn ( "Outgoing.bytes/sec" );
    pResult->AddColumn ( "Outgoing.cpu" );

    // Fill rows
    for ( uint i = 0 ; i < 256 ; i++ )
    {
        // Calc incoming delta values
        SPacketStat statInDelta;
        {
            const SPacketStat& statInPrev = m_PrevPacketStats [ CNetServer::STATS_INCOMING_TRAFFIC ] [ i ];
            const SPacketStat& statInNow = m_PacketStats [ CNetServer::STATS_INCOMING_TRAFFIC ] [ i ];
            statInDelta.iCount      = statInNow.iCount - statInPrev.iCount;
            statInDelta.iTotalBytes = statInNow.iTotalBytes - statInPrev.iTotalBytes;
            statInDelta.totalTime   = statInNow.totalTime - statInPrev.totalTime;
        }

        // Calc outgoing delta values
        SPacketStat statOutDelta;
        {
            const SPacketStat& statOutPrev = m_PrevPacketStats [ CNetServer::STATS_OUTGOING_TRAFFIC ] [ i ];
            const SPacketStat& statOutNow = m_PacketStats [ CNetServer::STATS_OUTGOING_TRAFFIC ] [ i ];
            statOutDelta.iCount      = statOutNow.iCount - statOutPrev.iCount;
            statOutDelta.iTotalBytes = statOutNow.iTotalBytes - statOutPrev.iTotalBytes;
            statOutDelta.totalTime   = statOutNow.totalTime - statOutPrev.totalTime;
        }

        if ( !statInDelta.iCount && !statOutDelta.iCount )
            continue;

        // Add row
        SString* row = pResult->AddRow ();

        int c = 0;
        // Turn "PACKET_ID_PED_SYNC" into "64_Ped_sync"
        SString strPacketDesc = EnumToString ( (ePacketID)i ).SplitRight ( "PACKET_ID", NULL, -1 ).ToLower ();
        row[c++] = SString ( "%d", i ) + strPacketDesc.Left ( 2 ).ToUpper () + strPacketDesc.SubStr ( 2 );
        if ( statInDelta.iCount )
        {
            row[c++] = SString ( "%d", statInDelta.iCount / 5 );
            row[c++] = SString ( "%d", statInDelta.iTotalBytes / 5 );
            row[c++] = SString ( "%2.2f%%", statInDelta.totalTime / 50000.f );   // Number of microseconds in sample period ( 5sec * 1000000 ) into percent ( * 100 )
        }
        else
        {
            row[c++] = "-";
            row[c++] = "-";
            row[c++] = "-";
        }

        if ( statOutDelta.iCount )
        {
            row[c++] = SString ( "%d", statOutDelta.iCount / 5 );
            row[c++] = SString ( "%d", statOutDelta.iTotalBytes / 5 );
            //row[c++] = SString ( "%2.2f%%", statOutDelta.totalTime / 50000.f );
            row[c++] = "n/a";
        }
        else
        {
            row[c++] = "-";
            row[c++] = "-";
            row[c++] = "-";
        }
    }
}