// <FS:Ansariel> Centralized voice power level
EVoicePowerLevel LLVoiceClient::getPowerLevel(const LLUUID& id)
{
	F32 power = getCurrentPower(id);
	if (getOnMuteList(id))
	{
		return VPL_MUTED;
	}
	else if (power == 0.f && !getIsSpeaking(id))
	{
		return VPL_PTT_Off;
	}
	else if (power < POWER_LEVEL_0)
	{
		return VPL_PTT_On;
	}
	else if (power < POWER_LEVEL_1)
	{
		return VPL_Level1;
	}
	else if (power < POWER_LEVEL_2)
	{
		return VPL_Level2;
	}
	else
	{
		return VPL_Level3;
	}
}
Ejemplo n.º 2
0
void PlayerStructure::handleUIEvent(BString strCharacterCash, BString strHarvesterCash, UIWindow* window)
{

    PlayerObject* player = window->getOwner();

    if(!player)
    {
        return;
    }

    switch(window->getWindowType())
    {
    case SUI_Window_Deposit_Power:
    {
        strCharacterCash.convert(BSTRType_ANSI);
        BString characterPower = strCharacterCash;

        strHarvesterCash.convert(BSTRType_ANSI);
        BString harvesterPower = strHarvesterCash;

        int32 harvesterPowerDelta = atoi(harvesterPower.getAnsi());

        gStructureManager->deductPower(player,harvesterPowerDelta);
        this->setCurrentPower(getCurrentPower()+harvesterPowerDelta);

        gWorldManager->getDatabase()->executeSqlAsync(0,0,"UPDATE %s.structure_attributes SET value='%u' WHERE structure_id=%" PRIu64 " AND attribute_id=384",gWorldManager->getDatabase()->galaxy(),getCurrentPower(),this->getId());
        
    }
    break;

    case SUI_Window_Pay_Maintenance:
    {
        strCharacterCash.convert(BSTRType_ANSI);
        strHarvesterCash.convert(BSTRType_ANSI);

        Bank* bank = dynamic_cast<Bank*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Bank));
        Inventory* inventory = dynamic_cast<Inventory*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory));
        int32 bankFunds = bank->credits();
        int32 inventoryFunds = inventory->getCredits();

        int32 funds = inventoryFunds + bankFunds;

        int32 characterMoneyDelta = atoi(strCharacterCash.getAnsi()) - funds;
        int32 harvesterMoneyDelta = atoi(strHarvesterCash.getAnsi()) - this->getCurrentMaintenance();

        // the amount transfered must be greater than zero
        if(harvesterMoneyDelta == 0 || characterMoneyDelta == 0)
        {
            return;
        }

        //lets get the money from the bank first
        if((bankFunds +characterMoneyDelta)< 0)
        {
            characterMoneyDelta += bankFunds;
            bankFunds = 0;

            inventoryFunds += characterMoneyDelta;

        }
        else
        {
            bankFunds += characterMoneyDelta;
        }

        if(inventoryFunds < 0)
        {
            return;
        }

        int32 maintenance = this->getCurrentMaintenance() + harvesterMoneyDelta;

        if(maintenance < 0)
        {
            return;
        }

        bank->credits(bankFunds);
        inventory->setCredits(inventoryFunds);

        gWorldManager->getDatabase()->destroyResult(gWorldManager->getDatabase()->executeSynchSql("UPDATE %s.banks SET credits=%u WHERE id=%" PRIu64 "",gWorldManager->getDatabase()->galaxy(),bank->credits(),bank->getId()));
        gWorldManager->getDatabase()->destroyResult(gWorldManager->getDatabase()->executeSynchSql("UPDATE %s.inventories SET credits=%u WHERE id=%" PRIu64 "",gWorldManager->getDatabase()->galaxy(),inventory->getCredits(),inventory->getId()));

        //send the appropriate deltas.
        gMessageLib->sendInventoryCreditsUpdate(player);
        gMessageLib->sendBankCreditsUpdate(player);

        //get the structures conditiondamage and see whether it needs repair
        uint32 damage = this->getDamage();

        if(damage)
        {
            uint32 cost = this->getRepairCost();
            uint32 all = cost*damage;
            if(maintenance <= (int32)all)
            {
                all -= (uint32)maintenance;
                damage = (uint32)(all/cost);
                maintenance = 0;
            }

            if(maintenance > (int32)all)
            {
                maintenance -= (int32)all;
                damage = 0;
            }

            //update the remaining damage in the db
            gWorldManager->getDatabase()->executeSqlAsync(0,0,"UPDATE %s.structures s SET s.condition= %u WHERE s.ID=%" PRIu64 "",gWorldManager->getDatabase()->galaxy(),damage,this->getId());
            
            this->setDamage(damage);

            //Update the structures Condition
            gMessageLib->sendHarvesterCurrentConditionUpdate(this);

        }

        gWorldManager->getDatabase()->executeSqlAsync(0,0,"UPDATE %s.structure_attributes SET value='%u' WHERE structure_id=%" PRIu64 " AND attribute_id=382",gWorldManager->getDatabase()->galaxy(),maintenance,this->getId());
        

        this->setCurrentMaintenance(maintenance);


    }
    break;

    }
}