TrinityCore
Loading...
Searching...
No Matches
GameClient.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "GameClient.h"
19#include "WorldSession.h"
20#include "Unit.h"
21#include "Player.h"
22
24{
25 _sessionToServer = sessionToServer;
26 _activelyMovedUnit = nullptr;
27}
28
30{
31 ASSERT(!unit->GetGameClientMovingMe() || unit->GetGameClientMovingMe() == this);
32
33 _allowedMovers.insert(unit->GetGUID());
34 unit->SetGameClientMovingMe(this);
35}
36
38{
40 _allowedMovers.erase(unit->GetGUID());
41 if (unit->GetGameClientMovingMe() == this)
42 {
43 unit->SetGameClientMovingMe(nullptr);
44 SetActivelyMovedUnit(nullptr);
45 }
46}
47
49{
50 return _allowedMovers.count(unit->GetGUID());
51}
52
54{
55 return _allowedMovers.count(guid);
56}
57
58void GameClient::SetMovedUnit(Unit* target, bool allowMove)
59{
60 if (allowMove)
61 AddAllowedMover(target);
62 else
63 RemoveAllowedMover(target);
64}
65
67{
69}
70
71std::string GameClient::GetDebugInfo() const
72{
73 std::stringstream sstr;
74 sstr << "GetBasePlayer(): " << (GetBasePlayer() ? GetBasePlayer()->GetGUID().ToString().c_str() : "NULL");
75 return sstr.str();
76}
#define ASSERT
Definition Errors.h:68
WorldSession * _sessionToServer
Definition GameClient.h:54
GuidUnorderedSet _allowedMovers
Definition GameClient.h:48
GameClient(WorldSession *sessionToServer)
void SetMovedUnit(Unit *target, bool allowMove)
Unit * _activelyMovedUnit
Definition GameClient.h:52
void SetActivelyMovedUnit(Unit *activelyMovedUnit)
Definition GameClient.h:38
void SendDirectMessage(WorldPacket const *data) const
Player * GetBasePlayer() const
Definition GameClient.h:40
bool IsAllowedToMove(Unit *unit) const
void AddAllowedMover(Unit *unit)
void RemoveAllowedMover(Unit *unit)
std::string GetDebugInfo() const
std::string ToString() const
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:78
void SendDirectMessage(WorldPacket const *data) const
Definition Player.cpp:6161
Definition Unit.h:769
void SetGameClientMovingMe(GameClient *gameClientMovingMe)
Definition Unit.h:1303
GameClient * GetGameClientMovingMe() const
Definition Unit.h:1302
void PurgeAndApplyPendingMovementChanges(bool informObservers=true)
Definition Unit.cpp:13005
Player session in the World.