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

Function savetrapchn

src/save.c:919–943  ·  view source on GitHub ↗

save traps; gf.ftrap is the only trap chain so 2nd arg is superfluous */

Source from the content-addressed store, hash-verified

917
918/* save traps; gf.ftrap is the only trap chain so 2nd arg is superfluous */
919staticfn void
920savetrapchn(NHFILE *nhfp, struct trap *trap)
921{
922 static struct trap zerotrap;
923 struct trap *trap2;
924
925 while (trap) {
926 boolean use_relative = (program_state.restoring != REST_GSTATE
927 && trap->dst.dnum == u.uz.dnum);
928 trap2 = trap->ntrap;
929 if (use_relative)
930 trap->dst.dlevel -= u.uz.dlevel; /* make it relative */
931 if (update_file(nhfp)) {
932 Sfo_trap(nhfp, trap, "trap");
933 }
934 if (use_relative)
935 trap->dst.dlevel += u.uz.dlevel; /* reset back to absolute */
936 if (release_data(nhfp))
937 dealloc_trap(trap);
938 trap = trap2;
939 }
940 if (update_file(nhfp)) {
941 Sfo_trap(nhfp, &zerotrap, "trap");
942 }
943}
944
945/* save all the fruit names and ID's; this is used only in saving whole games
946 * (not levels) and in saving bones levels. When saving a bones level,

Callers 1

savelev_coreFunction · 0.85

Calls 1

update_fileFunction · 0.85

Tested by

no test coverage detected