Exemple #1
0
    void ICharacter::consumeHP (const uint32_t amount)
    {
        if (amount)
        {
            boost::mutex::scoped_lock stats_lock(m_stats_mutex);

            if (m_HP)
            {
                if ( amount > m_HP)
                    m_HP = 0;
                else
                    m_HP -= amount;

                if (!m_HP)
                {
                    stats_lock.unlock();

                    if (!signal_dead.empty())
                        signal_dead(m_UniqueID,m_CurrentPos);

                    boost::lock(m_state_mutex,m_queue_mutex,m_mov_mutex);

                    boost::unique_lock<boost::mutex> stateLock(m_state_mutex,boost::adopt_lock);
                    boost::unique_lock<boost::mutex> queueLock(m_queue_mutex,boost::adopt_lock);
                    boost::unique_lock<boost::mutex> moveLock(m_mov_mutex,boost::adopt_lock);

                    if (m_AttackState != ATTACK_ACTION_STOP)
                    {
                        m_AttackState = ATTACK_ACTION_STOP;

                        if (!signal_state.empty())
                            signal_state(STATE_ATTACK,m_AttackState);
                    }

                    m_StatusState = STATUS_ACTION_DEAD;

                    if (!signal_state.empty())
                        signal_state(STATE_STATUS,m_StatusState);

                    m_QueueSkill = 0;
                    m_QueueTarget = 0;
                    m_CurrentTask = 0;

                    m_NextPos = Coord();
                }
            }
        }
    }
Exemple #2
0
int main(){
	int _l[LC_LEN]; char c[2];

	initLock(_l);

	printf(	"\nSecurity Lock v1.0\n"
			"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n"
			"Make all the lock values %i\n\n"
			"Key: 1-8 turns locks\n"
			"     r Resets the locks\n"
			"     q exits the program\n\n",
			LC_TARG);

	while(!checkLock(_l)) {
		printLock(_l);
		
		do {
			printf("Move < 1-8, r, q >: "); fflush(NULL);
			read(STDIN_FILENO, c, 2);
		} while (!validateInput(c[0]));

		if(c[0] == 'r' || c[0] == 'R') {
			initLock(_l);
			continue;
		}

		moveLock(_l, c[0]-0x30);
	}

	printLock(_l);
	printf("All locks are open!\n");
	printf("Your password is d%kj1//..");


	return EXIT_SUCCESS;
}