Opreturn player data

This commit is contained in:
jl777
2019-02-06 02:25:28 -11:00
parent fde8e549a3
commit 6c1d59e8a2
5 changed files with 40 additions and 19 deletions

View File

@@ -160,7 +160,7 @@ int32_t flushkeystrokes(struct rogue_state *rs)
return(0);
}
int32_t rogue_replay2(uint64_t seed,char *keystrokes,int32_t num)
int32_t rogue_replay2(uint8_t *player,uint64_t seed,char *keystrokes,int32_t num)
{
struct rogue_state *rs; FILE *fp; int32_t i;
rs = (struct rogue_state *)calloc(1,sizeof(*rs));
@@ -186,9 +186,13 @@ int32_t rogue_replay2(uint64_t seed,char *keystrokes,int32_t num)
fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL)-starttime);
sleep(1);*/
if ( (fp= fopen("checkfile","wb")) != 0 )
{
save_file(rs,fp,0);
if ( rs->playersize > 0 )
memcpy(player,rs->playerdata,rs->playersize);
}
free(rs);
return(0);
return(rs->playersize);
}
#endif

View File

@@ -321,7 +321,7 @@ struct rogue_packitem
struct rogue_player
{
int32_t gold,hitpoints,strength,level,experience,packsize;
int32_t gold,hitpoints,strength,level,experience,packsize,dungeonlevel,pad;
struct rogue_packitem roguepack[MAXPACK];
};
@@ -330,9 +330,10 @@ struct rogue_state
uint64_t seed;
char *keystrokes;
uint32_t needflush,replaydone;
int32_t numkeys,ind,num,guiflag,counter,sleeptime;
int32_t numkeys,ind,num,guiflag,counter,sleeptime,playersize;
struct rogue_player P;
char buffered[8192];
uint8_t playerdata[10000];
};
extern struct rogue_state globalR;

View File

@@ -167,7 +167,9 @@ save_file(struct rogue_state *rs,FILE *savef,int32_t guiflag)
{
fprintf(stderr,"%02x",((uint8_t *)&rs->P)[i]);
histo[((uint8_t *)&rs->P)[i]]++;
rs->playerdata[i] = ((uint8_t *)&rs->P)[i];
}
rs->playersize = n;
fprintf(stderr," packsize.%d n.%d\n",rs->P.packsize,n);
if ( (fp= fopen(rogue_packfname(rs,fname),"wb")) != 0 )
{

View File

@@ -1388,7 +1388,8 @@ rs_write_object(struct rogue_state *rs,FILE *savef, THING *o)
rs->P.strength = max_stats.s_str;
rs->P.level = pstats.s_lvl;
rs->P.experience = pstats.s_exp;
fprintf(stderr,"%ld gold.%d hp.%d strength.%d level.%d exp.%d\n",ftell(savef),purse,max_hp,max_stats.s_str,pstats.s_lvl,pstats.s_exp);
rs->P.dungeonlevel = level;
fprintf(stderr,"%ld gold.%d hp.%d strength.%d level.%d exp.%d %d\n",ftell(savef),purse,max_hp,max_stats.s_str,pstats.s_lvl,pstats.s_exp,level);
};
fprintf(stderr,"object (%s) x.%d y.%d type.%d pack.(%c:%d)\n",inv_name(o,FALSE),o->_o._o_pos.x,o->_o._o_pos.y,o->_o._o_type,o->_o._o_packch,o->_o._o_packch);
if ( rs->P.packsize < MAXPACK )