本文整理汇总了C++中Success函数的典型用法代码示例。如果您正苦于以下问题:C++ Success函数的具体用法?C++ Success怎么用?C++ Success使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Success函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: return
bool BaseGuildManager::GetEntireGuild(uint32 guild_id, std::vector<CharGuildInfo *> &members) {
members.clear();
if(m_db == nullptr)
return(false);
//load up the rank info for each guild.
std::string query = StringFormat(GuildMemberBaseQuery " WHERE g.guild_id=%d", guild_id);
auto results = m_db->QueryDatabase(query);
if (!results.Success()) {
_log(GUILDS__ERROR, "Error loading guild member list '%s': %s", query.c_str(), results.ErrorMessage().c_str());
return false;
}
for (auto row = results.begin(); row != results.end(); ++row) {
CharGuildInfo *ci = new CharGuildInfo;
ProcessGuildMember(row, *ci);
members.push_back(ci);
}
_log(GUILDS__DB, "Retreived entire guild member list for guild %d from the database", guild_id);
return true;
}
示例2: StringFormat
bool Group::LearnMembers() {
std::string query = StringFormat("SELECT name FROM group_id WHERE groupid = %lu", (unsigned long)GetID());
auto results = database.QueryDatabase(query);
if (!results.Success())
return false;
if (results.RowCount() == 0) {
Log.Out(Logs::General, Logs::Error, "Error getting group members for group %lu: %s", (unsigned long)GetID(), results.ErrorMessage().c_str());
return false;
}
int memberIndex = 0;
for(auto row = results.begin(); row != results.end(); ++row) {
if(!row[0])
continue;
members[memberIndex] = nullptr;
strn0cpy(membername[memberIndex], row[0], 64);
memberIndex++;
}
return true;
}
示例3: removeAndRecreateStateDir
Error ClientState::commit(ClientStateCommitType commitType,
const ::core::FilePath& stateDir,
const ::core::FilePath& projectStateDir)
{
// remove and re-create the stateDirs
Error error = removeAndRecreateStateDir(stateDir);
if (error)
return error;
error = removeAndRecreateStateDir(projectStateDir);
if (error)
return error;
// always commit persistent state
commitState(persistentState_, kPersistentExt, stateDir);
commitState(projectPersistentState_, kProjPersistentExt, projectStateDir);
// commit all state if requested
if (commitType == ClientStateCommitAll)
commitState(temporaryState_, kTemporaryExt, stateDir);
else
temporaryState_.clear();
return Success();
}
示例4: Success
// Given a path, searches for the document in the Documents collection that
// has the path given. The out parameter is set to that document's IDispatch
// pointer, or NULL if no document with the path could be found.
Error WordViewer::getDocumentByPath(QString& path, IDispatch** pidispDoc)
{
Error errorHR = Success();
HRESULT hr = S_OK;
IDispatch* idispDocs = NULL;
IDispatch* idispDoc = NULL;
VARIANT varDocIdx;
VARIANT varResult;
int docCount = 0;
*pidispDoc = NULL;
VERIFY_HRESULT(getIDispatchProp(idispWord_, L"Documents", &idispDocs));
VERIFY_HRESULT(getIntProp(idispDocs, L"Count", &docCount));
varDocIdx.vt = VT_INT;
for (int i = 1; i <= docCount; i++)
{
VariantInit(&varResult);
varDocIdx.intVal = i;
VERIFY_HRESULT(invokeDispatch(DISPATCH_METHOD, &varResult, idispDocs,
L"Item", 1, varDocIdx));
idispDoc = varResult.pdispVal;
VERIFY_HRESULT(invokeDispatch(DISPATCH_PROPERTYGET, &varResult, idispDoc,
L"FullName", 0));
if (path.toStdWString() == varResult.bstrVal)
{
*pidispDoc = idispDoc;
break;
}
}
LErrExit:
return errorHR;
}
示例5: entry
bool EQEmu::ProfanityManager::RemoveProfanity(DBcore *db, const char *profanity) {
if (!db || !profanity)
return false;
std::string entry(profanity);
std::transform(entry.begin(), entry.end(), entry.begin(), [](unsigned char c) -> unsigned char { return tolower(c); });
if (!check_for_existing_entry(entry.c_str()))
return true;
profanity_list.remove(entry);
std::string query = "DELETE FROM `profanity_list` WHERE `word` LIKE '";
query.append(entry);
query.append("'");
auto results = db->QueryDatabase(query);
if (!results.Success())
return false;
update_originator_flag = true;
return true;
}
示例6: switch
void RuleManager::_SaveRule(Database *db, RuleType type, uint16 index) {
char vstr[100];
switch(type) {
case IntRule:
sprintf(vstr, "%d", m_RuleIntValues[index]);
break;
case RealRule:
sprintf(vstr, "%.13f", m_RuleRealValues[index]);
break;
case BoolRule:
sprintf(vstr, "%s", m_RuleBoolValues[index]?"true":"false");
break;
}
std::string query = StringFormat("REPLACE INTO rule_values "
"(ruleset_id, rule_name, rule_value) "
" VALUES(%d, '%s', '%s')",
m_activeRuleset, _GetRuleName(type, index), vstr);
auto results = db->QueryDatabase(query);
if (!results.Success())
_log(RULES__ERROR, "Fauled to set rule in the database: %s: %s", query.c_str(), results.ErrorMessage().c_str());
}
示例7: strlen
// Add new Zone Object (theoretically only called for items dropped to ground)
uint32 ZoneDatabase::AddObject(uint32 type, uint32 icon, const Object_Struct& object, const ItemInst* inst)
{
uint32 database_id = 0;
uint32 item_id = 0;
int16 charges = 0;
if (inst && inst->GetItem()) {
item_id = inst->GetItem()->ID;
charges = inst->GetCharges();
}
// SQL Escape object_name
uint32 len = strlen(object.object_name) * 2 + 1;
char* object_name = new char[len];
DoEscapeString(object_name, object.object_name, strlen(object.object_name));
// Save new record for object
std::string query = StringFormat("INSERT INTO object "
"(zoneid, xpos, ypos, zpos, heading, "
"itemid, charges, objectname, type, icon) "
"values (%i, %f, %f, %f, %f, %i, %i, '%s', %i, %i)",
object.zone_id, object.x, object.y, object.z, object.heading,
item_id, charges, object_name, type, icon);
safe_delete_array(object_name);
auto results = QueryDatabase(query);
if (!results.Success()) {
LogFile->write(EQEMuLog::Error, "Unable to insert object: %s", results.ErrorMessage().c_str());
return 0;
}
// Save container contents, if container
if (inst && inst->IsType(ItemClassContainer))
SaveWorldContainer(object.zone_id, database_id, inst);
return database_id;
}
示例8: DoEscapeString
void Database::CreateLSAccount(std::string name, std::string password, std::string email, unsigned int created_by, std::string LastIPAddress, std::string creationIP)
{
bool activate = 0;
if (LoadServerSettings("options", "auto_account_activate") == "TRUE")
{
activate = 1;
}
std::string query;
char tmpUN[1024];
DoEscapeString(tmpUN, name.c_str(), (int)name.length());
query = StringFormat("INSERT INTO %s "
"SET AccountName = '%s', "
"AccountPassword = sha('%s'), "
"AccountCreateDate = now(), "
"LastLoginDate = now(), "
"LastIPAddress = '%s', "
"client_unlock = '%s', "
"created_by = '%s', "
"creationIP = '%s'",
LoadServerSettings("schema", "account_table").c_str(),
tmpUN,
password.c_str(),
LastIPAddress.c_str(),
std::to_string(activate).c_str(),
std::to_string(created_by).c_str(),
creationIP.c_str()
);
auto results = QueryDatabase(query);
if (!results.Success())
{
server_log->Log(log_database_error, "Mysql query failed: %s", query.c_str());
}
}
示例9: Log
int16 SpawnConditionManager::GetCondition(const char *zone_short, uint32 instance_id, uint16 condition_id) {
if(!strcasecmp(zone_short, zone->GetShortName()) && instance_id == zone->GetInstanceID())
{
//this is a local spawn condition
std::map<uint16, SpawnCondition>::iterator condi;
condi = spawn_conditions.find(condition_id);
if(condi == spawn_conditions.end())
{
Log(Logs::Detail, Logs::Spawns, "Unable to find local condition %d in Get request.", condition_id);
return(0); //unable to find the spawn condition
}
SpawnCondition &cond = condi->second;
return cond.value;
}
//this is a remote spawn condition, grab it from the DB
//load spawn conditions
std::string query = StringFormat("SELECT value FROM spawn_condition_values "
"WHERE zone = '%s' AND instance_id = %u AND id = %d",
zone_short, instance_id, condition_id);
auto results = database.QueryDatabase(query);
if (!results.Success()) {
Log(Logs::Detail, Logs::Spawns, "Unable to query remote condition %d from zone %s in Get request.", condition_id, zone_short);
return 0; //dunno a better thing to do...
}
if (results.RowCount() == 0) {
Log(Logs::Detail, Logs::Spawns, "Unable to load remote condition %d from zone %s in Get request.", condition_id, zone_short);
return 0; //dunno a better thing to do...
}
auto row = results.begin();
return atoi(row[0]);
}
示例10: systemError
Error ConnectionHistory::readConnections(json::Array* pConnections)
{
FilePath connectionListFile = connectionsDir_.childPath(kConnectionListFile);
if (connectionListFile.exists())
{
std::string contents;
Error error = core::readStringFromFile(connectionListFile, &contents);
if (error)
return error;
json::Value parsedJson;
if (!json::parse(contents, &parsedJson) ||
!json::isType<json::Array>(parsedJson))
{
return systemError(boost::system::errc::protocol_error,
"Error parsing connections json file",
ERROR_LOCATION);
}
*pConnections = parsedJson.get_value<json::Array>();
}
return Success();
}
示例11: StringFormat
bool Database::SetServerSettings(std::string type, std::string category, std::string defaults)
{
std::string query;
Config* newval = new Config;
std::string loadINIvalue = newval->LoadOption(category, type, "login.ini");
query = StringFormat(
"UPDATE tblloginserversettings "
"SET value = '%s' "
"WHERE type = '%s' "
"AND category = '%s' "
"LIMIT 1",
loadINIvalue.empty() ? defaults.c_str() : loadINIvalue.c_str(), type.c_str(), category.c_str());
safe_delete(newval);
auto results = QueryDatabase(query);
if (!results.Success())
{
server_log->Log(log_database_error, "SetServerSettings Mysql check_query failed: %s", query.c_str());
return false;
}
return true;
}
示例12: DoEscapeString
void Database::AddSpeech(const char* from, const char* to, const char* message, uint16 minstatus, uint32 guilddbid, uint8 type) {
char *escapedFrom = new char[strlen(from) * 2 + 1];
char *escapedTo = new char[strlen(to) * 2 + 1];
char *escapedMessage = new char[strlen(message) * 2 + 1];
DoEscapeString(escapedFrom, from, strlen(from));
DoEscapeString(escapedTo, to, strlen(to));
DoEscapeString(escapedMessage, message, strlen(message));
std::string query = StringFormat("INSERT INTO `qs_player_speech` "
"SET `from` = '%s', `to` = '%s', `message`='%s', "
"`minstatus`='%i', `guilddbid`='%i', `type`='%i'",
escapedFrom, escapedTo, escapedMessage, minstatus, guilddbid, type);
safe_delete_array(escapedFrom);
safe_delete_array(escapedTo);
safe_delete_array(escapedMessage);
auto results = QueryDatabase(query);
if(!results.Success()) {
Log.Out(Logs::Detail, Logs::QS_Server, "Failed Speech Entry Insert: %s", results.ErrorMessage().c_str());
Log.Out(Logs::Detail, Logs::QS_Server, "%s", query.c_str());
}
}
示例13: Success
void DelayProcess::VUpdate(unsigned int elapsedTime)
{
m_timeDelayed += elapsedTime;
if(m_timeDelayed >= m_timeToDelay)
Success();
}
示例14: StringFormat
bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 instance_id)
{
//clear out old stuff..
spawn_conditions.clear();
std::string query = StringFormat("SELECT id, onchange, value "
"FROM spawn_conditions "
"WHERE zone = '%s'", zone_name);
auto results = database.QueryDatabase(query);
if (!results.Success()) {
return false;
}
for (auto row = results.begin(); row != results.end(); ++row) {
//load spawn conditions
SpawnCondition cond;
cond.condition_id = atoi(row[0]);
cond.value = atoi(row[2]);
cond.on_change = (SpawnCondition::OnChange) atoi(row[1]);
spawn_conditions[cond.condition_id] = cond;
Log(Logs::Detail, Logs::Spawns, "Loaded spawn condition %d with value %d and on_change %d", cond.condition_id, cond.value, cond.on_change);
}
//load values
query = StringFormat("SELECT id, value FROM spawn_condition_values "
"WHERE zone = '%s' AND instance_id = %u",
zone_name, instance_id);
results = database.QueryDatabase(query);
if (!results.Success()) {
spawn_conditions.clear();
return false;
}
for (auto row = results.begin(); row != results.end(); ++row) {
auto iter = spawn_conditions.find(atoi(row[0]));
if(iter != spawn_conditions.end())
iter->second.value = atoi(row[1]);
}
//load spawn events
query = StringFormat("SELECT id, cond_id, period, next_minute, next_hour, "
"next_day, next_month, next_year, enabled, action, argument, strict "
"FROM spawn_events WHERE zone = '%s'", zone_name);
results = database.QueryDatabase(query);
if (!results.Success()) {
return false;
}
for (auto row = results.begin(); row != results.end(); ++row) {
SpawnEvent event;
event.id = atoi(row[0]);
event.condition_id = atoi(row[1]);
event.period = atoi(row[2]);
if(event.period == 0) {
Log(Logs::General, Logs::Error, "Refusing to load spawn event #%d because it has a period of 0\n", event.id);
continue;
}
event.next.minute = atoi(row[3]);
event.next.hour = atoi(row[4]);
event.next.day = atoi(row[5]);
event.next.month = atoi(row[6]);
event.next.year = atoi(row[7]);
event.enabled = atoi(row[8])==0?false:true;
event.action = (SpawnEvent::Action) atoi(row[9]);
event.argument = atoi(row[10]);
event.strict = atoi(row[11])==0?false:true;
spawn_events.push_back(event);
Log(Logs::Detail, Logs::Spawns, "(LoadSpawnConditions) Loaded %s spawn event %d on condition %d with period %d, action %d, argument %d, strict %d", event.enabled? "enabled": "disabled", event.id, event.condition_id, event.period, event.action, event.argument, event.strict);
}
//now we need to catch up on events that happened while we were away
//and use them to alter just the condition variables.
//each spawn2 will then use its correct condition value when
//it decides what to do. This essentially forces a 'depop' action
//on spawn points which are turned off, and a 'repop' action on
//spawn points which get turned on. Im too lazy to figure out a
//better solution, and I just dont care thats much.
//get our current time
TimeOfDay_Struct tod;
zone->zone_time.GetCurrentEQTimeOfDay(&tod);
for(auto cur = spawn_events.begin(); cur != spawn_events.end(); ++cur) {
SpawnEvent &cevent = *cur;
bool StrictCheck = false;
if(cevent.strict &&
cevent.next.hour == tod.hour &&
cevent.next.day == tod.day &&
cevent.next.month == tod.month &&
cevent.next.year == tod.year)
//.........这里部分代码省略.........
示例15: gettimeofday
bool ZoneDatabase::PopulateZoneSpawnList(uint32 zoneid, LinkedList<Spawn2*> &spawn2_list, int16 version, uint32 repopdelay) {
std::unordered_map<uint32, uint32> spawn_times;
timeval tv;
gettimeofday(&tv, nullptr);
/* Bulk Load NPC Types Data into the cache */
database.LoadNPCTypesData(0, true);
std::string spawn_query = StringFormat(
"SELECT "
"respawn_times.id, "
"respawn_times.`start`, "
"respawn_times.duration "
"FROM "
"respawn_times "
"WHERE instance_id = %u",
zone->GetInstanceID()
);
auto results = QueryDatabase(spawn_query);
for (auto row = results.begin(); row != results.end(); ++row) {
uint32 start_duration = atoi(row[1]) > 0 ? atoi(row[1]) : 0;
uint32 end_duration = atoi(row[2]) > 0 ? atoi(row[2]) : 0;
/* Our current time was expired */
if ((start_duration + end_duration) <= tv.tv_sec) {
spawn_times[atoi(row[0])] = 0;
}
/* We still have time left on this timer */
else {
spawn_times[atoi(row[0])] = ((start_duration + end_duration) - tv.tv_sec) * 1000;
}
}
const char *zone_name = database.GetZoneName(zoneid);
std::string query = StringFormat(
"SELECT "
"id, "
"spawngroupID, "
"x, "
"y, "
"z, "
"heading, "
"respawntime, "
"variance, "
"pathgrid, "
"_condition, "
"cond_value, "
"enabled, "
"animation "
"FROM "
"spawn2 "
"WHERE zone = '%s' AND (version = %u OR version = -1)",
zone_name,
version
);
results = QueryDatabase(query);
if (!results.Success()) {
return false;
}
for (auto row = results.begin(); row != results.end(); ++row) {
uint32 spawn_time_left = 0;
Spawn2* new_spawn = 0;
bool perl_enabled = atoi(row[11]) == 1 ? true : false;
if (spawn_times.count(atoi(row[0])) != 0)
spawn_time_left = spawn_times[atoi(row[0])];
new_spawn = new Spawn2( //
atoi(row[0]), // uint32 in_spawn2_id
atoi(row[1]), // uint32 spawngroup_id
atof(row[2]), // float in_x
atof(row[3]), // float in_y
atof(row[4]), // float in_z
atof(row[5]), // float in_heading
atoi(row[6]), // uint32 respawn
atoi(row[7]), // uint32 variance
spawn_time_left, // uint32 timeleft
atoi(row[8]), // uint32 grid
atoi(row[9]), // uint16 in_cond_id
atoi(row[10]), // int16 in_min_value
perl_enabled, // bool in_enabled
(EmuAppearance)atoi(row[12]) // EmuAppearance anim
);
spawn2_list.Insert(new_spawn);
}
NPC::SpawnZoneController();
return true;
}