Merge pull request #1308 from jl777/jl777

skip revalidating already validated playerdata, ie. 't'
This commit is contained in:
jl777
2019-03-03 06:10:33 -11:00
committed by GitHub
8 changed files with 335 additions and 305 deletions

View File

@@ -51,7 +51,7 @@ Komodo is based on Zcash and has been extended by our innovative consensus algor
```shell ```shell
#The following packages are needed: #The following packages are needed:
sudo apt-get install build-essential pkg-config libc6-dev m4 g++-multilib autoconf libtool ncurses-dev unzip git python python-zmq zlib1g-dev wget libcurl4-gnutls-dev bsdmainutils automake curl libboost-dev sudo apt-get install build-essential pkg-config libc6-dev m4 g++-multilib autoconf libtool ncurses-dev unzip git python python-zmq zlib1g-dev wget libcurl4-gnutls-dev bsdmainutils automake curl
``` ```
### Build Komodo ### Build Komodo

View File

@@ -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;

View File

@@ -27,31 +27,31 @@ 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 },
}; };
/* /*
* reinitialize room graph description * reinitialize room graph description
*/ */
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;
} }
/* /*
* starting with one room, connect it to a random adjacent room and * starting with one room, connect it to a random adjacent room and
* then pick a new room to start with. * then pick a new room to start with.
@@ -61,65 +61,65 @@ 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);
/* /*
* attempt to add passages to the graph a random number of times so * attempt to add passages to the graph a random number of times so
* that there isn't always just one unique passage through it. * that there isn't always just one unique passage through it.
*/ */
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();
} }
@@ -138,22 +138,22 @@ conn(struct rogue_state *rs,int r1, int r2)
int rm; int rm;
char direc; char direc;
static coord del, curr, turn_delta, spos, epos; static coord del, curr, turn_delta, spos, epos;
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,75 +162,75 @@ 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 */
/* /*
* Draw in the doors on either side of the passage or just put #'s * Draw in the doors on either side of the passage or just put #'s
* 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");
} }
/* /*
@@ -274,13 +274,13 @@ void
putpass(coord *cp) putpass(coord *cp)
{ {
PLACE *pp; PLACE *pp;
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;
} }
/* /*
@@ -293,23 +293,23 @@ void
door(struct room *rm, coord *cp) door(struct room *rm, coord *cp)
{ {
PLACE *pp; PLACE *pp;
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
@@ -324,31 +324,31 @@ add_pass()
PLACE *pp; PLACE *pp;
int y, x; int y, x;
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
@@ -365,17 +365,17 @@ passnum()
{ {
struct room *rp; struct room *rp;
int i; int i;
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);
} }
} }
/* /*
@@ -389,30 +389,30 @@ numpass(int y, int x)
char *fp; char *fp;
struct room *rp; struct room *rp;
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

View File

@@ -23,65 +23,65 @@ ring_on(struct rogue_state *rs)
{ {
THING *obj; THING *obj;
int ring; int ring;
obj = get_item(rs,"put on", RING); obj = get_item(rs,"put on", RING);
/* /*
* 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;
/* /*
* Calculate the effect it has on the poor guy. * Calculate the effect it has on the poor guy.
*/ */
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);
} }
@@ -95,31 +95,31 @@ ring_off(struct rogue_state *rs)
{ {
int ring; int ring;
THING *obj; THING *obj;
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;
} }
@@ -189,18 +189,18 @@ char *
ring_num(THING *obj) 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;
} }

View File

@@ -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);

View File

@@ -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
{ {
@@ -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 )
@@ -1515,14 +1517,15 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C
return(true); return(true);
break; break;
case 'H': case 'Q': case 'H': case 'Q':
if ( (f= rogue_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,pname,scriptPubKey)) != funcid ) /*if ( (f= rogue_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,pname,scriptPubKey)) != funcid )
{ {
//fprintf(stderr,"height.%d couldnt decode H/Q opret\n",height); //fprintf(stderr,"height.%d couldnt decode H/Q opret\n",height);
//if ( height > 20000 ) //if ( height > 20000 )
return eval->Invalid("couldnt decode H/Q opret"); return eval->Invalid("couldnt decode H/Q opret");
} }
fprintf(stderr,"height.%d decoded H/Q opret\n",height);
// spending the baton proves it is the user if the pk is the signer // spending the baton proves it is the user if the pk is the signer
// rest of validation is done below // rest of validation is done below*/
break; break;
default: default:
return eval->Invalid("illegal rogue non-decoded funcid"); return eval->Invalid("illegal rogue non-decoded funcid");
@@ -1536,27 +1539,37 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C
return(true); return(true);
case 'H': // win case 'H': // win
case 'Q': // bailout case 'Q': // bailout
// verify pk belongs to this tx if ( (f= rogue_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,pname,scriptPubKey)) != funcid )
if ( playerdata.size() > 0 )
{ {
//fprintf(stderr,"height.%d couldnt decode H/Q opret\n",height);
//if ( height > 20000 )
return eval->Invalid("couldnt decode H/Q opret");
}
// verify pk belongs to this tx
if ( tokentx == 'c' && 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 cashout amount"); 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 )
return eval->Invalid("mismatched cashout amount");
} }
if ( funcid == 'Q' ) if ( funcid == 'Q' )
{ {

View File

@@ -36,7 +36,7 @@
#define KOMODO_MAXNVALUE (((uint64_t)1 << 63) - 1) #define KOMODO_MAXNVALUE (((uint64_t)1 << 63) - 1)
#define KOMODO_BIT63SET(x) ((x) & ((uint64_t)1 << 63)) #define KOMODO_BIT63SET(x) ((x) & ((uint64_t)1 << 63))
#define KOMODO_VALUETOOBIG(x) ((x) > (uint64_t)10000000000*COIN) #define KOMODO_VALUETOOBIG(x) ((x) > (uint64_t)10000000001*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);

View File

@@ -3373,8 +3373,8 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
int64_t nTimeStart = GetTimeMicros(); int64_t nTimeStart = GetTimeMicros();
CAmount nFees = 0; CAmount nFees = 0;
int nInputs = 0; int nInputs = 0;
uint64_t voutsum = 0,prevsum=0,valueout; uint64_t valueout;
int64_t interest,sum = 0; int64_t voutsum = 0,prevsum=0,interest,sum = 0;
unsigned int nSigOps = 0; unsigned int nSigOps = 0;
CDiskTxPos pos(pindex->GetBlockPos(), GetSizeOfCompactSize(block.vtx.size())); CDiskTxPos pos(pindex->GetBlockPos(), GetSizeOfCompactSize(block.vtx.size()));
std::vector<std::pair<uint256, CDiskTxPos> > vPos; std::vector<std::pair<uint256, CDiskTxPos> > vPos;
@@ -3501,12 +3501,13 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
} }
prevsum = voutsum; prevsum = voutsum;
voutsum += valueout; voutsum += valueout;
if ( KOMODO_VALUETOOBIG(voutsum) != 0 ) /*if ( KOMODO_VALUETOOBIG(voutsum) != 0 )
{ {
fprintf(stderr,"voutsum %.8f too big\n",(double)voutsum/COIN); 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())
{ {
@@ -4276,6 +4277,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;