From fb8399c4132b97f5637efb8dd7262050964f568a Mon Sep 17 00:00:00 2001 From: Machiavelli Date: Wed, 2 Jun 2010 18:43:11 +0200 Subject: 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. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/game/ObjectMgr.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src/game/ObjectMgr.cpp') diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index acb5ca1c35e..c826c0ea441 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -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) { -- cgit v1.2.3