本文整理汇总了C++中Object类的典型用法代码示例。如果您正苦于以下问题:C++ Object类的具体用法?C++ Object怎么用?C++ Object使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Object类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: blockToJSON
Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex)
{
Object result;
result.push_back(Pair("hash", block.GetHash().GetHex()));
CMerkleTx txGen(block.vtx[0]);
txGen.SetMerkleBranch(&block);
result.push_back(Pair("confirmations", (int)txGen.GetDepthInMainChain()));
result.push_back(Pair("size", (int)::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION)));
result.push_back(Pair("height", blockindex->nHeight));
result.push_back(Pair("version", block.nVersion));
result.push_back(Pair("merkleroot", block.hashMerkleRoot.GetHex()));
Array txs;
BOOST_FOREACH(const CTransaction&tx, block.vtx)
txs.push_back(tx.GetHash().GetHex());
result.push_back(Pair("tx", txs));
result.push_back(Pair("time", (boost::int64_t)block.GetBlockTime()));
result.push_back(Pair("nonce", (boost::uint64_t)block.nNonce));
result.push_back(Pair("bits", HexBits(block.nBits)));
result.push_back(Pair("difficulty", GetDifficulty(blockindex)));
if (blockindex->pprev)
result.push_back(Pair("previousblockhash", blockindex->pprev->GetBlockHash().GetHex()));
if (blockindex->pnext)
result.push_back(Pair("nextblockhash", blockindex->pnext->GetBlockHash().GetHex()));
return result;
}
示例2: blockToJSON
Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool fPrintTransactionDetail)
{
Object result;
result.push_back(Pair("hash", block.GetHash().GetHex()));
CMerkleTx txGen(block.vtx[0]);
txGen.SetMerkleBranch(&block);
result.push_back(Pair("confirmations", (int)txGen.GetDepthInMainChain()));
result.push_back(Pair("size", (int)::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION)));
result.push_back(Pair("height", blockindex->nHeight));
result.push_back(Pair("version", block.nVersion));
result.push_back(Pair("merkleroot", block.hashMerkleRoot.GetHex()));
result.push_back(Pair("mint", ValueFromAmount(blockindex->nMint)));
result.push_back(Pair("time", (boost::int64_t)block.GetBlockTime()));
result.push_back(Pair("nonce", (boost::uint64_t)block.nNonce));
result.push_back(Pair("bits", HexBits(block.nBits)));
result.push_back(Pair("difficulty", GetDifficulty(blockindex)));
result.push_back(Pair("blocktrust", leftTrim(blockindex->GetBlockTrust().GetHex(), '0')));
result.push_back(Pair("chaintrust", leftTrim(blockindex->nChainTrust.GetHex(), '0')));
if (blockindex->pprev)
result.push_back(Pair("previousblockhash", blockindex->pprev->GetBlockHash().GetHex()));
if (blockindex->pnext)
result.push_back(Pair("nextblockhash", blockindex->pnext->GetBlockHash().GetHex()));
result.push_back(Pair("flags", strprintf("%s%s", blockindex->IsProofOfStake()? "proof-of-stake" : "proof-of-work", blockindex->GeneratedStakeModifier()? " stake-modifier": "")));
result.push_back(Pair("proofhash", blockindex->IsProofOfStake()? blockindex->hashProofOfStake.GetHex() : blockindex->GetBlockHash().GetHex()));
result.push_back(Pair("entropybit", (int)blockindex->GetStakeEntropyBit()));
result.push_back(Pair("modifier", strprintf("%016"PRIx64, blockindex->nStakeModifier)));
result.push_back(Pair("modifierchecksum", strprintf("%08x", blockindex->nStakeModifierChecksum)));
Array txinfo;
BOOST_FOREACH (const CTransaction& tx, block.vtx)
{
if (fPrintTransactionDetail)
{
Object entry;
entry.push_back(Pair("txid", tx.GetHash().GetHex()));
TxToJSON(tx, 0, entry);
txinfo.push_back(entry);
}
else
txinfo.push_back(tx.GetHash().GetHex());
}
result.push_back(Pair("tx", txinfo));
if (block.IsProofOfStake())
result.push_back(Pair("signature", HexStr(block.vchBlockSig.begin(), block.vchBlockSig.end())));
return result;
}
示例3: getrawtransaction
Value getrawtransaction(const Array& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error(
"getrawtransaction \"txid\" ( verbose )\n"
"\nNOTE: By default this function only works sometimes. This is when the tx is in the mempool\n"
"or there is an unspent output in the utxo for this transaction. To make it always work,\n"
"you need to maintain a transaction index, using the -txindex command line option.\n"
"\nReturn the raw transaction data.\n"
"\nIf verbose=0, returns a string that is serialized, hex-encoded data for 'txid'.\n"
"If verbose is non-zero, returns an Object with information about 'txid'.\n"
"\nArguments:\n"
"1. \"txid\" (string, required) The transaction id\n"
"2. verbose (numeric, optional, default=0) If 0, return a string, other return a json object\n"
"\nResult (if verbose is not set or set to 0):\n"
"\"data\" (string) The serialized, hex-encoded data for 'txid'\n"
"\nResult (if verbose > 0):\n"
"{\n"
" \"hex\" : \"data\", (string) The serialized, hex-encoded data for 'txid'\n"
" \"txid\" : \"id\", (string) The transaction id (same as provided)\n"
" \"version\" : n, (numeric) The version\n"
" \"locktime\" : ttt, (numeric) The lock time\n"
" \"vin\" : [ (array of json objects)\n"
" {\n"
" \"txid\": \"id\", (string) The transaction id\n"
" \"vout\": n, (numeric) \n"
" \"scriptSig\": { (json object) The script\n"
" \"asm\": \"asm\", (string) asm\n"
" \"hex\": \"hex\" (string) hex\n"
" },\n"
" \"sequence\": n (numeric) The script sequence number\n"
" }\n"
" ,...\n"
" ],\n"
" \"vout\" : [ (array of json objects)\n"
" {\n"
" \"value\" : x.xxx, (numeric) The value in btc\n"
" \"n\" : n, (numeric) index\n"
" \"scriptPubKey\" : { (json object)\n"
" \"asm\" : \"asm\", (string) the asm\n"
" \"hex\" : \"hex\", (string) the hex\n"
" \"reqSigs\" : n, (numeric) The required sigs\n"
" \"type\" : \"pubkeyhash\", (string) The type, eg 'pubkeyhash'\n"
" \"addresses\" : [ (json array of string)\n"
" \"viacoinaddress\" (string) viacoin address\n"
" ,...\n"
" ]\n"
" }\n"
" }\n"
" ,...\n"
" ],\n"
" \"blockhash\" : \"hash\", (string) the block hash\n"
" \"confirmations\" : n, (numeric) The confirmations\n"
" \"time\" : ttt, (numeric) The transaction time in seconds since epoch (Jan 1 1970 GMT)\n"
" \"blocktime\" : ttt (numeric) The block time in seconds since epoch (Jan 1 1970 GMT)\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("getrawtransaction", "\"mytxid\"")
+ HelpExampleCli("getrawtransaction", "\"mytxid\" 1")
+ HelpExampleRpc("getrawtransaction", "\"mytxid\", 1")
);
uint256 hash = ParseHashV(params[0], "parameter 1");
bool fVerbose = false;
if (params.size() > 1)
fVerbose = (params[1].get_int() != 0);
CTransaction tx;
uint256 hashBlock = 0;
if (!GetTransaction(hash, tx, hashBlock, true))
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available about transaction");
string strHex = EncodeHexTx(tx);
if (!fVerbose)
return strHex;
Object result;
result.push_back(Pair("hex", strHex));
TxToJSON(tx, hashBlock, result);
return result;
}
示例4: GetTargetType
bool Spell::GenerateTargets(SpellCastTargets* t)
{
if (u_caster == NULL || u_caster->GetAIInterface() == NULL || !u_caster->IsInWorld())
return false;
bool result = false;
for (uint32 i = 0; i < 3; ++i)
{
if (m_spellInfo->Effect[i] == 0)
continue;
uint32 TargetType = 0;
TargetType |= GetTargetType(m_spellInfo->EffectImplicitTargetA[i], i);
//never get info from B if it is 0 :P
if (m_spellInfo->EffectImplicitTargetB[i] != 0)
TargetType |= GetTargetType(m_spellInfo->EffectImplicitTargetB[i], i);
if (TargetType & (SPELL_TARGET_OBJECT_SELF | SPELL_TARGET_AREA_PARTY | SPELL_TARGET_AREA_RAID))
{
t->m_targetMask |= TARGET_FLAG_UNIT;
t->m_unitTarget = u_caster->GetGUID();
result = true;
}
if (TargetType & SPELL_TARGET_NO_OBJECT)
{
t->m_targetMask = TARGET_FLAG_SELF;
result = true;
}
if (!(TargetType & (SPELL_TARGET_AREA | SPELL_TARGET_AREA_SELF | SPELL_TARGET_AREA_CURTARGET | SPELL_TARGET_AREA_CONE)))
{
if (TargetType & SPELL_TARGET_ANY_OBJECT)
{
if (u_caster->GetUInt64Value(UNIT_FIELD_TARGET))
{
//generate targets for things like arcane missiles trigger, tame pet, etc
Object* target = u_caster->GetMapMgr()->_GetObject(u_caster->GetUInt64Value(UNIT_FIELD_TARGET));
if (target != NULL)
{
if (target->IsUnit())
{
t->m_targetMask |= TARGET_FLAG_UNIT;
t->m_unitTarget = target->GetGUID();
result = true;
}
else if (target->IsGameObject())
{
t->m_targetMask |= TARGET_FLAG_OBJECT;
t->m_unitTarget = target->GetGUID();
result = true;
}
}
result = true;
}
}
if (TargetType & SPELL_TARGET_REQUIRE_ATTACKABLE)
{
if (u_caster->GetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT))
{
//generate targets for things like arcane missiles trigger, tame pet, etc
Object* target = u_caster->GetMapMgr()->_GetObject(u_caster->GetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT));
if (target != NULL)
{
if (target->IsUnit())
{
t->m_targetMask |= TARGET_FLAG_UNIT;
t->m_unitTarget = target->GetGUID();
result = true;
}
else if (target->IsGameObject())
{
t->m_targetMask |= TARGET_FLAG_OBJECT;
t->m_unitTarget = target->GetGUID();
result = true;
}
}
}
else if (u_caster->GetUInt64Value(UNIT_FIELD_TARGET))
{
//generate targets for things like arcane missiles trigger, tame pet, etc
Object* target = u_caster->GetMapMgr()->_GetObject(u_caster->GetUInt64Value(UNIT_FIELD_TARGET));
if (target != NULL)
{
if (target->IsUnit())
{
t->m_targetMask |= TARGET_FLAG_UNIT;
t->m_unitTarget = target->GetGUID();
result = true;
}
else if (target->IsGameObject())
{
t->m_targetMask |= TARGET_FLAG_OBJECT;
t->m_unitTarget = target->GetGUID();
result = true;
}
}
//.........这里部分代码省略.........
示例5: main
int main(int argc, char **argv) {
PHYSFS_init(argv[0]);
#if defined(__APPLE__) && defined(__MACH__)
uint32_t bufsize = 2048;
char path[bufsize];
_NSGetExecutablePath(path, &bufsize);
String basePath = path;
vector<String> cpts = basePath.split("/");
String installPath = "";
for(int i=0; i < cpts.size() - 2; i++) {
installPath = installPath + cpts[i];
installPath += String("/");
}
#elif defined (_WINDOWS)
char path[2049];
TCHAR tpath[2049];
GetModuleFileName(NULL, (LPWSTR)tpath, 2048);
wtoc(path, tpath, 2048);
String basePath = path;
vector<String> cpts = basePath.split("\\");
String installPath = "";
for(int i=0; i < cpts.size() - 2; i++) {
installPath = installPath + cpts[i];
installPath += String("\\");
}
#else
String basePath = PHYSFS_getBaseDir();
vector<String> cpts = basePath.split("/");
String installPath = "";
for(int i=0; i < cpts.size() - 2; i++) {
installPath = installPath + cpts[i];
installPath += String("/");
}
#endif
printf("Polycode build tool v0.8.2\n");
for(int i=0; i < argc; i++) {
String argString = String(argv[i]);
vector<String> bits = argString.split("=");
if(bits.size() == 2) {
BuildArg arg;
arg.name = bits[0];
arg.value = bits[1];
// printf("arg: %s=%s\n", arg.name.c_str(), arg.value.c_str());
args.push_back(arg);
}
}
if(getArg("--config") == "") {
printf("\n\nInput config XML missing. Use --config=path to specify.\n\n");
return 1;
}
if(getArg("--out") == "") {
printf("\n\nOutput file not specified. Use --out=outfile.polyapp to specify.\n\n");
return 1;
}
char dirPath[4099];
#if defined(__APPLE__) && defined(__MACH__)
getcwd(dirPath, sizeof(dirPath));
#elif defined (_WINDOWS)
TCHAR tdirpath[4099];
GetCurrentDirectory(4098, (LPWSTR)tdirpath);
wtoc(dirPath, tdirpath, 4098);
#else
getcwd(dirPath, sizeof(dirPath));
#endif
String currentPath = String(dirPath);
String configPath = getArg("--config");
String finalPath = configPath;
if(configPath[0] != '/' && configPath[1] !=':') {
#ifdef _WINDOWS
finalPath = currentPath+"\\"+configPath;
#else
finalPath = currentPath+"/"+configPath;
#endif
}
printf("Reading config file from %s\n", finalPath.c_str());
Object configFile;
if(!configFile.loadFromXML(finalPath)) {
printf("Specified config file doesn't exist!\n");
return 1;
}
printf("OK!\n");
// start required params
//.........这里部分代码省略.........
示例6: while
void HavokExport::makeHavokRigidBody(NiNodeRef parent, INode *ragdollParent, float scale) {
this->scale = scale;
Object *Obj = ragdollParent->GetObjectRef();
Modifier* rbMod = nullptr;
Modifier* shapeMod = nullptr;
Modifier* constraintMod = nullptr;
SimpleObject* havokTaperCapsule = nullptr;
//get modifiers
while (Obj->SuperClassID() == GEN_DERIVOB_CLASS_ID) {
IDerivedObject *DerObj = static_cast<IDerivedObject *> (Obj);
const int nMods = DerObj->NumModifiers(); //it is really the last modifier on the stack, and not the total number of modifiers
for (int i = 0; i < nMods; i++)
{
Modifier *Mod = DerObj->GetModifier(i);
if (Mod->ClassID() == HK_RIGIDBODY_MODIFIER_CLASS_ID) {
rbMod = Mod;
}
if (Mod->ClassID() == HK_SHAPE_MODIFIER_CLASS_ID) {
shapeMod = Mod;
}
if (Mod->ClassID() == HK_CONSTRAINT_RAGDOLL_CLASS_ID || Mod->ClassID() == HK_CONSTRAINT_HINGE_CLASS_ID) {
constraintMod = Mod;
}
}
if (Obj->SuperClassID() == GEOMOBJECT_CLASS_ID) {
havokTaperCapsule = (SimpleObject*)Obj;
}
Obj = DerObj->GetObjRef();
}
if (!rbMod) {
throw exception(FormatText("No havok rigid body modifier found on %s", ragdollParent->GetName()));
}
if (!shapeMod) {
throw exception(FormatText("No havok shape modifier found on %s", ragdollParent->GetName()));
}
// Object* taper = ragdollParent->GetObjectRef();
IParamBlock2* taperParameters = Obj->GetParamBlockByID(PB_TAPEREDCAPSULE_OBJ_PBLOCK);
float radius;
enum
{
// GENERAL PROPERTIES ROLLOUT
PA_TAPEREDCAPSULE_OBJ_RADIUS = 0,
PA_TAPEREDCAPSULE_OBJ_TAPER,
PA_TAPEREDCAPSULE_OBJ_HEIGHT,
PA_TAPEREDCAPSULE_OBJ_VERSION_INTERNAL,
};
taperParameters->GetValue(PA_TAPEREDCAPSULE_OBJ_RADIUS, 0, radius, FOREVER);
int shapeType;
if (IParamBlock2* shapeParameters = shapeMod->GetParamBlockByID(PB_SHAPE_MOD_PBLOCK)) {
shapeParameters->GetValue(PA_SHAPE_MOD_SHAPE_TYPE,0,shapeType,FOREVER);
}
//Havok Shape
bhkShapeRef shape;
if (shapeType == 2) {
// Capsule
bhkCapsuleShapeRef capsule = new bhkCapsuleShape();
capsule->SetRadius(radius/scale);
capsule->SetRadius1(radius/scale);
capsule->SetRadius2(radius/scale);
float length;
taperParameters->GetValue(PA_TAPEREDCAPSULE_OBJ_HEIGHT, 0, length, FOREVER);
//get the normal
Matrix3 axis(true);
ragdollParent->GetObjOffsetRot().MakeMatrix(axis);
Point3 normalAx = axis.GetRow(2);
//capsule center
Point3 center = ragdollParent->GetObjOffsetPos();
//min and max points
Point3 pt1 = center - normalAx*(length/2);
Point3 pt2 = center + normalAx*(length/2);
capsule->SetFirstPoint(TOVECTOR3(pt1)/scale);
capsule->SetSecondPoint(TOVECTOR3(pt2)/scale);
capsule->SetMaterial(HAV_MAT_SKIN);
shape = StaticCast<bhkShape>(capsule);
}
else {
// Sphere
//CalcBoundingSphere(node, tm.GetTrans(), radius, 0);
bhkSphereShapeRef sphere = new bhkSphereShape();
sphere->SetRadius(radius/scale);
//.........这里部分代码省略.........
示例7: GetMaxRange
void Spell::AddChainTargets(uint32 i, uint32 TargetType, float r, uint32 maxtargets)
{
if (!m_caster->IsInWorld())
return;
Object* targ = m_caster->GetMapMgr()->_GetObject(m_targets.m_unitTarget);
if (targ == NULL)
return;
TargetsList* list = &m_targetUnits[i];
//if selected target is party member, then jumps on party
Unit* firstTarget = NULL;
if (targ->IsUnit())
firstTarget = static_cast<Unit*>(targ);
else
firstTarget = u_caster;
bool RaidOnly = false;
float range = GetMaxRange(dbcSpellRange.LookupEntry(m_spellInfo->rangeIndex));//this is probably wrong,
//this is cast distance, not searching distance
range *= range;
//is this party only?
Player* casterFrom = static_cast< Player* >(u_caster->GetPlayerOwner());
Player* pfirstTargetFrom = static_cast< Player* >(firstTarget->GetPlayerOwner());
if (casterFrom != NULL && pfirstTargetFrom != NULL && casterFrom->GetGroup() == pfirstTargetFrom->GetGroup())
RaidOnly = true;
uint32 jumps = m_spellInfo->EffectChainTarget[i];
//range
range /= jumps; //hacky, needs better implementation!
if (u_caster != nullptr)
SM_FIValue(u_caster->SM_FAdditionalTargets, (int32*)&jumps, m_spellInfo->SpellGroupType);
AddTarget(i, TargetType, firstTarget);
if (jumps <= 1 || list->size() == 0) //1 because we've added the first target, 0 size if spell is resisted
return;
ObjectSet::iterator itr;
for (itr = firstTarget->GetInRangeSetBegin(); itr != firstTarget->GetInRangeSetEnd(); itr++)
{
if (!(*itr)->IsUnit() || !static_cast<Unit*>((*itr))->isAlive())
continue;
if (RaidOnly && !pfirstTargetFrom->InRaid(static_cast<Unit*>(*itr)))
continue;
//healing spell, full health target = NONO
if (IsHealingSpell(m_spellInfo) && static_cast<Unit*>(*itr)->GetHealthPct() == 100)
continue;
size_t oldsize;
if (IsInrange(firstTarget->GetPositionX(), firstTarget->GetPositionY(), firstTarget->GetPositionZ(), (*itr), range))
{
oldsize = list->size();
AddTarget(i, TargetType, (*itr));
if (list->size() == oldsize || list->size() >= jumps) //either out of jumps or a resist
return;
}
}
}
示例8: DEBUG_LOG
void WorldSession::HandleQuestgiverAcceptQuestOpcode( WorldPacket & recv_data )
{
ObjectGuid guid;
uint32 quest;
uint32 unk1;
recv_data >> guid >> quest >> unk1;
if (!GetPlayer()->isAlive())
return;
DEBUG_LOG("WORLD: Received CMSG_QUESTGIVER_ACCEPT_QUEST npc = %s, quest = %u, unk1 = %u", guid.GetString().c_str(), quest, unk1 );
Object* pObject = _player->GetObjectByTypeMask(guid, TYPEMASK_CREATURE_GAMEOBJECT_PLAYER_OR_ITEM);
// no or incorrect quest giver
if(!pObject
|| (pObject->GetTypeId()!=TYPEID_PLAYER && !pObject->HasQuest(quest))
|| (pObject->GetTypeId()==TYPEID_PLAYER && !((Player*)pObject)->CanShareQuest(quest))
)
{
_player->PlayerTalkClass->CloseGossip();
_player->ClearDividerGuid();
return;
}
Quest const* qInfo = sObjectMgr.GetQuestTemplate(quest);
if ( qInfo )
{
// prevent cheating
if(!GetPlayer()->CanTakeQuest(qInfo,true) )
{
_player->PlayerTalkClass->CloseGossip();
_player->ClearDividerGuid();
return;
}
if (Player *pPlayer = ObjectAccessor::FindPlayer(_player->GetDividerGuid()))
{
pPlayer->SendPushToPartyResponse(_player, QUEST_PARTY_MSG_ACCEPT_QUEST);
_player->ClearDividerGuid();
}
if( _player->CanAddQuest( qInfo, true ) )
{
_player->AddQuest( qInfo, pObject ); // pObject (if it item) can be destroyed at call
if (qInfo->HasQuestFlag(QUEST_FLAGS_PARTY_ACCEPT))
{
if (Group* pGroup = _player->GetGroup())
{
for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player* pPlayer = itr->getSource();
if (!pPlayer || pPlayer == _player) // not self
continue;
if (pPlayer->CanTakeQuest(qInfo, true))
{
pPlayer->SetDividerGuid(_player->GetObjectGuid());
//need confirmation that any gossip window will close
pPlayer->PlayerTalkClass->CloseGossip();
_player->SendQuestConfirmAccept(qInfo, pPlayer);
}
}
}
}
if ( _player->CanCompleteQuest( quest ) )
_player->CompleteQuest( quest );
_player->GetAchievementMgr().StartTimedAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST, quest);
_player->PlayerTalkClass->CloseGossip();
if( qInfo->GetSrcSpell() > 0 )
_player->CastSpell( _player, qInfo->GetSrcSpell(), true);
return;
}
}
_player->PlayerTalkClass->CloseGossip();
}
示例9: PDFDocFactory
void PDFFormat::init(std::string& filename){
PDFDoc *doc = PDFDocFactory().createPDFDoc(GooString(filename.c_str()));
//GBool enc = doc->isEncrypted();
GooString ID;
Object obj,id_obj;
Dict* trailer = doc->getXRef()->getTrailerDict()->getDict();
trailer->lookupNF("ID",&obj);
obj.getArray()->getNF(0,&id_obj);
data.ID1.assign(id_obj.getString()->getCString(),16);
obj.getArray()->getNF(1,&id_obj);
data.ID2.assign(id_obj.getString()->getCString(),16);
GBool enc = trailer->hasKey("Encrypt");
if(enc){
is_encrypted = true;
trailer->lookupNF("Encrypt",&obj);
Object encObj;
doc->getXRef()->fetch(obj.getRef().num,obj.getRef().gen,&encObj);
encObj.getDict()->lookupNF("Filter",&obj);
encObj.getDict()->lookupNF("R",&obj);
this->data.R = obj.getInt();
encObj.getDict()->lookupNF("V",&obj);
this->data.V = obj.getInt();
encObj.getDict()->lookupNF("P",&obj);
this->data.P = obj.getInt();
encObj.getDict()->lookupNF("Length",&obj);
this->data.length = obj.getInt();
encObj.getDict()->lookupNF("O",&obj);
if ((int)this->data.R <= 4) {
/* Revision 4 or less => 32Byte O string */
this->data.O.assign(obj.getString()->getCString(),32);
} else {
/* Revision 5 or 6 => 48Byte O string */
this->data.O.assign(obj.getString()->getCString(),48);
::memcpy(this->data.O_valid_salt, this->data.O.substr(32, 8).c_str(), 8);
::memcpy(this->data.O_key_salt, this->data.O.substr(40, 8).c_str(), 8);
this->data.O.resize(32);
}
encObj.getDict()->lookupNF("U",&obj);
if ((int)this->data.R <= 4) {
/* Revision 4 or less => 32Byte U string */
this->data.U.assign(obj.getString()->getCString(),32);
} else {
/* Revision 5 or 6 => 48Byte U string */
this->data.U.assign(obj.getString()->getCString(),48);
::memcpy(this->data.U_valid_salt, this->data.U.substr(32, 8).c_str(), 8);
::memcpy(this->data.U_key_salt, this->data.U.substr(40, 8).c_str(), 8);
this->data.U.resize(32);
}
if(encObj.getDict()->hasKey("EncryptMetadata")){
encObj.getDict()->lookupNF("EncryptMetadata", &obj);
this->data.MetaEncrypted = obj.getBool();
}
int v_major = doc->getPDFMajorVersion();
int v_minor = doc->getPDFMinorVersion();
if (verbose) {
// Print PDF encryption information from EncObj
std::cout << "======= PDF information =======" << std::endl;
std::cout << "PDF version: " << v_major << "." << v_minor << std::endl;
if ((int)this->data.R == 5) {
std::cout << "Extension level 3 detected." << std::endl;
} else if ((int)this->data.R == 6) {
std::cout << "Extension level 5 detected." << std::endl;
} else if ((int)this->data.R > 6) {
std::cout << "Warning: Unknown (unsupported) security revision!" << std::endl;
}
std::cout << "Security revision: " << (int)this->data.R << std::endl;
std::cout << "Encryption alg. version: " << (int)this->data.V << std::endl;
std::cout << "Key length: " << (int)this->data.length << std::endl;
std::cout << "Metadata encrypted: ";
if (this->data.MetaEncrypted) {
std::cout << "yes";
} else {
std::cout << "no";
}
std::cout << std::endl;
std::cout << "===============================" << std::endl;
}
}else{
is_encrypted = false;
}
is_supported = true;
}
示例10: checkkernel
Value checkkernel(const Array& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error(
"checkkernel [{\"txid\":txid,\"vout\":n},...] [createblocktemplate=false]\n"
"Check if one of given inputs is a kernel input at the moment.\n"
);
RPCTypeCheck(params, list_of(array_type)(bool_type));
Array inputs = params[0].get_array();
bool fCreateBlockTemplate = params.size() > 1 ? params[1].get_bool() : false;
if (vNodes.empty())
throw JSONRPCError(-9, "SatoshiChain is not connected!");
if (IsInitialBlockDownload())
throw JSONRPCError(-10, "SatoshiChain is downloading blocks...");
COutPoint kernel;
CBlockIndex* pindexPrev = pindexBest;
unsigned int nBits = GetNextTargetRequired(pindexPrev, true);
int64_t nTime = GetAdjustedTime();
nTime &= ~STAKE_TIMESTAMP_MASK;
BOOST_FOREACH(Value& input, inputs)
{
const Object& o = input.get_obj();
const Value& txid_v = find_value(o, "txid");
if (txid_v.type() != str_type)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, missing txid key");
string txid = txid_v.get_str();
if (!IsHex(txid))
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, expected hex txid");
const Value& vout_v = find_value(o, "vout");
if (vout_v.type() != int_type)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, missing vout key");
int nOutput = vout_v.get_int();
if (nOutput < 0)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, vout must be positive");
COutPoint cInput(uint256(txid), nOutput);
if (CheckKernel(pindexPrev, nBits, nTime, cInput))
{
kernel = cInput;
break;
}
}
Object result;
result.push_back(Pair("found", !kernel.IsNull()));
if (kernel.IsNull())
return result;
Object oKernel;
oKernel.push_back(Pair("txid", kernel.hash.GetHex()));
oKernel.push_back(Pair("vout", (int64_t)kernel.n));
oKernel.push_back(Pair("time", nTime));
result.push_back(Pair("kernel", oKernel));
if (!fCreateBlockTemplate)
return result;
int64_t nFees;
auto_ptr<CBlock> pblock(CreateNewBlock(*pMiningKey, true, &nFees));
pblock->nTime = pblock->vtx[0].nTime = nTime;
CDataStream ss(SER_DISK, PROTOCOL_VERSION);
ss << *pblock;
result.push_back(Pair("blocktemplate", HexStr(ss.begin(), ss.end())));
result.push_back(Pair("blocktemplatefees", nFees));
CPubKey pubkey;
if (!pMiningKey->GetReservedKey(pubkey))
throw JSONRPCError(RPC_MISC_ERROR, "GetReservedKey failed");
result.push_back(Pair("blocktemplatesignkey", HexStr(pubkey)));
return result;
}
示例11: getstakinginfo
Value getstakinginfo(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw runtime_error(
"getstakinginfo\n"
"Returns an object containing staking-related information.");
uint64_t nMinWeight = 0, nMaxWeight = 0, nWeight = 0;
pwalletMain->GetStakeWeight(*pwalletMain, nMinWeight, nMaxWeight, nWeight);
uint64_t nNetworkWeight = GetPoSKernelPS();
bool staking = nLastCoinStakeSearchInterval && nWeight;
int nExpectedTime = staking ? (nTargetSpacing * nNetworkWeight / nWeight) : -1;
Object obj;
obj.push_back(Pair("enabled", GetBoolArg("-staking", true)));
obj.push_back(Pair("staking", staking));
obj.push_back(Pair("errors", GetWarnings("statusbar")));
obj.push_back(Pair("currentblocksize", (uint64_t)nLastBlockSize));
obj.push_back(Pair("currentblocktx", (uint64_t)nLastBlockTx));
obj.push_back(Pair("pooledtx", (uint64_t)mempool.size()));
obj.push_back(Pair("difficulty", GetDifficulty(GetLastBlockIndex(pindexBest, true))));
obj.push_back(Pair("search-interval", (int)nLastCoinStakeSearchInterval));
obj.push_back(Pair("weight", (uint64_t)nWeight));
obj.push_back(Pair("netstakeweight", (uint64_t)nNetworkWeight));
obj.push_back(Pair("expectedtime", nExpectedTime));
return obj;
}
示例12: getworkex
Value getworkex(const Array& params, bool fHelp)
{
if (fHelp || params.size() > 2)
throw runtime_error(
"getworkex [data, coinbase]\n"
"If [data, coinbase] is not specified, returns extended work data.\n"
);
if (vNodes.empty())
throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "Quatloo is not connected!");
if (IsInitialBlockDownload())
throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Quatloo is downloading blocks...");
typedef map<uint256, pair<CBlock*, CScript> > mapNewBlock_t;
static mapNewBlock_t mapNewBlock; // FIXME: thread safety
static vector<CBlockTemplate*> vNewBlockTemplate;
static CReserveKey reservekey(pwalletMain);
if (params.size() == 0)
{
// Update block
static unsigned int nTransactionsUpdatedLast;
static CBlockIndex* pindexPrev;
static int64 nStart;
static CBlockTemplate* pblocktemplate;
if (pindexPrev != pindexBest ||
(nTransactionsUpdated != nTransactionsUpdatedLast && GetTime() - nStart > 60))
{
if (pindexPrev != pindexBest)
{
// Deallocate old blocks since they're obsolete now
mapNewBlock.clear();
BOOST_FOREACH(CBlockTemplate* pblocktemplate, vNewBlockTemplate)
delete pblocktemplate;
vNewBlockTemplate.clear();
}
// Clear pindexPrev so future getworks make a new block, despite any failures from here on
pindexPrev = NULL;
// Store the pindexBest used before CreateNewBlock, to avoid races
nTransactionsUpdatedLast = nTransactionsUpdated;
CBlockIndex* pindexPrevNew = pindexBest;
nStart = GetTime();
// Create new block
pblocktemplate = CreateNewBlockWithKey(*pMiningKey);
if (!pblocktemplate)
throw JSONRPCError(RPC_OUT_OF_MEMORY, "Out of memory");
vNewBlockTemplate.push_back(pblocktemplate);
// Need to update only after we know CreateNewBlock succeeded
pindexPrev = pindexPrevNew;
}
CBlock* pblock = &pblocktemplate->block; // pointer for convenience
// Update nTime
pblock->UpdateTime(pindexPrev);
pblock->nNonce = 0;
// Update nExtraNonce
static unsigned int nExtraNonce = 0;
IncrementExtraNonce(pblock, pindexPrev, nExtraNonce);
// Save
mapNewBlock[pblock->hashMerkleRoot] = make_pair(pblock, pblock->vtx[0].vin[0].scriptSig);
// Pre-build hash buffers
char pmidstate[32];
char pdata[128];
char phash1[64];
FormatHashBuffers(pblock, pmidstate, pdata, phash1);
uint256 hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256();
CTransaction coinbaseTx = pblock->vtx[0];
std::vector<uint256> merkle = pblock->GetMerkleBranch(0);
Object result;
result.push_back(Pair("data", HexStr(BEGIN(pdata), END(pdata))));
result.push_back(Pair("target", HexStr(BEGIN(hashTarget), END(hashTarget))));
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
ssTx << coinbaseTx;
result.push_back(Pair("coinbase", HexStr(ssTx.begin(), ssTx.end())));
Array merkle_arr;
BOOST_FOREACH(uint256 merkleh, merkle) {
printf("%s\n", merkleh.ToString().c_str());
merkle_arr.push_back(HexStr(BEGIN(merkleh), END(merkleh)));
}
result.push_back(Pair("merkle", merkle_arr));
return result;
}
示例13: strlen
bool operator> (const Object& o, const Object& o2) {
bool r;
strlen(o.GetName()) > strlen(o2.GetName()) ? r = true : r = false;
return r;
}
示例14: recursiveSearch
void recursiveSearch( GroupObject* group, ofstream &out )
{
if (!group) return;
for( unsigned i=0; i<group->objectCount(); i++ )
{
Object* object = group->object(i);
if( object->isText() )
{
TextObject* T = static_cast<TextObject*>(object);
if(T)
{
// out << " " << T->typeAsString() << " (" << T->listSize() << "): ";
bool written = false;
for (int j=0; j<T->listSize(); j++)
{
if (T->text(j).cstring().c_str()!=NULL
&& T->text(j).cstring().c_str()[0]!='\0'
&& strncmp(T->text(j).cstring().c_str(),"Click to edit",13)
&& strncmp(T->text(j).cstring().c_str(),"Klikk for å redigere",20))
{
if (!written)
{
if (!textonly)
{
if (T->type()==TextObject::Body || T->type()==TextObject::CenterBody
|| T->type()==TextObject::HalfBody || T->type()==TextObject::QuarterBody)
out << "<p>";
else if (T->type()==TextObject::Title || T->type()==TextObject::CenterTitle)
out << "<h2>";
else out << "<div>";
}
written = true;
}
if (!textonly) out << "<span>";
out << T->text(j).cstring().c_str();
if (!textonly) out << "</span> ";
}
}
if (written && !textonly)
{
if (T->type()==TextObject::Body || T->type()==TextObject::CenterBody
|| T->type()==TextObject::HalfBody || T->type()==TextObject::QuarterBody)
out << "</p>";
else if (T->type()==TextObject::Title || T->type()==TextObject::CenterTitle)
out << "</h2>";
else out << "</div>";
out << endl;
}
else
out << endl;
}
}
if( object->isGroup() )
recursiveSearch( static_cast<GroupObject*>(object), out );
}
}
示例15: TC_LOG_ERROR
void WorldSession::HandleQuestgiverChooseRewardOpcode(WorldPacket& recvData)
{
uint32 questId, reward;
ObjectGuid guid;
recvData >> guid >> questId >> reward;
if (reward >= QUEST_REWARD_CHOICES_COUNT)
{
TC_LOG_ERROR("network", "Error in CMSG_QUESTGIVER_CHOOSE_REWARD: player %s (guid %d) tried to get invalid reward (%u) (possible packet-hacking detected)", _player->GetName().c_str(), _player->GetGUID().GetCounter(), reward);
return;
}
TC_LOG_DEBUG("network", "WORLD: Received CMSG_QUESTGIVER_CHOOSE_REWARD npc = %s, quest = %u, reward = %u", guid.ToString().c_str(), questId, reward);
Object* object = ObjectAccessor::GetObjectByTypeMask(*_player, guid, TYPEMASK_UNIT | TYPEMASK_GAMEOBJECT);
if (!object || !object->hasInvolvedQuest(questId))
return;
// some kind of WPE protection
if (!_player->CanInteractWithQuestGiver(object))
return;
if (Quest const* quest = sObjectMgr->GetQuestTemplate(questId))
{
if ((!_player->CanSeeStartQuest(quest) && _player->GetQuestStatus(questId) == QUEST_STATUS_NONE) ||
(_player->GetQuestStatus(questId) != QUEST_STATUS_COMPLETE && !quest->IsAutoComplete()))
{
TC_LOG_ERROR("network", "Error in QUEST_STATUS_COMPLETE: player %s (guid %u) tried to complete quest %u, but is not allowed to do so (possible packet-hacking or high latency)",
_player->GetName().c_str(), _player->GetGUID().GetCounter(), questId);
return;
}
if (_player->CanRewardQuest(quest, reward, true))
{
_player->RewardQuest(quest, reward, object);
switch (object->GetTypeId())
{
case TYPEID_UNIT:
{
Creature* questgiver = object->ToCreature();
if (!sScriptMgr->OnQuestReward(_player, questgiver, quest, reward))
{
// Send next quest
if (Quest const* nextQuest = _player->GetNextQuest(guid, quest))
{
// Only send the quest to the player if the conditions are met
if (_player->CanTakeQuest(nextQuest, false))
{
if (nextQuest->IsAutoAccept() && _player->CanAddQuest(nextQuest, true))
_player->AddQuestAndCheckCompletion(nextQuest, object);
_player->PlayerTalkClass->SendQuestGiverQuestDetails(nextQuest, guid, true);
}
}
questgiver->AI()->sQuestReward(_player, quest, reward);
}
break;
}
case TYPEID_GAMEOBJECT:
{
GameObject* questGiver = object->ToGameObject();
if (!sScriptMgr->OnQuestReward(_player, questGiver, quest, reward))
{
// Send next quest
if (Quest const* nextQuest = _player->GetNextQuest(guid, quest))
{
// Only send the quest to the player if the conditions are met
if (_player->CanTakeQuest(nextQuest, false))
{
if (nextQuest->IsAutoAccept() && _player->CanAddQuest(nextQuest, true))
_player->AddQuestAndCheckCompletion(nextQuest, object);
_player->PlayerTalkClass->SendQuestGiverQuestDetails(nextQuest, guid, true);
}
}
questGiver->AI()->QuestReward(_player, quest, reward);
}
break;
}
default:
break;
}
}
else
_player->PlayerTalkClass->SendQuestGiverOfferReward(quest, guid, true);
}
}