aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game/BattleGround.cpp29
-rw-r--r--src/game/BattleGround.h2
-rw-r--r--src/game/CharacterHandler.cpp2
-rw-r--r--src/game/MovementHandler.cpp36
-rw-r--r--src/game/Player.cpp116
-rw-r--r--src/game/WorldSession.cpp4
-rw-r--r--src/mangosd/Master.cpp3
-rw-r--r--src/shared/revision_nr.h2
8 files changed, 142 insertions, 52 deletions
diff --git a/src/game/BattleGround.cpp b/src/game/BattleGround.cpp
index 221d93323c8..49d5224c223 100644
--- a/src/game/BattleGround.cpp
+++ b/src/game/BattleGround.cpp
@@ -165,8 +165,6 @@ void BattleGround::Update(uint32 diff)
m_RemovedPlayers.clear();
}
- // this code isn't efficient and its idea isn't implemented yet
- /* offline players are removed from battleground in worldsession::LogoutPlayer()
// remove offline players from bg after ~5 minutes
if(GetPlayersSize())
{
@@ -181,7 +179,7 @@ void BattleGround::Update(uint32 diff)
if(itr->second.LastOnlineTime >= MAX_OFFLINE_TIME) // 5 minutes
m_RemovedPlayers[itr->first] = 1; // add to remove list (BG)
}
- }*/
+ }
m_LastResurrectTime += diff;
if (m_LastResurrectTime >= RESURRECTION_INTERVAL)
@@ -1535,6 +1533,31 @@ uint32 BattleGround::GetPlayerTeam(uint64 guid)
return 0;
}
+bool BattleGround::IsPlayerInBattleGround(uint64 guid)
+{
+ std::map<uint64, BattleGroundPlayer>::const_iterator itr = m_Players.find(guid);
+ if(itr!=m_Players.end())
+ return true;
+ return false;
+}
+
+void BattleGround::PlayerRelogin(Player* plr)
+{
+ if(GetStatus() != STATUS_WAIT_LEAVE)
+ return;
+
+ WorldPacket data;
+ uint32 bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(GetTypeID(), GetArenaType());
+
+ BlockMovement(plr);
+
+ sBattleGroundMgr.BuildPvpLogDataPacket(&data, this);
+ plr->GetSession()->SendPacket(&data);
+
+ sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, this, plr->GetTeam(), plr->GetBattleGroundQueueIndex(bgQueueTypeId), STATUS_IN_PROGRESS, TIME_TO_AUTOREMOVE, GetStartTime());
+ plr->GetSession()->SendPacket(&data);
+}
+
uint32 BattleGround::GetAlivePlayersCountByTeam(uint32 Team) const
{
int count = 0;
diff --git a/src/game/BattleGround.h b/src/game/BattleGround.h
index fbba9175ef2..b0c19afe782 100644
--- a/src/game/BattleGround.h
+++ b/src/game/BattleGround.h
@@ -452,6 +452,8 @@ class BattleGround
// since arenas can be AvA or Hvh, we have to get the "temporary" team of a player
uint32 GetPlayerTeam(uint64 guid);
+ bool IsPlayerInBattleGround(uint64 guid);
+ void PlayerRelogin(Player* plr);
void SetDeleteThis() {m_SetDeleteThis = true;}
diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp
index b09f57270b3..bb2c0957ab5 100644
--- a/src/game/CharacterHandler.cpp
+++ b/src/game/CharacterHandler.cpp
@@ -64,7 +64,7 @@ bool LoginQueryHolder::Initialize()
// NOTE: all fields in `characters` must be read to prevent lost character data at next save in case wrong DB structure.
// !!! NOTE: including unused `zone`,`online`
- res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADFROM, "SELECT guid, account, data, name, race, class, position_x, position_y, position_z, map, orientation, taximask, cinematic, totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, resettalents_time, trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, stable_slots, at_login, zone, online, death_expire_time, taxi_path, dungeon_difficulty, arena_pending_points FROM characters WHERE guid = '%u'", GUID_LOPART(m_guid));
+ res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADFROM, "SELECT guid, account, data, name, race, class, position_x, position_y, position_z, map, orientation, taximask, cinematic, totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, resettalents_time, trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, stable_slots, at_login, zone, online, death_expire_time, taxi_path, dungeon_difficulty, arena_pending_points,bgid,bgteam,bgmap,bgx,bgy,bgz,bgo FROM characters WHERE guid = '%u'", GUID_LOPART(m_guid));
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADGROUP, "SELECT leaderGuid FROM group_member WHERE memberGuid ='%u'", GUID_LOPART(m_guid));
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADBOUNDINSTANCES, "SELECT id, permanent, map, difficulty, resettime FROM character_instance LEFT JOIN instance ON instance = id WHERE guid = '%u'", GUID_LOPART(m_guid));
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADAURAS, "SELECT caster_guid,spell,effect_index,stackcount,amount,maxduration,remaintime,remaincharges FROM character_aura WHERE guid = '%u'", GUID_LOPART(m_guid));
diff --git a/src/game/MovementHandler.cpp b/src/game/MovementHandler.cpp
index 7cc126e965f..4e4dff56a47 100644
--- a/src/game/MovementHandler.cpp
+++ b/src/game/MovementHandler.cpp
@@ -132,31 +132,23 @@ void WorldSession::HandleMoveWorldportAckOpcode()
if(!mEntry->IsMountAllowed())
_player->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED);
- // battleground state prepare
+ // battleground state prepare (in case join to BG), at relogin/tele player not invited
// only add to bg group and object, if the player was invited (else he entered through command)
- if(_player->InBattleGround() && _player->IsInvitedForBattleGroundInstance(_player->GetBattleGroundId()))
+ if(_player->InBattleGround())
{
- BattleGround *bg = _player->GetBattleGround();
- if(bg)
+ // cleanup seting if outdated
+ if(!mEntry->IsBattleGroundOrArena())
{
- bg->AddPlayer(_player);
- if(bg->GetMapId() == _player->GetMapId()) // we teleported to bg
- {
- // get the team this way, because arenas might 'override' the teams.
- uint32 team = bg->GetPlayerTeam(_player->GetGUID());
- if(!team)
- team = _player->GetTeam();
- if(!bg->GetBgRaid(team)) // first player joined
- {
- Group *group = new Group;
- bg->SetBgRaid(team, group);
- group->Create(_player->GetGUIDLow(), _player->GetName());
- }
- else // raid already exist
- {
- bg->GetBgRaid(team)->AddMember(_player->GetGUID(), _player->GetName());
- }
- }
+ // Do next only if found in battleground
+ _player->SetBattleGroundId(0); // We're not in BG.
+ // reset destination bg team
+ _player->SetBGTeam(0);
+ }
+ // join to bg case
+ else if(BattleGround *bg = _player->GetBattleGround())
+ {
+ if(_player->IsInvitedForBattleGroundInstance(_player->GetBattleGroundId()))
+ bg->AddPlayer(_player);
}
}
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index a24af48f95b..7d2767275c6 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -14405,8 +14405,8 @@ float Player::GetFloatValueFromDB(uint16 index, uint64 guid)
bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
{
- //// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 [28] [29] 30 31 32 33
- //QueryResult *result = CharacterDatabase.PQuery("SELECT guid, account, data, name, race, class, position_x, position_y, position_z, map, orientation, taximask, cinematic, totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, resettalents_time, trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, stable_slots, at_login, zone, online, death_expire_time, taxi_path, dungeon_difficulty, arena_pending_points FROM characters WHERE guid = '%u'", guid);
+ //// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 [28] [29] 30 31 32 33 34 35 36 37 38 39 40
+ //QueryResult *result = CharacterDatabase.PQuery("SELECT guid, account, data, name, race, class, position_x, position_y, position_z, map, orientation, taximask, cinematic, totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, resettalents_time, trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, stable_slots, at_login, zone, online, death_expire_time, taxi_path, dungeon_difficulty, arena_pending_points,bgid,bgteam,bgmap,bgx,bgy,bgz,bgo FROM characters WHERE guid = '%u'", guid);
QueryResult *result = holder->GetResult(PLAYER_LOGIN_QUERY_LOADFROM);
if(!result)
@@ -14568,6 +14568,51 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
}
}*/
+ uint32 bgid = fields[34].GetUInt32();
+ uint32 bgteam = fields[35].GetUInt32();
+
+ if(bgid) //saved in BattleGround
+ {
+ SetBattleGroundEntryPoint(fields[36].GetUInt32(),fields[37].GetFloat(),fields[38].GetFloat(),fields[39].GetFloat(),fields[40].GetFloat());
+
+ // check entry point and fix to homebind if need
+ if(!MapManager::IsValidMapCoord(m_bgEntryPoint))
+ SetBattleGroundEntryPoint(m_homebindMapId,m_homebindX,m_homebindY,m_homebindZ,0.0f);
+
+ BattleGround *currentBg = sBattleGroundMgr.GetBattleGround(bgid);
+
+ if(currentBg && currentBg->IsPlayerInBattleGround(GetGUID()))
+ {
+ uint32 bgQueueTypeId = sBattleGroundMgr.BGQueueTypeId(currentBg->GetTypeID(), currentBg->GetArenaType());
+ uint32 queueSlot = AddBattleGroundQueueId(bgQueueTypeId);
+
+ SetBattleGroundId(currentBg->GetInstanceID());
+ SetBGTeam(bgteam);
+
+ SetInviteForBattleGroundQueueType(bgQueueTypeId,currentBg->GetInstanceID());
+ }
+ else
+ {
+ Relocate(GetBattleGroundEntryPoint());
+ //RemoveArenaAuras(true);
+ }
+ }
+ else
+ {
+ MapEntry const* mapEntry = sMapStore.LookupEntry(GetMapId());
+ // if server restart after player save in BG or area
+ // player can have current coordinates in to BG/Arean map, fix this
+ if(!mapEntry || mapEntry->IsBattleGroundOrArena())
+ {
+ // return to BG master
+ SetMapId(fields[36].GetUInt32());
+ Relocate(fields[37].GetFloat(),fields[38].GetFloat(),fields[39].GetFloat(),fields[40].GetFloat());
+ // check entry point and fix to homebind if need
+ if(!IsPositionValid())
+ RelocateToHomebind();
+ }
+ }
+
if (transGUID != 0)
{
m_movementInfo.t_x = fields[20].GetFloat();
@@ -15896,12 +15941,6 @@ void Player::SaveToDB()
// first save/honor gain after midnight will also update the player's honor fields
UpdateHonorFields();
- // players aren't saved on battleground maps
- uint32 mapid = IsBeingTeleported() ? GetTeleportDest().mapid : GetMapId();
- const MapEntry * me = sMapStore.LookupEntry(mapid);
- if(!me || me->IsBattleGroundOrArena())
- return;
-
int is_save_resting = HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) ? 1 : 0;
//save, far from tavern/city
//save, but in tavern/city
@@ -15937,23 +15976,14 @@ void Player::SaveToDB()
"taximask, online, cinematic, "
"totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, resettalents_time, "
"trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, stable_slots, at_login, zone, "
- "death_expire_time, taxi_path, arena_pending_points, latency) VALUES ("
+ "death_expire_time, taxi_path, arena_pending_points, latency, bgid, bgteam, bgmap, bgx, bgy, bgz, bgo) VALUES ("
<< GetGUIDLow() << ", "
<< GetSession()->GetAccountId() << ", '"
<< sql_name << "', "
<< m_race << ", "
<< m_class << ", ";
- bool save_to_dest = false;
- if(IsBeingTeleported())
- {
- // don't save to battlegrounds or arenas
- const MapEntry *entry = sMapStore.LookupEntry(GetTeleportDest().mapid);
- if(entry && entry->map_type != MAP_BATTLEGROUND && entry->map_type != MAP_ARENA)
- save_to_dest = true;
- }
-
- if(!save_to_dest)
+ if(!IsBeingTeleported())
{
ss << GetMapId() << ", "
<< (uint32)GetDifficulty() << ", "
@@ -16036,9 +16066,19 @@ void Player::SaveToDB()
ss << ", '";
ss << m_taxi.SaveTaxiDestinationsToString();
- ss << "', '0', '";
+ ss << "', '0', ";
ss << GetSession()->GetLatency();
- ss << "' )";
+ ss << ", ";
+ ss << GetBattleGroundId();
+ ss << ", ";
+ ss << GetBGTeam();
+ ss << ", ";
+ ss << m_bgEntryPoint.mapid << ", "
+ << finiteAlways(m_bgEntryPoint.x) << ", "
+ << finiteAlways(m_bgEntryPoint.y) << ", "
+ << finiteAlways(m_bgEntryPoint.z) << ", "
+ << finiteAlways(m_bgEntryPoint.o);
+ ss << ")";
CharacterDatabase.Execute( ss.str().c_str() );
@@ -18632,6 +18672,40 @@ void Player::SendInitialPacketsAfterAddToMap()
SendMessageToSet(&data,true);
}
+ // setup BG group membership if need
+ if(BattleGround* currentBg = GetBattleGround())
+ {
+ // call for invited (join) or listed (relogin) and avoid other cases (GM teleport)
+ if (IsInvitedForBattleGroundInstance(GetBattleGroundId()) ||
+ currentBg->IsPlayerInBattleGround(GetGUID()))
+ {
+ currentBg->PlayerRelogin(this);
+ if(currentBg->GetMapId() == GetMapId()) // we teleported/login to/in bg
+ {
+ uint32 team = currentBg->GetPlayerTeam(GetGUID());
+ if(!team)
+ team = GetTeam();
+ Group* group = currentBg->GetBgRaid(team);
+ if(!group) // first player joined
+ {
+ group = new Group;
+ currentBg->SetBgRaid(team, group);
+ group->Create(GetGUIDLow(), GetName());
+ }
+ else // raid already exist
+ {
+ if(group->IsMember(GetGUID()))
+ {
+ uint8 subgroup = group->GetMemberGroup(GetGUID());
+ SetGroup(group, subgroup);
+ }
+ else
+ currentBg->GetBgRaid(team)->AddMember(GetGUID(), GetName());
+ }
+ }
+ }
+ }
+
SendAurasForTarget(this);
SendEnchantmentDurations(); // must be after add to map
SendItemDurations(); // must be after add to map
diff --git a/src/game/WorldSession.cpp b/src/game/WorldSession.cpp
index 36f4414fd1f..edcb0dc8a39 100644
--- a/src/game/WorldSession.cpp
+++ b/src/game/WorldSession.cpp
@@ -314,10 +314,6 @@ void WorldSession::LogoutPlayer(bool Save)
_player->RepopAtGraveyard();
}
- ///- Remove player from battleground (teleport to entrance)
- if(_player->InBattleGround())
- _player->LeaveBattleground();
-
///- Teleport to home if the player is in an invalid instance
if(!_player->m_InstanceValid && !_player->isGameMaster())
_player->TeleportTo(_player->m_homebindMapId, _player->m_homebindX, _player->m_homebindY, _player->m_homebindZ, _player->GetOrientation());
diff --git a/src/mangosd/Master.cpp b/src/mangosd/Master.cpp
index fd5259fa916..f175d4d82b0 100644
--- a/src/mangosd/Master.cpp
+++ b/src/mangosd/Master.cpp
@@ -474,6 +474,9 @@ void Master::clearOnlineAccounts()
"AND id IN (SELECT acctid FROM realmcharacters WHERE realmid = '%d')",realmID);
CharacterDatabase.Execute("UPDATE characters SET online = 0 WHERE online<>0");
+
+ // Battleground instance ids reset at server restart
+ CharacterDatabase.Execute("UPDATE characters SET bgid = 0 WHERE bgid<>0");
}
/// Handle termination signals
diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h
index a1fd1f71117..4ce62dbb899 100644
--- a/src/shared/revision_nr.h
+++ b/src/shared/revision_nr.h
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
- #define REVISION_NR "7254"
+ #define REVISION_NR "7255"
#endif // __REVISION_NR_H__