From e3ccd36f0b325587acaf5a5c9affa36fb9190f9b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 00:46:28 -1100 Subject: [PATCH 01/87] Initial cursesd --- src/cc/makerogue | 2 +- src/cc/rogue/cursesd.c | 363 +++++++++++++++++++++++++++++++++++++---- src/cc/rogue/cursesd.h | 161 +++++++++--------- src/cc/rogue/options.c | 6 +- src/cc/rogue/rip.c | 1 + src/cc/rogue/rogue.c | 2 + src/cc/rogue/rogue.h | 2 +- src/cc/rogue/rogue.scr | 0 src/cc/rogue/save.c | 4 +- src/cc/rogue/things.c | 63 +++---- 10 files changed, 465 insertions(+), 139 deletions(-) create mode 100644 src/cc/rogue/rogue.scr diff --git a/src/cc/makerogue b/src/cc/makerogue index 490576bd1..249e646f5 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -2,7 +2,7 @@ cd rogue; ./configure # only need this first time make; cd .. -gcc -Wno-write-strings -DBUILD_ROGUE -std=c++11 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -o librogue.so -c cclib.cpp -lncurses +gcc -Wno-write-strings -DBUILD_ROGUE -std=c++11 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -o librogue.so -c cclib.cpp #gcc -std=c++11 -fPIC -shared -o librogue.so cclib.o rogue/rogue.so cp librogue.so ../libcc.so diff --git a/src/cc/rogue/cursesd.c b/src/cc/rogue/cursesd.c index 643ed87de..54f55c4f5 100644 --- a/src/cc/rogue/cursesd.c +++ b/src/cc/rogue/cursesd.c @@ -17,13 +17,268 @@ static int32_t endwinflag; +WINDOW *newwin(int32_t nlines,int32_t ncols,int32_t begin_y,int32_t begin_x) +{ + WINDOW *scr = 0; + if ( nlines == LINES && ncols == COLS && begin_y == 0 && begin_x == 0 ) + scr = (WINDOW *)calloc(1,sizeof(*stdscr)); + return(scr); +} + WINDOW *initscr() { if ( stdscr == 0 ) - stdscr = (WINDOW *)calloc(1,sizeof(*stdscr)); + stdscr = newwin(LINES,COLS,0,0); return(stdscr); } +int32_t delwin(WINDOW *win) +{ + free(win); + return(0); +} + +int32_t wmove(WINDOW *win, int32_t y, int32_t x) +{ + win->y = y; + win->x = x; + return(0); +} + +int32_t move(int32_t y, int32_t x) +{ + return(wmove(stdscr,y,x)); +} + +int werase(WINDOW *win) +{ + memset(win->screen,' ',sizeof(win->screen)); + return(0); +} + +int wclear(WINDOW *win) +{ + werase(win); + clearok(win,TRUE); + return(0); +} + +int wclrtoeol(WINDOW *win) +{ + if ( win->x < COLS-1 ) + memset(&win->screen[win->y][win->x],' ',COLS - win->x); + return(0); +} + +int wclrtobot(WINDOW *win) +{ + wclrtoeol(win); + if ( win->y < LINES-1 ) + memset(&win->screen[win->y+1][0],' ',COLS); + return(0); +} + +int erase(void) +{ + return(werase(stdscr)); +} + +int clear(void) +{ + return(wclear(stdscr)); +} + +int clrtobot(void) +{ + return(wclrtobot(stdscr)); +} + +int clrtoeol(void) +{ + return(wclrtoeol(stdscr)); +} + +int32_t waddch(WINDOW *win, chtype ch) +{ + int32_t t; + if ( ch == '\t' ) + { + for (i=0; i<8; i++) + { + if ( win->x >= COLS-1 ) + break; + win->x++; + if ( (win->x & 7) == 0 ) + break; + } + } + else if ( ch == '\n' ) + { + wclrtoeol(win); + win->x = 0; + win->y++; + if ( win->y >= LINES ) + win->y = 0; + } + else if ( ch == '\b' ) + { + if ( win->x > 0 ) + win->x--; + } + else + { + win->screen[win->y][win->x++] = ch; + if ( win->x >= COLS ) + { + win->x = 0; + win->y++; + if ( win->y >= LINES ) + win->y = 0; + } + } + reurn(0); +} + +int32_t mvwaddch(WINDOW *win, int32_t y, int32_t x, chtype ch) +{ + win->y = y; + win->x = x; + return(waddch(win,ch)); +} + +int32_t addch(chtype ch) +{ + return(waddch(stdscr,ch)); +} + +int32_t mvaddch(int32_t y, int32_t x, chtype ch) +{ + return(mvwaddch(stdscr,y,x,ch)); +} + +int32_t waddstr(WINDOW *win, const char *str) +{ + int32_t i; + for (i=0; str[i]!=0; i++) + waddch(win,str[i]); + return(0); +} + +int32_t waddnstr(WINDOW *win, const char *str, int32_t n) +{ + int32_t i; + for (i=0; str[i]!=0 && iy = y; + win->x = x; + return(waddstr(win,str)); +} + +int32_t mvwaddnstr(WINDOW *win, int32_t y, int32_t x, const char *str, int32_t n) +{ + win->y = y; + win->x = x; + return(waddnstr(win,str)); +} + +int32_t addstr(const char *str) +{ + return(waddstr(stdscr,str)); +} + +int32_t addnstr(const char *str, int32_t n) +{ + return(waddnstr(stdscr,str,n)); +} + +int32_t mvaddstr(int32_t y, int32_t x, const char *str) +{ + stdscr->y = y; + stdscr->x = x; + return(waddstr(stdscr,str)); +} + +int32_t mvaddnstr(int32_t y, int32_t x, const char *str, int32_t n) +{ + stdscr->y = y; + stdscr->x = x; + return(waddnstr(stdscr,str,n)); +} + +int32_t printw(char *fmt,...) +{ + char str[512]; int32_t ret; va_list myargs; // Declare a va_list type variable + va_start(myargs,fmt); // Initialise the va_list variable with the ... after fmt + ret = vsprintf(str,fmt,myargs); // Forward the '...' to vsprintf + va_end(myargs); // Clean up the va_list + return(addstr(str)); +} + +int32_t wprintw(WINDOW *win,char *fmt,...) +{ + char str[512]; int32_t ret; va_list myargs; // Declare a va_list type variable + va_start(myargs,fmt); // Initialise the va_list variable with the ... after fmt + ret = vsprintf(str,fmt,myargs); // Forward the '...' to vsprintf + va_end(myargs); // Clean up the va_list + return(waddstr(win,str)); +} + +int32_t mvprintw(int32_t y,int32_t x,char *fmt,...) +{ + char str[512]; int32_t ret; va_list myargs; // Declare a va_list type variable + va_start(myargs,fmt); // Initialise the va_list variable with the ... after fmt + ret = vsprintf(str,fmt,myargs); // Forward the '...' to vsprintf + va_end(myargs); // Clean up the va_list + stdscr->y = y; + stdscr->x = x; + return(addstr(str)); +} + +int32_t mvwprintw(WINDOW *win,int32_t y,int32_t x,char *fmt,...) +{ + char str[512]; int32_t ret; va_list myargs; // Declare a va_list type variable + va_start(myargs,fmt); // Initialise the va_list variable with the ... after fmt + ret = vsprintf(str,fmt,myargs); // Forward the '...' to vsprintf + va_end(myargs); // Clean up the va_list + win->y = y; + win->x = x; + return(waddstr(win,str)); +} + +chtype winch(WINDOW *win) +{ + return(win->screen[win->y][win->x]); +} + +chtype inch(void) +{ + return(winch(stdscr)); +} + +chtype mvwinch(WINDOW *win, int32_t y, int32_t x) +{ + win->y = y; + win->x = x; + return(win->screen[win->y][win->x]); +} + +chtype mvinch(int32_t y, int32_t x) +{ + return(mvwinch(stdscr,y,x)); +} + +int32_t mvcur(int32_t oldrow, int32_t oldcol, int32_t newrow, int32_t newcol) +{ + stdscr->y = newrow; + stdscr->x = newcol; + return(0); +} + void endwin() { if ( stdscr != 0 ) @@ -36,27 +291,12 @@ int isendwin(void) return(endwinflag); } -int wrefresh(WINDOW *win) -{ - return(0); -} - int refresh(void) { endwinflag = 0; return(wrefresh(stdscr)); } -int wnoutrefresh(WINDOW *win) -{ - return(0); -} - -int doupdate(void) -{ - return(0); -} - int redrawwin(WINDOW *win) { return(wrefresh(win)); @@ -67,42 +307,101 @@ int wredrawln(WINDOW *win, int beg_line, int num_lines) return(wrefresh(win)); } -int werase(WINDOW *win) +// functions with no data side effect +#ifdef they_are_macros +int wrefresh(WINDOW *win) { - + return(0); } -int erase(void) +int wnoutrefresh(WINDOW *win) { - return(werase(stdscr)); + return(0); } -int wclear(WINDOW *win) +int doupdate(void) { - + return(0); } -int clear(void) +int32_t touchwin(WINDOW *win) { - return(wclear(stdscr)); + return(0); } -int wclrtobot(WINDOW *win) +int standout(void) { - + return(0); } -int clrtobot(void) +int standend(void) { - return(wclrtobot(stdscr)); + return(0); } -int wclrtoeol(WINDOW *win) +int raw(void) { - + return(0); } -int clrtoeol(void) +int32_t keypad(WINDOW *win, bool bf) { - return(wclrtoeol(stdscr)); + return(0); } + +int noecho(void) +{ + return(0); +} + +int flushinp(void) +{ + return(0); +} + +int clearok(WINDOW *win, bool bf) +{ + return(0); +} + +int idlok(WINDOW *win, bool bf) +{ + return(0); +} + +int leaveok(WINDOW *win, bool bf) +{ + return(0); +} +#endif + +int32_t mvwin(WINDOW *win, int32_t y, int32_t x); // stub +{ + fprintf(stderr,"unexpected call to mvwin\n"); + return(0); +} + +WINDOW *subwin(WINDOW *orig, int nlines, int ncols, int begin_y, int begin_x) +{ + fprintf(stderr,"unexpected and unsupported call to subwin\n"); + return(0); +} + +char erasechar(void) +{ + fprintf(stderr,"unexpected and unsupported call to erasechar\n"); + return(8); +} + +char killchar(void) +{ + fprintf(stderr,"unexpected and unsupported call to erasechar\n"); + return(3); +} + +int32_t mvgetnstr(int32_t y, int32_t x, char *str, int32_t n) // stub +{ + fprintf(stderr,"unexpected and unsupported call to mvgetnstr\n"); + return(0); +} + diff --git a/src/cc/rogue/cursesd.h b/src/cc/rogue/cursesd.h index 5e3d375ca..6d5944b75 100644 --- a/src/cc/rogue/cursesd.h +++ b/src/cc/rogue/cursesd.h @@ -36,38 +36,107 @@ #include #include -#ifdef notyet - struct cursesd_info { uint8_t screen[LINES][COLS]; + int32_t x,y; } *stdscr; typedef struct cursesd_info WINDOW; +typedef char chtype; WINDOW *initscr(void); -int endwin(void); -int isendwin(void); +int32_t endwin(void); +int32_t isendwin(void); //SCREEN *newterm(const char *type, FILE *outfd, FILE *infd); //SCREEN *set_term(SCREEN *new); //void delscreen(SCREEN* sp); -int refresh(void); -int wrefresh(WINDOW *win); -//int wnoutrefresh(WINDOW *win); -//int doupdate(void); -int redrawwin(WINDOW *win); -int wredrawln(WINDOW *win, int beg_line, int num_lines); +int32_t refresh(void); +int32_t wrefresh(WINDOW *win); +//int32_t wnoutrefresh(WINDOW *win); +//int32_t doupdate(void); +int32_t redrawwin(WINDOW *win); +int32_t wredrawln(WINDOW *win, int32_t beg_line, int32_t num_lines); -int erase(void); -int werase(WINDOW *win); -int clear(void); -int wclear(WINDOW *win); -int clrtobot(void); -int wclrtobot(WINDOW *win); -int clrtoeol(void); -int wclrtoeol(WINDOW *win); +int32_t erase(void); +int32_t werase(WINDOW *win); +int32_t clear(void); +int32_t wclear(WINDOW *win); +int32_t clrtobot(void); +int32_t wclrtobot(WINDOW *win); +int32_t clrtoeol(void); +int32_t wclrtoeol(WINDOW *win); -#endif +int32_t standout(void); +int32_t standend(void); +int32_t raw(void); +int32_t noecho(void); +int32_t flushinp(void); +int32_t keypad(WINDOW *win, bool bf); + +int32_t clearok(WINDOW *win, bool bf); +int32_t idlok(WINDOW *win, bool bf); +int32_t leaveok(WINDOW *win, bool bf); + +WINDOW *newwin(int32_t nlines,int32_t ncols,int32_t begin_y,int32_t begin_x); // only LINES,COLS,0,0 +int32_t delwin(WINDOW *win); +int32_t touchwin(WINDOW *win); // stub +WINDOW *subwin(WINDOW *orig, int32_t nlines, int32_t ncols, int32_t begin_y, int32_t begin_x); // stub +int32_t mvwin(WINDOW *win, int32_t y, int32_t x); // stub +int32_t mvcur(int32_t oldrow, int32_t oldcol, int32_t newrow, int32_t newcol); + +char erasechar(void); // stub +char killchar(void); // stub + +int32_t move(int32_t y, int32_t x); +int32_t wmove(WINDOW *win, int32_t y, int32_t x); + +chtype inch(void); +chtype winch(WINDOW *win); +chtype mvinch(int32_t y, int32_t x); +chtype mvwinch(WINDOW *win, int32_t y, int32_t x); + +int32_t addch(chtype ch); +int32_t waddch(WINDOW *win, chtype ch); +int32_t mvaddch(int32_t y, int32_t x, chtype ch); +int32_t mvwaddch(WINDOW *win, int32_t y, int32_t x, chtype ch); + +int32_t addstr(const char *str); +int32_t addnstr(const char *str, int32_t n); +int32_t waddstr(WINDOW *win, const char *str); +int32_t waddnstr(WINDOW *win, const char *str, int32_t n); +int32_t mvaddstr(int32_t y, int32_t x, const char *str); +int32_t mvaddnstr(int32_t y, int32_t x, const char *str, int32_t n); +int32_t mvwaddstr(WINDOW *win, int32_t y, int32_t x, const char *str); +int32_t mvwaddnstr(WINDOW *win, int32_t y, int32_t x, const char *str, int32_t n); + +int32_t mvgetnstr(int32_t y, int32_t x, char *str, int32_t n); // stub +int32_t printw(char *fmt,...); +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,...); + +#define A_CHARTEXT 0xff +#define baudrate() 9600 +#define unctrl(a) "^x" +#define getmaxx(a) COLS +#define getmaxy(a) LINES +#define getxy(win,y,x) y = win->y, x = win->x + +// functions with only visible effects +#define wrefresh(win) 0 +#define wnoutrefresh(win) 0 +#define doupdate() 0 +#define touchwin(win) 0 +#define standout() 0 +#define standend() 0 +#define raw() 0 +#define keypad(win,bf) 0 +#define noecho() 0 +#define flushinp() 0 +#define clearok(win,bf) 0 +#define idlok(win,bf) 0 +#define leaveok(win,bf) 0 #ifndef TRUE #define TRUE 1 @@ -77,57 +146,3 @@ int wclrtoeol(WINDOW *win); #endif -#define standout() -#define standend() -#define refresh() -#define raw() -#define noecho() -#define flushinp() -#define clear() -#define clrtoeol() - -#define addch(a) -#define werase(a) -#define wclear(a) -#define delwin(a) -#define addstr(a) -#define touchwin(a) -#define idlok(a,b) -#define clearok(a,b) -#define keypad(a,b) -#define leaveok(a,b) -#define waddch(a,b) -#define waddstr(a,b) -#define move(a,b) -#define mvwin(a,b,c) -#define wmove(a,b,c) -#define mvaddch(a,b,c) -#define mvaddstr(a,b,c) -#define wgetnstr(a,b,c) -#define getyx(a,b,c) -#define mvcur(a,b,c,d) -#define mvwaddch(a,b,c,d) -#define mvprintw(...) -#define printw(...) -#define wprintw(...) -#define mvwprintw(...) - - -#define A_CHARTEXT 0xff -#define inch() 0 -#define endwin() 1 -#define isendwin() 0 -#define baudrate() 9600 -#define killchar() 3 -#define erasechar() 8 -#define wclrtoeol(a) 0 -#define wrefresh(a) 0 -#define unctrl(a) "^x" -#define getmaxx(a) COLS -#define getmaxy(a) LINES -#define mvinch(a,b) '.' -#define mvwinch(a,b,c) 0 -#define newwin(a,b,c,d) 0 -#define subwin(a,b,c,d,e) 0 - -#endif diff --git a/src/cc/rogue/options.c b/src/cc/rogue/options.c index d74979365..258bd184f 100644 --- a/src/cc/rogue/options.c +++ b/src/cc/rogue/options.c @@ -266,7 +266,7 @@ get_str(struct rogue_state *rs,void *vopt, WINDOW *win) { if (c == -1) continue; - else if (c == erasechar()) /* process erase character */ + /*else if (c == erasechar()) // process erase character { if (sp > buf) { @@ -276,12 +276,12 @@ get_str(struct rogue_state *rs,void *vopt, WINDOW *win) } continue; } - else if (c == killchar()) /* process kill character */ + else if (c == killchar()) // process kill character { sp = buf; wmove(win, oy, ox); continue; - } + }*/ else if (sp == buf) { if (c == '-' && win != stdscr) diff --git a/src/cc/rogue/rip.c b/src/cc/rogue/rip.c index be97fb867..65be2e8fa 100644 --- a/src/cc/rogue/rip.c +++ b/src/cc/rogue/rip.c @@ -87,6 +87,7 @@ score(struct rogue_state *rs,int amount, int flags, char monst) delwin(curscr); if (hw != NULL) delwin(hw); + hw = NULL; } top_ten = (SCORE *) malloc(numscores * sizeof (SCORE)); diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 63e699c30..eb605385d 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -91,7 +91,9 @@ void rogueiterate(struct rogue_state *rs) // Set up windows if ( hw == NULL ) + { hw = newwin(LINES, COLS, 0, 0); + } idlok(stdscr, TRUE); idlok(hw, TRUE); #ifdef MASTER diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index fac84d8b0..f8e5dd23b 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -29,7 +29,7 @@ #include #include -#ifndef DONTUSEGUI +#ifndef BUILD_ROGUE #include #else diff --git a/src/cc/rogue/rogue.scr b/src/cc/rogue/rogue.scr new file mode 100644 index 000000000..e69de29bb diff --git a/src/cc/rogue/save.c b/src/cc/rogue/save.c index 7349c196a..15dda401e 100644 --- a/src/cc/rogue/save.c +++ b/src/cc/rogue/save.c @@ -227,7 +227,9 @@ restore(struct rogue_state *rs,char *file, char **envp) char buf[MAXSTR]; //auto STAT sbuf2; - + if ( rs->guiflag == 0 ) + return(0); + if (strcmp(file, "-r") == 0) file = file_name; diff --git a/src/cc/rogue/things.c b/src/cc/rogue/things.c index 29c51c4ed..39c7b94b7 100644 --- a/src/cc/rogue/things.c +++ b/src/cc/rogue/things.c @@ -502,37 +502,44 @@ add_line(struct rogue_state *rs,char *fmt, char *arg) msg(rs,""); if ( rs->sleeptime != 0 ) refresh(); - tw = newwin(line_cnt + 1, maxlen + 2, 0, COLS - maxlen - 3); - sw = subwin(tw, line_cnt + 1, maxlen + 1, 0, COLS - maxlen - 2); - for (y = 0; y <= line_cnt; y++) + if ( rs->guiflag != 0 ) { - wmove(sw, y, 0); - for (x = 0; x <= maxlen; x++) - waddch(sw, mvwinch(hw, y, x)); - } - wmove(tw, line_cnt, 1); - waddstr(tw, prompt); - /* - * if there are lines below, use 'em - */ - if (LINES > NUMLINES) - { - if (NUMLINES + line_cnt > LINES) - mvwin(tw, LINES - (line_cnt + 1), COLS - maxlen - 3); - else - mvwin(tw, NUMLINES, 0); - } - touchwin(tw); - wrefresh(tw); - wait_for(rs,' '); - if (md_hasclreol()) - { - werase(tw); - leaveok(tw, TRUE); + tw = newwin(line_cnt + 1, maxlen + 2, 0, COLS - maxlen - 3); + sw = subwin(tw, line_cnt + 1, maxlen + 1, 0, COLS - maxlen - 2); + for (y = 0; y <= line_cnt; y++) + { + wmove(sw, y, 0); + for (x = 0; x <= maxlen; x++) + waddch(sw, mvwinch(hw, y, x)); + } + wmove(tw, line_cnt, 1); + waddstr(tw, prompt); + /* + * if there are lines below, use 'em + */ + if (LINES > NUMLINES) + { + if (NUMLINES + line_cnt > LINES) + mvwin(tw, LINES - (line_cnt + 1), COLS - maxlen - 3); + else + mvwin(tw, NUMLINES, 0); + } + touchwin(tw); wrefresh(tw); + wait_for(rs,' '); + if (md_hasclreol()) + { + werase(tw); + leaveok(tw, TRUE); + wrefresh(tw); + } + delwin(tw); + touchwin(stdscr); + } + else + { + wait_for(rs,' '); } - delwin(tw); - touchwin(stdscr); } else { From a6b024b5595f0a9e1c65217fc25b3cc32bee5fac Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 00:47:24 -1100 Subject: [PATCH 02/87] Delete rogue.scr --- src/cc/rogue/rogue.scr | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 src/cc/rogue/rogue.scr diff --git a/src/cc/rogue/rogue.scr b/src/cc/rogue/rogue.scr deleted file mode 100644 index e69de29bb..000000000 From 8d1a4eb532cc2ac86aa237be27af71e914a75ca6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 00:48:56 -1100 Subject: [PATCH 03/87] Terminate ifdef --- src/cc/rogue/cursesd.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/rogue/cursesd.h b/src/cc/rogue/cursesd.h index 6d5944b75..8a2062a36 100644 --- a/src/cc/rogue/cursesd.h +++ b/src/cc/rogue/cursesd.h @@ -145,4 +145,5 @@ int32_t mvwprintw(WINDOW *win,int32_t y,int32_t x,char *fmt,...); #define FALSE 0 #endif +#endif From a76f1fd959472a54c7534ceca9a48287f42a3b40 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 00:51:28 -1100 Subject: [PATCH 04/87] Test --- src/cc/rogue/rogue.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index f8e5dd23b..8cf5f7d90 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -30,9 +30,10 @@ #include #ifndef BUILD_ROGUE +xxx #include #else - +yyy #include "cursesd.h" #endif From 360cb73281bddb712eeec96dbbe11dbd96d3bb23 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 00:53:51 -1100 Subject: [PATCH 05/87] Mdport -= curses.h --- src/cc/rogue/mdport.c | 5 +++++ src/cc/rogue/rogue.h | 2 -- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/mdport.c b/src/cc/rogue/mdport.c index 443ef1e60..899f5d9db 100644 --- a/src/cc/rogue/mdport.c +++ b/src/cc/rogue/mdport.c @@ -81,7 +81,12 @@ #endif #endif +#ifndef BUILD_ROGUE #include /* AIX requires curses.h be included before term.h */ +#else +#include "cursesd.h" +#endif + #if defined(HAVE_TERM_H) #include diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index 8cf5f7d90..e99c0d5ff 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -30,10 +30,8 @@ #include #ifndef BUILD_ROGUE -xxx #include #else -yyy #include "cursesd.h" #endif From 413b477db0f6baba40e942d991cbcac87ac3983b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 00:55:09 -1100 Subject: [PATCH 06/87] io.c --- src/cc/rogue/io.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index fbcddf5fa..a5762adda 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -8,6 +8,12 @@ //#include //#include //#include +#ifndef BUILD_ROGUE +#include +#else +#include "cursesd.h" +#endif + #include "rogue.h" /* From bc1fc144ae51f30579e19e765737e5d9db511627 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 00:58:04 -1100 Subject: [PATCH 07/87] Stdscr --- src/cc/rogue/cursesd.c | 1 + src/cc/rogue/cursesd.h | 3 ++- src/cc/rogue/io.c | 5 ----- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/cc/rogue/cursesd.c b/src/cc/rogue/cursesd.c index 54f55c4f5..76760c3f9 100644 --- a/src/cc/rogue/cursesd.c +++ b/src/cc/rogue/cursesd.c @@ -16,6 +16,7 @@ #include "cursesd.h" static int32_t endwinflag; +WINDOW *stdscr; WINDOW *newwin(int32_t nlines,int32_t ncols,int32_t begin_y,int32_t begin_x) { diff --git a/src/cc/rogue/cursesd.h b/src/cc/rogue/cursesd.h index 8a2062a36..0cbb2cc01 100644 --- a/src/cc/rogue/cursesd.h +++ b/src/cc/rogue/cursesd.h @@ -40,7 +40,8 @@ struct cursesd_info { uint8_t screen[LINES][COLS]; int32_t x,y; -} *stdscr; +}; +extern WINDOW *stdscr; typedef struct cursesd_info WINDOW; typedef char chtype; diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index a5762adda..c920ee411 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -8,11 +8,6 @@ //#include //#include //#include -#ifndef BUILD_ROGUE -#include -#else -#include "cursesd.h" -#endif #include "rogue.h" From da992ca886ca526d58536b91501581d89284e848 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 01:15:30 -1100 Subject: [PATCH 08/87] Fixes --- src/cc/rogue/cursesd.c | 3 ++- src/cc/rogue/cursesd.h | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue/cursesd.c b/src/cc/rogue/cursesd.c index 76760c3f9..8462532b9 100644 --- a/src/cc/rogue/cursesd.c +++ b/src/cc/rogue/cursesd.c @@ -23,6 +23,7 @@ WINDOW *newwin(int32_t nlines,int32_t ncols,int32_t begin_y,int32_t begin_x) WINDOW *scr = 0; if ( nlines == LINES && ncols == COLS && begin_y == 0 && begin_x == 0 ) scr = (WINDOW *)calloc(1,sizeof(*stdscr)); + curscr = scr; return(scr); } @@ -400,7 +401,7 @@ char killchar(void) return(3); } -int32_t mvgetnstr(int32_t y, int32_t x, char *str, int32_t n) // stub +int32_t wgetnstr(WINDOW *win, char *str, int32_t n) // stub { fprintf(stderr,"unexpected and unsupported call to mvgetnstr\n"); return(0); diff --git a/src/cc/rogue/cursesd.h b/src/cc/rogue/cursesd.h index 0cbb2cc01..57cb51237 100644 --- a/src/cc/rogue/cursesd.h +++ b/src/cc/rogue/cursesd.h @@ -41,7 +41,7 @@ struct cursesd_info uint8_t screen[LINES][COLS]; int32_t x,y; }; -extern WINDOW *stdscr; +extern WINDOW *stdscr,*curscr; typedef struct cursesd_info WINDOW; typedef char chtype; @@ -111,7 +111,7 @@ int32_t mvaddnstr(int32_t y, int32_t x, const char *str, int32_t n); int32_t mvwaddstr(WINDOW *win, int32_t y, int32_t x, const char *str); int32_t mvwaddnstr(WINDOW *win, int32_t y, int32_t x, const char *str, int32_t n); -int32_t mvgetnstr(int32_t y, int32_t x, char *str, int32_t n); // stub +int32_t wgetnstr(WINDOW *win, char *str, int32_t n); // stub int32_t printw(char *fmt,...); int32_t wprintw(WINDOW *win,char *fmt,...); int32_t mvprintw(int32_t y,int32_t x,char *fmt,...); @@ -122,7 +122,7 @@ int32_t mvwprintw(WINDOW *win,int32_t y,int32_t x,char *fmt,...); #define unctrl(a) "^x" #define getmaxx(a) COLS #define getmaxy(a) LINES -#define getxy(win,y,x) y = win->y, x = win->x +#define getyx(win,y,x) y = win->y, x = win->x // functions with only visible effects #define wrefresh(win) 0 From 958365e987e02457d833e96b657c0e2406151d48 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 01:42:06 -1100 Subject: [PATCH 09/87] _argfory --- src/cc/rogue/cursesd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/cursesd.h b/src/cc/rogue/cursesd.h index 57cb51237..12ab8b2be 100644 --- a/src/cc/rogue/cursesd.h +++ b/src/cc/rogue/cursesd.h @@ -122,7 +122,7 @@ int32_t mvwprintw(WINDOW *win,int32_t y,int32_t x,char *fmt,...); #define unctrl(a) "^x" #define getmaxx(a) COLS #define getmaxy(a) LINES -#define getyx(win,y,x) y = win->y, x = win->x +#define getyx(win,_argfory,_argforx) _argfory = win->y, _argforx = win->x // functions with only visible effects #define wrefresh(win) 0 From 8824e836a700a03bdcc1265e1aa36cbd37e275f3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 01:44:12 -1100 Subject: [PATCH 10/87] extern WINDOW *stdscr,*curscr; --- src/cc/rogue/rogue.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index e99c0d5ff..f3f5572b2 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -860,5 +860,8 @@ extern const char *wood[]; extern int cNWOOD; extern const char *metal[]; extern int cNMETAL; + +extern WINDOW *stdscr,*curscr; + #endif From 43edfb4ae23abe6ce59ce2377f7329e78eb83e17 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 01:51:13 -1100 Subject: [PATCH 11/87] Stubs --- src/cc/rogue/cursesd.c | 6 ++++++ src/cc/rogue/cursesd.h | 6 +++++- src/cc/rogue/rogue.c | 2 ++ src/cc/rogue/rogue.h | 2 +- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/cursesd.c b/src/cc/rogue/cursesd.c index 8462532b9..c89a713ae 100644 --- a/src/cc/rogue/cursesd.c +++ b/src/cc/rogue/cursesd.c @@ -407,3 +407,9 @@ int32_t wgetnstr(WINDOW *win, char *str, int32_t n) // stub return(0); } +int32_t getch(void) +{ + fprintf(stderr,"unexpected and unsupported call to getch\n"); + return(0); +} + diff --git a/src/cc/rogue/cursesd.h b/src/cc/rogue/cursesd.h index 12ab8b2be..53d928ad0 100644 --- a/src/cc/rogue/cursesd.h +++ b/src/cc/rogue/cursesd.h @@ -41,10 +41,12 @@ struct cursesd_info uint8_t screen[LINES][COLS]; int32_t x,y; }; -extern WINDOW *stdscr,*curscr; typedef struct cursesd_info WINDOW; +extern WINDOW *stdscr,*curscr; typedef char chtype; +int32_t getch(void); // stub + WINDOW *initscr(void); int32_t endwin(void); int32_t isendwin(void); @@ -138,6 +140,8 @@ int32_t mvwprintw(WINDOW *win,int32_t y,int32_t x,char *fmt,...); #define clearok(win,bf) 0 #define idlok(win,bf) 0 #define leaveok(win,bf) 0 +#define halfdelay(x) 0 +#define nocbreak() 0 #ifndef TRUE #define TRUE 1 diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index eb605385d..b709e8d3a 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -544,9 +544,11 @@ tstp(int ignored) fflush(stdout); //wmove(curscr,oy,ox); #ifndef __APPLE__ +#ifndef BUILD_ROGUE curscr->_cury = oy; curscr->_curx = ox; #endif +#endif } /* diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index f3f5572b2..a5ddf943f 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -861,7 +861,7 @@ extern int cNWOOD; extern const char *metal[]; extern int cNMETAL; -extern WINDOW *stdscr,*curscr; +//extern WINDOW *stdscr,*curscr; #endif From db50762b5cd84439904e55d0f1d8515b84b24653 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 01:59:19 -1100 Subject: [PATCH 12/87] md_readchar --- src/cc/rogue/cursesd.c | 7 +++++++ src/cc/rogue/cursesd.h | 4 ++++ src/cc/rogue/mdport.c | 4 +++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/cursesd.c b/src/cc/rogue/cursesd.c index c89a713ae..c7a28fc62 100644 --- a/src/cc/rogue/cursesd.c +++ b/src/cc/rogue/cursesd.c @@ -17,6 +17,7 @@ static int32_t endwinflag; WINDOW *stdscr; +int32_t ESCDELAY; WINDOW *newwin(int32_t nlines,int32_t ncols,int32_t begin_y,int32_t begin_x) { @@ -413,3 +414,9 @@ int32_t getch(void) return(0); } +int32_t md_readchar(void) +{ + fprintf(stderr,"unexpected and unsupported call to md_readchar\n"); + return(0); +} + diff --git a/src/cc/rogue/cursesd.h b/src/cc/rogue/cursesd.h index 53d928ad0..4fa09e9d9 100644 --- a/src/cc/rogue/cursesd.h +++ b/src/cc/rogue/cursesd.h @@ -36,6 +36,8 @@ #include #include +#define ERR (-1) + struct cursesd_info { uint8_t screen[LINES][COLS]; @@ -43,9 +45,11 @@ struct cursesd_info }; typedef struct cursesd_info WINDOW; extern WINDOW *stdscr,*curscr; +extern int32_t ESCDELAY; typedef char chtype; int32_t getch(void); // stub +int32_t md_readchar(void); // stub WINDOW *initscr(void); int32_t endwin(void); diff --git a/src/cc/rogue/mdport.c b/src/cc/rogue/mdport.c index 899f5d9db..841dffbb8 100644 --- a/src/cc/rogue/mdport.c +++ b/src/cc/rogue/mdport.c @@ -1081,6 +1081,7 @@ md_setsuspchar(int c) #define M_KEYPAD 2 #define M_TRAIL 3 +#ifndef BUILD_ROGUE int md_readchar() { @@ -1320,7 +1321,8 @@ md_readchar() return(ch & 0x7F); } - +#endif + #if defined(LOADAV) && defined(HAVE_NLIST_H) && defined(HAVE_NLIST) /* * loadav: From 0e79c0002e61f8597ffd0e047ea14b0864859c04 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 02:03:09 -1100 Subject: [PATCH 13/87] Build cursesd.c --- src/cc/cclib.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 8a5cd2185..77f6a21ac 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -496,6 +496,7 @@ cJSON *cclib_reparse(int32_t *nump,cJSON *origparams) // assumes origparams will #ifdef BUILD_ROGUE #include "rogue_rpc.cpp" +#include "rogue/cursesd.c" #include "rogue/vers.c" #include "rogue/extern.c" #include "rogue/armor.c" From 4a6e3550134ae0b1d04a86f4e2fdac2a9aa4b1f4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 02:05:20 -1100 Subject: [PATCH 14/87] syntax --- src/cc/rogue/cursesd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue/cursesd.c b/src/cc/rogue/cursesd.c index c7a28fc62..d1975624c 100644 --- a/src/cc/rogue/cursesd.c +++ b/src/cc/rogue/cursesd.c @@ -103,7 +103,7 @@ int clrtoeol(void) int32_t waddch(WINDOW *win, chtype ch) { - int32_t t; + int32_t i; if ( ch == '\t' ) { for (i=0; i<8; i++) @@ -139,7 +139,7 @@ int32_t waddch(WINDOW *win, chtype ch) win->y = 0; } } - reurn(0); + return(0); } int32_t mvwaddch(WINDOW *win, int32_t y, int32_t x, chtype ch) @@ -186,7 +186,7 @@ int32_t mvwaddnstr(WINDOW *win, int32_t y, int32_t x, const char *str, int32_t n { win->y = y; win->x = x; - return(waddnstr(win,str)); + return(waddnstr(win,str,n)); } int32_t addstr(const char *str) @@ -378,7 +378,7 @@ int leaveok(WINDOW *win, bool bf) } #endif -int32_t mvwin(WINDOW *win, int32_t y, int32_t x); // stub +int32_t mvwin(WINDOW *win, int32_t y, int32_t x) // stub { fprintf(stderr,"unexpected call to mvwin\n"); return(0); From 62e1966b14263fcb96ca95d36f4535bc70b514f7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 02:05:58 -1100 Subject: [PATCH 15/87] Void --- src/cc/rogue/cursesd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/cursesd.c b/src/cc/rogue/cursesd.c index d1975624c..5bba65c95 100644 --- a/src/cc/rogue/cursesd.c +++ b/src/cc/rogue/cursesd.c @@ -282,7 +282,7 @@ int32_t mvcur(int32_t oldrow, int32_t oldcol, int32_t newrow, int32_t newcol) return(0); } -void endwin() +void endwin(void) { if ( stdscr != 0 ) free(stdscr), stdscr = 0; From 3666f642e496ef9a2bc9d27e5514794bd19dcfc3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 02:07:34 -1100 Subject: [PATCH 16/87] int32_t --- src/cc/rogue/cursesd.c | 51 +++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/src/cc/rogue/cursesd.c b/src/cc/rogue/cursesd.c index 5bba65c95..99274b86f 100644 --- a/src/cc/rogue/cursesd.c +++ b/src/cc/rogue/cursesd.c @@ -53,27 +53,27 @@ int32_t move(int32_t y, int32_t x) return(wmove(stdscr,y,x)); } -int werase(WINDOW *win) +int32_t werase(WINDOW *win) { memset(win->screen,' ',sizeof(win->screen)); return(0); } -int wclear(WINDOW *win) +int32_t wclear(WINDOW *win) { werase(win); clearok(win,TRUE); return(0); } -int wclrtoeol(WINDOW *win) +int32_t wclrtoeol(WINDOW *win) { if ( win->x < COLS-1 ) memset(&win->screen[win->y][win->x],' ',COLS - win->x); return(0); } -int wclrtobot(WINDOW *win) +int32_t wclrtobot(WINDOW *win) { wclrtoeol(win); if ( win->y < LINES-1 ) @@ -81,22 +81,22 @@ int wclrtobot(WINDOW *win) return(0); } -int erase(void) +int32_t erase(void) { return(werase(stdscr)); } -int clear(void) +int32_t clear(void) { return(wclear(stdscr)); } -int clrtobot(void) +int32_t clrtobot(void) { return(wclrtobot(stdscr)); } -int clrtoeol(void) +int32_t clrtoeol(void) { return(wclrtoeol(stdscr)); } @@ -282,47 +282,48 @@ int32_t mvcur(int32_t oldrow, int32_t oldcol, int32_t newrow, int32_t newcol) return(0); } -void endwin(void) +int32_t endwin(void) { if ( stdscr != 0 ) free(stdscr), stdscr = 0; endwinflag = 1; + return(0); } -int isendwin(void) +int32_t isendwin(void) { return(endwinflag); } -int refresh(void) +int32_t refresh(void) { endwinflag = 0; return(wrefresh(stdscr)); } -int redrawwin(WINDOW *win) +int32_t redrawwin(WINDOW *win) { return(wrefresh(win)); } -int wredrawln(WINDOW *win, int beg_line, int num_lines) +int32_t wredrawln(WINDOW *win, int32_t beg_line, int32_t num_lines) { return(wrefresh(win)); } // functions with no data side effect #ifdef they_are_macros -int wrefresh(WINDOW *win) +int32_t wrefresh(WINDOW *win) { return(0); } -int wnoutrefresh(WINDOW *win) +int32_t wnoutrefresh(WINDOW *win) { return(0); } -int doupdate(void) +int32_t doupdate(void) { return(0); } @@ -332,17 +333,17 @@ int32_t touchwin(WINDOW *win) return(0); } -int standout(void) +int32_t standout(void) { return(0); } -int standend(void) +int32_t standend(void) { return(0); } -int raw(void) +int32_t raw(void) { return(0); } @@ -352,27 +353,27 @@ int32_t keypad(WINDOW *win, bool bf) return(0); } -int noecho(void) +int32_t noecho(void) { return(0); } -int flushinp(void) +int32_t flushinp(void) { return(0); } -int clearok(WINDOW *win, bool bf) +int32_t clearok(WINDOW *win, bool bf) { return(0); } -int idlok(WINDOW *win, bool bf) +int32_t idlok(WINDOW *win, bool bf) { return(0); } -int leaveok(WINDOW *win, bool bf) +int32_t leaveok(WINDOW *win, bool bf) { return(0); } @@ -384,7 +385,7 @@ int32_t mvwin(WINDOW *win, int32_t y, int32_t x) // stub return(0); } -WINDOW *subwin(WINDOW *orig, int nlines, int ncols, int begin_y, int begin_x) +WINDOW *subwin(WINDOW *orig, int32_t nlines, int32_t ncols, int32_t begin_y, int32_t begin_x) { fprintf(stderr,"unexpected and unsupported call to subwin\n"); return(0); From d908ddc5a5bb97b63a62a8b6da45d3bebdf0ec58 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 02:34:50 -1100 Subject: [PATCH 17/87] +print --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 4d6167b3f..ed69b6bc2 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -459,7 +459,7 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,uint } if ( rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid) == 0 ) { - //fprintf(stderr,"playertxid.%s got vin.%s/v%d gametxid.%s iterate.%d\n",playertxid.ToString().c_str(),playertx.vin[1].prevout.hash.ToString().c_str(),(int32_t)playertx.vin[1].prevout.n-maxplayers,gametxid.ToString().c_str(),rogue_iterateplayer(registertxid,gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid)); + fprintf(stderr,"playertxid.%s got vin.%s/v%d gametxid.%s iterate.%d\n",playertxid.ToString().c_str(),playertx.vin[1].prevout.hash.ToString().c_str(),(int32_t)playertx.vin[1].prevout.n-maxplayers,gametxid.ToString().c_str(),rogue_iterateplayer(registertxid,gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid)); if ( (tokenid != zeroid || playertx.vin[1].prevout.hash == gametxid) && rogue_iterateplayer(registertxid,gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid) == 0 ) { // if registertxid has vin from pk, it can be used From acedc0026123f41a35bfd577f767f8d13e22ce03 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 02:39:36 -1100 Subject: [PATCH 18/87] Dont save from daemon --- src/cc/rogue/save.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/save.c b/src/cc/rogue/save.c index 15dda401e..b1cac8f8f 100644 --- a/src/cc/rogue/save.c +++ b/src/cc/rogue/save.c @@ -148,7 +148,9 @@ void save_file(struct rogue_state *rs,FILE *savef,int32_t guiflag) { char buf[80],fname[512]; int32_t i,n,nonz,histo[0x100]; FILE *fp; - memset(&rs->P,0,sizeof(rs->P)); + if ( rs->guiflag == 0 ) + return; + //memset(&rs->P,0,sizeof(rs->P)); mvcur(0, COLS - 1, LINES - 1, 0); putchar('\n'); endwin(); From dd68e9cdfeac3b0b7ddd838bd008b22d9b0bea8b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 02:49:03 -1100 Subject: [PATCH 19/87] +print --- src/cc/rogue/cursesd.c | 1 + src/cc/rogue_rpc.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/cursesd.c b/src/cc/rogue/cursesd.c index 99274b86f..e504a0ca4 100644 --- a/src/cc/rogue/cursesd.c +++ b/src/cc/rogue/cursesd.c @@ -162,6 +162,7 @@ int32_t mvaddch(int32_t y, int32_t x, chtype ch) int32_t waddstr(WINDOW *win, const char *str) { int32_t i; + fprintf(stderr,"%s\n",str); for (i=0; str[i]!=0; i++) waddch(win,str[i]); return(0); diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index ed69b6bc2..44d42dff8 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -459,7 +459,7 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,uint } if ( rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid) == 0 ) { - fprintf(stderr,"playertxid.%s got vin.%s/v%d gametxid.%s iterate.%d\n",playertxid.ToString().c_str(),playertx.vin[1].prevout.hash.ToString().c_str(),(int32_t)playertx.vin[1].prevout.n-maxplayers,gametxid.ToString().c_str(),rogue_iterateplayer(registertxid,gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid)); + //fprintf(stderr,"playertxid.%s got vin.%s/v%d gametxid.%s iterate.%d\n",playertxid.ToString().c_str(),playertx.vin[1].prevout.hash.ToString().c_str(),(int32_t)playertx.vin[1].prevout.n-maxplayers,gametxid.ToString().c_str(),rogue_iterateplayer(registertxid,gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid)); if ( (tokenid != zeroid || playertx.vin[1].prevout.hash == gametxid) && rogue_iterateplayer(registertxid,gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid) == 0 ) { // if registertxid has vin from pk, it can be used @@ -880,7 +880,7 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) fprintf(stderr,"error writing %s\n",fname); fclose(fp); } - num = rogue_replay2(player,seed,keystrokes,numkeys,playerdata.size()==0?0:&P,50); + num = rogue_replay2(player,seed,keystrokes,numkeys,playerdata.size()==0?0:&P,0); newdata.resize(num); for (i=0; i Date: Sun, 17 Feb 2019 02:53:02 -1100 Subject: [PATCH 20/87] Test --- src/cc/rogue/save.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/cc/rogue/save.c b/src/cc/rogue/save.c index b1cac8f8f..af0ed37b6 100644 --- a/src/cc/rogue/save.c +++ b/src/cc/rogue/save.c @@ -148,19 +148,20 @@ void save_file(struct rogue_state *rs,FILE *savef,int32_t guiflag) { char buf[80],fname[512]; int32_t i,n,nonz,histo[0x100]; FILE *fp; - if ( rs->guiflag == 0 ) - return; - //memset(&rs->P,0,sizeof(rs->P)); - mvcur(0, COLS - 1, LINES - 1, 0); - putchar('\n'); - endwin(); - resetltchars(); - md_chmod(file_name, 0400); - if ( guiflag != 0 ) + if ( rs->guiflag != 0 ) { - encwrite(version, strlen(version)+1, savef); - sprintf(buf,"%d x %d\n", LINES, COLS); - encwrite(buf,80,savef); + //memset(&rs->P,0,sizeof(rs->P)); + mvcur(0, COLS - 1, LINES - 1, 0); + putchar('\n'); + endwin(); + resetltchars(); + md_chmod(file_name, 0400); + if ( guiflag != 0 ) + { + encwrite(version, strlen(version)+1, savef); + sprintf(buf,"%d x %d\n", LINES, COLS); + encwrite(buf,80,savef); + } } rs_save_file(rs,savef); n = sizeof(rs->P) - sizeof(rs->P.roguepack) + sizeof(rs->P.roguepack[0])*rs->P.packsize; From 35eb8d347a2404e15b1187de9a344553fc63df6a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 02:57:06 -1100 Subject: [PATCH 21/87] Test speed --- src/cc/rogue/cursesd.c | 2 +- src/cc/rogue/rogue.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/cursesd.c b/src/cc/rogue/cursesd.c index e504a0ca4..c9785c0d1 100644 --- a/src/cc/rogue/cursesd.c +++ b/src/cc/rogue/cursesd.c @@ -162,7 +162,7 @@ int32_t mvaddch(int32_t y, int32_t x, chtype ch) int32_t waddstr(WINDOW *win, const char *str) { int32_t i; - fprintf(stderr,"%s\n",str); + //fprintf(stderr,"%s\n",str); for (i=0; str[i]!=0; i++) waddch(win,str[i]); return(0); diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index b709e8d3a..ca2926c35 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -252,7 +252,7 @@ int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t nu } uint32_t starttime = (uint32_t)time(NULL); rogueiterate(rs); - if ( 0 ) + if ( 1 ) { fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL) - starttime); sleep(2); From 4d1bfb8c862506993c14329f9fe5ff27b296d075 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 03:03:06 -1100 Subject: [PATCH 22/87] Test --- src/cc/rogue/rogue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index ca2926c35..b709e8d3a 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -252,7 +252,7 @@ int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t nu } uint32_t starttime = (uint32_t)time(NULL); rogueiterate(rs); - if ( 1 ) + if ( 0 ) { fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL) - starttime); sleep(2); From bb03c1d872d6cb3a0174bb7bc8744d72b027938b Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Sun, 17 Feb 2019 06:03:35 -0800 Subject: [PATCH 23/87] Update zeromq to 4.3.1 --- depends/packages/zeromq.mk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/depends/packages/zeromq.mk b/depends/packages/zeromq.mk index b9a57cba7..0cb256e81 100644 --- a/depends/packages/zeromq.mk +++ b/depends/packages/zeromq.mk @@ -14,10 +14,10 @@ define $(package)_set_vars endef else package=zeromq -$(package)_version=4.2.1 -$(package)_download_path=https://github.com/zeromq/libzmq/releases/download/v$($(package)_version) +$(package)_version=4.3.1 +$(package)_download_path=https://github.com/zeromq/libzmq/releases/download/v$($(package)_version)/ $(package)_file_name=$(package)-$($(package)_version).tar.gz -$(package)_sha256_hash=27d1e82a099228ee85a7ddb2260f40830212402c605a4a10b5e5498a7e0e9d03 +$(package)_sha256_hash=bcbabe1e2c7d0eec4ed612e10b94b112dd5f06fcefa994a0c79a45d835cd21eb define $(package)_set_vars $(package)_config_opts=--without-documentation --disable-shared --disable-curve From d16b2dd1bf68d50c69b497b8dda4b0a2fb1d0d05 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 05:56:17 -1100 Subject: [PATCH 24/87] Test --- src/cc/rogue/cursesd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/cursesd.c b/src/cc/rogue/cursesd.c index c9785c0d1..e504a0ca4 100644 --- a/src/cc/rogue/cursesd.c +++ b/src/cc/rogue/cursesd.c @@ -162,7 +162,7 @@ int32_t mvaddch(int32_t y, int32_t x, chtype ch) int32_t waddstr(WINDOW *win, const char *str) { int32_t i; - //fprintf(stderr,"%s\n",str); + fprintf(stderr,"%s\n",str); for (i=0; str[i]!=0; i++) waddch(win,str[i]); return(0); From 9c8ebf3f6279614516e32cbb5ee65c8a92aa2721 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 06:04:59 -1100 Subject: [PATCH 25/87] Flush always --- src/cc/rogue/rogue.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index b709e8d3a..f28d0df29 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -336,7 +336,7 @@ int32_t rogue_replay(uint64_t seed,int32_t sleeptime) } fclose(fp); } - rogue_replay2(0,seed,keystrokes,num,player,150); + rogue_replay2(0,seed,keystrokes,num,player,30); //mvaddstr(LINES - 2, 0, (char *)"replay completed"); endwin(); @@ -601,7 +601,7 @@ playit(struct rogue_state *rs) } else { - if ( rs->needflush != 0 && rs->num > 4096 ) + if ( rs->needflush != 0 )//&& rs->num > 4096 ) { if ( flushkeystrokes(rs) == 0 ) rs->needflush = 0; From e5865055252d9c5683e99de8d1bb81afd9f13052 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 06:18:52 -1100 Subject: [PATCH 26/87] +proint --- src/cc/rogue/state.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c index e738a9d16..8b312ae5f 100644 --- a/src/cc/rogue/state.c +++ b/src/cc/rogue/state.c @@ -1434,7 +1434,7 @@ rs_write_object(struct rogue_state *rs,FILE *savef, THING *o) item = &rs->P.roguepack[rs->P.packsize]; if ( pstats.s_hpt <= 0 ) { - //fprintf(stderr,"KILLED\n"); + fprintf(stderr,"KILLED\n"); rs->P.gold = -1; rs->P.hitpoints = -1; rs->P.strength = -1; @@ -1452,9 +1452,9 @@ rs_write_object(struct rogue_state *rs,FILE *savef, THING *o) rs->P.level = pstats.s_lvl; rs->P.experience = pstats.s_exp; rs->P.dungeonlevel = level; - //fprintf(stderr,"%ld gold.%d hp.%d strength.%d level.%d exp.%d %d\n",ftell(savef),purse,max_hp,max_stats.s_str,pstats.s_lvl,pstats.s_exp,level); + fprintf(stderr,"%ld gold.%d hp.%d strength.%d level.%d exp.%d %d\n",ftell(savef),purse,max_hp,max_stats.s_str,pstats.s_lvl,pstats.s_exp,level); } - //fprintf(stderr,"object (%s) x.%d y.%d type.%d pack.(%c:%d)\n",inv_name(o,FALSE),o->_o._o_pos.x,o->_o._o_pos.y,o->_o._o_type,o->_o._o_packch,o->_o._o_packch); + fprintf(stderr,"object (%s) x.%d y.%d type.%d pack.(%c:%d)\n",inv_name(o,FALSE),o->_o._o_pos.x,o->_o._o_pos.y,o->_o._o_type,o->_o._o_packch,o->_o._o_packch); if ( rs->P.packsize < MAXPACK && o->o_type != AMULET ) { packsave(item,o->_o._o_type,o->_o._o_launch,o->_o._o_damage,sizeof(o->_o._o_damage),o->_o._o_hurldmg,sizeof(o->_o._o_hurldmg),o->_o._o_count,o->_o._o_which,o->_o._o_hplus,o->_o._o_dplus,o->_o._o_arm,o->_o._o_flags,o->_o._o_group); @@ -2009,7 +2009,10 @@ int rs_save_file(struct rogue_state *rs,FILE *savef) { if (write_error) + { + fprintf(stderr,"write error\n"); return(WRITESTAT); + } rs_write_boolean(savef, after); /* 1 */ /* extern.c */ rs_write_boolean(savef, again); /* 2 */ From 9cec68f8c49833a6143eabf2a9b58858847321f1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 06:25:24 -1100 Subject: [PATCH 27/87] +prints --- src/cc/rogue/rogue.c | 1 + src/cc/rogue/rogue.h | 4 ++-- src/cc/rogue/save.c | 8 +++++--- src/cc/rogue/state.c | 3 ++- src/cc/rogue_rpc.cpp | 1 + 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index f28d0df29..2fd50607a 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -273,6 +273,7 @@ int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t nu if ( (fp= fopen("checkfile","wb")) != 0 ) { save_file(rs,fp,0); + fprintf(stderr,"gold.%d hp.%d strength.%d level.%d exp.%d dungeon.%d data[%d]\n",rs->P.gold,rs->P.hitpoints,rs->P.strength,rs->P.level,rs->P.experience,rs->P.dungeonlevel,rs->playersize); if ( newdata != 0 && rs->playersize > 0 ) memcpy(newdata,rs->playerdata,rs->playersize); } diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index a5ddf943f..20f32c6f2 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -358,7 +358,7 @@ typedef union _bits256 bits256; #endif -#ifndef ROGUE_DECLARED_PACK +/*#ifndef ROGUE_DECLARED_PACK struct rogue_packitem { int32_t type,launch,count,which,hplus,dplus,arm,flags,group; @@ -369,7 +369,7 @@ struct rogue_player int32_t gold,hitpoints,strength,level,experience,packsize,dungeonlevel,pad; struct rogue_packitem roguepack[MAXPACK]; }; -#define ROGUE_DECLARED_PACK +#define ROGUE_DECLARED_PACK*/ #endif struct rogue_state diff --git a/src/cc/rogue/save.c b/src/cc/rogue/save.c index af0ed37b6..0496eaa73 100644 --- a/src/cc/rogue/save.c +++ b/src/cc/rogue/save.c @@ -150,7 +150,6 @@ save_file(struct rogue_state *rs,FILE *savef,int32_t guiflag) char buf[80],fname[512]; int32_t i,n,nonz,histo[0x100]; FILE *fp; if ( rs->guiflag != 0 ) { - //memset(&rs->P,0,sizeof(rs->P)); mvcur(0, COLS - 1, LINES - 1, 0); putchar('\n'); endwin(); @@ -163,7 +162,10 @@ save_file(struct rogue_state *rs,FILE *savef,int32_t guiflag) encwrite(buf,80,savef); } } - rs_save_file(rs,savef); + memset(&rs->P,0,sizeof(rs->P)); + rs_save_file(rs,savef); // sets rs->P + fprintf(stderr,"gold.%d hp.%d strength.%d level.%d exp.%d %d\n",rs->P.gold,rs->P.hitpoints,rs->P.strength,rs->P.level,rs->P.experience,rs->P.dungeonlevel); + n = sizeof(rs->P) - sizeof(rs->P.roguepack) + sizeof(rs->P.roguepack[0])*rs->P.packsize; memset(histo,0,sizeof(histo)); for (i=0; iplayerdata[i] = ((uint8_t *)&rs->P)[i]; } rs->playersize = n; - //fprintf(stderr," packsize.%d n.%d\n",rs->P.packsize,n); + fprintf(stderr," packsize.%d playersize.%d\n",rs->P.packsize,n); if ( (fp= fopen(rogue_packfname(rs,fname),"wb")) != 0 ) { fwrite(&rs->P,1,n,fp); diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c index 8b312ae5f..d1ceaaa2f 100644 --- a/src/cc/rogue/state.c +++ b/src/cc/rogue/state.c @@ -1452,7 +1452,7 @@ rs_write_object(struct rogue_state *rs,FILE *savef, THING *o) rs->P.level = pstats.s_lvl; rs->P.experience = pstats.s_exp; rs->P.dungeonlevel = level; - fprintf(stderr,"%ld gold.%d hp.%d strength.%d level.%d exp.%d %d\n",ftell(savef),purse,max_hp,max_stats.s_str,pstats.s_lvl,pstats.s_exp,level); + fprintf(stderr,"%ld gold.%d hp.%d strength.%d level.%d exp.%d %d\n",ftell(savef),purse,max_hp,pstats.s_str,pstats.s_lvl,pstats.s_exp,level); } fprintf(stderr,"object (%s) x.%d y.%d type.%d pack.(%c:%d)\n",inv_name(o,FALSE),o->_o._o_pos.x,o->_o._o_pos.y,o->_o._o_type,o->_o._o_packch,o->_o._o_packch); if ( rs->P.packsize < MAXPACK && o->o_type != AMULET ) @@ -1460,6 +1460,7 @@ rs_write_object(struct rogue_state *rs,FILE *savef, THING *o) packsave(item,o->_o._o_type,o->_o._o_launch,o->_o._o_damage,sizeof(o->_o._o_damage),o->_o._o_hurldmg,sizeof(o->_o._o_hurldmg),o->_o._o_count,o->_o._o_which,o->_o._o_hplus,o->_o._o_dplus,o->_o._o_arm,o->_o._o_flags,o->_o._o_group); rs->P.packsize++; } + fprintf(stderr,"%ld gold.%d hp.%d strength.%d level.%d exp.%d %d\n",ftell(savef),purse,max_hp,pstats.s_str,pstats.s_lvl,pstats.s_exp,level); } } rs_write_marker(savef, RSID_OBJECT); diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 44d42dff8..7b26ff572 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -23,6 +23,7 @@ #define ROGUE_MAXKEYSTROKESGAP 60 #define ROGUE_MAXITERATIONS 777 + #define MAXPACK 23 struct rogue_packitem { From 2ee3594c1b0da6c8596be7f7f37d5afd0e422ec4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 06:27:05 -1100 Subject: [PATCH 28/87] Test --- src/cc/rogue/rogue.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index 20f32c6f2..a5ddf943f 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -358,7 +358,7 @@ typedef union _bits256 bits256; #endif -/*#ifndef ROGUE_DECLARED_PACK +#ifndef ROGUE_DECLARED_PACK struct rogue_packitem { int32_t type,launch,count,which,hplus,dplus,arm,flags,group; @@ -369,7 +369,7 @@ struct rogue_player int32_t gold,hitpoints,strength,level,experience,packsize,dungeonlevel,pad; struct rogue_packitem roguepack[MAXPACK]; }; -#define ROGUE_DECLARED_PACK*/ +#define ROGUE_DECLARED_PACK #endif struct rogue_state From fa7ad1f44bbc418ac2644f589844fb1f329af368 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 06:32:17 -1100 Subject: [PATCH 29/87] Test --- src/cc/rogue/cursesd.c | 2 +- src/cc/rogue/save.c | 4 ++-- src/cc/rogue/state.c | 7 +++---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/cc/rogue/cursesd.c b/src/cc/rogue/cursesd.c index e504a0ca4..c9785c0d1 100644 --- a/src/cc/rogue/cursesd.c +++ b/src/cc/rogue/cursesd.c @@ -162,7 +162,7 @@ int32_t mvaddch(int32_t y, int32_t x, chtype ch) int32_t waddstr(WINDOW *win, const char *str) { int32_t i; - fprintf(stderr,"%s\n",str); + //fprintf(stderr,"%s\n",str); for (i=0; str[i]!=0; i++) waddch(win,str[i]); return(0); diff --git a/src/cc/rogue/save.c b/src/cc/rogue/save.c index 0496eaa73..4df79e150 100644 --- a/src/cc/rogue/save.c +++ b/src/cc/rogue/save.c @@ -164,7 +164,7 @@ save_file(struct rogue_state *rs,FILE *savef,int32_t guiflag) } memset(&rs->P,0,sizeof(rs->P)); rs_save_file(rs,savef); // sets rs->P - fprintf(stderr,"gold.%d hp.%d strength.%d level.%d exp.%d %d\n",rs->P.gold,rs->P.hitpoints,rs->P.strength,rs->P.level,rs->P.experience,rs->P.dungeonlevel); + //fprintf(stderr,"gold.%d hp.%d strength.%d level.%d exp.%d %d\n",rs->P.gold,rs->P.hitpoints,rs->P.strength,rs->P.level,rs->P.experience,rs->P.dungeonlevel); n = sizeof(rs->P) - sizeof(rs->P.roguepack) + sizeof(rs->P.roguepack[0])*rs->P.packsize; memset(histo,0,sizeof(histo)); @@ -175,7 +175,7 @@ save_file(struct rogue_state *rs,FILE *savef,int32_t guiflag) rs->playerdata[i] = ((uint8_t *)&rs->P)[i]; } rs->playersize = n; - fprintf(stderr," packsize.%d playersize.%d\n",rs->P.packsize,n); + //fprintf(stderr," packsize.%d playersize.%d\n",rs->P.packsize,n); if ( (fp= fopen(rogue_packfname(rs,fname),"wb")) != 0 ) { fwrite(&rs->P,1,n,fp); diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c index d1ceaaa2f..800622444 100644 --- a/src/cc/rogue/state.c +++ b/src/cc/rogue/state.c @@ -1434,7 +1434,7 @@ rs_write_object(struct rogue_state *rs,FILE *savef, THING *o) item = &rs->P.roguepack[rs->P.packsize]; if ( pstats.s_hpt <= 0 ) { - fprintf(stderr,"KILLED\n"); + //fprintf(stderr,"KILLED\n"); rs->P.gold = -1; rs->P.hitpoints = -1; rs->P.strength = -1; @@ -1452,15 +1452,14 @@ rs_write_object(struct rogue_state *rs,FILE *savef, THING *o) rs->P.level = pstats.s_lvl; rs->P.experience = pstats.s_exp; rs->P.dungeonlevel = level; - fprintf(stderr,"%ld gold.%d hp.%d strength.%d level.%d exp.%d %d\n",ftell(savef),purse,max_hp,pstats.s_str,pstats.s_lvl,pstats.s_exp,level); + //fprintf(stderr,"%ld gold.%d hp.%d strength.%d level.%d exp.%d %d\n",ftell(savef),purse,max_hp,pstats.s_str,pstats.s_lvl,pstats.s_exp,level); } - fprintf(stderr,"object (%s) x.%d y.%d type.%d pack.(%c:%d)\n",inv_name(o,FALSE),o->_o._o_pos.x,o->_o._o_pos.y,o->_o._o_type,o->_o._o_packch,o->_o._o_packch); + //fprintf(stderr,"object (%s) x.%d y.%d type.%d pack.(%c:%d)\n",inv_name(o,FALSE),o->_o._o_pos.x,o->_o._o_pos.y,o->_o._o_type,o->_o._o_packch,o->_o._o_packch); if ( rs->P.packsize < MAXPACK && o->o_type != AMULET ) { packsave(item,o->_o._o_type,o->_o._o_launch,o->_o._o_damage,sizeof(o->_o._o_damage),o->_o._o_hurldmg,sizeof(o->_o._o_hurldmg),o->_o._o_count,o->_o._o_which,o->_o._o_hplus,o->_o._o_dplus,o->_o._o_arm,o->_o._o_flags,o->_o._o_group); rs->P.packsize++; } - fprintf(stderr,"%ld gold.%d hp.%d strength.%d level.%d exp.%d %d\n",ftell(savef),purse,max_hp,pstats.s_str,pstats.s_lvl,pstats.s_exp,level); } } rs_write_marker(savef, RSID_OBJECT); From 64d18650222bff6079d0f8e1ddd36224225d7a60 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 06:34:57 -1100 Subject: [PATCH 30/87] rogue_player.h --- src/cc/rogue/rogue.h | 15 +-------------- src/cc/rogue/rogue_player.h | 35 +++++++++++++++++++++++++++++++++++ src/cc/rogue_rpc.cpp | 17 +---------------- 3 files changed, 37 insertions(+), 30 deletions(-) create mode 100644 src/cc/rogue/rogue_player.h diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index a5ddf943f..905a5ed36 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -357,20 +357,7 @@ union _bits256 { uint8_t bytes[32]; uint16_t ushorts[16]; uint32_t uints[8]; uin typedef union _bits256 bits256; #endif - -#ifndef ROGUE_DECLARED_PACK -struct rogue_packitem -{ - int32_t type,launch,count,which,hplus,dplus,arm,flags,group; - char damage[8],hurldmg[8]; -}; -struct rogue_player -{ - int32_t gold,hitpoints,strength,level,experience,packsize,dungeonlevel,pad; - struct rogue_packitem roguepack[MAXPACK]; -}; -#define ROGUE_DECLARED_PACK -#endif +#include "rogue_player.h" // interface to rpc struct rogue_state { diff --git a/src/cc/rogue/rogue_player.h b/src/cc/rogue/rogue_player.h new file mode 100644 index 000000000..1319b3213 --- /dev/null +++ b/src/cc/rogue/rogue_player.h @@ -0,0 +1,35 @@ +/****************************************************************************** + * Copyright © 2014-2019 The SuperNET Developers. * + * * + * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * + * the top-level directory of this distribution for the individual copyright * + * holder information and the developer policies on copyright and licensing. * + * * + * Unless otherwise agreed in a custom licensing agreement, no part of the * + * SuperNET software, including this file may be copied, modified, propagated * + * or distributed except according to the terms contained in the LICENSE file * + * * + * Removal or modification of this copyright notice is prohibited. * + * * + ******************************************************************************/ + +#ifndef ROGUE_DECLARED_PACK +#define ROGUE_DECLARED_PACK + + +#define MAXPACK 23 +struct rogue_packitem +{ + int32_t type,launch,count,which,hplus,dplus,arm,flags,group; + char damage[8],hurldmg[8]; +}; +struct rogue_player +{ + int32_t gold,hitpoints,strength,level,experience,packsize,dungeonlevel,pad; + struct rogue_packitem roguepack[MAXPACK]; +}; +int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player,int32_t sleepmillis); +void rogue_packitemstr(char *packitemstr,struct rogue_packitem *item); + +#endif + diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 7b26ff572..253f3ec89 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -23,22 +23,7 @@ #define ROGUE_MAXKEYSTROKESGAP 60 #define ROGUE_MAXITERATIONS 777 - -#define MAXPACK 23 -struct rogue_packitem -{ - int32_t type,launch,count,which,hplus,dplus,arm,flags,group; - char damage[8],hurldmg[8]; -}; -struct rogue_player -{ - int32_t gold,hitpoints,strength,level,experience,packsize,dungeonlevel,pad; - struct rogue_packitem roguepack[MAXPACK]; -}; -int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player,int32_t sleepmillis); -#define ROGUE_DECLARED_PACK -void rogue_packitemstr(char *packitemstr,struct rogue_packitem *item); - +#include "rogue/rogueplayer.h" std::string Rogue_pname = ""; From 0d022d48145c19964ea5889138934b824c2937f6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 06:35:36 -1100 Subject: [PATCH 31/87] _ --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 253f3ec89..e297f6a27 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -23,7 +23,7 @@ #define ROGUE_MAXKEYSTROKESGAP 60 #define ROGUE_MAXITERATIONS 777 -#include "rogue/rogueplayer.h" +#include "rogue/rogue_player.h" std::string Rogue_pname = ""; From 82a43da6ec36fceefce05a21872cd64d447e5680 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 07:17:08 -1100 Subject: [PATCH 32/87] Print extracted string --- src/cc/rogue_rpc.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index e297f6a27..032a99ea9 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -720,7 +720,7 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) playertxid = juint256(jitem(params,1)); if ( rogue_playerdata(cp,origplayergame,tokenid,pk,playerdata,symbol,pname,playertxid) < 0 ) return(cclib_error(result,"couldnt extract valid playerdata")); - if ( tokenid != zeroid ) + if ( tokenid != zeroid ) // if it is tokentransfer this will be 0 vout = 1; } rogue_univalue(result,0,maxplayers,buyin); @@ -814,7 +814,7 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result; CPubKey pk,roguepk; int32_t i,n,num,maxplayers,gameheight,batonht,batonvout,numplayers,regslot,numkeys,err; std::string symbol,pname; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue; char rogueaddr[64],fname[64],*pubstr,*keystrokes = 0; std::vector playerdata,newdata; uint256 batontxid,playertxid,gametxid; FILE *fp; uint8_t player[10000],pub33[33]; + UniValue result; CPubKey pk,roguepk; int32_t i,n,num,maxplayers,gameheight,batonht,batonvout,numplayers,regslot,numkeys,err; std::string symbol,pname; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue; char rogueaddr[64],fname[64],str[512],*pubstr,*keystrokes = 0; std::vector playerdata,newdata; uint256 batontxid,playertxid,gametxid; FILE *fp; uint8_t player[10000],pub33[33]; pk = pubkey2pk(Mypubkey()); roguepk = GetUnspendable(cp,0); result.push_back(Pair("status","success")); @@ -878,7 +878,8 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) fprintf(stderr,"zero value character was killed -> no playerdata\n"); newdata.resize(0); } - fprintf(stderr,"\nextracted $$$gold.%d hp.%d strength.%d level.%d exp.%d dl.%d n.%d size.%d\n",P.gold,P.hitpoints,P.strength,P.level,P.experience,P.dungeonlevel,n,(int32_t)sizeof(P)); + sprintf(str,"\nextracted $$$gold.%d hp.%d strength.%d level.%d exp.%d dl.%d n.%d size.%d\n",P.gold,P.hitpoints,P.strength,P.level,P.experience,P.dungeonlevel,n,(int32_t)sizeof(P)); + result.push_back(Pair("extracted",str)); if ( keystrokes != 0 ) free(keystrokes); } else num = 0; From 72e86ef16ef542b2e754aafd4011cf661d24166d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 07:23:10 -1100 Subject: [PATCH 33/87] Test --- src/cc/rogue_rpc.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 032a99ea9..25b279f61 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -812,6 +812,8 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } else return(cclib_error(result,"couldnt reparse params")); } +// change to subfunction without JSON to be used by other functions + UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result; CPubKey pk,roguepk; int32_t i,n,num,maxplayers,gameheight,batonht,batonvout,numplayers,regslot,numkeys,err; std::string symbol,pname; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue; char rogueaddr[64],fname[64],str[512],*pubstr,*keystrokes = 0; std::vector playerdata,newdata; uint256 batontxid,playertxid,gametxid; FILE *fp; uint8_t player[10000],pub33[33]; @@ -878,8 +880,9 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) fprintf(stderr,"zero value character was killed -> no playerdata\n"); newdata.resize(0); } - sprintf(str,"\nextracted $$$gold.%d hp.%d strength.%d level.%d exp.%d dl.%d n.%d size.%d\n",P.gold,P.hitpoints,P.strength,P.level,P.experience,P.dungeonlevel,n,(int32_t)sizeof(P)); + sprintf(str,"extracted $$$gold.%d hp.%d strength.%d level.%d exp.%d dl.%d n.%d size.%d\n",P.gold,P.hitpoints,P.strength,P.level,P.experience,P.dungeonlevel,n,(int32_t)sizeof(P)); result.push_back(Pair("extracted",str)); + fprintf(stderr,"%s\n",str); if ( keystrokes != 0 ) free(keystrokes); } else num = 0; From b95214f57e411a114322b251b17822be4c81de61 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 07:43:08 -1100 Subject: [PATCH 34/87] - -lncurses --- src/Makefile.am | 4 ++-- src/cc/rogue_rpc.cpp | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 1881f0a90..53331ee8f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -574,9 +574,9 @@ komodod_LDADD += \ $(LIBZCASH_LIBS) if TARGET_DARWIN -komodod_LDADD += libcc.dylib -lncurses +komodod_LDADD += libcc.dylib # -lncurses else -komodod_LDADD += libcc.so -lncurses +komodod_LDADD += libcc.so # -lncurses endif diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 25b279f61..3ad5766a9 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -120,9 +120,9 @@ std::string Rogue_pname = ""; */ // todo: -// verify keystrokes tx is in mempool and confirmed -// chaining when mempool tx sometimes infinite loops? -// bailout stealing, is it possible? +// add some more conditions to multiplayer +// change rogue_extract to subfunction without JSON to be used by other functions +// how does it work with playertxid instead of pubkey //////////////////////// start of CClib interface //./komodod -ac_name=ROGUE -ac_supply=1000000 -pubkey=03951a6f7967ad784453116bc55cd30c54f91ea8a5b1e9b04d6b29cfd6b395ba6c -addnode=5.9.102.210 -ac_cclib=rogue -ac_perc=10000000 -ac_reward=100000000 -ac_cc=60001 -ac_script=2ea22c80203d1579313abe7d8ea85f48c65ea66fc512c878c0d0e6f6d54036669de940febf8103120c008203000401cc > /dev/null & @@ -812,8 +812,6 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } else return(cclib_error(result,"couldnt reparse params")); } -// change to subfunction without JSON to be used by other functions - UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result; CPubKey pk,roguepk; int32_t i,n,num,maxplayers,gameheight,batonht,batonvout,numplayers,regslot,numkeys,err; std::string symbol,pname; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue; char rogueaddr[64],fname[64],str[512],*pubstr,*keystrokes = 0; std::vector playerdata,newdata; uint256 batontxid,playertxid,gametxid; FILE *fp; uint8_t player[10000],pub33[33]; From d41134cb97a1e00d0b81586eda74df5f8a0f7836 Mon Sep 17 00:00:00 2001 From: dimxy Date: Mon, 18 Feb 2019 00:03:48 +0500 Subject: [PATCH 35/87] token marker moved to vout tokeninfo validates vouts --- src/cc/CCtokens.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index e5b9eeb78..d5fffdf5b 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -907,10 +907,12 @@ std::string CreateToken(int64_t txfee, int64_t tokensupply, std::string name, st if( nonfungibleData.size() > 0 ) destEvalCode = nonfungibleData.begin()[0]; + // NOTE: we should prevent spending fake-tokens from this marker in IsTokenvout(): + mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, txfee, GetUnspendable(cp, NULL))); // new marker to token cc addr, burnable and validated, vout pos now changed to 0 (from 1) mtx.vout.push_back(MakeTokensCC1vout(destEvalCode, tokensupply, mypk)); //mtx.vout.push_back(CTxOut(txfee, CScript() << ParseHex(cp->CChexstr) << OP_CHECKSIG)); // old marker (non-burnable because spending could not be validated) - // NOTE: we should prevent spending fake-tokens from this marker in IsTokenvout(): - mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, txfee, GetUnspendable(cp, NULL))); // new marker to token cc addr, burnable and validated, this vout must be=1 + //mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, txfee, GetUnspendable(cp, NULL))); // ...moved to vout=0 for matching with rogue-game token + return(FinalizeCCTx(0, cp, mtx, mypk, txfee, EncodeTokenCreateOpRet('c', Mypubkey(), name, description, nonfungibleData))); } @@ -1007,8 +1009,11 @@ UniValue TokenInfo(uint256 tokenid) std::vector origpubkey; std::vector vopretNonfungible; std::string name, description; + struct CCcontract_info *cpTokens, tokensCCinfo; - if (GetTransaction(tokenid, vintx, hashBlock, false) == 0) + cpTokens = CCinit(&tokensCCinfo, EVAL_TOKENS); + + if( !GetTransaction(tokenid, vintx, hashBlock, false) ) { fprintf(stderr, "TokenInfo() cant find tokenid\n"); result.push_back(Pair("result", "error")); @@ -1020,17 +1025,23 @@ UniValue TokenInfo(uint256 tokenid) LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "TokenInfo() passed tokenid isnt token creation txid" << std::endl); result.push_back(Pair("result", "error")); result.push_back(Pair("error", "tokenid isnt token creation txid")); + return result; } result.push_back(Pair("result", "success")); result.push_back(Pair("tokenid", tokenid.GetHex())); result.push_back(Pair("owner", HexStr(origpubkey))); result.push_back(Pair("name", name)); - result.push_back(Pair("supply", vintx.vout[0].nValue)); + + int64_t supply = 0, output; + for (int v = 0; v < vintx.vout.size() - 1; v++) + if ((output = IsTokensvout(false, true, cpTokens, NULL, vintx, v, tokenid)) > 0) + supply += output; + result.push_back(Pair("supply", supply)); result.push_back(Pair("description", description)); if( !vopretNonfungible.empty() ) result.push_back(Pair("data", HexStr(vopretNonfungible))); - return(result); + return result; } UniValue TokenList() From 2fc487d21339eeb8ba17a3022893bcffab06986e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 08:10:40 -1100 Subject: [PATCH 36/87] Fix undefined --- src/cc/rogue/cursesd.c | 2 +- src/cc/rogue/mdport.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue/cursesd.c b/src/cc/rogue/cursesd.c index c9785c0d1..02a80c470 100644 --- a/src/cc/rogue/cursesd.c +++ b/src/cc/rogue/cursesd.c @@ -16,7 +16,7 @@ #include "cursesd.h" static int32_t endwinflag; -WINDOW *stdscr; +WINDOW *stdscr,*curscr; int32_t ESCDELAY; WINDOW *newwin(int32_t nlines,int32_t ncols,int32_t begin_y,int32_t begin_x) diff --git a/src/cc/rogue/mdport.c b/src/cc/rogue/mdport.c index 841dffbb8..d72c4097a 100644 --- a/src/cc/rogue/mdport.c +++ b/src/cc/rogue/mdport.c @@ -263,12 +263,12 @@ int md_hasclreol() { #if defined(clr_eol) -#ifdef NCURSES_VERSION +/*#ifdef NCURSES_VERSION if (cur_term == NULL) return(0); //if (cur_term->type.Strings == NULL) return(0); -#endif +#endif*/ return((clr_eol != NULL) && (*clr_eol != 0)); #elif defined(__PDCURSES__) return(TRUE); From 54c7943a38b43b37acd2f7fafa2a33a58a47d99c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 08:16:52 -1100 Subject: [PATCH 37/87] Return 0 --- src/cc/rogue/mdport.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue/mdport.c b/src/cc/rogue/mdport.c index d72c4097a..9d6c7d2c6 100644 --- a/src/cc/rogue/mdport.c +++ b/src/cc/rogue/mdport.c @@ -262,19 +262,20 @@ md_onsignal_autosave() int md_hasclreol() { -#if defined(clr_eol) -/*#ifdef NCURSES_VERSION +/*#if defined(clr_eol) +#ifdef NCURSES_VERSION if (cur_term == NULL) return(0); //if (cur_term->type.Strings == NULL) return(0); -#endif*/ +#endif return((clr_eol != NULL) && (*clr_eol != 0)); #elif defined(__PDCURSES__) return(TRUE); #else return((CE != NULL) && (*CE != 0)); -#endif +#endif*/ + return(0); } void From f641b7c31d6603e597d8c3217d1b383ea3fb3edc Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 08:56:48 -1100 Subject: [PATCH 38/87] Guard null name --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 3ad5766a9..309602c2c 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -389,7 +389,7 @@ UniValue rogue_playerobj(std::vector playerdata,uint256 playertxid,uint obj.push_back(Pair("experience",(int64_t)P.experience)); obj.push_back(Pair("dungeonlevel",(int64_t)P.dungeonlevel)); obj.push_back(Pair("chain",symbol)); - obj.push_back(Pair("pname",pname)); + obj.push_back(Pair("pname",pname.size() > 0 ? pname : "noname")); return(obj); } From 9fda3717842d971cbf444e2fa3114449da7c9869 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 09:00:14 -1100 Subject: [PATCH 39/87] Test --- src/cc/rogue_rpc.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 309602c2c..c9d873656 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -388,8 +388,10 @@ UniValue rogue_playerobj(std::vector playerdata,uint256 playertxid,uint obj.push_back(Pair("level",(int64_t)P.level)); obj.push_back(Pair("experience",(int64_t)P.experience)); obj.push_back(Pair("dungeonlevel",(int64_t)P.dungeonlevel)); - obj.push_back(Pair("chain",symbol)); - obj.push_back(Pair("pname",pname.size() > 0 ? pname : "noname")); + if ( symbol.c_str() != 0 ) + obj.push_back(Pair("chain",symbol.c_str())); + if ( pname.c_str() != 0 ) + obj.push_back(Pair("pname",pname._cstr())); return(obj); } From 5fd1874cb363d14383c88d4ad3a4af2568857590 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 09:00:51 -1100 Subject: [PATCH 40/87] Test --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index c9d873656..1db0d51f1 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -391,7 +391,7 @@ UniValue rogue_playerobj(std::vector playerdata,uint256 playertxid,uint if ( symbol.c_str() != 0 ) obj.push_back(Pair("chain",symbol.c_str())); if ( pname.c_str() != 0 ) - obj.push_back(Pair("pname",pname._cstr())); + obj.push_back(Pair("pname",pname.c_str())); return(obj); } From 73fa543afa9495de92b250655def5c3613620134 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 09:04:16 -1100 Subject: [PATCH 41/87] Test --- src/cc/rogue_rpc.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 1db0d51f1..41e40edb4 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -357,7 +357,7 @@ int32_t rogue_isvalidgame(struct CCcontract_info *cp,int32_t &gameheight,CTransa UniValue rogue_playerobj(std::vector playerdata,uint256 playertxid,uint256 tokenid,std::string symbol,std::string pname) { - int32_t i; struct rogue_player P; char packitemstr[512],*datastr; UniValue obj(UniValue::VOBJ),a(UniValue::VARR); + int32_t i; struct rogue_player P; char packitemstr[512],*datastr=0; UniValue obj(UniValue::VOBJ),a(UniValue::VARR); memset(&P,0,sizeof(P)); if ( playerdata.size() > 0 ) { @@ -379,8 +379,11 @@ UniValue rogue_playerobj(std::vector playerdata,uint256 playertxid,uint if ( tokenid != zeroid ) obj.push_back(Pair("tokenid",tokenid.GetHex())); else obj.push_back(Pair("tokenid",playertxid.GetHex())); - obj.push_back(Pair("data",datastr)); - free(datastr); + if ( datastr != 0 ) + { + obj.push_back(Pair("data",datastr)); + free(datastr); + } obj.push_back(Pair("pack",a)); obj.push_back(Pair("packsize",(int64_t)P.packsize)); obj.push_back(Pair("hitpoints",(int64_t)P.hitpoints)); @@ -388,10 +391,8 @@ UniValue rogue_playerobj(std::vector playerdata,uint256 playertxid,uint obj.push_back(Pair("level",(int64_t)P.level)); obj.push_back(Pair("experience",(int64_t)P.experience)); obj.push_back(Pair("dungeonlevel",(int64_t)P.dungeonlevel)); - if ( symbol.c_str() != 0 ) - obj.push_back(Pair("chain",symbol.c_str())); - if ( pname.c_str() != 0 ) - obj.push_back(Pair("pname",pname.c_str())); + obj.push_back(Pair("chain",symbol)); + obj.push_back(Pair("pname",pname)); return(obj); } From 88fa8f223315f802c93cdf0025a09ad95d5204d9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 09:09:52 -1100 Subject: [PATCH 42/87] Test --- src/cc/rogue_rpc.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 41e40edb4..1e6d3111d 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -798,8 +798,11 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param GetCCaddress1of2(cp,destaddr,roguepk,mypk); if ( rogue_isvalidgame(cp,gameheight,tx,buyin,maxplayers,gametxid) == 0 ) { + result.push_back(Pair("gametxid",gametxid.GetHex())); if ( rogue_findbaton(cp,playertxid,0,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,tx,maxplayers,destaddr,numplayers,symbol,pname) == 0 ) { + result.push_back(Pair("batontxid",batontxid.GetHex())); + result.push_back(Pair("playertxid",playertxid.GetHex())); if ( maxplayers == 1 || nextheight <= batonht+ROGUE_MAXKEYSTROKESGAP ) { mtx.vin.push_back(CTxIn(batontxid,batonvout,CScript())); From 8a9687d2550cd1f46bb707fd2f23683a8a9ca0e6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 09:12:08 -1100 Subject: [PATCH 43/87] Dont keystrokes tx more than once per 1024 --- src/cc/rogue/rogue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 2fd50607a..01c8b1873 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -602,7 +602,7 @@ playit(struct rogue_state *rs) } else { - if ( rs->needflush != 0 )//&& rs->num > 4096 ) + if ( rs->needflush != 0 && rs->num > 1024 ) { if ( flushkeystrokes(rs) == 0 ) rs->needflush = 0; From 5391c8ca87f3c5ff564c58ef31ec210fbdb383e3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 09:28:54 -1100 Subject: [PATCH 44/87] Keystrokesstr --- src/cc/rogue_rpc.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 1e6d3111d..4fec21b5a 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -123,6 +123,7 @@ std::string Rogue_pname = ""; // add some more conditions to multiplayer // change rogue_extract to subfunction without JSON to be used by other functions // how does it work with playertxid instead of pubkey +// keystrokes retry //////////////////////// start of CClib interface //./komodod -ac_name=ROGUE -ac_supply=1000000 -pubkey=03951a6f7967ad784453116bc55cd30c54f91ea8a5b1e9b04d6b29cfd6b395ba6c -addnode=5.9.102.210 -ac_cclib=rogue -ac_perc=10000000 -ac_reward=100000000 -ac_cc=60001 -ac_script=2ea22c80203d1579313abe7d8ea85f48c65ea66fc512c878c0d0e6f6d54036669de940febf8103120c008203000401cc > /dev/null & @@ -792,13 +793,14 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param if ( (params= cclib_reparse(&n,params)) != 0 && n == 2 && (keystrokestr= jstr(jitem(params,1),0)) != 0 ) { gametxid = juint256(jitem(params,0)); + result.push_back(Pair("gametxid",gametxid.GetHex())); + result.push_back(Pair("keystrokes",keystrokestr)); keystrokes = ParseHex(keystrokestr); mypk = pubkey2pk(Mypubkey()); roguepk = GetUnspendable(cp,0); GetCCaddress1of2(cp,destaddr,roguepk,mypk); if ( rogue_isvalidgame(cp,gameheight,tx,buyin,maxplayers,gametxid) == 0 ) { - result.push_back(Pair("gametxid",gametxid.GetHex())); if ( rogue_findbaton(cp,playertxid,0,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,tx,maxplayers,destaddr,numplayers,symbol,pname) == 0 ) { result.push_back(Pair("batontxid",batontxid.GetHex())); From 6de80465b5dea552ac478a9162db961774d7726d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 20:06:22 -1100 Subject: [PATCH 45/87] Extract game function --- src/cc/rogue_rpc.cpp | 116 ++++++++++++++++++++++++------------------- 1 file changed, 66 insertions(+), 50 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 4fec21b5a..54aad1326 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -121,7 +121,6 @@ std::string Rogue_pname = ""; // todo: // add some more conditions to multiplayer -// change rogue_extract to subfunction without JSON to be used by other functions // how does it work with playertxid instead of pubkey // keystrokes retry @@ -820,12 +819,67 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } else return(cclib_error(result,"couldnt reparse params")); } +char *rogue_extractgame(char *str,int32_t *numkeysp,struct rogue_player &P,std::vector &newdata,struct rogue_player &endP,int64_t &seed,struct CCcontract_info *cp,uint256 gametxid,char *rogueaddr) +{ + CPubKey roguepk; int32_t i,num,maxplayers,gameheight,batonht,batonvout,numplayers,regslot,numkeys,err; std::string symbol,pname; CTransaction gametx; int64_t buyin,batonvalue; char fname[64],*keystrokes = 0; std::vector playerdata; uint256 batontxid,playertxid; FILE *fp; uint8_t newplayer[10000]; + roguepk = GetUnspendable(cp,0); + *numkeysp = 0; + seed = 0; + if ( (err= rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid)) == 0 ) + { + if ( rogue_findbaton(cp,playertxid,&keystrokes,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,rogueaddr,numplayers,symbol,pname) == 0 ) + { + UniValue obj; + seed = rogue_gamefields(obj,maxplayers,buyin,gametxid,rogueaddr); + fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d\n",pname.size()!=0?pname.c_str():Rogue_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size()); + memset(&P,0,sizeof(P)); + if ( playerdata.size() > 0 ) + { + for (i=0; i no playerdata\n"); + newdata.resize(0); + } + sprintf(str,"extracted $$$gold.%d hp.%d strength.%d level.%d exp.%d dl.%d n.%d size.%d\n",endP.gold,endP.hitpoints,endP.strength,endP.level,endP.experience,endP.dungeonlevel,n,(int32_t)sizeof(endP)); + fprintf(stderr,"%s\n",str); + } else num = 0; + } + } + *numkeysp = numkeys; + return(keystrokes); +} + UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result; CPubKey pk,roguepk; int32_t i,n,num,maxplayers,gameheight,batonht,batonvout,numplayers,regslot,numkeys,err; std::string symbol,pname; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue; char rogueaddr[64],fname[64],str[512],*pubstr,*keystrokes = 0; std::vector playerdata,newdata; uint256 batontxid,playertxid,gametxid; FILE *fp; uint8_t player[10000],pub33[33]; + UniValue result; CPubKey pk,roguepk; int32_t i,n,numkeys,flag = 0; uint64_t seed; char str[512],rogueaddr[64],*pubstr,*keystrokes = 0; std::vector newdata; uint256 gametxid; FILE *fp; uint8_t player[10000],pub33[33]; pk = pubkey2pk(Mypubkey()); roguepk = GetUnspendable(cp,0); - result.push_back(Pair("status","success")); result.push_back(Pair("name","rogue")); result.push_back(Pair("method","extract")); if ( (params= cclib_reparse(&n,params)) != 0 ) @@ -845,57 +899,19 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) } GetCCaddress1of2(cp,rogueaddr,roguepk,pk); result.push_back(Pair("rogueaddr",rogueaddr)); - if ( (err= rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid)) == 0 ) + if ( (keystrokes= rogue_extractgame(str,&numkeys,P,newdata,endP,seed,cp,gametxid,rogueaddr)) != 0 ) { - if ( rogue_findbaton(cp,playertxid,&keystrokes,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,rogueaddr,numplayers,symbol,pname) == 0 ) - { - UniValue obj; struct rogue_player P; - seed = rogue_gamefields(obj,maxplayers,buyin,gametxid,rogueaddr); - fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d\n",pname.size()!=0?pname.c_str():Rogue_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size()); - memset(&P,0,sizeof(P)); - if ( playerdata.size() > 0 ) - { - for (i=0; i no playerdata\n"); - newdata.resize(0); - } - sprintf(str,"extracted $$$gold.%d hp.%d strength.%d level.%d exp.%d dl.%d n.%d size.%d\n",P.gold,P.hitpoints,P.strength,P.level,P.experience,P.dungeonlevel,n,(int32_t)sizeof(P)); - result.push_back(Pair("extracted",str)); - fprintf(stderr,"%s\n",str); - if ( keystrokes != 0 ) - free(keystrokes); - } else num = 0; - } + result.push_back(Pair("status","success")); + flag = 1; + result.push_back(Pair("extracted",str)); + result.push_back(Pair("numkeys",(int64_t)numkeys)); + result.push_back(Pair("seed",(int64_t)seed)); + free(keystrokes); } } } + if ( flag == 0 ) + result.push_back(Pair("status","error")); return(result); } From e06149dc5617971911651a796de137de3423ad22 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 20:08:12 -1100 Subject: [PATCH 46/87] Syntax --- src/cc/rogue_rpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 54aad1326..b8a816158 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -866,7 +866,7 @@ char *rogue_extractgame(char *str,int32_t *numkeysp,struct rogue_player &P,std:: fprintf(stderr,"zero value character was killed -> no playerdata\n"); newdata.resize(0); } - sprintf(str,"extracted $$$gold.%d hp.%d strength.%d level.%d exp.%d dl.%d n.%d size.%d\n",endP.gold,endP.hitpoints,endP.strength,endP.level,endP.experience,endP.dungeonlevel,n,(int32_t)sizeof(endP)); + sprintf(str,"extracted $$$gold.%d hp.%d strength.%d level.%d exp.%d dl.%d\n",endP.gold,endP.hitpoints,endP.strength,endP.level,endP.experience,endP.dungeonlevel); fprintf(stderr,"%s\n",str); } else num = 0; } @@ -877,7 +877,7 @@ char *rogue_extractgame(char *str,int32_t *numkeysp,struct rogue_player &P,std:: UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result; CPubKey pk,roguepk; int32_t i,n,numkeys,flag = 0; uint64_t seed; char str[512],rogueaddr[64],*pubstr,*keystrokes = 0; std::vector newdata; uint256 gametxid; FILE *fp; uint8_t player[10000],pub33[33]; + UniValue result; CPubKey pk,roguepk; int32_t i,n,numkeys,flag = 0; uint64_t seed; char str[512],rogueaddr[64],*pubstr,*keystrokes = 0; std::vector newdata; uint256 gametxid; FILE *fp; uint8_t player[10000],pub33[33]; struct rogue_player P,endP; pk = pubkey2pk(Mypubkey()); roguepk = GetUnspendable(cp,0); result.push_back(Pair("name","rogue")); From 51e251ff220885c51c1a10536f9b56faf219bca3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 20:09:15 -1100 Subject: [PATCH 47/87] uint64_t seed --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index b8a816158..087567df5 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -819,7 +819,7 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } else return(cclib_error(result,"couldnt reparse params")); } -char *rogue_extractgame(char *str,int32_t *numkeysp,struct rogue_player &P,std::vector &newdata,struct rogue_player &endP,int64_t &seed,struct CCcontract_info *cp,uint256 gametxid,char *rogueaddr) +char *rogue_extractgame(char *str,int32_t *numkeysp,struct rogue_player &P,std::vector &newdata,struct rogue_player &endP,uint64_t &seed,struct CCcontract_info *cp,uint256 gametxid,char *rogueaddr) { CPubKey roguepk; int32_t i,num,maxplayers,gameheight,batonht,batonvout,numplayers,regslot,numkeys,err; std::string symbol,pname; CTransaction gametx; int64_t buyin,batonvalue; char fname[64],*keystrokes = 0; std::vector playerdata; uint256 batontxid,playertxid; FILE *fp; uint8_t newplayer[10000]; roguepk = GetUnspendable(cp,0); From 274bbfb0c8e8fa9e4e36ca139ac3b2f7164442e2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 20:12:42 -1100 Subject: [PATCH 48/87] Test --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 087567df5..144692404 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -899,7 +899,7 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) } GetCCaddress1of2(cp,rogueaddr,roguepk,pk); result.push_back(Pair("rogueaddr",rogueaddr)); - if ( (keystrokes= rogue_extractgame(str,&numkeys,P,newdata,endP,seed,cp,gametxid,rogueaddr)) != 0 ) + if ( 0 && (keystrokes= rogue_extractgame(str,&numkeys,P,newdata,endP,seed,cp,gametxid,rogueaddr)) != 0 ) { result.push_back(Pair("status","success")); flag = 1; From 99ea9f366ea5e7e90344376fa119148bc814163d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 20:14:29 -1100 Subject: [PATCH 49/87] Huh? --- src/cc/rogue_rpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 144692404..1a364dd53 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -877,12 +877,12 @@ char *rogue_extractgame(char *str,int32_t *numkeysp,struct rogue_player &P,std:: UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result; CPubKey pk,roguepk; int32_t i,n,numkeys,flag = 0; uint64_t seed; char str[512],rogueaddr[64],*pubstr,*keystrokes = 0; std::vector newdata; uint256 gametxid; FILE *fp; uint8_t player[10000],pub33[33]; struct rogue_player P,endP; + UniValue result; CPubKey pk,roguepk; int32_t i,n,numkeys,flag = 0; uint64_t seed; char str[512],rogueaddr[64],*pubstr,*keystrokes = 0; std::vector newdata; uint256 gametxid; FILE *fp; uint8_t pub33[33]; struct rogue_player P,endP; pk = pubkey2pk(Mypubkey()); roguepk = GetUnspendable(cp,0); result.push_back(Pair("name","rogue")); result.push_back(Pair("method","extract")); - if ( (params= cclib_reparse(&n,params)) != 0 ) + if ( 0 && (params= cclib_reparse(&n,params)) != 0 ) { if ( n > 0 ) { From 35110a993c489477b6a2ae148c08bb8f8b18d52c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 20:18:06 -1100 Subject: [PATCH 50/87] Test --- src/cc/rogue_rpc.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 1a364dd53..eb13d0a41 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -819,9 +819,9 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } else return(cclib_error(result,"couldnt reparse params")); } -char *rogue_extractgame(char *str,int32_t *numkeysp,struct rogue_player &P,std::vector &newdata,struct rogue_player &endP,uint64_t &seed,struct CCcontract_info *cp,uint256 gametxid,char *rogueaddr) +char *rogue_extractgame(char *str,int32_t *numkeysp,std::vector &newdata,uint64_t &seed,struct CCcontract_info *cp,uint256 gametxid,char *rogueaddr) { - CPubKey roguepk; int32_t i,num,maxplayers,gameheight,batonht,batonvout,numplayers,regslot,numkeys,err; std::string symbol,pname; CTransaction gametx; int64_t buyin,batonvalue; char fname[64],*keystrokes = 0; std::vector playerdata; uint256 batontxid,playertxid; FILE *fp; uint8_t newplayer[10000]; + CPubKey roguepk; int32_t i,num,maxplayers,gameheight,batonht,batonvout,numplayers,regslot,numkeys,err; std::string symbol,pname; CTransaction gametx; int64_t buyin,batonvalue; char fname[64],*keystrokes = 0; std::vector playerdata; uint256 batontxid,playertxid; FILE *fp; uint8_t newplayer[10000]; struct rogue_player P,endP; roguepk = GetUnspendable(cp,0); *numkeysp = 0; seed = 0; @@ -877,11 +877,12 @@ char *rogue_extractgame(char *str,int32_t *numkeysp,struct rogue_player &P,std:: UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result; CPubKey pk,roguepk; int32_t i,n,numkeys,flag = 0; uint64_t seed; char str[512],rogueaddr[64],*pubstr,*keystrokes = 0; std::vector newdata; uint256 gametxid; FILE *fp; uint8_t pub33[33]; struct rogue_player P,endP; + UniValue result; CPubKey pk,roguepk; int32_t i,n,numkeys,flag = 0; uint64_t seed; char str[512],rogueaddr[64],*pubstr,*keystrokes = 0; std::vector newdata; uint256 gametxid; FILE *fp; uint8_t pub33[33]; pk = pubkey2pk(Mypubkey()); roguepk = GetUnspendable(cp,0); result.push_back(Pair("name","rogue")); result.push_back(Pair("method","extract")); + fprintf(stderr,"inside rogue extract\n"); if ( 0 && (params= cclib_reparse(&n,params)) != 0 ) { if ( n > 0 ) @@ -899,7 +900,7 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) } GetCCaddress1of2(cp,rogueaddr,roguepk,pk); result.push_back(Pair("rogueaddr",rogueaddr)); - if ( 0 && (keystrokes= rogue_extractgame(str,&numkeys,P,newdata,endP,seed,cp,gametxid,rogueaddr)) != 0 ) + if ( 0 && (keystrokes= rogue_extractgame(str,&numkeys,newdata,seed,cp,gametxid,rogueaddr)) != 0 ) { result.push_back(Pair("status","success")); flag = 1; From 93f7c80bce2128f546a5320ac055b37c2c437e21 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 20:20:03 -1100 Subject: [PATCH 51/87] Test --- src/cc/rogue_rpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index eb13d0a41..5f7fb233f 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -883,7 +883,7 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) result.push_back(Pair("name","rogue")); result.push_back(Pair("method","extract")); fprintf(stderr,"inside rogue extract\n"); - if ( 0 && (params= cclib_reparse(&n,params)) != 0 ) + /* if ( 0 && (params= cclib_reparse(&n,params)) != 0 ) { if ( n > 0 ) { @@ -910,7 +910,7 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) free(keystrokes); } } - } + }*/ if ( flag == 0 ) result.push_back(Pair("status","error")); return(result); From 0ad53817bf541f2e3f2db081d4ac5bc75f035ec7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 20:22:29 -1100 Subject: [PATCH 52/87] Test --- src/cc/rogue_rpc.cpp | 45 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 5f7fb233f..9c6ab7152 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -876,6 +876,45 @@ char *rogue_extractgame(char *str,int32_t *numkeysp,std::vector &newdat } UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ),a(UniValue::VARR),b(UniValue::VARR); uint256 txid,hashBlock,gametxid,tokenid,playertxid; int32_t vout,maxplayers,gameheight,numvouts; CPubKey roguepk,mypk; char coinaddr[64]; CTransaction tx,gametx; int64_t buyin; + std::vector > addressIndex; + //std::vector > unspentOutputs; + roguepk = GetUnspendable(cp,0); + mypk = pubkey2pk(Mypubkey()); + GetCCaddress1of2(cp,coinaddr,roguepk,mypk); + //SetCCunspents(unspentOutputs,coinaddr); + SetCCtxids(addressIndex,coinaddr); + rogue_univalue(result,"extract",-1,-1); + for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) + //for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) + { + txid = it->first.txhash; + vout = (int32_t)it->first.index; + //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); + if ( vout == 0 ) + { + if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 ) + { + if ( rogue_registeropretdecode(gametxid,tokenid,playertxid,tx.vout[numvouts-1].scriptPubKey) == 'R' ) + { + if ( rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid) == 0 ) + { + if ( CCgettxout(txid,vout,1) < 0 ) + b.push_back(gametxid.GetHex()); + else a.push_back(gametxid.GetHex()); + } + } + } + } + } + result.push_back(Pair("pastgames",b)); + result.push_back(Pair("games",a)); + result.push_back(Pair("numgames",(int64_t)(a.size()+b.size()))); + return(result); +} + +UniValue realrogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result; CPubKey pk,roguepk; int32_t i,n,numkeys,flag = 0; uint64_t seed; char str[512],rogueaddr[64],*pubstr,*keystrokes = 0; std::vector newdata; uint256 gametxid; FILE *fp; uint8_t pub33[33]; pk = pubkey2pk(Mypubkey()); @@ -883,7 +922,7 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) result.push_back(Pair("name","rogue")); result.push_back(Pair("method","extract")); fprintf(stderr,"inside rogue extract\n"); - /* if ( 0 && (params= cclib_reparse(&n,params)) != 0 ) + if ( (params= cclib_reparse(&n,params)) != 0 ) { if ( n > 0 ) { @@ -900,7 +939,7 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) } GetCCaddress1of2(cp,rogueaddr,roguepk,pk); result.push_back(Pair("rogueaddr",rogueaddr)); - if ( 0 && (keystrokes= rogue_extractgame(str,&numkeys,newdata,seed,cp,gametxid,rogueaddr)) != 0 ) + if ( (keystrokes= rogue_extractgame(str,&numkeys,newdata,seed,cp,gametxid,rogueaddr)) != 0 ) { result.push_back(Pair("status","success")); flag = 1; @@ -910,7 +949,7 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) free(keystrokes); } } - }*/ + } if ( flag == 0 ) result.push_back(Pair("status","error")); return(result); From 7572af1ac9e250c8e89bee702ae7e2c5dcef1165 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 20:24:45 -1100 Subject: [PATCH 53/87] (UniValue::VOBJ) --- src/cc/rogue_rpc.cpp | 42 +----------------------------------------- 1 file changed, 1 insertion(+), 41 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 9c6ab7152..6101eead4 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -877,51 +877,11 @@ char *rogue_extractgame(char *str,int32_t *numkeysp,std::vector &newdat UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ),a(UniValue::VARR),b(UniValue::VARR); uint256 txid,hashBlock,gametxid,tokenid,playertxid; int32_t vout,maxplayers,gameheight,numvouts; CPubKey roguepk,mypk; char coinaddr[64]; CTransaction tx,gametx; int64_t buyin; - std::vector > addressIndex; - //std::vector > unspentOutputs; - roguepk = GetUnspendable(cp,0); - mypk = pubkey2pk(Mypubkey()); - GetCCaddress1of2(cp,coinaddr,roguepk,mypk); - //SetCCunspents(unspentOutputs,coinaddr); - SetCCtxids(addressIndex,coinaddr); - rogue_univalue(result,"extract",-1,-1); - for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) - //for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) - { - txid = it->first.txhash; - vout = (int32_t)it->first.index; - //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); - if ( vout == 0 ) - { - if ( GetTransaction(txid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 ) - { - if ( rogue_registeropretdecode(gametxid,tokenid,playertxid,tx.vout[numvouts-1].scriptPubKey) == 'R' ) - { - if ( rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid) == 0 ) - { - if ( CCgettxout(txid,vout,1) < 0 ) - b.push_back(gametxid.GetHex()); - else a.push_back(gametxid.GetHex()); - } - } - } - } - } - result.push_back(Pair("pastgames",b)); - result.push_back(Pair("games",a)); - result.push_back(Pair("numgames",(int64_t)(a.size()+b.size()))); - return(result); -} - -UniValue realrogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) -{ - UniValue result; CPubKey pk,roguepk; int32_t i,n,numkeys,flag = 0; uint64_t seed; char str[512],rogueaddr[64],*pubstr,*keystrokes = 0; std::vector newdata; uint256 gametxid; FILE *fp; uint8_t pub33[33]; + UniValue result(UniValue::VOBJ); CPubKey pk,roguepk; int32_t i,n,numkeys,flag = 0; uint64_t seed; char str[512],rogueaddr[64],*pubstr,*keystrokes = 0; std::vector newdata; uint256 gametxid; FILE *fp; uint8_t pub33[33]; pk = pubkey2pk(Mypubkey()); roguepk = GetUnspendable(cp,0); result.push_back(Pair("name","rogue")); result.push_back(Pair("method","extract")); - fprintf(stderr,"inside rogue extract\n"); if ( (params= cclib_reparse(&n,params)) != 0 ) { if ( n > 0 ) From ca219e38ad00ea27912b998aff294b698c6042b0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 20:26:46 -1100 Subject: [PATCH 54/87] Test --- src/cc/rogue_rpc.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 6101eead4..240d74752 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -899,6 +899,7 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) } GetCCaddress1of2(cp,rogueaddr,roguepk,pk); result.push_back(Pair("rogueaddr",rogueaddr)); + return(result); if ( (keystrokes= rogue_extractgame(str,&numkeys,newdata,seed,cp,gametxid,rogueaddr)) != 0 ) { result.push_back(Pair("status","success")); From 98947db212f7fd17b59a5651d87dbc7361fa31e4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 20:28:34 -1100 Subject: [PATCH 55/87] Test --- src/cc/rogue_rpc.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 240d74752..8f39b3d5e 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -899,14 +899,14 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) } GetCCaddress1of2(cp,rogueaddr,roguepk,pk); result.push_back(Pair("rogueaddr",rogueaddr)); - return(result); + str[0] = 0; if ( (keystrokes= rogue_extractgame(str,&numkeys,newdata,seed,cp,gametxid,rogueaddr)) != 0 ) { result.push_back(Pair("status","success")); flag = 1; result.push_back(Pair("extracted",str)); - result.push_back(Pair("numkeys",(int64_t)numkeys)); - result.push_back(Pair("seed",(int64_t)seed)); + //result.push_back(Pair("numkeys",(int64_t)numkeys)); + //result.push_back(Pair("seed",(int64_t)seed)); free(keystrokes); } } From 0a849f55b90626ffd9c3f376c3b961f4966e9bf0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 20:31:06 -1100 Subject: [PATCH 56/87] Test --- src/cc/rogue_rpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 8f39b3d5e..5fa964407 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -905,8 +905,8 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) result.push_back(Pair("status","success")); flag = 1; result.push_back(Pair("extracted",str)); - //result.push_back(Pair("numkeys",(int64_t)numkeys)); - //result.push_back(Pair("seed",(int64_t)seed)); + result.push_back(Pair("numkeys",(int64_t)numkeys)); + result.push_back(Pair("seed",(int64_t)seed)); free(keystrokes); } } From afc2c11591636aed86a9c3ab396b6f19a8a59592 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 20:39:10 -1100 Subject: [PATCH 57/87] Slseepmillis --- src/cc/cclib.cpp | 2 +- src/cc/rogue/main.c | 2 +- src/cc/rogue/rogue.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 77f6a21ac..f2f13837c 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -76,7 +76,7 @@ CClib_methods[] = std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *params); #ifdef BUILD_ROGUE -int32_t rogue_replay(uint64_t seed,int32_t sleeptime); +int32_t rogue_replay(uint64_t seed,int32_t sleepmillis); bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx); UniValue rogue_newgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 12e6af368..c0fa36752 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -253,7 +253,7 @@ int main(int argc, char **argv, char **envp) { seed = atol(argv[1]); //fprintf(stderr,"replay %llu\n",(long long)seed); - return(rogue_replay(seed,50000)); + return(rogue_replay(seed,10)); } else { diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 01c8b1873..516100906 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -337,7 +337,7 @@ int32_t rogue_replay(uint64_t seed,int32_t sleeptime) } fclose(fp); } - rogue_replay2(0,seed,keystrokes,num,player,30); + rogue_replay2(0,seed,keystrokes,num,player,sleeptime); //mvaddstr(LINES - 2, 0, (char *)"replay completed"); endwin(); From 02794ea8641936484dd4df859524ba6886939d4b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 20:39:51 -1100 Subject: [PATCH 58/87] Replay --- src/cc/rogue_rpc.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 5fa964407..318567383 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -907,6 +907,8 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) result.push_back(Pair("extracted",str)); result.push_back(Pair("numkeys",(int64_t)numkeys)); result.push_back(Pair("seed",(int64_t)seed)); + sprintf(str,"cc/rogue/rogue %llu",(long long)seed); + result.push_back(Pair("replay",str)); free(keystrokes); } } From 5793bef688561caa644d528e2830c88df4c149b9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 20:46:37 -1100 Subject: [PATCH 59/87] playertxid --- src/cc/rogue_rpc.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 318567383..93baaa44b 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -819,9 +819,9 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } else return(cclib_error(result,"couldnt reparse params")); } -char *rogue_extractgame(char *str,int32_t *numkeysp,std::vector &newdata,uint64_t &seed,struct CCcontract_info *cp,uint256 gametxid,char *rogueaddr) +char *rogue_extractgame(char *str,int32_t *numkeysp,std::vector &newdata,uint64_t &seed,uint256 &playertxid,struct CCcontract_info *cp,uint256 gametxid,char *rogueaddr) { - CPubKey roguepk; int32_t i,num,maxplayers,gameheight,batonht,batonvout,numplayers,regslot,numkeys,err; std::string symbol,pname; CTransaction gametx; int64_t buyin,batonvalue; char fname[64],*keystrokes = 0; std::vector playerdata; uint256 batontxid,playertxid; FILE *fp; uint8_t newplayer[10000]; struct rogue_player P,endP; + CPubKey roguepk; int32_t i,num,maxplayers,gameheight,batonht,batonvout,numplayers,regslot,numkeys,err; std::string symbol,pname; CTransaction gametx; int64_t buyin,batonvalue; char fname[64],*keystrokes = 0; std::vector playerdata; uint256 batontxid; FILE *fp; uint8_t newplayer[10000]; struct rogue_player P,endP; roguepk = GetUnspendable(cp,0); *numkeysp = 0; seed = 0; @@ -877,7 +877,7 @@ char *rogue_extractgame(char *str,int32_t *numkeysp,std::vector &newdat UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - UniValue result(UniValue::VOBJ); CPubKey pk,roguepk; int32_t i,n,numkeys,flag = 0; uint64_t seed; char str[512],rogueaddr[64],*pubstr,*keystrokes = 0; std::vector newdata; uint256 gametxid; FILE *fp; uint8_t pub33[33]; + UniValue result(UniValue::VOBJ); CPubKey pk,roguepk; int32_t i,n,numkeys,flag = 0; uint64_t seed; char str[512],rogueaddr[64],*pubstr,*keystrokes = 0; std::vector newdata; uint256 gametxid,playertxid; FILE *fp; uint8_t pub33[33]; pk = pubkey2pk(Mypubkey()); roguepk = GetUnspendable(cp,0); result.push_back(Pair("name","rogue")); @@ -900,10 +900,11 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) GetCCaddress1of2(cp,rogueaddr,roguepk,pk); result.push_back(Pair("rogueaddr",rogueaddr)); str[0] = 0; - if ( (keystrokes= rogue_extractgame(str,&numkeys,newdata,seed,cp,gametxid,rogueaddr)) != 0 ) + if ( (keystrokes= rogue_extractgame(str,&numkeys,newdata,seed,playertxid,cp,gametxid,rogueaddr)) != 0 ) { result.push_back(Pair("status","success")); flag = 1; + result.push_back(Pair("playertxid",playertxid.GetHex())); result.push_back(Pair("extracted",str)); result.push_back(Pair("numkeys",(int64_t)numkeys)); result.push_back(Pair("seed",(int64_t)seed)); From 156e9057d088b127f10be4da2d99797840b017e9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 20:52:01 -1100 Subject: [PATCH 60/87] Require registration within ROGUE_MAXKEYSTROKESGAP --- src/cc/rogue_rpc.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 93baaa44b..de91eef19 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -726,6 +726,8 @@ UniValue rogue_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) if ( tokenid != zeroid ) // if it is tokentransfer this will be 0 vout = 1; } + if ( komodo_nextheight() > gameheight + ROGUE_MAXKEYSTROKESGAP ) + return(cclib_error(result,"didnt register in time, ROGUE_MAXKEYSTROKESGAP")); rogue_univalue(result,0,maxplayers,buyin); GetCCaddress1of2(cp,coinaddr,roguepk,mypk); if ( rogue_iamregistered(maxplayers,gametxid,tx,coinaddr) > 0 ) From 3549fd1c0fb49cc792dab85a847704b31fc48f31 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 20:53:53 -1100 Subject: [PATCH 61/87] Update pending valid filter --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index de91eef19..4a7ef705d 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1113,7 +1113,7 @@ UniValue rogue_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); if ( it->second.satoshis != txfee || vout != 0 ) // reject any that are not highlander markers continue; - if ( rogue_isvalidgame(cp,gameheight,tx,buyin,maxplayers,txid) == 0 && gameheight > nextheight-777 ) + if ( rogue_isvalidgame(cp,gameheight,tx,buyin,maxplayers,txid) == 0 && nextheight <= gameheight+ROGUE_MAXKEYSTROKESGAP ) { rogue_playersalive(numplayers,txid,maxplayers); if ( numplayers < maxplayers ) From 533c2e564dd06eb2c1203bc8807c5bd8d23b9bba Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 21:27:02 -1100 Subject: [PATCH 62/87] Exit from replay --- src/cc/rogue/rogue.c | 3 ++- src/cc/rogue_rpc.cpp | 43 ++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 516100906..d015be4a9 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -339,8 +339,9 @@ int32_t rogue_replay(uint64_t seed,int32_t sleeptime) } rogue_replay2(0,seed,keystrokes,num,player,sleeptime); - //mvaddstr(LINES - 2, 0, (char *)"replay completed"); + mvaddstr(LINES - 2, 0, (char *)"replay completed"); endwin(); + my_exit(0); } if ( keystrokes != 0 ) free(keystrokes); diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 4a7ef705d..17d58a960 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -833,7 +833,7 @@ char *rogue_extractgame(char *str,int32_t *numkeysp,std::vector &newdat { UniValue obj; seed = rogue_gamefields(obj,maxplayers,buyin,gametxid,rogueaddr); - fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d\n",pname.size()!=0?pname.c_str():Rogue_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size()); + //fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d\n",pname.size()!=0?pname.c_str():Rogue_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size()); memset(&P,0,sizeof(P)); if ( playerdata.size() > 0 ) { @@ -897,7 +897,7 @@ UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) decode_hex(pub33,33,pubstr); pk = buf2pk(pub33); } - fprintf(stderr,"gametxid.%s %s\n",gametxid.GetHex().c_str(),pubstr); + //fprintf(stderr,"gametxid.%s %s\n",gametxid.GetHex().c_str(),pubstr); } GetCCaddress1of2(cp,rogueaddr,roguepk,pk); result.push_back(Pair("rogueaddr",rogueaddr)); @@ -1047,7 +1047,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } result.push_back(Pair("result","success")); } else fprintf(stderr,"illegal game err.%d\n",err); - } else fprintf(stderr,"n.%d\n",n); + } else fprintf(stderr,"parameters only n.%d\n",n); } return(result); } @@ -1217,6 +1217,43 @@ UniValue rogue_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) { + CScript scriptPubKey; std::vector vopret; uint8_t *script,e,f,funcid; int32_t i,ind,errflag,dispflag,score,numvouts; CTransaction vintx; uint256 hashBlock; + if ( (numvouts= tx.vout.size()) > 1 ) + { + scriptPubKey = tx.vout[numvouts-1].scriptPubKey; + GetOpReturnData(scriptPubKey,vopret); + if ( vopret.size() > 2 ) + { + script = (uint8_t *)vopret.data(); + if ( script[0] == EVAL_ROGUE ) + { + switch ( script[1] ) + { + case 'G': // newgame + case 'R': // register + case 'K': // keystrokes + case 'H': // win + case 'Q': // bailout + return(true); + break; + default: + return eval->Invalid("illegal rogue funcid"); + break; + } + } + else if ( script[0] == EVAL_TOKENS ) + { + if ( script[1] == 'c' ) + { + + } + else + { + + } + } else return eval->Invalid("illegal evalcode"); + } else return eval->Invalid("opret too small"); + } else return eval->Invalid("not enough vouts"); return(true); } From 444a5de9bc9156dd9666bd5d303657e0f4005613 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 21:30:29 -1100 Subject: [PATCH 63/87] -print --- src/cc/rogue/rogue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index d015be4a9..337592f86 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -743,7 +743,7 @@ my_exit(int st) { uint32_t counter; resetltchars(); - if ( globalR.guiflag != 0 ) + if ( globalR.guiflag != 0 || globalR.sleeptime != 0 ) exit(st); else if ( counter++ < 10 ) { From 9ecce2eb73035ce4bd640c5ffe2b78ff079998c7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 21:43:20 -1100 Subject: [PATCH 64/87] Preserve both player strength and max strength --- src/cc/rogue/init.c | 7 ++++++- src/cc/rogue/rogue.c | 2 +- src/cc/rogue/state.c | 6 +++--- src/cc/rogue_rpc.cpp | 11 ++++++----- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/cc/rogue/init.c b/src/cc/rogue/init.c index f296d6182..6ff0a71c0 100644 --- a/src/cc/rogue/init.c +++ b/src/cc/rogue/init.c @@ -27,7 +27,12 @@ void restore_player(struct rogue_state *rs) int32_t i; THING *obj; //rs->P.gold = purse; max_hp = rs->P.hitpoints; - pstats.s_str = max_stats.s_str = rs->P.strength; + pstats.s_str = rs->P.strength & 0xffff; + max_stats.s_str = rs->P.strength >> 16; + if ( max_stats.s_str < 12 ) + max_stats.s_str = 12; + if ( pstats.s_str > max_stats.s_str ) + pstats.s_str = max_stats.s_str; pstats.s_lvl = rs->P.level; pstats.s_exp = rs->P.experience; for (i=0; iP.packsize; i++) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 337592f86..72fe07558 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -273,7 +273,7 @@ int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t nu if ( (fp= fopen("checkfile","wb")) != 0 ) { save_file(rs,fp,0); - fprintf(stderr,"gold.%d hp.%d strength.%d level.%d exp.%d dungeon.%d data[%d]\n",rs->P.gold,rs->P.hitpoints,rs->P.strength,rs->P.level,rs->P.experience,rs->P.dungeonlevel,rs->playersize); + fprintf(stderr,"gold.%d hp.%d strength.%d/%d level.%d exp.%d dungeon.%d data[%d]\n",rs->P.gold,rs->P.hitpoints,rs->P.strength&0xffff,rs->P.strength>>16,rs->P.level,rs->P.experience,rs->P.dungeonlevel,rs->playersize); if ( newdata != 0 && rs->playersize > 0 ) memcpy(newdata,rs->playerdata,rs->playersize); } diff --git a/src/cc/rogue/state.c b/src/cc/rogue/state.c index 800622444..778540b68 100644 --- a/src/cc/rogue/state.c +++ b/src/cc/rogue/state.c @@ -1437,7 +1437,7 @@ rs_write_object(struct rogue_state *rs,FILE *savef, THING *o) //fprintf(stderr,"KILLED\n"); rs->P.gold = -1; rs->P.hitpoints = -1; - rs->P.strength = -1; + rs->P.strength = 0; rs->P.level = -1; rs->P.experience = -1; rs->P.dungeonlevel = -1; @@ -1448,11 +1448,11 @@ rs_write_object(struct rogue_state *rs,FILE *savef, THING *o) { rs->P.gold = purse; rs->P.hitpoints = max_hp; - rs->P.strength = pstats.s_str; //max_stats.s_str; + rs->P.strength = (pstats.s_str & 0xffff) | (max_stats.s_str << 16); rs->P.level = pstats.s_lvl; rs->P.experience = pstats.s_exp; rs->P.dungeonlevel = level; - //fprintf(stderr,"%ld gold.%d hp.%d strength.%d level.%d exp.%d %d\n",ftell(savef),purse,max_hp,pstats.s_str,pstats.s_lvl,pstats.s_exp,level); + //fprintf(stderr,"%ld gold.%d hp.%d strength.%d/%d level.%d exp.%d %d\n",ftell(savef),purse,max_hp,pstats.s_str,max_stats.s_str,pstats.s_lvl,pstats.s_exp,level); } //fprintf(stderr,"object (%s) x.%d y.%d type.%d pack.(%c:%d)\n",inv_name(o,FALSE),o->_o._o_pos.x,o->_o._o_pos.y,o->_o._o_type,o->_o._o_packch,o->_o._o_packch); if ( rs->P.packsize < MAXPACK && o->o_type != AMULET ) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 17d58a960..b79d653d5 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -387,7 +387,8 @@ UniValue rogue_playerobj(std::vector playerdata,uint256 playertxid,uint obj.push_back(Pair("pack",a)); obj.push_back(Pair("packsize",(int64_t)P.packsize)); obj.push_back(Pair("hitpoints",(int64_t)P.hitpoints)); - obj.push_back(Pair("strength",(int64_t)P.strength)); + obj.push_back(Pair("strength",(int64_t)(P.strength&0xffff))); + obj.push_back(Pair("maxstrength",(int64_t)(P.strength>>16))); obj.push_back(Pair("level",(int64_t)P.level)); obj.push_back(Pair("experience",(int64_t)P.experience)); obj.push_back(Pair("dungeonlevel",(int64_t)P.dungeonlevel)); @@ -863,12 +864,12 @@ char *rogue_extractgame(char *str,int32_t *numkeysp,std::vector &newdat newdata[i] = newplayer[i]; ((uint8_t *)&endP)[i] = newplayer[i]; } - if ( endP.gold <= 0 || endP.hitpoints <= 0 || endP.strength <= 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"); newdata.resize(0); } - sprintf(str,"extracted $$$gold.%d hp.%d strength.%d level.%d exp.%d dl.%d\n",endP.gold,endP.hitpoints,endP.strength,endP.level,endP.experience,endP.dungeonlevel); + sprintf(str,"extracted $$$gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d\n",endP.gold,endP.hitpoints,endP.strength&0xffff,endP.strength>>16,endP.level,endP.experience,endP.dungeonlevel); fprintf(stderr,"%s\n",str); } else num = 0; } @@ -993,7 +994,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param newdata[i] = player[i]; ((uint8_t *)&P)[i] = player[i]; } - if ( P.gold <= 0 || P.hitpoints <= 0 || P.strength <= 0 || P.level <= 0 || P.experience <= 0 || P.dungeonlevel <= 0 ) + if ( P.gold <= 0 || P.hitpoints <= 0 || (P.strength&0xffff) <= 0 || P.level <= 0 || P.experience <= 0 || P.dungeonlevel <= 0 ) { fprintf(stderr,"zero value character was killed -> no playerdata\n"); newdata.resize(0); @@ -1005,7 +1006,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param cpTokens = CCinit(&tokensC, EVAL_TOKENS); mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, txfee, GetUnspendable(cpTokens,NULL))); // marker to token cc addr, burnable and validated mtx.vout.push_back(MakeTokensCC1vout(cp->evalcode,1,mypk)); - fprintf(stderr,"\nextracted $$$gold.%d hp.%d strength.%d level.%d exp.%d dl.%d n.%d size.%d\n",P.gold,P.hitpoints,P.strength,P.level,P.experience,P.dungeonlevel,n,(int32_t)sizeof(P)); + fprintf(stderr,"\nextracted $$$gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d n.%d size.%d\n",P.gold,P.hitpoints,P.strength&0xffff,P.strength>>16,P.level,P.experience,P.dungeonlevel,n,(int32_t)sizeof(P)); cashout = (uint64_t)P.gold * mult; if ( funcid == 'H' && maxplayers > 1 ) { From 6224d87b12dd461382289b908ccc341ff40888ac Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 21:45:29 -1100 Subject: [PATCH 65/87] Validate bypass --- src/cc/rogue_rpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index b79d653d5..62f653685 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1246,11 +1246,11 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C { if ( script[1] == 'c' ) { - + return(true); } else { - + return(true); } } else return eval->Invalid("illegal evalcode"); } else return eval->Invalid("opret too small"); From 31a369f9855b16d616ba69f7830791e09e96adf2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 21:49:08 -1100 Subject: [PATCH 66/87] +fprintf in cursesd --- src/cc/rogue/cursesd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/cursesd.c b/src/cc/rogue/cursesd.c index 02a80c470..30cc54ec9 100644 --- a/src/cc/rogue/cursesd.c +++ b/src/cc/rogue/cursesd.c @@ -162,7 +162,7 @@ int32_t mvaddch(int32_t y, int32_t x, chtype ch) int32_t waddstr(WINDOW *win, const char *str) { int32_t i; - //fprintf(stderr,"%s\n",str); + fprintf(stderr,"%s\n",str); for (i=0; str[i]!=0; i++) waddch(win,str[i]); return(0); From ab28897a624d29b96d13d0ba5e493e257555c0ad Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 21:57:34 -1100 Subject: [PATCH 67/87] Redo chg_str --- src/cc/rogue/misc.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/cc/rogue/misc.c b/src/cc/rogue/misc.c index 7db9d073a..8a4d1df94 100644 --- a/src/cc/rogue/misc.c +++ b/src/cc/rogue/misc.c @@ -349,17 +349,36 @@ void chg_str(int amt) { //auto jl777: strange compiler error - str_t comp; + uint32_t comp; if (amt == 0) return; - add_str(&pstats.s_str, amt); + //add_str(&pstats.s_str, amt); + pstats.s_str += amt; + if ( pstats.s_str < 3 ) + pstats.s_str = 3; + else if ( pstats.s_str > 31 ) + pstats.s_str = 31; comp = pstats.s_str; if (ISRING(LEFT, R_ADDSTR)) - add_str(&comp, -cur_ring[LEFT]->o_arm); + { + // add_str(&comp, -cur_ring[LEFT]->o_arm); + comp += -cur_ring[LEFT]->o_arm; + if ( comp < 3 ) + comp = 3; + else if ( comp > 31 ) + comp = 31; + } if (ISRING(RIGHT, R_ADDSTR)) - add_str(&comp, -cur_ring[RIGHT]->o_arm); - if (comp > max_stats.s_str) + { + //add_str(&comp, -cur_ring[RIGHT]->o_arm); + comp += -cur_ring[RIGHT]->o_arm; + if ( comp < 3 ) + comp = 3; + else if ( comp > 31 ) + comp = 31; + } + if ( comp > max_stats.s_str ) max_stats.s_str = comp; } From 67879fb99208d901882322d83ef6a9416d9a5602 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 22:03:55 -1100 Subject: [PATCH 68/87] +chars print --- src/cc/rogue/io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index c920ee411..7cfa7e59f 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -161,7 +161,7 @@ readchar(struct rogue_state *rs) { //if ( rs->ind == rs->numkeys-1 ) // rs->replaydone = (uint32_t)time(NULL); - //fprintf(stderr,"(%c) ",rs->keystrokes[rs->ind]); + fprintf(stderr,"(%c) ",rs->keystrokes[rs->ind]); return(rs->keystrokes[rs->ind++]); } if ( rs->replaydone != 0 && counter++ < 3 ) From 10ad979ac9fe8cdf4862358f4ced79e84c9e51e0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 22:08:13 -1100 Subject: [PATCH 69/87] Test --- src/cc/rogue/command.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index 6cc6b0763..22723b6c6 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -259,7 +259,8 @@ over: again = TRUE; goto over; } - when 'q': quaff(rs); + case 'q': quaff(rs); + break; when 'Q': after = FALSE; q_comm = TRUE; From fbdd8a6166c356655a87b0ea8d4cb2c41c742504 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 22:10:48 -1100 Subject: [PATCH 70/87] Test --- src/cc/rogue/command.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index 22723b6c6..5dbc97051 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -262,15 +262,18 @@ over: case 'q': quaff(rs); break; when 'Q': - after = FALSE; - q_comm = TRUE; - quit(0); - if ( rs->guiflag != 0 && rs->needflush == 0 ) - rs->needflush = (uint32_t)time(NULL); - q_comm = FALSE; - if ( rs->guiflag != 0 ) - rogue_bailout(rs); - else rs->replaydone = (uint32_t)time(NULL); + if ( rs->sleeptime == 1 ) + { + after = FALSE; + q_comm = TRUE; + quit(0); + if ( rs->guiflag != 0 && rs->needflush == 0 ) + rs->needflush = (uint32_t)time(NULL); + q_comm = FALSE; + if ( rs->guiflag != 0 ) + rogue_bailout(rs); + else rs->replaydone = (uint32_t)time(NULL); + } return; when 'i': after = FALSE; inventory(rs,pack, 0); when 'I': after = FALSE; picky_inven(rs); From da2234e121cc9649b367dc0cd18ad9f1e80b3e9c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 22:15:25 -1100 Subject: [PATCH 71/87] Test --- src/cc/rogue/command.c | 21 +++++++++------------ src/cc/rogue/rogue.c | 6 +++--- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index 5dbc97051..d13be4972 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -262,18 +262,15 @@ over: case 'q': quaff(rs); break; when 'Q': - if ( rs->sleeptime == 1 ) - { - after = FALSE; - q_comm = TRUE; - quit(0); - if ( rs->guiflag != 0 && rs->needflush == 0 ) - rs->needflush = (uint32_t)time(NULL); - q_comm = FALSE; - if ( rs->guiflag != 0 ) - rogue_bailout(rs); - else rs->replaydone = (uint32_t)time(NULL); - } + after = FALSE; + q_comm = TRUE; + quit(0); + if ( rs->guiflag != 0 && rs->needflush == 0 ) + rs->needflush = (uint32_t)time(NULL); + q_comm = FALSE; + if ( rs->guiflag != 0 ) + rogue_bailout(rs); + else rs->replaydone = (uint32_t)time(NULL); return; when 'i': after = FALSE; inventory(rs,pack, 0); when 'I': after = FALSE; picky_inven(rs); diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 72fe07558..67a99aa14 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -633,9 +633,9 @@ quit(int sig) */ if (!q_comm) mpos = 0; - getyx(curscr, oy, ox); - msg(rs,"really quit?"); } + getyx(curscr, oy, ox); + msg(rs,"really quit?"); if (readchar(rs) == 'y') { if ( rs->guiflag != 0 ) @@ -653,7 +653,7 @@ quit(int sig) else { //score(rs,purse, 1, 0); - //fprintf(stderr,"done!\n"); + fprintf(stderr,"done!\n"); } } else From 0d262ff7e2e0a68520b6d59668fa3f7a9ae5d848 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 22:17:40 -1100 Subject: [PATCH 72/87] Test --- src/cc/rogue/io.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index 7cfa7e59f..83e0c2ff6 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -161,7 +161,12 @@ readchar(struct rogue_state *rs) { //if ( rs->ind == rs->numkeys-1 ) // rs->replaydone = (uint32_t)time(NULL); - fprintf(stderr,"(%c) ",rs->keystrokes[rs->ind]); + if ( rs->keystrokes[rs->ind] == 'Q' ) + { + rs->ind++; + fprintf(stderr,"Q.(%c) ",rs->keystrokes[rs->ind]); + return('q'); + } return(rs->keystrokes[rs->ind++]); } if ( rs->replaydone != 0 && counter++ < 3 ) From ae05cc1f6816560481cabb33d2e38041a5ce8f8a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 22:22:50 -1100 Subject: [PATCH 73/87] Quit handling --- src/cc/rogue/command.c | 17 ++++++++++------- src/cc/rogue/extern.h | 2 +- src/cc/rogue/io.c | 13 ------------- src/cc/rogue/rogue.c | 7 ++++--- 4 files changed, 15 insertions(+), 24 deletions(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index d13be4972..d55b93a5b 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -264,14 +264,17 @@ over: when 'Q': after = FALSE; q_comm = TRUE; - quit(0); - if ( rs->guiflag != 0 && rs->needflush == 0 ) - rs->needflush = (uint32_t)time(NULL); + if ( quit(0) > 0 ) + { + if ( rs->guiflag != 0 ) + { + if (rs->needflush == 0 ) + rs->needflush = (uint32_t)time(NULL); + rogue_bailout(rs); + } else rs->replaydone = (uint32_t)time(NULL); + } q_comm = FALSE; - if ( rs->guiflag != 0 ) - rogue_bailout(rs); - else rs->replaydone = (uint32_t)time(NULL); - return; + return; when 'i': after = FALSE; inventory(rs,pack, 0); when 'I': after = FALSE; picky_inven(rs); when 'd': drop(rs); diff --git a/src/cc/rogue/extern.h b/src/cc/rogue/extern.h index fc3454830..ff45e0fee 100644 --- a/src/cc/rogue/extern.h +++ b/src/cc/rogue/extern.h @@ -141,7 +141,7 @@ void getltchars(void); void leave(int); void my_exit(int st); void playltchars(void); -void quit(int); +int32_t quit(int); void resetltchars(void); void set_order(int *order, int numthings); void tstp(int ignored); diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index 83e0c2ff6..576314a42 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -158,23 +158,10 @@ readchar(struct rogue_state *rs) { static uint32_t counter; if ( rs->ind < rs->numkeys ) - { - //if ( rs->ind == rs->numkeys-1 ) - // rs->replaydone = (uint32_t)time(NULL); - if ( rs->keystrokes[rs->ind] == 'Q' ) - { - rs->ind++; - fprintf(stderr,"Q.(%c) ",rs->keystrokes[rs->ind]); - return('q'); - } return(rs->keystrokes[rs->ind++]); - } if ( rs->replaydone != 0 && counter++ < 3 ) fprintf(stderr,"replay finished but readchar called\n"); rs->replaydone = (uint32_t)time(NULL); - //if ( (rand() & 1) == 0 ) - // return(ESCAPE); - //else if ( counter < 3 || (counter & 1) == 0 ) return('y'); else return(ESCAPE); diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 67a99aa14..bfb4e0277 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -618,8 +618,7 @@ playit(struct rogue_state *rs) * Have player make certain, then exit. */ -void -quit(int sig) +int32_t quit(int sig) { struct rogue_state *rs = &globalR; int oy, ox; @@ -653,8 +652,9 @@ quit(int sig) else { //score(rs,purse, 1, 0); - fprintf(stderr,"done!\n"); + //fprintf(stderr,"done!\n"); } + return(1); } else { @@ -667,6 +667,7 @@ quit(int sig) mpos = 0; count = 0; to_death = FALSE; + return(0); } } From f513e5d1f531de4760c41d09f9f0ece0069d00ae Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 22:26:03 -1100 Subject: [PATCH 74/87] Prints --- src/cc/rogue/io.c | 2 ++ src/cc/rogue/rogue.c | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index 576314a42..6e070b2a8 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -158,7 +158,9 @@ readchar(struct rogue_state *rs) { static uint32_t counter; if ( rs->ind < rs->numkeys ) + { return(rs->keystrokes[rs->ind++]); + } if ( rs->replaydone != 0 && counter++ < 3 ) fprintf(stderr,"replay finished but readchar called\n"); rs->replaydone = (uint32_t)time(NULL); diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index bfb4e0277..dafcf3f01 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -621,7 +621,7 @@ playit(struct rogue_state *rs) int32_t quit(int sig) { struct rogue_state *rs = &globalR; - int oy, ox; + int oy, ox, c; //fprintf(stderr,"inside quit(%d)\n",sig); if ( rs->guiflag != 0 ) { @@ -635,7 +635,8 @@ int32_t quit(int sig) } getyx(curscr, oy, ox); msg(rs,"really quit?"); - if (readchar(rs) == 'y') + sleep(1); + if ( (c= readchar(rs)) == 'y') { if ( rs->guiflag != 0 ) { @@ -652,12 +653,13 @@ int32_t quit(int sig) else { //score(rs,purse, 1, 0); - //fprintf(stderr,"done!\n"); + fprintf(stderr,"done!\n"); } return(1); } else { + fprintf(stderr,"'Q' answer (%c)\n",c); move(0, 0); clrtoeol(); status(rs); From ef4844d5a3538f097c7b81a311c7409172f46107 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 22:29:58 -1100 Subject: [PATCH 75/87] _quit --- src/cc/rogue/command.c | 2 +- src/cc/rogue/extern.h | 3 ++- src/cc/rogue/io.c | 2 +- src/cc/rogue/rogue.c | 40 +++++++++++++++++++++++++--------------- 4 files changed, 29 insertions(+), 18 deletions(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index d55b93a5b..54d7beb99 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -264,7 +264,7 @@ over: when 'Q': after = FALSE; q_comm = TRUE; - if ( quit(0) > 0 ) + if ( _quit() > 0 ) { if ( rs->guiflag != 0 ) { diff --git a/src/cc/rogue/extern.h b/src/cc/rogue/extern.h index ff45e0fee..7fba842f3 100644 --- a/src/cc/rogue/extern.h +++ b/src/cc/rogue/extern.h @@ -141,7 +141,8 @@ void getltchars(void); void leave(int); void my_exit(int st); void playltchars(void); -int32_t quit(int); +void quit(int); +int32_t _quit(); void resetltchars(void); void set_order(int *order, int numthings); void tstp(int ignored); diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index 6e070b2a8..79eadb571 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -174,7 +174,7 @@ readchar(struct rogue_state *rs) if (ch == 3) { - quit(0); + _quit(); return(27); } if ( rs != 0 && rs->guiflag != 0 ) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index dafcf3f01..02feef2ab 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -613,26 +613,13 @@ playit(struct rogue_state *rs) endit(0); } -/* - * quit: - * Have player make certain, then exit. - */ -int32_t quit(int sig) + +int32_t _quit() { struct rogue_state *rs = &globalR; int oy, ox, c; //fprintf(stderr,"inside quit(%d)\n",sig); - if ( rs->guiflag != 0 ) - { - NOOP(sig); - - /* - * Reset the signal in case we got here via an interrupt - */ - if (!q_comm) - mpos = 0; - } getyx(curscr, oy, ox); msg(rs,"really quit?"); sleep(1); @@ -673,6 +660,29 @@ int32_t quit(int sig) } } +/* + * quit: + * Have player make certain, then exit. + */ + +void quit(int sig) +{ + struct rogue_state *rs = &globalR; + int oy, ox, c; + //fprintf(stderr,"inside quit(%d)\n",sig); + if ( rs->guiflag != 0 ) + { + NOOP(sig); + + /* + * Reset the signal in case we got here via an interrupt + */ + if (!q_comm) + mpos = 0; + } + _quit(); +} + /* * leave: * Leave quickly, but curteously From 7be1c552280b7c4347306e064632bdebcf024dba Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 22:33:13 -1100 Subject: [PATCH 76/87] tst --- src/cc/rogue/rogue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 02feef2ab..bc576dabf 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -640,7 +640,7 @@ int32_t _quit() else { //score(rs,purse, 1, 0); - fprintf(stderr,"done!\n"); + fprintf(stderr,"done! (%c)\n",c); } return(1); } From 0a11653334e01b49116a47003f57088d99fd5eac Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 22:38:44 -1100 Subject: [PATCH 77/87] test --- src/cc/rogue/io.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index 79eadb571..525550e67 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -153,13 +153,22 @@ step_ok(int ch) char readchar(struct rogue_state *rs) { - char ch = -1; + char c,ch = -1; if ( rs != 0 && rs->guiflag == 0 ) { static uint32_t counter; if ( rs->ind < rs->numkeys ) { - return(rs->keystrokes[rs->ind++]); + c = rs->keystrokes[rs->ind++]; + while ( c == 'Q' && rs->ind < rs->numkeys ) + { + fprintf(stderr,"Got 'Q' next (%c)\n",rs->keystrokes[rs->ind]); sleep(2); + if ( rs->keystrokes[rs->ind] == 'y' ) + return(c); + rs->ind++; + c = rs->keystrokes[rs->ind++]; + } + return(c); } if ( rs->replaydone != 0 && counter++ < 3 ) fprintf(stderr,"replay finished but readchar called\n"); From 8ea12e7dde906edc9d0e4342929bc13c7eb70b92 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 23:02:10 -1100 Subject: [PATCH 78/87] Test --- src/cc/rogue/rogue.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index bc576dabf..6583725f4 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -250,6 +250,7 @@ int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t nu rs->restoring = 1; //fprintf(stderr,"restore player packsize.%d HP.%d\n",rs->P.packsize,rs->P.hitpoints); } + globalR = *rs; uint32_t starttime = (uint32_t)time(NULL); rogueiterate(rs); if ( 0 ) @@ -760,7 +761,7 @@ my_exit(int st) exit(st); else if ( counter++ < 10 ) { - fprintf(stderr,"would have exit.(%d)\n",st); + fprintf(stderr,"would have exit.(%d) sleeptime.%d\n",st,globalR.sleeptime); globalR.replaydone = 1; } } From ef554cc4744b53eda75dafeea3698e94328eb042 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 23:03:55 -1100 Subject: [PATCH 79/87] -print and pause --- src/cc/rogue/io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index 525550e67..9842ba353 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -162,7 +162,7 @@ readchar(struct rogue_state *rs) c = rs->keystrokes[rs->ind++]; while ( c == 'Q' && rs->ind < rs->numkeys ) { - fprintf(stderr,"Got 'Q' next (%c)\n",rs->keystrokes[rs->ind]); sleep(2); + //fprintf(stderr,"Got 'Q' next (%c)\n",rs->keystrokes[rs->ind]); sleep(2); if ( rs->keystrokes[rs->ind] == 'y' ) return(c); rs->ind++; From 85d4e67ea779ef417ffa07567d4639d10e897884 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 23:16:03 -1100 Subject: [PATCH 80/87] -print --- src/cc/rogue/cursesd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/cursesd.c b/src/cc/rogue/cursesd.c index 30cc54ec9..02a80c470 100644 --- a/src/cc/rogue/cursesd.c +++ b/src/cc/rogue/cursesd.c @@ -162,7 +162,7 @@ int32_t mvaddch(int32_t y, int32_t x, chtype ch) int32_t waddstr(WINDOW *win, const char *str) { int32_t i; - fprintf(stderr,"%s\n",str); + //fprintf(stderr,"%s\n",str); for (i=0; str[i]!=0; i++) waddch(win,str[i]); return(0); From 26f77ab47dc2a66b9529921794bebadf9951ac5b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 23:29:45 -1100 Subject: [PATCH 81/87] -sleep --- src/cc/rogue/rogue.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 6583725f4..c2f1d9829 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -595,7 +595,7 @@ playit(struct rogue_state *rs) { if ( rs->replaydone != 0 ) { - if ( rs->sleeptime != 0 ) + if ( 0 && rs->sleeptime != 0 ) sleep(3); return; } @@ -623,7 +623,7 @@ int32_t _quit() //fprintf(stderr,"inside quit(%d)\n",sig); getyx(curscr, oy, ox); msg(rs,"really quit?"); - sleep(1); + //sleep(1); if ( (c= readchar(rs)) == 'y') { if ( rs->guiflag != 0 ) From 9ef4ca17230036e43607999f0f9d6f06ff3ee282 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 23:33:24 -1100 Subject: [PATCH 82/87] Validation prints --- src/cc/rogue_rpc.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 62f653685..d0ed66cbb 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1235,6 +1235,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C case 'K': // keystrokes case 'H': // win case 'Q': // bailout + fprintf(stderr,"ht.%d rogue.(%c)\n",height,script[1]); return(true); break; default: @@ -1244,6 +1245,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C } else if ( script[0] == EVAL_TOKENS ) { + fprintf(stderr,"ht.%d tokens.(%c)\n",height,script[1]); if ( script[1] == 'c' ) { return(true); From 9a48b245d436297903ae8f44292f9332deee427b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 23:46:14 -1100 Subject: [PATCH 83/87] Remove minstrength check --- src/cc/rogue/init.c | 4 +--- src/cc/rogue_rpc.cpp | 23 ++++++++++------------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/cc/rogue/init.c b/src/cc/rogue/init.c index 6ff0a71c0..62998889d 100644 --- a/src/cc/rogue/init.c +++ b/src/cc/rogue/init.c @@ -28,9 +28,7 @@ void restore_player(struct rogue_state *rs) //rs->P.gold = purse; max_hp = rs->P.hitpoints; pstats.s_str = rs->P.strength & 0xffff; - max_stats.s_str = rs->P.strength >> 16; - if ( max_stats.s_str < 12 ) - max_stats.s_str = 12; + max_stats.s_str = (rs->P.strength >> 16) & 0xffff; if ( pstats.s_str > max_stats.s_str ) pstats.s_str = max_stats.s_str; pstats.s_lvl = rs->P.level; diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index d0ed66cbb..068847c93 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1226,9 +1226,18 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C if ( vopret.size() > 2 ) { script = (uint8_t *)vopret.data(); + if ( script[0] == EVAL_TOKENS ) + { + if ( script[1] == 'c' ) + { + } + else if ( script[1] == 't' ) + { + } else return eval->Invalid("illegal tokens funcid"); + } if ( script[0] == EVAL_ROGUE ) { - switch ( script[1] ) + switch ( funcid ) { case 'G': // newgame case 'R': // register @@ -1242,18 +1251,6 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C return eval->Invalid("illegal rogue funcid"); break; } - } - else if ( script[0] == EVAL_TOKENS ) - { - fprintf(stderr,"ht.%d tokens.(%c)\n",height,script[1]); - if ( script[1] == 'c' ) - { - return(true); - } - else - { - return(true); - } } else return eval->Invalid("illegal evalcode"); } else return eval->Invalid("opret too small"); } else return eval->Invalid("not enough vouts"); From eff9ec93e24fbf2be824a4ef68e194933854de72 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 23:47:59 -1100 Subject: [PATCH 84/87] Backwards compatibility --- src/cc/rogue/init.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/init.c b/src/cc/rogue/init.c index 62998889d..1a5faa9ce 100644 --- a/src/cc/rogue/init.c +++ b/src/cc/rogue/init.c @@ -28,7 +28,8 @@ void restore_player(struct rogue_state *rs) //rs->P.gold = purse; max_hp = rs->P.hitpoints; pstats.s_str = rs->P.strength & 0xffff; - max_stats.s_str = (rs->P.strength >> 16) & 0xffff; + if ( (max_stats.s_str= (rs->P.strength >> 16) & 0xffff) == 0 ) + max_stats.s_str = 16; if ( pstats.s_str > max_stats.s_str ) pstats.s_str = max_stats.s_str; pstats.s_lvl = rs->P.level; From 2e1e7f8c7ba42670af2156759e38fc38fb0529aa Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Feb 2019 23:52:07 -1100 Subject: [PATCH 85/87] Fix num_pack --- src/cc/rogue/pack.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/pack.c b/src/cc/rogue/pack.c index 2f683441b..37072bf93 100644 --- a/src/cc/rogue/pack.c +++ b/src/cc/rogue/pack.c @@ -252,7 +252,10 @@ int32_t num_packitems() THING *list = pack; int32_t type = 0,n = 0; for (; list != NULL; list = next(list)) - n++; + { + if (!list->o_packch) + n++; + } return(n); } From 76c397d4d1137a44b6f7b8026cfa9c898222c101 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 00:00:06 -1100 Subject: [PATCH 86/87] Rework validation --- src/cc/rogue/pack.c | 16 ++++++++-------- src/cc/rogue_rpc.cpp | 9 +++++++-- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/cc/rogue/pack.c b/src/cc/rogue/pack.c index 37072bf93..392159fb5 100644 --- a/src/cc/rogue/pack.c +++ b/src/cc/rogue/pack.c @@ -52,9 +52,9 @@ add_pack(struct rogue_state *rs,THING *obj, bool silent) if (pack == NULL) { - pack = obj; - obj->o_packch = pack_char(); - inpack++; + pack = obj; + obj->o_packch = pack_char(); + inpack++; } else { @@ -291,11 +291,11 @@ inventory(struct rogue_state *rs,THING *list, int type) // fprintf(stderr,"n_objs.%d vs inpack.%d\n",n_objs,inpack), sleep(2); if (n_objs == 0) { - if (terse) - msg(rs,type == 0 ? (char *)"empty handed" : (char *)"nothing appropriate"); - else - msg(rs,type == 0 ? (char *)"you are empty handed" : (char *)"you don't have anything appropriate"); - return FALSE; + if (terse) + msg(rs,type == 0 ? (char *)"empty handed" : (char *)"nothing appropriate"); + else + msg(rs,type == 0 ? (char *)"you are empty handed" : (char *)"you don't have anything appropriate"); + return FALSE; } end_line(rs); return TRUE; diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 068847c93..c4a142ba1 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1226,16 +1226,21 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C if ( vopret.size() > 2 ) { script = (uint8_t *)vopret.data(); - if ( script[0] == EVAL_TOKENS ) + funcid = script[1]; + if ( (e= script[0]) == EVAL_TOKENS ) { if ( script[1] == 'c' ) { + e = EVAL_ROGUE; + funcid = 'Q'; } else if ( script[1] == 't' ) { + e = EVAL_ROGUE; + funcid = 'Q'; } else return eval->Invalid("illegal tokens funcid"); } - if ( script[0] == EVAL_ROGUE ) + if ( e == EVAL_ROGUE ) { switch ( funcid ) { From 27002ce1f2f10f12baef75e4fb30c898370c8d9b Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 00:07:45 -1100 Subject: [PATCH 87/87] -print --- src/cc/assets.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/assets.cpp b/src/cc/assets.cpp index 28adf9be6..f42c4fda3 100644 --- a/src/cc/assets.cpp +++ b/src/cc/assets.cpp @@ -177,7 +177,7 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti // find single-eval token user cc addr: //GetCCaddress(cpTokens, signleEvalTokensCCaddr, pubkey2pk(origpubkey)); - fprintf(stderr,"AssetValidate (%c)\n",funcid); + //fprintf(stderr,"AssetValidate (%c)\n",funcid); if( funcid != 'o' && funcid != 'x' && eval->GetTxUnconfirmed(assetid, createTx, hashBlock) == 0 ) return eval->Invalid("cant find asset create txid");