Пример #1
0
GuildWarList IOGuild::getWarList(uint32_t guildId)
{
	GuildWarList guildWarList;

	Database* db = Database::getInstance();

	DBQuery query;
	DBResult* result;
	query << "SELECT `guild1` FROM `guild_wars` WHERE `guild2` = " << guildId << " AND `ended` = 0 AND `status` = 1;";
	if((result = db->storeQuery(query.str())))
	{
		do {
			guildWarList.push_back(result->getDataInt("guild1"));
		} while (result->next());
		db->freeResult(result);
	}

	query.str("");
	query << "SELECT `guild2` FROM `guild_wars` WHERE `guild1` = " << guildId << " AND `ended` = 0 AND `status` = 1;";
	if((result = db->storeQuery(query.str())))
	{
		do {
			guildWarList.push_back(result->getDataInt("guild2"));
		} while (result->next());
		db->freeResult(result);
	}
	return guildWarList;
}
Пример #2
0
bool IOGuild::isInWar(uint32_t g1, uint32_t g2)
{
	GuildWarList gwList = getWarList(g1);

	for(GuildWarList::const_iterator it = gwList.begin(); it != gwList.end(); ++it)
	{
		if((*it) == g2)
			return true;
	}
	return false;
}
Пример #3
0
void IOGuild::getWarList(uint32_t guildId, GuildWarList& guildWarList)
{
	std::ostringstream query;
	query << "SELECT `guild1`, `guild2` FROM `guild_wars` WHERE (`guild1` = " << guildId << " OR `guild2` = " << guildId << ") AND `ended` = 0 AND `status` = 1";

	DBResult_ptr result = Database::getInstance()->storeQuery(query.str());
	if (!result) {
		return;
	}

	do {
		uint32_t guild1 = result->getDataInt("guild1");
		if (guildId != guild1) {
			guildWarList.push_back(guild1);
		} else {
			guildWarList.push_back(result->getDataInt("guild2"));
		}
	} while (result->next());
}