本文整理汇总了C++中data2函数的典型用法代码示例。如果您正苦于以下问题:C++ data2函数的具体用法?C++ data2怎么用?C++ data2使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了data2函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: median
// Computes the median in O(N) time. By making a copy this version assures no re-ordering.
inline double median(vector<double> &data) {
vector<double> data2(data.size());
for(size_t i = 0; i < data.size(); i++) data2[i] = data[i];
return median_unsafe(data2);
}
开发者ID:zia1138,项目名称:pview,代码行数:6,代码来源:util.hpp
示例2: TC_LOG_DEBUG
void WorldSession::HandleGrantLevel(WorldPacket& recvData)
{
TC_LOG_DEBUG("network", "WORLD: CMSG_GRANT_LEVEL");
ObjectGuid guid;
guid[2] = recvData.ReadBit();
guid[1] = recvData.ReadBit();
guid[5] = recvData.ReadBit();
guid[3] = recvData.ReadBit();
guid[7] = recvData.ReadBit();
guid[4] = recvData.ReadBit();
guid[0] = recvData.ReadBit();
guid[6] = recvData.ReadBit();
recvData.ReadByteSeq(guid[1]);
recvData.ReadByteSeq(guid[4]);
recvData.ReadByteSeq(guid[2]);
recvData.ReadByteSeq(guid[7]);
recvData.ReadByteSeq(guid[5]);
recvData.ReadByteSeq(guid[3]);
recvData.ReadByteSeq(guid[6]);
recvData.ReadByteSeq(guid[0]);
Player* target = ObjectAccessor::GetObjectInWorld(guid, _player);
// check cheating
uint8 levels = _player->GetGrantableLevels();
uint8 error = 0;
if (!target)
error = ERR_REFER_A_FRIEND_NO_TARGET;
else if (levels == 0)
error = ERR_REFER_A_FRIEND_INSUFFICIENT_GRANTABLE_LEVELS;
else if (GetRecruiterId() != target->GetSession()->GetAccountId())
error = ERR_REFER_A_FRIEND_NOT_REFERRED_BY;
else if (target->GetTeamId() != _player->GetTeamId())
error = ERR_REFER_A_FRIEND_DIFFERENT_FACTION;
else if (target->getLevel() >= _player->getLevel())
error = ERR_REFER_A_FRIEND_TARGET_TOO_HIGH;
else if (target->getLevel() >= sWorld->getIntConfig(CONFIG_MAX_RECRUIT_A_FRIEND_BONUS_PLAYER_LEVEL))
error = ERR_REFER_A_FRIEND_GRANT_LEVEL_MAX_I;
else if (target->GetGroup() != _player->GetGroup())
error = ERR_REFER_A_FRIEND_NOT_IN_GROUP;
if (error)
{
WorldPacket data(SMSG_REFER_A_FRIEND_FAILURE, 24);
data << uint32(error);
if (error == ERR_REFER_A_FRIEND_NOT_IN_GROUP)
data << target->GetName();
SendPacket(&data);
return;
}
WorldPacket data2(SMSG_PROPOSE_LEVEL_GRANT, 8);
data2.WriteBit(guid[6]);
data2.WriteBit(guid[7]);
data2.WriteBit(guid[2]);
data2.WriteBit(guid[5]);
data2.WriteBit(guid[3]);
data2.WriteBit(guid[0]);
data2.WriteBit(guid[1]);
data2.WriteBit(guid[4]);
data2.WriteByteSeq(guid[2]);
data2.WriteByteSeq(guid[5]);
data2.WriteByteSeq(guid[6]);
data2.WriteByteSeq(guid[7]);
data2.WriteByteSeq(guid[1]);
data2.WriteByteSeq(guid[4]);
data2.WriteByteSeq(guid[3]);
data2.WriteByteSeq(guid[0]);
target->GetSession()->SendPacket(&data2);
}
开发者ID:AriDEV,项目名称:SkyFire.548,代码行数:77,代码来源:ReferAFriendHandler.cpp
示例3: bgtype
void WorldSession::HandleBattleFieldPortOpcode( WorldPacket &recv_data )
{
sLog.outDebug( "WORLD: Recvd CMSG_BATTLEFIELD_PORT Message");
uint8 type; // arenatype if arena
uint8 unk2; // unk, can be 0x0 (may be if was invited?) and 0x1
uint32 bgTypeId_; // type id from dbc
uint16 unk; // 0x1F90 constant?
uint8 action; // enter battle 0x1, leave queue 0x0
recv_data >> type >> unk2 >> bgTypeId_ >> unk >> action;
if (!sBattlemasterListStore.LookupEntry(bgTypeId_))
{
sLog.outError("BattlegroundHandler: invalid bgtype (%u) received.", bgTypeId_);
return;
}
if (!_player->InBattleGroundQueue())
{
sLog.outError("BattlegroundHandler: Invalid CMSG_BATTLEFIELD_PORT received from player (%u), he is not in bg_queue.", _player->GetGUIDLow());
return;
}
//get GroupQueueInfo from BattleGroundQueue
BattleGroundTypeId bgTypeId = BattleGroundTypeId(bgTypeId_);
BattleGroundQueueTypeId bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(bgTypeId, type);
BattleGroundQueue& bgQueue = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId];
//we must use temporary variable, because GroupQueueInfo pointer can be deleted in BattleGroundQueue::RemovePlayer() function
GroupQueueInfo ginfo;
if (!bgQueue.GetPlayerGroupInfoData(_player->GetGUID(), &ginfo))
{
sLog.outError("BattlegroundHandler: itrplayerstatus not found.");
return;
}
// if action == 1, then instanceId is required
if (!ginfo.IsInvitedToBGInstanceGUID && action == 1)
{
sLog.outError("BattlegroundHandler: instance not found.");
return;
}
BattleGround *bg = sBattleGroundMgr.GetBattleGround(ginfo.IsInvitedToBGInstanceGUID, bgTypeId);
// bg template might and must be used in case of leaving queue, when instance is not created yet
if (!bg && action == 0)
bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId);
if (!bg)
{
sLog.outError("BattlegroundHandler: bg_template not found for type id %u.", bgTypeId);
return;
}
// expected bracket entry
PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bg->GetMapId(),_player->getLevel());
if (!bracketEntry)
return;
//some checks if player isn't cheating - it is not exactly cheating, but we cannot allow it
if (action == 1 && ginfo.ArenaType == 0)
{
//if player is trying to enter battleground (not arena!) and he has deserter debuff, we must just remove him from queue
if (!_player->CanJoinToBattleground())
{
//send bg command result to show nice message
WorldPacket data2(SMSG_GROUP_JOINED_BATTLEGROUND, 4);
data2 << uint32(0xFFFFFFFE);
_player->GetSession()->SendPacket(&data2);
action = 0;
sLog.outDebug("Battleground: player %s (%u) has a deserter debuff, do not port him to battleground!", _player->GetName(), _player->GetGUIDLow());
}
//if player don't match battleground max level, then do not allow him to enter! (this might happen when player leveled up during his waiting in queue
if (_player->getLevel() > bg->GetMaxLevel())
{
sLog.outError("Battleground: Player %s (%u) has level (%u) higher than maxlevel (%u) of battleground (%u)! Do not port him to battleground!",
_player->GetName(), _player->GetGUIDLow(), _player->getLevel(), bg->GetMaxLevel(), bg->GetTypeID());
action = 0;
}
}
uint32 queueSlot = _player->GetBattleGroundQueueIndex(bgQueueTypeId);
WorldPacket data;
switch( action )
{
case 1: // port to battleground
if (!_player->IsInvitedForBattleGroundQueueType(bgQueueTypeId))
return; // cheating?
if (!_player->InBattleGround())
_player->SetBattleGroundEntryPoint();
// resurrect the player
if (!_player->isAlive())
{
_player->ResurrectPlayer(1.0f);
_player->SpawnCorpseBones();
}
// stop taxi flight at port
if (_player->isInFlight())
{
_player->GetMotionMaster()->MovementExpired();
_player->m_taxi.ClearTaxiDestinations();
//.........这里部分代码省略.........
开发者ID:Apple15,项目名称:mangos,代码行数:101,代码来源:BattleGroundHandler.cpp
示例4: decrypted
void WorldSession::HandleClientAuthentication(WorldPacket& packet)
{
quint32 bufferSize;
packet >> bufferSize;
QByteArray buffer;
buffer.resize(bufferSize);
packet.ReadRawBytes(buffer.data(), buffer.size());
WorldPacket decrypted(0, Cryptography::Instance()->Decrypt(buffer));
quint64 rsaVerification;
decrypted >> rsaVerification;
QString account = decrypted.ReadString();
QString password = decrypted.ReadString();
QSqlQuery result = Database::Auth()->Query(SELECT_ACCOUNT_BY_USERNAME, QVariantList() << account);
if (!result.first())
{
SendLoginErrorResult(LOGIN_RESULT_INVALID_LOGIN);
return;
}
QSqlRecord fields = result.record();
QString hashPassword = result.value(fields.indexOf("hash_password")).toString();
if (Utils::HashPassword(account, password) != hashPassword)
{
SendLoginErrorResult(LOGIN_RESULT_INVALID_LOGIN);
return;
}
m_accountInfos.id = result.value(fields.indexOf("account_id")).toULongLong();
m_accountInfos.username = result.value(fields.indexOf("username")).toString();
m_accountInfos.pseudo = result.value(fields.indexOf("pseudo")).toString();
m_accountInfos.gmLevel = (quint8)result.value(fields.indexOf("username")).toUInt();
m_accountInfos.subscriptionTime = result.value(fields.indexOf("subscription_time")).toUInt();
// Send opcode 2 (connection retry ticket, not implemented)
WorldPacket data2(SMSG_CONNECTION_RETRY_TICKET);
SendPacket(data2);
WorldPacket data(SMSG_CLIENT_AUTH_RESULT);
data << quint8(LOGIN_RESULT_SUCCESS);
data.StartBlock<quint16>();
{
data << quint8(1);
{
data << quint8(0);
data << quint32(6);
data << quint8(0);
data << quint64(result.value(fields.indexOf("account_id")).toULongLong());
data << quint32(1); // m_subscriptionLevel
data << quint32(0); // antiAddictionLevel
data << quint64(m_accountInfos.subscriptionTime);
// Admin rights ?
for (quint8 i = 0; i <= 75; ++i)
data << quint32(0);
data.WriteString(m_accountInfos.pseudo);
data << quint32(0); // m_accountCommunity ID, see Wl.java for IDs
data << quint16(0); // size of hdv, see bOE.java something with m_accountCommunity and check TS.java
}
}
data.EndBlock<quint16>();
SendPacket(data);
SendWorldSelectResult();
}
开发者ID:prespik,项目名称:WakBox,代码行数:75,代码来源:LoginHandler.cpp
示例5: Sounds_crossCorrelate
Sound Sounds_crossCorrelate (Sound me, Sound thee, enum kSounds_convolve_scaling scaling, enum kSounds_convolve_signalOutsideTimeDomain signalOutsideTimeDomain) {
try {
if (my ny > 1 && thy ny > 1 && my ny != thy ny)
Melder_throw (U"The numbers of channels of the two sounds have to be equal or 1.");
if (my dx != thy dx)
Melder_throw (U"The sampling frequencies of the two sounds have to be equal.");
long numberOfChannels = my ny > thy ny ? my ny : thy ny;
long n1 = my nx, n2 = thy nx;
long n3 = n1 + n2 - 1, nfft = 1;
while (nfft < n3) nfft *= 2;
autoNUMvector <double> data1 (1, nfft);
autoNUMvector <double> data2 (1, nfft);
double my_xlast = my x1 + (n1 - 1) * my dx;
autoSound him = Sound_create (numberOfChannels, thy xmin - my xmax, thy xmax - my xmin, n3, my dx, thy x1 - my_xlast);
for (long channel = 1; channel <= numberOfChannels; channel ++) {
double *a = my z [my ny == 1 ? 1 : channel];
for (long i = n1; i > 0; i --) data1 [i] = a [i];
for (long i = n1 + 1; i <= nfft; i ++) data1 [i] = 0.0;
a = thy z [thy ny == 1 ? 1 : channel];
for (long i = n2; i > 0; i --) data2 [i] = a [i];
for (long i = n2 + 1; i <= nfft; i ++) data2 [i] = 0.0;
NUMrealft (data1.peek(), nfft, 1);
NUMrealft (data2.peek(), nfft, 1);
data2 [1] *= data1 [1];
data2 [2] *= data1 [2];
for (long i = 3; i <= nfft; i += 2) {
double temp = data1 [i] * data2 [i] + data1 [i + 1] * data2 [i + 1]; // reverse me by taking the conjugate of data1
data2 [i + 1] = data1 [i] * data2 [i + 1] - data1 [i + 1] * data2 [i]; // reverse me by taking the conjugate of data1
data2 [i] = temp;
}
NUMrealft (data2.peek(), nfft, -1);
a = him -> z [channel];
for (long i = 1; i < n1; i ++) {
a [i] = data2 [i + (nfft - (n1 - 1))]; // data for the first part ("negative lags") is at the end of data2
}
for (long i = 1; i <= n2; i ++) {
a [i + (n1 - 1)] = data2 [i]; // data for the second part ("positive lags") is at the beginning of data2
}
}
switch (signalOutsideTimeDomain) {
case kSounds_convolve_signalOutsideTimeDomain_ZERO: {
// do nothing
} break;
case kSounds_convolve_signalOutsideTimeDomain_SIMILAR: {
for (long channel = 1; channel <= numberOfChannels; channel ++) {
double *a = his z [channel];
double edge = n1 < n2 ? n1 : n2;
for (long i = 1; i < edge; i ++) {
double factor = edge / i;
a [i] *= factor;
a [n3 + 1 - i] *= factor;
}
}
} break;
//case kSounds_convolve_signalOutsideTimeDomain_PERIODIC: {
// do nothing
//} break;
default: Melder_fatal (U"Sounds_crossCorrelate: unimplemented outside-time-domain strategy ", signalOutsideTimeDomain);
}
switch (scaling) {
case kSounds_convolve_scaling_INTEGRAL: {
Vector_multiplyByScalar (him.peek(), my dx / nfft);
} break;
case kSounds_convolve_scaling_SUM: {
Vector_multiplyByScalar (him.peek(), 1.0 / nfft);
} break;
case kSounds_convolve_scaling_NORMALIZE: {
double normalizationFactor = Matrix_getNorm (me) * Matrix_getNorm (thee);
if (normalizationFactor != 0.0) {
Vector_multiplyByScalar (him.peek(), 1.0 / nfft / normalizationFactor);
}
} break;
case kSounds_convolve_scaling_PEAK_099: {
Vector_scale (him.peek(), 0.99);
} break;
default: Melder_fatal (U"Sounds_crossCorrelate: unimplemented scaling ", scaling);
}
return him.transfer();
} catch (MelderError) {
Melder_throw (me, U" & ", thee, U": not cross-correlated.");
}
}
开发者ID:psibre,项目名称:praat,代码行数:82,代码来源:Sound.cpp
示例6: SetData
void SetData(uint32 type, uint32 data)
{
switch (type)
{
case DATA_RAGEWINTERCHILLEVENT: Encounters[0] = data; break;
case DATA_ANETHERONEVENT:
Encounters[1] = data;
break;
case DATA_KAZROGALEVENT: Encounters[2] = data; break;
case DATA_AZGALOREVENT:
{
Encounters[3] = data;
if (data == DONE)
{
if (ArchiYell)break;
ArchiYell = true;
Creature* creature = instance->GetCreature(Azgalor);
if (creature)
{
Creature* pUnit = creature->SummonCreature(21987, creature->GetPositionX(),creature->GetPositionY(),creature->GetPositionZ(),0, TEMPSUMMON_TIMED_DESPAWN, 10000);
Map* pMap = creature->GetMap();
if (pMap->IsDungeon() && pUnit)
{
pUnit->SetVisibility(VISIBILITY_OFF);
Map::PlayerList const &PlayerList = pMap->GetPlayers();
if (PlayerList.isEmpty())
return;
for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
{
if (i->getSource())
{
WorldPacket data(SMSG_MESSAGECHAT, 200);
pUnit->BuildMonsterChat(&data, CHAT_MSG_MONSTER_YELL, YELL_EFFORTS, 0, YELL_EFFORTS_NAME, i->getSource()->GetGUID());
i->getSource()->GetSession()->SendPacket(&data);
WorldPacket data2(SMSG_PLAY_SOUND, 4);
data2 << 10986;
i->getSource()->GetSession()->SendPacket(&data2);
}
}
}
}
}
}
break;
case DATA_ARCHIMONDEEVENT: Encounters[4] = data; break;
case DATA_RESET_TRASH_COUNT: Trash = 0; break;
case DATA_TRASH:
if (data) Trash = data;
else Trash--;
UpdateWorldState(WORLD_STATE_ENEMYCOUNT, Trash);
break;
case DATA_ALLIANCE_RETREAT:
allianceRetreat = data;
OpenDoor(HordeGate, true);
SaveToDB();
break;
case DATA_HORDE_RETREAT:
hordeRetreat = data;
OpenDoor(ElfGate, true);
SaveToDB();
break;
case DATA_RAIDDAMAGE:
RaidDamage += data;
if (RaidDamage >= MINRAIDDAMAGE)
RaidDamage = MINRAIDDAMAGE;
break;
case DATA_RESET_RAIDDAMAGE:
RaidDamage = 0;
break;
}
sLog->outDebug("TSCR: Instance Hyjal: Instance data updated for event %u (Data=%u)",type, data);
if (data == DONE)
SaveToDB();
}
开发者ID:Maczuga,项目名称:SkyFire_one,代码行数:81,代码来源:instance_hyjal.cpp
示例7: GET_TYPE_FROM_GUID
/*Loot type MUST be
1-corpse, go
2-skinning/herbalism/minning
3-Fishing
*/
void Player::SendLoot(uint64 guid, uint8 loot_type, uint32 mapid)
{
Group* m_Group = m_playerInfo->m_Group;
if(!IsInWorld())
return;
Loot* pLoot = NULL;
uint32 guidtype = GET_TYPE_FROM_GUID(guid);
int8 loot_method;
if(m_Group != NULL)
loot_method = m_Group->GetMethod();
else
loot_method = PARTY_LOOT_FFA;
if(guidtype == HIGHGUID_TYPE_UNIT)
{
Creature* pCreature = GetMapMgr()->GetCreature(GET_LOWGUID_PART(guid));
if(!pCreature)return;
pLoot = &pCreature->loot;
m_currentLoot = pCreature->GetGUID();
}
else if(guidtype == HIGHGUID_TYPE_GAMEOBJECT)
{
GameObject* pGO = GetMapMgr()->GetGameObject(GET_LOWGUID_PART(guid));
if(!pGO)return;
pGO->SetByte(GAMEOBJECT_BYTES_1, 0, 0);
pLoot = &pGO->loot;
m_currentLoot = pGO->GetGUID();
}
else if((guidtype == HIGHGUID_TYPE_PLAYER))
{
Player* p = GetMapMgr()->GetPlayer((uint32)guid);
if(!p)return;
pLoot = &p->loot;
m_currentLoot = p->GetGUID();
}
else if((guidtype == HIGHGUID_TYPE_CORPSE))
{
Corpse* pCorpse = objmgr.GetCorpse((uint32)guid);
if(!pCorpse)return;
pLoot = &pCorpse->loot;
m_currentLoot = pCorpse->GetGUID();
}
else if((guidtype == HIGHGUID_TYPE_ITEM))
{
Item* pItem = GetItemInterface()->GetItemByGUID(guid);
if(!pItem)
return;
pLoot = pItem->loot;
m_currentLoot = pItem->GetGUID();
}
if(!pLoot)
{
// something whack happened.. damn cheaters..
return;
}
// add to looter set
pLoot->looters.insert(GetLowGUID());
WorldPacket data, data2(32);
data.SetOpcode(SMSG_LOOT_RESPONSE);
m_lootGuid = guid;
data << uint64(guid);
data << uint8(loot_type); //loot_type;
data << uint32(pLoot->gold);
data << uint8(0); //loot size reserve
std::vector<__LootItem>::iterator iter = pLoot->items.begin();
uint32 count = 0;
uint8 slottype = 0;
for(uint32 x = 0; iter != pLoot->items.end(); iter++, x++)
{
if(iter->iItemsCount == 0)
continue;
LooterSet::iterator itr = iter->has_looted.find(GetLowGUID());
if(iter->has_looted.end() != itr)
continue;
ItemPrototype* itemProto = iter->item.itemproto;
if(!itemProto)
continue;
//.........这里部分代码省略.........
开发者ID:Carbinfibre,项目名称:ArcPro,代码行数:101,代码来源:PlayerPacketWrapper.cpp
示例8: if
void ClipboardMonitor::checkClipboard(QClipboard::Mode mode)
{
#ifdef COPYQ_WS_X11
m_x11->cancelSynchronization();
#endif
// Check clipboard after interval because someone is updating it very quickly.
bool needToWait = m_updateTimer->isActive();
if (mode == QClipboard::Clipboard)
m_needCheckClipboard = needToWait;
#ifdef COPYQ_WS_X11
else if (mode == QClipboard::Selection)
m_needCheckSelection = needToWait;
#endif
else
return;
m_updateTimer->start();
if (needToWait)
return;
#ifdef COPYQ_WS_X11
if ( mode == QClipboard::Selection && m_x11->isSelectionIncomplete() )
return;
if ( m_x11->maybeResetClipboard(mode) )
return;
#endif
COPYQ_LOG( QString("Checking for new %1 content.")
.arg(mode == QClipboard::Clipboard ? "clipboard" : "selection") );
// get clipboard data
const QMimeData *data = clipboardData(mode);
// data retrieved?
if (!data) {
log( tr("Cannot access clipboard data!"), LogError );
return;
}
// clone only mime types defined by user
#if defined(Q_OS_MAC)
// On OS X, when you copy files in Finder, etc. you get:
// - The file name(s) (not paths) as plain text
// - The file URI(s)
// - The icon (not thumbnail) for the type of item you have in various image formants
// We really only want the URI list, so throw the rest away
QStringList formats = m_formats;
if (data->formats().contains(mimeUriList) && formats.contains(mimeUriList)) {
formats = QStringList() << mimeUriList;
}
QVariantMap data2( cloneData(*data, formats) );
#else
QVariantMap data2( cloneData(*data, m_formats) );
#endif
// add window title of clipboard owner
if ( !data2.contains(mimeOwner) && !data2.contains(mimeWindowTitle) ) {
PlatformPtr platform = createPlatformNativeInterface();
PlatformWindowPtr currentWindow = platform->getCurrentWindow();
if (currentWindow)
data2.insert( mimeWindowTitle, currentWindow->getTitle().toUtf8() );
}
#ifdef COPYQ_WS_X11
m_x11->setData(mode, data2);
if (mode == QClipboard::Clipboard) {
if ( !ownsClipboardData(data2) && m_x11->synchronize(QClipboard::Selection) )
m_needCheckSelection = false;
clipboardChanged(data2);
} else {
data2.insert(mimeClipboardMode, "selection");
if ( !ownsClipboardData(data2) && m_x11->synchronize(QClipboard::Clipboard) )
m_needCheckClipboard = false;
if ( m_x11->hasCheckSelection() )
clipboardChanged(data2);
}
#else /* !COPYQ_WS_X11 */
clipboardChanged(data2);
#endif
}
开发者ID:lmbrt,项目名称:CopyQ,代码行数:82,代码来源:clipboardmonitor.cpp
示例9: BOOST_FIXTURE_TEST_CASE
BOOST_FIXTURE_TEST_CASE(EndToEnd6, EndToEndFixture)
{
UdpFactory factory;
factory.createChannel("::1", "20071");
factory.createFace(FaceUri("udp://[::1]:20070"),
bind(&EndToEndFixture::channel2_onFaceCreated, this, _1),
bind(&EndToEndFixture::channel2_onConnectFailed, this, _1));
BOOST_CHECK_MESSAGE(limitedIo.run(1, time::seconds(1)) == LimitedIo::EXCEED_OPS,
"UdpChannel error: cannot connect or cannot accept connection");
BOOST_REQUIRE(static_cast<bool>(face2));
BOOST_CHECK_EQUAL(face2->getRemoteUri().toString(), "udp6://[::1]:20070");
BOOST_CHECK_EQUAL(face2->getLocalUri().toString(), "udp6://[::1]:20071");
BOOST_CHECK_EQUAL(face2->isLocal(), false);
// face1 is not created yet
shared_ptr<UdpChannel> channel1 = factory.createChannel("::1", "20070");
channel1->listen(bind(&EndToEndFixture::channel1_onFaceCreated, this, _1),
bind(&EndToEndFixture::channel1_onConnectFailed, this, _1));
Interest interest1("ndn:/TpnzGvW9R");
Data data1 ("ndn:/KfczhUqVix");
data1.setContent(0, 0);
Interest interest2("ndn:/QWiIMfj5sL");
Data data2 ("ndn:/XNBV796f");
data2.setContent(0, 0);
Interest interest3("ndn:/QWiIhjgkj5sL");
Data data3 ("ndn:/XNBV794f");
data3.setContent(0, 0);
ndn::SignatureSha256WithRsa fakeSignature;
fakeSignature.setValue(ndn::dataBlock(tlv::SignatureValue,
reinterpret_cast<const uint8_t*>(0),
0));
// set fake signature on data1 and data2
data1.setSignature(fakeSignature);
data2.setSignature(fakeSignature);
data3.setSignature(fakeSignature);
face2->sendInterest(interest2);
face2->sendData (data2 );
BOOST_CHECK_MESSAGE(limitedIo.run(3,//2 send + 1 listen return
time::seconds(1)) == LimitedIo::EXCEED_OPS,
"UdpChannel error: cannot send or receive Interest/Data packets");
BOOST_REQUIRE(static_cast<bool>(face1));
BOOST_CHECK_EQUAL(face1->getRemoteUri().toString(), "udp6://[::1]:20071");
BOOST_CHECK_EQUAL(face1->getLocalUri().toString(), "udp6://[::1]:20070");
BOOST_CHECK_EQUAL(face1->isLocal(), false);
face1->sendInterest(interest1);
face1->sendData (data1 );
BOOST_CHECK_MESSAGE(limitedIo.run(2, time::seconds(1)) == LimitedIo::EXCEED_OPS,
"UdpChannel error: cannot send or receive Interest/Data packets");
BOOST_REQUIRE_EQUAL(face1_receivedInterests.size(), 1);
BOOST_REQUIRE_EQUAL(face1_receivedDatas .size(), 1);
BOOST_REQUIRE_EQUAL(face2_receivedInterests.size(), 1);
BOOST_REQUIRE_EQUAL(face2_receivedDatas .size(), 1);
BOOST_CHECK_EQUAL(face1_receivedInterests[0].getName(), interest2.getName());
BOOST_CHECK_EQUAL(face1_receivedDatas [0].getName(), data2.getName());
BOOST_CHECK_EQUAL(face2_receivedInterests[0].getName(), interest1.getName());
BOOST_CHECK_EQUAL(face2_receivedDatas [0].getName(), data1.getName());
//checking if the connection accepting mechanism works properly.
face2->sendData (data3 );
face2->sendInterest(interest3);
BOOST_CHECK_MESSAGE(limitedIo.run(2, time::seconds(1)) == LimitedIo::EXCEED_OPS,
"UdpChannel error: cannot send or receive Interest/Data packets");
BOOST_REQUIRE_EQUAL(face1_receivedInterests.size(), 2);
BOOST_REQUIRE_EQUAL(face1_receivedDatas .size(), 2);
BOOST_CHECK_EQUAL(face1_receivedInterests[1].getName(), interest3.getName());
BOOST_CHECK_EQUAL(face1_receivedDatas [1].getName(), data3.getName());
}
开发者ID:PhilipsIII,项目名称:NFD,代码行数:90,代码来源:udp.cpp
示例10: main
int main(int argc, char** argv)
{
try
{
// Parse the command line
if (argc != 2)
{
std::cerr << "Usage: " << sys::Path::basename(argv[0])
<< " <output NITF pathname prefix>\n\n";
return 1;
}
const std::string outPathnamePrefix(argv[1]);
verifySchemaEnvVariableIsSet();
// In order to make it easier to test segmenting, let's artificially set
// the segment size really small
const size_t numCols = 200;
const size_t maxSize = numCols * 50;
six::XMLControlRegistry xmlRegistry;
xmlRegistry.addCreator(
six::DataType::DERIVED,
new six::XMLControlCreatorT<
six::sidd::DerivedXMLControl>());
six::Container container(six::DataType::DERIVED);
std::vector<six::UByte*> buffers;
// First a single segment without a legend
types::RowCol<size_t> dims1(40, numCols);
std::auto_ptr<six::Data> data1(mockupDerivedData(dims1));
const mem::ScopedArray<sys::ubyte> buffer1(new sys::ubyte[dims1.normL1()]);
std::fill_n(buffer1.get(), dims1.normL1(), 20);
container.addData(data1);
buffers.push_back(buffer1.get());
// Now a single segment with a mono legend
types::RowCol<size_t> dims2(40, numCols);
std::auto_ptr<six::Data> data2(mockupDerivedData(dims2));
const types::RowCol<size_t> legendDims(50, 50);
std::auto_ptr<six::Legend> monoLegend(new six::Legend());
monoLegend->mType = six::PixelType::MONO8I;
monoLegend->mLocation.row = 10;
monoLegend->mLocation.col = 10;
monoLegend->setDims(legendDims);
const mem::ScopedArray<sys::ubyte> buffer2(new sys::ubyte[dims2.normL1()]);
std::fill_n(buffer2.get(), dims2.normL1(), 100);
container.addData(data2, monoLegend);
buffers.push_back(buffer2.get());
// Now a multi-segment without a legend
types::RowCol<size_t> dims3(150, numCols);
std::auto_ptr<six::Data> data3(mockupDerivedData(dims3));
const mem::ScopedArray<sys::ubyte> buffer3(new sys::ubyte[dims3.normL1()]);
std::fill_n(buffer3.get(), dims3.normL1(), 60);
container.addData(data3);
buffers.push_back(buffer3.get());
// Now a multi-segment with an RGB legend
types::RowCol<size_t> dims4(155, numCols);
std::auto_ptr<six::Data> data4(mockupDerivedData(dims4));
std::auto_ptr<six::Legend> rgbLegend(new six::Legend());
rgbLegend->mType = six::PixelType::RGB8LU;
rgbLegend->mLocation.row = 10;
rgbLegend->mLocation.col = 10;
rgbLegend->setDims(legendDims);
rgbLegend->mLUT.reset(new six::LUT(256, 3));
for (size_t ii = 0, idx = 0;
ii < rgbLegend->mLUT->numEntries;
++ii, idx += 3)
{
rgbLegend->mLUT->table[idx] = ii;
rgbLegend->mLUT->table[idx + 1] = ii;
rgbLegend->mLUT->table[idx + 2] = ii;
}
const mem::ScopedArray<sys::ubyte> buffer4(new sys::ubyte[dims4.normL1()]);
std::fill_n(buffer4.get(), dims4.normL1(), 200);
container.addData(data4, rgbLegend);
buffers.push_back(buffer4.get());
// Write it out
{
six::NITFWriteControl writer;
writer.getOptions().setParameter(
six::NITFWriteControl::OPT_MAX_PRODUCT_SIZE,
str::toString(maxSize));
//.........这里部分代码省略.........
开发者ID:BSteine,项目名称:six-library,代码行数:101,代码来源:test_create_sidd_legend.cpp
示例11: DEBUG_LOG
void WorldSession::HandleBattleFieldPortOpcode(WorldPacket& recv_data)
{
DEBUG_LOG("WORLD: Received opcode CMSG_BATTLEFIELD_PORT");
uint8 action; // enter battle 0x1, leave queue 0x0
uint32 mapId;
recv_data >> mapId >> action;
BattleGroundTypeId bgTypeId = GetBattleGroundTypeIdByMapId(mapId);
if (bgTypeId == BATTLEGROUND_TYPE_NONE)
{
sLog.outError("BattlegroundHandler: invalid bg map (%u) received.", mapId);
return;
}
if (!_player->InBattleGroundQueue())
{
sLog.outError("BattlegroundHandler: Invalid CMSG_BATTLEFIELD_PORT received from player (%u), he is not in bg_queue.", _player->GetGUIDLow());
return;
}
// get GroupQueueInfo from BattleGroundQueue
BattleGroundQueueTypeId bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(bgTypeId);
BattleGroundQueue& bgQueue = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId];
// we must use temporary variable, because GroupQueueInfo pointer can be deleted in BattleGroundQueue::RemovePlayer() function
GroupQueueInfo ginfo;
if (!bgQueue.GetPlayerGroupInfoData(_player->GetObjectGuid(), &ginfo))
{
sLog.outError("BattlegroundHandler: itrplayerstatus not found.");
return;
}
// if action == 1, then instanceId is required
if (!ginfo.IsInvitedToBGInstanceGUID && action == 1)
{
sLog.outError("BattlegroundHandler: instance not found.");
return;
}
BattleGround* bg = sBattleGroundMgr.GetBattleGround(ginfo.IsInvitedToBGInstanceGUID, bgTypeId);
// bg template might and must be used in case of leaving queue, when instance is not created yet
if (!bg && action == 0)
bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId);
if (!bg)
{
sLog.outError("BattlegroundHandler: bg_template not found for type id %u.", bgTypeId);
return;
}
// some checks if player isn't cheating - it is not exactly cheating, but we cannot allow it
if (action == 1)
{
// if player is trying to enter battleground and he has deserter debuff, we must just remove him from queue
if (!_player->CanJoinToBattleground())
{
// send bg command result to show nice message
WorldPacket data2(SMSG_GROUP_JOINED_BATTLEGROUND, 4);
data2 << uint32(0xFFFFFFFE);
_player->GetSession()->SendPacket(&data2);
action = 0;
DEBUG_LOG("Battleground: player %s (%u) has a deserter debuff, do not port him to battleground!", _player->GetName(), _player->GetGUIDLow());
}
// if player don't match battleground max level, then do not allow him to enter! (this might happen when player leveled up during his waiting in queue
if (_player->getLevel() > bg->GetMaxLevel())
{
sLog.outError("Battleground: Player %s (%u) has level (%u) higher than maxlevel (%u) of battleground (%u)! Do not port him to battleground!",
_player->GetName(), _player->GetGUIDLow(), _player->getLevel(), bg->GetMaxLevel(), bg->GetTypeID());
action = 0;
}
}
uint32 queueSlot = _player->GetBattleGroundQueueIndex(bgQueueTypeId);
WorldPacket data;
switch (action)
{
case 1: // port to battleground
if (!_player->IsInvitedForBattleGroundQueueType(bgQueueTypeId))
return; // cheating?
// resurrect the player
if (!_player->isAlive())
{
_player->ResurrectPlayer(1.0f);
_player->SpawnCorpseBones();
}
// stop taxi flight at port
if (_player->IsTaxiFlying())
{
_player->GetMotionMaster()->MovementExpired();
_player->m_taxi.ClearTaxiDestinations();
}
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, queueSlot, STATUS_IN_PROGRESS, 0, bg->GetStartTime());
_player->GetSession()->SendPacket(&data);
// remove battleground queue status from BGmgr
bgQueue.RemovePlayer(_player->GetObjectGuid(), false);
// this is still needed here if battleground "jumping" shouldn't add deserter debuff
// also this is required to prevent stuck at old battleground after SetBattleGroundId set to new
if (BattleGround* currentBg = _player->GetBattleGround())
currentBg->RemovePlayerAtLeave(_player->GetObjectGuid(), false, true);
//.........这里部分代码省略.........
开发者ID:520lly,项目名称:mangos-classic,代码行数:101,代码来源:BattleGroundHandler.cpp
示例12: data2
string fmitcp::dataToString(const char* data, long size) {
std::string data2(data, size);
return data2;
}
开发者ID:jemmy655,项目名称:fmi-tcp,代码行数:4,代码来源:common.cpp
示例13: data
void Channel::Part(RPlayerInfo* plr, bool silent)
{
if(plr == NULL || plr->GetSession() == NULL)
return;
m_lock.Acquire();
WorldPacket data(SMSG_CHANNEL_NOTIFY, 100);
uint32 flags;
MemberMap::iterator itr = m_members.find(plr);
if(itr == m_members.end())
{
data << uint8(CHANNEL_NOTIFY_FLAG_NOTON) << m_name;
plr->GetSession()->SendPacket(&data);
m_lock.Release();
return;
}
flags = itr->second;
m_members.erase(itr);
WorldPacket data2(ISMSG_CHANNEL_ACTION, 9);
data2 << uint8(CHANNEL_PART); // left channel
data2 << uint32(plr->Guid);
data2 << uint32(m_channelId);
plr->GetSession()->GetServer()->SendPacket(&data2);
if(flags & CHANNEL_FLAG_OWNER)
{
// we need to find a new owner
SetOwner(NULL, NULL);
}
if(plr->GetSession())
{
if( !silent )
{
data << uint8(CHANNEL_NOTIFY_FLAG_YOULEFT) << m_name << m_typeId << uint32(0) << uint8(0);
plr->GetSession()->SendPacket(&data);
}
}
if(m_announce)
{
data.clear();
data << uint8(CHANNEL_NOTIFY_FLAG_LEFT) << m_name << uint64(plr->Guid);
SendToAll(&data);
}
#ifndef WIN32
if(m_members.size() == 0 )
{
m_lock.Release();
channelmgr.RemoveChannel(this);
}
else
m_lock.Release();
#else
m_lock.Release();
#endif
}
开发者ID:Bootz,项目名称:arcticdev,代码行数:61,代码来源:Channel.cpp
示例14: main
int main (int argc, char** argv)
{
// get run number
std::string inputName = std::string(argv[1]);
char split_char = '/';
std::vector<std::string> tokens;
std::istringstream split(inputName);
for(std::string each; getline(split, each, split_char);
tokens.push_back(each));
split_char = '_';
std::vector<std::string> tokens_name;
std::istringstream split_name(tokens.at(1));
for(std::string each; getline(split_name, each, split_char);
tokens_name.push_back(each));
const int Ch_ref1 = atoi((tokens_name.at(1)).c_str());
const int Ch_ref2 = atoi((tokens_name.at(3)).c_str());
const int Ch_1 = atoi((tokens_name.at(5)).c_str());
const int Ch_2 = atoi((tokens_name.at(7)).c_str());
const int Ch_3 = atoi((tokens_name.at(9)).c_str());
std::vector<std::string> nameMCP;
nameMCP.push_back("MiB1");
nameMCP.push_back("MiB2");
nameMCP.push_back("ScB");
nameMCP.push_back("Planacon");
nameMCP.push_back("MiB3");
nameMCP.push_back("Roma2");
if(tokens_name.at(0) == "Scan3") nameMCP.at(1) = "Roma1";
std::vector<std::string> pcMCP;
for(unsigned int ii=0; ii<nameMCP.size(); ++ii) pcMCP.push_back("");
pcMCP.at(Ch_ref1) = tokens_name.at(2);
pcMCP.at(Ch_ref2) = tokens_name.at(4);
pcMCP.at(Ch_1) = tokens_name.at(6);
pcMCP.at(Ch_2) = tokens_name.at(8);
pcMCP.at(Ch_3) = tokens_name.at(10);
//---treshold setup Scan-dependent
init();
const int iScanTh = atoi(argv[2])-1;
float Ch_th[6]={0,0,0,0,0,0};
Ch_th[Ch_ref1] = _th[iScanTh][Ch_ref1];
Ch_th[Ch_ref2] = _th[iScanTh][Ch_ref2];
Ch_th[Ch_1] = _th[iScanTh][Ch_1];
Ch_th[Ch_2] = _th[iScanTh][Ch_2];
Ch_th[Ch_3] = _th[iScanTh][Ch_3];
TFile* out = TFile::Open((tokens_name.at(0)+"_outHistos.root").c_str(),"recreate");
out->cd();
//Output dat
std::ofstream data1(("analized_data/"+tokens_name.at(0)+"_"+nameMCP.at(Ch_1)+"_pc_"+pcMCP.at(Ch_1)+".dat").data());
std::ofstream data2(("analized_data/"+tokens_name.at(0)+"_"+nameMCP.at(Ch_2)+"_pc_"+pcMCP.at(Ch_2)+".dat").data());
std::ofstream data3(("analized_data/"+tokens_name.at(0)+"_"+nameMCP.at(Ch_3)+"_pc_"+pcMCP.at(Ch_3)+".dat").data());
int nFiles = 1, iRun = 0, goodEvt = 0;
int iScan = 0;
//---usefull histos
TH1F* chHistoBase_All[9];
TH1F* chHistoSignal_All[9];
TH1F* timeDiffHisto[9];
TH1F* timeDiffHisto_Double = new TH1F("timeDiffHisto_Double", "timeDiffHisto_Double",5000,-10,10);
//---histos initialization
for(int iCh=0; iCh<6; ++iCh)
{
char h1[30], h2[30], h3[30];
sprintf(h1, "histoBase_All_Ch%d", iCh);
sprintf(h2, "histoSignal_All_Ch%d", iCh);
sprintf(h3, "histoTime_Ch%d", iCh);
chHistoBase_All[iCh] = new TH1F(h1,h1,30000,-30000,1000);
chHistoSignal_All[iCh] = new TH1F(h2, h2,30000,-30000,1000);
timeDiffHisto[iCh] = new TH1F(h3, h3,1024,0,1024);
}
//---do runs loop
ifstream log (argv[1], ios::in);
while(log >> nFiles)
{
++iScan;
vector<float> digiCh[9];
float timeCF[9];
float baseline[9];
float intSignal[9], intBase[9];
int count[5]={0,0,0,0,0}, spare[5]={0,0,0,0,0}, spare2[5]={0,0,0,0,0};
int tot_tr1 = 0, tot_tr0 = 0, trig = 0;
int HV1=0, HV2=0, HV3=0;
TH1F* chHistoWF_Ch[9];
TH1F* chHistoBase_Ch[9];
TH1F* chHistoSignal_Ch[9];
TH1F* timeDiffHisto_Triple_Ch1 = new TH1F(Form("timeDiffHisto_Triple_Ch1_Scan%d",iScan), "", 5000,-100,100);
TH1F* timeDiffHisto_Triple_Ch2 = new TH1F(Form("timeDiffHisto_Triple_Ch2_Scan%d",iScan), "", 5000,-100,100);
TH1F* timeDiffHisto_Triple_Ch3 = new TH1F(Form("timeDiffHisto_Triple_Ch3_Scan%d",iScan), "", 5000,-100,100);
char ha[10];
//.........这里部分代码省略.........
开发者ID:amartelli,项目名称:IMCP_BTFAnalysis,代码行数:101,代码来源:thScan.cpp
示例15: main
int main(int argc, char **argv)
{
//
// local variables used in test
//
Domain theDomain;
FEM_ObjectBroker theBroker;
int numColumns = 5;
char *columns[numColumns];
char column1[] = "col1";
char column2[] = "col2";
char column3[] = "col3";
char column4[] = "col4";
char column5[] = "col5";
columns[0] = column1;
columns[1] = column2;
columns[2] = column3;
columns[3] = column4;
columns[4] = column5;
int result, result1, result2, result3, result4;
Vector data1(numColumns);
Vector data2(numColumns-1);
for (int i=0; i<numColumns; i++)
data1(i) = i+1;
for (int i=0; i<numColumns-1; i++)
data2(i) = i+1;
FileDatastore theDatabase("testDatabase", theDomain, theBroker);
opserr << " *******************************************************************\n";
opserr << " DataOutputDatabaseHandler unit test\n";
opserr << " *******************************************************************\n\n";
opserr << " The DataOutputFile class provides implements 2 methods \n";
opserr << " open() - to open a connection to the o/p stream";
opserr << " write() - to send the contents of a vector to this stream\n\n";
opserr << " *******************************************************************\n";
//
// first test we can create DataOutputFile object to test.
//
opserr << "TEST: Creation of DataOutputFile object - will create 4 objects 1,2,3 and 4 (3,4 have no assigned database)\n";
DataOutputDatabaseHandler *theHandler1 = new DataOutputDatabaseHandler(&theDatabase, "UnitTest1");
DataOutputDatabaseHandler *theHandler2 = new DataOutputDatabaseHandler(&theDatabase, "UnitTest2");
DataOutputDatabaseHandler *theHandler3 = new DataOutputDatabaseHandler(0, "UnitTest3");
DataOutputDatabaseHandler *theHandler4 = new DataOutputDatabaseHandler(0, 0);
if (theHandler1 != 0 && theHandler2 != 0 && theHandler3 != 0 && theHandler4 != 0)
opserr << "PASS: Creation of DataOutputDatabaseHandler object\n\n";
else {
opserr << "FAIL: Creation of DataOutputDatabaseHandle
|
请发表评论