@@ -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:
|
* pack_room:
|
||||||
* See if there's room in the pack. If not, print out an
|
* See if there's room in the pack. If not, print out an
|
||||||
* appropriate message
|
* appropriate message
|
||||||
*/
|
*/
|
||||||
bool
|
bool pack_room(struct rogue_state *rs,bool from_floor, THING *obj)
|
||||||
pack_room(struct rogue_state *rs,bool from_floor, THING *obj)
|
|
||||||
{
|
{
|
||||||
inpack = num_packitems();
|
inpack = num_packitems(rs);
|
||||||
if (++inpack > MAXPACK)
|
if ( ++inpack > MAXPACK )
|
||||||
{
|
{
|
||||||
if (!terse)
|
if (!terse)
|
||||||
addmsg(rs,"there's ");
|
addmsg(rs,"there's ");
|
||||||
addmsg(rs,"no room");
|
addmsg(rs,"no room");
|
||||||
if (!terse)
|
if (!terse)
|
||||||
addmsg(rs," in your pack");
|
addmsg(rs," in your pack");
|
||||||
endmsg(rs);
|
endmsg(rs);
|
||||||
if (from_floor)
|
if (from_floor)
|
||||||
move_msg(rs,obj);
|
move_msg(rs,obj);
|
||||||
inpack = MAXPACK;
|
inpack = MAXPACK;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
//fprintf(stderr,"inpack.%d vs MAX.%d\n",inpack,MAXPACK), sleep(2);
|
//fprintf(stderr,"inpack.%d vs MAX.%d\n",inpack,MAXPACK), sleep(2);
|
||||||
|
if ( from_floor != 0 )
|
||||||
if (from_floor)
|
|
||||||
{
|
{
|
||||||
detach(lvl_obj, obj);
|
detach(lvl_obj, obj);
|
||||||
mvaddch(hero.y, hero.x, floor_ch());
|
mvaddch(hero.y, hero.x, floor_ch());
|
||||||
chat(hero.y, hero.x) = (proom->r_flags & ISGONE) ? PASSAGE : FLOOR;
|
chat(hero.y, hero.x) = (proom->r_flags & ISGONE) ? PASSAGE : FLOOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,26 +265,11 @@ pack_char()
|
|||||||
* the given type.
|
* the given type.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int32_t num_packitems()
|
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fprintf(stderr,"total.%d vs %d inventory letters\n",total,n); sleep(1);
|
|
||||||
return(n);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
inventory(struct rogue_state *rs,THING *list, int type)
|
inventory(struct rogue_state *rs,THING *list, int type)
|
||||||
{
|
{
|
||||||
static char inv_temp[MAXSTR];
|
char inv_temp[MAXSTR];
|
||||||
|
|
||||||
n_objs = 0;
|
n_objs = 0;
|
||||||
for (; list != NULL; list = next(list))
|
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_item(void);
|
||||||
THING *new_thing(struct rogue_state *rs);
|
THING *new_thing(struct rogue_state *rs);
|
||||||
void end_line(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 runners(struct rogue_state *rs,int);
|
||||||
void land(struct rogue_state *rs,int);
|
void land(struct rogue_state *rs,int);
|
||||||
|
|||||||
@@ -1234,35 +1234,56 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C
|
|||||||
if ( (funcid= rogue_registeropretdecode(gametxid,tokenid,playertxid,scriptPubKey)) == 0 )
|
if ( (funcid= rogue_registeropretdecode(gametxid,tokenid,playertxid,scriptPubKey)) == 0 )
|
||||||
{
|
{
|
||||||
funcid = 'Q';
|
funcid = 'Q';
|
||||||
fprintf(stderr,"ht.%d couldnt decode tokens opret\n",height);
|
fprintf(stderr,"ht.%d couldnt decode tokens opret (%c)\n",height,script[1]);
|
||||||
|
if ( height < 20000 )
|
||||||
|
e = EVAL_ROGUE;
|
||||||
} else e = EVAL_ROGUE, decoded = 1;
|
} else e = EVAL_ROGUE, decoded = 1;
|
||||||
} else e = EVAL_ROGUE, decoded = 1;
|
} else e = EVAL_ROGUE, decoded = 1;
|
||||||
}
|
}
|
||||||
if ( e == EVAL_ROGUE )
|
if ( e == EVAL_ROGUE )
|
||||||
{
|
{
|
||||||
|
fprintf(stderr,"ht.%d rogue.(%c)\n",height,script[1]);
|
||||||
if ( decoded == 0 )
|
if ( decoded == 0 )
|
||||||
{
|
{
|
||||||
switch ( funcid )
|
switch ( funcid )
|
||||||
{
|
{
|
||||||
case 'G':
|
case 'G':
|
||||||
if ( (funcid= rogue_newgameopreturndecode(buyin,maxplayers,scriptPubKey)) != 'G' )
|
if ( (funcid= rogue_newgameopreturndecode(buyin,maxplayers,scriptPubKey)) != 'G' )
|
||||||
return eval->Invalid("couldnt decode newgame opret");
|
{
|
||||||
|
fprintf(stderr,"height.%d couldnt decode newgame opret\n",height);
|
||||||
|
if ( height > 20000 )
|
||||||
|
return eval->Invalid("couldnt decode newgame opret");
|
||||||
|
}
|
||||||
// validate newgame tx
|
// validate newgame tx
|
||||||
return(true);
|
return(true);
|
||||||
break;
|
break;
|
||||||
case 'R':
|
case 'R':
|
||||||
if ( (funcid= rogue_registeropretdecode(gametxid,tokenid,playertxid,scriptPubKey)) != 'R' )
|
if ( (funcid= rogue_registeropretdecode(gametxid,tokenid,playertxid,scriptPubKey)) != 'R' )
|
||||||
return eval->Invalid("couldnt decode register opret");
|
{
|
||||||
|
fprintf(stderr,"height.%d couldnt decode register opret\n",height);
|
||||||
|
if ( height > 20000 )
|
||||||
|
return eval->Invalid("couldnt decode register opret");
|
||||||
|
}
|
||||||
|
// validation is done below
|
||||||
break;
|
break;
|
||||||
case 'K':
|
case 'K':
|
||||||
if ( (funcid= rogue_keystrokesopretdecode(gametxid,batontxid,pk,keystrokes,scriptPubKey)) != 'K' )
|
if ( (funcid= rogue_keystrokesopretdecode(gametxid,batontxid,pk,keystrokes,scriptPubKey)) != 'K' )
|
||||||
return eval->Invalid("couldnt decode keystrokes opret");
|
{
|
||||||
|
fprintf(stderr,"height.%d couldnt decode keystrokes opret\n",height);
|
||||||
|
if ( height > 20000 )
|
||||||
|
return eval->Invalid("couldnt decode keystrokes opret");
|
||||||
|
}
|
||||||
// validate keystrokes are from the correct pk. might need to add vin
|
// validate keystrokes are from the correct pk. might need to add vin
|
||||||
return(true);
|
return(true);
|
||||||
break;
|
break;
|
||||||
case 'H': case 'Q':
|
case 'H': case 'Q':
|
||||||
if ( (f= rogue_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,pname,scriptPubKey)) != funcid )
|
if ( (f= rogue_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,pname,scriptPubKey)) != funcid )
|
||||||
return eval->Invalid("couldnt decode H/Q opret");
|
{
|
||||||
|
fprintf(stderr,"height.%d couldnt decode H/Q opret\n",height);
|
||||||
|
if ( height > 20000 )
|
||||||
|
return eval->Invalid("couldnt decode H/Q opret");
|
||||||
|
}
|
||||||
|
// validation is done below
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return eval->Invalid("illegal rogue non-decoded funcid");
|
return eval->Invalid("illegal rogue non-decoded funcid");
|
||||||
@@ -1271,25 +1292,15 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C
|
|||||||
}
|
}
|
||||||
switch ( funcid )
|
switch ( funcid )
|
||||||
{
|
{
|
||||||
case 'R':
|
case 'G': // newgame
|
||||||
// validate register: within 60 blocks, not duplicate, etc.
|
case 'R': // register
|
||||||
return(true);
|
case 'K': // keystrokes
|
||||||
break;
|
case 'H': // win
|
||||||
case 'H': // fall through
|
case 'Q': // bailout
|
||||||
case 'Q':
|
//fprintf(stderr,"ht.%d rogue.(%c)\n",height,script[1]);
|
||||||
// make sure any playerdata is reproduced via replay
|
|
||||||
if ( funcid == 'Q' )
|
|
||||||
{
|
|
||||||
// validate bailout constraints
|
|
||||||
}
|
|
||||||
else // 'H'
|
|
||||||
{
|
|
||||||
// validate winner constraints
|
|
||||||
}
|
|
||||||
return(true);
|
return(true);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr,"ht.%d rogue.(%c)\n",height,script[1]);
|
|
||||||
return eval->Invalid("illegal rogue funcid");
|
return eval->Invalid("illegal rogue funcid");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user