diff options
-rw-r--r-- | sql/updates/world/2013_10_16_00_world_trinity_string.sql | 4 | ||||
-rw-r--r-- | src/server/scripts/Commands/cs_group.cpp | 52 |
2 files changed, 53 insertions, 3 deletions
diff --git a/sql/updates/world/2013_10_16_00_world_trinity_string.sql b/sql/updates/world/2013_10_16_00_world_trinity_string.sql new file mode 100644 index 00000000000..be77dd1b01c --- /dev/null +++ b/sql/updates/world/2013_10_16_00_world_trinity_string.sql @@ -0,0 +1,4 @@ +DELETE FROM `trinity_string` WHERE entry IN (1149, 1150); +INSERT INTO `trinity_string` (entry, content_default, content_loc1, content_loc2, content_loc3, content_loc4, content_loc5, content_loc6, content_loc7, content_loc8) VALUES +(1149, 'Group type: %s and consists of %u players.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), +(1150, 'Name: %s (%s), Zone: %s, Phase: %u, GUID: %u, Flags: %s, Roles: %s', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); diff --git a/src/server/scripts/Commands/cs_group.cpp b/src/server/scripts/Commands/cs_group.cpp index 8c38d954203..1c0949398b9 100644 --- a/src/server/scripts/Commands/cs_group.cpp +++ b/src/server/scripts/Commands/cs_group.cpp @@ -260,24 +260,36 @@ public: static bool HandleGroupListCommand(ChatHandler* handler, char const* args) { + // Get ALL the variables! Player* playerTarget; + uint32 phase = 0; + uint32 groupCounter = 0; uint64 guidTarget; std::string nameTarget; + std::string zoneName; + const char* onlineState = ""; + // Parse the guid to uint32... uint32 parseGUID = MAKE_NEW_GUID(atol((char*)args), 0, HIGHGUID_PLAYER); + // ... and try to extract a player out of it. if (sObjectMgr->GetPlayerNameByGUID(parseGUID, nameTarget)) { playerTarget = sObjectMgr->GetPlayerByLowGUID(parseGUID); guidTarget = parseGUID; } + // If not, we return false and end right away. else if (!handler->extractPlayerTarget((char*)args, &playerTarget, &guidTarget, &nameTarget)) return false; + // Next, we need a group. So we define a group variable. Group* groupTarget = NULL; + + // We try to extract a group from an online player. if (playerTarget) groupTarget = playerTarget->GetGroup(); + // If not, we extract it from the SQL. if (!groupTarget) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GROUP_MEMBER); @@ -287,6 +299,7 @@ public: groupTarget = sGroupMgr->GetGroupByDbStoreId((*resultGroup)[0].GetUInt32()); } + // If both fails, players simply has no party. Return false. if (!groupTarget) { handler->PSendSysMessage(LANG_GROUP_NOT_IN_GROUP, nameTarget.c_str()); @@ -294,12 +307,20 @@ public: return false; } - handler->PSendSysMessage(LANG_GROUP_TYPE, (groupTarget->isRaidGroup() ? "raid" : "party")); + // We get the group members after successfully detecting a group. Group::MemberSlotList const& members = groupTarget->GetMemberSlots(); + + // To avoid a cluster fuck, namely trying multiple queries to simply get a group member count... + handler->PSendSysMessage(LANG_GROUP_TYPE, (groupTarget->isRaidGroup() ? "raid" : "party"), members.size()); + // ... we simply move the group type and member count print after retrieving the slots and simply output it's size. + + // While rather dirty codestyle-wise, it saves space (if only a little). For each member, we look several informations up. for (Group::MemberSlotList::const_iterator itr = members.begin(); itr != members.end(); ++itr) { + // Define temporary variable slot to iterator. Group::MemberSlot const& slot = *itr; + // Check for given flag and assign it to that iterator std::string flags; if (slot.flags & MEMBER_FLAG_ASSISTANT) flags = "Assistant"; @@ -321,13 +342,38 @@ public: if (flags.empty()) flags = "None"; + // Check if iterator is online. If is... Player* p = ObjectAccessor::FindPlayer((*itr).guid); - const char* onlineState = (p && p->IsInWorld()) ? "online" : "offline"; + if (p && p->IsInWorld()) + { + // ... than, it prints information like "is online", where he is, etc... + onlineState = "online"; + phase = (!p->IsGameMaster() ? p->GetPhaseMask() : -1); + uint32 locale = handler->GetSessionDbcLocale(); + + AreaTableEntry const* area = GetAreaEntryByAreaID(p->GetAreaId()); + if (area) + { + AreaTableEntry const* zone = GetAreaEntryByAreaID(area->zone); + if (zone) + zoneName = zone->area_name[locale]; + } + } + else + { + // ... else, everything is set to offline or neutral values. + zoneName = "<ERROR>"; + onlineState = "Offline"; + phase = 0; + } + // Now we can print those informations for every single member of each group! handler->PSendSysMessage(LANG_GROUP_PLAYER_NAME_GUID, slot.name.c_str(), onlineState, - GUID_LOPART(slot.guid), flags.c_str(), lfg::GetRolesString(slot.roles).c_str()); + zoneName.c_str(), phase, GUID_LOPART(slot.guid), flags.c_str(), + lfg::GetRolesString(slot.roles).c_str()); } + // And finish after every iterator is done. return true; } }; |