这篇教程C++ GetGUID函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中GetGUID函数的典型用法代码示例。如果您正苦于以下问题:C++ GetGUID函数的具体用法?C++ GetGUID怎么用?C++ GetGUID使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了GetGUID函数的25个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: datavoid Totem::InitStats(uint32 duration){ // client requires SMSG_TOTEM_CREATED to be sent before adding to world and before removing old totem if (GetOwner()->GetTypeId() == TYPEID_PLAYER && m_Properties->Slot >= SUMMON_SLOT_TOTEM && m_Properties->Slot < MAX_TOTEM_SLOT) { WorldPacket data(SMSG_TOTEM_CREATED, 1 + 8 + 4 + 4); data << uint8(m_Properties->Slot - 1); data << uint64(GetGUID()); data << uint32(duration); data << uint32(GetUInt32Value(UNIT_CREATED_BY_SPELL)); GetOwner()->ToPlayer()->SendDirectMessage(&data); // set display id depending on caster's race SetDisplayId(GetOwner()->GetModelForTotem(PlayerTotemType(m_Properties->Id))); } Minion::InitStats(duration); // Get spell cast by totem if (SpellInfo const* totemSpell = sSpellMgr->GetSpellInfo(GetSpell())) if (totemSpell->CalcCastTime()) // If spell has cast time -> its an active totem m_type = TOTEM_ACTIVE; if (GetEntry() == SENTRY_TOTEM_ENTRY) { Position pos; GetOwner()->GetPosition(&pos); Relocate(&pos); } m_duration = duration; SetLevel(GetOwner()->getLevel());}
开发者ID:Expecto,项目名称:FCore,代码行数:36,
示例2: CanBeTradedbool Item::CanBeTraded(bool mail, bool trade) const{ if (m_lootGenerated) return false; if ((!mail || !IsBoundAccountWide()) && (IsSoulBound() && (!HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_BOP_TRADEABLE) || !trade))) return false; if (IsBag() && (Player::IsBagPos(GetPos()) || !((Bag const*)this)->IsEmpty())) return false; if (Player* owner = GetOwner()) { if (owner->CanUnequipItem(GetPos(), false) != EQUIP_ERR_OK) return false; if (owner->GetLootGUID() == GetGUID()) return false; } if (IsBoundByEnchant()) return false; return true;}
开发者ID:Krill156,项目名称:FreyaCore,代码行数:24,
示例3: GetMapCreature* Transport::AddNPCPassenger (uint32 tguid, uint32 entry, float x, float y, float z, float o, uint32 anim){ Map* map = GetMap(); Creature* pCreature = new Creature; if (!pCreature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, GetPhaseMask(), entry, 0, GetGOInfo()->faction, 0, 0, 0, 0)) { delete pCreature; return 0; } pCreature->SetTransport(this); pCreature->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT); pCreature->m_movementInfo.guid = GetGUID(); pCreature->m_movementInfo.t_pos.Relocate(x, y, z, o); o += GetOrientation(); MapManager::NormalizeOrientation(o); pCreature->Relocate(GetPositionX() + (x * cos(GetOrientation()) + y * sin(GetOrientation() + float(M_PI))), GetPositionY() + (y * cos(GetOrientation()) + x * sin(GetOrientation())), z + GetPositionZ(), o); pCreature->SetHomePosition(pCreature->GetPositionX(), pCreature->GetPositionY(), pCreature->GetPositionZ(), pCreature->GetOrientation()); if (!pCreature->IsPositionValid()) { sLog->outError("Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)", pCreature->GetGUIDLow(), pCreature->GetEntry(), pCreature->GetPositionX(), pCreature->GetPositionY()); delete pCreature; return 0; } map->Add(pCreature); m_NPCPassengerSet.insert(pCreature); pCreature->setActive(true); sScriptMgr->OnAddCreaturePassenger(this, pCreature); return pCreature;}
开发者ID:BoThay,项目名称:ArkCORE,代码行数:36,
示例4: CanBeTradedbool Item::CanBeTraded() const{ if (m_lootGenerated) return false; if (IsSoulBound()) return false; if (IsBag() && (Player::IsBagPos(GetPos()) || !((Bag const*)this)->IsEmpty())) return false; if (Player* owner = GetOwner()) { if (owner->CanUnequipItem(GetPos(),false) != EQUIP_ERR_OK) return false; if (owner->GetLootGUID() == GetGUID()) return false; } if (IsBoundByEnchant()) return false; return true;}
开发者ID:Amara1231,项目名称:blizzlikecore,代码行数:24,
示例5: GetUInt32ValueGameObject::~GameObject(){ sEventMgr.RemoveEvents(this); if(m_ritualmembers) { delete[] m_ritualmembers; m_ritualmembers = NULL; } uint32 guid = GetUInt32Value(OBJECT_FIELD_CREATED_BY); if(guid) { Player *plr = objmgr.GetPlayer(guid); if(plr && plr->GetSummonedObject() == this) plr->SetSummonedObject(NULL); if(plr == m_summoner) m_summoner = 0; } if(m_respawnCell!=NULL) hashmap64_remove(m_respawnCell->_respawnObjects, GetGUID()); if (m_summonedGo && m_summoner) for(int i = 0; i < 4; i++) if (m_summoner->m_ObjectSlots[i] == GetLowGUID()) m_summoner->m_ObjectSlots[i] = 0; if( m_battleground != NULL && m_battleground->GetType() == BATTLEGROUND_ARATHI_BASIN ) { if( bannerslot >= 0 && static_cast<ArathiBasin*>(m_battleground)->m_controlPoints[bannerslot] == this ) static_cast<ArathiBasin*>(m_battleground)->m_controlPoints[bannerslot] = NULL; if( bannerauraslot >= 0 && static_cast<ArathiBasin*>(m_battleground)->m_controlPointAuras[bannerauraslot] == this ) static_cast<ArathiBasin*>(m_battleground)->m_controlPointAuras[bannerauraslot] = NULL; }}
开发者ID:miklasiak,项目名称:projekt,代码行数:36,
示例6: data0void Vehicle::AddPassenger(Unit *unit, int8 seatId, bool force){ SeatMap::iterator seat; seat = m_Seats.find(seatId); // this should never happen if(seat == m_Seats.end()) return; unit->SetVehicleGUID(GetGUID()); seat->second.passenger = unit; if(unit->GetTypeId() == TYPEID_UNIT && ((Creature*)unit)->isVehicle()) { if(((Vehicle*)unit)->GetEmptySeatsCount(true) == 0) seat->second.flags = SEAT_VEHICLE_FULL; else seat->second.flags = SEAT_VEHICLE_FREE; } else { seat->second.flags = SEAT_FULL; } if(unit->GetTypeId() == TYPEID_PLAYER) { WorldPacket data0(SMSG_FORCE_MOVE_ROOT, 10); data0 << unit->GetPackGUID(); data0 << (uint32)((seat->second.vs_flags & SF_CAN_CAST) ? 2 : 0); unit->SendMessageToSet(&data0,true); } if(seat->second.vs_flags & SF_MAIN_RIDER) { if(!(GetVehicleFlags() & VF_MOVEMENT)) { GetMotionMaster()->Clear(false); GetMotionMaster()->MoveIdle(); SetCharmerGUID(unit->GetGUID()); unit->SetUInt64Value(UNIT_FIELD_CHARM, GetGUID()); if(unit->GetTypeId() == TYPEID_PLAYER) { ((Player*)unit)->SetMover(this); ((Player*)unit)->SetMoverInQueve(this); ((Player*)unit)->SetClientControl(this, 1); } if(canFly() || HasAuraType(SPELL_AURA_FLY) || HasAuraType(SPELL_AURA_MOD_FLIGHT_SPEED_MOUNTED)) { WorldPacket data3(SMSG_MOVE_SET_CAN_FLY, 12); data3<< GetPackGUID(); data3 << (uint32)(0); SendMessageToSet(&data3,false); } } SpellClickInfoMapBounds clickPair = sObjectMgr.GetSpellClickInfoMapBounds(GetEntry()); for(SpellClickInfoMap::const_iterator itr = clickPair.first; itr != clickPair.second; ++itr) { if (unit->GetTypeId() == TYPEID_UNIT || itr->second.IsFitToRequirements((Player*)unit)) { Unit *caster = (itr->second.castFlags & 0x1) ? unit : this; Unit *target = (itr->second.castFlags & 0x2) ? unit : this; caster->CastSpell(target, itr->second.spellId, true); } } if(unit->GetTypeId() == TYPEID_PLAYER) { // it should be added only on rider enter? if(((Player*)unit)->GetGroup()) ((Player*)unit)->SetGroupUpdateFlag(GROUP_UPDATE_VEHICLE); ((Player*)unit)->GetCamera().SetView(this); BuildVehicleActionBar((Player*)unit); } if(!(GetVehicleFlags() & VF_FACTION)) setFaction(unit->getFaction()); if(GetVehicleFlags() & VF_CANT_MOVE) { WorldPacket data2(SMSG_FORCE_MOVE_ROOT, 10); data2<< GetPackGUID(); data2 << (uint32)(2); SendMessageToSet(&data2,false); } if(GetVehicleFlags() & VF_NON_SELECTABLE) SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); } if(seat->second.vs_flags & SF_UNATTACKABLE) unit->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); EmptySeatsCountChanged();}
开发者ID:sc0rpio0o,项目名称:diamondcore,代码行数:96,
示例7: boolvoid Item::SaveToDB(SQLTransaction& trans){ bool isInTransaction = bool(trans); if (!isInTransaction) trans = CharacterDatabase.BeginTransaction(); ObjectGuid::LowType guid = GetGUID().GetCounter(); switch (uState) { case ITEM_NEW: case ITEM_CHANGED: { uint8 index = 0; PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(uState == ITEM_NEW ? CHAR_REP_ITEM_INSTANCE : CHAR_UPD_ITEM_INSTANCE); stmt->setUInt32( index, GetEntry()); stmt->setUInt32(++index, GetOwnerGUID().GetCounter()); stmt->setUInt32(++index, GetGuidValue(ITEM_FIELD_CREATOR).GetCounter()); stmt->setUInt32(++index, GetGuidValue(ITEM_FIELD_GIFTCREATOR).GetCounter()); stmt->setUInt32(++index, GetCount()); stmt->setUInt32(++index, GetUInt32Value(ITEM_FIELD_DURATION)); std::ostringstream ssSpells; for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i) ssSpells << GetSpellCharges(i) << ' '; stmt->setString(++index, ssSpells.str()); stmt->setUInt32(++index, GetUInt32Value(ITEM_FIELD_FLAGS)); std::ostringstream ssEnchants; for (uint8 i = 0; i < MAX_ENCHANTMENT_SLOT; ++i) { ssEnchants << GetEnchantmentId(EnchantmentSlot(i)) << ' '; ssEnchants << GetEnchantmentDuration(EnchantmentSlot(i)) << ' '; ssEnchants << GetEnchantmentCharges(EnchantmentSlot(i)) << ' '; } stmt->setString(++index, ssEnchants.str()); stmt->setInt16 (++index, GetItemRandomPropertyId()); stmt->setUInt16(++index, GetUInt32Value(ITEM_FIELD_DURABILITY)); stmt->setUInt32(++index, GetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME)); stmt->setString(++index, m_text); stmt->setUInt32(++index, guid); trans->Append(stmt); if ((uState == ITEM_CHANGED) && HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_WRAPPED)) { stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GIFT_OWNER); stmt->setUInt32(0, GetOwnerGUID().GetCounter()); stmt->setUInt32(1, guid); trans->Append(stmt); } break; } case ITEM_REMOVED: { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE); stmt->setUInt32(0, guid); trans->Append(stmt); if (HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_WRAPPED)) { stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GIFT); stmt->setUInt32(0, guid); trans->Append(stmt); } if (!isInTransaction) CharacterDatabase.CommitTransaction(trans); // Delete the items if this is a container if (!loot.isLooted()) sLootItemStorage->RemoveStoredLootForContainer(GetGUID().GetCounter()); delete this; return; } case ITEM_UNCHANGED: break; } SetState(ITEM_UNCHANGED); if (!isInTransaction) CharacterDatabase.CommitTransaction(trans);}
开发者ID:ElunaLuaEngine,项目名称:ElunaTrinityWotlk,代码行数:86,
示例8: FindFreeEnchantSlotint32 Item::AddEnchantment( EnchantEntry* Enchantment, uint32 Duration, bool Perm /* = false */, bool apply /* = true */, bool RemoveAtLogout /* = false */, uint32 Slot_, uint32 RandomSuffix ){ int32 Slot = Slot_; m_isDirty = true;/* if(Perm) { if(Slot_) { Slot=Slot_; } else { Slot = FindFreeEnchantSlot(Enchantment); } } else { if(Enchantment->EnchantGroups > 1) // replaceable temp enchants { Slot = 1; RemoveEnchantment(1); } else { Slot = FindFreeEnchantSlot(Enchantment);*/ /* Slot = Enchantment->type ? 3 : 0; //that's 's code for(uint32 Index = ITEM_FIELD_ENCHANTMENT_09; Index < ITEM_FIELD_ENCHANTMENT_32; Index += 3) { if(m_uint32Values[Index] == 0) break;; ++Slot; } //Slot = FindFreeEnchantSlot(Enchantment); // reach max of temp enchants if(Slot >= 11) return -1; */ /*} } */ // Create the enchantment struct. EnchantmentInstance Instance; Instance.ApplyTime = UNIXTIME; Instance.BonusApplied = false; Instance.Slot = Slot; Instance.Enchantment = Enchantment; Instance.Duration = Duration; Instance.RemoveAtLogout = RemoveAtLogout; Instance.RandomSuffix = RandomSuffix; // Set the enchantment in the item fields. uint32 EnchantBase = Slot * 3 + ITEM_FIELD_ENCHANTMENT; SetUInt32Value( EnchantBase, Enchantment->Id ); SetUInt32Value( EnchantBase + 1, (uint32)Instance.ApplyTime ); SetUInt32Value( EnchantBase + 2, 0 ); // charges // Add it to our map. Enchantments.insert(make_pair((uint32)Slot, Instance)); if( m_owner == NULL ) return Slot; // Add the removal event. if( Duration ) { sEventMgr.AddEvent( this, &Item::RemoveEnchantment, uint32(Slot), EVENT_REMOVE_ENCHANTMENT1 + Slot, Duration * 1000, 1, 0 ); } // No need to send the log packet, if the owner isn't in world (we're still loading) if( !m_owner->IsInWorld() ) return Slot; if( apply ) { WorldPacket EnchantLog( SMSG_ENCHANTMENTLOG, 25 ); EnchantLog << m_owner->GetGUID(); EnchantLog << m_owner->GetGUID(); EnchantLog << m_uint32Values[OBJECT_FIELD_ENTRY]; EnchantLog << Enchantment->Id; EnchantLog << uint8(0); m_owner->GetSession()->SendPacket( &EnchantLog ); if( m_owner->GetTradeTarget() ) { m_owner->SendTradeUpdate(); } /* Only apply the enchantment bonus if we're equipped */ uint8 slot = m_owner->GetItemInterface()->GetInventorySlotByGuid( GetGUID() ); if( slot >= EQUIPMENT_SLOT_START && slot < EQUIPMENT_SLOT_END ) ApplyEnchantmentBonus( Slot, APPLY ); } return Slot;}
开发者ID:AegisEmu,项目名称:AegisEmu,代码行数:99,
示例9: GetGUIDbool Item::ItemContainerLoadLootFromDB(){ // Loads the money and item loot associated with an openable item from the DB // Default. If there are no records for this item then it will be rolled for in Player::SendLoot() m_lootGenerated = false; ObjectGuid::LowType container_id = GetGUID().GetCounter(); // Save this for later use loot.containerID = container_id; // First, see if there was any money loot. This gets added directly to the container. PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_ITEMCONTAINER_MONEY); stmt->setUInt32(0, container_id); PreparedQueryResult money_result = CharacterDatabase.Query(stmt); if (money_result) { Field* fields = money_result->Fetch(); loot.gold = fields[0].GetUInt32(); } // Next, load any items that were saved stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_ITEMCONTAINER_ITEMS); stmt->setUInt32(0, container_id); PreparedQueryResult item_result = CharacterDatabase.Query(stmt); if (item_result) { // Get a LootTemplate for the container item. This is where // the saved loot was originally rolled from, we will copy conditions from it LootTemplate const* lt = LootTemplates_Item.GetLootFor(GetEntry()); if (lt) { do { // Create an empty LootItem LootItem loot_item = LootItem(); // Fill in the rest of the LootItem from the DB Field* fields = item_result->Fetch(); // item_id, itm_count, follow_rules, ffa, blocked, counted, under_threshold, needs_quest, rnd_prop, rnd_suffix loot_item.itemid = fields[0].GetUInt32(); loot_item.count = fields[1].GetUInt32(); loot_item.follow_loot_rules = fields[2].GetBool(); loot_item.freeforall = fields[3].GetBool(); loot_item.is_blocked = fields[4].GetBool(); loot_item.is_counted = fields[5].GetBool(); loot_item.canSave = true; loot_item.is_underthreshold = fields[6].GetBool(); loot_item.needs_quest = fields[7].GetBool(); loot_item.randomPropertyId = fields[8].GetInt32(); loot_item.randomSuffix = fields[9].GetUInt32(); // Copy the extra loot conditions from the item in the loot template lt->CopyConditions(&loot_item); // If container item is in a bag, add that player as an allowed looter if (GetBagSlot()) loot_item.allowedGUIDs.insert(GetOwner()->GetGUID().GetCounter()); // Finally add the LootItem to the container loot.items.push_back(loot_item); // Increment unlooted count loot.unlootedCount++; } while (item_result->NextRow()); } } // Mark the item if it has loot so it won't be generated again on open m_lootGenerated = !loot.isLooted(); return m_lootGenerated;}
开发者ID:winetaster,项目名称:InfinityCore,代码行数:78,
示例10: switchvoid GameObject::Use(Unit* user){ // by default spell caster is user Unit* spellCaster = user; uint32 spellId = 0; switch(GetGoType()) { case GAMEOBJECT_TYPE_DOOR: //0 case GAMEOBJECT_TYPE_BUTTON: //1 //doors/buttons never really despawn, only reset to default state/flags UseDoorOrButton(); // activate script sWorld.ScriptsStart(sGameObjectScripts, GetDBTableGUIDLow(), spellCaster, this); return; case GAMEOBJECT_TYPE_QUESTGIVER: //2 { if(user->GetTypeId()!=TYPEID_PLAYER) return; Player* player = (Player*)user; player->PrepareQuestMenu( GetGUID() ); player->SendPreparedQuest( GetGUID() ); return; } //Sitting: Wooden bench, chairs enzz case GAMEOBJECT_TYPE_CHAIR: //7 { GameObjectInfo const* info = GetGOInfo(); if(!info) return; if(user->GetTypeId()!=TYPEID_PLAYER) return; Player* player = (Player*)user; // a chair may have n slots. we have to calculate their positions and teleport the player to the nearest one // check if the db is sane if(info->chair.slots > 0) { float lowestDist = DEFAULT_VISIBILITY_DISTANCE; float x_lowest = GetPositionX(); float y_lowest = GetPositionY(); // the object orientation + 1/2 pi // every slot will be on that straight line float orthogonalOrientation = GetOrientation()+M_PI*0.5f; // find nearest slot for(uint32 i=0; i<info->chair.slots; i++) { // the distance between this slot and the center of the go - imagine a 1D space float relativeDistance = (info->size*i)-(info->size*(info->chair.slots-1)/2.0f); float x_i = GetPositionX() + relativeDistance * cos(orthogonalOrientation); float y_i = GetPositionY() + relativeDistance * sin(orthogonalOrientation); // calculate the distance between the player and this slot float thisDistance = player->GetDistance2d(x_i, y_i); /* debug code. It will spawn a npc on each slot to visualize them. Creature* helper = player->SummonCreature(14496, x_i, y_i, GetPositionZ(), GetOrientation(), TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 10000); std::ostringstream output; output << i << ": thisDist: " << thisDistance; helper->MonsterSay(output.str().c_str(), LANG_UNIVERSAL, 0); */ if(thisDistance <= lowestDist) { lowestDist = thisDistance; x_lowest = x_i; y_lowest = y_i; } } player->TeleportTo(GetMapId(), x_lowest, y_lowest, GetPositionZ(), GetOrientation(),TELE_TO_NOT_LEAVE_TRANSPORT | TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET); } else { // fallback, will always work player->TeleportTo(GetMapId(), GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation(),TELE_TO_NOT_LEAVE_TRANSPORT | TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET); } player->SetStandState(PLAYER_STATE_SIT_LOW_CHAIR+info->chair.height); return; } //big gun, its a spell/aura case GAMEOBJECT_TYPE_GOOBER: //10 { GameObjectInfo const* info = GetGOInfo(); if(user->GetTypeId()==TYPEID_PLAYER) { Player* player = (Player*)user; // show page if(info->goober.pageId)//.........这里部分代码省略.........
开发者ID:Actionfox,项目名称:mangos,代码行数:101,
示例11: mainint main(const int argc, const char *argv[]) { if (argc != 4) { std::cout << "ERROR!!! Specify all arguments/n"; std::cout << "Usage:/n"; std::cout << "/tVITDatasetCreator DIR_WITH_ETALONS ALPHABET_FILE OUTPUT_DIR/n"; return 1; } const char *kInputDirectory = argv[1]; const char *kAlphabetFile = argv[2]; const char *kOutputDir = argv[3]; auto alphabet = ReadAlphabetFromFile(kAlphabetFile); for (auto elem : alphabet.GetMap()) { fs::path directory_path = fs::path(kOutputDir) / fs::path(elem.second.name); if (!fs::is_directory(fs::status(directory_path)) && !fs::create_directory(directory_path)) { std::cout << "Can't create directory: " << directory_path << std::endl; return 1; } } std::string process_dir = kInputDirectory; auto img_paths = DirFiles(process_dir, ".jpg"); std::cout << "There are " << img_paths.size() << " images/n"; int processed = 0; for (auto impath : img_paths) { if (processed % 100 == 0) { std::cout << "Processed " << processed << " files of " << img_paths.size() << std::endl; } auto etalon_path = fs::path(impath).replace_extension("txt"); DataInfo dinfo; try { dinfo = ReadEtalonsFromFile(etalon_path.string()); if (0 == dinfo.pinfo.size()) continue; } catch(std::exception &e) { std::cout << "Skip " << impath << ", reason: " << e.what() << std::endl; continue; } //Export file to filesystem cv::Mat original_image = cv::imread(impath.string(), CV_LOAD_IMAGE_GRAYSCALE); for (auto p : dinfo.pinfo) { //std::cout << p.to_string() << std::endl; for (int i = 0; i < p.symbols.size(); i++) { std::string dir_name = alphabet.GetElemName(p.symbols[i].text); if (!dir_name.length()) { std::cout << "Unknown symbol: " << p.symbols[i].text << std::endl; continue; } fs::path output_dir = fs::path(kOutputDir) / fs::path(dir_name); auto save_image = [&output_dir](const cv::Mat& image) { std::string image_name = GetGUID() + ".bmp"; cv::Mat output_image; cv::resize(image, output_image, cv::Size(10, 12), 0, 0, CV_INTER_LANCZOS4); cv::imwrite((output_dir / fs::path(image_name)).c_str(), output_image); }; auto equalize = [](const cv::Mat& image) { cv::Mat result; cv::equalizeHist(image, result); return result; }; auto get_symbol_by_roi = [&original_image](cv::Rect r, int left_pad, int right_pad, int top_pad, int bottom_pad) { cv::Rect new_roi = r; int width = r.width; int height = r.height; new_roi.x = std::max(0, new_roi.x - width * left_pad / 100); new_roi.y = std::max(0, new_roi.y - height * top_pad / 100); int new_x2 = std::min(original_image.cols, r.x + width * (1 + right_pad / 100)); int new_y2 = std::min(original_image.rows, r.y + height * (1 + bottom_pad / 100)); new_roi.width = new_x2 - new_roi.x; new_roi.height = new_y2 - new_roi.y; return original_image(new_roi); }; cv::Rect symbol_roi = p.symbols[i].rect; //todo: rewrite using cycles//.........这里部分代码省略.........
开发者ID:drozdvadym,项目名称:VITDatasetCreator,代码行数:101,
示例12: GUID2String//! Get the GUID of the camera [return string]std::string PS3::GetGUIDStr() const { return GUID2String( GetGUID() );}
开发者ID:armdz,项目名称:ccv-multicam,代码行数:4,
示例13: ASSERTvoid TempSummon::InitStats(uint32 duration){ ASSERT(!isPet()); m_timer = duration; m_lifetime = duration; if (m_type == TEMPSUMMON_MANUAL_DESPAWN) m_type = (duration == 0) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_DESPAWN; Unit* owner = GetSummoner(); if (owner && isTrigger() && m_spells[0]) { setFaction(owner->getFaction()); SetLevel(owner->getLevel()); if (owner->GetTypeId() == TYPEID_PLAYER) m_ControlledByPlayer = true; } if (!m_Properties) return; // Fix Force of Nature treants stats if (owner && owner->getClass() == CLASS_DRUID && owner->HasSpell(106737)) { float damage = 0.0f; switch (GetEntry()) { case ENTRY_TREANT_RESTO: case ENTRY_TREANT_BALANCE: SetMaxHealth(owner->CountPctFromMaxHealth(40)); break; case ENTRY_TREANT_GUARDIAN: SetMaxHealth(owner->CountPctFromMaxHealth(40)); // (Attack power / 14 * 2 * 0.75) * 0.2f damage = ((owner->GetTotalAttackPowerValue(BASE_ATTACK) / 14.0f) * 2.0f * 0.75f) * 0.2f; SetStatFloatValue(UNIT_FIELD_MINDAMAGE, damage); SetStatFloatValue(UNIT_FIELD_MAXDAMAGE, damage); case ENTRY_TREANT_FERAL: SetMaxHealth(owner->CountPctFromMaxHealth(40)); // Attack power / 14 * 2 * 0.75 damage = (owner->GetTotalAttackPowerValue(BASE_ATTACK) / 14.0f) * 2.0f * 0.75f; SetStatFloatValue(UNIT_FIELD_MINDAMAGE, damage); SetStatFloatValue(UNIT_FIELD_MAXDAMAGE, damage); default: break; } } if (owner) { if (uint32 slot = m_Properties->Slot) { if (owner->m_SummonSlot[slot] && owner->m_SummonSlot[slot] != GetGUID()) { Creature* oldSummon = GetMap()->GetCreature(owner->m_SummonSlot[slot]); if (oldSummon && oldSummon->IsSummon()) oldSummon->ToTempSummon()->UnSummon(); } owner->m_SummonSlot[slot] = GetGUID(); } } if (m_Properties->Faction) setFaction(m_Properties->Faction); else if (IsVehicle() && owner) // properties should be vehicle setFaction(owner->getFaction());}
开发者ID:Exodius,项目名称:JadeCore548,代码行数:70,
示例14: asf_parse_headerext/** * Parse header extension object. Takes a pointer to a newly allocated * header extension structure, a pointer to the data buffer and the * length of the data buffer as its parameters. Subobject contents are * not parsed, but they are added as a linked list to the header object. */static intasf_parse_headerext(asf_object_headerext_t *header, uint8_t *buf, uint64_t buflen){ int64_t datalen; uint8_t *data; if (header->size < 46) { /* invalide size for headerext */ return ASF_ERROR_INVALID_OBJECT_SIZE; } /* Read reserved and datalen fields from the buffer */ GetGUID(buf + 24, &header->reserved1); header->reserved2 = GetWLE(buf + 40); header->datalen = GetDWLE(buf + 42); if (header->datalen != header->size - 46) { /* invalid header extension data length value */ return ASF_ERROR_INVALID_LENGTH; } header->data = buf + 46; debug_printf("parsing header extension subobjects"); datalen = header->datalen; data = header->data; while (datalen > 0) { asfint_object_t *current; if (datalen < 24) { /* not enough data for reading a new object */ break; } /* Allocate a new subobject */ current = malloc(sizeof(asfint_object_t)); if (!current) { return ASF_ERROR_OUTOFMEM; } asf_parse_read_object(current, data); if (current->size > datalen || current->size < 24) { /* invalid object size */ break; } current->datalen = current->size - 24; current->data = data + 24; /* add to the list of subobjects */ if (!header->first) { header->first = current; header->last = current; } else { header->last->next = current; header->last = current; } data += current->size; datalen -= current->size; } if (datalen != 0) { /* not enough data for reading the whole object */ return ASF_ERROR_INVALID_LENGTH; } debug_printf("header extension subobjects parsed successfully"); return header->size;}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:76,
示例15: HandleDummy void HandleDummy(SpellEffIndex /*effIndex*/) { auto target = GetHitUnit(); if (!target || target->GetTypeId() != TYPEID_PLAYER) return; auto player = GetCaster()->ToPlayer(); if (player->GetQuestStatus(29951) == QUEST_STATUS_INCOMPLETE) { if (!player->HasAura(106284)) { player->MonsterTextEmote("Mudmug's vial will slowly spill water while you are moving. Plan your path carefully!", player->GetGUID() , true); player->CastSpell(player, 106284, true); } else player->CastSpell(player, 106294, true); if (player->GetPower(POWER_ALTERNATE_POWER) == 100) { player->AddItem(76356, 1); player->RemoveAurasDueToSpell(106284); } } }
开发者ID:cnmir2,项目名称:camarote,代码行数:24,
示例16: FindMapTempSummon* Transport::SummonPassenger(uint32 entry, Position const& pos, TempSummonType summonType, SummonPropertiesEntry const* properties /*= NULL*/, uint32 duration /*= 0*/, Unit* summoner /*= NULL*/, uint32 spellId /*= 0*/, uint32 vehId /*= 0*/){ Map* map = FindMap(); if (!map) return NULL; uint32 mask = UNIT_MASK_SUMMON; if (properties) { switch (properties->Category) { case SUMMON_CATEGORY_PET: mask = UNIT_MASK_GUARDIAN; break; case SUMMON_CATEGORY_PUPPET: mask = UNIT_MASK_PUPPET; break; case SUMMON_CATEGORY_VEHICLE: mask = UNIT_MASK_MINION; break; case SUMMON_CATEGORY_WILD: case SUMMON_CATEGORY_ALLY: case SUMMON_CATEGORY_UNK: { switch (properties->Type) { case SUMMON_TYPE_MINION: case SUMMON_TYPE_GUARDIAN: case SUMMON_TYPE_GUARDIAN2: mask = UNIT_MASK_GUARDIAN; break; case SUMMON_TYPE_TOTEM: case SUMMON_TYPE_LIGHTWELL: mask = UNIT_MASK_TOTEM; break; case SUMMON_TYPE_VEHICLE: case SUMMON_TYPE_VEHICLE2: mask = UNIT_MASK_SUMMON; break; case SUMMON_TYPE_MINIPET: mask = UNIT_MASK_MINION; break; default: if (properties->Flags & 512) // Mirror Image, Summon Gargoyle mask = UNIT_MASK_GUARDIAN; break; } break; } default: return NULL; } } uint32 phase = PHASEMASK_NORMAL; uint32 team = 0; if (summoner) { phase = summoner->GetPhaseMask(); if (summoner->GetTypeId() == TYPEID_PLAYER) team = summoner->ToPlayer()->GetTeam(); } TempSummon* summon = NULL; switch (mask) { case UNIT_MASK_SUMMON: summon = new TempSummon(properties, summoner, false); break; case UNIT_MASK_GUARDIAN: summon = new Guardian(properties, summoner, false); break; case UNIT_MASK_PUPPET: summon = new Puppet(properties, summoner); break; case UNIT_MASK_TOTEM: summon = new Totem(properties, summoner); break; case UNIT_MASK_MINION: summon = new Minion(properties, summoner, false); break; } float x, y, z, o; pos.GetPosition(x, y, z, o); CalculatePassengerPosition(x, y, z, &o); if (!summon->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, phase, entry, vehId, team, x, y, z, o)) { delete summon; return NULL; } summon->SetUInt32Value(UNIT_CREATED_BY_SPELL, spellId); summon->SetTransport(this); summon->m_movementInfo.transport.guid = GetGUID(); summon->m_movementInfo.transport.pos.Relocate(pos); summon->Relocate(x, y, z, o); summon->SetHomePosition(x, y, z, o);//.........这里部分代码省略.........
开发者ID:BravadoToDeath,项目名称:ArkCORE-NG,代码行数:101,
示例17: memsetCreature::Creature(uint64 guid){ proto=0; m_valuesCount = UNIT_END; m_objectTypeId = TYPEID_UNIT; m_uint32Values = _fields; memset(m_uint32Values, 0,(UNIT_END)*sizeof(uint32)); m_updateMask.SetCount(UNIT_END); SetUInt32Value( OBJECT_FIELD_TYPE,TYPE_UNIT|TYPE_OBJECT); SetUInt64Value( OBJECT_FIELD_GUID,guid); m_wowGuid.Init(GetGUID()); m_quests = NULL; proto = NULL; spawnid=0; creature_info=NULL; m_H_regenTimer=0; m_P_regenTimer=0; m_useAI = true; mTaxiNode = 0; Tagged = false; TaggerGuid = 0; Skinned = false; m_enslaveCount = 0; m_enslaveSpell = 0; for(uint32 x=0;x<7;x++) { FlatResistanceMod[x]=0; BaseResistanceModPct[x]=0; ResistanceModPct[x]=0; ModDamageDone[x]=0; ModDamageDonePct[x]=1.0; } for(uint32 x=0;x<5;x++) { TotalStatModPct[x]=0; StatModPct[x]=0; FlatStatMod[x]=0; } totemOwner = NULL; totemSlot = -1; m_PickPocketed = false; m_SellItems = NULL; _myScriptClass = NULL; m_TaxiNode = 0; myFamily = 0; loot.gold = 0; haslinkupevent = false; original_emotestate = 0; mTrainer = 0; m_spawn = 0; spawnid = 0; auctionHouse = 0; has_waypoint_text = has_combat_text = false; SetFloatValue(UNIT_FIELD_ATTACK_POWER_MULTIPLIER,1); SetFloatValue(UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER,1); m_custom_waypoint_map = 0; m_escorter = 0; m_limbostate = false; m_corpseEvent=false; m_respawnCell=NULL; m_walkSpeed = 2.5f; m_runSpeed = MONSTER_NORMAL_RUN_SPEED; m_base_runSpeed = m_runSpeed; m_base_walkSpeed = m_walkSpeed; m_noRespawn=false; m_canRegenerateHP = true; m_transportGuid = 0; m_transportPosition = NULL; BaseAttackType = SCHOOL_NORMAL; m_lootMethod = -1;}
开发者ID:AwkwardDev,项目名称:ascent_classic,代码行数:82,
示例18: SetUInt32Value//called instead of parametrized constructorvoid Item::Init( uint32 high, uint32 low ){ SetUInt32Value( OBJECT_FIELD_GUID, low ); SetUInt32Value( OBJECT_FIELD_GUID + 1, high ); m_wowGuid.Init( GetGUID() );}
开发者ID:AegisEmu,项目名称:AegisEmu,代码行数:7,
示例19: GetGUIDvoid Item::ApplyEnchantmentBonus( uint32 Slot, bool Apply ){ if( m_owner == NULL ) return; EnchantmentMap::iterator itr = Enchantments.find( Slot ); if( itr == Enchantments.end() ) return; EnchantEntry* Entry = itr->second.Enchantment; uint32 RandomSuffixAmount = itr->second.RandomSuffix; if( itr->second.Dummy ) return; if( itr->second.BonusApplied == Apply ) return; itr->second.BonusApplied = Apply; // Apply the visual on the player. uint32 ItemSlot = m_owner->GetItemInterface()->GetInventorySlotByGuid( GetGUID() ); if(ItemSlot < EQUIPMENT_SLOT_END && Slot < 1) { uint32 VisibleBase = PLAYER_VISIBLE_ITEM_1_ENCHANTMENT + ItemSlot * PLAYER_VISIBLE_ITEM_LENGTH; m_owner->SetUInt16Value( VisibleBase, Slot, Apply ? Entry->Id : 0 ); } if( Apply ) { // Send the enchantment time update packet. SendEnchantTimeUpdate( itr->second.Slot, itr->second.Duration ); } // Another one of those for loop that where not indented properly god knows what will break // but i made it actually affect the code below it for( uint32 c = 0; c < 3; c++ ) { if( Entry->type[c] ) { // Depending on the enchantment type, take the appropriate course of action. switch( Entry->type[c] ) { case 1: // Trigger spell on melee attack. { if( Apply && Entry->spell[c] != 0 ) { // Create a proc trigger spell ProcTriggerSpell TS; memset(&TS, 0, sizeof(ProcTriggerSpell)); TS.caster = m_owner->GetGUID(); TS.procFlags = PROC_ON_MELEE_ATTACK; TS.origId = 0; TS.procflags2 = 0; TS.SpellClassMask[0] = 0; TS.SpellClassMask[1] = 0; TS.SpellClassMask[2] = 0; TS.ProcType = 0; TS.LastTrigger = 0; TS.procValue = 0; TS.procCharges = 0; TS.procChance = 10; if(ItemSlot == EQUIPMENT_SLOT_MAINHAND) TS.weapon_damage_type = 1; // Proc only on main hand attacks else if(ItemSlot == EQUIPMENT_SLOT_OFFHAND) TS.weapon_damage_type = 2; // Proc only on off hand attacks else TS.weapon_damage_type = 0; // Doesn't depend on weapon /* This needs to be modified based on the attack speed of the weapon. * Secondly, need to assign some static chance for instant attacks (ss, * gouge, etc.) */ if( GetProto()->Class == ITEM_CLASS_WEAPON ) { if( !Entry->min[c] ) { float speed = (float)GetProto()->Delay; /////// procChance calc /////// float ppm = 0; SpellEntry* sp = dbcSpell.LookupEntry( Entry->spell[c] ); if( sp ) { switch( sp->NameHash ) { case SPELL_HASH_FROSTBRAND_ATTACK: ppm = 9; break; } } if( ppm != 0 ) { float pcount = 60/ppm; float chance = (speed/10) / pcount; TS.procChance = (uint32)chance; } else TS.procChance = (uint32)( speed / 600.0f ); /////////////////////////////////.........这里部分代码省略.........
开发者ID:WowDevs,项目名称:Sandshroud,代码行数:101,
示例20: SendEnchantTimeUpdatevoid Item::ApplyEnchantmentBonus( uint32 Slot, bool Apply ){ if( m_owner == NULL ) return; EnchantmentMap::iterator itr = Enchantments.find( Slot ); if( itr == Enchantments.end() ) return; EnchantEntry* Entry = itr->second.Enchantment; uint32 RandomSuffixAmount = itr->second.RandomSuffix; if( itr->second.BonusApplied == Apply ) return; itr->second.BonusApplied = Apply; if( Apply ) { // Send the enchantment time update packet. SendEnchantTimeUpdate( itr->second.Slot, itr->second.Duration ); } // Apply the visual on the player. uint32 ItemSlot = m_owner->GetItemInterface()->GetInventorySlotByGuid( GetGUID() ) * 16; uint32 VisibleBase = PLAYER_VISIBLE_ITEM_1_0 + ItemSlot; m_owner->SetUInt32Value( VisibleBase + 1 + Slot, Apply ? Entry->Id : 0 ); // Another one of those for loop that where not indented properly god knows what will break // but i made it actually affect the code below it for( uint32 c = 0; c < 3; c++ ) { if( Entry->type[c] ) { // Depending on the enchantment type, take the appropriate course of action. switch( Entry->type[c] ) { case 1: // Trigger spell on melee attack. { if( Apply && Entry->spell[c] != 0 ) { // Create a proc trigger spell ProcTriggerSpell TS; TS.caster = m_owner->GetGUID(); TS.origId = 0; TS.procFlags = PROC_ON_MELEE_ATTACK; TS.procCharges = 0; /* This needs to be modified based on the attack speed of the weapon. * Secondly, need to assign some static chance for instant attacks (ss, * gouge, etc.) */ if( !Entry->min[c] && GetProto()->Class == 2 ) { float speed = (float)GetProto()->Delay; /////// procChance calc /////// float ppm = 0; SpellEntry* sp = dbcSpell.LookupEntry( Entry->spell[c] ); if( sp ) { switch( sp->NameHash ) { case SPELL_HASH_FROSTBRAND_ATTACK: ppm = 9; break; } } if( ppm != 0 ) { float pcount = 60/ppm; float chance = (speed/10) / pcount; TS.procChance = (uint32)chance; } else TS.procChance = (uint32)( speed / 600.0f ); /////////////////////////////// } else TS.procChance = Entry->min[c]; Log.Debug( "Enchant", "Setting procChance to %u%%.", TS.procChance ); TS.deleted = false; TS.spellId = Entry->spell[c]; TS.groupRelation = 0; TS.ProcType = 0; TS.LastTrigger = 0; m_owner->m_procSpells.push_back( TS ); } else { // Remove the proctriggerspell uint32 SpellId; list< struct ProcTriggerSpell >::iterator itr/*, itr2*/; for( itr = m_owner->m_procSpells.begin(); itr != m_owner->m_procSpells.end(); ) { SpellId = itr->spellId; /*itr2 = itr++;*/ if( SpellId == Entry->spell[c] ) { //m_owner->m_procSpells.erase(itr2); itr->deleted = true;//.........这里部分代码省略.........
开发者ID:AegisEmu,项目名称:AegisEmu,代码行数:101,
示例21: GetGUIDLowvoid Creature::_LoadGoods(){ itemcount = 0; std::stringstream query; query << "SELECT * FROM vendors WHERE vendorGuid=" << GetGUIDLow(); QueryResult *result = sDatabase.Query( query.str().c_str() ); if(!result) { std::stringstream query7; query7 << "SELECT * FROM vendors WHERE vendorGuid=" << GetNameID(); result = sDatabase.Query( query7.str().c_str() ); if (result) Log::getSingleton( ).outError( "Vendor %u has items.", GetNameID() ); } if(!result) { std::stringstream query2; query2 << "SELECT * FROM vendors WHERE vendorGuid=" << uint64(GetGUIDLow()+1); result = sDatabase.Query( query2.str().c_str() ); } if(!result) { std::stringstream query5; query5 << "SELECT * FROM vendors WHERE vendorGuid=" << uint64(GetGUIDLow()-10); result = sDatabase.Query( query5.str().c_str() ); } if(!result) { std::stringstream query3; query3 << "SELECT * FROM vendors WHERE vendorGuid=" << uint64(GetGUID()); result = sDatabase.Query( query3.str().c_str() ); } if(!result) { std::stringstream query4; query4 << "SELECT * FROM vendors WHERE vendorGuid=" << uint64(GetGUID()+1); result = sDatabase.Query( query4.str().c_str() ); } if(!result) { std::stringstream query6; query6 << "SELECT * FROM vendors WHERE vendorGuid=" << uint64(GetGUID()-10); result = sDatabase.Query( query6.str().c_str() ); } if(result) { do { Field *fields = result->Fetch(); if (getItemCount() >= MAX_CREATURE_ITEMS) { Log::getSingleton( ).outError( "Vendor %u has too many items (%u >= %i). Check the DB!", GetNameID(), getItemCount(), MAX_CREATURE_ITEMS ); break; } setItemId(getItemCount() , fields[1].GetUInt32()); setItemAmount(getItemCount() , fields[2].GetUInt32()); increaseItemCount(); } while( result->NextRow() ); delete result; }}
开发者ID:Artea,项目名称:mangos-svn,代码行数:87,
示例22: DeleteFromInventoryDBvoid Item::DeleteFromInventoryDB(SQLTransaction& trans){ DeleteFromInventoryDB(trans, GetGUID().GetCounter());}
开发者ID:ElunaLuaEngine,项目名称:ElunaTrinityWotlk,代码行数:4,
示例23: FindMapTempSummon* Transport::SummonPassenger(uint32 entry, Position const& pos, TempSummonType summonType, SummonPropertiesEntry const* properties /*= NULL*/, uint32 duration /*= 0*/, Unit* summoner /*= NULL*/, uint32 spellId /*= 0*/, uint32 vehId /*= 0*/){ Map* map = FindMap(); if (!map) return NULL; uint32 mask = UNIT_MASK_SUMMON; if (properties) { switch (properties->Control) { case SUMMON_CATEGORY_PET: mask = UNIT_MASK_GUARDIAN; break; case SUMMON_CATEGORY_PUPPET: mask = UNIT_MASK_PUPPET; break; case SUMMON_CATEGORY_VEHICLE: mask = UNIT_MASK_MINION; break; case SUMMON_CATEGORY_WILD: case SUMMON_CATEGORY_ALLY: case SUMMON_CATEGORY_UNK: { switch (properties->Title) { case SUMMON_TYPE_MINION: case SUMMON_TYPE_GUARDIAN: case SUMMON_TYPE_GUARDIAN2: mask = UNIT_MASK_GUARDIAN; break; case SUMMON_TYPE_TOTEM: case SUMMON_TYPE_LIGHTWELL: mask = UNIT_MASK_TOTEM; break; case SUMMON_TYPE_VEHICLE: case SUMMON_TYPE_VEHICLE2: mask = UNIT_MASK_SUMMON; break; case SUMMON_TYPE_MINIPET: mask = UNIT_MASK_MINION; break; default: if (properties->Flags & 512) // Mirror Image, Summon Gargoyle mask = UNIT_MASK_GUARDIAN; break; } break; } default: return NULL; } } TempSummon* summon = nullptr; switch (mask) { case UNIT_MASK_SUMMON: summon = new TempSummon(properties, summoner, false); break; case UNIT_MASK_GUARDIAN: summon = new Guardian(properties, summoner, false); break; case UNIT_MASK_PUPPET: summon = new Puppet(properties, summoner); break; case UNIT_MASK_TOTEM: summon = new Totem(properties, summoner); break; case UNIT_MASK_MINION: summon = new Minion(properties, summoner, false); break; } float x, y, z, o; pos.GetPosition(x, y, z, o); CalculatePassengerPosition(x, y, z, &o); if (!summon->Create(map->GenerateLowGuid<HighGuid::Creature>(), map, entry, x, y, z, o, nullptr, vehId)) { delete summon; return nullptr; } PhasingHandler::InheritPhaseShift(summon, summoner ? static_cast<WorldObject*>(summoner) : static_cast<WorldObject*>(this)); summon->SetUInt32Value(UNIT_CREATED_BY_SPELL, spellId); summon->SetTransport(this); summon->m_movementInfo.transport.guid = GetGUID(); summon->m_movementInfo.transport.pos.Relocate(pos); summon->Relocate(x, y, z, o); summon->SetHomePosition(x, y, z, o); summon->SetTransportHomePosition(pos); /// @HACK - transport models are not added to map's dynamic LoS calculations /// because the current GameObjectModel cannot be moved without recreating summon->AddUnitState(UNIT_STATE_IGNORE_PATHFINDING); summon->InitStats(duration);//.........这里部分代码省略.........
开发者ID:Asandru,项目名称:TrinityCore,代码行数:101,
示例24: SendObjectDeSpawnAnimvoid DynamicObject::Delete(){ SendObjectDeSpawnAnim(GetGUID()); AddObjectToRemoveList();}
开发者ID:MgCore,项目名称:Mangos_Cataclysm,代码行数:5,
示例25: asf_parse_index/** * Takes an initialized asf_file_t structure file as a parameter. Allocates * a new asf_object_index_t in file->index and uses the file->iostream to * read all its compulsory fields into it. Notice that the actual data is * not read in any way, because we need to be able to work with non-seekable * streams as well. */intasf_parse_index(asf_file_t *file){ asf_object_index_t *index; asf_iostream_t *iostream; uint8_t idata[56]; uint64_t entry_data_size; uint8_t *entry_data = NULL; int tmp, i; file->index = NULL; iostream = &file->iostream; /* read the raw data of an index header */ tmp = asf_byteio_read(iostream, idata, 56); if (tmp < 0) { printf("Could not read index header/n"); return tmp; } /* allocate the index object */ index = malloc(sizeof(asf_object_index_t)); if (!index) { return ASF_ERROR_OUTOFMEM; } asf_parse_read_object((asfint_object_t *) index, idata); if (index->type != GUID_INDEX) { tmp = index->size; free(index); /* The guid type was wrong, just return the bytes to skip */ return tmp; } if (index->size < 56) { /* invalid size for index object */ free(index); return ASF_ERROR_INVALID_OBJECT_SIZE; } GetGUID(idata + 24, &index->file_id); index->entry_time_interval = GetQWLE(idata + 40); index->max_packet_count = GetDWLE(idata + 48); index->entry_count = GetDWLE(idata + 52); printf("INDEX/n"); printf("Total Index Entries %d/n",index->entry_count); printf("Index Size in bytes %Ld/n",index->size); printf("Index Max Packet Count %d/n",index->max_packet_count); printf("Index Entry Time Interval %Ld/n",index->entry_time_interval); if (index->entry_count == 0) { printf("Index has no entries/n"); file->index = index; return index->size; } if (index->entry_count * 6 + 56 > index->size) { free(index); return ASF_ERROR_INVALID_LENGTH; } entry_data_size = index->entry_count * 6; entry_data = malloc(entry_data_size * sizeof(uint8_t)); if (!entry_data) { free(index); return ASF_ERROR_OUTOFMEM; } tmp = asf_byteio_read(iostream, entry_data, entry_data_size); if (tmp < 0) { printf("Could not read entry data/n"); free(index); free(entry_data); return tmp; } index->entries = malloc(index->entry_count * sizeof(asf_index_entry_t)); if (!index->entries) { free(index); free(entry_data); return ASF_ERROR_OUTOFMEM; } for (i=0; i<index->entry_count; i++) { index->entries[i].packet_index = GetDWLE(entry_data + i*6); index->entries[i].packet_count = GetWLE(entry_data + i*6 + 4); } free(entry_data); file->index = index; return index->size;//.........这里部分代码省略.........
开发者ID:AmirAbrams,项目名称:haiku,代码行数:101,
注:本文中的GetGUID函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ GetGUIDLow函数代码示例 C++ GetGDALDriverManager函数代码示例 |