Replace hardcoded client(100) and server side (255) level limtation values by defines.

This commit is contained in:
VladimirMangos 2008-12-14 22:18:52 +03:00
parent 09e8ea2ae6
commit c798318b7b
8 changed files with 36 additions and 27 deletions

View file

@ -363,7 +363,7 @@ bool Guild::FillPlayerData(uint64 guid, MemberSlot* memslot)
return false; return false;
plLevel = Player::GetUInt32ValueFromDB(UNIT_FIELD_LEVEL, guid); plLevel = Player::GetUInt32ValueFromDB(UNIT_FIELD_LEVEL, guid);
if(plLevel<1||plLevel>255) // can be at broken `data` field if(plLevel<1||plLevel>STRONG_MAX_LEVEL) // can be at broken `data` field
{ {
sLog.outError("Player (GUID: %u) has a broken data in field `characters`.`data`.",GUID_LOPART(guid)); sLog.outError("Player (GUID: %u) has a broken data in field `characters`.`data`.",GUID_LOPART(guid));
return false; return false;

View file

@ -3814,8 +3814,8 @@ bool ChatHandler::HandleLevelUpCommand(const char* args)
int32 newlevel = oldlevel + addlevel; int32 newlevel = oldlevel + addlevel;
if(newlevel < 1) if(newlevel < 1)
newlevel = 1; newlevel = 1;
if(newlevel > 255) // hardcoded maximum level if(newlevel > STRONG_MAX_LEVEL) // hardcoded maximum level
newlevel = 255; newlevel = STRONG_MAX_LEVEL;
if(chr) if(chr)
{ {

View file

@ -81,7 +81,7 @@ void WorldSession::HandleWhoOpcode( WorldPacket & recv_data )
std::string player_name, guild_name; std::string player_name, guild_name;
recv_data >> level_min; // maximal player level, default 0 recv_data >> level_min; // maximal player level, default 0
recv_data >> level_max; // minimal player level, default 100 recv_data >> level_max; // minimal player level, default 100 (MAX_LEVEL)
recv_data >> player_name; // player name, case sensitive... recv_data >> player_name; // player name, case sensitive...
// recheck // recheck
@ -146,8 +146,8 @@ void WorldSession::HandleWhoOpcode( WorldPacket & recv_data )
// client send in case not set max level value 100 but mangos support 255 max level, // client send in case not set max level value 100 but mangos support 255 max level,
// update it to show GMs with characters after 100 level // update it to show GMs with characters after 100 level
if(level_max >= 100) if(level_max >= MAX_LEVEL)
level_max = 255; level_max = STRONG_MAX_LEVEL;
uint32 team = _player->GetTeam(); uint32 team = _player->GetTeam();
uint32 security = GetSecurity(); uint32 security = GetSecurity();

View file

@ -1962,8 +1962,8 @@ void ObjectMgr::LoadPetLevelInfo()
uint32 current_level = fields[1].GetUInt32(); uint32 current_level = fields[1].GetUInt32();
if(current_level > sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)) if(current_level > sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL))
{ {
if(current_level > 255) // hardcoded level maximum if(current_level > STRONG_MAX_LEVEL) // hardcoded level maximum
sLog.outErrorDb("Wrong (> 255) level %u in `pet_levelstats` table, ignoring.",current_level); sLog.outErrorDb("Wrong (> %u) level %u in `pet_levelstats` table, ignoring.",STRONG_MAX_LEVEL,current_level);
else else
sLog.outDetail("Unused (> MaxPlayerLevel in mangosd.conf) level %u in `pet_levelstats` table, ignoring.",current_level); sLog.outDetail("Unused (> MaxPlayerLevel in mangosd.conf) level %u in `pet_levelstats` table, ignoring.",current_level);
continue; continue;
@ -2339,8 +2339,8 @@ void ObjectMgr::LoadPlayerInfo()
uint32 current_level = fields[1].GetUInt32(); uint32 current_level = fields[1].GetUInt32();
if(current_level > sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)) if(current_level > sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL))
{ {
if(current_level > 255) // hardcoded level maximum if(current_level > STRONG_MAX_LEVEL) // hardcoded level maximum
sLog.outErrorDb("Wrong (> 255) level %u in `player_classlevelstats` table, ignoring.",current_level); sLog.outErrorDb("Wrong (> %u) level %u in `player_classlevelstats` table, ignoring.",STRONG_MAX_LEVEL,current_level);
else else
sLog.outDetail("Unused (> MaxPlayerLevel in mangosd.conf) level %u in `player_classlevelstats` table, ignoring.",current_level); sLog.outDetail("Unused (> MaxPlayerLevel in mangosd.conf) level %u in `player_classlevelstats` table, ignoring.",current_level);
continue; continue;
@ -2434,8 +2434,8 @@ void ObjectMgr::LoadPlayerInfo()
uint32 current_level = fields[2].GetUInt32(); uint32 current_level = fields[2].GetUInt32();
if(current_level > sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)) if(current_level > sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL))
{ {
if(current_level > 255) // hardcoded level maximum if(current_level > STRONG_MAX_LEVEL) // hardcoded level maximum
sLog.outErrorDb("Wrong (> 255) level %u in `player_levelstats` table, ignoring.",current_level); sLog.outErrorDb("Wrong (> %u) level %u in `player_levelstats` table, ignoring.",STRONG_MAX_LEVEL,current_level);
else else
sLog.outDetail("Unused (> MaxPlayerLevel in mangosd.conf) level %u in `player_levelstats` table, ignoring.",current_level); sLog.outDetail("Unused (> MaxPlayerLevel in mangosd.conf) level %u in `player_levelstats` table, ignoring.",current_level);
continue; continue;

View file

@ -18719,7 +18719,7 @@ uint32 Player::GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 n
{ {
uint32 level = getLevel(); uint32 level = getLevel();
if(level > sGtBarberShopCostBaseStore.GetNumRows()) if(level > GT_MAX_LEVEL)
level = GT_MAX_LEVEL; // max level in this dbc level = GT_MAX_LEVEL; // max level in this dbc
uint8 hairstyle = GetByteValue(PLAYER_BYTES, 2); uint8 hairstyle = GetByteValue(PLAYER_BYTES, 2);

View file

@ -657,10 +657,10 @@ void World::LoadConfigSettings(bool reload)
else else
m_configs[CONFIG_MAX_PLAYER_LEVEL] = sConfig.GetIntDefault("MaxPlayerLevel", 60); m_configs[CONFIG_MAX_PLAYER_LEVEL] = sConfig.GetIntDefault("MaxPlayerLevel", 60);
if(m_configs[CONFIG_MAX_PLAYER_LEVEL] > 100) if(m_configs[CONFIG_MAX_PLAYER_LEVEL] > MAX_LEVEL)
{ {
sLog.outError("MaxPlayerLevel (%i) must be in range 1..100. Set to 100.",m_configs[CONFIG_MAX_PLAYER_LEVEL]); sLog.outError("MaxPlayerLevel (%i) must be in range 1..%u. Set to %u.",m_configs[CONFIG_MAX_PLAYER_LEVEL],MAX_LEVEL,MAX_LEVEL);
m_configs[CONFIG_MAX_PLAYER_LEVEL] = 100; m_configs[CONFIG_MAX_PLAYER_LEVEL] = MAX_LEVEL;
} }
m_configs[CONFIG_START_PLAYER_LEVEL] = sConfig.GetIntDefault("StartPlayerLevel", 1); m_configs[CONFIG_START_PLAYER_LEVEL] = sConfig.GetIntDefault("StartPlayerLevel", 1);
@ -763,14 +763,14 @@ void World::LoadConfigSettings(bool reload)
m_configs[CONFIG_START_GM_LEVEL] = sConfig.GetIntDefault("GM.StartLevel", 1); m_configs[CONFIG_START_GM_LEVEL] = sConfig.GetIntDefault("GM.StartLevel", 1);
if(m_configs[CONFIG_START_GM_LEVEL] < m_configs[CONFIG_START_PLAYER_LEVEL]) if(m_configs[CONFIG_START_GM_LEVEL] < m_configs[CONFIG_START_PLAYER_LEVEL])
{ {
sLog.outError("GM.StartLevel (%i) must be in range StartPlayerLevel(%u)..100. Set to %u.", sLog.outError("GM.StartLevel (%i) must be in range StartPlayerLevel(%u)..%u. Set to %u.",
m_configs[CONFIG_START_GM_LEVEL],m_configs[CONFIG_START_PLAYER_LEVEL], m_configs[CONFIG_START_PLAYER_LEVEL]); m_configs[CONFIG_START_GM_LEVEL],m_configs[CONFIG_START_PLAYER_LEVEL], MAX_LEVEL, m_configs[CONFIG_START_PLAYER_LEVEL]);
m_configs[CONFIG_START_GM_LEVEL] = m_configs[CONFIG_START_PLAYER_LEVEL]; m_configs[CONFIG_START_GM_LEVEL] = m_configs[CONFIG_START_PLAYER_LEVEL];
} }
else if(m_configs[CONFIG_START_GM_LEVEL] > 100) else if(m_configs[CONFIG_START_GM_LEVEL] > MAX_LEVEL)
{ {
sLog.outError("GM.StartLevel (%i) must be in range 1..100. Set to %u.", m_configs[CONFIG_START_GM_LEVEL], 100); sLog.outError("GM.StartLevel (%i) must be in range 1..%u. Set to %u.", m_configs[CONFIG_START_GM_LEVEL], MAX_LEVEL, MAX_LEVEL);
m_configs[CONFIG_START_GM_LEVEL] = 100; m_configs[CONFIG_START_GM_LEVEL] = MAX_LEVEL;
} }
m_configs[CONFIG_GROUP_VISIBILITY] = sConfig.GetIntDefault("Visibility.GroupMode",0); m_configs[CONFIG_GROUP_VISIBILITY] = sConfig.GetIntDefault("Visibility.GroupMode",0);
@ -862,13 +862,13 @@ void World::LoadConfigSettings(bool reload)
m_configs[CONFIG_WORLD_BOSS_LEVEL_DIFF] = sConfig.GetIntDefault("WorldBossLevelDiff",3); m_configs[CONFIG_WORLD_BOSS_LEVEL_DIFF] = sConfig.GetIntDefault("WorldBossLevelDiff",3);
// note: disable value (-1) will assigned as 0xFFFFFFF, to prevent overflow at calculations limit it to max possible player level (100) // note: disable value (-1) will assigned as 0xFFFFFFF, to prevent overflow at calculations limit it to max possible player level MAX_LEVEL(100)
m_configs[CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF] = sConfig.GetIntDefault("Quests.LowLevelHideDiff", 4); m_configs[CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF] = sConfig.GetIntDefault("Quests.LowLevelHideDiff", 4);
if(m_configs[CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF] > 100) if(m_configs[CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF] > MAX_LEVEL)
m_configs[CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF] = 100; m_configs[CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF] = MAX_LEVEL;
m_configs[CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF] = sConfig.GetIntDefault("Quests.HighLevelHideDiff", 7); m_configs[CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF] = sConfig.GetIntDefault("Quests.HighLevelHideDiff", 7);
if(m_configs[CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF] > 100) if(m_configs[CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF] > MAX_LEVEL)
m_configs[CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF] = 100; m_configs[CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF] = MAX_LEVEL;
m_configs[CONFIG_DETECT_POS_COLLISION] = sConfig.GetBoolDefault("DetectPosCollision", true); m_configs[CONFIG_DETECT_POS_COLLISION] = sConfig.GetBoolDefault("DetectPosCollision", true);

View file

@ -19,6 +19,14 @@
#ifndef DBCENUMS_H #ifndef DBCENUMS_H
#define DBCENUMS_H #define DBCENUMS_H
// client supported max level for player/pets/etc. Avoid overflow or client stability affected.
// also see GT_MAX_LEVEL define
#define MAX_LEVEL 100
// Server side limitation. Base at used code requirements.
// also see MAX_LEVEL and GT_MAX_LEVEL define
#define STRONG_MAX_LEVEL 255
enum AreaTeams enum AreaTeams
{ {
AREATEAM_NONE = 0, AREATEAM_NONE = 0,

View file

@ -741,6 +741,7 @@ struct GlyphSlotEntry
uint32 Order; uint32 Order;
}; };
// All Gt* DBC store data for 100 levels, some by 100 per class/race
#define GT_MAX_LEVEL 100 #define GT_MAX_LEVEL 100
struct GtBarberShopCostBaseEntry struct GtBarberShopCostBaseEntry