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

Function encodeachieve

src/topten.c:454–476  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

452}
453
454staticfn long
455encodeachieve(
456 boolean secondlong) /* False: handle achievements 1..31, True: 32..62 */
457{
458 int i, achidx, offset;
459 long r = 0L;
460
461 /*
462 * 32: portable limit for 'long'.
463 * Force 32 even on configurations that are using 64 bit longs.
464 *
465 * We use signed long and limit ourselves to 31 bits since tools
466 * that post-process xlogfile might not be able to cope with
467 * 'unsigned long'.
468 */
469 offset = secondlong ? (32 - 1) : 0;
470 for (i = 0; u.uachieved[i]; ++i) {
471 achidx = u.uachieved[i] - offset;
472 if (achidx > 0 && achidx < 32) /* value 1..31 sets bit 0..30 */
473 r |= 1L << (achidx - 1);
474 }
475 return r;
476}
477
478/* add the achievement or conduct comma-separated to string */
479staticfn void

Callers 1

writexlentryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected