| 1001 | } |
| 1002 | |
| 1003 | RESTORE_WARNING_FORMAT_NONLITERAL |
| 1004 | |
| 1005 | void |
| 1006 | adjabil(int oldlevel, int newlevel) |
| 1007 | { |
| 1008 | const struct innate *abil, *rabil; |
| 1009 | long prevabil, mask = FROMEXPER; |
| 1010 | |
| 1011 | abil = role_abil(Role_switch); |
| 1012 | |
| 1013 | switch (Race_switch) { |
| 1014 | case PM_ELF: |
| 1015 | rabil = elf_abil; |
| 1016 | break; |
| 1017 | case PM_ORC: |
| 1018 | rabil = orc_abil; |
| 1019 | break; |
| 1020 | case PM_HUMAN: |
| 1021 | case PM_DWARF: |
| 1022 | case PM_GNOME: |
| 1023 | default: |
| 1024 | rabil = 0; |
| 1025 | break; |
| 1026 | } |
| 1027 | |
| 1028 | while (abil || rabil) { |
| 1029 | /* Have we finished with the intrinsics list? */ |
| 1030 | if (!abil || !abil->ability) { |
| 1031 | /* Try the race intrinsics */ |
| 1032 | if (!rabil || !rabil->ability) |
| 1033 | break; |
| 1034 | abil = rabil; |
| 1035 | rabil = 0; |
| 1036 | mask = FROMRACE; |
| 1037 | } |
| 1038 | prevabil = *(abil->ability); |
| 1039 | if (oldlevel < abil->ulevel && newlevel >= abil->ulevel) { |
| 1040 | /* Abilities gained at level 1 can never be lost |
| 1041 | * via level loss, only via means that remove _any_ |
| 1042 | * sort of ability. A "gain" of such an ability from |
| 1043 | * an outside source is devoid of meaning, so we set |
| 1044 | * FROMOUTSIDE to avoid such gains. |
| 1045 | */ |
| 1046 | if (abil->ulevel == 1) |
| 1047 | *(abil->ability) |= (mask | FROMOUTSIDE); |
| 1048 | else |
| 1049 | *(abil->ability) |= mask; |
| 1050 | if (!(*(abil->ability) & INTRINSIC & ~mask)) { |
| 1051 | if (*(abil->gainstr)) |
| 1052 | You_feel("%s!", abil->gainstr); |
| 1053 | } |
| 1054 | } else if (oldlevel >= abil->ulevel && newlevel < abil->ulevel) { |
| 1055 | *(abil->ability) &= ~mask; |
| 1056 | if (!(*(abil->ability) & INTRINSIC)) { |
| 1057 | if (*(abil->losestr)) |
| 1058 | You_feel("%s!", abil->losestr); |
| 1059 | else if (*(abil->gainstr)) |
| 1060 | You_feel("less %s!", abil->gainstr); |
no test coverage detected