bool ChatHandler::HandleShowInstancesCommand(const char* args, WorldSession* m_session) { Player* plr = getSelectedChar(m_session, true); if (!plr) return true; uint32 count = 0; std::stringstream ss; ss << "Show persistent instances of " << MSG_COLOR_CYAN << plr->GetName() << "|r\n"; plr->getPlayerInfo()->savedInstanceIdsLock.Acquire(); for (uint32 difficulty = 0; difficulty < NUM_INSTANCE_MODES; difficulty++) { for (PlayerInstanceMap::iterator itr = plr->getPlayerInfo()->savedInstanceIds[difficulty].begin(); itr != plr->getPlayerInfo()->savedInstanceIds[difficulty].end(); ++itr) { count++; ss << " - " << MSG_COLOR_CYAN << (*itr).second << "|r"; MapInfo* mapInfo = WorldMapInfoStorage.LookupEntry((*itr).first); if (mapInfo != NULL) ss << " (" << MSG_COLOR_CYAN << mapInfo->name << "|r)"; Instance* pInstance = sInstanceMgr.GetInstanceByIds((*itr).first, (*itr).second); if (pInstance == NULL) ss << " - " << MSG_COLOR_RED << "Expired!|r"; else { ss << " [" << GetMapTypeString(static_cast<uint8>(pInstance->m_mapInfo->type)) << "]"; if (pInstance->m_mapInfo->type == INSTANCE_MULTIMODE) { ss << " [" << GetDifficultyString(static_cast<uint8>(pInstance->m_difficulty)) << "]"; } ss << " - "; if (pInstance->m_mapMgr == NULL) ss << MSG_COLOR_LIGHTRED << "Shut Down|r"; else { if (!pInstance->m_mapMgr->HasPlayers()) ss << MSG_COLOR_LIGHTRED << "Idle|r"; else ss << MSG_COLOR_GREEN << "In use|r"; } } ss << "\n"; } } plr->getPlayerInfo()->savedInstanceIdsLock.Release(); if (count == 0) ss << "Player is not assigned to any persistent instances.\n"; else ss << "Player is assigned to " << MSG_COLOR_CYAN << count << "|r persistent instances.\n"; SendMultilineMessage(m_session, ss.str().c_str()); sGMLog.writefromsession(m_session, "used show instances command on %s,", plr->GetName()); return true; }
bool ChatHandler::HandleGetInstanceInfoCommand(const char* args, WorldSession* m_session) { Player* plr = m_session->GetPlayer(); if (plr == NULL) return false; bool userInput = true; uint32 instanceId = (args ? atoi(args) : 0); if (instanceId == 0) { userInput = false; instanceId = plr->GetInstanceID(); if (instanceId == 0) return false; } Instance* instance = sInstanceMgr.GetInstanceByIds(NUM_MAPS, instanceId); if (instance == NULL) { if (userInput) { RedSystemMessage(m_session, "Instance with id %u not found.", instanceId); return true; } return false; } std::stringstream ss; ss << "Instance ID: " << MSG_COLOR_CYAN << instance->m_instanceId << "|r (" << MSG_COLOR_CYAN; if (instance->m_mapInfo == NULL) ss << instance->m_mapId; else ss << instance->m_mapInfo->name; ss << "|r)\n"; ss << "Persistent: " << MSG_COLOR_CYAN << (instance->m_persistent ? "Yes" : "No") << "|r\n"; if (instance->m_mapInfo != NULL) { ss << "Type: " << MSG_COLOR_CYAN << GetMapTypeString(static_cast<uint8>(instance->m_mapInfo->type)) << "|r"; if (instance->m_mapInfo->type == INSTANCE_MULTIMODE) { ss << " (" << MSG_COLOR_CYAN << GetDifficultyString(static_cast<uint8>(instance->m_difficulty)) << "|r)"; } if (instance->m_mapInfo->type == INSTANCE_RAID) { ss << " (" << MSG_COLOR_CYAN << GetRaidDifficultyString(static_cast<uint8>(instance->m_difficulty)) << "|r)"; } ss << "\n"; } ss << "Created: " << MSG_COLOR_CYAN << ConvertTimeStampToDataTime((uint32)instance->m_creation) << "|r\n"; if (instance->m_expiration != 0) ss << "Expires: " << MSG_COLOR_CYAN << ConvertTimeStampToDataTime((uint32)instance->m_expiration) << "|r\n"; if (instance->m_mapMgr == NULL) { ss << "Status: " << MSG_COLOR_LIGHTRED << "Shut Down|r\n"; } else if (!instance->m_mapMgr->HasPlayers()) { ss << "Status: " << MSG_COLOR_LIGHTRED << "Idle|r"; if (instance->m_mapMgr->InactiveMoveTime && instance->m_mapMgr->GetMapInfo()->type != INSTANCE_NULL) ss << " (" << MSG_COLOR_CYAN << "Shutdown in " << MSG_COLOR_LIGHTRED << (((long)instance->m_mapMgr->InactiveMoveTime - UNIXTIME) / 60) << MSG_COLOR_CYAN << " minutes|r)"; ss << "\n"; } else { ss << "Status: " << MSG_COLOR_GREEN << "In use|r (" << MSG_COLOR_GREEN << (uint32)instance->m_mapMgr->GetPlayerCount() << MSG_COLOR_CYAN << " players inside|r)\n"; } SendMultilineMessage(m_session, ss.str().c_str()); return true; }
bool ChatHandler::HandleGetInstanceInfoCommand(const char* args, WorldSession *m_session) { Player *plr = m_session->GetPlayer(); if(plr == NULL) return false; bool userInput = true; uint32 instanceId = (args ? atoi(args) : 0); if(instanceId == 0) { userInput = false; instanceId = plr->GetInstanceID(); if(instanceId == 0) return false; } Instance *instance = sInstanceMgr.GetInstanceByIds(NUM_MAPS, instanceId); if(instance == NULL) { if(userInput) { RedSystemMessage(m_session, "Instance with id %u not found.", instanceId); return true; } return false; } std::stringstream ss; ss << "Instance ID: " << MSG_COLOR_CYAN << instance->m_instanceId << "|r (" << MSG_COLOR_CYAN; if(instance->m_mapInfo == NULL) ss << instance->m_mapId; else ss << instance->m_mapInfo->name; ss << "|r)\n"; ss << "Persistent: " << MSG_COLOR_CYAN << (instance->m_persistent ? "Yes" : "No") << "|r\n"; if(instance->m_mapInfo != NULL) { ss << "Type: " << MSG_COLOR_CYAN << GetMapTypeString(instance->m_mapInfo->type) << "|r"; if(instance->m_mapInfo->type == INSTANCE_MULTIMODE) { ss << " (" << MSG_COLOR_CYAN << GetDifficultyString(instance->m_difficulty) << "|r)"; } ss << "\n"; } ss << "Created: " << MSG_COLOR_CYAN << ConvertTimeStampToDataTime((uint32)instance->m_creation) << "|r\n"; ss << "Expires: " << MSG_COLOR_CYAN << ConvertTimeStampToDataTime((uint32)instance->m_expiration) << "|r\n"; if(instance->m_mapMgr == NULL) { ss << "Status: " << MSG_COLOR_LIGHTRED << "Shut Down|r\n"; } else if(!instance->m_mapMgr->HasPlayers()) { ss << "Status: " << MSG_COLOR_LIGHTRED << "Idle|r"; if(instance->m_mapMgr->InactiveMoveTime && instance->m_mapMgr->GetMapInfo()->type != INSTANCE_NULL) ss << " (" << MSG_COLOR_CYAN << "Shutdown in " << MSG_COLOR_LIGHTRED << ( ((long)instance->m_mapMgr->InactiveMoveTime - UNIXTIME) / 60 ) << MSG_COLOR_CYAN << " minutes|r)"; ss << "\n"; } else { ss << "Status: " << MSG_COLOR_GREEN << "In use|r (" << MSG_COLOR_GREEN << (uint32)instance->m_mapMgr->GetPlayerCount() << MSG_COLOR_CYAN << " players inside|r)\n"; //ss << "Playerlist:\n"; //int cnt = 0; ////TODO: Implement lock... //for(PlayerStorageMap::iterator itr = instance->m_mapMgr->m_PlayerStorage.begin(); itr != instance->m_mapMgr->m_PlayerStorage.end(); ++itr) //{ // if(cnt > 0) // ss << ", "; // if((*itr).second->GetSession()->GetPermissionCount() > 0) // ss << MSG_COLOR_LIGHTRED << (*itr).second->GetName() << "|r"; // else // ss << MSG_COLOR_CYAN << (*itr).second->GetName() << "|r"; // cnt++; // if(cnt >= 5) // { // cnt = 0; // ss << "\n"; // } //} } SendMultilineMessage(m_session, ss.str().c_str()); return true; }