本文整理汇总了C++中CMutableTransaction::SetGameTx方法的典型用法代码示例。如果您正苦于以下问题:C++ CMutableTransaction::SetGameTx方法的具体用法?C++ CMutableTransaction::SetGameTx怎么用?C++ CMutableTransaction::SetGameTx使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMutableTransaction
的用法示例。
在下文中一共展示了CMutableTransaction::SetGameTx方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: error
bool
CreateGameTransactions (const CCoinsView& view, unsigned nHeight,
const StepResult& stepResult,
std::vector<CTransaction>& vGameTx)
{
vGameTx.clear ();
/* Destroy name-coins of killed players. */
bool haveTxKills = false;
CMutableTransaction txKills;
txKills.SetGameTx ();
const PlayerSet& killedPlayers = stepResult.GetKilledPlayers ();
const KilledByMap& killedBy = stepResult.GetKilledBy ();
txKills.vin.reserve (killedPlayers.size ());
BOOST_FOREACH(const PlayerID &victim, killedPlayers)
{
const valtype vchName = ValtypeFromString (victim);
CNameData data;
if (!view.GetName (vchName, data))
return error ("Game engine killed a non-existing player %s",
victim.c_str ());
CTxIn txin(data.getUpdateOutpoint ());
/* List all killers, if player was simultaneously killed by several
other players. If the reason was not KILLED_DESTRUCT, handle
it also. If multiple reasons apply, the game tx is constructed
for the first reason according to the ordering inside of KilledByMap.
(Which in turn is determined by the enum values for KILLED_*.) */
typedef KilledByMap::const_iterator Iter;
const std::pair<Iter, Iter> iters = killedBy.equal_range (victim);
if (iters.first == iters.second)
return error ("No reason for killed player %s", victim.c_str ());
const KilledByInfo::Reason reason = iters.first->second.reason;
/* Unless we have destruct, there should be exactly one entry with
the "first" reason. There may be multiple entries for different
reasons, for instance, killed by poison and staying in spawn
area at the same time. */
{
Iter it = iters.first;
++it;
if (reason != KilledByInfo::KILLED_DESTRUCT && it != iters.second
&& reason == it->second.reason)
return error ("Multiple same-reason, non-destruct killed-by"
" entries for %s", victim.c_str ());
}
switch (reason)
{
case KilledByInfo::KILLED_DESTRUCT:
txin.scriptSig << vchName << GAMEOP_KILLED_BY;
for (Iter it = iters.first; it != iters.second; ++it)
{
if (it->second.reason != KilledByInfo::KILLED_DESTRUCT)
{
assert (it != iters.first);
break;
}
txin.scriptSig
<< ValtypeFromString (it->second.killer.ToString ());
}
break;
case KilledByInfo::KILLED_SPAWN:
txin.scriptSig << vchName << GAMEOP_KILLED_BY;
break;
case KilledByInfo::KILLED_POISON:
txin.scriptSig << vchName << GAMEOP_KILLED_POISON;
break;
default:
assert (false);
}
txKills.vin.push_back (txin);
haveTxKills = true;
}
if (haveTxKills)
{
const CTransaction tx(txKills);
assert (tx.IsGameTx () && !tx.IsBountyTx ());
vGameTx.push_back (tx);
}
/* Pay bounties to the players who collected them. The transaction
inputs are just "dummy" containing informational messages. */
bool haveTxBounties = false;
CMutableTransaction txBounties;
txBounties.SetGameTx ();
txBounties.vin.reserve (stepResult.bounties.size ());
txBounties.vout.reserve (stepResult.bounties.size ());
BOOST_FOREACH(const CollectedBounty& bounty, stepResult.bounties)
//.........这里部分代码省略.........