bool RlvObject::removeCommand(const RlvCommand& rlvCmd) { RLV_ASSERT(RLV_TYPE_REMOVE == rlvCmd.getParamType()); for (rlv_command_list_t::iterator itCmd = m_Commands.begin(); itCmd != m_Commands.end(); ++itCmd) { //if (*itCmd == rlvCmd) <- commands will never be equal since one is an add and the other is a remove *rolls eyes* if ( (itCmd->getBehaviour() == rlvCmd.getBehaviour()) && (itCmd->getOption() == rlvCmd.getOption()) && (itCmd->isStrict() == rlvCmd.isStrict() ) ) { m_Commands.erase(itCmd); return true; } } return false; // Command was never added so nothing to remove now }
bool RlvObject::addCommand(const RlvCommand& rlvCmd) { RLV_ASSERT(RLV_TYPE_ADD == rlvCmd.getParamType()); // Don't add duplicate commands for this object (ie @detach=n followed by another @detach=n later on) for (rlv_command_list_t::iterator itCmd = m_Commands.begin(); itCmd != m_Commands.end(); ++itCmd) { if ( (itCmd->getBehaviour() == rlvCmd.getBehaviour()) && (itCmd->getOption() == rlvCmd.getOption()) && (itCmd->isStrict() == rlvCmd.isStrict() ) ) { return false; } } // Now that we know it's not a duplicate, add it to the end of the list m_Commands.push_back(rlvCmd); return true; }
// Checked: 2009-12-23 (RLVa-1.1.0k) | Modified: RLVa-1.1.0k bool RlvExtGetSet::processCommand(const RlvCommand& rlvCmd, ERlvCmdRet& eRet) { std::string strBehaviour = rlvCmd.getBehaviour(), strGetSet, strSetting; int idxSetting = strBehaviour.find('_'); if ( (strBehaviour.length() >= 6) && (-1 != idxSetting) && ((int)strBehaviour.length() > idxSetting + 1) ) { strSetting = strBehaviour.substr(idxSetting + 1); strBehaviour.erase(idxSetting); // Get rid of "_<setting>" strGetSet = strBehaviour.substr(0, 3); strBehaviour.erase(0, 3); // Get rid of get/set if ("debug" == strBehaviour) { if ( ("get" == strGetSet) && (RLV_TYPE_REPLY == rlvCmd.getParamType()) ) { RlvUtil::sendChatReply(rlvCmd.getParam(), onGetDebug(strSetting)); eRet = RLV_RET_SUCCESS; return true; } else if ( ("set" == strGetSet) && (RLV_TYPE_FORCE == rlvCmd.getParamType()) ) { if (!gRlvHandler.hasBehaviourExcept(RLV_BHVR_SETDEBUG, rlvCmd.getObjectID())) eRet = onSetDebug(strSetting, rlvCmd.getOption()); else eRet = RLV_RET_FAILED_LOCK; return true; } } else if ("env" == strBehaviour) { if ( ("get" == strGetSet) && (RLV_TYPE_REPLY == rlvCmd.getParamType()) ) { RlvUtil::sendChatReply(rlvCmd.getParam(), onGetEnv(strSetting)); eRet = RLV_RET_SUCCESS; return true; } else if ( ("set" == strGetSet) && (RLV_TYPE_FORCE == rlvCmd.getParamType()) ) { if (!gRlvHandler.hasBehaviourExcept(RLV_BHVR_SETENV, rlvCmd.getObjectID())) eRet = onSetEnv(strSetting, rlvCmd.getOption()); else eRet = RLV_RET_FAILED_LOCK; return true; } } } else if ("setrot" == rlvCmd.getBehaviour()) { // NOTE: if <option> is invalid (or missing) altogether then RLV-1.17 will rotate to 0.0 (which is actually PI / 4) F32 nAngle = 0.0f; if (LLStringUtil::convertToF32(rlvCmd.getOption(), nAngle)) { nAngle = RLV_SETROT_OFFSET - nAngle; gAgent.startCameraAnimation(); LLVector3 at(LLVector3::x_axis); at.rotVec(nAngle, LLVector3::z_axis); at.normalize(); gAgent.resetAxes(at); eRet = RLV_RET_SUCCESS; } else { eRet = RLV_RET_FAILED_OPTION; } return true; } return false; }