本文整理汇总了C++中sqf::Parameters类的典型用法代码示例。如果您正苦于以下问题:C++ Parameters类的具体用法?C++ Parameters怎么用?C++ Parameters使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Parameters类的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: loadPlayer
Sqf::Value HiveExtApp::loadPlayer( Sqf::Parameters params )
{
string playerId = Sqf::GetStringAny(params.at(0));
string playerName = Sqf::GetStringAny(params.at(2));
return _charData->fetchCharacterInitial(playerId,getServerId(),playerName);
}
示例3: 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;
}
示例4: playerDeath
Sqf::Value HiveExtApp::playerDeath( Sqf::Parameters params )
{
int characterId = Sqf::GetIntAny(params.at(0));
int duration = static_cast<int>(Sqf::GetDouble(params.at(1)));
return booleanReturn(_charData->killCharacter(characterId,duration));
}
示例5: 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);
}
}
示例6: 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);
}
}
示例7: 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;
};
};
示例8: recordCharacterLogin
Sqf::Value HiveExtApp::recordCharacterLogin( Sqf::Parameters params )
{
string playerId = Sqf::GetStringAny(params.at(0));
int characterId = Sqf::GetIntAny(params.at(1));
int action = Sqf::GetIntAny(params.at(2));
//TODO: Get survivor ID
return booleanReturn(_charData->recordLogEntry(playerId,0,getServerId(),action));
}
示例9: playerInit
Sqf::Value HiveExtApp::playerInit( Sqf::Parameters params )
{
int characterId = Sqf::GetIntAny(params.at(0));
Sqf::Value inventory = boost::get<Sqf::Parameters>(params.at(1));
Sqf::Value backpack = boost::get<Sqf::Parameters>(params.at(2));
return booleanReturn(_charData->initCharacter(characterId,inventory,backpack));
}
示例10: recordCharacterLogin
Sqf::Value HiveExtApp::recordCharacterLogin( Sqf::Parameters params )
{
string playerId = Sqf::GetStringAny(params.at(0));
int characterId = Sqf::GetIntAny(params.at(1));
int action = Sqf::GetIntAny(params.at(2));
return booleanReturn(_charData->recordLogin(playerId,characterId,action));
}
示例11: booleanReturn
Sqf::Parameters HiveExtApp::booleanReturn( bool isGood )
{
Sqf::Parameters retVal;
string retStatus = "PASS";
if (!isGood)
retStatus = "ERROR";
retVal.push_back(retStatus);
return retVal;
}
示例12: objectInventory
Sqf::Value HiveExtApp::objectInventory( Sqf::Parameters params, bool byUID /*= false*/ )
{
Int64 objectIdent = Sqf::GetBigInt(params.at(0));
Sqf::Value inventory = boost::get<Sqf::Parameters>(params.at(1));
if (objectIdent != 0) //all the vehicles have objectUID = 0, so it would be bad to update those
return booleanReturn(_objData->updateObjectInventory(getServerId(),objectIdent,byUID,inventory));
return booleanReturn(true);
}
示例13: vehicleMoved
Sqf::Value HiveExtApp::vehicleMoved( Sqf::Parameters params )
{
Int64 objectIdent = Sqf::GetBigInt(params.at(0));
Sqf::Value worldspace = boost::get<Sqf::Parameters>(params.at(1));
double fuel = Sqf::GetDouble(params.at(2));
if (objectIdent > 0) //sometimes script sends this with object id 0, which is bad
return booleanReturn(_objData->updateVehicleMovement(getServerId(),objectIdent,worldspace,fuel));
return booleanReturn(true);
}
示例14: vehicleDamaged
Sqf::Value HiveExtApp::vehicleDamaged( Sqf::Parameters params )
{
Int64 objectIdent = Sqf::GetBigInt(params.at(0));
Sqf::Value hitPoints = boost::get<Sqf::Parameters>(params.at(1));
double damage = Sqf::GetDouble(params.at(2));
if (objectIdent > 0) //sometimes script sends this with object id 0, which is bad
return booleanReturn(_objData->updateVehicleStatus(getServerId(),objectIdent,hitPoints,damage));
return booleanReturn(true);
}
示例15: 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();
};
};
};