TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
tele_commandscript Class Reference

Public Member Functions

 tele_commandscript ()
 
std::vector< ChatCommandGetCommands () const override
 
- Public Member Functions inherited from ScriptObject
const std::string & GetName () const
 

Static Public Member Functions

static bool HandleTeleAddCommand (ChatHandler *handler, const char *args)
 
static bool HandleTeleDelCommand (ChatHandler *handler, const char *args)
 
static bool HandleTeleNameCommand (ChatHandler *handler, const char *args)
 
static bool HandleTeleGroupCommand (ChatHandler *handler, const char *args)
 
static bool HandleTeleCommand (ChatHandler *handler, const char *args)
 

Additional Inherited Members

- Protected Member Functions inherited from CommandScript
 CommandScript (const char *name)
 
- Protected Member Functions inherited from ScriptObject
 ScriptObject (const char *name)
 
virtual ~ScriptObject ()
 

Constructor & Destructor Documentation

tele_commandscript::tele_commandscript ( )
inline
36 : CommandScript("tele_commandscript") { }
CommandScript(const char *name)
Definition: ScriptMgr.cpp:1616

Member Function Documentation

std::vector<ChatCommand> tele_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

39  {
40  static std::vector<ChatCommand> teleCommandTable =
41  {
47  };
48  static std::vector<ChatCommand> commandTable =
49  {
50  { "tele", rbac::RBAC_PERM_COMMAND_TELE, false, NULL, "", teleCommandTable },
51  };
52  return commandTable;
53  }
static bool HandleTeleGroupCommand(ChatHandler *handler, const char *args)
Definition: cs_tele.cpp:212
Definition: RBAC.h:646
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: RBAC.h:647
static bool HandleTeleNameCommand(ChatHandler *handler, const char *args)
Definition: cs_tele.cpp:115
static bool HandleTeleCommand(ChatHandler *handler, const char *args)
Definition: cs_tele.cpp:295
Definition: RBAC.h:645
Definition: RBAC.h:644
static bool HandleTeleAddCommand(ChatHandler *handler, const char *args)
Definition: cs_tele.cpp:55
static bool HandleTeleDelCommand(ChatHandler *handler, const char *args)
Definition: cs_tele.cpp:95

+ Here is the call graph for this function:

static bool tele_commandscript::HandleTeleAddCommand ( ChatHandler handler,
const char *  args 
)
inlinestatic
56  {
57  if (!*args)
58  return false;
59 
60  Player* player = handler->GetSession()->GetPlayer();
61  if (!player)
62  return false;
63 
64  std::string name = args;
65 
66  if (sObjectMgr->GetGameTeleExactName(name))
67  {
69  handler->SetSentErrorMessage(true);
70  return false;
71  }
72 
73  GameTele tele;
74  tele.position_x = player->GetPositionX();
75  tele.position_y = player->GetPositionY();
76  tele.position_z = player->GetPositionZ();
77  tele.orientation = player->GetOrientation();
78  tele.mapId = player->GetMapId();
79  tele.name = name;
80 
81  if (sObjectMgr->AddGameTele(tele))
82  {
84  }
85  else
86  {
88  handler->SetSentErrorMessage(true);
89  return false;
90  }
91 
92  return true;
93  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
std::string name
Definition: ObjectMgr.h:132
float orientation
Definition: ObjectMgr.h:130
float position_x
Definition: ObjectMgr.h:127
Definition: ObjectMgr.h:125
Player * GetPlayer() const
Definition: WorldSession.h:927
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: Language.h:464
float position_z
Definition: ObjectMgr.h:129
float position_y
Definition: ObjectMgr.h:128
Definition: Language.h:465
Definition: Language.h:466
uint32 mapId
Definition: ObjectMgr.h:131
WorldSession * GetSession()
Definition: Chat.h:59
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool tele_commandscript::HandleTeleCommand ( ChatHandler handler,
const char *  args 
)
inlinestatic
296  {
297  if (!*args)
298  return false;
299 
300  Player* me = handler->GetSession()->GetPlayer();
301 
302  // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
303  GameTele const* tele = handler->extractGameTeleFromLink((char*)args);
304 
305  if (!tele)
306  {
308  handler->SetSentErrorMessage(true);
309  return false;
310  }
311 
312  if (me->IsInCombat())
313  {
315  handler->SetSentErrorMessage(true);
316  return false;
317  }
318 
319  MapEntry const* map = sMapStore.LookupEntry(tele->mapId);
320  if (!map || (map->IsBattlegroundOrArena() && (me->GetMapId() != tele->mapId || !me->IsGameMaster())))
321  {
323  handler->SetSentErrorMessage(true);
324  return false;
325  }
326 
327  // stop flight if need
328  if (me->IsInFlight())
329  {
330  me->GetMotionMaster()->MovementExpired();
331  me->CleanupAfterTaxiFlight();
332  }
333  // save only in non-flight case
334  else
335  me->SaveRecallPosition();
336 
337  me->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation);
338  return true;
339  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
float orientation
Definition: ObjectMgr.h:130
Definition: DBCStructure.h:830
float position_x
Definition: ObjectMgr.h:127
Definition: ObjectMgr.h:125
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: Language.h:737
float position_z
Definition: ObjectMgr.h:129
Definition: Language.h:195
float position_y
Definition: ObjectMgr.h:128
bool IsBattlegroundOrArena() const
Definition: DBCStructure.h:863
Definition: Language.h:56
DBCStorage< MapEntry > sMapStore(Mapfmt)
uint32 mapId
Definition: ObjectMgr.h:131
WorldSession * GetSession()
Definition: Chat.h:59
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
GameTele const * extractGameTeleFromLink(char *text)
Definition: Chat.cpp:853

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool tele_commandscript::HandleTeleDelCommand ( ChatHandler handler,
const char *  args 
)
inlinestatic
96  {
97  if (!*args)
98  return false;
99 
100  // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
101  GameTele const* tele = handler->extractGameTeleFromLink((char*)args);
102  if (!tele)
103  {
105  handler->SetSentErrorMessage(true);
106  return false;
107  }
108  std::string name = tele->name;
109  sObjectMgr->DeleteGameTele(name);
111  return true;
112  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
std::string name
Definition: ObjectMgr.h:132
Definition: ObjectMgr.h:125
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: Language.h:467
Definition: Language.h:195
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
GameTele const * extractGameTeleFromLink(char *text)
Definition: Chat.cpp:853

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool tele_commandscript::HandleTeleGroupCommand ( ChatHandler handler,
const char *  args 
)
inlinestatic
213  {
214  if (!*args)
215  return false;
216 
217  Player* target = handler->getSelectedPlayer();
218  if (!target)
219  {
221  handler->SetSentErrorMessage(true);
222  return false;
223  }
224 
225  // check online security
226  if (handler->HasLowerSecurity(target, ObjectGuid::Empty))
227  return false;
228 
229  // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
230  GameTele const* tele = handler->extractGameTeleFromLink((char*)args);
231  if (!tele)
232  {
234  handler->SetSentErrorMessage(true);
235  return false;
236  }
237 
238  MapEntry const* map = sMapStore.LookupEntry(tele->mapId);
239  if (!map || map->IsBattlegroundOrArena())
240  {
242  handler->SetSentErrorMessage(true);
243  return false;
244  }
245 
246  std::string nameLink = handler->GetNameLink(target);
247 
248  Group* grp = target->GetGroup();
249  if (!grp)
250  {
251  handler->PSendSysMessage(LANG_NOT_IN_GROUP, nameLink.c_str());
252  handler->SetSentErrorMessage(true);
253  return false;
254  }
255 
256  for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
257  {
258  Player* player = itr->GetSource();
259 
260  if (!player || !player->GetSession())
261  continue;
262 
263  // check online security
264  if (handler->HasLowerSecurity(player, ObjectGuid::Empty))
265  return false;
266 
267  std::string plNameLink = handler->GetNameLink(player);
268 
269  if (player->IsBeingTeleported())
270  {
271  handler->PSendSysMessage(LANG_IS_TELEPORTED, plNameLink.c_str());
272  continue;
273  }
274 
275  handler->PSendSysMessage(LANG_TELEPORTING_TO, plNameLink.c_str(), "", tele->name.c_str());
276  if (handler->needReportToTarget(player))
277  ChatHandler(player->GetSession()).PSendSysMessage(LANG_TELEPORTED_TO_BY, nameLink.c_str());
278 
279  // stop flight if need
280  if (player->IsInFlight())
281  {
282  player->GetMotionMaster()->MovementExpired();
283  player->CleanupAfterTaxiFlight();
284  }
285  // save only in non-flight case
286  else
287  player->SaveRecallPosition();
288 
289  player->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation);
290  }
291 
292  return true;
293  }
Definition: Language.h:141
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
std::string name
Definition: ObjectMgr.h:132
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
float orientation
Definition: ObjectMgr.h:130
Definition: DBCStructure.h:830
float position_x
Definition: ObjectMgr.h:127
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: ObjectMgr.h:125
Definition: Language.h:140
bool HasLowerSecurity(Player *target, ObjectGuid guid, bool strong=false)
Definition: Chat.cpp:77
Definition: Language.h:737
float position_z
Definition: ObjectMgr.h:129
virtual std::string GetNameLink() const
Definition: Chat.h:101
Definition: Language.h:134
Definition: Language.h:195
GroupReference * GetFirstMember()
Definition: Group.h:295
float position_y
Definition: ObjectMgr.h:128
Player * getSelectedPlayer()
Definition: Chat.cpp:579
Definition: Chat.h:56
Definition: Language.h:135
bool IsBattlegroundOrArena() const
Definition: DBCStructure.h:863
DBCStorage< MapEntry > sMapStore(Mapfmt)
uint32 mapId
Definition: ObjectMgr.h:131
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
Definition: Language.h:126
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
virtual bool needReportToTarget(Player *chr) const
Definition: Chat.cpp:1056
Definition: Group.h:191
Definition: GroupReference.h:27
GameTele const * extractGameTeleFromLink(char *text)
Definition: Chat.cpp:853

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool tele_commandscript::HandleTeleNameCommand ( ChatHandler handler,
const char *  args 
)
inlinestatic
116  {
117  char* nameStr;
118  char* teleStr;
119  handler->extractOptFirstArg((char*)args, &nameStr, &teleStr);
120  if (!teleStr)
121  return false;
122 
123  Player* target;
124  ObjectGuid target_guid;
125  std::string target_name;
126  if (!handler->extractPlayerTarget(nameStr, &target, &target_guid, &target_name))
127  return false;
128 
129  if (strcmp(teleStr, "$home") == 0) // References target's homebind
130  {
131  if (target)
132  target->TeleportTo(target->m_homebindMapId, target->m_homebindX, target->m_homebindY, target->m_homebindZ, target->GetOrientation());
133  else
134  {
136  stmt->setUInt64(0, target_guid.GetCounter());
138 
139  if (resultDB)
140  {
141  Field* fieldsDB = resultDB->Fetch();
142  WorldLocation loc(fieldsDB[0].GetUInt16(), fieldsDB[2].GetFloat(), fieldsDB[3].GetFloat(), fieldsDB[4].GetFloat(), 0.0f);
143  uint32 zoneId = fieldsDB[1].GetUInt16();
144 
145  SQLTransaction dummy;
146  Player::SavePositionInDB(loc, zoneId, target_guid, dummy);
147  }
148  }
149 
150  return true;
151  }
152 
153  // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
154  GameTele const* tele = handler->extractGameTeleFromLink(teleStr);
155  if (!tele)
156  {
158  handler->SetSentErrorMessage(true);
159  return false;
160  }
161 
162  if (target)
163  {
164  // check online security
165  if (handler->HasLowerSecurity(target, ObjectGuid::Empty))
166  return false;
167 
168  std::string chrNameLink = handler->playerLink(target_name);
169 
170  if (target->IsBeingTeleported() == true)
171  {
172  handler->PSendSysMessage(LANG_IS_TELEPORTED, chrNameLink.c_str());
173  handler->SetSentErrorMessage(true);
174  return false;
175  }
176 
177  handler->PSendSysMessage(LANG_TELEPORTING_TO, chrNameLink.c_str(), "", tele->name.c_str());
178  if (handler->needReportToTarget(target))
179  ChatHandler(target->GetSession()).PSendSysMessage(LANG_TELEPORTED_TO_BY, handler->GetNameLink().c_str());
180 
181  // stop flight if need
182  if (target->IsInFlight())
183  {
184  target->GetMotionMaster()->MovementExpired();
185  target->CleanupAfterTaxiFlight();
186  }
187  // save only in non-flight case
188  else
189  target->SaveRecallPosition();
190 
191  target->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation);
192  }
193  else
194  {
195  // check offline security
196  if (handler->HasLowerSecurity(NULL, target_guid))
197  return false;
198 
199  std::string nameLink = handler->playerLink(target_name);
200 
201  handler->PSendSysMessage(LANG_TELEPORTING_TO, nameLink.c_str(), handler->GetTrinityString(LANG_OFFLINE), tele->name.c_str());
202 
203  SQLTransaction dummy;
204  Player::SavePositionInDB(WorldLocation(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation),
205  sMapMgr->GetZoneId(tele->mapId, tele->position_x, tele->position_y, tele->position_z), target_guid, dummy);
206  }
207 
208  return true;
209  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
Definition: Position.h:228
std::string name
Definition: ObjectMgr.h:132
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
Class used to access individual fields of database query result.
Definition: Field.h:56
float orientation
Definition: ObjectMgr.h:130
float position_x
Definition: ObjectMgr.h:127
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: ObjectMgr.h:125
Definition: CharacterDatabase.h:386
bool extractPlayerTarget(char *args, Player **player, ObjectGuid *player_guid=NULL, std::string *player_name=NULL)
Definition: Chat.cpp:945
Definition: PreparedStatement.h:74
bool HasLowerSecurity(Player *target, ObjectGuid guid, bool strong=false)
Definition: Chat.cpp:77
float position_z
Definition: ObjectMgr.h:129
virtual std::string GetNameLink() const
Definition: Chat.h:101
Definition: Language.h:70
Definition: Language.h:134
Definition: Language.h:195
uint32_t uint32
Definition: Define.h:150
uint16 GetUInt16() const
Definition: Field.h:108
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
float position_y
Definition: ObjectMgr.h:128
Definition: Chat.h:56
Definition: Language.h:135
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
uint32 mapId
Definition: ObjectMgr.h:131
virtual char const * GetTrinityString(uint32 entry) const
Definition: Chat.cpp:67
#define sMapMgr
Definition: MapManager.h:194
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
void extractOptFirstArg(char *args, char **arg1, char **arg2)
Definition: Chat.cpp:998
Definition: ObjectGuid.h:189
Definition: Language.h:126
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
virtual bool needReportToTarget(Player *chr) const
Definition: Chat.cpp:1056
std::string playerLink(std::string const &name) const
Definition: Chat.h:132
LowType GetCounter() const
Definition: ObjectGuid.h:221
GameTele const * extractGameTeleFromLink(char *text)
Definition: Chat.cpp:853
std::shared_ptr< Transaction > SQLTransaction
Definition: Transaction.h:58

+ Here is the call graph for this function:

+ Here is the caller graph for this function:


The documentation for this class was generated from the following file: