本文整理汇总了C++中data函数的典型用法代码示例。如果您正苦于以下问题:C++ data函数的具体用法?C++ data怎么用?C++ data使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了data函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: TestWStream
static void TestWStream(skiatest::Reporter* reporter) {
SkDynamicMemoryWStream ds;
const char s[] = "abcdefghijklmnopqrstuvwxyz";
int i;
for (i = 0; i < 100; i++) {
REPORTER_ASSERT(reporter, ds.write(s, 26));
}
REPORTER_ASSERT(reporter, ds.getOffset() == 100 * 26);
char* dst = new char[100 * 26 + 1];
dst[100*26] = '*';
ds.copyTo(dst);
REPORTER_ASSERT(reporter, dst[100*26] == '*');
for (i = 0; i < 100; i++) {
REPORTER_ASSERT(reporter, memcmp(&dst[i * 26], s, 26) == 0);
}
{
SkAutoTDelete<SkStreamAsset> stream(ds.detachAsStream());
REPORTER_ASSERT(reporter, 100 * 26 == stream->getLength());
REPORTER_ASSERT(reporter, ds.getOffset() == 0);
test_loop_stream(reporter, stream.get(), s, 26, 100);
SkAutoTDelete<SkStreamAsset> stream2(stream->duplicate());
test_loop_stream(reporter, stream2.get(), s, 26, 100);
SkAutoTDelete<SkStreamAsset> stream3(stream->fork());
REPORTER_ASSERT(reporter, stream3->isAtEnd());
char tmp;
size_t bytes = stream->read(&tmp, 1);
REPORTER_ASSERT(reporter, 0 == bytes);
stream3->rewind();
test_loop_stream(reporter, stream3.get(), s, 26, 100);
}
for (i = 0; i < 100; i++) {
REPORTER_ASSERT(reporter, ds.write(s, 26));
}
REPORTER_ASSERT(reporter, ds.getOffset() == 100 * 26);
{
sk_sp<SkData> data(ds.copyToData());
REPORTER_ASSERT(reporter, 100 * 26 == data->size());
REPORTER_ASSERT(reporter, memcmp(dst, data->data(), data->size()) == 0);
}
{
// Test that this works after a copyToData.
SkAutoTDelete<SkStreamAsset> stream(ds.detachAsStream());
REPORTER_ASSERT(reporter, ds.getOffset() == 0);
test_loop_stream(reporter, stream.get(), s, 26, 100);
SkAutoTDelete<SkStreamAsset> stream2(stream->duplicate());
test_loop_stream(reporter, stream2.get(), s, 26, 100);
}
delete[] dst;
SkString tmpDir = skiatest::GetTmpDir();
if (!tmpDir.isEmpty()) {
test_filestreams(reporter, tmpDir.c_str());
}
}
开发者ID:03050903,项目名称:skia,代码行数:62,代码来源:StreamTest.cpp
示例2: DEBUG_LOG
/*this procedure handles clients CMSG_REQUEST_PARTY_MEMBER_STATS request*/
void WorldSession::HandleRequestPartyMemberStatsOpcode( WorldPacket &recv_data )
{
DEBUG_LOG("WORLD: Received CMSG_REQUEST_PARTY_MEMBER_STATS");
uint64 Guid;
recv_data >> Guid;
Player *player = sObjectMgr.GetPlayer(Guid);
if(!player)
{
WorldPacket data(SMSG_PARTY_MEMBER_STATS_FULL, 3+4+2);
data.appendPackGUID(Guid);
data << uint32(GROUP_UPDATE_FLAG_STATUS);
data << uint8(MEMBER_STATUS_OFFLINE);
SendPacket(&data);
return;
}
Pet *pet = player->GetPet();
WorldPacket data(SMSG_PARTY_MEMBER_STATS_FULL, 4+2+2+2+1+2*6+8+1+8);
data << player->GetPackGUID();
uint32 mask1 = 0x00040BFF; // common mask, real flags used 0x000040BFF
if(pet)
mask1 = 0x7FFFFFFF; // for hunters and other classes with pets
Powers powerType = player->getPowerType();
data << uint32(mask1); // group update mask
data << uint8(MEMBER_STATUS_ONLINE); // member's online status
data << uint16(player->GetHealth()); // GROUP_UPDATE_FLAG_CUR_HP
data << uint16(player->GetMaxHealth()); // GROUP_UPDATE_FLAG_MAX_HP
data << uint8(powerType); // GROUP_UPDATE_FLAG_POWER_TYPE
data << uint16(player->GetPower(powerType)); // GROUP_UPDATE_FLAG_CUR_POWER
data << uint16(player->GetMaxPower(powerType)); // GROUP_UPDATE_FLAG_MAX_POWER
data << uint16(player->getLevel()); // GROUP_UPDATE_FLAG_LEVEL
data << uint16(player->GetZoneId()); // GROUP_UPDATE_FLAG_ZONE
data << uint16(player->GetPositionX()); // GROUP_UPDATE_FLAG_POSITION
data << uint16(player->GetPositionY()); // GROUP_UPDATE_FLAG_POSITION
uint32 auramask = 0;
size_t maskPos = data.wpos();
data << uint32(auramask); // placeholder
for(uint8 i = 0; i < MAX_AURAS; ++i)
{
if(uint32 aura = player->GetUInt32Value(UNIT_FIELD_AURA + i))
{
auramask |= (uint32(1) << i);
data << uint16(aura);
}
}
data.put<uint32>(maskPos,auramask); // GROUP_UPDATE_FLAG_AURAS
if(pet)
{
Powers petpowertype = pet->getPowerType();
data << uint64(pet->GetGUID()); // GROUP_UPDATE_FLAG_PET_GUID
data << pet->GetName(); // GROUP_UPDATE_FLAG_PET_NAME
data << uint16(pet->GetDisplayId()); // GROUP_UPDATE_FLAG_PET_MODEL_ID
data << uint16(pet->GetHealth()); // GROUP_UPDATE_FLAG_PET_CUR_HP
data << uint16(pet->GetMaxHealth()); // GROUP_UPDATE_FLAG_PET_MAX_HP
data << uint8(petpowertype); // GROUP_UPDATE_FLAG_PET_POWER_TYPE
data << uint16(pet->GetPower(petpowertype)); // GROUP_UPDATE_FLAG_PET_CUR_POWER
data << uint16(pet->GetMaxPower(petpowertype)); // GROUP_UPDATE_FLAG_PET_MAX_POWER
uint32 petauramask = 0;
size_t petMaskPos = data.wpos();
data << uint32(petauramask); // placeholder
for(uint8 i = 0; i < MAX_AURAS; ++i)
{
if(uint32 petaura = pet->GetUInt32Value(UNIT_FIELD_AURA + i))
{
petauramask |= (uint32(1) << i);
data << uint16(petaura);
}
}
data.put<uint32>(petMaskPos,petauramask); // GROUP_UPDATE_FLAG_PET_AURAS
}
else
{
data << uint8(0); // GROUP_UPDATE_FLAG_PET_NAME
data << uint32(0); // GROUP_UPDATE_FLAG_PET_AURAS
}
SendPacket(&data);
}
开发者ID:daemonaps,项目名称:mangoszero,代码行数:86,代码来源:GroupHandler.cpp
示例3: ASSERT
ResultCode HLERequestContext::PopulateFromIncomingCommandBuffer(const u32_le* src_cmdbuf,
Process& src_process,
HandleTable& src_table) {
IPC::Header header{src_cmdbuf[0]};
std::size_t untranslated_size = 1u + header.normal_params_size;
std::size_t command_size = untranslated_size + header.translate_params_size;
ASSERT(command_size <= IPC::COMMAND_BUFFER_LENGTH); // TODO(yuriks): Return error
std::copy_n(src_cmdbuf, untranslated_size, cmd_buf.begin());
std::size_t i = untranslated_size;
while (i < command_size) {
u32 descriptor = cmd_buf[i] = src_cmdbuf[i];
i += 1;
switch (IPC::GetDescriptorType(descriptor)) {
case IPC::DescriptorType::CopyHandle:
case IPC::DescriptorType::MoveHandle: {
u32 num_handles = IPC::HandleNumberFromDesc(descriptor);
ASSERT(i + num_handles <= command_size); // TODO(yuriks): Return error
for (u32 j = 0; j < num_handles; ++j) {
Handle handle = src_cmdbuf[i];
SharedPtr<Object> object = nullptr;
if (handle != 0) {
object = src_table.GetGeneric(handle);
ASSERT(object != nullptr); // TODO(yuriks): Return error
if (descriptor == IPC::DescriptorType::MoveHandle) {
src_table.Close(handle);
}
}
cmd_buf[i++] = AddOutgoingHandle(std::move(object));
}
break;
}
case IPC::DescriptorType::CallingPid: {
cmd_buf[i++] = src_process.process_id;
break;
}
case IPC::DescriptorType::StaticBuffer: {
VAddr source_address = src_cmdbuf[i];
IPC::StaticBufferDescInfo buffer_info{descriptor};
// Copy the input buffer into our own vector and store it.
std::vector<u8> data(buffer_info.size);
Memory::ReadBlock(src_process, source_address, data.data(), data.size());
AddStaticBuffer(buffer_info.buffer_id, std::move(data));
cmd_buf[i++] = source_address;
break;
}
case IPC::DescriptorType::MappedBuffer: {
u32 next_id = static_cast<u32>(request_mapped_buffers.size());
request_mapped_buffers.emplace_back(src_process, descriptor, src_cmdbuf[i], next_id);
cmd_buf[i++] = next_id;
break;
}
default:
UNIMPLEMENTED_MSG("Unsupported handle translation: {:#010X}", descriptor);
}
}
return RESULT_SUCCESS;
}
开发者ID:lioncash,项目名称:citra,代码行数:65,代码来源:hle_ipc.cpp
示例4: CHECK_PACKET_SIZE
//////////////////////////////////////////////////////////////
/// This function handles CMSG_GAMEOBJECT_QUERY:
//////////////////////////////////////////////////////////////
void WorldSession::HandleGameObjectQueryOpcode(WorldPacket & recv_data)
{
CHECK_INWORLD_RETURN
CHECK_PACKET_SIZE(recv_data, 10);
WorldPacket data(SMSG_GAMEOBJECT_QUERY_RESPONSE, 900);
uint32 entryID;
uint64 guid;
GameObjectInfo* goinfo;
recv_data >> entryID;
recv_data >> guid;
LOG_DETAIL("WORLD: CMSG_GAMEOBJECT_QUERY '%u'", entryID);
goinfo = GameObjectNameStorage.LookupEntry(entryID);
if(goinfo == NULL)
return;
LocalizedGameObjectName* lgn = (language > 0) ? sLocalizationMgr.GetLocalizedGameObjectName(entryID, language) : NULL;
data << entryID; // unique identifier of the GO template
data << goinfo->Type; // type of the gameobject
data << goinfo->DisplayID; // displayid/modelid of the gameobject
// Name of the gameobject
if(lgn)
data << lgn->Name;
else
data << goinfo->Name;
data << uint8(0); // name2, always seems to be empty
data << uint8(0); // name3, always seems to be empty
data << uint8(0); // name4, always seems to be empty
data << goinfo->Category; // Category string of the GO, like "attack", "pvp", "point", etc
data << goinfo->Castbartext; // text displayed when using the go, like "collecting", "summoning" etc
data << goinfo->Unkstr;
data << goinfo->SpellFocus; // spellfocus id, ex.: spell casted when interacting with the GO
data << goinfo->sound1;
data << goinfo->sound2;
data << goinfo->sound3;
data << goinfo->sound4;
data << goinfo->sound5;
data << goinfo->sound6;
data << goinfo->sound7;
data << goinfo->sound8;
data << goinfo->sound9;
data << goinfo->Unknown1;
data << goinfo->Unknown2;
data << goinfo->Unknown3;
data << goinfo->Unknown4;
data << goinfo->Unknown5;
data << goinfo->Unknown6;
data << goinfo->Unknown7;
data << goinfo->Unknown8;
data << goinfo->Unknown9;
data << goinfo->Unknown10;
data << goinfo->Unknown11;
data << goinfo->Unknown12;
data << goinfo->Unknown13;
data << goinfo->Unknown14;
data << uint32(0);
data << uint32(0);
data << uint32(0);
data << uint32(0);
data << uint32(0);
data << uint32(0);
data << uint32(0);
data << uint32(0);
// Questitems that the go can contain
for(uint32 i = 0; i < 6; ++i)
{
data << uint32(goinfo->QuestItems[i]);
}
data < uint32(0); // Go expansion field
SendPacket(&data);
}
开发者ID:Carbinfibre,项目名称:ArcPro,代码行数:86,代码来源:QueryHandler.cpp
示例5: main
int main(int argc, char const *argv[])
{
if (argc != 4)
{
std::cerr << "Usage: ./thlsh_test data_file lsh_file benchmark_file" << std::endl;
return -1;
}
std::cout << "Example of using Thresholding LSH" << std::endl << std::endl;
typedef float DATATYPE;
std::cout << "LOADING DATA ..." << std::endl;
lshbox::timer timer;
lshbox::Matrix<DATATYPE> data(argv[1]);
std::cout << "LOAD TIME: " << timer.elapsed() << "s." << std::endl;
std::cout << "CONSTRUCTING INDEX ..." << std::endl;
timer.restart();
std::string file(argv[2]);
bool use_index = false;
lshbox::thLsh<DATATYPE> mylsh;
if (use_index)
{
mylsh.load(file);
}
else
{
lshbox::thLsh<DATATYPE>::Parameter param;
param.M = 521;
param.L = 5;
param.D = data.getDim();
param.N = 12;
param.Max = std::numeric_limits<float>::max();
param.Min = - std::numeric_limits<float>::max();
for (unsigned i = 0; i != data.getSize(); ++i)
{
for (unsigned j = 0; j != data.getDim(); ++j)
{
if (data[i][j] > param.Max)
{
param.Max = data[i][j];
}
if (data[i][j] < param.Min)
{
param.Min = data[i][j];
}
}
}
mylsh.reset(param);
lshbox::progress_display pd(data.getSize());
for (unsigned i = 0; i != data.getSize(); ++i)
{
mylsh.insert(i, data[i]);
++pd;
}
}
mylsh.save(file);
std::cout << "CONSTRUCTING TIME: " << timer.elapsed() << "s." << std::endl;
std::cout << "LOADING BENCHMARK ..." << std::endl;
timer.restart();
lshbox::Matrix<DATATYPE>::Accessor accessor(data);
lshbox::Metric<DATATYPE> metric(data.getDim(), L1_DIST);
lshbox::Benchmark bench;
std::string benchmark(argv[3]);
bench.load(benchmark);
unsigned K = bench.getK();
lshbox::Scanner<lshbox::Matrix<DATATYPE>::Accessor> scanner(
accessor,
metric,
K
);
std::cout << "LOADING TIME: " << timer.elapsed() << "s." << std::endl;
std::cout << "RUNING QUERY ..." << std::endl;
timer.restart();
lshbox::Stat cost, recall, precision;
lshbox::progress_display pd(bench.getQ());
for (unsigned i = 0; i != bench.getQ(); ++i)
{
scanner.reset(data[bench.getQuery(i)]);
mylsh.query(data[bench.getQuery(i)], scanner);
scanner.topk().genTopk();
recall << bench.getAnswer(i).recall(scanner.topk());
recall << bench.getAnswer(i).precision(scanner.topk());
cost << float(scanner.cnt()) / float(data.getSize());
++pd;
}
std::cout << "MEAN QUERY TIME: " << timer.elapsed() / bench.getQ() << "s." << std::endl;
std::cout << "RECALL : " << recall.getAvg() << " +/- " << recall.getStd() << std::endl;
std::cout << "PRECISION: " << recall.getAvg() << " +/- " << recall.getStd() << std::endl;
std::cout << "COST : " << cost.getAvg() << " +/- " << cost.getStd() << std::endl;
// scanner.reset(data[0]);
// mylsh.query(data[0], scanner);
// scanner.topk().genTopk();
// std::vector<std::pair<float, unsigned> > res = scanner.topk().getTopk();
// for (std::vector<std::pair<float, unsigned> >::iterator it = res.begin(); it != res.end(); ++it)
// {
// std::cout << it->second << ": " << it->first << std::endl;
// }
// std::cout << "DISTANCE COMPARISON TIMES: " << scanner.cnt() << std::endl;
}
开发者ID:xionluhnis,项目名称:LSHBOX,代码行数:98,代码来源:thlsh_test.cpp
示例6: data
QVariant DailymotionAccountModel::data(int row, const QByteArray &role) const {
return data(index(row, 0), m_roles.key(role));
}
开发者ID:freemangordon,项目名称:cutetube2,代码行数:3,代码来源:dailymotionaccountmodel.cpp
示例7: tgaLoad
// this is the function to call when we want to load an image
tImageTGA * tgaLoad(const char *pszFilename)
{
int mode,total;
tImageTGA *info = NULL;
CCFileData data(pszFilename, "rb");
unsigned long nSize = data.getSize();
unsigned char* pBuffer = data.getBuffer();
do
{
CC_BREAK_IF(!pBuffer);
info = (tImageTGA *)malloc(sizeof(tImageTGA));
// get the file header info
if (!tgaLoadHeader(pBuffer, nSize, info))
{
info->status = TGA_ERROR_MEMORY;
break;
}
// check if the image is color indexed
if (info->type == 1)
{
info->status = TGA_ERROR_INDEXED_COLOR;
break;
}
// check for other types (compressed images)
if ((info->type != 2) && (info->type !=3) && (info->type !=10))
{
info->status = TGA_ERROR_COMPRESSED_FILE;
break;
}
// mode equals the number of image components
mode = info->pixelDepth / 8;
// total is the number of unsigned chars to read
total = info->height * info->width * mode;
// allocate memory for image pixels
info->imageData = (unsigned char *)malloc(sizeof(unsigned char) * total);
// check to make sure we have the memory required
if (info->imageData == NULL)
{
info->status = TGA_ERROR_MEMORY;
break;
}
bool bLoadImage = false;
// finally load the image pixels
if (info->type == 10)
{
bLoadImage = tgaLoadRLEImageData(pBuffer, nSize, info);
}
else
{
bLoadImage = tgaLoadImageData(pBuffer, nSize, info);
}
// check for errors when reading the pixels
if (!bLoadImage)
{
info->status = TGA_ERROR_READING_FILE;
break;
}
info->status = TGA_OK;
if (info->flipped)
{
tgaFlipImage(info);
if (info->flipped)
{
info->status = TGA_ERROR_MEMORY;
}
}
} while (0);
return info;
}
开发者ID:LiangYue1981816,项目名称:CrossEngine,代码行数:80,代码来源:TGAlib.cpp
示例8: llassert
// decode a given message
BOOL LLTemplateMessageReader::decodeData(const U8* buffer, const LLHost& sender )
{
llassert( mReceiveSize >= 0 );
llassert( mCurrentRMessageTemplate);
llassert( !mCurrentRMessageData );
delete mCurrentRMessageData; // just to make sure
// The offset tells us how may bytes to skip after the end of the
// message name.
U8 offset = buffer[PHL_OFFSET];
S32 decode_pos = LL_PACKET_ID_SIZE + (S32)(mCurrentRMessageTemplate->mFrequency) + offset;
// create base working data set
mCurrentRMessageData = new LLMsgData(mCurrentRMessageTemplate->mName);
// loop through the template building the data structure as we go
LLMessageTemplate::message_block_map_t::const_iterator iter;
for(iter = mCurrentRMessageTemplate->mMemberBlocks.begin();
iter != mCurrentRMessageTemplate->mMemberBlocks.end();
++iter)
{
LLMessageBlock* mbci = *iter;
U8 repeat_number;
S32 i;
// how many of this block?
if (mbci->mType == MBT_SINGLE)
{
// just one
repeat_number = 1;
}
else if (mbci->mType == MBT_MULTIPLE)
{
// a known number
repeat_number = mbci->mNumber;
}
else if (mbci->mType == MBT_VARIABLE)
{
// need to read the number from the message
// repeat number is a single byte
if (decode_pos >= mReceiveSize)
{
// commented out - hetgrid says that missing variable blocks
// at end of message are legal
// logRanOffEndOfPacket(sender, decode_pos, 1);
// default to 0 repeats
repeat_number = 0;
}
else
{
repeat_number = buffer[decode_pos];
decode_pos++;
}
}
else
{
llerrs << "Unknown block type" << llendl;
return FALSE;
}
LLMsgBlkData* cur_data_block = NULL;
// now loop through the block
for (i = 0; i < repeat_number; i++)
{
if (i)
{
// build new name to prevent collisions
// TODO: This should really change to a vector
cur_data_block = new LLMsgBlkData(mbci->mName, repeat_number);
cur_data_block->mName = mbci->mName + i;
}
else
{
cur_data_block = new LLMsgBlkData(mbci->mName, repeat_number);
}
// add the block to the message
mCurrentRMessageData->addBlock(cur_data_block);
// now read the variables
for (LLMessageBlock::message_variable_map_t::const_iterator iter =
mbci->mMemberVariables.begin();
iter != mbci->mMemberVariables.end(); iter++)
{
const LLMessageVariable& mvci = **iter;
// ok, build out the variables
// add variable block
cur_data_block->addVariable(mvci.getName(), mvci.getType());
// what type of variable?
if (mvci.getType() == MVT_VARIABLE)
{
// variable, get the number of bytes to read from the template
S32 data_size = mvci.getSize();
U8 tsizeb = 0;
//.........这里部分代码省略.........
开发者ID:lilly,项目名称:imprudence,代码行数:101,代码来源:lltemplatemessagereader.cpp
示例9: while
//.........这里部分代码省略.........
}
// FG: finish pending transfers after starting the logout
// this should fix players beeing able to logout and login back with full hp at death position
while (_player->IsBeingTeleportedFar())
HandleMoveWorldportAckOpcode();
for (int i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
{
if (BattleGroundQueueTypeId bgQueueTypeId = _player->GetBattleGroundQueueTypeId(i))
{
_player->RemoveBattleGroundQueueId(bgQueueTypeId);
sBattleGroundMgr.m_BattleGroundQueues[ bgQueueTypeId ].RemovePlayer(_player->GetObjectGuid(), true);
}
}
///- Reset the online field in the account table
// no point resetting online in character table here as Player::SaveToDB() will set it to 1 since player has not been removed from world at this stage
// No SQL injection as AccountID is uint32
static SqlStatementID id;
SqlStatement stmt = LoginDatabase.CreateStatement(id, "UPDATE account SET active_realm_id = ? WHERE id = ?");
stmt.PExecute(uint32(0), GetAccountId());
///- If the player is in a guild, update the guild roster and broadcast a logout message to other guild members
if (Guild* guild = sGuildMgr.GetGuildById(_player->GetGuildId()))
{
if (MemberSlot* slot = guild->GetMemberSlot(_player->GetObjectGuid()))
{
slot->SetMemberStats(_player);
slot->UpdateLogoutTime();
}
guild->BroadcastEvent(GE_SIGNED_OFF, _player->GetObjectGuid(), _player->GetName());
}
///- Remove pet
_player->RemovePet(PET_SAVE_AS_CURRENT);
///- empty buyback items and save the player in the database
// some save parts only correctly work in case player present in map/player_lists (pets, etc)
if (Save)
_player->SaveToDB();
///- Leave all channels before player delete...
_player->CleanupChannels();
///- If the player is in a group (or invited), remove him. If the group if then only 1 person, disband the group.
_player->UninviteFromGroup();
// remove player from the group if he is:
// a) in group; b) not in raid group; c) logging out normally (not being kicked or disconnected)
if (_player->GetGroup() && !_player->GetGroup()->isRaidGroup() && m_Socket)
_player->RemoveFromGroup();
///- Send update to group
if (_player->GetGroup())
_player->GetGroup()->SendUpdate();
///- Broadcast a logout message to the player's friends
sSocialMgr.SendFriendStatus(_player, FRIEND_OFFLINE, _player->GetObjectGuid(), true);
sSocialMgr.RemovePlayerSocial(_player->GetGUIDLow());
///- Remove the player from the world
// the player may not be in the world when logging out
// e.g if he got disconnected during a transfer to another map
// calls to GetMap in this case may cause crashes
if (_player->IsInWorld())
{
Map* _map = _player->GetMap();
_map->Remove(_player, true);
}
else
{
_player->CleanupsBeforeDelete();
Map::DeleteFromWorld(_player);
}
SetPlayer(NULL); // deleted in Remove/DeleteFromWorld call
///- Send the 'logout complete' packet to the client
WorldPacket data(SMSG_LOGOUT_COMPLETE, 0);
SendPacket(&data);
///- Since each account can only have one online character at any given time, ensure all characters for active account are marked as offline
// No SQL injection as AccountId is uint32
static SqlStatementID updChars;
stmt = CharacterDatabase.CreateStatement(updChars, "UPDATE characters SET online = 0 WHERE account = ?");
stmt.PExecute(GetAccountId());
DEBUG_LOG("SESSION: Sent SMSG_LOGOUT_COMPLETE Message");
}
m_playerLogout = false;
m_playerSave = false;
m_playerRecentlyLogout = true;
LogoutRequest(0);
}
开发者ID:KillaVulkan,项目名称:mangos-tbc,代码行数:101,代码来源:WorldSession.cpp
示例10: treeWidget
bool CCoinControlWidgetItem::operator<(const QTreeWidgetItem &other) const {
int column = treeWidget()->sortColumn();
if (column == CoinControlDialog::COLUMN_AMOUNT || column == CoinControlDialog::COLUMN_DATE || column == CoinControlDialog::COLUMN_CONFIRMATIONS || column == CoinControlDialog::COLUMN_PRIVATESEND_ROUNDS)
return data(column, Qt::UserRole).toLongLong() < other.data(column, Qt::UserRole).toLongLong();
return QTreeWidgetItem::operator<(other);
}
开发者ID:marcusfox0,项目名称:polis,代码行数:6,代码来源:coincontroldialog.cpp
示例11: SendTradeStatus
void WorldSession::SendUpdateTrade()
{
Item *item = NULL;
if (!_player || !_player->pTrader)
return;
// reset trade status
if (_player->acceptTrade)
{
_player->acceptTrade = false;
SendTradeStatus(TRADE_STATUS_BACK_TO_TRADE);
}
if (_player->pTrader->acceptTrade)
{
_player->pTrader->acceptTrade = false;
_player->pTrader->GetSession()->SendTradeStatus(TRADE_STATUS_BACK_TO_TRADE);
}
WorldPacket data(SMSG_TRADE_STATUS_EXTENDED, (100)); // guess size
data << (uint8) 1; // can be different (only seen 0 and 1)
data << (uint32) 0; // added in 2.4.0, this value must be equal to value from TRADE_STATUS_OPEN_WINDOW status packet (different value for different players to block multiple trades?)
data << (uint32) TRADE_SLOT_COUNT; // trade slots count/number?, = next field in most cases
data << (uint32) TRADE_SLOT_COUNT; // trade slots count/number?, = prev field in most cases
data << (uint32) _player->pTrader->tradeGold; // trader gold
data << (uint32) 0; // spell casted on lowest slot item
for (uint8 i = 0; i < TRADE_SLOT_COUNT; i++)
{
item = (_player->pTrader->tradeItems[i] != NULL_SLOT ? _player->pTrader->GetItemByPos(_player->pTrader->tradeItems[i]) : NULL);
data << (uint8) i; // trade slot number, if not specified, then end of packet
if (item)
{
data << (uint32) item->GetProto()->ItemId; // entry
// display id
data << (uint32) item->GetProto()->DisplayInfoID;
// stack count
data << (uint32) item->GetUInt32Value(ITEM_FIELD_STACK_COUNT);
data << (uint32) 0; // probably gift=1, created_by=0?
// gift creator
data << (uint64) item->GetUInt64Value(ITEM_FIELD_GIFTCREATOR);
data << (uint32) item->GetEnchantmentId(PERM_ENCHANTMENT_SLOT);
for (uint8 j = 0; j < 3; ++j)
data << (uint32) 0; // enchantment id (permanent/gems?)
// creator
data << (uint64) item->GetUInt64Value(ITEM_FIELD_CREATOR);
data << (uint32) item->GetSpellCharges(); // charges
data << (uint32) item->GetItemSuffixFactor(); // SuffixFactor
// random properties id
data << (uint32) item->GetItemRandomPropertyId();
data << (uint32) item->GetProto()->LockID; // lock id
// max durability
data << (uint32) item->GetUInt32Value(ITEM_FIELD_MAXDURABILITY);
// durability
data << (uint32) item->GetUInt32Value(ITEM_FIELD_DURABILITY);
}
else
{
for (uint8 j = 0; j < 18; j++)
data << uint32(0);
}
}
SendPacket(&data);
}
开发者ID:ekzobam,项目名称:HGCore,代码行数:67,代码来源:TradeHandler.cpp
示例12: OnReachWP
void OnReachWP(uint32 iWaypointId, bool bForwards)
{
switch(iWaypointId)
{
case 1:
{
_unit->GetAIInterface()->setMoveType(MOVEMENTTYPE_WANTEDWP);
_unit->GetAIInterface()->setWaypointToMove(2);
Fly();
}break;
case 2:
{
_unit->GetAIInterface()->setMoveType(MOVEMENTTYPE_WANTEDWP);
_unit->GetAIInterface()->setWaypointToMove(3);
}break;
case 3:
{
_unit->GetAIInterface()->m_canMove = false;
_unit->GetAIInterface()->SetAllowedToEnterCombat(true);
_unit->GetAIInterface()->setCurrentAgent(AGENT_SPELL);
//_unit->m_pacified--;
_unit->GetAIInterface()->SetAIState(STATE_SCRIPTIDLE);
_unit->GetAIInterface()->setMoveType(MOVEMENTTYPE_DONTMOVEWP);
_unit->GetAIInterface()->setWaypointToMove(0);
WorldPacket data(SMSG_MOVE_SET_HOVER, 13);
data << _unit->GetNewGUID();
data << uint32(0);
_unit->SendMessageToSet(&data, false);
m_currentWP = 3;
}break;
case 8:
{
_unit->GetAIInterface()->SetAllowedToEnterCombat(true);
_unit->GetAIInterface()->setCurrentAgent(AGENT_NULL);
_unit->GetAIInterface()->SetAIState(STATE_SCRIPTIDLE);
_unit->GetAIInterface()->setMoveType(MOVEMENTTYPE_DONTMOVEWP);
_unit->GetAIInterface()->setWaypointToMove(0);
/*_unit->m_pacified--;
if(_unit->m_pacified > 0)
_unit->m_pacified--;*/
WorldPacket data(SMSG_MOVE_UNSET_HOVER, 13);
data << _unit->GetNewGUID();
data << uint32(0);
_unit->SendMessageToSet(&data, false);
Land();
}break;
default:
{
_unit->GetAIInterface()->m_canMove = false;
_unit->GetAIInterface()->SetAllowedToEnterCombat(true);
_unit->GetAIInterface()->SetAIState(STATE_SCRIPTIDLE);
_unit->GetAIInterface()->setMoveType(MOVEMENTTYPE_DONTMOVEWP);
_unit->GetAIInterface()->setWaypointToMove(0);
WorldPacket data(SMSG_MOVE_SET_HOVER, 13);
data << _unit->GetNewGUID();
data << uint32(0);
_unit->SendMessageToSet(&data, false);
//_unit->m_pacified--;
}break;
};
}
开发者ID:Bootz,项目名称:arcticdev,代码行数:61,代码来源:Raid_OnyxiasLair.cpp
示例13: data
const unsigned char & ImageRGB::at(unsigned int x, unsigned int y, Channel channel) const
{
auto ptr = data(x, y, channel);
return *ptr;
}
开发者ID:ngf-koster,项目名称:THO7-OCR-Team2,代码行数:6,代码来源:ImageRGB.cpp
示例14: PLATFORM
void BitmapTextureImageBuffer::updateContents(const void* data, const IntRect& targetRect, const IntPoint& sourceOffset, int bytesPerLine, UpdateContentsFlag)
{
#if PLATFORM(QT)
QImage image(reinterpret_cast<const uchar*>(data), targetRect.width(), targetRect.height(), bytesPerLine, NativeImageQt::defaultFormatForAlphaEnabledImages());
QPainter* painter = m_image->context()->platformContext();
painter->save();
painter->setCompositionMode(QPainter::CompositionMode_Source);
painter->drawImage(targetRect, image, IntRect(sourceOffset, targetRect.size()));
painter->restore();
#elif PLATFORM(CAIRO)
RefPtr<cairo_surface_t> surface = adoptRef(cairo_image_surface_create_for_data(static_cast<unsigned char*>(data()),
CAIRO_FORMAT_ARGB32,
targetRect.width(), targetRect.height(),
bytesPerLine));
m_image->context()->platformContext()->drawSurfaceToContext(surface.get(), targetRect,
IntRect(sourceOffset, targetRect.size()), m_image->context());
#else
UNUSED_PARAM(data);
UNUSED_PARAM(targetRect);
UNUSED_PARAM(sourceOffset);
UNUSED_PARAM(bytesPerLine);
#endif
}
开发者ID:dog-god,项目名称:iptv,代码行数:24,代码来源:TextureMapperImageBuffer.cpp
示例15: while
//.........这里部分代码省略.........
_player->RepopAtGraveyard();
_player->SetPendingBind(NULL, 0);
}
//drop a flag if player is carrying it
if (Battleground *bg = _player->GetBattleground())
bg->EventPlayerLoggedOut(_player);
///- Teleport to home if the player is in an invalid instance
if (!_player->m_InstanceValid && !_player->isGameMaster())
_player->TeleportTo(_player->m_homebindMapId, _player->m_homebindX, _player->m_homebindY, _player->m_homebindZ, _player->GetOrientation());
sOutdoorPvPMgr->HandlePlayerLeaveZone(_player, _player->GetZoneId());
for (int i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
{
if (BattlegroundQueueTypeId bgQueueTypeId = _player->GetBattlegroundQueueTypeId(i))
{
_player->RemoveBattlegroundQueueId(bgQueueTypeId);
sBattlegroundMgr->m_BattlegroundQueues[bgQueueTypeId].RemovePlayer(_player->GetGUID(), true);
}
}
// Repop at GraveYard or other player far teleport will prevent saving player because of not present map
// Teleport player immediately for correct player save
while (_player->IsBeingTeleportedFar())
HandleMoveWorldportAckOpcode();
///- If the player is in a guild, update the guild roster and broadcast a logout message to other guild members
if (Guild* pGuild = sGuildMgr->GetGuildById(_player->GetGuildId()))
pGuild->HandleMemberLogout(this);
///- Remove pet
_player->RemovePet(NULL, PET_SLOT_ACTUAL_PET_SLOT, true);
///- empty buyback items and save the player in the database
// some save parts only correctly work in case player present in map/player_lists (pets, etc)
if (Save)
{
uint32 eslot;
for (int j = BUYBACK_SLOT_START; j < BUYBACK_SLOT_END; ++j)
{
eslot = j - BUYBACK_SLOT_START;
_player->SetUInt64Value(PLAYER_FIELD_VENDORBUYBACK_SLOT_1 + (eslot * 2), 0);
_player->SetUInt32Value(PLAYER_FIELD_BUYBACK_PRICE_1 + eslot, 0);
_player->SetUInt32Value(PLAYER_FIELD_BUYBACK_TIMESTAMP_1 + eslot, 0);
}
_player->SaveToDB();
}
///- Leave all channels before player delete...
_player->CleanupChannels();
///- If the player is in a group (or invited), remove him. If the group if then only 1 person, disband the group.
_player->UninviteFromGroup();
// remove player from the group if he is:
// a) in group; b) not in raid group; c) logging out normally (not being kicked or disconnected)
if (_player->GetGroup() && !_player->GetGroup()->isRaidGroup() && m_Socket)
_player->RemoveFromGroup();
///- Send update to group and reset stored max enchanting level
if (_player->GetGroup())
{
_player->GetGroup()->SendUpdate();
_player->GetGroup()->ResetMaxEnchantingLevel();
}
///- Broadcast a logout message to the player's friends
sSocialMgr->SendFriendStatus(_player, FRIEND_OFFLINE, _player->GetGUIDLow(), true);
sSocialMgr->RemovePlayerSocial(_player->GetGUIDLow());
// Call script hook before deletion
sScriptMgr->OnPlayerLogout(GetPlayer());
///- Remove the player from the world
// the player may not be in the world when logging out
// e.g if he got disconnected during a transfer to another map
// calls to GetMap in this case may cause crashes
_player->CleanupsBeforeDelete();
sLog->outChar("Account: %d (IP: %s) Logout Character:[%s] (GUID: %u)", GetAccountId(), GetRemoteAddress().c_str(), _player->GetName(), _player->GetGUIDLow());
Map* _map = _player->GetMap();
_map->Remove(_player, true);
SetPlayer (NULL); // deleted in Remove call
///- Send the 'logout complete' packet to the client
WorldPacket data(SMSG_LOGOUT_COMPLETE, 0);
SendPacket(&data);
///- Since each account can only have one online character at any given time, ensure all characters for active account are marked as offline
//No SQL injection as AccountId is uint32
CharacterDatabase.PExecute("UPDATE characters SET online = 0 WHERE account = '%u'", GetAccountId());
sLog->outDebug(LOG_FILTER_NETWORKIO, "SESSION: Sent SMSG_LOGOUT_COMPLETE Message");
}
m_playerLogout = false;
m_playerSave = false;
m_playerRecentlyLogout = true;
LogoutRequest(0);
}
开发者ID:VeraDev,项目名称:ArkCORE-4.3.4,代码行数:101,代码来源:WorldSession.cpp
示例16: data
void AggrTypeBuilder::addAggregate(AggregateDeclaration *ad)
{
// mirror the ad->fields array but only fill in contributors
const size_t n = ad->fields.dim;
LLSmallVector<VarDeclaration*, 16> data(n, NULL);
unsigned int errors = global.errors;
// first fill in the fields with explicit initializers
for (size_t index = 0; index < n; ++index)
{
VarDeclaration *field = ad->fields[index];
// init is !null for explicit inits
if (field->init != NULL && !field->init->isVoidInitializer())
{
IF_LOG Logger::println("adding explicit initializer for struct field %s",
field->toChars());
size_t f_size = field->type->size();
size_t f_begin = field->offset;
size_t f_end = f_begin + f_size;
if (f_size == 0)
continue;
data[index] = field;
// make sure there is no overlap
for (size_t i = 0; i < index; i++)
{
if (data[i] != NULL)
{
VarDeclaration* vd = data[i];
size_t v_begin = vd->offset;
size_t v_end = v_begin + vd->type->size();
if (v_begin >= f_end || v_end <= f_begin)
continue;
ad->error(vd->loc, "has overlapping initialization for %s and %s",
field->toChars(), vd->toChars());
}
}
}
}
if (errors != global.errors)
{
// There was an overlapping initialization.
// Return if errors are gagged otherwise abort.
if (global.gag) return;
fatal();
}
// fill in default initializers
for (size_t index = 0; index < n; ++index)
{
if (data[index])
continue;
VarDeclaration *field = ad->fields[index];
size_t f_size = field->type->size();
size_t f_begin = field->offset;
size_t f_end = f_begin + f_size;
if (f_size == 0)
continue;
// make sure it doesn't overlap anything explicit
bool overlaps = false;
for (size_t i = 0; i < n; i++)
{
if (data[i])
{
size_t v_begin = data[i]->offset;
size_t v_end = v_begin + data[i]->type->size();
if (v_begin >= f_end || v_end <= f_begin)
continue;
overlaps = true;
break;
}
}
// if no overlap was found, add the default initializer
if (!overlaps)
{
IF_LOG Logger::println("adding default initializer for struct field %s",
field->toChars());
data[index] = field;
}
}
//
// ok. now we can build a list of llvm types. and make sure zeros are inserted if necessary.
//
// first we sort the list by offset
std::sort(data.begin(), data.end(), var_offset_sort_cb);
//.........这里部分代码省略.........
开发者ID:REAP720801,项目名称: |
请发表评论