当前位置: 首页>>代码示例>>C++>>正文


C++ Battle::GetID方法代码示例

本文整理汇总了C++中Battle::GetID方法的典型用法代码示例。如果您正苦于以下问题:C++ Battle::GetID方法的具体用法?C++ Battle::GetID怎么用?C++ Battle::GetID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Battle的用法示例。


在下文中一共展示了Battle::GetID方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OnUserQuit

void ServerEvents::OnUserQuit( const wxString& nick )
{
    wxLogDebugFunc( _T("") );
    try
    {
        User &user=m_serv.GetUser( nick );
				Battle* userbattle = user.GetBattle();
				if ( userbattle )
				{
					int battleid = userbattle->GetID();
					try
					{
						if ( &userbattle->GetFounder() == &user )
						{
							for ( int i = 0; i < int(userbattle->GetNumUsers()); i ++ )
							{
								User& battleuser = userbattle->GetUser( i );
								OnUserLeftBattle( battleid, battleuser.GetNick() );
							}
							 OnBattleClosed( battleid );
						}
						else OnUserLeftBattle( battleid, user.GetNick() );
					}catch(...){}
				}
        ui().OnUserOffline( user );
        m_serv._RemoveUser( nick );
        if ( useractions().DoActionOnUser( UserActions::ActNotifLogin, nick ) )
            actNotifBox( SL_MAIN_ICON, nick + _(" just went offline") );
    }
    catch (std::runtime_error &except)
    {
    }
}
开发者ID:mallyvai,项目名称:springlobby,代码行数:33,代码来源:serverevents.cpp

示例2: OnUserQuit

void SimpleServerEvents::OnUserQuit( const wxString& nick )
{
    wxLogDebugFunc( _T("") );
    try
    {
        User &user=m_serv.GetUser( nick );
				Battle* userbattle = user.GetBattle();
				if ( userbattle )
				{
					int battleid = userbattle->GetID();
					try
					{
						if ( &userbattle->GetFounder() == &user )
						{
							for ( int i = 0; i < int(userbattle->GetNumUsers()); i ++ )
							{
								User& battleuser = userbattle->GetUser( i );
								OnUserLeftBattle( battleid, battleuser.GetNick() );
							}
							 OnBattleClosed( battleid );
						}
						else OnUserLeftBattle( battleid, user.GetNick() );
					}catch(...){}
				}
//        ui().OnUserOffline( user );
        m_serv._RemoveUser( nick );
    }
    catch (std::runtime_error &except)
	{ }
}
开发者ID:SpliFF,项目名称:springlobby,代码行数:30,代码来源:simpleserverevents.cpp

示例3: DoJoin

void BattleListTab::DoJoin( Battle& battle )
{
	if ( !ui().IsSpringCompatible() )
	{
		wxLogWarning( _T( "trying to join battles with imcompatible spring version" ) );
		customMessageBox( SL_MAIN_ICON, _( "Joining battles is disabled due to the incompatible spring version you're using." ), _( "Spring error" ), wxICON_EXCLAMATION | wxOK );
		return;
	}

	Battle* curbattle = ui().mw().GetJoinTab().GetCurrentBattle();

	if ( curbattle != 0 && curbattle->GetID() == battle.GetID() )
	{
		if ( ui().Ask( _( "Already in this battle" ), _( "You are already in this battle.\n\nDo you want to leave it?" ) ) )
		{
			curbattle->Leave();
			ui().mw().GetJoinTab().LeaveCurrentBattle();
			return;
		}
		else
		{
			return;
		}
	}

	if ( curbattle != 0 )
	{
		if ( ui().Ask( _( "Already in another battle" ), _( "You are already in a battle.\n\nDo you want to leave your current battle and join this one?" ) ) ) {
			curbattle->Leave();
			ui().mw().GetJoinTab().LeaveCurrentBattle();
		}
		else
		{
			return;
		}
	}

#ifdef NO_TORRENT_SYSTEM
	wxString downloadProc = _( "Do you want me to take you to the download page?" );
#else
	wxString downloadProc = _( "Should i try to download it for you?\nYou can see the progress in the \"Download Manager\" tab." );
#endif

	if ( !battle.ModExists() )
	{
		if ( customMessageBox( SL_MAIN_ICON, _( "You need to download the game before you can join this game.\n\n" ) + downloadProc, _( "Game not available" ), wxYES_NO | wxICON_QUESTION ) == wxYES ) {
			wxString modhash = battle.GetHostModHash();
			wxString modname = battle.GetHostModName();
			ui().DownloadMod ( modhash, modname );
		}
		return;
	}

	if ( !battle.MapExists() )
	{
		if ( customMessageBox( SL_MAIN_ICON, _( "You need to download the map to be able to play in this game.\n\n" ) + downloadProc, _( "Map not available" ), wxYES_NO | wxICON_QUESTION ) == wxYES ) {
			wxString maphash = battle.GetHostMapHash();
			wxString mapname = battle.GetHostMapName();
			ui().DownloadMap ( maphash, mapname );
		}
	}

	if ( battle.IsPassworded() )
	{
		wxPasswordEntryDialog pw( this, _( "Battle password" ), _( "Enter password (spaces will be stripped)" ) );
		pw.SetFocus();
		if ( pw.ShowModal() == wxID_OK )
		{
			wxString password = pw.GetValue();
			password.Replace(_T(" "), _T(""));
			battle.Join( password );
		}
	}
	else
	{
		battle.Join();
	}
}
开发者ID:hoijui,项目名称:springlobby,代码行数:78,代码来源:battlelisttab.cpp


注:本文中的Battle::GetID方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。