@@ -28,8 +28,8 @@ CC = @CC@
|
||||
#CFLAGS=-O2
|
||||
CFLAGS= @CFLAGS@ -fPIC
|
||||
|
||||
#LIBS=-lcurses
|
||||
LIBS = @LIBS@
|
||||
LIBS=-lcurses -lcurl
|
||||
#LIBS = @LIBS@
|
||||
|
||||
#RM=rm -f
|
||||
RM = rm -f
|
||||
|
||||
@@ -1,270 +0,0 @@
|
||||
/* config.h. Generated from config.h.in by configure. */
|
||||
/* config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Define if scorefile is top scores, not top players */
|
||||
#define ALLSCORES 1
|
||||
|
||||
/* Define if checktime feature should be enabled */
|
||||
/* #undef CHECKTIME */
|
||||
|
||||
/* Define to group owner of setgid executable */
|
||||
/* #undef GROUPOWNER */
|
||||
|
||||
/* Define to 1 if you have the `alarm' function. */
|
||||
#define HAVE_ALARM 1
|
||||
|
||||
/* Define to 1 if you have the <arpa/inet.h> header file. */
|
||||
#define HAVE_ARPA_INET_H 1
|
||||
|
||||
/* Define to 1 if libcurses is requested */
|
||||
#define HAVE_CURSES_H 1
|
||||
|
||||
/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
|
||||
/* #undef HAVE_DOPRNT */
|
||||
|
||||
/* Define to 1 if you have the `erasechar' function. */
|
||||
#define HAVE_ERASECHAR 1
|
||||
|
||||
/* Define if ncurses has ESCDELAY variable */
|
||||
#define HAVE_ESCDELAY 1
|
||||
|
||||
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||
#define HAVE_FCNTL_H 1
|
||||
|
||||
/* Define to 1 if you have the `fork' function. */
|
||||
#define HAVE_FORK 1
|
||||
|
||||
/* Define to 1 if you have the `getgid' function. */
|
||||
#define HAVE_GETGID 1
|
||||
|
||||
/* Define to 1 if you have the `getloadavg' function. */
|
||||
#define HAVE_GETLOADAVG 1
|
||||
|
||||
/* Define to 1 if you have the `getpass' function. */
|
||||
#define HAVE_GETPASS 1
|
||||
|
||||
/* Define to 1 if you have the `getpwuid' function. */
|
||||
#define HAVE_GETPWUID 1
|
||||
|
||||
/* Define to 1 if you have the `getuid' function. */
|
||||
#define HAVE_GETUID 1
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the `killchar' function. */
|
||||
#define HAVE_KILLCHAR 1
|
||||
|
||||
/* Define to 1 if you have the <limits.h> header file. */
|
||||
#define HAVE_LIMITS_H 1
|
||||
|
||||
/* Define to 1 if you have the `loadav' function. */
|
||||
/* #undef HAVE_LOADAV */
|
||||
|
||||
/* Define to 1 if `lstat' has the bug that it succeeds when given the
|
||||
zero-length file name argument. */
|
||||
/* #undef HAVE_LSTAT_EMPTY_STRING_BUG */
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* Define to 1 if you have the `memset' function. */
|
||||
#define HAVE_MEMSET 1
|
||||
|
||||
/* Define to 1 if libncurses is requested */
|
||||
/* #undef HAVE_NCURSES_H */
|
||||
|
||||
/* Define to 1 if you have the <ncurses/term.h> header file. */
|
||||
/* #undef HAVE_NCURSES_TERM_H */
|
||||
|
||||
/* Define to 1 if you have the `nlist' function. */
|
||||
/* #undef HAVE_NLIST */
|
||||
|
||||
/* Define to 1 if you have the <nlist.h> header file. */
|
||||
#define HAVE_NLIST_H 1
|
||||
|
||||
/* Define to 1 if you have the <process.h> header file. */
|
||||
/* #undef HAVE_PROCESS_H */
|
||||
|
||||
/* Define to 1 if you have the <pwd.h> header file. */
|
||||
#define HAVE_PWD_H 1
|
||||
|
||||
/* Define to 1 if you have the `setenv' function. */
|
||||
#define HAVE_SETENV 1
|
||||
|
||||
/* Define to 1 if you have the `setgid' function. */
|
||||
#define HAVE_SETGID 1
|
||||
|
||||
/* Define to 1 if you have the `setregid' function. */
|
||||
#define HAVE_SETREGID 1
|
||||
|
||||
/* Define to 1 if you have the `setresgid' function. */
|
||||
/* #undef HAVE_SETRESGID */
|
||||
|
||||
/* Define to 1 if you have the `setresuid' function. */
|
||||
/* #undef HAVE_SETRESUID */
|
||||
|
||||
/* Define to 1 if you have the `setreuid' function. */
|
||||
#define HAVE_SETREUID 1
|
||||
|
||||
/* Define to 1 if you have the `setuid' function. */
|
||||
#define HAVE_SETUID 1
|
||||
|
||||
/* Define to 1 if you have the `spawnl' function. */
|
||||
/* #undef HAVE_SPAWNL */
|
||||
|
||||
/* Define to 1 if `stat' has the bug that it succeeds when given the
|
||||
zero-length file name argument. */
|
||||
/* #undef HAVE_STAT_EMPTY_STRING_BUG */
|
||||
|
||||
/* Define to 1 if stdbool.h conforms to C99. */
|
||||
#define HAVE_STDBOOL_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#define HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the `strchr' function. */
|
||||
#define HAVE_STRCHR 1
|
||||
|
||||
/* Define to 1 if you have the `strerror' function. */
|
||||
#define HAVE_STRERROR 1
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#define HAVE_STRINGS_H 1
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/ioctl.h> header file. */
|
||||
#define HAVE_SYS_IOCTL_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/utsname.h> header file. */
|
||||
#define HAVE_SYS_UTSNAME_H 1
|
||||
|
||||
/* Define to 1 if you have the <termios.h> header file. */
|
||||
#define HAVE_TERMIOS_H 1
|
||||
|
||||
/* Define to 1 if you have the <term.h> header file. */
|
||||
#define HAVE_TERM_H 1
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Define to 1 if you have the <utmp.h> header file. */
|
||||
#define HAVE_UTMP_H 1
|
||||
|
||||
/* Define to 1 if you have the `vfork' function. */
|
||||
#define HAVE_VFORK 1
|
||||
|
||||
/* Define to 1 if you have the <vfork.h> header file. */
|
||||
/* #undef HAVE_VFORK_H */
|
||||
|
||||
/* Define to 1 if you have the `vprintf' function. */
|
||||
#define HAVE_VPRINTF 1
|
||||
|
||||
/* Define to 1 if `fork' works. */
|
||||
#define HAVE_WORKING_FORK 1
|
||||
|
||||
/* Define to 1 if `vfork' works. */
|
||||
#define HAVE_WORKING_VFORK 1
|
||||
|
||||
/* Define to 1 if the system has the type `_Bool'. */
|
||||
#define HAVE__BOOL 1
|
||||
|
||||
/* Define to 1 if you have the `_spawnl' function. */
|
||||
/* #undef HAVE__SPAWNL */
|
||||
|
||||
/* define if we should use program's load average function instead of system
|
||||
*/
|
||||
/* #undef LOADAV */
|
||||
|
||||
/* Define to file to use for scoreboard lockfile */
|
||||
#define LOCKFILE "rogue.lck"
|
||||
|
||||
/* Define to 1 if `lstat' dereferences a symlink specified with a trailing
|
||||
slash. */
|
||||
/* #undef LSTAT_FOLLOWS_SLASHED_SYMLINK */
|
||||
|
||||
/* Define to include wizard mode */
|
||||
/* #undef MASTER */
|
||||
|
||||
/* Define if maxusers feature should be enabled */
|
||||
/* #undef MAXLOAD */
|
||||
|
||||
/* Define if maxusers feature should be enabled */
|
||||
/* #undef MAXUSERS */
|
||||
|
||||
/* kernel file to pass to nlist() when reading load average (unlikely to work)
|
||||
*/
|
||||
/* #undef NAMELIST */
|
||||
|
||||
/* word for the number of scores to store in scoreboard */
|
||||
#define NUMNAME "Ten"
|
||||
|
||||
/* number of scores to store in scoreboard */
|
||||
#define NUMSCORES 10
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT "yendor@rogueforge.net"
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "Rogue"
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "Rogue 5.4.4"
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "rogue"
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "5.4.4"
|
||||
|
||||
/* Define crypt(3) wizard mode password */
|
||||
/* #undef PASSWD */
|
||||
|
||||
/* Define as the return type of signal handlers (`int' or `void'). */
|
||||
#define RETSIGTYPE void
|
||||
|
||||
/* Define to file to use for scoreboard */
|
||||
#define SCOREFILE "rogue.scr"
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Define to 1 if your <sys/time.h> declares `struct tm'. */
|
||||
/* #undef TM_IN_SYS_TIME */
|
||||
|
||||
/* define if we should use program's user counting function instead of
|
||||
system's */
|
||||
/* #undef UCOUNT */
|
||||
|
||||
/* utmp like file to pass to ucount() when counting online users (unlikely to
|
||||
work) */
|
||||
/* #undef UTMP */
|
||||
|
||||
/* Define to empty if `const' does not conform to ANSI C. */
|
||||
/* #undef const */
|
||||
|
||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||
/* #undef gid_t */
|
||||
|
||||
/* Define to `int' if <sys/types.h> does not define. */
|
||||
/* #undef pid_t */
|
||||
|
||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
/* #undef size_t */
|
||||
|
||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||
/* #undef uid_t */
|
||||
|
||||
/* Define as `fork' if `vfork' does not work. */
|
||||
/* #undef vfork */
|
||||
@@ -34,6 +34,7 @@ void restore_player(struct rogue_state *rs)
|
||||
int32_t i,total = 0; THING *obj;
|
||||
//rs->P.gold = purse;
|
||||
max_hp = rs->P.hitpoints;
|
||||
//pstats.s_hpt = max_hp;
|
||||
pstats.s_str = rs->P.strength & 0xffff;
|
||||
if ( (max_stats.s_str= (rs->P.strength >> 16) & 0xffff) == 0 )
|
||||
max_stats.s_str = 16;
|
||||
|
||||
@@ -160,6 +160,18 @@ readchar(struct rogue_state *rs)
|
||||
if ( rs->ind < rs->numkeys )
|
||||
{
|
||||
c = rs->keystrokes[rs->ind++];
|
||||
if ( 0 )
|
||||
{
|
||||
static FILE *fp; static int32_t counter;
|
||||
if ( fp == 0 )
|
||||
fp = fopen("log","wb");
|
||||
if ( fp != 0 )
|
||||
{
|
||||
fprintf(fp,"%d: (%c) hp.%d\n",counter,c,pstats.s_hpt);
|
||||
fflush(fp);
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
while ( c == 'Q' && rs->ind < rs->numkeys )
|
||||
{
|
||||
//fprintf(stderr,"Got 'Q' next (%c)\n",rs->keystrokes[rs->ind]); sleep(2);
|
||||
|
||||
@@ -20,10 +20,17 @@
|
||||
#include <memory.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <curl/curl.h>
|
||||
#include <curl/easy.h>
|
||||
|
||||
char USERPASS[8192]; uint16_t ROGUE_PORT;
|
||||
extern char Gametxidstr[67];
|
||||
|
||||
#define SMALLVAL 0.000000000000001
|
||||
#define SATOSHIDEN ((uint64_t)100000000L)
|
||||
#define dstr(x) ((double)(x) / SATOSHIDEN)
|
||||
#define KOMODO_ASSETCHAIN_MAXLEN 65
|
||||
char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
|
||||
|
||||
#ifndef _BITS256
|
||||
#define _BITS256
|
||||
@@ -31,6 +38,15 @@ union _bits256 { uint8_t bytes[32]; uint16_t ushorts[16]; uint32_t uints[8]; uin
|
||||
typedef union _bits256 bits256;
|
||||
#endif
|
||||
|
||||
double OS_milliseconds()
|
||||
{
|
||||
struct timeval tv; double millis;
|
||||
gettimeofday(&tv,NULL);
|
||||
millis = ((double)tv.tv_sec * 1000. + (double)tv.tv_usec / 1000.);
|
||||
//printf("tv_sec.%ld usec.%d %f\n",tv.tv_sec,tv.tv_usec,millis);
|
||||
return(millis);
|
||||
}
|
||||
|
||||
int32_t _unhex(char c)
|
||||
{
|
||||
if ( c >= '0' && c <= '9' )
|
||||
@@ -167,6 +183,23 @@ char *clonestr(char *str)
|
||||
strcpy(clone,str);
|
||||
return(clone);
|
||||
}
|
||||
|
||||
char *parse_conf_line(char *line,char *field)
|
||||
{
|
||||
line += strlen(field);
|
||||
for (; *line!='='&&*line!=0; line++)
|
||||
break;
|
||||
if ( *line == 0 )
|
||||
return(0);
|
||||
if ( *line == '=' )
|
||||
line++;
|
||||
while ( line[strlen(line)-1] == '\r' || line[strlen(line)-1] == '\n' || line[strlen(line)-1] == ' ' )
|
||||
line[strlen(line)-1] = 0;
|
||||
//printf("LINE.(%s)\n",line);
|
||||
_stripwhite(line,0);
|
||||
return(clonestr(line));
|
||||
}
|
||||
|
||||
int32_t safecopy(char *dest,char *src,long len)
|
||||
{
|
||||
int32_t i = -1;
|
||||
@@ -246,9 +279,522 @@ uint8_t *OS_fileptr(long *allocsizep,char *fname)
|
||||
return((uint8_t *)retptr);
|
||||
}
|
||||
|
||||
struct MemoryStruct { char *memory; size_t size; };
|
||||
struct return_string { char *ptr; size_t len; };
|
||||
|
||||
// return data from the server
|
||||
#define CURL_GLOBAL_ALL (CURL_GLOBAL_SSL|CURL_GLOBAL_WIN32)
|
||||
#define CURL_GLOBAL_SSL (1<<0)
|
||||
#define CURL_GLOBAL_WIN32 (1<<1)
|
||||
|
||||
|
||||
/************************************************************************
|
||||
*
|
||||
* Initialize the string handler so that it is thread safe
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
void init_string(struct return_string *s)
|
||||
{
|
||||
s->len = 0;
|
||||
s->ptr = (char *)calloc(1,s->len+1);
|
||||
if ( s->ptr == NULL )
|
||||
{
|
||||
fprintf(stderr,"init_string malloc() failed\n");
|
||||
exit(-1);
|
||||
}
|
||||
s->ptr[0] = '\0';
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
*
|
||||
* Use the "writer" to accumulate text until done
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
size_t accumulatebytes(void *ptr,size_t size,size_t nmemb,struct return_string *s)
|
||||
{
|
||||
size_t new_len = s->len + size*nmemb;
|
||||
s->ptr = (char *)realloc(s->ptr,new_len+1);
|
||||
if ( s->ptr == NULL )
|
||||
{
|
||||
fprintf(stderr, "accumulate realloc() failed\n");
|
||||
exit(-1);
|
||||
}
|
||||
memcpy(s->ptr+s->len,ptr,size*nmemb);
|
||||
s->ptr[new_len] = '\0';
|
||||
s->len = new_len;
|
||||
return(size * nmemb);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
*
|
||||
* return the current system time in milliseconds
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
#define EXTRACT_BITCOIND_RESULT // if defined, ensures error is null and returns the "result" field
|
||||
#ifdef EXTRACT_BITCOIND_RESULT
|
||||
|
||||
/************************************************************************
|
||||
*
|
||||
* perform post processing of the results
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
char *post_process_bitcoind_RPC(char *debugstr,char *command,char *rpcstr,char *params)
|
||||
{
|
||||
long i,j,len; char *retstr = 0; cJSON *json,*result,*error;
|
||||
//printf("<<<<<<<<<<< bitcoind_RPC: %s post_process_bitcoind_RPC.%s.[%s]\n",debugstr,command,rpcstr);
|
||||
if ( command == 0 || rpcstr == 0 || rpcstr[0] == 0 )
|
||||
{
|
||||
if ( strcmp(command,"signrawtransaction") != 0 )
|
||||
printf("<<<<<<<<<<< bitcoind_RPC: %s post_process_bitcoind_RPC.%s.[%s]\n",debugstr,command,rpcstr);
|
||||
return(rpcstr);
|
||||
}
|
||||
json = cJSON_Parse(rpcstr);
|
||||
if ( json == 0 )
|
||||
{
|
||||
printf("<<<<<<<<<<< bitcoind_RPC: %s post_process_bitcoind_RPC.%s can't parse.(%s) params.(%s)\n",debugstr,command,rpcstr,params);
|
||||
free(rpcstr);
|
||||
return(0);
|
||||
}
|
||||
result = cJSON_GetObjectItem(json,"result");
|
||||
error = cJSON_GetObjectItem(json,"error");
|
||||
if ( error != 0 && result != 0 )
|
||||
{
|
||||
if ( (error->type&0xff) == cJSON_NULL && (result->type&0xff) != cJSON_NULL )
|
||||
{
|
||||
retstr = cJSON_Print(result);
|
||||
len = strlen(retstr);
|
||||
if ( retstr[0] == '"' && retstr[len-1] == '"' )
|
||||
{
|
||||
for (i=1,j=0; i<len-1; i++,j++)
|
||||
retstr[j] = retstr[i];
|
||||
retstr[j] = 0;
|
||||
}
|
||||
}
|
||||
else if ( (error->type&0xff) != cJSON_NULL || (result->type&0xff) != cJSON_NULL )
|
||||
{
|
||||
if ( strcmp(command,"signrawtransaction") != 0 )
|
||||
printf("<<<<<<<<<<< bitcoind_RPC: %s post_process_bitcoind_RPC (%s) error.%s\n",debugstr,command,rpcstr);
|
||||
}
|
||||
free(rpcstr);
|
||||
} else retstr = rpcstr;
|
||||
free_json(json);
|
||||
//fprintf(stderr,"<<<<<<<<<<< bitcoind_RPC: postprocess returns.(%s)\n",retstr);
|
||||
return(retstr);
|
||||
}
|
||||
#endif
|
||||
|
||||
/************************************************************************
|
||||
*
|
||||
* perform the query
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
char *bitcoind_RPC(char **retstrp,char *debugstr,char *url,char *userpass,char *command,char *params)
|
||||
{
|
||||
static int didinit,count,count2; static double elapsedsum,elapsedsum2;
|
||||
struct curl_slist *headers = NULL; struct return_string s; CURLcode res; CURL *curl_handle;
|
||||
char *bracket0,*bracket1,*databuf = 0; long len; int32_t specialcase,numretries; double starttime;
|
||||
if ( didinit == 0 )
|
||||
{
|
||||
didinit = 1;
|
||||
curl_global_init(CURL_GLOBAL_ALL); //init the curl session
|
||||
}
|
||||
numretries = 0;
|
||||
if ( debugstr != 0 && strcmp(debugstr,"BTCD") == 0 && command != 0 && strcmp(command,"SuperNET") == 0 )
|
||||
specialcase = 1;
|
||||
else specialcase = 0;
|
||||
if ( url[0] == 0 )
|
||||
strcpy(url,"http://127.0.0.1:7876/nxt");
|
||||
if ( specialcase != 0 && 0 )
|
||||
printf("<<<<<<<<<<< bitcoind_RPC: debug.(%s) url.(%s) command.(%s) params.(%s)\n",debugstr,url,command,params);
|
||||
try_again:
|
||||
if ( retstrp != 0 )
|
||||
*retstrp = 0;
|
||||
starttime = OS_milliseconds();
|
||||
curl_handle = curl_easy_init();
|
||||
init_string(&s);
|
||||
headers = curl_slist_append(0,"Expect:");
|
||||
|
||||
curl_easy_setopt(curl_handle,CURLOPT_USERAGENT,"mozilla/4.0");//"Mozilla/4.0 (compatible; )");
|
||||
curl_easy_setopt(curl_handle,CURLOPT_HTTPHEADER, headers);
|
||||
curl_easy_setopt(curl_handle,CURLOPT_URL, url);
|
||||
curl_easy_setopt(curl_handle,CURLOPT_WRITEFUNCTION, (void *)accumulatebytes); // send all data to this function
|
||||
curl_easy_setopt(curl_handle,CURLOPT_WRITEDATA, &s); // we pass our 's' struct to the callback
|
||||
curl_easy_setopt(curl_handle,CURLOPT_NOSIGNAL, 1L); // supposed to fix "Alarm clock" and long jump crash
|
||||
curl_easy_setopt(curl_handle,CURLOPT_NOPROGRESS, 1L); // no progress callback
|
||||
if ( strncmp(url,"https",5) == 0 )
|
||||
{
|
||||
curl_easy_setopt(curl_handle,CURLOPT_SSL_VERIFYPEER,0);
|
||||
curl_easy_setopt(curl_handle,CURLOPT_SSL_VERIFYHOST,0);
|
||||
}
|
||||
if ( userpass != 0 )
|
||||
curl_easy_setopt(curl_handle,CURLOPT_USERPWD, userpass);
|
||||
databuf = 0;
|
||||
if ( params != 0 )
|
||||
{
|
||||
if ( command != 0 && specialcase == 0 )
|
||||
{
|
||||
len = strlen(params);
|
||||
if ( len > 0 && params[0] == '[' && params[len-1] == ']' ) {
|
||||
bracket0 = bracket1 = (char *)"";
|
||||
}
|
||||
else
|
||||
{
|
||||
bracket0 = (char *)"[";
|
||||
bracket1 = (char *)"]";
|
||||
}
|
||||
|
||||
databuf = (char *)malloc(256 + strlen(command) + strlen(params));
|
||||
sprintf(databuf,"{\"id\":\"jl777\",\"method\":\"%s\",\"params\":%s%s%s}",command,bracket0,params,bracket1);
|
||||
//printf("url.(%s) userpass.(%s) databuf.(%s)\n",url,userpass,databuf);
|
||||
//
|
||||
} //else if ( specialcase != 0 ) fprintf(stderr,"databuf.(%s)\n",params);
|
||||
curl_easy_setopt(curl_handle,CURLOPT_POST,1L);
|
||||
if ( databuf != 0 )
|
||||
curl_easy_setopt(curl_handle,CURLOPT_POSTFIELDS,databuf);
|
||||
else curl_easy_setopt(curl_handle,CURLOPT_POSTFIELDS,params);
|
||||
}
|
||||
//laststart = milliseconds();
|
||||
res = curl_easy_perform(curl_handle);
|
||||
curl_slist_free_all(headers);
|
||||
curl_easy_cleanup(curl_handle);
|
||||
if ( databuf != 0 ) // clean up temporary buffer
|
||||
{
|
||||
free(databuf);
|
||||
databuf = 0;
|
||||
}
|
||||
if ( res != CURLE_OK )
|
||||
{
|
||||
numretries++;
|
||||
if ( specialcase != 0 )
|
||||
{
|
||||
printf("<<<<<<<<<<< bitcoind_RPC.(%s): BTCD.%s timeout params.(%s) s.ptr.(%s) err.%d\n",url,command,params,s.ptr,res);
|
||||
free(s.ptr);
|
||||
return(0);
|
||||
}
|
||||
else if ( numretries >= 1 )
|
||||
{
|
||||
//printf("Maximum number of retries exceeded!\n");
|
||||
free(s.ptr);
|
||||
return(0);
|
||||
}
|
||||
if ( (rand() % 1000) == 0 )
|
||||
printf( "curl_easy_perform() failed: %s %s.(%s %s), retries: %d\n",curl_easy_strerror(res),debugstr,url,command,numretries);
|
||||
free(s.ptr);
|
||||
sleep((1<<numretries));
|
||||
goto try_again;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( command != 0 && specialcase == 0 )
|
||||
{
|
||||
count++;
|
||||
elapsedsum += (OS_milliseconds() - starttime);
|
||||
if ( (count % 1000000) == 0)
|
||||
printf("%d: ave %9.6f | elapsed %.3f millis | bitcoind_RPC.(%s) url.(%s)\n",count,elapsedsum/count,(OS_milliseconds() - starttime),command,url);
|
||||
if ( retstrp != 0 )
|
||||
{
|
||||
*retstrp = s.ptr;
|
||||
return(s.ptr);
|
||||
}
|
||||
return(post_process_bitcoind_RPC(debugstr,command,s.ptr,params));
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( 0 && specialcase != 0 )
|
||||
fprintf(stderr,"<<<<<<<<<<< bitcoind_RPC: BTCD.(%s) -> (%s)\n",params,s.ptr);
|
||||
count2++;
|
||||
elapsedsum2 += (OS_milliseconds() - starttime);
|
||||
if ( (count2 % 10000) == 0)
|
||||
printf("%d: ave %9.6f | elapsed %.3f millis | NXT calls.(%s) cmd.(%s)\n",count2,elapsedsum2/count2,(double)(OS_milliseconds() - starttime),url,command);
|
||||
return(s.ptr);
|
||||
}
|
||||
}
|
||||
printf("bitcoind_RPC: impossible case\n");
|
||||
free(s.ptr);
|
||||
return(0);
|
||||
}
|
||||
|
||||
static size_t WriteMemoryCallback(void *ptr,size_t size,size_t nmemb,void *data)
|
||||
{
|
||||
size_t realsize = (size * nmemb);
|
||||
struct MemoryStruct *mem = (struct MemoryStruct *)data;
|
||||
mem->memory = (char *)((ptr != 0) ? realloc(mem->memory,mem->size + realsize + 1) : malloc(mem->size + realsize + 1));
|
||||
if ( mem->memory != 0 )
|
||||
{
|
||||
if ( ptr != 0 )
|
||||
memcpy(&(mem->memory[mem->size]),ptr,realsize);
|
||||
mem->size += realsize;
|
||||
mem->memory[mem->size] = 0;
|
||||
}
|
||||
//printf("got %d bytes\n",(int32_t)(size*nmemb));
|
||||
return(realsize);
|
||||
}
|
||||
|
||||
char *curl_post(CURL **cHandlep,char *url,char *userpass,char *postfields,char *hdr0,char *hdr1,char *hdr2,char *hdr3)
|
||||
{
|
||||
struct MemoryStruct chunk; CURL *cHandle; long code; struct curl_slist *headers = 0;
|
||||
if ( (cHandle= *cHandlep) == NULL )
|
||||
*cHandlep = cHandle = curl_easy_init();
|
||||
else curl_easy_reset(cHandle);
|
||||
//#ifdef DEBUG
|
||||
//curl_easy_setopt(cHandle,CURLOPT_VERBOSE, 1);
|
||||
//#endif
|
||||
curl_easy_setopt(cHandle,CURLOPT_USERAGENT,"mozilla/4.0");//"Mozilla/4.0 (compatible; )");
|
||||
curl_easy_setopt(cHandle,CURLOPT_SSL_VERIFYPEER,0);
|
||||
//curl_easy_setopt(cHandle,CURLOPT_SSLVERSION,1);
|
||||
curl_easy_setopt(cHandle,CURLOPT_URL,url);
|
||||
curl_easy_setopt(cHandle,CURLOPT_CONNECTTIMEOUT,10);
|
||||
if ( userpass != 0 && userpass[0] != 0 )
|
||||
curl_easy_setopt(cHandle,CURLOPT_USERPWD,userpass);
|
||||
if ( postfields != 0 && postfields[0] != 0 )
|
||||
{
|
||||
curl_easy_setopt(cHandle,CURLOPT_POST,1);
|
||||
curl_easy_setopt(cHandle,CURLOPT_POSTFIELDS,postfields);
|
||||
}
|
||||
if ( hdr0 != NULL && hdr0[0] != 0 )
|
||||
{
|
||||
//printf("HDR0.(%s) HDR1.(%s) HDR2.(%s) HDR3.(%s)\n",hdr0!=0?hdr0:"",hdr1!=0?hdr1:"",hdr2!=0?hdr2:"",hdr3!=0?hdr3:"");
|
||||
headers = curl_slist_append(headers,hdr0);
|
||||
if ( hdr1 != 0 && hdr1[0] != 0 )
|
||||
headers = curl_slist_append(headers,hdr1);
|
||||
if ( hdr2 != 0 && hdr2[0] != 0 )
|
||||
headers = curl_slist_append(headers,hdr2);
|
||||
if ( hdr3 != 0 && hdr3[0] != 0 )
|
||||
headers = curl_slist_append(headers,hdr3);
|
||||
} //headers = curl_slist_append(0,"Expect:");
|
||||
if ( headers != 0 )
|
||||
curl_easy_setopt(cHandle,CURLOPT_HTTPHEADER,headers);
|
||||
//res = curl_easy_perform(cHandle);
|
||||
memset(&chunk,0,sizeof(chunk));
|
||||
curl_easy_setopt(cHandle,CURLOPT_WRITEFUNCTION,WriteMemoryCallback);
|
||||
curl_easy_setopt(cHandle,CURLOPT_WRITEDATA,(void *)&chunk);
|
||||
curl_easy_perform(cHandle);
|
||||
curl_easy_getinfo(cHandle,CURLINFO_RESPONSE_CODE,&code);
|
||||
if ( headers != 0 )
|
||||
curl_slist_free_all(headers);
|
||||
if ( code != 200 )
|
||||
printf("(%s) server responded with code %ld (%s)\n",url,code,chunk.memory);
|
||||
return(chunk.memory);
|
||||
}
|
||||
|
||||
uint16_t _komodo_userpass(char *username,char *password,FILE *fp)
|
||||
{
|
||||
char *rpcuser,*rpcpassword,*str,line[8192]; uint16_t port = 0;
|
||||
rpcuser = rpcpassword = 0;
|
||||
username[0] = password[0] = 0;
|
||||
while ( fgets(line,sizeof(line),fp) != 0 )
|
||||
{
|
||||
if ( line[0] == '#' )
|
||||
continue;
|
||||
//printf("line.(%s) %p %p\n",line,strstr(line,(char *)"rpcuser"),strstr(line,(char *)"rpcpassword"));
|
||||
if ( (str= strstr(line,(char *)"rpcuser")) != 0 )
|
||||
rpcuser = parse_conf_line(str,(char *)"rpcuser");
|
||||
else if ( (str= strstr(line,(char *)"rpcpassword")) != 0 )
|
||||
rpcpassword = parse_conf_line(str,(char *)"rpcpassword");
|
||||
else if ( (str= strstr(line,(char *)"rpcport")) != 0 )
|
||||
{
|
||||
port = atoi(parse_conf_line(str,(char *)"rpcport"));
|
||||
//fprintf(stderr,"rpcport.%u in file\n",port);
|
||||
}
|
||||
}
|
||||
if ( rpcuser != 0 && rpcpassword != 0 )
|
||||
{
|
||||
strcpy(username,rpcuser);
|
||||
strcpy(password,rpcpassword);
|
||||
}
|
||||
//printf("rpcuser.(%s) rpcpassword.(%s) KMDUSERPASS.(%s) %u\n",rpcuser,rpcpassword,KMDUSERPASS,port);
|
||||
if ( rpcuser != 0 )
|
||||
free(rpcuser);
|
||||
if ( rpcpassword != 0 )
|
||||
free(rpcpassword);
|
||||
return(port);
|
||||
}
|
||||
|
||||
/*void komodo_statefname(char *fname,char *symbol,char *str)
|
||||
{
|
||||
int32_t n,len;
|
||||
sprintf(fname,"%s",getDataDir());
|
||||
if ( (n= (int32_t)strlen(ASSETCHAINS_SYMBOL)) != 0 )
|
||||
{
|
||||
len = (int32_t)strlen(fname);
|
||||
if ( strcmp(ASSETCHAINS_SYMBOL,&fname[len - n]) == 0 )
|
||||
fname[len - n] = 0;
|
||||
else
|
||||
{
|
||||
printf("unexpected fname.(%s) vs %s [%s] n.%d len.%d (%s)\n",fname,symbol,ASSETCHAINS_SYMBOL,n,len,&fname[len - n]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef _WIN32
|
||||
strcat(fname,"\\");
|
||||
#else
|
||||
strcat(fname,"/");
|
||||
#endif
|
||||
}
|
||||
if ( symbol != 0 && symbol[0] != 0 && strcmp("KMD",symbol) != 0 )
|
||||
{
|
||||
strcat(fname,symbol);
|
||||
//printf("statefname.(%s) -> (%s)\n",symbol,fname);
|
||||
#ifdef _WIN32
|
||||
strcat(fname,"\\");
|
||||
#else
|
||||
strcat(fname,"/");
|
||||
#endif
|
||||
}
|
||||
strcat(fname,str);
|
||||
//printf("test.(%s) -> [%s] statename.(%s) %s\n",test,ASSETCHAINS_SYMBOL,symbol,fname);
|
||||
}*/
|
||||
|
||||
uint16_t komodo_userpass(char *userpass,char *symbol)
|
||||
{
|
||||
FILE *fp; uint16_t port = 0; char fname[512],username[512],password[512],confname[KOMODO_ASSETCHAIN_MAXLEN];
|
||||
userpass[0] = 0;
|
||||
if ( strcmp("KMD",symbol) == 0 )
|
||||
{
|
||||
#ifdef __APPLE__
|
||||
sprintf(confname,"Komodo.conf");
|
||||
#else
|
||||
sprintf(confname,"komodo.conf");
|
||||
#endif
|
||||
}
|
||||
else sprintf(confname,"%s.conf",symbol);
|
||||
//komodo_statefname(fname,symbol,confname);
|
||||
if ( (fp= fopen(confname,"rb")) != 0 )
|
||||
{
|
||||
port = _komodo_userpass(username,password,fp);
|
||||
sprintf(userpass,"%s:%s",username,password);
|
||||
if ( strcmp(symbol,ASSETCHAINS_SYMBOL) == 0 )
|
||||
strcpy(USERPASS,userpass);
|
||||
fclose(fp);
|
||||
}
|
||||
return(port);
|
||||
}
|
||||
|
||||
#define is_cJSON_True(json) ((json) != 0 && ((json)->type & 0xff) == cJSON_True)
|
||||
|
||||
char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port)
|
||||
{
|
||||
//static void *cHandle;
|
||||
char url[512],*retstr=0,*retstr2=0,postdata[8192];
|
||||
if ( params == 0 || params[0] == 0 )
|
||||
params = (char *)"[]";
|
||||
if ( strlen(params) < sizeof(postdata)-128 )
|
||||
{
|
||||
sprintf(url,(char *)"http://127.0.0.1:%u",port);
|
||||
sprintf(postdata,"{\"method\":\"%s\",\"params\":%s}",method,params);
|
||||
//printf("[%s] (%s) postdata.(%s) params.(%s) USERPASS.(%s)\n",ASSETCHAINS_SYMBOL,url,postdata,params,USERPASS);
|
||||
retstr2 = bitcoind_RPC(&retstr,(char *)"debug",url,userpass,method,params);
|
||||
//retstr = curl_post(&cHandle,url,USERPASS,postdata,0,0,0,0);
|
||||
}
|
||||
return(retstr2);
|
||||
}
|
||||
|
||||
#include "rogue.h"
|
||||
|
||||
void rogue_progress(struct rogue_state *rs,uint64_t seed,char *keystrokes,int32_t num)
|
||||
{
|
||||
char cmd[16384],hexstr[16384],params[32768],*retstr; int32_t i;
|
||||
if ( rs->guiflag != 0 && Gametxidstr[0] != 0 )
|
||||
{
|
||||
for (i=0; i<num; i++)
|
||||
sprintf(&hexstr[i<<1],"%02x",keystrokes[i]&0xff);
|
||||
hexstr[i<<1] = 0;
|
||||
if ( 0 )
|
||||
{
|
||||
sprintf(cmd,"./komodo-cli -ac_name=ROGUE cclib keystrokes 17 \\\"[%%22%s%%22,%%22%s%%22]\\\" >> keystrokes.log",Gametxidstr,hexstr);
|
||||
if ( system(cmd) != 0 )
|
||||
fprintf(stderr,"error issuing (%s)\n",cmd);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(params,"[\"keystrokes\",\"17\",\"[%%22%s%%22,%%22%s%%22]\"]",Gametxidstr,hexstr);
|
||||
if ( (retstr= komodo_issuemethod(USERPASS,"cclib",params,ROGUE_PORT)) != 0 )
|
||||
{
|
||||
//fprintf(stderr,"KEYSTROKES.(%s)\n",retstr);
|
||||
free(retstr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr)
|
||||
{
|
||||
char cmd[32768]; int32_t i,n,retval=-1; char params[1024],*filestr=0,*pname,*statusstr,*datastr,fname[128]; long allocsize; cJSON *retjson,*array,*item,*resultjson;
|
||||
if ( rs->guiflag == 0 )
|
||||
return(-1);
|
||||
if ( gametxidstr == 0 || *gametxidstr == 0 )
|
||||
return(retval);
|
||||
if ( 0 )
|
||||
{
|
||||
sprintf(fname,"%s.gameinfo",gametxidstr);
|
||||
sprintf(cmd,"./komodo-cli -ac_name=ROGUE cclib gameinfo 17 \\\"[%%22%s%%22]\\\" > %s",gametxidstr,fname);
|
||||
if ( system(cmd) != 0 )
|
||||
fprintf(stderr,"error issuing (%s)\n",cmd);
|
||||
else filestr = (char *)OS_fileptr(&allocsize,fname);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(params,"[\"gameinfo\",\"17\",\"[%%22%s%%22]\"]",gametxidstr);
|
||||
filestr = komodo_issuemethod(USERPASS,"cclib",params,ROGUE_PORT);
|
||||
}
|
||||
if ( filestr != 0 )
|
||||
{
|
||||
if ( (retjson= cJSON_Parse(filestr)) != 0 && (resultjson= jobj(retjson,"result")) != 0 )
|
||||
{
|
||||
//fprintf(stderr,"gameinfo.(%s)\n",jprint(resultjson,0));
|
||||
if ( (array= jarray(&n,resultjson,"players")) != 0 )
|
||||
{
|
||||
for (i=0; i<n; i++)
|
||||
{
|
||||
item = jitem(array,i);
|
||||
if ( is_cJSON_True(jobj(item,"ismine")) != 0 && (statusstr= jstr(item,"status")) != 0 )
|
||||
{
|
||||
if ( strcmp(statusstr,"registered") == 0 )
|
||||
{
|
||||
retval = 0;
|
||||
if ( (item= jobj(item,"player")) != 0 && (datastr= jstr(item,"data")) != 0 )
|
||||
{
|
||||
if ( (pname= jstr(item,"pname")) != 0 && strlen(pname) < MAXSTR-1 )
|
||||
strcpy(whoami,pname);
|
||||
decode_hex((uint8_t *)&rs->P,(int32_t)strlen(datastr)/2,datastr);
|
||||
fprintf(stderr,"set pname[%s] %s\n",pname==0?"":pname,jprint(item,0));
|
||||
rs->restoring = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
free_json(retjson);
|
||||
}
|
||||
free(filestr);
|
||||
}
|
||||
return(retval);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv, char **envp)
|
||||
{
|
||||
uint64_t seed; FILE *fp = 0;
|
||||
uint64_t seed; FILE *fp = 0; int32_t i,j,c; char userpass[8192];
|
||||
for (i=j=0; argv[0][i]!=0&&j<sizeof(ASSETCHAINS_SYMBOL); i++)
|
||||
{
|
||||
c = argv[0][i];
|
||||
if ( c == '\\' || c == '/' )
|
||||
{
|
||||
j = 0;
|
||||
continue;
|
||||
}
|
||||
ASSETCHAINS_SYMBOL[j++] = toupper(c);
|
||||
}
|
||||
ASSETCHAINS_SYMBOL[j++] = 0;
|
||||
ROGUE_PORT = komodo_userpass(userpass,ASSETCHAINS_SYMBOL);
|
||||
printf("ASSETCHAINS_SYMBOL.(%s) port.%u (%s)\n",ASSETCHAINS_SYMBOL,ROGUE_PORT,USERPASS); sleep(1);
|
||||
if ( argc == 2 && (fp=fopen(argv[1],"rb")) == 0 )
|
||||
{
|
||||
seed = atol(argv[1]);
|
||||
@@ -259,6 +805,11 @@ int main(int argc, char **argv, char **envp)
|
||||
{
|
||||
if ( fp != 0 )
|
||||
fclose(fp);
|
||||
if ( ROGUE_PORT == 0 )
|
||||
{
|
||||
printf("you must copy ROGUE.conf from ~/.komodo/ROGUE/ROGUE.conf (or equivalent location) to current dir\n");
|
||||
return(-1);
|
||||
}
|
||||
return(rogue(argc,argv,envp));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,7 +238,7 @@ death(struct rogue_state *rs,char monst)
|
||||
//struct tm *localtime(const time_t *);
|
||||
if ( rs->guiflag == 0 )
|
||||
{
|
||||
fprintf(stderr,"death during replay\n");
|
||||
fprintf(stderr,"death during replay by (%c)\n",monst); //sleep(3);
|
||||
rs->replaydone = (uint32_t)time(NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
* The main program, of course
|
||||
*/
|
||||
struct rogue_state globalR;
|
||||
void garbage_collect();
|
||||
char Gametxidstr[67];
|
||||
void garbage_collect();
|
||||
|
||||
void purge_obj_guess(struct obj_info *array,int32_t n)
|
||||
{
|
||||
@@ -152,71 +152,24 @@ int32_t flushkeystrokes(struct rogue_state *rs)
|
||||
}
|
||||
#else
|
||||
|
||||
uint8_t *OS_fileptr(long *allocsizep,char *fname);
|
||||
#define is_cJSON_True(json) ((json) != 0 && ((json)->type & 0xff) == cJSON_True)
|
||||
#ifdef BUILD_ROGUE
|
||||
// stubs for inside daemon
|
||||
|
||||
void rogue_progress(struct rogue_state *rs,uint64_t seed,char *keystrokes,int32_t num)
|
||||
{
|
||||
}
|
||||
|
||||
int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr)
|
||||
{
|
||||
char cmd[32768]; int32_t i,n,retval=-1; char *filestr,*pname,*statusstr,*datastr,fname[128]; long allocsize; cJSON *retjson,*array,*item;
|
||||
if ( gametxidstr == 0 || *gametxidstr == 0 )
|
||||
return(retval);
|
||||
sprintf(fname,"%s.gameinfo",gametxidstr);
|
||||
sprintf(cmd,"./komodo-cli -ac_name=ROGUE cclib gameinfo 17 \\\"[%%22%s%%22]\\\" > %s",gametxidstr,fname);
|
||||
if ( system(cmd) != 0 )
|
||||
fprintf(stderr,"error issuing (%s)\n",cmd);
|
||||
else
|
||||
{
|
||||
filestr = (char *)OS_fileptr(&allocsize,fname);
|
||||
if ( (retjson= cJSON_Parse(filestr)) != 0 )
|
||||
{
|
||||
if ( (array= jarray(&n,retjson,"players")) != 0 )
|
||||
{
|
||||
for (i=0; i<n; i++)
|
||||
{
|
||||
item = jitem(array,i);
|
||||
if ( is_cJSON_True(jobj(item,"ismine")) != 0 && (statusstr= jstr(item,"status")) != 0 )
|
||||
{
|
||||
if ( strcmp(statusstr,"registered") == 0 )
|
||||
{
|
||||
retval = 0;
|
||||
if ( (item= jobj(item,"player")) != 0 && (datastr= jstr(item,"data")) != 0 )
|
||||
{
|
||||
if ( (pname= jstr(item,"pname")) != 0 && strlen(pname) < MAXSTR-1 )
|
||||
strcpy(whoami,pname);
|
||||
decode_hex((uint8_t *)&rs->P,(int32_t)strlen(datastr)/2,datastr);
|
||||
fprintf(stderr,"set pname[%s] %s\n",pname==0?"":pname,jprint(item,0));
|
||||
rs->restoring = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
free_json(retjson);
|
||||
}
|
||||
free(filestr);
|
||||
}
|
||||
return(retval);
|
||||
}
|
||||
|
||||
void rogue_progress(uint64_t seed,char *keystrokes,int32_t num)
|
||||
{
|
||||
char cmd[16384],hexstr[16384]; int32_t i;
|
||||
if ( Gametxidstr[0] != 0 )
|
||||
{
|
||||
for (i=0; i<num; i++)
|
||||
sprintf(&hexstr[i<<1],"%02x",keystrokes[i]);
|
||||
hexstr[i<<1] = 0;
|
||||
sprintf(cmd,"./komodo-cli -ac_name=ROGUE cclib keystrokes 17 \\\"[%%22%s%%22,%%22%s%%22]\\\" >> keystrokes.log",Gametxidstr,hexstr);
|
||||
if ( system(cmd) != 0 )
|
||||
fprintf(stderr,"error issuing (%s)\n",cmd);
|
||||
}
|
||||
return(-1);
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t flushkeystrokes(struct rogue_state *rs)
|
||||
{
|
||||
if ( rs->num > 0 )
|
||||
{
|
||||
rogue_progress(rs->seed,rs->buffered,rs->num);
|
||||
rogue_progress(rs,rs->seed,rs->buffered,rs->num);
|
||||
memset(rs->buffered,0,sizeof(rs->buffered));
|
||||
rs->counter++;
|
||||
rs->num = 0;
|
||||
@@ -230,10 +183,10 @@ void rogue_bailout(struct rogue_state *rs)
|
||||
flushkeystrokes(rs);
|
||||
//sleep(5);
|
||||
return;
|
||||
fprintf(stderr,"bailing out\n");
|
||||
/*fprintf(stderr,"bailing out\n");
|
||||
sprintf(cmd,"./komodo-cli -ac_name=ROGUE cclib bailout 17 \\\"[%%22%s%%22]\\\" >> bailout.log",Gametxidstr);
|
||||
if ( system(cmd) != 0 )
|
||||
fprintf(stderr,"error issuing (%s)\n",cmd);
|
||||
fprintf(stderr,"error issuing (%s)\n",cmd);*/
|
||||
}
|
||||
|
||||
int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player,int32_t sleepmillis)
|
||||
@@ -356,6 +309,8 @@ int rogue(int argc, char **argv, char **envp)
|
||||
{
|
||||
char *env; int lowtime; struct rogue_state *rs = &globalR;
|
||||
memset(rs,0,sizeof(*rs));
|
||||
rs->guiflag = 1;
|
||||
rs->sleeptime = 1; // non-zero to allow refresh()
|
||||
if ( argc == 3 && strlen(argv[2]) == 64 )
|
||||
{
|
||||
rs->seed = atol(argv[1]);
|
||||
@@ -366,8 +321,6 @@ int rogue(int argc, char **argv, char **envp)
|
||||
return(-1);
|
||||
}
|
||||
} else rs->seed = 777;
|
||||
rs->guiflag = 1;
|
||||
rs->sleeptime = 1; // non-zero to allow refresh()
|
||||
md_init();
|
||||
|
||||
#ifdef MASTER
|
||||
@@ -607,7 +560,7 @@ playit(struct rogue_state *rs)
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( rs->needflush != 0 && rs->num > 1024 )
|
||||
if ( rs->needflush != 0 && rs->num > 8000 )
|
||||
{
|
||||
if ( flushkeystrokes(rs) == 0 )
|
||||
rs->needflush = 0;
|
||||
|
||||
@@ -371,7 +371,6 @@ struct rogue_state
|
||||
};
|
||||
extern struct rogue_state globalR;
|
||||
|
||||
|
||||
int rogue(int argc, char **argv, char **envp);
|
||||
void rogueiterate(struct rogue_state *rs);
|
||||
int32_t roguefname(char *fname,uint64_t seed,int32_t counter);
|
||||
@@ -380,6 +379,8 @@ int32_t rogue_restorepack(struct rogue_state *rs);
|
||||
void restore_player(struct rogue_state *rs);
|
||||
int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player,int32_t sleepmillis);
|
||||
void rogue_bailout(struct rogue_state *rs);
|
||||
void rogue_progress(struct rogue_state *rs,uint64_t seed,char *keystrokes,int32_t num);
|
||||
int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr);
|
||||
|
||||
#define ROGUE_MAXTOTAL (pstats.s_str*2)
|
||||
|
||||
|
||||
@@ -1432,7 +1432,7 @@ rs_write_object(struct rogue_state *rs,FILE *savef, THING *o)
|
||||
if ( o->_o._o_packch != 0 )
|
||||
{
|
||||
item = &rs->P.roguepack[rs->P.packsize];
|
||||
if ( pstats.s_hpt <= 0 )
|
||||
if ( 0 && pstats.s_hpt <= 0 )
|
||||
{
|
||||
//fprintf(stderr,"KILLED\n");
|
||||
rs->P.gold = -1;
|
||||
|
||||
Reference in New Issue
Block a user