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

Function save_bc

src/save.c:695–721  ·  view source on GitHub ↗

if ball and/or chain are loose, make an object chain for it/them and save that separately from other objects */

Source from the content-addressed store, hash-verified

693/* if ball and/or chain are loose, make an object chain for it/them and
694 save that separately from other objects */
695staticfn void
696save_bc(NHFILE *nhfp)
697{
698 struct obj *bc_objs = 0;
699
700 /* save ball and chain if they are currently dangling free (i.e. not
701 on floor or in inventory); 'looseball' and 'loosechain' have been
702 set up in caller because ball and chain will be gone by now if on
703 floor, or ball gone if carried */
704 if (gl.loosechain) {
705 gl.loosechain->nobj = bc_objs; /* uchain */
706 bc_objs = gl.loosechain;
707 if (nhfp->mode & FREEING) {
708 setworn((struct obj *) 0, W_CHAIN); /* sets 'uchain' to Null */
709 gl.loosechain = (struct obj *) 0;
710 }
711 }
712 if (gl.looseball) {
713 gl.looseball->nobj = bc_objs;
714 bc_objs = gl.looseball;
715 if (nhfp->mode & FREEING) {
716 setworn((struct obj *) 0, W_BALL); /* sets 'uball' to Null */
717 gl.looseball = (struct obj *) 0;
718 }
719 }
720 saveobjchn(nhfp, &bc_objs); /* frees objs in list, sets bc_objs to Null */
721}
722
723/* save one object;
724 caveat: this is only for update_file(); caller handles release_data() */

Callers 1

savegamestateFunction · 0.85

Calls 2

setwornFunction · 0.85
saveobjchnFunction · 0.85

Tested by

no test coverage detected