All pastes #956493 Raw Edit

Mine

public text v1 · immutable
#956493 ·published 2008-03-25 10:44 UTC
rendered paste body
Index: src/game/Chat.cpp
===================================================================
--- src/game/Chat.cpp	(revision 5489)
+++ src/game/Chat.cpp	(working copy)
@@ -189,6 +189,7 @@
         { "spell_script_target",         SEC_ADMINISTRATOR, &ChatHandler::HandleReloadSpellScriptTargetCommand,       "", NULL },
         { "spell_scripts",               SEC_ADMINISTRATOR, &ChatHandler::HandleReloadSpellScriptsCommand,            "", NULL },
         { "spell_teleport",              SEC_ADMINISTRATOR, &ChatHandler::HandleReloadSpellTeleportCommand,           "", NULL },
+        { "spell_disabled",              SEC_ADMINISTRATOR, &ChatHandler::HandleReloadSpellDisabledCommand,           "", NULL },
 
         { "",                            SEC_ADMINISTRATOR, &ChatHandler::HandleReloadCommand,                        "", NULL },
         { NULL,                          0,                 NULL,                                                     "", NULL }
Index: src/game/Chat.h
===================================================================
--- src/game/Chat.h	(revision 5489)
+++ src/game/Chat.h	(working copy)
@@ -98,7 +98,7 @@
         bool HandleDismountCommand(const char* args);
         bool HandleSaveCommand(const char* args);
         bool HandleGMListCommand(const char* args);
-
+        bool HandleReloadSpellDisabledCommand(const char* args);
         bool HandleNamegoCommand(const char* args);
         bool HandleGonameCommand(const char* args);
         bool HandleGroupgoCommand(const char* args);
Index: src/game/Level3.cpp
===================================================================
--- src/game/Level3.cpp	(revision 5489)
+++ src/game/Level3.cpp	(working copy)
@@ -122,6 +122,7 @@
     HandleReloadSpellProcEventCommand("a");
     HandleReloadSpellScriptTargetCommand("a");
     HandleReloadSpellTeleportCommand("a");
+    HandleReloadSpellDisabledCommand("a");
     return true;
 }
 
@@ -446,6 +447,17 @@
     return true;
 }
 
+bool ChatHandler::HandleReloadSpellDisabledCommand(const char* /*arg*/)
+{
+    sLog.outString( "Re-Loading spell disabled table...");
+
+    objmgr.LoadSpellDisabledEntrys();
+
+    SendGlobalSysMessage("DB table `spell_disabled` reloaded.");
+
+    return true;
+}
+
 bool ChatHandler::HandleLoadScriptsCommand(const char* args)
 {
     if(!LoadScriptingModule(args)) return true;
Index: src/game/ObjectMgr.cpp
===================================================================
--- src/game/ObjectMgr.cpp	(revision 5489)
+++ src/game/ObjectMgr.cpp	(working copy)
@@ -5286,3 +5286,43 @@
     }
     return GetMangosStringDefault(entry);
 }
+
+void ObjectMgr::LoadSpellDisabledEntrys()
+{
+    m_spell_disabled.clear();                                // need for reload case
+    QueryResult *result = WorldDatabase.Query("SELECT entry, ischeat_spell FROM spell_disabled where active=1");
+
+    uint32 total_count = 0;
+	uint32 cheat_spell_count=0;
+
+    if( !result )
+    {
+        barGoLink bar( 1 );
+        bar.step();
+
+        sLog.outString();
+        sLog.outString( ">> Loaded %u disabled spells", total_count );
+        return;
+    }
+
+    barGoLink bar( result->GetRowCount() );
+
+    Field* fields;
+    do
+    {
+        bar.step();
+        fields = result->Fetch();
+        uint32 spellid = fields[0].GetUInt32();
+		bool ischeater = fields[1].GetBool();
+        m_spell_disabled[spellid] = ischeater;
+        ++total_count;
+		if(ischeater)
+		++cheat_spell_count;
+
+   } while ( result->NextRow() );
+
+    delete result;
+
+    sLog.outString();
+    sLog.outString( ">> Loaded %u disabled spells ( %u - is cheaters spells)", total_count, cheat_spell_count);
+}
Index: src/game/ObjectMgr.h
===================================================================
--- src/game/ObjectMgr.h	(revision 5489)
+++ src/game/ObjectMgr.h	(working copy)
@@ -599,6 +599,18 @@
             return m_ReservedNames.find(name) != m_ReservedNames.end();
         }
 
+		void LoadSpellDisabledEntrys();
+    	bool IsSpellDisabled(uint32 spellid) const
+        {
+            return m_spell_disabled.find(spellid) != m_spell_disabled.end();
+        }
+		bool IsCheaterSpell(uint32 spellid)
+		{
+		    SpellDisabledMap::const_iterator itr = m_spell_disabled.find(spellid);
+            if(itr != m_spell_disabled.end())
+            return itr->second;
+		return false;
+		}
         int GetIndexForLocale(LocaleConstant loc);
         LocaleConstant GetLocalForIndex(int);
         // guild bank tabs
@@ -658,6 +670,9 @@
         typedef std::set<std::string> ReservedNamesMap;
         ReservedNamesMap    m_ReservedNames;
 
+        typedef HM_NAMESPACE::hash_map<uint32, uint32> SpellDisabledMap;
+		SpellDisabledMap  m_spell_disabled;
+
         GraveYardMap        mGraveYardMap;
 
         typedef             std::vector<LocaleConstant> LocalToIndex;
Index: src/game/Spell.cpp
===================================================================
--- src/game/Spell.cpp	(revision 5489)
+++ src/game/Spell.cpp	(working copy)
@@ -1519,6 +1519,19 @@
         return;
     }
 
+	if(objmgr.IsSpellDisabled(m_spellInfo->Id))
+	{
+		if(m_caster->GetTypeId() == TYPEID_PLAYER)
+		{
+			sLog.outDebug("Player %s cast a spell %u which was disabled by server administrator",   m_caster->GetName(), m_spellInfo->Id);
+			if(objmgr.IsCheaterSpell(m_spellInfo->Id))
+			sLog.outChar("Player %s cast a spell %u which was disabled by server administrator and marked as CheatSpell",   m_caster->GetName(), m_spellInfo->Id);
+		}
+		SendCastResult(SPELL_FAILED_SPELL_UNAVAILABLE);
+        finish(false);
+        return;
+	}
+
     uint8 result = CanCast(true);
     if(result != 0)
     {
Index: src/game/World.cpp
===================================================================
--- src/game/World.cpp	(revision 5489)
+++ src/game/World.cpp	(working copy)
@@ -750,7 +750,10 @@
 
     sLog.outString( "Loading Player Corpses..." );
     objmgr.LoadCorpses();
-
+    
+    sLog.outString( "Loading Spell disabled..." );
+    objmgr.LoadSpellDisabledEntrys();
+    
     sLog.outString( "Loading Loot Tables..." );
     LoadLootTables();