Пример #1
0
    CMainParams() {
        // The message start string is designed to be unlikely to occur in normal data.
        pchMessageStart[0] = 0xfd;
        pchMessageStart[1] = 0xa4;
        pchMessageStart[2] = 0xdc;
        pchMessageStart[3] = 0x6c;
        vAlertPubKey = ParseHex("04d1832d7d0c59634d67d3023379403014c2878d0c2372d175219063a48fa06e6d429e09f36d3196ec544c2cfdd12d6fe510a399595f75ebb6da238eb5f70f2072");
        nDefaultPort = 12340;
        nRPCPort = 12341;

        bnProofOfWorkLimit[ALGO_SHA256D] = CBigNum(~uint256(0) >> 20); // 1.00000000
        bnProofOfWorkLimit[ALGO_SCRYPT]  = CBigNum(~uint256(0) >> 20);
        bnProofOfWorkLimit[ALGO_GROESTL] = CBigNum(~uint256(0) >> 20); // 0.00195311
        bnProofOfWorkLimit[ALGO_SKEIN]   = CBigNum(~uint256(0) >> 20); // 0.00195311
        bnProofOfWorkLimit[ALGO_QUBIT]   = CBigNum(~uint256(0) >> 20); // 0.00097655

        // Build the genesis block.
        const char* pszTimestamp = "Visir 10. oktober 2008 Gjaldeyrishoft sett a Islendinga";
        CTransaction txNew;
        txNew.vin.resize(1);
        txNew.vout.resize(1);
        txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) << std::vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
        txNew.vout[0].nValue = 1 * COIN;
        txNew.vout[0].scriptPubKey = CScript() << ParseHex("04a5814813115273a109cff99907ba4a05d951873dae7acb6c973d0c9e7c88911a3dbc9aa600deac241b91707e7b4ffb30ad91c8e56e695a1ddf318592988afe0a") << OP_CHECKSIG;
        genesis.vtx.push_back(txNew);
        genesis.hashPrevBlock = 0;
        genesis.hashMerkleRoot = genesis.BuildMerkleTree();
        genesis.nVersion = 1;
        genesis.nTime    = 1390598806;
        genesis.nBits    = Params().ProofOfWorkLimit(ALGO_SCRYPT).GetCompact();
        //genesis.nBits = 0x1e0fffff;
        genesis.nNonce   = 538548;

        hashGenesisBlock = genesis.GetHash();

        assert(hashGenesisBlock == uint256("0x2a8e100939494904af825b488596ddd536b3a96226ad02e0f7ab7ae472b27a8e"));
        assert(genesis.hashMerkleRoot == uint256("0x8957e5e8d2f0e90c42e739ec62fcc5dd21064852da64b6528ebd46567f222169"));

        vSeeds.push_back(CDNSSeedData("luxembourgh", "s1.auroraseed.net"));
        vSeeds.push_back(CDNSSeedData("united-states-west", "aurseed1.criptoe.com"));
        vSeeds.push_back(CDNSSeedData("united-states-east", "s1.auroraseed.com"));
        vSeeds.push_back(CDNSSeedData("iceland", "s1.auroraseed.org"));
        vSeeds.push_back(CDNSSeedData("the-netherlands", "s1.auroraseed.eu"));
        vSeeds.push_back(CDNSSeedData("electrum2", "electrum2.aurorcoin.is"));
        vSeeds.push_back(CDNSSeedData("electrum3", "electrum3.auroracoin.is"));
        vSeeds.push_back(CDNSSeedData("electrum4", "electrum4.auroracoin.is"));

        base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,23);
        base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,5);
        base58Prefixes[SECRET_KEY]     = std::vector<unsigned char>(1,176);
        base58Prefixes[SECRET_KEY_OLD] = std::vector<unsigned char>(1,151);
        base58Prefixes[EXT_PUBLIC_KEY] = boost::assign::list_of(0x04)(0x88)(0xB2)(0x1E).convert_to_container<std::vector<unsigned char> >();
        base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x04)(0x88)(0xAD)(0xE4).convert_to_container<std::vector<unsigned char> >();

        // Convert the pnSeeds array into usable address objects.
        for (unsigned int i = 0; i < ARRAYLEN(pnSeed); i++)
        {
            const int64_t nOneWeek = 7*24*60*60;
            struct in_addr ip;
            memcpy(&ip, &pnSeed[i], sizeof(ip));
            CAddress addr(CService(ip, GetDefaultPort()));
            addr.nTime = GetTime() - GetRand(nOneWeek) - nOneWeek;
            vFixedSeeds.push_back(addr);
        }
    }
Пример #2
0
static int DamageCalc( Character_t Attacker, Character_t Defender ){
	// 通常攻撃の計算式の答えを返す
	return (int)( Attacker.LEVEL*2*Attacker.Power /Defender.Defense +2 )*( 85+ GetRand(15) )/100;
}
Пример #3
0
//敵弾の初期設定
void EnemyBulletInit(){
	for(int i=0; i<EnemyBulletNum; i++){
		EnemyBullet[i].flag = false;
		EnemyBullet[i].interval = GetRand(5)*60;
	}
}
Пример #4
0
/**
    Set random shape
*/
void Tetromino::NewShape()
{
    int rand = GetRand(0, 6);

    mColor = GetRand(1, 7);

    if(rand == 0)       // O
    {
        mShape = 0;
        mWidth = 2;
        mHeight = 2;

        int temp[2][2] = {{mColor, mColor}, {mColor, mColor}};

        mShape = new int*[mHeight];
        for(int i=0; i<mHeight; i++) mShape[i] = new int[mWidth];

        for(int row=0; row<mHeight; row++)
        {
            for(int col=0; col<mWidth; col++)
            {
                mShape[row][col] = temp[row][col];
            }
        }
    }
    else if(rand == 1)       // I
    {
        mShape = 0;
        mWidth = 1;
        mHeight = 4;

        mShape = new int*[mHeight];
        for(int i=0; i<mHeight; i++) mShape[i] = new int[mWidth];

        int temp[4][1] = {{mColor}, {mColor}, {mColor}, {mColor}};

        for(int row=0; row<mHeight; row++)
        {
            for(int col=0; col<mWidth; col++)
            {
                mShape[row][col] = temp[row][col];
            }
        }
    }
    else if(rand == 2)       // L
    {
        mShape = 0;
        mWidth = 2;
        mHeight = 3;

        mShape = new int*[mHeight];
        for(int i=0; i<mHeight; i++) mShape[i] = new int[mWidth];

        int temp[3][2] = {{mColor, 0}, {mColor, 0}, {mColor, mColor}};

        for(int row=0; row<mHeight; row++)
        {
            for(int col=0; col<mWidth; col++)
            {
                mShape[row][col] = temp[row][col];
            }
        }
    }
    else if(rand == 3)       // J
    {
        mShape = 0;
        mWidth = 2;
        mHeight = 3;

        mShape = new int*[mHeight];
        for(int i=0; i<mHeight; i++) mShape[i] = new int[mWidth];

        int temp[3][2] = {{0, mColor}, {0, mColor}, {mColor, mColor}};

        for(int row=0; row<mHeight; row++)
        {
            for(int col=0; col<mWidth; col++)
            {
                mShape[row][col] = temp[row][col];
            }
        }
    }
    else if(rand == 4)       // S
    {
        mShape = 0;
        mWidth = 3;
        mHeight = 2;

        mShape = new int*[mHeight];
        for(int i=0; i<mHeight; i++) mShape[i] = new int[mWidth];

        int temp[2][3] = {{0, mColor, mColor}, {mColor, mColor, 0}};

        for(int row=0; row<mHeight; row++)
        {
            for(int col=0; col<mWidth; col++)
            {
                mShape[row][col] = temp[row][col];
            }
        }
    }
    else if(rand == 5)       // T
    {
        mShape = 0;
        mWidth = 3;
        mHeight = 2;

        mShape = new int*[mHeight];
        for(int i=0; i<mHeight; i++) mShape[i] = new int[mWidth];

        int temp[2][3] = {{0, mColor, 0}, {mColor, mColor, mColor}};

        for(int row=0; row<mHeight; row++)
        {
            for(int col=0; col<mWidth; col++)
            {
                mShape[row][col] = temp[row][col];
            }
        }
    }
    else if(rand == 6)       // Z
    {
        mShape = 0;
        mWidth = 3;
        mHeight = 2;

        mShape = new int*[mHeight];
        for(int i=0; i<mHeight; i++) mShape[i] = new int[mWidth];

        int temp[2][3] = {{mColor, mColor, 0}, {0, mColor, mColor}};

        for(int row=0; row<mHeight; row++)
        {
            for(int col=0; col<mWidth; col++)
            {
                mShape[row][col] = temp[row][col];
            }
        }
    }
    // Set shape start position
    mTopLeft.row = 0;
    mTopLeft.col = 4;

    mPotentialTopLeft.row = 0;
    mPotentialTopLeft.col = 4;

}
Пример #5
0
    CMainParams() {
        // The message start string is designed to be unlikely to occur in normal data.
            // The characters are rarely used upper ASCII, not valid as UTF-8, and produce
            // a large 4-byte int at any alignment.
            pchMessageStart[0] = 0xc7;
            pchMessageStart[1] = 0xa1;
            pchMessageStart[2] = 0xf6;
            pchMessageStart[3] = 0xc9; //chimark
            vAlertPubKey = ParseHex("04fc9702847840aaf195de8442ebecedf5b095cdbb9bc716bda9110971b28a49e0ead8564ff0db22209e0374782c093bb899692d524e9d6a6956e7c5ecbcd68284");
            nDefaultPort = 58778;
            nRPCPort = 58777;
            bnProofOfWorkLimit = CBigNum(~uint256(0) >> 20);
            nSubsidyHalvingInterval = 770000;

            // Build the genesis block. Note that the output of the genesis coinbase cannot
            // be spent as it did not originally exist in the database.
            //

        const char* pszTimestamp = "Dec 2013 light speed X-day";
        CTransaction txNew;
        txNew.vin.resize(1);
        txNew.vout.resize(1);
        txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
        txNew.vout[0].nValue = 1 * COIN;
        txNew.vout[0].scriptPubKey = CScript() << ParseHex("") << OP_CHECKSIG;
        genesis.vtx.push_back(txNew);
        genesis.hashPrevBlock = 0;
        genesis.hashMerkleRoot = genesis.BuildMerkleTree();
        genesis.nVersion = 1;
        genesis.nTime    = 1389429187;
        genesis.nBits    = 0x1e0fffff; //chimark
        genesis.nNonce   = 1030111;
        hashGenesisBlock = genesis.GetHash();

        //// debug print
        //while (hashGenesisBlock > bnProofOfWorkLimit.getuint256()){
        //    if (++genesis.nNonce==0) break;
        //   hashGenesisBlock = genesis.GetHash();
        //}

        printf("%s\n", hashGenesisBlock.ToString().c_str());
        printf("%s\n", genesis.hashMerkleRoot.ToString().c_str());
        printf("%x\n", bnProofOfWorkLimit.GetCompact());
        genesis.print();
        
        
        assert(hashGenesisBlock == uint256("0x00000a8f9572e068cffbdb30c23f698e659e1e2e13e51cfcb8114fa5df38ffee"));
        assert(genesis.hashMerkleRoot == uint256("0x91c7edee50dd32d8544412f4cef06f8812723eefe8fec24fd3e66d92f83b1b9e"));

        vSeeds.push_back(CDNSSeedData("chicoin.sipa.be", "seed.chicoin.sipa.be"));
        vSeeds.push_back(CDNSSeedData("bluematt.me", "dnsseed.bluematt.me"));
        vSeeds.push_back(CDNSSeedData("dashjr.org", "dnsseed.chicoin.dashjr.org"));
        vSeeds.push_back(CDNSSeedData("xf2.org", "bitseed.xf2.org"));

        base58Prefixes[PUBKEY_ADDRESS] = 27;
        base58Prefixes[SCRIPT_ADDRESS] = 29;
        base58Prefixes[SECRET_KEY] =     127;


        // Convert the pnSeeds array into usable address objects.
        for (unsigned int i = 0; i < ARRAYLEN(pnSeed); i++)
        {
            // It'll only connect to one or two seed nodes because once it connects,
            // it'll get a pile of addresses with newer timestamps.
            // Seed nodes are given a random 'last seen time' 
            const int64 nTwoDays = 2 * 24 * 60 * 60;
            struct in_addr ip;
            memcpy(&ip, &pnSeed[i], sizeof(ip));
            CAddress addr(CService(ip, GetDefaultPort()));
            addr.nTime = GetTime() - GetRand(nTwoDays) - nTwoDays;
            vFixedSeeds.push_back(addr);
        }
    }
Пример #6
0
    CMainParams() {
        // The message start string is designed to be unlikely to occur in normal data.
        pchMessageStart[0] = 0xf8;
        pchMessageStart[1] = 0xb5;
        pchMessageStart[2] = 0x03;
        pchMessageStart[3] = 0xdf;
        vAlertPubKey = ParseHex("04f09702847840aaf195de8442ebecedf5b095cdbb9bc716bda9110971b28a49e0ead8564ff0db22209e0374782c093bb899692d524e9d6a6956e7c5ecbcd68284");
        nDefaultPort = 12835;
        nRPCPort = 12832;
        bnProofOfWorkLimit = CBigNum(~uint256(0) >> 20);
        nSubsidyHalvingInterval = 950000;

        // Build the genesis block. Note that the output of the genesis coinbase cannot
        // be spent as it did not originally exist in the database.

        const char* pszTimestamp = "February 5, 2014: The Black Hills are not for sale - 1868 Is The LAW!";
        CTransaction txNew;
        txNew.vin.resize(1);
        txNew.vout.resize(1);
        txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
        txNew.vout[0].nValue = 5000 * COIN;
        txNew.vout[0].scriptPubKey = CScript() << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG;
        genesis.vtx.push_back(txNew);
        genesis.hashPrevBlock = 0;
        genesis.hashMerkleRoot = genesis.BuildMerkleTree();
        genesis.nVersion = 1;
        genesis.nTime    = 1390747675;
        genesis.nBits    = 0x1e0ffff0;
        genesis.nNonce   = 2091390249;

        //// debug print
        hashGenesisBlock = genesis.GetHash();
        //while (hashGenesisBlock > bnProofOfWorkLimit.getuint256()){
        //   if (++genesis.nNonce==0) break;
        //    hashGenesisBlock = genesis.GetHash();
        //}

        //printf("%s\n", hashGenesisBlock.ToString().c_str());
        //printf("%s\n", genesis.hashMerkleRoot.ToString().c_str());
        //printf("%x\n", bnProofOfWorkLimit.GetCompact());
        //genesis.print();


        assert(hashGenesisBlock == uint256("0x00000c7c73d8ce604178dae13f0fc6ec0be3275614366d44b1b4b5c6e238c60c"));
        assert(genesis.hashMerkleRoot == uint256("0x62d496378e5834989dd9594cfc168dbb76f84a39bbda18286cddc7d1d1589f4f"));

        vSeeds.push_back(CDNSSeedData("node.Maza.org", "node.Maza.org"));
        vSeeds.push_back(CDNSSeedData("node.Maza.cf", "node.Maza.cf"));
        vSeeds.push_back(CDNSSeedData("Maza.no-ip.org", "Maza.no-ip.org"));

        base58Prefixes[PUBKEY_ADDRESS] = 50;
        base58Prefixes[SCRIPT_ADDRESS] = 9;
        base58Prefixes[SECRET_KEY] = 224;

        // Convert the pnSeeds array into usable address objects.
        for (unsigned int i = 0; i < ARRAYLEN(pnSeed); i++)
        {
            // It'll only connect to one or two seed nodes because once it connects,
            // it'll get a pile of addresses with newer timestamps.
            // Seed nodes are given a random 'last seen time'
            const int64 nTwoDays = 2 * 24 * 60 * 60;
            struct in_addr ip;
            memcpy(&ip, &pnSeed[i], sizeof(ip));
            CAddress addr(CService(ip, GetDefaultPort()));
            addr.nTime = GetTime() - GetRand(nTwoDays) - nTwoDays;
            vFixedSeeds.push_back(addr);
        }
    }
Пример #7
0
    CMainParams() {
        // The message start string is designed to be unlikely to occur in normal data.
        pchMessageStart[0] = 0x06;
        pchMessageStart[1] = 0x03;
        pchMessageStart[2] = 0x04;
        pchMessageStart[3] = 0x01;
        nDefaultPort = 2222; //Ring was forged in the second age
        nRPCPort = 2223; //Ring was forged in the second age.
        bnProofOfWorkLimit = CBigNum(~uint256(0) >> 20);
        nSubsidyHalvingInterval = 500000;

        // Build the genesis block. Note that the output of the genesis coinbase cannot
        // be spent as it did not originally exist in the database.
  
        const char* pszTimestamp = "Sauron says hello.";
        CTransaction txNew;
        txNew.vin.resize(1);
        txNew.vout.resize(1);
        txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
        txNew.vout[0].nValue = 1 * COIN;
        txNew.vout[0].scriptPubKey = CScript() << ParseHex("") << OP_CHECKSIG;
        genesis.vtx.push_back(txNew);
        genesis.hashPrevBlock = 0;
        genesis.hashMerkleRoot = genesis.BuildMerkleTree();
        genesis.nVersion = 1;
        genesis.nTime    = 1386541846;
        genesis.nBits    = 0x1e0fffff;
        genesis.nNonce   = 0;
        
        //// debug print
        hashGenesisBlock = genesis.GetHash();
        while (hashGenesisBlock > bnProofOfWorkLimit.getuint256()){
            if (++genesis.nNonce==0) break;
            hashGenesisBlock = genesis.GetHash();
        }

        printf("%s\n", hashGenesisBlock.ToString().c_str());
        printf("%s\n", genesis.hashMerkleRoot.ToString().c_str());
        printf("%x\n", bnProofOfWorkLimit.GetCompact());
        genesis.print();
        
        
        assert(hashGenesisBlock == uint256("0x"));
        assert(genesis.hashMerkleRoot == uint256("0x"));

        vSeeds.push_back(CDNSSeedData("someaddress.com or IP addy", "someaddress.com"));


        base58Prefixes[PUBKEY_ADDRESS] = 63;
        base58Prefixes[SCRIPT_ADDRESS] = 30;
        base58Prefixes[SECRET_KEY] = 224;

        // Convert the pnSeeds array into usable address objects.
        for (unsigned int i = 0; i < ARRAYLEN(pnSeed); i++)
        {
            // It'll only connect to one or two seed nodes because once it connects,
            // it'll get a pile of addresses with newer timestamps.
            // Seed nodes are given a random 'last seen time' 
            const int64 nTwoDays = 2 * 24 * 60 * 60;
            struct in_addr ip;
            memcpy(&ip, &pnSeed[i], sizeof(ip));
            CAddress addr(CService(ip, GetDefaultPort()));
            addr.nTime = GetTime() - GetRand(nTwoDays) - nTwoDays;
            vFixedSeeds.push_back(addr);
        }
    }
Пример #8
0
TestingSetup::TestingSetup(const std::string& chainName) : BasicTestingSetup(chainName)
{
    const CChainParams& chainparams = Params();
        // Ideally we'd move all the RPC tests to the functional testing framework
        // instead of unit tests, but for now we need these here.

        RegisterAllCoreRPCCommands(tableRPC);
        ClearDatadirCache();
        pathTemp = GetTempPath() / strprintf("test_bitcoin_%lu_%i", (unsigned long)GetTime(), (int)(GetRand(100000)));
        boost::filesystem::create_directories(pathTemp);
        mapArgs["-datadir"] = pathTemp.string();
        mempool.setSanityCheck(1.0);
        pblocktree = new CBlockTreeDB(1 << 20, true);
        pcoinsdbview = new CCoinsViewDB(1 << 23, true);
        pcoinsTip = new CCoinsViewCache(pcoinsdbview);
        InitBlockIndex(chainparams);
        {
            CValidationState state;
            bool ok = ActivateBestChain(state, chainparams);
            BOOST_CHECK(ok);
        }
        nScriptCheckThreads = 3;
        for (int i=0; i < nScriptCheckThreads-1; i++)
            threadGroup.create_thread(&ThreadScriptCheck);
        g_connman = std::unique_ptr<CConnman>(new CConnman(0x1337, 0x1337)); // Deterministic randomness for tests.
        connman = g_connman.get();
        RegisterNodeSignals(GetNodeSignals());
}
Пример #9
0
void CTxMemPool::check(const CCoinsViewCache *pcoins) const
{
    LOCK(cs);
    if (nCheckFrequency == 0)
        return;

    if (GetRand(std::numeric_limits<uint32_t>::max()) >= nCheckFrequency)
        return;

    LogPrint(BCLog::MEMPOOL, "Checking mempool with %u transactions and %u inputs\n", (unsigned int)mapTx.size(), (unsigned int)mapNextTx.size());

    uint64_t checkTotal = 0;
    uint64_t innerUsage = 0;

    CCoinsViewCache mempoolDuplicate(const_cast<CCoinsViewCache*>(pcoins));
    const int64_t spendheight = GetSpendHeight(mempoolDuplicate);

    std::list<const CTxMemPoolEntry*> waitingOnDependants;
    for (indexed_transaction_set::const_iterator it = mapTx.begin(); it != mapTx.end(); it++) {
        unsigned int i = 0;
        checkTotal += it->GetTxSize();
        innerUsage += it->DynamicMemoryUsage();
        const CTransaction& tx = it->GetTx();
        txlinksMap::const_iterator linksiter = mapLinks.find(it);
        assert(linksiter != mapLinks.end());
        const TxLinks &links = linksiter->second;
        innerUsage += memusage::DynamicUsage(links.parents) + memusage::DynamicUsage(links.children);
        bool fDependsWait = false;
        setEntries setParentCheck;
        int64_t parentSizes = 0;
        int64_t parentSigOpCost = 0;
        for (const CTxIn &txin : tx.vin) {
            // Check that every mempool transaction's inputs refer to available coins, or other mempool tx's.
            indexed_transaction_set::const_iterator it2 = mapTx.find(txin.prevout.hash);
            if (it2 != mapTx.end()) {
                const CTransaction& tx2 = it2->GetTx();
                assert(tx2.vout.size() > txin.prevout.n && !tx2.vout[txin.prevout.n].IsNull());
                fDependsWait = true;
                if (setParentCheck.insert(it2).second) {
                    parentSizes += it2->GetTxSize();
                    parentSigOpCost += it2->GetSigOpCost();
                }
            } else {
                assert(pcoins->HaveCoin(txin.prevout));
            }
            // Check whether its inputs are marked in mapNextTx.
            auto it3 = mapNextTx.find(txin.prevout);
            assert(it3 != mapNextTx.end());
            assert(it3->first == &txin.prevout);
            assert(it3->second == &tx);
            i++;
        }
        assert(setParentCheck == GetMemPoolParents(it));
        // Verify ancestor state is correct.
        setEntries setAncestors;
        uint64_t nNoLimit = std::numeric_limits<uint64_t>::max();
        std::string dummy;
        CalculateMemPoolAncestors(*it, setAncestors, nNoLimit, nNoLimit, nNoLimit, nNoLimit, dummy);
        uint64_t nCountCheck = setAncestors.size() + 1;
        uint64_t nSizeCheck = it->GetTxSize();
        CAmount nFeesCheck = it->GetModifiedFee();
        int64_t nSigOpCheck = it->GetSigOpCost();

        for (txiter ancestorIt : setAncestors) {
            nSizeCheck += ancestorIt->GetTxSize();
            nFeesCheck += ancestorIt->GetModifiedFee();
            nSigOpCheck += ancestorIt->GetSigOpCost();
        }

        assert(it->GetCountWithAncestors() == nCountCheck);
        assert(it->GetSizeWithAncestors() == nSizeCheck);
        assert(it->GetSigOpCostWithAncestors() == nSigOpCheck);
        assert(it->GetModFeesWithAncestors() == nFeesCheck);

        // Check children against mapNextTx
        CTxMemPool::setEntries setChildrenCheck;
        auto iter = mapNextTx.lower_bound(COutPoint(it->GetTx().GetHash(), 0));
        int64_t childSizes = 0;
        for (; iter != mapNextTx.end() && iter->first->hash == it->GetTx().GetHash(); ++iter) {
            txiter childit = mapTx.find(iter->second->GetHash());
            assert(childit != mapTx.end()); // mapNextTx points to in-mempool transactions
            if (setChildrenCheck.insert(childit).second) {
                childSizes += childit->GetTxSize();
            }
        }
        assert(setChildrenCheck == GetMemPoolChildren(it));
        // Also check to make sure size is greater than sum with immediate children.
        // just a sanity check, not definitive that this calc is correct...
        assert(it->GetSizeWithDescendants() >= childSizes + it->GetTxSize());

        if (fDependsWait)
            waitingOnDependants.push_back(&(*it));
        else {
            CheckInputsAndUpdateCoins(tx, mempoolDuplicate, spendheight);
        }
    }
    unsigned int stepsSinceLastRemove = 0;
    while (!waitingOnDependants.empty()) {
        const CTxMemPoolEntry* entry = waitingOnDependants.front();
        waitingOnDependants.pop_front();
        CValidationState state;
        if (!mempoolDuplicate.HaveInputs(entry->GetTx())) {
            waitingOnDependants.push_back(entry);
            stepsSinceLastRemove++;
            assert(stepsSinceLastRemove < waitingOnDependants.size());
        } else {
            CheckInputsAndUpdateCoins(entry->GetTx(), mempoolDuplicate, spendheight);
            stepsSinceLastRemove = 0;
        }
    }
    for (auto it = mapNextTx.cbegin(); it != mapNextTx.cend(); it++) {
        uint256 hash = it->second->GetHash();
        indexed_transaction_set::const_iterator it2 = mapTx.find(hash);
        const CTransaction& tx = it2->GetTx();
        assert(it2 != mapTx.end());
        assert(&tx == it->second);
    }

    assert(totalTxSize == checkTotal);
    assert(innerUsage == cachedInnerUsage);
}
Пример #10
0
void Scene_TestDangeon::Debug_ClearStage1(){
	DWORD prevID = 0;
	DOLL_ID dollID = DOLL_ID(0, 0);
	dollID._aliceID = gr_others.GetAliceID();
	// 人形を全て削除
	r_aliceDoll.DeleteAllDolls();
	g_dollList.RefreshAllDolls(&r_aliceDoll, &r_aliceInfo);
	g_temp.isUnitedDoll = false;
	// プリセットの人形を追加
	for(int n=0; n<10; n++){
		switch(n){
		case 0:
			g_temp.SetDroppedDoll(13, 100);
			g_temp.SetDollName(_T("シアン"));
			break;
		case 1:
			g_temp.SetDroppedDoll(14, 75);
			g_temp.SetDollName(_T("マゼンタ"));
			break;
		case 2:
			g_temp.SetDroppedDoll(15, 75);
			g_temp.SetDollName(_T("イエロー"));
			break;
		case 7:
			g_temp.SetDroppedDoll(7, 60);
			g_temp.SetDollName(_T("サン"));
			break;
		case 8:
			g_temp.SetDroppedDoll(8, 60);
			g_temp.SetDollName(_T("ムーン"));
			break;
		case 9:
			g_temp.SetDroppedDoll(9, 60);
			g_temp.SetDollName(_T("スター"));
			break;
		default:
			g_temp.SetDroppedDoll(60+GetRand(79), GetRand(40));
			switch(n){
			case 3:
				g_temp.SetDollName(_T("イズ"));
				break;
			case 4:
				g_temp.SetDollName(_T("ウェスタ"));
				break;
			case 5:
				g_temp.SetDollName(_T("ノルス"));
				break;
			case 6:
				g_temp.SetDollName(_T("サウジー"));
				break;
			}
			break;
		}
		g_dollList.AddDoll(g_temp.dollData.GetDataPtr(), true, true, &r_aliceInfo);
		prevID = gr_others.GetNextDollID() - 1;
		dollID._id = prevID;
		if(n < MAX_BATTLEDOLL){
			r_aliceInfo.SetBattleDollID(n, dollID);
		}
	}
	// チュートリアルのクリアボーナスの追加
	// ExecuteMapClearBonus(NUM_TESTDANGEON_TUTORIAL);
	// 終了
	g_dollList.ReflectAllDollsToRecord();
	// 時間経過
	r_aliceInfo.ResetTime();
	r_aliceInfo.AddTime(15);
}
float mmrand(int  min, int max, float divisor)
{
	return ((float)GetRand(min, max)) / divisor;
};
Пример #12
0
void Scene_TestDangeon::Debug_ClearStage6(){
	DWORD prevID = 0;
	DOLL_ID dollID = DOLL_ID(0, 0);
	dollID._aliceID = gr_others.GetAliceID();
	// 人形を全て削除
	r_aliceDoll.DeleteAllDolls();
	g_dollList.RefreshAllDolls(&r_aliceDoll, &r_aliceInfo);
	g_temp.isUnitedDoll = false;
	// プリセットの人形を追加
	for(int n=0; n<13; n++){
		switch(n){
		case 0:
			g_temp.SetDroppedDoll(25, 800);
			g_temp.SetDollName(_T("モノ"));
			break;
		case 1:
			g_temp.SetDroppedDoll(26, 800);
			g_temp.SetDollName(_T("ディー"));
			break;
		case 2:
			g_temp.SetDroppedDoll(27, 800);
			g_temp.SetDollName(_T("トライ"));
			break;
		case 3:
			g_temp.SetDroppedDoll(28, 800);
			g_temp.SetDollName(_T("テトラ"));
			break;
		case 4:
			g_temp.SetDroppedDoll(29, 800);
			g_temp.SetDollName(_T("ペンタ"));
			break;
		case 5:
			g_temp.SetDroppedDoll(30, 800);
			g_temp.SetDollName(_T("ヘキサ"));
			break;
		case 6:
			g_temp.SetDroppedDoll(22, 800);
			g_temp.SetDollName(_T("アン"));
			break;
		case 7:
			g_temp.SetDroppedDoll(23, 800);
			g_temp.SetDollName(_T("ドゥ"));
			break;
		case 8:
			g_temp.SetDroppedDoll(24, 800);
			g_temp.SetDollName(_T("トロワ"));
			break;
		default:
			g_temp.SetDroppedDoll(200+GetRand(19), 80+GetRand(80));
			switch(n){
			case 9:
				g_temp.SetDollName(_T("イズ"));
				break;
			case 10:
				g_temp.SetDollName(_T("ウェスタ"));
				break;
			case 11:
				g_temp.SetDollName(_T("ノルス"));
				break;
			case 12:
				g_temp.SetDollName(_T("サウジー"));
				break;
			}
			break;
		}
		g_dollList.AddDoll(g_temp.dollData.GetDataPtr(), true, true, &r_aliceInfo);
		prevID = gr_others.GetNextDollID() - 1;
		dollID._id = prevID;
		if(n < MAX_BATTLEDOLL){
			r_aliceInfo.SetBattleDollID(n, dollID);
		}
	}
	// チュートリアルのクリアボーナスの追加
	// ExecuteMapClearBonus(NUM_TESTDANGEON_TUTORIAL);
	// 終了
	g_dollList.ReflectAllDollsToRecord();
	// 時間経過
	r_aliceInfo.ResetTime();
	r_aliceInfo.AddTime(24);
}
Пример #13
0
/**********************************************************
	AIの行動を返す関数
**********************************************************/
Action aiSample(int view[2*VISIBLE+1][2*VISIBLE+1])
{
	int r;
	int danger=0;
	double direct;
	double  PI=3.141592;
	int tx,ty;

	for(int i=0;i<2*VISIBLE+1;i++){
		for(int j=0;j<2*VISIBLE+1;j++){
			if(view[i][j]==3){
				tx=i;
				ty=j;
				danger=1;
				int dx=tx-CENTER;
				int dy=ty-CENTER;
				if(dx==0){
					if(dy>=0){
						direct=90;
					}else{
						direct=-90;
					}
				}else{
					double t=dy/dx;
					if(dx>0){
						direct=atan(t)/PI*180;
					}
					else{
						direct=atan(t)/PI*180+180;
					}
				}
			}
		}
	}
	if(danger==0){	
		int r=GetRand(4);
		switch(r%4){
		case 0:
			if(view[CENTER][CENTER-1]!=1)
			return N;
			break;
		case 1:
			if(view[CENTER+1][CENTER]!=1)
			return E;
			break;
		case 2:
			if(view[CENTER][CENTER+1]!=1)
			return S;
			break;
		case 3:
			if(view[CENTER-1][CENTER]!=1)
			return W;
			break;
		}
	}else{
		if(direct<-45 || direct>=225){
			if(view[CENTER][CENTER+1]!=1)
				return S;
			else{
				if(view[CENTER+1][CENTER]!=1){
					return E;
				}else if(view[CENTER-1][CENTER]!=1){
					return W;
				}else{
					return N;
				}
			}
		}
		else if(direct<45){
			if(view[CENTER-1][CENTER]!=1)
				return W;
			else{
				if(view[CENTER][CENTER-1]!=1){
					return N;
				}else if(view[CENTER][CENTER+1]!=1){
					return S;
				}else{
					return E;
				}
			}
		}else if(direct<135){
			if(view[CENTER][CENTER-1]!=1)
				return N;
			else{
				if(view[CENTER-1][CENTER]!=1){
					return W;
				}else if(view[CENTER+1][CENTER]!=1){
					return E;
				}else{
					return S;
				}
			}
		}
		else if(direct<225){
			if(view[CENTER+1][CENTER]!=1)
				return E;
			else{
				if(view[CENTER][CENTER-1]!=1){
					return N;
				}else if(view[CENTER][CENTER+1]!=1){
					return S;
				}else{
					return W;
				}
			}
		}
		return STOP;
	}
}
Пример #14
0
int GetRandInt(int nMax)
{
    return GetRand(nMax);
}
Пример #15
0
    CMainParams() {
        // The message start string is designed to be unlikely to occur in normal data.
        pchMessageStart[0] = 0x55;
        pchMessageStart[1] = 0x42;
        pchMessageStart[2] = 0x4B;
        pchMessageStart[3] = 0x45;
        nDefaultPort = 11066;
        nRPCPort = 11067;
        bnProofOfWorkLimit = CBigNum(~uint256(0) >> 20);
        nSubsidyHalvingInterval = 100000;

        // Build the genesis block. Note that the output of the genesis coinbase cannot
        // be spent as it did not originally exist in the database.
  
        const char* pszTimestamp = "Viking Era";
        CTransaction txNew;
        txNew.vin.resize(1);
        txNew.vout.resize(1);
        txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
        txNew.vout[0].nValue = 0.001 * COIN;
        txNew.vout[0].scriptPubKey = CScript() << ParseHex("") << OP_CHECKSIG;
        genesis.vtx.push_back(txNew);
        genesis.hashPrevBlock = 0;
        genesis.hashMerkleRoot = genesis.BuildMerkleTree();
        genesis.nVersion = 1;
        genesis.nTime    = 1400630400; //nTime
        genesis.nBits    = 0x1e0fffff;
        genesis.nNonce   = 2016973;
        
        hashGenesisBlock = genesis.GetHash();
        // while (hashGenesisBlock > bnProofOfWorkLimit.getuint256()){
        //     if (++genesis.nNonce==0) break;
        //     hashGenesisBlock = genesis.GetHash();
        //}


        printf("%s\n", hashGenesisBlock.ToString().c_str());
        printf("%s\n", genesis.hashMerkleRoot.ToString().c_str());
        printf("%x\n", bnProofOfWorkLimit.GetCompact());
        genesis.print();
        
        
        assert(hashGenesisBlock == uint256("0x00000c07c30a4f74683e64ed156668e3f8d2e71bb4efcdcc44c248708d1cabf2"));
        assert(genesis.hashMerkleRoot == uint256("0xb8b26c88ea01ea6cbbd9fd39158f1e6cae130cc2cd5950b78727d83aa71c056d"));

        vSeeds.push_back(CDNSSeedData("198.46.134.15", "192.3.10.93"));
		vSeeds.push_back(CDNSSeedData("95.85.46.218", "81.11.246.44"));
        vSeeds.push_back(CDNSSeedData("108.61.10.90", "192.241.199.243"));
   

        base58Prefixes[PUBKEY_ADDRESS] = 70;
        base58Prefixes[SCRIPT_ADDRESS] = 132;
        base58Prefixes[SECRET_KEY] = 86;

        // Convert the pnSeeds array into usable address objects.
        for (unsigned int i = 0; i < ARRAYLEN(pnSeed); i++)
        {
            // It'll only connect to one or two seed nodes because once it connects,
            // it'll get a pile of addresses with newer timestamps.
            // Seed nodes are given a random 'last seen time' 
            const int64 nTwoDays = 2 * 24 * 60 * 60;
            struct in_addr ip;
            memcpy(&ip, &pnSeed[i], sizeof(ip));
            CAddress addr(CService(ip, GetDefaultPort()));
            addr.nTime = GetTime() - GetRand(nTwoDays) - nTwoDays;
            vFixedSeeds.push_back(addr);
        }
    }
Пример #16
0
    CMainParams() {
        // The message start string is designed to be unlikely to occur in normal data.
        pchMessageStart[0] = 0x66;
        pchMessageStart[1] = 0x66;
        pchMessageStart[2] = 0x66;
        pchMessageStart[3] = 0x66;
        nDefaultPort = 24242;
        nRPCPort = 24243;
        bnProofOfWorkLimit = CBigNum(~uint256(0) >> 20);
        nSubsidyHalvingInterval = 35040000;

        // Build the genesis block. Note that the output of the genesis coinbase cannot
        // be spent as it did not originally exist in the database.
  
        const char* pszTimestamp = "Release the Kraken - www.krakencoin.com";
        CTransaction txNew;
        txNew.vin.resize(1);
        txNew.vout.resize(1);
        txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
        txNew.vout[0].nValue = 1 * COIN;
        txNewvout1nValue = 5;
        txNewvout2nValue = 450000 * COIN;
        txNew.vout[0].scriptPubKey = CScript() << ParseHex("") << OP_CHECKSIG;
        genesis.vtx.push_back(txNew);
        genesis.hashPrevBlock = 0;
        genesis.hashMerkleRoot = genesis.BuildMerkleTree();
        genesis.nVersion = 1;
        genesis.nTime    = 1394270601;
        genesis.nBits    = 0x1e0fffff;
        genesis.nNonce   = 943874;
        
        //// debug print
        hashGenesisBlock = genesis.GetHash();
        //while (hashGenesisBlock > bnProofOfWorkLimit.getuint256()){
          //  if (++genesis.nNonce==0) break;
            //hashGenesisBlock = genesis.GetHash();
        //}

        printf("%s\n", hashGenesisBlock.ToString().c_str());
        printf("%s\n", genesis.hashMerkleRoot.ToString().c_str());
        printf("%x\n", bnProofOfWorkLimit.GetCompact());
        genesis.print();
        
        
        assert(hashGenesisBlock == uint256("0x00000e9d058285796d9d49c3110a98c9367d25b7ab82cab06088f29ff4160b2a"));
        assert(genesis.hashMerkleRoot == uint256("0x67cf79c130dc3b7f3a164ffde6d4ff3b30fb3847e649e5ab8c889cbcba8db40d"));

        vSeeds.push_back(CDNSSeedData("162.243.90.199", "162.243.90.199"));


        base58Prefixes[PUBKEY_ADDRESS] = 45;
        base58Prefixes[SCRIPT_ADDRESS] = 30;
        base58Prefixes[SECRET_KEY] = 224;

        // Convert the pnSeeds array into usable address objects.
        for (unsigned int i = 0; i < ARRAYLEN(pnSeed); i++)
        {
            // It'll only connect to one or two seed nodes because once it connects,
            // it'll get a pile of addresses with newer timestamps.
            // Seed nodes are given a random 'last seen time' 
            const int64 nTwoDays = 2 * 24 * 60 * 60;
            struct in_addr ip;
            memcpy(&ip, &pnSeed[i], sizeof(ip));
            CAddress addr(CService(ip, GetDefaultPort()));
            addr.nTime = GetTime() - GetRand(nTwoDays) - nTwoDays;
            vFixedSeeds.push_back(addr);
        }
    }
Пример #17
0
Enemy_Test::Enemy_Test(vector<Enemy*>* enemyList) :Enemy(enemyList, imageAsset_Enemy_Test){
	Vec2 pos					= Vec2::Setup((float)GetRand(Window::WIDTH), (float)GetRand(Window::HEIGHT));
	CharacterInformation prm	= CharacterInformation::Setup(2, 0, 1, 30, 2, 32);
	SetupData(pos, prm);
	Initialize();
}
Пример #18
0
SaltedTxidHasher::SaltedTxidHasher() : k0(GetRand(std::numeric_limits<uint64_t>::max())), k1(GetRand(std::numeric_limits<uint64_t>::max())) {}
Пример #19
0
unsigned int scanhash_scrypt(
                            block_header *pdata,
                            ::uint32_t max_nonce, 
                            ::uint32_t &hash_count,
                            void *result, 
                            block_header *res_header, 
                            unsigned char Nfactor
                            , CBlockIndex *pindexPrev
                            , uint256 *phashTarget
                            )
{
    hash_count = 0;
    const ::uint32_t
        nArbitraryHashCount = 70;
    block_header 
        data = *pdata;
    ::uint32_t 
        hash[8];
    unsigned char 
        *hashc = (unsigned char *) &hash;
    ::uint32_t  // really any random uint32_t
        n = (::uint32_t)GetRand( (::uint64_t)UINT_MAX );
    while (true) 
    {
        if( UINT_MAX == n ) // not allowed as a nonce
        {
            ++n;
        }
        data.nonce = n;

        scrypt(
               (const unsigned char*)&data, 
               80,
               (const unsigned char*)&data, 
               80,
               Nfactor, 
               0, 
               0, 
               (unsigned char*)hash, 
               32
              );
        ++hash_count;
        if (
            (   0 == (        hashc[31]))
            && (0 == ( 0xfe & hashc[30]))
            && (0 == ( 0xc0 & hashc[29]))
           ) 
        {
            memcpy(result, hash, 32);
            return data.nonce;
        }
        if( 0 == (hash_count % nArbitraryHashCount) )
        {   // really we should hash for a while, then check
            if (
                (pindexPrev != pindexBest) ||
                fShutdown
               )
                break;
        }
        ++n;
    }
    return UINT_MAX;
}
Пример #20
0
    CMainParams() {
        // The message start string is designed to be unlikely to occur in normal data.
        pchMessageStart[0] = 0x09;
        pchMessageStart[1] = 0x04;
        pchMessageStart[2] = 0x04;
        pchMessageStart[3] = 0x05;
        nDefaultPort = 7777;
        nRPCPort = 7070;
        bnProofOfWorkLimit = CBigNum(~uint256(0) >> 20);
        nSubsidyHalvingInterval = 250000;

        // Build the genesis block. Note that the output of the genesis coinbase cannot
        // be spent as it did not originally exist in the database.

        const char* pszTimestamp = "Pump dump sell buy hold but when you hear the thunder be ready bc it will be showtimeee";
        CTransaction txNew;
        txNew.vin.resize(1);
        txNew.vout.resize(1);
        txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
        txNew.vout[0].nValue = 1 * COIN;
        txNew.vout[0].scriptPubKey = CScript() << ParseHex("") << OP_CHECKSIG;
        genesis.vtx.push_back(txNew);
        genesis.hashPrevBlock = 0;
        genesis.hashMerkleRoot = genesis.BuildMerkleTree();
        genesis.nVersion = 1;
        genesis.nTime    = 1387754247;
        genesis.nBits    = 0x1e0fffff;
        genesis.nNonce   = 416023;

        //// debug print
        hashGenesisBlock = genesis.GetHash();
        while (hashGenesisBlock > bnProofOfWorkLimit.getuint256()){
            if (++genesis.nNonce==0) break;
            hashGenesisBlock = genesis.GetHash();
        }

        printf("%s\n", hashGenesisBlock.ToString().c_str());
        printf("%s\n", genesis.hashMerkleRoot.ToString().c_str());
        printf("%x\n", bnProofOfWorkLimit.GetCompact());
        genesis.print();


        assert(hashGenesisBlock == uint256("0x00000a26ae3a3e42c19266cdcb6c1705c644f6e12eff14ed69384ae9415f555d"));
        assert(genesis.hashMerkleRoot == uint256("0xcbe518469ca4a98504a704913d2e3b4c0a131c8734a21aa8e56f879071e5c3fc"));

        vSeeds.push_back(CDNSSeedData("70.193.4.56", "70.193.4.56"));


        base58Prefixes[PUBKEY_ADDRESS] = 127;
        base58Prefixes[SCRIPT_ADDRESS] = 30;
        base58Prefixes[SECRET_KEY] = 224;

        // Convert the pnSeeds array into usable address objects.
        for (unsigned int i = 0; i < ARRAYLEN(pnSeed); i++)
        {
            // It'll only connect to one or two seed nodes because once it connects,
            // it'll get a pile of addresses with newer timestamps.
            // Seed nodes are given a random 'last seen time'
            const int64 nTwoDays = 2 * 24 * 60 * 60;
            struct in_addr ip;
            memcpy(&ip, &pnSeed[i], sizeof(ip));
            CAddress addr(CService(ip, GetDefaultPort()));
            addr.nTime = GetTime() - GetRand(nTwoDays) - nTwoDays;
            vFixedSeeds.push_back(addr);
        }
    }
Пример #21
0
    CMainParams() {
        // The message start string is designed to be unlikely to occur in normal data.
        pchMessageStart[0] = 0x03;
        pchMessageStart[1] = 0xd5;
        pchMessageStart[2] = 0xb5;
        pchMessageStart[3] = 0x03;
        nDefaultPort = 65534;
        nRPCPort = 65535;
        bnProofOfWorkLimit = CBigNum(~uint256(0) >> 20);
        nSubsidyHalvingInterval = 100000;

        // Build the genesis block. Note that the output of the genesis coinbase cannot
        // be spent as it did not originally exist in the database.
  
        const char* pszTimestamp = "San Francisco plaza evacuated after suspicious package is found";
        CTransaction txNew;
        txNew.vin.resize(1);
        txNew.vout.resize(1);
        txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
        txNew.vout[0].nValue = 1 * COIN;
        txNew.vout[0].scriptPubKey = CScript() << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG;
        genesis.vtx.push_back(txNew);
        genesis.hashPrevBlock = 0;
        genesis.hashMerkleRoot = genesis.BuildMerkleTree();
        genesis.nVersion = 1;
        genesis.nTime    = 1375548986;
        genesis.nBits    = 0x1e0fffff;
        genesis.nNonce   = 1211565;
        
        //// debug print
        hashGenesisBlock = genesis.GetHash();
        //while (hashGenesisBlock > bnProofOfWorkLimit.getuint256()){
        //    if (++genesis.nNonce==0) break;
        //    hashGenesisBlock = genesis.GetHash();
        //}

        printf("%s\n", hashGenesisBlock.ToString().c_str());
        printf("%s\n", genesis.hashMerkleRoot.ToString().c_str());
        printf("%x\n", bnProofOfWorkLimit.GetCompact());
        genesis.print();
        
        
        assert(hashGenesisBlock == uint256("0x000004c2fc5fffb810dccc197d603690099a68305232e552d96ccbe8e2c52b75"));
        assert(genesis.hashMerkleRoot == uint256("0x36a192e90f70131a884fe541a1e8a5643a28ba4cb24cbb2924bd0ee483f7f484"));

        vSeeds.push_back(CDNSSeedData("andarazoroflove.org", "andarazoroflove.org"));
        vSeeds.push_back(CDNSSeedData("rockchain.info", "rockchain.info"));

        base58Prefixes[PUBKEY_ADDRESS] = 130;
        base58Prefixes[SCRIPT_ADDRESS] = 30;
        base58Prefixes[SECRET_KEY] = 224;

        // Convert the pnSeeds array into usable address objects.
        for (unsigned int i = 0; i < ARRAYLEN(pnSeed); i++)
        {
            // It'll only connect to one or two seed nodes because once it connects,
            // it'll get a pile of addresses with newer timestamps.
            // Seed nodes are given a random 'last seen time' 
            const int64 nTwoDays = 2 * 24 * 60 * 60;
            struct in_addr ip;
            memcpy(&ip, &pnSeed[i], sizeof(ip));
            CAddress addr(CService(ip, GetDefaultPort()));
            addr.nTime = GetTime() - GetRand(nTwoDays) - nTwoDays;
            vFixedSeeds.push_back(addr);
        }
    }
Пример #22
0
//==============================================================
// 区画を分ける
//==============================================================
void CDunHard::SplitRect(int nParentRectIndex, int nFlagHV)
{
	DUNRECT *pParent, *pChild;
	RECT *pRect;
	int nChildIndex1 = 0, nChildIndex2 = 0;

	// わける区画情報を取得
	pParent = &m_Rect[nParentRectIndex];
	pRect   = &pParent->Rect;

	//---------
	// 分割する
	//---------
	if((nFlagHV & 1) == 0) {
		// 横に分割する
		nFlagHV |= 1;

		// 区分を分割できるか?チェック
		if(RECT_W(*pRect) >= (MIN_ROOM_SIZE + 3) * 2 + 1) {
			int a, b, ab, p;
			// 左端のA点を求める
			a = MIN_ROOM_SIZE + 3;

			// 右端のB点を求める
			b = RECT_W(*pRect) - MIN_ROOM_SIZE - 4;

			// ABの距離を求める
			ab = b - a;

			// AB間のどこかに決定する
			p = a + GetRand(ab + 1);

			// 新しく右の区画を作成する
			pChild = CreateRect(pRect->left + p,
								pRect->top,
								pRect->right,
								pRect->bottom);

			// 元の区画の右を p 地点に移動させて、左側の区画とする
			pParent->Rect.right = pChild->Rect.left;

			// 子の部屋をさらに分割する
			nChildIndex1 = DunrectToIndex(pChild);
			SplitRect(nChildIndex1, 0);
		}
	}

	if((nFlagHV & 2) == 0) {
		// 縦に分割する
		nFlagHV |= 2;

		// 区分を分割できるか?チェック
		if( RECT_H(*pRect) >= (MIN_ROOM_SIZE+3)*2+1 ) {
			int a, b, ab, p;
			a = MIN_ROOM_SIZE + 3;
			b = RECT_H(*pRect) - MIN_ROOM_SIZE - 4;
			ab = b - a;

			p = a + GetRand(ab + 1);

			// 新しく下の区画を作成する
			pChild = CreateRect(pRect->left,
								pRect->top + p,
								pRect->right,
								pRect->bottom);

			// 元の区画の下を p 地点に移動させて、上側の区画とする
			pParent->Rect.bottom = pChild->Rect.top;

			// 子の部屋をさらに分割する
			nChildIndex2 = DunrectToIndex(pChild);
			SplitRect(nChildIndex2, 0);
		}
	}

	// 部屋を作る
	CreateRoom(nParentRectIndex);

	// 子供とつなげる
	if(nChildIndex1) {
		CreateRoad( nParentRectIndex, nChildIndex1 );
	}
	if(nChildIndex2) {
		CreateRoad( nParentRectIndex, nChildIndex2 );
	}
}
Пример #23
0
TestingSetup::TestingSetup()
{
#ifdef ENABLE_WALLET
        bitdb.MakeMock();
#endif
        ClearDatadirCache();
        pathTemp = GetTempPath() / strprintf("test_bitcoin_%lu_%i", (unsigned long)GetTime(), (int)(GetRand(100000)));
        boost::filesystem::create_directories(pathTemp);
        mapArgs["-datadir"] = pathTemp.string();
        pblocktree = new CBlockTreeDB(1 << 20, true);
        pcoinsdbview = new CCoinsViewDB(1 << 23, true);
        pcoinsTip = new CCoinsViewCache(pcoinsdbview);
        InitBlockIndex();
#ifdef ENABLE_WALLET
        bool fFirstRun;
        pwalletMain = new CWallet("wallet.dat");
        pwalletMain->LoadWallet(fFirstRun);
        RegisterValidationInterface(pwalletMain);
#endif
        nScriptCheckThreads = 3;
        for (int i=0; i < nScriptCheckThreads-1; i++)
            threadGroup.create_thread(&ThreadScriptCheck);
        RegisterNodeSignals(GetNodeSignals());
}
Пример #24
0
//==============================================================
// ダンジョンを作る
//==============================================================
void CDunHard::Make( CChara *pPlayer)
{
	// 区画の数をリセット
	m_uRectCnt = 0;
	m_pPlayer = pPlayer;

	//-----------------------------------
	// 初期化:一旦すべて壁にする
	//-----------------------------------
	int x, y;
	for(y = 0; y < m_uHeight; y ++) {
		for(x = 0; x < m_uWidth; x ++) {
			GetTile(x, y)->bIsWall = TRUE;
		}
	}
	
	//-----------------------------------
	// 区画を作る
	//-----------------------------------
	// まずは全体を1つの区画にする
	CreateRect(0, 0, m_uWidth - 1, m_uHeight - 1);
	// 再帰でどんどん細かくする
	SplitRect(0, 0);
	
	//-----------------------------------
	// 階段の設置
	//-----------------------------------
	// ランダムな部屋の適当な位置に下階段を配置
	int nStepDownIndex;
	nStepDownIndex = GetRand(m_uRectCnt);
	while (true) {
		RandRoomPoint(nStepDownIndex, &x, &y);
		if (GetTile(x, y)->bIsWall == false) {
			GetTile(x, y)->bIsStepDown = TRUE;
			m_uDownStepX = x;
			m_uDownStepY = y;
			break;
		}
	}

	// 下階段とは違う部屋でランダムな部屋の適当な位置に上階段を配置
	int nStepUpIndex;
	nStepUpIndex = GetRand(m_uRectCnt);
	while(nStepUpIndex == nStepDownIndex) {
		nStepUpIndex = GetRand(m_uRectCnt);
	}
	while (true) {
		RandRoomPoint(nStepUpIndex, &x, &y);
		if (GetTile(x, y)->bIsWall == false) {
			GetTile(x, y)->bIsStepUp = TRUE;
			m_uUpStepX = x;
			m_uUpStepY = y;
			break;
		}
	}

	//-----------------------------------
	// 迷路以外はもう一回区画を塗り直しておく
	//-----------------------------------
	ReFillRoom();

	//-----------------------------------
	// 各部屋にアイテムを配置する
	//-----------------------------------
	CreateItem(60);

	//-----------------------------------
	// 各部屋にモンスターを配置する
	//-----------------------------------
	CreateMob(60);
}
Пример #25
0
void RPCNestedTests::rpcNestedTests()
{
    UniValue jsonRPCError;

    // do some test setup
    // could be moved to a more generic place when we add more tests on QT level
    const CChainParams& chainparams = Params();
    RegisterAllCoreRPCCommands(tableRPC);
    tableRPC.appendCommand("rpcNestedTest", &vRPCCommands[0]);
    ClearDatadirCache();
    std::string path = QDir::tempPath().toStdString() + "/" + strprintf("test_bitcoin_qt_%lu_%i", (unsigned long)GetTime(), (int)(GetRand(100000)));
    QDir dir(QString::fromStdString(path));
    dir.mkpath(".");
    mapArgs["-datadir"] = path;
    //mempool.setSanityCheck(1.0);
    pblocktree = new CBlockTreeDB(1 << 20, true);
    pcoinsdbview = new CCoinsViewDB(1 << 23, true);
    pcoinsTip = new CCoinsViewCache(pcoinsdbview);
    InitBlockIndex(chainparams);
    {
        CValidationState state;
        bool ok = ActivateBestChain(state, chainparams);
        QVERIFY(ok);
    }

    SetRPCWarmupFinished();

    std::string result;
    std::string result2;
    RPCConsole::RPCExecuteCommandLine(result, "getblockchaininfo()[chain]"); //simple result filtering with path
    QVERIFY(result=="main");

    RPCConsole::RPCExecuteCommandLine(result, "getblock(getbestblockhash())"); //simple 2 level nesting
    RPCConsole::RPCExecuteCommandLine(result, "getblock(getblock(getbestblockhash())[hash], true)");

    RPCConsole::RPCExecuteCommandLine(result, "getblock( getblock( getblock(getbestblockhash())[hash] )[hash], true)"); //4 level nesting with whitespace, filtering path and boolean parameter

    RPCConsole::RPCExecuteCommandLine(result, "getblockchaininfo");
    QVERIFY(result.substr(0,1) == "{");

    RPCConsole::RPCExecuteCommandLine(result, "getblockchaininfo()");
    QVERIFY(result.substr(0,1) == "{");

    RPCConsole::RPCExecuteCommandLine(result, "getblockchaininfo "); //whitespace at the end will be tolerated
    QVERIFY(result.substr(0,1) == "{");

    (RPCConsole::RPCExecuteCommandLine(result, "getblockchaininfo()[\"chain\"]")); //Quote path identifier are allowed, but look after a child contaning the quotes in the key
    QVERIFY(result == "null");

    (RPCConsole::RPCExecuteCommandLine(result, "createrawtransaction [] {} 0")); //parameter not in brackets are allowed
    (RPCConsole::RPCExecuteCommandLine(result2, "createrawtransaction([],{},0)")); //parameter in brackets are allowed
    QVERIFY(result == result2);
    (RPCConsole::RPCExecuteCommandLine(result2, "createrawtransaction( [],  {} , 0   )")); //whitespace between parametres is allowed
    QVERIFY(result == result2);

    RPCConsole::RPCExecuteCommandLine(result, "getblock(getbestblockhash())[tx][0]");
    QVERIFY(result == "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b");

    RPCConsole::RPCExecuteCommandLine(result, "rpcNestedTest");
    QVERIFY(result == "[]");
    RPCConsole::RPCExecuteCommandLine(result, "rpcNestedTest ''");
    QVERIFY(result == "[\"\"]");
    RPCConsole::RPCExecuteCommandLine(result, "rpcNestedTest \"\"");
    QVERIFY(result == "[\"\"]");
    RPCConsole::RPCExecuteCommandLine(result, "rpcNestedTest '' abc");
    QVERIFY(result == "[\"\",\"abc\"]");
    RPCConsole::RPCExecuteCommandLine(result, "rpcNestedTest abc '' abc");
    QVERIFY(result == "[\"abc\",\"\",\"abc\"]");
    RPCConsole::RPCExecuteCommandLine(result, "rpcNestedTest abc  abc");
    QVERIFY(result == "[\"abc\",\"abc\"]");
    RPCConsole::RPCExecuteCommandLine(result, "rpcNestedTest abc\t\tabc");
    QVERIFY(result == "[\"abc\",\"abc\"]");
    RPCConsole::RPCExecuteCommandLine(result, "rpcNestedTest(abc )");
    QVERIFY(result == "[\"abc\"]");
    RPCConsole::RPCExecuteCommandLine(result, "rpcNestedTest( abc )");
    QVERIFY(result == "[\"abc\"]");
    RPCConsole::RPCExecuteCommandLine(result, "rpcNestedTest(   abc   ,   cba )");
    QVERIFY(result == "[\"abc\",\"cba\"]");

#if QT_VERSION >= 0x050300
    // do the QVERIFY_EXCEPTION_THROWN checks only with Qt5.3 and higher (QVERIFY_EXCEPTION_THROWN was introduced in Qt5.3)
    QVERIFY_EXCEPTION_THROWN(RPCConsole::RPCExecuteCommandLine(result, "getblockchaininfo() .\n"), std::runtime_error); //invalid syntax
    QVERIFY_EXCEPTION_THROWN(RPCConsole::RPCExecuteCommandLine(result, "getblockchaininfo() getblockchaininfo()"), std::runtime_error); //invalid syntax
    (RPCConsole::RPCExecuteCommandLine(result, "getblockchaininfo(")); //tolerate non closing brackets if we have no arguments
    (RPCConsole::RPCExecuteCommandLine(result, "getblockchaininfo()()()")); //tolerate non command brackts
    QVERIFY_EXCEPTION_THROWN(RPCConsole::RPCExecuteCommandLine(result, "getblockchaininfo(True)"), UniValue); //invalid argument
    QVERIFY_EXCEPTION_THROWN(RPCConsole::RPCExecuteCommandLine(result, "a(getblockchaininfo(True))"), UniValue); //method not found
    QVERIFY_EXCEPTION_THROWN(RPCConsole::RPCExecuteCommandLine(result, "rpcNestedTest abc,,abc"), std::runtime_error); //don't tollerate empty arguments when using ,
    QVERIFY_EXCEPTION_THROWN(RPCConsole::RPCExecuteCommandLine(result, "rpcNestedTest(abc,,abc)"), std::runtime_error); //don't tollerate empty arguments when using ,
    QVERIFY_EXCEPTION_THROWN(RPCConsole::RPCExecuteCommandLine(result, "rpcNestedTest(abc,,)"), std::runtime_error); //don't tollerate empty arguments when using ,
#endif

    delete pcoinsTip;
    delete pcoinsdbview;
    delete pblocktree;

    boost::filesystem::remove_all(boost::filesystem::path(path));
}
Пример #26
0
//==============================================================
// 特定の部屋に迷路を作成する
//==============================================================
void CDunHard::CreateMaze(int uRoom)
{
	//-- 壁延ばし法で迷路を作成 --
	// 変数宣言
	int oX, oY, nX, nY, nX2, nY2;
	int dir;
	bool badDir[4];

	// 部屋情報取得
	RECT *pRoom;
	pRoom = &m_Rect[uRoom].Room;

	// ワーク領域を作成
	int w = pRoom->right - pRoom->left + 2;
	int h = pRoom->bottom - pRoom->top + 2;
	int *pWork = new int[w * h];

	// 道(0)で初期化
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			pWork[i * w + j] = 0;
		}
	}

	// 外周を壁(1)にする
	for (int i = 0; i < w; i++) {
		pWork[i] = 1;
		pWork[(h - 1) * w + i] = 1;
	}
	for (int i = 0; i < h; i++) {
		pWork[i * w] = 1;
		pWork[i * w + (w - 1)] = 1;
	}

	// 起点を選択
	oX = 2;
	oY = 2;

	// 起点を現在位置にする
	nX = oX;
	nY = oY;

	// 選択先が暫定壁であることを知るためのフラグを初期化
	for (int i = 0; i < 4; i++) {
		badDir[i] = false;
	}

	// 壁作成ループ
	while (true) {
		// 選択先を取得
		dir = GetRand(4);
		switch (dir) {
			// 上
		case 0: nX2 = nX; nY2 = nY - 2; break;
			// 右
		case 1: nX2 = nX + 2; nY2 = nY; break;
			// 下
		case 2: nX2 = nX; nY2 = nY + 2; break;
			// 左
		case 3: nX2 = nX - 2; nY2 = nY; break;
		}

		// 選択先が道なら、そこまで暫定の壁(2)を延ばして次の選択先へ
		if (pWork[nY2 * w + nX2] == 0) {
			pWork[nY * w + nX] = 2;
			switch (dir) {
				// 上
			case 0: pWork[(nY - 1) * w + nX] = 2; pWork[nY2 * w + nX2] = 2; break;
				// 右
			case 1: pWork[nY * w + nX + 1] = 2; pWork[nY2 * w + nX2] = 2; break;
				// 下
			case 2: pWork[(nY + 1) * w + nX] = 2; pWork[nY2 * w + nX2] = 2; break;
				// 左
			case 3: pWork[nY * w + nX - 1] = 2; pWork[nY2 * w + nX2] = 2; break;
			}
			nX = nX2;
			nY = nY2;
		}
		// 選択先が確定済みの壁(1)ならば、そこまで壁を繋げて、
		// 暫定の壁を全て確定させ、次の起点へ移動する
		else if (pWork[nY2 * w + nX2] == 1) {
			pWork[nY * w + nX] = 2;
			switch (dir) {
				// 上
			case 0: pWork[(nY - 1) * w + nX] = 2; pWork[nY2 * w + nX2] = 2; break;
				// 右
			case 1: pWork[nY * w + nX + 1] = 2; pWork[nY2 * w + nX2] = 2; break;
				// 下
			case 2: pWork[(nY + 1) * w + nX] = 2; pWork[nY2 * w + nX2] = 2; break;
				// 左
			case 3: pWork[nY * w + nX - 1] = 2; pWork[nY2 * w + nX2] = 2; break;
			}
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					if (pWork[i * w + j] == 2) {
						pWork[i * w + j] = 1;
					}
				}
			}

			// 暫定壁フラグを初期化
			for (int i = 0; i < 4; i++) {
				badDir[i] = false;
			}

			// 次の起点を探す
			bool hitOrigin = false;
			while (!hitOrigin) {
				for (int i = oY; i < h; i += 2) {
					for (int j = oX; j < w - 1; j += 2) {
						if (pWork[i * w + j] == 0) {
							oX = j;
							oY = i;
							nX = oX;
							nY = oY;
							hitOrigin = true;
							break;
						}
					}
					if (hitOrigin) {
						break;
					}
					oX = 2;
				}
				break;
			}

			// 起点が見つからなかったら迷路化終了
			if (!hitOrigin) {
				break;
			}
		}
		// 選択先が暫定の壁(2)なら、選択先が暫定壁であることをフラグに登録して、次の選択先へ
		else if (pWork[nY2 * w + nX2] == 2) {
			badDir[dir] = true;

			// 全て暫定壁だった場合は、今までに敷いた暫定壁を全て道に戻し、起点に戻る
			int cnt = 0;
			for (int i = 0; i < 4; i++) {
				if (badDir[i]) {
					cnt++;
				}
			}
			if (cnt >= 4) {
				for (int i = 0; i < h; i++) {
					for (int j = 0; j < w; j++) {
						if (pWork[i * w + j] == 2) {
							pWork[i * w + j] = 0;
						}
					}
				}
				nX = oX;
				nY = oY;
				for (int i = 0; i < 4; i++) {
					badDir[i] = false;
				}
			}
		}
	}

	// 壁の部分と道の部分を部屋に反映させる
	for (int i = 1; i < h - 1; i++) {
		for (int j = 1; j < w - 1; j++) {
			GetTile(pRoom->left + j - 1, pRoom->top + i - 1)->bIsRoom = FALSE;
			if (pWork[i * w + j] == 0) {
				GetTile(pRoom->left + j - 1, pRoom->top + i - 1)->bIsWall = FALSE;
			}
			else {
				GetTile(pRoom->left + j - 1, pRoom->top + i - 1)->bIsWall = TRUE;
			}
		}
	}

	// ワーク領域を開放
	delete[] pWork;
}
Пример #27
0
// 敵抽選はBefore_Battle.cppで行う
int BattleMgr( Character_t *Character, EnemySelect_t EnemySelect){
	MessageFrame();

	switch(BattlePhase){
		// 初期化 敵の枠に代入
		case 0:for(int i=0;i<4;i++){
			if(EnemySelect.Enemy[i]!=0)Substitution( &Enemy[i], EnemyStatus[(EnemySelect.Enemy[i]-1)]);
			if(EnemySelect.Enemy[i]==0)Substitution( &Enemy[i], EnemyStatus[(EnemySelect.Enemy[i]-1)], FALSE);
			SecondIni( Enemy[i], i);
		}BattlePhase=1;break;

		// 戦闘に入ったとこ
		case 1:if(DrawBattleMessageString( 0, 1, BattleMenuString)==100)BattlePhase=2;break;

		// 何を行うかの選択
		case 2:switch(DrawMenu( 2, 2, KEY_INPUT_Z, BattleMenu )){
				case 0:BattlePhase=4;SpeedChecker( Character, Enemy );break;
				case 1:break;
				case 2:BattlePhase=3;break;
				case 3:break;
			   }break;

		// 逃げる時の文表示
		case 3:if( DrawBattleMessageString( 2, 2, BattleMenuString ) == 100 ){BattlePhase=0;MenuSelect=0;return 2;}break;

		// 攻撃する敵を選択数
		case 4:{
			switch(MenuSelect){
				case 0:{
					DrawFormatString(230,380,GetColor(255,255,255),"勇者はどの敵を攻撃する?");
					Attack[0]=DrawCursor( Enemy );
					if(Attack[0]!=100){
						if(Attack[0]!=200)MenuSelect++;
						BattlePhase=2;
					}
				}break;

				case 1:{
					DrawFormatString(230,380,GetColor(255,255,255),"勇者(二人目)どの敵を攻撃する?");
					Attack[1]=DrawCursor( Enemy );
					if(Attack[1]!=100){
						if(Attack[1]==200)BattlePhase=2;
						else MenuSelect++;
					}
				}break;

				case 2:{MenuSelect=0;BattlePhase=5;}break;
			}
		}break;

		// 攻撃実行
		case 5:{
			// 敵四体
			for(int i=0;i<4;i++){
				if( Enemy[i].Speed==Data[BattleTurn] && doing==0 && (Enemy[i].Speed2==0)){
					doing=1;
					if( Enemy[i].Defense && Enemy[i].HP>0){
						switch( DrawBattleMessageString( 5, 6, BattleMenuString, Enemy[i].NameNumber, Damage )){
							case 0:if(once==0){Rand=GetRand(1);Damage=DamageCalc( Enemy[i], *(Character+Rand) );once++;}break;
							case 1:if(Rand!=2)(Character+Rand)->HP-=Damage;Rand=2;break;
							case 100:Enemy[i].Speed2=1;Rand=0;BattleTurn++;once=0;break;
						}
					}else if( Enemy[i].HP<=0 ){
						BattleTurn++;
						Enemy[i].Speed2++;
						Enemy[i].Flag=0;
					}
				} 
			}

			if( !Character->Speed2 && Character->Speed==Data[BattleTurn] && !doing ){
				doing=1;
				if(Enemy[Attack[0]].Flag){
					switch( DrawBattleMessageString( 3, 4, BattleMenuString, Enemy[Attack[0]].NameNumber, Damage )){
						case 0:if(!once){Damage=DamageCalc( *Character, Enemy[Attack[0]] );once++;}break;
						case 1:if(Rand!=2)Enemy[Attack[0]].HP-=Damage;Rand=2;break;
						case 100:Character->Speed2=1;if(Enemy[Attack[0]].HP<=0)Enemy[Attack[0]].Flag=0;Rand=0;BattleTurn++;once=0;break;
					}
				}else BattleTurn+=1;
			}

			if( !(Character+1)->Speed2 && (Character+1)->Speed==Data[BattleTurn] && !doing){
				doing=1;
				if(Enemy[Attack[1]].Flag){
					switch( DrawBattleMessageString( 3, 4, BattleMenuString, Enemy[Attack[1]].NameNumber, Damage )){
						case 0:if(once==0){Damage=DamageCalc( *(Character+1), Enemy[Attack[1]] );once++;}break;
						case 1:if(Rand!=2)Enemy[Attack[1]].HP-=Damage;Rand=2;break;
						case 100:(Character+1)->Speed2=1;if(Enemy[Attack[1]].HP<=0)Enemy[Attack[1]].Flag=0;Rand=0;BattleTurn++;once=0;break;
					}
				}else BattleTurn+=1;
			}

			//BattleTurnが6は全員行動したことになっている
			if( !doing && BattleTurn==6){
				doing=1;
				BattlePhase=2;
				for(int i=0; i<4; i++ )Enemy[i].Speed2=0;
				for(int i=0; i<2; i++)(Character+i)->Speed2=0;
				//敵全滅
				if( Enemy[0].HP<=0 && Enemy[1].HP<=0 && Enemy[2].HP<=0 && Enemy[3].HP<=0 ){
					for(int i=0 ; i<4; i++){ //先に経験値の合計を求める
						EnemyExpSum+=Enemy[i].Ex;
						Substitution( &Enemy[i], EnemyStatus[(EnemySelect.Enemy[i]-1)], FALSE);
					}
					BattlePhase=6;
				}
				else BattleTurn=0;
			}
		}doing=0;break;//case 5の終了

		// 戦闘終了後の処理
		case 6:{
			if( DrawBattleMessageString( 7, 8, BattleMenuString,0,EnemyExpSum ) == 100 ){
				doing=0;
				BattlePhase=0;
				BattleTurn=0;
				for(int i=0; i<4; i++ )Enemy[i].Speed2=0;
				for(int i=0; i<2; i++)(Character+i)->Speed2=0; 
				if(Character->HP>=0)Character->Ex+=EnemyExpSum;
				// EnemyExpSumは一度の戦闘で手に入れた経験値の合計
				EnemyExpSum=0;
				if(Levelup(Character)==1)BattlePhase=7;
				else return 2;
			}
		}break;
		// レベルアップ時
		case 7:{
			if( DrawBattleMessageString( 9, 9, BattleMenuString, 0, Character->LEVEL) == 100 ){
				BattlePhase=0;
				return 2;
			}
		}break;
	}//switchの終了
	
	//数字表示系 敵の数字を表示
	DrawFormatString(420,360,GetColor(255,255,255),"BattleTurn:%d",BattleTurn);
	DrawFormatString(150,100,GetColor(255,255,255),"%d,%d,%d,%d,%d,%d",Data[0],Data[1],Data[2],Data[3],Data[4],Data[5]);
	DrawFormatString(150,120,GetColor(0,255,0),"%d",Character->Ex);
	for(int i=0;i<4;i++)DrawFormatString(320,240+20*i,GetColor(255,255,255),"%d",EnemySelect.Enemy[i]);	

	//条件を満たしている敵の枠のみ表示
	for(int i=0; i<4; i++)if(Enemy[i].HP>0 && Enemy[i].Flag==1)DrawGraph( Enemy[i].X+80*i, Enemy[i].Y, Enemy[i].Graph, TRUE );
	//勇者側のステータス表示
	for(int i=0; i<2; i++){
		if( (Character+i)->HP > 0 ){
			DrawGauge( 15, 16+35*i, (Character+i)->MaxHP, (Character+i)->HP, GetColor( 0, 255, 0 ), GetColor(0, 255/2, 0),TRUE);
			DrawGauge( 15, 31+35*i, (Character+i)->MaxMP, (Character+i)->MP, GetColor( 255, 255, 0 ),GetColor( 255/2, 255/2, 0 ),TRUE );
		}else if( (Character+i)->HP <=0 ) (Character+i)->HP=0;
	}

	if(CheckHitKey(KEY_INPUT_H)==1)return 2;
	return 4;
}
Пример #28
0
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{
	ChangeWindowMode(TRUE);
	//SetMouseDispFlag(TRUE);
	SetMainWindowText("調布祭AI対戦2013") ;
	SetDrawMode(DX_DRAWMODE_BILINEAR);
	SetScreenMemToVramFlag(FALSE);
	SetAlwaysRunFlag(TRUE);
	SetDrawScreen( DX_SCREEN_BACK);
	if(DxLib_Init()==-1)		// DXライブラリ初期化処理
	{
		return -1 ;			// エラーが起きたら直ちに終了
	}

	//デバック用にコンソールを出現させる
	/*
	AllocConsole();
	freopen("CONOUT$","w",stdout);
	freopen("CONIN$","r",stdin);z
	*/

	Mode gamemode=OPENING;
	AI_T ai[AI_NUM];
	Takara takara;
	int death[AI_NUM]={0};
	Tagger tagger[TAGGER_NUM];
	int tagger_num = 0;
	int STAGE[WIDTH][HEIGHT]={0};
	int round=0;
	int start=0;
	int end=0;
	int newround=0;
	int StartTime,TimeLimit;

	for(int i=0;i<AI_NUM;i++){
		ai[i].entry=0;
	}

	while(ProcessMessage()!=-1){
		int speed=0;
		switch(gamemode){
		case OPENING:
			start=intro(ai,takara);
			if(start==1)gamemode=SETTING;
			break;
		case SETTING:
			make_Stage(STAGE,takara);//マップ構成
			do{
			takara.x=GetRand(WIDTH/2-2)+WIDTH/2;
			takara.y=GetRand(HEIGHT/2-1)+1;
			}while(STAGE[takara.x][takara.y]==1);
			takara.ich=0;
			takara.drop=0;
			takara.muteki=0;
			init_Tagger(tagger,STAGE,takara);//鬼の初期化 //tagger_numは鬼の要素番号

			init_Ai(ai,STAGE);
			newround=1;
			round++;
			TimeLimit=TIME_LIMIT*60*79;//ゲーム開始時の時刻に合わせる
			gamemode=RUNNING;

			break;
		case RUNNING:
			TimeLimit-=79;
			if(TimeLimit<0)TimeLimit=0;
			for(int i=0;i<TAGGER_NUM;i++){
				if(tagger[i].step==0){
					//tagger[tagger_num].act=next_Tagger(tagger[tagger_num],STAGE,ai);
					tagger[i].act=tagger[i].moveFunc(tagger[i].x,tagger[i].y,STAGE,takara); //AIと一緒で、moveFunc使う
				}
			}
			for(int i=0;i<AI_NUM;i++){
				if(ai[i].step == 0 && ai[i].entry==1){
					setview_Ai(&ai[i],STAGE);
					//ai[i].act=next_Ai(ai[i].view); //henteko : 下のmoveFunc()を使うためコメントアウト
					ai[i].act = ai[i].moveFunc(ai[i].view,takara.ich,ai[i].takara_flag,newround);
				}
			}
			newround=0;
			/*if(TimeLimit>TIME_LIMIT*45*79)speed=0;
			else if(TimeLimit>TIME_LIMIT*30*79)speed=1;
			else if(TimeLimit>TIME_LIMIT*15*79)speed=1;
			else speed=3;*/
			for(int i=0;i<TAGGER_NUM;i++){
				update_Tagger(&tagger[i],STAGE);
			}
			for(int i=0;i<AI_NUM;i++){
				if(ai[i].entry==1){
					update_Ai(&ai[i],STAGE,&takara,speed);
					if(ai[i].life==1){//捕まった場合
						ai[i].x=1;
						ai[i].y=HEIGHT-2;
						ai[i].s_x=(ai[i].x+0.5)*BOX;
						ai[i].s_y=(ai[i].y+0.5)*BOX;
						ai[i].act=STOP;
						ai[i].step=0;
						STAGE[ai[i].x][ai[i].y]=2;
						TimeLimit-=10000;//時間ペナルティ
						ai[i].score-=100;//点数ペナルティ
						ai[i].muteki=60;//捕まって数ターンは敵に見つからない
						ai[i].life=0;
					}
				}
			}
			update_stage(STAGE,ai,tagger,takara);
			
			ClearDrawScreen();
			draw(STAGE,ai,tagger,takara);
			DrawFormatString(30,30,GetColor(0,255,255),"ROUND%d",round);
			
			DrawFormatString(500,15,GetColor(0,255,0),"TIME %d",TimeLimit);
			
			if(1){
				for(int i=0;i<AI_NUM;i++){
					for(int j=0;j<TAGGER_NUM;j++){
						if(death_Ai(ai[i],tagger[j])==1 && ai[i].entry==1){
							death[i]++;
							DrawBox(0,230,640,260,GetColor(0,0,0),1);
							DrawBox(-1,230,642,260,GetColor(255,0,0),0);
							//DrawFormatString(100,240,GetColor(255,0,0),"%sがつかまりました",ai[i].name);// 8/3 zero追記:AI捕獲の宣言をまとめた。

							
							if(ai[i].takara_flag==1){//宝を持っていた時
								takara.x=ai[i].x;
								takara.y=ai[i].y;
								takara.drop=0;
								takara.muteki=60*AI_NUM;
								ai[i].takara_flag=0;
								ai[i].score-=400;
							}
							ai[i].life=1;
						}
					}
					if(ai[i].takara_flag==1&&STAGE[ai[i].x][ai[i].y]==5/*&&ai[i].x<3&&ai[i].y>HEIGHT-4*/){//クリア判定
						ai[i].score+=1000;
						WaitTimer(3000);
						if(round>=ROUND_MAX){
							gamemode=ENDING;
						}else{
							gamemode=SETTING;
						}
						break;
					}
				}
			}
			if(TimeLimit<=0){// 8/3 zero追記:タイムアップを設定
				//round--;
				DrawString(100,240,"時間切れです",GetColor(255,0,0));
				WaitTimer(3000);
				if(round>=ROUND_MAX){
					gamemode=ENDING;
				}
				else{
					gamemode=SETTING;
				}
				break;
			}
			if(CheckHitKey(KEY_INPUT_R)==1){
				gamemode=SETTING;
			}
			break;
		case ENDING:
			end=ranking(ai,death);
			break;
		default:
			break;
		}
		if(end==1 || CheckHitKey(KEY_INPUT_ESCAPE))break;
		ScreenFlip();
	}

	DxLib_End() ;				// DXライブラリ使用の終了処理

	return 0 ;				// ソフトの終了 
}
Пример #29
0
 TestingSetup() {
     fPrintToDebugger = true; // don't want to write to debug.log file
     noui_connect();
     bitdb.MakeMock();
     pathTemp = GetTempPath() / strprintf("test_imacredit_%lu_%i", (unsigned long)GetTime(), (int)(GetRand(100000)));
     boost::filesystem::create_directories(pathTemp);
     mapArgs["-datadir"] = pathTemp.string();
     pblocktree = new CBlockTreeDB(1 << 20, true);
     pcoinsdbview = new CCoinsViewDB(1 << 23, true);
     pcoinsTip = new CCoinsViewCache(*pcoinsdbview);
     InitBlockIndex();
     bool fFirstRun;
     pwalletMain = new CWallet("wallet.dat");
     pwalletMain->LoadWallet(fFirstRun);
     RegisterWallet(pwalletMain);
     nScriptCheckThreads = 3;
     for (int i=0; i < nScriptCheckThreads-1; i++)
         threadGroup.create_thread(&ThreadScriptCheck);
 }
Пример #30
0
//	--------------------------------------------------------------------
//	敵がショットをうつまでのタイミングを計算する
//	--------------------------------------------------------------------
void CalcEnemyShotTiming()
{
    //	ショットを打つまでの間隔を決める
    //	ENEMY_SHOT_MIN_TIMEからENEMY_SHOT_MAX_TIMEまでの間の乱数をつくる
    enemyShotTime = GetRand(ENEMY_SHOT_MAX_TIME - ENEMY_SHOT_MIN_TIME) + ENEMY_SHOT_MIN_TIME;
}