diff options
Diffstat (limited to 'src/bindings/scripts/ScriptMgr.cpp')
-rw-r--r-- | src/bindings/scripts/ScriptMgr.cpp | 77 |
1 files changed, 69 insertions, 8 deletions
diff --git a/src/bindings/scripts/ScriptMgr.cpp b/src/bindings/scripts/ScriptMgr.cpp index f6e450283ab..54425873632 100644 --- a/src/bindings/scripts/ScriptMgr.cpp +++ b/src/bindings/scripts/ScriptMgr.cpp @@ -16,7 +16,6 @@ # define _TRINITY_SCRIPT_CONFIG "trinitycore.conf" #endif _TRINITY_SCRIPT_CONFIG -//*** Global data *** int num_sc_scripts; Script *m_scripts[MAX_SCRIPTS]; @@ -48,20 +47,16 @@ enum ChatType // Text Maps UNORDERED_MAP<int32, StringTextData> TextMap; -//*** End Global data *** +// Waypoint lists +std::list<PointMovement> PointMovementList; -//*** EventAI data *** //Event AI structure. Used exclusivly by mob_event_ai.cpp (60 bytes each) std::list<EventAI_Event> EventAI_Event_List; //Event AI summon structure. Used exclusivly by mob_event_ai.cpp. UNORDERED_MAP<uint32, EventAI_Summon> EventAI_Summon_Map; -//Event AI error prevention structure. Used at runtime to prevent error log spam of same creature id. -//UNORDERED_MAP<uint32, EventAI_CreatureError> EventAI_CreatureErrorPreventionList; - uint32 EAI_ErrorLevel; -//*** End EventAI data *** void FillSpellSummary(); void LoadOverridenSQLData(); @@ -858,6 +853,67 @@ void LoadDatabase() outstring_log(""); outstring_log(">> Loaded 0 additional Custom Texts data. DB table `custom_texts` is empty."); } + + // Drop Existing Waypoint list + PointMovementList.clear(); + uint64 uiCreatureCount = 0; + + // Load Waypoints + result = TScriptDB.PQuery("SELECT COUNT(entry) FROM script_waypoint GROUP BY entry"); + if (result) + { + uiCreatureCount = result->GetRowCount(); + delete result; + } + + outstring_log("SD2: Loading Script Waypoints for %u creature(s)...", uiCreatureCount); + + result = TScriptDB.PQuery("SELECT entry, pointid, location_x, location_y, location_z, waittime FROM script_waypoint ORDER BY pointid"); + + if (result) + { + barGoLink bar(result->GetRowCount()); + uint32 uiNodeCount = 0; + + do + { + bar.step(); + Field* pFields = result->Fetch(); + PointMovement pTemp; + + pTemp.m_uiCreatureEntry = pFields[0].GetUInt32(); + pTemp.m_uiPointId = pFields[1].GetUInt32(); + pTemp.m_fX = pFields[2].GetFloat(); + pTemp.m_fY = pFields[3].GetFloat(); + pTemp.m_fZ = pFields[4].GetFloat(); + pTemp.m_uiWaitTime = pFields[5].GetUInt32(); + + CreatureInfo const* pCInfo = GetCreatureTemplateStore(pTemp.m_uiCreatureEntry); + if (!pCInfo) + { + error_db_log("SD2: DB table script_waypoint has waypoint for non-existant creature entry %u", pTemp.m_uiCreatureEntry); + continue; + } + + if (!pCInfo->ScriptID) + error_db_log("SD2: DB table script_waypoint has waypoint for creature entry %u, but creature does not have ScriptName defined and then useless.", pTemp.m_uiCreatureEntry); + + PointMovementList.push_back(pTemp); + ++uiNodeCount; + } while (result->NextRow()); + + delete result; + + outstring_log(""); + outstring_log(">> Loaded %u Script Waypoint nodes.", uiNodeCount); + } + else + { + barGoLink bar(1); + bar.step(); + outstring_log(""); + outstring_log(">> Loaded 0 Script Waypoints. DB table `script_waypoint` is empty."); + } //Gather additional data for EventAI result = TScriptDB.PQuery("SELECT id, position_x, position_y, position_z, orientation, spawntimesecs FROM eventai_summons"); @@ -913,6 +969,12 @@ void LoadDatabase() delete result; } + outstring_log("SD2: Loading EventAI scripts for %u creature(s)...", uiEAICreatureCount); + if (result) + { + uiEAICreatureCount = result->GetRowCount(); + delete result; + } //Gather event data result = TScriptDB.PQuery("SELECT id, creature_id, event_type, event_inverse_phase_mask, event_chance, event_flags, " @@ -1037,7 +1099,6 @@ void LoadDatabase() } break; - case EVENT_T_RANGE: case EVENT_T_FRIENDLY_HP: case EVENT_T_FRIENDLY_IS_CC: { |