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


C++ BroadcastPacket函数代码示例

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


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

示例1: PacketParser

void PacketParser(SOCKET sck, const char *Packet)
{
	switch (Packet[0])
	{
	// Movement packet.
	case PacketHeaders.MovementPacket:
		{
			MOVEMENTPACKET *mp = (MOVEMENTPACKET*)Packet;
			cout << "Mov*" << "ID:" << mp->ID << "|" << "MID:" << mp->MapID << "|" << "X:" << mp->XPos << "|" << "Y:" << mp->YPos << endl;
			BroadcastPacket(Packet, sizeof(MOVEMENTPACKET));
		}
		break;

	// Chat packet
	case PacketHeaders.ChatPacket:
		{
			CHATPACKET *cp = (CHATPACKET*)Packet;
			cout << "Chat*"<< cp->ID << "||" << cp->Text << endl;
			BroadcastPacket(Packet, cp->Length);
		}
		break;

	// Login packet
	case PacketHeaders.LoginPacket:
		{
			LOGINPACKET *lp = (LOGINPACKET*)Packet;
			cout << "Login*" << lp->Username << " : " << lp->Password << endl;

			stringstream querystring;
			querystring << "SELECT * FROM (`Users`) WHERE (`Username`='" << lp->Username << "' AND `Password`='" << lp->Password << "') LIMIT 1";
			mysqlpp::Connection con;
			con.connect(0, "localhost", "root", "", 3306);
			con.select_db("moonlightfrost");
			mysqlpp::Query qry(con.query(querystring.str()));
			mysqlpp::StoreQueryResult qr(qry.store());
			con.disconnect();

			if ( qr.num_rows() == 0 )
			{
				lp->UserID = 0;
				send(sck, (char *)lp, sizeof(LOGINPACKET), 0);
			}
			else
			{
				lp->UserID = atol(qr[0]["ID"].c_str());
				send(sck, (char *)lp, sizeof(LOGINPACKET), 0);
			}
		}
		break;

	default:
		{
			printf("WARNING: Recieved packet structure not recognized. Header: %s \n", (int)((char)Packet[0]));
		}
		break;
	}
}
开发者ID:ClericX,项目名称:Projects,代码行数:57,代码来源:PacketParser.cpp

示例2: data

void Guild::BroadcastEvent(GuildEvents event, ObjectGuid guid, char const* str1 /*=NULL*/, char const* str2 /*=NULL*/, char const* str3 /*=NULL*/)
{
    uint8 strCount = !str1 ? 0 : (!str2 ? 1 : (!str3 ? 2 : 3));

    WorldPacket data(SMSG_GUILD_EVENT, 1 + 1 + 1 * strCount + (guid.IsEmpty() ? 0 : 8));
    data << uint8(event);
    data << uint8(strCount);

    if (str3)
    {
        data << str1;
        data << str2;
        data << str3;
    }
    else if (str2)
    {
        data << str1;
        data << str2;
    }
    else if (str1)
        { data << str1; }

    if (!guid.IsEmpty())
        { data << guid; }

    BroadcastPacket(&data);

    DEBUG_LOG("WORLD: Sent SMSG_GUILD_EVENT");
}
开发者ID:billy1arm,项目名称:MangosMC,代码行数:29,代码来源:Guild.cpp

示例3: data

void ArenaTeam::BroadcastEvent(ArenaTeamEvents event, ObjectGuid guid, char const* str1 /*=NULL*/, char const* str2 /*=NULL*/, char const* str3 /*=NULL*/)
{
    uint8 strCount = !str1 ? 0 : (!str2 ? 1 : (!str3 ? 2 : 3));

    WorldPacket data(SMSG_ARENA_TEAM_EVENT, 1 + 1 + 1*strCount + (!guid ? 0 : 8));
    data << uint8(event);
    data << uint8(strCount);

    if (str3)
    {
        data << str1;
        data << str2;
        data << str3;
    }
    else if (str2)
    {
        data << str1;
        data << str2;
    }
    else if (str1)
        data << str1;

    if (guid)
        data << ObjectGuid(guid);

    BroadcastPacket(&data);

    DEBUG_LOG("WORLD: Sent SMSG_ARENA_TEAM_EVENT");
}
开发者ID:Archives,项目名称:easy-mangos,代码行数:29,代码来源:ArenaTeam.cpp

示例4: data

void Guild::BroadcastEvent(GuildEvents event, uint64 guid, uint8 strCount, std::string str1, std::string str2, std::string str3)
{
    WorldPacket data(SMSG_GUILD_EVENT, 1+1+(guid ? 8 : 0));
    data << uint8(event);
    data << uint8(strCount);

    switch(strCount)
    {
    case 0:
        break;
    case 1:
        data << str1;
        break;
    case 2:
        data << str1 << str2;
        break;
    case 3:
        data << str1 << str2 << str3;
        break;
    default:
        sLog.outError("Guild::BroadcastEvent: incorrect strings count %u!", strCount);
        break;
    }

    if(guid)
        data << uint64(guid);

    BroadcastPacket(&data);

    sLog.outDebug("WORLD: Sent SMSG_GUILD_EVENT");
}
开发者ID:dythzer,项目名称:mangoszero,代码行数:31,代码来源:Guild.cpp

示例5: data

void ArenaTeam::BroadcastEvent(ArenaTeamEvents event, ObjectGuid guid, uint8 strCount, std::string const& str1, std::string const& str2, std::string const& str3)
{
    WorldPacket data(SMSG_ARENA_TEAM_EVENT, 1+1+1);
    data << uint8(event);
    data << uint8(strCount);
    switch (strCount)
    {
        case 0:
            break;
        case 1:
            data << str1;
            break;
        case 2:
            data << str1 << str2;
            break;
        case 3:
            data << str1 << str2 << str3;
            break;
        default:
            TC_LOG_ERROR("bg.arena", "Unhandled strCount %u in ArenaTeam::BroadcastEvent", strCount);
            return;
    }

    if (guid)
        data << uint64(guid);

    BroadcastPacket(&data);

    TC_LOG_DEBUG("network", "WORLD: Sent SMSG_ARENA_TEAM_EVENT");
}
开发者ID:ElunaLuaEngine,项目名称:ElunaTrinityWotlk,代码行数:30,代码来源:ArenaTeam.cpp

示例6: GetName

void ArenaTeam::Disband(WorldSession *session)
{
    // event
    WorldPacket data;
    session->BuildArenaTeamEventPacket(&data, ERR_ARENA_TEAM_DISBANDED_S, 2, session->GetPlayerName(), GetName(), "");
    BroadcastPacket(&data);

    uint32 count = members.size();
    uint64 *memberGuids = new uint64[count];

    MemberList::iterator itr;
    uint32 i=0;
    for(itr = members.begin(); itr != members.end(); itr++)
    {
        memberGuids[i] = itr->guid;
        ++i;
    }

    for(uint32 j = 0; j < count; j++)
        DelMember(memberGuids[j]);
    delete[] memberGuids;

    CharacterDatabase.BeginTransaction();
    CharacterDatabase.PExecute("DELETE FROM arena_team WHERE arenateamid = '%u'", Id);
    CharacterDatabase.PExecute("DELETE FROM arena_team_stats WHERE arenateamid = '%u'", Id);
    CharacterDatabase.CommitTransaction();
    objmgr.RemoveArenaTeam(this);
}
开发者ID:Cha0Sxx,项目名称:mangos,代码行数:28,代码来源:ArenaTeam.cpp

示例7: data

void ArenaTeam::BroadcastEvent(ArenaTeamEvents event, uint64 guid, uint8 strCount, std::string str1, std::string str2, std::string str3)
{
    WorldPacket data(SMSG_ARENA_TEAM_EVENT, 1+1+1);
    data << uint8(event);
    data << uint8(strCount);
    switch (strCount)
    {
        case 0:
            break;
        case 1:
            data << str1;
            break;
        case 2:
            data << str1 << str2;
            break;
        case 3:
            data << str1 << str2 << str3;
            break;
        default:
            sLog->outError("Unhandled strCount %u in ArenaTeam::BroadcastEvent", strCount);
            return;
    }

    if (guid)
        data << uint64(guid);

    BroadcastPacket(&data);

    sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Sent SMSG_ARENA_TEAM_EVENT");
}
开发者ID:Crash911,项目名称:RaptoredSkyFire,代码行数:30,代码来源:ArenaTeam.cpp

示例8: BroadcastPacket

// Removes a player from the battle
void _Battle::RemoveObject(_Object *RemoveObject) {

	// Remove action results
	for(auto Iterator = ActionResults.begin(); Iterator != ActionResults.end(); ) {
		_ActionResult &ActionResult = *Iterator;
		if(ActionResult.Source.Object == RemoveObject || ActionResult.Target.Object == RemoveObject) {
			Iterator = ActionResults.erase(Iterator);
		}
		else
			++Iterator;
	}

	// Remove objects
	for(auto Iterator = Objects.begin(); Iterator != Objects.end(); ++Iterator) {
		_Object *Object = *Iterator;
		if(Object == RemoveObject) {

			// Broadcast object leaving
			if(Server) {
				ae::_Buffer Packet;
				Packet.Write<PacketType>(PacketType::BATTLE_LEAVE);
				Packet.Write<ae::NetworkIDType>(Object->NetworkID);
				BroadcastPacket(Packet);
			}

			SideCount[Object->Fighter->BattleSide]--;
			Object->StopBattle();
			Objects.erase(Iterator);
			return;
		}
	}
}
开发者ID:jazztickets,项目名称:choria,代码行数:33,代码来源:battle.cpp

示例9: _removeMember

uint32 Group::RemoveMember(ObjectGuid guid, uint8 method)
{
    //Playerbot mod - if master leaves group, all bots leave group
    {
        Player* const player = sObjectMgr.GetPlayer(guid);
        if (player && player->GetPlayerbotMgr())
            player->GetPlayerbotMgr()->RemoveAllBotsFromGroup();
    }
    //END Playerbot mod

    // remove member and change leader (if need) only if strong more 2 members _before_ member remove
    if (GetMembersCount() > uint32(isBGGroup() ? 1 : 2))    // in BG group case allow 1 members group
    {
        bool leaderChanged = _removeMember(guid);

        if (Player* player = sObjectMgr.GetPlayer(guid))
        {
            // quest related GO state dependent from raid membership
            if (isRaidGroup())
                player->UpdateForQuestWorldObjects();

            WorldPacket data;

            if (method == 1)
            {
                data.Initialize(SMSG_GROUP_UNINVITE, 0);
                player->GetSession()->SendPacket(&data);
            }

            // we already removed player from group and in player->GetGroup() is his original group!
            if (Group* group = player->GetGroup())
            {
                group->SendUpdate();
            }
            else
            {
                data.Initialize(SMSG_GROUP_LIST, 24);
                data << uint64(0) << uint64(0) << uint64(0);
                player->GetSession()->SendPacket(&data);
            }

            _homebindIfInstance(player);
        }

        if (leaderChanged)
        {
            WorldPacket data(SMSG_GROUP_SET_LEADER, (m_memberSlots.front().name.size() + 1));
            data << m_memberSlots.front().name;
            BroadcastPacket(&data, true);
        }

        SendUpdate();
    }
    // if group before remove <= 2 disband it
    else
        Disband(true);

    return m_memberSlots.size();
}
开发者ID:jpiolho,项目名称:portalclassic,代码行数:59,代码来源:Group.cpp

示例10: doexit

OVERLAY void doexit(void)
{
  packet_header_t packet;

  // Send "downed" packet
  packet.type = PKT_DOWN; 
  packet.tic = 0; // Clients should not need the tic number, can't see a use for it
  BroadcastPacket(&packet, sizeof packet);
}
开发者ID:rlsosborne,项目名称:doom,代码行数:9,代码来源:d_server.cpp

示例11: _setLeader

void Group::ChangeLeader(const uint64 &guid)
{
    _setLeader(guid);

    WorldPacket data(SMSG_GROUP_SET_LEADER, (m_members[_getMemberIndex(guid)].name.size()+1));
    data << m_members[_getMemberIndex(guid)].name;
    BroadcastPacket(&data);
    SendUpdate();
}
开发者ID:Aion,项目名称:caldari,代码行数:9,代码来源:Group.cpp

示例12: _getMemberCSlot

void Group::ChangeLeader(ObjectGuid guid)
{
    member_citerator slot = _getMemberCSlot(guid);
    if (slot == m_memberSlots.end())
        return;

    _setLeader(guid);

    WorldPacket data(SMSG_GROUP_SET_LEADER, slot->name.size() + 1);
    data << slot->name;
    BroadcastPacket(&data, true);
    SendUpdate();
}
开发者ID:jpiolho,项目名称:portalclassic,代码行数:13,代码来源:Group.cpp

示例13: data

void Group::SetTargetIcon(uint8 id, uint64 guid)
{
    if(id >= TARGETICONCOUNT)
        return;

    m_targetIcons[id] = guid;

    WorldPacket data(MSG_RAID_ICON_TARGET, (2+8));
    data << (uint8)0;
    data << id;
    data << guid;
    BroadcastPacket(&data);
}
开发者ID:Aion,项目名称:caldari,代码行数:13,代码来源:Group.cpp

示例14: doexit

void doexit(void)
{
  char buf[200];
  packet_header_t packet;

  // Remove any stats file
  sprintf(buf, "lxdoom-game-server-stats.%u", getpid());
  unlink(buf);

  // Send "downed" packet
  packet.type = PKT_DOWN; 
  packet.tic = 0; // Clients should not need the tic number, can't see a use for it
  BroadcastPacket(&packet, sizeof packet);
}
开发者ID:hexameron,项目名称:DOOM,代码行数:14,代码来源:d_server.c

示例15: data

void OPvPWintergrasp::SendInitWorldStatesTo(Player *player)
{
    WorldPacket data(SMSG_INIT_WORLD_STATES, (4+4+4+2+(m_buildingStates.size()*8)));
    data << uint32(571);
    data << uint32(ZONE_WINTERGRASP);
    data << uint32(0);
    data << uint16(m_buildingStates.size());
    for(BuildingStateMap::iterator itr = m_buildingStates.begin(); itr != m_buildingStates.end(); ++itr)
        itr->second->FillData(data);
    if(player)
        player->GetSession()->SendPacket(&data);
    else
        BroadcastPacket(data);
}
开发者ID:pfchrono,项目名称:mangos-mods,代码行数:14,代码来源:Wintergrasp.cpp


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