本文整理汇总了C++中sqf::Parameters::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ Parameters::push_back方法的具体用法?C++ Parameters::push_back怎么用?C++ Parameters::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sqf::Parameters
的用法示例。
在下文中一共展示了Parameters::push_back方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: populateQuery
void SqlCustDataSource::populateQuery(string query, Sqf::Parameters& params, CustomDataQueue& queue)
{
for (int i = 0; i < params.size(); i++)
{
query = boost::algorithm::replace_nth_copy(query, "?", i, Sqf::GetStringAny(params.at(i)));
}
auto custRes = getDB()->queryParams(query.c_str());
while (custRes->fetchRow())
{
Sqf::Parameters custParams;
for (int i = 0; i < custRes->numFields(); i++)
{
int val = custRes->at(i).getInt32();
if (val == 0 && custRes->at(i).getString() != "0")
{
custParams.push_back(custRes->at(i).getString());
}
else
{
custParams.push_back(val);
}
}
queue.push(custParams);
}
}
示例2: fetchObjectId
Sqf::Value SqlCharDataSource::fetchObjectId( Int64 objectIdent )
{
Sqf::Parameters retVal;
//get details from db
auto charDetRes = getDB()->queryParams(
"SELECT `ObjectID` FROM `Object_DATA` WHERE `ObjectUID`=%lld", objectIdent);
if (charDetRes && charDetRes->fetchRow())
{
int objectid = 0;
//get stuff from row
objectid = charDetRes->at(0).getInt32();
if(objectid != 0)
{
retVal.push_back(string("PASS"));
retVal.push_back(lexical_cast<string>(objectid));
}
else
{
retVal.push_back(string("ERROR"));
}
}
else
{
retVal.push_back(string("ERROR"));
}
return retVal;
}
示例3: populateHouses
void Database::populateHouses(std::queue<Sqf::Parameters>& queue)
{
try
{
Poco::Data::Statement stmt((*activeSession));
stmt << "select `player_id`, `unique_id`, `building_id`, `building_name`, `worldspace`, `lock`, `explosive`, `reinforcement` from `buildings` where `instance_id` = ?", use(serverID), now;
Poco::Data::RecordSet rs(stmt);
if (rs.columnCount() >= 1)
{
bool more = rs.moveFirst();
while (more)
{
Sqf::Parameters objParams;
objParams.push_back(string("HOUSE"));
string playerID = rs[0].convert<std::string>();
objParams.push_back(playerID);
string uniqueID = rs[1].convert<std::string>();
objParams.push_back(uniqueID);
string buildingID = rs[2].convert<std::string>();
objParams.push_back(buildingID);
string buildingName = rs[3].convert<std::string>();
objParams.push_back(buildingName);
try
{
string worldSpace = rs[4].convert<std::string>();
Sqf::Value worldSpaceArray = lexical_cast<Sqf::Value>(worldSpace);
objParams.push_back(worldSpaceArray);
}
catch (boost::bad_lexical_cast)
{
console->log("Invalid Worldspace for House: " + buildingID);
}
string lock = rs[5].convert<std::string>();
objParams.push_back(lock);
bool explosive = rs[6].convert<bool>();
objParams.push_back(explosive);
int reinforcement = rs[7].convert<int>();
objParams.push_back(reinforcement);
queue.push(objParams);
more = rs.moveNext();
};
};
}
catch (std::exception& ex)
{
std::cout << ex.what() << std::endl;
};
};
示例4: fetchAntiHackWhitelist
void SqlAntiHackDataSource::fetchAntiHackWhitelist( AntiHackQueue& queue )
{
auto antiHackRes = getDB()->queryParams(
"SELECT antihack_whitelist.playerID FROM antihack_whitelist");
if (!antiHackRes)
{
_logger.error("Failed to fetch whitelist from database");
return;
}
string banId;
while (antiHackRes->fetchRow())
{
Sqf::Parameters ahParams;
auto row = antiHackRes->fields();
//ahParams.push_back(string("BANS"));
try
{
banId = row[0].getString(); //objectId should be stringified
ahParams.push_back(banId);
_logger.information("Pushed whitelists (" + lexical_cast<string>(banId) + ")");
}
catch (const bad_lexical_cast&)
{
_logger.error("Skipping whitelist " + lexical_cast<string>(banId) + " load because of invalid data in db");
continue;
}
queue.push(ahParams);
}
}
示例5: fetchAntiHackAdmins
void SqlAntiHackDataSource::fetchAntiHackAdmins( int serverId, int adminlevel, AntiHackQueue& queue )
{
auto antiHackRes = getDB()->queryParams(
"SELECT antihack_admins.playerID FROM antihack_admins WHERE antihack_admins.instance = %d and antihack_admins.adminlevel = %d", serverId, adminlevel);
if (!antiHackRes)
{
_logger.error("Failed to fetch admins from database");
return;
}
string adminId;
while (antiHackRes->fetchRow())
{
Sqf::Parameters ahParams;
auto row = antiHackRes->fields();
try
{
adminId = row[0].getString(); //objectId should be stringified
ahParams.push_back(adminId);
_logger.information("Pushed Admin (" + lexical_cast<string>(adminId) + ")");
}
catch (const bad_lexical_cast&)
{
_logger.error("Skipping Admin " + lexical_cast<string>(adminId) + " load because of invalid data in db");
continue;
}
queue.push(ahParams);
}
}
示例6: populateTraps
void Database::populateTraps(std::queue<Sqf::Parameters>& queue)
{
try
{
Poco::Data::Statement stmt((*activeSession));
stmt << "select `unique_id`, `classname`, `worldspace` from `instance_traps` where `instance_id` = ?", use(serverID);
stmt.execute();
Poco::Data::RecordSet rs(stmt);
if (rs.columnCount() >= 1)
{
bool more = rs.moveFirst();
while (more)
{
Sqf::Parameters objParams;
objParams.push_back(string("TRAP"));
string uniqueID = rs[0].convert<std::string>();
objParams.push_back(uniqueID);
string classname = rs[1].convert<std::string>();
objParams.push_back(classname);
try
{
string worldSpace = rs[2].convert<std::string>();
Sqf::Value worldSpaceArray = lexical_cast<Sqf::Value>(worldSpace);
objParams.push_back(worldSpaceArray);
}
catch (boost::bad_lexical_cast)
{
console->log("Invalid Worldspace for Trap: " + uniqueID);
}
queue.push(objParams);
more = rs.moveNext();
};
};
}
catch (std::exception& ex)
{
std::cout << ex.what() << std::endl;
};
};
示例7: killCharacter
Sqf::Value Database::killCharacter(int characterID)
{
//Update Stats Profile
{
Poco::Data::Statement stmt((*activeSession));
stmt << "update `profile` p inner join `survivor` s on s.`unique_id` = p.`unique_id` set p.`survival_attempts` = p.`survival_attempts` + 1, p.`total_survivor_kills` = p.`total_survivor_kills` + s.`survivor_kills`, p.`total_zombie_kills` = p.`total_zombie_kills` + s.`zombie_kills`, p.`total_headshots` = p.`total_headshots` + s.`headshots`, p.`total_survival_time` = p.`total_survival_time` + s.`survival_time` where s.`id` = ? and s.`is_dead` = 0", use(characterID), now;
}
//Kill Character
Poco::Data::Statement stmt((*activeSession));
stmt << "update `survivor` set `is_dead` = 1 where `id` = ?", use(characterID), now;
//Return Success
Sqf::Parameters retVal;
retVal.push_back(string("PASS"));
retVal.push_back(lexical_cast<string>(characterID));
return retVal;
};
示例8: booleanReturn
Sqf::Parameters HiveExtApp::booleanReturn( bool isGood )
{
Sqf::Parameters retVal;
string retStatus = "PASS";
if (!isGood)
retStatus = "ERROR";
retVal.push_back(retStatus);
return retVal;
}
示例9: loadTraderDetails
Sqf::Value HiveExtApp::loadTraderDetails( Sqf::Parameters params )
{
if (_srvObjects.empty())
{
int characterId = Sqf::GetIntAny(params.at(0));
_objData->populateTraderObjects(characterId, _srvObjects);
Sqf::Parameters retVal;
retVal.push_back(string("ObjectStreamStart"));
retVal.push_back(static_cast<int>(_srvObjects.size()));
return retVal;
}
else
{
Sqf::Parameters retVal = _srvObjects.front();
_srvObjects.pop();
return retVal;
}
}
示例10: populateTraderObjects
void SqlObjDataSource::populateTraderObjects( int characterId, ServerObjectsQueue& queue )
{
auto worldObjsRes = getDB()->queryParams("SELECT `id`, `item`, `qty`, `buy`, `sell`, `order`, `tid`, `afile` FROM `Traders_DATA` WHERE `tid`=%d", characterId);
while (worldObjsRes->fetchRow())
{
auto row = worldObjsRes->fields();
Sqf::Parameters objParams;
objParams.push_back(row[0].getInt32());
// `item` varchar(255) NOT NULL COMMENT '[Class Name,1 = CfgMagazines | 2 = Vehicle | 3 = Weapon]',
// `qty` int(8) NOT NULL COMMENT 'amount in stock available to buy',
// `buy` varchar(255) NOT NULL COMMENT '[[Qty,Class,Type],]',
// `sell` varchar(255) NOT NULL COMMENT '[[Qty,Class,Type],]',
// `order` int(2) NOT NULL DEFAULT '0' COMMENT '# sort order for addAction menu',
// `tid` int(8) NOT NULL COMMENT 'Trader Menu ID',
// `afile` varchar(64) NOT NULL DEFAULT 'trade_items',
//get stuff from row
objParams.push_back(lexical_cast<Sqf::Value>(row[1].getString())); // item
objParams.push_back(row[2].getInt32()); // qty
objParams.push_back(lexical_cast<Sqf::Value>(row[3].getString())); // buy
objParams.push_back(lexical_cast<Sqf::Value>(row[4].getString())); // sell
objParams.push_back(row[5].getInt32()); // order
objParams.push_back(row[6].getInt32()); // tid
objParams.push_back(row[7].getString()); // afile
queue.push(objParams);
}
}
示例11: streamObjects
Sqf::Value HiveExtApp::streamObjects( Sqf::Parameters params )
{
if (_srvObjects.empty())
{
int serverId = boost::get<int>(params.at(0));
setServerId(serverId);
_objData->populateObjects(getServerId(), _srvObjects);
Sqf::Parameters retVal;
retVal.push_back(string("ObjectStreamStart"));
retVal.push_back(static_cast<int>(_srvObjects.size()));
return retVal;
}
else
{
Sqf::Parameters retVal = _srvObjects.front();
_srvObjects.pop();
return retVal;
}
}
示例12: streamCustom
Sqf::Value HiveExtApp::streamCustom( Sqf::Parameters params )
{
if (_custQueue.empty())
{
string query = Sqf::GetStringAny(params.at(0));
//if (!Sqf::IsNull(params.at(1)))
Sqf::Parameters rawParams = boost::get<Sqf::Parameters>(params.at(1));
_custData->populateQuery(query, rawParams, _custQueue);
Sqf::Parameters retVal;
retVal.push_back(string("CustomStreamStart"));
retVal.push_back(static_cast<int>(_custQueue.size()));
return retVal;
}
else
{
Sqf::Parameters retVal = _custQueue.front();
_custQueue.pop();
return retVal;
}
}
示例13: populateHackData
void Database::populateHackData(int requestID, std::queue<Sqf::Parameters>& queue)
{
Poco::Data::Statement stmt((*activeSession));
switch (requestID)
{
//Weapons
case 1:
{
stmt << "select `weapon` from `hack_weapons` where 1";
break;
}
//Magazines
case 2:
{
stmt << "select `magazine` from `hack_magazines` where 1";
break;
}
//Vars
case 3:
{
stmt << "select `var` from `hack_vars` where 1";
break;
}
//Scripts
case 4:
{
stmt << "select `script` from `hack_scripts` where 1";
break;
}
}
stmt.execute();
Poco::Data::RecordSet rs(stmt);
if (rs.columnCount() >= 1)
{
bool more = rs.moveFirst();
while (more)
{
Sqf::Parameters objParams;
string str = rs[0].convert<std::string>();
objParams.push_back(str);
queue.push(objParams);
more = rs.moveNext();
};
};
};
示例14: getDateTime
Sqf::Value HiveExtApp::getDateTime( Sqf::Parameters params )
{
namespace pt=boost::posix_time;
pt::ptime now = pt::second_clock::universal_time() + _timeOffset;
Sqf::Parameters retVal;
retVal.push_back(string("PASS"));
{
Sqf::Parameters dateTime;
dateTime.push_back(static_cast<int>(now.date().year()));
dateTime.push_back(static_cast<int>(now.date().month()));
dateTime.push_back(static_cast<int>(now.date().day()));
dateTime.push_back(static_cast<int>(now.time_of_day().hours()));
dateTime.push_back(static_cast<int>(now.time_of_day().minutes()));
retVal.push_back(dateTime);
}
return retVal;
}
示例15: fetchCharacterInitial
//.........这里部分代码省略.........
//update last login
{
//update last character login
auto stmt = getDB()->makeStatement(_stmtUpdateCharacterLastLogin, "UPDATE `Character_DATA` SET `LastLogin` = CURRENT_TIMESTAMP WHERE `CharacterID` = ?");
stmt->addInt32(characterId);
bool exRes = stmt->execute();
poco_assert(exRes == true);
}
}
else //inserting new character
{
newChar = true;
int generation = 1;
int humanity = 2500;
//try getting previous character info
{
auto prevCharRes = getDB()->queryParams(
("SELECT `Generation`, `Humanity`, `Model`, `Infected` FROM `Character_DATA` WHERE `" + _idFieldName + "` = '%s' AND `Slot` = %d AND `Alive` = 0 ORDER BY `CharacterID` DESC LIMIT 1").c_str(), getDB()->escape(playerId).c_str(), characterSlot);
if (prevCharRes && prevCharRes->fetchRow())
{
generation = prevCharRes->at(0).getInt32();
generation++; //apparently this was the correct behaviour all along
humanity = prevCharRes->at(1).getInt32();
try
{
model = boost::get<string>(lexical_cast<Sqf::Value>(prevCharRes->at(2).getString()));
}
catch (...)
{
model = prevCharRes->at(2).getString();
}
infected = prevCharRes->at(3).getInt32();
}
}
Sqf::Value medical = Sqf::Parameters(); //script will fill this in if empty
//insert new char into db
{
auto stmt = getDB()->makeStatement(_stmtInsertNewCharacter,
"INSERT INTO `Character_DATA` (`" + _idFieldName + "`, `Slot`, `InstanceID`, `" + _wsFieldName + "`, `Inventory`, `Backpack`, `Medical`, `Generation`, `Datestamp`, `LastLogin`, `LastAte`, `LastDrank`, `Humanity`) "
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, ?)");
stmt->addString(playerId);
stmt->addUInt8(characterSlot);
stmt->addInt32(serverId);
stmt->addString(lexical_cast<string>(worldSpace));
stmt->addString(lexical_cast<string>(inventory));
stmt->addString(lexical_cast<string>(backpack));
stmt->addString(lexical_cast<string>(medical));
stmt->addInt32(generation);
stmt->addInt32(humanity);
bool exRes = stmt->directExecute(); //need sync as we will be getting the CharacterID right after this
if (exRes == false)
{
_logger.error("Error creating character for playerId " + playerId);
Sqf::Parameters retVal;
retVal.push_back(string("ERROR"));
return retVal;
}
}
//get the new character's id
{
auto newCharRes = getDB()->queryParams(
("SELECT `CharacterID` FROM `Character_DATA` WHERE `" + _idFieldName + "` = '%s' AND `Alive` = 1 ORDER BY `CharacterID` DESC LIMIT 1").c_str(), getDB()->escape(playerId).c_str());
if (!newCharRes || !newCharRes->fetchRow())
{
_logger.error("Error fetching created character for playerId " + playerId);
Sqf::Parameters retVal;
retVal.push_back(string("ERROR"));
return retVal;
}
characterId = newCharRes->at(0).getInt32();
}
_logger.information("Created a new character " + lexical_cast<string>(characterId)+" for player '" + playerName + "' (" + playerId + ")");
}
Sqf::Parameters retVal;
retVal.push_back(string("PASS"));
retVal.push_back(newPlayer);
retVal.push_back(lexical_cast<string>(characterId));
if (!newChar)
{
retVal.push_back(worldSpace);
retVal.push_back(inventory);
retVal.push_back(backpack);
retVal.push_back(survival);
}
else {
retVal.push_back(infected);
}
retVal.push_back(model);
//hive interface version
retVal.push_back(0.96f);
return retVal;
}