| 3666 | } |
| 3667 | |
| 3668 | staticfn int |
| 3669 | optfn_scores( |
| 3670 | int optidx, int req, boolean negated, |
| 3671 | char *opts, char *op) |
| 3672 | { |
| 3673 | if (req == do_init) { |
| 3674 | return optn_ok; |
| 3675 | } |
| 3676 | if (req == do_set) { |
| 3677 | /* scores:5t[op] 5a[round] o[wn] */ |
| 3678 | |
| 3679 | if ((op = string_for_opt(opts, FALSE)) == empty_optstr) |
| 3680 | return optn_err; |
| 3681 | |
| 3682 | /* 5.0: earlier versions left old values for unspecified arguments |
| 3683 | if player's scores:foo option only specified some of the three; |
| 3684 | in particular, attempting to use 'scores:own' rather than |
| 3685 | 'scores:0 top/0 around/own' didn't work as intended */ |
| 3686 | flags.end_top = flags.end_around = 0, flags.end_own = FALSE; |
| 3687 | |
| 3688 | if (negated) |
| 3689 | op = eos(op); |
| 3690 | |
| 3691 | while (*op) { |
| 3692 | int inum = 1; |
| 3693 | |
| 3694 | negated = (*op == '!') || !strncmpi(op, "no", 2); |
| 3695 | if (negated) |
| 3696 | op += (*op == '!') ? 1 : (op[2] != '-') ? 2 : 3; |
| 3697 | |
| 3698 | if (digit(*op)) { |
| 3699 | inum = atoi(op); |
| 3700 | while (digit(*op)) |
| 3701 | op++; |
| 3702 | } |
| 3703 | while (*op == ' ') |
| 3704 | op++; |
| 3705 | |
| 3706 | switch (lowc(*op)) { |
| 3707 | case 't': |
| 3708 | flags.end_top = negated ? 0 : inum; |
| 3709 | break; |
| 3710 | case 'a': |
| 3711 | flags.end_around = negated ? 0 : inum; |
| 3712 | break; |
| 3713 | case 'o': |
| 3714 | flags.end_own = (negated || !inum) ? FALSE : TRUE; |
| 3715 | break; |
| 3716 | case 'n': /* none */ |
| 3717 | flags.end_top = flags.end_around = 0, flags.end_own = FALSE; |
| 3718 | break; |
| 3719 | case '-': |
| 3720 | if (digit(*(op + 1))) { |
| 3721 | config_error_add( |
| 3722 | "Values for %s:top and %s:around must not be negative", |
| 3723 | allopt[optidx].name, |
| 3724 | allopt[optidx].name); |
| 3725 | return optn_silenterr; |
nothing calls this directly
no test coverage detected