Example #1
0
void Action::Process(void)
{
#ifndef _TEST
	STOMPCHECK();
#endif

	if (!m_curAnim)
    {
        SetFinished(true);
        return;
    }
	
	m_animPos = m_curAnim->GetNextPosition(m_animPos);
	m_animDelayEnd = m_curAnim->GetDelayEnd();
	m_animElapsed = m_curAnim->GetElapsed();
	m_animLastFrameTime = m_curAnim->GetLastFrameTime();

	
	
	
	






	
	m_specialDelayProcess = m_curAnim->GetWeAreInDelay() && (m_actionType == UNITACTION_IDLE);
	if (m_specialDelayProcess)
    {
		m_animPos = 0;
	}

	m_curActionCounter++;


	
	

	if (m_curActionCounter > m_maxActionCounter || m_curAnim->Finished()) 
	{
		m_curActionCounter = m_maxActionCounter;
		m_loopAnimFinished = true;

		if ( m_endCondition == ACTIONEND_ANIMEND ||
			m_endCondition == ACTIONEND_PATHEND )
		{
			SetFinished(true);
		}
	}

}
Example #2
0
void
WUploadThread::Reset()
{
	PRINT("WUploadThread::Reset()\n");
	SetFinished(true);
	if (fTunneled)
		SessionDisconnected(_sessionID);
	else
		qmtt->Reset();
	PRINT("WUploadThread::Reset() OK\n");
}
long AudioStreamDecoder::EnqueueBuffer()
{
	bool locked = false;

	if (mFinished)
		return 0;

	long err = AudioQueueEnqueueBuffer(mQueue, *mCurrentBuffer, 0, NULL);
	BAIL_IF(err, "AudioQueueEnqueueBuffer returned %ld\n", err);

	if (++mCurrentBuffer == mBuffers + kBufferCount)
		mCurrentBuffer = mBuffers;

	if (!mStarted && !mFinished)
	{
		mStarted = true;

		err = AudioQueueStart(mQueue, NULL);
		BAIL_IF(err, "AudioQueueStart returned %ld\n", err);
	}

	err = pthread_mutex_lock(&mMutex);
	BAIL_IF(err, "pthread_mutex_lock returned %ld\n", err);

	locked = true;

	while ((*mCurrentBuffer)->mUserData && !mFinished)
	{
		err = pthread_cond_wait(&mCond, &mMutex);
		BAIL_IF(err, "pthread_cond_wait returned %ld\n", err);
	}

	(*mCurrentBuffer)->mUserData = this;
	(*mCurrentBuffer)->mAudioDataByteSize = 0;
	(*mCurrentBuffer)->mPacketDescriptionCount = 0;

bail:
	long err2;

	if (locked)
	{
		err2 = pthread_mutex_unlock(&mMutex);
		CARP_IF(err2, "pthread_mutex_unlock returned %ld\n", err2);
	}

	if (err && mStarted)
	{
		err2 = SetFinished();
		CARP_IF(err2, "SetFinished returned %ld\n", err2);
	}

	return err;
}
Example #4
0
void
WUploadThread::_OutputQueuesDrained()
{
	fIdles = 0;

	if (fWaitingForUploadToFinish)
	{
		PRINT("\tfWaitingForUploadToFinish\n");
		SetFinished(true);
		fWaitingForUploadToFinish = false;

		PRINT("\t\tSending message\n");

		{
			WUploadEvent *wue = new WUploadEvent(WUploadEvent::FileDone);
			if (wue)
			{
				wue->SetDone(true);
				wue->SetFile(SimplifyPath(fFileUl));
				PRINT("\t\tSending...\n");
				SendReply(wue);
				PRINT("\t\tSent...\n"); // <*****@*****.**> 20021023 -- Fixed typo
			}
			else
			{
				PRINT("\t\tNot sent!\n");
			}
		}

		PRINT("\t\tDisconnecting...\n");

		{
			WUploadEvent *dis = new WUploadEvent(WUploadEvent::Disconnected);
			if (dis)
			{
				dis->SetDone(true);
				SendReply(dis);
				PRINT("\t\tDisconnected...\n");
			}
			else
			{
				PRINT("\t\tCould not disconnect!\n");
			}
		}

		PRINT("\tfWaitingForUploadToFinish OK\n");
	}
	else if (!fFinished)
	{
		SignalUpload();
	}
}
void CMemSpyDeviceWideOperations::RunL()
    {
#ifdef _DEBUG
    RDebug::Printf( "CMemSpyDeviceWideOperations::RunL() - START - iStatus: %d, iOperationCancelled: %d, iThreadIndex: %03d, iOperation: %d", iStatus.Int(), iOperationCancelled, iThreadIndex, iOperation );
#endif

    User::LeaveIfError( iStatus.Int() );
    User::ResetInactivityTime();
 
    if  ( iOperationCancelled )
        {
#ifdef _DEBUG
        RDebug::Printf( "CMemSpyDeviceWideOperations::RunL() - operation was cancelled whilst running... => Finished" );
#endif
        SetFinished();
        }
    else
        {
        // Get the current process
        CMemSpyEngineObjectContainer& container = iEngine.Container();
        const TInt processCount = container.Count();
        //
        if  ( iProcessIndex < processCount ) 
            {
            PerformNextStepL();
            }
        else
            {
            // We're done - RunL will not be called again
            TRAP_IGNORE( PerformFinalOperationL() );
            SetFinished();
            }
        }

#ifdef _DEBUG
    RDebug::Printf("CMemSpyDeviceWideOperations::RunL() - END" );
#endif
    }
Example #6
0
void TowerDefenseInstanceScript::TowerDefenseMapInstanceScript::SetupEventData()
{
    Player *player = GetPlayer();
    if(!player)
        return;

    SetEventId(GenerateEventId()); // set the event id
    SetPlayerGUID(player->GetGUIDLow()); // set the player guid 
    SetCurrentWaveId(0); // set the current wave id to zero
    SetBaseHealth(100); // set the base health to 100
    SetResources(GetStartResources()); // set the resources that the player has to starter resources
    SetUnits(0); // set the number of spawned attackers to zero
    SetFinished(false); // set the event to unfinished
    SetEventStatus(TD_EVENT_STATUS_TELEPORT); // Set the event status to started and not running a wave
    Events.Reset();
}
Example #7
0
void Level1::ZoomOutEffect()
{
    auto cameraEntity = Engine::GetInstance().GetEntityWithComponentOfClass("CameraComponent");
    auto cameraComponent = std::static_pointer_cast<CameraComponent>(Engine::GetInstance().GetSingleComponentOfClass(cameraEntity, "CameraComponent"));
    auto height = cameraComponent->GetHeight();

    if (height < 4)
    {
        height += 0.01;
        cameraComponent->SetHeight(height);
    }
    else
    {
        Engine::GetInstance().SetNextLevel(std::make_shared<Level2>());
        SetFinished();
    }
}
Example #8
0
void Level1::Update()
{
    LOG_D("[Level1] Updating");

    auto cells = Engine::GetInstance().GetAllEntitiesWithComponentOfClass("GrowthComponent");

    for (int i = cells.size(); i < CFG_GETI("LEVEL_1_INITIAL_NUM_CELLS"); ++i)
    {
        Random r;
        float x = r.GenerateFloat(CFG_GETF("LEVEL_1_MIN_X"), CFG_GETF("LEVEL_1_MAX_X"));
        float y = r.GenerateFloat(CFG_GETF("LEVEL_1_MIN_Y"), CFG_GETF("LEVEL_1_MAX_Y"));
        auto cell = EntityFactory::CreateCell(Vector(x, y));
        auto growthComponent = std::static_pointer_cast<GrowthComponent>(Engine::GetInstance().GetEntityManager()->GetSingleComponentOfClass(cell, "GrowthComponent"));

        if (r.GenerateFloat() < 0.1)
            growthComponent->SetLevel(2);

        Engine::GetInstance().AddComponent(
            std::make_shared<AIComponent>("EatableComponent"), cell);
    }

    if (finished)
    {
        ZoomOutEffect();
    }
    else
    {
        if (!Engine::GetInstance().HasEntityWithComponentOfClass("PlayerComponent"))
        {
            Engine::GetInstance().SetNextLevel(std::make_shared<LoseLevel>());
            SetFinished();
        }
        else
        {
            auto playerEntity = Engine::GetInstance().GetEntityWithComponentOfClass("PlayerComponent");
            auto growthComponent = std::static_pointer_cast<GrowthComponent>(Engine::GetInstance().GetEntityManager()->GetSingleComponentOfClass(playerEntity, "GrowthComponent"));

            if (growthComponent->GetLevel() == CFG_GETI("LEVEL_1_GOAL_SIZE"))
            {
                finished = true;
                Engine::GetInstance().DeleteSystem("GrowthSystem");
            }
        }
    }
}
    GeometricObjectTutorialParams()
        : ParamBlockDescUtil(
			0,
			_M("GeometricObjectTutorialParameters"),
            IDS_PARAMS, 
			GeometricObjectTutorialClassDesc::GetInstance(),  
			0,
			0,
			IDD_PANEL, 
			IDS_TITLE,
			NULL)
    {
        // Adds a float parameter, with a spinner UI
        AddFloatSpinnerParam(GeometricObjectTutorial::SIZE_PARAM_ID, _M("Size"), IDS_FLOAT_PARAM, 0.0f, 1000.0f, 0.0f, IDC_PARAM_EDIT, IDC_PARAM_SPIN);

        // Prevent further changes to the parameter block descriptor
        SetFinished(); 
    }
Example #10
0
void Action::Process(Action *pendingAction)
{
#ifndef _TEST
	STOMPCHECK();
#endif

	if(pendingAction != this )
		Process();

	if (m_endCondition == ACTIONEND_INTERRUPT || Finished())
	{
		pendingAction->SetItIsTimeToAct(true);
		SetFinished(true);
	}

#ifndef _TEST
	STOMPCHECK();
#endif
}
Example #11
0
void TowerDefenseInstanceScript::TowerDefenseMapInstanceScript::DeleteEventData()
{
    Player *player = GetPlayer();
    if(!player)
        return;

    SetEventId(0);
    SetPlayerGUID(0);
    SetCurrentWaveId(0);
    SetBaseHealth(0);
    SetResources(0);
    SetUnits(0);
    SetFinished(false);
    SetEventStatus(TD_EVENT_STATUS_NONE);
    CountDown = 0;
    Events.Reset();
    RecordLog("TowerDefense: the tower defense event for player %s was deleted", player->GetName());
    _player = NULL;
}
void AudioStreamDecoder::QueueRunningCallback(AudioQueueRef queue, AudioQueuePropertyID property)
{
	long err;

	BAIL_IF(!queue || queue != mQueue, "Invalid queue %p\n", queue);
	BAIL_IF(!mStarted, "Queue not started\n");

	UInt32 running, size;
	err = AudioQueueGetProperty(mQueue, kAudioQueueProperty_IsRunning, &running, &size);
	BAIL_IF(err, "AudioQueueGetProperty returned %ld\n", err);

	if (!running)
	{
		err = SetFinished();
		BAIL_IF(err, "Finished returned %ld\n", err);
	}

bail:
	return;
}
Example #13
0
void
WUploadThread::DoUpload()
{
	PRINT("WUploadThread::DoUpload\n");
	if (fShutdownFlag && *fShutdownFlag)	// Do we need to interrupt?
	{
		ConnectTimer();
		return;
	}

	// Still connected?

	if (!IsInternalThreadRunning())
	{
		ConnectTimer();
		return;
	}

	// Small files get to bypass queue
	if (IsLocallyQueued())
	{
		if (
			(fFile && (fFileSize >= gWin->fSettings->GetMinQueuedSize())) ||
			IsManuallyQueued()
			)
		{
			// not yet
			fForced = false;
			WUploadEvent *lq = new WUploadEvent(WUploadEvent::FileQueued);
			if (lq)
			{
				SendReply(lq);
			}
			return;
		}
		fForced = true;		// Set this here to avoid duplicate call to DoUpload()
	}

	// Recheck if IP is ignored or not
	//

	if (gWin->IsIgnoredIP(fStrRemoteIP) && !IsBlocked())
	{
		SetBlocked(true);
	}

	if (IsBlocked())
	{
		WUploadEvent *wue = new WUploadEvent(WUploadEvent::FileBlocked);
		if (wue)
		{
			if (fTimeLeft != -1)
				wue->SetTime(fTimeLeft);
			SendReply(wue);
		}
		return;
	}

	if (fStartTime == 0)
		fStartTime = GetRunTime64();

	if (fFile)
	{
		MessageRef uref(GetMessageFromPool(WTransfer::TransferFileData));
		if (uref())
		{
			// think about doing this in a dynamic way (depending on connection)
			double dpps = GetPacketSize() * 1024.0;
			uint32 bufferSize = lrint(dpps);
			ByteBufferRef buf = GetByteBufferFromPool(bufferSize);

			uint8 * scratchBuffer = buf()->GetBuffer();
			if (scratchBuffer == NULL)
			{
				_nobuffer();
				return;
			}

			int32 numBytes = 0;
			numBytes = fFile->ReadBlock32(scratchBuffer, bufferSize);
			if (numBytes > 0)
			{
				buf()->SetNumBytes(numBytes, true);

				// munge mode

				switch (fMungeMode)
				{
					case WTransfer::MungeModeNone:
					{
						uref()->AddInt32("mm", WTransfer::MungeModeNone);
						break;
					}

					case WTransfer::MungeModeXOR:
					{
						for (int32 x = 0; x < numBytes; x++)
							scratchBuffer[x] ^= 0xFF;
						uref()->AddInt32("mm", WTransfer::MungeModeXOR);
						break;
					}

					default:
					{
						break;
					}
				}

				if (uref()->AddFlat("data", buf) == B_OK)
				{
					// possibly do checksums here
					uref()->AddInt32("chk", CalculateFileChecksum(buf));  // a little paranoia, due to file-resumes not working.... (TCP should handle this BUT...)

					SendMessageToSessions(uref);

					// NOTE: RequestOutputQueuesDrainedNotification() can recurse, so we need to update the offset before
					//       calling it!
					fCurrentOffset += numBytes;
					if (fTunneled)
					{
						SignalUpload();
					}
					else
					{
						MessageRef drain(GetMessageFromPool());
						if (drain())
							qmtt->RequestOutputQueuesDrainedNotification(drain);
					}

					WUploadEvent *update = new WUploadEvent(WUploadEvent::FileDataSent);
					if (update)
					{
						update->SetOffset(fCurrentOffset);
						update->SetSize(fFileSize);
						update->SetSent(numBytes);

						if (fCurrentOffset >= fFileSize)
						{
							update->SetDone(true);	// file done!
							update->SetFile(SimplifyPath(fFileUl));

							if (gWin->fSettings->GetUploads())
							{
								SystemEvent( gWin, tr("%1 has finished downloading %2.").arg( GetRemoteUser() ).arg( SimplifyPath(fFileUl) ) );
							}
						}
						SendReply(update);
					}

					return;
				}
				else
				{
					_nobuffer();
					return;
				}
			}

			if (numBytes <= 0)
			{
				NextFile();
				SignalUpload();
				return;
			}
		}
	}
	else
	{
		while (!fFile)
		{
			if (fUploads.GetNumItems() != 0)
			{
				// grab the ref and remove it from the list
				fUploads.RemoveHead(fCurrentRef);

				fFileUl = MakeUploadPath(fCurrentRef);

#ifdef _DEBUG
				// <*****@*****.**> 20021023, 20030702 -- Add additional debug message
				WString wul(fFileUl);
				PRINT("WUploadThread::DoUpload: filePath = %S\n", wul.getBuffer());
#endif

				fFile = new WFile();
				Q_CHECK_PTR(fFile);
				if (!fFile->Open(fFileUl, QIODevice::ReadOnly))	// probably doesn't exist
				{
					delete fFile;
					fFile = NULL;
					fCurFile++;
					continue;	// onward
				}
				// got our file!
				fFileSize = fFile->Size();
				fCurrentOffset = 0;	// from the start
                                if (fCurrentRef()->FindInt64("secret:offset", fCurrentOffset) == B_OK)
				{
					if (!fFile->Seek(fCurrentOffset)) // <*****@*****.**> 20021026
					{
						fFile->Seek(0);	// this can't fail :) (I hope)
						fCurrentOffset = 0;
					}
				}
				// copy the message in our current file ref
				MessageRef headRef = fCurrentRef.Clone();
				if (headRef())
				{
					headRef()->what = WTransfer::TransferFileHeader;
					headRef()->AddInt64("beshare:StartOffset", fCurrentOffset);
					SendMessageToSessions(headRef);
				}

				fCurFile++;

				// Reset statistics
				InitTransferRate();
				InitTransferETA();

				WUploadEvent *started = new WUploadEvent(WUploadEvent::FileStarted);
				if (started)
				{
					started->SetFile(SimplifyPath(fFileUl));
					started->SetStart(fCurrentOffset);
					started->SetSize(fFileSize);
#ifdef _DEBUG
					started->SetSession(fRemoteSessionID);
#endif
					SendReply(started);
				}

				if (gWin->fSettings->GetUploads())
				{
					SystemEvent( gWin, tr("%1 is downloading %2.").arg( GetRemoteUser() ).arg( SimplifyPath(fFileUl) ) );
				}

				// nested call
				SignalUpload();
				return;
			}
			else
			{
				PRINT("No more files!\n");
				fWaitingForUploadToFinish = true;
				SetFinished(true);
				if (fTunneled)
				{
					_OutputQueuesDrained();
				}
				else
				{
					MessageRef drain(GetMessageFromPool());
					if (drain())
						qmtt->RequestOutputQueuesDrainedNotification(drain);
				}
				break;
			}
		}
	}
}
Example #14
0
void Level1::ExitButtonCallback()
{
    LOG_I("[Level1] Clicked on exit button");
    SetFinished();
}
Example #15
0
void Level1::MenuButtonCallback()
{
    LOG_I("[Level1] Clicked on menu button");
    SetFinished();
    Engine::GetInstance().SetNextLevel(std::make_shared<EntryLevel>());
}
Example #16
0
void TowerDefenseInstanceScript::TowerDefenseMapInstanceScript::HandleEventComplete(TDEventCompleteType completeType)
{
    Player *player = GetPlayer();
    if(!player)
        return;
    if(!completeType)
        return;

    switch(completeType)
    {
    case TD_EVENT_COMPLETE_UNFINISHED:
        {
            if(IsAwardingFledPlayers()){
                UpdatePlayerStats(GetPlayerGUID(), TD_PLAYER_STAT_CURRENT_RESOURCES, GetResources());
                SendMailToPlayer(NULL, GetPlayerGUID(), TD_SYSTEM_MSG_MAIL_BODY_EVENT_UNFINISHED, GetResources());
                RecordLog("TowerDefense: Player: [%s] has received: [%u] resources due to an unfinished Event Id: [%u].", player->GetName(), GetResources(), GetEventId());
            }else{
                SendMailToPlayer(NULL, GetPlayerGUID(), TD_SYSTEM_MSG_MAIL_BODY_EVENT_UNFINISHED_FLED, GetResources(), GetCurrentWaveId());
                RecordLog("TowerDefense: Player: [%s] was informed that he lost all his unfinished Event Id: [%u] rewards.", player->GetName(), GetResources(), GetEventId());
            }
            UpdatePlayerStats(player->GetGUIDLow(), TD_PLAYER_STAT_EVENTS_UNFINISHED, 1);
        }break;
    case TD_EVENT_COMPLETE_QUIT:
        {
            if(player->GetSession()->isLogingOut()){
                SendMessageToPlayer(TD_SYSTEM_MSG_LOGGING_OUT);
                return;
            }
            if(GetCurrentWaveId() < GetQuitAfterWave()){
                uint32 remaining = GetQuitAfterWave() - GetCurrentWaveId();
                SendMessageToPlayer(TD_SYSTEM_MSG_MORE_WAVES, remaining);
                return;
            }
            SendMessageToPlayer(TD_SYSTEM_MSG_QUIT_EVENT, GetResources(), GetCurrentWaveId());
            UpdatePlayerStats(GetPlayerGUID(), TD_PLAYER_STAT_CURRENT_RESOURCES, GetResources());
            UpdatePlayerStats(player->GetGUIDLow(), TD_PLAYER_STAT_EVENTS_LOST, 1);
            RecordLog("TowerDefense: Player: [%s] has received: [%u] resources after leaving Event Id: [%u].", player->GetName(), GetResources(), GetEventId());
        }break;
    case TD_EVENT_COMPLETE_LOST:
        {
            player->PlayDirectSound(TD_ENDEVENT_MUSIC,_player);
            SendMessageToPlayer(TD_SYSTEM_MSG_LOST_EVENT, GetResources(), GetCurrentWaveId());
            UpdatePlayerStats(player->GetGUIDLow(), TD_PLAYER_STAT_EVENTS_LOST, 1);
            RecordLog("TowerDefense: Player: [%s] was informed that he lost all his Event Id: [%u] rewards.", player->GetName(), GetResources(), GetEventId());
        }break;
    case TD_EVENT_COMPLETE_WON:
        {
            SendMessageToPlayer(TD_SYSTEM_MSG_WON_EVENT, GetResources());
            UpdatePlayerStats(GetPlayerGUID(), TD_PLAYER_STAT_CURRENT_RESOURCES, GetResources());
            UpdatePlayerStats(player->GetGUIDLow(), TD_PLAYER_STAT_EVENTS_WON, 1);
            RecordLog("TowerDefense: Player: [%s] has won [%u] resources after completing Event Id: [%u].", player->GetName(), GetResources(), GetEventId());
        }break;
    }
    player->DestroyItemCount(GetItemEntry(),1,true); // destroy the item from the player
    player->TeleportTo(1, -3673.392090, -4384.723145, 10.026433,  3.879712); // Teleport to a Neutral Mall
    player->RemoveAllAuras(); // remove all auras set by event
    player->RemoveAllAttackers(); // remove all attackers
    SetFinished(true); // finish the event
    SaveEventData(); // save event information
    RecordLog("TowerDefense: Player: [%s] has completed Event Id: [%u] and his event data was saved and he was teleported.", player->GetName(), GetEventId());
    DeleteEventData();
}