本文整理汇总了C++中ConfigManager::getBool方法的典型用法代码示例。如果您正苦于以下问题:C++ ConfigManager::getBool方法的具体用法?C++ ConfigManager::getBool怎么用?C++ ConfigManager::getBool使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConfigManager
的用法示例。
在下文中一共展示了ConfigManager::getBool方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: allow
bool Manager::allow(uint32_t ip) const
{
if(!g_config.getBool(ConfigManager::MANAGER_LOCALHOST_ONLY))
return !ConnectionManager::getInstance()->isDisabled(ip, 0xFE);
if(ip == 0x0100007F) //127.0.0.1
return true;
if(g_config.getBool(ConfigManager::MANAGER_LOGS))
LOG_MESSAGE(LOGTYPE_EVENT, "forbidden connection try", "MANAGER " + convertIPAddress(ip));
return false;
}
示例2: onCreatureLeave
void Monster::onCreatureLeave(Creature* creature)
{
#ifdef __DEBUG__
std::clog << "onCreatureLeave - " << creature->getName() << std::endl;
#endif
if(isSummon() && master == creature)
{
if(!g_config.getBool(ConfigManager::TELEPORT_SUMMONS) && (!master->getPlayer()
|| !g_config.getBool(ConfigManager::TELEPORT_PLAYER_SUMMONS)))
{
//Turn the monster off until its master comes back
isMasterInRange = false;
updateIdleStatus();
}
else if(!doTeleportToMaster())
teleportToMaster = true;
}
//update friendList
if(isFriend(creature))
{
CreatureList::iterator it = std::find(friendList.begin(), friendList.end(), creature);
if(it != friendList.end())
{
(*it)->unRef();
friendList.erase(it);
}
#ifdef __DEBUG__
else
std::clog << "Monster: " << creature->getName() << " not found in the friendList." << std::endl;
#endif
}
//update targetList
if(isOpponent(creature))
{
CreatureList::iterator it = std::find(targetList.begin(), targetList.end(), creature);
if(it != targetList.end())
{
(*it)->unRef();
targetList.erase(it);
if(targetList.empty())
updateIdleStatus();
}
#ifdef __DEBUG__
else
std::clog << "Player: " << creature->getName() << " not found in the targetList." << std::endl;
#endif
}
}
示例3: open
void ServicePort::open(uint16_t port)
{
m_serverPort = port;
m_pendingStart = false;
try
{
if(g_config.getBool(ConfigManager::BIND_IP_ONLY))
m_acceptor = new boost::asio::ip::tcp::acceptor(m_io_service, boost::asio::ip::tcp::endpoint(
boost::asio::ip::address(boost::asio::ip::address_v4::from_string(
g_config.getString(ConfigManager::IP))), m_serverPort));
else
m_acceptor = new boost::asio::ip::tcp::acceptor(m_io_service, boost::asio::ip::tcp::endpoint(
boost::asio::ip::address(boost::asio::ip::address_v4(INADDR_ANY)), m_serverPort));
accept();
}
catch(boost::system::system_error& e)
{
if(m_logError)
{
LOG_MESSAGE(LOGTYPE_ERROR, e.what(), "NETWORK")
m_logError = false;
}
m_pendingStart = true;
Scheduler::getInstance().addEvent(createSchedulerTask(5000, boost::bind(
&ServicePort::onOpen, boost::weak_ptr<ServicePort>(shared_from_this()), m_serverPort)));
}
}
示例4: saveMap
bool IOMapSerialize::saveMap(Map* map)
{
if(g_config.getBool(ConfigManager::HOUSE_STORAGE))
return saveMapBinary(map);
return saveMapRelational(map);
}
示例5: updateDoorDescription
void House::updateDoorDescription()
{
std::stringstream houseDescription;
houseDescription << "It belongs to house '" << houseName << "'. " << std::endl;
if(houseOwner != 0){
houseDescription << houseOwnerName;
}
else{
houseDescription << "Nobody";
}
houseDescription << " owns this house." << std::endl;
if(getHouseOwner() == 0 && g_config.getBool(ConfigManager::SHOW_HOUSE_PRICE))
{
int price = 0;
for(HouseTileList::iterator it = getHouseTileBegin(); it != getHouseTileEnd(); it++)
{
price += g_config.getNumber(ConfigManager::HOUSE_PRICE);
}
houseDescription << " This house costs " << price << " gold." << std::endl;
}
HouseDoorList::iterator it;
for(it = doorList.begin(); it != doorList.end(); ++it){
(*it)->setSpecialDescription(houseDescription.str());
}
}
示例6: login
bool WaitingList::login(const Player* player)
{
uint32_t online = g_game.getPlayersOnline(), max = g_config.getNumber(ConfigManager::MAX_PLAYERS);
if(player->hasFlag(PlayerFlag_CanAlwaysLogin) || player->isAccountManager() || (waitList.empty()
&& online < max) || (g_config.getBool(ConfigManager::PREMIUM_SKIP_WAIT) && player->isPremium()))
return true;
cleanup();
uint32_t slot = 0;
WaitList::iterator it = find(player, slot);
if(it != waitList.end())
{
if((online + slot) > max)
{
//let them wait a bit longer
(*it)->timeout = OTSYS_TIME() + getTimeout(slot) * 1000;
return false;
}
//should be able to login now
delete *it;
waitList.erase(it);
return true;
}
Wait* wait = new Wait();
if(player->isPremium())
{
slot = 1;
WaitList::iterator it = waitList.end();
for(WaitList::iterator wit = waitList.begin(); wit != it; ++wit)
{
if(!(*wit)->premium)
{
it = wit;
break;
}
++slot;
}
waitList.insert(it, wait);
}
else
{
waitList.push_back(wait);
slot = waitList.size();
}
wait->name = player->getName();
wait->ip = player->getIP();
wait->premium = player->isPremium();
wait->timeout = OTSYS_TIME() + getTimeout(slot) * 1000;
return false;
}
示例7: dropCorpse
void Creature::dropCorpse(DeathList deathList)
{
if(master && !g_config.getBool(ConfigManager::SUMMONS_DROP_CORPSE))
{
g_game.addMagicEffect(getPosition(), MAGIC_EFFECT_POFF);
return;
}
Item* corpse = createCorpse(deathList);
if(corpse)
corpse->setParent(VirtualCylinder::virtualCylinder);
bool deny = false;
CreatureEventList deathEvents = getCreatureEvents(CREATURE_EVENT_DEATH);
for(CreatureEventList::iterator it = deathEvents.begin(); it != deathEvents.end(); ++it)
{
if(!(*it)->executeDeath(this, corpse, deathList) && !deny)
deny = true;
}
if(!corpse)
return;
corpse->setParent(NULL);
if(deny)
return;
Tile* tile = getTile();
if(!tile)
return;
Item* splash = NULL;
switch(getRace())
{
case RACE_VENOM:
splash = Item::CreateItem(ITEM_FULLSPLASH, FLUID_GREEN);
break;
case RACE_BLOOD:
splash = Item::CreateItem(ITEM_FULLSPLASH, FLUID_BLOOD);
break;
default:
break;
}
if(splash)
{
g_game.internalAddItem(NULL, tile, splash, INDEX_WHEREEVER, FLAG_NOLIMIT);
g_game.startDecay(splash);
}
g_game.internalAddItem(NULL, tile, corpse, INDEX_WHEREEVER, FLAG_NOLIMIT);
dropLoot(corpse->getContainer());
g_game.startDecay(corpse);
}
示例8: onAttackedCreatureDisappear
void Monster::onAttackedCreatureDisappear(bool)
{
#ifdef __DEBUG__
std::clog << "Attacked creature disappeared." << std::endl;
#endif
attackTicks = 0;
extraMeleeAttack = true;
if(g_config.getBool(ConfigManager::MONSTER_SPAWN_WALKBACK))
g_game.internalTeleport(this, getMasterPosition(), false);
}
示例9: addLogLine
void ProtocolManager::addLogLine(LogType_t type, std::string message)
{
if(!g_config.getBool(ConfigManager::MANAGER_LOGS))
return;
std::string tmp = "MANAGER";
if(getIP())
tmp += " " + convertIPAddress(getIP());
LOG_MESSAGE(type, message, tmp)
}
示例10: getPolicy
uint16_t Admin::getPolicy() const
{
uint16_t policy = 0;
if(g_config.getBool(ConfigManager::ADMIN_REQUIRE_LOGIN))
policy |= REQUIRE_LOGIN;
if(m_encrypted)
policy |= REQUIRE_ENCRYPTION;
return policy;
}
示例11: reloadPrices
bool Houses::reloadPrices()
{
if(g_config.getBool(ConfigManager::HOUSE_RENTASPRICE))
return true;
const uint32_t tilePrice = g_config.getNumber(ConfigManager::HOUSE_PRICE);
for(HouseMap::iterator it = houseMap.begin(); it != houseMap.end(); ++it)
it->second->setPrice(tilePrice * it->second->getTilesCount(), true);
return true;
}
示例12: 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();
}
示例13: payRent
bool Houses::payRent(Player* player, House* house, uint32_t bid, time_t _time/* = 0*/)
{
if(rentPeriod == RENTPERIOD_NEVER || !house->getOwner() ||
house->getPaidUntil() > _time || !house->getRent() ||
player->hasCustomFlag(PlayerCustomFlag_IgnoreHouseRent))
return true;
Town* town = Towns::getInstance()->getTown(house->getTownId());
if(!town)
return false;
bool paid = false;
uint32_t amount = house->getRent() + bid;
if(g_config.getBool(ConfigManager::BANK_SYSTEM) && player->balance >= amount)
{
player->balance -= amount;
paid = true;
}
else if(DepotChest* depotChest = player->getDepotChest(town->getID(), true))
paid = g_game.removeMoney(depotChest, amount, FLAG_NOLIMIT);
if(!paid)
return false;
if(!_time)
_time = time(NULL);
uint32_t paidUntil = _time;
switch(rentPeriod)
{
case RENTPERIOD_DAILY:
paidUntil += 86400;
break;
case RENTPERIOD_WEEKLY:
paidUntil += 7 * 86400;
break;
case RENTPERIOD_MONTHLY:
paidUntil += 30 * 86400;
break;
case RENTPERIOD_YEARLY:
paidUntil += 365 * 86400;
break;
default:
break;
}
house->setLastWarning(0);
house->setRentWarnings(0);
house->setPaidUntil(paidUntil);
return true;
}
示例14: isProtected
bool Combat::isProtected(Player* attacker, Player* target)
{
if(attacker->hasFlag(PlayerFlag_CannotAttackPlayer))
return true;
if(attacker->hasCustomFlag(PlayerCustomFlag_GamemasterPrivileges))
return false;
if(attacker->getZone() == ZONE_HARDCORE && target->getZone() == ZONE_HARDCORE && g_config.getBool(ConfigManager::PVP_TILE_IGNORE_PROTECTION))
return false;
return target->isProtected() || attacker->isProtected() || (attacker->checkLoginDelay() && !attacker->hasBeenAttacked(target->getID()));
}
示例15: doCombatDispel
void Combat::doCombatDispel(Creature* caster, Creature* target, const CombatParams& params, bool check/* = true*/)
{
if(check && params.isAggressive && (caster == target || Combat::canDoCombat(caster, target, true) != RET_NOERROR))
return;
CombatDispelFunc(caster, target, params, NULL);
if(params.targetCallback)
params.targetCallback->onTargetCombat(caster, target);
if(params.effects.impact != MAGIC_EFFECT_NONE && (!caster || !caster->isGhost()
|| g_config.getBool(ConfigManager::GHOST_SPELL_EFFECTS)))
g_game.addMagicEffect(target->getPosition(), params.effects.impact);
if(caster && params.effects.distance != SHOOT_EFFECT_NONE)
addDistanceEffect(caster, caster->getPosition(), target->getPosition(), params.effects.distance);
}