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

(cherry picked from commit 389a1784e288f11587067d3a6d4b70cce9214cb9)

Conflicts:

	src/game/Player.cpp
	src/game/World.cpp
	src/shared/Database/DBCStructure.h
This commit is contained in:
VladimirMangos 2008-12-14 23:52:32 +03:00
parent 5113af643e
commit 35f54d365d
7 changed files with 37 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

@ -3805,8 +3805,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

@ -80,7 +80,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
@ -145,8 +145,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

@ -1909,8 +1909,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;
@ -2286,8 +2286,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;
@ -2381,8 +2381,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

@ -650,10 +650,11 @@ 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] > 255)
if(m_configs[CONFIG_MAX_PLAYER_LEVEL] > MAX_LEVEL)
{ {
sLog.outError("MaxPlayerLevel (%i) must be in range 1..255. Set to 255.",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] = 255; 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);
@ -756,14 +757,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)..255. 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] > 255) else if(m_configs[CONFIG_START_GM_LEVEL] > MAX_LEVEL)
{ {
sLog.outError("GM.StartLevel (%i) must be in range 1..255. Set to %u.",m_configs[CONFIG_START_GM_LEVEL],255); 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] = 255; 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);
@ -854,13 +855,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 (255) // 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] > 255) if(m_configs[CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF] > MAX_LEVEL)
m_configs[CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF] = 255; 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] > 255) if(m_configs[CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF] > MAX_LEVEL)
m_configs[CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF] = 255; 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

@ -267,6 +267,7 @@ struct GemPropertiesEntry
uint32 color; uint32 color;
}; };
// 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 GtCombatRatingsEntry struct GtCombatRatingsEntry