Exemple #1
0
bool ChatHandler::HandleQuestItemCommand(const char * args, WorldSession * m_session)
{
	if(!*args) return false;

	std::string my_item_lookup = "SELECT item, item_count FROM gameobject_quest_item_binding WHERE quest = " + string(args);

	QueryResult *result = WorldDatabase.Query(my_item_lookup.c_str());

	std::string recout;

	if(!result)
	{
		recout = "|cff00ccffNo matches found.\n\n";
		SendMultilineMessage(m_session, recout.c_str());
		return true;
	}

	recout = "|cff00ff00Quest item matches: itemid: count -> Name\n\n";
	SendMultilineMessage(m_session, recout.c_str());

	uint32 count = 0;

	do
	{
		Field *fields = result->Fetch();
		uint32 id = fields[0].GetUInt32();
		string itemid  = MyConvertIntToString(id);
		string itemcnt = MyConvertIntToString(fields[1].GetUInt32());
		ItemPrototype* tmpItem = ItemPrototypeStorage.LookupEntry(id);
		recout = "|cff00ccff";
		recout += itemid.c_str();
		recout += ": ";
		recout += itemcnt.c_str();
		recout += " -> ";
		recout += tmpItem->Name1;
		recout += "\n";

		SendMultilineMessage(m_session, recout.c_str());

		count++;
		
		if(count == 25)
		{
			RedSystemMessage(m_session, "More than 25 results returned. aborting.");
			break;
		}
	}while (result->NextRow());

	delete result;

	if (count == 0)
	{
		recout = "|cff00ccffNo matches found.\n\n";
		SendMultilineMessage(m_session, recout.c_str());
	}

	return true;
}
Exemple #2
0
bool ChatHandler::ExecuteCommandInTable(ChatCommand *table, uint8* text)
{
    char *cmd = (char*)text;
	uint32 AcctLvl = m_pClient->getAccountLvl();

    while (*text != ' ' && *text != '\0') text++; // skip command
    if(*text != '\0')
    {
        *text = '\0';
        text++;
    }

    while (*text == ' ') text++; // skip whitespace

    if(*cmd == '\0')
        return false;

    for(uint32 i = 0; table[i].Name != NULL; i++)
    {
        if(!hasStringAbbr(table[i].Name, cmd))
            continue;

        if(AcctLvl < table[i].SecurityLevel)
            continue;

		if(table[i].ChildCommands != NULL)
        {
            if(!ExecuteCommandInTable(table[i].ChildCommands, text))
            {
                if(table[i].Help != "")
                    SendMultilineMessage(table[i].Help.c_str());
                else
                {
                    wowWData data;
                    FillMessageData(&data, 0x09, m_pClient, (uint8*)"There is no such subcommand.");
                    m_pClient->SendMsg(&data);
                }
            }
            return true;
        }

		if(!(this->*(table[i].Handler))(text))
        {
            if(table[i].Help != "")
                SendMultilineMessage(table[i].Help.c_str());
            else
            {
                wowWData data;
                FillMessageData(&data, 0x09, m_pClient, (uint8*)"Incorrect syntax.");
                m_pClient->SendMsg(&data);
            }
        }
        return true;
    }
    return false;
}
Exemple #3
0
bool ChatHandler::HandleCommandsCommand(const char* args, WorldSession* m_session)
{
    ChatCommand* table = CommandTableStorage::getSingleton().Get();

    std::string output;
    uint32 count = 0;

    output = "Available commands: \n\n";

    for (uint32 i = 0; table[i].Name != NULL; i++)
    {
        if (*args && !hasStringAbbr(table[i].Name, (char*)args))
            continue;

        if (table[i].CommandGroup != '0' && !m_session->CanUseCommand(table[i].CommandGroup))
            continue;

        switch (table[i].CommandGroup)
        {
            case 'z':
            {
                output += "|cffff6060";
                output += table[i].Name;
                output += "|r, ";
            }break;
            case 'm':
            {
                output += "|cff00ffff";
                output += table[i].Name;
                output += ", ";
            }break;
            case 'c':
            {
                output += "|cff00ff00";
                output += table[i].Name;
                output += "|r, ";
            }break;
            default:
            {
                output += "|cff00ccff";
                output += table[i].Name;
                output += "|r, ";
            }break;
        }

        ++count;
        if (count == 5)  // 5 per line
        {
            output += "\n";
            count = 0;
        }
    }

    if (count)
        output += "\n";

    SendMultilineMessage(m_session, output.c_str());

    return true;
}
Exemple #4
0
bool ChatHandler::ShowHelpForCommand(WorldSession *m_session, ChatCommand *table, const char* cmd)
{
	for(uint32 i = 0; table[i].Name != NULL; i++)
	{
		if(!hasStringAbbr(table[i].Name, cmd))
			continue;

		if(m_session->CanUseCommand(table[i].CommandGroup))
			continue;

		if(table[i].ChildCommands != NULL)
		{
			cmd = strtok(NULL, " ");
			if(cmd && ShowHelpForCommand(m_session, table[i].ChildCommands, cmd))
				return true;
		}

		if(table[i].Help == "")
		{
			SystemMessage(m_session, "There is no help for that command");
			return true;
		}

		SendMultilineMessage(m_session, table[i].Help.c_str());

		return true;
	}

	return false;
}
Exemple #5
0
bool ChatHandler::HandleTicketListAllCommand(const char* /*args*/, WorldSession* m_session)
{
    Player* player = m_session->GetPlayer();

    QueryResult* result = CharacterDatabase.Query("SELECT * FROM gm_tickets");

    if (!result)
        return false;

    std::stringstream sstext;
    sstext << "List of active tickets: " << '\n';

    do
    {
        Field* fields = result->Fetch();
        sstext << "TicketID: " << fields[0].GetUInt16()
            << " | Player: " << fields[2].GetString()
            << " | Opened: " << Util::GetDateStringFromSeconds((uint32)UNIXTIME - fields[9].GetUInt32())
            << '\n';
    } while (result->NextRow());

    delete result;

    SendMultilineMessage(m_session, sstext.str().c_str());

    return true;
}
Exemple #6
0
bool ChatHandler::HandleTicketGetCommand(const char* args, WorldSession* m_session)
{
    if (!args)
    {
        RedSystemMessage(m_session, "You need to specify a ticket ID!");
        return false;
    }

    Player* player = m_session->GetPlayer();

    uint32 ticketID = atol(args);

    QueryResult* result = CharacterDatabase.Query("SELECT * FROM gm_tickets WHERE ticketid = %u", ticketID);

    if (!result)
        return false;

    std::stringstream sstext;
    Field* fields = result->Fetch();

    sstext << "Ticket ID: " << ticketID << " | Player: " << fields[2].GetString() << '\n'
            << "======= Content =======" << '\n'
            << fields[8].GetString() << '\n';

    delete result;

    SendMultilineMessage(m_session, sstext.str().c_str());

    return true;
}
Exemple #7
0
bool
ChatHandler::ShowHelpForCommand(ChatCommand *table, const char* cmd)
{
    for(uint32 i = 0; table[i].Name != NULL; ++i)
    {
        if(!hasStringAbbr(table[i].Name, cmd))
            continue;
        if(m_session->GetSecurity() < table[i].SecurityLevel)
            continue;

        if(table[i].ChildCommands != NULL)
        {
            cmd = strtok(NULL, " ");
            if(cmd && ShowHelpForCommand(table[i].ChildCommands, cmd))
                return true;
        }

        if(table[i].Help == "")
        {
			m_session->SystemMessage(LANG_CMD_NOHELP);
            return true;
        }

        SendMultilineMessage(table[i].Help.c_str());

        return true;
    }

    return false;
}
Exemple #8
0
bool ChatHandler::HandleRecallListCommand(const char* args, WorldSession *m_session)
{
	QueryResult *result = WorldDatabase.Query( "SELECT id,name FROM recall ORDER BY name" );
	if(!result)
		return false;
	std::string recout;
	uint32 count = 0;

	recout = "|cff00ff00Recall locations|r:\n\n";
	do
	{
		Field *fields = result->Fetch();
		//float id = fields[0].GetFloat();
		const char * locname = fields[1].GetString();
		recout += "|cff00ccff";
		recout += locname;
		recout += "|r, ";
		count++;
		
		if(count == 5)
		{
			recout += "\n";
			count = 0;
		}
	}while (result->NextRow());
	SendMultilineMessage(m_session, recout.c_str());

	delete result;
	return true;
}
Exemple #9
0
bool ChatHandler::ShowHelpForCommand(ChatCommand *table, const char* cmd)
{
    for(uint32 i = 0; table[i].Name != NULL; i++)
    {
        if(!hasStringAbbr(table[i].Name, cmd))
            continue;

        if(m_session->GetSecurity() < table[i].SecurityLevel)
            continue;

        if(table[i].ChildCommands != NULL)
        {
            cmd = strtok(NULL, " ");
            if(cmd && ShowHelpForCommand(table[i].ChildCommands, cmd))
                return true;
        }

        if(table[i].Help == "")
        {
            WorldPacket data;
            FillSystemMessageData(&data, m_session, "There is no help for that command");
            m_session->SendPacket(&data);
            return true;
        }

        SendMultilineMessage(table[i].Help.c_str());

        return true;
    }

    return false;
}
Exemple #10
0
bool ChatHandler::HandleListAIAgentCommand(const char* args, WorldSession *m_session)
{
	Unit* target = m_session->GetPlayer()->GetMapMgr()->GetCreature(GET_LOWGUID_PART(m_session->GetPlayer()->GetSelection()));
	if(!target)
	{
		RedSystemMessage(m_session, "You have to select a Creature!");
		return false;
	}

	std::stringstream sstext;
	sstext << "agentlist of creature: " << target->GetGUID() << '\n';

	std::stringstream ss;
	ss << "SELECT * FROM ai_agents where entry=" << target->GetUInt32Value(OBJECT_FIELD_ENTRY);
	QueryResult *result = WorldDatabase.Query( ss.str().c_str() );

	if( !result )
		return false;

	do
	{
		Field *fields = result->Fetch();
		sstext << "agent: "   << fields[1].GetUInt16()
			<< " | spellId: " << fields[5].GetUInt32()
			<< " | Event: "   << fields[2].GetUInt32()
			<< " | chance: "  << fields[3].GetUInt32()
			<< " | count: "   << fields[4].GetUInt32() << '\n';
	} while( result->NextRow() );

	delete result;

	SendMultilineMessage(m_session, sstext.str().c_str());

	return true;
}
bool ChatHandler::HandleWPInfoCommand(const char* args, WorldSession *m_session)
{
	uint64 guid = m_session->GetPlayer()->GetSelection();
	if (guid == 0)
	{
		SystemMessage(m_session, "No selection.");
		return true;
	}

	if(GET_TYPE_FROM_GUID(guid) != HIGHGUID_TYPE_WAYPOINT)
	{
		SystemMessage(m_session, "You should select a Waypoint.");
		return true;
	}

	Player* pPlayer = m_session->GetPlayer();
	AIInterface* ai = pPlayer->waypointunit;
	if(!ai || !ai->GetUnit())
	{
		SystemMessage(m_session, "Invalid Creature, please select another one.");
		return true;
	}
	std::stringstream ss;

	uint32 wpid = GUID_LOPART(guid);
	if((wpid > 0) && (wpid <= ai->GetWayPointsCount()))
	{
		WayPoint* wp = ai->getWayPoint(wpid);
		if(wp)
		{
			ss << "Waypoint Number " << wp->id << ":\n";
			ss << "WaitTime: " << wp->waittime << "\n";
			ss << "Flags: " << wp->flags;
			if(wp->flags == 768)
				ss << " (Fly)\n";
			else if(wp->flags == 256)
				ss << " (Run)\n";
			else
				ss << " (Walk)\n";
			ss << "Backwards\n";
			ss << "   emoteid: " << wp->backwardemoteid << "\n";
			ss << "   oneshot: " << ((wp->backwardemoteoneshot == 1)? "Yes" : "No") << "\n";
			ss << "   skinid: " << wp->backwardskinid << "\n";
			ss << "Forwards\n";
			ss << "   emoteid: " << wp->forwardemoteid << "\n";
			ss << "   oneshot: " << ((wp->forwardemoteoneshot == 1)? "Yes" : "No") << "\n";
			ss << "   skinid: " << wp->forwardskinid << "\n";
			SendMultilineMessage(m_session, ss.str().c_str());
		}
	}
	else
	{
	   SystemMessage(m_session,  "Invalid Waypoint.");
		return true;
	}
	return true;
}
Exemple #12
0
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;
}
Exemple #13
0
bool ChatHandler::HandleQuestRewardCommand(const char * args, WorldSession * m_session)
{
	if(!*args) return false;

	string recout = "";

	recout += "\n\n";

	SendMultilineMessage(m_session, recout.c_str());

	return true;
}
bool ChatHandler::HandleWaypointGettextCommand(const char* args, WorldSession *m_session)
{
    uint64 guid = m_session->GetPlayer()->GetSelection();
    if (guid == 0)
    {
        SystemMessage(m_session, "No selection.");
        return true;
    }

    if(GET_TYPE_FROM_GUID(guid) != HIGHGUID_TYPE_WAYPOINT)
    {
        SystemMessage(m_session, "You should select a Waypoint.");
        return true;
    }

    Player* pPlayer = m_session->GetPlayer();
    AIInterface* ai = pPlayer->waypointunit;
    if(!ai || !ai->GetUnit())
    {
        SystemMessage(m_session, "Invalid Creature, please select another one.");
        return true;
    }
    std::stringstream ss;

    uint32 wpid = GUID_LOPART(guid);
    if((wpid > 0) && (wpid <= ai->GetWayPointsCount()))
    {
        WayPoint* wp = ai->getWayPoint(wpid);
        if(wp)
        {
            ss << "Waypoint Number " << wp->id << ":\n";
            if(wp->backwardInfo)
            {
                ss << "Backward:\n";
                ss << wp->backwardInfo->SayText << "\n";
            }
            if(wp->forwardInfo)
            {
                ss << "Forward:\n";
                ss << wp->forwardInfo->SayText << "\n";
            }
            SendMultilineMessage(m_session, ss.str().c_str());
        }
    }
    else
    {
       SystemMessage(m_session,  "Invalid Waypoint.");
        return true;
    }
    return true;
}
Exemple #15
0
bool ChatHandler::HandleWPMoveTypeCommand(const char* args, WorldSession *m_session)
{
	if(!*args)
		return false;

	uint32 option = atoi((char*)args);

	if (option != 0 && option != 1 && option != 2)
	{
		std::stringstream ss;
		ss << "Incorrect value." << endl;
		ss << "0 is Move from WP 1 ->  10 then 10 -> 1." << endl;
		ss << "1 is Move from WP to a random WP." << endl;
		ss << "2 is Move from WP 1 -> 10 then 1 -> 10." << endl;
		SendMultilineMessage(m_session, ss.str().c_str());
		return true;
	}

	uint64 guid = m_session->GetPlayer()->GetSelection();
	if (guid == 0)
	{
		SystemMessage(m_session, "No selection.");
		return true;
	}

	Creature* pCreature = m_session->GetPlayer()->GetMapMgr()->GetCreature(GET_LOWGUID_PART(guid));
	if(!pCreature)
	{
		SystemMessage(m_session, "You should select a creature.");
		return true;
	}

	if( pCreature->m_spawn == NULL )
	{
		SystemMessage(m_session, "You cannot add waypoints to a creature that is not saved.");
		return true;
	}

	char sql[512];
	snprintf(sql, 512, "UPDATE creature_spawns SET movetype = '%u' WHERE id = '%u'", (unsigned int)option, (unsigned int)pCreature-> GetSQL_id());
	WorldDatabase.Execute( sql );

	pCreature->GetAIInterface()->setMoveType(option);

	SystemMessage(m_session, "Value saved to database.");
	return true;
}
Exemple #16
0
bool ChatHandler::HandleQuestStatusCommand(const char * args, WorldSession * m_session)
{
	if(!*args) return false;

	Player *plr = getSelectedChar(m_session, true);
	if(!plr)
	{
		plr = m_session->GetPlayer();
		SystemMessage(m_session, "Auto-targeting self.");
	}

	uint32 quest_id = atol(args);
	if(quest_id== 0)
	{
		quest_id = GetQuestIDFromLink(args);
		if(quest_id== 0)
			return false;
	}
	std::string recout = "|cff00ff00";

	Quest * qst = QuestStorage.LookupEntry(quest_id);
	if(qst)
	{
		if (plr->HasFinishedQuest(quest_id))
			recout += "Player has already completed that quest.";
		else
		{
			QuestLogEntry * IsPlrOnQuest = plr->GetQuestLogForEntry(quest_id);
			if (IsPlrOnQuest)
				recout += "Player is currently on that quest.";
			else
				recout += "Player has NOT finished that quest.";
		}
	}
	else
	{
		recout += "Quest Id [";
		recout += args;
		recout += "] was not found and unable to add it to the player's quest log.";
	}

	recout += "\n\n";

	SendMultilineMessage(m_session, recout.c_str());

	return true;
}
bool ChatHandler::HandleRecallListCommand(const char* args, WorldSession *m_session)
{
    if(!args || *args == NULL)
        return false;

    std::set<RecallLocation*> locations;
    if(!objmgr.FillRecallNames(std::string(args), locations))
        return false;

    uint32 count = 0;
    std::string recout;
    recout = "|cff00ff00Recall locations|r:\n\n";
    for(std::set<RecallLocation*>::iterator itr = locations.begin(); itr != locations.end(); itr++)
    {
        recout += "|cff00ccff";
        recout += (*itr)->RealName;
        recout += "|r, ";
        if(count%5 == 5)
            recout += "\n";
    }
    SendMultilineMessage(m_session, recout.c_str());
    return true;
}
Exemple #18
0
bool ChatHandler::HandleQuestSpawnCommand(const char * args, WorldSession * m_session)
{
	if(!*args) return false;

	std::string recout;

	std::string my_query = "SELECT id FROM creature_quest_starter WHERE quest = " + string(args);
	QueryResult *objectResult = WorldDatabase.Query(my_query.c_str());

	string starterId;
	if(objectResult)
	{
		Field *fields = objectResult->Fetch();
		starterId = MyConvertIntToString(fields[0].GetUInt32());
	}
	else
	{
		recout = "|cff00ccffNo quest starters found.\n\n";
		SendMultilineMessage(m_session, recout.c_str());
		return true;
	}

	delete objectResult;

	std::string starterName = "N/A";
	CreatureInfo *creatureResult = CreatureNameStorage.LookupEntry(atol(starterId.c_str()));

	if(creatureResult)
		starterName = creatureResult->Name;
	else
	{
		recout = "|cff00ccffNo quest starter info found.\n\n";
		SendMultilineMessage(m_session, recout.c_str());
		return true;
	}

	my_query = "SELECT map, position_x, position_y, position_z FROM creature_spawns WHERE entry = " + starterId;
	QueryResult *spawnResult = WorldDatabase.Query(my_query.c_str());

	if(!spawnResult)
	{
		recout = "|cff00ccffNo spawn location for quest starter was found.\n\n";
		SendMultilineMessage(m_session, recout.c_str());
		return true;
	}

	Field *fields = spawnResult->Fetch();
	uint32 locmap = fields[0].GetUInt32();
	float x = fields[1].GetFloat();
	float y = fields[2].GetFloat();
	float z = fields[3].GetFloat();

	delete spawnResult;

	recout = "|cff00ccffPorting to Quest Starter/Giver: id, name\n\n";
	SendMultilineMessage(m_session, recout.c_str());

	recout = "|cff00ccff";
	recout += starterId.c_str();
	recout += ", ";
    recout += starterName.c_str();
	recout += "\n\n";
	SendMultilineMessage(m_session, recout.c_str());

	m_session->GetPlayer()->SafeTeleport(locmap, 0, LocationVector(x, y, z));

	return true;
}
Exemple #19
0
bool ChatHandler::HandleQuestLookupCommand(const char * args, WorldSession * m_session)
{
	if(!*args) return false;

	string x = string(args);
	ASCENT_TOLOWER(x);
	if(x.length() < 4)
	{
		RedSystemMessage(m_session, "Your search string must be at least 5 characters long.");
		return true;
	}

	BlueSystemMessage(m_session, "Starting search of quests `%s`...", x.c_str());
	uint32 t = getMSTime();

	StorageContainerIterator<Quest> * itr = QuestStorage.MakeIterator();

	Quest * i;
	uint32 count = 0;
	string y;
	string recout;

	while(!itr->AtEnd())
	{
		i = itr->Get();

		y = string(i->title);
		ASCENT_TOLOWER(y);

		if(FindXinYString(x, y))
		{
			string questid = MyConvertIntToString(i->id);
			const char * questtitle = i->title;
			recout = "|cff00ccff";
			recout += questid.c_str();
			recout += ": ";
			recout += questtitle;
			recout += "\n";
			SendMultilineMessage(m_session, recout.c_str());

			++count;
			if(count == 25)
			{
				RedSystemMessage(m_session, "More than 25 results returned. aborting.");
				break;
			}
		}
		if(!itr->Inc())
			break;
	}
	itr->Destruct();

	if (count == 0)
	{
		recout = "|cff00ccffNo matches found.\n\n";
		SendMultilineMessage(m_session, recout.c_str());
	}

	BlueSystemMessage(m_session, "Search completed in %u ms.", getMSTime() - t);

	return true;
}
Exemple #20
0
bool ChatHandler::HandleQuestFinishCommand(const char * args, WorldSession * m_session)
{
	if(!*args) return false;

	Player *plr = getSelectedChar(m_session, true);
	if(!plr)
	{
		plr = m_session->GetPlayer();
		SystemMessage(m_session, "Auto-targeting self.");
	}

	uint32 quest_id = atol(args);
	std::string recout = "|cff00ff00";

	Quest * qst = QuestStorage.LookupEntry(quest_id);
	if(qst)
	{
		if (plr->HasFinishedQuest(quest_id))
			recout += "Player has already completed that quest.\n\n";
		else
		{
			QuestLogEntry * IsPlrOnQuest = plr->GetQuestLogForEntry(quest_id);
			if (IsPlrOnQuest)
			{	
				uint32 giver_id = 0;
				std::string my_query = "";

				my_query = "SELECT id FROM creature_quest_starter WHERE quest = " + string(args);
				QueryResult *creatureResult = WorldDatabase.Query(my_query.c_str());

				if(creatureResult)
				{
					Field *creatureFields = creatureResult->Fetch();
					giver_id = creatureFields[0].GetUInt32();
					delete creatureResult;
				}
				else
				{
					my_query = "SELECT id FROM gameobject_quest_starter WHERE quest = " + string(args);
					QueryResult *objectResult = WorldDatabase.Query(my_query.c_str());
					if(objectResult)
					{
						Field *objectFields = objectResult->Fetch();
						giver_id = objectFields[0].GetUInt32();
						delete objectResult;
					}
				}

				if(giver_id == 0)
					SystemMessage(m_session, "Unable to find quest giver creature or object.");
				else
				{
					// I need some way to get the guid without targeting the creature or looking through all the spawns...
					Object *quest_giver;

					for(uint32 guid=1; guid < plr->GetMapMgr()->m_CreatureArraySize; guid++)
					{
						Creature *pCreature = plr->GetMapMgr()->GetCreature(GET_LOWGUID_PART(guid));
						if(pCreature)
						{
							if(pCreature->GetEntry() == giver_id) //found creature
							{
								quest_giver = (Object*)pCreature;
								guid = plr->GetMapMgr()->m_CreatureArraySize;
							}
						}
					}

					if(quest_giver)
					{
						GreenSystemMessage(m_session, "Found a quest_giver creature.");
						//WorldPacket data;
						//sQuestMgr.BuildOfferReward(&data, qst, quest_giver, 1);
						//m_session->SendPacket(&data);
						sQuestMgr.GiveQuestRewardReputation(plr, qst, quest_giver);
					}
					else
						RedSystemMessage(m_session, "Unable to find quest_giver object.");
				}

				sQuestMgr.GenerateQuestXP(plr, qst);
				sQuestMgr.BuildQuestComplete(plr, qst);

				IsPlrOnQuest->Finish();
				recout += "Player was on that quest, but has now completed it.";
			}
			else
				recout += "The quest has now been completed for that player.";

			plr->AddToFinishedQuests(quest_id);
		}
	}
	else
	{
		recout += "Quest Id [";
		recout += args;
		recout += "] was not found and unable to add it to the player's quest log.";
	}

	recout += "\n\n";

	SendMultilineMessage(m_session, recout.c_str());

	return true;
}
Exemple #21
0
bool ChatHandler::HandleQuestStartCommand(const char * args, WorldSession * m_session)
{
	if(!*args) return false;

	Player *plr = getSelectedChar(m_session, true);
	if(!plr)
	{
		plr = m_session->GetPlayer();
		SystemMessage(m_session, "Auto-targeting self.");
	}

	uint32 quest_id = atol(args);
	std::string recout = "|cff00ff00";

	Quest * qst = QuestStorage.LookupEntry(quest_id);
	if(qst)
	{
		if (plr->HasFinishedQuest(quest_id))
			recout += "Player has already completed that quest.";
		else
		{
			QuestLogEntry * IsPlrOnQuest = plr->GetQuestLogForEntry(quest_id);
			if (IsPlrOnQuest)
				recout += "Player is currently on that quest.";
			else
			{
				int32 open_slot = plr->GetOpenQuestSlot();

				if (open_slot == -1)
				{
					sQuestMgr.SendQuestLogFull(plr);
					recout += "Player's quest log is full.";
				}
				else
				{
					QuestLogEntry *qle = new QuestLogEntry();
					qle->Init(qst, plr, (uint32)open_slot);
					qle->UpdatePlayerFields();
		
					// If the quest should give any items on begin, give them the items.
					for(uint32 i = 0; i < 4; ++i)
					{
						if(qst->receive_items[i])
						{
							Item *item = objmgr.CreateItem( qst->receive_items[i], plr);
							if(!plr->GetItemInterface()->AddItemToFreeSlot(item))
								delete item;
						}
					}

					if(qst->srcitem && qst->srcitem != qst->receive_items[0])
					{
						Item * item = objmgr.CreateItem( qst->srcitem, plr);
						if(item)
						{
							item->SetUInt32Value(ITEM_FIELD_STACK_COUNT, qst->srcitemcount ? qst->srcitemcount : 1);
							if(!plr->GetItemInterface()->AddItemToFreeSlot(item))
								delete item;
						}
					}
				

					//if(qst->count_required_item || qst_giver->GetTypeId() == TYPEID_GAMEOBJECT)	// gameobject quests deactivate
					//	plr->UpdateNearbyGameObjects();
					//ScriptSystem->OnQuestEvent(qst, static_cast< Creature* >( qst_giver ), _player, QUEST_EVENT_ON_ACCEPT);
				
					sHookInterface.OnQuestAccept( plr, qst );

					recout += "Quest has been added to the player's quest log.";
				}
			}
		}
	}
	else
	{
		recout += "Quest Id [";
		recout += args;
		recout += "] was not found and unable to add it to the player's quest log.";
	}

	recout += "\n\n";

	SendMultilineMessage(m_session, recout.c_str());

	return true;
}
Exemple #22
0
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;
}
Exemple #23
0
bool ChatHandler::HandleQuestGiverCommand(const char * args, WorldSession * m_session)
{
	if(!*args) return false;

	std::string recout;

	std::string my_query1 = "SELECT id FROM creature_quest_starter WHERE quest = " + string(args);
	QueryResult *objectResult1 = WorldDatabase.Query(my_query1.c_str());

	if(objectResult1)
	{
		Field *fields = objectResult1->Fetch();
		std::string creatureId1 = MyConvertIntToString(fields[0].GetUInt32());

		delete objectResult1;

		std::string creatureName1 = "N/A";
		CreatureInfo *creatureResult1 = CreatureNameStorage.LookupEntry(atol(creatureId1.c_str()));
		if (creatureResult1)
		{
			creatureName1 = creatureResult1->Name;

			my_query1 = "SELECT id FROM creature_spawns WHERE entry = " + creatureId1;
			QueryResult *spawnResult1 = WorldDatabase.Query(my_query1.c_str());

			string spawnId1;
			if(spawnResult1)
			{
				Field *fields = spawnResult1->Fetch();
				spawnId1 = fields[0].GetString();

				delete spawnResult1;
			}
			else
				spawnId1 = "N/A";

			recout = "|cff00ccffQuest Starter found: creature id, spawnid, name\n\n";
			SendMultilineMessage(m_session, recout.c_str());

			recout = "|cff00ccff";
			recout += creatureId1.c_str();
			recout += ", ";
			recout += spawnId1.c_str();
			recout += ", ";
			recout += creatureName1.c_str();
			recout += "\n\n";
			SendMultilineMessage(m_session, recout.c_str());
		}
		else
		{
			recout = "|cff00ccffNo creature quest starter info found.\n\n";
			SendMultilineMessage(m_session, recout.c_str());
		}

	}
	else
	{
		recout = "|cff00ccffNo creature quest starters found.\n\n";
		SendMultilineMessage(m_session, recout.c_str());
	}

	std::string my_query2 = "SELECT id FROM gameobject_quest_starter WHERE quest = " + string(args);
	QueryResult *objectResult2 = WorldDatabase.Query(my_query2.c_str());

	if(objectResult2)
	{
		Field *fields = objectResult2->Fetch();
		std::string itemId2 = MyConvertIntToString(fields[0].GetUInt32());

		delete objectResult2;

		std::string itemName2 = "N/A";
		ItemPrototype *itemResult2 = ItemPrototypeStorage.LookupEntry(atol(itemId2.c_str()));
		if (itemResult2)
		{
			itemName2 = itemResult2->Name1;

			my_query2 = "SELECT id FROM gameobject_spawns WHERE entry = " + itemId2;
			QueryResult *spawnResult2 = WorldDatabase.Query(my_query2.c_str());

			string spawnId2;
			if(spawnResult2)
			{
				Field *fields = spawnResult2->Fetch();
				spawnId2 = fields[0].GetString();

				delete spawnResult2;
			}
			else
				spawnId2 = "N/A";

			recout = "|cff00ccffQuest starter found: object id, spawnid, name\n\n";
			SendMultilineMessage(m_session, recout.c_str());

			recout = "|cff00ccff";
			recout += itemId2.c_str();
			recout += ", ";
			recout += spawnId2.c_str();
			recout += ", ";
			recout += itemName2.c_str();
			recout += "\n\n";
			SendMultilineMessage(m_session, recout.c_str());
		}
		else
		{
			recout = "|cff00ccffNo object quest starter info found.\n\n";
			SendMultilineMessage(m_session, recout.c_str());
		}
	}
	else
	{
		recout = "|cff00ccffNo object quest starters found.\n\n";
		SendMultilineMessage(m_session, recout.c_str());
	}

	return true;
}
Exemple #24
0
bool ChatHandler::HandleCommandsCommand(const char* args, WorldSession *m_session)
{
	ChatCommand *table = sComTableStore.Get();
	WorldPacket data;

	std::string output;
	uint32 count = 0;

	output = "Available commands: \n\n";

	for(uint32 i = 0; table[i].Name != NULL; i++)
	{
		if(*args && !hasStringAbbr(table[i].Name, (char*)args))
			continue;

		if(table[i].CommandGroup != '0' && !m_session->CanUseCommand(table[i].CommandGroup))
			continue;

		switch(table[i].CommandGroup)
		{
		case 'z':
			{
				output+="|cffff6060";
				output+=table[i].Name;
				output+="|r, ";
			}
			break;
		case 'm':
			{
				output+="|cff00ffff";
				output+=table[i].Name;
				output+=", ";
			}
			break;
		case 'c':
			{
				output += "|cff00ff00";
				output += table[i].Name;
				output += "|r, ";
			}break;
		default:
			{
				output+="|cff00ccff";
				output+=table[i].Name;
				output+="|r, ";
			}
			break;
		}

		count++;
		if(count == 5)  // 5 per line
		{
			output += "\n";
			count = 0;
		}
	}
	if(count)
		output += "\n";


		//FillSystemMessageData(&data, table[i].Name);
		//m_session->SendPacket(&data);
	//}

	SendMultilineMessage(m_session, output.c_str());

	return true;
}
Exemple #25
0
bool ChatHandler::HandleGMListCommand(const char* args, WorldSession *m_session)
{
	stringstream out;
	out << MSG_COLOR_GREEN << "Online GMs:|r\n";

	WorldPacket data;
	bool found = false;
	bool admin = RANK_CHECK(RANK_ADMIN);
	PlayerStorageMap::const_iterator itr;
	objmgr._playerslock.AcquireReadLock();
	for (itr = objmgr._players.begin(); itr != objmgr._players.end(); itr++)
	{
		//if(itr->second->GetSession()->GetPermissionCount())//ORIGINAL LINE
		if(itr->second->GetSession()->GetPermissionCount())
		{
			if (!itr->second->m_isGmInvisible || admin)
			{
				found = true;

				if (itr->second->GetSession()->m_gmData->dev)
					out << MSG_COLOR_LIGHTBLUE; 
				else
					switch (itr->second->GetSession()->m_gmData->rank)
					{
					case RANK_SYRA:
						out << MSG_COLOR_GREENYELLOW;
						break;
					case RANK_ADMIN: //admin
						out << MSG_COLOR_ADMIN;
						break;
					case RANK_COADMIN:
						out << MSG_COLOR_COADMIN;
						break;
					}

				if (admin) //Add acct name for admins
					out << "[Account: " << itr->second->GetSession()->GetAccountName().c_str() << "] ";


				out << itr->second->GetName();
				out << " [";
				out << itr->second->GetSession()->m_gmData->perms.c_str();
				out << "]";

				if(itr->second->GetSession()->m_gmData->suspended >= (uint32)UNIXTIME)
					out << " -- SUSPENDED";

				if(itr->second->GetSession()->m_gmData->temp >= (uint32)UNIXTIME)
					out << " -- TEMPORARY";

				out << "\n";
			}
		}
	}

	objmgr._playerslock.ReleaseReadLock();
	if(!found)
	{
		out.clear();
		out << "There are no GMs currently logged in on this server. \n";
	}

	SendMultilineMessage(m_session, out.str().c_str());
	return true;
}
Exemple #26
0
bool ChatHandler::HandleQuestListCommand(const char * args, WorldSession * m_session)
{
	uint32 quest_giver = 0;
	if(*args)
		quest_giver = atol(args);
	else
	{
		uint64 guid = m_session->GetPlayer()->GetSelection();
		if (guid == 0)
		{
			SystemMessage(m_session, "You must target an npc or specify an id.");
			return true;
		}

		Creature *unit = m_session->GetPlayer()->GetMapMgr()->GetCreature(GET_LOWGUID_PART(guid));
		if(unit)
		{
			if (!unit->isQuestGiver())
			{
				SystemMessage(m_session, "Unit is not a valid quest giver.");
				return true;
			}

			if (!unit->HasQuests())
			{
				SystemMessage(m_session, "NPC does not have any quests.");
				return true;
			}

			quest_giver = unit->GetEntry();
		}
	}

	string recout = "|cff00ff00Quest matches: id: title\n\n";
	SendMultilineMessage(m_session, recout.c_str());

	uint32 count = 0;
	uint32 quest_id = 0;
	Quest * qst;
	Field *fields;

	if(quest_giver == 0)
	{
		Player *plr = getSelectedChar(m_session, true);
		if(!plr)
		{
			plr = m_session->GetPlayer();
			SystemMessage(m_session, "Auto-targeting self.");
		}

		if(plr)
		{
			if(plr->HasQuests())
			{
				QueryResult *playerResult = CharacterDatabase.Query("SELECT quest_id FROM questlog WHERE player_guid=%u", plr->GetLowGUID());
				if(playerResult)
				{
					do 
					{
						fields = playerResult->Fetch();
						quest_id = fields[0].GetUInt32();

						qst = QuestStorage.LookupEntry(quest_id);

						string qid  = MyConvertIntToString(quest_id);
						const char * qname = qst->title;

						recout = "|cff00ccff";
						recout += qid.c_str();
						recout += ": ";
						recout += qname;
						recout += "\n";

						SendMultilineMessage(m_session, recout.c_str());

						count++;
						
						if(count == 25)
						{
							RedSystemMessage(m_session, "More than 25 results returned. aborting.");
							break;
						}

					} while(playerResult->NextRow());

					delete playerResult;
				}
			}
		}
	}
	else
	{
		QueryResult *creatureResult = WorldDatabase.Query("SELECT quest FROM creature_quest_starter WHERE id = %u", quest_giver);

		if(!creatureResult)
		{
			recout = "|cff00ccffNo quests found for the specified NPC id.\n\n";
			SendMultilineMessage(m_session, recout.c_str());
			return true;
		}

		do
		{
			Field *fields = creatureResult->Fetch();
			uint32 quest_id = fields[0].GetUInt32();

			qst = QuestStorage.LookupEntry(quest_id);
			if(qst==NULL)
				continue;

			string qid  = MyConvertIntToString(quest_id);
			const char * qname = qst->title;

			recout = "|cff00ccff";
			recout += qid.c_str();
			recout += ": ";
			recout += qname;
			recout += "\n";

			SendMultilineMessage(m_session, recout.c_str());

			count++;
			
			if(count == 25)
			{
				RedSystemMessage(m_session, "More than 25 results returned. aborting.");
				break;
			}
		}while (creatureResult->NextRow());

		delete creatureResult;
	}

	if (count == 0)
	{
		recout = "|cff00ccffNo matches found.\n\n";
		SendMultilineMessage(m_session, recout.c_str());
	}

	return true;
}
Exemple #27
0
bool ChatHandler::HandleQuestAddStartCommand(const char * args, WorldSession * m_session)
{
	if(!*args) return false;

	uint64 guid = m_session->GetPlayer()->GetSelection();
	if (guid == 0)
	{
		SystemMessage(m_session, "You must target an npc.");
		return false;
	}

	Creature *unit = m_session->GetPlayer()->GetMapMgr()->GetCreature(GET_LOWGUID_PART(guid));
	if(!unit)
	{
		SystemMessage(m_session, "You must target an npc.");
		return false;
	}

	if (!unit->isQuestGiver())
	{
		SystemMessage(m_session, "Unit is not a valid quest giver.");
		return false;
	}

	uint32 quest_id = atol(args);
	Quest * qst = QuestStorage.LookupEntry(quest_id);

	if (qst == NULL)
	{
		SystemMessage(m_session, "Invalid quest selected, unable to add quest to the specified NPC.");
		return false;
	}

	std::string quest_giver = MyConvertIntToString(unit->GetEntry());

	std::string my_query1 = "SELECT id FROM creature_quest_starter WHERE id = " + quest_giver + " AND quest = " + string(args);
	QueryResult *selectResult1 = WorldDatabase.Query(my_query1.c_str());
	if (selectResult1)
	{
		delete selectResult1;
		SystemMessage(m_session, "Quest was already found for the specified NPC.");
	}
	else
	{
		std::string my_insert1 = "INSERT INTO creature_quest_starter (id, quest) VALUES (" + quest_giver + "," + string(args) + ")";
		QueryResult *insertResult1 = WorldDatabase.Query(my_insert1.c_str());
		if (insertResult1)
			delete insertResult1;
	}

	std::string my_query2 = "SELECT id FROM gameobject_quest_starter WHERE id = " + quest_giver + " AND quest = " + string(args);
	QueryResult *selectResult2 = WorldDatabase.Query(my_query2.c_str());
	if (selectResult2)
		delete selectResult2;
	else
	{
		std::string my_insert2 = "INSERT INTO gameobject_quest_starter (id, quest) VALUES (" + quest_giver + "," + string(args) + ")";
		QueryResult *insertResult2 = WorldDatabase.Query(my_insert2.c_str());
		if (insertResult2)
			delete insertResult2;
	}

	sQuestMgr.LoadExtraQuestStuff();

	QuestRelation *qstrel = new QuestRelation;
	qstrel->qst = qst;
	qstrel->type = QUESTGIVER_QUEST_START;
	uint8 qstrelid = (uint8)unit->GetQuestRelation(quest_id);
	unit->FindQuest(quest_id, qstrelid);
	unit->AddQuest(qstrel);
	unit->_LoadQuests();

	const char * qname = qst->title;

	std::string recout = "|cff00ff00Added Quest to NPC as starter: ";
	recout += "|cff00ccff";
	recout += qname;
	recout += "\n\n";
	SendMultilineMessage(m_session, recout.c_str());

	return true;
}
Exemple #28
0
bool ChatHandler::ExecuteCommandInTable(ChatCommand *table, const char* text, WorldSession *m_session)
{
	std::string cmd = "";

	// get command
	while (*text != ' ' && *text != '\0')
	{
		cmd += *text;
		text++;
	}

	while (*text == ' ') text++; // skip whitespace

	if(!cmd.length())
		return false;

	for(uint32 i = 0; table[i].Name != NULL; i++)
	{
		if(!hasStringAbbr(table[i].Name, cmd.c_str()))
			continue;

		if(!m_session->CanUseCommand(table[i].CommandGroup))
			continue;

		if(table[i].ChildCommands != NULL)
		{
			if(!ExecuteCommandInTable(table[i].ChildCommands, text, m_session))
			{
				if(table[i].Help != "")
					SendMultilineMessage(m_session, table[i].Help.c_str());
				else
				{
					GreenSystemMessage(m_session, "Available Subcommands:");
					for(uint32 k=0; table[i].ChildCommands[k].Name;k++)
					{
						if(m_session->CanUseCommand(table[i].ChildCommands[k].CommandGroup))
							BlueSystemMessage(m_session, "	%s - %s", table[i].ChildCommands[k].Name, table[i].ChildCommands[k].Help.size() ? table[i].ChildCommands[k].Help.c_str() : "No Help Available");
					}
				}
			}

			return true;
		}
		
		// Check for field-based commands
		if(table[i].Handler == NULL && (table[i].MaxValueField || table[i].NormalValueField))
		{
			bool result = false;
			if(strlen(text) == 0)
			{
				RedSystemMessage(m_session, "No values specified.");
			}
			if(table[i].ValueType == 2)
				result = CmdSetFloatField(m_session, table[i].NormalValueField, table[i].MaxValueField, table[i].Name, text);
			else
				result = CmdSetValueField(m_session, table[i].NormalValueField, table[i].MaxValueField, table[i].Name, text);
			if(!result)
				RedSystemMessage(m_session, "Must be in the form of (command) <value>, or, (command) <value> <maxvalue>");
		}
		else
		{
			if(!(this->*(table[i].Handler))(text, m_session))
			{
				if(table[i].Help != "")
					SendMultilineMessage(m_session, table[i].Help.c_str());
				else
				{
					RedSystemMessage(m_session, "Incorrect syntax specified. Try .help %s for the correct syntax.", table[i].Name);
				}
			}
		}

		return true;
	}

	return false;
}
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;
}
Exemple #30
0
bool ChatHandler::HandleQuestDelFinishCommand(const char * args, WorldSession * m_session)
{
	if(!*args)
		return false;

	uint64 guid = m_session->GetPlayer()->GetSelection();
	if (guid == 0)
	{
		SystemMessage(m_session, "You must target an npc.");
		return false;
	}

	Creature *unit = m_session->GetPlayer()->GetMapMgr()->GetCreature(GET_LOWGUID_PART(guid));
	if(!unit)
	{
		SystemMessage(m_session, "You must target an npc.");
		return false;
	}

	if (!unit->isQuestGiver())
	{
		SystemMessage(m_session, "Unit is not a valid quest giver.");
		return false;
	}

	uint32 quest_id = atol(args);
	Quest * qst = QuestStorage.LookupEntry(quest_id);

	if (qst == NULL)
	{
		SystemMessage(m_session, "Invalid Quest selected.");
		return false;
	}

	std::string quest_giver = MyConvertIntToString(unit->GetEntry());

	std::string my_query1 = "SELECT id FROM creature_quest_finisher WHERE id = " + quest_giver + " AND quest = " + string(args);
	QueryResult *selectResult1 = WorldDatabase.Query(my_query1.c_str());
	if (selectResult1)
		delete selectResult1;
	else
	{
		SystemMessage(m_session, "Quest was NOT found for the specified NPC.");
		return true;
	}

	std::string my_delete1 = "DELETE FROM creature_quest_finisher WHERE id = " + quest_giver + " AND quest = " + string(args);
	QueryResult *deleteResult1 = WorldDatabase.Query(my_delete1.c_str());
	if (deleteResult1)
		delete deleteResult1;

	std::string my_query2 = "SELECT id FROM gameobject_quest_finisher WHERE id = " + quest_giver + " AND quest = " + string(args);
	QueryResult *selectResult2 = WorldDatabase.Query(my_query2.c_str());
	if (selectResult2)
	{
		delete selectResult2;

		std::string my_delete2 = "DELETE FROM gameobject_quest_finisher WHERE id = " + quest_giver + " AND quest = " + string(args);
		QueryResult *deleteResult2 = WorldDatabase.Query(my_delete2.c_str());
		if (deleteResult2)
			delete deleteResult2;
	}

	sQuestMgr.LoadExtraQuestStuff();

	QuestRelation *qstrel = new QuestRelation;
	qstrel->qst = qst;
	qstrel->type = QUESTGIVER_QUEST_END;
	uint8 qstrelid = (uint8)unit->GetQuestRelation(quest_id);
	unit->FindQuest(quest_id, qstrelid);
	unit->DeleteQuest(qstrel);
	unit->_LoadQuests();

	const char * qname = qst->title;

	std::string recout = "|cff00ff00Deleted Quest from NPC: ";
	recout += "|cff00ccff";
	recout += qname;
	recout += "\n\n";
	SendMultilineMessage(m_session, recout.c_str());

	return true;
}