当前位置: 首页>>代码示例>>C++>>正文


C++ DBResult::getDataLong方法代码示例

本文整理汇总了C++中DBResult::getDataLong方法的典型用法代码示例。如果您正苦于以下问题:C++ DBResult::getDataLong方法的具体用法?C++ DBResult::getDataLong怎么用?C++ DBResult::getDataLong使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DBResult的用法示例。


在下文中一共展示了DBResult::getDataLong方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: canLeaveWar

bool IOGuild::canLeaveWar(uint32_t guildId)
{
	if(!isInWar(guildId))
		return true;

	Database* db = Database::getInstance();

	DBQuery query;
	DBResult* result;
	bool returnVal = true;

	query << "SELECT `started` FROM `guild_wars` WHERE `guild1` = " << guildId << " AND `ended` = 0 AND `status` = 1;";
	if((result = db->storeQuery(query.str())))
	{
		do {
			if((result->getDataLong("started") + (86400 * 4)) >= time(NULL))
				returnVal = false;
		} while (result->next());
		db->freeResult(result);
	}

	query.str("");
	query << "SELECT `started` FROM `guild_wars` WHERE `guild2` = " << guildId << " AND `ended` = 0 AND `status` = 1;";
	if((result = db->storeQuery(query.str())))
	{
		do {
			if((result->getDataLong("started") + (86400 * 4)) >= time(NULL))
				returnVal = false;
		} while (result->next());
		db->freeResult(result);
	}
	return returnVal;
}
开发者ID:armadaazteca,项目名称:tfs0.2.15,代码行数:33,代码来源:ioguild.cpp

示例2:

std::vector<Ban> BanManager::getBans(const BanType_t& type)
{
	assert(type == BAN_IPADDRESS || type == BAN_PLAYER || type == BAN_ACCOUNT || type == BAN_NOTATION);
	Database* db = Database::instance();
	DBQuery query;
	query <<
	      "SELECT "
	      "`id`, "
	      "`value`, "
	      "`param`, "
	      "`expires`, "
	      "`added`, "
	      "`admin_id`, "
	      "`comment`, "
	      "`reason`, "
	      "`action`, "
	      "`statement` "
	      "FROM "
	      "`bans` "
	      "WHERE "
	      "`type` = " << type << " AND "
	      "`active` = 1 AND " <<
	      "(`expires` >= " << std::time(NULL) << " OR `expires` = 0)";
	std::vector<Ban> vec;
	DBResult* result;

	if (!(result = db->storeQuery(query.str())))
	{
		return vec;
	}

	do
	{
		Ban ban;
		ban.type = type;
		ban.id = result->getDataInt("id");
		ban.value = result->getDataString("value");
		ban.param = result->getDataString("param");
		ban.expires = result->getDataLong("expires");
		ban.added = (uint32_t)result->getDataLong("id");
		ban.adminId = result->getDataInt("admin_id");
		ban.reason = result->getDataInt("reason");
		ban.action = (violationAction_t)result->getDataInt("action");
		ban.comment = result->getDataString("comment");
		ban.statement = result->getDataString("statement");
		vec.push_back(ban);
	}
	while (result->next());

	db->freeResult(result);
	return vec;
}
开发者ID:edubart,项目名称:otserv,代码行数:52,代码来源:ban.cpp

示例3: getPlayerGroup

const PlayerGroup* IOPlayer::getPlayerGroup(uint32_t groupid)
{
	PlayerGroupMap::const_iterator it = playerGroupMap.find(groupid);

	if(it != playerGroupMap.end()){
		return it->second;
	}
	else{
		Database* db = Database::instance();
		DBQuery query;
		DBResult* result;

		query << "SELECT * FROM `groups` WHERE `id`= " << groupid;

		if((result = db->storeQuery(query.str()))){
			PlayerGroup* group = new PlayerGroup;

			group->m_name = result->getDataString("name");
			group->m_flags = result->getDataLong("flags");
			group->m_access = result->getDataInt("access");
			group->m_maxDepotItems = result->getDataInt("maxdepotitems");
			group->m_maxVip = result->getDataInt("maxviplist");

			playerGroupMap[groupid] = group;

			db->freeResult(result);
			return group;
		}
	}
	return NULL;
}
开发者ID:gianflogao,项目名称:divinity-ots,代码行数:31,代码来源:ioplayer.cpp

示例4: getPlayerGroup

const PlayerGroup* IOLoginData::getPlayerGroup(uint32_t groupid)
{
	PlayerGroupMap::const_iterator it = playerGroupMap.find(groupid);
	if (it != playerGroupMap.end()) {
		return it->second;
	}

	Database* db = Database::getInstance();

	std::ostringstream query;
	query << "SELECT `name`, `flags`, `access`, `maxdepotitems`, `maxviplist` FROM `groups` WHERE `id` = " << groupid;

	DBResult* result = db->storeQuery(query.str());
	if (!result) {
		return NULL;
	}

	PlayerGroup* group = new PlayerGroup;
	group->m_name = result->getDataString("name");
	group->m_flags = result->getDataLong("flags");
	group->m_access = result->getDataInt("access");
	group->m_maxdepotitems = result->getDataInt("maxdepotitems");
	group->m_maxviplist = result->getDataInt("maxviplist");
	db->freeResult(result);

	playerGroupMap[groupid] = group;
	return group;
}
开发者ID:24312108k,项目名称:forgottenserver,代码行数:28,代码来源:iologindata.cpp

示例5: updateStatistics

void IOMarket::updateStatistics()
{
	Database* db = Database::getInstance();
	DBQuery query;
	query << "SELECT `sale`, `itemtype`, COUNT(`price`) AS `num`, MIN(`price`) AS `min`, MAX(`price`) AS `max`, SUM(`price`) AS `sum` FROM `market_history` WHERE `state` = "
		<< OFFERSTATE_ACCEPTED << " AND `world_id` = " << g_config.getNumber(ConfigManager::WORLD_ID) << " GROUP BY `itemtype`, `sale`;";

	DBResult* result;
	if(!(result = db->storeQuery(query.str())))
		return;

	do
	{
		MarketStatistics* statistics;
		if(result->getDataInt("sale") == MARKETACTION_BUY)
			statistics = &purchaseStatistics[result->getDataInt("itemtype")];
		else
			statistics = &saleStatistics[result->getDataInt("itemtype")];

		statistics->numTransactions = result->getDataInt("num");
		statistics->lowestPrice = result->getDataInt("min");
		statistics->totalPrice = result->getDataLong("sum");
		statistics->highestPrice = result->getDataInt("max");
	}
	while(result->next());
	result->free();
}
开发者ID:081421,项目名称:otxserver,代码行数:27,代码来源:iomarket.cpp

示例6: storeQuery

DatabaseMySQL::DatabaseMySQL() :
	m_timeoutTask(0)
{
	m_connected = false;
	if(!mysql_init(&m_handle))
	{
		std::clog << std::endl << "Failed to initialize MySQL connection handler." << std::endl;
		return;
	}

	uint32_t timeout = g_config.getNumber(ConfigManager::MYSQL_READ_TIMEOUT);
	if(timeout)
		mysql_options(&m_handle, MYSQL_OPT_READ_TIMEOUT, (const char*)&timeout);

	timeout = g_config.getNumber(ConfigManager::MYSQL_WRITE_TIMEOUT);
	if(timeout)
		mysql_options(&m_handle, MYSQL_OPT_WRITE_TIMEOUT, (const char*)&timeout);

	my_bool reconnect = true;
	mysql_options(&m_handle, MYSQL_OPT_RECONNECT, &reconnect);
	if(!mysql_real_connect(&m_handle, g_config.getString(ConfigManager::SQL_HOST).c_str(), g_config.getString(
		ConfigManager::SQL_USER).c_str(), g_config.getString(ConfigManager::SQL_PASS).c_str(), g_config.getString(
		ConfigManager::SQL_DB).c_str(), g_config.getNumber(ConfigManager::SQL_PORT), NULL, 0))
	{
		std::clog << "Failed connecting to database - MYSQL ERROR: " << mysql_error(&m_handle) << " (" << mysql_errno(&m_handle) << ")" << std::endl;
		return;
	}

	m_connected = true;
	if(mysql_get_client_version() <= 50019)
		//MySQL servers <= 5.0.19 have a bug where MYSQL_OPT_RECONNECT option is reset by mysql_real_connect calls.
		//Read this http://dev.mysql.com/doc/refman/5.0/en/mysql-options.html for more information.
		std::clog << std::endl << "> WARNING: Outdated MySQL server detected, consider upgrading to a newer version." << std::endl;

	timeout = g_config.getNumber(ConfigManager::SQL_KEEPALIVE) * 1000;
	if(timeout)
		m_timeoutTask = Scheduler::getInstance().addEvent(createSchedulerTask(timeout,
			boost::bind(&DatabaseMySQL::keepAlive, this)));

	if(!g_config.getBool(ConfigManager::HOUSE_STORAGE))
		return;

	//we cannot lock mutex here :)
	DBResult* result = storeQuery("SHOW variables LIKE 'max_allowed_packet';");
	if(!result)
		return;

	if(result->getDataLong("Value") < 16776192)
		std::clog << std::endl << "> WARNING: max_allowed_packet might be set too low for binary map storage." << std::endl
			<< "Use the following query to raise max_allow_packet: SET GLOBAL max_allowed_packet = 16776192;" << std::endl;

	result->free();
}
开发者ID:Berze,项目名称:sour,代码行数:53,代码来源:databasemysql.cpp

示例7: internalHasFlag

bool IOPlayer::internalHasFlag(uint32_t groupId, PlayerFlags value)
{
	PlayerGroupMap::const_iterator it = playerGroupMap.find(groupId);
	if(it != playerGroupMap.end())
		return (0 != (it->second->m_flags & ((uint64_t)1 << value)));

	Database* db = Database::instance();
	DBResult* result;

	DBQuery query;
	query << "SELECT `flags` FROM `groups` WHERE `id` = " << groupId;
	if(!(result = db->storeQuery(query.str())))
		return false;

	uint64_t flags = result->getDataLong("flags");
	db->freeResult(result);
	return (0 != (flags & ((uint64_t)1 << value)));
}
开发者ID:gianflogao,项目名称:divinity-ots,代码行数:18,代码来源:ioplayer.cpp

示例8: getLastLoginSaved

time_t IOLoginData::getLastLoginSaved(uint32_t guid)
{
	Database* db = Database::getInstance();

	std::ostringstream query;
	query << "SELECT `lastlogin` FROM `players` WHERE `id` = " << guid;
	DBResult* result;
	time_t lastLoginSaved;

	if ((result = db->storeQuery(query.str()))) {
		lastLoginSaved = result->getDataLong("lastlogin");
		db->freeResult(result);
	} else {
		lastLoginSaved = 0;
	}

	return lastLoginSaved;
}
开发者ID:24312108k,项目名称:forgottenserver,代码行数:18,代码来源:iologindata.cpp

示例9: loadPlayer

bool IOPlayer::loadPlayer(Player* player, const std::string& name, bool preload /*= false*/)
{
	Database* db = Database::instance();
	DBQuery query;
	DBResult* result;

	query << "SELECT `players`.`id` AS `id`, `players`.`name` AS `name`, `account_id`, \
			 `players`.`group_id` as `group_id`, `sex`, `vocation`, `experience`, `level`, `maglevel`, `health`, \
			 `healthmax`, `mana`, `manamax`, `manaspent`, `soul`, `direction`, `lookbody`, \
			 `lookfeet`, `lookhead`, `looklegs`, `looktype`, `posx`, `posy`, \
			 `posz`, `cap`, `lastlogin`, `lastip`, `save`, `conditions`, `redskulltime`, \
			 `redskull`, `guildnick`, `loss_experience`, `loss_mana`, `loss_skills`, \
			 `loss_items`, `rank_id`, `town_id`, `balance`, `premend` \
			 FROM `players` LEFT JOIN `accounts` ON `account_id` = `accounts`.`id` \
			 WHERE `players`.`name` = " + db->escapeString(name);

	if(!(result = db->storeQuery(query.str()))){
	  	return false;
	}
	query.str("");

	player->setGUID(result->getDataInt("id"));
	player->accountNumber = result->getDataInt("account_id");

	const PlayerGroup* group = getPlayerGroup(result->getDataInt("group_id"));
	if(group){
		player->accessLevel = group->m_access;
		player->maxDepotLimit = group->m_maxDepotItems;
		player->maxVipLimit = group->m_maxVip;
		player->setFlags(group->m_flags);
	}

	if(preload){
		//only loading basic info
		db->freeResult(result);
		return true;
	}

	// Getting all player properties
	player->setSex((playersex_t)result->getDataInt("sex"));
	player->setDirection((Direction)result->getDataInt("direction"));
	player->level = std::max((uint32_t)1, (uint32_t)result->getDataInt("level"));

	uint64_t currExpCount = Player::getExpForLevel(player->level);
	uint64_t nextExpCount = Player::getExpForLevel(player->level + 1);
	uint64_t experience = (uint64_t)result->getDataLong("experience");
	if(experience < currExpCount || experience  > nextExpCount){
		experience = currExpCount;
	}
	player->experience = experience;
	player->levelPercent = Player::getPercentLevel(player->experience - currExpCount, nextExpCount - currExpCount);
	player->soul = result->getDataInt("soul");
	player->capacity = result->getDataInt("cap");
	player->lastLoginSaved = result->getDataInt("lastlogin");

	player->health = result->getDataInt("health");
	player->healthMax = result->getDataInt("healthmax");
	player->defaultOutfit.lookType = result->getDataInt("looktype");
	player->defaultOutfit.lookHead = result->getDataInt("lookhead");
	player->defaultOutfit.lookBody = result->getDataInt("lookbody");
	player->defaultOutfit.lookLegs = result->getDataInt("looklegs");
	player->defaultOutfit.lookFeet = result->getDataInt("lookfeet");
	player->currentOutfit = player->defaultOutfit;

#ifdef __SKULLSYSTEM__
	int32_t redSkullSeconds = result->getDataInt("redskulltime") - std::time(NULL);
	if(redSkullSeconds > 0){
		//ensure that we round up the number of ticks
		player->redSkullTicks = (redSkullSeconds + 2)*1000;

		if(result->getDataInt("redskull") == 1){
			player->skull = SKULL_RED;
		}
	}
#endif

	unsigned long conditionsSize = 0;
	const char* conditions = result->getDataStream("conditions", conditionsSize);
	PropStream propStream;
	propStream.init(conditions, conditionsSize);

	Condition* condition;
	while((condition = Condition::createCondition(propStream))){
		if(condition->unserialize(propStream)){
			player->storedConditionList.push_back(condition);
		}
		else{
			delete condition;
		}
	}
	// you need to set the vocation after conditions in order to ensure the proper regeneration rates for the vocation
	player->setVocation(result->getDataInt("vocation"));
	// this stuff has to go after the vocation is set
	player->mana = result->getDataInt("mana");
	player->manaMax = result->getDataInt("manamax");
	player->magLevel = result->getDataInt("maglevel");

	uint32_t nextManaCount = (uint32_t)player->vocation->getReqMana(player->magLevel + 1);
	uint32_t manaSpent = (uint32_t)result->getDataInt("manaspent");
	if(manaSpent > nextManaCount){
//.........这里部分代码省略.........
开发者ID:gianflogao,项目名称:divinity-ots,代码行数:101,代码来源:ioplayer.cpp

示例10: loadPlayer

bool IOPlayer::loadPlayer(Player* player, const std::string& name, bool preload /*= false*/)
{
	Database* db = Database::instance();
	DBQuery query;
	DBResult* result;

	query << "SELECT `players`.`id` AS `id`, `players`.`name` AS `name`, \
		`account_id`, `sex`, `vocation`, `experience`, `level`, `maglevel`, `health`, \
		`groups`.`name` AS `groupname`, `groups`.`flags` AS `groupflags`, `groups`.`access` AS `access`, \
		`groups`.`maxviplist` AS `maxviplist`, `groups`.`maxdepotitems` AS `maxdepotitems`, `groups`.`violation` AS `violation`, \
		`healthmax`, `mana`, `manamax`, `manaspent`, `soul`, `direction`, `lookbody`, \
		`lookfeet`, `lookhead`, `looklegs`, `looktype`, `posx`, `posy`, \
		`posz`, `cap`, `lastlogin`, `lastlogout`, `lastip`, `conditions`, `skull_time`, \
		`skull_type`, `loss_experience`, `loss_mana`, `loss_skills`, ";

#ifdef __OLD_GUILD_SYSTEM__
	query << "`rank_id`, `guildnick`, ";
#endif

	query << "`loss_items`, `loss_containers`, `town_id`, `balance` \
		FROM `players` \
		LEFT JOIN `accounts` ON `account_id` = `accounts`.`id`\
		LEFT JOIN `groups` ON `groups`.`id` = `players`.`group_id` \
		WHERE `players`.`name` = " + db->escapeString(name);

	if(!(result = db->storeQuery(query.str()))){
		return false;
	}
	query.str("");

	player->setGUID(result->getDataInt("id"));
	player->accountId = result->getDataInt("account_id");

	player->groupName = result->getDataString("groupname");
	player->accessLevel = result->getDataInt("access");
	int32_t violationLevel = result->getDataInt("violation");
	if(violationLevel > maxViolationLevel){
		violationLevel = maxViolationLevel;
		std::cout << "Warning: When loading player, maximum violation level is" << maxViolationLevel << std::endl;
	}
	player->violationLevel = violationLevel;

	player->maxDepotLimit = result->getDataInt("maxdepotitems");
	int32_t vipLimit = result->getDataInt("maxviplist");
	if(vipLimit > 100){
		vipLimit = 100;
		std::cout << "Warning: When loading player, maximum size of VIP list is 100." << std::endl;
	}
	player->maxVipLimit = vipLimit;
	player->setFlags(result->getDataLong("groupflags"));

	if(preload){
		//only loading basic info
		db->freeResult(result);
		return true;
	}

	// Getting all player properties
	player->setSex((PlayerSex_t)result->getDataInt("sex"));
	player->setDirection((Direction)result->getDataInt("direction"));
	player->level = std::max((uint32_t)1, (uint32_t)result->getDataInt("level"));

	uint64_t currExpCount = Player::getExpForLevel(player->level);
	uint64_t nextExpCount = Player::getExpForLevel(player->level + 1);
	uint64_t experience = (uint64_t)result->getDataLong("experience");
	if(experience < currExpCount || experience  > nextExpCount){
		experience = currExpCount;
	}
	player->experience = experience;
	player->levelPercent = Player::getPercentLevel(player->experience - currExpCount, nextExpCount - currExpCount);
	player->soul = result->getDataInt("soul");
	player->capacity = result->getDataInt("cap");
	player->lastLoginSaved = result->getDataInt("lastlogin");
	player->lastLogout = result->getDataInt("lastlogout");

	player->health = result->getDataInt("health");
	player->healthMax = result->getDataInt("healthmax");

	loadOutfit(player, result);

#ifdef __SKULLSYSTEM__
	int32_t skullType = result->getDataInt("skull_type");
	int64_t lastSkullTime = result->getDataLong("skull_time");

	if((skullType == SKULL_RED && std::time(NULL) < lastSkullTime + g_config.getNumber(ConfigManager::RED_SKULL_DURATION))){
		player->lastSkullTime = lastSkullTime;
		player->skullType = (Skulls_t)skullType;
	}
#endif

	loadConditions(player, result);

	// you need to set the vocation after conditions in order to ensure the proper regeneration rates for the vocation
	if(!player->setVocation(result->getDataInt("vocation"))){
		return false;
	}
	// this stuff has to go after the vocation is set
	player->mana = result->getDataInt("mana");
	player->manaMax = result->getDataInt("manamax");
	player->magLevel = result->getDataInt("maglevel");
//.........这里部分代码省略.........
开发者ID:angeliker,项目名称:OTHire,代码行数:101,代码来源:ioplayer.cpp

示例11: loadPlayer

bool IOLoginData::loadPlayer(Player* player, const std::string& name, bool preload /*= false*/)
{
	Database* db = Database::getInstance();

	std::ostringstream query;
	query << "SELECT `id`, `account_id`, `group_id`, `sex`, `vocation`, `experience`, `level`, `maglevel`, `health`, `healthmax`, `blessings`, `mana`, `manamax`, `manaspent`, `soul`, `lookbody`, `lookfeet`, `lookhead`, `looklegs`, `looktype`, `lookaddons`, `posx`, `posy`, `posz`, `cap`, `lastlogin`, `lastlogout`, `lastip`, `conditions`, `skulltime`, `skull`, `town_id`, `balance`, `offlinetraining_time`, `offlinetraining_skill`, `stamina` FROM `players` WHERE `name` = " << db->escapeString(name);

	DBResult* result = db->storeQuery(query.str());

	if (!result) {
		return false;
	}

	uint32_t accno = result->getDataInt("account_id");
	Account acc = loadAccount(accno);

	player->setGUID(result->getDataInt("id"));
	player->accountNumber = accno;

	player->accountType = acc.accountType;

	if (g_config.getBoolean(ConfigManager::FREE_PREMIUM)) {
		player->premiumDays = 0xFFFF;
	} else {
		player->premiumDays = acc.premiumDays;
	}

	player->setGroupId(result->getDataInt("group_id"));

	if (preload) {
		//only loading basic info
		db->freeResult(result);
		return true;
	}

	player->bankBalance = (uint64_t)result->getDataLong("balance");

	player->setSex((PlayerSex_t)result->getDataInt("sex"));
	player->level = std::max<uint32_t>(1, result->getDataInt("level"));

	uint64_t currExpCount = Player::getExpForLevel(player->level);
	uint64_t nextExpCount = Player::getExpForLevel(player->level + 1);
	uint64_t experience = (uint64_t)result->getDataLong("experience");

	if (experience < currExpCount || experience > nextExpCount) {
		experience = currExpCount;
	}

	player->experience = experience;

	if (currExpCount < nextExpCount) {
		player->levelPercent = Player::getPercentLevel(player->experience - currExpCount, nextExpCount - currExpCount);
	} else {
		player->levelPercent = 0;
	}

	player->soul = result->getDataInt("soul");
	player->capacity = result->getDataInt("cap");
	player->blessings = result->getDataInt("blessings");

	unsigned long conditionsSize = 0;
	const char* conditions = result->getDataStream("conditions", conditionsSize);
	PropStream propStream;
	propStream.init(conditions, conditionsSize);

	Condition* condition = Condition::createCondition(propStream);
	while (condition) {
		if (condition->unserialize(propStream)) {
			player->storedConditionList.push_back(condition);
		} else {
			delete condition;
		}
		condition = Condition::createCondition(propStream);
	}

	player->setVocation(result->getDataInt("vocation"));
	player->mana = result->getDataInt("mana");
	player->manaMax = result->getDataInt("manamax");
	player->magLevel = result->getDataInt("maglevel");

	uint64_t nextManaCount = player->vocation->getReqMana(player->magLevel + 1);
	uint64_t manaSpent = result->getDataLong("manaspent");

	if (manaSpent > nextManaCount) {
		manaSpent = 0;
	}

	player->manaSpent = manaSpent;
	player->magLevelPercent = Player::getPercentLevel(player->manaSpent,
	                          nextManaCount);

	player->health = result->getDataInt("health");
	player->healthMax = result->getDataInt("healthmax");

	player->defaultOutfit.lookType = result->getDataInt("looktype");
	player->defaultOutfit.lookHead = result->getDataInt("lookhead");
	player->defaultOutfit.lookBody = result->getDataInt("lookbody");
	player->defaultOutfit.lookLegs = result->getDataInt("looklegs");
	player->defaultOutfit.lookFeet = result->getDataInt("lookfeet");
	player->defaultOutfit.lookAddons = result->getDataInt("lookaddons");
//.........这里部分代码省略.........
开发者ID:24312108k,项目名称:forgottenserver,代码行数:101,代码来源:iologindata.cpp


注:本文中的DBResult::getDataLong方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。