@@ -182,7 +182,7 @@
|
|||||||
"190.114.254.104"
|
"190.114.254.104"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ac_name": "DION",
|
"ac_name": "DION",
|
||||||
"ac_supply": "3900000000",
|
"ac_supply": "3900000000",
|
||||||
"ac_reward": "22260000000",
|
"ac_reward": "22260000000",
|
||||||
@@ -247,4 +247,5 @@
|
|||||||
"ac_cc": "2",
|
"ac_cc": "2",
|
||||||
"addnode": ["51.75.122.83"]
|
"addnode": ["51.75.122.83"]
|
||||||
}
|
}
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -147,6 +147,13 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti
|
|||||||
outputsDummy = inputs = 0;
|
outputsDummy = inputs = 0;
|
||||||
preventCCvins = preventCCvouts = -1;
|
preventCCvins = preventCCvouts = -1;
|
||||||
|
|
||||||
|
// add specific chains exceptions for old token support:
|
||||||
|
if (strcmp(ASSETCHAINS_SYMBOL, "SEC") == 0 && chainActive.Height() <= 144073)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (strcmp(ASSETCHAINS_SYMBOL, "MGNX") == 0 && chainActive.Height() <= 210190)
|
||||||
|
return true;
|
||||||
|
|
||||||
// add specific chains exceptions for old token support:
|
// add specific chains exceptions for old token support:
|
||||||
if (strcmp(ASSETCHAINS_SYMBOL, "SEC") == 0 && chainActive.Height() <= 144073)
|
if (strcmp(ASSETCHAINS_SYMBOL, "SEC") == 0 && chainActive.Height() <= 144073)
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1213,6 +1213,9 @@ int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbit
|
|||||||
} else {
|
} else {
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
//fprintf(stderr,"numentropy tx %d: %.8f\n",n,(double)totalinputs/COIN);
|
||||||
|
entropytxs = n;
|
||||||
|
return(totalinputs);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DicePlanExists(CScript &fundingPubKey,uint256 &fundingtxid,struct CCcontract_info *cp,uint64_t refsbits,CPubKey dicepk,int64_t &minbet,int64_t &maxbet,int64_t &maxodds,int64_t &timeoutblocks)
|
bool DicePlanExists(CScript &fundingPubKey,uint256 &fundingtxid,struct CCcontract_info *cp,uint64_t refsbits,CPubKey dicepk,int64_t &minbet,int64_t &maxbet,int64_t &maxodds,int64_t &timeoutblocks)
|
||||||
|
|||||||
@@ -2929,26 +2929,28 @@ int32_t main(void)
|
|||||||
void calc_rmd160_sha256(uint8_t rmd160[20],uint8_t *data,int32_t datalen);
|
void calc_rmd160_sha256(uint8_t rmd160[20],uint8_t *data,int32_t datalen);
|
||||||
char *bitcoin_address(char *coinaddr,uint8_t addrtype,uint8_t *pubkey_or_rmd160,int32_t len);
|
char *bitcoin_address(char *coinaddr,uint8_t addrtype,uint8_t *pubkey_or_rmd160,int32_t len);
|
||||||
|
|
||||||
int32_t dilithium_Qmsghash(uint8_t *msg,CTransaction tx,std::vector<uint256> voutpubtxids)
|
int32_t dilithium_Qmsghash(uint8_t *msg,CTransaction tx,int32_t numvouts,std::vector<uint256> voutpubtxids)
|
||||||
{
|
{
|
||||||
CScript data; uint256 hash; int32_t i,numvins,numvouts,len = 0; std::vector<uint256> vintxids; std::vector<int32_t> vinprevns; std::vector<CTxOut> vouts;
|
CScript data; uint256 hash; int32_t i,numvins,len = 0; std::vector<uint256> vintxids; std::vector<int32_t> vinprevns; std::vector<CTxOut> vouts;
|
||||||
numvins = tx.vin.size();
|
numvins = tx.vin.size();
|
||||||
numvouts = tx.vout.size();
|
for (i=0; i<numvins; i++)
|
||||||
if ( tx.vout[numvouts-1].scriptPubKey[0] == 0x6a )
|
|
||||||
{
|
{
|
||||||
for (i=0; i<numvins; i++)
|
vintxids.push_back(tx.vin[i].prevout.hash);
|
||||||
{
|
vinprevns.push_back(tx.vin[i].prevout.n);
|
||||||
vintxids.push_back(tx.vin[i].prevout.hash);
|
//fprintf(stderr,"%s/v%d ",tx.vin[i].prevout.hash.GetHex().c_str(),tx.vin[i].prevout.n);
|
||||||
vinprevns.push_back(tx.vin[i].prevout.n);
|
}
|
||||||
}
|
for (i=0; i<numvouts; i++)
|
||||||
for (i=0; i<numvouts-1; i++)
|
{
|
||||||
vouts.push_back(tx.vout[i]);
|
//char destaddr[64];
|
||||||
data << E_MARSHAL(ss << vintxids << vinprevns << vouts << voutpubtxids);
|
//Getscriptaddress(destaddr,tx.vout[i].scriptPubKey);
|
||||||
fprintf(stderr,"size of data.%d\n",(int32_t)data.size());
|
//fprintf(stderr,"%s %.8f ",destaddr,(double)tx.vout[i].nValue/COIN);
|
||||||
hash = Hash(data.begin(),data.end());
|
vouts.push_back(tx.vout[i]);
|
||||||
memcpy(msg,&hash,sizeof(hash));
|
}
|
||||||
return(0);
|
data << E_MARSHAL(ss << vintxids << vinprevns << vouts << voutpubtxids);
|
||||||
} else return(-1);
|
//fprintf(stderr,"numvins.%d numvouts.%d size of data.%d\n",numvins,numvouts,(int32_t)data.size());
|
||||||
|
hash = Hash(data.begin(),data.end());
|
||||||
|
memcpy(msg,&hash,sizeof(hash));
|
||||||
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
CScript dilithium_registeropret(std::string handle,CPubKey pk,std::vector<uint8_t> bigpub)
|
CScript dilithium_registeropret(std::string handle,CPubKey pk,std::vector<uint8_t> bigpub)
|
||||||
@@ -3367,7 +3369,10 @@ UniValue dilithium_Qsend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params
|
|||||||
voutpubtxids.push_back(mypubtxid);
|
voutpubtxids.push_back(mypubtxid);
|
||||||
}
|
}
|
||||||
tx = mtx;
|
tx = mtx;
|
||||||
dilithium_Qmsghash(msg,tx,voutpubtxids);
|
dilithium_Qmsghash(msg,tx,(int32_t)voutpubtxids.size(),voutpubtxids);
|
||||||
|
//for (i=0; i<32; i++)
|
||||||
|
// fprintf(stderr,"%02x",msg[i]);
|
||||||
|
//fprintf(stderr," msg\n");
|
||||||
sig.resize(32+CRYPTO_BYTES);
|
sig.resize(32+CRYPTO_BYTES);
|
||||||
if ( dilithium_bigpubget(handle,destpub33,pk2,mypubtxid) < 0 )
|
if ( dilithium_bigpubget(handle,destpub33,pk2,mypubtxid) < 0 )
|
||||||
return(cclib_error(result,"couldnt get bigpub"));
|
return(cclib_error(result,"couldnt get bigpub"));
|
||||||
@@ -3423,7 +3428,7 @@ bool dilithium_Qvalidate(struct CCcontract_info *cp,int32_t height,Eval *eval,co
|
|||||||
numvouts = tx.vout.size();
|
numvouts = tx.vout.size();
|
||||||
if ( dilithium_Qsendopretdecode(destpubtxid,sig,voutpubtxids,tx.vout[numvouts-1].scriptPubKey) == 'Q' && destpubtxid == signerpubtxid && sig.size() == smlen )
|
if ( dilithium_Qsendopretdecode(destpubtxid,sig,voutpubtxids,tx.vout[numvouts-1].scriptPubKey) == 'Q' && destpubtxid == signerpubtxid && sig.size() == smlen )
|
||||||
{
|
{
|
||||||
if ( dilithium_Qmsghash(msg,tx,voutpubtxids) < 0 )
|
if ( dilithium_Qmsghash(msg,tx,numvouts-1,voutpubtxids) < 0 )
|
||||||
return eval->Invalid("couldnt get Qmsghash");
|
return eval->Invalid("couldnt get Qmsghash");
|
||||||
else if ( dilithium_bigpubget(handle,destpub33,pk,signerpubtxid) < 0 )
|
else if ( dilithium_bigpubget(handle,destpub33,pk,signerpubtxid) < 0 )
|
||||||
return eval->Invalid("couldnt get bigpub");
|
return eval->Invalid("couldnt get bigpub");
|
||||||
@@ -3432,7 +3437,15 @@ bool dilithium_Qvalidate(struct CCcontract_info *cp,int32_t height,Eval *eval,co
|
|||||||
if ( _dilithium_verify(msg2,&mlen,&sig[0],smlen,pk) < 0 )
|
if ( _dilithium_verify(msg2,&mlen,&sig[0],smlen,pk) < 0 )
|
||||||
return eval->Invalid("failed dilithium verify");
|
return eval->Invalid("failed dilithium verify");
|
||||||
else if ( mlen != 32 || memcmp(msg,msg2,32) != 0 )
|
else if ( mlen != 32 || memcmp(msg,msg2,32) != 0 )
|
||||||
|
{
|
||||||
|
for (i=0; i<32; i++)
|
||||||
|
fprintf(stderr,"%02x",msg[i]);
|
||||||
|
fprintf(stderr," vs ");
|
||||||
|
for (i=0; i<mlen; i++)
|
||||||
|
fprintf(stderr,"%02x",msg2[i]);
|
||||||
|
fprintf(stderr,"mlen.%d\n",mlen);
|
||||||
return eval->Invalid("failed dilithium msg verify");
|
return eval->Invalid("failed dilithium msg verify");
|
||||||
|
}
|
||||||
else return true;
|
else return true;
|
||||||
}
|
}
|
||||||
} else return eval->Invalid("failed decode Qsend");
|
} else return eval->Invalid("failed decode Qsend");
|
||||||
|
|||||||
@@ -235,6 +235,7 @@ int32_t safecopy(char *dest,char *src,long len)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
int32_t rogue_replay(uint64_t seed,int32_t sleeptime);
|
int32_t rogue_replay(uint64_t seed,int32_t sleeptime);
|
||||||
|
char *rogue_keystrokesload(int32_t *numkeysp,uint64_t seed,int32_t counter);
|
||||||
int rogue(int argc, char **argv, char **envp);
|
int rogue(int argc, char **argv, char **envp);
|
||||||
|
|
||||||
void *OS_loadfile(char *fname,uint8_t **bufp,long *lenp,long *allocsizep)
|
void *OS_loadfile(char *fname,uint8_t **bufp,long *lenp,long *allocsizep)
|
||||||
@@ -741,7 +742,7 @@ int32_t rogue_sendrawtransaction(char *rawtx)
|
|||||||
|
|
||||||
void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char *keystrokes,int32_t num)
|
void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char *keystrokes,int32_t num)
|
||||||
{
|
{
|
||||||
char cmd[16384],hexstr[16384],params[32768],*retstr,*rawtx; int32_t i; cJSON *retjson;
|
char cmd[16384],hexstr[16384],params[32768],*retstr,*rawtx,*pastkeys; int32_t i,numpastkeys; cJSON *retjson;
|
||||||
//fprintf(stderr,"rogue_progress num.%d\n",num);
|
//fprintf(stderr,"rogue_progress num.%d\n",num);
|
||||||
if ( rs->guiflag != 0 && Gametxidstr[0] != 0 )
|
if ( rs->guiflag != 0 && Gametxidstr[0] != 0 )
|
||||||
{
|
{
|
||||||
@@ -762,6 +763,11 @@ void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char *
|
|||||||
}
|
}
|
||||||
free(rs->keystrokeshex), rs->keystrokeshex = 0;
|
free(rs->keystrokeshex), rs->keystrokeshex = 0;
|
||||||
}
|
}
|
||||||
|
if ( (pastkeys= rogue_keystrokesload(&numpastkeys,seed,1)) != 0 )
|
||||||
|
{
|
||||||
|
free(pastkeys);
|
||||||
|
}
|
||||||
|
|
||||||
for (i=0; i<num; i++)
|
for (i=0; i<num; i++)
|
||||||
sprintf(&hexstr[i<<1],"%02x",keystrokes[i]&0xff);
|
sprintf(&hexstr[i<<1],"%02x",keystrokes[i]&0xff);
|
||||||
hexstr[i<<1] = 0;
|
hexstr[i<<1] = 0;
|
||||||
|
|||||||
@@ -27,19 +27,19 @@ do_passages(struct rogue_state *rs)
|
|||||||
int roomcount;
|
int roomcount;
|
||||||
static struct rdes
|
static struct rdes
|
||||||
{
|
{
|
||||||
bool conn[MAXROOMS]; /* possible to connect to room i? */
|
bool conn[MAXROOMS]; /* possible to connect to room i? */
|
||||||
bool isconn[MAXROOMS]; /* connection been made to room i? */
|
bool isconn[MAXROOMS]; /* connection been made to room i? */
|
||||||
bool ingraph; /* this room in graph already? */
|
bool ingraph; /* this room in graph already? */
|
||||||
} rdes[MAXROOMS] = {
|
} rdes[MAXROOMS] = {
|
||||||
{ { 0, 1, 0, 1, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0 },
|
{ { 0, 1, 0, 1, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0 },
|
||||||
{ { 1, 0, 1, 0, 1, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0 },
|
{ { 1, 0, 1, 0, 1, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0 },
|
||||||
{ { 0, 1, 0, 0, 0, 1, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0 },
|
{ { 0, 1, 0, 0, 0, 1, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0 },
|
||||||
{ { 1, 0, 0, 0, 1, 0, 1, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0 },
|
{ { 1, 0, 0, 0, 1, 0, 1, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0 },
|
||||||
{ { 0, 1, 0, 1, 0, 1, 0, 1, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0 },
|
{ { 0, 1, 0, 1, 0, 1, 0, 1, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0 },
|
||||||
{ { 0, 0, 1, 0, 1, 0, 0, 0, 1 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0 },
|
{ { 0, 0, 1, 0, 1, 0, 0, 0, 1 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0 },
|
||||||
{ { 0, 0, 0, 1, 0, 0, 0, 1, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0 },
|
{ { 0, 0, 0, 1, 0, 0, 0, 1, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0 },
|
||||||
{ { 0, 0, 0, 0, 1, 0, 1, 0, 1 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0 },
|
{ { 0, 0, 0, 0, 1, 0, 1, 0, 1 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0 },
|
||||||
{ { 0, 0, 0, 0, 0, 1, 0, 1, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0 },
|
{ { 0, 0, 0, 0, 0, 1, 0, 1, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -47,9 +47,9 @@ do_passages(struct rogue_state *rs)
|
|||||||
*/
|
*/
|
||||||
for (r1 = rdes; r1 <= &rdes[MAXROOMS-1]; r1++)
|
for (r1 = rdes; r1 <= &rdes[MAXROOMS-1]; r1++)
|
||||||
{
|
{
|
||||||
for (j = 0; j < MAXROOMS; j++)
|
for (j = 0; j < MAXROOMS; j++)
|
||||||
r1->isconn[j] = FALSE;
|
r1->isconn[j] = FALSE;
|
||||||
r1->ingraph = FALSE;
|
r1->ingraph = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -61,37 +61,37 @@ do_passages(struct rogue_state *rs)
|
|||||||
r1->ingraph = TRUE;
|
r1->ingraph = TRUE;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* find a room to connect with
|
* find a room to connect with
|
||||||
*/
|
*/
|
||||||
j = 0;
|
j = 0;
|
||||||
for (i = 0; i < MAXROOMS; i++)
|
for (i = 0; i < MAXROOMS; i++)
|
||||||
if (r1->conn[i] && !rdes[i].ingraph && rnd(++j) == 0)
|
if (r1->conn[i] && !rdes[i].ingraph && rnd(++j) == 0)
|
||||||
r2 = &rdes[i];
|
r2 = &rdes[i];
|
||||||
/*
|
/*
|
||||||
* if no adjacent rooms are outside the graph, pick a new room
|
* if no adjacent rooms are outside the graph, pick a new room
|
||||||
* to look from
|
* to look from
|
||||||
*/
|
*/
|
||||||
if (j == 0)
|
if (j == 0)
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
r1 = &rdes[rnd(MAXROOMS)];
|
r1 = &rdes[rnd(MAXROOMS)];
|
||||||
until (r1->ingraph);
|
until (r1->ingraph);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* otherwise, connect new room to the graph, and draw a tunnel
|
* otherwise, connect new room to the graph, and draw a tunnel
|
||||||
* to it
|
* to it
|
||||||
*/
|
*/
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
r2->ingraph = TRUE;
|
r2->ingraph = TRUE;
|
||||||
i = (int)(r1 - rdes);
|
i = (int)(r1 - rdes);
|
||||||
j = (int)(r2 - rdes);
|
j = (int)(r2 - rdes);
|
||||||
conn(rs,i, j);
|
conn(rs,i, j);
|
||||||
r1->isconn[j] = TRUE;
|
r1->isconn[j] = TRUE;
|
||||||
r2->isconn[i] = TRUE;
|
r2->isconn[i] = TRUE;
|
||||||
roomcount++;
|
roomcount++;
|
||||||
}
|
}
|
||||||
} while (roomcount < MAXROOMS);
|
} while (roomcount < MAXROOMS);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -100,26 +100,26 @@ do_passages(struct rogue_state *rs)
|
|||||||
*/
|
*/
|
||||||
for (roomcount = rnd(5); roomcount > 0; roomcount--)
|
for (roomcount = rnd(5); roomcount > 0; roomcount--)
|
||||||
{
|
{
|
||||||
r1 = &rdes[rnd(MAXROOMS)]; /* a random room to look from */
|
r1 = &rdes[rnd(MAXROOMS)]; /* a random room to look from */
|
||||||
/*
|
/*
|
||||||
* find an adjacent room not already connected
|
* find an adjacent room not already connected
|
||||||
*/
|
*/
|
||||||
j = 0;
|
j = 0;
|
||||||
for (i = 0; i < MAXROOMS; i++)
|
for (i = 0; i < MAXROOMS; i++)
|
||||||
if (r1->conn[i] && !r1->isconn[i] && rnd(++j) == 0)
|
if (r1->conn[i] && !r1->isconn[i] && rnd(++j) == 0)
|
||||||
r2 = &rdes[i];
|
r2 = &rdes[i];
|
||||||
/*
|
/*
|
||||||
* if there is one, connect it and look for the next added
|
* if there is one, connect it and look for the next added
|
||||||
* passage
|
* passage
|
||||||
*/
|
*/
|
||||||
if (j != 0)
|
if (j != 0)
|
||||||
{
|
{
|
||||||
i = (int)(r1 - rdes);
|
i = (int)(r1 - rdes);
|
||||||
j = (int)(r2 - rdes);
|
j = (int)(r2 - rdes);
|
||||||
conn(rs,i, j);
|
conn(rs,i, j);
|
||||||
r1->isconn[j] = TRUE;
|
r1->isconn[j] = TRUE;
|
||||||
r2->isconn[i] = TRUE;
|
r2->isconn[i] = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
passnum();
|
passnum();
|
||||||
}
|
}
|
||||||
@@ -141,19 +141,19 @@ conn(struct rogue_state *rs,int r1, int r2)
|
|||||||
|
|
||||||
if (r1 < r2)
|
if (r1 < r2)
|
||||||
{
|
{
|
||||||
rm = r1;
|
rm = r1;
|
||||||
if (r1 + 1 == r2)
|
if (r1 + 1 == r2)
|
||||||
direc = 'r';
|
direc = 'r';
|
||||||
else
|
else
|
||||||
direc = 'd';
|
direc = 'd';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rm = r2;
|
rm = r2;
|
||||||
if (r2 + 1 == r1)
|
if (r2 + 1 == r1)
|
||||||
direc = 'r';
|
direc = 'r';
|
||||||
else
|
else
|
||||||
direc = 'd';
|
direc = 'd';
|
||||||
}
|
}
|
||||||
rpf = &rooms[rm];
|
rpf = &rooms[rm];
|
||||||
/*
|
/*
|
||||||
@@ -162,59 +162,59 @@ conn(struct rogue_state *rs,int r1, int r2)
|
|||||||
*/
|
*/
|
||||||
if (direc == 'd')
|
if (direc == 'd')
|
||||||
{
|
{
|
||||||
rmt = rm + 3; /* room # of dest */
|
rmt = rm + 3; /* room # of dest */
|
||||||
rpt = &rooms[rmt]; /* room pointer of dest */
|
rpt = &rooms[rmt]; /* room pointer of dest */
|
||||||
del.x = 0; /* direction of move */
|
del.x = 0; /* direction of move */
|
||||||
del.y = 1;
|
del.y = 1;
|
||||||
spos.x = rpf->r_pos.x; /* start of move */
|
spos.x = rpf->r_pos.x; /* start of move */
|
||||||
spos.y = rpf->r_pos.y;
|
spos.y = rpf->r_pos.y;
|
||||||
epos.x = rpt->r_pos.x; /* end of move */
|
epos.x = rpt->r_pos.x; /* end of move */
|
||||||
epos.y = rpt->r_pos.y;
|
epos.y = rpt->r_pos.y;
|
||||||
if (!(rpf->r_flags & ISGONE)) /* if not gone pick door pos */
|
if (!(rpf->r_flags & ISGONE)) /* if not gone pick door pos */
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
spos.x = rpf->r_pos.x + rnd(rpf->r_max.x - 2) + 1;
|
spos.x = rpf->r_pos.x + rnd(rpf->r_max.x - 2) + 1;
|
||||||
spos.y = rpf->r_pos.y + rpf->r_max.y - 1;
|
spos.y = rpf->r_pos.y + rpf->r_max.y - 1;
|
||||||
} while ((rpf->r_flags&ISMAZE) && !(flat(spos.y, spos.x)&F_PASS));
|
} while ((rpf->r_flags&ISMAZE) && !(flat(spos.y, spos.x)&F_PASS));
|
||||||
if (!(rpt->r_flags & ISGONE))
|
if (!(rpt->r_flags & ISGONE))
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
epos.x = rpt->r_pos.x + rnd(rpt->r_max.x - 2) + 1;
|
epos.x = rpt->r_pos.x + rnd(rpt->r_max.x - 2) + 1;
|
||||||
} while ((rpt->r_flags&ISMAZE) && !(flat(epos.y, epos.x)&F_PASS));
|
} while ((rpt->r_flags&ISMAZE) && !(flat(epos.y, epos.x)&F_PASS));
|
||||||
distance = abs(spos.y - epos.y) - 1; /* distance to move */
|
distance = abs(spos.y - epos.y) - 1; /* distance to move */
|
||||||
turn_delta.y = 0; /* direction to turn */
|
turn_delta.y = 0; /* direction to turn */
|
||||||
turn_delta.x = (spos.x < epos.x ? 1 : -1);
|
turn_delta.x = (spos.x < epos.x ? 1 : -1);
|
||||||
turn_distance = abs(spos.x - epos.x); /* how far to turn */
|
turn_distance = abs(spos.x - epos.x); /* how far to turn */
|
||||||
}
|
}
|
||||||
else if (direc == 'r') /* setup for moving right */
|
else if (direc == 'r') /* setup for moving right */
|
||||||
{
|
{
|
||||||
rmt = rm + 1;
|
rmt = rm + 1;
|
||||||
rpt = &rooms[rmt];
|
rpt = &rooms[rmt];
|
||||||
del.x = 1;
|
del.x = 1;
|
||||||
del.y = 0;
|
del.y = 0;
|
||||||
spos.x = rpf->r_pos.x;
|
spos.x = rpf->r_pos.x;
|
||||||
spos.y = rpf->r_pos.y;
|
spos.y = rpf->r_pos.y;
|
||||||
epos.x = rpt->r_pos.x;
|
epos.x = rpt->r_pos.x;
|
||||||
epos.y = rpt->r_pos.y;
|
epos.y = rpt->r_pos.y;
|
||||||
if (!(rpf->r_flags & ISGONE))
|
if (!(rpf->r_flags & ISGONE))
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
spos.x = rpf->r_pos.x + rpf->r_max.x - 1;
|
spos.x = rpf->r_pos.x + rpf->r_max.x - 1;
|
||||||
spos.y = rpf->r_pos.y + rnd(rpf->r_max.y - 2) + 1;
|
spos.y = rpf->r_pos.y + rnd(rpf->r_max.y - 2) + 1;
|
||||||
} while ((rpf->r_flags&ISMAZE) && !(flat(spos.y, spos.x)&F_PASS));
|
} while ((rpf->r_flags&ISMAZE) && !(flat(spos.y, spos.x)&F_PASS));
|
||||||
if (!(rpt->r_flags & ISGONE))
|
if (!(rpt->r_flags & ISGONE))
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
epos.y = rpt->r_pos.y + rnd(rpt->r_max.y - 2) + 1;
|
epos.y = rpt->r_pos.y + rnd(rpt->r_max.y - 2) + 1;
|
||||||
} while ((rpt->r_flags&ISMAZE) && !(flat(epos.y, epos.x)&F_PASS));
|
} while ((rpt->r_flags&ISMAZE) && !(flat(epos.y, epos.x)&F_PASS));
|
||||||
distance = abs(spos.x - epos.x) - 1;
|
distance = abs(spos.x - epos.x) - 1;
|
||||||
turn_delta.y = (spos.y < epos.y ? 1 : -1);
|
turn_delta.y = (spos.y < epos.y ? 1 : -1);
|
||||||
turn_delta.x = 0;
|
turn_delta.x = 0;
|
||||||
turn_distance = abs(spos.y - epos.y);
|
turn_distance = abs(spos.y - epos.y);
|
||||||
}
|
}
|
||||||
#ifdef MASTER
|
#ifdef MASTER
|
||||||
else
|
else
|
||||||
debug("error in connection tables");
|
debug("error in connection tables");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
turn_spot = rnd(distance - 1) + 1; /* where turn starts */
|
turn_spot = rnd(distance - 1) + 1; /* where turn starts */
|
||||||
@@ -224,13 +224,13 @@ conn(struct rogue_state *rs,int r1, int r2)
|
|||||||
* if the rooms are gone.
|
* if the rooms are gone.
|
||||||
*/
|
*/
|
||||||
if (!(rpf->r_flags & ISGONE))
|
if (!(rpf->r_flags & ISGONE))
|
||||||
door(rpf, &spos);
|
door(rpf, &spos);
|
||||||
else
|
else
|
||||||
putpass(&spos);
|
putpass(&spos);
|
||||||
if (!(rpt->r_flags & ISGONE))
|
if (!(rpt->r_flags & ISGONE))
|
||||||
door(rpt, &epos);
|
door(rpt, &epos);
|
||||||
else
|
else
|
||||||
putpass(&epos);
|
putpass(&epos);
|
||||||
/*
|
/*
|
||||||
* Get ready to move...
|
* Get ready to move...
|
||||||
*/
|
*/
|
||||||
@@ -238,31 +238,31 @@ conn(struct rogue_state *rs,int r1, int r2)
|
|||||||
curr.y = spos.y;
|
curr.y = spos.y;
|
||||||
while (distance > 0)
|
while (distance > 0)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Move to new position
|
* Move to new position
|
||||||
*/
|
*/
|
||||||
curr.x += del.x;
|
curr.x += del.x;
|
||||||
curr.y += del.y;
|
curr.y += del.y;
|
||||||
/*
|
/*
|
||||||
* Check if we are at the turn place, if so do the turn
|
* Check if we are at the turn place, if so do the turn
|
||||||
*/
|
*/
|
||||||
if (distance == turn_spot)
|
if (distance == turn_spot)
|
||||||
while (turn_distance--)
|
while (turn_distance--)
|
||||||
{
|
{
|
||||||
putpass(&curr);
|
putpass(&curr);
|
||||||
curr.x += turn_delta.x;
|
curr.x += turn_delta.x;
|
||||||
curr.y += turn_delta.y;
|
curr.y += turn_delta.y;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Continue digging along
|
* Continue digging along
|
||||||
*/
|
*/
|
||||||
putpass(&curr);
|
putpass(&curr);
|
||||||
distance--;
|
distance--;
|
||||||
}
|
}
|
||||||
curr.x += del.x;
|
curr.x += del.x;
|
||||||
curr.y += del.y;
|
curr.y += del.y;
|
||||||
if (!ce(curr, epos))
|
if (!ce(curr, epos))
|
||||||
msg(rs,"warning, connectivity problem on this level");
|
msg(rs,"warning, connectivity problem on this level");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -278,9 +278,9 @@ putpass(coord *cp)
|
|||||||
pp = INDEX(cp->y, cp->x);
|
pp = INDEX(cp->y, cp->x);
|
||||||
pp->p_flags |= F_PASS;
|
pp->p_flags |= F_PASS;
|
||||||
if (rnd(10) + 1 < level && rnd(40) == 0)
|
if (rnd(10) + 1 < level && rnd(40) == 0)
|
||||||
pp->p_flags &= ~F_REAL;
|
pp->p_flags &= ~F_REAL;
|
||||||
else
|
else
|
||||||
pp->p_ch = PASSAGE;
|
pp->p_ch = PASSAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -297,19 +297,19 @@ door(struct room *rm, coord *cp)
|
|||||||
rm->r_exit[rm->r_nexits++] = *cp;
|
rm->r_exit[rm->r_nexits++] = *cp;
|
||||||
|
|
||||||
if (rm->r_flags & ISMAZE)
|
if (rm->r_flags & ISMAZE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pp = INDEX(cp->y, cp->x);
|
pp = INDEX(cp->y, cp->x);
|
||||||
if (rnd(10) + 1 < level && rnd(5) == 0)
|
if (rnd(10) + 1 < level && rnd(5) == 0)
|
||||||
{
|
{
|
||||||
if (cp->y == rm->r_pos.y || cp->y == rm->r_pos.y + rm->r_max.y - 1)
|
if (cp->y == rm->r_pos.y || cp->y == rm->r_pos.y + rm->r_max.y - 1)
|
||||||
pp->p_ch = '-';
|
pp->p_ch = '-';
|
||||||
else
|
else
|
||||||
pp->p_ch = '|';
|
pp->p_ch = '|';
|
||||||
pp->p_flags &= ~F_REAL;
|
pp->p_flags &= ~F_REAL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
pp->p_ch = DOOR;
|
pp->p_ch = DOOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MASTER
|
#ifdef MASTER
|
||||||
@@ -326,29 +326,29 @@ add_pass()
|
|||||||
char ch;
|
char ch;
|
||||||
|
|
||||||
for (y = 1; y < NUMLINES - 1; y++)
|
for (y = 1; y < NUMLINES - 1; y++)
|
||||||
for (x = 0; x < NUMCOLS; x++)
|
for (x = 0; x < NUMCOLS; x++)
|
||||||
{
|
{
|
||||||
pp = INDEX(y, x);
|
pp = INDEX(y, x);
|
||||||
if ((pp->p_flags & F_PASS) || pp->p_ch == DOOR ||
|
if ((pp->p_flags & F_PASS) || pp->p_ch == DOOR ||
|
||||||
(!(pp->p_flags&F_REAL) && (pp->p_ch == '|' || pp->p_ch == '-')))
|
(!(pp->p_flags&F_REAL) && (pp->p_ch == '|' || pp->p_ch == '-')))
|
||||||
{
|
{
|
||||||
ch = pp->p_ch;
|
ch = pp->p_ch;
|
||||||
if (pp->p_flags & F_PASS)
|
if (pp->p_flags & F_PASS)
|
||||||
ch = PASSAGE;
|
ch = PASSAGE;
|
||||||
pp->p_flags |= F_SEEN;
|
pp->p_flags |= F_SEEN;
|
||||||
move(y, x);
|
move(y, x);
|
||||||
if (pp->p_monst != NULL)
|
if (pp->p_monst != NULL)
|
||||||
pp->p_monst->t_oldch = pp->p_ch;
|
pp->p_monst->t_oldch = pp->p_ch;
|
||||||
else if (pp->p_flags & F_REAL)
|
else if (pp->p_flags & F_REAL)
|
||||||
addch(ch);
|
addch(ch);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
standout();
|
standout();
|
||||||
addch((pp->p_flags & F_PASS) ? PASSAGE : DOOR);
|
addch((pp->p_flags & F_PASS) ? PASSAGE : DOOR);
|
||||||
standend();
|
standend();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -369,13 +369,13 @@ passnum()
|
|||||||
pnum = 0;
|
pnum = 0;
|
||||||
newpnum = FALSE;
|
newpnum = FALSE;
|
||||||
for (rp = passages; rp < &passages[MAXPASS]; rp++)
|
for (rp = passages; rp < &passages[MAXPASS]; rp++)
|
||||||
rp->r_nexits = 0;
|
rp->r_nexits = 0;
|
||||||
for (rp = rooms; rp < &rooms[MAXROOMS]; rp++)
|
for (rp = rooms; rp < &rooms[MAXROOMS]; rp++)
|
||||||
for (i = 0; i < rp->r_nexits; i++)
|
for (i = 0; i < rp->r_nexits; i++)
|
||||||
{
|
{
|
||||||
newpnum ^= 1;//newpnum++;
|
newpnum ^= 1;//newpnum++;
|
||||||
numpass(rp->r_exit[i].y, rp->r_exit[i].x);
|
numpass(rp->r_exit[i].y, rp->r_exit[i].x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -391,28 +391,28 @@ numpass(int y, int x)
|
|||||||
char ch;
|
char ch;
|
||||||
|
|
||||||
if (x >= NUMCOLS || x < 0 || y >= NUMLINES || y <= 0)
|
if (x >= NUMCOLS || x < 0 || y >= NUMLINES || y <= 0)
|
||||||
return;
|
return;
|
||||||
fp = &flat(y, x);
|
fp = &flat(y, x);
|
||||||
if (*fp & F_PNUM)
|
if (*fp & F_PNUM)
|
||||||
return;
|
return;
|
||||||
if (newpnum)
|
if (newpnum)
|
||||||
{
|
{
|
||||||
pnum++;
|
pnum++;
|
||||||
newpnum = FALSE;
|
newpnum = FALSE;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* check to see if it is a door or secret door, i.e., a new exit,
|
* check to see if it is a door or secret door, i.e., a new exit,
|
||||||
* or a numerable type of place
|
* or a numerable type of place
|
||||||
*/
|
*/
|
||||||
if ((ch = chat(y, x)) == DOOR ||
|
if ((ch = chat(y, x)) == DOOR ||
|
||||||
(!(*fp & F_REAL) && (ch == '|' || ch == '-')))
|
(!(*fp & F_REAL) && (ch == '|' || ch == '-')))
|
||||||
{
|
{
|
||||||
rp = &passages[pnum];
|
rp = &passages[pnum];
|
||||||
rp->r_exit[rp->r_nexits].y = y;
|
rp->r_exit[rp->r_nexits].y = y;
|
||||||
rp->r_exit[rp->r_nexits++].x = x;
|
rp->r_exit[rp->r_nexits++].x = x;
|
||||||
}
|
}
|
||||||
else if (!(*fp & F_PASS))
|
else if (!(*fp & F_PASS))
|
||||||
return;
|
return;
|
||||||
*fp |= pnum;
|
*fp |= pnum;
|
||||||
/*
|
/*
|
||||||
* recurse on the surrounding places
|
* recurse on the surrounding places
|
||||||
|
|||||||
@@ -29,38 +29,38 @@ ring_on(struct rogue_state *rs)
|
|||||||
* Make certain that it is somethings that we want to wear
|
* Make certain that it is somethings that we want to wear
|
||||||
*/
|
*/
|
||||||
if (obj == NULL)
|
if (obj == NULL)
|
||||||
return;
|
return;
|
||||||
if (obj->o_type != RING)
|
if (obj->o_type != RING)
|
||||||
{
|
{
|
||||||
if (!terse)
|
if (!terse)
|
||||||
msg(rs,"it would be difficult to wrap that around a finger");
|
msg(rs,"it would be difficult to wrap that around a finger");
|
||||||
else
|
else
|
||||||
msg(rs,"not a ring");
|
msg(rs,"not a ring");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* find out which hand to put it on
|
* find out which hand to put it on
|
||||||
*/
|
*/
|
||||||
if (is_current(rs,obj))
|
if (is_current(rs,obj))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (cur_ring[LEFT] == NULL && cur_ring[RIGHT] == NULL)
|
if (cur_ring[LEFT] == NULL && cur_ring[RIGHT] == NULL)
|
||||||
{
|
{
|
||||||
if ((ring = gethand(rs)) < 0)
|
if ((ring = gethand(rs)) < 0)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (cur_ring[LEFT] == NULL)
|
else if (cur_ring[LEFT] == NULL)
|
||||||
ring = LEFT;
|
ring = LEFT;
|
||||||
else if (cur_ring[RIGHT] == NULL)
|
else if (cur_ring[RIGHT] == NULL)
|
||||||
ring = RIGHT;
|
ring = RIGHT;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!terse)
|
if (!terse)
|
||||||
msg(rs,"you already have a ring on each hand");
|
msg(rs,"you already have a ring on each hand");
|
||||||
else
|
else
|
||||||
msg(rs,"wearing two");
|
msg(rs,"wearing two");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cur_ring[ring] = obj;
|
cur_ring[ring] = obj;
|
||||||
|
|
||||||
@@ -69,19 +69,19 @@ ring_on(struct rogue_state *rs)
|
|||||||
*/
|
*/
|
||||||
switch (obj->o_which)
|
switch (obj->o_which)
|
||||||
{
|
{
|
||||||
case R_ADDSTR:
|
case R_ADDSTR:
|
||||||
chg_str(obj->o_arm);
|
chg_str(obj->o_arm);
|
||||||
break;
|
break;
|
||||||
case R_SEEINVIS:
|
case R_SEEINVIS:
|
||||||
invis_on();
|
invis_on();
|
||||||
break;
|
break;
|
||||||
case R_AGGR:
|
case R_AGGR:
|
||||||
aggravate(rs);
|
aggravate(rs);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!terse)
|
if (!terse)
|
||||||
addmsg(rs,"you are now wearing ");
|
addmsg(rs,"you are now wearing ");
|
||||||
msg(rs,"%s (%c)", inv_name(obj, TRUE), obj->o_packch);
|
msg(rs,"%s (%c)", inv_name(obj, TRUE), obj->o_packch);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,28 +98,28 @@ ring_off(struct rogue_state *rs)
|
|||||||
|
|
||||||
if (cur_ring[LEFT] == NULL && cur_ring[RIGHT] == NULL)
|
if (cur_ring[LEFT] == NULL && cur_ring[RIGHT] == NULL)
|
||||||
{
|
{
|
||||||
if (terse)
|
if (terse)
|
||||||
msg(rs,"no rings");
|
msg(rs,"no rings");
|
||||||
else
|
else
|
||||||
msg(rs,"you aren't wearing any rings");
|
msg(rs,"you aren't wearing any rings");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (cur_ring[LEFT] == NULL)
|
else if (cur_ring[LEFT] == NULL)
|
||||||
ring = RIGHT;
|
ring = RIGHT;
|
||||||
else if (cur_ring[RIGHT] == NULL)
|
else if (cur_ring[RIGHT] == NULL)
|
||||||
ring = LEFT;
|
ring = LEFT;
|
||||||
else
|
else
|
||||||
if ((ring = gethand(rs)) < 0)
|
if ((ring = gethand(rs)) < 0)
|
||||||
return;
|
return;
|
||||||
mpos = 0;
|
mpos = 0;
|
||||||
obj = cur_ring[ring];
|
obj = cur_ring[ring];
|
||||||
if (obj == NULL)
|
if (obj == NULL)
|
||||||
{
|
{
|
||||||
msg(rs,"not wearing such a ring");
|
msg(rs,"not wearing such a ring");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (dropcheck(rs,obj))
|
if (dropcheck(rs,obj))
|
||||||
msg(rs,"was wearing %s(%c)", inv_name(obj, TRUE), obj->o_packch);
|
msg(rs,"was wearing %s(%c)", inv_name(obj, TRUE), obj->o_packch);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -163,21 +163,21 @@ ring_eat(int hand)
|
|||||||
THING *ring;
|
THING *ring;
|
||||||
int eat;
|
int eat;
|
||||||
static int uses[] = {
|
static int uses[] = {
|
||||||
1, /* R_PROTECT */ 1, /* R_ADDSTR */
|
1, /* R_PROTECT */ 1, /* R_ADDSTR */
|
||||||
1, /* R_SUSTSTR */ -3, /* R_SEARCH */
|
1, /* R_SUSTSTR */ -3, /* R_SEARCH */
|
||||||
-5, /* R_SEEINVIS */ 0, /* R_NOP */
|
-5, /* R_SEEINVIS */ 0, /* R_NOP */
|
||||||
0, /* R_AGGR */ -3, /* R_ADDHIT */
|
0, /* R_AGGR */ -3, /* R_ADDHIT */
|
||||||
-3, /* R_ADDDAM */ 2, /* R_REGEN */
|
-3, /* R_ADDDAM */ 2, /* R_REGEN */
|
||||||
-2, /* R_DIGEST */ 0, /* R_TELEPORT */
|
-2, /* R_DIGEST */ 0, /* R_TELEPORT */
|
||||||
1, /* R_STEALTH */ 1 /* R_SUSTARM */
|
1, /* R_STEALTH */ 1 /* R_SUSTARM */
|
||||||
};
|
};
|
||||||
|
|
||||||
if ((ring = cur_ring[hand]) == NULL)
|
if ((ring = cur_ring[hand]) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
if ((eat = uses[ring->o_which]) < 0)
|
if ((eat = uses[ring->o_which]) < 0)
|
||||||
eat = (rnd(-eat) == 0);
|
eat = (rnd(-eat) == 0);
|
||||||
if (ring->o_which == R_DIGEST)
|
if (ring->o_which == R_DIGEST)
|
||||||
eat = -eat;
|
eat = -eat;
|
||||||
return eat;
|
return eat;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,16 +191,16 @@ ring_num(THING *obj)
|
|||||||
static char buf[10];
|
static char buf[10];
|
||||||
|
|
||||||
if (!(obj->o_flags & ISKNOW))
|
if (!(obj->o_flags & ISKNOW))
|
||||||
return "";
|
return "";
|
||||||
switch (obj->o_which)
|
switch (obj->o_which)
|
||||||
{
|
{
|
||||||
case R_PROTECT:
|
case R_PROTECT:
|
||||||
case R_ADDSTR:
|
case R_ADDSTR:
|
||||||
case R_ADDDAM:
|
case R_ADDDAM:
|
||||||
case R_ADDHIT:
|
case R_ADDHIT:
|
||||||
sprintf(buf, " [%s]", num(obj->o_arm, 0, RING));
|
sprintf(buf, " [%s]", num(obj->o_arm, 0, RING));
|
||||||
otherwise:
|
otherwise:
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -131,21 +131,21 @@ int32_t flushkeystrokes_local(struct rogue_state *rs,int32_t waitflag)
|
|||||||
rs->num = 0;
|
rs->num = 0;
|
||||||
retflag = 0;
|
retflag = 0;
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
if ( (fp= fopen("savefile","wb")) != 0 )
|
/*if ( (fp= fopen("savefile","wb")) != 0 )
|
||||||
{
|
{
|
||||||
//save_file(rs,fp,0);
|
save_file(rs,fp,0);
|
||||||
if ( 0 && (fp= fopen("savefile","rb")) != 0 )
|
if ( 0 && (fp= fopen("savefile","rb")) != 0 )
|
||||||
{
|
{
|
||||||
for (i=0; i<0x150; i++)
|
for (i=0; i<0x150; i++)
|
||||||
fprintf(stderr,"%02x",fgetc(fp));
|
fprintf(stderr,"%02x",fgetc(fp));
|
||||||
fprintf(stderr," first part rnd.%d\n",rnd(1000));
|
fprintf(stderr," first part rnd.%d\n",rnd(1000));
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}*/
|
||||||
roguefname(fname,rs->seed,rs->counter);
|
roguefname(fname,rs->seed,rs->counter+1);
|
||||||
if ( (fp= fopen(fname,"wb")) != 0 ) // truncate next file
|
if ( (fp= fopen(fname,"wb")) != 0 ) // truncate next file
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
//fprintf(stderr,"savefile <- %s retflag.%d\n",fname,retflag);
|
//fprintf(stderr,"savefile <- %s retflag.%d\n",fname,retflag);
|
||||||
}
|
//}
|
||||||
} else fprintf(stderr,"error writing (%s)\n",fname);
|
} else fprintf(stderr,"error writing (%s)\n",fname);
|
||||||
} else fprintf(stderr,"error creating (%s)\n",fname);
|
} else fprintf(stderr,"error creating (%s)\n",fname);
|
||||||
return(retflag);
|
return(retflag);
|
||||||
@@ -254,11 +254,10 @@ long get_filesize(FILE *fp)
|
|||||||
return(fsize);
|
return(fsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t rogue_replay(uint64_t seed,int32_t sleeptime)
|
char *rogue_keystrokesload(int32_t *numkeysp,uint64_t seed,int32_t counter)
|
||||||
{
|
{
|
||||||
FILE *fp; char fname[1024]; char *keystrokes = 0; long num=0,fsize; int32_t i,counter = 0; struct rogue_state *rs; struct rogue_player P,*player = 0;
|
char fname[1024],*keystrokes = 0; FILE *fp; long fsize; int32_t num = 0;
|
||||||
if ( seed == 0 )
|
*numkeysp = 0;
|
||||||
seed = 777;
|
|
||||||
while ( 1 )
|
while ( 1 )
|
||||||
{
|
{
|
||||||
roguefname(fname,seed,counter);
|
roguefname(fname,seed,counter);
|
||||||
@@ -275,19 +274,30 @@ int32_t rogue_replay(uint64_t seed,int32_t sleeptime)
|
|||||||
{
|
{
|
||||||
fprintf(stderr,"error reallocating keystrokes\n");
|
fprintf(stderr,"error reallocating keystrokes\n");
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return(-1);
|
return(0);
|
||||||
}
|
}
|
||||||
if ( fread(&keystrokes[num],1,fsize,fp) != fsize )
|
if ( fread(&keystrokes[num],1,fsize,fp) != fsize )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"error reading keystrokes from (%s)\n",fname);
|
fprintf(stderr,"error reading keystrokes from (%s)\n",fname);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return(-1);
|
free(keystrokes);
|
||||||
|
return(0);
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
num += fsize;
|
num += fsize;
|
||||||
counter++;
|
counter++;
|
||||||
fprintf(stderr,"loaded %ld from (%s) total %ld\n",fsize,fname,num);
|
fprintf(stderr,"loaded %ld from (%s) total %d\n",fsize,fname,num);
|
||||||
}
|
}
|
||||||
|
*numkeysp = num;
|
||||||
|
return(keystrokes);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t rogue_replay(uint64_t seed,int32_t sleeptime)
|
||||||
|
{
|
||||||
|
FILE *fp; char fname[1024]; char *keystrokes = 0; long fsize; int32_t i,num=0,counter = 0; struct rogue_state *rs; struct rogue_player P,*player = 0;
|
||||||
|
if ( seed == 0 )
|
||||||
|
seed = 777;
|
||||||
|
keystrokes = rogue_keystrokesload(&num,seed,counter);
|
||||||
if ( num > 0 )
|
if ( num > 0 )
|
||||||
{
|
{
|
||||||
sprintf(fname,"rogue.%llu.player",(long long)seed);
|
sprintf(fname,"rogue.%llu.player",(long long)seed);
|
||||||
@@ -301,7 +311,6 @@ int32_t rogue_replay(uint64_t seed,int32_t sleeptime)
|
|||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
rogue_replay2(0,seed,keystrokes,num,player,sleeptime);
|
rogue_replay2(0,seed,keystrokes,num,player,sleeptime);
|
||||||
|
|
||||||
mvaddstr(LINES - 2, 0, (char *)"replay completed");
|
mvaddstr(LINES - 2, 0, (char *)"replay completed");
|
||||||
endwin();
|
endwin();
|
||||||
my_exit(0);
|
my_exit(0);
|
||||||
|
|||||||
@@ -978,16 +978,18 @@ char *rogue_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vecto
|
|||||||
}
|
}
|
||||||
if ( endP.gold <= 0 || endP.hitpoints <= 0 || (endP.strength&0xffff) <= 0 || endP.level <= 0 || endP.experience <= 0 || endP.dungeonlevel <= 0 )
|
if ( endP.gold <= 0 || endP.hitpoints <= 0 || (endP.strength&0xffff) <= 0 || endP.level <= 0 || endP.experience <= 0 || endP.dungeonlevel <= 0 )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"zero value character was killed -> no playerdata\n");
|
sprintf(str,"zero value character was killed -> no playerdata\n");
|
||||||
newdata.resize(0);
|
newdata.resize(0);
|
||||||
//P.gold = (P.gold * 8) / 10;
|
*numkeysp = numkeys;
|
||||||
|
return(keystrokes);
|
||||||
|
/* P.gold = (P.gold * 8) / 10;
|
||||||
if ( keystrokes != 0 )
|
if ( keystrokes != 0 )
|
||||||
{
|
{
|
||||||
free(keystrokes);
|
free(keystrokes);
|
||||||
keystrokes = 0;
|
keystrokes = 0;
|
||||||
*numkeysp = 0;
|
*numkeysp = 0;
|
||||||
return(keystrokes);
|
return(keystrokes);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1084,8 +1086,8 @@ int32_t rogue_playerdata_validate(int64_t *cashoutp,uint256 &playertxid,struct C
|
|||||||
if ( P.amulet != 0 )
|
if ( P.amulet != 0 )
|
||||||
mult *= 5;
|
mult *= 5;
|
||||||
dungeonlevel = P.dungeonlevel;
|
dungeonlevel = P.dungeonlevel;
|
||||||
if ( P.amulet != 0 && dungeonlevel < 21 )
|
if ( P.amulet != 0 && dungeonlevel < 26 )
|
||||||
dungeonlevel = 21;
|
dungeonlevel = 26;
|
||||||
*cashoutp = (uint64_t)P.gold * P.gold * mult * dungeonlevel;
|
*cashoutp = (uint64_t)P.gold * P.gold * mult * dungeonlevel;
|
||||||
if ( newdata == playerdata )
|
if ( newdata == playerdata )
|
||||||
{
|
{
|
||||||
@@ -1315,7 +1317,7 @@ UniValue rogue_gameinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
|
|||||||
rogue_gameplayerinfo(cp,obj,txid,tx,i+1,maxplayers,myrogueaddr);
|
rogue_gameplayerinfo(cp,obj,txid,tx,i+1,maxplayers,myrogueaddr);
|
||||||
a.push_back(obj);
|
a.push_back(obj);
|
||||||
}
|
}
|
||||||
else
|
else if ( 0 )
|
||||||
{
|
{
|
||||||
sprintf(str,"vout %d+1 is unspent",i);
|
sprintf(str,"vout %d+1 is unspent",i);
|
||||||
result.push_back(Pair("unspent",str));
|
result.push_back(Pair("unspent",str));
|
||||||
@@ -1466,7 +1468,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C
|
|||||||
funcid = script[1];
|
funcid = script[1];
|
||||||
if ( (e= script[0]) == EVAL_TOKENS )
|
if ( (e= script[0]) == EVAL_TOKENS )
|
||||||
{
|
{
|
||||||
tokentx = 1;
|
tokentx = funcid;
|
||||||
if ( (funcid= rogue_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,pname,scriptPubKey)) == 0 )
|
if ( (funcid= rogue_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,pname,scriptPubKey)) == 0 )
|
||||||
{
|
{
|
||||||
if ( (funcid= rogue_registeropretdecode(gametxid,tokenid,playertxid,scriptPubKey)) == 0 )
|
if ( (funcid= rogue_registeropretdecode(gametxid,tokenid,playertxid,scriptPubKey)) == 0 )
|
||||||
@@ -1539,22 +1541,29 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C
|
|||||||
// verify pk belongs to this tx
|
// verify pk belongs to this tx
|
||||||
if ( playerdata.size() > 0 )
|
if ( playerdata.size() > 0 )
|
||||||
{
|
{
|
||||||
|
static char laststr[512]; char cashstr[512];
|
||||||
if ( rogue_playerdata_validate(&cashout,ptxid,cp,playerdata,gametxid,pk) < 0 )
|
if ( rogue_playerdata_validate(&cashout,ptxid,cp,playerdata,gametxid,pk) < 0 )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"ht.%d gametxid.%s player.%s invalid playerdata[%d]\n",height,gametxid.GetHex().c_str(),ptxid.GetHex().c_str(),(int32_t)playerdata.size());
|
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 ( funcid == 'H' )
|
|
||||||
cashout *= 2;
|
|
||||||
if ( tx.vout.size() > 3 ) // orig of 't' has 0 cashout
|
|
||||||
{
|
|
||||||
static char laststr[512]; char cashstr[512];
|
|
||||||
sprintf(cashstr,"ht.%d txid.%s %d,%d %.8f vs vout2 %.8f",height,txid.GetHex().c_str(),tokentx,decoded,(double)cashout/COIN,(double)tx.vout[2].nValue/COIN);
|
|
||||||
if ( strcmp(laststr,cashstr) != 0 )
|
if ( strcmp(laststr,cashstr) != 0 )
|
||||||
{
|
{
|
||||||
strcpy(laststr,cashstr);
|
strcpy(laststr,cashstr);
|
||||||
fprintf(stderr,"%s\n",cashstr);
|
fprintf(stderr,"%s\n",cashstr);
|
||||||
}
|
}
|
||||||
if ( enabled != 0 && tx.vout[2].nValue != cashout )
|
if ( enabled != 0 )
|
||||||
|
return eval->Invalid("mismatched playerdata");
|
||||||
|
}
|
||||||
|
if ( funcid == 'H' )
|
||||||
|
cashout *= 2;
|
||||||
|
//if ( tokentx == 0 )
|
||||||
|
{
|
||||||
|
sprintf(cashstr,"tokentx.(%c) decoded.%d ht.%d txid.%s %d,%d %.8f vs vout2 %.8f",tokentx,decoded,height,txid.GetHex().c_str(),tokentx,decoded,(double)cashout/COIN,(double)tx.vout[2].nValue/COIN);
|
||||||
|
if ( strcmp(laststr,cashstr) != 0 )
|
||||||
|
{
|
||||||
|
strcpy(laststr,cashstr);
|
||||||
|
fprintf(stderr,"%s\n",cashstr);
|
||||||
|
}
|
||||||
|
if ( tokentx == 0 && enabled != 0 && tx.vout[2].nValue != cashout )
|
||||||
return eval->Invalid("mismatched cashout amount");
|
return eval->Invalid("mismatched cashout amount");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2126,7 +2126,7 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
bnTarget = komodo_PoWtarget(&PoSperc,bnTarget,height,ASSETCHAINS_STAKED);
|
bnTarget = komodo_PoWtarget(&PoSperc,bnTarget,height,ASSETCHAINS_STAKED);
|
||||||
if ( bhash > bnTarget )
|
if ( bhash > bnTarget && height > 100 )
|
||||||
{
|
{
|
||||||
for (i=31; i>=16; i--)
|
for (i=31; i>=16; i--)
|
||||||
fprintf(stderr,"%02x",((uint8_t *)&bhash)[i]);
|
fprintf(stderr,"%02x",((uint8_t *)&bhash)[i]);
|
||||||
@@ -2135,7 +2135,8 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height)
|
|||||||
fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]);
|
fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]);
|
||||||
fprintf(stderr," ht.%d PoW diff violation PoSperc.%d vs goalperc.%d\n",height,PoSperc,(int32_t)ASSETCHAINS_STAKED);
|
fprintf(stderr," ht.%d PoW diff violation PoSperc.%d vs goalperc.%d\n",height,PoSperc,(int32_t)ASSETCHAINS_STAKED);
|
||||||
return(-1);
|
return(-1);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
failed = 0;
|
failed = 0;
|
||||||
CBlockIndex *pindex;
|
CBlockIndex *pindex;
|
||||||
|
|||||||
@@ -34,6 +34,10 @@
|
|||||||
#define GETBIT(bits,bitoffset) (((uint8_t *)bits)[(bitoffset) >> 3] & (1 << ((bitoffset) & 7)))
|
#define GETBIT(bits,bitoffset) (((uint8_t *)bits)[(bitoffset) >> 3] & (1 << ((bitoffset) & 7)))
|
||||||
#define CLEARBIT(bits,bitoffset) (((uint8_t *)bits)[(bitoffset) >> 3] &= ~(1 << ((bitoffset) & 7)))
|
#define CLEARBIT(bits,bitoffset) (((uint8_t *)bits)[(bitoffset) >> 3] &= ~(1 << ((bitoffset) & 7)))
|
||||||
|
|
||||||
|
#define KOMODO_MAXNVALUE (((uint64_t)1 << 63) - 1)
|
||||||
|
#define KOMODO_BIT63SET(x) ((x) & ((uint64_t)1 << 63))
|
||||||
|
#define KOMODO_VALUETOOBIG(x) ((x) > (uint64_t)10000000000*COIN)
|
||||||
|
|
||||||
extern uint8_t ASSETCHAINS_TXPOW,ASSETCHAINS_PUBLIC;
|
extern uint8_t ASSETCHAINS_TXPOW,ASSETCHAINS_PUBLIC;
|
||||||
int32_t MAX_BLOCK_SIZE(int32_t height);
|
int32_t MAX_BLOCK_SIZE(int32_t height);
|
||||||
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
|
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
|
||||||
|
|||||||
@@ -134,15 +134,15 @@ uint64_t komodo_current_supply(uint32_t nHeight)
|
|||||||
uint64_t cur_money;
|
uint64_t cur_money;
|
||||||
int32_t baseid;
|
int32_t baseid;
|
||||||
|
|
||||||
if ( (baseid = komodo_baseid(ASSETCHAINS_SYMBOL)) >= 0 && baseid < 32 )
|
//if ( (baseid = komodo_baseid(ASSETCHAINS_SYMBOL)) >= 0 && baseid < 32 )
|
||||||
cur_money = ASSETCHAINS_GENESISTXVAL + ASSETCHAINS_SUPPLY + nHeight * ASSETCHAINS_REWARD[0] / SATOSHIDEN;
|
// cur_money = ASSETCHAINS_GENESISTXVAL + ASSETCHAINS_SUPPLY + nHeight * ASSETCHAINS_REWARD[0] / SATOSHIDEN;
|
||||||
else
|
//else
|
||||||
{
|
{
|
||||||
// figure out max_money by adding up supply to a maximum of 10,000,000 blocks
|
// figure out max_money by adding up supply to a maximum of 10,000,000 blocks
|
||||||
cur_money = (ASSETCHAINS_SUPPLY+1) * SATOSHIDEN + (ASSETCHAINS_MAGIC & 0xffffff) + ASSETCHAINS_GENESISTXVAL;
|
cur_money = (ASSETCHAINS_SUPPLY+1) * SATOSHIDEN + (ASSETCHAINS_MAGIC & 0xffffff) + ASSETCHAINS_GENESISTXVAL;
|
||||||
if ( ASSETCHAINS_LASTERA == 0 && ASSETCHAINS_REWARD[0] == 0 )
|
if ( ASSETCHAINS_LASTERA == 0 && ASSETCHAINS_REWARD[0] == 0 )
|
||||||
{
|
{
|
||||||
cur_money += (nHeight * 10000) / SATOSHIDEN;
|
cur_money += (nHeight * 10000);// / SATOSHIDEN;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -155,6 +155,8 @@ uint64_t komodo_current_supply(uint32_t nHeight)
|
|||||||
|
|
||||||
// add rewards from this era, up to nHeight
|
// add rewards from this era, up to nHeight
|
||||||
int64_t reward = ASSETCHAINS_REWARD[j];
|
int64_t reward = ASSETCHAINS_REWARD[j];
|
||||||
|
|
||||||
|
//fprintf(stderr,"last.%d reward %llu period %llu\n",(int32_t)ASSETCHAINS_LASTERA,(long long)reward,(long long)ASSETCHAINS_HALVING[j]);
|
||||||
if ( reward > 0 )
|
if ( reward > 0 )
|
||||||
{
|
{
|
||||||
uint64_t lastEnd = j == 0 ? 0 : ASSETCHAINS_ENDSUBSIDY[j - 1];
|
uint64_t lastEnd = j == 0 ? 0 : ASSETCHAINS_ENDSUBSIDY[j - 1];
|
||||||
@@ -166,10 +168,12 @@ uint64_t komodo_current_supply(uint32_t nHeight)
|
|||||||
uint32_t modulo = (curEnd - lastEnd) % period;
|
uint32_t modulo = (curEnd - lastEnd) % period;
|
||||||
uint64_t decay = ASSETCHAINS_DECAY[j];
|
uint64_t decay = ASSETCHAINS_DECAY[j];
|
||||||
|
|
||||||
if (!period)
|
//fprintf(stderr,"period.%llu cur_money %.8f += %.8f * %d\n",(long long)period,(double)cur_money/COIN,(double)reward/COIN,nHeight);
|
||||||
|
if ( ASSETCHAINS_HALVING[j] == 0 )
|
||||||
{
|
{
|
||||||
// no halving, straight multiply
|
// no halving, straight multiply
|
||||||
cur_money += reward * (nHeight - 1);
|
cur_money += reward * (nHeight - 1);
|
||||||
|
//fprintf(stderr,"cur_money %.8f\n",(double)cur_money/COIN);
|
||||||
}
|
}
|
||||||
// if exactly SATOSHIDEN, linear decay to zero or to next era, same as:
|
// if exactly SATOSHIDEN, linear decay to zero or to next era, same as:
|
||||||
// (next_era_reward + (starting reward - next_era_reward) / 2) * num_blocks
|
// (next_era_reward + (starting reward - next_era_reward) / 2) * num_blocks
|
||||||
@@ -264,19 +268,17 @@ uint64_t komodo_current_supply(uint32_t nHeight)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#define KOMODO_MAXNVALUE (((uint64_t)1 << 63) - 1)
|
|
||||||
#define KOMODO_BIT63SET(x) ((x) & ((uint64_t)1 << 63))
|
|
||||||
|
|
||||||
if ( KOMODO_BIT63SET(cur_money) != 0 )
|
if ( KOMODO_BIT63SET(cur_money) != 0 )
|
||||||
return(KOMODO_MAXNVALUE);
|
return(KOMODO_MAXNVALUE);
|
||||||
if ( ASSETCHAINS_COMMISSION != 0 )
|
if ( ASSETCHAINS_COMMISSION != 0 )
|
||||||
{
|
{
|
||||||
uint64_t newval = (cur_money + (cur_money * ASSETCHAINS_COMMISSION));
|
uint64_t newval = (cur_money + (cur_money/COIN * ASSETCHAINS_COMMISSION));
|
||||||
if ( KOMODO_BIT63SET(newval) != 0 )
|
if ( KOMODO_BIT63SET(newval) != 0 )
|
||||||
return(KOMODO_MAXNVALUE);
|
return(KOMODO_MAXNVALUE);
|
||||||
else if ( newval < cur_money ) // check for underflow
|
else if ( newval < cur_money ) // check for underflow
|
||||||
return(KOMODO_MAXNVALUE);
|
return(KOMODO_MAXNVALUE);
|
||||||
return(newval);
|
return(newval);
|
||||||
}
|
}
|
||||||
|
//fprintf(stderr,"cur_money %.8f\n",(double)cur_money/COIN);
|
||||||
return(cur_money);
|
return(cur_money);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1639,9 +1639,18 @@ uint64_t komodo_ac_block_subsidy(int nHeight)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( nHeight == 1 )
|
uint32_t magicExtra = ASSETCHAINS_STAKED ? ASSETCHAINS_MAGIC : (ASSETCHAINS_MAGIC & 0xffffff);
|
||||||
|
if ( ASSETCHAINS_SUPPLY > 10000000000 ) // over 10 billion?
|
||||||
|
{
|
||||||
|
if ( nHeight <= ASSETCHAINS_SUPPLY/1000000000 )
|
||||||
|
{
|
||||||
|
subsidy += (uint64_t)1000000000 * COIN;
|
||||||
|
if ( nHeight == 1 )
|
||||||
|
subsidy += (ASSETCHAINS_SUPPLY % 1000000000)*COIN + magicExtra;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( nHeight == 1 )
|
||||||
{
|
{
|
||||||
uint32_t magicExtra = ASSETCHAINS_STAKED ? ASSETCHAINS_MAGIC : (ASSETCHAINS_MAGIC & 0xffffff);
|
|
||||||
if ( ASSETCHAINS_LASTERA == 0 )
|
if ( ASSETCHAINS_LASTERA == 0 )
|
||||||
subsidy = ASSETCHAINS_SUPPLY * SATOSHIDEN + magicExtra;
|
subsidy = ASSETCHAINS_SUPPLY * SATOSHIDEN + magicExtra;
|
||||||
else
|
else
|
||||||
@@ -1792,6 +1801,8 @@ void komodo_args(char *argv0)
|
|||||||
fprintf(stderr,"-ac_supply must be less than 90 billion\n");
|
fprintf(stderr,"-ac_supply must be less than 90 billion\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
fprintf(stderr,"ASSETCHAINS_SUPPLY %llu\n",(long long)ASSETCHAINS_SUPPLY);
|
||||||
|
|
||||||
ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0);
|
ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0);
|
||||||
ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey","");
|
ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey","");
|
||||||
ASSETCHAINS_SCRIPTPUB = GetArg("-ac_script","");
|
ASSETCHAINS_SCRIPTPUB = GetArg("-ac_script","");
|
||||||
@@ -1885,6 +1896,11 @@ void komodo_args(char *argv0)
|
|||||||
}
|
}
|
||||||
if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) == 66 || ASSETCHAINS_SCRIPTPUB.size() > 1 )
|
if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) == 66 || ASSETCHAINS_SCRIPTPUB.size() > 1 )
|
||||||
{
|
{
|
||||||
|
if ( ASSETCHAINS_SUPPLY > 10000000000 )
|
||||||
|
{
|
||||||
|
printf("ac_pubkey or ac_script wont work with ac_supply over 10 billion\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
if ( ASSETCHAINS_NOTARY_PAY[0] != 0 )
|
if ( ASSETCHAINS_NOTARY_PAY[0] != 0 )
|
||||||
{
|
{
|
||||||
printf("Assetchains NOTARY PAY cannot be used with ac_pubkey or ac_script.\n");
|
printf("Assetchains NOTARY PAY cannot be used with ac_pubkey or ac_script.\n");
|
||||||
@@ -2049,9 +2065,9 @@ void komodo_args(char *argv0)
|
|||||||
|
|
||||||
if ( ASSETCHAINS_CC >= KOMODO_FIRSTFUNGIBLEID && MAX_MONEY < 1000000LL*SATOSHIDEN )
|
if ( ASSETCHAINS_CC >= KOMODO_FIRSTFUNGIBLEID && MAX_MONEY < 1000000LL*SATOSHIDEN )
|
||||||
MAX_MONEY = 1000000LL*SATOSHIDEN;
|
MAX_MONEY = 1000000LL*SATOSHIDEN;
|
||||||
if ( MAX_MONEY <= 0 || MAX_MONEY > 10000100000LL*SATOSHIDEN )
|
if ( KOMODO_BIT63SET(MAX_MONEY) != 0 )
|
||||||
MAX_MONEY = 10000100000LL*SATOSHIDEN;
|
MAX_MONEY = KOMODO_MAXNVALUE;
|
||||||
//fprintf(stderr,"MAX_MONEY %llu %.8f\n",(long long)MAX_MONEY,(double)MAX_MONEY/SATOSHIDEN);
|
fprintf(stderr,"MAX_MONEY %llu %.8f\n",(long long)MAX_MONEY,(double)MAX_MONEY/SATOSHIDEN);
|
||||||
//printf("baseid.%d MAX_MONEY.%s %.8f\n",baseid,ASSETCHAINS_SYMBOL,(double)MAX_MONEY/SATOSHIDEN);
|
//printf("baseid.%d MAX_MONEY.%s %.8f\n",baseid,ASSETCHAINS_SYMBOL,(double)MAX_MONEY/SATOSHIDEN);
|
||||||
uint16_t tmpport = komodo_port(ASSETCHAINS_SYMBOL,ASSETCHAINS_SUPPLY,&ASSETCHAINS_MAGIC,extraptr,extralen);
|
uint16_t tmpport = komodo_port(ASSETCHAINS_SYMBOL,ASSETCHAINS_SUPPLY,&ASSETCHAINS_MAGIC,extraptr,extralen);
|
||||||
if ( GetArg("-port",0) != 0 )
|
if ( GetArg("-port",0) != 0 )
|
||||||
|
|||||||
22
src/main.cpp
22
src/main.cpp
@@ -1808,7 +1808,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
|
|||||||
CAmount nValueOut = tx.GetValueOut();
|
CAmount nValueOut = tx.GetValueOut();
|
||||||
CAmount nFees = nValueIn-nValueOut;
|
CAmount nFees = nValueIn-nValueOut;
|
||||||
double dPriority = view.GetPriority(tx, chainActive.Height());
|
double dPriority = view.GetPriority(tx, chainActive.Height());
|
||||||
if ( KOMODO_BIT63SET(nValueOut) != 0 )
|
if ( nValueOut > 777777*COIN && KOMODO_VALUETOOBIG(nValueOut - 777777*COIN) != 0 ) // some room for blockreward and txfees
|
||||||
return state.DoS(100, error("AcceptToMemoryPool: GetValueOut too big"),REJECT_INVALID,"tx valueout is too big");
|
return state.DoS(100, error("AcceptToMemoryPool: GetValueOut too big"),REJECT_INVALID,"tx valueout is too big");
|
||||||
|
|
||||||
// Keep track of transactions that spend a coinbase, which we re-scan
|
// Keep track of transactions that spend a coinbase, which we re-scan
|
||||||
@@ -2845,7 +2845,7 @@ namespace {
|
|||||||
hasher << hashBlock;
|
hasher << hashBlock;
|
||||||
hasher << blockundo;
|
hasher << blockundo;
|
||||||
fileout << hasher.GetHash();
|
fileout << hasher.GetHash();
|
||||||
|
//fprintf(stderr,"hashBlock.%s hasher.%s\n",hashBlock.GetHex().c_str(),hasher.GetHash().GetHex().c_str());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2870,7 +2870,7 @@ namespace {
|
|||||||
hasher << hashBlock;
|
hasher << hashBlock;
|
||||||
hasher << blockundo;
|
hasher << blockundo;
|
||||||
if (hashChecksum != hasher.GetHash())
|
if (hashChecksum != hasher.GetHash())
|
||||||
return error("%s: Checksum mismatch", __func__);
|
return error("%s: %s Checksum mismatch %s vs %s", __func__,hashBlock.GetHex().c_str(),hashChecksum.GetHex().c_str(),hasher.GetHash().GetHex().c_str());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -3494,12 +3494,18 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
|||||||
txdata.emplace_back(tx);
|
txdata.emplace_back(tx);
|
||||||
|
|
||||||
valueout = tx.GetValueOut();
|
valueout = tx.GetValueOut();
|
||||||
if ( KOMODO_BIT63SET(valueout) != 0 )
|
if ( KOMODO_VALUETOOBIG(valueout) != 0 )
|
||||||
|
{
|
||||||
|
fprintf(stderr,"valueout %.8f too big\n",(double)valueout/COIN);
|
||||||
return state.DoS(100, error("ConnectBlock(): GetValueOut too big"),REJECT_INVALID,"tx valueout is too big");
|
return state.DoS(100, error("ConnectBlock(): GetValueOut too big"),REJECT_INVALID,"tx valueout is too big");
|
||||||
|
}
|
||||||
prevsum = voutsum;
|
prevsum = voutsum;
|
||||||
voutsum += valueout;
|
voutsum += valueout;
|
||||||
if ( KOMODO_BIT63SET(voutsum) != 0 )
|
if ( KOMODO_VALUETOOBIG(voutsum) != 0 )
|
||||||
|
{
|
||||||
|
fprintf(stderr,"voutsum %.8f too big\n",(double)voutsum/COIN);
|
||||||
return state.DoS(100, error("ConnectBlock(): voutsum too big"),REJECT_INVALID,"tx valueout is too big");
|
return state.DoS(100, error("ConnectBlock(): voutsum too big"),REJECT_INVALID,"tx valueout is too big");
|
||||||
|
}
|
||||||
else if ( voutsum < prevsum )
|
else if ( voutsum < prevsum )
|
||||||
return state.DoS(100, error("ConnectBlock(): voutsum less after adding valueout"),REJECT_INVALID,"tx valueout is too big");
|
return state.DoS(100, error("ConnectBlock(): voutsum less after adding valueout"),REJECT_INVALID,"tx valueout is too big");
|
||||||
if (!tx.IsCoinBase())
|
if (!tx.IsCoinBase())
|
||||||
@@ -3634,9 +3640,11 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Write undo information to disk
|
// Write undo information to disk
|
||||||
|
//fprintf(stderr,"nFile.%d isNull %d vs isvalid %d nStatus %x\n",(int32_t)pindex->nFile,pindex->GetUndoPos().IsNull(),pindex->IsValid(BLOCK_VALID_SCRIPTS),(uint32_t)pindex->nStatus);
|
||||||
if (pindex->GetUndoPos().IsNull() || !pindex->IsValid(BLOCK_VALID_SCRIPTS))
|
if (pindex->GetUndoPos().IsNull() || !pindex->IsValid(BLOCK_VALID_SCRIPTS))
|
||||||
{
|
{
|
||||||
if (pindex->GetUndoPos().IsNull()) {
|
if (pindex->GetUndoPos().IsNull())
|
||||||
|
{
|
||||||
CDiskBlockPos pos;
|
CDiskBlockPos pos;
|
||||||
if (!FindUndoPos(state, pindex->nFile, pos, ::GetSerializeSize(blockundo, SER_DISK, CLIENT_VERSION) + 40))
|
if (!FindUndoPos(state, pindex->nFile, pos, ::GetSerializeSize(blockundo, SER_DISK, CLIENT_VERSION) + 40))
|
||||||
return error("ConnectBlock(): FindUndoPos failed");
|
return error("ConnectBlock(): FindUndoPos failed");
|
||||||
@@ -3644,7 +3652,6 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
|||||||
fprintf(stderr,"ConnectBlock: unexpected null pprev\n");
|
fprintf(stderr,"ConnectBlock: unexpected null pprev\n");
|
||||||
if (!UndoWriteToDisk(blockundo, pos, pindex->pprev->GetBlockHash(), chainparams.MessageStart()))
|
if (!UndoWriteToDisk(blockundo, pos, pindex->pprev->GetBlockHash(), chainparams.MessageStart()))
|
||||||
return AbortNode(state, "Failed to write undo data");
|
return AbortNode(state, "Failed to write undo data");
|
||||||
|
|
||||||
// update nUndoPos in block index
|
// update nUndoPos in block index
|
||||||
pindex->nUndoPos = pos.nPos;
|
pindex->nUndoPos = pos.nPos;
|
||||||
pindex->nStatus |= BLOCK_HAVE_UNDO;
|
pindex->nStatus |= BLOCK_HAVE_UNDO;
|
||||||
@@ -4269,6 +4276,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo
|
|||||||
ASSETCHAINS_SYMBOL,pindexFork->phashBlock->GetHex(), pindexFork->GetHeight()) + "\n\n" +
|
ASSETCHAINS_SYMBOL,pindexFork->phashBlock->GetHex(), pindexFork->GetHeight()) + "\n\n" +
|
||||||
_("Please help, human!");
|
_("Please help, human!");
|
||||||
LogPrintf("*** %s\nif you launch with -maxreorg=%d it might be able to resolve this automatically", msg,reorgLength+10);
|
LogPrintf("*** %s\nif you launch with -maxreorg=%d it might be able to resolve this automatically", msg,reorgLength+10);
|
||||||
|
fprintf(stderr,"*** %s\nif you launch with -maxreorg=%d it might be able to resolve this automatically", msg.c_str(),reorgLength+10);
|
||||||
uiInterface.ThreadSafeMessageBox(msg, "", CClientUIInterface::MSG_ERROR);
|
uiInterface.ThreadSafeMessageBox(msg, "", CClientUIInterface::MSG_ERROR);
|
||||||
StartShutdown();
|
StartShutdown();
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
}
|
}
|
||||||
} else pk = _pk;
|
} else pk = _pk;
|
||||||
|
|
||||||
uint64_t deposits; int32_t isrealtime,kmdheight; uint32_t blocktime; const CChainParams& chainparams = Params();
|
uint64_t deposits,voutsum=0; int32_t isrealtime,kmdheight; uint32_t blocktime; const CChainParams& chainparams = Params();
|
||||||
bool fNotarisationBlock = false; std::vector<int8_t> NotarisationNotaries;
|
bool fNotarisationBlock = false; std::vector<int8_t> NotarisationNotaries;
|
||||||
|
|
||||||
//fprintf(stderr,"create new block\n");
|
//fprintf(stderr,"create new block\n");
|
||||||
@@ -233,6 +233,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
|
|
||||||
const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast();
|
const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast();
|
||||||
uint32_t proposedTime = GetAdjustedTime();
|
uint32_t proposedTime = GetAdjustedTime();
|
||||||
|
voutsum = GetBlockSubsidy(nHeight,consensusParams) + 10000*COIN; // approx fees
|
||||||
|
|
||||||
if (proposedTime == nMedianTimePast)
|
if (proposedTime == nMedianTimePast)
|
||||||
{
|
{
|
||||||
@@ -270,7 +271,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
vecPriority.reserve(mempool.mapTx.size() + 1);
|
vecPriority.reserve(mempool.mapTx.size() + 1);
|
||||||
|
|
||||||
// now add transactions from the mem pool
|
// now add transactions from the mem pool
|
||||||
int32_t Notarisations = 0;
|
int32_t Notarisations = 0; uint64_t txvalue;
|
||||||
for (CTxMemPool::indexed_transaction_set::iterator mi = mempool.mapTx.begin();
|
for (CTxMemPool::indexed_transaction_set::iterator mi = mempool.mapTx.begin();
|
||||||
mi != mempool.mapTx.end(); ++mi)
|
mi != mempool.mapTx.end(); ++mi)
|
||||||
{
|
{
|
||||||
@@ -285,7 +286,12 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
//fprintf(stderr,"coinbase.%d finaltx.%d expired.%d\n",tx.IsCoinBase(),IsFinalTx(tx, nHeight, nLockTimeCutoff),IsExpiredTx(tx, nHeight));
|
//fprintf(stderr,"coinbase.%d finaltx.%d expired.%d\n",tx.IsCoinBase(),IsFinalTx(tx, nHeight, nLockTimeCutoff),IsExpiredTx(tx, nHeight));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
txvalue = tx.GetValueOut();
|
||||||
|
if ( KOMODO_VALUETOOBIG(txvalue) != 0 )
|
||||||
|
continue;
|
||||||
|
if ( KOMODO_VALUETOOBIG(txvalue + voutsum) != 0 )
|
||||||
|
continue;
|
||||||
|
voutsum += txvalue;
|
||||||
if ( ASSETCHAINS_SYMBOL[0] == 0 && komodo_validate_interest(tx,nHeight,(uint32_t)pblock->nTime,0) < 0 )
|
if ( ASSETCHAINS_SYMBOL[0] == 0 && komodo_validate_interest(tx,nHeight,(uint32_t)pblock->nTime,0) < 0 )
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"CreateNewBlock: komodo_validate_interest failure nHeight.%d nTime.%u vs locktime.%u\n",nHeight,(uint32_t)pblock->nTime,(uint32_t)tx.nLockTime);
|
//fprintf(stderr,"CreateNewBlock: komodo_validate_interest failure nHeight.%d nTime.%u vs locktime.%u\n",nHeight,(uint32_t)pblock->nTime,(uint32_t)tx.nLockTime);
|
||||||
@@ -621,7 +627,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
txNew.vout.resize(1);
|
txNew.vout.resize(1);
|
||||||
txNew.vout[0].scriptPubKey = scriptPubKeyIn;
|
txNew.vout[0].scriptPubKey = scriptPubKeyIn;
|
||||||
txNew.vout[0].nValue = GetBlockSubsidy(nHeight,consensusParams) + nFees;
|
txNew.vout[0].nValue = GetBlockSubsidy(nHeight,consensusParams) + nFees;
|
||||||
|
//fprintf(stderr,"mine ht.%d with %.8f\n",nHeight,(double)txNew.vout[0].nValue/COIN);
|
||||||
txNew.nExpiryHeight = 0;
|
txNew.nExpiryHeight = 0;
|
||||||
txNew.nLockTime = std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime());
|
txNew.nLockTime = std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime());
|
||||||
|
|
||||||
|
|||||||
@@ -419,10 +419,26 @@ bool ParseFixedPoint(const std::string &val, int decimals, int64_t *amount_out)
|
|||||||
int mantissa_tzeros = 0;
|
int mantissa_tzeros = 0;
|
||||||
bool mantissa_sign = false;
|
bool mantissa_sign = false;
|
||||||
bool exponent_sign = false;
|
bool exponent_sign = false;
|
||||||
int ptr = 0;
|
int i,n,ptr = 0; char *str = (char *)val.c_str();
|
||||||
int end = val.size();
|
int end = val.size();
|
||||||
int point_ofs = 0;
|
int point_ofs = 0;
|
||||||
|
n = val.size();
|
||||||
|
if ( n == 11 && (val[0] < '9' || val[1] < '3') )
|
||||||
|
{
|
||||||
|
uint64_t val64 = 0;
|
||||||
|
for (i=0; i<n; i++)
|
||||||
|
{
|
||||||
|
if ( val[i] < '0' || val[i] > '9' )
|
||||||
|
break;
|
||||||
|
val64 = (val64 * 10) + (val[i] - '0');
|
||||||
|
}
|
||||||
|
if ( i == n ) // 90000000000
|
||||||
|
{
|
||||||
|
*amount_out = val64 * 100000000;
|
||||||
|
//fprintf(stderr,"special case: %s -> %.8f\n",val.c_str(),(double)*amount_out/100000000);
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (ptr < end && val[ptr] == '-') {
|
if (ptr < end && val[ptr] == '-') {
|
||||||
mantissa_sign = true;
|
mantissa_sign = true;
|
||||||
++ptr;
|
++ptr;
|
||||||
|
|||||||
@@ -421,7 +421,7 @@ static void SendMoney(const CTxDestination &address, CAmount nValue, bool fSubtr
|
|||||||
// Check amount
|
// Check amount
|
||||||
if (nValue <= 0)
|
if (nValue <= 0)
|
||||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid amount");
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid amount");
|
||||||
|
//fprintf(stderr,"nValue %.8f vs curBalance %.8f\n",(double)nValue/COIN,(double)curBalance/COIN);
|
||||||
if (nValue > curBalance)
|
if (nValue > curBalance)
|
||||||
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Insufficient funds");
|
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Insufficient funds");
|
||||||
|
|
||||||
@@ -1030,7 +1030,6 @@ CAmount GetAccountBalance(const string& strAccount, int nMinDepth, const isminef
|
|||||||
return GetAccountBalance(walletdb, strAccount, nMinDepth, filter);
|
return GetAccountBalance(walletdb, strAccount, nMinDepth, filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
UniValue cleanwallettransactions(const UniValue& params, bool fHelp)
|
UniValue cleanwallettransactions(const UniValue& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
|
|||||||
Reference in New Issue
Block a user