Skip to content

Commit fee29de

Browse files
authored
Merge 5d7e563 into adbf4cf
2 parents adbf4cf + 5d7e563 commit fee29de

File tree

6 files changed

+138
-9
lines changed

6 files changed

+138
-9
lines changed

src/game/ChatCommands/GMCommands.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,27 @@ bool ChatHandler::HandlePInfoCommand(char* args)
134134
uint32 silv = (money % GOLD) / SILVER;
135135
uint32 copp = (money % GOLD) % SILVER;
136136
PSendSysMessage(LANG_PINFO_LEVEL, timeStr.c_str(), level, gold, silv, copp);
137+
if (target)
138+
{
139+
uint32 mapId = target->GetMapId();
140+
uint32 zoneId = target->GetZoneId();
141+
float posX = target->GetPositionX();
142+
float posY = target->GetPositionY();
143+
float posZ = target->GetPositionZ();
144+
float orientation = target->GetOrientation();
145+
146+
MapEntry const* mapEntry = sMapStore.LookupEntry(mapId);
147+
AreaTableEntry const* zoneEntry = GetAreaEntryByAreaID(zoneId);
137148

149+
PSendSysMessage("Location: Map %u (%s), Zone %u (%s)",
150+
mapId,
151+
(mapEntry ? mapEntry->name[GetSessionDbcLocale()] : "<unknown>"),
152+
zoneId,
153+
(zoneEntry ? zoneEntry->area_name[GetSessionDbcLocale()] : "<unknown>"));
154+
155+
PSendSysMessage("Coordinates: X=%.2f Y=%.2f Z=%.2f O=%.2f",
156+
posX, posY, posZ, orientation);
157+
}
138158
return true;
139159
}
140160

src/game/ChatCommands/ListCommands.cpp

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,45 @@ bool ChatHandler::HandleListItemCommand(char* args)
364364
return true;
365365
}
366366

367+
bool ChatHandler::HandleListPlayersCommand(char* args)
368+
{
369+
uint32 limit;
370+
if (!ExtractOptUInt32(&args, limit, 100))
371+
{
372+
return false;
373+
}
374+
375+
uint32 count = 0;
376+
377+
PSendSysMessage("Online Players (Limit %u):", limit);
378+
PSendSysMessage("===========================================");
379+
380+
sObjectAccessor.DoForAllPlayers([&](Player* player)
381+
{
382+
if (count >= limit)
383+
{
384+
return;
385+
}
386+
387+
uint32 mapId = player->GetMapId();
388+
uint32 zoneId = player->GetZoneId();
389+
390+
MapEntry const* mapEntry = sMapStore.LookupEntry(mapId);
391+
AreaTableEntry const* zoneEntry = GetAreaEntryByAreaID(zoneId);
392+
393+
PSendSysMessage("%-20s | Lvl %-2u | Map %u Zone %u (%s)",
394+
player->GetName(),
395+
player->getLevel(),
396+
mapId,
397+
zoneId,
398+
(zoneEntry ? zoneEntry->area_name[GetSessionDbcLocale()] : "Unknown"));
399+
400+
count++;
401+
});
402+
403+
return true;
404+
}
405+
367406
bool ChatHandler::HandleListObjectCommand(char* args)
368407
{
369408
// number or [name] Shift-click form |color|Hgameobject_entry:go_id|h[name]|h|r
@@ -520,4 +559,4 @@ bool ChatHandler::HandleListCreatureCommand(char* args)
520559

521560
PSendSysMessage(LANG_COMMAND_LISTCREATUREMESSAGE, cr_id, cr_count);
522561
return true;
523-
}
562+
}

src/game/ChatCommands/LookupCommands.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -255,13 +255,6 @@ bool ChatHandler::HandleLookupAreaCommand(char* args)
255255
// Find tele in game_tele order by name
256256
bool ChatHandler::HandleLookupTeleCommand(char* args)
257257
{
258-
if (!*args)
259-
{
260-
SendSysMessage(LANG_COMMAND_TELE_PARAMETER);
261-
SetSentErrorMessage(true);
262-
return false;
263-
}
264-
265258
std::string namepart = args;
266259
std::wstring wnamepart;
267260

src/game/ChatCommands/TeleportationAndPositionCommands.cpp

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1514,7 +1514,81 @@ bool ChatHandler::HandleTeleNameCommand(char* args)
15141514
return false;
15151515
}
15161516

1517-
// id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
1517+
// id, or string, coordinates, or [name] Shift-click form |color|Htele:id|h[name]|h|r
1518+
1519+
// Try to parse as coordinates first: <mapid> <x> <y> <z> [orientation]
1520+
uint32 mapId;
1521+
float x, y, z, o = 0.0f;
1522+
char* mapStr = ExtractLiteralArg(&args);
1523+
if (mapStr && ExtractUInt32(&mapStr, mapId))
1524+
{
1525+
char* xStr = ExtractLiteralArg(&args);
1526+
char* yStr = ExtractLiteralArg(&args);
1527+
char* zStr = ExtractLiteralArg(&args);
1528+
1529+
if (xStr && yStr && zStr &&
1530+
ExtractFloat(&xStr, x) && ExtractFloat(&yStr, y) && ExtractFloat(&zStr, z))
1531+
{
1532+
char* oStr = ExtractLiteralArg(&args);
1533+
if (oStr)
1534+
{
1535+
ExtractFloat(&oStr, o);
1536+
}
1537+
1538+
MapEntry const* mapEntry = sMapStore.LookupEntry(mapId);
1539+
if (!mapEntry)
1540+
{
1541+
PSendSysMessage("Map %u does not exist.", mapId);
1542+
SetSentErrorMessage(true);
1543+
return false;
1544+
}
1545+
1546+
std::string chrNameLink = playerLink(target_name);
1547+
1548+
if (target)
1549+
{
1550+
// Online player
1551+
if (HasLowerSecurity(target))
1552+
{
1553+
return false;
1554+
}
1555+
1556+
if (target->IsBeingTeleported())
1557+
{
1558+
PSendSysMessage(LANG_IS_TELEPORTED, chrNameLink.c_str());
1559+
SetSentErrorMessage(true);
1560+
return false;
1561+
}
1562+
1563+
PSendSysMessage("Teleporting %s to map %u (%s) at coordinates %.2f, %.2f, %.2f",
1564+
chrNameLink.c_str(), mapId, mapEntry->name[GetSessionDbcLocale()], x, y, z);
1565+
1566+
if (needReportToTarget(target))
1567+
{
1568+
ChatHandler(target).PSendSysMessage(LANG_TELEPORTED_TO_BY, GetNameLink().c_str());
1569+
}
1570+
1571+
return HandleGoHelper(target, mapId, x, y, z, o);
1572+
}
1573+
else
1574+
{
1575+
// offline player
1576+
if (HasLowerSecurity(NULL, target_guid))
1577+
{
1578+
return false;
1579+
}
1580+
1581+
PSendSysMessage("Teleporting %s %s to map %u at coordinates %.2f, %.2f, %.2f",
1582+
chrNameLink.c_str(), GetMangosString(LANG_OFFLINE), mapId, x, y, z);
1583+
1584+
Player::SavePositionInDB(target_guid, mapId, x, y, z, o,
1585+
sTerrainMgr.GetZoneId(mapId, x, y, z));
1586+
return true;
1587+
}
1588+
}
1589+
}
1590+
1591+
// Not coordinates, restore args pointer and try as saved location name
15181592
GameTele const* tele = ExtractGameTeleFromLink(&args);
15191593
if (!tele)
15201594
{
@@ -1568,6 +1642,7 @@ bool ChatHandler::HandleTeleNameCommand(char* args)
15681642
}
15691643

15701644

1645+
15711646
bool ChatHandler::HandleTeleCommand(char* args)
15721647
{
15731648
if (!*args)

src/game/WorldHandlers/Chat.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,7 @@ ChatCommand* ChatHandler::getCommandTable()
340340
{ "item", SEC_ADMINISTRATOR, true, &ChatHandler::HandleListItemCommand, "", NULL },
341341
{ "object", SEC_ADMINISTRATOR, true, &ChatHandler::HandleListObjectCommand, "", NULL },
342342
{ "talents", SEC_ADMINISTRATOR, true, &ChatHandler::HandleListTalentsCommand, "", NULL },
343+
{ "players", SEC_ADMINISTRATOR, true, &ChatHandler::HandleListPlayersCommand, "", NULL },
343344
{ NULL, 0, false, NULL, "", NULL }
344345
};
345346

src/game/WorldHandlers/Chat.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ class ChatHandler
380380
bool HandleListCreatureCommand(char* args);
381381
bool HandleListItemCommand(char* args);
382382
bool HandleListObjectCommand(char* args);
383+
bool HandleListPlayersCommand(char* args);
383384
bool HandleListTalentsCommand(char* args);
384385

385386
bool HandleLookupAccountEmailCommand(char* args);

0 commit comments

Comments
 (0)