From c1ae939fb1f0853f3d816eac77644be4ad470782 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Sun, 21 Dec 2008 04:40:40 +0300 Subject: [PATCH] Implement new mangos.conf setting HeroicCharactersPerRealm for set cstiom (default 1) amount heroic class chanarcters for account per realm. Note: set option to 0 disable heroic characters creating. Also non-player account not have now any limits (except 10 clinet limit) for heroic characters creating. --- src/game/CharacterHandler.cpp | 37 +++++++++++++++++++++++++------- src/game/Player.cpp | 5 +++++ src/game/World.cpp | 7 ++++++ src/game/World.h | 1 + src/mangosd/mangosd.conf.dist.in | 6 ++++++ 5 files changed, 48 insertions(+), 8 deletions(-) diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp index 04f003fc6..903a4a082 100644 --- a/src/game/CharacterHandler.cpp +++ b/src/game/CharacterHandler.cpp @@ -308,6 +308,15 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data ) } } + // speedup check for heroic class disabled case + uint32 heroic_free_slots = sWorld.getConfig(CONFIG_HEROIC_CHARACTERS_PER_REALM); + if(heroic_free_slots==0 && GetSecurity()==SEC_PLAYER && class_ == CLASS_DEATH_KNIGHT) + { + data << (uint8)CHAR_CREATE_UNIQUE_CLASS_LIMIT; + SendPacket( &data ); + return; + } + bool AllowTwoSideAccounts = !sWorld.IsPvPRealm() || sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_ACCOUNTS) || GetSecurity() > SEC_PLAYER; uint32 skipCinematics = sWorld.getConfig(CONFIG_SKIP_CINEMATICS); @@ -323,14 +332,20 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data ) Field* field = result2->Fetch(); uint8 acc_race = field[0].GetUInt32(); - if(class_ == CLASS_DEATH_KNIGHT) + if(GetSecurity()==SEC_PLAYER && class_ == CLASS_DEATH_KNIGHT) { uint8 acc_class = field[1].GetUInt32(); if(acc_class == CLASS_DEATH_KNIGHT) { - data << (uint8)CHAR_CREATE_UNIQUE_CLASS_LIMIT; - SendPacket( &data ); - return; + if(heroic_free_slots > 0) + --heroic_free_slots; + + if(heroic_free_slots==0) + { + data << (uint8)CHAR_CREATE_UNIQUE_CLASS_LIMIT; + SendPacket( &data ); + return; + } } } @@ -364,14 +379,20 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data ) if(!have_same_race) have_same_race = race_ == acc_race; - if(class_ == CLASS_DEATH_KNIGHT) + if(GetSecurity()==SEC_PLAYER && class_ == CLASS_DEATH_KNIGHT) { uint8 acc_class = field[1].GetUInt32(); if(acc_class == CLASS_DEATH_KNIGHT) { - data << (uint8)CHAR_CREATE_UNIQUE_CLASS_LIMIT; - SendPacket( &data ); - return; + if(heroic_free_slots > 0) + --heroic_free_slots; + + if(heroic_free_slots==0) + { + data << (uint8)CHAR_CREATE_UNIQUE_CLASS_LIMIT; + SendPacket( &data ); + return; + } } } } diff --git a/src/game/Player.cpp b/src/game/Player.cpp index deac9c543..259ec5f27 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -690,6 +690,11 @@ bool Player::Create( uint32 guidlow, const std::string& name, uint8 race, uint8 uint32 item_id = oEntry->ItemId[j]; + + // Hack for not existed item id in dbc 3.0.3 + if(item_id==40582) + continue; + ItemPrototype const* iProto = objmgr.GetItemPrototype(item_id); if(!iProto) { diff --git a/src/game/World.cpp b/src/game/World.cpp index d7ed8de6b..6fa9a3088 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -633,6 +633,13 @@ void World::LoadConfigSettings(bool reload) m_configs[CONFIG_CHARACTERS_PER_REALM] = 10; } + m_configs[CONFIG_HEROIC_CHARACTERS_PER_REALM] = sConfig.GetIntDefault("HeroicCharactersPerRealm", 1); + if(m_configs[CONFIG_HEROIC_CHARACTERS_PER_REALM] < 0 || m_configs[CONFIG_HEROIC_CHARACTERS_PER_REALM] > 10) + { + sLog.outError("HeroicCharactersPerRealm (%i) must be in range 0..10. Set to 1.",m_configs[CONFIG_HEROIC_CHARACTERS_PER_REALM]); + m_configs[CONFIG_HEROIC_CHARACTERS_PER_REALM] = 1; + } + // must be after CONFIG_CHARACTERS_PER_REALM m_configs[CONFIG_CHARACTERS_PER_ACCOUNT] = sConfig.GetIntDefault("CharactersPerAccount", 50); if(m_configs[CONFIG_CHARACTERS_PER_ACCOUNT] < m_configs[CONFIG_CHARACTERS_PER_REALM]) diff --git a/src/game/World.h b/src/game/World.h index 9e5b2ad50..57167bf83 100644 --- a/src/game/World.h +++ b/src/game/World.h @@ -100,6 +100,7 @@ enum WorldConfigs CONFIG_CHARACTERS_CREATING_DISABLED, CONFIG_CHARACTERS_PER_ACCOUNT, CONFIG_CHARACTERS_PER_REALM, + CONFIG_HEROIC_CHARACTERS_PER_REALM, CONFIG_SKIP_CINEMATICS, CONFIG_MAX_PLAYER_LEVEL, CONFIG_START_PLAYER_LEVEL, diff --git a/src/mangosd/mangosd.conf.dist.in b/src/mangosd/mangosd.conf.dist.in index 08d0dbc01..2056bf98b 100644 --- a/src/mangosd/mangosd.conf.dist.in +++ b/src/mangosd/mangosd.conf.dist.in @@ -408,6 +408,11 @@ LogColors = "" # Default: 10 (client limitation) # The number must be between 1 and 10 # +# HeroicCharactersPerRealm +# Limit numbers of heroic class characters for account at realm +# Default: 1 +# The number must be between 0 (not allowed) and 10 +# # SkipCinematics # Disable in-game script movie at first character's login(allows to prevent buggy intro in case of custom start location coordinates) # Default: 0 - show intro for each new characrer @@ -574,6 +579,7 @@ StrictPetNames = 0 CharactersCreatingDisabled = 0 CharactersPerAccount = 50 CharactersPerRealm = 10 +HeroicCharactersPerRealm = 1 SkipCinematics = 0 MaxPlayerLevel = 80 StartPlayerLevel = 1