这篇教程C++ uint8函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中uint8函数的典型用法代码示例。如果您正苦于以下问题:C++ uint8函数的具体用法?C++ uint8怎么用?C++ uint8使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了uint8函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: datavoid WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data ){ std::string name; uint8 race_, class_; recv_data >> name; recv_data >> race_; recv_data >> class_; WorldPacket data(SMSG_CHAR_CREATE, 1); // returned with diff.values in all cases if(GetSecurity() == SEC_PLAYER) { if(uint32 mask = sWorld.getConfig(CONFIG_UINT32_CHARACTERS_CREATING_DISABLED)) { bool disabled = false; uint32 team = Player::TeamForRace(race_); switch(team) { case ALLIANCE: disabled = mask & (1 << 0); break; case HORDE: disabled = mask & (1 << 1); break; } if(disabled) { data << (uint8)CHAR_CREATE_DISABLED; SendPacket( &data ); return; } } } ChrClassesEntry const* classEntry = sChrClassesStore.LookupEntry(class_); ChrRacesEntry const* raceEntry = sChrRacesStore.LookupEntry(race_); if( !classEntry || !raceEntry ) { data << (uint8)CHAR_CREATE_FAILED; SendPacket( &data ); sLog.outError("Class: %u or Race %u not found in DBC (Wrong DBC files?) or Cheater?", class_, race_); return; } // prevent character creating Expansion race without Expansion account if (raceEntry->expansion > Expansion()) { data << (uint8)CHAR_CREATE_EXPANSION; sLog.outError("Expansion %u account:[%d] tried to Create character with expansion %u race (%u)", Expansion(), GetAccountId(), raceEntry->expansion, race_); SendPacket( &data ); return; } // prevent character creating Expansion class without Expansion account if (classEntry->expansion > Expansion()) { data << (uint8)CHAR_CREATE_EXPANSION_CLASS; sLog.outError("Expansion %u account:[%d] tried to Create character with expansion %u class (%u)", Expansion(), GetAccountId(), classEntry->expansion, class_); SendPacket( &data ); return; } // prevent character creating with invalid name if (!normalizePlayerName(name)) { data << (uint8)CHAR_NAME_NO_NAME; SendPacket( &data ); sLog.outError("Account:[%d] but tried to Create character with empty [name]", GetAccountId()); return; } // check name limitations uint8 res = ObjectMgr::CheckPlayerName(name, true); if (res != CHAR_NAME_SUCCESS) { data << uint8(res); SendPacket( &data ); return; } if (GetSecurity() == SEC_PLAYER && sObjectMgr.IsReservedName(name)) { data << (uint8)CHAR_NAME_RESERVED; SendPacket( &data ); return; } if (sObjectMgr.GetPlayerGUIDByName(name)) { data << (uint8)CHAR_CREATE_NAME_IN_USE; SendPacket( &data ); return; } QueryResult *resultacct = LoginDatabase.PQuery("SELECT SUM(numchars) FROM realmcharacters WHERE acctid = '%d'", GetAccountId()); if (resultacct) { Field *fields=resultacct->Fetch(); uint32 acctcharcount = fields[0].GetUInt32();//.........这里部分代码省略.........
开发者ID:OWalla,项目名称:mangos,代码行数:101,
示例2: objectvoid WorldSession::HandlePetActionHelper(Unit* pet, uint64 guid1, uint16 spellid, uint16 flag, uint64 guid2){ CharmInfo* charmInfo = pet->GetCharmInfo(); if (!charmInfo) { sLog->outError("WorldSession::HandlePetAction(petGuid: " UI64FMTD ", tagGuid: " UI64FMTD ", spellId: %u, flag: %u): object (entry: %u TypeId: %u) is considered pet-like but doesn't have a charminfo!", guid1, guid2, spellid, flag, pet->GetGUIDLow(), pet->GetTypeId()); return; } switch (flag) { case ACT_COMMAND: //0x07 switch (spellid) { case COMMAND_STAY: //flat=1792 //STAY { bool controlledMotion = pet->GetMotionMaster()->GetMotionSlotType(MOTION_SLOT_CONTROLLED) != NULL_MOTION_TYPE; if (!controlledMotion) { pet->StopMovingOnCurrentPos(); pet->GetMotionMaster()->Clear(false); pet->GetMotionMaster()->MoveIdle(); } charmInfo->SetCommandState(COMMAND_STAY); charmInfo->SetIsCommandAttack(false); charmInfo->SetIsCommandFollow(false); charmInfo->SetIsFollowing(false); charmInfo->SetIsReturning(false); charmInfo->SetIsAtStay(!controlledMotion); charmInfo->SaveStayPosition(controlledMotion); charmInfo->SetForcedSpell(0); charmInfo->SetForcedTargetGUID(0); break; } case COMMAND_FOLLOW: //spellid=1792 //FOLLOW { pet->AttackStop(); pet->InterruptNonMeleeSpells(false); pet->ClearInPetCombat(); pet->GetMotionMaster()->MoveFollow(_player, PET_FOLLOW_DIST, pet->GetFollowAngle()); charmInfo->SetCommandState(COMMAND_FOLLOW); charmInfo->SetIsCommandAttack(false); charmInfo->SetIsAtStay(false); charmInfo->SetIsReturning(true); charmInfo->SetIsCommandFollow(true); charmInfo->SetIsFollowing(false); charmInfo->SetForcedSpell(0); charmInfo->SetForcedTargetGUID(0); break; } case COMMAND_ATTACK: //spellid=1792 //ATTACK { // Can't attack if owner is pacified if (_player->HasAuraType(SPELL_AURA_MOD_PACIFY)) { //pet->SendPetCastFail(spellid, SPELL_FAILED_PACIFIED); //TODO: Send proper error message to client return; } // only place where pet can be player Unit* TargetUnit = ObjectAccessor::GetUnit(*_player, guid2); if (!TargetUnit) return; if (Unit* owner = pet->GetOwner()) if (!owner->IsValidAttackTarget(TargetUnit)) return; // pussywizard: if (Creature* creaturePet = pet->ToCreature()) if (!creaturePet->_CanDetectFeignDeathOf(TargetUnit) || !creaturePet->CanCreatureAttack(TargetUnit) || creaturePet->isTargetNotAcceptableByMMaps(TargetUnit->GetGUID(), sWorld->GetGameTime(), TargetUnit)) return; // Not let attack through obstructions bool checkLos = !MMAP::MMapFactory::IsPathfindingEnabled(pet->GetMap()) || (TargetUnit->GetTypeId() == TYPEID_UNIT && (TargetUnit->ToCreature()->isWorldBoss() || TargetUnit->ToCreature()->IsDungeonBoss())); if (checkLos && !pet->IsWithinLOSInMap(TargetUnit)) { WorldPacket data(SMSG_CAST_FAILED, 1+4+1); data << uint8(0); data << uint32(7389); data << uint8(SPELL_FAILED_LINE_OF_SIGHT); SendPacket(&data); return; } pet->ClearUnitState(UNIT_STATE_FOLLOW); // This is true if pet has no target or has target but targets differs. if (pet->GetVictim() != TargetUnit || (pet->GetVictim() == TargetUnit && !pet->GetCharmInfo()->IsCommandAttack())) { pet->AttackStop(); if (pet->GetTypeId() != TYPEID_PLAYER && pet->ToCreature()->IsAIEnabled)//.........这里部分代码省略.........
开发者ID:AlexHjelm,项目名称:sunwell,代码行数:101,
示例3: datavoid Weather::SendWeatherUpdateToPlayer(Player* player){ WorldPacket data(SMSG_WEATHER, (4+4+4)); data << uint32(GetWeatherState()) << (float)m_grade << uint8(0); player->GetSession()->SendPacket(&data);}
开发者ID:samaelsacred,项目名称:4.3.4,代码行数:6,
示例4: ReadAMSPattern// Read AMS or AMS2 (newVersion = true) pattern. At least this part of the format is more or less identical between the two trackers...static void ReadAMSPattern(CPattern &pattern, bool newVersion, FileReader &patternChunk, CSoundFile &sndFile)//-----------------------------------------------------------------------------------------------------------{ enum { emptyRow = 0xFF, // No commands on row endOfRowMask = 0x80, // If set, no more commands on this row noteMask = 0x40, // If set, no note+instr in this command channelMask = 0x1F, // Mask for extracting channel // Note flags readNextCmd = 0x80, // One more command follows noteDataMask = 0x7F, // Extract note // Command flags volCommand = 0x40, // Effect is compressed volume command commandMask = 0x3F, // Command or volume mask }; // Effect translation table for extended (non-Protracker) effects static const ModCommand::COMMAND effTrans[] = { CMD_S3MCMDEX, // Forward / Backward CMD_PORTAMENTOUP, // Extra fine slide up CMD_PORTAMENTODOWN, // Extra fine slide up CMD_RETRIG, // Retrigger CMD_NONE, CMD_TONEPORTAVOL, // Toneporta with fine volume slide CMD_VIBRATOVOL, // Vibrato with fine volume slide CMD_NONE, CMD_PANNINGSLIDE, CMD_NONE, CMD_VOLUMESLIDE, // Two times finder volume slide than Axx CMD_NONE, CMD_CHANNELVOLUME, // Channel volume (0...127) CMD_PATTERNBREAK, // Long pattern break (in hex) CMD_S3MCMDEX, // Fine slide commands CMD_NONE, // Fractional BPM CMD_KEYOFF, // Key off at tick xx CMD_PORTAMENTOUP, // Porta up, but uses all octaves (?) CMD_PORTAMENTODOWN, // Porta down, but uses all octaves (?) CMD_NONE, CMD_NONE, CMD_NONE, CMD_NONE, CMD_NONE, CMD_NONE, CMD_NONE, CMD_GLOBALVOLSLIDE, // Global volume slide CMD_NONE, CMD_GLOBALVOLUME, // Global volume (0... 127) }; ModCommand dummy; for(ROWINDEX row = 0; row < pattern.GetNumRows(); row++) { PatternRow baseRow = pattern.GetRow(row); while(patternChunk.AreBytesLeft()) { const uint8 flags = patternChunk.ReadUint8(); if(flags == emptyRow) { break; } const CHANNELINDEX chn = (flags & channelMask); ModCommand &m = chn < pattern.GetNumChannels() ? baseRow[chn] : dummy; bool moreCommands = true; if(!(flags & noteMask)) { // Read note + instr uint8 note = patternChunk.ReadUint8(); moreCommands = (note & readNextCmd) != 0; note &= noteDataMask; if(note == 1) { m.note = NOTE_KEYOFF; } else if(note >= 2 && note <= 121 && newVersion) { m.note = note - 2 + NOTE_MIN; } else if(note >= 12 && note <= 108 && !newVersion) { m.note = note + 12 + NOTE_MIN; } m.instr = patternChunk.ReadUint8(); } while(moreCommands) { // Read one more effect command ModCommand origCmd = m; const uint8 command = patternChunk.ReadUint8(), effect = (command & commandMask); moreCommands = (command & readNextCmd) != 0; if(command & volCommand) { m.volcmd = VOLCMD_VOLUME;//.........这里部分代码省略.........
开发者ID:ksnydertn,项目名称:modplug,代码行数:101,
示例5: GetItemvoid CUser::MerchantItemBuy(Packet & pkt){ uint32 itemid, req_gold; uint16 item_count, leftover_count; uint8 item_slot, dest_slot; CUser *pMerchant = g_pMain->GetUserPtr(m_sMerchantsSocketID); if (pMerchant == NULL) return; pkt >> itemid >> item_count >> item_slot >> dest_slot; // Make sure the slots are correct and that we're actually buying at least 1 item. if (item_slot >= MAX_MERCH_ITEMS || dest_slot >= HAVE_MAX || item_count == 0) return; // Grab pointers to the items. _MERCH_DATA *pMerch = &pMerchant->m_arMerchantItems[item_slot]; _ITEM_DATA *pItem = GetItem(SLOT_MAX + dest_slot); // Make sure the merchant actually has that item in that slot // and that they have enough if (pMerch->nNum != itemid || pMerch->sCount < item_count) return; // If it's not stackable, and we're specifying something other than 1 // we really don't care to handle this request... _ITEM_TABLE *proto = g_pMain->GetItemPtr(itemid); if (proto == NULL || !proto->m_bCountable && item_count != 1) return; // Do we have enough coins? req_gold = pMerch->nPrice * item_count; if (m_iGold < req_gold) return; // If the slot's not empty if (pItem->nNum != 0 // and we already have an item that isn't the same item // or it's the same item but the item's not stackable... && (pItem->nNum != itemid || !proto->m_bCountable)) return; leftover_count = pMerch->sCount - item_count; pMerchant->GoldChange(GetSocketID(), req_gold); pItem->nNum = itemid; pItem->sCount += item_count; pItem->sDuration = pMerch->sDuration; pItem->nSerialNum = pMerch->nSerialNum; pMerch->sCount -= item_count; // TO-DO : Proper checks for the removal of the items in the array, we're now assuming everything gets bought if (pMerch->sCount == 0) memset(pMerch, 0, sizeof(_MERCH_DATA)); SetSlotItemValue(); pMerchant->SetSlotItemValue(); SetUserAbility(); pMerchant->SetUserAbility(); SendStackChange(itemid, pItem->sCount, pItem->sDuration, dest_slot, (pItem->sCount == item_count)); // is it a new item? pMerchant->SendStackChange(itemid, leftover_count, pMerch->sDuration, pMerch->bOriginalSlot - SLOT_MAX); Packet result(WIZ_MERCHANT, uint8(MERCHANT_ITEM_PURCHASED)); result << itemid << GetName(); pMerchant->Send(&result); result.clear(); result << uint8(MERCHANT_ITEM_BUY) << uint16(1) << itemid << leftover_count << item_slot << dest_slot; Send(&result); if (item_slot < 4 && leftover_count == 0) { result.Initialize(WIZ_MERCHANT_INOUT); result << uint8(2) << m_sMerchantsSocketID << uint16(item_slot); pMerchant->SendToRegion(&result); } int nItemsRemaining = 0; for (int i = 0; i < MAX_MERCH_ITEMS; i++) { if (pMerchant->m_arMerchantItems[i].nNum != 0) nItemsRemaining++; } if (nItemsRemaining == 0) MerchantClose();}
开发者ID:Witoldinio,项目名称:snoxd-koserver,代码行数:100,
示例6: TRACE//.........这里部分代码省略......... if (pNpc == NULL || pNpc->m_NpcState == NPC_DEAD) continue; if( m_pSrcUser->m_bNation == pNpc->m_byGroup ) continue; vEnd.Set(pNpc->m_fCurX, pNpc->m_fCurY, pNpc->m_fCurZ); fDis = pNpc->GetDistance(vStart, vEnd); if(fDis > fRadius) continue; if(magictype == 3) { // C++ uint8_fromregion函数代码示例 C++ uint64_t函数代码示例
|