Split get_rnd_toptenentry from tt_oname
This commit is contained in:
@@ -2299,6 +2299,7 @@ E void NDECL(timer_sanity_check);
|
||||
E void FDECL(formatkiller, (char *, unsigned, int, BOOLEAN_P));
|
||||
E void FDECL(topten, (int, time_t));
|
||||
E void FDECL(prscore, (int, char **));
|
||||
E struct toptenentry *NDECL(get_rnd_toptenentry);
|
||||
E struct obj *FDECL(tt_oname, (struct obj *));
|
||||
|
||||
/* ### track.c ### */
|
||||
|
||||
47
src/topten.c
47
src/topten.c
@@ -1171,25 +1171,19 @@ boolean fem;
|
||||
|
||||
/*
|
||||
* Get a random player name and class from the high score list,
|
||||
* and attach them to an object (for statues or morgue corpses).
|
||||
*/
|
||||
struct obj *
|
||||
tt_oname(otmp)
|
||||
struct obj *otmp;
|
||||
struct toptenentry *
|
||||
get_rnd_toptenentry()
|
||||
{
|
||||
int rank;
|
||||
register int i;
|
||||
register struct toptenentry *tt;
|
||||
int rank, i;
|
||||
FILE *rfile;
|
||||
struct toptenentry tt_buf;
|
||||
|
||||
if (!otmp)
|
||||
return (struct obj *) 0;
|
||||
register struct toptenentry *tt;
|
||||
static struct toptenentry tt_buf;
|
||||
|
||||
rfile = fopen_datafile(RECORD, "r", SCOREPREFIX);
|
||||
if (!rfile) {
|
||||
impossible("Cannot open record file!");
|
||||
return (struct obj *) 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tt = &tt_buf;
|
||||
@@ -1207,13 +1201,34 @@ pickentry:
|
||||
rewind(rfile);
|
||||
goto pickentry;
|
||||
}
|
||||
otmp = (struct obj *) 0;
|
||||
} else {
|
||||
set_corpsenm(otmp, classmon(tt->plrole, (tt->plgend[0] == 'F')));
|
||||
otmp = oname(otmp, tt->name);
|
||||
tt = NULL;
|
||||
}
|
||||
|
||||
(void) fclose(rfile);
|
||||
return tt;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Attach random player name and class from high score list
|
||||
* to an object (for statues or morgue corpses).
|
||||
*/
|
||||
struct obj *
|
||||
tt_oname(otmp)
|
||||
struct obj *otmp;
|
||||
{
|
||||
struct toptenentry *tt;
|
||||
if (!otmp)
|
||||
return (struct obj *) 0;
|
||||
|
||||
tt = get_rnd_toptenentry();
|
||||
|
||||
if (!tt)
|
||||
return (struct obj *) 0;
|
||||
|
||||
set_corpsenm(otmp, classmon(tt->plrole, (tt->plgend[0] == 'F')));
|
||||
otmp = oname(otmp, tt->name);
|
||||
|
||||
return otmp;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user