Jump to content

[PATCH] Character Create Race/Class Blocker


Guest envien

Recommended Posts

What this patch do?

-You can setup character creation by (mangosd.conf)

For example...Player can create only Tauren or Night Elf and can't create another class.

Or player can create Tauren of Night Elf and can have all profession except Rogue or another.

[idea]: eNVieN

[Patch Autor]: DLxko

[Revision Work]: [9723]

[%WORK?]: Tested - Work

[Clock for Maximalized]: [REMOVED: ingame screenshot]

diff --git a/CharacterHandler.cpp b/CharacterHandler.cpp
index ae7e3f1..2e5de34 100644
--- a/CharacterHandler.cpp
+++ b/CharacterHandler.cpp
@@ -319,6 +319,7 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )

    // speedup check for heroic class disabled case
    uint32 heroic_free_slots = sWorld.getConfig(CONFIG_UINT32_HEROIC_CHARACTERS_PER_REALM);
+
    if(heroic_free_slots == 0 && GetSecurity() == SEC_PLAYER && class_ == CLASS_DEATH_KNIGHT)
    {
        data << (uint8)CHAR_CREATE_UNIQUE_CLASS_LIMIT;
@@ -326,6 +327,144 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
        return;
    }

+//=========================================//
+///Character Create Disable PATCH by DLxko///
+//=========================================//
+
+//First we need get this from config =D for all races /classes
+uint32 warrior = sWorld.getConfig(CONFIG_UINT32_WARRIOR_ENABLE); 
+uint32 paladin = sWorld.getConfig(CONFIG_UINT32_PALADIN_ENABLE);
+uint32 hunter = sWorld.getConfig(CONFIG_UINT32_HUNTER_ENABLE);
+uint32 rogue = sWorld.getConfig(CONFIG_UINT32_ROGUE_ENABLE);
+uint32 priest = sWorld.getConfig(CONFIG_UINT32_PRIEST_ENABLE);
+uint32 shaman = sWorld.getConfig(CONFIG_UINT32_SHAMAN_ENABLE);
+uint32 mage = sWorld.getConfig(CONFIG_UINT32_MAGE_ENABLE);
+uint32 warlock = sWorld.getConfig(CONFIG_UINT32_WARLOCK_ENABLE);
+
+
+uint32 dwarf = sWorld.getConfig(CONFIG_UINT32_DWARF_ENABLE);
+uint32 gnome = sWorld.getConfig(CONFIG_UINT32_GNOME_ENABLE);
+uint32 human = sWorld.getConfig(CONFIG_UINT32_HUMAN_ENABLE);
+uint32 nightelf = sWorld.getConfig(CONFIG_UINT32_NIGHTELF_ENABLE);
+uint32 orc = sWorld.getConfig(CONFIG_UINT32_ORC_ENABLE);
+uint32 tauren = sWorld.getConfig(CONFIG_UINT32_TAUREN_ENABLE);
+uint32 troll = sWorld.getConfig(CONFIG_UINT32_TROLL_ENABLE);
+uint32 undead = sWorld.getConfig(CONFIG_UINT32_UNDEAD_ENABLE);
+uint32 bloodelf = sWorld.getConfig(CONFIG_UINT32_BLOODELF_ENABLE);
+uint32 draenei = sWorld.getConfig(CONFIG_UINT32_DRAENEI_ENABLE);
+
+//If disabled class return error
+if(warrior == 0  && class_ == CLASS_WARRIOR)
+    {
+        data << (uint8)CHAR_CREATE_DISABLED;
+        SendPacket( &data );
+        return;
+    }
+if(paladin == 0  && class_ == CLASS_PALADIN)
+    {
+        data << (uint8)CHAR_CREATE_DISABLED;
+        SendPacket( &data );
+        return;
+    }
+if(hunter == 0  && class_ == CLASS_HUNTER)
+    {
+        data << (uint8)CHAR_CREATE_DISABLED;
+        SendPacket( &data );
+        return;
+    }
+if(rogue == 0  && class_ == CLASS_ROGUE)
+    {
+        data << (uint8)CHAR_CREATE_DISABLED;
+        SendPacket( &data );
+        return;
+    }
+if(priest == 0  && class_ == CLASS_PRIEST)
+    {
+        data << (uint8)CHAR_CREATE_DISABLED;
+        SendPacket( &data );
+        return;
+    }
+if(shaman == 0  && class_ == CLASS_SHAMAN)
+    {
+        data << (uint8)CHAR_CREATE_DISABLED;
+        SendPacket( &data );
+        return;
+    }
+if(mage == 0  && class_ == CLASS_MAGE)
+    {
+        data << (uint8)CHAR_CREATE_DISABLED;
+        SendPacket( &data );
+        return;
+    }
+if(warlock == 0  && class_ == CLASS_WARLOCK)
+    {
+        data << (uint8)CHAR_CREATE_DISABLED;
+        SendPacket( &data );
+        return;
+    }
+
+
+if(dwarf == 0  && race_ == RACE_DWARF)
+    {
+        data << (uint8)CHAR_CREATE_DISABLED;
+        SendPacket( &data );
+        return;
+    }
+if(gnome == 0  && race_ == RACE_GNOME)
+    {
+        data << (uint8)CHAR_CREATE_DISABLED;
+        SendPacket( &data );
+        return;
+    }
+if(human == 0  && race_ == RACE_HUMAN)
+    {
+        data << (uint8)CHAR_CREATE_DISABLED;
+        SendPacket( &data );
+        return;
+    }
+if(nightelf == 0  && race_ == RACE_NIGHTELF)
+    {
+        data << (uint8)CHAR_CREATE_DISABLED;
+        SendPacket( &data );
+        return;
+    }
+if(orc == 0  && race_ == RACE_ORC)
+    {
+        data << (uint8)CHAR_CREATE_DISABLED;
+        SendPacket( &data );
+        return;
+    }
+if(tauren == 0  && race_ == RACE_TAUREN)
+    {
+        data << (uint8)CHAR_CREATE_DISABLED;
+        SendPacket( &data );
+        return;
+    }
+if(troll == 0  && race_ == RACE_TROLL)
+    {
+        data << (uint8)CHAR_CREATE_DISABLED;
+        SendPacket( &data );
+        return;
+    }
+if(undead == 0  && race_ == RACE_UNDEAD_PLAYER)
+    {
+        data << (uint8)CHAR_CREATE_DISABLED;
+        SendPacket( &data );
+        return;
+    }
+if(bloodelf == 0  && race_ == RACE_BLOODELF)
+    {
+        data << (uint8)CHAR_CREATE_DISABLED;
+        SendPacket( &data );
+        return;
+    }
+if(draenei == 0  && race_ == RACE_DRAENEI)
+    {
+        data << (uint8)CHAR_CREATE_DISABLED;
+        SendPacket( &data );
+        return;
+    }
+
    // speedup check for heroic class disabled case
    uint32 req_level_for_heroic = sWorld.getConfig(CONFIG_UINT32_MIN_LEVEL_FOR_HEROIC_CHARACTER_CREATING);
    if(GetSecurity() == SEC_PLAYER && class_ == CLASS_DEATH_KNIGHT && req_level_for_heroic > sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL))
diff --git a/World.cpp b/World.cpp
index 6bf621c..cc3d29a 100644
--- a/World.cpp
+++ b/World.cpp
@@ -570,6 +570,28 @@ void World::LoadConfigSettings(bool reload)

    setConfigMinMax(CONFIG_UINT32_HEROIC_CHARACTERS_PER_REALM, "HeroicCharactersPerRealm", 1, 1, 10);

+    setConfig(CONFIG_UINT32_WARRIOR_ENABLE, "Warrior.Character.Enable", 0);
+    setConfig(CONFIG_UINT32_PALADIN_ENABLE, "Paladin.Character.Enable", 0);
+    setConfig(CONFIG_UINT32_HUNTER_ENABLE, "Hunter.Character.Enable", 0);
+    setConfig(CONFIG_UINT32_ROGUE_ENABLE, "Rogue.Character.Enable", 0);
+    setConfig(CONFIG_UINT32_PRIEST_ENABLE, "Priest.Character.Enable", 0);
+    setConfig(CONFIG_UINT32_SHAMAN_ENABLE, "Shaman.Character.Enable", 0);
+    setConfig(CONFIG_UINT32_MAGE_ENABLE, "Mage.Character.Enable", 0);
+    setConfig(CONFIG_UINT32_WARLOCK_ENABLE, "Warlock.Character.Enable", 0);
+
+    setConfig(CONFIG_UINT32_DWARF_ENABLE, "Dwarf.Character.Enable", 0);
+    setConfig(CONFIG_UINT32_GNOME_ENABLE, "Gnome.Character.Enable", 0);
+    setConfig(CONFIG_UINT32_HUMAN_ENABLE, "Human.Character.Enable", 0);
+    setConfig(CONFIG_UINT32_NIGHTELF_ENABLE, "NightElf.Character.Enable", 0);
+    setConfig(CONFIG_UINT32_ORC_ENABLE, "Orc.Character.Enable", 0);
+    setConfig(CONFIG_UINT32_TAUREN_ENABLE, "Tauren.Character.Enable", 0);
+    setConfig(CONFIG_UINT32_TROLL_ENABLE, "Troll.Character.Enable", 0);
+    setConfig(CONFIG_UINT32_UNDEAD_ENABLE, "Undead.Character.Enable", 0);
+  setConfig(CONFIG_UINT32_BLOODELF_ENABLE, "BloodElf.Character.Enable", 0);
+  setConfig(CONFIG_UINT32_DRAENEI_ENABLE, "Draenei.Character.Enable", 0);
+
+
+
    setConfig(CONFIG_UINT32_MIN_LEVEL_FOR_HEROIC_CHARACTER_CREATING, "MinLevelForHeroicCharacterCreating", 55);

    setConfigMinMax(CONFIG_UINT32_SKIP_CINEMATICS, "SkipCinematics", 0, 0, 2);
diff --git a/World.h b/World.h
index a4e4f6f..4eb28eb 100644
--- a/World.h
+++ b/World.h
@@ -177,7 +177,25 @@ enum eConfigUInt32Values
    CONFIG_UINT32_TIMERBAR_FIRE_GMLEVEL,
    CONFIG_UINT32_TIMERBAR_FIRE_MAX,
    CONFIG_UINT32_MIN_LEVEL_STAT_SAVE,
-    CONFIG_UINT32_VALUE_COUNT
+    CONFIG_UINT32_VALUE_COUNT,
+      CONFIG_UINT32_WARRIOR_ENABLE,
+      CONFIG_UINT32_PALADIN_ENABLE,
+      CONFIG_UINT32_HUNTER_ENABLE,
+      CONFIG_UINT32_ROGUE_ENABLE,
+      CONFIG_UINT32_PRIEST_ENABLE,
+      CONFIG_UINT32_SHAMAN_ENABLE,
+      CONFIG_UINT32_MAGE_ENABLE,
+      CONFIG_UINT32_WARLOCK_ENABLE,
+       CONFIG_UINT32_DWARF_ENABLE,
+      CONFIG_UINT32_GNOME_ENABLE,
+      CONFIG_UINT32_HUMAN_ENABLE,
+      CONFIG_UINT32_NIGHTELF_ENABLE,
+      CONFIG_UINT32_ORC_ENABLE,
+      CONFIG_UINT32_TAUREN_ENABLE,
+      CONFIG_UINT32_TROLL_ENABLE,
+      CONFIG_UINT32_UNDEAD_ENABLE,
+      CONFIG_UINT32_BLOODELF_ENABLE,
+      CONFIG_UINT32_DRAENEI_ENABLE
};

/// Configuration elements
diff --git a/mangosd.conf.dist.in b/mangosd.conf.dist.in
index 5d4053f..2adef11 100644
--- a/mangosd.conf.dist.in
+++ b/mangosd.conf.dist.in
@@ -1451,3 +1451,39 @@ SOAP.Enabled = 0
SOAP.IP = 127.0.0.1
SOAP.Port = 7878

+###################################################################################################################
+# NEW CHARACTER CREATE
+#    
+#    *RACE*.Character.enable
+#        (A: Human, Dwarf, Gnome, Night Elf, Draenei / H: Orc, Troll, Undead, Tauren, Blood Elf)
+#                 0 - disable (blocked)
+#        Default: 1 - enable  (enabled)
+#
+#    *CLASS*.Character.enable
+#        (Warrior, Paladin, Death Knight, Shaman, Hunter, Druid, Rogue, Priest, Mage, Warlock)
+#                 0 - disable (blocked)
+#        Default: 1 - enable  (enabled)
+#
+###################################################################################################################
+
+Human.Character.enable = 1
+Dwarf.Character.enable = 1
+Gnome.Character.enable = 1
+NightElf.Character.enable = 1
+Draenei.Character.enable = 1
+Orc.Character.enable = 1
+Troll.Character.enable = 1
+Undead.Character.enable = 1
+Tauren.Character.enable = 1
+BloodElf.Character.enable = 1
+
+Warrior.Character.enable = 1
+Paladin.Character.enable = 1
+DeathKnight.Character.enable = 1
+Shaman.Character.enable = 1
+Hunter.Character.enable = 1
+Druid.Character.enable = 1
+Rogue.Character.enable = 1
+Priest.Character.enable = 1
+Mage.Character.enable = 1
+Warlock.Character.enable = 1

Link to comment
Share on other sites

I have modified the patch:

diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp
index ae7e3f1..2e5de34 100644
--- a/src/game/CharacterHandler.cpp
+++ b/src/game/CharacterHandler.cpp
@@ -15,10 +15,11 @@
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#include "Common.h"
+#include "Config/ConfigEnv.h"
#include "Database/DatabaseEnv.h"
#include "WorldPacket.h"
#include "SharedDefines.h"
#include "WorldSession.h"
#include "Opcodes.h"
@@ -223,10 +224,47 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
                return;
            }
        }
    }

+    //=========================================//
+    ///Character Create Disable PATCH by DLxko///
+    ///Modified by Fabian                     ///
+    //=========================================//
+
+    //First we need get this from config =D for all races /classes
+    bool warrior = sConfig.GetBoolDefault("WarriorCharacter.Enable", true);
+    bool paladin = sConfig.GetBoolDefault("PaladinCharacter.Enable", true);
+    bool hunter = sConfig.GetBoolDefault("HunterCharacter.Enable", true);
+    bool rogue = sConfig.GetBoolDefault("RogueCharacter.Enable", true);
+    bool priest = sConfig.GetBoolDefault("PriestCharacter.Enable", true);
+    bool shaman = sConfig.GetBoolDefault("ShamanCharacter.Enable", true);
+    bool mage = sConfig.GetBoolDefault("MageCharacter.Enable", true);
+    bool warlock = sConfig.GetBoolDefault("WarlockCharacter.Enable", true);
+
+    bool dwarf = sConfig.GetBoolDefault("DwarfCharacter.Enable", true);
+    bool gnome = sConfig.GetBoolDefault( "GnomeCharacter.Enable", true);
+    bool human = sConfig.GetBoolDefault("HumanCharacter.Enable", true);
+    bool nightelf = sConfig.GetBoolDefault("NightElfCharacter.Enable", true);
+    bool orc = sConfig.GetBoolDefault("OrcCharacter.Enable", true);
+    bool tauren = sConfig.GetBoolDefault("TaurenCharacter.Enable", true);
+    bool troll = sConfig.GetBoolDefault("TrollCharacter.Enable", true);
+    bool undead = sConfig.GetBoolDefault("UndeadCharacter.Enable", true);
+    bool bloodelf = sConfig.GetBoolDefault("BloodElfCharacter.Enable", true);
+    bool draenei = sConfig.GetBoolDefault("DraeneiCharacter.Enable", true);
+
+    //If disabled class return error
+    if (!warrior && class_ == CLASS_WARRIOR || !paladin && class_ == CLASS_PALADIN || !hunter && class_ == CLASS_HUNTER || !rogue && class_ == CLASS_ROGUE || !priest && class_ == CLASS_PRIEST
+        || !shaman && class_ == CLASS_SHAMAN || !mage && class_ == CLASS_MAGE || !warlock && class_ == CLASS_WARLOCK || !dwarf && race_ == RACE_DWARF || !gnome && race_ == RACE_GNOME
+        || !human && race_ == RACE_HUMAN || !nightelf && race_ == RACE_NIGHTELF || !orc && race_ == RACE_ORC || !tauren && race_ == RACE_TAUREN || !troll && race_ == RACE_TROLL
+        || !undead && race_ == RACE_UNDEAD_PLAYER || !bloodelf && race_ == RACE_BLOODELF || !draenei && race_ == RACE_DRAENEI)
+    {
+        data << uint8(CHAR_CREATE_DISABLED);
+        SendPacket( &data );
+        return;
+    }
+
    ChrClassesEntry const* classEntry = sChrClassesStore.LookupEntry(class_);
    ChrRacesEntry const* raceEntry = sChrRacesStore.LookupEntry(race_);

    if( !classEntry || !raceEntry )
    {

diff --git a/src/mangosd/mangosd.conf.dist.in b/src/mangosd/mangosd.conf.dist.in
index 5d4053f..2adef11 100644
--- a/src/mangosd/mangosd.conf.dist.in
+++ b/src/mangosd/mangosd.conf.dist.in
@@ -1523,10 +1523,47 @@ Ra.Stricted = 1
SOAP.Enabled = 0
SOAP.IP = 127.0.0.1
SOAP.Port = 7878

###################################################################################################################
+# NEW CHARACTER CREATE
+#    
+#    RaceCharacter.Enable
+#        (A: Human, Dwarf, Gnome, Night Elf, Draenei / H: Orc, Troll, Undead, Tauren, Blood Elf)
+#                 0 - disable (blocked)
+#        Default: 1 - enable  (enabled)
+#
+#    ClassCharacter.Enable
+#        (Warrior, Paladin, Shaman, Hunter, Druid, Rogue, Priest, Mage, Warlock)
+#                 0 - disable (blocked)
+#        Default: 1 - enable  (enabled)
+#
+###################################################################################################################
+
+HumanCharacter.Enable       = 1
+DwarfCharacter.Enable       = 1
+GnomeCharacter.Enable       = 1
+NightElfCharacter.Enable    = 1
+DraeneiCharacter.Enable     = 1
+OrcCharacter.Enable         = 1
+TrollCharacter.Enable       = 1
+UndeadCharacter.Enable      = 1
+TaurenCharacter.Enable      = 1
+BloodElfCharacter.Enable    = 1
+
+WarriorCharacter.Enable     = 1
+PaladinCharacter.Enable     = 1
+ShamanCharacter.Enable      = 1
+HunterCharacter.Enable      = 1
+DruidCharacter.Enable       = 1
+RogueCharacter.Enable       = 1
+PriestCharacter.Enable      = 1
+MageCharacter.Enable        = 1
+WarlockCharacter.Enable     = 1
+
+###################################################################################################################

Link to comment
Share on other sites

Support for DeathKnight

diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp
index 68754d8..f5acf06 100644
--- a/src/game/CharacterHandler.cpp
+++ b/src/game/CharacterHandler.cpp
@@ -340,7 +340,7 @@ uint32 priest = sWorld.getConfig(CONFIG_UINT32_PRIEST_ENABLE);
uint32 shaman = sWorld.getConfig(CONFIG_UINT32_SHAMAN_ENABLE);
uint32 mage = sWorld.getConfig(CONFIG_UINT32_MAGE_ENABLE);
uint32 warlock = sWorld.getConfig(CONFIG_UINT32_WARLOCK_ENABLE);
-
+uint32 deathknight = sWorld.getConfig(CONFIG_UINT32_DEATH_KNIGHT_ENABLE); 

uint32 dwarf = sWorld.getConfig(CONFIG_UINT32_DWARF_ENABLE);
uint32 gnome = sWorld.getConfig(CONFIG_UINT32_GNOME_ENABLE);
@@ -402,7 +402,12 @@ if(warlock == 0  && class_ == CLASS_WARLOCK)
        SendPacket( &data );
        return;
    }
-
+if(deathknight == 0  && class_ == CLASS_DEATH_KNIGHT)
+    {
+        data << (uint8)CHAR_CREATE_DISABLED;
+        SendPacket( &data );
+        return;
+    }

if(dwarf == 0  && race_ == RACE_DWARF)
    {
diff --git a/src/game/World.cpp b/src/game/World.cpp
index 05e6b9e..0f8ef0f 100644
--- a/src/game/World.cpp
+++ b/src/game/World.cpp
@@ -579,6 +579,7 @@ void World::LoadConfigSettings(bool reload)
    setConfig(CONFIG_UINT32_SHAMAN_ENABLE, "Shaman.Character.Enable", 0);
    setConfig(CONFIG_UINT32_MAGE_ENABLE, "Mage.Character.Enable", 0);
    setConfig(CONFIG_UINT32_WARLOCK_ENABLE, "Warlock.Character.Enable", 0);
+    setConfig(CONFIG_UINT32_DEATH_KNIGHT_ENABLE, "DeathKnight.Character.Enable", 0);

    setConfig(CONFIG_UINT32_DWARF_ENABLE, "Dwarf.Character.Enable", 0);
    setConfig(CONFIG_UINT32_GNOME_ENABLE, "Gnome.Character.Enable", 0);
diff --git a/src/game/World.h b/src/game/World.h
index 6ea9a18..1d774ac 100644
--- a/src/game/World.h
+++ b/src/game/World.h
@@ -187,6 +187,7 @@ enum eConfigUInt32Values
    CONFIG_UINT32_SHAMAN_ENABLE,
    CONFIG_UINT32_MAGE_ENABLE,
    CONFIG_UINT32_WARLOCK_ENABLE,
+    CONFIG_UINT32_DEATH_KNIGHT_ENABLE,
    CONFIG_UINT32_DWARF_ENABLE,
    CONFIG_UINT32_GNOME_ENABLE,
    CONFIG_UINT32_HUMAN_ENABLE,
-- 
1.7.0.2

Link to comment
Share on other sites

we have already a config option for deathknight :

HeroicCharactersPerRealm

is the option.

we don't need an option for the dk in this patch

and we should use bool and not uint32.

look at my patch. I have rewrite envines patch, and it works fine

Link to comment
Share on other sites

  • 2 weeks later...

So this is the best patch to allow races to have all classes unlocked? I'm wanting to unlock dwarf shaman as an option. Please clarify if this does indeed unlock and disable certain classes for races or if this is just useful for death knights etc.

Also, is this the best patch option?

Link to comment
Share on other sites

This is probably the best option.

This IS the correct way to go. Imagine if this game had 500 classes. You would 500 options instead of 1. With one for all classes and a good explanation showing what flag value means what class and/or race, this will be an excellent addition.

Link to comment
Share on other sites

  • 1 month later...

I have written a new patch. I have implent all race/class combinations.

Patch:

diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp
index 8357ede..477006a 100644
--- a/src/game/CharacterHandler.cpp
+++ b/src/game/CharacterHandler.cpp
@@ -225,6 +225,243 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
        }
    }

+    // Disable Race/Class combinations \\\\
+     //            by Fabian          \\\\
+
+    // Enable Race/Class Blocker for GameMaster/Admins ?!
+    // Default is 0 (Race/Class Blocker only enabled for normal players)
+    uint8 block_gmlevel = sConfig.GetIntDefault("Race.Class.Blocker.GMLevel", 0);
+
+    //####################################ALLIANCE####################################\\\\
+    // Human
+    bool human_priest      = sConfig.GetBoolDefault("Human.Priest.Enable", true);
+    bool human_rogue       = sConfig.GetBoolDefault("Human.Rogue.Enable", true);
+    bool human_warrior     = sConfig.GetBoolDefault("Human.Warrior.Enable", true);
+    bool human_mage        = sConfig.GetBoolDefault("Human.Mage.Enable", true);
+    // Druid not aviable for this Race
+    /* Hunter will come in Cataclysm
+    bool human_hunter      = sConfig.GetBoolDefault("Human.Hunter.Enable", true);*/
+    bool human_warlock     = sConfig.GetBoolDefault("Human.Warlock.Enable", true);
+    // Shaman not aviable for this Race
+    bool human_paladin     = sConfig.GetBoolDefault("Human.Paladin.Enable", true);
+    bool human_deathknight = sConfig.GetBoolDefault("Human.DeathKnight.Enable", true);
+
+    // Dwarf
+    bool dwarf_priest      = sConfig.GetBoolDefault("Dwarf.Priest.Enable", true);
+    bool dwarf_rogue       = sConfig.GetBoolDefault("Dwarf.Rogue.Enable", true);
+    bool dwarf_warrior     = sConfig.GetBoolDefault("Dwarf.Warrior.Enable", true);
+    /* Mage will come in Cataclysm
+    bool dwarf_mage        = sConfig.GetBoolDefault("Dwarf.Mage.Enable", true);*/
+    // Druid not aviable for this Race
+    bool dwarf_hunter      = sConfig.GetBoolDefault("Dwarf.Hunter.Enable", true);
+    // Warlock not aviable for this Race
+    /* Shaman will come in Cataclysm
+    bool dwarf_shaman      = sConfig.GetBoolDefault("Dwarf.Shaman.Enable", true);*/
+    bool dwarf_paladin     = sConfig.GetBoolDefault("Dwarf.Paladin.Enable", true);
+    bool dwarf_deathknight = sConfig.GetBoolDefault("Dwarf.DeathKnight.Enable", true);
+
+    // Night elf
+    bool nightelf_priest      = sConfig.GetBoolDefault("NightElf.Priest.Enable", true);
+    bool nightelf_rogue       = sConfig.GetBoolDefault("NightElf.Rogue.Enable", true);
+    bool nightelf_warrior     = sConfig.GetBoolDefault("NightElf.Warrior.Enable", true);
+    /* Mage will come in Cataclysm
+    bool nightelf_mage        = sConfig.GetBoolDefault("NightElf.Mage.Enable", true);*/
+    bool nightelf_druid       = sConfig.GetBoolDefault("NightElf.Druid.Enable", true);
+    bool nightelf_hunter      = sConfig.GetBoolDefault("NightElf.Hunter.Enable", true);
+    // Warlock not aviable for this Race
+    // Shaman not aviable for this Race
+    // Paladin not aviable for this Race
+    bool nightelf_deathknight = sConfig.GetBoolDefault("NightElf.DeathKnight.Enable", true);
+
+    // Gnome
+    /* Priest will come in Cataclysm
+    bool gnome_priest      = sConfig.GetBoolDefault("Gnome.Priest.Enable", true);*/
+    bool gnome_rogue       = sConfig.GetBoolDefault("Gnome.Rogue.Enable", true);
+    bool gnome_warrior     = sConfig.GetBoolDefault("Gnome.Warrior.Enable", true);
+    bool gnome_mage        = sConfig.GetBoolDefault("Gnome.Mage.Enable", true);
+    // Druid not aviable for this Race
+    // Hunter not aviable for this Race
+    bool gnome_warlock     = sConfig.GetBoolDefault("Gnome.Warlock.Enable", true);
+    // Shaman not aviable for this Race
+    // Paladin not aviable for this Race
+    bool gnome_deathknight = sConfig.GetBoolDefault("Gnome.DeathKnight.Enable", true);
+
+    // Draenei
+    bool draenei_priest      = sConfig.GetBoolDefault("Draenei.Priest.Enable", true);
+    // Rogue not aviable for this Race
+    bool draenei_warrior     = sConfig.GetBoolDefault("Draenei.Warrior.Enable", true);
+    bool draenei_mage        = sConfig.GetBoolDefault("Draenei.Mage.Enable", true);
+    // Druid not aviable for this Race
+    bool draenei_hunter      = sConfig.GetBoolDefault("Draenei.Hunter.Enable", true);
+    // Warlock not aviable for this Race
+    bool draenei_shaman      = sConfig.GetBoolDefault("Draenei.Shaman.Enable", true);
+    bool draenei_paladin     = sConfig.GetBoolDefault("Draenei.Paladin.Enable", true);
+    bool draenei_deathknight = sConfig.GetBoolDefault("Draenei.DeathKnight.Enable", true);
+
+    // Worgen
+    // Will come in Cataclysm \\\\
+
+    //####################################HORDE####################################\\\\
+    // Orc
+    // Priest not aviable for this Race
+    bool orc_rogue       = sConfig.GetBoolDefault("Orc.Rogue.Enable", true);
+    bool orc_warrior     = sConfig.GetBoolDefault("Orc.Warrior.Enable", true);
+    /* Mage will come in Cataclysm
+    bool orc_mage      = sConfig.GetBoolDefault("Orc.Mage.Enable", true);*/
+    // Druid not aviable for this Race
+    bool orc_hunter      = sConfig.GetBoolDefault("Orc.Hunter.Enable", true);
+    bool orc_warlock     = sConfig.GetBoolDefault("Orc.Warlock.Enable", true);
+    bool orc_shaman       = sConfig.GetBoolDefault("Orc.Shaman.Enable", true);
+    // Paladin not aviable for this Race
+    bool orc_deathknight = sConfig.GetBoolDefault("Orc.DeathKnight.Enable", true);
+
+    // Forsaken
+    bool forsaken_priest      = sConfig.GetBoolDefault("Forsaken.Priest.Enable", true);
+    bool forsaken_rogue       = sConfig.GetBoolDefault("Forsaken.Rogue.Enable", true);
+    bool forsaken_warrior     = sConfig.GetBoolDefault("Forsaken.Warrior.Enable", true);
+    bool forsaken_mage        = sConfig.GetBoolDefault("Forsaken.Mage.Enable", true);
+    // Druid not aviable for this Race
+    /* Hunter will come in Cataclysm
+    bool forsaken_hunter      = sConfig.GetBoolDefault("Forsaken.Hunter.Enable", true);*/
+    bool forsaken_warlock     = sConfig.GetBoolDefault("Forsaken.Warlock.Enable", true);
+    // Shaman not aviable for this Race
+    // Paladin not aviable for this Race
+    bool forsaken_deathknight = sConfig.GetBoolDefault("Forsaken.DeathKnight.Enable", true);
+
+    // Tauren
+    /* Priest will come in Cataclysm
+    bool tauren_priest      = sConfig.GetBoolDefault("Tauren.Priest.Enable", true);*/
+    // Rogue not aviable for this Race
+    bool tauren_warrior     = sConfig.GetBoolDefault("Tauren.Warrior.Enable", true);
+    // Mage not aviable for this Race
+    bool tauren_druid       = sConfig.GetBoolDefault("Tauren.Druid.Enable", true);
+    bool tauren_hunter      = sConfig.GetBoolDefault("Tauren.Hunter.Enable", true);
+    // Warlock not aviable for this Race
+    bool tauren_shaman      = sConfig.GetBoolDefault("Tauren.Shaman.Enable", true);
+    /* Paladin will come in Cataclysm
+    bool tauren_paladin     = sConfig.GetBoolDefault("Tauren.Paladin.Enable", true);*/
+    bool tauren_deathknight = sConfig.GetBoolDefault("Tauren.DeathKnight.Enable", true);
+
+    // Troll
+    bool troll_priest      = sConfig.GetBoolDefault("Troll.Priest.Enable", true);
+    bool troll_rogue       = sConfig.GetBoolDefault("Troll.Rogue.Enable", true);
+    bool troll_warrior     = sConfig.GetBoolDefault("Troll.Warrior.Enable", true);
+    bool troll_mage        = sConfig.GetBoolDefault("Troll.Mage.Enable", true);
+    /* Druid will come in Cataclysm
+    bool troll_druid       = sConfig.GetBoolDefault("Troll.Druid.Enable", true);*/
+    bool troll_hunter      = sConfig.GetBoolDefault("Troll.Hunter.Enable", true);
+    // Warlock not aviable for this Race
+    bool troll_shaman      = sConfig.GetBoolDefault("Troll.Shaman.Enable", true);
+    // Paladin not aviable for this Race
+    bool troll_deathknight = sConfig.GetBoolDefault("Troll.DeathKnight.Enable", true);
+
+    // Blood elf
+    bool bloodelf_priest      = sConfig.GetBoolDefault("BloodElf.Priest.Enable", true);
+    bool bloodelf_rogue       = sConfig.GetBoolDefault("BloodElf.Rogue.Enable", true);
+    /* Warrior will come in Cataclysm
+    bool bloodelf_warrior     = sConfig.GetBoolDefault("BloodElf.Warrior.Enable", true);*/
+    bool bloodelf_mage        = sConfig.GetBoolDefault("BloodElf.Mage.Enable", true);
+    // Druid not aviable for this Race
+    bool bloodelf_hunter      = sConfig.GetBoolDefault("BloodElf.Hunter.Enable", true);
+    bool bloodelf_warlock     = sConfig.GetBoolDefault("BloodElf.Warlock.Enable", true);
+    // Shaman not aviable for this Race
+    bool bloodelf_paladin     = sConfig.GetBoolDefault("BloodElf.Paladin.Enable", true);
+    bool bloodelf_deathknight = sConfig.GetBoolDefault("BloodElf.DeathKnight.Enable", true);
+
+    // Goblin
+    // Will come in Cataclysm \\\\
+
+    if(GetSecurity() <= block_gmlevel)
+    {
+        
+        // Function for Human
+        if (!human_priest && class_ == CLASS_PRIEST && race_ == RACE_HUMAN || !human_rogue && class_ == CLASS_ROGUE && race_ == RACE_HUMAN || !human_warrior && class_ == CLASS_WARRIOR && race_ == RACE_HUMAN
+            || !human_mage && class_ == CLASS_MAGE && race_ == RACE_HUMAN || !human_warlock && class_ == CLASS_WARLOCK && race_ == RACE_HUMAN || !human_paladin && class_ == CLASS_PALADIN && race_ == RACE_HUMAN
+            || !human_deathknight && class_ == CLASS_DEATH_KNIGHT && race_ == RACE_HUMAN)
+        {
+            data << uint8(CHAR_LOGIN_DISABLED);
+            SendPacket(&data);
+            return;
+        }
+        // Function for Dwarf
+        else if (!dwarf_priest && class_ == CLASS_PRIEST && race_ == RACE_DWARF || !dwarf_rogue && class_ == CLASS_ROGUE && race_ == RACE_DWARF || !dwarf_warrior && class_ == CLASS_WARRIOR && race_ == RACE_DWARF
+            || !dwarf_hunter && class_ == CLASS_HUNTER && race_ == RACE_DWARF || !dwarf_paladin && class_ == CLASS_PALADIN && race_ == RACE_DWARF || !dwarf_deathknight && class_ == CLASS_DEATH_KNIGHT && race_ == RACE_DWARF)
+        {
+            data << uint8(CHAR_LOGIN_DISABLED);
+            SendPacket(&data);
+            return;
+        }
+        // Function for Nightelf
+        else if (!nightelf_priest && class_ == CLASS_PRIEST && race_ == RACE_NIGHTELF || !nightelf_rogue && class_ == CLASS_ROGUE && race_ == RACE_NIGHTELF || !nightelf_warrior && class_ == CLASS_WARRIOR && race_ == RACE_NIGHTELF
+            || !nightelf_druid && class_ == CLASS_DRUID && race_ == RACE_NIGHTELF || !nightelf_hunter && class_ == CLASS_HUNTER && race_ == RACE_NIGHTELF
+            || !nightelf_deathknight && class_ == CLASS_DEATH_KNIGHT && race_ == RACE_NIGHTELF)
+        {
+            data << uint8(CHAR_LOGIN_DISABLED);
+            SendPacket(&data);
+            return;
+        }
+        // Function for Gnome
+        else if (!gnome_rogue && class_ == CLASS_ROGUE && race_ == RACE_GNOME || !gnome_warrior && class_ == CLASS_WARRIOR && race_ == RACE_GNOME || !gnome_mage && class_ == CLASS_MAGE && race_ == RACE_GNOME
+            || !gnome_warlock && class_ == CLASS_WARLOCK && race_ == RACE_GNOME || !gnome_deathknight && class_ == CLASS_DEATH_KNIGHT && race_ == RACE_GNOME)
+        {
+            data << uint8(CHAR_LOGIN_DISABLED);
+            SendPacket(&data);
+            return;
+        }
+        // Function for Draenei
+        else if (!draenei_priest && class_ == CLASS_PRIEST && race_ == RACE_DRAENEI|| !draenei_warrior && class_ == CLASS_WARRIOR && race_ == RACE_DRAENEI || !draenei_mage && class_ == CLASS_MAGE && race_ == RACE_DRAENEI
+            || !draenei_hunter && class_ == CLASS_HUNTER && race_ == RACE_DRAENEI || !draenei_shaman && class_ == CLASS_SHAMAN && race_ == RACE_DRAENEI || !draenei_paladin && class_ == CLASS_PALADIN && race_ == RACE_DRAENEI
+            || !draenei_deathknight && class_ == CLASS_DEATH_KNIGHT && race_ == RACE_DRAENEI)
+        {
+            data << uint8(CHAR_LOGIN_DISABLED);
+            SendPacket(&data);
+            return;
+        }
+
+        // Function for Orc
+        else if (!orc_rogue && class_ == CLASS_ROGUE && race_ == RACE_ORC || !orc_warrior && class_ == CLASS_WARRIOR && race_ == RACE_ORC || !orc_hunter && class_ == CLASS_HUNTER && race_ == RACE_ORC
+            || !orc_warlock && class_ == CLASS_WARLOCK && race_ == RACE_ORC || !orc_shaman && class_ == CLASS_SHAMAN && race_ == RACE_ORC || !orc_deathknight && class_ == CLASS_DEATH_KNIGHT && race_ == RACE_ORC)
+        {
+            data << uint8(CHAR_LOGIN_DISABLED);
+            SendPacket(&data);
+            return;
+        }
+        // Function for Forsaken
+        else if (!forsaken_priest && class_ == CLASS_PRIEST && race_ == RACE_UNDEAD_PLAYER || !forsaken_rogue && class_ == CLASS_ROGUE && race_ == RACE_UNDEAD_PLAYER || !forsaken_mage && class_ == CLASS_MAGE && race_ == RACE_UNDEAD_PLAYER
+            || !forsaken_warlock && class_ == CLASS_WARLOCK && race_ == RACE_UNDEAD_PLAYER || !forsaken_deathknight && class_ == CLASS_DEATH_KNIGHT && race_ == RACE_UNDEAD_PLAYER)
+        {
+            data << uint8(CHAR_LOGIN_DISABLED);
+            SendPacket(&data);
+            return;
+        }
+        // Function for Tauren
+        else if (!tauren_warrior && class_ == CLASS_WARRIOR && race_ == RACE_TAUREN || !tauren_druid && class_ == CLASS_DRUID && race_ == RACE_TAUREN || !tauren_hunter && class_ == CLASS_HUNTER && race_ == RACE_TAUREN
+            || !tauren_shaman && class_ == CLASS_SHAMAN && race_ == RACE_TAUREN || !tauren_deathknight && class_ == CLASS_DEATH_KNIGHT && race_ == RACE_TAUREN)
+        {
+            data << uint8(CHAR_LOGIN_DISABLED);
+            SendPacket(&data);
+            return;
+        }
+        // Function for Troll
+        else if (!troll_priest && class_ == CLASS_PRIEST && race_ == RACE_TROLL || !troll_rogue && class_ == CLASS_ROGUE && race_ == RACE_TROLL || !troll_warrior && class_ == CLASS_WARRIOR && race_ == RACE_TROLL
+            || !troll_mage && class_ == CLASS_MAGE && race_ == RACE_TROLL || !troll_hunter && class_ == CLASS_HUNTER && race_ == RACE_TROLL || !troll_shaman && class_ == CLASS_SHAMAN && race_ == RACE_TROLL
+            || !troll_deathknight && class_ == CLASS_DEATH_KNIGHT && race_ == RACE_TROLL)
+        {
+            data << uint8(CHAR_LOGIN_DISABLED);
+            SendPacket(&data);
+            return;
+        }
+        // Function for BloodElf
+        else if (!bloodelf_priest && class_ == CLASS_PRIEST && race_ == RACE_BLOODELF || !bloodelf_rogue && class_ == CLASS_ROGUE && race_ == RACE_BLOODELF || !bloodelf_mage && class_ == CLASS_MAGE && race_ == RACE_BLOODELF
+            || !bloodelf_hunter && class_ == CLASS_HUNTER && race_ == RACE_BLOODELF || !bloodelf_warlock && class_ == CLASS_WARLOCK && race_ == RACE_BLOODELF || !bloodelf_paladin && class_ == CLASS_PALADIN && race_ == RACE_BLOODELF
+            || !bloodelf_deathknight && class_ == CLASS_DEATH_KNIGHT && race_ == RACE_BLOODELF)
+        {
+            data << uint8(CHAR_LOGIN_DISABLED);
+            SendPacket(&data);
+            return;
+        }
+    }
+
    ChrClassesEntry const* classEntry = sChrClassesStore.LookupEntry(class_);
    ChrRacesEntry const* raceEntry = sChrRacesStore.LookupEntry(race_);

diff --git a/src/mangosd/mangosd.conf.dist.in b/src/mangosd/mangosd.conf.dist.in
index f5ba807..26f0bf2 100644
--- a/src/mangosd/mangosd.conf.dist.in
+++ b/src/mangosd/mangosd.conf.dist.in
@@ -1,4 +1,4 @@
-#####################################
+#####################################
# MaNGOS Configuration file         #
#####################################
ConfVersion=2010051901
@@ -1519,3 +1519,89 @@ SOAP.Port = 7878
CharDelete.Method = 0
CharDelete.MinLevel = 0
CharDelete.KeepDays = 30
+
+###################################################################################################################
+# RACE / CLASS BLOCKER
+#
+#    Race.Class.Blocker.GMLevel
+#        Enable the race/class blocker for accounts with this gm level
+#        Default: 0 - Only for normal players
+#
+#    Race.Class.Enable
+#        Allow to disable character creation for race/class combis
+#        Default: 1 - All Race/Class combis enabled
+#
+###################################################################################################################
+
+Race.Class.Blocker.GMLevel  = 0
+
+Human.Priest.Enable         = 1
+Human.Rogue.Enable          = 1
+Human.Warrior.Enable        = 1
+Human.Mage.Enable           = 1
+Human.Warlock.Enable        = 1
+Human.Paladin.Enable        = 1
+Human.DeathKnight.Enable    = 1
+
+Dwarf.Priest.Enable         = 1
+Dwarf.Rogue.Enable          = 1
+Dwarf.Warrior.Enable        = 1
+Dwarf.Hunter.Enable         = 1
+Dwarf.Paladin.Enable        = 1
+Dwarf.DeathKnight.Enable    = 1
+
+NightElf.Priest.Enable      = 1
+NightElf.Rogue.Enable       = 1
+NightElf.Warrior.Enable     = 1
+NightElf.Druid.Enable       = 1
+NightElf.Hunter.Enable      = 1
+NightElf.DeathKnight.Enable = 1
+
+Gnome.Rogue.Enable          = 1
+Gnome.Warrior.Enable        = 1
+Gnome.Mage.Enable           = 1
+Gnome.Warlock.Enable        = 1
+Gnome.DeathKnight.Enable    = 1
+
+Draenei.Priest.Enable       = 1
+Draenei.Warrior.Enable      = 1
+Draenei.Mage.Enable         = 1
+Draenei.Hunter.Enable       = 1
+Draenei.Shaman.Enable       = 1
+Draenei.Paladin.Enable      = 1
+Draenei.DeathKnight.Enable  = 1
+
+Orc.Rogue.Enable            = 1
+Orc.Warrior.Enable          = 1
+Orc.Hunter.Enable           = 1
+Orc.Warlock.Enable          = 1
+Orc.Shaman.Enable           = 1
+Orc.DeathKnight.Enable      = 1
+
+Forsaken.Priest.Enable      = 1
+Forsaken.Rogue.Enable       = 1
+Forsaken.Mage.Enable        = 1
+Forsaken.Warlock.Enable     = 1
+Forsaken.DeathKnight.Enable = 1
+
+Tauren.Warrior.Enable       = 1
+Tauren.Druid.Enable         = 1
+Tauren.Hunter.Enable        = 1
+Tauren.Shaman.Enable        = 1
+Tauren.DeathKnight.Enable   = 1
+
+Troll.Priest.Enable         = 1
+Troll.Rogue.Enable          = 1
+Troll.Warrior.Enable        = 1
+Troll.Mage.Enable           = 1
+Troll.Hunter.Enable         = 1
+Troll.Shaman.Enable         = 1
+Troll.DeathKnight.Enable    = 1
+
+BloodElf.Priest.Enable      = 1
+BloodElf.Rogue.Enable       = 1
+BloodElf.Mage.Enable        = 1
+BloodElf.Hunter.Enable      = 1
+BloodElf.Warlock.Enable     = 1
+BloodElf.Paladin.Enable     = 1
+BloodElf.DeathKnight.Enable = 1

Link to comment
Share on other sites

Well, MaNGOS is a learning project.

How about providng an example of these masks, for the benefit of this patch and education of everyone curious to know?

For those wanting to learn, you need teachers. Though the lessons come from artificial or human repositories of knowledge, only the human aspect can teach the art of reason where artificial methods can only impart technical details.

Link to comment
Share on other sites

So perhaps you might have a configuration option where 0 = allow and 1 = block.

Allowed.Races
To disable specific player races, use a value of 1.
Human  = 0
Dark Elf = 0
Dwarf   = 0
Gnome  = 0
.......

Allowed.Classes
To disable specific player classes, use a value of 1
Warrior = 0
Paladin = 0
Hunter = 0
Mage   = 0
........

For those entries marked with 1 (true), you might then add the masks together and use the sum as the input value for...?

...and this is as far as I've gotten with it. Sorry to say I'm only on lesson #4, CASE-SWITCH, in my C++ home studies.

I suppose you might also just use the two line approach by simply using the sum of the masks as the setting in the config file, but using the on/off switches for each one seems less prone to error on the part of the server admin.

Link to comment
Share on other sites

if you have a problem, don't start with the coding, but start with thinking:

Flags mean:

if you have a few values, which can be 1 or 0, then each combination of these possibilites (given a defined order for the values) are equivalent to an unique number:

example: Values A_4, A_3, A_2, A_1, A_0 (nightelf, drainei, human, dwarf, gnome in example)

then the bit pattern 10101 represents for example the number:1*2^4 + 0*2^3+1*2^2+0*2^1+1*2^0 = 21

So you could encode every possible Allowed (1) denied(0) combination for allieance with a number <= 31.

Just as a remark on the idea behind flags :P

An hint for the implementation: A number n "has" a flag f if (n & f)

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use