• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ GetTicks函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中GetTicks函数的典型用法代码示例。如果您正苦于以下问题:C++ GetTicks函数的具体用法?C++ GetTicks怎么用?C++ GetTicks使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了GetTicks函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: ScheduleEvent

// This must be run ONLY from within the CPU thread
// cyclesIntoFuture may be VERY inaccurate if called from anything else
// than Advance
void ScheduleEvent(s64 cyclesIntoFuture, int event_type, u64 userdata)
{
	_assert_msg_(POWERPC, Core::IsCPUThread() || Core::GetState() == Core::CORE_PAUSE,
				 "ScheduleEvent from wrong thread");

	Event *ne = GetNewEvent();
	ne->userdata = userdata;
	ne->type = event_type;
	ne->time = GetTicks() + cyclesIntoFuture;

	// If this event needs to be scheduled before the next advance(), force one early
	if (!globalTimerIsSane)
		ForceExceptionCheck(cyclesIntoFuture);


	AddEventToQueue(ne);
}
开发者ID:Abrahamh08,项目名称:dolphin,代码行数:20,代码来源:CoreTiming.cpp


示例2: GetTicks

void LetterDisplayAnimation::Animate()
{
	unsigned int elapsed = GetTicks() - mStartTime;
	float t = elapsed/(float)mDuration;
	if(t > 1.0f)
	{
			GameMessage msg;
			msg.mEventName = "FINISHED";
			msg.mSender = mID;
			SendOutMessage(msg);
			return;
	}
	IvVector3 pos = Lerp(t, mStartPos, mEndPos);
	
	//Add noise to movement
	IvVector3 normDir = mEndPos - mStartPos;
	normDir.z = 0;
	normDir.Normalize();
	float x = normDir.x;
	float y = normDir.y;
	normDir.x = -y;
	normDir.y = x;
	
	float noise = Perlin::Noise(pos.x*0.01f,pos.y*0.01f);
	
	//ramp noise based on proximity to endpoints
	float s = 1.0f;
	if(t <= 0.1f)
		s = Perlin::lerp(t*10.0f,0.0f,1.0f);
	else if( t >= 0.9f)
		s = Perlin::lerp((t-0.9f)*10.0f,1.0f,0.0f);
	normDir *= noise*5.0f * s;
	
	pos += normDir;
	
	IvVector3 intPos;
	intPos.x = (int)pos.x;
	intPos.y = (int)pos.y;
	intPos.z = mStartPos.z;

	SetPosition(intPos);
	IvVector3 vel(0,201,0);
	mMetaballGrid->ObjectMoved(mID, intPos,vel);
	
}
开发者ID:kristofe,项目名称:GameEngine,代码行数:45,代码来源:LetterDisplayAnimation.cpp


示例3: assert

bool CPositionHandler::HandleMovement(uint8 x, uint8 y, uint8 *pPath, uint32 map)
{
	std::vector<uint8> nodes;
	uint32 count = pPath[0] & 0x0f;
	for(int32 i = 1; i < 8; ++i) /* calculating roadpath nodes */
	{
		if(nodes.size() < count)
		{
			nodes.push_back((pPath[i] & 0xf0) / 0x10);
		}
		if(nodes.size() < count)
		{
			nodes.push_back(pPath[i] & 0x0f);
		}
	}
	assert(nodes.size() == count);
	std::vector<CPositionHandler::MovePoint> new_path;
	new_path.reserve(count + 1); /* reserve space immediately, it must be faster i think */
	MovePoint origin;
	origin.x = x;
	origin.y = y;
	origin.time = GetTicks();
	new_path.push_back(origin);
	uint8 tx = x;
	uint8 ty = y;
	for(uint32 i = 0; i < nodes.size(); ++i) /* building path from client data and checking it for walkability */
	{
		tx += RoadX[nodes.at(i)];
		ty += RoadY[nodes.at(i)];
		if(!WorldMap[map].FreeToMove(tx, ty))
		{
			return false;
		}
		MovePoint pt;
		pt.time = origin.time + 300 * (i + 1); /* time is constant (reversed speed), need calculate it later */
		pt.x = tx;
		pt.y = ty;
		new_path.push_back(pt);
	}
	this->mtx.lock(); /* applying new path, also storing backup of previous */
	this->cache = this->path;
	this->path = new_path;
	this->mtx.unlock();
	return true;
}
开发者ID:Goresome,项目名称:orange,代码行数:45,代码来源:PositionHandler.cpp


示例4: GetTicks

const CPositionHandler::MovePoint CPositionHandler::GetPosition()
{
	uint32 current_time = GetTicks();
	CPositionHandler::MovePoint pt;
	this->mtx.lock();
	for(uint32 i = 0; i < this->path.size(); ++i)
	{
		if(this->path.at(i).time > current_time)
		{
			pt = this->path.at(i - 1);
			this->mtx.unlock();
			return pt;
		}
	}
	pt = this->path.at(this->path.size() - 1);
	this->mtx.unlock();
	return pt;
}
开发者ID:Goresome,项目名称:orange,代码行数:18,代码来源:PositionHandler.cpp


示例5: init_genrand

GUID_HIGH CObjectManager::CreateGuid()
{
	init_genrand(GetTicks());
	GUID_HIGH guid = 0;
	uint32 count = 0;
	while(count < RETRIES)
	{
		count++;
		guid = GUID_HIGH(genrand_int32());
		MapType::iterator it = this->container.find(guid);
		if(it == this->container.end())
		{
			break;
		}
	}
	assert(count != RETRIES);
	return guid;
}
开发者ID:Goresome,项目名称:orange,代码行数:18,代码来源:objectmanager.cpp


示例6: SEND_W3GS_STOP_LAG

BYTEARRAY CGameProtocol :: SEND_W3GS_STOP_LAG( CGamePlayer *player, bool loadInGame )
{
	BYTEARRAY packet;
	packet.push_back( W3GS_HEADER_CONSTANT );	// W3GS header constant
	packet.push_back( W3GS_STOP_LAG );			// W3GS_STOP_LAG
	packet.push_back( 0 );						// packet length will be assigned later
	packet.push_back( 0 );						// packet length will be assigned later
	packet.push_back( player->GetPID( ) );

	if( loadInGame )
		UTIL_AppendByteArray( packet, (uint32_t)0, false );
	else
		UTIL_AppendByteArray( packet, GetTicks( ) - player->GetStartedLaggingTicks( ), false );

	AssignLength( packet );
	// DEBUG_Print( "SENT W3GS_STOP_LAG" );
	// DEBUG_Print( packet );
	return packet;
}
开发者ID:brunobnb,项目名称:ghostcb,代码行数:19,代码来源:gameprotocol.cpp


示例7: CGamePlayer

CGamePlayer :: CGamePlayer( CGameProtocol *nProtocol, CBaseGame *nGame, CTCPSocket *nSocket, unsigned char nPID, string nJoinedRealm, string nName, BYTEARRAY nInternalIP, bool nReserved ) : CPotentialPlayer( nProtocol, nGame, nSocket )
{
	m_PID = nPID;
	m_Name = nName;
	m_InternalIP = nInternalIP;
	m_JoinedRealm = nJoinedRealm;
	m_TotalPacketsSent = 0;
	m_TotalPacketsReceived = 0;
	m_LeftCode = PLAYERLEAVE_LOBBY;
	m_LoginAttempts = 0;
	m_SyncCounter = 0;
	m_JoinTime = GetTime( );
	m_LastMapPartSent = 0;
	m_LastMapPartAcked = 0;
	m_StartedDownloadingTicks = 0;
	m_FinishedDownloadingTime = 0;
	m_FinishedLoadingTicks = 0;
	m_StartedLaggingTicks = 0;
	m_StatsSentTime = 0;
	m_StatsDotASentTime = 0;
	m_LastGProxyWaitNoticeSentTime = 0;
	m_Score = -100000.0;
	m_LoggedIn = false;
	m_Spoofed = false;
	m_Reserved = nReserved;
	m_WhoisShouldBeSent = false;
	m_WhoisSent = false;
	m_DownloadAllowed = false;
	m_DownloadStarted = false;
	m_DownloadFinished = false;
	m_FinishedLoading = false;
	m_Lagging = false;
	m_DropVote = false;
	m_KickVote = false;
	m_Muted = false;
	m_LeftMessageSent = false;
	m_GProxy = false;
	m_GProxyDisconnectNoticeSent = false;
	m_GProxyReconnectKey = GetTicks( );
	m_LastGProxyAckTime = 0;
    m_PlayerId = 0;
    m_LeftTime = 0;
}
开发者ID:PLEASE-EXCUSE-MY-DOPE-ASS-SWAG,项目名称:GHost,代码行数:43,代码来源:gameplayer.cpp


示例8: GetTicks

void HangingLetterSign::AnimateWind()
{
	unsigned int time = GetTicks();
	unsigned int elapsed = time - mStartTime;
	IvVector3 pos;
	this->GetLocalPosition(pos);
	float t = elapsed/(float)mWindDuration;
	
	if(t > 1.0f)
	{
			//this->ResetLocalTransform();//Start with identity
			//this->Translate(pos);
			IdleAnimate();
			return;
			/*GameMessage msg;
			msg.mEventName = "FINISHED";
			msg.mSender = mID;
			SendOutMessage(msg);
			return;*/
	}

	float noise = 0.2f* Perlin::Noise(time*0.001f,pos.x*0.01f);
	float hiFreqNoise = Perlin::Noise(time*0.007f,pos.x*0.01f);
	//ramp noise based on proximity to start and end animation
	
	//have to start with 1.0f times noise because that is what was driving the position and motion of the sign before
	//this animation... if you didn't start with the regular noise value then you would get a hitch in position.
	float s = 2.0f;
	if(t <= 0.25f)
		s = LERP(t*4.0f,1.0f,2.0f);
	else if( t >= 0.75f)
		s = LERP((t-0.75f)*4.0f,2.0f,1.0f);

	mLastUpdateTime = time;
	
	this->ResetLocalTransform();//Start with identity
	this->Translate(pos);
	
	float negNoise = -(0.5f*noise + 0.5f);
	this->Rotate(s*noise*0.3,s*hiFreqNoise*0.5f,s*negNoise*0.5);
	
}
开发者ID:kristofe,项目名称:GameEngine,代码行数:42,代码来源:HangingLetterSign.cpp


示例9: ScheduleEvent

void ScheduleEvent(s64 cycles_into_future, EventType* event_type, u64 userdata, FromThread from)
{
  ASSERT_MSG(POWERPC, event_type, "Event type is nullptr, will crash now.");

  bool from_cpu_thread;
  if (from == FromThread::ANY)
  {
    from_cpu_thread = Core::IsCPUThread();
  }
  else
  {
    from_cpu_thread = from == FromThread::CPU;
    ASSERT_MSG(POWERPC, from_cpu_thread == Core::IsCPUThread(),
               "A \"%s\" event was scheduled from the wrong thread (%s)", event_type->name->c_str(),
               from_cpu_thread ? "CPU" : "non-CPU");
  }

  if (from_cpu_thread)
  {
    s64 timeout = GetTicks() + cycles_into_future;

    // If this event needs to be scheduled before the next advance(), force one early
    if (!s_is_global_timer_sane)
      ForceExceptionCheck(cycles_into_future);

    s_event_queue.emplace_back(Event{timeout, s_event_fifo_id++, userdata, event_type});
    std::push_heap(s_event_queue.begin(), s_event_queue.end(), std::greater<Event>());
  }
  else
  {
    if (Core::WantsDeterminism())
    {
      ERROR_LOG(POWERPC,
                "Someone scheduled an off-thread \"%s\" event while netplay or "
                "movie play/record was active.  This is likely to cause a desync.",
                event_type->name->c_str());
    }

    std::lock_guard<std::mutex> lk(s_ts_write_lock);
    s_ts_queue.Push(Event{g.global_timer + cycles_into_future, 0, userdata, event_type});
  }
}
开发者ID:AdmiralCurtiss,项目名称:dolphin,代码行数:42,代码来源:CoreTiming.cpp


示例10: GetTicks

void ScreenFader::Update()
{
    if(!mActive)
        return;

    unsigned int elapsed = GetTicks() - mStartTime;
    float t = elapsed/(float)mDuration;
    mCurrentColor = Lerp(t,mStartColor,mEndColor);
    SetColor(mCurrentColor);

    if(elapsed >= mDuration)
    {

        GameMessage msg;
        msg.mEventName = "FINISHED";
        msg.mSender = mID;
        SendOutMessage(msg);
    }

}
开发者ID:kristofe,项目名称:GameEngine,代码行数:20,代码来源:ScreenFader.cpp


示例11: QueryPerformanceFrequency

// Constructor
// begin of a profile section
VSProfileLib::VSProfileLib(std::string name, bool profileGL) {

	int found;
	pTime w;
	sCurrLevel++;

#if VSPL_CLOCK == VSPL_WIN_HIGH_PERFORMANCE_COUNTER
	QueryPerformanceFrequency(&sFreq);
#endif

	GetTicks(&w);

	// create new level
	if (sCurrLevel == sTotalLevels) {

		sLevels[sCurrLevel].cursor = -1;
		createNewSection(name, w, profileGL);
		// store the size of the largest section name
		int aux = name.size() ;
		if (aux > sDisp)
			sDisp = aux;
		sTotalLevels++;
	}
	else {  	
		// search for name and parent
		found = searchSection(name);
		if (found != -1)
			updateSection(found, w);
		else {
			// create new section inside current level
			createNewSection(name, w, profileGL);
			// store the size of the largest section name
			// for report formatting purposes
			int aux = name.size() ;
			if (aux > sDisp)
				sDisp = aux;
		}
	}

}
开发者ID:v3c70r,项目名称:sph-fluids,代码行数:42,代码来源:vsProfileLib.cpp


示例12: QueryPerformanceCounter

inline void Platform::update_time()
{
	/*
	u64 t;
	QueryPerformanceCounter((LARGE_INTEGER *) &t);
	f32 newTime = (f32) (((f64) t) / timer_freq);
	*/
	f32 f;
	i32 t;
	double ticks;

	ticks = GetTicks();
	t = ticks;
	//printf("update ticks %f, %d\n",ticks, t);
	f = ((f32) t) * 0.001f;
	
//	deviceState.timeStep = f - deviceState.time;
//	deviceState.time = f;
	
	deviceState.timeStep = ticks - deviceState.time;
	deviceState.time = ticks;

}
开发者ID:aronsoderling,项目名称:high-perfomance-cg,代码行数:23,代码来源:PlatformIOS.cpp


示例13: GetWorldPosition

void HangingLetterSign::SetChar(char c)
{
	mUseWindAnimation = false;
	IvVector3 pos;
	GetWorldPosition(pos);
	pos.x = (int) pos.x;
	pos.y = (int) pos.y;
	this->SetWorldPosition(pos);
	//LetterDisplay::SetChar(c);
	if(mLetterDisplay == NULL)
	{
		mLetterDisplay = new LetterDisplay(mFont);
		IvVector3 disp;
		//GetWorldPosition(disp);
		disp.z += 2.55f;
		disp.y -= 27;
		mLetterDisplay->Translate(disp);
		
		//Hack!  for letter "i" it is too sharp and thin
		if(c == 'I')
		{
			IvVector3 s(1.25f,1.0f,1.0f);
			mLetterDisplay->Scale(s);
		}
		this->AddChild(mLetterDisplay);

	}
	mPendingChar = c;
	mStartTime = GetTicks();
	int randTime =  (rand()/(float)RAND_MAX)*1000;
	mStartTime += randTime;
	//mLetterDisplay->SetChar(c);
	

	

}
开发者ID:kristofe,项目名称:GameEngine,代码行数:37,代码来源:HangingLetterSign.cpp


示例14: GetTime

quint32 GetTime()
{
	return GetTicks( ) / 1000;
}
开发者ID:svn2github,项目名称:ghostplusplus,代码行数:4,代码来源:ghost.cpp


示例15: Draw_skill_icons

static void Draw_skill_icons (SDL_Surface *screen, struct character *player) {
    SDL_Rect rect= {350 * scale, (top ? 0 : (practise ? ky - (double)kx/1920 * 150 : ky - (double)kx/1920 * 90))
                    , skill_icons[0][0]->w, skill_icons[0][0]->h
                   };
    if(!top && kyBottom > rect.y - 10*scale)
        kyBottom = rect.y - 10*scale;
    int i,j;
    for(j=0; j < (practise ? 2 : 1); j++) {
        for(i=0; i<skill_num; i++) {
            if(j == 0)
                BlitSurface(skill_bg, NULL, screen, &rect);
            BlitSurface(skill_icons[j][i], NULL, screen, &rect);
            // A Cooldownok kirajzolása
            if(j == 0) {
                int time = GetTicks();
                int percent = 0;
                bool available = false;
                bool current = false;
                switch (i) {
                case skill_a_melee:
                    if(player->act == a_walk)
                        available = true;
                    if(player->act == a_melee)
                        current = true;
                    if(player->melee.a_cd > time)
                        percent = ((player->melee.a_cd - time) * 100) / player->a_melee_cd;
                    break;
                case skill_s_melee:
                    if(player->act == a_walk || player->act == jump || player->act == air)
                        available = true;
                    if(player->act == s_melee)
                        current = true;
                    if(player->melee.s_cd > time)
                        percent = ((player->melee.s_cd - time) * 100) / player->s_melee_cd;
                    break;
                case skill_s_walk:
                    if( (player->act == a_walk || player->act == jump) && player->jump.second == false)
                        available = true;
                    if(player->act == s_walk)
                        current = true;
                    if(player->walk.cd > time)
                        percent = ((player->walk.cd - time) * 100) / player->s_walk_cd;
                    break;
                case skill_def:
                    if(player->act == a_walk || player->act == a_melee)
                        available = true;
                    if(player->act == def)
                        current = true;
                    if(player->def.cd > time)
                        percent = ((player->def.cd - time) * 100) / player->def_cd;
                    break;
                case skill_jump_attack1:
                    if(player->act == jump && player->jump.second == false)
                        available = true;
                    if(player->act == jump_attack)
                        current = true;
                    if(player->jump.cd1 > time)
                        percent = ((player->jump.cd1 - time) * 100) / player->jump_attack_cd;
                    break;
                case skill_jump_attack2:
                    if(player->act == jump && player->jump.second == false)
                        available = true;
                    if(player->act == jump_attack2)
                        current = true;
                    if(player->jump.cd2 > time)
                        percent = ((player->jump.cd2 - time) * 100) / player->jump_attack_cd;
                    break;
                case skill_counter:
                    if(player->act == a_walk || player->act == hit
                            || player->act == a_melee || player->act == ground)
                        available = true;
                    if(player->act == counter)
                        current = true;
                    if(player->counter.cd > time)
                        percent =  ((player->counter.cd - time) * 100) / player->counter_cd;
                    break;
                case skill_a_ranged:
                    if(player->act == a_walk)
                        available = true;
                    if(player->act == a_ranged)
                        current = true;
                    if(player->ranged.a_cd > time)
                        percent =  ((player->ranged.a_cd - time) * 100) / player->a_cast_cd;
                    break;
                case skill_s_ranged:
                    if(player->act == a_walk)
                        available = true;
                    if(player->act == s_ranged)
                        current = true;
                    if(player->ranged.s_cd > time)
                        percent =  ((player->ranged.s_cd - time) * 100) / player->s_cast_cd;
                    break;
                default:
                    break;
                }
                if(!available && !current)
                    boxRGBA(screen, rect.x, rect.y, rect.x + rect.w, rect.y + rect.h, 0, 0, 0, 125);
                if(percent != 0 && !current) { // A hátralévő cooldown kirajzolása
                    int w =skill_icons[j][i]->w, h = skill_icons[j][i]->h;
                    Sint16 x[7] = {w/2 + w*(100-percent)/24, w, w, 0, 0, w/2, w/2};
//.........这里部分代码省略.........
开发者ID:Tomius,项目名称:LittleFighter,代码行数:101,代码来源:UI.c


示例16: return

double Timer::Get() const
{
	return (GetTicks() - m_offset)*m_timerUnit;
}
开发者ID:MarkGoldberg,项目名称:DebugViewPP,代码行数:4,代码来源:Utilities.cpp


示例17: GetTicks

void Timer::Reset()
{
	m_offset = GetTicks();
}
开发者ID:MarkGoldberg,项目名称:DebugViewPP,代码行数:4,代码来源:Utilities.cpp


示例18: ProcessPackets

void CGamePlayer :: ProcessPackets( )
{
    if( !m_Socket )
        return;

    CIncomingAction *Action = NULL;
    CIncomingChatPlayer *ChatPlayer = NULL;
    CIncomingMapSize *MapSize = NULL;
    bool HasMap = false;
    uint32_t CheckSum = 0;
    uint32_t Pong = 0;

    // process all the received packets in the m_Packets queue

    while( !m_Packets.empty( ) )
    {
        CCommandPacket *Packet = m_Packets.front( );
        m_Packets.pop( );

        if( Packet->GetPacketType( ) == W3GS_HEADER_CONSTANT )
        {
            switch( Packet->GetID( ) )
            {
            case CGameProtocol :: W3GS_LEAVEGAME:
                m_Game->EventPlayerLeft( this, m_Protocol->RECEIVE_W3GS_LEAVEGAME( Packet->GetData( ) ) );
                break;

            case CGameProtocol :: W3GS_GAMELOADED_SELF:
                if( m_Protocol->RECEIVE_W3GS_GAMELOADED_SELF( Packet->GetData( ) ) )
                {
                    if( !m_FinishedLoading && m_Game->GetGameLoading( ) )
                    {
                        m_FinishedLoading = true;
                        m_FinishedLoadingTicks = GetTicks( );
                        m_Game->EventPlayerLoaded( this );
                    }
                    else
                    {
                        // we received two W3GS_GAMELOADED_SELF packets from this player!
                    }
                }

                break;

            case CGameProtocol :: W3GS_OUTGOING_ACTION:
                Action = m_Protocol->RECEIVE_W3GS_OUTGOING_ACTION( Packet->GetData( ), m_PID );

                if( Action )
                {
                    // don't delete Action here because the game is going to store it in a queue and delete it later
                    m_Game->EventPlayerAction( this, Action );
                }

                break;

            case CGameProtocol :: W3GS_OUTGOING_KEEPALIVE:
                CheckSum = m_Protocol->RECEIVE_W3GS_OUTGOING_KEEPALIVE( Packet->GetData( ) );
                m_CheckSums.push( CheckSum );
                ++m_SyncCounter;
                m_Game->EventPlayerKeepAlive( this, CheckSum );
                break;

            case CGameProtocol :: W3GS_CHAT_TO_HOST:
                ChatPlayer = m_Protocol->RECEIVE_W3GS_CHAT_TO_HOST( Packet->GetData( ) );

                if( ChatPlayer )
                {
                    // determine if we should auto-mute this player
                    if( ChatPlayer->GetType( ) == CIncomingChatPlayer :: CTH_MESSAGE || ChatPlayer->GetType( ) == CIncomingChatPlayer :: CTH_MESSAGEEXTRA )
                    {
                        if( m_Level <= 1 &&! GetMuted( ) )
                        {
                            m_MuteMessages.push_back( GetTicks( ) );

                            if( m_MuteMessages.size( ) > 7 )
                                m_MuteMessages.erase( m_MuteMessages.begin( ) );

                            uint32_t RecentCount = 0;
                            for( unsigned int i = 0; i < m_MuteMessages.size( ); ++i )
                            {
                                if( GetTicks( ) - m_MuteMessages[i] < 5000 )
                                {
                                    RecentCount++;
                                }
                            }

                            if( m_Game->m_OHBot->m_AutoMuteSpammer && RecentCount >= 7 )
                            {
                                m_Count++;
                                if(  m_Count == 1 )
                                {
                                    SetMuted( true );
                                    m_MutedAuto = true;
                                    m_Game->SendChat( m_PID, "["+m_Game->m_OHBot->m_BotManagerName+"] "+m_Game->m_OHBot->m_Language->SpamWarning( ) );
                                    m_MuteMessages.clear( );
                                    m_Game->SendAllChat( "["+m_Game->m_OHBot->m_BotManagerName+"] " + m_Game->m_OHBot->m_Language->UserWasMutedForReason( m_Name, "spamming" ) );
                                }
                                if( m_Count == 2 )
                                {
                                    m_Game->SendAllChat( m_Game->m_OHBot->m_Language->UserIgnoerNotify( m_Name ) );
//.........这里部分代码省略.........
开发者ID:m-unkel,项目名称:OHSystem,代码行数:101,代码来源:gameplayer.cpp


示例19: Update

bool CGamePlayer :: Update( void *fd )
{
    // wait 4 seconds after joining before sending the /whois or /w
    // if we send the /whois too early battle.net may not have caught up with where the player is and return erroneous results

    if( m_WhoisShouldBeSent && !m_Spoofed && !m_WhoisSent && !m_JoinedRealm.empty( ) && GetTime( ) - m_JoinTime >= 4 )
    {
        // todotodo: we could get kicked from battle.net for sending a command with invalid characters, do some basic checking

        for( vector<CBNET *> :: iterator i = m_Game->m_OHBot->m_BNETs.begin( ); i != m_Game->m_OHBot->m_BNETs.end( ); ++i )
        {
            if( (*i)->GetServer( ) == m_JoinedRealm )
            {
                if( m_Game->GetGameState( ) == GAME_PUBLIC )
                {
                    if( (*i)->GetPasswordHashType( ) == "pvpgn" )
                        (*i)->QueueChatCommand( "/whereis " + m_Name );
                    else
                        (*i)->QueueChatCommand( "/whois " + m_Name );
                }
                else if( m_Game->GetGameState( ) == GAME_PRIVATE )
                    (*i)->QueueChatCommand( m_Game->m_OHBot->m_Language->SpoofCheckByReplying( ), m_Name, true );
            }
        }

        m_WhoisSent = true;
    }

    // check for socket timeouts
    // if we don't receive anything from a player for 30 seconds we can assume they've dropped
    // this works because in the lobby we send pings every 5 seconds and expect a response to each one
    // and in the game the Warcraft 3 client sends keepalives frequently (at least once per second it looks like)

    if( m_Socket && GetTime( ) - m_Socket->GetLastRecv( ) >= 30 )
        m_Game->EventPlayerDisconnectTimedOut( this );

    // make sure we're not waiting too long for the first MAPSIZE packet

    /*    	if( m_ConnectionState == 1 && GetTicks( ) - m_ConnectionTime > 5000 && !m_Game->GetGameLoaded() && !m_Game->GetGameLoading() )
        {
            Log->Info( "[DENY] Kicking player: MAPSIZE not received within five seconds" );
            m_DeleteMe = true;
                SetLeftReason( "MAPSIZE not received within five seconds" );
                SetLeftCode( PLAYERLEAVE_LOBBY );
                m_Game->OpenSlot( m_Game->GetSIDFromPID( GetPID( ) ), false );
            }
    */
    // disconnect if the player is downloading too slowly

    // make this a bit dynamically, first 10 KB/s is a bit too low, increasing to 100KB/s
    //decreasing the checktime to 5 seconds
    // adding an actual playercheck how many players are ingame, if there less than 1 open slots we deny users with a download rate under 500KB/s
    if( m_DownloadStarted && !m_DownloadFinished && !m_Game->GetGameLoaded() && !m_Game->GetGameLoading() && GetLastMapPartSent( ) > 0 && m_Game->m_OHBot->m_KickSlowDownloader )
    {
        uint32_t downloadingTime = GetTicks( ) - m_StartedDownloadingTicks;

        if( downloadingTime > 5000 && m_Level < 1)
        {
            if( GetLastMapPartAcked( ) / downloadingTime < 500 && m_Game->GetSlotsOccupied( ) <= 1 )
            {
                m_DeleteMe = true;
                SetLeftReason( "download speed too low" );
                SetLeftCode( PLAYERLEAVE_LOBBY );
                m_Game->SendAllChat( m_Game->m_OHBot->m_Language->UserWasKickedForSlowDownloadRate( m_Name ) );
                m_Game->OpenSlot( m_Game->GetSIDFromPID( GetPID( ) ), false );
            }
            else if( GetLastMapPartAcked( ) / downloadingTime < 100 )
            {
                m_DeleteMe = true;
                SetLeftReason( "download speed too low" );
                SetLeftCode( PLAYERLEAVE_LOBBY );
                m_Game->SendAllChat( m_Game->m_OHBot->m_Language->UserWasKickedForSlowDownloadRate( m_Name ) );
                m_Game->OpenSlot( m_Game->GetSIDFromPID( GetPID( ) ), false );
            }
        }
    }

    // unmute player
    if( GetMuted( ) && m_MutedAuto && GetTicks( ) - m_MutedTicks > 30000  )
    {
        SetMuted( false );
        m_Game->SendChat( m_PID, "["+m_Game->m_OHBot->m_BotManagerName+"] "+m_Game->m_OHBot->m_Language->UserWasAutomaticallyUnmuted( ) );
        m_MuteMessages.clear( );
    }

    // GProxy++ acks

    if( m_Game->m_OHBot->IsMode( BOT_MODE_GPROXY ) && m_GProxy && GetTime( ) - m_LastGProxyAckTime >= 10 )
    {
        if( m_Socket )
            m_Socket->PutBytes( m_Game->m_OHBot->m_GPSProtocol->SEND_GPSS_ACK( m_TotalPacketsReceived ) );

        m_LastGProxyAckTime = GetTime( );
    }

    // base class update

    CPotentialPlayer :: Update( fd );
    bool Deleting;

//.........这里部分代码省略.........
开发者ID:m-unkel,项目名称:OHSystem,代码行数:101,代码来源:gameplayer.cpp


示例20: MIDI_RawOutByte

void MIDI_RawOutByte(Bit8u data) {
	if (midi.sysex.start) {
		Bit32u passed_ticks = GetTicks() - midi.sysex.start;
		if (passed_ticks < midi.sysex.delay) SDL_Delay(midi.sysex.delay - passed_ticks);
	}

	/* Test for a realtime MIDI message */
	if (data>=0xf8) {
		midi.rt_buf[0]=data;
		midi.handler->PlayMsg(midi.rt_buf);
		return;
	}
	/* Test for a active sysex tranfer */
	if (midi.status==0xf0) {
		if (!(data&0x80)) {
			if (midi.sysex.used<(SYSEX_SIZE-1)) midi.sysex.buf[midi.sysex.used++] = data;
			return;
		} else {
			midi.sysex.buf[midi.sysex.used++] = 0xf7;

			if ((midi.sysex.start) && (midi.sysex.used >= 4) && (midi.sysex.used <= 9) && (midi.sysex.buf[1] == 0x41) && (midi.sysex.buf[3] == 0x16)) {
				LOG(LOG_ALL,LOG_ERROR)("MIDI:Skipping invalid MT-32 SysEx midi message (too short to contain a checksum)");
			} else {
//				LOG(LOG_ALL,LOG_NORMAL)("Play sysex; address:%02X %02X %02X, length:%4d, delay:%3d", midi.sysex.buf[5], midi.sysex.buf[6], midi.sysex.buf[7], midi.sysex.used, midi.sysex.delay);
				midi.handler->PlaySysex(midi.sysex.buf, midi.sysex.used);
				if (midi.sysex.start) {
					if (midi.sysex.buf[5] == 0x7F) {
						midi.sysex.delay = 290; // All Parameters reset
					} else if (midi.sysex.buf[5] == 0x10 && midi.sysex.buf[6] == 0x00 && midi.sysex.buf[7] == 0x04) {
						midi.sysex.delay = 145; // Viking Child
					} else if (midi.sysex.buf[5] == 0x10 && midi.sysex.buf[6] == 0x00 && midi.sysex.buf[7] == 0x01) {
						midi.sysex.delay = 30; // Dark Sun 1
					} else midi.sysex.delay = (Bitu)(((float)(midi.sysex.used) * 1.25f) * 1000.0f / 3125.0f) + 2;
					midi.sysex.start = GetTicks();
				}
			}

			LOG(LOG_ALL,LOG_NORMAL)("Sysex message size %d",midi.sysex.used);
			if (CaptureState & CAPTURE_MIDI) {
				CAPTURE_AddMidi( true, midi.sysex.used-1, &midi.sysex.buf[1]);
			}
		}
	}
	if (data&0x80) {
		midi.status=data;
		midi.cmd_pos=0;
		midi.cmd_len=MIDI_evt_len[data];
		if (midi.status==0xf0) {
			midi.sysex.buf[0]=0xf0;
			midi.sysex.used=1;
		}
	}
	if (midi.cmd_len) {
		midi.cmd_buf[midi.cmd_pos++]=data;
		if (midi.cmd_pos >= midi.cmd_len) {
			if (CaptureState & CAPTURE_MIDI) {
				CAPTURE_AddMidi(false, midi.cmd_len, midi.cmd_buf);
			}
			midi.handler->PlayMsg(midi.cmd_buf);
			midi.cmd_pos=1;		//Use Running status
		}
	}
}
开发者ID:henriknil,项目名称:dosbox,代码行数:63,代码来源:midi.cpp



注:本文中的GetTicks函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ GetTile函数代码示例发布时间:2022-05-30
下一篇:
C++ GetTickCount64函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap