void CUser::ReqWithdrawKnights(Packet & pkt)
{
	Packet result(WIZ_KNIGHTS_PROCESS, uint8(KNIGHTS_WITHDRAW));
	uint16 sClanID;
	pkt >> sClanID;

	_USER_DATA *pUser = m_DBAgent.GetUser(uid);
	if (pUser == NULL)
		return;

	string strCharID = pUser->m_id;

	result << int8(m_DBAgent.UpdateKnights(KNIGHTS_WITHDRAW, strCharID, sClanID, 0))
		   << sClanID;
	m_LoggerSendQueue.PutData(&result, uid);
}
Esempio n. 2
0
 void SetData(uint32 uiType, uint32 uiData)
 {
     if(!EventInProgress && uiType == DATA_BRANN_EVENT)
     {
         me->AddUnitMovementFlag(MOVEMENTFLAG_WALKING);
         me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
         EventInProgress = true;
         Talk(SAY_BRANN_INTRO_1);
         events.ScheduleEvent(EVENT_OPEN_DOOR, 3000);
     }
     else if(uiType == DATA_BRANN_ELEMENTALS)
     {
         elementals = int8(uiData);
         if(EventInProgress)
             Talk(SAY_BRANN_ELEMENTALS_1 + uiData - 1);
     }
 }
Esempio n. 3
0
void SpellHistory::WritePacket(WorldPackets::Pet::PetSpells* petSpells) const
{
    Clock::time_point now = Clock::now();

    petSpells->Cooldowns.reserve(_spellCooldowns.size());
    for (auto const& p : _spellCooldowns)
    {
        WorldPackets::Pet::PetSpellCooldown petSpellCooldown;
        petSpellCooldown.SpellID = p.first;
        petSpellCooldown.Category = p.second.CategoryId;

        if (!p.second.OnHold)
        {
            std::chrono::milliseconds cooldownDuration = std::chrono::duration_cast<std::chrono::milliseconds>(p.second.CooldownEnd - now);
            if (cooldownDuration.count() <= 0)
                continue;

            petSpellCooldown.Duration = uint32(cooldownDuration.count());
            std::chrono::milliseconds categoryDuration = std::chrono::duration_cast<std::chrono::milliseconds>(p.second.CategoryEnd - now);
            if (categoryDuration.count() > 0)
                petSpellCooldown.CategoryDuration = uint32(categoryDuration.count());
        }
        else
            petSpellCooldown.CategoryDuration = 0x80000000;

        petSpells->Cooldowns.push_back(petSpellCooldown);
    }

    petSpells->SpellHistory.reserve(_categoryCharges.size());
    for (auto const& p : _categoryCharges)
    {
        if (!p.second.empty())
        {
            std::chrono::milliseconds cooldownDuration = std::chrono::duration_cast<std::chrono::milliseconds>(p.second.front().RechargeEnd - now);
            if (cooldownDuration.count() <= 0)
                continue;

            WorldPackets::Pet::PetSpellHistory petChargeEntry;
            petChargeEntry.CategoryID = p.first;
            petChargeEntry.RecoveryTime = uint32(cooldownDuration.count());
            petChargeEntry.ConsumedCharges = int8(p.second.size());

            petSpells->SpellHistory.push_back(petChargeEntry);
        }
    }
}
    void MoveSplineInit::Stop()
    {
        MoveSpline& move_spline = *unit->movespline;

        // No need to stop if we are not moving
        if (move_spline.Finalized())
            return;

        bool transport = unit->HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT) && unit->GetTransGUID();
        Location loc;
        if (move_spline.onTransport == transport)
            loc = move_spline.ComputePosition();
        else
        {
            Position const* pos;
            if (!transport)
                pos = unit;
            else
                pos = &unit->m_movementInfo.transport.pos;

            loc.x = pos->GetPositionX();
            loc.y = pos->GetPositionY();
            loc.z = pos->GetPositionZ();
            loc.orientation = unit->GetOrientation();
        }

        args.flags = MoveSplineFlag::Done;
        unit->m_movementInfo.RemoveMovementFlag(MOVEMENTFLAG_FORWARD | MOVEMENTFLAG_SPLINE_ENABLED);
        move_spline.onTransport = transport;
        move_spline.Initialize(args);

        WorldPacket data(SMSG_MONSTER_MOVE, 64);
        data.append(unit->GetPackGUID());
        if (transport)
        {
            data.SetOpcode(SMSG_MONSTER_MOVE_TRANSPORT);
            data.appendPackGUID(unit->GetTransGUID());
            data << int8(unit->GetTransSeat());
        }

        // Xinef: increase z position in packet
        loc.z += unit->GetHoverHeight();
        PacketBuilder::WriteStopMovement(loc, args.splineId, data);
        unit->SendMessageToSet(&data, true);
    }
Esempio n. 5
0
//-------------------------------------------------------------------------------------
void ServerApp::lookApp(Network::Channel* pChannel)
{
	if(pChannel->isExternal())
		return;

	DEBUG_MSG(fmt::format("ServerApp::lookApp: {}\n", pChannel->c_str()));

	Network::Bundle* pBundle = Network::Bundle::ObjPool().createObject();
	
	(*pBundle) << g_componentType;
	(*pBundle) << componentID_;

	ShutdownHandler::SHUTDOWN_STATE state = shuttingdown();
	int8 istate = int8(state);
	(*pBundle) << istate;

	pChannel->send(pBundle);
}
int strokeDictBuild (const char*rawDictName, const char*chineseDictName,const char*treeFileName)
{
    TernarySearchTree tst;
    if((!rawDictName)||(!chineseDictName)||(!treeFileName)) {
        return -1;
    }
    FILE * fr = fopen( rawDictName,"r" );
    FILE * fc = fopen( chineseDictName,"rb" );
    FILE * ft = fopen (treeFileName,"wb");
    if( !fr || !fc || !ft) {
        return -1;
    }

    char s[MAX_LINE_LEN] = {};
    int8 charFreq = 0;
    size_t tmpFreq = 0;
    char16 charCode = 0;
    if(fread(&charCode,sizeof(char16),1,fc)==NULL) {
        return -1;   // skip the little endian flag at the beginning of the file
    }
    while(fscanf( fr,"%s%d",s,&tmpFreq) != EOF)
    {
        charFreq = int8(tmpFreq);
        fread(&charCode, sizeof(char16),1,fc);
        tst.add( s, charCode,charFreq);

        //Reset temporary char string.
        for (size_t i = 0; i<MAX_LINE_LEN; i++)
        {
            s[i] = '\0';
        }
    }
    size_t nodesCount = tst.getNodesCount();
    fwrite(&nodesCount,sizeof(size_t),1,ft);
    fwrite(tst.getNodeBuffer(0),sizeof(TstNode),nodesCount,ft);

    fclose(fr);
    fclose(fc);
    fclose(ft);

    return 0;
}
Esempio n. 7
0
//-------------------------------------------------------------------------------------
void ServerApp::lookApp(Mercury::Channel* pChannel)
{
	if(pChannel->isExternal())
		return;

	DEBUG_MSG(boost::format("ServerApp::lookApp: %1%\n") % pChannel->c_str());

	Mercury::Bundle* pBundle = Mercury::Bundle::ObjPool().createObject();
	
	(*pBundle) << g_componentType;
	(*pBundle) << componentID_;

	ShutdownHandler::SHUTDOWN_STATE state = shuttingdown();
	int8 istate = int8(state);
	(*pBundle) << istate;

	(*pBundle).send(getNetworkInterface(), pChannel);

	Mercury::Bundle::ObjPool().reclaimObject(pBundle);
}
Esempio n. 8
0
int main(int argc, char **argc)
{
	double f_s[]={38.192e6,16.368e6,8.184e6};
	double taums[]={1,2,4,8,16};
	double tau,ns,crate,coff,freq,phi0,ti;
	double I[3],Q[3];
	char *data;
	int i,j,k,dtype,sat,s,nc,nt,n;
	
	dtype=1;
	sat  =1;
	freq =9.548e6;
	crate=1023000;
	coff =1234.5;
	s    =20;
	
	for (i=0;i<4;i++) for (j=0;j<5;j++) {
		
		printf('sampling rate=%.3fMHz\n',f_s/1e6);
		
		tau  =taums[j]*1e-3;
		ns   =tau*f_s[i];
		if (dtype) nt=ns*2; else nt=ns;
		phi0 =0.1234;
		data=int8((rand(1,nt)-0.5)*4);
		ti   =1/f_s;
		n    =100000/taums;
		
		tic,
		for (k=0;k<n;k++) {
			correlator(data,dtype,ti,freq,phi0,sat,0,crate,coff,s,1,I,Q);
		}
		t=toc;
		
		printf("tau=%2.0fms: ns=%7d time=%5.3fms rate=%.1fMsps\n",...
	           taums,ns,t/n*1e3,n*ns/t/1e6);
	}
	return 0;
}
Esempio n. 9
0
CGOGN_IO_API std::string cgogn_name_of_type_to_vtk_xml_data_type(const std::string& cgogn_type)
{
	static const std::map<std::string, std::string> type_map{
		{name_of_type(int8()), "Int8"},
		{name_of_type(uint8()), "UInt8"},
		{name_of_type(int16()), "Int16"},
		{name_of_type(uint16()), "UInt16"},
		{name_of_type(int32()), "Int32"},
		{name_of_type(uint32()), "UInt32"},
		{name_of_type(int64()), "Int64"},
		{name_of_type(uint64()), "UInt64"},
		{name_of_type(float32()), "Float32"},
		{name_of_type(float64()), "Float64"}
	};

	const auto it = type_map.find(cgogn_type);
	if ( it != type_map.end())
		return it->second;

	cgogn_log_error("cgogn_name_of_type_to_vtk_xml_data_type") << "Unknown cgogn type \"" << cgogn_type << "\".";
	return std::string();
}
Esempio n. 10
0
CGOGN_IO_API std::string cgogn_name_of_type_to_vtk_legacy_data_type(const std::string& cgogn_type)
{
	static const std::map<std::string, std::string> type_map{
		{name_of_type(bool()), "bit"},
		{name_of_type(int8()), "char"},
		{name_of_type(uint8()), "unsigned_char"},
		{name_of_type(int16()), "short"},
		{name_of_type(uint16()), "unsigned_short"},
		{name_of_type(int32()), "int"},
		{name_of_type(uint32()), "unsigned_int"},
		{name_of_type(int64()), "long"},
		{name_of_type(uint64()), "unsigned_long"},
		{name_of_type(float32()), "float"},
		{name_of_type(float64()), "double"}
	};

	const auto it = type_map.find(cgogn_type);
	if ( it != type_map.end())
		return it->second;

	cgogn_log_error("cgogn_name_of_type_to_vtk_legacy_data_type") << "Unknown cgogn type \"" << cgogn_type << "\".";
	return std::string();
}
Esempio n. 11
0
// Convert OpenMPT's internal sample representation to an XMInstrument.
uint16 XMInstrument::ConvertToXM(const ModInstrument &mptIns, bool compatibilityExport)
//-------------------------------------------------------------------------------------
{
	MemsetZero(*this);

	// FFF is maximum in the FT2 GUI, but it can also accept other values. MilkyTracker just allows 0...4095 and 32767 ("cut")
	volFade = static_cast<uint16>(std::min(mptIns.nFadeOut, uint32(32767)));

	// Convert envelopes
	ConvertEnvelopeToXM(mptIns.VolEnv, volPoints, volFlags, volSustain, volLoopStart, volLoopEnd, EnvTypeVol);
	ConvertEnvelopeToXM(mptIns.PanEnv, panPoints, panFlags, panSustain, panLoopStart, panLoopEnd, EnvTypePan);

	// Create sample assignment table
	std::vector<SAMPLEINDEX> sampleList = GetSampleList(mptIns, compatibilityExport);
	for(size_t i = 0; i < CountOf(sampleMap); i++)
	{
		if(mptIns.Keyboard[i + 12] > 0)
		{
			std::vector<SAMPLEINDEX>::iterator sample = std::find(sampleList.begin(), sampleList.end(), mptIns.Keyboard[i + 12]);
			if(sample != sampleList.end())
			{
				// Yep, we want to export this sample.
				sampleMap[i] = static_cast<uint8>(sample - sampleList.begin());
			}
		}
	}

	if(mptIns.nMidiChannel != MidiNoChannel)
	{
		midiEnabled = 1;
		midiChannel = (mptIns.nMidiChannel != MidiMappedChannel ? (mptIns.nMidiChannel - MidiFirstChannel) : 0);
	}
	midiProgram = (mptIns.nMidiProgram != 0 ? mptIns.nMidiProgram - 1 : 0);
	pitchWheelRange = std::min(mptIns.midiPWD, int8(36));

	return static_cast<uint16>(sampleList.size());
}
Esempio n. 12
0
WorldPacket const* WorldPackets::CombatLog::AttackerStateUpdate::Write()
{
    ByteBuffer attackRoundInfo;
    attackRoundInfo << uint32(HitInfo);
    attackRoundInfo << AttackerGUID;
    attackRoundInfo << VictimGUID;
    attackRoundInfo << int32(Damage);
    attackRoundInfo << int32(OverDamage);
    attackRoundInfo << uint8(SubDmg.is_initialized());
    if (SubDmg)
    {
       attackRoundInfo << int32(SubDmg->SchoolMask);
       attackRoundInfo << float(SubDmg->FDamage);
       attackRoundInfo << int32(SubDmg->Damage);
        if (HitInfo & (HITINFO_FULL_ABSORB | HITINFO_PARTIAL_ABSORB))
            attackRoundInfo << int32(SubDmg->Absorbed);
        if (HitInfo & (HITINFO_FULL_RESIST | HITINFO_PARTIAL_RESIST))
            attackRoundInfo << int32(SubDmg->Resisted);
    }

    attackRoundInfo << uint8(VictimState);
    attackRoundInfo << uint32(AttackerState);
    attackRoundInfo << uint32(MeleeSpellID);
    if (HitInfo & HITINFO_BLOCK)
        attackRoundInfo << int32(BlockAmount);

    if (HitInfo & HITINFO_RAGE_GAIN)
        attackRoundInfo << int32(RageGained);

    if (HitInfo & HITINFO_UNK1)
    {
        attackRoundInfo << uint32(UnkState.State1);
        attackRoundInfo << float(UnkState.State2);
        attackRoundInfo << float(UnkState.State3);
        attackRoundInfo << float(UnkState.State4);
        attackRoundInfo << float(UnkState.State5);
        attackRoundInfo << float(UnkState.State6);
        attackRoundInfo << float(UnkState.State7);
        attackRoundInfo << float(UnkState.State8);
        attackRoundInfo << float(UnkState.State9);
        attackRoundInfo << float(UnkState.State10);
        attackRoundInfo << float(UnkState.State11);
        attackRoundInfo << uint32(UnkState.State12);
    }

    if (HitInfo & (HITINFO_BLOCK | HITINFO_UNK12))
        attackRoundInfo << float(Unk);

    attackRoundInfo << uint8(SandboxScaling.Type);
    attackRoundInfo << uint8(SandboxScaling.TargetLevel);
    attackRoundInfo << uint8(SandboxScaling.Expansion);
    attackRoundInfo << uint8(SandboxScaling.Class);
    attackRoundInfo << uint8(SandboxScaling.TargetMinScalingLevel);
    attackRoundInfo << uint8(SandboxScaling.TargetMaxScalingLevel);
    attackRoundInfo << int16(SandboxScaling.PlayerLevelDelta);
    attackRoundInfo << int8(SandboxScaling.TargetScalingLevelDelta);

    WriteLogDataBit();
    FlushBits();
    WriteLogData();

    *this << uint32(attackRoundInfo.size());
    _worldPacket.append(attackRoundInfo);
    _fullLogPacket.append(attackRoundInfo);

    return &_worldPacket;
}
Esempio n. 13
0
// Translate instrument properties between two given formats.
void ModInstrument::Convert(MODTYPE fromType, MODTYPE toType)
{
	MPT_UNREFERENCED_PARAMETER(fromType);

	if(toType & MOD_TYPE_XM)
	{
		ResetNoteMap();

		PitchEnv.dwFlags.reset(ENV_ENABLED | ENV_FILTER);

		dwFlags.reset(INS_SETPANNING);
		SetCutoff(GetCutoff(), false);
		SetResonance(GetResonance(), false);
		nFilterMode = FLTMODE_UNCHANGED;

		nCutSwing = nPanSwing = nResSwing = nVolSwing = 0;

		nPPC = NOTE_MIDDLEC - 1;
		nPPS = 0;

		nNNA = NNA_NOTECUT;
		nDCT = DCT_NONE;
		nDNA = DNA_NOTECUT;

		if(nMidiChannel == MidiMappedChannel)
		{
			nMidiChannel = 1;
		}

		// FT2 only has unsigned Pitch Wheel Depth, and it's limited to 0...36 (in the GUI, at least. As you would expect it from FT2, this value is actually not sanitized on load).
		midiPWD = static_cast<int8>(mpt::abs(midiPWD));
		Limit(midiPWD, int8(0), int8(36));

		nGlobalVol = 64;
		nPan = 128;

		LimitMax(nFadeOut, 32767u);
	}

	VolEnv.Convert(fromType, toType);
	PanEnv.Convert(fromType, toType);
	PitchEnv.Convert(fromType, toType);

	if(fromType == MOD_TYPE_XM && (toType & (MOD_TYPE_IT | MOD_TYPE_MPT)))
	{
		if(!VolEnv.dwFlags[ENV_ENABLED])
		{
			// Note-Off with no envelope cuts the note immediately in XM
			VolEnv.resize(2);
			VolEnv[0].tick = 0;
			VolEnv[0].value =  ENVELOPE_MAX;
			VolEnv[1].tick = 1;
			VolEnv[1].value =  ENVELOPE_MIN;
			VolEnv.dwFlags.set(ENV_ENABLED | ENV_SUSTAIN);
			VolEnv.dwFlags.reset(ENV_LOOP);
			VolEnv.nSustainStart = VolEnv.nSustainEnd = 0;
		}
	}

	// Limit fadeout length for IT
	if(toType & MOD_TYPE_IT)
	{
		LimitMax(nFadeOut, 8192u);
	}

	// MPT-specific features - remove instrument tunings, Pitch/Tempo Lock, cutoff / resonance swing and filter mode for other formats
	if(!(toType & MOD_TYPE_MPT))
	{
		SetTuning(nullptr);
		pitchToTempoLock.Set(0);
		nCutSwing = nResSwing = 0;
		nFilterMode = FLTMODE_UNCHANGED;
		nVolRampUp = 0;
	}
}
Esempio n. 14
0
void SampleConverter::convert(int8 *dest, const uint8 *source, int samplecount)
{
	while (samplecount--)
		*dest++ = int8(*source++ - 128);
}
Esempio n. 15
0
void MidiParser_S1D::parseNextEvent(EventInfo &info) {
	info.start = _position._playPos;
	info.length = 0;
	info.delta = _noDelta ? 0 : readVLQ2(_position._playPos);
	_noDelta = false;

	info.event = *_position._playPos++;
	if (!(info.event & 0x80)) {
		_noDelta = true;
		info.event |= 0x80;
	}

	if (info.event == 0xFC) {
		// This means End of Track.
		// Rewrite in SMF (MIDI transmission) form.
		info.event = 0xFF;
		info.ext.type = 0x2F;
	} else {
		switch (info.command()) {
		case 0x8: // note off
			info.basic.param1 = *_position._playPos++;
			info.basic.param2 = 0;
			break;

		case 0x9: // note on
			info.basic.param1 = *_position._playPos++;
			info.basic.param2 = *_position._playPos++;
			// Rewrite note on events with velocity 0 as note off events.
			// This is the actual meaning of this, but theoretically this
			// should not need to be rewritten, since all MIDI devices should
			// interpret it like that. On the other hand all our MidiParser
			// implementations do it and there seems to be code in MidiParser
			// which relies on this for tracking active notes.
			if (info.basic.param2 == 0) {
				info.event = info.channel() | 0x80;
			}
			break;

		case 0xA: { // loop control
			// In case the stop mode(?) is set to 0x80 this will stop the
			// track over here.

			const int16 loopIterations = int8(*_position._playPos++);
			if (!loopIterations) {
				_loops[info.channel()].start = _position._playPos;
			} else {
				if (!_loops[info.channel()].timer) {
					if (_loops[info.channel()].start) {
						_loops[info.channel()].timer = uint16(loopIterations);
						_loops[info.channel()].end = _position._playPos;

						// Go to the start of the loop
						_position._playPos = _loops[info.channel()].start;
					}
				} else {
					if (_loops[info.channel()].timer)
						_position._playPos = _loops[info.channel()].start;
					--_loops[info.channel()].timer;
				}
			}

			// We need to read the next midi event here. Since we can not
			// safely pass this event to the MIDI event processing.
			chainEvent(info);
			} break;

		case 0xB: // auto stop marker(?)
			// In case the stop mode(?) is set to 0x80 this will stop the
			// track.

			// We need to read the next midi event here. Since we can not
			// safely pass this event to the MIDI event processing.
			chainEvent(info);
			break;

		case 0xC: // program change
			info.basic.param1 = *_position._playPos++;
			info.basic.param2 = 0;
			break;

		case 0xD: // jump to loop end
			if (_loops[info.channel()].end)
				_position._playPos = _loops[info.channel()].end;

			// We need to read the next midi event here. Since we can not
			// safely pass this event to the MIDI event processing.
			chainEvent(info);
			break;

		default:
			// The original called some other function from here, which seems
			// not to be MIDI related.
			warning("MidiParser_S1D: default case %d", info.channel());

			// We need to read the next midi event here. Since we can not
			// safely pass this event to the MIDI event processing.
			chainEvent(info);
			break;
		}
	}
}
Esempio n. 16
0
void MailDraft::SendMailTo(SQLTransaction& trans, MailReceiver const& receiver, MailSender const& sender, MailCheckMask checked, uint32 deliver_delay)
{
    Player* pReceiver = receiver.GetPlayer();               // can be NULL
    Player* pSender = sObjectMgr->GetPlayerByLowGUID(sender.GetSenderId());

    if (pReceiver)
        prepareItems(pReceiver, trans);                            // generate mail template items

    uint32 mailId = sObjectMgr->GenerateMailID();

    time_t deliver_time = time(NULL) + deliver_delay;

    //expire time if COD 3 days, if no COD 30 days, if auction sale pending 1 hour
    uint32 expire_delay;

    // auction mail without any items and money
    if (sender.GetMailMessageType() == MAIL_AUCTION && m_items.empty() && !m_money)
        expire_delay = sWorld->getIntConfig(CONFIG_MAIL_DELIVERY_DELAY);
    // mail from battlemaster (rewardmarks) should last only one day
    else if (sender.GetMailMessageType() == MAIL_CREATURE && sBattlegroundMgr->GetBattleMasterBG(sender.GetSenderId()) != BATTLEGROUND_TYPE_NONE)
        expire_delay = DAY;
     // default case: expire time if COD 3 days, if no COD 30 days (or 90 days if sender is a game master)
    else
    {
        if (m_COD)
            expire_delay = 3 * DAY;
        else
            expire_delay = pSender && pSender->IsGameMaster() ? 90 * DAY : 30 * DAY;
    }

    time_t expire_time = deliver_time + expire_delay;

    // Add to DB
    uint8 index = 0;
    PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_MAIL);
    stmt->setUInt32(  index, mailId);
    stmt->setUInt8 (++index, uint8(sender.GetMailMessageType()));
    stmt->setInt8  (++index, int8(sender.GetStationery()));
    stmt->setUInt16(++index, GetMailTemplateId());
    stmt->setUInt32(++index, sender.GetSenderId());
    stmt->setUInt32(++index, receiver.GetPlayerGUIDLow());
    stmt->setString(++index, GetSubject());
    stmt->setString(++index, GetBody());
    stmt->setBool  (++index, !m_items.empty());
    stmt->setUInt64(++index, uint64(expire_time));
    stmt->setUInt64(++index, uint64(deliver_time));
    stmt->setUInt32(++index, m_money);
    stmt->setUInt32(++index, m_COD);
    stmt->setUInt8 (++index, uint8(checked));
    trans->Append(stmt);

    for (MailItemMap::const_iterator mailItemIter = m_items.begin(); mailItemIter != m_items.end(); ++mailItemIter)
    {
        Item* pItem = mailItemIter->second;
        stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_MAIL_ITEM);
        stmt->setUInt32(0, mailId);
        stmt->setUInt32(1, pItem->GetGUID().GetCounter());
        stmt->setUInt32(2, receiver.GetPlayerGUIDLow());
        trans->Append(stmt);
    }

    // For online receiver update in game mail status and data
    if (pReceiver)
    {
        pReceiver->AddNewMailDeliverTime(deliver_time);

        if (pReceiver->IsMailsLoaded())
        {
            Mail* m = new Mail;
            m->messageID = mailId;
            m->mailTemplateId = GetMailTemplateId();
            m->subject = GetSubject();
            m->body = GetBody();
            m->money = GetMoney();
            m->COD = GetCOD();

            for (MailItemMap::const_iterator mailItemIter = m_items.begin(); mailItemIter != m_items.end(); ++mailItemIter)
            {
                Item* item = mailItemIter->second;
                m->AddItem(item->GetGUID().GetCounter(), item->GetEntry());
            }

            m->messageType = sender.GetMailMessageType();
            m->stationery = sender.GetStationery();
            m->sender = sender.GetSenderId();
            m->receiver = receiver.GetPlayerGUIDLow();
            m->expire_time = expire_time;
            m->deliver_time = deliver_time;
            m->checked = checked;
            m->state = MAIL_STATE_UNCHANGED;

            pReceiver->AddMail(m);                           // to insert new mail to beginning of maillist

            if (!m_items.empty())
            {
                for (MailItemMap::iterator mailItemIter = m_items.begin(); mailItemIter != m_items.end(); ++mailItemIter)
                    pReceiver->AddMItem(mailItemIter->second);
            }
        }
        else if (!m_items.empty())
        {
            SQLTransaction temp = SQLTransaction(NULL);
            deleteIncludedItems(temp);
        }
    }
    else if (!m_items.empty())
    {
        SQLTransaction temp = SQLTransaction(NULL);
        deleteIncludedItems(temp);
    }
}
Esempio n. 17
0
    int32 MoveSplineInit::Launch()
    {
        MoveSpline& move_spline = *unit.movespline;
        TransportInfo* transportInfo = unit.GetTransportInfo();

        Location real_position(unit.GetPositionX(), unit.GetPositionY(), unit.GetPositionZ(), unit.GetOrientation());

        // If boarded use current local position
        if (transportInfo)
            transportInfo->GetLocalPosition(real_position.x, real_position.y, real_position.z, real_position.orientation);

        // there is a big chane that current position is unknown if current state is not finalized, need compute it
        // this also allows calculate spline position and update map position in much greater intervals
        if (!move_spline.Finalized() && !transportInfo)
            real_position = move_spline.ComputePosition();

        if (args.path.empty())
        {
            // should i do the things that user should do?
            MoveTo(real_position);
        }

        // corrent first vertex
        args.path[0] = real_position;
        args.initialOrientation = real_position.orientation;

        uint32 moveFlags = unit.m_movementInfo.GetMovementFlags();
        if (args.flags.walkmode)
            moveFlags |= MOVEFLAG_WALK_MODE;
        else
            moveFlags &= ~MOVEFLAG_WALK_MODE;

        moveFlags |= (MOVEFLAG_SPLINE_ENABLED | MOVEFLAG_FORWARD);

        if (fabs(args.velocity) < M_NULL_F)
            args.velocity = unit.GetSpeed(SelectSpeedType(moveFlags));

        if (!args.Validate(&unit))
            return 0;

        if (moveFlags & MOVEFLAG_ROOT)
            moveFlags &= ~MOVEFLAG_MASK_MOVING;

        unit.m_movementInfo.SetMovementFlags((MovementFlags)moveFlags);
        move_spline.Initialize(args);

        WorldPacket data(SMSG_MONSTER_MOVE, 64);
        data << unit.GetPackGUID();

        if (transportInfo)
        {
            data.SetOpcode(SMSG_MONSTER_MOVE_TRANSPORT);
            data << transportInfo->GetTransportGuid().WriteAsPacked();
            data << int8(transportInfo->GetTransportSeat());
        }

        PacketBuilder::WriteMonsterMove(move_spline, data);
        unit.SendMessageToSet(&data, true);

        return move_spline.Duration();
    }
Esempio n. 18
0
void PlayerMenu::SendQuestQueryResponse(Quest const* quest) const
{
    std::string questTitle = quest->GetTitle();
    std::string questDetails = quest->GetDetails();
    std::string questObjectives = quest->GetObjectives();
    std::string questEndText = quest->GetEndText();
    std::string questCompletedText = quest->GetCompletedText();
    std::string questGiverTextWindow = quest->GetQuestGiverTextWindow();
    std::string questGiverTargetName = quest->GetQuestGiverTargetName();
    std::string questTurnTextWindow = quest->GetQuestTurnTextWindow();
    std::string questTurnTargetName = quest->GetQuestTurnTargetName();

    int32 locale = _session->GetSessionDbLocaleIndex();
    if (locale >= 0)
    {
        if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId()))
        {
            ObjectMgr::GetLocaleString(localeData->Title, locale, questTitle);
            ObjectMgr::GetLocaleString(localeData->Details, locale, questDetails);
            ObjectMgr::GetLocaleString(localeData->Objectives, locale, questObjectives);
            ObjectMgr::GetLocaleString(localeData->EndText, locale, questEndText);
            ObjectMgr::GetLocaleString(localeData->CompletedText, locale, questCompletedText);
            ObjectMgr::GetLocaleString(localeData->QuestGiverTextWindow, locale, questGiverTextWindow);
            ObjectMgr::GetLocaleString(localeData->QuestGiverTargetName, locale, questGiverTargetName);
            ObjectMgr::GetLocaleString(localeData->QuestTurnTextWindow, locale, questTurnTextWindow);
            ObjectMgr::GetLocaleString(localeData->QuestTurnTargetName, locale, questTurnTargetName);
        }
    }

    if (sWorld->getBoolConfig(CONFIG_UI_QUESTLEVELS_IN_DIALOGS))
        AddQuestLevelToTitle(questTitle, quest->GetQuestLevel());

    bool hiddenReward = quest->HasFlag(QUEST_FLAGS_HIDDEN_REWARDS);

    WorldPacket data(SMSG_QUEST_QUERY_RESPONSE, 100);   // guess size
    data << uint32(quest->GetQuestId());

    data.WriteBit(1);                                   // has data
    data.FlushBits();

    data << int32(quest->GetQuestId());
    data << int32(quest->GetType());
    data << int32(quest->GetQuestLevel());
    data << int32(quest->GetRewardPackageItemId());
    data << int32(quest->GetMinLevel());
    data << int32(quest->GetZoneOrSort());
    data << int32(0);                                   // QuestInfoID
    data << int32(quest->GetSuggestedPlayers());
    data << int32(quest->GetNextQuestId());
    data << int32(quest->GetXPId());
    data << float(0);                                   // unknown
    data << int32(quest->GetRewMoney());
    data << int32(0);                                   // RewardMoneyDifficulty
    data << float(0);                                   // unknown
    data << int32(quest->GetRewMoneyMaxLevel());
    data << int32(quest->GetRewSpell());
    data << int32(quest->GetRewSpellCast());
    data << int32(quest->GetRewHonorAddition());
    data << float(quest->GetRewHonorMultiplier());
    data << int32(quest->GetSrcItemId());
    data << int32(quest->GetFlags());
    data << int32(quest->GetFlags2());

    for (uint8 i = 0; i < QUEST_REWARDS_COUNT; i++)
    {
        data << int32(hiddenReward ? 0 : quest->RewardItemId[i]);
        data << int32(hiddenReward ? 0 : quest->RewardItemIdCount[i]);
        data << int32(quest->RequiredSourceItemId[i]);
        data << int32(quest->RequiredSourceItemCount[i]);
    }

    for (uint8 i = 0; i < QUEST_REWARD_CHOICES_COUNT; i++)
    {
        data << int32(hiddenReward ? 0 : quest->RewardChoiceItemId[i]);
        data << int32(hiddenReward ? 0 : quest->RewardChoiceItemCount[i]);

        if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(quest->RewardChoiceItemId[i]))
            data << int32(hiddenReward ? 0 : itemTemplate->DisplayInfoID);
        else
            data << int32(0);
    }

    data << int32(quest->GetPointMapId());
    data << float(quest->GetPointX());
    data << float(quest->GetPointY());
    data << int32(quest->GetPointOpt());
    data << int32(quest->GetCharTitleId());
    data << int32(quest->GetBonusTalents());
    data << int32(quest->GetRewArenaPoints());
    data << int32(quest->GetRewardSkillId());
    data << int32(quest->GetRewardSkillPoints());
    data << int32(quest->GetQuestGiverPortrait());
    data << int32(quest->GetQuestTurnInPortrait());

    for (uint8 i = 0; i < QUEST_REPUTATIONS_COUNT; i++)
    {
        data << int32(hiddenReward ? 0 : quest->RewardFactionId[i]);
        data << int32(hiddenReward ? 0 : quest->RewardFactionValueId[i]);
        data << int32(hiddenReward ? 0 : quest->RewardFactionValueIdOverride[i]);
    }

    data << int32(quest->GetRewardReputationMask());

    for (uint8 i = 0; i < QUEST_REWARD_CURRENCY_COUNT; i++)
    {
        data << int32(hiddenReward ? 0 : quest->RewardCurrencyId[i]);
        data << int32(hiddenReward ? 0 : quest->RewardChoiceItemCount[i]);
    }

    data << int32(quest->GetSoundAccept());
    data << int32(quest->GetSoundTurnIn());
    data << int32(0);                                   // AreaGroupID
    data << int32(quest->GetLimitTime());
    data << uint32(quest->m_questObjectives.size());
    data << int32(quest->m_questObjectives.size());

    for (QuestObjectiveSet::const_iterator citr = quest->m_questObjectives.begin(); citr != quest->m_questObjectives.end(); citr++)
    {
        QuestObjective const* questObjective = *citr;

        std::string descriptionText = questObjective->Description;
        if (locale > 0)
            if (QuestObjectiveLocale const* questObjectiveLocale = sObjectMgr->GetQuestObjectiveLocale(questObjective->Id))
                ObjectMgr::GetLocaleString(questObjectiveLocale->Description, locale, descriptionText);

        data << int32(questObjective->Id);
        data << uint8(questObjective->Type);
        data << int8(questObjective->Index);
        data << int32(questObjective->ObjectId);
        data << int32(questObjective->Amount);
        data << int32(questObjective->Flags);
        data << float(0);                               // unknown
        data << uint32(questObjective->VisualEffects.size());

        for (VisualEffectVec::const_iterator citrEffects = questObjective->VisualEffects.begin(); citrEffects != questObjective->VisualEffects.end(); citrEffects++)
            data << int32(*citrEffects);

        data.WriteBits(descriptionText.size(), 8);
        data.WriteString(descriptionText);
    }

    data.WriteBits(questTitle.size(), 9);
    data.WriteBits(questObjectives.size(), 12);
    data.WriteBits(questDetails.size(), 12);
    data.WriteBits(questEndText.size(), 9);
    data.WriteBits(questGiverTextWindow.size(), 10);
    data.WriteBits(questGiverTargetName.size(), 8);
    data.WriteBits(questTurnTextWindow.size(), 10);
    data.WriteBits(questTurnTargetName.size(), 8);
    data.WriteBits(questCompletedText.size(), 11);
    data.FlushBits();

    data.WriteString(questTitle);
    data.WriteString(questObjectives);
    data.WriteString(questDetails);
    data.WriteString(questEndText);
    data.WriteString(questGiverTextWindow);
    data.WriteString(questGiverTargetName);
    data.WriteString(questTurnTextWindow);
    data.WriteString(questTurnTargetName);
    data.WriteString(questCompletedText);

    _session->SendPacket(&data);

    TC_LOG_DEBUG("network", "WORLD: Sent SMSG_QUEST_QUERY_RESPONSE questid=%u", quest->GetQuestId());
}
Esempio n. 19
0
uint32 CPU::decode(uint8 offset_type, uint32 addr) {
    uint32 r = 0;

    switch(offset_type) {
    case OPTYPE_DP:
        r = (regs.d + (addr & 0xffff)) & 0xffff;
        break;
    case OPTYPE_DPX:
        r = (regs.d + regs.x + (addr & 0xffff)) & 0xffff;
        break;
    case OPTYPE_DPY:
        r = (regs.d + regs.y + (addr & 0xffff)) & 0xffff;
        break;
    case OPTYPE_IDP:
        addr = (regs.d + (addr & 0xffff)) & 0xffff;
        r = (regs.db << 16) + dreadw(addr);
        break;
    case OPTYPE_IDPX:
        addr = (regs.d + regs.x + (addr & 0xffff)) & 0xffff;
        r = (regs.db << 16) + dreadw(addr);
        break;
    case OPTYPE_IDPY:
        addr = (regs.d + (addr & 0xffff)) & 0xffff;
        r = (regs.db << 16) + dreadw(addr) + regs.y;
        break;
    case OPTYPE_ILDP:
        addr = (regs.d + (addr & 0xffff)) & 0xffff;
        r = dreadl(addr);
        break;
    case OPTYPE_ILDPY:
        addr = (regs.d + (addr & 0xffff)) & 0xffff;
        r = dreadl(addr) + regs.y;
        break;
    case OPTYPE_ADDR:
        r = (regs.db << 16) + (addr & 0xffff);
        break;
    case OPTYPE_ADDR_PC:
        r = (regs.pc.b << 16) + (addr & 0xffff);
        break;
    case OPTYPE_ADDRX:
        r = (regs.db << 16) + (addr & 0xffff) + regs.x;
        break;
    case OPTYPE_ADDRY:
        r = (regs.db << 16) + (addr & 0xffff) + regs.y;
        break;
    case OPTYPE_IADDR_PC:
        r = (regs.pc.b << 16) + (addr & 0xffff);
        break;
    case OPTYPE_IADDRX:
        r = (regs.pc.b << 16) + ((addr + regs.x) & 0xffff);
        break;
    case OPTYPE_ILADDR:
        r = addr;
        break;
    case OPTYPE_LONG:
        r = addr;
        break;
    case OPTYPE_LONGX:
        r = (addr + regs.x);
        break;
    case OPTYPE_SR:
        r = (regs.s + (addr & 0xff)) & 0xffff;
        break;
    case OPTYPE_ISRY:
        addr = (regs.s + (addr & 0xff)) & 0xffff;
        r = (regs.db << 16) + dreadw(addr) + regs.y;
        break;
    case OPTYPE_RELB:
        r  = (regs.pc.b << 16) + ((regs.pc.w + 2) & 0xffff);
        r += int8(addr);
        break;
    case OPTYPE_RELW:
        r  = (regs.pc.b << 16) + ((regs.pc.w + 3) & 0xffff);
        r += int16(addr);
        break;
    }

    return(r & 0xffffff);
}
Esempio n. 20
0
    void BVH8Intersector8Hybrid<PrimitiveIntersector8>::occluded(bool8* valid_i, BVH8* bvh, Ray8& ray)
    {
      /* load ray */
      const bool8 valid = *valid_i;
      bool8 terminated = !valid;
      Vec3f8 ray_org = ray.org, ray_dir = ray.dir;
      float8 ray_tnear = ray.tnear, ray_tfar  = ray.tfar;
      const Vec3f8 rdir = rcp_safe(ray_dir);
      const Vec3f8 org(ray_org), org_rdir = org * rdir;
      ray_tnear = select(valid,ray_tnear,float8(pos_inf));
      ray_tfar  = select(valid,ray_tfar ,float8(neg_inf));
      const float8 inf = float8(pos_inf);
      Precalculations pre(valid,ray);

      /* compute near/far per ray */
      Vec3i8 nearXYZ;
      nearXYZ.x = select(rdir.x >= 0.0f,int8(0*(int)sizeof(float8)),int8(1*(int)sizeof(float8)));
      nearXYZ.y = select(rdir.y >= 0.0f,int8(2*(int)sizeof(float8)),int8(3*(int)sizeof(float8)));
      nearXYZ.z = select(rdir.z >= 0.0f,int8(4*(int)sizeof(float8)),int8(5*(int)sizeof(float8)));

      /* allocate stack and push root node */
      float8    stack_near[stackSizeChunk];
      NodeRef stack_node[stackSizeChunk];
      stack_node[0] = BVH8::invalidNode;
      stack_near[0] = inf;
      stack_node[1] = bvh->root;
      stack_near[1] = ray_tnear; 
      NodeRef* stackEnd = stack_node+stackSizeChunk;
      NodeRef* __restrict__ sptr_node = stack_node + 2;
      float8*    __restrict__ sptr_near = stack_near + 2;

      while (1)
      {
        /* pop next node from stack */
        assert(sptr_node > stack_node);
        sptr_node--;
        sptr_near--;
        NodeRef cur = *sptr_node;
        if (unlikely(cur == BVH8::invalidNode)) {
          assert(sptr_node == stack_node);
          break;
        }

        /* cull node if behind closest hit point */
        float8 curDist = *sptr_near;
        const bool8 active = curDist < ray_tfar;
        if (unlikely(none(active))) 
          continue;
        
        /* switch to single ray traversal */
#if !defined(__WIN32__) || defined(__X86_64__)
        size_t bits = movemask(active);
        if (unlikely(__popcnt(bits) <= SWITCH_THRESHOLD)) {
          for (size_t i=__bsf(bits); bits!=0; bits=__btc(bits,i), i=__bsf(bits)) {
            if (occluded1(bvh,cur,i,pre,ray,ray_org,ray_dir,rdir,ray_tnear,ray_tfar,nearXYZ))
              terminated[i] = -1;
          }
          if (all(terminated)) break;
          ray_tfar = select(terminated,float8(neg_inf),ray_tfar);
          continue;
        }
#endif
                
        while (1)
        {
          /* test if this is a leaf node */
          if (unlikely(cur.isLeaf()))
            break;
          
          const bool8 valid_node = ray_tfar > curDist;
          STAT3(shadow.trav_nodes,1,popcnt(valid_node),8);
          const Node* __restrict__ const node = (Node*)cur.node();
          
          /* pop of next node */
          assert(sptr_node > stack_node);
          sptr_node--;
          sptr_near--;
          cur = *sptr_node;
          curDist = *sptr_near;
          
          for (unsigned i=0; i<BVH8::N; i++)
          {
            const NodeRef child = node->children[i];
            if (unlikely(child == BVH8::emptyNode)) break;
            
#if defined(__AVX2__)
            const float8 lclipMinX = msub(node->lower_x[i],rdir.x,org_rdir.x);
            const float8 lclipMinY = msub(node->lower_y[i],rdir.y,org_rdir.y);
            const float8 lclipMinZ = msub(node->lower_z[i],rdir.z,org_rdir.z);
            const float8 lclipMaxX = msub(node->upper_x[i],rdir.x,org_rdir.x);
            const float8 lclipMaxY = msub(node->upper_y[i],rdir.y,org_rdir.y);
            const float8 lclipMaxZ = msub(node->upper_z[i],rdir.z,org_rdir.z);
            const float8 lnearP = maxi(maxi(mini(lclipMinX, lclipMaxX), mini(lclipMinY, lclipMaxY)), mini(lclipMinZ, lclipMaxZ));
            const float8 lfarP  = mini(mini(maxi(lclipMinX, lclipMaxX), maxi(lclipMinY, lclipMaxY)), maxi(lclipMinZ, lclipMaxZ));
            const bool8 lhit   = maxi(lnearP,ray_tnear) <= mini(lfarP,ray_tfar);      
#else
            const float8 lclipMinX = (node->lower_x[i] - org.x) * rdir.x;
            const float8 lclipMinY = (node->lower_y[i] - org.y) * rdir.y;
            const float8 lclipMinZ = (node->lower_z[i] - org.z) * rdir.z;
            const float8 lclipMaxX = (node->upper_x[i] - org.x) * rdir.x;
            const float8 lclipMaxY = (node->upper_y[i] - org.y) * rdir.y;
            const float8 lclipMaxZ = (node->upper_z[i] - org.z) * rdir.z;
            const float8 lnearP = max(max(min(lclipMinX, lclipMaxX), min(lclipMinY, lclipMaxY)), min(lclipMinZ, lclipMaxZ));
            const float8 lfarP  = min(min(max(lclipMinX, lclipMaxX), max(lclipMinY, lclipMaxY)), max(lclipMinZ, lclipMaxZ));
            const bool8 lhit   = max(lnearP,ray_tnear) <= min(lfarP,ray_tfar);      
#endif
            
            /* if we hit the child we choose to continue with that child if it 
               is closer than the current next child, or we push it onto the stack */
            if (likely(any(lhit)))
            {
              assert(sptr_node < stackEnd);
              assert(child != BVH8::emptyNode);
              const float8 childDist = select(lhit,lnearP,inf);
              sptr_node++;
              sptr_near++;
              
              /* push cur node onto stack and continue with hit child */
              if (any(childDist < curDist))
              {
                *(sptr_node-1) = cur;
                *(sptr_near-1) = curDist; 
                curDist = childDist;
                cur = child;
              }
              
              /* push hit child onto stack */
              else {
                *(sptr_node-1) = child;
                *(sptr_near-1) = childDist; 
              }
            }	      
          }
        }
        
        /* return if stack is empty */
        if (unlikely(cur == BVH8::invalidNode)) {
          assert(sptr_node == stack_node);
          break;
        }
        
        /* intersect leaf */
	assert(cur != BVH8::emptyNode);
        const bool8 valid_leaf = ray_tfar > curDist;
        STAT3(shadow.trav_leaves,1,popcnt(valid_leaf),8);
        size_t items; const Triangle* prim = (Triangle*) cur.leaf(items);
        terminated |= PrimitiveIntersector8::occluded(!terminated,pre,ray,prim,items,bvh->scene);
        if (all(terminated)) break;
        ray_tfar = select(terminated,float8(neg_inf),ray_tfar);
      }
      store8i(valid & terminated,&ray.geomID,0);
      AVX_ZERO_UPPER();
    }
Esempio n. 21
0
 ssize_t string8( const std::string &str ){
   ssize_t written = int8( str.length() );
   return written + string( str, false );
 }
int32 MoveSplineInit::Launch()
{
    MoveSpline& move_spline = *unit->movespline;

    bool transport = unit->GetTransGUID();
    Location real_position;
    // there is a big chance that current position is unknown if current state is not finalized, need compute it
    // this also allows calculate spline position and update map position in much greater intervals
    // Don't compute for transport movement if the unit is in a motion between two transports
    if (!move_spline.Finalized() && move_spline.onTransport == (unit->GetTransGUID() != 0))
        real_position = move_spline.ComputePosition();
    else
    {
        Position const* pos;
        if (!transport)
            pos = unit;
        else
            pos = &unit->m_movementInfo.transport.pos;

        real_position.x = pos->GetPositionX();
        real_position.y = pos->GetPositionY();
        real_position.z = pos->GetPositionZ();
        real_position.orientation = unit->GetOrientation();
    }

    // should i do the things that user should do? - no.
    if (args.path.empty())
        return 0;

    // correct first vertex
    args.path[0] = real_position;
    args.initialOrientation = real_position.orientation;
    move_spline.onTransport = (unit->GetTransGUID() != 0);

    uint32 moveFlags = unit->m_movementInfo.GetMovementFlags();
    moveFlags |= MOVEMENTFLAG_FORWARD;

    if (moveFlags & MOVEMENTFLAG_ROOT)
        moveFlags &= ~MOVEMENTFLAG_MASK_MOVING;

    if (!args.HasVelocity)
    {
        // If spline is initialized with SetWalk method it only means we need to select
        // walk move speed for it but not add walk flag to unit
        uint32 moveFlagsForSpeed = moveFlags;
        if (args.flags.walkmode)
            moveFlagsForSpeed |= MOVEMENTFLAG_WALKING;
        else
            moveFlagsForSpeed &= ~MOVEMENTFLAG_WALKING;

        args.velocity = unit->GetSpeed(SelectSpeedType(moveFlagsForSpeed));
    }

    if (!args.Validate(unit))
        return 0;

    unit->m_movementInfo.SetMovementFlags(moveFlags);
    move_spline.Initialize(args);

    WorldPacket data(SMSG_MONSTER_MOVE, 64);
    data.append(unit->GetPackGUID());
    if (unit->GetTransGUID())
    {
        data.SetOpcode(SMSG_MONSTER_MOVE_TRANSPORT);
        data.appendPackGUID(unit->GetTransGUID());
        data << int8(unit->GetTransSeat());
    }

    PacketBuilder::WriteMonsterMove(move_spline, data);
    unit->SendMessageToSet(&data, true);

    return move_spline.Duration();
}
Esempio n. 23
0
    int32 MoveSplineInit::Launch()
    {
        MoveSpline& move_spline = *unit->movespline;

        bool transport = unit->HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT) && unit->GetTransGUID();
        Location real_position;
        // there is a big chance that current position is unknown if current state is not finalized, need compute it
        // this also allows CalculatePath spline position and update map position in much greater intervals
        // Don't compute for transport movement if the unit is in a motion between two transports
        if (!move_spline.Finalized() && move_spline.onTransport == transport)
            real_position = move_spline.ComputePosition();
        else
        {
            Position const* pos;
            if (!transport)
                pos = unit;
            else
                pos = &unit->m_movementInfo.transport.pos;

            real_position.x = pos->GetPositionX();
            real_position.y = pos->GetPositionY();
            real_position.z = pos->GetPositionZ();
            real_position.orientation = unit->GetOrientation();
        }

        // should i do the things that user should do? - no.
        if (args.path.empty())
            return 0;

        // corrent first vertex
        args.path[0] = real_position;
        args.initialOrientation = real_position.orientation;
        move_spline.onTransport = transport;

        uint32 moveFlags = unit->m_movementInfo.GetMovementFlags();
        moveFlags |= (MOVEMENTFLAG_SPLINE_ENABLED|MOVEMENTFLAG_FORWARD);

        if (moveFlags & MOVEMENTFLAG_ROOT)
            moveFlags &= ~MOVEMENTFLAG_MASK_MOVING;

        if (!args.HasVelocity)
        {
            // If spline is initialized with SetWalk method it only means we need to select
            // walk move speed for it but not add walk flag to unit
            uint32 moveFlagsForSpeed = moveFlags;
            if (args.flags.walkmode)
                moveFlagsForSpeed |= MOVEMENTFLAG_WALKING;
            else
                moveFlagsForSpeed &= ~MOVEMENTFLAG_WALKING;

            args.velocity = unit->GetSpeed(SelectSpeedType(moveFlagsForSpeed));
        }

        if (!args.Validate(unit))
            return 0;

        unit->m_movementInfo.SetMovementFlags(moveFlags);
        move_spline.Initialize(args);

        WorldPacket data(SMSG_MONSTER_MOVE, 64);
        data.append(unit->GetPackGUID());
        if (transport)
        {
            data.SetOpcode(SMSG_MONSTER_MOVE_TRANSPORT);
            data.appendPackGUID(unit->GetTransGUID());
            data << int8(unit->GetTransSeat());
        }

        Movement::SplineBase::ControlArray* visualPoints = const_cast<Movement::SplineBase::ControlArray*>(move_spline._Spline().allocateVisualPoints());
        visualPoints->resize(move_spline._Spline().getPointCount());
        // Xinef: Apply hover in creature movement packet
        if (unit->IsHovering())
            std::transform(move_spline._Spline().getPoints(false).begin(), move_spline._Spline().getPoints(false).end(), visualPoints->begin(), HoverMovementTransform(unit->GetHoverHeight()));
        else
            std::copy(move_spline._Spline().getPoints(false).begin(), move_spline._Spline().getPoints(false).end(), visualPoints->begin());

        PacketBuilder::WriteMonsterMove(move_spline, data);
        unit->SendMessageToSet(&data,true);

        return move_spline.Duration();
    }
Esempio n. 24
0
    void MoveSplineInit::Launch()
    {
        MoveSpline& move_spline = *unit.movespline;

        Location real_position(unit.GetPositionX(), unit.GetPositionY(), unit.GetPositionZMinusOffset(), unit.GetOrientation());
        // Elevators also use MOVEMENTFLAG_ONTRANSPORT but we do not keep track of their position changes
        if (unit.GetTransGUID())
        {
            real_position.x = unit.GetTransOffsetX();
            real_position.y = unit.GetTransOffsetY();
            real_position.z = unit.GetTransOffsetZ();
            real_position.orientation = unit.GetTransOffsetO();
        }

        // there is a big chance that current position is unknown if current state is not finalized, need compute it
        // this also allows calculate spline position and update map position in much greater intervals
        // Don't compute for transport movement if the unit is in a motion between two transports
        if (!move_spline.Finalized() && move_spline.onTransport == (unit.GetTransGUID() != 0))
            real_position = move_spline.ComputePosition();

        // should i do the things that user should do? - no.
        if (args.path.empty())
            return;

        // correct first vertex
        args.path[0] = real_position;
        args.initialOrientation = real_position.orientation;
        move_spline.onTransport = (unit.GetTransGUID() != 0);

        uint32 moveFlags = unit.m_movementInfo.GetMovementFlags();
        if (args.flags.walkmode)
            moveFlags |= MOVEMENTFLAG_WALKING;
        else
            moveFlags &= ~MOVEMENTFLAG_WALKING;

        moveFlags |= MOVEMENTFLAG_FORWARD;

        if (!args.HasVelocity || args.velocity == 0.f)
            args.velocity = unit.GetSpeed(SelectSpeedType(moveFlags));

        if (!args.Validate())
            return;

        if (moveFlags & MOVEMENTFLAG_ROOT)
            moveFlags &= ~MOVEMENTFLAG_MASK_MOVING;

        unit.m_movementInfo.AddServerMovementFlag(SERVERMOVEFLAG_SPLINE1);
        unit.m_movementInfo.AddServerMovementFlag(SERVERMOVEFLAG_SPLINE2);
        unit.m_movementInfo.SetMovementFlags(moveFlags);
        move_spline.Initialize(args);

        WorldPacket data(SMSG_MONSTER_MOVE, 64);
        data.append(unit.GetPackGUID());
        if (unit.GetTransGUID())
        {
            data.SetOpcode(SMSG_MONSTER_MOVE_TRANSPORT);
            data.appendPackGUID(unit.GetTransGUID());
            data << int8(unit.GetTransSeat());
        }

        PacketBuilder::WriteMonsterMove(move_spline, data);
        unit.SendMessageToSet(&data, true);
    }
Esempio n. 25
0
EbmlSInteger::operator int8() {return  int8(Value);}
Esempio n. 26
0
void SampleConverter::convert(int8 *dest, const int16 *source, int samplecount)
{
	while (samplecount--)
		*dest++ = int8(*source++ / 256);
}
Esempio n. 27
0
 OnVehicleState(int32 _type) : m_seatId(int8(_type))
 {};
Esempio n. 28
0
    int32 MoveSplineInit::Launch()
    {
        MoveSpline& move_spline = *unit.movespline;

        bool transport = false;
        Location real_position(unit.GetPositionX(), unit.GetPositionY(), unit.GetPositionZMinusOffset(), unit.GetOrientation());
        // Elevators also use MOVEMENTFLAG_ONTRANSPORT but we do not keep track of their position changes
        if (unit.HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT) && unit.GetTransGUID())
        {
            transport = true;
            real_position.x = unit.GetTransOffsetX();
            real_position.y = unit.GetTransOffsetY();
            real_position.z = unit.GetTransOffsetZ();
            real_position.orientation = unit.GetTransOffsetO();
        }

        // there is a big chance that current position is unknown if current state is not finalized, need compute it
        // this also allows calculate spline position and update map position in much greater intervals
        if (!move_spline.Finalized())
            real_position = move_spline.ComputePosition();

        // should i do the things that user should do? - no.
        if (args.path.empty())
            return 0;

        // corrent first vertex
        args.path[0] = real_position;
        args.initialOrientation = real_position.orientation;

        uint32 moveFlags = unit.m_movementInfo.GetMovementFlags();
        if (args.flags.walkmode)
            moveFlags |= MOVEMENTFLAG_WALKING;
        else
            moveFlags &= ~MOVEMENTFLAG_WALKING;

        moveFlags |= (MOVEMENTFLAG_SPLINE_ENABLED|MOVEMENTFLAG_FORWARD);

        if (!args.HasVelocity)
            args.velocity = unit.GetSpeed(SelectSpeedType(moveFlags));

        if (!args.Validate())
            return 0;

        if (moveFlags & MOVEMENTFLAG_ROOT)
            moveFlags &= ~MOVEMENTFLAG_MASK_MOVING;

        unit.m_movementInfo.SetMovementFlags((MovementFlags)moveFlags);
        move_spline.Initialize(args);

        WorldPacket data(!transport ? SMSG_MONSTER_MOVE : SMSG_MONSTER_MOVE_TRANSPORT, 64);
        data.append(unit.GetPackGUID());
        if (transport)
        {
            data.appendPackGUID(unit.GetTransGUID());
            data << int8(unit.GetTransSeat());
        }

        PacketBuilder::WriteMonsterMove(move_spline, data);
        unit.SendMessageToSet(&data,true);

        return move_spline.Duration();
    }
Esempio n. 29
0
	void UITextButton::GoDisable()
	{
		m_pTextField->SetColor(m_StateColors[int8(m_ElementState)]);
		UIButton::GoDisable();
	}
Esempio n. 30
0
void PlayerMenu::SendGossipMenu(uint32 titleTextId, uint64 objectGUID) const
{
    std::string updatedQuestTitles[0x20];
    ObjectGuid guid = ObjectGuid(objectGUID);

    WorldPacket data(SMSG_GOSSIP_MESSAGE, 150); //??? GUESSED 

    data.WriteBit(guid[7]);
    data.WriteBit(guid[6]);
    data.WriteBit(guid[1]);
    data.WriteBits(_questMenu.GetMenuItemCount(), 19);      // max count 0x20
    data.WriteBit(guid[0]);
    data.WriteBit(guid[4]);
    data.WriteBit(guid[5]);
    data.WriteBit(guid[2]);
    data.WriteBit(guid[3]);
    data.WriteBits(_gossipMenu.GetMenuItemCount(), 20);     // max count 0x10

    for (GossipMenuItemContainer::const_iterator itr = _gossipMenu.GetMenuItems().begin(); itr != _gossipMenu.GetMenuItems().end(); ++itr)
    {
        GossipMenuItem const& item = itr->second;

        data.WriteBits(item.BoxMessage.length(), 12);
        data.WriteBits(item.Message.length(), 12);
    }

    // Store this instead of checking the Singleton every loop iteration
    bool questLevelInTitle = sWorld->getBoolConfig(CONFIG_UI_QUESTLEVELS_IN_DIALOGS);

    for (uint8 i = 0; i < _questMenu.GetMenuItemCount(); ++i)
    {
        uint32 questId = _questMenu.GetItem(i).QuestId;
        Quest const* quest = sObjectMgr->GetQuestTemplate(questId);

        std::string title = quest->GetTitle();

        int32 locale = _session->GetSessionDbLocaleIndex();
            if (locale >= 0)
                if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(questId))
                    ObjectMgr::GetLocaleString(localeData->Title, locale, title);

        if (questLevelInTitle)
            AddQuestLevelToTitle(title, quest->GetQuestLevel());

        if (title.length() % 2 != 0)
            title += " ";                                   // if quest title length is odd dividing by 2 will cause precision loss, add a space to the end

        data.WriteBit(0);                                   // unknown bit
        data.WriteBits(title.length() / 2, 8);              // title length is divided by 2
        data.WriteBit(0);                                   // unknown bit

        updatedQuestTitles[i] = title;
    }

    data.FlushBits();

    for (uint8 i = 0; i < _questMenu.GetMenuItemCount(); ++i)
    {
        QuestMenuItem const& item = _questMenu.GetItem(i);
        Quest const* quest = sObjectMgr->GetQuestTemplate(item.QuestId);

        data << int32(quest->GetSpecialFlags());
        data << int32(item.QuestId);
        data << int32(quest->GetQuestLevel());
        data << int32(item.QuestIcon);
        data << int32(quest->GetFlags());
        data.WriteString(updatedQuestTitles[i]);            // max 0xFF?, length is stored in 8 bits, 5.4.1
    }

    data.WriteByteSeq(guid[6]);

    for (GossipMenuItemContainer::const_iterator itr = _gossipMenu.GetMenuItems().begin(); itr != _gossipMenu.GetMenuItems().end(); ++itr)
    {
        GossipMenuItem const& item = itr->second;

        data << int32(item.BoxMoney);                       // money required to open menu, 2.0.3
        data.WriteString(item.Message);                     // text for gossip item
        data << int32(itr->first);
        data << int8(item.MenuItemIcon);
        data.WriteString(item.BoxMessage);                  // accept text (related to money) pop up box, 2.0.
        data << int8(item.IsCoded);                         // makes pop up box password
    }

    data.WriteByteSeq(guid[2]);

    data << int32(titleTextId);

    data.WriteByteSeq(guid[1]);
    data.WriteByteSeq(guid[5]);

    data << int32(_gossipMenu.GetMenuId());                 // new 2.4.0
    data << int32(0);                                       // friend faction ID?

    data.WriteByteSeq(guid[4]);
    data.WriteByteSeq(guid[7]);
    data.WriteByteSeq(guid[3]);
    data.WriteByteSeq(guid[0]);

    _session->SendPacket(&data);
}