Merge branch 'founders' into duke

This commit is contained in:
Jonathan "Duke" Leto
2019-03-15 11:29:55 -07:00
41 changed files with 3645 additions and 310 deletions

11
.gitignore vendored
View File

@@ -132,6 +132,11 @@ src/cc/rogue/rogue
src/cc/rogue/rogue.so
src/cc/rogue/test.zip
src/checkfile
src/foo.zip
src/log
src/rogue.530623577502174316.0
@@ -139,11 +144,6 @@ src/rogue.530623577502174316.pack
src/rogue.530623577502174316.player
src/checkfile
src/log
src/foo.zip
src/cc/rogue/config.h
@@ -154,3 +154,4 @@ src/ROGUE.conf
src/rogue.scr
src/cc/rogue/confdefs.h
src/cc/rogue/x64

View File

@@ -73,8 +73,8 @@ build:windows:
src/komodo-tx.exe
src/cc/rogue/rogue.exe
zcutil/fetch-params.bat
src/cc/rogue/x86_64-w64-mingw32/libcurl-4.dll
src/cc/rogue/x86_64-w64-mingw32/libncursesw6.dll
src/cc/rogue/x86_64-w64-mingw32/bin/libcurl-4.dll
src/cc/rogue/x86_64-w64-mingw32/bin/libncursesw6.dll
${PACKAGE_DIR_WINDOWS}
- zip -r ${PACKAGE_DIR_WINDOWS}.zip ${PACKAGE_DIR_WINDOWS}
- md5sum ${AGAMA_ARTIFACTS_WINDOWS} > ${AGAMA_ARTIFACTS_WINDOWS_CHECKSUM}

3
src/ac/ilien Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/bash
./komodo-cli -ac_name=ILN $1 $2 $3 $4 $5 $6

View File

@@ -64,13 +64,10 @@
"ac_name": "MESH",
"ac_supply": "1000007"
},
{
"ac_name": "MNZ",
"ac_supply": "257142858"
},
{
"ac_name": "AXO",
"ac_supply": "200000000"
"ac_supply": "200000000",
"ac_ccactivate": "130000"
},
{
"ac_name": "ETOMIC",

View File

@@ -20,8 +20,7 @@ echo $pubkey
./komodod -pubkey=$pubkey -ac_name=KV -ac_supply=1000000 -addnode=78.47.196.146 $1 &
./komodod -pubkey=$pubkey -ac_name=CEAL -ac_supply=366666666 -addnode=78.47.196.146 $1 &
./komodod -pubkey=$pubkey -ac_name=MESH -ac_supply=1000007 -addnode=78.47.196.146 $1 &
./komodod -pubkey=$pubkey -ac_name=MNZ -ac_supply=257142858 -addnode=51.15.138.138 $1 &
./komodod -pubkey=$pubkey -ac_name=AXO -ac_supply=200000000 -addnode=78.47.196.146 &
./komodod -pubkey=$pubkey -ac_name=AXO -ac_supply=200000000 -ac_ccactivate=130000 -addnode=78.47.196.146 &
./komodod -pubkey=$pubkey -ac_name=ETOMIC -ac_supply=100000000 -addnode=78.47.196.146 &
./komodod -pubkey=$pubkey -ac_name=BTCH -ac_supply=20998641 -addnode=78.47.196.146 &
./komodod -pubkey=$pubkey -ac_name=BEER -ac_supply=100000000 -addnode=78.47.196.146 &
@@ -47,4 +46,5 @@ echo $pubkey
./komodod -pubkey=$pubkey -ac_name=ZEX -ac_cc=2 -ac_founders=1 -ac_halving=525600 -ac_reward=13000000000 -ac_pubkey=039d4a50cc70d1184e462a22edb3b66385da97cc8059196f8305c184a3e21440af -addnode=5.9.102.210 &
./komodod -pubkey=$pubkey -ac_name=KSB -ac_supply=1000000000 -ac_end=1 -ac_public=1 -addnode=37.187.225.231 &
./komodod -pubkey=$pubkey -ac_name=OUR -ac_reward=1478310502 -ac_halving=525600 -ac_cc=42 -ac_supply=100000000 -ac_perc=77700 -ac_staked=93 -ac_pubkey=02652a3f3e00b3a1875a918314f0bac838d6dd189a346fa623f5efe9541ac0b98c -ac_public=1 -addnode=51.255.195.65 -addnode=217.182.129.38 -addnode=37.187.225.231 &
./komodod -pubkey=$pubkey -ac_name=ILN -ac_supply=10000000000 -ac_cc=2 -addnode=51.75.122.83 &
./komodod -pubkey=$pubkey -ac_name=ILN -ac_supply=10000000000 -ac_cc=2 -addressindex=1 -spentindex=1 -addnode=51.75.122.83 &

View File

@@ -290,6 +290,16 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran
cc_free(othercond3);
if ( othercond4 != 0 )
cc_free(othercond4);
if ( othercond1of2 != 0 )
cc_free(othercond1of2);
if ( othercond1of2tokens != 0 )
cc_free(othercond1of2tokens);
if ( mytokenscond != 0 )
cc_free(mytokenscond);
if ( mysingletokenscond != 0 )
cc_free(mysingletokenscond);
if ( othertokenscond != 0 )
cc_free(othertokenscond);
std::string strHex = EncodeHexTx(mtx);
if ( strHex.size() > 0 )
return(strHex);

View File

@@ -33,8 +33,12 @@
#ifdef BUILD_ROGUE
#define EVAL_ROGUE 17
std::string MYCCLIBNAME = (char *)"rogue";
#else
#elif BUILD_CUSTOMCC
#include "customcc.h"
#else
#define EVAL_SUDOKU 17
#define EVAL_MUSIG 18
#define EVAL_DILITHIUM 19
@@ -67,6 +71,8 @@ CClib_methods[] =
{ (char *)"rogue", (char *)"games", (char *)"<no args>", 0, 0, 'F', EVAL_ROGUE },
{ (char *)"rogue", (char *)"setname", (char *)"pname", 1, 1, 'N', EVAL_ROGUE },
{ (char *)"rogue", (char *)"extract", (char *)"gametxid [pubkey]", 1, 2, 'X', EVAL_ROGUE },
#elif BUILD_CUSTOMCC
RPC_FUNCS
#else
{ (char *)"sudoku", (char *)"gen", (char *)"<no args>", 0, 0, 'G', EVAL_SUDOKU },
{ (char *)"sudoku", (char *)"txidinfo", (char *)"txid", 1, 1, 'T', EVAL_SUDOKU },
@@ -214,6 +220,8 @@ UniValue CClib_method(struct CCcontract_info *cp,char *method,char *jsonstr)
return(result);
}
}
#elif BUILD_CUSTOMCC
CUSTOM_DISPATCH
#else
if ( cp->evalcode == EVAL_SUDOKU )
{
@@ -410,6 +418,8 @@ bool CClib_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C
{
#ifdef BUILD_ROGUE
return(rogue_validate(cp,height,eval,tx));
#elif BUILD_CUSTOMCC
return(custom_validate(cp,height,eval,tx));
#else
if ( cp->evalcode == EVAL_SUDOKU )
return(sudoku_validate(cp,height,eval,tx));
@@ -660,6 +670,9 @@ int32_t cclib_parsehash(uint8_t *hash32,cJSON *item,int32_t len)
#include "rogue/weapons.c"
#include "rogue/wizard.c"
#elif BUILD_CUSTOMCC
#include "customcc.cpp"
#else
#include "sudoku.cpp"
#include "musig.cpp"

88
src/cc/customcc.cpp Normal file
View File

@@ -0,0 +1,88 @@
/*
simple stub custom cc
Just update the functions in this file, then from ~/komodo/src/cc
../komodo-cli -ac_name=CUSTOM stop
./makecustom
../komodod -ac_name=CUSTOM -ac_cclib=custom -ac_cc=2 ...
The above will rebuild komodod and get it running again
*/
CScript custom_opret(uint8_t funcid,CPubKey pk)
{
CScript opret; uint8_t evalcode = EVAL_CUSTOM;
opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << pk);
return(opret);
}
uint8_t custom_opretdecode(CPubKey &pk,CScript scriptPubKey)
{
std::vector<uint8_t> vopret; uint8_t e,f;
GetOpReturnData(scriptPubKey,vopret);
if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> pk) != 0 && e == EVAL_CUSTOM )
{
return(f);
}
return(0);
}
UniValue custom_rawtxresult(UniValue &result,std::string rawtx,int32_t broadcastflag)
{
CTransaction tx;
if ( rawtx.size() > 0 )
{
result.push_back(Pair("hex",rawtx));
if ( DecodeHexTx(tx,rawtx) != 0 )
{
if ( broadcastflag != 0 && myAddtomempool(tx) != 0 )
RelayTransaction(tx);
result.push_back(Pair("txid",tx.GetHash().ToString()));
result.push_back(Pair("result","success"));
} else result.push_back(Pair("error","decode hex"));
} else result.push_back(Pair("error","couldnt finalize CCtx"));
return(result);
}
UniValue custom_func0(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
{
UniValue result(UniValue::VOBJ);
result.push_back(Pair("result","success"));
result.push_back(Pair("message","just an example of an information returning rpc"));
return(result);
}
// send yourself 1 coin to your CC address using normal utxo from your -pubkey
UniValue custom_func1(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
{
CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); std::string rawtx;
UniValue result(UniValue::VOBJ); CPubKey mypk; int64_t amount = COIN; int32_t broadcastflag=0;
if ( txfee == 0 )
txfee = CUSTOM_TXFEE;
mypk = pubkey2pk(Mypubkey());
if ( AddNormalinputs(mtx,mypk,COIN+txfee,64) >= COIN+txfee ) // add utxo to mtx
{
mtx.vout.push_back(MakeCC1vout(cp->evalcode,amount,mypk)); // make vout0
// add opreturn, change is automatically added and tx is properly signed
rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,custom_opret('1',mypk));
return(custom_rawtxresult(result,rawtx,broadcastflag));
}
return(result);
}
bool custom_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx)
{
char expectedaddress[64]; CPubKey pk;
if ( tx.vout.size() != 2 ) // make sure the tx only has 2 outputs
return eval->Invalid("invalid number of vouts");
else if ( custom_opretdecode(pk,tx.vout[1].scriptPubKey) != '1' ) // verify has opreturn
return eval->Invalid("invalid opreturn");
GetCCaddress(cp,expectedaddress,pk);
if ( IsCClibvout(cp,tx,0,expectedaddress) == COIN ) // make sure amount and destination matches
return(true);
else return eval->Invalid("invalid vout0 amount");
}

45
src/cc/customcc.h Normal file
View File

@@ -0,0 +1,45 @@
/*
to create a custom libcc.so:
1. change "func0" and "func1" to method names that fit your custom cc. Of course, you can create more functions by adding another entry to RPC_FUNCS. there is not any practical limit to the number of methods.
2. For each method make sure there is a UniValue function declaration and CUSTOM_DISPATCH has an if statement checking for it that calls the custom_func
3. write the actual custom_func0, custom_func1 and custom_validate in customcc.cpp
4. ./makecustom, which builds cclib.cpp with -DBUILD_CUSTOMCC and puts the libcc.so in ~/komodo/src and rebuilds komodod
5. launch your chain with -ac_cclib=customcc -ac_cc=2
*/
std::string MYCCLIBNAME = (char *)"customcc";
#define EVAL_CUSTOM (EVAL_FAUCET2+1)
#define CUSTOM_TXFEE 10000
#define MYCCNAME "custom"
#define RPC_FUNCS \
{ (char *)MYCCNAME, (char *)"func0", (char *)"<parameter help>", 1, 1, '0', EVAL_CUSTOM }, \
{ (char *)MYCCNAME, (char *)"func1", (char *)"<no args>", 0, 0, '1', EVAL_CUSTOM },
bool custom_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx);
UniValue custom_func0(uint64_t txfee,struct CCcontract_info *cp,cJSON *params);
UniValue custom_func1(uint64_t txfee,struct CCcontract_info *cp,cJSON *params);
#define CUSTOM_DISPATCH \
if ( cp->evalcode == EVAL_CUSTOM ) \
{ \
if ( strcmp(method,"func0") == 0 ) \
return(custom_func0(txfee,cp,params)); \
else if ( strcmp(method,"func1") == 0 ) \
return(custom_func1(txfee,cp,params)); \
else \
{ \
result.push_back(Pair("result","error")); \
result.push_back(Pair("error","invalid customcc method")); \
result.push_back(Pair("method",method)); \
return(result); \
} \
}

View File

@@ -3352,7 +3352,7 @@ int64_t dilithium_inputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPu
{
if ( (nValue= IsCClibvout(cp,vintx,vout,cmpaddr)) > DILITHIUM_TXFEE && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 )
{
if ( (dilithium_Qsendopretdecode(checktxid,tmpsig,voutpubtxids,vintx.vout[numvouts-1].scriptPubKey) == 'Q' && vout < voutpubtxids.size() && checktxid == voutpubtxids[vout]) || (dilithium_sendopretdecode(checktxid,vintx.vout[numvouts-1].scriptPubKey) == 'x' && destpubtxid == checktxid) )
if ( (dilithium_Qsendopretdecode(checktxid,tmpsig,voutpubtxids,vintx.vout[numvouts-1].scriptPubKey) == 'Q' && vout < voutpubtxids.size() && destpubtxid == voutpubtxids[vout]) || (dilithium_sendopretdecode(checktxid,vintx.vout[numvouts-1].scriptPubKey) == 'x' && destpubtxid == checktxid) )
{
if ( total != 0 && maxinputs != 0 )
mtx.vin.push_back(CTxIn(txid,vout,CScript()));

View File

@@ -166,7 +166,7 @@ CScript EncodeGatewaysBindOpRet(uint8_t funcid,uint256 tokenid,std::string coin,
return(EncodeTokenOpRet(tokenid,pubkeys, std::make_pair(OPRETID_GATEWAYSDATA, vopret)));
}
uint8_t DecodeGatewaysBindOpRet(char *depositaddr,const CScript &scriptPubKey,uint256 &tokenid,std::string &coin,int64_t &totalsupply,uint256 &oracletxid,uint8_t &M,uint8_t &N,std::vector<CPubKey> &gatewaypubkeys,uint8_t &taddr,uint8_t &prefix,uint8_t &prefix2,uint8_t wiftype)
uint8_t DecodeGatewaysBindOpRet(char *depositaddr,const CScript &scriptPubKey,uint256 &tokenid,std::string &coin,int64_t &totalsupply,uint256 &oracletxid,uint8_t &M,uint8_t &N,std::vector<CPubKey> &gatewaypubkeys,uint8_t &taddr,uint8_t &prefix,uint8_t &prefix2,uint8_t &wiftype)
{
std::vector<std::pair<uint8_t, vscript_t>> oprets;
std::vector<uint8_t> vopret,vOpretExtra; uint8_t *script,e,f,tokenevalcode; std::vector<CPubKey> pubkeys;
@@ -185,7 +185,7 @@ uint8_t DecodeGatewaysBindOpRet(char *depositaddr,const CScript &scriptPubKey,ui
if ( N > 1 )
{
strcpy(depositaddr,CBitcoinAddress(CScriptID(GetScriptForMultisig(M,gatewaypubkeys))).ToString().c_str());
LogPrint("gatewayscc-1","f.%c M.%d of N.%d size.%d -> %s\n",f,M,N,(int32_t)gatewaypubkeys.size(),depositaddr);
LOGSTREAM("gatewayscc", CCLOG_DEBUG1, stream << "f." << f << " M." << M << " of N." << N << " size." << (int32_t)gatewaypubkeys.size() << " -> " << depositaddr << std::endl);
} else Getscriptaddress(depositaddr,CScript() << ParseHex(HexStr(gatewaypubkeys[0])) << OP_CHECKSIG);
}
else
@@ -194,7 +194,7 @@ uint8_t DecodeGatewaysBindOpRet(char *depositaddr,const CScript &scriptPubKey,ui
else GetCustomscriptaddress(depositaddr,CScript() << ParseHex(HexStr(gatewaypubkeys[0])) << OP_CHECKSIG,taddr,prefix,prefix2);
}
return(f);
} else LogPrint("gatewayscc-1","error decoding bind opret\n");
} else LOGSTREAM("gatewayscc",CCLOG_DEBUG1, stream << "error decoding bind opret" << std::endl);
return(0);
}
@@ -381,15 +381,15 @@ bool GatewaysExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransacti
numvouts = tx.vout.size();
for (i=0; i<numvins; i++)
{
//LogPrint("gatewayscc","vini.%d\n",i);
LOGSTREAM("gatewayscc",CCLOG_DEBUG2, stream << "vini." << i << std::endl);
if ( (*cp->ismyvin)(tx.vin[i].scriptSig) != 0 )
{
//LogPrint("gatewayscc","vini.%d check mempool\n",i);
LOGSTREAM("gatewayscc",CCLOG_DEBUG2, stream << "vini." << i << " check mempool" << std::endl);
if ( eval->GetTxUnconfirmed(tx.vin[i].prevout.hash,vinTx,hashBlock) == 0 )
return eval->Invalid("cant find vinTx");
else
{
//LogPrint("gatewayscc","vini.%d check hash and vout\n",i);
LOGSTREAM("gatewayscc",CCLOG_DEBUG2, stream << "vini." << i << " check hash and vout" << std::endl);
if ( hashBlock == zerohash )
return eval->Invalid("cant Gateways from mempool");
if ( (assetoshis= IsGatewaysvout(cp,vinTx,tx.vin[i].prevout.n)) != 0 )
@@ -399,13 +399,13 @@ bool GatewaysExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransacti
}
for (i=0; i<numvouts; i++)
{
//LogPrint("gatewayscc","i.%d of numvouts.%d\n",i,numvouts);
LOGSTREAM("gatewayscc",CCLOG_DEBUG2, stream << "i." << i << " of numvouts." << numvouts << std::endl);
if ( (assetoshis= IsGatewaysvout(cp,tx,i)) != 0 )
outputs += assetoshis;
}
if ( inputs != outputs+txfee )
{
LogPrint("gatewayscc","inputs %llu vs outputs %llu\n",(long long)inputs,(long long)outputs);
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << "inputs " << (long long)inputs << " vs outputs " << (long long)outputs << std::endl);
return eval->Invalid("mismatched inputs != outputs + txfee");
}
else return(true);
@@ -425,7 +425,7 @@ static int32_t myIs_coinaddr_inmempoolvout(char *coinaddr)
Getscriptaddress(destaddr,tx.vout[i].scriptPubKey);
if ( strcmp(destaddr,coinaddr) == 0 )
{
LogPrint("gatewayscc-1","found (%s) vout in mempool\n",coinaddr);
LOGSTREAM("gatewayscc",CCLOG_DEBUG1, stream << "found (" << coinaddr << ") vout in mempool" << std::endl);
return(1);
}
}
@@ -438,36 +438,35 @@ uint256 GatewaysReverseScan(uint256 &txid,int32_t height,uint256 reforacletxid,u
{
CTransaction tx; uint256 hash,mhash,bhash,hashBlock,oracletxid; int32_t len,len2,numvouts; int64_t val,merkleht; CPubKey pk; std::vector<uint8_t>data;
txid = zeroid;
char str[65];
LogPrint("gatewayscc-2","start reverse scan %s\n",uint256_str(str,batontxid));
LOGSTREAM("gatewayscc",CCLOG_DEBUG2, stream << "start reverse scan " << batontxid.GetHex() << std::endl);
while ( myGetTransaction(batontxid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 0 )
{
LogPrint("gatewayscc-2","check %s\n",uint256_str(str,batontxid));
LOGSTREAM("gatewayscc",CCLOG_DEBUG2, stream << "check " << batontxid.GetHex() << std::endl);
if ( DecodeOraclesData(tx.vout[numvouts-1].scriptPubKey,oracletxid,bhash,pk,data) == 'D' && oracletxid == reforacletxid )
{
LogPrint("gatewayscc-2","decoded %s\n",uint256_str(str,batontxid));
LOGSTREAM("gatewayscc",CCLOG_DEBUG2, stream << "decoded " << batontxid.GetHex() << std::endl);
if ( oracle_format(&hash,&merkleht,0,'I',(uint8_t *)data.data(),0,(int32_t)data.size()) == sizeof(int32_t) && merkleht == height )
{
len = oracle_format(&hash,&val,0,'h',(uint8_t *)data.data(),sizeof(int32_t),(int32_t)data.size());
len2 = oracle_format(&mhash,&val,0,'h',(uint8_t *)data.data(),(int32_t)(sizeof(int32_t)+sizeof(uint256)),(int32_t)data.size());
char str2[65]; LogPrint("gatewayscc","found merkleht.%d len.%d len2.%d %s %s\n",(int32_t)merkleht,len,len2,uint256_str(str,hash),uint256_str(str2,mhash));
LOGSTREAM("gatewayscc",CCLOG_DEBUG1, stream << "found merkleht." << (int32_t)merkleht << " len." << len << " len2." << len2 << " " << hash.GetHex() << " " << mhash.GetHex() << std::endl);
if ( len == sizeof(hash)+sizeof(int32_t) && len2 == 2*sizeof(mhash)+sizeof(int32_t) && mhash != zeroid )
{
txid = batontxid;
LogPrint("gatewayscc-2","set txid\n");
LOGSTREAM("gatewayscc",CCLOG_DEBUG2, stream << "set txid" << std::endl);
return(mhash);
}
else
{
LogPrint("gatewayscc-2","missing hash\n");
LOGSTREAM("gatewayscc",CCLOG_DEBUG2, stream << "missing hash" << std::endl);
return(zeroid);
}
} else LogPrint("gatewayscc-2","height.%d vs search ht.%d\n",(int32_t)merkleht,(int32_t)height);
} else LOGSTREAM("gatewayscc",CCLOG_DEBUG2, stream << "height." << (int32_t)merkleht << " vs search ht." << (int32_t)height << std::endl);
batontxid = bhash;
LogPrint("gatewayscc-2","new hash %s\n",uint256_str(str,batontxid));
LOGSTREAM("gatewayscc",CCLOG_DEBUG2, stream << "new hash " << batontxid.GetHex() << std::endl);
} else break;
}
LogPrint("gatewayscc-2","end of loop\n");
LOGSTREAM("gatewayscc",CCLOG_DEBUG2, stream << "end of loop\n");
return(zeroid);
}
@@ -500,27 +499,27 @@ uint256 BitcoinGetProofMerkleRoot(const std::vector<uint8_t> &proofData, std::ve
int64_t GatewaysVerify(char *refdepositaddr,uint256 oracletxid,int32_t claimvout,std::string refcoin,uint256 cointxid,const std::string deposithex,std::vector<uint8_t>proof,uint256 merkleroot,CPubKey destpub,uint8_t taddr,uint8_t prefix,uint8_t prefix2)
{
std::vector<uint256> txids; uint256 proofroot,hashBlock,txid = zeroid; CTransaction tx; std::string name,description,format;
char destaddr[64],destpubaddr[64],claimaddr[64],str[65],str2[65]; int32_t i,numvouts; int64_t nValue = 0;
char destaddr[64],destpubaddr[64],claimaddr[64]; int32_t i,numvouts; int64_t nValue = 0;
if ( myGetTransaction(oracletxid,tx,hashBlock) == 0 || (numvouts= tx.vout.size()) <= 0 )
{
LogPrint("gatewayscc","GatewaysVerify cant find oracletxid %s\n",uint256_str(str,oracletxid));
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << "GatewaysVerify cant find oracletxid " << oracletxid.GetHex() << std::endl);
return(0);
}
if ( DecodeOraclesCreateOpRet(tx.vout[numvouts-1].scriptPubKey,name,description,format) != 'C' || name != refcoin )
{
LogPrint("gatewayscc","GatewaysVerify mismatched oracle name %s != %s\n",name.c_str(),refcoin.c_str());
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << "GatewaysVerify mismatched oracle name " << name << " != " << refcoin << std::endl);
return(0);
}
proofroot = BitcoinGetProofMerkleRoot(proof,txids);
if ( proofroot != merkleroot )
{
LogPrint("gatewayscc","GatewaysVerify mismatched merkleroot %s != %s\n",uint256_str(str,proofroot),uint256_str(str2,merkleroot));
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << "GatewaysVerify mismatched merkleroot " << proofroot.GetHex() << " != " << merkleroot.GetHex() << std::endl);
return(0);
}
if (std::find(txids.begin(), txids.end(), cointxid) == txids.end())
{
LogPrint("gatewayscc", "GatewaysVerify invalid proof for this cointxid\n");
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << "GatewaysVerify invalid proof for this cointxid" << std::endl);
return 0;
}
if ( DecodeHexTx(tx,deposithex) != 0 )
@@ -541,10 +540,10 @@ int64_t GatewaysVerify(char *refdepositaddr,uint256 oracletxid,int32_t claimvout
}
if ( txid == cointxid )
{
LogPrint("gatewayscc-1","verified proof for cointxid in merkleroot\n");
LOGSTREAM("gatewayscc",CCLOG_DEBUG1, stream << "verified proof for cointxid in merkleroot" << std::endl);
return(nValue);
} else LogPrint("gatewayscc","(%s) != (%s) or txid %s mismatch.%d or script mismatch\n",refdepositaddr,destaddr,uint256_str(str,txid),txid != cointxid);
} else LogPrint("gatewayscc","claimaddr.(%s) != destpubaddr.(%s)\n",claimaddr,destpubaddr);
} else LOGSTREAM("gatewayscc",CCLOG_INFO, stream << "(" << refdepositaddr << ") != (" << destaddr << ") or txid " << txid.GetHex() << " mismatch." << (txid!=cointxid) << " or script mismatch" << std::endl);
} else LOGSTREAM("gatewayscc",CCLOG_INFO, stream << "claimaddr." << claimaddr << " != destpubaddr." << destpubaddr << std::endl);
}
return(0);
}
@@ -578,7 +577,7 @@ int32_t GatewaysBindExists(struct CCcontract_info *cp,CPubKey gatewayspk,uint256
{
if ( tokenid == reftokenid )
{
LogPrint("gatewayscc","trying to bind an existing tokenid\n");
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << "trying to bind an existing tokenid" << std::endl);
return(1);
}
}
@@ -876,7 +875,7 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction &
}
retval = PreventCC(eval,tx,preventCCvins,numvins,preventCCvouts,numvouts);
if ( retval != 0 )
LogPrint("gatewayscc","Gateways tx validated\n");
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << "Gateways tx validated" << std::endl);
else fprintf(stderr,"Gateways tx invalid\n");
return(retval);
// }
@@ -900,7 +899,7 @@ int64_t AddGatewaysInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP
GetTokensCCaddress(cp,coinaddr,pk);
SetCCunspents(unspentOutputs,coinaddr);
threshold = total/(maxinputs+1);
LogPrint("gatewayscc-1","check %s for gateway inputs\n",coinaddr);
LOGSTREAM("gatewayscc",CCLOG_DEBUG1, stream << "check " << coinaddr << " for gateway inputs" << std::endl);
for (std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++)
{
txid = it->first.txhash;
@@ -935,9 +934,9 @@ int64_t AddGatewaysInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP
}
return(totalinputs);
}
else LogPrint("gatewayscc","invalid GatewaysBind\n");
else LOGSTREAM("gatewayscc",CCLOG_INFO, stream << "invalid GatewaysBind" << std::endl);
}
else LogPrint("gatewayscc","can't find GatewaysBind txid\n");
else LOGSTREAM("gatewayscc",CCLOG_INFO, stream << "can't find GatewaysBind txid" << std::endl);
return(0);
}
@@ -963,18 +962,18 @@ std::string GatewaysBind(uint64_t txfee,std::string coin,uint256 tokenid,int64_t
prefix2 = p2;
wiftype = p3;
taddr = p4;
LogPrint("gatewayscc-1","set prefix %d, prefix2 %d, wiftype %d, taddr %d for %s\n",prefix,prefix2,wiftype,taddr,coin.c_str());
LOGSTREAM("gatewayscc",CCLOG_DEBUG1, stream << "set prefix " << prefix << ", prefix2 " << prefix2 << ", wiftype " << wiftype << ", taddr " << taddr << " for " << coin << std::endl);
}
if ( N == 0 || N > 15 || M > N )
{
CCerror = strprintf("illegal M.%d or N.%d",M,N);
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
if ( pubkeys.size() != N )
{
CCerror = strprintf("M.%d N.%d but pubkeys[%d]",M,N,(int32_t)pubkeys.size());
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
for (i=0; i<N; i++)
@@ -983,7 +982,7 @@ std::string GatewaysBind(uint64_t txfee,std::string coin,uint256 tokenid,int64_t
if ( CCaddress_balance(coinaddr) == 0 )
{
CCerror = strprintf("M.%d N.%d but pubkeys[%d] has no balance",M,N,i);
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
}
@@ -995,43 +994,43 @@ std::string GatewaysBind(uint64_t txfee,std::string coin,uint256 tokenid,int64_t
if ( _GetCCaddress(destaddr,EVAL_GATEWAYS,gatewayspk) == 0 )
{
CCerror = strprintf("Gateway bind.%s (%s) cant create globaladdr",coin.c_str(),uint256_str(str,tokenid));
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
if ( (fullsupply=CCfullsupply(tokenid)) != totalsupply )
{
CCerror = strprintf("Gateway bind.%s (%s) globaladdr.%s totalsupply %.8f != fullsupply %.8f",coin.c_str(),uint256_str(str,tokenid),cp->unspendableCCaddr,(double)totalsupply/COIN,(double)fullsupply/COIN);
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
if ( CCtoken_balance(myTokenCCaddr,tokenid) != totalsupply )
{
CCerror = strprintf("token balance on %s %.8f != %.8f",myTokenCCaddr,(double)CCtoken_balance(myTokenCCaddr,tokenid)/COIN,(double)totalsupply/COIN);
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
if ( GetTransaction(oracletxid,oracletx,hashBlock,false) == 0 || (numvouts= oracletx.vout.size()) <= 0 )
{
CCerror = strprintf("cant find oracletxid %s",uint256_str(str,oracletxid));
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
if ( DecodeOraclesCreateOpRet(oracletx.vout[numvouts-1].scriptPubKey,name,description,format) != 'C' )
{
CCerror = strprintf("mismatched oracle name %s != %s",name.c_str(),coin.c_str());
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
if ( (fstr=(char *)format.c_str()) == 0 || strncmp(fstr,"Ihh",3) != 0 )
{
CCerror = strprintf("illegal format (%s) != (%s)",fstr,(char *)"Ihh");
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
if ( GatewaysBindExists(cp,gatewayspk,tokenid) != 0 )
{
CCerror = strprintf("Gateway bind.%s (%s) already exists",coin.c_str(),uint256_str(str,tokenid));
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
if ( AddNormalinputs(mtx,mypk,2*txfee,3) > 0 )
@@ -1044,7 +1043,7 @@ std::string GatewaysBind(uint64_t txfee,std::string coin,uint256 tokenid,int64_t
}
}
CCerror = strprintf("cant find enough inputs");
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
@@ -1059,30 +1058,31 @@ std::string GatewaysDeposit(uint64_t txfee,uint256 bindtxid,int32_t height,std::
if ( txfee == 0 )
txfee = 10000;
mypk = pubkey2pk(Mypubkey());
LogPrint("gatewayscc-1","GatewaysDeposit ht.%d %s %.8f numpks.%d\n",height,refcoin.c_str(),(double)amount/COIN,(int32_t)pubkeys.size());
LOGSTREAM("gatewayscc",CCLOG_DEBUG1, stream << "GatewaysDeposit ht." << height << " " << refcoin << " " << (double)amount/COIN << " numpks." << (int32_t)pubkeys.size() << std::endl);
if ( GetTransaction(bindtxid,bindtx,hashBlock,false) == 0 || (numvouts= bindtx.vout.size()) <= 0 )
{
CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid));
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
if ( DecodeGatewaysBindOpRet(depositaddr,bindtx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 'B' || refcoin != coin )
{
CCerror = strprintf("invalid coin - bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str());
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
if (komodo_txnotarizedconfirmed(bindtxid)==false)
{
CCerror = strprintf("gatewaysbind tx not yet confirmed/notarized");
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
n = (int32_t)pubkeys.size();
merkleroot = zeroid;
for (i=m=0; i<n; i++)
{
LogPrint("gatewayscc","pubkeys[%d] %s\n",i,pubkey33_str(str,(uint8_t *)&pubkeys[i]));
pubkey33_str(str,(uint8_t *)&pubkeys[i]);
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << "pubkeys[" << i << "] " << str << std::endl);
if ( (mhash= GatewaysReverseScan(txid,height,oracletxid,OraclesBatontxid(oracletxid,pubkeys[i]))) != zeroid )
{
if ( merkleroot == zeroid )
@@ -1093,23 +1093,23 @@ std::string GatewaysDeposit(uint64_t txfee,uint256 bindtxid,int32_t height,std::
txids.push_back(txid);
}
}
LogPrint("gatewayscc","cointxid.%s m.%d of n.%d\n",uint256_str(str,cointxid),m,n);
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << "cointxid." << cointxid.GetHex() << " m." << m << " of n." << n << std::endl);
if ( merkleroot == zeroid || m < n/2 )
{
CCerror = strprintf("couldnt find merkleroot for ht.%d %s oracle.%s m.%d vs n.%d",height,coin.c_str(),uint256_str(str,oracletxid),m,n);
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
if ( GatewaysCointxidExists(cp,cointxid) != 0 )
{
CCerror = strprintf("cointxid.%s already exists",uint256_str(str,cointxid));
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
if ( GatewaysVerify(depositaddr,oracletxid,claimvout,coin,cointxid,deposithex,proof,merkleroot,destpub,taddr,prefix,prefix2) != amount )
{
CCerror = strprintf("deposittxid didnt validate");
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
if ( AddNormalinputs(mtx,mypk,3*txfee,4) > 0 )
@@ -1119,7 +1119,7 @@ std::string GatewaysDeposit(uint64_t txfee,uint256 bindtxid,int32_t height,std::
return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeGatewaysDepositOpRet('D',bindtxid,coin,publishers,txids,height,cointxid,claimvout,deposithex,proof,destpub,amount)));
}
CCerror = strprintf("cant find enough inputs");
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
@@ -1139,49 +1139,49 @@ std::string GatewaysClaim(uint64_t txfee,uint256 bindtxid,std::string refcoin,ui
if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 )
{
CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid));
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2,wiftype) != 'B' || coin != refcoin )
{
CCerror = strprintf("invalid coin - bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str());
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
if (komodo_txnotarizedconfirmed(bindtxid)==false)
{
CCerror = strprintf("gatewaysbind tx not yet confirmed/notarized");
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
if ( GetTransaction(deposittxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 )
{
CCerror = strprintf("cant find deposittxid %s",uint256_str(str,bindtxid));
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
if (DecodeGatewaysDepositOpRet(tx.vout[numvouts-1].scriptPubKey,tmptxid,coin,publishers,txids,height,cointxid,claimvout,deposithex,proof,tmpdestpub,tmpamount) != 'D' || coin != refcoin)
{
CCerror = strprintf("invalid coin - deposittxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str());
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
if (komodo_txnotarizedconfirmed(deposittxid)==false)
{
CCerror = strprintf("gatewaysdeposit tx not yet confirmed/notarized");
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
if (tmpdestpub!=destpub)
{
CCerror = strprintf("different destination pubkey from desdeposit tx");
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
if ( (depositamount=GatewaysDepositval(tx,mypk)) != amount )
{
CCerror = strprintf("invalid Gateways deposittxid %s %.8f != %.8f",uint256_str(str,deposittxid),(double)depositamount/COIN,(double)amount/COIN);
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
if ( AddNormalinputs(mtx,mypk,txfee,3) > 0 )
@@ -1196,7 +1196,7 @@ std::string GatewaysClaim(uint64_t txfee,uint256 bindtxid,std::string refcoin,ui
}
}
CCerror = strprintf("cant find enough inputs or mismatched total");
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
@@ -1218,19 +1218,19 @@ std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin
if( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 )
{
CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid));
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
if( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2,wiftype) != 'B' || coin != refcoin )
{
CCerror = strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str());
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
if (komodo_txnotarizedconfirmed(bindtxid)==false)
{
CCerror = strprintf("gatewaysbind tx not yet confirmed/notarized");
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
_GetCCaddress(coinaddr,EVAL_GATEWAYS,gatewayspk);
@@ -1248,7 +1248,7 @@ std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin
&& refcoin==coin && tmptokenid==tokenid && tmpbindtxid==bindtxid)
{
CCerror = strprintf("unable to create withdraw, another withdraw pending");
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
@@ -1257,7 +1257,7 @@ std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin
&& refcoin==coin && tmptokenid==tokenid && tmpbindtxid==bindtxid)
{
CCerror = strprintf("unable to create withdraw, another withdraw pending");
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
}
@@ -1275,12 +1275,12 @@ std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin
else
{
CCerror = strprintf("not enough balance of tokens for withdraw");
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
}
CCerror = strprintf("cant find enough normal inputs");
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
@@ -1301,7 +1301,7 @@ std::string GatewaysPartialSign(uint64_t txfee,uint256 lasttxid,std::string refc
|| (funcid=DecodeGatewaysOpRet(tx.vout[numvouts-1].scriptPubKey))==0 || (funcid!='W' && funcid!='P'))
{
CCerror = strprintf("can't find last tx %s",uint256_str(str,lasttxid));
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
if (funcid=='W')
@@ -1310,26 +1310,26 @@ std::string GatewaysPartialSign(uint64_t txfee,uint256 lasttxid,std::string refc
if (DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,coin,withdrawpub,amount)!='W' || refcoin!=coin)
{
CCerror = strprintf("invalid withdraw tx %s",uint256_str(str,lasttxid));
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
else if (komodo_txnotarizedconfirmed(withdrawtxid)==false)
{
CCerror = strprintf("gatewayswithdraw tx not yet confirmed/notarized");
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
else if (GetTransaction(bindtxid,tmptx,hashBlock,false)==0 || (numvouts=tmptx.vout.size())<=0)
{
CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid));
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
else if (DecodeGatewaysBindOpRet(depositaddr,tmptx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 'B'
|| refcoin!=coin || tokenid!=tmptokenid)
{
CCerror = strprintf("invalid bind tx %s",uint256_str(str,bindtxid));
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
}
@@ -1338,39 +1338,39 @@ std::string GatewaysPartialSign(uint64_t txfee,uint256 lasttxid,std::string refc
if (DecodeGatewaysPartialOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,signerpk,tmphex)!='P' || refcoin!=coin)
{
CCerror = strprintf("cannot decode partialsign tx opret %s",uint256_str(str,lasttxid));
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
else if (GetTransaction(withdrawtxid,tmptx,hashBlock,false)==0 || (numvouts= tmptx.vout.size())<=0)
{
CCerror = strprintf("can't find withdraw tx %s",uint256_str(str,withdrawtxid));
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
else if (DecodeGatewaysWithdrawOpRet(tmptx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,coin,withdrawpub,amount)!='W'
|| refcoin!=coin)
{
CCerror = strprintf("invalid withdraw tx %s",uint256_str(str,lasttxid));
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
else if (komodo_txnotarizedconfirmed(withdrawtxid)==false)
{
CCerror = strprintf("gatewayswithdraw tx not yet confirmed/notarized");
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
else if (GetTransaction(bindtxid,tmptx,hashBlock,false)==0 || (numvouts=tmptx.vout.size())<=0)
{
CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid));
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
else if (DecodeGatewaysBindOpRet(depositaddr,tmptx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 'B'
|| refcoin!=coin || tokenid!=tmptokenid)
{
CCerror = strprintf("invalid bind tx %s",uint256_str(str,bindtxid));
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
}
@@ -1381,7 +1381,7 @@ std::string GatewaysPartialSign(uint64_t txfee,uint256 lasttxid,std::string refc
return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeGatewaysPartialOpRet('P',withdrawtxid,refcoin,K+1,mypk,hex)));
}
CCerror = strprintf("error adding funds for partialsign");
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
@@ -1401,7 +1401,7 @@ std::string GatewaysCompleteSigning(uint64_t txfee,uint256 lasttxid,std::string
|| (funcid=DecodeGatewaysOpRet(tx.vout[numvouts-1].scriptPubKey))==0 || (funcid!='W' && funcid!='P'))
{
CCerror = strprintf("invalid last txid %s",uint256_str(str,lasttxid));
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
if (funcid=='W')
@@ -1410,26 +1410,26 @@ std::string GatewaysCompleteSigning(uint64_t txfee,uint256 lasttxid,std::string
if (DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,coin,withdrawpub,amount)!='W' || refcoin!=coin)
{
CCerror = strprintf("cannot decode withdraw tx opret %s",uint256_str(str,lasttxid));
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
else if (GetTransaction(bindtxid,tmptx,hashBlock,false)==0 || (numvouts=tmptx.vout.size())<=0)
{
CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid));
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
else if (komodo_txnotarizedconfirmed(withdrawtxid)==false)
{
CCerror = strprintf("gatewayswithdraw tx not yet confirmed/notarized");
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
else if (DecodeGatewaysBindOpRet(depositaddr,tmptx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 'B'
|| refcoin!=coin || tokenid!=tmptokenid)
{
CCerror = strprintf("invalid bind tx %s",uint256_str(str,bindtxid));
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
}
@@ -1438,38 +1438,38 @@ std::string GatewaysCompleteSigning(uint64_t txfee,uint256 lasttxid,std::string
if (DecodeGatewaysPartialOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,signerpk,tmphex)!='P' || refcoin!=coin)
{
CCerror = strprintf("cannot decode partialsign tx opret %s",uint256_str(str,lasttxid));
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
else if (GetTransaction(withdrawtxid,tmptx,hashBlock,false)==0 || (numvouts=tmptx.vout.size())==0)
{
CCerror = strprintf("invalid withdraw txid %s",uint256_str(str,withdrawtxid));
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
else if (DecodeGatewaysWithdrawOpRet(tmptx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,coin,withdrawpub,amount)!='W' || refcoin!=coin)
{
CCerror = strprintf("cannot decode withdraw tx opret %s",uint256_str(str,withdrawtxid));
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
else if (komodo_txnotarizedconfirmed(withdrawtxid)==false)
{
CCerror = strprintf("gatewayswithdraw tx not yet confirmed/notarized");
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
else if (GetTransaction(bindtxid,tmptx,hashBlock,false)==0 || (numvouts=tmptx.vout.size())<=0)
{
CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid));
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
else if (DecodeGatewaysBindOpRet(depositaddr,tmptx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 'B'
|| refcoin!=coin || tokenid!=tmptokenid)
{
CCerror = strprintf("invalid bind tx %s",uint256_str(str,bindtxid));
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
}
@@ -1480,7 +1480,7 @@ std::string GatewaysCompleteSigning(uint64_t txfee,uint256 lasttxid,std::string
return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeGatewaysCompleteSigningOpRet('S',withdrawtxid,refcoin,K+1,hex)));
}
CCerror = strprintf("error adding funds for completesigning");
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
@@ -1498,44 +1498,44 @@ std::string GatewaysMarkDone(uint64_t txfee,uint256 completetxid,std::string ref
if (GetTransaction(completetxid,tx,hashBlock,false)==0 || (numvouts= tx.vout.size())<=0)
{
CCerror = strprintf("invalid completesigning txid %s",uint256_str(str,completetxid));
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
else if (DecodeGatewaysCompleteSigningOpRet(tx.vout[numvouts-1].scriptPubKey,withdrawtxid,coin,K,hex)!='S' || refcoin!=coin)
{
CCerror = strprintf("cannot decode completesigning tx opret %s",uint256_str(str,completetxid));
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
if (komodo_txnotarizedconfirmed(completetxid)==false)
{
CCerror = strprintf("gatewayscompletesigning tx not yet confirmed/notarized");
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
else if (GetTransaction(withdrawtxid,tx,hashBlock,false)==0 || (numvouts= tx.vout.size())==0)
{
CCerror = strprintf("invalid withdraw txid %s",uint256_str(str,withdrawtxid));
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
else if (DecodeGatewaysWithdrawOpRet(tx.vout[numvouts-1].scriptPubKey,tmptokenid,bindtxid,coin,withdrawpub,amount)!='W' || refcoin!=coin)
{
CCerror = strprintf("cannot decode withdraw tx opret %s\n",uint256_str(str,withdrawtxid));
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
else if (GetTransaction(bindtxid,tx,hashBlock,false)==0 || (numvouts=tx.vout.size())<=0)
{
CCerror = strprintf("can't find bind tx %s",uint256_str(str,bindtxid));
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
else if (DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 'B'
|| refcoin!=coin || tokenid!=tmptokenid)
{
CCerror = strprintf("invalid bind tx %s",uint256_str(str,bindtxid));
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
if (AddNormalinputs(mtx,mypk,txfee,3)!=0)
@@ -1545,7 +1545,7 @@ std::string GatewaysMarkDone(uint64_t txfee,uint256 completetxid,std::string ref
return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeGatewaysMarkDoneOpRet('M',withdrawtxid,refcoin,completetxid)));
}
CCerror = strprintf("error adding funds for markdone");
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
@@ -1565,13 +1565,13 @@ UniValue GatewaysPendingDeposits(uint256 bindtxid,std::string refcoin)
if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 )
{
CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid));
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 'B' || refcoin != coin)
{
CCerror = strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str());
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
SetCCunspents(unspentOutputs,coinaddr);
@@ -1620,13 +1620,13 @@ UniValue GatewaysPendingWithdraws(uint256 bindtxid,std::string refcoin)
if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 )
{
CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid));
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2,wiftype) != 'B' || refcoin != coin )
{
CCerror = strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str());
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
n = msigpubkeys.size();
@@ -1708,13 +1708,13 @@ UniValue GatewaysProcessedWithdraws(uint256 bindtxid,std::string refcoin)
if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 )
{
CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid));
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2,wiftype) != 'B' || refcoin != coin)
{
CCerror = strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str());
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
n = msigpubkeys.size();
@@ -1786,13 +1786,13 @@ UniValue GatewaysExternalAddress(uint256 bindtxid,CPubKey pubkey)
if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 )
{
CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid));
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2,wiftype) != 'B')
{
CCerror = strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str());
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
GetCustomscriptaddress(addr,CScript() << ParseHex(HexStr(pubkey)) << OP_CHECKSIG,taddr,prefix,prefix2);
@@ -1810,13 +1810,13 @@ UniValue GatewaysDumpPrivKey(uint256 bindtxid,CKey key)
if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 )
{
CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid));
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2,wiftype) != 'B')
{
CCerror = strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str());
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
@@ -1839,13 +1839,13 @@ UniValue GatewaysInfo(uint256 bindtxid)
if ( GetTransaction(bindtxid,tx,hashBlock,false) == 0 || (numvouts= tx.vout.size()) <= 0 )
{
CCerror = strprintf("cant find bindtxid %s",uint256_str(str,bindtxid));
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,msigpubkeys,taddr,prefix,prefix2,wiftype) != 'B')
{
CCerror = strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str());
LogPrint("gatewayscc","%s\n", CCerror.c_str() );
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return("");
}
if ( GetTransaction(bindtxid,tx,hashBlock,false) != 0 )

7
src/cc/makecustom Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/sh
gcc -O3 -DBUILD_CUSTOMCC -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o customcc.so cclib.cpp
cp customcc.so ../libcc.so
cd ..
make
cd cc

View File

@@ -344,7 +344,7 @@ over:
if (wizard)
{
wizard = FALSE;
turn_see(TRUE);
turn_see(rs,TRUE);
msg(rs,"not wizard any more");
}
else
@@ -353,7 +353,7 @@ over:
if (wizard)
{
noscore = TRUE;
turn_see(FALSE);
turn_see(rs,FALSE);
msg(rs,"you are suddenly as smart as Ken Arnold in dungeon #%d", dnum);
}
else
@@ -403,7 +403,7 @@ over:
when CTRL('T'): teleport();
when CTRL('E'): msg(rs,"food left: %d", food_left);
when CTRL('C'): add_pass();
when CTRL('X'): turn_see(on(player, SEEMONST));
when CTRL('X'): turn_see(rs,on(player, SEEMONST));
when CTRL('~'):
{
THING *item;
@@ -455,7 +455,7 @@ over:
if (!running)
door_stop = FALSE;
}
/*
/*
* If he ran into something to take, let him pick it up.
*/
if (take != 0)

View File

@@ -160,10 +160,43 @@ extinguish(void (*func)(struct rogue_state *rs,int))
* do_fuses:
* Decrement counters and start needed fuses
*/
/*char *actionfunc_str(char *str,void *ptr)
{
if ( ptr == (void *)runners )
strcpy(str,"runners");
else if ( ptr == (void *)doctor )
strcpy(str,"doctor");
else if ( ptr == (void *)stomach )
strcpy(str,"stomach");
else if ( ptr == (void *)nohaste )
strcpy(str,"nohaste");
else if ( ptr == (void *)unconfuse )
strcpy(str,"unconfuse");
else if ( ptr == (void *)swander )
strcpy(str,"swander");
else if ( ptr == (void *)come_down )
strcpy(str,"come_down");
else if ( ptr == (void *)unsee )
strcpy(str,"unsee");
else if ( ptr == (void *)sight )
strcpy(str,"sight");
else if ( ptr == (void *)land )
strcpy(str,"land");
else if ( ptr == (void *)rollwand )
strcpy(str,"rollwand");
else if ( ptr == (void *)visuals )
strcpy(str,"visuals");
else if ( ptr == (void *)turn_see )
strcpy(str,"turn_see");
else strcpy(str,"no match");
return(str);
}*/
void
do_fuses(struct rogue_state *rs,int flag)
{
register struct delayed_action *wire;
register struct delayed_action *wire; char str[64];
/*
* Step though the list
@@ -175,6 +208,8 @@ do_fuses(struct rogue_state *rs,int flag)
*/
if (flag == wire->d_type && wire->d_time > 0 && --wire->d_time == 0)
{
//if ( fp != 0 )
// fprintf(fp,"t.%d %d %s, ",wire->d_type,wire->d_time,actionfunc_str(str,wire->d_func));
wire->d_type = EMPTY;
(*wire->d_func)(rs,wire->d_arg);
}

View File

@@ -21,6 +21,8 @@ void
doctor(struct rogue_state *rs,int arg)
{
register int lv, ohp;
if ( rs->logfp != 0 )
fprintf(rs->logfp,"doctor\n");
lv = pstats.s_lvl;
ohp = pstats.s_hpt;
@@ -52,6 +54,8 @@ doctor(struct rogue_state *rs,int arg)
void
swander(struct rogue_state *rs,int arg)
{
if ( rs->logfp != 0 )
fprintf(rs->logfp,"swander\n");
start_daemon(rollwand, 0, BEFORE);
}
@@ -63,6 +67,8 @@ int between = 0;
void
rollwand(struct rogue_state *rs,int arg)
{
if ( rs->logfp != 0 )
fprintf(rs->logfp,"rollwand\n");
if (++between >= 4)
{
if (roll(1, 6) == 4)
@@ -82,6 +88,8 @@ rollwand(struct rogue_state *rs,int arg)
void
unconfuse(struct rogue_state *rs,int arg)
{
if ( rs->logfp != 0 )
fprintf(rs->logfp,"unconfuse\n");
player.t_flags &= ~ISHUH;
msg(rs,"you feel less %s now", choose_str("trippy", "confused"));
}
@@ -94,6 +102,8 @@ void
unsee(struct rogue_state *rs,int arg)
{
register THING *th;
if ( rs->logfp != 0 )
fprintf(rs->logfp,"unsee\n");
for (th = mlist; th != NULL; th = next(th))
if (on(*th, ISINVIS) && see_monst(th))
@@ -108,6 +118,8 @@ unsee(struct rogue_state *rs,int arg)
void
sight(struct rogue_state *rs,int arg)
{
if ( rs->logfp != 0 )
fprintf(rs->logfp,"sight\n");
if (on(player, ISBLIND))
{
extinguish(sight);
@@ -126,6 +138,8 @@ sight(struct rogue_state *rs,int arg)
void
nohaste(struct rogue_state *rs,int arg)
{
if ( rs->logfp != 0 )
fprintf(rs->logfp,"nohaste\n");
player.t_flags &= ~ISHASTE;
msg(rs,"you feel yourself slowing down");
}
@@ -139,6 +153,8 @@ stomach(struct rogue_state *rs,int arg)
{
register int oldfood;
int orig_hungry = hungry_state;
if ( rs->logfp != 0 )
fprintf(rs->logfp,"stomach\n");
if (food_left <= 0)
{
@@ -194,41 +210,43 @@ come_down(struct rogue_state *rs,int arg)
{
register THING *tp;
register bool seemonst;
if ( rs->logfp != 0 )
fprintf(rs->logfp,"come_down\n");
if (!on(player, ISHALU))
return;
return;
kill_daemon(visuals);
player.t_flags &= ~ISHALU;
if (on(player, ISBLIND))
return;
return;
/*
* undo the things
*/
for (tp = lvl_obj; tp != NULL; tp = next(tp))
if (cansee(rs,tp->o_pos.y, tp->o_pos.x))
mvaddch(tp->o_pos.y, tp->o_pos.x, tp->o_type);
if (cansee(rs,tp->o_pos.y, tp->o_pos.x))
mvaddch(tp->o_pos.y, tp->o_pos.x, tp->o_type);
/*
* undo the monsters
*/
seemonst = on(player, SEEMONST);
for (tp = mlist; tp != NULL; tp = next(tp))
{
move(tp->t_pos.y, tp->t_pos.x);
if (cansee(rs,tp->t_pos.y, tp->t_pos.x))
if (!on(*tp, ISINVIS) || on(player, CANSEE))
addch(tp->t_disguise);
else
addch(chat(tp->t_pos.y, tp->t_pos.x));
else if (seemonst)
{
standout();
addch(tp->t_type);
standend();
}
move(tp->t_pos.y, tp->t_pos.x);
if (cansee(rs,tp->t_pos.y, tp->t_pos.x))
if (!on(*tp, ISINVIS) || on(player, CANSEE))
addch(tp->t_disguise);
else
addch(chat(tp->t_pos.y, tp->t_pos.x));
else if (seemonst)
{
standout();
addch(tp->t_type);
standend();
}
}
msg(rs,"Everything looks SO boring now.");
}
@@ -242,42 +260,44 @@ visuals(struct rogue_state *rs,int arg)
{
register THING *tp;
register bool seemonst;
if (!after || (running && jump))
return;
return;
if ( rs->logfp != 0 )
fprintf(rs->logfp,"visuals\n");
/*
* change the things
*/
for (tp = lvl_obj; tp != NULL; tp = next(tp))
if (cansee(rs,tp->o_pos.y, tp->o_pos.x))
mvaddch(tp->o_pos.y, tp->o_pos.x, rnd_thing());
if (cansee(rs,tp->o_pos.y, tp->o_pos.x))
mvaddch(tp->o_pos.y, tp->o_pos.x, rnd_thing());
/*
* change the stairs
*/
if (!seenstairs && cansee(rs,stairs.y, stairs.x))
mvaddch(stairs.y, stairs.x, rnd_thing());
mvaddch(stairs.y, stairs.x, rnd_thing());
/*
* change the monsters
*/
seemonst = on(player, SEEMONST);
for (tp = mlist; tp != NULL; tp = next(tp))
{
move(tp->t_pos.y, tp->t_pos.x);
if (see_monst(tp))
{
if (tp->t_type == 'X' && tp->t_disguise != 'X')
addch(rnd_thing());
else
addch(rnd(26) + 'A');
}
else if (seemonst)
{
standout();
addch(rnd(26) + 'A');
standend();
}
move(tp->t_pos.y, tp->t_pos.x);
if (see_monst(tp))
{
if (tp->t_type == 'X' && tp->t_disguise != 'X')
addch(rnd_thing());
else
addch(rnd(26) + 'A');
}
else if (seemonst)
{
standout();
addch(rnd(26) + 'A');
standend();
}
}
}
@@ -288,7 +308,54 @@ visuals(struct rogue_state *rs,int arg)
void
land(struct rogue_state *rs,int arg)
{
if ( rs->logfp != 0 )
fprintf(rs->logfp,"land\n");
player.t_flags &= ~ISLEVIT;
msg(rs,choose_str("bummer! You've hit the ground",
"you float gently to the ground"));
}
/*
* turn_see:
* Put on or off seeing monsters on this level
*/
bool
turn_see(struct rogue_state *rs,bool turn_off)
{
THING *mp;
bool can_see, add_new;
if ( rs->logfp != 0 )
fprintf(rs->logfp,"turn_see\n");
add_new = FALSE;
for (mp = mlist; mp != NULL; mp = next(mp))
{
move(mp->t_pos.y, mp->t_pos.x);
can_see = see_monst(mp);
if (turn_off)
{
if (!can_see)
addch(mp->t_oldch);
}
else
{
if (!can_see)
standout();
if (!on(player, ISHALU))
addch(mp->t_type);
else
addch(rnd(26) + 'A');
if (!can_see)
{
standend();
add_new ^= 1;//add_new++;
}
}
}
if (turn_off)
player.t_flags &= ~SEEMONST;
else
player.t_flags |= SEEMONST;
return add_new;
}

View File

@@ -107,6 +107,12 @@
#include <stdlib.h>
#include <time.h>
#ifdef _WIN32
#ifdef _MSC_VER
#include <stdint.h>
#endif
#endif
#undef SIGTSTP
#define MAXSTR 1024 /* maximum length of strings */
@@ -142,7 +148,8 @@ void leave(int);
void my_exit(int st);
void playltchars(void);
void quit(int);
int32_t _quit();
int32_t _quit();
void resetltchars(void);
void set_order(int *order, int numthings);
void tstp(int ignored);

View File

@@ -167,7 +167,7 @@ readchar(struct rogue_state *rs)
fp = fopen("log","wb");
if ( fp != 0 )
{
fprintf(fp,"%d: (%c) hp.%d num.%d\n",counter,c,pstats.s_hpt,num_packitems(rs));
fprintf(fp,"%d: (%c) hp.%d num.%d gold.%d seed.%llu\n",counter,c,pstats.s_hpt,num_packitems(rs),purse,(long long)seed);
fflush(fp);
counter++;
}

View File

@@ -38,6 +38,31 @@ union _bits256 { uint8_t bytes[32]; uint16_t ushorts[16]; uint32_t uints[8]; uin
typedef union _bits256 bits256;
#endif
#ifdef _WIN32
#ifdef _MSC_VER
int gettimeofday(struct timeval * tp, struct timezone * tzp)
{
// Note: some broken versions only have 8 trailing zero's, the correct epoch has 9 trailing zero's
static const uint64_t EPOCH = ((uint64_t)116444736000000000ULL);
SYSTEMTIME system_time;
FILETIME file_time;
uint64_t time;
GetSystemTime(&system_time);
SystemTimeToFileTime(&system_time, &file_time);
time = ((uint64_t)file_time.dwLowDateTime);
time += ((uint64_t)file_time.dwHighDateTime) << 32;
tp->tv_sec = (long)((time - EPOCH) / 10000000L);
tp->tv_usec = (long)(system_time.wMilliseconds * 1000);
return 0;
}
#endif // _MSC_VER
#endif
double OS_milliseconds()
{
struct timeval tv; double millis;
@@ -392,6 +417,12 @@ char *post_process_bitcoind_RPC(char *debugstr,char *command,char *rpcstr,char *
}
#endif
#ifdef _WIN32
#ifdef _MSC_VER
#define sleep(x) Sleep(1000*(x))
#endif
#endif
/************************************************************************
*
* perform the query
@@ -736,6 +767,17 @@ int32_t rogue_sendrawtransaction(char *rawtx)
}
free_json(retjson);
}
/* log sendrawtx result in file */
/*
FILE *debug_file;
debug_file = fopen("tx_debug.log", "a");
fprintf(debug_file, "%s\n", retstr);
fflush(debug_file);
fclose(debug_file);
*/
free(retstr);
}
free(params);
@@ -899,9 +941,46 @@ int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr)
return(retval);
}
#ifdef _WIN32
#ifdef _MSC_VER
__inline int msver(void) {
switch (_MSC_VER) {
case 1500: return 2008;
case 1600: return 2010;
case 1700: return 2012;
case 1800: return 2013;
case 1900: return 2015;
//case 1910: return 2017;
default: return (_MSC_VER / 100);
}
}
static inline bool is_x64(void) {
#if defined(__x86_64__) || defined(_WIN64) || defined(__aarch64__)
return 1;
#elif defined(__amd64__) || defined(__amd64) || defined(_M_X64) || defined(_M_IA64)
return 1;
#else
return 0;
#endif
}
#define BUILD_DATE __DATE__ " " __TIME__
#endif // _WIN32
#endif // _MSC_VER
int main(int argc, char **argv, char **envp)
{
uint64_t seed; FILE *fp = 0; int32_t i,j,c; char userpass[8192];
#ifdef _WIN32
#ifdef _MSC_VER
printf("*** rogue for Windows [ Build %s ] ***\n", BUILD_DATE);
const char* arch = is_x64() ? "64-bits" : "32-bits";
printf(" Built with VC++ %d (%ld) %s\n\n", msver(), _MSC_FULL_VER, arch);
#endif
#endif
for (i=j=0; argv[0][i]!=0&&j<sizeof(ASSETCHAINS_SYMBOL); i++)
{
c = argv[0][i];
@@ -913,13 +992,34 @@ int main(int argc, char **argv, char **envp)
ASSETCHAINS_SYMBOL[j++] = toupper(c);
}
ASSETCHAINS_SYMBOL[j++] = 0;
#ifdef _WIN32
#ifdef _MSC_VER
if (strncmp(ASSETCHAINS_SYMBOL, "ROGUE.EXE", sizeof(ASSETCHAINS_SYMBOL)) == 0 || strncmp(ASSETCHAINS_SYMBOL, "ROGUE54.EXE", sizeof(ASSETCHAINS_SYMBOL)) == 0) {
strcpy(ASSETCHAINS_SYMBOL, "ROGUE"); // accept ROGUE.conf, instead of ROGUE.EXE.conf or ROGUE54.EXE.conf if build with MSVC
}
#endif
#endif
ROGUE_PORT = komodo_userpass(userpass,ASSETCHAINS_SYMBOL);
if ( IPADDRESS[0] == 0 )
strcpy(IPADDRESS,"127.0.0.1");
printf("ASSETCHAINS_SYMBOL.(%s) port.%u (%s) IPADDRESS.%s \n",ASSETCHAINS_SYMBOL,ROGUE_PORT,USERPASS,IPADDRESS); sleep(1);
if ( argc == 2 && (fp=fopen(argv[1],"rb")) == 0 )
{
seed = atol(argv[1]);
#ifdef _WIN32
#ifdef _MSC_VER
seed = _strtoui64(argv[1], NULL, 10);
fprintf(stderr, "replay seed.str(%s) seed.uint64_t(%I64u)", argv[1], seed);
#else
fprintf(stderr, "replay seed.str(%s) seed.uint64_t(%llu)", argv[1], (long long)seed);
seed = atol(argv[1]); // windows, but not MSVC
#endif // _MSC_VER
#else
seed = atol(argv[1]); // non-windows
#endif // _WIN32
//fprintf(stderr,"replay %llu\n",(long long)seed);
return(rogue_replay(seed,10));
}

View File

@@ -404,18 +404,18 @@ add_haste(struct rogue_state *rs,bool potion)
{
if (on(player, ISHASTE))
{
no_command += rnd(8);
player.t_flags &= ~(ISRUN|ISHASTE);
extinguish(nohaste);
msg(rs,"you faint from exhaustion");
return FALSE;
no_command += rnd(8);
player.t_flags &= ~(ISRUN|ISHASTE);
extinguish(nohaste);
msg(rs,"you faint from exhaustion");
return FALSE;
}
else
{
player.t_flags |= ISHASTE;
if (potion)
fuse(nohaste, 0, rnd(4)+4, AFTER);
return TRUE;
player.t_flags |= ISHASTE;
if (potion)
fuse(nohaste, 0, rnd(4)+4, AFTER);
return TRUE;
}
}

View File

@@ -26,7 +26,17 @@ new_level(struct rogue_state *rs)
PLACE *pp;
char *sp;
int i;
if ( 0 )
{
static FILE *fp;
if ( fp == 0 )
fp = fopen("debug","wb");
if ( fp != 0 )
{
fprintf(fp,"newlevel seed.%llu\n",(long long)seed);
fflush(fp);
}
}
player.t_flags &= ~ISHELD; /* unhold when you go down just in case */
if (level > max_level)
max_level = level;
@@ -95,7 +105,7 @@ new_level(struct rogue_state *rs)
enter_room(rs,&hero);
mvaddch(hero.y, hero.x, PLAYER);
if (on(player, SEEMONST))
turn_see(FALSE);
turn_see(rs,FALSE);
if (on(player, ISHALU))
visuals(rs,0);
}

View File

@@ -78,7 +78,6 @@ quaff(struct rogue_state *rs)
}
if (obj == cur_weapon)
cur_weapon = NULL;
/*
* Calculate the effect it has on the poor guy.
*/
@@ -91,7 +90,7 @@ quaff(struct rogue_state *rs)
do_pot(rs,P_CONFUSE, !trip);
when P_POISON:
pot_info[P_POISON].oi_know = TRUE;
if (ISWEARING(R_SUSTSTR))
if (ISWEARING(R_SUSTSTR))
msg(rs,"you feel momentarily sick");
else
{
@@ -112,7 +111,7 @@ quaff(struct rogue_state *rs)
when P_MFIND:
player.t_flags |= SEEMONST;
fuse((void(*)(struct rogue_state *rs,int))turn_see, TRUE, HUHDURATION, AFTER);
if (!turn_see(FALSE))
if (!turn_see(rs,FALSE))
msg(rs,"you have a %s feeling for a moment, then it passes",
choose_str("normal", "strange"));
when P_TFIND:
@@ -158,7 +157,7 @@ quaff(struct rogue_state *rs)
if (!trip)
{
if (on(player, SEEMONST))
turn_see(FALSE);
turn_see(rs,FALSE);
start_daemon(visuals, 0, BEFORE);
seenstairs = seen_stairs();
}
@@ -263,47 +262,6 @@ invis_on()
mvaddch(mp->t_pos.y, mp->t_pos.x, mp->t_disguise);
}
/*
* turn_see:
* Put on or off seeing monsters on this level
*/
bool
turn_see(bool turn_off)
{
THING *mp;
bool can_see, add_new;
add_new = FALSE;
for (mp = mlist; mp != NULL; mp = next(mp))
{
move(mp->t_pos.y, mp->t_pos.x);
can_see = see_monst(mp);
if (turn_off)
{
if (!can_see)
addch(mp->t_oldch);
}
else
{
if (!can_see)
standout();
if (!on(player, ISHALU))
addch(mp->t_type);
else
addch(rnd(26) + 'A');
if (!can_see)
{
standend();
add_new ^= 1;//add_new++;
}
}
}
if (turn_off)
player.t_flags &= ~SEEMONST;
else
player.t_flags |= SEEMONST;
return add_new;
}
/*
* seen_stairs:
@@ -358,18 +316,18 @@ do_pot(struct rogue_state *rs,int type, bool knowit)
{
PACT *pp;
int t;
pp = &p_actions[type];
if (!pot_info[type].oi_know)
pot_info[type].oi_know = knowit;
pot_info[type].oi_know = knowit;
t = spread(pp->pa_time);
if (!on(player, pp->pa_flags))
{
player.t_flags |= pp->pa_flags;
fuse(pp->pa_daemon, 0, t, AFTER);
look(rs,FALSE);
player.t_flags |= pp->pa_flags;
fuse(pp->pa_daemon, 0, t, AFTER);
look(rs,FALSE);
}
else
lengthen(pp->pa_daemon, t);
lengthen(pp->pa_daemon, t);
msg(rs,choose_str(pp->pa_high, pp->pa_straight));
}

View File

@@ -13,6 +13,7 @@
#include <signal.h>
//#include <unistd.h>
//#include <curses.h>
#include "rogue.h"
#ifdef STANDALONE
#include "../komodo/src/komodo_cJSON.h"
@@ -196,6 +197,12 @@ void rogue_bailout(struct rogue_state *rs)
fprintf(stderr,"error issuing (%s)\n",cmd);*/
}
#ifdef _WIN32
#ifdef _MSC_VER
#define sleep(x) Sleep(1000*(x))
#endif
#endif
int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player,int32_t sleepmillis)
{
struct rogue_state *rs; FILE *fp; int32_t i,n;
@@ -215,6 +222,14 @@ int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t nu
globalR = *rs;
uint32_t starttime = (uint32_t)time(NULL);
rogueiterate(rs);
/*
// keypress after replay
printf("[Press return to continue]");
fflush(stdout);
if (fgets(prbuf, 10, stdin) != 0);
*/
if ( 0 )
{
fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL) - starttime);
@@ -328,7 +343,15 @@ int rogue(int argc, char **argv, char **envp)
rs->sleeptime = 1; // non-zero to allow refresh()
if ( argc == 3 && strlen(argv[2]) == 64 )
{
rs->seed = atol(argv[1]);
#ifdef _WIN32
#ifdef _MSC_VER
rs->seed = _strtoui64(argv[1], NULL, 10);
#else
rs->seed = atol(argv[1]); // windows, but not MSVC
#endif // _MSC_VER
#else
rs->seed = atol(argv[1]); // non-windows
#endif // _WIN32
strcpy(Gametxidstr,argv[2]);
fprintf(stderr,"setplayerdata\n");
if ( rogue_setplayerdata(rs,Gametxidstr) < 0 )
@@ -526,6 +549,18 @@ tstp(int ignored)
#endif*/
}
#ifdef _WIN32
#ifdef _MSC_VER
void usleep(int32_t micros)
{
if (micros < 1000)
Sleep(1);
else Sleep(micros / 1000);
}
#endif
#endif
/*
* playit:
* The main loop of the program. Loop until the game is over,

View File

@@ -365,6 +365,7 @@ struct rogue_state
char *keystrokes,*keystrokeshex;
uint32_t needflush,replaydone;
int32_t numkeys,ind,num,guiflag,counter,sleeptime,playersize,restoring,lastnum;
FILE *logfp;
struct rogue_player P;
char buffered[10000];
uint8_t playerdata[10000];
@@ -770,7 +771,7 @@ bool roll_em(THING *thatt, THING *thdef, THING *weap, bool hurl);
bool see_monst(THING *mp);
bool seen_stairs(void);
bool turn_ok(int y, int x);
bool turn_see(bool turn_off);
bool turn_see(struct rogue_state *rs,bool turn_off);
bool is_current(struct rogue_state *rs,THING *obj);
int passwd(void);

View File

@@ -1,17 +1,25 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual C++ Express 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rogue54", "rogue54.vcproj", "{9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}"
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rogue54", "rogue54.vcxproj", "{9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}.Debug|Win32.ActiveCfg = Debug|Win32
{9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}.Debug|Win32.Build.0 = Debug|Win32
{9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}.Debug|x64.ActiveCfg = Debug|x64
{9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}.Debug|x64.Build.0 = Debug|x64
{9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}.Release|Win32.ActiveCfg = Release|Win32
{9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}.Release|Win32.Build.0 = Release|Win32
{9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}.Release|x64.ActiveCfg = Release|x64
{9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@@ -0,0 +1,257 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>14.0.25431.1</_ProjectFileVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>Debug\</OutDir>
<IntDir>Debug\</IntDir>
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>Release\</OutDir>
<IntDir>Release\</IntDir>
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
<AdditionalIncludeDirectories>../pdcurses;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;ALLSCORES;MASTER;SCOREFILE="rogue54.scr";LOCKFILE="rogue54.lck";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<MinimalRebuild>false</MinimalRebuild>
<ExceptionHandling />
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<BufferSecurityCheck>true</BufferSecurityCheck>
<FunctionLevelLinking>true</FunctionLevelLinking>
<DisableLanguageExtensions>false</DisableLanguageExtensions>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<PrecompiledHeader />
<BrowseInformation />
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<CompileAs>CompileAsC</CompileAs>
</ClCompile>
<Link>
<AdditionalDependencies>Ws2_32.lib;pdcurses.lib;advapi32.lib;shfolder.lib;user32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)rogue54.exe</OutputFile>
<AdditionalLibraryDirectories>..\pdcurses;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>$(OutDir)rogue54.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
<AdditionalIncludeDirectories>$(ProjectDir)x86_64-w64-msvc\deps\install\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;PDC_DLL_BUILD;PDC_WIDE;PDCDEBUG;_CRT_SECURE_NO_DEPRECATE;ALLSCORES;SCOREFILE="rogue54.scr";LOCKFILE="rogue54.lck";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<MinimalRebuild>false</MinimalRebuild>
<ExceptionHandling>
</ExceptionHandling>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<BufferSecurityCheck>true</BufferSecurityCheck>
<FunctionLevelLinking>true</FunctionLevelLinking>
<DisableLanguageExtensions>false</DisableLanguageExtensions>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<PrecompiledHeader>
</PrecompiledHeader>
<BrowseInformation>
</BrowseInformation>
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>CompileAsC</CompileAs>
</ClCompile>
<Link>
<AdditionalDependencies>Ws2_32.lib;wincon\pdcurses.lib;libcurl_imp.lib;advapi32.lib;shfolder.lib;user32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)rogue54.exe</OutputFile>
<AdditionalLibraryDirectories>$(ProjectDir)x86_64-w64-msvc\deps\install\lib;$(ProjectDir)x86_64-w64-msvc\deps\install\Release\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>$(OutDir)rogue54.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<OmitFramePointers>true</OmitFramePointers>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalIncludeDirectories>$(ProjectDir)\x86_64-w64-msvc\include\ncursesw;$(ProjectDir)\x86_64-w64-msvc\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<OutputFile>$(OutDir)rogue54.exe</OutputFile>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<OmitFramePointers>true</OmitFramePointers>
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;PDC_DLL_BUILD;PDC_WIDE;PDCDEBUG;_CRT_SECURE_NO_DEPRECATE;ALLSCORES;SCOREFILE="rogue54.scr";LOCKFILE="rogue54.lck";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalIncludeDirectories>$(ProjectDir)x86_64-w64-msvc\deps\install\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
<CompileAs>CompileAsC</CompileAs>
<ExceptionHandling />
<BrowseInformation />
</ClCompile>
<Link>
<OutputFile>$(OutDir)rogue54.exe</OutputFile>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<AdditionalLibraryDirectories>$(ProjectDir)x86_64-w64-msvc\deps\install\lib;$(ProjectDir)x86_64-w64-msvc\deps\install\Release\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>Ws2_32.lib;wincon\pdcurses.lib;libcurl_imp.lib;advapi32.lib;shfolder.lib;user32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
<ForceSymbolReferences>%(ForceSymbolReferences)</ForceSymbolReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="armor.c" />
<ClCompile Include="chase.c" />
<ClCompile Include="command.c" />
<ClCompile Include="daemon.c" />
<ClCompile Include="daemons.c" />
<ClCompile Include="extern.c" />
<ClCompile Include="fight.c" />
<ClCompile Include="init.c" />
<ClCompile Include="io.c" />
<ClCompile Include="list.c" />
<ClCompile Include="mach_dep.c" />
<ClCompile Include="main.c" />
<ClCompile Include="mdport.c" />
<ClCompile Include="misc.c" />
<ClCompile Include="monsters.c" />
<ClCompile Include="move.c" />
<ClCompile Include="new_level.c" />
<ClCompile Include="options.c" />
<ClCompile Include="pack.c" />
<ClCompile Include="passages.c" />
<ClCompile Include="potions.c" />
<ClCompile Include="rings.c" />
<ClCompile Include="rip.c" />
<ClCompile Include="rogue.c" />
<ClCompile Include="rooms.c" />
<ClCompile Include="save.c" />
<ClCompile Include="scrolls.c" />
<ClCompile Include="state.c" />
<ClCompile Include="sticks.c" />
<ClCompile Include="things.c" />
<ClCompile Include="vers.c" />
<ClCompile Include="weapons.c" />
<ClCompile Include="wizard.c" />
<ClCompile Include="xcrypt.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="extern.h" />
<ClInclude Include="rogue.h" />
<ClInclude Include="score.h" />
</ItemGroup>
<ItemGroup>
<Text Include="LICENSE.TXT" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,64 @@
@echo off
echo Rogue Build Script by Decker (c) 2019
@REM Check for Visual Studio
call set "VSPATH="
if defined VS140COMNTOOLS ( if not defined VSPATH (
call set "VSPATH=%%VS140COMNTOOLS%%"
) )
@REM check if we already have the tools in the environment
if exist "%VCINSTALLDIR%" (
goto compile
)
if not defined VSPATH (
echo You need Microsoft Visual Studio 15 installed
pause
exit
)
@REM set up the environment
if exist "%VSPATH%..\..\vc\vcvarsall.bat" (
call "%%VSPATH%%..\..\vc\vcvarsall.bat" amd64
goto compile
)
echo Unable to set up the environment
pause
exit
:compile
mkdir x86_64-w64-msvc\deps
mkdir x86_64-w64-msvc\deps\install
pushd x86_64-w64-msvc\deps
:compile_pdcurses
rem git clone https://github.com/wmcbrine/PDCurses PDCurses.org
git clone https://github.com/Bill-Gray/PDCurses
set PREFIX_DIR=%CD%\install
pushd PDCurses
mkdir build64 & pushd build64
rem cmake -G"Visual Studio 14 2015 Win64" -DPDC_WIDE=ON -DCMAKE_INSTALL_PREFIX=%PREFIX_DIR% -DCMAKE_BUILD_TYPE=Debug -DPDCDEBUG=ON ..
cmake -G"Visual Studio 14 2015 Win64" -DPDC_WIDE=ON -DCMAKE_INSTALL_PREFIX=%PREFIX_DIR% -DCMAKE_BUILD_TYPE=Release ..
popd
rem cmake --build build64 --config Debug --target install
cmake --build build64 --config Release --target install
popd
:compile_curl
git clone https://github.com/curl/curl
pushd curl
mkdir build64 & pushd build64
cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX=%PREFIX_DIR% -DCMAKE_USE_WINSSL:BOOL=ON ..
cmake --build . --config Release --target libcurl
cmake --build . --config Release --target install
popd
popd

View File

@@ -0,0 +1,265 @@
/* Many of the following #defines are completely unused for the
nonce. For each character, its code point in code page 437,
Unicode, and page 8859-1 are given. The first is used for
non-wide builds in Win32 console, DOS, SDL, and OS/2.
Unicode is used for all wide builds, and for the non-wide
build of WinGUI. Code page 8859-1 is used for non-wide X11.
All of these characters exist in CP437 and Unicode. Some
don't exist in 8859-1, in which case the last column is 'TBD'.
Only 32 are used in ncurses. So caution is advised. */
#ifdef USE_ISO8859_CHARSET
#define CHOOSE( A, B, C) (C)
#define TBD '!'
#else
#define CHOOSE( A, B, C) (USE_UNICODE_ACS_CHARS ? B : A)
#endif
/* Codes found from https://en.wikipedia.org/wiki/Code_page_437 */
#define SMILE CHOOSE( 0x01, 0x263a, 'O')
#define REV_SMILE CHOOSE( 0x02, 0x263b, 'O')
#define HEART CHOOSE( 0x03, 0x2665, 'H')
#define DIAMOND CHOOSE( 0x04, 0x2666, 0x01)
#define CLUB CHOOSE( 0x05, 0x2663, 'C')
#define SPADE CHOOSE( 0x06, 0x2660, 'S')
#define MEDIUM_BULLET CHOOSE( 0x07, 0x2022, 0xb7)
#define REV_BULLET CHOOSE( 0x08, 0x2508, 0xb7)
#define WHITE_BULLET CHOOSE( 0x09, 0x25cb, 7)
#define REV_WHITE_BULLET CHOOSE( 0x0a, 0x25D9, 7)
#define MALE_SYM CHOOSE( 0x0b, 0x2642, 'm')
#define FEMALE_SYM CHOOSE( 0x0c, 0x2640, 'f')
#define QTR_NOTE CHOOSE( 0x0d, 0x266a, 0xbc)
#define EIGHTH_NOTE CHOOSE( 0x0e, 0x266b, 0xbd)
#define SPLAT CHOOSE( 0x0f, 0xa4 , 0xa4)
#define RIGHT_TRIANGLE CHOOSE( 0x10, 0x25b6, '>')
#define LEFT_TRIANGLE CHOOSE( 0x11, 0x25c0, '<')
#define UP_DOWN_ARROW CHOOSE( 0x12, 0x2195, 0x19)
#define DBL_BANG CHOOSE( 0x13, 0x203c, '!')
#define PILCROW CHOOSE( 0x14, 0xb6 , 0xb6)
#define SECTION_SIGN CHOOSE( 0x15, 0xa7 , 0xa7)
#define LOW_QTR_BLOCK CHOOSE( 0x16, 0x25b2, '_')
#define UP_DOWN_ARROW_UNDERSCORED CHOOSE( 0x17, 0x21ab, 0x19)
#define UP_ARROW CHOOSE( 0x18, 0x2191, '^')
#define DOWN_ARROW CHOOSE( 0x19, 0x2193, 'v')
#define RIGHT_ARROW CHOOSE( 0x1a, 0x2192, '>')
#define LEFT_ARROW CHOOSE( 0x1b, 0x2190, '<')
#define RIGHT_ANGLE CHOOSE( 0x1c, 0x221f, 0xe)
#define LEFT_RIGHT_ARROW CHOOSE( 0x1d, 0x2194, '-')
#define UP_TRIANGLE CHOOSE( 0x1e, 0x25b2, '^')
#define DOWN_TRIANGLE CHOOSE( 0x1f, 0x25bc, 'v')
#define UPPERCASE_C_CEDILLA CHOOSE( 0x80, 0xc7 , 0xc7)
#define LOWERCASE_U_UMLAUT CHOOSE( 0x81, 0xfc , 0xfc)
#define LOWERCASE_E_ACUTE CHOOSE( 0x82, 0xe9 , 0xe9)
#define LOWERCASE_A_CIRCUMFLEX CHOOSE( 0x83, 0xe2 , 0xe2)
#define LOWERCASE_A_UMLAUT CHOOSE( 0x84, 0xe4 , 0xe4)
#define LOWERCASE_A_GRAVE CHOOSE( 0x85, 0xe0 , 0xea)
#define LOWERCASE_A_RING CHOOSE( 0x86, 0xe5 , 0xe5)
#define LOWERCASE_C_CEDILLA CHOOSE( 0x87, 0xe7 , 0xe7)
#define LOWERCASE_E_CIRCUMFLEX CHOOSE( 0x88, 0xea , 0xea)
#define LOWERCASE_E_UMLAUT CHOOSE( 0x89, 0xeb , 0xeb)
#define LOWERCASE_E_GRAVE CHOOSE( 0x8a, 0xe8 , 0xe8)
#define LOWERCASE_I_UMLAUT CHOOSE( 0x8b, 0xef , 0xef)
#define LOWERCASE_I_CIRCUMFLEX CHOOSE( 0x8c, 0xee , 0xee)
#define LOWERCASE_I_GRAVE CHOOSE( 0x8d, 0xec , 0xce)
#define UPPERCASE_A_UMLAUT CHOOSE( 0x8e, 0xc4 , 0xc4)
#define UPPERCASE_A_RING CHOOSE( 0x8f, 0xc5 , 0xc5)
#define UPPERCASE_E_ACUTE CHOOSE( 0x90, 0xc9 , 0xc9)
#define LOWERCASE_AE_LIGATURE CHOOSE( 0x91, 0xe6 , 0xe6)
#define UPPERCASE_AE_LIGATURE CHOOSE( 0x92, 0xc6 , 0xc6)
#define LOWERCASE_O_CIRCUMFLEX CHOOSE( 0x93, 0xf4 , 0xf4)
#define LOWERCASE_O_UMLAUT CHOOSE( 0x94, 0xf6 , 0xf6)
#define LOWERCASE_O_GRAVE CHOOSE( 0x95, 0xf2 , 0xf2)
#define LOWERCASE_U_CIRCUMFLEX CHOOSE( 0x96, 0xfb , 0xfb)
#define LOWERCASE_U_GRAVE CHOOSE( 0x97, 0xf9 , 0xf9)
#define LOWERCASE_Y_UMLAUT CHOOSE( 0x98, 0xff , 0xff)
#define UPPERCASE_O_UMLAUT CHOOSE( 0x99, 0xd6 , 0xd6)
#define UPPERCASE_U_UMLAUT CHOOSE( 0x9a, 0xdc , 0xdc)
#define CENT_SIGN CHOOSE( 0x9b, 0xa2 , 0xa2)
#define STERLING_SIGN CHOOSE( 0x9c, 0xa3 , 30)
#define YEN_SIGN CHOOSE( 0x9d, 0xa5 , 0xa5)
#define PESETA_SIGN CHOOSE( 0x9e, 0x20a7, TBD)
#define F_WITH_HOOK CHOOSE( 0x9f, 0x0192, TBD)
#define LOWERCASE_A_ACUTE CHOOSE( 0xa0, 0xe1 , 0xe1)
#define LOWERCASE_I_ACUTE CHOOSE( 0xa1, 0xed , 0xed)
#define LOWERCASE_O_ACUTE CHOOSE( 0xa2, 0xf3 , 0xf3)
#define LOWERCASE_U_ACUTE CHOOSE( 0xa3, 0xfa , 0xfa)
#define LOWERCASE_N_TILDE CHOOSE( 0xa4, 0xf1 , 0xf1)
#define UPPERCASE_N_TILDE CHOOSE( 0xa5, 0xd1 , 0xd1)
#define A_ORDINAL CHOOSE( 0xa6, 0xaa , 0xaa)
#define O_ORDINAL CHOOSE( 0xa7, 0xba , 0xba)
#define INVERTED_QUESTION_MARK CHOOSE( 0xa8, 0xbf , 0xbf)
#define REVERSED_NOT_SIGN CHOOSE( 0xa9, 0x2310, TBD)
#define NOT_SIGN CHOOSE( 0xaa, 0xac , 0xac)
#define VULGAR_HALF CHOOSE( 0xab, 0xbd , 0xbd)
#define VULGAR_QUARTER CHOOSE( 0xac, 0xbc , 0xbc)
#define INVERTED_EXCLAMATION_MARK CHOOSE( 0xad, 0xa1 , 0xa1)
#define LEFT_ANGLE_QUOTE_MARK CHOOSE( 0xae, 0xab , 0xab)
#define RIGHT_ANGLE_QUOTE_MARK CHOOSE( 0xaf, 0xbb , 0xbb)
#define LIGHT_SHADE CHOOSE( 0xb0, 0x2591, '#' )
#define MEDIUM_SHADE CHOOSE( 0xb1, 0x2592, 2)
#define DARK_SHADE CHOOSE( 0xb2, 0x2593, TBD)
#define BOX_VLINE CHOOSE( 0xb3, 0x2502, 25)
#define BOX_RTEE CHOOSE( 0xb4, 0x2524, 22)
#define BOX_SD_RTEE CHOOSE( 0xb5, 0x2561, 22)
#define BOX_DS_RTEE CHOOSE( 0xb6, 0x2562, 22)
#define BOX_DS_URCORNER CHOOSE( 0xb7, 0x2556, 12)
#define BOX_SD_URCORNER CHOOSE( 0xb8, 0x2555, 12)
#define BOX_D_RTEE CHOOSE( 0xb9, 0x2563, 22)
#define BOX_D_VLINE CHOOSE( 0xba, 0x2551, 25)
#define BOX_D_URCORNER CHOOSE( 0xbb, 0x2557, 12)
#define BOX_D_LRCORNER CHOOSE( 0xbc, 0x255D, 11)
#define BOX_DS_LRCORNER CHOOSE( 0xbd, 0x255c, 11)
#define BOX_SD_LRCORNER CHOOSE( 0xbe, 0x255b, 11)
#define BOX_URCORNER CHOOSE( 0xbf, 0x2510, 12)
#define BOX_LLCORNER CHOOSE( 0xc0, 0x2514, 14)
#define BOX_BTEE CHOOSE( 0xc1, 0x2534, 23)
#define BOX_TTEE CHOOSE( 0xc2, 0x252c, 24)
#define BOX_LTEE CHOOSE( 0xc3, 0x251c, 21)
#define BOX_HLINE CHOOSE( 0xc4, 0x2500, 18)
#define BOX_PLUS CHOOSE( 0xc5, 0x253c, 15)
#define BOX_SD_LTEE CHOOSE( 0xc6, 0x255e, 21)
#define BOX_DS_LTEE CHOOSE( 0xc7, 0x255f, 21)
#define BOX_D_LLCORNER CHOOSE( 0xc8, 0x255A, 14)
#define BOX_D_ULCORNER CHOOSE( 0xc9, 0x2554, 13)
#define BOX_D_BTEE CHOOSE( 0xca, 0x2569, 23)
#define BOX_D_TTEE CHOOSE( 0xcb, 0x2566, 24)
#define BOX_D_LTEE CHOOSE( 0xcc, 0x2560, 21)
#define BOX_D_HLINE CHOOSE( 0xcd, 0x2550, 18)
#define BOX_D_PLUS CHOOSE( 0xce, 0x256C, 15)
#define BOX_SD_BTEE CHOOSE( 0xcf, 0x2567, 23)
#define BOX_DS_BTEE CHOOSE( 0xd0, 0x2568, 23)
#define BOX_SD_TTEE CHOOSE( 0xd1, 0x2564, 24)
#define BOX_DS_TTEE CHOOSE( 0xd2, 0x2565, 24)
#define BOX_DS_LLCORNER CHOOSE( 0xd3, 0x2559, 14)
#define BOX_SD_LLCORNER CHOOSE( 0xd4, 0x2558, 14)
#define BOX_SD_ULCORNER CHOOSE( 0xd5, 0x2552, 13)
#define BOX_DS_ULCORNER CHOOSE( 0xd6, 0x2553, 13)
#define BOX_DS_PLUS CHOOSE( 0xd7, 0x256b, 15)
#define BOX_SD_PLUS CHOOSE( 0xd8, 0x256a, 15)
#define BOX_LRCORNER CHOOSE( 0xd9, 0x2518, 11)
#define BOX_ULCORNER CHOOSE( 0xda, 0x250c, 13)
#define FULL_BLOCK CHOOSE( 0xdb, 0x2588, 0)
#define LOWER_HALF_BLOCK CHOOSE( 0xdc, 0x2584, TBD)
#define LEFT_HALF_BLOCK CHOOSE( 0xdd, 0x258c, TBD)
#define RIGHT_HALF_BLOCK CHOOSE( 0xde, 0x2590, TBD)
#define UPPER_HALF_BLOCK CHOOSE( 0xdf, 0x2580, TBD)
#define ALPHA CHOOSE( 0xe0, 0x03b1, TBD)
#define BETA CHOOSE( 0xe1, 0x00df, TBD)
#define GAMMA CHOOSE( 0xe2, 0x0393, TBD)
#define PI CHOOSE( 0xe3, 0x03c0, 28)
#define UPPERCASE_SIGMA CHOOSE( 0xe4, 0x03a3, TBD)
#define LOWERCASE_SIGMA CHOOSE( 0xe5, 0x03c3, TBD)
#define MU CHOOSE( 0xe6, 0x00b5, 0xb5)
#define TAU CHOOSE( 0xe7, 0x03c4, TBD)
#define UPPERCASE_PHI CHOOSE( 0xe8, 0x03a6, TBD)
#define THETA CHOOSE( 0xe9, 0x0398, TBD)
#define OMEGA CHOOSE( 0xea, 0x03a9, TBD)
#define DELTA CHOOSE( 0xeb, 0x03b4, TBD)
#define INFINITY_SIGN CHOOSE( 0xec, 0x221e, TBD)
#define LOWERCASE_PHI CHOOSE( 0xed, 0x03c6, TBD)
#define EPSILON CHOOSE( 0xee, 0x03b5, TBD)
#define INTERSECTION CHOOSE( 0xef, 0x2229, TBD)
#define TRIPLE_BAR CHOOSE( 0xf0, 0x2261, TBD)
#define PLUS_OR_MINUS CHOOSE( 0xf1, 0x00b1, 8)
#define GREATER_THAN_OR_EQUAL_TO CHOOSE( 0xf2, 0x2265, 27)
#define LESSER_THAN_OR_EQUAL_TO CHOOSE( 0xf3, 0x2264, 26)
#define UPPER_HALF_INTEGRAL_SIGN CHOOSE( 0xf4, 0x2320, TBD)
#define LOWER_HALF_INTEGRAL_SIGN CHOOSE( 0xf5, 0x2321, TBD)
#define DIVISION_SIGN CHOOSE( 0xf6, 0x00f7, 0xf7)
#define APPROXIMATELY_EQUALS_SIGN CHOOSE( 0xf7, 0x2248, TBD)
#define DEGREE_SIGN CHOOSE( 0xf8, 0x00b0, 0xb0)
#define LARGE_BULLET CHOOSE( 0xf9, 0x2219, 7)
#define SMALL_BULLET CHOOSE( 0xfa, 0x00b7, 0xb7)
#define SQUARE_ROOT CHOOSE( 0xfb, 0x221a, TBD)
#define SUPERSCRIPT_N CHOOSE( 0xfc, 0x207f, TBD)
#define SUPERSCRIPT_2 CHOOSE( 0xfd, 0x00b2, 0xb2)
#define CENTERED_SQUARE CHOOSE( 0xfe, 0x25a0, TBD)
#define NON_BREAKING_SPACE CHOOSE( 0xff, 0x00a0, TBD)
/* It says at http://unicode.org/charts/PDF/U2300.pdf */
/* that '...the scan line numbers here refer to old, */
/* low-resolution technology for terminals, with only */
/* nine scan lines per fixed-size character glyph. */
/* Even-numbered scan lines are unified with box */
/* drawing graphics." */
/* The utility of these is questionable; they'd */
/* work Just Fine in wingdi (_if_ the appropriate */
/* glyphs are available), but not elsewhere. */
#define HORIZ_SCAN_LINE_1 CHOOSE( 0x2d, 0x23ba, 16)
#define HORIZ_SCAN_LINE_3 CHOOSE( 0x2d, 0x23bb, 17)
#define HORIZ_SCAN_LINE_7 CHOOSE( 0x2d, 0x23bc, 19)
#define HORIZ_SCAN_LINE_9 CHOOSE( '_', 0x23bd, 20)
/* Code page 437 lacks a 'for real' not-equals, so for that, */
/* we use the double-horizontal single-vertical box drawing : */
#define NOT_EQUALS_SIGN CHOOSE( 0xd8, 0x2260, 29)
# define A(x) ((chtype)x | A_ALTCHARSET)
chtype acs_map[128] =
{
A(0), A(1), A(2), A(3), A(4), A(5), A(6), A(7), A(8),
A(9), A(10),
CLUB, HEART, SPADE, SMILE, REV_SMILE, /* 11 12 13 14 15 */
MEDIUM_BULLET, WHITE_BULLET, PILCROW, SECTION_SIGN, /* 16 17 18 19 */
A_ORDINAL, O_ORDINAL, LOWERCASE_PHI, /* 20 21 22 */
INVERTED_EXCLAMATION_MARK, INVERTED_QUESTION_MARK, /* 23 24 */
REVERSED_NOT_SIGN, NOT_SIGN, /* 25 26 */
UPPER_HALF_INTEGRAL_SIGN, LOWER_HALF_INTEGRAL_SIGN, /* 27 28 */
SUPERSCRIPT_N, CENTERED_SQUARE, F_WITH_HOOK, /* 29 30 31 */
RIGHT_ARROW, LEFT_ARROW, UP_ARROW, DOWN_ARROW, /* 32 !"# */
PI, NOT_EQUALS_SIGN, VULGAR_HALF, VULGAR_QUARTER, /* $%&' */
'(',
LEFT_ANGLE_QUOTE_MARK, RIGHT_ANGLE_QUOTE_MARK, /* )* */
DARK_SHADE, SUPERSCRIPT_2, INFINITY_SIGN, /* +,- */
ALPHA, BETA, GAMMA, UPPERCASE_SIGMA, LOWERCASE_SIGMA, /* ./012 */
'3',
MU, TAU, UPPERCASE_PHI, THETA, OMEGA, DELTA, EPSILON, /* 456789: */
BOX_SD_LRCORNER, BOX_SD_URCORNER, BOX_SD_ULCORNER, /* ;<= */
BOX_SD_LLCORNER, BOX_SD_PLUS, /* >? */
BOX_SD_LTEE, BOX_SD_RTEE, BOX_SD_BTEE, BOX_SD_TTEE, /* @ABC */
BOX_D_LRCORNER, BOX_D_URCORNER, BOX_D_ULCORNER, /* DEF */
BOX_D_LLCORNER, BOX_D_PLUS, /* GH */
BOX_D_LTEE, BOX_D_RTEE, BOX_D_BTEE, BOX_D_TTEE, /* IJKL */
BOX_DS_LRCORNER, BOX_DS_URCORNER, BOX_DS_ULCORNER, /* MNO */
BOX_DS_LLCORNER, BOX_DS_PLUS, /* PQ */
BOX_DS_LTEE, BOX_DS_RTEE, BOX_DS_BTEE, BOX_DS_TTEE, /* RSTU */
BOX_LRCORNER, BOX_URCORNER, BOX_ULCORNER, /* VWX */
BOX_LLCORNER, BOX_PLUS, /* YZ */
BOX_LTEE, BOX_RTEE, BOX_BTEE, BOX_TTEE, /* [\]^ */
BOX_HLINE, BOX_VLINE, BOX_D_HLINE, BOX_D_VLINE, /* _`ab */
DIVISION_SIGN, APPROXIMATELY_EQUALS_SIGN, /* cd */
INTERSECTION, TRIPLE_BAR, /* ef */
SMALL_BULLET, LARGE_BULLET, SQUARE_ROOT, /* ghi */
DIAMOND, MEDIUM_SHADE, /* jk */
HORIZ_SCAN_LINE_1, HORIZ_SCAN_LINE_3, /* lm */
HORIZ_SCAN_LINE_7, HORIZ_SCAN_LINE_9, /* no */
UPPER_HALF_BLOCK, LOWER_HALF_BLOCK, /* pq */
LEFT_HALF_BLOCK, RIGHT_HALF_BLOCK, FULL_BLOCK, /* rst */
LESSER_THAN_OR_EQUAL_TO, GREATER_THAN_OR_EQUAL_TO, /* uv */
DEGREE_SIGN, PLUS_OR_MINUS, LIGHT_SHADE, SPLAT, /* wxyz */
CENT_SIGN, YEN_SIGN, PESETA_SIGN, STERLING_SIGN, /* {|}~ */
A(127)
};
# undef A

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,134 @@
/* Public Domain Curses */
/* Private definitions and declarations for use within PDCurses.
These should generally not be referenced by applications. */
#ifndef __CURSES_INTERNALS__
#define __CURSES_INTERNALS__ 1
#define CURSES_LIBRARY
#include <curses.h>
#if defined(__TURBOC__) || defined(__EMX__) || defined(__DJGPP__) || \
defined(__CYGWIN__) || defined(__MINGW32__) || \
defined(__WATCOMC__) || defined(__PACIFIC__)
# ifndef HAVE_VSSCANF
# define HAVE_VSSCANF /* have vsscanf() */
# endif
#endif
#if defined(__CYGWIN__) || defined(__MINGW32__) || \
defined(__LCC__) || defined(__WATCOMC__)
# ifndef HAVE_VSNPRINTF
# define HAVE_VSNPRINTF /* have vsnprintf() */
# endif
#endif
#if defined(_MSC_VER) && defined(_WIN32) && !defined(_CRT_SECURE_NO_DEPRECATE)
# define _CRT_SECURE_NO_DEPRECATE 1 /* kill nonsense warnings */
#endif
/*----------------------------------------------------------------------*/
typedef struct /* structure for ripped off lines */
{
int line;
int (*init)(WINDOW *, int);
} RIPPEDOFFLINE;
/* Window properties */
#define _SUBWIN 0x01 /* window is a subwindow */
#define _PAD 0x10 /* X/Open Pad. */
#define _SUBPAD 0x20 /* X/Open subpad. */
/* Miscellaneous */
#define _NO_CHANGE -1 /* flags line edge unchanged */
#define _ECHAR 0x08 /* Erase char (^H) */
#define _DWCHAR 0x17 /* Delete Word char (^W) */
#define _DLCHAR 0x15 /* Delete Line char (^U) */
extern WINDOW *pdc_lastscr;
extern FILE *pdc_dbfp; /* tracing file pointer (NULL = off) */
extern bool pdc_color_started;
extern unsigned long pdc_key_modifiers;
extern MOUSE_STATUS pdc_mouse_status;
/*----------------------------------------------------------------------*/
/* Platform implementation functions */
void PDC_beep(void);
bool PDC_can_change_color(void);
int PDC_color_content(short, short *, short *, short *);
bool PDC_check_key(void);
int PDC_curs_set(int);
void PDC_flushinp(void);
int PDC_get_columns(void);
int PDC_get_cursor_mode(void);
int PDC_get_key(void);
int PDC_get_rows(void);
void PDC_gotoyx(int, int);
int PDC_init_color(short, short, short, short);
void PDC_init_pair(short, short, short);
int PDC_modifiers_set(void);
int PDC_mouse_set(void);
void PDC_napms(int);
int PDC_pair_content(short, short *, short *);
void PDC_reset_prog_mode(void);
void PDC_reset_shell_mode(void);
int PDC_resize_screen(int, int);
void PDC_restore_screen_mode(int);
void PDC_save_screen_mode(int);
void PDC_scr_close(void);
void PDC_scr_free(void);
int PDC_scr_open(int, char **);
void PDC_set_keyboard_binary(bool);
void PDC_transform_line(int, int, int, const chtype *);
const char *PDC_sysname(void);
/* Internal cross-module functions */
void PDC_init_atrtab(void);
WINDOW *PDC_makelines(WINDOW *);
WINDOW *PDC_makenew(int, int, int, int);
int PDC_mouse_in_slk(int, int);
void PDC_slk_free(void);
void PDC_slk_initialize(void);
void PDC_sync(WINDOW *);
#ifdef PDC_WIDE
int PDC_mbtowc(wchar_t *, const char *, size_t);
size_t PDC_mbstowcs(wchar_t *, const char *, size_t);
size_t PDC_wcstombs(char *, const wchar_t *, size_t);
#endif
#ifdef PDCDEBUG
# define PDC_LOG(x) if (pdc_dbfp) PDC_debug x
#else
# define PDC_LOG(x)
#endif
/* Internal macros for attributes */
#ifdef CHTYPE_LONG
# define PDC_COLOR_PAIRS 256
#else
# define PDC_COLOR_PAIRS 32
#endif
#ifndef max
# define max(a,b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef min
# define min(a,b) (((a) < (b)) ? (a) : (b))
#endif
#define DIVROUND(num, divisor) (((num) + ((divisor) >> 1)) / (divisor))
#define PDC_CLICK_PERIOD 150 /* time to wait for a click, if
not set by mouseinterval() */
#endif /* __CURSES_INTERNALS__*/

View File

@@ -0,0 +1,93 @@
/* $Id: getopt.h,v 1.1 2009/10/16 19:50:28 rodney Exp rodney $ */
/* $OpenBSD: getopt.h,v 1.1 2002/12/03 20:24:29 millert Exp $ */
/* $NetBSD: getopt.h,v 1.4 2000/07/07 10:43:54 ad Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Dieter Baron and Thomas Klausner.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _GETOPT_H_
#define _GETOPT_H_
#if 0
#include <sys/cdefs.h>
#endif
/*
* GNU-like getopt_long() and 4.4BSD getsubopt()/optreset extensions
*/
#define no_argument 0
#define required_argument 1
#define optional_argument 2
struct option {
/* name of long option */
const char *name;
/*
* one of no_argument, required_argument, and optional_argument:
* whether option takes an argument
*/
int has_arg;
/* if not NULL, set *flag to val when option found */
int *flag;
/* if flag not NULL, value to set *flag to; else return value */
int val;
};
#ifdef __cplusplus
extern "C" {
#endif
int getopt_long(int, char * const *, const char *,
const struct option *, int *);
int getopt_long_only(int, char * const *, const char *,
const struct option *, int *);
#ifndef _GETOPT_DEFINED
#define _GETOPT_DEFINED
int getopt(int, char * const *, const char *);
int getsubopt(char **, char * const *, char **);
extern char *optarg; /* getopt(3) external variables */
extern int opterr;
extern int optind;
extern int optopt;
extern int optreset;
extern char *suboptarg; /* getsubopt(3) external variable */
#endif /* _GETOPT_DEFINED */
#ifdef __cplusplus
}
#endif
#endif /* !_GETOPT_H_ */

View File

@@ -0,0 +1,56 @@
/* Public Domain Curses */
/*----------------------------------------------------------------------*
* Panels for PDCurses *
*----------------------------------------------------------------------*/
#ifndef __PDCURSES_PANEL_H__
#define __PDCURSES_PANEL_H__ 1
#include <curses.h>
#if defined(__cplusplus) || defined(__cplusplus__) || defined(__CPLUSPLUS)
extern "C"
{
#endif
typedef struct panelobs
{
struct panelobs *above;
struct panel *pan;
} PANELOBS;
typedef struct panel
{
WINDOW *win;
int wstarty;
int wendy;
int wstartx;
int wendx;
struct panel *below;
struct panel *above;
const void *user;
struct panelobs *obscure;
} PANEL;
PDCEX int bottom_panel(PANEL *pan);
PDCEX int del_panel(PANEL *pan);
PDCEX int hide_panel(PANEL *pan);
PDCEX int move_panel(PANEL *pan, int starty, int startx);
PDCEX PANEL *new_panel(WINDOW *win);
PDCEX PANEL *panel_above(const PANEL *pan);
PDCEX PANEL *panel_below(const PANEL *pan);
PDCEX int panel_hidden(const PANEL *pan);
PDCEX const void *panel_userptr(const PANEL *pan);
PDCEX WINDOW *panel_window(const PANEL *pan);
PDCEX int replace_panel(PANEL *pan, WINDOW *win);
PDCEX int set_panel_userptr(PANEL *pan, const void *uptr);
PDCEX int show_panel(PANEL *pan);
PDCEX int top_panel(PANEL *pan);
PDCEX void update_panels(void);
#if defined(__cplusplus) || defined(__cplusplus__) || defined(__CPLUSPLUS)
}
#endif
#endif /* __PDCURSES_PANEL_H__ */

View File

@@ -0,0 +1,48 @@
/* Public Domain Curses */
/* PDCurses doesn't operate with terminfo, but we need these functions for
compatibility, to allow some things (notably, interface libraries for
other languages) to be compiled. Anyone who tries to actually _use_
them will be disappointed, since they only return ERR. */
#ifndef __PDCURSES_TERM_H__
#define __PDCURSES_TERM_H__ 1
#include <curses.h>
#if defined(__cplusplus) || defined(__cplusplus__) || defined(__CPLUSPLUS)
extern "C"
{
#endif
typedef struct
{
const char *_termname;
} TERMINAL;
/* PDCEX is defined in curses.h */
PDCEX TERMINAL *cur_term;
int del_curterm(TERMINAL *);
int putp(const char *);
int restartterm(const char *, int, int *);
TERMINAL *set_curterm(TERMINAL *);
int setterm(const char *);
int setupterm(const char *, int, int *);
int tgetent(char *, const char *);
int tgetflag(const char *);
int tgetnum(const char *);
char *tgetstr(const char *, char **);
char *tgoto(const char *, int, int);
int tigetflag(const char *);
int tigetnum(const char *);
char *tigetstr(const char *);
char *tparm(const char *, long, long, long, long, long,
long, long, long, long);
int tputs(const char *, int, int (*)(int));
#if defined(__cplusplus) || defined(__cplusplus__) || defined(__CPLUSPLUS)
}
#endif
#endif /* __PDCURSES_TERM_H__ */

View File

@@ -0,0 +1,56 @@
#ifndef _UNISTD_H
#define _UNISTD_H 1
/* This is intended as a drop-in replacement for unistd.h on Windows.
* Please add functionality as neeeded.
* https://stackoverflow.com/a/826027/1202830
*/
#include <stdlib.h>
#include <io.h>
#include <getopt.h> /* getopt at: https://gist.github.com/ashelly/7776712 */
#include <process.h> /* for getpid() and the exec..() family */
#include <direct.h> /* for _getcwd() and _chdir() */
#define srandom srand
#define random rand
/* Values for the second argument to access.
These may be OR'd together. */
#define R_OK 4 /* Test for read permission. */
#define W_OK 2 /* Test for write permission. */
//#define X_OK 1 /* execute permission - unsupported in windows*/
#define F_OK 0 /* Test for existence. */
#define access _access
#define dup2 _dup2
#define execve _execve
#define ftruncate _chsize
#define unlink _unlink
#define fileno _fileno
#define getcwd _getcwd
#define chdir _chdir
#define isatty _isatty
#define lseek _lseek
/* read, write, and close are NOT being #defined here, because while there are file handle specific versions for Windows, they probably don't work for sockets. You need to look at your app and consider whether to call e.g. closesocket(). */
#ifdef _WIN64
#define ssize_t __int64
#else
#define ssize_t long
#endif
#define STDIN_FILENO 0
#define STDOUT_FILENO 1
#define STDERR_FILENO 2
/* should be in some equivalent to <sys/types.h> */
typedef __int8 int8_t;
typedef __int16 int16_t;
typedef __int32 int32_t;
typedef __int64 int64_t;
typedef unsigned __int8 uint8_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int64 uint64_t;
#endif /* unistd.h */

View File

@@ -321,6 +321,26 @@ int32_t rogue_isvalidgame(struct CCcontract_info *cp,int32_t &gameheight,CTransa
} else return(-1);
}
void disp_playerdata(std::vector<uint8_t> playerdata)
{
struct rogue_player P; int32_t i; char packitemstr[512];
if ( playerdata.size() > 0 )
{
for (i=0; i<playerdata.size(); i++)
{
((uint8_t *)&P)[i] = playerdata[i];
fprintf(stderr,"%02x",playerdata[i]);
}
fprintf(stderr," <- playerdata: gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d\n",P.gold,P.hitpoints,P.strength&0xffff,P.strength>>16,P.level,P.experience,P.dungeonlevel);
for (i=0; i<P.packsize&&i<MAXPACK; i++)
{
rogue_packitemstr(packitemstr,&P.roguepack[i]);
fprintf(stderr,"%d: %s\n",i,packitemstr);
}
fprintf(stderr,"\n");
}
}
UniValue rogue_playerobj(std::vector<uint8_t> playerdata,uint256 playertxid,uint256 tokenid,std::string symbol,std::string pname,uint256 gametxid)
{
int32_t i,vout,spentvini,numvouts,n=0; uint256 txid,spenttxid,hashBlock; struct rogue_player P; char packitemstr[512],*datastr=0; UniValue obj(UniValue::VOBJ),a(UniValue::VARR); CTransaction tx;
@@ -487,6 +507,8 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke
int32_t i,numvouts,spentvini,n,matches = 0; CPubKey pk; uint256 tid,active,spenttxid,tokenid,hashBlock,txid,origplayergame; CTransaction spenttx,matchtx,batontx; std::vector<uint8_t> checkdata; CBlockIndex *pindex; char ccaddr[64],*keystrokes=0;
batonvalue = numkeys = numplayers = batonht = 0;
playertxid = batontxid = zeroid;
if ( keystrokesp != 0 )
*keystrokesp = 0;
for (i=0; i<maxplayers; i++)
{
//fprintf(stderr,"findbaton.%d of %d\n",i,maxplayers);
@@ -943,7 +965,7 @@ char *rogue_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vecto
{
UniValue obj;
seed = rogue_gamefields(obj,maxplayers,buyin,gametxid,rogueaddr);
//fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d playertxid.%s\n",pname.size()!=0?pname.c_str():Rogue_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size(),playertxid.GetHex().c_str());
//fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d playertxid.%s\n",pname.size()!=0?pname.c_str():Rogue_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size(),playertxid.GetHex().c_str());
memset(&P,0,sizeof(P));
if ( playerdata.size() > 0 )
{
@@ -969,6 +991,7 @@ char *rogue_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vecto
fclose(fp);
}
}
//fprintf(stderr,"call replay2\n");
num = rogue_replay2(newplayer,seed,keystrokes,numkeys,playerdata.size()==0?0:&P,0);
newdata.resize(num);
for (i=0; i<num; i++)
@@ -976,6 +999,7 @@ char *rogue_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vecto
newdata[i] = newplayer[i];
((uint8_t *)&endP)[i] = newplayer[i];
}
//fprintf(stderr,"back replay2 gold.%d\n",endP.gold);
if ( endP.gold <= 0 || endP.hitpoints <= 0 || (endP.strength&0xffff) <= 0 || endP.level <= 0 || endP.experience <= 0 || endP.dungeonlevel <= 0 )
{
sprintf(str,"zero value character was killed -> no playerdata\n");
@@ -1075,17 +1099,14 @@ int32_t rogue_playerdata_validate(int64_t *cashoutp,uint256 &playertxid,struct C
*cashoutp = 0;
roguepk = GetUnspendable(cp,0);
GetCCaddress1of2(cp,rogueaddr,roguepk,pk);
//fprintf(stderr,"call extractgame\n");
if ( (keystrokes= rogue_extractgame(0,str,&numkeys,newdata,seed,playertxid,cp,gametxid,rogueaddr)) != 0 )
{
//fprintf(stderr,"numkeys.%d rogue_extractgame %s\n",numkeys,gametxid.GetHex().c_str());
free(keystrokes);
sprintf(fname,"rogue.%llu.pack",(long long)seed);
remove(fname);
//fprintf(stderr,"extracted.(%s)\n",str);
for (i=0; i<playerdata.size(); i++)
((uint8_t *)&P)[i] = playerdata[i];
for (i=0; i<newdata.size(); i++)
((uint8_t *)&P)[i] = newdata[i];
if ( P.amulet != 0 )
mult *= 5;
dungeonlevel = P.dungeonlevel;
@@ -1113,6 +1134,17 @@ int32_t rogue_playerdata_validate(int64_t *cashoutp,uint256 &playertxid,struct C
}
return(0);
}
newdata[0] = newdata[1] = playerdata[0] = playerdata[1] = 0; // vout.2 check will validate gold
if ( newdata == playerdata )
{
if ( gametxid != prevgame )
{
prevgame = gametxid;
good++;
fprintf(stderr,"%s matched after clearing lower 16bits of gold good.%d bad.%d\n",gametxid.GetHex().c_str(),good,bad);
}
return(0);
}
if ( P.gold <= 0 || P.hitpoints <= 0 || (P.strength&0xffff) <= 0 || P.level <= 0 || P.experience <= 0 || P.dungeonlevel <= 0 )
{
//P.gold = (P.gold * 8) / 10;
@@ -1134,6 +1166,8 @@ int32_t rogue_playerdata_validate(int64_t *cashoutp,uint256 &playertxid,struct C
{
prevgame = gametxid;
bad++;
disp_playerdata(newdata);
disp_playerdata(playerdata);
fprintf(stderr,"%s playerdata: gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d\n",gametxid.GetHex().c_str(),P.gold,P.hitpoints,P.strength&0xffff,P.strength>>16,P.level,P.experience,P.dungeonlevel);
fprintf(stderr,"newdata[%d] != playerdata[%d], numkeys.%d %s pub.%s playertxid.%s good.%d bad.%d\n",(int32_t)newdata.size(),(int32_t)playerdata.size(),numkeys,rogueaddr,pubkey33_str(str2,(uint8_t *)&pk),playertxid.GetHex().c_str(),good,bad);
}
@@ -1158,7 +1192,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param
// vout0 -> 1% ingame gold
// get any playerdata, get all keystrokes, replay game and compare final state
CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight());
UniValue result(UniValue::VOBJ); std::string rawtx,symbol,pname; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue,inputsum,cashout,CCchange=0; int32_t i,err,gameheight,tmp,numplayers,regslot,n,num,dungeonlevel,numkeys,maxplayers,batonht,batonvout; char myrogueaddr[64],*keystrokes = 0; std::vector<uint8_t> playerdata,newdata,nodata; uint256 batontxid,playertxid,gametxid; CPubKey mypk,roguepk; uint8_t player[10000],mypriv[32],funcid;
UniValue result(UniValue::VOBJ); std::string rawtx,symbol,pname; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue,inputsum,cashout=0,CCchange=0; int32_t i,err,gameheight,tmp,numplayers,regslot,n,num,dungeonlevel,numkeys,maxplayers,batonht,batonvout; char myrogueaddr[64],*keystrokes = 0; std::vector<uint8_t> playerdata,newdata,nodata; uint256 batontxid,playertxid,gametxid; CPubKey mypk,roguepk; uint8_t player[10000],mypriv[32],funcid;
struct CCcontract_info *cpTokens, tokensC;
if ( txfee == 0 )
@@ -1230,8 +1264,8 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param
if ( P.amulet != 0 )
mult *= 5;
dungeonlevel = P.dungeonlevel;
if ( P.amulet != 0 && dungeonlevel < 21 )
dungeonlevel = 21;
if ( P.amulet != 0 && dungeonlevel < 26 )
dungeonlevel = 26;
cashout = (uint64_t)P.gold * P.gold * mult * dungeonlevel;
fprintf(stderr,"\nextracted $$$gold.%d -> %.8f ROGUE hp.%d strength.%d/%d level.%d exp.%d dl.%d n.%d amulet.%d\n",P.gold,(double)cashout/COIN,P.hitpoints,P.strength&0xffff,P.strength>>16,P.level,P.experience,P.dungeonlevel,n,P.amulet);
if ( funcid == 'H' && maxplayers > 1 )
@@ -1245,15 +1279,16 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param
}
cashout += numplayers * buyin;
}
if ( cashout >= txfee )
if ( cashout > 0 )
{
if ( (inputsum= AddCClibInputs(cp,mtx,roguepk,cashout,16,cp->unspendableCCaddr)) > (uint64_t)P.gold*mult )
if ( (inputsum= AddCClibInputs(cp,mtx,roguepk,cashout,16,cp->unspendableCCaddr)) > cashout )
CCchange = (inputsum - cashout);
mtx.vout.push_back(CTxOut(cashout,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG));
}
mtx.vout.push_back(CTxOut(cashout,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG));
}
}
mtx.vout.push_back(MakeCC1vout(cp->evalcode,CCchange + (batonvalue-3*txfee),roguepk));
if ( CCchange + (batonvalue-3*txfee) >= txfee )
mtx.vout.push_back(MakeCC1vout(cp->evalcode,CCchange + (batonvalue-3*txfee),roguepk));
Myprivkey(mypriv);
CCaddr1of2set(cp,roguepk,mypk,mypriv,myrogueaddr);
CScript opret;
@@ -1465,6 +1500,8 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C
if ( (numvouts= tx.vout.size()) > 1 )
{
txid = tx.GetHash();
if ( txid == Parseuint256("1ae04dc0c5f2fca2053819a3a1b2efe5d355c34f58d6f16d59e5e2573e7baf7f") ) // osx rogue chain ht.50902
enabled = 0;
scriptPubKey = tx.vout[numvouts-1].scriptPubKey;
GetOpReturnData(scriptPubKey,vopret);
if ( vopret.size() > 2 )
@@ -1539,29 +1576,32 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C
return eval->Invalid("couldnt decode H/Q opret");
}
// verify pk belongs to this tx
if ( tokentx == 'c' && playerdata.size() > 0 )
if ( tokentx == 'c' )
{
static char laststr[512]; char cashstr[512];
if ( rogue_playerdata_validate(&cashout,ptxid,cp,playerdata,gametxid,pk) < 0 )
if ( playerdata.size() > 0 )
{
sprintf(cashstr,"tokentx.(%c) decoded.%d ht.%d gametxid.%s player.%s invalid playerdata[%d]\n",tokentx,decoded,height,gametxid.GetHex().c_str(),ptxid.GetHex().c_str(),(int32_t)playerdata.size());
static char laststr[512]; char cashstr[512];
if ( rogue_playerdata_validate(&cashout,ptxid,cp,playerdata,gametxid,pk) < 0 )
{
sprintf(cashstr,"tokentx.(%c) decoded.%d ht.%d gametxid.%s player.%s invalid playerdata[%d]\n",tokentx,decoded,height,gametxid.GetHex().c_str(),ptxid.GetHex().c_str(),(int32_t)playerdata.size());
if ( strcmp(laststr,cashstr) != 0 )
{
strcpy(laststr,cashstr);
fprintf(stderr,"%s\n",cashstr);
}
if ( enabled != 0 )
return eval->Invalid("mismatched playerdata");
}
if ( funcid == 'H' )
cashout *= 2;
sprintf(cashstr,"tokentx.(%c) decoded.%d ht.%d txid.%s %.8f vs vout2 %.8f",tokentx,decoded,height,txid.GetHex().c_str(),(double)cashout/COIN,(double)tx.vout[2].nValue/COIN);
if ( strcmp(laststr,cashstr) != 0 )
{
strcpy(laststr,cashstr);
fprintf(stderr,"%s\n",cashstr);
}
if ( enabled != 0 )
return eval->Invalid("mismatched playerdata");
}
if ( funcid == 'H' )
cashout *= 2;
sprintf(cashstr,"tokentx.(%c) decoded.%d ht.%d txid.%s %.8f vs vout2 %.8f",tokentx,decoded,height,txid.GetHex().c_str(),(double)cashout/COIN,(double)tx.vout[2].nValue/COIN);
if ( strcmp(laststr,cashstr) != 0 )
{
strcpy(laststr,cashstr);
fprintf(stderr,"%s\n",cashstr);
}
if ( enabled != 0 && tx.vout[2].nValue != cashout )
} else cashout = 10000;
if ( enabled != 0 && tx.vout[2].nValue > cashout )
return eval->Invalid("mismatched cashout amount");
}
if ( funcid == 'Q' )

3
src/fiat/ilien Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/bash
./komodo-cli -ac_name=ILN $1 $2 $3 $4 $5 $6

View File

@@ -1623,7 +1623,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_
fprintf(stderr,"ht.%d isPoS.%d utxo not validated -> must be PoW fake\n",height,isPoS);
isPoS = 0;
}
else
else if ( ASSETCHAINS_STAKED != 100 )
{
if ( bhash < POWTarget )
{

View File

@@ -1655,6 +1655,87 @@ UniValue getmempoolinfo(const UniValue& params, bool fHelp)
return mempoolInfoToJSON();
}
inline CBlockIndex* LookupBlockIndex(const uint256& hash)
{
AssertLockHeld(cs_main);
BlockMap::const_iterator it = mapBlockIndex.find(hash);
return it == mapBlockIndex.end() ? nullptr : it->second;
}
UniValue getchaintxstats(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() > 2)
throw runtime_error(
"getchaintxstats\n"
"\nCompute statistics about the total number and rate of transactions in the chain.\n"
"\nArguments:\n"
"1. nblocks (numeric, optional) Number of blocks in averaging window.\n"
"2. blockhash (string, optional) The hash of the block which ends the window.\n"
"\nResult:\n"
"{\n"
" \"time\": xxxxx, (numeric) The timestamp for the final block in the window in UNIX format.\n"
" \"txcount\": xxxxx, (numeric) The total number of transactions in the chain up to that point.\n"
" \"window_final_block_hash\": \"...\", (string) The hash of the final block in the window.\n"
" \"window_block_count\": xxxxx, (numeric) Size of the window in number of blocks.\n"
" \"window_tx_count\": xxxxx, (numeric) The number of transactions in the window. Only returned if \"window_block_count\" is > 0.\n"
" \"window_interval\": xxxxx, (numeric) The elapsed time in the window in seconds. Only returned if \"window_block_count\" is > 0.\n"
" \"txrate\": x.xx, (numeric) The average rate of transactions per second in the window. Only returned if \"window_interval\" is > 0.\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("getchaintxstats", "")
+ HelpExampleRpc("getchaintxstats", "2016")
);
const CBlockIndex* pindex;
int blockcount = 30 * 24 * 60 * 60 / Params().GetConsensus().nPowTargetSpacing; // By default: 1 month
if (params[1].isNull()) {
LOCK(cs_main);
pindex = chainActive.Tip();
} else {
uint256 hash(ParseHashV(params[1], "blockhash"));
LOCK(cs_main);
pindex = LookupBlockIndex(hash);
if (!pindex) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
}
if (!chainActive.Contains(pindex)) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Block is not in main chain");
}
}
assert(pindex != nullptr);
if (params[0].isNull()) {
blockcount = std::max(0, std::min(blockcount, pindex->GetHeight() - 1));
} else {
blockcount = params[0].get_int();
if (blockcount < 0 || (blockcount > 0 && blockcount >= pindex->GetHeight())) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid block count: should be between 0 and the block's height - 1");
}
}
const CBlockIndex* pindexPast = pindex->GetAncestor(pindex->GetHeight() - blockcount);
int nTimeDiff = pindex->GetMedianTimePast() - pindexPast->GetMedianTimePast();
int nTxDiff = pindex->nChainTx - pindexPast->nChainTx;
UniValue ret(UniValue::VOBJ);
ret.pushKV("time", (int64_t)pindex->nTime);
ret.pushKV("txcount", (int64_t)pindex->nChainTx);
ret.pushKV("window_final_block_hash", pindex->GetBlockHash().GetHex());
ret.pushKV("window_block_count", blockcount);
if (blockcount > 0) {
ret.pushKV("window_tx_count", nTxDiff);
ret.pushKV("window_interval", nTimeDiff);
if (nTimeDiff > 0) {
ret.pushKV("txrate", ((double)nTxDiff) / nTimeDiff);
}
}
return ret;
}
UniValue invalidateblock(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 1)
@@ -1742,6 +1823,7 @@ static const CRPCCommand commands[] =
{ "blockchain", "getblockhash", &getblockhash, true },
{ "blockchain", "getblockheader", &getblockheader, true },
{ "blockchain", "getchaintips", &getchaintips, true },
{ "blockchain", "getchaintxstats", &getchaintxstats, true },
{ "blockchain", "getdifficulty", &getdifficulty, true },
{ "blockchain", "getmempoolinfo", &getmempoolinfo, true },
{ "blockchain", "getrawmempool", &getrawmempool, true },

View File

@@ -89,6 +89,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
{ "listunspent", 2 },
{ "getblock", 1 },
{ "getblockheader", 1 },
{ "getchaintxstats", 0 },
{ "getlastsegidstakes", 0 },
{ "gettransaction", 1 },
{ "getrawtransaction", 1 },

View File

@@ -49,6 +49,7 @@
using namespace std;
#include "komodo_defs.h"
extern int32_t ASSETCHAINS_FOUNDERS;
arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t height,int32_t goalperc);
@@ -785,10 +786,10 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
if (tx.IsCoinBase() && coinbasetxn == true ) {
// Show founders' reward if it is required
//if (pblock->vtx[0].vout.size() > 1) {
if (ASSETCHAINS_FOUNDERS && pblock->vtx[0].vout.size() > 1) {
// Correct this if GetBlockTemplate changes the order
// entry.push_back(Pair("foundersreward", (int64_t)tx.vout[1].nValue));
//}
entry.push_back(Pair("foundersreward", (int64_t)tx.vout[1].nValue));
}
CAmount nReward = GetBlockSubsidy(chainActive.LastTip()->GetHeight()+1, Params().GetConsensus());
entry.push_back(Pair("coinbasevalue", nReward));
entry.push_back(Pair("required", true));

View File

@@ -441,7 +441,7 @@ uint32_t komodo_segid32(char *coinaddr);
UniValue CBlockTreeDB::Snapshot(int top)
{
int64_t total = 0; int64_t totalAddresses = 0; std::string address;
int64_t utxos = 0; int64_t ignoredAddresses;
int64_t utxos = 0; int64_t ignoredAddresses = 0;
boost::scoped_ptr<CDBIterator> iter(NewIterator());
std::map <std::string, CAmount> addressAmounts;
std::vector <std::pair<CAmount, std::string>> vaddr;
@@ -491,27 +491,31 @@ UniValue CBlockTreeDB::Snapshot(int top)
getAddressFromIndex(indexKey.type, indexKey.hashBytes, address);
std::map <std::string, int>::iterator ignored = ignoredMap.find(address);
if (ignored != ignoredMap.end()) {
fprintf(stderr,"ignoring %s\n", address.c_str());
ignoredAddresses++;
continue;
}
if (nValue > 0) {
std::map <std::string, int>::iterator ignored = ignoredMap.find(address);
if (ignored != ignoredMap.end()) {
fprintf(stderr,"ignoring %s\n", address.c_str());
ignoredAddresses++;
continue;
}
std::map <std::string, CAmount>::iterator pos = addressAmounts.find(address);
if (pos == addressAmounts.end()) {
// insert new address + utxo amount
//fprintf(stderr, "inserting new address %s with amount %li\n", address.c_str(), nValue);
addressAmounts[address] = nValue;
totalAddresses++;
std::map <std::string, CAmount>::iterator pos = addressAmounts.find(address);
if (pos == addressAmounts.end()) {
// insert new address + utxo amount
//fprintf(stderr, "inserting new address %s with amount %li\n", address.c_str(), nValue);
addressAmounts[address] = nValue;
totalAddresses++;
} else {
// update unspent tally for this address
//fprintf(stderr, "updating address %s with new utxo amount %li\n", address.c_str(), nValue);
addressAmounts[address] += nValue;
}
//fprintf(stderr,"{\"%s\", %.8f},\n",address.c_str(),(double)nValue/COIN);
// total += nValue;
utxos++;
} else {
// update unspent tally for this address
//fprintf(stderr, "updating address %s with new utxo amount %li\n", address.c_str(), nValue);
addressAmounts[address] += nValue;
fprintf(stderr,"ignoring amount=0 UTXO for %s\n", address.c_str());
}
//fprintf(stderr,"{\"%s\", %.8f},\n",address.c_str(),(double)nValue/COIN);
// total += nValue;
utxos++;
} catch (const std::exception& e) {
fprintf(stderr, "DONE %s: LevelDB addressindex exception! - %s\n", __func__, e.what());
break;

View File

@@ -5369,9 +5369,12 @@ UniValue CCaddress(struct CCcontract_info *cp,char *name,std::vector<unsigned ch
result.push_back(Pair("result", "success"));
sprintf(str,"%sCCAddress",name);
result.push_back(Pair(str,cp->unspendableCCaddr));
result.push_back(Pair("CCbalance",ValueFromAmount(CCaddress_balance(cp->unspendableCCaddr))));
sprintf(str,"%sCCBalance",name);
result.push_back(Pair(str,ValueFromAmount(CCaddress_balance(cp->unspendableCCaddr))));
sprintf(str,"%sNormalAddress",name);
result.push_back(Pair(str,cp->normaladdr));
sprintf(str,"%sNormalBalance",name);
result.push_back(Pair(str,ValueFromAmount(CCaddress_balance(cp->normaladdr))));
if (strcmp(name,"Gateways")==0) result.push_back(Pair("GatewaysPubkey","03ea9c062b9652d8eff34879b504eda0717895d27597aaeb60347d65eed96ccb40"));
if ((strcmp(name,"Channels")==0 || strcmp(name,"Heir")==0) && pubkey.size() == 33)
{
@@ -5393,25 +5396,22 @@ UniValue CCaddress(struct CCcontract_info *cp,char *name,std::vector<unsigned ch
result.push_back(Pair(str,destaddr));
}
}
//if ( Getscriptaddress(destaddr,(CScript() << Mypubkey() << OP_CHECKSIG)) != 0 )
// result.push_back(Pair("myAddress",destaddr));
if ( GetCCaddress(cp,destaddr,pubkey2pk(Mypubkey())) != 0 )
{
sprintf(str,"myCCAddress(%s)",name);
result.push_back(Pair(str,destaddr));
}
if ( pubkey.size() == 33 )
{
if ( GetCCaddress(cp,destaddr,pubkey2pk(pubkey)) != 0 )
{
sprintf(str,"PubkeyCCaddress(%s)",name);
result.push_back(Pair(str,destaddr));
sprintf(str,"PubkeyCCbalance(%s)",name);
result.push_back(Pair(str,ValueFromAmount(CCaddress_balance(destaddr))));
}
}
if ( GetCCaddress(cp,destaddr,pubkey2pk(Mypubkey())) != 0 )
{
result.push_back(Pair("myCCaddress",destaddr));
result.push_back(Pair("myCCbalance",ValueFromAmount(CCaddress_balance(destaddr))));
sprintf(str,"myCCAddress(%s)",name);
result.push_back(Pair(str,destaddr));
sprintf(str,"myCCbalance(%s)",name);
result.push_back(Pair(str,ValueFromAmount(CCaddress_balance(destaddr))));
}
if ( Getscriptaddress(destaddr,(CScript() << Mypubkey() << OP_CHECKSIG)) != 0 )
{