@@ -157,37 +157,55 @@ out:
|
||||
}
|
||||
}
|
||||
|
||||
int32_t num_packitems(struct rogue_state *rs)
|
||||
{
|
||||
THING *list = pack;
|
||||
int32_t type = 0,n = 0,total = 0;
|
||||
for (; list != NULL; list = next(list))
|
||||
{
|
||||
if ( list->o_packch != 0 )
|
||||
{
|
||||
n++;
|
||||
total += list->o_count;
|
||||
}
|
||||
}
|
||||
|
||||
char str[MAXSTR];
|
||||
sprintf(str,"strength*3 %d vs total.%d vs %d inventory letters\n",pstats.s_str*3,total,n);
|
||||
add_line(rs,"%s",str);
|
||||
if ( total > pstats.s_str*3 )
|
||||
return(MAXPACK);
|
||||
return(n);
|
||||
}
|
||||
|
||||
/*
|
||||
* pack_room:
|
||||
* See if there's room in the pack. If not, print out an
|
||||
* appropriate message
|
||||
*/
|
||||
bool
|
||||
pack_room(struct rogue_state *rs,bool from_floor, THING *obj)
|
||||
bool pack_room(struct rogue_state *rs,bool from_floor, THING *obj)
|
||||
{
|
||||
inpack = num_packitems();
|
||||
if (++inpack > MAXPACK)
|
||||
inpack = num_packitems(rs);
|
||||
if ( ++inpack > MAXPACK )
|
||||
{
|
||||
if (!terse)
|
||||
addmsg(rs,"there's ");
|
||||
addmsg(rs,"no room");
|
||||
if (!terse)
|
||||
addmsg(rs," in your pack");
|
||||
endmsg(rs);
|
||||
if (from_floor)
|
||||
move_msg(rs,obj);
|
||||
inpack = MAXPACK;
|
||||
return FALSE;
|
||||
if (!terse)
|
||||
addmsg(rs,"there's ");
|
||||
addmsg(rs,"no room");
|
||||
if (!terse)
|
||||
addmsg(rs," in your pack");
|
||||
endmsg(rs);
|
||||
if (from_floor)
|
||||
move_msg(rs,obj);
|
||||
inpack = MAXPACK;
|
||||
return FALSE;
|
||||
}
|
||||
//fprintf(stderr,"inpack.%d vs MAX.%d\n",inpack,MAXPACK), sleep(2);
|
||||
|
||||
if (from_floor)
|
||||
if ( from_floor != 0 )
|
||||
{
|
||||
detach(lvl_obj, obj);
|
||||
mvaddch(hero.y, hero.x, floor_ch());
|
||||
chat(hero.y, hero.x) = (proom->r_flags & ISGONE) ? PASSAGE : FLOOR;
|
||||
detach(lvl_obj, obj);
|
||||
mvaddch(hero.y, hero.x, floor_ch());
|
||||
chat(hero.y, hero.x) = (proom->r_flags & ISGONE) ? PASSAGE : FLOOR;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -247,22 +265,11 @@ pack_char()
|
||||
* the given type.
|
||||
*/
|
||||
|
||||
int32_t num_packitems()
|
||||
{
|
||||
THING *list = pack;
|
||||
int32_t type = 0,n = 0;
|
||||
for (; list != NULL; list = next(list))
|
||||
{
|
||||
if (!list->o_packch)
|
||||
n++;
|
||||
}
|
||||
return(n);
|
||||
}
|
||||
|
||||
bool
|
||||
inventory(struct rogue_state *rs,THING *list, int type)
|
||||
{
|
||||
static char inv_temp[MAXSTR];
|
||||
char inv_temp[MAXSTR];
|
||||
|
||||
n_objs = 0;
|
||||
for (; list != NULL; list = next(list))
|
||||
|
||||
@@ -802,7 +802,7 @@ THING *leave_pack(struct rogue_state *rs,THING *obj, bool newobj, bool all);
|
||||
THING *new_item(void);
|
||||
THING *new_thing(struct rogue_state *rs);
|
||||
void end_line(struct rogue_state *rs);
|
||||
int32_t num_packitems();
|
||||
int32_t num_packitems(struct rogue_state *rs);
|
||||
|
||||
void runners(struct rogue_state *rs,int);
|
||||
void land(struct rogue_state *rs,int);
|
||||
|
||||
@@ -1218,7 +1218,8 @@ 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<uint8_t> vopret; uint8_t *script,e,f,funcid; int32_t i,ind,errflag,dispflag,score,numvouts; CTransaction vintx; uint256 hashBlock;
|
||||
CScript scriptPubKey; std::vector<uint8_t> vopret; uint8_t *script,e,f,funcid; int32_t i,maxplayers,decoded=0,regslot,ind,errflag,dispflag,score,numvouts; CTransaction vintx; CPubKey pk; uint256 hashBlock,gametxid,tokenid,batontxid,playertxid; int64_t buyin; std::vector<uint8_t> playerdata,keystrokes; std::string symbol,pname;
|
||||
return(true);
|
||||
if ( (numvouts= tx.vout.size()) > 1 )
|
||||
{
|
||||
scriptPubKey = tx.vout[numvouts-1].scriptPubKey;
|
||||
@@ -1229,19 +1230,46 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C
|
||||
funcid = script[1];
|
||||
if ( (e= script[0]) == EVAL_TOKENS )
|
||||
{
|
||||
if ( script[1] == 'c' )
|
||||
if ( (funcid= rogue_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,pname,scriptPubKey)) == 0 )
|
||||
{
|
||||
e = EVAL_ROGUE;
|
||||
funcid = 'Q';
|
||||
}
|
||||
else if ( script[1] == 't' )
|
||||
{
|
||||
e = EVAL_ROGUE;
|
||||
funcid = 'Q';
|
||||
} else return eval->Invalid("illegal tokens funcid");
|
||||
if ( (funcid= rogue_registeropretdecode(gametxid,tokenid,playertxid,scriptPubKey)) == 0 )
|
||||
{
|
||||
funcid = 'Q';
|
||||
fprintf(stderr,"ht.%d couldnt decode tokens opret\n",height);
|
||||
} else e = EVAL_ROGUE, decoded = 1;
|
||||
} else e = EVAL_ROGUE, decoded = 1;
|
||||
}
|
||||
if ( e == EVAL_ROGUE )
|
||||
{
|
||||
if ( decoded == 0 )
|
||||
{
|
||||
switch ( funcid )
|
||||
{
|
||||
case 'G':
|
||||
if ( (funcid= rogue_newgameopreturndecode(buyin,maxplayers,scriptPubKey)) != 'G' )
|
||||
return eval->Invalid("couldnt decode newgame opret");
|
||||
// validate newgame tx
|
||||
return(true);
|
||||
break;
|
||||
case 'R':
|
||||
if ( (funcid= rogue_registeropretdecode(gametxid,tokenid,playertxid,scriptPubKey)) != 'R' )
|
||||
return eval->Invalid("couldnt decode register opret");
|
||||
break;
|
||||
case 'K':
|
||||
if ( (funcid= rogue_keystrokesopretdecode(gametxid,batontxid,pk,keystrokes,scriptPubKey)) != 'K' )
|
||||
return eval->Invalid("couldnt decode keystrokes opret");
|
||||
// validate keystrokes are from the correct pk. might need to add vin
|
||||
return(true);
|
||||
break;
|
||||
case 'H': case 'Q':
|
||||
if ( (f= rogue_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,pname,scriptPubKey)) != funcid )
|
||||
return eval->Invalid("couldnt decode H/Q opret");
|
||||
break;
|
||||
default:
|
||||
return eval->Invalid("illegal rogue non-decoded funcid");
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch ( funcid )
|
||||
{
|
||||
case 'G': // newgame
|
||||
@@ -1253,6 +1281,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C
|
||||
return(true);
|
||||
break;
|
||||
default:
|
||||
//fprintf(stderr,"ht.%d rogue.(%c)\n",height,script[1]);
|
||||
return eval->Invalid("illegal rogue funcid");
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user