MCPcopy Create free account
hub / github.com/NetHack/NetHack / set_bonesfile_name

Function set_bonesfile_name

src/files.c:768–809  ·  view source on GitHub ↗

set up "file" to be file name for retrieving bones, and return a * bonesid to be read/written in the bones file. */

Source from the content-addressed store, hash-verified

766 * bonesid to be read/written in the bones file.
767 */
768staticfn char *
769set_bonesfile_name(char *file, d_level *lev)
770{
771 s_level *sptr;
772 char *dptr;
773
774 /*
775 * "bonD0.nn" = bones for level nn in the main dungeon;
776 * "bonM0.T" = bones for Minetown;
777 * "bonQBar.n" = bones for level n in the Barbarian quest;
778 * "bon3D0.nn" = \
779 * "bon3M0.T" = > same as above, but for bones pool #3.
780 * "bon3QBar.n" = /
781 *
782 * Return value for content validation skips "bon" and the
783 * pool number (if present), making it feasible for the admin
784 * to manually move a bones file from one pool to another by
785 * renaming it.
786 */
787 Strcpy(file, "bon");
788#ifdef SYSCF
789 if (sysopt.bones_pools > 1) {
790 unsigned poolnum = min((unsigned) sysopt.bones_pools, 10);
791
792 poolnum = (unsigned) ubirthday % poolnum; /* 0..9 */
793 Sprintf(eos(file), "%u", poolnum);
794 }
795#endif
796 dptr = eos(file);
797 /* when this naming scheme was adopted, 'filecode' was one letter;
798 3.3.0 turned it into a three letter string for quest levels */
799 Sprintf(dptr, "%c%s", svd.dungeons[lev->dnum].boneid,
800 In_quest(lev) ? gu.urole.filecode : "0");
801 if ((sptr = Is_special(lev)) != 0)
802 Sprintf(eos(dptr), ".%c", sptr->boneid);
803 else
804 Sprintf(eos(dptr), ".%d", lev->dlevel);
805#ifdef VMS
806 Strcat(dptr, ";1");
807#endif
808 return dptr;
809}
810
811/* set up temporary file name for writing bones, to avoid another game's
812 * trying to read from an uncompleted bones file. we want an uncontentious

Callers 4

create_bonesfileFunction · 0.85
commit_bonesfileFunction · 0.85
open_bonesfileFunction · 0.85
delete_bonesfileFunction · 0.85

Calls 3

eosFunction · 0.85
In_questFunction · 0.85
Is_specialFunction · 0.85

Tested by

no test coverage detected