Merge pull request #8583 from Gacko/scripttexts

Core/DB: Drop table script_texts
This commit is contained in:
Subv
2012-12-14 18:11:31 -08:00
6 changed files with 2 additions and 237 deletions

View File

@@ -0,0 +1,2 @@
DROP TABLE IF EXISTS `script_texts`;
DROP TABLE IF EXISTS `custom_texts`;

View File

@@ -29,17 +29,6 @@ class Quest;
class Unit;
struct AISpellInfoType;
// Default script texts
enum GeneralScriptTexts
{
DEFAULT_TEXT = -1000000,
EMOTE_GENERIC_FRENZY_KILL = -1000001,
EMOTE_GENERIC_FRENZY = -1000002,
EMOTE_GENERIC_ENRAGED = -1000003,
EMOTE_GENERIC_BERSERK = -1000004,
EMOTE_GENERIC_BERSERK_RAID = -1000005 // RaidBossEmote version of the previous one
};
//Selection method used by SelectTarget
enum SelectAggroTarget
{

View File

@@ -160,83 +160,7 @@ class ScriptRegistry
if (!V) \
return R;
void DoScriptText(int32 iTextEntry, WorldObject* pSource, Unit* target)
{
if (!pSource)
{
sLog->outError(LOG_FILTER_TSCR, "DoScriptText entry %i, invalid Source pointer.", iTextEntry);
return;
}
if (iTextEntry >= 0)
{
sLog->outError(LOG_FILTER_TSCR, "DoScriptText with source entry %u (TypeId=%u, guid=%u) attempts to process text entry %i, but text entry must be negative.", pSource->GetEntry(), pSource->GetTypeId(), pSource->GetGUIDLow(), iTextEntry);
return;
}
const StringTextData* pData = sScriptSystemMgr->GetTextData(iTextEntry);
if (!pData)
{
sLog->outError(LOG_FILTER_TSCR, "DoScriptText with source entry %u (TypeId=%u, guid=%u) could not find text entry %i.", pSource->GetEntry(), pSource->GetTypeId(), pSource->GetGUIDLow(), iTextEntry);
return;
}
sLog->outDebug(LOG_FILTER_TSCR, "DoScriptText: text entry=%i, Sound=%u, Type=%u, Language=%u, Emote=%u", iTextEntry, pData->uiSoundId, pData->uiType, pData->uiLanguage, pData->uiEmote);
if (pData->uiSoundId)
{
if (sSoundEntriesStore.LookupEntry(pData->uiSoundId))
pSource->SendPlaySound(pData->uiSoundId, false);
else
sLog->outError(LOG_FILTER_TSCR, "DoScriptText entry %i tried to process invalid sound id %u.", iTextEntry, pData->uiSoundId);
}
if (pData->uiEmote)
{
if (pSource->GetTypeId() == TYPEID_UNIT || pSource->GetTypeId() == TYPEID_PLAYER)
((Unit*)pSource)->HandleEmoteCommand(pData->uiEmote);
else
sLog->outError(LOG_FILTER_TSCR, "DoScriptText entry %i tried to process emote for invalid TypeId (%u).", iTextEntry, pSource->GetTypeId());
}
switch (pData->uiType)
{
case CHAT_TYPE_SAY:
pSource->MonsterSay(iTextEntry, pData->uiLanguage, target ? target->GetGUID() : 0);
break;
case CHAT_TYPE_YELL:
pSource->MonsterYell(iTextEntry, pData->uiLanguage, target ? target->GetGUID() : 0);
break;
case CHAT_TYPE_TEXT_EMOTE:
pSource->MonsterTextEmote(iTextEntry, target ? target->GetGUID() : 0);
break;
case CHAT_TYPE_BOSS_EMOTE:
pSource->MonsterTextEmote(iTextEntry, target ? target->GetGUID() : 0, true);
break;
case CHAT_TYPE_WHISPER:
{
if (target && target->GetTypeId() == TYPEID_PLAYER)
pSource->MonsterWhisper(iTextEntry, target->GetGUID());
else
sLog->outError(LOG_FILTER_TSCR, "DoScriptText entry %i cannot whisper without target unit (TYPEID_PLAYER).", iTextEntry);
break;
}
case CHAT_TYPE_BOSS_WHISPER:
{
if (target && target->GetTypeId() == TYPEID_PLAYER)
pSource->MonsterWhisper(iTextEntry, target->GetGUID(), true);
else
sLog->outError(LOG_FILTER_TSCR, "DoScriptText entry %i cannot whisper without target unit (TYPEID_PLAYER).", iTextEntry);
break;
}
case CHAT_TYPE_ZONE_YELL:
pSource->MonsterYellToZone(iTextEntry, pData->uiLanguage, target ? target->GetGUID() : 0);
break;
}
}
ScriptMgr::ScriptMgr()
: _scriptCount(0), _scheduledScripts(0)
@@ -299,8 +223,6 @@ void ScriptMgr::Unload()
void ScriptMgr::LoadDatabase()
{
sScriptSystemMgr->LoadScriptTexts();
sScriptSystemMgr->LoadScriptTextsCustom();
sScriptSystemMgr->LoadScriptWaypoints();
}

View File

@@ -69,8 +69,6 @@ struct OutdoorPvPData;
#define VISIBLE_RANGE 166.0f //MAX visible range (size of grid)
// Generic scripting text function.
void DoScriptText(int32 textEntry, WorldObject* pSource, Unit* target = NULL);
/*
TODO: Add more script type classes.

View File

@@ -23,128 +23,6 @@
ScriptPointVector const SystemMgr::_empty;
void SystemMgr::LoadScriptTexts()
{
sLog->outInfo(LOG_FILTER_SERVER_LOADING, "Loading Script Texts...");
LoadTrinityStrings("script_texts", TEXT_SOURCE_RANGE, 1+(TEXT_SOURCE_RANGE*2));
sLog->outInfo(LOG_FILTER_SERVER_LOADING, "Loading Script Texts additional data...");
uint32 oldMSTime = getMSTime();
// 0 1 2 3
QueryResult result = WorldDatabase.Query("SELECT entry, sound, type, language, emote FROM script_texts");
if (!result)
{
sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded 0 additional Script Texts data. DB table `script_texts` is empty.");
return;
}
uint32 uiCount = 0;
do
{
Field* pFields = result->Fetch();
StringTextData temp;
int32 iId = pFields[0].GetInt32();
temp.uiSoundId = pFields[1].GetUInt32();
temp.uiType = pFields[2].GetUInt8();
temp.uiLanguage = pFields[3].GetUInt8();
temp.uiEmote = pFields[4].GetUInt16();
if (iId >= 0)
{
sLog->outError(LOG_FILTER_SQL, "TSCR: Entry %i in table `script_texts` is not a negative value.", iId);
continue;
}
if (iId > TEXT_SOURCE_RANGE || iId <= TEXT_SOURCE_RANGE*2)
{
sLog->outError(LOG_FILTER_SQL, "TSCR: Entry %i in table `script_texts` is out of accepted entry range for table.", iId);
continue;
}
if (temp.uiSoundId)
{
if (!sSoundEntriesStore.LookupEntry(temp.uiSoundId))
sLog->outError(LOG_FILTER_SQL, "TSCR: Entry %i in table `script_texts` has soundId %u but sound does not exist.", iId, temp.uiSoundId);
}
if (!GetLanguageDescByID(temp.uiLanguage))
sLog->outError(LOG_FILTER_SQL, "TSCR: Entry %i in table `script_texts` using Language %u but Language does not exist.", iId, temp.uiLanguage);
if (temp.uiType > CHAT_TYPE_ZONE_YELL)
sLog->outError(LOG_FILTER_SQL, "TSCR: Entry %i in table `script_texts` has Type %u but this Chat Type does not exist.", iId, temp.uiType);
m_mTextDataMap[iId] = temp;
++uiCount;
}
while (result->NextRow());
sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded %u additional Script Texts data in %u ms", uiCount, GetMSTimeDiffToNow(oldMSTime));
}
void SystemMgr::LoadScriptTextsCustom()
{
sLog->outInfo(LOG_FILTER_SERVER_LOADING, "Loading Custom Texts...");
LoadTrinityStrings("custom_texts", TEXT_SOURCE_RANGE*2, 1+(TEXT_SOURCE_RANGE*3));
sLog->outInfo(LOG_FILTER_SERVER_LOADING, "Loading Custom Texts additional data...");
QueryResult result = WorldDatabase.Query("SELECT entry, sound, type, language, emote FROM custom_texts");
if (!result)
{
sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded 0 additional Custom Texts data. DB table `custom_texts` is empty.");
return;
}
uint32 uiCount = 0;
do
{
Field* pFields = result->Fetch();
StringTextData temp;
int32 iId = pFields[0].GetInt32();
temp.uiSoundId = pFields[1].GetUInt32();
temp.uiType = pFields[2].GetUInt8();
temp.uiLanguage = pFields[3].GetUInt8();
temp.uiEmote = pFields[4].GetUInt16();
if (iId >= 0)
{
sLog->outError(LOG_FILTER_SQL, "TSCR: Entry %i in table `custom_texts` is not a negative value.", iId);
continue;
}
if (iId > TEXT_SOURCE_RANGE*2 || iId <= TEXT_SOURCE_RANGE*3)
{
sLog->outError(LOG_FILTER_SQL, "TSCR: Entry %i in table `custom_texts` is out of accepted entry range for table.", iId);
continue;
}
if (temp.uiSoundId)
{
if (!sSoundEntriesStore.LookupEntry(temp.uiSoundId))
sLog->outError(LOG_FILTER_SQL, "TSCR: Entry %i in table `custom_texts` has soundId %u but sound does not exist.", iId, temp.uiSoundId);
}
if (!GetLanguageDescByID(temp.uiLanguage))
sLog->outError(LOG_FILTER_SQL, "TSCR: Entry %i in table `custom_texts` using Language %u but Language does not exist.", iId, temp.uiLanguage);
if (temp.uiType > CHAT_TYPE_ZONE_YELL)
sLog->outError(LOG_FILTER_SQL, "TSCR: Entry %i in table `custom_texts` has Type %u but this Chat Type does not exist.", iId, temp.uiType);
m_mTextDataMap[iId] = temp;
++uiCount;
}
while (result->NextRow());
sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded %u additional Custom Texts data.", uiCount);
}
void SystemMgr::LoadScriptWaypoints()
{
uint32 oldMSTime = getMSTime();

View File

@@ -46,14 +46,6 @@ struct ScriptPointMove
typedef std::vector<ScriptPointMove> ScriptPointVector;
struct StringTextData
{
uint32 uiSoundId;
uint8 uiType;
uint32 uiLanguage;
uint32 uiEmote;
};
class SystemMgr
{
friend class ACE_Singleton<SystemMgr, ACE_Null_Mutex>;
@@ -61,26 +53,11 @@ class SystemMgr
~SystemMgr() {}
public:
//Maps and lists
typedef UNORDERED_MAP<int32, StringTextData> TextDataMap;
typedef UNORDERED_MAP<uint32, ScriptPointVector> PointMoveMap;
//Database
void LoadScriptTexts();
void LoadScriptTextsCustom();
void LoadScriptWaypoints();
//Retrive from storage
StringTextData const* GetTextData(int32 textId) const
{
TextDataMap::const_iterator itr = m_mTextDataMap.find(textId);
if (itr == m_mTextDataMap.end())
return NULL;
return &itr->second;
}
ScriptPointVector const& GetPointMoveList(uint32 creatureEntry) const
{
PointMoveMap::const_iterator itr = m_mPointMoveMap.find(creatureEntry);
@@ -92,7 +69,6 @@ class SystemMgr
}
protected:
TextDataMap m_mTextDataMap; //additional data for text strings
PointMoveMap m_mPointMoveMap; //coordinates for waypoints
private: