Esempio n. 1
0
bool EVState::validate(uint32 &reply1, uint32 &reply2, uint64 targetId, uint32 opcode, ObjectControllerCmdProperties*& cmdProperties)
{
    CreatureObject* creature = dynamic_cast<CreatureObject*>(mController->getObject());
	if(creature && cmdProperties)
	{
		//gLogger->log(LogManager::DEBUG, "locomotionMask(%u) & creature->getLocomotion (%u) ==%u",
			//cmdProperties->mLocomotionMask,mController->getLocoValidator(creature->states.getLocomotion()), cmdProperties->mLocomotionMask & creature->states.getLocomotion());
		// skip over commands with no state requirement and check the rest
		if((cmdProperties->mStates != 0) && creature->states.checkStates(cmdProperties->mStates))
		{
			LOG(info) << "EVState::validate :: states Mask" << cmdProperties->mStates << " creature : " << creature->GetStateBitmask();
			reply1 = kCannotDoWhileState;
			reply2 = this->mController->getLowestCommonBit(creature->GetStateBitmask(), cmdProperties->mStates);
			return false;
		}
		//command_table.deny_in_locomotion
		if (cmdProperties->mLocomotionMask !=0 && ((cmdProperties->mLocomotionMask & creature->states.getLocomotion()) != 0))
		{
			LOG(info) << "EVState::validate :: Locomotion Mask" << cmdProperties->mLocomotionMask << " creature : " << creature->states.getLocomotion();
			reply1 = kCannotDoWhileLocomotion;
			reply2 = mController->getPostureValidator(creature->states.getLocomotion());
			return false;
		}
	}
    return true;
}
Esempio n. 2
0
bool PVState::validate(uint32 &reply1, uint32 &reply2, uint64 targetId, uint32 opcode, ObjectControllerCmdProperties*& cmdProperties)
{
    CreatureObject* creature = dynamic_cast<CreatureObject*>(mController->getObject());

    // if this command doesn't require state checks skip it, otherwise check our states
    if(creature && cmdProperties && (cmdProperties->mStates != 0) && (creature->GetStateBitmask() & cmdProperties->mStates) != 0)
    {
		if(creature->states.checkStates(cmdProperties->mStates))
		{
			reply1 = kCannotDoWhileState;
			reply2 = mController->getLowestCommonBit(creature->GetStateBitmask(), cmdProperties->mStates);
			return false;
		}
		if (cmdProperties->mPostureMask !=0 && ((cmdProperties->mPostureMask & creature->GetPosture()) != 0))
		{
			reply1 = kCannotDoWhileLocomotion;
			reply2 = mController->getPostureValidator(creature->states.getLocomotion());
			return false;
		}
    }
    return true;
}