Exemple #1
0
void CProcessor::Edit(CBirthday * pbd)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState( )); 
	CSetBirthdayDlg bddlg( AfxGetMainWnd(), pbd->m_name, pbd->m_date.GetDay(), pbd->m_date.GetMonth(), pbd->m_date.GetYear() );
	if( bddlg.DoModal() == IDOK )
	{
		// Update the data
		pbd->m_name = bddlg.m_name;

		if( pbd->m_date != CDate(bddlg.m_day,bddlg.m_month,bddlg.m_year) )
		{
			// UPDATE ALL

			m_pApp->ClearKnown( pbd );
			// This garantees re-sorting
			CBirthday* pnew = new CBirthday;
			*pnew = *pbd;
			Remove( pbd );

			pnew->m_date = CDate(bddlg.m_day,bddlg.m_month,bddlg.m_year);
			Add( pbd=pnew );
		}

		// Persistency
		Store();

		// ONLY UPDATE SOME TEXT
		m_pApp->UpdateText( pbd );

		ProcessAction(true);
	}
}
Exemple #2
0
void CProcessor::Confirm(CBirthday *pbd)
{
	pbd->m_confirmed = true;

	if( !pbd->m_date.AfterAndWithinDays( CDate(),
			m_pconfig->m_daysAdvance ) )
		pbd->m_alerted_this_year = false;

	Store();
	ProcessAction(true);
}
Exemple #3
0
void CProcessor::PrefsAction(HWND hwnd)
{
	ASSERT(m_pconfig);
	if( m_pconfig )
	{
		m_pconfig->PrefsAction(hwnd);
		DepopulateKnowns();
		PopulateKnowns();
		DepopulateBirthdays();
		ProcessAction(true);
	}
}
void RPG_ActionHandler::PerformAction(RPG_ActionType_e const& action, bool forceAction /*= false*/, RPG_BaseEntity* const interactionEntity /*= NULL*/, 
                                      hkvVec3 const& interactionPosition /*= hkvVec3(0, 0, 0)*/, int const flags /*= 0*/)
{
  // if the action and the target are the same, we're just updating flags or interaction.
  bool updatingActionParams = false;
  
  if(m_activeAction.m_Action == action)
  {
    if(m_activeAction.m_interactionEntity != interactionEntity ||
       !m_activeAction.m_interactionPosition.isIdentical(interactionPosition) ||
       m_activeAction.m_flags != flags)
    {
      updatingActionParams = true;
    }
  }

  if(!forceAction && 
     m_activeAction.m_Action != AT_None &&
     action != AT_None)
  {  
    // there's an action already playing, and we aren't forcing the new one. perfor more checks.
    if(m_Actions[m_activeAction.m_Action]->CanOverrideActionWith(action) ||
       m_Actions[action]->CanThisActionOverride(m_activeAction.m_Action))
    {
      forceAction = true;
    }
  }

  if (forceAction || updatingActionParams || CanPerformAction(action))
  {
    // bundle the action into a struct for easier network replication
    RPG_ActionData actionData(action, interactionEntity, interactionPosition, flags);

    // simulate the action locally
    ProcessAction(actionData, forceAction);

    // replicate the action to the server
    //@todo: Once the network branch is integrated, here's where we replicate this action to the server.
    /*
    Work that needs to happen here:
    - Find out whether this is a non-authoritative client.
    - If all we're doing is updating action flags, preserve bandwidth by calling a client->server UpdateActionFlags() with just that data
    - If we're doing a new Action, call a client->server ProcessAction() using the constructed struct.
    */
  }
  else if(action != AT_None &&
     m_Actions[m_activeAction.m_Action]->CanChainAction(action))
  {
    // can't process the new action, so check to see if we can chain it
    RPG_ActionData actionData(action, interactionEntity, interactionPosition, flags);
    m_pendingAction = actionData;
  }
}
Exemple #5
0
void CProcessor::Add(CBirthday * pbd)
{
	ASSERT(m_pbds);
	if( m_pbds )
	{
		m_pbds->Add(pbd);
		ProcessAction(true);
		m_pbds->Store();
	}
	// Add to list
	m_pApp->DrawKnown( pbd );
	m_pApp->UpdateCounter();
}
tResult LightMessageLogger::OnAsyncPinEvent(IPin* pSource, tInt nEventCode, tInt nParam1, tInt nParam2,
		IMediaSample* pMediaSample) {
	RETURN_IF_POINTER_NULL(pMediaSample);
	RETURN_IF_POINTER_NULL(pSource);

	__synchronized_obj(criticalSection_OnPinEvent);

	if (nEventCode == IPinEventSink::PE_MediaSampleReceived) {
		if (pSource == &actionInput) {
			TActionStruct::ActionSub actionSub_tmp;
			actionSub_tmp = tActionStruct_object.Read_Action(pMediaSample, F_LIGHT_MESSAGE_LOGGER);
			ProcessAction(actionSub_tmp);
		}
	}

	RETURN_NOERROR;
}
Exemple #7
0
void CProcessor::Reload(CBirthday *pbd)
{
	if( pbd->Reload() )
	{
		// UPDATE ALL

		m_pApp->ClearKnown( pbd );
		// This garantees re-sorting
		CBirthday* pnew = new CBirthday;
		*pnew = *pbd;
		Remove( pbd );
		Add( pbd=pnew );

		// Persistency
		Store();

		ProcessAction(true);
	}
}
Exemple #8
0
//---------------------------------------------------------------------------------------------------
void FactionState::Update(float deltaTime)
{
  std::vector<ShipInfo> shipInfos;
  std::vector<ShipInfo> friendlyShips;

  // Gather info on all ships
  for (auto &ship : battle_.ships())
  {
    shipInfos.emplace_back(
      ship.faction().id(), ship.id(),
      ship.hp(), ship.max_hp(),
      ship.position(), ship.orientation(),
      ship.mass(), ship.velocity());

    if (&ship.faction() == this)
      friendlyShips.emplace_back(
        ship.faction().id(), ship.id(),
        ship.hp(), ship.max_hp(),
        ship.position(), ship.orientation(),
        ship.mass(), ship.velocity());
  }

  // Create the input buffer
  AIInput input(deltaTime,
    battle_.bounds(),
    std::move(shipInfos),
    std::move(friendlyShips));

  FactionAICommand command;
  ai_->Update(input, command);

	const ActionBuffer& commandBuffer = command.read_buffer();
	while (!commandBuffer.read_eof())
	{
		AIAction action = commandBuffer.BeginReadEvent();
    ProcessAction(action, commandBuffer);
		commandBuffer.EndReadEvent();
	}
}
void IsuCompetition::AddAction(OsisAction* newAction)
{
   if (!newAction)
   {
      return;
   }
   if (Current_Action)
   {
      delete Current_Action;
   }
   Current_Action = newAction;

   const QMetaObject &mo = Actions::staticMetaObject;
   int index = mo.indexOfEnumerator("ObsAction");
   QMetaEnum metaEnum = mo.enumerator(index);

   QString elementName = newAction->GetAttribute(OsisAction::Command);
   elementName = elementName.toUpper();
   elementName.prepend("ACTION_");
   int xmlElementTag = metaEnum.keyToValue(&elementName.toStdString()[0]);
   ProcessAction(xmlElementTag);
}
void Connection::ProcessSectorServerOpcode(short opcode, short bytes)
{
	unsigned long tick = GetNet7TickCount();
	//LogMessage("<CLIENT> ---> 0x%04x\n", opcode);
    //this can be used to intercept messages from the client
    switch (opcode)
    {
        case ENB_OPCODE_0002_LOGIN:
            g_LoggedIn = true;
            g_ServerMgr->m_SectorConnection = this;
            LogMessage("Sending Login packet - connection active\n");
            g_ServerMgr->m_UDPConnection->SetConnectionActive(true);
            g_ServerMgr->m_UDPClient->SetConnectionActive(true);
            time_debug = 50;
            break;

		case ENB_OPCODE_0006_START_ACK :
			g_ServerMgr->m_UDPConnection->ForwardClientOpcode(opcode, bytes, (char*)m_RecvBuffer);
			if (g_ServerMgr->m_UDPClient->GetSectorID() > 9999 || g_ServerMgr->m_UDPConnection->PreferTCP())
			{
				long player_id = g_ServerMgr->m_UDPClient->PlayerID();
				g_ServerMgr->m_UDPConnection->ForwardClientOpcode(ENB_OPCODE_3008_STARBASE_LOGIN_COMPLETE, sizeof(player_id), (char *) &player_id);
				g_ServerMgr->m_UDPClient->SetLoginComplete(true);
			}
			else
			{
				long player_id = g_ServerMgr->m_UDPClient->PlayerID();
				g_ServerMgr->m_UDPConnection->ForwardClientOpcode(ENB_OPCODE_3004_PLAYER_SHIP_SENT, sizeof(player_id), (char *) &player_id);
				g_ServerMgr->m_UDPConnection->KillTCPConnection();
				g_ServerMgr->m_UDPClient->SetLoginComplete(true);
			}
			LogMessage("Sending StartAck to Server %d\n", *((long *) &m_RecvBuffer[0]) );
			return;
			break;

		case ENB_OPCODE_0014_MOVE :
			break;

		case ENB_OPCODE_0012_TURN :
			//only send one of these per 0.25 secs
			if (tick > (m_Turn_Sent + 250))
			{
				g_ServerMgr->m_UDPConnection->ForwardClientOpcode(opcode, bytes, (char*)m_RecvBuffer);
				m_Turn_Sent = tick;
			}
			return;
			break;

		case ENB_OPCODE_0013_TILT :
			//only send one of these per 0.25 secs
			if (tick > (m_Tilt_Sent + 250))
			{
				g_ServerMgr->m_UDPConnection->ForwardClientOpcode(opcode, bytes, (char*)m_RecvBuffer);
				m_Tilt_Sent = tick;
			}
			return;
			break;

        case ENB_OPCODE_00B9_LOGOFF_REQUEST:
            g_LoggedIn = true;
            //drop through
        case ENB_OPCODE_003A_SERVER_HANDOFF:
            //DumpBuffer(m_RecvBuffer, bytes);
            //LogMessage("Handoff\n", opcode);
            //g_ServerMgr->m_UDPConnection->SetConnectionActive(false);
            //g_ServerMgr->m_UDPClient->SetConnectionActive(false);
            break;

        case ENB_OPCODE_002C_ACTION:
            g_ServerMgr->m_UDPConnection->ForwardClientOpcode(opcode, bytes, (char*)m_RecvBuffer);
            ProcessAction();
            return;
            break;

		case ENB_OPCODE_009F_STARBASE_ROOM_CHANGE :
			HandleStarbaseRoomChange();
			break;

		case ENB_OPCODE_009B_WARP:
			HandleWarp();
			break;

        default:
            //LogMessage("Forwarding opcode to server 0x%04x\n", opcode);
            break;
    }

    //forward the opcode to the server via UDP
    g_ServerMgr->m_UDPConnection->ForwardClientOpcode(opcode, bytes, (char*)m_RecvBuffer);
}
Exemple #11
0
int main(void) {
		char str[100];

//		char buffer1[100];
		
//	/* Free and total space */
//	uint32_t total, free;
	
	/* Initialize system */
	SystemInit();
	
	/* Initialize delays */
	TM_DELAY_Init();
	/* Enable watchdog, 4 seconds before timeout */
	if (TM_WATCHDOG_Init(TM_WATCHDOG_Timeout_8s)) {
		/* Report to user */
		//printf("Reset occured because of Watchdog\n");
	}	
	/* Reset counter to 0 */
	TM_DELAY_SetTime(0);
	/* init DTMF*/
	TM_GPIO_Init(DTMF_BIT0_PORT, DTMF_BIT0_PIN, TM_GPIO_Mode_IN, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_Low);
	TM_GPIO_Init(DTMF_BIT1_PORT, DTMF_BIT1_PIN, TM_GPIO_Mode_IN, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_Low);
	TM_GPIO_Init(DTMF_BIT2_PORT, DTMF_BIT2_PIN, TM_GPIO_Mode_IN, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_Low);
	TM_GPIO_Init(DTMF_BIT3_PORT, DTMF_BIT3_PIN, TM_GPIO_Mode_IN, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_Low);
	/* DTMF*/
		if (TM_EXTI_Attach(DFMF_BIT4_PORT, DTMF_BIT4_PIN, TM_EXTI_Trigger_Rising) == TM_EXTI_Result_Ok) {
		TM_USART_Puts(USART3, "khoi tao ngat DFMF_BIT4\n");
	}
	
	/*init interrup INPUT*/
		if (TM_EXTI_Attach(W1_D0_PORT, W1_D0_PIN, TM_EXTI_Trigger_Rising) == TM_EXTI_Result_Ok) {
		TM_USART_Puts(USART3, "khoi tao ngat W1_D0\n");
	}
		if (TM_EXTI_Attach(W1_D1_PORT, W1_D1_PIN, TM_EXTI_Trigger_Rising) == TM_EXTI_Result_Ok) {
		TM_USART_Puts(USART3, "khoi tao ngat W1_D1\n");
	}
		if (TM_EXTI_Attach(W2_D1_PORT, W2_D1_PIN, TM_EXTI_Trigger_Falling) == TM_EXTI_Result_Ok) {
		TM_USART_Puts(USART3, "khoi tao ngat W2_D1\n");
	}
		if (TM_EXTI_Attach(W2_D0_PORT, W2_D0_PIN, TM_EXTI_Trigger_Falling) == TM_EXTI_Result_Ok) {
		TM_USART_Puts(USART3, "khoi tao ngat W2_D0\n"); // W2D0
	}
	/*init SWADD*/
	TM_GPIO_Init(ADD_BIT0_PORT, ADD_BIT0_PIN, TM_GPIO_Mode_IN, TM_GPIO_OType_PP, TM_GPIO_PuPd_UP, TM_GPIO_Speed_Medium);	
	TM_GPIO_Init(ADD_BIT1_PORT, ADD_BIT1_PIN, TM_GPIO_Mode_IN, TM_GPIO_OType_PP, TM_GPIO_PuPd_UP, TM_GPIO_Speed_Medium);
	TM_GPIO_Init(ADD_BIT2_PORT, ADD_BIT2_PIN, TM_GPIO_Mode_IN, TM_GPIO_OType_PP, TM_GPIO_PuPd_UP, TM_GPIO_Speed_Medium);
	TM_GPIO_Init(ADD_BIT3_PORT, ADD_BIT3_PIN, TM_GPIO_Mode_IN, TM_GPIO_OType_PP, TM_GPIO_PuPd_UP, TM_GPIO_Speed_Medium);
	TM_GPIO_Init(ADD_BIT4_PORT, ADD_BIT4_PIN, TM_GPIO_Mode_IN, TM_GPIO_OType_PP, TM_GPIO_PuPd_UP, TM_GPIO_Speed_Medium);
	TM_GPIO_Init(ADD_BIT5_PORT, ADD_BIT5_PIN, TM_GPIO_Mode_IN, TM_GPIO_OType_PP, TM_GPIO_PuPd_UP, TM_GPIO_Speed_Medium);
	TM_GPIO_Init(ADD_BIT6_PORT, ADD_BIT6_PIN, TM_GPIO_Mode_IN, TM_GPIO_OType_PP, TM_GPIO_PuPd_UP, TM_GPIO_Speed_Medium);
	TM_GPIO_Init(ADD_BIT7_PORT, ADD_BIT7_PIN, TM_GPIO_Mode_IN, TM_GPIO_OType_PP, TM_GPIO_PuPd_UP, TM_GPIO_Speed_Medium);
	/* init OUTPUT*/
	TM_GPIO_Init(RELAY_DK1_PORT, RELAY_DK1_PIN, TM_GPIO_Mode_OUT, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High);
	TM_GPIO_Init(RELAY_DK2_PORT, RELAY_DK2_PIN, TM_GPIO_Mode_OUT, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High);
	TM_GPIO_Init(RELAY_DK3_PORT, RELAY_DK3_PIN, TM_GPIO_Mode_OUT, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High);
	TM_GPIO_Init(RELAY_DK4_PORT, RELAY_DK4_PIN, TM_GPIO_Mode_OUT, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High);
/* Initialize USART6 at 115200 baud, TX: PC6, RX: PC7 , COM 1 - RFID1 gan cong tac nguon*/ 
	TM_USART_Init(USART6, TM_USART_PinsPack_1, 115200);
/* Initialize USART3 at 115200 baud, TX: PD8, RX: PD9 ,	COM 2 -RFID 2 gan ethernet*/
	TM_USART_Init(USART3, TM_USART_PinsPack_3, 115200);
/* Initialize USART1 at 115200 baud, TX: PA9, RX: PA10, CONG 485 */
	TM_USART_Init(USART1, TM_USART_PinsPack_1, 9600);
	/* Initialize USART2, with custom pins */					// COM 3 extension PC
	//TM_USART_Init(USART2, TM_USART_PinsPack_Custom,9600);
	TM_USART_Init(USART2, TM_USART_PinsPack_2,9600);
	
/* int DIR 485 set = send , reset = recvice*/ 
	TM_GPIO_Init(CCU_DIR_PORT, CCU_DIR_PIN, TM_GPIO_Mode_OUT, TM_GPIO_OType_PP, TM_GPIO_PuPd_UP, TM_GPIO_Speed_High);
	TM_GPIO_SetPinHigh(CCU_DIR_PORT,CCU_DIR_PIN);
/* Init 2 custom timers */
/* Timer1 has reload value each 500ms, enabled auto reload feature and timer is enabled */
	CustomTimer1 = TM_DELAY_TimerCreate(500, 1, 1, CustomTIMER1_Task, NULL);
	/* Timer1 has reload value each 1000ms, enabled auto reload feature and timer is enabled */
	CustomTimer2 = TM_DELAY_TimerCreate(100, 1, 1, CustomTIMER2_Task, NULL);
/* Init LCD*/
		TM_GPIO_Init(HD44780_RW_PORT, HD44780_RW_PIN, TM_GPIO_Mode_OUT, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High);
		TM_GPIO_SetPinLow(HD44780_RW_PORT,HD44780_RW_PIN);

		read_sw_add();
		timeout = value_dip;
		memset(str,'\0',0);
    //Initialize LCD 20 cols x 4 rows
    TM_HD44780_Init(16, 4);
    //Save custom character on location 0 in LCD
    TM_HD44780_CreateChar(0, &customChar[0]);    
    //Put string to LCD
    TM_HD44780_Puts(0, 0, "STM32F407VET\n\rCreartbyR&D-TIS"); /* 0 dong 1, 1 dong 2*/
    TM_HD44780_Puts(0, 2, "Welcome");
		Delayms(1000);
		TM_HD44780_Clear();
		sprintf(str,"Timer out %d", timeout);
		TM_HD44780_Puts(0, 0,str);
		Delayms(1000);
		TM_HD44780_Clear();
		TM_HD44780_Puts(0, 0,"----TIS8 PRO----");
		//TM_USART_Puts(USART3, "Welcome2");

	/*creat by duc*/
		TM_WATCHDOG_Reset();

//		TM_USART_BufferEmpty(USART3);
//		TM_USART_BufferEmpty(USART6);
		flag_RFID2=0;	
		flag_RFID1=0;
	/*end by duc*/
	while (1) {
/*process 485*/
	if(flag_485){
	flag_485=0;
	if(LEDStatus==0) TM_USART_Puts(USART1, "/LED000>\r\n");
	if(LEDStatus==1) TM_USART_Puts(USART1, "/LED001>\r\n");
	if(LEDStatus==2) TM_USART_Puts(USART1, "/LED002>\r\n");
	}	

/* xu li W1D0 - dk1*/
	if(flag_W1D0){
		turn_on_dk1();
		//flag_W1D0=0;
	}
/* xu li W1D1 - dk2*/
	if(flag_W1D1){
		turn_on_dk2();
		//flag_W1D1=0;
	}
	//TM_WATCHDOG_Reset();
//		/*end*/


if(Process!=1)
		TM_HD44780_Puts(0, 2,"Wait for Card"); /* 0 dong 1, 1 dong 2*/
if(flag_RFID1==1)
		{	
		
		Process=1;
		IDCAR1[0]=BufferCom1[4];
		IDCAR1[1]=BufferCom1[5];
		IDCAR1[2]=BufferCom1[6];
		IDCAR1[3]=BufferCom1[7];
		IDCAR1[4]=BufferCom1[8];
		IDCAR1[5]=BufferCom1[9];
		IDCAR1[6]=BufferCom1[10];
		
		if(BufferCom1[1]==0x08)	
			{
			sprintf(UID1,"%02x %02x %02x %02x,1",IDCAR1[0],IDCAR1[1],IDCAR1[2],IDCAR1[3]);
			}
		if(BufferCom1[1]==0x0B) 
			{
			sprintf(UID1,"%02x %02x %02x %02x %02x %02x %02x,1",IDCAR1[0],IDCAR1[1],IDCAR1[2],IDCAR1[3],IDCAR1[4],IDCAR1[5],IDCAR1[6]);
			}
		TM_HD44780_Puts(0, 2,"Waiting PC..."); /* 0 dong 1, 1 dong 2*/
				if(check_vip(UID1)){
			flag_PC=1;
			flag_R11=1;
			timerdk1 =0;
			Process=0;
		}
		else{
		if(Process)TM_USART_Puts(USART2,UID1);
		}
		WaitPC(200);
		flag_RFID1=0;
		if(flag_PC)
		{
			TM_HD44780_Puts(0, 2,"Door opened.."); /* 0 dong 1, 1 dong 2*/
			flag_PC=0;
			ProcessAction();
		}
		else Process=0;
		flag_RFID1=0;
	}
if(flag_RFID2==1)
		{	
		
		Process=1;
		IDCAR2[0]=BufferCom2[4];
		IDCAR2[1]=BufferCom2[5];
		IDCAR2[2]=BufferCom2[6];
		IDCAR2[3]=BufferCom2[7];
		IDCAR2[4]=BufferCom2[8];
		IDCAR2[5]=BufferCom2[9];
		IDCAR2[6]=BufferCom2[10];
		
		if(BufferCom2[1]==0x08)	
			{
			sprintf(UID2,"%02x %02x %02x %02x ,2",IDCAR2[0],IDCAR2[1],IDCAR2[2],IDCAR2[3]);
			}
		if(BufferCom2[1]==0x0B) 
			{
			sprintf(UID2,"%02x %02x %02x %02x %02x %02x %02x ,2",IDCAR2[0],IDCAR2[1],IDCAR2[2],IDCAR2[3],IDCAR2[4],IDCAR2[5],IDCAR2[6]);
			}
		TM_HD44780_Puts(0, 2,"Waiting PC..."); /* 0 dong 1, 1 dong 2*/
			if(check_vip(UID2)){
			flag_PC=1;
			flag_R31=1;
			timerdk2 =0;
			Process=0;
		}
		else{
		if(Process)TM_USART_Puts(USART2,UID2);}
		WaitPC(200);
		flag_RFID2=0;
		if(flag_PC)
		{
			TM_HD44780_Puts(0, 2,"Door opened.."); /* 0 dong 1, 1 dong 2*/
			flag_PC=0;
			ProcessAction();
		}
		else Process=0;
		flag_RFID2=0;
	}
		
/**/
timer_dk1 = timerdk1/2;	
if (timer_dk1 >= timeout){
			turn_off_dk1();
			flag_R11 =0;
			flag_W1D0=0;
			timerdk1=0;
			timer_dk1=0;
			flag_RFID1=0;
			flag_RFID2=0;
			Process=0;
//			if(LEDStatus==0) TM_USART_Puts(USART3, "/LED000>\r\n");
		}
timer_dk2 = timerdk2/2;
if (timer_dk2 >= timeout){
			turn_off_dk2();
			//flag_R21 =0;
			flag_R31 =0;
			flag_W1D1=0;
			timerdk2=0;
			timer_dk2=0;
			//flag_RFID1=0;
			Process=0;
//			if(LEDStatus==0) TM_USART_Puts(USART3, "/LED000>\r\n");
		}
timer_dk3 = timerdk3;
if (timer_dk3 >= 1){
			turn_off_dk3();
			flag_R12 =0;
			timerdk3=0;
			timer_dk3=0;
		}
timer_dk4 = timerdk4;
if (timer_dk4 >= 1){
			turn_off_dk4();
			flag_R22 =0;
			timer_dk4=0;
			timerdk4=0;
		}


		TM_WATCHDOG_Reset();
}
}
Exemple #12
0
bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& holder, Unit* actionInvoker /*=NULL*/)
{
    if (!holder.Enabled || holder.Time)
        return false;

    //Check the inverse phase mask (event doesn't trigger if current phase bit is set in mask)
    if (holder.Event.event_inverse_phase_mask & (1 << m_Phase))
        return false;

    CreatureEventAI_Event const& event = holder.Event;

    //Check event conditions based on the event type, also reset events
    switch (event.event_type)
    {
    case EVENT_T_TIMER:
        if (!me->isInCombat())
            return false;

        //Repeat Timers
        holder.UpdateRepeatTimer(me, event.timer.repeatMin, event.timer.repeatMax);
        break;
    case EVENT_T_TIMER_OOC:
        if (me->isInCombat())
            return false;

        //Repeat Timers
        holder.UpdateRepeatTimer(me, event.timer.repeatMin, event.timer.repeatMax);
        break;
    case EVENT_T_HP:
    {
        if (!me->isInCombat() || !me->GetMaxHealth())
            return false;

        uint32 perc = uint32(me->GetHealthPct());

        if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin)
            return false;

        //Repeat Timers
        holder.UpdateRepeatTimer(me, event.percent_range.repeatMin, event.percent_range.repeatMax);
        break;
    }
    case EVENT_T_MANA:
    {
        if (!me->isInCombat() || !me->GetMaxPower(POWER_MANA))
            return false;

        uint32 perc = (me->GetPower(POWER_MANA)*100) / me->GetMaxPower(POWER_MANA);

        if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin)
            return false;

        //Repeat Timers
        holder.UpdateRepeatTimer(me, event.percent_range.repeatMin, event.percent_range.repeatMax);
        break;
    }
    case EVENT_T_AGGRO:
        break;
    case EVENT_T_KILL:
        //Repeat Timers
        holder.UpdateRepeatTimer(me, event.kill.repeatMin, event.kill.repeatMax);
        break;
    case EVENT_T_DEATH:
    case EVENT_T_EVADE:
        break;
    case EVENT_T_SPELLHIT:
        //Spell hit is special case, param1 and param2 handled within CreatureEventAI::SpellHit

        //Repeat Timers
        holder.UpdateRepeatTimer(me, event.spell_hit.repeatMin, event.spell_hit.repeatMax);
        break;
    case EVENT_T_RANGE:
        //Repeat Timers
        holder.UpdateRepeatTimer(me, event.range.repeatMin, event.range.repeatMax);
        break;
    case EVENT_T_OOC_LOS:
        //Repeat Timers
        holder.UpdateRepeatTimer(me, event.ooc_los.repeatMin, event.ooc_los.repeatMax);
        break;
    case EVENT_T_RESET:
    case EVENT_T_SPAWNED:
        break;
    case EVENT_T_TARGET_HP:
    {
        if (!me->isInCombat() || !me->getVictim() || !me->getVictim()->GetMaxHealth())
            return false;

        uint32 perc = uint32(me->getVictim()->GetHealthPct());

        if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin)
            return false;

        //Repeat Timers
        holder.UpdateRepeatTimer(me, event.percent_range.repeatMin, event.percent_range.repeatMax);
        break;
    }
    case EVENT_T_TARGET_CASTING:
        if (!me->isInCombat() || !me->getVictim() || !me->getVictim()->IsNonMeleeSpellCasted(false, false, true))
            return false;

        //Repeat Timers
        holder.UpdateRepeatTimer(me, event.target_casting.repeatMin, event.target_casting.repeatMax);
        break;
    case EVENT_T_FRIENDLY_HP:
    {
        if (!me->isInCombat())
            return false;

        Unit* unit = DoSelectLowestHpFriendly((float)event.friendly_hp.radius, event.friendly_hp.hpDeficit);
        if (!unit)
            return false;

        actionInvoker = unit;

        //Repeat Timers
        holder.UpdateRepeatTimer(me, event.friendly_hp.repeatMin, event.friendly_hp.repeatMax);
        break;
    }
    case EVENT_T_FRIENDLY_IS_CC:
    {
        if (!me->isInCombat())
            return false;

        std::list<Creature*> pList;
        DoFindFriendlyCC(pList, (float)event.friendly_is_cc.radius);

        //List is empty
        if (pList.empty())
            return false;

        //We don't really care about the whole list, just return first available
        actionInvoker = *(pList.begin());

        //Repeat Timers
        holder.UpdateRepeatTimer(me, event.friendly_is_cc.repeatMin, event.friendly_is_cc.repeatMax);
        break;
    }
    case EVENT_T_FRIENDLY_MISSING_BUFF:
    {
        std::list<Creature*> pList;
        DoFindFriendlyMissingBuff(pList, (float)event.friendly_buff.radius, event.friendly_buff.spellId);

        //List is empty
        if (pList.empty())
            return false;

        //We don't really care about the whole list, just return first available
        actionInvoker = *(pList.begin());

        //Repeat Timers
        holder.UpdateRepeatTimer(me, event.friendly_buff.repeatMin, event.friendly_buff.repeatMax);
        break;
    }
    case EVENT_T_SUMMONED_UNIT:
    {
        //Prevent event from occuring on no unit or non creatures
        if (!actionInvoker || actionInvoker->GetTypeId() != TYPEID_UNIT)
            return false;

        //Creature id doesn't match up
        if (actionInvoker->ToCreature()->GetEntry() != event.summon_unit.creatureId)
            return false;

        //Repeat Timers
        holder.UpdateRepeatTimer(me, event.summon_unit.repeatMin, event.summon_unit.repeatMax);
        break;
    }
    case EVENT_T_TARGET_MANA:
    {
        if (!me->isInCombat() || !me->getVictim() || !me->getVictim()->GetMaxPower(POWER_MANA))
            return false;

        uint32 perc = (me->getVictim()->GetPower(POWER_MANA)*100) / me->getVictim()->GetMaxPower(POWER_MANA);

        if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin)
            return false;

        //Repeat Timers
        holder.UpdateRepeatTimer(me, event.percent_range.repeatMin, event.percent_range.repeatMax);
        break;
    }
    case EVENT_T_REACHED_HOME:
    case EVENT_T_RECEIVE_EMOTE:
        break;
    case EVENT_T_BUFFED:
    {
        //Note: checked only aura for effect 0, if need check aura for effect 1/2 then
        // possible way: pack in event.buffed.amount 2 uint16 (ammount+effectIdx)
        Aura const* aura = me->GetAura(event.buffed.spellId);
        if (!aura || aura->GetStackAmount() < event.buffed.amount)
            return false;

        //Repeat Timers
        holder.UpdateRepeatTimer(me, event.buffed.repeatMin, event.buffed.repeatMax);
        break;
    }
    case EVENT_T_TARGET_BUFFED:
    {
        //Prevent event from occuring on no unit
        if (!actionInvoker)
            return false;

        //Note: checked only aura for effect 0, if need check aura for effect 1/2 then
        // possible way: pack in event.buffed.amount 2 uint16 (ammount+effectIdx)
        Aura const* aura = actionInvoker->GetAura(event.buffed.spellId);
        if (!aura || aura->GetStackAmount() < event.buffed.amount)
            return false;

        //Repeat Timers
        holder.UpdateRepeatTimer(me, event.buffed.repeatMin, event.buffed.repeatMax);
        break;
    }
    default:
        sLog->outErrorDb("CreatureEventAI: Creature %u using Event %u has invalid Event Type(%u), missing from ProcessEvent() Switch.", me->GetEntry(), holder.Event.event_id, holder.Event.event_type);
        break;
    }

    //Disable non-repeatable events
    if (!(holder.Event.event_flags & EFLAG_REPEATABLE))
        holder.Enabled = false;

    //Store random here so that all random actions match up
    uint32 rnd = rand();

    //Return if chance for event is not met
    if (holder.Event.event_chance <= rnd % 100)
        return false;

    //Process actions
    for (uint8 j = 0; j < MAX_ACTIONS; ++j)
        ProcessAction(holder.Event.action[j], rnd, holder.Event.event_id, actionInvoker);

    return true;
}
bool CEditCategoryBuilder::Build(CWholePage* pPage)
{
	CCategory	Category(m_InputContext); // holds the hierarchy information from the given nodeid
	CEditCategory EditCategory(m_InputContext); //holds the information
	CUser*		pViewer = NULL;
	bool		bSuccess = true;

	if(!InitPage(pPage, "EDITCATEGORY",true))
	{
		return false;
	}

	// get the viewing user
	pViewer = m_InputContext.GetCurrentUser();

	
		bool bActionProcessed = false;

		//Where in the hierarchy we will display from
		int iDestinationNodeID = 0;
		
		//found out if there is a nodeid
		int iNodeID =0;
		if (m_InputContext.ParamExists("nodeid"))
		{
			iNodeID = m_InputContext.GetParamInt("nodeid");
		}
		
		//find out if there is an action
		CTDVString sAction;
		bool bActionExists = false;
		if(m_InputContext.ParamExists("action"))
		{
			bActionExists = m_InputContext.GetParamString("action",sAction);
		}
		
		//TagItemId can be provided as follows...
		//1. activenode parameter - depreciated.
		//2. tagitemid parameter if in tag mode.
		int iTagItemId = 0;
		if(m_InputContext.ParamExists("activenode"))
		{
			//ActiveNode parameter actually refers to the Id of the item to tag.
			iTagItemId = m_InputContext.GetParamInt("activenode");
		}
		else if ( m_InputContext.ParamExists("tagmode") )
		{
			iTagItemId = m_InputContext.GetParamInt("tagitemid");
		}
		
		
		//if there is no activeNode and no action then we are doing simple navigation
		if ( !iTagItemId  && !bActionExists && (iNodeID >=0))
		{
			bSuccess = bSuccess && EditCategory.Initialise(m_InputContext.GetSiteID());
		}
		else if (bActionExists && bSuccess)
		{	
			//there is something to do so let EditCategory deal with it and find out where it wants to display the hierarchy from 
			bSuccess = bSuccess && EditCategory.Initialise(m_InputContext.GetSiteID());
			bSuccess = ProcessAction(sAction,iTagItemId,iNodeID,iDestinationNodeID,&EditCategory,pPage,bActionProcessed);
				
		}
		else
		{
			bSuccess = false;
		}

		if(bSuccess)
		{
			bSuccess = bSuccess && Category.InitialiseViaNodeID(iDestinationNodeID, m_InputContext.GetSiteID());
			int h2g2ID = Category.Geth2g2ID();
			bSuccess = bSuccess && EditCategory.AddInside("EDITCATEGORY",&Category);

			if (h2g2ID > 0)
			{
				CGuideEntry GuideEntry(m_InputContext);
				GuideEntry.Initialise(h2g2ID, m_InputContext.GetSiteID(), pViewer, true, true, true, true);
				EditCategory.AddInside("HIERARCHYDETAILS", &GuideEntry);
			}

			// Check to see if we're in tagmode or category mode
			if(bSuccess)
			{
				// Check to see if we're in tag mode.
				if (m_InputContext.ParamExists("tagmode"))
				{
					// Get the TagitemID and the TagType from the url
					int iTagItemID = m_InputContext.GetParamInt("tagitemid");
					CTDVString sTagItemType;
					m_InputContext.GetParamString("tagitemtype",sTagItemType);
					int iTagMode = m_InputContext.GetParamInt("tagmode");
					int iSiteID = m_InputContext.GetSiteID();
					CUser* pCurrentUser = m_InputContext.GetCurrentUser();

					// Now put it into the XML
					CTDVString sTagInfo;
					sTagInfo << "<TAGINFO MODE='" << iTagMode << "'";
					
					// Check to see if we've been given the TagItemID
					if (iTagItemID == 0)
					{
						// No, just do the default thing by putting the tagmose into the xml
						sTagInfo << "></TAGINFO>";
						bSuccess = bSuccess && EditCategory.AddInside("HIERARCHYDETAILS",sTagInfo);
					}
					else
					{
						// We have! it to the XML and then get the tagitem details as well!
						sTagInfo << " TAGITEMID='" << iTagItemID << "' TAGITEMTYPE='" << sTagItemType << "'></TAGINFO>";
						bSuccess = bSuccess && EditCategory.AddInside("HIERARCHYDETAILS",sTagInfo);

						// Now get the tag items details
						CTagItem TagItem(m_InputContext);
						bool bOk = false;
						if (sTagItemType.CompareText("USER"))
						{
							bOk = TagItem.InitialiseFromUserId(iTagItemID,iSiteID,pCurrentUser);
						}
						else if (sTagItemType.CompareText("THREAD"))
						{
							bOk = TagItem.InitialiseFromThreadId(iTagItemID,iSiteID,pCurrentUser);
						}
						else
						{
							bOk = TagItem.InitialiseItem(iTagItemID,m_InputContext.GetParamInt("tagitemtype"),iSiteID,pCurrentUser);
						}

						if (!bOk)
						{
							// Get the error from the object
							bSuccess = bSuccess && EditCategory.AddInside("HIERARCHYDETAILS/TAGINFO",TagItem.GetLastErrorAsXMLString());
						}

						//Get taginfo
						CTDVString sDetailsXML;
						TagItem.GetItemDetailsXML(sDetailsXML);
						bSuccess = bSuccess && EditCategory.AddInside("HIERARCHYDETAILS/TAGINFO",sDetailsXML);

						// Get all the nodes that the item is currently tagged to.
						if (bOk && TagItem.GetAllNodesTaggedForItem())
						{
							// Put the results into the XML
							bSuccess = bSuccess && EditCategory.AddInside("HIERARCHYDETAILS/TAGINFO",&TagItem);
						}
						else
						{
							// Get the error from the object
							bSuccess = bSuccess && EditCategory.AddInside("HIERARCHYDETAILS/TAGINFO",TagItem.GetLastErrorAsXMLString());
						}

						// Get all the nodes that the user has ever tagged to.
						if (bOk && TagItem.GetNodesUserHasTaggedTo())
						{
							// Put the results into the XML
							bSuccess = bSuccess && EditCategory.AddInside("HIERARCHYDETAILS/TAGINFO",&TagItem);
						}
						else
						{
							// Get the error from the object
							bSuccess = bSuccess && EditCategory.AddInside("HIERARCHYDETAILS/TAGINFO",TagItem.GetLastErrorAsXMLString());
						}
					}
				}
				
				// Check to see if we're adding category nodes to cat lists
				if (m_InputContext.ParamExists("catlistid"))
				{
					CTDVString sCatList, sGUID;
					m_InputContext.GetParamString("catlistid",sGUID);
					sCatList << "<CATEGORYLIST MODE='1' GUID='" << sGUID << "'/>";
					bSuccess = bSuccess && EditCategory.AddInside("HIERARCHYDETAILS",sCatList);
				}
			}
		}
		
		//add the editcategory to the wholepage
		if (bSuccess)
		{
			bSuccess = bSuccess && pPage->AddInside("H2G2",&EditCategory);
		}

		{//add search functionality 								
		// Get the TagitemID and the TagType from the url
		int iTagItemID = m_InputContext.GetParamInt("tagitemid");
		CTDVString sTagItemType;
		m_InputContext.GetParamString("tagitemtype",sTagItemType);
		int iTagMode = m_InputContext.GetParamInt("tagmode");
		int iSiteID = m_InputContext.GetSiteID();
		int iActiveNode = m_InputContext.GetParamInt("activenode");
		CUser* pCurrentUser = m_InputContext.GetCurrentUser();

		CTDVString sActiveNode(iActiveNode), sNodeID(iNodeID), sTagMode(iTagMode), sTagItemID(iTagItemID);
		bSuccess = bSuccess && pPage->AddInside("H2G2","<SEARCH></SEARCH>");
		bSuccess = bSuccess && pPage->AddInside("H2G2/SEARCH", "<ACTION>" + sAction + "</ACTION>");
		bSuccess = bSuccess && pPage->AddInside("H2G2/SEARCH", "<NODEID>" + sNodeID + "</NODEID>");
		bSuccess = bSuccess && pPage->AddInside("H2G2/SEARCH", "<ACTIVENODE>" + sActiveNode + "</ACTIVENODE>");
		bSuccess = bSuccess && pPage->AddInside("H2G2/SEARCH", "<TAGITEMID>" + sTagItemID + "</TAGITEMID>");
		bSuccess = bSuccess && pPage->AddInside("H2G2/SEARCH", "<TAGMODE>" + sTagMode + "</TAGMODE>");
		bSuccess = bSuccess && pPage->AddInside("H2G2/SEARCH", "<TAGITEMTYPE>" + sTagItemType + "</TAGITEMTYPE>");

		if ( m_InputContext.ParamExists("searchstring")  )
		{
			CTDVString sSearchString = "";
			CTDVString sSearchType   = "";
			bool bGotSearchString = m_InputContext.GetParamString("searchstring", sSearchString);

			//search type is always assumed to be hierarchial
			if ( bGotSearchString)
			{						
				bool bSearchItemsFound = false;
				//detect postcode searches
				if ( m_InputContext.GetAllowPostCodesInSearch() > 0  )
				{
					//detect if string is a postcode
					CPostCodeParser oPostCodeParser ;		
					if (oPostCodeParser.IsPostCode(sSearchString))
					{			
						CTDVString sActualPostCode ="";
						CTDVString sActualPostCodeXML = "";
						int iNode=0;
						CNotice oNotice(m_InputContext);

						int nRes =  oNotice.GetDetailsForPostCodeArea(sSearchString, iSiteID, iNode, sActualPostCode, sActualPostCodeXML);
						if (nRes == CNotice::PR_REQUESTOK)
						{
							if (iNode)
							{
								CTDVString sCategoryName;						
								CCategory oCategory(m_InputContext);		
								if ( oCategory.GetHierarchyName(iNode, sCategoryName) == false)
								{
									SetDNALastError("CEditCategoryBuilder::Build", "CatgeoryNotFound", "Could not be found Category's Name");
									bSuccess = bSuccess && pPage->AddInside("H2G2",GetLastErrorAsXMLString());
									return false;
								}

								bSuccess = bSuccess && pPage->AddInside("H2G2/SEARCH","<SEARCHRESULTS TYPE=\"HIERARCHY\"></SEARCHRESULTS>");
								bSuccess = bSuccess && pPage->AddInside("H2G2/SEARCH/SEARCHRESULTS", "<ISPOSTCODE>1</FROMPOSTCODE>");
								bSuccess = bSuccess && pPage->AddInside("H2G2/SEARCH/SEARCHRESULTS", "<SEARCHTERM>" + sActualPostCode + "</SEARCHTERM>");


								CTDVString sSite(m_InputContext.GetSiteID( ));
								CTDVString sCatgeory(iNode);
								CTDVString sXML =  "";
								sXML += "<HIERARCHYRESULT>";
								sXML += "<NODEID>" + sCatgeory + "</NODEID>"; 
								sXML += "<DISPLAYNAME>" + sCategoryName + "</DISPLAYNAME>"; 
								sXML += "<SITEID>" + sSite + "</SITEID>"; 
								sXML += "</HIERARCHYRESULT>";
								bSuccess = bSuccess && pPage->AddInside("SEARCH/SEARCHRESULTS", sXML);

								bSearchItemsFound = true;
							}
						}
						else if ( nRes == CNotice::PR_POSTCODENOTFOUND)
						{
							SetDNALastError("CEditCategoryBuilder::Build", "PostcodeNotFound", sSearchString + " could not be found");
							bSuccess = bSuccess && pPage->AddInside("H2G2",GetLastErrorAsXMLString());
							//return true;
						}
						else if (nRes == CNotice::PR_REQUESTTIMEOUT)
						{
							SetDNALastError("CEditCategoryBuilder::Build", "RequestTimedOut", "Request timed out");
							bSuccess = bSuccess && pPage->AddInside("H2G2",GetLastErrorAsXMLString());
							//return true;
						}
					}
					else if ( oPostCodeParser.IsCloseMatch(sSearchString) )
					{
						SetDNALastError("CEditCategoryBuilder::Build", "PostCodeError", sSearchString + " looks like a post code, but it is invalid");
						bSuccess = bSuccess && pPage->AddInside("H2G2",GetLastErrorAsXMLString());
						//return true;
					}
				}
				
				if ( bSearchItemsFound == false)
				{
					int iSkip = m_InputContext.GetParamInt("skip");
					int iShow = m_InputContext.GetParamInt("show");
					if (iShow == 0)
					{
						// default case... show 20 search results at a time
						iShow = 20;
					}

					
					CSearch Search(m_InputContext);
					Search.InitialiseHierarchySearch(sSearchString,iSiteID,iSkip,iShow);
					
					//Add Search results to page.
					bSuccess = bSuccess && pPage->AddInside("H2G2/SEARCH", &Search);
				}
			}					
		}
	}
		
	return bSuccess;
}
Exemple #14
0
bool GuardianAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pActionInvoker, Creature* pAIEventSender /*=nullptr*/)
{
    if (!pHolder.Enabled || pHolder.Time)
        return false;

    // Check the inverse phase mask (event doesn't trigger if current phase bit is set in mask)
    if (pHolder.Event.event_inverse_phase_mask & (1 << m_Phase))
    {
        if (!IsTimerBasedEvent(pHolder.Event.event_type))
            DEBUG_FILTER_LOG(LOG_FILTER_EVENT_AI_DEV, "CreatureEventAI: Event %u skipped because of phasemask %u. Current phase %u", pHolder.Event.event_id, pHolder.Event.event_inverse_phase_mask, m_Phase);
        return false;
    }

    if (!IsTimerBasedEvent(pHolder.Event.event_type))
        LOG_PROCESS_EVENT;

    CreatureEventAI_Event const& event = pHolder.Event;

    // Check event conditions based on the event type, also reset events
    switch (event.event_type)
    {
        case EVENT_T_FRIENDLY_HP:
        {
            Unit* pUnit = DoSelectLowestHpFriendly((float)event.friendly_hp.radius, event.friendly_hp.hpDeficit, false);
            if (!pUnit)
                return false;

            pActionInvoker = pUnit;

            LOG_PROCESS_EVENT;
            // Repeat Timers
            pHolder.UpdateRepeatTimer(m_creature, event.friendly_hp.repeatMin, event.friendly_hp.repeatMax);
            break;
        }
        default:
            return CreatureEventAI::ProcessEvent(pHolder, pActionInvoker, pAIEventSender);
    }

    // Disable non-repeatable events
    if (!(pHolder.Event.event_flags & EFLAG_REPEATABLE))
        pHolder.Enabled = false;

    // Store random here so that all random actions match up
    uint32 rnd = rand();

    // Return if chance for event is not met
    if (pHolder.Event.event_chance <= rnd % 100)
        return false;

    // Process actions, normal case
    if (!(pHolder.Event.event_flags & EFLAG_RANDOM_ACTION))
    {
        for (uint32 j = 0; j < MAX_ACTIONS; ++j)
            ProcessAction(pHolder.Event.action[j], rnd, pHolder.Event.event_id, pActionInvoker, pAIEventSender);
    }
    // Process actions, random case
    else
    {
        // amount of real actions
        uint32 count = 0;
        for (uint32 j = 0; j < MAX_ACTIONS; ++j)
            if (pHolder.Event.action[j].type != ACTION_T_NONE)
                ++count;

        if (count)
        {
            // select action number from found amount
            uint32 idx = rnd % count;

            // find selected action, skipping not used
            uint32 j = 0;
            for (; ; ++j)
            {
                if (pHolder.Event.action[j].type != ACTION_T_NONE)
                {
                    if (!idx)
                        break;
                    --idx;
                }
            }

            ProcessAction(pHolder.Event.action[j], rnd, pHolder.Event.event_id, pActionInvoker, pAIEventSender);
        }
    }
    return true;
}
void RPG_ActionHandler::ProcessAction(RPG_ActionData const& actionData, bool const forceAction /*= false*/)
{
  // if we're already doing the requested move, ignore the call except to update flags or interaction entities.
  if (actionData.m_Action == m_activeAction.m_Action)
  {
    // same move, updated flags
    if (actionData.m_Action != AT_None && actionData.m_flags != m_activeAction.m_flags)
    {
      m_activeAction.m_flags = actionData.m_flags;
      //@todo: if this is happening on the authoritative server, replicate this flag change to clients.
      if (m_Actions[actionData.m_Action])
      {
        m_Actions[actionData.m_Action]->UpdateFlags(actionData.m_flags);
      }
    }

    // same move, updated interaction entity
    if(actionData.m_interactionEntity != m_activeAction.m_interactionEntity ||
        !actionData.m_interactionPosition.isIdentical(m_activeAction.m_interactionPosition))
    {
      m_activeAction.m_interactionEntity = actionData.m_interactionEntity;
      m_activeAction.m_interactionPosition = actionData.m_interactionPosition;

      if(m_Actions[actionData.m_Action])
      {
        m_Actions[actionData.m_Action]->UpdateInteraction(actionData.m_interactionEntity, actionData.m_interactionPosition);

        // clear the pending action, as enough data has changed for the pending action to probably not be the desired behavior.
        m_pendingAction.Clear();
      }
    }

    // clear the pending action if this was forced
    if(forceAction)
    {
      m_pendingAction.Clear();
    }

    // no further action required, since this isn't a new move.
    return;
  }

  // if we're chaining from an action that needs to complete first, defer this action
  if (m_endingAction)
  {
    m_pendingAction = actionData;
    return;
  }

  // verify that we can do this move
  if (actionData.m_Action != AT_None && !forceAction && !m_chainingAction && !CanPerformAction(actionData.m_Action))
  {
    Vision::Error.Warning("Cannot perform requested Action.");
    return;
  }

  // ready to go.
  m_previousAction = m_activeAction;

  // stop the previous action, if any
  if (m_activeAction.m_Action != AT_None)
  {
    m_endingAction = true;
    m_activeAction.m_Action = AT_None;
    RPG_ActionType_e nextAction = actionData.m_Action;
    if (nextAction == AT_None && m_pendingAction.m_Action != AT_None)
    {
      nextAction = m_pendingAction.m_Action;
    }
    CleanUpAction(m_previousAction.m_Action, nextAction);
    m_endingAction = false;
  }

  // if we need to start a pending action, do it now
  if (actionData.m_Action == AT_None && m_pendingAction.m_Action != AT_None)
  {
    // Recursively Process the pending action if one exists.
    
    m_chainingAction = true;
    m_activeAction.m_Action = m_previousAction.m_Action;  // restore this value, since the pending action call will need it.
    ProcessAction(m_pendingAction);
    m_chainingAction = false;
    
    if (m_activeAction.m_Action == m_pendingAction.m_Action)
    {
      m_pendingAction.Clear();
      return;
    }
  }

  // set the new Action
  m_activeAction = actionData;

  // @todo: Once the network branch is in, replicate these values.
  // - m_replicatedAction = m_activeAction;
  // - force net update

  if (m_activeAction.m_Action != AT_None)
  {
    StartAction(m_activeAction.m_Action, m_previousAction.m_Action, forceAction, m_activeAction.m_interactionEntity, m_activeAction.m_interactionPosition, m_activeAction.m_flags);

    // if this was a forced action, clear any pending action, as this was an interrupt of the current action
    if (forceAction)
    {
      m_pendingAction.Clear();
    }
  }
}