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


C++ BitStream类代码示例

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


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

示例1: SetState

// =============================================================================
// Nat Ryall                                                         11-Jul-2008
// =============================================================================
void CPlayer::Move(t_PlayerDirection iDirection)
{
	m_pTargetBlock = m_pCurrentBlock->m_pAdjacents[iDirection];
	m_iMoveDir = iDirection;
	m_iTransitionDir = iDirection;
	m_iTime = 0;
	m_fTransition = 0.f;

	if (m_pCurrentBlock->m_pAdjacents[iDirection])
		SetState(PlayerState_Move);
	else
	{
		m_bLeaving = true;
		SetState(PlayerState_Warp);
	}

	// Network.
	if (NetworkManager.IsRunning())
	{
		if (m_iLogicType == PlayerLogicType_Local || m_iLogicType == PlayerLogicType_AI)
		{
			BitStream xStream;

			xStream.Write((xuint8)PlayerStreamType_Move);
			xStream.Write((xuint8)m_iIndex);
			xStream.Write((xuint8)iDirection);

			NetworkManager.Broadcast(NULL, NetworkStreamType_PlayerUpdate, &xStream, HIGH_PRIORITY, RELIABLE_ORDERED);
		}
	}
}
开发者ID:ryall,项目名称:pikpik,代码行数:34,代码来源:Player.cpp

示例2: NotifyNoTeam

void TeamBalancer::NotifyNoTeam(RakNetGUID target)
{
    BitStream bsOut;
    bsOut.Write((MessageID)ID_TEAM_BALANCER_TEAM_ASSIGNED);
    bsOut.Write((unsigned char)UNASSIGNED_TEAM_ID);
    rakPeerInterface->Send(&bsOut,HIGH_PRIORITY,RELIABLE_ORDERED,0,target,false);
}
开发者ID:Azon099,项目名称:Five-Multiplayer,代码行数:7,代码来源:TeamBalancer.cpp

示例3: SendMessageToRoom

void RelayPlugin::SendMessageToRoom(StrAndGuidAndRoom **strAndGuidSender, BitStream* message)
{
	if ((*strAndGuidSender)->currentRoom.IsEmpty())
		return;

	for (unsigned int i=0; i < chatRooms.Size(); i++)
	{
		if (chatRooms[i]->roomName==(*strAndGuidSender)->currentRoom)
		{
			BitStream bsOut;
			bsOut.WriteCasted<MessageID>(ID_RELAY_PLUGIN);
			bsOut.WriteCasted<MessageID>(RPE_GROUP_MSG_FROM_SERVER);
			message->ResetReadPointer();
			bsOut.WriteCompressed((*strAndGuidSender)->str);
			bsOut.AlignWriteToByteBoundary();
			bsOut.Write(message);

			RP_Group *room = chatRooms[i];
			for (unsigned int i=0; i < room->usersInRoom.Size(); i++)
			{
				if (room->usersInRoom[i].guid!=(*strAndGuidSender)->guid)
					SendUnified(&bsOut, HIGH_PRIORITY, RELIABLE_ORDERED, 0, room->usersInRoom[i].guid, false);
			}

			break;
		}
	}
}
开发者ID:Aasagi,项目名称:DICEProgrammingChallenge,代码行数:28,代码来源:RelayPlugin.cpp

示例4: switch

void LobbyMenu::HandleKey( int key, int x, int y )
{
    BaseMenu::HandleKey(key, x, y);
    if((key == KEY_ENTER) || (key == KEY_SPACE))
    {
        switch(m_nSelectedItem)
        {
        case GOTO_LAST_MENU:
            {
                BaseMenu *menu = dynamic_cast<BaseMenu*>(menuSystem->mainMenu);
                if(menu != NULL)
                {
                    menuSystem->Switch(menu);
                }
            }
            break;
        case 1:
            {
                menuSystem->StartGame();
                BitStream * stream = new BitStream();
                stream->Write((MessageID)END_YOUR_TURN);
                Network::GetInstance()->Message(stream);
                delete stream;
            }
            break;
        }
    }
}
开发者ID:danielselnick,项目名称:Sentry-Tactics,代码行数:28,代码来源:ConcreteMenus.cpp

示例5: StoreDNAHuf

// ********************************************************************************************
void Block::StoreDNAHuf(BitStream &bit_stream, LzMatcher &lz_matcher, uchar *sym_code, HuffmanEncoder::Code *sym_huf_codes, bool try_lz)
{
	// Info about LZ matches
	if (try_lz)
	{
		FindLzMatches(lz_matcher);

		StoreLzMatches(bit_stream, lz_matcher);

		for (uint32 i = 0; i < rec_count; ++i)
		{
			uint32 cur_sequence_len = records[i].sequence_len;
			uchar *cur_sequence = records[i].sequence;
			for (uint32 j = lz_matches[i].length; j < cur_sequence_len; ++j)
			{
				bit_stream.PutBits(sym_huf_codes[sym_code[cur_sequence[j]]].code, sym_huf_codes[sym_code[cur_sequence[j]]].len);
			}
		}
	}
	else
	{
		for (uint32 i = 0; i < rec_count; ++i)
		{
			uint32 cur_sequence_len = records[i].sequence_len;
			uchar *cur_sequence = records[i].sequence;
			for (uint32 j = 0; j < cur_sequence_len; ++j)
			{
				bit_stream.PutBits(sym_huf_codes[sym_code[cur_sequence[j]]].code, sym_huf_codes[sym_code[cur_sequence[j]]].len);
			}
		}
	}

	bit_stream.FlushPartialWordBuffer();
}
开发者ID:PCDS,项目名称:paraDSRC,代码行数:35,代码来源:block.cpp

示例6: NotifyTeamsLocked

void TeamBalancer::NotifyTeamsLocked(RakNetGUID target, TeamId requestedTeam)
{
	BitStream bsOut;
	bsOut.Write((MessageID)ID_TEAM_BALANCER_REQUESTED_TEAM_LOCKED);
	bsOut.Write(requestedTeam);
	rakPeerInterface->Send(&bsOut,HIGH_PRIORITY,RELIABLE_ORDERED,0,target,false);
}
开发者ID:TrevorCash,项目名称:Urho3D,代码行数:7,代码来源:TeamBalancer.cpp

示例7: qDebug

pair<SystemAddress, QueryData> QueryClient::Update(const RakNet::SystemAddress &addr)
{
    qDebug() << "Locking mutex in QueryClient::Update(RakNet::SystemAddress addr)";
    pair<SystemAddress, QueryData> server;
    BitStream bs;
    bs.Write((unsigned char) (ID_MASTER_UPDATE));
    bs.Write(addr);

    mxServers.lock();
    status = -1;
    int attempts = 3;
    pmu->SetServer(&server);
    do
    {
        if (Connect() == IS_NOT_CONNECTED)
        {
            qDebug() << IS_NOT_CONNECTED;
            qDebug() << "Unlocking mutex in QueryClient::Update(RakNet::SystemAddress addr)";
            mxServers.unlock();
            return server;
        }

        peer->Send(&bs, HIGH_PRIORITY, RELIABLE_ORDERED, CHANNEL_MASTER, masterAddr, false);
        status = GetAnswer(ID_MASTER_UPDATE);
        RakSleep(100);
    }
    while(status != ID_MASTER_UPDATE && attempts-- > 0);
    if(status != ID_MASTER_UPDATE)
        qDebug() << "Getting update was failed";
    peer->CloseConnection(masterAddr, true);
    qDebug() << "Unlocking mutex in QueryClient::Update(RakNet::SystemAddress addr)";
    mxServers.unlock();
    return server;
}
开发者ID:GrimKriegor,项目名称:openmw-tes3mp,代码行数:34,代码来源:QueryClient.cpp

示例8: initRandomData

void NetInterface::handleConnectChallengeRequest(const NetAddress *addr, BitStream *stream)
{
   char buf[256];
   Net::addressToString(addr, buf);
   Con::printf("Got Connect challenge Request from %s", buf);
   if(!mAllowConnections)
      return;

   U32 connectSequence;
   stream->read(&connectSequence);

   if(!mRandomDataInitialized)
      initRandomData();

   U32 addressDigest[4];
   computeNetMD5(addr, connectSequence, addressDigest);

   BitStream *out = BitStream::getPacketStream();
   out->write(U8(ConnectChallengeResponse));
   out->write(connectSequence);
   out->write(addressDigest[0]);
   out->write(addressDigest[1]);
   out->write(addressDigest[2]);
   out->write(addressDigest[3]);

   BitStream::sendPacketStream(addr);
}
开发者ID:mray,项目名称:terminal-overload,代码行数:27,代码来源:netInterface.cpp

示例9: decode

int Golomb::decode(uint m, int *value, BitStream& bs){
	int q = 0, r, v;
	int nbits = (int) floor(log2(m)) + 1;
	int err;
	uint32_t bit;


	do {
		if ((err=bs.readBit(&bit)) != 0)
			return err;

		if (bit == 0)
			break;
		q++;
	} while(true);


	if ((err = bs.readBits(nbits, &bit)) != 0)
		return err;

	r = (int) bit;

	v = q * m + r;
	if (v % 2 == 0)
		*value =  v/2;
	else
		*value = -(v+1)/2;

	return 0;
}
开发者ID:fmanco,项目名称:cavt2,代码行数:30,代码来源:Golomb.cpp

示例10: RequestClass

void  RakClient::RequestClass( int classId )
{
    BitStream bsClass;

    bsClass.Write( classId );
    g_RakClient->RPC( RPC_RequestClass, &bsClass );
}
开发者ID:ananay,项目名称:mod-s0beit-sa,代码行数:7,代码来源:RakClient.cpp

示例11: GetCharBuildInfo

void Character::GetCharBuildInfo(BitStream &src)
{
    src.GetString(m_char_data.m_class_name);
    src.GetString(m_char_data.m_origin_name);

    qInfo() << "Loading Starting Character Settings...";
    QSettings config(Settings::getSettingsPath(),QSettings::IniFormat,nullptr);

    config.beginGroup("StartingCharacter");
        QRegExp space("\\s");
        QStringList inherent_and_preorders = config.value(QStringLiteral("inherent_powers"), "Brawl").toString().remove(space).split(',');
        QStringList starting_temps = config.value(QStringLiteral("starting_temps"), "EMP_Glove").toString().remove(space).split(',');
        QStringList starting_insps = config.value(QStringLiteral("starting_inspirations"), "Resurgence").toString().remove(space).split(',');
        uint startlevel = config.value(QStringLiteral("starting_level"), "1").toUInt() -1; //convert from 1-50 to 0-49
        uint startinf = config.value(QStringLiteral("starting_inf"), "0").toUInt();
    config.endGroup();

    m_char_data.m_level = startlevel;
    m_char_data.m_influence = startinf;

    // Temporary Powers MUST come first (must be idx 0)
    addStartingPowers(QStringLiteral("Temporary_Powers"), QStringLiteral("Temporary_Powers"), starting_temps);
    addStartingPowers(QStringLiteral("Inherent"), QStringLiteral("Inherent"), inherent_and_preorders);
    getPowerFromBuildInfo(src);     // primary, secondary

    // Now that character is created. Finalize level and update hp and end
    finalizeLevel();
    setHPToMax(*this); // set max hp
    setEndToMax(*this); // set max end

    // This must come after finalize
    addStartingInspirations(starting_insps);      // resurgence and phenomenal_luck

    m_char_data.m_trays.serializefrom(src);
}
开发者ID:ldilley,项目名称:Segs,代码行数:35,代码来源:Character.cpp

示例12: writeBox

void ImageSpatialExtentsProperty::writeBox(BitStream& output)
{
    writeFullBoxHeader(output);
    output.write32Bits(mImageWidth);
    output.write32Bits(mImageHeight);
    updateSize(output);
}
开发者ID:axelriet,项目名称:heif,代码行数:7,代码来源:imagespatialextentsproperty.cpp

示例13: Read

//=================================================================================================
bool QuestManager::Read(BitStream& stream)
{
	const int QUEST_MIN_SIZE = sizeof(int) + sizeof(byte) * 3;
	word quest_count;
	if(!stream.Read(quest_count)
		|| !EnsureSize(stream, QUEST_MIN_SIZE * quest_count))
	{
		Error("Read world: Broken packet for quests.");
		return false;
	}
	quests.resize(quest_count);

	int index = 0;
	for(Quest*& quest : quests)
	{
		quest = new PlaceholderQuest;
		quest->quest_index = index;
		if(!stream.Read(quest->refid) ||
			!stream.ReadCasted<byte>(quest->state) ||
			!ReadString1(stream, quest->name) ||
			!ReadStringArray<byte, word>(stream, quest->msgs))
		{
			Error("Read world: Broken packet for quest %d.", index);
			return false;
		}
		++index;
	}

	return true;
}
开发者ID:lcs2,项目名称:carpg,代码行数:31,代码来源:QuestManager.cpp

示例14: Net_cbDataReceived

void Server::Net_cbDataReceived( Net_ConnID  _id, BitStream &_data)
{
	Network::NetEvents event = (Network::NetEvents) _data.getInt(8);
	switch( event ) {
			case Network::RConMsg: {
				std::string passwordSent = _data.getString();
				if ( !gusGame.options.rConPassword.empty() && gusGame.options.rConPassword == passwordSent ) {
					//console.addQueueCommand(_data.getStringStatic());
					console.parseLine(_data.getString());
				}
			}
			break;

			case Network::ConsistencyInfo: {
				int clientProtocol = _data.getInt(32);
				if(clientProtocol != Network::protocolVersion) {
					network.disconnect(_id, Network::IncompatibleProtocol);
				}

				if(!gusGame.checkCRCs(_data) && network.checkCRC) // We call checkCRC anyway so that the stream is advanced
					network.disconnect(_id, Network::IncompatibleData);

			}
			break;
	}
}
开发者ID:iamnilay3,项目名称:openlierox,代码行数:26,代码来源:server.cpp

示例15: test_bug2

 void test_bug2()
 {
     BitStream bs;
     bs.append_bit(0);
     bs.resize(3, 1);
     NUT_TA(bs.to_string() == "011");
 }
开发者ID:jingqi,项目名称:nut,代码行数:7,代码来源:test_bitstream.cpp


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