[10941] More strict check player race/class allowed values.

This commit is contained in:
VladimirMangos 2010-12-30 06:46:27 +03:00
parent b325e93538
commit 16768da053
3 changed files with 32 additions and 31 deletions

View file

@ -204,7 +204,7 @@ bool Guild::AddMember(ObjectGuid plGuid, uint32 plRank)
newmember.accountId = fields[4].GetInt32(); newmember.accountId = fields[4].GetInt32();
delete result; delete result;
if (newmember.Level < 1 || newmember.Level > STRONG_MAX_LEVEL || if (newmember.Level < 1 || newmember.Level > STRONG_MAX_LEVEL ||
newmember.Class < CLASS_WARRIOR || newmember.Class >= MAX_CLASSES) !((1 << (newmember.Class-1)) & CLASSMASK_ALL_PLAYABLE))
{ {
sLog.outError("%s has a broken data in field `characters` table, cannot add him to guild.", plGuid.GetString().c_str()); sLog.outError("%s has a broken data in field `characters` table, cannot add him to guild.", plGuid.GetString().c_str());
return false; return false;
@ -456,7 +456,7 @@ bool Guild::LoadMembersFromDB(QueryResult *guildMembersResult)
// the zone through xy coords .. this is a bit redundant, but shouldn't be called often // the zone through xy coords .. this is a bit redundant, but shouldn't be called often
newmember.ZoneId = Player::GetZoneIdFromDB(newmember.guid); newmember.ZoneId = Player::GetZoneIdFromDB(newmember.guid);
} }
if (newmember.Class < CLASS_WARRIOR || newmember.Class >= MAX_CLASSES) // can be at broken `class` field if (!((1 << (newmember.Class-1)) & CLASSMASK_ALL_PLAYABLE)) // can be at broken `class` field
{ {
sLog.outError("%s has a broken data in field `characters`.`class`, deleting him from guild!", newmember.guid.GetString().c_str()); sLog.outError("%s has a broken data in field `characters`.`class`, deleting him from guild!", newmember.guid.GetString().c_str());
CharacterDatabase.PExecute("DELETE FROM guild_member WHERE guid = '%u'", lowguid); CharacterDatabase.PExecute("DELETE FROM guild_member WHERE guid = '%u'", lowguid);

View file

@ -2764,26 +2764,15 @@ void ObjectMgr::LoadPlayerInfo()
float positionZ = fields[6].GetFloat(); float positionZ = fields[6].GetFloat();
float orientation = fields[7].GetFloat(); float orientation = fields[7].GetFloat();
if(current_race >= MAX_RACES)
{
sLog.outErrorDb("Wrong race %u in `playercreateinfo` table, ignoring.",current_race);
continue;
}
ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(current_race); ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(current_race);
if(!rEntry) if(!rEntry || !((1 << (current_race-1)) & RACEMASK_ALL_PLAYABLE))
{ {
sLog.outErrorDb("Wrong race %u in `playercreateinfo` table, ignoring.",current_race); sLog.outErrorDb("Wrong race %u in `playercreateinfo` table, ignoring.",current_race);
continue; continue;
} }
if(current_class >= MAX_CLASSES) ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(current_class);
{ if(!cEntry || !((1 << (current_class-1)) & CLASSMASK_ALL_PLAYABLE))
sLog.outErrorDb("Wrong class %u in `playercreateinfo` table, ignoring.",current_class);
continue;
}
if(!sChrClassesStore.LookupEntry(current_class))
{ {
sLog.outErrorDb("Wrong class %u in `playercreateinfo` table, ignoring.",current_class); sLog.outErrorDb("Wrong class %u in `playercreateinfo` table, ignoring.",current_class);
continue; continue;
@ -2850,14 +2839,17 @@ void ObjectMgr::LoadPlayerInfo()
Field* fields = result->Fetch(); Field* fields = result->Fetch();
uint32 current_race = fields[0].GetUInt32(); uint32 current_race = fields[0].GetUInt32();
if(current_race >= MAX_RACES) uint32 current_class = fields[1].GetUInt32();
ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(current_race);
if(!rEntry || !((1 << (current_race-1)) & RACEMASK_ALL_PLAYABLE))
{ {
sLog.outErrorDb("Wrong race %u in `playercreateinfo_item` table, ignoring.",current_race); sLog.outErrorDb("Wrong race %u in `playercreateinfo_item` table, ignoring.",current_race);
continue; continue;
} }
uint32 current_class = fields[1].GetUInt32(); ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(current_class);
if(current_class >= MAX_CLASSES) if(!cEntry || !((1 << (current_class-1)) & CLASSMASK_ALL_PLAYABLE))
{ {
sLog.outErrorDb("Wrong class %u in `playercreateinfo_item` table, ignoring.",current_class); sLog.outErrorDb("Wrong class %u in `playercreateinfo_item` table, ignoring.",current_class);
continue; continue;
@ -2919,14 +2911,17 @@ void ObjectMgr::LoadPlayerInfo()
Field* fields = result->Fetch(); Field* fields = result->Fetch();
uint32 current_race = fields[0].GetUInt32(); uint32 current_race = fields[0].GetUInt32();
if(current_race >= MAX_RACES) uint32 current_class = fields[1].GetUInt32();
ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(current_race);
if(!rEntry || !((1 << (current_race-1)) & RACEMASK_ALL_PLAYABLE))
{ {
sLog.outErrorDb("Wrong race %u in `playercreateinfo_spell` table, ignoring.",current_race); sLog.outErrorDb("Wrong race %u in `playercreateinfo_spell` table, ignoring.",current_race);
continue; continue;
} }
uint32 current_class = fields[1].GetUInt32(); ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(current_class);
if(current_class >= MAX_CLASSES) if(!cEntry || !((1 << (current_class-1)) & CLASSMASK_ALL_PLAYABLE))
{ {
sLog.outErrorDb("Wrong class %u in `playercreateinfo_spell` table, ignoring.",current_class); sLog.outErrorDb("Wrong class %u in `playercreateinfo_spell` table, ignoring.",current_class);
continue; continue;
@ -2978,14 +2973,17 @@ void ObjectMgr::LoadPlayerInfo()
Field* fields = result->Fetch(); Field* fields = result->Fetch();
uint32 current_race = fields[0].GetUInt32(); uint32 current_race = fields[0].GetUInt32();
if(current_race >= MAX_RACES) uint32 current_class = fields[1].GetUInt32();
ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(current_race);
if(!rEntry || !((1 << (current_race-1)) & RACEMASK_ALL_PLAYABLE))
{ {
sLog.outErrorDb("Wrong race %u in `playercreateinfo_action` table, ignoring.",current_race); sLog.outErrorDb("Wrong race %u in `playercreateinfo_action` table, ignoring.",current_race);
continue; continue;
} }
uint32 current_class = fields[1].GetUInt32(); ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(current_class);
if(current_class >= MAX_CLASSES) if(!cEntry || !((1 << (current_class-1)) & CLASSMASK_ALL_PLAYABLE))
{ {
sLog.outErrorDb("Wrong class %u in `playercreateinfo_action` table, ignoring.",current_class); sLog.outErrorDb("Wrong class %u in `playercreateinfo_action` table, ignoring.",current_class);
continue; continue;
@ -3136,14 +3134,17 @@ void ObjectMgr::LoadPlayerInfo()
Field* fields = result->Fetch(); Field* fields = result->Fetch();
uint32 current_race = fields[0].GetUInt32(); uint32 current_race = fields[0].GetUInt32();
if(current_race >= MAX_RACES) uint32 current_class = fields[1].GetUInt32();
ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(current_race);
if(!rEntry || !((1 << (current_race-1)) & RACEMASK_ALL_PLAYABLE))
{ {
sLog.outErrorDb("Wrong race %u in `player_levelstats` table, ignoring.",current_race); sLog.outErrorDb("Wrong race %u in `player_levelstats` table, ignoring.",current_race);
continue; continue;
} }
uint32 current_class = fields[1].GetUInt32(); ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(current_class);
if(current_class >= MAX_CLASSES) if(!cEntry || !((1 << (current_class-1)) & CLASSMASK_ALL_PLAYABLE))
{ {
sLog.outErrorDb("Wrong class %u in `player_levelstats` table, ignoring.",current_class); sLog.outErrorDb("Wrong class %u in `player_levelstats` table, ignoring.",current_class);
continue; continue;
@ -3189,13 +3190,13 @@ void ObjectMgr::LoadPlayerInfo()
for (int race = 0; race < MAX_RACES; ++race) for (int race = 0; race < MAX_RACES; ++race)
{ {
// skip nonexistent races // skip nonexistent races
if(!sChrRacesStore.LookupEntry(race)) if(!((1 << (race-1)) & RACEMASK_ALL_PLAYABLE) || !sChrRacesStore.LookupEntry(race))
continue; continue;
for (int class_ = 0; class_ < MAX_CLASSES; ++class_) for (int class_ = 0; class_ < MAX_CLASSES; ++class_)
{ {
// skip nonexistent classes // skip nonexistent classes
if(!sChrClassesStore.LookupEntry(class_)) if(!((1 << (class_-1)) & CLASSMASK_ALL_PLAYABLE) || !sChrClassesStore.LookupEntry(class_))
continue; continue;
PlayerInfo* pInfo = &playerInfo[race][class_]; PlayerInfo* pInfo = &playerInfo[race][class_];

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "10940" #define REVISION_NR "10941"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__