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


C++ IBattle::GetHostMapName方法代码示例

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


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

示例1: 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,代码来源:

示例2: LoadPopular

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

示例3: FilterBattle


//.........这里部分代码省略.........
                if (!bResult)
                    for (unsigned int i = 0; i < battle.GetNumUsers(); ++i) {
                        wxString name = TowxString(battle.GetUser(i).GetNick());
                        if (useractions().DoActionOnUser(UserActions::ActHighlight, name)) {
                            bResult = true;
                            break;
                        }
                    }
            } catch (...) {
            }
        }


        //Battle Status Check
        if (m_filter_status_start->GetValue())
            bResult |= battle.GetInGame();

        if (m_filter_status_locked->GetValue())
            bResult |= battle.IsLocked();

        if (m_filter_status_pass->GetValue())
            bResult |= battle.IsPassworded();

        if (m_filter_status_full->GetValue())
            bResult |= battle.IsFull();

        if (m_filter_status_open->GetValue())
            bResult |= (!battle.IsPassworded() && !battle.IsLocked() && !battle.GetInGame() && !battle.IsFull());

        if (bResult == false)
            return false;
    }

    //Rank Check

    /** @fixme Is `nonsenserank' useful, or can it be removed?  Why is
   * it here in the first place?
   */
    /* `Nonsense', in this context, apparently means that the battle
   * requires rank 100, exactly, AND we're filtering for values less
   * than some number.
   */
    bool nonsenserank = (m_filter_rank_mode == BUTTON_MODE_SMALLER) && (battle.GetRankNeeded() == 100);

    if (m_filter_rank_choice_value != -1 /* don't have "all" selected */
        && !nonsenserank		     /* Nonsensical `nonsenserank' flag isn't set. */
        && !_IntCompare(battle.GetRankNeeded(), m_filter_rank_choice_value, m_filter_rank_mode))
        return false;

    //Player Check
    if ((m_filter_player_choice_value != -1) && !_IntCompare(battle.GetNumUsers() - battle.GetSpectators(), m_filter_player_choice_value, m_filter_player_mode))
        return false;

    //MaxPlayer Check
    if ((m_filter_maxplayer_choice_value != -1) && !_IntCompare(battle.GetMaxPlayers(), m_filter_maxplayer_choice_value, m_filter_maxplayer_mode))
        return false;

    //Spectator Check
    if ((m_filter_spectator_choice_value != -1) && !_IntCompare(battle.GetSpectators(), m_filter_spectator_choice_value, m_filter_spectator_mode))
        return false;

    //Only Maps i have Check
    if (m_filter_map_show->GetValue() && !battle.MapExists())
        return false;

    //Only Mods i have Check
    if (m_filter_mod_show->GetValue() && !battle.GameExists())
        return false;

    //Strings Plain Text & RegEx Check (Case insensitiv)

    //Description:
    if (!StringMatches(TowxString(battle.GetDescription()),
               m_filter_description_edit->GetValue(),
               m_filter_description_expression))
        return false;

    //Host:
    try { //!TODO
        if (!StringMatches(TowxString(battle.GetFounder().GetNick()),
                   m_filter_host_edit->GetValue(),
                   m_filter_host_expression))
            return false;
    } catch (...) {
    }

    //Map:
    if (!StringMatches(TowxString(battle.GetHostMapName()),
               m_filter_map_edit->GetValue(),
               m_filter_map_expression))
        return false;

    //Mod:
    if (!StringMatches(TowxString(battle.GetHostGameName()),
               m_filter_mod_edit->GetValue(),
               m_filter_mod_expression))
        return false;

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

示例4: WriteScriptTxt

wxString Spring::WriteScriptTxt( IBattle& battle ) const
{
    wxLogMessage(_T("0 WriteScriptTxt called "));

    wxString ret;

    TDFWriter tdf(ret);

    // Start generating the script.
    tdf.EnterSection( _T("GAME") );

        tdf.Append( _T("HostIP"), battle.GetHostIp() );
            if ( battle.IsFounderMe() )
            {
                    if ( battle.GetNatType() == NAT_Hole_punching ) tdf.Append( _T("HostPort"), battle.GetMyInternalUdpSourcePort() );
                    else tdf.Append(_T("HostPort"), battle.GetHostPort() );
            }
            else
            {
                    tdf.Append( _T("HostPort"), battle.GetHostPort() );
                    if ( battle.GetNatType() == NAT_Hole_punching )
                    {
                        tdf.Append( _T("SourcePort"), battle.GetMyInternalUdpSourcePort() );
                    }
                    else if ( sett().GetClientPort() != 0)
                    {
                        tdf.Append( _T("SourcePort"), sett().GetClientPort() ); /// this allows to play with broken router by setting SourcePort to some forwarded port.
                    }
            }
            tdf.Append( _T("IsHost"), battle.IsFounderMe() );

            tdf.Append(_T("MyPlayerName"), battle.GetMe().GetNick() );

            if ( !battle.IsFounderMe() )
            {
                    tdf.LeaveSection();
                    return ret;
            }

            /**********************************************************************************
                                                                        Host-only section
            **********************************************************************************/

            tdf.AppendLineBreak();

            tdf.Append(_T("ModHash"), battle.LoadMod().hash );
            tdf.Append(_T("MapHash"), battle.LoadMap().hash );

            tdf.Append( _T("Mapname"), battle.GetHostMapName() );
            tdf.Append( _T("GameType"), battle.GetHostModName() );

            tdf.AppendLineBreak();

            switch ( battle.GetBattleType() )
            {
                case BT_Played: break;
                case BT_Replay:
                {
                    wxString path = battle.GetPlayBackFilePath();
                    if ( path.Find(_T("/")) != wxNOT_FOUND ) path.BeforeLast(_T('/'));
                    tdf.Append( _T("DemoFile"), path );
                    tdf.AppendLineBreak();
                    break;
                }
                case BT_Savegame:
                {
                    wxString path = battle.GetPlayBackFilePath();
                    if ( path.Find(_T("/")) != wxNOT_FOUND ) path.BeforeLast(_T('/'));
                    tdf.Append( _T("Savefile"), path );
                    tdf.AppendLineBreak();
                    break;
                }
                default:
                    wxLogDebugFunc( _T("") ); break;
            }

            long startpostype;
            battle.CustomBattleOptions().getSingleValue( _T("startpostype"), OptionsWrapper::EngineOption ).ToLong( &startpostype );

            std::vector<StartPos> remap_positions;
            if ( battle.IsProxy() && ( startpostype != IBattle::ST_Pick ) && ( startpostype != IBattle::ST_Choose ) )
            {
                std::set<int> parsedteams;
                unsigned int NumUsers = battle.GetNumUsers();
                unsigned int NumTeams = 0;
                for ( unsigned int i = 0; i < NumUsers; i++ )
                {
                        User& usr = battle.GetUser( i );
                        UserBattleStatus& status = usr.BattleStatus();
                        if ( status.spectator ) continue;
                        if ( parsedteams.find( status.team ) != parsedteams.end() ) continue; // skip duplicates
                        parsedteams.insert( status.team );
                        NumTeams++;
                }

                MapInfo infos = battle.LoadMap().info;
                unsigned int nummapstartpositions = infos.positions.size();
                unsigned int copysize = std::min( nummapstartpositions, NumTeams );
                remap_positions = std::vector<StartPos> ( infos.positions.begin(), infos.positions.begin() + copysize ); // only add the first x positions

//.........这里部分代码省略.........
开发者ID:tvo,项目名称:springlobby,代码行数:101,代码来源:spring.cpp

示例5: WriteScriptTxt

wxString Spring::WriteScriptTxt( IBattle& battle ) const
{
    wxLogMessage(_T("0 WriteScriptTxt called "));

    std::stringstream ret;

    LSL::TDF::TDFWriter tdf(ret);

    // Start generating the script.
    tdf.EnterSection("GAME");

    if ( battle.IsFounderMe() ) {
        tdf.Append("HostIP", ""); //Listen on all addresses for connections when hosting
        if ( battle.GetNatType() == NAT_Hole_punching ) tdf.Append("HostPort", battle.GetMyInternalUdpSourcePort() );
        else tdf.Append("HostPort", battle.GetHostPort() );
    } else {
        tdf.Append("HostIP", battle.GetHostIp() );
        tdf.Append("HostPort", battle.GetHostPort() );
        if ( battle.GetNatType() == NAT_Hole_punching ) {
            tdf.Append("SourcePort", battle.GetMyInternalUdpSourcePort() );
        } else if ( sett().GetClientPort() != 0) {
            tdf.Append("SourcePort", sett().GetClientPort() ); /// this allows to play with broken router by setting SourcePort to some forwarded port.
        }
    }
    tdf.Append("IsHost", battle.IsFounderMe() );

    User& me = battle.GetMe();
    tdf.Append("MyPlayerName", me.GetNick());

    if ( !me.BattleStatus().scriptPassword.empty() ) {
        tdf.Append("MyPasswd", me.BattleStatus().scriptPassword);
    }

    if ( !battle.IsFounderMe() ) {
        tdf.LeaveSection();
        return TowxString(ret.str());
    }

    /**********************************************************************************
                                                                Host-only section
    **********************************************************************************/

    tdf.AppendLineBreak();

    tdf.Append("ModHash", battle.LoadMod().hash);
    tdf.Append("MapHash", battle.LoadMap().hash);

    tdf.Append("Mapname", battle.GetHostMapName());
    tdf.Append("GameType", battle.GetHostModName());

    tdf.AppendLineBreak();

    switch ( battle.GetBattleType() ) {
    case BT_Played:
        break;
    case BT_Replay: {
        wxString path = TowxString(battle.GetPlayBackFilePath());
        if ( path.Find(_T("/")) != wxNOT_FOUND ) path.BeforeLast(_T('/'));
        tdf.Append("DemoFile", STD_STRING(path));
        tdf.AppendLineBreak();
        break;
    }
    case BT_Savegame: {
        wxString path = TowxString(battle.GetPlayBackFilePath());
        if ( path.Find(_T("/")) != wxNOT_FOUND ) path.BeforeLast(_T('/'));
        tdf.Append("Savefile", STD_STRING(path));
        tdf.AppendLineBreak();
        break;
    }
    default:
        slLogDebugFunc("");
        break;
    }

    const long startpostype = LSL::Util::FromString<long>(
                      battle.CustomBattleOptions().getSingleValue("startpostype", LSL::Enum::EngineOption ));

    std::vector<LSL::StartPos> remap_positions;
    if ( battle.IsProxy() && ( startpostype != IBattle::ST_Pick ) && ( startpostype != IBattle::ST_Choose ) ) {
        std::set<int> parsedteams;
        unsigned int NumUsers = battle.GetNumUsers();
        unsigned int NumTeams = 0;
        for ( unsigned int i = 0; i < NumUsers; i++ ) {
            User& usr = battle.GetUser( i );
            UserBattleStatus& status = usr.BattleStatus();
            if ( status.spectator ) continue;
            if ( parsedteams.find( status.team ) != parsedteams.end() ) continue; // skip duplicates
            parsedteams.insert( status.team );
            NumTeams++;
        }

        LSL::MapInfo infos = battle.LoadMap().info;
        unsigned int nummapstartpositions = infos.positions.size();
        unsigned int copysize = std::min( nummapstartpositions, NumTeams );
        remap_positions = std::vector<LSL::StartPos> ( infos.positions.begin(), infos.positions.begin() + copysize ); // only add the first x positions

        if ( startpostype == IBattle::ST_Random ) {
            std::random_shuffle( remap_positions.begin(), remap_positions.end() ); // shuffle the positions
        }

//.........这里部分代码省略.........
开发者ID:jgleesawn,项目名称:springlobby,代码行数:101,代码来源:spring.cpp


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