Пример #1
0
void CRecastContainer::Add(RECASTTYPE type, uint16 id, uint32 duration, uint32 chargeTime, uint8 maxCharges)
{
    Recast_t* recast = GetRecast(type, id);

    if( recast == NULL)
    {
        Recast_t* newRecast = new Recast_t;
        newRecast->ID = id;
        newRecast->TimeStamp = gettick();
        newRecast->RecastTime = duration;
        newRecast->chargeTime = chargeTime;
        newRecast->maxCharges = maxCharges;

        GetRecastList(type)->push_back(newRecast);
    }
    else
    {
        if (chargeTime == 0)
        {
            recast->TimeStamp = gettick();
            recast->RecastTime = duration;
        }
        else
        {
            if (recast->RecastTime == 0)
            {
                recast->TimeStamp = gettick();
            }
            recast->RecastTime += chargeTime * 1000;
            recast->chargeTime = chargeTime;
            recast->maxCharges = maxCharges;
        }
    }
}
Пример #2
0
void CRecastContainer::Del(RECASTTYPE type, uint16 id)
{
    RecastList_t* PRecastList = GetRecastList(type);

    if (type == RECAST_ABILITY)
    {
        if (auto recast = GetRecast(RECAST_ABILITY, id))
        {
            recast->RecastTime = 0;
        }
    }
    else
    {
        PRecastList->erase(std::remove_if(PRecastList->begin(), PRecastList->end(), [&id](auto& recast)
        {
            return recast.ID == id;
        }), PRecastList->end());
    }
}
Пример #3
0
Recast_t* CRecastContainer::Load(RECASTTYPE type, uint16 id, uint32 duration, uint32 chargeTime, uint8 maxCharges)
{
    Recast_t* recast = GetRecast(type, id);

    if (recast == nullptr)
    {
        GetRecastList(type)->push_back({id, time(nullptr), duration, chargeTime, maxCharges});
        return &GetRecastList(type)->back();
    }
    else
    {
        if (chargeTime)
        {
            recast->chargeTime = chargeTime;
        }
        if (maxCharges)
        {
            recast->maxCharges = maxCharges;
        }
        if (recast->chargeTime == 0)
        {
            recast->TimeStamp = time(nullptr);
            recast->RecastTime = duration;
        }
        else
        {
            if (recast->RecastTime == 0)
            {
                recast->TimeStamp = time(nullptr);
            }
            else if (recast->RecastTime + duration > recast->chargeTime * recast->maxCharges)
            {
                auto diff = (recast->RecastTime + duration) - (recast->chargeTime * recast->maxCharges);
                recast->TimeStamp += diff;
                duration -= diff;
            }
            recast->RecastTime += duration;
        }
        return recast;
    }
}
Пример #4
0
void CRecastContainer::ResetAbilities()
{
    RecastList_t* PRecastList = GetRecastList(RECAST_ABILITY);

    uint32 timestamp = 0;
    uint32 recastTime = 0;

    Recast_t* twoHour = GetRecast(RECAST_ABILITY, 0);
    if (twoHour != NULL)
    {
        timestamp = twoHour->TimeStamp;
        recastTime = twoHour->RecastTime;
    }
    PRecastList->clear();
    if (twoHour != NULL)
    {
        Recast_t* newTwoHour = new Recast_t;
        newTwoHour->ID = 0;
        newTwoHour->TimeStamp = timestamp;
        newTwoHour->RecastTime = recastTime;
        PRecastList->push_back(newTwoHour);
    }
}
Пример #5
0
void CRecastContainer::ResetAbilities()
{
    RecastList_t* PRecastList = GetRecastList(RECAST_ABILITY);

    uint32 timestamp = 0;
    uint32 recastTime = 0;

    Recast_t* twoHour = GetRecast(RECAST_ABILITY, 0);
    if (twoHour != nullptr)
    {
        timestamp = twoHour->TimeStamp;
        recastTime = twoHour->RecastTime;
    }
    PRecastList->clear();
    if (twoHour != nullptr)
    {
        Recast_t* newTwoHour = new Recast_t;
        newTwoHour->ID = 0;
        newTwoHour->TimeStamp = timestamp;
        newTwoHour->RecastTime = recastTime;
        PRecastList->push_back(newTwoHour);
    }
    Sql_Query(SqlHandle, "DELETE FROM char_recast WHERE charid = %u AND id != 0;", m_PChar->id);
}
Пример #6
0
Recast_t* CRecastContainer::Load(RECASTTYPE type, uint16 id, uint32 duration, uint32 chargeTime, uint8 maxCharges)
{
    Recast_t* recast = GetRecast(type, id);

    if (recast == nullptr)
    {
        Recast_t* newRecast = new Recast_t;
        newRecast->ID = id;
        newRecast->TimeStamp = time(nullptr);
        newRecast->RecastTime = duration;
        newRecast->chargeTime = chargeTime;
        newRecast->maxCharges = maxCharges;

        GetRecastList(type)->push_back(newRecast);
        return newRecast;
    }
    else
    {
        if (chargeTime == 0)
        {
            recast->TimeStamp = time(nullptr);
            recast->RecastTime = duration;
        }
        else
        {
            if (recast->RecastTime == 0)
            {
                recast->TimeStamp = time(nullptr);
            }
            recast->RecastTime += chargeTime;
            recast->chargeTime = chargeTime;
            recast->maxCharges = maxCharges;
        }
        return recast;
    }
}