[6937] Implement another character level requirement for heroic character creating.

Add option to mangosd.conf for set required level for this limitation or let disable limitation.
This commit is contained in:
VladimirMangos 2008-12-24 05:51:53 +03:00
parent e6e35f38d1
commit eeabb03e2d
5 changed files with 60 additions and 13 deletions

View file

@ -317,24 +317,37 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
return;
}
// speedup check for heroic class disabled case
uint32 req_level_for_heroic = sWorld.getConfig(CONFIG_MIN_LEVEL_FOR_HEROIC_CHARACTER_CREATING);
if(GetSecurity()==SEC_PLAYER && class_ == CLASS_DEATH_KNIGHT && req_level_for_heroic > sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL))
{
data << (uint8)CHAR_CREATE_LEVEL_REQUIREMENT;
SendPacket( &data );
return;
}
bool AllowTwoSideAccounts = !sWorld.IsPvPRealm() || sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_ACCOUNTS) || GetSecurity() > SEC_PLAYER;
uint32 skipCinematics = sWorld.getConfig(CONFIG_SKIP_CINEMATICS);
bool have_same_race = false;
// if 0 then allowed creating without any characters
bool have_req_level_for_heroic = (req_level_for_heroic==0);
if(!AllowTwoSideAccounts || skipCinematics == 1 || class_ == CLASS_DEATH_KNIGHT)
{
QueryResult *result2 = CharacterDatabase.PQuery("SELECT race,class FROM characters WHERE account = '%u' %s",
QueryResult *result2 = CharacterDatabase.PQuery("SELECT guid,race,class FROM characters WHERE account = '%u' %s",
GetAccountId(), (skipCinematics == 1 || class_ == CLASS_DEATH_KNIGHT) ? "" : "LIMIT 1");
if(result2)
{
uint32 team_= Player::TeamForRace(race_);
Field* field = result2->Fetch();
uint8 acc_race = field[0].GetUInt32();
uint8 acc_race = field[1].GetUInt32();
if(GetSecurity()==SEC_PLAYER && class_ == CLASS_DEATH_KNIGHT)
{
uint8 acc_class = field[1].GetUInt32();
uint8 acc_class = field[2].GetUInt32();
if(acc_class == CLASS_DEATH_KNIGHT)
{
if(heroic_free_slots > 0)
@ -347,6 +360,14 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
return;
}
}
if(!have_req_level_for_heroic)
{
uint32 acc_guid = field[0].GetUInt32();
uint32 acc_level = Player::GetUInt32ValueFromDB(UNIT_FIELD_LEVEL,acc_guid);
if(acc_level >= req_level_for_heroic)
have_req_level_for_heroic = true;
}
}
// need to check team only for first character
@ -374,14 +395,14 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
break;
field = result2->Fetch();
acc_race = field[0].GetUInt32();
acc_race = field[1].GetUInt32();
if(!have_same_race)
have_same_race = race_ == acc_race;
if(GetSecurity()==SEC_PLAYER && class_ == CLASS_DEATH_KNIGHT)
{
uint8 acc_class = field[1].GetUInt32();
uint8 acc_class = field[2].GetUInt32();
if(acc_class == CLASS_DEATH_KNIGHT)
{
if(heroic_free_slots > 0)
@ -394,12 +415,27 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
return;
}
}
if(!have_req_level_for_heroic)
{
uint32 acc_guid = field[0].GetUInt32();
uint32 acc_level = Player::GetUInt32ValueFromDB(UNIT_FIELD_LEVEL,acc_guid);
if(acc_level >= req_level_for_heroic)
have_req_level_for_heroic = true;
}
}
}
delete result2;
}
}
if(GetSecurity()==SEC_PLAYER && class_ == CLASS_DEATH_KNIGHT && !have_req_level_for_heroic)
{
data << (uint8)CHAR_CREATE_LEVEL_REQUIREMENT;
SendPacket( &data );
return;
}
// extract other data required for player creating
uint8 gender, skin, face, hairStyle, hairColor, facialHair, outfitId;
recv_data >> gender >> skin >> face;

View file

@ -633,13 +633,6 @@ 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])
@ -648,6 +641,15 @@ void World::LoadConfigSettings(bool reload)
m_configs[CONFIG_CHARACTERS_PER_ACCOUNT] = m_configs[CONFIG_CHARACTERS_PER_REALM];
}
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;
}
m_configs[CONFIG_MIN_LEVEL_FOR_HEROIC_CHARACTER_CREATING] = sConfig.GetIntDefault("MinLevelForHeroicCharacterCreating", 55);
m_configs[CONFIG_SKIP_CINEMATICS] = sConfig.GetIntDefault("SkipCinematics", 0);
if(m_configs[CONFIG_SKIP_CINEMATICS] < 0 || m_configs[CONFIG_SKIP_CINEMATICS] > 2)
{

View file

@ -101,6 +101,7 @@ enum WorldConfigs
CONFIG_CHARACTERS_PER_ACCOUNT,
CONFIG_CHARACTERS_PER_REALM,
CONFIG_HEROIC_CHARACTERS_PER_REALM,
CONFIG_MIN_LEVEL_FOR_HEROIC_CHARACTER_CREATING,
CONFIG_SKIP_CINEMATICS,
CONFIG_MAX_PLAYER_LEVEL,
CONFIG_START_PLAYER_LEVEL,

View file

@ -413,6 +413,13 @@ LogColors = ""
# Default: 1
# The number must be between 0 (not allowed) and 10
#
# MinLevelForHeroicCharacterCreating
# Limit creating heroic characters only for account with another character of specific level (ignored for GM accounts)
# 0 - not require any existed chaarcter
# 1 - require at least any character existed
# Default: 55 - default requirement
#
#
# 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
@ -580,6 +587,7 @@ CharactersCreatingDisabled = 0
CharactersPerAccount = 50
CharactersPerRealm = 10
HeroicCharactersPerRealm = 1
MinLevelForHeroicCharacterCreating = 55
SkipCinematics = 0
MaxPlayerLevel = 80
StartPlayerLevel = 1

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "6936"
#define REVISION_NR "6937"
#endif // __REVISION_NR_H__