Few changes to *_scripts handling in core.
- Use pointers of most abstract classes possible where applicable. - Don´t use dynamic_cast when casting possibility is already explicitly checked per typeid. - Where applicable use the ToCreature() and ToPlayer() functions for typecasting. - Fix functioning of SCRIPT_COMMAND_CAST_SPELL - Fix possible crash in SCRIPT_COMMAND_KILL - Always include script id in error messages. - Added a few TODO comments. These changesets were merged in from MaNGOS: - [9576] Implement SCRIPT_COMMAND_CREATE_ITEM by NoFantasy - [9577] Implement SCRIPT_COMMAND_DESPAWN_SELF by NoFantasy - [9869] Extend SCRIPT_COMMAND_QUEST_EXPLORED to allow player<->player as source/target by NoFantasy --HG-- branch : trunk
This commit is contained in:
+350
-239
File diff suppressed because it is too large
Load Diff
+20
-2
@@ -4429,11 +4429,11 @@ void ObjectMgr::LoadScripts(ScriptMapMap& scripts, char const* tablename)
|
||||
tmp.o = fields[9].GetFloat();
|
||||
|
||||
// generic command args check
|
||||
switch(tmp.command)
|
||||
switch (tmp.command)
|
||||
{
|
||||
case SCRIPT_COMMAND_TALK:
|
||||
{
|
||||
if (tmp.datalong > 4)
|
||||
if (tmp.datalong > CHAT_TYPE_WHISPER)
|
||||
{
|
||||
sLog.outErrorDb("Table `%s` has invalid talk type (datalong = %u) in SCRIPT_COMMAND_TALK for script id %u",tablename,tmp.datalong,tmp.id);
|
||||
continue;
|
||||
@@ -4631,6 +4631,23 @@ void ObjectMgr::LoadScripts(ScriptMapMap& scripts, char const* tablename)
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SCRIPT_COMMAND_CREATE_ITEM:
|
||||
{
|
||||
if (!GetItemPrototype(tmp.datalong))
|
||||
{
|
||||
sLog.outErrorDb("Table `%s` has nonexistent item (entry: %u) in SCRIPT_COMMAND_CREATE_ITEM for script id %u",
|
||||
tablename, tmp.datalong, tmp.id);
|
||||
continue;
|
||||
}
|
||||
if (!tmp.datalong2)
|
||||
{
|
||||
sLog.outErrorDb("Table `%s` SCRIPT_COMMAND_CREATE_ITEM but amount is %u for script id %u",
|
||||
tablename, tmp.datalong2, tmp.id);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (scripts.find(tmp.id) == scripts.end())
|
||||
@@ -4763,6 +4780,7 @@ void ObjectMgr::LoadEventScripts()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Then check if all scripts are in above list of possible script entries
|
||||
for (ScriptMapMap::const_iterator itr = sEventScripts.begin(); itr != sEventScripts.end(); ++itr)
|
||||
{
|
||||
|
||||
@@ -440,6 +440,9 @@ enum WorldStates
|
||||
#define SCRIPT_COMMAND_REMOVE_AURA 14 // source (datalong2 != 0) or target (datalong == 0) unit, datalong = spell_id
|
||||
#define SCRIPT_COMMAND_CAST_SPELL 15 // source/target cast spell at target/source (script->datalong2: 0: s->t 1: s->s 2: t->t 3: t->s
|
||||
#define SCRIPT_COMMAND_PLAY_SOUND 16 // source = any object, target=any/player, datalong (sound_id), datalong2 (bitmask: 0/1=anyone/target, 0/2=with distance dependent, so 1|2 = 3 is target with distance dependent)
|
||||
#define SCRIPT_COMMAND_CREATE_ITEM 17 // source or target must be player, datalong = item entry, datalong2 = amount
|
||||
#define SCRIPT_COMMAND_DESPAWN_SELF 18 // source or target must be creature, datalong = despawn delay
|
||||
|
||||
#define SCRIPT_COMMAND_LOAD_PATH 20 // source = unit, path = datalong, repeatable datalong2
|
||||
#define SCRIPT_COMMAND_CALLSCRIPT_TO_UNIT 21 // datalong scriptid, lowguid datalong2, dataint table
|
||||
#define SCRIPT_COMMAND_KILL 22 // datalong removecorpse
|
||||
|
||||
Reference in New Issue
Block a user