This commit is contained in:
jl777
2019-02-09 23:06:57 -11:00
parent 3cc3c3abed
commit 3c5c8f3599
3 changed files with 54 additions and 42 deletions

View File

@@ -1338,6 +1338,7 @@ rs_read_monsters(FILE *inf, struct monster *m, int count)
void rogue_restoreobject(THING *o,struct rogue_packitem *item) void rogue_restoreobject(THING *o,struct rogue_packitem *item)
{ {
int32_t i;
o->_o._o_type = item->type; o->_o._o_type = item->type;
o->_o._o_launch = item->launch; o->_o._o_launch = item->launch;
memcpy(o->_o._o_damage,item->damage,sizeof(item->damage)); memcpy(o->_o._o_damage,item->damage,sizeof(item->damage));
@@ -1350,6 +1351,25 @@ void rogue_restoreobject(THING *o,struct rogue_packitem *item)
o->_o._o_flags = item->flags; o->_o._o_flags = item->flags;
o->_o._o_group = item->group; o->_o._o_group = item->group;
o->o_flags |= ISKNOW; o->o_flags |= ISKNOW;
switch ( item->type )
{
case SCROLL:
if ( item->which < MAXSCROLLS )
scr_info[item->which].oi_know = TRUE;
break;
case POTION:
if ( item->which < MAXPOTIONS )
pot_info[item->which].oi_know = TRUE;
break;
case RING:
if ( item->which < MAXRINGS )
ring_info[item->which].oi_know = TRUE;
break;
case STICK:
if ( item->which < MAXSTICKS )
ws_info[item->which].oi_know = TRUE;
break;
}
} }
void rogue_packitemstr(char *packitemstr,struct rogue_packitem *item) void rogue_packitemstr(char *packitemstr,struct rogue_packitem *item)

View File

@@ -432,15 +432,15 @@ print_disc(struct rogue_state *rs,char type)
obj.o_flags = 0; obj.o_flags = 0;
num_found = 0; num_found = 0;
for (i = 0; i < maxnum; i++) for (i = 0; i < maxnum; i++)
if (info[order[i]].oi_know || info[order[i]].oi_guess) if (info[order[i]].oi_know || info[order[i]].oi_guess)
{ {
obj.o_type = type; obj.o_type = type;
obj.o_which = order[i]; obj.o_which = order[i];
add_line(rs,"%s", inv_name(&obj, FALSE)); add_line(rs,"%s", inv_name(&obj, FALSE));
num_found++; num_found++;
} }
if (num_found == 0) if (num_found == 0)
add_line(rs,nothing(type), NULL); add_line(rs,nothing(type), NULL);
} }
/* /*
@@ -452,16 +452,16 @@ void
set_order(int *order, int numthings) set_order(int *order, int numthings)
{ {
int i, r, t; int i, r, t;
for (i = 0; i< numthings; i++) for (i = 0; i< numthings; i++)
order[i] = i; order[i] = i;
for (i = numthings; i > 0; i--) for (i = numthings; i > 0; i--)
{ {
r = rnd(i); r = rnd(i);
t = order[i - 1]; t = order[i - 1];
order[i - 1] = order[r]; order[i - 1] = order[r];
order[r] = t; order[r] = t;
} }
} }
@@ -624,20 +624,20 @@ nameit(THING *obj, const char *type,const char *which, struct obj_info *op,
if (op->oi_know || op->oi_guess) if (op->oi_know || op->oi_guess)
{ {
if (obj->o_count == 1) if (obj->o_count == 1)
sprintf(prbuf, "A %s ", type); sprintf(prbuf, "A %s ", type);
else else
sprintf(prbuf, "%d %ss ", obj->o_count, type); sprintf(prbuf, "%d %ss ", obj->o_count, type);
pb = &prbuf[strlen(prbuf)]; pb = &prbuf[strlen(prbuf)];
if (op->oi_know) if (op->oi_know)
sprintf(pb, "of %s%s(%s)", op->oi_name, (*prfunc)(obj), which); sprintf(pb, "of %s%s(%s)", op->oi_name, (*prfunc)(obj), which);
else if (op->oi_guess) else if (op->oi_guess)
sprintf(pb, "called %s%s(%s)", op->oi_guess, (*prfunc)(obj), which); sprintf(pb, "called %s%s(%s)", op->oi_guess, (*prfunc)(obj), which);
} }
else if (obj->o_count == 1) else if (obj->o_count == 1)
sprintf(prbuf, "A%s %s %s", vowelstr((char *)which), which, type); sprintf(prbuf, "A%s %s %s", vowelstr((char *)which), which, type);
else else
sprintf(prbuf, "%d %s %ss", obj->o_count, which, type); sprintf(prbuf, "%d %s %ss", obj->o_count, which, type);
} }
/* /*

View File

@@ -361,9 +361,9 @@ int32_t rogue_isvalidgame(struct CCcontract_info *cp,int32_t &gameheight,CTransa
} else return(-1); } else return(-1);
} }
UniValue rogue_playerobj(UniValue &obj,std::vector<uint8_t> playerdata) UniValue rogue_playerobj(std::vector<uint8_t> playerdata)
{ {
int32_t i; struct rogue_player P; char packitemstr[512]; UniValue a(UniValue::VARR); int32_t i; struct rogue_player P; char packitemstr[512]; UniValue obj(UniValue:VOBJ),a(UniValue::VARR);
memset(&P,0,sizeof(P)); memset(&P,0,sizeof(P));
if ( playerdata.size() > 0 ) if ( playerdata.size() > 0 )
{ {
@@ -383,7 +383,6 @@ UniValue rogue_playerobj(UniValue &obj,std::vector<uint8_t> playerdata)
obj.push_back(Pair("level",(int64_t)P.level)); obj.push_back(Pair("level",(int64_t)P.level));
obj.push_back(Pair("experience",(int64_t)P.experience)); obj.push_back(Pair("experience",(int64_t)P.experience));
obj.push_back(Pair("dungeonlevel",(int64_t)P.dungeonlevel)); obj.push_back(Pair("dungeonlevel",(int64_t)P.dungeonlevel));
// convert to scrolls, etc.
return(obj); return(obj);
} }
@@ -425,13 +424,13 @@ int32_t rogue_playerdata(struct CCcontract_info *cp,uint256 &origplayergame,CPub
memcpy(&gametxid,script+2,sizeof(gametxid)); memcpy(&gametxid,script+2,sizeof(gametxid));
if ( rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid) == 0 ) if ( rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid) == 0 )
{ {
fprintf(stderr,"playertxid.%s got vin.%s/v%d gametxid.%s iterate.%d valid.%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(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(gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid));
if ( playertx.vin[1].prevout.hash == gametxid ) if ( playertx.vin[1].prevout.hash == gametxid && rogue_iterateplayer(gametxid,playertx.vin[1].prevout.n-maxplayers,playertxid) == 0 )
{ {
if ( (f= rogue_highlanderopretdecode(origplayergame,pk,playerdata,playertx.vout[numvouts-1].scriptPubKey)) == 'H' || f == 'Q' || f == 'S' ) if ( (f= rogue_highlanderopretdecode(origplayergame,pk,playerdata,playertx.vout[numvouts-1].scriptPubKey)) == 'H' || f == 'Q' || f == 'S' )
return(0); return(0);
else fprintf(stderr,"f is %c/%d\n",f,f); else fprintf(stderr,"f is %c/%d\n",f,f);
} else fprintf(stderr,"hash mismatch or illegale gametxid\n"); } else fprintf(stderr,"hash mismatch or illegal gametxid\n");
} }
} }
} }
@@ -559,10 +558,7 @@ void rogue_gameplayerinfo(struct CCcontract_info *cp,UniValue &obj,uint256 gamet
obj.push_back(Pair("batonvalue",ValueFromAmount(batonvalue))); obj.push_back(Pair("batonvalue",ValueFromAmount(batonvalue)));
obj.push_back(Pair("batonht",(int64_t)batonht)); obj.push_back(Pair("batonht",(int64_t)batonht));
if ( playerdata.size() > 0 ) if ( playerdata.size() > 0 )
{ obj.push_back(Pair("player",rogue_playerobj(playerdata)));
UniValue pobj(UniValue::VOBJ);
obj.push_back(Pair("player",rogue_playerobj(pobj,playerdata)));
}
} else fprintf(stderr,"findbaton err.%d\n",retval); } else fprintf(stderr,"findbaton err.%d\n",retval);
} }
@@ -649,11 +645,10 @@ UniValue rogue_playerinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *param
{ {
if ( n > 0 ) if ( n > 0 )
{ {
UniValue pobj(UniValue::VOBJ);
playertxid = juint256(jitem(params,0)); playertxid = juint256(jitem(params,0));
if ( rogue_playerdata(cp,origplayergame,pk,playerdata,playertxid) < 0 ) if ( rogue_playerdata(cp,origplayergame,pk,playerdata,playertxid) < 0 )
return(cclib_error(result,"invalid playerdata")); return(cclib_error(result,"invalid playerdata"));
result.push_back(Pair("player",rogue_playerobj(pobj,playerdata))); result.push_back(Pair("player",rogue_playerobj(playerdata)));
} else return(cclib_error(result,"no playertxid")); } else return(cclib_error(result,"no playertxid"));
return(result); return(result);
} else return(cclib_error(result,"couldnt reparse params")); } else return(cclib_error(result,"couldnt reparse params"));
@@ -929,10 +924,7 @@ UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
if ( it->second.satoshis != 1 || vout != 0 ) if ( it->second.satoshis != 1 || vout != 0 )
continue; continue;
if ( rogue_playerdata(cp,gametxid,pk,playerdata,txid) == 0 && pk == mypk ) if ( rogue_playerdata(cp,gametxid,pk,playerdata,txid) == 0 && pk == mypk )
{ a.push_back(Pair("player",rogue_playerobj(playerdata)));
UniValue obj(UniValue::VOBJ);
a.push_back(Pair("player",rogue_playerobj(obj,playerdata)));
}
} }
result.push_back(Pair("result","success")); result.push_back(Pair("result","success"));
rogue_univalue(result,"players",-1,-1); rogue_univalue(result,"players",-1,-1);