@@ -692,6 +692,7 @@ int32_t cclib_parsehash(uint8_t *hash32,cJSON *item,int32_t len)
|
||||
|
||||
#elif BUILD_GAMESCC
|
||||
#include "gamescc.cpp"
|
||||
#include "rogue/cursesd.c"
|
||||
|
||||
#else
|
||||
#include "sudoku.cpp"
|
||||
|
||||
3450
src/cc/gamescc.cpp
3450
src/cc/gamescc.cpp
File diff suppressed because it is too large
Load Diff
105
src/cc/gamescc.h
105
src/cc/gamescc.h
@@ -1,10 +1,26 @@
|
||||
#ifndef H_GAMESCC_H
|
||||
#define H_GAMESCC_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef STANDALONE
|
||||
|
||||
#define ENABLE_WALLET
|
||||
extern CWallet* pwalletMain;
|
||||
|
||||
#include "CCinclude.h"
|
||||
#include "secp256k1.h"
|
||||
|
||||
std::string MYCCLIBNAME = (char *)"gamescc";
|
||||
|
||||
#define EVAL_GAMES (EVAL_FAUCET2+1)
|
||||
#define GAMES_TXFEE 10000
|
||||
#define GAMES_MAXITERATIONS 777
|
||||
#define GAMES_MAXKEYSTROKESGAP 60
|
||||
#define GAMES_MAXPLAYERS 64
|
||||
#define GAMES_REGISTRATIONSIZE (100 * 10000)
|
||||
#define GAMES_REGISTRATION 5
|
||||
|
||||
#define GAMES_RNGMULT 11109
|
||||
#define GAMES_RNGOFFSET 13849
|
||||
@@ -12,21 +28,40 @@ std::string MYCCLIBNAME = (char *)"gamescc";
|
||||
|
||||
#define MYCCNAME "games"
|
||||
|
||||
std::string Games_pname;
|
||||
#define GAMENAME "sudoku"
|
||||
|
||||
#define RPC_FUNCS \
|
||||
{ (char *)MYCCNAME, (char *)"rng", (char *)"hash,playerid", 1, 2, ' ', EVAL_GAMES }, \
|
||||
{ (char *)MYCCNAME, (char *)"rngnext", (char *)"seed", 1, 1, ' ', EVAL_GAMES }, \
|
||||
{ (char *)MYCCNAME, (char *)"create", (char *)"game,minplayers,maxplayers,buyin,numblocks", 5, 5, ' ', EVAL_GAMES }, \
|
||||
{ (char *)MYCCNAME, (char *)"info", (char *)"txid", 1, 1, ' ', EVAL_GAMES }, \
|
||||
{ (char *)MYCCNAME, (char *)"events", (char *)"hex", 1, 1, ' ', EVAL_GAMES }, \
|
||||
{ (char *)MYCCNAME, (char *)"register", (char *)"txid", 1, 1, ' ', EVAL_GAMES },
|
||||
{ (char *)MYCCNAME, (char *)"players", (char *)"no params", 0, 0, ' ', EVAL_GAMES }, \
|
||||
{ (char *)MYCCNAME, (char *)"games", (char *)"no params", 0, 0, ' ', EVAL_GAMES }, \
|
||||
{ (char *)MYCCNAME, (char *)"pending", (char *)"no params", 0, 0, ' ', EVAL_GAMES }, \
|
||||
{ (char *)MYCCNAME, (char *)"setname", (char *)"pname", 1, 1, ' ', EVAL_GAMES }, \
|
||||
{ (char *)MYCCNAME, (char *)"newgame", (char *)"maxplayers,buyin", 2, 2, 'C', EVAL_GAMES }, \
|
||||
{ (char *)MYCCNAME, (char *)"playerinfo", (char *)"playertxid", 1, 1, ' ', EVAL_GAMES }, \
|
||||
{ (char *)MYCCNAME, (char *)"gameinfo", (char *)"gametxid", 1, 1, ' ', EVAL_GAMES }, \
|
||||
{ (char *)MYCCNAME, (char *)"keystrokes", (char *)"txid,hexstr", 2, 2, 'K', EVAL_GAMES }, \
|
||||
{ (char *)MYCCNAME, (char *)"finish", (char *)"gametxid", 1, 1, 'Q', EVAL_GAMES }, \
|
||||
{ (char *)MYCCNAME, (char *)"events", (char *)"eventshex [gametxid [eventid]]", 1, 3, ' ', EVAL_GAMES }, \
|
||||
{ (char *)MYCCNAME, (char *)"extract", (char *)"gametxid [pubkey]", 1, 2, ' ', EVAL_GAMES }, \
|
||||
{ (char *)MYCCNAME, (char *)"register", (char *)"gametxid [playertxid]", 1, 2, 'R', EVAL_GAMES },
|
||||
|
||||
bool games_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx);
|
||||
UniValue games_rng(uint64_t txfee,struct CCcontract_info *cp,cJSON *params);
|
||||
UniValue games_rngnext(uint64_t txfee,struct CCcontract_info *cp,cJSON *params);
|
||||
UniValue games_create(uint64_t txfee,struct CCcontract_info *cp,cJSON *params);
|
||||
UniValue games_info(uint64_t txfee,struct CCcontract_info *cp,cJSON *params);
|
||||
UniValue games_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params);
|
||||
UniValue games_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params);
|
||||
UniValue games_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params);
|
||||
UniValue games_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params);
|
||||
UniValue games_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params);
|
||||
UniValue games_newgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *params);
|
||||
UniValue games_playerinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params);
|
||||
UniValue games_gameinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *params);
|
||||
UniValue games_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *params);
|
||||
UniValue games_finish(uint64_t txfee,struct CCcontract_info *cp,cJSON *params);
|
||||
UniValue games_events(uint64_t txfee,struct CCcontract_info *cp,cJSON *params);
|
||||
UniValue games_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params);
|
||||
UniValue games_register(uint64_t txfee,struct CCcontract_info *cp,cJSON *params);
|
||||
|
||||
#define CUSTOM_DISPATCH \
|
||||
if ( cp->evalcode == EVAL_GAMES ) \
|
||||
@@ -35,14 +70,30 @@ if ( cp->evalcode == EVAL_GAMES ) \
|
||||
return(games_rng(txfee,cp,params)); \
|
||||
else if ( strcmp(method,"rngnext") == 0 ) \
|
||||
return(games_rngnext(txfee,cp,params)); \
|
||||
else if ( strcmp(method,"create") == 0 ) \
|
||||
return(games_create(txfee,cp,params)); \
|
||||
else if ( strcmp(method,"info") == 0 ) \
|
||||
return(games_info(txfee,cp,params)); \
|
||||
else if ( strcmp(method,"newgame") == 0 ) \
|
||||
return(games_newgame(txfee,cp,params)); \
|
||||
else if ( strcmp(method,"gameinfo") == 0 ) \
|
||||
return(games_gameinfo(txfee,cp,params)); \
|
||||
else if ( strcmp(method,"register") == 0 ) \
|
||||
return(games_register(txfee,cp,params)); \
|
||||
else if ( strcmp(method,"events") == 0 ) \
|
||||
return(games_events(txfee,cp,params)); \
|
||||
else if ( strcmp(method,"players") == 0 ) \
|
||||
return(games_players(txfee,cp,params)); \
|
||||
else if ( strcmp(method,"games") == 0 ) \
|
||||
return(games_games(txfee,cp,params)); \
|
||||
else if ( strcmp(method,"pending") == 0 ) \
|
||||
return(games_pending(txfee,cp,params)); \
|
||||
else if ( strcmp(method,"setname") == 0 ) \
|
||||
return(games_setname(txfee,cp,params)); \
|
||||
else if ( strcmp(method,"playerinfo") == 0 ) \
|
||||
return(games_playerinfo(txfee,cp,params)); \
|
||||
else if ( strcmp(method,"keystrokes") == 0 ) \
|
||||
return(games_keystrokes(txfee,cp,params)); \
|
||||
else if ( strcmp(method,"extract") == 0 ) \
|
||||
return(games_extract(txfee,cp,params)); \
|
||||
else if ( strcmp(method,"finish") == 0 ) \
|
||||
return(games_finish(txfee,cp,params)); \
|
||||
else \
|
||||
{ \
|
||||
result.push_back(Pair("result","error")); \
|
||||
@@ -51,3 +102,35 @@ if ( cp->evalcode == EVAL_GAMES ) \
|
||||
return(result); \
|
||||
} \
|
||||
}
|
||||
#endif
|
||||
|
||||
#define MAXPACK 23
|
||||
struct games_packitem
|
||||
{
|
||||
int32_t type,launch,count,which,hplus,dplus,arm,flags,group;
|
||||
char damage[8],hurldmg[8];
|
||||
};
|
||||
|
||||
struct games_player
|
||||
{
|
||||
int32_t gold,hitpoints,strength,level,experience,packsize,dungeonlevel,amulet;
|
||||
struct games_packitem gamespack[MAXPACK];
|
||||
};
|
||||
|
||||
struct games_state
|
||||
{
|
||||
uint64_t seed;
|
||||
char *keystrokes,*keystrokeshex;
|
||||
uint32_t needflush,replaydone;
|
||||
int32_t numkeys,ind,num,guiflag,counter,sleeptime,playersize,restoring,lastnum;
|
||||
FILE *logfp;
|
||||
struct games_player P;
|
||||
char buffered[10000];
|
||||
uint8_t playerdata[10000];
|
||||
};
|
||||
|
||||
int32_t games_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct games_player *player,int32_t sleepmillis);
|
||||
void games_packitemstr(char *packitemstr,struct games_packitem *item);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
gcc -O3 -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -DSTANDALONE tetris.cpp -lncurses -o tetris
|
||||
gcc -O3 -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -DSTANDALONE gamescc.cpp -lncurses -lcurl -o tetris
|
||||
|
||||
|
||||
@@ -819,7 +819,7 @@ UniValue PaymentsInfo(struct CCcontract_info *cp,char *jsonstr)
|
||||
UniValue PaymentsList(struct CCcontract_info *cp,char *jsonstr)
|
||||
{
|
||||
std::vector<std::pair<CAddressIndexKey, CAmount> > addressIndex; uint256 txid,hashBlock;
|
||||
UniValue result(UniValue::VOBJ),a(UniValue::VARR); char markeraddr[64],str[65]; CPubKey Paymentspk; CTransaction tx; int32_t lockedblocks,minrelease,totalallocations; std::vector<uint256> txidoprets;
|
||||
UniValue result(UniValue::VOBJ),a(UniValue::VARR); char markeraddr[64],str[65]; CPubKey Paymentspk; CTransaction tx; int32_t lockedblocks,minrelease; std::vector<uint256> txidoprets; int64_t totalallocations;
|
||||
Paymentspk = GetUnspendable(cp,0);
|
||||
GetCCaddress1of2(cp,markeraddr,Paymentspk,Paymentspk);
|
||||
SetCCtxids(addressIndex,markeraddr);
|
||||
|
||||
@@ -16,6 +16,24 @@
|
||||
#ifndef H_CURSESD_H
|
||||
#define H_CURSESD_H
|
||||
|
||||
#define COLOR_BLACK 0
|
||||
|
||||
#ifdef PDC_RGB /* RGB */
|
||||
# define COLOR_RED 1
|
||||
# define COLOR_GREEN 2
|
||||
# define COLOR_BLUE 4
|
||||
#else /* BGR */
|
||||
# define COLOR_BLUE 1
|
||||
# define COLOR_GREEN 2
|
||||
# define COLOR_RED 4
|
||||
#endif
|
||||
|
||||
#define COLOR_CYAN (COLOR_BLUE | COLOR_GREEN)
|
||||
#define COLOR_MAGENTA (COLOR_RED | COLOR_BLUE)
|
||||
#define COLOR_YELLOW (COLOR_RED | COLOR_GREEN)
|
||||
|
||||
#define COLOR_WHITE 7
|
||||
|
||||
#define LINES 24
|
||||
#define COLS 80
|
||||
|
||||
@@ -151,6 +169,15 @@ char *unctrl(char c);
|
||||
#define halfdelay(x) 0
|
||||
#define nocbreak() 0
|
||||
|
||||
// for tetris
|
||||
#define init_pair(a,b,c) 0
|
||||
#define start_color() 0
|
||||
#define box(a,b,c) 0
|
||||
#define A_REVERSE 0
|
||||
#define COLOR_PAIR(a) 0
|
||||
#define timeout(x) 0
|
||||
// end for tetris
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
@@ -784,9 +784,9 @@ int32_t rogue_sendrawtransaction(char *rawtx)
|
||||
return(retval);
|
||||
}
|
||||
|
||||
void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char *keystrokes,int32_t num)
|
||||
int32_t rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char *keystrokes,int32_t num)
|
||||
{
|
||||
char cmd[16384],hexstr[16384],params[32768],*retstr,*rawtx,*pastkeys,*pastcmp,*keys; int32_t i,len,numpastkeys; cJSON *retjson,*resobj;
|
||||
char cmd[16384],hexstr[16384],params[32768],*retstr,*errstr,*rawtx,*pastkeys,*pastcmp,*keys; int32_t i,len,numpastkeys,retflag = -1; cJSON *retjson,*resobj;
|
||||
//fprintf(stderr,"rogue_progress num.%d\n",num);
|
||||
if ( rs->guiflag != 0 && Gametxidstr[0] != 0 )
|
||||
{
|
||||
@@ -795,7 +795,7 @@ void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char *
|
||||
if ( rogue_sendrawtransaction(rs->keystrokeshex) == 0 )
|
||||
{
|
||||
if ( waitflag == 0 )
|
||||
return;
|
||||
return(0);
|
||||
else if ( 0 )
|
||||
{
|
||||
while ( rogue_sendrawtransaction(rs->keystrokeshex) == 0 )
|
||||
@@ -866,8 +866,12 @@ void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char *
|
||||
{
|
||||
if ( rs->keystrokeshex != 0 )
|
||||
free(rs->keystrokeshex);
|
||||
rs->keystrokeshex = (char *)malloc(strlen(rawtx)+1);
|
||||
strcpy(rs->keystrokeshex,rawtx);
|
||||
if ( (errstr= jstr(resobj,"error")) == 0 )
|
||||
{
|
||||
rs->keystrokeshex = (char *)malloc(strlen(rawtx)+1);
|
||||
strcpy(rs->keystrokeshex,rawtx);
|
||||
retflag = 1;
|
||||
} else fprintf(stderr,"error sending keystrokes tx\n"), sleep(1);
|
||||
//fprintf(stderr,"set keystrokestx <- %s\n",rs->keystrokeshex);
|
||||
}
|
||||
free_json(retjson);
|
||||
@@ -885,6 +889,7 @@ void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char *
|
||||
}
|
||||
}
|
||||
}
|
||||
return(retflag);
|
||||
}
|
||||
|
||||
int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr)
|
||||
|
||||
@@ -158,7 +158,7 @@ int32_t flushkeystrokes_local(struct rogue_state *rs,int32_t waitflag)
|
||||
#ifdef BUILD_ROGUE
|
||||
// stubs for inside daemon
|
||||
|
||||
void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char *keystrokes,int32_t num)
|
||||
int32_t rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char *keystrokes,int32_t num)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -172,15 +172,11 @@ int32_t flushkeystrokes(struct rogue_state *rs,int32_t waitflag)
|
||||
{
|
||||
if ( rs->num > 0 )
|
||||
{
|
||||
// need to get existing keystrokes including mempool
|
||||
// create keystrokes that are not saved
|
||||
//rs->keytxid = rogue_progress(rs,waitflag,rs->seed,&rs->buffered[rs->lastnum],rs->num - rs->lastnum);
|
||||
//rs->lastnum = rs->num;
|
||||
rogue_progress(rs,waitflag,rs->seed,rs->buffered,rs->num);
|
||||
flushkeystrokes_local(rs,waitflag);
|
||||
memset(rs->buffered,0,sizeof(rs->buffered));
|
||||
//rs->num = 0;
|
||||
//rs->counter++;
|
||||
if ( rogue_progress(rs,waitflag,rs->seed,rs->buffered,rs->num) > 0 )
|
||||
{
|
||||
flushkeystrokes_local(rs,waitflag);
|
||||
memset(rs->buffered,0,sizeof(rs->buffered));
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -380,7 +380,7 @@ 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,int32_t waitflag,uint64_t seed,char *keystrokes,int32_t num);
|
||||
int32_t rogue_progress(struct rogue_state *rs,int32_t waitflag,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)
|
||||
|
||||
@@ -1594,7 +1594,10 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C
|
||||
return eval->Invalid("mismatched playerdata");
|
||||
}
|
||||
if ( funcid == 'H' )
|
||||
{
|
||||
cashout *= 2;
|
||||
//cashout += numplayers * buyin;
|
||||
}
|
||||
sprintf(cashstr,"tokentx.(%c) decoded.%d ht.%d txid.%s %.8f vs vout2 %.8f",tokentx,decoded,height,txid.GetHex().c_str(),(double)cashout/COIN,(double)tx.vout[2].nValue/COIN);
|
||||
if ( strcmp(laststr,cashstr) != 0 )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user