Ejemplo n.º 1
0
void BSWScriptedAI::_loadFromDB()
{
    // mutex block for process-safe request execute
    ACE_Process_Mutex mMutex = ACE_Process_Mutex("BSW_Lock");

    debug_log("BSW: Loading table of creature %u spell on difficulty %u", m_creature->GetEntry(), currentDifficulty);

    char query[MAX_QUERY_LEN];

    sprintf(query, "SELECT entry, spellID_N10, spellID_N25, spellID_H10, spellID_H25, timerMin_N10, timerMin_N25, timerMin_H10, timerMin_H25, timerMax_N10, timerMax_N25, timerMax_H10, timerMax_H25, data1, data2, data3, data4, locData_x, locData_y, locData_z, varData, StageMask_N, StageMask_H, CastType, isVisualEffect, isBugged, textEntry FROM `boss_spell_table` WHERE entry = %u;\r\n", m_creature->GetEntry());

    mMutex.acquire();
       QueryResult* Result = strSD2Pquery(query);
    mMutex.release();

    if (Result)
    {
        uint32 uiCount = 0;
        do
        {
            BSWRecord m_BSWRecord;

            Field* pFields = Result->Fetch();

            m_BSWRecord.id  = uiCount;

            uint32 m_creatureEntry          = pFields[0].GetUInt32();

            for (uint8 j = 0; j < DIFFICULTY_LEVELS; ++j)
                 m_BSWRecord.m_uiSpellEntry[j]  = pFields[1+j].GetUInt32();

            for (uint8 j = 0; j < DIFFICULTY_LEVELS; ++j)
                 m_BSWRecord.m_uiSpellTimerMin[j]  = pFields[1+DIFFICULTY_LEVELS+j].GetUInt32();

            for (uint8 j = 0; j < DIFFICULTY_LEVELS; ++j)
                 m_BSWRecord.m_uiSpellTimerMax[j]  = pFields[1+DIFFICULTY_LEVELS*2+j].GetUInt32();

            for (uint8 j = 0; j < DIFFICULTY_LEVELS; ++j)
                 m_BSWRecord.m_uiSpellData[j]  = pFields[1+DIFFICULTY_LEVELS*3+j].GetUInt32();

            m_BSWRecord.LocData.x  = pFields[1+DIFFICULTY_LEVELS*4].GetFloat();
            m_BSWRecord.LocData.y  = pFields[2+DIFFICULTY_LEVELS*4].GetFloat();
            m_BSWRecord.LocData.z  = pFields[3+DIFFICULTY_LEVELS*4].GetFloat();

            m_BSWRecord.varData    = pFields[4+DIFFICULTY_LEVELS*4].GetInt32();

            m_BSWRecord.StageMaskN = pFields[5+DIFFICULTY_LEVELS*4].GetUInt32();
            m_BSWRecord.StageMaskH = pFields[6+DIFFICULTY_LEVELS*4].GetUInt32();

            m_BSWRecord.m_CastTarget = _getBSWCastType(pFields[7+DIFFICULTY_LEVELS*4].GetUInt8());

            m_BSWRecord.m_IsVisualEffect = (pFields[8+DIFFICULTY_LEVELS*4].GetUInt8() == 0) ? false : true ;

            m_BSWRecord.m_IsBugged = (pFields[9+DIFFICULTY_LEVELS*4].GetUInt8() == 0) ? false : true ;

            m_BSWRecord.textEntry = pFields[10+DIFFICULTY_LEVELS*4].GetInt32();

            m_BSWRecords.push_back(m_BSWRecord);

            if (m_creatureEntry != m_creature->GetEntry()) error_log("BSW: Unknown error while load boss_spell_table");
               else ++uiCount;
        } while (Result->NextRow());

        delete Result;

        debug_log("BSW: Loaded %u spell data records for creature %u", bossSpellCount(), m_creature->GetEntry());
    }
    else
    {
        error_log("BSW: BSW table for creature %u is empty.", m_creature->GetEntry());
    };
}
Ejemplo n.º 2
0
void BossSpellWorker::LoadSpellTable()
{
    // mutex block for process-safe request execute
    ACE_Process_Mutex mMutex = ACE_Process_Mutex("BSW_Lock");

    debug_log("BSW: Loading table of spells boss  %u difficulty %u", bossID , currentDifficulty);

    char query[MAX_QUERY_LEN];

    sprintf(query, "SELECT entry, spellID_N10, spellID_N25, spellID_H10, spellID_H25, timerMin_N10, timerMin_N25, timerMin_H10, timerMin_H25, timerMax_N10, timerMax_N25, timerMax_H10, timerMax_H25, data1, data2, data3, data4, locData_x, locData_y, locData_z, varData, StageMask_N, StageMask_H, CastType, isVisualEffect, isBugged, textEntry FROM `boss_spell_table` WHERE entry = %u;\r\n", bossID);

    mMutex.acquire();
       QueryResult* Result = strSD2Pquery(query);
    mMutex.release();

    if (Result)
    {
        uint32 uiCount = 0;
        do
        {
            Field* pFields = Result->Fetch();

            m_BossSpell[uiCount].id  = uiCount;

            uint32 bossEntry          = pFields[0].GetUInt32();

            for (uint8 j = 0; j < DIFFICULTY_LEVELS; ++j)
                 m_BossSpell[uiCount].m_uiSpellEntry[j]  = pFields[1+j].GetUInt32();

            for (uint8 j = 0; j < DIFFICULTY_LEVELS; ++j)
                 m_BossSpell[uiCount].m_uiSpellTimerMin[j]  = pFields[1+DIFFICULTY_LEVELS+j].GetUInt32();

            for (uint8 j = 0; j < DIFFICULTY_LEVELS; ++j)
                 m_BossSpell[uiCount].m_uiSpellTimerMax[j]  = pFields[1+DIFFICULTY_LEVELS*2+j].GetUInt32();

            for (uint8 j = 0; j < DIFFICULTY_LEVELS; ++j)
                 m_BossSpell[uiCount].m_uiSpellData[j]  = pFields[1+DIFFICULTY_LEVELS*3+j].GetUInt32();

            m_BossSpell[uiCount].LocData.x  = pFields[1+DIFFICULTY_LEVELS*4].GetFloat();
            m_BossSpell[uiCount].LocData.y  = pFields[2+DIFFICULTY_LEVELS*4].GetFloat();
            m_BossSpell[uiCount].LocData.z  = pFields[3+DIFFICULTY_LEVELS*4].GetFloat();

            m_BossSpell[uiCount].varData    = pFields[4+DIFFICULTY_LEVELS*4].GetInt32();

            m_BossSpell[uiCount].StageMaskN = pFields[5+DIFFICULTY_LEVELS*4].GetUInt32();
            m_BossSpell[uiCount].StageMaskH = pFields[6+DIFFICULTY_LEVELS*4].GetUInt32();

            m_BossSpell[uiCount].m_CastTarget = _getBSWCastType(pFields[7+DIFFICULTY_LEVELS*4].GetUInt8());

            m_BossSpell[uiCount].m_IsVisualEffect = (pFields[8+DIFFICULTY_LEVELS*4].GetUInt8() == 0) ? false : true ;

            m_BossSpell[uiCount].m_IsBugged = (pFields[9+DIFFICULTY_LEVELS*4].GetUInt8() == 0) ? false : true ;

            m_BossSpell[uiCount].textEntry = pFields[10+DIFFICULTY_LEVELS*4].GetInt32();

            if (bossEntry != bossID) error_log("BSW: Unknown error while load boss_spell_table");
               else ++uiCount;

        } while (Result->NextRow());

        _bossSpellCount = uiCount;

        delete Result;

        _fillEmptyDataField();

        debug_log("BSW: Loaded %u boss spell data records for boss %u", uiCount, bossID);
    }
    else
    {
        error_log("BSW: Boss spell table for boss %u is empty.", bossID);
        _bossSpellCount = 0;
    };
}