diff --git a/src/game/AccountMgr.cpp b/src/game/AccountMgr.cpp index b8e4d5523..c3823507e 100644 --- a/src/game/AccountMgr.cpp +++ b/src/game/AccountMgr.cpp @@ -37,18 +37,18 @@ AccountMgr::~AccountMgr() AccountOpResult AccountMgr::CreateAccount(std::string username, std::string password) { - if(utf8length(username) > MAX_ACCOUNT_STR) + if (utf8length(username) > MAX_ACCOUNT_STR) return AOR_NAME_TOO_LONG; // username's too long normalizeString(username); normalizeString(password); - if(GetId(username)) + if (GetId(username)) { return AOR_NAME_ALREDY_EXIST; // username does already exist } - if(!LoginDatabase.PExecute("INSERT INTO account(username,sha_pass_hash,joindate) VALUES('%s','%s',NOW())", username.c_str(), CalculateShaPassHash(username, password).c_str())) + if (!LoginDatabase.PExecute("INSERT INTO account(username,sha_pass_hash,joindate) VALUES('%s','%s',NOW())", username.c_str(), CalculateShaPassHash(username, password).c_str())) return AOR_DB_INTERNAL_ERROR; // unexpected error LoginDatabase.Execute("INSERT INTO realmcharacters (realmid, acctid, numchars) SELECT realmlist.id, account.id, 0 FROM realmlist,account LEFT JOIN realmcharacters ON acctid=account.id WHERE acctid IS NULL"); @@ -57,8 +57,8 @@ AccountOpResult AccountMgr::CreateAccount(std::string username, std::string pass AccountOpResult AccountMgr::DeleteAccount(uint32 accid) { - QueryResult *result = LoginDatabase.PQuery("SELECT 1 FROM account WHERE id='%u'", accid); - if(!result) + QueryResult* result = LoginDatabase.PQuery("SELECT 1 FROM account WHERE id='%u'", accid); + if (!result) return AOR_NAME_NOT_EXIST; // account doesn't exist delete result; @@ -68,14 +68,15 @@ AccountOpResult AccountMgr::DeleteAccount(uint32 accid) { do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 guidlo = fields[0].GetUInt32(); ObjectGuid guid = ObjectGuid(HIGHGUID_PLAYER, guidlo); // kick if player currently ObjectAccessor::KickPlayer(guid); Player::DeleteFromDB(guid, accid, false); // no need to update realm characters - } while (result->NextRow()); + } + while (result->NextRow()); delete result; } @@ -91,7 +92,7 @@ AccountOpResult AccountMgr::DeleteAccount(uint32 accid) LoginDatabase.CommitTransaction(); - if(!res) + if (!res) return AOR_DB_INTERNAL_ERROR; // unexpected error; return AOR_OK; @@ -99,15 +100,15 @@ AccountOpResult AccountMgr::DeleteAccount(uint32 accid) AccountOpResult AccountMgr::ChangeUsername(uint32 accid, std::string new_uname, std::string new_passwd) { - QueryResult *result = LoginDatabase.PQuery("SELECT 1 FROM account WHERE id='%u'", accid); - if(!result) + QueryResult* result = LoginDatabase.PQuery("SELECT 1 FROM account WHERE id='%u'", accid); + if (!result) return AOR_NAME_NOT_EXIST; // account doesn't exist delete result; - if(utf8length(new_uname) > MAX_ACCOUNT_STR) + if (utf8length(new_uname) > MAX_ACCOUNT_STR) return AOR_NAME_TOO_LONG; - if(utf8length(new_passwd) > MAX_ACCOUNT_STR) + if (utf8length(new_passwd) > MAX_ACCOUNT_STR) return AOR_PASS_TOO_LONG; normalizeString(new_uname); @@ -116,8 +117,8 @@ AccountOpResult AccountMgr::ChangeUsername(uint32 accid, std::string new_uname, std::string safe_new_uname = new_uname; LoginDatabase.escape_string(safe_new_uname); - if(!LoginDatabase.PExecute("UPDATE account SET v='0',s='0',username='%s',sha_pass_hash='%s' WHERE id='%u'", safe_new_uname.c_str(), - CalculateShaPassHash(new_uname, new_passwd).c_str(), accid)) + if (!LoginDatabase.PExecute("UPDATE account SET v='0',s='0',username='%s',sha_pass_hash='%s' WHERE id='%u'", safe_new_uname.c_str(), + CalculateShaPassHash(new_uname, new_passwd).c_str(), accid)) return AOR_DB_INTERNAL_ERROR; // unexpected error return AOR_OK; @@ -127,7 +128,7 @@ AccountOpResult AccountMgr::ChangePassword(uint32 accid, std::string new_passwd) { std::string username; - if(!GetName(accid, username)) + if (!GetName(accid, username)) return AOR_NAME_NOT_EXIST; // account doesn't exist if (utf8length(new_passwd) > MAX_ACCOUNT_STR) @@ -136,8 +137,8 @@ AccountOpResult AccountMgr::ChangePassword(uint32 accid, std::string new_passwd) normalizeString(new_passwd); // also reset s and v to force update at next realmd login - if(!LoginDatabase.PExecute("UPDATE account SET v='0', s='0', sha_pass_hash='%s' WHERE id='%u'", - CalculateShaPassHash(username, new_passwd).c_str(), accid)) + if (!LoginDatabase.PExecute("UPDATE account SET v='0', s='0', sha_pass_hash='%s' WHERE id='%u'", + CalculateShaPassHash(username, new_passwd).c_str(), accid)) return AOR_DB_INTERNAL_ERROR; // unexpected error return AOR_OK; @@ -146,8 +147,8 @@ AccountOpResult AccountMgr::ChangePassword(uint32 accid, std::string new_passwd) uint32 AccountMgr::GetId(std::string username) { LoginDatabase.escape_string(username); - QueryResult *result = LoginDatabase.PQuery("SELECT id FROM account WHERE username = '%s'", username.c_str()); - if(!result) + QueryResult* result = LoginDatabase.PQuery("SELECT id FROM account WHERE username = '%s'", username.c_str()); + if (!result) return 0; else { @@ -159,8 +160,8 @@ uint32 AccountMgr::GetId(std::string username) AccountTypes AccountMgr::GetSecurity(uint32 acc_id) { - QueryResult *result = LoginDatabase.PQuery("SELECT gmlevel FROM account WHERE id = '%u'", acc_id); - if(result) + QueryResult* result = LoginDatabase.PQuery("SELECT gmlevel FROM account WHERE id = '%u'", acc_id); + if (result) { AccountTypes sec = AccountTypes((*result)[0].GetInt32()); delete result; @@ -170,10 +171,10 @@ AccountTypes AccountMgr::GetSecurity(uint32 acc_id) return SEC_PLAYER; } -bool AccountMgr::GetName(uint32 acc_id, std::string &name) +bool AccountMgr::GetName(uint32 acc_id, std::string& name) { - QueryResult *result = LoginDatabase.PQuery("SELECT username FROM account WHERE id = '%u'", acc_id); - if(result) + QueryResult* result = LoginDatabase.PQuery("SELECT username FROM account WHERE id = '%u'", acc_id); + if (result) { name = (*result)[0].GetCppString(); delete result; @@ -186,10 +187,10 @@ bool AccountMgr::GetName(uint32 acc_id, std::string &name) uint32 AccountMgr::GetCharactersCount(uint32 acc_id) { // check character count - QueryResult *result = CharacterDatabase.PQuery("SELECT COUNT(guid) FROM characters WHERE account = '%u'", acc_id); + QueryResult* result = CharacterDatabase.PQuery("SELECT COUNT(guid) FROM characters WHERE account = '%u'", acc_id); if (result) { - Field *fields=result->Fetch(); + Field* fields=result->Fetch(); uint32 charcount = fields[0].GetUInt32(); delete result; return charcount; @@ -201,12 +202,12 @@ uint32 AccountMgr::GetCharactersCount(uint32 acc_id) bool AccountMgr::CheckPassword(uint32 accid, std::string passwd) { std::string username; - if(!GetName(accid, username)) + if (!GetName(accid, username)) return false; normalizeString(passwd); - QueryResult *result = LoginDatabase.PQuery("SELECT 1 FROM account WHERE id='%u' AND sha_pass_hash='%s'", accid, CalculateShaPassHash(username, passwd).c_str()); + QueryResult* result = LoginDatabase.PQuery("SELECT 1 FROM account WHERE id='%u' AND sha_pass_hash='%s'", accid, CalculateShaPassHash(username, passwd).c_str()); if (result) { delete result; @@ -221,10 +222,10 @@ bool AccountMgr::normalizeString(std::string& utf8str) wchar_t wstr_buf[MAX_ACCOUNT_STR+1]; size_t wstr_len = MAX_ACCOUNT_STR; - if(!Utf8toWStr(utf8str,wstr_buf,wstr_len)) + if (!Utf8toWStr(utf8str,wstr_buf,wstr_len)) return false; - std::transform( &wstr_buf[0], wstr_buf+wstr_len, &wstr_buf[0], wcharToUpperOnlyLatin ); + std::transform(&wstr_buf[0], wstr_buf+wstr_len, &wstr_buf[0], wcharToUpperOnlyLatin); return WStrToUtf8(wstr_buf,wstr_len,utf8str); } diff --git a/src/game/AccountMgr.h b/src/game/AccountMgr.h index a55c1b2cd..9771d1124 100644 --- a/src/game/AccountMgr.h +++ b/src/game/AccountMgr.h @@ -49,7 +49,7 @@ class AccountMgr uint32 GetId(std::string username); AccountTypes GetSecurity(uint32 acc_id); - bool GetName(uint32 acc_id, std::string &name); + bool GetName(uint32 acc_id, std::string& name); uint32 GetCharactersCount(uint32 acc_id); std::string CalculateShaPassHash(std::string& name, std::string& password); diff --git a/src/game/AchievementMgr.cpp b/src/game/AchievementMgr.cpp index bf42905fd..20123a54d 100644 --- a/src/game/AchievementMgr.cpp +++ b/src/game/AchievementMgr.cpp @@ -79,7 +79,7 @@ namespace MaNGOS bool AchievementCriteriaRequirement::IsValid(AchievementCriteriaEntry const* criteria) { - switch(criteria->requiredType) + switch (criteria->requiredType) { case ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE: case ACHIEVEMENT_CRITERIA_TYPE_WIN_BG: @@ -99,11 +99,11 @@ bool AchievementCriteriaRequirement::IsValid(AchievementCriteriaEntry const* cri case ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL2: break; default: - sLog.outErrorDb( "Table `achievement_criteria_requirement` have not supported data for criteria %u (Not supported as of its criteria type: %u), ignore.", criteria->ID, criteria->requiredType); + sLog.outErrorDb("Table `achievement_criteria_requirement` have not supported data for criteria %u (Not supported as of its criteria type: %u), ignore.", criteria->ID, criteria->requiredType); return false; } - switch(requirementType) + switch (requirementType) { case ACHIEVEMENT_CRITERIA_REQUIRE_NONE: case ACHIEVEMENT_CRITERIA_REQUIRE_VALUE: @@ -115,44 +115,44 @@ bool AchievementCriteriaRequirement::IsValid(AchievementCriteriaEntry const* cri case ACHIEVEMENT_CRITERIA_REQUIRE_T_CREATURE: if (!creature.id || !ObjectMgr::GetCreatureTemplate(creature.id)) { - sLog.outErrorDb( "Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_CREATURE (%u) have nonexistent creature id in value1 (%u), ignore.", - criteria->ID, criteria->requiredType,requirementType,creature.id); + sLog.outErrorDb("Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_CREATURE (%u) have nonexistent creature id in value1 (%u), ignore.", + criteria->ID, criteria->requiredType,requirementType,creature.id); return false; } return true; case ACHIEVEMENT_CRITERIA_REQUIRE_T_PLAYER_CLASS_RACE: if (!classRace.class_id && !classRace.race_id) { - sLog.outErrorDb( "Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_PLAYER_CLASS_RACE (%u) must have not 0 in one from value fields, ignore.", - criteria->ID, criteria->requiredType,requirementType); + sLog.outErrorDb("Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_PLAYER_CLASS_RACE (%u) must have not 0 in one from value fields, ignore.", + criteria->ID, criteria->requiredType,requirementType); return false; } if (classRace.class_id && ((1 << (classRace.class_id-1)) & CLASSMASK_ALL_PLAYABLE)==0) { - sLog.outErrorDb( "Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_CREATURE (%u) have nonexistent class in value1 (%u), ignore.", - criteria->ID, criteria->requiredType,requirementType,classRace.class_id); + sLog.outErrorDb("Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_CREATURE (%u) have nonexistent class in value1 (%u), ignore.", + criteria->ID, criteria->requiredType,requirementType,classRace.class_id); return false; } if (classRace.race_id && ((1 << (classRace.race_id-1)) & RACEMASK_ALL_PLAYABLE)==0) { - sLog.outErrorDb( "Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_CREATURE (%u) have nonexistent race in value2 (%u), ignore.", - criteria->ID, criteria->requiredType,requirementType,classRace.race_id); + sLog.outErrorDb("Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_CREATURE (%u) have nonexistent race in value2 (%u), ignore.", + criteria->ID, criteria->requiredType,requirementType,classRace.race_id); return false; } return true; case ACHIEVEMENT_CRITERIA_REQUIRE_T_PLAYER_LESS_HEALTH: if (health.percent < 1 || health.percent > 100) { - sLog.outErrorDb( "Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_PLAYER_LESS_HEALTH (%u) have wrong percent value in value1 (%u), ignore.", - criteria->ID, criteria->requiredType,requirementType,health.percent); + sLog.outErrorDb("Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_PLAYER_LESS_HEALTH (%u) have wrong percent value in value1 (%u), ignore.", + criteria->ID, criteria->requiredType,requirementType,health.percent); return false; } return true; case ACHIEVEMENT_CRITERIA_REQUIRE_T_PLAYER_DEAD: if (player_dead.own_team_flag > 1) { - sLog.outErrorDb( "Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_T_PLAYER_DEAD (%u) have wrong boolean value1 (%u).", - criteria->ID, criteria->requiredType,requirementType,player_dead.own_team_flag); + sLog.outErrorDb("Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_T_PLAYER_DEAD (%u) have wrong boolean value1 (%u).", + criteria->ID, criteria->requiredType,requirementType,player_dead.own_team_flag); return false; } return true; @@ -162,20 +162,20 @@ bool AchievementCriteriaRequirement::IsValid(AchievementCriteriaEntry const* cri SpellEntry const* spellEntry = sSpellStore.LookupEntry(aura.spell_id); if (!spellEntry) { - sLog.outErrorDb( "Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement %s (%u) have wrong spell id in value1 (%u), ignore.", - criteria->ID, criteria->requiredType,(requirementType==ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA?"ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA":"ACHIEVEMENT_CRITERIA_REQUIRE_T_AURA"),requirementType,aura.spell_id); + sLog.outErrorDb("Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement %s (%u) have wrong spell id in value1 (%u), ignore.", + criteria->ID, criteria->requiredType,(requirementType==ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA?"ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA":"ACHIEVEMENT_CRITERIA_REQUIRE_T_AURA"),requirementType,aura.spell_id); return false; } if (aura.effect_idx >= MAX_EFFECT_INDEX) { - sLog.outErrorDb( "Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement %s (%u) have wrong spell effect index in value2 (%u), ignore.", - criteria->ID, criteria->requiredType,(requirementType==ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA?"ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA":"ACHIEVEMENT_CRITERIA_REQUIRE_T_AURA"),requirementType,aura.effect_idx); + sLog.outErrorDb("Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement %s (%u) have wrong spell effect index in value2 (%u), ignore.", + criteria->ID, criteria->requiredType,(requirementType==ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA?"ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA":"ACHIEVEMENT_CRITERIA_REQUIRE_T_AURA"),requirementType,aura.effect_idx); return false; } if (!spellEntry->EffectApplyAuraName[aura.effect_idx]) { - sLog.outErrorDb( "Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement %s (%u) have non-aura spell effect (ID: %u Effect: %u), ignore.", - criteria->ID, criteria->requiredType,(requirementType==ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA?"ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA":"ACHIEVEMENT_CRITERIA_REQUIRE_T_AURA"),requirementType,aura.spell_id,aura.effect_idx); + sLog.outErrorDb("Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement %s (%u) have non-aura spell effect (ID: %u Effect: %u), ignore.", + criteria->ID, criteria->requiredType,(requirementType==ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA?"ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA":"ACHIEVEMENT_CRITERIA_REQUIRE_T_AURA"),requirementType,aura.spell_id,aura.effect_idx); return false; } return true; @@ -183,95 +183,95 @@ bool AchievementCriteriaRequirement::IsValid(AchievementCriteriaEntry const* cri case ACHIEVEMENT_CRITERIA_REQUIRE_S_AREA: if (!GetAreaEntryByAreaID(area.id)) { - sLog.outErrorDb( "Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_S_AREA (%u) have wrong area id in value1 (%u), ignore.", - criteria->ID, criteria->requiredType,requirementType,area.id); + sLog.outErrorDb("Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_S_AREA (%u) have wrong area id in value1 (%u), ignore.", + criteria->ID, criteria->requiredType,requirementType,area.id); return false; } return true; case ACHIEVEMENT_CRITERIA_REQUIRE_T_LEVEL: if (level.minlevel > STRONG_MAX_LEVEL) { - sLog.outErrorDb( "Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_T_LEVEL (%u) have wrong minlevel in value1 (%u), ignore.", - criteria->ID, criteria->requiredType,requirementType,level.minlevel); + sLog.outErrorDb("Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_T_LEVEL (%u) have wrong minlevel in value1 (%u), ignore.", + criteria->ID, criteria->requiredType,requirementType,level.minlevel); return false; } return true; case ACHIEVEMENT_CRITERIA_REQUIRE_T_GENDER: if (gender.gender > GENDER_NONE) { - sLog.outErrorDb( "Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_T_GENDER (%u) have wrong gender in value1 (%u), ignore.", - criteria->ID, criteria->requiredType,requirementType,gender.gender); + sLog.outErrorDb("Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_T_GENDER (%u) have wrong gender in value1 (%u), ignore.", + criteria->ID, criteria->requiredType,requirementType,gender.gender); return false; } return true; case ACHIEVEMENT_CRITERIA_REQUIRE_MAP_DIFFICULTY: if (difficulty.difficulty >= MAX_DIFFICULTY) { - sLog.outErrorDb( "Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_MAP_DIFFICULTY (%u) have wrong difficulty in value1 (%u), ignore.", - criteria->ID, criteria->requiredType,requirementType,difficulty.difficulty); + sLog.outErrorDb("Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_MAP_DIFFICULTY (%u) have wrong difficulty in value1 (%u), ignore.", + criteria->ID, criteria->requiredType,requirementType,difficulty.difficulty); return false; } return true; case ACHIEVEMENT_CRITERIA_REQUIRE_MAP_PLAYER_COUNT: if (map_players.maxcount <= 0) { - sLog.outErrorDb( "Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_MAP_PLAYER_COUNT (%u) have wrong max players count in value1 (%u), ignore.", - criteria->ID, criteria->requiredType,requirementType,map_players.maxcount); + sLog.outErrorDb("Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_MAP_PLAYER_COUNT (%u) have wrong max players count in value1 (%u), ignore.", + criteria->ID, criteria->requiredType,requirementType,map_players.maxcount); return false; } return true; case ACHIEVEMENT_CRITERIA_REQUIRE_T_TEAM: if (team.team != ALLIANCE && team.team != HORDE) { - sLog.outErrorDb( "Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_T_TEAM (%u) have unknown team in value1 (%u), ignore.", - criteria->ID, criteria->requiredType,requirementType,team.team); + sLog.outErrorDb("Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_T_TEAM (%u) have unknown team in value1 (%u), ignore.", + criteria->ID, criteria->requiredType,requirementType,team.team); return false; } return true; case ACHIEVEMENT_CRITERIA_REQUIRE_S_DRUNK: - if(drunk.state >= MAX_DRUNKEN) + if (drunk.state >= MAX_DRUNKEN) { - sLog.outErrorDb( "Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_S_DRUNK (%u) have unknown drunken state in value1 (%u), ignore.", - criteria->ID, criteria->requiredType,requirementType,drunk.state); + sLog.outErrorDb("Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_S_DRUNK (%u) have unknown drunken state in value1 (%u), ignore.", + criteria->ID, criteria->requiredType,requirementType,drunk.state); return false; } return true; case ACHIEVEMENT_CRITERIA_REQUIRE_HOLIDAY: if (!sHolidaysStore.LookupEntry(holiday.id)) { - sLog.outErrorDb( "Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_HOLIDAY (%u) have unknown holiday in value1 (%u), ignore.", - criteria->ID, criteria->requiredType,requirementType,holiday.id); + sLog.outErrorDb("Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_HOLIDAY (%u) have unknown holiday in value1 (%u), ignore.", + criteria->ID, criteria->requiredType,requirementType,holiday.id); return false; } return true; case ACHIEVEMENT_CRITERIA_REQUIRE_S_EQUIPPED_ITEM_LVL: - if(equipped_item.item_quality >= MAX_ITEM_QUALITY) + if (equipped_item.item_quality >= MAX_ITEM_QUALITY) { - sLog.outErrorDb( "Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_S_EQUIPPED_ITEM_LVL (%u) have unknown quality state in value1 (%u), ignore.", - criteria->ID, criteria->requiredType,requirementType,equipped_item.item_quality); + sLog.outErrorDb("Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_S_EQUIPPED_ITEM_LVL (%u) have unknown quality state in value1 (%u), ignore.", + criteria->ID, criteria->requiredType,requirementType,equipped_item.item_quality); return false; } return true; case ACHIEVEMENT_CRITERIA_REQUIRE_KNOWN_TITLE: + { + CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(known_title.title_id); + if (!titleInfo) { - CharTitlesEntry const *titleInfo = sCharTitlesStore.LookupEntry(known_title.title_id); - if (!titleInfo) - { - sLog.outErrorDb( "Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_KNOWN_TITLE (%u) have unknown title_id in value1 (%u), ignore.", - criteria->ID, criteria->requiredType, requirementType, known_title.title_id); - return false; - } - return true; + sLog.outErrorDb("Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_KNOWN_TITLE (%u) have unknown title_id in value1 (%u), ignore.", + criteria->ID, criteria->requiredType, requirementType, known_title.title_id); + return false; } + return true; + } default: - sLog.outErrorDb( "Table `achievement_criteria_requirement` (Entry: %u Type: %u) have data for not supported data type (%u), ignore.", criteria->ID, criteria->requiredType,requirementType); + sLog.outErrorDb("Table `achievement_criteria_requirement` (Entry: %u Type: %u) have data for not supported data type (%u), ignore.", criteria->ID, criteria->requiredType,requirementType); return false; } } bool AchievementCriteriaRequirement::Meets(uint32 criteria_id, Player const* source, Unit const* target, uint32 miscvalue1 /*= 0*/) const { - switch(requirementType) + switch (requirementType) { case ACHIEVEMENT_CRITERIA_REQUIRE_NONE: return true; @@ -282,9 +282,9 @@ bool AchievementCriteriaRequirement::Meets(uint32 criteria_id, Player const* sou case ACHIEVEMENT_CRITERIA_REQUIRE_T_PLAYER_CLASS_RACE: if (!target || target->GetTypeId()!=TYPEID_PLAYER) return false; - if(classRace.class_id && classRace.class_id != ((Player*)target)->getClass()) + if (classRace.class_id && classRace.class_id != ((Player*)target)->getClass()) return false; - if(classRace.race_id && classRace.race_id != ((Player*)target)->getRace()) + if (classRace.race_id && classRace.race_id != ((Player*)target)->getRace()) return false; return true; case ACHIEVEMENT_CRITERIA_REQUIRE_T_PLAYER_LESS_HEALTH: @@ -333,7 +333,7 @@ bool AchievementCriteriaRequirement::Meets(uint32 criteria_id, Player const* sou case ACHIEVEMENT_CRITERIA_REQUIRE_BG_LOSS_TEAM_SCORE: { BattleGround* bg = source->GetBattleGround(); - if(!bg) + if (!bg) return false; return bg->IsTeamScoreInRange(source->GetTeam()==ALLIANCE ? HORDE : ALLIANCE,bg_loss_team_score.min_score,bg_loss_team_score.max_score); } @@ -345,7 +345,7 @@ bool AchievementCriteriaRequirement::Meets(uint32 criteria_id, Player const* sou if (!data) { sLog.outErrorDb("Achievement system call ACHIEVEMENT_CRITERIA_REQUIRE_INSTANCE_SCRIPT (%u) for achievement criteria %u for map %u but map not have instance script", - ACHIEVEMENT_CRITERIA_REQUIRE_INSTANCE_SCRIPT, criteria_id, source->GetMapId()); + ACHIEVEMENT_CRITERIA_REQUIRE_INSTANCE_SCRIPT, criteria_id, source->GetMapId()); return false; } return data->CheckAchievementCriteriaMeet(criteria_id, source, target, miscvalue1); @@ -385,14 +385,14 @@ bool AchievementCriteriaRequirement::Meets(uint32 criteria_id, Player const* sou bool AchievementCriteriaRequirementSet::Meets(Player const* source, Unit const* target, uint32 miscvalue /*= 0*/) const { - for(Storage::const_iterator itr = storage.begin(); itr != storage.end(); ++itr) - if(!itr->Meets(criteria_id, source, target, miscvalue)) + for (Storage::const_iterator itr = storage.begin(); itr != storage.end(); ++itr) + if (!itr->Meets(criteria_id, source, target, miscvalue)) return false; return true; } -AchievementMgr::AchievementMgr(Player *player) +AchievementMgr::AchievementMgr(Player* player) { m_player = player; } @@ -403,14 +403,14 @@ AchievementMgr::~AchievementMgr() void AchievementMgr::Reset() { - for(CompletedAchievementMap::const_iterator iter = m_completedAchievements.begin(); iter!=m_completedAchievements.end(); ++iter) + for (CompletedAchievementMap::const_iterator iter = m_completedAchievements.begin(); iter!=m_completedAchievements.end(); ++iter) { WorldPacket data(SMSG_ACHIEVEMENT_DELETED,4); data << uint32(iter->first); m_player->SendDirectMessage(&data); } - for(CriteriaProgressMap::const_iterator iter = m_criteriaProgress.begin(); iter!=m_criteriaProgress.end(); ++iter) + for (CriteriaProgressMap::const_iterator iter = m_criteriaProgress.begin(); iter!=m_criteriaProgress.end(); ++iter) { WorldPacket data(SMSG_CRITERIA_DELETED,4); data << uint32(iter->first); @@ -433,11 +433,11 @@ void AchievementMgr::ResetAchievementCriteria(AchievementCriteriaTypes type, uin return; AchievementCriteriaEntryList const& achievementCriteriaList = sAchievementMgr.GetAchievementCriteriaByType(type); - for(AchievementCriteriaEntryList::const_iterator i = achievementCriteriaList.begin(); i!=achievementCriteriaList.end(); ++i) + for (AchievementCriteriaEntryList::const_iterator i = achievementCriteriaList.begin(); i!=achievementCriteriaList.end(); ++i) { - AchievementCriteriaEntry const *achievementCriteria = (*i); + AchievementCriteriaEntry const* achievementCriteria = (*i); - AchievementEntry const *achievement = sAchievementStore.LookupEntry(achievementCriteria->referredAchievement); + AchievementEntry const* achievement = sAchievementStore.LookupEntry(achievementCriteria->referredAchievement); // Checked in LoadAchievementCriteriaList // don't update already completed criteria @@ -449,7 +449,7 @@ void AchievementMgr::ResetAchievementCriteria(AchievementCriteriaTypes type, uin case ACHIEVEMENT_CRITERIA_TYPE_DAMAGE_DONE: // have total statistic also not expected to be reset case ACHIEVEMENT_CRITERIA_TYPE_HEALING_DONE: // have total statistic also not expected to be reset if (achievementCriteria->healing_done.flag == miscvalue1 && - achievementCriteria->healing_done.mapid == miscvalue2) + achievementCriteria->healing_done.mapid == miscvalue2) SetCriteriaProgress(achievementCriteria, achievement, 0, PROGRESS_SET); break; case ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA: // have total statistic also not expected to be reset @@ -466,10 +466,10 @@ void AchievementMgr::ResetAchievementCriteria(AchievementCriteriaTypes type, uin void AchievementMgr::DeleteFromDB(ObjectGuid guid) { uint32 lowguid = guid.GetCounter(); - CharacterDatabase.BeginTransaction (); + CharacterDatabase.BeginTransaction(); CharacterDatabase.PExecute("DELETE FROM character_achievement WHERE guid = %u", lowguid); CharacterDatabase.PExecute("DELETE FROM character_achievement_progress WHERE guid = %u", lowguid); - CharacterDatabase.CommitTransaction (); + CharacterDatabase.CommitTransaction(); } void AchievementMgr::SaveToDB() @@ -479,12 +479,12 @@ void AchievementMgr::SaveToDB() static SqlStatementID delProgress ; static SqlStatementID insProgress ; - if(!m_completedAchievements.empty()) + if (!m_completedAchievements.empty()) { //delete existing achievements in the loop - for(CompletedAchievementMap::iterator iter = m_completedAchievements.begin(); iter!=m_completedAchievements.end(); ++iter) + for (CompletedAchievementMap::iterator iter = m_completedAchievements.begin(); iter!=m_completedAchievements.end(); ++iter) { - if(!iter->second.changed) + if (!iter->second.changed) continue; /// mark as saved in db @@ -498,12 +498,12 @@ void AchievementMgr::SaveToDB() } } - if(!m_criteriaProgress.empty()) + if (!m_criteriaProgress.empty()) { //insert achievements - for(CriteriaProgressMap::iterator iter = m_criteriaProgress.begin(); iter!=m_criteriaProgress.end(); ++iter) + for (CriteriaProgressMap::iterator iter = m_criteriaProgress.begin(); iter!=m_criteriaProgress.end(); ++iter) { - if(!iter->second.changed) + if (!iter->second.changed) continue; /// mark as updated in db @@ -529,35 +529,36 @@ void AchievementMgr::SaveToDB() } } -void AchievementMgr::LoadFromDB(QueryResult *achievementResult, QueryResult *criteriaResult) +void AchievementMgr::LoadFromDB(QueryResult* achievementResult, QueryResult* criteriaResult) { // Note: this code called before any character data loading so don't must triggering any events req. inventory/etc // all like cases must be happens in CheckAllAchievementCriteria called after character data load - if(achievementResult) + if (achievementResult) { do { - Field *fields = achievementResult->Fetch(); + Field* fields = achievementResult->Fetch(); uint32 achievement_id = fields[0].GetUInt32(); // don't must happen: cleanup at server startup in sAchievementMgr.LoadCompletedAchievements() - if(!sAchievementStore.LookupEntry(achievement_id)) + if (!sAchievementStore.LookupEntry(achievement_id)) continue; CompletedAchievementData& ca = m_completedAchievements[achievement_id]; ca.date = time_t(fields[1].GetUInt64()); ca.changed = false; - } while(achievementResult->NextRow()); + } + while (achievementResult->NextRow()); delete achievementResult; } - if(criteriaResult) + if (criteriaResult) { do { - Field *fields = criteriaResult->Fetch(); + Field* fields = criteriaResult->Fetch(); uint32 id = fields[0].GetUInt32(); uint32 counter = fields[1].GetUInt32(); @@ -604,7 +605,8 @@ void AchievementMgr::LoadFromDB(QueryResult *achievementResult, QueryResult *cri progress.changed = true; } } - } while(criteriaResult->NextRow()); + } + while (criteriaResult->NextRow()); delete criteriaResult; } @@ -612,7 +614,7 @@ void AchievementMgr::LoadFromDB(QueryResult *achievementResult, QueryResult *cri void AchievementMgr::SendAchievementEarned(AchievementEntry const* achievement) { - if(GetPlayer()->GetSession()->PlayerLoading()) + if (GetPlayer()->GetSession()->PlayerLoading()) return; DEBUG_FILTER_LOG(LOG_FILTER_ACHIEVEMENT_UPDATES, "AchievementMgr::SendAchievementEarned(%u)", achievement->ID); @@ -624,7 +626,7 @@ void AchievementMgr::SendAchievementEarned(AchievementEntry const* achievement) guild->BroadcastWorker(say_do,GetPlayer()); } - if(achievement->flags & (ACHIEVEMENT_FLAG_REALM_FIRST_KILL|ACHIEVEMENT_FLAG_REALM_FIRST_REACH)) + if (achievement->flags & (ACHIEVEMENT_FLAG_REALM_FIRST_KILL|ACHIEVEMENT_FLAG_REALM_FIRST_REACH)) { // broadcast realm first reached WorldPacket data(SMSG_SERVER_FIRST_ACHIEVEMENT, strlen(GetPlayer()->GetName())+1+8+4+4); @@ -675,7 +677,7 @@ void AchievementMgr::SendCriteriaUpdate(uint32 id, CriteriaProgress const* progr void AchievementMgr::CheckAllAchievementCriteria() { // suppress sending packets - for(uint32 i=0; itimedCriteriaMiscId != timedRequirementId) @@ -718,11 +720,11 @@ void AchievementMgr::StartTimedAchievementCriteria(AchievementCriteriaTypes type if (!achievementCriteria->IsExplicitlyStartedTimedCriteria()) continue; - AchievementEntry const *achievement = sAchievementStore.LookupEntry(achievementCriteria->referredAchievement); + AchievementEntry const* achievement = sAchievementStore.LookupEntry(achievementCriteria->referredAchievement); // Checked in LoadAchievementCriteriaList if ((achievement->factionFlag == ACHIEVEMENT_FACTION_FLAG_HORDE && GetPlayer()->GetTeam() != HORDE) || - (achievement->factionFlag == ACHIEVEMENT_FACTION_FLAG_ALLIANCE && GetPlayer()->GetTeam() != ALLIANCE)) + (achievement->factionFlag == ACHIEVEMENT_FACTION_FLAG_ALLIANCE && GetPlayer()->GetTeam() != ALLIANCE)) continue; // don't update already completed criteria @@ -806,7 +808,7 @@ void AchievementMgr::DoFailedTimedAchievementCriterias() /** * this function will be called whenever the user might have done a criteria relevant action */ -void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscvalue1, uint32 miscvalue2, Unit *unit, uint32 time) +void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscvalue1, uint32 miscvalue2, Unit* unit, uint32 time) { DETAIL_FILTER_LOG(LOG_FILTER_ACHIEVEMENT_UPDATES, "AchievementMgr::UpdateAchievementCriteria(%u, %u, %u, %u)", type, miscvalue1, miscvalue2, time); @@ -814,15 +816,15 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui return; AchievementCriteriaEntryList const& achievementCriteriaList = sAchievementMgr.GetAchievementCriteriaByType(type); - for(AchievementCriteriaEntryList::const_iterator itr = achievementCriteriaList.begin(); itr != achievementCriteriaList.end(); ++itr) + for (AchievementCriteriaEntryList::const_iterator itr = achievementCriteriaList.begin(); itr != achievementCriteriaList.end(); ++itr) { - AchievementCriteriaEntry const *achievementCriteria = *itr; + AchievementCriteriaEntry const* achievementCriteria = *itr; - AchievementEntry const *achievement = sAchievementStore.LookupEntry(achievementCriteria->referredAchievement); + AchievementEntry const* achievement = sAchievementStore.LookupEntry(achievementCriteria->referredAchievement); // Checked in LoadAchievementCriteriaList if ((achievement->factionFlag == ACHIEVEMENT_FACTION_FLAG_HORDE && GetPlayer()->GetTeam() != HORDE) || - (achievement->factionFlag == ACHIEVEMENT_FACTION_FLAG_ALLIANCE && GetPlayer()->GetTeam() != ALLIANCE)) + (achievement->factionFlag == ACHIEVEMENT_FACTION_FLAG_ALLIANCE && GetPlayer()->GetTeam() != ALLIANCE)) continue; // don't update already completed criteria @@ -835,7 +837,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui switch (type) { - // std. case: increment at 1 + // std. case: increment at 1 case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST: case ACHIEVEMENT_CRITERIA_TYPE_NUMBER_OF_TALENT_RESETS: case ACHIEVEMENT_CRITERIA_TYPE_LOSE_DUEL: @@ -847,12 +849,12 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui case ACHIEVEMENT_CRITERIA_TYPE_FLIGHT_PATHS_TAKEN: case ACHIEVEMENT_CRITERIA_TYPE_ACCEPTED_SUMMONINGS: // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case - if(!miscvalue1) + if (!miscvalue1) continue; change = 1; progressType = PROGRESS_ACCUMULATE; break; - // std case: increment at miscvalue1 + // std case: increment at miscvalue1 case ACHIEVEMENT_CRITERIA_TYPE_MONEY_FROM_VENDORS: case ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_TALENTS: case ACHIEVEMENT_CRITERIA_TYPE_MONEY_FROM_QUEST_REWARD: @@ -864,12 +866,12 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui case ACHIEVEMENT_CRITERIA_TYPE_TOTAL_DAMAGE_RECEIVED: case ACHIEVEMENT_CRITERIA_TYPE_TOTAL_HEALING_RECEIVED: // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case - if(!miscvalue1) + if (!miscvalue1) continue; change = miscvalue1; progressType = PROGRESS_ACCUMULATE; break; - // std case: high value at miscvalue1 + // std case: high value at miscvalue1 case ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID: case ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_SOLD: /* FIXME: for online player only currently */ case ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HIT_DEALT: @@ -877,13 +879,13 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui case ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEAL_CASTED: case ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEALING_RECEIVED: // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case - if(!miscvalue1) + if (!miscvalue1) continue; change = miscvalue1; progressType = PROGRESS_HIGHEST; break; - // specialized cases + // specialized cases case ACHIEVEMENT_CRITERIA_TYPE_WIN_BG: { @@ -907,7 +909,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui if (!bg) continue; - switch(achievementCriteria->referredAchievement) + switch (achievementCriteria->referredAchievement) { case 161: // AB, Overcome a 500 resource disadvantage { @@ -920,7 +922,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui case 156: // AB, win while controlling all 5 flags (all nodes) case 784: // EY, win while holding 4 bases (all nodes) { - if(!bg->IsAllNodesConrolledByTeam(GetPlayer()->GetTeam())) + if (!bg->IsAllNodesConrolledByTeam(GetPlayer()->GetTeam())) continue; break; } @@ -937,14 +939,14 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui case ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE: { // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case - if(!miscvalue1) + if (!miscvalue1) continue; - if(achievementCriteria->kill_creature.creatureID != miscvalue1) + if (achievementCriteria->kill_creature.creatureID != miscvalue1) continue; // those requirements couldn't be found in the dbc AchievementCriteriaRequirementSet const* data = sAchievementMgr.GetCriteriaRequirementSet(achievementCriteria); - if(!data || !data->Meets(GetPlayer(),unit)) + if (!data || !data->Meets(GetPlayer(),unit)) continue; change = miscvalue2; @@ -956,7 +958,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui bool ok = true; // skip wrong class achievements - for(uint8 i = 1; i < MAX_CLASSES; ++i) + for (uint8 i = 1; i < MAX_CLASSES; ++i) { if (achievIdByClass[i] == achievement->ID && i != GetPlayer()->getClass()) { @@ -969,7 +971,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui continue; // skip wrong race achievements - for(uint8 i = 1; i < MAX_RACES; ++i) + for (uint8 i = 1; i < MAX_RACES; ++i) { if (achievIdByRace[i] == achievement->ID && i != GetPlayer()->getRace()) { @@ -988,7 +990,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui case ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL: { // update at loading or specific skill update - if(miscvalue1 && miscvalue1 != achievementCriteria->reach_skill_level.skillID) + if (miscvalue1 && miscvalue1 != achievementCriteria->reach_skill_level.skillID) continue; change = GetPlayer()->GetBaseSkillValue(achievementCriteria->reach_skill_level.skillID); progressType = PROGRESS_HIGHEST; @@ -997,7 +999,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LEVEL: { // update at loading or specific skill update - if(miscvalue1 && miscvalue1 != achievementCriteria->learn_skill_level.skillID) + if (miscvalue1 && miscvalue1 != achievementCriteria->learn_skill_level.skillID) continue; change = GetPlayer()->GetPureMaxSkillValue(achievementCriteria->learn_skill_level.skillID); progressType = PROGRESS_HIGHEST; @@ -1005,7 +1007,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui } case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_ACHIEVEMENT: { - if(m_completedAchievements.find(achievementCriteria->complete_achievement.linkedAchievement) == m_completedAchievements.end()) + if (m_completedAchievements.find(achievementCriteria->complete_achievement.linkedAchievement) == m_completedAchievements.end()) continue; change = 1; @@ -1015,8 +1017,8 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST_COUNT: { uint32 counter =0; - for(QuestStatusMap::const_iterator itr = GetPlayer()->getQuestStatusMap().begin(); itr!=GetPlayer()->getQuestStatusMap().end(); ++itr) - if(itr->second.m_rewarded) + for (QuestStatusMap::const_iterator itr = GetPlayer()->getQuestStatusMap().begin(); itr!=GetPlayer()->getQuestStatusMap().end(); ++itr) + if (itr->second.m_rewarded) counter++; change = counter; progressType = PROGRESS_HIGHEST; @@ -1025,14 +1027,14 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUESTS_IN_ZONE: { // speedup for non-login case - if(miscvalue1 && miscvalue1 != achievementCriteria->complete_quests_in_zone.zoneID) + if (miscvalue1 && miscvalue1 != achievementCriteria->complete_quests_in_zone.zoneID) continue; uint32 counter =0; - for(QuestStatusMap::const_iterator itr = GetPlayer()->getQuestStatusMap().begin(); itr!=GetPlayer()->getQuestStatusMap().end(); ++itr) + for (QuestStatusMap::const_iterator itr = GetPlayer()->getQuestStatusMap().begin(); itr!=GetPlayer()->getQuestStatusMap().end(); ++itr) { Quest const* quest = sObjectMgr.GetQuestTemplate(itr->first); - if(itr->second.m_rewarded && quest->GetZoneOrSort() >= 0 && uint32(quest->GetZoneOrSort()) == achievementCriteria->complete_quests_in_zone.zoneID) + if (itr->second.m_rewarded && quest->GetZoneOrSort() >= 0 && uint32(quest->GetZoneOrSort()) == achievementCriteria->complete_quests_in_zone.zoneID) counter++; } change = counter; @@ -1041,18 +1043,18 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui } case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_BATTLEGROUND: // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case - if(!miscvalue1) + if (!miscvalue1) continue; - if(GetPlayer()->GetMapId() != achievementCriteria->complete_battleground.mapID) + if (GetPlayer()->GetMapId() != achievementCriteria->complete_battleground.mapID) continue; change = miscvalue1; progressType = PROGRESS_ACCUMULATE; break; case ACHIEVEMENT_CRITERIA_TYPE_DEATH_AT_MAP: // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case - if(!miscvalue1) + if (!miscvalue1) continue; - if(GetPlayer()->GetMapId() != achievementCriteria->death_at_map.mapID) + if (GetPlayer()->GetMapId() != achievementCriteria->death_at_map.mapID) continue; change = 1; progressType = PROGRESS_ACCUMULATE; @@ -1060,22 +1062,22 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui case ACHIEVEMENT_CRITERIA_TYPE_DEATH: { // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case - if(!miscvalue1) + if (!miscvalue1) continue; // skip wrong arena achievements, if not achievIdByArenaSlot then normal total death counter bool notfit = false; - for(int j = 0; j < MAX_ARENA_SLOT; ++j) + for (int j = 0; j < MAX_ARENA_SLOT; ++j) { - if(achievIdByArenaSlot[j] == achievement->ID) + if (achievIdByArenaSlot[j] == achievement->ID) { BattleGround* bg = GetPlayer()->GetBattleGround(); - if(!bg || !bg->isArena() || ArenaTeam::GetSlotByType(bg->GetArenaType()) != j) + if (!bg || !bg->isArena() || ArenaTeam::GetSlotByType(bg->GetArenaType()) != j) notfit = true; break; } } - if(notfit) + if (notfit) continue; change = 1; @@ -1085,35 +1087,35 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui case ACHIEVEMENT_CRITERIA_TYPE_DEATH_IN_DUNGEON: { // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case - if(!miscvalue1) + if (!miscvalue1) continue; Map const* map = GetPlayer()->IsInWorld() ? GetPlayer()->GetMap() : sMapMgr.FindMap(GetPlayer()->GetMapId(), GetPlayer()->GetInstanceId()); - if(!map || !map->IsDungeon()) + if (!map || !map->IsDungeon()) continue; // search case bool found = false; - for(int j = 0; achievIdForDungeon[j][0]; ++j) + for (int j = 0; achievIdForDungeon[j][0]; ++j) { - if(achievIdForDungeon[j][0] == achievement->ID) + if (achievIdForDungeon[j][0] == achievement->ID) { - if(map->IsRaid()) + if (map->IsRaid()) { // if raid accepted (ignore difficulty) - if(!achievIdForDungeon[j][2]) + if (!achievIdForDungeon[j][2]) break; // for } - else if(GetPlayer()->GetDungeonDifficulty()==DUNGEON_DIFFICULTY_NORMAL) + else if (GetPlayer()->GetDungeonDifficulty()==DUNGEON_DIFFICULTY_NORMAL) { // dungeon in normal mode accepted - if(!achievIdForDungeon[j][1]) + if (!achievIdForDungeon[j][1]) break; // for } else { // dungeon in heroic mode accepted - if(!achievIdForDungeon[j][3]) + if (!achievIdForDungeon[j][3]) break; // for } @@ -1121,7 +1123,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui break; // for } } - if(!found) + if (!found) continue; //FIXME: work only for instances where max==min for players @@ -1135,20 +1137,20 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui } case ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_CREATURE: // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case - if(!miscvalue1) + if (!miscvalue1) continue; - if(miscvalue1 != achievementCriteria->killed_by_creature.creatureEntry) + if (miscvalue1 != achievementCriteria->killed_by_creature.creatureEntry) continue; change = 1; progressType = PROGRESS_ACCUMULATE; break; case ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_PLAYER: // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case - if(!miscvalue1) + if (!miscvalue1) continue; // if team check required: must kill by opposition faction - if(achievement->ID==318 && miscvalue2==uint32(GetPlayer()->GetTeam())) + if (achievement->ID==318 && miscvalue2==uint32(GetPlayer()->GetTeam())) continue; change = 1; @@ -1157,12 +1159,12 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui case ACHIEVEMENT_CRITERIA_TYPE_FALL_WITHOUT_DYING: { // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case - if(!miscvalue1) + if (!miscvalue1) continue; // those requirements couldn't be found in the dbc AchievementCriteriaRequirementSet const* data = sAchievementMgr.GetCriteriaRequirementSet(achievementCriteria); - if(!data || !data->Meets(GetPlayer(),unit)) + if (!data || !data->Meets(GetPlayer(),unit)) continue; // miscvalue1 is the ingame fallheight*100 as stored in dbc @@ -1172,9 +1174,9 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui } case ACHIEVEMENT_CRITERIA_TYPE_DEATHS_FROM: // AchievementMgr::UpdateAchievementCriteria might also be called on login - skip in this case - if(!miscvalue1) + if (!miscvalue1) continue; - if(miscvalue2 != achievementCriteria->death_from.type) + if (miscvalue2 != achievementCriteria->death_from.type) continue; change = 1; progressType = PROGRESS_ACCUMULATE; @@ -1190,23 +1192,23 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui else { // login case. - if(!GetPlayer()->GetQuestRewardStatus(achievementCriteria->complete_quest.questID)) + if (!GetPlayer()->GetQuestRewardStatus(achievementCriteria->complete_quest.questID)) continue; } // exist many achievements with this criteria, use at this moment hardcoded check to skip simple case - switch(achievement->ID) + switch (achievement->ID) { case 31: - //case 1275: // these timed achievements have to be "started" on Quest Accept - //case 1276: - //case 1277: + //case 1275: // these timed achievements have to be "started" on Quest Accept + //case 1276: + //case 1277: case 1282: case 1789: { // those requirements couldn't be found in the dbc AchievementCriteriaRequirementSet const* data = sAchievementMgr.GetCriteriaRequirementSet(achievementCriteria); - if(!data || !data->Meets(GetPlayer(),unit)) + if (!data || !data->Meets(GetPlayer(),unit)) continue; break; } @@ -1230,10 +1232,10 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui // those requirements couldn't be found in the dbc AchievementCriteriaRequirementSet const* data = sAchievementMgr.GetCriteriaRequirementSet(achievementCriteria); - if(!data) + if (!data) continue; - if(!data->Meets(GetPlayer(),unit)) + if (!data->Meets(GetPlayer(),unit)) continue; change = 1; @@ -1248,10 +1250,10 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui // those requirements couldn't be found in the dbc AchievementCriteriaRequirementSet const* data = sAchievementMgr.GetCriteriaRequirementSet(achievementCriteria); - if(!data) + if (!data) continue; - if(!data->Meets(GetPlayer(),unit)) + if (!data->Meets(GetPlayer(),unit)) continue; change = 1; @@ -1259,10 +1261,10 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui break; } case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SPELL: - if(miscvalue1 && miscvalue1!=achievementCriteria->learn_spell.spellID) + if (miscvalue1 && miscvalue1!=achievementCriteria->learn_spell.spellID) continue; - if(!GetPlayer()->HasSpell(achievementCriteria->learn_spell.spellID)) + if (!GetPlayer()->HasSpell(achievementCriteria->learn_spell.spellID)) continue; change = 1; @@ -1278,11 +1280,11 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui continue; // zone specific - if(achievementCriteria->loot_type.lootTypeCount==1) + if (achievementCriteria->loot_type.lootTypeCount==1) { // those requirements couldn't be found in the dbc AchievementCriteriaRequirementSet const* data = sAchievementMgr.GetCriteriaRequirementSet(achievementCriteria); - if(!data || !data->Meets(GetPlayer(),unit)) + if (!data || !data->Meets(GetPlayer(),unit)) continue; } @@ -1292,7 +1294,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui } case ACHIEVEMENT_CRITERIA_TYPE_OWN_ITEM: // speedup for non-login case - if(miscvalue1 && achievementCriteria->own_item.itemID != miscvalue1) + if (miscvalue1 && achievementCriteria->own_item.itemID != miscvalue1) continue; change = GetPlayer()->GetItemCount(achievementCriteria->own_item.itemID, true); progressType = PROGRESS_HIGHEST; @@ -1303,11 +1305,11 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui continue; // additional requirements - if(achievementCriteria->win_rated_arena.flag==ACHIEVEMENT_CRITERIA_CONDITION_NO_LOOSE) + if (achievementCriteria->win_rated_arena.flag==ACHIEVEMENT_CRITERIA_CONDITION_NO_LOOSE) { // those requirements couldn't be found in the dbc AchievementCriteriaRequirementSet const* data = sAchievementMgr.GetCriteriaRequirementSet(achievementCriteria); - if(!data || !data->Meets(GetPlayer(),unit,miscvalue1)) + if (!data || !data->Meets(GetPlayer(),unit,miscvalue1)) { // reset the progress as we have a win without the requirement. SetCriteriaProgress(achievementCriteria, achievement, 0, PROGRESS_SET); @@ -1335,9 +1337,9 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui } case ACHIEVEMENT_CRITERIA_TYPE_LOOT_ITEM: // You _have_ to loot that item, just owning it when logging in does _not_ count! - if(!miscvalue1) + if (!miscvalue1) continue; - if(miscvalue1 != achievementCriteria->own_item.itemID) + if (miscvalue1 != achievementCriteria->own_item.itemID) continue; change = miscvalue2; progressType = PROGRESS_ACCUMULATE; @@ -1345,31 +1347,31 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui case ACHIEVEMENT_CRITERIA_TYPE_EXPLORE_AREA: { WorldMapOverlayEntry const* worldOverlayEntry = sWorldMapOverlayStore.LookupEntry(achievementCriteria->explore_area.areaReference); - if(!worldOverlayEntry) + if (!worldOverlayEntry) break; bool matchFound = false; for (int j = 0; j < MAX_WORLD_MAP_OVERLAY_AREA_IDX; ++j) { uint32 area_id = worldOverlayEntry->areatableID[j]; - if(!area_id) // array have 0 only in empty tail + if (!area_id) // array have 0 only in empty tail break; int32 exploreFlag = GetAreaFlagByAreaID(area_id); - if(exploreFlag < 0) + if (exploreFlag < 0) continue; uint32 playerIndexOffset = uint32(exploreFlag) / 32; uint32 mask = 1<< (uint32(exploreFlag) % 32); - if(GetPlayer()->GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + playerIndexOffset) & mask) + if (GetPlayer()->GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + playerIndexOffset) & mask) { matchFound = true; break; } } - if(!matchFound) + if (!matchFound) continue; change = 1; @@ -1403,7 +1405,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui case ACHIEVEMENT_CRITERIA_TYPE_VISIT_BARBER_SHOP: { // skip for login case - if(!miscvalue1) + if (!miscvalue1) continue; change = 1; progressType = PROGRESS_HIGHEST; @@ -1412,14 +1414,14 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui case ACHIEVEMENT_CRITERIA_TYPE_EQUIP_EPIC_ITEM: { // miscvalue1 = equip_slot+1 (for avoid use 0) - if(!miscvalue1) + if (!miscvalue1) continue; uint32 item_slot = miscvalue1-1; - if(item_slot != achievementCriteria->equip_epic_item.itemSlot) + if (item_slot != achievementCriteria->equip_epic_item.itemSlot) continue; // those requirements couldn't be found in the dbc AchievementCriteriaRequirementSet const* data = sAchievementMgr.GetCriteriaRequirementSet(achievementCriteria); - if(!data || !data->Meets(GetPlayer(),unit,item_slot)) + if (!data || !data->Meets(GetPlayer(),unit,item_slot)) continue; change = 1; progressType = PROGRESS_HIGHEST; @@ -1430,17 +1432,17 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui { // miscvalue1 = itemid // miscvalue2 = diced value - if(!miscvalue1) + if (!miscvalue1) continue; - if(miscvalue2 != achievementCriteria->roll_greed_on_loot.rollValue) + if (miscvalue2 != achievementCriteria->roll_greed_on_loot.rollValue) continue; - ItemPrototype const *pProto = ObjectMgr::GetItemPrototype( miscvalue1 ); + ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(miscvalue1); uint32 requiredItemLevel = 0; if (achievementCriteria->ID == 2412 || achievementCriteria->ID == 2358) requiredItemLevel = 185; - if(!pProto || pProto->ItemLevel ItemLevel do_emote.emoteID) + if (miscvalue1 != achievementCriteria->do_emote.emoteID) continue; - if(achievementCriteria->do_emote.count) + if (achievementCriteria->do_emote.count) { // those requirements couldn't be found in the dbc AchievementCriteriaRequirementSet const* data = sAchievementMgr.GetCriteriaRequirementSet(achievementCriteria); - if(!data || !data->Meets(GetPlayer(),unit)) + if (!data || !data->Meets(GetPlayer(),unit)) continue; } @@ -1473,11 +1475,11 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui if (achievementCriteria->healing_done.flag == ACHIEVEMENT_CRITERIA_CONDITION_MAP) { - if(GetPlayer()->GetMapId() != achievementCriteria->healing_done.mapid) + if (GetPlayer()->GetMapId() != achievementCriteria->healing_done.mapid) continue; // map specific case (BG in fact) expected player targeted damage/heal - if(!unit || unit->GetTypeId()!=TYPEID_PLAYER) + if (!unit || unit->GetTypeId()!=TYPEID_PLAYER) continue; } @@ -1539,13 +1541,13 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui uint32 spellCount = 0; for (PlayerSpellMap::const_iterator spellIter = GetPlayer()->GetSpellMap().begin(); - spellIter != GetPlayer()->GetSpellMap().end(); - ++spellIter) + spellIter != GetPlayer()->GetSpellMap().end(); + ++spellIter) { SkillLineAbilityMapBounds bounds = sSpellMgr.GetSkillLineAbilityMapBounds(spellIter->first); - for(SkillLineAbilityMap::const_iterator skillIter = bounds.first; skillIter != bounds.second; ++skillIter) + for (SkillLineAbilityMap::const_iterator skillIter = bounds.first; skillIter != bounds.second; ++skillIter) { - if(skillIter->second->skillId == achievementCriteria->learn_skillline_spell.skillLine) + if (skillIter->second->skillId == achievementCriteria->learn_skillline_spell.skillLine) spellCount++; } } @@ -1604,11 +1606,11 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui uint32 spellCount = 0; for (PlayerSpellMap::const_iterator spellIter = GetPlayer()->GetSpellMap().begin(); - spellIter != GetPlayer()->GetSpellMap().end(); - ++spellIter) + spellIter != GetPlayer()->GetSpellMap().end(); + ++spellIter) { SkillLineAbilityMapBounds bounds = sSpellMgr.GetSkillLineAbilityMapBounds(spellIter->first); - for(SkillLineAbilityMap::const_iterator skillIter = bounds.first; skillIter != bounds.second; ++skillIter) + for (SkillLineAbilityMap::const_iterator skillIter = bounds.first; skillIter != bounds.second; ++skillIter) if (skillIter->second->skillId == achievementCriteria->learn_skill_line.skillLine) spellCount++; } @@ -1640,7 +1642,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui break; case ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_TEAM_RATING: { - if(!miscvalue1 || achievementCriteria->highest_team_rating.teamtype != miscvalue1) + if (!miscvalue1 || achievementCriteria->highest_team_rating.teamtype != miscvalue1) continue; change = miscvalue2; @@ -1649,10 +1651,10 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui } case ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_PERSONAL_RATING: { - if(!miscvalue1 || achievementCriteria->highest_personal_rating.teamtype != miscvalue1) + if (!miscvalue1 || achievementCriteria->highest_personal_rating.teamtype != miscvalue1) continue; - if(achievementCriteria->highest_personal_rating.teamrating != 0 && achievementCriteria->highest_personal_rating.teamrating > miscvalue2) + if (achievementCriteria->highest_personal_rating.teamrating != 0 && achievementCriteria->highest_personal_rating.teamrating > miscvalue2) continue; change = miscvalue2; @@ -1682,7 +1684,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui case ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_STAT: case ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_RATING: break; - // FIXME: not triggered in code as result, need to implement + // FIXME: not triggered in code as result, need to implement case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST_DAILY: case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_RAID: case ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE: @@ -1844,7 +1846,7 @@ uint32 AchievementMgr::GetCriteriaProgressMaxCounter(AchievementCriteriaEntry co resultValue = achievementCriteria->highest_personal_rating.teamrating; break; - // handle all statistic-only criteria here + // handle all statistic-only criteria here case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_BATTLEGROUND: case ACHIEVEMENT_CRITERIA_TYPE_DEATH_AT_MAP: case ACHIEVEMENT_CRITERIA_TYPE_DEATH: @@ -1949,7 +1951,7 @@ bool AchievementMgr::IsCompletedAchievement(AchievementEntry const* entry) AchievementCriteriaEntry const* criteria = *itr; CriteriaProgressMap::const_iterator itrProgress = m_criteriaProgress.find(criteria->ID); - if(itrProgress == m_criteriaProgress.end()) + if (itrProgress == m_criteriaProgress.end()) continue; CriteriaProgress const* progress = &itrProgress->second; @@ -1998,7 +2000,7 @@ void AchievementMgr::SetCriteriaProgress(AchievementCriteriaEntry const* criteri if (changeValue > max_value) changeValue = max_value; - CriteriaProgress *progress = NULL; + CriteriaProgress* progress = NULL; uint32 old_value = 0; uint32 newValue = 0; @@ -2033,7 +2035,7 @@ void AchievementMgr::SetCriteriaProgress(AchievementCriteriaEntry const* criteri progress = &iter->second; old_value = progress->counter; - switch(ptype) + switch (ptype) { case PROGRESS_SET: newValue = changeValue; @@ -2106,7 +2108,7 @@ void AchievementMgr::SetCriteriaProgress(AchievementCriteriaEntry const* criteri void AchievementMgr::CompletedAchievement(AchievementEntry const* achievement) { DETAIL_LOG("AchievementMgr::CompletedAchievement(%u)", achievement->ID); - if(achievement->flags & ACHIEVEMENT_FLAG_COUNTER || m_completedAchievements.find(achievement->ID)!=m_completedAchievements.end()) + if (achievement->flags & ACHIEVEMENT_FLAG_COUNTER || m_completedAchievements.find(achievement->ID)!=m_completedAchievements.end()) return; SendAchievementEarned(achievement); @@ -2116,7 +2118,7 @@ void AchievementMgr::CompletedAchievement(AchievementEntry const* achievement) // don't insert for ACHIEVEMENT_FLAG_REALM_FIRST_KILL since otherwise only the first group member would reach that achievement // TODO: where do set this instead? - if(!(achievement->flags & ACHIEVEMENT_FLAG_REALM_FIRST_KILL)) + if (!(achievement->flags & ACHIEVEMENT_FLAG_REALM_FIRST_KILL)) sAchievementMgr.SetRealmCompleted(achievement); UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_ACHIEVEMENT); @@ -2125,29 +2127,29 @@ void AchievementMgr::CompletedAchievement(AchievementEntry const* achievement) AchievementReward const* reward = sAchievementMgr.GetAchievementReward(achievement, GetPlayer()->getGender()); // no rewards - if(!reward) + if (!reward) return; // titles - if(uint32 titleId = reward->titleId[GetPlayer()->GetTeam() == HORDE ? 1 : 0]) + if (uint32 titleId = reward->titleId[GetPlayer()->GetTeam() == HORDE ? 1 : 0]) { - if(CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(titleId)) + if (CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(titleId)) GetPlayer()->SetTitle(titleEntry); } // mail - if(reward->sender) + if (reward->sender) { - Item* item = reward->itemId ? Item::CreateItem(reward->itemId, 1, GetPlayer ()) : NULL; + Item* item = reward->itemId ? Item::CreateItem(reward->itemId, 1, GetPlayer()) : NULL; int loc_idx = GetPlayer()->GetSession()->GetSessionDbLocaleIndex(); // subject and text std::string subject = reward->subject; std::string text = reward->text; - if ( loc_idx >= 0 ) + if (loc_idx >= 0) { - if(AchievementRewardLocale const* loc = sAchievementMgr.GetAchievementRewardLocale(achievement, GetPlayer()->getGender())) + if (AchievementRewardLocale const* loc = sAchievementMgr.GetAchievementRewardLocale(achievement, GetPlayer()->getGender())) { if (loc->subject.size() > size_t(loc_idx) && !loc->subject[loc_idx].empty()) subject = loc->subject[loc_idx]; @@ -2158,7 +2160,7 @@ void AchievementMgr::CompletedAchievement(AchievementEntry const* achievement) MailDraft draft(subject, text); - if(item) + if (item) { // save new item before send item->SaveToDB(); // save for prevent lost at next mail load, if send fail then item will deleted @@ -2187,7 +2189,7 @@ void AchievementMgr::IncompletedAchievement(AchievementEntry const* achievement) if (!itr->second.changed) // complete state saved CharacterDatabase.PExecute("DELETE FROM character_achievement WHERE guid = %u AND achievement = %u", - GetPlayer()->GetGUIDLow(), achievement->ID); + GetPlayer()->GetGUIDLow(), achievement->ID); m_completedAchievements.erase(achievement->ID); @@ -2195,13 +2197,13 @@ void AchievementMgr::IncompletedAchievement(AchievementEntry const* achievement) AchievementReward const* reward = sAchievementMgr.GetAchievementReward(achievement, GetPlayer()->getGender()); // no rewards - if(!reward) + if (!reward) return; // titles - if(uint32 titleId = reward->titleId[GetPlayer()->GetTeam() == HORDE ? 0 : 1]) + if (uint32 titleId = reward->titleId[GetPlayer()->GetTeam() == HORDE ? 0 : 1]) { - if(CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(titleId)) + if (CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(titleId)) GetPlayer()->SetTitle(titleEntry, true); } @@ -2228,9 +2230,9 @@ void AchievementMgr::SendRespondInspectAchievements(Player* player) /** * used by both SMSG_ALL_ACHIEVEMENT_DATA and SMSG_RESPOND_INSPECT_ACHIEVEMENT */ -void AchievementMgr::BuildAllDataPacket(WorldPacket *data) +void AchievementMgr::BuildAllDataPacket(WorldPacket* data) { - for(CompletedAchievementMap::const_iterator iter = m_completedAchievements.begin(); iter!=m_completedAchievements.end(); ++iter) + for (CompletedAchievementMap::const_iterator iter = m_completedAchievements.begin(); iter!=m_completedAchievements.end(); ++iter) { *data << uint32(iter->first); *data << uint32(secsToTimeBitFields(iter->second.date)); @@ -2238,7 +2240,7 @@ void AchievementMgr::BuildAllDataPacket(WorldPacket *data) *data << int32(-1); time_t now = time(NULL); - for(CriteriaProgressMap::const_iterator iter = m_criteriaProgress.begin(); iter!=m_criteriaProgress.end(); ++iter) + for (CriteriaProgressMap::const_iterator iter = m_criteriaProgress.begin(); iter!=m_criteriaProgress.end(); ++iter) { *data << uint32(iter->first); data->appendPackGUID(iter->second.counter); @@ -2274,7 +2276,7 @@ AchievementReward const* AchievementGlobalMgr::GetAchievementReward(AchievementE { AchievementRewardsMapBounds bounds = m_achievementRewards.equal_range(achievement->ID); for (AchievementRewardsMap::const_iterator iter = bounds.first; iter != bounds.second; ++iter) - if(iter->second.gender == GENDER_NONE || uint8(iter->second.gender) == gender) + if (iter->second.gender == GENDER_NONE || uint8(iter->second.gender) == gender) return &iter->second; return NULL; @@ -2284,7 +2286,7 @@ AchievementRewardLocale const* AchievementGlobalMgr::GetAchievementRewardLocale( { AchievementRewardLocalesMapBounds bounds = m_achievementRewardLocales.equal_range(achievement->ID); for (AchievementRewardLocalesMap::const_iterator iter = bounds.first; iter != bounds.second; ++iter) - if(iter->second.gender == GENDER_NONE || uint8(iter->second.gender) == gender) + if (iter->second.gender == GENDER_NONE || uint8(iter->second.gender) == gender) return &iter->second; return NULL; @@ -2350,7 +2352,7 @@ void AchievementGlobalMgr::LoadAchievementCriteriaList() void AchievementGlobalMgr::LoadAchievementReferenceList() { - if(sAchievementStore.GetNumRows()==0) + if (sAchievementStore.GetNumRows()==0) { BarGoLink bar(1); bar.step(); @@ -2391,7 +2393,7 @@ void AchievementGlobalMgr::LoadAchievementCriteriaRequirements() { m_criteriaRequirementMap.clear(); // need for reload case - QueryResult *result = WorldDatabase.Query("SELECT criteria_id, type, value1, value2 FROM achievement_criteria_requirement"); + QueryResult* result = WorldDatabase.Query("SELECT criteria_id, type, value1, value2 FROM achievement_criteria_requirement"); if (!result) { @@ -2409,14 +2411,14 @@ void AchievementGlobalMgr::LoadAchievementCriteriaRequirements() do { bar.step(); - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 criteria_id = fields[0].GetUInt32(); AchievementCriteriaEntry const* criteria = sAchievementCriteriaStore.LookupEntry(criteria_id); if (!criteria) { - sLog.outErrorDb( "Table `achievement_criteria_requirement`.`criteria_id` %u does not exist, ignoring.", criteria_id); + sLog.outErrorDb("Table `achievement_criteria_requirement`.`criteria_id` %u does not exist, ignoring.", criteria_id); continue; } @@ -2441,7 +2443,8 @@ void AchievementGlobalMgr::LoadAchievementCriteriaRequirements() // counting requirements ++count; - } while(result->NextRow()); + } + while (result->NextRow()); delete result; @@ -2449,13 +2452,13 @@ void AchievementGlobalMgr::LoadAchievementCriteriaRequirements() for (uint32 entryId = 0; entryId < sAchievementCriteriaStore.GetNumRows(); ++entryId) { AchievementCriteriaEntry const* criteria = sAchievementCriteriaStore.LookupEntry(entryId); - if(!criteria) + if (!criteria) continue; - switch(criteria->requiredType) + switch (criteria->requiredType) { case ACHIEVEMENT_CRITERIA_TYPE_WIN_BG: - if(!criteria->win_bg.additionalRequirement1_type && !criteria->win_bg.additionalRequirement2_type) + if (!criteria->win_bg.additionalRequirement1_type && !criteria->win_bg.additionalRequirement2_type) continue; break; case ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE: @@ -2466,12 +2469,12 @@ void AchievementGlobalMgr::LoadAchievementCriteriaRequirements() // Checked in LoadAchievementCriteriaList // exist many achievements with this criteria, use at this moment hardcoded check to skil simple case - switch(achievement->ID) + switch (achievement->ID) { case 31: - //case 1275: // these timed achievements are "started" on Quest Accept, and simple ended on quest-complete - //case 1276: - //case 1277: + //case 1275: // these timed achievements are "started" on Quest Accept, and simple ended on quest-complete + //case 1276: + //case 1277: case 1282: case 1789: break; @@ -2484,25 +2487,25 @@ void AchievementGlobalMgr::LoadAchievementCriteriaRequirements() case ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL: // any cases break; case ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA: // need skip generic cases - if(criteria->win_rated_arena.flag!=ACHIEVEMENT_CRITERIA_CONDITION_NO_LOOSE) + if (criteria->win_rated_arena.flag!=ACHIEVEMENT_CRITERIA_CONDITION_NO_LOOSE) continue; break; case ACHIEVEMENT_CRITERIA_TYPE_EQUIP_EPIC_ITEM: // any cases break; case ACHIEVEMENT_CRITERIA_TYPE_DO_EMOTE: // need skip generic cases - if(criteria->do_emote.count==0) + if (criteria->do_emote.count==0) continue; break; case ACHIEVEMENT_CRITERIA_TYPE_SPECIAL_PVP_KILL:// any cases break; case ACHIEVEMENT_CRITERIA_TYPE_WIN_DUEL: // skip statistics - if(criteria->win_duel.duelCount==0) + if (criteria->win_duel.duelCount==0) continue; break; case ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL2: // any cases break; case ACHIEVEMENT_CRITERIA_TYPE_LOOT_TYPE: // need skip generic cases - if(criteria->loot_type.lootTypeCount!=1) + if (criteria->loot_type.lootTypeCount!=1) continue; break; default: // type not use DB data, ignore @@ -2519,7 +2522,7 @@ void AchievementGlobalMgr::LoadAchievementCriteriaRequirements() void AchievementGlobalMgr::LoadCompletedAchievements() { - QueryResult *result = CharacterDatabase.Query("SELECT achievement FROM character_achievement GROUP BY achievement"); + QueryResult* result = CharacterDatabase.Query("SELECT achievement FROM character_achievement GROUP BY achievement"); if (!result) { @@ -2535,7 +2538,7 @@ void AchievementGlobalMgr::LoadCompletedAchievements() do { bar.step(); - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 achievement_id = fields[0].GetUInt32(); if (!sAchievementStore.LookupEntry(achievement_id)) @@ -2547,7 +2550,8 @@ void AchievementGlobalMgr::LoadCompletedAchievements() } m_allCompletedAchievements.insert(achievement_id); - } while(result->NextRow()); + } + while (result->NextRow()); delete result; @@ -2560,7 +2564,7 @@ void AchievementGlobalMgr::LoadRewards() m_achievementRewards.clear(); // need for reload case // 0 1 2 3 4 5 6 7 - QueryResult *result = WorldDatabase.Query("SELECT entry, gender, title_A, title_H, item, sender, subject, text FROM achievement_reward"); + QueryResult* result = WorldDatabase.Query("SELECT entry, gender, title_A, title_H, item, sender, subject, text FROM achievement_reward"); if (!result) { @@ -2580,11 +2584,11 @@ void AchievementGlobalMgr::LoadRewards() { bar.step(); - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 entry = fields[0].GetUInt32(); if (!sAchievementStore.LookupEntry(entry)) { - sLog.outErrorDb( "Table `achievement_reward` has wrong achievement (Entry: %u), ignore", entry); + sLog.outErrorDb("Table `achievement_reward` has wrong achievement (Entry: %u), ignore", entry); continue; } @@ -2598,7 +2602,7 @@ void AchievementGlobalMgr::LoadRewards() reward.text = fields[7].GetCppString(); if (reward.gender >= MAX_GENDER) - sLog.outErrorDb( "Table `achievement_reward` (Entry: %u) has wrong gender %u.", entry, reward.gender); + sLog.outErrorDb("Table `achievement_reward` (Entry: %u) has wrong gender %u.", entry, reward.gender); // GENDER_NONE must be single (so or already in and none must be attempt added new data or just adding and none in) // other duplicate cases prevented by DB primary key @@ -2609,7 +2613,7 @@ void AchievementGlobalMgr::LoadRewards() if (iter->second.gender == GENDER_NONE || reward.gender == GENDER_NONE) { dup = true; - sLog.outErrorDb( "Table `achievement_reward` must have single GENDER_NONE (%u) case (Entry: %u), ignore duplicate case", GENDER_NONE, entry); + sLog.outErrorDb("Table `achievement_reward` must have single GENDER_NONE (%u) case (Entry: %u), ignore duplicate case", GENDER_NONE, entry); break; } } @@ -2617,12 +2621,12 @@ void AchievementGlobalMgr::LoadRewards() continue; if ((reward.titleId[0]==0)!=(reward.titleId[1]==0)) - sLog.outErrorDb( "Table `achievement_reward` (Entry: %u) has title (A: %u H: %u) only for one from teams.", entry, reward.titleId[0], reward.titleId[1]); + sLog.outErrorDb("Table `achievement_reward` (Entry: %u) has title (A: %u H: %u) only for one from teams.", entry, reward.titleId[0], reward.titleId[1]); // must be title or mail at least if (!reward.titleId[0] && !reward.titleId[1] && !reward.sender) { - sLog.outErrorDb( "Table `achievement_reward` (Entry: %u) not have title or item reward data, ignore.", entry); + sLog.outErrorDb("Table `achievement_reward` (Entry: %u) not have title or item reward data, ignore.", entry); continue; } @@ -2631,7 +2635,7 @@ void AchievementGlobalMgr::LoadRewards() CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(reward.titleId[0]); if (!titleEntry) { - sLog.outErrorDb( "Table `achievement_reward` (Entry: %u) has invalid title id (%u) in `title_A`, set to 0", entry, reward.titleId[0]); + sLog.outErrorDb("Table `achievement_reward` (Entry: %u) has invalid title id (%u) in `title_A`, set to 0", entry, reward.titleId[0]); reward.titleId[0] = 0; } } @@ -2641,7 +2645,7 @@ void AchievementGlobalMgr::LoadRewards() CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(reward.titleId[1]); if (!titleEntry) { - sLog.outErrorDb( "Table `achievement_reward` (Entry: %u) has invalid title id (%u) in `title_A`, set to 0", entry, reward.titleId[1]); + sLog.outErrorDb("Table `achievement_reward` (Entry: %u) has invalid title id (%u) in `title_A`, set to 0", entry, reward.titleId[1]); reward.titleId[1] = 0; } } @@ -2651,27 +2655,27 @@ void AchievementGlobalMgr::LoadRewards() { if (!ObjectMgr::GetCreatureTemplate(reward.sender)) { - sLog.outErrorDb( "Table `achievement_reward` (Entry: %u) has invalid creature entry %u as sender, mail reward skipped.", entry, reward.sender); + sLog.outErrorDb("Table `achievement_reward` (Entry: %u) has invalid creature entry %u as sender, mail reward skipped.", entry, reward.sender); reward.sender = 0; } } else { if (reward.itemId) - sLog.outErrorDb( "Table `achievement_reward` (Entry: %u) not have sender data but have item reward, item will not rewarded", entry); + sLog.outErrorDb("Table `achievement_reward` (Entry: %u) not have sender data but have item reward, item will not rewarded", entry); if (!reward.subject.empty()) - sLog.outErrorDb( "Table `achievement_reward` (Entry: %u) not have sender data but have mail subject.", entry); + sLog.outErrorDb("Table `achievement_reward` (Entry: %u) not have sender data but have mail subject.", entry); if (!reward.text.empty()) - sLog.outErrorDb( "Table `achievement_reward` (Entry: %u) not have sender data but have mail text.", entry); + sLog.outErrorDb("Table `achievement_reward` (Entry: %u) not have sender data but have mail text.", entry); } if (reward.itemId) { if (!ObjectMgr::GetItemPrototype(reward.itemId)) { - sLog.outErrorDb( "Table `achievement_reward` (Entry: %u) has invalid item id %u, reward mail will be without item.", entry, reward.itemId); + sLog.outErrorDb("Table `achievement_reward` (Entry: %u) has invalid item id %u, reward mail will be without item.", entry, reward.itemId); reward.itemId = 0; } } @@ -2679,19 +2683,20 @@ void AchievementGlobalMgr::LoadRewards() m_achievementRewards.insert(AchievementRewardsMap::value_type(entry, reward)); ++count; - } while (result->NextRow()); + } + while (result->NextRow()); delete result; sLog.outString(); - sLog.outString( ">> Loaded %u achievement rewards", count ); + sLog.outString(">> Loaded %u achievement rewards", count); } void AchievementGlobalMgr::LoadRewardLocales() { m_achievementRewardLocales.clear(); // need for reload case - QueryResult *result = WorldDatabase.Query("SELECT entry,gender,subject_loc1,text_loc1,subject_loc2,text_loc2,subject_loc3,text_loc3,subject_loc4,text_loc4,subject_loc5,text_loc5,subject_loc6,text_loc6,subject_loc7,text_loc7,subject_loc8,text_loc8 FROM locales_achievement_reward"); + QueryResult* result = WorldDatabase.Query("SELECT entry,gender,subject_loc1,text_loc1,subject_loc2,text_loc2,subject_loc3,text_loc3,subject_loc4,text_loc4,subject_loc5,text_loc5,subject_loc6,text_loc6,subject_loc7,text_loc7,subject_loc8,text_loc8 FROM locales_achievement_reward"); if (!result) { @@ -2708,14 +2713,14 @@ void AchievementGlobalMgr::LoadRewardLocales() do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); bar.step(); uint32 entry = fields[0].GetUInt32(); if (m_achievementRewards.find(entry)==m_achievementRewards.end()) { - sLog.outErrorDb( "Table `locales_achievement_reward` (Entry: %u) has locale strings for nonexistent achievement reward .", entry); + sLog.outErrorDb("Table `locales_achievement_reward` (Entry: %u) has locale strings for nonexistent achievement reward .", entry); continue; } @@ -2724,7 +2729,7 @@ void AchievementGlobalMgr::LoadRewardLocales() data.gender = Gender(fields[1].GetUInt8()); if (data.gender >= MAX_GENDER) - sLog.outErrorDb( "Table `locales_achievement_reward` (Entry: %u) has wrong gender %u.", entry, data.gender); + sLog.outErrorDb("Table `locales_achievement_reward` (Entry: %u) has wrong gender %u.", entry, data.gender); // GENDER_NONE must be single (so or already in and none must be attempt added new data or just adding and none in) // other duplicate cases prevented by DB primary key @@ -2735,34 +2740,34 @@ void AchievementGlobalMgr::LoadRewardLocales() if (iter->second.gender == GENDER_NONE || data.gender == GENDER_NONE) { dup = true; - sLog.outErrorDb( "Table `locales_achievement_reward` must have single GENDER_NONE (%u) case (Entry: %u), ignore duplicate case", GENDER_NONE, entry); + sLog.outErrorDb("Table `locales_achievement_reward` must have single GENDER_NONE (%u) case (Entry: %u), ignore duplicate case", GENDER_NONE, entry); break; } } if (dup) continue; - for(int i = 1; i < MAX_LOCALE; ++i) + for (int i = 1; i < MAX_LOCALE; ++i) { std::string str = fields[2+2*(i-1)].GetCppString(); - if(!str.empty()) + if (!str.empty()) { int idx = sObjectMgr.GetOrNewIndexForLocale(LocaleConstant(i)); - if(idx >= 0) + if (idx >= 0) { - if(data.subject.size() <= size_t(idx)) + if (data.subject.size() <= size_t(idx)) data.subject.resize(idx+1); data.subject[idx] = str; } } str = fields[2+2*(i-1)+1].GetCppString(); - if(!str.empty()) + if (!str.empty()) { int idx = sObjectMgr.GetOrNewIndexForLocale(LocaleConstant(i)); - if(idx >= 0) + if (idx >= 0) { - if(data.text.size() <= size_t(idx)) + if (data.text.size() <= size_t(idx)) data.text.resize(idx+1); data.text[idx] = str; @@ -2772,10 +2777,11 @@ void AchievementGlobalMgr::LoadRewardLocales() m_achievementRewardLocales.insert(AchievementRewardLocalesMap::value_type(entry, data)); - } while (result->NextRow()); + } + while (result->NextRow()); delete result; sLog.outString(); - sLog.outString( ">> Loaded %lu achievement reward locale strings", (unsigned long)m_achievementRewardLocales.size() ); + sLog.outString(">> Loaded %lu achievement reward locale strings", (unsigned long)m_achievementRewardLocales.size()); } diff --git a/src/game/AchievementMgr.h b/src/game/AchievementMgr.h index 9a3971af6..b30f1bb4a 100644 --- a/src/game/AchievementMgr.h +++ b/src/game/AchievementMgr.h @@ -47,7 +47,8 @@ struct CriteriaProgress }; enum AchievementCriteriaRequirementType -{ // value1 value2 comment +{ + // value1 value2 comment ACHIEVEMENT_CRITERIA_REQUIRE_NONE = 0, // 0 0 ACHIEVEMENT_CRITERIA_REQUIRE_T_CREATURE = 1, // creature_id 0 ACHIEVEMENT_CRITERIA_REQUIRE_T_PLAYER_CLASS_RACE = 2, // class_id race_id @@ -261,12 +262,12 @@ class AchievementMgr void Reset(); static void DeleteFromDB(ObjectGuid guid); - void LoadFromDB(QueryResult *achievementResult, QueryResult *criteriaResult); + void LoadFromDB(QueryResult* achievementResult, QueryResult* criteriaResult); void SaveToDB(); void ResetAchievementCriteria(AchievementCriteriaTypes type, uint32 miscvalue1=0, uint32 miscvalue2=0); void StartTimedAchievementCriteria(AchievementCriteriaTypes type, uint32 timedRequirementId, time_t startTime = 0); void DoFailedTimedAchievementCriterias(); - void UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscvalue1=0, uint32 miscvalue2=0, Unit *unit=NULL, uint32 time=0); + void UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscvalue1=0, uint32 miscvalue2=0, Unit* unit=NULL, uint32 time=0); void CheckAllAchievementCriteria(); void SendAllAchievementData(); void SendRespondInspectAchievements(Player* player); @@ -298,7 +299,7 @@ class AchievementMgr void IncompletedAchievement(AchievementEntry const* entry); bool IsCompletedAchievement(AchievementEntry const* entry); void CompleteAchievementsWithRefs(AchievementEntry const* entry); - void BuildAllDataPacket(WorldPacket *data); + void BuildAllDataPacket(WorldPacket* data); Player* m_player; CriteriaProgressMap m_criteriaProgress; diff --git a/src/game/AggressorAI.cpp b/src/game/AggressorAI.cpp index 9f6e87440..d7d7f0523 100644 --- a/src/game/AggressorAI.cpp +++ b/src/game/AggressorAI.cpp @@ -28,38 +28,38 @@ #include int -AggressorAI::Permissible(const Creature *creature) +AggressorAI::Permissible(const Creature* creature) { // have some hostile factions, it will be selected by IsHostileTo check at MoveInLineOfSight - if( !creature->IsCivilian() && !creature->IsNeutralToAll() ) + if (!creature->IsCivilian() && !creature->IsNeutralToAll()) return PERMIT_BASE_PROACTIVE; return PERMIT_BASE_NO; } -AggressorAI::AggressorAI(Creature *c) : CreatureAI(c), i_state(STATE_NORMAL), i_tracker(TIME_INTERVAL_LOOK) +AggressorAI::AggressorAI(Creature* c) : CreatureAI(c), i_state(STATE_NORMAL), i_tracker(TIME_INTERVAL_LOOK) { } void -AggressorAI::MoveInLineOfSight(Unit *u) +AggressorAI::MoveInLineOfSight(Unit* u) { // Ignore Z for flying creatures - if( !m_creature->CanFly() && m_creature->GetDistanceZ(u) > CREATURE_Z_ATTACK_RANGE ) + if (!m_creature->CanFly() && m_creature->GetDistanceZ(u) > CREATURE_Z_ATTACK_RANGE) return; if (m_creature->CanInitiateAttack() && u->isTargetableForAttack() && - m_creature->IsHostileTo(u) && u->isInAccessablePlaceFor(m_creature)) + m_creature->IsHostileTo(u) && u->isInAccessablePlaceFor(m_creature)) { float attackRadius = m_creature->GetAttackDistance(u); - if(m_creature->IsWithinDistInMap(u, attackRadius) && m_creature->IsWithinLOSInMap(u) ) + if (m_creature->IsWithinDistInMap(u, attackRadius) && m_creature->IsWithinLOSInMap(u)) { - if(!m_creature->getVictim()) + if (!m_creature->getVictim()) { AttackStart(u); u->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); } - else if(sMapStore.LookupEntry(m_creature->GetMapId())->IsDungeon()) + else if (sMapStore.LookupEntry(m_creature->GetMapId())->IsDungeon()) { m_creature->AddThreat(u); u->SetInCombatWith(m_creature); @@ -123,7 +123,7 @@ void AggressorAI::UpdateAI(const uint32 /*diff*/) { // update i_victimGuid if m_creature->getVictim() !=0 and changed - if(!m_creature->SelectHostileTarget() || !m_creature->getVictim()) + if (!m_creature->SelectHostileTarget() || !m_creature->getVictim()) return; i_victimGuid = m_creature->getVictim()->GetObjectGuid(); @@ -132,19 +132,19 @@ AggressorAI::UpdateAI(const uint32 /*diff*/) } bool -AggressorAI::IsVisible(Unit *pl) const +AggressorAI::IsVisible(Unit* pl) const { return m_creature->IsWithinDist(pl,sWorld.getConfig(CONFIG_FLOAT_SIGHT_MONSTER)) - && pl->isVisibleForOrDetect(m_creature,m_creature,true); + && pl->isVisibleForOrDetect(m_creature,m_creature,true); } void -AggressorAI::AttackStart(Unit *u) +AggressorAI::AttackStart(Unit* u) { - if( !u ) + if (!u) return; - if(m_creature->Attack(u,true)) + if (m_creature->Attack(u,true)) { i_victimGuid = u->GetObjectGuid(); diff --git a/src/game/AggressorAI.h b/src/game/AggressorAI.h index beefeed0d..96b290588 100644 --- a/src/game/AggressorAI.h +++ b/src/game/AggressorAI.h @@ -27,23 +27,23 @@ class Creature; class MANGOS_DLL_DECL AggressorAI : public CreatureAI { - enum AggressorState - { - STATE_NORMAL = 1, - STATE_LOOK_AT_VICTIM = 2 - }; + enum AggressorState + { + STATE_NORMAL = 1, + STATE_LOOK_AT_VICTIM = 2 + }; public: - explicit AggressorAI(Creature *c); + explicit AggressorAI(Creature* c); - void MoveInLineOfSight(Unit *); - void AttackStart(Unit *); + void MoveInLineOfSight(Unit*); + void AttackStart(Unit*); void EnterEvadeMode(); - bool IsVisible(Unit *) const; + bool IsVisible(Unit*) const; void UpdateAI(const uint32); - static int Permissible(const Creature *); + static int Permissible(const Creature*); private: ObjectGuid i_victimGuid; diff --git a/src/game/ArenaTeam.cpp b/src/game/ArenaTeam.cpp index 5e946d215..88303fd49 100644 --- a/src/game/ArenaTeam.cpp +++ b/src/game/ArenaTeam.cpp @@ -29,7 +29,7 @@ void ArenaTeamMember::ModifyPersonalRating(Player* plr, int32 mod, uint32 slot) personal_rating = 0; else personal_rating += mod; - if(plr) + if (plr) plr->SetArenaTeamInfoField(slot, ARENA_TEAM_PERSONAL_RATING, personal_rating); } @@ -90,10 +90,10 @@ bool ArenaTeam::Create(ObjectGuid captainGuid, ArenaType type, std::string arena // CharacterDatabase.PExecute("DELETE FROM arena_team WHERE arenateamid='%u'", m_TeamId); - MAX(arenateam)+1 not exist CharacterDatabase.PExecute("DELETE FROM arena_team_member WHERE arenateamid='%u'", m_TeamId); CharacterDatabase.PExecute("INSERT INTO arena_team (arenateamid,name,captainguid,type,BackgroundColor,EmblemStyle,EmblemColor,BorderStyle,BorderColor) " - "VALUES('%u','%s','%u','%u','%u','%u','%u','%u','%u')", - m_TeamId, arenaTeamName.c_str(), m_CaptainGuid.GetCounter(), m_Type, m_BackgroundColor, m_EmblemStyle, m_EmblemColor, m_BorderStyle, m_BorderColor); + "VALUES('%u','%s','%u','%u','%u','%u','%u','%u','%u')", + m_TeamId, arenaTeamName.c_str(), m_CaptainGuid.GetCounter(), m_Type, m_BackgroundColor, m_EmblemStyle, m_EmblemColor, m_BorderStyle, m_BorderColor); CharacterDatabase.PExecute("INSERT INTO arena_team_stats (arenateamid, rating, games_week, wins_week, games_season, wins_season, rank) VALUES " - "('%u', '%u', '%u', '%u', '%u', '%u', '%u')", m_TeamId, m_stats.rating, m_stats.games_week, m_stats.wins_week, m_stats.games_season, m_stats.wins_season, m_stats.rank); + "('%u', '%u', '%u', '%u', '%u', '%u', '%u')", m_TeamId, m_stats.rating, m_stats.games_week, m_stats.wins_week, m_stats.games_season, m_stats.wins_season, m_stats.rank); CharacterDatabase.CommitTransaction(); @@ -110,7 +110,7 @@ bool ArenaTeam::AddMember(ObjectGuid playerGuid) if (GetMembersSize() >= GetMaxMembersSize()) return false; - Player *pl = sObjectMgr.GetPlayer(playerGuid); + Player* pl = sObjectMgr.GetPlayer(playerGuid); if (pl) { if (pl->GetArenaTeamId(GetSlot())) @@ -125,7 +125,7 @@ bool ArenaTeam::AddMember(ObjectGuid playerGuid) else { // 0 1 - QueryResult *result = CharacterDatabase.PQuery("SELECT name, class FROM characters WHERE guid='%u'", playerGuid.GetCounter()); + QueryResult* result = CharacterDatabase.PQuery("SELECT name, class FROM characters WHERE guid='%u'", playerGuid.GetCounter()); if (!result) return false; @@ -174,9 +174,9 @@ bool ArenaTeam::AddMember(ObjectGuid playerGuid) m_members.push_back(newmember); - CharacterDatabase.PExecute("INSERT INTO arena_team_member (arenateamid, guid, personal_rating) VALUES ('%u', '%u', '%u')", m_TeamId, newmember.guid.GetCounter(), newmember.personal_rating ); + CharacterDatabase.PExecute("INSERT INTO arena_team_member (arenateamid, guid, personal_rating) VALUES ('%u', '%u', '%u')", m_TeamId, newmember.guid.GetCounter(), newmember.personal_rating); - if(pl) + if (pl) { pl->SetInArenaTeam(m_TeamId, GetSlot(), GetType()); pl->SetArenaTeamIdInvited(0); @@ -189,12 +189,12 @@ bool ArenaTeam::AddMember(ObjectGuid playerGuid) return true; } -bool ArenaTeam::LoadArenaTeamFromDB(QueryResult *arenaTeamDataResult) +bool ArenaTeam::LoadArenaTeamFromDB(QueryResult* arenaTeamDataResult) { - if(!arenaTeamDataResult) + if (!arenaTeamDataResult) return false; - Field *fields = arenaTeamDataResult->Fetch(); + Field* fields = arenaTeamDataResult->Fetch(); m_TeamId = fields[0].GetUInt32(); m_Name = fields[1].GetCppString(); @@ -220,16 +220,16 @@ bool ArenaTeam::LoadArenaTeamFromDB(QueryResult *arenaTeamDataResult) return true; } -bool ArenaTeam::LoadMembersFromDB(QueryResult *arenaTeamMembersResult) +bool ArenaTeam::LoadMembersFromDB(QueryResult* arenaTeamMembersResult) { - if(!arenaTeamMembersResult) + if (!arenaTeamMembersResult) return false; bool captainPresentInTeam = false; do { - Field *fields = arenaTeamMembersResult->Fetch(); + Field* fields = arenaTeamMembersResult->Fetch(); //prevent crash if db records are broken, when all members in result are already processed and current team hasn't got any members if (!fields) break; @@ -272,7 +272,8 @@ bool ArenaTeam::LoadMembersFromDB(QueryResult *arenaTeamMembersResult) captainPresentInTeam = true; m_members.push_back(newmember); - } while (arenaTeamMembersResult->NextRow()); + } + while (arenaTeamMembersResult->NextRow()); if (Empty() || !captainPresentInTeam) { @@ -287,7 +288,7 @@ bool ArenaTeam::LoadMembersFromDB(QueryResult *arenaTeamMembersResult) void ArenaTeam::SetCaptain(ObjectGuid guid) { // disable remove/promote buttons - Player *oldcaptain = sObjectMgr.GetPlayer(GetCaptainGuid()); + Player* oldcaptain = sObjectMgr.GetPlayer(GetCaptainGuid()); if (oldcaptain) oldcaptain->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_MEMBER, 1); @@ -298,7 +299,7 @@ void ArenaTeam::SetCaptain(ObjectGuid guid) CharacterDatabase.PExecute("UPDATE arena_team SET captainguid = '%u' WHERE arenateamid = '%u'", guid.GetCounter(), m_TeamId); // enable remove/promote buttons - if (Player *newcaptain = sObjectMgr.GetPlayer(guid)) + if (Player* newcaptain = sObjectMgr.GetPlayer(guid)) newcaptain->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_MEMBER, 0); } @@ -317,14 +318,14 @@ void ArenaTeam::DelMember(ObjectGuid guid) { player->GetSession()->SendArenaTeamCommandResult(ERR_ARENA_TEAM_QUIT_S, GetName(), "", 0); // delete all info regarding this team - for(int i = 0; i < ARENA_TEAM_END; ++i) + for (int i = 0; i < ARENA_TEAM_END; ++i) player->SetArenaTeamInfoField(GetSlot(), ArenaTeamInfoType(i), 0); } CharacterDatabase.PExecute("DELETE FROM arena_team_member WHERE arenateamid = '%u' AND guid = '%u'", GetId(), guid.GetCounter()); } -void ArenaTeam::Disband(WorldSession *session) +void ArenaTeam::Disband(WorldSession* session) { // event if (session) @@ -347,9 +348,9 @@ void ArenaTeam::Disband(WorldSession *session) sObjectMgr.RemoveArenaTeam(m_TeamId); } -void ArenaTeam::Roster(WorldSession *session) +void ArenaTeam::Roster(WorldSession* session) { - Player *pl = NULL; + Player* pl = NULL; uint8 unk308 = 0; @@ -374,7 +375,7 @@ void ArenaTeam::Roster(WorldSession *session) data << uint32(itr->games_season); // played this season data << uint32(itr->wins_season); // wins this season data << uint32(itr->personal_rating); // personal rating - if(unk308) + if (unk308) { data << float(0.0); // 308 unk data << float(0.0); // 308 unk @@ -385,7 +386,7 @@ void ArenaTeam::Roster(WorldSession *session) DEBUG_LOG("WORLD: Sent SMSG_ARENA_TEAM_ROSTER"); } -void ArenaTeam::Query(WorldSession *session) +void ArenaTeam::Query(WorldSession* session) { WorldPacket data(SMSG_ARENA_TEAM_QUERY_RESPONSE, 4*7+GetName().size()+1); data << uint32(GetId()); // team id @@ -400,7 +401,7 @@ void ArenaTeam::Query(WorldSession *session) DEBUG_LOG("WORLD: Sent SMSG_ARENA_TEAM_QUERY_RESPONSE"); } -void ArenaTeam::Stats(WorldSession *session) +void ArenaTeam::Stats(WorldSession* session) { WorldPacket data(SMSG_ARENA_TEAM_STATS, 4*7); data << uint32(GetId()); // team id @@ -417,18 +418,18 @@ void ArenaTeam::NotifyStatsChanged() { // this is called after a rated match ended // updates arena team stats for every member of the team (not only the ones who participated!) - for(MemberList::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr) + for (MemberList::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr) { - Player * plr = sObjectMgr.GetPlayer(itr->guid); - if(plr) + Player* plr = sObjectMgr.GetPlayer(itr->guid); + if (plr) Stats(plr->GetSession()); } } -void ArenaTeam::InspectStats(WorldSession *session, ObjectGuid guid) +void ArenaTeam::InspectStats(WorldSession* session, ObjectGuid guid) { ArenaTeamMember* member = GetMember(guid); - if(!member) + if (!member) return; WorldPacket data(MSG_INSPECT_ARENA_TEAMS, 8+1+4*6); @@ -456,7 +457,7 @@ void ArenaTeam::SetEmblem(uint32 backgroundColor, uint32 emblemStyle, uint32 emb void ArenaTeam::SetStats(uint32 stat_type, uint32 value) { - switch(stat_type) + switch (stat_type) { case STAT_TYPE_RATING: m_stats.rating = value; @@ -488,12 +489,12 @@ void ArenaTeam::SetStats(uint32 stat_type, uint32 value) } } -void ArenaTeam::BroadcastPacket(WorldPacket *packet) +void ArenaTeam::BroadcastPacket(WorldPacket* packet) { for (MemberList::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr) { - Player *player = sObjectMgr.GetPlayer(itr->guid); - if(player) + Player* player = sObjectMgr.GetPlayer(itr->guid); + if (player) player->GetSession()->SendPacket(packet); } } @@ -528,9 +529,9 @@ void ArenaTeam::BroadcastEvent(ArenaTeamEvents event, ObjectGuid guid, char cons DEBUG_LOG("WORLD: Sent SMSG_ARENA_TEAM_EVENT"); } -uint8 ArenaTeam::GetSlotByType(ArenaType type ) +uint8 ArenaTeam::GetSlotByType(ArenaType type) { - switch(type) + switch (type) { case ARENA_TYPE_2v2: return 0; case ARENA_TYPE_3v3: return 1; @@ -545,7 +546,7 @@ uint8 ArenaTeam::GetSlotByType(ArenaType type ) bool ArenaTeam::HaveMember(ObjectGuid guid) const { for (MemberList::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr) - if(itr->guid == guid) + if (itr->guid == guid) return true; return false; @@ -572,7 +573,7 @@ uint32 ArenaTeam::GetPoints(uint32 MemberRating) // type penalties for <5v5 teams if (m_Type == ARENA_TYPE_2v2) points *= 0.76f; - else if(m_Type == ARENA_TYPE_3v3) + else if (m_Type == ARENA_TYPE_3v3) points *= 0.88f; return (uint32) points; @@ -601,7 +602,7 @@ void ArenaTeam::FinishGame(int32 mod) // update team's rank m_stats.rank = 1; ObjectMgr::ArenaTeamMap::const_iterator i = sObjectMgr.GetArenaTeamMapBegin(); - for ( ; i != sObjectMgr.GetArenaTeamMapEnd(); ++i) + for (; i != sObjectMgr.GetArenaTeamMapEnd(); ++i) { if (i->second->GetType() == this->m_Type && i->second->GetStats().rating > m_stats.rating) ++m_stats.rank; @@ -640,10 +641,10 @@ int32 ArenaTeam::LostAgainst(uint32 againstRating) return mod; } -void ArenaTeam::MemberLost(Player * plr, uint32 againstRating) +void ArenaTeam::MemberLost(Player* plr, uint32 againstRating) { // called for each participant of a match after losing - for(MemberList::iterator itr = m_members.begin(); itr != m_members.end(); ++itr) + for (MemberList::iterator itr = m_members.begin(); itr != m_members.end(); ++itr) { if (itr->guid == plr->GetObjectGuid()) { @@ -667,7 +668,7 @@ void ArenaTeam::MemberLost(Player * plr, uint32 againstRating) void ArenaTeam::OfflineMemberLost(ObjectGuid guid, uint32 againstRating) { // called for offline player after ending rated arena match! - for(MemberList::iterator itr = m_members.begin(); itr != m_members.end(); ++itr) + for (MemberList::iterator itr = m_members.begin(); itr != m_members.end(); ++itr) { if (itr->guid == guid) { @@ -688,10 +689,10 @@ void ArenaTeam::OfflineMemberLost(ObjectGuid guid, uint32 againstRating) } } -void ArenaTeam::MemberWon(Player * plr, uint32 againstRating) +void ArenaTeam::MemberWon(Player* plr, uint32 againstRating) { // called for each participant after winning a match - for(MemberList::iterator itr = m_members.begin(); itr != m_members.end(); ++itr) + for (MemberList::iterator itr = m_members.begin(); itr != m_members.end(); ++itr) { if (itr->guid == plr->GetObjectGuid()) { @@ -723,7 +724,7 @@ void ArenaTeam::UpdateArenaPointsHelper(std::map& PlayerPoints) return; // to get points, a player has to participate in at least 30% of the matches uint32 min_plays = (uint32) ceil(m_stats.games_week * 0.3); - for(MemberList::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr) + for (MemberList::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr) { // the player participated in enough games, update his points uint32 points_to_add = 0; @@ -749,7 +750,7 @@ void ArenaTeam::SaveToDB() // called after a match has ended, or when calculating arena_points CharacterDatabase.BeginTransaction(); CharacterDatabase.PExecute("UPDATE arena_team_stats SET rating = '%u',games_week = '%u',games_season = '%u',rank = '%u',wins_week = '%u',wins_season = '%u' WHERE arenateamid = '%u'", m_stats.rating, m_stats.games_week, m_stats.games_season, m_stats.rank, m_stats.wins_week, m_stats.wins_season, GetId()); - for(MemberList::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr) + for (MemberList::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr) { CharacterDatabase.PExecute("UPDATE arena_team_member SET played_week = '%u', wons_week = '%u', played_season = '%u', wons_season = '%u', personal_rating = '%u' WHERE arenateamid = '%u' AND guid = '%u'", itr->games_week, itr->wins_week, itr->games_season, itr->wins_season, itr->personal_rating, m_TeamId, itr->guid.GetCounter()); } @@ -760,7 +761,7 @@ void ArenaTeam::FinishWeek() { m_stats.games_week = 0; // played this week m_stats.wins_week = 0; // wins this week - for(MemberList::iterator itr = m_members.begin(); itr != m_members.end(); ++itr) + for (MemberList::iterator itr = m_members.begin(); itr != m_members.end(); ++itr) { itr->games_week = 0; itr->wins_week = 0; @@ -771,7 +772,7 @@ bool ArenaTeam::IsFighting() const { for (MemberList::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr) { - if (Player *p = sObjectMgr.GetPlayer(itr->guid)) + if (Player* p = sObjectMgr.GetPlayer(itr->guid)) { if (p->GetMap()->IsBattleArena()) return true; diff --git a/src/game/ArenaTeam.h b/src/game/ArenaTeam.h index 450f1b8a2..45ce56a6a 100644 --- a/src/game/ArenaTeam.h +++ b/src/game/ArenaTeam.h @@ -120,7 +120,7 @@ class ArenaTeam ~ArenaTeam(); bool Create(ObjectGuid captainGuid, ArenaType type, std::string arenaTeamName); - void Disband(WorldSession *session); + void Disband(WorldSession* session); typedef std::list MemberList; @@ -173,13 +173,13 @@ class ArenaTeam bool IsFighting() const; - bool LoadArenaTeamFromDB(QueryResult *arenaTeamDataResult); - bool LoadMembersFromDB(QueryResult *arenaTeamMembersResult); + bool LoadArenaTeamFromDB(QueryResult* arenaTeamDataResult); + bool LoadMembersFromDB(QueryResult* arenaTeamMembersResult); void LoadStatsFromDB(uint32 ArenaTeamId); void SaveToDB(); - void BroadcastPacket(WorldPacket *packet); + void BroadcastPacket(WorldPacket* packet); void BroadcastEvent(ArenaTeamEvents event, ObjectGuid guid, char const* str1 = NULL, char const* str2 = NULL, char const* str3 = NULL); void BroadcastEvent(ArenaTeamEvents event, char const* str1 = NULL, char const* str2 = NULL, char const* str3 = NULL) @@ -187,20 +187,20 @@ class ArenaTeam BroadcastEvent(event, ObjectGuid(), str1, str2, str3); } - void Roster(WorldSession *session); - void Query(WorldSession *session); - void Stats(WorldSession *session); - void InspectStats(WorldSession *session, ObjectGuid guid); + void Roster(WorldSession* session); + void Query(WorldSession* session); + void Stats(WorldSession* session); + void InspectStats(WorldSession* session, ObjectGuid guid); uint32 GetPoints(uint32 MemberRating); float GetChanceAgainst(uint32 own_rating, uint32 enemy_rating); int32 WonAgainst(uint32 againstRating); - void MemberWon(Player * plr, uint32 againstRating); + void MemberWon(Player* plr, uint32 againstRating); int32 LostAgainst(uint32 againstRating); - void MemberLost(Player * plr, uint32 againstRating); + void MemberLost(Player* plr, uint32 againstRating); void OfflineMemberLost(ObjectGuid guid, uint32 againstRating); - void UpdateArenaPointsHelper(std::map & PlayerPoints); + void UpdateArenaPointsHelper(std::map& PlayerPoints); void NotifyStatsChanged(); diff --git a/src/game/ArenaTeamHandler.cpp b/src/game/ArenaTeamHandler.cpp index e1c0f0028..9f6e8f265 100644 --- a/src/game/ArenaTeamHandler.cpp +++ b/src/game/ArenaTeamHandler.cpp @@ -26,7 +26,7 @@ #include "World.h" #include "SocialMgr.h" -void WorldSession::HandleInspectArenaTeamsOpcode(WorldPacket & recv_data) +void WorldSession::HandleInspectArenaTeamsOpcode(WorldPacket& recv_data) { DEBUG_LOG("MSG_INSPECT_ARENA_TEAMS"); @@ -34,84 +34,84 @@ void WorldSession::HandleInspectArenaTeamsOpcode(WorldPacket & recv_data) recv_data >> guid; DEBUG_LOG("Inspect Arena stats %s", guid.GetString().c_str()); - if(Player *plr = sObjectMgr.GetPlayer(guid)) + if (Player* plr = sObjectMgr.GetPlayer(guid)) { for (uint8 i = 0; i < MAX_ARENA_SLOT; ++i) { - if(uint32 a_id = plr->GetArenaTeamId(i)) + if (uint32 a_id = plr->GetArenaTeamId(i)) { - if(ArenaTeam *at = sObjectMgr.GetArenaTeamById(a_id)) + if (ArenaTeam* at = sObjectMgr.GetArenaTeamById(a_id)) at->InspectStats(this, plr->GetObjectGuid()); } } } } -void WorldSession::HandleArenaTeamQueryOpcode(WorldPacket & recv_data) +void WorldSession::HandleArenaTeamQueryOpcode(WorldPacket& recv_data) { - DEBUG_LOG( "WORLD: Received CMSG_ARENA_TEAM_QUERY" ); + DEBUG_LOG("WORLD: Received CMSG_ARENA_TEAM_QUERY"); uint32 ArenaTeamId; recv_data >> ArenaTeamId; - if(ArenaTeam *arenateam = sObjectMgr.GetArenaTeamById(ArenaTeamId)) + if (ArenaTeam* arenateam = sObjectMgr.GetArenaTeamById(ArenaTeamId)) { arenateam->Query(this); arenateam->Stats(this); } } -void WorldSession::HandleArenaTeamRosterOpcode(WorldPacket & recv_data) +void WorldSession::HandleArenaTeamRosterOpcode(WorldPacket& recv_data) { - DEBUG_LOG( "WORLD: Received CMSG_ARENA_TEAM_ROSTER" ); + DEBUG_LOG("WORLD: Received CMSG_ARENA_TEAM_ROSTER"); uint32 ArenaTeamId; // arena team id recv_data >> ArenaTeamId; - if(ArenaTeam *arenateam = sObjectMgr.GetArenaTeamById(ArenaTeamId)) + if (ArenaTeam* arenateam = sObjectMgr.GetArenaTeamById(ArenaTeamId)) arenateam->Roster(this); } -void WorldSession::HandleArenaTeamInviteOpcode(WorldPacket & recv_data) +void WorldSession::HandleArenaTeamInviteOpcode(WorldPacket& recv_data) { DEBUG_LOG("CMSG_ARENA_TEAM_INVITE"); uint32 ArenaTeamId; // arena team id std::string Invitedname; - Player * player = NULL; + Player* player = NULL; recv_data >> ArenaTeamId >> Invitedname; - if(!Invitedname.empty()) + if (!Invitedname.empty()) { - if(!normalizePlayerName(Invitedname)) + if (!normalizePlayerName(Invitedname)) return; player = ObjectAccessor::FindPlayerByName(Invitedname.c_str()); } - if(!player) + if (!player) { SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", Invitedname, ERR_ARENA_TEAM_PLAYER_NOT_FOUND_S); return; } - if(player->getLevel() < sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)) + if (player->getLevel() < sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)) { SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", player->GetName(), ERR_ARENA_TEAM_TARGET_TOO_LOW_S); return; } - ArenaTeam *arenateam = sObjectMgr.GetArenaTeamById(ArenaTeamId); - if(!arenateam) + ArenaTeam* arenateam = sObjectMgr.GetArenaTeamById(ArenaTeamId); + if (!arenateam) { SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", "", ERR_ARENA_TEAM_PLAYER_NOT_IN_TEAM); return; } // OK result but not send invite - if(player->GetSocial()->HasIgnore(GetPlayer()->GetObjectGuid())) + if (player->GetSocial()->HasIgnore(GetPlayer()->GetObjectGuid())) return; if (!sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_GUILD) && player->GetTeam() != GetPlayer()->GetTeam()) @@ -120,19 +120,19 @@ void WorldSession::HandleArenaTeamInviteOpcode(WorldPacket & recv_data) return; } - if(player->GetArenaTeamId(arenateam->GetSlot())) + if (player->GetArenaTeamId(arenateam->GetSlot())) { SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", player->GetName(), ERR_ALREADY_IN_ARENA_TEAM_S); return; } - if(player->GetArenaTeamIdInvited()) + if (player->GetArenaTeamIdInvited()) { SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", player->GetName(), ERR_ALREADY_INVITED_TO_ARENA_TEAM_S); return; } - if(arenateam->GetMembersSize() >= arenateam->GetMaxMembersSize()) + if (arenateam->GetMembersSize() >= arenateam->GetMaxMembersSize()) { SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, arenateam->GetName(), "", ERR_ARENA_TEAM_TOO_MANY_MEMBERS_S); return; @@ -150,11 +150,11 @@ void WorldSession::HandleArenaTeamInviteOpcode(WorldPacket & recv_data) DEBUG_LOG("WORLD: Sent SMSG_ARENA_TEAM_INVITE"); } -void WorldSession::HandleArenaTeamAcceptOpcode(WorldPacket & /*recv_data*/) +void WorldSession::HandleArenaTeamAcceptOpcode(WorldPacket& /*recv_data*/) { DEBUG_LOG("CMSG_ARENA_TEAM_ACCEPT"); // empty opcode - ArenaTeam *at = sObjectMgr.GetArenaTeamById(_player->GetArenaTeamIdInvited()); + ArenaTeam* at = sObjectMgr.GetArenaTeamById(_player->GetArenaTeamIdInvited()); if (!at) return; @@ -166,7 +166,7 @@ void WorldSession::HandleArenaTeamAcceptOpcode(WorldPacket & /*recv_data*/) } if (!sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_GUILD) && - _player->GetTeam() != sObjectMgr.GetPlayerTeamByGUID(at->GetCaptainGuid())) + _player->GetTeam() != sObjectMgr.GetPlayerTeamByGUID(at->GetCaptainGuid())) { // not let enemies sign petition SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", "", ERR_ARENA_TEAM_NOT_ALLIED); @@ -184,21 +184,21 @@ void WorldSession::HandleArenaTeamAcceptOpcode(WorldPacket & /*recv_data*/) at->BroadcastEvent(ERR_ARENA_TEAM_JOIN_SS, _player->GetObjectGuid(), _player->GetName(), at->GetName().c_str()); } -void WorldSession::HandleArenaTeamDeclineOpcode(WorldPacket & /*recv_data*/) +void WorldSession::HandleArenaTeamDeclineOpcode(WorldPacket& /*recv_data*/) { DEBUG_LOG("CMSG_ARENA_TEAM_DECLINE"); // empty opcode _player->SetArenaTeamIdInvited(0); // no more invited } -void WorldSession::HandleArenaTeamLeaveOpcode(WorldPacket & recv_data) +void WorldSession::HandleArenaTeamLeaveOpcode(WorldPacket& recv_data) { DEBUG_LOG("CMSG_ARENA_TEAM_LEAVE"); uint32 ArenaTeamId; // arena team id recv_data >> ArenaTeamId; - ArenaTeam *at = sObjectMgr.GetArenaTeamById(ArenaTeamId); + ArenaTeam* at = sObjectMgr.GetArenaTeamById(ArenaTeamId); if (!at) return; @@ -226,14 +226,14 @@ void WorldSession::HandleArenaTeamLeaveOpcode(WorldPacket & recv_data) SendArenaTeamCommandResult(ERR_ARENA_TEAM_QUIT_S, at->GetName(), "", 0); } -void WorldSession::HandleArenaTeamDisbandOpcode(WorldPacket & recv_data) +void WorldSession::HandleArenaTeamDisbandOpcode(WorldPacket& recv_data) { DEBUG_LOG("CMSG_ARENA_TEAM_DISBAND"); uint32 ArenaTeamId; // arena team id recv_data >> ArenaTeamId; - if (ArenaTeam *at = sObjectMgr.GetArenaTeamById(ArenaTeamId)) + if (ArenaTeam* at = sObjectMgr.GetArenaTeamById(ArenaTeamId)) { if (at->GetCaptainGuid() != _player->GetObjectGuid()) return; @@ -246,7 +246,7 @@ void WorldSession::HandleArenaTeamDisbandOpcode(WorldPacket & recv_data) } } -void WorldSession::HandleArenaTeamRemoveOpcode(WorldPacket & recv_data) +void WorldSession::HandleArenaTeamRemoveOpcode(WorldPacket& recv_data) { DEBUG_LOG("CMSG_ARENA_TEAM_REMOVE"); @@ -256,7 +256,7 @@ void WorldSession::HandleArenaTeamRemoveOpcode(WorldPacket & recv_data) recv_data >> ArenaTeamId; recv_data >> name; - ArenaTeam *at = sObjectMgr.GetArenaTeamById(ArenaTeamId); + ArenaTeam* at = sObjectMgr.GetArenaTeamById(ArenaTeamId); if (!at) // arena team not found return; @@ -288,7 +288,7 @@ void WorldSession::HandleArenaTeamRemoveOpcode(WorldPacket & recv_data) at->BroadcastEvent(ERR_ARENA_TEAM_REMOVE_SSS, name.c_str(), at->GetName().c_str(), _player->GetName()); } -void WorldSession::HandleArenaTeamLeaderOpcode(WorldPacket & recv_data) +void WorldSession::HandleArenaTeamLeaderOpcode(WorldPacket& recv_data) { DEBUG_LOG("CMSG_ARENA_TEAM_LEADER"); @@ -298,7 +298,7 @@ void WorldSession::HandleArenaTeamLeaderOpcode(WorldPacket & recv_data) recv_data >> ArenaTeamId; recv_data >> name; - ArenaTeam *at = sObjectMgr.GetArenaTeamById(ArenaTeamId); + ArenaTeam* at = sObjectMgr.GetArenaTeamById(ArenaTeamId); if (!at) // arena team not found return; @@ -342,7 +342,7 @@ void WorldSession::SendNotInArenaTeamPacket(uint8 type) WorldPacket data(SMSG_ARENA_ERROR, 4+1); // 886 - You are not in a %uv%u arena team uint32 unk = 0; data << uint32(unk); // unk(0) - if(!unk) + if (!unk) data << uint8(type); // team type (2=2v2,3=3v3,5=5v5), can be used for custom types... SendPacket(&data); } diff --git a/src/game/AuctionHouseBot/AuctionHouseBot.cpp b/src/game/AuctionHouseBot/AuctionHouseBot.cpp index c59c93d36..315d046db 100644 --- a/src/game/AuctionHouseBot/AuctionHouseBot.cpp +++ b/src/game/AuctionHouseBot/AuctionHouseBot.cpp @@ -128,7 +128,7 @@ class AHB_Seller_Config uint32 GetItemsQuantityPerClass(AuctionQuality quality, ItemClass itemclass) const { return m_ItemInfo[quality].ItemClassInfos[itemclass].Quantity; } void SetMissedItemsPerClass(AuctionQuality quality, ItemClass itemclass, uint32 found) { - if (m_ItemInfo[quality].ItemClassInfos[itemclass].AmountOfItems > found ) + if (m_ItemInfo[quality].ItemClassInfos[itemclass].AmountOfItems > found) m_ItemInfo[quality].ItemClassInfos[itemclass].MissItems=m_ItemInfo[quality].ItemClassInfos[itemclass].AmountOfItems - found; else m_ItemInfo[quality].ItemClassInfos[itemclass].MissItems = 0; @@ -191,7 +191,7 @@ class AuctionBotSeller : public AuctionBotAgent void addNewAuctions(AHB_Seller_Config& config); void SetItemsRatio(uint32 al, uint32 ho, uint32 ne); void SetItemsRatioForHouse(AuctionHouseType house, uint32 val); - void SetItemsAmount(uint32 (&vals) [MAX_AUCTION_QUALITY]); + void SetItemsAmount(uint32(&vals) [MAX_AUCTION_QUALITY]); void SetItemsAmountForQuality(AuctionQuality quality, uint32 val); void LoadConfig(); @@ -202,13 +202,13 @@ class AuctionBotSeller : public AuctionBotAgent void LoadSellerValues(AHB_Seller_Config& config); uint32 SetStat(AHB_Seller_Config& config); - bool getRandomArray( AHB_Seller_Config& config, RandomArray& ra, const std::vector >& addedItem ); - void SetPricesOfItem(ItemPrototype const *itemProto, AHB_Seller_Config& config, uint32& buyp, uint32& bidp, uint32 stackcnt, ItemQualities itemQuality); + bool getRandomArray(AHB_Seller_Config& config, RandomArray& ra, const std::vector >& addedItem); + void SetPricesOfItem(ItemPrototype const* itemProto, AHB_Seller_Config& config, uint32& buyp, uint32& bidp, uint32 stackcnt, ItemQualities itemQuality); void LoadItemsQuantity(AHB_Seller_Config& config); }; -INSTANTIATE_SINGLETON_1( AuctionHouseBot ); -INSTANTIATE_SINGLETON_1( AuctionBotConfig ); +INSTANTIATE_SINGLETON_1(AuctionHouseBot); +INSTANTIATE_SINGLETON_1(AuctionBotConfig); //== AuctionBotConfig functions ============================ @@ -238,7 +238,7 @@ bool AuctionBotConfig::Initialize() } if ((getConfig(CONFIG_UINT32_AHBOT_ALLIANCE_ITEM_AMOUNT_RATIO)==0) && (getConfig(CONFIG_UINT32_AHBOT_HORDE_ITEM_AMOUNT_RATIO)==0) && (getConfig(CONFIG_UINT32_AHBOT_NEUTRAL_ITEM_AMOUNT_RATIO)==0) && - !getConfig(CONFIG_BOOL_AHBOT_BUYER_ALLIANCE_ENABLED) && !getConfig(CONFIG_BOOL_AHBOT_BUYER_HORDE_ENABLED) && !getConfig(CONFIG_BOOL_AHBOT_BUYER_NEUTRAL_ENABLED)) + !getConfig(CONFIG_BOOL_AHBOT_BUYER_ALLIANCE_ENABLED) && !getConfig(CONFIG_BOOL_AHBOT_BUYER_HORDE_ENABLED) && !getConfig(CONFIG_BOOL_AHBOT_BUYER_NEUTRAL_ENABLED)) { sLog.outString("All feature of AuctionHouseBot are disabled! (If you want to use it please set config in 'ahbot.conf')"); return false; @@ -486,19 +486,19 @@ bool AuctionBotBuyer::Initialize() void AuctionBotBuyer::LoadBuyerValues(AHB_Buyer_Config& config) { uint32 FactionChance; - switch(config.GetHouseType()) + switch (config.GetHouseType()) { case AUCTION_HOUSE_ALLIANCE: - config.BuyerPriceRatio = sAuctionBotConfig.getConfig( CONFIG_UINT32_AHBOT_ALLIANCE_PRICE_RATIO )+50; - FactionChance = sAuctionBotConfig.getConfig( CONFIG_UINT32_AHBOT_BUYER_CHANCE_RATIO_ALLIANCE ); + config.BuyerPriceRatio = sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_ALLIANCE_PRICE_RATIO)+50; + FactionChance = sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_BUYER_CHANCE_RATIO_ALLIANCE); break; case AUCTION_HOUSE_HORDE: - config.BuyerPriceRatio = sAuctionBotConfig.getConfig( CONFIG_UINT32_AHBOT_HORDE_PRICE_RATIO )+50; - FactionChance = sAuctionBotConfig.getConfig( CONFIG_UINT32_AHBOT_BUYER_CHANCE_RATIO_HORDE ); + config.BuyerPriceRatio = sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_HORDE_PRICE_RATIO)+50; + FactionChance = sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_BUYER_CHANCE_RATIO_HORDE); break; default: - config.BuyerPriceRatio = sAuctionBotConfig.getConfig( CONFIG_UINT32_AHBOT_NEUTRAL_PRICE_RATIO )+50; - FactionChance = sAuctionBotConfig.getConfig( CONFIG_UINT32_AHBOT_BUYER_CHANCE_RATIO_NEUTRAL ); + config.BuyerPriceRatio = sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_NEUTRAL_PRICE_RATIO)+50; + FactionChance = sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_BUYER_CHANCE_RATIO_NEUTRAL); break; } config.FactionChance=5000*FactionChance; @@ -523,11 +523,11 @@ uint32 AuctionBotBuyer::GetBuyableEntry(AHB_Buyer_Config& config) AuctionHouseObject::AuctionEntryMapBounds bounds = sAuctionMgr.GetAuctionsMap(config.GetHouseType())->GetAuctionsBounds(); for (AuctionHouseObject::AuctionEntryMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr) { - AuctionEntry *Aentry = itr->second; - Item *item = sAuctionMgr.GetAItem(Aentry->itemGuidLow); + AuctionEntry* Aentry = itr->second; + Item* item = sAuctionMgr.GetAItem(Aentry->itemGuidLow); if (item) { - ItemPrototype const *prototype = item->GetProto(); + ItemPrototype const* prototype = item->GetProto(); if (prototype) { ++config.SameItemInfo[item->GetEntry()].ItemCount; // Structure constructor will make sure Element are correctly initialised if entry is created here. @@ -559,7 +559,7 @@ uint32 AuctionBotBuyer::GetBuyableEntry(AHB_Buyer_Config& config) { if (Aentry->bid!=0) { - if (Aentry->bidder) + if (Aentry->bidder) { config.CheckedEntry[Aentry->Id].LastExist=Now; config.CheckedEntry[Aentry->Id].AuctionId=Aentry->Id; @@ -586,7 +586,7 @@ void AuctionBotBuyer::PrepareListOfEntry(AHB_Buyer_Config& config) { time_t Now=time(NULL)-5; - for (CheckEntryMap::iterator itr=config.CheckedEntry.begin();itr != config.CheckedEntry.end();) + for (CheckEntryMap::iterator itr=config.CheckedEntry.begin(); itr != config.CheckedEntry.end();) { if (itr->second.LastExist < (Now-5)) config.CheckedEntry.erase(itr++); @@ -611,10 +611,10 @@ bool AuctionBotBuyer::IsBuyableEntry(uint32 buyoutPrice, double InGame_BuyPrice, if ((buyoutPrice > 0) && (MaxBuyablePrice > 0)) { - ratio = buyoutPrice / MaxBuyablePrice; - if (ratio < 10) - Chance=MaxChance - (ratio*(MaxChance/10)); - else Chance=1; + ratio = buyoutPrice / MaxBuyablePrice; + if (ratio < 10) + Chance=MaxChance - (ratio*(MaxChance/10)); + else Chance=1; } } } @@ -627,10 +627,10 @@ bool AuctionBotBuyer::IsBuyableEntry(uint32 buyoutPrice, double InGame_BuyPrice, if ((buyoutPrice > 0) && (MaxBuyablePrice > 0)) { - ratio = buyoutPrice / MaxBuyablePrice; - if (ratio < 10) - Chance=(MaxChance/5) - (ratio*(MaxChance/50)); - else Chance=1; + ratio = buyoutPrice / MaxBuyablePrice; + if (ratio < 10) + Chance=(MaxChance/5) - (ratio*(MaxChance/50)); + else Chance=1; } } } @@ -644,7 +644,7 @@ bool AuctionBotBuyer::IsBuyableEntry(uint32 buyoutPrice, double InGame_BuyPrice, if (ratio < 10) Chance=(MaxChance/5) - (ratio*(MaxChance/50)); else Chance=0; - } + } else Chance = 0; } uint32 RandNum = urand(1,ChanceRatio); @@ -699,7 +699,8 @@ bool AuctionBotBuyer::IsBidableEntry(uint32 bidPrice, double InGame_BuyPrice, do { DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_BUYER, "AHBot: WIN BID! Chance = %u, num = %u.",Chance, RandNum); return true; - } else + } + else { DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_BUYER, "AHBot: LOOSE BID! Chance = %u, num = %u.",Chance, RandNum); return false; @@ -714,7 +715,7 @@ void AuctionBotBuyer::PlaceBidToEntry(AuctionEntry* auction, uint32 bidPrice) void AuctionBotBuyer::BuyEntry(AuctionEntry* auction) { - DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_BUYER, "AHBot: Entry %u buyed at %.2fg", auction->Id, float(auction->buyout) / 10000.0f); + DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_BUYER, "AHBot: Entry %u buyed at %.2fg", auction->Id, float(auction->buyout) / 10000.0f); auction->UpdateBid(auction->buyout); } @@ -740,7 +741,7 @@ void AuctionBotBuyer::addNewAuctionBuyerBotBid(AHB_Buyer_Config& config) if (!auction || auction->moneyDeliveryTime) // is auction not active now { DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_BUYER, "AHBot: Entry %u on ah %u doesn't exists, perhaps bought already?", - itr->second.AuctionId, auction->GetHouseId()); + itr->second.AuctionId, auction->GetHouseId()); config.CheckedEntry.erase(itr++); continue; @@ -758,19 +759,19 @@ void AuctionBotBuyer::addNewAuctionBuyerBotBid(AHB_Buyer_Config& config) uint32 MaxChance=5000; - Item *item = sAuctionMgr.GetAItem(auction->itemGuidLow); + Item* item = sAuctionMgr.GetAItem(auction->itemGuidLow); if (!item) // auction item not accessible, possible auction in payment pending mode { config.CheckedEntry.erase(itr++); continue; } - ItemPrototype const *prototype = item->GetProto(); + ItemPrototype const* prototype = item->GetProto(); uint32 BasePrice = sAuctionBotConfig.getConfig(CONFIG_BOOL_AHBOT_BUYPRICE_BUYER) ? prototype->BuyPrice : prototype->SellPrice; BasePrice *= item->GetCount(); - double MaxBuyablePrice = ( BasePrice * config.BuyerPriceRatio )/100; + double MaxBuyablePrice = (BasePrice * config.BuyerPriceRatio)/100; BuyerItemInfoMap::iterator sameitem_itr = config.SameItemInfo.find(item->GetEntry()); uint32 buyoutPrice = auction->buyout/item->GetCount(); @@ -801,13 +802,13 @@ void AuctionBotBuyer::addNewAuctionBuyerBotBid(AHB_Buyer_Config& config) InGame_BidPrice=sameitem_itr->second.BidPrice/sameitem_itr->second.ItemCount; } - double MaxBidablePrice = MaxBuyablePrice - ( MaxBuyablePrice / 30); // Max Bidable price defined to 70% of max buyable price + double MaxBidablePrice = MaxBuyablePrice - (MaxBuyablePrice / 30); // Max Bidable price defined to 70% of max buyable price DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_BUYER, "AHBot: Auction added with data:"); DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_BUYER, "AHBot: MaxPrice of Entry %u is %.1fg.", itr->second.AuctionId, MaxBuyablePrice / 10000); DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_BUYER, "AHBot: GamePrice buy=%.1fg, bid=%.1fg.",InGame_BuyPrice/10000, InGame_BidPrice / 10000); DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_BUYER, "AHBot: Minimal price see in AH Buy=%ug, Bid=%ug.", - sameitem_itr->second.MinBuyPrice / 10000,sameitem_itr->second.MinBidPrice / 10000); + sameitem_itr->second.MinBuyPrice / 10000,sameitem_itr->second.MinBidPrice / 10000); DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_BUYER, "AHBot: Actual Entry price, Buy=%ug, Bid=%ug.", buyoutPrice / 10000, bidPrice/ 10000); if (!auction->owner) // Original auction owner @@ -819,7 +820,7 @@ void AuctionBotBuyer::addNewAuctionBuyerBotBid(AHB_Buyer_Config& config) if (IsBuyableEntry(buyoutPrice, InGame_BuyPrice, MaxBuyablePrice, sameitem_itr->second.MinBuyPrice, MaxChance, config.FactionChance)) { if (IsBidableEntry(bidPriceByItem, InGame_BuyPrice, MaxBidablePrice, sameitem_itr->second.MinBidPrice, MaxChance/2, config.FactionChance)) - if (urand(0,5)==0) PlaceBidToEntry(auction, bidPrice); else BuyEntry(auction); + if (urand(0,5)==0) PlaceBidToEntry(auction, bidPrice); else BuyEntry(auction); else BuyEntry(auction); } @@ -903,7 +904,8 @@ bool AuctionBotSeller::Initialize() Field* fields = result->Fetch(); npcItems.push_back(fields[0].GetUInt32()); - } while (result->NextRow()); + } + while (result->NextRow()); delete result; } else @@ -916,16 +918,16 @@ bool AuctionBotSeller::Initialize() sLog.outString("Loading loot items for filter.."); if (QueryResult* result = WorldDatabase.PQuery( - "SELECT item FROM creature_loot_template UNION " - "SELECT item FROM disenchant_loot_template UNION " - "SELECT item FROM fishing_loot_template UNION " - "SELECT item FROM gameobject_loot_template UNION " - "SELECT item FROM item_loot_template UNION " - "SELECT item FROM milling_loot_template UNION " - "SELECT item FROM pickpocketing_loot_template UNION " - "SELECT item FROM prospecting_loot_template UNION " - "SELECT item FROM skinning_loot_template UNION " - "SELECT item FROM spell_loot_template")) + "SELECT item FROM creature_loot_template UNION " + "SELECT item FROM disenchant_loot_template UNION " + "SELECT item FROM fishing_loot_template UNION " + "SELECT item FROM gameobject_loot_template UNION " + "SELECT item FROM item_loot_template UNION " + "SELECT item FROM milling_loot_template UNION " + "SELECT item FROM pickpocketing_loot_template UNION " + "SELECT item FROM prospecting_loot_template UNION " + "SELECT item FROM skinning_loot_template UNION " + "SELECT item FROM spell_loot_template")) { BarGoLink bar(result->GetRowCount()); do @@ -938,7 +940,8 @@ bool AuctionBotSeller::Initialize() continue; lootItems.push_back(fields[0].GetUInt32()); - } while (result->NextRow()); + } + while (result->NextRow()); delete result; } else @@ -1018,7 +1021,7 @@ bool AuctionBotSeller::Initialize() // no price filter if (sAuctionBotConfig.getConfig(CONFIG_BOOL_AHBOT_BUYPRICE_SELLER)) { - if(prototype->BuyPrice == 0) + if (prototype->BuyPrice == 0) continue; } else @@ -1088,7 +1091,7 @@ bool AuctionBotSeller::Initialize() continue; if (uint32 value = sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_ITEM_MIN_SKILL_RANK)) if (prototype->RequiredSkillRank < value) - continue; + continue; if (uint32 value = sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_ITEM_MAX_SKILL_RANK)) if (prototype->RequiredSkillRank > value) continue; @@ -1199,10 +1202,10 @@ bool AuctionBotSeller::Initialize() sLog.outString("Items loaded \tGrey\tWhite\tGreen\tBlue\tPurple\tOrange\tYellow"); for (uint32 i = 0; i < MAX_ITEM_CLASS; ++i) sLog.outString("%-18s\t" SIZEFMTD "\t" SIZEFMTD "\t" SIZEFMTD "\t" SIZEFMTD "\t" SIZEFMTD "\t" SIZEFMTD "\t" SIZEFMTD, - sAuctionBotConfig.GetItemClassName(ItemClass(i)), - m_ItemPool[0][i].size(), m_ItemPool[1][i].size(), m_ItemPool[2][i].size(), - m_ItemPool[3][i].size(), m_ItemPool[4][i].size(), m_ItemPool[5][i].size(), - m_ItemPool[6][i].size()); + sAuctionBotConfig.GetItemClassName(ItemClass(i)), + m_ItemPool[0][i].size(), m_ItemPool[1][i].size(), m_ItemPool[2][i].size(), + m_ItemPool[3][i].size(), m_ItemPool[4][i].size(), m_ItemPool[5][i].size(), + m_ItemPool[6][i].size()); sLog.outString(); sLog.outString("AHBot seller configuration data loaded and initilized"); @@ -1350,11 +1353,11 @@ void AuctionBotSeller::LoadItemsQuantity(AHB_Seller_Config& config) for (uint32 j = 0; j < MAX_AUCTION_QUALITY; ++j) { uint32 indice = config.GetItemsAmountPerQuality(AuctionQuality(j)) / - (sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_CLASS_CONSUMABLE_AMOUNT) + sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_CLASS_CONTAINER_AMOUNT) + sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_CLASS_WEAPON_AMOUNT) + - sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_CLASS_GEM_AMOUNT) + sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_CLASS_ARMOR_AMOUNT) + sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_CLASS_REAGENT_AMOUNT) + - sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_CLASS_PROJECTILE_AMOUNT) + sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_CLASS_TRADEGOOD_AMOUNT) + sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_CLASS_GENERIC_AMOUNT) + - sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_CLASS_RECIPE_AMOUNT) + sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_CLASS_QUIVER_AMOUNT) + sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_CLASS_QUEST_AMOUNT) + - sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_CLASS_KEY_AMOUNT) + sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_CLASS_MISC_AMOUNT) + sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_CLASS_GLYPH_AMOUNT)); + (sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_CLASS_CONSUMABLE_AMOUNT) + sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_CLASS_CONTAINER_AMOUNT) + sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_CLASS_WEAPON_AMOUNT) + + sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_CLASS_GEM_AMOUNT) + sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_CLASS_ARMOR_AMOUNT) + sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_CLASS_REAGENT_AMOUNT) + + sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_CLASS_PROJECTILE_AMOUNT) + sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_CLASS_TRADEGOOD_AMOUNT) + sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_CLASS_GENERIC_AMOUNT) + + sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_CLASS_RECIPE_AMOUNT) + sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_CLASS_QUIVER_AMOUNT) + sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_CLASS_QUEST_AMOUNT) + + sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_CLASS_KEY_AMOUNT) + sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_CLASS_MISC_AMOUNT) + sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_CLASS_GLYPH_AMOUNT)); for (uint32 i = 0; i < MAX_ITEM_CLASS; ++i) config.SetItemsAmountPerClass(AuctionQuality(j), ItemClass(i), indice); } @@ -1364,7 +1367,7 @@ void AuctionBotSeller::LoadSellerValues(AHB_Seller_Config& config) { LoadItemsQuantity(config); uint32 PriceRatio; - switch(config.GetHouseType()) + switch (config.GetHouseType()) { case AUCTION_HOUSE_ALLIANCE: PriceRatio = sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_ALLIANCE_PRICE_RATIO); @@ -1411,11 +1414,11 @@ uint32 AuctionBotSeller::SetStat(AHB_Seller_Config& config) AuctionHouseObject::AuctionEntryMapBounds bounds = sAuctionMgr.GetAuctionsMap(config.GetHouseType())->GetAuctionsBounds(); for (AuctionHouseObject::AuctionEntryMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr) { - AuctionEntry *Aentry = itr->second; - Item *item = sAuctionMgr.GetAItem(Aentry->itemGuidLow); + AuctionEntry* Aentry = itr->second; + Item* item = sAuctionMgr.GetAItem(Aentry->itemGuidLow); if (item) { - ItemPrototype const *prototype = item->GetProto(); + ItemPrototype const* prototype = item->GetProto(); if (prototype) { if (!Aentry->owner) // Add only ahbot items @@ -1428,7 +1431,7 @@ uint32 AuctionBotSeller::SetStat(AHB_Seller_Config& config) uint32 count=0; for (uint32 j=0; j >& addedItem ) +bool AuctionBotSeller::getRandomArray(AHB_Seller_Config& config, RandomArray& ra, const std::vector >& addedItem) { ra.clear(); bool Ok=false; @@ -1476,10 +1479,10 @@ bool AuctionBotSeller::getRandomArray( AHB_Seller_Config& config, RandomArray& r } // Set items price. All important value are passed by address. -void AuctionBotSeller::SetPricesOfItem(ItemPrototype const *itemProto, AHB_Seller_Config& config, uint32& buyp, uint32& bidp, uint32 stackcnt, ItemQualities itemQuality) +void AuctionBotSeller::SetPricesOfItem(ItemPrototype const* itemProto, AHB_Seller_Config& config, uint32& buyp, uint32& bidp, uint32 stackcnt, ItemQualities itemQuality) { double temp_buyp = buyp * stackcnt * - (itemQuality < MAX_AUCTION_QUALITY ? config.GetPriceRatioPerQuality(AuctionQuality(itemQuality)) : 1) ; + (itemQuality < MAX_AUCTION_QUALITY ? config.GetPriceRatioPerQuality(AuctionQuality(itemQuality)) : 1) ; double randrange = temp_buyp * 0.4; buyp = (urand(temp_buyp-randrange, temp_buyp+randrange)/100)+1; @@ -1513,7 +1516,7 @@ void AuctionBotSeller::SetItemsRatioForHouse(AuctionHouseType house, uint32 val) LoadItemsQuantity(m_HouseConfig[house]); } -void AuctionBotSeller::SetItemsAmount(uint32 (&vals) [MAX_AUCTION_QUALITY]) +void AuctionBotSeller::SetItemsAmount(uint32(&vals) [MAX_AUCTION_QUALITY]) { sAuctionBotConfig.setConfig(CONFIG_UINT32_AHBOT_ITEM_GREY_AMOUNT, vals[AUCTION_QUALITY_GREY]); sAuctionBotConfig.setConfig(CONFIG_UINT32_AHBOT_ITEM_WHITE_AMOUNT, vals[AUCTION_QUALITY_WHITE]); @@ -1579,7 +1582,7 @@ void AuctionBotSeller::addNewAuctions(AHB_Seller_Config& config) --items; // Select random position from missed items table - uint32 pos = (urand(0,randArray.size()-1)); + uint32 pos = (urand(0,randArray.size()-1)); // Set itemID with random item ID for selected categories and color, from m_ItemPool table uint32 itemID = m_ItemPool[randArray[pos].color][randArray[pos].itemclass][urand(0,m_ItemPool[randArray[pos].color][randArray[pos].itemclass].size()-1)]; @@ -1689,7 +1692,7 @@ void AuctionHouseBot::SetItemsRatioForHouse(AuctionHouseType house, uint32 val) seller->SetItemsRatioForHouse(house, val); } -void AuctionHouseBot::SetItemsAmount(uint32 (&vals) [MAX_AUCTION_QUALITY]) +void AuctionHouseBot::SetItemsAmount(uint32(&vals) [MAX_AUCTION_QUALITY]) { if (AuctionBotSeller* seller = dynamic_cast(m_Seller)) seller->SetItemsAmount(vals); @@ -1725,10 +1728,10 @@ void AuctionHouseBot::PrepareStatusInfos(AuctionHouseBotStatusInfo& statusInfo) AuctionHouseObject::AuctionEntryMapBounds bounds = sAuctionMgr.GetAuctionsMap(AuctionHouseType(i))->GetAuctionsBounds(); for (AuctionHouseObject::AuctionEntryMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr) { - AuctionEntry *Aentry = itr->second; - if (Item *item = sAuctionMgr.GetAItem(Aentry->itemGuidLow)) + AuctionEntry* Aentry = itr->second; + if (Item* item = sAuctionMgr.GetAItem(Aentry->itemGuidLow)) { - ItemPrototype const *prototype = item->GetProto(); + ItemPrototype const* prototype = item->GetProto(); if (!Aentry->owner) // Add only ahbot items { if (prototype->Quality < MAX_AUCTION_QUALITY) @@ -1757,7 +1760,7 @@ void AuctionHouseBot::Update() { // nothing do... if (!m_Buyer && !m_Seller) - return; + return; // scan all possible update cases until first success for (uint32 count = 0; count < 2*MAX_AUCTION_HOUSE_TYPE; ++count) diff --git a/src/game/AuctionHouseBot/AuctionHouseBot.h b/src/game/AuctionHouseBot/AuctionHouseBot.h index 61a8316ab..767288617 100644 --- a/src/game/AuctionHouseBot/AuctionHouseBot.h +++ b/src/game/AuctionHouseBot/AuctionHouseBot.h @@ -186,7 +186,7 @@ class AuctionHouseBot // Followed method is mainly used by level3.cpp for ingame/console command void SetItemsRatio(uint32 al, uint32 ho, uint32 ne); void SetItemsRatioForHouse(AuctionHouseType house, uint32 val); - void SetItemsAmount(uint32 (&vals) [MAX_AUCTION_QUALITY]); + void SetItemsAmount(uint32(&vals) [MAX_AUCTION_QUALITY]); void SetItemsAmountForQuality(AuctionQuality quality, uint32 val); bool ReloadAllConfig(); void Rebuild(bool all); diff --git a/src/game/AuctionHouseHandler.cpp b/src/game/AuctionHouseHandler.cpp index 252ce3455..9844b6d5b 100644 --- a/src/game/AuctionHouseHandler.cpp +++ b/src/game/AuctionHouseHandler.cpp @@ -34,12 +34,12 @@ // post-incrementation is always slower than pre-incrementation ! // void called when player click on auctioneer npc -void WorldSession::HandleAuctionHelloOpcode(WorldPacket & recv_data) +void WorldSession::HandleAuctionHelloOpcode(WorldPacket& recv_data) { ObjectGuid auctioneerGuid; // NPC guid recv_data >> auctioneerGuid; - Creature *unit = GetPlayer()->GetNPCIfCanInteractWith(auctioneerGuid, UNIT_NPC_FLAG_AUCTIONEER); + Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(auctioneerGuid, UNIT_NPC_FLAG_AUCTIONEER); if (!unit) { DEBUG_LOG("WORLD: HandleAuctionHelloOpcode - %s not found or you can't interact with him.", auctioneerGuid.GetString().c_str()); @@ -67,7 +67,7 @@ void WorldSession::SendAuctionHello(Unit* unit) } // call this method when player bids, creates, or deletes auction -void WorldSession::SendAuctionCommandResult(AuctionEntry *auc, AuctionAction Action, AuctionError ErrorCode, InventoryResult invError) +void WorldSession::SendAuctionCommandResult(AuctionEntry* auc, AuctionAction Action, AuctionError ErrorCode, InventoryResult invError) { WorldPacket data(SMSG_AUCTION_COMMAND_RESULT, 16); data << uint32(auc ? auc->Id : 0); @@ -149,13 +149,13 @@ void WorldSession::SendAuctionRemovedNotification(AuctionEntry* auction) } // this function sends mail to old bidder -void WorldSession::SendAuctionOutbiddedMail(AuctionEntry *auction) +void WorldSession::SendAuctionOutbiddedMail(AuctionEntry* auction) { ObjectGuid oldBidder_guid = ObjectGuid(HIGHGUID_PLAYER, auction->bidder); - Player *oldBidder = sObjectMgr.GetPlayer(oldBidder_guid); + Player* oldBidder = sObjectMgr.GetPlayer(oldBidder_guid); uint32 oldBidder_accId = 0; - if(!oldBidder) + if (!oldBidder) oldBidder_accId = sObjectMgr.GetPlayerAccountIdByGUID(oldBidder_guid); // old bidder exist @@ -168,8 +168,8 @@ void WorldSession::SendAuctionOutbiddedMail(AuctionEntry *auction) oldBidder->GetSession()->SendAuctionBidderNotification(auction); MailDraft(msgAuctionOutbiddedSubject.str(), "") // TODO: fix body - .SetMoney(auction->bid) - .SendMailTo(MailReceiver(oldBidder, oldBidder_guid), auction, MAIL_CHECK_MASK_COPIED); + .SetMoney(auction->bid) + .SendMailTo(MailReceiver(oldBidder, oldBidder_guid), auction, MAIL_CHECK_MASK_COPIED); } } @@ -177,7 +177,7 @@ void WorldSession::SendAuctionOutbiddedMail(AuctionEntry *auction) void WorldSession::SendAuctionCancelledToBidderMail(AuctionEntry* auction) { ObjectGuid bidder_guid = ObjectGuid(HIGHGUID_PLAYER, auction->bidder); - Player *bidder = sObjectMgr.GetPlayer(bidder_guid); + Player* bidder = sObjectMgr.GetPlayer(bidder_guid); uint32 bidder_accId = 0; if (!bidder) @@ -193,8 +193,8 @@ void WorldSession::SendAuctionCancelledToBidderMail(AuctionEntry* auction) bidder->GetSession()->SendAuctionRemovedNotification(auction); MailDraft(msgAuctionCancelledSubject.str(), "") // TODO: fix body - .SetMoney(auction->bid) - .SendMailTo(MailReceiver(bidder, bidder_guid), auction, MAIL_CHECK_MASK_COPIED); + .SetMoney(auction->bid) + .SendMailTo(MailReceiver(bidder, bidder_guid), auction, MAIL_CHECK_MASK_COPIED); } } @@ -231,7 +231,7 @@ AuctionHouseEntry const* WorldSession::GetCheckedAuctionHouseForAuctioneer(Objec } // this void creates new auction and adds auction to some auctionhouse -void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data) +void WorldSession::HandleAuctionSellItem(WorldPacket& recv_data) { DEBUG_LOG("WORLD: HandleAuctionSellItem"); @@ -265,7 +265,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data) if (!bid || !etime) return; // check for cheaters - Player *pl = GetPlayer(); + Player* pl = GetPlayer(); AuctionHouseEntry const* auctionHouseEntry = GetCheckedAuctionHouseForAuctioneer(auctioneerGuid); if (!auctionHouseEntry) @@ -301,7 +301,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data) uint32 stackSize = stackSizes[i]; - Item *it = pl->GetItemByGuid(itemGuid); + Item* it = pl->GetItemByGuid(itemGuid); // do not allow to sell already auctioned items if (sAuctionMgr.GetAItem(itemGuid.GetCounter())) @@ -341,7 +341,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data) if (GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_BOOL_GM_LOG_TRADE)) { sLog.outCommand(GetAccountId(),"GM %s (Account: %u) create auction: %s (Entry: %u Count: %u)", - GetPlayerName(), GetAccountId(), it->GetProto()->Name1, it->GetEntry(), it->GetCount()); + GetPlayerName(), GetAccountId(), it->GetProto()->Name1, it->GetEntry(), it->GetCount()); } if (stackSize == 0) @@ -353,7 +353,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data) if (!pl->HasItemCount(it->GetEntry(), stackSize)) // not enough items continue; - Item *newItem = it->CloneItem(stackSize); + Item* newItem = it->CloneItem(stackSize); pl->DestroyItemCount(it, stackSize, true); @@ -362,7 +362,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data) AuctionEntry* AH = auctionHouse->AddAuction(auctionHouseEntry, newItem, etime, bid, buyout, deposit, pl); DETAIL_LOG("selling %s to auctioneer %s with initial bid %u with buyout %u and with time %u (in sec) in auctionhouse %u", - itemGuid.GetString().c_str(), auctioneerGuid.GetString().c_str(), bid, buyout, etime, auctionHouseEntry->houseId); + itemGuid.GetString().c_str(), auctioneerGuid.GetString().c_str(), bid, buyout, etime, auctionHouseEntry->houseId); SendAuctionCommandResult(AH, AUCTION_STARTED, AUCTION_OK); @@ -371,7 +371,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data) } // this function is called when client bids or buys out auction -void WorldSession::HandleAuctionPlaceBid(WorldPacket & recv_data) +void WorldSession::HandleAuctionPlaceBid(WorldPacket& recv_data) { DEBUG_LOG("WORLD: HandleAuctionPlaceBid"); @@ -395,8 +395,8 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket & recv_data) if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); - AuctionEntry *auction = auctionHouse->GetAuction(auctionId); - Player *pl = GetPlayer(); + AuctionEntry* auction = auctionHouse->GetAuction(auctionId); + Player* pl = GetPlayer(); if (!auction || auction->owner == pl->GetGUIDLow()) { @@ -426,7 +426,7 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket & recv_data) // price too low for next bid if not buyout if ((price < auction->buyout || auction->buyout == 0) && - price < auction->bid + auction->GetAuctionOutBid()) + price < auction->bid + auction->GetAuctionOutBid()) { // client test but possible in result lags SendAuctionCommandResult(auction, AUCTION_BID_PLACED, AUCTION_ERR_BID_INCREMENT); @@ -453,7 +453,7 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket & recv_data) } // this void is called when auction_owner cancels his auction -void WorldSession::HandleAuctionRemoveItem(WorldPacket & recv_data) +void WorldSession::HandleAuctionRemoveItem(WorldPacket& recv_data) { DEBUG_LOG("WORLD: HandleAuctionRemoveItem"); @@ -474,8 +474,8 @@ void WorldSession::HandleAuctionRemoveItem(WorldPacket & recv_data) if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); - AuctionEntry *auction = auctionHouse->GetAuction(auctionId); - Player *pl = GetPlayer(); + AuctionEntry* auction = auctionHouse->GetAuction(auctionId); + Player* pl = GetPlayer(); if (!auction || auction->owner != pl->GetGUIDLow()) { @@ -484,7 +484,7 @@ void WorldSession::HandleAuctionRemoveItem(WorldPacket & recv_data) return; } - Item *pItem = sAuctionMgr.GetAItem(auction->itemGuidLow); + Item* pItem = sAuctionMgr.GetAItem(auction->itemGuidLow); if (!pItem) { sLog.outError("Auction id: %u has nonexistent item (item guid : %u)!!!", auction->Id, auction->itemGuidLow); @@ -509,8 +509,8 @@ void WorldSession::HandleAuctionRemoveItem(WorldPacket & recv_data) // item will deleted or added to received mail list MailDraft(msgAuctionCanceledOwner.str(), "") // TODO: fix body - .AddItem(pItem) - .SendMailTo(pl, auction, MAIL_CHECK_MASK_COPIED); + .AddItem(pItem) + .SendMailTo(pl, auction, MAIL_CHECK_MASK_COPIED); // inform player, that auction is removed SendAuctionCommandResult(auction, AUCTION_REMOVED, AUCTION_OK); @@ -525,7 +525,7 @@ void WorldSession::HandleAuctionRemoveItem(WorldPacket & recv_data) } // called when player lists his bids -void WorldSession::HandleAuctionListBidderItems(WorldPacket & recv_data) +void WorldSession::HandleAuctionListBidderItems(WorldPacket& recv_data) { DEBUG_LOG("WORLD: HandleAuctionListBidderItems"); @@ -554,7 +554,7 @@ void WorldSession::HandleAuctionListBidderItems(WorldPacket & recv_data) GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); WorldPacket data(SMSG_AUCTION_BIDDER_LIST_RESULT, (4+4+4)); - Player *pl = GetPlayer(); + Player* pl = GetPlayer(); data << uint32(0); // add 0 as count uint32 count = 0; uint32 totalcount = 0; @@ -563,7 +563,7 @@ void WorldSession::HandleAuctionListBidderItems(WorldPacket & recv_data) --outbiddedCount; uint32 outbiddedAuctionId; recv_data >> outbiddedAuctionId; - AuctionEntry *auction = auctionHouse->GetAuction(outbiddedAuctionId); + AuctionEntry* auction = auctionHouse->GetAuction(outbiddedAuctionId); if (auction && auction->BuildAuctionInfo(data)) { ++totalcount; @@ -579,7 +579,7 @@ void WorldSession::HandleAuctionListBidderItems(WorldPacket & recv_data) } // this void sends player info about his auctions -void WorldSession::HandleAuctionListOwnerItems(WorldPacket & recv_data) +void WorldSession::HandleAuctionListOwnerItems(WorldPacket& recv_data) { DEBUG_LOG("WORLD: HandleAuctionListOwnerItems"); @@ -614,7 +614,7 @@ void WorldSession::HandleAuctionListOwnerItems(WorldPacket & recv_data) } // this void is called when player clicks on search button -void WorldSession::HandleAuctionListItems(WorldPacket & recv_data) +void WorldSession::HandleAuctionListItems(WorldPacket& recv_data) { DEBUG_LOG("WORLD: HandleAuctionListItems"); @@ -688,7 +688,7 @@ void WorldSession::HandleAuctionListItems(WorldPacket & recv_data) wstrToLower(wsearchedname); BuildListAuctionItems(auctions, data, wsearchedname, listfrom, levelmin, levelmax, usable, - auctionSlotID, auctionMainCategory, auctionSubCategory, quality, count, totalcount, isFull); + auctionSlotID, auctionMainCategory, auctionSubCategory, quality, count, totalcount, isFull); data.put(0, count); data << uint32(totalcount); @@ -696,7 +696,7 @@ void WorldSession::HandleAuctionListItems(WorldPacket & recv_data) SendPacket(&data); } -void WorldSession::HandleAuctionListPendingSales(WorldPacket & recv_data) +void WorldSession::HandleAuctionListPendingSales(WorldPacket& recv_data) { DEBUG_LOG("CMSG_AUCTION_LIST_PENDING_SALES"); diff --git a/src/game/AuctionHouseMgr.cpp b/src/game/AuctionHouseMgr.cpp index f395e0e04..3184a0b85 100644 --- a/src/game/AuctionHouseMgr.cpp +++ b/src/game/AuctionHouseMgr.cpp @@ -44,17 +44,17 @@ AuctionHouseMgr::AuctionHouseMgr() AuctionHouseMgr::~AuctionHouseMgr() { - for(ItemMap::const_iterator itr = mAitems.begin(); itr != mAitems.end(); ++itr) + for (ItemMap::const_iterator itr = mAitems.begin(); itr != mAitems.end(); ++itr) delete itr->second; } -AuctionHouseObject * AuctionHouseMgr::GetAuctionsMap(AuctionHouseEntry const* house) +AuctionHouseObject* AuctionHouseMgr::GetAuctionsMap(AuctionHouseEntry const* house) { - if(sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_AUCTION)) + if (sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_AUCTION)) return &mAuctions[AUCTION_HOUSE_NEUTRAL]; // team have linked auction houses - switch(GetAuctionHouseTeam(house)) + switch (GetAuctionHouseTeam(house)) { case ALLIANCE: return &mAuctions[AUCTION_HOUSE_ALLIANCE]; case HORDE: return &mAuctions[AUCTION_HOUSE_HORDE]; @@ -62,7 +62,7 @@ AuctionHouseObject * AuctionHouseMgr::GetAuctionsMap(AuctionHouseEntry const* ho } } -uint32 AuctionHouseMgr::GetAuctionDeposit(AuctionHouseEntry const* entry, uint32 time, Item *pItem) +uint32 AuctionHouseMgr::GetAuctionDeposit(AuctionHouseEntry const* entry, uint32 time, Item* pItem) { float deposit = float(pItem->GetProto()->SellPrice * pItem->GetCount() * (time / MIN_AUCTION_TIME)); @@ -77,14 +77,14 @@ uint32 AuctionHouseMgr::GetAuctionDeposit(AuctionHouseEntry const* entry, uint32 } // does not clear ram -void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry *auction) +void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry* auction) { - Item *pItem = GetAItem(auction->itemGuidLow); + Item* pItem = GetAItem(auction->itemGuidLow); if (!pItem) return; ObjectGuid bidder_guid = ObjectGuid(HIGHGUID_PLAYER, auction->bidder); - Player *bidder = sObjectMgr.GetPlayer(bidder_guid); + Player* bidder = sObjectMgr.GetPlayer(bidder_guid); uint32 bidder_accId = 0; @@ -125,7 +125,7 @@ void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry *auction) uint32 owner_accid = sObjectMgr.GetPlayerAccountIdByGUID(ownerGuid); sLog.outCommand(bidder_accId,"GM %s (Account: %u) won item in auction (Entry: %u Count: %u) and pay money: %u. Original owner %s (Account: %u)", - bidder_name.c_str(), bidder_accId, auction->itemTemplate, auction->itemCount, auction->bid, owner_name.c_str(), owner_accid); + bidder_name.c_str(), bidder_accId, auction->itemTemplate, auction->itemCount, auction->bid, owner_name.c_str(), owner_accid); } } else if (!bidder) @@ -162,8 +162,8 @@ void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry *auction) // will delete item or place to receiver mail list MailDraft(msgAuctionWonSubject.str(), msgAuctionWonBody.str()) - .AddItem(pItem) - .SendMailTo(MailReceiver(bidder, bidder_guid), auction, MAIL_CHECK_MASK_COPIED); + .AddItem(pItem) + .SendMailTo(MailReceiver(bidder, bidder_guid), auction, MAIL_CHECK_MASK_COPIED); } // receiver not exist else @@ -176,10 +176,10 @@ void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry *auction) } // call this method to send mail to auction owner, when auction is successful, it does not clear ram -void AuctionHouseMgr::SendAuctionSuccessfulMail(AuctionEntry * auction) +void AuctionHouseMgr::SendAuctionSuccessfulMail(AuctionEntry* auction) { ObjectGuid owner_guid = ObjectGuid(HIGHGUID_PLAYER, auction->owner); - Player *owner = sObjectMgr.GetPlayer(owner_guid); + Player* owner = sObjectMgr.GetPlayer(owner_guid); uint32 owner_accId = 0; if (!owner) @@ -211,15 +211,16 @@ void AuctionHouseMgr::SendAuctionSuccessfulMail(AuctionEntry * auction) } MailDraft(msgAuctionSuccessfulSubject.str(), auctionSuccessfulBody.str()) - .SetMoney(profit) - .SendMailTo(MailReceiver(owner, owner_guid), auction, MAIL_CHECK_MASK_COPIED); + .SetMoney(profit) + .SendMailTo(MailReceiver(owner, owner_guid), auction, MAIL_CHECK_MASK_COPIED); } } // does not clear ram -void AuctionHouseMgr::SendAuctionExpiredMail(AuctionEntry * auction) -{ // return an item in auction to its owner by mail - Item *pItem = GetAItem(auction->itemGuidLow); +void AuctionHouseMgr::SendAuctionExpiredMail(AuctionEntry* auction) +{ + // return an item in auction to its owner by mail + Item* pItem = GetAItem(auction->itemGuidLow); if (!pItem) { sLog.outError("Auction item (GUID: %u) not found, and lost.", auction->itemGuidLow); @@ -227,7 +228,7 @@ void AuctionHouseMgr::SendAuctionExpiredMail(AuctionEntry * auction) } ObjectGuid owner_guid = ObjectGuid(HIGHGUID_PLAYER, auction->owner); - Player *owner = sObjectMgr.GetPlayer(owner_guid); + Player* owner = sObjectMgr.GetPlayer(owner_guid); uint32 owner_accId = 0; if (!owner) @@ -247,8 +248,8 @@ void AuctionHouseMgr::SendAuctionExpiredMail(AuctionEntry * auction) // will delete item or place to receiver mail list MailDraft(subject.str(), "") // TODO: fix body - .AddItem(pItem) - .SendMailTo(MailReceiver(owner, owner_guid), auction, MAIL_CHECK_MASK_COPIED); + .AddItem(pItem) + .SendMailTo(MailReceiver(owner, owner_guid), auction, MAIL_CHECK_MASK_COPIED); } // owner not found else @@ -263,7 +264,7 @@ void AuctionHouseMgr::SendAuctionExpiredMail(AuctionEntry * auction) void AuctionHouseMgr::LoadAuctionItems() { // data needs to be at first place for Item::LoadFromDB 0 1 2 3 - QueryResult *result = CharacterDatabase.Query("SELECT data,text,itemguid,item_template FROM auction JOIN item_instance ON itemguid = guid"); + QueryResult* result = CharacterDatabase.Query("SELECT data,text,itemguid,item_template FROM auction JOIN item_instance ON itemguid = guid"); if (!result) { @@ -278,7 +279,7 @@ void AuctionHouseMgr::LoadAuctionItems() uint32 count = 0; - Field *fields; + Field* fields; do { bar.step(); @@ -287,7 +288,7 @@ void AuctionHouseMgr::LoadAuctionItems() uint32 item_guid = fields[2].GetUInt32(); uint32 item_template = fields[3].GetUInt32(); - ItemPrototype const *proto = ObjectMgr::GetItemPrototype(item_template); + ItemPrototype const* proto = ObjectMgr::GetItemPrototype(item_template); if (!proto) { @@ -295,7 +296,7 @@ void AuctionHouseMgr::LoadAuctionItems() continue; } - Item *item = NewItemOrBag(proto); + Item* item = NewItemOrBag(proto); if (!item->LoadFromDB(item_guid, fields)) { @@ -315,7 +316,7 @@ void AuctionHouseMgr::LoadAuctionItems() void AuctionHouseMgr::LoadAuctions() { - QueryResult *result = CharacterDatabase.Query("SELECT COUNT(*) FROM auction"); + QueryResult* result = CharacterDatabase.Query("SELECT COUNT(*) FROM auction"); if (!result) { BarGoLink bar(1); @@ -325,7 +326,7 @@ void AuctionHouseMgr::LoadAuctions() return; } - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 AuctionCount=fields[0].GetUInt32(); delete result; @@ -359,7 +360,7 @@ void AuctionHouseMgr::LoadAuctions() bar.step(); - AuctionEntry *auction = new AuctionEntry; + AuctionEntry* auction = new AuctionEntry; auction->Id = fields[0].GetUInt32(); uint32 houseid = fields[1].GetUInt32(); auction->itemGuidLow = fields[2].GetUInt32(); @@ -410,8 +411,8 @@ void AuctionHouseMgr::LoadAuctions() // overwrite by real item data if ((auction->itemTemplate != pItem->GetEntry()) || - (auction->itemCount != pItem->GetCount()) || - (auction->itemRandomPropertyId != pItem->GetItemRandomPropertyId())) + (auction->itemCount != pItem->GetCount()) || + (auction->itemRandomPropertyId != pItem->GetItemRandomPropertyId())) { auction->itemTemplate = pItem->GetEntry(); auction->itemCount = pItem->GetCount(); @@ -419,7 +420,7 @@ void AuctionHouseMgr::LoadAuctions() //No SQL injection (no strings) CharacterDatabase.PExecute("UPDATE auction SET item_template = %u, item_count = %u, item_randompropertyid = %i WHERE itemguid = %u", - auction->itemTemplate, auction->itemCount, auction->itemRandomPropertyId, auction->itemGuidLow); + auction->itemTemplate, auction->itemCount, auction->itemRandomPropertyId, auction->itemGuidLow); } } @@ -443,8 +444,8 @@ void AuctionHouseMgr::LoadAuctions() // item will deleted or added to received mail list MailDraft(msgAuctionCanceledOwner.str(), "") // TODO: fix body - .AddItem(pItem) - .SendMailTo(MailReceiver(ObjectGuid(HIGHGUID_PLAYER, auction->owner)), auction, MAIL_CHECK_MASK_COPIED); + .AddItem(pItem) + .SendMailTo(MailReceiver(ObjectGuid(HIGHGUID_PLAYER, auction->owner)), auction, MAIL_CHECK_MASK_COPIED); } auction->DeleteFromDB(); @@ -455,7 +456,8 @@ void AuctionHouseMgr::LoadAuctions() GetAuctionsMap(auction->auctionHouseEntry)->AddAuction(auction); - } while (result->NextRow()); + } + while (result->NextRow()); delete result; sLog.outString(); @@ -567,7 +569,7 @@ void AuctionHouseObject::Update() { time_t curTime = sWorld.GetGameTime(); ///- Handle expired auctions - for (AuctionEntryMap::iterator itr = AuctionsMap.begin(); itr != AuctionsMap.end(); ) + for (AuctionEntryMap::iterator itr = AuctionsMap.begin(); itr != AuctionsMap.end();) { if (itr->second->moneyDeliveryTime) // pending auction { @@ -608,9 +610,9 @@ void AuctionHouseObject::Update() void AuctionHouseObject::BuildListBidderItems(WorldPacket& data, Player* player, uint32& count, uint32& totalcount) { - for (AuctionEntryMap::const_iterator itr = AuctionsMap.begin();itr != AuctionsMap.end();++itr) + for (AuctionEntryMap::const_iterator itr = AuctionsMap.begin(); itr != AuctionsMap.end(); ++itr) { - AuctionEntry *Aentry = itr->second; + AuctionEntry* Aentry = itr->second; if (Aentry->moneyDeliveryTime) // skip pending sell auctions continue; if (Aentry->bidder == player->GetGUIDLow()) @@ -626,7 +628,7 @@ void AuctionHouseObject::BuildListOwnerItems(WorldPacket& data, Player* player, { for (AuctionEntryMap::const_iterator itr = AuctionsMap.begin(); itr != AuctionsMap.end(); ++itr) { - AuctionEntry *Aentry = itr->second; + AuctionEntry* Aentry = itr->second; if (Aentry->moneyDeliveryTime) // skip pending sell auctions continue; if (Aentry->owner == player->GetGUIDLow()) @@ -638,7 +640,7 @@ void AuctionHouseObject::BuildListOwnerItems(WorldPacket& data, Player* player, } } -int AuctionEntry::CompareAuctionEntry(uint32 column, const AuctionEntry *auc, Player* viewPlayer) const +int AuctionEntry::CompareAuctionEntry(uint32 column, const AuctionEntry* auc, Player* viewPlayer) const { switch (column) { @@ -746,7 +748,7 @@ int AuctionEntry::CompareAuctionEntry(uint32 column, const AuctionEntry *auc, Pl if (bid1 < bid2) return -1; else if (bid1 > bid2) - return +1; + return +1; break; } case 9: // quantity = 9 @@ -771,7 +773,7 @@ int AuctionEntry::CompareAuctionEntry(uint32 column, const AuctionEntry *auc, Pl return 0; } -bool AuctionSorter::operator()(const AuctionEntry *auc1, const AuctionEntry *auc2) const +bool AuctionSorter::operator()(const AuctionEntry* auc1, const AuctionEntry* auc2) const { if (m_sort[0] == MAX_AUCTION_SORT) // not sorted return false; @@ -793,16 +795,16 @@ bool AuctionSorter::operator()(const AuctionEntry *auc1, const AuctionEntry *auc } void WorldSession::BuildListAuctionItems(std::vector const& auctions, WorldPacket& data, std::wstring const& wsearchedname, uint32 listfrom, uint32 levelmin, - uint32 levelmax, uint32 usable, uint32 inventoryType, uint32 itemClass, uint32 itemSubClass, uint32 quality, uint32& count, uint32& totalcount, bool isFull) + uint32 levelmax, uint32 usable, uint32 inventoryType, uint32 itemClass, uint32 itemSubClass, uint32 quality, uint32& count, uint32& totalcount, bool isFull) { int loc_idx = _player->GetSession()->GetSessionDbLocaleIndex(); for (std::vector::const_iterator itr = auctions.begin(); itr != auctions.end(); ++itr) { - AuctionEntry *Aentry = *itr; + AuctionEntry* Aentry = *itr; if (Aentry->moneyDeliveryTime) continue; - Item *item = sAuctionMgr.GetAItem(Aentry->itemGuidLow); + Item* item = sAuctionMgr.GetAItem(Aentry->itemGuidLow); if (!item) continue; @@ -813,7 +815,7 @@ void WorldSession::BuildListAuctionItems(std::vector const& aucti } else { - ItemPrototype const *proto = item->GetProto(); + ItemPrototype const* proto = item->GetProto(); if (itemClass != 0xffffffff && proto->Class != itemClass) continue; @@ -854,7 +856,7 @@ void AuctionHouseObject::BuildListPendingSales(WorldPacket& data, Player* player { for (AuctionEntryMap::const_iterator itr = AuctionsMap.begin(); itr != AuctionsMap.end(); ++itr) { - AuctionEntry *Aentry = itr->second; + AuctionEntry* Aentry = itr->second; if (!Aentry->moneyDeliveryTime) // skip not pending auctions continue; if (Aentry->owner == player->GetGUIDLow()) @@ -878,11 +880,11 @@ void AuctionHouseObject::BuildListPendingSales(WorldPacket& data, Player* player } } -AuctionEntry* AuctionHouseObject::AddAuction(AuctionHouseEntry const* auctionHouseEntry, Item* newItem, uint32 etime, uint32 bid, uint32 buyout, uint32 deposit, Player * pl /*= NULL*/) +AuctionEntry* AuctionHouseObject::AddAuction(AuctionHouseEntry const* auctionHouseEntry, Item* newItem, uint32 etime, uint32 bid, uint32 buyout, uint32 deposit, Player* pl /*= NULL*/) { uint32 auction_time = uint32(etime * sWorld.getConfig(CONFIG_FLOAT_RATE_AUCTION_TIME)); - AuctionEntry *AH = new AuctionEntry; + AuctionEntry* AH = new AuctionEntry; AH->Id = sObjectMgr.GenerateAuctionID(); AH->itemGuidLow = newItem->GetObjectGuid().GetCounter(); AH->itemTemplate = newItem->GetEntry(); @@ -920,9 +922,9 @@ AuctionEntry* AuctionHouseObject::AddAuction(AuctionHouseEntry const* auctionHou } // this function inserts to WorldPacket auction's data -bool AuctionEntry::BuildAuctionInfo(WorldPacket & data) const +bool AuctionEntry::BuildAuctionInfo(WorldPacket& data) const { - Item *pItem = sAuctionMgr.GetAItem(itemGuidLow); + Item* pItem = sAuctionMgr.GetAItem(itemGuidLow); if (!pItem) { sLog.outError("auction to item, that doesn't exist !!!!"); @@ -977,8 +979,8 @@ void AuctionEntry::SaveToDB() const { //No SQL injection (no strings) CharacterDatabase.PExecute("INSERT INTO auction (id,houseid,itemguid,item_template,item_count,item_randompropertyid,itemowner,buyoutprice,time,moneyTime,buyguid,lastbid,startbid,deposit) " - "VALUES ('%u', '%u', '%u', '%u', '%u', '%i', '%u', '%u', '" UI64FMTD "', '" UI64FMTD "', '%u', '%u', '%u', '%u')", - Id, auctionHouseEntry->houseId, itemGuidLow, itemTemplate, itemCount, itemRandomPropertyId, owner, buyout, (uint64)expireTime, (uint64)moneyDeliveryTime, bidder, bid, startbid, deposit); + "VALUES ('%u', '%u', '%u', '%u', '%u', '%i', '%u', '%u', '" UI64FMTD "', '" UI64FMTD "', '%u', '%u', '%u', '%u')", + Id, auctionHouseEntry->houseId, itemGuidLow, itemTemplate, itemCount, itemRandomPropertyId, owner, buyout, (uint64)expireTime, (uint64)moneyDeliveryTime, bidder, bid, startbid, deposit); } void AuctionEntry::AuctionBidWinning(Player* newbidder) diff --git a/src/game/AuctionHouseMgr.h b/src/game/AuctionHouseMgr.h index 8e3707734..771a7ec29 100644 --- a/src/game/AuctionHouseMgr.h +++ b/src/game/AuctionHouseMgr.h @@ -76,13 +76,13 @@ struct AuctionEntry uint32 GetHouseFaction() const { return auctionHouseEntry->faction; } uint32 GetAuctionCut() const; uint32 GetAuctionOutBid() const; - bool BuildAuctionInfo(WorldPacket & data) const; + bool BuildAuctionInfo(WorldPacket& data) const; void DeleteFromDB() const; void SaveToDB() const; void AuctionBidWinning(Player* bidder = NULL); // -1,0,+1 order result - int CompareAuctionEntry(uint32 column, const AuctionEntry *auc, Player* viewPlayer) const; + int CompareAuctionEntry(uint32 column, const AuctionEntry* auc, Player* viewPlayer) const; bool UpdateBid(uint32 newbid, Player* newbidder = NULL);// true if normal bid, false if buyout, bidder==NULL for generated bid }; @@ -106,15 +106,15 @@ class AuctionHouseObject AuctionEntryMap const& GetAuctions() const { return AuctionsMap; } AuctionEntryMapBounds GetAuctionsBounds() const {return AuctionEntryMapBounds(AuctionsMap.begin(), AuctionsMap.end()); } - void AddAuction(AuctionEntry *ah) + void AddAuction(AuctionEntry* ah) { - MANGOS_ASSERT( ah ); + MANGOS_ASSERT(ah); AuctionsMap[ah->Id] = ah; } AuctionEntry* GetAuction(uint32 id) const { - AuctionEntryMap::const_iterator itr = AuctionsMap.find( id ); + AuctionEntryMap::const_iterator itr = AuctionsMap.find(id); return itr != AuctionsMap.end() ? itr->second : NULL; } @@ -129,7 +129,7 @@ class AuctionHouseObject void BuildListOwnerItems(WorldPacket& data, Player* player, uint32& count, uint32& totalcount); void BuildListPendingSales(WorldPacket& data, Player* player, uint32& count); - AuctionEntry* AddAuction(AuctionHouseEntry const* auctionHouseEntry, Item* newItem, uint32 etime, uint32 bid, uint32 buyout = 0, uint32 deposit = 0, Player * pl = NULL); + AuctionEntry* AddAuction(AuctionHouseEntry const* auctionHouseEntry, Item* newItem, uint32 etime, uint32 bid, uint32 buyout = 0, uint32 deposit = 0, Player* pl = NULL); private: AuctionEntryMap AuctionsMap; }; @@ -138,8 +138,8 @@ class AuctionSorter { public: AuctionSorter(AuctionSorter const& sorter) : m_sort(sorter.m_sort), m_viewPlayer(sorter.m_viewPlayer) {} - AuctionSorter(uint8 *sort, Player* viewPlayer) : m_sort(sort), m_viewPlayer(viewPlayer) {} - bool operator()(const AuctionEntry *auc1, const AuctionEntry *auc2) const; + AuctionSorter(uint8* sort, Player* viewPlayer) : m_sort(sort), m_viewPlayer(viewPlayer) {} + bool operator()(const AuctionEntry* auc1, const AuctionEntry* auc2) const; private: uint8* m_sort; @@ -177,10 +177,10 @@ class AuctionHouseMgr } //auction messages - void SendAuctionWonMail( AuctionEntry * auction ); - void SendAuctionSuccessfulMail( AuctionEntry * auction ); - void SendAuctionExpiredMail( AuctionEntry * auction ); - static uint32 GetAuctionDeposit(AuctionHouseEntry const* entry, uint32 time, Item *pItem); + void SendAuctionWonMail(AuctionEntry* auction); + void SendAuctionSuccessfulMail(AuctionEntry* auction); + void SendAuctionExpiredMail(AuctionEntry* auction); + static uint32 GetAuctionDeposit(AuctionHouseEntry const* entry, uint32 time, Item* pItem); static uint32 GetAuctionHouseTeam(AuctionHouseEntry const* house); static AuctionHouseEntry const* GetAuctionHouseEntry(Unit* unit); diff --git a/src/game/Bag.cpp b/src/game/Bag.cpp index d64af4819..8d032083d 100644 --- a/src/game/Bag.cpp +++ b/src/game/Bag.cpp @@ -219,7 +219,7 @@ uint32 Bag::GetItemCountWithLimitCategory(uint32 limitCategory, Item* eItem) con for (uint32 i = 0; i < GetBagSize(); ++i) if (m_bagslot[i]) - if (m_bagslot[i] != eItem && m_bagslot[i]->GetProto()->ItemLimitCategory == limitCategory ) + if (m_bagslot[i] != eItem && m_bagslot[i]->GetProto()->ItemLimitCategory == limitCategory) count += m_bagslot[i]->GetCount(); return count; diff --git a/src/game/Bag.h b/src/game/Bag.h index 2896a5655..5a2c84e12 100644 --- a/src/game/Bag.h +++ b/src/game/Bag.h @@ -39,7 +39,7 @@ class Bag : public Item bool Create(uint32 guidlow, uint32 itemid, Player const* owner); void Clear(); - void StoreItem(uint8 slot, Item *pItem, bool update); + void StoreItem(uint8 slot, Item* pItem, bool update); void RemoveItem(uint8 slot, bool update); Item* GetItemByPos(uint8 slot) const; diff --git a/src/game/BattleGround.cpp b/src/game/BattleGround.cpp index 000a81abc..6b36bff7e 100644 --- a/src/game/BattleGround.cpp +++ b/src/game/BattleGround.cpp @@ -53,7 +53,7 @@ namespace MaNGOS va_copy(ap,*i_args); char str [2048]; - vsnprintf(str,2048,text, ap ); + vsnprintf(str,2048,text, ap); va_end(ap); do_helper(data,&str[0]); @@ -91,14 +91,14 @@ namespace MaNGOS { char const* text = sObjectMgr.GetMangosString(i_textId,loc_idx); - if(i_args) + if (i_args) { // we need copy va_list before use or original va_list will corrupted va_list ap; va_copy(ap,*i_args); char str [2048]; - vsnprintf(str,2048,text, ap ); + vsnprintf(str,2048,text, ap); va_end(ap); do_helper(data,&str[0]); @@ -141,7 +141,7 @@ namespace MaNGOS char const* arg2str = i_arg2 ? sObjectMgr.GetMangosString(i_arg2,loc_idx) : ""; char str [2048]; - snprintf(str,2048,text, arg1str, arg2str ); + snprintf(str,2048,text, arg1str, arg2str); ObjectGuid targetGuid = i_source ? i_source ->GetObjectGuid() : ObjectGuid(); @@ -201,8 +201,8 @@ namespace MaNGOS template void BattleGround::BroadcastWorker(Do& _do) { - for(BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) - if (Player *plr = ObjectAccessor::FindPlayer(itr->first)) + for (BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) + if (Player* plr = ObjectAccessor::FindPlayer(itr->first)) _do(plr); } @@ -282,7 +282,7 @@ BattleGround::~BattleGround() // (this is done automatically in mapmanager update, when the instance is reset after the reset time) int size = m_BgObjects.size(); - for(int i = 0; i < size; ++i) + for (int i = 0; i < size; ++i) DelObject(i); sBattleGroundMgr.RemoveBattleGround(GetInstanceID(), GetTypeID()); @@ -300,7 +300,7 @@ BattleGround::~BattleGround() // remove from bg free slot queue this->RemoveFromBGFreeSlotQueue(); - for(BattleGroundScoreMap::const_iterator itr = m_PlayerScores.begin(); itr != m_PlayerScores.end(); ++itr) + for (BattleGroundScoreMap::const_iterator itr = m_PlayerScores.begin(); itr != m_PlayerScores.end(); ++itr) delete itr->second; } @@ -462,7 +462,7 @@ void BattleGround::Update(uint32 diff) PlaySoundToAll(SOUND_BG_START); - for(BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) + for (BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) if (Player* plr = sObjectMgr.GetPlayer(itr->first)) plr->RemoveAurasDueToSpell(SPELL_PREPARATION); //Announce BG starting @@ -486,7 +486,7 @@ void BattleGround::Update(uint32 diff) { m_EndTime = 0; BattleGroundPlayerMap::iterator itr, next; - for(itr = m_Players.begin(); itr != m_Players.end(); itr = next) + for (itr = m_Players.begin(); itr != m_Players.end(); itr = next) { next = itr; ++next; @@ -510,28 +510,28 @@ void BattleGround::SetTeamStartLoc(Team team, float X, float Y, float Z, float O m_TeamStartLocO[teamIdx] = O; } -void BattleGround::SendPacketToAll(WorldPacket *packet) +void BattleGround::SendPacketToAll(WorldPacket* packet) { - for(BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) + for (BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) { if (itr->second.OfflineRemoveTime) continue; - if (Player *plr = sObjectMgr.GetPlayer(itr->first)) + if (Player* plr = sObjectMgr.GetPlayer(itr->first)) plr->GetSession()->SendPacket(packet); else sLog.outError("BattleGround:SendPacketToAll: %s not found!", itr->first.GetString().c_str()); } } -void BattleGround::SendPacketToTeam(Team teamId, WorldPacket *packet, Player *sender, bool self) +void BattleGround::SendPacketToTeam(Team teamId, WorldPacket* packet, Player* sender, bool self) { - for(BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) + for (BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) { if (itr->second.OfflineRemoveTime) continue; - Player *plr = sObjectMgr.GetPlayer(itr->first); + Player* plr = sObjectMgr.GetPlayer(itr->first); if (!plr) { sLog.outError("BattleGround:SendPacketToTeam: %s not found!", itr->first.GetString().c_str()); @@ -560,12 +560,12 @@ void BattleGround::PlaySoundToTeam(uint32 SoundID, Team teamId) { WorldPacket data; - for(BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) + for (BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) { if (itr->second.OfflineRemoveTime) continue; - Player *plr = sObjectMgr.GetPlayer(itr->first); + Player* plr = sObjectMgr.GetPlayer(itr->first); if (!plr) { sLog.outError("BattleGround:PlaySoundToTeam: %s not found!", itr->first.GetString().c_str()); @@ -573,7 +573,7 @@ void BattleGround::PlaySoundToTeam(uint32 SoundID, Team teamId) } Team team = itr->second.PlayerTeam; - if(!team) team = plr->GetTeam(); + if (!team) team = plr->GetTeam(); if (team == teamId) { @@ -585,12 +585,12 @@ void BattleGround::PlaySoundToTeam(uint32 SoundID, Team teamId) void BattleGround::CastSpellOnTeam(uint32 SpellID, Team teamId) { - for(BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) + for (BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) { if (itr->second.OfflineRemoveTime) continue; - Player *plr = sObjectMgr.GetPlayer(itr->first); + Player* plr = sObjectMgr.GetPlayer(itr->first); if (!plr) { @@ -599,7 +599,7 @@ void BattleGround::CastSpellOnTeam(uint32 SpellID, Team teamId) } Team team = itr->second.PlayerTeam; - if(!team) team = plr->GetTeam(); + if (!team) team = plr->GetTeam(); if (team == teamId) plr->CastSpell(plr, SpellID, true); @@ -608,12 +608,12 @@ void BattleGround::CastSpellOnTeam(uint32 SpellID, Team teamId) void BattleGround::RewardHonorToTeam(uint32 Honor, Team teamId) { - for(BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) + for (BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) { if (itr->second.OfflineRemoveTime) continue; - Player *plr = sObjectMgr.GetPlayer(itr->first); + Player* plr = sObjectMgr.GetPlayer(itr->first); if (!plr) { @@ -622,7 +622,7 @@ void BattleGround::RewardHonorToTeam(uint32 Honor, Team teamId) } Team team = itr->second.PlayerTeam; - if(!team) team = plr->GetTeam(); + if (!team) team = plr->GetTeam(); if (team == teamId) UpdatePlayerScore(plr, SCORE_BONUS_HONOR, Honor); @@ -636,12 +636,12 @@ void BattleGround::RewardReputationToTeam(uint32 faction_id, uint32 Reputation, if (!factionEntry) return; - for(BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) + for (BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) { if (itr->second.OfflineRemoveTime) continue; - Player *plr = sObjectMgr.GetPlayer(itr->first); + Player* plr = sObjectMgr.GetPlayer(itr->first); if (!plr) { @@ -650,7 +650,7 @@ void BattleGround::RewardReputationToTeam(uint32 faction_id, uint32 Reputation, } Team team = itr->second.PlayerTeam; - if(!team) team = plr->GetTeam(); + if (!team) team = plr->GetTeam(); if (team == teamId) plr->GetReputationMgr().ModifyReputation(factionEntry, Reputation); @@ -664,7 +664,7 @@ void BattleGround::UpdateWorldState(uint32 Field, uint32 Value) SendPacketToAll(&data); } -void BattleGround::UpdateWorldStateForPlayer(uint32 Field, uint32 Value, Player *Source) +void BattleGround::UpdateWorldStateForPlayer(uint32 Field, uint32 Value, Player* Source) { WorldPacket data; sBattleGroundMgr.BuildUpdateWorldStatePacket(&data, Field, Value); @@ -675,8 +675,8 @@ void BattleGround::EndBattleGround(Team winner) { this->RemoveFromBGFreeSlotQueue(); - ArenaTeam * winner_arena_team = NULL; - ArenaTeam * loser_arena_team = NULL; + ArenaTeam* winner_arena_team = NULL; + ArenaTeam* loser_arena_team = NULL; uint32 loser_rating = 0; uint32 winner_rating = 0; WorldPacket data; @@ -723,7 +723,7 @@ void BattleGround::EndBattleGround(Team winner) } } - for(BattleGroundPlayerMap::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) + for (BattleGroundPlayerMap::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) { Team team = itr->second.PlayerTeam; @@ -740,7 +740,7 @@ void BattleGround::EndBattleGround(Team winner) continue; } - Player *plr = sObjectMgr.GetPlayer(itr->first); + Player* plr = sObjectMgr.GetPlayer(itr->first); if (!plr) { sLog.outError("BattleGround:EndBattleGround %s not found!", itr->first.GetString().c_str()); @@ -841,7 +841,7 @@ uint32 BattleGround::GetBonusHonorFromKill(uint32 kills) const uint32 BattleGround::GetBattlemasterEntry() const { - switch(GetTypeID()) + switch (GetTypeID()) { case BATTLEGROUND_AV: return 15972; case BATTLEGROUND_WS: return 14623; @@ -852,9 +852,9 @@ uint32 BattleGround::GetBattlemasterEntry() const } } -void BattleGround::RewardMark(Player *plr,uint32 count) +void BattleGround::RewardMark(Player* plr,uint32 count) { - switch(GetTypeID()) + switch (GetTypeID()) { case BATTLEGROUND_AV: if (count == ITEM_WINNER_COUNT) @@ -880,14 +880,14 @@ void BattleGround::RewardMark(Player *plr,uint32 count) } } -void BattleGround::RewardSpellCast(Player *plr, uint32 spell_id) +void BattleGround::RewardSpellCast(Player* plr, uint32 spell_id) { // 'Inactive' this aura prevents the player from gaining honor points and battleground tokens if (plr->GetDummyAura(SPELL_AURA_PLAYER_INACTIVE)) return; - SpellEntry const *spellInfo = sSpellStore.LookupEntry(spell_id); - if(!spellInfo) + SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell_id); + if (!spellInfo) { sLog.outError("Battleground reward casting spell %u not exist.",spell_id); return; @@ -896,7 +896,7 @@ void BattleGround::RewardSpellCast(Player *plr, uint32 spell_id) plr->CastSpell(plr, spellInfo, true); } -void BattleGround::RewardItem(Player *plr, uint32 item_id, uint32 count) +void BattleGround::RewardItem(Player* plr, uint32 item_id, uint32 count) { // 'Inactive' this aura prevents the player from gaining honor points and battleground tokens if (plr->GetDummyAura(SPELL_AURA_PLAYER_INACTIVE)) @@ -904,26 +904,26 @@ void BattleGround::RewardItem(Player *plr, uint32 item_id, uint32 count) ItemPosCountVec dest; uint32 no_space_count = 0; - uint8 msg = plr->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, item_id, count, &no_space_count ); + uint8 msg = plr->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, item_id, count, &no_space_count); - if( msg == EQUIP_ERR_ITEM_NOT_FOUND) + if (msg == EQUIP_ERR_ITEM_NOT_FOUND) { sLog.outErrorDb("Battleground reward item (Entry %u) not exist in `item_template`.",item_id); return; } - if( msg != EQUIP_ERR_OK ) // convert to possible store amount + if (msg != EQUIP_ERR_OK) // convert to possible store amount count -= no_space_count; - if( count != 0 && !dest.empty()) // can add some - if (Item* item = plr->StoreNewItem( dest, item_id, true, 0)) + if (count != 0 && !dest.empty()) // can add some + if (Item* item = plr->StoreNewItem(dest, item_id, true, 0)) plr->SendNewItem(item,count,true,false); if (no_space_count > 0) SendRewardMarkByMail(plr,item_id,no_space_count); } -void BattleGround::SendRewardMarkByMail(Player *plr,uint32 mark, uint32 count) +void BattleGround::SendRewardMarkByMail(Player* plr,uint32 mark, uint32 count) { uint32 bmEntry = GetBattlemasterEntry(); if (!bmEntry) @@ -950,15 +950,15 @@ void BattleGround::SendRewardMarkByMail(Player *plr,uint32 mark, uint32 count) snprintf(textBuf, 300, textFormat.c_str(), GetName(), GetName()); MailDraft(subject, textBuf) - .AddItem(markItem) - .SendMailTo(plr, MailSender(MAIL_CREATURE, bmEntry)); + .AddItem(markItem) + .SendMailTo(plr, MailSender(MAIL_CREATURE, bmEntry)); } } -void BattleGround::RewardQuestComplete(Player *plr) +void BattleGround::RewardQuestComplete(Player* plr) { uint32 quest; - switch(GetTypeID()) + switch (GetTypeID()) { case BATTLEGROUND_AV: quest = SPELL_AV_QUEST_REWARD; @@ -979,7 +979,7 @@ void BattleGround::RewardQuestComplete(Player *plr) RewardSpellCast(plr, quest); } -void BattleGround::BlockMovement(Player *plr) +void BattleGround::BlockMovement(Player* plr) { plr->SetClientControl(plr, 0); // movement disabled NOTE: the effect will be automatically removed by client when the player is teleported from the battleground, so no need to send with uint8(1) in RemovePlayerAtLeave() } @@ -1005,7 +1005,7 @@ void BattleGround::RemovePlayerAtLeave(ObjectGuid guid, bool Transport, bool Sen m_PlayerScores.erase(itr2); } - Player *plr = sObjectMgr.GetPlayer(guid); + Player* plr = sObjectMgr.GetPlayer(guid); if (plr) { @@ -1024,7 +1024,7 @@ void BattleGround::RemovePlayerAtLeave(ObjectGuid guid, bool Transport, bool Sen RemovePlayer(plr, guid); // BG subclass specific code - if(participant) // if the player was a match participant, remove auras, calc rating, update queue + if (participant) // if the player was a match participant, remove auras, calc rating, update queue { BattleGroundTypeId bgTypeId = GetTypeID(); BattleGroundQueueTypeId bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(GetTypeID(), GetArenaType()); @@ -1047,8 +1047,8 @@ void BattleGround::RemovePlayerAtLeave(ObjectGuid guid, bool Transport, bool Sen if (isRated() && GetStatus() == STATUS_IN_PROGRESS) { //left a rated match while the encounter was in progress, consider as loser - ArenaTeam * winner_arena_team = sObjectMgr.GetArenaTeamById(GetArenaTeamIdForTeam(GetOtherTeam(team))); - ArenaTeam * loser_arena_team = sObjectMgr.GetArenaTeamById(GetArenaTeamIdForTeam(team)); + ArenaTeam* winner_arena_team = sObjectMgr.GetArenaTeamById(GetArenaTeamIdForTeam(GetOtherTeam(team))); + ArenaTeam* loser_arena_team = sObjectMgr.GetArenaTeamById(GetArenaTeamIdForTeam(team)); if (winner_arena_team && loser_arena_team) loser_arena_team->MemberLost(plr,winner_arena_team->GetRating()); } @@ -1064,22 +1064,22 @@ void BattleGround::RemovePlayerAtLeave(ObjectGuid guid, bool Transport, bool Sen plr->RemoveBattleGroundQueueId(bgQueueTypeId); } else - // removing offline participant + // removing offline participant { if (isRated() && GetStatus() == STATUS_IN_PROGRESS) { //left a rated match while the encounter was in progress, consider as loser - ArenaTeam * others_arena_team = sObjectMgr.GetArenaTeamById(GetArenaTeamIdForTeam(GetOtherTeam(team))); - ArenaTeam * players_arena_team = sObjectMgr.GetArenaTeamById(GetArenaTeamIdForTeam(team)); + ArenaTeam* others_arena_team = sObjectMgr.GetArenaTeamById(GetArenaTeamIdForTeam(GetOtherTeam(team))); + ArenaTeam* players_arena_team = sObjectMgr.GetArenaTeamById(GetArenaTeamIdForTeam(team)); if (others_arena_team && players_arena_team) players_arena_team->OfflineMemberLost(guid, others_arena_team->GetRating()); } } // remove from raid group if player is member - if (Group *group = GetBgRaid(team)) + if (Group* group = GetBgRaid(team)) { - if( !group->RemoveMember(guid, 0) ) // group was disbanded + if (!group->RemoveMember(guid, 0)) // group was disbanded { SetBgRaid(team, NULL); delete group; @@ -1145,7 +1145,7 @@ void BattleGround::Reset() m_Players.clear(); - for(BattleGroundScoreMap::const_iterator itr = m_PlayerScores.begin(); itr != m_PlayerScores.end(); ++itr) + for (BattleGroundScoreMap::const_iterator itr = m_PlayerScores.begin(); itr != m_PlayerScores.end(); ++itr) delete itr->second; m_PlayerScores.clear(); } @@ -1170,7 +1170,7 @@ void BattleGround::StartTimedAchievement(AchievementCriteriaTypes type, uint32 e pPlayer->GetAchievementMgr().StartTimedAchievementCriteria(type, entry); } -void BattleGround::AddPlayer(Player *plr) +void BattleGround::AddPlayer(Player* plr) { // remove afk from player if (plr->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_AFK)) @@ -1218,14 +1218,14 @@ void BattleGround::AddPlayer(Player *plr) plr->DestroyConjuredItems(true); plr->UnsummonPetTemporaryIfAny(); - if(GetStatus() == STATUS_WAIT_JOIN) // not started yet + if (GetStatus() == STATUS_WAIT_JOIN) // not started yet plr->CastSpell(plr, SPELL_ARENA_PREPARATION, true); plr->CastSpell(plr, SPELL_ARENA_DAMPENING, true); } else { - if(GetStatus() == STATUS_WAIT_JOIN) // not started yet + if (GetStatus() == STATUS_WAIT_JOIN) // not started yet plr->CastSpell(plr, SPELL_PREPARATION, true); // reduces all mana cost of spells. plr->CastSpell(plr, SPELL_BATTLEGROUND_DAMPENING, true); @@ -1243,7 +1243,7 @@ void BattleGround::AddPlayer(Player *plr) } /* this method adds player to his team's bg group, or sets his correct group if player is already in bg group */ -void BattleGround::AddOrSetPlayerToCorrectBgGroup(Player *plr, ObjectGuid plr_guid, Team team) +void BattleGround::AddOrSetPlayerToCorrectBgGroup(Player* plr, ObjectGuid plr_guid, Team team) { if (Group* group = GetBgRaid(team)) // raid already exist { @@ -1272,7 +1272,7 @@ void BattleGround::AddOrSetPlayerToCorrectBgGroup(Player *plr, ObjectGuid plr_gu void BattleGround::EventPlayerLoggedIn(Player* player, ObjectGuid plr_guid) { // player is correct pointer - for(OfflineQueue::iterator itr = m_OfflineQueue.begin(); itr != m_OfflineQueue.end(); ++itr) + for (OfflineQueue::iterator itr = m_OfflineQueue.begin(); itr != m_OfflineQueue.end(); ++itr) { if (*itr == plr_guid) { @@ -1346,15 +1346,15 @@ bool BattleGround::HasFreeSlots() const return GetPlayersSize() < GetMaxPlayers(); } -void BattleGround::UpdatePlayerScore(Player *Source, uint32 type, uint32 value) +void BattleGround::UpdatePlayerScore(Player* Source, uint32 type, uint32 value) { //this procedure is called from virtual function implemented in bg subclass BattleGroundScoreMap::const_iterator itr = m_PlayerScores.find(Source->GetObjectGuid()); - if(itr == m_PlayerScores.end()) // player not found... + if (itr == m_PlayerScores.end()) // player not found... return; - switch(type) + switch (type) { case SCORE_KILLING_BLOWS: // Killing blows itr->second->KillingBlows += value; @@ -1392,37 +1392,37 @@ bool BattleGround::AddObject(uint32 type, uint32 entry, float x, float y, float // must be created this way, adding to godatamap would add it to the base map of the instance // and when loading it (in go::LoadFromDB()), a new guid would be assigned to the object, and a new object would be created // so we must create it specific for this instance - GameObject * go = new GameObject; + GameObject* go = new GameObject; if (!go->Create(GetBgMap()->GenerateLocalLowGuid(HIGHGUID_GAMEOBJECT),entry, GetBgMap(), - PHASEMASK_NORMAL, x,y,z,o, QuaternionData(rotation0,rotation1,rotation2,rotation3))) + PHASEMASK_NORMAL, x,y,z,o, QuaternionData(rotation0,rotation1,rotation2,rotation3))) { sLog.outErrorDb("Gameobject template %u not found in database! BattleGround not created!", entry); sLog.outError("Cannot create gameobject template %u! BattleGround not created!", entry); delete go; return false; } -/* - uint32 guid = go->GetGUIDLow(); + /* + uint32 guid = go->GetGUIDLow(); - // without this, UseButtonOrDoor caused the crash, since it tried to get go info from godata - // iirc that was changed, so adding to go data map is no longer required if that was the only function using godata from GameObject without checking if it existed - GameObjectData& data = sObjectMgr.NewGOData(guid); + // without this, UseButtonOrDoor caused the crash, since it tried to get go info from godata + // iirc that was changed, so adding to go data map is no longer required if that was the only function using godata from GameObject without checking if it existed + GameObjectData& data = sObjectMgr.NewGOData(guid); - data.id = entry; - data.mapid = GetMapId(); - data.posX = x; - data.posY = y; - data.posZ = z; - data.orientation = o; - data.rotation0 = rotation0; - data.rotation1 = rotation1; - data.rotation2 = rotation2; - data.rotation3 = rotation3; - data.spawntimesecs = respawnTime; - data.spawnMask = 1; - data.animprogress = 100; - data.go_state = 1; -*/ + data.id = entry; + data.mapid = GetMapId(); + data.posX = x; + data.posY = y; + data.posZ = z; + data.orientation = o; + data.rotation0 = rotation0; + data.rotation1 = rotation1; + data.rotation2 = rotation2; + data.rotation3 = rotation3; + data.spawntimesecs = respawnTime; + data.spawnMask = 1; + data.animprogress = 100; + data.go_state = 1; + */ // add to world, so it can be later looked up from HashMapHolder go->AddToWorld(); m_BgObjects[type] = go->GetObjectGuid(); @@ -1433,7 +1433,7 @@ bool BattleGround::AddObject(uint32 type, uint32 entry, float x, float y, float //it would be nice to correctly implement GO_ACTIVATED state and open/close doors in gameobject code void BattleGround::DoorClose(ObjectGuid guid) { - GameObject *obj = GetBgMap()->GetGameObject(guid); + GameObject* obj = GetBgMap()->GetGameObject(guid); if (obj) { //if doors are open, close it @@ -1450,7 +1450,7 @@ void BattleGround::DoorClose(ObjectGuid guid) void BattleGround::DoorOpen(ObjectGuid guid) { - GameObject *obj = GetBgMap()->GetGameObject(guid); + GameObject* obj = GetBgMap()->GetGameObject(guid); if (obj) { //change state to be sure they will be opened @@ -1524,7 +1524,7 @@ void BattleGround::OpenDoorEvent(uint8 event1, uint8 event2 /*=0*/) return; } GuidVector::const_iterator itr = m_EventObjects[MAKE_PAIR32(event1, event2)].gameobjects.begin(); - for(; itr != m_EventObjects[MAKE_PAIR32(event1, event2)].gameobjects.end(); ++itr) + for (; itr != m_EventObjects[MAKE_PAIR32(event1, event2)].gameobjects.end(); ++itr) DoorOpen(*itr); } @@ -1533,7 +1533,7 @@ void BattleGround::SpawnEvent(uint8 event1, uint8 event2, bool spawn) // stop if we want to spawn something which was already spawned // or despawn something which was already despawned if (event2 == BG_EVENT_NONE || (spawn && m_ActiveEvents[event1] == event2) - || (!spawn && m_ActiveEvents[event1] != event2)) + || (!spawn && m_ActiveEvents[event1] != event2)) return; if (spawn) @@ -1546,10 +1546,10 @@ void BattleGround::SpawnEvent(uint8 event1, uint8 event2, bool spawn) m_ActiveEvents[event1] = BG_EVENT_NONE; // no event active if event2 gets despawned GuidVector::const_iterator itr = m_EventObjects[MAKE_PAIR32(event1, event2)].creatures.begin(); - for(; itr != m_EventObjects[MAKE_PAIR32(event1, event2)].creatures.end(); ++itr) + for (; itr != m_EventObjects[MAKE_PAIR32(event1, event2)].creatures.end(); ++itr) SpawnBGCreature(*itr, (spawn) ? RESPAWN_IMMEDIATELY : RESPAWN_ONE_DAY); GuidVector::const_iterator itr2 = m_EventObjects[MAKE_PAIR32(event1, event2)].gameobjects.begin(); - for(; itr2 != m_EventObjects[MAKE_PAIR32(event1, event2)].gameobjects.end(); ++itr2) + for (; itr2 != m_EventObjects[MAKE_PAIR32(event1, event2)].gameobjects.end(); ++itr2) SpawnBGObject(*itr2, (spawn) ? RESPAWN_IMMEDIATELY : RESPAWN_ONE_DAY); } @@ -1557,8 +1557,8 @@ void BattleGround::SpawnBGObject(ObjectGuid guid, uint32 respawntime) { Map* map = GetBgMap(); - GameObject *obj = map->GetGameObject(guid); - if(!obj) + GameObject* obj = map->GetGameObject(guid); + if (!obj) return; if (respawntime == 0) { @@ -1602,7 +1602,7 @@ bool BattleGround::DelObject(uint32 type) if (!m_BgObjects[type]) return true; - GameObject *obj = GetBgMap()->GetGameObject(m_BgObjects[type]); + GameObject* obj = GetBgMap()->GetGameObject(m_BgObjects[type]); if (!obj) { sLog.outError("Can't find gobject: %s", m_BgObjects[type].GetString().c_str()); @@ -1625,7 +1625,7 @@ void BattleGround::SendMessageToAll(int32 entry, ChatMsg type, Player const* sou void BattleGround::SendYellToAll(int32 entry, uint32 language, ObjectGuid guid) { Creature* source = GetBgMap()->GetCreature(guid); - if(!source) + if (!source) return; MaNGOS::BattleGroundYellBuilder bg_builder(language, entry, source); MaNGOS::LocalizedPacketDo bg_do(bg_builder); @@ -1654,7 +1654,7 @@ void BattleGround::SendMessage2ToAll(int32 entry, ChatMsg type, Player const* so void BattleGround::SendYell2ToAll(int32 entry, uint32 language, ObjectGuid guid, int32 arg1, int32 arg2) { Creature* source = GetBgMap()->GetCreature(guid); - if(!source) + if (!source) return; MaNGOS::BattleGround2YellBuilder bg_builder(language, entry, source, arg1, arg2); MaNGOS::LocalizedPacketDo bg_do(bg_builder); @@ -1675,7 +1675,7 @@ buffs are in their positions when battleground starts */ void BattleGround::HandleTriggerBuff(ObjectGuid go_guid) { - GameObject *obj = GetBgMap()->GetGameObject(go_guid); + GameObject* obj = GetBgMap()->GetGameObject(go_guid); if (!obj || obj->GetGoType() != GAMEOBJECT_TYPE_TRAP || !obj->isSpawned()) return; @@ -1695,7 +1695,7 @@ void BattleGround::HandleTriggerBuff(ObjectGuid go_guid) if (index < 0) { sLog.outError("BattleGround (Type: %u) has buff trigger %s GOType: %u but it hasn't that object in its internal data", - GetTypeID(), go_guid.GetString().c_str(), obj->GetGoType()); + GetTypeID(), go_guid.GetString().c_str(), obj->GetGoType()); return; } @@ -1720,7 +1720,7 @@ void BattleGround::HandleTriggerBuff(ObjectGuid go_guid) SpawnBGObject(m_BgObjects[index], BUFF_RESPAWN_TIME); } -void BattleGround::HandleKillPlayer( Player *player, Player *killer ) +void BattleGround::HandleKillPlayer(Player* player, Player* killer) { // add +1 deaths UpdatePlayerScore(player, SCORE_DEATHS, 1); @@ -1731,9 +1731,9 @@ void BattleGround::HandleKillPlayer( Player *player, Player *killer ) UpdatePlayerScore(killer, SCORE_HONORABLE_KILLS, 1); UpdatePlayerScore(killer, SCORE_KILLING_BLOWS, 1); - for(BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) + for (BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) { - Player *plr = sObjectMgr.GetPlayer(itr->first); + Player* plr = sObjectMgr.GetPlayer(itr->first); if (!plr || plr == killer) continue; @@ -1745,7 +1745,7 @@ void BattleGround::HandleKillPlayer( Player *player, Player *killer ) // to be able to remove insignia -- ONLY IN BattleGrounds if (!isArena()) - player->SetFlag( UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE ); + player->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE); } // return the player's team based on battlegroundplayer info @@ -1786,11 +1786,11 @@ void BattleGround::PlayerAddedToBGCheckIfBGIsRunning(Player* plr) uint32 BattleGround::GetAlivePlayersCountByTeam(Team team) const { int count = 0; - for(BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) + for (BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) { if (itr->second.PlayerTeam == team) { - Player * pl = sObjectMgr.GetPlayer(itr->first); + Player* pl = sObjectMgr.GetPlayer(itr->first); if (pl && pl->isAlive()) ++count; } @@ -1806,9 +1806,9 @@ void BattleGround::CheckArenaWinConditions() EndBattleGround(ALLIANCE); } -void BattleGround::SetBgRaid(Team team, Group *bg_raid) +void BattleGround::SetBgRaid(Team team, Group* bg_raid) { - Group* &old_raid = m_BgRaids[GetTeamIndexByTeamId(team)]; + Group*& old_raid = m_BgRaids[GetTeamIndexByTeamId(team)]; if (old_raid) old_raid->SetBattlegroundGroup(NULL); @@ -1819,7 +1819,7 @@ void BattleGround::SetBgRaid(Team team, Group *bg_raid) old_raid = bg_raid; } -WorldSafeLocsEntry const* BattleGround::GetClosestGraveYard( Player* player ) +WorldSafeLocsEntry const* BattleGround::GetClosestGraveYard(Player* player) { return sObjectMgr.GetClosestGraveYard(player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), player->GetTeam()); } @@ -1831,7 +1831,7 @@ bool BattleGround::IsTeamScoreInRange(Team team, uint32 minScore, uint32 maxScor return score >= minScore && score <= maxScore; } -void BattleGround::SetBracket( PvPDifficultyEntry const* bracketEntry ) +void BattleGround::SetBracket(PvPDifficultyEntry const* bracketEntry) { m_BracketId = bracketEntry->GetBracketId(); SetLevelRange(bracketEntry->minLevel,bracketEntry->maxLevel); diff --git a/src/game/BattleGround.h b/src/game/BattleGround.h index c0d84f17e..c2593e905 100644 --- a/src/game/BattleGround.h +++ b/src/game/BattleGround.h @@ -151,7 +151,7 @@ struct BattleGroundObjectInfo { BattleGroundObjectInfo() : object(NULL), timer(0), spellid(0) {} - GameObject *object; + GameObject* object; int32 timer; uint32 spellid; }; @@ -273,7 +273,7 @@ This class is used to: */ class BattleGround { - friend class BattleGroundMgr; + friend class BattleGroundMgr; public: /* Construction */ @@ -388,7 +388,7 @@ class BattleGround } void SetTeamStartLoc(Team team, float X, float Y, float Z, float O); - void GetTeamStartLoc(Team team, float &X, float &Y, float &Z, float &O) const + void GetTeamStartLoc(Team team, float& X, float& Y, float& Z, float& O) const { BattleGroundTeamIndex idx = GetTeamIndexByTeamId(team); X = m_TeamStartLocX[idx]; @@ -400,8 +400,8 @@ class BattleGround /* Packet Transfer */ // method that should fill worldpacket with actual world states (not yet implemented for all battlegrounds!) virtual void FillInitialWorldStates(WorldPacket& /*data*/, uint32& /*count*/) {} - void SendPacketToTeam(Team team, WorldPacket *packet, Player *sender = NULL, bool self = true); - void SendPacketToAll(WorldPacket *packet); + void SendPacketToTeam(Team team, WorldPacket* packet, Player* sender = NULL, bool self = true); + void SendPacketToAll(WorldPacket* packet); template void BroadcastWorker(Do& _do); @@ -411,29 +411,29 @@ class BattleGround void CastSpellOnTeam(uint32 SpellID, Team team); void RewardHonorToTeam(uint32 Honor, Team team); void RewardReputationToTeam(uint32 faction_id, uint32 Reputation, Team team); - void RewardMark(Player *plr,uint32 count); - void SendRewardMarkByMail(Player *plr,uint32 mark, uint32 count); - void RewardItem(Player *plr, uint32 item_id, uint32 count); - void RewardQuestComplete(Player *plr); - void RewardSpellCast(Player *plr, uint32 spell_id); + void RewardMark(Player* plr,uint32 count); + void SendRewardMarkByMail(Player* plr,uint32 mark, uint32 count); + void RewardItem(Player* plr, uint32 item_id, uint32 count); + void RewardQuestComplete(Player* plr); + void RewardSpellCast(Player* plr, uint32 spell_id); void UpdateWorldState(uint32 Field, uint32 Value); - void UpdateWorldStateForPlayer(uint32 Field, uint32 Value, Player *Source); + void UpdateWorldStateForPlayer(uint32 Field, uint32 Value, Player* Source); virtual void EndBattleGround(Team winner); - void BlockMovement(Player *plr); + void BlockMovement(Player* plr); void SendMessageToAll(int32 entry, ChatMsg type, Player const* source = NULL); void SendYellToAll(int32 entry, uint32 language, ObjectGuid guid); - void PSendMessageToAll(int32 entry, ChatMsg type, Player const* source, ... ); + void PSendMessageToAll(int32 entry, ChatMsg type, Player const* source, ...); // specialized version with 2 string id args void SendMessage2ToAll(int32 entry, ChatMsg type, Player const* source, int32 strId1 = 0, int32 strId2 = 0); void SendYell2ToAll(int32 entry, uint32 language, ObjectGuid guid, int32 arg1, int32 arg2); /* Raid Group */ - Group *GetBgRaid(Team team) const { return m_BgRaids[GetTeamIndexByTeamId(team)]; } - void SetBgRaid(Team team, Group *bg_raid); + Group* GetBgRaid(Team team) const { return m_BgRaids[GetTeamIndexByTeamId(team)]; } + void SetBgRaid(Team team, Group* bg_raid); - virtual void UpdatePlayerScore(Player *Source, uint32 type, uint32 value); + virtual void UpdatePlayerScore(Player* Source, uint32 type, uint32 value); static BattleGroundTeamIndex GetTeamIndexByTeamId(Team team) { return team == ALLIANCE ? BG_TEAM_ALLIANCE : BG_TEAM_HORDE; } uint32 GetPlayersCountByTeam(Team team) const { return m_PlayersCount[GetTeamIndexByTeamId(team)]; } @@ -457,7 +457,7 @@ class BattleGround // must be implemented in BG subclass virtual void HandleAreaTrigger(Player* /*Source*/, uint32 /*Trigger*/) {} // must be implemented in BG subclass if need AND call base class generic code - virtual void HandleKillPlayer(Player *player, Player *killer); + virtual void HandleKillPlayer(Player* player, Player* killer); virtual void HandleKillUnit(Creature* /*unit*/, Player* /*killer*/) { return; }; /* Battleground events */ @@ -470,12 +470,12 @@ class BattleGround /* Death related */ virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* player); - virtual void AddPlayer(Player *plr); // must be implemented in BG subclass + virtual void AddPlayer(Player* plr); // must be implemented in BG subclass - void AddOrSetPlayerToCorrectBgGroup(Player *plr, ObjectGuid plr_guid, Team team); + void AddOrSetPlayerToCorrectBgGroup(Player* plr, ObjectGuid plr_guid, Team team); virtual void RemovePlayerAtLeave(ObjectGuid guid, bool Transport, bool SendPacket); - // can be extended in in BG subclass + // can be extended in in BG subclass /* event related */ // called when a creature gets added to map (NOTE: only triggered if @@ -507,12 +507,12 @@ class BattleGround void DoorOpen(ObjectGuid guid); void DoorClose(ObjectGuid guid); - virtual bool HandlePlayerUnderMap(Player * /*plr*/) { return false; } + virtual bool HandlePlayerUnderMap(Player* /*plr*/) { return false; } // since arenas can be AvA or Hvh, we have to get the "temporary" team of a player Team GetPlayerTeam(ObjectGuid guid); - static Team GetOtherTeam(Team team){ return team ? ((team == ALLIANCE) ? HORDE : ALLIANCE) : TEAM_NONE; } - static BattleGroundTeamIndex GetOtherTeamIndex(BattleGroundTeamIndex teamIdx){ return teamIdx == BG_TEAM_ALLIANCE ? BG_TEAM_HORDE : BG_TEAM_ALLIANCE; } + static Team GetOtherTeam(Team team) { return team ? ((team == ALLIANCE) ? HORDE : ALLIANCE) : TEAM_NONE; } + static BattleGroundTeamIndex GetOtherTeamIndex(BattleGroundTeamIndex teamIdx) { return teamIdx == BG_TEAM_ALLIANCE ? BG_TEAM_HORDE : BG_TEAM_ALLIANCE; } bool IsPlayerInBattleGround(ObjectGuid guid); /* virtual score-array - get's used in bg-subclasses */ @@ -543,7 +543,7 @@ class BattleGround BattleGroundScoreMap m_PlayerScores; // Player scores // must be implemented in BG subclass - virtual void RemovePlayer(Player * /*player*/, ObjectGuid /*guid*/) {} + virtual void RemovePlayer(Player* /*player*/, ObjectGuid /*guid*/) {} /* Player lists, those need to be accessible by inherited classes */ BattleGroundPlayerMap m_Players; @@ -575,7 +575,7 @@ class BattleGround bool m_IsRated; // is this battle rated? bool m_PrematureCountDown; uint32 m_PrematureCountDownTimer; - char const *m_Name; + char const* m_Name; /* Player lists */ typedef std::deque OfflineQueue; @@ -588,7 +588,7 @@ class BattleGround uint32 m_InvitedHorde; /* Raid Group */ - Group *m_BgRaids[BG_TEAMS_COUNT]; // 0 - alliance, 1 - horde + Group* m_BgRaids[BG_TEAMS_COUNT]; // 0 - alliance, 1 - horde /* Players count by team */ uint32 m_PlayersCount[BG_TEAMS_COUNT]; @@ -645,7 +645,7 @@ struct WorldStatePair inline void FillInitialWorldState(ByteBuffer& data, uint32& count, WorldStatePair const* array) { - for(WorldStatePair const* itr = array; itr->state; ++itr) + for (WorldStatePair const* itr = array; itr->state; ++itr) { data << uint32(itr->state); data << uint32(itr->value); diff --git a/src/game/BattleGroundAA.cpp b/src/game/BattleGroundAA.cpp index c6630fa92..2b33ab44d 100644 --- a/src/game/BattleGroundAA.cpp +++ b/src/game/BattleGroundAA.cpp @@ -53,7 +53,7 @@ void BattleGroundAA::StartingEventOpenDoors() { } -void BattleGroundAA::AddPlayer(Player *plr) +void BattleGroundAA::AddPlayer(Player* plr) { BattleGround::AddPlayer(plr); //create score and add it to map, default values are set in constructor @@ -62,7 +62,7 @@ void BattleGroundAA::AddPlayer(Player *plr) m_PlayerScores[plr->GetObjectGuid()] = sc; } -void BattleGroundAA::RemovePlayer(Player * /*plr*/, ObjectGuid /*guid*/) +void BattleGroundAA::RemovePlayer(Player* /*plr*/, ObjectGuid /*guid*/) { } @@ -71,7 +71,7 @@ void BattleGroundAA::HandleKillPlayer(Player* player, Player* killer) BattleGround::HandleKillPlayer(player, killer); } -void BattleGroundAA::HandleAreaTrigger(Player * /*Source*/, uint32 /*Trigger*/) +void BattleGroundAA::HandleAreaTrigger(Player* /*Source*/, uint32 /*Trigger*/) { } diff --git a/src/game/BattleGroundAA.h b/src/game/BattleGroundAA.h index cd5ee902d..60b3ef524 100644 --- a/src/game/BattleGroundAA.h +++ b/src/game/BattleGroundAA.h @@ -30,7 +30,7 @@ class BattleGroundAAScore : public BattleGroundScore class BattleGroundAA : public BattleGround { - friend class BattleGroundMgr; + friend class BattleGroundMgr; public: BattleGroundAA(); @@ -38,13 +38,13 @@ class BattleGroundAA : public BattleGround void Update(uint32 diff); /* inherited from BattlegroundClass */ - virtual void AddPlayer(Player *plr); + virtual void AddPlayer(Player* plr); virtual void StartingEventCloseDoors(); virtual void StartingEventOpenDoors(); - void RemovePlayer(Player *plr, ObjectGuid guid); - void HandleAreaTrigger(Player *Source, uint32 Trigger); + void RemovePlayer(Player* plr, ObjectGuid guid); + void HandleAreaTrigger(Player* Source, uint32 Trigger); bool SetupBattleGround(); - void HandleKillPlayer(Player* player, Player *killer); + void HandleKillPlayer(Player* player, Player* killer); }; #endif diff --git a/src/game/BattleGroundAB.cpp b/src/game/BattleGroundAB.cpp index 0f4154844..774afd5fc 100644 --- a/src/game/BattleGroundAB.cpp +++ b/src/game/BattleGroundAB.cpp @@ -180,7 +180,7 @@ void BattleGroundAB::StartingEventOpenDoors() StartTimedAchievement(ACHIEVEMENT_CRITERIA_TYPE_WIN_BG, BG_AB_EVENT_START_BATTLE); } -void BattleGroundAB::AddPlayer(Player *plr) +void BattleGroundAB::AddPlayer(Player* plr) { BattleGround::AddPlayer(plr); //create score and add it to map, default values are set in the constructor @@ -189,14 +189,14 @@ void BattleGroundAB::AddPlayer(Player *plr) m_PlayerScores[plr->GetObjectGuid()] = sc; } -void BattleGroundAB::RemovePlayer(Player * /*plr*/, ObjectGuid /*guid*/) +void BattleGroundAB::RemovePlayer(Player* /*plr*/, ObjectGuid /*guid*/) { } -void BattleGroundAB::HandleAreaTrigger(Player *Source, uint32 Trigger) +void BattleGroundAB::HandleAreaTrigger(Player* Source, uint32 Trigger) { - switch(Trigger) + switch (Trigger) { case 3948: // Arathi Basin Alliance Exit. if (Source->GetTeam() != ALLIANCE) @@ -334,7 +334,7 @@ void BattleGroundAB::_NodeOccupied(uint8 node,Team team) } /* Invoked if a player used a banner as a gameobject */ -void BattleGroundAB::EventPlayerClickedOnFlag(Player *source, GameObject* target_obj) +void BattleGroundAB::EventPlayerClickedOnFlag(Player* source, GameObject* target_obj) { if (GetStatus() != STATUS_IN_PROGRESS) return; @@ -447,9 +447,9 @@ bool BattleGroundAB::SetupBattleGround() for (int i = 0; i < BG_AB_NODES_MAX; ++i) { if (!AddObject(BG_AB_OBJECT_SPEEDBUFF_STABLES + 3 * i, Buff_Entries[0], BG_AB_BuffPositions[i][0], BG_AB_BuffPositions[i][1], BG_AB_BuffPositions[i][2], BG_AB_BuffPositions[i][3], 0, 0, sin(BG_AB_BuffPositions[i][3]/2), cos(BG_AB_BuffPositions[i][3]/2), RESPAWN_ONE_DAY) - || !AddObject(BG_AB_OBJECT_SPEEDBUFF_STABLES + 3 * i + 1, Buff_Entries[1], BG_AB_BuffPositions[i][0], BG_AB_BuffPositions[i][1], BG_AB_BuffPositions[i][2], BG_AB_BuffPositions[i][3], 0, 0, sin(BG_AB_BuffPositions[i][3]/2), cos(BG_AB_BuffPositions[i][3]/2), RESPAWN_ONE_DAY) - || !AddObject(BG_AB_OBJECT_SPEEDBUFF_STABLES + 3 * i + 2, Buff_Entries[2], BG_AB_BuffPositions[i][0], BG_AB_BuffPositions[i][1], BG_AB_BuffPositions[i][2], BG_AB_BuffPositions[i][3], 0, 0, sin(BG_AB_BuffPositions[i][3]/2), cos(BG_AB_BuffPositions[i][3]/2), RESPAWN_ONE_DAY) - ) + || !AddObject(BG_AB_OBJECT_SPEEDBUFF_STABLES + 3 * i + 1, Buff_Entries[1], BG_AB_BuffPositions[i][0], BG_AB_BuffPositions[i][1], BG_AB_BuffPositions[i][2], BG_AB_BuffPositions[i][3], 0, 0, sin(BG_AB_BuffPositions[i][3]/2), cos(BG_AB_BuffPositions[i][3]/2), RESPAWN_ONE_DAY) + || !AddObject(BG_AB_OBJECT_SPEEDBUFF_STABLES + 3 * i + 2, Buff_Entries[2], BG_AB_BuffPositions[i][0], BG_AB_BuffPositions[i][1], BG_AB_BuffPositions[i][2], BG_AB_BuffPositions[i][3], 0, 0, sin(BG_AB_BuffPositions[i][3]/2), cos(BG_AB_BuffPositions[i][3]/2), RESPAWN_ONE_DAY) + ) sLog.outErrorDb("BatteGroundAB: Failed to spawn buff object!"); } @@ -522,7 +522,7 @@ WorldSafeLocsEntry const* BattleGroundAB::GetClosestGraveYard(Player* player) float mindist = 999999.0f; for (uint8 i = 0; i < nodes.size(); ++i) { - WorldSafeLocsEntry const*entry = sWorldSafeLocsStore.LookupEntry( BG_AB_GraveyardIds[nodes[i]] ); + WorldSafeLocsEntry const* entry = sWorldSafeLocsStore.LookupEntry(BG_AB_GraveyardIds[nodes[i]]); if (!entry) continue; float dist = (entry->x - plr_x)*(entry->x - plr_x)+(entry->y - plr_y)*(entry->y - plr_y); @@ -536,18 +536,18 @@ WorldSafeLocsEntry const* BattleGroundAB::GetClosestGraveYard(Player* player) } // If not, place ghost on starting location if (!good_entry) - good_entry = sWorldSafeLocsStore.LookupEntry( BG_AB_GraveyardIds[teamIndex+5] ); + good_entry = sWorldSafeLocsStore.LookupEntry(BG_AB_GraveyardIds[teamIndex+5]); return good_entry; } -void BattleGroundAB::UpdatePlayerScore(Player *Source, uint32 type, uint32 value) +void BattleGroundAB::UpdatePlayerScore(Player* Source, uint32 type, uint32 value) { BattleGroundScoreMap::iterator itr = m_PlayerScores.find(Source->GetObjectGuid()); - if( itr == m_PlayerScores.end() ) // player not found... + if (itr == m_PlayerScores.end()) // player not found... return; - switch(type) + switch (type) { case SCORE_BASES_ASSAULTED: ((BattleGroundABScore*)itr->second)->BasesAssaulted += value; @@ -566,7 +566,7 @@ bool BattleGroundAB::IsAllNodesConrolledByTeam(Team team) const uint32 count = 0; for (int i = 0; i < BG_AB_NODES_MAX; ++i) if ((team == ALLIANCE && m_Nodes[i] == BG_AB_NODE_STATUS_ALLY_OCCUPIED) || - (team == HORDE && m_Nodes[i] == BG_AB_NODE_STATUS_HORDE_OCCUPIED)) + (team == HORDE && m_Nodes[i] == BG_AB_NODE_STATUS_HORDE_OCCUPIED)) ++count; return count == BG_AB_NODES_MAX; diff --git a/src/game/BattleGroundAB.h b/src/game/BattleGroundAB.h index f6a254c43..9a6191d60 100644 --- a/src/game/BattleGroundAB.h +++ b/src/game/BattleGroundAB.h @@ -29,34 +29,34 @@ enum BG_AB_WorldStates BG_AB_OP_RESOURCES_HORDE = 1777, BG_AB_OP_RESOURCES_MAX = 1780, BG_AB_OP_RESOURCES_WARNING = 1955 -/* - BG_AB_OP_STABLE_ICON = 1842, //Stable map icon (NONE) - BG_AB_OP_STABLE_STATE_ALIENCE = 1767, //Stable map state (ALIENCE) - BG_AB_OP_STABLE_STATE_HORDE = 1768, //Stable map state (HORDE) - BG_AB_OP_STABLE_STATE_CON_ALI = 1769, //Stable map state (CON ALIENCE) - BG_AB_OP_STABLE_STATE_CON_HOR = 1770, //Stable map state (CON HORDE) - BG_AB_OP_FARM_ICON = 1845, //Farm map icon (NONE) - BG_AB_OP_FARM_STATE_ALIENCE = 1772, //Farm state (ALIENCE) - BG_AB_OP_FARM_STATE_HORDE = 1773, //Farm state (HORDE) - BG_AB_OP_FARM_STATE_CON_ALI = 1774, //Farm state (CON ALIENCE) - BG_AB_OP_FARM_STATE_CON_HOR = 1775, //Farm state (CON HORDE) + /* + BG_AB_OP_STABLE_ICON = 1842, //Stable map icon (NONE) + BG_AB_OP_STABLE_STATE_ALIENCE = 1767, //Stable map state (ALIENCE) + BG_AB_OP_STABLE_STATE_HORDE = 1768, //Stable map state (HORDE) + BG_AB_OP_STABLE_STATE_CON_ALI = 1769, //Stable map state (CON ALIENCE) + BG_AB_OP_STABLE_STATE_CON_HOR = 1770, //Stable map state (CON HORDE) + BG_AB_OP_FARM_ICON = 1845, //Farm map icon (NONE) + BG_AB_OP_FARM_STATE_ALIENCE = 1772, //Farm state (ALIENCE) + BG_AB_OP_FARM_STATE_HORDE = 1773, //Farm state (HORDE) + BG_AB_OP_FARM_STATE_CON_ALI = 1774, //Farm state (CON ALIENCE) + BG_AB_OP_FARM_STATE_CON_HOR = 1775, //Farm state (CON HORDE) - BG_AB_OP_BLACKSMITH_ICON = 1846, //Blacksmith map icon (NONE) - BG_AB_OP_BLACKSMITH_STATE_ALIENCE = 1782, //Blacksmith map state (ALIENCE) - BG_AB_OP_BLACKSMITH_STATE_HORDE = 1783, //Blacksmith map state (HORDE) - BG_AB_OP_BLACKSMITH_STATE_CON_ALI = 1784, //Blacksmith map state (CON ALIENCE) - BG_AB_OP_BLACKSMITH_STATE_CON_HOR = 1785, //Blacksmith map state (CON HORDE) - BG_AB_OP_LUMBERMILL_ICON = 1844, //Lumber Mill map icon (NONE) - BG_AB_OP_LUMBERMILL_STATE_ALIENCE = 1792, //Lumber Mill map state (ALIENCE) - BG_AB_OP_LUMBERMILL_STATE_HORDE = 1793, //Lumber Mill map state (HORDE) - BG_AB_OP_LUMBERMILL_STATE_CON_ALI = 1794, //Lumber Mill map state (CON ALIENCE) - BG_AB_OP_LUMBERMILL_STATE_CON_HOR = 1795, //Lumber Mill map state (CON HORDE) - BG_AB_OP_GOLDMINE_ICON = 1843, //Gold Mine map icon (NONE) - BG_AB_OP_GOLDMINE_STATE_ALIENCE = 1787, //Gold Mine map state (ALIENCE) - BG_AB_OP_GOLDMINE_STATE_HORDE = 1788, //Gold Mine map state (HORDE) - BG_AB_OP_GOLDMINE_STATE_CON_ALI = 1789, //Gold Mine map state (CON ALIENCE - BG_AB_OP_GOLDMINE_STATE_CON_HOR = 1790, //Gold Mine map state (CON HORDE) -*/ + BG_AB_OP_BLACKSMITH_ICON = 1846, //Blacksmith map icon (NONE) + BG_AB_OP_BLACKSMITH_STATE_ALIENCE = 1782, //Blacksmith map state (ALIENCE) + BG_AB_OP_BLACKSMITH_STATE_HORDE = 1783, //Blacksmith map state (HORDE) + BG_AB_OP_BLACKSMITH_STATE_CON_ALI = 1784, //Blacksmith map state (CON ALIENCE) + BG_AB_OP_BLACKSMITH_STATE_CON_HOR = 1785, //Blacksmith map state (CON HORDE) + BG_AB_OP_LUMBERMILL_ICON = 1844, //Lumber Mill map icon (NONE) + BG_AB_OP_LUMBERMILL_STATE_ALIENCE = 1792, //Lumber Mill map state (ALIENCE) + BG_AB_OP_LUMBERMILL_STATE_HORDE = 1793, //Lumber Mill map state (HORDE) + BG_AB_OP_LUMBERMILL_STATE_CON_ALI = 1794, //Lumber Mill map state (CON ALIENCE) + BG_AB_OP_LUMBERMILL_STATE_CON_HOR = 1795, //Lumber Mill map state (CON HORDE) + BG_AB_OP_GOLDMINE_ICON = 1843, //Gold Mine map icon (NONE) + BG_AB_OP_GOLDMINE_STATE_ALIENCE = 1787, //Gold Mine map state (ALIENCE) + BG_AB_OP_GOLDMINE_STATE_HORDE = 1788, //Gold Mine map state (HORDE) + BG_AB_OP_GOLDMINE_STATE_CON_ALI = 1789, //Gold Mine map state (CON ALIENCE + BG_AB_OP_GOLDMINE_STATE_CON_HOR = 1790, //Gold Mine map state (CON HORDE) + */ }; const uint32 BG_AB_OP_NODESTATES[5] = {1767, 1782, 1772, 1792, 1787}; @@ -149,7 +149,8 @@ const uint32 BG_AB_TickPoints[6] = {0, 10, 10, 10, 10, 30}; const uint32 BG_AB_GraveyardIds[7] = {895, 894, 893, 897, 896, 898, 899}; // x, y, z, o -const float BG_AB_BuffPositions[BG_AB_NODES_MAX][4] = { +const float BG_AB_BuffPositions[BG_AB_NODES_MAX][4] = +{ {1185.71f, 1185.24f, -56.36f, 2.56f}, // stables {990.75f, 1008.18f, -42.60f, 2.43f}, // blacksmith {817.66f, 843.34f, -56.54f, 3.01f}, // farm @@ -175,30 +176,30 @@ class BattleGroundABScore : public BattleGroundScore class BattleGroundAB : public BattleGround { - friend class BattleGroundMgr; + friend class BattleGroundMgr; public: BattleGroundAB(); ~BattleGroundAB(); void Update(uint32 diff); - void AddPlayer(Player *plr); + void AddPlayer(Player* plr); virtual void StartingEventCloseDoors(); virtual void StartingEventOpenDoors(); - void RemovePlayer(Player *plr, ObjectGuid guid); - void HandleAreaTrigger(Player *Source, uint32 Trigger); + void RemovePlayer(Player* plr, ObjectGuid guid); + void HandleAreaTrigger(Player* Source, uint32 Trigger); virtual bool SetupBattleGround(); virtual void Reset(); void EndBattleGround(Team winner); virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* player); /* Scorekeeping */ - virtual void UpdatePlayerScore(Player *Source, uint32 type, uint32 value); + virtual void UpdatePlayerScore(Player* Source, uint32 type, uint32 value); virtual void FillInitialWorldStates(WorldPacket& data, uint32& count); /* Nodes occupying */ - virtual void EventPlayerClickedOnFlag(Player *source, GameObject* target_obj); + virtual void EventPlayerClickedOnFlag(Player* source, GameObject* target_obj); /* achievement req. */ bool IsAllNodesConrolledByTeam(Team team) const; // overwrited diff --git a/src/game/BattleGroundAV.cpp b/src/game/BattleGroundAV.cpp index 94bd50190..687a6d91f 100644 --- a/src/game/BattleGroundAV.cpp +++ b/src/game/BattleGroundAV.cpp @@ -38,7 +38,7 @@ BattleGroundAV::~BattleGroundAV() { } -void BattleGroundAV::HandleKillPlayer(Player *player, Player *killer) +void BattleGroundAV::HandleKillPlayer(Player* player, Player* killer) { if (GetStatus() != STATUS_IN_PROGRESS) return; @@ -47,7 +47,7 @@ void BattleGroundAV::HandleKillPlayer(Player *player, Player *killer) UpdateScore(GetTeamIndexByTeamId(player->GetTeam()), -1); } -void BattleGroundAV::HandleKillUnit(Creature *creature, Player *killer) +void BattleGroundAV::HandleKillUnit(Creature* creature, Player* killer) { DEBUG_LOG("BattleGroundAV: HandleKillUnit %i", creature->GetEntry()); if (GetStatus() != STATUS_IN_PROGRESS) @@ -55,7 +55,7 @@ void BattleGroundAV::HandleKillUnit(Creature *creature, Player *killer) uint8 event1 = (sBattleGroundMgr.GetCreatureEventIndex(creature->GetGUIDLow())).event1; if (event1 == BG_EVENT_NONE) return; - switch(event1) + switch (event1) { case BG_AV_BOSS_A: CastSpellOnTeam(BG_AV_BOSS_KILL_QUEST_SPELL, HORDE); // this is a spell which finishes a quest where a player has to kill the boss @@ -98,7 +98,7 @@ void BattleGroundAV::HandleKillUnit(Creature *creature, Player *killer) } } -void BattleGroundAV::HandleQuestComplete(uint32 questid, Player *player) +void BattleGroundAV::HandleQuestComplete(uint32 questid, Player* player) { if (GetStatus() != STATUS_IN_PROGRESS) return; @@ -108,7 +108,7 @@ void BattleGroundAV::HandleQuestComplete(uint32 questid, Player *player) uint32 reputation = 0; // reputation for the whole team (other reputation must be done in db) // TODO add events (including quest not available anymore, next quest availabe, go/npc de/spawning) sLog.outError("BattleGroundAV: Quest %i completed", questid); - switch(questid) + switch (questid) { case BG_AV_QUEST_A_SCRAPS1: case BG_AV_QUEST_A_SCRAPS2: @@ -116,7 +116,7 @@ void BattleGroundAV::HandleQuestComplete(uint32 questid, Player *player) case BG_AV_QUEST_H_SCRAPS2: m_Team_QuestStatus[teamIdx][0] += 20; reputation = 1; - if( m_Team_QuestStatus[teamIdx][0] == 500 || m_Team_QuestStatus[teamIdx][0] == 1000 || m_Team_QuestStatus[teamIdx][0] == 1500 ) //25,50,75 turn ins + if (m_Team_QuestStatus[teamIdx][0] == 500 || m_Team_QuestStatus[teamIdx][0] == 1000 || m_Team_QuestStatus[teamIdx][0] == 1500) //25,50,75 turn ins { DEBUG_LOG("BattleGroundAV: Quest %i completed starting with unit upgrading..", questid); for (BG_AV_Nodes i = BG_AV_NODES_FIRSTAID_STATION; i <= BG_AV_NODES_FROSTWOLF_HUT; ++i) @@ -209,10 +209,10 @@ void BattleGroundAV::HandleQuestComplete(uint32 questid, Player *player) RewardReputationToTeam((player->GetTeam() == ALLIANCE) ? BG_AV_FACTION_A : BG_AV_FACTION_H, reputation, player->GetTeam()); } -void BattleGroundAV::UpdateScore(BattleGroundTeamIndex teamIdx, int32 points ) +void BattleGroundAV::UpdateScore(BattleGroundTeamIndex teamIdx, int32 points) { // note: to remove reinforcements points must be negative, for adding reinforcements points must be positive - MANGOS_ASSERT( teamIdx == BG_TEAM_ALLIANCE || teamIdx == BG_TEAM_HORDE); + MANGOS_ASSERT(teamIdx == BG_TEAM_ALLIANCE || teamIdx == BG_TEAM_HORDE); m_TeamScores[teamIdx] += points; // m_TeamScores is int32 - so no problems here if (points < 0) @@ -242,7 +242,7 @@ void BattleGroundAV::Update(uint32 diff) return; // add points from mine owning, and look if the neutral team can reclaim the mine - for(uint8 mine = 0; mine < BG_AV_MAX_MINES; mine++) + for (uint8 mine = 0; mine < BG_AV_MAX_MINES; mine++) { if (m_Mine_Owner[mine] != BG_AV_TEAM_NEUTRAL) { @@ -261,7 +261,7 @@ void BattleGroundAV::Update(uint32 diff) } // looks for all timers of the nodes and destroy the building (for graveyards the building wont get destroyed, it goes just to the other team - for(BG_AV_Nodes i = BG_AV_NODES_FIRSTAID_STATION; i < BG_AV_NODES_MAX; ++i) + for (BG_AV_Nodes i = BG_AV_NODES_FIRSTAID_STATION; i < BG_AV_NODES_MAX; ++i) { if (m_Nodes[i].State == POINT_ASSAULTED) { @@ -289,7 +289,7 @@ void BattleGroundAV::StartingEventOpenDoors() StartTimedAchievement(ACHIEVEMENT_CRITERIA_TYPE_WIN_BG, BG_AV_EVENT_START_BATTLE); } -void BattleGroundAV::AddPlayer(Player *plr) +void BattleGroundAV::AddPlayer(Player* plr) { BattleGround::AddPlayer(plr); // create score and add it to map, default values are set in constructor @@ -304,17 +304,17 @@ void BattleGroundAV::EndBattleGround(Team winner) uint32 graves_owned[BG_TEAMS_COUNT] = {0, 0}; uint32 mines_owned[BG_TEAMS_COUNT] = {0, 0}; // towers all not destroyed: - for(BG_AV_Nodes i = BG_AV_NODES_DUNBALDAR_SOUTH; i <= BG_AV_NODES_STONEHEART_BUNKER; ++i) + for (BG_AV_Nodes i = BG_AV_NODES_DUNBALDAR_SOUTH; i <= BG_AV_NODES_STONEHEART_BUNKER; ++i) if (m_Nodes[i].State == POINT_CONTROLLED) if (m_Nodes[i].TotalOwner == BG_AV_TEAM_ALLIANCE) ++tower_survived[BG_TEAM_ALLIANCE]; - for(BG_AV_Nodes i = BG_AV_NODES_ICEBLOOD_TOWER; i <= BG_AV_NODES_FROSTWOLF_WTOWER; ++i) + for (BG_AV_Nodes i = BG_AV_NODES_ICEBLOOD_TOWER; i <= BG_AV_NODES_FROSTWOLF_WTOWER; ++i) if (m_Nodes[i].State == POINT_CONTROLLED) if (m_Nodes[i].TotalOwner == BG_AV_TEAM_HORDE) ++tower_survived[BG_TEAM_HORDE]; // graves all controlled - for(BG_AV_Nodes i = BG_AV_NODES_FIRSTAID_STATION; i < BG_AV_NODES_MAX; ++i) + for (BG_AV_Nodes i = BG_AV_NODES_FIRSTAID_STATION; i < BG_AV_NODES_MAX; ++i) if (m_Nodes[i].State == POINT_CONTROLLED && m_Nodes[i].Owner != BG_AV_TEAM_NEUTRAL) ++graves_owned[m_Nodes[i].Owner]; @@ -358,10 +358,10 @@ void BattleGroundAV::RemovePlayer(Player* /*plr*/, ObjectGuid /*guid*/) { } -void BattleGroundAV::HandleAreaTrigger(Player *Source, uint32 Trigger) +void BattleGroundAV::HandleAreaTrigger(Player* Source, uint32 Trigger) { // this is wrong way to implement these things. On official it done by gameobject spell cast. - switch(Trigger) + switch (Trigger) { case 95: case 2608: @@ -395,10 +395,10 @@ void BattleGroundAV::UpdatePlayerScore(Player* Source, uint32 type, uint32 value { BattleGroundScoreMap::iterator itr = m_PlayerScores.find(Source->GetObjectGuid()); - if(itr == m_PlayerScores.end()) // player not found... + if (itr == m_PlayerScores.end()) // player not found... return; - switch(type) + switch (type) { case SCORE_GRAVEYARDS_ASSAULTED: ((BattleGroundAVScore*)itr->second)->GraveyardsAssaulted += value; @@ -474,8 +474,8 @@ void BattleGroundAV::ChangeMineOwner(uint8 mine, BattleGroundAVTeamIndex teamIdx PlaySoundToAll((teamIdx == BG_AV_TEAM_ALLIANCE) ? BG_AV_SOUND_ALLIANCE_GOOD : BG_AV_SOUND_HORDE_GOOD); m_Mine_Reclaim_Timer[mine] = BG_AV_MINE_RECLAIM_TIMER; SendYell2ToAll(LANG_BG_AV_MINE_TAKEN , LANG_UNIVERSAL, GetSingleCreatureGuid(BG_AV_HERALD, 0), - (teamIdx == BG_AV_TEAM_ALLIANCE ) ? LANG_BG_ALLY : LANG_BG_HORDE, - (mine == BG_AV_NORTH_MINE) ? LANG_BG_AV_MINE_NORTH : LANG_BG_AV_MINE_SOUTH); + (teamIdx == BG_AV_TEAM_ALLIANCE) ? LANG_BG_ALLY : LANG_BG_HORDE, + (mine == BG_AV_NORTH_MINE) ? LANG_BG_AV_MINE_NORTH : LANG_BG_AV_MINE_SOUTH); } } @@ -496,11 +496,11 @@ void BattleGroundAV::PopulateNode(BG_AV_Nodes node) if (IsGrave(node) && teamIdx != BG_AV_TEAM_NEUTRAL) { uint32 graveDefenderType; - if (m_Team_QuestStatus[teamIdx][0] < 500 ) + if (m_Team_QuestStatus[teamIdx][0] < 500) graveDefenderType = 0; - else if (m_Team_QuestStatus[teamIdx][0] < 1000 ) + else if (m_Team_QuestStatus[teamIdx][0] < 1000) graveDefenderType = 1; - else if (m_Team_QuestStatus[teamIdx][0] < 1500 ) + else if (m_Team_QuestStatus[teamIdx][0] < 1500) graveDefenderType = 2; else graveDefenderType = 3; @@ -514,7 +514,7 @@ void BattleGroundAV::PopulateNode(BG_AV_Nodes node) } /// called when using a banner -void BattleGroundAV::EventPlayerClickedOnFlag(Player *source, GameObject* target_obj) +void BattleGroundAV::EventPlayerClickedOnFlag(Player* source, GameObject* target_obj) { if (GetStatus() != STATUS_IN_PROGRESS) return; @@ -544,7 +544,7 @@ void BattleGroundAV::EventPlayerDefendsPoint(Player* player, BG_AV_Nodes node) if (m_Nodes[node].Owner == BattleGroundAVTeamIndex(teamIdx) || m_Nodes[node].State != POINT_ASSAULTED) return; - if( m_Nodes[node].TotalOwner == BG_AV_TEAM_NEUTRAL ) // initial snowfall capture + if (m_Nodes[node].TotalOwner == BG_AV_TEAM_NEUTRAL) // initial snowfall capture { // until snowfall doesn't belong to anyone it is better handled in assault - code (best would be to have a special function // for neutral nodes.. but doing this just for snowfall will be a bit to much i think @@ -566,19 +566,19 @@ void BattleGroundAV::EventPlayerDefendsPoint(Player* player, BG_AV_Nodes node) if (IsTower(node)) { - SendYell2ToAll( LANG_BG_AV_TOWER_DEFENDED, LANG_UNIVERSAL, GetSingleCreatureGuid(BG_AV_HERALD, 0), - GetNodeName(node), - ( teamIdx == BG_TEAM_ALLIANCE ) ? LANG_BG_ALLY:LANG_BG_HORDE); + SendYell2ToAll(LANG_BG_AV_TOWER_DEFENDED, LANG_UNIVERSAL, GetSingleCreatureGuid(BG_AV_HERALD, 0), + GetNodeName(node), + (teamIdx == BG_TEAM_ALLIANCE) ? LANG_BG_ALLY:LANG_BG_HORDE); UpdatePlayerScore(player, SCORE_TOWERS_DEFENDED, 1); PlaySoundToAll(BG_AV_SOUND_BOTH_TOWER_DEFEND); } else { SendYell2ToAll(LANG_BG_AV_GRAVE_DEFENDED, LANG_UNIVERSAL, GetSingleCreatureGuid(BG_AV_HERALD, 0), - GetNodeName(node), - ( teamIdx == BG_TEAM_ALLIANCE ) ? LANG_BG_ALLY:LANG_BG_HORDE); + GetNodeName(node), + (teamIdx == BG_TEAM_ALLIANCE) ? LANG_BG_ALLY:LANG_BG_HORDE); UpdatePlayerScore(player, SCORE_GRAVEYARDS_DEFENDED, 1); - // update the statistic for the defending player + // update the statistic for the defending player PlaySoundToAll((teamIdx == BG_TEAM_ALLIANCE)?BG_AV_SOUND_ALLIANCE_GOOD:BG_AV_SOUND_HORDE_GOOD); } } @@ -598,15 +598,15 @@ void BattleGroundAV::EventPlayerAssaultsPoint(Player* player, BG_AV_Nodes node) if (IsTower(node)) { SendYell2ToAll(LANG_BG_AV_TOWER_ASSAULTED, LANG_UNIVERSAL, GetSingleCreatureGuid(BG_AV_HERALD, 0), - GetNodeName(node), - ( teamIdx == BG_TEAM_ALLIANCE ) ? LANG_BG_ALLY:LANG_BG_HORDE); + GetNodeName(node), + (teamIdx == BG_TEAM_ALLIANCE) ? LANG_BG_ALLY:LANG_BG_HORDE); UpdatePlayerScore(player, SCORE_TOWERS_ASSAULTED, 1); } else { SendYell2ToAll(LANG_BG_AV_GRAVE_ASSAULTED, LANG_UNIVERSAL, GetSingleCreatureGuid(BG_AV_HERALD, 0), - GetNodeName(node), - ( teamIdx == BG_TEAM_ALLIANCE ) ? LANG_BG_ALLY:LANG_BG_HORDE); + GetNodeName(node), + (teamIdx == BG_TEAM_ALLIANCE) ? LANG_BG_ALLY:LANG_BG_HORDE); // update the statistic for the assaulting player UpdatePlayerScore(player, SCORE_GRAVEYARDS_ASSAULTED, 1); } @@ -623,18 +623,18 @@ void BattleGroundAV::FillInitialWorldStates(WorldPacket& data, uint32& count) { stateok = (m_Nodes[i].State == j); FillInitialWorldState(data, count, BG_AV_NodeWorldStates[i][GetWorldStateType(j, BG_AV_TEAM_ALLIANCE)], - m_Nodes[i].Owner == BG_AV_TEAM_ALLIANCE && stateok); + m_Nodes[i].Owner == BG_AV_TEAM_ALLIANCE && stateok); FillInitialWorldState(data, count, BG_AV_NodeWorldStates[i][GetWorldStateType(j, BG_AV_TEAM_HORDE)], - m_Nodes[i].Owner == BG_AV_TEAM_HORDE && stateok); + m_Nodes[i].Owner == BG_AV_TEAM_HORDE && stateok); } } - if( m_Nodes[BG_AV_NODES_SNOWFALL_GRAVE].Owner == BG_AV_TEAM_NEUTRAL ) // cause neutral teams aren't handled generic + if (m_Nodes[BG_AV_NODES_SNOWFALL_GRAVE].Owner == BG_AV_TEAM_NEUTRAL) // cause neutral teams aren't handled generic FillInitialWorldState(data, count, AV_SNOWFALL_N, 1); FillInitialWorldState(data, count, BG_AV_Alliance_Score, m_TeamScores[BG_TEAM_ALLIANCE]); FillInitialWorldState(data, count, BG_AV_Horde_Score, m_TeamScores[BG_TEAM_HORDE]); - if( GetStatus() == STATUS_IN_PROGRESS ) // only if game is running the teamscores are displayed + if (GetStatus() == STATUS_IN_PROGRESS) // only if game is running the teamscores are displayed { FillInitialWorldState(data, count, BG_AV_SHOW_A_SCORE, 1); FillInitialWorldState(data, count, BG_AV_SHOW_H_SCORE, 1); @@ -657,7 +657,7 @@ void BattleGroundAV::FillInitialWorldStates(WorldPacket& data, uint32& count) void BattleGroundAV::UpdateNodeWorldState(BG_AV_Nodes node) { UpdateWorldState(BG_AV_NodeWorldStates[node][GetWorldStateType(m_Nodes[node].State,m_Nodes[node].Owner)], 1); - if( m_Nodes[node].PrevOwner == BG_AV_TEAM_NEUTRAL ) // currently only snowfall is supported as neutral node + if (m_Nodes[node].PrevOwner == BG_AV_TEAM_NEUTRAL) // currently only snowfall is supported as neutral node UpdateWorldState(AV_SNOWFALL_N, 0); else UpdateWorldState(BG_AV_NodeWorldStates[node][GetWorldStateType(m_Nodes[node].PrevState,m_Nodes[node].PrevOwner)], 0); @@ -672,7 +672,7 @@ void BattleGroundAV::SendMineWorldStates(uint32 mine) UpdateWorldState(BG_AV_MineWorldStates[mine][m_Mine_PrevOwner[mine]], 0); } -WorldSafeLocsEntry const* BattleGroundAV::GetClosestGraveYard(Player *plr) +WorldSafeLocsEntry const* BattleGroundAV::GetClosestGraveYard(Player* plr) { float x = plr->GetPositionX(); float y = plr->GetPositionY(); @@ -682,11 +682,11 @@ WorldSafeLocsEntry const* BattleGroundAV::GetClosestGraveYard(Player *plr) { // Is there any occupied node for this team? float mindist = 9999999.0f; - for(uint8 i = BG_AV_NODES_FIRSTAID_STATION; i <= BG_AV_NODES_FROSTWOLF_HUT; ++i) + for (uint8 i = BG_AV_NODES_FIRSTAID_STATION; i <= BG_AV_NODES_FROSTWOLF_HUT; ++i) { if (m_Nodes[i].Owner != teamIdx || m_Nodes[i].State != POINT_CONTROLLED) continue; - WorldSafeLocsEntry const * entry = sWorldSafeLocsStore.LookupEntry( BG_AV_GraveyardIds[i] ); + WorldSafeLocsEntry const* entry = sWorldSafeLocsStore.LookupEntry(BG_AV_GraveyardIds[i]); if (!entry) continue; float dist = (entry->x - x) * (entry->x - x) + (entry->y - y) * (entry->y - y); @@ -699,7 +699,7 @@ WorldSafeLocsEntry const* BattleGroundAV::GetClosestGraveYard(Player *plr) } // If not, place ghost in the starting-cave if (!good_entry) - good_entry = sWorldSafeLocsStore.LookupEntry( BG_AV_GraveyardIds[teamIdx + 7] ); + good_entry = sWorldSafeLocsStore.LookupEntry(BG_AV_GraveyardIds[teamIdx + 7]); return good_entry; } @@ -794,16 +794,16 @@ void BattleGroundAV::Reset() m_RepSurviveTower = (isBGWeekend) ? BG_AV_REP_SURVIVING_TOWER_HOLIDAY : BG_AV_REP_SURVIVING_TOWER; m_RepOwnedMine = (isBGWeekend) ? BG_AV_REP_OWNED_MINE_HOLIDAY : BG_AV_REP_OWNED_MINE; - for(uint8 i = 0; i < BG_TEAMS_COUNT; i++) + for (uint8 i = 0; i < BG_TEAMS_COUNT; i++) { - for(uint8 j = 0; j < 9; j++) // 9 quests getting tracked + for (uint8 j = 0; j < 9; j++) // 9 quests getting tracked m_Team_QuestStatus[i][j] = 0; m_TeamScores[i] = BG_AV_SCORE_INITIAL_POINTS; m_IsInformedNearLose[i] = false; m_ActiveEvents[BG_AV_NodeEventCaptainDead_A + i] = BG_EVENT_NONE; } - for(uint8 i = 0; i < BG_AV_MAX_MINES; i++) + for (uint8 i = 0; i < BG_AV_MAX_MINES; i++) { m_Mine_Owner[i] = BG_AV_TEAM_NEUTRAL; m_Mine_PrevOwner[i] = m_Mine_Owner[i]; @@ -817,17 +817,17 @@ void BattleGroundAV::Reset() m_ActiveEvents[BG_AV_HERALD] = 0; m_ActiveEvents[BG_AV_BOSS_A] = 0; m_ActiveEvents[BG_AV_BOSS_H] = 0; - for(BG_AV_Nodes i = BG_AV_NODES_DUNBALDAR_SOUTH; i <= BG_AV_NODES_FROSTWOLF_WTOWER; ++i) // towers + for (BG_AV_Nodes i = BG_AV_NODES_DUNBALDAR_SOUTH; i <= BG_AV_NODES_FROSTWOLF_WTOWER; ++i) // towers m_ActiveEvents[BG_AV_MARSHAL_A_SOUTH + i - BG_AV_NODES_DUNBALDAR_SOUTH] = 0; - for(BG_AV_Nodes i = BG_AV_NODES_FIRSTAID_STATION; i <= BG_AV_NODES_STONEHEART_GRAVE; ++i) // alliance graves + for (BG_AV_Nodes i = BG_AV_NODES_FIRSTAID_STATION; i <= BG_AV_NODES_STONEHEART_GRAVE; ++i) // alliance graves InitNode(i, BG_AV_TEAM_ALLIANCE, false); - for(BG_AV_Nodes i = BG_AV_NODES_DUNBALDAR_SOUTH; i <= BG_AV_NODES_STONEHEART_BUNKER; ++i) // alliance towers + for (BG_AV_Nodes i = BG_AV_NODES_DUNBALDAR_SOUTH; i <= BG_AV_NODES_STONEHEART_BUNKER; ++i) // alliance towers InitNode(i, BG_AV_TEAM_ALLIANCE, true); - for(BG_AV_Nodes i = BG_AV_NODES_ICEBLOOD_GRAVE; i <= BG_AV_NODES_FROSTWOLF_HUT; ++i) // horde graves + for (BG_AV_Nodes i = BG_AV_NODES_ICEBLOOD_GRAVE; i <= BG_AV_NODES_FROSTWOLF_HUT; ++i) // horde graves InitNode(i, BG_AV_TEAM_HORDE, false); - for(BG_AV_Nodes i = BG_AV_NODES_ICEBLOOD_TOWER; i <= BG_AV_NODES_FROSTWOLF_WTOWER; ++i) // horde towers + for (BG_AV_Nodes i = BG_AV_NODES_ICEBLOOD_TOWER; i <= BG_AV_NODES_FROSTWOLF_WTOWER; ++i) // horde towers InitNode(i, BG_AV_TEAM_HORDE, true); InitNode(BG_AV_NODES_SNOWFALL_GRAVE, BG_AV_TEAM_NEUTRAL, false); // give snowfall neutral owner diff --git a/src/game/BattleGroundAV.h b/src/game/BattleGroundAV.h index f5dcdc84a..a87df41da 100644 --- a/src/game/BattleGroundAV.h +++ b/src/game/BattleGroundAV.h @@ -175,7 +175,8 @@ enum BG_AV_Graveyards BG_AV_GRAVE_MAIN_HORDE = 610 }; -const uint32 BG_AV_GraveyardIds[9]= { +const uint32 BG_AV_GraveyardIds[9]= +{ BG_AV_GRAVE_STORM_AID, BG_AV_GRAVE_STORM_GRAVE, BG_AV_GRAVE_STONE_GRAVE, @@ -216,13 +217,15 @@ enum BattleGroundAVTeamIndex #define BG_AV_TEAMS_COUNT 3 // alliance_control horde_control neutral_control -const uint32 BG_AV_MineWorldStates[2][BG_AV_TEAMS_COUNT] = { +const uint32 BG_AV_MineWorldStates[2][BG_AV_TEAMS_COUNT] = +{ {1358, 1359, 1360}, {1355, 1356, 1357} }; // alliance_control alliance_assault h_control h_assault -const uint32 BG_AV_NodeWorldStates[BG_AV_NODES_MAX][4] = { +const uint32 BG_AV_NodeWorldStates[BG_AV_NODES_MAX][4] = +{ // Stormpike first aid station {1326,1325,1328,1327}, // Stormpike Graveyard @@ -294,7 +297,7 @@ struct BG_AV_NodeInfo bool Tower; }; -inline BG_AV_Nodes &operator++(BG_AV_Nodes &i) +inline BG_AV_Nodes& operator++(BG_AV_Nodes& i) { return i = BG_AV_Nodes(i + 1); } @@ -313,7 +316,7 @@ class BattleGroundAVScore : public BattleGroundScore class BattleGroundAV : public BattleGround { - friend class BattleGroundMgr; + friend class BattleGroundMgr; public: BattleGroundAV(); @@ -321,31 +324,31 @@ class BattleGroundAV : public BattleGround void Update(uint32 diff); /* inherited from BattlegroundClass */ - virtual void AddPlayer(Player *plr); + virtual void AddPlayer(Player* plr); virtual void StartingEventCloseDoors(); virtual void StartingEventOpenDoors(); // world states virtual void FillInitialWorldStates(WorldPacket& data, uint32& count); - void RemovePlayer(Player *plr, ObjectGuid guid); - void HandleAreaTrigger(Player *Source, uint32 Trigger); + void RemovePlayer(Player* plr, ObjectGuid guid); + void HandleAreaTrigger(Player* Source, uint32 Trigger); virtual void Reset(); /*general stuff*/ void UpdateScore(BattleGroundTeamIndex teamIdx, int32 points); - void UpdatePlayerScore(Player *Source, uint32 type, uint32 value); + void UpdatePlayerScore(Player* Source, uint32 type, uint32 value); /*handle stuff*/ // these are functions which get called from extern scripts - virtual void EventPlayerClickedOnFlag(Player *source, GameObject* target_obj); - void HandleKillPlayer(Player* player, Player *killer); - void HandleKillUnit(Creature *creature, Player *killer); - void HandleQuestComplete(uint32 questid, Player *player); + virtual void EventPlayerClickedOnFlag(Player* source, GameObject* target_obj); + void HandleKillPlayer(Player* player, Player* killer); + void HandleKillUnit(Creature* creature, Player* killer); + void HandleQuestComplete(uint32 questid, Player* player); bool PlayerCanDoMineQuest(int32 GOId, Team team); void EndBattleGround(Team winner); - virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player *plr); + virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* plr); static BattleGroundAVTeamIndex GetAVTeamIndexByTeamId(Team team) { return BattleGroundAVTeamIndex(GetTeamIndexByTeamId(team)); } private: diff --git a/src/game/BattleGroundBE.cpp b/src/game/BattleGroundBE.cpp index 8ce5b1e9a..7461949b9 100644 --- a/src/game/BattleGroundBE.cpp +++ b/src/game/BattleGroundBE.cpp @@ -60,7 +60,7 @@ void BattleGroundBE::StartingEventOpenDoors() OpenDoorEvent(BG_EVENT_DOOR); } -void BattleGroundBE::AddPlayer(Player *plr) +void BattleGroundBE::AddPlayer(Player* plr) { BattleGround::AddPlayer(plr); //create score and add it to map, default values are set in constructor @@ -83,7 +83,7 @@ void BattleGroundBE::RemovePlayer(Player* /*plr*/, ObjectGuid /*guid*/) CheckArenaWinConditions(); } -void BattleGroundBE::HandleKillPlayer(Player *player, Player *killer) +void BattleGroundBE::HandleKillPlayer(Player* player, Player* killer) { if (GetStatus() != STATUS_IN_PROGRESS) return; @@ -102,13 +102,13 @@ void BattleGroundBE::HandleKillPlayer(Player *player, Player *killer) CheckArenaWinConditions(); } -bool BattleGroundBE::HandlePlayerUnderMap(Player *player) +bool BattleGroundBE::HandlePlayerUnderMap(Player* player) { player->TeleportTo(GetMapId(),6238.930176f,262.963470f,0.889519f,player->GetOrientation(),false); return true; } -void BattleGroundBE::HandleAreaTrigger(Player *Source, uint32 Trigger) +void BattleGroundBE::HandleAreaTrigger(Player* Source, uint32 Trigger) { // this is wrong way to implement these things. On official it done by gameobject spell cast. if (GetStatus() != STATUS_IN_PROGRESS) @@ -116,7 +116,7 @@ void BattleGroundBE::HandleAreaTrigger(Player *Source, uint32 Trigger) //uint32 SpellId = 0; //uint64 buff_guid = 0; - switch(Trigger) + switch (Trigger) { case 4538: // buff trigger? //buff_guid = m_BgObjects[BG_BE_OBJECT_BUFF_1]; @@ -134,7 +134,7 @@ void BattleGroundBE::HandleAreaTrigger(Player *Source, uint32 Trigger) // HandleTriggerBuff(buff_guid,Source); } -void BattleGroundBE::FillInitialWorldStates(WorldPacket &data, uint32& count) +void BattleGroundBE::FillInitialWorldStates(WorldPacket& data, uint32& count) { FillInitialWorldState(data, count, 0x9f1, GetAlivePlayersCountByTeam(ALLIANCE)); FillInitialWorldState(data, count, 0x9f0, GetAlivePlayersCountByTeam(HORDE)); @@ -156,7 +156,7 @@ void BattleGroundBE::UpdatePlayerScore(Player* Source, uint32 type, uint32 value { BattleGroundScoreMap::iterator itr = m_PlayerScores.find(Source->GetObjectGuid()); - if(itr == m_PlayerScores.end()) // player not found... + if (itr == m_PlayerScores.end()) // player not found... return; //there is nothing special in this score diff --git a/src/game/BattleGroundBE.h b/src/game/BattleGroundBE.h index 75c2f936d..76441f930 100644 --- a/src/game/BattleGroundBE.h +++ b/src/game/BattleGroundBE.h @@ -29,7 +29,7 @@ class BattleGroundBEScore : public BattleGroundScore class BattleGroundBE : public BattleGround { - friend class BattleGroundMgr; + friend class BattleGroundMgr; public: BattleGroundBE(); @@ -37,19 +37,19 @@ class BattleGroundBE : public BattleGround void Update(uint32 diff); /* inherited from BattlegroundClass */ - virtual void AddPlayer(Player *plr); + virtual void AddPlayer(Player* plr); virtual void StartingEventCloseDoors(); virtual void StartingEventOpenDoors(); - void RemovePlayer(Player *plr, ObjectGuid guid); - void HandleAreaTrigger(Player *Source, uint32 Trigger); + void RemovePlayer(Player* plr, ObjectGuid guid); + void HandleAreaTrigger(Player* Source, uint32 Trigger); bool SetupBattleGround(); virtual void Reset(); - virtual void FillInitialWorldStates(WorldPacket &d, uint32& count); - void HandleKillPlayer(Player* player, Player *killer); - bool HandlePlayerUnderMap(Player * plr); + virtual void FillInitialWorldStates(WorldPacket& d, uint32& count); + void HandleKillPlayer(Player* player, Player* killer); + bool HandlePlayerUnderMap(Player* plr); /* Scorekeeping */ - void UpdatePlayerScore(Player *Source, uint32 type, uint32 value); + void UpdatePlayerScore(Player* Source, uint32 type, uint32 value); }; #endif diff --git a/src/game/BattleGroundDS.cpp b/src/game/BattleGroundDS.cpp index 56fd41893..2334628eb 100644 --- a/src/game/BattleGroundDS.cpp +++ b/src/game/BattleGroundDS.cpp @@ -53,7 +53,7 @@ void BattleGroundDS::StartingEventOpenDoors() { } -void BattleGroundDS::AddPlayer(Player *plr) +void BattleGroundDS::AddPlayer(Player* plr) { BattleGround::AddPlayer(plr); //create score and add it to map, default values are set in constructor @@ -62,7 +62,7 @@ void BattleGroundDS::AddPlayer(Player *plr) m_PlayerScores[plr->GetObjectGuid()] = sc; } -void BattleGroundDS::RemovePlayer(Player * /*plr*/, ObjectGuid /*guid*/) +void BattleGroundDS::RemovePlayer(Player* /*plr*/, ObjectGuid /*guid*/) { } @@ -71,7 +71,7 @@ void BattleGroundDS::HandleKillPlayer(Player* player, Player* killer) BattleGround::HandleKillPlayer(player, killer); } -void BattleGroundDS::HandleAreaTrigger(Player * /*Source*/, uint32 /*Trigger*/) +void BattleGroundDS::HandleAreaTrigger(Player* /*Source*/, uint32 /*Trigger*/) { } diff --git a/src/game/BattleGroundDS.h b/src/game/BattleGroundDS.h index 84701d895..01fff760a 100644 --- a/src/game/BattleGroundDS.h +++ b/src/game/BattleGroundDS.h @@ -30,7 +30,7 @@ class BattleGroundDSScore : public BattleGroundScore class BattleGroundDS : public BattleGround { - friend class BattleGroundMgr; + friend class BattleGroundMgr; public: BattleGroundDS(); @@ -38,13 +38,13 @@ class BattleGroundDS : public BattleGround void Update(uint32 diff); /* inherited from BattlegroundClass */ - virtual void AddPlayer(Player *plr); + virtual void AddPlayer(Player* plr); virtual void StartingEventCloseDoors(); virtual void StartingEventOpenDoors(); - void RemovePlayer(Player *plr, ObjectGuid guid); - void HandleAreaTrigger(Player *Source, uint32 Trigger); + void RemovePlayer(Player* plr, ObjectGuid guid); + void HandleAreaTrigger(Player* Source, uint32 Trigger); bool SetupBattleGround(); - void HandleKillPlayer(Player* player, Player *killer); + void HandleKillPlayer(Player* player, Player* killer); }; #endif diff --git a/src/game/BattleGroundEY.cpp b/src/game/BattleGroundEY.cpp index 3e20e0a65..e72aecb61 100644 --- a/src/game/BattleGroundEY.cpp +++ b/src/game/BattleGroundEY.cpp @@ -103,7 +103,7 @@ void BattleGroundEY::StartingEventOpenDoors() // eye-doors are despawned, not opened SpawnEvent(BG_EVENT_DOOR, 0, false); - for(uint32 i = 0; i < BG_EY_NODES_MAX; ++i) + for (uint32 i = 0; i < BG_EY_NODES_MAX; ++i) { //randomly spawn buff uint8 buff = urand(0, 2); @@ -119,7 +119,7 @@ void BattleGroundEY::AddPoints(Team team, uint32 Points) BattleGroundTeamIndex team_index = GetTeamIndexByTeamId(team); m_TeamScores[team_index] += Points; m_HonorScoreTics[team_index] += Points; - if (m_HonorScoreTics[team_index] >= m_HonorTics ) + if (m_HonorScoreTics[team_index] >= m_HonorTics) { RewardHonorToTeam(GetBonusHonorFromKill(1), team); m_HonorScoreTics[team_index] -= m_HonorTics; @@ -134,7 +134,7 @@ void BattleGroundEY::CheckSomeoneJoinedPoint() uint8 j = 0; while (j < m_PlayersNearPoint[BG_EY_PLAYERS_OUT_OF_POINTS].size()) { - Player *plr = sObjectMgr.GetPlayer(m_PlayersNearPoint[BG_EY_PLAYERS_OUT_OF_POINTS][j]); + Player* plr = sObjectMgr.GetPlayer(m_PlayersNearPoint[BG_EY_PLAYERS_OUT_OF_POINTS][j]); if (!plr) { sLog.outError("BattleGroundEY:CheckSomeoneJoinedPoint: %s not found!", m_PlayersNearPoint[BG_EY_PLAYERS_OUT_OF_POINTS][j].GetString().c_str()); @@ -142,7 +142,7 @@ void BattleGroundEY::CheckSomeoneJoinedPoint() continue; } if (plr->CanUseCapturePoint() && - plr->IsWithinDist3d(BG_EY_NodePositions[i][0], BG_EY_NodePositions[i][1], BG_EY_NodePositions[i][2], BG_EY_POINT_RADIUS)) + plr->IsWithinDist3d(BG_EY_NodePositions[i][0], BG_EY_NodePositions[i][1], BG_EY_NodePositions[i][2], BG_EY_POINT_RADIUS)) { //player joined point! //show progress bar @@ -165,12 +165,12 @@ void BattleGroundEY::CheckSomeoneLeftPoint() //reset current point counts for (uint8 i = 0; i < 2*BG_EY_NODES_MAX; ++i) m_CurrentPointPlayersCount[i] = 0; - for(uint8 i = 0; i < BG_EY_NODES_MAX; ++i) + for (uint8 i = 0; i < BG_EY_NODES_MAX; ++i) { uint8 j = 0; while (j < m_PlayersNearPoint[i].size()) { - Player *plr = sObjectMgr.GetPlayer(m_PlayersNearPoint[i][j]); + Player* plr = sObjectMgr.GetPlayer(m_PlayersNearPoint[i][j]); if (!plr) { sLog.outError("BattleGroundEY:CheckSomeoneLeftPoint %s not found!", m_PlayersNearPoint[i][j].GetString().c_str()); @@ -181,7 +181,7 @@ void BattleGroundEY::CheckSomeoneLeftPoint() continue; } if (!plr->CanUseCapturePoint() || - !plr->IsWithinDist3d(BG_EY_NodePositions[i][0], BG_EY_NodePositions[i][1], BG_EY_NodePositions[i][2], BG_EY_POINT_RADIUS)) + !plr->IsWithinDist3d(BG_EY_NodePositions[i][0], BG_EY_NodePositions[i][1], BG_EY_NodePositions[i][2], BG_EY_POINT_RADIUS)) //move player out of point (add him to players that are out of points { m_PlayersNearPoint[BG_EY_PLAYERS_OUT_OF_POINTS].push_back(m_PlayersNearPoint[i][j]); @@ -200,7 +200,7 @@ void BattleGroundEY::CheckSomeoneLeftPoint() void BattleGroundEY::UpdatePointStatuses() { - for(uint8 point = 0; point < BG_EY_NODES_MAX; ++point) + for (uint8 point = 0; point < BG_EY_NODES_MAX; ++point) { if (m_PlayersNearPoint[point].empty()) continue; @@ -225,10 +225,10 @@ void BattleGroundEY::UpdatePointStatuses() for (uint8 i = 0; i < m_PlayersNearPoint[point].size(); ++i) { - if (Player *plr = sObjectMgr.GetPlayer(m_PlayersNearPoint[point][i])) + if (Player* plr = sObjectMgr.GetPlayer(m_PlayersNearPoint[point][i])) { UpdateWorldStateForPlayer(PROGRESS_BAR_STATUS, m_PointBarStatus[point], plr); - //if point owner changed we must evoke event! + //if point owner changed we must evoke event! if (pointOwnerTeamId != m_PointOwnedByTeam[point]) { //point was uncontrolled and player is from team which captured point @@ -303,7 +303,7 @@ void BattleGroundEY::UpdatePointsIcons(Team team, uint32 Point) } } -void BattleGroundEY::AddPlayer(Player *plr) +void BattleGroundEY::AddPlayer(Player* plr) { BattleGround::AddPlayer(plr); //create score and add it to map @@ -314,12 +314,12 @@ void BattleGroundEY::AddPlayer(Player *plr) m_PlayerScores[plr->GetObjectGuid()] = sc; } -void BattleGroundEY::RemovePlayer(Player *plr, ObjectGuid guid) +void BattleGroundEY::RemovePlayer(Player* plr, ObjectGuid guid) { // sometimes flag aura not removed :( for (int j = BG_EY_NODES_MAX; j >= 0; --j) { - for(size_t i = 0; i < m_PlayersNearPoint[j].size(); ++i) + for (size_t i = 0; i < m_PlayersNearPoint[j].size(); ++i) if (m_PlayersNearPoint[j][i] == guid) m_PlayersNearPoint[j].erase(m_PlayersNearPoint[j].begin() + i); } @@ -338,15 +338,15 @@ void BattleGroundEY::RemovePlayer(Player *plr, ObjectGuid guid) } } -void BattleGroundEY::HandleAreaTrigger(Player *Source, uint32 Trigger) +void BattleGroundEY::HandleAreaTrigger(Player* Source, uint32 Trigger) { if (GetStatus() != STATUS_IN_PROGRESS) return; - if(!Source->isAlive()) //hack code, must be removed later + if (!Source->isAlive()) //hack code, must be removed later return; - switch(Trigger) + switch (Trigger) { case TR_BLOOD_ELF_POINT: if (m_PointState[BG_EY_NODE_BLOOD_ELF] == EY_POINT_UNDER_CONTROL && m_PointOwnedByTeam[BG_EY_NODE_BLOOD_ELF] == Source->GetTeam()) @@ -399,9 +399,9 @@ bool BattleGroundEY::SetupBattleGround() continue; } if (!AddObject(BG_EY_OBJECT_SPEEDBUFF_FEL_REAVER + i * 3, Buff_Entries[0], at->x, at->y, at->z, 0.907571f, 0, 0, 0.438371f, 0.898794f, RESPAWN_ONE_DAY) - || !AddObject(BG_EY_OBJECT_SPEEDBUFF_FEL_REAVER + i * 3 + 1, Buff_Entries[1], at->x, at->y, at->z, 0.907571f, 0, 0, 0.438371f, 0.898794f, RESPAWN_ONE_DAY) - || !AddObject(BG_EY_OBJECT_SPEEDBUFF_FEL_REAVER + i * 3 + 2, Buff_Entries[2], at->x, at->y, at->z, 0.907571f, 0, 0, 0.438371f, 0.898794f, RESPAWN_ONE_DAY) - ) + || !AddObject(BG_EY_OBJECT_SPEEDBUFF_FEL_REAVER + i * 3 + 1, Buff_Entries[1], at->x, at->y, at->z, 0.907571f, 0, 0, 0.438371f, 0.898794f, RESPAWN_ONE_DAY) + || !AddObject(BG_EY_OBJECT_SPEEDBUFF_FEL_REAVER + i * 3 + 2, Buff_Entries[2], at->x, at->y, at->z, 0.907571f, 0, 0, 0.438371f, 0.898794f, RESPAWN_ONE_DAY) + ) sLog.outError("BattleGroundEY: Cannot spawn buff"); } @@ -427,7 +427,7 @@ void BattleGroundEY::Reset() bool isBGWeekend = BattleGroundMgr::IsBGWeekend(GetTypeID()); m_HonorTics = (isBGWeekend) ? BG_EY_EYWeekendHonorTicks : BG_EY_NotEYWeekendHonorTicks; - for(uint8 i = 0; i < BG_EY_NODES_MAX; ++i) + for (uint8 i = 0; i < BG_EY_NODES_MAX; ++i) { m_PointOwnedByTeam[i] = TEAM_NONE; m_PointState[i] = EY_POINT_STATE_UNCONTROLLED; @@ -462,7 +462,7 @@ void BattleGroundEY::RespawnFlagAfterDrop() { RespawnFlag(true); - GameObject *obj = GetBgMap()->GetGameObject(GetDroppedFlagGuid()); + GameObject* obj = GetBgMap()->GetGameObject(GetDroppedFlagGuid()); if (obj) obj->Delete(); else @@ -471,7 +471,7 @@ void BattleGroundEY::RespawnFlagAfterDrop() ClearDroppedFlagGuid(); } -void BattleGroundEY::HandleKillPlayer(Player *player, Player *killer) +void BattleGroundEY::HandleKillPlayer(Player* player, Player* killer) { if (GetStatus() != STATUS_IN_PROGRESS) return; @@ -480,7 +480,7 @@ void BattleGroundEY::HandleKillPlayer(Player *player, Player *killer) EventPlayerDroppedFlag(player); } -void BattleGroundEY::EventPlayerDroppedFlag(Player *Source) +void BattleGroundEY::EventPlayerDroppedFlag(Player* Source) { if (GetStatus() != STATUS_IN_PROGRESS) { @@ -516,7 +516,7 @@ void BattleGroundEY::EventPlayerDroppedFlag(Player *Source) SendMessageToAll(LANG_BG_EY_DROPPED_FLAG, CHAT_MSG_BG_SYSTEM_HORDE, NULL); } -void BattleGroundEY::EventPlayerClickedOnFlag(Player *Source, GameObject* target_obj) +void BattleGroundEY::EventPlayerClickedOnFlag(Player* Source, GameObject* target_obj) { if (GetStatus() != STATUS_IN_PROGRESS || IsFlagPickedup() || !Source->IsWithinDistInMap(target_obj, 10)) return; @@ -550,7 +550,7 @@ void BattleGroundEY::EventPlayerClickedOnFlag(Player *Source, GameObject* target PSendMessageToAll(LANG_BG_EY_HAS_TAKEN_FLAG, CHAT_MSG_BG_SYSTEM_HORDE, NULL, Source->GetName()); } -void BattleGroundEY::EventTeamLostPoint(Player *Source, uint32 Point) +void BattleGroundEY::EventTeamLostPoint(Player* Source, uint32 Point) { if (GetStatus() != STATUS_IN_PROGRESS) return; @@ -584,7 +584,7 @@ void BattleGroundEY::EventTeamLostPoint(Player *Source, uint32 Point) UpdatePointsCount(team); } -void BattleGroundEY::EventTeamCapturedPoint(Player *Source, uint32 Point) +void BattleGroundEY::EventTeamCapturedPoint(Player* Source, uint32 Point) { if (GetStatus() != STATUS_IN_PROGRESS) return; @@ -608,7 +608,7 @@ void BattleGroundEY::EventTeamCapturedPoint(Player *Source, uint32 Point) UpdatePointsCount(team); } -void BattleGroundEY::EventPlayerCapturedFlag(Player *Source, BG_EY_Nodes node) +void BattleGroundEY::EventPlayerCapturedFlag(Player* Source, BG_EY_Nodes node) { if (GetStatus() != STATUS_IN_PROGRESS || GetFlagPickerGuid() != Source->GetObjectGuid()) return; @@ -646,13 +646,13 @@ void BattleGroundEY::EventPlayerCapturedFlag(Player *Source, BG_EY_Nodes node) UpdatePlayerScore(Source, SCORE_FLAG_CAPTURES, 1); } -void BattleGroundEY::UpdatePlayerScore(Player *Source, uint32 type, uint32 value) +void BattleGroundEY::UpdatePlayerScore(Player* Source, uint32 type, uint32 value) { BattleGroundScoreMap::iterator itr = m_PlayerScores.find(Source->GetObjectGuid()); - if(itr == m_PlayerScores.end()) // player not found + if (itr == m_PlayerScores.end()) // player not found return; - switch(type) + switch (type) { case SCORE_FLAG_CAPTURES: // flags captured ((BattleGroundEYScore*)itr->second)->FlagCaptures += value; @@ -700,11 +700,11 @@ void BattleGroundEY::FillInitialWorldStates(WorldPacket& data, uint32& count) FillInitialWorldState(data, count, 0xc0d, 0x17b); } -WorldSafeLocsEntry const *BattleGroundEY::GetClosestGraveYard(Player* player) +WorldSafeLocsEntry const* BattleGroundEY::GetClosestGraveYard(Player* player) { uint32 g_id = 0; - switch(player->GetTeam()) + switch (player->GetTeam()) { case ALLIANCE: g_id = EY_GRAVEYARD_MAIN_ALLIANCE; break; case HORDE: g_id = EY_GRAVEYARD_MAIN_HORDE; break; @@ -732,7 +732,7 @@ WorldSafeLocsEntry const *BattleGroundEY::GetClosestGraveYard(Player* player) distance = (entry->x - plr_x)*(entry->x - plr_x) + (entry->y - plr_y)*(entry->y - plr_y) + (entry->z - plr_z)*(entry->z - plr_z); nearestDistance = distance; - for(uint8 i = 0; i < BG_EY_NODES_MAX; ++i) + for (uint8 i = 0; i < BG_EY_NODES_MAX; ++i) { if (m_PointOwnedByTeam[i]==player->GetTeam() && m_PointState[i]==EY_POINT_UNDER_CONTROL) { @@ -756,7 +756,7 @@ WorldSafeLocsEntry const *BattleGroundEY::GetClosestGraveYard(Player* player) bool BattleGroundEY::IsAllNodesConrolledByTeam(Team team) const { - for(int i = 0; i < BG_EY_NODES_MAX; ++i) + for (int i = 0; i < BG_EY_NODES_MAX; ++i) if (m_PointState[i] != EY_POINT_UNDER_CONTROL || m_PointOwnedByTeam[i] != team) return false; diff --git a/src/game/BattleGroundEY.h b/src/game/BattleGroundEY.h index 0ac6e3c1d..5d8d708b7 100644 --- a/src/game/BattleGroundEY.h +++ b/src/game/BattleGroundEY.h @@ -127,7 +127,8 @@ enum BG_EY_Nodes // x, y, z // used to check, when player is in range of a node -const float BG_EY_NodePositions[BG_EY_NODES_MAX][3] = { +const float BG_EY_NodePositions[BG_EY_NODES_MAX][3] = +{ {2024.600708f, 1742.819580f, 1195.157715f}, // BG_EY_NODE_FEL_REAVER {2050.493164f, 1372.235962f, 1194.563477f}, // BG_EY_NODE_BLOOD_ELF {2301.010498f, 1386.931641f, 1197.183472f}, // BG_EY_NODE_DRAENEI_RUINS @@ -235,14 +236,14 @@ const BattleGroundEYCapturingPointStruct CapturingPointTypes[BG_EY_NODES_MAX] = class BattleGroundEYScore : public BattleGroundScore { public: - BattleGroundEYScore () : FlagCaptures(0) {}; + BattleGroundEYScore() : FlagCaptures(0) {}; virtual ~BattleGroundEYScore() {}; uint32 FlagCaptures; }; class BattleGroundEY : public BattleGround { - friend class BattleGroundMgr; + friend class BattleGroundMgr; public: BattleGroundEY(); @@ -250,7 +251,7 @@ class BattleGroundEY : public BattleGround void Update(uint32 diff); /* inherited from BattlegroundClass */ - virtual void AddPlayer(Player *plr); + virtual void AddPlayer(Player* plr); virtual void StartingEventCloseDoors(); virtual void StartingEventOpenDoors(); @@ -263,31 +264,31 @@ class BattleGroundEY : public BattleGround void RespawnFlag(bool send_message); void RespawnFlagAfterDrop(); - void RemovePlayer(Player *plr, ObjectGuid guid); - void HandleAreaTrigger(Player *Source, uint32 Trigger); - void HandleKillPlayer(Player *player, Player *killer); + void RemovePlayer(Player* plr, ObjectGuid guid); + void HandleAreaTrigger(Player* Source, uint32 Trigger); + void HandleKillPlayer(Player* player, Player* killer); virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* player); virtual bool SetupBattleGround(); virtual void Reset(); void UpdateTeamScore(Team team); void EndBattleGround(Team winner); - void UpdatePlayerScore(Player *Source, uint32 type, uint32 value); + void UpdatePlayerScore(Player* Source, uint32 type, uint32 value); virtual void FillInitialWorldStates(WorldPacket& data, uint32& count); void SetDroppedFlagGuid(ObjectGuid guid) { m_DroppedFlagGuid = guid;} void ClearDroppedFlagGuid() { m_DroppedFlagGuid.Clear();} ObjectGuid const& GetDroppedFlagGuid() const { return m_DroppedFlagGuid;} /* Battleground Events */ - virtual void EventPlayerClickedOnFlag(Player *Source, GameObject* target_obj); - virtual void EventPlayerDroppedFlag(Player *Source); + virtual void EventPlayerClickedOnFlag(Player* Source, GameObject* target_obj); + virtual void EventPlayerDroppedFlag(Player* Source); /* achievement req. */ bool IsAllNodesConrolledByTeam(Team team) const; private: - void EventPlayerCapturedFlag(Player *Source, BG_EY_Nodes node); - void EventTeamCapturedPoint(Player *Source, uint32 Point); - void EventTeamLostPoint(Player *Source, uint32 Point); + void EventPlayerCapturedFlag(Player* Source, BG_EY_Nodes node); + void EventTeamCapturedPoint(Player* Source, uint32 Point); + void EventTeamLostPoint(Player* Source, uint32 Point); void UpdatePointsCount(Team team); void UpdatePointsIcons(Team team, uint32 Point); diff --git a/src/game/BattleGroundHandler.cpp b/src/game/BattleGroundHandler.cpp index f44e9f9c4..23b21716d 100644 --- a/src/game/BattleGroundHandler.cpp +++ b/src/game/BattleGroundHandler.cpp @@ -34,14 +34,14 @@ #include "ScriptMgr.h" #include "World.h" -void WorldSession::HandleBattlemasterHelloOpcode(WorldPacket & recv_data) +void WorldSession::HandleBattlemasterHelloOpcode(WorldPacket& recv_data) { ObjectGuid guid; recv_data >> guid; DEBUG_LOG("WORLD: Recvd CMSG_BATTLEMASTER_HELLO Message from %s", guid.GetString().c_str()); - Creature *pCreature = GetPlayer()->GetMap()->GetCreature(guid); + Creature* pCreature = GetPlayer()->GetMap()->GetCreature(guid); if (!pCreature) return; @@ -68,21 +68,21 @@ void WorldSession::HandleBattlemasterHelloOpcode(WorldPacket & recv_data) SendBattlegGroundList(guid, bgTypeId); } -void WorldSession::SendBattlegGroundList( ObjectGuid guid, BattleGroundTypeId bgTypeId ) +void WorldSession::SendBattlegGroundList(ObjectGuid guid, BattleGroundTypeId bgTypeId) { WorldPacket data; sBattleGroundMgr.BuildBattleGroundListPacket(&data, guid, _player, bgTypeId, 0); - SendPacket( &data ); + SendPacket(&data); } -void WorldSession::HandleBattlemasterJoinOpcode( WorldPacket & recv_data ) +void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket& recv_data) { ObjectGuid guid; uint32 bgTypeId_; uint32 instanceId; uint8 joinAsGroup; bool isPremade = false; - Group * grp; + Group* grp; recv_data >> guid; // battlemaster guid recv_data >> bgTypeId_; // battleground type id (DBC id) @@ -97,7 +97,7 @@ void WorldSession::HandleBattlemasterJoinOpcode( WorldPacket & recv_data ) BattleGroundTypeId bgTypeId = BattleGroundTypeId(bgTypeId_); - DEBUG_LOG( "WORLD: Recvd CMSG_BATTLEMASTER_JOIN Message from %s", guid.GetString().c_str()); + DEBUG_LOG("WORLD: Recvd CMSG_BATTLEMASTER_JOIN Message from %s", guid.GetString().c_str()); // can do this, since it's battleground, not arena BattleGroundQueueTypeId bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(bgTypeId, ARENA_TYPE_NONE); @@ -107,7 +107,7 @@ void WorldSession::HandleBattlemasterJoinOpcode( WorldPacket & recv_data ) return; // get bg instance or bg template if instance not found - BattleGround *bg = NULL; + BattleGround* bg = NULL; if (instanceId) bg = sBattleGroundMgr.GetBattleGroundThroughClientInstance(instanceId, bgTypeId); @@ -153,7 +153,7 @@ void WorldSession::HandleBattlemasterJoinOpcode( WorldPacket & recv_data ) return; err = grp->CanJoinBattleGroundQueue(bg, bgQueueTypeId, 0, bg->GetMaxPlayersPerTeam(), false, 0); isPremade = sWorld.getConfig(CONFIG_UINT32_BATTLEGROUND_PREMADE_GROUP_WAIT_FOR_MATCH) && - (grp->GetMembersCount() >= bg->GetMinPlayersPerTeam()); + (grp->GetMembersCount() >= bg->GetMinPlayersPerTeam()); } // if we're here, then the conditions to join a bg are met. We can proceed in joining. @@ -164,22 +164,22 @@ void WorldSession::HandleBattlemasterJoinOpcode( WorldPacket & recv_data ) GroupQueueInfo* ginfo = NULL; uint32 avgTime = 0; - if(err > 0) + if (err > 0) { DEBUG_LOG("Battleground: the following players are joining as group:"); ginfo = bgQueue.AddGroup(_player, grp, bgTypeId, bracketEntry, ARENA_TYPE_NONE, false, isPremade, 0); avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, bracketEntry->GetBracketId()); } - for(GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next()) + for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next()) { - Player *member = itr->getSource(); - if(!member) + Player* member = itr->getSource(); + if (!member) continue; // this should never happen WorldPacket data; - if(err <= 0) + if (err <= 0) { sBattleGroundMgr.BuildGroupJoinedBattlegroundPacket(&data, err); member->GetSession()->SendPacket(&data); @@ -200,13 +200,13 @@ void WorldSession::HandleBattlemasterJoinOpcode( WorldPacket & recv_data ) } else { - GroupQueueInfo * ginfo = bgQueue.AddGroup(_player, NULL, bgTypeId, bracketEntry, ARENA_TYPE_NONE, false, isPremade, 0); + GroupQueueInfo* ginfo = bgQueue.AddGroup(_player, NULL, bgTypeId, bracketEntry, ARENA_TYPE_NONE, false, isPremade, 0); uint32 avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, bracketEntry->GetBracketId()); // already checked if queueSlot is valid, now just get it uint32 queueSlot = _player->AddBattleGroundQueueId(bgQueueTypeId); WorldPacket data; - // send status packet (in queue) + // send status packet (in queue) sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_QUEUE, avgTime, 0, ginfo->arenaType); SendPacket(&data); DEBUG_LOG("Battleground: player joined queue for bg queue type %u bg type %u: GUID %u, NAME %s",bgQueueTypeId,bgTypeId,_player->GetGUIDLow(), _player->GetName()); @@ -214,79 +214,79 @@ void WorldSession::HandleBattlemasterJoinOpcode( WorldPacket & recv_data ) sBattleGroundMgr.ScheduleQueueUpdate(0, ARENA_TYPE_NONE, bgQueueTypeId, bgTypeId, bracketEntry->GetBracketId()); } -void WorldSession::HandleBattleGroundPlayerPositionsOpcode( WorldPacket & /*recv_data*/ ) +void WorldSession::HandleBattleGroundPlayerPositionsOpcode(WorldPacket& /*recv_data*/) { - // empty opcode + // empty opcode DEBUG_LOG("WORLD: Recvd MSG_BATTLEGROUND_PLAYER_POSITIONS Message"); - BattleGround *bg = _player->GetBattleGround(); - if(!bg) // can't be received if player not in battleground + BattleGround* bg = _player->GetBattleGround(); + if (!bg) // can't be received if player not in battleground return; - switch( bg->GetTypeID() ) + switch (bg->GetTypeID()) { case BATTLEGROUND_WS: + { + uint32 count1 = 0; // always constant zero? + uint32 count2 = 0; // count of next fields + + Player* ali_plr = sObjectMgr.GetPlayer(((BattleGroundWS*)bg)->GetAllianceFlagPickerGuid()); + if (ali_plr) + ++count2; + + Player* horde_plr = sObjectMgr.GetPlayer(((BattleGroundWS*)bg)->GetHordeFlagPickerGuid()); + if (horde_plr) + ++count2; + + WorldPacket data(MSG_BATTLEGROUND_PLAYER_POSITIONS, (4+4+16*count1+16*count2)); + data << count1; // alliance flag holders count - obsolete, now always 0 + /*for(uint8 i = 0; i < count1; ++i) { - uint32 count1 = 0; // always constant zero? - uint32 count2 = 0; // count of next fields - - Player *ali_plr = sObjectMgr.GetPlayer(((BattleGroundWS*)bg)->GetAllianceFlagPickerGuid()); - if (ali_plr) - ++count2; - - Player *horde_plr = sObjectMgr.GetPlayer(((BattleGroundWS*)bg)->GetHordeFlagPickerGuid()); - if (horde_plr) - ++count2; - - WorldPacket data(MSG_BATTLEGROUND_PLAYER_POSITIONS, (4+4+16*count1+16*count2)); - data << count1; // alliance flag holders count - obsolete, now always 0 - /*for(uint8 i = 0; i < count1; ++i) - { - data << ObjectGuid(0); // guid - data << (float)0; // x - data << (float)0; // y - }*/ - data << count2; // horde flag holders count - obsolete, now count of next fields - if (ali_plr) - { - data << ObjectGuid(ali_plr->GetObjectGuid()); - data << float(ali_plr->GetPositionX()); - data << float(ali_plr->GetPositionY()); - } - if (horde_plr) - { - data << ObjectGuid(horde_plr->GetObjectGuid()); - data << float(horde_plr->GetPositionX()); - data << float(horde_plr->GetPositionY()); - } - - SendPacket(&data); + data << ObjectGuid(0); // guid + data << (float)0; // x + data << (float)0; // y + }*/ + data << count2; // horde flag holders count - obsolete, now count of next fields + if (ali_plr) + { + data << ObjectGuid(ali_plr->GetObjectGuid()); + data << float(ali_plr->GetPositionX()); + data << float(ali_plr->GetPositionY()); } - break; + if (horde_plr) + { + data << ObjectGuid(horde_plr->GetObjectGuid()); + data << float(horde_plr->GetPositionX()); + data << float(horde_plr->GetPositionY()); + } + + SendPacket(&data); + } + break; case BATTLEGROUND_EY: //TODO : fix me! break; case BATTLEGROUND_AB: case BATTLEGROUND_AV: - { - //for other BG types - send default - WorldPacket data(MSG_BATTLEGROUND_PLAYER_POSITIONS, (4+4)); - data << uint32(0); - data << uint32(0); - SendPacket(&data); - } - break; + { + //for other BG types - send default + WorldPacket data(MSG_BATTLEGROUND_PLAYER_POSITIONS, (4+4)); + data << uint32(0); + data << uint32(0); + SendPacket(&data); + } + break; default: //maybe it is sent also in arena - do nothing break; } } -void WorldSession::HandlePVPLogDataOpcode( WorldPacket & /*recv_data*/ ) +void WorldSession::HandlePVPLogDataOpcode(WorldPacket& /*recv_data*/) { - DEBUG_LOG( "WORLD: Recvd MSG_PVP_LOG_DATA Message"); + DEBUG_LOG("WORLD: Recvd MSG_PVP_LOG_DATA Message"); - BattleGround *bg = _player->GetBattleGround(); + BattleGround* bg = _player->GetBattleGround(); if (!bg) return; @@ -298,12 +298,12 @@ void WorldSession::HandlePVPLogDataOpcode( WorldPacket & /*recv_data*/ ) sBattleGroundMgr.BuildPvpLogDataPacket(&data, bg); SendPacket(&data); - DEBUG_LOG( "WORLD: Sent MSG_PVP_LOG_DATA Message"); + DEBUG_LOG("WORLD: Sent MSG_PVP_LOG_DATA Message"); } -void WorldSession::HandleBattlefieldListOpcode( WorldPacket &recv_data ) +void WorldSession::HandleBattlefieldListOpcode(WorldPacket& recv_data) { - DEBUG_LOG( "WORLD: Recvd CMSG_BATTLEFIELD_LIST Message"); + DEBUG_LOG("WORLD: Recvd CMSG_BATTLEFIELD_LIST Message"); uint32 bgTypeId; recv_data >> bgTypeId; // id from DBC @@ -323,12 +323,12 @@ void WorldSession::HandleBattlefieldListOpcode( WorldPacket &recv_data ) WorldPacket data; sBattleGroundMgr.BuildBattleGroundListPacket(&data, ObjectGuid(), _player, BattleGroundTypeId(bgTypeId), fromWhere); - SendPacket( &data ); + SendPacket(&data); } -void WorldSession::HandleBattleFieldPortOpcode( WorldPacket &recv_data ) +void WorldSession::HandleBattleFieldPortOpcode(WorldPacket& recv_data) { - DEBUG_LOG( "WORLD: Recvd CMSG_BATTLEFIELD_PORT Message"); + DEBUG_LOG("WORLD: Recvd CMSG_BATTLEFIELD_PORT Message"); uint8 type; // arenatype if arena uint8 unk2; // unk, can be 0x0 (may be if was invited?) and 0x1 @@ -374,7 +374,7 @@ void WorldSession::HandleBattleFieldPortOpcode( WorldPacket &recv_data ) return; } - BattleGround *bg = sBattleGroundMgr.GetBattleGround(ginfo.IsInvitedToBGInstanceGUID, bgTypeId); + BattleGround* bg = sBattleGroundMgr.GetBattleGround(ginfo.IsInvitedToBGInstanceGUID, bgTypeId); // bg template might and must be used in case of leaving queue, when instance is not created yet if (!bg && action == 0) @@ -407,13 +407,13 @@ void WorldSession::HandleBattleFieldPortOpcode( WorldPacket &recv_data ) if (_player->getLevel() > bg->GetMaxLevel()) { sLog.outError("Battleground: Player %s (%u) has level (%u) higher than maxlevel (%u) of battleground (%u)! Do not port him to battleground!", - _player->GetName(), _player->GetGUIDLow(), _player->getLevel(), bg->GetMaxLevel(), bg->GetTypeID()); + _player->GetName(), _player->GetGUIDLow(), _player->getLevel(), bg->GetMaxLevel(), bg->GetTypeID()); action = 0; } } uint32 queueSlot = _player->GetBattleGroundQueueIndex(bgQueueTypeId); WorldPacket data; - switch( action ) + switch (action) { case 1: // port to battleground if (!_player->IsInvitedForBattleGroundQueueType(bgQueueTypeId)) @@ -441,7 +441,7 @@ void WorldSession::HandleBattleFieldPortOpcode( WorldPacket &recv_data ) bgQueue.RemovePlayer(_player->GetObjectGuid(), false); // this is still needed here if battleground "jumping" shouldn't add deserter debuff // also this is required to prevent stuck at old battleground after SetBattleGroundId set to new - if (BattleGround *currentBg = _player->GetBattleGround()) + if (BattleGround* currentBg = _player->GetBattleGround()) currentBg->RemovePlayerAtLeave(_player->GetObjectGuid(), false, true); // set the destination instance id @@ -458,7 +458,7 @@ void WorldSession::HandleBattleFieldPortOpcode( WorldPacket &recv_data ) // if player leaves rated arena match before match start, it is counted as he played but he lost if (ginfo.IsRated && ginfo.IsInvitedToBGInstanceGUID) { - ArenaTeam * at = sObjectMgr.GetArenaTeamById(ginfo.ArenaTeamId); + ArenaTeam* at = sObjectMgr.GetArenaTeamById(ginfo.ArenaTeamId); if (at) { DEBUG_LOG("UPDATING memberLost's personal arena rating for %s by opponents rating: %u, because he has left queue!", _player->GetGuidStr().c_str(), ginfo.OpponentsTeamRating); @@ -481,9 +481,9 @@ void WorldSession::HandleBattleFieldPortOpcode( WorldPacket &recv_data ) } } -void WorldSession::HandleLeaveBattlefieldOpcode( WorldPacket& recv_data ) +void WorldSession::HandleLeaveBattlefieldOpcode(WorldPacket& recv_data) { - DEBUG_LOG( "WORLD: Recvd CMSG_LEAVE_BATTLEFIELD Message"); + DEBUG_LOG("WORLD: Recvd CMSG_LEAVE_BATTLEFIELD Message"); recv_data.read_skip(); // unk1 recv_data.read_skip(); // unk2 @@ -502,14 +502,14 @@ void WorldSession::HandleLeaveBattlefieldOpcode( WorldPacket& recv_data ) _player->LeaveBattleground(); } -void WorldSession::HandleBattlefieldStatusOpcode( WorldPacket & /*recv_data*/ ) +void WorldSession::HandleBattlefieldStatusOpcode(WorldPacket& /*recv_data*/) { // empty opcode - DEBUG_LOG( "WORLD: Battleground status" ); + DEBUG_LOG("WORLD: Battleground status"); WorldPacket data; // we must update all queues here - BattleGround *bg = NULL; + BattleGround* bg = NULL; for (uint8 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) { BattleGroundQueueTypeId bgQueueTypeId = _player->GetBattleGroundQueueTypeId(i); @@ -567,49 +567,49 @@ void WorldSession::HandleBattlefieldStatusOpcode( WorldPacket & /*recv_data*/ ) } } -void WorldSession::HandleAreaSpiritHealerQueryOpcode( WorldPacket & recv_data ) +void WorldSession::HandleAreaSpiritHealerQueryOpcode(WorldPacket& recv_data) { DEBUG_LOG("WORLD: CMSG_AREA_SPIRIT_HEALER_QUERY"); - BattleGround *bg = _player->GetBattleGround(); + BattleGround* bg = _player->GetBattleGround(); if (!bg) return; ObjectGuid guid; recv_data >> guid; - Creature *unit = GetPlayer()->GetMap()->GetCreature(guid); + Creature* unit = GetPlayer()->GetMap()->GetCreature(guid); if (!unit) return; - if(!unit->isSpiritService()) // it's not spirit service + if (!unit->isSpiritService()) // it's not spirit service return; unit->SendAreaSpiritHealerQueryOpcode(GetPlayer()); } -void WorldSession::HandleAreaSpiritHealerQueueOpcode( WorldPacket & recv_data ) +void WorldSession::HandleAreaSpiritHealerQueueOpcode(WorldPacket& recv_data) { DEBUG_LOG("WORLD: CMSG_AREA_SPIRIT_HEALER_QUEUE"); - BattleGround *bg = _player->GetBattleGround(); + BattleGround* bg = _player->GetBattleGround(); if (!bg) return; ObjectGuid guid; recv_data >> guid; - Creature *unit = GetPlayer()->GetMap()->GetCreature(guid); + Creature* unit = GetPlayer()->GetMap()->GetCreature(guid); if (!unit) return; - if(!unit->isSpiritService()) // it's not spirit service + if (!unit->isSpiritService()) // it's not spirit service return; sScriptMgr.OnGossipHello(GetPlayer(), unit); } -void WorldSession::HandleBattlemasterJoinArena( WorldPacket & recv_data ) +void WorldSession::HandleBattlemasterJoinArena(WorldPacket& recv_data) { DEBUG_LOG("WORLD: CMSG_BATTLEMASTER_JOIN_ARENA"); //recv_data.hexlike(); @@ -625,17 +625,17 @@ void WorldSession::HandleBattlemasterJoinArena( WorldPacket & recv_data ) if (_player->InBattleGround()) return; - Creature *unit = GetPlayer()->GetMap()->GetCreature(guid); + Creature* unit = GetPlayer()->GetMap()->GetCreature(guid); if (!unit) return; - if(!unit->isBattleMaster()) // it's not battle master + if (!unit->isBattleMaster()) // it's not battle master return; ArenaType arenatype; uint32 arenaRating = 0; - switch(arenaslot) + switch (arenaslot) { case 0: arenatype = ARENA_TYPE_2v2; @@ -667,7 +667,7 @@ void WorldSession::HandleBattlemasterJoinArena( WorldPacket & recv_data ) GroupJoinBattlegroundResult err; - Group * grp = NULL; + Group* grp = NULL; // check queue conditions if (!asGroup) @@ -702,7 +702,7 @@ void WorldSession::HandleBattlemasterJoinArena( WorldPacket & recv_data ) { ateamId = _player->GetArenaTeamId(arenaslot); // check real arena team existence only here (if it was moved to group->CanJoin .. () then we would have to get it twice) - ArenaTeam * at = sObjectMgr.GetArenaTeamById(ateamId); + ArenaTeam* at = sObjectMgr.GetArenaTeamById(ateamId); if (!at) { _player->GetSession()->SendNotInArenaTeamPacket(arenatype); @@ -714,7 +714,7 @@ void WorldSession::HandleBattlemasterJoinArena( WorldPacket & recv_data ) // get the personal ratings for queue uint32 avg_pers_rating = 0; - for(Group::member_citerator citr = grp->GetMemberSlots().begin(); citr != grp->GetMemberSlots().end(); ++citr) + for (Group::member_citerator citr = grp->GetMemberSlots().begin(); citr != grp->GetMemberSlots().end(); ++citr) { ArenaTeamMember const* at_member = at->GetMember(citr->guid); if (!at_member) // group member joining to arena must be in leader arena team @@ -731,30 +731,30 @@ void WorldSession::HandleBattlemasterJoinArena( WorldPacket & recv_data ) arenaRating = avg_pers_rating; } - BattleGroundQueue &bgQueue = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId]; + BattleGroundQueue& bgQueue = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId]; if (asGroup) { uint32 avgTime = 0; - if(err > 0) + if (err > 0) { DEBUG_LOG("Battleground: arena join as group start"); if (isRated) DEBUG_LOG("Battleground: arena team id %u, leader %s queued with rating %u for type %u",_player->GetArenaTeamId(arenaslot),_player->GetName(),arenaRating,arenatype); - GroupQueueInfo * ginfo = bgQueue.AddGroup(_player, grp, bgTypeId, bracketEntry, arenatype, isRated, false, arenaRating, ateamId); + GroupQueueInfo* ginfo = bgQueue.AddGroup(_player, grp, bgTypeId, bracketEntry, arenatype, isRated, false, arenaRating, ateamId); avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, bracketEntry->GetBracketId()); } - for(GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next()) + for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next()) { - Player *member = itr->getSource(); - if(!member) + Player* member = itr->getSource(); + if (!member) continue; WorldPacket data; - if(err <= 0) + if (err <= 0) { sBattleGroundMgr.BuildGroupJoinedBattlegroundPacket(&data, err); member->GetSession()->SendPacket(&data); @@ -775,7 +775,7 @@ void WorldSession::HandleBattlemasterJoinArena( WorldPacket & recv_data ) } else { - GroupQueueInfo * ginfo = bgQueue.AddGroup(_player, NULL, bgTypeId, bracketEntry, arenatype, isRated, false, arenaRating, ateamId); + GroupQueueInfo* ginfo = bgQueue.AddGroup(_player, NULL, bgTypeId, bracketEntry, arenatype, isRated, false, arenaRating, ateamId); uint32 avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, bracketEntry->GetBracketId()); uint32 queueSlot = _player->AddBattleGroundQueueId(bgQueueTypeId); @@ -788,11 +788,11 @@ void WorldSession::HandleBattlemasterJoinArena( WorldPacket & recv_data ) sBattleGroundMgr.ScheduleQueueUpdate(arenaRating, arenatype, bgQueueTypeId, bgTypeId, bracketEntry->GetBracketId()); } -void WorldSession::HandleReportPvPAFK( WorldPacket & recv_data ) +void WorldSession::HandleReportPvPAFK(WorldPacket& recv_data) { ObjectGuid playerGuid; recv_data >> playerGuid; - Player *reportedPlayer = sObjectMgr.GetPlayer(playerGuid); + Player* reportedPlayer = sObjectMgr.GetPlayer(playerGuid); if (!reportedPlayer) { diff --git a/src/game/BattleGroundIC.cpp b/src/game/BattleGroundIC.cpp index d84e7a9ee..8cc2873c9 100644 --- a/src/game/BattleGroundIC.cpp +++ b/src/game/BattleGroundIC.cpp @@ -48,7 +48,7 @@ void BattleGroundIC::StartingEventOpenDoors() { } -void BattleGroundIC::AddPlayer(Player *plr) +void BattleGroundIC::AddPlayer(Player* plr) { BattleGround::AddPlayer(plr); //create score and add it to map, default values are set in constructor @@ -62,7 +62,7 @@ void BattleGroundIC::RemovePlayer(Player* /*plr*/, ObjectGuid /*guid*/) } -void BattleGroundIC::HandleAreaTrigger(Player * /*Source*/, uint32 /*Trigger*/) +void BattleGroundIC::HandleAreaTrigger(Player* /*Source*/, uint32 /*Trigger*/) { // this is wrong way to implement these things. On official it done by gameobject spell cast. if (GetStatus() != STATUS_IN_PROGRESS) @@ -74,7 +74,7 @@ void BattleGroundIC::UpdatePlayerScore(Player* Source, uint32 type, uint32 value BattleGroundScoreMap::iterator itr = m_PlayerScores.find(Source->GetObjectGuid()); - if(itr == m_PlayerScores.end()) // player not found... + if (itr == m_PlayerScores.end()) // player not found... return; BattleGround::UpdatePlayerScore(Source,type,value); diff --git a/src/game/BattleGroundIC.h b/src/game/BattleGroundIC.h index 4fbb7fc49..946c2e7a4 100644 --- a/src/game/BattleGroundIC.h +++ b/src/game/BattleGroundIC.h @@ -30,7 +30,7 @@ class BattleGroundICScore : public BattleGroundScore class BattleGroundIC : public BattleGround { - friend class BattleGroundMgr; + friend class BattleGroundMgr; public: BattleGroundIC(); @@ -38,16 +38,16 @@ class BattleGroundIC : public BattleGround void Update(uint32 diff); /* inherited from BattlegroundClass */ - virtual void AddPlayer(Player *plr); + virtual void AddPlayer(Player* plr); virtual void StartingEventCloseDoors(); virtual void StartingEventOpenDoors(); - void RemovePlayer(Player *plr, ObjectGuid guid); - void HandleAreaTrigger(Player *Source, uint32 Trigger); + void RemovePlayer(Player* plr, ObjectGuid guid); + void HandleAreaTrigger(Player* Source, uint32 Trigger); //bool SetupBattleGround(); /* Scorekeeping */ - void UpdatePlayerScore(Player *Source, uint32 type, uint32 value); + void UpdatePlayerScore(Player* Source, uint32 type, uint32 value); private: }; diff --git a/src/game/BattleGroundMgr.cpp b/src/game/BattleGroundMgr.cpp index 486288313..9108cc386 100644 --- a/src/game/BattleGroundMgr.cpp +++ b/src/game/BattleGroundMgr.cpp @@ -45,7 +45,7 @@ #include "Policies/SingletonImp.h" -INSTANTIATE_SINGLETON_1( BattleGroundMgr ); +INSTANTIATE_SINGLETON_1(BattleGroundMgr); /*********************************************************/ /*** BATTLEGROUND QUEUE SYSTEM ***/ @@ -53,13 +53,13 @@ INSTANTIATE_SINGLETON_1( BattleGroundMgr ); BattleGroundQueue::BattleGroundQueue() { - for(uint32 i = 0; i < BG_TEAMS_COUNT; ++i) + for (uint32 i = 0; i < BG_TEAMS_COUNT; ++i) { - for(uint32 j = 0; j < MAX_BATTLEGROUND_BRACKETS; ++j) + for (uint32 j = 0; j < MAX_BATTLEGROUND_BRACKETS; ++j) { m_SumOfWaitTimes[i][j] = 0; m_WaitTimeLastPlayer[i][j] = 0; - for(uint32 k = 0; k < COUNT_OF_PLAYERS_TO_AVERAGE_WAIT_TIME; ++k) + for (uint32 k = 0; k < COUNT_OF_PLAYERS_TO_AVERAGE_WAIT_TIME; ++k) m_WaitTimes[i][j][k] = 0; } } @@ -70,10 +70,10 @@ BattleGroundQueue::~BattleGroundQueue() m_QueuedPlayers.clear(); for (int i = 0; i < MAX_BATTLEGROUND_BRACKETS; ++i) { - for(uint32 j = 0; j < BG_QUEUE_GROUP_TYPES_COUNT; ++j) + for (uint32 j = 0; j < BG_QUEUE_GROUP_TYPES_COUNT; ++j) { - for(GroupsQueueType::iterator itr = m_QueuedGroups[i][j].begin(); itr!= m_QueuedGroups[i][j].end(); ++itr) - delete (*itr); + for (GroupsQueueType::iterator itr = m_QueuedGroups[i][j].begin(); itr!= m_QueuedGroups[i][j].end(); ++itr) + delete(*itr); m_QueuedGroups[i][j].clear(); } } @@ -127,7 +127,7 @@ bool BattleGroundQueue::SelectionPool::KickGroup(uint32 size) // used when building selection pools // returns true if we can invite more players, or when we added group to selection pool // returns false when selection pool is full -bool BattleGroundQueue::SelectionPool::AddGroup(GroupQueueInfo *ginfo, uint32 desiredCount) +bool BattleGroundQueue::SelectionPool::AddGroup(GroupQueueInfo* ginfo, uint32 desiredCount) { //if group is larger than desired count - don't allow to add it to pool if (!ginfo->IsInvitedToBGInstanceGUID && desiredCount >= PlayerCount + ginfo->Players.size()) @@ -147,7 +147,7 @@ bool BattleGroundQueue::SelectionPool::AddGroup(GroupQueueInfo *ginfo, uint32 de /*********************************************************/ // add group or player (grp == NULL) to bg queue with the given leader and bg specifications -GroupQueueInfo * BattleGroundQueue::AddGroup(Player *leader, Group* grp, BattleGroundTypeId BgTypeId, PvPDifficultyEntry const* bracketEntry, ArenaType arenaType, bool isRated, bool isPremade, uint32 arenaRating, uint32 arenateamid) +GroupQueueInfo* BattleGroundQueue::AddGroup(Player* leader, Group* grp, BattleGroundTypeId BgTypeId, PvPDifficultyEntry const* bracketEntry, ArenaType arenaType, bool isRated, bool isPremade, uint32 arenaRating, uint32 arenateamid) { BattleGroundBracketId bracketId = bracketEntry->GetBracketId(); @@ -189,10 +189,10 @@ GroupQueueInfo * BattleGroundQueue::AddGroup(Player *leader, Group* grp, BattleG //ACE_Guard guard(m_Lock); if (grp) { - for(GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next()) + for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next()) { - Player *member = itr->getSource(); - if(!member) + Player* member = itr->getSource(); + if (!member) continue; // this should never happen PlayerQueueInfo& pl_info = m_QueuedPlayers[member->GetObjectGuid()]; pl_info.LastOnlineTime = lastOnlineTime; @@ -224,10 +224,10 @@ GroupQueueInfo * BattleGroundQueue::AddGroup(Player *leader, Group* grp, BattleG uint32 q_min_level = bracketEntry->minLevel; uint32 q_max_level = bracketEntry->maxLevel; GroupsQueueType::const_iterator itr; - for(itr = m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_ALLIANCE].begin(); itr != m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_ALLIANCE].end(); ++itr) + for (itr = m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_ALLIANCE].begin(); itr != m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_ALLIANCE].end(); ++itr) if (!(*itr)->IsInvitedToBGInstanceGUID) qAlliance += (*itr)->Players.size(); - for(itr = m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_HORDE].begin(); itr != m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_HORDE].end(); ++itr) + for (itr = m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_HORDE].begin(); itr != m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_HORDE].end(); ++itr) if (!(*itr)->IsInvitedToBGInstanceGUID) qHorde += (*itr)->Players.size(); @@ -235,13 +235,13 @@ GroupQueueInfo * BattleGroundQueue::AddGroup(Player *leader, Group* grp, BattleG if (sWorld.getConfig(CONFIG_UINT32_BATTLEGROUND_QUEUE_ANNOUNCER_JOIN)==1) { ChatHandler(leader).PSendSysMessage(LANG_BG_QUEUE_ANNOUNCE_SELF, bgName, q_min_level, q_max_level, - qAlliance, (MinPlayers > qAlliance) ? MinPlayers - qAlliance : (uint32)0, qHorde, (MinPlayers > qHorde) ? MinPlayers - qHorde : (uint32)0); + qAlliance, (MinPlayers > qAlliance) ? MinPlayers - qAlliance : (uint32)0, qHorde, (MinPlayers > qHorde) ? MinPlayers - qHorde : (uint32)0); } // System message else { sWorld.SendWorldText(LANG_BG_QUEUE_ANNOUNCE_WORLD, bgName, q_min_level, q_max_level, - qAlliance, (MinPlayers > qAlliance) ? MinPlayers - qAlliance : (uint32)0, qHorde, (MinPlayers > qHorde) ? MinPlayers - qHorde : (uint32)0); + qAlliance, (MinPlayers > qAlliance) ? MinPlayers - qAlliance : (uint32)0, qHorde, (MinPlayers > qHorde) ? MinPlayers - qHorde : (uint32)0); } } } @@ -293,7 +293,7 @@ uint32 BattleGroundQueue::GetAverageQueueWaitTime(GroupQueueInfo* ginfo, BattleG team_index = BG_TEAM_HORDE; //for rated arenas use BG_TEAM_HORDE } //check if there is enought values(we always add values > 0) - if (m_WaitTimes[team_index][bracket_id][COUNT_OF_PLAYERS_TO_AVERAGE_WAIT_TIME - 1] ) + if (m_WaitTimes[team_index][bracket_id][COUNT_OF_PLAYERS_TO_AVERAGE_WAIT_TIME - 1]) return (m_SumOfWaitTimes[team_index][bracket_id] / COUNT_OF_PLAYERS_TO_AVERAGE_WAIT_TIME); else //if there aren't enough values return 0 - not available @@ -330,7 +330,7 @@ void BattleGroundQueue::RemovePlayer(ObjectGuid guid, bool decreaseInvitedCount) //they leave groupinfo so we can't use its players size to find out index for (uint32 j = index; j < BG_QUEUE_GROUP_TYPES_COUNT; j += BG_QUEUE_NORMAL_ALLIANCE) { - for(group_itr_tmp = m_QueuedGroups[bracket_id_tmp][j].begin(); group_itr_tmp != m_QueuedGroups[bracket_id_tmp][j].end(); ++group_itr_tmp) + for (group_itr_tmp = m_QueuedGroups[bracket_id_tmp][j].begin(); group_itr_tmp != m_QueuedGroups[bracket_id_tmp][j].end(); ++group_itr_tmp) { if ((*group_itr_tmp) == group) { @@ -379,11 +379,11 @@ void BattleGroundQueue::RemovePlayer(ObjectGuid guid, bool decreaseInvitedCount) //if player leaves queue and he is invited to rated arena match, then he have to loose if (group->IsInvitedToBGInstanceGUID && group->IsRated && decreaseInvitedCount) { - ArenaTeam * at = sObjectMgr.GetArenaTeamById(group->ArenaTeamId); + ArenaTeam* at = sObjectMgr.GetArenaTeamById(group->ArenaTeamId); if (at) { DEBUG_LOG("UPDATING memberLost's personal arena rating for %s by opponents rating: %u", guid.GetString().c_str(), group->OpponentsTeamRating); - Player *plr = sObjectMgr.GetPlayer(guid); + Player* plr = sObjectMgr.GetPlayer(guid); if (plr) at->MemberLost(plr, group->OpponentsTeamRating); else @@ -405,13 +405,13 @@ void BattleGroundQueue::RemovePlayer(ObjectGuid guid, bool decreaseInvitedCount) { // remove next player, this is recursive // first send removal information - if (Player *plr2 = sObjectMgr.GetPlayer(group->Players.begin()->first)) + if (Player* plr2 = sObjectMgr.GetPlayer(group->Players.begin()->first)) { - BattleGround * bg = sBattleGroundMgr.GetBattleGroundTemplate(group->BgTypeId); + BattleGround* bg = sBattleGroundMgr.GetBattleGroundTemplate(group->BgTypeId); BattleGroundQueueTypeId bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(group->BgTypeId, group->arenaType); uint32 queueSlot = plr2->GetBattleGroundQueueIndex(bgQueueTypeId); plr2->RemoveBattleGroundQueueId(bgQueueTypeId); // must be called this way, because if you move this call to - // queue->removeplayer, it causes bugs + // queue->removeplayer, it causes bugs WorldPacket data; sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, queueSlot, STATUS_NONE, 0, 0, ARENA_TYPE_NONE); plr2->GetSession()->SendPacket(&data); @@ -426,9 +426,9 @@ bool BattleGroundQueue::IsPlayerInvited(ObjectGuid pl_guid, const uint32 bgInsta { //ACE_Guard g(m_Lock); QueuedPlayersMap::const_iterator qItr = m_QueuedPlayers.find(pl_guid); - return ( qItr != m_QueuedPlayers.end() - && qItr->second.GroupInfo->IsInvitedToBGInstanceGUID == bgInstanceGuid - && qItr->second.GroupInfo->RemoveInviteTime == removeTime ); + return (qItr != m_QueuedPlayers.end() + && qItr->second.GroupInfo->IsInvitedToBGInstanceGUID == bgInstanceGuid + && qItr->second.GroupInfo->RemoveInviteTime == removeTime); } bool BattleGroundQueue::GetPlayerGroupInfoData(ObjectGuid guid, GroupQueueInfo* ginfo) @@ -441,7 +441,7 @@ bool BattleGroundQueue::GetPlayerGroupInfoData(ObjectGuid guid, GroupQueueInfo* return true; } -bool BattleGroundQueue::InviteGroupToBG(GroupQueueInfo * ginfo, BattleGround * bg, Team side) +bool BattleGroundQueue::InviteGroupToBG(GroupQueueInfo* ginfo, BattleGround* bg, Team side) { // set side if needed if (side) @@ -463,7 +463,7 @@ bool BattleGroundQueue::InviteGroupToBG(GroupQueueInfo * ginfo, BattleGround * b ginfo->RemoveInviteTime = WorldTimer::getMSTime() + INVITE_ACCEPT_WAIT_TIME; // loop through the players - for(GroupQueueInfoPlayers::iterator itr = ginfo->Players.begin(); itr != ginfo->Players.end(); ++itr) + for (GroupQueueInfoPlayers::iterator itr = ginfo->Players.begin(); itr != ginfo->Players.end(); ++itr) { // get the player Player* plr = sObjectMgr.GetPlayer(itr->first); @@ -492,7 +492,7 @@ bool BattleGroundQueue::InviteGroupToBG(GroupQueueInfo * ginfo, BattleGround * b uint32 queueSlot = plr->GetBattleGroundQueueIndex(bgQueueTypeId); DEBUG_LOG("Battleground: invited %s to BG instance %u queueindex %u bgtype %u, I can't help it if they don't press the enter battle button.", - plr->GetGuidStr().c_str(), bg->GetInstanceID(), queueSlot, bg->GetTypeID()); + plr->GetGuidStr().c_str(), bg->GetInstanceID(), queueSlot, bg->GetTypeID()); // send status packet sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_JOIN, INVITE_ACCEPT_WAIT_TIME, 0, ginfo->arenaType); @@ -544,7 +544,7 @@ void BattleGroundQueue::FillPlayersToBG(BattleGround* bg, BattleGroundBracketId // At first we need to compare free space in bg and our selection pool int32 diffAli = aliFree - int32(m_SelectionPools[BG_TEAM_ALLIANCE].GetPlayerCount()); int32 diffHorde = hordeFree - int32(m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount()); - while( abs(diffAli - diffHorde) > 1 && (m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount() > 0 || m_SelectionPools[BG_TEAM_ALLIANCE].GetPlayerCount() > 0) ) + while (abs(diffAli - diffHorde) > 1 && (m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount() > 0 || m_SelectionPools[BG_TEAM_ALLIANCE].GetPlayerCount() > 0)) { //each cycle execution we need to kick at least 1 group if (diffAli < diffHorde) @@ -595,10 +595,10 @@ bool BattleGroundQueue::CheckPremadeMatch(BattleGroundBracketId bracket_id, uint //start premade match //if groups aren't invited GroupsQueueType::const_iterator ali_group, horde_group; - for( ali_group = m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].begin(); ali_group != m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].end(); ++ali_group) + for (ali_group = m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].begin(); ali_group != m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].end(); ++ali_group) if (!(*ali_group)->IsInvitedToBGInstanceGUID) break; - for( horde_group = m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].begin(); horde_group != m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].end(); ++horde_group) + for (horde_group = m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].begin(); horde_group != m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].end(); ++horde_group) if (!(*horde_group)->IsInvitedToBGInstanceGUID) break; @@ -609,9 +609,9 @@ bool BattleGroundQueue::CheckPremadeMatch(BattleGroundBracketId bracket_id, uint //add groups/players from normal queue to size of bigger group uint32 maxPlayers = std::max(m_SelectionPools[BG_TEAM_ALLIANCE].GetPlayerCount(), m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount()); GroupsQueueType::const_iterator itr; - for(uint32 i = 0; i < BG_TEAMS_COUNT; i++) + for (uint32 i = 0; i < BG_TEAMS_COUNT; i++) { - for(itr = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + i].begin(); itr != m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + i].end(); ++itr) + for (itr = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + i].begin(); itr != m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + i].end(); ++itr) { //if itr can join BG and player count is less that maxPlayers, then add group to selectionpool if (!(*itr)->IsInvitedToBGInstanceGUID && !m_SelectionPools[i].AddGroup((*itr), maxPlayers)) @@ -627,7 +627,7 @@ bool BattleGroundQueue::CheckPremadeMatch(BattleGroundBracketId bracket_id, uint // if first is invited to BG and seconds timer expired, but we can ignore it, because players have only 80 seconds to click to enter bg // and when they click or after 80 seconds the queue info is removed from queue uint32 time_before = WorldTimer::getMSTime() - sWorld.getConfig(CONFIG_UINT32_BATTLEGROUND_PREMADE_GROUP_WAIT_FOR_MATCH); - for(uint32 i = 0; i < BG_TEAMS_COUNT; i++) + for (uint32 i = 0; i < BG_TEAMS_COUNT; i++) { if (!m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE + i].empty()) { @@ -648,10 +648,10 @@ bool BattleGroundQueue::CheckPremadeMatch(BattleGroundBracketId bracket_id, uint bool BattleGroundQueue::CheckNormalMatch(BattleGround* bg_template, BattleGroundBracketId bracket_id, uint32 minPlayers, uint32 maxPlayers) { GroupsQueueType::const_iterator itr_team[BG_TEAMS_COUNT]; - for(uint32 i = 0; i < BG_TEAMS_COUNT; i++) + for (uint32 i = 0; i < BG_TEAMS_COUNT; i++) { itr_team[i] = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + i].begin(); - for(; itr_team[i] != m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + i].end(); ++(itr_team[i])) + for (; itr_team[i] != m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + i].end(); ++(itr_team[i])) { if (!(*(itr_team[i]))->IsInvitedToBGInstanceGUID) { @@ -665,12 +665,12 @@ bool BattleGroundQueue::CheckNormalMatch(BattleGround* bg_template, BattleGround uint32 j = BG_TEAM_ALLIANCE; if (m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount() < m_SelectionPools[BG_TEAM_ALLIANCE].GetPlayerCount()) j = BG_TEAM_HORDE; - if( sWorld.getConfig(CONFIG_UINT32_BATTLEGROUND_INVITATION_TYPE) != 0 - && m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount() >= minPlayers && m_SelectionPools[BG_TEAM_ALLIANCE].GetPlayerCount() >= minPlayers ) + if (sWorld.getConfig(CONFIG_UINT32_BATTLEGROUND_INVITATION_TYPE) != 0 + && m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount() >= minPlayers && m_SelectionPools[BG_TEAM_ALLIANCE].GetPlayerCount() >= minPlayers) { //we will try to invite more groups to team with less players indexed by j ++(itr_team[j]); //this will not cause a crash, because for cycle above reached break; - for(; itr_team[j] != m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + j].end(); ++(itr_team[j])) + for (; itr_team[j] != m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + j].end(); ++(itr_team[j])) { if (!(*(itr_team[j]))->IsInvitedToBGInstanceGUID) if (!m_SelectionPools[j].AddGroup(*(itr_team[j]), m_SelectionPools[(j + 1) % BG_TEAMS_COUNT].GetPlayerCount())) @@ -695,7 +695,7 @@ bool BattleGroundQueue::CheckSkirmishForSameFaction(BattleGroundBracketId bracke BattleGroundTeamIndex teamIdx = BG_TEAM_ALLIANCE; BattleGroundTeamIndex otherTeamIdx = BG_TEAM_HORDE; Team otherTeamId = HORDE; - if (m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount() == minPlayersPerTeam ) + if (m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount() == minPlayersPerTeam) { teamIdx = BG_TEAM_HORDE; otherTeamIdx = BG_TEAM_ALLIANCE; @@ -707,7 +707,7 @@ bool BattleGroundQueue::CheckSkirmishForSameFaction(BattleGroundBracketId bracke GroupQueueInfo* ginfo = m_SelectionPools[teamIdx].SelectedGroups.back(); //set itr_team to group that was added to selection pool latest GroupsQueueType::iterator itr_team = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + teamIdx].begin(); - for(; itr_team != m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + teamIdx].end(); ++itr_team) + for (; itr_team != m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + teamIdx].end(); ++itr_team) if (ginfo == *itr_team) break; if (itr_team == m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + teamIdx].end()) @@ -715,7 +715,7 @@ bool BattleGroundQueue::CheckSkirmishForSameFaction(BattleGroundBracketId bracke GroupsQueueType::iterator itr_team2 = itr_team; ++itr_team2; //invite players to other selection pool - for(; itr_team2 != m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + teamIdx].end(); ++itr_team2) + for (; itr_team2 != m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + teamIdx].end(); ++itr_team2) { //if selection pool is full then break; if (!(*itr_team2)->IsInvitedToBGInstanceGUID && !m_SelectionPools[otherTeamIdx].AddGroup(*itr_team2, minPlayersPerTeam)) @@ -725,7 +725,7 @@ bool BattleGroundQueue::CheckSkirmishForSameFaction(BattleGroundBracketId bracke return false; //here we have correct 2 selections and we need to change one teams team and move selection pool teams to other team's queue - for(GroupsQueueType::iterator itr = m_SelectionPools[otherTeamIdx].SelectedGroups.begin(); itr != m_SelectionPools[otherTeamIdx].SelectedGroups.end(); ++itr) + for (GroupsQueueType::iterator itr = m_SelectionPools[otherTeamIdx].SelectedGroups.begin(); itr != m_SelectionPools[otherTeamIdx].SelectedGroups.end(); ++itr) { //set correct team (*itr)->GroupTeam = otherTeamId; @@ -734,7 +734,7 @@ bool BattleGroundQueue::CheckSkirmishForSameFaction(BattleGroundBracketId bracke //remove team from old queue GroupsQueueType::iterator itr2 = itr_team; ++itr2; - for(; itr2 != m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + teamIdx].end(); ++itr2) + for (; itr2 != m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + teamIdx].end(); ++itr2) { if (*itr2 == *itr) { @@ -755,10 +755,10 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BattleGroundBracketI { //ACE_Guard guard(m_Lock); //if no players in queue - do nothing - if( m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].empty() && - m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].empty() && - m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE].empty() && - m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_HORDE].empty() ) + if (m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].empty() && + m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].empty() && + m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE].empty() && + m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_HORDE].empty()) return; //battleground with free slot for player should be always in the beggining of the queue @@ -769,8 +769,8 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BattleGroundBracketI next = itr; ++next; // DO NOT allow queue manager to invite new player to arena - if( (*itr)->isBattleGround() && (*itr)->GetTypeID() == bgTypeId && (*itr)->GetBracketId() == bracket_id && - (*itr)->GetStatus() > STATUS_WAIT_QUEUE && (*itr)->GetStatus() < STATUS_WAIT_LEAVE ) + if ((*itr)->isBattleGround() && (*itr)->GetTypeID() == bgTypeId && (*itr)->GetBracketId() == bracket_id && + (*itr)->GetStatus() > STATUS_WAIT_QUEUE && (*itr)->GetStatus() < STATUS_WAIT_LEAVE) { BattleGround* bg = *itr; //we have to store battleground pointer here, because when battleground is full, it is removed from free queue (not yet implemented!!) // and iterator is invalid @@ -783,9 +783,9 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BattleGroundBracketI FillPlayersToBG(bg, bracket_id); // now everything is set, invite players - for(GroupsQueueType::const_iterator citr = m_SelectionPools[BG_TEAM_ALLIANCE].SelectedGroups.begin(); citr != m_SelectionPools[BG_TEAM_ALLIANCE].SelectedGroups.end(); ++citr) + for (GroupsQueueType::const_iterator citr = m_SelectionPools[BG_TEAM_ALLIANCE].SelectedGroups.begin(); citr != m_SelectionPools[BG_TEAM_ALLIANCE].SelectedGroups.end(); ++citr) InviteGroupToBG((*citr), bg, (*citr)->GroupTeam); - for(GroupsQueueType::const_iterator citr = m_SelectionPools[BG_TEAM_HORDE].SelectedGroups.begin(); citr != m_SelectionPools[BG_TEAM_HORDE].SelectedGroups.end(); ++citr) + for (GroupsQueueType::const_iterator citr = m_SelectionPools[BG_TEAM_HORDE].SelectedGroups.begin(); citr != m_SelectionPools[BG_TEAM_HORDE].SelectedGroups.end(); ++citr) InviteGroupToBG((*citr), bg, (*citr)->GroupTeam); if (!bg->HasFreeSlots()) @@ -798,7 +798,7 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BattleGroundBracketI // finished iterating through the bgs with free slots, maybe we need to create a new bg - BattleGround * bg_template = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId); + BattleGround* bg_template = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId); if (!bg_template) { sLog.outError("Battleground: Update: bg template not found for %u", bgTypeId); @@ -856,15 +856,15 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BattleGroundBracketI if (CheckPremadeMatch(bracket_id, MinPlayersPerTeam, MaxPlayersPerTeam)) { //create new battleground - BattleGround * bg2 = sBattleGroundMgr.CreateNewBattleGround(bgTypeId, bracketEntry, ARENA_TYPE_NONE, false); + BattleGround* bg2 = sBattleGroundMgr.CreateNewBattleGround(bgTypeId, bracketEntry, ARENA_TYPE_NONE, false); if (!bg2) { sLog.outError("BattleGroundQueue::Update - Cannot create battleground: %u", bgTypeId); return; } //invite those selection pools - for(uint32 i = 0; i < BG_TEAMS_COUNT; i++) - for(GroupsQueueType::const_iterator citr = m_SelectionPools[BG_TEAM_ALLIANCE + i].SelectedGroups.begin(); citr != m_SelectionPools[BG_TEAM_ALLIANCE + i].SelectedGroups.end(); ++citr) + for (uint32 i = 0; i < BG_TEAMS_COUNT; i++) + for (GroupsQueueType::const_iterator citr = m_SelectionPools[BG_TEAM_ALLIANCE + i].SelectedGroups.begin(); citr != m_SelectionPools[BG_TEAM_ALLIANCE + i].SelectedGroups.end(); ++citr) InviteGroupToBG((*citr), bg2, (*citr)->GroupTeam); //start bg bg2->StartBattleGround(); @@ -879,10 +879,10 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BattleGroundBracketI { // if there are enough players in pools, start new battleground or non rated arena if (CheckNormalMatch(bg_template, bracket_id, MinPlayersPerTeam, MaxPlayersPerTeam) - || (bg_template->isArena() && CheckSkirmishForSameFaction(bracket_id, MinPlayersPerTeam)) ) + || (bg_template->isArena() && CheckSkirmishForSameFaction(bracket_id, MinPlayersPerTeam))) { // we successfully created a pool - BattleGround * bg2 = sBattleGroundMgr.CreateNewBattleGround(bgTypeId, bracketEntry, arenaType, false); + BattleGround* bg2 = sBattleGroundMgr.CreateNewBattleGround(bgTypeId, bracketEntry, arenaType, false); if (!bg2) { sLog.outError("BattleGroundQueue::Update - Cannot create battleground: %u", bgTypeId); @@ -890,8 +890,8 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BattleGroundBracketI } // invite those selection pools - for(uint32 i = 0; i < BG_TEAMS_COUNT; i++) - for(GroupsQueueType::const_iterator citr = m_SelectionPools[BG_TEAM_ALLIANCE + i].SelectedGroups.begin(); citr != m_SelectionPools[BG_TEAM_ALLIANCE + i].SelectedGroups.end(); ++citr) + for (uint32 i = 0; i < BG_TEAMS_COUNT; i++) + for (GroupsQueueType::const_iterator citr = m_SelectionPools[BG_TEAM_ALLIANCE + i].SelectedGroups.begin(); citr != m_SelectionPools[BG_TEAM_ALLIANCE + i].SelectedGroups.end(); ++citr) InviteGroupToBG((*citr), bg2, (*citr)->GroupTeam); // start bg bg2->StartBattleGround(); @@ -902,7 +902,7 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BattleGroundBracketI // found out the minimum and maximum ratings the newly added team should battle against // arenaRating is the rating of the latest joined team, or 0 // 0 is on (automatic update call) and we must set it to team's with longest wait time - if (!arenaRating ) + if (!arenaRating) { GroupQueueInfo* front1 = NULL; GroupQueueInfo* front2 = NULL; @@ -940,16 +940,16 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BattleGroundBracketI //optimalization : --- we dont need to use selection_pools - each update we select max 2 groups - for(uint32 i = BG_QUEUE_PREMADE_ALLIANCE; i < BG_QUEUE_NORMAL_ALLIANCE; i++) + for (uint32 i = BG_QUEUE_PREMADE_ALLIANCE; i < BG_QUEUE_NORMAL_ALLIANCE; i++) { // take the group that joined first itr_team[i] = m_QueuedGroups[bracket_id][i].begin(); - for(; itr_team[i] != m_QueuedGroups[bracket_id][i].end(); ++(itr_team[i])) + for (; itr_team[i] != m_QueuedGroups[bracket_id][i].end(); ++(itr_team[i])) { // if group match conditions, then add it to pool - if( !(*itr_team[i])->IsInvitedToBGInstanceGUID - && (((*itr_team[i])->ArenaTeamRating >= arenaMinRating && (*itr_team[i])->ArenaTeamRating <= arenaMaxRating) - || (*itr_team[i])->JoinTime < discardTime) ) + if (!(*itr_team[i])->IsInvitedToBGInstanceGUID + && (((*itr_team[i])->ArenaTeamRating >= arenaMinRating && (*itr_team[i])->ArenaTeamRating <= arenaMaxRating) + || (*itr_team[i])->JoinTime < discardTime)) { m_SelectionPools[i].AddGroup((*itr_team[i]), MaxPlayersPerTeam); // break for cycle to be able to start selecting another group from same faction queue @@ -965,11 +965,11 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BattleGroundBracketI { itr_team[BG_TEAM_ALLIANCE] = itr_team[BG_TEAM_HORDE]; ++itr_team[BG_TEAM_ALLIANCE]; - for(; itr_team[BG_TEAM_ALLIANCE] != m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].end(); ++(itr_team[BG_TEAM_ALLIANCE])) + for (; itr_team[BG_TEAM_ALLIANCE] != m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].end(); ++(itr_team[BG_TEAM_ALLIANCE])) { - if( !(*itr_team[BG_TEAM_ALLIANCE])->IsInvitedToBGInstanceGUID - && (((*itr_team[BG_TEAM_ALLIANCE])->ArenaTeamRating >= arenaMinRating && (*itr_team[BG_TEAM_ALLIANCE])->ArenaTeamRating <= arenaMaxRating) - || (*itr_team[BG_TEAM_ALLIANCE])->JoinTime < discardTime) ) + if (!(*itr_team[BG_TEAM_ALLIANCE])->IsInvitedToBGInstanceGUID + && (((*itr_team[BG_TEAM_ALLIANCE])->ArenaTeamRating >= arenaMinRating && (*itr_team[BG_TEAM_ALLIANCE])->ArenaTeamRating <= arenaMaxRating) + || (*itr_team[BG_TEAM_ALLIANCE])->JoinTime < discardTime)) { m_SelectionPools[BG_TEAM_ALLIANCE].AddGroup((*itr_team[BG_TEAM_ALLIANCE]), MaxPlayersPerTeam); break; @@ -981,11 +981,11 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BattleGroundBracketI { itr_team[BG_TEAM_HORDE] = itr_team[BG_TEAM_ALLIANCE]; ++itr_team[BG_TEAM_HORDE]; - for(; itr_team[BG_TEAM_HORDE] != m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].end(); ++(itr_team[BG_TEAM_HORDE])) + for (; itr_team[BG_TEAM_HORDE] != m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].end(); ++(itr_team[BG_TEAM_HORDE])) { - if( !(*itr_team[BG_TEAM_HORDE])->IsInvitedToBGInstanceGUID - && (((*itr_team[BG_TEAM_HORDE])->ArenaTeamRating >= arenaMinRating && (*itr_team[BG_TEAM_HORDE])->ArenaTeamRating <= arenaMaxRating) - || (*itr_team[BG_TEAM_HORDE])->JoinTime < discardTime) ) + if (!(*itr_team[BG_TEAM_HORDE])->IsInvitedToBGInstanceGUID + && (((*itr_team[BG_TEAM_HORDE])->ArenaTeamRating >= arenaMinRating && (*itr_team[BG_TEAM_HORDE])->ArenaTeamRating <= arenaMaxRating) + || (*itr_team[BG_TEAM_HORDE])->JoinTime < discardTime)) { m_SelectionPools[BG_TEAM_HORDE].AddGroup((*itr_team[BG_TEAM_HORDE]), MaxPlayersPerTeam); break; @@ -1039,7 +1039,7 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BattleGroundBracketI bool BGQueueInviteEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) { - Player* plr = sObjectMgr.GetPlayer( m_PlayerGuid ); + Player* plr = sObjectMgr.GetPlayer(m_PlayerGuid); // player logged off (we should do nothing, he is correctly removed from queue in another procedure) if (!plr) return true; @@ -1054,7 +1054,7 @@ bool BGQueueInviteEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) if (queueSlot < PLAYER_MAX_BATTLEGROUND_QUEUES) // player is in queue or in battleground { // check if player is invited to this bg - BattleGroundQueue &bgQueue = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId]; + BattleGroundQueue& bgQueue = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId]; if (bgQueue.IsPlayerInvited(m_PlayerGuid, m_BgInstanceGUID, m_RemoveTime)) { WorldPacket data; @@ -1082,7 +1082,7 @@ void BGQueueInviteEvent::Abort(uint64 /*e_time*/) */ bool BGQueueRemoveEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) { - Player* plr = sObjectMgr.GetPlayer( m_PlayerGuid ); + Player* plr = sObjectMgr.GetPlayer(m_PlayerGuid); if (!plr) // player logged off (we should do nothing, he is correctly removed from queue in another procedure) return true; @@ -1095,7 +1095,7 @@ bool BGQueueRemoveEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) if (queueSlot < PLAYER_MAX_BATTLEGROUND_QUEUES) // player is in queue, or in Battleground { // check if player is in queue for this BG and if we are removing his invite event - BattleGroundQueue &bgQueue = sBattleGroundMgr.m_BattleGroundQueues[m_BgQueueTypeId]; + BattleGroundQueue& bgQueue = sBattleGroundMgr.m_BattleGroundQueues[m_BgQueueTypeId]; if (bgQueue.IsPlayerInvited(m_PlayerGuid, m_BgInstanceGUID, m_RemoveTime)) { DEBUG_LOG("Battleground: removing player %u from bg queue for instance %u because of not pressing enter battle in time.",plr->GetGUIDLow(),m_BgInstanceGUID); @@ -1127,7 +1127,7 @@ void BGQueueRemoveEvent::Abort(uint64 /*e_time*/) BattleGroundMgr::BattleGroundMgr() : m_AutoDistributionTimeChecker(0), m_ArenaTesting(false) { - for(uint32 i = BATTLEGROUND_TYPE_NONE; i < MAX_BATTLEGROUND_TYPE_ID; i++) + for (uint32 i = BATTLEGROUND_TYPE_NONE; i < MAX_BATTLEGROUND_TYPE_ID; i++) m_BattleGrounds[i].clear(); m_NextRatingDiscardUpdate = sWorld.getConfig(CONFIG_UINT32_ARENA_RATING_DISCARD_TIMER); m_Testing=false; @@ -1141,11 +1141,11 @@ BattleGroundMgr::~BattleGroundMgr() void BattleGroundMgr::DeleteAllBattleGrounds() { // will also delete template bgs: - for(uint32 i = BATTLEGROUND_TYPE_NONE; i < MAX_BATTLEGROUND_TYPE_ID; ++i) + for (uint32 i = BATTLEGROUND_TYPE_NONE; i < MAX_BATTLEGROUND_TYPE_ID; ++i) { - for(BattleGroundSet::iterator itr = m_BattleGrounds[i].begin(); itr != m_BattleGrounds[i].end();) + for (BattleGroundSet::iterator itr = m_BattleGrounds[i].begin(); itr != m_BattleGrounds[i].end();) { - BattleGround * bg = itr->second; + BattleGround* bg = itr->second; ++itr; // step from invalidate iterator pos in result element remove in ~BattleGround call delete bg; } @@ -1187,8 +1187,8 @@ void BattleGroundMgr::Update(uint32 diff) { // forced update for rated arenas (scan all, but skipped non rated) DEBUG_LOG("BattleGroundMgr: UPDATING ARENA QUEUES"); - for(int qtype = BATTLEGROUND_QUEUE_2v2; qtype <= BATTLEGROUND_QUEUE_5v5; ++qtype) - for(int bracket = BG_BRACKET_ID_FIRST; bracket < MAX_BATTLEGROUND_BRACKETS; ++bracket) + for (int qtype = BATTLEGROUND_QUEUE_2v2; qtype <= BATTLEGROUND_QUEUE_5v5; ++qtype) + for (int bracket = BG_BRACKET_ID_FIRST; bracket < MAX_BATTLEGROUND_BRACKETS; ++bracket) m_BattleGroundQueues[qtype].Update( BATTLEGROUND_AA, BattleGroundBracketId(bracket), BattleGroundMgr::BGArenaType(BattleGroundQueueTypeId(qtype)), true, 0); @@ -1215,7 +1215,7 @@ void BattleGroundMgr::Update(uint32 diff) } } -void BattleGroundMgr::BuildBattleGroundStatusPacket(WorldPacket *data, BattleGround *bg, uint8 QueueSlot, uint8 StatusID, uint32 Time1, uint32 Time2, ArenaType arenatype) +void BattleGroundMgr::BuildBattleGroundStatusPacket(WorldPacket* data, BattleGround* bg, uint8 QueueSlot, uint8 StatusID, uint32 Time1, uint32 Time2, ArenaType arenatype) { // we can be in 2 queues in same time... @@ -1230,7 +1230,7 @@ void BattleGroundMgr::BuildBattleGroundStatusPacket(WorldPacket *data, BattleGro data->Initialize(SMSG_BATTLEFIELD_STATUS, (4+8+1+1+4+1+4+4+4)); *data << uint32(QueueSlot); // queue id (0...1) - player can be in 2 queues in time // uint64 in client - *data << uint64( uint64(arenatype) | (uint64(0x0D) << 8) | (uint64(bg->GetTypeID()) << 16) | (uint64(0x1F90) << 48) ); + *data << uint64(uint64(arenatype) | (uint64(0x0D) << 8) | (uint64(bg->GetTypeID()) << 16) | (uint64(0x1F90) << 48)); *data << uint8(0); // 3.3.0, some level, only saw 80... *data << uint8(0); // 3.3.0, some level, only saw 80... *data << uint32(bg->GetClientInstanceID()); @@ -1238,7 +1238,7 @@ void BattleGroundMgr::BuildBattleGroundStatusPacket(WorldPacket *data, BattleGro // following displays the minimap-icon 0 = faction icon 1 = arenaicon *data << uint8(bg->isRated()); *data << uint32(StatusID); // status - switch(StatusID) + switch (StatusID) { case STATUS_WAIT_QUEUE: // status_in_queue *data << uint32(Time1); // average wait time, milliseconds @@ -1262,17 +1262,17 @@ void BattleGroundMgr::BuildBattleGroundStatusPacket(WorldPacket *data, BattleGro } } -void BattleGroundMgr::BuildPvpLogDataPacket(WorldPacket *data, BattleGround *bg) +void BattleGroundMgr::BuildPvpLogDataPacket(WorldPacket* data, BattleGround* bg) { uint8 type = (bg->isArena() ? 1 : 0); - // last check on 3.0.3 + // last check on 3.0.3 data->Initialize(MSG_PVP_LOG_DATA, (1+1+4+40*bg->GetPlayerScoresSize())); *data << uint8(type); // type (battleground=0/arena=1) - if(type) // arena + if (type) // arena { // it seems this must be according to BG_WINNER_A/H and _NOT_ BG_TEAM_A/H - for(int i = 1; i >= 0; --i) + for (int i = 1; i >= 0; --i) { uint32 pointsLost = bg->m_ArenaTeamRatingChanges[i] < 0 ? abs(bg->m_ArenaTeamRatingChanges[i]) : 0; uint32 pointsGained = bg->m_ArenaTeamRatingChanges[i] > 0 ? bg->m_ArenaTeamRatingChanges[i] : 0; @@ -1282,10 +1282,10 @@ void BattleGroundMgr::BuildPvpLogDataPacket(WorldPacket *data, BattleGround *bg) *data << uint32(0); // Matchmaking Value DEBUG_LOG("rating change: %d", bg->m_ArenaTeamRatingChanges[i]); } - for(int i = 1; i >= 0; --i) + for (int i = 1; i >= 0; --i) { uint32 at_id = bg->m_ArenaTeamIds[i]; - ArenaTeam * at = sObjectMgr.GetArenaTeamById(at_id); + ArenaTeam* at = sObjectMgr.GetArenaTeamById(at_id); if (at) *data << at->GetName(); else @@ -1305,7 +1305,7 @@ void BattleGroundMgr::BuildPvpLogDataPacket(WorldPacket *data, BattleGround *bg) *data << (int32)(bg->GetPlayerScoresSize()); - for(BattleGround::BattleGroundScoreMap::const_iterator itr = bg->GetPlayerScoresBegin(); itr != bg->GetPlayerScoresEnd(); ++itr) + for (BattleGround::BattleGroundScoreMap::const_iterator itr = bg->GetPlayerScoresBegin(); itr != bg->GetPlayerScoresEnd(); ++itr) { *data << ObjectGuid(itr->first); *data << (int32)itr->second->KillingBlows; @@ -1329,7 +1329,7 @@ void BattleGroundMgr::BuildPvpLogDataPacket(WorldPacket *data, BattleGround *bg) } *data << (int32)itr->second->DamageDone; // damage done *data << (int32)itr->second->HealingDone; // healing done - switch(bg->GetTypeID()) // battleground specific things + switch (bg->GetTypeID()) // battleground specific things { case BATTLEGROUND_AV: *data << (uint32)0x00000005; // count of next fields @@ -1372,40 +1372,40 @@ void BattleGroundMgr::BuildPvpLogDataPacket(WorldPacket *data, BattleGround *bg) } } -void BattleGroundMgr::BuildGroupJoinedBattlegroundPacket(WorldPacket *data, GroupJoinBattlegroundResult result) +void BattleGroundMgr::BuildGroupJoinedBattlegroundPacket(WorldPacket* data, GroupJoinBattlegroundResult result) { data->Initialize(SMSG_GROUP_JOINED_BATTLEGROUND, 4); *data << int32(result); - if(result == ERR_BATTLEGROUND_JOIN_TIMED_OUT || result == ERR_BATTLEGROUND_JOIN_FAILED) + if (result == ERR_BATTLEGROUND_JOIN_TIMED_OUT || result == ERR_BATTLEGROUND_JOIN_FAILED) *data << uint64(0); // player guid } -void BattleGroundMgr::BuildUpdateWorldStatePacket(WorldPacket *data, uint32 field, uint32 value) +void BattleGroundMgr::BuildUpdateWorldStatePacket(WorldPacket* data, uint32 field, uint32 value) { data->Initialize(SMSG_UPDATE_WORLD_STATE, 4+4); *data << uint32(field); *data << uint32(value); } -void BattleGroundMgr::BuildPlaySoundPacket(WorldPacket *data, uint32 soundid) +void BattleGroundMgr::BuildPlaySoundPacket(WorldPacket* data, uint32 soundid) { data->Initialize(SMSG_PLAY_SOUND, 4); *data << uint32(soundid); } -void BattleGroundMgr::BuildPlayerLeftBattleGroundPacket(WorldPacket *data, ObjectGuid guid) +void BattleGroundMgr::BuildPlayerLeftBattleGroundPacket(WorldPacket* data, ObjectGuid guid) { data->Initialize(SMSG_BATTLEGROUND_PLAYER_LEFT, 8); *data << ObjectGuid(guid); } -void BattleGroundMgr::BuildPlayerJoinedBattleGroundPacket(WorldPacket *data, Player *plr) +void BattleGroundMgr::BuildPlayerJoinedBattleGroundPacket(WorldPacket* data, Player* plr) { data->Initialize(SMSG_BATTLEGROUND_PLAYER_JOINED, 8); *data << plr->GetObjectGuid(); } -BattleGround * BattleGroundMgr::GetBattleGroundThroughClientInstance(uint32 instanceId, BattleGroundTypeId bgTypeId) +BattleGround* BattleGroundMgr::GetBattleGroundThroughClientInstance(uint32 instanceId, BattleGroundTypeId bgTypeId) { //cause at HandleBattleGroundJoinOpcode the clients sends the instanceid he gets from //SMSG_BATTLEFIELD_LIST we need to find the battleground with this clientinstance-id @@ -1416,7 +1416,7 @@ BattleGround * BattleGroundMgr::GetBattleGroundThroughClientInstance(uint32 inst if (bg->isArena()) return GetBattleGround(instanceId, bgTypeId); - for(BattleGroundSet::iterator itr = m_BattleGrounds[bgTypeId].begin(); itr != m_BattleGrounds[bgTypeId].end(); ++itr) + for (BattleGroundSet::iterator itr = m_BattleGrounds[bgTypeId].begin(); itr != m_BattleGrounds[bgTypeId].end(); ++itr) { if (itr->second->GetClientInstanceID() == instanceId) return itr->second; @@ -1424,13 +1424,13 @@ BattleGround * BattleGroundMgr::GetBattleGroundThroughClientInstance(uint32 inst return NULL; } -BattleGround * BattleGroundMgr::GetBattleGround(uint32 InstanceID, BattleGroundTypeId bgTypeId) +BattleGround* BattleGroundMgr::GetBattleGround(uint32 InstanceID, BattleGroundTypeId bgTypeId) { //search if needed BattleGroundSet::iterator itr; if (bgTypeId == BATTLEGROUND_TYPE_NONE) { - for(uint32 i = BATTLEGROUND_AV; i < MAX_BATTLEGROUND_TYPE_ID; i++) + for (uint32 i = BATTLEGROUND_AV; i < MAX_BATTLEGROUND_TYPE_ID; i++) { itr = m_BattleGrounds[i].find(InstanceID); if (itr != m_BattleGrounds[i].end()) @@ -1439,10 +1439,10 @@ BattleGround * BattleGroundMgr::GetBattleGround(uint32 InstanceID, BattleGroundT return NULL; } itr = m_BattleGrounds[bgTypeId].find(InstanceID); - return ( (itr != m_BattleGrounds[bgTypeId].end()) ? itr->second : NULL ); + return ((itr != m_BattleGrounds[bgTypeId].end()) ? itr->second : NULL); } -BattleGround * BattleGroundMgr::GetBattleGroundTemplate(BattleGroundTypeId bgTypeId) +BattleGround* BattleGroundMgr::GetBattleGroundTemplate(BattleGroundTypeId bgTypeId) { //map is sorted and we can be sure that lowest instance id has only BG template return m_BattleGrounds[bgTypeId].empty() ? NULL : m_BattleGrounds[bgTypeId].begin()->second; @@ -1461,9 +1461,9 @@ uint32 BattleGroundMgr::CreateClientVisibleInstanceId(BattleGroundTypeId bgTypeI // the optimalization would be to use as bitmask std::vector - but that would only make code unreadable uint32 lastId = 0; ClientBattleGroundIdSet& ids = m_ClientBattleGroundIds[bgTypeId][bracket_id]; - for(ClientBattleGroundIdSet::const_iterator itr = ids.begin(); itr != ids.end();) + for (ClientBattleGroundIdSet::const_iterator itr = ids.begin(); itr != ids.end();) { - if( (++lastId) != *itr) //if there is a gap between the ids, we will break.. + if ((++lastId) != *itr) //if there is a gap between the ids, we will break.. break; lastId = *itr; } @@ -1472,10 +1472,10 @@ uint32 BattleGroundMgr::CreateClientVisibleInstanceId(BattleGroundTypeId bgTypeI } // create a new battleground that will really be used to play -BattleGround * BattleGroundMgr::CreateNewBattleGround(BattleGroundTypeId bgTypeId, PvPDifficultyEntry const* bracketEntry, ArenaType arenaType, bool isRated) +BattleGround* BattleGroundMgr::CreateNewBattleGround(BattleGroundTypeId bgTypeId, PvPDifficultyEntry const* bracketEntry, ArenaType arenaType, bool isRated) { // get the template BG - BattleGround *bg_template = GetBattleGroundTemplate(bgTypeId); + BattleGround* bg_template = GetBattleGroundTemplate(bgTypeId); if (!bg_template) { sLog.outError("BattleGround: CreateNewBattleGround - bg template not found for %u", bgTypeId); @@ -1495,9 +1495,9 @@ BattleGround * BattleGroundMgr::CreateNewBattleGround(BattleGroundTypeId bgTypeI } } - BattleGround *bg = NULL; + BattleGround* bg = NULL; // create a copy of the BG template - switch(bgTypeId) + switch (bgTypeId) { case BATTLEGROUND_AV: bg = new BattleGroundAV(*(BattleGroundAV*)bg_template); @@ -1566,8 +1566,8 @@ BattleGround * BattleGroundMgr::CreateNewBattleGround(BattleGroundTypeId bgTypeI uint32 BattleGroundMgr::CreateBattleGround(BattleGroundTypeId bgTypeId, bool IsArena, uint32 MinPlayersPerTeam, uint32 MaxPlayersPerTeam, uint32 LevelMin, uint32 LevelMax, char const* BattleGroundName, uint32 MapID, float Team1StartLocX, float Team1StartLocY, float Team1StartLocZ, float Team1StartLocO, float Team2StartLocX, float Team2StartLocY, float Team2StartLocZ, float Team2StartLocO) { // Create the BG - BattleGround *bg = NULL; - switch(bgTypeId) + BattleGround* bg = NULL; + switch (bgTypeId) { case BATTLEGROUND_AV: bg = new BattleGroundAV; break; case BATTLEGROUND_WS: bg = new BattleGroundWS; break; @@ -1609,7 +1609,7 @@ void BattleGroundMgr::CreateInitialBattleGrounds() uint32 count = 0; // 0 1 2 3 4 5 6 - QueryResult *result = WorldDatabase.Query("SELECT id, MinPlayersPerTeam,MaxPlayersPerTeam,AllianceStartLoc,AllianceStartO,HordeStartLoc,HordeStartO FROM battleground_template"); + QueryResult* result = WorldDatabase.Query("SELECT id, MinPlayersPerTeam,MaxPlayersPerTeam,AllianceStartLoc,AllianceStartO,HordeStartLoc,HordeStartO FROM battleground_template"); if (!result) { @@ -1626,13 +1626,13 @@ void BattleGroundMgr::CreateInitialBattleGrounds() do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); bar.step(); uint32 bgTypeID_ = fields[0].GetUInt32(); // can be overwrite by values from DB - BattlemasterListEntry const *bl = sBattlemasterListStore.LookupEntry(bgTypeID_); + BattlemasterListEntry const* bl = sBattlemasterListStore.LookupEntry(bgTypeID_); if (!bl) { sLog.outError("Battleground ID %u not found in BattlemasterList.dbc. Battleground not created.", bgTypeID_); @@ -1660,7 +1660,7 @@ void BattleGroundMgr::CreateInitialBattleGrounds() uint32 start1 = fields[3].GetUInt32(); - WorldSafeLocsEntry const *start = sWorldSafeLocsStore.LookupEntry(start1); + WorldSafeLocsEntry const* start = sWorldSafeLocsStore.LookupEntry(start1); if (start) { AStartLoc[0] = start->x; @@ -1709,12 +1709,13 @@ void BattleGroundMgr::CreateInitialBattleGrounds() continue; ++count; - } while (result->NextRow()); + } + while (result->NextRow()); delete result; sLog.outString(); - sLog.outString( ">> Loaded %u battlegrounds", count ); + sLog.outString(">> Loaded %u battlegrounds", count); } void BattleGroundMgr::InitAutomaticArenaPointDistribution() @@ -1722,7 +1723,7 @@ void BattleGroundMgr::InitAutomaticArenaPointDistribution() if (sWorld.getConfig(CONFIG_BOOL_ARENA_AUTO_DISTRIBUTE_POINTS)) { DEBUG_LOG("Initializing Automatic Arena Point Distribution"); - QueryResult * result = CharacterDatabase.Query("SELECT NextArenaPointDistributionTime FROM saved_variables"); + QueryResult* result = CharacterDatabase.Query("SELECT NextArenaPointDistributionTime FROM saved_variables"); if (!result) { DEBUG_LOG("Battleground: Next arena point distribution time not found in SavedVariables, reseting it now."); @@ -1749,9 +1750,9 @@ void BattleGroundMgr::DistributeArenaPoints() std::map PlayerPoints; //at first update all points for all team members - for(ObjectMgr::ArenaTeamMap::iterator team_itr = sObjectMgr.GetArenaTeamMapBegin(); team_itr != sObjectMgr.GetArenaTeamMapEnd(); ++team_itr) + for (ObjectMgr::ArenaTeamMap::iterator team_itr = sObjectMgr.GetArenaTeamMapBegin(); team_itr != sObjectMgr.GetArenaTeamMapEnd(); ++team_itr) { - if (ArenaTeam * at = team_itr->second) + if (ArenaTeam* at = team_itr->second) { at->UpdateArenaPointsHelper(PlayerPoints); } @@ -1772,9 +1773,9 @@ void BattleGroundMgr::DistributeArenaPoints() sWorld.SendWorldText(LANG_DIST_ARENA_POINTS_ONLINE_END); sWorld.SendWorldText(LANG_DIST_ARENA_POINTS_TEAM_START); - for(ObjectMgr::ArenaTeamMap::iterator titr = sObjectMgr.GetArenaTeamMapBegin(); titr != sObjectMgr.GetArenaTeamMapEnd(); ++titr) + for (ObjectMgr::ArenaTeamMap::iterator titr = sObjectMgr.GetArenaTeamMapBegin(); titr != sObjectMgr.GetArenaTeamMapEnd(); ++titr) { - if (ArenaTeam * at = titr->second) + if (ArenaTeam* at = titr->second) { at->FinishWeek(); // set played this week etc values to 0 in memory, too at->SaveToDB(); // save changes @@ -1787,7 +1788,7 @@ void BattleGroundMgr::DistributeArenaPoints() sWorld.SendWorldText(LANG_DIST_ARENA_POINTS_END); } -void BattleGroundMgr::BuildBattleGroundListPacket(WorldPacket *data, ObjectGuid guid, Player* plr, BattleGroundTypeId bgTypeId, uint8 fromWhere) +void BattleGroundMgr::BuildBattleGroundListPacket(WorldPacket* data, ObjectGuid guid, Player* plr, BattleGroundTypeId bgTypeId, uint8 fromWhere) { if (!plr) return; @@ -1807,7 +1808,7 @@ void BattleGroundMgr::BuildBattleGroundListPacket(WorldPacket *data, ObjectGuid uint8 isRandom = 0; *data << uint8(isRandom); // 3.3.3 isRandom - if(isRandom) + if (isRandom) { // Rewards (random) *data << uint8(0); // 3.3.3 hasWin_Random @@ -1816,7 +1817,7 @@ void BattleGroundMgr::BuildBattleGroundListPacket(WorldPacket *data, ObjectGuid *data << uint32(0); // 3.3.3 lossHonor_Random } - if(bgTypeId == BATTLEGROUND_AA) // arena + if (bgTypeId == BATTLEGROUND_AA) // arena { *data << uint32(0); // arena - no instances showed } @@ -1826,27 +1827,27 @@ void BattleGroundMgr::BuildBattleGroundListPacket(WorldPacket *data, ObjectGuid uint32 count = 0; *data << uint32(0); // number of bg instances - if(BattleGround* bgTemplate = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId)) + if (BattleGround* bgTemplate = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId)) { // expected bracket entry - if(PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bgTemplate->GetMapId(),plr->getLevel())) + if (PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bgTemplate->GetMapId(),plr->getLevel())) { BattleGroundBracketId bracketId = bracketEntry->GetBracketId(); ClientBattleGroundIdSet const& ids = m_ClientBattleGroundIds[bgTypeId][bracketId]; - for(ClientBattleGroundIdSet::const_iterator itr = ids.begin(); itr != ids.end();++itr) + for (ClientBattleGroundIdSet::const_iterator itr = ids.begin(); itr != ids.end(); ++itr) { *data << uint32(*itr); ++count; } - data->put( count_pos , count); + data->put(count_pos , count); } } } } -void BattleGroundMgr::SendToBattleGround(Player *pl, uint32 instanceId, BattleGroundTypeId bgTypeId) +void BattleGroundMgr::SendToBattleGround(Player* pl, uint32 instanceId, BattleGroundTypeId bgTypeId) { - BattleGround *bg = GetBattleGround(instanceId, bgTypeId); + BattleGround* bg = GetBattleGround(instanceId, bgTypeId); if (bg) { uint32 mapid = bg->GetMapId(); @@ -1867,7 +1868,7 @@ void BattleGroundMgr::SendToBattleGround(Player *pl, uint32 instanceId, BattleGr bool BattleGroundMgr::IsArenaType(BattleGroundTypeId bgTypeId) { - switch(bgTypeId) + switch (bgTypeId) { case BATTLEGROUND_NA: case BATTLEGROUND_BE: @@ -1883,7 +1884,7 @@ bool BattleGroundMgr::IsArenaType(BattleGroundTypeId bgTypeId) BattleGroundQueueTypeId BattleGroundMgr::BGQueueTypeId(BattleGroundTypeId bgTypeId, ArenaType arenaType) { - switch(bgTypeId) + switch (bgTypeId) { case BATTLEGROUND_WS: return BATTLEGROUND_QUEUE_WS; @@ -1905,7 +1906,7 @@ BattleGroundQueueTypeId BattleGroundMgr::BGQueueTypeId(BattleGroundTypeId bgType case BATTLEGROUND_BE: case BATTLEGROUND_DS: case BATTLEGROUND_RV: - switch(arenaType) + switch (arenaType) { case ARENA_TYPE_2v2: return BATTLEGROUND_QUEUE_2v2; @@ -1923,7 +1924,7 @@ BattleGroundQueueTypeId BattleGroundMgr::BGQueueTypeId(BattleGroundTypeId bgType BattleGroundTypeId BattleGroundMgr::BGTemplateId(BattleGroundQueueTypeId bgQueueTypeId) { - switch(bgQueueTypeId) + switch (bgQueueTypeId) { case BATTLEGROUND_QUEUE_WS: return BATTLEGROUND_WS; @@ -1948,7 +1949,7 @@ BattleGroundTypeId BattleGroundMgr::BGTemplateId(BattleGroundQueueTypeId bgQueue ArenaType BattleGroundMgr::BGArenaType(BattleGroundQueueTypeId bgQueueTypeId) { - switch(bgQueueTypeId) + switch (bgQueueTypeId) { case BATTLEGROUND_QUEUE_2v2: return ARENA_TYPE_2v2; @@ -2020,7 +2021,7 @@ void BattleGroundMgr::LoadBattleMastersEntry() { mBattleMastersMap.clear(); // need for reload case - QueryResult *result = WorldDatabase.Query( "SELECT entry,bg_template FROM battlemaster_entry" ); + QueryResult* result = WorldDatabase.Query("SELECT entry,bg_template FROM battlemaster_entry"); uint32 count = 0; @@ -2041,7 +2042,7 @@ void BattleGroundMgr::LoadBattleMastersEntry() ++count; bar.step(); - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 entry = fields[0].GetUInt32(); uint32 bgTypeId = fields[1].GetUInt32(); @@ -2053,12 +2054,13 @@ void BattleGroundMgr::LoadBattleMastersEntry() mBattleMastersMap[entry] = BattleGroundTypeId(bgTypeId); - } while(result->NextRow()); + } + while (result->NextRow()); delete result; sLog.outString(); - sLog.outString( ">> Loaded %u battlemaster entries", count ); + sLog.outString(">> Loaded %u battlemaster entries", count); } HolidayIds BattleGroundMgr::BGTypeToWeekendHolidayId(BattleGroundTypeId bgTypeId) @@ -2104,38 +2106,38 @@ void BattleGroundMgr::LoadBattleEventIndexes() uint32 count = 0; - QueryResult *result = + QueryResult* result = // 0 1 2 3 4 5 6 - WorldDatabase.Query( "SELECT data.typ, data.guid1, data.ev1 AS ev1, data.ev2 AS ev2, data.map AS m, data.guid2, description.map, " - // 7 8 9 - "description.event1, description.event2, description.description " - "FROM " - "(SELECT '1' AS typ, a.guid AS guid1, a.event1 AS ev1, a.event2 AS ev2, b.map AS map, b.guid AS guid2 " - "FROM gameobject_battleground AS a " - "LEFT OUTER JOIN gameobject AS b ON a.guid = b.guid " - "UNION " - "SELECT '2' AS typ, a.guid AS guid1, a.event1 AS ev1, a.event2 AS ev2, b.map AS map, b.guid AS guid2 " - "FROM creature_battleground AS a " - "LEFT OUTER JOIN creature AS b ON a.guid = b.guid " - ") data " - "RIGHT OUTER JOIN battleground_events AS description ON data.map = description.map " - "AND data.ev1 = description.event1 AND data.ev2 = description.event2 " - // full outer join doesn't work in mysql :-/ so just UNION-select the same again and add a left outer join - "UNION " - "SELECT data.typ, data.guid1, data.ev1, data.ev2, data.map, data.guid2, description.map, " - "description.event1, description.event2, description.description " - "FROM " - "(SELECT '1' AS typ, a.guid AS guid1, a.event1 AS ev1, a.event2 AS ev2, b.map AS map, b.guid AS guid2 " - "FROM gameobject_battleground AS a " - "LEFT OUTER JOIN gameobject AS b ON a.guid = b.guid " - "UNION " - "SELECT '2' AS typ, a.guid AS guid1, a.event1 AS ev1, a.event2 AS ev2, b.map AS map, b.guid AS guid2 " - "FROM creature_battleground AS a " - "LEFT OUTER JOIN creature AS b ON a.guid = b.guid " - ") data " - "LEFT OUTER JOIN battleground_events AS description ON data.map = description.map " - "AND data.ev1 = description.event1 AND data.ev2 = description.event2 " - "ORDER BY m, ev1, ev2" ); + WorldDatabase.Query("SELECT data.typ, data.guid1, data.ev1 AS ev1, data.ev2 AS ev2, data.map AS m, data.guid2, description.map, " + // 7 8 9 + "description.event1, description.event2, description.description " + "FROM " + "(SELECT '1' AS typ, a.guid AS guid1, a.event1 AS ev1, a.event2 AS ev2, b.map AS map, b.guid AS guid2 " + "FROM gameobject_battleground AS a " + "LEFT OUTER JOIN gameobject AS b ON a.guid = b.guid " + "UNION " + "SELECT '2' AS typ, a.guid AS guid1, a.event1 AS ev1, a.event2 AS ev2, b.map AS map, b.guid AS guid2 " + "FROM creature_battleground AS a " + "LEFT OUTER JOIN creature AS b ON a.guid = b.guid " + ") data " + "RIGHT OUTER JOIN battleground_events AS description ON data.map = description.map " + "AND data.ev1 = description.event1 AND data.ev2 = description.event2 " + // full outer join doesn't work in mysql :-/ so just UNION-select the same again and add a left outer join + "UNION " + "SELECT data.typ, data.guid1, data.ev1, data.ev2, data.map, data.guid2, description.map, " + "description.event1, description.event2, description.description " + "FROM " + "(SELECT '1' AS typ, a.guid AS guid1, a.event1 AS ev1, a.event2 AS ev2, b.map AS map, b.guid AS guid2 " + "FROM gameobject_battleground AS a " + "LEFT OUTER JOIN gameobject AS b ON a.guid = b.guid " + "UNION " + "SELECT '2' AS typ, a.guid AS guid1, a.event1 AS ev1, a.event2 AS ev2, b.map AS map, b.guid AS guid2 " + "FROM creature_battleground AS a " + "LEFT OUTER JOIN creature AS b ON a.guid = b.guid " + ") data " + "LEFT OUTER JOIN battleground_events AS description ON data.map = description.map " + "AND data.ev1 = description.event1 AND data.ev2 = description.event2 " + "ORDER BY m, ev1, ev2"); if (!result) { BarGoLink bar(1); @@ -2151,7 +2153,7 @@ void BattleGroundMgr::LoadBattleEventIndexes() do { bar.step(); - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); if (fields[2].GetUInt8() == BG_EVENT_NONE || fields[3].GetUInt8() == BG_EVENT_NONE) continue; // we don't need to add those to the eventmap @@ -2164,13 +2166,13 @@ void BattleGroundMgr::LoadBattleEventIndexes() uint32 desc_map = fields[6].GetUInt32(); uint8 desc_event1 = fields[7].GetUInt8(); uint8 desc_event2 = fields[8].GetUInt8(); - const char *description = fields[9].GetString(); + const char* description = fields[9].GetString(); // checking for NULL - through right outer join this will mean following: if (fields[5].GetUInt32() != dbTableGuidLow) { sLog.outErrorDb("BattleGroundEvent: %s with nonexistent guid %u for event: map:%u, event1:%u, event2:%u (\"%s\")", - (gameobject) ? "gameobject" : "creature", dbTableGuidLow, map, events.event1, events.event2, description); + (gameobject) ? "gameobject" : "creature", dbTableGuidLow, map, events.event1, events.event2, description); continue; } @@ -2187,7 +2189,7 @@ void BattleGroundMgr::LoadBattleEventIndexes() else { sLog.outErrorDb("BattleGroundEvent: %s with guid %u is registered, for a nonexistent event: map:%u, event1:%u, event2:%u", - (gameobject) ? "gameobject" : "creature", dbTableGuidLow, map, events.event1, events.event2); + (gameobject) ? "gameobject" : "creature", dbTableGuidLow, map, events.event1, events.event2); continue; } } @@ -2199,9 +2201,10 @@ void BattleGroundMgr::LoadBattleEventIndexes() ++count; - } while(result->NextRow()); + } + while (result->NextRow()); sLog.outString(); - sLog.outString( ">> Loaded %u battleground eventindexes", count); + sLog.outString(">> Loaded %u battleground eventindexes", count); delete result; } diff --git a/src/game/BattleGroundMgr.h b/src/game/BattleGroundMgr.h index 9a3bc01e2..40fcfc5bf 100644 --- a/src/game/BattleGroundMgr.h +++ b/src/game/BattleGroundMgr.h @@ -43,7 +43,7 @@ struct GroupQueueInfo; // type predefinitio struct PlayerQueueInfo // stores information for players in queue { uint32 LastOnlineTime; // for tracking and removing offline players from queue after 5 minutes - GroupQueueInfo * GroupInfo; // pointer to the associated groupqueueinfo + GroupQueueInfo* GroupInfo; // pointer to the associated groupqueueinfo }; typedef std::map GroupQueueInfoPlayers; @@ -85,7 +85,7 @@ class BattleGroundQueue bool CheckPremadeMatch(BattleGroundBracketId bracket_id, uint32 MinPlayersPerTeam, uint32 MaxPlayersPerTeam); bool CheckNormalMatch(BattleGround* bg_template, BattleGroundBracketId bracket_id, uint32 minPlayers, uint32 maxPlayers); bool CheckSkirmishForSameFaction(BattleGroundBracketId bracket_id, uint32 minPlayersPerTeam); - GroupQueueInfo * AddGroup(Player* leader, Group* group, BattleGroundTypeId bgTypeId, PvPDifficultyEntry const* bracketEntry, ArenaType arenaType, bool isRated, bool isPremade, uint32 ArenaRating, uint32 ArenaTeamId = 0); + GroupQueueInfo* AddGroup(Player* leader, Group* group, BattleGroundTypeId bgTypeId, PvPDifficultyEntry const* bracketEntry, ArenaType arenaType, bool isRated, bool isPremade, uint32 ArenaRating, uint32 ArenaTeamId = 0); void RemovePlayer(ObjectGuid guid, bool decreaseInvitedCount); bool IsPlayerInvited(ObjectGuid pl_guid, const uint32 bgInstanceGuid, const uint32 removeTime); bool GetPlayerGroupInfoData(ObjectGuid guid, GroupQueueInfo* ginfo); @@ -117,21 +117,21 @@ class BattleGroundQueue // class to select and invite groups to bg class SelectionPool { - public: - void Init(); - bool AddGroup(GroupQueueInfo *ginfo, uint32 desiredCount); - bool KickGroup(uint32 size); - uint32 GetPlayerCount() const {return PlayerCount;} - public: - GroupsQueueType SelectedGroups; - private: - uint32 PlayerCount; + public: + void Init(); + bool AddGroup(GroupQueueInfo* ginfo, uint32 desiredCount); + bool KickGroup(uint32 size); + uint32 GetPlayerCount() const {return PlayerCount;} + public: + GroupsQueueType SelectedGroups; + private: + uint32 PlayerCount; }; //one selection pool for horde, other one for alliance SelectionPool m_SelectionPools[BG_TEAMS_COUNT]; - bool InviteGroupToBG(GroupQueueInfo * ginfo, BattleGround * bg, Team side); + bool InviteGroupToBG(GroupQueueInfo* ginfo, BattleGround* bg, Team side); uint32 m_WaitTimes[BG_TEAMS_COUNT][MAX_BATTLEGROUND_BRACKETS][COUNT_OF_PLAYERS_TO_AVERAGE_WAIT_TIME]; uint32 m_WaitTimeLastPlayer[BG_TEAMS_COUNT][MAX_BATTLEGROUND_BRACKETS]; uint32 m_SumOfWaitTimes[BG_TEAMS_COUNT][MAX_BATTLEGROUND_BRACKETS]; @@ -145,9 +145,9 @@ class BGQueueInviteEvent : public BasicEvent { public: BGQueueInviteEvent(ObjectGuid pl_guid, uint32 BgInstanceGUID, BattleGroundTypeId BgTypeId, ArenaType arenaType, uint32 removeTime) : - m_PlayerGuid(pl_guid), m_BgInstanceGUID(BgInstanceGUID), m_BgTypeId(BgTypeId), m_ArenaType(arenaType), m_RemoveTime(removeTime) - { - }; + m_PlayerGuid(pl_guid), m_BgInstanceGUID(BgInstanceGUID), m_BgTypeId(BgTypeId), m_ArenaType(arenaType), m_RemoveTime(removeTime) + { + }; virtual ~BGQueueInviteEvent() {}; virtual bool Execute(uint64 e_time, uint32 p_time); @@ -193,14 +193,14 @@ class BattleGroundMgr void Update(uint32 diff); /* Packet Building */ - void BuildPlayerJoinedBattleGroundPacket(WorldPacket *data, Player *plr); - void BuildPlayerLeftBattleGroundPacket(WorldPacket *data, ObjectGuid guid); - void BuildBattleGroundListPacket(WorldPacket *data, ObjectGuid guid, Player *plr, BattleGroundTypeId bgTypeId, uint8 fromWhere); - void BuildGroupJoinedBattlegroundPacket(WorldPacket *data, GroupJoinBattlegroundResult result); - void BuildUpdateWorldStatePacket(WorldPacket *data, uint32 field, uint32 value); - void BuildPvpLogDataPacket(WorldPacket *data, BattleGround *bg); - void BuildBattleGroundStatusPacket(WorldPacket *data, BattleGround *bg, uint8 QueueSlot, uint8 StatusID, uint32 Time1, uint32 Time2, ArenaType arenatype); - void BuildPlaySoundPacket(WorldPacket *data, uint32 soundid); + void BuildPlayerJoinedBattleGroundPacket(WorldPacket* data, Player* plr); + void BuildPlayerLeftBattleGroundPacket(WorldPacket* data, ObjectGuid guid); + void BuildBattleGroundListPacket(WorldPacket* data, ObjectGuid guid, Player* plr, BattleGroundTypeId bgTypeId, uint8 fromWhere); + void BuildGroupJoinedBattlegroundPacket(WorldPacket* data, GroupJoinBattlegroundResult result); + void BuildUpdateWorldStatePacket(WorldPacket* data, uint32 field, uint32 value); + void BuildPvpLogDataPacket(WorldPacket* data, BattleGround* bg); + void BuildBattleGroundStatusPacket(WorldPacket* data, BattleGround* bg, uint8 QueueSlot, uint8 StatusID, uint32 Time1, uint32 Time2, ArenaType arenatype); + void BuildPlaySoundPacket(WorldPacket* data, uint32 soundid); /* Battlegrounds */ BattleGround* GetBattleGroundThroughClientInstance(uint32 instanceId, BattleGroundTypeId bgTypeId); @@ -222,7 +222,7 @@ class BattleGroundMgr void CreateInitialBattleGrounds(); void DeleteAllBattleGrounds(); - void SendToBattleGround(Player *pl, uint32 InstanceID, BattleGroundTypeId bgTypeId); + void SendToBattleGround(Player* pl, uint32 InstanceID, BattleGroundTypeId bgTypeId); /* Battleground queues */ //these queues are instantiated when creating BattlegroundMrg @@ -253,14 +253,14 @@ class BattleGroundMgr const BattleGroundEventIdx GetCreatureEventIndex(uint32 dbTableGuidLow) const { CreatureBattleEventIndexesMap::const_iterator itr = m_CreatureBattleEventIndexMap.find(dbTableGuidLow); - if(itr != m_CreatureBattleEventIndexMap.end()) + if (itr != m_CreatureBattleEventIndexMap.end()) return itr->second; return m_CreatureBattleEventIndexMap.find(-1)->second; } const BattleGroundEventIdx GetGameObjectEventIndex(uint32 dbTableGuidLow) const { GameObjectBattleEventIndexesMap::const_iterator itr = m_GameObjectBattleEventIndexMap.find(dbTableGuidLow); - if(itr != m_GameObjectBattleEventIndexMap.end()) + if (itr != m_GameObjectBattleEventIndexMap.end()) return itr->second; return m_GameObjectBattleEventIndexMap.find(-1)->second; } diff --git a/src/game/BattleGroundNA.cpp b/src/game/BattleGroundNA.cpp index 541b5e79f..7258ef959 100644 --- a/src/game/BattleGroundNA.cpp +++ b/src/game/BattleGroundNA.cpp @@ -61,7 +61,7 @@ void BattleGroundNA::StartingEventOpenDoors() OpenDoorEvent(BG_EVENT_DOOR); } -void BattleGroundNA::AddPlayer(Player *plr) +void BattleGroundNA::AddPlayer(Player* plr) { BattleGround::AddPlayer(plr); //create score and add it to map, default values are set in constructor @@ -84,7 +84,7 @@ void BattleGroundNA::RemovePlayer(Player* /*plr*/, ObjectGuid /*guid*/) CheckArenaWinConditions(); } -void BattleGroundNA::HandleKillPlayer(Player *player, Player *killer) +void BattleGroundNA::HandleKillPlayer(Player* player, Player* killer) { if (GetStatus() != STATUS_IN_PROGRESS) return; @@ -103,20 +103,20 @@ void BattleGroundNA::HandleKillPlayer(Player *player, Player *killer) CheckArenaWinConditions(); } -bool BattleGroundNA::HandlePlayerUnderMap(Player *player) +bool BattleGroundNA::HandlePlayerUnderMap(Player* player) { player->TeleportTo(GetMapId(),4055.504395f,2919.660645f,13.611241f,player->GetOrientation(),false); return true; } -void BattleGroundNA::HandleAreaTrigger(Player *Source, uint32 Trigger) +void BattleGroundNA::HandleAreaTrigger(Player* Source, uint32 Trigger) { if (GetStatus() != STATUS_IN_PROGRESS) return; //uint32 SpellId = 0; //uint64 buff_guid = 0; - switch(Trigger) + switch (Trigger) { case 4536: // buff trigger? case 4537: // buff trigger? @@ -131,7 +131,7 @@ void BattleGroundNA::HandleAreaTrigger(Player *Source, uint32 Trigger) // HandleTriggerBuff(buff_guid,Source); } -void BattleGroundNA::FillInitialWorldStates(WorldPacket &data, uint32& count) +void BattleGroundNA::FillInitialWorldStates(WorldPacket& data, uint32& count) { FillInitialWorldState(data, count, 0xa0f, GetAlivePlayersCountByTeam(ALLIANCE)); FillInitialWorldState(data, count, 0xa10, GetAlivePlayersCountByTeam(HORDE)); diff --git a/src/game/BattleGroundNA.h b/src/game/BattleGroundNA.h index 29169bf35..3dd0cbbcc 100644 --- a/src/game/BattleGroundNA.h +++ b/src/game/BattleGroundNA.h @@ -30,7 +30,7 @@ class BattleGroundNAScore : public BattleGroundScore class BattleGroundNA : public BattleGround { - friend class BattleGroundMgr; + friend class BattleGroundMgr; public: BattleGroundNA(); @@ -38,16 +38,16 @@ class BattleGroundNA : public BattleGround void Update(uint32 diff); /* inherited from BattlegroundClass */ - virtual void AddPlayer(Player *plr); + virtual void AddPlayer(Player* plr); virtual void StartingEventCloseDoors(); virtual void StartingEventOpenDoors(); - void RemovePlayer(Player *plr, ObjectGuid guid); - void HandleAreaTrigger(Player *Source, uint32 Trigger); + void RemovePlayer(Player* plr, ObjectGuid guid); + void HandleAreaTrigger(Player* Source, uint32 Trigger); bool SetupBattleGround(); virtual void Reset(); - virtual void FillInitialWorldStates(WorldPacket &d, uint32& count); - void HandleKillPlayer(Player* player, Player *killer); - bool HandlePlayerUnderMap(Player * plr); + virtual void FillInitialWorldStates(WorldPacket& d, uint32& count); + void HandleKillPlayer(Player* player, Player* killer); + bool HandlePlayerUnderMap(Player* plr); }; #endif diff --git a/src/game/BattleGroundRB.cpp b/src/game/BattleGroundRB.cpp index a14dfc9dc..c4c256b5f 100644 --- a/src/game/BattleGroundRB.cpp +++ b/src/game/BattleGroundRB.cpp @@ -48,7 +48,7 @@ void BattleGroundRB::StartingEventOpenDoors() { } -void BattleGroundRB::AddPlayer(Player *plr) +void BattleGroundRB::AddPlayer(Player* plr) { BattleGround::AddPlayer(plr); //create score and add it to map, default values are set in constructor @@ -62,7 +62,7 @@ void BattleGroundRB::RemovePlayer(Player* /*plr*/, ObjectGuid /*guid*/) } -void BattleGroundRB::HandleAreaTrigger(Player * /*Source*/, uint32 /*Trigger*/) +void BattleGroundRB::HandleAreaTrigger(Player* /*Source*/, uint32 /*Trigger*/) { // this is wrong way to implement these things. On official it done by gameobject spell cast. if (GetStatus() != STATUS_IN_PROGRESS) @@ -74,7 +74,7 @@ void BattleGroundRB::UpdatePlayerScore(Player* Source, uint32 type, uint32 value BattleGroundScoreMap::iterator itr = m_PlayerScores.find(Source->GetObjectGuid()); - if(itr == m_PlayerScores.end()) // player not found... + if (itr == m_PlayerScores.end()) // player not found... return; BattleGround::UpdatePlayerScore(Source,type,value); diff --git a/src/game/BattleGroundRB.h b/src/game/BattleGroundRB.h index 024652eb8..9cb058e2c 100644 --- a/src/game/BattleGroundRB.h +++ b/src/game/BattleGroundRB.h @@ -30,7 +30,7 @@ class BattleGroundABGScore : public BattleGroundScore class BattleGroundRB : public BattleGround { - friend class BattleGroundMgr; + friend class BattleGroundMgr; public: BattleGroundRB(); @@ -38,16 +38,16 @@ class BattleGroundRB : public BattleGround void Update(uint32 diff); /* inherited from BattlegroundClass */ - virtual void AddPlayer(Player *plr); + virtual void AddPlayer(Player* plr); virtual void StartingEventCloseDoors(); virtual void StartingEventOpenDoors(); - void RemovePlayer(Player *plr, ObjectGuid guid); - void HandleAreaTrigger(Player *Source, uint32 Trigger); + void RemovePlayer(Player* plr, ObjectGuid guid); + void HandleAreaTrigger(Player* Source, uint32 Trigger); //bool SetupBattleGround(); /* Scorekeeping */ - void UpdatePlayerScore(Player *Source, uint32 type, uint32 value); + void UpdatePlayerScore(Player* Source, uint32 type, uint32 value); private: }; diff --git a/src/game/BattleGroundRL.cpp b/src/game/BattleGroundRL.cpp index 0db6bc4d3..6fc689780 100644 --- a/src/game/BattleGroundRL.cpp +++ b/src/game/BattleGroundRL.cpp @@ -60,7 +60,7 @@ void BattleGroundRL::StartingEventOpenDoors() OpenDoorEvent(BG_EVENT_DOOR); } -void BattleGroundRL::AddPlayer(Player *plr) +void BattleGroundRL::AddPlayer(Player* plr) { BattleGround::AddPlayer(plr); //create score and add it to map, default values are set in constructor @@ -83,7 +83,7 @@ void BattleGroundRL::RemovePlayer(Player* /*plr*/, ObjectGuid /*guid*/) CheckArenaWinConditions(); } -void BattleGroundRL::HandleKillPlayer(Player *player, Player *killer) +void BattleGroundRL::HandleKillPlayer(Player* player, Player* killer) { if (GetStatus() != STATUS_IN_PROGRESS) return; @@ -102,13 +102,13 @@ void BattleGroundRL::HandleKillPlayer(Player *player, Player *killer) CheckArenaWinConditions(); } -bool BattleGroundRL::HandlePlayerUnderMap(Player *player) +bool BattleGroundRL::HandlePlayerUnderMap(Player* player) { player->TeleportTo(GetMapId(),1285.810547f,1667.896851f,39.957642f,player->GetOrientation(),false); return true; } -void BattleGroundRL::HandleAreaTrigger(Player *Source, uint32 Trigger) +void BattleGroundRL::HandleAreaTrigger(Player* Source, uint32 Trigger) { // this is wrong way to implement these things. On official it done by gameobject spell cast. if (GetStatus() != STATUS_IN_PROGRESS) @@ -116,7 +116,7 @@ void BattleGroundRL::HandleAreaTrigger(Player *Source, uint32 Trigger) //uint32 SpellId = 0; //uint64 buff_guid = 0; - switch(Trigger) + switch (Trigger) { case 4696: // buff trigger? case 4697: // buff trigger? @@ -131,7 +131,7 @@ void BattleGroundRL::HandleAreaTrigger(Player *Source, uint32 Trigger) // HandleTriggerBuff(buff_guid,Source); } -void BattleGroundRL::FillInitialWorldStates(WorldPacket &data, uint32& count) +void BattleGroundRL::FillInitialWorldStates(WorldPacket& data, uint32& count) { FillInitialWorldState(data, count, 0xbb8, GetAlivePlayersCountByTeam(ALLIANCE)); FillInitialWorldState(data, count, 0xbb9, GetAlivePlayersCountByTeam(HORDE)); diff --git a/src/game/BattleGroundRL.h b/src/game/BattleGroundRL.h index 7ce4d42a2..81bf4195e 100644 --- a/src/game/BattleGroundRL.h +++ b/src/game/BattleGroundRL.h @@ -30,7 +30,7 @@ class BattleGroundRLScore : public BattleGroundScore class BattleGroundRL : public BattleGround { - friend class BattleGroundMgr; + friend class BattleGroundMgr; public: BattleGroundRL(); @@ -38,16 +38,16 @@ class BattleGroundRL : public BattleGround void Update(uint32 diff); /* inherited from BattlegroundClass */ - virtual void AddPlayer(Player *plr); + virtual void AddPlayer(Player* plr); virtual void Reset(); - virtual void FillInitialWorldStates(WorldPacket &d, uint32& count); + virtual void FillInitialWorldStates(WorldPacket& d, uint32& count); virtual void StartingEventCloseDoors(); virtual void StartingEventOpenDoors(); - void RemovePlayer(Player *plr, ObjectGuid guid); - void HandleAreaTrigger(Player *Source, uint32 Trigger); + void RemovePlayer(Player* plr, ObjectGuid guid); + void HandleAreaTrigger(Player* Source, uint32 Trigger); bool SetupBattleGround(); - void HandleKillPlayer(Player* player, Player *killer); - bool HandlePlayerUnderMap(Player * plr); + void HandleKillPlayer(Player* player, Player* killer); + bool HandlePlayerUnderMap(Player* plr); }; #endif diff --git a/src/game/BattleGroundRV.cpp b/src/game/BattleGroundRV.cpp index d968bd40a..331482c58 100644 --- a/src/game/BattleGroundRV.cpp +++ b/src/game/BattleGroundRV.cpp @@ -53,7 +53,7 @@ void BattleGroundRV::StartingEventOpenDoors() { } -void BattleGroundRV::AddPlayer(Player *plr) +void BattleGroundRV::AddPlayer(Player* plr) { BattleGround::AddPlayer(plr); //create score and add it to map, default values are set in constructor @@ -62,7 +62,7 @@ void BattleGroundRV::AddPlayer(Player *plr) m_PlayerScores[plr->GetObjectGuid()] = sc; } -void BattleGroundRV::RemovePlayer(Player * /*plr*/, ObjectGuid /*guid*/) +void BattleGroundRV::RemovePlayer(Player* /*plr*/, ObjectGuid /*guid*/) { } @@ -71,7 +71,7 @@ void BattleGroundRV::HandleKillPlayer(Player* player, Player* killer) BattleGround::HandleKillPlayer(player, killer); } -void BattleGroundRV::HandleAreaTrigger(Player * /*Source*/, uint32 /*Trigger*/) +void BattleGroundRV::HandleAreaTrigger(Player* /*Source*/, uint32 /*Trigger*/) { } diff --git a/src/game/BattleGroundRV.h b/src/game/BattleGroundRV.h index 2159b35af..8b20cb2f8 100644 --- a/src/game/BattleGroundRV.h +++ b/src/game/BattleGroundRV.h @@ -30,7 +30,7 @@ class BattleGroundRVScore : public BattleGroundScore class BattleGroundRV : public BattleGround { - friend class BattleGroundMgr; + friend class BattleGroundMgr; public: BattleGroundRV(); @@ -38,13 +38,13 @@ class BattleGroundRV : public BattleGround void Update(uint32 diff); /* inherited from BattlegroundClass */ - virtual void AddPlayer(Player *plr); + virtual void AddPlayer(Player* plr); virtual void StartingEventCloseDoors(); virtual void StartingEventOpenDoors(); - void RemovePlayer(Player *plr, ObjectGuid guid); - void HandleAreaTrigger(Player *Source, uint32 Trigger); + void RemovePlayer(Player* plr, ObjectGuid guid); + void HandleAreaTrigger(Player* Source, uint32 Trigger); bool SetupBattleGround(); - void HandleKillPlayer(Player* player, Player *killer); + void HandleKillPlayer(Player* player, Player* killer); }; #endif diff --git a/src/game/BattleGroundSA.cpp b/src/game/BattleGroundSA.cpp index 49948ec9d..6a9ad9dec 100644 --- a/src/game/BattleGroundSA.cpp +++ b/src/game/BattleGroundSA.cpp @@ -48,7 +48,7 @@ void BattleGroundSA::StartingEventOpenDoors() { } -void BattleGroundSA::AddPlayer(Player *plr) +void BattleGroundSA::AddPlayer(Player* plr) { BattleGround::AddPlayer(plr); //create score and add it to map, default values are set in constructor @@ -62,7 +62,7 @@ void BattleGroundSA::RemovePlayer(Player* /*plr*/, ObjectGuid /*guid*/) } -void BattleGroundSA::HandleAreaTrigger(Player * /*Source*/, uint32 /*Trigger*/) +void BattleGroundSA::HandleAreaTrigger(Player* /*Source*/, uint32 /*Trigger*/) { // this is wrong way to implement these things. On official it done by gameobject spell cast. if (GetStatus() != STATUS_IN_PROGRESS) @@ -73,7 +73,7 @@ void BattleGroundSA::UpdatePlayerScore(Player* Source, uint32 type, uint32 value { BattleGroundScoreMap::iterator itr = m_PlayerScores.find(Source->GetObjectGuid()); - if(itr == m_PlayerScores.end()) // player not found... + if (itr == m_PlayerScores.end()) // player not found... return; BattleGround::UpdatePlayerScore(Source,type,value); diff --git a/src/game/BattleGroundSA.h b/src/game/BattleGroundSA.h index b3382561d..652f013bd 100644 --- a/src/game/BattleGroundSA.h +++ b/src/game/BattleGroundSA.h @@ -33,7 +33,7 @@ class BattleGroundSAScore : public BattleGroundScore class BattleGroundSA : public BattleGround { - friend class BattleGroundMgr; + friend class BattleGroundMgr; public: BattleGroundSA(); @@ -41,16 +41,16 @@ class BattleGroundSA : public BattleGround void Update(uint32 diff); /* inherited from BattlegroundClass */ - virtual void AddPlayer(Player *plr); + virtual void AddPlayer(Player* plr); virtual void StartingEventCloseDoors(); virtual void StartingEventOpenDoors(); - void RemovePlayer(Player *plr, ObjectGuid guid); - void HandleAreaTrigger(Player *Source, uint32 Trigger); + void RemovePlayer(Player* plr, ObjectGuid guid); + void HandleAreaTrigger(Player* Source, uint32 Trigger); //bool SetupBattleGround(); /* Scorekeeping */ - void UpdatePlayerScore(Player *Source, uint32 type, uint32 value); + void UpdatePlayerScore(Player* Source, uint32 type, uint32 value); private: }; diff --git a/src/game/BattleGroundWS.cpp b/src/game/BattleGroundWS.cpp index f900fb1f3..8b9992171 100644 --- a/src/game/BattleGroundWS.cpp +++ b/src/game/BattleGroundWS.cpp @@ -132,7 +132,7 @@ void BattleGroundWS::StartingEventOpenDoors() StartTimedAchievement(ACHIEVEMENT_CRITERIA_TYPE_WIN_BG, BG_WS_EVENT_START_BATTLE); } -void BattleGroundWS::AddPlayer(Player *plr) +void BattleGroundWS::AddPlayer(Player* plr) { BattleGround::AddPlayer(plr); //create score and add it to map, default values are set in constructor @@ -179,7 +179,7 @@ void BattleGroundWS::RespawnFlagAfterDrop(Team team) PlaySoundToAll(BG_WS_SOUND_FLAGS_RESPAWNED); - GameObject *obj = GetBgMap()->GetGameObject(GetDroppedFlagGuid(team)); + GameObject* obj = GetBgMap()->GetGameObject(GetDroppedFlagGuid(team)); if (obj) obj->Delete(); else @@ -188,7 +188,7 @@ void BattleGroundWS::RespawnFlagAfterDrop(Team team) ClearDroppedFlagGuid(team); } -void BattleGroundWS::EventPlayerCapturedFlag(Player *Source) +void BattleGroundWS::EventPlayerCapturedFlag(Player* Source) { if (GetStatus() != STATUS_IN_PROGRESS) return; @@ -203,9 +203,9 @@ void BattleGroundWS::EventPlayerCapturedFlag(Player *Source) if (!IsHordeFlagPickedup()) return; ClearHordeFlagPicker(); // must be before aura remove to prevent 2 events (drop+capture) at the same time - // horde flag in base (but not respawned yet) + // horde flag in base (but not respawned yet) m_FlagState[BG_TEAM_HORDE] = BG_WS_FLAG_STATE_WAIT_RESPAWN; - // Drop Horde Flag from Player + // Drop Horde Flag from Player Source->RemoveAurasDueToSpell(BG_WS_SPELL_WARSONG_FLAG); if (GetTeamScore(ALLIANCE) < BG_WS_MAX_TEAM_SCORE) AddPoint(ALLIANCE, 1); @@ -217,9 +217,9 @@ void BattleGroundWS::EventPlayerCapturedFlag(Player *Source) if (!IsAllianceFlagPickedup()) return; ClearAllianceFlagPicker(); // must be before aura remove to prevent 2 events (drop+capture) at the same time - // alliance flag in base (but not respawned yet) + // alliance flag in base (but not respawned yet) m_FlagState[BG_TEAM_ALLIANCE] = BG_WS_FLAG_STATE_WAIT_RESPAWN; - // Drop Alliance Flag from Player + // Drop Alliance Flag from Player Source->RemoveAurasDueToSpell(BG_WS_SPELL_SILVERWING_FLAG); if (GetTeamScore(HORDE) < BG_WS_MAX_TEAM_SCORE) AddPoint(HORDE, 1); @@ -264,7 +264,7 @@ void BattleGroundWS::EventPlayerCapturedFlag(Player *Source) } } -void BattleGroundWS::EventPlayerDroppedFlag(Player *Source) +void BattleGroundWS::EventPlayerDroppedFlag(Player* Source) { if (GetStatus() != STATUS_IN_PROGRESS) { @@ -342,7 +342,7 @@ void BattleGroundWS::EventPlayerDroppedFlag(Player *Source) } } -void BattleGroundWS::EventPlayerClickedOnFlag(Player *Source, GameObject* target_obj) +void BattleGroundWS::EventPlayerClickedOnFlag(Player* Source, GameObject* target_obj) { if (GetStatus() != STATUS_IN_PROGRESS) return; @@ -353,8 +353,8 @@ void BattleGroundWS::EventPlayerClickedOnFlag(Player *Source, GameObject* target uint8 event = (sBattleGroundMgr.GetGameObjectEventIndex(target_obj->GetGUIDLow())).event1; //alliance flag picked up from base - if(Source->GetTeam() == HORDE && GetFlagState(ALLIANCE) == BG_WS_FLAG_STATE_ON_BASE - && event == WS_EVENT_FLAG_A) + if (Source->GetTeam() == HORDE && GetFlagState(ALLIANCE) == BG_WS_FLAG_STATE_ON_BASE + && event == WS_EVENT_FLAG_A) { message_id = LANG_BG_WS_PICKEDUP_AF; type = CHAT_MSG_BG_SYSTEM_HORDE; @@ -370,7 +370,7 @@ void BattleGroundWS::EventPlayerClickedOnFlag(Player *Source, GameObject* target //horde flag picked up from base if (Source->GetTeam() == ALLIANCE && GetFlagState(HORDE) == BG_WS_FLAG_STATE_ON_BASE - && event == WS_EVENT_FLAG_H) + && event == WS_EVENT_FLAG_H) { message_id = LANG_BG_WS_PICKEDUP_HF; type = CHAT_MSG_BG_SYSTEM_ALLIANCE; @@ -447,7 +447,7 @@ void BattleGroundWS::EventPlayerClickedOnFlag(Player *Source, GameObject* target Source->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT); } -void BattleGroundWS::RemovePlayer(Player *plr, ObjectGuid guid) +void BattleGroundWS::RemovePlayer(Player* plr, ObjectGuid guid) { // sometimes flag aura not removed :( if (IsAllianceFlagPickedup() && m_FlagKeepers[BG_TEAM_ALLIANCE] == guid) @@ -490,7 +490,7 @@ void BattleGroundWS::UpdateTeamScore(Team team) UpdateWorldState(BG_WS_FLAG_CAPTURES_HORDE, GetTeamScore(team)); } -void BattleGroundWS::HandleAreaTrigger(Player *Source, uint32 Trigger) +void BattleGroundWS::HandleAreaTrigger(Player* Source, uint32 Trigger) { // this is wrong way to implement these things. On official it done by gameobject spell cast. if (GetStatus() != STATUS_IN_PROGRESS) @@ -498,7 +498,7 @@ void BattleGroundWS::HandleAreaTrigger(Player *Source, uint32 Trigger) //uint32 SpellId = 0; //uint64 buff_guid = 0; - switch(Trigger) + switch (Trigger) { case 3686: // Alliance elixir of speed spawn. Trigger not working, because located inside other areatrigger, can be replaced by IsWithinDist(object, dist) in BattleGround::Update(). case 3687: // Horde elixir of speed spawn. Trigger not working, because located inside other areatrigger, can be replaced by IsWithinDist(object, dist) in BattleGround::Update(). @@ -544,7 +544,7 @@ void BattleGroundWS::Reset() m_ActiveEvents[WS_EVENT_FLAG_A] = BG_EVENT_NONE; m_ActiveEvents[WS_EVENT_FLAG_H] = BG_EVENT_NONE; - for(uint32 i = 0; i < BG_TEAMS_COUNT; ++i) + for (uint32 i = 0; i < BG_TEAMS_COUNT; ++i) { m_DroppedFlagGuid[i].Clear(); m_FlagKeepers[i].Clear(); @@ -574,7 +574,7 @@ void BattleGroundWS::EndBattleGround(Team winner) BattleGround::EndBattleGround(winner); } -void BattleGroundWS::HandleKillPlayer(Player *player, Player *killer) +void BattleGroundWS::HandleKillPlayer(Player* player, Player* killer) { if (GetStatus() != STATUS_IN_PROGRESS) return; @@ -584,14 +584,14 @@ void BattleGroundWS::HandleKillPlayer(Player *player, Player *killer) BattleGround::HandleKillPlayer(player, killer); } -void BattleGroundWS::UpdatePlayerScore(Player *Source, uint32 type, uint32 value) +void BattleGroundWS::UpdatePlayerScore(Player* Source, uint32 type, uint32 value) { BattleGroundScoreMap::iterator itr = m_PlayerScores.find(Source->GetObjectGuid()); - if(itr == m_PlayerScores.end()) // player not found + if (itr == m_PlayerScores.end()) // player not found return; - switch(type) + switch (type) { case SCORE_FLAG_CAPTURES: // flags captured ((BattleGroundWGScore*)itr->second)->FlagCaptures += value; diff --git a/src/game/BattleGroundWS.h b/src/game/BattleGroundWS.h index 86f6e1c1e..8637339c1 100644 --- a/src/game/BattleGroundWS.h +++ b/src/game/BattleGroundWS.h @@ -96,7 +96,7 @@ enum BG_WS_Events class BattleGroundWS : public BattleGround { - friend class BattleGroundMgr; + friend class BattleGroundMgr; public: /* Construction */ @@ -105,12 +105,12 @@ class BattleGroundWS : public BattleGround void Update(uint32 diff); /* inherited from BattlegroundClass */ - virtual void AddPlayer(Player *plr); + virtual void AddPlayer(Player* plr); virtual void StartingEventCloseDoors(); virtual void StartingEventOpenDoors(); /* BG Flags */ - ObjectGuid GetAllianceFlagPickerGuid() const{ return m_FlagKeepers[BG_TEAM_ALLIANCE]; } + ObjectGuid GetAllianceFlagPickerGuid() const { return m_FlagKeepers[BG_TEAM_ALLIANCE]; } ObjectGuid GetHordeFlagPickerGuid() const { return m_FlagKeepers[BG_TEAM_HORDE]; } void SetAllianceFlagPicker(ObjectGuid guid) { m_FlagKeepers[BG_TEAM_ALLIANCE] = guid; } void SetHordeFlagPicker(ObjectGuid guid) { m_FlagKeepers[BG_TEAM_HORDE] = guid; } @@ -123,13 +123,13 @@ class BattleGroundWS : public BattleGround uint8 GetFlagState(Team team) { return m_FlagState[GetTeamIndexByTeamId(team)]; } /* Battleground Events */ - virtual void EventPlayerDroppedFlag(Player *Source); - virtual void EventPlayerClickedOnFlag(Player *Source, GameObject* target_obj); - virtual void EventPlayerCapturedFlag(Player *Source); + virtual void EventPlayerDroppedFlag(Player* Source); + virtual void EventPlayerClickedOnFlag(Player* Source, GameObject* target_obj); + virtual void EventPlayerCapturedFlag(Player* Source); - void RemovePlayer(Player *plr, ObjectGuid guid); - void HandleAreaTrigger(Player *Source, uint32 Trigger); - void HandleKillPlayer(Player *player, Player *killer); + void RemovePlayer(Player* plr, ObjectGuid guid); + void HandleAreaTrigger(Player* Source, uint32 Trigger); + void HandleKillPlayer(Player* player, Player* killer); bool SetupBattleGround(); virtual void Reset(); void EndBattleGround(Team winner); @@ -138,7 +138,7 @@ class BattleGroundWS : public BattleGround void UpdateFlagState(Team team, uint32 value); void UpdateTeamScore(Team team); - void UpdatePlayerScore(Player *Source, uint32 type, uint32 value); + void UpdatePlayerScore(Player* Source, uint32 type, uint32 value); void SetDroppedFlagGuid(ObjectGuid guid, Team team) { m_DroppedFlagGuid[GetTeamIndexByTeamId(team)] = guid;} void ClearDroppedFlagGuid(Team team) { m_DroppedFlagGuid[GetTeamIndexByTeamId(team)].Clear();} ObjectGuid const& GetDroppedFlagGuid(Team team) const { return m_DroppedFlagGuid[GetTeamIndexByTeamId(team)];}