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


C++ IBattle类代码示例

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


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

示例1: while

void IServer::Reset()
{
    m_users.Nullify();
    while (m_users.GetNumUsers() > 0) {
        try {
            User* u = &m_users.GetUser(0);
            m_users.RemoveUser(u->GetNick());
            delete u;
        } catch (std::runtime_error) {
        }
    }

    while (battles_iter->GetNumBattles() > 0) {
        battles_iter->IteratorBegin();
        IBattle* b = battles_iter->GetBattle();
        if (b != 0) {
            m_battles.RemoveBattle(b->GetBattleId());
            delete b;
        }
    }
    while (m_channels.GetNumChannels() > 0) {
        Channel* c = &m_channels.GetChannel(0);
        m_channels.RemoveChannel(c->GetName());
        delete c;
    }
}
开发者ID:apoleon,项目名称:springlobby,代码行数:26,代码来源:iserver.cpp

示例2: slLogDebugFunc

void ServerEvents::OnUserQuit(const std::string& nick)
{
	slLogDebugFunc("");
	try {
		User& user = m_serv.GetUser(nick);
		IBattle* 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, TowxString(nick)))
			actNotifBox(SL_MAIN_ICON, TowxString(nick) + _(" just went offline"));
	} catch (std::runtime_error& except) {
	}
}
开发者ID:OursDesCavernes,项目名称:springlobby,代码行数:27,代码来源:serverevents.cpp

示例3: wxLogWarning

void BattleListTab::OnHost( wxCommandEvent& /*unused*/ )
{
	if ( !ui().IsConnected() )
	{
		wxLogWarning( _T( "Trying to host while offline" ) );
		customMessageBoxNoModal( SL_MAIN_ICON, _( "You cannot host a game while being offline. Please connect to a lobby server." ), _( "Not Online." ), wxOK );
		ui().ShowConnectWindow();
		return;
	}

	IBattle* battle = ui().mw().GetJoinTab().GetCurrentBattle();
	if ( battle != 0 )
	{
		if ( ui().Ask( _( "Already in a battle" ), _( "You are already in a battle.\n\nDo you want to leave current battle to start a new?" ) ) ) {
			battle->Leave();
			ui().mw().GetJoinTab().LeaveCurrentBattle();
		}
		else
		{
			return;
		}
	}

	SL::RunHostBattleDialog( this );
}
开发者ID:jgleesawn,项目名称:springlobby,代码行数:25,代码来源:battlelisttab.cpp

示例4: AddBattle

void BattleListTab::AddBattle(IBattle& battle)
{
	if (battle.GetGUIListActiv() || (m_filter->GetActiv() && !m_filter->FilterBattle(battle))) {
		return;
	}
	m_battle_list->AddBattle(battle);
	battle.SetGUIListActiv(true);
	SetNumDisplayed();
}
开发者ID:spike-spb,项目名称:springlobby,代码行数:9,代码来源:battlelisttab.cpp

示例5: OnForceJoinBattle

void ServerEvents::OnForceJoinBattle(int battleid, const std::string& scriptPW)
{
	IBattle* battle = m_serv.GetCurrentBattle();
	if (battle != NULL) {
		m_serv.LeaveBattle(battle->GetID());
	}
	m_serv.JoinBattle(battleid, scriptPW);
	UiEvents::GetStatusEventSender(UiEvents::addStatusMessage).SendEvent(
	    UiEvents::StatusData(_("Automatically moved to new battle"), 1));
}
开发者ID:OursDesCavernes,项目名称:springlobby,代码行数:10,代码来源:serverevents.cpp

示例6: WhatContentForBattleIsRequired

ContentDownloadRequest ContentManager::WhatContentForBattleIsRequired(
		const IBattle& battle) {

	ContentDownloadRequest contentNeeded = ContentDownloadRequest();

	const std::string engineVersion = battle.GetBattleOptions().engineVersion;
	const std::string engineName = battle.GetBattleOptions().engineName;

	/*Engine is needed*/
	if (IsHavingSpringVersion(engineName, engineVersion) == false) {
		contentNeeded.EngineRequired(engineVersion);
	}

	/*Map is needed*/
	if (battle.MapExists() == false) {
		contentNeeded.MapRequired(battle.GetHostMapName(), battle.GetHostMapHash());
	}

	/*Game is needed*/
	if (battle.GameExists() == false) {
		contentNeeded.GameRequired(battle.GetHostGameName(), battle.GetHostGameHash());
	}

	return contentNeeded;
}
开发者ID:,项目名称:,代码行数:25,代码来源:

示例7: AutoCheckCommandSpam

void ServerEvents::AutoCheckCommandSpam(IBattle& battle, User& user)
{
	const std::string nick = user.GetNick();
	MessageSpamCheck info = m_spam_check[nick];
	time_t now = time(0);
	if (info.lastmessage == now)
		info.count++;
	else
		info.count = 0;
	info.lastmessage = now;
	m_spam_check[nick] = info;
	if (info.count == 7) {
		battle.DoAction("is autokicking " + nick + " due to command spam.");
		battle.KickPlayer(user);
	}
}
开发者ID:OursDesCavernes,项目名称:springlobby,代码行数:16,代码来源:serverevents.cpp

示例8: wxLogDebugFunc

void MapSelectDialog::LoadPopular()
{
	wxLogDebugFunc( wxEmptyString );

	m_mapgrid->Clear();

	try {
		serverSelector().GetServer().battles_iter->IteratorBegin();
		while ( !serverSelector().GetServer().battles_iter->EOL() ) {
			IBattle* b = serverSelector().GetServer().battles_iter->GetBattle();
			const std::string mapname = b->GetHostMapName();
			assert(!mapname.empty());
			if ( b != NULL ) m_mapgrid->AddMap(TowxString(mapname));
		}
	}
	catch (...) {} // ui().GetServer may throw when disconnected...

	m_mapgrid->Refresh();
}
开发者ID:renemilk,项目名称:springlobby,代码行数:19,代码来源:mapselectdialog.cpp

示例9: RemoveBattle

void BattleListTab::RemoveBattle(IBattle& battle)
{
	if (&battle == m_sel_battle) {
		SelectBattle(0);
	}

	m_battle_list->RemoveBattle(battle);

	battle.SetGUIListActiv(false);
	SetNumDisplayed();
}
开发者ID:spike-spb,项目名称:springlobby,代码行数:11,代码来源:battlelisttab.cpp

示例10: Run

bool Spring::Run( IBattle& battle )
{
	std::string executable = SlPaths::GetSpringBinary(battle.GetEngineVersion());
	if ( !wxFile::Exists(TowxString(executable)) ) {
		executable = SlPaths::GetSpringBinary(SlPaths::GetCompatibleVersion(battle.GetEngineVersion())); //fallback, no exact version found, try fallback version
		if ( !wxFile::Exists(TowxString(executable)) ) {
			customMessageBoxNoModal( SL_MAIN_ICON, wxFormat(_T("The spring executable version '%s' was not found at the set location '%s', please re-check.")) % battle.GetEngineVersion() % executable, _T("Executable not found") );
			ui().mw().ShowConfigure( MainWindow::OPT_PAGE_SPRING );
			return false;
		}
	}

	wxArrayString params;

	const std::string demopath = battle.GetPlayBackFilePath();
	if (!demopath.empty()){
		params.push_back(TowxString(demopath));
		return LaunchEngine(executable, params);
	}

	const wxString scripttxt = TowxString(SlPaths::GetLobbyWriteDir()) + _T("script.txt");
	try {

		wxFile f( scripttxt, wxFile::write );
		battle.DisableHostStatusInProxyMode( true );
		f.Write( WriteScriptTxt(battle) );
		battle.DisableHostStatusInProxyMode( false );
		f.Close();
	} catch ( std::exception& e ) {
		wxLogError( wxString::Format( _T("Couldn't write %s, exception caught:\n %s"), scripttxt.c_str(), TowxString( e.what() ).c_str() ) );
		return false;
	} catch (...) {
		wxLogError( wxString::Format( _T("Couldn't write %s"), scripttxt.c_str()));
		return false;
	}

	params.push_back(scripttxt);
	return LaunchEngine(executable, params);
}
开发者ID:jgleesawn,项目名称:springlobby,代码行数:39,代码来源:spring.cpp

示例11: UpdateBattle

void BattleListTab::UpdateBattle( IBattle& battle )
{
	if ( !battle.GetGUIListActiv() ) {
		AddBattle( battle );
		return;
	}
	if ( m_filter->GetActiv() && !m_filter->FilterBattle( battle ) ) {
		RemoveBattle( battle );
		return;
	}
	m_battle_list->UpdateBattle( battle );
	if ( &battle == m_sel_battle )
		SelectBattle( m_sel_battle );
}
开发者ID:jgleesawn,项目名称:springlobby,代码行数:14,代码来源:battlelisttab.cpp

示例12: GetBattleStatusIcon

int IconImageList::GetBattleStatusIcon( const IBattle& battle ) const
{
    unsigned idx = battle.GetInGame() << 3 | battle.IsLocked() << 2 | battle.IsFull() << 1 | battle.IsPassworded() << 0;
    static const int icons[16] = {
        /* -                                 */ ICON_OPEN_GAME,
        /* passworded                        */ ICON_OPEN_PW_GAME,
        /* full                              */ ICON_OPEN_FULL_GAME,
        /* full, passworded                  */ ICON_OPEN_FULL_PW_GAME,
        /* locked                            */ ICON_CLOSED_GAME,
        /* locked, passworded                */ ICON_CLOSED_PW_GAME,
        /* locked, full                      */ ICON_CLOSED_FULL_GAME,
        /* locked, full, passworded          */ ICON_CLOSED_FULL_PW_GAME,
        /* in game                           */ ICON_STARTED_GAME,
        /* in game, passworded               */ ICON_STARTED_GAME,
        /* in game, full                     */ ICON_STARTED_GAME,
        /* in game, full, passworded         */ ICON_STARTED_GAME,
        /* in game, locked                   */ ICON_STARTED_GAME_LOCKED,
        /* in game, locked, passworded       */ ICON_STARTED_GAME_LOCKED,
        /* in game, locked, full             */ ICON_STARTED_GAME_LOCKED,
        /* in game, locked, full, passworded */ ICON_STARTED_GAME_LOCKED,
    };
    return icons[idx];
    // return ICON_GAME_UNKNOWN;
}
开发者ID:renemilk,项目名称:springlobby,代码行数:24,代码来源:iconimagelist.cpp

示例13: GetBattleStatus

wxString IconImageList::GetBattleStatus( const IBattle& battle ) const
{
    unsigned idx = battle.GetInGame() << 3 | battle.IsLocked() << 2 | battle.IsFull() << 1 | battle.IsPassworded() << 0;
    static const wxString states[16] = {
        /* -                                 */ _("Game is open."),
        /* passworded                        */ _("Game is password-protected."),
        /* full                              */ _("Game is full."),
        /* full, passworded                  */ _("Game is full and password-protected."),
        /* locked                            */ _("Game is closed."),
        /* locked, passworded                */ _("Game is closed and password-protected."),
        /* locked, full                      */ _("Game is closed and full."),
        /* locked, full, passworded          */ _("Game is closed, full and password-protected."),
        /* in game                           */ _("Game is in progress."),
        /* in game, passworded               */ _("Game is in progress and password-protected."),
        /* in game, full                     */ _("Game is in progress and full."),
        /* in game, full, passworded         */ _("Game is in progress, full and password-protected."),
        /* in game, locked                   */ _("Game is in progress and closed."),
        /* in game, locked, passworded       */ _("Game is in progress, closed and password-protected."),
        /* in game, locked, full             */ _("Game is in progress, closed and full."),
        /* in game, locked, full, passworded */ _("Game is in progress, closed, full and password-protected."),
    };
    return states[idx];
    // return _T("Game has unknown status");
}
开发者ID:renemilk,项目名称:springlobby,代码行数:24,代码来源:iconimagelist.cpp

示例14: UpdateBattle

void BattleListTab::UpdateBattle(IBattle& battle)
{
	if (!battle.GetGUIListActiv()) {
		AddBattle(battle);
	}
	if (m_filter->GetActiv() && !m_filter->FilterBattle(battle)) {
		RemoveBattle(battle);
		if (&battle == m_sel_battle) {
			m_sel_battle = NULL;
			SelectBattle(NULL);
			m_battle_list->SetSelectedIndex(-1);
		}
		return;
	}
	m_battle_list->UpdateBattle(battle);
	if (&battle == m_sel_battle)
		SelectBattle(m_sel_battle);
}
开发者ID:spike-spb,项目名称:springlobby,代码行数:18,代码来源:battlelisttab.cpp

示例15: ui

void BattleListTab::DoJoin(IBattle& battle)
{
	wxString password = wxEmptyString;

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

	if (curbattle != 0 && curbattle->GetID() == battle.GetID()) {
		ui().mw().ShowTab(MainWindow::PAGE_JOIN);
		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;
		}
	}

	if (battle.IsPassworded()) {
		wxPasswordEntryDialog pw(this, _("Battle password"), _("Enter password (spaces will be stripped)"));
		pw.SetFocus();
		if (pw.ShowModal() != wxID_OK) {
			return;
		}
		password = pw.GetValue();
		password.Replace(_T(" "), wxEmptyString);
	}

	if (!ui().DownloadArchives(battle)) {
		return;
	}

	battle.Join(STD_STRING(password));
}
开发者ID:spike-spb,项目名称:springlobby,代码行数:36,代码来源:battlelisttab.cpp


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