Merge pull request #138 from jl777/jl777

sync jl777
This commit is contained in:
ca333
2019-02-19 00:15:59 +01:00
committed by GitHub
8 changed files with 93 additions and 71 deletions

View File

@@ -259,7 +259,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti
return eval->Invalid("invalid refund for cancelbuy");
preventCCvins = 3;
preventCCvouts = 0;
fprintf(stderr,"cancelbuy validated to origaddr.(%s)\n",origNormalAddr);
//fprintf(stderr,"cancelbuy validated to origaddr.(%s)\n",origNormalAddr);
break;
case 'B': // fillbuy:
@@ -305,7 +305,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti
return eval->Invalid("mismatched vout0 AssetsCCaddr for fillbuy");
}
}
fprintf(stderr,"fillbuy validated\n");
//fprintf(stderr,"fillbuy validated\n");
break;
//case 'e': // selloffer
// break; // disable swaps

View File

@@ -422,3 +422,9 @@ int32_t md_readchar(void)
return(0);
}
char *unctrl(char c)
{
static char ctrlstr[5];
sprintf(ctrlstr,"^%%%02x",c);
return(ctrlstr);
}

View File

@@ -123,9 +123,10 @@ int32_t wprintw(WINDOW *win,char *fmt,...);
int32_t mvprintw(int32_t y,int32_t x,char *fmt,...);
int32_t mvwprintw(WINDOW *win,int32_t y,int32_t x,char *fmt,...);
char *unctrl(char c);
#define A_CHARTEXT 0xff
#define baudrate() 9600
#define unctrl(a) "^x"
#define getmaxx(a) COLS
#define getmaxy(a) LINES
#define getyx(win,_argfory,_argforx) _argfory = win->y, _argforx = win->x

View File

@@ -24,7 +24,7 @@ void rogue_restoreobject(THING *o,struct rogue_packitem *item);
void restore_player(struct rogue_state *rs)
{
int32_t i; THING *obj;
int32_t i,total = 0; THING *obj;
//rs->P.gold = purse;
max_hp = rs->P.hitpoints;
pstats.s_str = rs->P.strength & 0xffff;
@@ -34,10 +34,13 @@ void restore_player(struct rogue_state *rs)
pstats.s_str = max_stats.s_str;
pstats.s_lvl = rs->P.level;
pstats.s_exp = rs->P.experience;
for (i=0; i<rs->P.packsize; i++)
for (i=0; i<rs->P.packsize&&i<MAXPACK; i++)
{
obj = new_item();
rogue_restoreobject(obj,&rs->P.roguepack[i]);
total += obj->o_count;
if ( total > pstats.s_str*3 )
break;
add_pack(rs,obj,TRUE);
}
}

View File

@@ -169,7 +169,7 @@ int32_t num_packitems(struct rogue_state *rs)
total += list->o_count;
}
}
if ( 0 )
if ( rs->guiflag != 0 )
{
char str[MAXSTR];
sprintf(str,"strength*3 %d vs total.%d vs %d inventory letters\n",pstats.s_str*3,total,n);
@@ -410,59 +410,63 @@ get_item(struct rogue_state *rs,char *purpose, int type)
{
THING *obj;
char ch;
if (pack == NULL)
msg(rs,"you aren't carrying anything");
msg(rs,"you aren't carrying anything");
else if (again)
if (last_pick)
return last_pick;
else
msg(rs,"you ran out");
else
{
for (;;)
{
if (!terse)
addmsg(rs,"which object do you want to ");
addmsg(rs,purpose);
if (terse)
addmsg(rs," what");
msg(rs,"? (* for list): ");
ch = readchar(rs);
mpos = 0;
/*
* Give the poor player a chance to abort the command
*/
if (ch == ESCAPE)
{
reset_last();
after = FALSE;
msg(rs,"");
return NULL;
}
n_objs = 1; /* normal case: person types one char */
if (ch == '*')
{
mpos = 0;
if (inventory(rs,pack, type) == 0)
{
after = FALSE;
return NULL;
}
continue;
}
for (obj = pack; obj != NULL; obj = next(obj))
if (obj->o_packch == ch)
break;
if (obj == NULL)
{
msg(rs,"'%s' is not a valid item",unctrl(ch));
continue;
}
else
return obj;
}
}
if (last_pick)
return last_pick;
else
msg(rs,"you ran out");
else
{
for (;;)
{
if (!terse)
addmsg(rs,"which object do you want to ");
addmsg(rs,purpose);
if (terse)
addmsg(rs," what");
msg(rs,"? (* for list): ");
ch = readchar(rs);
mpos = 0;
/*
* Give the poor player a chance to abort the command
*/
if (ch == ESCAPE)
{
reset_last();
after = FALSE;
msg(rs,"");
return NULL;
}
n_objs = 1; /* normal case: person types one char */
if (ch == '*')
{
mpos = 0;
if (inventory(rs,pack, type) == 0)
{
after = FALSE;
return NULL;
}
continue;
}
for (obj = pack; obj != NULL; obj = next(obj))
if (obj->o_packch == ch)
break;
if (obj == NULL)
{
//msg(rs,"'%s' is not a valid item",unctrl(ch));
//continue;
reset_last();
after = FALSE;
msg(rs,"'%s' is not a valid item",unctrl(ch));
return NULL;
}
else
return obj;
}
}
return NULL;
}

View File

@@ -238,7 +238,7 @@ void rogue_bailout(struct rogue_state *rs)
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;
struct rogue_state *rs; FILE *fp; int32_t i,n;
rs = (struct rogue_state *)calloc(1,sizeof(*rs));
rs->seed = seed;
rs->keystrokes = keystrokes;
@@ -249,6 +249,8 @@ int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t nu
rs->P = *player;
rs->restoring = 1;
//fprintf(stderr,"restore player packsize.%d HP.%d\n",rs->P.packsize,rs->P.hitpoints);
if ( rs->P.packsize > MAXPACK )
rs->P.packsize = MAXPACK;
}
globalR = *rs;
uint32_t starttime = (uint32_t)time(NULL);
@@ -278,8 +280,9 @@ int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t nu
if ( newdata != 0 && rs->playersize > 0 )
memcpy(newdata,rs->playerdata,rs->playersize);
}
n = rs->playersize;
free(rs);
return(rs->playersize);
return(n);
}
#endif
@@ -647,7 +650,7 @@ int32_t _quit()
}
else
{
fprintf(stderr,"'Q' answer (%c)\n",c);
//fprintf(stderr,"'Q' answer (%c)\n",c);
move(0, 0);
clrtoeol();
status(rs);

View File

@@ -1127,10 +1127,10 @@ uint64_t komodo_accrued_interest(int32_t *txheightp,uint32_t *locktimep,uint256
int32_t komodo_nextheight()
{
CBlockIndex *pindex; int32_t ht,longest = komodo_longestchain();
if ( (pindex= chainActive.LastTip()) != 0 && (ht= pindex->GetHeight()) >= longest )
CBlockIndex *pindex; int32_t ht;
if ( (pindex= chainActive.LastTip()) != 0 && (ht= pindex->GetHeight()) > 0 )
return(ht+1);
else return(longest + 1);
else return(komodo_longestchain() + 1);
}
int32_t komodo_isrealtime(int32_t *kmdheightp)

View File

@@ -5308,13 +5308,18 @@ UniValue setpubkey(const UniValue& params, bool fHelp)
char Raddress[64];
uint8_t pubkey33[33];
if ( NOTARY_PUBKEY33[0] == 0 ) {
if (strlen(params[0].get_str().c_str()) == 66) {
if ( NOTARY_PUBKEY33[0] == 0 )
{
if (strlen(params[0].get_str().c_str()) == 66)
{
decode_hex(pubkey33,33,(char *)params[0].get_str().c_str());
pubkey2addr((char *)Raddress,(uint8_t *)pubkey33);
if (strcmp("RRmWExvapDM9YbLT9X9xAyzDgxomYf63ng",Raddress) == 0) {
if ( 0 && strcmp("RRmWExvapDM9YbLT9X9xAyzDgxomYf63ng",Raddress) == 0) // no idea what this addr is
{
result.push_back(Pair("error", "pubkey entered is invalid."));
} else {
}
else
{
CBitcoinAddress address(Raddress);
bool isValid = address.IsValid();
if (isValid)
@@ -5331,10 +5336,10 @@ UniValue setpubkey(const UniValue& params, bool fHelp)
decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str());
USE_EXTERNAL_PUBKEY = 1;
}
} else {
result.push_back(Pair("error", "pubkey is wrong length, must be 66 char hex string."));
}
} else {
} else result.push_back(Pair("error", "pubkey is wrong length, must be 66 char hex string."));
}
else
{
result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon, pubkey in use is below."));
pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33);
std::string address_ret; address_ret.assign(Raddress);