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

Function status_hilite2str

src/botl.c:3589–3669  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3587
3588
3589staticfn char *
3590status_hilite2str(struct hilite_s *hl)
3591{
3592 static char buf[BUFSZ];
3593 int clr = NO_COLOR, attr = ATR_NONE;
3594 char behavebuf[BUFSZ];
3595 char clrbuf[BUFSZ];
3596 char attrbuf[BUFSZ];
3597 char *tmpattr;
3598 const char *op;
3599
3600 if (!hl)
3601 return (char *) 0;
3602
3603 behavebuf[0] = '\0';
3604 clrbuf[0] = '\0';
3605 op = (hl->rel == LT_VALUE) ? "<"
3606 : (hl->rel == LE_VALUE) ? "<="
3607 : (hl->rel == GT_VALUE) ? ">"
3608 : (hl->rel == GE_VALUE) ? ">="
3609 : (hl->rel == EQ_VALUE) ? "="
3610 : 0;
3611
3612 switch (hl->behavior) {
3613 case BL_TH_VAL_PERCENTAGE:
3614 if (op)
3615 Sprintf(behavebuf, "%s%d%%", op, hl->value.a_int);
3616 else
3617 impossible("hl->behavior=percentage, rel error");
3618 break;
3619 case BL_TH_UPDOWN:
3620 if (hl->rel == LT_VALUE)
3621 Sprintf(behavebuf, "down");
3622 else if (hl->rel == GT_VALUE)
3623 Sprintf(behavebuf, "up");
3624 else if (hl->rel == EQ_VALUE)
3625 Sprintf(behavebuf, "changed");
3626 else
3627 impossible("hl->behavior=updown, rel error");
3628 break;
3629 case BL_TH_VAL_ABSOLUTE:
3630 if (op)
3631 Sprintf(behavebuf, "%s%d", op, hl->value.a_int);
3632 else
3633 impossible("hl->behavior=absolute, rel error");
3634 break;
3635 case BL_TH_TEXTMATCH:
3636 if (hl->rel == TXT_VALUE && hl->textmatch[0])
3637 Sprintf(behavebuf, "%s", hl->textmatch);
3638 else
3639 impossible("hl->behavior=textmatch, rel or textmatch error");
3640 break;
3641 case BL_TH_CONDITION:
3642 if (hl->rel == EQ_VALUE)
3643 Sprintf(behavebuf, "%s", conditionbitmask2str(hl->value.a_ulong));
3644 else
3645 impossible("hl->behavior=condition, rel error");
3646 break;

Callers 2

status_hilite_menu_addFunction · 0.85

Calls 7

conditionbitmask2strFunction · 0.85
split_clridxFunction · 0.85
strNsubstFunction · 0.85
clr2colornameFunction · 0.85
hlattr2attrnameFunction · 0.85
eosFunction · 0.85
impossibleFunction · 0.70

Tested by

no test coverage detected