virtual T process()
    {
        ObjectiveInterface::syncObjectives( connect_client );

        PowerUpInterface::syncPowerUps( connect_client );

        
        PlayerState * player = PlayerInterface::getPlayer(connect_client->getPlayerIndex());

        player->setStateSelectingFlag();

        PlayerFlagSync pfs;
        pfs.player_id = connect_client->player_id;
        ResourceManager::getFlag(connect_client->player_id)->frameToBuffer(pfs.player_flag, sizeof(pfs.player_flag));
        SERVER->broadcastMessage(&pfs, sizeof(pfs));

        PlayerStateSync player_state_update
            (player->getNetworkPlayerState());

        SERVER->broadcastMessage( &player_state_update, sizeof(PlayerStateSync));

        ConnectProcessStateMessage state_mesg;
        state_mesg.setMessageEnum(_connect_state_sync_complete);
        connect_client->sendMessage( &state_mesg,
                                     sizeof(ConnectProcessStateMessage));


        sendConnectionAlert( connect_client );
        if (GameControlRulesDaemon::getGameState() == _game_state_prepare_team)
        {
            GameControlCyclePrepareTeam prepare_team_mesg;
            SERVER->sendMessage(connect_client->player_id, &prepare_team_mesg, sizeof(GameControlCyclePrepareTeam));
        }
        return connect_state_idle;
    }
예제 #2
0
Uint16
BotManager::addBot()
{
    PlayerState *p = PlayerInterface::allocateNewPlayer();
    if ( p )
    {
        Bot * b = new BotPlayer(p->getID());
        bot_list.push_back(b);

        ResourceManagerSyncFlagMessage flagmsg;
        ResourceManager::getFlagData("bot.bmp",(Uint8*)&flagmsg.flagdata);
        flagmsg.setFlagID(ResourceManager::registerFlagFromData((Uint8*)&flagmsg.flagdata));

        p->setName("Bot");
        p->setFlag(flagmsg.getFlagID());
        p->setStatus(_player_state_active);

        NetworkServer::broadcastMessage(&flagmsg, sizeof(flagmsg));

        PlayerStateSync updatemsg(p->getNetworkPlayerState());
        NetworkServer::broadcastMessage( &updatemsg, sizeof(updatemsg));

        SystemConnectAlert connect_alert;
        connect_alert.set( p->getID(), _connect_alert_mesg_connect );
        NetworkServer::broadcastMessage( &connect_alert, sizeof(SystemConnectAlert));
        NetworkClient::sendMessage(&connect_alert, sizeof(SystemConnectAlert));
        
        return p->getID();
    }
    return 0xffff;
}
    virtual void enter()
    {
        player = PlayerInterface::getPlayer(connect_client->getPlayerIndex());

        sync_count = 0;
        sync_done = 0;
        sync_end = 0;
        sync_total = UnitInterface::getTotalUnitCount();

        if ( sync_total )
        {
            sync_end = UnitInterface::getUnits().rbegin()->first;
        }

        sync_end += 1;

        ConnectProcessStateMessage state_mesg;
        state_mesg.setMessageEnum(_connect_state_message_sync_units);
        connect_client->sendMessage( &state_mesg,
                                     sizeof(ConnectProcessStateMessage));

        SERVER->addClientToSendList( connect_client );

        PlayerState *p = PlayerInterface::getPlayer(connect_client->getPlayerIndex());
        PlayerStateSync player_state_update( p->getNetworkPlayerState() );
        SERVER->broadcastMessage(&player_state_update, sizeof(PlayerStateSync));

        sendunitpercent_timer.reset();
        time_out_timer.reset();
    }