diff options
| author | megamage <none@none> | 2008-11-30 12:47:26 -0600 |
|---|---|---|
| committer | megamage <none@none> | 2008-11-30 12:47:26 -0600 |
| commit | bb1ee8a004c79d0f2262820f92df4bd72bdd6587 (patch) | |
| tree | c240378ccc96b12f1f67cc9e096368bc95662a2c /src/game | |
| parent | 375d3ba4eb986676fc9084a93414083a89d542a0 (diff) | |
*Update to Mangos 6867. Source: Mangos.
*Big changes:
*[6858] Prevent cheating with ignore waiting in login queue.
*[6863] Arena team related clean ups and adding parts of w12x's arena patch.
*Some Config changes and guild changes.
--HG--
branch : trunk
Diffstat (limited to 'src/game')
| -rw-r--r-- | src/game/ArenaTeam.cpp | 230 | ||||
| -rw-r--r-- | src/game/ArenaTeam.h | 43 | ||||
| -rw-r--r-- | src/game/BattleGround.cpp | 23 | ||||
| -rw-r--r-- | src/game/CharacterHandler.cpp | 46 | ||||
| -rw-r--r-- | src/game/Creature.cpp | 2 | ||||
| -rw-r--r-- | src/game/Guild.cpp | 20 | ||||
| -rw-r--r-- | src/game/MiscHandler.cpp | 18 | ||||
| -rw-r--r-- | src/game/ObjectMgr.cpp | 2 | ||||
| -rw-r--r-- | src/game/Player.cpp | 59 | ||||
| -rw-r--r-- | src/game/Player.h | 6 | ||||
| -rw-r--r-- | src/game/Spell.cpp | 24 | ||||
| -rw-r--r-- | src/game/SpellMgr.cpp | 30 | ||||
| -rw-r--r-- | src/game/WaypointMovementGenerator.cpp | 3 | ||||
| -rw-r--r-- | src/game/World.cpp | 271 | ||||
| -rw-r--r-- | src/game/World.h | 30 | ||||
| -rw-r--r-- | src/game/WorldSession.cpp | 9 | ||||
| -rw-r--r-- | src/game/WorldSession.h | 4 |
17 files changed, 457 insertions, 363 deletions
diff --git a/src/game/ArenaTeam.cpp b/src/game/ArenaTeam.cpp index b108c98e1ec..40b75c047c7 100644 --- a/src/game/ArenaTeam.cpp +++ b/src/game/ArenaTeam.cpp @@ -24,21 +24,21 @@ ArenaTeam::ArenaTeam() { - Id = 0; - Type = 0; - Name = ""; - CaptainGuid = 0; - BackgroundColor = 0; // background - EmblemStyle = 0; // icon - EmblemColor = 0; // icon color - BorderStyle = 0; // border - BorderColor = 0; // border color - stats.games = 0; - stats.played = 0; - stats.rank = 0; - stats.rating = 1500; - stats.wins = 0; - stats.wins2 = 0; + Id = 0; + Type = 0; + Name = ""; + CaptainGuid = 0; + BackgroundColor = 0; // background + EmblemStyle = 0; // icon + EmblemColor = 0; // icon color + BorderStyle = 0; // border + BorderColor = 0; // border color + stats.games_week = 0; + stats.games_season = 0; + stats.rank = 0; + stats.rating = 1500; + stats.wins_week = 0; + stats.wins_season = 0; } ArenaTeam::~ArenaTeam() @@ -77,7 +77,7 @@ bool ArenaTeam::create(uint64 captainGuid, uint32 type, std::string ArenaTeamNam "VALUES('%u','%s','%u','%u','%u','%u','%u','%u','%u')", Id, ArenaTeamName.c_str(), GUID_LOPART(CaptainGuid), Type, BackgroundColor,EmblemStyle,EmblemColor,BorderStyle,BorderColor); CharacterDatabase.PExecute("INSERT INTO arena_team_stats (arenateamid, rating, games, wins, played, wins2, rank) VALUES " - "('%u', '%u', '%u', '%u', '%u', '%u', '%u')", Id,stats.rating,stats.games,stats.wins,stats.played,stats.wins2,stats.rank); + "('%u', '%u', '%u', '%u', '%u', '%u', '%u')", Id,stats.rating,stats.games_week,stats.wins_week,stats.games_season,stats.wins_season,stats.rank); CharacterDatabase.CommitTransaction(); @@ -130,13 +130,14 @@ bool ArenaTeam::AddMember(uint64 PlayerGuid) Player::RemovePetitionsAndSigns(PlayerGuid, GetType()); ArenaTeamMember newmember; - newmember.name = plName; - newmember.guid = PlayerGuid; - newmember.Class = plClass; - newmember.played_season = 0; - newmember.played_week = 0; - newmember.wons_season = 0; - newmember.wons_week = 0; + newmember.name = plName; + newmember.guid = PlayerGuid; + newmember.Class = plClass; + newmember.games_season = 0; + newmember.games_week = 0; + newmember.wins_season = 0; + newmember.wins_week = 0; + newmember.personal_rating = 1500; members.push_back(newmember); CharacterDatabase.PExecute("INSERT INTO arena_team_member (arenateamid,guid) VALUES ('%u', '%u')", Id, GUID_LOPART(newmember.guid)); @@ -145,43 +146,24 @@ bool ArenaTeam::AddMember(uint64 PlayerGuid) { pl->SetInArenaTeam(Id, GetSlot()); pl->SetArenaTeamIdInvited(0); - // personal rating - pl->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (GetSlot() * 6) + 5, 1500); - } - // hide promote/remove buttons - if(CaptainGuid != PlayerGuid) - { - if(pl) + // hide promote/remove buttons + if(CaptainGuid != PlayerGuid) pl->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 1 + (GetSlot() * 6), 1); } - - // setuint32valueindb is asynch, can't be used here - Tokens tokens; - if(!Player::LoadValuesArrayFromDB(tokens,PlayerGuid)) - return false; - - // arena team id - uint16 index = PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (GetSlot() * 6); - char buf[11]; - snprintf(buf,11,"%u",Id); - tokens[index] = buf; - // pers rating - index = PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (GetSlot() * 6) + 5; - buf[11]; - snprintf(buf,11,"%u",1500); - tokens[index] = buf; - // hide promote/remove buttons - if(CaptainGuid != PlayerGuid) + else { - index = PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 1 + (GetSlot() * 6); - buf[11]; - snprintf(buf,11,"%u",1); - tokens[index] = buf; - } - - Player::SaveValuesArrayInDB(tokens,PlayerGuid); + Tokens tokens; + if(Player::LoadValuesArrayFromDB(tokens,PlayerGuid)) + { + Player::SetUInt32ValueInArray(tokens,PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (GetSlot() * 6), Id); + // hide promote/remove buttons + if(CaptainGuid != PlayerGuid) + Player::SetUInt32ValueInArray(tokens,PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 1 + (GetSlot() * 6), 1); + Player::SaveValuesArrayInDB(tokens,PlayerGuid); + } + } return true; } @@ -235,12 +217,12 @@ void ArenaTeam::LoadStatsFromDB(uint32 ArenaTeamId) Field *fields = result->Fetch(); - stats.rating = fields[0].GetUInt32(); - stats.games = fields[1].GetUInt32(); - stats.wins = fields[2].GetUInt32(); - stats.played = fields[3].GetUInt32(); - stats.wins2 = fields[4].GetUInt32(); - stats.rank = fields[5].GetUInt32(); + stats.rating = fields[0].GetUInt32(); + stats.games_week = fields[1].GetUInt32(); + stats.wins_week = fields[2].GetUInt32(); + stats.games_season = fields[3].GetUInt32(); + stats.wins_season = fields[4].GetUInt32(); + stats.rank = fields[5].GetUInt32(); delete result; } @@ -249,7 +231,7 @@ void ArenaTeam::LoadMembersFromDB(uint32 ArenaTeamId) { Field *fields; - QueryResult *result = CharacterDatabase.PQuery("SELECT guid,played_week,wons_week,played_season,wons_season,points_to_add FROM arena_team_member WHERE arenateamid = '%u'", ArenaTeamId); + QueryResult *result = CharacterDatabase.PQuery("SELECT guid,games_week,wins_week,games_season,wins_season,points_to_add FROM arena_team_member WHERE arenateamid = '%u'", ArenaTeamId); if(!result) return; @@ -267,10 +249,10 @@ void ArenaTeam::LoadMembersFromDB(uint32 ArenaTeamId) continue; } LoadPlayerStats(&newmember); - newmember.played_week = fields[1].GetUInt32(); - newmember.wons_week = fields[2].GetUInt32(); - newmember.played_season = fields[3].GetUInt32(); - newmember.wons_season = fields[4].GetUInt32(); + newmember.games_week = fields[1].GetUInt32(); + newmember.wins_week = fields[2].GetUInt32(); + newmember.games_season = fields[3].GetUInt32(); + newmember.wins_season = fields[4].GetUInt32(); members.push_back(newmember); }while( result->NextRow() ); delete result; @@ -408,11 +390,11 @@ void ArenaTeam::Roster(WorldSession *session) data << uint32(itr->guid == GetCaptain() ? 0 : 1);// unknown data << uint8(pl->getLevel()); // unknown, probably level data << uint8(pl->getClass()); // class - data << uint32(itr->played_week); // played this week - data << uint32(itr->wons_week); // wins this week - data << uint32(itr->played_season); // played this season - data << uint32(itr->wons_season); // wins this season - data << uint32(pl->GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + GetSlot() * 6 + 5)); // personal rating? + data << uint32(itr->games_week); // played this week + data << uint32(itr->wins_week); // wins this week + data << uint32(itr->games_season); // played this season + data << uint32(itr->wins_season); // wins this season + data << uint32(itr->personal_rating); // personal rating } else { @@ -422,11 +404,11 @@ void ArenaTeam::Roster(WorldSession *session) data << uint32(itr->guid == GetCaptain() ? 0 : 1);// unknown data << uint8(0); // unknown, level? data << uint8(itr->Class); // class - data << uint32(itr->played_week); // played this week - data << uint32(itr->wons_week); // wins this week - data << uint32(itr->played_season); // played this season - data << uint32(itr->wons_season); // wins this season - data << uint32(Player::GetUInt32ValueFromDB(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + GetSlot() * 6 + 5, itr->guid)); // personal rating? + data << uint32(itr->games_week); // played this week + data << uint32(itr->wins_week); // wins this week + data << uint32(itr->games_season); // played this season + data << uint32(itr->wins_season); // wins this season + data << uint32(itr->personal_rating); // personal rating } } session->SendPacket(&data); @@ -453,10 +435,10 @@ void ArenaTeam::Stats(WorldSession *session) WorldPacket data(SMSG_ARENA_TEAM_STATS, 4*7); data << uint32(GetId()); // arena team id data << uint32(stats.rating); // rating - data << uint32(stats.games); // games - data << uint32(stats.wins); // wins - data << uint32(stats.played); // played - data << uint32(stats.wins2); // wins(again o_O) + data << uint32(stats.games_week); // games this week + data << uint32(stats.wins_week); // wins this week + data << uint32(stats.games_season); // played this season + data << uint32(stats.wins_season); // wins this season data << uint32(stats.rank); // rank session->SendPacket(&data); } @@ -475,25 +457,19 @@ void ArenaTeam::NotifyStatsChanged() void ArenaTeam::InspectStats(WorldSession *session, uint64 guid) { + ArenaTeamMember* member = GetMember(guid); + if(!member) + return; + WorldPacket data(MSG_INSPECT_ARENA_TEAMS, 8+1+4*6); data << uint64(guid); // player guid data << uint8(GetSlot()); // slot (0...2) data << uint32(GetId()); // arena team id data << uint32(stats.rating); // rating - data << uint32(stats.played); // season played - data << uint32(stats.wins2); // season wins - uint32 participated = 0; - for(MemberList::iterator itr = members.begin(); itr!= members.end(); ++itr) - { - if(itr->guid == guid) - { - participated = itr->played_season; - break; - } - } - data << uint32(participated); // played (count of all games, that the inspected member participated...) - data << uint32(Player::GetUInt32ValueFromDB(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + GetSlot() * 6 + 5, guid)); // unk, 2.3.3 (personal rating?) - + data << uint32(stats.games_season); // season played + data << uint32(stats.wins_season); // season wins + data << member->games_season; // played (count of all games, that the inspected member participated...) + data << member->personal_rating; // personal rating session->SendPacket(&data); } @@ -516,20 +492,20 @@ void ArenaTeam::SetStats(uint32 stat_type, uint32 value) stats.rating = value; CharacterDatabase.PExecute("UPDATE arena_team_stats SET rating = '%u' WHERE arenateamid = '%u'", value, GetId()); break; - case STAT_TYPE_GAMES: - stats.games = value; + case STAT_TYPE_GAMES_WEEK: + stats.games_week = value; CharacterDatabase.PExecute("UPDATE arena_team_stats SET games = '%u' WHERE arenateamid = '%u'", value, GetId()); break; - case STAT_TYPE_WINS: - stats.wins = value; + case STAT_TYPE_WINS_WEEK: + stats.wins_week = value; CharacterDatabase.PExecute("UPDATE arena_team_stats SET wins = '%u' WHERE arenateamid = '%u'", value, GetId()); break; - case STAT_TYPE_PLAYED: - stats.played = value; + case STAT_TYPE_GAMES_SEASON: + stats.games_season = value; CharacterDatabase.PExecute("UPDATE arena_team_stats SET played = '%u' WHERE arenateamid = '%u'", value, GetId()); break; - case STAT_TYPE_WINS2: - stats.wins2 = value; + case STAT_TYPE_WINS_SEASON: + stats.wins_season = value; CharacterDatabase.PExecute("UPDATE arena_team_stats SET wins2 = '%u' WHERE arenateamid = '%u'", value, GetId()); break; case STAT_TYPE_RANK: @@ -625,10 +601,10 @@ int32 ArenaTeam::WonAgainstChance(float chance) int32 mod = (int32)floor(32.0f * (1.0f - chance)); // modify the team stats accordingly stats.rating += mod; - stats.games += 1; - stats.wins += 1; - stats.played += 1; - stats.wins2 += 1; + stats.games_week += 1; + stats.wins_week += 1; + stats.games_season += 1; + stats.wins_season += 1; /* this should be done in .flusharenapoints; not a breaker though. uint32 higher_rank = 0; QueryResult *result = CharacterDatabase.PQuery("SELECT DISTINCT COUNT(arenateamid) FROM arena_team_stats WHERE rating > '%u' AND arenateamid <> '%u'",stats.rating, Id); @@ -649,8 +625,8 @@ int32 ArenaTeam::LostAgainstChance(float chance) int32 mod = (int32)ceil(32.0f * (0.0f - chance)); // modify the team stats accordingly stats.rating += mod; - stats.games += 1; - stats.played += 1; + stats.games_week += 1; + stats.games_season += 1; /* uint32 higher_rank = 0; QueryResult *result = CharacterDatabase.PQuery("SELECT DISTINCT COUNT (arenateamid) FROM arena_team_stats WHERE rating > '%u' AND arenateamid <> '%u'",stats.rating, Id); if(result) @@ -679,11 +655,11 @@ void ArenaTeam::MemberLost(Player * plr, uint32 againstrating) personalrating = 0; plr->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (GetSlot()*6) + 5, personalrating); // update personal played stats - itr->played_week +=1; - itr->played_season +=1; + itr->games_week +=1; + itr->games_season +=1; // update the unit fields - plr->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 6 * GetSlot() + 2, itr->played_week); - plr->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 6 * GetSlot() + 3, itr->played_season); + plr->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 6 * GetSlot() + 2, itr->games_week); + plr->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 6 * GetSlot() + 3, itr->games_season); return; } } @@ -705,13 +681,13 @@ void ArenaTeam::MemberWon(Player * plr, uint32 againstrating) personalrating = 0; plr->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (GetSlot()*6) + 5, personalrating); // update personal stats - itr->played_week +=1; - itr->played_season +=1; - itr->wons_season += 1; - itr->wons_week += 1; + itr->games_week +=1; + itr->games_season +=1; + itr->wins_season += 1; + itr->wins_week += 1; // update unit fields - plr->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 6 * GetSlot() + 2, itr->played_week); - plr->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 6 * GetSlot() + 3, itr->played_season); + plr->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 6 * GetSlot() + 2, itr->games_week); + plr->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 6 * GetSlot() + 3, itr->games_season); return; } } @@ -722,14 +698,14 @@ void ArenaTeam::UpdateArenaPointsHelper() // called after a match has ended and the stats are already modified // helper function for arena point distribution (this way, when distributing, no actual calculation is required, just a few comparisons) // 10 played games per week is a minimum - if(stats.games < 10) + if(stats.games_week < 10) return; // to get points, a player has to participate in at least 30% of the matches - uint32 min_plays = (uint32)ceil(stats.games * 0.3); + uint32 min_plays = (uint32)ceil(stats.games_week * 0.3); for(MemberList::iterator itr = members.begin(); itr != members.end(); ++itr) { // the player participated in enough games, update his points - if(itr->played_week >= min_plays) + if(itr->games_week >= min_plays) { // do it separately for online and offline players // online players might have modified personal rating in MemberLost/MemberWon, that's not already saved to DB because of asynch queries @@ -755,21 +731,21 @@ void ArenaTeam::SaveToDB() { // save team and member stats to db // called after a match has ended - CharacterDatabase.PExecute("UPDATE arena_team_stats SET rating = '%u',games = '%u',played = '%u',rank = '%u',wins = '%u',wins2 = '%u' WHERE arenateamid = '%u'", stats.rating, stats.games, stats.played, stats.rank, stats.wins, stats.wins2, GetId()); + CharacterDatabase.PExecute("UPDATE arena_team_stats SET rating = '%u',games = '%u',played = '%u',rank = '%u',wins = '%u',wins2 = '%u' WHERE arenateamid = '%u'", stats.rating, stats.games_week, stats.games_season, stats.rank, stats.wins_week, stats.wins_season, GetId()); for(MemberList::iterator itr = members.begin(); itr != members.end(); ++itr) { - CharacterDatabase.PExecute("UPDATE arena_team_member SET played_week = '%u', wons_week = '%u', played_season = '%u', wons_season = '%u' WHERE arenateamid = '%u' AND guid = '%u'", itr->played_week, itr->wons_week, itr->played_season, itr->wons_season, Id, itr->guid); + CharacterDatabase.PExecute("UPDATE arena_team_member SET games_week = '%u', wins_week = '%u', games_season = '%u', wins_season = '%u' WHERE arenateamid = '%u' AND guid = '%u'", itr->games_week, itr->wins_week, itr->games_season, itr->wins_season, Id, itr->guid); } } void ArenaTeam::FinishWeek() { - stats.games = 0; // played this week - stats.wins = 0; // wins this week + stats.games_week = 0; // played this week + stats.wins_week = 0; // wins this week for(MemberList::iterator itr = members.begin(); itr != members.end(); ++itr) { - itr->played_week = 0; - itr->wons_week = 0; + itr->games_week = 0; + itr->wins_week = 0; } } diff --git a/src/game/ArenaTeam.h b/src/game/ArenaTeam.h index 03cf5ccc7d4..2e6b3d5faee 100644 --- a/src/game/ArenaTeam.h +++ b/src/game/ArenaTeam.h @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef TRINITYCORE_ARENATEAM_H @@ -68,12 +68,12 @@ ERR_ARENA_TEAM_LEVEL_TOO_LOW_I enum ArenaTeamStatTypes { - STAT_TYPE_RATING = 0, - STAT_TYPE_GAMES = 1, - STAT_TYPE_WINS = 2, - STAT_TYPE_PLAYED = 3, - STAT_TYPE_WINS2 = 4, - STAT_TYPE_RANK = 5 + STAT_TYPE_RATING = 0, + STAT_TYPE_GAMES_WEEK = 1, + STAT_TYPE_WINS_WEEK = 2, + STAT_TYPE_GAMES_SEASON = 3, + STAT_TYPE_WINS_SEASON = 4, + STAT_TYPE_RANK = 5 }; enum ArenaTeamTypes @@ -90,19 +90,20 @@ struct ArenaTeamMember //uint32 unk2; //uint8 unk1; uint8 Class; - uint32 played_week; - uint32 wons_week; - uint32 played_season; - uint32 wons_season; + uint32 games_week; + uint32 wins_week; + uint32 games_season; + uint32 wins_season; + uint32 personal_rating; }; struct ArenaTeamStats { uint32 rating; - uint32 games; - uint32 wins; - uint32 played; - uint32 wins2; + uint32 games_week; + uint32 wins_week; + uint32 games_season; + uint32 wins_season; uint32 rank; }; @@ -125,7 +126,7 @@ class ArenaTeam static uint8 GetSlotByType(uint32 type); const uint64& GetCaptain() const { return CaptainGuid; } std::string GetName() const { return Name; } - ArenaTeamStats GetStats() const { return stats; } + const ArenaTeamStats& GetStats() const { return stats; } void SetStats(uint32 stat_type, uint32 value); uint32 GetRating() const { return stats.rating; } @@ -145,6 +146,14 @@ class ArenaTeam MemberList::iterator membersbegin(){ return members.begin(); } MemberList::iterator membersEnd(){ return members.end(); } bool HaveMember(uint64 guid) const; + ArenaTeamMember* GetMember(uint64 guid) + { + for (MemberList::iterator itr = members.begin(); itr != members.end(); ++itr) + if(itr->guid==guid) + return &(*itr); + + return NULL; + } bool LoadArenaTeamFromDB(uint32 ArenaTeamId); void LoadMembersFromDB(uint32 ArenaTeamId); diff --git a/src/game/BattleGround.cpp b/src/game/BattleGround.cpp index 772368841d1..098b5a0d28e 100644 --- a/src/game/BattleGround.cpp +++ b/src/game/BattleGround.cpp @@ -946,14 +946,21 @@ void BattleGround::AddPlayer(Player *plr) plr->RemoveArenaAuras(); plr->RemoveArenaSpellCooldowns(); plr->RemoveAllEnchantments(TEMP_ENCHANTMENT_SLOT); - if(team == ALLIANCE && plr->GetTeam() == ALLIANCE) - plr->CastSpell(plr,SPELL_ALLIANCE_GOLD_FLAG,true); - else if(team == HORDE && plr->GetTeam() == ALLIANCE) - plr->CastSpell(plr,SPELL_ALLIANCE_GREEN_FLAG,true); - else if(team == ALLIANCE && plr->GetTeam() == HORDE) - plr->CastSpell(plr,SPELL_HORDE_GOLD_FLAG,true); - else - plr->CastSpell(plr,SPELL_HORDE_GREEN_FLAG,true); + if(team == ALLIANCE) // gold + { + if(plr->GetTeam() == HORDE) + plr->CastSpell(plr, SPELL_HORDE_GOLD_FLAG,true); + else + plr->CastSpell(plr, SPELL_ALLIANCE_GOLD_FLAG,true); + } + else // green + { + if(plr->GetTeam() == HORDE) + plr->CastSpell(plr, SPELL_HORDE_GREEN_FLAG,true); + else + plr->CastSpell(plr, SPELL_ALLIANCE_GREEN_FLAG,true); + } + plr->DestroyConjuredItems(true); Pet* pet = plr->GetPet(); diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp index 42732a17d2b..40f3fb8e530 100644 --- a/src/game/CharacterHandler.cpp +++ b/src/game/CharacterHandler.cpp @@ -158,18 +158,20 @@ void WorldSession::HandleCharEnumOpcode( WorldPacket & /*recv_data*/ ) // ------- Query Without Declined Names -------- // 0 1 2 3 4 5 6 7 8 "SELECT characters.guid, characters.data, characters.name, characters.position_x, characters.position_y, characters.position_z, characters.map, characters.totaltime, characters.leveltime, " - // 9 10 11 12 - "characters.at_login, character_pet.entry, character_pet.modelid, character_pet.level " + // 9 10 11 12 13 + "characters.at_login, character_pet.entry, character_pet.modelid, character_pet.level, guild_member.guildid " "FROM characters LEFT JOIN character_pet ON characters.guid=character_pet.owner AND character_pet.slot='0' " + "LEFT JOIN guild_member ON characters.guid = guild_member.guid " "WHERE characters.account = '%u' ORDER BY characters.guid" : // --------- Query With Declined Names --------- // 0 1 2 3 4 5 6 7 8 "SELECT characters.guid, characters.data, characters.name, characters.position_x, characters.position_y, characters.position_z, characters.map, characters.totaltime, characters.leveltime, " - // 9 10 11 12 13 - "characters.at_login, character_pet.entry, character_pet.modelid, character_pet.level, genitive " + // 9 10 11 12 13 14 + "characters.at_login, character_pet.entry, character_pet.modelid, character_pet.level, guild_member.guildid, genitive " "FROM characters LEFT JOIN character_pet ON characters.guid = character_pet.owner AND character_pet.slot='0' " "LEFT JOIN character_declinedname ON characters.guid = character_declinedname.guid " + "LEFT JOIN guild_member ON characters.guid = guild_member.guid " "WHERE characters.account = '%u' ORDER BY characters.guid", GetAccountId()); } @@ -542,6 +544,22 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder) DEBUG_LOG( "WORLD: Sent motd (SMSG_MOTD)" ); } + //QueryResult *result = CharacterDatabase.PQuery("SELECT guildid,rank FROM guild_member WHERE guid = '%u'",pCurrChar->GetGUIDLow()); + QueryResult *resultGuild = holder->GetResult(PLAYER_LOGIN_QUERY_LOADGUILD); + + if(resultGuild) + { + Field *fields = resultGuild->Fetch(); + pCurrChar->SetInGuild(fields[0].GetUInt32()); + pCurrChar->SetRank(fields[1].GetUInt32()); + delete resultGuild; + } + else if(pCurrChar->GetGuildId()) // clear guild related fields in case wrong data about non existed membership + { + pCurrChar->SetInGuild(0); + pCurrChar->SetRank(0); + } + if(pCurrChar->GetGuildId() != 0) { Guild* guild = objmgr.GetGuildById(pCurrChar->GetGuildId()); @@ -569,8 +587,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder) { // remove wrong guild data sLog.outError("Player %s (GUID: %u) marked as member not existed guild (id: %u), removing guild membership for player.",pCurrChar->GetName(),pCurrChar->GetGUIDLow(),pCurrChar->GetGuildId()); - pCurrChar->SetUInt32Value(PLAYER_GUILDID,0); - pCurrChar->SetUInt32ValueInDB(PLAYER_GUILDID,0,pCurrChar->GetGUID()); + pCurrChar->SetInGuild(0); } } @@ -593,22 +610,6 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder) } } - //QueryResult *result = CharacterDatabase.PQuery("SELECT guildid,rank FROM guild_member WHERE guid = '%u'",pCurrChar->GetGUIDLow()); - QueryResult *resultGuild = holder->GetResult(PLAYER_LOGIN_QUERY_LOADGUILD); - - if(resultGuild) - { - Field *fields = resultGuild->Fetch(); - pCurrChar->SetInGuild(fields[0].GetUInt32()); - pCurrChar->SetRank(fields[1].GetUInt32()); - delete resultGuild; - } - else if(pCurrChar->GetGuildId()) // clear guild related fields in case wrong data about non existed membership - { - pCurrChar->SetInGuild(0); - pCurrChar->SetRank(0); - } - if (!pCurrChar->GetMap()->Add(pCurrChar)) { AreaTrigger const* at = objmgr.GetGoBackTrigger(pCurrChar->GetMapId()); @@ -750,7 +751,6 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder) if(sWorld.getConfig(CONFIG_START_ALL_TAXI)) pCurrChar->SetTaxiCheater(true); - if(pCurrChar->isGameMaster()) SendNotification(LANG_GM_ON); diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index e02f48e6134..e23059de8fa 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -1979,7 +1979,7 @@ bool Creature::IsOutOfThreatArea(Unit* pVictim) const if(!pVictim->isInAccessiblePlaceFor(this)) return true; - if(sMapStore.LookupEntry(GetMapId())->Instanceable()) + if(sMapStore.LookupEntry(GetMapId())->IsDungeon()) return false; float length = pVictim->GetDistance(CombatStartX,CombatStartY,CombatStartZ); diff --git a/src/game/Guild.cpp b/src/game/Guild.cpp index 2fe6b2108b2..a4ac81f3a40 100644 --- a/src/game/Guild.cpp +++ b/src/game/Guild.cpp @@ -151,17 +151,13 @@ bool Guild::AddMember(uint64 plGuid, uint32 plRank) CharacterDatabase.PExecute("INSERT INTO guild_member (guildid,guid,rank,pnote,offnote) VALUES ('%u', '%u', '%u','%s','%s')", Id, GUID_LOPART(plGuid), newmember.RankId, dbPnote.c_str(), dbOFFnote.c_str()); + // If player not in game data in data field will be loaded from guild tables, no need to update it!! if(pl) { pl->SetInGuild(Id); pl->SetRank(newmember.RankId); pl->SetGuildIdInvited(0); } - else - { - Player::SetUInt32ValueInDB(PLAYER_GUILDID, Id, plGuid); - Player::SetUInt32ValueInDB(PLAYER_GUILDRANK, newmember.RankId, plGuid); - } return true; } @@ -460,16 +456,15 @@ void Guild::DelMember(uint64 guid, bool isDisbanding) this->SetLeader(newLeaderGUID); newLeader = objmgr.GetPlayer(newLeaderGUID); + + // If player not online data in data field will be loaded from guild tabs no need to update it !! if(newLeader) { newLeader->SetRank(GR_GUILDMASTER); newLeaderName = newLeader->GetName(); } else - { - Player::SetUInt32ValueInDB(PLAYER_GUILDRANK, GR_GUILDMASTER, newLeaderGUID); objmgr.GetPlayerNameByGUID(newLeaderGUID, newLeaderName); - } // when leader non-exist (at guild load with deleted leader only) not send broadcasts if(objmgr.GetPlayerNameByGUID(guid, oldLeaderName)) @@ -500,16 +495,12 @@ void Guild::DelMember(uint64 guid, bool isDisbanding) members.erase(GUID_LOPART(guid)); Player *player = objmgr.GetPlayer(guid); + // If player not online data in data field will be loaded from guild tabs no need to update it !! if(player) { player->SetInGuild(0); player->SetRank(0); } - else - { - Player::SetUInt32ValueInDB(PLAYER_GUILDID, 0, guid); - Player::SetUInt32ValueInDB(PLAYER_GUILDRANK, GR_GUILDMASTER, guid); - } CharacterDatabase.PExecute("DELETE FROM guild_member WHERE guid = '%u'", GUID_LOPART(guid)); } @@ -521,10 +512,9 @@ void Guild::ChangeRank(uint64 guid, uint32 newRank) itr->second.RankId = newRank; Player *player = objmgr.GetPlayer(guid); + // If player not online data in data field will be loaded from guild tabs no need to update it !! if(player) player->SetRank(newRank); - else - Player::SetUInt32ValueInDB(PLAYER_GUILDRANK, newRank, guid); CharacterDatabase.PExecute( "UPDATE guild_member SET rank='%u' WHERE guid='%u'", newRank, GUID_LOPART(guid) ); } diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp index 0da6e1b74e4..e63a92c27b1 100644 --- a/src/game/MiscHandler.cpp +++ b/src/game/MiscHandler.cpp @@ -279,13 +279,6 @@ void WorldSession::HandleLogoutRequestOpcode( WorldPacket & /*recv_data*/ ) if (uint64 lguid = GetPlayer()->GetLootGUID()) DoLootRelease(lguid); - //instant logout for admins, gm's, mod's - if( GetSecurity() > SEC_PLAYER ) - { - LogoutPlayer(true); - return; - } - //Can not logout if... if( GetPlayer()->isInCombat() || //...is in combat GetPlayer()->duel || //...is in Duel @@ -302,8 +295,9 @@ void WorldSession::HandleLogoutRequestOpcode( WorldPacket & /*recv_data*/ ) return; } - //instant logout in taverns/cities or on taxi or if its enabled in Trinityd.conf - if(GetPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) || GetPlayer()->isInFlight() || sWorld.getConfig(CONFIG_INSTANT_LOGOUT)) + //instant logout in taverns/cities or on taxi or for admins, gm's, mod's if its enabled in mangosd.conf + if (GetPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) || GetPlayer()->isInFlight() || + GetSecurity() >= sWorld.getConfig(CONFIG_INSTANT_LOGOUT)) { LogoutPlayer(true); return; @@ -671,9 +665,9 @@ void WorldSession::HandleCorpseReclaimOpcode(WorldPacket &recv_data) if (GetPlayer()->isAlive()) return; - if (BattleGround * bg = _player->GetBattleGround()) - if(bg->isArena()) - return; + // do not allow corpse reclaim in arena + if (GetPlayer()->InArena()) + return; // body not released yet if(!GetPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index bdf9e0328f2..75f5ab8273e 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -7446,7 +7446,7 @@ void ObjectMgr::CheckScripts(ScriptMapMap const& scripts,std::set<int32>& ids) if(itrM->second.dataint) { if(!GetTrinityStringLocale (itrM->second.dataint)) - sLog.outErrorDb( "Table `db_script_string` has not existed string id %u", *itrM); + sLog.outErrorDb( "Table `db_script_string` has not existed string id %u", itrM->first); if(ids.count(itrM->second.dataint)) ids.erase(itrM->second.dataint); diff --git a/src/game/Player.cpp b/src/game/Player.cpp index b1dfb911c2b..783172a89d4 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -593,18 +593,14 @@ bool Player::Create( uint32 guidlow, std::string name, uint8 race, uint8 class_, SetUInt32Value( PLAYER_FIELD_YESTERDAY_CONTRIBUTION, 0 ); // set starting level - if(GetSession()->GetSecurity() >= SEC_MODERATOR) - SetUInt32Value( UNIT_FIELD_LEVEL, sWorld.getConfig(CONFIG_GM_START_LEVEL) ); + if (GetSession()->GetSecurity() >= SEC_MODERATOR) + SetUInt32Value (UNIT_FIELD_LEVEL, sWorld.getConfig(CONFIG_START_GM_LEVEL)); else - SetUInt32Value( UNIT_FIELD_LEVEL, sWorld.getConfig(CONFIG_START_PLAYER_LEVEL) ); - // set starting gold - SetUInt32Value( PLAYER_FIELD_COINAGE, sWorld.getConfig(CONFIG_PLAYER_START_GOLD) ); + SetUInt32Value (UNIT_FIELD_LEVEL, sWorld.getConfig(CONFIG_START_PLAYER_LEVEL)); - // set starting honor - SetUInt32Value( PLAYER_FIELD_HONOR_CURRENCY, sWorld.getConfig(CONFIG_PLAYER_START_HONOR) ); - - // set starting arena pts - SetUInt32Value( PLAYER_FIELD_ARENA_CURRENCY, sWorld.getConfig(CONFIG_PLAYER_START_ARENAPTS) ); + SetUInt32Value (PLAYER_FIELD_COINAGE, sWorld.getConfig(CONFIG_START_PLAYER_MONEY)); + SetUInt32Value (PLAYER_FIELD_HONOR_CURRENCY, sWorld.getConfig(CONFIG_START_HONOR_POINTS)); + SetUInt32Value (PLAYER_FIELD_ARENA_CURRENCY, sWorld.getConfig(CONFIG_START_ARENA_POINTS)); // start with every map explored if(sWorld.getConfig(CONFIG_START_ALL_EXPLORED)) @@ -883,8 +879,8 @@ void Player::HandleDrowning() if(!m_isunderwater) return; - //if players is GM, have waterbreath, dead or breathing is disabled - if(sWorld.getConfig(CONFIG_DISABLE_BREATHING) || waterbreath || isGameMaster() || !isAlive()) + //if player is GM, have waterbreath, is dead or if breathing is disabled then return + if(waterbreath || isGameMaster() || !isAlive() || GetSession()->GetSecurity() >= sWorld.getConfig(CONFIG_DISABLE_BREATHING)) { StopMirrorTimer(BREATH_TIMER); m_isunderwater = 0; @@ -1415,7 +1411,7 @@ void Player::BuildEnumData( QueryResult * result, WorldPacket * p_data ) *p_data << GetPositionY(); *p_data << GetPositionZ(); - *p_data << GetUInt32Value(PLAYER_GUILDID); // guild id + *p_data << (result ? result->Fetch()[13].GetUInt32() : 0); uint32 char_flags = 0; if(HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_HELM)) @@ -1428,7 +1424,7 @@ void Player::BuildEnumData( QueryResult * result, WorldPacket * p_data ) char_flags |= CHARACTER_FLAG_RENAME; // always send the flag if declined names aren't used // to let the client select a default method of declining the name - if(!sWorld.getConfig(CONFIG_DECLINED_NAMES_USED) || (result && result->Fetch()[13].GetCppString() != "")) + if(!sWorld.getConfig(CONFIG_DECLINED_NAMES_USED) || (result && result->Fetch()[14].GetCppString() != "")) char_flags |= CHARACTER_FLAG_DECLINED; *p_data << (uint32)char_flags; // character flags @@ -2245,7 +2241,7 @@ void Player::GiveLevel(uint32 level) if(getLevel()!= level) m_Played_time[1] = 0; // Level Played Time reset SetLevel(level); - UpdateMaxSkills(); + UpdateSkillsForLevel (); // save base values (bonuses already included in stored stats for(int i = STAT_STRENGTH; i < MAX_STATS; ++i) @@ -2321,7 +2317,7 @@ void Player::InitStatsForLevel(bool reapplyMods) SetUInt32Value(PLAYER_FIELD_MAX_LEVEL, sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL) ); SetUInt32Value(PLAYER_NEXT_LEVEL_XP, Trinity::XP::xp_to_level(getLevel())); - UpdateMaxSkills (); + UpdateSkillsForLevel (); // set default cast time multiplier SetFloatValue(UNIT_MOD_CAST_SPEED, 1.0f); @@ -3851,7 +3847,7 @@ void Player::ResurrectPlayer(float restore_percent, bool applySickness) // some items limited to specific map DestroyZoneLimitedItem( true, GetZoneId()); - if(!applySickness || getLevel() <= 10) + if(!applySickness) return; //Characters from level 1-10 are not affected by resurrection sickness. @@ -4972,9 +4968,12 @@ void Player::ModifySkillBonus(uint32 skillid,int32 val, bool talent) } } -void Player::UpdateMaxSkills() +void Player::UpdateSkillsForLevel() { uint16 maxconfskill = sWorld.GetConfigMaxSkillValue(); + uint32 maxSkill = GetMaxSkillValueForLevel(); + + bool alwaysMaxSkill = sWorld.getConfig(CONFIG_ALWAYS_MAX_SKILL_FOR_LEVEL); for (uint16 i=0; i < PLAYER_MAX_SKILLS; i++) if (GetUInt32Value(PLAYER_SKILL_INDEX(i))) @@ -4992,11 +4991,15 @@ void Player::UpdateMaxSkills() uint32 max = SKILL_MAX(data); uint32 val = SKILL_VALUE(data); - // update only level dependent max skill values - if(max!=1 && max != maxconfskill) + /// update only level dependent max skill values + if(max!=1) { - uint32 max_Skill = GetMaxSkillValueForLevel(); - SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i),MAKE_SKILL_VALUE(val,max_Skill)); + /// miximize skill always + if(alwaysMaxSkill) + SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i),MAKE_SKILL_VALUE(maxSkill,maxSkill)); + /// update max skill value if current max skill not maximized + else if(max != maxconfskill) + SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i),MAKE_SKILL_VALUE(val,maxSkill)); } } } @@ -6019,6 +6022,18 @@ void Player::UpdateHonorFields() ///An exact honor value can also be given (overriding the calcs) bool Player::RewardHonor(Unit *uVictim, uint32 groupsize, float honor, bool pvptoken) { + // do not reward honor in arenas, but enable onkill spellproc + if(InArena()) + { + if(!uVictim || uVictim == this || uVictim->GetTypeId() != TYPEID_PLAYER) + return false; + + if( GetBGTeam() == ((Player*)uVictim)->GetBGTeam() ) + return false; + + return true; + } + // 'Inactive' this aura prevents the player from gaining honor points and battleground tokens if(GetDummyAura(SPELL_AURA_PLAYER_INACTIVE)) return false; diff --git a/src/game/Player.h b/src/game/Player.h index 0f2b9fc0dd5..6aa91c6dfb9 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -1517,8 +1517,8 @@ class TRINITY_DLL_SPEC Player : public Unit void RemoveFromGroup() { RemoveFromGroup(GetGroup(),GetGUID()); } void SendUpdateToOutOfRangeGroupMembers(); - void SetInGuild(uint32 GuildId) { SetUInt32Value(PLAYER_GUILDID, GuildId); Player::SetUInt32ValueInDB(PLAYER_GUILDID, GuildId, GetGUID()); } - void SetRank(uint32 rankId){ SetUInt32Value(PLAYER_GUILDRANK, rankId); Player::SetUInt32ValueInDB(PLAYER_GUILDRANK, rankId, GetGUID()); } + void SetInGuild(uint32 GuildId) { SetUInt32Value(PLAYER_GUILDID, GuildId); } + void SetRank(uint32 rankId){ SetUInt32Value(PLAYER_GUILDRANK, rankId); } void SetGuildIdInvited(uint32 GuildId) { m_GuildIdInvited = GuildId; } uint32 GetGuildId() { return GetUInt32Value(PLAYER_GUILDID); } static uint32 GetGuildIdFromDB(uint64 guid); @@ -1726,7 +1726,7 @@ class TRINITY_DLL_SPEC Player : public Unit void SetFactionVisible(FactionState* faction); void SetFactionVisibleForFactionTemplateId(uint32 FactionTemplateId); void SetFactionVisibleForFactionId(uint32 FactionId); - void UpdateMaxSkills(); + void UpdateSkillsForLevel(); void UpdateSkillsToMaxSkillsForLevel(); // for .levelup void ModifySkillBonus(uint32 skillid,int32 val, bool talent); diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 1aa916f3f56..746336cdcce 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -2991,13 +2991,23 @@ void Spell::SendCastResult(uint8 result) break; case SPELL_FAILED_REQUIRES_AREA: // hardcode areas limitation case - if( m_spellInfo->Id==41618 || m_spellInfo->Id==41620 ) - data << uint32(3842); - else if( m_spellInfo->Id==41617 || m_spellInfo->Id==41619 ) - data << uint32(3905); - // normal case - else - data << uint32(m_spellInfo->AreaId); + switch(m_spellInfo->Id) + { + case 41617: // Cenarion Mana Salve + case 41619: // Cenarion Healing Salve + data << uint32(3905); + break; + case 41618: // Bottled Nethergon Energy + case 41620: // Bottled Nethergon Vapor + data << uint32(3842); + break; + case 45373: // Bloodberry Elixir + data << uint32(4075); + break; + default: // default case + data << uint32(m_spellInfo->AreaId); + break; + } break; case SPELL_FAILED_TOTEMS: if(m_spellInfo->Totem[0]) diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp index 1b6bd482468..8d17d94ec8e 100644 --- a/src/game/SpellMgr.cpp +++ b/src/game/SpellMgr.cpp @@ -2034,6 +2034,11 @@ bool IsSpellAllowedInLocation(SpellEntry const *spellInfo,uint32 map_id,uint32 z { if(uint32 mask = spellmgr.GetSpellElixirMask(spellInfo->Id)) { + if(mask & ELIXIR_BATTLE_MASK) + { + if(spellInfo->Id==45373) // Bloodberry Elixir + return zone_id==4075; + } if(mask & ELIXIR_UNSTABLE_MASK) { // in the Blade's Edge Mountains Plateaus and Gruul's Lair. @@ -2041,9 +2046,8 @@ bool IsSpellAllowedInLocation(SpellEntry const *spellInfo,uint32 map_id,uint32 z } if(mask & ELIXIR_SHATTRATH_MASK) { - // in Tempest Keep, Serpentshrine Cavern, Caverns of Time: Mount Hyjal, Black Temple - // TODO: and the Sunwell Plateau - if(zone_id ==3607 || map_id==534 || map_id==564) + // in Tempest Keep, Serpentshrine Cavern, Caverns of Time: Mount Hyjal, Black Temple, Sunwell Plateau + if(zone_id ==3607 || map_id==534 || map_id==564 || zone_id==4075) return true; MapEntry const* mapEntry = sMapStore.LookupEntry(map_id); @@ -2061,8 +2065,8 @@ bool IsSpellAllowedInLocation(SpellEntry const *spellInfo,uint32 map_id,uint32 z // special cases zone check (maps checked by multimap common id) switch(spellInfo->Id) { - case 41618: - case 41620: + case 41618: // Bottled Nethergon Energy + case 41620: // Bottled Nethergon Vapor { MapEntry const* mapEntry = sMapStore.LookupEntry(map_id); if(!mapEntry) @@ -2070,9 +2074,8 @@ bool IsSpellAllowedInLocation(SpellEntry const *spellInfo,uint32 map_id,uint32 z return mapEntry->multimap_id==206; } - - case 41617: - case 41619: + case 41617: // Cenarion Mana Salve + case 41619: // Cenarion Healing Salve { MapEntry const* mapEntry = sMapStore.LookupEntry(map_id); if(!mapEntry) @@ -2080,14 +2083,9 @@ bool IsSpellAllowedInLocation(SpellEntry const *spellInfo,uint32 map_id,uint32 z return mapEntry->multimap_id==207; } - // Dragonmaw Illusion - case 40216: - case 42016: - { - if ( area_id != 3759 && area_id != 3966 && area_id != 3939 ) - return false; - break; - } + case 40216: // Dragonmaw Illusion + case 42016: // Dragonmaw Illusion + return area_id == 3759 || area_id == 3966 || area_id == 3939; } return true; diff --git a/src/game/WaypointMovementGenerator.cpp b/src/game/WaypointMovementGenerator.cpp index 7969c375e81..3dc3ddebf42 100644 --- a/src/game/WaypointMovementGenerator.cpp +++ b/src/game/WaypointMovementGenerator.cpp @@ -52,7 +52,8 @@ WaypointMovementGenerator<Creature>::LoadPath(Creature &c) i_path = WaypointMgr.GetPath(c.GetDBTableGUIDLow()); if(!i_path) { - sLog.outErrorDb("WaypointMovementGenerator::LoadPath: creature %s(%d) doesn't have waypoint path", c.GetName(), c.GetDBTableGUIDLow()); + sLog.outErrorDb("WaypointMovementGenerator::LoadPath: creature %s (Entry: %u GUID: %d) doesn't have waypoint path", + c.GetName(), c.GetEntry(), c.GetDBTableGUIDLow()); return; } diff --git a/src/game/World.cpp b/src/game/World.cpp index 11236caa59e..ce733a035ec 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -116,10 +116,12 @@ World::World() World::~World() { ///- Empty the kicked session set - for (std::set<WorldSession*>::iterator itr = m_kicked_sessions.begin(); itr != m_kicked_sessions.end(); ++itr) - delete *itr; - - m_kicked_sessions.clear(); + while (!m_sessions.empty()) + { + // not remove from queue, prevent loading new sessions + delete m_sessions.begin()->second; + m_sessions.erase(m_sessions.begin()); + } ///- Empty the WeatherMap for (WeatherMap::iterator itr = m_weathers.begin(); itr != m_weathers.end(); ++itr) @@ -199,17 +201,26 @@ World::AddSession_ (WorldSession* s) if (!RemoveSession (s->GetAccountId ())) { s->KickPlayer (); - m_kicked_sessions.insert (s); + delete s; // session not added yet in session list, so not listed in queue return; } + // decrease session counts only at not reconnection case + bool decrease_session = true; + // if session already exist, prepare to it deleting at next world update // NOTE - KickPlayer() should be called on "old" in RemoveSession() { - SessionMap::const_iterator old = m_sessions.find(s->GetAccountId ()); + SessionMap::const_iterator old = m_sessions.find(s->GetAccountId ()); - if(old != m_sessions.end()) - m_kicked_sessions.insert (old->second); + if(old != m_sessions.end()) + { + // prevent decrease sessions count if session queued + if(RemoveQueuedPlayer(old->second)) + decrease_session = false; + // not remove replaced session form queue if listed + delete old->second; + } } m_sessions[s->GetAccountId ()] = s; @@ -217,10 +228,11 @@ World::AddSession_ (WorldSession* s) uint32 Sessions = GetActiveAndQueuedSessionCount (); uint32 pLimit = GetPlayerAmountLimit (); uint32 QueueSize = GetQueueSize (); //number of players in the queue - bool inQueue = false; + //so we don't count the user trying to //login as a session and queue the socket that we are using - --Sessions; + if(decrease_session) + --Sessions; if (pLimit > 0 && Sessions >= pLimit && s->GetSecurity () == SEC_PLAYER ) { @@ -264,6 +276,7 @@ int32 World::GetQueuePos(WorldSession* sess) void World::AddQueuedPlayer(WorldSession* sess) { + sess->SetInQueue(true); m_QueuedPlayer.push_back (sess); // The 1st SMSG_AUTH_RESPONSE needs to contain other info too. @@ -279,7 +292,7 @@ void World::AddQueuedPlayer(WorldSession* sess) //sess->SendAuthWaitQue (GetQueuePos (sess)); } -void World::RemoveQueuedPlayer(WorldSession* sess) +bool World::RemoveQueuedPlayer(WorldSession* sess) { // sessions count including queued to remove (if removed_session set) uint32 sessions = GetActiveSessionCount(); @@ -287,16 +300,16 @@ void World::RemoveQueuedPlayer(WorldSession* sess) uint32 position = 1; Queue::iterator iter = m_QueuedPlayer.begin(); - // if session not queued then we need decrease sessions count (Remove socked callet before session removing from session list) - bool decrease_session = true; - // search to remove and count skipped positions + bool found = false; + for(;iter != m_QueuedPlayer.end(); ++iter, ++position) { if(*iter==sess) { + sess->SetInQueue(false); iter = m_QueuedPlayer.erase(iter); - decrease_session = false; // removing queued session + found = true; // removing queued session break; } } @@ -304,15 +317,16 @@ void World::RemoveQueuedPlayer(WorldSession* sess) // iter point to next socked after removed or end() // position store position of removed socket and then new position next socket after removed - // decrease for case session queued for removing - if(decrease_session && sessions) + // if session not queued then we need decrease sessions count + if(!found && sessions) --sessions; // accept first in queue if( (!m_playerLimit || sessions < m_playerLimit) && !m_QueuedPlayer.empty() ) { - WorldSession * socket = m_QueuedPlayer.front(); - socket->SendAuthWaitQue(0); + WorldSession* pop_sess = m_QueuedPlayer.front(); + pop_sess->SetInQueue(false); + pop_sess->SendAuthWaitQue(0); m_QueuedPlayer.pop_front(); // update iter to point first queued socket or end() if queue is empty now @@ -324,6 +338,8 @@ void World::RemoveQueuedPlayer(WorldSession* sess) // iter point to first not updated socket, position store new position for(; iter != m_QueuedPlayer.end(); ++iter, ++position) (*iter)->SendAuthWaitQue(position); + + return found; } /// Find a Weather object by the given zoneid @@ -581,8 +597,6 @@ void World::LoadConfigSettings(bool reload) m_configs[CONFIG_CHARACTERS_CREATING_DISABLED] = sConfig.GetIntDefault("CharactersCreatingDisabled", 0); - m_configs[CONFIG_MAX_WHO] = sConfig.GetIntDefault("MaxWhoListReturns", 49); - m_configs[CONFIG_CHARACTERS_PER_REALM] = sConfig.GetIntDefault("CharactersPerRealm", 10); if(m_configs[CONFIG_CHARACTERS_PER_REALM] < 1 || m_configs[CONFIG_CHARACTERS_PER_REALM] > 10) { @@ -630,13 +644,70 @@ void World::LoadConfigSettings(bool reload) sLog.outError("StartPlayerLevel (%i) must be in range 1..MaxPlayerLevel(%u). Set to %u.",m_configs[CONFIG_START_PLAYER_LEVEL],m_configs[CONFIG_MAX_PLAYER_LEVEL],m_configs[CONFIG_MAX_PLAYER_LEVEL]); m_configs[CONFIG_START_PLAYER_LEVEL] = m_configs[CONFIG_MAX_PLAYER_LEVEL]; } + + m_configs[CONFIG_START_PLAYER_MONEY] = sConfig.GetIntDefault("StartPlayerMoney", 0); + if(m_configs[CONFIG_START_PLAYER_MONEY] < 0) + { + sLog.outError("StartPlayerMoney (%i) must be in range 0..%u. Set to %u.",m_configs[CONFIG_START_PLAYER_MONEY],MAX_MONEY_AMOUNT,0); + m_configs[CONFIG_START_PLAYER_MONEY] = 0; + } + else if(m_configs[CONFIG_START_PLAYER_MONEY] > MAX_MONEY_AMOUNT) + { + sLog.outError("StartPlayerMoney (%i) must be in range 0..%u. Set to %u.", + m_configs[CONFIG_START_PLAYER_MONEY],MAX_MONEY_AMOUNT,MAX_MONEY_AMOUNT); + m_configs[CONFIG_START_PLAYER_MONEY] = MAX_MONEY_AMOUNT; + } + m_configs[CONFIG_MAX_HONOR_POINTS] = sConfig.GetIntDefault("MaxHonorPoints", 75000); + if(m_configs[CONFIG_MAX_HONOR_POINTS] < 0) + { + sLog.outError("MaxHonorPoints (%i) can't be negative. Set to 0.",m_configs[CONFIG_MAX_HONOR_POINTS]); + m_configs[CONFIG_MAX_HONOR_POINTS] = 0; + } + + m_configs[CONFIG_START_HONOR_POINTS] = sConfig.GetIntDefault("StartHonorPoints", 0); + if(m_configs[CONFIG_START_HONOR_POINTS] < 0) + { + sLog.outError("StartHonorPoints (%i) must be in range 0..MaxHonorPoints(%u). Set to %u.", + m_configs[CONFIG_START_HONOR_POINTS],m_configs[CONFIG_MAX_HONOR_POINTS],0); + m_configs[CONFIG_MAX_HONOR_POINTS] = 0; + } + else if(m_configs[CONFIG_START_HONOR_POINTS] > m_configs[CONFIG_MAX_HONOR_POINTS]) + { + sLog.outError("StartHonorPoints (%i) must be in range 0..MaxHonorPoints(%u). Set to %u.", + m_configs[CONFIG_START_HONOR_POINTS],m_configs[CONFIG_MAX_HONOR_POINTS],m_configs[CONFIG_MAX_HONOR_POINTS]); + m_configs[CONFIG_START_HONOR_POINTS] = m_configs[CONFIG_MAX_HONOR_POINTS]; + } + m_configs[CONFIG_MAX_ARENA_POINTS] = sConfig.GetIntDefault("MaxArenaPoints", 5000); + if(m_configs[CONFIG_MAX_ARENA_POINTS] < 0) + { + sLog.outError("MaxArenaPoints (%i) can't be negative. Set to 0.",m_configs[CONFIG_MAX_ARENA_POINTS]); + m_configs[CONFIG_MAX_ARENA_POINTS] = 0; + } + + m_configs[CONFIG_START_ARENA_POINTS] = sConfig.GetIntDefault("StartArenaPoints", 0); + if(m_configs[CONFIG_START_ARENA_POINTS] < 0) + { + sLog.outError("StartArenaPoints (%i) must be in range 0..MaxArenaPoints(%u). Set to %u.", + m_configs[CONFIG_START_ARENA_POINTS],m_configs[CONFIG_MAX_ARENA_POINTS],0); + m_configs[CONFIG_MAX_ARENA_POINTS] = 0; + } + else if(m_configs[CONFIG_START_ARENA_POINTS] > m_configs[CONFIG_MAX_ARENA_POINTS]) + { + sLog.outError("StartArenaPoints (%i) must be in range 0..MaxArenaPoints(%u). Set to %u.", + m_configs[CONFIG_START_ARENA_POINTS],m_configs[CONFIG_MAX_ARENA_POINTS],m_configs[CONFIG_MAX_ARENA_POINTS]); + m_configs[CONFIG_START_ARENA_POINTS] = m_configs[CONFIG_MAX_ARENA_POINTS]; + } + + m_configs[CONFIG_ALL_TAXI_PATHS] = sConfig.GetBoolDefault("AllFlightPaths", false); m_configs[CONFIG_INSTANCE_IGNORE_LEVEL] = sConfig.GetBoolDefault("Instance.IgnoreLevel", false); m_configs[CONFIG_INSTANCE_IGNORE_RAID] = sConfig.GetBoolDefault("Instance.IgnoreRaid", false); m_configs[CONFIG_BATTLEGROUND_CAST_DESERTER] = sConfig.GetBoolDefault("Battleground.CastDeserter", true); + m_configs[CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE] = sConfig.GetBoolDefault("Battleground.QueueAnnouncer.Enable", true); + m_configs[CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_PLAYERONLY] = sConfig.GetBoolDefault("Battleground.QueueAnnouncer.PlayerOnly", false); m_configs[CONFIG_CAST_UNSTUCK] = sConfig.GetBoolDefault("CastUnstuck", true); m_configs[CONFIG_INSTANCE_RESET_TIME_HOUR] = sConfig.GetIntDefault("Instance.ResetTimeHour", 4); @@ -659,6 +730,19 @@ void World::LoadConfigSettings(bool reload) m_configs[CONFIG_GM_IN_WHO_LIST] = sConfig.GetBoolDefault("GM.InWhoList",false); m_configs[CONFIG_GM_LOG_TRADE] = sConfig.GetBoolDefault("GM.LogTrade", false); + m_configs[CONFIG_START_GM_LEVEL] = sConfig.GetIntDefault("GM.StartLevel", 1); + if(m_configs[CONFIG_START_GM_LEVEL] < m_configs[CONFIG_START_PLAYER_LEVEL]) + { + sLog.outError("GM.StartLevel (%i) must be in range StartPlayerLevel(%u)..255. Set to %u.", + m_configs[CONFIG_START_GM_LEVEL],m_configs[CONFIG_START_PLAYER_LEVEL],m_configs[CONFIG_START_PLAYER_LEVEL]); + m_configs[CONFIG_START_GM_LEVEL] = m_configs[CONFIG_START_PLAYER_LEVEL]; + } + else if(m_configs[CONFIG_START_GM_LEVEL] > 255) + { + sLog.outError("GM.StartLevel (%i) must be in range 1..255. Set to %u.",m_configs[CONFIG_START_GM_LEVEL],255); + m_configs[CONFIG_START_GM_LEVEL] = 255; + } + m_configs[CONFIG_GROUP_VISIBILITY] = sConfig.GetIntDefault("Visibility.GroupMode",0); m_configs[CONFIG_MAIL_DELIVERY_DELAY] = sConfig.GetIntDefault("MailDeliveryDelay",HOUR); @@ -723,6 +807,10 @@ void World::LoadConfigSettings(bool reload) m_configs[CONFIG_SAVE_RESPAWN_TIME_IMMEDIATELY] = sConfig.GetBoolDefault("SaveRespawnTimeImmediately",true); m_configs[CONFIG_WEATHER] = sConfig.GetBoolDefault("ActivateWeather",true); + m_configs[CONFIG_DISABLE_BREATHING] = sConfig.GetIntDefault("DisableWaterBreath", SEC_CONSOLE); + + m_configs[CONFIG_ALWAYS_MAX_SKILL_FOR_LEVEL] = sConfig.GetBoolDefault("AlwaysMaxSkillForLevel", false); + if(reload) { uint32 val = sConfig.GetIntDefault("Expansion",1); @@ -751,6 +839,8 @@ void World::LoadConfigSettings(bool reload) if(m_configs[CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF] > 255) m_configs[CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF] = 255; + m_configs[CONFIG_DETECT_POS_COLLISION] = sConfig.GetBoolDefault("DetectPosCollision", true); + m_configs[CONFIG_RESTRICTED_LFG_CHANNEL] = sConfig.GetBoolDefault("Channel.RestrictedLfg", true); m_configs[CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL] = sConfig.GetBoolDefault("Channel.SilentlyGMJoin", false); @@ -777,48 +867,7 @@ void World::LoadConfigSettings(bool reload) m_configs[CONFIG_LISTEN_RANGE_TEXTEMOTE] = sConfig.GetIntDefault("ListenRange.TextEmote", 25); m_configs[CONFIG_LISTEN_RANGE_YELL] = sConfig.GetIntDefault("ListenRange.Yell", 300); - m_configs[CONFIG_PLAYER_START_GOLD] = (uint32)(sConfig.GetFloatDefault("PlayerStart.Gold", 0.0f) * 10000.0f); - - if(m_configs[CONFIG_PLAYER_START_GOLD] > MAX_MONEY_AMOUNT) - m_configs[CONFIG_PLAYER_START_GOLD] = MAX_MONEY_AMOUNT; - - m_configs[CONFIG_PLAYER_START_HONOR] = sConfig.GetIntDefault("PlayerStart.HonorPoints", 0); - if(m_configs[CONFIG_PLAYER_START_HONOR] < 0) - m_configs[CONFIG_PLAYER_START_HONOR] = 0; - - m_configs[CONFIG_PLAYER_START_ARENAPTS] = sConfig.GetIntDefault("PlayerStart.ArenaPoints", 0); - if(m_configs[CONFIG_PLAYER_START_ARENAPTS] < 0) - m_configs[CONFIG_PLAYER_START_ARENAPTS] = 0; - - m_configs[CONFIG_GM_START_LEVEL] = sConfig.GetIntDefault("GamemasterStartLevel", 1); - if(m_configs[CONFIG_GM_START_LEVEL] < 1) - m_configs[CONFIG_GM_START_LEVEL] = 1; - - m_configs[CONFIG_INSTANT_LOGOUT] = sConfig.GetBoolDefault("PlayerInstantLogout", false); - m_configs[CONFIG_BG_START_MUSIC] = sConfig.GetBoolDefault("MusicInBattleground", false); - m_configs[CONFIG_START_ALL_SPELLS] = sConfig.GetBoolDefault("PlayerStart.AllSpells", false); - m_configs[CONFIG_HONOR_AFTER_DUEL] = sConfig.GetIntDefault("HonorPointsAfterDuel", 0); - if(m_configs[CONFIG_HONOR_AFTER_DUEL] < 0) - m_configs[CONFIG_HONOR_AFTER_DUEL]= 0; - m_configs[CONFIG_START_ALL_EXPLORED] = sConfig.GetBoolDefault("PlayerStart.MapsExplored", false); - m_configs[CONFIG_DISABLE_BREATHING] = sConfig.GetBoolDefault("DisableWaterBreath", false); - m_configs[CONFIG_START_ALL_REP] = sConfig.GetBoolDefault("PlayerStart.AllReputation", false); - m_configs[CONFIG_ALWAYS_MAXSKILL] = sConfig.GetBoolDefault("AlwaysMaxWeaponSkill", false); - m_configs[CONFIG_START_ALL_TAXI] = sConfig.GetBoolDefault("PlayerStart.AllFlightPaths", false); - m_configs[CONFIG_PVP_TOKEN_ENABLE] = sConfig.GetBoolDefault("PvPToken.Enable", false); - m_configs[CONFIG_PVP_TOKEN_MAP_TYPE] = sConfig.GetIntDefault("PvPToken.MapAllowType", 4); - m_configs[CONFIG_PVP_TOKEN_ID] = sConfig.GetIntDefault("PvPToken.ItemID", 29434); - m_configs[CONFIG_PVP_TOKEN_COUNT] = sConfig.GetIntDefault("PvPToken.ItemCount", 1); - if(m_configs[CONFIG_PVP_TOKEN_COUNT] < 1) - m_configs[CONFIG_PVP_TOKEN_COUNT] = 1; - m_configs[CONFIG_NO_RESET_TALENT_COST] = sConfig.GetBoolDefault("NoResetTalentsCost", false); - - m_configs[CONFIG_ARENA_MAX_RATING_DIFFERENCE] = sConfig.GetIntDefault("Arena.MaxRatingDifference", 0); - m_configs[CONFIG_ARENA_RATING_DISCARD_TIMER] = sConfig.GetIntDefault("Arena.RatingDiscardTimer",300000); - m_configs[CONFIG_ARENA_AUTO_DISTRIBUTE_POINTS] = sConfig.GetBoolDefault("Arena.AutoDistributePoints", false); - m_configs[CONFIG_ARENA_AUTO_DISTRIBUTE_INTERVAL_DAYS] = sConfig.GetIntDefault("Arena.AutoDistributeInterval", 7); - - m_configs[CONFIG_BATTLEGROUND_PREMATURE_FINISH_TIMER] = sConfig.GetIntDefault("BattleGround.PrematureFinishTimer", 0); + m_configs[CONFIG_INSTANT_LOGOUT] = sConfig.GetIntDefault("InstantLogout", SEC_MODERATOR); m_VisibleUnitGreyDistance = sConfig.GetFloatDefault("Visibility.Distance.Grey.Unit", 1); if(m_VisibleUnitGreyDistance > MAX_VISIBILITY_DISTANCE) @@ -889,6 +938,63 @@ void World::LoadConfigSettings(bool reload) sLog.outString("Using DataDir %s",m_dataPath.c_str()); } + bool enableLOS = sConfig.GetBoolDefault("vmap.enableLOS", false); + bool enableHeight = sConfig.GetBoolDefault("vmap.enableHeight", false); + std::string ignoreMapIds = sConfig.GetStringDefault("vmap.ignoreMapIds", ""); + std::string ignoreSpellIds = sConfig.GetStringDefault("vmap.ignoreSpellIds", ""); + VMAP::VMapFactory::createOrGetVMapManager()->setEnableLineOfSightCalc(enableLOS); + VMAP::VMapFactory::createOrGetVMapManager()->setEnableHeightCalc(enableHeight); + VMAP::VMapFactory::createOrGetVMapManager()->preventMapsFromBeingUsed(ignoreMapIds.c_str()); + VMAP::VMapFactory::preventSpellsFromBeingTestedForLoS(ignoreSpellIds.c_str()); + sLog.outString( "WORLD: VMap support included. LineOfSight:%i, getHeight:%i",enableLOS, enableHeight); + sLog.outString( "WORLD: VMap data directory is: %svmaps",m_dataPath.c_str()); + sLog.outString( "WORLD: VMap config keys are: vmap.enableLOS, vmap.enableHeight, vmap.ignoreMapIds, vmap.ignoreSpellIds"); + + + m_configs[CONFIG_MAX_WHO] = sConfig.GetIntDefault("MaxWhoListReturns", 49); + + m_configs[CONFIG_PLAYER_START_GOLD] = (uint32)(sConfig.GetFloatDefault("PlayerStart.Gold", 0.0f) * 10000.0f); + + if(m_configs[CONFIG_PLAYER_START_GOLD] > MAX_MONEY_AMOUNT) + m_configs[CONFIG_PLAYER_START_GOLD] = MAX_MONEY_AMOUNT; + + m_configs[CONFIG_PLAYER_START_HONOR] = sConfig.GetIntDefault("PlayerStart.HonorPoints", 0); + if(m_configs[CONFIG_PLAYER_START_HONOR] < 0) + m_configs[CONFIG_PLAYER_START_HONOR] = 0; + + m_configs[CONFIG_PLAYER_START_ARENAPTS] = sConfig.GetIntDefault("PlayerStart.ArenaPoints", 0); + if(m_configs[CONFIG_PLAYER_START_ARENAPTS] < 0) + m_configs[CONFIG_PLAYER_START_ARENAPTS] = 0; + + m_configs[CONFIG_GM_START_LEVEL] = sConfig.GetIntDefault("GamemasterStartLevel", 1); + if(m_configs[CONFIG_GM_START_LEVEL] < 1) + m_configs[CONFIG_GM_START_LEVEL] = 1; + + m_configs[CONFIG_BG_START_MUSIC] = sConfig.GetBoolDefault("MusicInBattleground", false); + m_configs[CONFIG_START_ALL_SPELLS] = sConfig.GetBoolDefault("PlayerStart.AllSpells", false); + m_configs[CONFIG_HONOR_AFTER_DUEL] = sConfig.GetIntDefault("HonorPointsAfterDuel", 0); + if(m_configs[CONFIG_HONOR_AFTER_DUEL] < 0) + m_configs[CONFIG_HONOR_AFTER_DUEL]= 0; + m_configs[CONFIG_START_ALL_EXPLORED] = sConfig.GetBoolDefault("PlayerStart.MapsExplored", false); + m_configs[CONFIG_DISABLE_BREATHING] = sConfig.GetBoolDefault("DisableWaterBreath", false); + m_configs[CONFIG_START_ALL_REP] = sConfig.GetBoolDefault("PlayerStart.AllReputation", false); + m_configs[CONFIG_ALWAYS_MAXSKILL] = sConfig.GetBoolDefault("AlwaysMaxWeaponSkill", false); + m_configs[CONFIG_START_ALL_TAXI] = sConfig.GetBoolDefault("PlayerStart.AllFlightPaths", false); + m_configs[CONFIG_PVP_TOKEN_ENABLE] = sConfig.GetBoolDefault("PvPToken.Enable", false); + m_configs[CONFIG_PVP_TOKEN_MAP_TYPE] = sConfig.GetIntDefault("PvPToken.MapAllowType", 4); + m_configs[CONFIG_PVP_TOKEN_ID] = sConfig.GetIntDefault("PvPToken.ItemID", 29434); + m_configs[CONFIG_PVP_TOKEN_COUNT] = sConfig.GetIntDefault("PvPToken.ItemCount", 1); + if(m_configs[CONFIG_PVP_TOKEN_COUNT] < 1) + m_configs[CONFIG_PVP_TOKEN_COUNT] = 1; + m_configs[CONFIG_NO_RESET_TALENT_COST] = sConfig.GetBoolDefault("NoResetTalentsCost", false); + + m_configs[CONFIG_ARENA_MAX_RATING_DIFFERENCE] = sConfig.GetIntDefault("Arena.MaxRatingDifference", 0); + m_configs[CONFIG_ARENA_RATING_DISCARD_TIMER] = sConfig.GetIntDefault("Arena.RatingDiscardTimer",300000); + m_configs[CONFIG_ARENA_AUTO_DISTRIBUTE_POINTS] = sConfig.GetBoolDefault("Arena.AutoDistributePoints", false); + m_configs[CONFIG_ARENA_AUTO_DISTRIBUTE_INTERVAL_DAYS] = sConfig.GetIntDefault("Arena.AutoDistributeInterval", 7); + + m_configs[CONFIG_BATTLEGROUND_PREMATURE_FINISH_TIMER] = sConfig.GetIntDefault("BattleGround.PrematureFinishTimer", 0); + std::string forbiddenmaps = sConfig.GetStringDefault("ForbiddenMaps", ""); char * forbiddenMaps = new char[forbiddenmaps.length() + 1]; forbiddenMaps[forbiddenmaps.length()] = 0; @@ -902,18 +1008,6 @@ void World::LoadConfigSettings(bool reload) token = strtok(NULL,delim); } delete[] forbiddenMaps; - - bool enableLOS = sConfig.GetBoolDefault("vmap.enableLOS", false); - bool enableHeight = sConfig.GetBoolDefault("vmap.enableHeight", false); - std::string ignoreMapIds = sConfig.GetStringDefault("vmap.ignoreMapIds", ""); - std::string ignoreSpellIds = sConfig.GetStringDefault("vmap.ignoreSpellIds", ""); - VMAP::VMapFactory::createOrGetVMapManager()->setEnableLineOfSightCalc(enableLOS); - VMAP::VMapFactory::createOrGetVMapManager()->setEnableHeightCalc(enableHeight); - VMAP::VMapFactory::createOrGetVMapManager()->preventMapsFromBeingUsed(ignoreMapIds.c_str()); - VMAP::VMapFactory::preventSpellsFromBeingTestedForLoS(ignoreSpellIds.c_str()); - sLog.outString( "WORLD: VMap support included. LineOfSight:%i, getHeight:%i",enableLOS, enableHeight); - sLog.outString( "WORLD: VMap data directory is: %svmaps",m_dataPath.c_str()); - sLog.outString( "WORLD: VMap config keys are: vmap.enableLOS, vmap.enableHeight, vmap.ignoreMapIds, vmap.ignoreSpellIds"); } /// Initialize the World @@ -2238,6 +2332,8 @@ void World::SendZoneText(uint32 zone, const char* text, WorldSession *self, uint /// Kick (and save) all players void World::KickAll() { + m_QueuedPlayer.clear(); // prevent send queue update packet and login queued sessions + // session not removed at kick and will removed in next update tick for (SessionMap::iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr) itr->second->KickPlayer(); @@ -2252,18 +2348,6 @@ void World::KickAllLess(AccountTypes sec) itr->second->KickPlayer(); } -/// Kick all queued players -void World::KickAllQueued() -{ - // session not removed at kick and will removed in next update tick - //TODO here -// for (Queue::iterator itr = m_QueuedPlayer.begin(); itr != m_QueuedPlayer.end(); ++itr) -// if(WorldSession* session = (*itr)->GetSession()) -// session->KickPlayer(); - - m_QueuedPlayer.empty(); -} - /// Kick (and save) the designated player bool World::KickPlayer(std::string playerName) { @@ -2494,19 +2578,12 @@ void World::SendServerMessage(uint32 type, const char *text, Player* player) void World::UpdateSessions( time_t diff ) { + ///- Add new sessions while(!addSessQueue.empty()) { - WorldSession* sess = addSessQueue.next (); - AddSession_ (sess); - } - - ///- Delete kicked sessions at add new session - for (std::set<WorldSession*>::iterator itr = m_kicked_sessions.begin(); itr != m_kicked_sessions.end(); ++itr) - { - RemoveQueuedPlayer (*itr); - delete *itr; + WorldSession* sess = addSessQueue.next (); + AddSession_ (sess); } - m_kicked_sessions.clear(); ///- Then send an update signal to remaining ones for (SessionMap::iterator itr = m_sessions.begin(), next; itr != m_sessions.end(); itr = next) diff --git a/src/game/World.h b/src/game/World.h index 2be2360728d..3784f0a3cf0 100644 --- a/src/game/World.h +++ b/src/game/World.h @@ -100,14 +100,16 @@ enum WorldConfigs CONFIG_STRICT_CHARTER_NAMES, CONFIG_STRICT_PET_NAMES, CONFIG_CHARACTERS_CREATING_DISABLED, - CONFIG_MAX_WHO, CONFIG_CHARACTERS_PER_ACCOUNT, CONFIG_CHARACTERS_PER_REALM, CONFIG_SKIP_CINEMATICS, CONFIG_MAX_PLAYER_LEVEL, CONFIG_START_PLAYER_LEVEL, + CONFIG_START_PLAYER_MONEY, CONFIG_MAX_HONOR_POINTS, + CONFIG_START_HONOR_POINTS, CONFIG_MAX_ARENA_POINTS, + CONFIG_START_ARENA_POINTS, CONFIG_INSTANCE_IGNORE_LEVEL, CONFIG_INSTANCE_IGNORE_RAID, CONFIG_BATTLEGROUND_CAST_DESERTER, @@ -125,6 +127,7 @@ enum WorldConfigs CONFIG_GM_IN_GM_LIST, CONFIG_GM_IN_WHO_LIST, CONFIG_GM_LOG_TRADE, + CONFIG_START_GM_LEVEL, CONFIG_GROUP_VISIBILITY, CONFIG_MAIL_DELIVERY_DELAY, CONFIG_UPTIME_UPDATE, @@ -141,6 +144,7 @@ enum WorldConfigs CONFIG_SKILL_GAIN_WEAPON, CONFIG_MAX_OVERSPEED_PINGS, CONFIG_SAVE_RESPAWN_TIME_IMMEDIATELY, + CONFIG_ALWAYS_MAX_SKILL_FOR_LEVEL, CONFIG_WEATHER, CONFIG_EXPANSION, CONFIG_CHATFLOOD_MESSAGE_COUNT, @@ -166,17 +170,27 @@ enum WorldConfigs CONFIG_DEATH_SICKNESS_LEVEL, CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVP, CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVE, + CONFIG_THREAT_RADIUS, + CONFIG_INSTANT_LOGOUT, + CONFIG_DISABLE_BREATHING, + CONFIG_ALL_TAXI_PATHS, + CONFIG_DECLINED_NAMES_USED, + CONFIG_LISTEN_RANGE_SAY, + CONFIG_LISTEN_RANGE_TEXTEMOTE, + CONFIG_LISTEN_RANGE_YELL, + CONFIG_VALUE_COUNT, + CONFIG_MAX_WHO, CONFIG_PLAYER_START_GOLD, CONFIG_PLAYER_START_HONOR, CONFIG_PLAYER_START_ARENAPTS, CONFIG_GM_START_LEVEL, - CONFIG_INSTANT_LOGOUT, + CONFIG_BG_START_MUSIC, CONFIG_START_ALL_SPELLS, CONFIG_HONOR_AFTER_DUEL, CONFIG_START_ALL_EXPLORED, - CONFIG_DISABLE_BREATHING, + CONFIG_START_ALL_REP, CONFIG_ALWAYS_MAXSKILL, CONFIG_START_ALL_TAXI, @@ -186,17 +200,11 @@ enum WorldConfigs CONFIG_PVP_TOKEN_COUNT, CONFIG_NO_RESET_TALENT_COST, - CONFIG_THREAT_RADIUS, - CONFIG_DECLINED_NAMES_USED, - CONFIG_LISTEN_RANGE_SAY, - CONFIG_LISTEN_RANGE_TEXTEMOTE, - CONFIG_LISTEN_RANGE_YELL, CONFIG_ARENA_MAX_RATING_DIFFERENCE, CONFIG_ARENA_RATING_DISCARD_TIMER, CONFIG_ARENA_AUTO_DISTRIBUTE_POINTS, CONFIG_ARENA_AUTO_DISTRIBUTE_INTERVAL_DAYS, CONFIG_BATTLEGROUND_PREMATURE_FINISH_TIMER, - CONFIG_VALUE_COUNT }; /// Server rates @@ -378,7 +386,7 @@ class World //player Queue typedef std::list<WorldSession*> Queue; void AddQueuedPlayer(WorldSession*); - void RemoveQueuedPlayer(WorldSession*); + bool RemoveQueuedPlayer(WorldSession* session); int32 GetQueuePos(WorldSession*); uint32 GetQueueSize() const { return m_QueuedPlayer.size(); } @@ -461,7 +469,6 @@ class World bool KickPlayer(std::string playerName); void KickAll(); void KickAllLess(AccountTypes sec); - void KickAllQueued(); BanReturn BanAccount(BanMode mode, std::string nameOrIP, std::string duration, std::string reason, std::string author); bool RemoveBanAccount(BanMode mode, std::string nameOrIP); @@ -523,7 +530,6 @@ class World WeatherMap m_weathers; typedef UNORDERED_MAP<uint32, WorldSession*> SessionMap; SessionMap m_sessions; - std::set<WorldSession*> m_kicked_sessions; uint32 m_maxActiveSessionCount; uint32 m_maxQueuedSessionCount; diff --git a/src/game/WorldSession.cpp b/src/game/WorldSession.cpp index 69f1598d743..eeb7d41efb6 100644 --- a/src/game/WorldSession.cpp +++ b/src/game/WorldSession.cpp @@ -48,7 +48,7 @@ WorldSession::WorldSession(uint32 id, WorldSocket *sock, uint32 sec, uint8 expan LookingForGroup_auto_join(false), LookingForGroup_auto_add(false), m_muteTime(mute_time), _player(NULL), m_Socket(sock),_security(sec), _accountId(id), m_expansion(expansion), m_sessionDbcLocale(sWorld.GetAvailableDbcLocale(locale)), m_sessionDbLocaleIndex(objmgr.GetIndexForLocale(locale)), -_logoutTime(0), m_playerLoading(false), m_playerLogout(false), m_playerRecentlyLogout(false), m_latency(0) +_logoutTime(0), m_inQueue(false), m_playerLoading(false), m_playerLogout(false), m_playerRecentlyLogout(false), m_latency(0) { if (sock) { @@ -208,6 +208,13 @@ bool WorldSession::Update(uint32 /*diff*/) (this->*opHandle.handler)(*packet); break; case STATUS_AUTHED: + // prevent cheating with skip queue wait + if(m_inQueue) + { + logUnexpectedOpcode(packet, "the player not pass queue yet"); + break; + } + m_playerRecentlyLogout = false; (this->*opHandle.handler)(*packet); break; diff --git a/src/game/WorldSession.h b/src/game/WorldSession.h index 27391ae9618..c9f98765092 100644 --- a/src/game/WorldSession.h +++ b/src/game/WorldSession.h @@ -98,6 +98,9 @@ class TRINITY_DLL_SPEC WorldSession void SetPlayer(Player *plr) { _player = plr; } uint8 Expansion() const { return m_expansion; } + /// Session in auth.queue currently + void SetInQueue(bool state) { m_inQueue = state; } + /// Is the user engaged in a log out process? bool isLogingOut() const { return _logoutTime || m_playerLogout; } @@ -639,6 +642,7 @@ class TRINITY_DLL_SPEC WorldSession uint8 m_expansion; time_t _logoutTime; + bool m_inQueue; // session wait in auth.queue bool m_playerLoading; // code processed in LoginPlayer bool m_playerLogout; // code processed in LogoutPlayer bool m_playerRecentlyLogout; |
